@heybox/hb-sdk 0.9.6-alpha.9 → 0.9.6

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 (50) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +8 -1
  3. package/THIRD_PARTY_NOTICES.md +472 -48
  4. package/dist/cli-chunks/{artifact-BPntCpxe.cjs → artifact-D63EGQx9.cjs} +6 -5
  5. package/dist/cli-chunks/{build-C-u_43nO.cjs → build-fyHfi216.cjs} +6 -5
  6. package/dist/cli-chunks/{create-HUynjFAz.cjs → create-B-EnCHjU.cjs} +322 -4
  7. package/dist/cli-chunks/{dev-Dpg4MIoV.cjs → dev-Zb0pMdzr.cjs} +309 -39
  8. package/dist/cli-chunks/{dev-context-BBInsRLS.cjs → dev-context-DYFBVQ_C.cjs} +22 -14
  9. package/dist/cli-chunks/{doctor-qjPdtMIj.cjs → doctor-DmkHu1Hk.cjs} +1 -1
  10. package/dist/cli-chunks/{games-B7ckiLkr.cjs → games-CeCLFeTt.cjs} +1 -1
  11. package/dist/cli-chunks/{index-SB2iukXP.cjs → index-C696i2DY.cjs} +1 -1
  12. package/dist/cli-chunks/{index-D0fPJhtR.cjs → index-It90_ScC.cjs} +210 -38
  13. package/dist/cli-chunks/index.esm-CvMA_ppV.cjs +7977 -0
  14. package/dist/cli-chunks/{index.esm-jOc0zgE7.cjs → index.esm-YDTVatz_.cjs} +7 -6
  15. package/dist/cli-chunks/{login-DDKJA4pj.cjs → login-BGJz7JZV.cjs} +1 -1
  16. package/dist/cli-chunks/{project-vite-B_yd6m3R.cjs → project-vite-DybH-3Qp.cjs} +1 -1
  17. package/dist/cli-chunks/{remote-CSmfJpqd.cjs → remote-D9-2nonN.cjs} +13 -8
  18. package/dist/cli-chunks/{runtime-permission-env-Bbc5KS3u.cjs → runtime-permission-env-BrSofQNz.cjs} +52 -6990
  19. package/dist/cli-chunks/{skill-BTKQpM8e.cjs → skill-D6ebJn5J.cjs} +2 -2
  20. package/dist/cli-chunks/{version-Blqp4J3r.cjs → version-CtGTgNGb.cjs} +1 -1
  21. package/dist/cli.cjs +1 -1
  22. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DsmreI9p.js +228 -0
  23. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-CLikLiNS.js +6 -0
  24. package/dist/devtools/browser-dev-host/assets/index-1VVyBeMq.js +567 -0
  25. package/dist/devtools/browser-dev-host/assets/index-ophYZqpX.css +1 -0
  26. package/dist/devtools/browser-dev-host/assets/linux-DwJAcUeD.svg +1 -0
  27. package/dist/devtools/browser-dev-host/index.html +6 -4
  28. package/dist/index.cjs.js +1201 -156
  29. package/dist/index.esm.js +1201 -156
  30. package/dist/miniapp-publish.cjs.js +1072 -131
  31. package/dist/miniapp-publish.esm.js +1072 -131
  32. package/dist/protocol.cjs.js +732 -158
  33. package/dist/protocol.esm.js +716 -159
  34. package/dist/templates/vanilla-vite-js/README.md.ejs +27 -0
  35. package/dist/templates/vanilla-vite-js/package.json.ejs +1 -1
  36. package/dist/templates/vanilla-vite-js/src/user-game-data.js.ejs +1 -0
  37. package/dist/vite.cjs.js +1087 -150
  38. package/dist/vite.esm.js +1087 -150
  39. package/docs/appreciation-code.md +4 -8
  40. package/package.json +8 -9
  41. package/skill/SKILL.md +4 -0
  42. package/skill/skill.json +5 -5
  43. package/types/index.d.ts +492 -77
  44. package/types/miniapp-publish/index.d.ts +18 -2
  45. package/types/protocol.d.ts +1 -1
  46. package/types/vite/index.d.ts +10 -16
  47. package/dist/devtools/browser-dev-host/assets/browser-dev-host-sU7AkNvZ.js +0 -100
  48. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-CRHmhFwH.js +0 -6
  49. package/dist/devtools/browser-dev-host/assets/index-CHYEXFEg.css +0 -1
  50. package/dist/devtools/browser-dev-host/assets/index-yw_35zwq.js +0 -586
package/dist/index.esm.js CHANGED
@@ -408,6 +408,16 @@ const COMPANION_SESSION_OUTPUT_EVENT = 'companion.session.output';
408
408
  const COMPANION_SESSION_EXIT_EVENT = 'companion.session.exit';
409
409
  const COMPANION_SESSION_OWNERSHIP_LOST_EVENT = 'companion.session.ownershipLost';
410
410
 
411
+ /** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
412
+ const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
413
+ const USER_DATA_QUERY_METHOD = 'user.data.query';
414
+ const USER_DATA_SYNC_METHOD = 'user.data.sync';
415
+ const USER_DATA_FILE_METHOD = 'user.data.file';
416
+ const USER_DATA_PERMISSION_REQUEST_METHOD = 'user.dataPermission.request';
417
+ const USER_DATA_PERMISSION_GET_METHOD = 'user.dataPermission.get';
418
+ const USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD = 'user.dataPermission.openSettings';
419
+ const USER_DATA_PERMISSION_REVOKE_SESSION_METHOD = 'user.dataPermission.revokeSession';
420
+
411
421
  const WORKSPACE_CARDS_REQUEST_REFRESH_METHOD = 'workspaceCards.requestRefresh';
412
422
  const AUTH_GET_ACCOUNT_STATE_METHOD = 'auth.getAccountState';
413
423
  const AUTH_LOGIN_METHOD = 'auth.login';
@@ -424,6 +434,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
424
434
  const SHARE_COPY_LINK_METHOD = 'share.copyLink';
425
435
  const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
426
436
  const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
437
+ /** DOM 长图内部传输方法;业务仍调用 screenshotElement。
438
+ * @internal
439
+ */
440
+ const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
427
441
  const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
428
442
  const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
429
443
  const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
@@ -551,7 +565,7 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
551
565
  * @since 0.3.1
552
566
  */
553
567
  function isMiniProgramBridgeMessage(value) {
554
- if (!isRecord$3(value))
568
+ if (!isRecord$5(value))
555
569
  return false;
556
570
  if (value.namespace !== MINI_PROGRAM_MESSAGE_NAMESPACE || (value.version !== 1 && value.version !== 2) || !isNonEmptyString$1(value.nonce)) {
557
571
  return false;
@@ -703,7 +717,7 @@ function isMiniProgramRelativePath(value) {
703
717
  * @since 0.8.0
704
718
  */
705
719
  function isMiniProgramPathRootRef(value) {
706
- if (!isRecord$3(value))
720
+ if (!isRecord$5(value))
707
721
  return false;
708
722
  if (value.kind === 'sandbox')
709
723
  return hasOnlyKeys(value, ['kind']);
@@ -770,7 +784,7 @@ function isMiniProgramPathRootRef(value) {
770
784
  * @since 0.8.0
771
785
  */
772
786
  function isMiniProgramFileRef(value) {
773
- if (!isRecord$3(value) || value.kind !== 'file')
787
+ if (!isRecord$5(value) || value.kind !== 'file')
774
788
  return false;
775
789
  if (isNonEmptyString$1(value.handleId)) {
776
790
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -838,7 +852,7 @@ function isMiniProgramFileRef(value) {
838
852
  * @since 0.8.0
839
853
  */
840
854
  function isMiniProgramDirectoryRef(value) {
841
- if (!isRecord$3(value) || value.kind !== 'directory')
855
+ if (!isRecord$5(value) || value.kind !== 'directory')
842
856
  return false;
843
857
  if (isNonEmptyString$1(value.handleId)) {
844
858
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -915,7 +929,7 @@ function isMiniProgramDirectoryRef(value) {
915
929
  * @since 0.8.0
916
930
  */
917
931
  function isMiniProgramFileDescriptor(value) {
918
- return (isRecord$3(value) &&
932
+ return (isRecord$5(value) &&
919
933
  value.kind === 'file' &&
920
934
  isNonEmptyString$1(value.name) &&
921
935
  isFileMode(value.mode) &&
@@ -968,20 +982,20 @@ const MEDIA_PICK_ITEM_KEYS = ['type', 'mimeType', 'size', 'width', 'height', 'pr
968
982
  * @since 0.9.3
969
983
  */
970
984
  function isMiniProgramMediaPickItem(value) {
971
- if (!isRecord$3(value) || (value.type !== 'image' && value.type !== 'video'))
985
+ if (!isRecord$5(value) || (value.type !== 'image' && value.type !== 'video'))
972
986
  return false;
973
987
  const isVideo = value.type === 'video';
974
988
  if (!hasOnlyKeys(value, isVideo ? [...MEDIA_PICK_ITEM_KEYS, 'durationMs'] : MEDIA_PICK_ITEM_KEYS))
975
989
  return false;
976
990
  if (!isNonEmptyString$1(value.mimeType) ||
977
- !isNonNegativeSafeInteger(value.size) ||
991
+ !isNonNegativeSafeInteger$1(value.size) ||
978
992
  !isPositiveSafeInteger$1(value.width) ||
979
993
  !isPositiveSafeInteger$1(value.height) ||
980
994
  !isNonEmptyString$1(value.previewUrl) ||
981
995
  !isDirectFileDescriptor(value.file)) {
982
996
  return false;
983
997
  }
984
- return isVideo ? isNonNegativeSafeInteger(value.durationMs) : true;
998
+ return isVideo ? isNonNegativeSafeInteger$1(value.durationMs) : true;
985
999
  }
986
1000
  /**
987
1001
  * 判断未知值是否为整批 `media.pick` 结果。
@@ -1139,9 +1153,9 @@ function isMiniProgramByteArray(value) {
1139
1153
  * @since 0.8.0
1140
1154
  */
1141
1155
  function isMiniProgramFileStat(value) {
1142
- return (isRecord$3(value) &&
1156
+ return (isRecord$5(value) &&
1143
1157
  value.kind === 'file' &&
1144
- isNonNegativeSafeInteger(value.size) &&
1158
+ isNonNegativeSafeInteger$1(value.size) &&
1145
1159
  (value.modifiedAt === undefined || isNonNegativeFiniteNumber(value.modifiedAt)) &&
1146
1160
  (value.createdAt === undefined || isNonNegativeFiniteNumber(value.createdAt)) &&
1147
1161
  hasOnlyKeys(value, ['kind', 'size', 'modifiedAt', 'createdAt']));
@@ -1200,28 +1214,28 @@ function isMiniProgramFileStat(value) {
1200
1214
  * @since 0.8.0
1201
1215
  */
1202
1216
  function isMiniProgramDownloadProgressPayload(value) {
1203
- if (!isRecord$3(value) ||
1204
- !isNonNegativeSafeInteger(value.loaded) ||
1217
+ if (!isRecord$5(value) ||
1218
+ !isNonNegativeSafeInteger$1(value.loaded) ||
1205
1219
  typeof value.lengthComputable !== 'boolean' ||
1206
1220
  !hasOnlyKeys(value, ['loaded', 'total', 'lengthComputable'])) {
1207
1221
  return false;
1208
1222
  }
1209
1223
  if (!value.lengthComputable)
1210
1224
  return value.total === undefined;
1211
- return isNonNegativeSafeInteger(value.total) && value.loaded <= value.total;
1225
+ return isNonNegativeSafeInteger$1(value.total) && value.loaded <= value.total;
1212
1226
  }
1213
1227
  function isMiniProgramCompanionPrepareProgress(value) {
1214
- if (!isRecord$3(value))
1228
+ if (!isRecord$5(value))
1215
1229
  return false;
1216
1230
  if (value.phase === 'downloading') {
1217
- return (isNonNegativeSafeInteger(value.loaded) &&
1218
- (value.total === undefined || (isNonNegativeSafeInteger(value.total) && value.loaded <= value.total)) &&
1231
+ return (isNonNegativeSafeInteger$1(value.loaded) &&
1232
+ (value.total === undefined || (isNonNegativeSafeInteger$1(value.total) && value.loaded <= value.total)) &&
1219
1233
  hasOnlyKeys(value, ['phase', 'loaded', 'total']));
1220
1234
  }
1221
1235
  if (value.phase !== 'verifying' && value.phase !== 'extracting')
1222
1236
  return false;
1223
- return (isNonNegativeSafeInteger(value.processed) &&
1224
- isNonNegativeSafeInteger(value.total) &&
1237
+ return (isNonNegativeSafeInteger$1(value.processed) &&
1238
+ isNonNegativeSafeInteger$1(value.total) &&
1225
1239
  value.processed <= value.total &&
1226
1240
  hasOnlyKeys(value, ['phase', 'processed', 'total']));
1227
1241
  }
@@ -1229,15 +1243,15 @@ function isMiniProgramOperationProgressPayload(value) {
1229
1243
  return isMiniProgramDownloadProgressPayload(value) || isMiniProgramCompanionPrepareProgress(value);
1230
1244
  }
1231
1245
  function isSDKHandshakePayload(value) {
1232
- return isRecord$3(value) && isNonEmptyString$1(value.href) && typeof value.userAgent === 'string' && isNonEmptyString$1(value.sdkVersion);
1246
+ return isRecord$5(value) && isNonEmptyString$1(value.href) && typeof value.userAgent === 'string' && isNonEmptyString$1(value.sdkVersion);
1233
1247
  }
1234
1248
  function isBridgeError(value) {
1235
- return isRecord$3(value) && isNonEmptyString$1(value.code) && typeof value.message === 'string';
1249
+ return isRecord$5(value) && isNonEmptyString$1(value.code) && typeof value.message === 'string';
1236
1250
  }
1237
1251
  function isFileMode(value) {
1238
1252
  return value === 'read' || value === 'readwrite';
1239
1253
  }
1240
- function isNonNegativeSafeInteger(value) {
1254
+ function isNonNegativeSafeInteger$1(value) {
1241
1255
  return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
1242
1256
  }
1243
1257
  function isPositiveSafeInteger$1(value) {
@@ -1253,10 +1267,217 @@ function hasOnlyKeys(value, allowedKeys) {
1253
1267
  const allowed = new Set(allowedKeys);
1254
1268
  return Object.keys(value).every((key) => allowed.has(key));
1255
1269
  }
1256
- function isRecord$3(value) {
1270
+ function isRecord$5(value) {
1257
1271
  return typeof value === 'object' && value !== null && !Array.isArray(value);
1258
1272
  }
1259
1273
 
1274
+ /**
1275
+ * 首发游戏与资源目录(冻结范围)。
1276
+ *
1277
+ * @remarks
1278
+ * 本版只开放 4 个游戏、8 项资源,资源 key 精确匹配,**不接受通配符、前缀或未登记的 key**。
1279
+ * 目录是 Manifest 声明、Host 门禁、SDK 具名方法与概览的唯一事实源:新增资源必须在代码中显式
1280
+ * 登记并重新生成机器可读目录,不会因为上游新增解析分支而自动扩大已有声明或许可。
1281
+ *
1282
+ * `disclosureRevision` 描述披露字段与用途的版本。本版所有资源都从 `1` 开始;只要字段或用途实质
1283
+ * 变化就必须递增,并让旧的持久许可指纹失配后重新确认。
1284
+ *
1285
+ * @since 0.9.6
1286
+ * @hbPlatform android
1287
+ * @hbPlatform ios
1288
+ * @hbPlatform ohos
1289
+ * @hbPlatform windows
1290
+ * @hbPlatform macos
1291
+ * @hbClient android none
1292
+ * @hbClient ios none
1293
+ * @hbClient ohos none
1294
+ * @hbClient windows none
1295
+ * @hbClient macos none
1296
+ */
1297
+ /**
1298
+ * 首发公开 GameId(冻结顺序)。
1299
+ *
1300
+ * @since 0.9.6
1301
+ */
1302
+ const USER_GAME_DATA_GAMES = {
1303
+ ark: '明日方舟',
1304
+ black_myth_wukong: '黑神话悟空',
1305
+ task_bar_hero: '任务栏英雄',
1306
+ phantom_blade_zero: '影之刃零',
1307
+ };
1308
+ const USER_GAME_DATA_GAME_IDS = Object.keys(USER_GAME_DATA_GAMES);
1309
+ /**
1310
+ * 首发 8 项资源的公开目录。
1311
+ *
1312
+ * @remarks
1313
+ * - `ark` 与 `ark_lottery` 映射到同一游戏的 profile / gacha 两项资源,**来源资格不合并**。
1314
+ * - 明日方舟不提供 `saves`;三款存档不提供 profile / gacha 方法。
1315
+ * - 存档资源的 Steam AppID 与 `gamesaves.Client.Parsed` 的分支冻结一致:2358720、
1316
+ * 3678970、4115450。原始文件支持不等于已支持结构化解析,两个资源分别声明与许可。
1317
+ *
1318
+ * @since 0.9.6
1319
+ * @hbPlatform android
1320
+ * @hbPlatform ios
1321
+ * @hbPlatform ohos
1322
+ * @hbPlatform windows
1323
+ * @hbPlatform macos
1324
+ * @hbClient android none
1325
+ * @hbClient ios none
1326
+ * @hbClient ohos none
1327
+ * @hbClient windows none
1328
+ * @hbClient macos none
1329
+ */
1330
+ const GAME_DATA_RESOURCE_CATALOG = [
1331
+ {
1332
+ key: 'game.ark.profile',
1333
+ game: 'ark',
1334
+ family: 'profile',
1335
+ name: '明日方舟角色与养成资料',
1336
+ disclosureRevision: 1,
1337
+ queries: { get: { schema: 'ark.profile', version: 1 } },
1338
+ sync: false,
1339
+ file: false,
1340
+ },
1341
+ {
1342
+ key: 'game.ark.gacha',
1343
+ game: 'ark',
1344
+ family: 'gacha',
1345
+ name: '明日方舟抽卡记录与分析',
1346
+ disclosureRevision: 1,
1347
+ queries: {
1348
+ get: { schema: 'ark.gacha-analysis', version: 1 },
1349
+ list: { schema: 'ark.gacha-record-page', version: 1, page: { defaultSize: 50, maxSize: 100 } },
1350
+ },
1351
+ sync: false,
1352
+ file: false,
1353
+ },
1354
+ {
1355
+ key: 'game.black_myth_wukong.save_analysis',
1356
+ game: 'black_myth_wukong',
1357
+ family: 'save_analysis',
1358
+ name: '黑神话悟空存档解析结果',
1359
+ disclosureRevision: 1,
1360
+ queries: { get: { schema: 'black_myth_wukong.save', version: 1 } },
1361
+ sync: true,
1362
+ file: false,
1363
+ },
1364
+ {
1365
+ key: 'game.black_myth_wukong.save_files',
1366
+ game: 'black_myth_wukong',
1367
+ family: 'save_files',
1368
+ name: '黑神话悟空云存档文件',
1369
+ disclosureRevision: 1,
1370
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1371
+ sync: true,
1372
+ file: true,
1373
+ },
1374
+ {
1375
+ key: 'game.task_bar_hero.save_analysis',
1376
+ game: 'task_bar_hero',
1377
+ family: 'save_analysis',
1378
+ name: '任务栏英雄存档解析结果',
1379
+ disclosureRevision: 1,
1380
+ queries: { get: { schema: 'task_bar_hero.save', version: 1 } },
1381
+ sync: true,
1382
+ file: false,
1383
+ },
1384
+ {
1385
+ key: 'game.task_bar_hero.save_files',
1386
+ game: 'task_bar_hero',
1387
+ family: 'save_files',
1388
+ name: '任务栏英雄云存档文件',
1389
+ disclosureRevision: 1,
1390
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1391
+ sync: true,
1392
+ file: true,
1393
+ },
1394
+ {
1395
+ key: 'game.phantom_blade_zero.save_analysis',
1396
+ game: 'phantom_blade_zero',
1397
+ family: 'save_analysis',
1398
+ name: '影之刃零存档解析结果',
1399
+ disclosureRevision: 1,
1400
+ queries: { get: { schema: 'phantom_blade_zero.save', version: 1 } },
1401
+ sync: true,
1402
+ file: false,
1403
+ },
1404
+ {
1405
+ key: 'game.phantom_blade_zero.save_files',
1406
+ game: 'phantom_blade_zero',
1407
+ family: 'save_files',
1408
+ name: '影之刃零云存档文件',
1409
+ disclosureRevision: 1,
1410
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1411
+ sync: true,
1412
+ file: true,
1413
+ },
1414
+ ];
1415
+ const USER_GAME_DATA_RESOURCE_KEYS = GAME_DATA_RESOURCE_CATALOG.map((resource) => resource.key);
1416
+ const RESOURCE_KEY_SET = new Set(USER_GAME_DATA_RESOURCE_KEYS);
1417
+ const GAME_ID_SET = new Set(USER_GAME_DATA_GAME_IDS);
1418
+ /**
1419
+ * 判断字符串是否为已发布的精确资源 key。
1420
+ *
1421
+ * @param key - 候选字符串;来自 `unknown` 边界时调用方必须先完成字符串检查。
1422
+ * @returns 与 {@link USER_GAME_DATA_RESOURCE_KEYS} 中某项精确相等时返回 `true` 并收窄类型。
1423
+ *
1424
+ * @remarks
1425
+ * 匹配大小写敏感且不做 trim 之外的归一化:`'*'`、`'game.ark'`、`'game.ark.gacha.*'` 等
1426
+ * 通配符或前缀一律返回 `false`。返回 `true` 只表示该 key 已登记在公开目录,不代表当前小程序
1427
+ * 已声明、平台已批准或用户已许可;这些门禁必须分别校验。
1428
+ *
1429
+ * @example
1430
+ * ```ts
1431
+ * isUserGameDataResourceKey('game.ark.profile'); // true
1432
+ * isUserGameDataResourceKey('game.ark'); // false:前缀不是资源
1433
+ * isUserGameDataResourceKey('game.ark.*'); // false:禁止通配符
1434
+ * ```
1435
+ *
1436
+ * @since 0.9.6
1437
+ * @hbPlatform android
1438
+ * @hbPlatform ios
1439
+ * @hbPlatform ohos
1440
+ * @hbPlatform windows
1441
+ * @hbPlatform macos
1442
+ * @hbClient android none
1443
+ * @hbClient ios none
1444
+ * @hbClient ohos none
1445
+ * @hbClient windows none
1446
+ * @hbClient macos none
1447
+ */
1448
+ function isUserGameDataResourceKey(key) {
1449
+ return RESOURCE_KEY_SET.has(key);
1450
+ }
1451
+ /**
1452
+ * 判断字符串是否为已发布的公开 GameId。
1453
+ *
1454
+ * @since 0.9.6
1455
+ */
1456
+ function isUserGameDataGameId(gameId) {
1457
+ return GAME_ID_SET.has(gameId);
1458
+ }
1459
+ /** 从同一目录派生内部操作,不维护第二套游戏白名单。 */
1460
+ function getUserDataResourceContract(key) {
1461
+ const resource = GAME_DATA_RESOURCE_CATALOG.find((entry) => entry.key === key);
1462
+ if (!resource)
1463
+ return undefined;
1464
+ const queries = resource.queries;
1465
+ const operations = Object.keys(queries);
1466
+ if (resource.sync)
1467
+ operations.push('sync');
1468
+ if (resource.file)
1469
+ operations.push('file');
1470
+ return {
1471
+ key: resource.key,
1472
+ game: resource.game,
1473
+ name: resource.name,
1474
+ family: resource.family,
1475
+ disclosureRevision: resource.disclosureRevision,
1476
+ queries,
1477
+ operations,
1478
+ };
1479
+ }
1480
+
1260
1481
  const MINI_PROGRAM_PERMISSION_KEYS = [
1261
1482
  'userInfo',
1262
1483
  'steamLibrary',
@@ -1272,6 +1493,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
1272
1493
  'companion',
1273
1494
  'appProtocol',
1274
1495
  'workspaceCards',
1496
+ 'user_game_data',
1275
1497
  ];
1276
1498
  new Set(MINI_PROGRAM_PERMISSION_KEYS);
1277
1499
 
@@ -1894,6 +2116,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
1894
2116
  }
1895
2117
  return result.value;
1896
2118
  };
2119
+ const parse$1 = /* @__PURE__*/ _parse($ZodRealError);
1897
2120
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1898
2121
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
1899
2122
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -1906,6 +2129,7 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1906
2129
  }
1907
2130
  return result.value;
1908
2131
  };
2132
+ const parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
1909
2133
  const _safeParse = (_Err) => (schema, value, _ctx) => {
1910
2134
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
1911
2135
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -2032,14 +2256,14 @@ function datetime$1(args) {
2032
2256
  const timeRegex = `${time}(?:${opts.join("|")})`;
2033
2257
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
2034
2258
  }
2035
- const string$1 = (params) => {
2259
+ const string$2 = (params) => {
2036
2260
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
2037
2261
  return new RegExp(`^${regex}$`);
2038
2262
  };
2039
2263
  const integer = /^-?\d+$/;
2040
- const number$1 = /^-?\d+(?:\.\d+)?$/;
2264
+ const number$2 = /^-?\d+(?:\.\d+)?$/;
2041
2265
  const boolean$1 = /^(?:true|false)$/i;
2042
- const _null$2 = /^null$/i;
2266
+ const _null$3 = /^null$/i;
2043
2267
  // regex for string with no uppercase letters
2044
2268
  const lowercase = /^[^A-Z]*$/;
2045
2269
  // regex for string with no lowercase letters
@@ -2625,7 +2849,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
2625
2849
  });
2626
2850
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
2627
2851
  $ZodType.init(inst, def);
2628
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$1(inst._zod.bag);
2852
+ inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$2(inst._zod.bag);
2629
2853
  inst._zod.parse = (payload, _) => {
2630
2854
  if (def.coerce)
2631
2855
  try {
@@ -2960,7 +3184,7 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
2960
3184
  });
2961
3185
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
2962
3186
  $ZodType.init(inst, def);
2963
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
3187
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
2964
3188
  inst._zod.parse = (payload, _ctx) => {
2965
3189
  if (def.coerce)
2966
3190
  try {
@@ -3015,7 +3239,7 @@ const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
3015
3239
  });
3016
3240
  const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
3017
3241
  $ZodType.init(inst, def);
3018
- inst._zod.pattern = _null$2;
3242
+ inst._zod.pattern = _null$3;
3019
3243
  inst._zod.values = new Set([null]);
3020
3244
  inst._zod.parse = (payload, _ctx) => {
3021
3245
  const input = payload.value;
@@ -3699,7 +3923,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
3699
3923
  }
3700
3924
  // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
3701
3925
  // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
3702
- const checkNumericKey = typeof key === "string" && number$1.test(key) && keyResult.issues.length;
3926
+ const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length;
3703
3927
  if (checkNumericKey) {
3704
3928
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
3705
3929
  if (retryResult instanceof Promise) {
@@ -4448,7 +4672,7 @@ function _boolean(Class, params) {
4448
4672
  });
4449
4673
  }
4450
4674
  // @__NO_SIDE_EFFECTS__
4451
- function _null$1(Class, params) {
4675
+ function _null$2(Class, params) {
4452
4676
  return new Class({
4453
4677
  type: "null",
4454
4678
  ...normalizeParams(params),
@@ -5699,7 +5923,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5699
5923
  return this.check(_overwrite(fn));
5700
5924
  },
5701
5925
  optional() {
5702
- return optional(this);
5926
+ return optional$1(this);
5703
5927
  },
5704
5928
  exactOptional() {
5705
5929
  return exactOptional(this);
@@ -5708,16 +5932,16 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5708
5932
  return nullable(this);
5709
5933
  },
5710
5934
  nullish() {
5711
- return optional(nullable(this));
5935
+ return optional$1(nullable(this));
5712
5936
  },
5713
5937
  nonoptional(params) {
5714
5938
  return nonoptional(this, params);
5715
5939
  },
5716
5940
  array() {
5717
- return array(this);
5941
+ return array$1(this);
5718
5942
  },
5719
5943
  or(arg) {
5720
- return union([this, arg]);
5944
+ return union$1([this, arg]);
5721
5945
  },
5722
5946
  and(arg) {
5723
5947
  return intersection(this, arg);
@@ -5863,7 +6087,7 @@ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
5863
6087
  inst.time = (params) => inst.check(time(params));
5864
6088
  inst.duration = (params) => inst.check(duration(params));
5865
6089
  });
5866
- function string(params) {
6090
+ function string$1(params) {
5867
6091
  return _string(ZodString, params);
5868
6092
  }
5869
6093
  const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
@@ -5992,10 +6216,10 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
5992
6216
  return this.check(_lte(value, params));
5993
6217
  },
5994
6218
  int(params) {
5995
- return this.check(int(params));
6219
+ return this.check(int$1(params));
5996
6220
  },
5997
6221
  safe(params) {
5998
- return this.check(int(params));
6222
+ return this.check(int$1(params));
5999
6223
  },
6000
6224
  positive(params) {
6001
6225
  return this.check(_gt(0, params));
@@ -6028,14 +6252,14 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
6028
6252
  inst.isFinite = true;
6029
6253
  inst.format = bag.format ?? null;
6030
6254
  });
6031
- function number(params) {
6255
+ function number$1(params) {
6032
6256
  return _number(ZodNumber, params);
6033
6257
  }
6034
6258
  const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
6035
6259
  $ZodNumberFormat.init(inst, def);
6036
6260
  ZodNumber.init(inst, def);
6037
6261
  });
6038
- function int(params) {
6262
+ function int$1(params) {
6039
6263
  return _int(ZodNumberFormat, params);
6040
6264
  }
6041
6265
  const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
@@ -6051,8 +6275,8 @@ const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
6051
6275
  ZodType.init(inst, def);
6052
6276
  inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json);
6053
6277
  });
6054
- function _null(params) {
6055
- return _null$1(ZodNull, params);
6278
+ function _null$1(params) {
6279
+ return _null$2(ZodNull, params);
6056
6280
  }
6057
6281
  const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
6058
6282
  $ZodUnknown.init(inst, def);
@@ -6067,7 +6291,7 @@ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
6067
6291
  ZodType.init(inst, def);
6068
6292
  inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
6069
6293
  });
6070
- function never(params) {
6294
+ function never$1(params) {
6071
6295
  return _never(ZodNever, params);
6072
6296
  }
6073
6297
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
@@ -6093,7 +6317,7 @@ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
6093
6317
  },
6094
6318
  });
6095
6319
  });
6096
- function array(element, params) {
6320
+ function array$1(element, params) {
6097
6321
  return _array(ZodArray, element, params);
6098
6322
  }
6099
6323
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
@@ -6117,7 +6341,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
6117
6341
  return this.clone({ ...this._zod.def, catchall: unknown() });
6118
6342
  },
6119
6343
  strict() {
6120
- return this.clone({ ...this._zod.def, catchall: never() });
6344
+ return this.clone({ ...this._zod.def, catchall: never$1() });
6121
6345
  },
6122
6346
  strip() {
6123
6347
  return this.clone({ ...this._zod.def, catchall: undefined });
@@ -6168,7 +6392,7 @@ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
6168
6392
  inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
6169
6393
  inst.options = def.options;
6170
6394
  });
6171
- function union(options, params) {
6395
+ function union$1(options, params) {
6172
6396
  return new ZodUnion({
6173
6397
  type: "union",
6174
6398
  options: options,
@@ -6212,7 +6436,7 @@ function record$1(keyType, valueType, params) {
6212
6436
  if (!valueType || !valueType._zod) {
6213
6437
  return new ZodRecord({
6214
6438
  type: "record",
6215
- keyType: string(),
6439
+ keyType: string$1(),
6216
6440
  valueType: keyType,
6217
6441
  ...normalizeParams(valueType),
6218
6442
  });
@@ -6286,7 +6510,7 @@ const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
6286
6510
  },
6287
6511
  });
6288
6512
  });
6289
- function literal(value, params) {
6513
+ function literal$1(value, params) {
6290
6514
  return new ZodLiteral({
6291
6515
  type: "literal",
6292
6516
  values: Array.isArray(value) ? value : [value],
@@ -6342,7 +6566,7 @@ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
6342
6566
  inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
6343
6567
  inst.unwrap = () => inst._zod.def.innerType;
6344
6568
  });
6345
- function optional(innerType) {
6569
+ function optional$1(innerType) {
6346
6570
  return new ZodOptional({
6347
6571
  type: "optional",
6348
6572
  innerType: innerType,
@@ -6483,7 +6707,7 @@ function superRefine(fn, params) {
6483
6707
  }
6484
6708
  function json(params) {
6485
6709
  const jsonSchema = lazy(() => {
6486
- return union([string(params), number(), boolean(), _null(), array(jsonSchema), record$1(string(), jsonSchema)]);
6710
+ return union$1([string$1(params), number$1(), boolean(), _null$1(), array$1(jsonSchema), record$1(string$1(), jsonSchema)]);
6487
6711
  });
6488
6712
  return jsonSchema;
6489
6713
  }
@@ -6556,7 +6780,7 @@ var viewElevationSchema = _enum(["flat", "raised"]);
6556
6780
  var viewWidthSchema = _enum(["auto", "fill"]);
6557
6781
  var viewBoxSizeSchema = _enum(["md", "hero"]);
6558
6782
  var viewHeightSchema = _enum(["data-tile"]);
6559
- var viewGridColumnsSchema = union([literal(2), literal(3), literal(4)]);
6783
+ var viewGridColumnsSchema = union$1([literal$1(2), literal$1(3), literal$1(4)]);
6560
6784
  var viewTextVariantSchema = _enum([
6561
6785
  "display",
6562
6786
  "title",
@@ -6601,7 +6825,7 @@ var viewImageSizeSchema = _enum([
6601
6825
  "landscape-compact",
6602
6826
  "landscape-content"
6603
6827
  ]);
6604
- var viewIconSizeSchema = union([literal(16), literal(20), literal(24)]);
6828
+ var viewIconSizeSchema = union$1([literal$1(16), literal$1(20), literal$1(24)]);
6605
6829
  var viewIconColorSchema = _enum([
6606
6830
  "default",
6607
6831
  "secondary",
@@ -6621,28 +6845,28 @@ var viewImageOverlaySchema = _enum([
6621
6845
  var viewListVariantSchema = _enum(["media", "plain", "compact"]);
6622
6846
  var viewCarouselPaginationSchema = _enum(["none", "bullets", "fraction"]);
6623
6847
  var viewCarouselPaginationPlacementSchema = _enum(["inside", "outside"]);
6624
- var viewCarouselSlidesPerViewSchema = union([literal(1), literal(2), literal(3)]);
6848
+ var viewCarouselSlidesPerViewSchema = union$1([literal$1(1), literal$1(2), literal$1(3)]);
6625
6849
  var viewTransitionEffectSchema = _enum(["crossfade", "morph"]);
6626
6850
  var viewTransitionSchema = object({
6627
6851
  /** 新旧内容仅交叉淡化,或同时执行轻量位移与缩放变换。 */
6628
6852
  effect: viewTransitionEffectSchema
6629
6853
  });
6630
- var nodeIdSchema = string().trim().min(1).max(120);
6854
+ var nodeIdSchema = string$1().trim().min(1).max(120);
6631
6855
  var viewActionSchema = object({
6632
6856
  /** 完整 Command id。 */
6633
- commandId: string().trim().min(1).max(120),
6857
+ commandId: string$1().trim().min(1).max(120),
6634
6858
  /** Command 的 JSON 输入。 */
6635
6859
  input: json().optional(),
6636
6860
  /** 提交时并入 `input` 的用户输入绑定;键是 input 字段名,值是 `textField` 节点 id。 */
6637
- inputFrom: record$1(string().trim().min(1).max(40), nodeIdSchema).refine((value) => Object.keys(value).length <= VIEW_BUDGET.maxActionInputBindings, {
6861
+ inputFrom: record$1(string$1().trim().min(1).max(40), nodeIdSchema).refine((value) => Object.keys(value).length <= VIEW_BUDGET.maxActionInputBindings, {
6638
6862
  error: "\u5355\u4E2A\u52A8\u4F5C\u7ED1\u5B9A\u7684\u8F93\u5165\u5B57\u6BB5\u8FC7\u591A"
6639
6863
  }).optional()
6640
6864
  });
6641
- var textValueSchema = string().max(VIEW_BUDGET.maxTextLength);
6642
- var shortTextSchema = string().trim().min(1).max(200);
6865
+ var textValueSchema = string$1().max(VIEW_BUDGET.maxTextLength);
6866
+ var shortTextSchema = string$1().trim().min(1).max(200);
6643
6867
  var viewMeterSegmentSchema = object({
6644
6868
  /** 该数据段占整个容量的比例,值域 (0,1]。 */
6645
- value: number().positive().max(1),
6869
+ value: number$1().positive().max(1),
6646
6870
  /** 数据段的可访问说明。 */
6647
6871
  label: shortTextSchema,
6648
6872
  /** 数据段语气;缺省使用宿主上下文强调色。 */
@@ -6650,37 +6874,37 @@ var viewMeterSegmentSchema = object({
6650
6874
  });
6651
6875
  var viewBarChartItemSchema = object({
6652
6876
  /** 分类标签,例如星期“一”。 */
6653
- label: string().trim().min(1).max(20),
6877
+ label: string$1().trim().min(1).max(20),
6654
6878
  /** 非负原始值;宿主只按同组最大值归一化,不改变数据口径。 */
6655
- value: number().finite().nonnegative(),
6879
+ value: number$1().finite().nonnegative(),
6656
6880
  /** 精确值文本,例如“2 小时 30 分”。 */
6657
- valueLabel: string().trim().min(1).max(80).optional()
6881
+ valueLabel: string$1().trim().min(1).max(80).optional()
6658
6882
  });
6659
6883
  var viewTextSpanSchema = object({
6660
6884
  /** 片段文本;全部片段拼接后必须与所属节点的 `value` 完全一致。 */
6661
- text: string().min(1).max(VIEW_BUDGET.maxTextLength),
6885
+ text: string$1().min(1).max(VIEW_BUDGET.maxTextLength),
6662
6886
  /** 叠加在该片段上的语义标记;缺省即为普通文本。 */
6663
- marks: array(viewTextMarkSchema).max(4).optional()
6887
+ marks: array$1(viewTextMarkSchema).max(4).optional()
6664
6888
  });
6665
6889
  var viewImageFallbackSchema = object({
6666
6890
  /** 缺图时复用宿主当前应用的缓存模糊背景;不请求远程资源,缺省沿用图标或文本回退。 */
6667
- source: literal("app-ambient").optional(),
6891
+ source: literal$1("app-ambient").optional(),
6668
6892
  /** 回退图标名;宿主无法识别时退回文本。 */
6669
- icon: string().trim().min(1).max(80).optional(),
6893
+ icon: string$1().trim().min(1).max(80).optional(),
6670
6894
  /** 回退文本。 */
6671
- text: string().trim().max(120).optional()
6895
+ text: string$1().trim().max(120).optional()
6672
6896
  });
6673
6897
  var viewFieldItemSchema = object({
6674
6898
  label: shortTextSchema,
6675
- value: string().max(400).optional(),
6676
- placeholder: string().trim().max(120).optional()
6899
+ value: string$1().max(400).optional(),
6900
+ placeholder: string$1().trim().max(120).optional()
6677
6901
  });
6678
6902
  var viewListItemActionSchema = object({
6679
6903
  text: shortTextSchema,
6680
6904
  variant: viewButtonVariantSchema.optional(),
6681
6905
  tone: viewToneSchema.optional(),
6682
6906
  disabled: boolean().optional(),
6683
- disabledReason: string().trim().max(200).optional(),
6907
+ disabledReason: string$1().trim().max(200).optional(),
6684
6908
  action: viewActionSchema.optional()
6685
6909
  });
6686
6910
  var viewListItemBadgeSchema = object({
@@ -6690,9 +6914,9 @@ var viewListItemBadgeSchema = object({
6690
6914
  var viewListItemSchema = object({
6691
6915
  id: nodeIdSchema,
6692
6916
  title: shortTextSchema,
6693
- subtitle: string().trim().max(400).optional(),
6694
- meta: string().trim().max(120).optional(),
6695
- image: string().trim().max(2e3).optional(),
6917
+ subtitle: string$1().trim().max(400).optional(),
6918
+ meta: string$1().trim().max(120).optional(),
6919
+ image: string$1().trim().max(2e3).optional(),
6696
6920
  imageFallback: viewImageFallbackSchema.optional(),
6697
6921
  /** 媒体位外形;缺省保持历史横向缩略图。 */
6698
6922
  imageShape: viewListItemImageShapeSchema.optional(),
@@ -6703,7 +6927,7 @@ var viewListItemSchema = object({
6703
6927
  /** 列表图片是否以颜色传达业务含义;不影响卡片主次下的原色显示。 */
6704
6928
  imageColorRole: viewImageColorRoleSchema.optional(),
6705
6929
  /** 行首图标名;宿主不认识该名称时不渲染图标位。 */
6706
- icon: string().trim().min(1).max(80).optional(),
6930
+ icon: string$1().trim().min(1).max(80).optional(),
6707
6931
  /** 条目整体语气;作用于标题与行首图标。 */
6708
6932
  tone: viewToneSchema.optional(),
6709
6933
  /** 行尾状态标记;与 `meta` 并存时标记在前。 */
@@ -6713,7 +6937,7 @@ var viewListItemSchema = object({
6713
6937
  /** 当前不可激活。 */
6714
6938
  disabled: boolean().optional(),
6715
6939
  /** 不可激活的可读原因。 */
6716
- disabledReason: string().trim().max(200).optional(),
6940
+ disabledReason: string$1().trim().max(200).optional(),
6717
6941
  action: viewActionSchema.optional(),
6718
6942
  /** 行尾次级动作;宿主把它渲染成与整行动作并列的独立按钮。 */
6719
6943
  secondaryAction: viewListItemActionSchema.optional()
@@ -6721,7 +6945,7 @@ var viewListItemSchema = object({
6721
6945
  var viewRegionNoticeSchema = object({
6722
6946
  /** 稳定键;用户关闭后按该键记住,换一条提示会重新出现。 */
6723
6947
  id: nodeIdSchema,
6724
- text: string().trim().min(1).max(200),
6948
+ text: string$1().trim().min(1).max(200),
6725
6949
  tone: viewToneSchema.optional(),
6726
6950
  /** 是否允许用户关闭;关闭状态属于宿主自持呈现状态。 */
6727
6951
  dismissible: boolean().optional()
@@ -6797,18 +7021,18 @@ var layoutShape = {
6797
7021
  var boxShape = {
6798
7022
  ...layoutShape,
6799
7023
  action: viewActionSchema.optional(),
6800
- accessibilityLabel: string().min(1).max(80).optional(),
7024
+ accessibilityLabel: string$1().min(1).max(80).optional(),
6801
7025
  interaction: _enum(["soft", "media", "text", "content"]).optional()
6802
7026
  };
6803
7027
  var meterNodeSchema = object({
6804
7028
  ...baseNodeShape,
6805
- type: literal("meter"),
7029
+ type: literal$1("meter"),
6806
7030
  /** 比例值,值域 [0,1];超出值域是插件缺陷,按 schema 错误稳定失败。 */
6807
- value: number().min(0).max(1),
7031
+ value: number$1().min(0).max(1),
6808
7032
  /** 可访问名称;缺省时由宿主以百分比文本兜底。 */
6809
7033
  label: shortTextSchema.optional(),
6810
7034
  tone: viewToneSchema.optional(),
6811
- segments: array(viewMeterSegmentSchema).min(1).max(8).optional(),
7035
+ segments: array$1(viewMeterSegmentSchema).min(1).max(8).optional(),
6812
7036
  size: viewMeterSizeSchema.optional(),
6813
7037
  ticks: boolean().optional()
6814
7038
  }).refine(
@@ -6822,31 +7046,31 @@ var knownNodeSchema = lazy(
6822
7046
  () => discriminatedUnion("type", [
6823
7047
  object({
6824
7048
  ...boxShape,
6825
- type: literal("vstack"),
6826
- children: array(viewNodeSchema)
7049
+ type: literal$1("vstack"),
7050
+ children: array$1(viewNodeSchema)
6827
7051
  }),
6828
7052
  object({
6829
7053
  ...boxShape,
6830
- type: literal("hstack"),
7054
+ type: literal$1("hstack"),
6831
7055
  wrap: boolean().optional(),
6832
- children: array(viewNodeSchema)
7056
+ children: array$1(viewNodeSchema)
6833
7057
  }),
6834
7058
  object({
6835
7059
  ...boxShape,
6836
- type: literal("zstack"),
6837
- children: array(viewNodeSchema)
7060
+ type: literal$1("zstack"),
7061
+ children: array$1(viewNodeSchema)
6838
7062
  }),
6839
7063
  object({
6840
7064
  ...boxShape,
6841
- type: literal("grid"),
7065
+ type: literal$1("grid"),
6842
7066
  columns: viewGridColumnsSchema,
6843
- children: array(viewNodeSchema)
7067
+ children: array$1(viewNodeSchema)
6844
7068
  }),
6845
7069
  object({
6846
7070
  id: nodeIdSchema,
6847
- type: literal("carousel"),
7071
+ type: literal$1("carousel"),
6848
7072
  label: shortTextSchema,
6849
- children: array(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
7073
+ children: array$1(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
6850
7074
  fallback: viewNodeSchema.optional(),
6851
7075
  slidesPerView: viewCarouselSlidesPerViewSchema.optional(),
6852
7076
  gap: viewGapSchema.optional(),
@@ -6855,36 +7079,36 @@ var knownNodeSchema = lazy(
6855
7079
  navigation: boolean().optional(),
6856
7080
  pagination: viewCarouselPaginationSchema.optional(),
6857
7081
  paginationPlacement: viewCarouselPaginationPlacementSchema.optional(),
6858
- autoplayDelay: number().int().min(2e3).max(3e4).optional()
7082
+ autoplayDelay: number$1().int().min(2e3).max(3e4).optional()
6859
7083
  }),
6860
7084
  object({
6861
7085
  ...layoutShape,
6862
- type: literal("group"),
7086
+ type: literal$1("group"),
6863
7087
  title: shortTextSchema.optional(),
6864
7088
  collapsible: boolean().optional(),
6865
7089
  defaultExpanded: boolean().optional(),
6866
7090
  stickyTitle: boolean().optional(),
6867
- children: array(viewNodeSchema)
7091
+ children: array$1(viewNodeSchema)
6868
7092
  }),
6869
- object({ ...baseNodeShape, type: literal("spacer") }),
7093
+ object({ ...baseNodeShape, type: literal$1("spacer") }),
6870
7094
  object({
6871
7095
  ...baseNodeShape,
6872
- type: literal("text"),
7096
+ type: literal$1("text"),
6873
7097
  value: textValueSchema,
6874
- spans: array(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
7098
+ spans: array$1(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
6875
7099
  variant: viewTextVariantSchema.optional(),
6876
7100
  weight: viewTextWeightSchema.optional(),
6877
7101
  tone: viewTextToneSchema.optional(),
6878
7102
  paint: viewTextPaintSchema.optional(),
6879
- maxLines: number().int().positive().max(50).optional(),
7103
+ maxLines: number$1().int().positive().max(50).optional(),
6880
7104
  reserveLines: boolean().optional()
6881
7105
  }),
6882
7106
  object({
6883
7107
  ...baseNodeShape,
6884
- type: literal("image"),
7108
+ type: literal$1("image"),
6885
7109
  /** 图片资源地址;无原图且声明 app-ambient 回退时,用 app-ambient://current 直接选择宿主缓存。 */
6886
- src: string().trim().min(1).max(2e3),
6887
- aspectRatio: string().trim().max(20).optional(),
7110
+ src: string$1().trim().min(1).max(2e3),
7111
+ aspectRatio: string$1().trim().max(20).optional(),
6888
7112
  size: viewImageSizeSchema.optional(),
6889
7113
  fit: viewImageFitSchema.optional(),
6890
7114
  appearance: viewImageAppearanceSchema.optional(),
@@ -6895,34 +7119,34 @@ var knownNodeSchema = lazy(
6895
7119
  }),
6896
7120
  object({
6897
7121
  ...baseNodeShape,
6898
- type: literal("icon"),
6899
- name: string().trim().min(1).max(80),
7122
+ type: literal$1("icon"),
7123
+ name: string$1().trim().min(1).max(80),
6900
7124
  size: viewIconSizeSchema.optional(),
6901
7125
  color: viewIconColorSchema.optional(),
6902
7126
  tone: viewToneSchema.optional()
6903
7127
  }),
6904
7128
  object({
6905
7129
  ...baseNodeShape,
6906
- type: literal("fields"),
6907
- items: array(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
7130
+ type: literal$1("fields"),
7131
+ items: array$1(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
6908
7132
  }),
6909
7133
  object({
6910
7134
  ...baseNodeShape,
6911
- type: literal("list"),
7135
+ type: literal$1("list"),
6912
7136
  variant: viewListVariantSchema.optional(),
6913
- initialCount: number().int().positive().max(VIEW_BUDGET.maxListItems).optional(),
6914
- items: array(viewListItemSchema).max(VIEW_BUDGET.maxListItems)
7137
+ initialCount: number$1().int().positive().max(VIEW_BUDGET.maxListItems).optional(),
7138
+ items: array$1(viewListItemSchema).max(VIEW_BUDGET.maxListItems)
6915
7139
  }),
6916
7140
  object({
6917
7141
  ...baseNodeShape,
6918
- type: literal("badge"),
7142
+ type: literal$1("badge"),
6919
7143
  text: shortTextSchema,
6920
7144
  tone: _enum([...viewToneSchema.options, "primary", "primary-media"]).optional()
6921
7145
  }),
6922
- object({ ...baseNodeShape, type: literal("divider") }),
7146
+ object({ ...baseNodeShape, type: literal$1("divider") }),
6923
7147
  object({
6924
7148
  ...baseNodeShape,
6925
- type: literal("button"),
7149
+ type: literal$1("button"),
6926
7150
  text: shortTextSchema,
6927
7151
  variant: viewButtonVariantSchema.optional(),
6928
7152
  /**
@@ -6931,56 +7155,56 @@ var knownNodeSchema = lazy(
6931
7155
  */
6932
7156
  tone: viewToneSchema.optional(),
6933
7157
  disabled: boolean().optional(),
6934
- disabledReason: string().trim().max(200).optional(),
7158
+ disabledReason: string$1().trim().max(200).optional(),
6935
7159
  busy: boolean().optional(),
6936
7160
  action: viewActionSchema.optional()
6937
7161
  }),
6938
7162
  object({
6939
7163
  id: nodeIdSchema,
6940
- type: literal("switch"),
7164
+ type: literal$1("switch"),
6941
7165
  label: shortTextSchema,
6942
7166
  checked: boolean(),
6943
7167
  disabled: boolean().optional(),
6944
- disabledReason: string().trim().max(200).optional(),
7168
+ disabledReason: string$1().trim().max(200).optional(),
6945
7169
  busy: boolean().optional(),
6946
7170
  action: viewActionSchema.optional(),
6947
7171
  fallback: viewNodeSchema.optional()
6948
7172
  }),
6949
7173
  object({
6950
7174
  id: nodeIdSchema,
6951
- type: literal("expandable"),
6952
- collapsedLines: number().int().positive().max(50),
7175
+ type: literal$1("expandable"),
7176
+ collapsedLines: number$1().int().positive().max(50),
6953
7177
  expandText: shortTextSchema,
6954
7178
  collapseText: shortTextSchema,
6955
- children: array(viewNodeSchema)
7179
+ children: array$1(viewNodeSchema)
6956
7180
  }),
6957
7181
  object({
6958
7182
  id: nodeIdSchema,
6959
- type: literal("renderer"),
6960
- rendererViewId: string().trim().min(1).max(120),
7183
+ type: literal$1("renderer"),
7184
+ rendererViewId: string$1().trim().min(1).max(120),
6961
7185
  content: object({
6962
- resourceKey: string().trim().min(1).max(512),
7186
+ resourceKey: string$1().trim().min(1).max(512),
6963
7187
  space: _enum(["instance", "shared"]).optional()
6964
7188
  }).optional(),
6965
- aspectRatio: string().trim().max(20).optional(),
6966
- height: number().int().positive().max(2e3).optional()
7189
+ aspectRatio: string$1().trim().max(20).optional(),
7190
+ height: number$1().int().positive().max(2e3).optional()
6967
7191
  }),
6968
7192
  object({
6969
7193
  id: nodeIdSchema,
6970
- type: literal("frame"),
6971
- frameId: string().trim().min(1).max(120),
6972
- key: string().min(1).max(200).optional(),
7194
+ type: literal$1("frame"),
7195
+ frameId: string$1().trim().min(1).max(120),
7196
+ key: string$1().min(1).max(200).optional(),
6973
7197
  params: viewFrameParamsSchema.optional(),
6974
- aspectRatio: string().trim().max(20).optional(),
6975
- height: number().int().positive().max(2e3).optional()
7198
+ aspectRatio: string$1().trim().max(20).optional(),
7199
+ height: number$1().int().positive().max(2e3).optional()
6976
7200
  }),
6977
7201
  meterNodeSchema,
6978
7202
  object({
6979
7203
  ...baseNodeShape,
6980
- type: literal("radialProgress"),
6981
- value: number().min(0).max(1),
7204
+ type: literal$1("radialProgress"),
7205
+ value: number$1().min(0).max(1),
6982
7206
  label: shortTextSchema,
6983
- valueLabel: string().trim().min(1).max(40).optional(),
7207
+ valueLabel: string$1().trim().min(1).max(40).optional(),
6984
7208
  centerGraphic: viewRadialProgressCenterGraphicSchema.optional(),
6985
7209
  size: viewRadialProgressSizeSchema.optional(),
6986
7210
  tone: viewToneSchema.optional(),
@@ -6988,17 +7212,17 @@ var knownNodeSchema = lazy(
6988
7212
  }),
6989
7213
  object({
6990
7214
  ...baseNodeShape,
6991
- type: literal("sparkline"),
7215
+ type: literal$1("sparkline"),
6992
7216
  /** 原始数值序列,宿主归一化绘制;少于 2 个点不构成趋势,由 schema 拒绝。 */
6993
- values: array(number()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
7217
+ values: array$1(number$1()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
6994
7218
  /** 可访问名称;缺省时由宿主以末值文本兜底。 */
6995
7219
  label: shortTextSchema.optional(),
6996
7220
  tone: viewToneSchema.optional()
6997
7221
  }),
6998
7222
  object({
6999
7223
  ...baseNodeShape,
7000
- type: literal("barChart"),
7001
- items: array(viewBarChartItemSchema).min(2).max(VIEW_BUDGET.maxBarChartItems),
7224
+ type: literal$1("barChart"),
7225
+ items: array$1(viewBarChartItemSchema).min(2).max(VIEW_BUDGET.maxBarChartItems),
7002
7226
  label: shortTextSchema,
7003
7227
  size: viewBarChartSizeSchema.optional(),
7004
7228
  tone: viewToneSchema.optional(),
@@ -7006,27 +7230,27 @@ var knownNodeSchema = lazy(
7006
7230
  }),
7007
7231
  object({
7008
7232
  id: nodeIdSchema,
7009
- type: literal("tabs"),
7010
- items: array(
7233
+ type: literal$1("tabs"),
7234
+ items: array$1(
7011
7235
  object({
7012
7236
  id: nodeIdSchema,
7013
7237
  label: shortTextSchema,
7014
- badge: string().trim().max(40).optional(),
7015
- children: array(viewNodeSchema)
7238
+ badge: string$1().trim().max(40).optional(),
7239
+ children: array$1(viewNodeSchema)
7016
7240
  })
7017
7241
  ).min(1).max(VIEW_BUDGET.maxTabItems),
7018
7242
  fallback: viewNodeSchema.optional()
7019
7243
  }),
7020
7244
  object({
7021
7245
  id: nodeIdSchema,
7022
- type: literal("textField"),
7246
+ type: literal$1("textField"),
7023
7247
  label: shortTextSchema,
7024
- placeholder: string().trim().max(120).optional(),
7025
- value: string().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7026
- maxLength: number().int().positive().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7248
+ placeholder: string$1().trim().max(120).optional(),
7249
+ value: string$1().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7250
+ maxLength: number$1().int().positive().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7027
7251
  disabled: boolean().optional(),
7028
7252
  clearable: boolean().optional(),
7029
- resetToken: string().trim().max(120).optional(),
7253
+ resetToken: string$1().trim().max(120).optional(),
7030
7254
  submitAction: viewActionSchema.optional(),
7031
7255
  fallback: viewNodeSchema.optional()
7032
7256
  })
@@ -7034,13 +7258,13 @@ var knownNodeSchema = lazy(
7034
7258
  );
7035
7259
  var unknownNodeSchema = lazy(
7036
7260
  () => looseObject({
7037
- type: string().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7261
+ type: string$1().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7038
7262
  error: "\u5DF2\u77E5\u8282\u70B9\u7C7B\u578B\u5FC5\u987B\u5339\u914D\u5176\u81EA\u8EAB schema\uFF0C\u4E0D\u80FD\u9000\u5316\u4E3A\u672A\u77E5\u8282\u70B9"
7039
7263
  }),
7040
7264
  fallback: viewNodeSchema.optional()
7041
7265
  })
7042
7266
  );
7043
- var viewNodeSchema = union([knownNodeSchema, unknownNodeSchema]);
7267
+ var viewNodeSchema = union$1([knownNodeSchema, unknownNodeSchema]);
7044
7268
  var viewRegionStatusSchema = _enum(["ready", "loading", "empty", "error"]);
7045
7269
  var viewRetryPresentationSchema = _enum(["button", "inline"]);
7046
7270
  var viewRegionSchema = object({
@@ -7052,15 +7276,15 @@ var viewRegionSchema = object({
7052
7276
  /** 仅在 `status` 为 `error` 时有意义。 */
7053
7277
  retry: viewActionSchema.optional(),
7054
7278
  /** 覆盖宿主默认错误文案;仅用于 `error` Region。 */
7055
- errorText: string().trim().min(1).max(200).optional(),
7279
+ errorText: string$1().trim().min(1).max(200).optional(),
7056
7280
  /** 重试动作的宿主呈现方式;`inline` 使用 Accent 文字动作。 */
7057
7281
  retryPresentation: viewRetryPresentationSchema.optional(),
7058
7282
  /** 覆盖宿主默认空态文案;显式空字符串表示只呈现业务视觉锚点。 */
7059
- emptyText: string().trim().max(200).optional(),
7283
+ emptyText: string$1().trim().max(200).optional(),
7060
7284
  /** 顶部瞬时说明;出现与消失不参与节点预算,也不引起内容重排。 */
7061
7285
  notice: viewRegionNoticeSchema.optional(),
7062
7286
  /** `ready` 时是真实内容,`loading` 时是占位蓝图,`empty/error` 时可选保留业务视觉锚点。 */
7063
- nodes: array(viewNodeSchema).default([])
7287
+ nodes: array$1(viewNodeSchema).default([])
7064
7288
  }).superRefine((region2, context) => {
7065
7289
  if (region2.refreshing === true && region2.status !== "ready") {
7066
7290
  context.addIssue({
@@ -7093,10 +7317,10 @@ var viewRegionSchema = object({
7093
7317
  });
7094
7318
  object({
7095
7319
  /** 文档 schema 的整数 major 版本。 */
7096
- schema: number().int().positive(),
7320
+ schema: number$1().int().positive(),
7097
7321
  /** Runtime 更新文档时由包内 renderer 执行的渐进增强过渡。 */
7098
7322
  transition: viewTransitionSchema.optional(),
7099
- regions: array(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7323
+ regions: array$1(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7100
7324
  });
7101
7325
  function fail(message) {
7102
7326
  throw new Error(`workspaceCards: ${message}`);
@@ -7157,6 +7381,317 @@ function validateWorkspaceCardParams(value) {
7157
7381
  visit(value);
7158
7382
  }
7159
7383
 
7384
+ const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
7385
+ if (!inst._zod)
7386
+ throw new Error("Uninitialized schema in ZodMiniType.");
7387
+ $ZodType.init(inst, def);
7388
+ inst.def = def;
7389
+ inst.type = def.type;
7390
+ inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
7391
+ inst.safeParse = (data, params) => safeParse$1(inst, data, params);
7392
+ inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
7393
+ inst.safeParseAsync = async (data, params) => safeParseAsync$1(inst, data, params);
7394
+ inst.check = (...checks) => {
7395
+ return inst.clone({
7396
+ ...def,
7397
+ checks: [
7398
+ ...(def.checks ?? []),
7399
+ ...checks.map((ch) => typeof ch === "function"
7400
+ ? {
7401
+ _zod: { check: ch, def: { check: "custom" }, onattach: [] },
7402
+ }
7403
+ : ch),
7404
+ ],
7405
+ }, { parent: true });
7406
+ };
7407
+ inst.with = inst.check;
7408
+ inst.clone = (_def, params) => clone(inst, _def, params);
7409
+ inst.brand = () => inst;
7410
+ inst.register = ((reg, meta) => {
7411
+ reg.add(inst, meta);
7412
+ return inst;
7413
+ });
7414
+ inst.apply = (fn) => fn(inst);
7415
+ });
7416
+ const ZodMiniString = /*@__PURE__*/ $constructor("ZodMiniString", (inst, def) => {
7417
+ $ZodString.init(inst, def);
7418
+ ZodMiniType.init(inst, def);
7419
+ });
7420
+ // @__NO_SIDE_EFFECTS__
7421
+ function string(params) {
7422
+ return _string(ZodMiniString, params);
7423
+ }
7424
+ const ZodMiniNumber = /*@__PURE__*/ $constructor("ZodMiniNumber", (inst, def) => {
7425
+ $ZodNumber.init(inst, def);
7426
+ ZodMiniType.init(inst, def);
7427
+ });
7428
+ // @__NO_SIDE_EFFECTS__
7429
+ function number(params) {
7430
+ return _number(ZodMiniNumber, params);
7431
+ }
7432
+ const ZodMiniNumberFormat = /*@__PURE__*/ $constructor("ZodMiniNumberFormat", (inst, def) => {
7433
+ $ZodNumberFormat.init(inst, def);
7434
+ ZodMiniNumber.init(inst, def);
7435
+ });
7436
+ // int
7437
+ // @__NO_SIDE_EFFECTS__
7438
+ function int(params) {
7439
+ return _int(ZodMiniNumberFormat, params);
7440
+ }
7441
+ const ZodMiniNull = /*@__PURE__*/ $constructor("ZodMiniNull", (inst, def) => {
7442
+ $ZodNull.init(inst, def);
7443
+ ZodMiniType.init(inst, def);
7444
+ });
7445
+ // @__NO_SIDE_EFFECTS__
7446
+ function _null(params) {
7447
+ return _null$2(ZodMiniNull, params);
7448
+ }
7449
+ const ZodMiniNever = /*@__PURE__*/ $constructor("ZodMiniNever", (inst, def) => {
7450
+ $ZodNever.init(inst, def);
7451
+ ZodMiniType.init(inst, def);
7452
+ });
7453
+ // @__NO_SIDE_EFFECTS__
7454
+ function never(params) {
7455
+ return _never(ZodMiniNever, params);
7456
+ }
7457
+ const ZodMiniArray = /*@__PURE__*/ $constructor("ZodMiniArray", (inst, def) => {
7458
+ $ZodArray.init(inst, def);
7459
+ ZodMiniType.init(inst, def);
7460
+ });
7461
+ // @__NO_SIDE_EFFECTS__
7462
+ function array(element, params) {
7463
+ return new ZodMiniArray({
7464
+ type: "array",
7465
+ element: element,
7466
+ ...normalizeParams(params),
7467
+ });
7468
+ }
7469
+ const ZodMiniObject = /*@__PURE__*/ $constructor("ZodMiniObject", (inst, def) => {
7470
+ $ZodObject.init(inst, def);
7471
+ ZodMiniType.init(inst, def);
7472
+ defineLazy(inst, "shape", () => def.shape);
7473
+ });
7474
+ // strictObject
7475
+ // @__NO_SIDE_EFFECTS__
7476
+ function strictObject(shape, params) {
7477
+ return new ZodMiniObject({
7478
+ type: "object",
7479
+ shape,
7480
+ catchall: never(),
7481
+ ...normalizeParams(params),
7482
+ });
7483
+ }
7484
+ const ZodMiniUnion = /*@__PURE__*/ $constructor("ZodMiniUnion", (inst, def) => {
7485
+ $ZodUnion.init(inst, def);
7486
+ ZodMiniType.init(inst, def);
7487
+ });
7488
+ // @__NO_SIDE_EFFECTS__
7489
+ function union(options, params) {
7490
+ return new ZodMiniUnion({
7491
+ type: "union",
7492
+ options: options,
7493
+ ...normalizeParams(params),
7494
+ });
7495
+ }
7496
+ const ZodMiniLiteral = /*@__PURE__*/ $constructor("ZodMiniLiteral", (inst, def) => {
7497
+ $ZodLiteral.init(inst, def);
7498
+ ZodMiniType.init(inst, def);
7499
+ });
7500
+ // @__NO_SIDE_EFFECTS__
7501
+ function literal(value, params) {
7502
+ return new ZodMiniLiteral({
7503
+ type: "literal",
7504
+ values: Array.isArray(value) ? value : [value],
7505
+ ...normalizeParams(params),
7506
+ });
7507
+ }
7508
+ const ZodMiniOptional = /*@__PURE__*/ $constructor("ZodMiniOptional", (inst, def) => {
7509
+ $ZodOptional.init(inst, def);
7510
+ ZodMiniType.init(inst, def);
7511
+ });
7512
+ // @__NO_SIDE_EFFECTS__
7513
+ function optional(innerType) {
7514
+ return new ZodMiniOptional({
7515
+ type: "optional",
7516
+ innerType: innerType,
7517
+ });
7518
+ }
7519
+ const ZodMiniLazy = /*@__PURE__*/ $constructor("ZodMiniLazy", (inst, def) => {
7520
+ $ZodLazy.init(inst, def);
7521
+ ZodMiniType.init(inst, def);
7522
+ });
7523
+ // export function lazy<T extends object>(getter: () => T): T {
7524
+ // return util.createTransparentProxy<T>(getter);
7525
+ // }
7526
+ // @__NO_SIDE_EFFECTS__
7527
+ function _lazy(getter) {
7528
+ return new ZodMiniLazy({
7529
+ type: "lazy",
7530
+ getter: getter,
7531
+ });
7532
+ }
7533
+
7534
+ // 由 scripts/generate-user-data-contract.mjs 从公开 DTO 生成,请勿手改。
7535
+ const definitions = {
7536
+ "ArkGachaAnalysisRecord": strictObject({ "name": string(), "timestamp": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "diff": number(), "negativeDiff": number(), "tag": string(), "missUp": union([literal(false), literal(true)]) }),
7537
+ "GachaRecord": strictObject({ "id": string(), "name": string(), "pool": string(), "rarity": number(), "timestamp": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7538
+ "TaskBarHeroSave": strictObject({ "update_time": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "game_version": string(), "account_version": string(), "play_time": number(), "last_saved_time": string(), "common": _lazy(() => definitions["TaskBarHeroCommon"]), "summary": _lazy(() => definitions["TaskBarHeroSummary"]), "heroes": union([_null(), array(_lazy(() => definitions["TaskBarHeroHero"]))]), "rune_save_data": union([_null(), array(_lazy(() => definitions["TaskBarHeroRune"]))]), "pets": union([_null(), array(_lazy(() => definitions["TaskBarHeroPet"]))]), "attributes": union([_null(), array(_lazy(() => definitions["TaskBarHeroAttribute"]))]), "inventory_slots": union([_null(), array(_lazy(() => definitions["TaskBarHeroItemSlot"]))]), "stash_slots": union([_null(), array(_lazy(() => definitions["TaskBarHeroItemSlot"]))]), "item_instances": union([_null(), array(_lazy(() => definitions["TaskBarHeroItemInstance"]))]), "values": _lazy(() => definitions["TaskBarHeroValueSummary"]) }),
7539
+ "TaskBarHeroCommon": strictObject({ "max_completed_stage": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "current_stage_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "current_stage_wave": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "arranged_hero_keys": union([_null(), array(union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]))]), "arranged_pet_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7540
+ "TaskBarHeroSummary": strictObject({ "max_hero_level": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "learned_rune_count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "unlocked_hero": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "total_hero": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "item_count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "inventory_slots": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "stash_slots": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7541
+ "TaskBarHeroHero": strictObject({ "hero_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "hero_level": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "is_unlock": union([literal(false), literal(true)]), "hero_exp": number(), "ability_point": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "allocated_hero_ability_point": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "equipped_item_ids": union([_null(), array(string())]), "equipped_skill_keys": union([_null(), array(union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]))]), "unlocked_attribute_group_keys": union([_null(), array(union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]))]) }),
7542
+ "TaskBarHeroRune": strictObject({ "rune_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "level": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7543
+ "TaskBarHeroPet": strictObject({ "pet_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "is_unlock": union([literal(false), literal(true)]) }),
7544
+ "TaskBarHeroAttribute": strictObject({ "key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "level": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7545
+ "TaskBarHeroItemSlot": strictObject({ "index": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "item_unique_id": string(), "is_unlock": union([literal(false), literal(true)]), "is_unlocked_by_rune": union([literal(false), literal(true)]) }),
7546
+ "TaskBarHeroItemInstance": strictObject({ "item_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "unique_id": string(), "is_chaotic": union([literal(false), literal(true)]), "is_blocked": union([literal(false), literal(true)]), "is_server_pending_item": union([literal(false), literal(true)]), "enchant_count": union([_null(), array(union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]))]), "enchant_data": union([_null(), array(_lazy(() => definitions["TaskBarHeroEnchantData"]))]), "item_get_source_type": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "decoration_applied_total_count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "engraving_applied_total_count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "inscription_applied_total_count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7547
+ "TaskBarHeroEnchantData": strictObject({ "stat_mod_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "tier": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "value": number(), "recipe_type": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "mod_type": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "material_key": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "stat_type": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7548
+ "TaskBarHeroValueSummary": strictObject({ "market_value": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "price_state": string(), "currency": string() }),
7549
+ "PhantomBladeZeroUnavailableValue": strictObject({ "value": _null(), "reason": string() }),
7550
+ "PhantomBladeZeroClearanceRecord": strictObject({ "Cycle": optional(union([_null(), number()])), "Ending": number(), "Difficulty": number(), "GameTime": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "Completion": number(), "DiedTimes": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7551
+ "PhantomBladeZeroSlotProgress": strictObject({ "playTimeSeconds": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "playTime": string(), "lastLaunch": _lazy(() => definitions["PhantomBladeZeroUnavailableValue"]), "narrativePercentage": number(), "chapter": string(), "remainingDays": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7552
+ "PhantomBladeZeroSlotCombat": strictObject({ "loadout": optional(_lazy(() => definitions["PhantomBladeZeroSlotLoadout"])), "totalDeaths": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "cycleDeaths": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "bossKillTotal": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "currentMainWeapon": optional(union([_null(), _lazy(() => definitions["PhantomBladeZeroNamedItem"])])), "mainWeapon": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "currentShaqi": optional(union([_null(), _lazy(() => definitions["PhantomBladeZeroNamedItem"])])), "shaqi": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]) }),
7553
+ "PhantomBladeZeroSlotLoadout": strictObject({ "states": optional(union([_null(), array(_lazy(() => definitions["PhantomBladeZeroLoadoutState"]))])), "main_weapons": union([_null(), array(string())]), "shaqi_weapons": union([_null(), array(string())]), "accessory_ids": union([_null(), array(string())]), "top_medicine": string(), "bottom_medicine": string(), "current_weapon_index": number(), "current_shaqi_weapon_index": number() }),
7554
+ "PhantomBladeZeroLoadoutState": strictObject({ "category": string(), "id": string(), "level": optional(number()), "soul_forged": optional(union([literal(false), literal(true)])), "reincarnation_count": optional(number()) }),
7555
+ "PhantomBladeZeroNamedItem": strictObject({ "id": string(), "name": string() }),
7556
+ "PhantomBladeZeroCollectionCount": strictObject({ "unknown": optional(union([string(), number()])), "done": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "total": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7557
+ "PhantomBladeZeroSlotAchievementSummary": strictObject({ "unlocked": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "total": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "reason": string() }),
7558
+ "PhantomBladeZeroBossGroup": strictObject({ "map": string(), "mapName": string(), "count": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "bosses": union([_null(), array(_lazy(() => definitions["PhantomBladeZeroBoss"]))]) }),
7559
+ "PhantomBladeZeroBoss": strictObject({ "id": string(), "classPath": string(), "map": string(), "mapName": string(), "encountered": union([literal(false), literal(true)]), "killed": union([literal(false), literal(true)]), "kill": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "attempt": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "bestTimeMs": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "records": union([_null(), array(_lazy(() => definitions["PhantomBladeZeroBossRecord"]))]) }),
7560
+ "PhantomBladeZeroBossRecord": strictObject({ "cycle": string(), "diff": string(), "diffName": string(), "kill": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "attempt": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "bestTimeMs": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7561
+ "PhantomBladeZeroSlotCollectibles": strictObject({ "overall": _lazy(() => definitions["PhantomBladeZeroCollectionSummary"]), "craneBellCount": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "byBigMap": union([_null(), array(_lazy(() => definitions["PhantomBladeZeroBigMapProgress"]))]), "currentChapter": _lazy(() => definitions["PhantomBladeZeroChapterProgress"]) }),
7562
+ "PhantomBladeZeroCollectionSummary": strictObject({ "bell": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "weapon": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "shaqi": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "accessory": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "medicine": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "challenge": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "hupo": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "heishi": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]), "flower": _lazy(() => definitions["PhantomBladeZeroCollectionCount"]) }),
7563
+ "PhantomBladeZeroBigMapProgress": strictObject({ "unknown": optional(union([string(), number()])), "mapID": string(), "name": string(), "pct": number(), "done": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "total": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "subMaps": union([_null(), array(string())]) }),
7564
+ "PhantomBladeZeroChapterProgress": strictObject({ "unknown": optional(union([string(), number()])), "mapID": string(), "pct": number(), "done": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "total": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "reason": string() }),
7565
+ "PhantomBladeZeroQuestBranch": strictObject({ "BranchID": string(), "TasksProgress": union([_null(), array(union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]))]), "BranchType": string() }),
7566
+ "PhantomBladeZeroInventoryItem": strictObject({ "id": string(), "amount": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7567
+ "PhantomBladeZeroLocation": strictObject({ "map": string(), "mapName": string(), "x": number(), "y": number(), "z": number() }),
7568
+ "PhantomBladeZeroChallengeDetail": strictObject({ "key": optional(string()), "unknown": optional(union([literal(false), literal(true)])), "index": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]), "guids": union([_null(), array(string())]), "done": union([literal(false), literal(true)]), "locs": union([_null(), array(_lazy(() => definitions["PhantomBladeZeroLocation"]))]) })};
7569
+ const SNAPSHOT_FIELDS = ['schema_version', 'canPersist', 'resources'];
7570
+ const SNAPSHOT_OPTIONAL_FIELDS = ['egressTier'];
7571
+ const EGRESS_TIER_SET = new Set(['upload', 'no_network']);
7572
+ const RESOURCE_STATE_REQUIRED_FIELDS = [
7573
+ 'resource',
7574
+ 'declared',
7575
+ 'available',
7576
+ 'decision',
7577
+ 'revision',
7578
+ 'sessionAllowed',
7579
+ 'allowed',
7580
+ 'name',
7581
+ 'purposeText',
7582
+ 'scopeFingerprint',
7583
+ ];
7584
+ const RESOURCE_STATE_OPTIONAL_FIELDS = ['consentFingerprint'];
7585
+ const DECISION_SET = new Set(['ask', 'allow', 'deny']);
7586
+ /**
7587
+ * 严格解析 Host 返回的数据许可快照。
7588
+ *
7589
+ * @param value - 桥方法返回的未知值。
7590
+ * @returns 合法时返回归一化并冻结的 {@link DataPermissionSnapshot},否则 `{ valid: false }`。
7591
+ *
7592
+ * @remarks
7593
+ * 校验项:`schema_version === 1`;`revision` 是非负安全整数;`resources` 只包含已发布精确资源 key
7594
+ * 且不重复;每个资源状态字段齐全、类型正确、`decision` 合法;`consentFingerprint` 只允许出现在持久
7595
+ * `allow` 上。未知字段一律拒绝,避免 Host 把私人决定或额外私有字段顺带塞进公开页面。
7596
+ *
7597
+ * @since 0.9.6
7598
+ */
7599
+ function parseDataPermissionSnapshot(value) {
7600
+ if (!hasExactFields(value, SNAPSHOT_FIELDS, SNAPSHOT_OPTIONAL_FIELDS))
7601
+ return { valid: false };
7602
+ if (value.schema_version !== 1)
7603
+ return { valid: false };
7604
+ if (typeof value.canPersist !== 'boolean')
7605
+ return { valid: false };
7606
+ if (!Array.isArray(value.resources))
7607
+ return { valid: false };
7608
+ if (value.resources.length > USER_GAME_DATA_RESOURCE_KEYS.length)
7609
+ return { valid: false };
7610
+ if (value.egressTier !== undefined && (typeof value.egressTier !== 'string' || !EGRESS_TIER_SET.has(value.egressTier))) {
7611
+ return { valid: false };
7612
+ }
7613
+ const seen = new Set();
7614
+ const resources = [];
7615
+ for (const entry of value.resources) {
7616
+ const parsed = parseResourceState(entry);
7617
+ if (!parsed)
7618
+ return { valid: false };
7619
+ if (seen.has(parsed.resource))
7620
+ return { valid: false };
7621
+ seen.add(parsed.resource);
7622
+ resources.push(parsed);
7623
+ }
7624
+ return {
7625
+ valid: true,
7626
+ snapshot: Object.freeze({
7627
+ schema_version: 1,
7628
+ canPersist: value.canPersist,
7629
+ resources: Object.freeze(resources),
7630
+ ...(value.egressTier === undefined ? {} : { egressTier: value.egressTier }),
7631
+ }),
7632
+ };
7633
+ }
7634
+ function parseResourceState(value) {
7635
+ if (!hasExactFields(value, RESOURCE_STATE_REQUIRED_FIELDS, RESOURCE_STATE_OPTIONAL_FIELDS)) {
7636
+ return undefined;
7637
+ }
7638
+ if (typeof value.resource !== 'string' || !isUserGameDataResourceKey(value.resource))
7639
+ return undefined;
7640
+ if (typeof value.declared !== 'boolean')
7641
+ return undefined;
7642
+ if (typeof value.available !== 'boolean')
7643
+ return undefined;
7644
+ if (typeof value.decision !== 'string' || !DECISION_SET.has(value.decision))
7645
+ return undefined;
7646
+ if (!isNonNegativeSafeInteger(value.revision))
7647
+ return undefined;
7648
+ if (typeof value.name !== 'string' || typeof value.purposeText !== 'string' || typeof value.scopeFingerprint !== 'string')
7649
+ return undefined;
7650
+ if (typeof value.allowed !== 'boolean' || typeof value.sessionAllowed !== 'boolean')
7651
+ return undefined;
7652
+ const hasFingerprint = Object.prototype.hasOwnProperty.call(value, 'consentFingerprint');
7653
+ if (hasFingerprint) {
7654
+ if (value.decision !== 'allow')
7655
+ return undefined;
7656
+ if (typeof value.consentFingerprint !== 'string' || value.consentFingerprint.length === 0) {
7657
+ return undefined;
7658
+ }
7659
+ }
7660
+ return {
7661
+ resource: value.resource,
7662
+ declared: value.declared,
7663
+ available: value.available,
7664
+ decision: value.decision,
7665
+ revision: value.revision,
7666
+ name: value.name,
7667
+ purposeText: value.purposeText,
7668
+ scopeFingerprint: value.scopeFingerprint,
7669
+ sessionAllowed: value.sessionAllowed,
7670
+ allowed: value.allowed,
7671
+ ...(hasFingerprint ? { consentFingerprint: value.consentFingerprint } : {}),
7672
+ };
7673
+ }
7674
+ function isRecord$2(value) {
7675
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
7676
+ }
7677
+ function isNonNegativeSafeInteger(value) {
7678
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
7679
+ }
7680
+ function hasExactFields(value, required, optional = []) {
7681
+ if (!isRecord$2(value))
7682
+ return false;
7683
+ const keys = Object.keys(value);
7684
+ for (const key of keys) {
7685
+ if (!required.includes(key) && !optional.includes(key))
7686
+ return false;
7687
+ }
7688
+ for (const key of required) {
7689
+ if (!Object.prototype.hasOwnProperty.call(value, key))
7690
+ return false;
7691
+ }
7692
+ return true;
7693
+ }
7694
+
7160
7695
  /** 仅 SDK 内部拥有状态更新入口,业务只可读。 */
7161
7696
  function createWorkspaceCardsModule(client) {
7162
7697
  let context = null;
@@ -7505,7 +8040,7 @@ function createMessageId() {
7505
8040
  /** 构建时替换为当前发布包的实际版本。 */
7506
8041
  const HB_SDK_VERSION = typeof undefined === 'string'
7507
8042
  ? undefined
7508
- : '0.9.6-alpha.9';
8043
+ : '0.9.6';
7509
8044
 
7510
8045
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
7511
8046
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
@@ -7551,8 +8086,17 @@ function readRecord$1(value) {
7551
8086
  }
7552
8087
 
7553
8088
  const DEFAULT_TIMEOUT = 10000;
7554
- // 选择器等待、截图延迟、登录和关注确认由 Host 管理,使用长操作生命周期,不设固定总时长。
7555
- const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD]);
8089
+ // 这些操作等待 Host 的真实终态或用户选择,不使用普通请求的固定总时长。
8090
+ const HOST_MANAGED_TIMEOUT_METHODS = new Set([
8091
+ FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD,
8092
+ SHARE_SCREENSHOT_METHOD, SHARE_SCREENSHOT_LONG_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD,
8093
+ USER_DATA_FILE_METHOD, USER_DATA_SYNC_METHOD,
8094
+ USER_DATA_PERMISSION_REQUEST_METHOD, USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD,
8095
+ ]);
8096
+ /** SDK 内部共用的长操作分类;资料模块与普通 request 使用同一超时策略。 */
8097
+ function isHostManagedOperation(method) {
8098
+ return HOST_MANAGED_TIMEOUT_METHODS.has(method);
8099
+ }
7556
8100
  const HANDSHAKE_RETRY_INTERVAL = 250;
7557
8101
  /** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
7558
8102
  class MiniProgramBridgeClient {
@@ -7635,7 +8179,7 @@ class MiniProgramBridgeClient {
7635
8179
  }
7636
8180
  /** 调用父容器开放能力。 */
7637
8181
  async request(method, ...args) {
7638
- return this.performRequest(method, args[0], !HOST_MANAGED_TIMEOUT_METHODS.has(method), undefined, true);
8182
+ return this.performRequest(method, args[0], !isHostManagedOperation(method), undefined, true);
7639
8183
  }
7640
8184
  /** 发起不使用固定总时长 timer 的长操作。 */
7641
8185
  async requestOperation(method, payload, options = {}) {
@@ -10588,6 +11132,14 @@ function decodeBase64Url(value) {
10588
11132
  return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
10589
11133
  }
10590
11134
 
11135
+ let queue = Promise.resolve();
11136
+ /** 同页截图串行执行,避免长图捕获面遮挡另一次截图。 */
11137
+ function serializeScreenshot(capture) {
11138
+ const result = queue.then(capture);
11139
+ queue = result.catch(() => undefined);
11140
+ return result;
11141
+ }
11142
+
10591
11143
  /**
10592
11144
  * 截图并唤起分享。
10593
11145
  *
@@ -10604,13 +11156,169 @@ function decodeBase64Url(value) {
10604
11156
  * @see {@link MiniProgramScreenshotOptions}
10605
11157
  */
10606
11158
  function screenshot(requester, options) {
11159
+ return serializeScreenshot(() => captureScreenshot(requester, options));
11160
+ }
11161
+ /** 已持有截图队列的内部入口。 */
11162
+ function captureScreenshot(requester, options) {
11163
+ warnScreenshotWatermark();
11164
+ return requester.request(SHARE_SCREENSHOT_METHOD, options);
11165
+ }
11166
+ function warnScreenshotWatermark() {
10607
11167
  try {
10608
11168
  console.warn('[hb-sdk] share.screenshot 行为变更提醒:正式版 SDK 0.9.1 及以上默认添加小程序品牌水印;低于 0.9.1(含预发布版本)的 SDK 保持无水印截图。升级前请在目标截图区域底部预留至少 57 个逻辑像素,避免遮挡重要内容;watermarkTheme 的 light 为黑色水印,dark 为白色水印且是默认值,不自动跟随系统主题。系统按键截图不在此能力范围内。');
10609
11169
  }
10610
11170
  catch {
10611
11171
  // 日志输出失败不能阻断截图调用。
10612
11172
  }
10613
- return requester.request(SHARE_SCREENSHOT_METHOD, options);
11173
+ }
11174
+
11175
+ /** 将当前页面的 DOM 边界转换为逻辑像素矩形,再复用原截图分享流程。 */
11176
+ async function screenshotElement(requester, options) {
11177
+ return serializeScreenshot(() => captureElement(requester, options));
11178
+ }
11179
+ async function captureElement(requester, options) {
11180
+ if (!options || typeof options !== 'object' || Array.isArray(options) || 'rect' in options) {
11181
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement 必须传入包含 element 的配置,且不能指定 rect');
11182
+ }
11183
+ const { element, ...screenshotOptions } = options;
11184
+ if (typeof window === 'undefined' || typeof document === 'undefined' || typeof Element === 'undefined'
11185
+ || !(element instanceof Element) || element.ownerDocument !== document || !element.isConnected) {
11186
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须是当前页面中已挂载的 DOM 元素');
11187
+ }
11188
+ // DOMRect 已是当前窗口逻辑像素;不叠加滚动偏移,也不乘设备像素比。
11189
+ const { left, top, width, height } = element.getBoundingClientRect();
11190
+ const windowWidth = document.documentElement.clientWidth || window.innerWidth;
11191
+ const windowHeight = document.documentElement.clientHeight || window.innerHeight;
11192
+ const visibility = window.getComputedStyle(element).visibility;
11193
+ if (![left, top, width, height, windowWidth, windowHeight].every(Number.isFinite)
11194
+ || width <= 0 || height <= 0 || windowWidth <= 0 || windowHeight <= 0
11195
+ || element.getClientRects().length === 0 || visibility === 'hidden' || visibility === 'collapse') {
11196
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须具有可见的布局尺寸');
11197
+ }
11198
+ // 原生只支持纵向拼接;横向溢出不能静默退化为可见区域截图。
11199
+ if (width >= windowWidth + 1 || element.scrollWidth > element.clientWidth + 1) {
11200
+ throw createSDKError('INVALID_PARAMS', '暂不支持横向长图:元素宽度不能超过窗口,且不能包含横向溢出内容');
11201
+ }
11202
+ if (height >= windowHeight + 1 || element.scrollHeight > height + 1) {
11203
+ if (width > windowWidth + 1)
11204
+ throw createSDKError('INVALID_PARAMS', '长图宽度不能超过窗口');
11205
+ return screenshotLongElement(requester, options);
11206
+ }
11207
+ // clientWidth/clientHeight 为整数,DOMRect 保留亚像素;仅容忍不足 1 个逻辑像素的边界误差。
11208
+ const tolerance = 1;
11209
+ const right = left + width;
11210
+ const bottom = top + height;
11211
+ if (left <= -tolerance || top <= -tolerance || right >= windowWidth + tolerance || bottom >= windowHeight + tolerance) {
11212
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 的完整边界必须位于当前可见窗口内');
11213
+ }
11214
+ const clippedLeft = Math.max(0, left);
11215
+ const clippedTop = Math.max(0, top);
11216
+ const clippedWidth = left < 0 || right > windowWidth ? Math.min(windowWidth, right) - clippedLeft : width;
11217
+ const clippedHeight = top < 0 || bottom > windowHeight ? Math.min(windowHeight, bottom) - clippedTop : height;
11218
+ if (clippedWidth <= 0 || clippedHeight <= 0) {
11219
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须与当前可见窗口相交');
11220
+ }
11221
+ return captureScreenshot(requester, { ...screenshotOptions, rect: { left: clippedLeft, top: clippedTop, width: clippedWidth, height: clippedHeight } });
11222
+ }
11223
+ /** 在业务文档准备长图捕获面,再交给宿主原生截图。调用方持有同页截图队列。 */
11224
+ async function screenshotLongElement(requester, { element, ...options }) {
11225
+ if (!element.isConnected)
11226
+ throw createSDKError('INVALID_PARAMS', '截图元素已卸载');
11227
+ const bounds = element.getBoundingClientRect();
11228
+ const height = Math.max(bounds.height, element.scrollHeight + bounds.height - element.clientHeight);
11229
+ if (height > 10000 || bounds.width > 2048 || bounds.width * height > 4000000) {
11230
+ throw createSDKError('INVALID_PARAMS', '长图尺寸超过限制(高度 10000、面积 400 万逻辑像素)');
11231
+ }
11232
+ if (element.matches('iframe,video,object,embed') || element.querySelector('iframe,video,object,embed')) {
11233
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持嵌入网页和视频');
11234
+ }
11235
+ // 在业务自己的文档内复制,DOM 不经过 bridge,也不导出 Canvas 像素。
11236
+ if (!(element instanceof HTMLElement))
11237
+ throw createSDKError('INVALID_PARAMS', '长图需要 HTML 容器元素');
11238
+ const sources = [element, ...element.querySelectorAll('*')];
11239
+ if (sources.some(source => source.shadowRoot || source.localName.includes('-'))) {
11240
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持自定义元素和 Shadow DOM');
11241
+ }
11242
+ const clone = element.cloneNode(true);
11243
+ const copies = [clone, ...clone.querySelectorAll('*')];
11244
+ for (let i = 0; i < sources.length; i++) {
11245
+ const source = sources[i];
11246
+ const copy = copies[i];
11247
+ if (!copy.style)
11248
+ continue;
11249
+ const computed = window.getComputedStyle(source);
11250
+ if (computed.position === 'fixed' || computed.position === 'sticky')
11251
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持固定或吸顶元素');
11252
+ for (let j = 0; j < computed.length; j++) {
11253
+ const name = computed.item(j);
11254
+ copy.style.setProperty(name, computed.getPropertyValue(name), 'important');
11255
+ }
11256
+ copy.style.setProperty('animation', 'none', 'important');
11257
+ copy.style.setProperty('transition', 'none', 'important');
11258
+ if (source instanceof HTMLCanvasElement) {
11259
+ copy.getContext('2d')?.drawImage(source, 0, 0);
11260
+ }
11261
+ if (source instanceof HTMLInputElement)
11262
+ copy.value = source.value;
11263
+ if (source instanceof HTMLTextAreaElement)
11264
+ copy.value = source.value;
11265
+ if (source instanceof HTMLSelectElement)
11266
+ copy.selectedIndex = source.selectedIndex;
11267
+ if (source instanceof HTMLImageElement) {
11268
+ copy.src = source.currentSrc || source.src;
11269
+ copy.removeAttribute('srcset');
11270
+ copy.loading = 'eager';
11271
+ }
11272
+ }
11273
+ if (window.getComputedStyle(element).backgroundColor === 'rgba(0, 0, 0, 0)')
11274
+ clone.style.setProperty('background-color', 'white', 'important');
11275
+ clone.querySelectorAll('script').forEach(script => script.remove());
11276
+ clone.setAttribute('aria-hidden', 'true');
11277
+ clone.inert = true;
11278
+ clone.dataset.hbScreenshotStage = '';
11279
+ for (const [key, value] of Object.entries({ position: 'absolute', left: '0', top: '0', margin: '0', transform: 'none', width: `${bounds.width}px`, height: `${height}px`, 'box-sizing': 'border-box', 'min-width': '0', 'max-width': 'none', 'min-height': '0', 'max-height': 'none', overflow: 'hidden', 'z-index': '2147483647', 'pointer-events': 'none' })) {
11280
+ clone.style.setProperty(key, value, 'important');
11281
+ }
11282
+ const x = window.scrollX;
11283
+ const y = window.scrollY;
11284
+ const documentStyles = [document.documentElement, document.body].map(node => ({ node, style: node.getAttribute('style') }));
11285
+ let timer;
11286
+ try {
11287
+ // 小程序经常锁定 body 的高度与滚动;临时释放裁剪,确保捕获面完整可绘制。
11288
+ for (const { node } of documentStyles) {
11289
+ node.style.setProperty('overflow', 'visible', 'important');
11290
+ node.style.setProperty('min-height', `${height}px`, 'important');
11291
+ node.style.setProperty('scroll-behavior', 'auto', 'important');
11292
+ }
11293
+ document.body.append(clone);
11294
+ window.scrollTo(0, 0);
11295
+ // body 定位上下文可能有偏移,将独立捕获面校正到文档原点。
11296
+ const stageBounds = clone.getBoundingClientRect();
11297
+ clone.style.setProperty('left', `${-stageBounds.left}px`, 'important');
11298
+ clone.style.setProperty('top', `${-stageBounds.top}px`, 'important');
11299
+ await Promise.race([
11300
+ Promise.all([...(clone instanceof HTMLImageElement ? [clone] : []), ...clone.querySelectorAll('img')].map(image => image.decode())),
11301
+ new Promise((_, reject) => { timer = setTimeout(() => reject(createSDKError('REQUEST_TIMEOUT', '长图图片加载超时')), 5000); }),
11302
+ ]);
11303
+ const rendered = clone.getBoundingClientRect();
11304
+ if (Math.abs(rendered.left) >= 1 || Math.abs(rendered.top) >= 1 || Math.abs(rendered.width - bounds.width) >= 1 || Math.abs(rendered.height - height) >= 1) {
11305
+ throw createSDKError('INVALID_PARAMS', '当前页面布局无法容纳长图捕获面');
11306
+ }
11307
+ warnScreenshotWatermark();
11308
+ return await requester.request(SHARE_SCREENSHOT_LONG_METHOD, { ...options, rect: { left: 0, top: 0, width: bounds.width, height } });
11309
+ }
11310
+ finally {
11311
+ clearTimeout(timer);
11312
+ clone.remove();
11313
+ // 在恢复业务的 smooth 滚动样式前立即还原,避免退出截图后继续滚动。
11314
+ window.scrollTo(x, y);
11315
+ for (const { node, style } of documentStyles) {
11316
+ if (style === null)
11317
+ node.removeAttribute('style');
11318
+ else
11319
+ node.setAttribute('style', style);
11320
+ }
11321
+ }
10614
11322
  }
10615
11323
 
10616
11324
  /**
@@ -10641,6 +11349,7 @@ function createShareModule(requester, launchHref) {
10641
11349
  getExtra: () => readMiniProgramShareExtra(launchHref),
10642
11350
  showShareMenu: (options) => showShareMenu(requester, options),
10643
11351
  screenshot: (options) => screenshot(requester, options),
11352
+ screenshotElement: (options) => screenshotElement(requester, options),
10644
11353
  };
10645
11354
  }
10646
11355
 
@@ -11474,8 +12183,327 @@ function getSteamGameList(requester, options) {
11474
12183
  return requester.request(USER_GET_STEAM_GAME_LIST_METHOD, options);
11475
12184
  }
11476
12185
 
12186
+ function isRecord$1(value) {
12187
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
12188
+ }
12189
+ function requireRecord(value, label) {
12190
+ if (!isRecord$1(value))
12191
+ throw createSDKError('INVALID_RESPONSE', `${label}响应无效`);
12192
+ return value;
12193
+ }
12194
+ function requireString(value, label) {
12195
+ if (typeof value !== 'string')
12196
+ throw createSDKError('INVALID_RESPONSE', `${label}响应无效`);
12197
+ return value;
12198
+ }
12199
+ function readReadMeta(value) {
12200
+ if (value === undefined)
12201
+ return {};
12202
+ const input = requireRecord(value, 'meta');
12203
+ if (input.cacheHit !== undefined && typeof input.cacheHit !== 'boolean')
12204
+ throw createSDKError('INVALID_RESPONSE', 'meta 响应无效');
12205
+ return {
12206
+ ...(typeof input.cacheHit === 'boolean' ? { cacheHit: input.cacheHit } : {}),
12207
+ ...(typeof input.sourceRevision === 'string' ? { sourceRevision: input.sourceRevision } : {}),
12208
+ };
12209
+ }
12210
+ async function requestUserGameData(requester, method, payload, signal, cancelledCode = 'REQUEST_CANCELLED', cancelledMessage = '资料请求已取消') {
12211
+ if (signal?.aborted)
12212
+ throw createSDKError(cancelledCode, cancelledMessage);
12213
+ const operation = requester;
12214
+ const cancellableSignal = signal && typeof signal.addEventListener === 'function' ? signal : undefined;
12215
+ if (typeof operation.requestOperation === 'function' && (isHostManagedOperation(method) || cancellableSignal))
12216
+ return operation.requestOperation(method, payload, {
12217
+ ...(cancellableSignal ? { signal: cancellableSignal } : {}),
12218
+ createAbortError: () => createSDKError(cancelledCode, cancelledMessage),
12219
+ });
12220
+ const send = requester.request.bind(requester);
12221
+ return send(method, payload);
12222
+ }
12223
+ /** 只是 SDK 调用组合:真实授权、账号和交付策略仍由 Runtime 决定。 */
12224
+ function decorateBlocked(requester, value, retry) {
12225
+ if (typeof value.resource !== 'string' ||
12226
+ !isUserGameDataResourceKey(value.resource) ||
12227
+ !['login_required', 'permission_required', 'permission_denied', 'source_not_linked', 'source_login_required'].includes(String(value.reason)))
12228
+ throw createSDKError('INVALID_RESPONSE', '资料阻塞状态无效');
12229
+ const resource = value.resource;
12230
+ const message = requireString(value.message, '资料说明');
12231
+ const blocked = { status: 'blocked', resource, reason: value.reason, message };
12232
+ if (value.interaction === undefined)
12233
+ return blocked;
12234
+ const interaction = requireRecord(value.interaction, '交互');
12235
+ if (!['permission', 'manage', 'user_login'].includes(String(interaction.type)))
12236
+ throw createSDKError('INVALID_RESPONSE', '交互类型无效');
12237
+ return {
12238
+ ...blocked,
12239
+ action: Object.freeze({
12240
+ resource,
12241
+ type: interaction.type,
12242
+ label: requireString(interaction.label, '交互说明'),
12243
+ async resolve(options = {}) {
12244
+ try {
12245
+ const result = await requestUserGameData(requester, USER_DATA_PERMISSION_REQUEST_METHOD, { resource }, options.signal);
12246
+ if (result.status === 'cancelled')
12247
+ return null;
12248
+ return retry(options.signal);
12249
+ }
12250
+ catch (cause) {
12251
+ if (options.signal?.aborted || (isRecord$1(cause) && ['REQUEST_CANCELLED', 'AUTH_CANCELLED', 'LOGIN_CANCELLED'].includes(String(cause.code))))
12252
+ return null;
12253
+ throw cause;
12254
+ }
12255
+ },
12256
+ }),
12257
+ };
12258
+ }
12259
+ function convertWireReadResult(requester, value, convert, retry, schemaVersion) {
12260
+ const input = requireRecord(value, '资料');
12261
+ if (input.status !== 'blocked' && input.schemaVersion !== schemaVersion)
12262
+ throw createSDKError('REQUEST_UNSUPPORTED', 'SDK 与宿主正文版本不匹配');
12263
+ if (input.status === 'ready')
12264
+ return { status: 'ready', data: convert(input.data), meta: readReadMeta(input.meta) };
12265
+ if (input.status === 'empty' && (input.reason === 'no_data' || input.reason === 'not_ready'))
12266
+ return { status: 'empty', reason: input.reason, message: requireString(input.message, '空资料说明'), meta: readReadMeta(input.meta) };
12267
+ if (input.status === 'blocked')
12268
+ return decorateBlocked(requester, input, retry);
12269
+ throw createSDKError('INVALID_RESPONSE', '资料状态无效');
12270
+ }
12271
+ function convertWireSyncResult(requester, value, retry) {
12272
+ const input = requireRecord(value, '同步');
12273
+ if (input.status === 'succeeded')
12274
+ return { status: 'succeeded' };
12275
+ if (input.status === 'blocked')
12276
+ return decorateBlocked(requester, input, retry);
12277
+ throw createSDKError('INVALID_RESPONSE', '同步状态无效');
12278
+ }
12279
+
12280
+ /** 游戏门面与存档门面共用的精确资源映射,不依赖任一门面工厂。 */
12281
+ function resourceFor(game, family) {
12282
+ const resource = GAME_DATA_RESOURCE_CATALOG.find((value) => value.game === game && value.family === family);
12283
+ if (!resource)
12284
+ throw createSDKError('REQUEST_UNSUPPORTED', '游戏没有开放这类资料');
12285
+ return resource.key;
12286
+ }
12287
+ function queryPayload(game, family, operation) {
12288
+ const resource = resourceFor(game, family);
12289
+ const query = getUserDataResourceContract(resource).queries[operation];
12290
+ if (!query)
12291
+ throw createSDKError('REQUEST_UNSUPPORTED', '未开放资料操作');
12292
+ return { resource, operation, schemaVersion: query.version };
12293
+ }
12294
+
12295
+ /** 创建响应校验失败错误。 */
12296
+ function invalidResponse(message) {
12297
+ return createSDKError('INVALID_RESPONSE', message);
12298
+ }
12299
+ /**
12300
+ * 创建单个云存档文件对象。
12301
+ *
12302
+ * @remarks
12303
+ * 对象只持有查询快照中的 `gameId`/`saveId`/`fileId` 与公开元数据,冻结后不可改写。`downloadFile()`
12304
+ * 不接受 URL、路径或文件 ID,因此不能借对象把下载目标换成其它资源;字节始终由 Host 的受控
12305
+ * 文件句柄交付。
12306
+ */
12307
+ function createSaveFileInfo(requester, gameId, saveId, value) {
12308
+ const record = requireRecord(value, '存档文件元数据');
12309
+ const fileId = requireString(record.fileId, '存档文件 fileId');
12310
+ const name = requireString(record.name, '存档文件 name');
12311
+ if (typeof record.sizeBytes !== 'number' || !Number.isFinite(record.sizeBytes) || record.sizeBytes < 0) {
12312
+ throw invalidResponse('存档文件 sizeBytes 响应不合法');
12313
+ }
12314
+ const modifiedAt = requireString(record.modifiedAt, '存档文件 modifiedAt');
12315
+ return Object.freeze({
12316
+ fileId,
12317
+ name,
12318
+ sizeBytes: record.sizeBytes,
12319
+ modifiedAt,
12320
+ async downloadFile({ signal } = {}) {
12321
+ const descriptor = await requestUserGameData(requester, USER_DATA_FILE_METHOD, { resource: resourceFor(gameId, 'save_files'), saveId, fileId }, signal, 'DOWNLOAD_CANCELLED', '存档下载已取消').catch((error) => {
12322
+ if (signal?.aborted)
12323
+ throw createSDKError('DOWNLOAD_CANCELLED', '存档下载已取消');
12324
+ throw error;
12325
+ });
12326
+ // Host 必须返回只读 direct 文件描述符;写模式、URL/路径或其它形状都按非法响应拒绝。
12327
+ if (!isMiniProgramFileDescriptor(descriptor) || descriptor.mode !== 'read') {
12328
+ throw invalidResponse('存档文件必须为只读文件描述符');
12329
+ }
12330
+ const ref = descriptor.ref;
12331
+ if (!('handleId' in ref) || typeof ref.handleId !== 'string' || ref.handleId.length === 0) {
12332
+ throw invalidResponse('存档文件必须为受控只读文件句柄');
12333
+ }
12334
+ return getFileHandleRegistry(requester).createFile(descriptor);
12335
+ },
12336
+ });
12337
+ }
12338
+ /** 创建单个存档批次;只暴露公开字段,不透传宿主附加的账号或数据库元数据。 */
12339
+ function createSaveInfo(requester, gameId, value) {
12340
+ const record = requireRecord(value, '存档批次');
12341
+ const saveId = requireString(record.saveId, '存档批次 saveId');
12342
+ if (!Array.isArray(record.files))
12343
+ throw invalidResponse('存档批次 files 响应不合法');
12344
+ return Object.freeze({
12345
+ saveId,
12346
+ createdAt: requireString(record.createdAt, '存档批次 createdAt'),
12347
+ files: record.files.map((file) => createSaveFileInfo(requester, gameId, saveId, file)),
12348
+ });
12349
+ }
12350
+ /** 校验存档列表;空数组是合法的 `ready` 结果。 */
12351
+ function convertSaveInfoList(requester, gameId, value) {
12352
+ if (!Array.isArray(value))
12353
+ throw invalidResponse('云存档列表响应不合法');
12354
+ return value.map((entry) => createSaveInfo(requester, gameId, entry));
12355
+ }
12356
+ /**
12357
+ * 创建云存档三方法模块。
12358
+ *
12359
+ * @param requester - 模块发起请求所需的 bridge 能力。
12360
+ * @param gameId - 已开放的存档游戏,方法只作用于该游戏。
12361
+ * @returns `saves` 对象;每次调用重新解析当前来源、许可与解析结果。
12362
+ * @remarks
12363
+ * `list` 不触发同步或解析;`sync` 等待文件同步终态;`getLatestStructuredData` 只读已有结果。
12364
+ * `list()` 交付的文件对象取得受控只读文件句柄,不拼接 URL 或
12365
+ * 路径;四者都不接受账号、Steam AppID 或文件路径参数。
12366
+ *
12367
+ * @since 0.9.6
12368
+ * @hbPlatform android
12369
+ * @hbPlatform ios
12370
+ * @hbPlatform ohos
12371
+ * @hbPlatform windows
12372
+ * @hbPlatform macos
12373
+ * @hbClient android none
12374
+ * @hbClient ios none
12375
+ * @hbClient ohos none
12376
+ * @hbClient windows none
12377
+ * @hbClient macos none
12378
+ */
12379
+ function createUserSavesModule(requester, gameId) {
12380
+ const list = async (options = {}) => {
12381
+ const payload = queryPayload(gameId, 'save_files', 'list');
12382
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12383
+ return convertWireReadResult(requester, result, (value) => {
12384
+ const page = requireRecord(value, '存档列表');
12385
+ if (page.hasMore !== false || page.nextCursor !== undefined)
12386
+ throw invalidResponse('存档列表必须完整返回');
12387
+ return convertSaveInfoList(requester, gameId, page.items);
12388
+ }, (signal) => list({ signal }), payload.schemaVersion);
12389
+ };
12390
+ const sync = async (options = {}) => {
12391
+ const result = await requestUserGameData(requester, USER_DATA_SYNC_METHOD, { game: gameId }, options.signal);
12392
+ return convertWireSyncResult(requester, result, (signal) => sync({ signal }));
12393
+ };
12394
+ const getLatestStructuredData = async (options = {}) => {
12395
+ const payload = queryPayload(gameId, 'save_analysis', 'get');
12396
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12397
+ return convertWireReadResult(requester, result, (value) => requireRecord(value, '存档解析正文'), (signal) => getLatestStructuredData({ signal }), payload.schemaVersion);
12398
+ };
12399
+ return Object.freeze({ list, sync, getLatestStructuredData });
12400
+ }
12401
+
12402
+ function validate(value) {
12403
+ return requireRecord(value, '资料正文');
12404
+ }
12405
+ function createArkGameModule(requester) {
12406
+ const getProfile = async (options = {}) => {
12407
+ const payload = queryPayload('ark', 'profile', 'get');
12408
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12409
+ return convertWireReadResult(requester, result, (value) => validate(value), (signal) => getProfile({ signal }), payload.schemaVersion);
12410
+ };
12411
+ const getGachaAnalysis = async (options = {}) => {
12412
+ const payload = queryPayload('ark', 'gacha', 'get');
12413
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12414
+ return convertWireReadResult(requester, result, (value) => validate(value), (signal) => getGachaAnalysis({ signal }), payload.schemaVersion);
12415
+ };
12416
+ const listGachaRecords = async (options = {}) => {
12417
+ const payload = {
12418
+ ...queryPayload('ark', 'gacha', 'list'),
12419
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
12420
+ ...(options.limit === undefined ? {} : { limit: options.limit }),
12421
+ };
12422
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12423
+ return convertWireReadResult(requester, result, (value) => {
12424
+ const page = requireRecord(value, '分页');
12425
+ if (!Array.isArray(page.items) || typeof page.hasMore !== 'boolean')
12426
+ throw createSDKError('INVALID_RESPONSE', '分页正文无效');
12427
+ return page;
12428
+ }, (signal) => listGachaRecords({ ...options, signal }), payload.schemaVersion);
12429
+ };
12430
+ return Object.freeze({ getProfile, getGachaAnalysis, listGachaRecords });
12431
+ }
12432
+ function createUserGamesModule(requester) {
12433
+ const factories = {
12434
+ ark: () => createArkGameModule(requester),
12435
+ black_myth_wukong: () => ({ saves: createUserSavesModule(requester, 'black_myth_wukong') }),
12436
+ task_bar_hero: () => ({ saves: createUserSavesModule(requester, 'task_bar_hero') }),
12437
+ phantom_blade_zero: () => ({ saves: createUserSavesModule(requester, 'phantom_blade_zero') }),
12438
+ };
12439
+ return Object.freeze({
12440
+ get(game) {
12441
+ if (!isUserGameDataGameId(game))
12442
+ throw createSDKError('REQUEST_UNSUPPORTED', '尚未开放该游戏资料');
12443
+ return factories[game]();
12444
+ },
12445
+ async getOverview(options = {}) {
12446
+ const result = await requester.request(USER_GAMES_GET_OVERVIEW_METHOD, options);
12447
+ if (!Array.isArray(result))
12448
+ throw createSDKError('INVALID_RESPONSE', '资料概览无效');
12449
+ return {
12450
+ status: 'ready',
12451
+ meta: {},
12452
+ data: result.map((value) => {
12453
+ const game = requireRecord(value, '游戏概览');
12454
+ if (typeof game.game !== 'string' || !isUserGameDataGameId(game.game) || !Array.isArray(game.resources))
12455
+ throw createSDKError('INVALID_RESPONSE', '游戏概览无效');
12456
+ return {
12457
+ game: game.game,
12458
+ name: requireString(game.name, '游戏名'),
12459
+ resources: game.resources.map((value) => {
12460
+ const resource = requireRecord(value, '资源概览');
12461
+ if (typeof resource.resource !== 'string' || !isUserGameDataResourceKey(resource.resource) || resource.status !== 'not_checked')
12462
+ throw createSDKError('INVALID_RESPONSE', '资源概览无效');
12463
+ return {
12464
+ resource: resource.resource,
12465
+ name: requireString(resource.name, '资源名'),
12466
+ statusText: requireString(resource.statusText, '状态'),
12467
+ status: 'not_checked',
12468
+ };
12469
+ }),
12470
+ };
12471
+ }),
12472
+ };
12473
+ },
12474
+ });
12475
+ }
12476
+
12477
+ function createUserDataPermissionModule(requester) {
12478
+ function snapshot(value) {
12479
+ const parsed = parseDataPermissionSnapshot(value);
12480
+ if (!parsed.valid)
12481
+ throw createSDKError('INVALID_RESPONSE', '本机许可快照无效');
12482
+ return parsed.snapshot;
12483
+ }
12484
+ return {
12485
+ async request(resource, options = {}) {
12486
+ const result = await requestUserGameData(requester, USER_DATA_PERMISSION_REQUEST_METHOD, { resource }, options.signal);
12487
+ if (!result || !['allowed', 'denied', 'cancelled'].includes(result.status))
12488
+ throw createSDKError('INVALID_RESPONSE', '许可确认结果无效');
12489
+ return result;
12490
+ },
12491
+ async get() {
12492
+ return snapshot(await requester.request(USER_DATA_PERMISSION_GET_METHOD, {}));
12493
+ },
12494
+ async revokeSession(resource) {
12495
+ return snapshot(await requester.request(USER_DATA_PERMISSION_REVOKE_SESSION_METHOD, resource === undefined ? {} : { resource }));
12496
+ },
12497
+ async openSettings() {
12498
+ return snapshot(await requester.request(USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD, {}));
12499
+ },
12500
+ };
12501
+ }
12502
+
11477
12503
  function createUserModule(requester) {
11478
12504
  return {
12505
+ games: createUserGamesModule(requester),
12506
+ dataPermission: createUserDataPermissionModule(requester),
11479
12507
  requestFollowAuthor: () => requestFollowAuthor(requester),
11480
12508
  getFollowStatus: () => getFollowStatus(requester),
11481
12509
  showAppreciation: () => requester.request(USER_SHOW_APPRECIATION_METHOD),
@@ -11762,7 +12790,10 @@ class MiniProgramSDK {
11762
12790
  navigation;
11763
12791
  /** 云端数据相关开放能力。 */
11764
12792
  cloud;
11765
- /** 查询、同步并读取当前用户的 Steam 游戏存档。 */
12793
+ /**
12794
+ * 查询、同步并读取当前用户的 Steam 游戏存档。
12795
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
12796
+ */
11766
12797
  gameSaves;
11767
12798
  /** 受管桌面程序能力。 */
11768
12799
  companion;
@@ -12202,6 +13233,16 @@ const auth = {
12202
13233
  };
12203
13234
  /** 默认 SDK 实例的用户资料模块。 */
12204
13235
  const user = {
13236
+ dataPermission: {
13237
+ request: (resource, options) => getDefaultSDK().user.dataPermission.request(resource, options),
13238
+ get: () => getDefaultSDK().user.dataPermission.get(),
13239
+ revokeSession: (resource) => getDefaultSDK().user.dataPermission.revokeSession(resource),
13240
+ openSettings: () => getDefaultSDK().user.dataPermission.openSettings(),
13241
+ },
13242
+ games: {
13243
+ getOverview: (options) => getDefaultSDK().user.games.getOverview(options),
13244
+ get: (gameId) => getDefaultSDK().user.games.get(gameId),
13245
+ },
12205
13246
  requestFollowAuthor: () => getDefaultSDK().user.requestFollowAuthor(),
12206
13247
  getFollowStatus: () => getDefaultSDK().user.getFollowStatus(),
12207
13248
  showAppreciation: () => getDefaultSDK().user.showAppreciation(),
@@ -12215,6 +13256,7 @@ const share = {
12215
13256
  getExtra: () => getDefaultSDK().share.getExtra(),
12216
13257
  showShareMenu: (options) => getDefaultSDK().share.showShareMenu(options),
12217
13258
  screenshot: (options) => getDefaultSDK().share.screenshot(options),
13259
+ screenshotElement: (options) => getDefaultSDK().share.screenshotElement(options),
12218
13260
  };
12219
13261
  /** 默认 SDK 实例的 Viewport 模块。 */
12220
13262
  const viewport = {
@@ -12264,13 +13306,16 @@ const navigation = {
12264
13306
  reload: () => getDefaultSDK().navigation.reload(),
12265
13307
  openAppPage: (options) => getDefaultSDK().navigation.openAppPage(options),
12266
13308
  };
12267
- /** 默认 SDK 实例的 cloud 模块。 */
12268
- /** 当前用户的游戏存档能力。 */
13309
+ /**
13310
+ * 当前用户的游戏存档能力。
13311
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
13312
+ */
12269
13313
  const gameSaves = {
12270
13314
  list: (gameId) => getDefaultSDK().gameSaves.list(gameId),
12271
13315
  getLatestStructuredData: (gameId) => getDefaultSDK().gameSaves.getLatestStructuredData(gameId),
12272
13316
  sync: (gameId, options) => getDefaultSDK().gameSaves.sync(gameId, options),
12273
13317
  };
13318
+ /** 默认 SDK 实例的 cloud 模块。 */
12274
13319
  const cloud = {
12275
13320
  leaderboard: {
12276
13321
  submit: (options) => getDefaultSDK().cloud.leaderboard.submit(options),