mobile-web-bridge 0.1.5 → 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 CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  MWB 为 iOS 和 Android 的 Web 容器提供统一 JS API。原生通信由 DSBridge 3.x 完成。
4
4
 
5
- 当前版本为 `0.1.5`,与同一 Git Tag 下的 iOS/Android 源码配套。下方安装命令固定为 `0.1.5`;分发状态见 [版本说明](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/versioning.md),需要本地构建时可按 [源码构建与安装](https://github.com/gaoxiao228/MobileWebBridge#从源码构建-js-sdk) 使用。
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.1.5
15
+ npm install mobile-web-bridge@0.2.0
14
16
  ```
15
17
 
16
18
  ```ts
@@ -32,7 +34,7 @@ await mwb.setNavigationBarTheme({
32
34
  });
33
35
  ```
34
36
 
35
- 再次设置会替换原回调;传入 `actionTxt: ""` 可移除按钮。`onActionClick` 不会序列化传给原生,原生点击时只回传 `actionExt`。目前 iOS、Android 均支持文字按钮,`actionIcon` 尚不支持。
37
+ 仅显式提供新 onActionClick 才替换原回调;局部颜色、显隐或 actionExt 更新保留 handler;传入 `actionTxt: ""` 可移除按钮。`onActionClick` 不会序列化传给原生,原生点击时只回传 `actionExt`。目前 iOS、Android 均支持文字按钮,`actionIcon` 尚不支持。
36
38
 
37
39
  网页也可直接引入发布包中的 `dist/mwb.iife.js`,通过 `window.mwb` 调用。应在 MWB 原生容器内加载;普通浏览器中的原生调用会给出“桥未就绪”错误。
38
40
 
@@ -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.1.5`。此方法走文档身份网关,等待上限 30000ms;旧原生和普通浏览器明确失败。调用时机、原生回调和重载规则见 [接入说明](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/page-lifecycle.md)。
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
 
@@ -97,7 +99,7 @@ Promise 完成仅表示该方法约定的操作完成:`navigateTo` 默认在
97
99
 
98
100
  当前 iOS 源码可传 `await mwb.navigateTo({ url: childURL, waitForReady: true })`,由 SDK 自动等待主文档加载及 WebKit 绘制准备后再发起原系统转场;无需 H5 报告 ready。参数默认 `false`,Android 应省略此参数。总等待 3000 ms,加载/绘制失败或超时拒绝为 `-1002`,源页离开或后台取消为 `-1005`,同源已有准备请求为 `-1004`,非布尔值为 `-1001`。源文档失效后旧回复丢弃。成功不表示动画结束或异步业务数据完成,详见 [iOS 接入说明](../MWB-iOS/README.md)。
99
101
 
100
- 当前源码另新增 `redirectTo`,与 `mwb.basic.redirectTo` 共用函数:替换当前容器,返回时跳过旧页。两端可立即替换;`waitForReady` 仅 iOS 支持,Android 必须省略。旧页成功替换后会销毁,后续业务在目标页初始化,不依赖旧页成功回调继续运行;完整参数和平台边界见[页面打开与替换](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/navigation.md)。此方法自 `0.1.5` 提供,需同步升级 JS 与原生 SDK。
102
+ `redirectTo` 与 `mwb.basic.redirectTo` 共用函数,用于替换当前容器,返回时跳过旧页。两端可立即替换;`waitForReady` 仅 iOS 支持,Android 必须省略。旧页成功替换后会销毁,后续业务在目标页初始化,不依赖旧页成功回调继续运行;完整参数和平台边界见[页面打开与替换](https://github.com/gaoxiao228/MobileWebBridge/blob/main/docs/navigation.md)。此方法自 `0.1.5` 提供,需同步升级 JS 与原生 SDK。
101
103
 
102
104
  除新增 `notifyPageReady()` 外,既有 basic 异步调用没有统一超时及文档失效兜底;原生未回调时可能持续等待。业务添加等待超时只会停止自己的等待,不代表原生操作已取消;支付等操作尤其不能据超时推断业务失败或直接重试。
103
105
 
@@ -111,7 +113,7 @@ Promise 完成仅表示该方法约定的操作完成:`navigateTo` 默认在
111
113
 
112
114
  ## 插件组合与构建
113
115
 
114
- 当前源码默认提供 basic 的 50 个方法;已发布包为原有 48 个。源码分为 `container`、`device`、`media`、`storage` 四组;事件和 JS 句柄始终包含在 SDK 内。`basicPlugin` 为完整组合,`--plugins=basic` 可构建全量 basic;与旧分组混用时去重。原有 `createMWB(legacyPlugins)` 数组裁剪入口保留,只在 basic 下映射选中的方法。重复方法或覆盖 Core/事件入口的配置直接报错。
116
+ 当前源码默认提供 basic 的 50 个方法。源码分为 `container`、`device`、`media`、`storage` 四组;事件和 JS 句柄始终包含在 SDK 内。`basicPlugin` 为完整组合,`--plugins=basic` 可构建全量 basic;与旧分组混用时去重。原有 `createMWB(legacyPlugins)` 数组裁剪入口保留,只在 basic 下映射选中的方法。重复方法或覆盖 Core/事件入口的配置直接报错。
115
117
 
116
118
  ```bash
117
119
  pnpm install
@@ -169,3 +171,5 @@ if (await sdk.hasPlugin("network")) {
169
171
  MWB 的通信底层基于 [DSBridge](https://github.com/wendux/DSBridge-Android)(MIT)。接口能力参考当前工作区的旧项目,MWB 不依赖 Cordova。
170
172
 
171
173
  包内包含 LICENSE 和 THIRD_PARTY_NOTICES.md,ESM/IIFE/组合脚本保留完整许可注释;单独分发 bundle 时也不要移除这些注释。
174
+
175
+ `0.2.0` 支持三个导航方法共用外观字段,宿主可设置 `navigationBarAppearance` 默认主题;打开或替换页面时,目标页首帧前即应用外观。按钮背景开关仅 iOS 26 及以上支持,Android 请省略。详见[原生导航栏外观](../docs/navigation-bar.md)。
@@ -1,4 +1,4 @@
1
- import { type MWBJSSDK } from "./types";
1
+ import { type MWBJSSDK } from "./types.js";
2
2
  /** 插件描述只包含所选功能,供浏览器组合包静态裁剪。 */
3
3
  export interface MWBPlugin {
4
4
  readonly name: string;
package/dist/bridge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GenericAsyncResult } from "./types";
1
+ import type { GenericAsyncResult } from "./types.js";
2
2
  /** DSBridge 的最小接口,便于把原生通信限制在一个文件内。 */
3
3
  export interface DSBridgeLike {
4
4
  call(method: string, args?: unknown, callback?: (value: unknown) => void): unknown;
@@ -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
  };
@@ -1,4 +1,4 @@
1
- import type { DSBridgeLike } from "./bridge";
1
+ import type { DSBridgeLike } from "./bridge.js";
2
2
  type Handler = (...args: unknown[]) => unknown;
3
3
  /** 同一 bridge 只注册一次原生接收器,避免默认 SDK 和业务组合实例相互覆盖。 */
4
4
  declare class EventHub {
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
@@ -222,7 +222,7 @@ var require_dsbridge = __commonJS({
222
222
  var import_dsbridge = __toESM(require_dsbridge(), 1);
223
223
 
224
224
  // src/types.ts
225
- var version = "0.1.5";
225
+ var version = "0.2.0";
226
226
 
227
227
  // src/eventHub.ts
228
228
  var hubs = /* @__PURE__ */ new WeakMap();
@@ -408,16 +408,24 @@ function assembleMWB(plugins) {
408
408
  const nativeSetTheme = methods.setNavigationBarTheme;
409
409
  if (nativeSetTheme) {
410
410
  let currentActionClick;
411
+ let themeQueue = Promise.resolve();
411
412
  methods.setNavigationBarTheme = async (param) => {
412
413
  const { onActionClick, ...nativeParam } = param;
413
- const result = await nativeSetTheme(nativeParam);
414
- if (currentActionClick) events.unRegisterHandler("navigationActionClick", currentActionClick);
415
- currentActionClick = void 0;
416
- if (nativeParam.actionTxt?.trim() && onActionClick) {
417
- events.registerHandler("navigationActionClick", onActionClick);
418
- currentActionClick = onActionClick;
414
+ if (onActionClick !== void 0 && typeof onActionClick !== "function") {
415
+ throw new TypeError("onActionClick must be a function");
419
416
  }
420
- return result;
417
+ const request = themeQueue.then(async () => {
418
+ const result = await nativeSetTheme(nativeParam);
419
+ const clearsAction = typeof nativeParam.actionTxt === "string" && !nativeParam.actionTxt.trim();
420
+ if (clearsAction || onActionClick !== void 0) {
421
+ if (currentActionClick) events.unRegisterHandler("navigationActionClick", currentActionClick);
422
+ currentActionClick = clearsAction ? void 0 : onActionClick;
423
+ if (currentActionClick) events.registerHandler("navigationActionClick", currentActionClick);
424
+ }
425
+ return result;
426
+ });
427
+ themeQueue = request.catch(() => void 0);
428
+ return request;
421
429
  };
422
430
  }
423
431
  const basic = Object.freeze({ ...methods, ...events });
package/dist/mwb.iife.js CHANGED
@@ -224,7 +224,7 @@ SOFTWARE.
224
224
  var import_dsbridge = __toESM(require_dsbridge(), 1);
225
225
 
226
226
  // src/types.ts
227
- var version = "0.1.5";
227
+ var version = "0.2.0";
228
228
 
229
229
  // src/eventHub.ts
230
230
  var hubs = /* @__PURE__ */ new WeakMap();
@@ -410,16 +410,24 @@ SOFTWARE.
410
410
  const nativeSetTheme = methods.setNavigationBarTheme;
411
411
  if (nativeSetTheme) {
412
412
  let currentActionClick;
413
+ let themeQueue = Promise.resolve();
413
414
  methods.setNavigationBarTheme = async (param) => {
414
415
  const { onActionClick, ...nativeParam } = param;
415
- const result = await nativeSetTheme(nativeParam);
416
- if (currentActionClick) events.unRegisterHandler("navigationActionClick", currentActionClick);
417
- currentActionClick = void 0;
418
- if (nativeParam.actionTxt?.trim() && onActionClick) {
419
- events.registerHandler("navigationActionClick", onActionClick);
420
- currentActionClick = onActionClick;
416
+ if (onActionClick !== void 0 && typeof onActionClick !== "function") {
417
+ throw new TypeError("onActionClick must be a function");
421
418
  }
422
- return result;
419
+ const request = themeQueue.then(async () => {
420
+ const result = await nativeSetTheme(nativeParam);
421
+ const clearsAction = typeof nativeParam.actionTxt === "string" && !nativeParam.actionTxt.trim();
422
+ if (clearsAction || onActionClick !== void 0) {
423
+ if (currentActionClick) events.unRegisterHandler("navigationActionClick", currentActionClick);
424
+ currentActionClick = clearsAction ? void 0 : onActionClick;
425
+ if (currentActionClick) events.registerHandler("navigationActionClick", currentActionClick);
426
+ }
427
+ return result;
428
+ });
429
+ themeQueue = request.catch(() => void 0);
430
+ return request;
423
431
  };
424
432
  }
425
433
  const basic = Object.freeze({ ...methods, ...events });
@@ -1,4 +1,4 @@
1
- import type { GenericAsyncResult } from "./types";
1
+ import type { GenericAsyncResult } from "./types.js";
2
2
  declare const descriptorBrand: unique symbol;
3
3
  type AsyncMethods<T> = {
4
4
  [K in keyof T]: (params: never) => Promise<GenericAsyncResult<unknown>>;
@@ -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("..").ParamCompressImage) => Promise<import("..").GenericAsyncResult<import("..").ReturnCompressImageResult>>;
10
- readonly scanCode: (param: import("..").ParamScanCode) => Promise<import("..").GenericAsyncResult<import("..").ReturnScanCode>>;
11
- readonly saveImageToPhotosAlbum: (param: import("..").ParamImageToPhotosAlbum) => Promise<import("..").GenericAsyncResult<undefined>>;
12
- readonly chooseImage: (param: import("..").ParamChooseImage) => Promise<import("..").GenericAsyncResult<import("..").ReturnChooseImageResult>>;
13
- readonly openFile: (param: import("..").ParamOpenFileInfo | undefined) => Promise<import("..").GenericAsyncResult<undefined>>;
14
- readonly checkRequestCameraPermissions: (param: import("..").ParamCheckRequestCameraPermissions | undefined) => Promise<import("..").GenericAsyncResult<import("..").ReturnPermissionResult>>;
15
- readonly convertImagePathToBase64: (param: import("..").ParamConvertImagePathToBase64 | undefined) => Promise<import("..").GenericAsyncResult<import("..").ReturnConvertImagePathToBase64Result>>;
16
- readonly openAppAuthorizeSetting: () => Promise<import("..").GenericAsyncResult<undefined>>;
17
- readonly getAppInfoSync: () => import("..").ReturnAppInfo;
18
- readonly setBadgeCount: (param: import("..").ParamBadgeCount) => Promise<import("..").GenericAsyncResult<undefined>>;
19
- readonly getDeviceInfoSync: () => import("..").ReturnDeviceInfo;
20
- readonly getClipboardDataSync: () => import("..").ClipboardData;
21
- readonly setClipboardData: (param: import("..").ClipboardData) => Promise<import("..").GenericAsyncResult<undefined>>;
22
- readonly makePhoneCall: (param: import("..").ParamPhoneCall) => Promise<import("..").GenericAsyncResult<undefined>>;
23
- readonly getNetworkTypeSync: () => import("..").ReturnNetworkType;
24
- readonly getNotificationSwitchStatus: () => Promise<import("..").GenericAsyncResult<import("..").ReturnNotiSwitchStatus>>;
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("..").ParamToast) => Promise<import("..").GenericAsyncResult<undefined>>;
28
- readonly navigateTo: (param: import("..").ParamNavigateTo) => Promise<import("..").GenericAsyncResult<undefined>>;
29
- readonly redirectTo: (param: import("..").ParamRedirectTo) => Promise<import("..").GenericAsyncResult<undefined>>;
30
- readonly navigateBack: (callbackInfo: Record<string, any> | undefined) => Promise<import("..").GenericAsyncResult<undefined>>;
31
- readonly navigateBackToRoot: () => Promise<import("..").GenericAsyncResult<undefined>>;
32
- readonly openExternalBrowser: (param: import("..").ParamExternalBrowse) => Promise<import("..").GenericAsyncResult<undefined>>;
33
- readonly setNavigationBarTheme: (param: import("..").ParamNavigationBarTheme) => Promise<import("..").GenericAsyncResult<undefined>>;
34
- readonly cleanWebviewCache: () => Promise<import("..").GenericAsyncResult<undefined>>;
35
- readonly exitApp: () => Promise<import("..").GenericAsyncResult<undefined>>;
36
- readonly openNativePage: (param: import("..").ParamOpenAppPage) => Promise<import("..").GenericAsyncResult<undefined>>;
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("..").ParamToast): Promise<import("..").GenericAsyncResult<undefined>>;
9
- navigateTo(param: import("..").ParamNavigateTo): Promise<import("..").GenericAsyncResult<undefined>>;
10
- redirectTo(param: import("..").ParamRedirectTo): Promise<import("..").GenericAsyncResult<undefined>>;
11
- navigateBack(callbackInfo: Record<string, any> | undefined): Promise<import("..").GenericAsyncResult<undefined>>;
12
- navigateBackToRoot(): Promise<import("..").GenericAsyncResult<undefined>>;
13
- openExternalBrowser(param: import("..").ParamExternalBrowse): Promise<import("..").GenericAsyncResult<undefined>>;
14
- setNavigationBarTheme(param: import("..").ParamNavigationBarTheme): Promise<import("..").GenericAsyncResult<undefined>>;
15
- cleanWebviewCache(): Promise<import("..").GenericAsyncResult<undefined>>;
16
- exitApp(): Promise<import("..").GenericAsyncResult<undefined>>;
17
- openNativePage(param: import("..").ParamOpenAppPage): Promise<import("..").GenericAsyncResult<undefined>>;
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
  };
@@ -2,14 +2,14 @@
2
2
  export declare const devicePlugin: {
3
3
  readonly name: "device";
4
4
  readonly methods: {
5
- openAppAuthorizeSetting(): Promise<import("..").GenericAsyncResult<undefined>>;
6
- getAppInfoSync(): import("..").ReturnAppInfo;
7
- setBadgeCount(param: import("..").ParamBadgeCount): Promise<import("..").GenericAsyncResult<undefined>>;
8
- getDeviceInfoSync(): import("..").ReturnDeviceInfo;
9
- getClipboardDataSync(): import("..").ClipboardData;
10
- setClipboardData(param: import("..").ClipboardData): Promise<import("..").GenericAsyncResult<undefined>>;
11
- makePhoneCall(param: import("..").ParamPhoneCall): Promise<import("..").GenericAsyncResult<undefined>>;
12
- getNetworkTypeSync(): import("..").ReturnNetworkType;
13
- getNotificationSwitchStatus(): Promise<import("..").GenericAsyncResult<import("..").ReturnNotiSwitchStatus>>;
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
  };
@@ -2,12 +2,12 @@
2
2
  export declare const mediaPlugin: {
3
3
  readonly name: "media";
4
4
  readonly methods: {
5
- compressImage(param: import("..").ParamCompressImage): Promise<import("..").GenericAsyncResult<import("..").ReturnCompressImageResult>>;
6
- scanCode(param: import("..").ParamScanCode): Promise<import("..").GenericAsyncResult<import("..").ReturnScanCode>>;
7
- saveImageToPhotosAlbum(param: import("..").ParamImageToPhotosAlbum): Promise<import("..").GenericAsyncResult<undefined>>;
8
- chooseImage(param: import("..").ParamChooseImage): Promise<import("..").GenericAsyncResult<import("..").ReturnChooseImageResult>>;
9
- openFile(param: import("..").ParamOpenFileInfo | undefined): Promise<import("..").GenericAsyncResult<undefined>>;
10
- checkRequestCameraPermissions(param: import("..").ParamCheckRequestCameraPermissions | undefined): Promise<import("..").GenericAsyncResult<import("..").ReturnPermissionResult>>;
11
- convertImagePathToBase64(param: import("..").ParamConvertImagePathToBase64 | undefined): Promise<import("..").GenericAsyncResult<import("..").ReturnConvertImagePathToBase64Result>>;
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.5";
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;
@@ -31,8 +31,30 @@ export type ReturnStorageResult = {
31
31
  export type ParamStorageClear = {
32
32
  groupName?: string;
33
33
  };
34
+ /** 三个导航方法共享的可选原生外观;打开时在目标容器首帧前应用。 */
35
+ export type NavigationBarAppearanceOptions = {
36
+ /** 6 位十六进制背景色,可带 #。 */
37
+ color?: string;
38
+ /** 未显式设置 buttonColor 时,沿用标题和按钮同色的旧行为。 */
39
+ titleColor?: string;
40
+ /** 显式指定后,后续 titleColor 更新不再影响按钮。 */
41
+ buttonColor?: string;
42
+ /** 仅 iOS(26 起生效):false 隐藏系统按钮背景,true 恢复系统样式;Android 请省略。 */
43
+ buttonBackgroundVisible?: boolean;
44
+ backButtonStyle?: "text" | "arrow" | "arrowText";
45
+ /** 默认“返回”;不能是空白字符串。 */
46
+ backButtonText?: string;
47
+ showBackButton?: boolean;
48
+ separatorVisible?: boolean;
49
+ separatorColor?: string;
50
+ /** 系统缩放前字号,0 < size <= 32;iOS 缩放后上限 32pt。 */
51
+ titleFontSize?: number;
52
+ titleFontWeight?: "regular" | "medium" | "semibold" | "bold";
53
+ /** 系统缩放前字号,0 < size <= 28;iOS 缩放后上限 28pt。 */
54
+ buttonFontSize?: number;
55
+ };
34
56
  /** 替换当前原生容器;Android 必须省略 waitForReady,不支持创建新弹窗。 */
35
- export type ParamRedirectTo = {
57
+ export type ParamRedirectTo = NavigationBarAppearanceOptions & {
36
58
  /** 目标地址,沿用容器的可信来源限制。 */
37
59
  url: string;
38
60
  /** 新容器标题。 */
@@ -42,117 +64,49 @@ export type ParamRedirectTo = {
42
64
  /** 仅 iOS:等待主文档加载和绘制准备,默认 false;最多 3000ms,失败保留当前页。 */
43
65
  waitForReady?: boolean;
44
66
  };
45
- export type ParamNavigateTo = {
46
- /** 仅 iOS:SDK 等待主文档加载与绘制准备后转场,默认 false;最长等待 3000ms,不代表业务数据就绪。 */
47
- waitForReady?: boolean;
48
- /**
49
- * 跳转地址
50
- **/
67
+ export type ParamNavigateTo = NavigationBarAppearanceOptions & {
51
68
  url: string;
52
- /**
53
- * 是否隐藏导航栏,默认 true
54
- **/
69
+ /** 默认 true;样式参数不会自动显示导航栏。 */
55
70
  hidden?: boolean;
56
- /**
57
- * 导航栏标题
58
- **/
59
71
  title?: string;
60
- /**
61
- * 标题文字颜色,如 eeeeee
62
- **/
63
- titleColor?: string;
64
- /**
65
- * 导航栏颜色 如 eeeeee
66
- **/
67
- color?: string;
68
- /**
69
- * 是否是亮色主题 控制状态栏
70
- **/
72
+ /** 仅 iOS,默认 false;Android 必须省略。 */
73
+ waitForReady?: boolean;
74
+ /** 仅 iOS:打开新的原生导航弹窗。 */
75
+ isPopUp?: boolean;
76
+ /** @deprecated 打开方法不支持;由 Android 目标文档通过主题方法设置。 */
71
77
  isBright?: boolean;
72
- /**
73
- * 是否显示返回按钮
74
- **/
75
- showBackButton?: boolean;
76
- /**
77
- * 是否显示关闭按钮
78
- **/
78
+ /** @deprecated 打开方法不支持;由 Android 目标文档通过主题方法设置。 */
79
79
  showCloseButton?: boolean;
80
- /**
81
- * 右上角文字按钮
82
- **/
80
+ /** @deprecated 操作与回调由目标文档注册,不能从来源页传入。 */
83
81
  actionTxt?: string;
84
- /**
85
- * 右上角 icon base64
86
- **/
82
+ /** @deprecated 原生尚不支持图片按钮。 */
87
83
  actionIcon?: string;
88
- /**
89
- * 右上角 传参 点击的时候会回传给H5
90
- **/
84
+ /** @deprecated 操作载荷由目标文档设置。 */
91
85
  actionExt?: string;
92
- /**
93
- * 状态栏是否沉浸
94
- **/
86
+ /** @deprecated 原生不支持沉浸状态栏参数。 */
95
87
  translucentStatusBars?: boolean;
96
- /**
97
- * 打开新页面样式是否弹出
98
- **/
99
- isPopUp?: boolean;
100
- /**
101
- * 打开的新页面回调给当前页面的回调函数
102
- **/
88
+ /** @deprecated 原生不支持此回调参数;使用已有返回事件。 */
103
89
  callbackFunction?: GenericCallbackFunc | string;
104
90
  };
105
91
  export type ParamExternalBrowse = {
106
92
  url: string;
107
93
  };
108
- export type ParamNavigationBarTheme = {
109
- /**
110
- * 是否隐藏导航栏
111
- **/
94
+ export type ParamNavigationBarTheme = NavigationBarAppearanceOptions & {
112
95
  hidden?: boolean;
113
- /**
114
- * 导航栏标题
115
- **/
116
96
  title?: string;
117
- /**
118
- * 标题文字颜色,如 eeeeee
119
- **/
120
- titleColor?: string;
121
- /**
122
- * 导航栏颜色 如 eeeeee
123
- **/
124
- color?: string;
125
- /**
126
- * 是否是亮色主题 控制状态栏
127
- **/
97
+ /** 仅 Android:状态栏明暗。 */
128
98
  isBright?: boolean;
129
- /**
130
- * 是否显示返回按钮
131
- **/
132
- showBackButton?: boolean;
133
- /**
134
- * 是否显示关闭按钮
135
- **/
99
+ /** 仅 Android:显示关闭按钮。 */
136
100
  showCloseButton?: boolean;
137
- /**
138
- * 右上角文字按钮
139
- **/
140
101
  actionTxt?: string;
141
- /**
142
- * 右上角 icon base64
143
- **/
102
+ /** 原生尚不支持,传入会拒绝。 */
144
103
  actionIcon?: string;
145
- /**
146
- * 右上角 传参 点击的时候会回传给H5
147
- **/
148
104
  actionExt?: string;
149
- /** 当前页面右上角文字按钮被点击时执行;函数只由 JS SDK 保存。 */
105
+ /** 函数仅留在当前文档;局部外观更新保留现有 handler。 */
150
106
  onActionClick?: (data: {
151
107
  actionExt?: string;
152
108
  }) => void;
153
- /**
154
- * 状态栏是否沉浸
155
- **/
109
+ /** 原生尚不支持,传入会拒绝。 */
156
110
  translucentStatusBars?: boolean;
157
111
  };
158
112
  export type ParamPhoneCall = {
@@ -160,19 +114,19 @@ export type ParamPhoneCall = {
160
114
  };
161
115
  export type ParamScanCode = {
162
116
  /**
163
- * 扫码类型 qrCode:二维码 barCode:条形码
117
+ * 扫码类型:qrCode 为二维码,barCode 为条形码。省略时识别两类。
164
118
  **/
165
119
  scanType?: ScanType[];
166
120
  /**
167
- * 是否隐藏相册按钮 如果不隐藏,则可以通过选择相册里的二维码识别
121
+ * 是否隐藏相册。省略时 iOS 显示、Android 隐藏;显式传入 false 可选图识别。
168
122
  **/
169
123
  hideAlbum?: boolean;
170
124
  /**
171
- * 权限提示 标题 用于Android 提示
125
+ * 兼容字段,目前不自定义系统相机权限提示标题。
172
126
  **/
173
127
  permissionPromptTitle?: string;
174
128
  /**
175
- * 权限提示内容 用于Android 提示
129
+ * 兼容字段,目前不自定义系统相机权限提示内容。
176
130
  **/
177
131
  permissionPromptMessage?: string;
178
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-web-bridge",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Mobile Web Bridge JavaScript SDK",
5
5
  "author": "gaoxiao228",
6
6
  "repository": {