@ttmg/cli 0.4.6-vibe-beta.17 → 0.4.6-vibe-beta.19

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.
package/dist/index.js CHANGED
@@ -7248,6 +7248,7 @@ const messages = {
7248
7248
  'cli.command.game.categories.category': 'Filter by an exact category value, e.g. Puzzle',
7249
7249
  'cli.command.game.categories.unknown': 'Unknown category. Run ttmg game categories --format json for valid values.',
7250
7250
  'cli.command.game.categories.invalidFormat': 'Use text, json, or ndjson output.',
7251
+ 'cli.command.upload.minisType': 'MINI_GAME (default) or MINI_TOOL (local PPE trial; Native ZIP, Efficiency & Office)',
7251
7252
  'cli.command.upload.vibeCategory': 'Optional game category; provide with --subcategory (--vibe). Query ttmg game categories --format json',
7252
7253
  'cli.command.upload.vibeDescription': 'Optional game description (--vibe); default: Discover the fun of TikTok Mini Games.',
7253
7254
  'cli.command.upload.vibeSubcategory': 'Optional subcategory belonging to --category; omit both to keep Other/Other (--vibe)',
@@ -7263,8 +7264,9 @@ Vibe QR upload (real PPE trial):
7263
7264
  Keep this process running. At waiting_authorization, scan the QR on pageUrl with TikTok on your phone.
7264
7265
  pageUrl is the local QR/progress page on the CLI computer. Reopen it with authorizationOpenCommand.
7265
7266
  The CLI polls and uploads avatar, app_info and package automatically after authorization. Do not start a second upload.
7266
- After upload, waiting_preview keeps polling the same task until previewUrl is available; pageUrl then shows the game preview QR.
7267
- Preview ready: previewReady=true and qrPurpose=game_preview. A preview timeout preserves uploaded=true; check the task, do not reupload.
7267
+ After upload, waiting_preview keeps polling the same task until previewUrl is available, including status 9 (waiting for review submission).
7268
+ When previewReady=true, pageUrl shows the preview QR first and retains the original QR for checking progress. qrPurpose is game_preview or tool_preview. A preview timeout preserves uploaded=true; do not reupload.
7269
+ The operation timeout defaults to 1800 seconds (maximum 3600). The page stays available during the operation and for 30 minutes after the CLI finishes.
7268
7270
  Real success: terminal=true, status=uploaded, uploaded=true, simulation=false. On failure, read errorCode and nextAction.
7269
7271
  The local QR page opens for every output format; --no-open disables automatic opening.
7270
7272
  The page displays the submitted title, icon, description, category and subcategory.
@@ -7483,7 +7485,7 @@ Vibe QR upload (real PPE trial):
7483
7485
  'cli.command.upload.vibeApi': 'Minis Import API origin on a loopback IP only (--vibe)',
7484
7486
  'cli.command.upload.vibeAuthorizeUrl': 'Obsolete: remove this option; task creation returns landing_url (--vibe)',
7485
7487
  'cli.command.upload.vibePollInterval': 'Override task polling interval; otherwise use poll_interval_seconds (--vibe)',
7486
- 'cli.command.upload.vibeTimeout': 'Operation timeout in seconds (--vibe; default 300)',
7488
+ 'cli.command.upload.vibeTimeout': 'Operation timeout in seconds (--vibe; default 1800, maximum 3600)',
7487
7489
  'cli.command.upload.vibeRequired': 'These options require --vibe; the existing platform upload has not been executed.',
7488
7490
  'cli.command.testAccount.desc': 'Manage Mini Game test-account access',
7489
7491
  'cli.command.testAccount.add.desc': 'Generate the authorization entry for adding a TikTok test account',
@@ -7698,6 +7700,7 @@ Vibe QR upload (real PPE trial):
7698
7700
  'cli.command.game.categories.category': '按类型的精确值筛选,例如 Puzzle',
7699
7701
  'cli.command.game.categories.unknown': '类型不存在。使用 ttmg game categories --format json 查询有效值。',
7700
7702
  'cli.command.game.categories.invalidFormat': '输出格式请使用 text、json 或 ndjson。',
7703
+ 'cli.command.upload.minisType': 'MINI_GAME(默认)或 MINI_TOOL(本地 PPE 试用;Native ZIP、效率办公类)',
7701
7704
  'cli.command.upload.vibeCategory': '可选游戏类型,须与 --subcategory 同传(--vibe);用 ttmg game categories --format json 查询',
7702
7705
  'cli.command.upload.vibeDescription': '可选游戏描述(--vibe);默认值:Discover the fun of TikTok Mini Games.',
7703
7706
  'cli.command.upload.vibeSubcategory': '所属类型的可选子类型;两者均不传保留 Other/Other(--vibe)',
@@ -7713,8 +7716,9 @@ Vibe 扫码上传(真实 PPE 试用):
7713
7716
  保持原进程运行。在 waiting_authorization 阶段,使用手机 TikTok 扫描 pageUrl 页面中的二维码。
7714
7717
  pageUrl 是 CLI 所在电脑的二维码/进度页;重新打开时,执行返回的 authorizationOpenCommand。
7715
7718
  CLI 负责轮询,授权后自动上传 avatar、app_info、package,不再启动第二次上传。
7716
- 上传后进入 waiting_preview,继续查询同一任务;拿到 previewUrl 后,原 pageUrl 页面展示游戏预览二维码。
7717
- previewReady=true 且 qrPurpose=game_preview 表示可扫码预览;等待超时仍保留 uploaded=true,请核对任务,不要重传。
7719
+ 上传成功后 waiting_preview 继续查询同一任务直到取得 previewUrl,包括状态 9(等待提交代码审核)。
7720
+ previewReady=true 时,pageUrl 优先显示预览码,保留原码用于查看进度;qrPurpose 为 game_preview 或 tool_preview。等待超时仍保留 uploaded=true,请核对任务,不要重传。
7721
+ 整体超时默认 1800 秒,最大 3600 秒;页面在任务进行中保持可用,CLI 结束后再保留 30 分钟。
7718
7722
  真实成功:terminal=true、status=uploaded、uploaded=true、simulation=false。失败时读取 errorCode 和 nextAction。
7719
7723
  所有输出格式都会打开本地二维码页;--no-open 可关闭自动打开。
7720
7724
  页面展示本次提交的标题、头像、描述、类型和子类型。
@@ -7933,7 +7937,7 @@ Vibe 扫码上传(真实 PPE 试用):
7933
7937
  'cli.command.upload.vibeApi': 'Minis Import 接口地址,仅接受回环 IP(--vibe)',
7934
7938
  'cli.command.upload.vibeAuthorizeUrl': '已废弃,请移除此参数;授权地址由创建任务返回(--vibe)',
7935
7939
  'cli.command.upload.vibePollInterval': '覆盖 task 轮询间隔;默认使用接口 poll_interval_seconds(--vibe)',
7936
- 'cli.command.upload.vibeTimeout': '操作超时秒数(--vibe,默认 300)',
7940
+ 'cli.command.upload.vibeTimeout': '操作超时秒数(--vibe,默认 1800,最大 3600)',
7937
7941
  'cli.command.upload.vibeRequired': '这些参数需要 --vibe;没有执行原有平台上传。',
7938
7942
  'cli.command.testAccount.desc': '管理小游戏测试账号访问',
7939
7943
  'cli.command.testAccount.add.desc': '生成添加 TikTok 测试账号的授权入口',
@@ -16382,7 +16386,7 @@ async function authStatus(options = {}) {
16382
16386
  return result;
16383
16387
  }
16384
16388
 
16385
- var version = "0.4.6-vibe-beta.17";
16389
+ var version = "0.4.6-vibe-beta.19";
16386
16390
  var engines = {
16387
16391
  node: ">=20.19.1 <21 || >=22"
16388
16392
  };
@@ -16405,6 +16409,23 @@ const VIBE_INPUT_REQUIREMENTS = {
16405
16409
  categoryPairRequiredWhenProvided: true,
16406
16410
  defaultCategory: { category: 'Other', subcategory: 'Other' },
16407
16411
  };
16412
+ const VIBE_TOOL_INPUT_REQUIREMENTS = {
16413
+ ...VIBE_INPUT_REQUIREMENTS,
16414
+ defaultMetadataProfile: 'ppe-tool-trial',
16415
+ optionalSkillInputs: ['description', 'minisType'],
16416
+ defaultDescription: 'A simple productivity tool for everyday tasks.',
16417
+ categoryQuery: undefined,
16418
+ categoryPairRequiredWhenProvided: false,
16419
+ defaultCategory: { category: 'EFFICIENCY_AND_OFFICE', subcategory: '' },
16420
+ region: 'US', minSDKVersion: '1.0.0',
16421
+ };
16422
+ function resolveMinisType(value) {
16423
+ if (value === undefined)
16424
+ return 'MINI_GAME';
16425
+ if (value !== 'MINI_GAME' && value !== 'MINI_TOOL')
16426
+ throw new VibeError('VIBE_INVALID_MINIS_TYPE');
16427
+ return value;
16428
+ }
16408
16429
  class VibeError extends Error {
16409
16430
  constructor(code) {
16410
16431
  super(code);
@@ -17142,6 +17163,10 @@ function getCapabilities() {
17142
17163
  networkRequired: false,
17143
17164
  },
17144
17165
  vibeUpload: {
17166
+ minisType: {
17167
+ option: '--minis-type', default: 'MINI_GAME', values: ['MINI_GAME', 'MINI_TOOL'],
17168
+ tool: { readiness: 'local-ppe-trial', deviceVerified: false, category: 'EFFICIENCY_AND_OFFICE', region: 'US', minSDKVersion: '1.0.0', assetType: 'NativeRuntime', metadataOverrides: false },
17169
+ },
17145
17170
  command: 'ttmg upload --vibe --dir <gameDir> --title <title> --icon <iconPath> --format ndjson',
17146
17171
  mockCommand: 'ttmg upload --vibe --mock --dir <gameDir> --title <title> --icon <iconPath> --format ndjson',
17147
17172
  guide: 'vibe-upload.md',
@@ -17275,6 +17300,9 @@ function getCapabilities() {
17275
17300
  resultFields: ['previewUrl', 'previewReady', 'clientKey', 'appId', 'codeAssetId', 'minisCenterHistoryId'],
17276
17301
  readiness: 'nonempty-valid-preview-url',
17277
17302
  qrPurpose: 'game_preview',
17303
+ toolQrPurpose: 'tool_preview',
17304
+ pageQrSource: 'preview-url',
17305
+ retainsBindingQr: true,
17278
17306
  sameTask: true,
17279
17307
  timeout: 'shared-operation-timeout',
17280
17308
  failurePreservesUploaded: true,
@@ -18038,6 +18066,7 @@ withVerboseOption(program
18038
18066
  .option('--serve-preview-page', t('cli.command.upload.servePreviewPage'))
18039
18067
  .option('--no-open', t('cli.command.upload.noOpen'))
18040
18068
  .option('--vibe', t('cli.command.upload.vibe'))
18069
+ .option('--minis-type <type>', t('cli.command.upload.minisType'))
18041
18070
  .addOption(new commander.Option('--web', t('cli.command.upload.vibeWeb')).hideHelp())
18042
18071
  // Vibe v2 backend selection (including opt-in ppe-mock) stays outside the Skill workflow.
18043
18072
  .option('--title <title>', t('cli.command.upload.vibeTitle'))
@@ -18063,6 +18092,7 @@ withVerboseOption(program
18063
18092
  }
18064
18093
  if ([
18065
18094
  cmd.title,
18095
+ cmd.minisType,
18066
18096
  cmd.description,
18067
18097
  cmd.icon,
18068
18098
  cmd.appInfo,
@@ -18663,7 +18693,10 @@ function taskId(value) {
18663
18693
  return value;
18664
18694
  }
18665
18695
  function status(value) {
18666
- if (!Number.isInteger(value) || Number(value) < 1 || Number(value) > 8)
18696
+ // IDL status 9 waits for code review submission; preview may already be ready.
18697
+ // Keep polling it just like other non-failure states and use preview_url to
18698
+ // determine preview readiness, rather than treating review as a prerequisite.
18699
+ if (!Number.isInteger(value) || Number(value) < 1 || Number(value) > 9)
18667
18700
  throw new VibeError('VIBE_INVALID_RESPONSE');
18668
18701
  return Number(value);
18669
18702
  }
@@ -18774,7 +18807,7 @@ function createBackend(mode, transport) {
18774
18807
  path: MINIS_IMPORT_PATHS.info,
18775
18808
  data: {
18776
18809
  ...credentials(task),
18777
- app_info: { ...(appInfo || VIBE_PPE_DEFAULT_APP_INFO), app_name: title, icon_uri: iconUri },
18810
+ app_info: { ...Object.fromEntries(Object.entries(appInfo || VIBE_PPE_DEFAULT_APP_INFO).filter(([, value]) => value !== '')), app_name: title, icon_uri: iconUri },
18778
18811
  },
18779
18812
  signal,
18780
18813
  });
@@ -18966,7 +18999,7 @@ function createMockBackend(scenario = 'success') {
18966
18999
  if (path === MINIS_IMPORT_PATHS.create) {
18967
19000
  if (created ||
18968
19001
  data.source_type !== 1 ||
18969
- data.minis_type !== 'MINI_GAME' ||
19002
+ !['MINI_GAME', 'MINI_TOOL'].includes(data.minis_type) ||
18970
19003
  !nonempty(data.source_project_id) ||
18971
19004
  !nonempty(data.task_idempotency_id))
18972
19005
  throw new VibeError('VIBE_INVALID_RESPONSE');
@@ -19270,9 +19303,19 @@ function readFile(file, limit, code) {
19270
19303
  }
19271
19304
  async function prepareVibeInput(options, onPackaging, signal, deps = { check: executeCheck, zip: zipCwdToBuffer }) {
19272
19305
  const title = options.title?.trim();
19306
+ const minisType = resolveMinisType(options.minisType);
19273
19307
  if (!title)
19274
19308
  throw new VibeError('VIBE_TITLE_REQUIRED');
19275
- const appInfo = applyVibeCategory(options, applyVibeDescription(options.description, readVibeAppInfo(options.appInfo)));
19309
+ if (minisType === 'MINI_TOOL' && (options.appInfo || options.category || options.subcategory))
19310
+ throw new VibeError('VIBE_TOOL_TRIAL_METADATA');
19311
+ const appInfo = minisType === 'MINI_TOOL'
19312
+ ? applyVibeDescription(options.description, {
19313
+ description: 'A simple productivity tool for everyday tasks.',
19314
+ category: 'EFFICIENCY_AND_OFFICE', subcategory: '',
19315
+ terms_of_service: 'https://www.tiktok.com', privacy_policy: 'https://www.tiktok.com',
19316
+ copyright_confirmation: true, region: 'US', min_sdk_version: '1.0.0',
19317
+ })
19318
+ : applyVibeCategory(options, applyVibeDescription(options.description, readVibeAppInfo(options.appInfo)));
19276
19319
  if (options.package && options.dir)
19277
19320
  throw new VibeError('VIBE_INPUT_CONFLICT');
19278
19321
  const image = readFile(options.icon, VIBE_ICON_LIMIT, 'VIBE_INVALID_ICON');
@@ -19306,6 +19349,7 @@ async function prepareVibeInput(options, onPackaging, signal, deps = { check: ex
19306
19349
  if (signal.aborted)
19307
19350
  throw new VibeError('VIBE_CANCELLED');
19308
19351
  const input = {
19352
+ minisType,
19309
19353
  title,
19310
19354
  ...(appInfo ? { appInfo } : {}),
19311
19355
  icon: {
@@ -19325,33 +19369,295 @@ const vibePageStyles = `
19325
19369
  :root{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;color:#24282f;background:#fff;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased}
19326
19370
  *{box-sizing:border-box}
19327
19371
  body{margin:0;min-height:100vh;min-height:100svh;display:flex;align-items:center;justify-content:center;padding:64px 24px;font-size:14px;line-height:1.5}
19328
- .shell{position:relative;width:100%;max-width:400px}
19329
- .steps{display:flex;align-items:center;justify-content:center;gap:10px;margin:0 0 24px;padding:0;list-style:none}
19372
+ .shell{position:relative;width:480px;max-width:100%}
19373
+ .steps{display:flex;align-items:center;justify-content:center;gap:10px;margin:24px 0 20px;padding:0;list-style:none}
19330
19374
  .step{display:flex;align-items:center;gap:6px;font-size:11px;color:#9298a2;white-space:nowrap}
19331
19375
  .step:after{content:"";height:1px;width:25px;margin-left:4px;background:#e9ebef}.step:last-child:after{display:none}
19332
19376
  .step-number{height:18px;min-width:18px;border-radius:50%;border:1px solid #e2e5e9;display:grid;place-items:center;font-size:10px}
19333
- .step.active{color:#272c34;font-weight:600}.step.active .step-number{background:#272c34;color:#fff;border-color:#272c34}
19334
- .step.done{color:#537565}.step.done .step-number{background:#edf6f0;color:#287c54;border-color:#edf6f0}
19335
- .heading{text-align:center}h1{font-size:26px;font-weight:650;line-height:1.35;letter-spacing:-.6px;margin:0 0 10px}
19336
- .subtitle{color:#7a818c;font-size:12px;line-height:1.7;margin:0;overflow-wrap:anywhere}
19337
- .game{margin:24px 0 0;padding-top:20px;border-top:1px solid #eceef1;text-align:center}
19338
- .game-summary{display:flex;align-items:center;justify-content:center;gap:12px}.game-title{max-width:100%;margin:0;font-size:15px;font-weight:600;overflow-wrap:anywhere;min-width:0}
19377
+ .step.active{color:#272c34;font-weight:600}.step.active .step-number{background:none;color:#272c34;border-color:transparent}
19378
+ .step.done{color:#7a818c}.step.done .step-number{background:#a3e635;color:#24282f;border-color:#a3e635}
19379
+ .swirl{display:block;width:18px;height:18px;border-radius:50%;background:conic-gradient(transparent 0 .1turn,currentColor 1turn);-webkit-mask:radial-gradient(farthest-side,#0000 calc(100% - 2.5px),#000 0);mask:radial-gradient(farthest-side,#0000 calc(100% - 2.5px),#000 0);animation:swirl-spin .9s linear infinite}
19380
+ @keyframes swirl-spin{to{transform:rotate(1turn)}}
19381
+ .heading{text-align:center}h1{font-size:22px;font-weight:600;line-height:1.35;letter-spacing:-.3px;margin:0 0 8px}
19382
+ .subtitle{color:#7a818c;font-size:12px;line-height:1.7;margin:0;min-height:41px;overflow-wrap:anywhere}
19383
+ .loading-space{height:22px}
19384
+ .preview-loading{width:min(240px,100%);height:4px;margin:18px auto 0;border-radius:4px;overflow:hidden;background:#eceef1}
19385
+ .preview-loading span{display:block;width:40%;height:100%;border-radius:inherit;background:#858c96;animation:preview-loading-slide 1.8s ease-in-out infinite}
19386
+ @keyframes preview-loading-slide{from{transform:translateX(-100%)}to{transform:translateX(250%)}}
19387
+ @media(prefers-reduced-motion:reduce){.preview-loading span{animation:none;transform:translateX(75%)}}
19388
+ .game{display:grid;grid-template-columns:44px minmax(0,1fr);column-gap:14px;align-items:start;margin:24px 22px 0;padding:16px 18px;border-radius:16px;background:#f7f8fa;text-align:left}
19389
+ .game-summary{display:contents}.game-title{grid-column:2;max-width:100%;margin:0;font-size:15px;font-weight:600;overflow-wrap:anywhere;min-width:0}
19339
19390
  .game-icon,.game-avatar{width:44px;height:44px;border-radius:10px;flex-shrink:0;background:#f0f2f5}.game-avatar{object-fit:cover}.game-icon{display:grid;place-items:center;color:#707b8b}
19340
- .game-details{margin:16px 0 0;font-size:13px}.game-details>div:first-child,.game-categories>div{display:flex;align-items:baseline;justify-content:center;gap:8px}.game-details dt{flex-shrink:0;font-size:11px;color:#9298a2;margin:0}.game-details dd{min-width:0;margin:0;text-align:left;overflow-wrap:anywhere}
19341
- .game-description{white-space:pre-wrap;line-height:1.65}.game-categories{display:grid;grid-template-columns:1fr;gap:16px;margin-top:16px}
19342
- .scan-action{text-align:center;font-size:13px;font-weight:500;margin:26px 0 10px}.qr-area{display:flex;justify-content:center}.qr-frame{padding:8px;width:208px;height:208px}.qr-frame img{display:block;width:192px;height:192px;max-width:100%}
19391
+ .game-icon,.game-avatar{grid-column:1;grid-row:1 / 3}
19392
+ .game-details{grid-column:2;margin:4px 0 0;font-size:12px;color:#7a818c}.game-details>div:first-child,.game-categories>div{display:flex;align-items:baseline;gap:6px}.game-details dt{flex-shrink:0;font-size:11px;color:#9298a2;margin:0}.game-details dd{min-width:0;margin:0;text-align:left;overflow-wrap:anywhere}
19393
+ .game-description{white-space:pre-wrap;line-height:1.65}.game-categories{display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:6px}
19394
+ /* 32px preserves at least four quiet modules even for a 21-module QR at 160px. */
19395
+ .scan-action{text-align:center;font-size:13px;font-weight:500;margin:26px 0 10px}.qr-area{display:flex;justify-content:center}.qr-frame{padding:32px;width:224px;height:224px;background:#fff}.qr-frame img{display:block;width:160px;height:160px;max-width:100%}
19396
+ .game+.qr-area{margin-top:20px}.scan-hint{text-align:center;font-size:11px;color:#7a818c;line-height:1.7;margin:8px 0 0;min-height:19px}
19397
+ .qr-area{flex-wrap:wrap;gap:20px;min-height:288px;align-content:flex-start}.qr-code{margin:0;width:224px;text-align:center}.qr-code figcaption{font-size:13px;font-weight:600;margin-top:4px;min-height:60px}.qr-code figcaption span{display:block;font-size:11px;font-weight:400;color:#7a818c;margin-top:4px;min-height:35px}
19398
+ .snake{display:grid;grid-template-columns:repeat(var(--cells),var(--module));color:#24282f;width:160px;height:160px}
19399
+ .snake i{width:var(--module);height:var(--module)}.snake i.lit,.snake i.on{background:currentColor}.snake i.fresh{animation:snake-settle .5s ease-out}.snake i.apple{background:#a3e635;animation:snake-apple 1.2s ease-in-out infinite}
19400
+ @keyframes snake-settle{from{background:#a3e635}to{background:currentColor}}@keyframes snake-apple{50%{opacity:.4}}
19401
+ @media(prefers-reduced-motion:reduce){.swirl,.snake i.fresh,.snake i.apple{animation:none}}
19343
19402
  .upload-area{display:flex;align-items:center;flex-direction:column;gap:16px;padding-top:26px}.percentage{font-size:34px;line-height:1;font-variant-numeric:tabular-nums;font-weight:550}.percentage span{font-size:16px;color:#858e9d;padding-left:3px}
19344
19403
  .progress-wrap{width:100%}progress{display:block;width:100%;height:4px;border:none;border-radius:20px;overflow:hidden;background:#edf0f4;accent-color:#4c6378}progress::-webkit-progress-bar{background:#edf0f4;border-radius:20px}progress::-webkit-progress-value{background:#4c6378;border-radius:20px}progress::-moz-progress-bar{background:#4c6378;border-radius:20px}.transfer-label{text-align:center;font-size:11px;color:#8b939f;margin:8px 0 0}
19345
19404
  .footer{text-align:center;font-size:10px;line-height:1.7;color:#a0a5ae;margin:24px 0 0}.footer .dot{display:inline-block;height:5px;width:5px;border-radius:50%;background:#c1995e;vertical-align:middle;margin-right:5px}.mock-badge{width:fit-content;margin:0 0 10px auto;font-size:10px;padding:2px 7px;border:1px solid #dfe2e7;border-radius:5px;color:#707783}
19346
19405
  @media(max-width:380px){body{padding-left:20px;padding-right:20px}.steps{gap:7px}.step:after{width:16px;margin-left:1px}h1{font-size:24px}}
19406
+ @media(max-width:520px){.game{margin-left:0;margin-right:0}.subtitle{min-height:61px}.scan-hint{min-height:38px}}
19347
19407
  `;
19348
19408
 
19409
+ // Adapted from tiktok-minis-skills publish_tool.js at 132cd91.
19410
+ // Decorative waiting animation only; real preview QRs always use previewUrl.
19411
+ const qrPreviewLoader = `(() => {
19412
+ const neighbours = (p, w) => {
19413
+ const row = (p / w) | 0, col = p % w, out = [];
19414
+ if (row > 0) out.push(p - w);
19415
+ if (row < w - 1) out.push(p + w);
19416
+ if (col > 0) out.push(p - 1);
19417
+ if (col < w - 1) out.push(p + 1);
19418
+ return out;
19419
+ };
19420
+
19421
+ /** First step of a shortest path from 'from' to 'to', body cells excluded. */
19422
+ function stepToward(from, to, blocked, w) {
19423
+ if (from === to) return from;
19424
+ const prev = new Map([[from, from]]);
19425
+ let front = [from];
19426
+ while (front.length) {
19427
+ const next = [];
19428
+ for (const cell of front)
19429
+ for (const nb of neighbours(cell, w)) {
19430
+ if (prev.has(nb) || (blocked.has(nb) && nb !== to)) continue;
19431
+ prev.set(nb, cell);
19432
+ if (nb === to) {
19433
+ let node = nb;
19434
+ while (prev.get(node) !== from) node = prev.get(node);
19435
+ return node;
19436
+ }
19437
+ next.push(nb);
19438
+ }
19439
+ front = next;
19440
+ }
19441
+ return -1;
19442
+ }
19443
+
19444
+ /** Nearest still-unlit module, by plain grid distance from the head. */
19445
+ function nearestTarget(head, pending, w) {
19446
+ const hr = (head / w) | 0, hc = head % w;
19447
+ let best = -1, bestD = Infinity;
19448
+ for (const cell of pending) {
19449
+ const d = Math.abs(((cell / w) | 0) - hr) + Math.abs((cell % w) - hc);
19450
+ if (d < bestD) { bestD = d; best = cell; }
19451
+ }
19452
+ return best;
19453
+ }
19454
+
19455
+ function play(matrix, w, maxLength) {
19456
+ const pending = new Set();
19457
+ for (let i = 0; i < w * w; i++) if (matrix[i]) pending.add(i);
19458
+
19459
+ // The snake starts on a dark module, and only moving lights one, so the
19460
+ // starting square has to be lit here or the finished code is a module
19461
+ // short -- a hole the error correction hides rather than a code that is
19462
+ // actually right.
19463
+ const start = [...pending][0];
19464
+ pending.delete(start);
19465
+ const snake = [start];
19466
+ const body = new Set(snake);
19467
+ const lit = new Set([start]);
19468
+ const frames = [];
19469
+ let budget = w * w * 6;
19470
+
19471
+ while (pending.size && --budget > 0) {
19472
+ const head = snake[snake.length - 1];
19473
+ const target = nearestTarget(head, pending, w);
19474
+ if (target < 0) break;
19475
+ const move = stepToward(head, target, body, w);
19476
+ if (move < 0) break;
19477
+
19478
+ snake.push(move);
19479
+ body.add(move);
19480
+ while (snake.length > maxLength) body.delete(snake.shift());
19481
+ if (matrix[move]) { lit.add(move); pending.delete(move); }
19482
+
19483
+ frames.push({ snake: [...snake], lit: [...lit], apple: target });
19484
+ }
19485
+ return frames;
19486
+ }
19487
+
19488
+ function mount(host) {
19489
+ if (host.dataset.mounted) return;
19490
+ host.dataset.mounted = '1';
19491
+ const matrix = JSON.parse(host.dataset.matrix);
19492
+ const w = Number(host.dataset.size);
19493
+ const SPEED = Number(host.dataset.speed) || 20; // ms a step
19494
+ host.style.setProperty('--cells', w);
19495
+ host.replaceChildren(...Array.from({ length: w * w }, () => document.createElement('i')));
19496
+ const dots = Array.from(host.children);
19497
+
19498
+ const frames = play(matrix, w, 14);
19499
+ const last = frames.length - 1;
19500
+ if (last < 1) return;
19501
+ const all = frames[last].lit;
19502
+
19503
+ // A lap stops short of the last modules and fades, rather than holding a
19504
+ // finished code that would read as the preview having arrived.
19505
+ const DRAW = Math.round(0.95 * last);
19506
+ const FADE = 20;
19507
+ const lap = DRAW + FADE;
19508
+ // Below this a lap is too unfinished for a sprint to be worth watching.
19509
+ const SPRINTABLE = 0.6;
19510
+
19511
+ // One clock for the whole wait. <main> is replaced as the upload advances,
19512
+ // so a board may be a later stand-in for an earlier one; it has to carry
19513
+ // on from where that one stopped instead of starting the code over.
19514
+ window.__snakeStart = window.__snakeStart || Date.now();
19515
+
19516
+ let sprint = null;
19517
+
19518
+ /**
19519
+ * Only the cells that changed. Repainting all 841 every frame meant ~2500
19520
+ * class writes 50 times a second to move a 14-cell snake; this touches
19521
+ * about 30. The lit list only ever grows within a pass, so the new
19522
+ * modules are its tail, and the body and the apple are small.
19523
+ *
19524
+ * The settle flag is off while the snake is only wandering: the flash
19525
+ * means a module was just revealed, and nothing is revealed then.
19526
+ */
19527
+ const litSet = new Set();
19528
+ let litCount = 0;
19529
+ let prevBody = [];
19530
+ let prevApple = -1;
19531
+
19532
+ const cell = (k, className, opacity) => {
19533
+ const dot = dots[k];
19534
+ if (dot.className !== className) dot.className = className;
19535
+ if (dot.style.opacity !== opacity) dot.style.opacity = opacity;
19536
+ };
19537
+ const restingClass = (k) => (litSet.has(k) ? 'lit' : '');
19538
+
19539
+ const paint = ({ snake, lit, apple }, settle = true) => {
19540
+ if (lit.length < litCount) { // a fresh pass: start from an empty board
19541
+ litSet.clear(); litCount = 0; prevBody = []; prevApple = -1;
19542
+ for (const dot of dots) { dot.className = ''; dot.style.opacity = ''; }
19543
+ }
19544
+ // Paint every new module here rather than relying on the body to
19545
+ // uncover it: frames are skipped whenever the board moves faster than
19546
+ // one step a tick -- the sprint skips dozens -- and a module the body
19547
+ // never sat on would otherwise stay dark in a finished code.
19548
+ for (let i = litCount; i < lit.length; i++) { litSet.add(lit[i]); cell(lit[i], 'lit', ''); }
19549
+ litCount = lit.length;
19550
+
19551
+ // The module the snake lit is under its head; it shows when the tail
19552
+ // clears it, so the flash belongs to the cell the body just left.
19553
+ for (const k of prevBody)
19554
+ if (!snake.includes(k))
19555
+ cell(k, litSet.has(k) && settle ? 'lit fresh' : restingClass(k), '');
19556
+
19557
+ const length = snake.length;
19558
+ snake.forEach((k, i) => cell(k, 'on', String(0.2 + 0.55 * ((i + 1) / length))));
19559
+ prevBody = snake;
19560
+
19561
+ if (prevApple !== apple) {
19562
+ if (prevApple >= 0 && !snake.includes(prevApple))
19563
+ cell(prevApple, restingClass(prevApple), '');
19564
+ if (apple >= 0) cell(apple, 'apple', '');
19565
+ prevApple = apple;
19566
+ }
19567
+ };
19568
+
19569
+ const step = () => Math.floor((Date.now() - window.__snakeStart) / SPEED) % lap;
19570
+ /** How far into its draw this lap is, 0 to 1. */
19571
+ const lapProgress = () => Math.min(1, step() / DRAW);
19572
+
19573
+ if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) {
19574
+ paint(frames[Math.floor(DRAW / 3)], false);
19575
+ host.finish = () => Promise.resolve();
19576
+ return;
19577
+ }
19578
+
19579
+ const timer = setInterval(() => {
19580
+ // The page swaps <main> as the upload advances; stop with the old board.
19581
+ if (!host.isConnected) { clearInterval(timer); return; }
19582
+ if (sprint) {
19583
+ const k = Math.min(1, (Date.now() - sprint.at) / sprint.ms);
19584
+ const p = sprint.from + (1 - sprint.from) * k;
19585
+ if (p >= 1) {
19586
+ paint({ snake: [], lit: all, apple: -1 });
19587
+ clearInterval(timer);
19588
+ sprint.done();
19589
+ return;
19590
+ }
19591
+ paint(frames[Math.round(p * last)]);
19592
+ return;
19593
+ }
19594
+ const at = step();
19595
+ if (at > DRAW) { // fading out before the next lap
19596
+ host.style.opacity = String(1 - (at - DRAW) / FADE);
19597
+ return;
19598
+ }
19599
+ if (host.style.opacity) host.style.opacity = '';
19600
+ paint(frames[at]);
19601
+ }, SPEED);
19602
+
19603
+ host.finish = () => {
19604
+ if (sprint) return Promise.resolve();
19605
+ const from = lapProgress();
19606
+ if (from < SPRINTABLE) return Promise.resolve();
19607
+ host.style.opacity = '';
19608
+ sprint = { from, at: Date.now(), ms: 300 + 500 * (1 - from), done: () => {} };
19609
+ return new Promise((resolve) => { sprint.done = resolve; });
19610
+ };
19611
+ }
19612
+
19613
+ const boards = () => [...document.querySelectorAll('.snake')];
19614
+ const start = () => boards().forEach(mount);
19615
+ window.__mountSnakes = start;
19616
+ window.__snakeFinish = () => Promise.all(boards().map((b) => b.finish?.()));
19617
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
19618
+ else start();
19619
+ })();`;
19620
+
19349
19621
  const VIBE_PAGE_WORKER = '__vibe-page-server';
19350
19622
  // Includes the base64 form of the locally validated image (up to 10 MiB).
19351
19623
  const VIBE_PAGE_HTML_LIMIT = 16 * 1024 * 1024;
19352
19624
  const pageUpdates = `(() => {
19353
19625
  let etag;
19354
19626
  const terminal = () => ['complete', 'preview', 'failed'].includes(document.querySelector('main')?.dataset.phase);
19627
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
19628
+ async function replace(current, updated) {
19629
+ const animate = current.dataset.phase !== updated.dataset.phase && current.animate &&
19630
+ !window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
19631
+ const height = current.getBoundingClientRect().height;
19632
+ if (animate) await current.animate([{opacity: 1}, {opacity: 0}], {duration: 140, fill: 'forwards'}).finished.catch(() => {});
19633
+ current.replaceWith(updated);
19634
+ window.__mountSnakes?.();
19635
+ if (animate) await updated.animate([
19636
+ {opacity: 0, height: height + 'px', overflow: 'hidden'},
19637
+ {opacity: 1, height: updated.getBoundingClientRect().height + 'px', overflow: 'hidden'}
19638
+ ], {duration: 280, easing: 'ease-out'}).finished.catch(() => {});
19639
+ }
19640
+ async function show(updated) {
19641
+ let current = document.querySelector('main');
19642
+ if (!current || current.dataset.rev === updated.dataset.rev) return;
19643
+ if (updated.dataset.phase === 'preview' && current.querySelector('.snake'))
19644
+ await window.__snakeFinish?.();
19645
+ if (updated.dataset.uploaded === 'true' && current.dataset.uploaded !== 'true') {
19646
+ // Show the upload receipt before either the binding or ready preview QR,
19647
+ // even when polling skips intermediate upload states.
19648
+ const success = updated.cloneNode(true);
19649
+ success.dataset.phase = 'upload_success';
19650
+ delete success.dataset.uploaded;
19651
+ const heading = success.querySelector('.heading');
19652
+ success.querySelector('h1').textContent = heading.dataset.uploadTitle;
19653
+ success.querySelector('.subtitle').textContent = heading.dataset.uploadSubtitle;
19654
+ success.querySelectorAll('.qr-area, .scan-action, .scan-hint, .preview-loading').forEach(node => node.remove());
19655
+ await replace(current, success);
19656
+ current = success;
19657
+ await delay(1200);
19658
+ }
19659
+ await replace(current, updated);
19660
+ }
19355
19661
  async function refresh() {
19356
19662
  if (terminal()) return;
19357
19663
  try {
@@ -19359,9 +19665,10 @@ const pageUpdates = `(() => {
19359
19665
  if (response.ok) {
19360
19666
  etag = response.headers.get('etag');
19361
19667
  const next = new DOMParser().parseFromString(await response.text(), 'text/html');
19362
- const current = document.querySelector('main'), updated = next.querySelector('main');
19363
- if (current && updated && current.outerHTML !== updated.outerHTML) current.replaceWith(updated);
19668
+ const updated = next.querySelector('main');
19669
+ if (updated) await show(updated);
19364
19670
  document.title = next.title;
19671
+ document.documentElement.lang = next.documentElement.lang;
19365
19672
  }
19366
19673
  } catch { /* Keep the current page readable during a temporary connection failure. */ }
19367
19674
  if (!terminal()) setTimeout(refresh, 2000);
@@ -19371,12 +19678,20 @@ const pageUpdates = `(() => {
19371
19678
  const escape = (s) => s.replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
19372
19679
  async function renderVibePage(input) {
19373
19680
  const zh = input.language !== 'en-US';
19681
+ const message = input.localizedMessages?.[zh ? 'zh-CN' : 'en-US'] ?? input.message;
19682
+ const tool = input.minisType === 'MINI_TOOL';
19374
19683
  const phase = input.phase ||
19375
19684
  (input.purpose === 'authorization_binding' ? 'binding' : 'uploading');
19685
+ const uploadedBinding = !input.simulation && input.purpose === 'authorization_binding' &&
19686
+ (phase === 'waiting_preview' || phase === 'preview' || phase === 'complete');
19687
+ const preview = !input.simulation && phase === 'preview' &&
19688
+ (input.purpose === 'game_preview' || input.purpose === 'tool_preview');
19689
+ const uploaded = uploadedBinding || preview;
19376
19690
  const copy = zh
19377
19691
  ? {
19378
- steps: ['扫码授权', '上传游戏', '完成'],
19692
+ steps: ['扫码授权', '上传游戏', '预览'],
19379
19693
  mock: input.hybrid ? 'PPE + Mock' : '模拟',
19694
+ game: '当前游戏',
19380
19695
  gameIcon: '游戏头像',
19381
19696
  bindingTitle: '上传到 TikTok',
19382
19697
  bindingAction: input.hybrid ? '真实授权二维码 · 混合联调' : '使用 TikTok 扫描二维码',
@@ -19389,6 +19704,7 @@ async function renderVibePage(input) {
19389
19704
  uploadingTitle: '正在上传小游戏',
19390
19705
  uploadingSubtitle: input.simulation ? '正在模拟授权后的上传流程,不会上传游戏内容。' : '授权已完成,正在上传本次游戏内容。',
19391
19706
  uploadLabel: input.simulation ? '模拟上传进度' : '上传进度',
19707
+ uploadStatus: '正在上传游戏,请稍候',
19392
19708
  completeTitle: input.simulation ? '模拟上传完成' : '上传完成',
19393
19709
  completeSubtitle: input.simulation
19394
19710
  ? '绑定和上传流程模拟完成,未向 TikTok 上传游戏。'
@@ -19397,11 +19713,11 @@ async function renderVibePage(input) {
19397
19713
  bindingCode: '授权绑定二维码',
19398
19714
  accepted: input.simulation ? '模拟完成' : '已上传',
19399
19715
  mockNote: input.hybrid ? '真实创建 / 查询任务 · 授权 / 上传为模拟 · 不改变真实任务状态' : '模拟运行 · 无需扫码,不会真实上传',
19400
- footer: '临时页面 · 15 分钟后关闭',
19401
19716
  }
19402
19717
  : {
19403
- steps: ['Authorize', 'Upload', 'Done'],
19718
+ steps: ['Scan', 'Upload', 'Preview'],
19404
19719
  mock: input.hybrid ? 'PPE + Mock' : 'MOCK',
19720
+ game: 'YOUR GAME',
19405
19721
  gameIcon: 'Game icon',
19406
19722
  bindingTitle: 'Upload to TikTok',
19407
19723
  bindingAction: input.hybrid ? 'Real authorization QR · integration demo' : 'Scan the QR code with TikTok',
@@ -19418,6 +19734,7 @@ async function renderVibePage(input) {
19418
19734
  uploadLabel: input.simulation
19419
19735
  ? 'Simulated upload progress'
19420
19736
  : 'Upload progress',
19737
+ uploadStatus: 'Uploading your game. Please wait.',
19421
19738
  completeTitle: input.simulation ? 'Simulated upload complete' : 'Upload complete',
19422
19739
  completeSubtitle: input.simulation
19423
19740
  ? 'Binding and upload simulation complete. Nothing was uploaded to TikTok.'
@@ -19426,8 +19743,17 @@ async function renderVibePage(input) {
19426
19743
  bindingCode: 'Authorization QR',
19427
19744
  accepted: input.simulation ? 'Simulation complete' : 'Uploaded',
19428
19745
  mockNote: input.hybrid ? 'Real task creation / polling · Mock authorization / upload · Real task status unchanged' : 'Mock only · no scan needed, nothing is uploaded',
19429
- footer: 'Temporary page · closes after 15 minutes',
19430
19746
  };
19747
+ if (tool) {
19748
+ for (const key of Object.keys(copy)) {
19749
+ const value = copy[key];
19750
+ if (typeof value === 'string')
19751
+ copy[key] = value.replace(/小游戏|游戏/g, '工具').replace(/game/gi, 'tool');
19752
+ }
19753
+ copy.steps[1] = zh ? '上传工具' : 'Upload';
19754
+ }
19755
+ if (input.simulation)
19756
+ copy.steps[2] = zh ? '完成' : 'Done';
19431
19757
  if (input.web) {
19432
19758
  copy.steps[0] = zh ? '网页授权' : 'Web authorization';
19433
19759
  copy.bindingAction = zh ? '在浏览器完成授权绑定' : 'Authorize in your browser';
@@ -19436,70 +19762,104 @@ async function renderVibePage(input) {
19436
19762
  : (zh ? '请在已打开的 TikTok 页面确认授权,当前命令会继续查询绑定状态。' : 'Confirm authorization on the opened TikTok page. The command continues polling.');
19437
19763
  copy.bindingStatus = input.simulation ? (zh ? '模拟等待授权' : 'Simulating authorization') : (zh ? '等待网页授权' : 'Waiting for browser authorization');
19438
19764
  }
19439
- const step = phase === 'binding' ? 0 : phase === 'uploading' ? 1 : 2;
19765
+ const step = phase === 'binding' ? 0 : phase === 'uploading' ? 1 : phase === 'preview' ? 3 : 2;
19440
19766
  // Only embed the chosen raster image; never fetch a URL or expose its local path.
19441
19767
  const icon = input.iconDataUrl &&
19442
19768
  input.iconDataUrl.length <= 14 * 1024 * 1024 &&
19443
19769
  /^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+=*$/.test(input.iconDataUrl)
19444
19770
  ? `<img class="game-avatar" width="44" height="44" alt="${copy.gameIcon}" src="${input.iconDataUrl}">`
19445
19771
  : '<span class="game-icon" aria-hidden="true"><svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M7 7h10c2 0 3 2 3 4l1 5c.4 2-1 3-2.5 2l-3-2h-7l-3 2C4 19 2.6 18 3 16l1-5c0-2 1-4 3-4Z" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M8 10v4m-2-2h4m6-1h.01M18 13h.01" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg></span>';
19446
- const game = `<div class="game"><div class="game-summary">${icon}<p class="game-title">${escape(input.title)}</p></div><dl class="game-details"><div><dt>${zh ? '描述' : 'Description'}</dt><dd class="game-description">${escape(input.description ?? VIBE_PPE_DEFAULT_APP_INFO.description)}</dd></div><div class="game-categories"><div><dt>${zh ? '类型' : 'Category'}</dt><dd>${escape(input.category ?? VIBE_PPE_DEFAULT_APP_INFO.category)}</dd></div><div><dt>${zh ? '子类型' : 'Subcategory'}</dt><dd>${escape(input.subcategory ?? VIBE_PPE_DEFAULT_APP_INFO.subcategory)}</dd></div></div></dl></div>`;
19772
+ const game = `<div class="game"><div class="game-summary">${icon}<p class="game-title">${escape(input.title)}</p></div><dl class="game-details"><div><dt>${zh ? '描述' : 'Description'}</dt><dd class="game-description">${escape(input.description ?? VIBE_PPE_DEFAULT_APP_INFO.description)}</dd></div><div class="game-categories"><div><dt>${zh ? '类型' : 'Category'}</dt><dd>${escape(tool && input.category === 'EFFICIENCY_AND_OFFICE' ? (zh ? '效率办公' : 'Efficiency & Office') : input.category ?? VIBE_PPE_DEFAULT_APP_INFO.category)}</dd></div>${tool ? '' : `<div><dt>${zh ? '子类型' : 'Subcategory'}</dt><dd>${escape(input.subcategory ?? VIBE_PPE_DEFAULT_APP_INFO.subcategory)}</dd></div>`}</div></dl></div>`;
19447
19773
  const checkIcon = '<svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="m3 8 3 3 7-7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
19448
- const title = phase === 'waiting_preview' ? (zh ? '正在准备预览' : 'Preparing preview')
19449
- : phase === 'preview' ? (zh ? '扫码预览游戏' : 'Scan to preview')
19450
- : phase === 'binding'
19451
- ? copy.bindingTitle
19452
- : phase === 'uploading'
19453
- ? copy.uploadingTitle
19454
- : phase === 'failed'
19455
- ? copy.failedTitle
19456
- : copy.completeTitle;
19457
- const subtitle = phase === 'waiting_preview' ? (zh ? '游戏内容已上传,预览就绪后会自动显示二维码。' : 'Game content uploaded. The preview QR will appear when ready.')
19458
- : phase === 'preview' ? (zh ? '上传完成,使用手机 TikTok 扫描下方二维码。' : 'Upload complete. Scan the QR below with TikTok on your phone.')
19459
- : phase === 'complete' && !input.simulation ? escape(input.message)
19774
+ const uploadSuccessTitle = zh ? '上传成功' : 'Upload complete';
19775
+ const uploadSuccessSubtitle = zh
19776
+ ? `${tool ? '工具' : '游戏'}内容已上传,正在返回扫码页面。`
19777
+ : `Your ${tool ? 'tool' : 'game'} has been uploaded. Returning to the scan page.`;
19778
+ const title = uploadedBinding ? (phase === 'waiting_preview' ? (zh ? '正在生成预览' : 'Preparing preview') : zh ? '扫码查看进度' : 'Scan to check progress')
19779
+ : phase === 'waiting_preview' ? (zh ? '正在准备预览' : 'Preparing preview')
19780
+ : phase === 'preview' ? (zh ? `扫码预览${tool ? '工具' : '游戏'}` : 'Scan to preview')
19460
19781
  : phase === 'binding'
19461
- ? copy.bindingSubtitle
19782
+ ? copy.bindingTitle
19462
19783
  : phase === 'uploading'
19463
- ? copy.uploadingSubtitle
19784
+ ? copy.uploadingTitle
19464
19785
  : phase === 'failed'
19465
- ? escape(input.message)
19466
- : copy.completeSubtitle;
19467
- const qr = (phase === 'binding' || phase === 'preview') && !input.web && input.qrUrl
19786
+ ? copy.failedTitle
19787
+ : copy.completeTitle;
19788
+ const subtitle = uploadedBinding ? (phase === 'complete' ? escape(message) : phase === 'waiting_preview'
19789
+ ? (zh ? '代码包已上传,正在生成预览。准备好后会自动显示预览二维码。' : 'Package uploaded. Your preview is being prepared; its QR will appear when ready.') : zh
19790
+ ? `本次${tool ? '工具' : '游戏'}代码包已上传完成,再次扫码即可查看预览版本并提交审核。`
19791
+ : `Your ${tool ? 'tool' : 'game'} package has been uploaded. Scan again to view the preview version and submit it for review.`)
19792
+ : phase === 'waiting_preview' ? (zh ? '内容已上传,预览就绪后会自动显示二维码。' : 'Content uploaded. The preview QR will appear when ready.')
19793
+ : phase === 'preview' ? ''
19794
+ : phase === 'complete' && !input.simulation ? escape(message)
19795
+ : phase === 'binding'
19796
+ ? copy.bindingSubtitle
19797
+ : phase === 'uploading'
19798
+ ? copy.uploadingSubtitle
19799
+ : phase === 'failed'
19800
+ ? escape(message)
19801
+ : copy.completeSubtitle;
19802
+ const qr = (phase === 'binding' || phase === 'uploading' || phase === 'preview' || uploadedBinding) && !input.web && input.qrUrl
19468
19803
  ? await QRCode.toDataURL(input.qrUrl, {
19469
19804
  width: 384,
19470
- margin: 4,
19805
+ // Fixed CSS quiet zones keep different QR versions visually equal.
19806
+ margin: 0,
19471
19807
  errorCorrectionLevel: 'M',
19472
19808
  })
19473
19809
  : '';
19474
- const purpose = phase === 'preview' ? (zh ? '游戏预览二维码' : 'Game preview QR') : copy.bindingCode;
19475
- const done = phase === 'complete' || phase === 'preview';
19810
+ const progressCode = zh ? '查看进度二维码' : 'Progress QR';
19811
+ const purpose = preview ? (zh ? `${tool ? '工具' : '游戏'}预览二维码` : `${tool ? 'Tool' : 'Game'} preview QR`) : uploadedBinding || phase === 'uploading' ? (zh ? '应用页面二维码' : 'App page QR') : copy.bindingCode;
19812
+ const bindingQr = preview && !input.web && input.bindingQrUrl && input.bindingQrUrl !== input.qrUrl
19813
+ ? await QRCode.toDataURL(input.bindingQrUrl, { width: 384, margin: 0, errorCorrectionLevel: 'M' }) : '';
19814
+ const done = phase === 'preview' || phase === 'complete' && input.simulation;
19815
+ const active = phase === 'binding' || phase === 'uploading' || phase === 'waiting_preview';
19816
+ const waiting = phase === 'waiting_preview';
19817
+ const matrix = waiting ? QRCode.create('https://www.tiktok.com/minis/').modules : undefined;
19818
+ const pendingQr = matrix ? `<figure class="qr-code qr-pending"><div class="qr-frame" role="img" aria-label="${zh ? '预览正在生成' : 'Preview is being prepared'}"><div class="snake" aria-hidden="true" data-size="${matrix.size}" data-speed="20" data-matrix='${JSON.stringify(Array.from(matrix.data))}' style="--module:${160 / matrix.size}px"></div></div><figcaption>${zh ? '正在生成预览' : 'Preparing preview'}</figcaption></figure>` : '';
19476
19819
  const progress = typeof input.progressPercent === 'number' &&
19477
19820
  Number.isFinite(input.progressPercent)
19478
19821
  ? Math.max(0, Math.min(100, Math.round(input.progressPercent)))
19479
19822
  : undefined;
19480
19823
  const content = qr
19481
- ? `<div class="qr-area"><div class="qr-frame"><img width="192" height="192" alt="${purpose}" src="${qr}"></div></div>`
19824
+ ? `<div class="qr-area">${pendingQr}<figure class="qr-code"><div class="qr-frame"><img width="160" height="160" alt="${purpose}" src="${qr}"></div>${preview ? `<figcaption>${zh ? '扫码预览' : 'Preview'}<span>${zh ? '打开本次上传的预览版本' : 'Open the preview of this upload'}</span></figcaption>` : phase === 'binding' ? `<figcaption>${zh ? '扫码授权' : 'Authorize upload'}</figcaption>` : `<figcaption>${zh ? '查看进度' : 'Check progress'}<span>${zh ? '扫码查看应用信息' : 'Scan to view app details'}</span></figcaption>`}</figure>${bindingQr ? `<figure class="qr-code"><div class="qr-frame"><img width="160" height="160" alt="${progressCode}" src="${bindingQr}"></div><figcaption>${zh ? '查看进度' : 'Check progress'}<span>${zh ? '查看应用信息并提交审核' : 'View app details and submit for review'}</span></figcaption></figure>` : ''}</div>`
19482
19825
  : phase === 'uploading' && progress !== undefined
19483
19826
  ? `<div class="upload-area"><div class="percentage">${progress}<span>%</span></div><div class="progress-wrap"><progress aria-label="${copy.uploadLabel}" max="100" value="${progress}"></progress><p class="transfer-label">${copy.uploadLabel}</p></div></div>`
19484
19827
  : '';
19828
+ const previewLoading = phase === 'waiting_preview'
19829
+ ? `<div class="preview-loading" role="progressbar" aria-label="${zh ? '正在生成预览' : 'Preparing preview'}"><span aria-hidden="true"></span></div>`
19830
+ : '<div class="loading-space" aria-hidden="true"></div>';
19831
+ const revision = crypto.createHash('sha256').update(JSON.stringify(input)).digest('hex');
19832
+ const steps = phase === 'failed' ? '' : `<ol class="steps" aria-label="${zh ? '上传步骤' : 'Upload steps'}">${copy.steps.map((label, i) => `<li class="step ${done || i < step ? 'done' : active && i === step ? 'active' : ''}"${!done && active && i === step ? ' aria-current="step"' : ''}><span class="step-number">${done || i < step ? checkIcon : active && i === step ? '<span class="swirl" aria-hidden="true"></span>' : i + 1}</span>${label}</li>`).join('')}</ol>`;
19485
19833
  return `<!doctype html><html lang="${zh ? 'zh-CN' : 'en'}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escape(title)} · ${escape(input.title)}</title><style>${vibePageStyles}</style><script src="?updates" defer></script></head>
19486
- <body><main class="shell" data-phase="${phase}">${input.simulation ? `<p class="mock-badge">${copy.mock}</p>` : ''}
19487
- <section class="card" aria-labelledby="page-title">${phase === 'failed' ? '' : `<ol class="steps" aria-label="${zh ? '上传步骤' : 'Upload steps'}">${copy.steps.map((label, i) => `<li class="step ${done || i < step ? 'done' : i === step ? 'active' : ''}"${!done && i === step ? ' aria-current="step"' : ''}><span class="step-number">${done || i < step ? checkIcon : i + 1}</span>${label}</li>`).join('')}</ol>`}
19488
- <div class="heading"><h1 id="page-title">${title}</h1><p class="subtitle" role="status">${subtitle}</p></div>${game}${phase === 'binding' ? `<p class="scan-action">${copy.bindingAction}</p>` : ''}${content}
19834
+ <body><main class="shell${bindingQr || pendingQr ? ' dual-qr' : ''}" data-phase="${phase}" data-rev="${revision}"${uploaded ? ' data-uploaded="true"' : ''}>${input.simulation ? `<p class="mock-badge">${copy.mock}</p>` : ''}
19835
+ <section class="card" aria-labelledby="page-title">
19836
+ <div class="heading"${uploaded ? ` data-upload-title="${escape(uploadSuccessTitle)}" data-upload-subtitle="${escape(uploadSuccessSubtitle)}"` : ''}><h1 id="page-title">${title}</h1><p class="subtitle" role="status">${subtitle}</p>${previewLoading}</div>${game}${steps}${phase === 'binding' && (input.web || input.hybrid) ? `<p class="scan-action">${copy.bindingAction}</p>` : ''}${content}<p class="scan-hint">${uploadedBinding ? (zh ? '可扫码查看进度信息,无需重复上传。' : 'Scan to view app details. No need to upload again.') : ''}</p>
19489
19837
  </section>
19490
- <p class="footer">${input.simulation ? `<span class="dot" aria-hidden="true"></span>${copy.mockNote}` : copy.footer}</p></main></body></html>`;
19838
+ ${input.simulation ? `<p class="footer"><span class="dot" aria-hidden="true"></span>${copy.mockNote}</p>` : ''}</main></body></html>`;
19839
+ }
19840
+ // Follow the reader's preferred browser language, as in the Tool skill.
19841
+ function browserPageLanguage(header) {
19842
+ const preferred = (header || '').split(',').map(part => {
19843
+ const [tag, ...parameters] = part.trim().split(';');
19844
+ const quality = parameters.find(value => /^\s*q=/i.test(value));
19845
+ const q = quality ? Number(quality.split('=')[1]) : 1;
19846
+ return { tag: tag.toLowerCase(), q };
19847
+ }).filter(item => item.tag && Number.isFinite(item.q) && item.q > 0 && item.q <= 1)
19848
+ .sort((a, b) => b.q - a.q)[0];
19849
+ return preferred?.tag.split('-')[0] === 'zh' ? 'zh-CN' : 'en-US';
19491
19850
  }
19492
19851
  async function createVibePageServer() {
19493
19852
  const route = `/${crypto.randomBytes(24).toString('hex')}`;
19494
19853
  let html = 'Starting…';
19495
19854
  let etag = '';
19855
+ let variants = {};
19496
19856
  let landingUrl;
19497
19857
  const server = http.createServer((req, res) => {
19498
19858
  const address = server.address();
19499
19859
  const host = address && typeof address !== 'string' ? `127.0.0.1:${address.port}` : '';
19500
19860
  if (req.method === 'GET' && req.url === `${route}?updates` && req.headers.host === host) {
19501
19861
  res.writeHead(200, { 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' });
19502
- res.end(pageUpdates);
19862
+ res.end(qrPreviewLoader + '\n' + pageUpdates);
19503
19863
  return;
19504
19864
  }
19505
19865
  if (req.url === `${route}/authorize` && req.headers.host === host &&
@@ -19522,19 +19882,23 @@ async function createVibePageServer() {
19522
19882
  res.writeHead(404).end();
19523
19883
  return;
19524
19884
  }
19525
- if (etag && req.headers['if-none-match'] === etag) {
19526
- res.writeHead(304, { 'ETag': etag, 'Cache-Control': 'no-store' }).end();
19885
+ const localized = variants[browserPageLanguage(req.headers['accept-language'])];
19886
+ const responseHtml = localized?.html ?? html;
19887
+ const responseEtag = localized?.etag ?? etag;
19888
+ if (responseEtag && req.headers['if-none-match'] === responseEtag) {
19889
+ res.writeHead(304, { 'ETag': responseEtag, 'Cache-Control': 'no-store', 'Vary': 'Accept-Language' }).end();
19527
19890
  return;
19528
19891
  }
19529
19892
  res.writeHead(200, {
19530
- 'ETag': etag,
19893
+ 'ETag': responseEtag,
19894
+ 'Vary': 'Accept-Language',
19531
19895
  'Content-Type': 'text/html; charset=utf-8',
19532
19896
  'Cache-Control': 'no-store',
19533
19897
  'Referrer-Policy': 'no-referrer',
19534
19898
  'X-Content-Type-Options': 'nosniff',
19535
19899
  'Content-Security-Policy': "default-src 'none'; img-src data:; style-src 'unsafe-inline'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'",
19536
19900
  });
19537
- res.end(html);
19901
+ res.end(responseHtml);
19538
19902
  });
19539
19903
  await new Promise((resolve, reject) => {
19540
19904
  server.once('error', reject);
@@ -19543,9 +19907,15 @@ async function createVibePageServer() {
19543
19907
  const address = server.address();
19544
19908
  return {
19545
19909
  url: `http://127.0.0.1:${address.port}${route}`,
19546
- update: (value, authorization) => {
19910
+ update: (value, authorization, localizedHtml) => {
19547
19911
  html = value;
19548
19912
  etag = '"' + crypto.createHash('sha256').update(value).digest('hex') + '"';
19913
+ variants = {};
19914
+ for (const language of ['zh-CN', 'en-US']) {
19915
+ const localized = localizedHtml?.[language];
19916
+ if (typeof localized === 'string' && localized.length < VIBE_PAGE_HTML_LIMIT)
19917
+ variants[language] = { html: localized, etag: '"' + crypto.createHash('sha256').update(localized).digest('hex') + '"' };
19918
+ }
19549
19919
  landingUrl = browserLandingUrl(authorization);
19550
19920
  },
19551
19921
  close: () => server.close(),
@@ -19558,24 +19928,34 @@ async function runVibePageWorker() {
19558
19928
  }
19559
19929
  const server = await createVibePageServer();
19560
19930
  const requestedTtl = Number(process.env.TTMG_VIBE_PAGE_TTL_MS);
19561
- const ttl = requestedTtl > 0 && requestedTtl <= 900000 ? requestedTtl : 900000;
19562
- const timer = setTimeout(() => {
19931
+ const ttl = requestedTtl > 0 && requestedTtl <= 1800000 ? requestedTtl : 1800000;
19932
+ let timer;
19933
+ let closing = false;
19934
+ const close = () => {
19935
+ closing = true;
19936
+ clearTimeout(timer);
19563
19937
  server.close();
19564
19938
  if (process.connected)
19565
19939
  process.disconnect();
19566
- }, ttl);
19940
+ };
19941
+ // The parent owns the operation deadline. Keep the page alive during polling,
19942
+ // then start its retention window when the parent detaches (or exits).
19943
+ const retain = () => {
19944
+ if (!closing && !timer)
19945
+ timer = setTimeout(close, ttl);
19946
+ };
19947
+ process.once('disconnect', retain);
19948
+ if (!process.connected)
19949
+ retain();
19567
19950
  process.on('message', (message) => {
19568
19951
  if (message?.type === 'render' &&
19569
19952
  typeof message.html === 'string' &&
19570
19953
  message.html.length < VIBE_PAGE_HTML_LIMIT) {
19571
- server.update(message.html, message.browserLandingUrl);
19954
+ server.update(message.html, message.browserLandingUrl, message.localizedHtml);
19572
19955
  process.send?.({ type: 'rendered', id: message.id });
19573
19956
  }
19574
19957
  if (message?.type === 'close') {
19575
- clearTimeout(timer);
19576
- server.close();
19577
- if (process.connected)
19578
- process.disconnect();
19958
+ close();
19579
19959
  }
19580
19960
  });
19581
19961
  process.send({ type: 'ready', url: server.url });
@@ -19613,11 +19993,15 @@ async function startVibePage() {
19613
19993
  return {
19614
19994
  url: ready.url,
19615
19995
  async update(input) {
19616
- const html = await renderVibePage(input);
19996
+ const [zh, en] = await Promise.all([
19997
+ renderVibePage({ ...input, language: 'zh-CN' }),
19998
+ renderVibePage({ ...input, language: 'en-US' }),
19999
+ ]);
20000
+ const html = input.language === 'en-US' ? en : zh;
19617
20001
  const current = ++id;
19618
20002
  const ack = receive(m => m?.type === 'rendered' && m.id === current);
19619
20003
  const landingUrl = input.phase === 'binding' ? browserLandingUrl(input.browserLandingUrl) : undefined;
19620
- child.send({ type: 'render', id: current, html, browserLandingUrl: landingUrl }, error => {
20004
+ child.send({ type: 'render', id: current, html, localizedHtml: { 'zh-CN': zh, 'en-US': en }, browserLandingUrl: landingUrl }, error => {
19621
20005
  if (error)
19622
20006
  child.emit('error', error);
19623
20007
  });
@@ -19641,6 +20025,7 @@ async function startVibePage() {
19641
20025
 
19642
20026
  // Source identity is project metadata, not a Skill input or a credential.
19643
20027
  function getVibeProjectId(options) {
20028
+ const minisType = resolveMinisType(options.minisType);
19644
20029
  const root = path.resolve(options.package ? path.dirname(options.package) : options.dir || '.');
19645
20030
  const dir = path.join(root, '.ttmg');
19646
20031
  const file = path.join(dir, 'vibe-project.json');
@@ -19648,7 +20033,7 @@ function getVibeProjectId(options) {
19648
20033
  fs.mkdirSync(dir, { recursive: true });
19649
20034
  const id = crypto.randomUUID();
19650
20035
  try {
19651
- fs.writeFileSync(file, JSON.stringify({ schemaVersion: '1', sourceProjectId: id }) + '\n', { flag: 'wx', mode: 0o600 });
20036
+ fs.writeFileSync(file, JSON.stringify({ schemaVersion: '1', sourceProjectId: id, minisType }) + '\n', { flag: 'wx', mode: 0o600 });
19652
20037
  }
19653
20038
  catch (error) {
19654
20039
  if (error.code !== 'EEXIST')
@@ -19659,9 +20044,13 @@ function getVibeProjectId(options) {
19659
20044
  typeof saved.sourceProjectId !== 'string' ||
19660
20045
  !/^[a-zA-Z0-9_-]{1,100}$/.test(saved.sourceProjectId))
19661
20046
  throw new Error();
20047
+ if ((saved.minisType || 'MINI_GAME') !== minisType)
20048
+ throw new VibeError('VIBE_PROJECT_TYPE_CONFLICT');
19662
20049
  return saved.sourceProjectId;
19663
20050
  }
19664
- catch {
20051
+ catch (error) {
20052
+ if (error instanceof VibeError)
20053
+ throw error;
19665
20054
  throw new VibeError('VIBE_PROJECT_STATE_FAILED');
19666
20055
  }
19667
20056
  }
@@ -19749,6 +20138,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19749
20138
  let page;
19750
20139
  let backend = deps.backend;
19751
20140
  let task;
20141
+ let authorizationUrl;
19752
20142
  let detached = false;
19753
20143
  let progressUpdates = Promise.resolve();
19754
20144
  let ppeLane;
@@ -19792,6 +20182,10 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19792
20182
  try {
19793
20183
  if (options.web)
19794
20184
  throw new VibeError('VIBE_WEB_DISABLED');
20185
+ const minisType = resolveMinisType(options.minisType);
20186
+ result.minisType = minisType;
20187
+ if (minisType === 'MINI_TOOL')
20188
+ result.inputRequirements = VIBE_TOOL_INPUT_REQUIREMENTS;
19795
20189
  // Real QR uploads use the release-owned PPE route.
19796
20190
  // Explicit test backends remain opt-in; real failures never fall back to them.
19797
20191
  if (!options.mock && !options.vibeApi && process.env.TTMG_VIBE_BACKEND) {
@@ -19832,7 +20226,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19832
20226
  throw new VibeError('VIBE_BACKEND_OPTION_CONFLICT');
19833
20227
  if (options.pollInterval !== undefined)
19834
20228
  seconds(options.pollInterval, 1);
19835
- const timeoutMs = seconds(options.timeout, 300);
20229
+ const timeoutMs = seconds(options.timeout, 1800);
19836
20230
  timeout = setTimeout(() => {
19837
20231
  timedOut = true;
19838
20232
  controller.abort();
@@ -19867,7 +20261,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19867
20261
  category: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).category,
19868
20262
  subcategory: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).subcategory,
19869
20263
  source: options.category !== undefined ? 'arguments' : options.appInfo !== undefined ? 'app-info' : 'defaults',
19870
- catalogVersion: GAME_CATEGORY_CATALOG_VERSION,
20264
+ catalogVersion: minisType === 'MINI_TOOL' ? 'mini-tool-ppe-trial-2026-09-19' : GAME_CATEGORY_CATALOG_VERSION,
19871
20265
  },
19872
20266
  iconSizeBytes: input.icon.bytes.length,
19873
20267
  packageSizeBytes: input.code.bytes.length,
@@ -19879,6 +20273,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19879
20273
  return result;
19880
20274
  const submittedInfo = input.appInfo || VIBE_PPE_DEFAULT_APP_INFO;
19881
20275
  pageMetadata = {
20276
+ minisType,
19882
20277
  iconDataUrl: `data:${input.icon.contentType};base64,${input.icon.bytes.toString('base64')}`,
19883
20278
  description: submittedInfo.description,
19884
20279
  category: submittedInfo.category,
@@ -19896,10 +20291,10 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19896
20291
  source_type: 1,
19897
20292
  source_project_id: sourceProjectId,
19898
20293
  task_idempotency_id: result.operationId,
19899
- minis_type: 'MINI_GAME',
20294
+ minis_type: minisType,
19900
20295
  }, controller.signal);
19901
20296
  ensureActive();
19902
- const authorizationUrl = createAuthorizationScheme(task.landingUrl);
20297
+ authorizationUrl = createAuthorizationScheme(task.landingUrl);
19903
20298
  const pollMs = seconds(options.pollInterval, task.pollIntervalSeconds);
19904
20299
  result = {
19905
20300
  ...result,
@@ -19978,6 +20373,8 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
19978
20373
  ...pageGame,
19979
20374
  language: getCurrentLanguage(),
19980
20375
  phase: 'uploading',
20376
+ qrUrl: result.simulation ? undefined : authorizationUrl,
20377
+ purpose: result.simulation ? undefined : 'authorization_binding',
19981
20378
  simulation: result.simulation,
19982
20379
  message: text('uploading', result.simulation),
19983
20380
  });
@@ -20016,6 +20413,8 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20016
20413
  ...pageGame,
20017
20414
  language: getCurrentLanguage(),
20018
20415
  phase: 'uploading',
20416
+ qrUrl: result.simulation ? undefined : authorizationUrl,
20417
+ purpose: result.simulation ? undefined : 'authorization_binding',
20019
20418
  simulation: result.simulation,
20020
20419
  message: text('uploading', result.simulation),
20021
20420
  progressPercent: percent(loaded, validTotal),
@@ -20037,8 +20436,9 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20037
20436
  throw progressPageError;
20038
20437
  if (!result.simulation) {
20039
20438
  emit('waiting_preview', { previewReady: false, terminal: false, nextAction: 'wait',
20040
- qrPurpose: undefined, authorizationOpenCommand: undefined });
20439
+ qrPurpose: 'authorization_binding', authorizationOpenCommand: undefined });
20041
20440
  await page.update({ ...pageGame, language: getCurrentLanguage(), phase: 'waiting_preview',
20441
+ qrUrl: authorizationUrl, purpose: 'authorization_binding',
20042
20442
  simulation: false, message: text('waiting_preview') });
20043
20443
  while (true) {
20044
20444
  ensureActive();
@@ -20062,17 +20462,20 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20062
20462
  ...pageGame,
20063
20463
  language: getCurrentLanguage(),
20064
20464
  phase: result.previewReady ? 'preview' : 'complete',
20065
- qrUrl: result.previewUrl,
20066
- purpose: result.previewReady ? 'game_preview' : undefined,
20465
+ qrUrl: result.simulation ? undefined : result.previewUrl || authorizationUrl,
20466
+ bindingQrUrl: result.previewReady ? authorizationUrl : undefined,
20467
+ purpose: result.simulation ? undefined : result.previewReady
20468
+ ? result.minisType === 'MINI_TOOL' ? 'tool_preview' : 'game_preview'
20469
+ : 'authorization_binding',
20067
20470
  simulation: result.simulation,
20068
20471
  message: text('uploaded', result.simulation),
20069
20472
  });
20070
20473
  page.detach();
20071
20474
  detached = true;
20072
20475
  return emit('uploaded', { terminal: true, nextAction: result.previewReady ? 'scan_qr' : 'none',
20073
- qrPurpose: result.previewReady ? 'game_preview' : undefined,
20476
+ qrPurpose: result.previewReady ? result.minisType === 'MINI_TOOL' ? 'tool_preview' : 'game_preview' : undefined,
20074
20477
  ...(result.previewReady ? { message: getCurrentLanguage() === 'zh-CN'
20075
- ? '上传完成,请使用 TikTok 扫码预览游戏。' : 'Upload complete. Scan with TikTok to preview your game.' } : {}) });
20478
+ ? '预览已就绪,请使用 TikTok 扫描预览二维码;也可扫描“查看进度”二维码查看应用信息并提交审核。' : 'Preview ready. Scan the preview QR with TikTok, or scan the progress QR to view app details and submit for review.' } : {}) });
20076
20479
  }
20077
20480
  catch (error) {
20078
20481
  const code = timedOut
@@ -20090,6 +20493,9 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20090
20493
  const messages = {
20091
20494
  VIBE_CATEGORY_PAIR_REQUIRED: ['--category 和 --subcategory 必须同时提供;均不传时保留默认分类。使用 ttmg game categories --format json 查询。', 'Provide --category and --subcategory together, or omit both to keep the default. Query ttmg game categories --format json.'],
20092
20495
  VIBE_INVALID_CATEGORY: ['类型或子类型无效,或两者不匹配。使用 ttmg game categories --format json 查询有效组合。', 'Invalid category/subcategory pair. Query valid values with ttmg game categories --format json.'],
20496
+ VIBE_INVALID_MINIS_TYPE: ['应用类型须为 MINI_GAME 或 MINI_TOOL。', 'Minis type must be MINI_GAME or MINI_TOOL.'],
20497
+ VIBE_TOOL_TRIAL_METADATA: ['本地 Tool 试用固定使用效率办公类、US 和 SDK 1.0.0;暂不接受分类或 app-info 覆盖。', 'The local Tool trial uses Efficiency & Office, US and SDK 1.0.0; category and app-info overrides are not supported yet.'],
20498
+ VIBE_PROJECT_TYPE_CONFLICT: ['该工程已使用其他应用类型,请为新的 Tool 使用独立工程目录。', 'This project has a different Minis type. Use a separate project directory for a new Tool.'],
20093
20499
  VIBE_INVALID_DESCRIPTION: ['描述必须是非空的有效 Unicode 文本;省略 --description 可使用默认描述。', 'Description must be non-empty valid Unicode text; omit --description to use the default.'],
20094
20500
  VIBE_AUTH_DENIED: [
20095
20501
  '已取消授权,本次未上传。',
@@ -20171,7 +20577,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20171
20577
  text(status);
20172
20578
  controller.abort();
20173
20579
  await progressUpdates;
20174
- // Remove the binding QR on failure too. Keep a readable terminal result page.
20580
+ // After upload, preserve the original code for checking progress even if preview lookup stops.
20175
20581
  if (page && (code !== 'VIBE_CANCELLED' || result.uploaded)) {
20176
20582
  try {
20177
20583
  await page.update({
@@ -20181,7 +20587,20 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
20181
20587
  simulation: result.simulation,
20182
20588
  hybrid: result.backend === 'ppe-mock',
20183
20589
  phase: result.uploaded ? 'complete' : 'failed',
20184
- message,
20590
+ qrUrl: result.uploaded && !result.simulation ? authorizationUrl : undefined,
20591
+ purpose: result.uploaded && !result.simulation ? 'authorization_binding' : undefined,
20592
+ localizedMessages: result.uploaded && !result.simulation ? {
20593
+ 'zh-CN': '代码包已上传,本页已停止等待预览。可扫码查看进度,无需重复上传。',
20594
+ 'en-US': 'Package uploaded. This page has stopped waiting for the preview. Scan to check progress; no need to upload again.',
20595
+ } : {
20596
+ 'zh-CN': messages[code]?.[0] || '本次操作未完成,请检查 CLI 输出。',
20597
+ 'en-US': messages[code]?.[1] || 'This operation did not complete. Check the CLI output.',
20598
+ },
20599
+ message: result.uploaded && !result.simulation
20600
+ ? getCurrentLanguage() === 'zh-CN'
20601
+ ? '代码包已上传,本页已停止等待预览。可扫码查看进度,无需重复上传。'
20602
+ : 'Package uploaded. This page has stopped waiting for the preview. Scan to check progress; no need to upload again.'
20603
+ : message,
20185
20604
  });
20186
20605
  page.detach();
20187
20606
  detached = true;