@webview-bridge/react-native 1.4.6-nightly.0 → 1.4.7
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.
|
@@ -38,20 +38,20 @@ const createWebView = ({ bridge, debug, responseTimeout = 2000, fallback, }) =>
|
|
|
38
38
|
isReady: false,
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
|
-
const
|
|
41
|
+
const webviewRefList = [];
|
|
42
42
|
const emitter = (0, util_1.createEvents)();
|
|
43
43
|
bridge.subscribe((state) => {
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
44
|
+
for (const ref of webviewRefList) {
|
|
45
|
+
ref?.current?.injectJavaScript((0, integrations_1.SAFE_NATIVE_EMITTER_EMIT)("bridgeStateChange", state));
|
|
46
|
+
}
|
|
47
47
|
});
|
|
48
48
|
return {
|
|
49
49
|
WebView: (0, react_1.forwardRef)((props, ref) => {
|
|
50
50
|
const webviewRef = (0, react_1.useRef)(null);
|
|
51
51
|
(0, react_1.useLayoutEffect)(() => {
|
|
52
|
-
|
|
52
|
+
webviewRefList.push(webviewRef);
|
|
53
53
|
return () => {
|
|
54
|
-
|
|
54
|
+
webviewRefList.pop();
|
|
55
55
|
};
|
|
56
56
|
}, []);
|
|
57
57
|
const bridgeNames = (0, react_1.useMemo)(() => Object.entries(bridge.getState() ?? {})
|
|
@@ -85,9 +85,9 @@ const createWebView = ({ bridge, debug, responseTimeout = 2000, fallback, }) =>
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
case "getBridgeState": {
|
|
88
|
-
|
|
89
|
-
.
|
|
90
|
-
|
|
88
|
+
for (const ref of webviewRefList) {
|
|
89
|
+
ref?.current?.injectJavaScript((0, integrations_1.SAFE_NATIVE_EMITTER_EMIT)("bridgeStateChange", bridge.getState()));
|
|
90
|
+
}
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
case "registerWebMethod": {
|
|
@@ -19,5 +19,4 @@ __exportStar(require("./createRandomId"), exports);
|
|
|
19
19
|
__exportStar(require("./equals"), exports);
|
|
20
20
|
__exportStar(require("./noop"), exports);
|
|
21
21
|
__exportStar(require("./removeUndefinedKeys"), exports);
|
|
22
|
-
__exportStar(require("./stack"), exports);
|
|
23
22
|
__exportStar(require("./timeout"), exports);
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Stack = void 0;
|
|
4
|
-
class Stack {
|
|
5
|
-
items = [];
|
|
6
|
-
push(element) {
|
|
7
|
-
this.items.push(element);
|
|
8
|
-
}
|
|
9
|
-
pop() {
|
|
10
|
-
return this.items.pop();
|
|
11
|
-
}
|
|
12
|
-
top() {
|
|
13
|
-
return this.items[this.items.length - 1];
|
|
14
|
-
}
|
|
15
|
-
isEmpty() {
|
|
16
|
-
return this.items.length === 0;
|
|
17
|
-
}
|
|
18
|
-
size() {
|
|
19
|
-
return this.items.length;
|
|
20
|
-
}
|
|
21
|
-
clear() {
|
|
22
|
-
this.items = [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.Stack = Stack;
|