@webview-bridge/web 1.0.2 → 1.0.4

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.
@@ -1,7 +1,7 @@
1
- import { WithAvailable } from "./types";
2
- export interface LinkNativeMethodOptions<T extends object> {
1
+ import { Bridge, WithAvailable } from "./types";
2
+ export interface LinkNativeMethodOptions<BridgeObject extends Bridge> {
3
3
  timeout?: number;
4
- throwOnError?: boolean | (keyof T)[];
5
- onFallback?: (method: keyof T) => void;
4
+ throwOnError?: boolean | (keyof BridgeObject)[];
5
+ onFallback?: (method: keyof BridgeObject) => void;
6
6
  }
7
- export declare const linkNativeMethod: <T extends object>(options?: LinkNativeMethodOptions<T>) => WithAvailable<T>;
7
+ export declare const linkNativeMethod: <BridgeObject extends Bridge>(options?: LinkNativeMethodOptions<BridgeObject>) => WithAvailable<BridgeObject>;
@@ -1,2 +1,2 @@
1
1
  import type { Bridge } from "./types";
2
- export declare const registerWebMethod: Bridge;
2
+ export declare const registerWebMethod: <BridgeObject extends Bridge>(bridge: BridgeObject) => BridgeObject;
@@ -1,8 +1,5 @@
1
- export type Procedure = (...args: any[]) => any;
2
- export type ProceduresObject<T extends Record<string, Procedure>> = {
3
- [K in keyof T]: (...args: Parameters<T[K]>) => Promise<Awaited<ReturnType<T[K]>>>;
4
- };
5
- export type Bridge = <T extends Record<string, Procedure>>(procedures: T) => ProceduresObject<T>;
1
+ export type AsyncFunction = (...args: any[]) => Promise<any>;
2
+ export type Bridge = Record<string, AsyncFunction>;
6
3
  export type WithAvailable<T> = {
7
4
  isWebViewBridgeAvailable: boolean;
8
5
  } & T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webview-bridge/web",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "Integration Web and React Native WebView",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -20,9 +20,14 @@
20
20
  "types": "/dist/typescript/packages/web/src/index.d.ts",
21
21
  "exports": {
22
22
  ".": {
23
- "import": "./dist/module/index.mjs",
24
- "require": "./dist/commonjs/index.cjs",
25
- "types": "./dist/typescript/packages/web/src/index.d.ts"
23
+ "require": {
24
+ "default": "./dist/commonjs/index.cjs",
25
+ "types": "./dist/typescript/packages/web/src/index.d.cts"
26
+ },
27
+ "import": {
28
+ "default": "./dist/module/index.mjs",
29
+ "types": "./dist/typescript/packages/web/src/index.d.ts"
30
+ }
26
31
  }
27
32
  },
28
33
  "devDependencies": {
@@ -1,3 +0,0 @@
1
- export declare const createNativeMethod: <T = unknown>(options?: {
2
- timeout: number;
3
- }) => T;
@@ -1,2 +0,0 @@
1
- import type { Bridge } from "./types";
2
- export declare const createWebMethod: Bridge;
@@ -1,5 +0,0 @@
1
- export type Procedure = (...args: any[]) => any;
2
- export type ProceduresObject<T extends Record<string, Procedure>> = {
3
- [K in keyof T]: (...args: Parameters<T[K]>) => Promise<Awaited<ReturnType<T[K]>>>;
4
- };
5
- export type Bridge = <T extends Record<string, Procedure>>(procedures: T) => ProceduresObject<T>;