@incodetech/web 0.0.0-dev-20260421-b9de520 → 0.0.0-dev-20260421-b7cc65e

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.
@@ -4,25 +4,42 @@ import { t as s } from "../uiConfig-CwpQ-IM6.js";
4
4
  import { o as c, t as l } from "../incodeComponent-dxwR00fd.js";
5
5
  import { t as u } from "../transitionSpinner-CpwivARH.js";
6
6
  import { t as d } from "../incodeModule-BH9gV7jI.js";
7
- import { a as f, c as p, d as m, i as h, l as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "../useModuleLoader-B4EtGg2Y.js";
7
+ import { a as f, c as p, d as m, i as h, l as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "../useModuleLoader-zEhxlZfy.js";
8
8
  import { getDeviceClass as w } from "@incodetech/core/device";
9
9
  import { getRequiredWasmPipelines as T } from "@incodetech/core/flow";
10
10
  import { createSession as E, validateQrUuid as D } from "@incodetech/core/session";
11
+ //#region src/shared/processing/useDelayedFlag.ts
12
+ function O(e, n) {
13
+ let [r, i] = a(!1);
14
+ return t(() => {
15
+ if (e === !1) {
16
+ i(!1);
17
+ return;
18
+ }
19
+ let t = window.setTimeout(() => {
20
+ i(!0);
21
+ }, n);
22
+ return () => {
23
+ window.clearTimeout(t);
24
+ };
25
+ }, [e, n]), r;
26
+ }
27
+ //#endregion
11
28
  //#region src/modules/flow/createFlowSession.ts
12
- function O(e) {
29
+ function k(e) {
13
30
  return Array.from(new Uint8Array(e), (e) => e.toString(16).padStart(2, "0")).join("");
14
31
  }
15
- async function k(e) {
32
+ async function A(e) {
16
33
  let t = globalThis.crypto?.subtle;
17
34
  if (!t) throw Error("SHA-1 is not available in this environment");
18
- return O(await t.digest("SHA-1", new TextEncoder().encode(e)));
35
+ return k(await t.digest("SHA-1", new TextEncoder().encode(e)));
19
36
  }
20
- async function A(e) {
37
+ async function j(e) {
21
38
  if (typeof e.apiKey == "string") return e.apiKey;
22
- if (typeof e.clientId == "string") return k(e.clientId);
39
+ if (typeof e.clientId == "string") return A(e.clientId);
23
40
  throw Error("Flow self-loading mode requires apiKey or clientId");
24
41
  }
25
- async function j(e, t) {
42
+ async function M(e, t) {
26
43
  if (typeof e.urlUuid != "string" || e.urlUuid.length === 0) return;
27
44
  let n = await D({
28
45
  onboardingId: e.uuid ?? null,
@@ -30,8 +47,8 @@ async function j(e, t) {
30
47
  }, t);
31
48
  return e.onUrlUuidRefreshed?.(n.urlUuid), n.urlUuid;
32
49
  }
33
- async function M(e, t) {
34
- let n = await A(e), r = await j(e, t);
50
+ async function N(e, t) {
51
+ let n = await j(e), r = await M(e, t);
35
52
  return E(n, {
36
53
  configurationId: e.configurationId,
37
54
  externalId: e.externalId,
@@ -45,18 +62,18 @@ async function M(e, t) {
45
62
  }
46
63
  //#endregion
47
64
  //#region src/modules/flow/flowConfig.ts
48
- function N(e) {
65
+ function P(e) {
49
66
  return typeof e.token == "string";
50
67
  }
51
- function P(e) {
68
+ function F(e) {
52
69
  let t = e;
53
70
  return typeof t.configurationId == "string" && (typeof t.apiKey == "string" || typeof t.clientId == "string");
54
71
  }
55
72
  //#endregion
56
73
  //#region src/modules/flow/preloadFlow.ts
57
- var F = /* @__PURE__ */ new Map();
58
- function I(e) {
59
- let t = F.get(e);
74
+ var I = /* @__PURE__ */ new Map();
75
+ function L(e) {
76
+ let t = I.get(e);
60
77
  if (!t) throw Error("Preload state not found");
61
78
  return {
62
79
  get isReady() {
@@ -72,13 +89,13 @@ function I(e) {
72
89
  }
73
90
  },
74
91
  cancel() {
75
- t.status === "loading" && (t.unsubscribe && t.unsubscribe(), t.flowManager.stop(), t.readyReject(/* @__PURE__ */ Error("Preload cancelled")), F.delete(e));
92
+ t.status === "loading" && (t.unsubscribe && t.unsubscribe(), t.flowManager.stop(), t.readyReject(/* @__PURE__ */ Error("Preload cancelled")), I.delete(e));
76
93
  }
77
94
  };
78
95
  }
79
- function L(e) {
96
+ function R(e) {
80
97
  let { token: t } = e;
81
- if (F.has(t)) return I(t);
98
+ if (I.has(t)) return L(t);
82
99
  let n, r, i = new Promise((e, t) => {
83
100
  n = e, r = t;
84
101
  }), a = v(e);
@@ -91,7 +108,7 @@ function L(e) {
91
108
  readyResolve: n,
92
109
  readyReject: r
93
110
  };
94
- return F.set(t, o), (async () => {
111
+ return I.set(t, o), (async () => {
95
112
  try {
96
113
  await p({
97
114
  apiURL: e.apiURL,
@@ -109,37 +126,37 @@ function L(e) {
109
126
  } else t.status === "error" && (o.unsubscribe?.(), o.unsubscribe = void 0, o.status = "error", o.error = t.error, o.readyReject(Error(t.error)));
110
127
  }), await t;
111
128
  } catch (e) {
112
- o.status = "error", o.error = e instanceof Error ? e.message : "Failed to preload", o.readyReject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to preload")), F.delete(t);
129
+ o.status = "error", o.error = e instanceof Error ? e.message : "Failed to preload", o.readyReject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to preload")), I.delete(t);
113
130
  }
114
- })(), I(t);
115
- }
116
- function R(e) {
117
- return F.get(e) ?? null;
131
+ })(), L(t);
118
132
  }
119
133
  function z(e) {
120
- let t = R(e);
121
- return t && F.delete(e), t;
134
+ return I.get(e) ?? null;
135
+ }
136
+ function B(e) {
137
+ let t = z(e);
138
+ return t && I.delete(e), t;
122
139
  }
123
140
  //#endregion
124
141
  //#region src/modules/flow/useFlowInitialization.ts
125
- function B(e) {
142
+ function V(e) {
126
143
  e.getState().presentation.shouldPrefetchHome && C();
127
144
  }
128
- function V() {
145
+ function H() {
129
146
  w() === "desktop" && m();
130
147
  }
131
- function H(e) {
132
- let { apiURL: n, lang: i, disableDashboardTheme: o, enableHome: c, onError: l } = e, u = N(e) ? e.token : void 0, d = r(null), [f, m] = a(() => {
133
- let t = u ? R(u) : null;
148
+ function U(e) {
149
+ let { apiURL: n, lang: i, disableDashboardTheme: o, enableHome: c, onError: l } = e, u = P(e) ? e.token : void 0, d = r(null), [f, m] = a(() => {
150
+ let t = u ? z(u) : null;
134
151
  if (u && t?.status === "ready") {
135
- let e = z(u);
136
- if (e) return d.current = e.flowManager, B(e.flowManager), V(), e.uiConfig && s(e.uiConfig), {
152
+ let e = B(u);
153
+ if (e) return d.current = e.flowManager, V(e.flowManager), H(), e.uiConfig && s(e.uiConfig), {
137
154
  status: "ready",
138
155
  flowManager: e.flowManager
139
156
  };
140
157
  }
141
158
  let n = v(e);
142
- return d.current = n, B(n), V(), t?.status === "error" ? {
159
+ return d.current = n, V(n), H(), t?.status === "error" ? {
143
160
  status: "error",
144
161
  error: t.error ?? "Preload failed",
145
162
  flowManager: n
@@ -150,11 +167,11 @@ function H(e) {
150
167
  }), h = r(!1);
151
168
  return t(() => {
152
169
  if (f.status !== "initializing") return;
153
- let t = u ? R(u) : null;
170
+ let t = u ? z(u) : null;
154
171
  if (u && t?.status === "loading") {
155
172
  t.readyPromise.then(() => {
156
- let e = z(u);
157
- e && (d.current = e.flowManager, B(e.flowManager), V(), e.uiConfig && s(e.uiConfig), m({
173
+ let e = B(u);
174
+ e && (d.current = e.flowManager, V(e.flowManager), H(), e.uiConfig && s(e.uiConfig), m({
158
175
  status: "ready",
159
176
  flowManager: e.flowManager
160
177
  }));
@@ -171,8 +188,8 @@ function H(e) {
171
188
  h.current || (h.current = !0, (async () => {
172
189
  try {
173
190
  let t;
174
- if (N(e)) t = e.token;
175
- else if (P(e)) t = (await M(e)).token;
191
+ if (P(e)) t = e.token;
192
+ else if (F(e)) t = (await N(e)).token;
176
193
  else throw Error("Flow requires token, or configurationId with apiKey or clientId");
177
194
  await p({
178
195
  apiURL: n,
@@ -207,8 +224,8 @@ function H(e) {
207
224
  }
208
225
  //#endregion
209
226
  //#region src/modules/flow/flow.tsx
210
- var U = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.HomeScreen }))), W = ({ config: n, onFinish: r, onError: a }) => {
211
- let { i18n: s } = e(), l = H({
227
+ var W = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.HomeScreen }))), G = ({ config: n, onFinish: r, onError: a }) => {
228
+ let { i18n: s } = e(), l = U({
212
229
  ...n,
213
230
  onError: a
214
231
  }), [d, p] = c(() => l.flowManager, { autoLoad: !1 }), m = d.presentation.lazyModuleKey, g = d.status === "ready" ? d.currentStep : void 0, v = S({
@@ -217,13 +234,13 @@ var U = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.Ho
217
234
  onModuleLoading: n.onModuleLoading,
218
235
  onModuleLoaded: n.onModuleLoaded,
219
236
  onError: a
220
- }), x = _({
237
+ });
238
+ _({
221
239
  moduleKey: d.status === "ready" && d.homeScreen.visible ? g : void 0,
222
240
  modules: f
223
- }), w = v.status === "loaded";
224
- w === !1 && d.homeScreen.visible && (w = x);
225
- let E = n.enableHome === !0 && d.status === "ready" && d.currentStepIndex === 0 && d.homeScreen.visible === !1 && v.status === "loading";
226
- if (b(d?.status === "ready" ? d.steps : [], d?.status === "ready" ? d.currentStepIndex : -1, f, w), t(() => {
241
+ });
242
+ let x = v.status === "loaded", w = n.enableHome === !0 && d.status === "ready" && d.currentStepIndex === 0 && d.homeScreen.visible === !1 && v.status === "loading", E = O(d.presentation.isAwaitingReady === !0, 150), D = O(d.status === "ready" && (v.status === "idle" || v.status === "loading" || v.status === "error"), 150);
243
+ if (b(d?.status === "ready" ? d.steps : [], d?.status === "ready" ? d.currentStepIndex : -1, f, x), t(() => {
227
244
  d.presentation.shouldPrefetchHome && C();
228
245
  }, [d.presentation.shouldPrefetchHome]), t(() => {
229
246
  n.lang && s.language !== n.lang && s.changeLanguage(n.lang);
@@ -249,20 +266,24 @@ var U = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.Ho
249
266
  class: "IncodeFlow",
250
267
  children: /* @__PURE__ */ o("div", { children: ["Error: ", l.error] })
251
268
  });
252
- if (d.homeScreen.visible || E) return /* @__PURE__ */ o("div", {
269
+ if (d.homeScreen.visible || w) return /* @__PURE__ */ o("div", {
253
270
  class: "IncodeFlow",
254
271
  children: /* @__PURE__ */ o(i, {
255
272
  fallback: null,
256
- children: /* @__PURE__ */ o(U, {
257
- isContinueLoading: d.homeScreen.isContinueLoading || E,
273
+ children: /* @__PURE__ */ o(W, {
274
+ isContinueLoading: d.homeScreen.isContinueLoading || w,
258
275
  onContinue: () => p.continueFromHome()
259
276
  })
260
277
  })
261
278
  });
262
- if (l.status === "initializing" || d.presentation.isAwaitingReady) return /* @__PURE__ */ o("div", {
279
+ if (l.status === "initializing") return /* @__PURE__ */ o("div", {
263
280
  class: "IncodeFlow",
264
281
  children: /* @__PURE__ */ o(u, { spinnerConfig: n.spinnerConfig })
265
282
  });
283
+ if (d.presentation.isAwaitingReady) return E ? /* @__PURE__ */ o("div", {
284
+ class: "IncodeFlow",
285
+ children: /* @__PURE__ */ o(u, { spinnerConfig: n.spinnerConfig })
286
+ }) : /* @__PURE__ */ o("div", { class: "IncodeFlow" });
266
287
  if (d.status === "error") return /* @__PURE__ */ o("div", {
267
288
  class: "IncodeFlow",
268
289
  children: /* @__PURE__ */ o("div", { children: ["Error: ", d.error] })
@@ -281,10 +302,10 @@ var U = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.Ho
281
302
  onNext: () => p.completeModule()
282
303
  })
283
304
  });
284
- if (v.status === "idle" || v.status === "loading" || v.status === "error") return /* @__PURE__ */ o("div", {
305
+ if (v.status === "idle" || v.status === "loading" || v.status === "error") return D ? /* @__PURE__ */ o("div", {
285
306
  class: "IncodeFlow",
286
307
  children: /* @__PURE__ */ o(u, { spinnerConfig: n.spinnerConfig })
287
- });
308
+ }) : /* @__PURE__ */ o("div", { class: "IncodeFlow" });
288
309
  let { Component: i } = v;
289
310
  if (e === "REDIRECT_TO_MOBILE") return /* @__PURE__ */ o("div", {
290
311
  class: "IncodeFlow",
@@ -527,11 +548,11 @@ var U = n(() => import("../homeScreen-CC6U7vbU.js").then((e) => ({ default: e.Ho
527
548
  });
528
549
  }
529
550
  return null;
530
- }, G = ({ config: e, onFinish: t = () => {}, onError: n }) => /* @__PURE__ */ o(l, { children: e ? /* @__PURE__ */ o(W, {
551
+ }, K = ({ config: e, onFinish: t = () => {}, onError: n }) => /* @__PURE__ */ o(l, { children: e ? /* @__PURE__ */ o(G, {
531
552
  config: e,
532
553
  onFinish: t,
533
554
  onError: n
534
555
  }) : null });
535
- d(G, "incode-flow");
556
+ d(K, "incode-flow");
536
557
  //#endregion
537
- export { G as IncodeFlow, L as preloadIncodeFlow };
558
+ export { K as IncodeFlow, R as preloadIncodeFlow };
@@ -296,41 +296,67 @@ var V = ({ moduleKey: e, onNext: t }) => /* @__PURE__ */ r("section", {
296
296
  function H(e, t) {
297
297
  return e instanceof Error ? e.message : t;
298
298
  }
299
- function U(r) {
300
- let { loader: i, onLoading: a, onLoaded: o, onError: s } = r, [c, l] = n({ status: "idle" }), u = t(a), d = t(o), f = t(s);
299
+ var U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap();
300
+ function G(e) {
301
+ return e;
302
+ }
303
+ function K(e) {
304
+ if (e) return U.get(G(e));
305
+ }
306
+ function q(e) {
307
+ let t = G(e), n = U.get(t);
308
+ if (n) return Promise.resolve(n);
309
+ let r = W.get(t);
310
+ if (r) return r;
311
+ let i = e().then((e) => (U.set(t, e), W.delete(t), e)).catch((e) => {
312
+ throw W.delete(t), e;
313
+ });
314
+ return W.set(t, i), i;
315
+ }
316
+ function J(e) {
317
+ if (!e) return { status: "idle" };
318
+ let t = K(e);
319
+ return t ? {
320
+ status: "loaded",
321
+ Component: t
322
+ } : { status: "loading" };
323
+ }
324
+ function Y(r) {
325
+ let { loader: i, onLoading: a, onLoaded: o, onError: s } = r, [c, l] = n(() => J(i)), u = t(i), d = t(a), f = t(o), p = t(s);
301
326
  return e(() => {
302
- u.current = a, d.current = o, f.current = s;
327
+ d.current = a, f.current = o, p.current = s;
303
328
  }, [
304
329
  a,
305
330
  o,
306
331
  s
307
- ]), e(() => {
308
- if (!i) {
309
- l({ status: "idle" });
332
+ ]), u.current !== i && (u.current = i, l(J(i))), e(() => {
333
+ if (!i) return;
334
+ if (K(i)) {
335
+ f.current?.();
310
336
  return;
311
337
  }
312
- l({ status: "loading" }), u.current?.();
338
+ d.current?.();
313
339
  let e = !1;
314
- return i().then((t) => {
340
+ return q(i).then((t) => {
315
341
  e || (l({
316
342
  status: "loaded",
317
343
  Component: t
318
- }), d.current?.());
344
+ }), f.current?.());
319
345
  }).catch((t) => {
320
346
  if (!e) {
321
347
  let e = H(t, "Failed to load component");
322
348
  l({
323
349
  status: "error",
324
350
  error: e
325
- }), f.current?.(e);
351
+ }), p.current?.(e);
326
352
  }
327
353
  }), () => {
328
354
  e = !0;
329
355
  };
330
356
  }, [i]), c;
331
357
  }
332
- function W(t) {
333
- let { moduleKey: r, modules: i, onModuleLoading: a, onModuleLoaded: o, onError: s } = t, [c, l] = n(void 0), u = r ? i[r] : void 0, d = U({
358
+ function X(t) {
359
+ let { moduleKey: r, modules: i, onModuleLoading: a, onModuleLoaded: o, onError: s } = t, [c, l] = n(void 0), u = r ? i[r] : void 0, d = Y({
334
360
  loader: u,
335
361
  onLoading: r ? () => a?.(r) : void 0,
336
362
  onLoaded: r ? () => o?.(r) : void 0,
@@ -358,16 +384,16 @@ function W(t) {
358
384
  Component: d.Component
359
385
  } : { status: "idle" };
360
386
  }
361
- function G(e) {
362
- let { moduleKey: t, modules: n } = e, r = t ? n[t] : void 0, i = U({ loader: r });
387
+ function Z(e) {
388
+ let { moduleKey: t, modules: n } = e, r = t ? n[t] : void 0, i = Y({ loader: r });
363
389
  return r != null && i.status === "loaded";
364
390
  }
365
- function K(e) {
391
+ function Q(e) {
366
392
  typeof requestIdleCallback < "u" ? requestIdleCallback(() => {
367
393
  e();
368
394
  }) : setTimeout(e, 0);
369
395
  }
370
- function q(n, r, i, a) {
396
+ function $(n, r, i, a) {
371
397
  let o = t(/* @__PURE__ */ new Set());
372
398
  e(() => {
373
399
  if (a && r < n.length - 1) {
@@ -375,7 +401,7 @@ function q(n, r, i, a) {
375
401
  if (e && !o.current.has(e)) {
376
402
  o.current.add(e);
377
403
  let t = i[e];
378
- t && K(() => {
404
+ t && Q(() => {
379
405
  t().catch(() => {
380
406
  o.current.delete(e);
381
407
  });
@@ -390,4 +416,4 @@ function q(n, r, i, a) {
390
416
  ]);
391
417
  }
392
418
  //#endregion
393
- export { A as a, L as c, P as d, I as f, V as i, B as l, w as m, G as n, F as o, z as p, q as r, R as s, W as t, M as u };
419
+ export { A as a, L as c, P as d, I as f, V as i, B as l, w as m, Z as n, F as o, z as p, $ as r, R as s, X as t, M as u };
@@ -5,7 +5,7 @@ import { o, t as s } from "../incodeComponent-dxwR00fd.js";
5
5
  import "../spinner-BmFWJNHp.js";
6
6
  import { t as c } from "../transitionSpinner-CpwivARH.js";
7
7
  import { t as l } from "../incodeModule-BH9gV7jI.js";
8
- import { a as u, f as d, i as f, m as p, t as m } from "../useModuleLoader-B4EtGg2Y.js";
8
+ import { a as u, f as d, i as f, m as p, t as m } from "../useModuleLoader-zEhxlZfy.js";
9
9
  import { resolveWasmConfig as h, warmupWasm as g } from "@incodetech/core/wasm";
10
10
  import { createWorkflowManager as _ } from "@incodetech/core/workflow";
11
11
  //#region src/modules/workflow/workflowInit.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/web",
3
- "version": "0.0.0-dev-20260421-b9de520",
3
+ "version": "0.0.0-dev-20260421-b7cc65e",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -183,7 +183,7 @@
183
183
  "qrcode": "^1.5.4",
184
184
  "signature_pad": "^5.1.3",
185
185
  "tailwindcss": "^4.1.17",
186
- "@incodetech/core": "0.0.0-dev-20260421-b9de520"
186
+ "@incodetech/core": "0.0.0-dev-20260421-b7cc65e"
187
187
  },
188
188
  "devDependencies": {
189
189
  "@microsoft/api-extractor": "^7.53.3",