@heybox/hb-sdk 0.9.4-alpha.0 → 0.9.4-alpha.2

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 (31) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -0
  3. package/dist/cli-chunks/{runtime-gate-alLUP4_C.cjs → artifact-BTi9i7N4.cjs} +136 -65
  4. package/dist/cli-chunks/{build-BHfbvke-.cjs → build-CScc5bgz.cjs} +34 -83
  5. package/dist/cli-chunks/{create-B-KOcThY.cjs → create-BybyVKxB.cjs} +1 -1
  6. package/dist/cli-chunks/{deploy-lock-DY7E8TFw.cjs → deploy-lock-CtJXBtKK.cjs} +1 -1
  7. package/dist/cli-chunks/{dev-BC_oKKzT.cjs → dev-BVZ9yV84.cjs} +15469 -15357
  8. package/dist/cli-chunks/{context-DZldyzoT.cjs → dev-context-BjwOy-fF.cjs} +299 -299
  9. package/dist/cli-chunks/{doctor-l9Gd1Rhf.cjs → doctor-CTEun30u.cjs} +1 -1
  10. package/dist/cli-chunks/{games-DDoaQ_KF.cjs → games-Bp6gkkgb.cjs} +2 -2
  11. package/dist/cli-chunks/{index-Czupnh5A.cjs → index-CxelQqdy.cjs} +17 -17
  12. package/dist/cli-chunks/{index-COzyQErL.cjs → index-DF8KQKoa.cjs} +1 -1
  13. package/dist/cli-chunks/{index.esm-BX-KdUxn.cjs → index.esm-vr3yuZ2Q.cjs} +6 -6
  14. package/dist/cli-chunks/{login-Dy-um6Ka.cjs → login-BPyX2p9v.cjs} +1 -1
  15. package/dist/cli-chunks/{project-vite-CTWRejM4.cjs → project-vite-DBId94T0.cjs} +1 -1
  16. package/dist/cli-chunks/{remote-BKIgszJS.cjs → remote-C1n11VWk.cjs} +66 -144
  17. package/dist/cli-chunks/{runtime-permission-env-DFFgIfoX.cjs → runtime-permission-env-Beurz19O.cjs} +127 -128
  18. package/dist/cli-chunks/{skill-WQPin-5N.cjs → skill-C33zgdJF.cjs} +2 -2
  19. package/dist/cli-chunks/{version-BQVBVZPA.cjs → version-BKjLEHsb.cjs} +1 -1
  20. package/dist/cli.cjs +1 -1
  21. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-j00ZN_C-.js → browser-dev-host-DedSMBMn.js} +15 -15
  22. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-BTmNqUZA.js → desktop-app-launch-BBIYbjgT.js} +1 -1
  23. package/dist/devtools/browser-dev-host/assets/{index-D3cBjlwQ.js → index-CnC7wDP_.js} +3 -3
  24. package/dist/devtools/browser-dev-host/index.html +2 -2
  25. package/dist/index.cjs.js +1 -1
  26. package/dist/index.esm.js +1 -1
  27. package/dist/vite.cjs.js +79 -13
  28. package/dist/vite.esm.js +79 -13
  29. package/package.json +6 -6
  30. package/skill/skill.json +4 -4
  31. package/types/vite/index.d.ts +35 -7
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  本文件随 `@heybox/hb-sdk` npm 包公开分发,只记录外部小程序开发者可观察到的变化。
4
4
 
5
+ ## 0.9.4-alpha.2 - 2026-10-26
6
+
7
+ ### 必须操作
8
+
9
+ - 使用 `esbuild: false` 的生产配置需要移除该设置,保留[生产构建](https://docs.xiaoheihe.cn/hb_sdk/guide/cli#%E7%94%9F%E4%BA%A7%E6%9E%84%E5%BB%BA)的语法转换;已有小程序需升级 SDK 后重新构建、提交并发布,已上线旧包不会自动更新。
10
+
11
+ ### 行为调整
12
+
13
+ - [miniappManifest()](https://docs.xiaoheihe.cn/hb_sdk/reference/symbols/vite/functions/miniappManifest.html) 的生产构建保留 Chrome 64 / Safari 12 语法目标,项目更保守的目标继续生效;原样复制或远端加载的脚本、运行时 API polyfill 不在转换范围内。
14
+
15
+ ### 问题修复
16
+
17
+ - 修复部分旧 WebView 因构建产物包含现代 JavaScript 语法而无法初始化小程序的问题。
18
+
19
+ ## 0.9.4-alpha.1 - 2026-10-26
20
+
21
+ ### 行为调整
22
+
23
+ - [hb-sdk build](https://docs.xiaoheihe.cn/hb_sdk/guide/cli.html#%E7%94%9F%E4%BA%A7%E6%9E%84%E5%BB%BA) 与 [hb-sdk remote deploy](https://docs.xiaoheihe.cn/hb_sdk/guide/cli.html#%E9%83%A8%E7%BD%B2%E5%8F%91%E5%B8%83) 统一拒绝含真实反斜杠的文件名、空 `node_modules` 目录及符号链接;请调整产物内容后重新构建。
24
+
5
25
  ## 0.9.4-alpha.0 - 2026-10-26
6
26
 
7
27
  ### 问题修复
package/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  SDK 只提供面向小程序开发者的稳定接口,不提供客户端内部协议、登录凭据或私有实现入口。本地浏览器调试请使用 `hb-sdk dev` 提供的 Mock 环境,发布前仍需在小黑盒 APP 中完成真机验收。
8
8
 
9
+ 生产构建的 [`miniappManifest()`](https://docs.xiaoheihe.cn/hb_sdk/reference/symbols/vite/functions/miniappManifest.html) 将 Vite 编译脚本的 JavaScript 语法目标约束为 Chrome 64 / Safari 12,避免现代默认目标把 `??=` 等语法带入旧 WebView。项目更保守的目标会保留,`esnext`、更高版本目标和环境级配置不能抬高该下限;生产构建不允许 `esbuild: false`。原样复制或远端加载的脚本不在转换范围内,也不包含运行时 API polyfill,不能据此认定全部业务依赖已适配旧设备;已有项目需升级到包含该修复的 SDK,重新构建、提交并发布后才会更新线上产物。
10
+
9
11
  宿主集成边界:`@heybox/hb-sdk-runtime` 运行在 iframe 外并负责 bridge/Host Port;跨 iframe 的 wire contract 唯一维护在零依赖 `@heybox/hb-sdk-protocol`。业务页面不需要创建 Runtime、实现 Host Port 或导入协议包;客户端 SDK 只依赖已兼容 re-export 的 `@heybox/hb-sdk/protocol`。
10
12
 
11
13
  ## 快速开始
@@ -1,18 +1,82 @@
1
1
  'use strict';
2
2
 
3
+ var fs = require('node:fs');
4
+ var fs$1 = require('node:fs/promises');
5
+ var path = require('node:path');
6
+ var runtimePermissionEnv = require('./runtime-permission-env-Beurz19O.cjs');
7
+ require('./version-BKjLEHsb.cjs');
8
+ var index = require('./index-CxelQqdy.cjs');
3
9
  var node_crypto = require('node:crypto');
10
+ require('node:zlib');
4
11
  require('node:module');
5
12
  require('node:url');
6
- var fs = require('node:fs');
7
- var path = require('node:path');
8
- var runtimePermissionEnv = require('./runtime-permission-env-DFFgIfoX.cjs');
9
- var index = require('./index-Czupnh5A.cjs');
10
13
  var _commonjsDynamicModules = require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
11
14
  var require$$0$1 = require('fs');
12
15
  var require$$1 = require('path');
13
16
  var require$$0 = require('os');
14
17
  var require$$6 = require('inspector');
15
18
 
19
+ // Shorthands
20
+ /**
21
+ * Parses an HTML string.
22
+ *
23
+ * @param html Input HTML string.
24
+ * @param options Parsing options.
25
+ * @returns Document
26
+ *
27
+ * @example
28
+ *
29
+ * ```js
30
+ * const parse5 = require('parse5');
31
+ *
32
+ * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
33
+ *
34
+ * console.log(document.childNodes[1].tagName); //> 'html'
35
+ *```
36
+ */
37
+ function parse(html, options) {
38
+ return runtimePermissionEnv.Parser.parse(html, options);
39
+ }
40
+
41
+ const RUNTIME_GATE_MARKER = 'data-heybox-runtime-gate';
42
+ const RUNTIME_GATE_STYLE_MARKER = 'data-heybox-runtime-gate-style';
43
+ const RUNTIME_GATE_BOOTSTRAP_MARKER = 'data-heybox-runtime-gate-bootstrap';
44
+ /**
45
+ * 检查 HTML 是否包含 Runtime Gate 的三个结构标记。
46
+ *
47
+ * @param html - 待检查的完整 HTML 文本,使用 HTML parser 解析。
48
+ * @returns Gate、隐藏样式及 bootstrap 标记均出现时返回 `true`,否则返回 `false`。
49
+ * @remarks 只识别标记,不验证脚本内容、标记所在节点或宿主握手;不能据此判断页面安全或实际可运行。
50
+ * @since 0.8.2
51
+ */
52
+ function hasMiniappRuntimeGate(html) {
53
+ const document = parse(html);
54
+ let hasGate = false;
55
+ let hasGateStyle = false;
56
+ let hasGateBootstrap = false;
57
+ walk(document, (element) => {
58
+ hasGate ||= hasAttr(element, RUNTIME_GATE_MARKER);
59
+ hasGateStyle ||= hasAttr(element, RUNTIME_GATE_STYLE_MARKER);
60
+ hasGateBootstrap ||= hasAttr(element, RUNTIME_GATE_BOOTSTRAP_MARKER);
61
+ });
62
+ return hasGate && hasGateStyle && hasGateBootstrap;
63
+ }
64
+ function readAttr(element, name) {
65
+ return element.attrs.find((attr) => attr.name.toLowerCase() === name)?.value;
66
+ }
67
+ function hasAttr(element, name) {
68
+ return readAttr(element, name) !== undefined;
69
+ }
70
+ function walk(node, visit) {
71
+ if ('tagName' in node)
72
+ visit(node);
73
+ if ('childNodes' in node)
74
+ for (const child of node.childNodes)
75
+ walk(child, visit);
76
+ if ('content' in node && node.content)
77
+ walk(node.content, visit);
78
+ }
79
+
16
80
  var typescript = {exports: {}};
17
81
 
18
82
  var sourceMapSupport = {exports: {}};
@@ -201881,67 +201945,74 @@ function verifyWorkspaceCardArtifacts(root, manifest) {
201881
201945
  }
201882
201946
  }
201883
201947
 
201884
- // Shorthands
201885
- /**
201886
- * Parses an HTML string.
201887
- *
201888
- * @param html Input HTML string.
201889
- * @param options Parsing options.
201890
- * @returns Document
201891
- *
201892
- * @example
201893
- *
201894
- * ```js
201895
- * const parse5 = require('parse5');
201896
- *
201897
- * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
201898
- *
201899
- * console.log(document.childNodes[1].tagName); //> 'html'
201900
- *```
201901
- */
201902
- function parse(html, options) {
201903
- return runtimePermissionEnv.Parser.parse(html, options);
201904
- }
201905
-
201906
- const RUNTIME_GATE_MARKER = 'data-heybox-runtime-gate';
201907
- const RUNTIME_GATE_STYLE_MARKER = 'data-heybox-runtime-gate-style';
201908
- const RUNTIME_GATE_BOOTSTRAP_MARKER = 'data-heybox-runtime-gate-bootstrap';
201909
- /**
201910
- * 检查 HTML 是否包含 Runtime Gate 的三个结构标记。
201911
- *
201912
- * @param html - 待检查的完整 HTML 文本,使用 HTML parser 解析。
201913
- * @returns Gate、隐藏样式及 bootstrap 标记均出现时返回 `true`,否则返回 `false`。
201914
- * @remarks 只识别标记,不验证脚本内容、标记所在节点或宿主握手;不能据此判断页面安全或实际可运行。
201915
- * @since 0.8.2
201916
- */
201917
- function hasMiniappRuntimeGate(html) {
201918
- const document = parse(html);
201919
- let hasGate = false;
201920
- let hasGateStyle = false;
201921
- let hasGateBootstrap = false;
201922
- walk(document, (element) => {
201923
- hasGate ||= hasAttr(element, RUNTIME_GATE_MARKER);
201924
- hasGateStyle ||= hasAttr(element, RUNTIME_GATE_STYLE_MARKER);
201925
- hasGateBootstrap ||= hasAttr(element, RUNTIME_GATE_BOOTSTRAP_MARKER);
201926
- });
201927
- return hasGate && hasGateStyle && hasGateBootstrap;
201928
- }
201929
- function readAttr(element, name) {
201930
- return element.attrs.find((attr) => attr.name.toLowerCase() === name)?.value;
201931
- }
201932
- function hasAttr(element, name) {
201933
- return readAttr(element, name) !== undefined;
201948
+ /** 仅描述读取时刻的产物;文件没有加锁,发布仍须生成并复核 receipt。 */
201949
+ async function inspectVersionArtifact(input) {
201950
+ const distDir = path.join(input.projectRoot, 'dist');
201951
+ const entryHtmlPath = path.join(distDir, 'index.html');
201952
+ const manifestPath = path.join(distDir, 'manifest.json');
201953
+ if (!fs.existsSync(manifestPath))
201954
+ throw new Error('未找到 dist/manifest.json,请在 Vite 配置中显式启用 miniappManifest()');
201955
+ if (!fs.existsSync(entryHtmlPath))
201956
+ throw new Error('未找到 dist/index.html,Vite 构建产物不完整');
201957
+ if (!hasMiniappRuntimeGate(await fs$1.readFile(entryHtmlPath, 'utf8'))) {
201958
+ throw new Error('dist/index.html 缺少平台 Runtime 启动门禁,请在 Vite 配置中显式启用 miniappManifest()');
201959
+ }
201960
+ const { manifest, hadBom } = runtimePermissionEnv.parseMiniappManifestJson(await fs$1.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
201961
+ const validated = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
201962
+ const bindAppIds = validated.bindAppIds ?? [];
201963
+ if (validated.workspaceCards) {
201964
+ verifyWorkspaceCardsSnapshot({ ...validated, bindAppIds, workspaceCards: validated.workspaceCards });
201965
+ verifyWorkspaceCardArtifacts(distDir, validated.workspaceCards);
201966
+ }
201967
+ const declared = input.declarations;
201968
+ if (validated.category !== declared.category) {
201969
+ throw new Error('dist/manifest.json.category 与 package.json#heybox.category 不一致,请重新 build');
201970
+ }
201971
+ if (!runtimePermissionEnv.areMiniappPlatformsEqual(validated.platforms, declared.platforms)) {
201972
+ throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build');
201973
+ }
201974
+ if (!runtimePermissionEnv.areMiniappWindowsEqual(validated.window, declared.window)) {
201975
+ throw new Error('dist/manifest.json.window 与 package.json#heybox.window 不一致,请重新 build');
201976
+ }
201977
+ if (bindAppIds.length !== declared.bindAppIds.length || bindAppIds.some((value, index) => value !== declared.bindAppIds[index])) {
201978
+ throw new Error('dist/manifest.json.bindAppIds 与 package.json#heybox.bindAppIds 不一致,请重新 build');
201979
+ }
201980
+ return {
201981
+ distDir,
201982
+ hadBom,
201983
+ // 上送仍保留原始未知字段,只归一原有 deploy 已处理的字段。
201984
+ manifest: { ...manifest, platforms: validated.platforms, ...(bindAppIds.length === 0 ? {} : { bindAppIds }) },
201985
+ summary: { ...validated, bindAppIds },
201986
+ };
201934
201987
  }
201935
- function walk(node, visit) {
201936
- if ('tagName' in node)
201937
- visit(node);
201938
- if ('childNodes' in node)
201939
- for (const child of node.childNodes)
201940
- walk(child, visit);
201941
- if ('content' in node && node.content)
201942
- walk(node.content, visit);
201988
+ /** 扫描不依赖元数据对象,不能把先前校验误当作文件持续不变的凭证。 */
201989
+ async function inspectVersionArtifactFiles(distDir) {
201990
+ const files = [];
201991
+ await walk(distDir, '');
201992
+ const uploadFiles = runtimePermissionEnv.prepareMiniappArtifactFiles(files.filter((file) => runtimePermissionEnv.shouldUploadDistFile(file.relativePath)));
201993
+ const sizeError = runtimePermissionEnv.validateMiniappUploadSizeBudgets(uploadFiles);
201994
+ if (sizeError)
201995
+ throw new Error(sizeError);
201996
+ return { files: uploadFiles, fileCount: uploadFiles.length, totalBytes: uploadFiles.reduce((total, file) => total + file.size, 0) };
201997
+ async function walk(directory, prefix) {
201998
+ for (const entry of await fs$1.readdir(directory, { withFileTypes: true })) {
201999
+ const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
202000
+ const absolutePath = path.join(directory, entry.name);
202001
+ const info = await fs$1.lstat(absolutePath);
202002
+ if (info.isSymbolicLink())
202003
+ throw new Error(`dist 目录包含 symlink,拒绝处理:${relativePath}`);
202004
+ if (relativePath.includes('\\'))
202005
+ throw new Error(`构建产物路径不能包含反斜杠:${relativePath}`);
202006
+ // 在进入目录前检查,因此空的禁用目录同样拒绝。
202007
+ if (runtimePermissionEnv.relativePathContainsNodeModulesSegment(relativePath))
202008
+ throw new Error(`dist 目录含 node_modules:${relativePath}`);
202009
+ if (info.isDirectory())
202010
+ await walk(absolutePath, relativePath);
202011
+ else if (info.isFile())
202012
+ files.push({ relativePath, absolutePath, size: info.size });
202013
+ }
202014
+ }
201943
202015
  }
201944
202016
 
201945
- exports.hasMiniappRuntimeGate = hasMiniappRuntimeGate;
201946
- exports.verifyWorkspaceCardArtifacts = verifyWorkspaceCardArtifacts;
201947
- exports.verifyWorkspaceCardsSnapshot = verifyWorkspaceCardsSnapshot;
202017
+ exports.inspectVersionArtifact = inspectVersionArtifact;
202018
+ exports.inspectVersionArtifactFiles = inspectVersionArtifactFiles;
@@ -1,35 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var runtimeGate = require('./runtime-gate-alLUP4_C.cjs');
4
- var fs$1 = require('node:fs');
5
3
  var fs = require('node:fs/promises');
6
4
  var path = require('node:path');
7
- var runtimePermissionEnv = require('./runtime-permission-env-DFFgIfoX.cjs');
8
- var index = require('./index-Czupnh5A.cjs');
5
+ var runtimePermissionEnv = require('./runtime-permission-env-Beurz19O.cjs');
6
+ var index = require('./index-CxelQqdy.cjs');
9
7
  require('node:crypto');
8
+ require('node:fs');
10
9
  require('node:zlib');
11
- var projectVite = require('./project-vite-CTWRejM4.cjs');
12
- require('node:module');
13
- require('node:url');
14
- require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
15
- require('fs');
16
- require('path');
17
- require('os');
18
- require('inspector');
19
- require('./version-BQVBVZPA.cjs');
10
+ var artifact = require('./artifact-BTi9i7N4.cjs');
11
+ var projectVite = require('./project-vite-DBId94T0.cjs');
12
+ require('./version-BKjLEHsb.cjs');
20
13
  require('node:async_hooks');
14
+ require('node:module');
21
15
  require('readline');
16
+ require('os');
22
17
  require('tty');
23
18
  require('assert');
24
19
  require('events');
25
20
  require('stream');
26
21
  require('buffer');
27
22
  require('util');
23
+ require('path');
24
+ require('fs');
28
25
  require('constants');
26
+ require('node:url');
27
+ require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
28
+ require('inspector');
29
29
 
30
- function areStringArraysEqual(left, right) {
31
- return left.length === right.length && left.every((value, index) => value === right[index]);
32
- }
33
30
  async function runBuildCommand(_options = {}, runtime = {}) {
34
31
  const logger = runtime.logger ?? index.createCliLogger();
35
32
  const projectRoot = projectVite.findProjectRoot(runtime.cwd ?? process.cwd());
@@ -89,84 +86,38 @@ function createFixedBuildOutputPlugin(projectRoot) {
89
86
  };
90
87
  }
91
88
  async function validateBuildOutput(projectRoot, logger, declaredPlatforms, declaredWindow, declaredBindAppIds, declaredCategory) {
92
- const distDir = path.join(projectRoot, 'dist');
93
- const entryHtmlPath = path.join(distDir, 'index.html');
94
- const manifestPath = path.join(distDir, 'manifest.json');
95
- if (!fs$1.existsSync(entryHtmlPath)) {
96
- throw new Error('未找到 dist/index.html,Vite 构建产物不完整');
97
- }
98
- if (!fs$1.existsSync(manifestPath)) {
99
- throw new Error('未找到 dist/manifest.json,请在 Vite 配置中显式启用 miniappManifest()');
100
- }
101
- const entryHtml = await fs.readFile(entryHtmlPath, 'utf8');
102
- if (!runtimeGate.hasMiniappRuntimeGate(entryHtml)) {
103
- throw new Error('dist/index.html 缺少平台 Runtime 启动门禁,请在 Vite 配置中显式启用 miniappManifest()');
104
- }
105
- const { manifest, hadBom } = runtimePermissionEnv.parseMiniappManifestJson(await fs.readFile(manifestPath, 'utf8'), 'dist/manifest.json');
106
- if (hadBom) {
89
+ const artifact$1 = await artifact.inspectVersionArtifact({
90
+ projectRoot,
91
+ declarations: {
92
+ platforms: declaredPlatforms,
93
+ window: declaredWindow,
94
+ bindAppIds: declaredBindAppIds,
95
+ category: declaredCategory,
96
+ },
97
+ });
98
+ if (artifact$1.hadBom)
107
99
  logger.warn('dist/manifest.json 包含 BOM,已自动剥离');
100
+ let inventory;
101
+ try {
102
+ inventory = await artifact.inspectVersionArtifactFiles(artifact$1.distDir);
108
103
  }
109
- const validated = runtimePermissionEnv.validateMiniappManifestForDeploy(manifest);
110
- if (validated.workspaceCards) {
111
- runtimeGate.verifyWorkspaceCardsSnapshot({ ...validated, bindAppIds: validated.bindAppIds ?? [], workspaceCards: validated.workspaceCards });
112
- runtimeGate.verifyWorkspaceCardArtifacts(distDir, validated.workspaceCards);
113
- }
114
- const { platforms, sdkVersion, version, permissions, window } = validated;
115
- const bindAppIds = validated.bindAppIds ?? [];
116
- if (validated.category !== declaredCategory) {
117
- throw new Error('dist/manifest.json.category 与 package.json#heybox.category 不一致,请重新 build');
118
- }
119
- if (!runtimePermissionEnv.areMiniappPlatformsEqual(platforms, declaredPlatforms)) {
120
- throw new Error('dist/manifest.json.platforms 与 package.json#heybox.platforms 不一致,请重新 build');
121
- }
122
- if (!runtimePermissionEnv.areMiniappWindowsEqual(window, declaredWindow)) {
123
- throw new Error('dist/manifest.json.window 与 package.json#heybox.window 不一致,请重新 build');
124
- }
125
- if (!areStringArraysEqual(bindAppIds, declaredBindAppIds)) {
126
- throw new Error('dist/manifest.json.bindAppIds 与 package.json#heybox.bindAppIds 不一致,请重新 build');
127
- }
128
- const allFiles = await walkDistFiles(distDir);
129
- const uploadFiles = allFiles.filter((file) => runtimePermissionEnv.shouldUploadDistFile(file.relativePath));
130
- const sizeError = runtimePermissionEnv.validateMiniappUploadSizeBudgets(uploadFiles);
131
- if (sizeError) {
132
- throw new Error(sizeError.replace('重新 deploy', '重新 build'));
104
+ catch (error) {
105
+ if (error instanceof Error)
106
+ error.message = error.message.replace('重新 deploy', '重新 build');
107
+ throw error;
133
108
  }
109
+ const { platforms, sdkVersion, version, permissions, bindAppIds } = artifact$1.summary;
134
110
  return {
135
- distDir,
111
+ distDir: artifact$1.distDir,
136
112
  bindAppIds,
137
- fileCount: uploadFiles.length,
113
+ fileCount: inventory.fileCount,
138
114
  sdkVersion,
139
115
  platforms,
140
116
  ...(permissions === undefined ? {} : { permissions }),
141
- totalBytes: uploadFiles.reduce((total, file) => total + file.size, 0),
117
+ totalBytes: inventory.totalBytes,
142
118
  version,
143
119
  };
144
120
  }
145
- async function walkDistFiles(distDir) {
146
- const results = [];
147
- await walk(distDir, '');
148
- return results;
149
- async function walk(absDir, relDir) {
150
- const entries = await fs.readdir(absDir, { withFileTypes: true });
151
- for (const entry of entries) {
152
- const absPath = path.join(absDir, entry.name);
153
- const relPath = runtimePermissionEnv.normalizeRelativePath(relDir ? `${relDir}/${entry.name}` : entry.name);
154
- const link = await fs.lstat(absPath);
155
- if (link.isSymbolicLink()) {
156
- throw new Error(`dist 目录包含 symlink,拒绝处理:${relPath}`);
157
- }
158
- if (runtimePermissionEnv.relativePathContainsNodeModulesSegment(relPath)) {
159
- throw new Error(`dist 目录含 node_modules:${relPath}`);
160
- }
161
- if (entry.isDirectory()) {
162
- await walk(absPath, relPath);
163
- }
164
- else if (entry.isFile()) {
165
- results.push({ relativePath: relPath, size: (await fs.stat(absPath)).size });
166
- }
167
- }
168
- }
169
- }
170
121
  function formatSize(bytes) {
171
122
  if (bytes < 1024)
172
123
  return `${bytes} B`;
@@ -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-Czupnh5A.cjs');
8
+ var index = require('./index-CxelQqdy.cjs');
9
9
  require('node:module');
10
10
  require('readline');
11
11
  require('os');
@@ -3,7 +3,7 @@
3
3
  var node_crypto = require('node:crypto');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
- var index = require('./index-Czupnh5A.cjs');
6
+ var index = require('./index-CxelQqdy.cjs');
7
7
 
8
8
  const DEPLOY_LOCKED_MESSAGE = '当前设备已有同版本产物正在上传,请等待完成后重试';
9
9
  const DEPLOY_LOCK_DIRECTORY_NAME = 'deploy-locks';