@heybox/hb-sdk 0.8.1-alpha.13 → 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 +14 -0
- package/README.md +38 -0
- package/dist/cli-chunks/{build-CBPmqCVZ.cjs → build-6nkCiXV0.cjs} +21 -7
- package/dist/cli-chunks/{context-CvuPJq1G.cjs → context-DyeSJSqE.cjs} +2 -2
- package/dist/cli-chunks/{create-CyMWFYrc.cjs → create-wXBzkgmP.cjs} +1 -1
- package/dist/cli-chunks/{dev-BcAPHk9L.cjs → dev-Caq_oO7n.cjs} +28 -10
- package/dist/cli-chunks/{doctor-CIwaVrM1.cjs → doctor-n4vISsD-.cjs} +1 -1
- package/dist/cli-chunks/{index-E0qh3FUb.cjs → index-BTUkiKjC.cjs} +15 -15
- package/dist/cli-chunks/{index-B0KCGR9H.cjs → index-hyB5_A_G.cjs} +2 -2
- package/dist/cli-chunks/{index.esm-DTEOIvDp.cjs → index.esm-DU-rsJ3-.cjs} +7 -7
- package/dist/cli-chunks/{login-DGvHzH9j.cjs → login-CsXZXtCS.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CRnpRhSb.cjs → project-vite-87sg4Mnk.cjs} +1 -1
- package/dist/cli-chunks/{remote-C1_Hs11w.cjs → remote-Cfr3wcGq.cjs} +74 -10
- package/dist/cli-chunks/{runtime-permission-env-Bn1ONUDU.cjs → runtime-permission-env-B3wQZF2c.cjs} +128 -1
- package/dist/cli-chunks/{session-BvZgS7VI.cjs → session-YWsulrKF.cjs} +1 -1
- package/dist/cli-chunks/{skill-BVT6fBpQ.cjs → skill-CS2JoOL8.cjs} +2 -2
- package/dist/cli-chunks/{version-CJTEIaOQ.cjs → version-DXjXtCXW.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-DOzYp6JS.js → browser-dev-host-GNgPrL3B.js} +21 -21
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-DZ_umnQp.js → desktop-app-launch-BUVHeuGC.js} +3 -3
- package/dist/devtools/browser-dev-host/assets/{index-DoPg_zh_.js → index-C3EtSrqt.js} +4 -4
- 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 +179 -17
- package/dist/vite.esm.js +179 -18
- package/package.json +5 -5
- package/skill/SKILL.md +17 -14
- package/skill/references/api-protocol.md +3 -3
- package/skill/references/api-root.md +3 -1
- package/skill/references/cli.md +2 -0
- package/skill/references/safety-boundaries.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 +9 -1
- package/types/miniapp-manifest/schema.d.ts +39 -0
- package/types/miniapp-publish/index.d.ts +1 -0
- package/types/vite/index.d.ts +1 -0
package/dist/cli-chunks/{runtime-permission-env-Bn1ONUDU.cjs → runtime-permission-env-B3wQZF2c.cjs}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var version = require('./version-
|
|
5
|
+
var version = require('./version-DXjXtCXW.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
var node_async_hooks = require('node:async_hooks');
|
|
8
8
|
|
|
@@ -2791,6 +2791,35 @@ function requireSemver () {
|
|
|
2791
2791
|
|
|
2792
2792
|
var semverExports = requireSemver();
|
|
2793
2793
|
|
|
2794
|
+
const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
|
|
2795
|
+
function parseMiniappBindAppIds(value, options = {}) {
|
|
2796
|
+
const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
|
|
2797
|
+
if (value === undefined)
|
|
2798
|
+
return Object.freeze([]);
|
|
2799
|
+
if (!Array.isArray(value))
|
|
2800
|
+
throw new Error(`${sourceLabel} 必须是字符串数组`);
|
|
2801
|
+
if (value.length > MINIAPP_BIND_APP_IDS_MAX_COUNT) {
|
|
2802
|
+
throw new Error(`${sourceLabel} 最多包含 ${MINIAPP_BIND_APP_IDS_MAX_COUNT} 个游戏 appid`);
|
|
2803
|
+
}
|
|
2804
|
+
const seen = new Set();
|
|
2805
|
+
const appIds = [];
|
|
2806
|
+
for (const item of value) {
|
|
2807
|
+
if (typeof item !== 'string' || !/^[1-9]\d*$/.test(item)) {
|
|
2808
|
+
throw new Error(`${sourceLabel} 包含非法游戏 appid:${String(item)}`);
|
|
2809
|
+
}
|
|
2810
|
+
const numeric = Number(item);
|
|
2811
|
+
if (!Number.isSafeInteger(numeric) || numeric > 2_147_483_647) {
|
|
2812
|
+
throw new Error(`${sourceLabel} 包含超出正 int32 范围的游戏 appid:${item}`);
|
|
2813
|
+
}
|
|
2814
|
+
if (seen.has(item))
|
|
2815
|
+
throw new Error(`${sourceLabel} 包含重复游戏 appid:${item}`);
|
|
2816
|
+
seen.add(item);
|
|
2817
|
+
appIds.push(item);
|
|
2818
|
+
}
|
|
2819
|
+
appIds.sort((left, right) => Number(left) - Number(right));
|
|
2820
|
+
return Object.freeze(appIds);
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2794
2823
|
const MINI_PROGRAM_PERMISSION_KEYS = [
|
|
2795
2824
|
'userInfo',
|
|
2796
2825
|
'steamLibrary',
|
|
@@ -3108,6 +3137,10 @@ function isRecord$3(value) {
|
|
|
3108
3137
|
}
|
|
3109
3138
|
|
|
3110
3139
|
const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
|
|
3140
|
+
/** 窗口尺寸字段的脏值兜底上限;真正的上限是宿主侧显示器 workArea。 */
|
|
3141
|
+
const MINIAPP_WINDOW_SIZE_MAX = 16_384;
|
|
3142
|
+
const MINIAPP_WINDOW_NUMBER_FIELDS = ['defaultWidth', 'defaultHeight', 'minWidth', 'minHeight'];
|
|
3143
|
+
const MINIAPP_WINDOW_ALLOWED_FIELDS = [...MINIAPP_WINDOW_NUMBER_FIELDS, 'resizable'];
|
|
3111
3144
|
/**
|
|
3112
3145
|
* 桌面平台子集:从唯一平台词表 `MINIAPP_PLATFORM_VALUES` 派生,`satisfies` 阻止它漂移出词表。
|
|
3113
3146
|
* 小程序声明其中任一平台,即视为该项目承诺适配 PC / 桌面端;调试台据此取舍桌面调试入口。
|
|
@@ -3158,12 +3191,16 @@ function validateMiniappManifestForDeploy(manifest) {
|
|
|
3158
3191
|
sourceLabel: 'manifest.permissions',
|
|
3159
3192
|
});
|
|
3160
3193
|
const companions = validateGeneratedCompanions(manifest.companions);
|
|
3194
|
+
const window = validateMiniappWindow(manifest.window, 'manifest.window');
|
|
3195
|
+
const bindAppIds = parseMiniappBindAppIds(manifest.bindAppIds, { sourceLabel: 'manifest.bindAppIds' });
|
|
3161
3196
|
return {
|
|
3162
3197
|
version,
|
|
3163
3198
|
sdkVersion,
|
|
3164
3199
|
platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
|
|
3165
3200
|
...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
|
|
3166
3201
|
...(companions === undefined ? {} : { companions }),
|
|
3202
|
+
...(window === undefined ? {} : { window }),
|
|
3203
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
3167
3204
|
};
|
|
3168
3205
|
}
|
|
3169
3206
|
function validateGeneratedCompanions(value) {
|
|
@@ -3240,6 +3277,77 @@ function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
|
|
|
3240
3277
|
function areMiniappPlatformsEqual(left, right) {
|
|
3241
3278
|
return left.length === right.length && left.every((platform, index) => platform === right[index]);
|
|
3242
3279
|
}
|
|
3280
|
+
/**
|
|
3281
|
+
* 校验并归一化 `package.json#heybox.window` / `manifest.window` 声明。
|
|
3282
|
+
*
|
|
3283
|
+
* @remarks
|
|
3284
|
+
* 与 `heybox.permissions` 同样的严格风格:未知字段报错,不做静默忽略。
|
|
3285
|
+
* `width` / `height` 显式给出改名提示;`x` / `y` 按未知字段显式报错(`INV-NO-DEV-POSITION`)。
|
|
3286
|
+
* 未声明时返回 `undefined`,由调用方决定不写入产物。
|
|
3287
|
+
* @param value - 待校验的原始声明(不可信输入)。
|
|
3288
|
+
* @param sourceLabel - 报错前缀,默认指向开发者声明路径。
|
|
3289
|
+
* @throws 当声明不是非空对象、含未知字段、数值/布尔类型不合法或 min/default 不配对时抛出。
|
|
3290
|
+
*/
|
|
3291
|
+
function validateMiniappWindow(value, sourceLabel = 'package.json#heybox.window') {
|
|
3292
|
+
if (value === undefined)
|
|
3293
|
+
return undefined;
|
|
3294
|
+
if (!isRecord$2(value) || Object.keys(value).length === 0) {
|
|
3295
|
+
throw new Error(`${sourceLabel} 至少需要声明 defaultWidth/defaultHeight/minWidth/minHeight/resizable 之一`);
|
|
3296
|
+
}
|
|
3297
|
+
if (Object.prototype.hasOwnProperty.call(value, 'width') || Object.prototype.hasOwnProperty.call(value, 'height')) {
|
|
3298
|
+
throw new Error(`${sourceLabel} 请使用 defaultWidth/defaultHeight,而不是 width/height`);
|
|
3299
|
+
}
|
|
3300
|
+
for (const key of Object.keys(value)) {
|
|
3301
|
+
if (!MINIAPP_WINDOW_ALLOWED_FIELDS.includes(key)) {
|
|
3302
|
+
throw new Error(`${sourceLabel} 包含未知字段:${key}`);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
const window = {};
|
|
3306
|
+
for (const field of MINIAPP_WINDOW_NUMBER_FIELDS) {
|
|
3307
|
+
if (!Object.prototype.hasOwnProperty.call(value, field))
|
|
3308
|
+
continue;
|
|
3309
|
+
const size = value[field];
|
|
3310
|
+
if (typeof size !== 'number' || !Number.isSafeInteger(size) || size <= 0) {
|
|
3311
|
+
throw new Error(`${sourceLabel}.${field} 必须是正整数`);
|
|
3312
|
+
}
|
|
3313
|
+
if (size > MINIAPP_WINDOW_SIZE_MAX) {
|
|
3314
|
+
throw new Error(`${sourceLabel}.${field} 不能大于 ${MINIAPP_WINDOW_SIZE_MAX}`);
|
|
3315
|
+
}
|
|
3316
|
+
window[field] = size;
|
|
3317
|
+
}
|
|
3318
|
+
if (Object.prototype.hasOwnProperty.call(value, 'resizable')) {
|
|
3319
|
+
if (typeof value.resizable !== 'boolean') {
|
|
3320
|
+
throw new Error(`${sourceLabel}.resizable 必须是 boolean`);
|
|
3321
|
+
}
|
|
3322
|
+
window.resizable = value.resizable;
|
|
3323
|
+
}
|
|
3324
|
+
for (const [minimum, fallback] of [
|
|
3325
|
+
['minWidth', 'defaultWidth'],
|
|
3326
|
+
['minHeight', 'defaultHeight'],
|
|
3327
|
+
]) {
|
|
3328
|
+
const minimumValue = window[minimum];
|
|
3329
|
+
if (minimumValue === undefined)
|
|
3330
|
+
continue;
|
|
3331
|
+
const fallbackValue = window[fallback];
|
|
3332
|
+
if (fallbackValue === undefined) {
|
|
3333
|
+
throw new Error(`${sourceLabel}.${minimum} 必须与 ${fallback} 同时声明`);
|
|
3334
|
+
}
|
|
3335
|
+
if (minimumValue > fallbackValue) {
|
|
3336
|
+
throw new Error(`${sourceLabel}.${minimum} 必须小于等于 ${fallback}`);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
return window;
|
|
3340
|
+
}
|
|
3341
|
+
/** 比较两份窗口声明是否逐字段一致;未声明视同 `undefined`。 */
|
|
3342
|
+
function areMiniappWindowsEqual(left, right) {
|
|
3343
|
+
if (left === undefined || right === undefined)
|
|
3344
|
+
return left === right;
|
|
3345
|
+
return (left.defaultWidth === right.defaultWidth &&
|
|
3346
|
+
left.defaultHeight === right.defaultHeight &&
|
|
3347
|
+
left.minWidth === right.minWidth &&
|
|
3348
|
+
left.minHeight === right.minHeight &&
|
|
3349
|
+
left.resizable === right.resizable);
|
|
3350
|
+
}
|
|
3243
3351
|
function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
|
|
3244
3352
|
if (typeof version !== 'string' || version.trim() === '') {
|
|
3245
3353
|
throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
|
|
@@ -3637,6 +3745,17 @@ function readMiniappPlatformsFromPackageJson(root) {
|
|
|
3637
3745
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3638
3746
|
return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
|
|
3639
3747
|
}
|
|
3748
|
+
/**
|
|
3749
|
+
* 读取并校验 `package.json#heybox.window`。
|
|
3750
|
+
*
|
|
3751
|
+
* @returns 合法声明;未声明时返回 `undefined`,调用方不得向 manifest 写入空对象或 `null`。
|
|
3752
|
+
* @throws 当声明违反 {@link validateMiniappWindow} 的规则时抛出,报错前缀为 `package.json#heybox.window`。
|
|
3753
|
+
*/
|
|
3754
|
+
function readMiniappWindowFromPackageJson(root) {
|
|
3755
|
+
const { packageJson } = readMiniappPackageJson(root);
|
|
3756
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3757
|
+
return validateMiniappWindow(heybox?.window, 'package.json#heybox.window');
|
|
3758
|
+
}
|
|
3640
3759
|
function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
3641
3760
|
const { packageJson } = readMiniappPackageJson(root);
|
|
3642
3761
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
@@ -3646,6 +3765,11 @@ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
|
3646
3765
|
sdkVersion,
|
|
3647
3766
|
});
|
|
3648
3767
|
}
|
|
3768
|
+
function readMiniappBindAppIdsFromPackageJson(root) {
|
|
3769
|
+
const { packageJson } = readMiniappPackageJson(root);
|
|
3770
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3771
|
+
return parseMiniappBindAppIds(heybox?.bindAppIds);
|
|
3772
|
+
}
|
|
3649
3773
|
function resolveMiniappSdkVersion() {
|
|
3650
3774
|
if (!version.HB_SDK_VERSION.startsWith('__HB_SDK_'))
|
|
3651
3775
|
return version.HB_SDK_VERSION;
|
|
@@ -3789,6 +3913,7 @@ exports.USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = USER_MINIPROGRAM_PREVIEW_A
|
|
|
3789
3913
|
exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH;
|
|
3790
3914
|
exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
|
|
3791
3915
|
exports.areMiniappPlatformsEqual = areMiniappPlatformsEqual;
|
|
3916
|
+
exports.areMiniappWindowsEqual = areMiniappWindowsEqual;
|
|
3792
3917
|
exports.composeMiniappRuntimePermissions = composeMiniappRuntimePermissions;
|
|
3793
3918
|
exports.createMiniappArtifactFileHeader = createMiniappArtifactFileHeader;
|
|
3794
3919
|
exports.createMiniappArtifactSignatureHeader = createMiniappArtifactSignatureHeader;
|
|
@@ -3800,8 +3925,10 @@ exports.normalizeRelativePath = normalizeRelativePath;
|
|
|
3800
3925
|
exports.parseMiniProgramRuntimePermissions = parseMiniProgramRuntimePermissions;
|
|
3801
3926
|
exports.parseMiniappManifestJson = parseMiniappManifestJson;
|
|
3802
3927
|
exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
|
|
3928
|
+
exports.readMiniappBindAppIdsFromPackageJson = readMiniappBindAppIdsFromPackageJson;
|
|
3803
3929
|
exports.readMiniappPermissionsFromPackageJson = readMiniappPermissionsFromPackageJson;
|
|
3804
3930
|
exports.readMiniappPlatformsFromPackageJson = readMiniappPlatformsFromPackageJson;
|
|
3931
|
+
exports.readMiniappWindowFromPackageJson = readMiniappWindowFromPackageJson;
|
|
3805
3932
|
exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
|
|
3806
3933
|
exports.requireSemver = requireSemver;
|
|
3807
3934
|
exports.resolveMiniappSdkVersion = resolveMiniappSdkVersion;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = require('./version-
|
|
3
|
+
var version = require('./version-DXjXtCXW.cjs');
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var childProcess = require('node:child_process');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-BTUkiKjC.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('path');
|