@heybox/hb-sdk 0.8.1-alpha.8 → 0.8.1
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 +97 -1
- package/README.md +64 -18
- package/dist/cli-chunks/{build-BYWPo2MY.cjs → build-DPe1Ycjd.cjs} +21 -7
- package/dist/cli-chunks/{context-B4tBsR6l.cjs → context-BSUhAv3Z.cjs} +2 -2
- package/dist/cli-chunks/{create-Dct-INxs.cjs → create-CaiKrGnb.cjs} +2 -1
- package/dist/cli-chunks/{dev-6N5ruKiC.cjs → dev-BG1o8Q-0.cjs} +45 -12
- package/dist/cli-chunks/doctor-DutO2P5H.cjs +195 -0
- package/dist/cli-chunks/{index-Cl5cfUqJ.cjs → index-Bur0U2z1.cjs} +2 -2
- package/dist/cli-chunks/{index-Bc4AXYHM.cjs → index-CKIyipP9.cjs} +77 -21
- package/dist/cli-chunks/{index.esm-DhXN7XjE.cjs → index.esm-BPlpP-O0.cjs} +8 -8
- package/dist/cli-chunks/{login-CTZgu8Q-.cjs → login-C1JlLEza.cjs} +2 -2
- package/dist/cli-chunks/{project-vite--h2M6eBb.cjs → project-vite-Bd0WzAqQ.cjs} +1 -1
- package/dist/cli-chunks/{remote-0hw42fDG.cjs → remote-DTFEf3Dj.cjs} +74 -10
- package/dist/cli-chunks/{runtime-permission-env-Bvggu6mn.cjs → runtime-permission-env-C2S34ldj.cjs} +145 -4
- package/dist/cli-chunks/{session-5fnHlEGO.cjs → session-zXVkHuhY.cjs} +1 -1
- package/dist/cli-chunks/{skill-DrFEqmdD.cjs → skill-CCB3DyXk.cjs} +3 -2
- package/dist/cli-chunks/{version-CccOA4so.cjs → version-0qwlEyZC.cjs} +1 -1
- package/dist/cli.cjs +2 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-pUcws1MK.js +101 -0
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-DnPRjCa3.js → desktop-app-launch-DOfl5YvO.js} +3 -3
- package/dist/devtools/browser-dev-host/assets/{index-8LTH05np.js → index-CFr28-0O.js} +4 -4
- package/dist/devtools/browser-dev-host/assets/{index-D-aNERAr.css → index-DXd5IZBz.css} +1 -1
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +24 -24
- package/dist/index.esm.js +24 -24
- package/dist/miniapp-publish.cjs.js +121 -3
- package/dist/miniapp-publish.esm.js +118 -4
- package/dist/protocol.cjs.js +27 -27
- package/dist/protocol.esm.js +27 -27
- package/dist/vite.cjs.js +179 -17
- package/dist/vite.esm.js +179 -18
- package/docs/device-logs.md +36 -0
- package/docs/runtime-host-migration.md +120 -0
- package/package.json +9 -7
- package/skill/SKILL.md +25 -20
- package/skill/references/api-protocol.md +3 -3
- package/skill/references/api-root.md +104 -11
- package/skill/references/cli.md +110 -9
- package/skill/references/examples.md +2 -2
- package/skill/references/recipes.md +25 -10
- package/skill/references/safety-boundaries.md +10 -7
- 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 +94 -0
- package/types/miniapp-publish/index.d.ts +4 -2
- package/types/modules/companion/index.d.ts +68 -0
- package/types/modules/files/types.d.ts +10 -11
- package/types/modules/network/index.d.ts +3 -3
- package/types/skill-metadata.d.ts +16 -0
- package/types/vite/index.d.ts +1 -0
- package/dist/cli-chunks/doctor-9HtdddBL.cjs +0 -65
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-BQ9v4rI1.js +0 -101
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var promises = require('node:readline/promises');
|
|
4
|
-
var index = require('./index-
|
|
5
|
-
var session = require('./session-
|
|
4
|
+
var index = require('./index-CKIyipP9.cjs');
|
|
5
|
+
var session = require('./session-zXVkHuhY.cjs');
|
|
6
6
|
var childProcess = require('node:child_process');
|
|
7
7
|
var fs = require('node:fs');
|
|
8
8
|
var fs$1 = require('node:fs/promises');
|
|
9
9
|
var path = require('node:path');
|
|
10
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
10
|
+
var runtimePermissionEnv = require('./runtime-permission-env-C2S34ldj.cjs');
|
|
11
11
|
var node_crypto = require('node:crypto');
|
|
12
12
|
require('node:zlib');
|
|
13
13
|
var runtimeGate = require('./runtime-gate-BWb8QIcX.cjs');
|
|
14
|
-
var context = require('./context-
|
|
14
|
+
var context = require('./context-BSUhAv3Z.cjs');
|
|
15
15
|
require('node:module');
|
|
16
16
|
require('path');
|
|
17
17
|
require('os');
|
|
@@ -24,7 +24,7 @@ require('buffer');
|
|
|
24
24
|
require('util');
|
|
25
25
|
require('fs');
|
|
26
26
|
require('constants');
|
|
27
|
-
require('./version-
|
|
27
|
+
require('./version-0qwlEyZC.cjs');
|
|
28
28
|
require('node:async_hooks');
|
|
29
29
|
|
|
30
30
|
async function getCDNUploadInfo(options, runtime = {}) {
|
|
@@ -69,6 +69,7 @@ async function precheckUserMiniprogramVersion(options, runtime = {}) {
|
|
|
69
69
|
// 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
|
|
70
70
|
...(options.version ? { version: options.version } : {}),
|
|
71
71
|
...(options.source_version ? { source_version: options.source_version } : {}),
|
|
72
|
+
...(options.manifest ? { manifest: JSON.stringify(options.manifest) } : {}),
|
|
72
73
|
release_note: options.releaseNote,
|
|
73
74
|
auto_publish: String(options.autoPublish),
|
|
74
75
|
}, runtime);
|
|
@@ -274,7 +275,7 @@ function createDefaultCosClient(uploadToken, COS) {
|
|
|
274
275
|
};
|
|
275
276
|
}
|
|
276
277
|
async function loadCosConstructor() {
|
|
277
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
278
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-Bur0U2z1.cjs'); }).then(function (n) { return n.index; });
|
|
278
279
|
return cosModule.default;
|
|
279
280
|
}
|
|
280
281
|
function formatSize(bytes) {
|
|
@@ -516,6 +517,8 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
516
517
|
}
|
|
517
518
|
const fromVersion = options.fromVersion?.trim();
|
|
518
519
|
const declaredPlatforms = fromVersion ? undefined : runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
|
|
520
|
+
const declaredWindow = fromVersion ? undefined : runtimePermissionEnv.readMiniappWindowFromPackageJson(projectRoot);
|
|
521
|
+
const declaredBindAppIds = fromVersion ? undefined : runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(projectRoot);
|
|
519
522
|
const releaseNote = await resolveDeployReleaseNote(options, runtime);
|
|
520
523
|
const session$1 = await logger.task('正在校验 Heybox 登录态', () => (runtime.requireAuthSession ?? session.requireHeyboxAuthSession)({ loginBaseUrl }), { successText: 'Heybox 登录态有效' });
|
|
521
524
|
logger.debug(`Heybox API: ${apiBaseUrl}`);
|
|
@@ -593,9 +596,23 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
593
596
|
if (!declaredPlatforms || !runtimePermissionEnv.areMiniappPlatformsEqual(parsedManifest.platforms, declaredPlatforms)) {
|
|
594
597
|
throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build 后再 deploy');
|
|
595
598
|
}
|
|
599
|
+
if (!runtimePermissionEnv.areMiniappWindowsEqual(parsedManifest.window, declaredWindow)) {
|
|
600
|
+
throw new Error('dist/manifest.json.window 与 package.json#heybox.window 不一致,请重新 build 后再 deploy');
|
|
601
|
+
}
|
|
596
602
|
if (version !== precheckVersion) {
|
|
597
603
|
throw new Error(`dist/manifest.json.version (${version}) 与预检版本 (${precheckVersion}) 不一致,请重新 build 后再 deploy`);
|
|
598
604
|
}
|
|
605
|
+
if (declaredBindAppIds && !areStringArraysEqual(parsedManifest.bindAppIds, declaredBindAppIds)) {
|
|
606
|
+
throw new Error('dist/manifest.json.bindAppIds 与 package.json#heybox.bindAppIds 不一致,请重新 build 后再 deploy');
|
|
607
|
+
}
|
|
608
|
+
await runVersionPrecheck({
|
|
609
|
+
session: session$1,
|
|
610
|
+
miniProgramId,
|
|
611
|
+
version,
|
|
612
|
+
manifest,
|
|
613
|
+
releaseNote,
|
|
614
|
+
autoPublish,
|
|
615
|
+
}, runtime, apiBaseUrl, projectRoot, logger);
|
|
599
616
|
const uploadFiles = await logger.task('正在校验 dist 上传文件', async () => {
|
|
600
617
|
const allFiles = await walkDistFiles(distDir);
|
|
601
618
|
const blocked = allFiles.find((entry) => runtimePermissionEnv.relativePathContainsNodeModulesSegment(entry.relativePath));
|
|
@@ -733,6 +750,9 @@ function findProjectRoot(startDir) {
|
|
|
733
750
|
async function readPackageJson(projectRoot) {
|
|
734
751
|
return JSON.parse(await fs$1.readFile(path.join(projectRoot, 'package.json'), 'utf8'));
|
|
735
752
|
}
|
|
753
|
+
function areStringArraysEqual(left, right) {
|
|
754
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
755
|
+
}
|
|
736
756
|
async function readDeployManifest(projectRoot, logger) {
|
|
737
757
|
const distDir = path.join(projectRoot, 'dist');
|
|
738
758
|
const manifestPath = path.join(distDir, 'manifest.json');
|
|
@@ -752,11 +772,18 @@ async function readDeployManifest(projectRoot, logger) {
|
|
|
752
772
|
logger.warn('dist/manifest.json 包含 BOM,已自动剥离');
|
|
753
773
|
}
|
|
754
774
|
const validated = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
|
|
775
|
+
const bindAppIds = validated.bindAppIds ?? [];
|
|
755
776
|
return {
|
|
756
|
-
manifest: {
|
|
777
|
+
manifest: {
|
|
778
|
+
...manifest,
|
|
779
|
+
platforms: validated.platforms,
|
|
780
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
781
|
+
},
|
|
782
|
+
bindAppIds,
|
|
757
783
|
sdkVersion: validated.sdkVersion,
|
|
758
784
|
version: validated.version,
|
|
759
785
|
platforms: validated.platforms,
|
|
786
|
+
...(validated.window === undefined ? {} : { window: validated.window }),
|
|
760
787
|
};
|
|
761
788
|
}
|
|
762
789
|
function validateVersionForDeploy(version, sourceLabel) {
|
|
@@ -1261,9 +1288,18 @@ async function remoteInfo(options, context, runtime) {
|
|
|
1261
1288
|
const detail = await context.api.getMiniProgramDetail(miniProgramId);
|
|
1262
1289
|
const localPermissions = runtimePermissionEnv.readMiniappPermissionsFromPackageJson(context.packageJson.projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
|
|
1263
1290
|
const permissionViews = runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, detail.runtime_permissions).views;
|
|
1264
|
-
const
|
|
1291
|
+
const localBindAppIds = runtimePermissionEnv.readMiniappBindAppIdsFromPackageJson(context.packageJson.projectRoot);
|
|
1292
|
+
const currentBindApps = normalizeRemoteBoundApps(detail.bind_apps);
|
|
1293
|
+
const currentByID = new Map(currentBindApps.map((item) => [item.appid, item]));
|
|
1294
|
+
const local = localBindAppIds.map((appid) => currentByID.get(appid) ?? { appid });
|
|
1295
|
+
const currentIDs = new Set(currentBindApps.map((item) => item.appid));
|
|
1296
|
+
const added = local.filter((item) => !currentIDs.has(item.appid));
|
|
1297
|
+
const localIDs = new Set(localBindAppIds);
|
|
1298
|
+
const removed = currentBindApps.filter((item) => !localIDs.has(item.appid));
|
|
1299
|
+
const bindings = { local, current: currentBindApps, added, removed };
|
|
1300
|
+
const output = { changed: false, miniProgramId, detail: toCamelCaseDeep(detail), permissions: permissionViews, bindings };
|
|
1265
1301
|
if (!options.json) {
|
|
1266
|
-
printMiniProgramDetail(context.logger, detail, permissionViews);
|
|
1302
|
+
printMiniProgramDetail(context.logger, detail, permissionViews, bindings);
|
|
1267
1303
|
}
|
|
1268
1304
|
return finishRemoteCommand(options, runtime, output);
|
|
1269
1305
|
}
|
|
@@ -1762,7 +1798,7 @@ async function promptConfirm(message, runtime) {
|
|
|
1762
1798
|
rl.close();
|
|
1763
1799
|
}
|
|
1764
1800
|
}
|
|
1765
|
-
function printMiniProgramDetail(logger, detail, permissionViews) {
|
|
1801
|
+
function printMiniProgramDetail(logger, detail, permissionViews, bindings) {
|
|
1766
1802
|
logger.info(`Mini-program: ${detail.mini_program_id ?? '--'}`);
|
|
1767
1803
|
logger.info(`Name: ${detail.name ?? '--'}`);
|
|
1768
1804
|
logger.info(`Status: ${detail.status ?? '--'}`);
|
|
@@ -1781,6 +1817,34 @@ function printMiniProgramDetail(logger, detail, permissionViews) {
|
|
|
1781
1817
|
: '';
|
|
1782
1818
|
logger.info(` ${view.key}: 声明=${view.declared ? '是' : '否'}${approval} 最终=${view.effective ? '可用' : '不可用'}${configs}`);
|
|
1783
1819
|
}
|
|
1820
|
+
if (bindings) {
|
|
1821
|
+
logger.info('关联游戏(本地/线上/新增/移除):');
|
|
1822
|
+
logger.info(` local=${formatBoundApps(bindings.local)}`);
|
|
1823
|
+
logger.info(` current=${formatBoundApps(bindings.current)}`);
|
|
1824
|
+
logger.info(` added=${formatBoundApps(bindings.added)}`);
|
|
1825
|
+
logger.info(` removed=${formatBoundApps(bindings.removed)}`);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
function normalizeRemoteBoundApps(value) {
|
|
1829
|
+
if (!Array.isArray(value))
|
|
1830
|
+
return [];
|
|
1831
|
+
return value.flatMap((item) => {
|
|
1832
|
+
if (!item || typeof item !== 'object')
|
|
1833
|
+
return [];
|
|
1834
|
+
const source = item;
|
|
1835
|
+
if (typeof source.appid !== 'string' || !/^[1-9]\d*$/.test(source.appid))
|
|
1836
|
+
return [];
|
|
1837
|
+
return [
|
|
1838
|
+
{
|
|
1839
|
+
appid: source.appid,
|
|
1840
|
+
...(typeof source.name === 'string' && source.name.trim() ? { name: source.name.trim() } : {}),
|
|
1841
|
+
...(typeof source.icon_url === 'string' && source.icon_url.trim() ? { icon_url: source.icon_url.trim() } : {}),
|
|
1842
|
+
},
|
|
1843
|
+
];
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
function formatBoundApps(items) {
|
|
1847
|
+
return items.length === 0 ? '--' : items.map((item) => (item.name ? `${item.appid}(${item.name})` : item.appid)).join(', ');
|
|
1784
1848
|
}
|
|
1785
1849
|
function printDeveloperEntities(logger, entities) {
|
|
1786
1850
|
for (const entity of entities) {
|
package/dist/cli-chunks/{runtime-permission-env-Bvggu6mn.cjs → runtime-permission-env-C2S34ldj.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-0qwlEyZC.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,23 @@ 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'];
|
|
3144
|
+
/**
|
|
3145
|
+
* 桌面平台子集:从唯一平台词表 `MINIAPP_PLATFORM_VALUES` 派生,`satisfies` 阻止它漂移出词表。
|
|
3146
|
+
* 小程序声明其中任一平台,即视为该项目承诺适配 PC / 桌面端;调试台据此取舍桌面调试入口。
|
|
3147
|
+
*
|
|
3148
|
+
* 注意:子集只表达「声明为桌面」,不保证已有可用的客户端基线——例如 `linux` 目前既没有 `@hbPlatform` 声明,
|
|
3149
|
+
* 也没有 Companion target,仅声明 `linux` 的项目会展示入口但未必能真正打开。
|
|
3150
|
+
*/
|
|
3151
|
+
const MINIAPP_DESKTOP_PLATFORM_VALUES = ['windows', 'macos', 'linux'];
|
|
3152
|
+
function hasMiniappDesktopPlatform(platforms) {
|
|
3153
|
+
if (!platforms)
|
|
3154
|
+
return false;
|
|
3155
|
+
return MINIAPP_DESKTOP_PLATFORM_VALUES.some((platform) => platforms.includes(platform));
|
|
3156
|
+
}
|
|
3111
3157
|
function isValidMiniappManifestVersion(version) {
|
|
3112
3158
|
return getMiniappManifestVersionError(version) === undefined;
|
|
3113
3159
|
}
|
|
@@ -3145,12 +3191,16 @@ function validateMiniappManifestForDeploy(manifest) {
|
|
|
3145
3191
|
sourceLabel: 'manifest.permissions',
|
|
3146
3192
|
});
|
|
3147
3193
|
const companions = validateGeneratedCompanions(manifest.companions);
|
|
3194
|
+
const window = validateMiniappWindow(manifest.window, 'manifest.window');
|
|
3195
|
+
const bindAppIds = parseMiniappBindAppIds(manifest.bindAppIds, { sourceLabel: 'manifest.bindAppIds' });
|
|
3148
3196
|
return {
|
|
3149
3197
|
version,
|
|
3150
3198
|
sdkVersion,
|
|
3151
3199
|
platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
|
|
3152
3200
|
...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
|
|
3153
3201
|
...(companions === undefined ? {} : { companions }),
|
|
3202
|
+
...(window === undefined ? {} : { window }),
|
|
3203
|
+
...(bindAppIds.length === 0 ? {} : { bindAppIds }),
|
|
3154
3204
|
};
|
|
3155
3205
|
}
|
|
3156
3206
|
function validateGeneratedCompanions(value) {
|
|
@@ -3227,6 +3277,77 @@ function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
|
|
|
3227
3277
|
function areMiniappPlatformsEqual(left, right) {
|
|
3228
3278
|
return left.length === right.length && left.every((platform, index) => platform === right[index]);
|
|
3229
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
|
+
}
|
|
3230
3351
|
function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
|
|
3231
3352
|
if (typeof version !== 'string' || version.trim() === '') {
|
|
3232
3353
|
throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
|
|
@@ -3275,8 +3396,8 @@ const MINIAPP_UPLOAD_SCOPE = 'activity';
|
|
|
3275
3396
|
const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
|
|
3276
3397
|
const MINIAPP_UPLOAD_BATCH_SIZE = 50;
|
|
3277
3398
|
const MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES = 100 * 1024 * 1024;
|
|
3278
|
-
/**
|
|
3279
|
-
const MINIAPP_COMPANION_UPLOAD_TEMPORARY_SIZE_LIMIT_BYTES =
|
|
3399
|
+
/** 与 Activity 上传后端合同一致的 Companion 归档总大小上限。 */
|
|
3400
|
+
const MINIAPP_COMPANION_UPLOAD_TEMPORARY_SIZE_LIMIT_BYTES = 500 * 1024 * 1024;
|
|
3280
3401
|
const USER_MINIPROGRAM_ACCESS_STATUS_API_PATH = '/mall/developer/user_miniprogram/access_status';
|
|
3281
3402
|
const DEVELOPER_ENTITY_LIST_API_PATH = '/mall/developer/entity/list';
|
|
3282
3403
|
const DEVELOPER_ENTITY_SWITCH_API_PATH = '/mall/developer/entity/switch';
|
|
@@ -3345,7 +3466,7 @@ function validateMiniappUploadSizeBudgets(items, options = {}) {
|
|
|
3345
3466
|
const companionTotal = companionItems.reduce((sum, item) => sum + (Number.isFinite(item.size) && item.size > 0 ? item.size : 0), 0);
|
|
3346
3467
|
const companionLimit = options.companionLimitBytes ?? MINIAPP_COMPANION_UPLOAD_TEMPORARY_SIZE_LIMIT_BYTES;
|
|
3347
3468
|
if (companionTotal > companionLimit)
|
|
3348
|
-
return 'Companion
|
|
3469
|
+
return 'Companion 归档总大小超过 500MiB 上限,请缩减归档后重新 deploy';
|
|
3349
3470
|
return undefined;
|
|
3350
3471
|
}
|
|
3351
3472
|
function shouldUploadDistFile(relativePath) {
|
|
@@ -3624,6 +3745,17 @@ function readMiniappPlatformsFromPackageJson(root) {
|
|
|
3624
3745
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3625
3746
|
return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
|
|
3626
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
|
+
}
|
|
3627
3759
|
function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
3628
3760
|
const { packageJson } = readMiniappPackageJson(root);
|
|
3629
3761
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
@@ -3633,6 +3765,11 @@ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
|
3633
3765
|
sdkVersion,
|
|
3634
3766
|
});
|
|
3635
3767
|
}
|
|
3768
|
+
function readMiniappBindAppIdsFromPackageJson(root) {
|
|
3769
|
+
const { packageJson } = readMiniappPackageJson(root);
|
|
3770
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3771
|
+
return parseMiniappBindAppIds(heybox?.bindAppIds);
|
|
3772
|
+
}
|
|
3636
3773
|
function resolveMiniappSdkVersion() {
|
|
3637
3774
|
if (!version.HB_SDK_VERSION.startsWith('__HB_SDK_'))
|
|
3638
3775
|
return version.HB_SDK_VERSION;
|
|
@@ -3776,18 +3913,22 @@ exports.USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = USER_MINIPROGRAM_PREVIEW_A
|
|
|
3776
3913
|
exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH;
|
|
3777
3914
|
exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
|
|
3778
3915
|
exports.areMiniappPlatformsEqual = areMiniappPlatformsEqual;
|
|
3916
|
+
exports.areMiniappWindowsEqual = areMiniappWindowsEqual;
|
|
3779
3917
|
exports.composeMiniappRuntimePermissions = composeMiniappRuntimePermissions;
|
|
3780
3918
|
exports.createMiniappArtifactFileHeader = createMiniappArtifactFileHeader;
|
|
3781
3919
|
exports.createMiniappArtifactSignatureHeader = createMiniappArtifactSignatureHeader;
|
|
3782
3920
|
exports.createMiniappPlatformCspEnv = createMiniappPlatformCspEnv;
|
|
3783
3921
|
exports.getMissingPermissionsWarning = getMissingPermissionsWarning;
|
|
3922
|
+
exports.hasMiniappDesktopPlatform = hasMiniappDesktopPlatform;
|
|
3784
3923
|
exports.isValidMiniappManifestVersion = isValidMiniappManifestVersion;
|
|
3785
3924
|
exports.normalizeRelativePath = normalizeRelativePath;
|
|
3786
3925
|
exports.parseMiniProgramRuntimePermissions = parseMiniProgramRuntimePermissions;
|
|
3787
3926
|
exports.parseMiniappManifestJson = parseMiniappManifestJson;
|
|
3788
3927
|
exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
|
|
3928
|
+
exports.readMiniappBindAppIdsFromPackageJson = readMiniappBindAppIdsFromPackageJson;
|
|
3789
3929
|
exports.readMiniappPermissionsFromPackageJson = readMiniappPermissionsFromPackageJson;
|
|
3790
3930
|
exports.readMiniappPlatformsFromPackageJson = readMiniappPlatformsFromPackageJson;
|
|
3931
|
+
exports.readMiniappWindowFromPackageJson = readMiniappWindowFromPackageJson;
|
|
3791
3932
|
exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
|
|
3792
3933
|
exports.requireSemver = requireSemver;
|
|
3793
3934
|
exports.resolveMiniappSdkVersion = resolveMiniappSdkVersion;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = require('./version-
|
|
3
|
+
var version = require('./version-0qwlEyZC.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-CKIyipP9.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('path');
|
|
11
11
|
require('os');
|
|
12
|
+
require('node:crypto');
|
|
12
13
|
require('readline');
|
|
13
14
|
require('tty');
|
|
14
15
|
require('assert');
|
package/dist/cli.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./cli-chunks/index-
|
|
3
|
+
var index = require('./cli-chunks/index-CKIyipP9.cjs');
|
|
4
4
|
require('node:module');
|
|
5
5
|
require('node:fs');
|
|
6
6
|
require('node:fs/promises');
|
|
7
7
|
require('node:path');
|
|
8
8
|
require('path');
|
|
9
9
|
require('os');
|
|
10
|
+
require('node:crypto');
|
|
10
11
|
require('readline');
|
|
11
12
|
require('tty');
|
|
12
13
|
require('assert');
|