@heybox/hb-sdk 0.10.0-alpha.2 → 0.10.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +13 -0
- package/dist/cli-chunks/{build-Be8QI9ma.cjs → build-DJvUpgCG.cjs} +8 -6
- package/dist/cli-chunks/{create-CaAGgJXF.cjs → create-CKFbAKsd.cjs} +2 -2
- package/dist/cli-chunks/{dev-BS8uwRH2.cjs → dev-DkQ3XT4g.cjs} +19 -11
- package/dist/cli-chunks/{doctor-CgdrOrS5.cjs → doctor-CrDV0t0X.cjs} +1 -1
- package/dist/cli-chunks/{game-binding-guide-DX8uXx0V.cjs → game-binding-guide-Du9jYSv0.cjs} +3 -3
- package/dist/cli-chunks/{game-bindings-CjI0oA1t.cjs → game-bindings-DyUsgTvm.cjs} +4 -4
- package/dist/cli-chunks/{games-C8A0PCo-.cjs → games-60o0JlU1.cjs} +1 -1
- package/dist/cli-chunks/{index-BTOX41Vr.cjs → index-B3bDDBnX.cjs} +1 -1
- package/dist/cli-chunks/{index-CMbVUUpA.cjs → index-oQnW71g6.cjs} +24 -22
- package/dist/cli-chunks/{index.esm-D7A_j5MA.cjs → index.esm-B8H9EwB1.cjs} +67 -0
- package/dist/cli-chunks/{index.esm-CIBT3Na1.cjs → index.esm-C5mTEO5-.cjs} +9 -9
- package/dist/cli-chunks/{login-BWuLgJWT.cjs → login-81EUI3Tp.cjs} +1 -1
- package/dist/cli-chunks/{project-vite-FWtHl3XL.cjs → project-vite-BL7txpEs.cjs} +1 -1
- package/dist/cli-chunks/{remote-R1jgvh-Z.cjs → remote-BaistJfP.cjs} +13 -9
- package/dist/cli-chunks/{runtime-permission-env-BuXOApO4.cjs → runtime-permission-env-ChCGtenG.cjs} +392 -113
- package/dist/cli-chunks/{skill-EM-Uv3Rj.cjs → skill-BQUjMV7k.cjs} +2 -2
- package/dist/cli-chunks/{version-BXh-cltM.cjs → version-CUuM16X6.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-Dho-QHhS.js +224 -0
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-BXVw6d6N.js → desktop-app-launch-CIC_pBdX.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-CABlopeJ.js → index-D1Iqs-0N.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +284 -1
- package/dist/index.esm.js +284 -1
- package/dist/miniapp-publish.cjs.js +215 -116
- package/dist/miniapp-publish.esm.js +214 -117
- package/dist/protocol.cjs.js +57 -0
- package/dist/protocol.esm.js +57 -0
- package/dist/vite.cjs.js +238 -96
- package/dist/vite.esm.js +238 -96
- package/package.json +7 -7
- package/skill/skill.json +4 -4
- package/types/index.d.ts +76 -3
- package/types/miniapp-publish/index.d.ts +30 -15
- package/types/vite/index.d.ts +7 -0
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-CpphzCg4.js +0 -224
|
@@ -19,6 +19,13 @@ const POST_WRITE_METHODS = [
|
|
|
19
19
|
'post.comments.delete',
|
|
20
20
|
'post.comments.setLiked',
|
|
21
21
|
];
|
|
22
|
+
const CLOUD_ROOMS_LIST_METHOD = 'cloud.rooms.list';
|
|
23
|
+
const CLOUD_ROOMS_CREATE_METHOD = 'cloud.rooms.create';
|
|
24
|
+
const CLOUD_ROOMS_JOIN_METHOD = 'cloud.rooms.join';
|
|
25
|
+
const CLOUD_ROOMS_SEND_METHOD = 'cloud.rooms.send';
|
|
26
|
+
const CLOUD_ROOMS_LEAVE_METHOD = 'cloud.rooms.leave';
|
|
27
|
+
const CLOUD_ROOMS_DISPOSE_METHOD = 'cloud.rooms.dispose';
|
|
28
|
+
const CLOUD_ROOMS_LIFECYCLE_METHOD = 'cloud.rooms.lifecycle';
|
|
22
29
|
|
|
23
30
|
/** 游戏资料内部 wire:业务方法由 SDK 映射为精确资源请求。 */
|
|
24
31
|
const USER_GAMES_GET_OVERVIEW_METHOD = 'user.games.getOverview';
|
|
@@ -432,6 +439,55 @@ const COMPANION_SHOW_NOTIFICATION_METHOD = 'companion.showNotification';
|
|
|
432
439
|
requirement: { kind: 'none' },
|
|
433
440
|
risk: 'medium',
|
|
434
441
|
},
|
|
442
|
+
{
|
|
443
|
+
method: CLOUD_ROOMS_LIST_METHOD,
|
|
444
|
+
module: 'cloud',
|
|
445
|
+
capability: CLOUD_ROOMS_LIST_METHOD,
|
|
446
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
447
|
+
risk: 'medium',
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
method: CLOUD_ROOMS_CREATE_METHOD,
|
|
451
|
+
module: 'cloud',
|
|
452
|
+
capability: CLOUD_ROOMS_CREATE_METHOD,
|
|
453
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
454
|
+
risk: 'medium',
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
method: CLOUD_ROOMS_JOIN_METHOD,
|
|
458
|
+
module: 'cloud',
|
|
459
|
+
capability: CLOUD_ROOMS_JOIN_METHOD,
|
|
460
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
461
|
+
risk: 'medium',
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
method: CLOUD_ROOMS_SEND_METHOD,
|
|
465
|
+
module: 'cloud',
|
|
466
|
+
capability: CLOUD_ROOMS_SEND_METHOD,
|
|
467
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
468
|
+
risk: 'medium',
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
method: CLOUD_ROOMS_LEAVE_METHOD,
|
|
472
|
+
module: 'cloud',
|
|
473
|
+
capability: CLOUD_ROOMS_LEAVE_METHOD,
|
|
474
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
475
|
+
risk: 'medium',
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
method: CLOUD_ROOMS_DISPOSE_METHOD,
|
|
479
|
+
module: 'cloud',
|
|
480
|
+
capability: CLOUD_ROOMS_DISPOSE_METHOD,
|
|
481
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
482
|
+
risk: 'medium',
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
method: CLOUD_ROOMS_LIFECYCLE_METHOD,
|
|
486
|
+
module: 'cloud',
|
|
487
|
+
capability: CLOUD_ROOMS_LIFECYCLE_METHOD,
|
|
488
|
+
requirement: { kind: 'all', permissions: ['cloud_rooms'] },
|
|
489
|
+
risk: 'medium',
|
|
490
|
+
},
|
|
435
491
|
{
|
|
436
492
|
method: CLOUD_LEADERBOARD_SUBMIT_METHOD,
|
|
437
493
|
module: 'cloud',
|
|
@@ -754,6 +810,7 @@ const MINI_PROGRAM_PERMISSION_KEYS = [
|
|
|
754
810
|
'share',
|
|
755
811
|
'storage',
|
|
756
812
|
'cloud_storage',
|
|
813
|
+
'cloud_rooms',
|
|
757
814
|
'gameSaves',
|
|
758
815
|
'filesystem',
|
|
759
816
|
'media',
|
|
@@ -951,6 +1008,16 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
|
|
|
951
1008
|
methods: ['workspaceCards.requestRefresh'],
|
|
952
1009
|
conditions: ['需平台批准、Host 支持与有效执行租约;不隐式授予网络或存储权限。'],
|
|
953
1010
|
},
|
|
1011
|
+
{
|
|
1012
|
+
key: 'cloud_rooms',
|
|
1013
|
+
name: '实时动作房间',
|
|
1014
|
+
description: '在少人数房间内交换随包声明的结构化动作。',
|
|
1015
|
+
access: 'platform-approval',
|
|
1016
|
+
risk: 'medium',
|
|
1017
|
+
config: {},
|
|
1018
|
+
methods: ['cloud.rooms.list', 'cloud.rooms.create', 'cloud.rooms.join', 'cloud.rooms.send', 'cloud.rooms.leave', 'cloud.rooms.dispose', 'cloud.rooms.lifecycle'],
|
|
1019
|
+
conditions: ['仅允许当前版本房间协议中的动作和受限参数,不提供自由文字、文件或媒体传输。'],
|
|
1020
|
+
},
|
|
954
1021
|
{
|
|
955
1022
|
key: 'user_game_data',
|
|
956
1023
|
name: '游戏资料',
|
|
@@ -7630,23 +7697,6 @@ const definitions = {
|
|
|
7630
7697
|
"PhantomBladeZeroLocation": strictObject({ "map": string(), "mapName": string(), "x": number(), "y": number(), "z": number() }),
|
|
7631
7698
|
"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"]))]) })};
|
|
7632
7699
|
|
|
7633
|
-
/**
|
|
7634
|
-
* 校验项目配置或产物中的小程序类别。
|
|
7635
|
-
*
|
|
7636
|
-
* @param value - 待校验值,只接受 `tool`、`game`、`other` 或 `undefined`;不做 trim 或大小写转换。
|
|
7637
|
-
* @param sourceLabel - 错误消息中的字段来源,默认 `package.json#heybox.category`。
|
|
7638
|
-
* @returns 合法类别原值;输入 `undefined` 时返回 `undefined`,由发布流程另行检查是否必填。
|
|
7639
|
-
* @throws `Error` 输入为其他值(包括 null 或空字符串)时抛出带字段来源的错误。
|
|
7640
|
-
* @since 0.8.3
|
|
7641
|
-
*/
|
|
7642
|
-
function parseMiniappCategory(value, sourceLabel = 'package.json#heybox.category') {
|
|
7643
|
-
if (value === undefined)
|
|
7644
|
-
return undefined;
|
|
7645
|
-
if (value === 'tool' || value === 'game' || value === 'other')
|
|
7646
|
-
return value;
|
|
7647
|
-
throw new Error(`${sourceLabel} 必须是 tool、game 或 other`);
|
|
7648
|
-
}
|
|
7649
|
-
|
|
7650
7700
|
var re = {exports: {}};
|
|
7651
7701
|
|
|
7652
7702
|
var constants;
|
|
@@ -10432,6 +10482,139 @@ function requireSemver () {
|
|
|
10432
10482
|
|
|
10433
10483
|
var semverExports = requireSemver();
|
|
10434
10484
|
|
|
10485
|
+
const MINIAPP_PERMISSION_KEYS = MINI_PROGRAM_PERMISSION_KEYS;
|
|
10486
|
+
function parseMiniappPermissions(value, options) {
|
|
10487
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.permissions';
|
|
10488
|
+
if (!options.present) {
|
|
10489
|
+
if (requiresExplicitPermissions(options.sdkVersion)) {
|
|
10490
|
+
throw new Error(`${sourceLabel} 在 @heybox/hb-sdk ${options.sdkVersion} 中必须声明;无权限需求时请配置空对象 {}`);
|
|
10491
|
+
}
|
|
10492
|
+
return { declared: false };
|
|
10493
|
+
}
|
|
10494
|
+
if (!isRecord$3(value)) {
|
|
10495
|
+
throw new Error(`${sourceLabel} 必须是 JSON 对象`);
|
|
10496
|
+
}
|
|
10497
|
+
const knownKeys = new Set(MINIAPP_PERMISSION_KEYS);
|
|
10498
|
+
for (const key of Object.keys(value)) {
|
|
10499
|
+
if (!knownKeys.has(key))
|
|
10500
|
+
throw new Error(`${sourceLabel} 包含未知权限:${key}`);
|
|
10501
|
+
}
|
|
10502
|
+
const permissions = {};
|
|
10503
|
+
for (const key of MINIAPP_PERMISSION_KEYS) {
|
|
10504
|
+
if (!Object.prototype.hasOwnProperty.call(value, key))
|
|
10505
|
+
continue;
|
|
10506
|
+
const declaration = value[key];
|
|
10507
|
+
const itemLabel = `${sourceLabel}.${key}`;
|
|
10508
|
+
if (!isRecord$3(declaration))
|
|
10509
|
+
throw new Error(`${itemLabel} 必须是 JSON 对象`);
|
|
10510
|
+
const definition = MINI_PROGRAM_PERMISSION_CATALOG.find((item) => item.key === key);
|
|
10511
|
+
if (!definition)
|
|
10512
|
+
throw new Error(`权限目录缺少定义:${key}`);
|
|
10513
|
+
const allowedFields = new Set(['enabled', ...Object.keys(definition.config)]);
|
|
10514
|
+
for (const field of Object.keys(declaration)) {
|
|
10515
|
+
if (!allowedFields.has(field))
|
|
10516
|
+
throw new Error(`${itemLabel} 包含未知字段:${field}`);
|
|
10517
|
+
}
|
|
10518
|
+
if (typeof declaration.enabled !== 'boolean')
|
|
10519
|
+
throw new Error(`${itemLabel}.enabled 必须是 boolean`);
|
|
10520
|
+
let useOfficialDomain = false;
|
|
10521
|
+
if (key === 'network') {
|
|
10522
|
+
if (declaration.useOfficialDomain !== undefined && typeof declaration.useOfficialDomain !== 'boolean') {
|
|
10523
|
+
throw new Error(`${itemLabel}.useOfficialDomain 必须是 boolean`);
|
|
10524
|
+
}
|
|
10525
|
+
useOfficialDomain = declaration.useOfficialDomain === true;
|
|
10526
|
+
}
|
|
10527
|
+
if (key === 'post') {
|
|
10528
|
+
for (const field of ['read', 'write']) {
|
|
10529
|
+
if (declaration[field] !== undefined && typeof declaration[field] !== 'boolean') {
|
|
10530
|
+
throw new Error(`${itemLabel}.${field} 必须是 boolean`);
|
|
10531
|
+
}
|
|
10532
|
+
}
|
|
10533
|
+
if (declaration.enabled)
|
|
10534
|
+
permissions.post = { enabled: true, read: declaration.read === true, write: declaration.write === true };
|
|
10535
|
+
continue;
|
|
10536
|
+
}
|
|
10537
|
+
if (key === 'user_game_data') {
|
|
10538
|
+
// 即使声明关闭也校验资源清单:enabled:false 不能隐藏非法字段。
|
|
10539
|
+
const resources = parseUserGameDataResources(declaration.resources, itemLabel);
|
|
10540
|
+
if (!declaration.enabled)
|
|
10541
|
+
continue;
|
|
10542
|
+
permissions.user_game_data = { enabled: true, resources };
|
|
10543
|
+
continue;
|
|
10544
|
+
}
|
|
10545
|
+
if (!declaration.enabled)
|
|
10546
|
+
continue;
|
|
10547
|
+
permissions[key] = key === 'network' ? { enabled: true, useOfficialDomain } : { enabled: true };
|
|
10548
|
+
}
|
|
10549
|
+
return { declared: true, permissions: permissions };
|
|
10550
|
+
}
|
|
10551
|
+
/**
|
|
10552
|
+
* 校验 Manifest 中的精确资源清单。
|
|
10553
|
+
*
|
|
10554
|
+
* @param value - `user_game_data.resources`;必须显式提供对象,空对象表示不请求任何资源。
|
|
10555
|
+
* @param itemLabel - 报错时使用的字段路径。
|
|
10556
|
+
* @returns 按固定顺序输出的已发布资源与规范化用途。
|
|
10557
|
+
* @throws 非对象、未开放 key 或非法用途直接报错。
|
|
10558
|
+
*/
|
|
10559
|
+
function parseUserGameDataResources(value, itemLabel) {
|
|
10560
|
+
try {
|
|
10561
|
+
return parseUserGameDataResourceDeclarations(value);
|
|
10562
|
+
}
|
|
10563
|
+
catch (error) {
|
|
10564
|
+
throw new Error(`${itemLabel}.${error.message}`);
|
|
10565
|
+
}
|
|
10566
|
+
}
|
|
10567
|
+
function requiresExplicitPermissions(sdkVersion) {
|
|
10568
|
+
const parsed = semverExports.parse(sdkVersion);
|
|
10569
|
+
if (!parsed)
|
|
10570
|
+
throw new Error(`sdkVersion 必须是合法 SemVer:${sdkVersion}`);
|
|
10571
|
+
return parsed.major > 0 || parsed.minor >= 9;
|
|
10572
|
+
}
|
|
10573
|
+
function isRecord$3(value) {
|
|
10574
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10575
|
+
}
|
|
10576
|
+
/** Whether this manifest opts into the reviewed cloud room capability. */
|
|
10577
|
+
function declaresCloudRooms(manifest) {
|
|
10578
|
+
const permissions = manifest.permissions;
|
|
10579
|
+
return permissions?.cloud_rooms?.enabled === true;
|
|
10580
|
+
}
|
|
10581
|
+
|
|
10582
|
+
/**
|
|
10583
|
+
* 校验项目配置或产物中的小程序类别。
|
|
10584
|
+
*
|
|
10585
|
+
* @param value - 待校验值,只接受 `tool`、`game`、`other` 或 `undefined`;不做 trim 或大小写转换。
|
|
10586
|
+
* @param sourceLabel - 错误消息中的字段来源,默认 `package.json#heybox.category`。
|
|
10587
|
+
* @returns 合法类别原值;输入 `undefined` 时返回 `undefined`,由发布流程另行检查是否必填。
|
|
10588
|
+
* @throws `Error` 输入为其他值(包括 null 或空字符串)时抛出带字段来源的错误。
|
|
10589
|
+
* @since 0.8.3
|
|
10590
|
+
*/
|
|
10591
|
+
function parseMiniappCategory(value, sourceLabel = 'package.json#heybox.category') {
|
|
10592
|
+
if (value === undefined)
|
|
10593
|
+
return undefined;
|
|
10594
|
+
if (value === 'tool' || value === 'game' || value === 'other')
|
|
10595
|
+
return value;
|
|
10596
|
+
throw new Error(`${sourceLabel} 必须是 tool、game 或 other`);
|
|
10597
|
+
}
|
|
10598
|
+
|
|
10599
|
+
function isRecord$2(value) {
|
|
10600
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10601
|
+
}
|
|
10602
|
+
function assertRoomReferences(refs) {
|
|
10603
|
+
if (!isRecord$2(refs) || Object.keys(refs).length > 4)
|
|
10604
|
+
throw new Error('roomDefinitions 无效');
|
|
10605
|
+
for (const [name, ref] of Object.entries(refs)) {
|
|
10606
|
+
if (!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(name) ||
|
|
10607
|
+
['constructor', 'prototype', '__proto__'].includes(name) ||
|
|
10608
|
+
!isRecord$2(ref) ||
|
|
10609
|
+
Object.keys(ref).some((key) => key !== 'name' && key !== 'hash') ||
|
|
10610
|
+
ref.name !== name ||
|
|
10611
|
+
typeof ref.hash !== 'string' ||
|
|
10612
|
+
!/^[a-f0-9]{64}$/.test(ref.hash)) {
|
|
10613
|
+
throw new Error('Room 公开引用无效');
|
|
10614
|
+
}
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
|
|
10435
10618
|
const BASIC_INFO_MAX_BYTES = 10 * 1024 * 1024;
|
|
10436
10619
|
const BASIC_INFO_MAX_PIXELS = 40_000_000;
|
|
10437
10620
|
/**
|
|
@@ -10601,98 +10784,6 @@ function parseMiniappDesc(value, sourceLabel = 'package.json#heybox.desc') {
|
|
|
10601
10784
|
return desc;
|
|
10602
10785
|
}
|
|
10603
10786
|
|
|
10604
|
-
const MINIAPP_PERMISSION_KEYS = MINI_PROGRAM_PERMISSION_KEYS;
|
|
10605
|
-
function parseMiniappPermissions(value, options) {
|
|
10606
|
-
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.permissions';
|
|
10607
|
-
if (!options.present) {
|
|
10608
|
-
if (requiresExplicitPermissions(options.sdkVersion)) {
|
|
10609
|
-
throw new Error(`${sourceLabel} 在 @heybox/hb-sdk ${options.sdkVersion} 中必须声明;无权限需求时请配置空对象 {}`);
|
|
10610
|
-
}
|
|
10611
|
-
return { declared: false };
|
|
10612
|
-
}
|
|
10613
|
-
if (!isRecord$2(value)) {
|
|
10614
|
-
throw new Error(`${sourceLabel} 必须是 JSON 对象`);
|
|
10615
|
-
}
|
|
10616
|
-
const knownKeys = new Set(MINIAPP_PERMISSION_KEYS);
|
|
10617
|
-
for (const key of Object.keys(value)) {
|
|
10618
|
-
if (!knownKeys.has(key))
|
|
10619
|
-
throw new Error(`${sourceLabel} 包含未知权限:${key}`);
|
|
10620
|
-
}
|
|
10621
|
-
const permissions = {};
|
|
10622
|
-
for (const key of MINIAPP_PERMISSION_KEYS) {
|
|
10623
|
-
if (!Object.prototype.hasOwnProperty.call(value, key))
|
|
10624
|
-
continue;
|
|
10625
|
-
const declaration = value[key];
|
|
10626
|
-
const itemLabel = `${sourceLabel}.${key}`;
|
|
10627
|
-
if (!isRecord$2(declaration))
|
|
10628
|
-
throw new Error(`${itemLabel} 必须是 JSON 对象`);
|
|
10629
|
-
const definition = MINI_PROGRAM_PERMISSION_CATALOG.find((item) => item.key === key);
|
|
10630
|
-
if (!definition)
|
|
10631
|
-
throw new Error(`权限目录缺少定义:${key}`);
|
|
10632
|
-
const allowedFields = new Set(['enabled', ...Object.keys(definition.config)]);
|
|
10633
|
-
for (const field of Object.keys(declaration)) {
|
|
10634
|
-
if (!allowedFields.has(field))
|
|
10635
|
-
throw new Error(`${itemLabel} 包含未知字段:${field}`);
|
|
10636
|
-
}
|
|
10637
|
-
if (typeof declaration.enabled !== 'boolean')
|
|
10638
|
-
throw new Error(`${itemLabel}.enabled 必须是 boolean`);
|
|
10639
|
-
let useOfficialDomain = false;
|
|
10640
|
-
if (key === 'network') {
|
|
10641
|
-
if (declaration.useOfficialDomain !== undefined && typeof declaration.useOfficialDomain !== 'boolean') {
|
|
10642
|
-
throw new Error(`${itemLabel}.useOfficialDomain 必须是 boolean`);
|
|
10643
|
-
}
|
|
10644
|
-
useOfficialDomain = declaration.useOfficialDomain === true;
|
|
10645
|
-
}
|
|
10646
|
-
if (key === 'post') {
|
|
10647
|
-
for (const field of ['read', 'write']) {
|
|
10648
|
-
if (declaration[field] !== undefined && typeof declaration[field] !== 'boolean') {
|
|
10649
|
-
throw new Error(`${itemLabel}.${field} 必须是 boolean`);
|
|
10650
|
-
}
|
|
10651
|
-
}
|
|
10652
|
-
if (declaration.enabled)
|
|
10653
|
-
permissions.post = { enabled: true, read: declaration.read === true, write: declaration.write === true };
|
|
10654
|
-
continue;
|
|
10655
|
-
}
|
|
10656
|
-
if (key === 'user_game_data') {
|
|
10657
|
-
// 即使声明关闭也校验资源清单:enabled:false 不能隐藏非法字段。
|
|
10658
|
-
const resources = parseUserGameDataResources(declaration.resources, itemLabel);
|
|
10659
|
-
if (!declaration.enabled)
|
|
10660
|
-
continue;
|
|
10661
|
-
permissions.user_game_data = { enabled: true, resources };
|
|
10662
|
-
continue;
|
|
10663
|
-
}
|
|
10664
|
-
if (!declaration.enabled)
|
|
10665
|
-
continue;
|
|
10666
|
-
permissions[key] = key === 'network' ? { enabled: true, useOfficialDomain } : { enabled: true };
|
|
10667
|
-
}
|
|
10668
|
-
return { declared: true, permissions: permissions };
|
|
10669
|
-
}
|
|
10670
|
-
/**
|
|
10671
|
-
* 校验 Manifest 中的精确资源清单。
|
|
10672
|
-
*
|
|
10673
|
-
* @param value - `user_game_data.resources`;必须显式提供对象,空对象表示不请求任何资源。
|
|
10674
|
-
* @param itemLabel - 报错时使用的字段路径。
|
|
10675
|
-
* @returns 按固定顺序输出的已发布资源与规范化用途。
|
|
10676
|
-
* @throws 非对象、未开放 key 或非法用途直接报错。
|
|
10677
|
-
*/
|
|
10678
|
-
function parseUserGameDataResources(value, itemLabel) {
|
|
10679
|
-
try {
|
|
10680
|
-
return parseUserGameDataResourceDeclarations(value);
|
|
10681
|
-
}
|
|
10682
|
-
catch (error) {
|
|
10683
|
-
throw new Error(`${itemLabel}.${error.message}`);
|
|
10684
|
-
}
|
|
10685
|
-
}
|
|
10686
|
-
function requiresExplicitPermissions(sdkVersion) {
|
|
10687
|
-
const parsed = semverExports.parse(sdkVersion);
|
|
10688
|
-
if (!parsed)
|
|
10689
|
-
throw new Error(`sdkVersion 必须是合法 SemVer:${sdkVersion}`);
|
|
10690
|
-
return parsed.major > 0 || parsed.minor >= 9;
|
|
10691
|
-
}
|
|
10692
|
-
function isRecord$2(value) {
|
|
10693
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10694
|
-
}
|
|
10695
|
-
|
|
10696
10787
|
/**
|
|
10697
10788
|
* `package.json#heybox.platforms` 接受的平台值,顺序同时是 Manifest 的规范化输出顺序。
|
|
10698
10789
|
*
|
|
@@ -10710,13 +10801,7 @@ const MINIAPP_PLATFORM_HARD_CUT_SDK_VERSION = '0.9.0';
|
|
|
10710
10801
|
*
|
|
10711
10802
|
* 不含 `linux`:客户端暂无 linux 基线,后端 `x_os_type` 也不映射该平台,声明了也进不了运行门禁。
|
|
10712
10803
|
*/
|
|
10713
|
-
const MINIAPP_LEGACY_DEFAULT_PLATFORM_VALUES = [
|
|
10714
|
-
'android',
|
|
10715
|
-
'ios',
|
|
10716
|
-
'ohos',
|
|
10717
|
-
'windows',
|
|
10718
|
-
'macos',
|
|
10719
|
-
];
|
|
10804
|
+
const MINIAPP_LEGACY_DEFAULT_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos'];
|
|
10720
10805
|
/**
|
|
10721
10806
|
* 历史兜底平台集合的旧名称。
|
|
10722
10807
|
*
|
|
@@ -10793,6 +10878,9 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
|
|
|
10793
10878
|
* @since 0.8.2
|
|
10794
10879
|
*/
|
|
10795
10880
|
function validateMiniappManifestForDeploy(manifest) {
|
|
10881
|
+
const roomDefinitions = declaresCloudRooms(manifest) ? manifest.roomDefinitions : undefined;
|
|
10882
|
+
if (roomDefinitions !== undefined)
|
|
10883
|
+
assertRoomReferences(roomDefinitions);
|
|
10796
10884
|
const version = validateMiniappManifestVersion(manifest.version, 'manifest.version');
|
|
10797
10885
|
const sdkVersion = validateSdkVersion(manifest.sdkVersion, 'manifest.sdkVersion');
|
|
10798
10886
|
const permissions = parseMiniappPermissions(manifest.permissions, {
|
|
@@ -10817,6 +10905,7 @@ function validateMiniappManifestForDeploy(manifest) {
|
|
|
10817
10905
|
platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
|
|
10818
10906
|
...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
|
|
10819
10907
|
...(companions === undefined ? {} : { companions }),
|
|
10908
|
+
...(roomDefinitions === undefined ? {} : { roomDefinitions }),
|
|
10820
10909
|
...(manifest.workspaceCards === undefined ? {} : { workspaceCards: manifest.workspaceCards }),
|
|
10821
10910
|
...(window === undefined ? {} : { window }),
|
|
10822
10911
|
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
@@ -19853,6 +19942,9 @@ function prepareMiniappArtifactFiles(files) {
|
|
|
19853
19942
|
const usedPaths = new Set();
|
|
19854
19943
|
const prepared = files.map((file) => {
|
|
19855
19944
|
const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
|
|
19945
|
+
if (isPrivateRoomArtifactPath(relativePath)) {
|
|
19946
|
+
throw new Error(`Room 私有文件不能上传到 CDN:${relativePath}`);
|
|
19947
|
+
}
|
|
19856
19948
|
if (usedPaths.has(relativePath)) {
|
|
19857
19949
|
throw new Error(`构建产物包含重复文件路径:${relativePath}`);
|
|
19858
19950
|
}
|
|
@@ -19862,6 +19954,11 @@ function prepareMiniappArtifactFiles(files) {
|
|
|
19862
19954
|
});
|
|
19863
19955
|
return prepared.sort((left, right) => compareBytes(textEncoder.encode(left.relativePath), textEncoder.encode(right.relativePath)));
|
|
19864
19956
|
}
|
|
19957
|
+
/** 平台私有目录在所有产物中保留,房间定义源文件仅对启用该能力的产物保留。 */
|
|
19958
|
+
function isPrivateRoomArtifactPath(relativePath, checkRoomSources = false) {
|
|
19959
|
+
return /(?:^|\/)\.hb-sdk\/rooms(?:\/|$)/i.test(relativePath) ||
|
|
19960
|
+
(checkRoomSources && /\.room\.(?:json|[cm]?ts)$/i.test(relativePath));
|
|
19961
|
+
}
|
|
19865
19962
|
/**
|
|
19866
19963
|
* 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
|
|
19867
19964
|
*
|
|
@@ -20234,9 +20331,11 @@ exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSIO
|
|
|
20234
20331
|
exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
|
|
20235
20332
|
exports.createMiniappArtifactFileHeader = createMiniappArtifactFileHeader;
|
|
20236
20333
|
exports.createMiniappArtifactSignatureHeader = createMiniappArtifactSignatureHeader;
|
|
20334
|
+
exports.declaresCloudRooms = declaresCloudRooms;
|
|
20237
20335
|
exports.getMiniProgramUploadAlias = getMiniProgramUploadAlias;
|
|
20238
20336
|
exports.getMiniappMetadataWarnings = getMiniappMetadataWarnings;
|
|
20239
20337
|
exports.hasMiniappRuntimeGate = hasMiniappRuntimeGate;
|
|
20338
|
+
exports.isPrivateRoomArtifactPath = isPrivateRoomArtifactPath;
|
|
20240
20339
|
exports.isValidVersion = isValidMiniappManifestVersion;
|
|
20241
20340
|
exports.normalizeBasicInfoName = normalizeBasicInfoName;
|
|
20242
20341
|
exports.normalizeRelativePath = normalizeRelativePath;
|