@heybox/hb-sdk 0.7.5-alpha.0 → 0.8.0-alpha.2
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/CHANGELOG.md +86 -0
- package/README.md +69 -16
- package/THIRD_PARTY_NOTICES.md +1755 -0
- package/dist/cli-chunks/{build-V1YBdpzY.cjs → build-CCLWgXyA.cjs} +6 -5
- package/dist/cli-chunks/{context-Ba1Je-wT.cjs → context-Brh56h56.cjs} +2 -27
- package/dist/cli-chunks/{create-CKGjqo9E.cjs → create-BZ-hi2s1.cjs} +1 -1
- package/dist/cli-chunks/{dev-XopYKLYZ.cjs → dev-CoSXtEYa.cjs} +336 -517
- package/dist/cli-chunks/{doctor-BHbrYQqT.cjs → doctor-EsCYJGhV.cjs} +1 -1
- package/dist/cli-chunks/{index-C9mpajVG.cjs → index-BL5eEPap.cjs} +14 -14
- package/dist/cli-chunks/{index-DKWfX6Ut.cjs → index-CS6Q0o5C.cjs} +2 -2
- package/dist/cli-chunks/{index.esm-SXAQ3WVR.cjs → index.esm-BoBHPfpq.cjs} +6 -6
- package/dist/cli-chunks/{login-BVWicWqe.cjs → login-CILLxGuf.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CBb38HJ3.cjs → project-vite-Qu6Xe9Dn.cjs} +1 -1
- package/dist/cli-chunks/{remote-BG1u0NKT.cjs → remote-DRuTQ51u.cjs} +10 -8
- package/dist/cli-chunks/{runtime-gate-CtV7rWyX.cjs → runtime-gate-DFjw66kF.cjs} +20 -1
- package/dist/cli-chunks/{runtime-permission-env-D-8_jPG3.cjs → runtime-permission-env-CjsCe5bp.cjs} +13 -13
- package/dist/cli-chunks/{session-CJS_SEp9.cjs → session-D-_N3WVL.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-uq-Wac6k.js +97 -0
- package/dist/devtools/browser-dev-host/assets/heybox-logo-CogNENsk.svg +6 -0
- package/dist/devtools/browser-dev-host/assets/index-CeP6SLB3.js +567 -0
- package/dist/devtools/browser-dev-host/assets/index-KD2f3Jdz.css +1 -0
- package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +5 -0
- package/dist/devtools/browser-dev-host/index.html +6 -435
- package/dist/index.cjs.js +1036 -90
- package/dist/index.esm.js +1036 -91
- package/dist/miniapp-publish.cjs.js +13 -13
- package/dist/miniapp-publish.esm.js +13 -13
- package/dist/protocol.cjs.js +208 -6
- package/dist/protocol.esm.js +182 -7
- package/dist/templates/vue3-vite-ts/README.md.ejs +2 -0
- package/dist/templates/vue3-vite-ts/vite.config.ts +1 -1
- package/dist/vite.cjs.js +31 -4
- package/dist/vite.esm.js +31 -5
- package/package.json +28 -11
- package/skill/SKILL.md +9 -5
- package/skill/references/api-protocol.md +111 -3
- package/skill/references/api-root.md +170 -22
- package/skill/references/cli.md +21 -17
- package/skill/references/examples.md +30 -1
- package/skill/references/recipes.md +105 -1
- package/skill/references/safety-boundaries.md +12 -1
- package/skill/scripts/sync-references.mjs +37 -3
- package/skill/skill.json +4 -4
- package/types/core/client.d.ts +17 -1
- package/types/core/errors.d.ts +5 -5
- package/types/core/sdk.d.ts +8 -5
- package/types/core/singleton.d.ts +59 -6
- package/types/index.d.ts +4 -2
- package/types/miniapp-manifest/schema.d.ts +5 -0
- package/types/miniapp-publish/index.d.ts +8 -8
- package/types/modules/auth/index.d.ts +15 -1
- package/types/modules/cloud/index.d.ts +75 -5
- package/types/modules/device/index.d.ts +31 -3
- package/types/modules/files/index.d.ts +5 -0
- package/types/modules/files/registry.d.ts +35 -0
- package/types/modules/files/types.d.ts +159 -0
- package/types/modules/navigation/index.d.ts +46 -4
- package/types/modules/network/index.d.ts +72 -14
- package/types/modules/share/copy-link.d.ts +3 -3
- package/types/modules/share/index.d.ts +61 -5
- package/types/modules/share/screenshot.d.ts +3 -3
- package/types/modules/share/show-share-menu.d.ts +3 -3
- package/types/modules/storage/index.d.ts +38 -10
- package/types/modules/ui/index.d.ts +46 -4
- package/types/modules/user/get-info.d.ts +1 -1
- package/types/modules/user/index.d.ts +46 -4
- package/types/modules/user/steam-game-list.d.ts +2 -2
- package/types/modules/viewport/index.d.ts +36 -8
- package/types/protocol/capabilities.d.ts +2 -2
- package/types/protocol/constants.d.ts +1 -1
- package/types/protocol/guards.d.ts +1 -1
- package/types/protocol/types.d.ts +1 -1
- package/types/protocol.d.ts +4 -3
- package/types/vite/index.d.ts +15 -7
- package/dist/devtools/browser-dev-host/main.js +0 -12158
|
@@ -81,15 +81,85 @@ export interface GetLeaderboardInfoResult {
|
|
|
81
81
|
}
|
|
82
82
|
/** 外部小程序可调用的云端排行榜模块。 */
|
|
83
83
|
export interface MiniProgramCloudLeaderboardModule {
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* 提交当前用户分数。
|
|
86
|
+
*
|
|
87
|
+
* @since 0.5.11
|
|
88
|
+
* @hbPlatform android
|
|
89
|
+
* @hbPlatform ios
|
|
90
|
+
* @hbPlatform ohos
|
|
91
|
+
* @hbPlatform windows
|
|
92
|
+
* @hbPlatform macos
|
|
93
|
+
* @hbClient android none
|
|
94
|
+
* @hbClient ios none
|
|
95
|
+
* @hbClient ohos none
|
|
96
|
+
* @hbClient windows none
|
|
97
|
+
* @hbClient macos none
|
|
98
|
+
*/
|
|
85
99
|
submit(options: SubmitLeaderboardEntryPayload): Promise<SubmitLeaderboardEntryResult>;
|
|
86
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* 读取排行榜列表。
|
|
102
|
+
*
|
|
103
|
+
* @since 0.5.11
|
|
104
|
+
* @hbPlatform android
|
|
105
|
+
* @hbPlatform ios
|
|
106
|
+
* @hbPlatform ohos
|
|
107
|
+
* @hbPlatform windows
|
|
108
|
+
* @hbPlatform macos
|
|
109
|
+
* @hbClient android none
|
|
110
|
+
* @hbClient ios none
|
|
111
|
+
* @hbClient ohos none
|
|
112
|
+
* @hbClient windows none
|
|
113
|
+
* @hbClient macos none
|
|
114
|
+
*/
|
|
87
115
|
getList(options?: GetLeaderboardListPayload): Promise<GetLeaderboardListResult>;
|
|
88
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* 读取当前用户记录。
|
|
118
|
+
*
|
|
119
|
+
* @since 0.5.11
|
|
120
|
+
* @hbPlatform android
|
|
121
|
+
* @hbPlatform ios
|
|
122
|
+
* @hbPlatform ohos
|
|
123
|
+
* @hbPlatform windows
|
|
124
|
+
* @hbPlatform macos
|
|
125
|
+
* @hbClient android none
|
|
126
|
+
* @hbClient ios none
|
|
127
|
+
* @hbClient ohos none
|
|
128
|
+
* @hbClient windows none
|
|
129
|
+
* @hbClient macos none
|
|
130
|
+
*/
|
|
89
131
|
getCurrentUserEntry(options?: GetCurrentUserLeaderboardEntryPayload): Promise<GetCurrentUserLeaderboardEntryResult>;
|
|
90
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* 删除当前用户记录。
|
|
134
|
+
*
|
|
135
|
+
* @since 0.5.11
|
|
136
|
+
* @hbPlatform android
|
|
137
|
+
* @hbPlatform ios
|
|
138
|
+
* @hbPlatform ohos
|
|
139
|
+
* @hbPlatform windows
|
|
140
|
+
* @hbPlatform macos
|
|
141
|
+
* @hbClient android none
|
|
142
|
+
* @hbClient ios none
|
|
143
|
+
* @hbClient ohos none
|
|
144
|
+
* @hbClient windows none
|
|
145
|
+
* @hbClient macos none
|
|
146
|
+
*/
|
|
91
147
|
deleteCurrentUserEntry(options?: DeleteCurrentUserLeaderboardEntryPayload): Promise<DeleteCurrentUserLeaderboardEntryResult>;
|
|
92
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* 读取排行榜基础信息。
|
|
150
|
+
*
|
|
151
|
+
* @since 0.5.11
|
|
152
|
+
* @hbPlatform android
|
|
153
|
+
* @hbPlatform ios
|
|
154
|
+
* @hbPlatform ohos
|
|
155
|
+
* @hbPlatform windows
|
|
156
|
+
* @hbPlatform macos
|
|
157
|
+
* @hbClient android none
|
|
158
|
+
* @hbClient ios none
|
|
159
|
+
* @hbClient ohos none
|
|
160
|
+
* @hbClient windows none
|
|
161
|
+
* @hbClient macos none
|
|
162
|
+
*/
|
|
93
163
|
getInfo(options?: GetLeaderboardInfoPayload): Promise<GetLeaderboardInfoResult>;
|
|
94
164
|
}
|
|
95
165
|
/** 外部小程序可调用的云端能力模块。 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
export { DEVICE_SET_CLIPBOARD_METHOD, DEVICE_VIBRATE_METHOD
|
|
2
|
+
export { DEVICE_SET_CLIPBOARD_METHOD, DEVICE_VIBRATE_METHOD } from '../../protocol/capabilities';
|
|
3
3
|
/** 震动强度。 */
|
|
4
4
|
export type MiniProgramVibrateIntensity = 'light' | 'medium' | 'heavy';
|
|
5
5
|
/** `device.vibrate` 入参。 */
|
|
@@ -21,9 +21,37 @@ export type SetClipboardResult = void;
|
|
|
21
21
|
export type { MiniProgramDeviceMethod } from '../../protocol/capabilities';
|
|
22
22
|
/** 外部小程序可调用的 device 模块。 */
|
|
23
23
|
export interface MiniProgramDeviceModule {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* 触发宿主震动反馈。
|
|
26
|
+
*
|
|
27
|
+
* @since 0.4.4
|
|
28
|
+
* @hbPlatform android
|
|
29
|
+
* @hbPlatform ios
|
|
30
|
+
* @hbPlatform ohos
|
|
31
|
+
* @hbPlatform windows
|
|
32
|
+
* @hbPlatform macos
|
|
33
|
+
* @hbClient android none
|
|
34
|
+
* @hbClient ios none
|
|
35
|
+
* @hbClient ohos none
|
|
36
|
+
* @hbClient windows none
|
|
37
|
+
* @hbClient macos none
|
|
38
|
+
*/
|
|
25
39
|
vibrate(options?: VibratePayload): Promise<void>;
|
|
26
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 写入系统文本剪贴板。
|
|
42
|
+
*
|
|
43
|
+
* @since 0.4.4
|
|
44
|
+
* @hbPlatform android
|
|
45
|
+
* @hbPlatform ios
|
|
46
|
+
* @hbPlatform ohos
|
|
47
|
+
* @hbPlatform windows
|
|
48
|
+
* @hbPlatform macos
|
|
49
|
+
* @hbClient android none
|
|
50
|
+
* @hbClient ios none
|
|
51
|
+
* @hbClient ohos none
|
|
52
|
+
* @hbClient windows none
|
|
53
|
+
* @hbClient macos none
|
|
54
|
+
*/
|
|
27
55
|
setClipboard(options: SetClipboardPayload): Promise<void>;
|
|
28
56
|
}
|
|
29
57
|
/** 触发宿主震动反馈。 */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
+
import type { FilesModule } from './types';
|
|
3
|
+
export type { CreateOptions, DirectoryHandle, FileHandle, FileMode, FileStat, FileSystem, FileSystemEntity, FilesModule, ListOptions, PathRoot, PickDirectoryOptions, PickFilesOptions, RemoveOptions, SaveFileOptions, } from './types';
|
|
4
|
+
/** 创建当前 SDK session 的 files 模块。 */
|
|
5
|
+
export declare function createFilesModule(requester: MiniProgramRequester): FilesModule;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
+
import type { MiniProgramDirectoryDescriptor, MiniProgramDirectoryRef, MiniProgramFileDescriptor, MiniProgramFileMode, MiniProgramFileRef, MiniProgramFileSystemEntityDescriptor } from '@heybox/hb-sdk-protocol';
|
|
3
|
+
import type { DirectoryHandle, FileHandle, FileSystem, FileSystemEntity } from './types';
|
|
4
|
+
interface FileHandleState {
|
|
5
|
+
ref: MiniProgramFileRef;
|
|
6
|
+
mode: MiniProgramFileMode;
|
|
7
|
+
}
|
|
8
|
+
interface DirectoryHandleState {
|
|
9
|
+
ref: MiniProgramDirectoryRef;
|
|
10
|
+
mode: MiniProgramFileMode;
|
|
11
|
+
}
|
|
12
|
+
/** 校验并返回平台无关的 `/` 分隔逻辑相对路径。 */
|
|
13
|
+
export declare function normalizeRelativePath(value: unknown): string;
|
|
14
|
+
export declare class MiniProgramFileHandleRegistry {
|
|
15
|
+
private readonly requester;
|
|
16
|
+
private readonly fileStates;
|
|
17
|
+
private readonly directoryStates;
|
|
18
|
+
private readonly pathRootStates;
|
|
19
|
+
private sandboxRoot?;
|
|
20
|
+
constructor(requester: MiniProgramRequester);
|
|
21
|
+
getSandbox(): FileSystem;
|
|
22
|
+
createFile(descriptor: MiniProgramFileDescriptor): FileHandle;
|
|
23
|
+
createDirectFile(descriptor: MiniProgramFileDescriptor): FileHandle;
|
|
24
|
+
createDirectory(descriptor: MiniProgramDirectoryDescriptor): DirectoryHandle;
|
|
25
|
+
createDirectDirectory(descriptor: MiniProgramDirectoryDescriptor): DirectoryHandle;
|
|
26
|
+
createEntity(descriptor: MiniProgramFileSystemEntityDescriptor): FileSystemEntity;
|
|
27
|
+
requireFile(handle: unknown): FileHandleState;
|
|
28
|
+
requireDirectory(handle: unknown): DirectoryHandleState;
|
|
29
|
+
private definePathRootMethods;
|
|
30
|
+
private assertFileDescriptor;
|
|
31
|
+
private assertDirectoryDescriptor;
|
|
32
|
+
}
|
|
33
|
+
export declare function getFileHandleRegistry(requester: MiniProgramRequester): MiniProgramFileHandleRegistry;
|
|
34
|
+
export declare function isMiniProgramFileSystemValue(value: unknown): value is FileSystem | FileSystemEntity;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** File/Directory 访问模式。 */
|
|
2
|
+
export type FileMode = 'read' | 'readwrite';
|
|
3
|
+
export interface PickFilesOptions {
|
|
4
|
+
mode?: FileMode;
|
|
5
|
+
accept?: string[];
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PickDirectoryOptions {
|
|
9
|
+
mode?: FileMode;
|
|
10
|
+
}
|
|
11
|
+
export interface SaveFileOptions {
|
|
12
|
+
suggestedName: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateOptions {
|
|
15
|
+
recursive?: boolean;
|
|
16
|
+
exclusive?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface RemoveOptions {
|
|
19
|
+
/** 是否递归删除目录内容,默认 `false`。 */
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ListOptions {
|
|
23
|
+
limit?: number;
|
|
24
|
+
}
|
|
25
|
+
/** 可同步派生 lazy File/Directory proxy 的逻辑根。 */
|
|
26
|
+
export interface PathRoot {
|
|
27
|
+
/**
|
|
28
|
+
* 按规范相对路径派生文件代理。
|
|
29
|
+
*
|
|
30
|
+
* @param relativePath - 使用 `/` 分隔的规范相对路径。
|
|
31
|
+
* @returns 延迟访问对应文件的代理。
|
|
32
|
+
* @since 0.8.0-alpha.2
|
|
33
|
+
* @hbPlatform android
|
|
34
|
+
* @hbPlatform ios
|
|
35
|
+
* @hbPlatform ohos
|
|
36
|
+
* @hbPlatform windows
|
|
37
|
+
* @hbPlatform macos
|
|
38
|
+
* @hbClient android none
|
|
39
|
+
* @hbClient ios none
|
|
40
|
+
* @hbClient ohos none
|
|
41
|
+
* @hbClient windows none
|
|
42
|
+
* @hbClient macos none
|
|
43
|
+
*/
|
|
44
|
+
file(relativePath: string): FileHandle;
|
|
45
|
+
/**
|
|
46
|
+
* 按规范相对路径派生目录代理。
|
|
47
|
+
*
|
|
48
|
+
* @param relativePath - 使用 `/` 分隔的规范相对路径。
|
|
49
|
+
* @returns 延迟访问对应目录的代理。
|
|
50
|
+
* @since 0.8.0-alpha.2
|
|
51
|
+
* @hbPlatform android
|
|
52
|
+
* @hbPlatform ios
|
|
53
|
+
* @hbPlatform ohos
|
|
54
|
+
* @hbPlatform windows
|
|
55
|
+
* @hbPlatform macos
|
|
56
|
+
* @hbClient android none
|
|
57
|
+
* @hbClient ios none
|
|
58
|
+
* @hbClient ohos none
|
|
59
|
+
* @hbClient windows none
|
|
60
|
+
* @hbClient macos none
|
|
61
|
+
*/
|
|
62
|
+
directory(relativePath: string): DirectoryHandle;
|
|
63
|
+
}
|
|
64
|
+
/** Mini-program 私有 sandbox 的逻辑根。 */
|
|
65
|
+
export interface FileSystem extends PathRoot {
|
|
66
|
+
}
|
|
67
|
+
/** 当前 SDK session 中的文件代理。 */
|
|
68
|
+
export interface FileHandle {
|
|
69
|
+
readonly kind: 'file';
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly mode: FileMode;
|
|
72
|
+
create(options?: CreateOptions): Promise<FileHandle>;
|
|
73
|
+
/** 删除 sandbox 文件;外部授权文件不允许删除。 */
|
|
74
|
+
remove(): Promise<void>;
|
|
75
|
+
exists(): Promise<boolean>;
|
|
76
|
+
readText(): Promise<string>;
|
|
77
|
+
writeText(content: string): Promise<void>;
|
|
78
|
+
readBytes(): Promise<Uint8Array>;
|
|
79
|
+
writeBytes(content: Uint8Array): Promise<void>;
|
|
80
|
+
stat(): Promise<FileStat>;
|
|
81
|
+
}
|
|
82
|
+
/** 当前 SDK session 中的目录代理。 */
|
|
83
|
+
export interface DirectoryHandle extends PathRoot {
|
|
84
|
+
readonly kind: 'directory';
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly mode: FileMode;
|
|
87
|
+
create(options?: CreateOptions): Promise<DirectoryHandle>;
|
|
88
|
+
/** 删除 sandbox 目录;非空目录需要显式设置 `recursive`,外部授权目录不允许删除。 */
|
|
89
|
+
remove(options?: RemoveOptions): Promise<void>;
|
|
90
|
+
exists(): Promise<boolean>;
|
|
91
|
+
list(options?: ListOptions): Promise<FileSystemEntity[]>;
|
|
92
|
+
}
|
|
93
|
+
export type FileSystemEntity = FileHandle | DirectoryHandle;
|
|
94
|
+
export interface FileStat {
|
|
95
|
+
kind: 'file';
|
|
96
|
+
size: number;
|
|
97
|
+
/** Unix epoch milliseconds。 */
|
|
98
|
+
modifiedAt?: number;
|
|
99
|
+
/** Unix epoch milliseconds。 */
|
|
100
|
+
createdAt?: number;
|
|
101
|
+
}
|
|
102
|
+
/** Mini-program 对外文件能力。 */
|
|
103
|
+
export interface FilesModule {
|
|
104
|
+
readonly sandbox: FileSystem;
|
|
105
|
+
/**
|
|
106
|
+
* 让用户选择一个或多个文件并返回当前 session 的授权代理。
|
|
107
|
+
*
|
|
108
|
+
* @param options - 访问模式、扩展名筛选与多选设置。
|
|
109
|
+
* @returns 用户选择的文件代理。
|
|
110
|
+
* @since 0.8.0-alpha.2
|
|
111
|
+
* @hbPlatform android
|
|
112
|
+
* @hbPlatform ios
|
|
113
|
+
* @hbPlatform ohos
|
|
114
|
+
* @hbPlatform windows
|
|
115
|
+
* @hbPlatform macos
|
|
116
|
+
* @hbClient android none
|
|
117
|
+
* @hbClient ios none
|
|
118
|
+
* @hbClient ohos none
|
|
119
|
+
* @hbClient windows none
|
|
120
|
+
* @hbClient macos none
|
|
121
|
+
*/
|
|
122
|
+
pickFiles(options?: PickFilesOptions): Promise<FileHandle[]>;
|
|
123
|
+
/**
|
|
124
|
+
* 让用户选择目录并返回当前 session 的授权代理。
|
|
125
|
+
*
|
|
126
|
+
* @param options - 目录访问模式。
|
|
127
|
+
* @returns 用户选择的目录代理。
|
|
128
|
+
* @since 0.8.0-alpha.2
|
|
129
|
+
* @hbPlatform android
|
|
130
|
+
* @hbPlatform ios
|
|
131
|
+
* @hbPlatform ohos
|
|
132
|
+
* @hbPlatform windows
|
|
133
|
+
* @hbPlatform macos
|
|
134
|
+
* @hbClient android none
|
|
135
|
+
* @hbClient ios none
|
|
136
|
+
* @hbClient ohos none
|
|
137
|
+
* @hbClient windows none
|
|
138
|
+
* @hbClient macos none
|
|
139
|
+
*/
|
|
140
|
+
pickDirectory(options?: PickDirectoryOptions): Promise<DirectoryHandle>;
|
|
141
|
+
/**
|
|
142
|
+
* 让用户选择一个精确的文件保存目标。
|
|
143
|
+
*
|
|
144
|
+
* @param options - 建议文件名。
|
|
145
|
+
* @returns 具备读写权限的目标文件代理。
|
|
146
|
+
* @since 0.8.0-alpha.2
|
|
147
|
+
* @hbPlatform android
|
|
148
|
+
* @hbPlatform ios
|
|
149
|
+
* @hbPlatform ohos
|
|
150
|
+
* @hbPlatform windows
|
|
151
|
+
* @hbPlatform macos
|
|
152
|
+
* @hbClient android none
|
|
153
|
+
* @hbClient ios none
|
|
154
|
+
* @hbClient ohos none
|
|
155
|
+
* @hbClient windows none
|
|
156
|
+
* @hbClient macos none
|
|
157
|
+
*/
|
|
158
|
+
saveFile(options: SaveFileOptions): Promise<FileHandle>;
|
|
159
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
2
|
import { type OpenAppPageOptions } from './app-pages';
|
|
3
|
-
export { NAVIGATION_CLOSE_METHOD, NAVIGATION_OPEN_APP_PAGE_METHOD, NAVIGATION_RELOAD_METHOD
|
|
3
|
+
export { NAVIGATION_CLOSE_METHOD, NAVIGATION_OPEN_APP_PAGE_METHOD, NAVIGATION_RELOAD_METHOD } from '../../protocol/capabilities';
|
|
4
4
|
export type { MiniProgramAppPageTarget, MiniProgramGameDetailGameType, MiniProgramGameDetailPage, OpenAppPageOptions, OpenAppPagePayload, OpenAppPageResult, OpenGameDetailAppPagePayload, OpenGameDetailAppPageOptions, OpenPostDetailAppPagePayload, OpenPostDetailAppPageOptions, OpenUserDetailAppPagePayload, OpenUserDetailAppPageOptions, } from './app-pages';
|
|
5
5
|
/** `navigation.close` 不需要入参。 */
|
|
6
6
|
export type ClosePayload = void;
|
|
@@ -13,11 +13,53 @@ export type ReloadResult = void;
|
|
|
13
13
|
export type { MiniProgramNavigationMethod } from '../../protocol/capabilities';
|
|
14
14
|
/** 外部小程序可调用的 navigation 模块。 */
|
|
15
15
|
export interface MiniProgramNavigationModule {
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* 请求宿主关闭当前小程序容器。
|
|
18
|
+
*
|
|
19
|
+
* @since 0.4.4
|
|
20
|
+
* @hbPlatform android
|
|
21
|
+
* @hbPlatform ios
|
|
22
|
+
* @hbPlatform ohos
|
|
23
|
+
* @hbPlatform windows
|
|
24
|
+
* @hbPlatform macos
|
|
25
|
+
* @hbClient android none
|
|
26
|
+
* @hbClient ios none
|
|
27
|
+
* @hbClient ohos none
|
|
28
|
+
* @hbClient windows none
|
|
29
|
+
* @hbClient macos none
|
|
30
|
+
*/
|
|
17
31
|
close(): Promise<void>;
|
|
18
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* 请求宿主重载当前小程序容器。
|
|
34
|
+
*
|
|
35
|
+
* @since 0.4.4
|
|
36
|
+
* @hbPlatform android
|
|
37
|
+
* @hbPlatform ios
|
|
38
|
+
* @hbPlatform ohos
|
|
39
|
+
* @hbPlatform windows
|
|
40
|
+
* @hbPlatform macos
|
|
41
|
+
* @hbClient android none
|
|
42
|
+
* @hbClient ios none
|
|
43
|
+
* @hbClient ohos none
|
|
44
|
+
* @hbClient windows none
|
|
45
|
+
* @hbClient macos none
|
|
46
|
+
*/
|
|
19
47
|
reload(): Promise<void>;
|
|
20
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* 请求宿主打开受 SDK 白名单约束的黑盒 App 页面。
|
|
50
|
+
*
|
|
51
|
+
* @since 0.5.2
|
|
52
|
+
* @hbPlatform android
|
|
53
|
+
* @hbPlatform ios
|
|
54
|
+
* @hbPlatform ohos
|
|
55
|
+
* @hbPlatform windows
|
|
56
|
+
* @hbPlatform macos
|
|
57
|
+
* @hbClient android none
|
|
58
|
+
* @hbClient ios none
|
|
59
|
+
* @hbClient ohos none
|
|
60
|
+
* @hbClient windows none
|
|
61
|
+
* @hbClient macos none
|
|
62
|
+
*/
|
|
21
63
|
openAppPage(options: OpenAppPageOptions): Promise<void>;
|
|
22
64
|
}
|
|
23
65
|
/** 请求宿主关闭当前小程序容器。 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
|
|
1
|
+
import type { MiniProgramOperationRequester, MiniProgramRequester } from '../../core/client';
|
|
2
|
+
import type { DirectoryHandle, FileHandle } from '../files';
|
|
3
|
+
export { NETWORK_DOWNLOAD_METHOD, NETWORK_REQUEST_METHOD } from '../../protocol/capabilities';
|
|
3
4
|
export { createNetworkRequestFailureLog, formatNetworkRequestFailureMessage, logNetworkRequestFailure, previewNetworkData, sanitizeNetworkHeaders, sanitizeNetworkRequestUrl, } from './observability';
|
|
4
5
|
export { describeHostNetworkFailure, isMultipartContentType, isUnsupportedMultipartNetworkRequest, looksLikeMultipartBody, NETWORK_REQUEST_MULTIPART_UNSUPPORTED_MESSAGE, readNetworkContentType, } from './request-shape';
|
|
5
6
|
/** `network.request` 请求头。 */
|
|
@@ -11,7 +12,7 @@ export type MiniProgramNetworkRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' |
|
|
|
11
12
|
/**
|
|
12
13
|
* SDK 侧可配置的状态校验函数。
|
|
13
14
|
*
|
|
14
|
-
* @param status 标准化后的 HTTP 状态码。
|
|
15
|
+
* @param status - 标准化后的 HTTP 状态码。
|
|
15
16
|
* @returns 返回 `true` 时表示本次响应应视为成功。
|
|
16
17
|
*
|
|
17
18
|
* @remarks
|
|
@@ -42,6 +43,32 @@ export interface MiniProgramNetworkRequestConfig {
|
|
|
42
43
|
/** SDK 侧状态校验;不会跨 bridge 传输函数值。 */
|
|
43
44
|
validateStatus?: MiniProgramNetworkValidateStatus;
|
|
44
45
|
}
|
|
46
|
+
/** 流式下载的 request-scoped 进度。 */
|
|
47
|
+
export interface DownloadProgress {
|
|
48
|
+
loaded: number;
|
|
49
|
+
total?: number;
|
|
50
|
+
lengthComputable: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface DownloadBaseOptions {
|
|
53
|
+
url: string;
|
|
54
|
+
params?: MiniProgramNetworkParams;
|
|
55
|
+
headers?: MiniProgramNetworkHeaders;
|
|
56
|
+
timeout?: number;
|
|
57
|
+
withCredentials?: boolean;
|
|
58
|
+
maxBytes?: number;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
61
|
+
}
|
|
62
|
+
/** File target 原子替换,Directory target 创建或替换子文件。 */
|
|
63
|
+
export type DownloadOptions = DownloadBaseOptions & ({
|
|
64
|
+
to: FileHandle;
|
|
65
|
+
suggestedName?: never;
|
|
66
|
+
overwrite?: never;
|
|
67
|
+
} | {
|
|
68
|
+
to: DirectoryHandle;
|
|
69
|
+
suggestedName?: string;
|
|
70
|
+
overwrite?: boolean;
|
|
71
|
+
});
|
|
45
72
|
/**
|
|
46
73
|
* bridge / runtime 可消费的网络请求 payload。
|
|
47
74
|
*
|
|
@@ -60,7 +87,7 @@ export interface NetworkRequestPayload {
|
|
|
60
87
|
/**
|
|
61
88
|
* bridge / runtime 返回的标准化 HTTP 响应。
|
|
62
89
|
*
|
|
63
|
-
* @typeParam T 标准化响应数据的类型。
|
|
90
|
+
* @typeParam T - 标准化响应数据的类型。
|
|
64
91
|
*/
|
|
65
92
|
export interface NetworkResponsePayload<T = unknown> {
|
|
66
93
|
data: T;
|
|
@@ -71,7 +98,7 @@ export interface NetworkResponsePayload<T = unknown> {
|
|
|
71
98
|
/**
|
|
72
99
|
* SDK 对外暴露的网络响应。
|
|
73
100
|
*
|
|
74
|
-
* @typeParam T 标准化响应数据的类型。
|
|
101
|
+
* @typeParam T - 标准化响应数据的类型。
|
|
75
102
|
*/
|
|
76
103
|
export interface MiniProgramNetworkResponse<T = unknown> extends NetworkResponsePayload<T> {
|
|
77
104
|
/** 发起请求时的 SDK 公共配置快照。 */
|
|
@@ -83,21 +110,50 @@ export interface MiniProgramNetworkModule {
|
|
|
83
110
|
/**
|
|
84
111
|
* 发起网络请求。
|
|
85
112
|
*
|
|
86
|
-
* @param config 面向业务层的网络请求配置。
|
|
113
|
+
* @param config - 面向业务层的网络请求配置。
|
|
87
114
|
* @returns 标准化网络响应;HTTP 2xx 默认返回 resolve。
|
|
88
|
-
* @throws
|
|
89
|
-
* @throws
|
|
115
|
+
* @throws 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出 `HbMiniProgramNetworkError`。
|
|
116
|
+
* @throws 当 bridge、运行时或宿主能力调用失败时抛出 `HbMiniProgramSDKError`。
|
|
117
|
+
* @since 0.2.0-alpha.0
|
|
118
|
+
* @hbPlatform android
|
|
119
|
+
* @hbPlatform ios
|
|
120
|
+
* @hbPlatform ohos
|
|
121
|
+
* @hbPlatform windows
|
|
122
|
+
* @hbPlatform macos
|
|
123
|
+
* @hbClient android none
|
|
124
|
+
* @hbClient ios none
|
|
125
|
+
* @hbClient ohos none
|
|
126
|
+
* @hbClient windows none
|
|
127
|
+
* @hbClient macos none
|
|
90
128
|
*/
|
|
91
129
|
request<T = unknown>(config: MiniProgramNetworkRequestConfig): Promise<MiniProgramNetworkResponse<T>>;
|
|
130
|
+
/**
|
|
131
|
+
* 将 GET 响应流式写入受控 File/Directory target。
|
|
132
|
+
*
|
|
133
|
+
* @param options - 下载地址、写入目标、取消信号与进度回调。
|
|
134
|
+
* @returns 原子提交完成后的目标文件代理。
|
|
135
|
+
* @since 0.8.0-alpha.2
|
|
136
|
+
* @hbPlatform android
|
|
137
|
+
* @hbPlatform ios
|
|
138
|
+
* @hbPlatform ohos
|
|
139
|
+
* @hbPlatform windows
|
|
140
|
+
* @hbPlatform macos
|
|
141
|
+
* @hbClient android none
|
|
142
|
+
* @hbClient ios none
|
|
143
|
+
* @hbClient ohos none
|
|
144
|
+
* @hbClient windows none
|
|
145
|
+
* @hbClient macos none
|
|
146
|
+
*/
|
|
147
|
+
download(options: DownloadOptions): Promise<FileHandle>;
|
|
92
148
|
}
|
|
93
149
|
/**
|
|
94
150
|
* 发起网络请求并返回标准化响应。
|
|
95
151
|
*
|
|
96
|
-
* @param requester 底层 bridge 请求能力。
|
|
97
|
-
* @param config 面向业务层的网络请求配置。
|
|
152
|
+
* @param requester - 底层 bridge 请求能力。
|
|
153
|
+
* @param config - 面向业务层的网络请求配置。
|
|
98
154
|
* @returns 标准化网络响应。HTTP 2xx 默认返回 resolve。
|
|
99
|
-
* @throws {HbMiniProgramNetworkError} 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出。
|
|
100
|
-
* @throws {HbMiniProgramSDKError} 当 bridge、运行时或宿主能力调用失败时抛出。
|
|
155
|
+
* @throws {@link HbMiniProgramNetworkError} 当请求已完成但 HTTP 状态不满足 `validateStatus` 时抛出。
|
|
156
|
+
* @throws {@link HbMiniProgramSDKError} 当 bridge、运行时或宿主能力调用失败时抛出。
|
|
101
157
|
*
|
|
102
158
|
* @remarks
|
|
103
159
|
* `validateStatus` 仅在 SDK 侧执行,不会跨 bridge 传输函数值。
|
|
@@ -112,10 +168,12 @@ export interface MiniProgramNetworkModule {
|
|
|
112
168
|
* ```
|
|
113
169
|
*/
|
|
114
170
|
export declare function request<T = unknown>(requester: MiniProgramRequester, config: MiniProgramNetworkRequestConfig): Promise<MiniProgramNetworkResponse<T>>;
|
|
171
|
+
/** 发起不使用 bridge 固定总时长 timer 的流式下载。 */
|
|
172
|
+
export declare function download(requester: MiniProgramOperationRequester, options: DownloadOptions): Promise<FileHandle>;
|
|
115
173
|
/**
|
|
116
174
|
* 创建 network 模块。
|
|
117
175
|
*
|
|
118
|
-
* @param requester 底层 bridge 请求能力。
|
|
176
|
+
* @param requester - 底层 bridge 请求能力。
|
|
119
177
|
* @returns 面向业务层的网络模块对象。
|
|
120
178
|
*/
|
|
121
|
-
export declare function createNetworkModule(requester:
|
|
179
|
+
export declare function createNetworkModule(requester: MiniProgramOperationRequester): MiniProgramNetworkModule;
|
|
@@ -8,9 +8,9 @@ export type CopyLinkResult = string;
|
|
|
8
8
|
/**
|
|
9
9
|
* 复制当前小程序的通用分享链接。
|
|
10
10
|
*
|
|
11
|
-
* @param requester 底层 bridge 请求能力。
|
|
12
|
-
* @param options 分享扩展数据;不传时复制默认首页链接。
|
|
11
|
+
* @param requester - 底层 bridge 请求能力。
|
|
12
|
+
* @param options - 分享扩展数据;不传时复制默认首页链接。
|
|
13
13
|
* @returns 已写入系统剪贴板的完整分享链接。
|
|
14
|
-
* @throws {HbMiniProgramSDKError} 当参数、bridge、父容器或剪贴板能力调用失败时抛出。
|
|
14
|
+
* @throws {@link HbMiniProgramSDKError} 当参数、bridge、父容器或剪贴板能力调用失败时抛出。
|
|
15
15
|
*/
|
|
16
16
|
export declare function copyLink(requester: MiniProgramRequester, options?: MiniProgramCopyLinkOptions): Promise<CopyLinkResult>;
|
|
@@ -10,19 +10,75 @@ export * from './types';
|
|
|
10
10
|
export type { MiniProgramShareMethod } from '../../protocol/capabilities';
|
|
11
11
|
/** 外部小程序可调用的分享模块。 */
|
|
12
12
|
export interface MiniProgramShareModule {
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* 复制当前小程序的通用分享链接,并返回该链接。
|
|
15
|
+
*
|
|
16
|
+
* @since 0.7.4-alpha.5
|
|
17
|
+
* @hbPlatform android
|
|
18
|
+
* @hbPlatform ios
|
|
19
|
+
* @hbPlatform ohos
|
|
20
|
+
* @hbPlatform windows
|
|
21
|
+
* @hbPlatform macos
|
|
22
|
+
* @hbClient android none
|
|
23
|
+
* @hbClient ios none
|
|
24
|
+
* @hbClient ohos none
|
|
25
|
+
* @hbClient windows none
|
|
26
|
+
* @hbClient macos none
|
|
27
|
+
*/
|
|
14
28
|
copyLink(options?: MiniProgramCopyLinkOptions): Promise<CopyLinkResult>;
|
|
15
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* 同步获取小程序启动时携带的分享扩展数据;没有有效数据时返回 `undefined`。
|
|
31
|
+
*
|
|
32
|
+
* @since 0.7.4-alpha.5
|
|
33
|
+
* @hbPlatform android
|
|
34
|
+
* @hbPlatform ios
|
|
35
|
+
* @hbPlatform ohos
|
|
36
|
+
* @hbPlatform windows
|
|
37
|
+
* @hbPlatform macos
|
|
38
|
+
* @hbClient android none
|
|
39
|
+
* @hbClient ios none
|
|
40
|
+
* @hbClient ohos none
|
|
41
|
+
* @hbClient windows none
|
|
42
|
+
* @hbClient macos none
|
|
43
|
+
*/
|
|
16
44
|
getExtra(): MiniProgramShareExtraValue | undefined;
|
|
17
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* 展示基础分享面板。
|
|
47
|
+
*
|
|
48
|
+
* @since 0.2.0-alpha.0
|
|
49
|
+
* @hbPlatform android
|
|
50
|
+
* @hbPlatform ios
|
|
51
|
+
* @hbPlatform ohos
|
|
52
|
+
* @hbPlatform windows
|
|
53
|
+
* @hbPlatform macos
|
|
54
|
+
* @hbClient android none
|
|
55
|
+
* @hbClient ios none
|
|
56
|
+
* @hbClient ohos none
|
|
57
|
+
* @hbClient windows none
|
|
58
|
+
* @hbClient macos none
|
|
59
|
+
*/
|
|
18
60
|
showShareMenu(options: ShowShareMenuPayload): Promise<ShowShareMenuResult>;
|
|
19
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* 截图并唤起分享。
|
|
63
|
+
*
|
|
64
|
+
* @since 0.2.0-alpha.0
|
|
65
|
+
* @hbPlatform android
|
|
66
|
+
* @hbPlatform ios
|
|
67
|
+
* @hbPlatform ohos
|
|
68
|
+
* @hbPlatform windows
|
|
69
|
+
* @hbPlatform macos
|
|
70
|
+
* @hbClient android none
|
|
71
|
+
* @hbClient ios none
|
|
72
|
+
* @hbClient ohos none
|
|
73
|
+
* @hbClient windows none
|
|
74
|
+
* @hbClient macos none
|
|
75
|
+
*/
|
|
20
76
|
screenshot(options?: MiniProgramScreenshotOptions): Promise<ScreenshotResult>;
|
|
21
77
|
}
|
|
22
78
|
/**
|
|
23
79
|
* 创建分享模块。
|
|
24
80
|
*
|
|
25
|
-
* @param requester 底层 bridge 请求能力。
|
|
81
|
+
* @param requester - 底层 bridge 请求能力。
|
|
26
82
|
* @returns 面向业务层的分享模块对象。
|
|
27
83
|
*/
|
|
28
84
|
export declare function createShareModule(requester: MiniProgramRequester, launchHref?: string): MiniProgramShareModule;
|
|
@@ -8,9 +8,9 @@ export type ScreenshotResult = unknown;
|
|
|
8
8
|
/**
|
|
9
9
|
* 截图并唤起分享。
|
|
10
10
|
*
|
|
11
|
-
* @param requester 底层 bridge 请求能力。
|
|
12
|
-
* @param options 截图区域、延迟与保存相册等配置。
|
|
11
|
+
* @param requester - 底层 bridge 请求能力。
|
|
12
|
+
* @param options - 截图区域、延迟与保存相册等配置。
|
|
13
13
|
* @returns 由宿主客户端协议决定的结果。
|
|
14
|
-
* @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
|
|
14
|
+
* @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
|
|
15
15
|
*/
|
|
16
16
|
export declare function screenshot(requester: MiniProgramRequester, options?: MiniProgramScreenshotOptions): Promise<ScreenshotResult>;
|
|
@@ -8,9 +8,9 @@ export type ShowShareMenuResult = unknown;
|
|
|
8
8
|
/**
|
|
9
9
|
* 展示基础分享面板。
|
|
10
10
|
*
|
|
11
|
-
* @param requester 底层 bridge 请求能力。
|
|
12
|
-
* @param options 基础分享参数。
|
|
11
|
+
* @param requester - 底层 bridge 请求能力。
|
|
12
|
+
* @param options - 基础分享参数。
|
|
13
13
|
* @returns 由宿主客户端协议决定的结果。
|
|
14
|
-
* @throws {HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
|
|
14
|
+
* @throws {@link HbMiniProgramSDKError} 当 bridge、父容器或宿主能力调用失败时抛出。
|
|
15
15
|
*/
|
|
16
16
|
export declare function showShareMenu(requester: MiniProgramRequester, options: ShowShareMenuPayload): Promise<ShowShareMenuResult>;
|