@ttmg/cli 0.3.9-beta.1 → 0.3.9-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/index.js +224 -82
  2. package/dist/index.js.map +1 -1
  3. package/dist/package.json +1 -1
  4. package/dist/public/assets/Card-CTv745_w.js +1 -0
  5. package/dist/public/assets/Detail-DgPwDVds.js +1 -0
  6. package/dist/public/assets/Detail-DgPwDVds.js.br +0 -0
  7. package/dist/public/assets/MonetizationMode-CqG7VmZX.js +1 -0
  8. package/dist/public/assets/MonetizationModeSummary-BSmi2Vjs.js +1 -0
  9. package/dist/public/assets/SectionHeader-BFCjOsAZ.js +1 -0
  10. package/dist/public/assets/Tag-Cwc1Bal2.js +1 -0
  11. package/dist/public/assets/arrow-left-DrT44p81.js +1 -0
  12. package/dist/public/assets/baseForm-DY0XNYDE.js +10 -0
  13. package/dist/public/assets/baseForm-DY0XNYDE.js.br +0 -0
  14. package/dist/public/assets/baseForm-Dl4zA6hU.css +1 -0
  15. package/dist/public/assets/baseForm-Dl4zA6hU.css.br +0 -0
  16. package/dist/public/assets/chevron-right-DzleLIdl.js +1 -0
  17. package/dist/public/assets/compass-BW4vGO0x.js +1 -0
  18. package/dist/public/assets/index-4NS2mMuQ.css +1 -0
  19. package/dist/public/assets/index-B-AeuNlL.css +1 -0
  20. package/dist/public/assets/index-B-AeuNlL.css.br +0 -0
  21. package/dist/public/assets/index-B3e59WZW.js +1 -0
  22. package/dist/public/assets/{index-tOg_vZEc.js → index-B6NHbQwP.js} +1 -1
  23. package/dist/public/assets/index-B6RZ7AdI.js +1 -0
  24. package/dist/public/assets/index-B6RZ7AdI.js.br +0 -0
  25. package/dist/public/assets/index-BAud2cRu.css +1 -0
  26. package/dist/public/assets/index-BBuCNszs.js +1 -0
  27. package/dist/public/assets/index-BJ1WI0xW.js +14 -0
  28. package/dist/public/assets/index-BJ1WI0xW.js.br +0 -0
  29. package/dist/public/assets/index-BOl1-Siv.css +1 -0
  30. package/dist/public/assets/index-BOl1-Siv.css.br +0 -0
  31. package/dist/public/assets/index-BQiwR45B.js +1 -0
  32. package/dist/public/assets/index-BR2iFF5J.js +1 -0
  33. package/dist/public/assets/index-BR2iFF5J.js.br +0 -0
  34. package/dist/public/assets/index-BbSY5AoV.js +1 -0
  35. package/dist/public/assets/{index-BpefkOoB.js → index-BmP2LC8F.js} +1 -1
  36. package/dist/public/assets/index-Bmw61rl1.css +1 -0
  37. package/dist/public/assets/index-Bmw61rl1.css.br +0 -0
  38. package/dist/public/assets/index-BqUsIqrD.js +1 -0
  39. package/dist/public/assets/index-BqUsIqrD.js.br +0 -0
  40. package/dist/public/assets/{index-Ba1XAQLw.js → index-BrC0aWmM.js} +1 -1
  41. package/dist/public/assets/index-BsEJ06u7.js +1 -0
  42. package/dist/public/assets/index-C-tTmNa4.css +1 -0
  43. package/dist/public/assets/index-C0slAX90.js +1 -0
  44. package/dist/public/assets/index-C0slAX90.js.br +0 -0
  45. package/dist/public/assets/index-CBlaFQAe.js +1 -0
  46. package/dist/public/assets/index-CBlaFQAe.js.br +0 -0
  47. package/dist/public/assets/index-CCIR5x04.js +1 -0
  48. package/dist/public/assets/index-CVrG-aCP.js +1 -0
  49. package/dist/public/assets/index-CYONSh3E.js +1 -0
  50. package/dist/public/assets/index-Cc1ilXmc.css +1 -0
  51. package/dist/public/assets/index-CmVUh50W.css +1 -0
  52. package/dist/public/assets/index-Crx61Qjc.css +1 -0
  53. package/dist/public/assets/index-D-GbEkoB.css +1 -0
  54. package/dist/public/assets/{index-BJQfbNPd.js → index-DYNaiQIB.js} +1 -1
  55. package/dist/public/assets/index-Dvg_oNs7.css +1 -0
  56. package/dist/public/assets/{index-CgAbOvxk.css → index-ROKxx4f7.css} +1 -1
  57. package/dist/public/assets/index-ROKxx4f7.css.br +0 -0
  58. package/dist/public/assets/index-RYY-l6Oq.css +1 -0
  59. package/dist/public/assets/{index-BUDAPXlB.js → index-TElbHITb.js} +1 -1
  60. package/dist/public/assets/{index-f0PBkQd9.js → index-Yv0czelv.js} +1 -1
  61. package/dist/public/assets/index-ZYC8SS17.js +1 -0
  62. package/dist/public/assets/index-faRHENEQ.css +1 -0
  63. package/dist/public/assets/sparkles-KMi7bfJ3.js +1 -0
  64. package/dist/public/assets/zap-BlvSLoGD.js +1 -0
  65. package/dist/public/index.html +11 -8
  66. package/package.json +1 -1
  67. package/CHANGELOG.md +0 -228
  68. package/dist/public/assets/Detail-CqXvsvPM.js +0 -1
  69. package/dist/public/assets/Detail-CqXvsvPM.js.br +0 -0
  70. package/dist/public/assets/MonetizationMode-2bp9UZWM.js +0 -1
  71. package/dist/public/assets/MonetizationModeSummary-DBtIQq9Z.js +0 -1
  72. package/dist/public/assets/baseForm-BFkpAlns.js +0 -10
  73. package/dist/public/assets/baseForm-BFkpAlns.js.br +0 -0
  74. package/dist/public/assets/baseForm-CB6KCNqW.css +0 -1
  75. package/dist/public/assets/baseForm-CB6KCNqW.css.br +0 -0
  76. package/dist/public/assets/index-88dZ53Te.css +0 -1
  77. package/dist/public/assets/index-88dZ53Te.css.br +0 -0
  78. package/dist/public/assets/index-B6ZeUJlM.js +0 -1
  79. package/dist/public/assets/index-BFePHKNX.js +0 -1
  80. package/dist/public/assets/index-BFePHKNX.js.br +0 -0
  81. package/dist/public/assets/index-BPzYPKPA.js +0 -1
  82. package/dist/public/assets/index-BRFS2ZhY.css +0 -1
  83. package/dist/public/assets/index-BRFS2ZhY.css.br +0 -0
  84. package/dist/public/assets/index-BYgShzrj.js +0 -1
  85. package/dist/public/assets/index-Bf6aJOeV.css +0 -1
  86. package/dist/public/assets/index-Bf85t01Q.css +0 -1
  87. package/dist/public/assets/index-Bf85t01Q.css.br +0 -0
  88. package/dist/public/assets/index-BnU4EHWL.css +0 -1
  89. package/dist/public/assets/index-BnU4EHWL.css.br +0 -0
  90. package/dist/public/assets/index-BvxhyFWU.js +0 -14
  91. package/dist/public/assets/index-BvxhyFWU.js.br +0 -0
  92. package/dist/public/assets/index-BwbPFgZF.css +0 -1
  93. package/dist/public/assets/index-C06KDNuj.css +0 -1
  94. package/dist/public/assets/index-CH7igbHY.css +0 -1
  95. package/dist/public/assets/index-CL2qDQto.js +0 -1
  96. package/dist/public/assets/index-CLgcHgzd.css +0 -1
  97. package/dist/public/assets/index-CMUKwrEm.js +0 -1
  98. package/dist/public/assets/index-CRAXXzpR.js +0 -1
  99. package/dist/public/assets/index-CRAXXzpR.js.br +0 -0
  100. package/dist/public/assets/index-CgAbOvxk.css.br +0 -0
  101. package/dist/public/assets/index-DNsJSSmy.css +0 -1
  102. package/dist/public/assets/index-DY13Lo-E.js +0 -1
  103. package/dist/public/assets/index-DY13Lo-E.js.br +0 -0
  104. package/dist/public/assets/index-DqFmR7Qk.css +0 -1
  105. package/dist/public/assets/index-FFfimhRp.js +0 -1
  106. package/dist/public/assets/index-FFfimhRp.js.br +0 -0
  107. package/dist/public/assets/index-OLBa9viz.js +0 -1
  108. package/dist/public/assets/index-OsVhWD4K.js +0 -1
  109. package/dist/public/assets/index-lKrpiZfQ.js +0 -1
  110. package/dist/public/assets/index-lKrpiZfQ.js.br +0 -0
  111. package/dist/public/assets/times-C1GmugF6.js +0 -1
  112. package/dist/public/assets/times-C7C5ulLg.css +0 -1
package/dist/index.js CHANGED
@@ -6588,9 +6588,30 @@ function buildCookieHeaderFromSetCookies(setCookies) {
6588
6588
  return sanitizeCookieHeader(setCookies.join('; '));
6589
6589
  }
6590
6590
 
6591
+ /**
6592
+ * Verbose logging helpers.
6593
+ *
6594
+ * The CLI registers a global `--verbose` flag (see `src/index.ts`). Detailed
6595
+ * diagnostic logs — HTTP request/response bodies, the local wasm split
6596
+ * pipeline's `[wasmtool]` / `[wasm-split]` / `[download]` breadcrumbs — should
6597
+ * only surface when the user explicitly opts in, so the default `ttmg dev`
6598
+ * output stays readable.
6599
+ *
6600
+ * Genuine failures must keep using `console.error` directly so they are always
6601
+ * visible regardless of `--verbose`.
6602
+ */
6591
6603
  function isVerboseEnabled() {
6592
6604
  return process.argv.includes('--verbose');
6593
6605
  }
6606
+ function verboseLog(...args) {
6607
+ if (isVerboseEnabled())
6608
+ console.log(...args);
6609
+ }
6610
+ function verboseWarn(...args) {
6611
+ if (isVerboseEnabled())
6612
+ console.warn(...args);
6613
+ }
6614
+
6594
6615
  /**
6595
6616
  * PPE / 测试环境开关。
6596
6617
  *
@@ -6749,7 +6770,7 @@ function printApiResponseLog(title, result) {
6749
6770
  ['Return Value', result.data],
6750
6771
  ]);
6751
6772
  }
6752
- async function request({ url, method, data, headers, params, }) {
6773
+ async function request({ url, method, data, headers, params, logRequestBody = true, }) {
6753
6774
  const config = getTTMGRC();
6754
6775
  const cookie = sanitizeCookieHeader(config?.cookie);
6755
6776
  const proxyConfig = getAxiosProxyConfig();
@@ -6757,7 +6778,9 @@ async function request({ url, method, data, headers, params, }) {
6757
6778
  printApiRequestLog({
6758
6779
  url,
6759
6780
  method,
6760
- params: getRequestParams(params, data),
6781
+ params: logRequestBody
6782
+ ? getRequestParams(params, data)
6783
+ : '[omitted: large request body]',
6761
6784
  });
6762
6785
  }
6763
6786
  try {
@@ -6821,7 +6844,7 @@ async function download(url, filePath) {
6821
6844
  catch { }
6822
6845
  }
6823
6846
  const proxyConfig = getAxiosProxyConfig();
6824
- console.log('[download] start', { url: url.slice(0, 120), filePath, hasProxy: !!proxyConfig.httpsAgent });
6847
+ verboseLog('[download] start', { url: url.slice(0, 120), filePath, hasProxy: !!proxyConfig.httpsAgent });
6825
6848
  try {
6826
6849
  const res = await axios.get(url, {
6827
6850
  responseType: 'stream',
@@ -6857,7 +6880,7 @@ async function download(url, filePath) {
6857
6880
  };
6858
6881
  const onClose = () => {
6859
6882
  cleanup();
6860
- console.log(`[download] done: ${received} bytes in ${Date.now() - startedAt}ms`);
6883
+ verboseLog(`[download] done: ${received} bytes in ${Date.now() - startedAt}ms`);
6861
6884
  resolve();
6862
6885
  };
6863
6886
  const cleanup = () => {
@@ -6875,7 +6898,7 @@ async function download(url, filePath) {
6875
6898
  const pct = Math.floor((received / total) * 10) * 10;
6876
6899
  if (pct !== lastLoggedPct) {
6877
6900
  lastLoggedPct = pct;
6878
- console.log(`[download] ${pct}% (${received}/${total})`);
6901
+ verboseLog(`[download] ${pct}% (${received}/${total})`);
6879
6902
  }
6880
6903
  }
6881
6904
  };
@@ -6889,7 +6912,7 @@ async function download(url, filePath) {
6889
6912
  return { ok: true };
6890
6913
  }
6891
6914
  catch (err) {
6892
- console.log('[download] failed:', err?.message);
6915
+ verboseLog('[download] failed:', err?.message);
6893
6916
  if (isAxiosError(err) && err.response?.status === 403) {
6894
6917
  throw new Error('下载链接已过期,请重新进行分包后重试');
6895
6918
  }
@@ -9332,6 +9355,68 @@ const gameCheckRoute = {
9332
9355
  };
9333
9356
 
9334
9357
  const changelog = [
9358
+ {
9359
+ title: '0.3.9',
9360
+ target: {
9361
+ iOS: '>=43.1',
9362
+ Android: '>=43.1',
9363
+ },
9364
+ changes: {
9365
+ optimize: [
9366
+ {
9367
+ desc: {
9368
+ 'zh-CN': '调试 IDE 默认使用浅色主题,暗色模式改为手动开启并记忆选择,避免跟随系统强制进入暗色导致不适应',
9369
+ 'en-US': 'The debugging IDE now defaults to the light theme. Dark mode is opt-in and your choice is remembered, so it no longer follows the system and forces an unexpected dark UI.',
9370
+ },
9371
+ module: 'new',
9372
+ },
9373
+ {
9374
+ desc: {
9375
+ 'zh-CN': '优化暗色模式下二维码显示,调整背景避免过亮刺眼,同时保证扫码识别率',
9376
+ 'en-US': 'Improve the QR code in dark mode by toning down the background so it is no longer glaring while staying easy to scan.',
9377
+ },
9378
+ module: 'scanQrcode',
9379
+ },
9380
+ {
9381
+ desc: {
9382
+ 'zh-CN': 'Wasm 分包页面及相关组件补齐多语言,修复页面文案中英文混排的问题',
9383
+ 'en-US': 'Complete localization for the Wasm Code Split page and its components, fixing the mixed Chinese/English text.',
9384
+ },
9385
+ module: 'check',
9386
+ },
9387
+ {
9388
+ desc: {
9389
+ 'zh-CN': '能力接入助手页面视觉升级:变现模式卡片新增图标与强调色,关键能力标签按「必需 / 可选 / 实验」分级展示,信息层级更清晰',
9390
+ 'en-US': 'Refresh the Capability Integration Assistant: monetization-mode cards get icons and accent colors, and capability tags are grouped as Required / Optional / Experimental for a clearer hierarchy.',
9391
+ },
9392
+ module: 'new',
9393
+ },
9394
+ {
9395
+ desc: {
9396
+ 'zh-CN': '完成扫码连接后,首页标题与说明文案会切换为「已连接」状态,状态反馈更明确',
9397
+ 'en-US': 'After scanning to connect, the home page title and subtitle switch to a "connected" state for clearer feedback.',
9398
+ },
9399
+ module: 'scanQrcode',
9400
+ },
9401
+ {
9402
+ desc: {
9403
+ 'zh-CN': '新版本提示由红点改为「有更新」文字标签,含义更直观;上传游戏包按钮配色与产品主题色统一',
9404
+ 'en-US': 'Replace the ambiguous red dot for new versions with an explicit "Update available" label, and align the upload button color with the product theme.',
9405
+ },
9406
+ module: 'new',
9407
+ },
9408
+ ],
9409
+ bugfix: [
9410
+ {
9411
+ desc: {
9412
+ 'zh-CN': '修复多个页面中区块标题与正文内容未对齐的问题,整体排版更整齐',
9413
+ 'en-US': 'Fix section titles that were misaligned with their body content across multiple pages for a tidier layout.',
9414
+ },
9415
+ module: 'new',
9416
+ },
9417
+ ],
9418
+ },
9419
+ },
9335
9420
  {
9336
9421
  title: '0.3.8',
9337
9422
  target: {
@@ -10590,7 +10675,7 @@ async function startPrepare$1(params) {
10590
10675
  const preparedWasmPath = path$1.join(tempDir, 'prepared.wasm');
10591
10676
  try {
10592
10677
  const result = ttmgWasmtool.prepare(rawWasmPath, preparedWasmPath);
10593
- console.log(`[wasmtool] prepare done: ${result.outputSize} bytes, ${result.timeCost}s`);
10678
+ verboseLog(`[wasmtool] prepare done: ${result.outputSize} bytes, ${result.timeCost}s`);
10594
10679
  const gameJson = getGameJson();
10595
10680
  const totalWasmFuncCount = gameJson.wasmFuncCount ?? 0;
10596
10681
  const wasmSize = fs$1.existsSync(inputPath)
@@ -10624,13 +10709,13 @@ async function startPrepare$1(params) {
10624
10709
  const preparedMd5 = fs$1.existsSync(preparedWasmPath)
10625
10710
  ? crypto$1.createHash('md5').update(fs$1.readFileSync(preparedWasmPath)).digest('hex')
10626
10711
  : '<missing>';
10627
- console.log(`[wasmtool] prepare sanity: raw(size=${rawSize} md5=${rawMd5}) -> prepared(size=${preparedSize} md5=${preparedMd5}) delta=${preparedSize - rawSize}`);
10712
+ verboseLog(`[wasmtool] prepare sanity: raw(size=${rawSize} md5=${rawMd5}) -> prepared(size=${preparedSize} md5=${preparedMd5}) delta=${preparedSize - rawSize}`);
10628
10713
  if (preparedSize <= rawSize || preparedMd5 === rawMd5) {
10629
- console.warn('[wasmtool] WARNING: prepared wasm is not larger / md5 is unchanged vs raw wasm. Instrumentation likely did not happen.');
10714
+ verboseWarn('[wasmtool] WARNING: prepared wasm is not larger / md5 is unchanged vs raw wasm. Instrumentation likely did not happen.');
10630
10715
  }
10631
- console.log('[wasmtool] compressing prepared wasm (quality=9)...');
10716
+ verboseLog('[wasmtool] compressing prepared wasm (quality=9)...');
10632
10717
  await compressWasmFile(preparedWasmPath, willReplaceWasmPath);
10633
- console.log('[wasmtool] compressed and written to project');
10718
+ verboseLog('[wasmtool] compressed and written to project');
10634
10719
  // Diagnostic: confirm the file the client actually fetches was overwritten,
10635
10720
  // and compare to the cached original brotli so we can prove on-disk replacement.
10636
10721
  const replacedSize = fs$1.existsSync(willReplaceWasmPath)
@@ -10649,12 +10734,12 @@ async function startPrepare$1(params) {
10649
10734
  .update(fs$1.readFileSync(cachedOriginalBr))
10650
10735
  .digest('hex')
10651
10736
  : '<missing>';
10652
- console.log(`[wasmtool] on-disk replace check: project=${params.wasm_file_path} size=${replacedSize} md5=${replacedMd5} | cached-original size=${cachedOriginalSize} md5=${cachedOriginalMd5}`);
10737
+ verboseLog(`[wasmtool] on-disk replace check: project=${params.wasm_file_path} size=${replacedSize} md5=${replacedMd5} | cached-original size=${cachedOriginalSize} md5=${cachedOriginalMd5}`);
10653
10738
  if (replacedMd5 === cachedOriginalMd5) {
10654
- console.warn('[wasmtool] WARNING: project wasm md5 matches cached-original md5. The file was not actually replaced with the instrumented build.');
10739
+ verboseWarn('[wasmtool] WARNING: project wasm md5 matches cached-original md5. The file was not actually replaced with the instrumented build.');
10655
10740
  }
10656
10741
  else {
10657
- console.log('[wasmtool] OK: project wasm differs from cached-original — instrumented wasm is on disk.');
10742
+ verboseLog('[wasmtool] OK: project wasm differs from cached-original — instrumented wasm is on disk.');
10658
10743
  }
10659
10744
  // Local pipeline uses the new wasm-collect/v1/report API + archive sub-wasm.
10660
10745
  // ORIGINALWASMMD5 must be set now (not only at split time) so the plugin
@@ -10664,7 +10749,7 @@ async function startPrepare$1(params) {
10664
10749
  ENABLEARCHIVEMODE: true,
10665
10750
  ORIGINALWASMMD5: params.wasm_md5,
10666
10751
  });
10667
- console.log('[wasmtool] wasm split config updated (local pipeline: archive=true)');
10752
+ verboseLog('[wasmtool] wasm split config updated (local pipeline: archive=true)');
10668
10753
  // Disk-persisted anchor for "wasm drift" detection in
10669
10754
  // `game-wasm-split-config` route. Stores the md5 that prepare just
10670
10755
  // wrote into the project alongside the project-relative path. The
@@ -10678,7 +10763,7 @@ async function startPrepare$1(params) {
10678
10763
  preparedWasmMd5: replacedMd5,
10679
10764
  codePath: params.wasm_file_path,
10680
10765
  });
10681
- console.log(`[wasmtool] prepared-meta written: md5=${replacedMd5} codePath=${params.wasm_file_path}`);
10766
+ verboseLog(`[wasmtool] prepared-meta written: md5=${replacedMd5} codePath=${params.wasm_file_path}`);
10682
10767
  return {
10683
10768
  data: {
10684
10769
  code: 0,
@@ -10787,42 +10872,30 @@ async function startWasmSession({ client_key, wasm_md5, reset, }) {
10787
10872
  }
10788
10873
 
10789
10874
  /**
10790
- * "开始收集" 的本地 pipeline 实现。语义上等价于老远程流程的
10791
- * `stark_wasm/v4/post/set_collecting`:**打开 server 端的 collect 窗口**,
10792
- * 让 plugin 之后的 `/report` 请求能落库。
10875
+ * 打开 server 端 collect session(本地 pipeline 的 `/start`)。
10793
10876
  *
10794
- * 做三件事(顺序敏感):
10795
- * 1. `POST /start` 打开 session —— 失败必须立即返回给 IDE,
10796
- * 否则 UI 会让用户进"正在收集"但实际 plugin 所有上报都会被 fail-close
10797
- * 丢弃,场面非常悲伤。
10798
- * 2. 成功后上传符号表(`/symbols`)。这一步故意不 await、错误仅 warn —
10799
- * 符号表只是给 server 端后续调试用的 debug 信息,丢了也不影响分包主链路。
10800
- * 3. 返回 `{code: 0}`。
10877
+ * 这是**鉴权门**:`/start` 走 Portal 鉴权中间件,登录态失效会返回 `-401`
10878
+ * (或带登录关键字的 `-1`)。鉴权失败必须立即把错误回给 IDE 并中止——
10879
+ * 否则用户进了"正在收集",但 plugin 之后所有 `/report` 都会被 fail-close
10880
+ * 丢弃,函数数量永远 0,且很难归因。
10801
10881
  *
10802
- * 两种调用语义(与 `wasm_api.md` §5.1 对齐):
10803
- * - 默认(`resume` 缺省 / false)—— 用户点"开始收集 / 重新开始分包",
10804
- * `reset: true`,服务端清空历史。这是历史行为,对应 IDE 上的
10805
- * "willCollect startCollect" 主入口。
10806
- * - `resume: true` —— 页面刷新 / 恢复继续,发 `reset: false`,幂等
10807
- * 打开 session、保留已有 func_ids。需要这条路径的 caller(如 IDE
10808
- * 重新挂载组件检测到 server `collect_state: "open"` 想接续)必须
10809
- * 显式传,避免误清。
10882
+ * IDE 通过独立路由 `/game/wasm-collect-start` 调用本函数,所以它在浏览器
10883
+ * Network 里是一条可见且**明确叫 start** 的请求——出鉴权问题时一眼能定位到
10884
+ * 是开 session 这步失败,而不是被误认为 collect 轮询接口的问题。symbols
10885
+ * 上传是另一步(`uploadCollectSymbols`),与开 session 解耦。
10810
10886
  *
10811
- * Session 生命周期对前端透明——IDE 只知道"开始收集 / 完成收集"两个动作,
10812
- * `/start` `/finish` 都被封在本地 dispatcher 内。这样远程 pipeline(没有
10813
- * session 概念)和本地 pipeline(有 session)在 IDE 层看起来是对称的。
10887
+ * 两种语义(与 `wasm_api.md` §5.1 对齐):
10888
+ * - 默认(`resume` 缺省 / false)→ `reset: true`,服务端清空历史。
10889
+ * - `resume: true` `reset: false`,幂等打开、保留已有 func_ids。
10814
10890
  */
10815
- async function setCollect$1({ client_key, wasm_md5, resume, }) {
10891
+ async function openCollectSession$1({ client_key, wasm_md5, resume, }) {
10816
10892
  const startRes = await startWasmSession({
10817
10893
  client_key,
10818
10894
  wasm_md5,
10819
10895
  reset: !resume,
10820
10896
  });
10821
10897
  if (startRes.error || !startRes.data || startRes.data.code !== 0) {
10822
- // /start is invoked internally by setCollect now; IDE only sees this
10823
- // bubbled up as a generic "开始收集失败" toast, so dump a structured
10824
- // one-liner here with logid — the single most useful field when
10825
- // asking backend to look up what happened on their side.
10898
+ // 结构化日志带 logid——找后端排查鉴权/会话问题时最有用的字段。
10826
10899
  const code = startRes.error?.code ?? startRes.data?.code ?? -1;
10827
10900
  const message = startRes.error?.message ||
10828
10901
  startRes.data?.message ||
@@ -10835,6 +10908,20 @@ async function setCollect$1({ client_key, wasm_md5, resume, }) {
10835
10908
  ctx: startRes.ctx,
10836
10909
  };
10837
10910
  }
10911
+ return {
10912
+ data: { code: 0, message: 'success', result: startRes.data.result },
10913
+ error: null,
10914
+ ctx: startRes.ctx,
10915
+ };
10916
+ }
10917
+ /**
10918
+ * 上传符号表(`/symbols`)。只在 session 已打开后调用。
10919
+ *
10920
+ * 符号表只是给 server 端后续调试用的 debug 信息,丢了不影响分包主链路,
10921
+ * 所以这里故意不 await、失败仅 warn,且总是返回 `{code: 0}`——它不应该
10922
+ * 阻塞或失败掉"开始收集"流程。
10923
+ */
10924
+ async function uploadCollectSymbols$1({ client_key, wasm_md5, }) {
10838
10925
  let symbolPath = path$1.join(process.cwd(), WASM_SYMBOL_FILE_NAME);
10839
10926
  if (!fs$1.existsSync(symbolPath)) {
10840
10927
  symbolPath = path$1.join(process.cwd(), TTMG_TEMP_DIR, WASM_SYMBOL_FILE_NAME);
@@ -10844,13 +10931,15 @@ async function setCollect$1({ client_key, wasm_md5, resume, }) {
10844
10931
  request({
10845
10932
  url: `${WASM_COLLECT_BASE_URL}/symbols`,
10846
10933
  method: 'POST',
10934
+ // symbols 是整张符号表,verbose 下打出来会刷屏,关掉它的入参日志。
10935
+ logRequestBody: false,
10847
10936
  data: {
10848
10937
  app_id: client_key,
10849
10938
  wasm_md5,
10850
10939
  symbols,
10851
10940
  },
10852
10941
  }).catch(err => {
10853
- console.warn('[wasmtool] Failed to upload symbols:', err);
10942
+ verboseWarn('[wasmtool] Failed to upload symbols:', err);
10854
10943
  });
10855
10944
  }
10856
10945
  return {
@@ -10963,7 +11052,7 @@ async function startSplit$1({ client_key, wasm_md5, }) {
10963
11052
  ctx: { logid: 'local', httpStatusCode: 400 },
10964
11053
  };
10965
11054
  }
10966
- console.log(`[wasmtool] splitting with ${funcIds.length} func IDs` +
11055
+ verboseLog(`[wasmtool] splitting with ${funcIds.length} func IDs` +
10967
11056
  (bootFuncIds.length > 0
10968
11057
  ? `, ${bootFuncIds.length} boot-phase func IDs (→ alwaysInclude)`
10969
11058
  : ', no boot-phase info (legacy server, falling back to callClosure only)') +
@@ -11023,14 +11112,14 @@ async function startSplit$1({ client_key, wasm_md5, }) {
11023
11112
  const actualArchivePath = fs$1.existsSync(archiveBrPath)
11024
11113
  ? archiveBrPath
11025
11114
  : result.archivePath;
11026
- console.log(`[wasmtool] archivePath=${result.archivePath}, brExists=${fs$1.existsSync(archiveBrPath)}, actualExists=${fs$1.existsSync(actualArchivePath)}`);
11115
+ verboseLog(`[wasmtool] archivePath=${result.archivePath}, brExists=${fs$1.existsSync(archiveBrPath)}, actualExists=${fs$1.existsSync(actualArchivePath)}`);
11027
11116
  if (fs$1.existsSync(actualArchivePath)) {
11028
11117
  archiveMd5 = computeFileMd5Sync(actualArchivePath);
11029
- console.log(`[wasmtool] archive_md5=${archiveMd5}`);
11118
+ verboseLog(`[wasmtool] archive_md5=${archiveMd5}`);
11030
11119
  }
11031
11120
  }
11032
11121
  else {
11033
- console.log(`[wasmtool] skip archive md5: archive=${archive}, archivePath=${result.archivePath}`);
11122
+ verboseLog(`[wasmtool] skip archive md5: archive=${archive}, archivePath=${result.archivePath}`);
11034
11123
  }
11035
11124
  const globalVarList = result.globalVarList
11036
11125
  .split(';')
@@ -11072,7 +11161,7 @@ async function startSplit$1({ client_key, wasm_md5, }) {
11072
11161
  export_added: result.exportAdded,
11073
11162
  };
11074
11163
  setLocalState({ splitOutputDir, splitMeta });
11075
- console.log(`[wasmtool] split done: total=${result.totalWasmCount}, main=${result.mainWasmCount} ` +
11164
+ verboseLog(`[wasmtool] split done: total=${result.totalWasmCount}, main=${result.mainWasmCount} ` +
11076
11165
  `(collect=${result.collectFuncCount}, +alwaysInclude=${result.alwaysIncludeAdded}, ` +
11077
11166
  `+closure=${result.closureAdded}, +indirectClosure=${result.indirectClosureAdded}` +
11078
11167
  `[types=${result.indirectClosureTypes}], +exports=${result.exportAdded}), ` +
@@ -11177,7 +11266,7 @@ async function downloadSplited$1(_context) {
11177
11266
  const dirs = [...new Set([mainAndroidDir, subAndroidDir, mainIosDir, subIosDir])];
11178
11267
  dirs.forEach(ensureDirSync);
11179
11268
  try {
11180
- console.log('[wasmtool] organizing split output...');
11269
+ verboseLog('[wasmtool] organizing split output...');
11181
11270
  const mainWasmMd5 = splitMeta.main_wasm_md5;
11182
11271
  const subWasmMd5 = splitMeta.sub_wasm_md5;
11183
11272
  const mainWasmH5Md5 = splitMeta.main_wasm_h5_md5;
@@ -11220,20 +11309,20 @@ async function downloadSplited$1(_context) {
11220
11309
  if (isArchive && localArchivePath) {
11221
11310
  const archiveBrPath = localArchivePath + BR_SUFFIX;
11222
11311
  const actualArchivePath = fs.existsSync(archiveBrPath) ? archiveBrPath : localArchivePath;
11223
- console.log(`[wasmtool] archive copy: archive_md5=${splitMeta.archive_md5}, localPath=${localArchivePath}, brExists=${fs.existsSync(archiveBrPath)}, actual=${actualArchivePath}`);
11312
+ verboseLog(`[wasmtool] archive copy: archive_md5=${splitMeta.archive_md5}, localPath=${localArchivePath}, brExists=${fs.existsSync(archiveBrPath)}, actual=${actualArchivePath}`);
11224
11313
  if (fs.existsSync(actualArchivePath)) {
11225
11314
  const archiveMd5 = splitMeta.archive_md5 || '';
11226
11315
  const archiveBaseName = path.basename(actualArchivePath);
11227
11316
  const destName = archiveMd5 ? `${archiveMd5}.${archiveBaseName}` : archiveBaseName;
11228
11317
  const archiveDest = path.join(subIosDir, destName);
11229
- console.log(`[wasmtool] archive dest: ${archiveDest}`);
11318
+ verboseLog(`[wasmtool] archive dest: ${archiveDest}`);
11230
11319
  fs.copyFileSync(actualArchivePath, archiveDest);
11231
11320
  }
11232
11321
  }
11233
11322
  dirs.forEach((dir) => {
11234
11323
  fs.writeFileSync(path.join(dir, 'game.js'), '', { encoding: 'utf-8' });
11235
11324
  });
11236
- console.log('[wasmtool] copy split output to root...');
11325
+ verboseLog('[wasmtool] copy split output to root...');
11237
11326
  wsServer.sendUnitySplitStatus({ status: 'start_write_splited_wasm_br' });
11238
11327
  for (const file of fs.readdirSync(splitTempDir)) {
11239
11328
  const srcPath = path.join(splitTempDir, file);
@@ -11244,9 +11333,9 @@ async function downloadSplited$1(_context) {
11244
11333
  await promises.cp(srcPath, destPath, { recursive: true, force: true });
11245
11334
  }
11246
11335
  wsServer.sendUnitySplitStatus({ status: 'write_splited_wasm_done' });
11247
- console.log('[wasmtool] updating subpackage config...');
11336
+ verboseLog('[wasmtool] updating subpackage config...');
11248
11337
  updateSubpackageConfigSync(isArchive);
11249
- console.log('[wasmtool] updating wasm split config...');
11338
+ verboseLog('[wasmtool] updating wasm split config...');
11250
11339
  wsServer.sendUnitySplitStatus({ status: 'start_update_wasm_split_config' });
11251
11340
  updateWasmSplitConfig({
11252
11341
  ENABLEWASMCOLLECT: true,
@@ -11464,7 +11553,7 @@ async function downloadOne(opts) {
11464
11553
  const willDownloadedFileIsBr = url.includes(BR_SUFFIX);
11465
11554
  const finalOut = willDownloadedFileIsBr && !out.endsWith(BR_SUFFIX) ? out + BR_SUFFIX : out;
11466
11555
  wsServer.sendUnitySplitStatus({ status: startStatus });
11467
- console.log(`[remote-split-download] fetching -> ${finalOut}`);
11556
+ verboseLog(`[remote-split-download] fetching -> ${finalOut}`);
11468
11557
  const t0 = Date.now();
11469
11558
  await withRetry(() => download(url, finalOut), DOWNLOAD_RETRY);
11470
11559
  const st = await promises.stat(finalOut);
@@ -11472,7 +11561,7 @@ async function downloadOne(opts) {
11472
11561
  await promises.rm(finalOut, { force: true });
11473
11562
  throw new Error(`Empty download: ${finalOut}`);
11474
11563
  }
11475
- console.log(`[remote-split-download] done: ${path.basename(finalOut)} size=${st.size}B time=${Date.now() - t0}ms`);
11564
+ verboseLog(`[remote-split-download] done: ${path.basename(finalOut)} size=${st.size}B time=${Date.now() - t0}ms`);
11476
11565
  wsServer.sendUnitySplitStatus({ status: doneStatus, url });
11477
11566
  // Legacy behaviour: write an empty game.js next to each downloaded artifact
11478
11567
  // so the subpackage loader doesn't complain about missing js entries.
@@ -11492,7 +11581,7 @@ async function downloadSplitedRemote(context) {
11492
11581
  const mainIosOut = path.join(mainIosDir, `${context.main_wasm_h5_md5}${WASM_FILENAME_SUFFIX}`);
11493
11582
  const limit = pLimit(CONCURRENCY_LIMIT);
11494
11583
  try {
11495
- console.log('[remote-split-download] start', {
11584
+ verboseLog('[remote-split-download] start', {
11496
11585
  original_wasm_md5: context.original_wasm_md5,
11497
11586
  main_wasm_md5: context.main_wasm_md5,
11498
11587
  sub_wasm_md5: context.sub_wasm_md5,
@@ -11530,7 +11619,7 @@ async function downloadSplitedRemote(context) {
11530
11619
  out: path.join(subIosDir, 'subjs.data'),
11531
11620
  })),
11532
11621
  ]);
11533
- console.log('[remote-split-download] copying split output to project root...');
11622
+ verboseLog('[remote-split-download] copying split output to project root...');
11534
11623
  wsServer.sendUnitySplitStatus({ status: 'start_write_splited_wasm_br' });
11535
11624
  for (const file of fs.readdirSync(splitTempDir)) {
11536
11625
  const srcPath = path.join(splitTempDir, file);
@@ -11541,9 +11630,9 @@ async function downloadSplitedRemote(context) {
11541
11630
  await promises.cp(srcPath, destPath, { recursive: true, force: true });
11542
11631
  }
11543
11632
  wsServer.sendUnitySplitStatus({ status: 'write_splited_wasm_done' });
11544
- console.log('[remote-split-download] updating subpackage config...');
11633
+ verboseLog('[remote-split-download] updating subpackage config...');
11545
11634
  updateSubpackageConfigSync(false);
11546
- console.log('[remote-split-download] updating webgl-wasm-split.js...');
11635
+ verboseLog('[remote-split-download] updating webgl-wasm-split.js...');
11547
11636
  wsServer.sendUnitySplitStatus({ status: 'start_update_wasm_split_config' });
11548
11637
  updateWasmSplitConfig({
11549
11638
  ENABLEWASMCOLLECT: true,
@@ -11560,12 +11649,12 @@ async function downloadSplitedRemote(context) {
11560
11649
  USINGWASMH5: Boolean(context.main_wasm_h5_md5),
11561
11650
  });
11562
11651
  wsServer.sendUnitySplitStatus({ status: 'update_wasm_split_config_done' });
11563
- console.log('[remote-split-download] all done');
11652
+ verboseLog('[remote-split-download] all done');
11564
11653
  return { data: { isSuccess: true }, ctx: context };
11565
11654
  }
11566
11655
  catch (err) {
11567
11656
  const message = err instanceof Error ? err.message : String(err);
11568
- console.log('[remote-split-download] failed:', message);
11657
+ verboseLog('[remote-split-download] failed:', message);
11569
11658
  wsServer.sendUnitySplitStatus({ status: 'wasm_split_failed', errorMsg: message });
11570
11659
  return {
11571
11660
  data: { isSuccess: false },
@@ -11890,7 +11979,7 @@ async function downloadPreparedRemote(data) {
11890
11979
  try {
11891
11980
  const downloadUrl = res?.data?.result?.download_url;
11892
11981
  if (!downloadUrl) {
11893
- console.log('[remote-download-prepared] no download_url in response');
11982
+ verboseLog('[remote-download-prepared] no download_url in response');
11894
11983
  return {
11895
11984
  isSuccess: false,
11896
11985
  error: { code: res.data?.code, message: res.data?.message || 'No download_url returned' },
@@ -11903,28 +11992,28 @@ async function downloadPreparedRemote(data) {
11903
11992
  originalWasmPath: data.wasm_path,
11904
11993
  originalSplitConfigPath: WASM_SPLIT_CONFIG_FILE_NAME,
11905
11994
  });
11906
- console.log(`[remote-download-prepared] target=${willReplaceWasmPath}`);
11995
+ verboseLog(`[remote-download-prepared] target=${willReplaceWasmPath}`);
11907
11996
  if (downloadUrl.includes('.br')) {
11908
11997
  const tempWasmPath = path$1.join(cacheDir, '__temp__.wasm.br');
11909
- console.log('[remote-download-prepared] downloading (br) ->', tempWasmPath);
11998
+ verboseLog('[remote-download-prepared] downloading (br) ->', tempWasmPath);
11910
11999
  wsServer.sendUnitySplitStatus({ status: 'start_download_prepared_wasm', url: downloadUrl });
11911
12000
  const startedAt = Date.now();
11912
12001
  await download(downloadUrl, tempWasmPath);
11913
- console.log(`[remote-download-prepared] download done in ${Date.now() - startedAt}ms, size=${fs$1.statSync(tempWasmPath).size}`);
12002
+ verboseLog(`[remote-download-prepared] download done in ${Date.now() - startedAt}ms, size=${fs$1.statSync(tempWasmPath).size}`);
11914
12003
  fs$1.copyFileSync(tempWasmPath, willReplaceWasmPath);
11915
12004
  wsServer.sendUnitySplitStatus({ status: 'download_prepared_wasm_done', url: downloadUrl });
11916
12005
  }
11917
12006
  else {
11918
12007
  const tempWasmPath = path$1.join(cacheDir, '__temp__.wasm');
11919
- console.log('[remote-download-prepared] downloading (raw) ->', tempWasmPath);
12008
+ verboseLog('[remote-download-prepared] downloading (raw) ->', tempWasmPath);
11920
12009
  wsServer.sendUnitySplitStatus({ status: 'start_download_prepared_wasm', url: downloadUrl });
11921
12010
  const startedAt = Date.now();
11922
12011
  await download(downloadUrl, tempWasmPath);
11923
- console.log(`[remote-download-prepared] download done in ${Date.now() - startedAt}ms, size=${fs$1.statSync(tempWasmPath).size}`);
12012
+ verboseLog(`[remote-download-prepared] download done in ${Date.now() - startedAt}ms, size=${fs$1.statSync(tempWasmPath).size}`);
11924
12013
  wsServer.sendUnitySplitStatus({ status: 'download_prepared_wasm_done', url: downloadUrl });
11925
12014
  wsServer.sendUnitySplitStatus({ status: 'start_compress_prepared_wasm' });
11926
12015
  await compressWasmFile(tempWasmPath, willReplaceWasmPath);
11927
- console.log('[remote-download-prepared] compressed and written to project');
12016
+ verboseLog('[remote-download-prepared] compressed and written to project');
11928
12017
  wsServer.sendUnitySplitStatus({ status: 'compress_prepared_wasm_done', url: downloadUrl });
11929
12018
  wsServer.sendUnitySplitStatus({ status: 'write_compress_prepared_wasm_done' });
11930
12019
  }
@@ -11942,11 +12031,11 @@ async function downloadPreparedRemote(data) {
11942
12031
  data.wasm_md5,
11943
12032
  });
11944
12033
  wsServer.sendUnitySplitStatus({ status: 'update_wasm_split_config_done' });
11945
- console.log('[remote-download-prepared] split config updated, returning success');
12034
+ verboseLog('[remote-download-prepared] split config updated, returning success');
11946
12035
  return { isSuccess: true, ctx: res?.ctx };
11947
12036
  }
11948
12037
  catch (error) {
11949
- console.log('[remote-download-prepared] error:', error);
12038
+ verboseLog('[remote-download-prepared] error:', error);
11950
12039
  return {
11951
12040
  isSuccess: false,
11952
12041
  error: { code: res.data?.code, message: error instanceof Error ? error.message : String(error) },
@@ -11960,7 +12049,21 @@ function isLocal() {
11960
12049
  }
11961
12050
  const startPrepare = (params) => isLocal() ? startPrepare$1(params) : startPrepareRemote(params);
11962
12051
  const downloadPrepared = (params) => isLocal() ? downloadPrepared$1() : downloadPreparedRemote(params);
11963
- const setCollect = (params) => isLocal() ? setCollect$1(params) : setCollectRemote(params);
12052
+ // collect session(鉴权门)。IDE `/game/wasm-collect-start` 调用,
12053
+ // 所以它在浏览器 Network 里是一条独立可见、明确叫 start 的请求。
12054
+ // - 本地 → `/start`
12055
+ // - 远程 → 老的 `set_collecting`(远程没有独立 /start,set_collecting 即开窗)
12056
+ const openCollectSession = (params) => isLocal() ? openCollectSession$1(params) : setCollectRemote(params);
12057
+ // 上传符号表。本地走 `/symbols`(非阻塞、失败不致命);远程在 prepare 阶段
12058
+ // 已随表单上传过 symbol 文件,这里是 no-op,直接返回成功保持两条 pipeline
12059
+ // 在 IDE 层对称。
12060
+ const uploadCollectSymbols = (params) => isLocal()
12061
+ ? uploadCollectSymbols$1(params)
12062
+ : Promise.resolve({
12063
+ data: { code: 0, message: 'success', result: {} },
12064
+ error: null,
12065
+ ctx: { logid: 'remote-noop', httpStatusCode: 200 },
12066
+ });
11964
12067
  const getCollectedFuncIds = (params) => isLocal() ? getCollectedFuncIds$1(params) : getCollectedFuncIdsRemote(params);
11965
12068
  const getCollecttingInfo = (params) => isLocal() ? getCollecttingInfo$1(params) : getCollecttingInfoRemote(params);
11966
12069
  const startSplit = (params) => isLocal() ? startSplit$1(params) : startSplitRemote(params);
@@ -12148,20 +12251,58 @@ const gameWasmPrepareRoute = {
12148
12251
  },
12149
12252
  };
12150
12253
 
12254
+ /**
12255
+ * 上传符号表(`/symbols`)。只在 session 已通过 `/game/wasm-collect-start`
12256
+ * 打开后调用,与"开 session"解耦:
12257
+ * - 鉴权门是 `/game/wasm-collect-start`(→ `/start`),不在这条。
12258
+ * - 这步是非关键的 debug 信息上传,本地非阻塞/失败不致命,远程为 no-op。
12259
+ * 因此即便失败也只回 errorCode 让调用方静默处理,不应阻断"开始收集"。
12260
+ */
12151
12261
  const gameWasmSetCollectRoute = {
12152
12262
  method: 'post',
12153
12263
  path: '/game/wasm-set-collect',
12154
12264
  handler: async (req, res) => {
12155
- // `resume` is optional and only meaningful for the local pipeline:
12156
- // when the IDE detects an existing open session (e.g. user refreshed
12157
- // the page mid-collect) and wants to "继续收集" without nuking the
12158
- // already-uploaded func_ids, it POSTs `{ resume: true }`. Default
12159
- // (omitted / false) keeps the historical "fresh run" behaviour on
12160
- // /start (server gets `reset: true`). See `setCollect` jsdoc for the
12161
- // two-path contract; remote pipeline ignores the field outright.
12265
+ const { clientKey, codeMd5 } = req.body;
12266
+ console.log('wasm-set-collect (upload symbols)', req.body);
12267
+ const response = await uploadCollectSymbols({
12268
+ client_key: clientKey,
12269
+ wasm_md5: codeMd5,
12270
+ });
12271
+ if (response.error) {
12272
+ res.send({
12273
+ code: errorCode,
12274
+ error: response.error,
12275
+ ctx: response.ctx,
12276
+ });
12277
+ }
12278
+ else {
12279
+ res.send({
12280
+ code: successCode,
12281
+ data: response.data || {},
12282
+ ctx: response.ctx,
12283
+ });
12284
+ }
12285
+ },
12286
+ };
12287
+
12288
+ /**
12289
+ * 打开 collect session —— 对应后端 `/start`(本地)/ `set_collecting`(远程)。
12290
+ *
12291
+ * 单独成一条 IDE 可见路由(而不是埋在 set-collect 里),是为了让浏览器
12292
+ * Network 里有一条**明确叫 start** 的请求:`/start` 走 Portal 鉴权中间件,
12293
+ * 鉴权失败(`-401`)时这条请求会带着透传上来的 `error.code:-401` 返回,
12294
+ * IDE 全局拦截器据此弹"登录态失效"toast,且排查时能一眼定位到是开 session
12295
+ * 这步报的鉴权,而非 collect 轮询接口。
12296
+ *
12297
+ * `resume` 可选:仅本地 pipeline 有意义,缺省 → `reset:true`(重新开始)。
12298
+ */
12299
+ const gameWasmCollectStartRoute = {
12300
+ method: 'post',
12301
+ path: '/game/wasm-collect-start',
12302
+ handler: async (req, res) => {
12162
12303
  const { clientKey, codeMd5, resume } = req.body;
12163
- console.log('wasm-set-collect', req.body);
12164
- const response = await setCollect({
12304
+ console.log('wasm-collect-start', req.body);
12305
+ const response = await openCollectSession({
12165
12306
  client_key: clientKey,
12166
12307
  wasm_md5: codeMd5,
12167
12308
  resume,
@@ -12533,6 +12674,7 @@ const routes = [
12533
12674
  gameWasmPrepareDownloadRoute,
12534
12675
  gameWasmSplitRoute,
12535
12676
  gameWasmTaskinfoRoute,
12677
+ gameWasmCollectStartRoute,
12536
12678
  gameWasmSetCollectRoute,
12537
12679
  gameWasmCollectFuncidsRoute,
12538
12680
  gameWasmCollectInfoRoute,
@@ -12997,7 +13139,7 @@ async function upload({ clientKey, note = '--', dir, }) {
12997
13139
  }
12998
13140
  }
12999
13141
 
13000
- var version = "0.3.9-beta.1";
13142
+ var version = "0.3.9-beta.2";
13001
13143
  var pkg = {
13002
13144
  version: version};
13003
13145