@heybox/hb-sdk 0.9.2-alpha.7 → 0.9.2-alpha.9

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 (43) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +4 -2
  3. package/dist/card-controller.cjs.js +35 -3
  4. package/dist/card-controller.esm.js +35 -3
  5. package/dist/cli-chunks/{build-Do22AWbq.cjs → build-DvHmPnZZ.cjs} +5 -5
  6. package/dist/cli-chunks/{context-DQhjWa7X.cjs → context-DYlZV8UG.cjs} +2 -2
  7. package/dist/cli-chunks/{create-QuI_mw8x.cjs → create-CJ0cyrJG.cjs} +1 -1
  8. package/dist/cli-chunks/deploy-lock-CmKl9M1c.cjs +148 -0
  9. package/dist/cli-chunks/{dev-KAhj5UTy.cjs → dev-DhEZBjd6.cjs} +8 -8
  10. package/dist/cli-chunks/{doctor-DNoQWBpo.cjs → doctor-B8q0UuXs.cjs} +1 -1
  11. package/dist/cli-chunks/games-CmO-AKXg.cjs +140 -0
  12. package/dist/cli-chunks/{index-DZUYwb3h.cjs → index-CRwNLk5w.cjs} +1 -1
  13. package/dist/cli-chunks/{index-bZIxID9N.cjs → index-hYvQR19Q.cjs} +35 -16
  14. package/dist/cli-chunks/{index.esm-EWleN3S5.cjs → index.esm-DU7YhFWI.cjs} +6 -6
  15. package/dist/cli-chunks/{login-BYM3Nwau.cjs → login-DMJ45_Bs.cjs} +1 -1
  16. package/dist/cli-chunks/{project-vite-6eLmb4Em.cjs → project-vite-BGy9w-Bx.cjs} +1 -1
  17. package/dist/cli-chunks/{remote-dvOjaxJu.cjs → remote-CSuwqlKA.cjs} +33 -146
  18. package/dist/cli-chunks/{runtime-gate-BKc2zPV-.cjs → runtime-gate-BvcLwvzi.cjs} +3 -2
  19. package/dist/cli-chunks/{runtime-permission-env-B9SqoP85.cjs → runtime-permission-env-CbqmHz0r.cjs} +14 -2
  20. package/dist/cli-chunks/{skill-DFXZ0SK_.cjs → skill-CtKW2J0U.cjs} +2 -2
  21. package/dist/cli-chunks/{version-CwEOrhL1.cjs → version-BQMfLqms.cjs} +1 -1
  22. package/dist/cli.cjs +1 -1
  23. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-BitDUIsy.js → browser-dev-host-Cjw0mAi_.js} +1 -1
  24. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-B0yrI7xe.js → desktop-app-launch-D9lPBkUV.js} +1 -1
  25. package/dist/devtools/browser-dev-host/assets/{index-D_mC4Hvt.js → index-DrbZkH9C.js} +3 -3
  26. package/dist/devtools/browser-dev-host/index.html +2 -2
  27. package/dist/index.cjs.js +13 -5
  28. package/dist/index.esm.js +13 -5
  29. package/dist/miniapp-publish.cjs.js +35 -81
  30. package/dist/miniapp-publish.esm.js +35 -80
  31. package/dist/protocol.cjs.js +13 -0
  32. package/dist/protocol.esm.js +13 -0
  33. package/dist/templates/vanilla-vite-js/README.md.ejs +4 -0
  34. package/dist/vite.cjs.js +51 -3
  35. package/dist/vite.esm.js +51 -3
  36. package/package.json +5 -4
  37. package/skill/SKILL.md +9 -0
  38. package/skill/skill.json +5 -5
  39. package/types/card-controller.d.ts +35 -3
  40. package/types/index.d.ts +51 -51
  41. package/types/miniapp-publish/index.d.ts +28 -60
  42. package/types/protocol.d.ts +10 -10
  43. package/types/vite/index.d.ts +8 -1
@@ -238,19 +238,19 @@ function requireArgument () {
238
238
 
239
239
  var command = {};
240
240
 
241
- 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-bZIxID9N.cjs', document.baseURI).href)));
241
+ 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-hYvQR19Q.cjs', document.baseURI).href)));
242
242
  function __require$4() { return require$5("node:events"); }
243
243
 
244
- 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-bZIxID9N.cjs', document.baseURI).href)));
244
+ 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-hYvQR19Q.cjs', document.baseURI).href)));
245
245
  function __require$3() { return require$4("node:child_process"); }
246
246
 
247
- 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-bZIxID9N.cjs', document.baseURI).href)));
247
+ 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-hYvQR19Q.cjs', document.baseURI).href)));
248
248
  function __require$2() { return require$3("node:path"); }
249
249
 
250
- 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-bZIxID9N.cjs', document.baseURI).href)));
250
+ 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-hYvQR19Q.cjs', document.baseURI).href)));
251
251
  function __require$1() { return require$2("node:fs"); }
252
252
 
253
- 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-bZIxID9N.cjs', document.baseURI).href)));
253
+ 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-hYvQR19Q.cjs', document.baseURI).href)));
254
254
  function __require() { return require$1("node:process"); }
255
255
 
256
256
  var help = {};
@@ -17249,7 +17249,7 @@ async function inspectFeedbackLog(file, size) {
17249
17249
  return { mimeType: 'text/plain', width: 0, height: 0 };
17250
17250
  }
17251
17251
  async function createFeedbackCosClient(getToken) {
17252
- const { default: COS } = await Promise.resolve().then(function () { return require('./index-DZUYwb3h.cjs'); }).then(function (n) { return n.index; });
17252
+ const { default: COS } = await Promise.resolve().then(function () { return require('./index-CRwNLk5w.cjs'); }).then(function (n) { return n.index; });
17253
17253
  const cos = new COS({
17254
17254
  getAuthorization(_options, callback) {
17255
17255
  void getToken().then((token) => callback({
@@ -20900,7 +20900,7 @@ function readEnvNameArgFromArgv(argv) {
20900
20900
  }
20901
20901
 
20902
20902
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
20903
- const BUILT_CLI_VERSION = '0.9.2-alpha.7';
20903
+ const BUILT_CLI_VERSION = '0.9.2-alpha.9';
20904
20904
  const PACKAGE_JSON_CANDIDATES = [
20905
20905
  path.resolve(__dirname, '..', '..', 'package.json'),
20906
20906
  path.resolve(__dirname, '..', 'package.json'),
@@ -20966,6 +20966,7 @@ function createCliProgram(overrides = {}) {
20966
20966
  runDevCommand: defaultRunDevCommand,
20967
20967
  runDoctorCommand: defaultRunDoctorCommand,
20968
20968
  runRemoteCommand: defaultRunRemoteCommand,
20969
+ runGameSearchCommand: defaultRunGameSearchCommand,
20969
20970
  runSkillInstallCommand: defaultRunSkillInstallCommand,
20970
20971
  ...overrides,
20971
20972
  };
@@ -21070,6 +21071,20 @@ function addRemotePublicOptions(command) {
21070
21071
  }
21071
21072
  function installRemoteCommands(program, handlers, resolveLogger) {
21072
21073
  const remote = addRemotePublicOptions(program.command('remote').description('管理当前项目绑定的远程 Heybox 工坊小程序'));
21074
+ const games = addVerboseOption(remote.command('games').description('查询平台游戏信息'));
21075
+ addVerboseOption(games.command('search').description('按名称查找游戏 appid,不修改绑定')
21076
+ .argument('<query>', '中文或英文游戏名')
21077
+ .option('--offset <offset>', '结果偏移量,0–10000', '0')
21078
+ .option('--limit <limit>', '每页数量,1–20', '10')
21079
+ .option('--json', '输出 JSON'))
21080
+ .action(async (query, _options, command) => {
21081
+ const options = readCommandOptionsWithAncestors(command);
21082
+ await handlers.runGameSearchCommand(query, {
21083
+ offset: readStringOption(options.offset),
21084
+ limit: readStringOption(options.limit),
21085
+ json: Boolean(options.json),
21086
+ });
21087
+ });
21073
21088
  addRemotePublicOptions(remote.command('access').description('查看当前账号的小程序工坊访问权限')).action(createRemoteAction(handlers, resolveLogger, 'access'));
21074
21089
  const entity = addRemotePublicOptions(remote.command('entity').description('查看和切换当前开发者主体'));
21075
21090
  addRemotePublicOptions(entity.command('list').description('列出当前账号可切换的开发者主体')).action(createRemoteAction(handlers, resolveLogger, 'entity:list'));
@@ -21269,39 +21284,39 @@ function createCommandLoggerResolver(options) {
21269
21284
  };
21270
21285
  }
21271
21286
  const defaultClearLoginStatus = async (...args) => {
21272
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-BYM3Nwau.cjs'); });
21287
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DMJ45_Bs.cjs'); });
21273
21288
  return clearLoginStatus(...args);
21274
21289
  };
21275
21290
  const defaultLoginToHeybox = async (...args) => {
21276
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-BYM3Nwau.cjs'); });
21291
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DMJ45_Bs.cjs'); });
21277
21292
  return loginToHeybox(...args);
21278
21293
  };
21279
21294
  const defaultPrintLoginStatus = async (...args) => {
21280
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-BYM3Nwau.cjs'); });
21295
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DMJ45_Bs.cjs'); });
21281
21296
  return printLoginStatus(...args);
21282
21297
  };
21283
21298
  const defaultRunBuildCommand = async (...args) => {
21284
- const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-Do22AWbq.cjs'); });
21299
+ const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-DvHmPnZZ.cjs'); });
21285
21300
  return runBuildCommand(...args);
21286
21301
  };
21287
21302
  const defaultRunCreateCommand = async (...args) => {
21288
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-QuI_mw8x.cjs'); });
21303
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CJ0cyrJG.cjs'); });
21289
21304
  return runCreateCommand(...args);
21290
21305
  };
21291
21306
  const defaultRunDevCommand = async (...args) => {
21292
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-KAhj5UTy.cjs'); }).then(function (n) { return n.dev; });
21307
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-DhEZBjd6.cjs'); }).then(function (n) { return n.dev; });
21293
21308
  return runDevCommand(...args);
21294
21309
  };
21295
21310
  const defaultRunDoctorCommand = async (...args) => {
21296
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-DNoQWBpo.cjs'); });
21311
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-B8q0UuXs.cjs'); });
21297
21312
  return runDoctorCommand(...args);
21298
21313
  };
21299
21314
  const defaultRunSkillInstallCommand = async (...args) => {
21300
- const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-DFXZ0SK_.cjs'); });
21315
+ const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-CtKW2J0U.cjs'); });
21301
21316
  return runSkillInstallCommand(...args);
21302
21317
  };
21303
21318
  const defaultRunRemoteCommand = async (...args) => {
21304
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-dvOjaxJu.cjs'); });
21319
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-CSuwqlKA.cjs'); });
21305
21320
  return runRemoteCommand(...args);
21306
21321
  };
21307
21322
  function resolveStandaloneLogger(options, verbose) {
@@ -21392,6 +21407,10 @@ function parseNonNegativeInteger(value) {
21392
21407
  }
21393
21408
  return parsed;
21394
21409
  }
21410
+ const defaultRunGameSearchCommand = async (...args) => {
21411
+ const { runGameSearchCommand } = await Promise.resolve().then(function () { return require('./games-CmO-AKXg.cjs'); });
21412
+ return runGameSearchCommand(...args);
21413
+ };
21395
21414
 
21396
21415
  exports.CliError = CliError;
21397
21416
  exports.HB_SDK_PACKAGE_NAME = HB_SDK_PACKAGE_NAME;
@@ -11,8 +11,8 @@ var require$$0$3 = require('url');
11
11
  var require$$5 = require('zlib');
12
12
  var require$$0 = require('buffer');
13
13
  var require$$1 = require('util');
14
- var index = require('./index-bZIxID9N.cjs');
15
- var dev = require('./dev-KAhj5UTy.cjs');
14
+ var index = require('./index-hYvQR19Q.cjs');
15
+ var dev = require('./dev-DhEZBjd6.cjs');
16
16
  require('node:module');
17
17
  require('readline');
18
18
  require('os');
@@ -26,9 +26,9 @@ require('constants');
26
26
  require('node:fs');
27
27
  require('node:fs/promises');
28
28
  require('node:zlib');
29
- require('./context-DQhjWa7X.cjs');
30
- require('./runtime-permission-env-B9SqoP85.cjs');
31
- require('./version-CwEOrhL1.cjs');
29
+ require('./context-DYlZV8UG.cjs');
30
+ require('./runtime-permission-env-CbqmHz0r.cjs');
31
+ require('./version-BQMfLqms.cjs');
32
32
  require('node:async_hooks');
33
33
  require('sharp');
34
34
  require('node:os');
@@ -42,7 +42,7 @@ require('node:buffer');
42
42
  require('node:url');
43
43
  require('node:util');
44
44
  require('node:child_process');
45
- require('./project-vite-6eLmb4Em.cjs');
45
+ require('./project-vite-BGy9w-Bx.cjs');
46
46
 
47
47
  var bufferUtil = {exports: {}};
48
48
 
@@ -3,7 +3,7 @@
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 index = require('./index-bZIxID9N.cjs');
6
+ var index = require('./index-hYvQR19Q.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
8
  require('node:module');
9
9
  require('readline');
@@ -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-bZIxID9N.cjs');
8
+ var index = require('./index-hYvQR19Q.cjs');
9
9
 
10
10
  function findProjectRoot(startDir) {
11
11
  let current = path.resolve(startDir);
@@ -1,17 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var runtimePermissionEnv = require('./runtime-permission-env-B9SqoP85.cjs');
4
- var context = require('./context-DQhjWa7X.cjs');
3
+ var runtimePermissionEnv = require('./runtime-permission-env-CbqmHz0r.cjs');
4
+ var context = require('./context-DYlZV8UG.cjs');
5
5
  var promises = require('node:readline/promises');
6
- var index = require('./index-bZIxID9N.cjs');
7
- var runtimeGate = require('./runtime-gate-BKc2zPV-.cjs');
6
+ var index = require('./index-hYvQR19Q.cjs');
7
+ var runtimeGate = require('./runtime-gate-BvcLwvzi.cjs');
8
8
  var childProcess = require('node:child_process');
9
9
  var fs = require('node:fs');
10
10
  var fs$1 = require('node:fs/promises');
11
11
  var path = require('node:path');
12
12
  var node_crypto = require('node:crypto');
13
13
  require('node:zlib');
14
- require('./version-CwEOrhL1.cjs');
14
+ var deployLock = require('./deploy-lock-CmKl9M1c.cjs');
15
+ require('./version-BQMfLqms.cjs');
15
16
  require('node:async_hooks');
16
17
  require('sharp');
17
18
  require('node:module');
@@ -33,6 +34,27 @@ require('inspector');
33
34
  // 脚手架开发占位图;构建可用,提审前必须替换。
34
35
  const BASIC_INFO_PLACEHOLDER_SHA256 = 'd14e54b30f5e6d1bcbf51267bc82b06a0af7c333f2945bcc16b4e1adc3b123dd';
35
36
 
37
+ /** 根据当前项目声明或实际版本 Manifest 检查资料完整性,不联网、不修改输入。 */
38
+ function getMiniappMetadataWarnings(metadata) {
39
+ const warnings = [];
40
+ if (metadata.desc === undefined || (typeof metadata.desc === 'string' && !metadata.desc.trim())) {
41
+ warnings.push({
42
+ code: 'MINIAPP_DESC_MISSING',
43
+ field: 'desc',
44
+ message: '尚未填写小程序简介。建议在 package.json#heybox.desc 中说明主要功能和适用场景,修改后重新构建。',
45
+ });
46
+ }
47
+ if (metadata.category === 'tool' &&
48
+ (metadata.bindAppIds === undefined || (Array.isArray(metadata.bindAppIds) && metadata.bindAppIds.length === 0))) {
49
+ warnings.push({
50
+ code: 'MINIAPP_TOOL_GAME_BINDING_MISSING',
51
+ field: 'bindAppIds',
52
+ message: '当前小程序为工具类,尚未关联游戏。如服务于特定 PC 游戏,可通过 hb-sdk remote games search "游戏名" 查询 appid 并填写 package.json#heybox.bindAppIds,修改后重新构建;通用工具可保持为空。',
53
+ });
54
+ }
55
+ return warnings;
56
+ }
57
+
36
58
  const CREATE_USER_MINIPROGRAM_UPLOAD_SESSION_API_PATH = '/mall/developer/user_miniprogram/version/upload_session/create';
37
59
  const RECORD_USER_MINIPROGRAM_UPLOAD_RESULT_API_PATH = '/mall/developer/user_miniprogram/version/upload_session/record';
38
60
  const COMPANION_FINALIZATION_TIMEOUT_MS = 30 * 60_000;
@@ -286,7 +308,7 @@ function createDefaultCosClient(uploadToken, COS) {
286
308
  };
287
309
  }
288
310
  async function loadCosConstructor() {
289
- const cosModule = await Promise.resolve().then(function () { return require('./index-DZUYwb3h.cjs'); }).then(function (n) { return n.index; });
311
+ const cosModule = await Promise.resolve().then(function () { return require('./index-CRwNLk5w.cjs'); }).then(function (n) { return n.index; });
290
312
  return cosModule.default;
291
313
  }
292
314
  function formatSize(bytes) {
@@ -353,144 +375,6 @@ async function computeMiniappArtifactReceipt(files, runtime = {}) {
353
375
  return { artifactSignature: hash.digest('hex'), files: preparedFiles };
354
376
  }
355
377
 
356
- const DEPLOY_LOCKED_MESSAGE = '当前设备已有同版本产物正在上传,请等待完成后重试';
357
- const DEPLOY_LOCK_DIRECTORY_NAME = 'deploy-locks';
358
- const DEPLOY_LOCK_OWNER_FILE = 'owner.json';
359
- const INCOMPLETE_LOCK_GRACE_MS = 30_000;
360
- const defaultPaths = index.envPaths('hb-sdk', { suffix: '' });
361
- class DeployLockConflictError extends Error {
362
- }
363
- async function withDeployLock(scope, operation, options = {}) {
364
- let lock;
365
- try {
366
- lock = await acquireDeployLock(scope, options);
367
- }
368
- catch (error) {
369
- if (error instanceof DeployLockConflictError) {
370
- throw error;
371
- }
372
- // 本地文件锁只减少重复操作,文件系统异常不阻断服务端上传流程。
373
- return operation();
374
- }
375
- try {
376
- return await operation();
377
- }
378
- finally {
379
- await lock.release().catch(() => undefined);
380
- }
381
- }
382
- async function acquireDeployLock(scope, options = {}) {
383
- const lockDirectory = getDeployLockDirectory(scope, options.cacheRoot);
384
- const ownerFile = path.join(lockDirectory, DEPLOY_LOCK_OWNER_FILE);
385
- const owner = {
386
- version: 1,
387
- pid: options.pid ?? process.pid,
388
- token: options.token ?? node_crypto.randomBytes(16).toString('hex'),
389
- };
390
- await fs$1.mkdir(path.dirname(lockDirectory), { recursive: true, mode: 0o700 });
391
- for (let attempt = 0; attempt < 2; attempt += 1) {
392
- let created = false;
393
- try {
394
- await fs$1.mkdir(lockDirectory, { mode: 0o700 });
395
- created = true;
396
- await fs$1.writeFile(ownerFile, `${JSON.stringify(owner)}\n`, { encoding: 'utf8', mode: 0o600 });
397
- return createDeployLock(lockDirectory, ownerFile, owner.token);
398
- }
399
- catch (error) {
400
- if (created) {
401
- await fs$1.rm(lockDirectory, { force: true, recursive: true });
402
- throw error;
403
- }
404
- if (!isNodeError(error) || error.code !== 'EEXIST') {
405
- throw error;
406
- }
407
- if (!(await canReclaimDeployLock(lockDirectory, ownerFile, options))) {
408
- throw new DeployLockConflictError(DEPLOY_LOCKED_MESSAGE);
409
- }
410
- await reclaimDeployLock(lockDirectory, owner.token);
411
- }
412
- }
413
- throw new DeployLockConflictError(DEPLOY_LOCKED_MESSAGE);
414
- }
415
- function getDeployLockDirectory(scope, cacheRoot = defaultPaths.cache) {
416
- const scopeHash = node_crypto.createHash('sha256').update(`${scope.apiBaseUrl}\0${scope.miniProgramId}\0${scope.version}`).digest('hex');
417
- return path.join(cacheRoot, DEPLOY_LOCK_DIRECTORY_NAME, scopeHash);
418
- }
419
- function createDeployLock(lockDirectory, ownerFile, token) {
420
- let released = false;
421
- return {
422
- async release() {
423
- if (released)
424
- return;
425
- released = true;
426
- await removeOwnedLock(lockDirectory, ownerFile, token);
427
- },
428
- };
429
- }
430
- async function canReclaimDeployLock(lockDirectory, ownerFile, options) {
431
- const owner = await readDeployLockOwner(ownerFile);
432
- if (owner) {
433
- return !(options.isProcessRunning ?? isProcessRunning)(owner.pid);
434
- }
435
- try {
436
- const lockStat = await fs$1.stat(lockDirectory);
437
- return (options.now ?? Date.now)() - lockStat.mtimeMs >= INCOMPLETE_LOCK_GRACE_MS;
438
- }
439
- catch (error) {
440
- return isNodeError(error) && error.code === 'ENOENT';
441
- }
442
- }
443
- async function removeOwnedLock(lockDirectory, ownerFile, token) {
444
- const owner = await readDeployLockOwner(ownerFile);
445
- if (owner?.token === token) {
446
- await fs$1.rm(lockDirectory, { force: true, recursive: true });
447
- }
448
- }
449
- async function reclaimDeployLock(lockDirectory, token) {
450
- const reclaimDirectory = `${lockDirectory}.reclaim-${node_crypto.createHash('sha256').update(token).digest('hex')}`;
451
- try {
452
- await fs$1.rename(lockDirectory, reclaimDirectory);
453
- }
454
- catch (error) {
455
- if (isNodeError(error) && error.code === 'ENOENT')
456
- return;
457
- throw error;
458
- }
459
- await fs$1.rm(reclaimDirectory, { force: true, recursive: true });
460
- }
461
- async function readDeployLockOwner(ownerFile) {
462
- try {
463
- const value = JSON.parse(await fs$1.readFile(ownerFile, 'utf8'));
464
- return isDeployLockOwner(value) ? value : null;
465
- }
466
- catch (error) {
467
- if (isNodeError(error) && error.code === 'ENOENT')
468
- return null;
469
- if (error instanceof SyntaxError)
470
- return null;
471
- throw error;
472
- }
473
- }
474
- function isDeployLockOwner(value) {
475
- return (typeof value === 'object' &&
476
- value !== null &&
477
- value.version === 1 &&
478
- Number.isInteger(value.pid) &&
479
- typeof value.token === 'string');
480
- }
481
- function isProcessRunning(pid) {
482
- try {
483
- process.kill(pid, 0);
484
- return true;
485
- }
486
- catch (error) {
487
- return !isNodeError(error) || error.code !== 'ESRCH';
488
- }
489
- }
490
- function isNodeError(error) {
491
- return error instanceof Error && 'code' in error;
492
- }
493
-
494
378
  /** 发布提示使用显式声明与远端主体批准策略,不消费本地调试授权。 */
495
379
  function getUnapprovedPermissionWarning(local, approvals, partyType) {
496
380
  if (!local.declared)
@@ -610,7 +494,7 @@ async function runDeployCommand(options, runtime = {}) {
610
494
  const buildScript = await readProjectBuildScript(projectRoot);
611
495
  logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode, buildScript).join(' ')}`);
612
496
  await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
613
- env: runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp),
497
+ env: { ...runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp), HB_SDK_DEFER_METADATA_WARNINGS: '1' },
614
498
  mode: buildMode,
615
499
  outputMode: options.buildOutputMode ?? 'inherit',
616
500
  platform,
@@ -627,6 +511,9 @@ async function runDeployCommand(options, runtime = {}) {
627
511
  const distDir = path.join(projectRoot, 'dist');
628
512
  const parsedManifest = await readDeployManifest(projectRoot, logger);
629
513
  ({ manifest, version } = parsedManifest);
514
+ for (const warning of getMiniappMetadataWarnings(manifest)) {
515
+ logger.warn(`[${warning.code}] ${warning.message}`, { stream: 'stderr' });
516
+ }
630
517
  if (manifest.category !== declaredCategory) {
631
518
  throw new Error('dist/manifest.json.category 与 package.json#heybox.category 不一致,请重新 build 后再 deploy');
632
519
  }
@@ -792,7 +679,7 @@ async function runDeployCommand(options, runtime = {}) {
792
679
  version,
793
680
  };
794
681
  };
795
- return (runtime.withDeployLock ?? withDeployLock)({ apiBaseUrl, miniProgramId, version: uploadVersion }, deploy);
682
+ return (runtime.withDeployLock ?? deployLock.withDeployLock)({ apiBaseUrl, miniProgramId, version: uploadVersion }, deploy);
796
683
  }
797
684
  function printDeploySuccess(options) {
798
685
  options.logger.success(`提交审核成功:${options.miniProgramId} ${options.version}`);
@@ -5,8 +5,8 @@ require('node:module');
5
5
  require('node:url');
6
6
  var fs = require('node:fs');
7
7
  var path = require('node:path');
8
- var runtimePermissionEnv = require('./runtime-permission-env-B9SqoP85.cjs');
9
- var index = require('./index-bZIxID9N.cjs');
8
+ var runtimePermissionEnv = require('./runtime-permission-env-CbqmHz0r.cjs');
9
+ var index = require('./index-hYvQR19Q.cjs');
10
10
  var _commonjsDynamicModules = require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
11
11
  var require$$0$1 = require('fs');
12
12
  var require$$1 = require('path');
@@ -201912,6 +201912,7 @@ const RUNTIME_GATE_BOOTSTRAP_MARKER = 'data-heybox-runtime-gate-bootstrap';
201912
201912
  * @param html - 待检查的完整 HTML 文本,使用 HTML parser 解析。
201913
201913
  * @returns Gate、隐藏样式及 bootstrap 标记均出现时返回 `true`,否则返回 `false`。
201914
201914
  * @remarks 只识别标记,不验证脚本内容、标记所在节点或宿主握手;不能据此判断页面安全或实际可运行。
201915
+ * @since 0.8.2
201915
201916
  */
201916
201917
  function hasMiniappRuntimeGate(html) {
201917
201918
  const document = parse(html);
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-bZIxID9N.cjs');
3
+ var index = require('./index-hYvQR19Q.cjs');
4
4
  var fs = require('node:fs');
5
5
  var path = require('node:path');
6
- var version$1 = require('./version-CwEOrhL1.cjs');
6
+ var version$1 = require('./version-BQMfLqms.cjs');
7
7
  require('node:crypto');
8
8
  var node_async_hooks = require('node:async_hooks');
9
9
 
@@ -247,6 +247,7 @@ const MANAGED_RUNTIME_PERMISSION_KEYS = new Set(MINI_PROGRAM_PERMISSION_KEYS);
247
247
  * @see [parseMiniProgramRuntimePermissions](/reference/symbols/protocol/functions/parseMiniProgramRuntimePermissions) 完整 snapshot 的 trim、legacy 归一化与 config 校验。
248
248
  * @see [MINI_PROGRAM_PROTOCOL_CAPABILITIES](/reference/symbols/protocol/constants/MINI_PROGRAM_PROTOCOL_CAPABILITIES) method 到 permission requirement 的权威映射。
249
249
  * @see [权限声明](/guide/permissions) Manifest 声明、平台批准与 Runtime 状态的完整流程。
250
+ * @since 0.6.4
250
251
  */
251
252
  function isManagedMiniProgramRuntimePermissionKey(key) {
252
253
  return MANAGED_RUNTIME_PERMISSION_KEYS.has(key);
@@ -322,6 +323,7 @@ function isManagedMiniProgramRuntimePermissionKey(key) {
322
323
  * @see {@link isManagedMiniProgramRuntimePermissionKey}
323
324
  * @see {@link MINI_PROGRAM_PROTOCOL_CAPABILITIES}
324
325
  * @see {@link https://docs.xiaoheihe.cn/hb_sdk/guide/permissions | 权限声明}
326
+ * @since 0.6.4
325
327
  */
326
328
  function parseMiniProgramRuntimePermissions(snapshot) {
327
329
  if (!isRecord$2$1(snapshot) || snapshot.schema_version !== 1 || !Array.isArray(snapshot.entries)) {
@@ -6955,6 +6957,7 @@ function serializeMiniProgramDevelopmentSnapshot(snapshot) {
6955
6957
  * @param sourceLabel - 错误消息中的字段来源,默认 `package.json#heybox.category`。
6956
6958
  * @returns 合法类别原值;输入 `undefined` 时返回 `undefined`,由发布流程另行检查是否必填。
6957
6959
  * @throws `Error` 输入为其他值(包括 null 或空字符串)时抛出带字段来源的错误。
6960
+ * @since 0.8.3
6958
6961
  */
6959
6962
  function parseMiniappCategory(value, sourceLabel = 'package.json#heybox.category') {
6960
6963
  if (value === undefined)
@@ -6973,6 +6976,7 @@ const BASIC_INFO_MAX_PIXELS = 40_000_000;
6973
6976
  * @returns NFKC 规范化、去除首尾 Unicode White_Space 后的名称;不折叠规范化后的内部空白。
6974
6977
  * @throws `Error` 输入不是字符串,或规范化后不是 1–40 个 Unicode code point、不含文字或数字,或包含控制字符、
6975
6978
  * 格式字符、行/段分隔符以及 HTML 特殊字符 `<`、`>`、`&`、双引号或单引号时抛出。
6979
+ * @since 0.8.2
6976
6980
  */
6977
6981
  function normalizeBasicInfoName(raw) {
6978
6982
  if (typeof raw !== 'string')
@@ -7004,6 +7008,7 @@ function validateBasicInfoPath(raw) {
7004
7008
  * @remarks
7005
7009
  * 图片路径必须使用 `/` 分隔的非空相对路径,扩展名为 JPEG、PNG、GIF 或 WebP;拒绝 URL、点段、
7006
7010
  * 控制字符和构建/缓存等保留目录。此函数只校验声明,不读取文件,也不验证图片字节、尺寸或存在性。
7011
+ * @since 0.8.2
7007
7012
  */
7008
7013
  function parseMiniappBasicInfo(value, sdkVersion = '0.8.2') {
7009
7014
  sdkVersion = sdkVersion.trim();
@@ -7076,6 +7081,7 @@ const MINIAPP_BIND_APP_IDS_MAX_COUNT = 20;
7076
7081
  * @see [miniappManifest](/reference/symbols/vite/functions/miniappManifest)
7077
7082
  * @see [navigation.openAppPage](/reference/sdk/navigation/openAppPage)
7078
7083
  * @see [CLI 与远端发布](/guide/cli#生产构建)
7084
+ * @since 0.8.1
7079
7085
  */
7080
7086
  function parseMiniappBindAppIds(value, options = {}) {
7081
7087
  const sourceLabel = options.sourceLabel ?? 'package.json#heybox.bindAppIds';
@@ -7312,6 +7318,7 @@ function hasMiniappDesktopPlatform(platforms) {
7312
7318
  *
7313
7319
  * @see {@link resolveMiniappManifestPlatforms}
7314
7320
  * @see {@link https://docs.xiaoheihe.cn/hb_sdk/reference/symbols/vite/functions/miniappManifest | miniappManifest}
7321
+ * @since 0.3.1
7315
7322
  */
7316
7323
  function isValidMiniappManifestVersion(version) {
7317
7324
  return getMiniappManifestVersionError(version) === undefined;
@@ -7350,6 +7357,7 @@ function parseMiniappManifestJson(raw, sourceLabel = 'manifest.json') {
7350
7357
  * @remarks
7351
7358
  * 不修改输入对象,不执行文件 I/O;不会验证图片/归档是否存在、内容摘要是否匹配,也不查询远端发布资格。
7352
7359
  * 成功仅表示 Manifest 字段通过校验,不能替代文件检查与服务端发布预检。
7360
+ * @since 0.8.2
7353
7361
  */
7354
7362
  function validateMiniappManifestForDeploy(manifest) {
7355
7363
  const version = validateMiniappManifestVersion(manifest.version, 'manifest.version');
@@ -15890,6 +15898,7 @@ const textEncoder = new TextEncoder();
15890
15898
  * @see {@link relativePathContainsNodeModulesSegment}
15891
15899
  * @see {@link shouldUploadDistFile}
15892
15900
  * @see {@link https://docs.xiaoheihe.cn/hb_sdk/reference/symbols/protocol/functions/isMiniProgramRelativePath | isMiniProgramRelativePath}
15901
+ * @since 0.3.1
15893
15902
  */
15894
15903
  function normalizeRelativePath(relativePath) {
15895
15904
  return String(relativePath || '')
@@ -15920,6 +15929,7 @@ function normalizeRelativePath(relativePath) {
15920
15929
  * @see [normalizeRelativePath](/reference/symbols/miniapp-publish/functions/normalizeRelativePath)
15921
15930
  * @see [shouldUploadDistFile](/reference/symbols/miniapp-publish/functions/shouldUploadDistFile)
15922
15931
  * @see [miniapp-publish](/reference/miniapp-publish/)
15932
+ * @since 0.3.1
15923
15933
  */
15924
15934
  function relativePathContainsNodeModulesSegment(relativePath) {
15925
15935
  return normalizeRelativePath(relativePath)
@@ -16003,6 +16013,7 @@ function getMiniProgramUploadAlias(miniProgramId) {
16003
16013
  * @see {@link ValidateUploadTotalSizeOptions}
16004
16014
  * @see [shouldUploadDistFile](/reference/symbols/miniapp-publish/functions/shouldUploadDistFile)
16005
16015
  * @see [miniapp-publish](/reference/miniapp-publish/)
16016
+ * @since 0.4.7
16006
16017
  */
16007
16018
  function validateUploadTotalSize(items, options = {}) {
16008
16019
  const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
@@ -16095,6 +16106,7 @@ function validateMiniappUploadSizeBudgets(items, options = {}) {
16095
16106
  * @see [relativePathContainsNodeModulesSegment](/reference/symbols/miniapp-publish/functions/relativePathContainsNodeModulesSegment)
16096
16107
  * @see [validateUploadTotalSize](/reference/symbols/miniapp-publish/functions/validateUploadTotalSize)
16097
16108
  * @see [miniapp-publish](/reference/miniapp-publish/)
16109
+ * @since 0.3.1
16098
16110
  */
16099
16111
  function shouldUploadDistFile(relativePath) {
16100
16112
  const normalized = normalizeRelativePath(relativePath);
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-CwEOrhL1.cjs');
3
+ var version = require('./version-BQMfLqms.cjs');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
6
  var childProcess = require('node:child_process');
7
- var index = require('./index-bZIxID9N.cjs');
7
+ var index = require('./index-hYvQR19Q.cjs');
8
8
  require('node:module');
9
9
  require('readline');
10
10
  require('os');
@@ -3,6 +3,6 @@
3
3
  /** 构建时替换为当前发布包的实际版本。 */
4
4
  const HB_SDK_VERSION = typeof undefined === 'string'
5
5
  ? undefined
6
- : '0.9.2-alpha.7';
6
+ : '0.9.2-alpha.9';
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-bZIxID9N.cjs');
3
+ var index = require('./cli-chunks/index-hYvQR19Q.cjs');
4
4
  require('node:module');
5
5
  require('readline');
6
6
  require('os');