@heybox/hb-sdk 0.6.7-alpha.1 → 0.6.7-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.
- package/README.md +3 -3
- package/dist/cli-chunks/{build-cBQK_qq-.cjs → build-CQmYxfxm.cjs} +25 -29
- package/dist/cli-chunks/{context-CfrdSQSg.cjs → context-ChkYWwH_.cjs} +23 -122
- package/dist/cli-chunks/{create-mp5nBLFJ.cjs → create-CC5r_8bL.cjs} +1 -1
- package/dist/cli-chunks/{dev-CSuSpwJC.cjs → dev-CD-38TgO.cjs} +110 -21
- package/dist/cli-chunks/{doctor-nEv6ikeF.cjs → doctor-43yEfVr0.cjs} +1 -1
- package/dist/cli-chunks/{index-CgUdrl3g.cjs → index-BM6oH2Hs.cjs} +3 -3
- package/dist/cli-chunks/{runtime-permission-env-BSs4uCNa.cjs → index-BQm5XmMC.cjs} +0 -71
- package/dist/cli-chunks/{index-CZ1l6xci.cjs → index-CQnkS0Z8.cjs} +14 -14
- package/dist/cli-chunks/{login-B2kXjmcM.cjs → login-BmisXAdp.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-BGAleOVW.cjs → project-vite-D9_v57vp.cjs} +1 -1
- package/dist/cli-chunks/{remote-B5byhdC7.cjs → remote-BXtT6M2f.cjs} +22 -40
- package/dist/cli-chunks/{runtime-gate--rPXjiG6.cjs → runtime-gate-B2MQf1vc.cjs} +3 -3
- package/dist/cli-chunks/{session-BbDd1r6M.cjs → session-BjtjhtPg.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/vite.cjs.js +50 -28
- package/dist/vite.esm.js +50 -28
- package/package.json +1 -1
- package/skill/references/api-root.md +7 -9
- package/skill/skill.json +4 -4
- package/types/vite/html-policy.d.ts +0 -1
- package/types/vite/index.d.ts +1 -0
- package/types/vite/runtime-permission-env.d.ts +0 -9
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var node_async_hooks = require('node:async_hooks');
|
|
4
|
-
|
|
5
3
|
var re = {exports: {}};
|
|
6
4
|
|
|
7
5
|
var constants;
|
|
@@ -2881,72 +2879,6 @@ function shouldUploadDistFile(relativePath) {
|
|
|
2881
2879
|
return true;
|
|
2882
2880
|
}
|
|
2883
2881
|
|
|
2884
|
-
const HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV = 'HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN';
|
|
2885
|
-
const HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV = 'HB_SDK_RUNTIME_PERMISSION_CONTEXT';
|
|
2886
|
-
const VERIFIED_RUNTIME_PERMISSION_CONTEXT = 'verified';
|
|
2887
|
-
const environmentScopeStorage = new node_async_hooks.AsyncLocalStorage();
|
|
2888
|
-
let environmentScopeTail = Promise.resolve();
|
|
2889
|
-
function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
|
|
2890
|
-
return env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] === '1';
|
|
2891
|
-
}
|
|
2892
|
-
function createMiniappPlatformCspEnv(env, skipPlatformCsp) {
|
|
2893
|
-
return {
|
|
2894
|
-
...env,
|
|
2895
|
-
[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV]: VERIFIED_RUNTIME_PERMISSION_CONTEXT,
|
|
2896
|
-
[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV]: skipPlatformCsp ? '1' : '0',
|
|
2897
|
-
};
|
|
2898
|
-
}
|
|
2899
|
-
async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.env) {
|
|
2900
|
-
if (environmentScopeStorage.getStore()?.active) {
|
|
2901
|
-
return runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env);
|
|
2902
|
-
}
|
|
2903
|
-
let releaseScope = () => undefined;
|
|
2904
|
-
const previousScope = environmentScopeTail;
|
|
2905
|
-
environmentScopeTail = new Promise((resolve) => {
|
|
2906
|
-
releaseScope = resolve;
|
|
2907
|
-
});
|
|
2908
|
-
await previousScope;
|
|
2909
|
-
const scope = { active: true };
|
|
2910
|
-
try {
|
|
2911
|
-
return await environmentScopeStorage.run(scope, () => runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env));
|
|
2912
|
-
}
|
|
2913
|
-
finally {
|
|
2914
|
-
scope.active = false;
|
|
2915
|
-
releaseScope();
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env) {
|
|
2919
|
-
const targets = env === process.env ? [env] : [env, process.env];
|
|
2920
|
-
const previousValues = targets.map((target) => ({
|
|
2921
|
-
context: target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV],
|
|
2922
|
-
officialDomain: target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV],
|
|
2923
|
-
}));
|
|
2924
|
-
for (const target of targets) {
|
|
2925
|
-
target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] = VERIFIED_RUNTIME_PERMISSION_CONTEXT;
|
|
2926
|
-
target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] = skipPlatformCsp ? '1' : '0';
|
|
2927
|
-
}
|
|
2928
|
-
try {
|
|
2929
|
-
return await action();
|
|
2930
|
-
}
|
|
2931
|
-
finally {
|
|
2932
|
-
targets.forEach((target, index) => {
|
|
2933
|
-
const previousValue = previousValues[index];
|
|
2934
|
-
if (previousValue?.context === undefined) {
|
|
2935
|
-
delete target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV];
|
|
2936
|
-
}
|
|
2937
|
-
else {
|
|
2938
|
-
target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] = previousValue.context;
|
|
2939
|
-
}
|
|
2940
|
-
if (previousValue?.officialDomain === undefined) {
|
|
2941
|
-
delete target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV];
|
|
2942
|
-
}
|
|
2943
|
-
else {
|
|
2944
|
-
target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] = previousValue.officialDomain;
|
|
2945
|
-
}
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
|
|
2950
2882
|
exports.ACTIVITY_UPLOAD_KEY_MAX_LENGTH = ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
|
|
2951
2883
|
exports.CREATE_USER_MINIPROGRAM_API_PATH = CREATE_USER_MINIPROGRAM_API_PATH;
|
|
2952
2884
|
exports.CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH = CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH;
|
|
@@ -2971,14 +2903,11 @@ exports.USER_MINIPROGRAM_ACCESS_STATUS_API_PATH = USER_MINIPROGRAM_ACCESS_STATUS
|
|
|
2971
2903
|
exports.USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH;
|
|
2972
2904
|
exports.USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH;
|
|
2973
2905
|
exports.WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH = WITHDRAW_USER_MINIPROGRAM_VERSION_API_PATH;
|
|
2974
|
-
exports.createMiniappPlatformCspEnv = createMiniappPlatformCspEnv;
|
|
2975
2906
|
exports.getMiniappUploadKey = getMiniappUploadKey;
|
|
2976
2907
|
exports.normalizeRelativePath = normalizeRelativePath;
|
|
2977
2908
|
exports.relativePathContainsNodeModulesSegment = relativePathContainsNodeModulesSegment;
|
|
2978
2909
|
exports.requireSemver = requireSemver;
|
|
2979
2910
|
exports.semverExports = semverExports;
|
|
2980
|
-
exports.shouldSkipMiniappPlatformCspFromEnv = shouldSkipMiniappPlatformCspFromEnv;
|
|
2981
2911
|
exports.shouldUploadDistFile = shouldUploadDistFile;
|
|
2982
2912
|
exports.validateUploadPaths = validateUploadPaths;
|
|
2983
2913
|
exports.validateUploadTotalSize = validateUploadTotalSize;
|
|
2984
|
-
exports.withMiniappPlatformCspEnv = withMiniappPlatformCspEnv;
|
|
@@ -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-CQnkS0Z8.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-CQnkS0Z8.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-CQnkS0Z8.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-CQnkS0Z8.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-CQnkS0Z8.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.7-alpha.
|
|
13350
|
+
const BUILT_CLI_VERSION = '0.6.7-alpha.2';
|
|
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-BmisXAdp.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-BmisXAdp.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-BmisXAdp.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-CQmYxfxm.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-CC5r_8bL.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-CD-38TgO.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-43yEfVr0.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-BXtT6M2f.cjs'); });
|
|
13712
13712
|
return runRemoteCommand(...args);
|
|
13713
13713
|
};
|
|
13714
13714
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -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-BjtjhtPg.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-CQnkS0Z8.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-CQnkS0Z8.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-CQnkS0Z8.cjs');
|
|
5
|
+
var session = require('./session-BjtjhtPg.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
|
|
11
|
-
var runtimeGate = require('./runtime-gate
|
|
12
|
-
var context = require('./context-
|
|
10
|
+
var index$1 = require('./index-BQm5XmMC.cjs');
|
|
11
|
+
var runtimeGate = require('./runtime-gate-B2MQf1vc.cjs');
|
|
12
|
+
var context = require('./context-ChkYWwH_.cjs');
|
|
13
13
|
require('node:module');
|
|
14
14
|
require('path');
|
|
15
15
|
require('os');
|
|
@@ -23,7 +23,6 @@ require('util');
|
|
|
23
23
|
require('node:crypto');
|
|
24
24
|
require('fs');
|
|
25
25
|
require('constants');
|
|
26
|
-
require('node:async_hooks');
|
|
27
26
|
|
|
28
27
|
async function getCDNUploadInfo(options, runtime = {}) {
|
|
29
28
|
const body = new URLSearchParams();
|
|
@@ -70,7 +69,7 @@ async function runUpload(options, runtime = {}) {
|
|
|
70
69
|
const postCDNUploadCallback$1 = runtime.postCDNUploadCallback ?? postCDNUploadCallback;
|
|
71
70
|
const createReadStream = runtime.createReadStream ?? fs.createReadStream;
|
|
72
71
|
const orderedFiles = [...options.files].sort((a, b) => a.relativePath.localeCompare(b.relativePath));
|
|
73
|
-
const batches = chunkUploadFiles(orderedFiles,
|
|
72
|
+
const batches = chunkUploadFiles(orderedFiles, index$1.MINIAPP_UPLOAD_BATCH_SIZE);
|
|
74
73
|
await logger.task(`正在上传 ${orderedFiles.length} 个文件`, async (taskContext) => {
|
|
75
74
|
logger.debug(`上传并发数: ${concurrency}`);
|
|
76
75
|
logger.debug(`上传批次数: ${batches.length}`);
|
|
@@ -80,7 +79,7 @@ async function runUpload(options, runtime = {}) {
|
|
|
80
79
|
logger.debug(`正在处理上传批次 ${batchIndex + 1}/${batches.length},文件数: ${batch.length}`);
|
|
81
80
|
logger.debug('正在获取 CDN 上传信息');
|
|
82
81
|
const fileInfos = createUploadFileInfos(batch, options);
|
|
83
|
-
const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope:
|
|
82
|
+
const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope: index$1.MINIAPP_UPLOAD_SCOPE, fileInfos, needCache: false }, { baseUrl: runtime.baseUrl, fetchImpl });
|
|
84
83
|
logger.debug(`CDN bucket: ${uploadInfo.bucket}`);
|
|
85
84
|
logger.debug(`CDN region: ${uploadInfo.region}`);
|
|
86
85
|
validateUploadInfoKeys(batch, uploadInfo.keys, options);
|
|
@@ -141,7 +140,7 @@ function createUploadFileInfos(files, options) {
|
|
|
141
140
|
name: file.relativePath.split('/').pop() ?? file.relativePath,
|
|
142
141
|
mimetype: file.mimeType,
|
|
143
142
|
fsize: file.size,
|
|
144
|
-
path:
|
|
143
|
+
path: index$1.getMiniappUploadKey({
|
|
145
144
|
miniProgramId: options.miniProgramId,
|
|
146
145
|
version: options.version,
|
|
147
146
|
relativePath: file.relativePath,
|
|
@@ -152,15 +151,15 @@ function validateUploadInfoKeys(files, keys, options) {
|
|
|
152
151
|
if (keys.length !== files.length) {
|
|
153
152
|
throw new index.CliError(`CDN 上传接口返回 key 数量异常:期望 ${files.length},实际 ${keys.length}`);
|
|
154
153
|
}
|
|
155
|
-
for (let index$
|
|
156
|
-
const expectedKey =
|
|
154
|
+
for (let index$2 = 0; index$2 < files.length; index$2 += 1) {
|
|
155
|
+
const expectedKey = index$1.getMiniappUploadKey({
|
|
157
156
|
miniProgramId: options.miniProgramId,
|
|
158
157
|
version: options.version,
|
|
159
|
-
relativePath: files[index$
|
|
158
|
+
relativePath: files[index$2].relativePath,
|
|
160
159
|
});
|
|
161
|
-
const actualKey = keys[index$
|
|
160
|
+
const actualKey = keys[index$2];
|
|
162
161
|
if (actualKey !== expectedKey) {
|
|
163
|
-
throw new index.CliError(`CDN 上传接口返回 key 异常:${files[index$
|
|
162
|
+
throw new index.CliError(`CDN 上传接口返回 key 异常:${files[index$2].relativePath}`, [`CDN 上传接口返回 key 异常:${files[index$2].relativePath}`, `expected: ${expectedKey}`, `actual: ${actualKey}`].join('\n'));
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
}
|
|
@@ -192,7 +191,7 @@ async function createDefaultCosClient(uploadToken) {
|
|
|
192
191
|
};
|
|
193
192
|
}
|
|
194
193
|
async function loadCosConstructor() {
|
|
195
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
194
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-BM6oH2Hs.cjs'); }).then(function (n) { return n.index; });
|
|
196
195
|
return cosModule.default;
|
|
197
196
|
}
|
|
198
197
|
function formatSize(bytes) {
|
|
@@ -236,7 +235,7 @@ function isRecord(value) {
|
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
async function precheckUserMiniprogramVersion(options, runtime = {}) {
|
|
239
|
-
return postUserMiniprogramVersionForm(
|
|
238
|
+
return postUserMiniprogramVersionForm(index$1.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
|
|
240
239
|
// 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
|
|
241
240
|
...(options.version ? { version: options.version } : {}),
|
|
242
241
|
...(options.source_version ? { source_version: options.source_version } : {}),
|
|
@@ -245,7 +244,7 @@ async function precheckUserMiniprogramVersion(options, runtime = {}) {
|
|
|
245
244
|
}, runtime);
|
|
246
245
|
}
|
|
247
246
|
async function submitUserMiniprogramAudit(options, runtime = {}) {
|
|
248
|
-
return postUserMiniprogramVersionForm(
|
|
247
|
+
return postUserMiniprogramVersionForm(index$1.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
|
|
249
248
|
// 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
|
|
250
249
|
...(options.manifest ? { manifest: JSON.stringify(options.manifest) } : {}),
|
|
251
250
|
...(options.source_version ? { source_version: options.source_version } : {}),
|
|
@@ -342,28 +341,11 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
342
341
|
releaseNote,
|
|
343
342
|
autoPublish,
|
|
344
343
|
}, runtime, apiBaseUrl, projectRoot, logger);
|
|
345
|
-
let skipPlatformCsp = false;
|
|
346
|
-
try {
|
|
347
|
-
const { detail } = await logger.task('正在读取远端小程序权限', () => (runtime.getBoundMiniProgram ?? context.getBoundMiniProgram)({
|
|
348
|
-
allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl,
|
|
349
|
-
apiBaseUrl,
|
|
350
|
-
cwd: projectRoot,
|
|
351
|
-
env,
|
|
352
|
-
fetchImpl: runtime.fetchImpl,
|
|
353
|
-
loginBaseUrl,
|
|
354
|
-
session: session$1,
|
|
355
|
-
}), { successText: '已读取远端小程序权限' });
|
|
356
|
-
skipPlatformCsp = context.shouldSkipMiniappPlatformCsp(detail.runtime_permissions);
|
|
357
|
-
}
|
|
358
|
-
catch (error) {
|
|
359
|
-
logger.warn('未读取到远端 Runtime 权限,构建将继续注入平台 CSP。');
|
|
360
|
-
logger.debug(`远端 Runtime 权限读取失败详情:${index.readRedactedErrorMessage(error, { verbose: true })}`);
|
|
361
|
-
}
|
|
362
344
|
const pm = detectPackageManager(projectRoot);
|
|
363
345
|
const buildMode = env.HB_SDK_ENV?.trim();
|
|
364
346
|
logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode).join(' ')}`);
|
|
365
347
|
await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
|
|
366
|
-
env
|
|
348
|
+
env,
|
|
367
349
|
mode: buildMode,
|
|
368
350
|
outputMode: options.buildOutputMode ?? 'inherit',
|
|
369
351
|
stderr: runtime.stderr,
|
|
@@ -382,16 +364,16 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
382
364
|
}
|
|
383
365
|
const uploadFiles = await logger.task('正在校验 dist 上传文件', async () => {
|
|
384
366
|
const allFiles = await walkDistFiles(distDir);
|
|
385
|
-
const blocked = allFiles.find((entry) =>
|
|
367
|
+
const blocked = allFiles.find((entry) => index$1.relativePathContainsNodeModulesSegment(entry.relativePath));
|
|
386
368
|
if (blocked) {
|
|
387
369
|
throw new Error(`dist 目录含 node_modules:${blocked.relativePath}`);
|
|
388
370
|
}
|
|
389
|
-
const files = allFiles.filter((entry) =>
|
|
390
|
-
const pathError =
|
|
371
|
+
const files = allFiles.filter((entry) => index$1.shouldUploadDistFile(entry.relativePath));
|
|
372
|
+
const pathError = index$1.validateUploadPaths(files, { miniProgramId, version, maxLength: index$1.ACTIVITY_UPLOAD_KEY_MAX_LENGTH });
|
|
391
373
|
if (pathError) {
|
|
392
374
|
throw new Error(pathError);
|
|
393
375
|
}
|
|
394
|
-
const sizeError =
|
|
376
|
+
const sizeError = index$1.validateUploadTotalSize(files);
|
|
395
377
|
if (sizeError) {
|
|
396
378
|
throw new Error(sizeError);
|
|
397
379
|
}
|
|
@@ -600,7 +582,7 @@ async function walkDistFiles(distDir) {
|
|
|
600
582
|
}
|
|
601
583
|
const fileStat = await fs$1.stat(absPath);
|
|
602
584
|
results.push({
|
|
603
|
-
relativePath:
|
|
585
|
+
relativePath: index$1.normalizeRelativePath(relPath),
|
|
604
586
|
absolutePath: absPath,
|
|
605
587
|
size: fileStat.size,
|
|
606
588
|
mimeType: inferMimeType(entry.name),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var index = require('./index-BQm5XmMC.cjs');
|
|
4
4
|
|
|
5
5
|
function isValidMiniappManifestVersion(version) {
|
|
6
6
|
return getMiniappManifestVersionError(version) === undefined;
|
|
@@ -41,7 +41,7 @@ function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
|
|
|
41
41
|
throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
|
|
42
42
|
}
|
|
43
43
|
const normalized = version.trim();
|
|
44
|
-
const parsed =
|
|
44
|
+
const parsed = index.semverExports.parse(normalized);
|
|
45
45
|
if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
|
|
46
46
|
throw new Error(`${sourceLabel} 必须是合法 SemVer:${normalized}`);
|
|
47
47
|
}
|
|
@@ -55,7 +55,7 @@ function getMiniappManifestVersionError(version) {
|
|
|
55
55
|
return `必须是合法 SemVer:${String(version)}`;
|
|
56
56
|
}
|
|
57
57
|
const normalized = version.trim();
|
|
58
|
-
const parsed =
|
|
58
|
+
const parsed = index.semverExports.parse(normalized);
|
|
59
59
|
if (!parsed) {
|
|
60
60
|
return `必须是合法 SemVer:${normalized}`;
|
|
61
61
|
}
|
package/dist/cli.cjs
CHANGED
package/dist/index.cjs.js
CHANGED
package/dist/index.esm.js
CHANGED
package/dist/vite.cjs.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var node_fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var node_async_hooks = require('node:async_hooks');
|
|
6
5
|
|
|
7
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
7
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
9
8
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
10
9
|
? undefined
|
|
11
|
-
: '0.6.7-alpha.
|
|
10
|
+
: '0.6.7-alpha.2';
|
|
12
11
|
|
|
13
12
|
var re = {exports: {}};
|
|
14
13
|
|
|
@@ -11433,13 +11432,17 @@ function walk$1(node, visit) {
|
|
|
11433
11432
|
|
|
11434
11433
|
const FORBIDDEN_RESOURCE_HINTS = new Set(['dns-prefetch', 'preconnect', 'prerender']);
|
|
11435
11434
|
const RELATIVE_URL_BASE = new URL('https://heybox-relative.invalid/');
|
|
11435
|
+
const OFFICIAL_RESOURCE_ROOT_DOMAINS = ['xiaoheihe.cn', 'max-c.com', 'debugmode.cn', 'maxjia.com'];
|
|
11436
|
+
const OFFICIAL_RESOURCE_SOURCES = OFFICIAL_RESOURCE_ROOT_DOMAINS.flatMap(rootDomain => [
|
|
11437
|
+
`https://${rootDomain}`,
|
|
11438
|
+
`https://*.${rootDomain}`,
|
|
11439
|
+
]);
|
|
11436
11440
|
const URL_ATTRIBUTES = {
|
|
11437
11441
|
audio: ['src'],
|
|
11438
11442
|
embed: ['src'],
|
|
11439
11443
|
iframe: ['src'],
|
|
11440
11444
|
img: ['src'],
|
|
11441
11445
|
input: ['src'],
|
|
11442
|
-
link: ['href'],
|
|
11443
11446
|
object: ['data'],
|
|
11444
11447
|
script: ['src'],
|
|
11445
11448
|
source: ['src', 'srcset'],
|
|
@@ -11449,11 +11452,11 @@ const URL_ATTRIBUTES = {
|
|
|
11449
11452
|
const PRODUCTION_CSP = [
|
|
11450
11453
|
"default-src 'none'",
|
|
11451
11454
|
"connect-src 'none'",
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11455
|
+
`script-src 'self' 'unsafe-inline' ${OFFICIAL_RESOURCE_SOURCES.join(' ')}`,
|
|
11456
|
+
`style-src 'self' 'unsafe-inline' ${OFFICIAL_RESOURCE_SOURCES.join(' ')}`,
|
|
11457
|
+
`img-src 'self' data: blob: ${OFFICIAL_RESOURCE_SOURCES.join(' ')}`,
|
|
11458
|
+
`font-src 'self' data: ${OFFICIAL_RESOURCE_SOURCES.join(' ')}`,
|
|
11459
|
+
`media-src 'self' blob: ${OFFICIAL_RESOURCE_SOURCES.join(' ')}`,
|
|
11457
11460
|
"manifest-src 'self'",
|
|
11458
11461
|
"frame-src 'none'",
|
|
11459
11462
|
"child-src 'none'",
|
|
@@ -11472,9 +11475,6 @@ function enforceMiniappHtmlPolicy(html, options = {}) {
|
|
|
11472
11475
|
removePlatformCspMarkers(document);
|
|
11473
11476
|
walk(document, element => validateElement(element));
|
|
11474
11477
|
injectMiniappRuntimeGate(document);
|
|
11475
|
-
if (options.skipPlatformCsp) {
|
|
11476
|
-
return serialize(document);
|
|
11477
|
-
}
|
|
11478
11478
|
const content = options.hmrWebSocketUrl
|
|
11479
11479
|
? PRODUCTION_CSP.replace("connect-src 'none'", `connect-src ${options.hmrWebSocketUrl}`)
|
|
11480
11480
|
: PRODUCTION_CSP;
|
|
@@ -11511,19 +11511,25 @@ function validateElement(element) {
|
|
|
11511
11511
|
if (forbidden) {
|
|
11512
11512
|
throw new Error(`index.html 不允许 rel="${forbidden}"`);
|
|
11513
11513
|
}
|
|
11514
|
-
if (rels.includes('
|
|
11514
|
+
if (rels.includes('stylesheet')) {
|
|
11515
|
+
validateResourceUrl(attrs.get('href'), '<link rel="stylesheet" href>', false, true);
|
|
11516
|
+
}
|
|
11517
|
+
else if (rels.includes('preload') || rels.includes('modulepreload')) {
|
|
11515
11518
|
validateRelativeUrl(attrs.get('href'), `<link rel="${rels.includes('modulepreload') ? 'modulepreload' : 'preload'}" href>`, false);
|
|
11516
11519
|
}
|
|
11520
|
+
else {
|
|
11521
|
+
validateRelativeUrl(attrs.get('href'), '<link href>', false);
|
|
11522
|
+
}
|
|
11517
11523
|
}
|
|
11518
11524
|
for (const attribute of URL_ATTRIBUTES[tagName] ?? []) {
|
|
11519
11525
|
const value = attrs.get(attribute);
|
|
11520
11526
|
if (attribute === 'srcset') {
|
|
11521
11527
|
for (const candidate of (value ?? '').split(',').map(item => item.trim().split(/\s+/)[0]).filter(Boolean)) {
|
|
11522
|
-
|
|
11528
|
+
validateResourceUrl(candidate, `<${tagName} ${attribute}>`, true, supportsOfficialResourceUrl(tagName, attribute));
|
|
11523
11529
|
}
|
|
11524
11530
|
}
|
|
11525
11531
|
else {
|
|
11526
|
-
|
|
11532
|
+
validateResourceUrl(value, `<${tagName} ${attribute}>`, true, supportsOfficialResourceUrl(tagName, attribute));
|
|
11527
11533
|
}
|
|
11528
11534
|
}
|
|
11529
11535
|
}
|
|
@@ -11538,16 +11544,43 @@ function removePlatformCspMarkers(node) {
|
|
|
11538
11544
|
for (const child of node.childNodes)
|
|
11539
11545
|
removePlatformCspMarkers(child);
|
|
11540
11546
|
}
|
|
11541
|
-
function
|
|
11547
|
+
function supportsOfficialResourceUrl(tagName, attribute) {
|
|
11548
|
+
return ((tagName === 'script' && attribute === 'src') ||
|
|
11549
|
+
(tagName === 'img' && attribute === 'src') ||
|
|
11550
|
+
(tagName === 'source' && (attribute === 'src' || attribute === 'srcset')) ||
|
|
11551
|
+
(tagName === 'audio' && attribute === 'src') ||
|
|
11552
|
+
(tagName === 'track' && attribute === 'src') ||
|
|
11553
|
+
(tagName === 'video' && (attribute === 'src' || attribute === 'poster')));
|
|
11554
|
+
}
|
|
11555
|
+
function validateResourceUrl(value, label, allowDataBlob, allowOfficialResourceUrl) {
|
|
11542
11556
|
if (!value || value.startsWith('#'))
|
|
11543
11557
|
return;
|
|
11544
11558
|
const normalized = value.trim().toLowerCase();
|
|
11545
11559
|
if (allowDataBlob && (normalized.startsWith('data:') || normalized.startsWith('blob:')))
|
|
11546
11560
|
return;
|
|
11561
|
+
if (allowOfficialResourceUrl && isOfficialResourceUrl(value))
|
|
11562
|
+
return;
|
|
11547
11563
|
if (!isRelativeUrl(value, normalized)) {
|
|
11548
11564
|
throw new Error(`${label} 必须使用相对路径${allowDataBlob ? '或明确的 data:/blob: URL' : ''}:${value}`);
|
|
11549
11565
|
}
|
|
11550
11566
|
}
|
|
11567
|
+
function validateRelativeUrl(value, label, allowDataBlob) {
|
|
11568
|
+
validateResourceUrl(value, label, allowDataBlob, false);
|
|
11569
|
+
}
|
|
11570
|
+
function isOfficialResourceUrl(value) {
|
|
11571
|
+
try {
|
|
11572
|
+
const url = new URL(value);
|
|
11573
|
+
if (url.protocol !== 'https:' || url.username || url.password)
|
|
11574
|
+
return false;
|
|
11575
|
+
const hostname = url.hostname.toLowerCase();
|
|
11576
|
+
if (hostname.endsWith('.'))
|
|
11577
|
+
return false;
|
|
11578
|
+
return OFFICIAL_RESOURCE_ROOT_DOMAINS.some(rootDomain => hostname === rootDomain || hostname.endsWith(`.${rootDomain}`));
|
|
11579
|
+
}
|
|
11580
|
+
catch {
|
|
11581
|
+
return false;
|
|
11582
|
+
}
|
|
11583
|
+
}
|
|
11551
11584
|
function isRelativeUrl(value, normalized) {
|
|
11552
11585
|
const browserNormalized = normalized.replace(/[\t\n\r]/g, '');
|
|
11553
11586
|
if (browserNormalized.includes('\\') || browserNormalized.startsWith('//'))
|
|
@@ -11584,19 +11617,9 @@ function walk(node, visit) {
|
|
|
11584
11617
|
walk(node.content, visit);
|
|
11585
11618
|
}
|
|
11586
11619
|
|
|
11587
|
-
const HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV = 'HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN';
|
|
11588
|
-
const HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV = 'HB_SDK_RUNTIME_PERMISSION_CONTEXT';
|
|
11589
|
-
const VERIFIED_RUNTIME_PERMISSION_CONTEXT = 'verified';
|
|
11590
|
-
new node_async_hooks.AsyncLocalStorage();
|
|
11591
|
-
Promise.resolve();
|
|
11592
|
-
function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
|
|
11593
|
-
return env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] === '1';
|
|
11594
|
-
}
|
|
11595
|
-
|
|
11596
11620
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
11597
11621
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
11598
11622
|
function miniappManifest() {
|
|
11599
|
-
const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
|
|
11600
11623
|
let root = process.cwd();
|
|
11601
11624
|
let outDir = 'dist';
|
|
11602
11625
|
let command = 'build';
|
|
@@ -11628,7 +11651,6 @@ function miniappManifest() {
|
|
|
11628
11651
|
transformIndexHtml(html) {
|
|
11629
11652
|
return enforceMiniappHtmlPolicy(html, {
|
|
11630
11653
|
...(command === 'serve' ? { hmrWebSocketUrl } : {}),
|
|
11631
|
-
skipPlatformCsp,
|
|
11632
11654
|
});
|
|
11633
11655
|
},
|
|
11634
11656
|
async closeBundle() {
|
|
@@ -11651,7 +11673,7 @@ function miniappManifest() {
|
|
|
11651
11673
|
if (!htmlFiles.includes(indexHtmlPath)) {
|
|
11652
11674
|
throw new Error('构建产物必须包含入口 dist/index.html');
|
|
11653
11675
|
}
|
|
11654
|
-
node_fs.writeFileSync(indexHtmlPath, enforceMiniappHtmlPolicy(node_fs.readFileSync(indexHtmlPath, 'utf8')
|
|
11676
|
+
node_fs.writeFileSync(indexHtmlPath, enforceMiniappHtmlPolicy(node_fs.readFileSync(indexHtmlPath, 'utf8')));
|
|
11655
11677
|
const manifestPath = path.join(outputRoot, 'manifest.json');
|
|
11656
11678
|
node_fs.mkdirSync(path.dirname(manifestPath), { recursive: true });
|
|
11657
11679
|
node_fs.writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion }));
|
|
@@ -11693,7 +11715,7 @@ function resolveHmrWebSocketUrl(resolved) {
|
|
|
11693
11715
|
if (hmr === false)
|
|
11694
11716
|
return undefined;
|
|
11695
11717
|
const options = typeof hmr === 'object' ? hmr : {};
|
|
11696
|
-
const protocol = options.protocol ?? 'ws';
|
|
11718
|
+
const protocol = options.protocol ?? (resolved.server.https ? 'wss' : 'ws');
|
|
11697
11719
|
const configuredHost = options.host ?? resolved.server.host;
|
|
11698
11720
|
const host = typeof configuredHost === 'string' && configuredHost !== '0.0.0.0' ? configuredHost : '127.0.0.1';
|
|
11699
11721
|
const port = options.clientPort ?? options.port ?? resolved.server.port;
|