@heybox/hb-sdk 0.7.5-alpha.0 → 0.8.0-alpha

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 (54) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +14 -14
  3. package/dist/cli-chunks/{build-V1YBdpzY.cjs → build-DJWFSM1B.cjs} +6 -5
  4. package/dist/cli-chunks/{context-Ba1Je-wT.cjs → context-DV2UK1Nz.cjs} +2 -2
  5. package/dist/cli-chunks/{create-CKGjqo9E.cjs → create-2HfoB48V.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-XopYKLYZ.cjs → dev-Dgt2zS9k.cjs} +8 -8
  7. package/dist/cli-chunks/{doctor-BHbrYQqT.cjs → doctor-C95gIao_.cjs} +1 -1
  8. package/dist/cli-chunks/{index-DKWfX6Ut.cjs → index-BjoSXl8C.cjs} +2 -2
  9. package/dist/cli-chunks/{index-C9mpajVG.cjs → index-D62ANeBv.cjs} +14 -14
  10. package/dist/cli-chunks/{index.esm-SXAQ3WVR.cjs → index.esm-CigcxJ2B.cjs} +6 -6
  11. package/dist/cli-chunks/{login-BVWicWqe.cjs → login-Cumknwdx.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-CBb38HJ3.cjs → project-vite-CcE-HMmd.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-BG1u0NKT.cjs → remote-DDdP3xcE.cjs} +10 -8
  14. package/dist/cli-chunks/{runtime-gate-CtV7rWyX.cjs → runtime-gate-DFjw66kF.cjs} +20 -1
  15. package/dist/cli-chunks/{runtime-permission-env-D-8_jPG3.cjs → runtime-permission-env-CjsCe5bp.cjs} +13 -13
  16. package/dist/cli-chunks/{session-CJS_SEp9.cjs → session-BDi_AZSv.cjs} +1 -1
  17. package/dist/cli.cjs +1 -1
  18. package/dist/devtools/browser-dev-host/main.js +173 -68
  19. package/dist/index.cjs.js +113 -63
  20. package/dist/index.esm.js +113 -63
  21. package/dist/miniapp-publish.cjs.js +13 -13
  22. package/dist/miniapp-publish.esm.js +13 -13
  23. package/dist/templates/vue3-vite-ts/README.md.ejs +2 -0
  24. package/dist/templates/vue3-vite-ts/vite.config.ts +1 -1
  25. package/dist/vite.cjs.js +31 -4
  26. package/dist/vite.esm.js +31 -5
  27. package/package.json +10 -7
  28. package/skill/references/api-protocol.md +14 -2
  29. package/skill/references/api-root.md +42 -21
  30. package/skill/references/examples.md +1 -1
  31. package/skill/references/safety-boundaries.md +1 -1
  32. package/skill/scripts/sync-references.mjs +3 -1
  33. package/skill/skill.json +4 -4
  34. package/types/core/errors.d.ts +5 -5
  35. package/types/core/sdk.d.ts +5 -5
  36. package/types/core/singleton.d.ts +56 -6
  37. package/types/miniapp-manifest/schema.d.ts +5 -0
  38. package/types/miniapp-publish/index.d.ts +8 -8
  39. package/types/modules/auth/index.d.ts +15 -1
  40. package/types/modules/cloud/index.d.ts +75 -5
  41. package/types/modules/device/index.d.ts +31 -3
  42. package/types/modules/navigation/index.d.ts +46 -4
  43. package/types/modules/network/index.d.ts +22 -11
  44. package/types/modules/share/copy-link.d.ts +3 -3
  45. package/types/modules/share/index.d.ts +61 -5
  46. package/types/modules/share/screenshot.d.ts +3 -3
  47. package/types/modules/share/show-share-menu.d.ts +3 -3
  48. package/types/modules/storage/index.d.ts +38 -10
  49. package/types/modules/ui/index.d.ts +46 -4
  50. package/types/modules/user/get-info.d.ts +1 -1
  51. package/types/modules/user/index.d.ts +46 -4
  52. package/types/modules/user/steam-game-list.d.ts +2 -2
  53. package/types/modules/viewport/index.d.ts +36 -8
  54. package/types/vite/index.d.ts +15 -7
package/dist/index.esm.js CHANGED
@@ -292,9 +292,9 @@ class HbMiniProgramSDKError extends Error {
292
292
  /**
293
293
  * 创建 SDK 标准错误。
294
294
  *
295
- * @param code 稳定错误码。
296
- * @param message 面向开发者的错误说明。
297
- * @param data 可选调试数据。
295
+ * @param code - 稳定错误码。
296
+ * @param message - 面向开发者的错误说明。
297
+ * @param data - 可选调试数据。
298
298
  * @returns 标准化 `HbMiniProgramSDKError` 实例。
299
299
  *
300
300
  * @remarks
@@ -314,7 +314,7 @@ function createSDKError(code, message, data) {
314
314
  * 仅在请求已经成功走完 bridge / runtime / 宿主调用链、但最终 HTTP 状态不满足
315
315
  * `validateStatus` 时抛出。它不表示握手失败或 bridge 级错误。
316
316
  *
317
- * @typeParam T 标准化响应数据的类型。
317
+ * @typeParam T - 标准化响应数据的类型。
318
318
  */
319
319
  class HbMiniProgramNetworkError extends Error {
320
320
  /** HTTP 状态码。 */
@@ -328,7 +328,7 @@ class HbMiniProgramNetworkError extends Error {
328
328
  /** 完整标准化响应。 */
329
329
  response;
330
330
  /**
331
- * @param response 已完成请求的标准化网络响应。
331
+ * @param response - 已完成请求的标准化网络响应。
332
332
  */
333
333
  constructor(response) {
334
334
  const method = (response.config.method || 'GET').toUpperCase();
@@ -668,7 +668,7 @@ function createMessageId() {
668
668
  /** 构建时替换为当前发布包的实际版本。 */
669
669
  const HB_SDK_VERSION = typeof undefined === 'string'
670
670
  ? undefined
671
- : '0.7.5-alpha.0';
671
+ : '0.8.0-alpha';
672
672
 
673
673
  const DEFAULT_TIMEOUT = 10000;
674
674
  const HANDSHAKE_RETRY_INTERVAL = 250;
@@ -1048,10 +1048,10 @@ function createCloudModule(requester) {
1048
1048
  /**
1049
1049
  * 复制当前小程序的通用分享链接。
1050
1050
  *
1051
- * @param requester 底层 bridge 请求能力。
1052
- * @param options 分享扩展数据;不传时复制默认首页链接。
1051
+ * @param requester - 底层 bridge 请求能力。
1052
+ * @param options - 分享扩展数据;不传时复制默认首页链接。
1053
1053
  * @returns 已写入系统剪贴板的完整分享链接。
1054
- * @throws {HbMiniProgramSDKError} 当参数、bridge、父容器或剪贴板能力调用失败时抛出。
1054
+ * @throws {@link HbMiniProgramSDKError} 当参数、bridge、父容器或剪贴板能力调用失败时抛出。
1055
1055
  */
1056
1056
  function copyLink(requester, options) {
1057
1057
  return requester.request(SHARE_COPY_LINK_METHOD, options);
@@ -2251,10 +2251,10 @@ function decodeBase64Url(value) {
2251
2251
  /**
2252
2252
  * 截图并唤起分享。
2253
2253
  *
2254
- * @param requester 底层 bridge 请求能力。
2255
- * @param options 截图区域、延迟与保存相册等配置。
2254
+ * @param requester - 底层 bridge 请求能力。
2255
+ * @param options - 截图区域、延迟与保存相册等配置。
2256
2256
  * @returns 由宿主客户端协议决定的结果。
2257
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2257
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2258
2258
  */
2259
2259
  function screenshot(requester, options) {
2260
2260
  return requester.request(SHARE_SCREENSHOT_METHOD, options);
@@ -2263,10 +2263,10 @@ function screenshot(requester, options) {
2263
2263
  /**
2264
2264
  * 展示基础分享面板。
2265
2265
  *
2266
- * @param requester 底层 bridge 请求能力。
2267
- * @param options 基础分享参数。
2266
+ * @param requester - 底层 bridge 请求能力。
2267
+ * @param options - 基础分享参数。
2268
2268
  * @returns 由宿主客户端协议决定的结果。
2269
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2269
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2270
2270
  */
2271
2271
  function showShareMenu(requester, options) {
2272
2272
  return requester.request(SHARE_SHOW_SHARE_MENU_METHOD, options);
@@ -2275,25 +2275,25 @@ function showShareMenu(requester, options) {
2275
2275
  /**
2276
2276
  * 创建分享模块。
2277
2277
  *
2278
- * @param requester 底层 bridge 请求能力。
2278
+ * @param requester - 底层 bridge 请求能力。
2279
2279
  * @returns 面向业务层的分享模块对象。
2280
2280
  */
2281
2281
  function createShareModule(requester, launchHref) {
2282
2282
  return {
2283
- copyLink: options => copyLink(requester, options),
2283
+ copyLink: (options) => copyLink(requester, options),
2284
2284
  getExtra: () => readMiniProgramShareExtra(launchHref),
2285
- showShareMenu: options => showShareMenu(requester, options),
2286
- screenshot: options => screenshot(requester, options),
2285
+ showShareMenu: (options) => showShareMenu(requester, options),
2286
+ screenshot: (options) => screenshot(requester, options),
2287
2287
  };
2288
2288
  }
2289
2289
 
2290
2290
  /**
2291
2291
  * 获取小程序隔离 storage。
2292
2292
  *
2293
- * @param requester 底层 bridge 请求能力。
2294
- * @param options 读取的 storage key。
2293
+ * @param requester - 底层 bridge 请求能力。
2294
+ * @param options - 读取的 storage key。
2295
2295
  * @returns 对应 key 的标准化读取结果。
2296
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2296
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2297
2297
  */
2298
2298
  function getStorage(requester, options) {
2299
2299
  return requester.request(STORAGE_GET_STORAGE_METHOD, options);
@@ -2301,10 +2301,10 @@ function getStorage(requester, options) {
2301
2301
  /**
2302
2302
  * 写入小程序隔离 storage。
2303
2303
  *
2304
- * @param requester 底层 bridge 请求能力。
2305
- * @param options 要写入的 storage key 与数据。
2304
+ * @param requester - 底层 bridge 请求能力。
2305
+ * @param options - 要写入的 storage key 与数据。
2306
2306
  * @returns 当写入完成后 resolve。
2307
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2307
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2308
2308
  */
2309
2309
  function setStorage(requester, options) {
2310
2310
  return requester.request(STORAGE_SET_STORAGE_METHOD, options);
@@ -2312,13 +2312,13 @@ function setStorage(requester, options) {
2312
2312
  /**
2313
2313
  * 创建 storage 模块。
2314
2314
  *
2315
- * @param requester 底层 bridge 请求能力。
2315
+ * @param requester - 底层 bridge 请求能力。
2316
2316
  * @returns 面向业务层的 storage 模块对象。
2317
2317
  */
2318
2318
  function createStorageModule(requester) {
2319
2319
  return {
2320
- getStorage: options => getStorage(requester, options),
2321
- setStorage: options => setStorage(requester, options),
2320
+ getStorage: (options) => getStorage(requester, options),
2321
+ setStorage: (options) => setStorage(requester, options),
2322
2322
  };
2323
2323
  }
2324
2324
 
@@ -2393,13 +2393,13 @@ function formatNetworkRequestFailureMessage(detail) {
2393
2393
  return `${detail.kind} ${detail.method} ${detail.url}${statusPart}${codePart}`;
2394
2394
  }
2395
2395
 
2396
- const DEFAULT_VALIDATE_STATUS = status => status >= 200 && status < 300;
2396
+ const DEFAULT_VALIDATE_STATUS = (status) => status >= 200 && status < 300;
2397
2397
  function isPlainObject(value) {
2398
2398
  return Object.prototype.toString.call(value) === '[object Object]';
2399
2399
  }
2400
2400
  function clonePublicValue(value) {
2401
2401
  if (Array.isArray(value)) {
2402
- return value.map(item => clonePublicValue(item));
2402
+ return value.map((item) => clonePublicValue(item));
2403
2403
  }
2404
2404
  if (isPlainObject(value)) {
2405
2405
  return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, clonePublicValue(item)]));
@@ -2453,11 +2453,11 @@ function toNetworkResponse(payload, config) {
2453
2453
  /**
2454
2454
  * 发起网络请求并返回标准化响应。
2455
2455
  *
2456
- * @param requester 底层 bridge 请求能力。
2457
- * @param config 面向业务层的网络请求配置。
2456
+ * @param requester - 底层 bridge 请求能力。
2457
+ * @param config - 面向业务层的网络请求配置。
2458
2458
  * @returns 标准化网络响应。HTTP 2xx 默认返回 resolve。
2459
- * @throws {HbMiniProgramNetworkError} 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出。
2460
- * @throws {HbMiniProgramSDKError} 当 bridge、运行时或宿主能力调用失败时抛出。
2459
+ * @throws {@link HbMiniProgramNetworkError} 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出。
2460
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、运行时或宿主能力调用失败时抛出。
2461
2461
  *
2462
2462
  * @remarks
2463
2463
  * `validateStatus` 仅在 SDK 侧执行,不会跨 bridge 传输函数值。
@@ -2475,7 +2475,7 @@ async function request(requester, config) {
2475
2475
  const validateStatus = config.validateStatus || DEFAULT_VALIDATE_STATUS;
2476
2476
  try {
2477
2477
  assertSupportedPublicNetworkRequest(config);
2478
- const responsePayload = await requester.request(NETWORK_REQUEST_METHOD, toRequestPayload(config));
2478
+ const responsePayload = (await requester.request(NETWORK_REQUEST_METHOD, toRequestPayload(config)));
2479
2479
  const response = toNetworkResponse(responsePayload, config);
2480
2480
  if (!validateStatus(response.status)) {
2481
2481
  const error = new HbMiniProgramNetworkError(response);
@@ -2527,21 +2527,21 @@ function assertSupportedPublicNetworkRequest(config) {
2527
2527
  /**
2528
2528
  * 创建 network 模块。
2529
2529
  *
2530
- * @param requester 底层 bridge 请求能力。
2530
+ * @param requester - 底层 bridge 请求能力。
2531
2531
  * @returns 面向业务层的网络模块对象。
2532
2532
  */
2533
2533
  function createNetworkModule(requester) {
2534
2534
  return {
2535
- request: config => request(requester, config),
2535
+ request: (config) => request(requester, config),
2536
2536
  };
2537
2537
  }
2538
2538
 
2539
2539
  /**
2540
2540
  * 获取当前小程序窗口信息。
2541
2541
  *
2542
- * @param requester 底层 bridge 请求能力。
2542
+ * @param requester - 底层 bridge 请求能力。
2543
2543
  * @returns 当前小程序可用窗口信息。
2544
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2544
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2545
2545
  */
2546
2546
  function getWindowInfo(requester) {
2547
2547
  return requester.request(VIEWPORT_GET_WINDOW_INFO_METHOD);
@@ -2549,10 +2549,10 @@ function getWindowInfo(requester) {
2549
2549
  /**
2550
2550
  * 设置导航栏关闭按钮与状态栏图标/文字的前景样式。
2551
2551
  *
2552
- * @param requester 底层 bridge 请求能力。
2553
- * @param options 导航栏样式配置。
2552
+ * @param requester - 底层 bridge 请求能力。
2553
+ * @param options - 导航栏样式配置。
2554
2554
  * @returns 宿主接受设置后 resolve。
2555
- * @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2555
+ * @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
2556
2556
  */
2557
2557
  function setNavigationBarStyle(requester, options) {
2558
2558
  return requester.request(VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD, options);
@@ -2560,13 +2560,13 @@ function setNavigationBarStyle(requester, options) {
2560
2560
  /**
2561
2561
  * 创建 Viewport 模块。
2562
2562
  *
2563
- * @param requester 底层 bridge 请求能力。
2563
+ * @param requester - 底层 bridge 请求能力。
2564
2564
  * @returns 面向业务层的 Viewport 模块对象。
2565
2565
  */
2566
2566
  function createViewportModule(requester) {
2567
2567
  return {
2568
2568
  getWindowInfo: () => getWindowInfo(requester),
2569
- setNavigationBarStyle: options => setNavigationBarStyle(requester, options),
2569
+ setNavigationBarStyle: (options) => setNavigationBarStyle(requester, options),
2570
2570
  };
2571
2571
  }
2572
2572
 
@@ -2579,7 +2579,7 @@ function createViewportModule(requester) {
2579
2579
  * `app_user_id`,并隐式授予 `identity` 与 `profile` 后返回昵称与头像,不展示授权 UI。未登录时返回
2580
2580
  * `{ isHeyboxAppLoggedIn: false, authorization: null, userInfo: null }`。
2581
2581
  *
2582
- * @throws {HbMiniProgramSDKError} 当 SDK 调用失败时抛出。
2582
+ * @throws {@link HbMiniProgramSDKError} 当 SDK 调用失败时抛出。
2583
2583
  */
2584
2584
  function getInfo(requester) {
2585
2585
  return requester.request(USER_GET_INFO_METHOD);
@@ -2592,8 +2592,8 @@ function revokeAuthorization(requester) {
2592
2592
  /**
2593
2593
  * 获取当前用户 Steam 游戏库。
2594
2594
  *
2595
- * @param requester 底层 bridge 请求能力。
2596
- * @param options 查询与分页参数。
2595
+ * @param requester - 底层 bridge 请求能力。
2596
+ * @param options - 查询与分页参数。
2597
2597
  * @returns 当前用户 Steam 游戏库;未登录或未绑定 Steam 时返回状态对象。
2598
2598
  */
2599
2599
  function getSteamGameList(requester, options) {
@@ -2623,8 +2623,8 @@ function hideLoading(requester) {
2623
2623
  /** 创建 UI 模块。 */
2624
2624
  function createUiModule(requester) {
2625
2625
  return {
2626
- showToast: options => showToast(requester, options),
2627
- showLoading: options => showLoading(requester, options),
2626
+ showToast: (options) => showToast(requester, options),
2627
+ showLoading: (options) => showLoading(requester, options),
2628
2628
  hideLoading: () => hideLoading(requester),
2629
2629
  };
2630
2630
  }
@@ -2640,8 +2640,8 @@ function setClipboard(requester, options) {
2640
2640
  /** 创建设备能力模块。 */
2641
2641
  function createDeviceModule(requester) {
2642
2642
  return {
2643
- vibrate: options => vibrate(requester, options),
2644
- setClipboard: options => setClipboard(requester, options),
2643
+ vibrate: (options) => vibrate(requester, options),
2644
+ setClipboard: (options) => setClipboard(requester, options),
2645
2645
  };
2646
2646
  }
2647
2647
 
@@ -2752,7 +2752,7 @@ function createNavigationModule(requester) {
2752
2752
  return {
2753
2753
  close: () => close(requester),
2754
2754
  reload: () => reload(requester),
2755
- openAppPage: options => openAppPage(requester, options),
2755
+ openAppPage: (options) => openAppPage(requester, options),
2756
2756
  };
2757
2757
  }
2758
2758
 
@@ -2815,8 +2815,8 @@ class MiniProgramSDK {
2815
2815
  /**
2816
2816
  * 注册小程序生命周期或业务事件。
2817
2817
  *
2818
- * @param eventName 要监听的事件名。
2819
- * @param handler 事件处理函数。
2818
+ * @param eventName - 要监听的事件名。
2819
+ * @param handler - 事件处理函数。
2820
2820
  * @returns 事件解绑函数。
2821
2821
  */
2822
2822
  on(eventName, handler) {
@@ -2825,8 +2825,8 @@ class MiniProgramSDK {
2825
2825
  /**
2826
2826
  * 移除小程序生命周期或业务事件。
2827
2827
  *
2828
- * @param eventName 要移除的事件名。
2829
- * @param handler 对应的事件处理函数。
2828
+ * @param eventName - 要移除的事件名。
2829
+ * @param handler - 对应的事件处理函数。
2830
2830
  */
2831
2831
  off(eventName, handler) {
2832
2832
  this.client.off(eventName, handler);
@@ -2845,7 +2845,7 @@ class MiniProgramSDK {
2845
2845
  /**
2846
2846
  * 创建独立 SDK 实例。
2847
2847
  *
2848
- * @param options SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
2848
+ * @param options - SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
2849
2849
  * @returns 可独立管理生命周期的 `MiniProgramSDK` 实例。
2850
2850
  *
2851
2851
  * @remarks
@@ -2871,20 +2871,59 @@ function getDefaultSDK() {
2871
2871
  }
2872
2872
  return defaultSDK;
2873
2873
  }
2874
- /** 获取默认 SDK 实例的当前握手状态。 */
2874
+ /**
2875
+ * 获取默认 SDK 实例的当前握手状态。
2876
+ *
2877
+ * @since 0.7.0-alpha.9
2878
+ * @hbPlatform android
2879
+ * @hbPlatform ios
2880
+ * @hbPlatform ohos
2881
+ * @hbPlatform windows
2882
+ * @hbPlatform macos
2883
+ * @hbClient android none
2884
+ * @hbClient ios none
2885
+ * @hbClient ohos none
2886
+ * @hbClient windows none
2887
+ * @hbClient macos none
2888
+ */
2875
2889
  function getHandshakeState() {
2876
2890
  return getDefaultSDK().getHandshakeState();
2877
2891
  }
2878
- /** 订阅默认 SDK 实例的握手状态,并立即接收当前状态。 */
2892
+ /**
2893
+ * 订阅默认 SDK 实例的握手状态,并立即接收当前状态。
2894
+ *
2895
+ * @since 0.7.0-alpha.9
2896
+ * @hbPlatform android
2897
+ * @hbPlatform ios
2898
+ * @hbPlatform ohos
2899
+ * @hbPlatform windows
2900
+ * @hbPlatform macos
2901
+ * @hbClient android none
2902
+ * @hbClient ios none
2903
+ * @hbClient ohos none
2904
+ * @hbClient windows none
2905
+ * @hbClient macos none
2906
+ */
2879
2907
  function onHandshakeStateChange(handler) {
2880
2908
  return getDefaultSDK().onHandshakeStateChange(handler);
2881
2909
  }
2882
2910
  /**
2883
2911
  * 注册默认 SDK 实例的事件监听。
2884
2912
  *
2885
- * @param eventName 要监听的事件名。
2886
- * @param handler 事件处理函数。
2913
+ * @param eventName - 要监听的事件名。
2914
+ * @param handler - 事件处理函数。
2887
2915
  * @returns 事件解绑函数。
2916
+ * @since 0.2.0-alpha.0
2917
+ * @hbPlatform android
2918
+ * @hbPlatform ios
2919
+ * @hbPlatform ohos
2920
+ * @hbPlatform windows
2921
+ * @hbPlatform macos
2922
+ * @hbClient android none
2923
+ * @hbClient ios none
2924
+ * @hbClient ohos none
2925
+ * @hbClient windows none
2926
+ * @hbClient macos none
2888
2927
  */
2889
2928
  function on(eventName, handler) {
2890
2929
  return getDefaultSDK().on(eventName, handler);
@@ -2892,9 +2931,20 @@ function on(eventName, handler) {
2892
2931
  /**
2893
2932
  * 移除默认 SDK 实例的事件监听。
2894
2933
  *
2895
- * @param eventName 要移除的事件名。
2896
- * @param handler 对应的事件处理函数。
2934
+ * @param eventName - 要移除的事件名。
2935
+ * @param handler - 对应的事件处理函数。
2897
2936
  * @returns 无返回值。
2937
+ * @since 0.2.0-alpha.0
2938
+ * @hbPlatform android
2939
+ * @hbPlatform ios
2940
+ * @hbPlatform ohos
2941
+ * @hbPlatform windows
2942
+ * @hbPlatform macos
2943
+ * @hbClient android none
2944
+ * @hbClient ios none
2945
+ * @hbClient ohos none
2946
+ * @hbClient windows none
2947
+ * @hbClient macos none
2898
2948
  */
2899
2949
  function off(eventName, handler) {
2900
2950
  getDefaultSDK().off(eventName, handler);
@@ -2937,7 +2937,7 @@ function shouldUploadDistFile(relativePath) {
2937
2937
  /**
2938
2938
  * 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
2939
2939
  *
2940
- * @param files 待处理的构建产物文件。
2940
+ * @param files - 待处理的构建产物文件。
2941
2941
  * @returns 保留输入附加字段的有序文件列表。
2942
2942
  * @throws 路径不规范、路径重复或文件大小非法时抛出错误。
2943
2943
  */
@@ -2946,7 +2946,7 @@ function prepareMiniappArtifactFiles(files) {
2946
2946
  throw new Error('构建产物文件数量超出签名协议上限');
2947
2947
  }
2948
2948
  const usedPaths = new Set();
2949
- const prepared = files.map(file => {
2949
+ const prepared = files.map((file) => {
2950
2950
  const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
2951
2951
  if (usedPaths.has(relativePath)) {
2952
2952
  throw new Error(`构建产物包含重复文件路径:${relativePath}`);
@@ -2960,15 +2960,15 @@ function prepareMiniappArtifactFiles(files) {
2960
2960
  /**
2961
2961
  * 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
2962
2962
  *
2963
- * @param files 待上传的构建产物文件。
2964
- * @param options 小程序和长度限制配置。
2963
+ * @param files - 待上传的构建产物文件。
2964
+ * @param options - 小程序和长度限制配置。
2965
2965
  * @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
2966
2966
  */
2967
2967
  function validateMiniappUploadPathLengths(files, options) {
2968
2968
  const maxLength = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
2969
2969
  const prefix = `/u/${getMiniProgramUploadAlias(options.miniProgramId)}/${'x'.repeat(MINIAPP_UPLOAD_SESSION_REF_LENGTH)}/`;
2970
2970
  const prefixLength = textEncoder.encode(prefix).length;
2971
- const tooLongFile = files.find(file => {
2971
+ const tooLongFile = files.find((file) => {
2972
2972
  const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
2973
2973
  return prefixLength + textEncoder.encode(relativePath).length > maxLength;
2974
2974
  });
@@ -2977,7 +2977,7 @@ function validateMiniappUploadPathLengths(files, options) {
2977
2977
  /**
2978
2978
  * 创建 v1 整包签名头。
2979
2979
  *
2980
- * @param fileCount 参与签名的文件数量。
2980
+ * @param fileCount - 参与签名的文件数量。
2981
2981
  * @returns 包含协议标识和文件数量的字节数组。
2982
2982
  * @throws 文件数量超出协议范围时抛出错误。
2983
2983
  */
@@ -2990,7 +2990,7 @@ function createMiniappArtifactSignatureHeader(fileCount) {
2990
2990
  /**
2991
2991
  * 创建单个文件的 v1 framing header。
2992
2992
  *
2993
- * @param file 已规范化或待校验的构建产物文件。
2993
+ * @param file - 已规范化或待校验的构建产物文件。
2994
2994
  * @returns 包含路径长度、路径和文件大小的字节数组。
2995
2995
  * @throws 文件路径或大小非法时抛出错误。
2996
2996
  */
@@ -3003,9 +3003,9 @@ function createMiniappArtifactFileHeader(file) {
3003
3003
  /**
3004
3004
  * 校验服务端 session 文件映射,并计算仍需上传的文件。
3005
3005
  *
3006
- * @param localFiles 本地构建产物文件。
3007
- * @param serverFiles 服务端签发的文件映射。
3008
- * @param uploadedKeys 服务端已确认上传成功的 key。
3006
+ * @param localFiles - 本地构建产物文件。
3007
+ * @param serverFiles - 服务端签发的文件映射。
3008
+ * @param uploadedKeys - 服务端已确认上传成功的 key。
3009
3009
  * @returns 完整映射、待上传文件和已确认 key。
3010
3010
  * @throws 服务端映射与本地产物不一致时抛出错误。
3011
3011
  */
@@ -3037,7 +3037,7 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
3037
3037
  serverSizes.set(relativePath, size);
3038
3038
  knownKeys.add(key);
3039
3039
  }
3040
- const files = preparedFiles.map(file => {
3040
+ const files = preparedFiles.map((file) => {
3041
3041
  const key = mappings.get(file.relativePath);
3042
3042
  if (!key) {
3043
3043
  throw new Error(`上传会话缺少文件映射:${file.relativePath}`);
@@ -3057,7 +3057,7 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
3057
3057
  }
3058
3058
  return {
3059
3059
  files,
3060
- missingFiles: files.filter(file => !completed.has(file.key)),
3060
+ missingFiles: files.filter((file) => !completed.has(file.key)),
3061
3061
  uploadedKeys: [...completed],
3062
3062
  };
3063
3063
  }
@@ -3075,7 +3075,7 @@ function normalizeMiniappArtifactRelativePath(relativePath) {
3075
3075
  if (containsControlCharacter(value) || UNPAIRED_SURROGATE_PATTERN.test(value)) {
3076
3076
  throw new Error(`构建产物路径包含非法字符:${value}`);
3077
3077
  }
3078
- if (value.split('/').some(segment => !segment || segment === '.' || segment === '..')) {
3078
+ if (value.split('/').some((segment) => !segment || segment === '.' || segment === '..')) {
3079
3079
  throw new Error(`构建产物路径包含非法目录段:${value}`);
3080
3080
  }
3081
3081
  if (value.includes(',')) {
@@ -2935,7 +2935,7 @@ function shouldUploadDistFile(relativePath) {
2935
2935
  /**
2936
2936
  * 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
2937
2937
  *
2938
- * @param files 待处理的构建产物文件。
2938
+ * @param files - 待处理的构建产物文件。
2939
2939
  * @returns 保留输入附加字段的有序文件列表。
2940
2940
  * @throws 路径不规范、路径重复或文件大小非法时抛出错误。
2941
2941
  */
@@ -2944,7 +2944,7 @@ function prepareMiniappArtifactFiles(files) {
2944
2944
  throw new Error('构建产物文件数量超出签名协议上限');
2945
2945
  }
2946
2946
  const usedPaths = new Set();
2947
- const prepared = files.map(file => {
2947
+ const prepared = files.map((file) => {
2948
2948
  const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
2949
2949
  if (usedPaths.has(relativePath)) {
2950
2950
  throw new Error(`构建产物包含重复文件路径:${relativePath}`);
@@ -2958,15 +2958,15 @@ function prepareMiniappArtifactFiles(files) {
2958
2958
  /**
2959
2959
  * 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
2960
2960
  *
2961
- * @param files 待上传的构建产物文件。
2962
- * @param options 小程序和长度限制配置。
2961
+ * @param files - 待上传的构建产物文件。
2962
+ * @param options - 小程序和长度限制配置。
2963
2963
  * @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
2964
2964
  */
2965
2965
  function validateMiniappUploadPathLengths(files, options) {
2966
2966
  const maxLength = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
2967
2967
  const prefix = `/u/${getMiniProgramUploadAlias(options.miniProgramId)}/${'x'.repeat(MINIAPP_UPLOAD_SESSION_REF_LENGTH)}/`;
2968
2968
  const prefixLength = textEncoder.encode(prefix).length;
2969
- const tooLongFile = files.find(file => {
2969
+ const tooLongFile = files.find((file) => {
2970
2970
  const relativePath = normalizeMiniappArtifactRelativePath(file.relativePath);
2971
2971
  return prefixLength + textEncoder.encode(relativePath).length > maxLength;
2972
2972
  });
@@ -2975,7 +2975,7 @@ function validateMiniappUploadPathLengths(files, options) {
2975
2975
  /**
2976
2976
  * 创建 v1 整包签名头。
2977
2977
  *
2978
- * @param fileCount 参与签名的文件数量。
2978
+ * @param fileCount - 参与签名的文件数量。
2979
2979
  * @returns 包含协议标识和文件数量的字节数组。
2980
2980
  * @throws 文件数量超出协议范围时抛出错误。
2981
2981
  */
@@ -2988,7 +2988,7 @@ function createMiniappArtifactSignatureHeader(fileCount) {
2988
2988
  /**
2989
2989
  * 创建单个文件的 v1 framing header。
2990
2990
  *
2991
- * @param file 已规范化或待校验的构建产物文件。
2991
+ * @param file - 已规范化或待校验的构建产物文件。
2992
2992
  * @returns 包含路径长度、路径和文件大小的字节数组。
2993
2993
  * @throws 文件路径或大小非法时抛出错误。
2994
2994
  */
@@ -3001,9 +3001,9 @@ function createMiniappArtifactFileHeader(file) {
3001
3001
  /**
3002
3002
  * 校验服务端 session 文件映射,并计算仍需上传的文件。
3003
3003
  *
3004
- * @param localFiles 本地构建产物文件。
3005
- * @param serverFiles 服务端签发的文件映射。
3006
- * @param uploadedKeys 服务端已确认上传成功的 key。
3004
+ * @param localFiles - 本地构建产物文件。
3005
+ * @param serverFiles - 服务端签发的文件映射。
3006
+ * @param uploadedKeys - 服务端已确认上传成功的 key。
3007
3007
  * @returns 完整映射、待上传文件和已确认 key。
3008
3008
  * @throws 服务端映射与本地产物不一致时抛出错误。
3009
3009
  */
@@ -3035,7 +3035,7 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
3035
3035
  serverSizes.set(relativePath, size);
3036
3036
  knownKeys.add(key);
3037
3037
  }
3038
- const files = preparedFiles.map(file => {
3038
+ const files = preparedFiles.map((file) => {
3039
3039
  const key = mappings.get(file.relativePath);
3040
3040
  if (!key) {
3041
3041
  throw new Error(`上传会话缺少文件映射:${file.relativePath}`);
@@ -3055,7 +3055,7 @@ function resolveMiniappUploadSessionFiles(localFiles, serverFiles, uploadedKeys)
3055
3055
  }
3056
3056
  return {
3057
3057
  files,
3058
- missingFiles: files.filter(file => !completed.has(file.key)),
3058
+ missingFiles: files.filter((file) => !completed.has(file.key)),
3059
3059
  uploadedKeys: [...completed],
3060
3060
  };
3061
3061
  }
@@ -3073,7 +3073,7 @@ function normalizeMiniappArtifactRelativePath(relativePath) {
3073
3073
  if (containsControlCharacter(value) || UNPAIRED_SURROGATE_PATTERN.test(value)) {
3074
3074
  throw new Error(`构建产物路径包含非法字符:${value}`);
3075
3075
  }
3076
- if (value.split('/').some(segment => !segment || segment === '.' || segment === '..')) {
3076
+ if (value.split('/').some((segment) => !segment || segment === '.' || segment === '..')) {
3077
3077
  throw new Error(`构建产物路径包含非法目录段:${value}`);
3078
3078
  }
3079
3079
  if (value.includes(',')) {
@@ -1,5 +1,7 @@
1
1
  # <%= projectName %>
2
2
 
3
+ `vite.config.ts` 中的 `miniappManifest({ platforms })` 声明本项目承诺适配的平台。模板预填的 `android`、`ios`、`ohos` 只是初始配置;发布前请按实际目标调整,并在每个声明的平台完成真机验收。
4
+
3
5
  这是通过 `hb-sdk create` 生成的小黑盒工坊小程序模板。项目使用 Vue 3、Vite、TypeScript 和 `@heybox/hb-sdk`。
4
6
 
5
7
  ## 使用命令
@@ -4,5 +4,5 @@ import { defineConfig } from 'vite';
4
4
 
5
5
  export default defineConfig({
6
6
  base: './',
7
- plugins: [vue(), miniappManifest()],
7
+ plugins: [vue(), miniappManifest({ platforms: ['android', 'ios', 'ohos'] })],
8
8
  });