@heybox/hb-sdk 0.8.1-alpha.13 → 0.8.1-alpha.14
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 +8 -0
- package/README.md +25 -0
- package/dist/cli-chunks/{build-CBPmqCVZ.cjs → build-D-VaxzAE.cjs} +11 -7
- package/dist/cli-chunks/{context-CvuPJq1G.cjs → context-BH7BZPoY.cjs} +2 -2
- package/dist/cli-chunks/{create-CyMWFYrc.cjs → create-Bmp9E1n8.cjs} +1 -1
- package/dist/cli-chunks/{dev-BcAPHk9L.cjs → dev-BntAFyWR.cjs} +28 -10
- package/dist/cli-chunks/{doctor-CIwaVrM1.cjs → doctor-t3YMD3qv.cjs} +1 -1
- package/dist/cli-chunks/{index-B0KCGR9H.cjs → index-CjP8Qye_.cjs} +2 -2
- package/dist/cli-chunks/{index-E0qh3FUb.cjs → index-VP8boR-7.cjs} +15 -15
- package/dist/cli-chunks/{index.esm-DTEOIvDp.cjs → index.esm-B_5UnniK.cjs} +7 -7
- package/dist/cli-chunks/{login-DGvHzH9j.cjs → login-p38-WSHx.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CRnpRhSb.cjs → project-vite-BfJ5TGoA.cjs} +1 -1
- package/dist/cli-chunks/{remote-C1_Hs11w.cjs → remote-CBH04z6v.cjs} +11 -6
- package/dist/cli-chunks/{runtime-permission-env-Bn1ONUDU.cjs → runtime-permission-env-CVYOOxPB.cjs} +91 -1
- package/dist/cli-chunks/{session-BvZgS7VI.cjs → session-BEpV8CZQ.cjs} +1 -1
- package/dist/cli-chunks/{skill-BVT6fBpQ.cjs → skill-DuVDTrA2.cjs} +2 -2
- package/dist/cli-chunks/{version-CJTEIaOQ.cjs → version-Df-F-uhW.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-DOzYp6JS.js → browser-dev-host-D_nC-Zex.js} +21 -21
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-DZ_umnQp.js → desktop-app-launch-C1GHFN_L.js} +3 -3
- package/dist/devtools/browser-dev-host/assets/{index-DoPg_zh_.js → index-mfGqyKpq.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/vite.cjs.js +141 -17
- package/dist/vite.esm.js +141 -18
- package/package.json +4 -4
- package/skill/SKILL.md +2 -0
- package/skill/references/api-protocol.md +2 -2
- package/skill/references/api-root.md +1 -1
- package/skill/references/safety-boundaries.md +2 -0
- package/skill/skill.json +5 -5
- package/types/miniapp-manifest/node.d.ts +8 -1
- package/types/miniapp-manifest/schema.d.ts +37 -0
- package/types/vite/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
本文件随 `@heybox/hb-sdk` npm 包公开分发,只记录外部小程序开发者可观察到的变化。内部集成、实现策略和审查证据不在此维护。
|
|
4
4
|
|
|
5
|
+
## 0.8.1-alpha.14
|
|
6
|
+
|
|
7
|
+
- 新增 `package.json#heybox.window` 开发者声明:`defaultWidth` / `defaultHeight` / `minWidth` / `minHeight` / `resizable`,构建时写入 `dist/manifest.json`,所有平台都会写入,由各宿主自行消费。
|
|
8
|
+
- 声明严格校验:空对象、未知字段、`width` / `height` 写法、非正整数、超过 `16384`、`min` 未与对应默认值配对或 `min > default` 全部构建期失败;`x` / `y` 显式报错,**位置不开放**。
|
|
9
|
+
- `resizable` 只约束用户手动拖拽;用户拖拽位置不受该字段限制,窗口位置始终不对开发者开放。
|
|
10
|
+
- `hb-sdk build` 与 `hb-sdk remote deploy` 校验 `dist/manifest.json.window` 与 `package.json#heybox.window` 一致,不一致时要求重新构建。
|
|
11
|
+
- Host/Runtime 集成维护者:页面通道合同升级到 `1.6.0`,新增 `window.getGeometry` 请求与 `window.geometryChanged` 上报,只有用户拖拽来源才允许写入本地记忆。detail 页面与工坊插件须成对发布和回滚。
|
|
12
|
+
|
|
5
13
|
## 0.8.1-alpha.13
|
|
6
14
|
|
|
7
15
|
- 审核前预览现在可以准备和启动当前候选版本声明的 Companion;旧版 PC Host 会返回 `COMPANION_PREVIEW_UNSUPPORTED`,需升级客户端后重试。
|
package/README.md
CHANGED
|
@@ -138,6 +138,29 @@ console.log(info.sdk.version);
|
|
|
138
138
|
|
|
139
139
|
环境信息无需权限,只用于界面适配、兼容降级、埋点和诊断,不能作为鉴权、权限控制或风控依据。完整字段和 Browser Mock 行为见[环境信息](https://docs.xiaoheihe.cn/hb_sdk/guide/environment)。
|
|
140
140
|
|
|
141
|
+
## 窗口尺寸
|
|
142
|
+
|
|
143
|
+
新 PC 工坊小程序支持在 `package.json#heybox.window` 声明开窗默认尺寸与可缩放性:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"heybox": {
|
|
148
|
+
"platforms": ["android", "ios", "ohos", "windows", "macos"],
|
|
149
|
+
"window": {
|
|
150
|
+
"defaultWidth": 480,
|
|
151
|
+
"defaultHeight": 900,
|
|
152
|
+
"minWidth": 360,
|
|
153
|
+
"minHeight": 600,
|
|
154
|
+
"resizable": true
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`window` 整体可选,字段为 `defaultWidth` / `defaultHeight` / `minWidth` / `minHeight` / `resizable`;`{}`、未知字段、`width` / `height` 写法、非正整数、超过 `16384`、`min` 未与对应默认值配对或 `min > default` 都会在构建期明确失败。`minWidth` / `minHeight` 必须与 `defaultWidth` / `defaultHeight` 同时声明。
|
|
161
|
+
|
|
162
|
+
`resizable` 只约束**用户手动拖拽**;**位置不开放**:开发者不能声明或设置窗口位置,位置由用户拖拽产生并由宿主按小程序身份本地记忆。完整语义见[窗口尺寸与可缩放性](https://docs.xiaoheihe.cn/hb_sdk/guide/window-size)。
|
|
163
|
+
|
|
141
164
|
## 文件与下载
|
|
142
165
|
|
|
143
166
|
`files` 提供当前小程序私有 sandbox 和由用户选择授予的外部 File/Directory;
|
|
@@ -282,6 +305,8 @@ SDK 还提供 `getHandshakeState()` / `onHandshakeStateChange()` 管理持久握
|
|
|
282
305
|
- Companion stdio 是原始 `Uint8Array` 且输出为 at-least-once 投递;业务自行定义 framing、去重、重放与恢复。
|
|
283
306
|
- Browser Dev Host 的 Companion Fake 只用于状态和 UI 开发,不能作为桌面程序可执行、签名、权限或进程监管的真机证据。
|
|
284
307
|
- 本地真 PC Companion 需要 `package.json#heybox.companions`、本地产物、已绑定项目和 COA `companion` 批准;未配置本地产物时使用 Browser Fake。配置或产物更新后校验并切换不可变快照;已有进程保留原产物,新产物须重新准备与启动。
|
|
308
|
+
- `package.json#heybox.window` 只声明开窗初值与可缩放性;`resizable` 只约束用户拖拽。
|
|
309
|
+
- 窗口位置不开放:开发者不能声明、也不能设置位置;位置由用户拖拽并由宿主按小程序身份本地记忆。
|
|
285
310
|
|
|
286
311
|
私有 Page Channel 适配没有修改 `@heybox/hb-sdk` 公开 API 或 iframe wire;本次 files/download
|
|
287
312
|
Runtime 能力随 `0.8.0-alpha.11` release family 发布,部署 detail 前必须保证
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var fs$1 = require('node:fs');
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
6
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CVYOOxPB.cjs');
|
|
7
7
|
require('node:crypto');
|
|
8
8
|
require('node:zlib');
|
|
9
9
|
var runtimeGate = require('./runtime-gate-BWb8QIcX.cjs');
|
|
10
|
-
var index = require('./index-
|
|
11
|
-
var projectVite = require('./project-vite-
|
|
12
|
-
require('./version-
|
|
10
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
11
|
+
var projectVite = require('./project-vite-BfJ5TGoA.cjs');
|
|
12
|
+
require('./version-Df-F-uhW.cjs');
|
|
13
13
|
require('node:async_hooks');
|
|
14
14
|
require('node:module');
|
|
15
15
|
require('path');
|
|
@@ -31,6 +31,7 @@ async function runBuildCommand(_options = {}, runtime = {}) {
|
|
|
31
31
|
const mode = env.HB_SDK_ENV?.trim() || undefined;
|
|
32
32
|
const skipPlatformCsp = runtimePermissionEnv.shouldSkipMiniappPlatformCspFromEnv(env);
|
|
33
33
|
const declaredPlatforms = runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
|
|
34
|
+
const declaredWindow = runtimePermissionEnv.readMiniappWindowFromPackageJson(projectRoot);
|
|
34
35
|
runtimePermissionEnv.readMiniappPermissionsFromPackageJson(projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
|
|
35
36
|
await fs.rm(distDir, { force: true, recursive: true });
|
|
36
37
|
try {
|
|
@@ -49,7 +50,7 @@ async function runBuildCommand(_options = {}, runtime = {}) {
|
|
|
49
50
|
write: true,
|
|
50
51
|
},
|
|
51
52
|
}), { successText: 'Vite 构建完成' });
|
|
52
|
-
const result = await validateBuildOutput(projectRoot, logger, declaredPlatforms);
|
|
53
|
+
const result = await validateBuildOutput(projectRoot, logger, declaredPlatforms, declaredWindow);
|
|
53
54
|
logger.success(`构建完成: dist/ | manifest version ${result.version} | sdkVersion ${result.sdkVersion} | 待上传文件 ${result.fileCount} 个 | ${formatSize(result.totalBytes)}`);
|
|
54
55
|
return result;
|
|
55
56
|
}, env);
|
|
@@ -78,7 +79,7 @@ function createFixedBuildOutputPlugin(projectRoot) {
|
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
|
-
async function validateBuildOutput(projectRoot, logger, declaredPlatforms) {
|
|
82
|
+
async function validateBuildOutput(projectRoot, logger, declaredPlatforms, declaredWindow) {
|
|
82
83
|
const distDir = path.join(projectRoot, 'dist');
|
|
83
84
|
const entryHtmlPath = path.join(distDir, 'index.html');
|
|
84
85
|
const manifestPath = path.join(distDir, 'manifest.json');
|
|
@@ -96,10 +97,13 @@ async function validateBuildOutput(projectRoot, logger, declaredPlatforms) {
|
|
|
96
97
|
if (hadBom) {
|
|
97
98
|
logger.warn('dist/manifest.json 包含 BOM,已自动剥离');
|
|
98
99
|
}
|
|
99
|
-
const { platforms, sdkVersion, version, permissions } = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
|
|
100
|
+
const { platforms, sdkVersion, version, permissions, window } = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
|
|
100
101
|
if (!runtimePermissionEnv.areMiniappPlatformsEqual(platforms, declaredPlatforms)) {
|
|
101
102
|
throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build');
|
|
102
103
|
}
|
|
104
|
+
if (!runtimePermissionEnv.areMiniappWindowsEqual(window, declaredWindow)) {
|
|
105
|
+
throw new Error('dist/manifest.json.window 与 package.json#heybox.window 不一致,请重新 build');
|
|
106
|
+
}
|
|
103
107
|
const allFiles = await walkDistFiles(distDir);
|
|
104
108
|
const uploadFiles = allFiles.filter((file) => runtimePermissionEnv.shouldUploadDistFile(file.relativePath));
|
|
105
109
|
const sizeError = runtimePermissionEnv.validateMiniappUploadSizeBudgets(uploadFiles);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
4
|
-
var session = require('./session-
|
|
3
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CVYOOxPB.cjs');
|
|
4
|
+
var session = require('./session-BEpV8CZQ.cjs');
|
|
5
5
|
var fs$1 = require('node:fs');
|
|
6
6
|
var fs = require('node:fs/promises');
|
|
7
7
|
var path = require('node:path');
|
|
@@ -5,7 +5,7 @@ var fs = require('node:fs/promises');
|
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$1 = require('path');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
9
9
|
require('node:module');
|
|
10
10
|
require('os');
|
|
11
11
|
require('readline');
|
|
@@ -8,17 +8,17 @@ var net = require('node:net');
|
|
|
8
8
|
var promises = require('node:dns/promises');
|
|
9
9
|
var node_http = require('node:http');
|
|
10
10
|
var node_module = require('node:module');
|
|
11
|
-
var context = require('./context-
|
|
12
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
11
|
+
var context = require('./context-BH7BZPoY.cjs');
|
|
12
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CVYOOxPB.cjs');
|
|
13
13
|
var undici = require('undici');
|
|
14
14
|
var fs$1 = require('node:fs/promises');
|
|
15
|
-
var index = require('./index-
|
|
15
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
16
16
|
var require$$0$1 = require('crypto');
|
|
17
17
|
var require$$0 = require('buffer');
|
|
18
|
-
var session = require('./session-
|
|
18
|
+
var session = require('./session-BEpV8CZQ.cjs');
|
|
19
19
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
20
|
-
var projectVite = require('./project-vite-
|
|
21
|
-
var version = require('./version-
|
|
20
|
+
var projectVite = require('./project-vite-BfJ5TGoA.cjs');
|
|
21
|
+
var version = require('./version-Df-F-uhW.cjs');
|
|
22
22
|
require('node:zlib');
|
|
23
23
|
|
|
24
24
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -1950,8 +1950,8 @@ const DEFAULT_CHANNEL_TRANSPORT = {
|
|
|
1950
1950
|
};
|
|
1951
1951
|
const IPV4_LOOPBACK_ADDRESSES = new net.BlockList();
|
|
1952
1952
|
IPV4_LOOPBACK_ADDRESSES.addSubnet('127.0.0.0', 8, 'ipv4');
|
|
1953
|
-
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1954
|
-
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1953
|
+
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-BntAFyWR.cjs', document.baseURI).href)))('ws');
|
|
1954
|
+
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-BntAFyWR.cjs', document.baseURI).href)))('parse5');
|
|
1955
1955
|
const BROWSER_DEV_HOST_ROOT_CANDIDATES = [
|
|
1956
1956
|
path.resolve(__dirname, 'devtools/browser-dev-host'),
|
|
1957
1957
|
path.resolve(__dirname, '../devtools/browser-dev-host'),
|
|
@@ -1985,6 +1985,7 @@ async function startBrowserDevHostServer(options) {
|
|
|
1985
1985
|
miniProgramSupportsDesktop: options.miniProgramSupportsDesktop,
|
|
1986
1986
|
mobileLaunchRedirect: initialMobileLaunchRedirect,
|
|
1987
1987
|
nativeAppLaunchUnavailableReason: options.nativeAppLaunchUnavailableReason,
|
|
1988
|
+
miniProgramManifestAccessToken: options.miniProgramManifestAccessToken,
|
|
1988
1989
|
runtimePermissions: options.runtimePermissions,
|
|
1989
1990
|
devReadiness: options.devReadiness,
|
|
1990
1991
|
};
|
|
@@ -11048,7 +11049,7 @@ function assertNodeRuntimeCapabilities(ctx, settings) {
|
|
|
11048
11049
|
function createNodeRealtimeDriverRegistry() {
|
|
11049
11050
|
const registry = createRuntimeRealtimeDriverRegistry();
|
|
11050
11051
|
registry.registerLazy('node-websocket', async () => {
|
|
11051
|
-
const mod = await Promise.resolve().then(function () { return require('./index.esm-
|
|
11052
|
+
const mod = await Promise.resolve().then(function () { return require('./index.esm-B_5UnniK.cjs'); });
|
|
11052
11053
|
return mod.createNodeWebSocketRuntimeDriver();
|
|
11053
11054
|
});
|
|
11054
11055
|
return registry;
|
|
@@ -15146,6 +15147,8 @@ const VITE_LOG_LEVEL = 'warn';
|
|
|
15146
15147
|
const COMPANION_DEV_MANIFEST_PATH = '/__hb_sdk__/companion/manifest.json';
|
|
15147
15148
|
const COMPANION_DEV_MANIFEST_MAX_BYTES = 1024 * 1024;
|
|
15148
15149
|
const COMPANION_ARTIFACT_ACCESS_TOKEN_ENV = 'HB_SDK_COMPANION_ARTIFACT_ACCESS_TOKEN';
|
|
15150
|
+
// 本地 PC 调试 manifest 的专用令牌:开窗时扩展还没拿到 LocalDevelopmentBinding,只能靠启动 URI 带来。
|
|
15151
|
+
const MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV = 'HB_SDK_MINI_PROGRAM_MANIFEST_ACCESS_TOKEN';
|
|
15149
15152
|
const COMPANION_ARTIFACT_ACCESS_TOKEN_HEADER = 'x-hb-sdk-companion-dev-token';
|
|
15150
15153
|
async function runDevCommand(options, runtime = {}) {
|
|
15151
15154
|
const logger = runtime.logger ?? index.createCliLogger();
|
|
@@ -15169,6 +15172,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15169
15172
|
};
|
|
15170
15173
|
const projectRoot = projectVite.findProjectRoot(runtime.cwd ?? process.cwd());
|
|
15171
15174
|
const companionArtifactAccessToken = (runtime.randomBytes ?? node_crypto.randomBytes)(32).toString('base64url');
|
|
15175
|
+
const miniProgramManifestAccessToken = (runtime.randomBytes ?? node_crypto.randomBytes)(32).toString('base64url');
|
|
15172
15176
|
const devSessionId = node_crypto.randomBytes(16).toString('hex');
|
|
15173
15177
|
const miniProgramPlatforms = runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
|
|
15174
15178
|
const { context: devLaunchContext, miniProgram } = await loadDevLaunchContext({
|
|
@@ -15230,7 +15234,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15230
15234
|
return true;
|
|
15231
15235
|
});
|
|
15232
15236
|
const vite = await runDevStartupTask(logger, '正在加载项目 Vite', () => projectVite.loadProjectVite(projectRoot), '已加载项目 Vite');
|
|
15233
|
-
const appServer = await runDevStartupTask(logger, '正在创建 Vite 开发服务器', () => runtimePermissionEnv.withMiniappPlatformCspEnv(context.shouldSkipMiniappPlatformCsp(devLaunchContext.runtimePermissions), () => withCompanionArtifactAccessTokenEnv(companionArtifactAccessToken, () => withManagedDevOutputEnv(() => vite.createServer(createViteServerOptions(projectRoot, resolvedOptions, launchPlugin)), runtime.env), runtime.env), runtime.env), '已创建 Vite 开发服务器');
|
|
15237
|
+
const appServer = await runDevStartupTask(logger, '正在创建 Vite 开发服务器', () => runtimePermissionEnv.withMiniappPlatformCspEnv(context.shouldSkipMiniappPlatformCsp(devLaunchContext.runtimePermissions), () => withCompanionArtifactAccessTokenEnv(companionArtifactAccessToken, () => withMiniProgramManifestAccessTokenEnv(miniProgramManifestAccessToken, () => withManagedDevOutputEnv(() => vite.createServer(createViteServerOptions(projectRoot, resolvedOptions, launchPlugin)), runtime.env), runtime.env), runtime.env), runtime.env), '已创建 Vite 开发服务器');
|
|
15234
15238
|
await runDevStartupTask(logger, '正在启动 Vite 开发服务器', () => appServer.listen(appPort), 'Vite 开发服务器已启动');
|
|
15235
15239
|
const appUrl = await runDevStartupTask(logger, '正在探测小程序入口', () => resolveViteAppUrl(appServer, resolvedOptions, fetchImpl), '已确定小程序入口');
|
|
15236
15240
|
const buildLanAddresses = () => createLanAddressCandidates({
|
|
@@ -15254,6 +15258,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15254
15258
|
getPort: getPortImpl,
|
|
15255
15259
|
defaultLanAddressId: lanAddresses[0]?.id,
|
|
15256
15260
|
lanAddresses,
|
|
15261
|
+
miniProgramManifestAccessToken,
|
|
15257
15262
|
lookupHostname: runtime.lookupHostname,
|
|
15258
15263
|
loginService: runtime.loginService,
|
|
15259
15264
|
miniProgram,
|
|
@@ -15603,6 +15608,19 @@ async function withCompanionArtifactAccessTokenEnv(token, action, env = process.
|
|
|
15603
15608
|
env[COMPANION_ARTIFACT_ACCESS_TOKEN_ENV] = previous;
|
|
15604
15609
|
}
|
|
15605
15610
|
}
|
|
15611
|
+
async function withMiniProgramManifestAccessTokenEnv(token, action, env = process.env) {
|
|
15612
|
+
const previous = env[MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV];
|
|
15613
|
+
env[MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV] = token;
|
|
15614
|
+
try {
|
|
15615
|
+
return await action();
|
|
15616
|
+
}
|
|
15617
|
+
finally {
|
|
15618
|
+
if (previous === undefined)
|
|
15619
|
+
delete env[MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV];
|
|
15620
|
+
else
|
|
15621
|
+
env[MINI_PROGRAM_MANIFEST_ACCESS_TOKEN_ENV] = previous;
|
|
15622
|
+
}
|
|
15623
|
+
}
|
|
15606
15624
|
function installShutdownHandlers(closers, processLike) {
|
|
15607
15625
|
const shutdown = async () => {
|
|
15608
15626
|
await closeAll(closers);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$2 = require('./index-
|
|
3
|
+
var index$2 = require('./index-VP8boR-7.cjs');
|
|
4
4
|
var require$$0$3 = require('fs');
|
|
5
5
|
var require$$0$2 = require('crypto');
|
|
6
6
|
var require$$1$2 = require('path');
|
|
7
7
|
var require$$0$5 = require('assert');
|
|
8
8
|
var require$$0$4 = require('events');
|
|
9
9
|
var require$$1$1 = require('util');
|
|
10
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
10
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CVYOOxPB.cjs');
|
|
11
11
|
var require$$0$7 = require('net');
|
|
12
12
|
var require$$0$6 = require('url');
|
|
13
13
|
var require$$2$1 = require('http');
|
|
@@ -234,19 +234,19 @@ function requireArgument () {
|
|
|
234
234
|
|
|
235
235
|
var command = {};
|
|
236
236
|
|
|
237
|
-
const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
237
|
+
const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-VP8boR-7.cjs', document.baseURI).href)));
|
|
238
238
|
function __require$4() { return require$5("node:events"); }
|
|
239
239
|
|
|
240
|
-
const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
240
|
+
const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-VP8boR-7.cjs', document.baseURI).href)));
|
|
241
241
|
function __require$3() { return require$4("node:child_process"); }
|
|
242
242
|
|
|
243
|
-
const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
243
|
+
const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-VP8boR-7.cjs', document.baseURI).href)));
|
|
244
244
|
function __require$2() { return require$3("node:path"); }
|
|
245
245
|
|
|
246
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
246
|
+
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-VP8boR-7.cjs', document.baseURI).href)));
|
|
247
247
|
function __require$1() { return require$2("node:fs"); }
|
|
248
248
|
|
|
249
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
249
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-VP8boR-7.cjs', document.baseURI).href)));
|
|
250
250
|
function __require() { return require$1("node:process"); }
|
|
251
251
|
|
|
252
252
|
var help = {};
|
|
@@ -13424,7 +13424,7 @@ function getPathname(pathWithQuery) {
|
|
|
13424
13424
|
}
|
|
13425
13425
|
|
|
13426
13426
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
13427
|
-
const BUILT_CLI_VERSION = '0.8.1-alpha.
|
|
13427
|
+
const BUILT_CLI_VERSION = '0.8.1-alpha.14';
|
|
13428
13428
|
const PACKAGE_JSON_CANDIDATES = [
|
|
13429
13429
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
13430
13430
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -13773,39 +13773,39 @@ function createCommandLoggerResolver(options) {
|
|
|
13773
13773
|
};
|
|
13774
13774
|
}
|
|
13775
13775
|
const defaultClearLoginStatus = async (...args) => {
|
|
13776
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13776
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-p38-WSHx.cjs'); });
|
|
13777
13777
|
return clearLoginStatus(...args);
|
|
13778
13778
|
};
|
|
13779
13779
|
const defaultLoginToHeybox = async (...args) => {
|
|
13780
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
13780
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-p38-WSHx.cjs'); });
|
|
13781
13781
|
return loginToHeybox(...args);
|
|
13782
13782
|
};
|
|
13783
13783
|
const defaultPrintLoginStatus = async (...args) => {
|
|
13784
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13784
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-p38-WSHx.cjs'); });
|
|
13785
13785
|
return printLoginStatus(...args);
|
|
13786
13786
|
};
|
|
13787
13787
|
const defaultRunBuildCommand = async (...args) => {
|
|
13788
|
-
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-
|
|
13788
|
+
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-D-VaxzAE.cjs'); });
|
|
13789
13789
|
return runBuildCommand(...args);
|
|
13790
13790
|
};
|
|
13791
13791
|
const defaultRunCreateCommand = async (...args) => {
|
|
13792
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
13792
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-Bmp9E1n8.cjs'); });
|
|
13793
13793
|
return runCreateCommand(...args);
|
|
13794
13794
|
};
|
|
13795
13795
|
const defaultRunDevCommand = async (...args) => {
|
|
13796
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
13796
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-BntAFyWR.cjs'); }).then(function (n) { return n.dev; });
|
|
13797
13797
|
return runDevCommand(...args);
|
|
13798
13798
|
};
|
|
13799
13799
|
const defaultRunDoctorCommand = async (...args) => {
|
|
13800
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
13800
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-t3YMD3qv.cjs'); });
|
|
13801
13801
|
return runDoctorCommand(...args);
|
|
13802
13802
|
};
|
|
13803
13803
|
const defaultRunSkillInstallCommand = async (...args) => {
|
|
13804
|
-
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-
|
|
13804
|
+
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-DuVDTrA2.cjs'); });
|
|
13805
13805
|
return runSkillInstallCommand(...args);
|
|
13806
13806
|
};
|
|
13807
13807
|
const defaultRunRemoteCommand = async (...args) => {
|
|
13808
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
13808
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-CBH04z6v.cjs'); });
|
|
13809
13809
|
return runRemoteCommand(...args);
|
|
13810
13810
|
};
|
|
13811
13811
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -11,8 +11,8 @@ var require$$0$4 = require('url');
|
|
|
11
11
|
var require$$0 = require('zlib');
|
|
12
12
|
var require$$0$1 = require('buffer');
|
|
13
13
|
var require$$1 = require('util');
|
|
14
|
-
var index = require('./index-
|
|
15
|
-
var dev = require('./dev-
|
|
14
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
15
|
+
var dev = require('./dev-BntAFyWR.cjs');
|
|
16
16
|
require('node:module');
|
|
17
17
|
require('node:fs');
|
|
18
18
|
require('node:fs/promises');
|
|
@@ -27,11 +27,11 @@ require('node:os');
|
|
|
27
27
|
require('node:net');
|
|
28
28
|
require('node:dns/promises');
|
|
29
29
|
require('node:http');
|
|
30
|
-
require('./context-
|
|
31
|
-
require('./runtime-permission-env-
|
|
32
|
-
require('./version-
|
|
30
|
+
require('./context-BH7BZPoY.cjs');
|
|
31
|
+
require('./runtime-permission-env-CVYOOxPB.cjs');
|
|
32
|
+
require('./version-Df-F-uhW.cjs');
|
|
33
33
|
require('node:async_hooks');
|
|
34
|
-
require('./session-
|
|
34
|
+
require('./session-BEpV8CZQ.cjs');
|
|
35
35
|
require('fs');
|
|
36
36
|
require('constants');
|
|
37
37
|
require('undici');
|
|
@@ -41,7 +41,7 @@ require('node:buffer');
|
|
|
41
41
|
require('node:url');
|
|
42
42
|
require('node:util');
|
|
43
43
|
require('node:child_process');
|
|
44
|
-
require('./project-vite-
|
|
44
|
+
require('./project-vite-BfJ5TGoA.cjs');
|
|
45
45
|
require('node:zlib');
|
|
46
46
|
|
|
47
47
|
var bufferUtil = {exports: {}};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var promises = require('node:readline/promises');
|
|
4
4
|
var node_crypto = require('node:crypto');
|
|
5
5
|
var node_http = require('node:http');
|
|
6
|
-
var session = require('./session-
|
|
6
|
+
var session = require('./session-BEpV8CZQ.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
9
9
|
require('node:path');
|
|
10
10
|
require('fs');
|
|
11
11
|
require('constants');
|
|
@@ -5,7 +5,7 @@ var fs$1 = require('node:fs/promises');
|
|
|
5
5
|
var node_module = require('node:module');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var node_url = require('node:url');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-VP8boR-7.cjs');
|
|
9
9
|
|
|
10
10
|
function findProjectRoot(startDir) {
|
|
11
11
|
let current = path.resolve(startDir);
|
|
@@ -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-VP8boR-7.cjs');
|
|
5
|
+
var session = require('./session-BEpV8CZQ.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-CVYOOxPB.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-BH7BZPoY.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-Df-F-uhW.cjs');
|
|
28
28
|
require('node:async_hooks');
|
|
29
29
|
|
|
30
30
|
async function getCDNUploadInfo(options, runtime = {}) {
|
|
@@ -274,7 +274,7 @@ function createDefaultCosClient(uploadToken, COS) {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
async function loadCosConstructor() {
|
|
277
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
277
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-CjP8Qye_.cjs'); }).then(function (n) { return n.index; });
|
|
278
278
|
return cosModule.default;
|
|
279
279
|
}
|
|
280
280
|
function formatSize(bytes) {
|
|
@@ -516,6 +516,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
516
516
|
}
|
|
517
517
|
const fromVersion = options.fromVersion?.trim();
|
|
518
518
|
const declaredPlatforms = fromVersion ? undefined : runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
|
|
519
|
+
const declaredWindow = fromVersion ? undefined : runtimePermissionEnv.readMiniappWindowFromPackageJson(projectRoot);
|
|
519
520
|
const releaseNote = await resolveDeployReleaseNote(options, runtime);
|
|
520
521
|
const session$1 = await logger.task('正在校验 Heybox 登录态', () => (runtime.requireAuthSession ?? session.requireHeyboxAuthSession)({ loginBaseUrl }), { successText: 'Heybox 登录态有效' });
|
|
521
522
|
logger.debug(`Heybox API: ${apiBaseUrl}`);
|
|
@@ -593,6 +594,9 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
593
594
|
if (!declaredPlatforms || !runtimePermissionEnv.areMiniappPlatformsEqual(parsedManifest.platforms, declaredPlatforms)) {
|
|
594
595
|
throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build 后再 deploy');
|
|
595
596
|
}
|
|
597
|
+
if (!runtimePermissionEnv.areMiniappWindowsEqual(parsedManifest.window, declaredWindow)) {
|
|
598
|
+
throw new Error('dist/manifest.json.window 与 package.json#heybox.window 不一致,请重新 build 后再 deploy');
|
|
599
|
+
}
|
|
596
600
|
if (version !== precheckVersion) {
|
|
597
601
|
throw new Error(`dist/manifest.json.version (${version}) 与预检版本 (${precheckVersion}) 不一致,请重新 build 后再 deploy`);
|
|
598
602
|
}
|
|
@@ -757,6 +761,7 @@ async function readDeployManifest(projectRoot, logger) {
|
|
|
757
761
|
sdkVersion: validated.sdkVersion,
|
|
758
762
|
version: validated.version,
|
|
759
763
|
platforms: validated.platforms,
|
|
764
|
+
...(validated.window === undefined ? {} : { window: validated.window }),
|
|
760
765
|
};
|
|
761
766
|
}
|
|
762
767
|
function validateVersionForDeploy(version, sourceLabel) {
|
package/dist/cli-chunks/{runtime-permission-env-Bn1ONUDU.cjs → runtime-permission-env-CVYOOxPB.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-Df-F-uhW.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
var node_async_hooks = require('node:async_hooks');
|
|
8
8
|
|
|
@@ -3108,6 +3108,10 @@ function isRecord$3(value) {
|
|
|
3108
3108
|
}
|
|
3109
3109
|
|
|
3110
3110
|
const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
|
|
3111
|
+
/** 窗口尺寸字段的脏值兜底上限;真正的上限是宿主侧显示器 workArea。 */
|
|
3112
|
+
const MINIAPP_WINDOW_SIZE_MAX = 16_384;
|
|
3113
|
+
const MINIAPP_WINDOW_NUMBER_FIELDS = ['defaultWidth', 'defaultHeight', 'minWidth', 'minHeight'];
|
|
3114
|
+
const MINIAPP_WINDOW_ALLOWED_FIELDS = [...MINIAPP_WINDOW_NUMBER_FIELDS, 'resizable'];
|
|
3111
3115
|
/**
|
|
3112
3116
|
* 桌面平台子集:从唯一平台词表 `MINIAPP_PLATFORM_VALUES` 派生,`satisfies` 阻止它漂移出词表。
|
|
3113
3117
|
* 小程序声明其中任一平台,即视为该项目承诺适配 PC / 桌面端;调试台据此取舍桌面调试入口。
|
|
@@ -3158,12 +3162,14 @@ function validateMiniappManifestForDeploy(manifest) {
|
|
|
3158
3162
|
sourceLabel: 'manifest.permissions',
|
|
3159
3163
|
});
|
|
3160
3164
|
const companions = validateGeneratedCompanions(manifest.companions);
|
|
3165
|
+
const window = validateMiniappWindow(manifest.window, 'manifest.window');
|
|
3161
3166
|
return {
|
|
3162
3167
|
version,
|
|
3163
3168
|
sdkVersion,
|
|
3164
3169
|
platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
|
|
3165
3170
|
...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
|
|
3166
3171
|
...(companions === undefined ? {} : { companions }),
|
|
3172
|
+
...(window === undefined ? {} : { window }),
|
|
3167
3173
|
};
|
|
3168
3174
|
}
|
|
3169
3175
|
function validateGeneratedCompanions(value) {
|
|
@@ -3240,6 +3246,77 @@ function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
|
|
|
3240
3246
|
function areMiniappPlatformsEqual(left, right) {
|
|
3241
3247
|
return left.length === right.length && left.every((platform, index) => platform === right[index]);
|
|
3242
3248
|
}
|
|
3249
|
+
/**
|
|
3250
|
+
* 校验并归一化 `package.json#heybox.window` / `manifest.window` 声明。
|
|
3251
|
+
*
|
|
3252
|
+
* @remarks
|
|
3253
|
+
* 与 `heybox.permissions` 同样的严格风格:未知字段报错,不做静默忽略。
|
|
3254
|
+
* `width` / `height` 显式给出改名提示;`x` / `y` 按未知字段显式报错(`INV-NO-DEV-POSITION`)。
|
|
3255
|
+
* 未声明时返回 `undefined`,由调用方决定不写入产物。
|
|
3256
|
+
* @param value - 待校验的原始声明(不可信输入)。
|
|
3257
|
+
* @param sourceLabel - 报错前缀,默认指向开发者声明路径。
|
|
3258
|
+
* @throws 当声明不是非空对象、含未知字段、数值/布尔类型不合法或 min/default 不配对时抛出。
|
|
3259
|
+
*/
|
|
3260
|
+
function validateMiniappWindow(value, sourceLabel = 'package.json#heybox.window') {
|
|
3261
|
+
if (value === undefined)
|
|
3262
|
+
return undefined;
|
|
3263
|
+
if (!isRecord$2(value) || Object.keys(value).length === 0) {
|
|
3264
|
+
throw new Error(`${sourceLabel} 至少需要声明 defaultWidth/defaultHeight/minWidth/minHeight/resizable 之一`);
|
|
3265
|
+
}
|
|
3266
|
+
if (Object.prototype.hasOwnProperty.call(value, 'width') || Object.prototype.hasOwnProperty.call(value, 'height')) {
|
|
3267
|
+
throw new Error(`${sourceLabel} 请使用 defaultWidth/defaultHeight,而不是 width/height`);
|
|
3268
|
+
}
|
|
3269
|
+
for (const key of Object.keys(value)) {
|
|
3270
|
+
if (!MINIAPP_WINDOW_ALLOWED_FIELDS.includes(key)) {
|
|
3271
|
+
throw new Error(`${sourceLabel} 包含未知字段:${key}`);
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
const window = {};
|
|
3275
|
+
for (const field of MINIAPP_WINDOW_NUMBER_FIELDS) {
|
|
3276
|
+
if (!Object.prototype.hasOwnProperty.call(value, field))
|
|
3277
|
+
continue;
|
|
3278
|
+
const size = value[field];
|
|
3279
|
+
if (typeof size !== 'number' || !Number.isSafeInteger(size) || size <= 0) {
|
|
3280
|
+
throw new Error(`${sourceLabel}.${field} 必须是正整数`);
|
|
3281
|
+
}
|
|
3282
|
+
if (size > MINIAPP_WINDOW_SIZE_MAX) {
|
|
3283
|
+
throw new Error(`${sourceLabel}.${field} 不能大于 ${MINIAPP_WINDOW_SIZE_MAX}`);
|
|
3284
|
+
}
|
|
3285
|
+
window[field] = size;
|
|
3286
|
+
}
|
|
3287
|
+
if (Object.prototype.hasOwnProperty.call(value, 'resizable')) {
|
|
3288
|
+
if (typeof value.resizable !== 'boolean') {
|
|
3289
|
+
throw new Error(`${sourceLabel}.resizable 必须是 boolean`);
|
|
3290
|
+
}
|
|
3291
|
+
window.resizable = value.resizable;
|
|
3292
|
+
}
|
|
3293
|
+
for (const [minimum, fallback] of [
|
|
3294
|
+
['minWidth', 'defaultWidth'],
|
|
3295
|
+
['minHeight', 'defaultHeight'],
|
|
3296
|
+
]) {
|
|
3297
|
+
const minimumValue = window[minimum];
|
|
3298
|
+
if (minimumValue === undefined)
|
|
3299
|
+
continue;
|
|
3300
|
+
const fallbackValue = window[fallback];
|
|
3301
|
+
if (fallbackValue === undefined) {
|
|
3302
|
+
throw new Error(`${sourceLabel}.${minimum} 必须与 ${fallback} 同时声明`);
|
|
3303
|
+
}
|
|
3304
|
+
if (minimumValue > fallbackValue) {
|
|
3305
|
+
throw new Error(`${sourceLabel}.${minimum} 必须小于等于 ${fallback}`);
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
return window;
|
|
3309
|
+
}
|
|
3310
|
+
/** 比较两份窗口声明是否逐字段一致;未声明视同 `undefined`。 */
|
|
3311
|
+
function areMiniappWindowsEqual(left, right) {
|
|
3312
|
+
if (left === undefined || right === undefined)
|
|
3313
|
+
return left === right;
|
|
3314
|
+
return (left.defaultWidth === right.defaultWidth &&
|
|
3315
|
+
left.defaultHeight === right.defaultHeight &&
|
|
3316
|
+
left.minWidth === right.minWidth &&
|
|
3317
|
+
left.minHeight === right.minHeight &&
|
|
3318
|
+
left.resizable === right.resizable);
|
|
3319
|
+
}
|
|
3243
3320
|
function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
|
|
3244
3321
|
if (typeof version !== 'string' || version.trim() === '') {
|
|
3245
3322
|
throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
|
|
@@ -3637,6 +3714,17 @@ function readMiniappPlatformsFromPackageJson(root) {
|
|
|
3637
3714
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3638
3715
|
return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
|
|
3639
3716
|
}
|
|
3717
|
+
/**
|
|
3718
|
+
* 读取并校验 `package.json#heybox.window`。
|
|
3719
|
+
*
|
|
3720
|
+
* @returns 合法声明;未声明时返回 `undefined`,调用方不得向 manifest 写入空对象或 `null`。
|
|
3721
|
+
* @throws 当声明违反 {@link validateMiniappWindow} 的规则时抛出,报错前缀为 `package.json#heybox.window`。
|
|
3722
|
+
*/
|
|
3723
|
+
function readMiniappWindowFromPackageJson(root) {
|
|
3724
|
+
const { packageJson } = readMiniappPackageJson(root);
|
|
3725
|
+
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
3726
|
+
return validateMiniappWindow(heybox?.window, 'package.json#heybox.window');
|
|
3727
|
+
}
|
|
3640
3728
|
function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
|
|
3641
3729
|
const { packageJson } = readMiniappPackageJson(root);
|
|
3642
3730
|
const heybox = readMiniappHeyboxConfig(packageJson);
|
|
@@ -3789,6 +3877,7 @@ exports.USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = USER_MINIPROGRAM_PREVIEW_A
|
|
|
3789
3877
|
exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH;
|
|
3790
3878
|
exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
|
|
3791
3879
|
exports.areMiniappPlatformsEqual = areMiniappPlatformsEqual;
|
|
3880
|
+
exports.areMiniappWindowsEqual = areMiniappWindowsEqual;
|
|
3792
3881
|
exports.composeMiniappRuntimePermissions = composeMiniappRuntimePermissions;
|
|
3793
3882
|
exports.createMiniappArtifactFileHeader = createMiniappArtifactFileHeader;
|
|
3794
3883
|
exports.createMiniappArtifactSignatureHeader = createMiniappArtifactSignatureHeader;
|
|
@@ -3802,6 +3891,7 @@ exports.parseMiniappManifestJson = parseMiniappManifestJson;
|
|
|
3802
3891
|
exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
|
|
3803
3892
|
exports.readMiniappPermissionsFromPackageJson = readMiniappPermissionsFromPackageJson;
|
|
3804
3893
|
exports.readMiniappPlatformsFromPackageJson = readMiniappPlatformsFromPackageJson;
|
|
3894
|
+
exports.readMiniappWindowFromPackageJson = readMiniappWindowFromPackageJson;
|
|
3805
3895
|
exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
|
|
3806
3896
|
exports.requireSemver = requireSemver;
|
|
3807
3897
|
exports.resolveMiniappSdkVersion = resolveMiniappSdkVersion;
|