@incodetech/core 2.0.0-rc.0 → 2.0.0
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/package.json +3 -3
- package/dist/Actor-CI32dTbG.d.ts +0 -2
- package/dist/BaseWasmProvider-C_DLEI40.esm.js +0 -1118
- package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +0 -55
- package/dist/BrowserTimerProvider-DhNc_x02.esm.js +0 -22
- package/dist/ITimerCapability-C67ZRskg.esm.js +0 -7
- package/dist/IpifyProvider-D7jx52AL.esm.js +0 -139
- package/dist/Manager-C8PrhBOx.d.ts +0 -19
- package/dist/MotionSensorProvider-4v7xkqAp.esm.js +0 -254
- package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +0 -87
- package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
- package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
- package/dist/addressSearch-BpTbTWCa.esm.js +0 -430
- package/dist/ae-signature-DDDZmWXj.esm.js +0 -12
- package/dist/ae-signature.d.ts +0 -25
- package/dist/ae-signature.esm.js +0 -8
- package/dist/antifraud.d.ts +0 -57
- package/dist/antifraud.esm.js +0 -45
- package/dist/antifraudStateMachine-O0TMf6yc.esm.js +0 -39
- package/dist/api-CESGtpbH.esm.js +0 -53
- package/dist/authentication.d.ts +0 -12
- package/dist/authentication.esm.js +0 -25
- package/dist/authenticationManager-5M-fKzXx.esm.js +0 -67
- package/dist/authenticationManager-C83GNIhl.d.ts +0 -66
- package/dist/authenticationStateMachine-BMZqatiF.esm.js +0 -139
- package/dist/backCameraStream-DMdMeGk2.esm.js +0 -346
- package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
- package/dist/camera-DBSxa6ML.d.ts +0 -4
- package/dist/camera-PA2Ljri3.esm.js +0 -22
- package/dist/camera.d.ts +0 -15
- package/dist/camera.esm.js +0 -5
- package/dist/chunk-CRF6K_H_.esm.js +0 -49
- package/dist/consent.d.ts +0 -398
- package/dist/consent.esm.js +0 -79
- package/dist/consentStateMachine-CCT-B60O.esm.js +0 -151
- package/dist/cpf-PPz2Njto.esm.js +0 -38
- package/dist/cpf-ocr.d.ts +0 -204
- package/dist/cpf-ocr.esm.js +0 -177
- package/dist/cross-document-data-match.d.ts +0 -34
- package/dist/cross-document-data-match.esm.js +0 -71
- package/dist/curp-validation.d.ts +0 -188
- package/dist/curp-validation.esm.js +0 -110
- package/dist/curpValidationStateMachine-CitWLr2c.esm.js +0 -595
- package/dist/custom-fields.d.ts +0 -115
- package/dist/custom-fields.esm.js +0 -177
- package/dist/custom-watchlist.d.ts +0 -66
- package/dist/custom-watchlist.esm.js +0 -86
- package/dist/dateUtils-UoN5xswP.esm.js +0 -23
- package/dist/deepsightLoader-Cm4JIT_z.esm.js +0 -52
- package/dist/deepsightService-CEVxzehb.d.ts +0 -412
- package/dist/deepsightService-O74l4Y__.esm.js +0 -489
- package/dist/device.d.ts +0 -46
- package/dist/device.esm.js +0 -106
- package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
- package/dist/document-capture.d.ts +0 -906
- package/dist/document-capture.esm.js +0 -156
- package/dist/document-upload.d.ts +0 -331
- package/dist/document-upload.esm.js +0 -203
- package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +0 -394
- package/dist/dynamic-forms.d.ts +0 -178
- package/dist/dynamic-forms.esm.js +0 -323
- package/dist/ekyb.d.ts +0 -148
- package/dist/ekyb.esm.js +0 -127
- package/dist/ekybStateMachine-B59rQjgj.esm.js +0 -674
- package/dist/ekyc.d.ts +0 -164
- package/dist/ekyc.esm.js +0 -104
- package/dist/ekycStateMachine-oeO0Iekd.esm.js +0 -10626
- package/dist/electronic-signature.d.ts +0 -4
- package/dist/electronic-signature.esm.js +0 -7
- package/dist/electronicSignatureManager-D9OHzTpG.esm.js +0 -428
- package/dist/email.d.ts +0 -4
- package/dist/email.esm.js +0 -9
- package/dist/emailManager-DIfnS5g1.d.ts +0 -352
- package/dist/emailManager-wAV0LE-H.esm.js +0 -238
- package/dist/emailStateMachine-DOf4j58N.esm.js +0 -292
- package/dist/endpoints-CnN3SyDa.esm.js +0 -87
- package/dist/events-D6-e4vok.esm.js +0 -596
- package/dist/events.d.ts +0 -265
- package/dist/events.esm.js +0 -4
- package/dist/extensibility.d.ts +0 -122
- package/dist/extensibility.esm.js +0 -43
- package/dist/face-match.d.ts +0 -228
- package/dist/face-match.esm.js +0 -173
- package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +0 -290
- package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +0 -690
- package/dist/faceCaptureSetup-B3faSpYA.esm.js +0 -873
- package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +0 -127
- package/dist/flow-events.d.ts +0 -6
- package/dist/flow-events.esm.js +0 -0
- package/dist/flow.d.ts +0 -358
- package/dist/flow.esm.js +0 -825
- package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
- package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
- package/dist/flowServices-DTsm-Vf1.esm.js +0 -188
- package/dist/geolocation.d.ts +0 -127
- package/dist/geolocation.esm.js +0 -89
- package/dist/geolocationStateMachine-asasuHY2.esm.js +0 -105
- package/dist/getBrowser-BSXUTWXw.esm.js +0 -41
- package/dist/getDeviceClass-BSntT9_j.esm.js +0 -14
- package/dist/government-validation.d.ts +0 -67
- package/dist/government-validation.esm.js +0 -81
- package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +0 -271
- package/dist/home.d.ts +0 -99
- package/dist/home.esm.js +0 -61
- package/dist/http.d.ts +0 -68
- package/dist/http.esm.js +0 -3
- package/dist/id-ocr.d.ts +0 -635
- package/dist/id-ocr.esm.js +0 -86
- package/dist/id-verification.d.ts +0 -190
- package/dist/id-verification.esm.js +0 -43
- package/dist/id.d.ts +0 -24
- package/dist/id.esm.js +0 -164
- package/dist/idCaptureManager-B9TGA5dq.d.ts +0 -956
- package/dist/idCaptureManager-DMK0GIt3.esm.js +0 -581
- package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +0 -2954
- package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +0 -388
- package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +0 -71
- package/dist/identity-reuse.d.ts +0 -530
- package/dist/identity-reuse.esm.js +0 -274
- package/dist/index-BLKtMA0g.d.ts +0 -1177
- package/dist/index-BcRG8rtJ.d.ts +0 -97
- package/dist/index.d.ts +0 -3
- package/dist/index.esm.js +0 -12
- package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +0 -30
- package/dist/lib-BB0B_qQX.esm.js +0 -12499
- package/dist/mandatory-consent.d.ts +0 -412
- package/dist/mandatory-consent.esm.js +0 -78
- package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +0 -126
- package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
- package/dist/openviduLazy-Cok70ZSg.esm.js +0 -12
- package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
- package/dist/phone.d.ts +0 -4
- package/dist/phone.esm.js +0 -9
- package/dist/phoneManager-B6M30hKE.d.ts +0 -397
- package/dist/phoneManager-DAJbGhlY.esm.js +0 -256
- package/dist/phoneStateMachine-CuPARRaT.esm.js +0 -351
- package/dist/platform-CfrjKhmi.esm.js +0 -83
- package/dist/qe-signature-DFo_Cc-I.esm.js +0 -12
- package/dist/qe-signature.d.ts +0 -25
- package/dist/qe-signature.esm.js +0 -8
- package/dist/recordingService-Ig2UgbLv.esm.js +0 -1003
- package/dist/redirect-to-mobile.d.ts +0 -107
- package/dist/redirect-to-mobile.esm.js +0 -102
- package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +0 -249
- package/dist/runChildModule-CqqwqAkW.esm.js +0 -219
- package/dist/selfie.d.ts +0 -26
- package/dist/selfie.esm.js +0 -146
- package/dist/selfieManager-D0lSgd-J.d.ts +0 -68
- package/dist/selfieManager-Duisl7qN.esm.js +0 -60
- package/dist/selfieStateMachine-D76whWEf.esm.js +0 -68
- package/dist/session-BS-d_vuE.esm.js +0 -3206
- package/dist/session.d.ts +0 -217
- package/dist/session.esm.js +0 -9
- package/dist/setup-Buy-hyj4.esm.js +0 -887
- package/dist/setup-C5AITV8m.d.ts +0 -254
- package/dist/signature.d.ts +0 -94
- package/dist/signature.esm.js +0 -66
- package/dist/signatureStateMachine-B5-QVUve.esm.js +0 -132
- package/dist/stats-CIfiPzb1.esm.js +0 -16
- package/dist/stats.d.ts +0 -16
- package/dist/stats.esm.js +0 -4
- package/dist/trust-graph.d.ts +0 -54
- package/dist/trust-graph.esm.js +0 -56
- package/dist/types-B06Ypu2F.d.ts +0 -49
- package/dist/types-BP1m8VRw.d.ts +0 -340
- package/dist/types-CAD4va6a.d.ts +0 -5
- package/dist/types-CFV9G_7j.d.ts +0 -24
- package/dist/warmup-CEcppFiS.d.ts +0 -63
- package/dist/wasm.d.ts +0 -15
- package/dist/wasm.esm.js +0 -12
- package/dist/watchlist-for-business.d.ts +0 -79
- package/dist/watchlist-for-business.esm.js +0 -148
- package/dist/watchlist.d.ts +0 -62
- package/dist/watchlist.esm.js +0 -86
- package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
- package/dist/workflow.d.ts +0 -907
- package/dist/workflow.esm.js +0 -702
- package/dist/xstate.esm-B70JrNqo.esm.js +0 -3404
package/dist/flow.esm.js
DELETED
|
@@ -1,825 +0,0 @@
|
|
|
1
|
-
import "./api-CESGtpbH.esm.js";
|
|
2
|
-
import "./events-D6-e4vok.esm.js";
|
|
3
|
-
import "./endpoints-CnN3SyDa.esm.js";
|
|
4
|
-
import "./session-BS-d_vuE.esm.js";
|
|
5
|
-
import "./IpifyProvider-D7jx52AL.esm.js";
|
|
6
|
-
import "./browserSimulation-gxD8cSpM.esm.js";
|
|
7
|
-
import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
|
|
8
|
-
import { n as getRequiredWasmPipelines, r as normalizeFlowModules, t as getFlow } from "./flowServices-DTsm-Vf1.esm.js";
|
|
9
|
-
import { n as attachFlowEventEmitter, t as runChildModule } from "./runChildModule-CqqwqAkW.esm.js";
|
|
10
|
-
import { t as getFinishStatus } from "./flowCompletionService-P54yzGvA.esm.js";
|
|
11
|
-
|
|
12
|
-
//#region src/modules/flow/noOpFlowModuleMachine.ts
|
|
13
|
-
const noOpFlowModuleMachine = setup({}).createMachine({
|
|
14
|
-
id: "noOpFlowModule",
|
|
15
|
-
initial: "finished",
|
|
16
|
-
states: { finished: { type: "final" } }
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/modules/flow/flowStateMachine.ts
|
|
21
|
-
const flowMachine = setup({
|
|
22
|
-
types: {
|
|
23
|
-
context: {},
|
|
24
|
-
events: {},
|
|
25
|
-
input: {}
|
|
26
|
-
},
|
|
27
|
-
actors: { fetchFlow: fromPromise(async ({ input, signal }) => {
|
|
28
|
-
return input.getFlow(signal);
|
|
29
|
-
}) },
|
|
30
|
-
actions: {
|
|
31
|
-
resetContext: assign(({ context }) => ({
|
|
32
|
-
flow: void 0,
|
|
33
|
-
error: void 0,
|
|
34
|
-
steps: [],
|
|
35
|
-
currentStepIndex: -1,
|
|
36
|
-
currentStep: void 0,
|
|
37
|
-
config: void 0,
|
|
38
|
-
getFlow: context.getFlow
|
|
39
|
-
})),
|
|
40
|
-
setFlowData: assign(({ event }) => {
|
|
41
|
-
const flow = event.output;
|
|
42
|
-
return {
|
|
43
|
-
flow,
|
|
44
|
-
steps: (flow.flowModules ?? []).map((m) => m.key),
|
|
45
|
-
currentStepIndex: (flow.flowModules ?? []).length > 0 ? 0 : -1,
|
|
46
|
-
currentStep: flow.flowModules?.[0]?.key,
|
|
47
|
-
config: flow.flowModules?.[0]?.configuration
|
|
48
|
-
};
|
|
49
|
-
}),
|
|
50
|
-
setError: assign(({ event }) => ({ error: String(event.error) })),
|
|
51
|
-
incrementStep: assign(({ context }) => {
|
|
52
|
-
const nextIndex = context.currentStepIndex + 1;
|
|
53
|
-
const module = context.flow?.flowModules?.[nextIndex];
|
|
54
|
-
return {
|
|
55
|
-
currentStepIndex: nextIndex,
|
|
56
|
-
currentStep: module?.key,
|
|
57
|
-
config: module?.configuration
|
|
58
|
-
};
|
|
59
|
-
}),
|
|
60
|
-
decrementStep: assign(({ context }) => {
|
|
61
|
-
const prevIndex = context.currentStepIndex - 1;
|
|
62
|
-
const module = context.flow?.flowModules?.[prevIndex];
|
|
63
|
-
return {
|
|
64
|
-
currentStepIndex: prevIndex,
|
|
65
|
-
currentStep: module?.key,
|
|
66
|
-
config: module?.configuration
|
|
67
|
-
};
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
guards: {
|
|
71
|
-
isLastStep: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex === context.steps.length - 1,
|
|
72
|
-
canGoNext: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex < context.steps.length - 1,
|
|
73
|
-
canGoPrev: ({ context }) => context.currentStepIndex > 0
|
|
74
|
-
}
|
|
75
|
-
}).createMachine({
|
|
76
|
-
id: "flow",
|
|
77
|
-
initial: "idle",
|
|
78
|
-
context: ({ input }) => ({
|
|
79
|
-
flow: void 0,
|
|
80
|
-
error: void 0,
|
|
81
|
-
steps: [],
|
|
82
|
-
currentStepIndex: -1,
|
|
83
|
-
currentStep: void 0,
|
|
84
|
-
config: void 0,
|
|
85
|
-
getFlow: input.getFlow
|
|
86
|
-
}),
|
|
87
|
-
states: {
|
|
88
|
-
idle: { on: { LOAD: {
|
|
89
|
-
target: "loading",
|
|
90
|
-
actions: "resetContext"
|
|
91
|
-
} } },
|
|
92
|
-
loading: {
|
|
93
|
-
invoke: {
|
|
94
|
-
id: "fetchFlow",
|
|
95
|
-
src: "fetchFlow",
|
|
96
|
-
input: ({ context }) => ({ getFlow: context.getFlow }),
|
|
97
|
-
onDone: {
|
|
98
|
-
target: "ready",
|
|
99
|
-
actions: "setFlowData"
|
|
100
|
-
},
|
|
101
|
-
onError: {
|
|
102
|
-
target: "error",
|
|
103
|
-
actions: "setError"
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
on: { CANCEL: {
|
|
107
|
-
target: "idle",
|
|
108
|
-
actions: "resetContext"
|
|
109
|
-
} }
|
|
110
|
-
},
|
|
111
|
-
ready: { on: {
|
|
112
|
-
NEXT_STEP: [{
|
|
113
|
-
target: "finished",
|
|
114
|
-
guard: "isLastStep"
|
|
115
|
-
}, {
|
|
116
|
-
target: "ready",
|
|
117
|
-
guard: "canGoNext",
|
|
118
|
-
actions: "incrementStep"
|
|
119
|
-
}],
|
|
120
|
-
PREV_STEP: {
|
|
121
|
-
target: "ready",
|
|
122
|
-
guard: "canGoPrev",
|
|
123
|
-
actions: "decrementStep"
|
|
124
|
-
},
|
|
125
|
-
RESET: {
|
|
126
|
-
target: "idle",
|
|
127
|
-
actions: "resetContext"
|
|
128
|
-
}
|
|
129
|
-
} },
|
|
130
|
-
finished: { on: { RESET: {
|
|
131
|
-
target: "idle",
|
|
132
|
-
actions: "resetContext"
|
|
133
|
-
} } },
|
|
134
|
-
error: { on: { RESET: {
|
|
135
|
-
target: "idle",
|
|
136
|
-
actions: "resetContext"
|
|
137
|
-
} } }
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/modules/flow/flowActor.ts
|
|
143
|
-
function createFlowActor(options) {
|
|
144
|
-
return createActor(flowMachine, { input: { getFlow: options?.getFlow ?? getFlow } }).start();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/modules/flow/flowManager.ts
|
|
149
|
-
function mapState(snapshot) {
|
|
150
|
-
const { value, context } = snapshot;
|
|
151
|
-
switch (value) {
|
|
152
|
-
case "idle": return { status: "idle" };
|
|
153
|
-
case "loading": return { status: "loading" };
|
|
154
|
-
case "ready": return {
|
|
155
|
-
status: "ready",
|
|
156
|
-
flow: context.flow ?? {},
|
|
157
|
-
steps: context.steps,
|
|
158
|
-
currentStepIndex: context.currentStepIndex,
|
|
159
|
-
currentStep: context.currentStep,
|
|
160
|
-
config: context.config
|
|
161
|
-
};
|
|
162
|
-
case "finished": return {
|
|
163
|
-
status: "finished",
|
|
164
|
-
flow: context.flow ?? {}
|
|
165
|
-
};
|
|
166
|
-
case "error": return {
|
|
167
|
-
status: "error",
|
|
168
|
-
error: context.error ?? "Unknown error"
|
|
169
|
-
};
|
|
170
|
-
default: return { status: "idle" };
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function createApi({ actor, getSnapshot, trackElementClicked }) {
|
|
174
|
-
function getCanNext() {
|
|
175
|
-
const snapshot = getSnapshot();
|
|
176
|
-
const { currentStepIndex, steps } = snapshot.context;
|
|
177
|
-
return snapshot.matches("ready") && currentStepIndex >= 0 && currentStepIndex < steps.length - 1;
|
|
178
|
-
}
|
|
179
|
-
function getCanPrev() {
|
|
180
|
-
const snapshot = getSnapshot();
|
|
181
|
-
return snapshot.matches("ready") && snapshot.context.currentStepIndex > 0;
|
|
182
|
-
}
|
|
183
|
-
function getModuleConfig$1(moduleKey) {
|
|
184
|
-
const snapshot = getSnapshot();
|
|
185
|
-
if (!snapshot.matches("ready")) return;
|
|
186
|
-
return (snapshot.context.flow?.flowModules.find((m) => m.key === moduleKey))?.configuration;
|
|
187
|
-
}
|
|
188
|
-
function isModuleEnabled(moduleKey) {
|
|
189
|
-
const snapshot = getSnapshot();
|
|
190
|
-
if (!snapshot.matches("ready")) return false;
|
|
191
|
-
return !!snapshot.context.flow?.flowModules.some((m) => m.key === moduleKey);
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
load() {
|
|
195
|
-
actor.send({ type: "LOAD" });
|
|
196
|
-
},
|
|
197
|
-
cancel() {
|
|
198
|
-
trackElementClicked?.("cancel");
|
|
199
|
-
actor.send({ type: "CANCEL" });
|
|
200
|
-
},
|
|
201
|
-
reset() {
|
|
202
|
-
actor.send({ type: "RESET" });
|
|
203
|
-
},
|
|
204
|
-
nextStep() {
|
|
205
|
-
trackElementClicked?.("nextStep");
|
|
206
|
-
actor.send({ type: "NEXT_STEP" });
|
|
207
|
-
},
|
|
208
|
-
prevStep() {
|
|
209
|
-
trackElementClicked?.("prevStep");
|
|
210
|
-
actor.send({ type: "PREV_STEP" });
|
|
211
|
-
},
|
|
212
|
-
get canNext() {
|
|
213
|
-
return getCanNext();
|
|
214
|
-
},
|
|
215
|
-
get canPrev() {
|
|
216
|
-
return getCanPrev();
|
|
217
|
-
},
|
|
218
|
-
getModuleConfig: getModuleConfig$1,
|
|
219
|
-
isModuleEnabled
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Creates a flow manager instance for managing onboarding flow state and navigation.
|
|
224
|
-
*
|
|
225
|
-
* The flow manager provides:
|
|
226
|
-
* - State management with statuses: `idle`, `loading`, `ready`, `finished`, `error`
|
|
227
|
-
* - Step navigation with `nextStep()` and `prevStep()`
|
|
228
|
-
* - Current step info via `state.currentStep` and `state.config` when in `ready` state
|
|
229
|
-
* - Module configuration lookup via `getModuleConfig()`
|
|
230
|
-
*
|
|
231
|
-
* @param options - Optional configuration for the flow actor
|
|
232
|
-
* @param options.getFlow - Custom function to fetch flow data. Defaults to `getOnboardingFlow`
|
|
233
|
-
* @returns A manager instance with state subscription, API methods, and lifecycle controls
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* ```ts
|
|
237
|
-
* const flowManager = createFlowManager();
|
|
238
|
-
*
|
|
239
|
-
* flowManager.subscribe((state) => {
|
|
240
|
-
* if (state.status === 'ready') {
|
|
241
|
-
* console.log(state.currentStep, state.config);
|
|
242
|
-
* }
|
|
243
|
-
* });
|
|
244
|
-
*
|
|
245
|
-
* flowManager.load({ token: 'session-token' });
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
function createFlowManager(options) {
|
|
249
|
-
return attachFlowEventEmitter(createManager({
|
|
250
|
-
actor: createFlowActor(options),
|
|
251
|
-
mapState,
|
|
252
|
-
createApi
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/modules/flow/moduleLoader.ts
|
|
258
|
-
var ModuleLoaderImpl = class {
|
|
259
|
-
constructor(registry) {
|
|
260
|
-
this.registry = registry;
|
|
261
|
-
this.loadedModules = /* @__PURE__ */ new Map();
|
|
262
|
-
this.prefetchedModules = /* @__PURE__ */ new Set();
|
|
263
|
-
}
|
|
264
|
-
async load(moduleKey) {
|
|
265
|
-
if (!this.registry[moduleKey]) throw new Error(`Module ${moduleKey} not found in registry`);
|
|
266
|
-
const cached = this.loadedModules.get(moduleKey);
|
|
267
|
-
if (cached) return await cached;
|
|
268
|
-
const loadPromise = this.registry[moduleKey]().then((module) => {
|
|
269
|
-
if (module && typeof module === "object" && "default" in module) return module.default;
|
|
270
|
-
return module;
|
|
271
|
-
});
|
|
272
|
-
this.loadedModules.set(moduleKey, loadPromise);
|
|
273
|
-
try {
|
|
274
|
-
return await loadPromise;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
this.loadedModules.delete(moduleKey);
|
|
277
|
-
throw error;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
prefetch(moduleKey) {
|
|
281
|
-
if (!this.registry[moduleKey]) return;
|
|
282
|
-
if (this.prefetchedModules.has(moduleKey) || this.loadedModules.has(moduleKey)) return;
|
|
283
|
-
this.prefetchedModules.add(moduleKey);
|
|
284
|
-
this.registry[moduleKey]().catch(() => {
|
|
285
|
-
this.prefetchedModules.delete(moduleKey);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
isLoaded(moduleKey) {
|
|
289
|
-
return this.loadedModules.has(moduleKey);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
function createModuleLoader(registry) {
|
|
293
|
-
return new ModuleLoaderImpl(registry);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/modules/flow/orchestratedFlowStateMachine.ts
|
|
298
|
-
function getModuleConfig(module, flow) {
|
|
299
|
-
const config = {
|
|
300
|
-
...module?.configuration,
|
|
301
|
-
ds: flow?.ds
|
|
302
|
-
};
|
|
303
|
-
if (module?.key === "ID" || module?.key === "TUTORIAL_ID" || module?.key === "SECOND_ID" || module?.key === "SELFIE") return {
|
|
304
|
-
...config,
|
|
305
|
-
ageAssurance: config.ageAssurance ?? flow?.ageAssurance
|
|
306
|
-
};
|
|
307
|
-
return config;
|
|
308
|
-
}
|
|
309
|
-
function createBaseContext(context, isHomeContinueLoading) {
|
|
310
|
-
return {
|
|
311
|
-
flow: void 0,
|
|
312
|
-
error: void 0,
|
|
313
|
-
errorCode: void 0,
|
|
314
|
-
steps: [],
|
|
315
|
-
currentStepIndex: -1,
|
|
316
|
-
currentStep: void 0,
|
|
317
|
-
config: void 0,
|
|
318
|
-
getFlow: context.getFlow,
|
|
319
|
-
registeredModules: context.registeredModules,
|
|
320
|
-
lazyRegisteredModules: context.lazyRegisteredModules,
|
|
321
|
-
currentModuleMachine: void 0,
|
|
322
|
-
getFinishStatus: context.getFinishStatus,
|
|
323
|
-
enableHome: context.enableHome,
|
|
324
|
-
finishStatus: void 0,
|
|
325
|
-
isHomeContinueLoading
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function createInitialContext(input) {
|
|
329
|
-
return createBaseContext({
|
|
330
|
-
getFlow: input.getFlow,
|
|
331
|
-
registeredModules: input.modules ?? {},
|
|
332
|
-
lazyRegisteredModules: input.lazyModules ?? {},
|
|
333
|
-
getFinishStatus: input.getFinishStatus ?? getFinishStatus,
|
|
334
|
-
enableHome: input.enableHome === true
|
|
335
|
-
}, false);
|
|
336
|
-
}
|
|
337
|
-
function shouldEnterHome(context) {
|
|
338
|
-
if (context.enableHome !== true) return false;
|
|
339
|
-
if (context.flow?.disableLaunchScreen === true) return false;
|
|
340
|
-
if (context.isHomeContinueLoading === true) return false;
|
|
341
|
-
const firstRealIndex = context.steps[0] === "REDIRECT_TO_MOBILE" ? 1 : 0;
|
|
342
|
-
return context.currentStepIndex === firstRealIndex;
|
|
343
|
-
}
|
|
344
|
-
const prefetchedLazyModules = /* @__PURE__ */ new WeakSet();
|
|
345
|
-
function prefetchNextLazyModule(context) {
|
|
346
|
-
const nextStep = context.steps[context.currentStepIndex + 1];
|
|
347
|
-
if (!nextStep) return;
|
|
348
|
-
const nextLazyModule = context.lazyRegisteredModules[nextStep];
|
|
349
|
-
if (!nextLazyModule || prefetchedLazyModules.has(nextLazyModule)) return;
|
|
350
|
-
prefetchedLazyModules.add(nextLazyModule);
|
|
351
|
-
nextLazyModule().catch(() => {
|
|
352
|
-
prefetchedLazyModules.delete(nextLazyModule);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
const homeContinueOn = { HOME_CONTINUE: { actions: "setHomeContinueLoading" } };
|
|
356
|
-
const orchestratedFlowMachine = setup({
|
|
357
|
-
types: {
|
|
358
|
-
context: {},
|
|
359
|
-
events: {},
|
|
360
|
-
input: {}
|
|
361
|
-
},
|
|
362
|
-
actors: {
|
|
363
|
-
fetchFlow: fromPromise(async ({ input, signal }) => {
|
|
364
|
-
return input.getFlow(signal);
|
|
365
|
-
}),
|
|
366
|
-
notifyBackend: fromPromise(async ({ input, signal }) => {
|
|
367
|
-
return await input.getFinishStatus(input.flowId, signal);
|
|
368
|
-
}),
|
|
369
|
-
runChildModule,
|
|
370
|
-
resolveCurrentModuleMachine: fromPromise(async ({ input }) => {
|
|
371
|
-
if (!input.moduleKey) return;
|
|
372
|
-
const eagerMachine = input.modules[input.moduleKey];
|
|
373
|
-
if (eagerMachine) return eagerMachine;
|
|
374
|
-
const lazyLoader = input.lazyModules[input.moduleKey];
|
|
375
|
-
if (!lazyLoader) return;
|
|
376
|
-
const loaded = await lazyLoader();
|
|
377
|
-
if (loaded && typeof loaded === "object" && "default" in loaded && loaded.default) return loaded.default;
|
|
378
|
-
return loaded;
|
|
379
|
-
})
|
|
380
|
-
},
|
|
381
|
-
actions: {
|
|
382
|
-
resetContext: assign(({ context }) => createBaseContext(context, false)),
|
|
383
|
-
resetContextForLoad: assign(({ context }) => createBaseContext(context, context.isHomeContinueLoading)),
|
|
384
|
-
setHomeContinueLoading: assign({ isHomeContinueLoading: true }),
|
|
385
|
-
clearHomeContinueLoading: assign({ isHomeContinueLoading: false }),
|
|
386
|
-
setFlowData: assign(({ event }) => {
|
|
387
|
-
const flow = event.output;
|
|
388
|
-
const flowModules = flow.flowModules ?? [];
|
|
389
|
-
const firstModule = flowModules[0];
|
|
390
|
-
const config = getModuleConfig(firstModule, flow);
|
|
391
|
-
return {
|
|
392
|
-
flow,
|
|
393
|
-
steps: flowModules.map((m) => m.key),
|
|
394
|
-
currentStepIndex: flowModules.length > 0 ? 0 : -1,
|
|
395
|
-
currentStep: firstModule?.key,
|
|
396
|
-
config,
|
|
397
|
-
currentModuleMachine: void 0
|
|
398
|
-
};
|
|
399
|
-
}),
|
|
400
|
-
setError: assign(({ event }) => {
|
|
401
|
-
const err = event.error;
|
|
402
|
-
return {
|
|
403
|
-
error: err?.message ?? String(err),
|
|
404
|
-
errorCode: err?.status
|
|
405
|
-
};
|
|
406
|
-
}),
|
|
407
|
-
incrementStep: assign(({ context }) => {
|
|
408
|
-
const nextIndex = context.currentStepIndex + 1;
|
|
409
|
-
const module = context.flow?.flowModules?.[nextIndex];
|
|
410
|
-
const config = getModuleConfig(module, context.flow);
|
|
411
|
-
return {
|
|
412
|
-
currentStepIndex: nextIndex,
|
|
413
|
-
currentStep: module?.key,
|
|
414
|
-
config,
|
|
415
|
-
currentModuleMachine: void 0
|
|
416
|
-
};
|
|
417
|
-
}),
|
|
418
|
-
setCurrentModuleMachine: assign(({ event }) => ({ currentModuleMachine: event.output })),
|
|
419
|
-
prefetchNextModule: ({ context }) => {
|
|
420
|
-
prefetchNextLazyModule(context);
|
|
421
|
-
},
|
|
422
|
-
setFinishStatus: assign(({ event }) => ({ finishStatus: event.output }))
|
|
423
|
-
},
|
|
424
|
-
guards: {
|
|
425
|
-
isLastStep: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex === context.steps.length - 1,
|
|
426
|
-
canGoNext: ({ context }) => context.currentStepIndex >= 0 && context.currentStepIndex < context.steps.length - 1,
|
|
427
|
-
shouldEnterHome: ({ context }) => shouldEnterHome(context),
|
|
428
|
-
hasModule: ({ context, event }) => {
|
|
429
|
-
if (!("output" in event)) return false;
|
|
430
|
-
const firstModuleKey = event.output.flowModules?.[0]?.key;
|
|
431
|
-
if (!firstModuleKey) return false;
|
|
432
|
-
return context.registeredModules[firstModuleKey] != null || context.lazyRegisteredModules[firstModuleKey] != null;
|
|
433
|
-
},
|
|
434
|
-
hasCurrentModuleMachine: ({ event }) => {
|
|
435
|
-
if (!("output" in event)) return false;
|
|
436
|
-
return event.output != null;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}).createMachine({
|
|
440
|
-
id: "orchestratedFlow",
|
|
441
|
-
initial: "idle",
|
|
442
|
-
context: ({ input }) => createInitialContext(input),
|
|
443
|
-
states: {
|
|
444
|
-
idle: { on: {
|
|
445
|
-
LOAD: {
|
|
446
|
-
target: "loading",
|
|
447
|
-
actions: "resetContextForLoad"
|
|
448
|
-
},
|
|
449
|
-
...homeContinueOn
|
|
450
|
-
} },
|
|
451
|
-
loading: {
|
|
452
|
-
invoke: {
|
|
453
|
-
id: "fetchFlow",
|
|
454
|
-
src: "fetchFlow",
|
|
455
|
-
input: ({ context }) => ({ getFlow: context.getFlow }),
|
|
456
|
-
onDone: [{
|
|
457
|
-
target: "resolvingModule",
|
|
458
|
-
guard: "hasModule",
|
|
459
|
-
actions: "setFlowData"
|
|
460
|
-
}, {
|
|
461
|
-
target: "error",
|
|
462
|
-
actions: assign({ error: ({ event }) => {
|
|
463
|
-
const firstModuleKey = event.output.flowModules?.[0]?.key;
|
|
464
|
-
return firstModuleKey ? `No registered module found for: ${firstModuleKey}` : "No registered module found: flow has no modules";
|
|
465
|
-
} })
|
|
466
|
-
}],
|
|
467
|
-
onError: {
|
|
468
|
-
target: "error",
|
|
469
|
-
actions: "setError"
|
|
470
|
-
}
|
|
471
|
-
},
|
|
472
|
-
on: {
|
|
473
|
-
CANCEL: {
|
|
474
|
-
target: "idle",
|
|
475
|
-
actions: "resetContext"
|
|
476
|
-
},
|
|
477
|
-
...homeContinueOn
|
|
478
|
-
}
|
|
479
|
-
},
|
|
480
|
-
resolvingModule: {
|
|
481
|
-
invoke: {
|
|
482
|
-
id: "resolveCurrentModuleMachine",
|
|
483
|
-
src: "resolveCurrentModuleMachine",
|
|
484
|
-
input: ({ context }) => ({
|
|
485
|
-
moduleKey: context.currentStep,
|
|
486
|
-
modules: context.registeredModules,
|
|
487
|
-
lazyModules: context.lazyRegisteredModules
|
|
488
|
-
}),
|
|
489
|
-
onDone: [
|
|
490
|
-
{
|
|
491
|
-
target: "home",
|
|
492
|
-
guard: "shouldEnterHome",
|
|
493
|
-
actions: ["setCurrentModuleMachine"]
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
target: "runningModule",
|
|
497
|
-
guard: "hasCurrentModuleMachine",
|
|
498
|
-
actions: ["setCurrentModuleMachine", "prefetchNextModule"]
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
target: "error",
|
|
502
|
-
actions: assign(({ context }) => ({ error: context.currentStep ? `No registered module found for: ${context.currentStep}` : "No registered module found: flow has no modules" }))
|
|
503
|
-
}
|
|
504
|
-
],
|
|
505
|
-
onError: {
|
|
506
|
-
target: "error",
|
|
507
|
-
actions: "setError"
|
|
508
|
-
}
|
|
509
|
-
},
|
|
510
|
-
on: {
|
|
511
|
-
RESET: {
|
|
512
|
-
target: "idle",
|
|
513
|
-
actions: "resetContext"
|
|
514
|
-
},
|
|
515
|
-
...homeContinueOn
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
home: { on: {
|
|
519
|
-
HOME_CONTINUE: {
|
|
520
|
-
target: "runningModule",
|
|
521
|
-
actions: ["clearHomeContinueLoading", "prefetchNextModule"]
|
|
522
|
-
},
|
|
523
|
-
RESET: {
|
|
524
|
-
target: "idle",
|
|
525
|
-
actions: "resetContext"
|
|
526
|
-
}
|
|
527
|
-
} },
|
|
528
|
-
runningModule: {
|
|
529
|
-
entry: "clearHomeContinueLoading",
|
|
530
|
-
invoke: {
|
|
531
|
-
id: "currentModule",
|
|
532
|
-
src: "runChildModule",
|
|
533
|
-
input: ({ context }) => {
|
|
534
|
-
if (!context.currentStep) throw new Error("No current step");
|
|
535
|
-
return {
|
|
536
|
-
machine: context.currentModuleMachine,
|
|
537
|
-
config: context.config
|
|
538
|
-
};
|
|
539
|
-
},
|
|
540
|
-
onDone: [{
|
|
541
|
-
target: "completing",
|
|
542
|
-
guard: "isLastStep"
|
|
543
|
-
}, {
|
|
544
|
-
target: "resolvingModule",
|
|
545
|
-
actions: "incrementStep"
|
|
546
|
-
}],
|
|
547
|
-
onError: {
|
|
548
|
-
target: "error",
|
|
549
|
-
actions: "setError"
|
|
550
|
-
}
|
|
551
|
-
},
|
|
552
|
-
on: {
|
|
553
|
-
MODULE_COMPLETE: [{
|
|
554
|
-
target: "completing",
|
|
555
|
-
guard: "isLastStep"
|
|
556
|
-
}, {
|
|
557
|
-
target: "resolvingModule",
|
|
558
|
-
actions: "incrementStep"
|
|
559
|
-
}],
|
|
560
|
-
MODULE_ERROR: {
|
|
561
|
-
target: "error",
|
|
562
|
-
actions: assign(({ event }) => ({ error: String(event.error) }))
|
|
563
|
-
},
|
|
564
|
-
COMPLETE_FLOW: { target: "completing" },
|
|
565
|
-
RESET: {
|
|
566
|
-
target: "idle",
|
|
567
|
-
actions: "resetContext"
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
},
|
|
571
|
-
completing: {
|
|
572
|
-
invoke: {
|
|
573
|
-
id: "notifyBackend",
|
|
574
|
-
src: "notifyBackend",
|
|
575
|
-
input: ({ context }) => ({
|
|
576
|
-
getFinishStatus: context.getFinishStatus,
|
|
577
|
-
flowId: context.flow?.flowId
|
|
578
|
-
}),
|
|
579
|
-
onDone: {
|
|
580
|
-
target: "finished",
|
|
581
|
-
actions: "setFinishStatus"
|
|
582
|
-
},
|
|
583
|
-
onError: {
|
|
584
|
-
target: "error",
|
|
585
|
-
actions: "setError"
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
on: { RESET: {
|
|
589
|
-
target: "idle",
|
|
590
|
-
actions: "resetContext"
|
|
591
|
-
} }
|
|
592
|
-
},
|
|
593
|
-
finished: { on: { RESET: {
|
|
594
|
-
target: "idle",
|
|
595
|
-
actions: "resetContext"
|
|
596
|
-
} } },
|
|
597
|
-
error: {
|
|
598
|
-
entry: "clearHomeContinueLoading",
|
|
599
|
-
on: { RESET: {
|
|
600
|
-
target: "idle",
|
|
601
|
-
actions: "resetContext"
|
|
602
|
-
} }
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region src/modules/flow/orchestratedFlowManager.ts
|
|
609
|
-
function deriveUiModel(snapshot, mappedStatus, isHomePhase, options) {
|
|
610
|
-
const { enableHome } = options;
|
|
611
|
-
const serverDisablesLaunch = snapshot.context.flow?.disableLaunchScreen === true;
|
|
612
|
-
const effectiveEnableHome = enableHome === true && serverDisablesLaunch === false;
|
|
613
|
-
const isTerminal = mappedStatus === "finished" || mappedStatus === "error";
|
|
614
|
-
const awaitingOrchestrator = mappedStatus === "idle" || mappedStatus === "loading";
|
|
615
|
-
const isCompletingPhase = snapshot.value === "completing";
|
|
616
|
-
const firstRealIndex = snapshot.context.steps[0] === "REDIRECT_TO_MOBILE" ? 1 : 0;
|
|
617
|
-
const isAtFirstRealModule = snapshot.context.currentStepIndex === firstRealIndex;
|
|
618
|
-
const isResolvingHomeAnchor = snapshot.value === "resolvingModule" && effectiveEnableHome && isAtFirstRealModule;
|
|
619
|
-
const isHomeBoundPhase = isHomePhase || isResolvingHomeAnchor;
|
|
620
|
-
const canShowHome = isTerminal === false && effectiveEnableHome && isCompletingPhase === false;
|
|
621
|
-
const visible = canShowHome ? isHomeBoundPhase : false;
|
|
622
|
-
const lazyModuleKey = mappedStatus === "ready" && visible === false ? snapshot.context.currentStep : void 0;
|
|
623
|
-
const shouldPrefetchHome = canShowHome && snapshot.context.isHomeContinueLoading === false && isHomeBoundPhase;
|
|
624
|
-
return {
|
|
625
|
-
homeScreen: {
|
|
626
|
-
visible,
|
|
627
|
-
isContinueLoading: isTerminal ? false : snapshot.context.isHomeContinueLoading
|
|
628
|
-
},
|
|
629
|
-
presentation: {
|
|
630
|
-
isAwaitingReady: awaitingOrchestrator,
|
|
631
|
-
lazyModuleKey,
|
|
632
|
-
shouldPrefetchHome
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function getMappedStatus(snapshot) {
|
|
637
|
-
const { value } = snapshot;
|
|
638
|
-
if (value === "idle") return "idle";
|
|
639
|
-
if (value === "loading" || value === "resolvingModule" || value === "completing" || typeof value === "object") return "loading";
|
|
640
|
-
if (value === "finished") return "finished";
|
|
641
|
-
if (value === "error") return "error";
|
|
642
|
-
return "ready";
|
|
643
|
-
}
|
|
644
|
-
function mapOrchestratedFlowState(snapshot, uiOptions) {
|
|
645
|
-
const { value, context } = snapshot;
|
|
646
|
-
const mappedStatus = getMappedStatus(snapshot);
|
|
647
|
-
const uiModel = deriveUiModel(snapshot, mappedStatus, value === "home", uiOptions);
|
|
648
|
-
if (mappedStatus === "idle") return {
|
|
649
|
-
status: "idle",
|
|
650
|
-
homeScreen: uiModel.homeScreen,
|
|
651
|
-
presentation: uiModel.presentation
|
|
652
|
-
};
|
|
653
|
-
if (mappedStatus === "loading") return {
|
|
654
|
-
status: "loading",
|
|
655
|
-
homeScreen: uiModel.homeScreen,
|
|
656
|
-
presentation: uiModel.presentation
|
|
657
|
-
};
|
|
658
|
-
if (mappedStatus === "finished") return {
|
|
659
|
-
status: "finished",
|
|
660
|
-
flow: context.flow ?? {},
|
|
661
|
-
finishStatus: context.finishStatus ?? {
|
|
662
|
-
redirectionUrl: "",
|
|
663
|
-
action: "none",
|
|
664
|
-
scoreStatus: "UNKNOWN"
|
|
665
|
-
},
|
|
666
|
-
homeScreen: uiModel.homeScreen,
|
|
667
|
-
presentation: uiModel.presentation
|
|
668
|
-
};
|
|
669
|
-
if (mappedStatus === "error") return {
|
|
670
|
-
status: "error",
|
|
671
|
-
error: context.error ?? "Unknown error",
|
|
672
|
-
errorCode: context.errorCode,
|
|
673
|
-
homeScreen: uiModel.homeScreen,
|
|
674
|
-
presentation: uiModel.presentation
|
|
675
|
-
};
|
|
676
|
-
const childSnapshot = value === "runningModule" ? snapshot.children.currentModule?.getSnapshot() : null;
|
|
677
|
-
return {
|
|
678
|
-
status: "ready",
|
|
679
|
-
flow: context.flow ?? {},
|
|
680
|
-
steps: context.steps,
|
|
681
|
-
currentStepIndex: context.currentStepIndex,
|
|
682
|
-
currentStep: context.currentStep,
|
|
683
|
-
config: context.config,
|
|
684
|
-
moduleState: childSnapshot ?? null,
|
|
685
|
-
homeScreen: uiModel.homeScreen,
|
|
686
|
-
presentation: uiModel.presentation
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
function waitForOrchestratorReadyFromActor(actor, mapState$1, isResolved) {
|
|
690
|
-
return new Promise((resolve, reject) => {
|
|
691
|
-
const initial = mapState$1(actor.getSnapshot());
|
|
692
|
-
if (isResolved(initial)) {
|
|
693
|
-
resolve();
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
if (initial.status === "error") {
|
|
697
|
-
reject(new Error(initial.error));
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
if (initial.status === "finished") {
|
|
701
|
-
reject(/* @__PURE__ */ new Error("Flow finished"));
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
const subscription = actor.subscribe(() => {
|
|
705
|
-
const next = mapState$1(actor.getSnapshot());
|
|
706
|
-
if (isResolved(next)) {
|
|
707
|
-
subscription.unsubscribe();
|
|
708
|
-
resolve();
|
|
709
|
-
} else if (next.status === "error") {
|
|
710
|
-
subscription.unsubscribe();
|
|
711
|
-
reject(new Error(next.error));
|
|
712
|
-
} else if (next.status === "finished") {
|
|
713
|
-
subscription.unsubscribe();
|
|
714
|
-
reject(/* @__PURE__ */ new Error("Flow finished"));
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
function createOrchestratedFlowApi({ actor, getSnapshot, trackElementClicked }, uiOptions) {
|
|
720
|
-
const { enableHome } = uiOptions;
|
|
721
|
-
function mapSnapshot() {
|
|
722
|
-
return mapOrchestratedFlowState(getSnapshot(), { enableHome });
|
|
723
|
-
}
|
|
724
|
-
function getCanNext() {
|
|
725
|
-
const snapshot = getSnapshot();
|
|
726
|
-
const { currentStepIndex, steps } = snapshot.context;
|
|
727
|
-
return snapshot.value === "runningModule" && currentStepIndex >= 0 && currentStepIndex < steps.length - 1;
|
|
728
|
-
}
|
|
729
|
-
function getModuleConfig$1(moduleKey) {
|
|
730
|
-
const snapshot = getSnapshot();
|
|
731
|
-
if (snapshot.value !== "runningModule") return;
|
|
732
|
-
return (snapshot.context.flow?.flowModules.find((m) => m.key === moduleKey))?.configuration;
|
|
733
|
-
}
|
|
734
|
-
function isModuleEnabled(moduleKey) {
|
|
735
|
-
const snapshot = getSnapshot();
|
|
736
|
-
if (snapshot.value !== "runningModule") return false;
|
|
737
|
-
return !!snapshot.context.flow?.flowModules.some((m) => m.key === moduleKey);
|
|
738
|
-
}
|
|
739
|
-
return {
|
|
740
|
-
load() {
|
|
741
|
-
actor.send({ type: "LOAD" });
|
|
742
|
-
},
|
|
743
|
-
cancel() {
|
|
744
|
-
trackElementClicked?.("cancel");
|
|
745
|
-
actor.send({ type: "CANCEL" });
|
|
746
|
-
},
|
|
747
|
-
reset() {
|
|
748
|
-
actor.send({ type: "RESET" });
|
|
749
|
-
},
|
|
750
|
-
completeModule() {
|
|
751
|
-
trackElementClicked?.("completeModule");
|
|
752
|
-
actor.send({ type: "MODULE_COMPLETE" });
|
|
753
|
-
},
|
|
754
|
-
completeFlow() {
|
|
755
|
-
trackElementClicked?.("completeFlow");
|
|
756
|
-
actor.send({ type: "COMPLETE_FLOW" });
|
|
757
|
-
},
|
|
758
|
-
errorModule(error) {
|
|
759
|
-
actor.send({
|
|
760
|
-
type: "MODULE_ERROR",
|
|
761
|
-
error
|
|
762
|
-
});
|
|
763
|
-
},
|
|
764
|
-
send(event) {
|
|
765
|
-
actor.send(event);
|
|
766
|
-
},
|
|
767
|
-
get canNext() {
|
|
768
|
-
return getCanNext();
|
|
769
|
-
},
|
|
770
|
-
getModuleConfig: getModuleConfig$1,
|
|
771
|
-
isModuleEnabled,
|
|
772
|
-
isAwaitingOrchestratorReady() {
|
|
773
|
-
return mapSnapshot().presentation.isAwaitingReady;
|
|
774
|
-
},
|
|
775
|
-
async waitForReady() {
|
|
776
|
-
return waitForOrchestratorReadyFromActor(actor, (snap) => mapOrchestratedFlowState(snap, { enableHome }), (next) => next.status === "ready" && next.presentation.isAwaitingReady === false);
|
|
777
|
-
},
|
|
778
|
-
getLazyModuleKey() {
|
|
779
|
-
return mapSnapshot().presentation.lazyModuleKey;
|
|
780
|
-
},
|
|
781
|
-
shouldRenderHomeScreen() {
|
|
782
|
-
return mapSnapshot().homeScreen.visible;
|
|
783
|
-
},
|
|
784
|
-
async continueFromHome() {
|
|
785
|
-
const state = mapSnapshot();
|
|
786
|
-
if (!state.homeScreen.visible) return;
|
|
787
|
-
if (state.status === "ready") {
|
|
788
|
-
trackElementClicked?.("homeContinue");
|
|
789
|
-
actor.send({ type: "HOME_CONTINUE" });
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
if (state.presentation.isAwaitingReady) {
|
|
793
|
-
trackElementClicked?.("homeContinue");
|
|
794
|
-
actor.send({ type: "HOME_CONTINUE" });
|
|
795
|
-
try {
|
|
796
|
-
await waitForOrchestratorReadyFromActor(actor, (snap) => mapOrchestratedFlowState(snap, { enableHome }), (next) => next.status === "ready" && next.homeScreen.visible === false);
|
|
797
|
-
} catch {
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
}
|
|
804
|
-
function createOrchestratedFlowActor(options) {
|
|
805
|
-
return createActor(orchestratedFlowMachine, { input: {
|
|
806
|
-
getFlow: options.getFlow ?? getFlow,
|
|
807
|
-
modules: options.modules,
|
|
808
|
-
lazyModules: options.lazyModules,
|
|
809
|
-
getFinishStatus: options.getFinishStatus,
|
|
810
|
-
enableHome: options.enableHome
|
|
811
|
-
} }).start();
|
|
812
|
-
}
|
|
813
|
-
function createOrchestratedFlowManager(options) {
|
|
814
|
-
const actor = createOrchestratedFlowActor(options);
|
|
815
|
-
const enableHome = options.enableHome === true;
|
|
816
|
-
const uiOpts = { enableHome };
|
|
817
|
-
return attachFlowEventEmitter(createManager({
|
|
818
|
-
actor,
|
|
819
|
-
mapState: (snapshot) => mapOrchestratedFlowState(snapshot, uiOpts),
|
|
820
|
-
createApi: (apiOpts) => createOrchestratedFlowApi(apiOpts, { enableHome })
|
|
821
|
-
}));
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
//#endregion
|
|
825
|
-
export { createFlowManager, createModuleLoader, createOrchestratedFlowManager, getFlow, getRequiredWasmPipelines, noOpFlowModuleMachine, normalizeFlowModules };
|