@incodetech/web 0.0.0-dev-20260417-78468b3 → 0.0.0-dev-20260417-4da85d5

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.
@@ -7,10 +7,46 @@ import "../spinner-CFvndzMU.js";
7
7
  import { t as d } from "../incodeModule-D_r2n18O.js";
8
8
  import { a as f, c as p, f as m, i as h, l as g, n as _, o as v, r as y, s as b, t as x, u as S } from "../useModuleLoader-B6JxxJWR.js";
9
9
  import { getRequiredWasmPipelines as C } from "@incodetech/core/flow";
10
- //#region src/modules/flow/preloadFlow.ts
11
- var w = /* @__PURE__ */ new Map();
10
+ import { createSession as w } from "@incodetech/core/session";
11
+ //#region src/modules/flow/createFlowSession.ts
12
12
  function T(e) {
13
- let t = w.get(e);
13
+ return Array.from(new Uint8Array(e), (e) => e.toString(16).padStart(2, "0")).join("");
14
+ }
15
+ async function E(e) {
16
+ let t = globalThis.crypto?.subtle;
17
+ if (!t) throw Error("SHA-1 is not available in this environment");
18
+ return T(await t.digest("SHA-1", new TextEncoder().encode(e)));
19
+ }
20
+ async function D(e) {
21
+ if (typeof e.apiKey == "string") return e.apiKey;
22
+ if (typeof e.clientId == "string") return E(e.clientId);
23
+ throw Error("Flow self-loading mode requires apiKey or clientId");
24
+ }
25
+ async function O(e, t) {
26
+ return w(await D(e), {
27
+ configurationId: e.configurationId,
28
+ externalId: e.externalId,
29
+ externalCustomerId: e.externalCustomerId,
30
+ language: e.lang,
31
+ customFields: e.customFields,
32
+ uuid: e.uuid,
33
+ interviewId: e.interviewId
34
+ }, t);
35
+ }
36
+ //#endregion
37
+ //#region src/modules/flow/flowConfig.ts
38
+ function k(e) {
39
+ return typeof e.token == "string";
40
+ }
41
+ function A(e) {
42
+ let t = e;
43
+ return typeof t.configurationId == "string" && (typeof t.apiKey == "string" || typeof t.clientId == "string");
44
+ }
45
+ //#endregion
46
+ //#region src/modules/flow/preloadFlow.ts
47
+ var j = /* @__PURE__ */ new Map();
48
+ function M(e) {
49
+ let t = j.get(e);
14
50
  if (!t) throw Error("Preload state not found");
15
51
  return {
16
52
  get isReady() {
@@ -26,13 +62,13 @@ function T(e) {
26
62
  }
27
63
  },
28
64
  cancel() {
29
- t.status === "loading" && (t.unsubscribe && t.unsubscribe(), t.flowManager.stop(), t.readyReject(/* @__PURE__ */ Error("Preload cancelled")), w.delete(e));
65
+ t.status === "loading" && (t.unsubscribe && t.unsubscribe(), t.flowManager.stop(), t.readyReject(/* @__PURE__ */ Error("Preload cancelled")), j.delete(e));
30
66
  }
31
67
  };
32
68
  }
33
- function E(e) {
69
+ function N(e) {
34
70
  let { token: t } = e;
35
- if (w.has(t)) return T(t);
71
+ if (j.has(t)) return M(t);
36
72
  let n, r, i = new Promise((e, t) => {
37
73
  n = e, r = t;
38
74
  }), a = v(e);
@@ -45,7 +81,7 @@ function E(e) {
45
81
  readyResolve: n,
46
82
  readyReject: r
47
83
  };
48
- return w.set(t, o), (async () => {
84
+ return j.set(t, o), (async () => {
49
85
  try {
50
86
  await p({
51
87
  apiURL: e.apiURL,
@@ -63,34 +99,34 @@ function E(e) {
63
99
  } else t.status === "error" && (o.unsubscribe?.(), o.unsubscribe = void 0, o.status = "error", o.error = t.error, o.readyReject(Error(t.error)));
64
100
  }), await t;
65
101
  } catch (e) {
66
- o.status = "error", o.error = e instanceof Error ? e.message : "Failed to preload", o.readyReject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to preload")), w.delete(t);
102
+ o.status = "error", o.error = e instanceof Error ? e.message : "Failed to preload", o.readyReject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to preload")), j.delete(t);
67
103
  }
68
- })(), T(t);
104
+ })(), M(t);
69
105
  }
70
- function D(e) {
71
- return w.get(e) ?? null;
106
+ function P(e) {
107
+ return j.get(e) ?? null;
72
108
  }
73
- function O(e) {
74
- let t = D(e);
75
- return t && w.delete(e), t;
109
+ function F(e) {
110
+ let t = P(e);
111
+ return t && j.delete(e), t;
76
112
  }
77
113
  //#endregion
78
114
  //#region src/modules/flow/useFlowInitialization.ts
79
- function k(e) {
115
+ function I(e) {
80
116
  e.getState().presentation.shouldPrefetchHome && S();
81
117
  }
82
- function A(e) {
83
- let { apiURL: n, token: i, lang: o, disableDashboardTheme: c, enableHome: l, onError: u } = e, d = r(null), [f, m] = a(() => {
84
- let t = D(i);
85
- if (t?.status === "ready") {
86
- let e = O(i);
87
- if (e) return d.current = e.flowManager, k(e.flowManager), e.uiConfig && s(e.uiConfig), {
118
+ function L(e) {
119
+ let { apiURL: n, lang: i, disableDashboardTheme: o, enableHome: c, onError: l } = e, u = k(e) ? e.token : void 0, d = r(null), [f, m] = a(() => {
120
+ let t = u ? P(u) : null;
121
+ if (u && t?.status === "ready") {
122
+ let e = F(u);
123
+ if (e) return d.current = e.flowManager, I(e.flowManager), e.uiConfig && s(e.uiConfig), {
88
124
  status: "ready",
89
125
  flowManager: e.flowManager
90
126
  };
91
127
  }
92
128
  let n = v(e);
93
- return d.current = n, k(n), t?.status === "error" ? {
129
+ return d.current = n, I(n), t?.status === "error" ? {
94
130
  status: "error",
95
131
  error: t.error ?? "Preload failed",
96
132
  flowManager: n
@@ -101,11 +137,11 @@ function A(e) {
101
137
  }), h = r(!1);
102
138
  return t(() => {
103
139
  if (f.status !== "initializing") return;
104
- let e = D(i);
105
- if (e?.status === "loading") {
106
- e.readyPromise.then(() => {
107
- let e = O(i);
108
- e && (d.current = e.flowManager, k(e.flowManager), e.uiConfig && s(e.uiConfig), m({
140
+ let t = u ? P(u) : null;
141
+ if (u && t?.status === "loading") {
142
+ t.readyPromise.then(() => {
143
+ let e = F(u);
144
+ e && (d.current = e.flowManager, I(e.flowManager), e.uiConfig && s(e.uiConfig), m({
109
145
  status: "ready",
110
146
  flowManager: e.flowManager
111
147
  }));
@@ -115,18 +151,22 @@ function A(e) {
115
151
  status: "error",
116
152
  error: t,
117
153
  flowManager: f.flowManager
118
- }), u?.(t);
154
+ }), l?.(t);
119
155
  });
120
156
  return;
121
157
  }
122
158
  h.current || (h.current = !0, (async () => {
123
159
  try {
160
+ let t;
161
+ if (k(e)) t = e.token;
162
+ else if (A(e)) t = (await O(e)).token;
163
+ else throw Error("Flow requires token, or configurationId with apiKey or clientId");
124
164
  await p({
125
165
  apiURL: n,
126
- token: i,
127
- lang: o,
166
+ token: t,
167
+ lang: i,
128
168
  flowManager: f.flowManager
129
- }), await (c ? Promise.resolve() : b().then((e) => {
169
+ }), await (o ? Promise.resolve() : b().then((e) => {
130
170
  e.uiConfig && s(e.uiConfig);
131
171
  })), m({
132
172
  status: "ready",
@@ -138,23 +178,24 @@ function A(e) {
138
178
  status: "error",
139
179
  error: t,
140
180
  flowManager: f.flowManager
141
- }), u?.(t);
181
+ }), l?.(t);
142
182
  }
143
183
  })());
144
184
  }, [
145
185
  n,
186
+ u,
146
187
  i,
147
188
  o,
148
189
  c,
149
190
  l,
150
- u,
191
+ e,
151
192
  f
152
193
  ]), f;
153
194
  }
154
195
  //#endregion
155
196
  //#region src/modules/flow/flow.tsx
156
- var j = n(() => import("../homeScreen-C0-81utl.js").then((e) => ({ default: e.HomeScreen }))), M = ({ config: n, onFinish: r, onError: a }) => {
157
- let { t: s, i18n: l } = e(), d = A({
197
+ var R = n(() => import("../homeScreen-C0-81utl.js").then((e) => ({ default: e.HomeScreen }))), z = ({ config: n, onFinish: r, onError: a }) => {
198
+ let { t: s, i18n: l } = e(), d = L({
158
199
  ...n,
159
200
  onError: a
160
201
  }), [p, g] = c(() => d.flowManager, { autoLoad: !1 }), v = p.presentation.lazyModuleKey, b = p.status === "ready" ? p.currentStep : void 0, w = x({
@@ -200,7 +241,7 @@ var j = n(() => import("../homeScreen-C0-81utl.js").then((e) => ({ default: e.Ho
200
241
  class: "IncodeFlow",
201
242
  children: /* @__PURE__ */ o(i, {
202
243
  fallback: null,
203
- children: /* @__PURE__ */ o(j, {
244
+ children: /* @__PURE__ */ o(R, {
204
245
  isContinueLoading: p.homeScreen.isContinueLoading || D,
205
246
  onContinue: () => g.continueFromHome()
206
247
  })
@@ -489,11 +530,11 @@ var j = n(() => import("../homeScreen-C0-81utl.js").then((e) => ({ default: e.Ho
489
530
  });
490
531
  }
491
532
  return null;
492
- }, N = ({ config: e, onFinish: t = () => {}, onError: n }) => /* @__PURE__ */ o(l, { children: e ? /* @__PURE__ */ o(M, {
533
+ }, B = ({ config: e, onFinish: t = () => {}, onError: n }) => /* @__PURE__ */ o(l, { children: e ? /* @__PURE__ */ o(z, {
493
534
  config: e,
494
535
  onFinish: t,
495
536
  onError: n
496
537
  }) : null });
497
- d(N, "incode-flow");
538
+ d(B, "incode-flow");
498
539
  //#endregion
499
- export { N as IncodeFlow, E as preloadIncodeFlow };
540
+ export { B as IncodeFlow, N as preloadIncodeFlow };
@@ -1,17 +1,20 @@
1
+ import { CreateSessionOptions } from '@incodetech/core/session';
1
2
  import { FC } from 'preact/compat';
2
3
  import { FinishStatus } from '@incodetech/core/flow';
3
4
  import { WasmConfig } from '@incodetech/core/wasm';
4
5
 
5
- export declare type FlowConfig = FlowRuntimeConfig & {
6
- onModuleLoading?: (moduleKey: string) => void;
7
- onModuleLoaded?: (moduleKey: string) => void;
8
- onWasmWarmup?: (pipelines: string[]) => void;
9
- spinnerConfig?: SpinnerConfig;
6
+ declare type ApiKeySessionBootstrap = {
7
+ apiKey: string;
8
+ clientId?: string;
9
+ };
10
+
11
+ declare type ClientIdSessionBootstrap = {
12
+ apiKey?: string;
13
+ clientId: string;
10
14
  };
11
15
 
12
- declare type FlowRuntimeConfig = {
16
+ declare type FlowBaseConfig = {
13
17
  apiURL: string;
14
- token: string;
15
18
  authHint?: string;
16
19
  wasmConfig?: WasmConfig;
17
20
  lang?: string;
@@ -19,6 +22,17 @@ declare type FlowRuntimeConfig = {
19
22
  enableHome?: boolean;
20
23
  };
21
24
 
25
+ export declare type FlowConfig = FlowRuntimeConfig & FlowUiConfig;
26
+
27
+ declare type FlowRuntimeConfig = TokenFlowRuntimeConfig | SelfLoadingFlowRuntimeConfig;
28
+
29
+ declare type FlowUiConfig = {
30
+ onModuleLoading?: (moduleKey: string) => void;
31
+ onModuleLoaded?: (moduleKey: string) => void;
32
+ onWasmWarmup?: (pipelines: string[]) => void;
33
+ spinnerConfig?: SpinnerConfig;
34
+ };
35
+
22
36
  export declare const IncodeFlow: FC<IncodeFlowProps>;
23
37
 
24
38
  declare type IncodeFlowProps = IncodeModuleProps<FlowConfig, FinishStatus>;
@@ -44,7 +58,7 @@ declare type IncodeModuleProps<TConfig, TResult = void, TManager = unknown> = {
44
58
  onError?: (error: string | undefined) => void;
45
59
  };
46
60
 
47
- declare type PreloadConfig = FlowRuntimeConfig;
61
+ declare type PreloadConfig = TokenFlowRuntimeConfig;
48
62
 
49
63
  export declare type PreloadHandle = {
50
64
  get isReady(): boolean;
@@ -55,6 +69,12 @@ export declare type PreloadHandle = {
55
69
 
56
70
  export declare function preloadIncodeFlow(config: PreloadConfig): PreloadHandle;
57
71
 
72
+ declare type SelfLoadingFlowRuntimeConfig = FlowBaseConfig & SelfLoadingSessionOptions & (ApiKeySessionBootstrap | ClientIdSessionBootstrap) & {
73
+ token?: never;
74
+ };
75
+
76
+ declare type SelfLoadingSessionOptions = Pick<CreateSessionOptions, 'configurationId' | 'externalId' | 'externalCustomerId' | 'customFields' | 'uuid' | 'interviewId'>;
77
+
58
78
  declare type SpinnerConfig = {
59
79
  title?: string;
60
80
  subtitle?: string;
@@ -63,6 +83,18 @@ declare type SpinnerConfig = {
63
83
 
64
84
  declare type SpinnerSize = 'small' | 'medium' | 'large';
65
85
 
86
+ declare type TokenFlowRuntimeConfig = FlowBaseConfig & {
87
+ token: string;
88
+ apiKey?: never;
89
+ clientId?: never;
90
+ configurationId?: never;
91
+ externalId?: never;
92
+ externalCustomerId?: never;
93
+ customFields?: never;
94
+ uuid?: never;
95
+ interviewId?: never;
96
+ };
97
+
66
98
  export { }
67
99
 
68
100
  declare global {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/web",
3
- "version": "0.0.0-dev-20260417-78468b3",
3
+ "version": "0.0.0-dev-20260417-4da85d5",
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-20260417-78468b3"
186
+ "@incodetech/core": "0.0.0-dev-20260417-4da85d5"
187
187
  },
188
188
  "devDependencies": {
189
189
  "@microsoft/api-extractor": "^7.53.3",