@heybox/hb-sdk 0.8.4-alpha.0 → 0.8.5

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 (33) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cli-chunks/{build-B1EpaBX8.cjs → build-zYnPSPFa.cjs} +5 -5
  3. package/dist/cli-chunks/{context-B_fkAKCx.cjs → context-DWoKsM_O.cjs} +2 -2
  4. package/dist/cli-chunks/{create-B4-C6RHp.cjs → create-C9FcEn9Y.cjs} +1 -1
  5. package/dist/cli-chunks/{dev-BEuaWe1E.cjs → dev-VxeEocjt.cjs} +340 -37
  6. package/dist/cli-chunks/{doctor-CYs1IzNT.cjs → doctor-6Cf9o1hD.cjs} +1 -1
  7. package/dist/cli-chunks/{index-X0IInb1Z.cjs → index-BpLYUwNe.cjs} +2 -2
  8. package/dist/cli-chunks/{index-BHMHVtD3.cjs → index-Brq_-WV3.cjs} +159 -67
  9. package/dist/cli-chunks/{index.esm-UDAU_Fxa.cjs → index.esm-DMvmTtIS.cjs} +7 -7
  10. package/dist/cli-chunks/{login-89UIn4WK.cjs → login-DeZpNrkY.cjs} +2 -2
  11. package/dist/cli-chunks/{project-vite-CossJ4nB.cjs → project-vite-TFEwLzYM.cjs} +1 -1
  12. package/dist/cli-chunks/{remote-b59420VC.cjs → remote-DOU11SNj.cjs} +7 -7
  13. package/dist/cli-chunks/{runtime-gate-YxmVuwbW.cjs → runtime-gate-DikSEEtm.cjs} +1 -1
  14. package/dist/cli-chunks/{runtime-permission-env-6Vtqki6F.cjs → runtime-permission-env-Bs_JqpTM.cjs} +1 -1
  15. package/dist/cli-chunks/{session-BH6zBMTi.cjs → session-CbisOcE4.cjs} +63 -1
  16. package/dist/cli-chunks/{skill-B5RsSYyk.cjs → skill-B82gXQhX.cjs} +2 -2
  17. package/dist/cli-chunks/{version-D9DtIjAK.cjs → version-UEmqQ6A-.cjs} +1 -1
  18. package/dist/cli.cjs +1 -1
  19. package/dist/devtools/browser-dev-host/assets/browser-dev-host-MOwoKrAP.js +102 -0
  20. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-BSLoUst-.js → desktop-app-launch-BcQjavzW.js} +1 -1
  21. package/dist/devtools/browser-dev-host/assets/{index-Bw1Bky5v.js → index-CS-AbGTE.js} +3 -3
  22. package/dist/devtools/browser-dev-host/index.html +2 -2
  23. package/dist/index.cjs.js +1 -1
  24. package/dist/index.esm.js +1 -1
  25. package/dist/vite.cjs.js +1 -1
  26. package/dist/vite.esm.js +1 -1
  27. package/package.json +6 -6
  28. package/skill/skill.json +4 -4
  29. package/types/modules/auth/index.d.ts +4 -0
  30. package/types/modules/cloud/index.d.ts +25 -0
  31. package/types/modules/user/index.d.ts +16 -0
  32. package/types/protocol/dev-session.d.ts +18 -0
  33. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DIwhte2r.js +0 -102
@@ -5,8 +5,8 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta name="theme-color" content="#f4f5f7" />
7
7
  <title>小程序工坊调试台</title>
8
- <script type="module" crossorigin src="/assets/index-Bw1Bky5v.js"></script>
9
- <link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-BSLoUst-.js">
8
+ <script type="module" crossorigin src="/assets/index-CS-AbGTE.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-BcQjavzW.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-0Ac39Njs.css">
11
11
  </head>
12
12
  <body>
package/dist/index.cjs.js CHANGED
@@ -1342,7 +1342,7 @@ function createMessageId() {
1342
1342
  /** 构建时替换为当前发布包的实际版本。 */
1343
1343
  const HB_SDK_VERSION = typeof undefined === 'string'
1344
1344
  ? undefined
1345
- : '0.8.4-alpha.0';
1345
+ : '0.8.5';
1346
1346
 
1347
1347
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
1348
1348
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
package/dist/index.esm.js CHANGED
@@ -1338,7 +1338,7 @@ function createMessageId() {
1338
1338
  /** 构建时替换为当前发布包的实际版本。 */
1339
1339
  const HB_SDK_VERSION = typeof undefined === 'string'
1340
1340
  ? undefined
1341
- : '0.8.4-alpha.0';
1341
+ : '0.8.5';
1342
1342
 
1343
1343
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
1344
1344
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
package/dist/vite.cjs.js CHANGED
@@ -2948,7 +2948,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
2948
2948
  /** 构建时替换为当前发布包的实际版本。 */
2949
2949
  const HB_SDK_VERSION = typeof undefined === 'string'
2950
2950
  ? undefined
2951
- : '0.8.4-alpha.0';
2951
+ : '0.8.5';
2952
2952
 
2953
2953
  /**
2954
2954
  * iframe 与调试台页面的开发期 console 捕获转发。
package/dist/vite.esm.js CHANGED
@@ -2945,7 +2945,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
2945
2945
  /** 构建时替换为当前发布包的实际版本。 */
2946
2946
  const HB_SDK_VERSION = typeof undefined === 'string'
2947
2947
  ? undefined
2948
- : '0.8.4-alpha.0';
2948
+ : '0.8.5';
2949
2949
 
2950
2950
  /**
2951
2951
  * iframe 与调试台页面的开发期 console 捕获转发。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.8.4-alpha.0",
3
+ "version": "0.8.5",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -65,7 +65,7 @@
65
65
  "undici": "^7.28.0",
66
66
  "ws": "^8.18.0",
67
67
  "sharp": "^0.34.5",
68
- "@heybox/hb-sdk-protocol": "0.8.4-alpha.0"
68
+ "@heybox/hb-sdk-protocol": "0.8.5"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "vite": ">=5"
@@ -116,13 +116,13 @@
116
116
  "vue-tsc": "^3.3.7",
117
117
  "vite": "^8.0.12",
118
118
  "vitest": "^3.2.4",
119
- "@heybox-domain/heybox-vue3-ui": "~0.1.0",
120
119
  "@heybox-domain/heybox-theme": "~0.1.0",
121
120
  "@heybox/hb-api": "~1.28.9",
122
- "@heybox/hb-sdk-runtime": "~0.8.4-alpha.0",
123
- "@heybox/runtime-policy": "~0.2.0",
121
+ "@heybox-domain/heybox-vue3-ui": "~0.1.0",
122
+ "@heybox/hb-sdk-runtime": "~0.8.5",
124
123
  "@heybox/runtime": "~0.2.0",
125
- "@heybox/runtime-transport-fetch": "~0.2.0"
124
+ "@heybox/runtime-transport-fetch": "~0.2.0",
125
+ "@heybox/runtime-policy": "~0.2.0"
126
126
  },
127
127
  "publishConfig": {
128
128
  "registry": "https://registry.npmjs.org/",
package/skill/skill.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.8.4-alpha.0+skill.aa24d6656331",
3
+ "skillVersion": "0.8.5+skill.aa24d6656331",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.8.4-alpha.0",
7
- "compatibility": "0.8.4-alpha.0"
6
+ "version": "0.8.5",
7
+ "compatibility": "0.8.5"
8
8
  },
9
9
  "distribution": {
10
10
  "type": "npm",
11
11
  "package": "@heybox/hb-sdk",
12
- "version": "0.8.4-alpha.0",
12
+ "version": "0.8.5",
13
13
  "path": "skill"
14
14
  },
15
15
  "integrity": "sha256-aa24d6656331cbad8f6aae7735258a49d7f1a82f6e900415de53a1b93a30ddb8"
@@ -108,6 +108,10 @@ export interface MiniProgramAuthModule {
108
108
  * @throws {@link HbMiniProgramSDKError} `REQUEST_FAILED`、`REQUEST_UNSUPPORTED`、
109
109
  * `INVALID_RESPONSE`、`INVALID_STATE`、`METHOD_FORBIDDEN` 或 `RUNTIME_DESTROYED`:Host
110
110
  * 请求、响应、身份上下文、能力支持或 Runtime 生命周期不满足调用要求。
111
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:登录或授权上下文请求遇到上游 403/429,
112
+ * 或该 endpoint 处于 Runtime 熔断窗口;`error.data.retryAfterMs`(可能缺失)给出建议退避时长。
113
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
114
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
111
115
  * @throws {@link HbMiniProgramSDKError} SDK 握手、bridge 请求超时或 SDK 销毁时,抛出对应
112
116
  * 初始化/transport 错误;业务应根据稳定的 `error.code` 分支,不比较 `message`。
113
117
  *
@@ -280,6 +280,11 @@ export interface MiniProgramCloudLeaderboardModule {
280
280
  * `METHOD_FORBIDDEN` / `REQUEST_UNSUPPORTED`:当前 Host 缺少所需账号或受信网络能力;
281
281
  * `REQUEST_FAILED`:平台请求失败;`INVALID_RESPONSE`:返回记录字段不符合公开合同。
282
282
  * 其他 bridge 超时与 SDK 状态错误会保留对应错误码。
283
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:上游返回 403/429,或该 endpoint 处于
284
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
285
+ * 建议退避时长。
286
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
287
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
283
288
  * @throws `DOMException` extra 含函数、Symbol 等不可 structured-clone 的内容时,浏览器可能
284
289
  * 在请求发送前抛出 `DataCloneError`。
285
290
  *
@@ -359,6 +364,11 @@ export interface MiniProgramCloudLeaderboardModule {
359
364
  * `METHOD_FORBIDDEN` / `REQUEST_UNSUPPORTED`:当前 Host 缺少所需受信网络能力;
360
365
  * `REQUEST_FAILED`:平台请求失败;`INVALID_RESPONSE`:entries、cursor、hasMore 或任一记录
361
366
  * 字段不符合公开合同。其他 bridge 超时与 SDK 状态错误会保留对应错误码。
367
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:上游返回 403/429,或该 endpoint 处于
368
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
369
+ * 建议退避时长。
370
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
371
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
362
372
  *
363
373
  * @remarks
364
374
  * 该查询不要求 Host 登录、用户授权或可信用户手势。它需要声明 `leaderboard`,但不需要
@@ -439,6 +449,11 @@ export interface MiniProgramCloudLeaderboardModule {
439
449
  * `METHOD_FORBIDDEN` / `REQUEST_UNSUPPORTED`:当前 Host 缺少所需账号或受信网络能力;
440
450
  * 其他网络失败、响应字段不合法和 bridge 超时分别保留对应 `REQUEST_FAILED`、
441
451
  * `INVALID_RESPONSE` 或 SDK 错误码。
452
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:上游返回 403/429,或该 endpoint 处于
453
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
454
+ * 建议退避时长。
455
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
456
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
442
457
  *
443
458
  * @remarks
444
459
  * 当前用户不来自参数。Runtime 每次调用都会先向 Host 校验当前登录账号,再用 Host 持有的
@@ -520,6 +535,11 @@ export interface MiniProgramCloudLeaderboardModule {
520
535
  * `METHOD_FORBIDDEN` / `REQUEST_UNSUPPORTED`:当前 Host 缺少所需账号或受信网络能力;
521
536
  * 其他网络失败、响应不合法和 bridge 超时分别保留对应 `REQUEST_FAILED`、
522
537
  * `INVALID_RESPONSE` 或 SDK 错误码。
538
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:上游返回 403/429,或该 endpoint 处于
539
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
540
+ * 建议退避时长。
541
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
542
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
523
543
  *
524
544
  * @remarks
525
545
  * 当前用户不来自参数。Runtime 先向 Host 读取当前登录状态,再用 Host 持有的受信会话调用
@@ -587,6 +607,11 @@ export interface MiniProgramCloudLeaderboardModule {
587
607
  * `METHOD_FORBIDDEN` / `REQUEST_UNSUPPORTED`:当前 Host 缺少所需受信网络能力;
588
608
  * `REQUEST_FAILED`:平台请求失败;`INVALID_RESPONSE`:返回 key、order 或 rankLimit
589
609
  * 不符合公开合同。其他 bridge 超时与 SDK 状态错误会保留对应错误码。
610
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED`:上游返回 403/429,或该 endpoint 处于
611
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
612
+ * 建议退避时长。
613
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME`:Runtime 本地配额或循环检测
614
+ * 拒绝,请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。两者都应停止立即重试。
590
615
  *
591
616
  * @remarks
592
617
  * 该查询不读取当前用户,也不要求 Host 登录、用户授权或可信用户手势。它需要声明
@@ -23,6 +23,12 @@ export interface MiniProgramUserModule {
23
23
  * `HEYBOX_APP_LOGIN_REQUIRED` 表示初次登录态检查后,Host 会话在隔离身份读取期间失效;
24
24
  * `AUTHORIZATION_CONTEXT_CHANGED` 表示请求期间发生账号切换或授权撤销;
25
25
  * `RUNTIME_DESTROYED` 表示 Runtime 已终止。握手失败也会以该错误类型拒绝调用。
26
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
27
+ * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
28
+ * 建议退避时长。
29
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
30
+ * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
31
+ * 两种情况调用方都应停止立即重试,避免把用户 IP 打成被封。
26
32
  *
27
33
  * @remarks
28
34
  * 该读取不展示授权 UI,也不要求可信用户手势。Manifest 中必须声明 `userInfo`,但不需要
@@ -89,6 +95,11 @@ export interface MiniProgramUserModule {
89
95
  * @throws {@link HbMiniProgramSDKError} `REQUEST_UNSUPPORTED` / `REQUEST_FAILED` /
90
96
  * `INVALID_RESPONSE` 表示 Host 请求能力、撤销请求或响应失败;`AUTHORIZATION_CONTEXT_CHANGED`
91
97
  * 表示请求期间切换了账号或授权上下文已变化。
98
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
99
+ * Runtime 熔断窗口;`error.data.retryAfterMs`(可能缺失)给出建议退避时长。
100
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
101
+ * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
102
+ * 两种情况调用方都应停止立即重试。
92
103
  * @throws {@link HbMiniProgramSDKError} `RUNTIME_DESTROYED` / `SDK_DESTROYED` 表示 Runtime 或 SDK
93
104
  * 已终止。SDK 握手失败或超过调用超时时间时,还会返回对应握手错误码或 `REQUEST_TIMEOUT`。
94
105
  * @remarks
@@ -157,6 +168,11 @@ export interface MiniProgramUserModule {
157
168
  * @throws {@link HbMiniProgramSDKError} `AUTHORIZATION_CONTEXT_CHANGED` 表示请求期间切换账号
158
169
  * 或撤销授权;`RUNTIME_DESTROYED` / `SDK_DESTROYED` 表示 Runtime 或 SDK 已终止。SDK 握手失败
159
170
  * 或超过调用超时时间时,还会返回对应的握手错误码或 `REQUEST_TIMEOUT`。
171
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
172
+ * Runtime 熔断窗口;`error.data.retryAfterMs`(可能缺失)给出建议退避时长。
173
+ * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
174
+ * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
175
+ * 两种情况调用方都应停止立即重试。
160
176
  * @remarks
161
177
  * 项目必须在 `package.json#heybox.permissions` 声明 `steamLibrary`。该能力通过 Host 的受信
162
178
  * 请求读取当前账号数据,不要求公开 `network` 权限,也不展示授权 UI 或要求可信用户手势。
@@ -1,5 +1,21 @@
1
1
  import type { MiniProgramRuntimePermissionsSnapshot } from './runtime-permissions';
2
2
  import type { MiniProgramLocalDevGrant, MiniProgramLocalDevPermissionDeclarations } from '@heybox/hb-sdk-protocol';
3
+ /**
4
+ * 网关限流状态。
5
+ *
6
+ * 加性、向后兼容字段:老宿主页或老 Runtime 忽略即可。CLI 收到 403/429 后把状态透出给
7
+ * 调试页与宿主页,让手机端停止「重连 → 打接口 → 被拒 → 再重连」的自激循环。
8
+ */
9
+ export interface MiniProgramDevRateLimitState {
10
+ /** 是否处于限流中;仅在限流时下发,取值为 true。 */
11
+ limited: boolean;
12
+ /** 网关建议的等待时长(毫秒)。 */
13
+ retryAfterMs?: number;
14
+ /** 限流预计解除的绝对时间(Unix 毫秒)。 */
15
+ untilTs?: number;
16
+ /** 网关原文摘要,仅用于展示。 */
17
+ message?: string;
18
+ }
3
19
  export interface MiniProgramLocalDevContextFields {
4
20
  local_dev_grant?: MiniProgramLocalDevGrant;
5
21
  context_revision?: number;
@@ -9,6 +25,8 @@ export interface MiniProgramLocalDevContextFields {
9
25
  local_dev_launch_token?: string;
10
26
  mini_program_id?: string;
11
27
  companion_manifest_sha256?: string;
28
+ /** 限流状态;正常时不下发该字段。 */
29
+ rate_limit?: MiniProgramDevRateLimitState | null;
12
30
  }
13
31
  /** Dev Shell 读取局域网 Dev Session endpoint 的 query 参数。 */
14
32
  export declare const MINI_PROGRAM_DEV_CONTEXT_QUERY_PARAM = "dev_context_url";