@getuserfeedback/react-native 3.0.71 → 3.0.73
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-direct-command-session.js +29 -132
- package/dist/version.js +1 -1
- package/dist/view-orchestration-runtime.js +16 -227
- package/package.json +1 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getFlowHandleFromSettlementDetail } from "@getuserfeedback/protocol/host";
|
|
2
2
|
import { toCoreCommandPayload, } from "@getuserfeedback/protocol/internal/public-core-command";
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
// [from=native-flow-handle-command-session] [to=native-instance-flow-command-session] [scope=slice] [principle=core-owned-flow-lifecycle] [priority=high] [impact=high] [risk=high] [epic=runtime-neutral-view-host-orchestration] [epic_order=180]
|
|
3
|
+
// TODO(migration): Route reset, unscoped close, and the public provider client through this core-ordered direct session.
|
|
4
|
+
// [from=native-core-ordered-command-session] [to=native-provider-direct-session] [scope=slice] [principle=core-owned-flow-lifecycle] [priority=high] [impact=high] [risk=high] [epic=runtime-neutral-view-host-orchestration] [epic_order=180]
|
|
6
5
|
export function createNativeDirectCommandSession(input) {
|
|
7
|
-
const flowHandleCommandStateStore = createFlowHandleCommandStateStore();
|
|
8
6
|
const dispatchToCore = (envelope, command) => {
|
|
9
7
|
const coreEnvelope = Object.assign(Object.assign({}, envelope), { command: toCoreCommandPayload(command) });
|
|
10
8
|
return input.coreSession.dispatch(coreEnvelope);
|
|
@@ -16,142 +14,41 @@ export function createNativeDirectCommandSession(input) {
|
|
|
16
14
|
throw new Error(`Expected ${input.expectedKind} settlement for requestId "${input.envelope.requestId}" and instanceId "${input.envelope.instanceId}"`);
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
assertSettlementMatches({
|
|
26
|
-
envelope,
|
|
27
|
-
expectedKind: command.kind,
|
|
28
|
-
settlement,
|
|
29
|
-
});
|
|
30
|
-
const allocation = getFlowHandleFromSettlementDetail(settlement);
|
|
31
|
-
if (!(allocation === null || allocation === void 0 ? void 0 : allocation.flowRunId)) {
|
|
32
|
-
throw new Error(`Expected ${command.kind} settlement to include flowHandleId and flowRunId`);
|
|
33
|
-
}
|
|
34
|
-
const { flowHandleId, flowRunId } = allocation;
|
|
35
|
-
await flowHandleCommandStateStore.enqueue(flowHandleId, async (state) => {
|
|
36
|
-
state.runtime.bindAffinity({
|
|
37
|
-
instanceId: envelope.instanceId,
|
|
38
|
-
flowId: command.flowId,
|
|
39
|
-
});
|
|
40
|
-
state.runtime.bindFlowRun({
|
|
41
|
-
flowRunId,
|
|
42
|
-
activationPolicy: "never",
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
return settlement;
|
|
46
|
-
}
|
|
47
|
-
const flowHandleId = command.flowHandleId;
|
|
48
|
-
return flowHandleCommandStateStore.enqueue(flowHandleId, async (state) => {
|
|
49
|
-
const runtime = state.runtime.getSnapshot();
|
|
50
|
-
const decision = planFlowHandleCommand({
|
|
51
|
-
command: command.kind,
|
|
52
|
-
runtime,
|
|
53
|
-
instanceId: envelope.instanceId,
|
|
54
|
-
flowId: command.flowId,
|
|
55
|
-
});
|
|
56
|
-
if (decision === "forward-to-core") {
|
|
57
|
-
return dispatchToCore(envelope, Object.assign(Object.assign({}, command), { flowHandleId }));
|
|
58
|
-
}
|
|
59
|
-
if (decision !== "orchestrate") {
|
|
60
|
-
throw new Error(`Unexpected flow-handle command decision for ${command.kind}: ${decision}`);
|
|
61
|
-
}
|
|
62
|
-
state.runtime.bindAffinity({
|
|
63
|
-
instanceId: envelope.instanceId,
|
|
64
|
-
flowId: command.flowId,
|
|
65
|
-
});
|
|
66
|
-
const shouldResolveFlowRun = runtime.flowRunId === null;
|
|
67
|
-
if (shouldResolveFlowRun &&
|
|
68
|
-
!state.runtime.beginFlowRunResolution(envelope.requestId)) {
|
|
69
|
-
return dispatchToCore(envelope, Object.assign(Object.assign({}, command), { flowHandleId }));
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const settlement = await dispatchToCore(envelope, Object.assign(Object.assign({}, command), { flowHandleId }));
|
|
73
|
-
if (!settlement.ok) {
|
|
74
|
-
if (shouldResolveFlowRun) {
|
|
75
|
-
state.runtime.finishFlowRunResolution(envelope.requestId);
|
|
76
|
-
}
|
|
77
|
-
return settlement;
|
|
78
|
-
}
|
|
79
|
-
assertSettlementMatches({
|
|
80
|
-
envelope,
|
|
81
|
-
expectedKind: command.kind,
|
|
82
|
-
settlement,
|
|
83
|
-
});
|
|
84
|
-
const allocation = getFlowHandleFromSettlementDetail(settlement);
|
|
85
|
-
if ((allocation === null || allocation === void 0 ? void 0 : allocation.flowHandleId) !== flowHandleId ||
|
|
86
|
-
allocation.flowRunId === undefined) {
|
|
87
|
-
throw new Error(`Expected ${command.kind} settlement to include matching flowHandleId and flowRunId`);
|
|
88
|
-
}
|
|
89
|
-
if (shouldResolveFlowRun &&
|
|
90
|
-
!state.runtime.finishFlowRunResolution(envelope.requestId)) {
|
|
91
|
-
throw new Error(`Could not finish flow-run resolution for requestId "${envelope.requestId}"`);
|
|
92
|
-
}
|
|
93
|
-
state.runtime.bindFlowRun({
|
|
94
|
-
flowRunId: allocation.flowRunId,
|
|
95
|
-
activationPolicy: "never",
|
|
96
|
-
});
|
|
97
|
-
return settlement;
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (shouldResolveFlowRun) {
|
|
101
|
-
state.runtime.finishFlowRunResolution(envelope.requestId);
|
|
102
|
-
}
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
const dispatchHandleClose = async (envelope, command) => {
|
|
108
|
-
const flowHandleId = command.flowHandleId;
|
|
109
|
-
return flowHandleCommandStateStore.enqueue(flowHandleId, async (state) => {
|
|
110
|
-
const decision = planFlowHandleCommand({
|
|
111
|
-
command: "close",
|
|
112
|
-
runtime: state.runtime.getSnapshot(),
|
|
113
|
-
instanceId: envelope.instanceId,
|
|
114
|
-
});
|
|
115
|
-
if (decision === "ignore") {
|
|
116
|
-
return {
|
|
117
|
-
instanceId: envelope.instanceId,
|
|
118
|
-
kind: "close",
|
|
119
|
-
ok: true,
|
|
120
|
-
requestId: envelope.requestId,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
if (decision === "forward-to-core") {
|
|
124
|
-
return dispatchToCore(envelope, command);
|
|
125
|
-
}
|
|
126
|
-
if (decision !== "orchestrate") {
|
|
127
|
-
throw new Error(`Unexpected flow-handle command decision for close: ${decision}`);
|
|
128
|
-
}
|
|
129
|
-
state.runtime.bindAffinity({ instanceId: envelope.instanceId });
|
|
130
|
-
const settlement = await dispatchToCore(envelope, command);
|
|
131
|
-
if (settlement.ok) {
|
|
132
|
-
assertSettlementMatches({
|
|
133
|
-
envelope,
|
|
134
|
-
expectedKind: "close",
|
|
135
|
-
settlement,
|
|
136
|
-
});
|
|
137
|
-
flowHandleCommandStateStore.invalidate(flowHandleId);
|
|
138
|
-
}
|
|
139
|
-
return settlement;
|
|
17
|
+
const assertAllocationSettlement = (envelope, command, settlement) => {
|
|
18
|
+
assertSettlementMatches({
|
|
19
|
+
envelope,
|
|
20
|
+
expectedKind: command.kind,
|
|
21
|
+
settlement,
|
|
140
22
|
});
|
|
23
|
+
const allocation = getFlowHandleFromSettlementDetail(settlement);
|
|
24
|
+
if (!(allocation === null || allocation === void 0 ? void 0 : allocation.flowRunId) ||
|
|
25
|
+
(command.flowHandleId !== undefined &&
|
|
26
|
+
allocation.flowHandleId !== command.flowHandleId)) {
|
|
27
|
+
throw new Error(command.flowHandleId === undefined
|
|
28
|
+
? `Expected ${command.kind} settlement to include flowHandleId and flowRunId`
|
|
29
|
+
: `Expected ${command.kind} settlement to include matching flowHandleId and flowRunId`);
|
|
30
|
+
}
|
|
141
31
|
};
|
|
142
32
|
return {
|
|
143
|
-
dispatch: (envelope) => {
|
|
33
|
+
dispatch: async (envelope) => {
|
|
34
|
+
const settlement = await dispatchToCore(envelope, envelope.command);
|
|
35
|
+
if (!settlement.ok) {
|
|
36
|
+
return settlement;
|
|
37
|
+
}
|
|
144
38
|
switch (envelope.command.kind) {
|
|
145
39
|
case "open":
|
|
146
40
|
case "prerender":
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return dispatchToCore(envelope, envelope.command);
|
|
41
|
+
assertAllocationSettlement(envelope, envelope.command, settlement);
|
|
42
|
+
break;
|
|
150
43
|
case "close":
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
44
|
+
assertSettlementMatches({
|
|
45
|
+
envelope,
|
|
46
|
+
expectedKind: "close",
|
|
47
|
+
settlement,
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
154
50
|
}
|
|
51
|
+
return settlement;
|
|
155
52
|
},
|
|
156
53
|
};
|
|
157
54
|
}
|
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 : "3.0.
|
|
6
|
+
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "3.0.73";
|
|
@@ -32,209 +32,6 @@ function createActiveViewSnapshotListController() {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
// ../view-orchestration/src/flow-handle-runtime-machine.ts
|
|
36
|
-
import { createMachine, interpret, reduce, state, transition } from "robot3";
|
|
37
|
-
var FLOW_HANDLE_RUNTIME_STATE_SET = {
|
|
38
|
-
active: true,
|
|
39
|
-
invalidated: true
|
|
40
|
-
};
|
|
41
|
-
var hasFlowHandleAffinityConflict = (input) => input.boundInstanceId !== undefined && input.boundInstanceId !== input.instanceId || input.flowId !== undefined && input.boundFlowId !== undefined && input.boundFlowId !== input.flowId;
|
|
42
|
-
var assertAffinityCompatible = (input) => {
|
|
43
|
-
const { context, event } = input;
|
|
44
|
-
if (!hasFlowHandleAffinityConflict({
|
|
45
|
-
boundInstanceId: context.instanceId,
|
|
46
|
-
boundFlowId: context.flowId,
|
|
47
|
-
instanceId: event.instanceId,
|
|
48
|
-
flowId: event.flowId
|
|
49
|
-
})) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (context.instanceId !== undefined && context.instanceId !== event.instanceId) {
|
|
53
|
-
throw new Error(`Flow handle affinity conflict: instanceId already bound to "${context.instanceId}" and cannot be rebound to "${event.instanceId}"`);
|
|
54
|
-
}
|
|
55
|
-
throw new Error(`Flow handle affinity conflict: flowId already bound to "${context.flowId}" and cannot be rebound to "${event.flowId}"`);
|
|
56
|
-
};
|
|
57
|
-
var bindAffinity = reduce((context, event) => {
|
|
58
|
-
assertAffinityCompatible({ context, event });
|
|
59
|
-
return {
|
|
60
|
-
...context,
|
|
61
|
-
instanceId: event.instanceId,
|
|
62
|
-
flowId: event.flowId ?? context.flowId
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
var bindFlowRun = reduce((context, event) => {
|
|
66
|
-
if (context.instanceId === undefined) {
|
|
67
|
-
throw new Error("Cannot bind flowRunId before instance affinity is bound for flow handle runtime");
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
...context,
|
|
71
|
-
flowRunId: event.flowRunId
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
var beginFlowRunResolution = reduce((context, event) => {
|
|
75
|
-
if (context.instanceId === undefined) {
|
|
76
|
-
throw new Error("Cannot begin flowRun resolution before instance affinity is bound for flow handle runtime");
|
|
77
|
-
}
|
|
78
|
-
if (context.pendingFlowRunResolutionRequestId !== null && context.pendingFlowRunResolutionRequestId !== event.requestId) {
|
|
79
|
-
throw new Error(`Flow handle already has a pending flowRun resolution for requestId "${context.pendingFlowRunResolutionRequestId}"`);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
...context,
|
|
83
|
-
pendingFlowRunResolutionRequestId: event.requestId
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
var clearFlowRunResolution = reduce((context, event) => context.pendingFlowRunResolutionRequestId === event.requestId ? { ...context, pendingFlowRunResolutionRequestId: null } : context);
|
|
87
|
-
var setContainerMode = reduce((context, event) => {
|
|
88
|
-
if (context.containerMode !== undefined && context.containerMode !== event.mode) {
|
|
89
|
-
throw new Error(`Flow handle container mode conflict: already locked to "${context.containerMode}" and cannot switch to "${event.mode}"`);
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
...context,
|
|
93
|
-
containerMode: event.mode
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
var invalidateRuntime = reduce((context) => ({
|
|
97
|
-
...context,
|
|
98
|
-
instanceId: undefined,
|
|
99
|
-
flowId: undefined,
|
|
100
|
-
flowRunId: null,
|
|
101
|
-
pendingFlowRunResolutionRequestId: null,
|
|
102
|
-
containerMode: undefined
|
|
103
|
-
}));
|
|
104
|
-
function createFlowHandleRuntimeMachine() {
|
|
105
|
-
const states = {
|
|
106
|
-
active: state(transition("bindAffinity", "active", bindAffinity), transition("bindFlowRun", "active", bindFlowRun), transition("beginFlowRunResolution", "active", beginFlowRunResolution), transition("finishFlowRunResolution", "active", clearFlowRunResolution), transition("setContainerMode", "active", setContainerMode), transition("invalidate", "invalidated", invalidateRuntime)),
|
|
107
|
-
invalidated: state()
|
|
108
|
-
};
|
|
109
|
-
return createMachine(states, () => ({
|
|
110
|
-
instanceId: undefined,
|
|
111
|
-
flowId: undefined,
|
|
112
|
-
flowRunId: null,
|
|
113
|
-
pendingFlowRunResolutionRequestId: null,
|
|
114
|
-
containerMode: undefined
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
function createFlowHandleRuntimeController() {
|
|
118
|
-
const machine = createFlowHandleRuntimeMachine();
|
|
119
|
-
const service = interpret(machine, () => {});
|
|
120
|
-
const buildSnapshot = (svc) => {
|
|
121
|
-
const context = svc.context;
|
|
122
|
-
return {
|
|
123
|
-
state: readFlowHandleRuntimeState(svc.machine.current),
|
|
124
|
-
instanceId: context.instanceId,
|
|
125
|
-
flowId: context.flowId,
|
|
126
|
-
flowRunId: context.flowRunId,
|
|
127
|
-
pendingFlowRunResolutionRequestId: context.pendingFlowRunResolutionRequestId,
|
|
128
|
-
containerMode: context.containerMode
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
return {
|
|
132
|
-
getSnapshot: () => buildSnapshot(service),
|
|
133
|
-
bindAffinity: (input) => {
|
|
134
|
-
service.send({
|
|
135
|
-
type: "bindAffinity",
|
|
136
|
-
instanceId: input.instanceId,
|
|
137
|
-
...input.flowId !== undefined ? { flowId: input.flowId } : {}
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
bindFlowRun: (input) => {
|
|
141
|
-
if (readFlowHandleRuntimeState(service.machine.current) === "invalidated") {
|
|
142
|
-
return "ignore";
|
|
143
|
-
}
|
|
144
|
-
const previousFlowRunId = service.context.flowRunId;
|
|
145
|
-
service.send({
|
|
146
|
-
type: "bindFlowRun",
|
|
147
|
-
flowRunId: input.flowRunId
|
|
148
|
-
});
|
|
149
|
-
if (input.activationPolicy === "always" || input.activationPolicy === "on-flow-run-change" && previousFlowRunId !== input.flowRunId) {
|
|
150
|
-
return "request-activation";
|
|
151
|
-
}
|
|
152
|
-
return "register";
|
|
153
|
-
},
|
|
154
|
-
beginFlowRunResolution: (requestId) => {
|
|
155
|
-
if (readFlowHandleRuntimeState(service.machine.current) === "invalidated") {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
service.send({ type: "beginFlowRunResolution", requestId });
|
|
159
|
-
return true;
|
|
160
|
-
},
|
|
161
|
-
finishFlowRunResolution: (requestId) => {
|
|
162
|
-
if (readFlowHandleRuntimeState(service.machine.current) === "invalidated" || service.context.pendingFlowRunResolutionRequestId !== requestId) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
service.send({ type: "finishFlowRunResolution", requestId });
|
|
166
|
-
return true;
|
|
167
|
-
},
|
|
168
|
-
setContainerMode: (mode) => {
|
|
169
|
-
service.send({ type: "setContainerMode", mode });
|
|
170
|
-
},
|
|
171
|
-
invalidate: () => {
|
|
172
|
-
service.send({ type: "invalidate" });
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function readFlowHandleRuntimeState(value) {
|
|
177
|
-
if (!isFlowHandleRuntimeState(value)) {
|
|
178
|
-
throw new Error(`Unknown flow-handle runtime state: ${String(value)}`);
|
|
179
|
-
}
|
|
180
|
-
return value;
|
|
181
|
-
}
|
|
182
|
-
function isFlowHandleRuntimeState(value) {
|
|
183
|
-
return typeof value === "string" && value in FLOW_HANDLE_RUNTIME_STATE_SET;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// ../view-orchestration/src/flow-handle-command-planner.ts
|
|
187
|
-
var planFlowHandleCommand = (input) => {
|
|
188
|
-
if (input.runtime.state === "invalidated") {
|
|
189
|
-
return input.command === "open" || input.command === "prerender" ? "forward-to-core" : "ignore";
|
|
190
|
-
}
|
|
191
|
-
if (hasFlowHandleAffinityConflict({
|
|
192
|
-
boundInstanceId: input.runtime.instanceId,
|
|
193
|
-
boundFlowId: input.runtime.flowId,
|
|
194
|
-
instanceId: input.instanceId,
|
|
195
|
-
...input.command === "open" || input.command === "prerender" ? { flowId: input.flowId } : {}
|
|
196
|
-
})) {
|
|
197
|
-
return input.command === "setContainer" ? "reject" : "forward-to-core";
|
|
198
|
-
}
|
|
199
|
-
return "orchestrate";
|
|
200
|
-
};
|
|
201
|
-
// ../view-orchestration/src/flow-handle-command-state-store.ts
|
|
202
|
-
var createInitialFlowHandleCommandState = () => ({
|
|
203
|
-
runtime: createFlowHandleRuntimeController()
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
class FlowHandleCommandStateStore {
|
|
207
|
-
flowHandles = new Map;
|
|
208
|
-
getOrCreate(flowHandleId) {
|
|
209
|
-
const existing = this.flowHandles.get(flowHandleId);
|
|
210
|
-
if (existing) {
|
|
211
|
-
return existing;
|
|
212
|
-
}
|
|
213
|
-
const created = {
|
|
214
|
-
state: createInitialFlowHandleCommandState(),
|
|
215
|
-
tail: Promise.resolve()
|
|
216
|
-
};
|
|
217
|
-
this.flowHandles.set(flowHandleId, created);
|
|
218
|
-
return created;
|
|
219
|
-
}
|
|
220
|
-
enqueue(flowHandleId, task) {
|
|
221
|
-
const entry = this.getOrCreate(flowHandleId);
|
|
222
|
-
const nextTask = entry.tail.then(() => task(entry.state), () => task(entry.state));
|
|
223
|
-
entry.tail = nextTask.then(() => {
|
|
224
|
-
return;
|
|
225
|
-
}, () => {
|
|
226
|
-
return;
|
|
227
|
-
});
|
|
228
|
-
return nextTask;
|
|
229
|
-
}
|
|
230
|
-
invalidate(flowHandleId) {
|
|
231
|
-
const state2 = this.getOrCreate(flowHandleId).state;
|
|
232
|
-
if (state2.runtime.getSnapshot().state !== "invalidated") {
|
|
233
|
-
state2.runtime.invalidate();
|
|
234
|
-
}
|
|
235
|
-
return state2;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
35
|
// ../view-orchestration/src/pending-command-tracker.ts
|
|
239
36
|
var createDeferred = () => {
|
|
240
37
|
let resolve;
|
|
@@ -287,7 +84,7 @@ class PendingCommandTracker {
|
|
|
287
84
|
}
|
|
288
85
|
}
|
|
289
86
|
// ../view-orchestration/src/view-activation-machine.ts
|
|
290
|
-
import { createMachine
|
|
87
|
+
import { createMachine, interpret, state, transition } from "robot3";
|
|
291
88
|
var VIEW_ACTIVATION_STATES = {
|
|
292
89
|
idle: true,
|
|
293
90
|
prerendering: true,
|
|
@@ -298,18 +95,18 @@ var VIEW_ACTIVATION_STATES = {
|
|
|
298
95
|
};
|
|
299
96
|
function createViewActivationMachine() {
|
|
300
97
|
const states = {
|
|
301
|
-
idle:
|
|
302
|
-
prerendering:
|
|
303
|
-
"activation-requested":
|
|
304
|
-
"prerendering-activation-requested":
|
|
305
|
-
prerendered:
|
|
306
|
-
active:
|
|
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()
|
|
307
104
|
};
|
|
308
|
-
return
|
|
105
|
+
return createMachine(states, () => ({}));
|
|
309
106
|
}
|
|
310
107
|
function createViewActivationController() {
|
|
311
108
|
const machine = createViewActivationMachine();
|
|
312
|
-
const service =
|
|
109
|
+
const service = interpret(machine, () => {});
|
|
313
110
|
const getState = () => readViewActivationState(service.machine.current);
|
|
314
111
|
const send = (event) => {
|
|
315
112
|
service.send(event);
|
|
@@ -336,22 +133,22 @@ function readViewActivationState(value) {
|
|
|
336
133
|
// ../view-orchestration/src/view-preparation-readiness-registry.ts
|
|
337
134
|
function createViewPreparationReadinessRegistry() {
|
|
338
135
|
const states = new Map;
|
|
339
|
-
const resolveReadySize = (
|
|
340
|
-
if (!
|
|
136
|
+
const resolveReadySize = (state2) => {
|
|
137
|
+
if (!state2 || state2.status === "ready" || !state2.hostPrepared || state2.size === null) {
|
|
341
138
|
return null;
|
|
342
139
|
}
|
|
343
|
-
|
|
344
|
-
return
|
|
140
|
+
state2.status = "ready";
|
|
141
|
+
return state2.size;
|
|
345
142
|
};
|
|
346
143
|
return {
|
|
347
144
|
begin(viewId) {
|
|
348
|
-
const
|
|
145
|
+
const state2 = {
|
|
349
146
|
hostPrepared: false,
|
|
350
147
|
size: null,
|
|
351
148
|
status: "pending"
|
|
352
149
|
};
|
|
353
|
-
states.set(viewId,
|
|
354
|
-
const getCurrentState = () => states.get(viewId) ===
|
|
150
|
+
states.set(viewId, state2);
|
|
151
|
+
const getCurrentState = () => states.get(viewId) === state2 ? state2 : null;
|
|
355
152
|
return {
|
|
356
153
|
markHostPrepared() {
|
|
357
154
|
const current = getCurrentState();
|
|
@@ -469,12 +266,6 @@ function createViewPreparationRegistry() {
|
|
|
469
266
|
function createPendingCommandTracker() {
|
|
470
267
|
return new PendingCommandTracker;
|
|
471
268
|
}
|
|
472
|
-
function createFlowHandleCommandStateStore() {
|
|
473
|
-
return new FlowHandleCommandStateStore;
|
|
474
|
-
}
|
|
475
|
-
function planFlowHandleCommand2(input) {
|
|
476
|
-
return planFlowHandleCommand(input);
|
|
477
|
-
}
|
|
478
269
|
function createActiveViewSnapshotListController2() {
|
|
479
270
|
return createActiveViewSnapshotListController();
|
|
480
271
|
}
|
|
@@ -488,11 +279,9 @@ function createViewPreparationReadinessRegistry2() {
|
|
|
488
279
|
return createViewPreparationReadinessRegistry();
|
|
489
280
|
}
|
|
490
281
|
export {
|
|
491
|
-
planFlowHandleCommand2 as planFlowHandleCommand,
|
|
492
282
|
createViewPreparationRegistry2 as createViewPreparationRegistry,
|
|
493
283
|
createViewPreparationReadinessRegistry2 as createViewPreparationReadinessRegistry,
|
|
494
284
|
createViewActivationController2 as createViewActivationController,
|
|
495
285
|
createPendingCommandTracker,
|
|
496
|
-
createFlowHandleCommandStateStore,
|
|
497
286
|
createActiveViewSnapshotListController2 as createActiveViewSnapshotListController
|
|
498
287
|
};
|