@ttmg/cli 0.4.6-vibe-beta.23 → 0.4.6-vibe-beta.24
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/CHANGELOG.md +41 -1
- package/README.md +13 -5
- package/dist/index.js +508 -87
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/scripts/vibe-upload-smoke.js +19 -3
- package/package.json +1 -1
- package/vibe-upload.md +26 -15
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
|
|
7267
|
-
|
|
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 keeps the original QR on the left for checking progress and shows the preview QR on the right. 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
|
|
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
|
-
|
|
7717
|
-
previewReady=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,默认
|
|
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.
|
|
16389
|
+
var version = "0.4.6-vibe-beta.24";
|
|
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'))
|
|
@@ -18064,6 +18093,7 @@ withVerboseOption(program
|
|
|
18064
18093
|
}
|
|
18065
18094
|
if ([
|
|
18066
18095
|
cmd.title,
|
|
18096
|
+
cmd.minisType,
|
|
18067
18097
|
cmd.description,
|
|
18068
18098
|
cmd.icon,
|
|
18069
18099
|
cmd.appInfo,
|
|
@@ -18708,7 +18738,10 @@ function taskId(value) {
|
|
|
18708
18738
|
return value;
|
|
18709
18739
|
}
|
|
18710
18740
|
function status(value) {
|
|
18711
|
-
|
|
18741
|
+
// IDL status 9 waits for code review submission; preview may already be ready.
|
|
18742
|
+
// Keep polling it just like other non-failure states and use preview_url to
|
|
18743
|
+
// determine preview readiness, rather than treating review as a prerequisite.
|
|
18744
|
+
if (!Number.isInteger(value) || Number(value) < 1 || Number(value) > 9)
|
|
18712
18745
|
throw new VibeError('VIBE_INVALID_RESPONSE');
|
|
18713
18746
|
return Number(value);
|
|
18714
18747
|
}
|
|
@@ -18770,6 +18803,7 @@ function createBackend(mode, transport) {
|
|
|
18770
18803
|
signal,
|
|
18771
18804
|
});
|
|
18772
18805
|
if (!nonempty(data.import_token) ||
|
|
18806
|
+
!nonempty(data.landing_url) ||
|
|
18773
18807
|
!Number.isFinite(data.poll_interval_seconds) ||
|
|
18774
18808
|
data.poll_interval_seconds <= 0 ||
|
|
18775
18809
|
data.poll_interval_seconds > 3600)
|
|
@@ -18777,7 +18811,7 @@ function createBackend(mode, transport) {
|
|
|
18777
18811
|
return {
|
|
18778
18812
|
taskId: taskId(data.task_id),
|
|
18779
18813
|
importToken: data.import_token,
|
|
18780
|
-
landingUrl:
|
|
18814
|
+
landingUrl: data.landing_url,
|
|
18781
18815
|
pollIntervalSeconds: data.poll_interval_seconds,
|
|
18782
18816
|
};
|
|
18783
18817
|
},
|
|
@@ -18819,7 +18853,7 @@ function createBackend(mode, transport) {
|
|
|
18819
18853
|
path: MINIS_IMPORT_PATHS.info,
|
|
18820
18854
|
data: {
|
|
18821
18855
|
...credentials(task),
|
|
18822
|
-
app_info: { ...(appInfo || VIBE_PPE_DEFAULT_APP_INFO), app_name: title, icon_uri: iconUri },
|
|
18856
|
+
app_info: { ...Object.fromEntries(Object.entries(appInfo || VIBE_PPE_DEFAULT_APP_INFO).filter(([, value]) => value !== '')), app_name: title, icon_uri: iconUri },
|
|
18823
18857
|
},
|
|
18824
18858
|
signal,
|
|
18825
18859
|
});
|
|
@@ -19039,7 +19073,7 @@ function createMockBackend(scenario = 'success') {
|
|
|
19039
19073
|
if (path === MINIS_IMPORT_PATHS.create) {
|
|
19040
19074
|
if (created ||
|
|
19041
19075
|
data.source_type !== 1 ||
|
|
19042
|
-
data.minis_type
|
|
19076
|
+
!['MINI_GAME', 'MINI_TOOL'].includes(data.minis_type) ||
|
|
19043
19077
|
!nonempty(data.source_project_id) ||
|
|
19044
19078
|
!nonempty(data.task_idempotency_id))
|
|
19045
19079
|
throw new VibeError('VIBE_INVALID_RESPONSE');
|
|
@@ -19108,7 +19142,7 @@ function createMockBackend(scenario = 'success') {
|
|
|
19108
19142
|
function createAuthorizationScheme(landingUrl) {
|
|
19109
19143
|
// QR and browser authorization use the same backend-provided landing URL.
|
|
19110
19144
|
// Preserve its query exactly; do not wrap it in an app scheme or re-encode it.
|
|
19111
|
-
return
|
|
19145
|
+
return landingUrl;
|
|
19112
19146
|
}
|
|
19113
19147
|
|
|
19114
19148
|
const DEV_PORT = 3000;
|
|
@@ -19343,9 +19377,19 @@ function readFile(file, limit, code) {
|
|
|
19343
19377
|
}
|
|
19344
19378
|
async function prepareVibeInput(options, onPackaging, signal, deps = { check: executeCheck, zip: zipCwdToBuffer }) {
|
|
19345
19379
|
const title = options.title?.trim();
|
|
19380
|
+
const minisType = resolveMinisType(options.minisType);
|
|
19346
19381
|
if (!title)
|
|
19347
19382
|
throw new VibeError('VIBE_TITLE_REQUIRED');
|
|
19348
|
-
|
|
19383
|
+
if (minisType === 'MINI_TOOL' && (options.appInfo || options.category || options.subcategory))
|
|
19384
|
+
throw new VibeError('VIBE_TOOL_TRIAL_METADATA');
|
|
19385
|
+
const appInfo = minisType === 'MINI_TOOL'
|
|
19386
|
+
? applyVibeDescription(options.description, {
|
|
19387
|
+
description: 'A simple productivity tool for everyday tasks.',
|
|
19388
|
+
category: 'EFFICIENCY_AND_OFFICE', subcategory: '',
|
|
19389
|
+
terms_of_service: 'https://www.tiktok.com', privacy_policy: 'https://www.tiktok.com',
|
|
19390
|
+
copyright_confirmation: true, region: 'US', min_sdk_version: '1.0.0',
|
|
19391
|
+
})
|
|
19392
|
+
: applyVibeCategory(options, applyVibeDescription(options.description, readVibeAppInfo(options.appInfo)));
|
|
19349
19393
|
if (options.package && options.dir)
|
|
19350
19394
|
throw new VibeError('VIBE_INPUT_CONFLICT');
|
|
19351
19395
|
const image = readFile(options.icon, VIBE_ICON_LIMIT, 'VIBE_INVALID_ICON');
|
|
@@ -19379,6 +19423,7 @@ async function prepareVibeInput(options, onPackaging, signal, deps = { check: ex
|
|
|
19379
19423
|
if (signal.aborted)
|
|
19380
19424
|
throw new VibeError('VIBE_CANCELLED');
|
|
19381
19425
|
const input = {
|
|
19426
|
+
minisType,
|
|
19382
19427
|
title,
|
|
19383
19428
|
...(appInfo ? { appInfo } : {}),
|
|
19384
19429
|
icon: {
|
|
@@ -19398,33 +19443,294 @@ const vibePageStyles = `
|
|
|
19398
19443
|
: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}
|
|
19399
19444
|
*{box-sizing:border-box}
|
|
19400
19445
|
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}
|
|
19401
|
-
.shell{position:relative;width:
|
|
19402
|
-
.steps{display:flex;align-items:center;justify-content:center;gap:10px;margin:
|
|
19446
|
+
.shell{position:relative;width:480px;max-width:100%}
|
|
19447
|
+
.steps{display:flex;align-items:center;justify-content:center;gap:10px;margin:24px 0 20px;padding:0;list-style:none}
|
|
19403
19448
|
.step{display:flex;align-items:center;gap:6px;font-size:11px;color:#9298a2;white-space:nowrap}
|
|
19404
19449
|
.step:after{content:"";height:1px;width:25px;margin-left:4px;background:#e9ebef}.step:last-child:after{display:none}
|
|
19405
19450
|
.step-number{height:18px;min-width:18px;border-radius:50%;border:1px solid #e2e5e9;display:grid;place-items:center;font-size:10px}
|
|
19406
|
-
.step.active{color:#272c34;font-weight:600}.step.active .step-number{background
|
|
19407
|
-
.step.done{color:#
|
|
19408
|
-
.
|
|
19409
|
-
|
|
19410
|
-
.
|
|
19411
|
-
.
|
|
19451
|
+
.step.active{color:#272c34;font-weight:600}.step.active .step-number{background:none;color:#272c34;border-color:transparent}
|
|
19452
|
+
.step.done{color:#7a818c}.step.done .step-number{background:#a3e635;color:#24282f;border-color:#a3e635}
|
|
19453
|
+
.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}
|
|
19454
|
+
@keyframes swirl-spin{to{transform:rotate(1turn)}}
|
|
19455
|
+
.heading{text-align:center}h1{font-size:20px;font-weight:600;line-height:1.6;letter-spacing:-.3px;margin:0 0 12px}
|
|
19456
|
+
.subtitle{color:#7a818c;font-size:14px;line-height:1.6;margin:0;min-height:22px;overflow-wrap:anywhere}
|
|
19457
|
+
.preview-loading{width:min(240px,100%);height:4px;margin:18px auto 0;border-radius:4px;overflow:hidden;background:#eceef1}
|
|
19458
|
+
.preview-loading span{display:block;width:40%;height:100%;border-radius:inherit;background:#858c96;animation:preview-loading-slide 1.8s ease-in-out infinite}
|
|
19459
|
+
@keyframes preview-loading-slide{from{transform:translateX(-100%)}to{transform:translateX(250%)}}
|
|
19460
|
+
@media(prefers-reduced-motion:reduce){.preview-loading span{animation:none;transform:translateX(75%)}}
|
|
19461
|
+
.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}
|
|
19462
|
+
.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}
|
|
19412
19463
|
.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}
|
|
19413
|
-
.game-
|
|
19414
|
-
.game-
|
|
19415
|
-
.
|
|
19464
|
+
.game-icon,.game-avatar{grid-column:1;grid-row:1 / 3;align-self:center}
|
|
19465
|
+
.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}
|
|
19466
|
+
.game-description{white-space:pre-wrap;line-height:1.65}.game-categories{display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:6px}
|
|
19467
|
+
/* 32px preserves at least four quiet modules even for a 21-module QR at 160px. */
|
|
19468
|
+
.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%}
|
|
19469
|
+
.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}
|
|
19470
|
+
.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}
|
|
19471
|
+
.snake{display:grid;grid-template-columns:repeat(var(--cells),var(--module));color:#24282f;width:160px;height:160px}
|
|
19472
|
+
.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}
|
|
19473
|
+
@keyframes snake-settle{from{background:#a3e635}to{background:currentColor}}@keyframes snake-apple{50%{opacity:.4}}
|
|
19474
|
+
@media(prefers-reduced-motion:reduce){.swirl,.snake i.fresh,.snake i.apple{animation:none}}
|
|
19416
19475
|
.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}
|
|
19417
19476
|
.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}
|
|
19418
19477
|
.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}
|
|
19419
|
-
@media(max-width:380px){body{padding-left:20px;padding-right:20px}.steps{gap:7px}.step:after{width:16px;margin-left:1px}
|
|
19478
|
+
@media(max-width:380px){body{padding-left:20px;padding-right:20px}.steps{gap:7px}.step:after{width:16px;margin-left:1px}}
|
|
19479
|
+
@media(max-width:520px){.game{margin-left:0;margin-right:0}.scan-hint{min-height:38px}}
|
|
19420
19480
|
`;
|
|
19421
19481
|
|
|
19482
|
+
// Adapted from tiktok-minis-skills publish_tool.js at 132cd91.
|
|
19483
|
+
// Decorative waiting animation only; real preview QRs always use previewUrl.
|
|
19484
|
+
const qrPreviewLoader = `(() => {
|
|
19485
|
+
const neighbours = (p, w) => {
|
|
19486
|
+
const row = (p / w) | 0, col = p % w, out = [];
|
|
19487
|
+
if (row > 0) out.push(p - w);
|
|
19488
|
+
if (row < w - 1) out.push(p + w);
|
|
19489
|
+
if (col > 0) out.push(p - 1);
|
|
19490
|
+
if (col < w - 1) out.push(p + 1);
|
|
19491
|
+
return out;
|
|
19492
|
+
};
|
|
19493
|
+
|
|
19494
|
+
/** First step of a shortest path from 'from' to 'to', body cells excluded. */
|
|
19495
|
+
function stepToward(from, to, blocked, w) {
|
|
19496
|
+
if (from === to) return from;
|
|
19497
|
+
const prev = new Map([[from, from]]);
|
|
19498
|
+
let front = [from];
|
|
19499
|
+
while (front.length) {
|
|
19500
|
+
const next = [];
|
|
19501
|
+
for (const cell of front)
|
|
19502
|
+
for (const nb of neighbours(cell, w)) {
|
|
19503
|
+
if (prev.has(nb) || (blocked.has(nb) && nb !== to)) continue;
|
|
19504
|
+
prev.set(nb, cell);
|
|
19505
|
+
if (nb === to) {
|
|
19506
|
+
let node = nb;
|
|
19507
|
+
while (prev.get(node) !== from) node = prev.get(node);
|
|
19508
|
+
return node;
|
|
19509
|
+
}
|
|
19510
|
+
next.push(nb);
|
|
19511
|
+
}
|
|
19512
|
+
front = next;
|
|
19513
|
+
}
|
|
19514
|
+
return -1;
|
|
19515
|
+
}
|
|
19516
|
+
|
|
19517
|
+
/** Nearest still-unlit module, by plain grid distance from the head. */
|
|
19518
|
+
function nearestTarget(head, pending, w) {
|
|
19519
|
+
const hr = (head / w) | 0, hc = head % w;
|
|
19520
|
+
let best = -1, bestD = Infinity;
|
|
19521
|
+
for (const cell of pending) {
|
|
19522
|
+
const d = Math.abs(((cell / w) | 0) - hr) + Math.abs((cell % w) - hc);
|
|
19523
|
+
if (d < bestD) { bestD = d; best = cell; }
|
|
19524
|
+
}
|
|
19525
|
+
return best;
|
|
19526
|
+
}
|
|
19527
|
+
|
|
19528
|
+
function play(matrix, w, maxLength) {
|
|
19529
|
+
const pending = new Set();
|
|
19530
|
+
for (let i = 0; i < w * w; i++) if (matrix[i]) pending.add(i);
|
|
19531
|
+
|
|
19532
|
+
// The snake starts on a dark module, and only moving lights one, so the
|
|
19533
|
+
// starting square has to be lit here or the finished code is a module
|
|
19534
|
+
// short -- a hole the error correction hides rather than a code that is
|
|
19535
|
+
// actually right.
|
|
19536
|
+
const start = [...pending][0];
|
|
19537
|
+
pending.delete(start);
|
|
19538
|
+
const snake = [start];
|
|
19539
|
+
const body = new Set(snake);
|
|
19540
|
+
const lit = new Set([start]);
|
|
19541
|
+
const frames = [];
|
|
19542
|
+
let budget = w * w * 6;
|
|
19543
|
+
|
|
19544
|
+
while (pending.size && --budget > 0) {
|
|
19545
|
+
const head = snake[snake.length - 1];
|
|
19546
|
+
const target = nearestTarget(head, pending, w);
|
|
19547
|
+
if (target < 0) break;
|
|
19548
|
+
const move = stepToward(head, target, body, w);
|
|
19549
|
+
if (move < 0) break;
|
|
19550
|
+
|
|
19551
|
+
snake.push(move);
|
|
19552
|
+
body.add(move);
|
|
19553
|
+
while (snake.length > maxLength) body.delete(snake.shift());
|
|
19554
|
+
if (matrix[move]) { lit.add(move); pending.delete(move); }
|
|
19555
|
+
|
|
19556
|
+
frames.push({ snake: [...snake], lit: [...lit], apple: target });
|
|
19557
|
+
}
|
|
19558
|
+
return frames;
|
|
19559
|
+
}
|
|
19560
|
+
|
|
19561
|
+
function mount(host) {
|
|
19562
|
+
if (host.dataset.mounted) return;
|
|
19563
|
+
host.dataset.mounted = '1';
|
|
19564
|
+
const matrix = JSON.parse(host.dataset.matrix);
|
|
19565
|
+
const w = Number(host.dataset.size);
|
|
19566
|
+
const SPEED = Number(host.dataset.speed) || 20; // ms a step
|
|
19567
|
+
host.style.setProperty('--cells', w);
|
|
19568
|
+
host.replaceChildren(...Array.from({ length: w * w }, () => document.createElement('i')));
|
|
19569
|
+
const dots = Array.from(host.children);
|
|
19570
|
+
|
|
19571
|
+
const frames = play(matrix, w, 14);
|
|
19572
|
+
const last = frames.length - 1;
|
|
19573
|
+
if (last < 1) return;
|
|
19574
|
+
const all = frames[last].lit;
|
|
19575
|
+
|
|
19576
|
+
// A lap stops short of the last modules and fades, rather than holding a
|
|
19577
|
+
// finished code that would read as the preview having arrived.
|
|
19578
|
+
const DRAW = Math.round(0.95 * last);
|
|
19579
|
+
const FADE = 20;
|
|
19580
|
+
const lap = DRAW + FADE;
|
|
19581
|
+
// Below this a lap is too unfinished for a sprint to be worth watching.
|
|
19582
|
+
const SPRINTABLE = 0.6;
|
|
19583
|
+
|
|
19584
|
+
// One clock for the whole wait. <main> is replaced as the upload advances,
|
|
19585
|
+
// so a board may be a later stand-in for an earlier one; it has to carry
|
|
19586
|
+
// on from where that one stopped instead of starting the code over.
|
|
19587
|
+
window.__snakeStart = window.__snakeStart || Date.now();
|
|
19588
|
+
|
|
19589
|
+
let sprint = null;
|
|
19590
|
+
|
|
19591
|
+
/**
|
|
19592
|
+
* Only the cells that changed. Repainting all 841 every frame meant ~2500
|
|
19593
|
+
* class writes 50 times a second to move a 14-cell snake; this touches
|
|
19594
|
+
* about 30. The lit list only ever grows within a pass, so the new
|
|
19595
|
+
* modules are its tail, and the body and the apple are small.
|
|
19596
|
+
*
|
|
19597
|
+
* The settle flag is off while the snake is only wandering: the flash
|
|
19598
|
+
* means a module was just revealed, and nothing is revealed then.
|
|
19599
|
+
*/
|
|
19600
|
+
const litSet = new Set();
|
|
19601
|
+
let litCount = 0;
|
|
19602
|
+
let prevBody = [];
|
|
19603
|
+
let prevApple = -1;
|
|
19604
|
+
|
|
19605
|
+
const cell = (k, className, opacity) => {
|
|
19606
|
+
const dot = dots[k];
|
|
19607
|
+
if (dot.className !== className) dot.className = className;
|
|
19608
|
+
if (dot.style.opacity !== opacity) dot.style.opacity = opacity;
|
|
19609
|
+
};
|
|
19610
|
+
const restingClass = (k) => (litSet.has(k) ? 'lit' : '');
|
|
19611
|
+
|
|
19612
|
+
const paint = ({ snake, lit, apple }, settle = true) => {
|
|
19613
|
+
if (lit.length < litCount) { // a fresh pass: start from an empty board
|
|
19614
|
+
litSet.clear(); litCount = 0; prevBody = []; prevApple = -1;
|
|
19615
|
+
for (const dot of dots) { dot.className = ''; dot.style.opacity = ''; }
|
|
19616
|
+
}
|
|
19617
|
+
// Paint every new module here rather than relying on the body to
|
|
19618
|
+
// uncover it: frames are skipped whenever the board moves faster than
|
|
19619
|
+
// one step a tick -- the sprint skips dozens -- and a module the body
|
|
19620
|
+
// never sat on would otherwise stay dark in a finished code.
|
|
19621
|
+
for (let i = litCount; i < lit.length; i++) { litSet.add(lit[i]); cell(lit[i], 'lit', ''); }
|
|
19622
|
+
litCount = lit.length;
|
|
19623
|
+
|
|
19624
|
+
// The module the snake lit is under its head; it shows when the tail
|
|
19625
|
+
// clears it, so the flash belongs to the cell the body just left.
|
|
19626
|
+
for (const k of prevBody)
|
|
19627
|
+
if (!snake.includes(k))
|
|
19628
|
+
cell(k, litSet.has(k) && settle ? 'lit fresh' : restingClass(k), '');
|
|
19629
|
+
|
|
19630
|
+
const length = snake.length;
|
|
19631
|
+
snake.forEach((k, i) => cell(k, 'on', String(0.2 + 0.55 * ((i + 1) / length))));
|
|
19632
|
+
prevBody = snake;
|
|
19633
|
+
|
|
19634
|
+
if (prevApple !== apple) {
|
|
19635
|
+
if (prevApple >= 0 && !snake.includes(prevApple))
|
|
19636
|
+
cell(prevApple, restingClass(prevApple), '');
|
|
19637
|
+
if (apple >= 0) cell(apple, 'apple', '');
|
|
19638
|
+
prevApple = apple;
|
|
19639
|
+
}
|
|
19640
|
+
};
|
|
19641
|
+
|
|
19642
|
+
const step = () => Math.floor((Date.now() - window.__snakeStart) / SPEED) % lap;
|
|
19643
|
+
/** How far into its draw this lap is, 0 to 1. */
|
|
19644
|
+
const lapProgress = () => Math.min(1, step() / DRAW);
|
|
19645
|
+
|
|
19646
|
+
if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) {
|
|
19647
|
+
paint(frames[Math.floor(DRAW / 3)], false);
|
|
19648
|
+
host.finish = () => Promise.resolve();
|
|
19649
|
+
return;
|
|
19650
|
+
}
|
|
19651
|
+
|
|
19652
|
+
const timer = setInterval(() => {
|
|
19653
|
+
// The page swaps <main> as the upload advances; stop with the old board.
|
|
19654
|
+
if (!host.isConnected) { clearInterval(timer); return; }
|
|
19655
|
+
if (sprint) {
|
|
19656
|
+
const k = Math.min(1, (Date.now() - sprint.at) / sprint.ms);
|
|
19657
|
+
const p = sprint.from + (1 - sprint.from) * k;
|
|
19658
|
+
if (p >= 1) {
|
|
19659
|
+
paint({ snake: [], lit: all, apple: -1 });
|
|
19660
|
+
clearInterval(timer);
|
|
19661
|
+
sprint.done();
|
|
19662
|
+
return;
|
|
19663
|
+
}
|
|
19664
|
+
paint(frames[Math.round(p * last)]);
|
|
19665
|
+
return;
|
|
19666
|
+
}
|
|
19667
|
+
const at = step();
|
|
19668
|
+
if (at > DRAW) { // fading out before the next lap
|
|
19669
|
+
host.style.opacity = String(1 - (at - DRAW) / FADE);
|
|
19670
|
+
return;
|
|
19671
|
+
}
|
|
19672
|
+
if (host.style.opacity) host.style.opacity = '';
|
|
19673
|
+
paint(frames[at]);
|
|
19674
|
+
}, SPEED);
|
|
19675
|
+
|
|
19676
|
+
host.finish = () => {
|
|
19677
|
+
if (sprint) return Promise.resolve();
|
|
19678
|
+
const from = lapProgress();
|
|
19679
|
+
if (from < SPRINTABLE) return Promise.resolve();
|
|
19680
|
+
host.style.opacity = '';
|
|
19681
|
+
sprint = { from, at: Date.now(), ms: 300 + 500 * (1 - from), done: () => {} };
|
|
19682
|
+
return new Promise((resolve) => { sprint.done = resolve; });
|
|
19683
|
+
};
|
|
19684
|
+
}
|
|
19685
|
+
|
|
19686
|
+
const boards = () => [...document.querySelectorAll('.snake')];
|
|
19687
|
+
const start = () => boards().forEach(mount);
|
|
19688
|
+
window.__mountSnakes = start;
|
|
19689
|
+
window.__snakeFinish = () => Promise.all(boards().map((b) => b.finish?.()));
|
|
19690
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
|
|
19691
|
+
else start();
|
|
19692
|
+
})();`;
|
|
19693
|
+
|
|
19422
19694
|
const VIBE_PAGE_WORKER = '__vibe-page-server';
|
|
19423
19695
|
// Includes the base64 form of the locally validated image (up to 10 MiB).
|
|
19424
19696
|
const VIBE_PAGE_HTML_LIMIT = 16 * 1024 * 1024;
|
|
19425
19697
|
const pageUpdates = `(() => {
|
|
19426
19698
|
let etag;
|
|
19427
19699
|
const terminal = () => ['complete', 'preview', 'failed'].includes(document.querySelector('main')?.dataset.phase);
|
|
19700
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
19701
|
+
async function replace(current, updated) {
|
|
19702
|
+
const animate = current.dataset.phase !== updated.dataset.phase && current.animate &&
|
|
19703
|
+
!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
19704
|
+
const height = current.getBoundingClientRect().height;
|
|
19705
|
+
if (animate) await current.animate([{opacity: 1}, {opacity: 0}], {duration: 140, fill: 'forwards'}).finished.catch(() => {});
|
|
19706
|
+
current.replaceWith(updated);
|
|
19707
|
+
window.__mountSnakes?.();
|
|
19708
|
+
if (animate) await updated.animate([
|
|
19709
|
+
{opacity: 0, height: height + 'px', overflow: 'hidden'},
|
|
19710
|
+
{opacity: 1, height: updated.getBoundingClientRect().height + 'px', overflow: 'hidden'}
|
|
19711
|
+
], {duration: 280, easing: 'ease-out'}).finished.catch(() => {});
|
|
19712
|
+
}
|
|
19713
|
+
async function show(updated) {
|
|
19714
|
+
let current = document.querySelector('main');
|
|
19715
|
+
if (!current || current.dataset.rev === updated.dataset.rev) return;
|
|
19716
|
+
if (updated.dataset.phase === 'preview' && current.querySelector('.snake'))
|
|
19717
|
+
await window.__snakeFinish?.();
|
|
19718
|
+
if (updated.dataset.uploaded === 'true' && current.dataset.uploaded !== 'true') {
|
|
19719
|
+
// Show the upload receipt before either the binding or ready preview QR,
|
|
19720
|
+
// even when polling skips intermediate upload states.
|
|
19721
|
+
const success = updated.cloneNode(true);
|
|
19722
|
+
success.dataset.phase = 'upload_success';
|
|
19723
|
+
delete success.dataset.uploaded;
|
|
19724
|
+
const heading = success.querySelector('.heading');
|
|
19725
|
+
success.querySelector('h1').textContent = heading.dataset.uploadTitle;
|
|
19726
|
+
success.querySelector('.subtitle').textContent = heading.dataset.uploadSubtitle;
|
|
19727
|
+
success.querySelectorAll('.qr-area, .scan-action, .scan-hint, .preview-loading').forEach(node => node.remove());
|
|
19728
|
+
await replace(current, success);
|
|
19729
|
+
current = success;
|
|
19730
|
+
await delay(1200);
|
|
19731
|
+
}
|
|
19732
|
+
await replace(current, updated);
|
|
19733
|
+
}
|
|
19428
19734
|
async function refresh() {
|
|
19429
19735
|
if (terminal()) return;
|
|
19430
19736
|
try {
|
|
@@ -19432,9 +19738,10 @@ const pageUpdates = `(() => {
|
|
|
19432
19738
|
if (response.ok) {
|
|
19433
19739
|
etag = response.headers.get('etag');
|
|
19434
19740
|
const next = new DOMParser().parseFromString(await response.text(), 'text/html');
|
|
19435
|
-
const
|
|
19436
|
-
if (
|
|
19741
|
+
const updated = next.querySelector('main');
|
|
19742
|
+
if (updated) await show(updated);
|
|
19437
19743
|
document.title = next.title;
|
|
19744
|
+
document.documentElement.lang = next.documentElement.lang;
|
|
19438
19745
|
}
|
|
19439
19746
|
} catch { /* Keep the current page readable during a temporary connection failure. */ }
|
|
19440
19747
|
if (!terminal()) setTimeout(refresh, 2000);
|
|
@@ -19444,12 +19751,20 @@ const pageUpdates = `(() => {
|
|
|
19444
19751
|
const escape = (s) => s.replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
19445
19752
|
async function renderVibePage(input) {
|
|
19446
19753
|
const zh = input.language !== 'en-US';
|
|
19754
|
+
const message = input.localizedMessages?.[zh ? 'zh-CN' : 'en-US'] ?? input.message;
|
|
19755
|
+
const tool = input.minisType === 'MINI_TOOL';
|
|
19447
19756
|
const phase = input.phase ||
|
|
19448
19757
|
(input.purpose === 'authorization_binding' ? 'binding' : 'uploading');
|
|
19758
|
+
const uploadedBinding = !input.simulation && input.purpose === 'authorization_binding' &&
|
|
19759
|
+
(phase === 'waiting_preview' || phase === 'preview' || phase === 'complete');
|
|
19760
|
+
const preview = !input.simulation && phase === 'preview' &&
|
|
19761
|
+
(input.purpose === 'game_preview' || input.purpose === 'tool_preview');
|
|
19762
|
+
const uploaded = uploadedBinding || preview;
|
|
19449
19763
|
const copy = zh
|
|
19450
19764
|
? {
|
|
19451
|
-
steps: ['扫码授权', '上传游戏', '
|
|
19765
|
+
steps: ['扫码授权', '上传游戏', '预览'],
|
|
19452
19766
|
mock: input.hybrid ? 'PPE + Mock' : '模拟',
|
|
19767
|
+
game: '当前游戏',
|
|
19453
19768
|
gameIcon: '游戏头像',
|
|
19454
19769
|
bindingTitle: '上传到 TikTok',
|
|
19455
19770
|
bindingAction: input.hybrid ? '真实授权二维码 · 混合联调' : '使用 TikTok 扫描二维码',
|
|
@@ -19462,6 +19777,7 @@ async function renderVibePage(input) {
|
|
|
19462
19777
|
uploadingTitle: '正在上传小游戏',
|
|
19463
19778
|
uploadingSubtitle: input.simulation ? '正在模拟授权后的上传流程,不会上传游戏内容。' : '授权已完成,正在上传本次游戏内容。',
|
|
19464
19779
|
uploadLabel: input.simulation ? '模拟上传进度' : '上传进度',
|
|
19780
|
+
uploadStatus: '正在上传游戏,请稍候',
|
|
19465
19781
|
completeTitle: input.simulation ? '模拟上传完成' : '上传完成',
|
|
19466
19782
|
completeSubtitle: input.simulation
|
|
19467
19783
|
? '绑定和上传流程模拟完成,未向 TikTok 上传游戏。'
|
|
@@ -19470,11 +19786,11 @@ async function renderVibePage(input) {
|
|
|
19470
19786
|
bindingCode: '授权绑定二维码',
|
|
19471
19787
|
accepted: input.simulation ? '模拟完成' : '已上传',
|
|
19472
19788
|
mockNote: input.hybrid ? '真实创建 / 查询任务 · 授权 / 上传为模拟 · 不改变真实任务状态' : '模拟运行 · 无需扫码,不会真实上传',
|
|
19473
|
-
footer: '临时页面 · 15 分钟后关闭',
|
|
19474
19789
|
}
|
|
19475
19790
|
: {
|
|
19476
|
-
steps: ['
|
|
19791
|
+
steps: ['Scan', 'Upload', 'Preview'],
|
|
19477
19792
|
mock: input.hybrid ? 'PPE + Mock' : 'MOCK',
|
|
19793
|
+
game: 'YOUR GAME',
|
|
19478
19794
|
gameIcon: 'Game icon',
|
|
19479
19795
|
bindingTitle: 'Upload to TikTok',
|
|
19480
19796
|
bindingAction: input.hybrid ? 'Real authorization QR · integration demo' : 'Scan the QR code with TikTok',
|
|
@@ -19491,6 +19807,7 @@ async function renderVibePage(input) {
|
|
|
19491
19807
|
uploadLabel: input.simulation
|
|
19492
19808
|
? 'Simulated upload progress'
|
|
19493
19809
|
: 'Upload progress',
|
|
19810
|
+
uploadStatus: 'Uploading your game. Please wait.',
|
|
19494
19811
|
completeTitle: input.simulation ? 'Simulated upload complete' : 'Upload complete',
|
|
19495
19812
|
completeSubtitle: input.simulation
|
|
19496
19813
|
? 'Binding and upload simulation complete. Nothing was uploaded to TikTok.'
|
|
@@ -19499,8 +19816,17 @@ async function renderVibePage(input) {
|
|
|
19499
19816
|
bindingCode: 'Authorization QR',
|
|
19500
19817
|
accepted: input.simulation ? 'Simulation complete' : 'Uploaded',
|
|
19501
19818
|
mockNote: input.hybrid ? 'Real task creation / polling · Mock authorization / upload · Real task status unchanged' : 'Mock only · no scan needed, nothing is uploaded',
|
|
19502
|
-
footer: 'Temporary page · closes after 15 minutes',
|
|
19503
19819
|
};
|
|
19820
|
+
if (tool) {
|
|
19821
|
+
for (const key of Object.keys(copy)) {
|
|
19822
|
+
const value = copy[key];
|
|
19823
|
+
if (typeof value === 'string')
|
|
19824
|
+
copy[key] = value.replace(/小游戏|游戏/g, '工具').replace(/game/gi, 'tool');
|
|
19825
|
+
}
|
|
19826
|
+
copy.steps[1] = zh ? '上传工具' : 'Upload';
|
|
19827
|
+
}
|
|
19828
|
+
if (input.simulation)
|
|
19829
|
+
copy.steps[2] = zh ? '完成' : 'Done';
|
|
19504
19830
|
if (input.web) {
|
|
19505
19831
|
copy.steps[0] = zh ? '网页授权' : 'Web authorization';
|
|
19506
19832
|
copy.bindingAction = zh ? '在浏览器完成授权绑定' : 'Authorize in your browser';
|
|
@@ -19509,70 +19835,106 @@ async function renderVibePage(input) {
|
|
|
19509
19835
|
: (zh ? '请在已打开的 TikTok 页面确认授权,当前命令会继续查询绑定状态。' : 'Confirm authorization on the opened TikTok page. The command continues polling.');
|
|
19510
19836
|
copy.bindingStatus = input.simulation ? (zh ? '模拟等待授权' : 'Simulating authorization') : (zh ? '等待网页授权' : 'Waiting for browser authorization');
|
|
19511
19837
|
}
|
|
19512
|
-
const step = phase === 'binding' ? 0 : phase === 'uploading' ? 1 : 2;
|
|
19838
|
+
const step = phase === 'binding' ? 0 : phase === 'uploading' ? 1 : phase === 'preview' ? 3 : 2;
|
|
19513
19839
|
// Only embed the chosen raster image; never fetch a URL or expose its local path.
|
|
19514
19840
|
const icon = input.iconDataUrl &&
|
|
19515
19841
|
input.iconDataUrl.length <= 14 * 1024 * 1024 &&
|
|
19516
19842
|
/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+=*$/.test(input.iconDataUrl)
|
|
19517
19843
|
? `<img class="game-avatar" width="44" height="44" alt="${copy.gameIcon}" src="${input.iconDataUrl}">`
|
|
19518
19844
|
: '<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>';
|
|
19519
|
-
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
|
|
19845
|
+
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>`;
|
|
19520
19846
|
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>';
|
|
19521
|
-
const
|
|
19522
|
-
|
|
19523
|
-
|
|
19524
|
-
|
|
19525
|
-
|
|
19526
|
-
|
|
19527
|
-
|
|
19528
|
-
? copy.failedTitle
|
|
19529
|
-
: copy.completeTitle;
|
|
19530
|
-
const subtitle = phase === 'waiting_preview' ? (zh ? '游戏内容已上传,预览就绪后会自动显示二维码。' : 'Game content uploaded. The preview QR will appear when ready.')
|
|
19531
|
-
: phase === 'preview' ? (zh ? '上传完成,使用手机 TikTok 扫描下方二维码。' : 'Upload complete. Scan the QR below with TikTok on your phone.')
|
|
19532
|
-
: phase === 'complete' && !input.simulation ? escape(input.message)
|
|
19847
|
+
const uploadSuccessTitle = zh ? '上传成功' : 'Upload complete';
|
|
19848
|
+
const uploadSuccessSubtitle = zh
|
|
19849
|
+
? `${tool ? '工具' : '游戏'}内容已上传,正在返回扫码页面。`
|
|
19850
|
+
: `Your ${tool ? 'tool' : 'game'} has been uploaded. Returning to the scan page.`;
|
|
19851
|
+
const title = uploadedBinding ? (phase === 'waiting_preview' ? (zh ? '正在生成预览' : 'Preparing preview') : zh ? '扫码查看进度' : 'Scan to check progress')
|
|
19852
|
+
: phase === 'waiting_preview' ? (zh ? '正在准备预览' : 'Preparing preview')
|
|
19853
|
+
: phase === 'preview' ? (zh ? `扫码预览${tool ? '工具' : '游戏'}` : 'Scan to preview')
|
|
19533
19854
|
: phase === 'binding'
|
|
19534
|
-
? copy.
|
|
19855
|
+
? copy.bindingTitle
|
|
19535
19856
|
: phase === 'uploading'
|
|
19536
|
-
? copy.
|
|
19857
|
+
? copy.uploadingTitle
|
|
19537
19858
|
: phase === 'failed'
|
|
19538
|
-
?
|
|
19539
|
-
: copy.
|
|
19540
|
-
const
|
|
19859
|
+
? copy.failedTitle
|
|
19860
|
+
: copy.completeTitle;
|
|
19861
|
+
const subtitle = uploadedBinding ? (phase === 'complete' ? escape(message) : phase === 'waiting_preview'
|
|
19862
|
+
? (zh ? '代码包已上传,正在生成预览。准备好后会自动显示预览二维码。' : 'Package uploaded. Your preview is being prepared; its QR will appear when ready.') : zh
|
|
19863
|
+
? `本次${tool ? '工具' : '游戏'}代码包已上传完成,再次扫码即可查看预览版本并提交审核。`
|
|
19864
|
+
: `Your ${tool ? 'tool' : 'game'} package has been uploaded. Scan again to view the preview version and submit it for review.`)
|
|
19865
|
+
: phase === 'waiting_preview' ? (zh ? '内容已上传,预览就绪后会自动显示二维码。' : 'Content uploaded. The preview QR will appear when ready.')
|
|
19866
|
+
: phase === 'preview' ? ''
|
|
19867
|
+
: phase === 'complete' && !input.simulation ? escape(message)
|
|
19868
|
+
: phase === 'binding'
|
|
19869
|
+
? copy.bindingSubtitle
|
|
19870
|
+
: phase === 'uploading'
|
|
19871
|
+
? copy.uploadingSubtitle
|
|
19872
|
+
: phase === 'failed'
|
|
19873
|
+
? escape(message)
|
|
19874
|
+
: copy.completeSubtitle;
|
|
19875
|
+
const qr = (phase === 'binding' || phase === 'uploading' || phase === 'preview' || uploadedBinding) && !input.web && input.qrUrl
|
|
19541
19876
|
? await QRCode.toDataURL(input.qrUrl, {
|
|
19542
19877
|
width: 384,
|
|
19543
|
-
|
|
19878
|
+
// Fixed CSS quiet zones keep different QR versions visually equal.
|
|
19879
|
+
margin: 0,
|
|
19544
19880
|
errorCorrectionLevel: 'M',
|
|
19545
19881
|
})
|
|
19546
19882
|
: '';
|
|
19547
|
-
const
|
|
19548
|
-
const
|
|
19883
|
+
const progressCode = zh ? '查看进度二维码' : 'Progress QR';
|
|
19884
|
+
const purpose = preview ? (zh ? `${tool ? '工具' : '游戏'}预览二维码` : `${tool ? 'Tool' : 'Game'} preview QR`) : uploadedBinding || phase === 'uploading' ? (zh ? '应用页面二维码' : 'App page QR') : copy.bindingCode;
|
|
19885
|
+
const bindingQr = preview && !input.web && input.bindingQrUrl && input.bindingQrUrl !== input.qrUrl
|
|
19886
|
+
? await QRCode.toDataURL(input.bindingQrUrl, { width: 384, margin: 0, errorCorrectionLevel: 'M' }) : '';
|
|
19887
|
+
const done = phase === 'preview' || phase === 'complete' && input.simulation;
|
|
19888
|
+
const active = phase === 'binding' || phase === 'uploading' || phase === 'waiting_preview';
|
|
19889
|
+
const waiting = phase === 'waiting_preview';
|
|
19890
|
+
const matrix = waiting ? QRCode.create('https://www.tiktok.com/minis/').modules : undefined;
|
|
19891
|
+
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>` : '';
|
|
19549
19892
|
const progress = typeof input.progressPercent === 'number' &&
|
|
19550
19893
|
Number.isFinite(input.progressPercent)
|
|
19551
19894
|
? Math.max(0, Math.min(100, Math.round(input.progressPercent)))
|
|
19552
19895
|
: undefined;
|
|
19896
|
+
const progressQr = 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>` : '';
|
|
19897
|
+
// Keep the original scan entry on the left while the right side becomes a preview.
|
|
19553
19898
|
const content = qr
|
|
19554
|
-
? `<div class="qr-area"><div class="qr-frame"><img width="
|
|
19899
|
+
? `<div class="qr-area">${progressQr}<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>${pendingQr}</div>`
|
|
19555
19900
|
: phase === 'uploading' && progress !== undefined
|
|
19556
19901
|
? `<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>`
|
|
19557
19902
|
: '';
|
|
19903
|
+
const previewLoading = phase === 'waiting_preview'
|
|
19904
|
+
? `<div class="preview-loading" role="progressbar" aria-label="${zh ? '正在生成预览' : 'Preparing preview'}"><span aria-hidden="true"></span></div>`
|
|
19905
|
+
: '';
|
|
19906
|
+
const revision = crypto.createHash('sha256').update(JSON.stringify(input)).digest('hex');
|
|
19907
|
+
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>`;
|
|
19558
19908
|
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>
|
|
19559
|
-
<body><main class="shell" data-phase="${phase}">${input.simulation ? `<p class="mock-badge">${copy.mock}</p>` : ''}
|
|
19560
|
-
<section class="card" aria-labelledby="page-title"
|
|
19561
|
-
<div class="heading"><h1 id="page-title">${title}</h1><p class="subtitle" role="status">${subtitle}</p
|
|
19909
|
+
<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>` : ''}
|
|
19910
|
+
<section class="card" aria-labelledby="page-title">
|
|
19911
|
+
<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>
|
|
19562
19912
|
</section>
|
|
19563
|
-
|
|
19913
|
+
${input.simulation ? `<p class="footer"><span class="dot" aria-hidden="true"></span>${copy.mockNote}</p>` : ''}</main></body></html>`;
|
|
19914
|
+
}
|
|
19915
|
+
// Follow the reader's preferred browser language, as in the Tool skill.
|
|
19916
|
+
function browserPageLanguage(header) {
|
|
19917
|
+
const preferred = (header || '').split(',').map(part => {
|
|
19918
|
+
const [tag, ...parameters] = part.trim().split(';');
|
|
19919
|
+
const quality = parameters.find(value => /^\s*q=/i.test(value));
|
|
19920
|
+
const q = quality ? Number(quality.split('=')[1]) : 1;
|
|
19921
|
+
return { tag: tag.toLowerCase(), q };
|
|
19922
|
+
}).filter(item => item.tag && Number.isFinite(item.q) && item.q > 0 && item.q <= 1)
|
|
19923
|
+
.sort((a, b) => b.q - a.q)[0];
|
|
19924
|
+
return preferred?.tag.split('-')[0] === 'zh' ? 'zh-CN' : 'en-US';
|
|
19564
19925
|
}
|
|
19565
19926
|
async function createVibePageServer() {
|
|
19566
19927
|
const route = `/${crypto.randomBytes(24).toString('hex')}`;
|
|
19567
19928
|
let html = 'Starting…';
|
|
19568
19929
|
let etag = '';
|
|
19930
|
+
let variants = {};
|
|
19569
19931
|
let landingUrl;
|
|
19570
19932
|
const server = http.createServer((req, res) => {
|
|
19571
19933
|
const address = server.address();
|
|
19572
19934
|
const host = address && typeof address !== 'string' ? `127.0.0.1:${address.port}` : '';
|
|
19573
19935
|
if (req.method === 'GET' && req.url === `${route}?updates` && req.headers.host === host) {
|
|
19574
19936
|
res.writeHead(200, { 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' });
|
|
19575
|
-
res.end(pageUpdates);
|
|
19937
|
+
res.end(qrPreviewLoader + '\n' + pageUpdates);
|
|
19576
19938
|
return;
|
|
19577
19939
|
}
|
|
19578
19940
|
if (req.url === `${route}/authorize` && req.headers.host === host &&
|
|
@@ -19595,19 +19957,23 @@ async function createVibePageServer() {
|
|
|
19595
19957
|
res.writeHead(404).end();
|
|
19596
19958
|
return;
|
|
19597
19959
|
}
|
|
19598
|
-
|
|
19599
|
-
|
|
19960
|
+
const localized = variants[browserPageLanguage(req.headers['accept-language'])];
|
|
19961
|
+
const responseHtml = localized?.html ?? html;
|
|
19962
|
+
const responseEtag = localized?.etag ?? etag;
|
|
19963
|
+
if (responseEtag && req.headers['if-none-match'] === responseEtag) {
|
|
19964
|
+
res.writeHead(304, { 'ETag': responseEtag, 'Cache-Control': 'no-store', 'Vary': 'Accept-Language' }).end();
|
|
19600
19965
|
return;
|
|
19601
19966
|
}
|
|
19602
19967
|
res.writeHead(200, {
|
|
19603
|
-
'ETag':
|
|
19968
|
+
'ETag': responseEtag,
|
|
19969
|
+
'Vary': 'Accept-Language',
|
|
19604
19970
|
'Content-Type': 'text/html; charset=utf-8',
|
|
19605
19971
|
'Cache-Control': 'no-store',
|
|
19606
19972
|
'Referrer-Policy': 'no-referrer',
|
|
19607
19973
|
'X-Content-Type-Options': 'nosniff',
|
|
19608
19974
|
'Content-Security-Policy': "default-src 'none'; img-src data:; style-src 'unsafe-inline'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'",
|
|
19609
19975
|
});
|
|
19610
|
-
res.end(
|
|
19976
|
+
res.end(responseHtml);
|
|
19611
19977
|
});
|
|
19612
19978
|
await new Promise((resolve, reject) => {
|
|
19613
19979
|
server.once('error', reject);
|
|
@@ -19616,9 +19982,15 @@ async function createVibePageServer() {
|
|
|
19616
19982
|
const address = server.address();
|
|
19617
19983
|
return {
|
|
19618
19984
|
url: `http://127.0.0.1:${address.port}${route}`,
|
|
19619
|
-
update: (value, authorization) => {
|
|
19985
|
+
update: (value, authorization, localizedHtml) => {
|
|
19620
19986
|
html = value;
|
|
19621
19987
|
etag = '"' + crypto.createHash('sha256').update(value).digest('hex') + '"';
|
|
19988
|
+
variants = {};
|
|
19989
|
+
for (const language of ['zh-CN', 'en-US']) {
|
|
19990
|
+
const localized = localizedHtml?.[language];
|
|
19991
|
+
if (typeof localized === 'string' && localized.length < VIBE_PAGE_HTML_LIMIT)
|
|
19992
|
+
variants[language] = { html: localized, etag: '"' + crypto.createHash('sha256').update(localized).digest('hex') + '"' };
|
|
19993
|
+
}
|
|
19622
19994
|
landingUrl = browserLandingUrl(authorization);
|
|
19623
19995
|
},
|
|
19624
19996
|
close: () => server.close(),
|
|
@@ -19631,24 +20003,34 @@ async function runVibePageWorker() {
|
|
|
19631
20003
|
}
|
|
19632
20004
|
const server = await createVibePageServer();
|
|
19633
20005
|
const requestedTtl = Number(process.env.TTMG_VIBE_PAGE_TTL_MS);
|
|
19634
|
-
const ttl = requestedTtl > 0 && requestedTtl <=
|
|
19635
|
-
|
|
20006
|
+
const ttl = requestedTtl > 0 && requestedTtl <= 1800000 ? requestedTtl : 1800000;
|
|
20007
|
+
let timer;
|
|
20008
|
+
let closing = false;
|
|
20009
|
+
const close = () => {
|
|
20010
|
+
closing = true;
|
|
20011
|
+
clearTimeout(timer);
|
|
19636
20012
|
server.close();
|
|
19637
20013
|
if (process.connected)
|
|
19638
20014
|
process.disconnect();
|
|
19639
|
-
}
|
|
20015
|
+
};
|
|
20016
|
+
// The parent owns the operation deadline. Keep the page alive during polling,
|
|
20017
|
+
// then start its retention window when the parent detaches (or exits).
|
|
20018
|
+
const retain = () => {
|
|
20019
|
+
if (!closing && !timer)
|
|
20020
|
+
timer = setTimeout(close, ttl);
|
|
20021
|
+
};
|
|
20022
|
+
process.once('disconnect', retain);
|
|
20023
|
+
if (!process.connected)
|
|
20024
|
+
retain();
|
|
19640
20025
|
process.on('message', (message) => {
|
|
19641
20026
|
if (message?.type === 'render' &&
|
|
19642
20027
|
typeof message.html === 'string' &&
|
|
19643
20028
|
message.html.length < VIBE_PAGE_HTML_LIMIT) {
|
|
19644
|
-
server.update(message.html, message.browserLandingUrl);
|
|
20029
|
+
server.update(message.html, message.browserLandingUrl, message.localizedHtml);
|
|
19645
20030
|
process.send?.({ type: 'rendered', id: message.id });
|
|
19646
20031
|
}
|
|
19647
20032
|
if (message?.type === 'close') {
|
|
19648
|
-
|
|
19649
|
-
server.close();
|
|
19650
|
-
if (process.connected)
|
|
19651
|
-
process.disconnect();
|
|
20033
|
+
close();
|
|
19652
20034
|
}
|
|
19653
20035
|
});
|
|
19654
20036
|
process.send({ type: 'ready', url: server.url });
|
|
@@ -19686,11 +20068,15 @@ async function startVibePage() {
|
|
|
19686
20068
|
return {
|
|
19687
20069
|
url: ready.url,
|
|
19688
20070
|
async update(input) {
|
|
19689
|
-
const
|
|
20071
|
+
const [zh, en] = await Promise.all([
|
|
20072
|
+
renderVibePage({ ...input, language: 'zh-CN' }),
|
|
20073
|
+
renderVibePage({ ...input, language: 'en-US' }),
|
|
20074
|
+
]);
|
|
20075
|
+
const html = input.language === 'en-US' ? en : zh;
|
|
19690
20076
|
const current = ++id;
|
|
19691
20077
|
const ack = receive(m => m?.type === 'rendered' && m.id === current);
|
|
19692
20078
|
const landingUrl = input.phase === 'binding' ? browserLandingUrl(input.browserLandingUrl) : undefined;
|
|
19693
|
-
child.send({ type: 'render', id: current, html, browserLandingUrl: landingUrl }, error => {
|
|
20079
|
+
child.send({ type: 'render', id: current, html, localizedHtml: { 'zh-CN': zh, 'en-US': en }, browserLandingUrl: landingUrl }, error => {
|
|
19694
20080
|
if (error)
|
|
19695
20081
|
child.emit('error', error);
|
|
19696
20082
|
});
|
|
@@ -19714,6 +20100,7 @@ async function startVibePage() {
|
|
|
19714
20100
|
|
|
19715
20101
|
// Source identity is project metadata, not a Skill input or a credential.
|
|
19716
20102
|
function getVibeProjectId(options) {
|
|
20103
|
+
const minisType = resolveMinisType(options.minisType);
|
|
19717
20104
|
const root = path.resolve(options.package ? path.dirname(options.package) : options.dir || '.');
|
|
19718
20105
|
const dir = path.join(root, '.ttmg');
|
|
19719
20106
|
const file = path.join(dir, 'vibe-project.json');
|
|
@@ -19721,7 +20108,7 @@ function getVibeProjectId(options) {
|
|
|
19721
20108
|
fs.mkdirSync(dir, { recursive: true });
|
|
19722
20109
|
const id = crypto.randomUUID();
|
|
19723
20110
|
try {
|
|
19724
|
-
fs.writeFileSync(file, JSON.stringify({ schemaVersion: '1', sourceProjectId: id }) + '\n', { flag: 'wx', mode: 0o600 });
|
|
20111
|
+
fs.writeFileSync(file, JSON.stringify({ schemaVersion: '1', sourceProjectId: id, minisType }) + '\n', { flag: 'wx', mode: 0o600 });
|
|
19725
20112
|
}
|
|
19726
20113
|
catch (error) {
|
|
19727
20114
|
if (error.code !== 'EEXIST')
|
|
@@ -19732,9 +20119,13 @@ function getVibeProjectId(options) {
|
|
|
19732
20119
|
typeof saved.sourceProjectId !== 'string' ||
|
|
19733
20120
|
!/^[a-zA-Z0-9_-]{1,100}$/.test(saved.sourceProjectId))
|
|
19734
20121
|
throw new Error();
|
|
20122
|
+
if ((saved.minisType || 'MINI_GAME') !== minisType)
|
|
20123
|
+
throw new VibeError('VIBE_PROJECT_TYPE_CONFLICT');
|
|
19735
20124
|
return saved.sourceProjectId;
|
|
19736
20125
|
}
|
|
19737
|
-
catch {
|
|
20126
|
+
catch (error) {
|
|
20127
|
+
if (error instanceof VibeError)
|
|
20128
|
+
throw error;
|
|
19738
20129
|
throw new VibeError('VIBE_PROJECT_STATE_FAILED');
|
|
19739
20130
|
}
|
|
19740
20131
|
}
|
|
@@ -19822,6 +20213,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19822
20213
|
let page;
|
|
19823
20214
|
let backend = deps.backend;
|
|
19824
20215
|
let task;
|
|
20216
|
+
let authorizationUrl;
|
|
19825
20217
|
let detached = false;
|
|
19826
20218
|
let progressUpdates = Promise.resolve();
|
|
19827
20219
|
let ppeLane;
|
|
@@ -19875,6 +20267,10 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19875
20267
|
try {
|
|
19876
20268
|
if (options.web)
|
|
19877
20269
|
throw new VibeError('VIBE_WEB_DISABLED');
|
|
20270
|
+
const minisType = resolveMinisType(options.minisType);
|
|
20271
|
+
result.minisType = minisType;
|
|
20272
|
+
if (minisType === 'MINI_TOOL')
|
|
20273
|
+
result.inputRequirements = VIBE_TOOL_INPUT_REQUIREMENTS;
|
|
19878
20274
|
// Real QR uploads use the release-owned PPE route.
|
|
19879
20275
|
// Explicit test backends remain opt-in; real failures never fall back to them.
|
|
19880
20276
|
if (!options.mock && !options.vibeApi && process.env.TTMG_VIBE_BACKEND) {
|
|
@@ -19915,7 +20311,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19915
20311
|
throw new VibeError('VIBE_BACKEND_OPTION_CONFLICT');
|
|
19916
20312
|
if (options.pollInterval !== undefined)
|
|
19917
20313
|
seconds(options.pollInterval, 1);
|
|
19918
|
-
const timeoutMs = seconds(options.timeout,
|
|
20314
|
+
const timeoutMs = seconds(options.timeout, 1800);
|
|
19919
20315
|
timeout = setTimeout(() => {
|
|
19920
20316
|
timedOut = true;
|
|
19921
20317
|
controller.abort();
|
|
@@ -19950,7 +20346,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19950
20346
|
category: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).category,
|
|
19951
20347
|
subcategory: (input.appInfo || VIBE_PPE_DEFAULT_APP_INFO).subcategory,
|
|
19952
20348
|
source: options.category !== undefined ? 'arguments' : options.appInfo !== undefined ? 'app-info' : 'defaults',
|
|
19953
|
-
catalogVersion: GAME_CATEGORY_CATALOG_VERSION,
|
|
20349
|
+
catalogVersion: minisType === 'MINI_TOOL' ? 'mini-tool-ppe-trial-2026-09-19' : GAME_CATEGORY_CATALOG_VERSION,
|
|
19954
20350
|
},
|
|
19955
20351
|
iconSizeBytes: input.icon.bytes.length,
|
|
19956
20352
|
packageSizeBytes: input.code.bytes.length,
|
|
@@ -19962,6 +20358,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19962
20358
|
return result;
|
|
19963
20359
|
const submittedInfo = input.appInfo || VIBE_PPE_DEFAULT_APP_INFO;
|
|
19964
20360
|
pageMetadata = {
|
|
20361
|
+
minisType,
|
|
19965
20362
|
iconDataUrl: `data:${input.icon.contentType};base64,${input.icon.bytes.toString('base64')}`,
|
|
19966
20363
|
description: submittedInfo.description,
|
|
19967
20364
|
category: submittedInfo.category,
|
|
@@ -19982,10 +20379,10 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
19982
20379
|
source_type: 1,
|
|
19983
20380
|
source_project_id: sourceProjectId,
|
|
19984
20381
|
task_idempotency_id: taskIdempotencyId,
|
|
19985
|
-
minis_type:
|
|
20382
|
+
minis_type: minisType,
|
|
19986
20383
|
}, controller.signal);
|
|
19987
20384
|
ensureActive();
|
|
19988
|
-
|
|
20385
|
+
authorizationUrl = createAuthorizationScheme(task.landingUrl);
|
|
19989
20386
|
const pollMs = seconds(options.pollInterval, task.pollIntervalSeconds);
|
|
19990
20387
|
result = {
|
|
19991
20388
|
...result,
|
|
@@ -20064,6 +20461,8 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20064
20461
|
...pageGame,
|
|
20065
20462
|
language: getCurrentLanguage(),
|
|
20066
20463
|
phase: 'uploading',
|
|
20464
|
+
qrUrl: result.simulation ? undefined : authorizationUrl,
|
|
20465
|
+
purpose: result.simulation ? undefined : 'authorization_binding',
|
|
20067
20466
|
simulation: result.simulation,
|
|
20068
20467
|
message: text('uploading', result.simulation),
|
|
20069
20468
|
});
|
|
@@ -20102,6 +20501,8 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20102
20501
|
...pageGame,
|
|
20103
20502
|
language: getCurrentLanguage(),
|
|
20104
20503
|
phase: 'uploading',
|
|
20504
|
+
qrUrl: result.simulation ? undefined : authorizationUrl,
|
|
20505
|
+
purpose: result.simulation ? undefined : 'authorization_binding',
|
|
20105
20506
|
simulation: result.simulation,
|
|
20106
20507
|
message: text('uploading', result.simulation),
|
|
20107
20508
|
progressPercent: percent(loaded, validTotal),
|
|
@@ -20123,8 +20524,9 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20123
20524
|
throw progressPageError;
|
|
20124
20525
|
if (!result.simulation) {
|
|
20125
20526
|
emit('waiting_preview', { previewReady: false, terminal: false, nextAction: 'wait',
|
|
20126
|
-
qrPurpose:
|
|
20527
|
+
qrPurpose: 'authorization_binding', authorizationOpenCommand: undefined });
|
|
20127
20528
|
await page.update({ ...pageGame, language: getCurrentLanguage(), phase: 'waiting_preview',
|
|
20529
|
+
qrUrl: authorizationUrl, purpose: 'authorization_binding',
|
|
20128
20530
|
simulation: false, message: text('waiting_preview') });
|
|
20129
20531
|
while (true) {
|
|
20130
20532
|
ensureActive();
|
|
@@ -20148,17 +20550,20 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20148
20550
|
...pageGame,
|
|
20149
20551
|
language: getCurrentLanguage(),
|
|
20150
20552
|
phase: result.previewReady ? 'preview' : 'complete',
|
|
20151
|
-
qrUrl: result.previewUrl,
|
|
20152
|
-
|
|
20553
|
+
qrUrl: result.simulation ? undefined : result.previewUrl || authorizationUrl,
|
|
20554
|
+
bindingQrUrl: result.previewReady ? authorizationUrl : undefined,
|
|
20555
|
+
purpose: result.simulation ? undefined : result.previewReady
|
|
20556
|
+
? result.minisType === 'MINI_TOOL' ? 'tool_preview' : 'game_preview'
|
|
20557
|
+
: 'authorization_binding',
|
|
20153
20558
|
simulation: result.simulation,
|
|
20154
20559
|
message: text('uploaded', result.simulation),
|
|
20155
20560
|
});
|
|
20156
20561
|
page.detach();
|
|
20157
20562
|
detached = true;
|
|
20158
20563
|
return emit('uploaded', { terminal: true, nextAction: result.previewReady ? 'scan_qr' : 'none',
|
|
20159
|
-
qrPurpose: result.previewReady ? 'game_preview' : undefined,
|
|
20564
|
+
qrPurpose: result.previewReady ? result.minisType === 'MINI_TOOL' ? 'tool_preview' : 'game_preview' : undefined,
|
|
20160
20565
|
...(result.previewReady ? { message: getCurrentLanguage() === 'zh-CN'
|
|
20161
|
-
? '
|
|
20566
|
+
? '预览已就绪,请使用 TikTok 扫描预览二维码;也可扫描“查看进度”二维码查看应用信息并提交审核。' : 'Preview ready. Scan the preview QR with TikTok, or scan the progress QR to view app details and submit for review.' } : {}) });
|
|
20162
20567
|
}
|
|
20163
20568
|
catch (error) {
|
|
20164
20569
|
const code = timedOut
|
|
@@ -20176,6 +20581,9 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20176
20581
|
const messages = {
|
|
20177
20582
|
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.'],
|
|
20178
20583
|
VIBE_INVALID_CATEGORY: ['类型或子类型无效,或两者不匹配。使用 ttmg game categories --format json 查询有效组合。', 'Invalid category/subcategory pair. Query valid values with ttmg game categories --format json.'],
|
|
20584
|
+
VIBE_INVALID_MINIS_TYPE: ['应用类型须为 MINI_GAME 或 MINI_TOOL。', 'Minis type must be MINI_GAME or MINI_TOOL.'],
|
|
20585
|
+
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.'],
|
|
20586
|
+
VIBE_PROJECT_TYPE_CONFLICT: ['该工程已使用其他应用类型,请为新的 Tool 使用独立工程目录。', 'This project has a different Minis type. Use a separate project directory for a new Tool.'],
|
|
20179
20587
|
VIBE_INVALID_DESCRIPTION: ['描述必须是非空的有效 Unicode 文本;省略 --description 可使用默认描述。', 'Description must be non-empty valid Unicode text; omit --description to use the default.'],
|
|
20180
20588
|
VIBE_AUTH_DENIED: [
|
|
20181
20589
|
'已取消授权,本次未上传。',
|
|
@@ -20257,7 +20665,7 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20257
20665
|
text(status);
|
|
20258
20666
|
controller.abort();
|
|
20259
20667
|
await progressUpdates;
|
|
20260
|
-
//
|
|
20668
|
+
// After upload, preserve the original code for checking progress even if preview lookup stops.
|
|
20261
20669
|
if (page && (code !== 'VIBE_CANCELLED' || result.uploaded)) {
|
|
20262
20670
|
try {
|
|
20263
20671
|
await page.update({
|
|
@@ -20267,7 +20675,20 @@ async function executeVibeUpload(options, onEvent = () => { }, dependencies = {}
|
|
|
20267
20675
|
simulation: result.simulation,
|
|
20268
20676
|
hybrid: result.backend === 'ppe-mock',
|
|
20269
20677
|
phase: result.uploaded ? 'complete' : 'failed',
|
|
20270
|
-
|
|
20678
|
+
qrUrl: result.uploaded && !result.simulation ? authorizationUrl : undefined,
|
|
20679
|
+
purpose: result.uploaded && !result.simulation ? 'authorization_binding' : undefined,
|
|
20680
|
+
localizedMessages: result.uploaded && !result.simulation ? {
|
|
20681
|
+
'zh-CN': '代码包已上传,本页已停止等待预览。可扫码查看进度,无需重复上传。',
|
|
20682
|
+
'en-US': 'Package uploaded. This page has stopped waiting for the preview. Scan to check progress; no need to upload again.',
|
|
20683
|
+
} : {
|
|
20684
|
+
'zh-CN': messages[code]?.[0] || '本次操作未完成,请检查 CLI 输出。',
|
|
20685
|
+
'en-US': messages[code]?.[1] || 'This operation did not complete. Check the CLI output.',
|
|
20686
|
+
},
|
|
20687
|
+
message: result.uploaded && !result.simulation
|
|
20688
|
+
? getCurrentLanguage() === 'zh-CN'
|
|
20689
|
+
? '代码包已上传,本页已停止等待预览。可扫码查看进度,无需重复上传。'
|
|
20690
|
+
: 'Package uploaded. This page has stopped waiting for the preview. Scan to check progress; no need to upload again.'
|
|
20691
|
+
: message,
|
|
20271
20692
|
});
|
|
20272
20693
|
page.detach();
|
|
20273
20694
|
detached = true;
|