@heybox/hb-sdk 0.9.8-alpha.1 → 0.9.8-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -0
  3. package/dist/cli-chunks/{artifact-DjBgoh5t.cjs → artifact-DpPkKB0p.cjs} +3 -3
  4. package/dist/cli-chunks/{build-BqCFUfmY.cjs → build-HnEZU7vh.cjs} +5 -5
  5. package/dist/cli-chunks/{create-C_vnYgLI.cjs → create-CoQZAi2o.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-Z3taoc-T.cjs → dev-DxvriNGb.cjs} +112 -14
  7. package/dist/cli-chunks/{dev-context-C82TNyzm.cjs → dev-context-rMlSIJDh.cjs} +2 -2
  8. package/dist/cli-chunks/{doctor-DDIsyoxg.cjs → doctor-BM6HYc6Q.cjs} +1 -1
  9. package/dist/cli-chunks/{games-CTCD0YEP.cjs → games-BdBtXI0v.cjs} +1 -1
  10. package/dist/cli-chunks/{index-DCu4v5vi.cjs → index-B3G8sxcs.cjs} +1 -1
  11. package/dist/cli-chunks/{index-BiV06A8-.cjs → index-D0s71o42.cjs} +20 -19
  12. package/dist/cli-chunks/{index.esm-BRUvLPPL.cjs → index.esm-7M7Fm5fI.cjs} +6 -6
  13. package/dist/cli-chunks/{login-DrWMllmo.cjs → login-utKL8hNg.cjs} +1 -1
  14. package/dist/cli-chunks/{project-vite-Bt1IWMur.cjs → project-vite-BGZ0nd6-.cjs} +1 -1
  15. package/dist/cli-chunks/{remote-CtJrk68J.cjs → remote-CgYHLC8e.cjs} +7 -7
  16. package/dist/cli-chunks/{runtime-permission-env-CIoMGBsf.cjs → runtime-permission-env-DcWIfDXK.cjs} +2 -2
  17. package/dist/cli-chunks/{skill-B2MlFRqa.cjs → skill-BXKBDPnA.cjs} +2 -2
  18. package/dist/cli-chunks/{version-DWFMQ8sw.cjs → version-BeddnZpt.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-W4n05_Hx.js → browser-dev-host-zYzCEWEd.js} +1 -1
  21. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CCRhmr4a.js → desktop-app-launch-CaciTQhd.js} +1 -1
  22. package/dist/devtools/browser-dev-host/assets/{index-I6DUyM3f.js → index-CLEAsVY-.js} +3 -3
  23. package/dist/devtools/browser-dev-host/index.html +2 -2
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/vite.cjs.js +1 -1
  27. package/dist/vite.esm.js +1 -1
  28. package/package.json +6 -6
  29. package/skill/skill.json +4 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  本文件随 `@heybox/hb-sdk` npm 包公开分发,只记录外部小程序开发者可观察到的变化。
4
4
 
5
+ ## 0.9.8-alpha.2 - 2026-11-10
6
+
7
+ ### 文档与工具
8
+
9
+ - [`hb-sdk remote deploy`](https://docs.xiaoheihe.cn/hb_sdk/guide/cli) 默认在审核通过后自动发布;需要手动控制上线时机时,请追加 `--no-auto-publish`。
10
+
5
11
  ## 0.9.7 - 2026-11-07
6
12
 
7
13
  ### 问题修复
package/README.md CHANGED
@@ -44,6 +44,8 @@ hb-sdk build
44
44
  hb-sdk remote deploy --release-note "本次更新说明"
45
45
  ```
46
46
 
47
+ `remote deploy` 默认在审核通过后自动发布。需要手动控制上线时机时,追加 `--no-auto-publish`。
48
+
47
49
  - [CLI 与调试台交互](https://docs.xiaoheihe.cn/hb_sdk/guide/agent-preview):服务发现、浏览器授权、机型、重载、截图和日志。
48
50
  - [Playwright 交互](https://docs.xiaoheihe.cn/hb_sdk/guide/preview-playwright):连接当前页面、宿主弹窗、资源与诊断。
49
51
  - [开发会话日志](./docs/device-logs.md):按目标、实例或调用排错。
@@ -3,9 +3,9 @@
3
3
  var fs = require('node:fs');
4
4
  var fs$1 = require('node:fs/promises');
5
5
  var path = require('node:path');
6
- var runtimePermissionEnv = require('./runtime-permission-env-CIoMGBsf.cjs');
7
- require('./version-DWFMQ8sw.cjs');
8
- var index = require('./index-BiV06A8-.cjs');
6
+ var runtimePermissionEnv = require('./runtime-permission-env-DcWIfDXK.cjs');
7
+ require('./version-BeddnZpt.cjs');
8
+ var index = require('./index-D0s71o42.cjs');
9
9
  var index_esm = require('./index.esm-CvMA_ppV.cjs');
10
10
  var node_crypto = require('node:crypto');
11
11
  require('node:zlib');
@@ -2,15 +2,15 @@
2
2
 
3
3
  var fs = require('node:fs/promises');
4
4
  var path = require('node:path');
5
- var runtimePermissionEnv = require('./runtime-permission-env-CIoMGBsf.cjs');
6
- var index = require('./index-BiV06A8-.cjs');
5
+ var runtimePermissionEnv = require('./runtime-permission-env-DcWIfDXK.cjs');
6
+ var index = require('./index-D0s71o42.cjs');
7
7
  require('./index.esm-CvMA_ppV.cjs');
8
8
  require('node:crypto');
9
9
  require('node:fs');
10
10
  require('node:zlib');
11
- var artifact = require('./artifact-DjBgoh5t.cjs');
12
- var projectVite = require('./project-vite-Bt1IWMur.cjs');
13
- require('./version-DWFMQ8sw.cjs');
11
+ var artifact = require('./artifact-DpPkKB0p.cjs');
12
+ var projectVite = require('./project-vite-BGZ0nd6-.cjs');
13
+ require('./version-BeddnZpt.cjs');
14
14
  require('node:async_hooks');
15
15
  require('node:module');
16
16
  require('readline');
@@ -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-BiV06A8-.cjs');
8
+ var index = require('./index-D0s71o42.cjs');
9
9
  var index_esm = require('./index.esm-CvMA_ppV.cjs');
10
10
  require('node:module');
11
11
  require('readline');
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BiV06A8-.cjs');
3
+ var index = require('./index-D0s71o42.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var fs = require('node:fs');
6
6
  var path = require('node:path');
7
7
  var index_esm = require('./index.esm-CvMA_ppV.cjs');
8
- var version = require('./version-DWFMQ8sw.cjs');
9
- var runtimePermissionEnv = require('./runtime-permission-env-CIoMGBsf.cjs');
8
+ var version = require('./version-BeddnZpt.cjs');
9
+ var runtimePermissionEnv = require('./runtime-permission-env-DcWIfDXK.cjs');
10
10
  require('node:zlib');
11
- var devContext = require('./dev-context-C82TNyzm.cjs');
11
+ var devContext = require('./dev-context-rMlSIJDh.cjs');
12
12
  var os = require('node:os');
13
13
  var net = require('node:net');
14
14
  var promises = require('node:dns/promises');
@@ -30,7 +30,7 @@ var require$$0$2 = require('stream');
30
30
  var require$$0$3 = require('url');
31
31
  var require$$5 = require('zlib');
32
32
  var require$$1 = require('util');
33
- var projectVite = require('./project-vite-Bt1IWMur.cjs');
33
+ var projectVite = require('./project-vite-BGZ0nd6-.cjs');
34
34
 
35
35
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
36
36
  const DEFAULT_DEV_CONTEXT_TIMEOUT_MS = 3000;
@@ -3317,8 +3317,8 @@ const DEFAULT_CHANNEL_TRANSPORT = {
3317
3317
  };
3318
3318
  const IPV4_LOOPBACK_ADDRESSES = new net.BlockList();
3319
3319
  IPV4_LOOPBACK_ADDRESSES.addSubnet('127.0.0.0', 8, 'ipv4');
3320
- const { WebSocket: WebSocket$1, WebSocketServer: WebSocketServer$1 } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-Z3taoc-T.cjs', document.baseURI).href)))('ws');
3321
- const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-Z3taoc-T.cjs', document.baseURI).href)))('parse5');
3320
+ const { WebSocket: WebSocket$1, WebSocketServer: WebSocketServer$1 } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-DxvriNGb.cjs', document.baseURI).href)))('ws');
3321
+ const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-DxvriNGb.cjs', document.baseURI).href)))('parse5');
3322
3322
  const BROWSER_DEV_HOST_ROOT_CANDIDATES = [
3323
3323
  path.resolve(__dirname, 'devtools/browser-dev-host'),
3324
3324
  path.resolve(__dirname, '../devtools/browser-dev-host'),
@@ -12676,7 +12676,7 @@ function assertNodeRuntimeCapabilities(ctx, settings) {
12676
12676
  function createNodeRealtimeDriverRegistry() {
12677
12677
  const registry = createRuntimeRealtimeDriverRegistry();
12678
12678
  registry.registerLazy('node-websocket', async () => {
12679
- const mod = await Promise.resolve().then(function () { return require('./index.esm-BRUvLPPL.cjs'); });
12679
+ const mod = await Promise.resolve().then(function () { return require('./index.esm-7M7Fm5fI.cjs'); });
12680
12680
  return mod.createNodeWebSocketRuntimeDriver();
12681
12681
  });
12682
12682
  return registry;
@@ -15379,7 +15379,28 @@ var md5Exports = requireMd5();
15379
15379
  * @packageDocumentation
15380
15380
  * 封装 runtime security 使用的同步密码学原语。
15381
15381
  */
15382
- new TextEncoder();
15382
+ const textEncoder = new TextEncoder();
15383
+ /**
15384
+ * 把 UTF-8 字符串转换为字节数组。
15385
+ *
15386
+ * @param value - 待转换字符串。
15387
+ */
15388
+ function encodeUtf8(value) {
15389
+ return textEncoder.encode(value);
15390
+ }
15391
+ /**
15392
+ * 把字节数组转换为 Base64,兼容浏览器和 Node 测试环境。
15393
+ *
15394
+ * @param value - 待编码字节数组。
15395
+ */
15396
+ function encodeBase64(value) {
15397
+ let binary = '';
15398
+ const chunkSize = 0x8000;
15399
+ for (let offset = 0; offset < value.length; offset += chunkSize) {
15400
+ binary += String.fromCharCode(...value.subarray(offset, offset + chunkSize));
15401
+ }
15402
+ return btoa(binary);
15403
+ }
15383
15404
  /**
15384
15405
  * 计算小写十六进制 MD5。该能力仅用于兼容既有服务端协议。
15385
15406
  *
@@ -15418,6 +15439,45 @@ function createHeyboxRND15Signature(nonce, data) {
15418
15439
  return createHmacSha256Hex(message, HEYBOX_RND_15_SECRET);
15419
15440
  }
15420
15441
 
15442
+ /** RND 16 固定密钥;与后端受控同步,禁止记录到日志或文档。 */
15443
+ const HEYBOX_RND_16_KEY_BASE64 = 'HFFSTsqmvG3uGxPNXDQW+1VARfqgG4nT6LS1PX7F8NQ=';
15444
+
15445
+ /** @packageDocumentation 提供 Heybox RND 16 的 AES-256-GCM 请求认证能力。 */
15446
+ /**
15447
+ * 计算 RND 16 的 Base64URL payload,不包含 `16:` 前缀。
15448
+ *
15449
+ * 使用固定 32 字节密钥、独立随机 12 字节 IV、128 位认证标签和固定 AAD。
15450
+ * 输出为 `Base64URL(IV || ciphertext || tag)`,不带 padding;不会降级为 v15。
15451
+ *
15452
+ * @param input - 本次请求的 Web V4 参数和实际 pathname。
15453
+ * @param options - 协议测试或特殊宿主配置,默认生成密码学安全随机 IV。
15454
+ */
15455
+ async function createHeyboxRND16Signature(input, options = {}) {
15456
+ const time = String(input.time);
15457
+ if (!/^(0|[1-9]\d*)$/.test(time) ||
15458
+ !Number.isSafeInteger(Number(time)) ||
15459
+ !/^[0-9A-F]{32}$/.test(input.nonce) ||
15460
+ !input.pathname.startsWith('/') ||
15461
+ /[\s?#\\]/.test(input.pathname) ||
15462
+ /[^\x21-\x7e]/.test(input.pathname)) {
15463
+ throw new Error('RND16 请求参数无效');
15464
+ }
15465
+ const key = Uint8Array.from(atob(options.keyBase64 ?? HEYBOX_RND_16_KEY_BASE64), (char) => char.charCodeAt(0));
15466
+ if (key.length !== 32)
15467
+ throw new Error('RND16 密钥长度无效');
15468
+ const iv = options.iv ? new Uint8Array(options.iv) : globalThis.crypto.getRandomValues(new Uint8Array(12));
15469
+ if (iv.length !== 12)
15470
+ throw new Error('RND16 IV 长度无效');
15471
+ const cryptoKey = await globalThis.crypto.subtle.importKey('raw', key, { name: 'AES-GCM' }, false, ['encrypt']);
15472
+ const pathname = input.pathname.endsWith('/') ? input.pathname : `${input.pathname}/`;
15473
+ const plaintext = encodeUtf8(JSON.stringify([time, input.nonce, pathname]));
15474
+ const sealed = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv, additionalData: encodeUtf8('heybox-rnd:v16'), tagLength: 128 }, cryptoKey, plaintext);
15475
+ const payload = new Uint8Array(iv.length + sealed.byteLength);
15476
+ payload.set(iv);
15477
+ payload.set(new Uint8Array(sealed), iv.length);
15478
+ return encodeBase64(payload).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
15479
+ }
15480
+
15421
15481
  /**
15422
15482
  * @packageDocumentation
15423
15483
  * 提供 Heybox Web V4 请求签名参数生成能力。
@@ -15910,7 +15970,7 @@ function applyHeyboxWebV4Signing(config) {
15910
15970
  if (!shouldSignHeyboxWebV4Request(config)) {
15911
15971
  return config;
15912
15972
  }
15913
- const pathname = stripRuntimeRequestTargetDevPrefix(normalizeHeyboxWebV4Pathname(config.url));
15973
+ const pathname = config.security?.rnd === '16' ? resolveRND16Pathname(config) : stripRuntimeRequestTargetDevPrefix(normalizeHeyboxWebV4Pathname(config.url));
15914
15974
  return {
15915
15975
  ...config,
15916
15976
  query: {
@@ -15920,16 +15980,32 @@ function applyHeyboxWebV4Signing(config) {
15920
15980
  };
15921
15981
  }
15922
15982
  /**
15923
- * 在 Web V4 参数生成后追加可选的 RND 15 签名。
15983
+ * 在 Web V4 参数生成后追加选定版本的 RND;v15 保留历史行为,v16 失败时中止请求。
15924
15984
  *
15925
15985
  * @param config - 已完成 Web V4 签名的请求配置。
15926
15986
  */
15927
- function applyHeyboxRND15Signing(config) {
15928
- if (config.security?.rnd !== '15') {
15987
+ function applyHeyboxRNDSigning(config) {
15988
+ const version = config.security?.rnd;
15989
+ if (version !== '15' && version !== '16') {
15929
15990
  return config;
15930
15991
  }
15931
15992
  const nonce = config.query?.nonce;
15932
15993
  const time = config.query?._time;
15994
+ if (version === '16') {
15995
+ if (!shouldSignHeyboxWebV4Request(config) || typeof nonce !== 'string' || (typeof time !== 'string' && typeof time !== 'number')) {
15996
+ throw new RuntimeError({
15997
+ code: 'runtime.request.rnd16_signing_unavailable',
15998
+ domain: 'request',
15999
+ message: 'RND16 需要启用第一方 Web V4 签名并提供有效公参',
16000
+ });
16001
+ }
16002
+ const pathname = resolveRND16Pathname(config);
16003
+ return createHeyboxRND16Signature({ time, nonce, pathname }).then((payload) => ({
16004
+ ...config,
16005
+ url: removeRND16ReservedURLParams(normalizeRND16RequestURL(config.url)),
16006
+ query: { ...config.query, _rnd: `16:${payload}` },
16007
+ }));
16008
+ }
15933
16009
  if (typeof nonce !== 'string' || (typeof time !== 'string' && typeof time !== 'number')) {
15934
16010
  return config;
15935
16011
  }
@@ -15941,6 +16017,28 @@ function applyHeyboxRND15Signing(config) {
15941
16017
  },
15942
16018
  };
15943
16019
  }
16020
+ /** 与 Fetch 的 baseURL 拼接语义一致,让 v16 的 Web V4 和 RND 绑定同一个实际服务路径。 */
16021
+ function resolveRND16Pathname(config) {
16022
+ const url = config.baseURL && !isAbsoluteRequestURL(config.url) ? `${config.baseURL.replace(/\/+$/, '')}/${config.url.replace(/^\/+/, '')}` : config.url;
16023
+ const pathname = stripRuntimeRequestTargetDevPrefix(normalizeHeyboxWebV4Pathname(url));
16024
+ return pathname.endsWith('/') ? pathname : `${pathname}/`;
16025
+ }
16026
+ /** v16 的协议相对 URL 显式使用 HTTPS,避免 Fetch 拼接 baseURL;保留原始路径。 */
16027
+ function normalizeRND16RequestURL(url) {
16028
+ return url.startsWith('//') ? `https:${url}` : url;
16029
+ }
16030
+ /** 清除 URL 中旧的安全公参,避免与本次生成的 query 重复发送。 */
16031
+ function removeRND16ReservedURLParams(url) {
16032
+ const [pathAndQuery, hash] = url.split('#', 2);
16033
+ const queryIndex = pathAndQuery.indexOf('?');
16034
+ if (queryIndex < 0)
16035
+ return url;
16036
+ const query = new URLSearchParams(pathAndQuery.slice(queryIndex + 1));
16037
+ for (const key of ['_rnd', '_time', 'nonce', 'hkey', 'version'])
16038
+ query.delete(key);
16039
+ const search = query.toString();
16040
+ return `${pathAndQuery.slice(0, queryIndex)}${search ? `?${search}` : ''}${hash === undefined ? '' : `#${hash}`}`;
16041
+ }
15944
16042
 
15945
16043
  /**
15946
16044
  * @packageDocumentation
@@ -16332,7 +16430,7 @@ function applyHeyboxLegacyWebDefaults(config) {
16332
16430
  * @param config - 已完成 query 合并的请求配置。
16333
16431
  */
16334
16432
  function applyHeyboxBrowserRequest(config) {
16335
- return applyHeyboxRND15Signing(applyHeyboxWebV4Signing(applyHeyboxLegacyWebDefaults(config)));
16433
+ return applyHeyboxRNDSigning(applyHeyboxWebV4Signing(applyHeyboxLegacyWebDefaults(config)));
16336
16434
  }
16337
16435
  /**
16338
16436
  * 把请求错误转换为 legacy `$get` / `$post` 兼容响应。
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BiV06A8-.cjs');
4
- var runtimePermissionEnv = require('./runtime-permission-env-CIoMGBsf.cjs');
3
+ var index = require('./index-D0s71o42.cjs');
4
+ var runtimePermissionEnv = require('./runtime-permission-env-DcWIfDXK.cjs');
5
5
  var node_crypto = require('node:crypto');
6
6
  var fs = require('node:fs/promises');
7
7
  var path = require('node:path');
@@ -3,7 +3,7 @@
3
3
  var fs = require('node:fs/promises');
4
4
  var os = require('node:os');
5
5
  var path = require('node:path');
6
- var index = require('./index-BiV06A8-.cjs');
6
+ var index = require('./index-D0s71o42.cjs');
7
7
  require('node:module');
8
8
  require('readline');
9
9
  require('os');
@@ -3,7 +3,7 @@
3
3
  var node_crypto = require('node:crypto');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
- var index = require('./index-BiV06A8-.cjs');
6
+ var index = require('./index-D0s71o42.cjs');
7
7
  require('node:module');
8
8
  require('readline');
9
9
  require('os');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-BiV06A8-.cjs');
3
+ var index$2 = require('./index-D0s71o42.cjs');
4
4
  var require$$0$3 = require('fs');
5
5
  var require$$0$2 = require('crypto');
6
6
  var require$$1$2 = require('path');
@@ -242,19 +242,19 @@ function requireArgument () {
242
242
 
243
243
  var command = {};
244
244
 
245
- 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-BiV06A8-.cjs', document.baseURI).href)));
245
+ 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-D0s71o42.cjs', document.baseURI).href)));
246
246
  function __require$4() { return require$5("node:events"); }
247
247
 
248
- 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-BiV06A8-.cjs', document.baseURI).href)));
248
+ 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-D0s71o42.cjs', document.baseURI).href)));
249
249
  function __require$3() { return require$4("node:child_process"); }
250
250
 
251
- 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-BiV06A8-.cjs', document.baseURI).href)));
251
+ 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-D0s71o42.cjs', document.baseURI).href)));
252
252
  function __require$2() { return require$3("node:path"); }
253
253
 
254
- 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-BiV06A8-.cjs', document.baseURI).href)));
254
+ 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-D0s71o42.cjs', document.baseURI).href)));
255
255
  function __require$1() { return require$2("node:fs"); }
256
256
 
257
- 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-BiV06A8-.cjs', document.baseURI).href)));
257
+ 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-D0s71o42.cjs', document.baseURI).href)));
258
258
  function __require() { return require$1("node:process"); }
259
259
 
260
260
  var help = {};
@@ -17253,7 +17253,7 @@ async function inspectFeedbackLog(file, size) {
17253
17253
  return { mimeType: 'text/plain', width: 0, height: 0 };
17254
17254
  }
17255
17255
  async function createFeedbackCosClient(getToken) {
17256
- const { default: COS } = await Promise.resolve().then(function () { return require('./index-DCu4v5vi.cjs'); }).then(function (n) { return n.index; });
17256
+ const { default: COS } = await Promise.resolve().then(function () { return require('./index-B3G8sxcs.cjs'); }).then(function (n) { return n.index; });
17257
17257
  const cos = new COS({
17258
17258
  getAuthorization(_options, callback) {
17259
17259
  void getToken().then((token) => callback({
@@ -21935,7 +21935,7 @@ function installDevPreviewCommands(dev) {
21935
21935
  }
21936
21936
 
21937
21937
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
21938
- const BUILT_CLI_VERSION = '0.9.8-alpha.1';
21938
+ const BUILT_CLI_VERSION = '0.9.8-alpha.2';
21939
21939
  const PACKAGE_JSON_CANDIDATES$1 = [
21940
21940
  path.resolve(__dirname, '..', '..', 'package.json'),
21941
21941
  path.resolve(__dirname, '..', 'package.json'),
@@ -23225,13 +23225,14 @@ function installRemoteCommands(program, handlers, resolveLogger) {
23225
23225
  .command('deploy')
23226
23226
  .description('构建并提交当前小程序版本审核')
23227
23227
  .option('--release-note <text>', '发布日志,提交审核必填')
23228
- .option('--auto-publish', '审核通过后自动发布;默认需在 CLI 中手动发布')
23228
+ .option('--auto-publish', '审核通过后自动发布(默认开启)', true)
23229
+ .option('--no-auto-publish', '关闭自动发布,审核通过后需手动发布')
23229
23230
  // 根程序开启位置化解析后,子命令需要自己声明这两个根级选项才能继续支持 deploy --env / --env-file。
23230
23231
  .option('--env <name>', '加载项目根下 .env.<name> 预设')
23231
23232
  .option('--env-file <path>', '显式指定 .env 文件路径,优先级高于 --env')).action(createRemoteAction(handlers, resolveLogger, 'deploy', (command) => {
23232
23233
  const options = readCommandOptionsWithAncestors(command);
23233
23234
  return {
23234
- autoPublish: Boolean(options.autoPublish),
23235
+ autoPublish: options.autoPublish ?? true,
23235
23236
  releaseNote: readStringOption(options.releaseNote),
23236
23237
  };
23237
23238
  }));
@@ -23346,39 +23347,39 @@ function createCommandLoggerResolver(options) {
23346
23347
  };
23347
23348
  }
23348
23349
  const defaultClearLoginStatus = async (...args) => {
23349
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DrWMllmo.cjs'); });
23350
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-utKL8hNg.cjs'); });
23350
23351
  return clearLoginStatus(...args);
23351
23352
  };
23352
23353
  const defaultLoginToHeybox = async (...args) => {
23353
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DrWMllmo.cjs'); });
23354
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-utKL8hNg.cjs'); });
23354
23355
  return loginToHeybox(...args);
23355
23356
  };
23356
23357
  const defaultPrintLoginStatus = async (...args) => {
23357
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DrWMllmo.cjs'); });
23358
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-utKL8hNg.cjs'); });
23358
23359
  return printLoginStatus(...args);
23359
23360
  };
23360
23361
  const defaultRunBuildCommand = async (...args) => {
23361
- const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-BqCFUfmY.cjs'); });
23362
+ const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-HnEZU7vh.cjs'); });
23362
23363
  return runBuildCommand(...args);
23363
23364
  };
23364
23365
  const defaultRunCreateCommand = async (...args) => {
23365
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-C_vnYgLI.cjs'); });
23366
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CoQZAi2o.cjs'); });
23366
23367
  return runCreateCommand(...args);
23367
23368
  };
23368
23369
  const defaultRunDevCommand = async (...args) => {
23369
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-Z3taoc-T.cjs'); }).then(function (n) { return n.dev; });
23370
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-DxvriNGb.cjs'); }).then(function (n) { return n.dev; });
23370
23371
  return runDevCommand(...args);
23371
23372
  };
23372
23373
  const defaultRunDoctorCommand = async (...args) => {
23373
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-DDIsyoxg.cjs'); });
23374
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-BM6HYc6Q.cjs'); });
23374
23375
  return runDoctorCommand(...args);
23375
23376
  };
23376
23377
  const defaultRunSkillInstallCommand = async (...args) => {
23377
- const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-B2MlFRqa.cjs'); });
23378
+ const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-BXKBDPnA.cjs'); });
23378
23379
  return runSkillInstallCommand(...args);
23379
23380
  };
23380
23381
  const defaultRunRemoteCommand = async (...args) => {
23381
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-CtJrk68J.cjs'); });
23382
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-CgYHLC8e.cjs'); });
23382
23383
  return runRemoteCommand(...args);
23383
23384
  };
23384
23385
  function resolveStandaloneLogger(options, verbose) {
@@ -23504,7 +23505,7 @@ function parseNonNegativeInteger(value) {
23504
23505
  return parsed;
23505
23506
  }
23506
23507
  const defaultRunGameSearchCommand = async (...args) => {
23507
- const { runGameSearchCommand } = await Promise.resolve().then(function () { return require('./games-CTCD0YEP.cjs'); });
23508
+ const { runGameSearchCommand } = await Promise.resolve().then(function () { return require('./games-BdBtXI0v.cjs'); });
23508
23509
  return runGameSearchCommand(...args);
23509
23510
  };
23510
23511
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var dev = require('./dev-Z3taoc-T.cjs');
4
- require('./index-BiV06A8-.cjs');
3
+ var dev = require('./dev-DxvriNGb.cjs');
4
+ require('./index-D0s71o42.cjs');
5
5
  require('node:module');
6
6
  require('readline');
7
7
  require('os');
@@ -24,10 +24,10 @@ require('node:util');
24
24
  require('node:readline/promises');
25
25
  require('node:timers/promises');
26
26
  require('./index.esm-CvMA_ppV.cjs');
27
- require('./version-DWFMQ8sw.cjs');
28
- require('./runtime-permission-env-CIoMGBsf.cjs');
27
+ require('./version-BeddnZpt.cjs');
28
+ require('./runtime-permission-env-DcWIfDXK.cjs');
29
29
  require('node:async_hooks');
30
- require('./dev-context-C82TNyzm.cjs');
30
+ require('./dev-context-rMlSIJDh.cjs');
31
31
  require('sharp');
32
32
  require('node:os');
33
33
  require('node:net');
@@ -46,7 +46,7 @@ require('net');
46
46
  require('tls');
47
47
  require('url');
48
48
  require('zlib');
49
- require('./project-vite-Bt1IWMur.cjs');
49
+ require('./project-vite-BGZ0nd6-.cjs');
50
50
 
51
51
  /**
52
52
  * @packageDocumentation
@@ -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-BiV06A8-.cjs');
6
+ var index = require('./index-D0s71o42.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
8
  require('node:module');
9
9
  require('readline');
@@ -4,7 +4,7 @@ var fs = require('node:fs/promises');
4
4
  var node_module = require('node:module');
5
5
  var path = require('node:path');
6
6
  var node_url = require('node:url');
7
- var index = require('./index-BiV06A8-.cjs');
7
+ var index = require('./index-D0s71o42.cjs');
8
8
 
9
9
  async function loadProjectVite(projectRoot) {
10
10
  const projectRequire = node_module.createRequire(path.join(projectRoot, 'package.json'));
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  var index_esm = require('./index.esm-CvMA_ppV.cjs');
4
- var runtimePermissionEnv = require('./runtime-permission-env-CIoMGBsf.cjs');
5
- var devContext = require('./dev-context-C82TNyzm.cjs');
4
+ var runtimePermissionEnv = require('./runtime-permission-env-DcWIfDXK.cjs');
5
+ var devContext = require('./dev-context-rMlSIJDh.cjs');
6
6
  var promises = require('node:readline/promises');
7
- var index = require('./index-BiV06A8-.cjs');
7
+ var index = require('./index-D0s71o42.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
- var artifact = require('./artifact-DjBgoh5t.cjs');
15
- require('./version-DWFMQ8sw.cjs');
14
+ var artifact = require('./artifact-DpPkKB0p.cjs');
15
+ require('./version-BeddnZpt.cjs');
16
16
  require('node:async_hooks');
17
17
  require('sharp');
18
18
  require('node:module');
@@ -310,7 +310,7 @@ function createDefaultCosClient(uploadToken, COS) {
310
310
  };
311
311
  }
312
312
  async function loadCosConstructor() {
313
- const cosModule = await Promise.resolve().then(function () { return require('./index-DCu4v5vi.cjs'); }).then(function (n) { return n.index; });
313
+ const cosModule = await Promise.resolve().then(function () { return require('./index-B3G8sxcs.cjs'); }).then(function (n) { return n.index; });
314
314
  return cosModule.default;
315
315
  }
316
316
  function formatSize(bytes) {
@@ -426,7 +426,7 @@ async function runDeployCommand(options, runtime = {}) {
426
426
  const projectRoot = index.findProjectRoot(cwd);
427
427
  const packageJson = await readPackageJson(projectRoot);
428
428
  const miniProgramId = packageJson.heybox?.miniProgramId;
429
- const autoPublish = Boolean(options.autoPublish);
429
+ const autoPublish = options.autoPublish ?? true;
430
430
  const env = options.env ?? process.env;
431
431
  const apiBaseUrl = index.resolveHeyboxApiBaseUrl({ ...options, env });
432
432
  const loginBaseUrl = index.resolveHeyboxLoginBaseUrl({ ...options, env });
@@ -2,10 +2,10 @@
2
2
 
3
3
  var fs = require('node:fs');
4
4
  var path = require('node:path');
5
- var version = require('./version-DWFMQ8sw.cjs');
5
+ var version = require('./version-BeddnZpt.cjs');
6
6
  require('node:crypto');
7
7
  var index_esm = require('./index.esm-CvMA_ppV.cjs');
8
- var index = require('./index-BiV06A8-.cjs');
8
+ var index = require('./index-D0s71o42.cjs');
9
9
  var node_async_hooks = require('node:async_hooks');
10
10
 
11
11
  const BASIC_INFO_MAX_BYTES = 10 * 1024 * 1024;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-DWFMQ8sw.cjs');
3
+ var version = require('./version-BeddnZpt.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-BiV06A8-.cjs');
7
+ var index = require('./index-D0s71o42.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.8-alpha.1';
6
+ : '0.9.8-alpha.2';
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-BiV06A8-.cjs');
3
+ var index = require('./cli-chunks/index-D0s71o42.cjs');
4
4
  require('node:module');
5
5
  require('readline');
6
6
  require('os');
@@ -1,4 +1,4 @@
1
- import{m as Yh,H as wc,aV as Wh,bv as Zh,a2 as Kh,bc as Jh,bd as Xh,n as ct,bF as q,b5 as al,l as cl,aH as em,e as Ic,aM as tm,ay as rm,k as nm,aI as im,bz as Qr,aT as pn,aS as Gs,aU as ii,aZ as dl,a$ as om,f as wi,v as sm,al as Ii,Y as Pa,aL as am,j as $s,ap as qs,h as cm,b9 as ul,aD as dm,G as um,aX as ll,S as lm,z as fm,aA as hm,y as mm,b6 as gm,bx as fl,bw as hl,b1 as pm,g as Qs,aC as ym,b as Yt,c as Em}from"./desktop-app-launch-CCRhmr4a.js";function wm(){return{targetId:"ui-preview-target",ownerId:"ui-preview-owner",adapterId:"browser-dev-host",kind:"browser",capabilities:{storage:!0,presentation:!0,sandboxList:!0,sandboxRead:!0},state:"attached",currentInstanceId:"ui-preview-instance",cdpTargetId:"ui-preview-browser-target",metadata:{displayName:"UI 预览(模拟)",browser:"Chrome",os:"macOS"},updatedAt:Date.now(),stale:!1}}function Im(){return[{key:"network",label:"网络请求",state:"approved",facts:{platformApproval:!0,temporary:!1,effective:!0,online:"enabled"}},{key:"companion",label:"桌面辅助应用",state:"temporary",facts:{platformApproval:!1,temporary:!0,effective:!0,online:"disabled"},releaseDifference:"发布前需要获得平台批准。"},{key:"network.useOfficialDomain",label:"官方域名",state:"unavailable",facts:{platformApproval:!1,temporary:!1,effective:!1,online:"disabled"},reason:"不支持本地临时授权,获得平台批准后才能使用。"}]}const Hn={device:'[data-preview-target="device"]',screen:'[data-preview-target="screen"]',app:"#device iframe",workbench:'[data-testid="workbench-root"]'},Ac=15e3,Am=32*1024*1024,_c="data-hb-preview-capture-device",$o="data-hb-preview-capture-ancestor",Dc="data-hb-preview-capture-surface",Nc=64,_m=1024;function Dm(e={}){const t=e.document??globalThis.document,r=t.defaultView,n=e.leaseMs??Ac;if(!Number.isFinite(n)||n<=0||n>Ac)throw Ve("INVALID_CAPTURE_LEASE","截图租约无效");let i;function o(d,u,f){d.attributes.push({element:u,name:f,previous:u.getAttribute(f)}),u.setAttribute(f,d.token)}function s(d){const u=i;if(!u||u.token!==d)return!1;const f=a(u),l=!!u.style?.isConnected;i=void 0,clearTimeout(u.timer),u.removeAbort?.(),u.removeResize?.(),u.observer?.disconnect(),u.style?.remove(),u.bounds?.remove();for(const{element:h,name:m,previous:E}of u.attributes)h.getAttribute(m)===d&&(E===null?h.removeAttribute(m):h.setAttribute(m,E));return u.overlay.remove(),l&&(r.scrollX!==u.scroll.x||r.scrollY!==u.scroll.y)&&r.scrollTo(u.scroll.x,u.scroll.y),f}function a(d){const{viewport:u,target:f,rect:l}=d;if(!f?.isConnected||!l||Date.now()>=d.expiresAt||r.innerWidth!==u.width||r.innerHeight!==u.height||r.devicePixelRatio!==u.devicePixelRatio)return!1;const h=f.getBoundingClientRect();return["left","top","width","height"].every(m=>Math.abs(h[m]-l[m])<.01)}async function c(d,u){if(u?.throwIfAborted(),!Number.isFinite(d.deadlineAt)||Date.now()>=d.deadlineAt)throw Ve("PREVIEW_TIMEOUT","截图操作已超时");if(d.scope==="workbench"||!Object.hasOwn(Hn,d.scope))throw Ve("INVALID_CAPTURE_SCOPE","设备像素截图仅支持 device、screen 或 app");if(!d.operationId||d.operationId.length>128)throw Ve("INVALID_OPERATION","截图操作标识无效");if(!d.previewImage.startsWith("data:image/png;base64,")||d.previewImage.length>Am)throw Ve("INVALID_CAPTURE_IMAGE","共享窗口冻结图无效或过大");if(i)throw Ve("PREVIEW_BUSY","已有设备截图正在执行");const f=t.querySelectorAll(Hn.device);if(f.length!==1)throw Ve("DEVICE_NOT_UNIQUE","设备画面不唯一或尚未创建");const l=f[0],h=d.scope==="device"?l:t.querySelector(Hn[d.scope]);if(!h||h!==l&&!l.contains(h))throw Ve("CAPTURE_TARGET_UNAVAILABLE","截图内容尚未创建");const m=l.getBoundingClientRect();if(!(m.width>0&&m.height>0))throw Ve("CAPTURE_TARGET_UNAVAILABLE","设备画面当前不可见");const E=t.createElement("img");E.alt="",E.setAttribute("aria-hidden","true"),E.setAttribute("data-hb-preview-capture-freeze",""),E.style.cssText=`position:fixed;left:0;top:0;width:${r.innerWidth}px;height:${r.innerHeight}px;max-width:none;max-height:none;margin:0;border:0;padding:0;z-index:2147483647;pointer-events:auto;user-select:none;`,E.addEventListener("wheel",z=>z.preventDefault(),{passive:!1}),E.addEventListener("touchmove",z=>z.preventDefault(),{passive:!1});const _=Math.min(Date.now()+n,d.deadlineAt),w={operationId:d.operationId,token:r.crypto.randomUUID(),overlay:E,attributes:[],scroll:{x:r.scrollX,y:r.scrollY},viewport:{width:r.innerWidth,height:r.innerHeight,devicePixelRatio:r.devicePixelRatio},expiresAt:_};i=w,w.timer=setTimeout(()=>s(w.token),Math.max(0,_-Date.now()));const S=()=>s(w.token);u?.addEventListener("abort",S,{once:!0}),w.removeAbort=()=>u?.removeEventListener("abort",S);const p=()=>{const{viewport:z}=w;(r.innerWidth!==z.width||r.innerHeight!==z.height||r.devicePixelRatio!==z.devicePixelRatio)&&s(w.token)};r.addEventListener("resize",p),w.removeResize=()=>r.removeEventListener("resize",p);const M=()=>{if(u?.throwIfAborted(),i!==w||Date.now()>=_)throw Ve("CAPTURE_EXPIRED","截图布局租约已结束,请重新截图")};try{E.src=d.previewImage,await E.decode(),M();const z=w.token,A=`[${_c}="${z}"]`,D=r.getComputedStyle(l),I=new r.DOMMatrixReadOnly(D.transform==="none"?void 0:D.transform),v=Math.atan2(I.b,I.a),T=l.querySelector(".desktop-window__surface"),x=T?T.offsetWidth:Number.parseFloat(D.width),N=T?T.offsetHeight:Number.parseFloat(D.height),b=D.backgroundColor,O=r.getComputedStyle(t.body).backgroundColor,j=ye=>!ye||ye==="transparent"||ye==="rgba(0, 0, 0, 0)",U=j(b)?j(O)?"#fff":O:b;if(!(x>0&&N>0))throw Ve("CAPTURE_TARGET_UNAVAILABLE","设备布局尺寸无效");M(),t.body.append(E),o(w,l,_c),T&&o(w,T,Dc);for(let ye=l.parentElement;ye;ye=ye.parentElement)o(w,ye,$o);const L=t.createElement("style");w.style=L;const C=`
1
+ import{m as Yh,H as wc,aV as Wh,bv as Zh,a2 as Kh,bc as Jh,bd as Xh,n as ct,bF as q,b5 as al,l as cl,aH as em,e as Ic,aM as tm,ay as rm,k as nm,aI as im,bz as Qr,aT as pn,aS as Gs,aU as ii,aZ as dl,a$ as om,f as wi,v as sm,al as Ii,Y as Pa,aL as am,j as $s,ap as qs,h as cm,b9 as ul,aD as dm,G as um,aX as ll,S as lm,z as fm,aA as hm,y as mm,b6 as gm,bx as fl,bw as hl,b1 as pm,g as Qs,aC as ym,b as Yt,c as Em}from"./desktop-app-launch-CaciTQhd.js";function wm(){return{targetId:"ui-preview-target",ownerId:"ui-preview-owner",adapterId:"browser-dev-host",kind:"browser",capabilities:{storage:!0,presentation:!0,sandboxList:!0,sandboxRead:!0},state:"attached",currentInstanceId:"ui-preview-instance",cdpTargetId:"ui-preview-browser-target",metadata:{displayName:"UI 预览(模拟)",browser:"Chrome",os:"macOS"},updatedAt:Date.now(),stale:!1}}function Im(){return[{key:"network",label:"网络请求",state:"approved",facts:{platformApproval:!0,temporary:!1,effective:!0,online:"enabled"}},{key:"companion",label:"桌面辅助应用",state:"temporary",facts:{platformApproval:!1,temporary:!0,effective:!0,online:"disabled"},releaseDifference:"发布前需要获得平台批准。"},{key:"network.useOfficialDomain",label:"官方域名",state:"unavailable",facts:{platformApproval:!1,temporary:!1,effective:!1,online:"disabled"},reason:"不支持本地临时授权,获得平台批准后才能使用。"}]}const Hn={device:'[data-preview-target="device"]',screen:'[data-preview-target="screen"]',app:"#device iframe",workbench:'[data-testid="workbench-root"]'},Ac=15e3,Am=32*1024*1024,_c="data-hb-preview-capture-device",$o="data-hb-preview-capture-ancestor",Dc="data-hb-preview-capture-surface",Nc=64,_m=1024;function Dm(e={}){const t=e.document??globalThis.document,r=t.defaultView,n=e.leaseMs??Ac;if(!Number.isFinite(n)||n<=0||n>Ac)throw Ve("INVALID_CAPTURE_LEASE","截图租约无效");let i;function o(d,u,f){d.attributes.push({element:u,name:f,previous:u.getAttribute(f)}),u.setAttribute(f,d.token)}function s(d){const u=i;if(!u||u.token!==d)return!1;const f=a(u),l=!!u.style?.isConnected;i=void 0,clearTimeout(u.timer),u.removeAbort?.(),u.removeResize?.(),u.observer?.disconnect(),u.style?.remove(),u.bounds?.remove();for(const{element:h,name:m,previous:E}of u.attributes)h.getAttribute(m)===d&&(E===null?h.removeAttribute(m):h.setAttribute(m,E));return u.overlay.remove(),l&&(r.scrollX!==u.scroll.x||r.scrollY!==u.scroll.y)&&r.scrollTo(u.scroll.x,u.scroll.y),f}function a(d){const{viewport:u,target:f,rect:l}=d;if(!f?.isConnected||!l||Date.now()>=d.expiresAt||r.innerWidth!==u.width||r.innerHeight!==u.height||r.devicePixelRatio!==u.devicePixelRatio)return!1;const h=f.getBoundingClientRect();return["left","top","width","height"].every(m=>Math.abs(h[m]-l[m])<.01)}async function c(d,u){if(u?.throwIfAborted(),!Number.isFinite(d.deadlineAt)||Date.now()>=d.deadlineAt)throw Ve("PREVIEW_TIMEOUT","截图操作已超时");if(d.scope==="workbench"||!Object.hasOwn(Hn,d.scope))throw Ve("INVALID_CAPTURE_SCOPE","设备像素截图仅支持 device、screen 或 app");if(!d.operationId||d.operationId.length>128)throw Ve("INVALID_OPERATION","截图操作标识无效");if(!d.previewImage.startsWith("data:image/png;base64,")||d.previewImage.length>Am)throw Ve("INVALID_CAPTURE_IMAGE","共享窗口冻结图无效或过大");if(i)throw Ve("PREVIEW_BUSY","已有设备截图正在执行");const f=t.querySelectorAll(Hn.device);if(f.length!==1)throw Ve("DEVICE_NOT_UNIQUE","设备画面不唯一或尚未创建");const l=f[0],h=d.scope==="device"?l:t.querySelector(Hn[d.scope]);if(!h||h!==l&&!l.contains(h))throw Ve("CAPTURE_TARGET_UNAVAILABLE","截图内容尚未创建");const m=l.getBoundingClientRect();if(!(m.width>0&&m.height>0))throw Ve("CAPTURE_TARGET_UNAVAILABLE","设备画面当前不可见");const E=t.createElement("img");E.alt="",E.setAttribute("aria-hidden","true"),E.setAttribute("data-hb-preview-capture-freeze",""),E.style.cssText=`position:fixed;left:0;top:0;width:${r.innerWidth}px;height:${r.innerHeight}px;max-width:none;max-height:none;margin:0;border:0;padding:0;z-index:2147483647;pointer-events:auto;user-select:none;`,E.addEventListener("wheel",z=>z.preventDefault(),{passive:!1}),E.addEventListener("touchmove",z=>z.preventDefault(),{passive:!1});const _=Math.min(Date.now()+n,d.deadlineAt),w={operationId:d.operationId,token:r.crypto.randomUUID(),overlay:E,attributes:[],scroll:{x:r.scrollX,y:r.scrollY},viewport:{width:r.innerWidth,height:r.innerHeight,devicePixelRatio:r.devicePixelRatio},expiresAt:_};i=w,w.timer=setTimeout(()=>s(w.token),Math.max(0,_-Date.now()));const S=()=>s(w.token);u?.addEventListener("abort",S,{once:!0}),w.removeAbort=()=>u?.removeEventListener("abort",S);const p=()=>{const{viewport:z}=w;(r.innerWidth!==z.width||r.innerHeight!==z.height||r.devicePixelRatio!==z.devicePixelRatio)&&s(w.token)};r.addEventListener("resize",p),w.removeResize=()=>r.removeEventListener("resize",p);const M=()=>{if(u?.throwIfAborted(),i!==w||Date.now()>=_)throw Ve("CAPTURE_EXPIRED","截图布局租约已结束,请重新截图")};try{E.src=d.previewImage,await E.decode(),M();const z=w.token,A=`[${_c}="${z}"]`,D=r.getComputedStyle(l),I=new r.DOMMatrixReadOnly(D.transform==="none"?void 0:D.transform),v=Math.atan2(I.b,I.a),T=l.querySelector(".desktop-window__surface"),x=T?T.offsetWidth:Number.parseFloat(D.width),N=T?T.offsetHeight:Number.parseFloat(D.height),b=D.backgroundColor,O=r.getComputedStyle(t.body).backgroundColor,j=ye=>!ye||ye==="transparent"||ye==="rgba(0, 0, 0, 0)",U=j(b)?j(O)?"#fff":O:b;if(!(x>0&&N>0))throw Ve("CAPTURE_TARGET_UNAVAILABLE","设备布局尺寸无效");M(),t.body.append(E),o(w,l,_c),T&&o(w,T,Dc);for(let ye=l.parentElement;ye;ye=ye.parentElement)o(w,ye,$o);const L=t.createElement("style");w.style=L;const C=`
2
2
  [${$o}="${z}"] {overflow:visible!important;scrollbar-width:none!important;}
3
3
  [${$o}="${z}"]::-webkit-scrollbar {display:none!important;}
4
4
  [${Dc}="${z}"] {transform:none!important;transition:none!important;}