@webview-bridge/web 1.7.2 → 1.7.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.
package/dist/index.cjs CHANGED
@@ -541,9 +541,9 @@ var mockStore = function() {
541
541
  };
542
542
  // src/internal/bridgeInstance.ts
543
543
  var BridgeInstance = /*#__PURE__*/ function() {
544
- function BridgeInstance(_options, _emitter) {
545
- var _bridgeMethods = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], _nativeInitialState = arguments.length > 3 ? arguments[3] : void 0;
544
+ function BridgeInstance(_bridgeId, _options, _emitter, _bridgeMethods, _nativeInitialState) {
546
545
  _class_call_check(this, BridgeInstance);
546
+ this._bridgeId = _bridgeId;
547
547
  this._options = _options;
548
548
  this._emitter = _emitter;
549
549
  this._bridgeMethods = _bridgeMethods;
@@ -585,9 +585,11 @@ var BridgeInstance = /*#__PURE__*/ function() {
585
585
  var _window_ReactNativeWebView;
586
586
  (_window_ReactNativeWebView = window.ReactNativeWebView) === null || _window_ReactNativeWebView === void 0 ? void 0 : _window_ReactNativeWebView.postMessage(JSON.stringify(body ? {
587
587
  type: type,
588
- body: body
588
+ body: body,
589
+ bridgeId: this._bridgeId
589
590
  } : {
590
- type: type
591
+ type: type,
592
+ bridgeId: this._bridgeId
591
593
  }));
592
594
  }
593
595
  },
@@ -682,7 +684,7 @@ var BridgeInstance = /*#__PURE__*/ function() {
682
684
  value: nativeMethod,
683
685
  writable: false
684
686
  });
685
- return _object_spread_props(_object_spread({}, acc), _define_property({}, methodName, nativeMethod));
687
+ return Object.assign(acc, _define_property({}, methodName, nativeMethod));
686
688
  }, initialBridge);
687
689
  this.loose = this._createLoose(nativeMethods);
688
690
  this.store = linkBridgeStore(this._emitter, _object_spread({}, nativeMethods, nativeInitialState));
@@ -759,7 +761,9 @@ var linkBridge = function() {
759
761
  if (!window.ReactNativeWebView) {
760
762
  console.warn("[WebViewBridge] Not in a WebView environment");
761
763
  }
764
+ var bridgeId = (0, import_utils3.createRandomId)();
762
765
  var emitter = (0, import_utils3.createEvents)();
766
+ window.nativeEmitterMap = _object_spread_props(_object_spread({}, window.nativeEmitterMap || {}), _define_property({}, bridgeId, emitter));
763
767
  if (!window.nativeEmitter) {
764
768
  window.nativeEmitter = emitter;
765
769
  }
@@ -767,7 +771,7 @@ var linkBridge = function() {
767
771
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
768
772
  var _window___bridgeInitialState__;
769
773
  var nativeInitialState = (_window___bridgeInitialState__ = window.__bridgeInitialState__) !== null && _window___bridgeInitialState__ !== void 0 ? _window___bridgeInitialState__ : {};
770
- var instance = new BridgeInstance(options, emitter, bridgeMethods, nativeInitialState);
774
+ var instance = new BridgeInstance(bridgeId, options, emitter, bridgeMethods, nativeInitialState);
771
775
  if (bridgeMethods.length === 0) {
772
776
  var unsubscribe = emitter.on("hydrate", function(param) {
773
777
  var bridgeMethods2 = param.bridgeMethods, nativeInitialState2 = param.nativeInitialState;
@@ -792,9 +796,8 @@ var linkBridge = function() {
792
796
  onFallback === null || onFallback === void 0 ? void 0 : onFallback(methodName, args);
793
797
  return Promise.reject(new MethodNotFoundError(methodName));
794
798
  };
795
- } else {
796
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
797
799
  }
800
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
798
801
  return function() {
799
802
  return Promise.resolve();
800
803
  };
package/dist/index.js CHANGED
@@ -396,7 +396,7 @@ var NativeMethodError = /*#__PURE__*/ function(Error1) {
396
396
  return NativeMethodError;
397
397
  }(_wrap_native_super(Error));
398
398
  // src/linkBridge.ts
399
- import { createEvents } from "@webview-bridge/utils";
399
+ import { createEvents, createRandomId as createRandomId2 } from "@webview-bridge/utils";
400
400
  // src/internal/bridgeInstance.ts
401
401
  import { createRandomId, createResolver, timeout } from "@webview-bridge/utils";
402
402
  // src/internal/createPromiseProxy.ts
@@ -481,9 +481,9 @@ var mockStore = function() {
481
481
  // src/internal/bridgeInstance.ts
482
482
  var BridgeInstance = /*#__PURE__*/ function() {
483
483
  "use strict";
484
- function BridgeInstance(_options, _emitter) {
485
- var _bridgeMethods = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], _nativeInitialState = arguments.length > 3 ? arguments[3] : void 0;
484
+ function BridgeInstance(_bridgeId, _options, _emitter, _bridgeMethods, _nativeInitialState) {
486
485
  _class_call_check(this, BridgeInstance);
486
+ this._bridgeId = _bridgeId;
487
487
  this._options = _options;
488
488
  this._emitter = _emitter;
489
489
  this._bridgeMethods = _bridgeMethods;
@@ -525,9 +525,11 @@ var BridgeInstance = /*#__PURE__*/ function() {
525
525
  var _window_ReactNativeWebView;
526
526
  (_window_ReactNativeWebView = window.ReactNativeWebView) === null || _window_ReactNativeWebView === void 0 ? void 0 : _window_ReactNativeWebView.postMessage(JSON.stringify(body ? {
527
527
  type: type,
528
- body: body
528
+ body: body,
529
+ bridgeId: this._bridgeId
529
530
  } : {
530
- type: type
531
+ type: type,
532
+ bridgeId: this._bridgeId
531
533
  }));
532
534
  }
533
535
  },
@@ -622,7 +624,7 @@ var BridgeInstance = /*#__PURE__*/ function() {
622
624
  value: nativeMethod,
623
625
  writable: false
624
626
  });
625
- return _object_spread_props(_object_spread({}, acc), _define_property({}, methodName, nativeMethod));
627
+ return Object.assign(acc, _define_property({}, methodName, nativeMethod));
626
628
  }, initialBridge);
627
629
  this.loose = this._createLoose(nativeMethods);
628
630
  this.store = linkBridgeStore(this._emitter, _object_spread({}, nativeMethods, nativeInitialState));
@@ -699,7 +701,9 @@ var linkBridge = function() {
699
701
  if (!window.ReactNativeWebView) {
700
702
  console.warn("[WebViewBridge] Not in a WebView environment");
701
703
  }
704
+ var bridgeId = createRandomId2();
702
705
  var emitter = createEvents();
706
+ window.nativeEmitterMap = _object_spread_props(_object_spread({}, window.nativeEmitterMap || {}), _define_property({}, bridgeId, emitter));
703
707
  if (!window.nativeEmitter) {
704
708
  window.nativeEmitter = emitter;
705
709
  }
@@ -707,7 +711,7 @@ var linkBridge = function() {
707
711
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
708
712
  var _window___bridgeInitialState__;
709
713
  var nativeInitialState = (_window___bridgeInitialState__ = window.__bridgeInitialState__) !== null && _window___bridgeInitialState__ !== void 0 ? _window___bridgeInitialState__ : {};
710
- var instance = new BridgeInstance(options, emitter, bridgeMethods, nativeInitialState);
714
+ var instance = new BridgeInstance(bridgeId, options, emitter, bridgeMethods, nativeInitialState);
711
715
  if (bridgeMethods.length === 0) {
712
716
  var unsubscribe = emitter.on("hydrate", function(param) {
713
717
  var bridgeMethods2 = param.bridgeMethods, nativeInitialState2 = param.nativeInitialState;
@@ -732,9 +736,8 @@ var linkBridge = function() {
732
736
  onFallback === null || onFallback === void 0 ? void 0 : onFallback(methodName, args);
733
737
  return Promise.reject(new MethodNotFoundError(methodName));
734
738
  };
735
- } else {
736
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
737
739
  }
740
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
738
741
  return function() {
739
742
  return Promise.resolve();
740
743
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webview-bridge/web",
3
3
  "type": "module",
4
- "version": "1.7.2",
4
+ "version": "1.7.4",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -26,11 +26,12 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@webview-bridge/utils": "1.7.2",
30
- "@webview-bridge/types": "1.7.2"
29
+ "@webview-bridge/utils": "1.7.4",
30
+ "@webview-bridge/types": "1.7.4"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --format cjs,esm --dts --target es5",
34
- "test:type": "tsc --noEmit"
34
+ "test:type": "tsc --noEmit",
35
+ "lint": "biome check"
35
36
  }
36
37
  }