@getuserfeedback/react-native 4.0.11 → 4.0.13
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/native-view-record-controller.js +58 -16
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -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,14 @@ export function createNativeViewRecordController(input) {
|
|
|
38
50
|
}
|
|
39
51
|
return true;
|
|
40
52
|
};
|
|
53
|
+
const closeEntry = (entry) => {
|
|
54
|
+
if (entries.get(entry.viewId) !== entry) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!preparations.cancel(entry.viewId)) {
|
|
58
|
+
removeEntry(entry);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
41
61
|
const handlePrerender = (action) => {
|
|
42
62
|
if (entries.has(action.viewId)) {
|
|
43
63
|
return;
|
|
@@ -52,6 +72,7 @@ export function createNativeViewRecordController(input) {
|
|
|
52
72
|
generation: action.gen,
|
|
53
73
|
instanceId: action.instanceId,
|
|
54
74
|
isActive: false,
|
|
75
|
+
isClosing: false,
|
|
55
76
|
isPreparationCommitted: false,
|
|
56
77
|
openRequest: toOpenRequestMetadata(action.openRequest),
|
|
57
78
|
preparation,
|
|
@@ -80,12 +101,9 @@ export function createNativeViewRecordController(input) {
|
|
|
80
101
|
}
|
|
81
102
|
};
|
|
82
103
|
const handleClose = (action) => {
|
|
83
|
-
if (preparations.cancel(action.viewId)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
104
|
const entry = entries.get(action.viewId);
|
|
87
105
|
if (entry) {
|
|
88
|
-
|
|
106
|
+
closeEntry(entry);
|
|
89
107
|
}
|
|
90
108
|
};
|
|
91
109
|
const handleCoreMessage = (value) => {
|
|
@@ -125,6 +143,30 @@ export function createNativeViewRecordController(input) {
|
|
|
125
143
|
viewId: entry.viewId,
|
|
126
144
|
}));
|
|
127
145
|
};
|
|
146
|
+
const closeViewFromRequest = (entry, request) => {
|
|
147
|
+
if (entry.isClosing) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
entry.isClosing = true;
|
|
151
|
+
try {
|
|
152
|
+
input.coreConnection.transport.postMessage(Object.assign(Object.assign({}, request), { viewId: entry.viewId }));
|
|
153
|
+
input.coreConnection.transport.postMessage(buildEventViewClosed({
|
|
154
|
+
gen: entry.generation,
|
|
155
|
+
reason: "user",
|
|
156
|
+
viewId: entry.viewId,
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
failCoreConnection(error, "Native view close delivery failed");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
closeEntry(entry);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
reportError(error, "Native view close cleanup failed");
|
|
168
|
+
}
|
|
169
|
+
};
|
|
128
170
|
const stopCoreTransport = input.coreConnection.transport.subscribe(handleCoreMessage);
|
|
129
171
|
return {
|
|
130
172
|
attachViewReadinessConnection({ allocationId, connection }) {
|
|
@@ -173,16 +215,7 @@ export function createNativeViewRecordController(input) {
|
|
|
173
215
|
completeConnectionReadiness(entry, size);
|
|
174
216
|
}
|
|
175
217
|
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
|
-
}
|
|
218
|
+
failCoreConnection(error, "Native view readiness delivery failed");
|
|
186
219
|
}
|
|
187
220
|
};
|
|
188
221
|
const handleMessage = (value) => {
|
|
@@ -193,6 +226,15 @@ export function createNativeViewRecordController(input) {
|
|
|
193
226
|
entry.viewReadinessDetach !== detach) {
|
|
194
227
|
return;
|
|
195
228
|
}
|
|
229
|
+
const closeRequest = actionRequestCloseViewSchema.safeParse(value);
|
|
230
|
+
if (closeRequest.success) {
|
|
231
|
+
if (closeRequest.data.gen === input.coreConnection.generation &&
|
|
232
|
+
(closeRequest.data.viewId === undefined ||
|
|
233
|
+
closeRequest.data.viewId === viewId)) {
|
|
234
|
+
closeViewFromRequest(entry, closeRequest.data);
|
|
235
|
+
}
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
196
238
|
const parsed = eventViewSizeSchema.safeParse(value);
|
|
197
239
|
if (!parsed.success ||
|
|
198
240
|
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.13";
|