@heybox/hb-sdk 0.8.1-alpha.2 → 0.8.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +13 -3
  3. package/dist/cli-chunks/{build-FQoALfGC.cjs → build-B5Sbi8Sq.cjs} +13 -9
  4. package/dist/cli-chunks/{context-CA_Q1lyH.cjs → context-DuxaBL3Y.cjs} +2 -2
  5. package/dist/cli-chunks/{create-BjIl4hy4.cjs → create-CIfZrg3F.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-CiPQYsW_.cjs → dev-CFubP5kW.cjs} +10 -9
  7. package/dist/cli-chunks/{doctor-CS6c3n-W.cjs → doctor-IPKn3PBn.cjs} +1 -1
  8. package/dist/cli-chunks/{index-BEn7WaqA.cjs → index-DCJN-V1y.cjs} +15 -15
  9. package/dist/cli-chunks/{index-CsP_x6y6.cjs → index-KHhdZ8eZ.cjs} +2 -2
  10. package/dist/cli-chunks/{index.esm-DeEc_-uV.cjs → index.esm-8hgZlNF8.cjs} +7 -7
  11. package/dist/cli-chunks/{login-BENCVgaQ.cjs → login-CoB9jXxC.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-BO8oOfcs.cjs → project-vite-DMxdOWsU.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-IiVCXcSq.cjs → remote-D4ZcngLn.cjs} +14 -10
  14. package/dist/cli-chunks/{runtime-gate-BMSY22AL.cjs → runtime-gate-BWb8QIcX.cjs} +0 -107
  15. package/dist/cli-chunks/{runtime-permission-env-BPRwn4Yc.cjs → runtime-permission-env-XAZFauvZ.cjs} +125 -9
  16. package/dist/cli-chunks/{session-C0eIKZ6V.cjs → session-BnoHxzFq.cjs} +1 -1
  17. package/dist/cli-chunks/{skill-DpInwbiA.cjs → skill-CDEJtATn.cjs} +2 -2
  18. package/dist/cli-chunks/{version-BONZQWPR.cjs → version-BGzCIQhE.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/index.cjs.js +1 -1
  21. package/dist/index.esm.js +1 -1
  22. package/dist/templates/vanilla-vite-js/README.md.ejs +1 -1
  23. package/dist/templates/vanilla-vite-js/package.json.ejs +1 -0
  24. package/dist/templates/vanilla-vite-js/vite.config.js +1 -1
  25. package/dist/vite.cjs.js +19 -10
  26. package/dist/vite.esm.js +19 -10
  27. package/package.json +6 -6
  28. package/skill/SKILL.md +2 -2
  29. package/skill/references/api-protocol.md +2 -2
  30. package/skill/references/api-root.md +11 -12
  31. package/skill/references/cli.md +2 -2
  32. package/skill/references/examples.md +9 -1
  33. package/skill/references/safety-boundaries.md +1 -1
  34. package/skill/skill.json +5 -5
  35. package/types/miniapp-manifest/node.d.ts +2 -0
  36. package/types/miniapp-manifest/schema.d.ts +1 -0
  37. package/types/vite/index.d.ts +1 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  本文件随 `@heybox/hb-sdk` npm 包公开分发,只记录外部小程序开发者可观察到的变化。内部集成、实现策略和审查证据不在此维护。
4
4
 
5
+ ## 0.8.1-alpha.3
6
+
7
+ - 目标平台声明统一迁移到 `package.json#heybox.platforms`;`miniappManifest()` 恢复无参调用,并在构建时将该声明写入 `dist/manifest.json`。
8
+ - `hb-sdk dev`、`hb-sdk build` 和普通 `hb-sdk remote deploy` 会拒绝缺失或非法的平台声明;build/deploy 也会拒绝与项目配置不一致的 Manifest。已有项目升级时需把原 Vite 参数中的 `platforms` 移入 `package.json#heybox`。
9
+
5
10
  ## 0.8.1-alpha.2
6
11
 
7
12
  - 新增 `environment.getInfo()` 与 `environment.getInfoSync()`,用于读取运行模式、小黑盒 App 版本、canonical 小程序 ID/版本、操作系统和 SDK 版本的冻结快照。
package/README.md CHANGED
@@ -94,7 +94,17 @@ async function revokeAuthorizationFromUserAction() {
94
94
 
95
95
  `user.revokeAuthorization()` 位于无需声明白名单,不接收小程序 ID、黑盒用户 ID 或手势参数。调用必须来自可信用户操作,否则返回 `USER_GESTURE_REQUIRED`。撤销成功后,后续身份或授权读取会重新进入授权流程;SDK 不会替业务清理已经持久化的数据。
96
96
 
97
- 已有 Vite 项目还需要启用构建插件:
97
+ 已有 Vite 项目先在 `package.json#heybox.platforms` 声明实际承诺适配的平台:
98
+
99
+ ```json
100
+ {
101
+ "heybox": {
102
+ "platforms": ["android", "ios", "ohos"]
103
+ }
104
+ }
105
+ ```
106
+
107
+ 再启用构建插件:
98
108
 
99
109
  ```ts
100
110
  import { miniappManifest } from '@heybox/hb-sdk/vite';
@@ -102,7 +112,7 @@ import { defineConfig } from 'vite';
102
112
 
103
113
  export default defineConfig({
104
114
  base: './',
105
- plugins: [miniappManifest({ platforms: ['android', 'ios', 'ohos'] })],
115
+ plugins: [miniappManifest()],
106
116
  });
107
117
  ```
108
118
 
@@ -231,7 +241,7 @@ SDK 还提供 `getHandshakeState()` / `onHandshakeStateChange()` 管理持久握
231
241
  - Host 文件错误只保留稳定 code 与 canonical 安全文案;原始 message、data、native path 和 credential 不会进入小程序。
232
242
  - `FileStat.size` 是非负 safe integer;`modifiedAt` / `createdAt` 若存在,单位为 Unix epoch milliseconds。
233
243
  - 仅当当前版本声明且平台已批准 `network` 时,`hb-sdk dev` 与 `hb-sdk remote deploy` 构建才会跳过平台 CSP;其他构建继续注入平台 CSP。`useOfficialDomain` 不参与 CSP 跳过判定。
234
- - 构建必须启用 `miniappManifest({ platforms })` 并显式声明实际承诺适配的平台,推荐统一使用 `hb-sdk build`。新项目模板中的 `['android', 'ios', 'ohos']` 只是初始配置,不代表已经完成真机验收。
244
+ - 构建必须启用 `miniappManifest()`,并在 `package.json#heybox.platforms` 显式声明实际承诺适配的平台,推荐统一使用 `hb-sdk build`。新项目模板中的 `['android', 'ios', 'ohos']` 只是初始配置,不代表已经完成真机验收。
235
245
 
236
246
  私有 Page Channel 适配没有修改 `@heybox/hb-sdk` 公开 API 或 iframe wire;本次 files/download
237
247
  Runtime 能力随 `0.8.0-alpha.11` release family 发布,部署 detail 前必须保证
@@ -3,11 +3,11 @@
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-BPRwn4Yc.cjs');
7
- var runtimeGate = require('./runtime-gate-BMSY22AL.cjs');
8
- var index = require('./index-BEn7WaqA.cjs');
9
- var projectVite = require('./project-vite-BO8oOfcs.cjs');
10
- require('./version-BONZQWPR.cjs');
6
+ var runtimePermissionEnv = require('./runtime-permission-env-XAZFauvZ.cjs');
7
+ var runtimeGate = require('./runtime-gate-BWb8QIcX.cjs');
8
+ var index = require('./index-DCJN-V1y.cjs');
9
+ var projectVite = require('./project-vite-DMxdOWsU.cjs');
10
+ require('./version-BGzCIQhE.cjs');
11
11
  require('node:async_hooks');
12
12
  require('node:module');
13
13
  require('path');
@@ -28,6 +28,7 @@ async function runBuildCommand(_options = {}, runtime = {}) {
28
28
  const env = runtime.env ?? process.env;
29
29
  const mode = env.HB_SDK_ENV?.trim() || undefined;
30
30
  const skipPlatformCsp = runtimePermissionEnv.shouldSkipMiniappPlatformCspFromEnv(env);
31
+ const declaredPlatforms = runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
31
32
  runtimePermissionEnv.readMiniappPermissionsFromPackageJson(projectRoot, runtimePermissionEnv.resolveMiniappSdkVersion());
32
33
  await fs.rm(distDir, { force: true, recursive: true });
33
34
  try {
@@ -46,7 +47,7 @@ async function runBuildCommand(_options = {}, runtime = {}) {
46
47
  write: true,
47
48
  },
48
49
  }), { successText: 'Vite 构建完成' });
49
- const result = await validateBuildOutput(projectRoot, logger);
50
+ const result = await validateBuildOutput(projectRoot, logger, declaredPlatforms);
50
51
  logger.success(`构建完成: dist/ | manifest version ${result.version} | sdkVersion ${result.sdkVersion} | 待上传文件 ${result.fileCount} 个 | ${formatSize(result.totalBytes)}`);
51
52
  return result;
52
53
  }, env);
@@ -75,7 +76,7 @@ function createFixedBuildOutputPlugin(projectRoot) {
75
76
  },
76
77
  };
77
78
  }
78
- async function validateBuildOutput(projectRoot, logger) {
79
+ async function validateBuildOutput(projectRoot, logger, declaredPlatforms) {
79
80
  const distDir = path.join(projectRoot, 'dist');
80
81
  const entryHtmlPath = path.join(distDir, 'index.html');
81
82
  const manifestPath = path.join(distDir, 'manifest.json');
@@ -89,11 +90,14 @@ async function validateBuildOutput(projectRoot, logger) {
89
90
  if (!runtimeGate.hasMiniappRuntimeGate(entryHtml)) {
90
91
  throw new Error('dist/index.html 缺少平台 Runtime 启动门禁,请在 Vite 配置中显式启用 miniappManifest()');
91
92
  }
92
- const { manifest, hadBom } = runtimeGate.parseMiniappManifestJson(await fs.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
93
+ const { manifest, hadBom } = runtimePermissionEnv.parseMiniappManifestJson(await fs.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
93
94
  if (hadBom) {
94
95
  logger.warn('dist/manifest.json 包含 BOM,已自动剥离');
95
96
  }
96
- const { platforms, sdkVersion, version, permissions } = runtimeGate.validateMiniappManifestForDeploy(manifest);
97
+ const { platforms, sdkVersion, version, permissions } = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
98
+ if (!runtimePermissionEnv.areMiniappPlatformsEqual(platforms, declaredPlatforms)) {
99
+ throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build');
100
+ }
97
101
  const allFiles = await walkDistFiles(distDir);
98
102
  const uploadFiles = allFiles.filter((file) => runtimePermissionEnv.shouldUploadDistFile(file.relativePath));
99
103
  const sizeError = runtimePermissionEnv.validateUploadTotalSize(uploadFiles);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var runtimePermissionEnv = require('./runtime-permission-env-BPRwn4Yc.cjs');
4
- var session = require('./session-C0eIKZ6V.cjs');
3
+ var runtimePermissionEnv = require('./runtime-permission-env-XAZFauvZ.cjs');
4
+ var session = require('./session-BnoHxzFq.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-BEn7WaqA.cjs');
8
+ var index = require('./index-DCJN-V1y.cjs');
9
9
  require('node:module');
10
10
  require('os');
11
11
  require('readline');
@@ -8,17 +8,17 @@ var node_crypto = require('node:crypto');
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-CA_Q1lyH.cjs');
12
- var runtimePermissionEnv = require('./runtime-permission-env-BPRwn4Yc.cjs');
11
+ var context = require('./context-DuxaBL3Y.cjs');
12
+ var runtimePermissionEnv = require('./runtime-permission-env-XAZFauvZ.cjs');
13
13
  var undici = require('undici');
14
14
  var fs$1 = require('node:fs/promises');
15
- var index = require('./index-BEn7WaqA.cjs');
15
+ var index = require('./index-DCJN-V1y.cjs');
16
16
  var require$$0$1 = require('crypto');
17
17
  var require$$0 = require('buffer');
18
- var session = require('./session-C0eIKZ6V.cjs');
18
+ var session = require('./session-BnoHxzFq.cjs');
19
19
  var browser = require('./browser-RAy8e8cV.cjs');
20
- var projectVite = require('./project-vite-BO8oOfcs.cjs');
21
- var version = require('./version-BONZQWPR.cjs');
20
+ var projectVite = require('./project-vite-DMxdOWsU.cjs');
21
+ var version = require('./version-BGzCIQhE.cjs');
22
22
 
23
23
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
24
24
  class Locked extends Error {
@@ -1851,8 +1851,8 @@ const DEFAULT_CHANNEL_TRANSPORT = {
1851
1851
  };
1852
1852
  const IPV4_LOOPBACK_ADDRESSES = new net.BlockList();
1853
1853
  IPV4_LOOPBACK_ADDRESSES.addSubnet('127.0.0.0', 8, 'ipv4');
1854
- 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-CiPQYsW_.cjs', document.baseURI).href)))('ws');
1855
- 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-CiPQYsW_.cjs', document.baseURI).href)))('parse5');
1854
+ 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-CFubP5kW.cjs', document.baseURI).href)))('ws');
1855
+ 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-CFubP5kW.cjs', document.baseURI).href)))('parse5');
1856
1856
  const BROWSER_DEV_HOST_ROOT_CANDIDATES = [
1857
1857
  path.resolve(__dirname, 'devtools/browser-dev-host'),
1858
1858
  path.resolve(__dirname, '../devtools/browser-dev-host'),
@@ -10902,7 +10902,7 @@ function assertNodeRuntimeCapabilities(ctx, settings) {
10902
10902
  function createNodeRealtimeDriverRegistry() {
10903
10903
  const registry = createRuntimeRealtimeDriverRegistry();
10904
10904
  registry.registerLazy('node-websocket', async () => {
10905
- const mod = await Promise.resolve().then(function () { return require('./index.esm-DeEc_-uV.cjs'); });
10905
+ const mod = await Promise.resolve().then(function () { return require('./index.esm-8hgZlNF8.cjs'); });
10906
10906
  return mod.createNodeWebSocketRuntimeDriver();
10907
10907
  });
10908
10908
  return registry;
@@ -14991,6 +14991,7 @@ async function runDevCommand(options, runtime = {}) {
14991
14991
  port: appPort,
14992
14992
  };
14993
14993
  const projectRoot = projectVite.findProjectRoot(runtime.cwd ?? process.cwd());
14994
+ runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
14994
14995
  const { context: devLaunchContext, miniProgram } = await loadDevLaunchContext({
14995
14996
  env: runtime.env,
14996
14997
  fetchImpl,
@@ -3,7 +3,7 @@
3
3
  var fs = require('node:fs/promises');
4
4
  var os = require('node:os');
5
5
  var path = require('node:path');
6
- var index = require('./index-BEn7WaqA.cjs');
6
+ var index = require('./index-DCJN-V1y.cjs');
7
7
  require('node:module');
8
8
  require('node:fs');
9
9
  require('path');
@@ -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-BEn7WaqA.cjs', document.baseURI).href)));
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-DCJN-V1y.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-BEn7WaqA.cjs', document.baseURI).href)));
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-DCJN-V1y.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-BEn7WaqA.cjs', document.baseURI).href)));
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-DCJN-V1y.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-BEn7WaqA.cjs', document.baseURI).href)));
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-DCJN-V1y.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-BEn7WaqA.cjs', document.baseURI).href)));
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-DCJN-V1y.cjs', document.baseURI).href)));
250
250
  function __require() { return require$1("node:process"); }
251
251
 
252
252
  var help = {};
@@ -13353,7 +13353,7 @@ function getPathname(pathWithQuery) {
13353
13353
  }
13354
13354
 
13355
13355
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
13356
- const BUILT_CLI_VERSION = '0.8.1-alpha.2';
13356
+ const BUILT_CLI_VERSION = '0.8.1-alpha.3';
13357
13357
  const PACKAGE_JSON_CANDIDATES = [
13358
13358
  path.resolve(__dirname, '..', '..', 'package.json'),
13359
13359
  path.resolve(__dirname, '..', 'package.json'),
@@ -13701,39 +13701,39 @@ function createCommandLoggerResolver(options) {
13701
13701
  };
13702
13702
  }
13703
13703
  const defaultClearLoginStatus = async (...args) => {
13704
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-BENCVgaQ.cjs'); });
13704
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-CoB9jXxC.cjs'); });
13705
13705
  return clearLoginStatus(...args);
13706
13706
  };
13707
13707
  const defaultLoginToHeybox = async (...args) => {
13708
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-BENCVgaQ.cjs'); });
13708
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-CoB9jXxC.cjs'); });
13709
13709
  return loginToHeybox(...args);
13710
13710
  };
13711
13711
  const defaultPrintLoginStatus = async (...args) => {
13712
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-BENCVgaQ.cjs'); });
13712
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-CoB9jXxC.cjs'); });
13713
13713
  return printLoginStatus(...args);
13714
13714
  };
13715
13715
  const defaultRunBuildCommand = async (...args) => {
13716
- const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-FQoALfGC.cjs'); });
13716
+ const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-B5Sbi8Sq.cjs'); });
13717
13717
  return runBuildCommand(...args);
13718
13718
  };
13719
13719
  const defaultRunCreateCommand = async (...args) => {
13720
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-BjIl4hy4.cjs'); });
13720
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CIfZrg3F.cjs'); });
13721
13721
  return runCreateCommand(...args);
13722
13722
  };
13723
13723
  const defaultRunDevCommand = async (...args) => {
13724
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CiPQYsW_.cjs'); }).then(function (n) { return n.dev; });
13724
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CFubP5kW.cjs'); }).then(function (n) { return n.dev; });
13725
13725
  return runDevCommand(...args);
13726
13726
  };
13727
13727
  const defaultRunDoctorCommand = async (...args) => {
13728
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-CS6c3n-W.cjs'); });
13728
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-IPKn3PBn.cjs'); });
13729
13729
  return runDoctorCommand(...args);
13730
13730
  };
13731
13731
  const defaultRunSkillInstallCommand = async (...args) => {
13732
- const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-DpInwbiA.cjs'); });
13732
+ const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-CDEJtATn.cjs'); });
13733
13733
  return runSkillInstallCommand(...args);
13734
13734
  };
13735
13735
  const defaultRunRemoteCommand = async (...args) => {
13736
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-IiVCXcSq.cjs'); });
13736
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-D4ZcngLn.cjs'); });
13737
13737
  return runRemoteCommand(...args);
13738
13738
  };
13739
13739
  function resolveStandaloneLogger(options, verbose) {
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-BEn7WaqA.cjs');
3
+ var index$2 = require('./index-DCJN-V1y.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-BPRwn4Yc.cjs');
10
+ var runtimePermissionEnv = require('./runtime-permission-env-XAZFauvZ.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');
@@ -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-BEn7WaqA.cjs');
15
- var dev = require('./dev-CiPQYsW_.cjs');
14
+ var index = require('./index-DCJN-V1y.cjs');
15
+ var dev = require('./dev-CFubP5kW.cjs');
16
16
  require('node:module');
17
17
  require('node:fs');
18
18
  require('node:fs/promises');
@@ -27,11 +27,11 @@ require('node:net');
27
27
  require('node:crypto');
28
28
  require('node:dns/promises');
29
29
  require('node:http');
30
- require('./context-CA_Q1lyH.cjs');
31
- require('./runtime-permission-env-BPRwn4Yc.cjs');
32
- require('./version-BONZQWPR.cjs');
30
+ require('./context-DuxaBL3Y.cjs');
31
+ require('./runtime-permission-env-XAZFauvZ.cjs');
32
+ require('./version-BGzCIQhE.cjs');
33
33
  require('node:async_hooks');
34
- require('./session-C0eIKZ6V.cjs');
34
+ require('./session-BnoHxzFq.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-BO8oOfcs.cjs');
44
+ require('./project-vite-DMxdOWsU.cjs');
45
45
 
46
46
  var bufferUtil = {exports: {}};
47
47
 
@@ -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-C0eIKZ6V.cjs');
6
+ var session = require('./session-BnoHxzFq.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-BEn7WaqA.cjs');
8
+ var index = require('./index-DCJN-V1y.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-BEn7WaqA.cjs');
8
+ var index = require('./index-DCJN-V1y.cjs');
9
9
 
10
10
  function findProjectRoot(startDir) {
11
11
  let current = path.resolve(startDir);
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var promises = require('node:readline/promises');
4
- var index = require('./index-BEn7WaqA.cjs');
5
- var session = require('./session-C0eIKZ6V.cjs');
4
+ var index = require('./index-DCJN-V1y.cjs');
5
+ var session = require('./session-BnoHxzFq.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-BPRwn4Yc.cjs');
11
- var runtimeGate = require('./runtime-gate-BMSY22AL.cjs');
10
+ var runtimePermissionEnv = require('./runtime-permission-env-XAZFauvZ.cjs');
12
11
  var node_crypto = require('node:crypto');
13
- var context = require('./context-CA_Q1lyH.cjs');
12
+ var runtimeGate = require('./runtime-gate-BWb8QIcX.cjs');
13
+ var context = require('./context-DuxaBL3Y.cjs');
14
14
  require('node:module');
15
15
  require('path');
16
16
  require('os');
@@ -23,7 +23,7 @@ require('buffer');
23
23
  require('util');
24
24
  require('fs');
25
25
  require('constants');
26
- require('./version-BONZQWPR.cjs');
26
+ require('./version-BGzCIQhE.cjs');
27
27
  require('node:async_hooks');
28
28
 
29
29
  async function getCDNUploadInfo(options, runtime = {}) {
@@ -272,7 +272,7 @@ function createDefaultCosClient(uploadToken, COS) {
272
272
  };
273
273
  }
274
274
  async function loadCosConstructor() {
275
- const cosModule = await Promise.resolve().then(function () { return require('./index-CsP_x6y6.cjs'); }).then(function (n) { return n.index; });
275
+ const cosModule = await Promise.resolve().then(function () { return require('./index-KHhdZ8eZ.cjs'); }).then(function (n) { return n.index; });
276
276
  return cosModule.default;
277
277
  }
278
278
  function formatSize(bytes) {
@@ -509,6 +509,7 @@ async function runDeployCommand(options, runtime = {}) {
509
509
  throw new Error('未在 package.json 中找到 heybox.miniProgramId,请先配置 mini program id');
510
510
  }
511
511
  const fromVersion = options.fromVersion?.trim();
512
+ const declaredPlatforms = fromVersion ? undefined : runtimePermissionEnv.readMiniappPlatformsFromPackageJson(projectRoot);
512
513
  const releaseNote = await resolveDeployReleaseNote(options, runtime);
513
514
  const session$1 = await logger.task('正在校验 Heybox 登录态', () => (runtime.requireAuthSession ?? session.requireHeyboxAuthSession)({ loginBaseUrl }), { successText: 'Heybox 登录态有效' });
514
515
  logger.debug(`Heybox API: ${apiBaseUrl}`);
@@ -583,6 +584,9 @@ async function runDeployCommand(options, runtime = {}) {
583
584
  const distDir = path.join(projectRoot, 'dist');
584
585
  const parsedManifest = await readDeployManifest(projectRoot, logger);
585
586
  ({ manifest, version } = parsedManifest);
587
+ if (!declaredPlatforms || !runtimePermissionEnv.areMiniappPlatformsEqual(parsedManifest.platforms, declaredPlatforms)) {
588
+ throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build 后再 deploy');
589
+ }
586
590
  if (version !== precheckVersion) {
587
591
  throw new Error(`dist/manifest.json.version (${version}) 与预检版本 (${precheckVersion}) 不一致,请重新 build 后再 deploy`);
588
592
  }
@@ -734,11 +738,11 @@ async function readDeployManifest(projectRoot, logger) {
734
738
  if (!runtimeGate.hasMiniappRuntimeGate(entryHtml)) {
735
739
  throw new Error('dist/index.html 缺少平台 Runtime 启动门禁,请在 Vite 配置中启用 miniappManifest() 后重新 build');
736
740
  }
737
- const { manifest, hadBom } = runtimeGate.parseMiniappManifestJson(await fs$1.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
741
+ const { manifest, hadBom } = runtimePermissionEnv.parseMiniappManifestJson(await fs$1.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
738
742
  if (hadBom) {
739
743
  logger.warn('dist/manifest.json 包含 BOM,已自动剥离');
740
744
  }
741
- const validated = runtimeGate.validateMiniappManifestForDeploy(manifest);
745
+ const validated = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
742
746
  return {
743
747
  manifest: { ...manifest, platforms: validated.platforms },
744
748
  sdkVersion: validated.sdkVersion,
@@ -747,7 +751,7 @@ async function readDeployManifest(projectRoot, logger) {
747
751
  };
748
752
  }
749
753
  function validateVersionForDeploy(version, sourceLabel) {
750
- if (typeof version !== 'string' || !runtimeGate.isValidMiniappManifestVersion(version)) {
754
+ if (typeof version !== 'string' || !runtimePermissionEnv.isValidMiniappManifestVersion(version)) {
751
755
  throw new Error(`${sourceLabel} 必须是合法 SemVer,允许 prerelease,不允许 build metadata 和 0.0.0:${String(version)}`);
752
756
  }
753
757
  return version.trim();
@@ -1,109 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var runtimePermissionEnv = require('./runtime-permission-env-BPRwn4Yc.cjs');
4
-
5
- const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
6
- function isValidMiniappManifestVersion(version) {
7
- return getMiniappManifestVersionError(version) === undefined;
8
- }
9
- function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version') {
10
- const error = getMiniappManifestVersionError(version);
11
- if (error) {
12
- throw new Error(`${sourceLabel} ${error}`);
13
- }
14
- return String(version).trim();
15
- }
16
- function parseMiniappManifestJson(raw, sourceLabel = 'manifest.json') {
17
- const hadBom = raw.charCodeAt(0) === 0xfeff;
18
- const text = hadBom ? raw.slice(1) : raw;
19
- let parsed;
20
- try {
21
- parsed = JSON.parse(text);
22
- }
23
- catch (error) {
24
- throw new Error(`${sourceLabel} 不是合法 JSON:${formatReason(error)}`);
25
- }
26
- if (!isManifestRecord(parsed)) {
27
- throw new Error(`${sourceLabel} 必须是 JSON 对象`);
28
- }
29
- return {
30
- manifest: parsed,
31
- hadBom,
32
- };
33
- }
34
- function validateMiniappManifestForDeploy(manifest) {
35
- const version = validateMiniappManifestVersion(manifest.version, 'manifest.version');
36
- const sdkVersion = validateSdkVersion(manifest.sdkVersion, 'manifest.sdkVersion');
37
- const permissions = runtimePermissionEnv.parseMiniappPermissions(manifest.permissions, {
38
- present: Object.prototype.hasOwnProperty.call(manifest, 'permissions'),
39
- sdkVersion,
40
- sourceLabel: 'manifest.permissions',
41
- });
42
- return {
43
- version,
44
- sdkVersion,
45
- platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
46
- ...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
47
- };
48
- }
49
- function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
50
- if (!Array.isArray(platforms) || platforms.length === 0) {
51
- throw new Error(`${sourceLabel} 必须是非空平台数组`);
52
- }
53
- const allowedPlatforms = new Set(MINIAPP_PLATFORM_VALUES);
54
- const seen = new Set();
55
- for (const platform of platforms) {
56
- if (typeof platform !== 'string' || !allowedPlatforms.has(platform)) {
57
- throw new Error(`${sourceLabel} 包含不支持的平台:${String(platform)}`);
58
- }
59
- if (seen.has(platform)) {
60
- throw new Error(`${sourceLabel} 包含重复平台:${platform}`);
61
- }
62
- seen.add(platform);
63
- }
64
- return Object.freeze(MINIAPP_PLATFORM_VALUES.filter((platform) => seen.has(platform)));
65
- }
66
- function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
67
- if (typeof version !== 'string' || version.trim() === '') {
68
- throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
69
- }
70
- const normalized = version.trim();
71
- const parsed = runtimePermissionEnv.semverExports.parse(normalized);
72
- if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
73
- throw new Error(`${sourceLabel} 必须是合法 SemVer:${normalized}`);
74
- }
75
- return normalized;
76
- }
77
- function isManifestRecord(value) {
78
- return typeof value === 'object' && value !== null && !Array.isArray(value);
79
- }
80
- function getMiniappManifestVersionError(version) {
81
- if (typeof version !== 'string' || version.trim() === '') {
82
- return `必须是合法 SemVer:${String(version)}`;
83
- }
84
- const normalized = version.trim();
85
- const parsed = runtimePermissionEnv.semverExports.parse(normalized);
86
- if (!parsed) {
87
- return `必须是合法 SemVer:${normalized}`;
88
- }
89
- if (parsed.build.length > 0) {
90
- return `不能包含 build metadata:${normalized}`;
91
- }
92
- if (parsed.version !== normalized) {
93
- return `必须是合法 SemVer:${normalized}`;
94
- }
95
- if (parsed.major === 0 && parsed.minor === 0 && parsed.patch === 0) {
96
- return '不能是模板默认版本 0.0.0';
97
- }
98
- return undefined;
99
- }
100
- function formatReason(error) {
101
- if (error instanceof Error && error.message) {
102
- return error.message;
103
- }
104
- return String(error);
105
- }
106
-
107
3
  const UNDEFINED_CODE_POINTS = new Set([
108
4
  65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
109
5
  393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
@@ -8390,6 +8286,3 @@ function walk(node, visit) {
8390
8286
  }
8391
8287
 
8392
8288
  exports.hasMiniappRuntimeGate = hasMiniappRuntimeGate;
8393
- exports.isValidMiniappManifestVersion = isValidMiniappManifestVersion;
8394
- exports.parseMiniappManifestJson = parseMiniappManifestJson;
8395
- exports.validateMiniappManifestForDeploy = validateMiniappManifestForDeploy;
@@ -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-BONZQWPR.cjs');
5
+ var version = require('./version-BGzCIQhE.cjs');
6
6
  var node_async_hooks = require('node:async_hooks');
7
7
 
8
8
  var re = {exports: {}};
@@ -3069,6 +3069,111 @@ function isRecord$1(value) {
3069
3069
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3070
3070
  }
3071
3071
 
3072
+ const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
3073
+ function isValidMiniappManifestVersion(version) {
3074
+ return getMiniappManifestVersionError(version) === undefined;
3075
+ }
3076
+ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version') {
3077
+ const error = getMiniappManifestVersionError(version);
3078
+ if (error) {
3079
+ throw new Error(`${sourceLabel} ${error}`);
3080
+ }
3081
+ return String(version).trim();
3082
+ }
3083
+ function parseMiniappManifestJson(raw, sourceLabel = 'manifest.json') {
3084
+ const hadBom = raw.charCodeAt(0) === 0xfeff;
3085
+ const text = hadBom ? raw.slice(1) : raw;
3086
+ let parsed;
3087
+ try {
3088
+ parsed = JSON.parse(text);
3089
+ }
3090
+ catch (error) {
3091
+ throw new Error(`${sourceLabel} 不是合法 JSON:${formatReason$1(error)}`);
3092
+ }
3093
+ if (!isManifestRecord(parsed)) {
3094
+ throw new Error(`${sourceLabel} 必须是 JSON 对象`);
3095
+ }
3096
+ return {
3097
+ manifest: parsed,
3098
+ hadBom,
3099
+ };
3100
+ }
3101
+ function validateMiniappManifestForDeploy(manifest) {
3102
+ const version = validateMiniappManifestVersion(manifest.version, 'manifest.version');
3103
+ const sdkVersion = validateSdkVersion(manifest.sdkVersion, 'manifest.sdkVersion');
3104
+ const permissions = parseMiniappPermissions(manifest.permissions, {
3105
+ present: Object.prototype.hasOwnProperty.call(manifest, 'permissions'),
3106
+ sdkVersion,
3107
+ sourceLabel: 'manifest.permissions',
3108
+ });
3109
+ return {
3110
+ version,
3111
+ sdkVersion,
3112
+ platforms: validateMiniappPlatforms(manifest.platforms, 'manifest.platforms'),
3113
+ ...(permissions.permissions === undefined ? {} : { permissions: permissions.permissions }),
3114
+ };
3115
+ }
3116
+ function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
3117
+ if (!Array.isArray(platforms) || platforms.length === 0) {
3118
+ throw new Error(`${sourceLabel} 必须是非空平台数组`);
3119
+ }
3120
+ const allowedPlatforms = new Set(MINIAPP_PLATFORM_VALUES);
3121
+ const seen = new Set();
3122
+ for (const platform of platforms) {
3123
+ if (typeof platform !== 'string' || !allowedPlatforms.has(platform)) {
3124
+ throw new Error(`${sourceLabel} 包含不支持的平台:${String(platform)}`);
3125
+ }
3126
+ if (seen.has(platform)) {
3127
+ throw new Error(`${sourceLabel} 包含重复平台:${platform}`);
3128
+ }
3129
+ seen.add(platform);
3130
+ }
3131
+ return Object.freeze(MINIAPP_PLATFORM_VALUES.filter((platform) => seen.has(platform)));
3132
+ }
3133
+ function areMiniappPlatformsEqual(left, right) {
3134
+ return left.length === right.length && left.every((platform, index) => platform === right[index]);
3135
+ }
3136
+ function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
3137
+ if (typeof version !== 'string' || version.trim() === '') {
3138
+ throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
3139
+ }
3140
+ const normalized = version.trim();
3141
+ const parsed = semverExports.parse(normalized);
3142
+ if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
3143
+ throw new Error(`${sourceLabel} 必须是合法 SemVer:${normalized}`);
3144
+ }
3145
+ return normalized;
3146
+ }
3147
+ function isManifestRecord(value) {
3148
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3149
+ }
3150
+ function getMiniappManifestVersionError(version) {
3151
+ if (typeof version !== 'string' || version.trim() === '') {
3152
+ return `必须是合法 SemVer:${String(version)}`;
3153
+ }
3154
+ const normalized = version.trim();
3155
+ const parsed = semverExports.parse(normalized);
3156
+ if (!parsed) {
3157
+ return `必须是合法 SemVer:${normalized}`;
3158
+ }
3159
+ if (parsed.build.length > 0) {
3160
+ return `不能包含 build metadata:${normalized}`;
3161
+ }
3162
+ if (parsed.version !== normalized) {
3163
+ return `必须是合法 SemVer:${normalized}`;
3164
+ }
3165
+ if (parsed.major === 0 && parsed.minor === 0 && parsed.patch === 0) {
3166
+ return '不能是模板默认版本 0.0.0';
3167
+ }
3168
+ return undefined;
3169
+ }
3170
+ function formatReason$1(error) {
3171
+ if (error instanceof Error && error.message) {
3172
+ return error.message;
3173
+ }
3174
+ return String(error);
3175
+ }
3176
+
3072
3177
  const MINIAPP_UPLOAD_SCOPE = 'activity';
3073
3178
  const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
3074
3179
  const MINIAPP_UPLOAD_BATCH_SIZE = 50;
@@ -3359,14 +3464,16 @@ function findNearestPackageJsonPath(startDir) {
3359
3464
  current = parent;
3360
3465
  }
3361
3466
  }
3467
+ function readMiniappPlatformsFromPackageJson(root) {
3468
+ const { packageJson } = readMiniappPackageJson(root);
3469
+ const heybox = readMiniappHeyboxConfig(packageJson);
3470
+ return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
3471
+ }
3362
3472
  function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
3363
3473
  const { packageJson } = readMiniappPackageJson(root);
3364
- const heybox = packageJson.heybox;
3365
- if (heybox !== undefined && !isRecord(heybox)) {
3366
- throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3367
- }
3368
- const present = isRecord(heybox) && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3369
- return parseMiniappPermissions(isRecord(heybox) ? heybox.permissions : undefined, {
3474
+ const heybox = readMiniappHeyboxConfig(packageJson);
3475
+ const present = heybox !== undefined && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3476
+ return parseMiniappPermissions(heybox?.permissions, {
3370
3477
  present,
3371
3478
  sdkVersion,
3372
3479
  });
@@ -3397,6 +3504,12 @@ function readMiniappPackageJson(root, requireVersion) {
3397
3504
  }
3398
3505
  return { packageJson, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
3399
3506
  }
3507
+ function readMiniappHeyboxConfig(packageJson) {
3508
+ if (packageJson.heybox !== undefined && !isRecord(packageJson.heybox)) {
3509
+ throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3510
+ }
3511
+ return packageJson.heybox;
3512
+ }
3400
3513
  function isRecord(value) {
3401
3514
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3402
3515
  }
@@ -3498,23 +3611,26 @@ exports.USER_MINIPROGRAM_ACCESS_STATUS_API_PATH = USER_MINIPROGRAM_ACCESS_STATUS
3498
3611
  exports.USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH;
3499
3612
  exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH;
3500
3613
  exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
3614
+ exports.areMiniappPlatformsEqual = areMiniappPlatformsEqual;
3501
3615
  exports.composeMiniappRuntimePermissions = composeMiniappRuntimePermissions;
3502
3616
  exports.createMiniappArtifactFileHeader = createMiniappArtifactFileHeader;
3503
3617
  exports.createMiniappArtifactSignatureHeader = createMiniappArtifactSignatureHeader;
3504
3618
  exports.createMiniappPlatformCspEnv = createMiniappPlatformCspEnv;
3505
3619
  exports.getMissingPermissionsWarning = getMissingPermissionsWarning;
3620
+ exports.isValidMiniappManifestVersion = isValidMiniappManifestVersion;
3506
3621
  exports.normalizeRelativePath = normalizeRelativePath;
3507
3622
  exports.parseMiniProgramRuntimePermissions = parseMiniProgramRuntimePermissions;
3508
- exports.parseMiniappPermissions = parseMiniappPermissions;
3623
+ exports.parseMiniappManifestJson = parseMiniappManifestJson;
3509
3624
  exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
3510
3625
  exports.readMiniappPermissionsFromPackageJson = readMiniappPermissionsFromPackageJson;
3626
+ exports.readMiniappPlatformsFromPackageJson = readMiniappPlatformsFromPackageJson;
3511
3627
  exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
3512
3628
  exports.requireSemver = requireSemver;
3513
3629
  exports.resolveMiniappSdkVersion = resolveMiniappSdkVersion;
3514
3630
  exports.resolveMiniappUploadSessionFiles = resolveMiniappUploadSessionFiles;
3515
- exports.semverExports = semverExports;
3516
3631
  exports.shouldSkipMiniappPlatformCspFromEnv = shouldSkipMiniappPlatformCspFromEnv;
3517
3632
  exports.shouldUploadDistFile = shouldUploadDistFile;
3633
+ exports.validateMiniappManifestForDeploy = validateMiniappManifestForDeploy;
3518
3634
  exports.validateMiniappUploadPathLengths = validateMiniappUploadPathLengths;
3519
3635
  exports.validateUploadTotalSize = validateUploadTotalSize;
3520
3636
  exports.withMiniappPlatformCspEnv = withMiniappPlatformCspEnv;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BEn7WaqA.cjs');
3
+ var index = require('./index-DCJN-V1y.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var path = require('node:path');
6
6
  var require$$0$2 = require('fs');
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var path = require('node:path');
4
- var version = require('./version-BONZQWPR.cjs');
4
+ var version = require('./version-BGzCIQhE.cjs');
5
5
  var childProcess = require('node:child_process');
6
6
  var fs = require('node:fs/promises');
7
- var index = require('./index-BEn7WaqA.cjs');
7
+ var index = require('./index-DCJN-V1y.cjs');
8
8
  require('node:module');
9
9
  require('node:fs');
10
10
  require('path');
@@ -3,6 +3,6 @@
3
3
  /** 构建时替换为当前发布包的实际版本。 */
4
4
  const HB_SDK_VERSION = typeof undefined === 'string'
5
5
  ? undefined
6
- : '0.8.1-alpha.2';
6
+ : '0.8.1-alpha.3';
7
7
 
8
8
  exports.HB_SDK_VERSION = HB_SDK_VERSION;
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-BEn7WaqA.cjs');
3
+ var index = require('./cli-chunks/index-DCJN-V1y.cjs');
4
4
  require('node:module');
5
5
  require('node:fs');
6
6
  require('node:fs/promises');
package/dist/index.cjs.js CHANGED
@@ -799,7 +799,7 @@ function createMessageId() {
799
799
  /** 构建时替换为当前发布包的实际版本。 */
800
800
  const HB_SDK_VERSION = typeof undefined === 'string'
801
801
  ? undefined
802
- : '0.8.1-alpha.2';
802
+ : '0.8.1-alpha.3';
803
803
 
804
804
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
805
805
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
package/dist/index.esm.js CHANGED
@@ -795,7 +795,7 @@ function createMessageId() {
795
795
  /** 构建时替换为当前发布包的实际版本。 */
796
796
  const HB_SDK_VERSION = typeof undefined === 'string'
797
797
  ? undefined
798
- : '0.8.1-alpha.2';
798
+ : '0.8.1-alpha.3';
799
799
 
800
800
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
801
801
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
@@ -9,6 +9,6 @@ npm run build
9
9
  npm run deploy -- --release-note "更新说明"
10
10
  ```
11
11
 
12
- `vite.config.js` 默认声明 `android`、`ios`、`ohos`。发布前请在每个声明的平台完成真机验收;需要支持桌面平台时,由项目自行加入并验收。
12
+ `package.json#heybox.platforms` 默认声明 `android`、`ios`、`ohos`。发布前请在每个声明的平台完成真机验收;需要支持桌面平台时,由项目自行加入并验收。
13
13
 
14
14
  更多内容见 [CLI 指南](https://docs.xiaoheihe.cn/hb_sdk/guide/cli) 和 [SDK 文档](https://docs.xiaoheihe.cn/hb_sdk/)。
@@ -5,6 +5,7 @@
5
5
  "type": "module",
6
6
  "heybox": {
7
7
  "miniProgramId": "",
8
+ "platforms": ["android", "ios", "ohos"],
8
9
  "permissions": {}
9
10
  },
10
11
  "scripts": {
@@ -3,5 +3,5 @@ import { defineConfig } from 'vite';
3
3
 
4
4
  export default defineConfig({
5
5
  base: './',
6
- plugins: [miniappManifest({ platforms: ['android', 'ios', 'ohos'] })],
6
+ plugins: [miniappManifest()],
7
7
  });
package/dist/vite.cjs.js CHANGED
@@ -8,7 +8,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
8
8
  /** 构建时替换为当前发布包的实际版本。 */
9
9
  const HB_SDK_VERSION = typeof undefined === 'string'
10
10
  ? undefined
11
- : '0.8.1-alpha.2';
11
+ : '0.8.1-alpha.3';
12
12
 
13
13
  /**
14
14
  * iframe 与调试台页面的开发期 console 捕获转发。
@@ -3085,14 +3085,16 @@ function findNearestPackageJsonPath(startDir) {
3085
3085
  function readMiniappVersionFromPackageJson(root) {
3086
3086
  return readMiniappPackageJson(root, true).version;
3087
3087
  }
3088
+ function readMiniappPlatformsFromPackageJson(root) {
3089
+ const { packageJson } = readMiniappPackageJson(root, false);
3090
+ const heybox = readMiniappHeyboxConfig(packageJson);
3091
+ return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
3092
+ }
3088
3093
  function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
3089
3094
  const { packageJson } = readMiniappPackageJson(root, false);
3090
- const heybox = packageJson.heybox;
3091
- if (heybox !== undefined && !isRecord(heybox)) {
3092
- throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3093
- }
3094
- const present = isRecord(heybox) && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3095
- return parseMiniappPermissions(isRecord(heybox) ? heybox.permissions : undefined, {
3095
+ const heybox = readMiniappHeyboxConfig(packageJson);
3096
+ const present = heybox !== undefined && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3097
+ return parseMiniappPermissions(heybox?.permissions, {
3096
3098
  present,
3097
3099
  sdkVersion,
3098
3100
  });
@@ -3118,6 +3120,12 @@ function readMiniappPackageJson(root, requireVersion) {
3118
3120
  }
3119
3121
  return { packageJson, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
3120
3122
  }
3123
+ function readMiniappHeyboxConfig(packageJson) {
3124
+ if (packageJson.heybox !== undefined && !isRecord(packageJson.heybox)) {
3125
+ throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3126
+ }
3127
+ return packageJson.heybox;
3128
+ }
3121
3129
  function isRecord(value) {
3122
3130
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3123
3131
  }
@@ -11903,8 +11911,7 @@ function injectMiniDevConsoleBootstrap(html) {
11903
11911
  const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
11904
11912
  const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
11905
11913
  const miniDevLoggingConstant = ['__HB_SDK_DEV', 'LOGGING__'].join('_');
11906
- function miniappManifest(options) {
11907
- const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
11914
+ function miniappManifest() {
11908
11915
  const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
11909
11916
  let root = process.cwd();
11910
11917
  let outDir = 'dist';
@@ -11951,7 +11958,8 @@ function miniappManifest(options) {
11951
11958
  skipPlatformCsp,
11952
11959
  });
11953
11960
  return command === 'serve' ? injectMiniDevConsoleBootstrap(enforced) : enforced;
11954
- }, async closeBundle() {
11961
+ },
11962
+ async closeBundle() {
11955
11963
  // Rollup 在 buildStart/transform 失败后仍会调用 closeBundle。
11956
11964
  // 若此时再抛「缺 index.html」等二次错误,会掩盖真实失败原因。
11957
11965
  if (priorBuildError) {
@@ -11959,6 +11967,7 @@ function miniappManifest(options) {
11959
11967
  }
11960
11968
  const version = validateMiniappPackageVersionForBuild(readMiniappVersionFromPackageJson(root));
11961
11969
  const sdkVersion = resolveSdkVersion();
11970
+ const platforms = readMiniappPlatformsFromPackageJson(root);
11962
11971
  const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
11963
11972
  if (!parsedPermissions.declared)
11964
11973
  this.warn(getMissingPermissionsWarning());
package/dist/vite.esm.js CHANGED
@@ -5,7 +5,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
5
5
  /** 构建时替换为当前发布包的实际版本。 */
6
6
  const HB_SDK_VERSION = typeof undefined === 'string'
7
7
  ? undefined
8
- : '0.8.1-alpha.2';
8
+ : '0.8.1-alpha.3';
9
9
 
10
10
  /**
11
11
  * iframe 与调试台页面的开发期 console 捕获转发。
@@ -3082,14 +3082,16 @@ function findNearestPackageJsonPath(startDir) {
3082
3082
  function readMiniappVersionFromPackageJson(root) {
3083
3083
  return readMiniappPackageJson(root, true).version;
3084
3084
  }
3085
+ function readMiniappPlatformsFromPackageJson(root) {
3086
+ const { packageJson } = readMiniappPackageJson(root, false);
3087
+ const heybox = readMiniappHeyboxConfig(packageJson);
3088
+ return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
3089
+ }
3085
3090
  function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
3086
3091
  const { packageJson } = readMiniappPackageJson(root, false);
3087
- const heybox = packageJson.heybox;
3088
- if (heybox !== undefined && !isRecord(heybox)) {
3089
- throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3090
- }
3091
- const present = isRecord(heybox) && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3092
- return parseMiniappPermissions(isRecord(heybox) ? heybox.permissions : undefined, {
3092
+ const heybox = readMiniappHeyboxConfig(packageJson);
3093
+ const present = heybox !== undefined && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3094
+ return parseMiniappPermissions(heybox?.permissions, {
3093
3095
  present,
3094
3096
  sdkVersion,
3095
3097
  });
@@ -3115,6 +3117,12 @@ function readMiniappPackageJson(root, requireVersion) {
3115
3117
  }
3116
3118
  return { packageJson, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
3117
3119
  }
3120
+ function readMiniappHeyboxConfig(packageJson) {
3121
+ if (packageJson.heybox !== undefined && !isRecord(packageJson.heybox)) {
3122
+ throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3123
+ }
3124
+ return packageJson.heybox;
3125
+ }
3118
3126
  function isRecord(value) {
3119
3127
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3120
3128
  }
@@ -11900,8 +11908,7 @@ function injectMiniDevConsoleBootstrap(html) {
11900
11908
  const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
11901
11909
  const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
11902
11910
  const miniDevLoggingConstant = ['__HB_SDK_DEV', 'LOGGING__'].join('_');
11903
- function miniappManifest(options) {
11904
- const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
11911
+ function miniappManifest() {
11905
11912
  const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
11906
11913
  let root = process.cwd();
11907
11914
  let outDir = 'dist';
@@ -11948,7 +11955,8 @@ function miniappManifest(options) {
11948
11955
  skipPlatformCsp,
11949
11956
  });
11950
11957
  return command === 'serve' ? injectMiniDevConsoleBootstrap(enforced) : enforced;
11951
- }, async closeBundle() {
11958
+ },
11959
+ async closeBundle() {
11952
11960
  // Rollup 在 buildStart/transform 失败后仍会调用 closeBundle。
11953
11961
  // 若此时再抛「缺 index.html」等二次错误,会掩盖真实失败原因。
11954
11962
  if (priorBuildError) {
@@ -11956,6 +11964,7 @@ function miniappManifest(options) {
11956
11964
  }
11957
11965
  const version = validateMiniappPackageVersionForBuild(readMiniappVersionFromPackageJson(root));
11958
11966
  const sdkVersion = resolveSdkVersion();
11967
+ const platforms = readMiniappPlatformsFromPackageJson(root);
11959
11968
  const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
11960
11969
  if (!parsedPermissions.declared)
11961
11970
  this.warn(getMissingPermissionsWarning());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.8.1-alpha.2",
3
+ "version": "0.8.1-alpha.3",
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.2"
65
+ "@heybox/hb-sdk-protocol": "0.8.1-alpha.3"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "vite": ">=5"
@@ -113,13 +113,13 @@
113
113
  "vue-tsc": "^3.3.7",
114
114
  "vite": "^8.0.12",
115
115
  "vitest": "^3.2.4",
116
- "@heybox-domain/heybox-vue3-ui": "~0.1.0",
117
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.3",
118
119
  "@heybox/hb-api": "~1.28.2",
119
- "@heybox/hb-sdk-runtime": "~0.8.1-alpha.2",
120
- "@heybox/runtime-policy": "~0.2.0",
120
+ "@heybox/runtime": "~0.2.0",
121
121
  "@heybox/runtime-transport-fetch": "~0.2.0",
122
- "@heybox/runtime": "~0.2.0"
122
+ "@heybox/runtime-policy": "~0.2.0"
123
123
  },
124
124
  "publishConfig": {
125
125
  "registry": "https://registry.npmjs.org/",
package/skill/SKILL.md CHANGED
@@ -61,7 +61,7 @@ Apply these instructions when writing, reviewing, or debugging code that consume
61
61
  2. Use `hb-sdk dev` for Browser Mock and Mobile App debugging. Browser debugging can start without CLI login, project binding, or a remote Dev Context; capabilities that need those inputs fail explicitly. Mobile uses the single QR entry with the `open_inapp` and `heybox://` `openWindow` wrapper around a LAN short URL, then opens `heybox-mini-dev://sandbox` with the complete launch context.
62
62
  3. The debugging page does not edit permissions. Treat the validated remote permission snapshot as canonical Runtime input. Use `--port`, `--browser-dev-host-port`, and `--no-open` to control local endpoints and browser opening. Select a Mobile network interface the device can reach. `launch.json` is a LAN discovery document, not authentication, encryption, signing, or HMAC protection.
63
63
  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.
64
- 5. Keep `miniappManifest()` explicitly enabled in `vite.config.ts`; `hb-sdk build` must fail when the required Manifest or Runtime gate output is missing.
64
+ 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.
65
65
  6. 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.
66
66
  7. 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`.
67
67
  8. 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.
@@ -97,7 +97,7 @@ For CLI and local development:
97
97
  1. Do not print, persist in templates, or pass through pkey, cookies, tokens, or private credentials.
98
98
  2. Do not skip `auth.login()` in mini-program code. Browser Mock may reuse the Node `hb-sdk login` session for Host network requests, but the page must still call `auth.login()` and handle the authorization dialog. Never paste CLI credentials into page JavaScript.
99
99
  3. Use the built-in local debugging page instead of creating another browser Mock.
100
- 4. Keep the Vite `miniappManifest()` plugin enabled.
100
+ 4. Keep target platforms in `package.json#heybox.platforms` and the no-argument Vite `miniappManifest()` plugin enabled. Do not configure platforms in Vite or maintain a second platform list.
101
101
  5. Do not suggest changing or resetting permissions in the `hb-sdk dev` debugging page; that UI does not exist. Diagnose permission behavior from the remote snapshot and capability result.
102
102
  6. Treat browser Mock results as development feedback only. Validate permissions, identity flows, and user interactions again in a real Heybox client before publishing.
103
103
  7. The Browser Dev Host offers iPhone 16 Pro Max (`440 x 956`) and Pixel 9 Pro (`410 x 914`) presets. Switching a preset must preserve the iframe, Runtime session, and page state. Authorization/action dialogs, Toast, Loading, and vibration feedback render inside the preview. Use the upper-right QR popover as the only Mobile QR entry.
@@ -302,9 +302,9 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
302
302
  | Root API | 2 | 4 | 67 | 62 | 2 |
303
303
  | Protocol API | 0 | 13 | 58 | 90 | 47 |
304
304
  | Miniapp Publish API | 0 | 5 | 2 | 0 | 0 |
305
- | Vite API | 0 | 1 | 5 | 1 | 1 |
305
+ | Vite API | 0 | 1 | 4 | 1 | 1 |
306
306
 
307
- <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=1b6c6a8f921122d588700ac1323b6c46a2ee6d331c585078527612b218546757 -->
307
+ <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=4; fingerprint=a8018ebd23e4d885efbe08f622a6cf4780dd152d5f90cc4a78d2eb7e15eca2e2 -->
308
308
 
309
309
  ## SDK API
310
310
 
@@ -26,7 +26,7 @@
26
26
  ## Package metadata
27
27
 
28
28
  - Package: `@heybox/hb-sdk`
29
- - Version at generation time: `0.8.1-alpha.2`
29
+ - Version at generation time: `0.8.1-alpha.3`
30
30
  - Public root export: `@heybox/hb-sdk`
31
31
  - Protocol export: `@heybox/hb-sdk/protocol`
32
32
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -248,11 +248,13 @@ import {
248
248
  MINIAPP_PLATFORM_VALUES,
249
249
  renderMiniappManifest,
250
250
  validateMiniappPackageVersionForBuild,
251
- validateMiniappPlatforms,
252
251
  type MiniappPlatform,
253
252
  } from '../miniapp-manifest/schema';
254
- import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
255
- import { readMiniappPermissionsFromPackageJson } from '../miniapp-manifest/node';
253
+ import {
254
+ readMiniappPermissionsFromPackageJson,
255
+ readMiniappPlatformsFromPackageJson,
256
+ readMiniappVersionFromPackageJson,
257
+ } from '../miniapp-manifest/node';
256
258
  import { getMissingPermissionsWarning } from '../miniapp-manifest/permissions';
257
259
  import { enforceMiniappHtmlPolicy } from './html-policy';
258
260
  import { shouldSkipMiniappPlatformCspFromEnv } from './runtime-permission-env';
@@ -322,16 +324,11 @@ function injectMiniDevConsoleBootstrap(html: string): string {
322
324
  return `${html.slice(0, insertAt)}${bootstrap}${html.slice(insertAt)}`;
323
325
  }
324
326
 
325
- export interface MiniappManifestOptions {
326
- platforms: readonly MiniappPlatform[];
327
- }
328
-
329
327
  const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
330
328
  const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
331
329
  const miniDevLoggingConstant = ['__HB_SDK_DEV', 'LOGGING__'].join('_');
332
330
 
333
- export function miniappManifest(options: MiniappManifestOptions): MiniappManifestPlugin {
334
- const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
331
+ export function miniappManifest(): MiniappManifestPlugin {
335
332
  const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
336
333
  let root = process.cwd();
337
334
  let outDir = 'dist';
@@ -379,7 +376,8 @@ export function miniappManifest(options: MiniappManifestOptions): MiniappManifes
379
376
  skipPlatformCsp,
380
377
  });
381
378
  return command === 'serve' ? injectMiniDevConsoleBootstrap(enforced) : enforced;
382
- }, async closeBundle() {
379
+ },
380
+ async closeBundle() {
383
381
  // Rollup 在 buildStart/transform 失败后仍会调用 closeBundle。
384
382
  // 若此时再抛「缺 index.html」等二次错误,会掩盖真实失败原因。
385
383
  if (priorBuildError) {
@@ -388,6 +386,7 @@ export function miniappManifest(options: MiniappManifestOptions): MiniappManifes
388
386
 
389
387
  const version = validateMiniappPackageVersionForBuild(readMiniappVersionFromPackageJson(root));
390
388
  const sdkVersion = resolveSdkVersion();
389
+ const platforms = readMiniappPlatformsFromPackageJson(root);
391
390
  const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
392
391
  if (!parsedPermissions.declared) this.warn(getMissingPermissionsWarning());
393
392
  const outputRoot = path.resolve(root, outDir);
@@ -469,7 +468,7 @@ function resolveHmrWebSocketUrl(resolved: MiniappManifestResolvedConfig) {
469
468
  hb-sdk build [--env <name>] [--verbose]
470
469
  ```
471
470
 
472
- `hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `vite.config.ts` 中显式注册 `miniappManifest()`。
471
+ `hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `package.json#heybox.platforms` 声明目标平台,并在 `vite.config.ts` 中显式注册无参的 `miniappManifest()`;配置与构建产物不一致时构建失败。
473
472
 
474
473
  直接运行 `hb-sdk build` 或 `vite build` 时默认注入平台 CSP。`hb-sdk remote deploy` 会在构建前读取绑定小程序的远端批准结果,并与当前版本声明取交集;仅当有效 `network` 权限启用时才跳过平台 CSP,`useOfficialDomain` 不参与该判定。权限缺失、非法或读取失败时继续注入,Runtime Gate、Manifest 与 HTML 构建检查始终保留。
475
474
 
@@ -162,7 +162,7 @@ Browser Mock uses the Node `hb-sdk login` session to send Host `heybox-session`
162
162
  hb-sdk build [--env <name>] [--verbose]
163
163
  ```
164
164
 
165
- `hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `vite.config.ts` 中显式注册 `miniappManifest()`。
165
+ `hb-sdk build` 直接使用项目安装的 Vite,先清理再生成固定的 `dist/`,并校验小程序入口、Manifest 和可上传产物。它不执行类型检查,不要求 CLI 登录或绑定小程序,也不访问远端服务。项目必须在 `package.json#heybox.platforms` 声明目标平台,并在 `vite.config.ts` 中显式注册无参的 `miniappManifest()`;配置与构建产物不一致时构建失败。
166
166
 
167
167
  直接运行 `hb-sdk build` 或 `vite build` 时默认注入平台 CSP。`hb-sdk remote deploy` 会在构建前读取绑定小程序的远端批准结果,并与当前版本声明取交集;仅当有效 `network` 权限启用时才跳过平台 CSP,`useOfficialDomain` 不参与该判定。权限缺失、非法或读取失败时继续注入,Runtime Gate、Manifest 与 HTML 构建检查始终保留。
168
168
 
@@ -181,7 +181,7 @@ hb-sdk build [--env <name>] [--verbose]
181
181
  Agent rules:
182
182
 
183
183
  - Use `hb-sdk build [--env <name>] [--verbose]` as the recommended production build entry.
184
- - Require explicit `miniappManifest()` configuration and keep typechecking in the project's `scripts.build`.
184
+ - Require target platforms in `package.json#heybox.platforms`, keep the no-argument `miniappManifest()` configured, and keep typechecking in the project's `scripts.build`.
185
185
  - Do not claim `hb-sdk build` needs login, binding, or network access, and do not invent unsupported build flags.
186
186
  - Existing `vite build` projects remain compatible and must not be auto-migrated.
187
187
 
@@ -165,13 +165,21 @@ hb-sdk login clear
165
165
 
166
166
  ### Vite manifest plugin
167
167
 
168
+ ```json
169
+ {
170
+ "heybox": {
171
+ "platforms": ["android", "ios", "ohos"]
172
+ }
173
+ }
174
+ ```
175
+
168
176
  ```ts
169
177
  import { miniappManifest } from '@heybox/hb-sdk/vite';
170
178
  import { defineConfig } from 'vite';
171
179
 
172
180
  export default defineConfig({
173
181
  base: './',
174
- plugins: [miniappManifest({ platforms: ['android', 'ios', 'ohos'] })],
182
+ plugins: [miniappManifest()],
175
183
  });
176
184
  ```
177
185
 
@@ -35,7 +35,7 @@
35
35
  - Host 文件错误只保留稳定 code 与 canonical 安全文案;原始 message、data、native path 和 credential 不会进入小程序。
36
36
  - `FileStat.size` 是非负 safe integer;`modifiedAt` / `createdAt` 若存在,单位为 Unix epoch milliseconds。
37
37
  - 仅当当前版本声明且平台已批准 `network` 时,`hb-sdk dev` 与 `hb-sdk remote deploy` 构建才会跳过平台 CSP;其他构建继续注入平台 CSP。`useOfficialDomain` 不参与 CSP 跳过判定。
38
- - 构建必须启用 `miniappManifest({ platforms })` 并显式声明实际承诺适配的平台,推荐统一使用 `hb-sdk build`。新项目模板中的 `['android', 'ios', 'ohos']` 只是初始配置,不代表已经完成真机验收。
38
+ - 构建必须启用 `miniappManifest()`,并在 `package.json#heybox.platforms` 显式声明实际承诺适配的平台,推荐统一使用 `hb-sdk build`。新项目模板中的 `['android', 'ios', 'ohos']` 只是初始配置,不代表已经完成真机验收。
39
39
 
40
40
  私有 Page Channel 适配没有修改 `@heybox/hb-sdk` 公开 API 或 iframe wire;本次 files/download
41
41
  Runtime 能力随 `0.8.0-alpha.11` release family 发布,部署 detail 前必须保证
package/skill/skill.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.8.1-alpha.2+skill.99494863257b",
3
+ "skillVersion": "0.8.1-alpha.3+skill.c60361a729d0",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.8.1-alpha.2",
7
- "compatibility": "0.8.1-alpha.2"
6
+ "version": "0.8.1-alpha.3",
7
+ "compatibility": "0.8.1-alpha.3"
8
8
  },
9
9
  "distribution": {
10
10
  "type": "npm",
11
11
  "package": "@heybox/hb-sdk",
12
- "version": "0.8.1-alpha.2",
12
+ "version": "0.8.1-alpha.3",
13
13
  "path": "skill"
14
14
  },
15
- "integrity": "sha256-99494863257b8e51843a42bb94c2e40555a1cc28f11ca0f7da37473e19424bdf"
15
+ "integrity": "sha256-c60361a729d0821a4a2d350d1d06a92ad94abfb77ae2f42320fce078fba023e1"
16
16
  }
@@ -1,4 +1,6 @@
1
1
  import { type ParsedMiniappPermissions } from './permissions';
2
+ import type { MiniappPlatform } from './schema';
2
3
  export declare function readMiniappVersionFromPackageJson(root: string): string;
4
+ export declare function readMiniappPlatformsFromPackageJson(root: string): readonly MiniappPlatform[];
3
5
  export declare function readMiniappPermissionsFromPackageJson(root: string, sdkVersion: string): ParsedMiniappPermissions;
4
6
  export declare function resolveMiniappSdkVersion(): string;
@@ -27,4 +27,5 @@ export declare function validateMiniappManifestForDeploy(manifest: MiniappManife
27
27
  platforms: readonly ("android" | "ios" | "ohos" | "windows" | "macos" | "linux")[];
28
28
  };
29
29
  export declare function validateMiniappPlatforms(platforms: unknown, sourceLabel?: string): readonly MiniappPlatform[];
30
+ export declare function areMiniappPlatformsEqual(left: readonly MiniappPlatform[], right: readonly MiniappPlatform[]): boolean;
30
31
  export declare function validateSdkVersion(version: unknown, sourceLabel?: string): string;
@@ -40,7 +40,4 @@ export interface MiniappManifestResolvedConfig {
40
40
  }
41
41
  export { MINIAPP_PLATFORM_VALUES };
42
42
  export type { MiniappPlatform };
43
- export interface MiniappManifestOptions {
44
- platforms: readonly MiniappPlatform[];
45
- }
46
- export declare function miniappManifest(options: MiniappManifestOptions): MiniappManifestPlugin;
43
+ export declare function miniappManifest(): MiniappManifestPlugin;