@getuserfeedback/react-native 4.0.10 → 4.0.12
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.
|
@@ -14,6 +14,14 @@ import { buildCoreWebViewBridgeScript, parseCoreWebViewBridgeMessage, toExternal
|
|
|
14
14
|
import { createCoreWebViewHostController, } from "./core-webview-host-controller.js";
|
|
15
15
|
import { WebViewDocumentHost } from "./webview-document-host.js";
|
|
16
16
|
let nextBridgeId = 0;
|
|
17
|
+
const CORE_WEBVIEW_HOST_STYLE = {
|
|
18
|
+
height: 1,
|
|
19
|
+
left: -10000,
|
|
20
|
+
opacity: 0,
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: 0,
|
|
23
|
+
width: 1,
|
|
24
|
+
};
|
|
17
25
|
function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onDisconnected, onInvalidMessage, webViewComponent, webViewProps, }) {
|
|
18
26
|
const bridgeIdRef = useRef(null);
|
|
19
27
|
if (bridgeIdRef.current === null) {
|
|
@@ -41,6 +49,7 @@ function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onDisconnected,
|
|
|
41
49
|
const controller = controllerRef.current;
|
|
42
50
|
const buildDocumentStartScript = useMemo(() => () => buildCoreWebViewBridgeScript({ bridgeId, phase: "documentStart" }), [bridgeId]);
|
|
43
51
|
const source = useMemo(() => ({ uri: externalCoreUrl }), [externalCoreUrl]);
|
|
52
|
+
const resolvedWebViewProps = useMemo(() => (Object.assign(Object.assign({}, webViewProps), { containerStyle: CORE_WEBVIEW_HOST_STYLE, pointerEvents: "none", style: CORE_WEBVIEW_HOST_STYLE })), [webViewProps]);
|
|
44
53
|
return createElement((WebViewDocumentHost), {
|
|
45
54
|
bridgeId,
|
|
46
55
|
buildDocumentStartScript,
|
|
@@ -48,7 +57,7 @@ function CoreWebViewHostDocument({ externalCoreUrl, onConnected, onDisconnected,
|
|
|
48
57
|
parseMessage: parseCoreWebViewBridgeMessage,
|
|
49
58
|
source,
|
|
50
59
|
webViewComponent,
|
|
51
|
-
webViewProps,
|
|
60
|
+
webViewProps: resolvedWebViewProps,
|
|
52
61
|
onInvalidMessage,
|
|
53
62
|
});
|
|
54
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { coreViewHostActionSchema, } from "@getuserfeedback/protocol/internal/core-view-host-actions";
|
|
2
|
-
import { buildEventViewSize, eventViewSizeSchema, } from "@getuserfeedback/protocol/internal/view-host-control-messages";
|
|
3
|
-
import { buildEventViewPrerendered } from "@getuserfeedback/protocol/internal/view-host-lifecycle-events";
|
|
2
|
+
import { actionRequestCloseViewSchema, buildEventViewSize, eventViewSizeSchema, } from "@getuserfeedback/protocol/internal/view-host-control-messages";
|
|
3
|
+
import { buildEventViewClosed, buildEventViewPrerendered, } from "@getuserfeedback/protocol/internal/view-host-lifecycle-events";
|
|
4
4
|
import { createViewPreparationReadinessRegistry, createViewPreparationRegistry, } from "./view-orchestration-runtime.js";
|
|
5
5
|
const createNativeViewReadinessRegistry = () => createViewPreparationReadinessRegistry();
|
|
6
6
|
export function createNativeViewRecordController(input) {
|
|
@@ -19,6 +19,18 @@ export function createNativeViewRecordController(input) {
|
|
|
19
19
|
// Error observers cannot change view lifecycle settlement.
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
const failCoreConnection = (error, fallbackMessage) => {
|
|
23
|
+
coreConnectionFailed = true;
|
|
24
|
+
try {
|
|
25
|
+
input.coreConnection.disconnect();
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
// Disconnect observers cannot change lifecycle settlement.
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
reportError(error, fallbackMessage);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
22
34
|
const notify = () => {
|
|
23
35
|
snapshot = Object.freeze(Array.from(entries.values(), toRecord));
|
|
24
36
|
for (const listener of listeners) {
|
|
@@ -38,6 +50,11 @@ export function createNativeViewRecordController(input) {
|
|
|
38
50
|
}
|
|
39
51
|
return true;
|
|
40
52
|
};
|
|
53
|
+
const closeEntry = (entry) => {
|
|
54
|
+
if (!preparations.cancel(entry.viewId)) {
|
|
55
|
+
removeEntry(entry);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
41
58
|
const handlePrerender = (action) => {
|
|
42
59
|
if (entries.has(action.viewId)) {
|
|
43
60
|
return;
|
|
@@ -80,12 +97,9 @@ export function createNativeViewRecordController(input) {
|
|
|
80
97
|
}
|
|
81
98
|
};
|
|
82
99
|
const handleClose = (action) => {
|
|
83
|
-
if (preparations.cancel(action.viewId)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
100
|
const entry = entries.get(action.viewId);
|
|
87
101
|
if (entry) {
|
|
88
|
-
|
|
102
|
+
closeEntry(entry);
|
|
89
103
|
}
|
|
90
104
|
};
|
|
91
105
|
const handleCoreMessage = (value) => {
|
|
@@ -125,6 +139,26 @@ export function createNativeViewRecordController(input) {
|
|
|
125
139
|
viewId: entry.viewId,
|
|
126
140
|
}));
|
|
127
141
|
};
|
|
142
|
+
const closeViewFromRequest = (entry, request) => {
|
|
143
|
+
try {
|
|
144
|
+
input.coreConnection.transport.postMessage(Object.assign(Object.assign({}, request), { viewId: entry.viewId }));
|
|
145
|
+
input.coreConnection.transport.postMessage(buildEventViewClosed({
|
|
146
|
+
gen: entry.generation,
|
|
147
|
+
reason: "user",
|
|
148
|
+
viewId: entry.viewId,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
failCoreConnection(error, "Native view close delivery failed");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
closeEntry(entry);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
reportError(error, "Native view close cleanup failed");
|
|
160
|
+
}
|
|
161
|
+
};
|
|
128
162
|
const stopCoreTransport = input.coreConnection.transport.subscribe(handleCoreMessage);
|
|
129
163
|
return {
|
|
130
164
|
attachViewReadinessConnection({ allocationId, connection }) {
|
|
@@ -173,16 +207,7 @@ export function createNativeViewRecordController(input) {
|
|
|
173
207
|
completeConnectionReadiness(entry, size);
|
|
174
208
|
}
|
|
175
209
|
catch (error) {
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
input.coreConnection.disconnect();
|
|
179
|
-
}
|
|
180
|
-
catch (_a) {
|
|
181
|
-
// Disconnect observers cannot change readiness settlement.
|
|
182
|
-
}
|
|
183
|
-
finally {
|
|
184
|
-
reportError(error, "Native view readiness delivery failed");
|
|
185
|
-
}
|
|
210
|
+
failCoreConnection(error, "Native view readiness delivery failed");
|
|
186
211
|
}
|
|
187
212
|
};
|
|
188
213
|
const handleMessage = (value) => {
|
|
@@ -193,6 +218,15 @@ export function createNativeViewRecordController(input) {
|
|
|
193
218
|
entry.viewReadinessDetach !== detach) {
|
|
194
219
|
return;
|
|
195
220
|
}
|
|
221
|
+
const closeRequest = actionRequestCloseViewSchema.safeParse(value);
|
|
222
|
+
if (closeRequest.success) {
|
|
223
|
+
if (closeRequest.data.gen === input.coreConnection.generation &&
|
|
224
|
+
(closeRequest.data.viewId === undefined ||
|
|
225
|
+
closeRequest.data.viewId === viewId)) {
|
|
226
|
+
closeViewFromRequest(entry, closeRequest.data);
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
196
230
|
const parsed = eventViewSizeSchema.safeParse(value);
|
|
197
231
|
if (!parsed.success ||
|
|
198
232
|
parsed.data.gen !== input.coreConnection.generation ||
|
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.12";
|