@getuserfeedback/react-native 4.0.5 → 4.0.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.
|
@@ -53,7 +53,7 @@ const resolveNativeView = () => {
|
|
|
53
53
|
export function NativeViewPresentationSurface({ children, nativeViewComponent, record, }) {
|
|
54
54
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
55
55
|
const NativeView = nativeViewComponent !== null && nativeViewComponent !== void 0 ? nativeViewComponent : resolveNativeView();
|
|
56
|
-
const isPresented = record.
|
|
56
|
+
const isPresented = record.isActive && record.size !== null;
|
|
57
57
|
const cornerRadii = toNativeWidgetCornerRadii((_a = record.size) === null || _a === void 0 ? void 0 : _a.frameAppearance);
|
|
58
58
|
const shadow = toNativeWidgetFrameShadow(((_c = (_b = record.size) === null || _b === void 0 ? void 0 : _b.frameAppearance) === null || _c === void 0 ? void 0 : _c.kind) === "page"
|
|
59
59
|
? record.size.frameAppearance.resolvedBoxShadow
|
|
@@ -2,13 +2,12 @@ import { type OpenRequestMetadata } from "@getuserfeedback/protocol/internal/cor
|
|
|
2
2
|
import { type EventViewSize } from "@getuserfeedback/protocol/internal/view-host-control-messages";
|
|
3
3
|
import type { CoreWebViewHostConnection } from "./core-webview-host-controller.js";
|
|
4
4
|
import type { ViewWebViewHostConnection } from "./view-webview-host-controller.js";
|
|
5
|
-
type NativeViewActivationState = "idle" | "prerendering" | "activation-requested" | "prerendering-activation-requested" | "prerendered" | "active";
|
|
6
5
|
type NativeViewSizeReport = Omit<EventViewSize, "gen" | "t" | "viewId">;
|
|
7
6
|
export type NativeViewRecord = Readonly<{
|
|
8
7
|
allocationId: number;
|
|
9
|
-
activationState: NativeViewActivationState;
|
|
10
8
|
generation: number;
|
|
11
9
|
instanceId: string;
|
|
10
|
+
isActive: boolean;
|
|
12
11
|
openRequest: Readonly<OpenRequestMetadata> | undefined;
|
|
13
12
|
size: NativeViewSizeReport | null;
|
|
14
13
|
srcdoc: string;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { coreViewHostActionSchema, } from "@getuserfeedback/protocol/internal/core-view-host-actions";
|
|
2
2
|
import { buildEventViewSize, eventViewSizeSchema, } from "@getuserfeedback/protocol/internal/view-host-control-messages";
|
|
3
3
|
import { buildEventViewPrerendered } from "@getuserfeedback/protocol/internal/view-host-lifecycle-events";
|
|
4
|
-
import {
|
|
4
|
+
import { createViewPreparationReadinessRegistry, createViewPreparationRegistry, } from "./view-orchestration-runtime.js";
|
|
5
5
|
const createNativeViewReadinessRegistry = () => createViewPreparationReadinessRegistry();
|
|
6
6
|
const DEFAULT_READINESS_RETRY_DELAY_MS = 50;
|
|
7
7
|
export function createNativeViewRecordController(input) {
|
|
8
8
|
var _a;
|
|
9
9
|
const entries = new Map();
|
|
10
10
|
const listeners = new Set();
|
|
11
|
-
const pendingActivations = new Map();
|
|
12
11
|
const preparations = createViewPreparationRegistry();
|
|
13
12
|
let disposed = false;
|
|
14
13
|
let nextAllocationId = 0;
|
|
@@ -28,19 +27,6 @@ export function createNativeViewRecordController(input) {
|
|
|
28
27
|
listener();
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
|
-
const ensurePendingActivation = (viewId, openRequest) => {
|
|
32
|
-
const existing = pendingActivations.get(viewId);
|
|
33
|
-
if (existing) {
|
|
34
|
-
existing.openRequest = openRequest;
|
|
35
|
-
return existing;
|
|
36
|
-
}
|
|
37
|
-
const created = {
|
|
38
|
-
activation: createViewActivationController(),
|
|
39
|
-
openRequest,
|
|
40
|
-
};
|
|
41
|
-
pendingActivations.set(viewId, created);
|
|
42
|
-
return created;
|
|
43
|
-
};
|
|
44
30
|
const removeEntry = (entry) => {
|
|
45
31
|
if (entries.get(entry.viewId) !== entry) {
|
|
46
32
|
return false;
|
|
@@ -55,7 +41,6 @@ export function createNativeViewRecordController(input) {
|
|
|
55
41
|
return true;
|
|
56
42
|
};
|
|
57
43
|
const handlePrerender = (action) => {
|
|
58
|
-
var _a;
|
|
59
44
|
if (entries.has(action.viewId)) {
|
|
60
45
|
return;
|
|
61
46
|
}
|
|
@@ -63,19 +48,13 @@ export function createNativeViewRecordController(input) {
|
|
|
63
48
|
if (!preparation) {
|
|
64
49
|
return;
|
|
65
50
|
}
|
|
66
|
-
const pendingActivation = pendingActivations.get(action.viewId);
|
|
67
|
-
const activation = (_a = pendingActivation === null || pendingActivation === void 0 ? void 0 : pendingActivation.activation) !== null && _a !== void 0 ? _a : createViewActivationController();
|
|
68
|
-
pendingActivations.delete(action.viewId);
|
|
69
|
-
activation.startPrerender();
|
|
70
51
|
nextAllocationId += 1;
|
|
71
52
|
const entry = {
|
|
72
|
-
activation,
|
|
73
53
|
allocationId: nextAllocationId,
|
|
74
54
|
generation: action.gen,
|
|
75
55
|
instanceId: action.instanceId,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
: toOpenRequestMetadata(action.openRequest),
|
|
56
|
+
isActive: false,
|
|
57
|
+
openRequest: toOpenRequestMetadata(action.openRequest),
|
|
79
58
|
preparation,
|
|
80
59
|
preparationState: "claimed",
|
|
81
60
|
size: null,
|
|
@@ -91,18 +70,14 @@ export function createNativeViewRecordController(input) {
|
|
|
91
70
|
};
|
|
92
71
|
const handleActivate = (action) => {
|
|
93
72
|
const entry = entries.get(action.viewId);
|
|
94
|
-
const openRequest = toOpenRequestMetadata(action.openRequest);
|
|
95
|
-
const activation = entry
|
|
96
|
-
? entry.activation
|
|
97
|
-
: ensurePendingActivation(action.viewId, openRequest).activation;
|
|
98
|
-
const previousState = activation.getState();
|
|
99
|
-
activation.requestActivation();
|
|
100
73
|
if (!entry) {
|
|
101
74
|
return;
|
|
102
75
|
}
|
|
76
|
+
const openRequest = toOpenRequestMetadata(action.openRequest);
|
|
103
77
|
const openRequestChanged = !areOpenRequestsEqual(entry.openRequest, openRequest);
|
|
104
78
|
entry.openRequest = openRequest;
|
|
105
|
-
if (
|
|
79
|
+
if (!entry.isActive || openRequestChanged) {
|
|
80
|
+
entry.isActive = true;
|
|
106
81
|
notify();
|
|
107
82
|
}
|
|
108
83
|
};
|
|
@@ -110,7 +85,6 @@ export function createNativeViewRecordController(input) {
|
|
|
110
85
|
if (preparations.cancel(action.viewId)) {
|
|
111
86
|
return;
|
|
112
87
|
}
|
|
113
|
-
pendingActivations.delete(action.viewId);
|
|
114
88
|
const entry = entries.get(action.viewId);
|
|
115
89
|
if (entry) {
|
|
116
90
|
removeEntry(entry);
|
|
@@ -160,7 +134,6 @@ export function createNativeViewRecordController(input) {
|
|
|
160
134
|
}
|
|
161
135
|
if (entry.preparationState !== "prepared") {
|
|
162
136
|
entry.preparationState = "prepared";
|
|
163
|
-
entry.activation.markPrerendered();
|
|
164
137
|
}
|
|
165
138
|
notify();
|
|
166
139
|
return true;
|
|
@@ -333,7 +306,6 @@ export function createNativeViewRecordController(input) {
|
|
|
333
306
|
for (const entry of Array.from(entries.values())) {
|
|
334
307
|
removeEntry(entry);
|
|
335
308
|
}
|
|
336
|
-
pendingActivations.clear();
|
|
337
309
|
if (hadEntries) {
|
|
338
310
|
snapshot = Object.freeze([]);
|
|
339
311
|
for (const listener of listeners) {
|
|
@@ -354,10 +326,10 @@ export function createNativeViewRecordController(input) {
|
|
|
354
326
|
}
|
|
355
327
|
function toRecord(entry) {
|
|
356
328
|
return Object.freeze({
|
|
357
|
-
activationState: entry.activation.getState(),
|
|
358
329
|
allocationId: entry.allocationId,
|
|
359
330
|
generation: entry.generation,
|
|
360
331
|
instanceId: entry.instanceId,
|
|
332
|
+
isActive: entry.isActive,
|
|
361
333
|
openRequest: entry.openRequest,
|
|
362
334
|
size: entry.size,
|
|
363
335
|
srcdoc: entry.srcdoc,
|
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.7";
|
|
@@ -83,72 +83,25 @@ class PendingCommandTracker {
|
|
|
83
83
|
return this.pendingByRequestId.size;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
// ../view-orchestration/src/view-activation-machine.ts
|
|
87
|
-
import { createMachine, interpret, state, transition } from "robot3";
|
|
88
|
-
var VIEW_ACTIVATION_STATES = {
|
|
89
|
-
idle: true,
|
|
90
|
-
prerendering: true,
|
|
91
|
-
"activation-requested": true,
|
|
92
|
-
"prerendering-activation-requested": true,
|
|
93
|
-
prerendered: true,
|
|
94
|
-
active: true
|
|
95
|
-
};
|
|
96
|
-
function createViewActivationMachine() {
|
|
97
|
-
const states = {
|
|
98
|
-
idle: state(transition("startPrerender", "prerendering"), transition("requestActivation", "activation-requested")),
|
|
99
|
-
prerendering: state(transition("requestActivation", "prerendering-activation-requested"), transition("markPrerendered", "prerendered")),
|
|
100
|
-
"activation-requested": state(transition("startPrerender", "prerendering-activation-requested")),
|
|
101
|
-
"prerendering-activation-requested": state(transition("markPrerendered", "active")),
|
|
102
|
-
prerendered: state(transition("requestActivation", "active")),
|
|
103
|
-
active: state()
|
|
104
|
-
};
|
|
105
|
-
return createMachine(states, () => ({}));
|
|
106
|
-
}
|
|
107
|
-
function createViewActivationController() {
|
|
108
|
-
const machine = createViewActivationMachine();
|
|
109
|
-
const service = interpret(machine, () => {});
|
|
110
|
-
const getState = () => readViewActivationState(service.machine.current);
|
|
111
|
-
const send = (event) => {
|
|
112
|
-
service.send(event);
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
getState,
|
|
116
|
-
startPrerender: () => {
|
|
117
|
-
send({ type: "startPrerender" });
|
|
118
|
-
},
|
|
119
|
-
requestActivation: () => {
|
|
120
|
-
send({ type: "requestActivation" });
|
|
121
|
-
},
|
|
122
|
-
markPrerendered: () => {
|
|
123
|
-
send({ type: "markPrerendered" });
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function readViewActivationState(value) {
|
|
128
|
-
if (typeof value !== "string" || !(value in VIEW_ACTIVATION_STATES)) {
|
|
129
|
-
throw new Error(`Unknown view activation state: ${String(value)}`);
|
|
130
|
-
}
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
86
|
// ../view-orchestration/src/view-preparation-readiness-registry.ts
|
|
134
87
|
function createViewPreparationReadinessRegistry() {
|
|
135
88
|
const states = new Map;
|
|
136
|
-
const resolveReadySize = (
|
|
137
|
-
if (!
|
|
89
|
+
const resolveReadySize = (state) => {
|
|
90
|
+
if (!state || state.status === "ready" || !state.hostPrepared || state.size === null) {
|
|
138
91
|
return null;
|
|
139
92
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
93
|
+
state.status = "ready";
|
|
94
|
+
return state.size;
|
|
142
95
|
};
|
|
143
96
|
return {
|
|
144
97
|
begin(viewId) {
|
|
145
|
-
const
|
|
98
|
+
const state = {
|
|
146
99
|
hostPrepared: false,
|
|
147
100
|
size: null,
|
|
148
101
|
status: "pending"
|
|
149
102
|
};
|
|
150
|
-
states.set(viewId,
|
|
151
|
-
const getCurrentState = () => states.get(viewId) ===
|
|
103
|
+
states.set(viewId, state);
|
|
104
|
+
const getCurrentState = () => states.get(viewId) === state ? state : null;
|
|
152
105
|
return {
|
|
153
106
|
markHostPrepared() {
|
|
154
107
|
const current = getCurrentState();
|
|
@@ -269,9 +222,6 @@ function createPendingCommandTracker() {
|
|
|
269
222
|
function createActiveViewSnapshotListController2() {
|
|
270
223
|
return createActiveViewSnapshotListController();
|
|
271
224
|
}
|
|
272
|
-
function createViewActivationController2() {
|
|
273
|
-
return createViewActivationController();
|
|
274
|
-
}
|
|
275
225
|
function createViewPreparationRegistry2() {
|
|
276
226
|
return createViewPreparationRegistry();
|
|
277
227
|
}
|
|
@@ -281,7 +231,6 @@ function createViewPreparationReadinessRegistry2() {
|
|
|
281
231
|
export {
|
|
282
232
|
createViewPreparationRegistry2 as createViewPreparationRegistry,
|
|
283
233
|
createViewPreparationReadinessRegistry2 as createViewPreparationReadinessRegistry,
|
|
284
|
-
createViewActivationController2 as createViewActivationController,
|
|
285
234
|
createPendingCommandTracker,
|
|
286
235
|
createActiveViewSnapshotListController2 as createActiveViewSnapshotListController
|
|
287
236
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
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.25.
|
|
48
|
-
"@getuserfeedback/sdk": "^0.12.
|
|
47
|
+
"@getuserfeedback/protocol": "^3.25.2",
|
|
48
|
+
"@getuserfeedback/sdk": "^0.12.14",
|
|
49
49
|
"robot3": "^1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|