@heybox/hb-sdk 0.8.1-alpha.14 → 0.8.1-alpha.15
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 +6 -0
- package/README.md +13 -0
- package/dist/cli-chunks/{build-D-VaxzAE.cjs → build-6nkCiXV0.cjs} +17 -7
- package/dist/cli-chunks/{context-BH7BZPoY.cjs → context-DyeSJSqE.cjs} +2 -2
- package/dist/cli-chunks/{create-Bmp9E1n8.cjs → create-wXBzkgmP.cjs} +1 -1
- package/dist/cli-chunks/{dev-BntAFyWR.cjs → dev-Caq_oO7n.cjs} +9 -9
- package/dist/cli-chunks/{doctor-t3YMD3qv.cjs → doctor-n4vISsD-.cjs} +1 -1
- package/dist/cli-chunks/{index-VP8boR-7.cjs → index-BTUkiKjC.cjs} +15 -15
- package/dist/cli-chunks/{index-CjP8Qye_.cjs → index-hyB5_A_G.cjs} +2 -2
- package/dist/cli-chunks/{index.esm-B_5UnniK.cjs → index.esm-DU-rsJ3-.cjs} +7 -7
- package/dist/cli-chunks/{login-p38-WSHx.cjs → login-CsXZXtCS.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-BfJ5TGoA.cjs → project-vite-87sg4Mnk.cjs} +1 -1
- package/dist/cli-chunks/{remote-CBH04z6v.cjs → remote-Cfr3wcGq.cjs} +69 -10
- package/dist/cli-chunks/{runtime-permission-env-CVYOOxPB.cjs → runtime-permission-env-B3wQZF2c.cjs} +38 -1
- package/dist/cli-chunks/{session-BEpV8CZQ.cjs → session-YWsulrKF.cjs} +1 -1
- package/dist/cli-chunks/{skill-DuVDTrA2.cjs → skill-CS2JoOL8.cjs} +2 -2
- package/dist/cli-chunks/{version-Df-F-uhW.cjs → version-DXjXtCXW.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-D_nC-Zex.js → browser-dev-host-GNgPrL3B.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-C1GHFN_L.js → desktop-app-launch-BUVHeuGC.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-mfGqyKpq.js → index-C3EtSrqt.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +30 -0
- package/dist/miniapp-publish.esm.js +30 -1
- package/dist/vite.cjs.js +39 -1
- package/dist/vite.esm.js +39 -1
- package/package.json +4 -4
- package/skill/SKILL.md +15 -14
- package/skill/references/api-protocol.md +2 -2
- package/skill/references/api-root.md +3 -1
- package/skill/references/cli.md +2 -0
- package/skill/skill.json +5 -5
- package/types/miniapp-manifest/bindings.d.ts +5 -0
- package/types/miniapp-manifest/index.d.ts +1 -0
- package/types/miniapp-manifest/node.d.ts +1 -0
- package/types/miniapp-manifest/schema.d.ts +2 -0
- package/types/miniapp-publish/index.d.ts +1 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="theme-color" content="#f4f5f7" />
|
|
7
7
|
<title>小程序工坊调试台</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-C3EtSrqt.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-BUVHeuGC.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-DXd5IZBz.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/index.cjs.js
CHANGED
|
@@ -835,7 +835,7 @@ function createMessageId() {
|
|
|
835
835
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
836
836
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
837
837
|
? undefined
|
|
838
|
-
: '0.8.1-alpha.
|
|
838
|
+
: '0.8.1-alpha.15';
|
|
839
839
|
|
|
840
840
|
const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
|
|
841
841
|
const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
|
package/dist/index.esm.js
CHANGED
|
@@ -831,7 +831,7 @@ function createMessageId() {
|
|
|
831
831
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
832
832
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
833
833
|
? undefined
|
|
834
|
-
: '0.8.1-alpha.
|
|
834
|
+
: '0.8.1-alpha.15';
|
|
835
835
|
|
|
836
836
|
const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
|
|
837
837
|
const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
|
|
@@ -2785,6 +2785,35 @@ function requireSemver () {
|
|
|
2785
2785
|
|
|
2786
2786
|
var semverExports = requireSemver();
|
|
2787
2787
|
|
|
2788
|
+
const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
|
|
2789
|
+
function parseMiniappBindAppIds(value, options = {}) {
|
|
2790
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
|
|
2791
|
+
if (value === undefined)
|
|
2792
|
+
return Object.freeze([]);
|
|
2793
|
+
if (!Array.isArray(value))
|
|
2794
|
+
throw new Error(`${sourceLabel} 必须是字符串数组`);
|
|
2795
|
+
if (value.length > MINIAPP_BIND_APP_IDS_MAX_COUNT) {
|
|
2796
|
+
throw new Error(`${sourceLabel} 最多包含 ${MINIAPP_BIND_APP_IDS_MAX_COUNT} 个游戏 appid`);
|
|
2797
|
+
}
|
|
2798
|
+
const seen = new Set();
|
|
2799
|
+
const appIds = [];
|
|
2800
|
+
for (const item of value) {
|
|
2801
|
+
if (typeof item !== 'string' || !/^[1-9]\d*$/.test(item)) {
|
|
2802
|
+
throw new Error(`${sourceLabel} 包含非法游戏 appid:${String(item)}`);
|
|
2803
|
+
}
|
|
2804
|
+
const numeric = Number(item);
|
|
2805
|
+
if (!Number.isSafeInteger(numeric) || numeric > 2_147_483_647) {
|
|
2806
|
+
throw new Error(`${sourceLabel} 包含超出正 int32 范围的游戏 appid:${item}`);
|
|
2807
|
+
}
|
|
2808
|
+
if (seen.has(item))
|
|
2809
|
+
throw new Error(`${sourceLabel} 包含重复游戏 appid:${item}`);
|
|
2810
|
+
seen.add(item);
|
|
2811
|
+
appIds.push(item);
|
|
2812
|
+
}
|
|
2813
|
+
appIds.sort((left, right) => Number(left) - Number(right));
|
|
2814
|
+
return Object.freeze(appIds);
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2788
2817
|
function isValidMiniappManifestVersion(version) {
|
|
2789
2818
|
return getMiniappManifestVersionError(version) === undefined;
|
|
2790
2819
|
}
|
|
@@ -3222,6 +3251,7 @@ exports.getMiniProgramUploadAlias = getMiniProgramUploadAlias;
|
|
|
3222
3251
|
exports.getMiniappUploadKey = getMiniappUploadKey;
|
|
3223
3252
|
exports.isValidVersion = isValidMiniappManifestVersion;
|
|
3224
3253
|
exports.normalizeRelativePath = normalizeRelativePath;
|
|
3254
|
+
exports.parseMiniappBindAppIds = parseMiniappBindAppIds;
|
|
3225
3255
|
exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
|
|
3226
3256
|
exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
|
|
3227
3257
|
exports.resolveMiniappUploadSessionFiles = resolveMiniappUploadSessionFiles;
|
|
@@ -2783,6 +2783,35 @@ function requireSemver () {
|
|
|
2783
2783
|
|
|
2784
2784
|
var semverExports = requireSemver();
|
|
2785
2785
|
|
|
2786
|
+
const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
|
|
2787
|
+
function parseMiniappBindAppIds(value, options = {}) {
|
|
2788
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
|
|
2789
|
+
if (value === undefined)
|
|
2790
|
+
return Object.freeze([]);
|
|
2791
|
+
if (!Array.isArray(value))
|
|
2792
|
+
throw new Error(`${sourceLabel} 必须是字符串数组`);
|
|
2793
|
+
if (value.length > MINIAPP_BIND_APP_IDS_MAX_COUNT) {
|
|
2794
|
+
throw new Error(`${sourceLabel} 最多包含 ${MINIAPP_BIND_APP_IDS_MAX_COUNT} 个游戏 appid`);
|
|
2795
|
+
}
|
|
2796
|
+
const seen = new Set();
|
|
2797
|
+
const appIds = [];
|
|
2798
|
+
for (const item of value) {
|
|
2799
|
+
if (typeof item !== 'string' || !/^[1-9]\d*$/.test(item)) {
|
|
2800
|
+
throw new Error(`${sourceLabel} 包含非法游戏 appid:${String(item)}`);
|
|
2801
|
+
}
|
|
2802
|
+
const numeric = Number(item);
|
|
2803
|
+
if (!Number.isSafeInteger(numeric) || numeric > 2_147_483_647) {
|
|
2804
|
+
throw new Error(`${sourceLabel} 包含超出正 int32 范围的游戏 appid:${item}`);
|
|
2805
|
+
}
|
|
2806
|
+
if (seen.has(item))
|
|
2807
|
+
throw new Error(`${sourceLabel} 包含重复游戏 appid:${item}`);
|
|
2808
|
+
seen.add(item);
|
|
2809
|
+
appIds.push(item);
|
|
2810
|
+
}
|
|
2811
|
+
appIds.sort((left, right) => Number(left) - Number(right));
|
|
2812
|
+
return Object.freeze(appIds);
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2786
2815
|
function isValidMiniappManifestVersion(version) {
|
|
2787
2816
|
return getMiniappManifestVersionError(version) === undefined;
|
|
2788
2817
|
}
|
|
@@ -3187,4 +3216,4 @@ function compareBytes(left, right) {
|
|
|
3187
3216
|
return left.length - right.length;
|
|
3188
3217
|
}
|
|
3189
3218
|
|
|
3190
|
-
export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, CREATE_USER_MINIPROGRAM_API_PATH, CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, CREATE_USER_MINIPROGRAM_LOCAL_DEV_LAUNCH_TOKEN_API_PATH, DELETE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DETAIL_USER_MINIPROGRAM_API_PATH, DETAIL_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DEVELOPER_ENTITY_LIST_API_PATH, DEVELOPER_ENTITY_SWITCH_API_PATH, LIST_USER_MINIPROGRAM_API_PATH, LIST_USER_MINIPROGRAM_LEADERBOARD_API_PATH, LIST_USER_MINIPROGRAM_VERSION_API_PATH, MINIAPP_COMPANION_UPLOAD_TEMPORARY_SIZE_LIMIT_BYTES, MINIAPP_UPLOAD_BATCH_SIZE, MINIAPP_UPLOAD_SCOPE, MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES, PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, RELEASE_USER_MINIPROGRAM_VERSION_API_PATH, REOPEN_USER_MINIPROGRAM_API_PATH, SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, TAKE_DOWN_USER_MINIPROGRAM_API_PATH, UPDATE_SQUARE_DISPLAY_API_PATH, UPDATE_USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_ACCESS_STATUS_API_PATH, USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH, WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH, createMiniappArtifactFileHeader, createMiniappArtifactSignatureHeader, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, prepareMiniappArtifactFiles, relativePathContainsNodeModulesSegment, resolveMiniappUploadSessionFiles, shouldUploadDistFile, validateMiniappCompanionFileReceipts, validateMiniappUploadPathLengths, validateMiniappUploadSizeBudgets, validateUploadPaths, validateUploadTotalSize };
|
|
3219
|
+
export { ACTIVITY_UPLOAD_KEY_MAX_LENGTH, CREATE_USER_MINIPROGRAM_API_PATH, CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, CREATE_USER_MINIPROGRAM_LOCAL_DEV_LAUNCH_TOKEN_API_PATH, DELETE_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DETAIL_USER_MINIPROGRAM_API_PATH, DETAIL_USER_MINIPROGRAM_LEADERBOARD_API_PATH, DEVELOPER_ENTITY_LIST_API_PATH, DEVELOPER_ENTITY_SWITCH_API_PATH, LIST_USER_MINIPROGRAM_API_PATH, LIST_USER_MINIPROGRAM_LEADERBOARD_API_PATH, LIST_USER_MINIPROGRAM_VERSION_API_PATH, MINIAPP_COMPANION_UPLOAD_TEMPORARY_SIZE_LIMIT_BYTES, MINIAPP_UPLOAD_BATCH_SIZE, MINIAPP_UPLOAD_SCOPE, MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES, PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, RELEASE_USER_MINIPROGRAM_VERSION_API_PATH, REOPEN_USER_MINIPROGRAM_API_PATH, SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, TAKE_DOWN_USER_MINIPROGRAM_API_PATH, UPDATE_SQUARE_DISPLAY_API_PATH, UPDATE_USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_ACCESS_STATUS_API_PATH, USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH, USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH, WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH, createMiniappArtifactFileHeader, createMiniappArtifactSignatureHeader, getMiniProgramUploadAlias, getMiniappUploadKey, isValidMiniappManifestVersion as isValidVersion, normalizeRelativePath, parseMiniappBindAppIds, prepareMiniappArtifactFiles, relativePathContainsNodeModulesSegment, resolveMiniappUploadSessionFiles, shouldUploadDistFile, validateMiniappCompanionFileReceipts, validateMiniappUploadPathLengths, validateMiniappUploadSizeBudgets, validateUploadPaths, validateUploadTotalSize };
|
package/dist/vite.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
11
11
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
12
12
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
13
13
|
? undefined
|
|
14
|
-
: '0.8.1-alpha.
|
|
14
|
+
: '0.8.1-alpha.15';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* iframe 与调试台页面的开发期 console 捕获转发。
|
|
@@ -3116,6 +3116,35 @@ function requireSemver () {
|
|
|
3116
3116
|
|
|
3117
3117
|
var semverExports = requireSemver();
|
|
3118
3118
|
|
|
3119
|
+
const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
|
|
3120
|
+
function parseMiniappBindAppIds(value, options = {}) {
|
|
3121
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
|
|
3122
|
+
if (value === undefined)
|
|
3123
|
+
return Object.freeze([]);
|
|
3124
|
+
if (!Array.isArray(value))
|
|
3125
|
+
throw new Error(`${sourceLabel} 必须是字符串数组`);
|
|
3126
|
+
if (value.length > MINIAPP_BIND_APP_IDS_MAX_COUNT) {
|
|
3127
|
+
throw new Error(`${sourceLabel} 最多包含 ${MINIAPP_BIND_APP_IDS_MAX_COUNT} 个游戏 appid`);
|
|
3128
|
+
}
|
|
3129
|
+
const seen = new Set();
|
|
3130
|
+
const appIds = [];
|
|
3131
|
+
for (const item of value) {
|
|
3132
|
+
if (typeof item !== 'string' || !/^[1-9]\d*$/.test(item)) {
|
|
3133
|
+
throw new Error(`${sourceLabel} 包含非法游戏 appid:${String(item)}`);
|
|
3134
|
+
}
|
|
3135
|
+
const numeric = Number(item);
|
|
3136
|
+
if (!Number.isSafeInteger(numeric) || numeric > 2_147_483_647) {
|
|
3137
|
+
throw new Error(`${sourceLabel} 包含超出正 int32 范围的游戏 appid:${item}`);
|
|
3138
|
+
}
|
|
3139
|
+
if (seen.has(item))
|
|
3140
|
+
throw new Error(`${sourceLabel} 包含重复游戏 appid:${item}`);
|
|
3141
|
+
seen.add(item);
|
|
3142
|
+
appIds.push(item);
|
|
3143
|
+
}
|
|
3144
|
+
appIds.sort((left, right) => Number(left) - Number(right));
|
|
3145
|
+
return Object.freeze(appIds);
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3119
3148
|
const MINI_PROGRAM_MESSAGE_NAMESPACE = 'heybox:miniprogram';
|
|
3120
3149
|
const MINI_PROGRAM_MESSAGE_VERSION = 2;
|
|
3121
3150
|
const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
|
|
@@ -3351,6 +3380,7 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
|
|
|
3351
3380
|
function renderMiniappManifest(manifest) {
|
|
3352
3381
|
const platforms = validateMiniappPlatforms(manifest.platforms, 'manifest.platforms');
|
|
3353
3382
|
const window = validateMiniappWindow(manifest.window, 'manifest.window');
|
|
3383
|
+
const bindAppIds = parseMiniappBindAppIds(manifest.bindAppIds, { sourceLabel: 'manifest.bindAppIds' });
|
|
3354
3384
|
const output = {
|
|
3355
3385
|
version: manifest.version,
|
|
3356
3386
|
sdkVersion: manifest.sdkVersion,
|
|
@@ -3358,6 +3388,7 @@ function renderMiniappManifest(manifest) {
|
|
|
3358
3388
|
...(manifest.permissions === undefined ? {} : { permissions: manifest.permissions }),
|
|
3359
3389
|
...(manifest.companions === undefined ? {} : { companions: manifest.companions }),
|
|
3360
3390
|
...(window === undefined ? {} : { window }),
|
|
3391
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
3361
3392
|
};
|
|
3362
3393
|
return `${JSON.stringify(output, null, 2)}\n`;
|
|
3363
3394
|
}
|
|
@@ -3519,6 +3550,11 @@ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
|
3519
3550
|
sdkVersion,
|
|
3520
3551
|
});
|
|
3521
3552
|
}
|
|
3553
|
+
function readMiniappBindAppIdsFromPackageJson(root) {
|
|
3554
|
+
const { packageJson } = readMiniappPackageJson(root, false);
|
|
3555
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3556
|
+
return parseMiniappBindAppIds(heybox?.bindAppIds);
|
|
3557
|
+
}
|
|
3522
3558
|
function readMiniappPackageJson(root, requireVersion) {
|
|
3523
3559
|
const packageJsonPath = findNearestPackageJsonPath(root);
|
|
3524
3560
|
let content;
|
|
@@ -13302,6 +13338,7 @@ function miniappManifest() {
|
|
|
13302
13338
|
const windowDeclaration = readMiniappWindowFromPackageJson(root);
|
|
13303
13339
|
const companionConfig = readMiniappCompanionsFromPackageJson(root);
|
|
13304
13340
|
const companionDeclarations = includeCompanions ? companionConfig.declarations : undefined;
|
|
13341
|
+
const bindAppIds = readMiniappBindAppIdsFromPackageJson(root);
|
|
13305
13342
|
if (!parsedPermissions.declared)
|
|
13306
13343
|
this.warn(getMissingPermissionsWarning());
|
|
13307
13344
|
if (companionDeclarations && !parsedPermissions.permissions?.companion) {
|
|
@@ -13330,6 +13367,7 @@ function miniappManifest() {
|
|
|
13330
13367
|
...(parsedPermissions.permissions === undefined ? {} : { permissions: parsedPermissions.permissions }),
|
|
13331
13368
|
...(companions === undefined ? {} : { companions }),
|
|
13332
13369
|
...(windowDeclaration === undefined ? {} : { window: windowDeclaration }),
|
|
13370
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
13333
13371
|
}));
|
|
13334
13372
|
},
|
|
13335
13373
|
};
|
package/dist/vite.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
8
8
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
9
9
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
10
10
|
? undefined
|
|
11
|
-
: '0.8.1-alpha.
|
|
11
|
+
: '0.8.1-alpha.15';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* iframe 与调试台页面的开发期 console 捕获转发。
|
|
@@ -3113,6 +3113,35 @@ function requireSemver () {
|
|
|
3113
3113
|
|
|
3114
3114
|
var semverExports = requireSemver();
|
|
3115
3115
|
|
|
3116
|
+
const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
|
|
3117
|
+
function parseMiniappBindAppIds(value, options = {}) {
|
|
3118
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
|
|
3119
|
+
if (value === undefined)
|
|
3120
|
+
return Object.freeze([]);
|
|
3121
|
+
if (!Array.isArray(value))
|
|
3122
|
+
throw new Error(`${sourceLabel} 必须是字符串数组`);
|
|
3123
|
+
if (value.length > MINIAPP_BIND_APP_IDS_MAX_COUNT) {
|
|
3124
|
+
throw new Error(`${sourceLabel} 最多包含 ${MINIAPP_BIND_APP_IDS_MAX_COUNT} 个游戏 appid`);
|
|
3125
|
+
}
|
|
3126
|
+
const seen = new Set();
|
|
3127
|
+
const appIds = [];
|
|
3128
|
+
for (const item of value) {
|
|
3129
|
+
if (typeof item !== 'string' || !/^[1-9]\d*$/.test(item)) {
|
|
3130
|
+
throw new Error(`${sourceLabel} 包含非法游戏 appid:${String(item)}`);
|
|
3131
|
+
}
|
|
3132
|
+
const numeric = Number(item);
|
|
3133
|
+
if (!Number.isSafeInteger(numeric) || numeric > 2_147_483_647) {
|
|
3134
|
+
throw new Error(`${sourceLabel} 包含超出正 int32 范围的游戏 appid:${item}`);
|
|
3135
|
+
}
|
|
3136
|
+
if (seen.has(item))
|
|
3137
|
+
throw new Error(`${sourceLabel} 包含重复游戏 appid:${item}`);
|
|
3138
|
+
seen.add(item);
|
|
3139
|
+
appIds.push(item);
|
|
3140
|
+
}
|
|
3141
|
+
appIds.sort((left, right) => Number(left) - Number(right));
|
|
3142
|
+
return Object.freeze(appIds);
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3116
3145
|
const MINI_PROGRAM_MESSAGE_NAMESPACE = 'heybox:miniprogram';
|
|
3117
3146
|
const MINI_PROGRAM_MESSAGE_VERSION = 2;
|
|
3118
3147
|
const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
|
|
@@ -3348,6 +3377,7 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
|
|
|
3348
3377
|
function renderMiniappManifest(manifest) {
|
|
3349
3378
|
const platforms = validateMiniappPlatforms(manifest.platforms, 'manifest.platforms');
|
|
3350
3379
|
const window = validateMiniappWindow(manifest.window, 'manifest.window');
|
|
3380
|
+
const bindAppIds = parseMiniappBindAppIds(manifest.bindAppIds, { sourceLabel: 'manifest.bindAppIds' });
|
|
3351
3381
|
const output = {
|
|
3352
3382
|
version: manifest.version,
|
|
3353
3383
|
sdkVersion: manifest.sdkVersion,
|
|
@@ -3355,6 +3385,7 @@ function renderMiniappManifest(manifest) {
|
|
|
3355
3385
|
...(manifest.permissions === undefined ? {} : { permissions: manifest.permissions }),
|
|
3356
3386
|
...(manifest.companions === undefined ? {} : { companions: manifest.companions }),
|
|
3357
3387
|
...(window === undefined ? {} : { window }),
|
|
3388
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
3358
3389
|
};
|
|
3359
3390
|
return `${JSON.stringify(output, null, 2)}\n`;
|
|
3360
3391
|
}
|
|
@@ -3516,6 +3547,11 @@ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
|
3516
3547
|
sdkVersion,
|
|
3517
3548
|
});
|
|
3518
3549
|
}
|
|
3550
|
+
function readMiniappBindAppIdsFromPackageJson(root) {
|
|
3551
|
+
const { packageJson } = readMiniappPackageJson(root, false);
|
|
3552
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3553
|
+
return parseMiniappBindAppIds(heybox?.bindAppIds);
|
|
3554
|
+
}
|
|
3519
3555
|
function readMiniappPackageJson(root, requireVersion) {
|
|
3520
3556
|
const packageJsonPath = findNearestPackageJsonPath(root);
|
|
3521
3557
|
let content;
|
|
@@ -13299,6 +13335,7 @@ function miniappManifest() {
|
|
|
13299
13335
|
const windowDeclaration = readMiniappWindowFromPackageJson(root);
|
|
13300
13336
|
const companionConfig = readMiniappCompanionsFromPackageJson(root);
|
|
13301
13337
|
const companionDeclarations = includeCompanions ? companionConfig.declarations : undefined;
|
|
13338
|
+
const bindAppIds = readMiniappBindAppIdsFromPackageJson(root);
|
|
13302
13339
|
if (!parsedPermissions.declared)
|
|
13303
13340
|
this.warn(getMissingPermissionsWarning());
|
|
13304
13341
|
if (companionDeclarations && !parsedPermissions.permissions?.companion) {
|
|
@@ -13327,6 +13364,7 @@ function miniappManifest() {
|
|
|
13327
13364
|
...(parsedPermissions.permissions === undefined ? {} : { permissions: parsedPermissions.permissions }),
|
|
13328
13365
|
...(companions === undefined ? {} : { companions }),
|
|
13329
13366
|
...(windowDeclaration === undefined ? {} : { window: windowDeclaration }),
|
|
13367
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
13330
13368
|
}));
|
|
13331
13369
|
},
|
|
13332
13370
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heybox/hb-sdk",
|
|
3
|
-
"version": "0.8.1-alpha.
|
|
3
|
+
"version": "0.8.1-alpha.15",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"./src/index.ts",
|
|
6
6
|
"./src/core/singleton.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"skills": "1.5.23",
|
|
63
63
|
"undici": "^7.28.0",
|
|
64
64
|
"ws": "^8.18.0",
|
|
65
|
-
"@heybox/hb-sdk-protocol": "0.8.1-alpha.
|
|
65
|
+
"@heybox/hb-sdk-protocol": "0.8.1-alpha.15"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"vite": ">=5"
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"vite": "^8.0.12",
|
|
115
115
|
"vitest": "^3.2.4",
|
|
116
116
|
"@heybox-domain/heybox-theme": "~0.1.0",
|
|
117
|
-
"@heybox-domain/heybox-vue3-ui": "~0.1.0",
|
|
118
|
-
"@heybox/hb-sdk-runtime": "~0.8.1-alpha.14",
|
|
119
117
|
"@heybox/hb-api": "~1.28.3",
|
|
118
|
+
"@heybox/hb-sdk-runtime": "~0.8.1-alpha.15",
|
|
119
|
+
"@heybox-domain/heybox-vue3-ui": "~0.1.0",
|
|
120
120
|
"@heybox/runtime": "~0.2.0",
|
|
121
121
|
"@heybox/runtime-policy": "~0.2.0",
|
|
122
122
|
"@heybox/runtime-transport-fetch": "~0.2.0"
|
package/skill/SKILL.md
CHANGED
|
@@ -66,20 +66,21 @@ Apply these instructions when writing, reviewing, or debugging code that consume
|
|
|
66
66
|
For real PC Companion debugging, configure local artifacts in `package.json#heybox.companions`, keep `miniappManifest()` enabled, bind the project, and ensure COA has approved `companion`. `hb-sdk dev` validates immutable snapshots without requiring an upload; config or artifact changes rotate the snapshot while existing Sessions retain their original artifact. Prepare and launch the new artifact explicitly. Check separate Browser, Mobile and PC Companion readiness in the debugging workbench. Without a local declaration, use Browser Fake only for state/UI integration.
|
|
67
67
|
4. Use `hb-sdk build [--env <name>] [--verbose]` as the recommended production build entry. It directly owns the Vite build, always cleans and writes `dist/`, and works without CLI login, project binding, or network access.
|
|
68
68
|
5. Declare the actual supported platforms in `package.json#heybox.platforms` and keep the no-argument `miniappManifest()` explicitly enabled in `vite.config.ts`; `hb-sdk build` must fail when the declaration, Manifest, or Runtime gate output is missing or inconsistent.
|
|
69
|
-
6.
|
|
70
|
-
7.
|
|
71
|
-
8.
|
|
72
|
-
9. Use `hb-sdk
|
|
73
|
-
10. Use `hb-sdk remote
|
|
74
|
-
11. Use `hb-sdk remote
|
|
75
|
-
12. Use `hb-sdk remote
|
|
76
|
-
13.
|
|
77
|
-
14.
|
|
78
|
-
15.
|
|
79
|
-
16.
|
|
80
|
-
17. Use
|
|
81
|
-
18. Use `
|
|
82
|
-
19.
|
|
69
|
+
6. When a released version should be discoverable from specific PC game workspaces, declare canonical decimal string appids in `package.json#heybox.bindAppIds` (maximum 20). This is version metadata, not a Runtime permission. Missing or empty clears bindings; `--from-version` inherits the source artifact snapshot.
|
|
70
|
+
7. Keep project typechecking in `scripts.build`, for example `vue-tsc --noEmit && hb-sdk build`; `hb-sdk build` does not run typechecking or invoke `scripts.build` itself.
|
|
71
|
+
8. Existing projects may continue to use `vite build`; do not auto-migrate them. Do not invent `--mode`, `--json`, config, or output-directory flags for `hb-sdk build`.
|
|
72
|
+
9. Use `hb-sdk login`, `hb-sdk login status`, and `hb-sdk login clear` for remote management, publishing, Mobile debugging, and optional Browser Mock Host `heybox-session` requests. Browser debugging itself can start without CLI login. Mini-program code must still call `auth.login()`; the debug page only confirms authorization. Do not paste CLI credentials into page JavaScript. Phone debugging continues to use the App login.
|
|
73
|
+
10. Use `hb-sdk remote entity current` to confirm the current developer account and `hb-sdk remote entity switch <entity-id>` to change it before remote operations.
|
|
74
|
+
11. Use `hb-sdk remote create` to create and bind a mini-program; use `hb-sdk remote bind <mini-program-id>` to bind an existing manageable mini-program.
|
|
75
|
+
12. Use `hb-sdk remote info` to compare local/current/added/removed game bindings, and use `hb-sdk remote list`, `hb-sdk remote access`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, and `hb-sdk remote allowlist ...` for remote inspection and preview management. These commands do not edit game bindings.
|
|
76
|
+
13. Use `hb-sdk remote deploy --release-note <text>` to run the project's `scripts.build`, upload, and submit the current project for audit. Do not recommend the removed top-level `hb-sdk deploy` alias.
|
|
77
|
+
14. `hb-sdk dev` and `hb-sdk remote deploy` skip the platform CSP only when the current version declares and the platform approves `network`. `useOfficialDomain` does not participate in CSP skip decisions. Direct `hb-sdk build`, direct Vite build, anonymous or invalid snapshots, and local Dev Context overrides must keep the platform CSP. Runtime Gate, Manifest, and HTML validation always remain active.
|
|
78
|
+
15. After approval, use `hb-sdk remote release <version>` for manual release or `--auto-publish` when an eligible low-risk version should release automatically.
|
|
79
|
+
16. Treat approval, release, and public display as separate states. Do not promise square, search, or recommendation visibility after release.
|
|
80
|
+
17. Use `hb-sdk remote withdraw`, `hb-sdk remote take-down`, `hb-sdk remote reopen`, and square visibility commands only after showing the target and obtaining required confirmation.
|
|
81
|
+
18. Use `--json` for remote script consumption and `--verbose` only when concise output is insufficient for diagnosis.
|
|
82
|
+
19. Use `hb-sdk doctor` to diagnose whether the local Skill matches the installed SDK; follow its output to install or refresh the Skill.
|
|
83
|
+
20. Do not print or expose cookies, tokens, private headers, or other credentials.
|
|
83
84
|
|
|
84
85
|
## Step 6: Preserve capability boundaries
|
|
85
86
|
|
|
@@ -301,10 +301,10 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
|
|
|
301
301
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
302
302
|
| Root API | 2 | 4 | 75 | 73 | 3 |
|
|
303
303
|
| Protocol API | 0 | 13 | 58 | 90 | 47 |
|
|
304
|
-
| Miniapp Publish API | 0 |
|
|
304
|
+
| Miniapp Publish API | 0 | 6 | 3 | 0 | 0 |
|
|
305
305
|
| Vite API | 0 | 1 | 5 | 1 | 3 |
|
|
306
306
|
|
|
307
|
-
<!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=
|
|
307
|
+
<!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=1dfd4c6306e8ac3680f60db083aa048395e38ffb49c30e19b49cc5db72249533 -->
|
|
308
308
|
|
|
309
309
|
## SDK API
|
|
310
310
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
## Package metadata
|
|
28
28
|
|
|
29
29
|
- Package: `@heybox/hb-sdk`
|
|
30
|
-
- Version at generation time: `0.8.1-alpha.
|
|
30
|
+
- Version at generation time: `0.8.1-alpha.15`
|
|
31
31
|
- Public root export: `@heybox/hb-sdk`
|
|
32
32
|
- Protocol export: `@heybox/hb-sdk/protocol`
|
|
33
33
|
- Vite plugin export: `@heybox/hb-sdk/vite`
|
|
@@ -328,6 +328,8 @@ hb-sdk build [--env <name>] [--verbose]
|
|
|
328
328
|
|
|
329
329
|
`hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `package.json#heybox.platforms` 声明目标平台,并在 `vite.config.ts` 中显式注册无参的 `miniappManifest()`;配置与构建产物不一致时构建失败。
|
|
330
330
|
|
|
331
|
+
`hb-sdk remote info` 会只读展示 `package.json#heybox.bindAppIds`、当前线上绑定以及新增/移除差异。修改绑定必须更新项目配置并重新提交版本;CLI、Open 和 COA 都不提供第二个写入入口。普通 deploy 在上传文件前把实际构建 Manifest 交给服务端预检;`--from-version` 只使用源版本快照。
|
|
332
|
+
|
|
331
333
|
直接运行 `hb-sdk build` 或 `vite build` 时默认注入平台 CSP。`hb-sdk remote deploy` 会在构建前读取绑定小程序的远端批准结果,并与当前版本声明取交集;仅当有效 `network` 权限启用时才跳过平台 CSP,`useOfficialDomain` 不参与该判定。权限缺失、非法或读取失败时继续注入,Runtime Gate、Manifest 与 HTML 构建检查始终保留。
|
|
332
334
|
|
|
333
335
|
推荐由项目的 `scripts.build` 保留类型检查:
|
package/skill/references/cli.md
CHANGED
|
@@ -172,6 +172,8 @@ hb-sdk build [--env <name>] [--verbose]
|
|
|
172
172
|
|
|
173
173
|
`hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `package.json#heybox.platforms` 声明目标平台,并在 `vite.config.ts` 中显式注册无参的 `miniappManifest()`;配置与构建产物不一致时构建失败。
|
|
174
174
|
|
|
175
|
+
`hb-sdk remote info` 会只读展示 `package.json#heybox.bindAppIds`、当前线上绑定以及新增/移除差异。修改绑定必须更新项目配置并重新提交版本;CLI、Open 和 COA 都不提供第二个写入入口。普通 deploy 在上传文件前把实际构建 Manifest 交给服务端预检;`--from-version` 只使用源版本快照。
|
|
176
|
+
|
|
175
177
|
直接运行 `hb-sdk build` 或 `vite build` 时默认注入平台 CSP。`hb-sdk remote deploy` 会在构建前读取绑定小程序的远端批准结果,并与当前版本声明取交集;仅当有效 `network` 权限启用时才跳过平台 CSP,`useOfficialDomain` 不参与该判定。权限缺失、非法或读取失败时继续注入,Runtime Gate、Manifest 与 HTML 构建检查始终保留。
|
|
176
178
|
|
|
177
179
|
推荐由项目的 `scripts.build` 保留类型检查:
|
package/skill/skill.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.8.1-alpha.
|
|
3
|
+
"skillVersion": "0.8.1-alpha.15+skill.b220fbc77b56",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.8.1-alpha.
|
|
7
|
-
"compatibility": "0.8.1-alpha.
|
|
6
|
+
"version": "0.8.1-alpha.15",
|
|
7
|
+
"compatibility": "0.8.1-alpha.15"
|
|
8
8
|
},
|
|
9
9
|
"distribution": {
|
|
10
10
|
"type": "npm",
|
|
11
11
|
"package": "@heybox/hb-sdk",
|
|
12
|
-
"version": "0.8.1-alpha.
|
|
12
|
+
"version": "0.8.1-alpha.15",
|
|
13
13
|
"path": "skill"
|
|
14
14
|
},
|
|
15
|
-
"integrity": "sha256-
|
|
15
|
+
"integrity": "sha256-b220fbc77b56021c0620c086c036ceba404be7a49741ffffb8bee9fce57706a7"
|
|
16
16
|
}
|
|
@@ -17,4 +17,5 @@ export declare function readMiniappPlatformsFromPackageJson(root: string): reado
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function readMiniappWindowFromPackageJson(root: string): MiniappWindowDeclaration | undefined;
|
|
19
19
|
export declare function readMiniappPermissionsFromPackageJson(root: string, sdkVersion: string): ParsedMiniappPermissions;
|
|
20
|
+
export declare function readMiniappBindAppIdsFromPackageJson(root: string): readonly string[];
|
|
20
21
|
export declare function resolveMiniappSdkVersion(): string;
|
|
@@ -41,6 +41,7 @@ export interface MiniappManifest {
|
|
|
41
41
|
permissions?: MiniappPermissionDeclarations;
|
|
42
42
|
companions?: MiniappCompanionManifestDeclarations;
|
|
43
43
|
window?: MiniappWindowDeclaration;
|
|
44
|
+
bindAppIds?: readonly string[];
|
|
44
45
|
}
|
|
45
46
|
export interface ParseMiniappManifestResult {
|
|
46
47
|
manifest: MiniappManifest;
|
|
@@ -52,6 +53,7 @@ export declare function validateMiniappManifestVersion(version: unknown, sourceL
|
|
|
52
53
|
export declare function renderMiniappManifest(manifest: MiniappManifest): string;
|
|
53
54
|
export declare function parseMiniappManifestJson(raw: string, sourceLabel?: string): ParseMiniappManifestResult;
|
|
54
55
|
export declare function validateMiniappManifestForDeploy(manifest: MiniappManifest): {
|
|
56
|
+
bindAppIds?: readonly string[] | undefined;
|
|
55
57
|
window?: MiniappWindowDeclaration | undefined;
|
|
56
58
|
companions?: MiniappCompanionManifestDeclarations | undefined;
|
|
57
59
|
permissions?: Partial<Record<"userInfo" | "steamLibrary" | "share" | "storage" | "filesystem" | "clipboard" | "leaderboard" | "companion", import("./permissions").SimpleMiniappPermissionDeclaration> & {
|
|
@@ -27,6 +27,7 @@ export declare const REOPEN_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_mi
|
|
|
27
27
|
export declare const UPDATE_SQUARE_DISPLAY_API_PATH = "/mall/developer/user_miniprogram/square_display/update";
|
|
28
28
|
export declare const LIST_USER_MINIPROGRAM_VERSION_API_PATH = "/mall/developer/user_miniprogram/version/list";
|
|
29
29
|
export { isValidMiniappManifestVersion as isValidVersion } from '../miniapp-manifest/schema';
|
|
30
|
+
export { parseMiniappBindAppIds, type ParseMiniappBindAppIdsOptions } from '../miniapp-manifest/bindings';
|
|
30
31
|
export declare function normalizeRelativePath(relativePath: string): string;
|
|
31
32
|
export declare function relativePathContainsNodeModulesSegment(relativePath: string): boolean;
|
|
32
33
|
export declare function getMiniProgramUploadAlias(miniProgramId: string): string;
|