@heybox/hb-sdk 0.6.7-alpha.2 → 0.6.8-alpha.0
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 +226 -0
- package/README.md +65 -583
- package/dist/cli-chunks/{build-CQmYxfxm.cjs → build-BfhZ07Qv.cjs} +4 -4
- package/dist/cli-chunks/{context-ChkYWwH_.cjs → context-CqoGNt7d.cjs} +2 -2
- package/dist/cli-chunks/{create-CC5r_8bL.cjs → create-us7swTbU.cjs} +1 -1
- package/dist/cli-chunks/{dev-CD-38TgO.cjs → dev-Bf49EoR8.cjs} +6 -6
- package/dist/cli-chunks/{doctor-43yEfVr0.cjs → doctor-CzETlRvH.cjs} +21 -3
- package/dist/cli-chunks/{index-CQnkS0Z8.cjs → index-BMhV2-vd.cjs} +14 -14
- package/dist/cli-chunks/{index-BM6oH2Hs.cjs → index-Cd37cCQM.cjs} +2 -2
- package/dist/cli-chunks/{index-BQm5XmMC.cjs → index-v4-6fbXX.cjs} +29 -2
- package/dist/cli-chunks/{login-BmisXAdp.cjs → login-Cb5ShNVQ.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-D9_v57vp.cjs → project-vite-WP6NzC3p.cjs} +1 -1
- package/dist/cli-chunks/{remote-BXtT6M2f.cjs → remote-Co84uKvV.cjs} +28 -8
- package/dist/cli-chunks/{runtime-gate-B2MQf1vc.cjs → runtime-gate-DfMJQGH9.cjs} +1 -1
- package/dist/cli-chunks/{session-BjtjhtPg.cjs → session-9A8AY7YK.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +29 -2
- package/dist/miniapp-publish.esm.js +29 -2
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.esm.js +1 -1
- package/package.json +3 -1
- package/skill/references/api-protocol.md +0 -10
- package/skill/references/api-root.md +153 -353
- package/skill/references/safety-boundaries.md +6 -9
- package/skill/scripts/sync-references.mjs +10 -20
- package/skill/skill.json +4 -4
|
@@ -3,10 +3,10 @@
|
|
|
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 index$1 = require('./index-
|
|
7
|
-
var runtimeGate = require('./runtime-gate-
|
|
8
|
-
var index = require('./index-
|
|
9
|
-
var projectVite = require('./project-vite-
|
|
6
|
+
var index$1 = require('./index-v4-6fbXX.cjs');
|
|
7
|
+
var runtimeGate = require('./runtime-gate-DfMJQGH9.cjs');
|
|
8
|
+
var index = require('./index-BMhV2-vd.cjs');
|
|
9
|
+
var projectVite = require('./project-vite-WP6NzC3p.cjs');
|
|
10
10
|
require('node:module');
|
|
11
11
|
require('path');
|
|
12
12
|
require('os');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var session = require('./session-
|
|
4
|
-
var index = require('./index-
|
|
3
|
+
var session = require('./session-9A8AY7YK.cjs');
|
|
4
|
+
var index = require('./index-v4-6fbXX.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-BMhV2-vd.cjs');
|
|
9
9
|
require('node:module');
|
|
10
10
|
require('os');
|
|
11
11
|
require('readline');
|
|
@@ -9,9 +9,9 @@ var node_http = require('node:http');
|
|
|
9
9
|
var node_crypto = require('node:crypto');
|
|
10
10
|
var undici = require('undici');
|
|
11
11
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
12
|
-
var index = require('./index-
|
|
13
|
-
var projectVite = require('./project-vite-
|
|
14
|
-
var context = require('./context-
|
|
12
|
+
var index = require('./index-BMhV2-vd.cjs');
|
|
13
|
+
var projectVite = require('./project-vite-WP6NzC3p.cjs');
|
|
14
|
+
var context = require('./context-CqoGNt7d.cjs');
|
|
15
15
|
var fs$1 = require('node:fs/promises');
|
|
16
16
|
require('node:process');
|
|
17
17
|
require('node:buffer');
|
|
@@ -28,10 +28,10 @@ require('events');
|
|
|
28
28
|
require('stream');
|
|
29
29
|
require('buffer');
|
|
30
30
|
require('util');
|
|
31
|
-
require('./session-
|
|
31
|
+
require('./session-9A8AY7YK.cjs');
|
|
32
32
|
require('fs');
|
|
33
33
|
require('constants');
|
|
34
|
-
require('./index-
|
|
34
|
+
require('./index-v4-6fbXX.cjs');
|
|
35
35
|
|
|
36
36
|
class Locked extends Error {
|
|
37
37
|
constructor(port) {
|
|
@@ -1259,7 +1259,7 @@ function cloneDefaultPermissionState() {
|
|
|
1259
1259
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
1260
1260
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
1261
1261
|
? undefined
|
|
1262
|
-
: '0.6.
|
|
1262
|
+
: '0.6.8-alpha.0';
|
|
1263
1263
|
|
|
1264
1264
|
class DevPermissionOverrideStoreError extends Error {
|
|
1265
1265
|
code;
|
|
@@ -4,7 +4,7 @@ var fs$1 = require('node:fs');
|
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var os = require('node:os');
|
|
6
6
|
var path = require('node:path');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-BMhV2-vd.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('path');
|
|
10
10
|
require('os');
|
|
@@ -33,7 +33,7 @@ async function runDoctorCommand(runtime = {}) {
|
|
|
33
33
|
}
|
|
34
34
|
async function getDoctorResult(runtime = {}) {
|
|
35
35
|
const currentSdkVersion = await readCurrentSdkVersion(runtime.packageJsonFiles);
|
|
36
|
-
const localSkillJsonPath = resolveLocalSkillJsonPath(runtime);
|
|
36
|
+
const localSkillJsonPath = await resolveLocalSkillJsonPath(runtime);
|
|
37
37
|
let remoteSkill;
|
|
38
38
|
try {
|
|
39
39
|
remoteSkill = await fetchRemoteSkill(runtime);
|
|
@@ -165,13 +165,31 @@ async function readCurrentSdkVersion(packageJsonCandidates = PACKAGE_JSON_CANDID
|
|
|
165
165
|
}
|
|
166
166
|
throw new Error('未能读取 @heybox/hb-sdk 当前版本号');
|
|
167
167
|
}
|
|
168
|
-
function resolveLocalSkillJsonPath(runtime) {
|
|
168
|
+
async function resolveLocalSkillJsonPath(runtime) {
|
|
169
169
|
if (runtime.localSkillJsonPath) {
|
|
170
170
|
return runtime.localSkillJsonPath;
|
|
171
171
|
}
|
|
172
|
+
const projectSkillJsonPath = await findProjectSkillJsonPath(runtime.cwd ?? process.cwd());
|
|
173
|
+
if (projectSkillJsonPath) {
|
|
174
|
+
return projectSkillJsonPath;
|
|
175
|
+
}
|
|
172
176
|
const codexHome = runtime.codexHome ?? runtime.env?.CODEX_HOME ?? process.env.CODEX_HOME ?? path.join(os.homedir(), '.codex');
|
|
173
177
|
return path.join(codexHome, 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
|
|
174
178
|
}
|
|
179
|
+
async function findProjectSkillJsonPath(startDir) {
|
|
180
|
+
let current = path.resolve(startDir);
|
|
181
|
+
while (true) {
|
|
182
|
+
const skillJsonPath = path.join(current, '.agents', 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
|
|
183
|
+
if ((await pathExists(path.join(current, 'package.json'))) && (await pathExists(skillJsonPath))) {
|
|
184
|
+
return skillJsonPath;
|
|
185
|
+
}
|
|
186
|
+
const parent = path.dirname(current);
|
|
187
|
+
if (parent === current) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
current = parent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
175
193
|
async function pathExists(filePath) {
|
|
176
194
|
try {
|
|
177
195
|
await fs.access(filePath, fs$1.constants.F_OK);
|
|
@@ -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-BMhV2-vd.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-BMhV2-vd.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-BMhV2-vd.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-BMhV2-vd.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-BMhV2-vd.cjs', document.baseURI).href)));
|
|
250
250
|
function __require() { return require$1("node:process"); }
|
|
251
251
|
|
|
252
252
|
var help = {};
|
|
@@ -13347,7 +13347,7 @@ function getPathname(pathWithQuery) {
|
|
|
13347
13347
|
}
|
|
13348
13348
|
|
|
13349
13349
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
13350
|
-
const BUILT_CLI_VERSION = '0.6.
|
|
13350
|
+
const BUILT_CLI_VERSION = '0.6.8-alpha.0';
|
|
13351
13351
|
const PACKAGE_JSON_CANDIDATES = [
|
|
13352
13352
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
13353
13353
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -13680,35 +13680,35 @@ function createCommandLoggerResolver(options) {
|
|
|
13680
13680
|
};
|
|
13681
13681
|
}
|
|
13682
13682
|
const defaultClearLoginStatus = async (...args) => {
|
|
13683
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13683
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-Cb5ShNVQ.cjs'); });
|
|
13684
13684
|
return clearLoginStatus(...args);
|
|
13685
13685
|
};
|
|
13686
13686
|
const defaultLoginToHeybox = async (...args) => {
|
|
13687
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
13687
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-Cb5ShNVQ.cjs'); });
|
|
13688
13688
|
return loginToHeybox(...args);
|
|
13689
13689
|
};
|
|
13690
13690
|
const defaultPrintLoginStatus = async (...args) => {
|
|
13691
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13691
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-Cb5ShNVQ.cjs'); });
|
|
13692
13692
|
return printLoginStatus(...args);
|
|
13693
13693
|
};
|
|
13694
13694
|
const defaultRunBuildCommand = async (...args) => {
|
|
13695
|
-
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-
|
|
13695
|
+
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-BfhZ07Qv.cjs'); });
|
|
13696
13696
|
return runBuildCommand(...args);
|
|
13697
13697
|
};
|
|
13698
13698
|
const defaultRunCreateCommand = async (...args) => {
|
|
13699
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
13699
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-us7swTbU.cjs'); });
|
|
13700
13700
|
return runCreateCommand(...args);
|
|
13701
13701
|
};
|
|
13702
13702
|
const defaultRunDevCommand = async (...args) => {
|
|
13703
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
13703
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-Bf49EoR8.cjs'); });
|
|
13704
13704
|
return runDevCommand(...args);
|
|
13705
13705
|
};
|
|
13706
13706
|
const defaultRunDoctorCommand = async (...args) => {
|
|
13707
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
13707
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-CzETlRvH.cjs'); });
|
|
13708
13708
|
return runDoctorCommand(...args);
|
|
13709
13709
|
};
|
|
13710
13710
|
const defaultRunRemoteCommand = async (...args) => {
|
|
13711
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
13711
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-Co84uKvV.cjs'); });
|
|
13712
13712
|
return runRemoteCommand(...args);
|
|
13713
13713
|
};
|
|
13714
13714
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$2 = require('./index-
|
|
3
|
+
var index$2 = require('./index-BMhV2-vd.cjs');
|
|
4
4
|
var require$$0$2 = require('fs');
|
|
5
5
|
var require$$2$1 = require('crypto');
|
|
6
6
|
var require$$1$2 = require('path');
|
|
7
7
|
var require$$0$3 = require('assert');
|
|
8
8
|
var require$$4$2 = require('events');
|
|
9
9
|
var require$$1$1 = require('util');
|
|
10
|
-
var index$3 = require('./index-
|
|
10
|
+
var index$3 = require('./index-v4-6fbXX.cjs');
|
|
11
11
|
var require$$0$5 = require('net');
|
|
12
12
|
var require$$0$4 = require('url');
|
|
13
13
|
var require$$2$2 = require('http');
|
|
@@ -2839,18 +2839,45 @@ function getMiniappUploadKey(input) {
|
|
|
2839
2839
|
}
|
|
2840
2840
|
function validateUploadPaths(items, options) {
|
|
2841
2841
|
const limit = options.maxLength;
|
|
2842
|
+
const uploadKeys = new Set();
|
|
2842
2843
|
for (const item of items) {
|
|
2844
|
+
const relativePath = String(item.relativePath ?? '');
|
|
2845
|
+
const normalizedRelativePath = normalizeRelativePath(relativePath);
|
|
2846
|
+
const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
|
|
2847
|
+
if (invalidReason) {
|
|
2848
|
+
return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
|
|
2849
|
+
}
|
|
2843
2850
|
const key = getMiniappUploadKey({
|
|
2844
2851
|
miniProgramId: options.miniProgramId,
|
|
2845
2852
|
version: options.version,
|
|
2846
|
-
relativePath:
|
|
2853
|
+
relativePath: normalizedRelativePath,
|
|
2847
2854
|
});
|
|
2855
|
+
if (uploadKeys.has(key)) {
|
|
2856
|
+
return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
|
|
2857
|
+
}
|
|
2858
|
+
uploadKeys.add(key);
|
|
2848
2859
|
if (key.length > limit) {
|
|
2849
|
-
return `文件路径过长,请缩短构建产物文件名或目录层级:${
|
|
2860
|
+
return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
|
|
2850
2861
|
}
|
|
2851
2862
|
}
|
|
2852
2863
|
return undefined;
|
|
2853
2864
|
}
|
|
2865
|
+
function getInvalidUploadPathReason(relativePath) {
|
|
2866
|
+
const segments = relativePath.replace(/\\/g, '/').split('/');
|
|
2867
|
+
if (segments.some((segment) => !segment)) {
|
|
2868
|
+
return '包含空路径段';
|
|
2869
|
+
}
|
|
2870
|
+
if (segments.some((segment) => segment === '.')) {
|
|
2871
|
+
return '包含当前目录';
|
|
2872
|
+
}
|
|
2873
|
+
if (segments.some((segment) => segment === '..')) {
|
|
2874
|
+
return '包含上级目录';
|
|
2875
|
+
}
|
|
2876
|
+
if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
|
|
2877
|
+
return '包含控制字符';
|
|
2878
|
+
}
|
|
2879
|
+
return undefined;
|
|
2880
|
+
}
|
|
2854
2881
|
function validateUploadTotalSize(items, options = {}) {
|
|
2855
2882
|
const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
|
|
2856
2883
|
const total = items.reduce((sum, item) => {
|
|
@@ -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-9A8AY7YK.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-BMhV2-vd.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-BMhV2-vd.cjs');
|
|
9
9
|
|
|
10
10
|
function findProjectRoot(startDir) {
|
|
11
11
|
let current = path.resolve(startDir);
|
|
@@ -1,15 +1,15 @@
|
|
|
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-BMhV2-vd.cjs');
|
|
5
|
+
var session = require('./session-9A8AY7YK.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 index$1 = require('./index-
|
|
11
|
-
var runtimeGate = require('./runtime-gate-
|
|
12
|
-
var context = require('./context-
|
|
10
|
+
var index$1 = require('./index-v4-6fbXX.cjs');
|
|
11
|
+
var runtimeGate = require('./runtime-gate-DfMJQGH9.cjs');
|
|
12
|
+
var context = require('./context-CqoGNt7d.cjs');
|
|
13
13
|
require('node:module');
|
|
14
14
|
require('path');
|
|
15
15
|
require('os');
|
|
@@ -191,7 +191,7 @@ async function createDefaultCosClient(uploadToken) {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
async function loadCosConstructor() {
|
|
194
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
194
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-Cd37cCQM.cjs'); }).then(function (n) { return n.index; });
|
|
195
195
|
return cosModule.default;
|
|
196
196
|
}
|
|
197
197
|
function formatSize(bytes) {
|
|
@@ -342,12 +342,14 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
342
342
|
autoPublish,
|
|
343
343
|
}, runtime, apiBaseUrl, projectRoot, logger);
|
|
344
344
|
const pm = detectPackageManager(projectRoot);
|
|
345
|
-
const
|
|
345
|
+
const platform = runtime.platform ?? process.platform;
|
|
346
|
+
const buildMode = validateBuildMode(env.HB_SDK_ENV?.trim(), platform);
|
|
346
347
|
logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode).join(' ')}`);
|
|
347
348
|
await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
|
|
348
349
|
env,
|
|
349
350
|
mode: buildMode,
|
|
350
351
|
outputMode: options.buildOutputMode ?? 'inherit',
|
|
352
|
+
platform,
|
|
351
353
|
stderr: runtime.stderr,
|
|
352
354
|
});
|
|
353
355
|
logger.success('构建完成');
|
|
@@ -536,9 +538,14 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
|
|
|
536
538
|
await new Promise((resolve, reject) => {
|
|
537
539
|
const pipeStdoutToStderr = options.outputMode === 'stderr';
|
|
538
540
|
const buildArgs = createBuildArgs(pm, options.mode);
|
|
539
|
-
const
|
|
541
|
+
const isWindows = options.platform === 'win32';
|
|
542
|
+
const [executable, args] = isWindows
|
|
543
|
+
? createWindowsBuildCommand(pm, buildArgs)
|
|
544
|
+
: [pm, buildArgs];
|
|
545
|
+
const child = spawnImpl(executable, args, {
|
|
540
546
|
cwd,
|
|
541
547
|
env: { ...process.env, ...options.env },
|
|
548
|
+
...(isWindows ? { shell: false, windowsVerbatimArguments: true } : {}),
|
|
542
549
|
stdio: pipeStdoutToStderr ? ['inherit', 'pipe', 'inherit'] : 'inherit',
|
|
543
550
|
});
|
|
544
551
|
if (pipeStdoutToStderr) {
|
|
@@ -557,6 +564,19 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
|
|
|
557
564
|
});
|
|
558
565
|
});
|
|
559
566
|
}
|
|
567
|
+
function createWindowsBuildCommand(pm, buildArgs) {
|
|
568
|
+
const command = `${pm}.cmd ${buildArgs.map(escapeWindowsCommandArgument).join(' ')}`;
|
|
569
|
+
return ['cmd.exe', ['/d', '/s', '/c', `"${command}"`]];
|
|
570
|
+
}
|
|
571
|
+
function validateBuildMode(mode, platform) {
|
|
572
|
+
if (platform === 'win32' && mode && !/^[A-Za-z0-9._-]+$/.test(mode)) {
|
|
573
|
+
throw new Error('Windows 下 HB_SDK_ENV 仅支持字母、数字、点、下划线和连字符');
|
|
574
|
+
}
|
|
575
|
+
return mode;
|
|
576
|
+
}
|
|
577
|
+
function escapeWindowsCommandArgument(argument) {
|
|
578
|
+
return `"${argument}"`;
|
|
579
|
+
}
|
|
560
580
|
function createBuildArgs(pm, mode) {
|
|
561
581
|
return ['run', 'build', ...(mode ? [...(pm === 'npm' ? ['--'] : []), '--mode', mode] : [])];
|
|
562
582
|
}
|
package/dist/cli.cjs
CHANGED
package/dist/index.cjs.js
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -2863,18 +2863,45 @@ function getMiniappUploadKey(input) {
|
|
|
2863
2863
|
}
|
|
2864
2864
|
function validateUploadPaths(items, options) {
|
|
2865
2865
|
const limit = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
|
|
2866
|
+
const uploadKeys = new Set();
|
|
2866
2867
|
for (const item of items) {
|
|
2868
|
+
const relativePath = String(item.relativePath ?? '');
|
|
2869
|
+
const normalizedRelativePath = normalizeRelativePath(relativePath);
|
|
2870
|
+
const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
|
|
2871
|
+
if (invalidReason) {
|
|
2872
|
+
return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
|
|
2873
|
+
}
|
|
2867
2874
|
const key = getMiniappUploadKey({
|
|
2868
2875
|
miniProgramId: options.miniProgramId,
|
|
2869
2876
|
version: options.version,
|
|
2870
|
-
relativePath:
|
|
2877
|
+
relativePath: normalizedRelativePath,
|
|
2871
2878
|
});
|
|
2879
|
+
if (uploadKeys.has(key)) {
|
|
2880
|
+
return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
|
|
2881
|
+
}
|
|
2882
|
+
uploadKeys.add(key);
|
|
2872
2883
|
if (key.length > limit) {
|
|
2873
|
-
return `文件路径过长,请缩短构建产物文件名或目录层级:${
|
|
2884
|
+
return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
|
|
2874
2885
|
}
|
|
2875
2886
|
}
|
|
2876
2887
|
return undefined;
|
|
2877
2888
|
}
|
|
2889
|
+
function getInvalidUploadPathReason(relativePath) {
|
|
2890
|
+
const segments = relativePath.replace(/\\/g, '/').split('/');
|
|
2891
|
+
if (segments.some((segment) => !segment)) {
|
|
2892
|
+
return '包含空路径段';
|
|
2893
|
+
}
|
|
2894
|
+
if (segments.some((segment) => segment === '.')) {
|
|
2895
|
+
return '包含当前目录';
|
|
2896
|
+
}
|
|
2897
|
+
if (segments.some((segment) => segment === '..')) {
|
|
2898
|
+
return '包含上级目录';
|
|
2899
|
+
}
|
|
2900
|
+
if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
|
|
2901
|
+
return '包含控制字符';
|
|
2902
|
+
}
|
|
2903
|
+
return undefined;
|
|
2904
|
+
}
|
|
2878
2905
|
function validateUploadTotalSize(items, options = {}) {
|
|
2879
2906
|
const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
|
|
2880
2907
|
const total = items.reduce((sum, item) => {
|
|
@@ -2861,18 +2861,45 @@ function getMiniappUploadKey(input) {
|
|
|
2861
2861
|
}
|
|
2862
2862
|
function validateUploadPaths(items, options) {
|
|
2863
2863
|
const limit = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
|
|
2864
|
+
const uploadKeys = new Set();
|
|
2864
2865
|
for (const item of items) {
|
|
2866
|
+
const relativePath = String(item.relativePath ?? '');
|
|
2867
|
+
const normalizedRelativePath = normalizeRelativePath(relativePath);
|
|
2868
|
+
const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
|
|
2869
|
+
if (invalidReason) {
|
|
2870
|
+
return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
|
|
2871
|
+
}
|
|
2865
2872
|
const key = getMiniappUploadKey({
|
|
2866
2873
|
miniProgramId: options.miniProgramId,
|
|
2867
2874
|
version: options.version,
|
|
2868
|
-
relativePath:
|
|
2875
|
+
relativePath: normalizedRelativePath,
|
|
2869
2876
|
});
|
|
2877
|
+
if (uploadKeys.has(key)) {
|
|
2878
|
+
return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
|
|
2879
|
+
}
|
|
2880
|
+
uploadKeys.add(key);
|
|
2870
2881
|
if (key.length > limit) {
|
|
2871
|
-
return `文件路径过长,请缩短构建产物文件名或目录层级:${
|
|
2882
|
+
return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
|
|
2872
2883
|
}
|
|
2873
2884
|
}
|
|
2874
2885
|
return undefined;
|
|
2875
2886
|
}
|
|
2887
|
+
function getInvalidUploadPathReason(relativePath) {
|
|
2888
|
+
const segments = relativePath.replace(/\\/g, '/').split('/');
|
|
2889
|
+
if (segments.some((segment) => !segment)) {
|
|
2890
|
+
return '包含空路径段';
|
|
2891
|
+
}
|
|
2892
|
+
if (segments.some((segment) => segment === '.')) {
|
|
2893
|
+
return '包含当前目录';
|
|
2894
|
+
}
|
|
2895
|
+
if (segments.some((segment) => segment === '..')) {
|
|
2896
|
+
return '包含上级目录';
|
|
2897
|
+
}
|
|
2898
|
+
if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
|
|
2899
|
+
return '包含控制字符';
|
|
2900
|
+
}
|
|
2901
|
+
return undefined;
|
|
2902
|
+
}
|
|
2876
2903
|
function validateUploadTotalSize(items, options = {}) {
|
|
2877
2904
|
const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
|
|
2878
2905
|
const total = items.reduce((sum, item) => {
|
package/dist/vite.cjs.js
CHANGED
package/dist/vite.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heybox/hb-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8-alpha.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"./src/index.ts",
|
|
6
6
|
"./src/core/singleton.ts",
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"hb-sdk": "./bin/hb-sdk.cjs"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
|
+
"README.md",
|
|
46
|
+
"CHANGELOG.md",
|
|
45
47
|
"bin",
|
|
46
48
|
"dist",
|
|
47
49
|
"skill",
|
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
## Sources
|
|
6
6
|
|
|
7
7
|
- packages/hb-sdk/src/protocol.ts
|
|
8
|
-
- packages/hb-sdk/README.md
|
|
9
8
|
- apps/docs/hb-sdk/reference/index.md
|
|
10
9
|
|
|
11
10
|
## Contents
|
|
12
11
|
|
|
13
12
|
- [Host/runtime-only warning](#hostruntime-only-warning)
|
|
14
13
|
- [Public protocol entrypoint](#public-protocol-entrypoint)
|
|
15
|
-
- [Protocol context](#protocol-context)
|
|
16
14
|
- [Generated reference index](#generated-reference-index)
|
|
17
15
|
## Host/runtime-only warning
|
|
18
16
|
|
|
@@ -191,14 +189,6 @@ export type {
|
|
|
191
189
|
} from './modules/navigation';
|
|
192
190
|
```
|
|
193
191
|
|
|
194
|
-
## Protocol context
|
|
195
|
-
|
|
196
|
-
## SDK 与 Runtime
|
|
197
|
-
|
|
198
|
-
`@heybox/hb-sdk` 跑在 iframe 内部,由外部小程序业务页面使用。`@heybox/hb-sdk-runtime` 跑在 iframe 外部,由黑盒宿主壳层使用,负责启动 iframe、注入 nonce、维护 bridge server、注册能力 handler、转发宿主生命周期与登录态变化。
|
|
199
|
-
|
|
200
|
-
两者共享同一套 bridge 协议。协议字段、事件名或能力 payload 发生变化时,应按同一批次联动升级 SDK 与 runtime;不要只升级其中一侧后假定另一侧自动兼容。
|
|
201
|
-
|
|
202
192
|
## Generated reference index
|
|
203
193
|
|
|
204
194
|
|