@ttmg/cli 0.3.7-beta.1 → 0.3.7-beta.3
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 +307 -36
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/public/assets/Detail-DZjhasKd.js +1 -0
- package/dist/public/assets/Detail-DZjhasKd.js.br +0 -0
- package/dist/public/assets/{baseForm-B7tArmif.js → baseForm-Dyl22bqB.js} +1 -1
- package/dist/public/assets/baseForm-Dyl22bqB.js.br +0 -0
- package/dist/public/assets/{index-TYa4eXxF.css → index-BBnWlodN.css} +1 -1
- package/dist/public/assets/index-BBnWlodN.css.br +0 -0
- package/dist/public/assets/{index-D35C4ac4.js → index-BKY0zDI7.js} +1 -1
- package/dist/public/assets/{index-aD1InxYk.js → index-BLRDSesS.js} +1 -1
- package/dist/public/assets/{index-BOiN8aIS.js → index-BUy8I0vu.js} +1 -1
- package/dist/public/assets/{index-DQqzytdw.js → index-BrSFFuip.js} +1 -1
- package/dist/public/assets/index-BrSFFuip.js.br +0 -0
- package/dist/public/assets/{index-BswgGVlz.js → index-C5pUkGpS.js} +1 -1
- package/dist/public/assets/index-C5pUkGpS.js.br +0 -0
- package/dist/public/assets/{index-tXDZpXMk.js → index-CBkk8KwT.js} +1 -1
- package/dist/public/assets/index-CBkk8KwT.js.br +0 -0
- package/dist/public/assets/{index-BVi9swz_.js → index-Cx35BU6U.js} +1 -1
- package/dist/public/assets/index-Cx35BU6U.js.br +0 -0
- package/dist/public/assets/{index-Sk6u8HWP.js → index-D48tyFsA.js} +1 -1
- package/dist/public/assets/{index-DkXWo3Jg.js → index-DD7xtDwI.js} +3 -3
- package/dist/public/assets/index-DD7xtDwI.js.br +0 -0
- package/dist/public/assets/{index-CDrq3KnY.js → index-HL2ryl1V.js} +1 -1
- package/dist/public/assets/{index-B0CT2rYr.js → index-KxEzggZ9.js} +1 -1
- package/dist/public/assets/{index-BlXhGm9R.js → index-_INIaBu0.js} +1 -1
- package/dist/public/assets/{index-DdH9Yin-.js → index-aXJ7ldcB.js} +1 -1
- package/dist/public/assets/{index-B-rc2X1H.js → index-bAz3gu-3.js} +1 -1
- package/dist/public/assets/{index-Cj-lTEG1.js → index-rDVdz60K.js} +1 -1
- package/dist/public/assets/index-rDVdz60K.js.br +0 -0
- package/dist/public/assets/{times-CCIAbLYL.js → times-Cue9NmYo.js} +1 -1
- package/dist/public/index.html +1 -1
- package/package.json +1 -1
- package/dist/public/assets/Detail-BInCTDTx.js +0 -1
- package/dist/public/assets/Detail-BInCTDTx.js.br +0 -0
- package/dist/public/assets/baseForm-B7tArmif.js.br +0 -0
- package/dist/public/assets/index-BVi9swz_.js.br +0 -0
- package/dist/public/assets/index-BswgGVlz.js.br +0 -0
- package/dist/public/assets/index-Cj-lTEG1.js.br +0 -0
- package/dist/public/assets/index-DQqzytdw.js.br +0 -0
- package/dist/public/assets/index-DkXWo3Jg.js.br +0 -0
- package/dist/public/assets/index-tXDZpXMk.js.br +0 -0
- /package/dist/public/assets/{index-OIQapQiA.js → index-4r0PC3Bk.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -6772,6 +6772,44 @@ function isAxiosError(e) {
|
|
|
6772
6772
|
return !!e?.isAxiosError;
|
|
6773
6773
|
}
|
|
6774
6774
|
|
|
6775
|
+
const CREATE_DIRECT_FEED_CARD_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/fyf_card/create_direct_feed_card';
|
|
6776
|
+
const DIRECT_FEED_CARD_HEADERS$2 = {
|
|
6777
|
+
'Content-Type': 'application/json',
|
|
6778
|
+
'x-use-ppe': '1',
|
|
6779
|
+
'x-tt-env': 'ppe_feed_play',
|
|
6780
|
+
};
|
|
6781
|
+
async function createDirectFeedCard({ appId, clientKey, directFeedCard, }) {
|
|
6782
|
+
const payload = {
|
|
6783
|
+
app_id: appId,
|
|
6784
|
+
client_key: clientKey,
|
|
6785
|
+
direct_feed_card: directFeedCard,
|
|
6786
|
+
};
|
|
6787
|
+
return request({
|
|
6788
|
+
url: CREATE_DIRECT_FEED_CARD_URL,
|
|
6789
|
+
method: 'POST',
|
|
6790
|
+
headers: DIRECT_FEED_CARD_HEADERS$2,
|
|
6791
|
+
data: payload,
|
|
6792
|
+
});
|
|
6793
|
+
}
|
|
6794
|
+
|
|
6795
|
+
const GET_DIRECT_FEED_SCENARIOS_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/fyf_card/get_direct_feed_scenario';
|
|
6796
|
+
const DIRECT_FEED_CARD_HEADERS$1 = {
|
|
6797
|
+
'Content-Type': 'application/json',
|
|
6798
|
+
'x-use-ppe': '1',
|
|
6799
|
+
'x-tt-env': 'ppe_feed_play',
|
|
6800
|
+
};
|
|
6801
|
+
async function fetchDirectFeedScenarios({ appId, clientKey, }) {
|
|
6802
|
+
return request({
|
|
6803
|
+
url: GET_DIRECT_FEED_SCENARIOS_URL,
|
|
6804
|
+
method: 'POST',
|
|
6805
|
+
headers: DIRECT_FEED_CARD_HEADERS$1,
|
|
6806
|
+
data: {
|
|
6807
|
+
app_id: appId,
|
|
6808
|
+
client_key: clientKey,
|
|
6809
|
+
},
|
|
6810
|
+
});
|
|
6811
|
+
}
|
|
6812
|
+
|
|
6775
6813
|
const GET_GAME_ASSET_PREVIEW_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/asset/preview_url';
|
|
6776
6814
|
async function fetchGameAssetPreviewUrl({ assetId, }) {
|
|
6777
6815
|
return request({
|
|
@@ -9192,49 +9230,130 @@ const gameDirectFeedCardAssetPreviewRoute = {
|
|
|
9192
9230
|
},
|
|
9193
9231
|
};
|
|
9194
9232
|
|
|
9195
|
-
function
|
|
9196
|
-
|
|
9197
|
-
|
|
9233
|
+
async function resolveAppIdentity$2(body) {
|
|
9234
|
+
const clientKey = body?.clientKey?.trim() ||
|
|
9235
|
+
body?.client_key?.trim() ||
|
|
9236
|
+
getClientKey().clientKey?.trim();
|
|
9237
|
+
let appId = body?.appId?.trim() ||
|
|
9238
|
+
body?.app_id?.trim() ||
|
|
9239
|
+
store.getState().appId?.trim();
|
|
9240
|
+
if (!clientKey) {
|
|
9241
|
+
return {
|
|
9242
|
+
clientKey: '',
|
|
9243
|
+
appId,
|
|
9244
|
+
error: 'Missing client key. Please run `ttmg init` or pass `clientKey` from IDE.',
|
|
9245
|
+
};
|
|
9198
9246
|
}
|
|
9199
|
-
if (
|
|
9200
|
-
|
|
9247
|
+
if (!appId) {
|
|
9248
|
+
const gameInfoResponse = await fetchGameInfo(clientKey);
|
|
9249
|
+
if (gameInfoResponse.error) {
|
|
9250
|
+
return {
|
|
9251
|
+
clientKey,
|
|
9252
|
+
appId: '',
|
|
9253
|
+
error: gameInfoResponse.error,
|
|
9254
|
+
};
|
|
9255
|
+
}
|
|
9256
|
+
appId = gameInfoResponse.data?.app_id?.trim() || '';
|
|
9257
|
+
if (appId) {
|
|
9258
|
+
store.setState({ appId });
|
|
9259
|
+
}
|
|
9201
9260
|
}
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
'reject',
|
|
9209
|
-
'rejected',
|
|
9210
|
-
'fail',
|
|
9211
|
-
'failed',
|
|
9212
|
-
'disable',
|
|
9213
|
-
'disabled',
|
|
9214
|
-
'offline',
|
|
9215
|
-
'draft',
|
|
9216
|
-
'delete',
|
|
9217
|
-
'deleted',
|
|
9218
|
-
].some(keyword => normalized.includes(keyword));
|
|
9219
|
-
}
|
|
9220
|
-
function isUsableDirectFeedCard(card) {
|
|
9221
|
-
if (!card?.content_id) {
|
|
9222
|
-
return false;
|
|
9261
|
+
if (!appId) {
|
|
9262
|
+
return {
|
|
9263
|
+
clientKey,
|
|
9264
|
+
appId: '',
|
|
9265
|
+
error: 'Missing app id. Please open project detail first or pass `appId` from IDE.',
|
|
9266
|
+
};
|
|
9223
9267
|
}
|
|
9224
|
-
|
|
9225
|
-
|
|
9268
|
+
return {
|
|
9269
|
+
clientKey,
|
|
9270
|
+
appId,
|
|
9271
|
+
error: null,
|
|
9272
|
+
};
|
|
9273
|
+
}
|
|
9274
|
+
function normalizeDirectFeedCard(body) {
|
|
9275
|
+
const camelCard = body?.directFeedCard;
|
|
9276
|
+
const snakeCard = body?.direct_feed_card;
|
|
9277
|
+
const normalized = {
|
|
9278
|
+
card_name: camelCard?.cardName?.trim() || snakeCard?.card_name?.trim() || '',
|
|
9279
|
+
card_desc: camelCard?.cardDesc?.trim() || snakeCard?.card_desc?.trim() || '',
|
|
9280
|
+
card_type: Number(camelCard?.cardType ?? snakeCard?.card_type ?? 0),
|
|
9281
|
+
scenario: camelCard?.scenario?.trim() || snakeCard?.scenario?.trim() || '',
|
|
9282
|
+
sub_pkg: camelCard?.subPkg?.trim() || snakeCard?.sub_pkg?.trim() || '__GAME__',
|
|
9283
|
+
params: camelCard?.params?.trim() || snakeCard?.params?.trim() || '',
|
|
9284
|
+
};
|
|
9285
|
+
if (!normalized.card_name || !normalized.card_desc || !normalized.card_type || !normalized.scenario) {
|
|
9286
|
+
return {
|
|
9287
|
+
card: normalized,
|
|
9288
|
+
error: 'Missing required direct-play card fields.',
|
|
9289
|
+
};
|
|
9226
9290
|
}
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9291
|
+
return {
|
|
9292
|
+
card: normalized,
|
|
9293
|
+
error: null,
|
|
9294
|
+
};
|
|
9295
|
+
}
|
|
9296
|
+
const gameDirectFeedCardCreateRoute = {
|
|
9297
|
+
method: 'post',
|
|
9298
|
+
path: '/game/direct-feed-card/create',
|
|
9299
|
+
handler: async (req, res) => {
|
|
9300
|
+
const identity = await resolveAppIdentity$2(req.body);
|
|
9301
|
+
if (identity.error) {
|
|
9302
|
+
res.send({
|
|
9303
|
+
code: errorCode,
|
|
9304
|
+
error: identity.error,
|
|
9305
|
+
data: null,
|
|
9306
|
+
});
|
|
9307
|
+
return;
|
|
9230
9308
|
}
|
|
9231
|
-
|
|
9232
|
-
|
|
9309
|
+
const directFeedCard = normalizeDirectFeedCard(req.body);
|
|
9310
|
+
if (directFeedCard.error) {
|
|
9311
|
+
res.send({
|
|
9312
|
+
code: errorCode,
|
|
9313
|
+
error: directFeedCard.error,
|
|
9314
|
+
data: null,
|
|
9315
|
+
});
|
|
9316
|
+
return;
|
|
9317
|
+
}
|
|
9318
|
+
const response = await createDirectFeedCard({
|
|
9319
|
+
appId: identity.appId,
|
|
9320
|
+
clientKey: identity.clientKey,
|
|
9321
|
+
directFeedCard: directFeedCard.card,
|
|
9322
|
+
});
|
|
9323
|
+
if (response.error) {
|
|
9324
|
+
res.send({
|
|
9325
|
+
code: errorCode,
|
|
9326
|
+
error: response.error,
|
|
9327
|
+
ctx: response.ctx,
|
|
9328
|
+
});
|
|
9329
|
+
return;
|
|
9330
|
+
}
|
|
9331
|
+
res.send({
|
|
9332
|
+
code: successCode,
|
|
9333
|
+
data: {
|
|
9334
|
+
...(typeof response.data === 'object' && response.data ? response.data : {}),
|
|
9335
|
+
direct_feed_card: {
|
|
9336
|
+
...(typeof response.data === 'object' &&
|
|
9337
|
+
response.data &&
|
|
9338
|
+
typeof response.data.direct_feed_card === 'object'
|
|
9339
|
+
? (response.data.direct_feed_card ||
|
|
9340
|
+
{})
|
|
9341
|
+
: {}),
|
|
9342
|
+
...directFeedCard.card,
|
|
9343
|
+
},
|
|
9344
|
+
},
|
|
9345
|
+
ctx: response.ctx,
|
|
9346
|
+
});
|
|
9347
|
+
},
|
|
9348
|
+
};
|
|
9349
|
+
|
|
9350
|
+
function isUsableDirectFeedCard(card) {
|
|
9351
|
+
if (!card?.content_id) {
|
|
9233
9352
|
return false;
|
|
9234
9353
|
}
|
|
9235
9354
|
return true;
|
|
9236
9355
|
}
|
|
9237
|
-
async function resolveAppIdentity(body) {
|
|
9356
|
+
async function resolveAppIdentity$1(body) {
|
|
9238
9357
|
const clientKey = body?.clientKey?.trim() ||
|
|
9239
9358
|
body?.client_key?.trim() ||
|
|
9240
9359
|
getClientKey().clientKey?.trim();
|
|
@@ -9279,7 +9398,7 @@ const gameDirectFeedCardListRoute = {
|
|
|
9279
9398
|
method: 'post',
|
|
9280
9399
|
path: '/game/direct-feed-card/list',
|
|
9281
9400
|
handler: async (req, res) => {
|
|
9282
|
-
const identity = await resolveAppIdentity(req.body);
|
|
9401
|
+
const identity = await resolveAppIdentity$1(req.body);
|
|
9283
9402
|
if (identity.error) {
|
|
9284
9403
|
res.send({
|
|
9285
9404
|
code: errorCode,
|
|
@@ -9319,6 +9438,156 @@ const gameDirectFeedCardListRoute = {
|
|
|
9319
9438
|
},
|
|
9320
9439
|
};
|
|
9321
9440
|
|
|
9441
|
+
function getStringCandidate(value) {
|
|
9442
|
+
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
9443
|
+
}
|
|
9444
|
+
function normalizeScenarioOption(item) {
|
|
9445
|
+
const value = getStringCandidate(item.value) ||
|
|
9446
|
+
getStringCandidate(item.key) ||
|
|
9447
|
+
getStringCandidate(item.scenario) ||
|
|
9448
|
+
getStringCandidate(item.scenario_key) ||
|
|
9449
|
+
getStringCandidate(item.scene) ||
|
|
9450
|
+
getStringCandidate(item.id) ||
|
|
9451
|
+
getStringCandidate(item.code);
|
|
9452
|
+
if (!value) {
|
|
9453
|
+
return null;
|
|
9454
|
+
}
|
|
9455
|
+
const label = getStringCandidate(item.label) ||
|
|
9456
|
+
getStringCandidate(item.name) ||
|
|
9457
|
+
getStringCandidate(item.title) ||
|
|
9458
|
+
getStringCandidate(item.desc) ||
|
|
9459
|
+
getStringCandidate(item.description) ||
|
|
9460
|
+
getStringCandidate(item.display_name) ||
|
|
9461
|
+
getStringCandidate(item.displayName) ||
|
|
9462
|
+
getStringCandidate(item.scenario_name) ||
|
|
9463
|
+
value;
|
|
9464
|
+
const cardTypeCandidate = item.card_type ?? item.cardType;
|
|
9465
|
+
const cardType = typeof cardTypeCandidate === 'number'
|
|
9466
|
+
? cardTypeCandidate
|
|
9467
|
+
: typeof cardTypeCandidate === 'string' && cardTypeCandidate.trim()
|
|
9468
|
+
? Number(cardTypeCandidate)
|
|
9469
|
+
: undefined;
|
|
9470
|
+
return {
|
|
9471
|
+
label,
|
|
9472
|
+
value,
|
|
9473
|
+
cardType: Number.isFinite(cardType) ? cardType : undefined,
|
|
9474
|
+
};
|
|
9475
|
+
}
|
|
9476
|
+
function extractScenarioOptions(data) {
|
|
9477
|
+
const dataRecord = data && typeof data === 'object' ? data : null;
|
|
9478
|
+
const candidateLists = [
|
|
9479
|
+
data,
|
|
9480
|
+
dataRecord?.data,
|
|
9481
|
+
dataRecord?.scenarios,
|
|
9482
|
+
dataRecord?.scenario_list,
|
|
9483
|
+
dataRecord?.scenario_infos,
|
|
9484
|
+
dataRecord?.scenario_info_list,
|
|
9485
|
+
dataRecord?.list,
|
|
9486
|
+
];
|
|
9487
|
+
for (const candidate of candidateLists) {
|
|
9488
|
+
if (!Array.isArray(candidate)) {
|
|
9489
|
+
continue;
|
|
9490
|
+
}
|
|
9491
|
+
const normalized = candidate
|
|
9492
|
+
.map(item => item && typeof item === 'object'
|
|
9493
|
+
? normalizeScenarioOption(item)
|
|
9494
|
+
: null)
|
|
9495
|
+
.filter((item) => Boolean(item));
|
|
9496
|
+
if (normalized.length > 0) {
|
|
9497
|
+
const deduped = new Map();
|
|
9498
|
+
normalized.forEach(item => {
|
|
9499
|
+
deduped.set(item.value, item);
|
|
9500
|
+
});
|
|
9501
|
+
return Array.from(deduped.values());
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
return [];
|
|
9505
|
+
}
|
|
9506
|
+
async function resolveAppIdentity(body) {
|
|
9507
|
+
const clientKey = body?.clientKey?.trim() ||
|
|
9508
|
+
body?.client_key?.trim() ||
|
|
9509
|
+
getClientKey().clientKey?.trim();
|
|
9510
|
+
let appId = body?.appId?.trim() ||
|
|
9511
|
+
body?.app_id?.trim() ||
|
|
9512
|
+
store.getState().appId?.trim();
|
|
9513
|
+
if (!clientKey) {
|
|
9514
|
+
return {
|
|
9515
|
+
clientKey: '',
|
|
9516
|
+
appId,
|
|
9517
|
+
error: 'Missing client key. Please run `ttmg init` or pass `clientKey` from IDE.',
|
|
9518
|
+
};
|
|
9519
|
+
}
|
|
9520
|
+
if (!appId) {
|
|
9521
|
+
const gameInfoResponse = await fetchGameInfo(clientKey);
|
|
9522
|
+
if (gameInfoResponse.error) {
|
|
9523
|
+
return {
|
|
9524
|
+
clientKey,
|
|
9525
|
+
appId: '',
|
|
9526
|
+
error: gameInfoResponse.error,
|
|
9527
|
+
};
|
|
9528
|
+
}
|
|
9529
|
+
appId = gameInfoResponse.data?.app_id?.trim() || '';
|
|
9530
|
+
if (appId) {
|
|
9531
|
+
store.setState({ appId });
|
|
9532
|
+
}
|
|
9533
|
+
}
|
|
9534
|
+
if (!appId) {
|
|
9535
|
+
return {
|
|
9536
|
+
clientKey,
|
|
9537
|
+
appId: '',
|
|
9538
|
+
error: 'Missing app id. Please open project detail first or pass `appId` from IDE.',
|
|
9539
|
+
};
|
|
9540
|
+
}
|
|
9541
|
+
return {
|
|
9542
|
+
clientKey,
|
|
9543
|
+
appId,
|
|
9544
|
+
error: null,
|
|
9545
|
+
};
|
|
9546
|
+
}
|
|
9547
|
+
const gameDirectFeedCardScenariosRoute = {
|
|
9548
|
+
method: 'post',
|
|
9549
|
+
path: '/game/direct-feed-card/scenarios',
|
|
9550
|
+
handler: async (req, res) => {
|
|
9551
|
+
const identity = await resolveAppIdentity(req.body);
|
|
9552
|
+
if (identity.error) {
|
|
9553
|
+
res.send({
|
|
9554
|
+
code: errorCode,
|
|
9555
|
+
error: identity.error,
|
|
9556
|
+
data: null,
|
|
9557
|
+
});
|
|
9558
|
+
return;
|
|
9559
|
+
}
|
|
9560
|
+
const response = await fetchDirectFeedScenarios({
|
|
9561
|
+
appId: identity.appId,
|
|
9562
|
+
clientKey: identity.clientKey,
|
|
9563
|
+
});
|
|
9564
|
+
if (response.error) {
|
|
9565
|
+
res.send({
|
|
9566
|
+
code: errorCode,
|
|
9567
|
+
error: response.error,
|
|
9568
|
+
ctx: response.ctx,
|
|
9569
|
+
});
|
|
9570
|
+
return;
|
|
9571
|
+
}
|
|
9572
|
+
const scenarios = extractScenarioOptions(response.data);
|
|
9573
|
+
const data = response.data && typeof response.data === 'object'
|
|
9574
|
+
? {
|
|
9575
|
+
...response.data,
|
|
9576
|
+
scenarios,
|
|
9577
|
+
total: scenarios.length,
|
|
9578
|
+
}
|
|
9579
|
+
: {
|
|
9580
|
+
scenarios,
|
|
9581
|
+
total: scenarios.length,
|
|
9582
|
+
};
|
|
9583
|
+
res.send({
|
|
9584
|
+
code: successCode,
|
|
9585
|
+
data,
|
|
9586
|
+
ctx: response.ctx,
|
|
9587
|
+
});
|
|
9588
|
+
},
|
|
9589
|
+
};
|
|
9590
|
+
|
|
9322
9591
|
const gameDetailRoute = {
|
|
9323
9592
|
method: 'get',
|
|
9324
9593
|
path: '/game/detail',
|
|
@@ -10705,7 +10974,9 @@ const routes = [
|
|
|
10705
10974
|
gameDetailRoute,
|
|
10706
10975
|
gameCheckRoute,
|
|
10707
10976
|
gameDirectFeedCardAssetPreviewRoute,
|
|
10977
|
+
gameDirectFeedCardCreateRoute,
|
|
10708
10978
|
gameDirectFeedCardListRoute,
|
|
10979
|
+
gameDirectFeedCardScenariosRoute,
|
|
10709
10980
|
gameUploadRoute,
|
|
10710
10981
|
gameWasmSplitConfigRoute,
|
|
10711
10982
|
gameWasmSplitOptionsRoute,
|
|
@@ -11164,7 +11435,7 @@ async function upload({ clientKey, note = '--', dir, }) {
|
|
|
11164
11435
|
}
|
|
11165
11436
|
}
|
|
11166
11437
|
|
|
11167
|
-
var version = "0.3.7-beta.
|
|
11438
|
+
var version = "0.3.7-beta.3";
|
|
11168
11439
|
var pkg = {
|
|
11169
11440
|
version: version};
|
|
11170
11441
|
|