@heybox/hb-sdk 0.7.5-alpha.0 → 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/CHANGELOG.md +99 -352
- package/README.md +103 -26
- package/THIRD_PARTY_NOTICES.md +1755 -0
- package/dist/cli-chunks/{build-V1YBdpzY.cjs → build-aDJbiFqF.cjs} +9 -5
- package/dist/cli-chunks/{context-Ba1Je-wT.cjs → context-Dp36pZ9a.cjs} +39 -81
- package/dist/cli-chunks/{create-CKGjqo9E.cjs → create-P3g0ricz.cjs} +2 -2
- package/dist/cli-chunks/{dev-XopYKLYZ.cjs → dev-CisJkXuQ.cjs} +396 -576
- package/dist/cli-chunks/doctor-B-LF5-uj.cjs +65 -0
- package/dist/cli-chunks/{index-C9mpajVG.cjs → index-BDaeBI_B.cjs} +50 -30
- package/dist/cli-chunks/{index-DKWfX6Ut.cjs → index-CZGkk7fQ.cjs} +2 -2
- package/dist/cli-chunks/{index.esm-SXAQ3WVR.cjs → index.esm-NNLG29Tt.cjs} +8 -7
- package/dist/cli-chunks/{login-BVWicWqe.cjs → login-DTY5GolC.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CBb38HJ3.cjs → project-vite-DlCjHlu_.cjs} +1 -1
- package/dist/cli-chunks/{remote-BG1u0NKT.cjs → remote-BBMr7j8W.cjs} +61 -27
- package/dist/cli-chunks/{runtime-gate-CtV7rWyX.cjs → runtime-gate-BppCl1r3.cjs} +30 -3
- package/dist/cli-chunks/{runtime-permission-env-D-8_jPG3.cjs → runtime-permission-env-CqsTHeas.cjs} +364 -13
- package/dist/cli-chunks/{session-CJS_SEp9.cjs → session-CnGeZCRZ.cjs} +1 -1
- package/dist/cli-chunks/skill-B0yAnPOJ.cjs +83 -0
- package/dist/cli-chunks/version-DN5jrixS.cjs +8 -0
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-BhZGUyYw.js +97 -0
- package/dist/devtools/browser-dev-host/assets/heybox-logo-CogNENsk.svg +6 -0
- package/dist/devtools/browser-dev-host/assets/index-DJFB5ySU.css +1 -0
- package/dist/devtools/browser-dev-host/assets/index-Dh9H1JOm.js +567 -0
- package/dist/devtools/browser-dev-host/assets/workbench-state-wHgWRb7I.js +5 -0
- package/dist/devtools/browser-dev-host/index.html +6 -435
- package/dist/index.cjs.js +1051 -91
- package/dist/index.esm.js +1051 -92
- package/dist/miniapp-publish.cjs.js +13 -13
- package/dist/miniapp-publish.esm.js +13 -13
- package/dist/protocol.cjs.js +381 -37
- package/dist/protocol.esm.js +355 -38
- package/dist/templates/{vue3-vite-ts → vanilla-vite-js}/.gitignore.ejs +0 -1
- package/dist/templates/vanilla-vite-js/README.md.ejs +14 -0
- package/dist/templates/vanilla-vite-js/index.html.ejs +20 -0
- package/dist/templates/vanilla-vite-js/package.json.ejs +22 -0
- package/dist/templates/vanilla-vite-js/src/assets/heybox-logo.svg +8 -0
- package/dist/templates/vanilla-vite-js/src/main.js +39 -0
- package/dist/templates/vanilla-vite-js/src/styles.css +155 -0
- package/dist/templates/{vue3-vite-ts/vite.config.ts → vanilla-vite-js/vite.config.js} +1 -2
- package/dist/vite.cjs.js +256 -10
- package/dist/vite.esm.js +256 -11
- package/package.json +37 -11
- package/skill/SKILL.md +22 -20
- package/skill/references/api-protocol.md +112 -6
- package/skill/references/api-root.md +194 -30
- package/skill/references/cli.md +41 -24
- package/skill/references/examples.md +31 -2
- package/skill/references/llms-index.md +1 -1
- package/skill/references/recipes.md +139 -36
- package/skill/references/safety-boundaries.md +15 -6
- package/skill/skill.json +10 -5
- 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/index.d.ts +1 -0
- package/types/miniapp-manifest/node.d.ts +3 -0
- package/types/miniapp-manifest/permissions.d.ts +37 -0
- package/types/miniapp-manifest/schema.d.ts +10 -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 +4 -4
- package/types/modules/share/types.d.ts +2 -4
- 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/skill-metadata.d.ts +0 -4
- package/types/vite/index.d.ts +15 -7
- package/dist/cli-chunks/doctor-BHbrYQqT.cjs +0 -204
- package/dist/devtools/browser-dev-host/main.js +0 -12158
- package/dist/templates/vue3-vite-ts/README.md.ejs +0 -45
- package/dist/templates/vue3-vite-ts/index.html.ejs +0 -12
- package/dist/templates/vue3-vite-ts/package.json.ejs +0 -33
- package/dist/templates/vue3-vite-ts/src/App.vue +0 -78
- package/dist/templates/vue3-vite-ts/src/__tests__/App.spec.ts +0 -148
- package/dist/templates/vue3-vite-ts/src/auth-handoff.ts +0 -46
- package/dist/templates/vue3-vite-ts/src/main.ts +0 -5
- package/dist/templates/vue3-vite-ts/src/styles.css +0 -60
- package/dist/templates/vue3-vite-ts/src/vite-env.d.ts +0 -1
- package/dist/templates/vue3-vite-ts/tsconfig.app.json +0 -17
- package/dist/templates/vue3-vite-ts/tsconfig.json +0 -11
- package/dist/templates/vue3-vite-ts/tsconfig.node.json +0 -11
- package/dist/templates/vue3-vite-ts/vitest.config.ts +0 -10
- package/skill/scripts/check-references.mjs +0 -14
- package/skill/scripts/markdown-sections.mjs +0 -36
- package/skill/scripts/package-skill.mjs +0 -60
- package/skill/scripts/package-skill.sh +0 -6
- package/skill/scripts/skill-metadata.mjs +0 -77
- package/skill/scripts/sync-agent-skills-payload.mjs +0 -359
- package/skill/scripts/sync-references.mjs +0 -792
- package/skill/scripts/validate-skill.mjs +0 -263
package/types/core/client.d.ts
CHANGED
|
@@ -25,8 +25,18 @@ export interface MiniProgramRequester {
|
|
|
25
25
|
/** 向父容器调用指定开放能力。 */
|
|
26
26
|
request<Method extends MiniProgramBridgeMethod>(method: Method, ...args: MiniProgramRequesterArgs<Method>): Promise<MiniProgramCapabilityResult<Method>>;
|
|
27
27
|
}
|
|
28
|
+
/** 长操作使用的本地 observer 与取消配置,不进入 bridge payload。 */
|
|
29
|
+
export interface MiniProgramOperationOptions<TProgress = unknown> {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
onProgress?: (progress: TProgress) => void;
|
|
32
|
+
createAbortError?: () => unknown;
|
|
33
|
+
}
|
|
34
|
+
/** 支持 request-scoped progress/cancel 的 bridge requester。 */
|
|
35
|
+
export interface MiniProgramOperationRequester extends MiniProgramRequester {
|
|
36
|
+
requestOperation<Method extends MiniProgramBridgeMethod, TProgress = unknown>(method: Method, payload: MiniProgramCapabilityPayload<Method>, options?: MiniProgramOperationOptions<TProgress>): Promise<MiniProgramCapabilityResult<Method>>;
|
|
37
|
+
}
|
|
28
38
|
/** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
|
|
29
|
-
export declare class MiniProgramBridgeClient implements
|
|
39
|
+
export declare class MiniProgramBridgeClient implements MiniProgramOperationRequester {
|
|
30
40
|
private readonly timeout;
|
|
31
41
|
private readonly selfWindow?;
|
|
32
42
|
private readonly targetWindow;
|
|
@@ -64,6 +74,9 @@ export declare class MiniProgramBridgeClient implements MiniProgramRequester {
|
|
|
64
74
|
off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
|
|
65
75
|
/** 调用父容器开放能力。 */
|
|
66
76
|
request<Method extends MiniProgramBridgeMethod>(method: Method, ...args: MiniProgramRequesterArgs<Method>): Promise<MiniProgramCapabilityResult<Method>>;
|
|
77
|
+
/** 发起不使用固定总时长 timer 的长操作。 */
|
|
78
|
+
requestOperation<Method extends MiniProgramBridgeMethod, TProgress = unknown>(method: Method, payload: MiniProgramCapabilityPayload<Method>, options?: MiniProgramOperationOptions<TProgress>): Promise<MiniProgramCapabilityResult<Method>>;
|
|
79
|
+
private performRequest;
|
|
67
80
|
/** 销毁 SDK 实例,并拒绝尚未完成的请求。 */
|
|
68
81
|
destroy(): void;
|
|
69
82
|
private ensureStarted;
|
|
@@ -73,6 +86,9 @@ export declare class MiniProgramBridgeClient implements MiniProgramRequester {
|
|
|
73
86
|
private postCSPViolation;
|
|
74
87
|
private handleEvent;
|
|
75
88
|
private handleResponse;
|
|
89
|
+
private handleOperationProgress;
|
|
90
|
+
private sendCancel;
|
|
91
|
+
private cleanupPending;
|
|
76
92
|
private postMessage;
|
|
77
93
|
private resolveHandshakeOnce;
|
|
78
94
|
private failHandshake;
|
package/types/core/errors.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export declare class HbMiniProgramSDKError extends Error {
|
|
|
18
18
|
/**
|
|
19
19
|
* 创建 SDK 标准错误。
|
|
20
20
|
*
|
|
21
|
-
* @param code 稳定错误码。
|
|
22
|
-
* @param message 面向开发者的错误说明。
|
|
23
|
-
* @param data 可选调试数据。
|
|
21
|
+
* @param code - 稳定错误码。
|
|
22
|
+
* @param message - 面向开发者的错误说明。
|
|
23
|
+
* @param data - 可选调试数据。
|
|
24
24
|
* @returns 标准化 `HbMiniProgramSDKError` 实例。
|
|
25
25
|
*
|
|
26
26
|
* @remarks
|
|
@@ -34,7 +34,7 @@ export declare function createSDKError(code: string, message: string, data?: unk
|
|
|
34
34
|
* 仅在请求已经成功走完 bridge / runtime / 宿主调用链、但最终 HTTP 状态不满足
|
|
35
35
|
* `validateStatus` 时抛出。它不表示握手失败或 bridge 级错误。
|
|
36
36
|
*
|
|
37
|
-
* @typeParam T 标准化响应数据的类型。
|
|
37
|
+
* @typeParam T - 标准化响应数据的类型。
|
|
38
38
|
*/
|
|
39
39
|
export declare class HbMiniProgramNetworkError<T = unknown> extends Error {
|
|
40
40
|
/** HTTP 状态码。 */
|
|
@@ -48,7 +48,7 @@ export declare class HbMiniProgramNetworkError<T = unknown> extends Error {
|
|
|
48
48
|
/** 完整标准化响应。 */
|
|
49
49
|
response: MiniProgramNetworkResponse<T>;
|
|
50
50
|
/**
|
|
51
|
-
* @param response 已完成请求的标准化网络响应。
|
|
51
|
+
* @param response - 已完成请求的标准化网络响应。
|
|
52
52
|
*/
|
|
53
53
|
constructor(response: MiniProgramNetworkResponse<T>);
|
|
54
54
|
}
|
package/types/core/sdk.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type MiniProgramCloudModule } from '../modules/cloud';
|
|
|
4
4
|
import { type MiniProgramShareModule } from '../modules/share';
|
|
5
5
|
import { type MiniProgramStorageModule } from '../modules/storage';
|
|
6
6
|
import { type MiniProgramNetworkModule } from '../modules/network';
|
|
7
|
+
import { type FilesModule } from '../modules/files';
|
|
7
8
|
import { type MiniProgramViewportModule } from '../modules/viewport';
|
|
8
9
|
import { type MiniProgramUserModule } from '../modules/user';
|
|
9
10
|
import { type MiniProgramUiModule } from '../modules/ui';
|
|
@@ -37,6 +38,8 @@ export declare class MiniProgramSDK {
|
|
|
37
38
|
readonly storage: MiniProgramStorageModule;
|
|
38
39
|
/** 网络请求相关开放能力。 */
|
|
39
40
|
readonly network: MiniProgramNetworkModule;
|
|
41
|
+
/** 受控文件与目录能力。 */
|
|
42
|
+
readonly files: FilesModule;
|
|
40
43
|
/** UI 交互相关开放能力。 */
|
|
41
44
|
readonly ui: MiniProgramUiModule;
|
|
42
45
|
/** 设备相关开放能力。 */
|
|
@@ -53,16 +56,16 @@ export declare class MiniProgramSDK {
|
|
|
53
56
|
/**
|
|
54
57
|
* 注册小程序生命周期或业务事件。
|
|
55
58
|
*
|
|
56
|
-
* @param eventName 要监听的事件名。
|
|
57
|
-
* @param handler 事件处理函数。
|
|
59
|
+
* @param eventName - 要监听的事件名。
|
|
60
|
+
* @param handler - 事件处理函数。
|
|
58
61
|
* @returns 事件解绑函数。
|
|
59
62
|
*/
|
|
60
63
|
on<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): () => void;
|
|
61
64
|
/**
|
|
62
65
|
* 移除小程序生命周期或业务事件。
|
|
63
66
|
*
|
|
64
|
-
* @param eventName 要移除的事件名。
|
|
65
|
-
* @param handler 对应的事件处理函数。
|
|
67
|
+
* @param eventName - 要移除的事件名。
|
|
68
|
+
* @param handler - 对应的事件处理函数。
|
|
66
69
|
*/
|
|
67
70
|
off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
|
|
68
71
|
/**
|
|
@@ -77,7 +80,7 @@ export declare class MiniProgramSDK {
|
|
|
77
80
|
/**
|
|
78
81
|
* 创建独立 SDK 实例。
|
|
79
82
|
*
|
|
80
|
-
* @param options SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
|
|
83
|
+
* @param options - SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
|
|
81
84
|
* @returns 可独立管理生命周期的 `MiniProgramSDK` 实例。
|
|
82
85
|
*
|
|
83
86
|
* @remarks
|
|
@@ -3,6 +3,7 @@ import type { MiniProgramCloudModule } from '../modules/cloud';
|
|
|
3
3
|
import type { MiniProgramShareModule } from '../modules/share';
|
|
4
4
|
import type { MiniProgramStorageModule } from '../modules/storage';
|
|
5
5
|
import type { MiniProgramNetworkModule } from '../modules/network';
|
|
6
|
+
import type { FilesModule } from '../modules/files';
|
|
6
7
|
import type { MiniProgramViewportModule } from '../modules/viewport';
|
|
7
8
|
import type { MiniProgramUserModule } from '../modules/user';
|
|
8
9
|
import type { MiniProgramUiModule } from '../modules/ui';
|
|
@@ -10,24 +11,74 @@ import type { MiniProgramDeviceModule } from '../modules/device';
|
|
|
10
11
|
import type { MiniProgramNavigationModule } from '../modules/navigation';
|
|
11
12
|
import type { MiniProgramEventHandler, MiniProgramEventName } from '../protocol/types';
|
|
12
13
|
import type { MiniProgramSDKHandshakeState, MiniProgramSDKHandshakeStateHandler } from './handshake-state';
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 获取默认 SDK 实例的当前握手状态。
|
|
16
|
+
*
|
|
17
|
+
* @since 0.7.0-alpha.9
|
|
18
|
+
* @hbPlatform android
|
|
19
|
+
* @hbPlatform ios
|
|
20
|
+
* @hbPlatform ohos
|
|
21
|
+
* @hbPlatform windows
|
|
22
|
+
* @hbPlatform macos
|
|
23
|
+
* @hbClient android none
|
|
24
|
+
* @hbClient ios none
|
|
25
|
+
* @hbClient ohos none
|
|
26
|
+
* @hbClient windows none
|
|
27
|
+
* @hbClient macos none
|
|
28
|
+
*/
|
|
14
29
|
export declare function getHandshakeState(): MiniProgramSDKHandshakeState;
|
|
15
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* 订阅默认 SDK 实例的握手状态,并立即接收当前状态。
|
|
32
|
+
*
|
|
33
|
+
* @since 0.7.0-alpha.9
|
|
34
|
+
* @hbPlatform android
|
|
35
|
+
* @hbPlatform ios
|
|
36
|
+
* @hbPlatform ohos
|
|
37
|
+
* @hbPlatform windows
|
|
38
|
+
* @hbPlatform macos
|
|
39
|
+
* @hbClient android none
|
|
40
|
+
* @hbClient ios none
|
|
41
|
+
* @hbClient ohos none
|
|
42
|
+
* @hbClient windows none
|
|
43
|
+
* @hbClient macos none
|
|
44
|
+
*/
|
|
16
45
|
export declare function onHandshakeStateChange(handler: MiniProgramSDKHandshakeStateHandler): () => void;
|
|
17
46
|
/**
|
|
18
47
|
* 注册默认 SDK 实例的事件监听。
|
|
19
48
|
*
|
|
20
|
-
* @param eventName 要监听的事件名。
|
|
21
|
-
* @param handler 事件处理函数。
|
|
49
|
+
* @param eventName - 要监听的事件名。
|
|
50
|
+
* @param handler - 事件处理函数。
|
|
22
51
|
* @returns 事件解绑函数。
|
|
52
|
+
* @since 0.2.0-alpha.0
|
|
53
|
+
* @hbPlatform android
|
|
54
|
+
* @hbPlatform ios
|
|
55
|
+
* @hbPlatform ohos
|
|
56
|
+
* @hbPlatform windows
|
|
57
|
+
* @hbPlatform macos
|
|
58
|
+
* @hbClient android none
|
|
59
|
+
* @hbClient ios none
|
|
60
|
+
* @hbClient ohos none
|
|
61
|
+
* @hbClient windows none
|
|
62
|
+
* @hbClient macos none
|
|
23
63
|
*/
|
|
24
64
|
export declare function on<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): () => void;
|
|
25
65
|
/**
|
|
26
66
|
* 移除默认 SDK 实例的事件监听。
|
|
27
67
|
*
|
|
28
|
-
* @param eventName 要移除的事件名。
|
|
29
|
-
* @param handler 对应的事件处理函数。
|
|
68
|
+
* @param eventName - 要移除的事件名。
|
|
69
|
+
* @param handler - 对应的事件处理函数。
|
|
30
70
|
* @returns 无返回值。
|
|
71
|
+
* @since 0.2.0-alpha.0
|
|
72
|
+
* @hbPlatform android
|
|
73
|
+
* @hbPlatform ios
|
|
74
|
+
* @hbPlatform ohos
|
|
75
|
+
* @hbPlatform windows
|
|
76
|
+
* @hbPlatform macos
|
|
77
|
+
* @hbClient android none
|
|
78
|
+
* @hbClient ios none
|
|
79
|
+
* @hbClient ohos none
|
|
80
|
+
* @hbClient windows none
|
|
81
|
+
* @hbClient macos none
|
|
31
82
|
*/
|
|
32
83
|
export declare function off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
|
|
33
84
|
/** 默认 SDK 实例的授权模块。 */
|
|
@@ -42,6 +93,8 @@ export declare const viewport: MiniProgramViewportModule;
|
|
|
42
93
|
export declare const storage: MiniProgramStorageModule;
|
|
43
94
|
/** 默认 SDK 实例的 network 模块。 */
|
|
44
95
|
export declare const network: MiniProgramNetworkModule;
|
|
96
|
+
/** 默认 SDK 实例的 files 模块。 */
|
|
97
|
+
export declare const files: FilesModule;
|
|
45
98
|
/** 默认 SDK 实例的 UI 模块。 */
|
|
46
99
|
export declare const ui: MiniProgramUiModule;
|
|
47
100
|
/** 默认 SDK 实例的 device 模块。 */
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { HbMiniProgramSDKError, HbMiniProgramNetworkError } from './core/errors';
|
|
2
|
-
export { getHandshakeState, onHandshakeStateChange, on, off, auth, user, share, viewport, storage, network, ui, device, navigation, cloud, } from './core/singleton';
|
|
2
|
+
export { getHandshakeState, onHandshakeStateChange, on, off, auth, user, share, viewport, storage, files, network, ui, device, navigation, cloud, } from './core/singleton';
|
|
3
3
|
export type { MiniProgramSDKHandshakeState, MiniProgramSDKHandshakeStateHandler } from './core/handshake-state';
|
|
4
4
|
export type { MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap } from './protocol/types';
|
|
5
5
|
export type { LoginOptions, LoginPayload, LoginResult, LoginScope, MiniProgramAuthModule } from './modules/auth';
|
|
@@ -10,7 +10,8 @@ export type { UserInfoAuthorizationScope } from './modules/user';
|
|
|
10
10
|
export type { CopyLinkPayload, CopyLinkResult, MiniProgramCopyLinkOptions, MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareExtraValue, MiniProgramShareModule, MiniProgramSharePostOptions, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
|
|
11
11
|
export type { GetWindowInfoPayload, GetWindowInfoResult, MiniProgramNavigationBarForegroundStyle, MiniProgramSafeArea, MiniProgramSetNavigationBarStyleOptions, MiniProgramViewportModule, MiniProgramWindowInfoResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, } from './modules/viewport';
|
|
12
12
|
export type { GetStoragePayload, GetStorageResult, MiniProgramStorageModule, SetStoragePayload } from './modules/storage';
|
|
13
|
-
export type { MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, NetworkRequestPayload, NetworkResponsePayload, } from './modules/network';
|
|
13
|
+
export type { DownloadBaseOptions, DownloadOptions, DownloadProgress, MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, NetworkRequestPayload, NetworkResponsePayload, } from './modules/network';
|
|
14
|
+
export type { CreateOptions, DirectoryHandle, FileHandle, FileMode, FileStat, FileSystem, FileSystemEntity, FilesModule, ListOptions, PathRoot, PickDirectoryOptions, PickFilesOptions, RemoveOptions, SaveFileOptions, } from './modules/files';
|
|
14
15
|
export type { HideLoadingPayload, HideLoadingResult, MiniProgramToastStatus, MiniProgramUiModule, ShowLoadingPayload, ShowLoadingResult, ShowToastPayload, ShowToastResult, } from './modules/ui';
|
|
15
16
|
export type { MiniProgramDeviceModule, MiniProgramVibrateIntensity, SetClipboardPayload, SetClipboardResult, VibratePayload, VibrateResult, } from './modules/device';
|
|
16
17
|
export type { ClosePayload, CloseResult, MiniProgramAppPageTarget, MiniProgramGameDetailGameType, MiniProgramGameDetailPage, MiniProgramNavigationModule, OpenAppPageOptions, OpenAppPagePayload, OpenAppPageResult, OpenGameDetailAppPagePayload, OpenGameDetailAppPageOptions, OpenPostDetailAppPagePayload, OpenPostDetailAppPageOptions, OpenUserDetailAppPagePayload, OpenUserDetailAppPageOptions, ReloadPayload, ReloadResult, } from './modules/navigation';
|
|
@@ -25,6 +26,7 @@ declare const hbSDK: {
|
|
|
25
26
|
share: import(".").MiniProgramShareModule;
|
|
26
27
|
viewport: import(".").MiniProgramViewportModule;
|
|
27
28
|
storage: import(".").MiniProgramStorageModule;
|
|
29
|
+
files: import(".").FilesModule;
|
|
28
30
|
network: import(".").MiniProgramNetworkModule;
|
|
29
31
|
ui: import(".").MiniProgramUiModule;
|
|
30
32
|
device: import(".").MiniProgramDeviceModule;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
import { type ParsedMiniappPermissions } from './permissions';
|
|
1
2
|
export declare function readMiniappVersionFromPackageJson(root: string): string;
|
|
3
|
+
export declare function readMiniappPermissionsFromPackageJson(root: string, sdkVersion: string): ParsedMiniappPermissions;
|
|
4
|
+
export declare function resolveMiniappSdkVersion(): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type MiniProgramPermissionKey, type MiniProgramRuntimePermissionsSnapshot } from '@heybox/hb-sdk-protocol';
|
|
2
|
+
export declare const MINIAPP_PERMISSION_KEYS: readonly ["userInfo", "steamLibrary", "share", "storage", "filesystem", "clipboard", "leaderboard", "network"];
|
|
3
|
+
export type MiniappPermissionKey = MiniProgramPermissionKey;
|
|
4
|
+
export interface SimpleMiniappPermissionDeclaration {
|
|
5
|
+
enabled: true;
|
|
6
|
+
}
|
|
7
|
+
export interface NetworkMiniappPermissionDeclaration extends SimpleMiniappPermissionDeclaration {
|
|
8
|
+
useOfficialDomain: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type MiniappPermissionDeclarations = Partial<Record<Exclude<MiniappPermissionKey, 'network'>, SimpleMiniappPermissionDeclaration> & {
|
|
11
|
+
network: NetworkMiniappPermissionDeclaration;
|
|
12
|
+
}>;
|
|
13
|
+
export interface ParsedMiniappPermissions {
|
|
14
|
+
declared: boolean;
|
|
15
|
+
permissions?: MiniappPermissionDeclarations;
|
|
16
|
+
}
|
|
17
|
+
export interface MiniappPermissionView {
|
|
18
|
+
key: MiniappPermissionKey;
|
|
19
|
+
access: 'declaration' | 'platform-approval';
|
|
20
|
+
declared: boolean;
|
|
21
|
+
approved: boolean | null;
|
|
22
|
+
requestedConfig?: Record<string, boolean>;
|
|
23
|
+
approvedConfig?: Record<string, boolean>;
|
|
24
|
+
effective: boolean;
|
|
25
|
+
effectiveConfig?: Record<string, boolean>;
|
|
26
|
+
}
|
|
27
|
+
export declare function parseMiniappPermissions(value: unknown, options: {
|
|
28
|
+
present: boolean;
|
|
29
|
+
sdkVersion: string;
|
|
30
|
+
sourceLabel?: string;
|
|
31
|
+
}): ParsedMiniappPermissions;
|
|
32
|
+
export declare function requiresExplicitPermissions(sdkVersion: string): boolean;
|
|
33
|
+
export declare function getMissingPermissionsWarning(sourceLabel?: string): string;
|
|
34
|
+
export declare function composeMiniappRuntimePermissions(local: ParsedMiniappPermissions, approvals: unknown): {
|
|
35
|
+
runtimePermissions: MiniProgramRuntimePermissionsSnapshot;
|
|
36
|
+
views: MiniappPermissionView[];
|
|
37
|
+
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { type MiniappPermissionDeclarations } from './permissions';
|
|
1
2
|
export declare const MINIAPP_TEMPLATE_VERSION = "0.0.0";
|
|
3
|
+
export declare const MINIAPP_PLATFORM_VALUES: readonly ["android", "ios", "ohos", "windows", "macos", "linux"];
|
|
4
|
+
export type MiniappPlatform = (typeof MINIAPP_PLATFORM_VALUES)[number];
|
|
2
5
|
export interface MiniappManifest {
|
|
3
6
|
[key: string]: unknown;
|
|
4
7
|
sdkVersion: string;
|
|
5
8
|
version: string;
|
|
9
|
+
platforms: readonly MiniappPlatform[];
|
|
10
|
+
permissions?: MiniappPermissionDeclarations;
|
|
6
11
|
}
|
|
7
12
|
export interface ParseMiniappManifestResult {
|
|
8
13
|
manifest: MiniappManifest;
|
|
@@ -14,7 +19,12 @@ export declare function validateMiniappManifestVersion(version: unknown, sourceL
|
|
|
14
19
|
export declare function renderMiniappManifest(manifest: MiniappManifest): string;
|
|
15
20
|
export declare function parseMiniappManifestJson(raw: string, sourceLabel?: string): ParseMiniappManifestResult;
|
|
16
21
|
export declare function validateMiniappManifestForDeploy(manifest: MiniappManifest): {
|
|
22
|
+
permissions?: Partial<Record<"storage" | "userInfo" | "steamLibrary" | "share" | "filesystem" | "clipboard" | "leaderboard", import("./permissions").SimpleMiniappPermissionDeclaration> & {
|
|
23
|
+
network: import("./permissions").NetworkMiniappPermissionDeclaration;
|
|
24
|
+
}> | undefined;
|
|
17
25
|
version: string;
|
|
18
26
|
sdkVersion: string;
|
|
27
|
+
platforms: readonly ("android" | "ios" | "ohos" | "windows" | "macos" | "linux")[];
|
|
19
28
|
};
|
|
29
|
+
export declare function validateMiniappPlatforms(platforms: unknown, sourceLabel?: string): readonly MiniappPlatform[];
|
|
20
30
|
export declare function validateSdkVersion(version: unknown, sourceLabel?: string): string;
|
|
@@ -71,7 +71,7 @@ export interface MiniappUploadSessionFile {
|
|
|
71
71
|
/**
|
|
72
72
|
* 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
|
|
73
73
|
*
|
|
74
|
-
* @param files 待处理的构建产物文件。
|
|
74
|
+
* @param files - 待处理的构建产物文件。
|
|
75
75
|
* @returns 保留输入附加字段的有序文件列表。
|
|
76
76
|
* @throws 路径不规范、路径重复或文件大小非法时抛出错误。
|
|
77
77
|
*/
|
|
@@ -81,8 +81,8 @@ export declare function prepareMiniappArtifactFiles<T extends MiniappArtifactFil
|
|
|
81
81
|
/**
|
|
82
82
|
* 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
|
|
83
83
|
*
|
|
84
|
-
* @param files 待上传的构建产物文件。
|
|
85
|
-
* @param options 小程序和长度限制配置。
|
|
84
|
+
* @param files - 待上传的构建产物文件。
|
|
85
|
+
* @param options - 小程序和长度限制配置。
|
|
86
86
|
* @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
|
|
87
87
|
*/
|
|
88
88
|
export declare function validateMiniappUploadPathLengths(files: readonly Pick<MiniappArtifactFile, 'relativePath'>[], options: {
|
|
@@ -92,7 +92,7 @@ export declare function validateMiniappUploadPathLengths(files: readonly Pick<Mi
|
|
|
92
92
|
/**
|
|
93
93
|
* 创建 v1 整包签名头。
|
|
94
94
|
*
|
|
95
|
-
* @param fileCount 参与签名的文件数量。
|
|
95
|
+
* @param fileCount - 参与签名的文件数量。
|
|
96
96
|
* @returns 包含协议标识和文件数量的字节数组。
|
|
97
97
|
* @throws 文件数量超出协议范围时抛出错误。
|
|
98
98
|
*/
|
|
@@ -100,7 +100,7 @@ export declare function createMiniappArtifactSignatureHeader(fileCount: number):
|
|
|
100
100
|
/**
|
|
101
101
|
* 创建单个文件的 v1 framing header。
|
|
102
102
|
*
|
|
103
|
-
* @param file 已规范化或待校验的构建产物文件。
|
|
103
|
+
* @param file - 已规范化或待校验的构建产物文件。
|
|
104
104
|
* @returns 包含路径长度、路径和文件大小的字节数组。
|
|
105
105
|
* @throws 文件路径或大小非法时抛出错误。
|
|
106
106
|
*/
|
|
@@ -108,9 +108,9 @@ export declare function createMiniappArtifactFileHeader(file: MiniappArtifactFil
|
|
|
108
108
|
/**
|
|
109
109
|
* 校验服务端 session 文件映射,并计算仍需上传的文件。
|
|
110
110
|
*
|
|
111
|
-
* @param localFiles 本地构建产物文件。
|
|
112
|
-
* @param serverFiles 服务端签发的文件映射。
|
|
113
|
-
* @param uploadedKeys 服务端已确认上传成功的 key。
|
|
111
|
+
* @param localFiles - 本地构建产物文件。
|
|
112
|
+
* @param serverFiles - 服务端签发的文件映射。
|
|
113
|
+
* @param uploadedKeys - 服务端已确认上传成功的 key。
|
|
114
114
|
* @returns 完整映射、待上传文件和已确认 key。
|
|
115
115
|
* @throws 服务端映射与本地产物不一致时抛出错误。
|
|
116
116
|
*/
|
|
@@ -16,7 +16,21 @@ export interface LoginResult {
|
|
|
16
16
|
export type { MiniProgramAuthMethod } from '../../protocol/capabilities';
|
|
17
17
|
/** 外部小程序可调用的授权模块。 */
|
|
18
18
|
export interface MiniProgramAuthModule {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* 获取短期授权码;不会向小程序暴露 token、cookie 或黑盒用户资料。
|
|
21
|
+
*
|
|
22
|
+
* @since 0.2.0-alpha.0
|
|
23
|
+
* @hbPlatform android
|
|
24
|
+
* @hbPlatform ios
|
|
25
|
+
* @hbPlatform ohos
|
|
26
|
+
* @hbPlatform windows
|
|
27
|
+
* @hbPlatform macos
|
|
28
|
+
* @hbClient android none
|
|
29
|
+
* @hbClient ios none
|
|
30
|
+
* @hbClient ohos none
|
|
31
|
+
* @hbClient windows none
|
|
32
|
+
* @hbClient macos none
|
|
33
|
+
*/
|
|
20
34
|
login(options?: LoginOptions): Promise<LoginResult>;
|
|
21
35
|
}
|
|
22
36
|
/** 获取短期授权码。 */
|
|
@@ -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 {};
|