@webview-bridge/web 1.7.3 → 1.7.5

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/dist/index.cjs CHANGED
@@ -733,7 +733,8 @@ var BridgeInstance = /*#__PURE__*/ function() {
733
733
  var linkBridge = function() {
734
734
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
735
735
  timeout: 2e3,
736
- throwOnError: false
736
+ throwOnError: false,
737
+ debug: false
737
738
  };
738
739
  if (typeof window === "undefined") {
739
740
  var _options_initialBridge;
@@ -758,12 +759,15 @@ var linkBridge = function() {
758
759
  store: mockStore(options === null || options === void 0 ? void 0 : options.initialBridge)
759
760
  };
760
761
  }
761
- if (!window.ReactNativeWebView) {
762
+ if (options.debug && !window.ReactNativeWebView) {
762
763
  console.warn("[WebViewBridge] Not in a WebView environment");
763
764
  }
764
765
  var bridgeId = (0, import_utils3.createRandomId)();
765
766
  var emitter = (0, import_utils3.createEvents)();
766
- window.nativeEmitter = _object_spread_props(_object_spread({}, window.nativeEmitter || {}), _define_property({}, bridgeId, emitter));
767
+ window.nativeEmitterMap = _object_spread_props(_object_spread({}, window.nativeEmitterMap || {}), _define_property({}, bridgeId, emitter));
768
+ if (!window.nativeEmitter) {
769
+ window.nativeEmitter = emitter;
770
+ }
767
771
  var _window___bridgeMethods__;
768
772
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
769
773
  var _window___bridgeInitialState__;
@@ -794,7 +798,9 @@ var linkBridge = function() {
794
798
  return Promise.reject(new MethodNotFoundError(methodName));
795
799
  };
796
800
  }
797
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
801
+ if (options.debug) {
802
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
803
+ }
798
804
  return function() {
799
805
  return Promise.resolve();
800
806
  };
package/dist/index.d.cts CHANGED
@@ -23,6 +23,11 @@ type LinkBridge<T, U, V extends ParserSchema<any>> = {
23
23
  } & T;
24
24
 
25
25
  interface LinkBridgeOptions<T extends BridgeStore<T extends Bridge ? T : any>, V extends ParserSchema<any>> {
26
+ /**
27
+ * If `true`, console warnings will be displayed.
28
+ * @default false
29
+ */
30
+ debug?: boolean;
26
31
  /**
27
32
  * It is possible to configure `initialBridge` to operate in a non-React Native environment.
28
33
  * Prioritize applying the bridge of the React Native WebView, and if it is unavailable, apply the `initialBridge`.
package/dist/index.d.ts CHANGED
@@ -23,6 +23,11 @@ type LinkBridge<T, U, V extends ParserSchema<any>> = {
23
23
  } & T;
24
24
 
25
25
  interface LinkBridgeOptions<T extends BridgeStore<T extends Bridge ? T : any>, V extends ParserSchema<any>> {
26
+ /**
27
+ * If `true`, console warnings will be displayed.
28
+ * @default false
29
+ */
30
+ debug?: boolean;
26
31
  /**
27
32
  * It is possible to configure `initialBridge` to operate in a non-React Native environment.
28
33
  * Prioritize applying the bridge of the React Native WebView, and if it is unavailable, apply the `initialBridge`.
package/dist/index.js CHANGED
@@ -673,7 +673,8 @@ var BridgeInstance = /*#__PURE__*/ function() {
673
673
  var linkBridge = function() {
674
674
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
675
675
  timeout: 2e3,
676
- throwOnError: false
676
+ throwOnError: false,
677
+ debug: false
677
678
  };
678
679
  if (typeof window === "undefined") {
679
680
  var _options_initialBridge;
@@ -698,12 +699,15 @@ var linkBridge = function() {
698
699
  store: mockStore(options === null || options === void 0 ? void 0 : options.initialBridge)
699
700
  };
700
701
  }
701
- if (!window.ReactNativeWebView) {
702
+ if (options.debug && !window.ReactNativeWebView) {
702
703
  console.warn("[WebViewBridge] Not in a WebView environment");
703
704
  }
704
705
  var bridgeId = createRandomId2();
705
706
  var emitter = createEvents();
706
- window.nativeEmitter = _object_spread_props(_object_spread({}, window.nativeEmitter || {}), _define_property({}, bridgeId, emitter));
707
+ window.nativeEmitterMap = _object_spread_props(_object_spread({}, window.nativeEmitterMap || {}), _define_property({}, bridgeId, emitter));
708
+ if (!window.nativeEmitter) {
709
+ window.nativeEmitter = emitter;
710
+ }
707
711
  var _window___bridgeMethods__;
708
712
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
709
713
  var _window___bridgeInitialState__;
@@ -734,7 +738,9 @@ var linkBridge = function() {
734
738
  return Promise.reject(new MethodNotFoundError(methodName));
735
739
  };
736
740
  }
737
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
741
+ if (options.debug) {
742
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
743
+ }
738
744
  return function() {
739
745
  return Promise.resolve();
740
746
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webview-bridge/web",
3
3
  "type": "module",
4
- "version": "1.7.3",
4
+ "version": "1.7.5",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -26,8 +26,8 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@webview-bridge/utils": "1.7.3",
30
- "@webview-bridge/types": "1.7.3"
29
+ "@webview-bridge/utils": "1.7.5",
30
+ "@webview-bridge/types": "1.7.5"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --format cjs,esm --dts --target es5",