@heybox/hb-sdk-protocol 0.8.1-alpha.9 → 0.8.2-alpha.1
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 +17 -1
- package/dist/index.cjs.js +154 -29
- package/dist/index.esm.js +145 -30
- package/generated/native-host-contract.json +479 -0
- package/generated/permission-catalog.json +185 -0
- package/package.json +6 -2
- package/src/capabilities.ts +3 -1
- package/src/index.ts +1 -0
- package/src/native-host-contract.generated.ts +60 -0
- package/src/native-host-contract.source.json +479 -0
- package/src/native-host.ts +213 -0
- package/src/payloads.ts +25 -7
- package/types/index.d.ts +1 -0
- package/types/native-host-contract.generated.d.ts +18 -0
- package/types/native-host.d.ts +147 -0
- package/types/payloads.d.ts +24 -7
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export {
|
|
2
|
+
MINI_PROGRAM_NATIVE_CHUNK_MAX_BYTES,
|
|
3
|
+
MINI_PROGRAM_NATIVE_HOST_CONTRACT_REVISION,
|
|
4
|
+
MINI_PROGRAM_NATIVE_HOST_DESCRIPTION,
|
|
5
|
+
MINI_PROGRAM_NATIVE_HOST_PROTOCOL_VERSION,
|
|
6
|
+
MINI_PROGRAM_NATIVE_OPERATIONS,
|
|
7
|
+
} from './native-host-contract.generated';
|
|
8
|
+
import { MINI_PROGRAM_NATIVE_CHUNK_MAX_BYTES } from './native-host-contract.generated';
|
|
9
|
+
/** Android WebMessageListener object 与 iOS WKScriptMessageHandler 共用名称。 */
|
|
10
|
+
export const MINI_PROGRAM_NATIVE_HOST_OBJECT = 'hbMiniProgramHost' as const;
|
|
11
|
+
/** Native 通过主文档 CustomEvent 回送 progress/result/error。 */
|
|
12
|
+
export const MINI_PROGRAM_NATIVE_HOST_MESSAGE_EVENT = 'heybox:miniprogram-native-host-message' as const;
|
|
13
|
+
|
|
14
|
+
export type MiniProgramNativeHostDomain = 'system' | 'network' | 'files';
|
|
15
|
+
|
|
16
|
+
/** H5 主文档发给 Native Host 的 operation 请求。 */
|
|
17
|
+
export interface MiniProgramNativeHostRequest {
|
|
18
|
+
requestId: string;
|
|
19
|
+
domain: MiniProgramNativeHostDomain;
|
|
20
|
+
operation: string;
|
|
21
|
+
payload?: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** 取消独立引用原请求,重复取消必须是幂等操作。 */
|
|
25
|
+
export interface MiniProgramNativeHostCancel {
|
|
26
|
+
type: 'cancel';
|
|
27
|
+
requestId: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface MiniProgramNativeHostError {
|
|
31
|
+
code: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MiniProgramNativeHostDescription {
|
|
36
|
+
protocolVersion: number;
|
|
37
|
+
contractRevision: number;
|
|
38
|
+
operations: Readonly<Record<MiniProgramNativeHostDomain, readonly string[]>>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type MiniProgramNativeHostMessage =
|
|
42
|
+
| { requestId: string; type: 'progress'; payload: unknown }
|
|
43
|
+
| { requestId: string; type: 'result'; payload?: unknown }
|
|
44
|
+
| { requestId: string; type: 'error'; error: MiniProgramNativeHostError };
|
|
45
|
+
|
|
46
|
+
export interface MiniProgramNativeBinaryChunk {
|
|
47
|
+
resourceId: string;
|
|
48
|
+
data: string;
|
|
49
|
+
byteLength: number;
|
|
50
|
+
eof: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type MiniProgramNativeFileRef =
|
|
54
|
+
| { scope: 'sandbox'; kind: 'file' | 'directory'; relativePath: string }
|
|
55
|
+
| { scope: 'grant'; id: string; kind: 'file' | 'directory'; relativePath: string };
|
|
56
|
+
|
|
57
|
+
export interface MiniProgramNativeFileDescriptor {
|
|
58
|
+
kind: 'file' | 'directory';
|
|
59
|
+
mode: 'read' | 'readwrite';
|
|
60
|
+
name: string;
|
|
61
|
+
ref: MiniProgramNativeFileRef;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface MiniProgramNativeNetworkOpenPayload {
|
|
65
|
+
purpose: 'request' | 'download';
|
|
66
|
+
url: string;
|
|
67
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
68
|
+
params?: Record<string, unknown>;
|
|
69
|
+
data?: unknown;
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
bodyEncoding?: 'json' | 'form';
|
|
72
|
+
timeoutMs: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface MiniProgramNativeNetworkOpenResult {
|
|
76
|
+
status: number;
|
|
77
|
+
statusText?: string;
|
|
78
|
+
headers: Record<string, string[]>;
|
|
79
|
+
resourceId: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface MiniProgramNativeNetworkReadPayload {
|
|
83
|
+
resourceId: string;
|
|
84
|
+
maxBytes: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface MiniProgramNativeNetworkReleasePayload {
|
|
88
|
+
resourceId: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface MiniProgramNativeNetworkTransferPayload {
|
|
92
|
+
resourceId: string;
|
|
93
|
+
target: MiniProgramNativeFileRef;
|
|
94
|
+
mode: 'replace-existing' | 'create-exclusive' | 'upsert';
|
|
95
|
+
maxBytes?: number;
|
|
96
|
+
expectedBytes?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface MiniProgramNativeNetworkTransferResult {
|
|
100
|
+
committedBytes: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface MiniProgramNativeFilesCreatePayload {
|
|
104
|
+
ref: MiniProgramNativeFileRef;
|
|
105
|
+
recursive: boolean;
|
|
106
|
+
exclusive: boolean;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MiniProgramNativeFilesRemovePayload {
|
|
110
|
+
ref: MiniProgramNativeFileRef;
|
|
111
|
+
recursive?: boolean;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface MiniProgramNativeFilesRefPayload {
|
|
115
|
+
ref: MiniProgramNativeFileRef;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface MiniProgramNativeFilesOpenPayload extends MiniProgramNativeFilesRefPayload {
|
|
119
|
+
maxBytes: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface MiniProgramNativeFilesOpenResult {
|
|
123
|
+
resourceId: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** openWrite 后按序发送;eof=true 的最后一块触发 atomic commit。 */
|
|
127
|
+
export interface MiniProgramNativeFilesWritePayload extends MiniProgramNativeBinaryChunk {}
|
|
128
|
+
|
|
129
|
+
export type MiniProgramNativeFilesStatResult =
|
|
130
|
+
| { kind: 'file'; size: number; modifiedAt?: number; createdAt?: number }
|
|
131
|
+
| { kind: 'directory'; modifiedAt?: number; createdAt?: number };
|
|
132
|
+
|
|
133
|
+
export interface MiniProgramNativeFilesListPayload extends MiniProgramNativeFilesRefPayload {
|
|
134
|
+
limit: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface MiniProgramNativeFilesPickFilesPayload {
|
|
138
|
+
mode: 'read' | 'readwrite';
|
|
139
|
+
accept?: string[];
|
|
140
|
+
multiple: boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface MiniProgramNativeFilesPickDirectoryPayload {
|
|
144
|
+
mode: 'read' | 'readwrite';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface MiniProgramNativeFilesSaveFilePayload {
|
|
148
|
+
suggestedName: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface MiniProgramNativeTransferProgress {
|
|
152
|
+
resourceId: string;
|
|
153
|
+
loaded: number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function isMiniProgramNativeHostMessage(value: unknown): value is MiniProgramNativeHostMessage {
|
|
157
|
+
if (!isRecord(value) || !isNonEmptyString(value.requestId)) return false;
|
|
158
|
+
if (value.type === 'progress') return Object.prototype.hasOwnProperty.call(value, 'payload');
|
|
159
|
+
if (value.type === 'result') return !Object.prototype.hasOwnProperty.call(value, 'error');
|
|
160
|
+
if (value.type !== 'error' || !isRecord(value.error)) return false;
|
|
161
|
+
return isNonEmptyString(value.error.code) && isNonEmptyString(value.error.message);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function isMiniProgramNativeHostDescription(value: unknown): value is MiniProgramNativeHostDescription {
|
|
165
|
+
if (
|
|
166
|
+
!isRecord(value) ||
|
|
167
|
+
!isPositiveSafeInteger(value.protocolVersion) ||
|
|
168
|
+
!isPositiveSafeInteger(value.contractRevision) ||
|
|
169
|
+
!isRecord(value.operations)
|
|
170
|
+
)
|
|
171
|
+
return false;
|
|
172
|
+
const operations = value.operations;
|
|
173
|
+
if (
|
|
174
|
+
!isOperationList(operations.system) ||
|
|
175
|
+
!isOperationList(operations.network) ||
|
|
176
|
+
!isOperationList(operations.files)
|
|
177
|
+
)
|
|
178
|
+
return false;
|
|
179
|
+
return operations.system.includes('describe');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function isMiniProgramNativeBinaryChunk(value: unknown): value is MiniProgramNativeBinaryChunk {
|
|
183
|
+
return (
|
|
184
|
+
isRecord(value) &&
|
|
185
|
+
isNonEmptyString(value.resourceId) &&
|
|
186
|
+
typeof value.data === 'string' &&
|
|
187
|
+
Number.isSafeInteger(value.byteLength) &&
|
|
188
|
+
Number(value.byteLength) >= 0 &&
|
|
189
|
+
Number(value.byteLength) <= MINI_PROGRAM_NATIVE_CHUNK_MAX_BYTES &&
|
|
190
|
+
typeof value.eof === 'boolean' &&
|
|
191
|
+
(Number(value.byteLength) > 0 || value.eof)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
196
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isNonEmptyString(value: unknown): value is string {
|
|
200
|
+
return typeof value === 'string' && value.length > 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function isPositiveSafeInteger(value: unknown): value is number {
|
|
204
|
+
return Number.isSafeInteger(value) && Number(value) > 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function isOperationList(value: unknown): value is string[] {
|
|
208
|
+
return (
|
|
209
|
+
Array.isArray(value) &&
|
|
210
|
+
value.every(operation => isNonEmptyString(operation) && operation === operation.trim()) &&
|
|
211
|
+
new Set(value).size === value.length
|
|
212
|
+
);
|
|
213
|
+
}
|
package/src/payloads.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** 当前用户信息与登录能力支持的完整 scope
|
|
2
|
-
export const USER_INFO_AUTHORIZATION_SCOPES = ['identity', 'profile'] as const;
|
|
1
|
+
/** 当前用户信息与登录能力支持的完整 scope 目录(canonical 顺序)。 */
|
|
2
|
+
export const USER_INFO_AUTHORIZATION_SCOPES = ['identity', 'profile', 'steam_account'] as const;
|
|
3
3
|
|
|
4
4
|
/** 用户信息授权 scope。 */
|
|
5
5
|
export type UserInfoAuthorizationScope = (typeof USER_INFO_AUTHORIZATION_SCOPES)[number];
|
|
@@ -16,10 +16,19 @@ export interface LoginResult {
|
|
|
16
16
|
/** 用户资料授权状态。 */
|
|
17
17
|
export type UserInfoAuthorizationStatus = 'not_required' | 'not_requested' | 'granted' | 'denied';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 当前小程序对 canonical 用户信息 scope 的授权状态。
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* `steam_account` 是可选键:新能力版本的 Runtime 必定返回,legacy Runtime/Version 可以
|
|
24
|
+
* 缺失。已授权不代表当前一定已绑定 Steam,只有 {@link AuthorizedUserInfo.steam_id}
|
|
25
|
+
* 存在才表示当前有主绑定。
|
|
26
|
+
*/
|
|
27
|
+
export interface UserInfoAuthorization {
|
|
28
|
+
identity: UserInfoAuthorizationStatus;
|
|
29
|
+
profile: UserInfoAuthorizationStatus;
|
|
30
|
+
steam_account?: UserInfoAuthorizationStatus;
|
|
31
|
+
}
|
|
23
32
|
|
|
24
33
|
/**
|
|
25
34
|
* 已获准向当前小程序披露的用户资料。
|
|
@@ -43,6 +52,14 @@ export interface AuthorizedUserInfo {
|
|
|
43
52
|
app_user_id: string;
|
|
44
53
|
/** `profile` 已授权时返回昵称与头像;当前 Heybox Runtime 在无网络模式下隐式授予该 scope。 */
|
|
45
54
|
profile: { nickname: string; avatar: string } | null;
|
|
55
|
+
/**
|
|
56
|
+
* `steam_account` 已授权且当前已绑定 Steam 时返回 canonical SteamID64。
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* 始终表示为 string,禁止作为 JSON number 使用;未绑定时省略该字段,不返回空字符串或
|
|
60
|
+
* `null`。只返回主绑定 SteamID64,不包含 Steam 昵称、头像、好友码、公开状态或绑定来源。
|
|
61
|
+
*/
|
|
62
|
+
steam_id?: string;
|
|
46
63
|
}
|
|
47
64
|
|
|
48
65
|
/**
|
|
@@ -494,6 +511,7 @@ export const COMPANION_ALIAS_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
|
494
511
|
/** Companion Host 可跨 bridge 保留的稳定领域错误码。 */
|
|
495
512
|
export const COMPANION_ERROR_CODES = [
|
|
496
513
|
'COMPANION_UNSUPPORTED',
|
|
514
|
+
'COMPANION_PREVIEW_UNSUPPORTED',
|
|
497
515
|
'COMPANION_NOT_DECLARED',
|
|
498
516
|
'COMPANION_TARGET_UNSUPPORTED',
|
|
499
517
|
'COMPANION_NOT_PREPARED',
|
|
@@ -527,7 +545,7 @@ export interface CompanionInfo {
|
|
|
527
545
|
archiveBytes: number;
|
|
528
546
|
signatureStatus: CompanionSignatureStatus;
|
|
529
547
|
/** Host 确认的产物来源;旧 Host 缺省时来源未知。 */
|
|
530
|
-
source?: 'local-dev' | 'released';
|
|
548
|
+
source?: 'local-dev' | 'preview' | 'released';
|
|
531
549
|
}
|
|
532
550
|
|
|
533
551
|
export interface CompanionErrorSummary {
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** 由 scripts/generate-native-host-contract.mjs 生成,请勿手改。 */
|
|
2
|
+
export declare const MINI_PROGRAM_NATIVE_HOST_PROTOCOL_VERSION: 1;
|
|
3
|
+
export declare const MINI_PROGRAM_NATIVE_HOST_CONTRACT_REVISION: 1;
|
|
4
|
+
export declare const MINI_PROGRAM_NATIVE_CHUNK_MAX_BYTES: 65536;
|
|
5
|
+
export declare const MINI_PROGRAM_NATIVE_OPERATIONS: {
|
|
6
|
+
readonly system: readonly ["describe"];
|
|
7
|
+
readonly network: readonly ["open", "read", "release", "transfer"];
|
|
8
|
+
readonly files: readonly ["create", "remove", "exists", "openRead", "openWrite", "read", "release", "write", "stat", "list", "pickFiles", "pickDirectory", "saveFile"];
|
|
9
|
+
};
|
|
10
|
+
export declare const MINI_PROGRAM_NATIVE_HOST_DESCRIPTION: {
|
|
11
|
+
readonly protocolVersion: 1;
|
|
12
|
+
readonly contractRevision: 1;
|
|
13
|
+
readonly operations: {
|
|
14
|
+
readonly system: readonly ["describe"];
|
|
15
|
+
readonly network: readonly ["open", "read", "release", "transfer"];
|
|
16
|
+
readonly files: readonly ["create", "remove", "exists", "openRead", "openWrite", "read", "release", "write", "stat", "list", "pickFiles", "pickDirectory", "saveFile"];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export { MINI_PROGRAM_NATIVE_CHUNK_MAX_BYTES, MINI_PROGRAM_NATIVE_HOST_CONTRACT_REVISION, MINI_PROGRAM_NATIVE_HOST_DESCRIPTION, MINI_PROGRAM_NATIVE_HOST_PROTOCOL_VERSION, MINI_PROGRAM_NATIVE_OPERATIONS, } from './native-host-contract.generated';
|
|
2
|
+
/** Android WebMessageListener object 与 iOS WKScriptMessageHandler 共用名称。 */
|
|
3
|
+
export declare const MINI_PROGRAM_NATIVE_HOST_OBJECT: "hbMiniProgramHost";
|
|
4
|
+
/** Native 通过主文档 CustomEvent 回送 progress/result/error。 */
|
|
5
|
+
export declare const MINI_PROGRAM_NATIVE_HOST_MESSAGE_EVENT: "heybox:miniprogram-native-host-message";
|
|
6
|
+
export type MiniProgramNativeHostDomain = 'system' | 'network' | 'files';
|
|
7
|
+
/** H5 主文档发给 Native Host 的 operation 请求。 */
|
|
8
|
+
export interface MiniProgramNativeHostRequest {
|
|
9
|
+
requestId: string;
|
|
10
|
+
domain: MiniProgramNativeHostDomain;
|
|
11
|
+
operation: string;
|
|
12
|
+
payload?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** 取消独立引用原请求,重复取消必须是幂等操作。 */
|
|
15
|
+
export interface MiniProgramNativeHostCancel {
|
|
16
|
+
type: 'cancel';
|
|
17
|
+
requestId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface MiniProgramNativeHostError {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MiniProgramNativeHostDescription {
|
|
24
|
+
protocolVersion: number;
|
|
25
|
+
contractRevision: number;
|
|
26
|
+
operations: Readonly<Record<MiniProgramNativeHostDomain, readonly string[]>>;
|
|
27
|
+
}
|
|
28
|
+
export type MiniProgramNativeHostMessage = {
|
|
29
|
+
requestId: string;
|
|
30
|
+
type: 'progress';
|
|
31
|
+
payload: unknown;
|
|
32
|
+
} | {
|
|
33
|
+
requestId: string;
|
|
34
|
+
type: 'result';
|
|
35
|
+
payload?: unknown;
|
|
36
|
+
} | {
|
|
37
|
+
requestId: string;
|
|
38
|
+
type: 'error';
|
|
39
|
+
error: MiniProgramNativeHostError;
|
|
40
|
+
};
|
|
41
|
+
export interface MiniProgramNativeBinaryChunk {
|
|
42
|
+
resourceId: string;
|
|
43
|
+
data: string;
|
|
44
|
+
byteLength: number;
|
|
45
|
+
eof: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type MiniProgramNativeFileRef = {
|
|
48
|
+
scope: 'sandbox';
|
|
49
|
+
kind: 'file' | 'directory';
|
|
50
|
+
relativePath: string;
|
|
51
|
+
} | {
|
|
52
|
+
scope: 'grant';
|
|
53
|
+
id: string;
|
|
54
|
+
kind: 'file' | 'directory';
|
|
55
|
+
relativePath: string;
|
|
56
|
+
};
|
|
57
|
+
export interface MiniProgramNativeFileDescriptor {
|
|
58
|
+
kind: 'file' | 'directory';
|
|
59
|
+
mode: 'read' | 'readwrite';
|
|
60
|
+
name: string;
|
|
61
|
+
ref: MiniProgramNativeFileRef;
|
|
62
|
+
}
|
|
63
|
+
export interface MiniProgramNativeNetworkOpenPayload {
|
|
64
|
+
purpose: 'request' | 'download';
|
|
65
|
+
url: string;
|
|
66
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
67
|
+
params?: Record<string, unknown>;
|
|
68
|
+
data?: unknown;
|
|
69
|
+
headers?: Record<string, string>;
|
|
70
|
+
bodyEncoding?: 'json' | 'form';
|
|
71
|
+
timeoutMs: number;
|
|
72
|
+
}
|
|
73
|
+
export interface MiniProgramNativeNetworkOpenResult {
|
|
74
|
+
status: number;
|
|
75
|
+
statusText?: string;
|
|
76
|
+
headers: Record<string, string[]>;
|
|
77
|
+
resourceId: string;
|
|
78
|
+
}
|
|
79
|
+
export interface MiniProgramNativeNetworkReadPayload {
|
|
80
|
+
resourceId: string;
|
|
81
|
+
maxBytes: number;
|
|
82
|
+
}
|
|
83
|
+
export interface MiniProgramNativeNetworkReleasePayload {
|
|
84
|
+
resourceId: string;
|
|
85
|
+
}
|
|
86
|
+
export interface MiniProgramNativeNetworkTransferPayload {
|
|
87
|
+
resourceId: string;
|
|
88
|
+
target: MiniProgramNativeFileRef;
|
|
89
|
+
mode: 'replace-existing' | 'create-exclusive' | 'upsert';
|
|
90
|
+
maxBytes?: number;
|
|
91
|
+
expectedBytes?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface MiniProgramNativeNetworkTransferResult {
|
|
94
|
+
committedBytes: number;
|
|
95
|
+
}
|
|
96
|
+
export interface MiniProgramNativeFilesCreatePayload {
|
|
97
|
+
ref: MiniProgramNativeFileRef;
|
|
98
|
+
recursive: boolean;
|
|
99
|
+
exclusive: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface MiniProgramNativeFilesRemovePayload {
|
|
102
|
+
ref: MiniProgramNativeFileRef;
|
|
103
|
+
recursive?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface MiniProgramNativeFilesRefPayload {
|
|
106
|
+
ref: MiniProgramNativeFileRef;
|
|
107
|
+
}
|
|
108
|
+
export interface MiniProgramNativeFilesOpenPayload extends MiniProgramNativeFilesRefPayload {
|
|
109
|
+
maxBytes: number;
|
|
110
|
+
}
|
|
111
|
+
export interface MiniProgramNativeFilesOpenResult {
|
|
112
|
+
resourceId: string;
|
|
113
|
+
}
|
|
114
|
+
/** openWrite 后按序发送;eof=true 的最后一块触发 atomic commit。 */
|
|
115
|
+
export interface MiniProgramNativeFilesWritePayload extends MiniProgramNativeBinaryChunk {
|
|
116
|
+
}
|
|
117
|
+
export type MiniProgramNativeFilesStatResult = {
|
|
118
|
+
kind: 'file';
|
|
119
|
+
size: number;
|
|
120
|
+
modifiedAt?: number;
|
|
121
|
+
createdAt?: number;
|
|
122
|
+
} | {
|
|
123
|
+
kind: 'directory';
|
|
124
|
+
modifiedAt?: number;
|
|
125
|
+
createdAt?: number;
|
|
126
|
+
};
|
|
127
|
+
export interface MiniProgramNativeFilesListPayload extends MiniProgramNativeFilesRefPayload {
|
|
128
|
+
limit: number;
|
|
129
|
+
}
|
|
130
|
+
export interface MiniProgramNativeFilesPickFilesPayload {
|
|
131
|
+
mode: 'read' | 'readwrite';
|
|
132
|
+
accept?: string[];
|
|
133
|
+
multiple: boolean;
|
|
134
|
+
}
|
|
135
|
+
export interface MiniProgramNativeFilesPickDirectoryPayload {
|
|
136
|
+
mode: 'read' | 'readwrite';
|
|
137
|
+
}
|
|
138
|
+
export interface MiniProgramNativeFilesSaveFilePayload {
|
|
139
|
+
suggestedName: string;
|
|
140
|
+
}
|
|
141
|
+
export interface MiniProgramNativeTransferProgress {
|
|
142
|
+
resourceId: string;
|
|
143
|
+
loaded: number;
|
|
144
|
+
}
|
|
145
|
+
export declare function isMiniProgramNativeHostMessage(value: unknown): value is MiniProgramNativeHostMessage;
|
|
146
|
+
export declare function isMiniProgramNativeHostDescription(value: unknown): value is MiniProgramNativeHostDescription;
|
|
147
|
+
export declare function isMiniProgramNativeBinaryChunk(value: unknown): value is MiniProgramNativeBinaryChunk;
|
package/types/payloads.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** 当前用户信息与登录能力支持的完整 scope
|
|
2
|
-
export declare const USER_INFO_AUTHORIZATION_SCOPES: readonly ["identity", "profile"];
|
|
1
|
+
/** 当前用户信息与登录能力支持的完整 scope 目录(canonical 顺序)。 */
|
|
2
|
+
export declare const USER_INFO_AUTHORIZATION_SCOPES: readonly ["identity", "profile", "steam_account"];
|
|
3
3
|
/** 用户信息授权 scope。 */
|
|
4
4
|
export type UserInfoAuthorizationScope = (typeof USER_INFO_AUTHORIZATION_SCOPES)[number];
|
|
5
5
|
/** 登录请求使用与用户信息授权相同的 canonical scope。 */
|
|
@@ -14,9 +14,18 @@ export interface LoginResult {
|
|
|
14
14
|
}
|
|
15
15
|
/** 用户资料授权状态。 */
|
|
16
16
|
export type UserInfoAuthorizationStatus = 'not_required' | 'not_requested' | 'granted' | 'denied';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 当前小程序对 canonical 用户信息 scope 的授权状态。
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* `steam_account` 是可选键:新能力版本的 Runtime 必定返回,legacy Runtime/Version 可以
|
|
22
|
+
* 缺失。已授权不代表当前一定已绑定 Steam,只有 {@link AuthorizedUserInfo.steam_id}
|
|
23
|
+
* 存在才表示当前有主绑定。
|
|
24
|
+
*/
|
|
25
|
+
export interface UserInfoAuthorization {
|
|
26
|
+
identity: UserInfoAuthorizationStatus;
|
|
27
|
+
profile: UserInfoAuthorizationStatus;
|
|
28
|
+
steam_account?: UserInfoAuthorizationStatus;
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
31
|
* 已获准向当前小程序披露的用户资料。
|
|
@@ -43,6 +52,14 @@ export interface AuthorizedUserInfo {
|
|
|
43
52
|
nickname: string;
|
|
44
53
|
avatar: string;
|
|
45
54
|
} | null;
|
|
55
|
+
/**
|
|
56
|
+
* `steam_account` 已授权且当前已绑定 Steam 时返回 canonical SteamID64。
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* 始终表示为 string,禁止作为 JSON number 使用;未绑定时省略该字段,不返回空字符串或
|
|
60
|
+
* `null`。只返回主绑定 SteamID64,不包含 Steam 昵称、头像、好友码、公开状态或绑定来源。
|
|
61
|
+
*/
|
|
62
|
+
steam_id?: string;
|
|
46
63
|
}
|
|
47
64
|
/**
|
|
48
65
|
* 当前黑盒 APP 登录态、授权状态和已获准披露的用户资料。
|
|
@@ -468,7 +485,7 @@ export type CompanionSignatureStatus = 'unsigned' | 'valid' | 'invalid' | 'unkno
|
|
|
468
485
|
/** Companion alias 的跨构建、Runtime 与 Host 规范。 */
|
|
469
486
|
export declare const COMPANION_ALIAS_PATTERN: RegExp;
|
|
470
487
|
/** Companion Host 可跨 bridge 保留的稳定领域错误码。 */
|
|
471
|
-
export declare const COMPANION_ERROR_CODES: readonly ["COMPANION_UNSUPPORTED", "COMPANION_NOT_DECLARED", "COMPANION_TARGET_UNSUPPORTED", "COMPANION_NOT_PREPARED", "COMPANION_PREPARATION_CANCELLED", "COMPANION_DOWNLOAD_FAILED", "COMPANION_DESCRIPTOR_UNAVAILABLE", "COMPANION_ARCHIVE_INVALID", "COMPANION_INTEGRITY_FAILED", "COMPANION_ENTRYPOINT_INVALID", "COMPANION_USER_CANCELLED", "COMPANION_ELEVATION_DENIED", "COMPANION_OS_BLOCKED", "COMPANION_LAUNCH_FAILED", "COMPANION_SESSION_VERSION_MISMATCH", "COMPANION_SESSION_OWNERSHIP_LOST", "COMPANION_SESSION_EXITED", "COMPANION_PIPE_CLOSED", "COMPANION_OUTPUT_LIMIT", "COMPANION_PROCESS_CRASHED", "COMPANION_ATTACHMENT_NOT_FOUND", "COMPANION_NOTIFICATION_UNAVAILABLE", "COMPANION_TERMINATE_FAILED"];
|
|
488
|
+
export declare const COMPANION_ERROR_CODES: readonly ["COMPANION_UNSUPPORTED", "COMPANION_PREVIEW_UNSUPPORTED", "COMPANION_NOT_DECLARED", "COMPANION_TARGET_UNSUPPORTED", "COMPANION_NOT_PREPARED", "COMPANION_PREPARATION_CANCELLED", "COMPANION_DOWNLOAD_FAILED", "COMPANION_DESCRIPTOR_UNAVAILABLE", "COMPANION_ARCHIVE_INVALID", "COMPANION_INTEGRITY_FAILED", "COMPANION_ENTRYPOINT_INVALID", "COMPANION_USER_CANCELLED", "COMPANION_ELEVATION_DENIED", "COMPANION_OS_BLOCKED", "COMPANION_LAUNCH_FAILED", "COMPANION_SESSION_VERSION_MISMATCH", "COMPANION_SESSION_OWNERSHIP_LOST", "COMPANION_SESSION_EXITED", "COMPANION_PIPE_CLOSED", "COMPANION_OUTPUT_LIMIT", "COMPANION_PROCESS_CRASHED", "COMPANION_ATTACHMENT_NOT_FOUND", "COMPANION_NOTIFICATION_UNAVAILABLE", "COMPANION_TERMINATE_FAILED"];
|
|
472
489
|
export type CompanionErrorCode = (typeof COMPANION_ERROR_CODES)[number];
|
|
473
490
|
export interface CompanionInfo {
|
|
474
491
|
alias: string;
|
|
@@ -478,7 +495,7 @@ export interface CompanionInfo {
|
|
|
478
495
|
archiveBytes: number;
|
|
479
496
|
signatureStatus: CompanionSignatureStatus;
|
|
480
497
|
/** Host 确认的产物来源;旧 Host 缺省时来源未知。 */
|
|
481
|
-
source?: 'local-dev' | 'released';
|
|
498
|
+
source?: 'local-dev' | 'preview' | 'released';
|
|
482
499
|
}
|
|
483
500
|
export interface CompanionErrorSummary {
|
|
484
501
|
code: CompanionErrorCode;
|