@webview-bridge/web 1.7.1 → 1.7.3

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,15 +761,14 @@ 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)();
763
- if (!window.nativeEmitter) {
764
- window.nativeEmitter = emitter;
765
- }
766
+ window.nativeEmitter = _object_spread_props(_object_spread({}, window.nativeEmitter || {}), _define_property({}, bridgeId, emitter));
766
767
  var _window___bridgeMethods__;
767
768
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
768
769
  var _window___bridgeInitialState__;
769
770
  var nativeInitialState = (_window___bridgeInitialState__ = window.__bridgeInitialState__) !== null && _window___bridgeInitialState__ !== void 0 ? _window___bridgeInitialState__ : {};
770
- var instance = new BridgeInstance(options, emitter, bridgeMethods, nativeInitialState);
771
+ var instance = new BridgeInstance(bridgeId, options, emitter, bridgeMethods, nativeInitialState);
771
772
  if (bridgeMethods.length === 0) {
772
773
  var unsubscribe = emitter.on("hydrate", function(param) {
773
774
  var bridgeMethods2 = param.bridgeMethods, nativeInitialState2 = param.nativeInitialState;
@@ -792,9 +793,8 @@ var linkBridge = function() {
792
793
  onFallback === null || onFallback === void 0 ? void 0 : onFallback(methodName, args);
793
794
  return Promise.reject(new MethodNotFoundError(methodName));
794
795
  };
795
- } else {
796
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
797
796
  }
797
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
798
798
  return function() {
799
799
  return Promise.resolve();
800
800
  };
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,15 +701,14 @@ 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();
703
- if (!window.nativeEmitter) {
704
- window.nativeEmitter = emitter;
705
- }
706
+ window.nativeEmitter = _object_spread_props(_object_spread({}, window.nativeEmitter || {}), _define_property({}, bridgeId, emitter));
706
707
  var _window___bridgeMethods__;
707
708
  var bridgeMethods = (_window___bridgeMethods__ = window.__bridgeMethods__) !== null && _window___bridgeMethods__ !== void 0 ? _window___bridgeMethods__ : [];
708
709
  var _window___bridgeInitialState__;
709
710
  var nativeInitialState = (_window___bridgeInitialState__ = window.__bridgeInitialState__) !== null && _window___bridgeInitialState__ !== void 0 ? _window___bridgeInitialState__ : {};
710
- var instance = new BridgeInstance(options, emitter, bridgeMethods, nativeInitialState);
711
+ var instance = new BridgeInstance(bridgeId, options, emitter, bridgeMethods, nativeInitialState);
711
712
  if (bridgeMethods.length === 0) {
712
713
  var unsubscribe = emitter.on("hydrate", function(param) {
713
714
  var bridgeMethods2 = param.bridgeMethods, nativeInitialState2 = param.nativeInitialState;
@@ -732,9 +733,8 @@ var linkBridge = function() {
732
733
  onFallback === null || onFallback === void 0 ? void 0 : onFallback(methodName, args);
733
734
  return Promise.reject(new MethodNotFoundError(methodName));
734
735
  };
735
- } else {
736
- console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
737
736
  }
737
+ console.warn("[WebViewBridge] ".concat(methodName, " is not defined, using fallback."));
738
738
  return function() {
739
739
  return Promise.resolve();
740
740
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webview-bridge/web",
3
3
  "type": "module",
4
- "version": "1.7.1",
4
+ "version": "1.7.3",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -15,8 +15,8 @@
15
15
  "dist",
16
16
  "package.json"
17
17
  ],
18
- "main": "dist/index.js",
19
- "module": "dist/index.cjs",
18
+ "main": "dist/index.cjs",
19
+ "module": "dist/index.js",
20
20
  "types": "dist/index.d.ts",
21
21
  "exports": {
22
22
  ".": {
@@ -26,11 +26,12 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@webview-bridge/utils": "1.7.1",
30
- "@webview-bridge/types": "1.7.1"
29
+ "@webview-bridge/utils": "1.7.3",
30
+ "@webview-bridge/types": "1.7.3"
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
  }