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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +8 -1
  3. package/THIRD_PARTY_NOTICES.md +472 -48
  4. package/dist/cli-chunks/{artifact-BPntCpxe.cjs → artifact-DRmtmvso.cjs} +6 -5
  5. package/dist/cli-chunks/{build-C-u_43nO.cjs → build-DlWamOPK.cjs} +6 -5
  6. package/dist/cli-chunks/{create-HUynjFAz.cjs → create-gE-2wFLG.cjs} +322 -4
  7. package/dist/cli-chunks/{dev-Dpg4MIoV.cjs → dev-Budk_Smf.cjs} +309 -39
  8. package/dist/cli-chunks/{dev-context-BBInsRLS.cjs → dev-context-CAHli9Px.cjs} +22 -14
  9. package/dist/cli-chunks/{doctor-qjPdtMIj.cjs → doctor-aDdBunUU.cjs} +1 -1
  10. package/dist/cli-chunks/{games-B7ckiLkr.cjs → games-8htvQVHu.cjs} +1 -1
  11. package/dist/cli-chunks/{index-D0fPJhtR.cjs → index-CWDt652P.cjs} +210 -38
  12. package/dist/cli-chunks/{index-SB2iukXP.cjs → index-N0bgCRua.cjs} +1 -1
  13. package/dist/cli-chunks/index.esm-CvMA_ppV.cjs +7977 -0
  14. package/dist/cli-chunks/{index.esm-jOc0zgE7.cjs → index.esm-ULhrR_yy.cjs} +7 -6
  15. package/dist/cli-chunks/{login-DDKJA4pj.cjs → login-CHbr4NWc.cjs} +1 -1
  16. package/dist/cli-chunks/{project-vite-B_yd6m3R.cjs → project-vite-VYZf9zWw.cjs} +1 -1
  17. package/dist/cli-chunks/{remote-CSmfJpqd.cjs → remote-hNKe7N9s.cjs} +13 -8
  18. package/dist/cli-chunks/{runtime-permission-env-Bbc5KS3u.cjs → runtime-permission-env-DHhcX3jq.cjs} +52 -6990
  19. package/dist/cli-chunks/{skill-BTKQpM8e.cjs → skill-Cdwkma5i.cjs} +2 -2
  20. package/dist/cli-chunks/{version-Blqp4J3r.cjs → version-DlH0pMxl.cjs} +1 -1
  21. package/dist/cli.cjs +1 -1
  22. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DiEnUK28.js +228 -0
  23. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-DadGpXHp.js +6 -0
  24. package/dist/devtools/browser-dev-host/assets/index-BQmadjnU.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 +1092 -156
  38. package/dist/vite.esm.js +1092 -156
  39. package/docs/appreciation-code.md +4 -8
  40. package/package.json +7 -8
  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.cjs.js CHANGED
@@ -412,6 +412,16 @@ const COMPANION_SESSION_OUTPUT_EVENT = 'companion.session.output';
412
412
  const COMPANION_SESSION_EXIT_EVENT = 'companion.session.exit';
413
413
  const COMPANION_SESSION_OWNERSHIP_LOST_EVENT = 'companion.session.ownershipLost';
414
414
 
415
+ /** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
416
+ const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
417
+ const USER_DATA_QUERY_METHOD = 'user.data.query';
418
+ const USER_DATA_SYNC_METHOD = 'user.data.sync';
419
+ const USER_DATA_FILE_METHOD = 'user.data.file';
420
+ const USER_DATA_PERMISSION_REQUEST_METHOD = 'user.dataPermission.request';
421
+ const USER_DATA_PERMISSION_GET_METHOD = 'user.dataPermission.get';
422
+ const USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD = 'user.dataPermission.openSettings';
423
+ const USER_DATA_PERMISSION_REVOKE_SESSION_METHOD = 'user.dataPermission.revokeSession';
424
+
415
425
  const WORKSPACE_CARDS_REQUEST_REFRESH_METHOD = 'workspaceCards.requestRefresh';
416
426
  const AUTH_GET_ACCOUNT_STATE_METHOD = 'auth.getAccountState';
417
427
  const AUTH_LOGIN_METHOD = 'auth.login';
@@ -428,6 +438,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
428
438
  const SHARE_COPY_LINK_METHOD = 'share.copyLink';
429
439
  const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
430
440
  const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
441
+ /** DOM 长图内部传输方法;业务仍调用 screenshotElement。
442
+ * @internal
443
+ */
444
+ const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
431
445
  const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
432
446
  const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
433
447
  const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
@@ -555,7 +569,7 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
555
569
  * @since 0.3.1
556
570
  */
557
571
  function isMiniProgramBridgeMessage(value) {
558
- if (!isRecord$3(value))
572
+ if (!isRecord$5(value))
559
573
  return false;
560
574
  if (value.namespace !== MINI_PROGRAM_MESSAGE_NAMESPACE || (value.version !== 1 && value.version !== 2) || !isNonEmptyString$1(value.nonce)) {
561
575
  return false;
@@ -707,7 +721,7 @@ function isMiniProgramRelativePath(value) {
707
721
  * @since 0.8.0
708
722
  */
709
723
  function isMiniProgramPathRootRef(value) {
710
- if (!isRecord$3(value))
724
+ if (!isRecord$5(value))
711
725
  return false;
712
726
  if (value.kind === 'sandbox')
713
727
  return hasOnlyKeys(value, ['kind']);
@@ -774,7 +788,7 @@ function isMiniProgramPathRootRef(value) {
774
788
  * @since 0.8.0
775
789
  */
776
790
  function isMiniProgramFileRef(value) {
777
- if (!isRecord$3(value) || value.kind !== 'file')
791
+ if (!isRecord$5(value) || value.kind !== 'file')
778
792
  return false;
779
793
  if (isNonEmptyString$1(value.handleId)) {
780
794
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -842,7 +856,7 @@ function isMiniProgramFileRef(value) {
842
856
  * @since 0.8.0
843
857
  */
844
858
  function isMiniProgramDirectoryRef(value) {
845
- if (!isRecord$3(value) || value.kind !== 'directory')
859
+ if (!isRecord$5(value) || value.kind !== 'directory')
846
860
  return false;
847
861
  if (isNonEmptyString$1(value.handleId)) {
848
862
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -919,7 +933,7 @@ function isMiniProgramDirectoryRef(value) {
919
933
  * @since 0.8.0
920
934
  */
921
935
  function isMiniProgramFileDescriptor(value) {
922
- return (isRecord$3(value) &&
936
+ return (isRecord$5(value) &&
923
937
  value.kind === 'file' &&
924
938
  isNonEmptyString$1(value.name) &&
925
939
  isFileMode(value.mode) &&
@@ -972,20 +986,20 @@ const MEDIA_PICK_ITEM_KEYS = ['type', 'mimeType', 'size', 'width', 'height', 'pr
972
986
  * @since 0.9.3
973
987
  */
974
988
  function isMiniProgramMediaPickItem(value) {
975
- if (!isRecord$3(value) || (value.type !== 'image' && value.type !== 'video'))
989
+ if (!isRecord$5(value) || (value.type !== 'image' && value.type !== 'video'))
976
990
  return false;
977
991
  const isVideo = value.type === 'video';
978
992
  if (!hasOnlyKeys(value, isVideo ? [...MEDIA_PICK_ITEM_KEYS, 'durationMs'] : MEDIA_PICK_ITEM_KEYS))
979
993
  return false;
980
994
  if (!isNonEmptyString$1(value.mimeType) ||
981
- !isNonNegativeSafeInteger(value.size) ||
995
+ !isNonNegativeSafeInteger$1(value.size) ||
982
996
  !isPositiveSafeInteger$1(value.width) ||
983
997
  !isPositiveSafeInteger$1(value.height) ||
984
998
  !isNonEmptyString$1(value.previewUrl) ||
985
999
  !isDirectFileDescriptor(value.file)) {
986
1000
  return false;
987
1001
  }
988
- return isVideo ? isNonNegativeSafeInteger(value.durationMs) : true;
1002
+ return isVideo ? isNonNegativeSafeInteger$1(value.durationMs) : true;
989
1003
  }
990
1004
  /**
991
1005
  * 判断未知值是否为整批 `media.pick` 结果。
@@ -1143,9 +1157,9 @@ function isMiniProgramByteArray(value) {
1143
1157
  * @since 0.8.0
1144
1158
  */
1145
1159
  function isMiniProgramFileStat(value) {
1146
- return (isRecord$3(value) &&
1160
+ return (isRecord$5(value) &&
1147
1161
  value.kind === 'file' &&
1148
- isNonNegativeSafeInteger(value.size) &&
1162
+ isNonNegativeSafeInteger$1(value.size) &&
1149
1163
  (value.modifiedAt === undefined || isNonNegativeFiniteNumber(value.modifiedAt)) &&
1150
1164
  (value.createdAt === undefined || isNonNegativeFiniteNumber(value.createdAt)) &&
1151
1165
  hasOnlyKeys(value, ['kind', 'size', 'modifiedAt', 'createdAt']));
@@ -1204,28 +1218,28 @@ function isMiniProgramFileStat(value) {
1204
1218
  * @since 0.8.0
1205
1219
  */
1206
1220
  function isMiniProgramDownloadProgressPayload(value) {
1207
- if (!isRecord$3(value) ||
1208
- !isNonNegativeSafeInteger(value.loaded) ||
1221
+ if (!isRecord$5(value) ||
1222
+ !isNonNegativeSafeInteger$1(value.loaded) ||
1209
1223
  typeof value.lengthComputable !== 'boolean' ||
1210
1224
  !hasOnlyKeys(value, ['loaded', 'total', 'lengthComputable'])) {
1211
1225
  return false;
1212
1226
  }
1213
1227
  if (!value.lengthComputable)
1214
1228
  return value.total === undefined;
1215
- return isNonNegativeSafeInteger(value.total) && value.loaded <= value.total;
1229
+ return isNonNegativeSafeInteger$1(value.total) && value.loaded <= value.total;
1216
1230
  }
1217
1231
  function isMiniProgramCompanionPrepareProgress(value) {
1218
- if (!isRecord$3(value))
1232
+ if (!isRecord$5(value))
1219
1233
  return false;
1220
1234
  if (value.phase === 'downloading') {
1221
- return (isNonNegativeSafeInteger(value.loaded) &&
1222
- (value.total === undefined || (isNonNegativeSafeInteger(value.total) && value.loaded <= value.total)) &&
1235
+ return (isNonNegativeSafeInteger$1(value.loaded) &&
1236
+ (value.total === undefined || (isNonNegativeSafeInteger$1(value.total) && value.loaded <= value.total)) &&
1223
1237
  hasOnlyKeys(value, ['phase', 'loaded', 'total']));
1224
1238
  }
1225
1239
  if (value.phase !== 'verifying' && value.phase !== 'extracting')
1226
1240
  return false;
1227
- return (isNonNegativeSafeInteger(value.processed) &&
1228
- isNonNegativeSafeInteger(value.total) &&
1241
+ return (isNonNegativeSafeInteger$1(value.processed) &&
1242
+ isNonNegativeSafeInteger$1(value.total) &&
1229
1243
  value.processed <= value.total &&
1230
1244
  hasOnlyKeys(value, ['phase', 'processed', 'total']));
1231
1245
  }
@@ -1233,15 +1247,15 @@ function isMiniProgramOperationProgressPayload(value) {
1233
1247
  return isMiniProgramDownloadProgressPayload(value) || isMiniProgramCompanionPrepareProgress(value);
1234
1248
  }
1235
1249
  function isSDKHandshakePayload(value) {
1236
- return isRecord$3(value) && isNonEmptyString$1(value.href) && typeof value.userAgent === 'string' && isNonEmptyString$1(value.sdkVersion);
1250
+ return isRecord$5(value) && isNonEmptyString$1(value.href) && typeof value.userAgent === 'string' && isNonEmptyString$1(value.sdkVersion);
1237
1251
  }
1238
1252
  function isBridgeError(value) {
1239
- return isRecord$3(value) && isNonEmptyString$1(value.code) && typeof value.message === 'string';
1253
+ return isRecord$5(value) && isNonEmptyString$1(value.code) && typeof value.message === 'string';
1240
1254
  }
1241
1255
  function isFileMode(value) {
1242
1256
  return value === 'read' || value === 'readwrite';
1243
1257
  }
1244
- function isNonNegativeSafeInteger(value) {
1258
+ function isNonNegativeSafeInteger$1(value) {
1245
1259
  return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
1246
1260
  }
1247
1261
  function isPositiveSafeInteger$1(value) {
@@ -1257,10 +1271,217 @@ function hasOnlyKeys(value, allowedKeys) {
1257
1271
  const allowed = new Set(allowedKeys);
1258
1272
  return Object.keys(value).every((key) => allowed.has(key));
1259
1273
  }
1260
- function isRecord$3(value) {
1274
+ function isRecord$5(value) {
1261
1275
  return typeof value === 'object' && value !== null && !Array.isArray(value);
1262
1276
  }
1263
1277
 
1278
+ /**
1279
+ * 首发游戏与资源目录(冻结范围)。
1280
+ *
1281
+ * @remarks
1282
+ * 本版只开放 4 个游戏、8 项资源,资源 key 精确匹配,**不接受通配符、前缀或未登记的 key**。
1283
+ * 目录是 Manifest 声明、Host 门禁、SDK 具名方法与概览的唯一事实源:新增资源必须在代码中显式
1284
+ * 登记并重新生成机器可读目录,不会因为上游新增解析分支而自动扩大已有声明或许可。
1285
+ *
1286
+ * `disclosureRevision` 描述披露字段与用途的版本。本版所有资源都从 `1` 开始;只要字段或用途实质
1287
+ * 变化就必须递增,并让旧的持久许可指纹失配后重新确认。
1288
+ *
1289
+ * @since 0.9.6
1290
+ * @hbPlatform android
1291
+ * @hbPlatform ios
1292
+ * @hbPlatform ohos
1293
+ * @hbPlatform windows
1294
+ * @hbPlatform macos
1295
+ * @hbClient android none
1296
+ * @hbClient ios none
1297
+ * @hbClient ohos none
1298
+ * @hbClient windows none
1299
+ * @hbClient macos none
1300
+ */
1301
+ /**
1302
+ * 首发公开 GameId(冻结顺序)。
1303
+ *
1304
+ * @since 0.9.6
1305
+ */
1306
+ const USER_GAME_DATA_GAMES = {
1307
+ ark: '明日方舟',
1308
+ black_myth_wukong: '黑神话悟空',
1309
+ task_bar_hero: '任务栏英雄',
1310
+ phantom_blade_zero: '影之刃零',
1311
+ };
1312
+ const USER_GAME_DATA_GAME_IDS = Object.keys(USER_GAME_DATA_GAMES);
1313
+ /**
1314
+ * 首发 8 项资源的公开目录。
1315
+ *
1316
+ * @remarks
1317
+ * - `ark` 与 `ark_lottery` 映射到同一游戏的 profile / gacha 两项资源,**来源资格不合并**。
1318
+ * - 明日方舟不提供 `saves`;三款存档不提供 profile / gacha 方法。
1319
+ * - 存档资源的 Steam AppID 与 `gamesaves.Client.Parsed` 的分支冻结一致:2358720、
1320
+ * 3678970、4115450。原始文件支持不等于已支持结构化解析,两个资源分别声明与许可。
1321
+ *
1322
+ * @since 0.9.6
1323
+ * @hbPlatform android
1324
+ * @hbPlatform ios
1325
+ * @hbPlatform ohos
1326
+ * @hbPlatform windows
1327
+ * @hbPlatform macos
1328
+ * @hbClient android none
1329
+ * @hbClient ios none
1330
+ * @hbClient ohos none
1331
+ * @hbClient windows none
1332
+ * @hbClient macos none
1333
+ */
1334
+ const GAME_DATA_RESOURCE_CATALOG = [
1335
+ {
1336
+ key: 'game.ark.profile',
1337
+ game: 'ark',
1338
+ family: 'profile',
1339
+ name: '明日方舟角色与养成资料',
1340
+ disclosureRevision: 1,
1341
+ queries: { get: { schema: 'ark.profile', version: 1 } },
1342
+ sync: false,
1343
+ file: false,
1344
+ },
1345
+ {
1346
+ key: 'game.ark.gacha',
1347
+ game: 'ark',
1348
+ family: 'gacha',
1349
+ name: '明日方舟抽卡记录与分析',
1350
+ disclosureRevision: 1,
1351
+ queries: {
1352
+ get: { schema: 'ark.gacha-analysis', version: 1 },
1353
+ list: { schema: 'ark.gacha-record-page', version: 1, page: { defaultSize: 50, maxSize: 100 } },
1354
+ },
1355
+ sync: false,
1356
+ file: false,
1357
+ },
1358
+ {
1359
+ key: 'game.black_myth_wukong.save_analysis',
1360
+ game: 'black_myth_wukong',
1361
+ family: 'save_analysis',
1362
+ name: '黑神话悟空存档解析结果',
1363
+ disclosureRevision: 1,
1364
+ queries: { get: { schema: 'black_myth_wukong.save', version: 1 } },
1365
+ sync: true,
1366
+ file: false,
1367
+ },
1368
+ {
1369
+ key: 'game.black_myth_wukong.save_files',
1370
+ game: 'black_myth_wukong',
1371
+ family: 'save_files',
1372
+ name: '黑神话悟空云存档文件',
1373
+ disclosureRevision: 1,
1374
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1375
+ sync: true,
1376
+ file: true,
1377
+ },
1378
+ {
1379
+ key: 'game.task_bar_hero.save_analysis',
1380
+ game: 'task_bar_hero',
1381
+ family: 'save_analysis',
1382
+ name: '任务栏英雄存档解析结果',
1383
+ disclosureRevision: 1,
1384
+ queries: { get: { schema: 'task_bar_hero.save', version: 1 } },
1385
+ sync: true,
1386
+ file: false,
1387
+ },
1388
+ {
1389
+ key: 'game.task_bar_hero.save_files',
1390
+ game: 'task_bar_hero',
1391
+ family: 'save_files',
1392
+ name: '任务栏英雄云存档文件',
1393
+ disclosureRevision: 1,
1394
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1395
+ sync: true,
1396
+ file: true,
1397
+ },
1398
+ {
1399
+ key: 'game.phantom_blade_zero.save_analysis',
1400
+ game: 'phantom_blade_zero',
1401
+ family: 'save_analysis',
1402
+ name: '影之刃零存档解析结果',
1403
+ disclosureRevision: 1,
1404
+ queries: { get: { schema: 'phantom_blade_zero.save', version: 1 } },
1405
+ sync: true,
1406
+ file: false,
1407
+ },
1408
+ {
1409
+ key: 'game.phantom_blade_zero.save_files',
1410
+ game: 'phantom_blade_zero',
1411
+ family: 'save_files',
1412
+ name: '影之刃零云存档文件',
1413
+ disclosureRevision: 1,
1414
+ queries: { list: { schema: 'save-file-page', version: 1 } },
1415
+ sync: true,
1416
+ file: true,
1417
+ },
1418
+ ];
1419
+ const USER_GAME_DATA_RESOURCE_KEYS = GAME_DATA_RESOURCE_CATALOG.map((resource) => resource.key);
1420
+ const RESOURCE_KEY_SET = new Set(USER_GAME_DATA_RESOURCE_KEYS);
1421
+ const GAME_ID_SET = new Set(USER_GAME_DATA_GAME_IDS);
1422
+ /**
1423
+ * 判断字符串是否为已发布的精确资源 key。
1424
+ *
1425
+ * @param key - 候选字符串;来自 `unknown` 边界时调用方必须先完成字符串检查。
1426
+ * @returns 与 {@link USER_GAME_DATA_RESOURCE_KEYS} 中某项精确相等时返回 `true` 并收窄类型。
1427
+ *
1428
+ * @remarks
1429
+ * 匹配大小写敏感且不做 trim 之外的归一化:`'*'`、`'game.ark'`、`'game.ark.gacha.*'` 等
1430
+ * 通配符或前缀一律返回 `false`。返回 `true` 只表示该 key 已登记在公开目录,不代表当前小程序
1431
+ * 已声明、平台已批准或用户已许可;这些门禁必须分别校验。
1432
+ *
1433
+ * @example
1434
+ * ```ts
1435
+ * isUserGameDataResourceKey('game.ark.profile'); // true
1436
+ * isUserGameDataResourceKey('game.ark'); // false:前缀不是资源
1437
+ * isUserGameDataResourceKey('game.ark.*'); // false:禁止通配符
1438
+ * ```
1439
+ *
1440
+ * @since 0.9.6
1441
+ * @hbPlatform android
1442
+ * @hbPlatform ios
1443
+ * @hbPlatform ohos
1444
+ * @hbPlatform windows
1445
+ * @hbPlatform macos
1446
+ * @hbClient android none
1447
+ * @hbClient ios none
1448
+ * @hbClient ohos none
1449
+ * @hbClient windows none
1450
+ * @hbClient macos none
1451
+ */
1452
+ function isUserGameDataResourceKey(key) {
1453
+ return RESOURCE_KEY_SET.has(key);
1454
+ }
1455
+ /**
1456
+ * 判断字符串是否为已发布的公开 GameId。
1457
+ *
1458
+ * @since 0.9.6
1459
+ */
1460
+ function isUserGameDataGameId(gameId) {
1461
+ return GAME_ID_SET.has(gameId);
1462
+ }
1463
+ /** 从同一目录派生内部操作,不维护第二套游戏白名单。 */
1464
+ function getUserDataResourceContract(key) {
1465
+ const resource = GAME_DATA_RESOURCE_CATALOG.find((entry) => entry.key === key);
1466
+ if (!resource)
1467
+ return undefined;
1468
+ const queries = resource.queries;
1469
+ const operations = Object.keys(queries);
1470
+ if (resource.sync)
1471
+ operations.push('sync');
1472
+ if (resource.file)
1473
+ operations.push('file');
1474
+ return {
1475
+ key: resource.key,
1476
+ game: resource.game,
1477
+ name: resource.name,
1478
+ family: resource.family,
1479
+ disclosureRevision: resource.disclosureRevision,
1480
+ queries,
1481
+ operations,
1482
+ };
1483
+ }
1484
+
1264
1485
  const MINI_PROGRAM_PERMISSION_KEYS = [
1265
1486
  'userInfo',
1266
1487
  'steamLibrary',
@@ -1276,6 +1497,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
1276
1497
  'companion',
1277
1498
  'appProtocol',
1278
1499
  'workspaceCards',
1500
+ 'user_game_data',
1279
1501
  ];
1280
1502
  new Set(MINI_PROGRAM_PERMISSION_KEYS);
1281
1503
 
@@ -1898,6 +2120,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
1898
2120
  }
1899
2121
  return result.value;
1900
2122
  };
2123
+ const parse$1 = /* @__PURE__*/ _parse($ZodRealError);
1901
2124
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1902
2125
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
1903
2126
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -1910,6 +2133,7 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1910
2133
  }
1911
2134
  return result.value;
1912
2135
  };
2136
+ const parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
1913
2137
  const _safeParse = (_Err) => (schema, value, _ctx) => {
1914
2138
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
1915
2139
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -2036,14 +2260,14 @@ function datetime$1(args) {
2036
2260
  const timeRegex = `${time}(?:${opts.join("|")})`;
2037
2261
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
2038
2262
  }
2039
- const string$1 = (params) => {
2263
+ const string$2 = (params) => {
2040
2264
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
2041
2265
  return new RegExp(`^${regex}$`);
2042
2266
  };
2043
2267
  const integer = /^-?\d+$/;
2044
- const number$1 = /^-?\d+(?:\.\d+)?$/;
2268
+ const number$2 = /^-?\d+(?:\.\d+)?$/;
2045
2269
  const boolean$1 = /^(?:true|false)$/i;
2046
- const _null$2 = /^null$/i;
2270
+ const _null$3 = /^null$/i;
2047
2271
  // regex for string with no uppercase letters
2048
2272
  const lowercase = /^[^A-Z]*$/;
2049
2273
  // regex for string with no lowercase letters
@@ -2629,7 +2853,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
2629
2853
  });
2630
2854
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
2631
2855
  $ZodType.init(inst, def);
2632
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$1(inst._zod.bag);
2856
+ inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$2(inst._zod.bag);
2633
2857
  inst._zod.parse = (payload, _) => {
2634
2858
  if (def.coerce)
2635
2859
  try {
@@ -2964,7 +3188,7 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
2964
3188
  });
2965
3189
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
2966
3190
  $ZodType.init(inst, def);
2967
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
3191
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
2968
3192
  inst._zod.parse = (payload, _ctx) => {
2969
3193
  if (def.coerce)
2970
3194
  try {
@@ -3019,7 +3243,7 @@ const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
3019
3243
  });
3020
3244
  const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
3021
3245
  $ZodType.init(inst, def);
3022
- inst._zod.pattern = _null$2;
3246
+ inst._zod.pattern = _null$3;
3023
3247
  inst._zod.values = new Set([null]);
3024
3248
  inst._zod.parse = (payload, _ctx) => {
3025
3249
  const input = payload.value;
@@ -3703,7 +3927,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
3703
3927
  }
3704
3928
  // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
3705
3929
  // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
3706
- const checkNumericKey = typeof key === "string" && number$1.test(key) && keyResult.issues.length;
3930
+ const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length;
3707
3931
  if (checkNumericKey) {
3708
3932
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
3709
3933
  if (retryResult instanceof Promise) {
@@ -4452,7 +4676,7 @@ function _boolean(Class, params) {
4452
4676
  });
4453
4677
  }
4454
4678
  // @__NO_SIDE_EFFECTS__
4455
- function _null$1(Class, params) {
4679
+ function _null$2(Class, params) {
4456
4680
  return new Class({
4457
4681
  type: "null",
4458
4682
  ...normalizeParams(params),
@@ -5703,7 +5927,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5703
5927
  return this.check(_overwrite(fn));
5704
5928
  },
5705
5929
  optional() {
5706
- return optional(this);
5930
+ return optional$1(this);
5707
5931
  },
5708
5932
  exactOptional() {
5709
5933
  return exactOptional(this);
@@ -5712,16 +5936,16 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5712
5936
  return nullable(this);
5713
5937
  },
5714
5938
  nullish() {
5715
- return optional(nullable(this));
5939
+ return optional$1(nullable(this));
5716
5940
  },
5717
5941
  nonoptional(params) {
5718
5942
  return nonoptional(this, params);
5719
5943
  },
5720
5944
  array() {
5721
- return array(this);
5945
+ return array$1(this);
5722
5946
  },
5723
5947
  or(arg) {
5724
- return union([this, arg]);
5948
+ return union$1([this, arg]);
5725
5949
  },
5726
5950
  and(arg) {
5727
5951
  return intersection(this, arg);
@@ -5867,7 +6091,7 @@ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
5867
6091
  inst.time = (params) => inst.check(time(params));
5868
6092
  inst.duration = (params) => inst.check(duration(params));
5869
6093
  });
5870
- function string(params) {
6094
+ function string$1(params) {
5871
6095
  return _string(ZodString, params);
5872
6096
  }
5873
6097
  const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
@@ -5996,10 +6220,10 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
5996
6220
  return this.check(_lte(value, params));
5997
6221
  },
5998
6222
  int(params) {
5999
- return this.check(int(params));
6223
+ return this.check(int$1(params));
6000
6224
  },
6001
6225
  safe(params) {
6002
- return this.check(int(params));
6226
+ return this.check(int$1(params));
6003
6227
  },
6004
6228
  positive(params) {
6005
6229
  return this.check(_gt(0, params));
@@ -6032,14 +6256,14 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
6032
6256
  inst.isFinite = true;
6033
6257
  inst.format = bag.format ?? null;
6034
6258
  });
6035
- function number(params) {
6259
+ function number$1(params) {
6036
6260
  return _number(ZodNumber, params);
6037
6261
  }
6038
6262
  const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
6039
6263
  $ZodNumberFormat.init(inst, def);
6040
6264
  ZodNumber.init(inst, def);
6041
6265
  });
6042
- function int(params) {
6266
+ function int$1(params) {
6043
6267
  return _int(ZodNumberFormat, params);
6044
6268
  }
6045
6269
  const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
@@ -6055,8 +6279,8 @@ const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
6055
6279
  ZodType.init(inst, def);
6056
6280
  inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json);
6057
6281
  });
6058
- function _null(params) {
6059
- return _null$1(ZodNull, params);
6282
+ function _null$1(params) {
6283
+ return _null$2(ZodNull, params);
6060
6284
  }
6061
6285
  const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
6062
6286
  $ZodUnknown.init(inst, def);
@@ -6071,7 +6295,7 @@ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
6071
6295
  ZodType.init(inst, def);
6072
6296
  inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
6073
6297
  });
6074
- function never(params) {
6298
+ function never$1(params) {
6075
6299
  return _never(ZodNever, params);
6076
6300
  }
6077
6301
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
@@ -6097,7 +6321,7 @@ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
6097
6321
  },
6098
6322
  });
6099
6323
  });
6100
- function array(element, params) {
6324
+ function array$1(element, params) {
6101
6325
  return _array(ZodArray, element, params);
6102
6326
  }
6103
6327
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
@@ -6121,7 +6345,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
6121
6345
  return this.clone({ ...this._zod.def, catchall: unknown() });
6122
6346
  },
6123
6347
  strict() {
6124
- return this.clone({ ...this._zod.def, catchall: never() });
6348
+ return this.clone({ ...this._zod.def, catchall: never$1() });
6125
6349
  },
6126
6350
  strip() {
6127
6351
  return this.clone({ ...this._zod.def, catchall: undefined });
@@ -6172,7 +6396,7 @@ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
6172
6396
  inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
6173
6397
  inst.options = def.options;
6174
6398
  });
6175
- function union(options, params) {
6399
+ function union$1(options, params) {
6176
6400
  return new ZodUnion({
6177
6401
  type: "union",
6178
6402
  options: options,
@@ -6216,7 +6440,7 @@ function record$1(keyType, valueType, params) {
6216
6440
  if (!valueType || !valueType._zod) {
6217
6441
  return new ZodRecord({
6218
6442
  type: "record",
6219
- keyType: string(),
6443
+ keyType: string$1(),
6220
6444
  valueType: keyType,
6221
6445
  ...normalizeParams(valueType),
6222
6446
  });
@@ -6290,7 +6514,7 @@ const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
6290
6514
  },
6291
6515
  });
6292
6516
  });
6293
- function literal(value, params) {
6517
+ function literal$1(value, params) {
6294
6518
  return new ZodLiteral({
6295
6519
  type: "literal",
6296
6520
  values: Array.isArray(value) ? value : [value],
@@ -6346,7 +6570,7 @@ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
6346
6570
  inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
6347
6571
  inst.unwrap = () => inst._zod.def.innerType;
6348
6572
  });
6349
- function optional(innerType) {
6573
+ function optional$1(innerType) {
6350
6574
  return new ZodOptional({
6351
6575
  type: "optional",
6352
6576
  innerType: innerType,
@@ -6487,7 +6711,7 @@ function superRefine(fn, params) {
6487
6711
  }
6488
6712
  function json(params) {
6489
6713
  const jsonSchema = lazy(() => {
6490
- return union([string(params), number(), boolean(), _null(), array(jsonSchema), record$1(string(), jsonSchema)]);
6714
+ return union$1([string$1(params), number$1(), boolean(), _null$1(), array$1(jsonSchema), record$1(string$1(), jsonSchema)]);
6491
6715
  });
6492
6716
  return jsonSchema;
6493
6717
  }
@@ -6560,7 +6784,7 @@ var viewElevationSchema = _enum(["flat", "raised"]);
6560
6784
  var viewWidthSchema = _enum(["auto", "fill"]);
6561
6785
  var viewBoxSizeSchema = _enum(["md", "hero"]);
6562
6786
  var viewHeightSchema = _enum(["data-tile"]);
6563
- var viewGridColumnsSchema = union([literal(2), literal(3), literal(4)]);
6787
+ var viewGridColumnsSchema = union$1([literal$1(2), literal$1(3), literal$1(4)]);
6564
6788
  var viewTextVariantSchema = _enum([
6565
6789
  "display",
6566
6790
  "title",
@@ -6605,7 +6829,7 @@ var viewImageSizeSchema = _enum([
6605
6829
  "landscape-compact",
6606
6830
  "landscape-content"
6607
6831
  ]);
6608
- var viewIconSizeSchema = union([literal(16), literal(20), literal(24)]);
6832
+ var viewIconSizeSchema = union$1([literal$1(16), literal$1(20), literal$1(24)]);
6609
6833
  var viewIconColorSchema = _enum([
6610
6834
  "default",
6611
6835
  "secondary",
@@ -6625,28 +6849,28 @@ var viewImageOverlaySchema = _enum([
6625
6849
  var viewListVariantSchema = _enum(["media", "plain", "compact"]);
6626
6850
  var viewCarouselPaginationSchema = _enum(["none", "bullets", "fraction"]);
6627
6851
  var viewCarouselPaginationPlacementSchema = _enum(["inside", "outside"]);
6628
- var viewCarouselSlidesPerViewSchema = union([literal(1), literal(2), literal(3)]);
6852
+ var viewCarouselSlidesPerViewSchema = union$1([literal$1(1), literal$1(2), literal$1(3)]);
6629
6853
  var viewTransitionEffectSchema = _enum(["crossfade", "morph"]);
6630
6854
  var viewTransitionSchema = object({
6631
6855
  /** 新旧内容仅交叉淡化,或同时执行轻量位移与缩放变换。 */
6632
6856
  effect: viewTransitionEffectSchema
6633
6857
  });
6634
- var nodeIdSchema = string().trim().min(1).max(120);
6858
+ var nodeIdSchema = string$1().trim().min(1).max(120);
6635
6859
  var viewActionSchema = object({
6636
6860
  /** 完整 Command id。 */
6637
- commandId: string().trim().min(1).max(120),
6861
+ commandId: string$1().trim().min(1).max(120),
6638
6862
  /** Command 的 JSON 输入。 */
6639
6863
  input: json().optional(),
6640
6864
  /** 提交时并入 `input` 的用户输入绑定;键是 input 字段名,值是 `textField` 节点 id。 */
6641
- inputFrom: record$1(string().trim().min(1).max(40), nodeIdSchema).refine((value) => Object.keys(value).length <= VIEW_BUDGET.maxActionInputBindings, {
6865
+ inputFrom: record$1(string$1().trim().min(1).max(40), nodeIdSchema).refine((value) => Object.keys(value).length <= VIEW_BUDGET.maxActionInputBindings, {
6642
6866
  error: "\u5355\u4E2A\u52A8\u4F5C\u7ED1\u5B9A\u7684\u8F93\u5165\u5B57\u6BB5\u8FC7\u591A"
6643
6867
  }).optional()
6644
6868
  });
6645
- var textValueSchema = string().max(VIEW_BUDGET.maxTextLength);
6646
- var shortTextSchema = string().trim().min(1).max(200);
6869
+ var textValueSchema = string$1().max(VIEW_BUDGET.maxTextLength);
6870
+ var shortTextSchema = string$1().trim().min(1).max(200);
6647
6871
  var viewMeterSegmentSchema = object({
6648
6872
  /** 该数据段占整个容量的比例,值域 (0,1]。 */
6649
- value: number().positive().max(1),
6873
+ value: number$1().positive().max(1),
6650
6874
  /** 数据段的可访问说明。 */
6651
6875
  label: shortTextSchema,
6652
6876
  /** 数据段语气;缺省使用宿主上下文强调色。 */
@@ -6654,37 +6878,37 @@ var viewMeterSegmentSchema = object({
6654
6878
  });
6655
6879
  var viewBarChartItemSchema = object({
6656
6880
  /** 分类标签,例如星期“一”。 */
6657
- label: string().trim().min(1).max(20),
6881
+ label: string$1().trim().min(1).max(20),
6658
6882
  /** 非负原始值;宿主只按同组最大值归一化,不改变数据口径。 */
6659
- value: number().finite().nonnegative(),
6883
+ value: number$1().finite().nonnegative(),
6660
6884
  /** 精确值文本,例如“2 小时 30 分”。 */
6661
- valueLabel: string().trim().min(1).max(80).optional()
6885
+ valueLabel: string$1().trim().min(1).max(80).optional()
6662
6886
  });
6663
6887
  var viewTextSpanSchema = object({
6664
6888
  /** 片段文本;全部片段拼接后必须与所属节点的 `value` 完全一致。 */
6665
- text: string().min(1).max(VIEW_BUDGET.maxTextLength),
6889
+ text: string$1().min(1).max(VIEW_BUDGET.maxTextLength),
6666
6890
  /** 叠加在该片段上的语义标记;缺省即为普通文本。 */
6667
- marks: array(viewTextMarkSchema).max(4).optional()
6891
+ marks: array$1(viewTextMarkSchema).max(4).optional()
6668
6892
  });
6669
6893
  var viewImageFallbackSchema = object({
6670
6894
  /** 缺图时复用宿主当前应用的缓存模糊背景;不请求远程资源,缺省沿用图标或文本回退。 */
6671
- source: literal("app-ambient").optional(),
6895
+ source: literal$1("app-ambient").optional(),
6672
6896
  /** 回退图标名;宿主无法识别时退回文本。 */
6673
- icon: string().trim().min(1).max(80).optional(),
6897
+ icon: string$1().trim().min(1).max(80).optional(),
6674
6898
  /** 回退文本。 */
6675
- text: string().trim().max(120).optional()
6899
+ text: string$1().trim().max(120).optional()
6676
6900
  });
6677
6901
  var viewFieldItemSchema = object({
6678
6902
  label: shortTextSchema,
6679
- value: string().max(400).optional(),
6680
- placeholder: string().trim().max(120).optional()
6903
+ value: string$1().max(400).optional(),
6904
+ placeholder: string$1().trim().max(120).optional()
6681
6905
  });
6682
6906
  var viewListItemActionSchema = object({
6683
6907
  text: shortTextSchema,
6684
6908
  variant: viewButtonVariantSchema.optional(),
6685
6909
  tone: viewToneSchema.optional(),
6686
6910
  disabled: boolean().optional(),
6687
- disabledReason: string().trim().max(200).optional(),
6911
+ disabledReason: string$1().trim().max(200).optional(),
6688
6912
  action: viewActionSchema.optional()
6689
6913
  });
6690
6914
  var viewListItemBadgeSchema = object({
@@ -6694,9 +6918,9 @@ var viewListItemBadgeSchema = object({
6694
6918
  var viewListItemSchema = object({
6695
6919
  id: nodeIdSchema,
6696
6920
  title: shortTextSchema,
6697
- subtitle: string().trim().max(400).optional(),
6698
- meta: string().trim().max(120).optional(),
6699
- image: string().trim().max(2e3).optional(),
6921
+ subtitle: string$1().trim().max(400).optional(),
6922
+ meta: string$1().trim().max(120).optional(),
6923
+ image: string$1().trim().max(2e3).optional(),
6700
6924
  imageFallback: viewImageFallbackSchema.optional(),
6701
6925
  /** 媒体位外形;缺省保持历史横向缩略图。 */
6702
6926
  imageShape: viewListItemImageShapeSchema.optional(),
@@ -6707,7 +6931,7 @@ var viewListItemSchema = object({
6707
6931
  /** 列表图片是否以颜色传达业务含义;不影响卡片主次下的原色显示。 */
6708
6932
  imageColorRole: viewImageColorRoleSchema.optional(),
6709
6933
  /** 行首图标名;宿主不认识该名称时不渲染图标位。 */
6710
- icon: string().trim().min(1).max(80).optional(),
6934
+ icon: string$1().trim().min(1).max(80).optional(),
6711
6935
  /** 条目整体语气;作用于标题与行首图标。 */
6712
6936
  tone: viewToneSchema.optional(),
6713
6937
  /** 行尾状态标记;与 `meta` 并存时标记在前。 */
@@ -6717,7 +6941,7 @@ var viewListItemSchema = object({
6717
6941
  /** 当前不可激活。 */
6718
6942
  disabled: boolean().optional(),
6719
6943
  /** 不可激活的可读原因。 */
6720
- disabledReason: string().trim().max(200).optional(),
6944
+ disabledReason: string$1().trim().max(200).optional(),
6721
6945
  action: viewActionSchema.optional(),
6722
6946
  /** 行尾次级动作;宿主把它渲染成与整行动作并列的独立按钮。 */
6723
6947
  secondaryAction: viewListItemActionSchema.optional()
@@ -6725,7 +6949,7 @@ var viewListItemSchema = object({
6725
6949
  var viewRegionNoticeSchema = object({
6726
6950
  /** 稳定键;用户关闭后按该键记住,换一条提示会重新出现。 */
6727
6951
  id: nodeIdSchema,
6728
- text: string().trim().min(1).max(200),
6952
+ text: string$1().trim().min(1).max(200),
6729
6953
  tone: viewToneSchema.optional(),
6730
6954
  /** 是否允许用户关闭;关闭状态属于宿主自持呈现状态。 */
6731
6955
  dismissible: boolean().optional()
@@ -6801,18 +7025,18 @@ var layoutShape = {
6801
7025
  var boxShape = {
6802
7026
  ...layoutShape,
6803
7027
  action: viewActionSchema.optional(),
6804
- accessibilityLabel: string().min(1).max(80).optional(),
7028
+ accessibilityLabel: string$1().min(1).max(80).optional(),
6805
7029
  interaction: _enum(["soft", "media", "text", "content"]).optional()
6806
7030
  };
6807
7031
  var meterNodeSchema = object({
6808
7032
  ...baseNodeShape,
6809
- type: literal("meter"),
7033
+ type: literal$1("meter"),
6810
7034
  /** 比例值,值域 [0,1];超出值域是插件缺陷,按 schema 错误稳定失败。 */
6811
- value: number().min(0).max(1),
7035
+ value: number$1().min(0).max(1),
6812
7036
  /** 可访问名称;缺省时由宿主以百分比文本兜底。 */
6813
7037
  label: shortTextSchema.optional(),
6814
7038
  tone: viewToneSchema.optional(),
6815
- segments: array(viewMeterSegmentSchema).min(1).max(8).optional(),
7039
+ segments: array$1(viewMeterSegmentSchema).min(1).max(8).optional(),
6816
7040
  size: viewMeterSizeSchema.optional(),
6817
7041
  ticks: boolean().optional()
6818
7042
  }).refine(
@@ -6826,31 +7050,31 @@ var knownNodeSchema = lazy(
6826
7050
  () => discriminatedUnion("type", [
6827
7051
  object({
6828
7052
  ...boxShape,
6829
- type: literal("vstack"),
6830
- children: array(viewNodeSchema)
7053
+ type: literal$1("vstack"),
7054
+ children: array$1(viewNodeSchema)
6831
7055
  }),
6832
7056
  object({
6833
7057
  ...boxShape,
6834
- type: literal("hstack"),
7058
+ type: literal$1("hstack"),
6835
7059
  wrap: boolean().optional(),
6836
- children: array(viewNodeSchema)
7060
+ children: array$1(viewNodeSchema)
6837
7061
  }),
6838
7062
  object({
6839
7063
  ...boxShape,
6840
- type: literal("zstack"),
6841
- children: array(viewNodeSchema)
7064
+ type: literal$1("zstack"),
7065
+ children: array$1(viewNodeSchema)
6842
7066
  }),
6843
7067
  object({
6844
7068
  ...boxShape,
6845
- type: literal("grid"),
7069
+ type: literal$1("grid"),
6846
7070
  columns: viewGridColumnsSchema,
6847
- children: array(viewNodeSchema)
7071
+ children: array$1(viewNodeSchema)
6848
7072
  }),
6849
7073
  object({
6850
7074
  id: nodeIdSchema,
6851
- type: literal("carousel"),
7075
+ type: literal$1("carousel"),
6852
7076
  label: shortTextSchema,
6853
- children: array(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
7077
+ children: array$1(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
6854
7078
  fallback: viewNodeSchema.optional(),
6855
7079
  slidesPerView: viewCarouselSlidesPerViewSchema.optional(),
6856
7080
  gap: viewGapSchema.optional(),
@@ -6859,36 +7083,36 @@ var knownNodeSchema = lazy(
6859
7083
  navigation: boolean().optional(),
6860
7084
  pagination: viewCarouselPaginationSchema.optional(),
6861
7085
  paginationPlacement: viewCarouselPaginationPlacementSchema.optional(),
6862
- autoplayDelay: number().int().min(2e3).max(3e4).optional()
7086
+ autoplayDelay: number$1().int().min(2e3).max(3e4).optional()
6863
7087
  }),
6864
7088
  object({
6865
7089
  ...layoutShape,
6866
- type: literal("group"),
7090
+ type: literal$1("group"),
6867
7091
  title: shortTextSchema.optional(),
6868
7092
  collapsible: boolean().optional(),
6869
7093
  defaultExpanded: boolean().optional(),
6870
7094
  stickyTitle: boolean().optional(),
6871
- children: array(viewNodeSchema)
7095
+ children: array$1(viewNodeSchema)
6872
7096
  }),
6873
- object({ ...baseNodeShape, type: literal("spacer") }),
7097
+ object({ ...baseNodeShape, type: literal$1("spacer") }),
6874
7098
  object({
6875
7099
  ...baseNodeShape,
6876
- type: literal("text"),
7100
+ type: literal$1("text"),
6877
7101
  value: textValueSchema,
6878
- spans: array(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
7102
+ spans: array$1(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
6879
7103
  variant: viewTextVariantSchema.optional(),
6880
7104
  weight: viewTextWeightSchema.optional(),
6881
7105
  tone: viewTextToneSchema.optional(),
6882
7106
  paint: viewTextPaintSchema.optional(),
6883
- maxLines: number().int().positive().max(50).optional(),
7107
+ maxLines: number$1().int().positive().max(50).optional(),
6884
7108
  reserveLines: boolean().optional()
6885
7109
  }),
6886
7110
  object({
6887
7111
  ...baseNodeShape,
6888
- type: literal("image"),
7112
+ type: literal$1("image"),
6889
7113
  /** 图片资源地址;无原图且声明 app-ambient 回退时,用 app-ambient://current 直接选择宿主缓存。 */
6890
- src: string().trim().min(1).max(2e3),
6891
- aspectRatio: string().trim().max(20).optional(),
7114
+ src: string$1().trim().min(1).max(2e3),
7115
+ aspectRatio: string$1().trim().max(20).optional(),
6892
7116
  size: viewImageSizeSchema.optional(),
6893
7117
  fit: viewImageFitSchema.optional(),
6894
7118
  appearance: viewImageAppearanceSchema.optional(),
@@ -6899,34 +7123,34 @@ var knownNodeSchema = lazy(
6899
7123
  }),
6900
7124
  object({
6901
7125
  ...baseNodeShape,
6902
- type: literal("icon"),
6903
- name: string().trim().min(1).max(80),
7126
+ type: literal$1("icon"),
7127
+ name: string$1().trim().min(1).max(80),
6904
7128
  size: viewIconSizeSchema.optional(),
6905
7129
  color: viewIconColorSchema.optional(),
6906
7130
  tone: viewToneSchema.optional()
6907
7131
  }),
6908
7132
  object({
6909
7133
  ...baseNodeShape,
6910
- type: literal("fields"),
6911
- items: array(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
7134
+ type: literal$1("fields"),
7135
+ items: array$1(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
6912
7136
  }),
6913
7137
  object({
6914
7138
  ...baseNodeShape,
6915
- type: literal("list"),
7139
+ type: literal$1("list"),
6916
7140
  variant: viewListVariantSchema.optional(),
6917
- initialCount: number().int().positive().max(VIEW_BUDGET.maxListItems).optional(),
6918
- items: array(viewListItemSchema).max(VIEW_BUDGET.maxListItems)
7141
+ initialCount: number$1().int().positive().max(VIEW_BUDGET.maxListItems).optional(),
7142
+ items: array$1(viewListItemSchema).max(VIEW_BUDGET.maxListItems)
6919
7143
  }),
6920
7144
  object({
6921
7145
  ...baseNodeShape,
6922
- type: literal("badge"),
7146
+ type: literal$1("badge"),
6923
7147
  text: shortTextSchema,
6924
7148
  tone: _enum([...viewToneSchema.options, "primary", "primary-media"]).optional()
6925
7149
  }),
6926
- object({ ...baseNodeShape, type: literal("divider") }),
7150
+ object({ ...baseNodeShape, type: literal$1("divider") }),
6927
7151
  object({
6928
7152
  ...baseNodeShape,
6929
- type: literal("button"),
7153
+ type: literal$1("button"),
6930
7154
  text: shortTextSchema,
6931
7155
  variant: viewButtonVariantSchema.optional(),
6932
7156
  /**
@@ -6935,56 +7159,56 @@ var knownNodeSchema = lazy(
6935
7159
  */
6936
7160
  tone: viewToneSchema.optional(),
6937
7161
  disabled: boolean().optional(),
6938
- disabledReason: string().trim().max(200).optional(),
7162
+ disabledReason: string$1().trim().max(200).optional(),
6939
7163
  busy: boolean().optional(),
6940
7164
  action: viewActionSchema.optional()
6941
7165
  }),
6942
7166
  object({
6943
7167
  id: nodeIdSchema,
6944
- type: literal("switch"),
7168
+ type: literal$1("switch"),
6945
7169
  label: shortTextSchema,
6946
7170
  checked: boolean(),
6947
7171
  disabled: boolean().optional(),
6948
- disabledReason: string().trim().max(200).optional(),
7172
+ disabledReason: string$1().trim().max(200).optional(),
6949
7173
  busy: boolean().optional(),
6950
7174
  action: viewActionSchema.optional(),
6951
7175
  fallback: viewNodeSchema.optional()
6952
7176
  }),
6953
7177
  object({
6954
7178
  id: nodeIdSchema,
6955
- type: literal("expandable"),
6956
- collapsedLines: number().int().positive().max(50),
7179
+ type: literal$1("expandable"),
7180
+ collapsedLines: number$1().int().positive().max(50),
6957
7181
  expandText: shortTextSchema,
6958
7182
  collapseText: shortTextSchema,
6959
- children: array(viewNodeSchema)
7183
+ children: array$1(viewNodeSchema)
6960
7184
  }),
6961
7185
  object({
6962
7186
  id: nodeIdSchema,
6963
- type: literal("renderer"),
6964
- rendererViewId: string().trim().min(1).max(120),
7187
+ type: literal$1("renderer"),
7188
+ rendererViewId: string$1().trim().min(1).max(120),
6965
7189
  content: object({
6966
- resourceKey: string().trim().min(1).max(512),
7190
+ resourceKey: string$1().trim().min(1).max(512),
6967
7191
  space: _enum(["instance", "shared"]).optional()
6968
7192
  }).optional(),
6969
- aspectRatio: string().trim().max(20).optional(),
6970
- height: number().int().positive().max(2e3).optional()
7193
+ aspectRatio: string$1().trim().max(20).optional(),
7194
+ height: number$1().int().positive().max(2e3).optional()
6971
7195
  }),
6972
7196
  object({
6973
7197
  id: nodeIdSchema,
6974
- type: literal("frame"),
6975
- frameId: string().trim().min(1).max(120),
6976
- key: string().min(1).max(200).optional(),
7198
+ type: literal$1("frame"),
7199
+ frameId: string$1().trim().min(1).max(120),
7200
+ key: string$1().min(1).max(200).optional(),
6977
7201
  params: viewFrameParamsSchema.optional(),
6978
- aspectRatio: string().trim().max(20).optional(),
6979
- height: number().int().positive().max(2e3).optional()
7202
+ aspectRatio: string$1().trim().max(20).optional(),
7203
+ height: number$1().int().positive().max(2e3).optional()
6980
7204
  }),
6981
7205
  meterNodeSchema,
6982
7206
  object({
6983
7207
  ...baseNodeShape,
6984
- type: literal("radialProgress"),
6985
- value: number().min(0).max(1),
7208
+ type: literal$1("radialProgress"),
7209
+ value: number$1().min(0).max(1),
6986
7210
  label: shortTextSchema,
6987
- valueLabel: string().trim().min(1).max(40).optional(),
7211
+ valueLabel: string$1().trim().min(1).max(40).optional(),
6988
7212
  centerGraphic: viewRadialProgressCenterGraphicSchema.optional(),
6989
7213
  size: viewRadialProgressSizeSchema.optional(),
6990
7214
  tone: viewToneSchema.optional(),
@@ -6992,17 +7216,17 @@ var knownNodeSchema = lazy(
6992
7216
  }),
6993
7217
  object({
6994
7218
  ...baseNodeShape,
6995
- type: literal("sparkline"),
7219
+ type: literal$1("sparkline"),
6996
7220
  /** 原始数值序列,宿主归一化绘制;少于 2 个点不构成趋势,由 schema 拒绝。 */
6997
- values: array(number()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
7221
+ values: array$1(number$1()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
6998
7222
  /** 可访问名称;缺省时由宿主以末值文本兜底。 */
6999
7223
  label: shortTextSchema.optional(),
7000
7224
  tone: viewToneSchema.optional()
7001
7225
  }),
7002
7226
  object({
7003
7227
  ...baseNodeShape,
7004
- type: literal("barChart"),
7005
- items: array(viewBarChartItemSchema).min(2).max(VIEW_BUDGET.maxBarChartItems),
7228
+ type: literal$1("barChart"),
7229
+ items: array$1(viewBarChartItemSchema).min(2).max(VIEW_BUDGET.maxBarChartItems),
7006
7230
  label: shortTextSchema,
7007
7231
  size: viewBarChartSizeSchema.optional(),
7008
7232
  tone: viewToneSchema.optional(),
@@ -7010,27 +7234,27 @@ var knownNodeSchema = lazy(
7010
7234
  }),
7011
7235
  object({
7012
7236
  id: nodeIdSchema,
7013
- type: literal("tabs"),
7014
- items: array(
7237
+ type: literal$1("tabs"),
7238
+ items: array$1(
7015
7239
  object({
7016
7240
  id: nodeIdSchema,
7017
7241
  label: shortTextSchema,
7018
- badge: string().trim().max(40).optional(),
7019
- children: array(viewNodeSchema)
7242
+ badge: string$1().trim().max(40).optional(),
7243
+ children: array$1(viewNodeSchema)
7020
7244
  })
7021
7245
  ).min(1).max(VIEW_BUDGET.maxTabItems),
7022
7246
  fallback: viewNodeSchema.optional()
7023
7247
  }),
7024
7248
  object({
7025
7249
  id: nodeIdSchema,
7026
- type: literal("textField"),
7250
+ type: literal$1("textField"),
7027
7251
  label: shortTextSchema,
7028
- placeholder: string().trim().max(120).optional(),
7029
- value: string().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7030
- maxLength: number().int().positive().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7252
+ placeholder: string$1().trim().max(120).optional(),
7253
+ value: string$1().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7254
+ maxLength: number$1().int().positive().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7031
7255
  disabled: boolean().optional(),
7032
7256
  clearable: boolean().optional(),
7033
- resetToken: string().trim().max(120).optional(),
7257
+ resetToken: string$1().trim().max(120).optional(),
7034
7258
  submitAction: viewActionSchema.optional(),
7035
7259
  fallback: viewNodeSchema.optional()
7036
7260
  })
@@ -7038,13 +7262,13 @@ var knownNodeSchema = lazy(
7038
7262
  );
7039
7263
  var unknownNodeSchema = lazy(
7040
7264
  () => looseObject({
7041
- type: string().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7265
+ type: string$1().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7042
7266
  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"
7043
7267
  }),
7044
7268
  fallback: viewNodeSchema.optional()
7045
7269
  })
7046
7270
  );
7047
- var viewNodeSchema = union([knownNodeSchema, unknownNodeSchema]);
7271
+ var viewNodeSchema = union$1([knownNodeSchema, unknownNodeSchema]);
7048
7272
  var viewRegionStatusSchema = _enum(["ready", "loading", "empty", "error"]);
7049
7273
  var viewRetryPresentationSchema = _enum(["button", "inline"]);
7050
7274
  var viewRegionSchema = object({
@@ -7056,15 +7280,15 @@ var viewRegionSchema = object({
7056
7280
  /** 仅在 `status` 为 `error` 时有意义。 */
7057
7281
  retry: viewActionSchema.optional(),
7058
7282
  /** 覆盖宿主默认错误文案;仅用于 `error` Region。 */
7059
- errorText: string().trim().min(1).max(200).optional(),
7283
+ errorText: string$1().trim().min(1).max(200).optional(),
7060
7284
  /** 重试动作的宿主呈现方式;`inline` 使用 Accent 文字动作。 */
7061
7285
  retryPresentation: viewRetryPresentationSchema.optional(),
7062
7286
  /** 覆盖宿主默认空态文案;显式空字符串表示只呈现业务视觉锚点。 */
7063
- emptyText: string().trim().max(200).optional(),
7287
+ emptyText: string$1().trim().max(200).optional(),
7064
7288
  /** 顶部瞬时说明;出现与消失不参与节点预算,也不引起内容重排。 */
7065
7289
  notice: viewRegionNoticeSchema.optional(),
7066
7290
  /** `ready` 时是真实内容,`loading` 时是占位蓝图,`empty/error` 时可选保留业务视觉锚点。 */
7067
- nodes: array(viewNodeSchema).default([])
7291
+ nodes: array$1(viewNodeSchema).default([])
7068
7292
  }).superRefine((region2, context) => {
7069
7293
  if (region2.refreshing === true && region2.status !== "ready") {
7070
7294
  context.addIssue({
@@ -7097,10 +7321,10 @@ var viewRegionSchema = object({
7097
7321
  });
7098
7322
  object({
7099
7323
  /** 文档 schema 的整数 major 版本。 */
7100
- schema: number().int().positive(),
7324
+ schema: number$1().int().positive(),
7101
7325
  /** Runtime 更新文档时由包内 renderer 执行的渐进增强过渡。 */
7102
7326
  transition: viewTransitionSchema.optional(),
7103
- regions: array(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7327
+ regions: array$1(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7104
7328
  });
7105
7329
  function fail(message) {
7106
7330
  throw new Error(`workspaceCards: ${message}`);
@@ -7161,6 +7385,317 @@ function validateWorkspaceCardParams(value) {
7161
7385
  visit(value);
7162
7386
  }
7163
7387
 
7388
+ const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
7389
+ if (!inst._zod)
7390
+ throw new Error("Uninitialized schema in ZodMiniType.");
7391
+ $ZodType.init(inst, def);
7392
+ inst.def = def;
7393
+ inst.type = def.type;
7394
+ inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
7395
+ inst.safeParse = (data, params) => safeParse$1(inst, data, params);
7396
+ inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
7397
+ inst.safeParseAsync = async (data, params) => safeParseAsync$1(inst, data, params);
7398
+ inst.check = (...checks) => {
7399
+ return inst.clone({
7400
+ ...def,
7401
+ checks: [
7402
+ ...(def.checks ?? []),
7403
+ ...checks.map((ch) => typeof ch === "function"
7404
+ ? {
7405
+ _zod: { check: ch, def: { check: "custom" }, onattach: [] },
7406
+ }
7407
+ : ch),
7408
+ ],
7409
+ }, { parent: true });
7410
+ };
7411
+ inst.with = inst.check;
7412
+ inst.clone = (_def, params) => clone(inst, _def, params);
7413
+ inst.brand = () => inst;
7414
+ inst.register = ((reg, meta) => {
7415
+ reg.add(inst, meta);
7416
+ return inst;
7417
+ });
7418
+ inst.apply = (fn) => fn(inst);
7419
+ });
7420
+ const ZodMiniString = /*@__PURE__*/ $constructor("ZodMiniString", (inst, def) => {
7421
+ $ZodString.init(inst, def);
7422
+ ZodMiniType.init(inst, def);
7423
+ });
7424
+ // @__NO_SIDE_EFFECTS__
7425
+ function string(params) {
7426
+ return _string(ZodMiniString, params);
7427
+ }
7428
+ const ZodMiniNumber = /*@__PURE__*/ $constructor("ZodMiniNumber", (inst, def) => {
7429
+ $ZodNumber.init(inst, def);
7430
+ ZodMiniType.init(inst, def);
7431
+ });
7432
+ // @__NO_SIDE_EFFECTS__
7433
+ function number(params) {
7434
+ return _number(ZodMiniNumber, params);
7435
+ }
7436
+ const ZodMiniNumberFormat = /*@__PURE__*/ $constructor("ZodMiniNumberFormat", (inst, def) => {
7437
+ $ZodNumberFormat.init(inst, def);
7438
+ ZodMiniNumber.init(inst, def);
7439
+ });
7440
+ // int
7441
+ // @__NO_SIDE_EFFECTS__
7442
+ function int(params) {
7443
+ return _int(ZodMiniNumberFormat, params);
7444
+ }
7445
+ const ZodMiniNull = /*@__PURE__*/ $constructor("ZodMiniNull", (inst, def) => {
7446
+ $ZodNull.init(inst, def);
7447
+ ZodMiniType.init(inst, def);
7448
+ });
7449
+ // @__NO_SIDE_EFFECTS__
7450
+ function _null(params) {
7451
+ return _null$2(ZodMiniNull, params);
7452
+ }
7453
+ const ZodMiniNever = /*@__PURE__*/ $constructor("ZodMiniNever", (inst, def) => {
7454
+ $ZodNever.init(inst, def);
7455
+ ZodMiniType.init(inst, def);
7456
+ });
7457
+ // @__NO_SIDE_EFFECTS__
7458
+ function never(params) {
7459
+ return _never(ZodMiniNever, params);
7460
+ }
7461
+ const ZodMiniArray = /*@__PURE__*/ $constructor("ZodMiniArray", (inst, def) => {
7462
+ $ZodArray.init(inst, def);
7463
+ ZodMiniType.init(inst, def);
7464
+ });
7465
+ // @__NO_SIDE_EFFECTS__
7466
+ function array(element, params) {
7467
+ return new ZodMiniArray({
7468
+ type: "array",
7469
+ element: element,
7470
+ ...normalizeParams(params),
7471
+ });
7472
+ }
7473
+ const ZodMiniObject = /*@__PURE__*/ $constructor("ZodMiniObject", (inst, def) => {
7474
+ $ZodObject.init(inst, def);
7475
+ ZodMiniType.init(inst, def);
7476
+ defineLazy(inst, "shape", () => def.shape);
7477
+ });
7478
+ // strictObject
7479
+ // @__NO_SIDE_EFFECTS__
7480
+ function strictObject(shape, params) {
7481
+ return new ZodMiniObject({
7482
+ type: "object",
7483
+ shape,
7484
+ catchall: never(),
7485
+ ...normalizeParams(params),
7486
+ });
7487
+ }
7488
+ const ZodMiniUnion = /*@__PURE__*/ $constructor("ZodMiniUnion", (inst, def) => {
7489
+ $ZodUnion.init(inst, def);
7490
+ ZodMiniType.init(inst, def);
7491
+ });
7492
+ // @__NO_SIDE_EFFECTS__
7493
+ function union(options, params) {
7494
+ return new ZodMiniUnion({
7495
+ type: "union",
7496
+ options: options,
7497
+ ...normalizeParams(params),
7498
+ });
7499
+ }
7500
+ const ZodMiniLiteral = /*@__PURE__*/ $constructor("ZodMiniLiteral", (inst, def) => {
7501
+ $ZodLiteral.init(inst, def);
7502
+ ZodMiniType.init(inst, def);
7503
+ });
7504
+ // @__NO_SIDE_EFFECTS__
7505
+ function literal(value, params) {
7506
+ return new ZodMiniLiteral({
7507
+ type: "literal",
7508
+ values: Array.isArray(value) ? value : [value],
7509
+ ...normalizeParams(params),
7510
+ });
7511
+ }
7512
+ const ZodMiniOptional = /*@__PURE__*/ $constructor("ZodMiniOptional", (inst, def) => {
7513
+ $ZodOptional.init(inst, def);
7514
+ ZodMiniType.init(inst, def);
7515
+ });
7516
+ // @__NO_SIDE_EFFECTS__
7517
+ function optional(innerType) {
7518
+ return new ZodMiniOptional({
7519
+ type: "optional",
7520
+ innerType: innerType,
7521
+ });
7522
+ }
7523
+ const ZodMiniLazy = /*@__PURE__*/ $constructor("ZodMiniLazy", (inst, def) => {
7524
+ $ZodLazy.init(inst, def);
7525
+ ZodMiniType.init(inst, def);
7526
+ });
7527
+ // export function lazy<T extends object>(getter: () => T): T {
7528
+ // return util.createTransparentProxy<T>(getter);
7529
+ // }
7530
+ // @__NO_SIDE_EFFECTS__
7531
+ function _lazy(getter) {
7532
+ return new ZodMiniLazy({
7533
+ type: "lazy",
7534
+ getter: getter,
7535
+ });
7536
+ }
7537
+
7538
+ // 由 scripts/generate-user-data-contract.mjs 从公开 DTO 生成,请勿手改。
7539
+ const definitions = {
7540
+ "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)]) }),
7541
+ "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]*)$")))]) }),
7542
+ "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"]) }),
7543
+ "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]*)$")))]) }),
7544
+ "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]*)$")))]) }),
7545
+ "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]*)$")))]))]) }),
7546
+ "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]*)$")))]) }),
7547
+ "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)]) }),
7548
+ "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]*)$")))]) }),
7549
+ "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)]) }),
7550
+ "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]*)$")))]) }),
7551
+ "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]*)$")))]) }),
7552
+ "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() }),
7553
+ "PhantomBladeZeroUnavailableValue": strictObject({ "value": _null(), "reason": string() }),
7554
+ "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]*)$")))]) }),
7555
+ "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]*)$")))]) }),
7556
+ "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"]) }),
7557
+ "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() }),
7558
+ "PhantomBladeZeroLoadoutState": strictObject({ "category": string(), "id": string(), "level": optional(number()), "soul_forged": optional(union([literal(false), literal(true)])), "reincarnation_count": optional(number()) }),
7559
+ "PhantomBladeZeroNamedItem": strictObject({ "id": string(), "name": string() }),
7560
+ "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]*)$")))]) }),
7561
+ "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() }),
7562
+ "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"]))]) }),
7563
+ "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"]))]) }),
7564
+ "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]*)$")))]) }),
7565
+ "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"]) }),
7566
+ "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"]) }),
7567
+ "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())]) }),
7568
+ "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() }),
7569
+ "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() }),
7570
+ "PhantomBladeZeroInventoryItem": strictObject({ "id": string(), "amount": union([int().check(_gte(-9007199254740991), _lte(9007199254740991)), string().check(_regex(new RegExp("^-?(0|[1-9][0-9]*)$")))]) }),
7571
+ "PhantomBladeZeroLocation": strictObject({ "map": string(), "mapName": string(), "x": number(), "y": number(), "z": number() }),
7572
+ "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"]))]) })};
7573
+ const SNAPSHOT_FIELDS = ['schema_version', 'canPersist', 'resources'];
7574
+ const SNAPSHOT_OPTIONAL_FIELDS = ['egressTier'];
7575
+ const EGRESS_TIER_SET = new Set(['upload', 'no_network']);
7576
+ const RESOURCE_STATE_REQUIRED_FIELDS = [
7577
+ 'resource',
7578
+ 'declared',
7579
+ 'available',
7580
+ 'decision',
7581
+ 'revision',
7582
+ 'sessionAllowed',
7583
+ 'allowed',
7584
+ 'name',
7585
+ 'purposeText',
7586
+ 'scopeFingerprint',
7587
+ ];
7588
+ const RESOURCE_STATE_OPTIONAL_FIELDS = ['consentFingerprint'];
7589
+ const DECISION_SET = new Set(['ask', 'allow', 'deny']);
7590
+ /**
7591
+ * 严格解析 Host 返回的数据许可快照。
7592
+ *
7593
+ * @param value - 桥方法返回的未知值。
7594
+ * @returns 合法时返回归一化并冻结的 {@link DataPermissionSnapshot},否则 `{ valid: false }`。
7595
+ *
7596
+ * @remarks
7597
+ * 校验项:`schema_version === 1`;`revision` 是非负安全整数;`resources` 只包含已发布精确资源 key
7598
+ * 且不重复;每个资源状态字段齐全、类型正确、`decision` 合法;`consentFingerprint` 只允许出现在持久
7599
+ * `allow` 上。未知字段一律拒绝,避免 Host 把私人决定或额外私有字段顺带塞进公开页面。
7600
+ *
7601
+ * @since 0.9.6
7602
+ */
7603
+ function parseDataPermissionSnapshot(value) {
7604
+ if (!hasExactFields(value, SNAPSHOT_FIELDS, SNAPSHOT_OPTIONAL_FIELDS))
7605
+ return { valid: false };
7606
+ if (value.schema_version !== 1)
7607
+ return { valid: false };
7608
+ if (typeof value.canPersist !== 'boolean')
7609
+ return { valid: false };
7610
+ if (!Array.isArray(value.resources))
7611
+ return { valid: false };
7612
+ if (value.resources.length > USER_GAME_DATA_RESOURCE_KEYS.length)
7613
+ return { valid: false };
7614
+ if (value.egressTier !== undefined && (typeof value.egressTier !== 'string' || !EGRESS_TIER_SET.has(value.egressTier))) {
7615
+ return { valid: false };
7616
+ }
7617
+ const seen = new Set();
7618
+ const resources = [];
7619
+ for (const entry of value.resources) {
7620
+ const parsed = parseResourceState(entry);
7621
+ if (!parsed)
7622
+ return { valid: false };
7623
+ if (seen.has(parsed.resource))
7624
+ return { valid: false };
7625
+ seen.add(parsed.resource);
7626
+ resources.push(parsed);
7627
+ }
7628
+ return {
7629
+ valid: true,
7630
+ snapshot: Object.freeze({
7631
+ schema_version: 1,
7632
+ canPersist: value.canPersist,
7633
+ resources: Object.freeze(resources),
7634
+ ...(value.egressTier === undefined ? {} : { egressTier: value.egressTier }),
7635
+ }),
7636
+ };
7637
+ }
7638
+ function parseResourceState(value) {
7639
+ if (!hasExactFields(value, RESOURCE_STATE_REQUIRED_FIELDS, RESOURCE_STATE_OPTIONAL_FIELDS)) {
7640
+ return undefined;
7641
+ }
7642
+ if (typeof value.resource !== 'string' || !isUserGameDataResourceKey(value.resource))
7643
+ return undefined;
7644
+ if (typeof value.declared !== 'boolean')
7645
+ return undefined;
7646
+ if (typeof value.available !== 'boolean')
7647
+ return undefined;
7648
+ if (typeof value.decision !== 'string' || !DECISION_SET.has(value.decision))
7649
+ return undefined;
7650
+ if (!isNonNegativeSafeInteger(value.revision))
7651
+ return undefined;
7652
+ if (typeof value.name !== 'string' || typeof value.purposeText !== 'string' || typeof value.scopeFingerprint !== 'string')
7653
+ return undefined;
7654
+ if (typeof value.allowed !== 'boolean' || typeof value.sessionAllowed !== 'boolean')
7655
+ return undefined;
7656
+ const hasFingerprint = Object.prototype.hasOwnProperty.call(value, 'consentFingerprint');
7657
+ if (hasFingerprint) {
7658
+ if (value.decision !== 'allow')
7659
+ return undefined;
7660
+ if (typeof value.consentFingerprint !== 'string' || value.consentFingerprint.length === 0) {
7661
+ return undefined;
7662
+ }
7663
+ }
7664
+ return {
7665
+ resource: value.resource,
7666
+ declared: value.declared,
7667
+ available: value.available,
7668
+ decision: value.decision,
7669
+ revision: value.revision,
7670
+ name: value.name,
7671
+ purposeText: value.purposeText,
7672
+ scopeFingerprint: value.scopeFingerprint,
7673
+ sessionAllowed: value.sessionAllowed,
7674
+ allowed: value.allowed,
7675
+ ...(hasFingerprint ? { consentFingerprint: value.consentFingerprint } : {}),
7676
+ };
7677
+ }
7678
+ function isRecord$2(value) {
7679
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
7680
+ }
7681
+ function isNonNegativeSafeInteger(value) {
7682
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
7683
+ }
7684
+ function hasExactFields(value, required, optional = []) {
7685
+ if (!isRecord$2(value))
7686
+ return false;
7687
+ const keys = Object.keys(value);
7688
+ for (const key of keys) {
7689
+ if (!required.includes(key) && !optional.includes(key))
7690
+ return false;
7691
+ }
7692
+ for (const key of required) {
7693
+ if (!Object.prototype.hasOwnProperty.call(value, key))
7694
+ return false;
7695
+ }
7696
+ return true;
7697
+ }
7698
+
7164
7699
  /** 仅 SDK 内部拥有状态更新入口,业务只可读。 */
7165
7700
  function createWorkspaceCardsModule(client) {
7166
7701
  let context = null;
@@ -7509,7 +8044,7 @@ function createMessageId() {
7509
8044
  /** 构建时替换为当前发布包的实际版本。 */
7510
8045
  const HB_SDK_VERSION = typeof undefined === 'string'
7511
8046
  ? undefined
7512
- : '0.9.6-alpha.9';
8047
+ : '0.9.7';
7513
8048
 
7514
8049
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
7515
8050
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
@@ -7555,8 +8090,17 @@ function readRecord$1(value) {
7555
8090
  }
7556
8091
 
7557
8092
  const DEFAULT_TIMEOUT = 10000;
7558
- // 选择器等待、截图延迟、登录和关注确认由 Host 管理,使用长操作生命周期,不设固定总时长。
7559
- 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]);
8093
+ // 这些操作等待 Host 的真实终态或用户选择,不使用普通请求的固定总时长。
8094
+ const HOST_MANAGED_TIMEOUT_METHODS = new Set([
8095
+ FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD,
8096
+ SHARE_SCREENSHOT_METHOD, SHARE_SCREENSHOT_LONG_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD,
8097
+ USER_DATA_FILE_METHOD, USER_DATA_SYNC_METHOD,
8098
+ USER_DATA_PERMISSION_REQUEST_METHOD, USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD,
8099
+ ]);
8100
+ /** SDK 内部共用的长操作分类;资料模块与普通 request 使用同一超时策略。 */
8101
+ function isHostManagedOperation(method) {
8102
+ return HOST_MANAGED_TIMEOUT_METHODS.has(method);
8103
+ }
7560
8104
  const HANDSHAKE_RETRY_INTERVAL = 250;
7561
8105
  /** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
7562
8106
  class MiniProgramBridgeClient {
@@ -7639,7 +8183,7 @@ class MiniProgramBridgeClient {
7639
8183
  }
7640
8184
  /** 调用父容器开放能力。 */
7641
8185
  async request(method, ...args) {
7642
- return this.performRequest(method, args[0], !HOST_MANAGED_TIMEOUT_METHODS.has(method), undefined, true);
8186
+ return this.performRequest(method, args[0], !isHostManagedOperation(method), undefined, true);
7643
8187
  }
7644
8188
  /** 发起不使用固定总时长 timer 的长操作。 */
7645
8189
  async requestOperation(method, payload, options = {}) {
@@ -10592,6 +11136,14 @@ function decodeBase64Url(value) {
10592
11136
  return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
10593
11137
  }
10594
11138
 
11139
+ let queue = Promise.resolve();
11140
+ /** 同页截图串行执行,避免长图捕获面遮挡另一次截图。 */
11141
+ function serializeScreenshot(capture) {
11142
+ const result = queue.then(capture);
11143
+ queue = result.catch(() => undefined);
11144
+ return result;
11145
+ }
11146
+
10595
11147
  /**
10596
11148
  * 截图并唤起分享。
10597
11149
  *
@@ -10608,13 +11160,169 @@ function decodeBase64Url(value) {
10608
11160
  * @see {@link MiniProgramScreenshotOptions}
10609
11161
  */
10610
11162
  function screenshot(requester, options) {
11163
+ return serializeScreenshot(() => captureScreenshot(requester, options));
11164
+ }
11165
+ /** 已持有截图队列的内部入口。 */
11166
+ function captureScreenshot(requester, options) {
11167
+ warnScreenshotWatermark();
11168
+ return requester.request(SHARE_SCREENSHOT_METHOD, options);
11169
+ }
11170
+ function warnScreenshotWatermark() {
10611
11171
  try {
10612
11172
  console.warn('[hb-sdk] share.screenshot 行为变更提醒:正式版 SDK 0.9.1 及以上默认添加小程序品牌水印;低于 0.9.1(含预发布版本)的 SDK 保持无水印截图。升级前请在目标截图区域底部预留至少 57 个逻辑像素,避免遮挡重要内容;watermarkTheme 的 light 为黑色水印,dark 为白色水印且是默认值,不自动跟随系统主题。系统按键截图不在此能力范围内。');
10613
11173
  }
10614
11174
  catch {
10615
11175
  // 日志输出失败不能阻断截图调用。
10616
11176
  }
10617
- return requester.request(SHARE_SCREENSHOT_METHOD, options);
11177
+ }
11178
+
11179
+ /** 将当前页面的 DOM 边界转换为逻辑像素矩形,再复用原截图分享流程。 */
11180
+ async function screenshotElement(requester, options) {
11181
+ return serializeScreenshot(() => captureElement(requester, options));
11182
+ }
11183
+ async function captureElement(requester, options) {
11184
+ if (!options || typeof options !== 'object' || Array.isArray(options) || 'rect' in options) {
11185
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement 必须传入包含 element 的配置,且不能指定 rect');
11186
+ }
11187
+ const { element, ...screenshotOptions } = options;
11188
+ if (typeof window === 'undefined' || typeof document === 'undefined' || typeof Element === 'undefined'
11189
+ || !(element instanceof Element) || element.ownerDocument !== document || !element.isConnected) {
11190
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须是当前页面中已挂载的 DOM 元素');
11191
+ }
11192
+ // DOMRect 已是当前窗口逻辑像素;不叠加滚动偏移,也不乘设备像素比。
11193
+ const { left, top, width, height } = element.getBoundingClientRect();
11194
+ const windowWidth = document.documentElement.clientWidth || window.innerWidth;
11195
+ const windowHeight = document.documentElement.clientHeight || window.innerHeight;
11196
+ const visibility = window.getComputedStyle(element).visibility;
11197
+ if (![left, top, width, height, windowWidth, windowHeight].every(Number.isFinite)
11198
+ || width <= 0 || height <= 0 || windowWidth <= 0 || windowHeight <= 0
11199
+ || element.getClientRects().length === 0 || visibility === 'hidden' || visibility === 'collapse') {
11200
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须具有可见的布局尺寸');
11201
+ }
11202
+ // 原生只支持纵向拼接;横向溢出不能静默退化为可见区域截图。
11203
+ if (width >= windowWidth + 1 || element.scrollWidth > element.clientWidth + 1) {
11204
+ throw createSDKError('INVALID_PARAMS', '暂不支持横向长图:元素宽度不能超过窗口,且不能包含横向溢出内容');
11205
+ }
11206
+ if (height >= windowHeight + 1 || element.scrollHeight > height + 1) {
11207
+ if (width > windowWidth + 1)
11208
+ throw createSDKError('INVALID_PARAMS', '长图宽度不能超过窗口');
11209
+ return screenshotLongElement(requester, options);
11210
+ }
11211
+ // clientWidth/clientHeight 为整数,DOMRect 保留亚像素;仅容忍不足 1 个逻辑像素的边界误差。
11212
+ const tolerance = 1;
11213
+ const right = left + width;
11214
+ const bottom = top + height;
11215
+ if (left <= -tolerance || top <= -tolerance || right >= windowWidth + tolerance || bottom >= windowHeight + tolerance) {
11216
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 的完整边界必须位于当前可见窗口内');
11217
+ }
11218
+ const clippedLeft = Math.max(0, left);
11219
+ const clippedTop = Math.max(0, top);
11220
+ const clippedWidth = left < 0 || right > windowWidth ? Math.min(windowWidth, right) - clippedLeft : width;
11221
+ const clippedHeight = top < 0 || bottom > windowHeight ? Math.min(windowHeight, bottom) - clippedTop : height;
11222
+ if (clippedWidth <= 0 || clippedHeight <= 0) {
11223
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须与当前可见窗口相交');
11224
+ }
11225
+ return captureScreenshot(requester, { ...screenshotOptions, rect: { left: clippedLeft, top: clippedTop, width: clippedWidth, height: clippedHeight } });
11226
+ }
11227
+ /** 在业务文档准备长图捕获面,再交给宿主原生截图。调用方持有同页截图队列。 */
11228
+ async function screenshotLongElement(requester, { element, ...options }) {
11229
+ if (!element.isConnected)
11230
+ throw createSDKError('INVALID_PARAMS', '截图元素已卸载');
11231
+ const bounds = element.getBoundingClientRect();
11232
+ const height = Math.max(bounds.height, element.scrollHeight + bounds.height - element.clientHeight);
11233
+ if (height > 10000 || bounds.width > 2048 || bounds.width * height > 4000000) {
11234
+ throw createSDKError('INVALID_PARAMS', '长图尺寸超过限制(高度 10000、面积 400 万逻辑像素)');
11235
+ }
11236
+ if (element.matches('iframe,video,object,embed') || element.querySelector('iframe,video,object,embed')) {
11237
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持嵌入网页和视频');
11238
+ }
11239
+ // 在业务自己的文档内复制,DOM 不经过 bridge,也不导出 Canvas 像素。
11240
+ if (!(element instanceof HTMLElement))
11241
+ throw createSDKError('INVALID_PARAMS', '长图需要 HTML 容器元素');
11242
+ const sources = [element, ...element.querySelectorAll('*')];
11243
+ if (sources.some(source => source.shadowRoot || source.localName.includes('-'))) {
11244
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持自定义元素和 Shadow DOM');
11245
+ }
11246
+ const clone = element.cloneNode(true);
11247
+ const copies = [clone, ...clone.querySelectorAll('*')];
11248
+ for (let i = 0; i < sources.length; i++) {
11249
+ const source = sources[i];
11250
+ const copy = copies[i];
11251
+ if (!copy.style)
11252
+ continue;
11253
+ const computed = window.getComputedStyle(source);
11254
+ if (computed.position === 'fixed' || computed.position === 'sticky')
11255
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持固定或吸顶元素');
11256
+ for (let j = 0; j < computed.length; j++) {
11257
+ const name = computed.item(j);
11258
+ copy.style.setProperty(name, computed.getPropertyValue(name), 'important');
11259
+ }
11260
+ copy.style.setProperty('animation', 'none', 'important');
11261
+ copy.style.setProperty('transition', 'none', 'important');
11262
+ if (source instanceof HTMLCanvasElement) {
11263
+ copy.getContext('2d')?.drawImage(source, 0, 0);
11264
+ }
11265
+ if (source instanceof HTMLInputElement)
11266
+ copy.value = source.value;
11267
+ if (source instanceof HTMLTextAreaElement)
11268
+ copy.value = source.value;
11269
+ if (source instanceof HTMLSelectElement)
11270
+ copy.selectedIndex = source.selectedIndex;
11271
+ if (source instanceof HTMLImageElement) {
11272
+ copy.src = source.currentSrc || source.src;
11273
+ copy.removeAttribute('srcset');
11274
+ copy.loading = 'eager';
11275
+ }
11276
+ }
11277
+ if (window.getComputedStyle(element).backgroundColor === 'rgba(0, 0, 0, 0)')
11278
+ clone.style.setProperty('background-color', 'white', 'important');
11279
+ clone.querySelectorAll('script').forEach(script => script.remove());
11280
+ clone.setAttribute('aria-hidden', 'true');
11281
+ clone.inert = true;
11282
+ clone.dataset.hbScreenshotStage = '';
11283
+ 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' })) {
11284
+ clone.style.setProperty(key, value, 'important');
11285
+ }
11286
+ const x = window.scrollX;
11287
+ const y = window.scrollY;
11288
+ const documentStyles = [document.documentElement, document.body].map(node => ({ node, style: node.getAttribute('style') }));
11289
+ let timer;
11290
+ try {
11291
+ // 小程序经常锁定 body 的高度与滚动;临时释放裁剪,确保捕获面完整可绘制。
11292
+ for (const { node } of documentStyles) {
11293
+ node.style.setProperty('overflow', 'visible', 'important');
11294
+ node.style.setProperty('min-height', `${height}px`, 'important');
11295
+ node.style.setProperty('scroll-behavior', 'auto', 'important');
11296
+ }
11297
+ document.body.append(clone);
11298
+ window.scrollTo(0, 0);
11299
+ // body 定位上下文可能有偏移,将独立捕获面校正到文档原点。
11300
+ const stageBounds = clone.getBoundingClientRect();
11301
+ clone.style.setProperty('left', `${-stageBounds.left}px`, 'important');
11302
+ clone.style.setProperty('top', `${-stageBounds.top}px`, 'important');
11303
+ await Promise.race([
11304
+ Promise.all([...(clone instanceof HTMLImageElement ? [clone] : []), ...clone.querySelectorAll('img')].map(image => image.decode())),
11305
+ new Promise((_, reject) => { timer = setTimeout(() => reject(createSDKError('REQUEST_TIMEOUT', '长图图片加载超时')), 5000); }),
11306
+ ]);
11307
+ const rendered = clone.getBoundingClientRect();
11308
+ if (Math.abs(rendered.left) >= 1 || Math.abs(rendered.top) >= 1 || Math.abs(rendered.width - bounds.width) >= 1 || Math.abs(rendered.height - height) >= 1) {
11309
+ throw createSDKError('INVALID_PARAMS', '当前页面布局无法容纳长图捕获面');
11310
+ }
11311
+ warnScreenshotWatermark();
11312
+ return await requester.request(SHARE_SCREENSHOT_LONG_METHOD, { ...options, rect: { left: 0, top: 0, width: bounds.width, height } });
11313
+ }
11314
+ finally {
11315
+ clearTimeout(timer);
11316
+ clone.remove();
11317
+ // 在恢复业务的 smooth 滚动样式前立即还原,避免退出截图后继续滚动。
11318
+ window.scrollTo(x, y);
11319
+ for (const { node, style } of documentStyles) {
11320
+ if (style === null)
11321
+ node.removeAttribute('style');
11322
+ else
11323
+ node.setAttribute('style', style);
11324
+ }
11325
+ }
10618
11326
  }
10619
11327
 
10620
11328
  /**
@@ -10645,6 +11353,7 @@ function createShareModule(requester, launchHref) {
10645
11353
  getExtra: () => readMiniProgramShareExtra(launchHref),
10646
11354
  showShareMenu: (options) => showShareMenu(requester, options),
10647
11355
  screenshot: (options) => screenshot(requester, options),
11356
+ screenshotElement: (options) => screenshotElement(requester, options),
10648
11357
  };
10649
11358
  }
10650
11359
 
@@ -11478,8 +12187,327 @@ function getSteamGameList(requester, options) {
11478
12187
  return requester.request(USER_GET_STEAM_GAME_LIST_METHOD, options);
11479
12188
  }
11480
12189
 
12190
+ function isRecord$1(value) {
12191
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
12192
+ }
12193
+ function requireRecord(value, label) {
12194
+ if (!isRecord$1(value))
12195
+ throw createSDKError('INVALID_RESPONSE', `${label}响应无效`);
12196
+ return value;
12197
+ }
12198
+ function requireString(value, label) {
12199
+ if (typeof value !== 'string')
12200
+ throw createSDKError('INVALID_RESPONSE', `${label}响应无效`);
12201
+ return value;
12202
+ }
12203
+ function readReadMeta(value) {
12204
+ if (value === undefined)
12205
+ return {};
12206
+ const input = requireRecord(value, 'meta');
12207
+ if (input.cacheHit !== undefined && typeof input.cacheHit !== 'boolean')
12208
+ throw createSDKError('INVALID_RESPONSE', 'meta 响应无效');
12209
+ return {
12210
+ ...(typeof input.cacheHit === 'boolean' ? { cacheHit: input.cacheHit } : {}),
12211
+ ...(typeof input.sourceRevision === 'string' ? { sourceRevision: input.sourceRevision } : {}),
12212
+ };
12213
+ }
12214
+ async function requestUserGameData(requester, method, payload, signal, cancelledCode = 'REQUEST_CANCELLED', cancelledMessage = '资料请求已取消') {
12215
+ if (signal?.aborted)
12216
+ throw createSDKError(cancelledCode, cancelledMessage);
12217
+ const operation = requester;
12218
+ const cancellableSignal = signal && typeof signal.addEventListener === 'function' ? signal : undefined;
12219
+ if (typeof operation.requestOperation === 'function' && (isHostManagedOperation(method) || cancellableSignal))
12220
+ return operation.requestOperation(method, payload, {
12221
+ ...(cancellableSignal ? { signal: cancellableSignal } : {}),
12222
+ createAbortError: () => createSDKError(cancelledCode, cancelledMessage),
12223
+ });
12224
+ const send = requester.request.bind(requester);
12225
+ return send(method, payload);
12226
+ }
12227
+ /** 只是 SDK 调用组合:真实授权、账号和交付策略仍由 Runtime 决定。 */
12228
+ function decorateBlocked(requester, value, retry) {
12229
+ if (typeof value.resource !== 'string' ||
12230
+ !isUserGameDataResourceKey(value.resource) ||
12231
+ !['login_required', 'permission_required', 'permission_denied', 'source_not_linked', 'source_login_required'].includes(String(value.reason)))
12232
+ throw createSDKError('INVALID_RESPONSE', '资料阻塞状态无效');
12233
+ const resource = value.resource;
12234
+ const message = requireString(value.message, '资料说明');
12235
+ const blocked = { status: 'blocked', resource, reason: value.reason, message };
12236
+ if (value.interaction === undefined)
12237
+ return blocked;
12238
+ const interaction = requireRecord(value.interaction, '交互');
12239
+ if (!['permission', 'manage', 'user_login'].includes(String(interaction.type)))
12240
+ throw createSDKError('INVALID_RESPONSE', '交互类型无效');
12241
+ return {
12242
+ ...blocked,
12243
+ action: Object.freeze({
12244
+ resource,
12245
+ type: interaction.type,
12246
+ label: requireString(interaction.label, '交互说明'),
12247
+ async resolve(options = {}) {
12248
+ try {
12249
+ const result = await requestUserGameData(requester, USER_DATA_PERMISSION_REQUEST_METHOD, { resource }, options.signal);
12250
+ if (result.status === 'cancelled')
12251
+ return null;
12252
+ return retry(options.signal);
12253
+ }
12254
+ catch (cause) {
12255
+ if (options.signal?.aborted || (isRecord$1(cause) && ['REQUEST_CANCELLED', 'AUTH_CANCELLED', 'LOGIN_CANCELLED'].includes(String(cause.code))))
12256
+ return null;
12257
+ throw cause;
12258
+ }
12259
+ },
12260
+ }),
12261
+ };
12262
+ }
12263
+ function convertWireReadResult(requester, value, convert, retry, schemaVersion) {
12264
+ const input = requireRecord(value, '资料');
12265
+ if (input.status !== 'blocked' && input.schemaVersion !== schemaVersion)
12266
+ throw createSDKError('REQUEST_UNSUPPORTED', 'SDK 与宿主正文版本不匹配');
12267
+ if (input.status === 'ready')
12268
+ return { status: 'ready', data: convert(input.data), meta: readReadMeta(input.meta) };
12269
+ if (input.status === 'empty' && (input.reason === 'no_data' || input.reason === 'not_ready'))
12270
+ return { status: 'empty', reason: input.reason, message: requireString(input.message, '空资料说明'), meta: readReadMeta(input.meta) };
12271
+ if (input.status === 'blocked')
12272
+ return decorateBlocked(requester, input, retry);
12273
+ throw createSDKError('INVALID_RESPONSE', '资料状态无效');
12274
+ }
12275
+ function convertWireSyncResult(requester, value, retry) {
12276
+ const input = requireRecord(value, '同步');
12277
+ if (input.status === 'succeeded')
12278
+ return { status: 'succeeded' };
12279
+ if (input.status === 'blocked')
12280
+ return decorateBlocked(requester, input, retry);
12281
+ throw createSDKError('INVALID_RESPONSE', '同步状态无效');
12282
+ }
12283
+
12284
+ /** 游戏门面与存档门面共用的精确资源映射,不依赖任一门面工厂。 */
12285
+ function resourceFor(game, family) {
12286
+ const resource = GAME_DATA_RESOURCE_CATALOG.find((value) => value.game === game && value.family === family);
12287
+ if (!resource)
12288
+ throw createSDKError('REQUEST_UNSUPPORTED', '游戏没有开放这类资料');
12289
+ return resource.key;
12290
+ }
12291
+ function queryPayload(game, family, operation) {
12292
+ const resource = resourceFor(game, family);
12293
+ const query = getUserDataResourceContract(resource).queries[operation];
12294
+ if (!query)
12295
+ throw createSDKError('REQUEST_UNSUPPORTED', '未开放资料操作');
12296
+ return { resource, operation, schemaVersion: query.version };
12297
+ }
12298
+
12299
+ /** 创建响应校验失败错误。 */
12300
+ function invalidResponse(message) {
12301
+ return createSDKError('INVALID_RESPONSE', message);
12302
+ }
12303
+ /**
12304
+ * 创建单个云存档文件对象。
12305
+ *
12306
+ * @remarks
12307
+ * 对象只持有查询快照中的 `gameId`/`saveId`/`fileId` 与公开元数据,冻结后不可改写。`downloadFile()`
12308
+ * 不接受 URL、路径或文件 ID,因此不能借对象把下载目标换成其它资源;字节始终由 Host 的受控
12309
+ * 文件句柄交付。
12310
+ */
12311
+ function createSaveFileInfo(requester, gameId, saveId, value) {
12312
+ const record = requireRecord(value, '存档文件元数据');
12313
+ const fileId = requireString(record.fileId, '存档文件 fileId');
12314
+ const name = requireString(record.name, '存档文件 name');
12315
+ if (typeof record.sizeBytes !== 'number' || !Number.isFinite(record.sizeBytes) || record.sizeBytes < 0) {
12316
+ throw invalidResponse('存档文件 sizeBytes 响应不合法');
12317
+ }
12318
+ const modifiedAt = requireString(record.modifiedAt, '存档文件 modifiedAt');
12319
+ return Object.freeze({
12320
+ fileId,
12321
+ name,
12322
+ sizeBytes: record.sizeBytes,
12323
+ modifiedAt,
12324
+ async downloadFile({ signal } = {}) {
12325
+ const descriptor = await requestUserGameData(requester, USER_DATA_FILE_METHOD, { resource: resourceFor(gameId, 'save_files'), saveId, fileId }, signal, 'DOWNLOAD_CANCELLED', '存档下载已取消').catch((error) => {
12326
+ if (signal?.aborted)
12327
+ throw createSDKError('DOWNLOAD_CANCELLED', '存档下载已取消');
12328
+ throw error;
12329
+ });
12330
+ // Host 必须返回只读 direct 文件描述符;写模式、URL/路径或其它形状都按非法响应拒绝。
12331
+ if (!isMiniProgramFileDescriptor(descriptor) || descriptor.mode !== 'read') {
12332
+ throw invalidResponse('存档文件必须为只读文件描述符');
12333
+ }
12334
+ const ref = descriptor.ref;
12335
+ if (!('handleId' in ref) || typeof ref.handleId !== 'string' || ref.handleId.length === 0) {
12336
+ throw invalidResponse('存档文件必须为受控只读文件句柄');
12337
+ }
12338
+ return getFileHandleRegistry(requester).createFile(descriptor);
12339
+ },
12340
+ });
12341
+ }
12342
+ /** 创建单个存档批次;只暴露公开字段,不透传宿主附加的账号或数据库元数据。 */
12343
+ function createSaveInfo(requester, gameId, value) {
12344
+ const record = requireRecord(value, '存档批次');
12345
+ const saveId = requireString(record.saveId, '存档批次 saveId');
12346
+ if (!Array.isArray(record.files))
12347
+ throw invalidResponse('存档批次 files 响应不合法');
12348
+ return Object.freeze({
12349
+ saveId,
12350
+ createdAt: requireString(record.createdAt, '存档批次 createdAt'),
12351
+ files: record.files.map((file) => createSaveFileInfo(requester, gameId, saveId, file)),
12352
+ });
12353
+ }
12354
+ /** 校验存档列表;空数组是合法的 `ready` 结果。 */
12355
+ function convertSaveInfoList(requester, gameId, value) {
12356
+ if (!Array.isArray(value))
12357
+ throw invalidResponse('云存档列表响应不合法');
12358
+ return value.map((entry) => createSaveInfo(requester, gameId, entry));
12359
+ }
12360
+ /**
12361
+ * 创建云存档三方法模块。
12362
+ *
12363
+ * @param requester - 模块发起请求所需的 bridge 能力。
12364
+ * @param gameId - 已开放的存档游戏,方法只作用于该游戏。
12365
+ * @returns `saves` 对象;每次调用重新解析当前来源、许可与解析结果。
12366
+ * @remarks
12367
+ * `list` 不触发同步或解析;`sync` 等待文件同步终态;`getLatestStructuredData` 只读已有结果。
12368
+ * `list()` 交付的文件对象取得受控只读文件句柄,不拼接 URL 或
12369
+ * 路径;四者都不接受账号、Steam AppID 或文件路径参数。
12370
+ *
12371
+ * @since 0.9.6
12372
+ * @hbPlatform android
12373
+ * @hbPlatform ios
12374
+ * @hbPlatform ohos
12375
+ * @hbPlatform windows
12376
+ * @hbPlatform macos
12377
+ * @hbClient android none
12378
+ * @hbClient ios none
12379
+ * @hbClient ohos none
12380
+ * @hbClient windows none
12381
+ * @hbClient macos none
12382
+ */
12383
+ function createUserSavesModule(requester, gameId) {
12384
+ const list = async (options = {}) => {
12385
+ const payload = queryPayload(gameId, 'save_files', 'list');
12386
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12387
+ return convertWireReadResult(requester, result, (value) => {
12388
+ const page = requireRecord(value, '存档列表');
12389
+ if (page.hasMore !== false || page.nextCursor !== undefined)
12390
+ throw invalidResponse('存档列表必须完整返回');
12391
+ return convertSaveInfoList(requester, gameId, page.items);
12392
+ }, (signal) => list({ signal }), payload.schemaVersion);
12393
+ };
12394
+ const sync = async (options = {}) => {
12395
+ const result = await requestUserGameData(requester, USER_DATA_SYNC_METHOD, { game: gameId }, options.signal);
12396
+ return convertWireSyncResult(requester, result, (signal) => sync({ signal }));
12397
+ };
12398
+ const getLatestStructuredData = async (options = {}) => {
12399
+ const payload = queryPayload(gameId, 'save_analysis', 'get');
12400
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12401
+ return convertWireReadResult(requester, result, (value) => requireRecord(value, '存档解析正文'), (signal) => getLatestStructuredData({ signal }), payload.schemaVersion);
12402
+ };
12403
+ return Object.freeze({ list, sync, getLatestStructuredData });
12404
+ }
12405
+
12406
+ function validate(value) {
12407
+ return requireRecord(value, '资料正文');
12408
+ }
12409
+ function createArkGameModule(requester) {
12410
+ const getProfile = async (options = {}) => {
12411
+ const payload = queryPayload('ark', 'profile', 'get');
12412
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12413
+ return convertWireReadResult(requester, result, (value) => validate(value), (signal) => getProfile({ signal }), payload.schemaVersion);
12414
+ };
12415
+ const getGachaAnalysis = async (options = {}) => {
12416
+ const payload = queryPayload('ark', 'gacha', 'get');
12417
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12418
+ return convertWireReadResult(requester, result, (value) => validate(value), (signal) => getGachaAnalysis({ signal }), payload.schemaVersion);
12419
+ };
12420
+ const listGachaRecords = async (options = {}) => {
12421
+ const payload = {
12422
+ ...queryPayload('ark', 'gacha', 'list'),
12423
+ ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
12424
+ ...(options.limit === undefined ? {} : { limit: options.limit }),
12425
+ };
12426
+ const result = await requestUserGameData(requester, USER_DATA_QUERY_METHOD, payload, options.signal);
12427
+ return convertWireReadResult(requester, result, (value) => {
12428
+ const page = requireRecord(value, '分页');
12429
+ if (!Array.isArray(page.items) || typeof page.hasMore !== 'boolean')
12430
+ throw createSDKError('INVALID_RESPONSE', '分页正文无效');
12431
+ return page;
12432
+ }, (signal) => listGachaRecords({ ...options, signal }), payload.schemaVersion);
12433
+ };
12434
+ return Object.freeze({ getProfile, getGachaAnalysis, listGachaRecords });
12435
+ }
12436
+ function createUserGamesModule(requester) {
12437
+ const factories = {
12438
+ ark: () => createArkGameModule(requester),
12439
+ black_myth_wukong: () => ({ saves: createUserSavesModule(requester, 'black_myth_wukong') }),
12440
+ task_bar_hero: () => ({ saves: createUserSavesModule(requester, 'task_bar_hero') }),
12441
+ phantom_blade_zero: () => ({ saves: createUserSavesModule(requester, 'phantom_blade_zero') }),
12442
+ };
12443
+ return Object.freeze({
12444
+ get(game) {
12445
+ if (!isUserGameDataGameId(game))
12446
+ throw createSDKError('REQUEST_UNSUPPORTED', '尚未开放该游戏资料');
12447
+ return factories[game]();
12448
+ },
12449
+ async getOverview(options = {}) {
12450
+ const result = await requester.request(USER_GAMES_GET_OVERVIEW_METHOD, options);
12451
+ if (!Array.isArray(result))
12452
+ throw createSDKError('INVALID_RESPONSE', '资料概览无效');
12453
+ return {
12454
+ status: 'ready',
12455
+ meta: {},
12456
+ data: result.map((value) => {
12457
+ const game = requireRecord(value, '游戏概览');
12458
+ if (typeof game.game !== 'string' || !isUserGameDataGameId(game.game) || !Array.isArray(game.resources))
12459
+ throw createSDKError('INVALID_RESPONSE', '游戏概览无效');
12460
+ return {
12461
+ game: game.game,
12462
+ name: requireString(game.name, '游戏名'),
12463
+ resources: game.resources.map((value) => {
12464
+ const resource = requireRecord(value, '资源概览');
12465
+ if (typeof resource.resource !== 'string' || !isUserGameDataResourceKey(resource.resource) || resource.status !== 'not_checked')
12466
+ throw createSDKError('INVALID_RESPONSE', '资源概览无效');
12467
+ return {
12468
+ resource: resource.resource,
12469
+ name: requireString(resource.name, '资源名'),
12470
+ statusText: requireString(resource.statusText, '状态'),
12471
+ status: 'not_checked',
12472
+ };
12473
+ }),
12474
+ };
12475
+ }),
12476
+ };
12477
+ },
12478
+ });
12479
+ }
12480
+
12481
+ function createUserDataPermissionModule(requester) {
12482
+ function snapshot(value) {
12483
+ const parsed = parseDataPermissionSnapshot(value);
12484
+ if (!parsed.valid)
12485
+ throw createSDKError('INVALID_RESPONSE', '本机许可快照无效');
12486
+ return parsed.snapshot;
12487
+ }
12488
+ return {
12489
+ async request(resource, options = {}) {
12490
+ const result = await requestUserGameData(requester, USER_DATA_PERMISSION_REQUEST_METHOD, { resource }, options.signal);
12491
+ if (!result || !['allowed', 'denied', 'cancelled'].includes(result.status))
12492
+ throw createSDKError('INVALID_RESPONSE', '许可确认结果无效');
12493
+ return result;
12494
+ },
12495
+ async get() {
12496
+ return snapshot(await requester.request(USER_DATA_PERMISSION_GET_METHOD, {}));
12497
+ },
12498
+ async revokeSession(resource) {
12499
+ return snapshot(await requester.request(USER_DATA_PERMISSION_REVOKE_SESSION_METHOD, resource === undefined ? {} : { resource }));
12500
+ },
12501
+ async openSettings() {
12502
+ return snapshot(await requester.request(USER_DATA_PERMISSION_OPEN_SETTINGS_METHOD, {}));
12503
+ },
12504
+ };
12505
+ }
12506
+
11481
12507
  function createUserModule(requester) {
11482
12508
  return {
12509
+ games: createUserGamesModule(requester),
12510
+ dataPermission: createUserDataPermissionModule(requester),
11483
12511
  requestFollowAuthor: () => requestFollowAuthor(requester),
11484
12512
  getFollowStatus: () => getFollowStatus(requester),
11485
12513
  showAppreciation: () => requester.request(USER_SHOW_APPRECIATION_METHOD),
@@ -11766,7 +12794,10 @@ class MiniProgramSDK {
11766
12794
  navigation;
11767
12795
  /** 云端数据相关开放能力。 */
11768
12796
  cloud;
11769
- /** 查询、同步并读取当前用户的 Steam 游戏存档。 */
12797
+ /**
12798
+ * 查询、同步并读取当前用户的 Steam 游戏存档。
12799
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
12800
+ */
11770
12801
  gameSaves;
11771
12802
  /** 受管桌面程序能力。 */
11772
12803
  companion;
@@ -12206,6 +13237,16 @@ const auth = {
12206
13237
  };
12207
13238
  /** 默认 SDK 实例的用户资料模块。 */
12208
13239
  const user = {
13240
+ dataPermission: {
13241
+ request: (resource, options) => getDefaultSDK().user.dataPermission.request(resource, options),
13242
+ get: () => getDefaultSDK().user.dataPermission.get(),
13243
+ revokeSession: (resource) => getDefaultSDK().user.dataPermission.revokeSession(resource),
13244
+ openSettings: () => getDefaultSDK().user.dataPermission.openSettings(),
13245
+ },
13246
+ games: {
13247
+ getOverview: (options) => getDefaultSDK().user.games.getOverview(options),
13248
+ get: (gameId) => getDefaultSDK().user.games.get(gameId),
13249
+ },
12209
13250
  requestFollowAuthor: () => getDefaultSDK().user.requestFollowAuthor(),
12210
13251
  getFollowStatus: () => getDefaultSDK().user.getFollowStatus(),
12211
13252
  showAppreciation: () => getDefaultSDK().user.showAppreciation(),
@@ -12219,6 +13260,7 @@ const share = {
12219
13260
  getExtra: () => getDefaultSDK().share.getExtra(),
12220
13261
  showShareMenu: (options) => getDefaultSDK().share.showShareMenu(options),
12221
13262
  screenshot: (options) => getDefaultSDK().share.screenshot(options),
13263
+ screenshotElement: (options) => getDefaultSDK().share.screenshotElement(options),
12222
13264
  };
12223
13265
  /** 默认 SDK 实例的 Viewport 模块。 */
12224
13266
  const viewport = {
@@ -12268,13 +13310,16 @@ const navigation = {
12268
13310
  reload: () => getDefaultSDK().navigation.reload(),
12269
13311
  openAppPage: (options) => getDefaultSDK().navigation.openAppPage(options),
12270
13312
  };
12271
- /** 默认 SDK 实例的 cloud 模块。 */
12272
- /** 当前用户的游戏存档能力。 */
13313
+ /**
13314
+ * 当前用户的游戏存档能力。
13315
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
13316
+ */
12273
13317
  const gameSaves = {
12274
13318
  list: (gameId) => getDefaultSDK().gameSaves.list(gameId),
12275
13319
  getLatestStructuredData: (gameId) => getDefaultSDK().gameSaves.getLatestStructuredData(gameId),
12276
13320
  sync: (gameId, options) => getDefaultSDK().gameSaves.sync(gameId, options),
12277
13321
  };
13322
+ /** 默认 SDK 实例的 cloud 模块。 */
12278
13323
  const cloud = {
12279
13324
  leaderboard: {
12280
13325
  submit: (options) => getDefaultSDK().cloud.leaderboard.submit(options),