@ttmg/cli 0.3.7-beta.2 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/index.js +690 -38
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +1 -1
  5. package/dist/public/assets/Detail-BzyVtzyL.js +1 -0
  6. package/dist/public/assets/Detail-BzyVtzyL.js.br +0 -0
  7. package/dist/public/assets/MonetizationMode-gxP1CQqy.js +1 -0
  8. package/dist/public/assets/MonetizationModeSummary-CD54_ROf.js +1 -0
  9. package/dist/public/assets/baseForm-CB6KCNqW.css +1 -0
  10. package/dist/public/assets/baseForm-CB6KCNqW.css.br +0 -0
  11. package/dist/public/assets/baseForm-d3x5z6BS.js +10 -0
  12. package/dist/public/assets/baseForm-d3x5z6BS.js.br +0 -0
  13. package/dist/public/assets/index-07cXGo3a.js +14 -0
  14. package/dist/public/assets/index-07cXGo3a.js.br +0 -0
  15. package/dist/public/assets/{index-BswgGVlz.js → index-766JxwXs.js} +1 -1
  16. package/dist/public/assets/index-766JxwXs.js.br +0 -0
  17. package/dist/public/assets/index-88dZ53Te.css +1 -0
  18. package/dist/public/assets/index-88dZ53Te.css.br +0 -0
  19. package/dist/public/assets/index-B7M-KACw.js +1 -0
  20. package/dist/public/assets/{index-Cj-lTEG1.js → index-BBHUSsVA.js} +1 -1
  21. package/dist/public/assets/index-BBHUSsVA.js.br +0 -0
  22. package/dist/public/assets/{index-Sk6u8HWP.js → index-BNtIdKnQ.js} +1 -1
  23. package/dist/public/assets/{index-tXDZpXMk.js → index-BZOItUfZ.js} +1 -1
  24. package/dist/public/assets/index-BZOItUfZ.js.br +0 -0
  25. package/dist/public/assets/{index-D35C4ac4.js → index-Ba-my-vz.js} +1 -1
  26. package/dist/public/assets/index-Bf85t01Q.css +1 -0
  27. package/dist/public/assets/index-Bf85t01Q.css.br +0 -0
  28. package/dist/public/assets/{index-B0CT2rYr.js → index-Bz8ZWlHc.js} +1 -1
  29. package/dist/public/assets/index-C06KDNuj.css +1 -0
  30. package/dist/public/assets/index-C0Izps-u.js +1 -0
  31. package/dist/public/assets/index-C4Lcagww.js +1 -0
  32. package/dist/public/assets/{index-B-rc2X1H.js → index-CLDvvBgM.js} +1 -1
  33. package/dist/public/assets/{index-DbiZkOAh.css → index-CLgcHgzd.css} +1 -1
  34. package/dist/public/assets/index-CQR5bkkv.js +1 -0
  35. package/dist/public/assets/{index-CDrq3KnY.js → index-CYD_pNmH.js} +1 -1
  36. package/dist/public/assets/{index-DdH9Yin-.js → index-Cr55HKuS.js} +1 -1
  37. package/dist/public/assets/{index-6LE--ADL.css → index-D2LsTDVa.css} +1 -1
  38. package/dist/public/assets/index-D2LsTDVa.css.br +0 -0
  39. package/dist/public/assets/{index-C4wGgEDm.css → index-DNsJSSmy.css} +1 -1
  40. package/dist/public/assets/index-E142v_RY.js +1 -0
  41. package/dist/public/assets/index-E142v_RY.js.br +0 -0
  42. package/dist/public/assets/index-tOg_vZEc.js +1 -0
  43. package/dist/public/assets/index-utYbqRWL.js +1 -0
  44. package/dist/public/assets/index-utYbqRWL.js.br +0 -0
  45. package/dist/public/assets/{times-CCIAbLYL.js → times-BvsrZcqF.js} +1 -1
  46. package/dist/public/index.html +2 -2
  47. package/dist/scripts/docs/capture.js +12 -4
  48. package/dist/scripts/docs/render.js +3 -2
  49. package/dist/scripts/docs/server.js +71 -9
  50. package/package.json +1 -1
  51. package/dist/public/assets/Detail-BInCTDTx.js +0 -1
  52. package/dist/public/assets/Detail-BInCTDTx.js.br +0 -0
  53. package/dist/public/assets/baseForm-B7tArmif.js +0 -10
  54. package/dist/public/assets/baseForm-B7tArmif.js.br +0 -0
  55. package/dist/public/assets/baseForm-DzWBZ1nI.css +0 -1
  56. package/dist/public/assets/baseForm-DzWBZ1nI.css.br +0 -0
  57. package/dist/public/assets/index-6LE--ADL.css.br +0 -0
  58. package/dist/public/assets/index-BACeBrQR.css +0 -1
  59. package/dist/public/assets/index-BOiN8aIS.js +0 -1
  60. package/dist/public/assets/index-BVi9swz_.js +0 -1
  61. package/dist/public/assets/index-BVi9swz_.js.br +0 -0
  62. package/dist/public/assets/index-BlXhGm9R.js +0 -1
  63. package/dist/public/assets/index-BswgGVlz.js.br +0 -0
  64. package/dist/public/assets/index-Cj-lTEG1.js.br +0 -0
  65. package/dist/public/assets/index-DQqzytdw.js +0 -1
  66. package/dist/public/assets/index-DQqzytdw.js.br +0 -0
  67. package/dist/public/assets/index-DkXWo3Jg.js +0 -14
  68. package/dist/public/assets/index-DkXWo3Jg.js.br +0 -0
  69. package/dist/public/assets/index-OIQapQiA.js +0 -1
  70. package/dist/public/assets/index-TYa4eXxF.css +0 -1
  71. package/dist/public/assets/index-aD1InxYk.js +0 -1
  72. package/dist/public/assets/index-jaMAKGHW.css +0 -1
  73. package/dist/public/assets/index-tXDZpXMk.js.br +0 -0
  74. /package/dist/public/assets/{Detail-BaQ9eM95.css → index-BaQ9eM95.css} +0 -0
package/dist/index.js CHANGED
@@ -6663,6 +6663,21 @@ async function request({ url, method, data, headers, params, }) {
6663
6663
  params: getRequestParams(params, data),
6664
6664
  });
6665
6665
  }
6666
+ // 打印请求信息
6667
+ console.log('\n========== API Request ==========');
6668
+ console.log('URL:', url);
6669
+ console.log('Method:', method);
6670
+ console.log('Headers:', JSON.stringify({
6671
+ Cookie: cookie,
6672
+ ...(headers || {}),
6673
+ }, null, 2));
6674
+ if (params) {
6675
+ console.log('Query Params:', JSON.stringify(params, null, 2));
6676
+ }
6677
+ if (data) {
6678
+ console.log('Request Body:', JSON.stringify(data, null, 2));
6679
+ }
6680
+ console.log('=================================\n');
6666
6681
  try {
6667
6682
  const res = await axios({
6668
6683
  url,
@@ -6772,6 +6787,44 @@ function isAxiosError(e) {
6772
6787
  return !!e?.isAxiosError;
6773
6788
  }
6774
6789
 
6790
+ const CREATE_DIRECT_FEED_CARD_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/fyf_card/create_direct_feed_card';
6791
+ const DIRECT_FEED_CARD_HEADERS$2 = {
6792
+ 'Content-Type': 'application/json',
6793
+ 'x-use-ppe': '1',
6794
+ 'x-tt-env': 'ppe_feed_play',
6795
+ };
6796
+ async function createDirectFeedCard({ appId, clientKey, directFeedCard, }) {
6797
+ const payload = {
6798
+ app_id: appId,
6799
+ client_key: clientKey,
6800
+ direct_feed_card: directFeedCard,
6801
+ };
6802
+ return request({
6803
+ url: CREATE_DIRECT_FEED_CARD_URL,
6804
+ method: 'POST',
6805
+ headers: DIRECT_FEED_CARD_HEADERS$2,
6806
+ data: payload,
6807
+ });
6808
+ }
6809
+
6810
+ const GET_DIRECT_FEED_SCENARIOS_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/fyf_card/get_direct_feed_scenario';
6811
+ const DIRECT_FEED_CARD_HEADERS$1 = {
6812
+ 'Content-Type': 'application/json',
6813
+ 'x-use-ppe': '1',
6814
+ 'x-tt-env': 'ppe_feed_play',
6815
+ };
6816
+ async function fetchDirectFeedScenarios({ appId, clientKey, }) {
6817
+ return request({
6818
+ url: GET_DIRECT_FEED_SCENARIOS_URL,
6819
+ method: 'POST',
6820
+ headers: DIRECT_FEED_CARD_HEADERS$1,
6821
+ data: {
6822
+ app_id: appId,
6823
+ client_key: clientKey,
6824
+ },
6825
+ });
6826
+ }
6827
+
6775
6828
  const GET_GAME_ASSET_PREVIEW_URL = 'https://developers.tiktok.com/tiktok/v4/devportal/mini_game/asset/preview_url';
6776
6829
  async function fetchGameAssetPreviewUrl({ assetId, }) {
6777
6830
  return request({
@@ -9157,6 +9210,373 @@ const gameCheckRoute = {
9157
9210
  },
9158
9211
  };
9159
9212
 
9213
+ const changelog = [
9214
+ {
9215
+ title: '0.3.7',
9216
+ target: {
9217
+ iOS: '>=43.1',
9218
+ Android: '>=43.1',
9219
+ },
9220
+ changes: {
9221
+ feature: [
9222
+ {
9223
+ desc: {
9224
+ 'zh-CN': '新增能力接入助手,帮助开发者基于小游戏变现类型获取关键能力的接入引导',
9225
+ 'en-US': 'Add Capability Integration Assistant to guide developers through key capability integration based on the game monetization model',
9226
+ },
9227
+ module: 'new',
9228
+ },
9229
+ ],
9230
+ optimize: [
9231
+ {
9232
+ desc: {
9233
+ 'zh-CN': '优化上传发布环节,将代码预检与代码上传整合为完整的上传发布流程',
9234
+ 'en-US': 'Optimize Upload & Publish by combining code precheck and code upload into a complete publishing flow',
9235
+ },
9236
+ module: 'upload',
9237
+ },
9238
+ {
9239
+ desc: {
9240
+ 'zh-CN': '扩充包体大小预检说明,补充整包、主包、独立分包限制规则与详细文档入口',
9241
+ 'en-US': 'Expand package size precheck guidance with project, main package, and independent package limits plus a detailed documentation entry',
9242
+ },
9243
+ module: 'check',
9244
+ },
9245
+ ],
9246
+ },
9247
+ },
9248
+ {
9249
+ title: '0.3.6',
9250
+ target: {
9251
+ iOS: '>=43.1',
9252
+ Android: '>=43.1',
9253
+ },
9254
+ changes: {
9255
+ bugfix: [
9256
+ {
9257
+ desc: {
9258
+ 'zh-CN': '优化请求超时时间,避免分包预处理超时导致分包无法进行',
9259
+ 'en-US': 'Optimize request timeout, avoid package preprocess timeout causing package not to be processed',
9260
+ },
9261
+ module: 'new',
9262
+ },
9263
+ ],
9264
+ },
9265
+ },
9266
+ {
9267
+ title: '0.3.5',
9268
+ target: {
9269
+ iOS: '>=43.1',
9270
+ Android: '>=43.1',
9271
+ },
9272
+ changes: {
9273
+ feature: [
9274
+ {
9275
+ desc: {
9276
+ 'zh-CN': '连接状态展示更多信息,帮助开发者了解调试环境状态',
9277
+ 'en-US': 'Show more information about the debugging environment to help developers understand the debugging environment status',
9278
+ },
9279
+ module: 'new',
9280
+ },
9281
+ {
9282
+ desc: {
9283
+ 'zh-CN': '支持手动配置客户端 IP、端口、WebSocket 端口,便于开发者调试',
9284
+ 'en-US': 'Support manually configuring client IP, port, WebSocket port, for developer debugging',
9285
+ },
9286
+ module: 'new',
9287
+ },
9288
+ ],
9289
+ },
9290
+ },
9291
+ {
9292
+ title: '0.3.4',
9293
+ target: {
9294
+ iOS: '>=43.1',
9295
+ Android: '>=43.1',
9296
+ },
9297
+ changes: {
9298
+ optimize: [
9299
+ {
9300
+ desc: {
9301
+ 'zh-CN': '顶部透出 wasm 分包建议提示信息,让开发者感知代码分包',
9302
+ 'en-US': 'Top area now displays wasm split suggestion information, making it easier for developers to understand code split',
9303
+ },
9304
+ module: 'check',
9305
+ },
9306
+ ],
9307
+ },
9308
+ },
9309
+ {
9310
+ title: '0.3.3',
9311
+ target: {
9312
+ iOS: '>=43.1',
9313
+ Android: '>=43.1',
9314
+ },
9315
+ changes: {
9316
+ bugfix: [
9317
+ {
9318
+ desc: {
9319
+ 'zh-CN': '修复安卓 unity 调试启动失败问题',
9320
+ 'en-US': 'Fix android unity debug start failed issue',
9321
+ },
9322
+ module: 'scanQrcode',
9323
+ },
9324
+ ],
9325
+ },
9326
+ },
9327
+ {
9328
+ title: '0.3.2',
9329
+ target: {
9330
+ iOS: '>=43.1',
9331
+ Android: '>=43.1',
9332
+ },
9333
+ changes: {
9334
+ feature: [
9335
+ {
9336
+ desc: {
9337
+ 'zh-CN': '支持通过 ttmg config set proxy 配置终端网络代理,便于调试时使用',
9338
+ 'en-US': 'Support configuring terminal network proxy via `ttmg config set proxy`,便于调试时使用',
9339
+ },
9340
+ module: 'new',
9341
+ link: 'https://bytedance.larkoffice.com/wiki/PeIawT4M4ia9R8kYyLMcjwHknOg',
9342
+ },
9343
+ {
9344
+ desc: {
9345
+ 'zh-CN': '支持通过 ttmg upload --client-key 上传游戏包到开发者平台',
9346
+ 'en-US': 'Support uploading game package to developer platform via `ttmg upload --client-key`',
9347
+ },
9348
+ module: 'new',
9349
+ link: 'https://bytedance.larkoffice.com/wiki/Y9Pkwm7nMiYiifk0iCbcDAGYnQh',
9350
+ },
9351
+ {
9352
+ desc: {
9353
+ 'zh-CN': '增加对 unity 是否需要分包的检查,对于需要分包的 unity 项目,给出明确提示',
9354
+ 'en-US': 'Add check for whether unity project needs subpackage, for unity projects that need subpackage, give clear prompt',
9355
+ },
9356
+ module: 'new',
9357
+ },
9358
+ {
9359
+ desc: {
9360
+ 'zh-CN': '调试与预检支持多语言展示,关键提示与校验信息更易理解',
9361
+ 'en-US': 'Debugging and precheck flows now support multilingual display, making key prompts and validation messages easier to understand',
9362
+ },
9363
+ module: 'new',
9364
+ },
9365
+ {
9366
+ desc: {
9367
+ 'zh-CN': '支持 Cocos 2.0 openDataContext 配置',
9368
+ 'en-US': 'Support Cocos 2.0 openDataContext configuration',
9369
+ },
9370
+ module: 'openDataContext',
9371
+ },
9372
+ {
9373
+ desc: {
9374
+ 'zh-CN': '变更记录新增提醒功能,当有新版本发布时,会通过弹窗提醒开发者更新',
9375
+ 'en-US': 'Change log now has a reminder function, when a new version is released, a popup will remind developers to update',
9376
+ },
9377
+ module: 'new',
9378
+ },
9379
+ ],
9380
+ optimize: [
9381
+ {
9382
+ desc: {
9383
+ 'zh-CN': 'ttmg login 支持 ttmg login --verbose 参数,打印更多登录信息',
9384
+ 'en-US': 'ttmg login supports ttmg login --verbose parameter, print more login information',
9385
+ },
9386
+ module: 'new',
9387
+ },
9388
+ {
9389
+ desc: {
9390
+ 'zh-CN': 'API 预检建议文案统一收敛,避免重复提示,阅读更清晰',
9391
+ 'en-US': 'API precheck suggestion messages are now unified to avoid duplicated hints and improve readability',
9392
+ },
9393
+ module: 'check',
9394
+ },
9395
+ {
9396
+ desc: {
9397
+ 'zh-CN': '顶部区域透出项目预检错误与警告信息,便于开发者及时发现问题并修复',
9398
+ 'en-US': 'Top area now displays project precheck error and warning information, making it easier for developers to find and fix problems',
9399
+ },
9400
+ module: 'check',
9401
+ },
9402
+ {
9403
+ desc: {
9404
+ 'zh-CN': '语言选择策略优化:优先使用 CLI 本地设置,未设置时自动回退浏览器语言',
9405
+ 'en-US': 'Language selection is optimized: CLI local setting is preferred, and browser language is used as fallback when unset',
9406
+ },
9407
+ module: 'check',
9408
+ },
9409
+ {
9410
+ desc: {
9411
+ 'zh-CN': '启动校验增强:检查是否在小游戏根目录执行,对于分包配置 subPackages 给出明确报错,引导开发者修改为 subpackages',
9412
+ 'en-US': 'Enhance entry validation: ensure running in project root and warn about subPackages typo; subpackages is required',
9413
+ },
9414
+ module: 'check',
9415
+ },
9416
+ {
9417
+ desc: {
9418
+ 'zh-CN': '启动界面增加如何解决调试连接不上的问题引导',
9419
+ 'en-US': 'Add guidance on how to solve the problem of debugging connection not working',
9420
+ },
9421
+ link: 'https://bytedance.larkoffice.com/wiki/WvifwWjGri7bTzkPbqKcqVi5ntc',
9422
+ module: 'new',
9423
+ },
9424
+ ],
9425
+ bugfix: [
9426
+ {
9427
+ desc: {
9428
+ 'zh-CN': '修复项目详情中展示的主包大小限制和代码预检不一致的情况',
9429
+ 'en-US': 'Fix the issue that the main package size limit and code precheck are inconsistent in the project details',
9430
+ },
9431
+ module: 'detail',
9432
+ },
9433
+ {
9434
+ desc: {
9435
+ 'zh-CN': '修复 CLI npm package size 过大问题',
9436
+ 'en-US': 'Fix the issue that the CLI npm package size is too large',
9437
+ },
9438
+ module: 'detail',
9439
+ },
9440
+ ],
9441
+ },
9442
+ },
9443
+ {
9444
+ title: '0.3.1',
9445
+ target: {
9446
+ iOS: '>=43.1',
9447
+ Android: '>=43.1',
9448
+ },
9449
+ changes: {
9450
+ feature: [
9451
+ {
9452
+ desc: {
9453
+ 'zh-CN': '支持 unity 小游戏本地一些列调试功能,如 Wasm 分包、包大小校验、一键上传代码包至平台等',
9454
+ 'en-US': 'Support unity debug features, such as Wasm split, package size check, one-click upload code package to platform, etc.',
9455
+ },
9456
+ link: 'https://bytedance.larkoffice.com/wiki/E5TAwQ1O1iylUXkoQFocfdL0ntG',
9457
+ module: 'new',
9458
+ },
9459
+ {
9460
+ desc: {
9461
+ 'zh-CN': '增加用户登录过期的异常提示,提醒开发者重新登录',
9462
+ 'en-US': 'Add login expired exception prompt, prompt developers to re-login.',
9463
+ },
9464
+ module: 'login',
9465
+ },
9466
+ ],
9467
+ optimize: [
9468
+ {
9469
+ desc: {
9470
+ 'zh-CN': '优化上传代码包至平台功能,开发者只用添加描述后点击上传便可自动压缩当前目录下的代码包上传至开发者平台',
9471
+ 'en-US': 'Optimize upload code package to platform function, developers only need to add a description and click upload to automatically compress the code package in the current directory to the developer platform.',
9472
+ },
9473
+ module: 'upload',
9474
+ },
9475
+ {
9476
+ desc: {
9477
+ 'zh-CN': '优化 ttmg login 终端网络代理异常导致无法登录的报错引导,提示用户检查网络设置',
9478
+ 'en-US': 'Optimize ttmg login terminal network proxy exception login prompt, prompt check network settings.',
9479
+ },
9480
+ module: 'login',
9481
+ },
9482
+ ],
9483
+ },
9484
+ },
9485
+ {
9486
+ title: '0.3.0',
9487
+ target: {
9488
+ iOS: '>=43.1',
9489
+ Android: '>=43.1',
9490
+ },
9491
+ changes: {
9492
+ feature: [
9493
+ {
9494
+ desc: {
9495
+ 'zh-CN': '支持了开发信息蒙层,打开后可以查看游戏 FPS、设备信息、调试开关等信息,便于查看游戏运行状态',
9496
+ 'en-US': 'Support devInfo panel, which can show game FPS, device info, debug switch, etc.',
9497
+ },
9498
+ module: 'devOptions',
9499
+ link: 'https://bytedance.larkoffice.com/wiki/PaK1wSu0eiPrxrkrqtrcR3VEnjf',
9500
+ },
9501
+ {
9502
+ desc: {
9503
+ 'zh-CN': '支持删除历史启动模式,便于管理历史启动模式',
9504
+ 'en-US': 'Support delete historical launch mode,keep consistent with client dev options',
9505
+ },
9506
+ module: 'devOptions',
9507
+ },
9508
+ {
9509
+ desc: {
9510
+ 'zh-CN': '调整调试设置模块名称为开发选项,和客户端内调开发者选项保持一致',
9511
+ 'en-US': 'Rename debug setting module to dev options, keep consistent with client dev options',
9512
+ },
9513
+ module: 'devOptions',
9514
+ link: 'https://bytedance.larkoffice.com/wiki/PaK1wSu0eiPrxrkrqtrcR3VEnjf',
9515
+ },
9516
+ {
9517
+ desc: {
9518
+ 'zh-CN': '调试设置新增定义 vConsole 和 开发信息浮层设置',
9519
+ 'en-US': 'Add debug setting to define vConsole and dev overlay',
9520
+ },
9521
+ module: 'devOptions',
9522
+ },
9523
+ {
9524
+ desc: {
9525
+ 'zh-CN': '支持了变更日志,用户可以在调试环境下查看游戏的变更记录,部分新功能可通过更多信息查看使用',
9526
+ 'en-US': 'Support change log, user can view game change log in IDE, some new features can be viewed in more info',
9527
+ },
9528
+ module: 'new',
9529
+ },
9530
+ ],
9531
+ optimize: [
9532
+ {
9533
+ desc: {
9534
+ 'zh-CN': '支持了调试设置开关本地缓存,避免每次都需要重新设置',
9535
+ 'en-US': 'Support debug setting cache, avoid setting debug mode every time',
9536
+ },
9537
+ module: 'devOptions',
9538
+ },
9539
+ ],
9540
+ bugfix: [
9541
+ {
9542
+ desc: {
9543
+ 'zh-CN': '修复上传名称为中文的游戏时,平台展示乱码的问题',
9544
+ 'en-US': 'Fix the issue that the platform shows garbled code when the game name is in Chinese',
9545
+ },
9546
+ module: 'upload',
9547
+ },
9548
+ {
9549
+ desc: {
9550
+ 'zh-CN': '修复启动模式模块,自定义query 参数无法持久化的问题',
9551
+ 'en-US': 'Fix the issue that custom query parameters cannot be persisted in launch mode module',
9552
+ },
9553
+ module: 'launchMode',
9554
+ },
9555
+ {
9556
+ desc: {
9557
+ 'zh-CN': '修复扫描二维码模块,内容过多,纵向无法滚动问题',
9558
+ 'en-US': 'Fix the issue that the content in scan QR code module is too long, and cannot be scrolled vertically',
9559
+ },
9560
+ module: 'scanQrcode',
9561
+ },
9562
+ ],
9563
+ },
9564
+ },
9565
+ ];
9566
+
9567
+ const gameChangelogRoute = {
9568
+ method: 'get',
9569
+ path: '/game/changelog',
9570
+ handler: async (_req, res) => {
9571
+ res.send({
9572
+ code: successCode,
9573
+ data: {
9574
+ items: changelog,
9575
+ },
9576
+ });
9577
+ },
9578
+ };
9579
+
9160
9580
  const gameDirectFeedCardAssetPreviewRoute = {
9161
9581
  method: 'post',
9162
9582
  path: '/game/direct-feed-card/asset-preview',
@@ -9192,51 +9612,130 @@ const gameDirectFeedCardAssetPreviewRoute = {
9192
9612
  },
9193
9613
  };
9194
9614
 
9195
- function hasBlockingCardStatus(value) {
9196
- if (value === null || value === undefined || value === '') {
9197
- return false;
9615
+ async function resolveAppIdentity$2(body) {
9616
+ const clientKey = body?.clientKey?.trim() ||
9617
+ body?.client_key?.trim() ||
9618
+ getClientKey().clientKey?.trim();
9619
+ let appId = body?.appId?.trim() ||
9620
+ body?.app_id?.trim() ||
9621
+ store.getState().appId?.trim();
9622
+ if (!clientKey) {
9623
+ return {
9624
+ clientKey: '',
9625
+ appId,
9626
+ error: 'Missing client key. Please run `ttmg init` or pass `clientKey` from IDE.',
9627
+ };
9628
+ }
9629
+ if (!appId) {
9630
+ const gameInfoResponse = await fetchGameInfo(clientKey);
9631
+ if (gameInfoResponse.error) {
9632
+ return {
9633
+ clientKey,
9634
+ appId: '',
9635
+ error: gameInfoResponse.error,
9636
+ };
9637
+ }
9638
+ appId = gameInfoResponse.data?.app_id?.trim() || '';
9639
+ if (appId) {
9640
+ store.setState({ appId });
9641
+ }
9198
9642
  }
9199
- if (typeof value === 'number') {
9200
- return value <= 0;
9643
+ if (!appId) {
9644
+ return {
9645
+ clientKey,
9646
+ appId: '',
9647
+ error: 'Missing app id. Please open project detail first or pass `appId` from IDE.',
9648
+ };
9201
9649
  }
9202
- const normalized = String(value).toLowerCase();
9203
- return [
9204
- 'pending',
9205
- 'review',
9206
- 'reviewing',
9207
- 'processing',
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));
9650
+ return {
9651
+ clientKey,
9652
+ appId,
9653
+ error: null,
9654
+ };
9219
9655
  }
9220
- function isUsableDirectFeedCard(card) {
9221
- if (!card?.content_id) {
9222
- return false;
9223
- }
9224
- if (hasBlockingCardStatus(card.status)) {
9225
- return false;
9656
+ function normalizeDirectFeedCard(body) {
9657
+ const camelCard = body?.directFeedCard;
9658
+ const snakeCard = body?.direct_feed_card;
9659
+ const normalized = {
9660
+ card_name: camelCard?.cardName?.trim() || snakeCard?.card_name?.trim() || '',
9661
+ card_desc: camelCard?.cardDesc?.trim() || snakeCard?.card_desc?.trim() || '',
9662
+ card_type: Number(camelCard?.cardType ?? snakeCard?.card_type ?? 0),
9663
+ scenario: camelCard?.scenario?.trim() || snakeCard?.scenario?.trim() || '',
9664
+ sub_pkg: camelCard?.subPkg?.trim() || snakeCard?.sub_pkg?.trim() || '__GAME__',
9665
+ params: camelCard?.params?.trim() || snakeCard?.params?.trim() || '',
9666
+ };
9667
+ if (!normalized.card_name || !normalized.card_desc || !normalized.card_type || !normalized.scenario) {
9668
+ return {
9669
+ card: normalized,
9670
+ error: 'Missing required direct-play card fields.',
9671
+ };
9226
9672
  }
9227
- // Dev Portal returns numeric audit statuses; `1` is already usable in practice,
9228
- // so only block clearly invalid numeric values and known textual blocking states.
9229
- if (typeof card.audit_status === 'number') {
9230
- if (card.audit_status <= 0) {
9231
- return false;
9673
+ return {
9674
+ card: normalized,
9675
+ error: null,
9676
+ };
9677
+ }
9678
+ const gameDirectFeedCardCreateRoute = {
9679
+ method: 'post',
9680
+ path: '/game/direct-feed-card/create',
9681
+ handler: async (req, res) => {
9682
+ const identity = await resolveAppIdentity$2(req.body);
9683
+ if (identity.error) {
9684
+ res.send({
9685
+ code: errorCode,
9686
+ error: identity.error,
9687
+ data: null,
9688
+ });
9689
+ return;
9232
9690
  }
9233
- }
9234
- else if (hasBlockingCardStatus(card.audit_status)) {
9691
+ const directFeedCard = normalizeDirectFeedCard(req.body);
9692
+ if (directFeedCard.error) {
9693
+ res.send({
9694
+ code: errorCode,
9695
+ error: directFeedCard.error,
9696
+ data: null,
9697
+ });
9698
+ return;
9699
+ }
9700
+ const response = await createDirectFeedCard({
9701
+ appId: identity.appId,
9702
+ clientKey: identity.clientKey,
9703
+ directFeedCard: directFeedCard.card,
9704
+ });
9705
+ if (response.error) {
9706
+ res.send({
9707
+ code: errorCode,
9708
+ error: response.error,
9709
+ ctx: response.ctx,
9710
+ });
9711
+ return;
9712
+ }
9713
+ res.send({
9714
+ code: successCode,
9715
+ data: {
9716
+ ...(typeof response.data === 'object' && response.data ? response.data : {}),
9717
+ direct_feed_card: {
9718
+ ...(typeof response.data === 'object' &&
9719
+ response.data &&
9720
+ typeof response.data.direct_feed_card === 'object'
9721
+ ? (response.data.direct_feed_card ||
9722
+ {})
9723
+ : {}),
9724
+ ...directFeedCard.card,
9725
+ },
9726
+ },
9727
+ ctx: response.ctx,
9728
+ });
9729
+ },
9730
+ };
9731
+
9732
+ function isUsableDirectFeedCard(card) {
9733
+ if (!card?.content_id) {
9235
9734
  return false;
9236
9735
  }
9237
9736
  return true;
9238
9737
  }
9239
- async function resolveAppIdentity(body) {
9738
+ async function resolveAppIdentity$1(body) {
9240
9739
  const clientKey = body?.clientKey?.trim() ||
9241
9740
  body?.client_key?.trim() ||
9242
9741
  getClientKey().clientKey?.trim();
@@ -9281,7 +9780,7 @@ const gameDirectFeedCardListRoute = {
9281
9780
  method: 'post',
9282
9781
  path: '/game/direct-feed-card/list',
9283
9782
  handler: async (req, res) => {
9284
- const identity = await resolveAppIdentity(req.body);
9783
+ const identity = await resolveAppIdentity$1(req.body);
9285
9784
  if (identity.error) {
9286
9785
  res.send({
9287
9786
  code: errorCode,
@@ -9321,6 +9820,156 @@ const gameDirectFeedCardListRoute = {
9321
9820
  },
9322
9821
  };
9323
9822
 
9823
+ function getStringCandidate(value) {
9824
+ return typeof value === 'string' && value.trim() ? value.trim() : '';
9825
+ }
9826
+ function normalizeScenarioOption(item) {
9827
+ const value = getStringCandidate(item.value) ||
9828
+ getStringCandidate(item.key) ||
9829
+ getStringCandidate(item.scenario) ||
9830
+ getStringCandidate(item.scenario_key) ||
9831
+ getStringCandidate(item.scene) ||
9832
+ getStringCandidate(item.id) ||
9833
+ getStringCandidate(item.code);
9834
+ if (!value) {
9835
+ return null;
9836
+ }
9837
+ const label = getStringCandidate(item.label) ||
9838
+ getStringCandidate(item.name) ||
9839
+ getStringCandidate(item.title) ||
9840
+ getStringCandidate(item.desc) ||
9841
+ getStringCandidate(item.description) ||
9842
+ getStringCandidate(item.display_name) ||
9843
+ getStringCandidate(item.displayName) ||
9844
+ getStringCandidate(item.scenario_name) ||
9845
+ value;
9846
+ const cardTypeCandidate = item.card_type ?? item.cardType;
9847
+ const cardType = typeof cardTypeCandidate === 'number'
9848
+ ? cardTypeCandidate
9849
+ : typeof cardTypeCandidate === 'string' && cardTypeCandidate.trim()
9850
+ ? Number(cardTypeCandidate)
9851
+ : undefined;
9852
+ return {
9853
+ label,
9854
+ value,
9855
+ cardType: Number.isFinite(cardType) ? cardType : undefined,
9856
+ };
9857
+ }
9858
+ function extractScenarioOptions(data) {
9859
+ const dataRecord = data && typeof data === 'object' ? data : null;
9860
+ const candidateLists = [
9861
+ data,
9862
+ dataRecord?.data,
9863
+ dataRecord?.scenarios,
9864
+ dataRecord?.scenario_list,
9865
+ dataRecord?.scenario_infos,
9866
+ dataRecord?.scenario_info_list,
9867
+ dataRecord?.list,
9868
+ ];
9869
+ for (const candidate of candidateLists) {
9870
+ if (!Array.isArray(candidate)) {
9871
+ continue;
9872
+ }
9873
+ const normalized = candidate
9874
+ .map(item => item && typeof item === 'object'
9875
+ ? normalizeScenarioOption(item)
9876
+ : null)
9877
+ .filter((item) => Boolean(item));
9878
+ if (normalized.length > 0) {
9879
+ const deduped = new Map();
9880
+ normalized.forEach(item => {
9881
+ deduped.set(item.value, item);
9882
+ });
9883
+ return Array.from(deduped.values());
9884
+ }
9885
+ }
9886
+ return [];
9887
+ }
9888
+ async function resolveAppIdentity(body) {
9889
+ const clientKey = body?.clientKey?.trim() ||
9890
+ body?.client_key?.trim() ||
9891
+ getClientKey().clientKey?.trim();
9892
+ let appId = body?.appId?.trim() ||
9893
+ body?.app_id?.trim() ||
9894
+ store.getState().appId?.trim();
9895
+ if (!clientKey) {
9896
+ return {
9897
+ clientKey: '',
9898
+ appId,
9899
+ error: 'Missing client key. Please run `ttmg init` or pass `clientKey` from IDE.',
9900
+ };
9901
+ }
9902
+ if (!appId) {
9903
+ const gameInfoResponse = await fetchGameInfo(clientKey);
9904
+ if (gameInfoResponse.error) {
9905
+ return {
9906
+ clientKey,
9907
+ appId: '',
9908
+ error: gameInfoResponse.error,
9909
+ };
9910
+ }
9911
+ appId = gameInfoResponse.data?.app_id?.trim() || '';
9912
+ if (appId) {
9913
+ store.setState({ appId });
9914
+ }
9915
+ }
9916
+ if (!appId) {
9917
+ return {
9918
+ clientKey,
9919
+ appId: '',
9920
+ error: 'Missing app id. Please open project detail first or pass `appId` from IDE.',
9921
+ };
9922
+ }
9923
+ return {
9924
+ clientKey,
9925
+ appId,
9926
+ error: null,
9927
+ };
9928
+ }
9929
+ const gameDirectFeedCardScenariosRoute = {
9930
+ method: 'post',
9931
+ path: '/game/direct-feed-card/scenarios',
9932
+ handler: async (req, res) => {
9933
+ const identity = await resolveAppIdentity(req.body);
9934
+ if (identity.error) {
9935
+ res.send({
9936
+ code: errorCode,
9937
+ error: identity.error,
9938
+ data: null,
9939
+ });
9940
+ return;
9941
+ }
9942
+ const response = await fetchDirectFeedScenarios({
9943
+ appId: identity.appId,
9944
+ clientKey: identity.clientKey,
9945
+ });
9946
+ if (response.error) {
9947
+ res.send({
9948
+ code: errorCode,
9949
+ error: response.error,
9950
+ ctx: response.ctx,
9951
+ });
9952
+ return;
9953
+ }
9954
+ const scenarios = extractScenarioOptions(response.data);
9955
+ const data = response.data && typeof response.data === 'object'
9956
+ ? {
9957
+ ...response.data,
9958
+ scenarios,
9959
+ total: scenarios.length,
9960
+ }
9961
+ : {
9962
+ scenarios,
9963
+ total: scenarios.length,
9964
+ };
9965
+ res.send({
9966
+ code: successCode,
9967
+ data,
9968
+ ctx: response.ctx,
9969
+ });
9970
+ },
9971
+ };
9972
+
9324
9973
  const gameDetailRoute = {
9325
9974
  method: 'get',
9326
9975
  path: '/game/detail',
@@ -10706,8 +11355,11 @@ const routes = [
10706
11355
  gameConfigFillbackRoute,
10707
11356
  gameDetailRoute,
10708
11357
  gameCheckRoute,
11358
+ gameChangelogRoute,
10709
11359
  gameDirectFeedCardAssetPreviewRoute,
11360
+ gameDirectFeedCardCreateRoute,
10710
11361
  gameDirectFeedCardListRoute,
11362
+ gameDirectFeedCardScenariosRoute,
10711
11363
  gameUploadRoute,
10712
11364
  gameWasmSplitConfigRoute,
10713
11365
  gameWasmSplitOptionsRoute,
@@ -11166,7 +11818,7 @@ async function upload({ clientKey, note = '--', dir, }) {
11166
11818
  }
11167
11819
  }
11168
11820
 
11169
- var version = "0.3.7-beta.2";
11821
+ var version = "0.3.7";
11170
11822
  var pkg = {
11171
11823
  version: version};
11172
11824