mobile-web-bridge 0.1.6 → 0.2.0
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 +6 -4
- package/dist/assembleMWB.d.ts +1 -1
- package/dist/bridge.d.ts +1 -1
- package/dist/createMWB.d.ts +6 -6
- package/dist/eventHub.d.ts +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/mwb.iife.js +1 -1
- package/dist/nativePlugins.d.ts +1 -1
- package/dist/plugins/basic.d.ts +27 -27
- package/dist/plugins/container.d.ts +11 -11
- package/dist/plugins/device.d.ts +9 -9
- package/dist/plugins/media.d.ts +7 -7
- package/dist/types.d.ts +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
MWB 为 iOS 和 Android 的 Web 容器提供统一 JS API。原生通信由 DSBridge 3.x 完成。
|
|
4
4
|
|
|
5
|
-
当前版本为 `0.
|
|
5
|
+
当前版本为 `0.2.0`,与同一 Git Tag 下的 iOS/Android 源码配套。下方安装命令固定为 `0.2.0`;分发状态见 [版本说明](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/versioning.md),需要本地构建时可按 [源码构建与安装](https://github.com/gaoxiao228/MobileWebBridge#从源码构建-js-sdk) 使用。
|
|
6
6
|
|
|
7
7
|
正式仓库:[gaoxiao228/MobileWebBridge](https://github.com/gaoxiao228/MobileWebBridge)。建议固定精确版本;Git Tag 与 npm 分发标签独立,原生接入与支持范围见 [项目 README](https://github.com/gaoxiao228/MobileWebBridge#readme)。
|
|
8
8
|
|
|
9
|
+
当 TypeScript 使用 `node16`、`nodenext` 或 `bundler` 解析模块时,均支持从包入口导入公开类型。此修复不新增 CommonJS 或服务端/SSR 支持。
|
|
10
|
+
|
|
9
11
|
## 安装和使用
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
14
|
# 固定项目版本;原生端也使用配套版本。
|
|
13
|
-
npm install mobile-web-bridge@0.
|
|
15
|
+
npm install mobile-web-bridge@0.2.0
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
```ts
|
|
@@ -42,7 +44,7 @@ await mwb.setNavigationBarTheme({
|
|
|
42
44
|
|
|
43
45
|
当前源码新增 `await mwb.basic.notifyPageReady()`(也可用根入口 `mwb.notifyPageReady()`),用于 H5 主动通知当前原生容器首屏准备完成。无需注册业务插件,重复调用幂等。成功表示原生接受通知,不代表宿主已完成展示。
|
|
44
46
|
|
|
45
|
-
此能力请配套使用 JS、iOS 和 Android `0.
|
|
47
|
+
此能力请配套使用 JS、iOS 和 Android `0.2.0`。此方法走文档身份网关,等待上限 30000ms;旧原生和普通浏览器明确失败。调用时机、原生回调和重载规则见 [接入说明](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/page-lifecycle.md)。
|
|
46
48
|
|
|
47
49
|
## 同步与异步调用
|
|
48
50
|
|
|
@@ -170,4 +172,4 @@ MWB 的通信底层基于 [DSBridge](https://github.com/wendux/DSBridge-Android)
|
|
|
170
172
|
|
|
171
173
|
包内包含 LICENSE 和 THIRD_PARTY_NOTICES.md,ESM/IIFE/组合脚本保留完整许可注释;单独分发 bundle 时也不要移除这些注释。
|
|
172
174
|
|
|
173
|
-
`0.
|
|
175
|
+
`0.2.0` 支持三个导航方法共用外观字段,宿主可设置 `navigationBarAppearance` 默认主题;打开或替换页面时,目标页首帧前即应用外观。按钮背景开关仅 iOS 26 及以上支持,Android 请省略。详见[原生导航栏外观](../docs/navigation-bar.md)。
|
package/dist/assembleMWB.d.ts
CHANGED
package/dist/bridge.d.ts
CHANGED
package/dist/createMWB.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type MWBPlugin, type MWBSDK, type MWBPartialSDK } from "./assembleMWB";
|
|
2
|
-
import { type MWBNativePlugin, type NativePluginNamespaces } from "./nativePlugins";
|
|
3
|
-
export type { MWBPlugin } from "./assembleMWB";
|
|
4
|
-
export type { MWBSDK, MWBBasic } from "./assembleMWB";
|
|
5
|
-
export { defineNativePlugin } from "./nativePlugins";
|
|
6
|
-
export type { MWBNativePlugin } from "./nativePlugins";
|
|
1
|
+
import { type MWBPlugin, type MWBSDK, type MWBPartialSDK } from "./assembleMWB.js";
|
|
2
|
+
import { type MWBNativePlugin, type NativePluginNamespaces } from "./nativePlugins.js";
|
|
3
|
+
export type { MWBPlugin } from "./assembleMWB.js";
|
|
4
|
+
export type { MWBSDK, MWBBasic } from "./assembleMWB.js";
|
|
5
|
+
export { defineNativePlugin } from "./nativePlugins.js";
|
|
6
|
+
export type { MWBNativePlugin } from "./nativePlugins.js";
|
|
7
7
|
export type MWBClient = MWBSDK & {
|
|
8
8
|
hasPlugin(name: string): Promise<boolean>;
|
|
9
9
|
};
|
package/dist/eventHub.d.ts
CHANGED
package/dist/events.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MWBJSSDK } from "./types";
|
|
1
|
+
import type { MWBJSSDK } from "./types.js";
|
|
2
2
|
/** DSBridge 只保留一个注册函数;多监听器和解绑由这一层管理。 */
|
|
3
3
|
export declare function createEvents(): Pick<MWBJSSDK, "registerHandler" | "unRegisterHandlers" | "unRegisterHandler" | "checkHandlerExist" | "onNetworkStatusChange" | "offNetworkStatusChange" | "onAppShow" | "offAppShow" | "onAppHide" | "offAppHide" | "onRemoteNotificationReceive" | "offRemoteNotificationReceive" | "onPageShow" | "offPageShow" | "onPageHide" | "offPageHide" | "onBackBtnPressed" | "offBackBtnPressed">;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** 默认入口组合全部能力,同时保留按功能组合的构造函数。 */
|
|
2
2
|
import "dsbridge";
|
|
3
|
-
export { createMWB, defineNativePlugin } from "./createMWB";
|
|
4
|
-
export type { MWBPlugin, MWBNativePlugin, MWBClient, MWBSDK, MWBBasic } from "./createMWB";
|
|
5
|
-
export { MWBBridgeError } from "./bridge";
|
|
6
|
-
export * from "./types";
|
|
7
|
-
export { containerPlugin } from "./plugins/container";
|
|
8
|
-
export { devicePlugin } from "./plugins/device";
|
|
9
|
-
export { mediaPlugin } from "./plugins/media";
|
|
10
|
-
export { storagePlugin } from "./plugins/storage";
|
|
11
|
-
export { basicPlugin } from "./plugins/basic";
|
|
12
|
-
import type { MWBClient } from "./createMWB";
|
|
3
|
+
export { createMWB, defineNativePlugin } from "./createMWB.js";
|
|
4
|
+
export type { MWBPlugin, MWBNativePlugin, MWBClient, MWBSDK, MWBBasic } from "./createMWB.js";
|
|
5
|
+
export { MWBBridgeError } from "./bridge.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export { containerPlugin } from "./plugins/container.js";
|
|
8
|
+
export { devicePlugin } from "./plugins/device.js";
|
|
9
|
+
export { mediaPlugin } from "./plugins/media.js";
|
|
10
|
+
export { storagePlugin } from "./plugins/storage.js";
|
|
11
|
+
export { basicPlugin } from "./plugins/basic.js";
|
|
12
|
+
import type { MWBClient } from "./createMWB.js";
|
|
13
13
|
declare global {
|
|
14
14
|
interface Window {
|
|
15
15
|
mwb: MWBClient;
|
package/dist/index.js
CHANGED
package/dist/mwb.iife.js
CHANGED
package/dist/nativePlugins.d.ts
CHANGED
package/dist/plugins/basic.d.ts
CHANGED
|
@@ -6,33 +6,33 @@ export declare const basicPlugin: {
|
|
|
6
6
|
readonly getStorageSync: <T>(key: string, groupName?: string) => T | undefined;
|
|
7
7
|
readonly removeStorageSync: (key: string, groupName: string | undefined) => void;
|
|
8
8
|
readonly clearStorageSync: (groupName: string | undefined) => void;
|
|
9
|
-
readonly compressImage: (param: import("
|
|
10
|
-
readonly scanCode: (param: import("
|
|
11
|
-
readonly saveImageToPhotosAlbum: (param: import("
|
|
12
|
-
readonly chooseImage: (param: import("
|
|
13
|
-
readonly openFile: (param: import("
|
|
14
|
-
readonly checkRequestCameraPermissions: (param: import("
|
|
15
|
-
readonly convertImagePathToBase64: (param: import("
|
|
16
|
-
readonly openAppAuthorizeSetting: () => Promise<import("
|
|
17
|
-
readonly getAppInfoSync: () => import("
|
|
18
|
-
readonly setBadgeCount: (param: import("
|
|
19
|
-
readonly getDeviceInfoSync: () => import("
|
|
20
|
-
readonly getClipboardDataSync: () => import("
|
|
21
|
-
readonly setClipboardData: (param: import("
|
|
22
|
-
readonly makePhoneCall: (param: import("
|
|
23
|
-
readonly getNetworkTypeSync: () => import("
|
|
24
|
-
readonly getNotificationSwitchStatus: () => Promise<import("
|
|
25
|
-
readonly notifyPageReady: typeof import("../nativePlugins").notifyPageReady;
|
|
9
|
+
readonly compressImage: (param: import("../types.js").ParamCompressImage) => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnCompressImageResult>>;
|
|
10
|
+
readonly scanCode: (param: import("../types.js").ParamScanCode) => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnScanCode>>;
|
|
11
|
+
readonly saveImageToPhotosAlbum: (param: import("../types.js").ParamImageToPhotosAlbum) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
12
|
+
readonly chooseImage: (param: import("../types.js").ParamChooseImage) => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnChooseImageResult>>;
|
|
13
|
+
readonly openFile: (param: import("../types.js").ParamOpenFileInfo | undefined) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
14
|
+
readonly checkRequestCameraPermissions: (param: import("../types.js").ParamCheckRequestCameraPermissions | undefined) => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnPermissionResult>>;
|
|
15
|
+
readonly convertImagePathToBase64: (param: import("../types.js").ParamConvertImagePathToBase64 | undefined) => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnConvertImagePathToBase64Result>>;
|
|
16
|
+
readonly openAppAuthorizeSetting: () => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
17
|
+
readonly getAppInfoSync: () => import("../types.js").ReturnAppInfo;
|
|
18
|
+
readonly setBadgeCount: (param: import("../types.js").ParamBadgeCount) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
19
|
+
readonly getDeviceInfoSync: () => import("../types.js").ReturnDeviceInfo;
|
|
20
|
+
readonly getClipboardDataSync: () => import("../types.js").ClipboardData;
|
|
21
|
+
readonly setClipboardData: (param: import("../types.js").ClipboardData) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
22
|
+
readonly makePhoneCall: (param: import("../types.js").ParamPhoneCall) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
23
|
+
readonly getNetworkTypeSync: () => import("../types.js").ReturnNetworkType;
|
|
24
|
+
readonly getNotificationSwitchStatus: () => Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnNotiSwitchStatus>>;
|
|
25
|
+
readonly notifyPageReady: typeof import("../nativePlugins.js").notifyPageReady;
|
|
26
26
|
readonly setEnableDebug: (enabled: boolean) => void;
|
|
27
|
-
readonly toast: (param: import("
|
|
28
|
-
readonly navigateTo: (param: import("
|
|
29
|
-
readonly redirectTo: (param: import("
|
|
30
|
-
readonly navigateBack: (callbackInfo: Record<string, any> | undefined) => Promise<import("
|
|
31
|
-
readonly navigateBackToRoot: () => Promise<import("
|
|
32
|
-
readonly openExternalBrowser: (param: import("
|
|
33
|
-
readonly setNavigationBarTheme: (param: import("
|
|
34
|
-
readonly cleanWebviewCache: () => Promise<import("
|
|
35
|
-
readonly exitApp: () => Promise<import("
|
|
36
|
-
readonly openNativePage: (param: import("
|
|
27
|
+
readonly toast: (param: import("../types.js").ParamToast) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
28
|
+
readonly navigateTo: (param: import("../types.js").ParamNavigateTo) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
29
|
+
readonly redirectTo: (param: import("../types.js").ParamRedirectTo) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
30
|
+
readonly navigateBack: (callbackInfo: Record<string, any> | undefined) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
31
|
+
readonly navigateBackToRoot: () => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
32
|
+
readonly openExternalBrowser: (param: import("../types.js").ParamExternalBrowse) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
33
|
+
readonly setNavigationBarTheme: (param: import("../types.js").ParamNavigationBarTheme) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
34
|
+
readonly cleanWebviewCache: () => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
35
|
+
readonly exitApp: () => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
36
|
+
readonly openNativePage: (param: import("../types.js").ParamOpenAppPage) => Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { notifyPageReady } from "../nativePlugins";
|
|
1
|
+
import { notifyPageReady } from "../nativePlugins.js";
|
|
2
2
|
/** Web 容器和页面导航能力。 */
|
|
3
3
|
export declare const containerPlugin: {
|
|
4
4
|
readonly name: "container";
|
|
5
5
|
readonly methods: {
|
|
6
6
|
notifyPageReady: typeof notifyPageReady;
|
|
7
7
|
setEnableDebug(enabled: boolean): void;
|
|
8
|
-
toast(param: import("
|
|
9
|
-
navigateTo(param: import("
|
|
10
|
-
redirectTo(param: import("
|
|
11
|
-
navigateBack(callbackInfo: Record<string, any> | undefined): Promise<import("
|
|
12
|
-
navigateBackToRoot(): Promise<import("
|
|
13
|
-
openExternalBrowser(param: import("
|
|
14
|
-
setNavigationBarTheme(param: import("
|
|
15
|
-
cleanWebviewCache(): Promise<import("
|
|
16
|
-
exitApp(): Promise<import("
|
|
17
|
-
openNativePage(param: import("
|
|
8
|
+
toast(param: import("../types.js").ParamToast): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
9
|
+
navigateTo(param: import("../types.js").ParamNavigateTo): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
10
|
+
redirectTo(param: import("../types.js").ParamRedirectTo): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
11
|
+
navigateBack(callbackInfo: Record<string, any> | undefined): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
12
|
+
navigateBackToRoot(): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
13
|
+
openExternalBrowser(param: import("../types.js").ParamExternalBrowse): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
14
|
+
setNavigationBarTheme(param: import("../types.js").ParamNavigationBarTheme): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
15
|
+
cleanWebviewCache(): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
16
|
+
exitApp(): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
17
|
+
openNativePage(param: import("../types.js").ParamOpenAppPage): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
18
18
|
};
|
|
19
19
|
};
|
package/dist/plugins/device.d.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const devicePlugin: {
|
|
3
3
|
readonly name: "device";
|
|
4
4
|
readonly methods: {
|
|
5
|
-
openAppAuthorizeSetting(): Promise<import("
|
|
6
|
-
getAppInfoSync(): import("
|
|
7
|
-
setBadgeCount(param: import("
|
|
8
|
-
getDeviceInfoSync(): import("
|
|
9
|
-
getClipboardDataSync(): import("
|
|
10
|
-
setClipboardData(param: import("
|
|
11
|
-
makePhoneCall(param: import("
|
|
12
|
-
getNetworkTypeSync(): import("
|
|
13
|
-
getNotificationSwitchStatus(): Promise<import("
|
|
5
|
+
openAppAuthorizeSetting(): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
6
|
+
getAppInfoSync(): import("../types.js").ReturnAppInfo;
|
|
7
|
+
setBadgeCount(param: import("../types.js").ParamBadgeCount): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
8
|
+
getDeviceInfoSync(): import("../types.js").ReturnDeviceInfo;
|
|
9
|
+
getClipboardDataSync(): import("../types.js").ClipboardData;
|
|
10
|
+
setClipboardData(param: import("../types.js").ClipboardData): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
11
|
+
makePhoneCall(param: import("../types.js").ParamPhoneCall): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
12
|
+
getNetworkTypeSync(): import("../types.js").ReturnNetworkType;
|
|
13
|
+
getNotificationSwitchStatus(): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnNotiSwitchStatus>>;
|
|
14
14
|
};
|
|
15
15
|
};
|
package/dist/plugins/media.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
export declare const mediaPlugin: {
|
|
3
3
|
readonly name: "media";
|
|
4
4
|
readonly methods: {
|
|
5
|
-
compressImage(param: import("
|
|
6
|
-
scanCode(param: import("
|
|
7
|
-
saveImageToPhotosAlbum(param: import("
|
|
8
|
-
chooseImage(param: import("
|
|
9
|
-
openFile(param: import("
|
|
10
|
-
checkRequestCameraPermissions(param: import("
|
|
11
|
-
convertImagePathToBase64(param: import("
|
|
5
|
+
compressImage(param: import("../types.js").ParamCompressImage): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnCompressImageResult>>;
|
|
6
|
+
scanCode(param: import("../types.js").ParamScanCode): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnScanCode>>;
|
|
7
|
+
saveImageToPhotosAlbum(param: import("../types.js").ParamImageToPhotosAlbum): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
8
|
+
chooseImage(param: import("../types.js").ParamChooseImage): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnChooseImageResult>>;
|
|
9
|
+
openFile(param: import("../types.js").ParamOpenFileInfo | undefined): Promise<import("../types.js").GenericAsyncResult<undefined>>;
|
|
10
|
+
checkRequestCameraPermissions(param: import("../types.js").ParamCheckRequestCameraPermissions | undefined): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnPermissionResult>>;
|
|
11
|
+
convertImagePathToBase64(param: import("../types.js").ParamConvertImagePathToBase64 | undefined): Promise<import("../types.js").GenericAsyncResult<import("../types.js").ReturnConvertImagePathToBase64Result>>;
|
|
12
12
|
};
|
|
13
13
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.2.0";
|
|
2
2
|
type TYPE_VERSION = typeof version;
|
|
3
3
|
export type GenericAsyncResult<T = any> = {
|
|
4
4
|
errCode: number;
|
|
@@ -114,19 +114,19 @@ export type ParamPhoneCall = {
|
|
|
114
114
|
};
|
|
115
115
|
export type ParamScanCode = {
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
117
|
+
* 扫码类型:qrCode 为二维码,barCode 为条形码。省略时识别两类。
|
|
118
118
|
**/
|
|
119
119
|
scanType?: ScanType[];
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* 是否隐藏相册。省略时 iOS 显示、Android 隐藏;显式传入 false 可选图识别。
|
|
122
122
|
**/
|
|
123
123
|
hideAlbum?: boolean;
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
125
|
+
* 兼容字段,目前不自定义系统相机权限提示标题。
|
|
126
126
|
**/
|
|
127
127
|
permissionPromptTitle?: string;
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* 兼容字段,目前不自定义系统相机权限提示内容。
|
|
130
130
|
**/
|
|
131
131
|
permissionPromptMessage?: string;
|
|
132
132
|
};
|