@heybox/hb-sdk 0.9.1-alpha.4 → 0.9.1-alpha.6

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 (112) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/README.md +33 -0
  3. package/dist/card-controller.cjs.js +194 -0
  4. package/dist/card-controller.esm.js +159 -0
  5. package/dist/cli-chunks/browser-DUdEZCyq.cjs +15 -0
  6. package/dist/cli-chunks/{build-BZg2rHkW.cjs → build-DYYWRiaY.cjs} +22 -10
  7. package/dist/cli-chunks/{context-YrzmEOau.cjs → context-Bo4L-Cx_.cjs} +12 -12
  8. package/dist/cli-chunks/{create-fPvlqLbS.cjs → create-CKC4yp0J.cjs} +12 -5
  9. package/dist/cli-chunks/{dev-X8_kbp78.cjs → dev-BMX6UXUe.cjs} +58 -13
  10. package/dist/cli-chunks/{doctor-DdiucYs9.cjs → doctor-DqEYRo4I.cjs} +13 -6
  11. package/dist/cli-chunks/{index-BdbwsefW.cjs → index-DmCWB_hF.cjs} +4 -7
  12. package/dist/cli-chunks/{index-BGh-Izf8.cjs → index-J4uQvKT_.cjs} +8780 -4464
  13. package/dist/cli-chunks/{index.esm-WYIrPjkF.cjs → index.esm-eNPTDv6W.cjs} +18 -19
  14. package/dist/cli-chunks/{login-DWmNuhWc.cjs → login-BL2OE6r9.cjs} +32 -33
  15. package/dist/cli-chunks/{project-vite-BVDIeoHB.cjs → project-vite-Du1m7Y_3.cjs} +1 -1
  16. package/dist/cli-chunks/{remote-BHJFxXyc.cjs → remote-ZHJUtx6l.cjs} +49 -38
  17. package/dist/cli-chunks/runtime-gate-DedD3ynE.cjs +201950 -0
  18. package/dist/cli-chunks/{runtime-permission-env-eiq8vE62.cjs → runtime-permission-env-DWaPlchd.cjs} +9396 -2929
  19. package/dist/cli-chunks/{skill-DC3cfPj2.cjs → skill-D4z_a_BH.cjs} +14 -7
  20. package/dist/cli-chunks/{version-DYFkOykv.cjs → version-tzrFwpkl.cjs} +1 -1
  21. package/dist/cli.cjs +14 -6
  22. package/dist/devtools/browser-dev-host/assets/browser-dev-host-BL1URvGR.js +102 -0
  23. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CZsodKbP.js → desktop-app-launch-D6QZYpUq.js} +3 -3
  24. package/dist/devtools/browser-dev-host/assets/{index-B9tOX3zG.js → index-Bqsp608m.js} +4 -4
  25. package/dist/devtools/browser-dev-host/index.html +2 -2
  26. package/dist/index.cjs.js +6224 -275
  27. package/dist/index.esm.js +6224 -276
  28. package/dist/miniapp-publish.cjs.js +6612 -168
  29. package/dist/miniapp-publish.esm.js +6612 -169
  30. package/dist/protocol.cjs.js +5805 -0
  31. package/dist/protocol.esm.js +5805 -0
  32. package/dist/vite.cjs.js +7475 -217
  33. package/dist/vite.esm.js +7474 -218
  34. package/dist/workspace-card-build-sandbox-worker.mjs +72 -0
  35. package/package.json +25 -11
  36. package/skill/SKILL.md +15 -0
  37. package/skill/skill.json +5 -5
  38. package/types/card-controller.d.ts +3682 -0
  39. package/types/index.d.ts +7532 -35
  40. package/types/miniapp-publish/index.d.ts +542 -64
  41. package/types/protocol.d.ts +2083 -9
  42. package/types/vite/index.d.ts +25 -12
  43. package/dist/cli-chunks/browser-RAy8e8cV.cjs +0 -635
  44. package/dist/cli-chunks/runtime-gate-CR0dRMpQ.cjs +0 -65
  45. package/dist/cli-chunks/session-Dz1cGg0E.cjs +0 -3403
  46. package/dist/devtools/browser-dev-host/assets/browser-dev-host-CO2_03W0.js +0 -102
  47. package/types/core/client.d.ts +0 -108
  48. package/types/core/csp-violation.d.ts +0 -5
  49. package/types/core/errors.d.ts +0 -78
  50. package/types/core/event-bus.d.ts +0 -11
  51. package/types/core/handshake-state.d.ts +0 -54
  52. package/types/core/history-observer.d.ts +0 -4
  53. package/types/core/mini-dev-console.d.ts +0 -36
  54. package/types/core/network-sanitize.d.ts +0 -31
  55. package/types/core/sdk.d.ts +0 -104
  56. package/types/core/singleton.d.ts +0 -372
  57. package/types/core/utils.d.ts +0 -10
  58. package/types/core/version.d.ts +0 -2
  59. package/types/devtools/device-logs.d.ts +0 -48
  60. package/types/miniapp-manifest/basic-info-browser.d.ts +0 -37
  61. package/types/miniapp-manifest/basic-info-image-header.d.ts +0 -6
  62. package/types/miniapp-manifest/basic-info-node.d.ts +0 -17
  63. package/types/miniapp-manifest/basic-info-placeholder.d.ts +0 -1
  64. package/types/miniapp-manifest/basic-info.d.ts +0 -33
  65. package/types/miniapp-manifest/bindings.d.ts +0 -70
  66. package/types/miniapp-manifest/category.d.ts +0 -11
  67. package/types/miniapp-manifest/companion-directory.d.ts +0 -2
  68. package/types/miniapp-manifest/companion-executable.d.ts +0 -4
  69. package/types/miniapp-manifest/companion-types.d.ts +0 -63
  70. package/types/miniapp-manifest/companions.d.ts +0 -17
  71. package/types/miniapp-manifest/index.d.ts +0 -7
  72. package/types/miniapp-manifest/node.d.ts +0 -22
  73. package/types/miniapp-manifest/permissions.d.ts +0 -48
  74. package/types/miniapp-manifest/runtime-gate.d.ts +0 -12
  75. package/types/miniapp-manifest/schema.d.ts +0 -302
  76. package/types/modules/auth/index.d.ts +0 -204
  77. package/types/modules/cloud/index.d.ts +0 -669
  78. package/types/modules/companion/index.d.ts +0 -1619
  79. package/types/modules/device/index.d.ts +0 -269
  80. package/types/modules/environment/index.d.ts +0 -238
  81. package/types/modules/files/index.d.ts +0 -5
  82. package/types/modules/files/registry.d.ts +0 -35
  83. package/types/modules/files/types.d.ts +0 -1548
  84. package/types/modules/navigation/app-pages/index.d.ts +0 -4
  85. package/types/modules/navigation/app-pages/types.d.ts +0 -135
  86. package/types/modules/navigation/index.d.ts +0 -312
  87. package/types/modules/network/index.d.ts +0 -457
  88. package/types/modules/network/observability.d.ts +0 -38
  89. package/types/modules/network/request-shape.d.ts +0 -44
  90. package/types/modules/share/copy-link.d.ts +0 -46
  91. package/types/modules/share/extra.d.ts +0 -5
  92. package/types/modules/share/index.d.ts +0 -294
  93. package/types/modules/share/screenshot.d.ts +0 -34
  94. package/types/modules/share/show-share-menu.d.ts +0 -29
  95. package/types/modules/share/types.d.ts +0 -201
  96. package/types/modules/storage/index.d.ts +0 -214
  97. package/types/modules/ui/index.d.ts +0 -315
  98. package/types/modules/user/get-info.d.ts +0 -44
  99. package/types/modules/user/index.d.ts +0 -245
  100. package/types/modules/user/revoke-authorization.d.ts +0 -31
  101. package/types/modules/user/steam-game-list.d.ts +0 -153
  102. package/types/modules/user/types.d.ts +0 -2
  103. package/types/modules/viewport/index.d.ts +0 -319
  104. package/types/protocol/capabilities.d.ts +0 -2
  105. package/types/protocol/constants.d.ts +0 -1
  106. package/types/protocol/dev-session.d.ts +0 -74
  107. package/types/protocol/guards.d.ts +0 -1
  108. package/types/protocol/runtime-permissions.d.ts +0 -2
  109. package/types/protocol/types.d.ts +0 -22
  110. package/types/skill-metadata.d.ts +0 -18
  111. package/types/vite/html-policy.d.ts +0 -6
  112. package/types/vite/runtime-permission-env.d.ts +0 -9
@@ -1,245 +0,0 @@
1
- import type { MiniProgramRequester } from '../../core/client';
2
- import { USER_GET_INFO_METHOD, type GetUserInfoResult } from './get-info';
3
- import { USER_REVOKE_AUTHORIZATION_METHOD, type RevokeAuthorizationResult } from './revoke-authorization';
4
- import { USER_GET_STEAM_GAME_LIST_METHOD, type GetSteamGameListOptions, type GetSteamGameListResult } from './steam-game-list';
5
- export * from './get-info';
6
- export * from './revoke-authorization';
7
- export * from './steam-game-list';
8
- export * from './types';
9
- /** 外部小程序可调用的用户模块。 */
10
- export interface MiniProgramUserModule {
11
- /**
12
- * 获取当前黑盒 APP 登录态、授权状态和已获准披露的资料。
13
- *
14
- * @returns 以 `isHeyboxAppLoggedIn` 为判别字段的联合结果:
15
- *
16
- * - `false`:当前未登录,`authorization` 和 `userInfo` 固定为 `null`。
17
- * - `true`:`authorization` 固定包含 `identity`、`profile` 两项状态;兼容 Host 的
18
- * `userInfo` 仍可能为 `null`,非空时包含隔离 `app_user_id` 与可空 `profile`。
19
- * 支持 Steam 账号能力的 Host 还可能返回 `authorization.steam_account` 与
20
- * `userInfo.steam_id`;授权与绑定状态应分别判断。
21
- *
22
- * @throws {@link HbMiniProgramSDKError} `PERMISSION_NOT_DECLARED` / `PERMISSION_DENIED` 表示
23
- * `userInfo` Manifest 权限不可用;`INVALID_STATE` 表示缺少 canonical 小程序身份;
24
- * `REQUEST_FAILED` / `REQUEST_UNSUPPORTED` / `INVALID_RESPONSE` 表示 Host 或资料读取失败;
25
- * `HEYBOX_APP_LOGIN_REQUIRED` 表示初次登录态检查后,Host 会话在隔离身份读取期间失效;
26
- * `AUTHORIZATION_CONTEXT_CHANGED` 表示请求期间发生账号切换或授权撤销;
27
- * `RUNTIME_DESTROYED` 表示 Runtime 已终止。握手失败也会以该错误类型拒绝调用。
28
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
29
- * Runtime 熔断窗口;`error.data.status` 为上游状态码,`error.data.retryAfterMs`(可能缺失)给出
30
- * 建议退避时长。
31
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
32
- * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
33
- * 两种情况调用方都应停止立即重试,避免把用户 IP 打成被封。
34
- *
35
- * @remarks
36
- * 该读取不展示授权 UI,也不要求可信用户手势。Manifest 中必须声明 `userInfo`,但不需要
37
- * 公开 `network` 权限;Manifest 权限与 `authorization.identity/profile` 表示的用户授权是
38
- * 两层独立门禁。开启网络权限后仍可调用本方法。
39
- *
40
- * 当前账号未登录是正常返回分支,不是 `HEYBOX_APP_LOGIN_REQUIRED` 错误。已登录时 Runtime
41
- * 会静默建立或读取本小程序隔离身份,并授予 `identity` 与 `profile`。`app_user_id` 只在
42
- * 当前小程序与当前授权有效期内作为稳定、不透明的关联键;它不是黑盒用户 ID、授权码或
43
- * 登录凭据。`profile.nickname` / `avatar` 只用于展示,可能为空字符串,不应用于鉴权。
44
- * Steam 账号能力启用时,该读取还会静默授予 `steam_account`;只有当前账号存在主绑定
45
- * 时才返回 string 类型的 `steam_id`。该字段缺失不能单独证明用户拒绝了授权。
46
- *
47
- * 该方法不返回 code、token 或 cookie,也不会创建开发者服务端会话。需要服务端身份时,
48
- * 在可信用户操作中调用 [auth.login](/reference/sdk/auth/login) 获取一次性 code;需要停止
49
- * 使用现有身份时,调用 [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
50
- * 并同步清理业务缓存与服务端会话。
51
- *
52
- * @example
53
- * ```ts
54
- * import hbSDK from '@heybox/hb-sdk'
55
- *
56
- * const result = await hbSDK.user.getInfo()
57
- * if (!result.isHeyboxAppLoggedIn) {
58
- * showHeyboxLoginHint()
59
- * } else if (!result.userInfo) {
60
- * showUserInfoUnavailable()
61
- * } else {
62
- * const { app_user_id, profile } = result.userInfo
63
- * bindLocalIdentity(app_user_id)
64
- * if (result.authorization.profile === 'granted' && profile) {
65
- * renderProfile(profile.nickname, profile.avatar)
66
- * }
67
- * }
68
- * ```
69
- *
70
- * @see [auth.login](/reference/sdk/auth/login)
71
- * @see [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
72
- * @see [用户身份与登录](/guide/auth)
73
- * @see [权限声明](/guide/permissions)
74
- *
75
- * @since 0.2.0-alpha.0
76
- * @hbPlatform android
77
- * @hbPlatform ios
78
- * @hbPlatform ohos
79
- * @hbPlatform windows
80
- * @hbPlatform macos
81
- * @hbClient android none
82
- * @hbClient ios none
83
- * @hbClient ohos none
84
- * @hbClient windows none
85
- * @hbClient macos none
86
- */
87
- getInfo(): Promise<GetUserInfoResult>;
88
- /**
89
- * 撤销当前用户授予本小程序的授权;必须由可信用户操作触发。
90
- *
91
- * @returns Host 确认撤销后 resolve `undefined`;不会返回被撤销的身份、scope 或清理结果。
92
- * @throws {@link HbMiniProgramSDKError} `USER_GESTURE_REQUIRED` 表示调用不在按钮点击、确认
93
- * 等可信用户操作中;校验发生在网络 I/O 之前。
94
- * @throws {@link HbMiniProgramSDKError} `HEYBOX_APP_LOGIN_REQUIRED` 表示当前 Host 没有已登录的
95
- * 小黑盒账号;该方法不会主动拉起登录流程。
96
- * @throws {@link HbMiniProgramSDKError} `INVALID_STATE` 表示缺少 canonical 小程序身份;
97
- * `METHOD_FORBIDDEN` 表示当前 Host 缺少该能力依赖;通过底层协议传入任何 payload 时返回
98
- * `INVALID_PARAMS`。
99
- * @throws {@link HbMiniProgramSDKError} `REQUEST_UNSUPPORTED` / `REQUEST_FAILED` /
100
- * `INVALID_RESPONSE` 表示 Host 请求能力、撤销请求或响应失败;`AUTHORIZATION_CONTEXT_CHANGED`
101
- * 表示请求期间切换了账号或授权上下文已变化。
102
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
103
- * Runtime 熔断窗口;`error.data.retryAfterMs`(可能缺失)给出建议退避时长。
104
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
105
- * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
106
- * 两种情况调用方都应停止立即重试。
107
- * @throws {@link HbMiniProgramSDKError} `RUNTIME_DESTROYED` / `SDK_DESTROYED` 表示 Runtime 或 SDK
108
- * 已终止。SDK 握手失败或超过调用超时时间时,还会返回对应握手错误码或 `REQUEST_TIMEOUT`。
109
- * @remarks
110
- * 该方法没有参数。页面不能传入小程序 ID、黑盒用户 ID 或手势标记;Runtime 从受信 Host
111
- * 启动上下文读取当前小程序和当前用户,并校验真实用户手势。
112
- *
113
- * `user.revokeAuthorization` 位于无需声明白名单,不要求 `userInfo`、`network` 或其他
114
- * `package.json#heybox.permissions` 项,也不会修改 Manifest 声明或平台批准状态。它使用 Host
115
- * 的受信请求撤销当前用户授予当前小程序的用户授权。
116
- *
117
- * 只有服务端确认成功且请求期间账号未变化时,Runtime 才清空缓存的隔离身份和授权 scope,
118
- * 并通过 [on](/reference/sdk/lifecycle/on) 发布 `user_info_authorization_change`,payload 为
119
- * `{ identity: 'denied', profile: 'denied' }`;启用 Steam 账号能力时还包含
120
- * `steam_account: 'denied'`。失败或过期的撤销结果不会发布该成功事件。
121
- *
122
- * 成功后必须立即停止使用旧 `app_user_id` 和资料,并由业务自行清理 localStorage、SDK
123
- * `storage` 中的业务值、cookie、数据库以及开发者服务端 session;SDK 不会代为删除这些
124
- * 数据。随后调用 [auth.login](/reference/sdk/auth/login) 会重新进入授权流程;随后调用
125
- * [user.getInfo](/reference/sdk/user/getInfo) 会按当前规则重新读取或建立隔离身份,不能假定
126
- * 新旧 `app_user_id` 相同。
127
- *
128
- * @example
129
- * ```ts
130
- * import hbSDK from '@heybox/hb-sdk'
131
- *
132
- * async function revokeFromSettingsButton() {
133
- * if (!window.confirm('确定撤销当前小程序的用户授权吗?')) return
134
- *
135
- * await hbSDK.user.revokeAuthorization()
136
- * clearPersistedUserProfile()
137
- * await deleteDeveloperSession()
138
- * }
139
- * ```
140
- *
141
- * @see [user.getInfo](/reference/sdk/user/getInfo)
142
- * @see [auth.login](/reference/sdk/auth/login)
143
- * @see [用户身份与登录](/guide/auth#撤销当前小程序授权)
144
- * @see [权限声明](/guide/permissions#无需声明的-api)
145
- *
146
- * @since 0.7.0-alpha.1
147
- * @hbPlatform android
148
- * @hbPlatform ios
149
- * @hbPlatform ohos
150
- * @hbPlatform windows
151
- * @hbPlatform macos
152
- * @hbClient android none
153
- * @hbClient ios none
154
- * @hbClient ohos none
155
- * @hbClient windows none
156
- * @hbClient macos none
157
- */
158
- revokeAuthorization(): Promise<RevokeAuthorizationResult>;
159
- /**
160
- * 获取当前用户的 Steam 游戏库。
161
- *
162
- * @param options - Steam 账号、分页、排序和过滤条件;不传时使用默认账号、`limit: 20`、
163
- * `offset: 0`、`sort: 'weeks'`、`includeHidden: false`。
164
- * @returns 以 `isLogin`、`isBound` 为判别字段的联合结果:未登录或未绑定 Steam 时
165
- * `data` 为 `null`;两者均为 `true` 时返回游戏列表、`hasMore` 和 `nextOffset`。
166
- * @throws {@link HbMiniProgramSDKError} `INVALID_PARAMS` 表示存在未知字段,或参数类型、范围
167
- * 不合法。
168
- * @throws {@link HbMiniProgramSDKError} `PERMISSION_NOT_DECLARED` / `PERMISSION_DENIED` 表示
169
- * `steamLibrary` 未声明或未启用;`METHOD_FORBIDDEN` 表示当前 Host 缺少该能力依赖。
170
- * @throws {@link HbMiniProgramSDKError} `INVALID_STATE` 表示缺少 canonical 小程序身份;
171
- * `REQUEST_UNSUPPORTED` / `REQUEST_FAILED` / `INVALID_RESPONSE` 表示 Host 请求能力、Steam
172
- * 请求或响应失败;`HEYBOX_APP_LOGIN_REQUIRED` 表示请求期间 Host 登录态失效。
173
- * @throws {@link HbMiniProgramSDKError} `AUTHORIZATION_CONTEXT_CHANGED` 表示请求期间切换账号
174
- * 或撤销授权;`RUNTIME_DESTROYED` / `SDK_DESTROYED` 表示 Runtime 或 SDK 已终止。SDK 握手失败
175
- * 或超过调用超时时间时,还会返回对应的握手错误码或 `REQUEST_TIMEOUT`。
176
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED` 表示上游返回 403/429,或该 endpoint 处于
177
- * Runtime 熔断窗口;`error.data.retryAfterMs`(可能缺失)给出建议退避时长。
178
- * @throws {@link HbMiniProgramSDKError} `RATE_LIMITED_BY_RUNTIME` 表示 Runtime 本地拒绝(每 session
179
- * 配额或同 endpoint 循环检测),请求没有到达上游;`error.data.origin` 为 `'budget'` 或 `'loop'`。
180
- * 两种情况调用方都应停止立即重试。
181
- * @remarks
182
- * 项目必须在 `package.json#heybox.permissions` 声明 `steamLibrary`。该能力通过 Host 的受信
183
- * 请求读取当前账号数据,不要求公开 `network` 权限,也不展示授权 UI 或要求可信用户手势。
184
- * 它不会调用 `auth.login()`,也不会返回授权码、token 或可供开发者服务端使用的 Steam
185
- * scope;公开 OpenAPI 当前也没有 Steam 游戏库资源。开启网络权限后仍可调用本方法。
186
- *
187
- * `steamId` 与 `q` 会 trim;空 `q` 会被省略,非空 `q` 最多保留前 100 个 UTF-16 code
188
- * unit。`limit` 必须为正整数并在大于 100 时收窄为 100。继续分页时把返回的
189
- * `data.nextOffset` 原样传给下一次调用。
190
- *
191
- * Host Runtime 默认将相同查询的成功游戏页缓存 24 小时,游戏新增、游玩时长、隐藏状态和
192
- * 价格可能延迟更新。支持 sandbox 文件操作的宿主可以跨小程序关闭复用;其他宿主仅在当前
193
- * Runtime 内复用。缓存仍检查当前账号和绑定上下文,首次全量读取仍需逐页请求。
194
- * 缓存行为与有效期由 Host Runtime 策略决定,小程序不能通过本方法指定强制刷新。
195
- * 系统或用户清理缓存目录后会重新请求;24 小时是有效期上限,不保证文件保留时长。
196
- *
197
- * 先检查 `isLogin` 和 `isBound`,再读取 `data`。需要单独读取小黑盒登录态和当前小程序
198
- * 隔离身份时使用 [user.getInfo](/reference/sdk/user/getInfo);需要为开发者服务端建立会话时,
199
- * 在可信用户操作中使用 [auth.login](/reference/sdk/auth/login)。这两个 API 都要求
200
- * `userInfo`,不能替代本方法的 `steamLibrary` 权限。
201
- *
202
- * @example
203
- * ```ts
204
- * import hbSDK from '@heybox/hb-sdk'
205
- *
206
- * const result = await hbSDK.user.getSteamGameList({
207
- * limit: 20,
208
- * offset: 0,
209
- * sort: 'weeks',
210
- * q: '合作',
211
- * })
212
- *
213
- * if (!result.isLogin) {
214
- * showHeyboxLoginHint()
215
- * } else if (!result.isBound) {
216
- * showSteamBindingHint()
217
- * } else {
218
- * renderGames(result.data.gameList)
219
- * if (result.data.hasMore) {
220
- * saveNextOffset(result.data.nextOffset)
221
- * }
222
- * }
223
- * ```
224
- *
225
- * @see [user.getInfo](/reference/sdk/user/getInfo)
226
- * @see [auth.login](/reference/sdk/auth/login)
227
- * @see [用户身份与登录](/guide/auth)
228
- * @see [权限声明](/guide/permissions)
229
- *
230
- * @since 0.5.0
231
- * @hbPlatform android
232
- * @hbPlatform ios
233
- * @hbPlatform ohos
234
- * @hbPlatform windows
235
- * @hbPlatform macos
236
- * @hbClient android none
237
- * @hbClient ios none
238
- * @hbClient ohos none
239
- * @hbClient windows none
240
- * @hbClient macos none
241
- */
242
- getSteamGameList(options?: GetSteamGameListOptions): Promise<GetSteamGameListResult>;
243
- }
244
- export declare function createUserModule(requester: MiniProgramRequester): MiniProgramUserModule;
245
- export { USER_GET_INFO_METHOD, USER_GET_STEAM_GAME_LIST_METHOD, USER_REVOKE_AUTHORIZATION_METHOD };
@@ -1,31 +0,0 @@
1
- import type { MiniProgramRequester } from '../../core/client';
2
- export { USER_REVOKE_AUTHORIZATION_METHOD } from '../../protocol/capabilities';
3
- /**
4
- * `user.revokeAuthorization` 不接收入参。
5
- *
6
- * @remarks
7
- * 小程序 ID、当前小黑盒用户和可信手势状态均由 Host 上下文提供,页面不能通过 payload
8
- * 指定或伪造。直接通过 bridge 发送非 `undefined` payload 会返回 `INVALID_PARAMS`。
9
- *
10
- * @see [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
11
- */
12
- export type RevokeAuthorizationPayload = void;
13
- /**
14
- * 撤销成功后不返回用户身份或资料,Promise resolve 值为 `undefined`。
15
- *
16
- * @remarks
17
- * resolve 表示 Host 已确认撤销,并已使当前 Runtime 缓存的用户授权和隔离身份失效;它不表示
18
- * SDK 已清理小程序自己的存储、cookie、数据库或开发者服务端会话。
19
- */
20
- export type RevokeAuthorizationResult = void;
21
- /**
22
- * 撤销当前用户授予本小程序的授权。
23
- *
24
- * @param requester - 底层 bridge 请求能力。
25
- * @returns 撤销完成后 resolve `undefined`。
26
- * @throws {@link HbMiniProgramSDKError} 缺少可信用户手势、当前用户未登录、Host 请求失败、
27
- * 账号上下文变化或 SDK / Runtime 已终止时抛出;具体稳定错误码见公开模块方法文档。
28
- * @remarks 该能力无需 Manifest 权限;撤销成功后由调用方清理自己的持久化数据和服务端会话。
29
- * @see [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
30
- */
31
- export declare function revokeAuthorization(requester: MiniProgramRequester): Promise<RevokeAuthorizationResult>;
@@ -1,153 +0,0 @@
1
- import type { MiniProgramRequester } from '../../core/client';
2
- /**
3
- * Steam 游戏库的服务端排序维度。
4
- *
5
- * @remarks
6
- * - `weeks`:按最近两周游玩时长排序,也是默认值。
7
- * - `all`:按累计游玩时长排序。
8
- * - `achieved`:按已解锁成就数排序。
9
- */
10
- export type SteamGameListSort = 'weeks' | 'all' | 'achieved';
11
- /**
12
- * Steam 游戏库查询与 offset 分页参数。
13
- *
14
- * @remarks
15
- * Runtime 会拒绝未知字段和类型不匹配的值,不会把数字字符串或 `0` / `1` 自动转换为
16
- * `number` / `boolean`。所有默认值和规范化均在 Host 发出 Steam 请求前完成。
17
- */
18
- export interface GetSteamGameListOptions {
19
- /**
20
- * 要查询的 Steam ID;省略时使用当前小黑盒用户的默认绑定账号。
21
- * 首尾空白会被移除,trim 后为空会以 `INVALID_PARAMS` 拒绝。
22
- */
23
- steamId?: string;
24
- /** 单页数量,默认 `20`;必须是大于等于 `1` 的整数,大于 `100` 时按 `100` 查询。 */
25
- limit?: number;
26
- /** 分页偏移量,默认 `0`;必须是大于等于 `0` 的整数,不接受数字字符串。 */
27
- offset?: number;
28
- /** 排序维度,默认 `weeks`;只接受大小写完全一致的 `weeks`、`all` 或 `achieved`。 */
29
- sort?: SteamGameListSort;
30
- /**
31
- * 游戏名称搜索词。Runtime 会先 trim,再保留前 `100` 个 UTF-16 code unit;trim 后为空时
32
- * 不向服务端发送 `q`,等价于不按关键词过滤。
33
- */
34
- q?: string;
35
- /** 是否包含当前用户隐藏的游戏,默认 `false`;只接受 boolean,不接受 `0` / `1`。 */
36
- includeHidden?: boolean;
37
- }
38
- /**
39
- * `user.getSteamGameList` 请求参数;省略时使用默认 Steam 账号和全部默认查询值。
40
- *
41
- * @see [user.getSteamGameList](/reference/sdk/user/getSteamGameList)
42
- */
43
- export type GetSteamGameListPayload = GetSteamGameListOptions | undefined;
44
- /**
45
- * Steam 游戏的可用价格信息。
46
- *
47
- * @remarks
48
- * 整个 `price` 及其中每个字段都可能缺失;服务端返回 `null`、空字符串或不可用数值时,
49
- * Runtime 会省略相应字段。协议不携带币种或最小货币单位,不能把数值字段自行解释为
50
- * “分”或固定币种;直接展示价格时优先使用 `current` / `initial`。
51
- */
52
- export interface SteamGamePrice {
53
- /** 当前售价的非空展示文本;币种与格式由服务端决定。 */
54
- current?: string;
55
- /** 原价的非空展示文本;币种与格式由服务端决定。 */
56
- initial?: string;
57
- /** 服务端原始折扣数值;当前公开合同不承诺比例、百分比或取值范围。 */
58
- discount?: number;
59
- /** 服务端最低价数值;协议不提供币种和缩放单位。 */
60
- lowestPrice?: number;
61
- /** 截止时间的非空展示文本,例如剩余天数;不要把它当作可解析日期。 */
62
- deadlineDate?: string;
63
- /** 服务端原始折扣截止时间数值;当前公开合同不承诺单位或时钟来源。 */
64
- deadlineTimestamp?: number;
65
- }
66
- /**
67
- * 经过 Runtime 规范化的 Steam 游戏库条目。
68
- *
69
- * @remarks
70
- * 原始记录缺少有效 `appid`、`steamAppid`/`appid` 或非空 `name` 时,整条记录会从
71
- * `gameList` 中移除。其余可选字段在服务端缺失、为空或类型无效时会被省略,而不是填充
72
- * `null`。
73
- */
74
- export interface SteamGameListItem {
75
- /** 游戏在小黑盒游戏目录中的有限数值 ID。 */
76
- appid: number;
77
- /** Steam App ID;服务端未提供有效值时回退为 `appid`。 */
78
- steamAppid: number;
79
- /** trim 后的非空游戏名称。 */
80
- name: string;
81
- /** 非空的游戏封面或主图 URL 字符串;Runtime 不保证 URL 协议。 */
82
- image?: string;
83
- /** 非空的 Steam 图标 URL 字符串;优先读取服务端 `appicon`。 */
84
- icon?: string;
85
- /** 当前接口返回的累计游玩时长,单位为秒;`0` 是有效值。该单位只适用于本接口响应。 */
86
- playtimeForever?: number;
87
- /** 当前接口返回的最近两周游玩时长,单位为秒;`0` 是有效值。该单位只适用于本接口响应。 */
88
- playtime2Weeks?: number;
89
- /** trim 后的非空游戏标签;没有有效标签时整个字段省略。 */
90
- tags?: string[];
91
- /** 至少有一个可用字段时返回价格信息;免费游戏或价格不可用时省略。 */
92
- price?: SteamGamePrice;
93
- }
94
- /**
95
- * Steam 游戏库的 offset 分页数据。
96
- *
97
- * @remarks
98
- * `nextOffset` 始终按“本次请求的有效 `offset` + `gameList.length`”计算。服务端返回有效
99
- * `total` 时,`hasMore` 等于 `nextOffset < total`;没有 `total` 时,以本页有效条目数是否
100
- * 达到规范化后的 `limit` 推断。继续加载应直接传回 `nextOffset`,不要自行加请求的原始
101
- * `limit`。
102
- */
103
- export interface SteamGameListData {
104
- /** 当前页通过必填字段校验的游戏条目;没有结果时为空数组。 */
105
- gameList: SteamGameListItem[];
106
- /** 服务端返回的游戏总数;缺失或不是有限数值时省略。 */
107
- total?: number;
108
- /** 按 `total` 或当前页有效条目数推导的下一页标记。 */
109
- hasMore: boolean;
110
- /** 下一页应使用的 offset;始终存在,即使 `hasMore` 为 `false`。 */
111
- nextOffset: number;
112
- /** 服务端对“结果是否属于当前用户本人”的标记;缺失或不可识别时省略。 */
113
- isMe?: boolean;
114
- }
115
- /**
116
- * `user.getSteamGameList` 返回当前用户的 Steam 绑定状态和游戏库。
117
- *
118
- * @remarks
119
- * 这是以 `isLogin` 和 `isBound` 为判别字段的联合类型:
120
- *
121
- * - `{ isLogin: false, isBound: false, data: null }`:当前小黑盒账号未登录;这是正常结果。
122
- * - `{ isLogin: true, isBound: false, data: null }`:已登录,但当前账号没有 Steam 绑定信息。
123
- * - `{ isLogin: true, isBound: true, data }`:已登录且已绑定,`data.gameList` 可以为空数组。
124
- *
125
- * 不存在 `isLogin: false, isBound: true` 分支。必须先缩窄两个判别字段再访问 `data`,不能
126
- * 把前两个状态当作“绑定账号的空游戏库”。
127
- */
128
- export type GetSteamGameListResult = {
129
- isLogin: false;
130
- isBound: false;
131
- data: null;
132
- } | {
133
- isLogin: true;
134
- isBound: false;
135
- data: null;
136
- } | {
137
- isLogin: true;
138
- isBound: true;
139
- data: SteamGameListData;
140
- };
141
- /**
142
- * 获取当前用户 Steam 游戏库。
143
- *
144
- * @param requester - 底层 bridge 请求能力。
145
- * @param options - 查询与分页参数;省略时采用默认 Steam 账号、分页和排序。
146
- * @returns 登录态、Steam 绑定态以及绑定成功时的规范化分页数据。
147
- * @throws {@link HbMiniProgramSDKError} 参数、权限、Host 能力、服务端响应、账号上下文或
148
- * SDK 生命周期不满足要求时抛出;具体稳定错误码见公开模块方法文档。
149
- * @remarks 该能力要求 `steamLibrary`,但不要求公开 `network` 权限或可信用户手势;开启网络权限后仍可调用。
150
- * @see [user.getSteamGameList](/reference/sdk/user/getSteamGameList)
151
- */
152
- export declare function getSteamGameList(requester: MiniProgramRequester, options?: GetSteamGameListOptions): Promise<GetSteamGameListResult>;
153
- export { USER_GET_STEAM_GAME_LIST_METHOD } from '../../protocol/capabilities';
@@ -1,2 +0,0 @@
1
- export { USER_INFO_AUTHORIZATION_SCOPES } from '@heybox/hb-sdk-protocol';
2
- export type { AuthorizedUserInfo, MiniProgramUserInfoResult, UserInfoAuthorization, UserInfoAuthorizationScope, UserInfoAuthorizationStatus, } from '@heybox/hb-sdk-protocol';