@dynamic-labs/react-native-extension 2.1.0-alpha.21 → 2.1.0-alpha.23
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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useRef, useEffect, useCallback, useState } from 'react';
|
|
2
2
|
import { WebView as WebView$1 } from 'react-native-webview';
|
|
3
3
|
import { parseMessageTransportData, createRequestChannel } from '@dynamic-labs/message-transport';
|
|
4
4
|
import { Logger } from '@dynamic-labs/logger';
|
|
@@ -6,7 +6,7 @@ import { StyleSheet } from 'react-native';
|
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { createPasskey, PasskeyStamper } from '@turnkey/react-native-passkey-stamper';
|
|
8
8
|
|
|
9
|
-
var version$1 = "2.1.0-alpha.
|
|
9
|
+
var version$1 = "2.1.0-alpha.23";
|
|
10
10
|
|
|
11
11
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
12
12
|
|
|
@@ -1094,12 +1094,22 @@ $$8({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
|
|
|
1094
1094
|
|
|
1095
1095
|
const logger = new Logger('react-native-extension');
|
|
1096
1096
|
|
|
1097
|
+
const useIsMounted = () => {
|
|
1098
|
+
const isMountedRef = useRef(true);
|
|
1099
|
+
useEffect(() => () => {
|
|
1100
|
+
isMountedRef.current = false;
|
|
1101
|
+
}, []);
|
|
1102
|
+
return useCallback(() => isMountedRef.current, [isMountedRef]);
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1097
1105
|
const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
1106
|
+
const canBroadcastMessages = useIsMounted();
|
|
1098
1107
|
/**
|
|
1099
1108
|
* Receive a message from the webview and forward it to the client
|
|
1100
1109
|
* message transport
|
|
1101
1110
|
*/
|
|
1102
1111
|
const onMessageHandler = event => {
|
|
1112
|
+
if (!canBroadcastMessages()) return;
|
|
1103
1113
|
let parsedData = null;
|
|
1104
1114
|
try {
|
|
1105
1115
|
parsedData = JSON.parse(event.nativeEvent.data);
|
|
@@ -1124,6 +1134,7 @@ const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
|
1124
1134
|
*/
|
|
1125
1135
|
useEffect(() => {
|
|
1126
1136
|
const sendMessageToWebView = message => {
|
|
1137
|
+
if (!canBroadcastMessages()) return;
|
|
1127
1138
|
/**
|
|
1128
1139
|
* Only forward messages to the webview
|
|
1129
1140
|
* that where created by the client/host
|
|
@@ -1136,7 +1147,7 @@ const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
|
1136
1147
|
return () => {
|
|
1137
1148
|
core.messageTransport.off(sendMessageToWebView);
|
|
1138
1149
|
};
|
|
1139
|
-
}, [core.messageTransport, webViewRef]);
|
|
1150
|
+
}, [core.messageTransport, webViewRef, canBroadcastMessages]);
|
|
1140
1151
|
return {
|
|
1141
1152
|
onMessageHandler
|
|
1142
1153
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/react-native-extension",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.23",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@dynamic-labs/message-transport": "2.1.0-alpha.
|
|
18
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
17
|
+
"@dynamic-labs/message-transport": "2.1.0-alpha.23",
|
|
18
|
+
"@dynamic-labs/logger": "2.1.0-alpha.23",
|
|
19
19
|
"@turnkey/react-native-passkey-stamper": "0.2.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": "^18.2.0",
|
|
23
23
|
"react-native": "^0.73.6",
|
|
24
24
|
"react-native-webview": "^13.6.4",
|
|
25
|
-
"@dynamic-labs/client": "2.1.0-alpha.
|
|
25
|
+
"@dynamic-labs/client": "2.1.0-alpha.23"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useIsMounted } from './useIsMounted';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsMounted: () => () => boolean;
|