@webview-bridge/react-native 1.1.0 → 1.1.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.
@@ -58,6 +58,11 @@ const createWebView = ({ bridge, debug, responseTimeout = 2000, fallback, }) =>
58
58
  emitter.emit(`${funcName}-${eventId}`, value);
59
59
  return;
60
60
  }
61
+ case "webMethodError": {
62
+ const { eventId, funcName } = body;
63
+ emitter.emit(`${funcName}-${eventId}`, {}, true);
64
+ return;
65
+ }
61
66
  case "fallback": {
62
67
  const { method } = body;
63
68
  fallback?.(method);
@@ -0,0 +1,3 @@
1
+ export declare class WebMethodError extends Error {
2
+ constructor(methodName: string);
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebMethodError = void 0;
4
+ class WebMethodError extends Error {
5
+ constructor(methodName) {
6
+ super(`An error occurred in the WebMethod.current.${methodName}`);
7
+ this.name = "WebMethodError";
8
+ }
9
+ }
10
+ exports.WebMethodError = WebMethodError;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleRegisterWebMethod = void 0;
4
4
  const util_1 = require("../../../../shared/util/src");
5
+ const error_1 = require("../error");
5
6
  const handleRegisterWebMethod = (emitter, webview, bridgeNames, responseTimeout) => {
6
7
  return bridgeNames.reduce((acc, method) => {
7
8
  acc[method] = async (...args) => {
@@ -13,7 +14,7 @@ const handleRegisterWebMethod = (emitter, webview, bridgeNames, responseTimeout)
13
14
 
14
15
  true;
15
16
  `);
16
- }),
17
+ }, new error_1.WebMethodError(method)),
17
18
  (0, util_1.timeout)(responseTimeout),
18
19
  ]);
19
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webview-bridge/react-native",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "main": "dist/packages/react-native/src/index.js",