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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -0
  3. package/dist/cli-chunks/{runtime-gate-alLUP4_C.cjs → artifact-BTi9i7N4.cjs} +136 -65
  4. package/dist/cli-chunks/{build-BHfbvke-.cjs → build-CScc5bgz.cjs} +34 -83
  5. package/dist/cli-chunks/{create-B-KOcThY.cjs → create-BybyVKxB.cjs} +1 -1
  6. package/dist/cli-chunks/{deploy-lock-DY7E8TFw.cjs → deploy-lock-CtJXBtKK.cjs} +1 -1
  7. package/dist/cli-chunks/{dev-BC_oKKzT.cjs → dev-BVZ9yV84.cjs} +15469 -15357
  8. package/dist/cli-chunks/{context-DZldyzoT.cjs → dev-context-BjwOy-fF.cjs} +299 -299
  9. package/dist/cli-chunks/{doctor-l9Gd1Rhf.cjs → doctor-CTEun30u.cjs} +1 -1
  10. package/dist/cli-chunks/{games-DDoaQ_KF.cjs → games-Bp6gkkgb.cjs} +2 -2
  11. package/dist/cli-chunks/{index-Czupnh5A.cjs → index-CxelQqdy.cjs} +17 -17
  12. package/dist/cli-chunks/{index-COzyQErL.cjs → index-DF8KQKoa.cjs} +1 -1
  13. package/dist/cli-chunks/{index.esm-BX-KdUxn.cjs → index.esm-vr3yuZ2Q.cjs} +6 -6
  14. package/dist/cli-chunks/{login-Dy-um6Ka.cjs → login-BPyX2p9v.cjs} +1 -1
  15. package/dist/cli-chunks/{project-vite-CTWRejM4.cjs → project-vite-DBId94T0.cjs} +1 -1
  16. package/dist/cli-chunks/{remote-BKIgszJS.cjs → remote-C1n11VWk.cjs} +66 -144
  17. package/dist/cli-chunks/{runtime-permission-env-DFFgIfoX.cjs → runtime-permission-env-Beurz19O.cjs} +127 -128
  18. package/dist/cli-chunks/{skill-WQPin-5N.cjs → skill-C33zgdJF.cjs} +2 -2
  19. package/dist/cli-chunks/{version-BQVBVZPA.cjs → version-BKjLEHsb.cjs} +1 -1
  20. package/dist/cli.cjs +1 -1
  21. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-j00ZN_C-.js → browser-dev-host-DedSMBMn.js} +15 -15
  22. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-BTmNqUZA.js → desktop-app-launch-BBIYbjgT.js} +1 -1
  23. package/dist/devtools/browser-dev-host/assets/{index-D3cBjlwQ.js → index-CnC7wDP_.js} +3 -3
  24. package/dist/devtools/browser-dev-host/index.html +2 -2
  25. package/dist/index.cjs.js +1 -1
  26. package/dist/index.esm.js +1 -1
  27. package/dist/vite.cjs.js +79 -13
  28. package/dist/vite.esm.js +79 -13
  29. package/package.json +6 -6
  30. package/skill/skill.json +4 -4
  31. package/types/vite/index.d.ts +35 -7
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-Czupnh5A.cjs');
4
3
  var fs = require('node:fs');
5
4
  var path = require('node:path');
6
- var version$1 = require('./version-BQVBVZPA.cjs');
5
+ var version$1 = require('./version-BKjLEHsb.cjs');
7
6
  require('node:crypto');
7
+ var index = require('./index-CxelQqdy.cjs');
8
8
  var node_async_hooks = require('node:async_hooks');
9
9
 
10
10
  /**
@@ -6961,23 +6961,6 @@ function serializeMiniProgramDevelopmentSnapshot(snapshot) {
6961
6961
  });
6962
6962
  }
6963
6963
 
6964
- /**
6965
- * 校验项目配置或产物中的小程序类别。
6966
- *
6967
- * @param value - 待校验值,只接受 `tool`、`game`、`other` 或 `undefined`;不做 trim 或大小写转换。
6968
- * @param sourceLabel - 错误消息中的字段来源,默认 `package.json#heybox.category`。
6969
- * @returns 合法类别原值;输入 `undefined` 时返回 `undefined`,由发布流程另行检查是否必填。
6970
- * @throws `Error` 输入为其他值(包括 null 或空字符串)时抛出带字段来源的错误。
6971
- * @since 0.8.3
6972
- */
6973
- function parseMiniappCategory(value, sourceLabel = 'package.json#heybox.category') {
6974
- if (value === undefined)
6975
- return undefined;
6976
- if (value === 'tool' || value === 'game' || value === 'other')
6977
- return value;
6978
- throw new Error(`${sourceLabel} 必须是 tool、game 或 other`);
6979
- }
6980
-
6981
6964
  const BASIC_INFO_MAX_BYTES = 10 * 1024 * 1024;
6982
6965
  const BASIC_INFO_MAX_PIXELS = 40_000_000;
6983
6966
  /**
@@ -7122,6 +7105,23 @@ function parseMiniappBindAppIds(value, options = {}) {
7122
7105
  return Object.freeze(appIds);
7123
7106
  }
7124
7107
 
7108
+ /**
7109
+ * 校验项目配置或产物中的小程序类别。
7110
+ *
7111
+ * @param value - 待校验值,只接受 `tool`、`game`、`other` 或 `undefined`;不做 trim 或大小写转换。
7112
+ * @param sourceLabel - 错误消息中的字段来源,默认 `package.json#heybox.category`。
7113
+ * @returns 合法类别原值;输入 `undefined` 时返回 `undefined`,由发布流程另行检查是否必填。
7114
+ * @throws `Error` 输入为其他值(包括 null 或空字符串)时抛出带字段来源的错误。
7115
+ * @since 0.8.3
7116
+ */
7117
+ function parseMiniappCategory(value, sourceLabel = 'package.json#heybox.category') {
7118
+ if (value === undefined)
7119
+ return undefined;
7120
+ if (value === 'tool' || value === 'game' || value === 'other')
7121
+ return value;
7122
+ throw new Error(`${sourceLabel} 必须是 tool、game 或 other`);
7123
+ }
7124
+
7125
7125
  /** 小程序简介最大长度(Unicode code point),与服务端截断口径一致。 */
7126
7126
  const MINIAPP_DESC_MAX_LENGTH = 200;
7127
7127
  /**
@@ -7595,6 +7595,110 @@ function formatReason$1(error) {
7595
7595
  return String(error);
7596
7596
  }
7597
7597
 
7598
+ function findNearestPackageJsonPath(startDir) {
7599
+ let current = path.resolve(startDir);
7600
+ while (true) {
7601
+ const packageJsonPath = path.join(current, 'package.json');
7602
+ if (fs.existsSync(packageJsonPath)) {
7603
+ return packageJsonPath;
7604
+ }
7605
+ const parent = path.dirname(current);
7606
+ if (parent === current) {
7607
+ return path.join(path.resolve(startDir), 'package.json');
7608
+ }
7609
+ current = parent;
7610
+ }
7611
+ }
7612
+ function readMiniappPlatformsFromPackageJson(root) {
7613
+ const { packageJson } = readMiniappPackageJson(root);
7614
+ const heybox = readMiniappHeyboxConfig(packageJson);
7615
+ return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
7616
+ }
7617
+ /**
7618
+ * 读取并校验 `package.json#heybox.window`。
7619
+ *
7620
+ * @returns 合法声明;未声明时返回 `undefined`,调用方不得向 manifest 写入空对象或 `null`。
7621
+ * @throws 当声明违反 {@link validateMiniappWindow} 的规则时抛出,报错前缀为 `package.json#heybox.window`。
7622
+ */
7623
+ function readMiniappWindowFromPackageJson(root) {
7624
+ const { packageJson } = readMiniappPackageJson(root);
7625
+ const heybox = readMiniappHeyboxConfig(packageJson);
7626
+ return validateMiniappWindow(heybox?.window, 'package.json#heybox.window');
7627
+ }
7628
+ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
7629
+ const { packageJson } = readMiniappPackageJson(root);
7630
+ const heybox = readMiniappHeyboxConfig(packageJson);
7631
+ const present = heybox !== undefined && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
7632
+ return parseMiniappPermissions(heybox?.permissions, {
7633
+ present,
7634
+ sdkVersion,
7635
+ });
7636
+ }
7637
+ function readMiniappBindAppIdsFromPackageJson(root) {
7638
+ const { packageJson } = readMiniappPackageJson(root);
7639
+ const heybox = readMiniappHeyboxConfig(packageJson);
7640
+ return parseMiniappBindAppIds(heybox?.bindAppIds);
7641
+ }
7642
+ function readMiniappCategoryFromPackageJson(root) {
7643
+ const { packageJson } = readMiniappPackageJson(root);
7644
+ return parseMiniappCategory(readMiniappHeyboxConfig(packageJson)?.category);
7645
+ }
7646
+ function resolveMiniappSdkVersion() {
7647
+ if (!version$1.HB_SDK_VERSION.startsWith('__HB_SDK_'))
7648
+ return version$1.HB_SDK_VERSION;
7649
+ const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), 'utf8'));
7650
+ if (typeof packageJson.version !== 'string' || !packageJson.version)
7651
+ throw new Error('未能读取 @heybox/hb-sdk 当前版本号');
7652
+ return packageJson.version;
7653
+ }
7654
+ function readMiniappPackageJson(root, requireVersion) {
7655
+ const packageJsonPath = findNearestPackageJsonPath(root);
7656
+ let content;
7657
+ try {
7658
+ content = fs.readFileSync(packageJsonPath, 'utf8');
7659
+ }
7660
+ catch (error) {
7661
+ throw new Error(`@heybox/hb-sdk 读取 package.json 失败:${formatReason(error)}`);
7662
+ }
7663
+ let packageJson;
7664
+ try {
7665
+ packageJson = JSON.parse(content);
7666
+ }
7667
+ catch (error) {
7668
+ throw new Error(`@heybox/hb-sdk 解析 package.json 失败:${formatReason(error)}`);
7669
+ }
7670
+ return { packageJson, packageJsonPath, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
7671
+ }
7672
+ function readMiniappHeyboxConfig(packageJson) {
7673
+ if (packageJson.heybox === undefined)
7674
+ return undefined;
7675
+ if (!isRecord$1(packageJson.heybox)) {
7676
+ throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
7677
+ }
7678
+ return packageJson.heybox;
7679
+ }
7680
+ function isRecord$1(value) {
7681
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
7682
+ }
7683
+ function formatReason(error) {
7684
+ if (error instanceof Error && error.message) {
7685
+ return error.message;
7686
+ }
7687
+ return String(error);
7688
+ }
7689
+ /** 声明路径与资源基准均来自最近 package.json。 */
7690
+ function readMiniappWorkspaceCardsFromPackageJson(root) {
7691
+ const { packageJson, packageJsonPath } = readMiniappPackageJson(root);
7692
+ return { declaration: readMiniappHeyboxConfig(packageJson)?.workspaceCards, projectRoot: path.dirname(packageJsonPath) };
7693
+ }
7694
+
7695
+ Array.from({ length: 256 }, (_, value) => {
7696
+ let crc = value;
7697
+ for (let bit = 0; bit < 8; bit++)
7698
+ crc = (crc >>> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
7699
+ return crc >>> 0;
7700
+ });
7701
+
7598
7702
  const UNDEFINED_CODE_POINTS = new Set([
7599
7703
  65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
7600
7704
  393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
@@ -16384,14 +16488,14 @@ function validateMiniappCompanionFileReceipts(companions, files) {
16384
16488
  throw new Error('dist 包含未被 manifest.companions 引用的 Companion 归档');
16385
16489
  return;
16386
16490
  }
16387
- if (!isRecord$1(companions))
16491
+ if (!isRecord(companions))
16388
16492
  throw new Error('manifest.companions 必须是对象');
16389
16493
  const referenced = new Set();
16390
16494
  for (const definition of Object.values(companions)) {
16391
- if (!isRecord$1(definition) || !isRecord$1(definition.targets))
16495
+ if (!isRecord(definition) || !isRecord(definition.targets))
16392
16496
  throw new Error('manifest.companions targets 不合法');
16393
16497
  for (const artifact of Object.values(definition.targets)) {
16394
- if (!isRecord$1(artifact) || typeof artifact.path !== 'string' || typeof artifact.size !== 'number' || typeof artifact.sha256 !== 'string') {
16498
+ if (!isRecord(artifact) || typeof artifact.path !== 'string' || typeof artifact.size !== 'number' || typeof artifact.sha256 !== 'string') {
16395
16499
  throw new Error('manifest.companions artifact 不合法');
16396
16500
  }
16397
16501
  const file = companionFiles.get(artifact.path);
@@ -16408,7 +16512,7 @@ function validateMiniappCompanionFileReceipts(companions, files) {
16408
16512
  if (extra)
16409
16513
  throw new Error(`Companion 归档未被 manifest.companions 引用:${extra}`);
16410
16514
  }
16411
- function isRecord$1(value) {
16515
+ function isRecord(value) {
16412
16516
  return typeof value === 'object' && value !== null && !Array.isArray(value);
16413
16517
  }
16414
16518
  function normalizeMiniappArtifactRelativePath(relativePath) {
@@ -16505,110 +16609,6 @@ const LIST_USER_MINIPROGRAM_PERMISSION_APPLICATION_API_PATH = '/mall/developer/u
16505
16609
  /** 提交不绑定版本的平台权限申请。 */
16506
16610
  const SUBMIT_USER_MINIPROGRAM_PERMISSION_APPLICATION_API_PATH = '/mall/developer/user_miniprogram/runtime_permission/application_submit';
16507
16611
 
16508
- function findNearestPackageJsonPath(startDir) {
16509
- let current = path.resolve(startDir);
16510
- while (true) {
16511
- const packageJsonPath = path.join(current, 'package.json');
16512
- if (fs.existsSync(packageJsonPath)) {
16513
- return packageJsonPath;
16514
- }
16515
- const parent = path.dirname(current);
16516
- if (parent === current) {
16517
- return path.join(path.resolve(startDir), 'package.json');
16518
- }
16519
- current = parent;
16520
- }
16521
- }
16522
- function readMiniappPlatformsFromPackageJson(root) {
16523
- const { packageJson } = readMiniappPackageJson(root);
16524
- const heybox = readMiniappHeyboxConfig(packageJson);
16525
- return validateMiniappPlatforms(heybox?.platforms, 'package.json#heybox.platforms');
16526
- }
16527
- /**
16528
- * 读取并校验 `package.json#heybox.window`。
16529
- *
16530
- * @returns 合法声明;未声明时返回 `undefined`,调用方不得向 manifest 写入空对象或 `null`。
16531
- * @throws 当声明违反 {@link validateMiniappWindow} 的规则时抛出,报错前缀为 `package.json#heybox.window`。
16532
- */
16533
- function readMiniappWindowFromPackageJson(root) {
16534
- const { packageJson } = readMiniappPackageJson(root);
16535
- const heybox = readMiniappHeyboxConfig(packageJson);
16536
- return validateMiniappWindow(heybox?.window, 'package.json#heybox.window');
16537
- }
16538
- function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
16539
- const { packageJson } = readMiniappPackageJson(root);
16540
- const heybox = readMiniappHeyboxConfig(packageJson);
16541
- const present = heybox !== undefined && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
16542
- return parseMiniappPermissions(heybox?.permissions, {
16543
- present,
16544
- sdkVersion,
16545
- });
16546
- }
16547
- function readMiniappBindAppIdsFromPackageJson(root) {
16548
- const { packageJson } = readMiniappPackageJson(root);
16549
- const heybox = readMiniappHeyboxConfig(packageJson);
16550
- return parseMiniappBindAppIds(heybox?.bindAppIds);
16551
- }
16552
- function readMiniappCategoryFromPackageJson(root) {
16553
- const { packageJson } = readMiniappPackageJson(root);
16554
- return parseMiniappCategory(readMiniappHeyboxConfig(packageJson)?.category);
16555
- }
16556
- function resolveMiniappSdkVersion() {
16557
- if (!version$1.HB_SDK_VERSION.startsWith('__HB_SDK_'))
16558
- return version$1.HB_SDK_VERSION;
16559
- const packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), 'utf8'));
16560
- if (typeof packageJson.version !== 'string' || !packageJson.version)
16561
- throw new Error('未能读取 @heybox/hb-sdk 当前版本号');
16562
- return packageJson.version;
16563
- }
16564
- function readMiniappPackageJson(root, requireVersion) {
16565
- const packageJsonPath = findNearestPackageJsonPath(root);
16566
- let content;
16567
- try {
16568
- content = fs.readFileSync(packageJsonPath, 'utf8');
16569
- }
16570
- catch (error) {
16571
- throw new Error(`@heybox/hb-sdk 读取 package.json 失败:${formatReason(error)}`);
16572
- }
16573
- let packageJson;
16574
- try {
16575
- packageJson = JSON.parse(content);
16576
- }
16577
- catch (error) {
16578
- throw new Error(`@heybox/hb-sdk 解析 package.json 失败:${formatReason(error)}`);
16579
- }
16580
- return { packageJson, packageJsonPath, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
16581
- }
16582
- function readMiniappHeyboxConfig(packageJson) {
16583
- if (packageJson.heybox === undefined)
16584
- return undefined;
16585
- if (!isRecord(packageJson.heybox)) {
16586
- throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
16587
- }
16588
- return packageJson.heybox;
16589
- }
16590
- function isRecord(value) {
16591
- return typeof value === 'object' && value !== null && !Array.isArray(value);
16592
- }
16593
- function formatReason(error) {
16594
- if (error instanceof Error && error.message) {
16595
- return error.message;
16596
- }
16597
- return String(error);
16598
- }
16599
- /** 声明路径与资源基准均来自最近 package.json。 */
16600
- function readMiniappWorkspaceCardsFromPackageJson(root) {
16601
- const { packageJson, packageJsonPath } = readMiniappPackageJson(root);
16602
- return { declaration: readMiniappHeyboxConfig(packageJson)?.workspaceCards, projectRoot: path.dirname(packageJsonPath) };
16603
- }
16604
-
16605
- Array.from({ length: 256 }, (_, value) => {
16606
- let crc = value;
16607
- for (let bit = 0; bit < 8; bit++)
16608
- crc = (crc >>> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
16609
- return crc >>> 0;
16610
- });
16611
-
16612
16612
  const HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV = 'HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN';
16613
16613
  const HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV = 'HB_SDK_RUNTIME_PERMISSION_CONTEXT';
16614
16614
  const VERIFIED_RUNTIME_PERMISSION_CONTEXT = 'verified';
@@ -16717,7 +16717,6 @@ exports.createMiniappPlatformCspEnv = createMiniappPlatformCspEnv;
16717
16717
  exports.hasMiniappDesktopPlatform = hasMiniappDesktopPlatform;
16718
16718
  exports.isValidMiniappManifestVersion = isValidMiniappManifestVersion;
16719
16719
  exports.normalizeBasicInfoName = normalizeBasicInfoName;
16720
- exports.normalizeRelativePath = normalizeRelativePath;
16721
16720
  exports.parseMiniProgramLocalDevGrant = parseMiniProgramLocalDevGrant;
16722
16721
  exports.parseMiniProgramRuntimePermissions = parseMiniProgramRuntimePermissions;
16723
16722
  exports.parseMiniappBasicInfo = parseMiniappBasicInfo;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-BQVBVZPA.cjs');
3
+ var version = require('./version-BKjLEHsb.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-Czupnh5A.cjs');
7
+ var index = require('./index-CxelQqdy.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.4-alpha.0';
6
+ : '0.9.4-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-Czupnh5A.cjs');
3
+ var index = require('./cli-chunks/index-CxelQqdy.cjs');
4
4
  require('node:module');
5
5
  require('readline');
6
6
  require('os');