@heybox/hb-sdk-protocol 0.9.1-alpha.3 → 0.9.1-alpha.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.
package/src/payloads.ts DELETED
@@ -1,1080 +0,0 @@
1
- /** 当前用户信息与登录能力支持的完整 scope 目录(canonical 顺序)。 */
2
- export const USER_INFO_AUTHORIZATION_SCOPES = ['identity', 'profile', 'steam_account'] as const;
3
-
4
- /** 用户信息授权 scope。 */
5
- export type UserInfoAuthorizationScope = (typeof USER_INFO_AUTHORIZATION_SCOPES)[number];
6
-
7
- /** 登录请求使用与用户信息授权相同的 canonical scope。 */
8
- export type LoginScope = UserInfoAuthorizationScope;
9
- export type LoginPayload = { scopes?: LoginScope[] } | undefined;
10
- export interface LoginResult {
11
- code: string;
12
- expiresIn: number;
13
- scopes: LoginScope[];
14
- }
15
-
16
- /**
17
- * 单个用户信息 scope 对当前小程序的授权状态。
18
- *
19
- * @remarks
20
- * - `not_required`:Host 判定该 scope 无需单独征得用户同意。
21
- * - `not_requested`:当前授权上下文尚未申请或授予该 scope。
22
- * - `granted`:当前小程序可以读取该 scope 对应的资料。
23
- * - `denied`:用户拒绝过该 scope,或该 scope 已被撤销。
24
- *
25
- * 该状态描述用户授权,不代表 `package.json#heybox.permissions` 的声明或平台审批结果。
26
- * 当前 Runtime 成功执行 `user.getInfo()` 时会静默授予 `identity` 与 `profile`,因此两项均为
27
- * `granted`;支持 Steam 账号能力的 Host 还会授予 `steam_account`。其余状态仍保留在公共协议中,
28
- * 供兼容 Host 和授权状态事件使用。
29
- */
30
- export type UserInfoAuthorizationStatus = 'not_required' | 'not_requested' | 'granted' | 'denied';
31
-
32
- /**
33
- * 当前小程序对 canonical 用户信息 scope 的授权状态。
34
- *
35
- * @remarks
36
- * 该对象固定包含 `identity` 与 `profile`,新能力版本还可能包含可选的 `steam_account`。
37
- * `steam_account` 已授权不代表当前一定已绑定 Steam,只有
38
- * {@link AuthorizedUserInfo.steam_id} 存在才表示当前有主绑定。该对象只反映用户授权层;开发者仍需
39
- * 在 Manifest 中声明 `userInfo` / `steamLibrary`,两层门禁不能互相替代。
40
- */
41
- export interface UserInfoAuthorization {
42
- /**
43
- * 隔离身份授权状态;控制 `AuthorizedUserInfo.app_user_id` 是否可向当前小程序披露。
44
- */
45
- identity: UserInfoAuthorizationStatus;
46
- /**
47
- * 公开资料授权状态;控制 `AuthorizedUserInfo.profile` 中昵称和头像是否可披露。
48
- */
49
- profile: UserInfoAuthorizationStatus;
50
- /** Steam 账号授权状态;legacy Runtime/Version 可能缺失该键。 */
51
- steam_account?: UserInfoAuthorizationStatus;
52
- }
53
-
54
- /**
55
- * 已获准向当前小程序披露的用户资料。
56
- *
57
- * @remarks
58
- * 当前黑盒 APP 用户已登录时,Runtime 会隐式授予 `identity` 与 `profile`,静默建立或
59
- * 读取隔离身份,并由 `user.getInfo()` 返回该对象。此过程只要求 Manifest 声明
60
- * `userInfo`,不要求公开 `network` 权限,也不会返回授权码或创建开发者服务端会话。
61
- * 支持 Steam 账号能力的 Host 还会授予 `steam_account`;已授权且有主绑定时才包含 `steam_id`。
62
- *
63
- * 撤销授权后旧身份失效;调用方应停止使用旧值,并清理本地缓存与开发者服务端会话。
64
- * 再次调用 `user.getInfo()` 会按当前账号重新建立隔离身份,不能假定新旧 `app_user_id`
65
- * 相同。
66
- *
67
- * @see [auth.login](/reference/sdk/auth/login) 获取供开发者服务端换票的一次性授权码。
68
- * @see [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization) 撤销当前小程序的用户授权。
69
- */
70
- export interface AuthorizedUserInfo {
71
- /**
72
- * 当前用户在当前小程序与当前授权有效期内稳定的隔离标识;不是黑盒用户 ID 或登录凭据。
73
- *
74
- * @remarks
75
- * 该值在当前授权有效期内可作为“当前用户 × 当前小程序”的稳定关联键;同一用户在不同
76
- * 小程序中的值不同,授权撤销后旧值失效。它不是黑盒用户 ID、登录凭据或主站私有接口凭据。
77
- * 示例:
78
- * `au_1_x7K9mQ2pL4vN8cR3tY6wB1zD5fH`。调用方必须把完整值视为不透明字符串,
79
- * 不应解析格式、依赖固定长度或尝试跨小程序关联用户。
80
- */
81
- app_user_id: string;
82
- /**
83
- * `profile` 获准披露时返回公开资料:`nickname` 是展示昵称,`avatar` 是头像资源字符串;
84
- * 未获准披露时为 `null`。
85
- *
86
- * @remarks
87
- * 当前 Runtime 的静默读取会授予 `profile`;资料读取暂时失败时仍可能返回对象,但
88
- * `nickname` 或 `avatar` 为空字符串。它们只适合展示,不应作为登录态、授权状态、
89
- * 唯一用户标识或鉴权依据。
90
- */
91
- profile: {
92
- /** 当前小黑盒账号的公开展示昵称;空字符串表示本次未取得可展示昵称。 */
93
- nickname: string;
94
- /** 当前小黑盒账号的公开头像资源字符串;空字符串表示本次未取得可展示头像。 */
95
- avatar: string;
96
- } | null;
97
- /**
98
- * `steam_account` 已授权且当前已绑定 Steam 时返回 canonical SteamID64。
99
- *
100
- * @remarks
101
- * 始终表示为 string,禁止作为 JSON number 使用;未绑定时省略该字段,不返回空字符串或
102
- * `null`。只返回主绑定 SteamID64,不包含 Steam 昵称、头像、好友码、公开状态或绑定来源。
103
- */
104
- steam_id?: string;
105
- }
106
-
107
- /**
108
- * 当前黑盒 APP 登录态、授权状态和已获准披露的用户资料。
109
- *
110
- * @remarks
111
- * 以 `isHeyboxAppLoggedIn` 作为判别字段处理返回值:
112
- *
113
- * - `false`:当前 Host 没有已登录的小黑盒账号,`authorization` 与 `userInfo` 固定为 `null`。
114
- * 这是正常业务分支,不会抛出登录错误。
115
- * - `true` 且 `userInfo` 非空:`authorization` 必含 `identity`、`profile`,支持时还包含 `steam_account`;
116
- * `userInfo` 包含当前小程序隔离的 `app_user_id`,而 `profile` 仍需独立判空。
117
- * - `true` 且 `userInfo` 为 `null`:公共协议为兼容 Host 保留的“已登录但资料未披露/不可用”分支。
118
- * 当前 Runtime 成功读取隔离身份时返回非空对象,但调用方仍应按类型处理该分支。
119
- *
120
- * `user.getInfo()` 不返回 `code`、token、cookie 或黑盒用户 ID。需要建立开发者服务端会话时,
121
- * 应在可信用户操作中调用 `auth.login()`,再把一次性 `code` 交给开发者自己的服务端。
122
- *
123
- * @see [auth.login](/reference/sdk/auth/login)
124
- * @see [user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
125
- */
126
- export type MiniProgramUserInfoResult =
127
- | {
128
- /** `false` 是未登录分支的稳定判别值。 */
129
- isHeyboxAppLoggedIn: false;
130
- /** 未登录时没有当前小程序的用户授权上下文。 */
131
- authorization: null;
132
- /** 未登录时不会披露隔离身份或公开资料。 */
133
- userInfo: null;
134
- }
135
- | {
136
- /** `true` 表示 Host 当前有已登录的小黑盒账号,不等同于开发者服务端已建立会话。 */
137
- isHeyboxAppLoggedIn: true;
138
- /** 当前小程序的用户授权状态;与 Manifest 权限声明是两层独立门禁。 */
139
- authorization: UserInfoAuthorization;
140
- /** 已获准披露的隔离身份与公开资料;兼容 Host 可能返回 `null`。 */
141
- userInfo: AuthorizedUserInfo | null;
142
- };
143
- /** `user.getInfo` 不接收入参,也不能由页面指定小程序或用户身份。 */
144
- export type GetUserInfoPayload = void;
145
- /** `user.getInfo` 的判别联合返回值;先判断 `isHeyboxAppLoggedIn`,再判断 `userInfo`。 */
146
- export type GetUserInfoResult = MiniProgramUserInfoResult;
147
- /**
148
- * `user.revokeAuthorization` 不接受 wire payload。
149
- *
150
- * @remarks
151
- * 小程序 ID、当前小黑盒用户和可信手势状态由 Host 注入;发送任何非 `undefined` payload
152
- * 都会返回 `INVALID_PARAMS`。该 method 无需 Manifest 权限,但仍要求当前用户已登录且调用
153
- * 来自可信用户操作。
154
- *
155
- * @see [App-facing user.revokeAuthorization](/reference/sdk/user/revokeAuthorization)
156
- */
157
- export type RevokeAuthorizationPayload = void;
158
- /**
159
- * 撤销成功后的 wire 结果为 `undefined`。
160
- *
161
- * @remarks
162
- * 成功后 Runtime 会使缓存的用户授权和隔离身份失效,并发布
163
- * `user_info_authorization_change`;业务持久化数据和开发者服务端会话不在该结果的清理范围内。
164
- */
165
- export type RevokeAuthorizationResult = void;
166
- /**
167
- * Steam 游戏库排序维度:`weeks` 按最近两周时长,`all` 按累计时长,`achieved` 按成就数。
168
- */
169
- export type SteamGameListSort = 'weeks' | 'all' | 'achieved';
170
- /** `user.getSteamGameList` 的 wire 请求对象;字段校验和默认值由 Host Runtime 执行。 */
171
- interface GetSteamGameListRequest {
172
- /** trim 后的非空 Steam ID;省略时使用当前用户的默认绑定账号。 */
173
- steamId?: string;
174
- /** 正整数页大小,默认 `20`,大于 `100` 时收窄为 `100`。 */
175
- limit?: number;
176
- /** 非负整数 offset,默认 `0`。 */
177
- offset?: number;
178
- /** 排序维度,默认 `weeks`。 */
179
- sort?: SteamGameListSort;
180
- /** trim 后最多保留前 100 个 UTF-16 code unit;空值会被省略。 */
181
- q?: string;
182
- /** 是否包含隐藏游戏,默认 `false`;仅接受 boolean。 */
183
- includeHidden?: boolean;
184
- }
185
- /**
186
- * `user.getSteamGameList` 的可选 wire payload;`undefined` 使用全部默认查询值。
187
- *
188
- * @remarks
189
- * Host 会拒绝未知字段、数字字符串和用 `0` / `1` 代替 boolean 的值。该 method 要求
190
- * `steamLibrary` 权限,但不要求公开 `network` 权限或可信用户手势。
191
- *
192
- * @see [App-facing user.getSteamGameList](/reference/sdk/user/getSteamGameList)
193
- */
194
- export type GetSteamGameListPayload = GetSteamGameListRequest | undefined;
195
- /**
196
- * Steam 游戏价格 wire 结果。所有字段都可省略,且协议不携带币种或最小货币单位。
197
- */
198
- export type SteamGamePrice = {
199
- /** 当前售价的非空展示文本。 */
200
- current?: string;
201
- /** 原价的非空展示文本。 */
202
- initial?: string;
203
- /** 服务端原始折扣数值;协议不承诺比例、百分比或取值范围。 */
204
- discount?: number;
205
- /** 服务端最低价数值;币种和缩放单位不属于本协议。 */
206
- lowestPrice?: number;
207
- /** 截止时间展示文本,不保证可解析为日期。 */
208
- deadlineDate?: string;
209
- /** 服务端原始折扣截止时间数值;协议不承诺单位或时钟来源。 */
210
- deadlineTimestamp?: number;
211
- };
212
- /**
213
- * 经过 Host Runtime 规范化的 Steam 游戏条目;无效必填字段会导致整条记录被移除。
214
- */
215
- export interface SteamGameListItem {
216
- /** 小黑盒游戏目录 ID。 */
217
- appid: number;
218
- /** Steam App ID;缺失时由 Host 回退为 `appid`。 */
219
- steamAppid: number;
220
- /** trim 后的非空名称。 */
221
- name: string;
222
- /** 非空封面或主图 URL 字符串。 */
223
- image?: string;
224
- /** 非空 Steam 图标 URL 字符串。 */
225
- icon?: string;
226
- /** Steam 游戏库接口返回的累计游玩时长,当前单位为秒;`0` 是有效值。 */
227
- playtimeForever?: number;
228
- /** Steam 游戏库接口返回的最近两周游玩时长,当前单位为秒;`0` 是有效值。 */
229
- playtime2Weeks?: number;
230
- /** 非空标签列表;没有有效标签时省略。 */
231
- tags?: string[];
232
- /** 至少有一个可用价格字段时存在。 */
233
- price?: SteamGamePrice;
234
- }
235
- /** Steam 游戏库的 offset 分页结果。 */
236
- export interface SteamGameListData {
237
- /** 当前页通过规范化校验的游戏条目。 */
238
- gameList: SteamGameListItem[];
239
- /** 服务端游戏总数;缺失或无效时省略。 */
240
- total?: number;
241
- /** 有 `total` 时按 `nextOffset < total` 计算,否则按本页是否达到有效 `limit` 推断。 */
242
- hasMore: boolean;
243
- /** `请求 offset + gameList.length`;下一页应直接复用该值。 */
244
- nextOffset: number;
245
- /** 服务端对结果是否属于当前用户本人的标记;不可识别时省略。 */
246
- isMe?: boolean;
247
- }
248
- /**
249
- * `user.getSteamGameList` 的判别联合结果。
250
- *
251
- * @remarks
252
- * - `isLogin: false`:未登录,`isBound` 固定为 `false`,`data` 固定为 `null`。
253
- * - `isLogin: true, isBound: false`:已登录但未绑定 Steam,`data` 固定为 `null`。
254
- * - 两者均为 `true`:`data` 固定为 {@link SteamGameListData},其中 `gameList` 可以为空。
255
- */
256
- export type GetSteamGameListResult =
257
- | { isLogin: false; isBound: false; data: null }
258
- | { isLogin: true; isBound: false; data: null }
259
- | { isLogin: true; isBound: true; data: SteamGameListData };
260
-
261
- /** 公开分享渠道;Host 可以只支持其中一部分,值区分大小写。 */
262
- export type MiniProgramShareChannel = 'wechatSession' | 'wechatTimeline' | 'qqFriend' | 'qzone' | 'weibo';
263
- /** 社区发帖页的可编辑分区与话题预置。 */
264
- export interface MiniProgramSharePostOptions {
265
- /** 正安全整数或 trim 后非空字符串;Runtime 转为字符串并去重。 */
266
- topicIds?: (string | number)[];
267
- /** trim 后非空且不以 `#` 开头或结尾的字符串;Runtime 去重。 */
268
- topics?: string[];
269
- }
270
- export interface MiniProgramScreenshotRect {
271
- left: number;
272
- top: number;
273
- width: number;
274
- height: number;
275
- }
276
- /**
277
- * `share.showShareMenu` 的 wire payload;落地页由 Runtime 固定生成,不接受 `url` 字段。
278
- */
279
- export type ShowShareMenuPayload = {
280
- /** trim 后必须非空;原字符串会交给 Host。 */
281
- title: string;
282
- /** trim 后必须非空;原字符串会交给 Host。 */
283
- desc: string;
284
- /** 经 Runtime 校验并编码到固定分享 URL 的 JSON-compatible 状态。 */
285
- extra?: unknown;
286
- /** 可解析的绝对 HTTP(S) 缩略图 URL。 */
287
- imageUrl?: string;
288
- /** 可选站外渠道;不能与有效社区 `post` 同时使用。 */
289
- channel?: MiniProgramShareChannel;
290
- /**
291
- * 可编辑社区预置;`null` 等同省略。普通分享最多保留一个分区,开发态严格拒绝无效项,
292
- * 生产态过滤无效项并在与 `channel` 冲突时省略 `post`。
293
- */
294
- post?: MiniProgramSharePostOptions | null;
295
- };
296
- /**
297
- * Host 分享面板返回的不透明值。
298
- *
299
- * @remarks 可能是 `undefined` 或任意对象;不能依赖结构或真假值判断用户分享结果。
300
- */
301
- export type ShowShareMenuResult = unknown;
302
- export type CopyLinkPayload = { extra?: unknown } | undefined;
303
- export type CopyLinkResult = string;
304
- export type ScreenshotPayload =
305
- | {
306
- rect?: MiniProgramScreenshotRect;
307
- delay?: number;
308
- saveToAlbum?: boolean;
309
- post?: MiniProgramSharePostOptions | null;
310
- }
311
- | undefined;
312
- export type ScreenshotResult = unknown;
313
-
314
- /** 当前小程序实例的运行模式。 */
315
- export type MiniProgramRuntimeMode = 'production' | 'preview' | 'development' | 'unknown';
316
-
317
- /** Host 明确提供的操作系统名称。 */
318
- export type MiniProgramOperatingSystemName = 'android' | 'ios' | 'ohos' | 'windows' | 'macos' | 'linux' | 'unknown';
319
-
320
- /**
321
- * Runtime 在握手期间下发的环境快照。
322
- *
323
- * @remarks
324
- * 所有字段只用于界面适配、兼容降级和诊断,不能作为鉴权、权限控制或风控依据。
325
- * 版本字段均为不透明字符串,除缺失判断外不承诺格式或大小比较语义。
326
- */
327
- export interface MiniProgramRuntimeEnvironmentInfo {
328
- readonly runtime: {
329
- readonly mode: MiniProgramRuntimeMode;
330
- };
331
- readonly host: {
332
- readonly appVersion: string | null;
333
- };
334
- readonly miniProgram: {
335
- readonly id: string | null;
336
- readonly version: string | null;
337
- };
338
- readonly operatingSystem: {
339
- readonly name: MiniProgramOperatingSystemName;
340
- readonly version: string | null;
341
- };
342
- }
343
-
344
- export interface GetStoragePayload {
345
- key: string;
346
- }
347
- export interface GetStorageResult<T = unknown> {
348
- data: T | undefined;
349
- }
350
- export interface SetStoragePayload {
351
- key: string;
352
- data: unknown;
353
- }
354
-
355
- export interface MiniProgramSafeArea {
356
- left: number;
357
- right: number;
358
- top: number;
359
- bottom: number;
360
- width: number;
361
- height: number;
362
- }
363
- export interface MiniProgramWindowInfoResult {
364
- pixelRatio: number;
365
- screenWidth: number;
366
- screenHeight: number;
367
- windowWidth: number;
368
- windowHeight: number;
369
- statusBarHeight: number;
370
- safeArea: MiniProgramSafeArea;
371
- screenTop: number;
372
- }
373
- /** 小程序窗口方向。 */
374
- export type MiniProgramOrientationMode = 'portrait' | 'landscape';
375
- /** 宿主确认生效的小程序展示状态;不表示手机旋转传感器状态。 */
376
- export interface MiniProgramDisplayState {
377
- /** 当前小程序锁定的窗口方向。 */
378
- orientation: MiniProgramOrientationMode;
379
- /** 是否同时收起胶囊和宿主额外顶部栏;横屏始终为 true。 */
380
- fullscreen: boolean;
381
- }
382
- export interface SetDisplayPayload {
383
- /** 锁定竖屏或横屏;省略保持当前目标方向,初始为 portrait。 */
384
- orientation?: MiniProgramOrientationMode;
385
- /** 同时收起胶囊和宿主额外顶部栏;省略保持当前目标值,初始为 false。合并后横屏强制 true;退出横屏全屏需同时设置 portrait 和 false。 */
386
- fullscreen?: boolean;
387
- }
388
- /** 本次展示设置的原生支持结果;不支持时保留原生状态,宿主仍可尽力收起 H5 顶部栏。 */
389
- export type SetDisplayResult = {
390
- /** true 表示原生方向与胶囊设置已完成;false 表示已按宿主可用能力降级。 */
391
- supported: boolean;
392
- };
393
-
394
- export type GetWindowInfoPayload = void;
395
- export type GetWindowInfoResult = MiniProgramWindowInfoResult;
396
- export type MiniProgramNavigationBarForegroundStyle = 'light' | 'dark';
397
- export type SetNavigationBarStylePayload = { foregroundStyle: MiniProgramNavigationBarForegroundStyle };
398
- export type SetNavigationBarStyleResult = void;
399
-
400
- export type MiniProgramNetworkHeaders = Record<string, string>;
401
- export type MiniProgramNetworkParams = Record<string, unknown>;
402
- export type MiniProgramNetworkRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
403
- export interface NetworkRequestPayload {
404
- url: string;
405
- method?: MiniProgramNetworkRequestMethod;
406
- params?: MiniProgramNetworkParams;
407
- data?: unknown;
408
- headers?: MiniProgramNetworkHeaders;
409
- timeout?: number;
410
- }
411
- export interface NetworkResponsePayload<T = unknown> {
412
- data: T;
413
- status: number;
414
- statusText?: string;
415
- headers: MiniProgramNetworkHeaders;
416
- }
417
-
418
- export type MiniProgramFileMode = 'read' | 'readwrite';
419
-
420
- export interface MiniProgramSandboxRootRef {
421
- kind: 'sandbox';
422
- }
423
-
424
- export interface MiniProgramDirectFileRef {
425
- kind: 'file';
426
- handleId: string;
427
- }
428
-
429
- export interface MiniProgramDirectDirectoryRef {
430
- kind: 'directory';
431
- handleId: string;
432
- }
433
-
434
- export type MiniProgramPathRootRef = MiniProgramSandboxRootRef | MiniProgramDirectDirectoryRef;
435
-
436
- export interface MiniProgramDerivedFileRef {
437
- kind: 'file';
438
- root: MiniProgramPathRootRef;
439
- relativePath: string;
440
- }
441
-
442
- export interface MiniProgramDerivedDirectoryRef {
443
- kind: 'directory';
444
- root: MiniProgramPathRootRef;
445
- relativePath: string;
446
- }
447
-
448
- export type MiniProgramFileRef = MiniProgramDirectFileRef | MiniProgramDerivedFileRef;
449
- export type MiniProgramDirectoryRef = MiniProgramDirectDirectoryRef | MiniProgramDerivedDirectoryRef;
450
- export type MiniProgramFileSystemEntityRef = MiniProgramFileRef | MiniProgramDirectoryRef;
451
-
452
- export interface MiniProgramFileDescriptor {
453
- kind: 'file';
454
- name: string;
455
- mode: MiniProgramFileMode;
456
- ref: MiniProgramFileRef;
457
- }
458
-
459
- export interface MiniProgramDirectoryDescriptor {
460
- kind: 'directory';
461
- name: string;
462
- mode: MiniProgramFileMode;
463
- ref: MiniProgramDirectoryRef;
464
- }
465
-
466
- export type MiniProgramFileSystemEntityDescriptor = MiniProgramFileDescriptor | MiniProgramDirectoryDescriptor;
467
-
468
- export interface MiniProgramCreateOptions {
469
- recursive?: boolean;
470
- exclusive?: boolean;
471
- }
472
-
473
- export interface MiniProgramFileStat {
474
- kind: 'file';
475
- size: number;
476
- modifiedAt?: number;
477
- createdAt?: number;
478
- }
479
-
480
- export type PickFilesPayload =
481
- | {
482
- mode?: MiniProgramFileMode;
483
- accept?: string[];
484
- multiple?: boolean;
485
- }
486
- | undefined;
487
- export type PickFilesResult = Array<MiniProgramFileDescriptor & { ref: MiniProgramDirectFileRef }>;
488
-
489
- export type PickDirectoryPayload = { mode?: MiniProgramFileMode } | undefined;
490
- export type PickDirectoryResult = MiniProgramDirectoryDescriptor & { ref: MiniProgramDirectDirectoryRef };
491
-
492
- export interface SaveFilePayload {
493
- suggestedName: string;
494
- }
495
- export type SaveFileResult = MiniProgramFileDescriptor & { ref: MiniProgramDirectFileRef };
496
-
497
- export interface FileCreatePayload extends MiniProgramCreateOptions {
498
- target: MiniProgramFileRef;
499
- }
500
- export type FileCreateResult = void;
501
-
502
- export interface FileRemovePayload {
503
- target: MiniProgramFileRef;
504
- }
505
- export type FileRemoveResult = void;
506
-
507
- export interface FileExistsPayload {
508
- target: MiniProgramFileRef;
509
- }
510
- export type FileExistsResult = boolean;
511
-
512
- export interface FileReadTextPayload {
513
- target: MiniProgramFileRef;
514
- }
515
- export type FileReadTextResult = string;
516
-
517
- export interface FileWriteTextPayload {
518
- target: MiniProgramFileRef;
519
- content: string;
520
- }
521
- export type FileWriteTextResult = void;
522
-
523
- export interface FileReadBytesPayload {
524
- target: MiniProgramFileRef;
525
- }
526
- export type FileReadBytesResult = Uint8Array;
527
-
528
- export interface FileWriteBytesPayload {
529
- target: MiniProgramFileRef;
530
- content: Uint8Array;
531
- }
532
- export type FileWriteBytesResult = void;
533
-
534
- export interface FileStatPayload {
535
- target: MiniProgramFileRef;
536
- }
537
- export type FileStatResult = MiniProgramFileStat;
538
-
539
- export interface DirectoryCreatePayload extends MiniProgramCreateOptions {
540
- target: MiniProgramDirectoryRef;
541
- }
542
- export type DirectoryCreateResult = void;
543
-
544
- export interface DirectoryRemovePayload {
545
- target: MiniProgramDirectoryRef;
546
- recursive?: boolean;
547
- }
548
- export type DirectoryRemoveResult = void;
549
-
550
- export interface DirectoryExistsPayload {
551
- target: MiniProgramDirectoryRef;
552
- }
553
- export type DirectoryExistsResult = boolean;
554
-
555
- export interface DirectoryListPayload {
556
- target: MiniProgramDirectoryRef;
557
- limit?: number;
558
- }
559
- export type DirectoryListResult = MiniProgramFileSystemEntityDescriptor[];
560
-
561
- export interface DownloadProgressPayload {
562
- loaded: number;
563
- total?: number;
564
- lengthComputable: boolean;
565
- }
566
-
567
- interface NetworkDownloadBasePayload {
568
- url: string;
569
- params?: MiniProgramNetworkParams;
570
- headers?: MiniProgramNetworkHeaders;
571
- timeout?: number;
572
- maxBytes?: number;
573
- }
574
-
575
- export type NetworkDownloadPayload = NetworkDownloadBasePayload &
576
- (
577
- | {
578
- to: MiniProgramFileRef;
579
- suggestedName?: never;
580
- overwrite?: never;
581
- }
582
- | {
583
- to: MiniProgramDirectoryRef;
584
- suggestedName?: string;
585
- overwrite?: boolean;
586
- }
587
- );
588
-
589
- export type NetworkDownloadResult = MiniProgramFileDescriptor;
590
-
591
- export type MiniProgramToastStatus = 'success' | 'error';
592
- export interface ShowToastPayload {
593
- message: string;
594
- status?: MiniProgramToastStatus;
595
- }
596
- export type ShowToastResult = void;
597
- export interface ShowLoadingPayload {
598
- dismissible?: boolean;
599
- }
600
- export type ShowLoadingResult = void;
601
- export type HideLoadingPayload = void;
602
- export type HideLoadingResult = void;
603
- export type MiniProgramVibrateIntensity = 'light' | 'medium' | 'heavy';
604
- export interface VibratePayload {
605
- intensity?: MiniProgramVibrateIntensity;
606
- delay?: number;
607
- }
608
- export type VibrateResult = void;
609
- export interface SetClipboardPayload {
610
- text: string;
611
- }
612
- export type SetClipboardResult = void;
613
-
614
- /**
615
- * `navigation.close` 的无参 wire payload。
616
- *
617
- * @remarks
618
- * App-facing API 发送 `undefined`。Host Runtime 为兼容协议也接受空普通对象,但非空对象、
619
- * 数组或其他值会返回 `INVALID_PARAMS`;payload 不能携带强制关闭、原因或窗口标识。
620
- *
621
- * @see [App-facing navigation.close](/reference/sdk/navigation/close)
622
- */
623
- export type ClosePayload = void;
624
- /**
625
- * Host 接受关闭请求后的 wire 结果为 `undefined`。
626
- *
627
- * @remarks
628
- * 该结果不保证 iframe 在响应抵达后继续存活,也不包含最终关闭状态。Host 销毁环境时会尽力
629
- * 派发 `unload`;关键持久化不能依赖 Promise 后续语句或 `unload` 回调。
630
- */
631
- export type CloseResult = void;
632
- /**
633
- * `navigation.reload` 的无参 wire payload。
634
- *
635
- * @remarks
636
- * App-facing API 发送 `undefined`。Host Runtime 为兼容协议也接受空普通对象,但非空对象、
637
- * 数组或其他值会返回 `INVALID_PARAMS`;payload 不能指定缓存策略、目标 URL 或 reload 模式。
638
- *
639
- * @see [App-facing navigation.reload](/reference/sdk/navigation/reload)
640
- */
641
- export type ReloadPayload = void;
642
- /**
643
- * Host 接受 reload 请求后的 wire 结果为 `undefined`。
644
- *
645
- * @remarks
646
- * 该结果不包含新页面加载状态或新 SDK 实例。旧页面内存、监听和 pending 请求不会跨 reload
647
- * 保留;关键持久化不能依赖 Promise 后续语句或 `unload` 回调。
648
- */
649
- export type ReloadResult = void;
650
- /** 允许打开的 App 页面与公开小程序目标白名单;不包含任意 URL、scheme 或内部路由。 */
651
- export type MiniProgramAppPageTarget = 'game_detail' | 'user_detail' | 'post_detail' | 'mini_program';
652
- /** 游戏平台类型:PC、主机或移动游戏。 */
653
- export type MiniProgramGameDetailGameType = 'pc' | 'console' | 'mobile';
654
- /** 游戏详情首屏:详情主页或百科页。 */
655
- export type MiniProgramGameDetailPage = 'game' | 'wiki';
656
- /** 打开游戏详情页的规范化 wire payload。 */
657
- export type OpenGameDetailAppPagePayload = {
658
- /** 固定判别值。 */
659
- target: 'game_detail';
660
- /** trim 后的非空游戏 app ID 字符串。 */
661
- appId: string;
662
- /** 只允许 `pc`、`console`、`mobile`。 */
663
- gameType: MiniProgramGameDetailGameType;
664
- /** 可选首屏,只允许 `game` 或 `wiki`。 */
665
- page?: MiniProgramGameDetailPage;
666
- /** trim 后的非空来源标识。 */
667
- hSrc?: string;
668
- /** trim 后的非空 SKU ID 字符串。 */
669
- skuId?: string;
670
- };
671
- /** 打开用户详情页的规范化 wire payload。 */
672
- export type OpenUserDetailAppPagePayload = {
673
- /** 固定判别值。 */
674
- target: 'user_detail';
675
- /** trim 后的非空 `heybox_id` 字符串。 */
676
- userId: string;
677
- };
678
- /** 打开帖子详情页的规范化 wire payload。 */
679
- export type OpenPostDetailAppPagePayload = {
680
- /** 固定判别值。 */
681
- target: 'post_detail';
682
- /** trim 后的非空帖子 ID 字符串。 */
683
- linkId: string;
684
- /** 可选的非空根评论 ID 字符串。 */
685
- rootCommentId?: string;
686
- /** 可选的非空目标评论 ID 字符串。 */
687
- commentId?: string;
688
- };
689
- /** 打开另一个公开发布小程序的 wire payload;目标版本与访问性由 Host 决定。 */
690
- export type OpenMiniProgramAppPagePayload = {
691
- /** 固定判别值。 */
692
- target: 'mini_program';
693
- /** trim 后的非空目标小程序 ID。 */
694
- miniProgramId: string;
695
- /** 可选 JSON-compatible 启动数据;Runtime 会按分享 `extra` 合同再次校验和编码。 */
696
- extra?: unknown;
697
- };
698
- /**
699
- * `navigation.openAppPage` 的判别联合 wire payload。
700
- *
701
- * @remarks
702
- * Runtime 只读取上述白名单字段并构造固定 Host 路由;额外 URL、path、scheme 或窗口字段
703
- * 不会透传。移动端 Host 支持全部四类目标;当前 PC Host 支持 `game_detail` 与 `mini_program`,
704
- * 仍拒绝用户详情和帖子详情。
705
- *
706
- * @see [App-facing navigation.openAppPage](/reference/sdk/navigation/openAppPage)
707
- */
708
- export type OpenAppPagePayload =
709
- | OpenGameDetailAppPagePayload
710
- | OpenUserDetailAppPagePayload
711
- | OpenPostDetailAppPagePayload
712
- | OpenMiniProgramAppPagePayload;
713
- /**
714
- * Host 接收参数并发起受控路由后的结果为 `undefined`。
715
- *
716
- * @remarks 不表示目标页加载完成,也不返回目标页数据、关闭结果或回调值。
717
- */
718
- export type OpenAppPageResult = void;
719
-
720
- export type LeaderboardOrder = 'asc' | 'desc';
721
- export interface LeaderboardEntry {
722
- rank: number;
723
- ranked: boolean;
724
- appUserId: string;
725
- score: number;
726
- extra: Record<string, unknown>;
727
- createdAt: number;
728
- updatedAt: number;
729
- }
730
- export interface SubmitLeaderboardEntryPayload {
731
- key?: string;
732
- score: number;
733
- extra?: Record<string, unknown>;
734
- }
735
- export type SubmitLeaderboardEntryResult = LeaderboardEntry;
736
- export interface GetLeaderboardListPayload {
737
- key?: string;
738
- limit?: number;
739
- cursor?: string;
740
- }
741
- export interface GetLeaderboardListResult {
742
- entries: LeaderboardEntry[];
743
- cursor?: string;
744
- hasMore: boolean;
745
- }
746
- export interface GetCurrentUserLeaderboardEntryPayload {
747
- key?: string;
748
- }
749
- export type GetCurrentUserLeaderboardEntryResult = LeaderboardEntry | undefined;
750
- export interface DeleteCurrentUserLeaderboardEntryPayload {
751
- key?: string;
752
- }
753
- export interface DeleteCurrentUserLeaderboardEntryResult {
754
- deleted: boolean;
755
- }
756
- export interface GetLeaderboardInfoPayload {
757
- key?: string;
758
- }
759
- export interface GetLeaderboardInfoResult {
760
- key: string;
761
- order: LeaderboardOrder;
762
- rankLimit: number;
763
- }
764
-
765
- /**
766
- * 当前 Companion 产物声明并由 Host 确认的可选能力。
767
- *
768
- * @remarks
769
- * - `stdio`:启动后的 Session 可以读写原始 stdin/stdout/stderr 字节流。
770
- * - `attachments`:Session 可以按 opaque ID 打开 Host 衰减为只读的受控附件。
771
- * - `notifications`:Session 可以请求 Host 展示固定类别的系统通知。
772
- *
773
- * 能力出现在 {@link CompanionInfo.capabilities} 只描述当前产物合同,不表示已经准备完成、
774
- * 已经启动或当前 Host 一定能成功执行每次操作。启动后仍应按 `CompanionSession` 对应可选
775
- * 属性是否存在进行分支。
776
- */
777
- export type CompanionCapability = 'stdio' | 'attachments' | 'notifications';
778
-
779
- /**
780
- * 当前 Host 为 Companion 选择的目标制品。
781
- *
782
- * @remarks
783
- * V1 仅支持 Windows x64 与 macOS arm64。该值是当前运行 Host 选中的一个 target,不是
784
- * Manifest 声明的全部 target 列表;当前平台没有匹配制品时 `companion.getInfo()` 会拒绝,
785
- * 不会返回猜测值。
786
- */
787
- export type CompanionTarget = 'windows-x64' | 'macos-arm64';
788
-
789
- /**
790
- * Host 对当前 Companion 制品给出的签名检查状态。
791
- *
792
- * @remarks
793
- * `unsigned` 表示未签名,`valid` 表示 Host 已确认签名有效,`invalid` 表示签名校验失败,
794
- * `unknown` 表示 Host 尚不能确认。该字段用于展示和诊断,不会替代准备完整性校验、Host
795
- * 授权或操作系统安全策略;本地开发制品可以是 `unsigned`。
796
- */
797
- export type CompanionSignatureStatus = 'unsigned' | 'valid' | 'invalid' | 'unknown';
798
-
799
- /** Companion alias 的跨构建、Runtime 与 Host 规范。 */
800
- export const COMPANION_ALIAS_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
801
-
802
- /** Companion Host 可跨 bridge 保留的稳定领域错误码。 */
803
- export const COMPANION_ERROR_CODES = [
804
- 'COMPANION_UNSUPPORTED',
805
- 'COMPANION_PREVIEW_UNSUPPORTED',
806
- 'COMPANION_NOT_DECLARED',
807
- 'COMPANION_TARGET_UNSUPPORTED',
808
- 'COMPANION_NOT_PREPARED',
809
- 'COMPANION_PREPARATION_CANCELLED',
810
- 'COMPANION_DOWNLOAD_FAILED',
811
- 'COMPANION_DESCRIPTOR_UNAVAILABLE',
812
- 'COMPANION_ARCHIVE_INVALID',
813
- 'COMPANION_INTEGRITY_FAILED',
814
- 'COMPANION_ENTRYPOINT_INVALID',
815
- 'COMPANION_USER_CANCELLED',
816
- 'COMPANION_ELEVATION_DENIED',
817
- 'COMPANION_OS_BLOCKED',
818
- 'COMPANION_LAUNCH_FAILED',
819
- 'COMPANION_SESSION_VERSION_MISMATCH',
820
- 'COMPANION_SESSION_OWNERSHIP_LOST',
821
- 'COMPANION_SESSION_EXITED',
822
- 'COMPANION_PIPE_CLOSED',
823
- 'COMPANION_OUTPUT_LIMIT',
824
- 'COMPANION_PROCESS_CRASHED',
825
- 'COMPANION_ATTACHMENT_NOT_FOUND',
826
- 'COMPANION_NOTIFICATION_UNAVAILABLE',
827
- 'COMPANION_TERMINATE_FAILED',
828
- ] as const;
829
- export type CompanionErrorCode = (typeof COMPANION_ERROR_CODES)[number];
830
-
831
- /**
832
- * Host 针对当前小程序版本与当前平台确认的 Companion 描述快照。
833
- *
834
- * @remarks
835
- * Runtime 会校验字段、去重并冻结 `capabilities`,再返回冻结对象;页面不应修改或缓存为
836
- * 跨版本事实。该结构刻意不包含准备 `state`、进度、`preparedAt`、Session ID、PID、物理
837
- * 路径、下载 URL、SHA-256、entrypoint 或单独的 Companion 版本号。
838
- *
839
- * 准备状态通过 `companion.getPreparationStatus()` 查询。Companion 随当前小程序审核版本、
840
- * 精确预览版本或本地开发快照绑定;`source` 只说明来源类别,不提供版本号,也不能用于
841
- * 比较版本新旧。
842
- *
843
- * @see {@link https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/companion/getInfo.html | companion.getInfo}
844
- * @see {@link https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/companion/getPreparationStatus.html | companion.getPreparationStatus}
845
- */
846
- export interface CompanionInfo {
847
- /**
848
- * 规范 alias;必须与请求值及 `package.json#heybox.companions` 中的 key 完全一致。
849
- */
850
- alias: string;
851
- /**
852
- * Host 确认的用户可见名称,只用于展示;不要把它当作稳定标识、文件名或版本号。
853
- */
854
- displayName: string;
855
- /** 当前 Host 选中的目标制品;不是项目声明的全部 target。 */
856
- target: CompanionTarget;
857
- /**
858
- * 当前产物声明且 Host 确认的去重能力列表;可能为空,不代表产物已准备或已启动。
859
- */
860
- capabilities: readonly CompanionCapability[];
861
- /** 当前压缩归档大小,单位字节;是大于等于 `0` 的安全整数,不是解压后磁盘占用。 */
862
- archiveBytes: number;
863
- /** Host 对当前制品给出的签名检查状态;不能替代完整性校验或系统安全判断。 */
864
- signatureStatus: CompanionSignatureStatus;
865
- /**
866
- * Host 确认的产物来源。
867
- *
868
- * @remarks
869
- * `local-dev` 是当前 `hb-sdk dev` 绑定的本地快照;`preview` 是精确审核前预览版本;
870
- * `released` 是已发布版本。旧 Host 缺省时为 `undefined`,只表示来源未知,不应回退为
871
- * `released`。不要根据 alias、displayName、签名状态或页面 URL 自行推断来源。
872
- */
873
- source?: 'local-dev' | 'preview' | 'released';
874
- }
875
-
876
- /**
877
- * Host 最近一次 Companion 准备失败的公开摘要。
878
- *
879
- * @remarks
880
- * Runtime 只保留稳定领域错误码、规范化文案和重试建议;原生路径、下载地址、堆栈和其他
881
- * Host 诊断信息不会下发。该摘要描述最近一次准备,不代表当前正在自动重试。
882
- */
883
- export interface CompanionErrorSummary {
884
- /** 稳定的 Companion 领域错误码;业务分支应比较该字段,不要比较 `message`。 */
885
- code: CompanionErrorCode;
886
- /** Runtime 根据错误码生成的安全展示文案;不承诺保留 Host 原始 message。 */
887
- message: string;
888
- /**
889
- * Host 对“以新的可信用户操作再次调用 `prepare()` 是否可能成功”的建议。
890
- *
891
- * `true` 不会触发自动重试,也不绕过权限、授权、完整性或手势要求;调用方仍应采用
892
- * 有界重试。`false` 表示不应原样循环重试,通常需要修改产物、配置或环境。
893
- */
894
- retryable: boolean;
895
- }
896
-
897
- /**
898
- * Host 持有的 Companion 准备操作的最近进度快照。
899
- *
900
- * @remarks
901
- * 三个阶段的计数都是非负安全整数。Runtime 只保证同一进度对象内当前值不大于已知总量,
902
- * 不定义 verifying/extracting 与下载字节之间的换算,也不保证不同阶段的 total 相同;进度
903
- * 只能用于展示当前阶段,不能作为归档完整性证据。
904
- */
905
- export type CompanionPrepareProgress =
906
- | {
907
- /** 下载阶段判别值。 */
908
- phase: 'downloading';
909
- /** Host 已下载的非负安全整数计数。 */
910
- loaded: number;
911
- /** Host 已知总量;未知时省略,存在时为不小于 `loaded` 的非负安全整数。 */
912
- total?: number;
913
- }
914
- | {
915
- /** 校验阶段判别值。 */
916
- phase: 'verifying';
917
- /** Host 已校验的非负安全整数计数,且不大于 `total`。 */
918
- processed: number;
919
- /** 当前校验阶段的非负安全整数总量。 */
920
- total: number;
921
- }
922
- | {
923
- /** 解压阶段判别值。 */
924
- phase: 'extracting';
925
- /** Host 已处理的非负安全整数计数,且不大于 `total`。 */
926
- processed: number;
927
- /** 当前解压阶段的非负安全整数总量。 */
928
- total: number;
929
- };
930
-
931
- /**
932
- * 当前小程序版本、当前平台与指定 alias 对应的 Host 准备状态快照。
933
- *
934
- * @remarks
935
- * 这是以 `state` 为判别字段的四态联合,Runtime 会冻结返回对象及嵌套的 `progress` 或
936
- * `error`。它描述 Host 持久状态,不等同于某个页面中 `prepare()` Promise 的状态,也不会
937
- * 随后台操作自动变化;需要最新值时重新调用 `companion.getPreparationStatus()`。
938
- *
939
- * @see {@link https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/companion/getPreparationStatus.html | companion.getPreparationStatus}
940
- */
941
- export type CompanionPreparationStatus =
942
- | {
943
- /** 当前版本与 target 尚无已原子提交的本地产物,也没有在途准备。 */
944
- state: 'not-prepared';
945
- }
946
- | {
947
- /** Host 正在下载、校验或解压;页面 reload 或隐藏不会自动取消该操作。 */
948
- state: 'preparing';
949
- /** 查询时 Host 保存的最近进度;这是快照,不是持续订阅。 */
950
- progress: CompanionPrepareProgress;
951
- }
952
- | {
953
- /** 当前版本产物已原子提交,可以由新的可信用户操作调用 `launch()`。 */
954
- state: 'ready';
955
- /**
956
- * Host 提供的非负安全整数准备完成时间戳。
957
- *
958
- * 协议不公开时钟来源、时区或过期语义;只适合展示和诊断,不应用于授权、版本比较
959
- * 或判断产物仍然有效。
960
- */
961
- preparedAt: number;
962
- }
963
- | {
964
- /** 最近一次准备已失败,当前没有可由该状态直接启动的新产物。 */
965
- state: 'failed';
966
- /** 经过 Runtime 脱敏和规范化的失败摘要。 */
967
- error: CompanionErrorSummary;
968
- };
969
-
970
- /**
971
- * Host 归一化后的 Companion 进程终止原因。
972
- *
973
- * @remarks
974
- * - `exited`:进程自行退出并提供 exit code;不表示 code 必然为 `0`。
975
- * - `terminated`:Host 报告进程已被显式终止。
976
- * - `crashed`:Host 把终态归类为异常崩溃。
977
- * - `host-shutdown`:Host 或其进程监管环境关闭。
978
- * - `permission-revoked`:Companion 权限撤销导致 Session 终止。
979
- * - `output-limit`:Host 的输出上限导致 Session 终止。
980
- *
981
- * 该枚举描述 Host 确认的终态,不包含 controller ownership 转移;后者不会结束进程。
982
- */
983
- export type CompanionExitReason = 'exited' | 'terminated' | 'crashed' | 'host-shutdown' | 'permission-revoked' | 'output-limit';
984
-
985
- /**
986
- * Companion Session 的一次性退出结果。
987
- *
988
- * @remarks
989
- * 这是以 `reason` 判别的只读语义结果。Runtime 只接受上方固定 reason,并要求所有出现的
990
- * `exitCode` 都是 safe integer;非法 Host 事件会被丢弃,不会进入 SDK Session。
991
- * `reason: 'exited'` 必须携带 `exitCode`,其余 Host 终止原因可携带或省略。exit code 的正负、
992
- * 具体编号和成功含义由 Companion 与目标操作系统决定,SDK 不把它转换为 HTTP 状态、信号或错误码。
993
- *
994
- * @see [CompanionSession.waitForExit()](/reference/symbols/root/interfaces/CompanionSession#waitforexit)
995
- * @see [CompanionSession.onExit()](/reference/symbols/root/interfaces/CompanionSession#onexit)
996
- */
997
- export type CompanionExit =
998
- | {
999
- /** 进程自行退出;该分支始终提供一个 safe-integer `exitCode`。 */
1000
- reason: 'exited';
1001
- /** Companion / 操作系统提供的进程退出码;调用方应按自己的进程合同解释。 */
1002
- exitCode: number;
1003
- }
1004
- | {
1005
- /** Host 确认的非普通退出原因;不会取值 `exited`。 */
1006
- reason: Exclude<CompanionExitReason, 'exited'>;
1007
- /** Host 可提供的 safe-integer 进程退出码;缺失时不要自行填充 `0` 或其他哨兵值。 */
1008
- exitCode?: number;
1009
- };
1010
-
1011
- /** 活动 Session 的 wire 快照;不包含路径、PID 或原生句柄。 */
1012
- export interface CompanionSessionSnapshot {
1013
- id: string;
1014
- alias: string;
1015
- target: CompanionTarget;
1016
- capabilities: readonly CompanionCapability[];
1017
- state: 'running';
1018
- controllerGeneration: number;
1019
- }
1020
-
1021
- export interface CompanionAliasPayload {
1022
- alias: string;
1023
- }
1024
- export type CompanionGetInfoPayload = CompanionAliasPayload;
1025
- export type CompanionGetInfoResult = CompanionInfo;
1026
- export type CompanionGetPreparationStatusPayload = CompanionAliasPayload;
1027
- export type CompanionGetPreparationStatusResult = CompanionPreparationStatus;
1028
- export type CompanionPreparePayload = CompanionAliasPayload;
1029
- export type CompanionPrepareResult = CompanionInfo;
1030
- export type CompanionCancelPreparationPayload = CompanionAliasPayload;
1031
- export type CompanionCancelPreparationResult = void;
1032
- export type CompanionGetActiveSessionPayload = CompanionAliasPayload;
1033
- export type CompanionGetActiveSessionResult = CompanionSessionSnapshot | undefined;
1034
- export type CompanionLaunchPayload = CompanionAliasPayload;
1035
- export type CompanionLaunchResult = CompanionSessionSnapshot;
1036
-
1037
- export interface CompanionSessionControllerPayload {
1038
- sessionId: string;
1039
- controllerGeneration: number;
1040
- }
1041
- export interface CompanionSessionWritePayload extends CompanionSessionControllerPayload {
1042
- data: Uint8Array;
1043
- }
1044
- export type CompanionSessionWriteResult = void;
1045
- export type CompanionSessionCloseStdinPayload = CompanionSessionControllerPayload;
1046
- export type CompanionSessionCloseStdinResult = void;
1047
- export type CompanionSessionTerminatePayload = CompanionSessionControllerPayload;
1048
- export type CompanionSessionTerminateResult = void;
1049
- export interface CompanionSessionAckOutputPayload extends CompanionSessionControllerPayload {
1050
- stream: 'stdout' | 'stderr';
1051
- sequence: number;
1052
- }
1053
- export type CompanionSessionAckOutputResult = void;
1054
- export interface CompanionOpenAttachmentPayload extends CompanionSessionControllerPayload {
1055
- id: string;
1056
- }
1057
- export type CompanionOpenAttachmentResult = MiniProgramFileDescriptor;
1058
- /**
1059
- * 桌面辅助应用通知的语义类别:`completed` 为完成,`failed` 为失败,`stopped` 为停止,
1060
- * `attention` 为需要用户关注。它只选择通知类别,不会改变进程或 session 状态。
1061
- */
1062
- export type CompanionNotificationCategory = 'completed' | 'failed' | 'stopped' | 'attention';
1063
- export interface CompanionShowNotificationPayload extends CompanionSessionControllerPayload {
1064
- category: CompanionNotificationCategory;
1065
- }
1066
- export type CompanionShowNotificationResult = void;
1067
-
1068
- export interface CompanionSessionOutputPayload extends CompanionSessionControllerPayload {
1069
- stream: 'stdout' | 'stderr';
1070
- sequence: number;
1071
- data: Uint8Array;
1072
- }
1073
- export interface CompanionSessionExitPayload {
1074
- sessionId: string;
1075
- exit: CompanionExit;
1076
- }
1077
- export interface CompanionSessionOwnershipLostPayload {
1078
- sessionId: string;
1079
- controllerGeneration: number;
1080
- }