@heybox/hb-sdk-protocol 0.8.0-alpha → 0.8.0-alpha.10
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 +3 -6
- package/dist/index.cjs.js +512 -37
- package/dist/index.esm.js +482 -38
- package/package.json +4 -1
- package/src/bridge.ts +21 -3
- package/src/capabilities.ts +294 -28
- package/src/constants.ts +1 -0
- package/src/guards.ts +161 -7
- package/src/index.ts +1 -0
- package/src/payloads.ts +174 -1
- package/src/permission-catalog.ts +168 -0
- package/src/permissions.ts +28 -10
- package/types/bridge.d.ts +19 -3
- package/types/capabilities.d.ts +291 -30
- package/types/constants.d.ts +1 -0
- package/types/guards.d.ts +11 -0
- package/types/index.d.ts +1 -0
- package/types/payloads.d.ts +144 -1
- package/types/permission-catalog.d.ts +108 -0
- package/types/permissions.d.ts +4 -3
package/types/capabilities.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ClosePayload, CloseResult, CopyLinkPayload, CopyLinkResult, DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, GetStoragePayload, GetStorageResult, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, GetWindowInfoPayload, GetWindowInfoResult, HideLoadingPayload, HideLoadingResult, LoginPayload, LoginResult, NetworkRequestPayload, NetworkResponsePayload, OpenAppPagePayload, OpenAppPageResult, ReloadPayload, ReloadResult, ScreenshotPayload, ScreenshotResult, SetClipboardPayload, SetClipboardResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, SetStoragePayload, ShowLoadingPayload, ShowLoadingResult, ShowShareMenuPayload, ShowShareMenuResult, ShowToastPayload, ShowToastResult, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, VibratePayload, VibrateResult } from './payloads';
|
|
1
|
+
import type { ClosePayload, CloseResult, CopyLinkPayload, CopyLinkResult, DirectoryCreatePayload, DirectoryCreateResult, DirectoryExistsPayload, DirectoryExistsResult, DirectoryListPayload, DirectoryListResult, DirectoryRemovePayload, DirectoryRemoveResult, DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, GetStoragePayload, GetStorageResult, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, GetWindowInfoPayload, GetWindowInfoResult, HideLoadingPayload, HideLoadingResult, FileCreatePayload, FileCreateResult, FileExistsPayload, FileExistsResult, FileReadBytesPayload, FileReadBytesResult, FileReadTextPayload, FileReadTextResult, FileRemovePayload, FileRemoveResult, FileStatPayload, FileStatResult, FileWriteBytesPayload, FileWriteBytesResult, FileWriteTextPayload, FileWriteTextResult, LoginPayload, LoginResult, NetworkDownloadPayload, NetworkDownloadResult, NetworkRequestPayload, NetworkResponsePayload, OpenAppPagePayload, OpenAppPageResult, PickDirectoryPayload, PickDirectoryResult, PickFilesPayload, PickFilesResult, ReloadPayload, ReloadResult, ScreenshotPayload, ScreenshotResult, SaveFilePayload, SaveFileResult, SetClipboardPayload, SetClipboardResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, SetStoragePayload, ShowLoadingPayload, ShowLoadingResult, ShowShareMenuPayload, ShowShareMenuResult, ShowToastPayload, ShowToastResult, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, VibratePayload, VibrateResult } from './payloads';
|
|
2
|
+
import type { MiniProgramPermissionRequirement } from './permission-catalog';
|
|
2
3
|
export declare const AUTH_LOGIN_METHOD: "auth.login";
|
|
3
4
|
export declare const USER_GET_INFO_METHOD: "user.getInfo";
|
|
4
5
|
export declare const USER_REVOKE_AUTHORIZATION_METHOD: "user.revokeAuthorization";
|
|
@@ -11,6 +12,22 @@ export declare const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD: "viewport.setNavi
|
|
|
11
12
|
export declare const STORAGE_GET_STORAGE_METHOD: "storage.getStorage";
|
|
12
13
|
export declare const STORAGE_SET_STORAGE_METHOD: "storage.setStorage";
|
|
13
14
|
export declare const NETWORK_REQUEST_METHOD: "network.request";
|
|
15
|
+
export declare const NETWORK_DOWNLOAD_METHOD: "network.download";
|
|
16
|
+
export declare const FILES_PICK_FILES_METHOD: "files.pickFiles";
|
|
17
|
+
export declare const FILES_PICK_DIRECTORY_METHOD: "files.pickDirectory";
|
|
18
|
+
export declare const FILES_SAVE_FILE_METHOD: "files.saveFile";
|
|
19
|
+
export declare const FILE_CREATE_METHOD: "file.create";
|
|
20
|
+
export declare const FILE_REMOVE_METHOD: "file.remove";
|
|
21
|
+
export declare const FILE_EXISTS_METHOD: "file.exists";
|
|
22
|
+
export declare const FILE_READ_TEXT_METHOD: "file.readText";
|
|
23
|
+
export declare const FILE_WRITE_TEXT_METHOD: "file.writeText";
|
|
24
|
+
export declare const FILE_READ_BYTES_METHOD: "file.readBytes";
|
|
25
|
+
export declare const FILE_WRITE_BYTES_METHOD: "file.writeBytes";
|
|
26
|
+
export declare const FILE_STAT_METHOD: "file.stat";
|
|
27
|
+
export declare const DIRECTORY_CREATE_METHOD: "directory.create";
|
|
28
|
+
export declare const DIRECTORY_REMOVE_METHOD: "directory.remove";
|
|
29
|
+
export declare const DIRECTORY_EXISTS_METHOD: "directory.exists";
|
|
30
|
+
export declare const DIRECTORY_LIST_METHOD: "directory.list";
|
|
14
31
|
export declare const UI_SHOW_TOAST_METHOD: "ui.showToast";
|
|
15
32
|
export declare const UI_SHOW_LOADING_METHOD: "ui.showLoading";
|
|
16
33
|
export declare const UI_HIDE_LOADING_METHOD: "ui.hideLoading";
|
|
@@ -29,170 +46,382 @@ export type MiniProgramUserMethod = typeof USER_GET_INFO_METHOD | typeof USER_RE
|
|
|
29
46
|
export type MiniProgramShareMethod = typeof SHARE_COPY_LINK_METHOD | typeof SHARE_SHOW_SHARE_MENU_METHOD | typeof SHARE_SCREENSHOT_METHOD;
|
|
30
47
|
export type MiniProgramViewportMethod = typeof VIEWPORT_GET_WINDOW_INFO_METHOD | typeof VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD;
|
|
31
48
|
export type MiniProgramStorageMethod = typeof STORAGE_GET_STORAGE_METHOD | typeof STORAGE_SET_STORAGE_METHOD;
|
|
32
|
-
export type MiniProgramNetworkMethod = typeof NETWORK_REQUEST_METHOD;
|
|
49
|
+
export type MiniProgramNetworkMethod = typeof NETWORK_REQUEST_METHOD | typeof NETWORK_DOWNLOAD_METHOD;
|
|
50
|
+
export type MiniProgramFilesMethod = typeof FILES_PICK_FILES_METHOD | typeof FILES_PICK_DIRECTORY_METHOD | typeof FILES_SAVE_FILE_METHOD;
|
|
51
|
+
export type MiniProgramFileMethod = typeof FILE_CREATE_METHOD | typeof FILE_REMOVE_METHOD | typeof FILE_EXISTS_METHOD | typeof FILE_READ_TEXT_METHOD | typeof FILE_WRITE_TEXT_METHOD | typeof FILE_READ_BYTES_METHOD | typeof FILE_WRITE_BYTES_METHOD | typeof FILE_STAT_METHOD;
|
|
52
|
+
export type MiniProgramDirectoryMethod = typeof DIRECTORY_CREATE_METHOD | typeof DIRECTORY_REMOVE_METHOD | typeof DIRECTORY_EXISTS_METHOD | typeof DIRECTORY_LIST_METHOD;
|
|
33
53
|
export type MiniProgramUiMethod = typeof UI_SHOW_TOAST_METHOD | typeof UI_SHOW_LOADING_METHOD | typeof UI_HIDE_LOADING_METHOD;
|
|
34
54
|
export type MiniProgramDeviceMethod = typeof DEVICE_VIBRATE_METHOD | typeof DEVICE_SET_CLIPBOARD_METHOD;
|
|
35
55
|
export type MiniProgramNavigationMethod = typeof NAVIGATION_CLOSE_METHOD | typeof NAVIGATION_RELOAD_METHOD | typeof NAVIGATION_OPEN_APP_PAGE_METHOD;
|
|
36
56
|
export type MiniProgramCloudMethod = typeof CLOUD_LEADERBOARD_SUBMIT_METHOD | typeof CLOUD_LEADERBOARD_GET_LIST_METHOD | typeof CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD | typeof CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD | typeof CLOUD_LEADERBOARD_GET_INFO_METHOD;
|
|
37
|
-
export type MiniProgramBridgeMethod = MiniProgramAuthMethod | MiniProgramUserMethod | MiniProgramShareMethod | MiniProgramViewportMethod | MiniProgramStorageMethod | MiniProgramNetworkMethod | MiniProgramUiMethod | MiniProgramDeviceMethod | MiniProgramNavigationMethod | MiniProgramCloudMethod;
|
|
38
|
-
export type MiniProgramCapabilityModule = 'auth' | 'user' | 'share' | 'viewport' | 'storage' | 'network' | 'ui' | 'device' | 'navigation' | 'cloud';
|
|
57
|
+
export type MiniProgramBridgeMethod = MiniProgramAuthMethod | MiniProgramUserMethod | MiniProgramShareMethod | MiniProgramViewportMethod | MiniProgramStorageMethod | MiniProgramNetworkMethod | MiniProgramFilesMethod | MiniProgramFileMethod | MiniProgramDirectoryMethod | MiniProgramUiMethod | MiniProgramDeviceMethod | MiniProgramNavigationMethod | MiniProgramCloudMethod;
|
|
58
|
+
export type MiniProgramCapabilityModule = 'auth' | 'user' | 'share' | 'viewport' | 'storage' | 'network' | 'files' | 'file' | 'directory' | 'ui' | 'device' | 'navigation' | 'cloud';
|
|
39
59
|
export type MiniProgramCapabilityRisk = 'low' | 'medium' | 'high';
|
|
40
60
|
export interface MiniProgramCapabilityDefinition {
|
|
41
61
|
method: MiniProgramBridgeMethod;
|
|
42
62
|
module: MiniProgramCapabilityModule;
|
|
43
63
|
capability: MiniProgramBridgeMethod;
|
|
44
|
-
|
|
64
|
+
requirement: MiniProgramPermissionRequirement;
|
|
45
65
|
risk: MiniProgramCapabilityRisk;
|
|
46
66
|
}
|
|
47
67
|
export declare const MINI_PROGRAM_PROTOCOL_CAPABILITIES: readonly [{
|
|
48
68
|
readonly method: "auth.login";
|
|
49
69
|
readonly module: "auth";
|
|
50
70
|
readonly capability: "auth.login";
|
|
51
|
-
readonly
|
|
71
|
+
readonly requirement: {
|
|
72
|
+
readonly kind: "all";
|
|
73
|
+
readonly permissions: readonly ["userInfo"];
|
|
74
|
+
};
|
|
52
75
|
readonly risk: "medium";
|
|
53
76
|
}, {
|
|
54
77
|
readonly method: "user.getInfo";
|
|
55
78
|
readonly module: "user";
|
|
56
79
|
readonly capability: "user.getInfo";
|
|
57
|
-
readonly
|
|
80
|
+
readonly requirement: {
|
|
81
|
+
readonly kind: "all";
|
|
82
|
+
readonly permissions: readonly ["userInfo"];
|
|
83
|
+
};
|
|
58
84
|
readonly risk: "medium";
|
|
59
85
|
}, {
|
|
60
86
|
readonly method: "user.revokeAuthorization";
|
|
61
87
|
readonly module: "user";
|
|
62
88
|
readonly capability: "user.revokeAuthorization";
|
|
63
|
-
readonly
|
|
89
|
+
readonly requirement: {
|
|
90
|
+
readonly kind: "none";
|
|
91
|
+
};
|
|
64
92
|
readonly risk: "high";
|
|
65
93
|
}, {
|
|
66
94
|
readonly method: "user.getSteamGameList";
|
|
67
95
|
readonly module: "user";
|
|
68
96
|
readonly capability: "user.getSteamGameList";
|
|
69
|
-
readonly
|
|
97
|
+
readonly requirement: {
|
|
98
|
+
readonly kind: "all";
|
|
99
|
+
readonly permissions: readonly ["steamLibrary"];
|
|
100
|
+
};
|
|
70
101
|
readonly risk: "high";
|
|
71
102
|
}, {
|
|
72
103
|
readonly method: "share.copyLink";
|
|
73
104
|
readonly module: "share";
|
|
74
105
|
readonly capability: "share.copyLink";
|
|
75
|
-
readonly
|
|
106
|
+
readonly requirement: {
|
|
107
|
+
readonly kind: "all";
|
|
108
|
+
readonly permissions: readonly ["share"];
|
|
109
|
+
};
|
|
76
110
|
readonly risk: "medium";
|
|
77
111
|
}, {
|
|
78
112
|
readonly method: "share.showShareMenu";
|
|
79
113
|
readonly module: "share";
|
|
80
114
|
readonly capability: "share.showShareMenu";
|
|
81
|
-
readonly
|
|
115
|
+
readonly requirement: {
|
|
116
|
+
readonly kind: "all";
|
|
117
|
+
readonly permissions: readonly ["share"];
|
|
118
|
+
};
|
|
82
119
|
readonly risk: "low";
|
|
83
120
|
}, {
|
|
84
121
|
readonly method: "share.screenshot";
|
|
85
122
|
readonly module: "share";
|
|
86
123
|
readonly capability: "share.screenshot";
|
|
87
|
-
readonly
|
|
124
|
+
readonly requirement: {
|
|
125
|
+
readonly kind: "all";
|
|
126
|
+
readonly permissions: readonly ["share"];
|
|
127
|
+
};
|
|
88
128
|
readonly risk: "medium";
|
|
89
129
|
}, {
|
|
90
130
|
readonly method: "viewport.getWindowInfo";
|
|
91
131
|
readonly module: "viewport";
|
|
92
132
|
readonly capability: "viewport.getWindowInfo";
|
|
93
|
-
readonly
|
|
133
|
+
readonly requirement: {
|
|
134
|
+
readonly kind: "none";
|
|
135
|
+
};
|
|
94
136
|
readonly risk: "low";
|
|
95
137
|
}, {
|
|
96
138
|
readonly method: "viewport.setNavigationBarStyle";
|
|
97
139
|
readonly module: "viewport";
|
|
98
140
|
readonly capability: "viewport.setNavigationBarStyle";
|
|
99
|
-
readonly
|
|
141
|
+
readonly requirement: {
|
|
142
|
+
readonly kind: "none";
|
|
143
|
+
};
|
|
100
144
|
readonly risk: "low";
|
|
101
145
|
}, {
|
|
102
146
|
readonly method: "storage.getStorage";
|
|
103
147
|
readonly module: "storage";
|
|
104
148
|
readonly capability: "storage.getStorage";
|
|
105
|
-
readonly
|
|
149
|
+
readonly requirement: {
|
|
150
|
+
readonly kind: "all";
|
|
151
|
+
readonly permissions: readonly ["storage"];
|
|
152
|
+
};
|
|
106
153
|
readonly risk: "low";
|
|
107
154
|
}, {
|
|
108
155
|
readonly method: "storage.setStorage";
|
|
109
156
|
readonly module: "storage";
|
|
110
157
|
readonly capability: "storage.setStorage";
|
|
111
|
-
readonly
|
|
158
|
+
readonly requirement: {
|
|
159
|
+
readonly kind: "all";
|
|
160
|
+
readonly permissions: readonly ["storage"];
|
|
161
|
+
};
|
|
112
162
|
readonly risk: "medium";
|
|
113
163
|
}, {
|
|
114
164
|
readonly method: "network.request";
|
|
115
165
|
readonly module: "network";
|
|
116
166
|
readonly capability: "network.request";
|
|
117
|
-
readonly
|
|
167
|
+
readonly requirement: {
|
|
168
|
+
readonly kind: "all";
|
|
169
|
+
readonly permissions: readonly ["network"];
|
|
170
|
+
};
|
|
171
|
+
readonly risk: "high";
|
|
172
|
+
}, {
|
|
173
|
+
readonly method: "network.download";
|
|
174
|
+
readonly module: "network";
|
|
175
|
+
readonly capability: "network.download";
|
|
176
|
+
readonly requirement: {
|
|
177
|
+
readonly kind: "all";
|
|
178
|
+
readonly permissions: readonly ["network", "filesystem"];
|
|
179
|
+
};
|
|
180
|
+
readonly risk: "high";
|
|
181
|
+
}, {
|
|
182
|
+
readonly method: "files.pickFiles";
|
|
183
|
+
readonly module: "files";
|
|
184
|
+
readonly capability: "files.pickFiles";
|
|
185
|
+
readonly requirement: {
|
|
186
|
+
readonly kind: "all";
|
|
187
|
+
readonly permissions: readonly ["filesystem"];
|
|
188
|
+
};
|
|
189
|
+
readonly risk: "high";
|
|
190
|
+
}, {
|
|
191
|
+
readonly method: "files.pickDirectory";
|
|
192
|
+
readonly module: "files";
|
|
193
|
+
readonly capability: "files.pickDirectory";
|
|
194
|
+
readonly requirement: {
|
|
195
|
+
readonly kind: "all";
|
|
196
|
+
readonly permissions: readonly ["filesystem"];
|
|
197
|
+
};
|
|
198
|
+
readonly risk: "high";
|
|
199
|
+
}, {
|
|
200
|
+
readonly method: "files.saveFile";
|
|
201
|
+
readonly module: "files";
|
|
202
|
+
readonly capability: "files.saveFile";
|
|
203
|
+
readonly requirement: {
|
|
204
|
+
readonly kind: "all";
|
|
205
|
+
readonly permissions: readonly ["filesystem"];
|
|
206
|
+
};
|
|
207
|
+
readonly risk: "high";
|
|
208
|
+
}, {
|
|
209
|
+
readonly method: "file.create";
|
|
210
|
+
readonly module: "file";
|
|
211
|
+
readonly capability: "file.create";
|
|
212
|
+
readonly requirement: {
|
|
213
|
+
readonly kind: "all";
|
|
214
|
+
readonly permissions: readonly ["filesystem"];
|
|
215
|
+
};
|
|
216
|
+
readonly risk: "high";
|
|
217
|
+
}, {
|
|
218
|
+
readonly method: "file.remove";
|
|
219
|
+
readonly module: "file";
|
|
220
|
+
readonly capability: "file.remove";
|
|
221
|
+
readonly requirement: {
|
|
222
|
+
readonly kind: "all";
|
|
223
|
+
readonly permissions: readonly ["filesystem"];
|
|
224
|
+
};
|
|
225
|
+
readonly risk: "high";
|
|
226
|
+
}, {
|
|
227
|
+
readonly method: "file.exists";
|
|
228
|
+
readonly module: "file";
|
|
229
|
+
readonly capability: "file.exists";
|
|
230
|
+
readonly requirement: {
|
|
231
|
+
readonly kind: "all";
|
|
232
|
+
readonly permissions: readonly ["filesystem"];
|
|
233
|
+
};
|
|
234
|
+
readonly risk: "high";
|
|
235
|
+
}, {
|
|
236
|
+
readonly method: "file.readText";
|
|
237
|
+
readonly module: "file";
|
|
238
|
+
readonly capability: "file.readText";
|
|
239
|
+
readonly requirement: {
|
|
240
|
+
readonly kind: "all";
|
|
241
|
+
readonly permissions: readonly ["filesystem"];
|
|
242
|
+
};
|
|
243
|
+
readonly risk: "high";
|
|
244
|
+
}, {
|
|
245
|
+
readonly method: "file.writeText";
|
|
246
|
+
readonly module: "file";
|
|
247
|
+
readonly capability: "file.writeText";
|
|
248
|
+
readonly requirement: {
|
|
249
|
+
readonly kind: "all";
|
|
250
|
+
readonly permissions: readonly ["filesystem"];
|
|
251
|
+
};
|
|
252
|
+
readonly risk: "high";
|
|
253
|
+
}, {
|
|
254
|
+
readonly method: "file.readBytes";
|
|
255
|
+
readonly module: "file";
|
|
256
|
+
readonly capability: "file.readBytes";
|
|
257
|
+
readonly requirement: {
|
|
258
|
+
readonly kind: "all";
|
|
259
|
+
readonly permissions: readonly ["filesystem"];
|
|
260
|
+
};
|
|
261
|
+
readonly risk: "high";
|
|
262
|
+
}, {
|
|
263
|
+
readonly method: "file.writeBytes";
|
|
264
|
+
readonly module: "file";
|
|
265
|
+
readonly capability: "file.writeBytes";
|
|
266
|
+
readonly requirement: {
|
|
267
|
+
readonly kind: "all";
|
|
268
|
+
readonly permissions: readonly ["filesystem"];
|
|
269
|
+
};
|
|
270
|
+
readonly risk: "high";
|
|
271
|
+
}, {
|
|
272
|
+
readonly method: "file.stat";
|
|
273
|
+
readonly module: "file";
|
|
274
|
+
readonly capability: "file.stat";
|
|
275
|
+
readonly requirement: {
|
|
276
|
+
readonly kind: "all";
|
|
277
|
+
readonly permissions: readonly ["filesystem"];
|
|
278
|
+
};
|
|
279
|
+
readonly risk: "high";
|
|
280
|
+
}, {
|
|
281
|
+
readonly method: "directory.create";
|
|
282
|
+
readonly module: "directory";
|
|
283
|
+
readonly capability: "directory.create";
|
|
284
|
+
readonly requirement: {
|
|
285
|
+
readonly kind: "all";
|
|
286
|
+
readonly permissions: readonly ["filesystem"];
|
|
287
|
+
};
|
|
288
|
+
readonly risk: "high";
|
|
289
|
+
}, {
|
|
290
|
+
readonly method: "directory.remove";
|
|
291
|
+
readonly module: "directory";
|
|
292
|
+
readonly capability: "directory.remove";
|
|
293
|
+
readonly requirement: {
|
|
294
|
+
readonly kind: "all";
|
|
295
|
+
readonly permissions: readonly ["filesystem"];
|
|
296
|
+
};
|
|
297
|
+
readonly risk: "high";
|
|
298
|
+
}, {
|
|
299
|
+
readonly method: "directory.exists";
|
|
300
|
+
readonly module: "directory";
|
|
301
|
+
readonly capability: "directory.exists";
|
|
302
|
+
readonly requirement: {
|
|
303
|
+
readonly kind: "all";
|
|
304
|
+
readonly permissions: readonly ["filesystem"];
|
|
305
|
+
};
|
|
306
|
+
readonly risk: "high";
|
|
307
|
+
}, {
|
|
308
|
+
readonly method: "directory.list";
|
|
309
|
+
readonly module: "directory";
|
|
310
|
+
readonly capability: "directory.list";
|
|
311
|
+
readonly requirement: {
|
|
312
|
+
readonly kind: "all";
|
|
313
|
+
readonly permissions: readonly ["filesystem"];
|
|
314
|
+
};
|
|
118
315
|
readonly risk: "high";
|
|
119
316
|
}, {
|
|
120
317
|
readonly method: "ui.showToast";
|
|
121
318
|
readonly module: "ui";
|
|
122
319
|
readonly capability: "ui.showToast";
|
|
123
|
-
readonly
|
|
320
|
+
readonly requirement: {
|
|
321
|
+
readonly kind: "none";
|
|
322
|
+
};
|
|
124
323
|
readonly risk: "low";
|
|
125
324
|
}, {
|
|
126
325
|
readonly method: "ui.showLoading";
|
|
127
326
|
readonly module: "ui";
|
|
128
327
|
readonly capability: "ui.showLoading";
|
|
129
|
-
readonly
|
|
328
|
+
readonly requirement: {
|
|
329
|
+
readonly kind: "none";
|
|
330
|
+
};
|
|
130
331
|
readonly risk: "low";
|
|
131
332
|
}, {
|
|
132
333
|
readonly method: "ui.hideLoading";
|
|
133
334
|
readonly module: "ui";
|
|
134
335
|
readonly capability: "ui.hideLoading";
|
|
135
|
-
readonly
|
|
336
|
+
readonly requirement: {
|
|
337
|
+
readonly kind: "none";
|
|
338
|
+
};
|
|
136
339
|
readonly risk: "low";
|
|
137
340
|
}, {
|
|
138
341
|
readonly method: "device.vibrate";
|
|
139
342
|
readonly module: "device";
|
|
140
343
|
readonly capability: "device.vibrate";
|
|
141
|
-
readonly
|
|
344
|
+
readonly requirement: {
|
|
345
|
+
readonly kind: "none";
|
|
346
|
+
};
|
|
142
347
|
readonly risk: "low";
|
|
143
348
|
}, {
|
|
144
349
|
readonly method: "device.setClipboard";
|
|
145
350
|
readonly module: "device";
|
|
146
351
|
readonly capability: "device.setClipboard";
|
|
147
|
-
readonly
|
|
352
|
+
readonly requirement: {
|
|
353
|
+
readonly kind: "all";
|
|
354
|
+
readonly permissions: readonly ["clipboard"];
|
|
355
|
+
};
|
|
148
356
|
readonly risk: "medium";
|
|
149
357
|
}, {
|
|
150
358
|
readonly method: "navigation.close";
|
|
151
359
|
readonly module: "navigation";
|
|
152
360
|
readonly capability: "navigation.close";
|
|
153
|
-
readonly
|
|
361
|
+
readonly requirement: {
|
|
362
|
+
readonly kind: "none";
|
|
363
|
+
};
|
|
154
364
|
readonly risk: "medium";
|
|
155
365
|
}, {
|
|
156
366
|
readonly method: "navigation.reload";
|
|
157
367
|
readonly module: "navigation";
|
|
158
368
|
readonly capability: "navigation.reload";
|
|
159
|
-
readonly
|
|
369
|
+
readonly requirement: {
|
|
370
|
+
readonly kind: "none";
|
|
371
|
+
};
|
|
160
372
|
readonly risk: "medium";
|
|
161
373
|
}, {
|
|
162
374
|
readonly method: "navigation.openAppPage";
|
|
163
375
|
readonly module: "navigation";
|
|
164
376
|
readonly capability: "navigation.openAppPage";
|
|
165
|
-
readonly
|
|
377
|
+
readonly requirement: {
|
|
378
|
+
readonly kind: "none";
|
|
379
|
+
};
|
|
166
380
|
readonly risk: "medium";
|
|
167
381
|
}, {
|
|
168
382
|
readonly method: "cloud.leaderboard.submit";
|
|
169
383
|
readonly module: "cloud";
|
|
170
384
|
readonly capability: "cloud.leaderboard.submit";
|
|
171
|
-
readonly
|
|
385
|
+
readonly requirement: {
|
|
386
|
+
readonly kind: "all";
|
|
387
|
+
readonly permissions: readonly ["leaderboard"];
|
|
388
|
+
};
|
|
172
389
|
readonly risk: "medium";
|
|
173
390
|
}, {
|
|
174
391
|
readonly method: "cloud.leaderboard.getList";
|
|
175
392
|
readonly module: "cloud";
|
|
176
393
|
readonly capability: "cloud.leaderboard.getList";
|
|
177
|
-
readonly
|
|
394
|
+
readonly requirement: {
|
|
395
|
+
readonly kind: "all";
|
|
396
|
+
readonly permissions: readonly ["leaderboard"];
|
|
397
|
+
};
|
|
178
398
|
readonly risk: "low";
|
|
179
399
|
}, {
|
|
180
400
|
readonly method: "cloud.leaderboard.getCurrentUserEntry";
|
|
181
401
|
readonly module: "cloud";
|
|
182
402
|
readonly capability: "cloud.leaderboard.getCurrentUserEntry";
|
|
183
|
-
readonly
|
|
403
|
+
readonly requirement: {
|
|
404
|
+
readonly kind: "all";
|
|
405
|
+
readonly permissions: readonly ["leaderboard"];
|
|
406
|
+
};
|
|
184
407
|
readonly risk: "medium";
|
|
185
408
|
}, {
|
|
186
409
|
readonly method: "cloud.leaderboard.deleteCurrentUserEntry";
|
|
187
410
|
readonly module: "cloud";
|
|
188
411
|
readonly capability: "cloud.leaderboard.deleteCurrentUserEntry";
|
|
189
|
-
readonly
|
|
412
|
+
readonly requirement: {
|
|
413
|
+
readonly kind: "all";
|
|
414
|
+
readonly permissions: readonly ["leaderboard"];
|
|
415
|
+
};
|
|
190
416
|
readonly risk: "medium";
|
|
191
417
|
}, {
|
|
192
418
|
readonly method: "cloud.leaderboard.getInfo";
|
|
193
419
|
readonly module: "cloud";
|
|
194
420
|
readonly capability: "cloud.leaderboard.getInfo";
|
|
195
|
-
readonly
|
|
421
|
+
readonly requirement: {
|
|
422
|
+
readonly kind: "all";
|
|
423
|
+
readonly permissions: readonly ["leaderboard"];
|
|
424
|
+
};
|
|
196
425
|
readonly risk: "low";
|
|
197
426
|
}];
|
|
198
427
|
export interface MiniProgramCapabilityPayloadMap {
|
|
@@ -208,6 +437,22 @@ export interface MiniProgramCapabilityPayloadMap {
|
|
|
208
437
|
[STORAGE_GET_STORAGE_METHOD]: GetStoragePayload;
|
|
209
438
|
[STORAGE_SET_STORAGE_METHOD]: SetStoragePayload;
|
|
210
439
|
[NETWORK_REQUEST_METHOD]: NetworkRequestPayload;
|
|
440
|
+
[NETWORK_DOWNLOAD_METHOD]: NetworkDownloadPayload;
|
|
441
|
+
[FILES_PICK_FILES_METHOD]: PickFilesPayload;
|
|
442
|
+
[FILES_PICK_DIRECTORY_METHOD]: PickDirectoryPayload;
|
|
443
|
+
[FILES_SAVE_FILE_METHOD]: SaveFilePayload;
|
|
444
|
+
[FILE_CREATE_METHOD]: FileCreatePayload;
|
|
445
|
+
[FILE_REMOVE_METHOD]: FileRemovePayload;
|
|
446
|
+
[FILE_EXISTS_METHOD]: FileExistsPayload;
|
|
447
|
+
[FILE_READ_TEXT_METHOD]: FileReadTextPayload;
|
|
448
|
+
[FILE_WRITE_TEXT_METHOD]: FileWriteTextPayload;
|
|
449
|
+
[FILE_READ_BYTES_METHOD]: FileReadBytesPayload;
|
|
450
|
+
[FILE_WRITE_BYTES_METHOD]: FileWriteBytesPayload;
|
|
451
|
+
[FILE_STAT_METHOD]: FileStatPayload;
|
|
452
|
+
[DIRECTORY_CREATE_METHOD]: DirectoryCreatePayload;
|
|
453
|
+
[DIRECTORY_REMOVE_METHOD]: DirectoryRemovePayload;
|
|
454
|
+
[DIRECTORY_EXISTS_METHOD]: DirectoryExistsPayload;
|
|
455
|
+
[DIRECTORY_LIST_METHOD]: DirectoryListPayload;
|
|
211
456
|
[UI_SHOW_TOAST_METHOD]: ShowToastPayload;
|
|
212
457
|
[UI_SHOW_LOADING_METHOD]: ShowLoadingPayload;
|
|
213
458
|
[UI_HIDE_LOADING_METHOD]: HideLoadingPayload;
|
|
@@ -235,6 +480,22 @@ export interface MiniProgramCapabilityResultMap {
|
|
|
235
480
|
[STORAGE_GET_STORAGE_METHOD]: GetStorageResult;
|
|
236
481
|
[STORAGE_SET_STORAGE_METHOD]: void;
|
|
237
482
|
[NETWORK_REQUEST_METHOD]: NetworkResponsePayload;
|
|
483
|
+
[NETWORK_DOWNLOAD_METHOD]: NetworkDownloadResult;
|
|
484
|
+
[FILES_PICK_FILES_METHOD]: PickFilesResult;
|
|
485
|
+
[FILES_PICK_DIRECTORY_METHOD]: PickDirectoryResult;
|
|
486
|
+
[FILES_SAVE_FILE_METHOD]: SaveFileResult;
|
|
487
|
+
[FILE_CREATE_METHOD]: FileCreateResult;
|
|
488
|
+
[FILE_REMOVE_METHOD]: FileRemoveResult;
|
|
489
|
+
[FILE_EXISTS_METHOD]: FileExistsResult;
|
|
490
|
+
[FILE_READ_TEXT_METHOD]: FileReadTextResult;
|
|
491
|
+
[FILE_WRITE_TEXT_METHOD]: FileWriteTextResult;
|
|
492
|
+
[FILE_READ_BYTES_METHOD]: FileReadBytesResult;
|
|
493
|
+
[FILE_WRITE_BYTES_METHOD]: FileWriteBytesResult;
|
|
494
|
+
[FILE_STAT_METHOD]: FileStatResult;
|
|
495
|
+
[DIRECTORY_CREATE_METHOD]: DirectoryCreateResult;
|
|
496
|
+
[DIRECTORY_REMOVE_METHOD]: DirectoryRemoveResult;
|
|
497
|
+
[DIRECTORY_EXISTS_METHOD]: DirectoryExistsResult;
|
|
498
|
+
[DIRECTORY_LIST_METHOD]: DirectoryListResult;
|
|
238
499
|
[UI_SHOW_TOAST_METHOD]: ShowToastResult;
|
|
239
500
|
[UI_SHOW_LOADING_METHOD]: ShowLoadingResult;
|
|
240
501
|
[UI_HIDE_LOADING_METHOD]: HideLoadingResult;
|
package/types/constants.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare const SDK_HANDSHAKE_METHOD: "sdk.handshake";
|
|
|
5
5
|
export declare const RUNTIME_LOCATION_PROBE_METHOD: "runtime.location.probe";
|
|
6
6
|
export declare const SDK_LOCATION_REPORT_METHOD: "sdk.location.report";
|
|
7
7
|
export declare const SDK_CSP_VIOLATION_METHOD: "sdk.csp.violation";
|
|
8
|
+
export declare const MINI_PROGRAM_OPERATION_PROGRESS_METHOD: "operation.progress";
|
package/types/guards.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { MiniProgramBridgeMessage } from './bridge';
|
|
2
|
+
import type { DownloadProgressPayload, MiniProgramDirectoryDescriptor, MiniProgramDirectoryRef, MiniProgramFileDescriptor, MiniProgramFileRef, MiniProgramFileStat, MiniProgramFileSystemEntityDescriptor, MiniProgramPathRootRef } from './payloads';
|
|
2
3
|
export declare function isMiniProgramBridgeMessage(value: unknown): value is MiniProgramBridgeMessage;
|
|
4
|
+
export declare function isMiniProgramRelativePath(value: unknown): value is string;
|
|
5
|
+
export declare function isMiniProgramPathRootRef(value: unknown): value is MiniProgramPathRootRef;
|
|
6
|
+
export declare function isMiniProgramFileRef(value: unknown): value is MiniProgramFileRef;
|
|
7
|
+
export declare function isMiniProgramDirectoryRef(value: unknown): value is MiniProgramDirectoryRef;
|
|
8
|
+
export declare function isMiniProgramFileDescriptor(value: unknown): value is MiniProgramFileDescriptor;
|
|
9
|
+
export declare function isMiniProgramDirectoryDescriptor(value: unknown): value is MiniProgramDirectoryDescriptor;
|
|
10
|
+
export declare function isMiniProgramFileSystemEntityDescriptor(value: unknown): value is MiniProgramFileSystemEntityDescriptor;
|
|
11
|
+
export declare function isMiniProgramByteArray(value: unknown): value is Uint8Array;
|
|
12
|
+
export declare function isMiniProgramFileStat(value: unknown): value is MiniProgramFileStat;
|
|
13
|
+
export declare function isMiniProgramDownloadProgressPayload(value: unknown): value is DownloadProgressPayload;
|
package/types/index.d.ts
CHANGED
package/types/payloads.d.ts
CHANGED
|
@@ -129,7 +129,6 @@ export interface MiniProgramScreenshotRect {
|
|
|
129
129
|
export type ShowShareMenuPayload = {
|
|
130
130
|
title: string;
|
|
131
131
|
desc: string;
|
|
132
|
-
url?: string;
|
|
133
132
|
extra?: unknown;
|
|
134
133
|
imageUrl?: string;
|
|
135
134
|
channel?: MiniProgramShareChannel;
|
|
@@ -200,6 +199,150 @@ export interface NetworkResponsePayload<T = unknown> {
|
|
|
200
199
|
statusText?: string;
|
|
201
200
|
headers: MiniProgramNetworkHeaders;
|
|
202
201
|
}
|
|
202
|
+
export type MiniProgramFileMode = 'read' | 'readwrite';
|
|
203
|
+
export interface MiniProgramSandboxRootRef {
|
|
204
|
+
kind: 'sandbox';
|
|
205
|
+
}
|
|
206
|
+
export interface MiniProgramDirectFileRef {
|
|
207
|
+
kind: 'file';
|
|
208
|
+
handleId: string;
|
|
209
|
+
}
|
|
210
|
+
export interface MiniProgramDirectDirectoryRef {
|
|
211
|
+
kind: 'directory';
|
|
212
|
+
handleId: string;
|
|
213
|
+
}
|
|
214
|
+
export type MiniProgramPathRootRef = MiniProgramSandboxRootRef | MiniProgramDirectDirectoryRef;
|
|
215
|
+
export interface MiniProgramDerivedFileRef {
|
|
216
|
+
kind: 'file';
|
|
217
|
+
root: MiniProgramPathRootRef;
|
|
218
|
+
relativePath: string;
|
|
219
|
+
}
|
|
220
|
+
export interface MiniProgramDerivedDirectoryRef {
|
|
221
|
+
kind: 'directory';
|
|
222
|
+
root: MiniProgramPathRootRef;
|
|
223
|
+
relativePath: string;
|
|
224
|
+
}
|
|
225
|
+
export type MiniProgramFileRef = MiniProgramDirectFileRef | MiniProgramDerivedFileRef;
|
|
226
|
+
export type MiniProgramDirectoryRef = MiniProgramDirectDirectoryRef | MiniProgramDerivedDirectoryRef;
|
|
227
|
+
export type MiniProgramFileSystemEntityRef = MiniProgramFileRef | MiniProgramDirectoryRef;
|
|
228
|
+
export interface MiniProgramFileDescriptor {
|
|
229
|
+
kind: 'file';
|
|
230
|
+
name: string;
|
|
231
|
+
mode: MiniProgramFileMode;
|
|
232
|
+
ref: MiniProgramFileRef;
|
|
233
|
+
}
|
|
234
|
+
export interface MiniProgramDirectoryDescriptor {
|
|
235
|
+
kind: 'directory';
|
|
236
|
+
name: string;
|
|
237
|
+
mode: MiniProgramFileMode;
|
|
238
|
+
ref: MiniProgramDirectoryRef;
|
|
239
|
+
}
|
|
240
|
+
export type MiniProgramFileSystemEntityDescriptor = MiniProgramFileDescriptor | MiniProgramDirectoryDescriptor;
|
|
241
|
+
export interface MiniProgramCreateOptions {
|
|
242
|
+
recursive?: boolean;
|
|
243
|
+
exclusive?: boolean;
|
|
244
|
+
}
|
|
245
|
+
export interface MiniProgramFileStat {
|
|
246
|
+
kind: 'file';
|
|
247
|
+
size: number;
|
|
248
|
+
modifiedAt?: number;
|
|
249
|
+
createdAt?: number;
|
|
250
|
+
}
|
|
251
|
+
export type PickFilesPayload = {
|
|
252
|
+
mode?: MiniProgramFileMode;
|
|
253
|
+
accept?: string[];
|
|
254
|
+
multiple?: boolean;
|
|
255
|
+
} | undefined;
|
|
256
|
+
export type PickFilesResult = Array<MiniProgramFileDescriptor & {
|
|
257
|
+
ref: MiniProgramDirectFileRef;
|
|
258
|
+
}>;
|
|
259
|
+
export type PickDirectoryPayload = {
|
|
260
|
+
mode?: MiniProgramFileMode;
|
|
261
|
+
} | undefined;
|
|
262
|
+
export type PickDirectoryResult = MiniProgramDirectoryDescriptor & {
|
|
263
|
+
ref: MiniProgramDirectDirectoryRef;
|
|
264
|
+
};
|
|
265
|
+
export interface SaveFilePayload {
|
|
266
|
+
suggestedName: string;
|
|
267
|
+
}
|
|
268
|
+
export type SaveFileResult = MiniProgramFileDescriptor & {
|
|
269
|
+
ref: MiniProgramDirectFileRef;
|
|
270
|
+
};
|
|
271
|
+
export interface FileCreatePayload extends MiniProgramCreateOptions {
|
|
272
|
+
target: MiniProgramFileRef;
|
|
273
|
+
}
|
|
274
|
+
export type FileCreateResult = void;
|
|
275
|
+
export interface FileRemovePayload {
|
|
276
|
+
target: MiniProgramFileRef;
|
|
277
|
+
}
|
|
278
|
+
export type FileRemoveResult = void;
|
|
279
|
+
export interface FileExistsPayload {
|
|
280
|
+
target: MiniProgramFileRef;
|
|
281
|
+
}
|
|
282
|
+
export type FileExistsResult = boolean;
|
|
283
|
+
export interface FileReadTextPayload {
|
|
284
|
+
target: MiniProgramFileRef;
|
|
285
|
+
}
|
|
286
|
+
export type FileReadTextResult = string;
|
|
287
|
+
export interface FileWriteTextPayload {
|
|
288
|
+
target: MiniProgramFileRef;
|
|
289
|
+
content: string;
|
|
290
|
+
}
|
|
291
|
+
export type FileWriteTextResult = void;
|
|
292
|
+
export interface FileReadBytesPayload {
|
|
293
|
+
target: MiniProgramFileRef;
|
|
294
|
+
}
|
|
295
|
+
export type FileReadBytesResult = Uint8Array;
|
|
296
|
+
export interface FileWriteBytesPayload {
|
|
297
|
+
target: MiniProgramFileRef;
|
|
298
|
+
content: Uint8Array;
|
|
299
|
+
}
|
|
300
|
+
export type FileWriteBytesResult = void;
|
|
301
|
+
export interface FileStatPayload {
|
|
302
|
+
target: MiniProgramFileRef;
|
|
303
|
+
}
|
|
304
|
+
export type FileStatResult = MiniProgramFileStat;
|
|
305
|
+
export interface DirectoryCreatePayload extends MiniProgramCreateOptions {
|
|
306
|
+
target: MiniProgramDirectoryRef;
|
|
307
|
+
}
|
|
308
|
+
export type DirectoryCreateResult = void;
|
|
309
|
+
export interface DirectoryRemovePayload {
|
|
310
|
+
target: MiniProgramDirectoryRef;
|
|
311
|
+
recursive?: boolean;
|
|
312
|
+
}
|
|
313
|
+
export type DirectoryRemoveResult = void;
|
|
314
|
+
export interface DirectoryExistsPayload {
|
|
315
|
+
target: MiniProgramDirectoryRef;
|
|
316
|
+
}
|
|
317
|
+
export type DirectoryExistsResult = boolean;
|
|
318
|
+
export interface DirectoryListPayload {
|
|
319
|
+
target: MiniProgramDirectoryRef;
|
|
320
|
+
limit?: number;
|
|
321
|
+
}
|
|
322
|
+
export type DirectoryListResult = MiniProgramFileSystemEntityDescriptor[];
|
|
323
|
+
export interface DownloadProgressPayload {
|
|
324
|
+
loaded: number;
|
|
325
|
+
total?: number;
|
|
326
|
+
lengthComputable: boolean;
|
|
327
|
+
}
|
|
328
|
+
interface NetworkDownloadBasePayload {
|
|
329
|
+
url: string;
|
|
330
|
+
params?: MiniProgramNetworkParams;
|
|
331
|
+
headers?: MiniProgramNetworkHeaders;
|
|
332
|
+
timeout?: number;
|
|
333
|
+
withCredentials?: boolean;
|
|
334
|
+
maxBytes?: number;
|
|
335
|
+
}
|
|
336
|
+
export type NetworkDownloadPayload = NetworkDownloadBasePayload & ({
|
|
337
|
+
to: MiniProgramFileRef;
|
|
338
|
+
suggestedName?: never;
|
|
339
|
+
overwrite?: never;
|
|
340
|
+
} | {
|
|
341
|
+
to: MiniProgramDirectoryRef;
|
|
342
|
+
suggestedName?: string;
|
|
343
|
+
overwrite?: boolean;
|
|
344
|
+
});
|
|
345
|
+
export type NetworkDownloadResult = MiniProgramFileDescriptor;
|
|
203
346
|
export type MiniProgramToastStatus = 'success' | 'error';
|
|
204
347
|
export interface ShowToastPayload {
|
|
205
348
|
message: string;
|