@heybox/hb-sdk 0.5.10 → 0.5.12
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.
- package/README.md +99 -55
- package/dist/cli-chunks/{create-D1W2pkHZ.cjs → create-Ba353lSg.cjs} +1 -1
- package/dist/cli-chunks/{dev-DwbE-c1x.cjs → dev-BhPFNef-.cjs} +1 -1
- package/dist/cli-chunks/{doctor-Bx71WFjM.cjs → doctor-CP4kwgAn.cjs} +1 -1
- package/dist/cli-chunks/{index-D5bZjpH9.cjs → index-BfpHPA6k.cjs} +2 -2
- package/dist/cli-chunks/{index-BBatNb1l.cjs → index-DeamIV1-.cjs} +57 -13
- package/dist/cli-chunks/{login-BX0YmVyi.cjs → login-DMNap0-y.cjs} +2 -2
- package/dist/cli-chunks/{remote-YDmSxyYi.cjs → remote-gXUjRvGB.cjs} +117 -3
- package/dist/cli-chunks/{session-BxZBXDZ-.cjs → session-D5Vf-fNZ.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/mock-host/main.js +590 -0
- package/dist/index.cjs.js +84 -4
- package/dist/index.esm.js +84 -5
- package/dist/miniapp-publish.cjs.js +8 -0
- package/dist/miniapp-publish.esm.js +5 -1
- package/dist/protocol.cjs.js +50 -0
- package/dist/protocol.esm.js +46 -1
- package/package.json +2 -4
- package/skill/SKILL.md +4 -3
- package/skill/references/api-protocol.md +27 -7
- package/skill/references/api-root.md +64 -4
- package/skill/references/cli.md +3 -3
- package/skill/references/examples.md +2 -1
- package/skill/references/llms-index.md +16 -37
- package/skill/references/recipes.md +9 -9
- package/skill/references/safety-boundaries.md +3 -2
- package/skill/scripts/sync-references.mjs +35 -25
- package/skill/skill.json +4 -4
- package/types/core/client.d.ts +5 -1
- package/types/core/sdk.d.ts +3 -0
- package/types/core/singleton.d.ts +3 -0
- package/types/index.d.ts +3 -1
- package/types/miniapp-publish/index.d.ts +4 -0
- package/types/modules/cloud/index.d.ts +100 -0
- package/types/protocol/capabilities.d.ts +55 -2
- package/types/protocol.d.ts +3 -2
package/README.md
CHANGED
|
@@ -250,6 +250,49 @@ const { data } = await storage.getStorage<{ theme: string }>({
|
|
|
250
250
|
|
|
251
251
|
storage key 只允许 1-128 位字母、数字、下划线和连字符。父容器会按小程序维度隔离 key,外部小程序不能读写黑盒客户端全局 storage。
|
|
252
252
|
|
|
253
|
+
### 云端排行榜
|
|
254
|
+
|
|
255
|
+
`cloud.leaderboard` 是平台托管的远端排行榜能力,不是本地 storage,也不是通用网络请求。小程序页面不能传 `userId`;宿主和服务端会按当前登录用户注入身份。
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
import { cloud } from '@heybox/hb-sdk';
|
|
259
|
+
|
|
260
|
+
const entry = await cloud.leaderboard.submit({
|
|
261
|
+
key: 'cube_run_total',
|
|
262
|
+
score: 150,
|
|
263
|
+
extra: {
|
|
264
|
+
run: 2,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const list = await cloud.leaderboard.getList({
|
|
269
|
+
key: 'cube_run_total',
|
|
270
|
+
limit: 20,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const current = await cloud.leaderboard.getCurrentUserEntry({
|
|
274
|
+
key: 'cube_run_total',
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await cloud.leaderboard.deleteCurrentUserEntry({
|
|
278
|
+
key: 'cube_run_total',
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const info = await cloud.leaderboard.getInfo({
|
|
282
|
+
key: 'cube_run_total',
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
排行榜需要先通过管理端创建;管理端创建成功时服务端会同步准备记录集合,之后运行时可立即读写。`key` 不传时服务端会查找当前小程序已创建的 `default` 榜单,不存在时会拒绝请求,不会自动创建空榜。单个小程序最多创建 3 个排行榜,超出时服务端返回 `LEADERBOARD_LIMIT_EXCEEDED`。
|
|
287
|
+
|
|
288
|
+
`order` 在创建榜单时固定,`desc` 表示分数越大越靠前,`asc` 表示分数越小越靠前。同分时按更早更新时间优先,再按 `userId` 稳定排序。`rankLimit` 为 `0` 表示列表不限制展示名次;大于 `0` 时限制 `getList()` 展示范围。当前用户记录仍会保留,但 `submit()` 和 `getCurrentUserEntry()` 只精确计算前 5000 名,且会优先受 `rankLimit` 限制;超过 `min(rankLimit, 5000)`(`rankLimit=0` 时按 5000)时返回 `ranked: false`、`rank: 0`。
|
|
289
|
+
|
|
290
|
+
`submit()` 只在本次 `score` 更优时更新当前用户记录,并返回最终 `LeaderboardEntry`;如果分数不更优,`extra` 也不会更新。同一用户同一榜单的并发提交由服务端串行保护,锁冲突时返回 `LEADERBOARD_SUBMIT_LOCKED`,业务可稍后重试。首次提交未传 `extra` 会保存为空对象;已有记录提交更优分数但未传 `extra` 时会保留旧 `extra`,需要清空时请显式传 `{}`。`score` 必须是有限安全数字,绝对值不能超过 `Number.MAX_SAFE_INTEGER`;`extra` 必须是 JSON 对象,序列化后的 UTF-8 长度不能超过 2048 字节。
|
|
291
|
+
|
|
292
|
+
`getList()` 默认 20 条、最多 100 条;`cursor` 是服务端返回的不透明分页游标,只能把上一页返回的值原样传给下一次 `getList()`,不要解析、拼接或自行构造。非法 cursor 会按参数错误拒绝。服务端会短暂缓存榜单头部结果,当前缓存前 500 条或 `rankLimit` 范围内记录,`submit()`、`deleteCurrentUserEntry()` 和管理端删榜会触发缓存失效;业务不要依赖毫秒级实时刷新。`getInfo()` 返回 `key/order/rankLimit`,其中 `rankLimit` 不包含当前用户记录的 5000 名精确排名计算上限。
|
|
293
|
+
|
|
294
|
+
排行榜后端错误会保留为 `HbMiniProgramSDKError.code`,常见值包括 `LEADERBOARD_DEFAULT_NOT_FOUND`、`LEADERBOARD_LIMIT_EXCEEDED`、`LEADERBOARD_SUBMIT_LOCKED`、`LEADERBOARD_TABLE_NOT_READY`、`InvalidArgument`、`NotFound`、`ResourceExhausted`、`Unauthenticated`。业务可以按 `code` 区分未建榜、并发提交、数据表配置异常、参数错误、容量限制和未登录等场景。
|
|
295
|
+
|
|
253
296
|
### 网络请求
|
|
254
297
|
|
|
255
298
|
`network.request()` 提供窄化的 axios-like 接口。SDK 只接受公开请求字段,真实请求由父容器运行时映射到宿主网络能力。
|
|
@@ -287,7 +330,7 @@ await network.request({
|
|
|
287
330
|
|
|
288
331
|
## 生命周期事件
|
|
289
332
|
|
|
290
|
-
|
|
333
|
+
SDK 实例创建后会自动开始与父容器握手。使用 `on()` 监听父容器派发的小程序事件时,默认单例会被懒创建并自动开始握手;`on()` 会返回取消监听函数,组件卸载或页面销毁时应及时调用。
|
|
291
334
|
|
|
292
335
|
```ts
|
|
293
336
|
import { on } from '@heybox/hb-sdk';
|
|
@@ -328,32 +371,32 @@ try {
|
|
|
328
371
|
|
|
329
372
|
`@heybox/hb-sdk` 随包提供 `hb-sdk` CLI。脚手架项目已在 npm scripts 中接好常用命令;已有项目也可以自行添加 scripts。
|
|
330
373
|
|
|
331
|
-
| 命令
|
|
332
|
-
|
|
|
333
|
-
| `hb-sdk create <project-name>`
|
|
334
|
-
| `hb-sdk dev [--runtime-url <url>]`
|
|
335
|
-
| `hb-sdk login [--login-base-url <url>] [--no-select-entity]`
|
|
336
|
-
| `hb-sdk login status`
|
|
337
|
-
| `hb-sdk login clear`
|
|
338
|
-
| `hb-sdk doctor`
|
|
339
|
-
| `hb-sdk remote access`
|
|
340
|
-
| `hb-sdk remote entity list`
|
|
341
|
-
| `hb-sdk remote entity current`
|
|
342
|
-
| `hb-sdk remote entity switch <entity-id>`
|
|
343
|
-
| `hb-sdk remote list [--status <status>] [--keyword <text>]`
|
|
344
|
-
| `hb-sdk remote create [--yes] [--force-bind]`
|
|
345
|
-
| `hb-sdk remote bind <mini-program-id> [--force]`
|
|
346
|
-
| `hb-sdk remote info`
|
|
347
|
-
| `hb-sdk remote allowlist list/add/remove/set ...`
|
|
374
|
+
| 命令 | 作用 |
|
|
375
|
+
| -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
376
|
+
| `hb-sdk create <project-name>` | 创建外部小程序模板。 |
|
|
377
|
+
| `hb-sdk dev [--runtime-url <url>]` | 启动当前项目的 Vite dev server 和浏览器 mock 宿主环境,并默认打开调试页;`--runtime-url` 会传给真实客户端 dev shell。 |
|
|
378
|
+
| `hb-sdk login [--login-base-url <url>] [--no-select-entity]` | 登录 Heybox,并把 CLI 自己需要的登录态和登录入口环境保存在本地缓存中;默认会引导多主体用户选择服务端 current entity。 |
|
|
379
|
+
| `hb-sdk login status` | 查看脱敏后的 CLI 登录态。 |
|
|
380
|
+
| `hb-sdk login clear` | 清理 CLI 登录态。 |
|
|
381
|
+
| `hb-sdk doctor` | 检查本机 `hb-sdk` Agent Skill 是否匹配当前 SDK,并输出手动安装/刷新命令。 |
|
|
382
|
+
| `hb-sdk remote access` | 查看当前 CLI 用户是否具备创建和管理工坊小程序的资格。 |
|
|
383
|
+
| `hb-sdk remote entity list` | 列出当前 CLI 用户可切换的开发者主体,并标记服务端 current entity。 |
|
|
384
|
+
| `hb-sdk remote entity current` | 查看服务端 current entity,以及该主体的小程序工坊权限状态。 |
|
|
385
|
+
| `hb-sdk remote entity switch <entity-id>` | 切换开发者平台服务端 current entity;不会修改项目绑定的小程序 ID。 |
|
|
386
|
+
| `hb-sdk remote list [--status <status>] [--keyword <text>]` | 列出当前 CLI 用户可管理的远端工坊小程序,用于发现并绑定当前项目。 |
|
|
387
|
+
| `hb-sdk remote create [--yes] [--force-bind]` | 在服务端 current entity 下创建远端工坊小程序并写入当前项目的 `package.json.heybox.miniProgramId`。 |
|
|
388
|
+
| `hb-sdk remote bind <mini-program-id> [--force]` | 校验当前 CLI 用户可管理目标小程序后,再把它绑定到当前项目。 |
|
|
389
|
+
| `hb-sdk remote info` | 查看当前项目绑定的小程序详情。 |
|
|
390
|
+
| `hb-sdk remote allowlist list/add/remove/set ...` | 管理绑定小程序的预览白名单。 |
|
|
348
391
|
| `hb-sdk remote deploy --release-note <text> [--skip-build \| --from-version <version>] [--auto-publish]` | 构建、上传并提交当前小程序版本审核;`--skip-build` 跳过 build 直接上传 `dist/`,`--from-version` 复用指定历史版本产物。 |
|
|
349
|
-
| `hb-sdk remote versions`
|
|
350
|
-
| `hb-sdk remote preview <version>`
|
|
351
|
-
| `hb-sdk remote release <version> [--yes]`
|
|
352
|
-
| `hb-sdk remote withdraw <version> [--yes] [--reason <text>]`
|
|
353
|
-
| `hb-sdk remote take-down [--yes]`
|
|
354
|
-
| `hb-sdk remote reopen [--yes]`
|
|
355
|
-
| `hb-sdk remote square hide [--yes]`
|
|
356
|
-
| `hb-sdk remote square show`
|
|
392
|
+
| `hb-sdk remote versions` | 列出绑定小程序的远端版本。 |
|
|
393
|
+
| `hb-sdk remote preview <version>` | 查看指定版本的远端预览入口。 |
|
|
394
|
+
| `hb-sdk remote release <version> [--yes]` | 发布审核通过的版本;非 TTY 环境必须传 `--yes`。 |
|
|
395
|
+
| `hb-sdk remote withdraw <version> [--yes] [--reason <text>]` | 撤回审核中或已通过但未发布的版本;非 TTY 环境必须传 `--yes`。 |
|
|
396
|
+
| `hb-sdk remote take-down [--yes]` | 下架当前线上小程序;非 TTY 环境必须传 `--yes`。 |
|
|
397
|
+
| `hb-sdk remote reopen [--yes]` | 重新上架已下架的小程序;非 TTY 环境必须传 `--yes`。 |
|
|
398
|
+
| `hb-sdk remote square hide [--yes]` | 隐藏当前绑定小程序在普通用户侧的小程序工坊广场展示;白名单用户仍可见,直接链接不受影响;非 TTY 环境必须传 `--yes`。 |
|
|
399
|
+
| `hb-sdk remote square show` | 恢复当前绑定小程序在普通用户侧的小程序工坊广场展示。 |
|
|
357
400
|
|
|
358
401
|
远端平台操作统一放在 `hb-sdk remote` 命令组下;顶层 `hb-sdk deploy` 已硬切删除,不再作为兼容别名保留。`hb-sdk login` 仍是顶层命令,因为它管理 CLI 登录态,不绑定到某个具体小程序。开发者主体的事实源是服务端 current entity;CLI 登录缓存中的 `selectedEntity` 只是上次选择时的提示快照,用于 `login status` 展示和漂移排障,不能作为权限或归属判断依据。
|
|
359
402
|
|
|
@@ -378,8 +421,8 @@ try {
|
|
|
378
421
|
4. 如果需要以公司的名义发布小程序,需先找 @秦浩东 申请小程序开发权限。
|
|
379
422
|
5. 每次部署都要在 `package.json` 里配置 `heybox.miniProgramProfile.name`、`iconUrl` 和至少一张 `coverImageUrls`,这些资料会随版本提交审核。
|
|
380
423
|
6. 每次部署都要准备发布日志:`hb-sdk remote deploy --release-note "..."`。发布日志 trim 后不能为空,最多 500 个字符,允许换行;CI / 非 TTY 环境缺失时会直接失败,TTY 环境会提示输入。
|
|
381
|
-
|
|
382
|
-
|
|
424
|
+
7. 项目根有 `scripts.build`,会被 CLI 通过 lockfile 自动选用的 `pnpm`、`yarn` 或 `npm` 触发;无 lockfile 时回退 `npm`。
|
|
425
|
+
8. 构建产物落在 `dist/`,包含 `index.html` 和 `manifest.json`。
|
|
383
426
|
|
|
384
427
|
执行流程:
|
|
385
428
|
|
|
@@ -437,29 +480,29 @@ HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1 hb-sdk remote deploy --api-base-url http://12
|
|
|
437
480
|
|
|
438
481
|
`hb-sdk remote` 默认作用于当前项目绑定的小程序,即 `package.json.heybox.miniProgramId`。`remote list` 只展示服务端 current entity 下可管理的小程序,用于发现和绑定;会改变远端状态的命令仍然只操作当前绑定的小程序,不接受临时 `mini_program_id` 参数。需要查看或切换开发者主体时,使用 `hb-sdk remote entity ...`;CLI 不会根据本地绑定自动切换主体。
|
|
439
482
|
|
|
440
|
-
| 命令
|
|
441
|
-
|
|
|
442
|
-
| `hb-sdk remote access`
|
|
443
|
-
| `hb-sdk remote entity list`
|
|
444
|
-
| `hb-sdk remote entity current`
|
|
445
|
-
| `hb-sdk remote entity switch <entity-id>`
|
|
446
|
-
| `hb-sdk remote list [--status <status>] [--keyword <text>]`
|
|
447
|
-
| `hb-sdk remote create [--yes] [--force-bind]`
|
|
448
|
-
| `hb-sdk remote bind <mini-program-id> [--force]`
|
|
449
|
-
| `hb-sdk remote info`
|
|
450
|
-
| `hb-sdk remote allowlist list`
|
|
451
|
-
| `hb-sdk remote allowlist add <heybox-id...>`
|
|
452
|
-
| `hb-sdk remote allowlist remove <heybox-id...>`
|
|
453
|
-
| `hb-sdk remote allowlist set <heybox-id...>`
|
|
483
|
+
| 命令 | 说明 |
|
|
484
|
+
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
485
|
+
| `hb-sdk remote access` | 查询当前 CLI 用户是否具备管理工坊小程序的资格。 |
|
|
486
|
+
| `hb-sdk remote entity list` | 列出可切换开发者主体,并标记服务端 current entity。 |
|
|
487
|
+
| `hb-sdk remote entity current` | 查看服务端 current entity 和该主体的小程序工坊权限状态。 |
|
|
488
|
+
| `hb-sdk remote entity switch <entity-id>` | 切换服务端 current entity;只允许切到 `entity list` 返回的主体。 |
|
|
489
|
+
| `hb-sdk remote list [--status <status>] [--keyword <text>]` | 列出 current entity 下当前 CLI 用户可管理的小程序,并标出当前绑定项。 |
|
|
490
|
+
| `hb-sdk remote create [--yes] [--force-bind]` | 在 current entity 下创建远端小程序并绑定当前项目;多主体非 TTY 环境必须传 `--yes` 确认使用当前主体;已有绑定时必须显式传 `--force-bind` 才能覆盖。 |
|
|
491
|
+
| `hb-sdk remote bind <mini-program-id> [--force]` | 先校验 current entity 可管理目标小程序,再写入当前项目绑定;`--force` 只允许覆盖本地绑定,不跳过远端校验或主体一致性校验。 |
|
|
492
|
+
| `hb-sdk remote info` | 查看当前绑定小程序的远端详情。 |
|
|
493
|
+
| `hb-sdk remote allowlist list` | 查看预览白名单。 |
|
|
494
|
+
| `hb-sdk remote allowlist add <heybox-id...>` | 添加十进制 Heybox ID 到预览白名单。 |
|
|
495
|
+
| `hb-sdk remote allowlist remove <heybox-id...>` | 从预览白名单移除非 owner 条目。 |
|
|
496
|
+
| `hb-sdk remote allowlist set <heybox-id...>` | 替换非 owner 白名单条目,并保留平台返回的 owner 语义。 |
|
|
454
497
|
| `hb-sdk remote deploy --release-note <text> [--skip-build \| --from-version <version>] [--auto-publish]` | 构建、上传或复用历史产物并提交当前版本审核。 |
|
|
455
|
-
| `hb-sdk remote versions`
|
|
456
|
-
| `hb-sdk remote preview <version>`
|
|
457
|
-
| `hb-sdk remote release <version> [--yes]`
|
|
458
|
-
| `hb-sdk remote withdraw <version> [--yes] [--reason <text>]`
|
|
459
|
-
| `hb-sdk remote take-down [--yes]`
|
|
460
|
-
| `hb-sdk remote reopen [--yes]`
|
|
461
|
-
| `hb-sdk remote square hide [--yes]`
|
|
462
|
-
| `hb-sdk remote square show`
|
|
498
|
+
| `hb-sdk remote versions` | 列出当前绑定小程序的远端版本。 |
|
|
499
|
+
| `hb-sdk remote preview <version>` | 查看指定版本的远端预览入口。 |
|
|
500
|
+
| `hb-sdk remote release <version> [--yes]` | 发布审核通过的版本;交互式终端会确认,非 TTY 必须传 `--yes`。 |
|
|
501
|
+
| `hb-sdk remote withdraw <version> [--yes] [--reason <text>]` | 撤回审核中或已通过但未发布的版本;交互式终端会确认,非 TTY 必须传 `--yes`。 |
|
|
502
|
+
| `hb-sdk remote take-down [--yes]` | 下架当前线上小程序;交互式终端会确认,非 TTY 必须传 `--yes`。 |
|
|
503
|
+
| `hb-sdk remote reopen [--yes]` | 重新上架已下架的小程序;交互式终端会确认,非 TTY 必须传 `--yes`。 |
|
|
504
|
+
| `hb-sdk remote square hide [--yes]` | 隐藏当前绑定小程序在普通用户侧的小程序工坊广场展示;白名单用户仍可见,直接链接不受影响;交互式终端会确认,非 TTY 必须传 `--yes`。 |
|
|
505
|
+
| `hb-sdk remote square show` | 恢复当前绑定小程序在普通用户侧的小程序工坊广场展示。 |
|
|
463
506
|
|
|
464
507
|
CLI 登录态只供 CLI 命令访问黑盒接口时复用,不会注入 iframe SDK,也不会改变 `auth.login()`、`user.getInfo()`、`network.request()` 或 mock 宿主中的用户状态。`hb-sdk login` 成功后会尝试读取开发者主体列表:单主体自动确认或切换为 current entity,多主体交互式环境要求选择主体,多主体非 TTY 环境只提示后续运行 `hb-sdk remote entity switch <entity-id>`;显式传 `--no-select-entity` 时只写登录态,不修改服务端 current entity。`hb-sdk login status` 默认展示脱敏状态、`heyboxId`、`loginBaseUrl`、登录时间和本地 `selectedEntity` 提示快照;`--verbose` 额外展示 cache 路径。不输出 `pkey`、cookie 或完整请求头。`selectedEntity` 不是权限事实源,每次 remote 命令仍以服务端 current entity 为准。
|
|
465
508
|
|
|
@@ -473,7 +516,8 @@ CLI 登录态只供 CLI 命令访问黑盒接口时复用,不会注入 iframe
|
|
|
473
516
|
|
|
474
517
|
## 能力边界
|
|
475
518
|
|
|
476
|
-
-
|
|
519
|
+
- SDK 实例创建后会自动开始握手;默认单例仍按需懒创建,`ready()`、`on()` 或任意模块能力调用都会创建默认单例并开始握手。
|
|
520
|
+
- `ready()` 只等待已有握手结果,不主动触发新的握手;调用模块能力前会自动等待 `ready()`,但业务仍建议在页面启动阶段显式 `await ready()`,便于集中处理握手失败。
|
|
477
521
|
- `user.getInfo()`、`user.getCurrentUserDetail()`、`user.getCurrentUserProfile()`、`user.getPlatformAccountOverview()`、`user.getPlatformAccountInfo(platform)` 和 `user.getSteamGameList(options)` 不会触发登录;登录必须由业务在用户操作后调用 `auth.login()`。
|
|
478
522
|
- 当前用户详情和平台账号 API 只允许读取当前登录用户,不支持传入 `userid` 查询其他人,也不透传 `/account/home_v2/` 原始响应。
|
|
479
523
|
- 分享、截图、UI、设备、导航、storage 和网络请求只开放稳定窄接口,不透传黑盒客户端内部协议参数。
|
|
@@ -517,12 +561,12 @@ export default defineConfig({
|
|
|
517
561
|
|
|
518
562
|
## 导出
|
|
519
563
|
|
|
520
|
-
默认导出 `hbSDK`,包含 `ready`、`on`、`off`、`auth`、`user`、`share`、`viewport`、`storage`、`network`、`ui`、`device`、`navigation`。
|
|
564
|
+
默认导出 `hbSDK`,包含 `ready`、`on`、`off`、`auth`、`user`、`share`、`viewport`、`storage`、`cloud`、`network`、`ui`、`device`、`navigation`。
|
|
521
565
|
|
|
522
566
|
常用命名导出:
|
|
523
567
|
|
|
524
568
|
- `ready`、`on`、`off`
|
|
525
|
-
- `auth`、`user`、`share`、`viewport`、`storage`、`network`、`ui`、`device`、`navigation`
|
|
569
|
+
- `auth`、`user`、`share`、`viewport`、`storage`、`cloud`、`network`、`ui`、`device`、`navigation`
|
|
526
570
|
- `createMiniProgramSDK`、`MiniProgramSDK`
|
|
527
571
|
- `HbMiniProgramSDKError`、`HbMiniProgramNetworkError`
|
|
528
572
|
- 各模块公开类型,例如 `MiniProgramNetworkRequestConfig`、`MiniProgramNetworkResponse`、`MiniProgramUserInfoResult`
|
|
@@ -537,9 +581,9 @@ export default defineConfig({
|
|
|
537
581
|
pnpm --filter @heybox/hb-sdk run test:unit
|
|
538
582
|
pnpm --filter @heybox/hb-sdk run build:package
|
|
539
583
|
pnpm --filter @heybox/hb-sdk run check:boundary
|
|
540
|
-
pnpm
|
|
584
|
+
pnpm exec hbexec hb-sdk check
|
|
541
585
|
```
|
|
542
586
|
|
|
543
587
|
`check:boundary` 用于保护 SDK、CLI、mock host 与 runtime 之间的依赖边界。调整 CLI、mock 或协议导出时应一起运行。
|
|
544
588
|
|
|
545
|
-
`
|
|
589
|
+
`hbexec hb-sdk check` 只读校验 docs、skill references,并在临时目录生成与校验 `agent-skills` payload;不要求 canonical artifact 已存在,也不包含 changelog。维护清单见 `packages/hb-sdk/DOC_SYNC_CHECKLIST.md`。
|
|
@@ -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-
|
|
8
|
+
var index = require('./index-DeamIV1-.cjs');
|
|
9
9
|
require('node:module');
|
|
10
10
|
require('os');
|
|
11
11
|
require('readline');
|
|
@@ -9,7 +9,7 @@ var node_url = require('node:url');
|
|
|
9
9
|
var net = require('node:net');
|
|
10
10
|
var node_http = require('node:http');
|
|
11
11
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
12
|
-
var index = require('./index-
|
|
12
|
+
var index = require('./index-DeamIV1-.cjs');
|
|
13
13
|
require('node:process');
|
|
14
14
|
require('node:buffer');
|
|
15
15
|
require('node:util');
|
|
@@ -4,7 +4,7 @@ var fs$1 = require('node:fs');
|
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var os = require('node:os');
|
|
6
6
|
var path = require('node:path');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-DeamIV1-.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('path');
|
|
10
10
|
require('os');
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$2 = require('./index-
|
|
3
|
+
var index$2 = require('./index-DeamIV1-.cjs');
|
|
4
4
|
var require$$0$2 = require('fs');
|
|
5
5
|
var require$$2$1 = require('crypto');
|
|
6
6
|
var require$$1$2 = require('path');
|
|
7
7
|
var require$$0$3 = require('assert');
|
|
8
8
|
var require$$4$2 = require('events');
|
|
9
9
|
var require$$1$1 = require('util');
|
|
10
|
-
var remote = require('./remote-
|
|
10
|
+
var remote = require('./remote-gXUjRvGB.cjs');
|
|
11
11
|
var require$$0$5 = require('net');
|
|
12
12
|
var require$$0$4 = require('url');
|
|
13
13
|
var require$$2$2 = require('http');
|
|
@@ -234,19 +234,19 @@ function requireArgument () {
|
|
|
234
234
|
|
|
235
235
|
var command = {};
|
|
236
236
|
|
|
237
|
-
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-
|
|
237
|
+
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-DeamIV1-.cjs', document.baseURI).href)));
|
|
238
238
|
function __require$4() { return require$5("node:events"); }
|
|
239
239
|
|
|
240
|
-
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-
|
|
240
|
+
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-DeamIV1-.cjs', document.baseURI).href)));
|
|
241
241
|
function __require$3() { return require$4("node:child_process"); }
|
|
242
242
|
|
|
243
|
-
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-
|
|
243
|
+
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-DeamIV1-.cjs', document.baseURI).href)));
|
|
244
244
|
function __require$2() { return require$3("node:path"); }
|
|
245
245
|
|
|
246
|
-
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-
|
|
246
|
+
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-DeamIV1-.cjs', document.baseURI).href)));
|
|
247
247
|
function __require$1() { return require$2("node:fs"); }
|
|
248
248
|
|
|
249
|
-
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-
|
|
249
|
+
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-DeamIV1-.cjs', document.baseURI).href)));
|
|
250
250
|
function __require() { return require$1("node:process"); }
|
|
251
251
|
|
|
252
252
|
var help = {};
|
|
@@ -13094,7 +13094,7 @@ function readErrorMessage(error, options = {}) {
|
|
|
13094
13094
|
}
|
|
13095
13095
|
|
|
13096
13096
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
13097
|
-
const BUILT_CLI_VERSION = '0.5.
|
|
13097
|
+
const BUILT_CLI_VERSION = '0.5.12';
|
|
13098
13098
|
const PACKAGE_JSON_CANDIDATES = [
|
|
13099
13099
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
13100
13100
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -13259,6 +13259,43 @@ function installRemoteCommands(program, handlers, resolveLogger) {
|
|
|
13259
13259
|
addRemotePublicOptions(allowlist.command('set').description('替换预览白名单 Heybox ID').argument('<heybox-id...>', 'Heybox ID')).action(createRemoteAction(handlers, resolveLogger, 'allowlist:set', (_command, heyboxIds) => ({
|
|
13260
13260
|
heyboxIds: readStringArrayArgument(heyboxIds, 'heybox-id'),
|
|
13261
13261
|
})));
|
|
13262
|
+
const cloud = addRemotePublicOptions(remote.command('cloud').description('管理当前绑定小程序的云端能力'));
|
|
13263
|
+
const leaderboard = addRemotePublicOptions(cloud.command('leaderboard').description('管理当前绑定小程序的云端排行榜'));
|
|
13264
|
+
addRemotePublicOptions(leaderboard
|
|
13265
|
+
.command('create')
|
|
13266
|
+
.description('创建云端排行榜')
|
|
13267
|
+
.argument('[key]', '排行榜 key;不传时创建 default')
|
|
13268
|
+
.requiredOption('--order <order>', '排序方向:asc 或 desc')
|
|
13269
|
+
.option('--rank-limit <count>', '榜单展示记录上限;0 表示不限制', parseNonNegativeInteger)).action(createRemoteAction(handlers, resolveLogger, 'cloud:leaderboard:create', (command, key) => {
|
|
13270
|
+
const options = readCommandOptionsWithAncestors(command);
|
|
13271
|
+
return {
|
|
13272
|
+
key: typeof key === 'string' ? key : undefined,
|
|
13273
|
+
order: readStringOption(options.order),
|
|
13274
|
+
rankLimit: typeof options.rankLimit === 'number' ? options.rankLimit : undefined,
|
|
13275
|
+
};
|
|
13276
|
+
}));
|
|
13277
|
+
addRemotePublicOptions(leaderboard.command('get').description('查看云端排行榜配置').argument('<key>', '排行榜 key')).action(createRemoteAction(handlers, resolveLogger, 'cloud:leaderboard:get', (_command, key) => ({
|
|
13278
|
+
key: readStringArgument(key, 'key'),
|
|
13279
|
+
})));
|
|
13280
|
+
addRemotePublicOptions(leaderboard
|
|
13281
|
+
.command('list')
|
|
13282
|
+
.description('列出当前绑定小程序的云端排行榜')
|
|
13283
|
+
.option('--created-at-start <timestamp>', '创建时间区间开始秒级时间戳', parseNonNegativeInteger)
|
|
13284
|
+
.option('--created-at-end <timestamp>', '创建时间区间结束秒级时间戳', parseNonNegativeInteger)).action(createRemoteAction(handlers, resolveLogger, 'cloud:leaderboard:list', (command) => {
|
|
13285
|
+
const options = readCommandOptionsWithAncestors(command);
|
|
13286
|
+
return {
|
|
13287
|
+
createdAtStart: typeof options.createdAtStart === 'number' ? options.createdAtStart : undefined,
|
|
13288
|
+
createdAtEnd: typeof options.createdAtEnd === 'number' ? options.createdAtEnd : undefined,
|
|
13289
|
+
};
|
|
13290
|
+
}));
|
|
13291
|
+
addRemotePublicOptions(leaderboard
|
|
13292
|
+
.command('delete')
|
|
13293
|
+
.description('硬删除云端排行榜及其全部记录')
|
|
13294
|
+
.argument('<key>', '排行榜 key')
|
|
13295
|
+
.requiredOption('--confirm <key>', '必须与排行榜 key 完全一致')).action(createRemoteAction(handlers, resolveLogger, 'cloud:leaderboard:delete', (command, key) => ({
|
|
13296
|
+
key: readStringArgument(key, 'key'),
|
|
13297
|
+
confirm: readStringOption(readCommandOptionsWithAncestors(command).confirm),
|
|
13298
|
+
})));
|
|
13262
13299
|
addRemotePublicOptions(remote
|
|
13263
13300
|
.command('deploy')
|
|
13264
13301
|
.description('构建并提交当前小程序版本审核')
|
|
@@ -13374,31 +13411,31 @@ function createCommandLoggerResolver(options) {
|
|
|
13374
13411
|
};
|
|
13375
13412
|
}
|
|
13376
13413
|
const defaultClearLoginStatus = async (...args) => {
|
|
13377
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13414
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DMNap0-y.cjs'); });
|
|
13378
13415
|
return clearLoginStatus(...args);
|
|
13379
13416
|
};
|
|
13380
13417
|
const defaultLoginToHeybox = async (...args) => {
|
|
13381
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
13418
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DMNap0-y.cjs'); });
|
|
13382
13419
|
return loginToHeybox(...args);
|
|
13383
13420
|
};
|
|
13384
13421
|
const defaultPrintLoginStatus = async (...args) => {
|
|
13385
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13422
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DMNap0-y.cjs'); });
|
|
13386
13423
|
return printLoginStatus(...args);
|
|
13387
13424
|
};
|
|
13388
13425
|
const defaultRunCreateCommand = async (...args) => {
|
|
13389
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
13426
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-Ba353lSg.cjs'); });
|
|
13390
13427
|
return runCreateCommand(...args);
|
|
13391
13428
|
};
|
|
13392
13429
|
const defaultRunDevCommand = async (...args) => {
|
|
13393
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
13430
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-BhPFNef-.cjs'); });
|
|
13394
13431
|
return runDevCommand(...args);
|
|
13395
13432
|
};
|
|
13396
13433
|
const defaultRunDoctorCommand = async (...args) => {
|
|
13397
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
13434
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-CP4kwgAn.cjs'); });
|
|
13398
13435
|
return runDoctorCommand(...args);
|
|
13399
13436
|
};
|
|
13400
13437
|
const defaultRunRemoteCommand = async (...args) => {
|
|
13401
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
13438
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-gXUjRvGB.cjs'); }).then(function (n) { return n.remote; });
|
|
13402
13439
|
return runRemoteCommand(...args);
|
|
13403
13440
|
};
|
|
13404
13441
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -13463,6 +13500,13 @@ function parsePositivePort(value) {
|
|
|
13463
13500
|
}
|
|
13464
13501
|
return parsed;
|
|
13465
13502
|
}
|
|
13503
|
+
function parseNonNegativeInteger(value) {
|
|
13504
|
+
const parsed = Number(value);
|
|
13505
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
13506
|
+
throw new InvalidArgumentError('必须是非负整数');
|
|
13507
|
+
}
|
|
13508
|
+
return parsed;
|
|
13509
|
+
}
|
|
13466
13510
|
|
|
13467
13511
|
exports.CliError = CliError;
|
|
13468
13512
|
exports.HB_SDK_PACKAGE_NAME = HB_SDK_PACKAGE_NAME;
|
|
@@ -3,9 +3,9 @@
|
|
|
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 session = require('./session-
|
|
6
|
+
var session = require('./session-D5Vf-fNZ.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-DeamIV1-.cjs');
|
|
9
9
|
require('node:path');
|
|
10
10
|
require('fs');
|
|
11
11
|
require('constants');
|