@getuserfeedback/react-native 4.0.28 → 4.0.31
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/core-webview-host-controller.d.ts +1 -0
- package/dist/core-webview-host-controller.js +1 -1
- package/dist/core-webview-host.d.ts +1 -0
- package/dist/core-webview-host.js +7 -1
- package/dist/native-runtime-root.js +16 -8
- package/dist/version.js +1 -1
- package/dist/webview-document-host.js +11 -2
- package/dist/webview-host-controller.d.ts +1 -0
- package/dist/webview-host-controller.js +21 -6
- package/package.json +3 -3
|
@@ -11,6 +11,7 @@ export declare const createCoreWebViewHostController: (input: {
|
|
|
11
11
|
bridgeId: string;
|
|
12
12
|
onConnected: (connection: CoreWebViewHostConnection) => void;
|
|
13
13
|
onDisconnected?: () => void;
|
|
14
|
+
onActivationRetryExhausted?: (error: Error) => void;
|
|
14
15
|
activationRetryIntervalMs?: number;
|
|
15
16
|
activationRetryTimeoutMs?: number;
|
|
16
17
|
}) => CoreWebViewHostController;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildCoreWebViewBridgeScript, buildCoreWebViewHostMessageScript, } from "./core-webview-bridge-adapter.js";
|
|
2
2
|
import { createWebViewHostController, } from "./webview-host-controller.js";
|
|
3
|
-
export const createCoreWebViewHostController = (input) => createWebViewHostController(Object.assign(Object.assign({}, input), { connectionLabel: "Core WebView host", buildActivationScript: buildCoreWebViewBridgeScript, buildHostMessageScript: buildCoreWebViewHostMessageScript, onConnected: (connection) => {
|
|
3
|
+
export const createCoreWebViewHostController = (input) => createWebViewHostController(Object.assign(Object.assign({}, input), { connectionLabel: "Core WebView host", buildActivationScript: buildCoreWebViewBridgeScript, buildHostMessageScript: buildCoreWebViewHostMessageScript, onActivationRetryExhausted: input.onActivationRetryExhausted, onConnected: (connection) => {
|
|
4
4
|
input.onConnected({
|
|
5
5
|
disconnect: connection.disconnect,
|
|
6
6
|
generation: connection.generation,
|
|
@@ -3,6 +3,7 @@ import { type CoreWebViewHostConnection } from "./core-webview-host-controller.j
|
|
|
3
3
|
export type CoreWebViewHostProps = {
|
|
4
4
|
coreUrl: string;
|
|
5
5
|
onConnected: (connection: CoreWebViewHostConnection) => void;
|
|
6
|
+
onActivationRetryExhausted?: (error: Error) => void;
|
|
6
7
|
onDisconnected?: () => void;
|
|
7
8
|
onInvalidMessage?: (error: Error, value: unknown) => void;
|
|
8
9
|
webViewComponent?: ComponentType<Record<string, unknown>>;
|
|
@@ -22,7 +22,7 @@ const CORE_WEBVIEW_HOST_STYLE = {
|
|
|
22
22
|
top: 0,
|
|
23
23
|
width: 1,
|
|
24
24
|
};
|
|
25
|
-
function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onDisconnected, onInvalidMessage, webViewComponent, webViewProps, }) {
|
|
25
|
+
function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onActivationRetryExhausted, onDisconnected, onInvalidMessage, webViewComponent, webViewProps, }) {
|
|
26
26
|
const bridgeIdRef = useRef(null);
|
|
27
27
|
if (bridgeIdRef.current === null) {
|
|
28
28
|
nextBridgeId += 1;
|
|
@@ -33,10 +33,16 @@ function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onDisconnected,
|
|
|
33
33
|
const onDisconnectedRef = useRef(onDisconnected);
|
|
34
34
|
onConnectedRef.current = onConnected;
|
|
35
35
|
onDisconnectedRef.current = onDisconnected;
|
|
36
|
+
const onActivationRetryExhaustedRef = useRef(onActivationRetryExhausted);
|
|
37
|
+
onActivationRetryExhaustedRef.current = onActivationRetryExhausted;
|
|
36
38
|
const controllerRef = useRef(null);
|
|
37
39
|
if (controllerRef.current === null) {
|
|
38
40
|
controllerRef.current = createCoreWebViewHostController({
|
|
39
41
|
bridgeId,
|
|
42
|
+
onActivationRetryExhausted: (error) => {
|
|
43
|
+
var _a;
|
|
44
|
+
(_a = onActivationRetryExhaustedRef.current) === null || _a === void 0 ? void 0 : _a.call(onActivationRetryExhaustedRef, error);
|
|
45
|
+
},
|
|
40
46
|
onConnected: (connection) => {
|
|
41
47
|
onConnectedRef.current(connection);
|
|
42
48
|
},
|
|
@@ -61,6 +61,16 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
61
61
|
reportError(error);
|
|
62
62
|
}
|
|
63
63
|
}, [reportError]);
|
|
64
|
+
const reportStartupTerminalError = useCallback((error) => {
|
|
65
|
+
var _a;
|
|
66
|
+
try {
|
|
67
|
+
(_a = onStartupTerminalErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onStartupTerminalErrorRef, error);
|
|
68
|
+
}
|
|
69
|
+
catch (observerError) {
|
|
70
|
+
reportError(observerError);
|
|
71
|
+
}
|
|
72
|
+
reportError(error);
|
|
73
|
+
}, [reportError]);
|
|
64
74
|
const handleConnected = useCallback((coreConnection) => {
|
|
65
75
|
const previousSession = sessionRef.current;
|
|
66
76
|
if (previousSession) {
|
|
@@ -121,7 +131,6 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
121
131
|
})
|
|
122
132
|
.then(commitSession)
|
|
123
133
|
.catch((error) => {
|
|
124
|
-
var _a;
|
|
125
134
|
if (sessionRef.current !== nextSession) {
|
|
126
135
|
return;
|
|
127
136
|
}
|
|
@@ -138,14 +147,11 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
138
147
|
}
|
|
139
148
|
else {
|
|
140
149
|
startupRetryAttemptedRef.current = false;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
reportError(observerError);
|
|
146
|
-
}
|
|
150
|
+
reportStartupTerminalError(error instanceof Error ? error : new Error(String(error)));
|
|
151
|
+
}
|
|
152
|
+
if (shouldRetry) {
|
|
153
|
+
reportError(error);
|
|
147
154
|
}
|
|
148
|
-
reportError(error);
|
|
149
155
|
});
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
@@ -154,6 +160,7 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
154
160
|
notifyCommandSessionObserver,
|
|
155
161
|
startupCommandSettlementTimeoutMs,
|
|
156
162
|
reportError,
|
|
163
|
+
reportStartupTerminalError,
|
|
157
164
|
]);
|
|
158
165
|
const handleDisconnected = useCallback(() => {
|
|
159
166
|
const currentSession = sessionRef.current;
|
|
@@ -199,6 +206,7 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
199
206
|
coreUrl,
|
|
200
207
|
key: `${coreUrl}:${coreHostRevision}`,
|
|
201
208
|
onConnected: handleConnected,
|
|
209
|
+
onActivationRetryExhausted: reportStartupTerminalError,
|
|
202
210
|
onDisconnected: handleDisconnected,
|
|
203
211
|
onInvalidMessage,
|
|
204
212
|
webViewComponent: coreWebViewComponent,
|
package/dist/version.js
CHANGED
|
@@ -3,4 +3,4 @@ const reactNativeSdkVersion = typeof __GX_REACT_NATIVE_SDK_VERSION__ === "string
|
|
|
3
3
|
: "";
|
|
4
4
|
// Build scripts patch this fallback to the package version for published artifacts.
|
|
5
5
|
// Source-linked workspace usage keeps the local fallback.
|
|
6
|
-
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "4.0.
|
|
6
|
+
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "4.0.31";
|
|
@@ -41,14 +41,23 @@ export function WebViewDocumentHost({ bridgeId, buildDocumentStartScript, contro
|
|
|
41
41
|
const callerOnLoadStart = toEventHandler(webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.onLoadStart);
|
|
42
42
|
const callerOnLoad = toEventHandler(webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.onLoad);
|
|
43
43
|
const callerOnMessage = toEventHandler(webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.onMessage);
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const webViewHandleRef = useRef(null);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const currentHandle = webViewHandleRef.current;
|
|
47
|
+
if (currentHandle) {
|
|
48
|
+
controller.attach(currentHandle);
|
|
49
|
+
}
|
|
50
|
+
return () => {
|
|
51
|
+
controller.detach();
|
|
52
|
+
};
|
|
46
53
|
}, [controller]);
|
|
47
54
|
const setWebViewRef = useCallback((handle) => {
|
|
48
55
|
if (!handle || typeof handle.injectJavaScript !== "function") {
|
|
56
|
+
webViewHandleRef.current = null;
|
|
49
57
|
controller.detach();
|
|
50
58
|
return;
|
|
51
59
|
}
|
|
60
|
+
webViewHandleRef.current = handle;
|
|
52
61
|
controller.attach(handle);
|
|
53
62
|
}, [controller]);
|
|
54
63
|
const handleLoadStart = useCallback((event) => {
|
|
@@ -41,6 +41,7 @@ export declare const createWebViewHostController: <TMessage extends WebViewBridg
|
|
|
41
41
|
}) => string;
|
|
42
42
|
onConnected: (connection: WebViewHostConnection<TMessage>) => void;
|
|
43
43
|
onDisconnected?: () => void;
|
|
44
|
+
onActivationRetryExhausted?: (error: Error) => void;
|
|
44
45
|
activationRetryIntervalMs?: number;
|
|
45
46
|
activationRetryTimeoutMs?: number;
|
|
46
47
|
}) => WebViewHostController<TMessage>;
|
|
@@ -18,6 +18,11 @@ export const createWebViewHostController = (input) => {
|
|
|
18
18
|
}
|
|
19
19
|
activationRetryDeadline = null;
|
|
20
20
|
};
|
|
21
|
+
const reportActivationRetryExhausted = () => {
|
|
22
|
+
var _a;
|
|
23
|
+
clearActivationRetry();
|
|
24
|
+
(_a = input.onActivationRetryExhausted) === null || _a === void 0 ? void 0 : _a.call(input, new Error(`${input.connectionLabel} activation retries exhausted after ${String(activationRetryTimeoutMs)}ms`));
|
|
25
|
+
};
|
|
21
26
|
const injectActivation = () => {
|
|
22
27
|
const snapshot = session.getSnapshot();
|
|
23
28
|
if (!handle || !isLoadComplete || snapshot.state !== "awaitingConnection") {
|
|
@@ -33,28 +38,37 @@ export const createWebViewHostController = (input) => {
|
|
|
33
38
|
}
|
|
34
39
|
catch (_a) {
|
|
35
40
|
// A newly attached WebView can reject injection transiently. The
|
|
36
|
-
//
|
|
41
|
+
// bounded retry loop reports when it can no longer recover delivery.
|
|
37
42
|
}
|
|
38
43
|
};
|
|
39
44
|
const scheduleActivationRetry = () => {
|
|
40
45
|
if (activationRetryTimer !== null ||
|
|
41
46
|
activationRetryDeadline === null ||
|
|
42
|
-
Date.now() >= activationRetryDeadline ||
|
|
43
47
|
!handle ||
|
|
44
48
|
!isLoadComplete ||
|
|
45
49
|
session.getSnapshot().state !== "awaitingConnection") {
|
|
46
50
|
return;
|
|
47
51
|
}
|
|
48
|
-
|
|
52
|
+
if (Date.now() >= activationRetryDeadline) {
|
|
53
|
+
reportActivationRetryExhausted();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const timer = setTimeout(() => {
|
|
57
|
+
if (activationRetryTimer !== timer) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
49
60
|
activationRetryTimer = null;
|
|
50
|
-
if (activationRetryDeadline === null
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
if (activationRetryDeadline === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (Date.now() >= activationRetryDeadline) {
|
|
65
|
+
reportActivationRetryExhausted();
|
|
53
66
|
return;
|
|
54
67
|
}
|
|
55
68
|
injectActivation();
|
|
56
69
|
scheduleActivationRetry();
|
|
57
70
|
}, activationRetryIntervalMs);
|
|
71
|
+
activationRetryTimer = timer;
|
|
58
72
|
};
|
|
59
73
|
const activateUntilConnected = () => {
|
|
60
74
|
if (session.getSnapshot().state !== "awaitingConnection") {
|
|
@@ -99,6 +113,7 @@ export const createWebViewHostController = (input) => {
|
|
|
99
113
|
}
|
|
100
114
|
};
|
|
101
115
|
const disconnect = () => {
|
|
116
|
+
clearActivationRetry();
|
|
102
117
|
session.close();
|
|
103
118
|
dropActiveConnection();
|
|
104
119
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.31",
|
|
4
4
|
"description": "getuserfeedback React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"lint": "biome check ."
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@getuserfeedback/protocol": "^3.30.
|
|
48
|
-
"@getuserfeedback/sdk": "^0.12.
|
|
47
|
+
"@getuserfeedback/protocol": "^3.30.4",
|
|
48
|
+
"@getuserfeedback/sdk": "^0.12.27",
|
|
49
49
|
"robot3": "^1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|