@heybox/hb-sdk 0.9.6-alpha.11 → 0.9.6-alpha.13

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 (46) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +4 -1
  3. package/dist/cli-chunks/{artifact-BW6SD1G6.cjs → artifact-CUNeWo4O.cjs} +6 -5
  4. package/dist/cli-chunks/{build-B0Id0UTN.cjs → build-BnUonzjX.cjs} +6 -5
  5. package/dist/cli-chunks/{create-DVu93Ekp.cjs → create-BbpSkT6L.cjs} +322 -4
  6. package/dist/cli-chunks/{dev-CeSjpEZQ.cjs → dev-Bj4ll4KS.cjs} +16 -15
  7. package/dist/cli-chunks/{dev-context-CVc_BsWR.cjs → dev-context-zGJh3bl_.cjs} +22 -14
  8. package/dist/cli-chunks/{doctor-BF9mtkJr.cjs → doctor-CJm6yLwg.cjs} +1 -1
  9. package/dist/cli-chunks/{games-BKnDCklM.cjs → games-M21dEyxU.cjs} +1 -1
  10. package/dist/cli-chunks/{index-Rp3UMZIO.cjs → index-C29Bsipw.cjs} +73 -20
  11. package/dist/cli-chunks/{index-Cgui_8Rk.cjs → index-DOEadJGe.cjs} +1 -1
  12. package/dist/cli-chunks/{index.esm-BK0eVYaM.cjs → index.esm-BDnn3rPW.cjs} +7 -6
  13. package/dist/cli-chunks/index.esm-CvMA_ppV.cjs +7977 -0
  14. package/dist/cli-chunks/{login-DpeDN-mt.cjs → login-sznH9Tub.cjs} +1 -1
  15. package/dist/cli-chunks/{project-vite-Cg3jYqAJ.cjs → project-vite-C3XGMxuI.cjs} +1 -1
  16. package/dist/cli-chunks/{remote-BQ-9rhTb.cjs → remote-ZN1aTL2_.cjs} +13 -8
  17. package/dist/cli-chunks/{runtime-permission-env-BgipCJ0Z.cjs → runtime-permission-env-CubbhSAi.cjs} +52 -6990
  18. package/dist/cli-chunks/{skill-D7pd4yPq.cjs → skill-MQLZiQHF.cjs} +2 -2
  19. package/dist/cli-chunks/{version-DbjRZkb6.cjs → version-d8xCNdNj.cjs} +1 -1
  20. package/dist/cli.cjs +1 -1
  21. package/dist/devtools/browser-dev-host/assets/browser-dev-host-OjGtNPTW.js +228 -0
  22. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-Dmzm0ERX.js +6 -0
  23. package/dist/devtools/browser-dev-host/assets/index-BkmmmW8K.css +1 -0
  24. package/dist/devtools/browser-dev-host/assets/index-Dp6vGvaS.js +586 -0
  25. package/dist/devtools/browser-dev-host/index.html +3 -3
  26. package/dist/index.cjs.js +1030 -155
  27. package/dist/index.esm.js +1030 -155
  28. package/dist/miniapp-publish.cjs.js +1071 -130
  29. package/dist/miniapp-publish.esm.js +1071 -130
  30. package/dist/protocol.cjs.js +727 -158
  31. package/dist/protocol.esm.js +711 -159
  32. package/dist/templates/vanilla-vite-js/README.md.ejs +27 -0
  33. package/dist/templates/vanilla-vite-js/package.json.ejs +1 -1
  34. package/dist/templates/vanilla-vite-js/src/user-game-data.js.ejs +1 -0
  35. package/dist/vite.cjs.js +1073 -132
  36. package/dist/vite.esm.js +1073 -132
  37. package/package.json +5 -5
  38. package/skill/SKILL.md +4 -0
  39. package/skill/skill.json +5 -5
  40. package/types/index.d.ts +386 -9
  41. package/types/miniapp-publish/index.d.ts +18 -2
  42. package/types/protocol.d.ts +1 -1
  43. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DVlT56iQ.js +0 -100
  44. package/dist/devtools/browser-dev-host/assets/desktop-app-launch-BzRxl_MM.js +0 -6
  45. package/dist/devtools/browser-dev-host/assets/index-CHYEXFEg.css +0 -1
  46. package/dist/devtools/browser-dev-host/assets/index-DY5ZynQp.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';
@@ -559,7 +569,7 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
559
569
  * @since 0.3.1
560
570
  */
561
571
  function isMiniProgramBridgeMessage(value) {
562
- if (!isRecord$3(value))
572
+ if (!isRecord$5(value))
563
573
  return false;
564
574
  if (value.namespace !== MINI_PROGRAM_MESSAGE_NAMESPACE || (value.version !== 1 && value.version !== 2) || !isNonEmptyString$1(value.nonce)) {
565
575
  return false;
@@ -711,7 +721,7 @@ function isMiniProgramRelativePath(value) {
711
721
  * @since 0.8.0
712
722
  */
713
723
  function isMiniProgramPathRootRef(value) {
714
- if (!isRecord$3(value))
724
+ if (!isRecord$5(value))
715
725
  return false;
716
726
  if (value.kind === 'sandbox')
717
727
  return hasOnlyKeys(value, ['kind']);
@@ -778,7 +788,7 @@ function isMiniProgramPathRootRef(value) {
778
788
  * @since 0.8.0
779
789
  */
780
790
  function isMiniProgramFileRef(value) {
781
- if (!isRecord$3(value) || value.kind !== 'file')
791
+ if (!isRecord$5(value) || value.kind !== 'file')
782
792
  return false;
783
793
  if (isNonEmptyString$1(value.handleId)) {
784
794
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -846,7 +856,7 @@ function isMiniProgramFileRef(value) {
846
856
  * @since 0.8.0
847
857
  */
848
858
  function isMiniProgramDirectoryRef(value) {
849
- if (!isRecord$3(value) || value.kind !== 'directory')
859
+ if (!isRecord$5(value) || value.kind !== 'directory')
850
860
  return false;
851
861
  if (isNonEmptyString$1(value.handleId)) {
852
862
  return hasOnlyKeys(value, ['kind', 'handleId']);
@@ -923,7 +933,7 @@ function isMiniProgramDirectoryRef(value) {
923
933
  * @since 0.8.0
924
934
  */
925
935
  function isMiniProgramFileDescriptor(value) {
926
- return (isRecord$3(value) &&
936
+ return (isRecord$5(value) &&
927
937
  value.kind === 'file' &&
928
938
  isNonEmptyString$1(value.name) &&
929
939
  isFileMode(value.mode) &&
@@ -976,20 +986,20 @@ const MEDIA_PICK_ITEM_KEYS = ['type', 'mimeType', 'size', 'width', 'height', 'pr
976
986
  * @since 0.9.3
977
987
  */
978
988
  function isMiniProgramMediaPickItem(value) {
979
- if (!isRecord$3(value) || (value.type !== 'image' && value.type !== 'video'))
989
+ if (!isRecord$5(value) || (value.type !== 'image' && value.type !== 'video'))
980
990
  return false;
981
991
  const isVideo = value.type === 'video';
982
992
  if (!hasOnlyKeys(value, isVideo ? [...MEDIA_PICK_ITEM_KEYS, 'durationMs'] : MEDIA_PICK_ITEM_KEYS))
983
993
  return false;
984
994
  if (!isNonEmptyString$1(value.mimeType) ||
985
- !isNonNegativeSafeInteger(value.size) ||
995
+ !isNonNegativeSafeInteger$1(value.size) ||
986
996
  !isPositiveSafeInteger$1(value.width) ||
987
997
  !isPositiveSafeInteger$1(value.height) ||
988
998
  !isNonEmptyString$1(value.previewUrl) ||
989
999
  !isDirectFileDescriptor(value.file)) {
990
1000
  return false;
991
1001
  }
992
- return isVideo ? isNonNegativeSafeInteger(value.durationMs) : true;
1002
+ return isVideo ? isNonNegativeSafeInteger$1(value.durationMs) : true;
993
1003
  }
994
1004
  /**
995
1005
  * 判断未知值是否为整批 `media.pick` 结果。
@@ -1147,9 +1157,9 @@ function isMiniProgramByteArray(value) {
1147
1157
  * @since 0.8.0
1148
1158
  */
1149
1159
  function isMiniProgramFileStat(value) {
1150
- return (isRecord$3(value) &&
1160
+ return (isRecord$5(value) &&
1151
1161
  value.kind === 'file' &&
1152
- isNonNegativeSafeInteger(value.size) &&
1162
+ isNonNegativeSafeInteger$1(value.size) &&
1153
1163
  (value.modifiedAt === undefined || isNonNegativeFiniteNumber(value.modifiedAt)) &&
1154
1164
  (value.createdAt === undefined || isNonNegativeFiniteNumber(value.createdAt)) &&
1155
1165
  hasOnlyKeys(value, ['kind', 'size', 'modifiedAt', 'createdAt']));
@@ -1208,28 +1218,28 @@ function isMiniProgramFileStat(value) {
1208
1218
  * @since 0.8.0
1209
1219
  */
1210
1220
  function isMiniProgramDownloadProgressPayload(value) {
1211
- if (!isRecord$3(value) ||
1212
- !isNonNegativeSafeInteger(value.loaded) ||
1221
+ if (!isRecord$5(value) ||
1222
+ !isNonNegativeSafeInteger$1(value.loaded) ||
1213
1223
  typeof value.lengthComputable !== 'boolean' ||
1214
1224
  !hasOnlyKeys(value, ['loaded', 'total', 'lengthComputable'])) {
1215
1225
  return false;
1216
1226
  }
1217
1227
  if (!value.lengthComputable)
1218
1228
  return value.total === undefined;
1219
- return isNonNegativeSafeInteger(value.total) && value.loaded <= value.total;
1229
+ return isNonNegativeSafeInteger$1(value.total) && value.loaded <= value.total;
1220
1230
  }
1221
1231
  function isMiniProgramCompanionPrepareProgress(value) {
1222
- if (!isRecord$3(value))
1232
+ if (!isRecord$5(value))
1223
1233
  return false;
1224
1234
  if (value.phase === 'downloading') {
1225
- return (isNonNegativeSafeInteger(value.loaded) &&
1226
- (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)) &&
1227
1237
  hasOnlyKeys(value, ['phase', 'loaded', 'total']));
1228
1238
  }
1229
1239
  if (value.phase !== 'verifying' && value.phase !== 'extracting')
1230
1240
  return false;
1231
- return (isNonNegativeSafeInteger(value.processed) &&
1232
- isNonNegativeSafeInteger(value.total) &&
1241
+ return (isNonNegativeSafeInteger$1(value.processed) &&
1242
+ isNonNegativeSafeInteger$1(value.total) &&
1233
1243
  value.processed <= value.total &&
1234
1244
  hasOnlyKeys(value, ['phase', 'processed', 'total']));
1235
1245
  }
@@ -1237,15 +1247,15 @@ function isMiniProgramOperationProgressPayload(value) {
1237
1247
  return isMiniProgramDownloadProgressPayload(value) || isMiniProgramCompanionPrepareProgress(value);
1238
1248
  }
1239
1249
  function isSDKHandshakePayload(value) {
1240
- 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);
1241
1251
  }
1242
1252
  function isBridgeError(value) {
1243
- 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';
1244
1254
  }
1245
1255
  function isFileMode(value) {
1246
1256
  return value === 'read' || value === 'readwrite';
1247
1257
  }
1248
- function isNonNegativeSafeInteger(value) {
1258
+ function isNonNegativeSafeInteger$1(value) {
1249
1259
  return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
1250
1260
  }
1251
1261
  function isPositiveSafeInteger$1(value) {
@@ -1261,10 +1271,217 @@ function hasOnlyKeys(value, allowedKeys) {
1261
1271
  const allowed = new Set(allowedKeys);
1262
1272
  return Object.keys(value).every((key) => allowed.has(key));
1263
1273
  }
1264
- function isRecord$3(value) {
1274
+ function isRecord$5(value) {
1265
1275
  return typeof value === 'object' && value !== null && !Array.isArray(value);
1266
1276
  }
1267
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
+
1268
1485
  const MINI_PROGRAM_PERMISSION_KEYS = [
1269
1486
  'userInfo',
1270
1487
  'steamLibrary',
@@ -1280,6 +1497,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
1280
1497
  'companion',
1281
1498
  'appProtocol',
1282
1499
  'workspaceCards',
1500
+ 'user_game_data',
1283
1501
  ];
1284
1502
  new Set(MINI_PROGRAM_PERMISSION_KEYS);
1285
1503
 
@@ -1902,6 +2120,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
1902
2120
  }
1903
2121
  return result.value;
1904
2122
  };
2123
+ const parse$1 = /* @__PURE__*/ _parse($ZodRealError);
1905
2124
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1906
2125
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
1907
2126
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -1914,6 +2133,7 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1914
2133
  }
1915
2134
  return result.value;
1916
2135
  };
2136
+ const parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
1917
2137
  const _safeParse = (_Err) => (schema, value, _ctx) => {
1918
2138
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
1919
2139
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -2040,14 +2260,14 @@ function datetime$1(args) {
2040
2260
  const timeRegex = `${time}(?:${opts.join("|")})`;
2041
2261
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
2042
2262
  }
2043
- const string$1 = (params) => {
2263
+ const string$2 = (params) => {
2044
2264
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
2045
2265
  return new RegExp(`^${regex}$`);
2046
2266
  };
2047
2267
  const integer = /^-?\d+$/;
2048
- const number$1 = /^-?\d+(?:\.\d+)?$/;
2268
+ const number$2 = /^-?\d+(?:\.\d+)?$/;
2049
2269
  const boolean$1 = /^(?:true|false)$/i;
2050
- const _null$2 = /^null$/i;
2270
+ const _null$3 = /^null$/i;
2051
2271
  // regex for string with no uppercase letters
2052
2272
  const lowercase = /^[^A-Z]*$/;
2053
2273
  // regex for string with no lowercase letters
@@ -2633,7 +2853,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
2633
2853
  });
2634
2854
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
2635
2855
  $ZodType.init(inst, def);
2636
- 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);
2637
2857
  inst._zod.parse = (payload, _) => {
2638
2858
  if (def.coerce)
2639
2859
  try {
@@ -2968,7 +3188,7 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
2968
3188
  });
2969
3189
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
2970
3190
  $ZodType.init(inst, def);
2971
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
3191
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
2972
3192
  inst._zod.parse = (payload, _ctx) => {
2973
3193
  if (def.coerce)
2974
3194
  try {
@@ -3023,7 +3243,7 @@ const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
3023
3243
  });
3024
3244
  const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
3025
3245
  $ZodType.init(inst, def);
3026
- inst._zod.pattern = _null$2;
3246
+ inst._zod.pattern = _null$3;
3027
3247
  inst._zod.values = new Set([null]);
3028
3248
  inst._zod.parse = (payload, _ctx) => {
3029
3249
  const input = payload.value;
@@ -3707,7 +3927,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
3707
3927
  }
3708
3928
  // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
3709
3929
  // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
3710
- 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;
3711
3931
  if (checkNumericKey) {
3712
3932
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
3713
3933
  if (retryResult instanceof Promise) {
@@ -4456,7 +4676,7 @@ function _boolean(Class, params) {
4456
4676
  });
4457
4677
  }
4458
4678
  // @__NO_SIDE_EFFECTS__
4459
- function _null$1(Class, params) {
4679
+ function _null$2(Class, params) {
4460
4680
  return new Class({
4461
4681
  type: "null",
4462
4682
  ...normalizeParams(params),
@@ -5707,7 +5927,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5707
5927
  return this.check(_overwrite(fn));
5708
5928
  },
5709
5929
  optional() {
5710
- return optional(this);
5930
+ return optional$1(this);
5711
5931
  },
5712
5932
  exactOptional() {
5713
5933
  return exactOptional(this);
@@ -5716,16 +5936,16 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5716
5936
  return nullable(this);
5717
5937
  },
5718
5938
  nullish() {
5719
- return optional(nullable(this));
5939
+ return optional$1(nullable(this));
5720
5940
  },
5721
5941
  nonoptional(params) {
5722
5942
  return nonoptional(this, params);
5723
5943
  },
5724
5944
  array() {
5725
- return array(this);
5945
+ return array$1(this);
5726
5946
  },
5727
5947
  or(arg) {
5728
- return union([this, arg]);
5948
+ return union$1([this, arg]);
5729
5949
  },
5730
5950
  and(arg) {
5731
5951
  return intersection(this, arg);
@@ -5871,7 +6091,7 @@ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
5871
6091
  inst.time = (params) => inst.check(time(params));
5872
6092
  inst.duration = (params) => inst.check(duration(params));
5873
6093
  });
5874
- function string(params) {
6094
+ function string$1(params) {
5875
6095
  return _string(ZodString, params);
5876
6096
  }
5877
6097
  const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
@@ -6000,10 +6220,10 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
6000
6220
  return this.check(_lte(value, params));
6001
6221
  },
6002
6222
  int(params) {
6003
- return this.check(int(params));
6223
+ return this.check(int$1(params));
6004
6224
  },
6005
6225
  safe(params) {
6006
- return this.check(int(params));
6226
+ return this.check(int$1(params));
6007
6227
  },
6008
6228
  positive(params) {
6009
6229
  return this.check(_gt(0, params));
@@ -6036,14 +6256,14 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
6036
6256
  inst.isFinite = true;
6037
6257
  inst.format = bag.format ?? null;
6038
6258
  });
6039
- function number(params) {
6259
+ function number$1(params) {
6040
6260
  return _number(ZodNumber, params);
6041
6261
  }
6042
6262
  const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
6043
6263
  $ZodNumberFormat.init(inst, def);
6044
6264
  ZodNumber.init(inst, def);
6045
6265
  });
6046
- function int(params) {
6266
+ function int$1(params) {
6047
6267
  return _int(ZodNumberFormat, params);
6048
6268
  }
6049
6269
  const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
@@ -6059,8 +6279,8 @@ const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
6059
6279
  ZodType.init(inst, def);
6060
6280
  inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json);
6061
6281
  });
6062
- function _null(params) {
6063
- return _null$1(ZodNull, params);
6282
+ function _null$1(params) {
6283
+ return _null$2(ZodNull, params);
6064
6284
  }
6065
6285
  const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
6066
6286
  $ZodUnknown.init(inst, def);
@@ -6075,7 +6295,7 @@ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
6075
6295
  ZodType.init(inst, def);
6076
6296
  inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
6077
6297
  });
6078
- function never(params) {
6298
+ function never$1(params) {
6079
6299
  return _never(ZodNever, params);
6080
6300
  }
6081
6301
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
@@ -6101,7 +6321,7 @@ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
6101
6321
  },
6102
6322
  });
6103
6323
  });
6104
- function array(element, params) {
6324
+ function array$1(element, params) {
6105
6325
  return _array(ZodArray, element, params);
6106
6326
  }
6107
6327
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
@@ -6125,7 +6345,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
6125
6345
  return this.clone({ ...this._zod.def, catchall: unknown() });
6126
6346
  },
6127
6347
  strict() {
6128
- return this.clone({ ...this._zod.def, catchall: never() });
6348
+ return this.clone({ ...this._zod.def, catchall: never$1() });
6129
6349
  },
6130
6350
  strip() {
6131
6351
  return this.clone({ ...this._zod.def, catchall: undefined });
@@ -6176,7 +6396,7 @@ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
6176
6396
  inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
6177
6397
  inst.options = def.options;
6178
6398
  });
6179
- function union(options, params) {
6399
+ function union$1(options, params) {
6180
6400
  return new ZodUnion({
6181
6401
  type: "union",
6182
6402
  options: options,
@@ -6220,7 +6440,7 @@ function record$1(keyType, valueType, params) {
6220
6440
  if (!valueType || !valueType._zod) {
6221
6441
  return new ZodRecord({
6222
6442
  type: "record",
6223
- keyType: string(),
6443
+ keyType: string$1(),
6224
6444
  valueType: keyType,
6225
6445
  ...normalizeParams(valueType),
6226
6446
  });
@@ -6294,7 +6514,7 @@ const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
6294
6514
  },
6295
6515
  });
6296
6516
  });
6297
- function literal(value, params) {
6517
+ function literal$1(value, params) {
6298
6518
  return new ZodLiteral({
6299
6519
  type: "literal",
6300
6520
  values: Array.isArray(value) ? value : [value],
@@ -6350,7 +6570,7 @@ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
6350
6570
  inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
6351
6571
  inst.unwrap = () => inst._zod.def.innerType;
6352
6572
  });
6353
- function optional(innerType) {
6573
+ function optional$1(innerType) {
6354
6574
  return new ZodOptional({
6355
6575
  type: "optional",
6356
6576
  innerType: innerType,
@@ -6491,7 +6711,7 @@ function superRefine(fn, params) {
6491
6711
  }
6492
6712
  function json(params) {
6493
6713
  const jsonSchema = lazy(() => {
6494
- 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)]);
6495
6715
  });
6496
6716
  return jsonSchema;
6497
6717
  }
@@ -6564,7 +6784,7 @@ var viewElevationSchema = _enum(["flat", "raised"]);
6564
6784
  var viewWidthSchema = _enum(["auto", "fill"]);
6565
6785
  var viewBoxSizeSchema = _enum(["md", "hero"]);
6566
6786
  var viewHeightSchema = _enum(["data-tile"]);
6567
- var viewGridColumnsSchema = union([literal(2), literal(3), literal(4)]);
6787
+ var viewGridColumnsSchema = union$1([literal$1(2), literal$1(3), literal$1(4)]);
6568
6788
  var viewTextVariantSchema = _enum([
6569
6789
  "display",
6570
6790
  "title",
@@ -6609,7 +6829,7 @@ var viewImageSizeSchema = _enum([
6609
6829
  "landscape-compact",
6610
6830
  "landscape-content"
6611
6831
  ]);
6612
- var viewIconSizeSchema = union([literal(16), literal(20), literal(24)]);
6832
+ var viewIconSizeSchema = union$1([literal$1(16), literal$1(20), literal$1(24)]);
6613
6833
  var viewIconColorSchema = _enum([
6614
6834
  "default",
6615
6835
  "secondary",
@@ -6629,28 +6849,28 @@ var viewImageOverlaySchema = _enum([
6629
6849
  var viewListVariantSchema = _enum(["media", "plain", "compact"]);
6630
6850
  var viewCarouselPaginationSchema = _enum(["none", "bullets", "fraction"]);
6631
6851
  var viewCarouselPaginationPlacementSchema = _enum(["inside", "outside"]);
6632
- var viewCarouselSlidesPerViewSchema = union([literal(1), literal(2), literal(3)]);
6852
+ var viewCarouselSlidesPerViewSchema = union$1([literal$1(1), literal$1(2), literal$1(3)]);
6633
6853
  var viewTransitionEffectSchema = _enum(["crossfade", "morph"]);
6634
6854
  var viewTransitionSchema = object({
6635
6855
  /** 新旧内容仅交叉淡化,或同时执行轻量位移与缩放变换。 */
6636
6856
  effect: viewTransitionEffectSchema
6637
6857
  });
6638
- var nodeIdSchema = string().trim().min(1).max(120);
6858
+ var nodeIdSchema = string$1().trim().min(1).max(120);
6639
6859
  var viewActionSchema = object({
6640
6860
  /** 完整 Command id。 */
6641
- commandId: string().trim().min(1).max(120),
6861
+ commandId: string$1().trim().min(1).max(120),
6642
6862
  /** Command 的 JSON 输入。 */
6643
6863
  input: json().optional(),
6644
6864
  /** 提交时并入 `input` 的用户输入绑定;键是 input 字段名,值是 `textField` 节点 id。 */
6645
- 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, {
6646
6866
  error: "\u5355\u4E2A\u52A8\u4F5C\u7ED1\u5B9A\u7684\u8F93\u5165\u5B57\u6BB5\u8FC7\u591A"
6647
6867
  }).optional()
6648
6868
  });
6649
- var textValueSchema = string().max(VIEW_BUDGET.maxTextLength);
6650
- 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);
6651
6871
  var viewMeterSegmentSchema = object({
6652
6872
  /** 该数据段占整个容量的比例,值域 (0,1]。 */
6653
- value: number().positive().max(1),
6873
+ value: number$1().positive().max(1),
6654
6874
  /** 数据段的可访问说明。 */
6655
6875
  label: shortTextSchema,
6656
6876
  /** 数据段语气;缺省使用宿主上下文强调色。 */
@@ -6658,37 +6878,37 @@ var viewMeterSegmentSchema = object({
6658
6878
  });
6659
6879
  var viewBarChartItemSchema = object({
6660
6880
  /** 分类标签,例如星期“一”。 */
6661
- label: string().trim().min(1).max(20),
6881
+ label: string$1().trim().min(1).max(20),
6662
6882
  /** 非负原始值;宿主只按同组最大值归一化,不改变数据口径。 */
6663
- value: number().finite().nonnegative(),
6883
+ value: number$1().finite().nonnegative(),
6664
6884
  /** 精确值文本,例如“2 小时 30 分”。 */
6665
- valueLabel: string().trim().min(1).max(80).optional()
6885
+ valueLabel: string$1().trim().min(1).max(80).optional()
6666
6886
  });
6667
6887
  var viewTextSpanSchema = object({
6668
6888
  /** 片段文本;全部片段拼接后必须与所属节点的 `value` 完全一致。 */
6669
- text: string().min(1).max(VIEW_BUDGET.maxTextLength),
6889
+ text: string$1().min(1).max(VIEW_BUDGET.maxTextLength),
6670
6890
  /** 叠加在该片段上的语义标记;缺省即为普通文本。 */
6671
- marks: array(viewTextMarkSchema).max(4).optional()
6891
+ marks: array$1(viewTextMarkSchema).max(4).optional()
6672
6892
  });
6673
6893
  var viewImageFallbackSchema = object({
6674
6894
  /** 缺图时复用宿主当前应用的缓存模糊背景;不请求远程资源,缺省沿用图标或文本回退。 */
6675
- source: literal("app-ambient").optional(),
6895
+ source: literal$1("app-ambient").optional(),
6676
6896
  /** 回退图标名;宿主无法识别时退回文本。 */
6677
- icon: string().trim().min(1).max(80).optional(),
6897
+ icon: string$1().trim().min(1).max(80).optional(),
6678
6898
  /** 回退文本。 */
6679
- text: string().trim().max(120).optional()
6899
+ text: string$1().trim().max(120).optional()
6680
6900
  });
6681
6901
  var viewFieldItemSchema = object({
6682
6902
  label: shortTextSchema,
6683
- value: string().max(400).optional(),
6684
- placeholder: string().trim().max(120).optional()
6903
+ value: string$1().max(400).optional(),
6904
+ placeholder: string$1().trim().max(120).optional()
6685
6905
  });
6686
6906
  var viewListItemActionSchema = object({
6687
6907
  text: shortTextSchema,
6688
6908
  variant: viewButtonVariantSchema.optional(),
6689
6909
  tone: viewToneSchema.optional(),
6690
6910
  disabled: boolean().optional(),
6691
- disabledReason: string().trim().max(200).optional(),
6911
+ disabledReason: string$1().trim().max(200).optional(),
6692
6912
  action: viewActionSchema.optional()
6693
6913
  });
6694
6914
  var viewListItemBadgeSchema = object({
@@ -6698,9 +6918,9 @@ var viewListItemBadgeSchema = object({
6698
6918
  var viewListItemSchema = object({
6699
6919
  id: nodeIdSchema,
6700
6920
  title: shortTextSchema,
6701
- subtitle: string().trim().max(400).optional(),
6702
- meta: string().trim().max(120).optional(),
6703
- 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(),
6704
6924
  imageFallback: viewImageFallbackSchema.optional(),
6705
6925
  /** 媒体位外形;缺省保持历史横向缩略图。 */
6706
6926
  imageShape: viewListItemImageShapeSchema.optional(),
@@ -6711,7 +6931,7 @@ var viewListItemSchema = object({
6711
6931
  /** 列表图片是否以颜色传达业务含义;不影响卡片主次下的原色显示。 */
6712
6932
  imageColorRole: viewImageColorRoleSchema.optional(),
6713
6933
  /** 行首图标名;宿主不认识该名称时不渲染图标位。 */
6714
- icon: string().trim().min(1).max(80).optional(),
6934
+ icon: string$1().trim().min(1).max(80).optional(),
6715
6935
  /** 条目整体语气;作用于标题与行首图标。 */
6716
6936
  tone: viewToneSchema.optional(),
6717
6937
  /** 行尾状态标记;与 `meta` 并存时标记在前。 */
@@ -6721,7 +6941,7 @@ var viewListItemSchema = object({
6721
6941
  /** 当前不可激活。 */
6722
6942
  disabled: boolean().optional(),
6723
6943
  /** 不可激活的可读原因。 */
6724
- disabledReason: string().trim().max(200).optional(),
6944
+ disabledReason: string$1().trim().max(200).optional(),
6725
6945
  action: viewActionSchema.optional(),
6726
6946
  /** 行尾次级动作;宿主把它渲染成与整行动作并列的独立按钮。 */
6727
6947
  secondaryAction: viewListItemActionSchema.optional()
@@ -6729,7 +6949,7 @@ var viewListItemSchema = object({
6729
6949
  var viewRegionNoticeSchema = object({
6730
6950
  /** 稳定键;用户关闭后按该键记住,换一条提示会重新出现。 */
6731
6951
  id: nodeIdSchema,
6732
- text: string().trim().min(1).max(200),
6952
+ text: string$1().trim().min(1).max(200),
6733
6953
  tone: viewToneSchema.optional(),
6734
6954
  /** 是否允许用户关闭;关闭状态属于宿主自持呈现状态。 */
6735
6955
  dismissible: boolean().optional()
@@ -6805,18 +7025,18 @@ var layoutShape = {
6805
7025
  var boxShape = {
6806
7026
  ...layoutShape,
6807
7027
  action: viewActionSchema.optional(),
6808
- accessibilityLabel: string().min(1).max(80).optional(),
7028
+ accessibilityLabel: string$1().min(1).max(80).optional(),
6809
7029
  interaction: _enum(["soft", "media", "text", "content"]).optional()
6810
7030
  };
6811
7031
  var meterNodeSchema = object({
6812
7032
  ...baseNodeShape,
6813
- type: literal("meter"),
7033
+ type: literal$1("meter"),
6814
7034
  /** 比例值,值域 [0,1];超出值域是插件缺陷,按 schema 错误稳定失败。 */
6815
- value: number().min(0).max(1),
7035
+ value: number$1().min(0).max(1),
6816
7036
  /** 可访问名称;缺省时由宿主以百分比文本兜底。 */
6817
7037
  label: shortTextSchema.optional(),
6818
7038
  tone: viewToneSchema.optional(),
6819
- segments: array(viewMeterSegmentSchema).min(1).max(8).optional(),
7039
+ segments: array$1(viewMeterSegmentSchema).min(1).max(8).optional(),
6820
7040
  size: viewMeterSizeSchema.optional(),
6821
7041
  ticks: boolean().optional()
6822
7042
  }).refine(
@@ -6830,31 +7050,31 @@ var knownNodeSchema = lazy(
6830
7050
  () => discriminatedUnion("type", [
6831
7051
  object({
6832
7052
  ...boxShape,
6833
- type: literal("vstack"),
6834
- children: array(viewNodeSchema)
7053
+ type: literal$1("vstack"),
7054
+ children: array$1(viewNodeSchema)
6835
7055
  }),
6836
7056
  object({
6837
7057
  ...boxShape,
6838
- type: literal("hstack"),
7058
+ type: literal$1("hstack"),
6839
7059
  wrap: boolean().optional(),
6840
- children: array(viewNodeSchema)
7060
+ children: array$1(viewNodeSchema)
6841
7061
  }),
6842
7062
  object({
6843
7063
  ...boxShape,
6844
- type: literal("zstack"),
6845
- children: array(viewNodeSchema)
7064
+ type: literal$1("zstack"),
7065
+ children: array$1(viewNodeSchema)
6846
7066
  }),
6847
7067
  object({
6848
7068
  ...boxShape,
6849
- type: literal("grid"),
7069
+ type: literal$1("grid"),
6850
7070
  columns: viewGridColumnsSchema,
6851
- children: array(viewNodeSchema)
7071
+ children: array$1(viewNodeSchema)
6852
7072
  }),
6853
7073
  object({
6854
7074
  id: nodeIdSchema,
6855
- type: literal("carousel"),
7075
+ type: literal$1("carousel"),
6856
7076
  label: shortTextSchema,
6857
- children: array(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
7077
+ children: array$1(viewNodeSchema).min(1).max(VIEW_BUDGET.maxCarouselSlides),
6858
7078
  fallback: viewNodeSchema.optional(),
6859
7079
  slidesPerView: viewCarouselSlidesPerViewSchema.optional(),
6860
7080
  gap: viewGapSchema.optional(),
@@ -6863,36 +7083,36 @@ var knownNodeSchema = lazy(
6863
7083
  navigation: boolean().optional(),
6864
7084
  pagination: viewCarouselPaginationSchema.optional(),
6865
7085
  paginationPlacement: viewCarouselPaginationPlacementSchema.optional(),
6866
- autoplayDelay: number().int().min(2e3).max(3e4).optional()
7086
+ autoplayDelay: number$1().int().min(2e3).max(3e4).optional()
6867
7087
  }),
6868
7088
  object({
6869
7089
  ...layoutShape,
6870
- type: literal("group"),
7090
+ type: literal$1("group"),
6871
7091
  title: shortTextSchema.optional(),
6872
7092
  collapsible: boolean().optional(),
6873
7093
  defaultExpanded: boolean().optional(),
6874
7094
  stickyTitle: boolean().optional(),
6875
- children: array(viewNodeSchema)
7095
+ children: array$1(viewNodeSchema)
6876
7096
  }),
6877
- object({ ...baseNodeShape, type: literal("spacer") }),
7097
+ object({ ...baseNodeShape, type: literal$1("spacer") }),
6878
7098
  object({
6879
7099
  ...baseNodeShape,
6880
- type: literal("text"),
7100
+ type: literal$1("text"),
6881
7101
  value: textValueSchema,
6882
- spans: array(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
7102
+ spans: array$1(viewTextSpanSchema).max(VIEW_BUDGET.maxTextSpans).optional(),
6883
7103
  variant: viewTextVariantSchema.optional(),
6884
7104
  weight: viewTextWeightSchema.optional(),
6885
7105
  tone: viewTextToneSchema.optional(),
6886
7106
  paint: viewTextPaintSchema.optional(),
6887
- maxLines: number().int().positive().max(50).optional(),
7107
+ maxLines: number$1().int().positive().max(50).optional(),
6888
7108
  reserveLines: boolean().optional()
6889
7109
  }),
6890
7110
  object({
6891
7111
  ...baseNodeShape,
6892
- type: literal("image"),
7112
+ type: literal$1("image"),
6893
7113
  /** 图片资源地址;无原图且声明 app-ambient 回退时,用 app-ambient://current 直接选择宿主缓存。 */
6894
- src: string().trim().min(1).max(2e3),
6895
- aspectRatio: string().trim().max(20).optional(),
7114
+ src: string$1().trim().min(1).max(2e3),
7115
+ aspectRatio: string$1().trim().max(20).optional(),
6896
7116
  size: viewImageSizeSchema.optional(),
6897
7117
  fit: viewImageFitSchema.optional(),
6898
7118
  appearance: viewImageAppearanceSchema.optional(),
@@ -6903,34 +7123,34 @@ var knownNodeSchema = lazy(
6903
7123
  }),
6904
7124
  object({
6905
7125
  ...baseNodeShape,
6906
- type: literal("icon"),
6907
- name: string().trim().min(1).max(80),
7126
+ type: literal$1("icon"),
7127
+ name: string$1().trim().min(1).max(80),
6908
7128
  size: viewIconSizeSchema.optional(),
6909
7129
  color: viewIconColorSchema.optional(),
6910
7130
  tone: viewToneSchema.optional()
6911
7131
  }),
6912
7132
  object({
6913
7133
  ...baseNodeShape,
6914
- type: literal("fields"),
6915
- items: array(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
7134
+ type: literal$1("fields"),
7135
+ items: array$1(viewFieldItemSchema).max(VIEW_BUDGET.maxFieldItems)
6916
7136
  }),
6917
7137
  object({
6918
7138
  ...baseNodeShape,
6919
- type: literal("list"),
7139
+ type: literal$1("list"),
6920
7140
  variant: viewListVariantSchema.optional(),
6921
- initialCount: number().int().positive().max(VIEW_BUDGET.maxListItems).optional(),
6922
- 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)
6923
7143
  }),
6924
7144
  object({
6925
7145
  ...baseNodeShape,
6926
- type: literal("badge"),
7146
+ type: literal$1("badge"),
6927
7147
  text: shortTextSchema,
6928
7148
  tone: _enum([...viewToneSchema.options, "primary", "primary-media"]).optional()
6929
7149
  }),
6930
- object({ ...baseNodeShape, type: literal("divider") }),
7150
+ object({ ...baseNodeShape, type: literal$1("divider") }),
6931
7151
  object({
6932
7152
  ...baseNodeShape,
6933
- type: literal("button"),
7153
+ type: literal$1("button"),
6934
7154
  text: shortTextSchema,
6935
7155
  variant: viewButtonVariantSchema.optional(),
6936
7156
  /**
@@ -6939,56 +7159,56 @@ var knownNodeSchema = lazy(
6939
7159
  */
6940
7160
  tone: viewToneSchema.optional(),
6941
7161
  disabled: boolean().optional(),
6942
- disabledReason: string().trim().max(200).optional(),
7162
+ disabledReason: string$1().trim().max(200).optional(),
6943
7163
  busy: boolean().optional(),
6944
7164
  action: viewActionSchema.optional()
6945
7165
  }),
6946
7166
  object({
6947
7167
  id: nodeIdSchema,
6948
- type: literal("switch"),
7168
+ type: literal$1("switch"),
6949
7169
  label: shortTextSchema,
6950
7170
  checked: boolean(),
6951
7171
  disabled: boolean().optional(),
6952
- disabledReason: string().trim().max(200).optional(),
7172
+ disabledReason: string$1().trim().max(200).optional(),
6953
7173
  busy: boolean().optional(),
6954
7174
  action: viewActionSchema.optional(),
6955
7175
  fallback: viewNodeSchema.optional()
6956
7176
  }),
6957
7177
  object({
6958
7178
  id: nodeIdSchema,
6959
- type: literal("expandable"),
6960
- collapsedLines: number().int().positive().max(50),
7179
+ type: literal$1("expandable"),
7180
+ collapsedLines: number$1().int().positive().max(50),
6961
7181
  expandText: shortTextSchema,
6962
7182
  collapseText: shortTextSchema,
6963
- children: array(viewNodeSchema)
7183
+ children: array$1(viewNodeSchema)
6964
7184
  }),
6965
7185
  object({
6966
7186
  id: nodeIdSchema,
6967
- type: literal("renderer"),
6968
- rendererViewId: string().trim().min(1).max(120),
7187
+ type: literal$1("renderer"),
7188
+ rendererViewId: string$1().trim().min(1).max(120),
6969
7189
  content: object({
6970
- resourceKey: string().trim().min(1).max(512),
7190
+ resourceKey: string$1().trim().min(1).max(512),
6971
7191
  space: _enum(["instance", "shared"]).optional()
6972
7192
  }).optional(),
6973
- aspectRatio: string().trim().max(20).optional(),
6974
- height: number().int().positive().max(2e3).optional()
7193
+ aspectRatio: string$1().trim().max(20).optional(),
7194
+ height: number$1().int().positive().max(2e3).optional()
6975
7195
  }),
6976
7196
  object({
6977
7197
  id: nodeIdSchema,
6978
- type: literal("frame"),
6979
- frameId: string().trim().min(1).max(120),
6980
- 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(),
6981
7201
  params: viewFrameParamsSchema.optional(),
6982
- aspectRatio: string().trim().max(20).optional(),
6983
- height: number().int().positive().max(2e3).optional()
7202
+ aspectRatio: string$1().trim().max(20).optional(),
7203
+ height: number$1().int().positive().max(2e3).optional()
6984
7204
  }),
6985
7205
  meterNodeSchema,
6986
7206
  object({
6987
7207
  ...baseNodeShape,
6988
- type: literal("radialProgress"),
6989
- value: number().min(0).max(1),
7208
+ type: literal$1("radialProgress"),
7209
+ value: number$1().min(0).max(1),
6990
7210
  label: shortTextSchema,
6991
- valueLabel: string().trim().min(1).max(40).optional(),
7211
+ valueLabel: string$1().trim().min(1).max(40).optional(),
6992
7212
  centerGraphic: viewRadialProgressCenterGraphicSchema.optional(),
6993
7213
  size: viewRadialProgressSizeSchema.optional(),
6994
7214
  tone: viewToneSchema.optional(),
@@ -6996,17 +7216,17 @@ var knownNodeSchema = lazy(
6996
7216
  }),
6997
7217
  object({
6998
7218
  ...baseNodeShape,
6999
- type: literal("sparkline"),
7219
+ type: literal$1("sparkline"),
7000
7220
  /** 原始数值序列,宿主归一化绘制;少于 2 个点不构成趋势,由 schema 拒绝。 */
7001
- values: array(number()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
7221
+ values: array$1(number$1()).min(2).max(VIEW_BUDGET.maxSparklinePoints),
7002
7222
  /** 可访问名称;缺省时由宿主以末值文本兜底。 */
7003
7223
  label: shortTextSchema.optional(),
7004
7224
  tone: viewToneSchema.optional()
7005
7225
  }),
7006
7226
  object({
7007
7227
  ...baseNodeShape,
7008
- type: literal("barChart"),
7009
- 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),
7010
7230
  label: shortTextSchema,
7011
7231
  size: viewBarChartSizeSchema.optional(),
7012
7232
  tone: viewToneSchema.optional(),
@@ -7014,27 +7234,27 @@ var knownNodeSchema = lazy(
7014
7234
  }),
7015
7235
  object({
7016
7236
  id: nodeIdSchema,
7017
- type: literal("tabs"),
7018
- items: array(
7237
+ type: literal$1("tabs"),
7238
+ items: array$1(
7019
7239
  object({
7020
7240
  id: nodeIdSchema,
7021
7241
  label: shortTextSchema,
7022
- badge: string().trim().max(40).optional(),
7023
- children: array(viewNodeSchema)
7242
+ badge: string$1().trim().max(40).optional(),
7243
+ children: array$1(viewNodeSchema)
7024
7244
  })
7025
7245
  ).min(1).max(VIEW_BUDGET.maxTabItems),
7026
7246
  fallback: viewNodeSchema.optional()
7027
7247
  }),
7028
7248
  object({
7029
7249
  id: nodeIdSchema,
7030
- type: literal("textField"),
7250
+ type: literal$1("textField"),
7031
7251
  label: shortTextSchema,
7032
- placeholder: string().trim().max(120).optional(),
7033
- value: string().max(VIEW_BUDGET.maxTextFieldLength).optional(),
7034
- 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(),
7035
7255
  disabled: boolean().optional(),
7036
7256
  clearable: boolean().optional(),
7037
- resetToken: string().trim().max(120).optional(),
7257
+ resetToken: string$1().trim().max(120).optional(),
7038
7258
  submitAction: viewActionSchema.optional(),
7039
7259
  fallback: viewNodeSchema.optional()
7040
7260
  })
@@ -7042,13 +7262,13 @@ var knownNodeSchema = lazy(
7042
7262
  );
7043
7263
  var unknownNodeSchema = lazy(
7044
7264
  () => looseObject({
7045
- type: string().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7265
+ type: string$1().trim().min(1).max(80).refine((type) => !isKnownViewNodeType(type), {
7046
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"
7047
7267
  }),
7048
7268
  fallback: viewNodeSchema.optional()
7049
7269
  })
7050
7270
  );
7051
- var viewNodeSchema = union([knownNodeSchema, unknownNodeSchema]);
7271
+ var viewNodeSchema = union$1([knownNodeSchema, unknownNodeSchema]);
7052
7272
  var viewRegionStatusSchema = _enum(["ready", "loading", "empty", "error"]);
7053
7273
  var viewRetryPresentationSchema = _enum(["button", "inline"]);
7054
7274
  var viewRegionSchema = object({
@@ -7060,15 +7280,15 @@ var viewRegionSchema = object({
7060
7280
  /** 仅在 `status` 为 `error` 时有意义。 */
7061
7281
  retry: viewActionSchema.optional(),
7062
7282
  /** 覆盖宿主默认错误文案;仅用于 `error` Region。 */
7063
- errorText: string().trim().min(1).max(200).optional(),
7283
+ errorText: string$1().trim().min(1).max(200).optional(),
7064
7284
  /** 重试动作的宿主呈现方式;`inline` 使用 Accent 文字动作。 */
7065
7285
  retryPresentation: viewRetryPresentationSchema.optional(),
7066
7286
  /** 覆盖宿主默认空态文案;显式空字符串表示只呈现业务视觉锚点。 */
7067
- emptyText: string().trim().max(200).optional(),
7287
+ emptyText: string$1().trim().max(200).optional(),
7068
7288
  /** 顶部瞬时说明;出现与消失不参与节点预算,也不引起内容重排。 */
7069
7289
  notice: viewRegionNoticeSchema.optional(),
7070
7290
  /** `ready` 时是真实内容,`loading` 时是占位蓝图,`empty/error` 时可选保留业务视觉锚点。 */
7071
- nodes: array(viewNodeSchema).default([])
7291
+ nodes: array$1(viewNodeSchema).default([])
7072
7292
  }).superRefine((region2, context) => {
7073
7293
  if (region2.refreshing === true && region2.status !== "ready") {
7074
7294
  context.addIssue({
@@ -7101,10 +7321,10 @@ var viewRegionSchema = object({
7101
7321
  });
7102
7322
  object({
7103
7323
  /** 文档 schema 的整数 major 版本。 */
7104
- schema: number().int().positive(),
7324
+ schema: number$1().int().positive(),
7105
7325
  /** Runtime 更新文档时由包内 renderer 执行的渐进增强过渡。 */
7106
7326
  transition: viewTransitionSchema.optional(),
7107
- regions: array(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7327
+ regions: array$1(viewRegionSchema).max(VIEW_BUDGET.maxRegions)
7108
7328
  });
7109
7329
  function fail(message) {
7110
7330
  throw new Error(`workspaceCards: ${message}`);
@@ -7165,6 +7385,317 @@ function validateWorkspaceCardParams(value) {
7165
7385
  visit(value);
7166
7386
  }
7167
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
+
7168
7699
  /** 仅 SDK 内部拥有状态更新入口,业务只可读。 */
7169
7700
  function createWorkspaceCardsModule(client) {
7170
7701
  let context = null;
@@ -7513,7 +8044,7 @@ function createMessageId() {
7513
8044
  /** 构建时替换为当前发布包的实际版本。 */
7514
8045
  const HB_SDK_VERSION = typeof undefined === 'string'
7515
8046
  ? undefined
7516
- : '0.9.6-alpha.11';
8047
+ : '0.9.6-alpha.13';
7517
8048
 
7518
8049
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
7519
8050
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
@@ -7559,8 +8090,17 @@ function readRecord$1(value) {
7559
8090
  }
7560
8091
 
7561
8092
  const DEFAULT_TIMEOUT = 10000;
7562
- // 选择器等待、截图延迟、登录和关注确认由 Host 管理,使用长操作生命周期,不设固定总时长。
7563
- const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SCREENSHOT_LONG_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
+ }
7564
8104
  const HANDSHAKE_RETRY_INTERVAL = 250;
7565
8105
  /** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
7566
8106
  class MiniProgramBridgeClient {
@@ -7643,7 +8183,7 @@ class MiniProgramBridgeClient {
7643
8183
  }
7644
8184
  /** 调用父容器开放能力。 */
7645
8185
  async request(method, ...args) {
7646
- 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);
7647
8187
  }
7648
8188
  /** 发起不使用固定总时长 timer 的长操作。 */
7649
8189
  async requestOperation(method, payload, options = {}) {
@@ -11647,8 +12187,327 @@ function getSteamGameList(requester, options) {
11647
12187
  return requester.request(USER_GET_STEAM_GAME_LIST_METHOD, options);
11648
12188
  }
11649
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
+
11650
12507
  function createUserModule(requester) {
11651
12508
  return {
12509
+ games: createUserGamesModule(requester),
12510
+ dataPermission: createUserDataPermissionModule(requester),
11652
12511
  requestFollowAuthor: () => requestFollowAuthor(requester),
11653
12512
  getFollowStatus: () => getFollowStatus(requester),
11654
12513
  showAppreciation: () => requester.request(USER_SHOW_APPRECIATION_METHOD),
@@ -11935,7 +12794,10 @@ class MiniProgramSDK {
11935
12794
  navigation;
11936
12795
  /** 云端数据相关开放能力。 */
11937
12796
  cloud;
11938
- /** 查询、同步并读取当前用户的 Steam 游戏存档。 */
12797
+ /**
12798
+ * 查询、同步并读取当前用户的 Steam 游戏存档。
12799
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
12800
+ */
11939
12801
  gameSaves;
11940
12802
  /** 受管桌面程序能力。 */
11941
12803
  companion;
@@ -12375,6 +13237,16 @@ const auth = {
12375
13237
  };
12376
13238
  /** 默认 SDK 实例的用户资料模块。 */
12377
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
+ },
12378
13250
  requestFollowAuthor: () => getDefaultSDK().user.requestFollowAuthor(),
12379
13251
  getFollowStatus: () => getDefaultSDK().user.getFollowStatus(),
12380
13252
  showAppreciation: () => getDefaultSDK().user.showAppreciation(),
@@ -12438,13 +13310,16 @@ const navigation = {
12438
13310
  reload: () => getDefaultSDK().navigation.reload(),
12439
13311
  openAppPage: (options) => getDefaultSDK().navigation.openAppPage(options),
12440
13312
  };
12441
- /** 默认 SDK 实例的 cloud 模块。 */
12442
- /** 当前用户的游戏存档能力。 */
13313
+ /**
13314
+ * 当前用户的游戏存档能力。
13315
+ * @deprecated Since 0.9.6-alpha.12. 请改用 {@link UserGamesModule.get},使用返回对象的 saves 能力;此入口将在 0.10.0 移除。
13316
+ */
12443
13317
  const gameSaves = {
12444
13318
  list: (gameId) => getDefaultSDK().gameSaves.list(gameId),
12445
13319
  getLatestStructuredData: (gameId) => getDefaultSDK().gameSaves.getLatestStructuredData(gameId),
12446
13320
  sync: (gameId, options) => getDefaultSDK().gameSaves.sync(gameId, options),
12447
13321
  };
13322
+ /** 默认 SDK 实例的 cloud 模块。 */
12448
13323
  const cloud = {
12449
13324
  leaderboard: {
12450
13325
  submit: (options) => getDefaultSDK().cloud.leaderboard.submit(options),