@picked/client 0.0.1-dev.1769473835566 → 0.0.1-dev.1769486944066
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/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/data-layer/index.js +1 -0
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +270 -997
- package/dist/esm/plugins/create-experience/index.js +251 -255
- package/dist/esm/plugins/data-layer/index.js +198 -0
- package/dist/esm/plugins/responses-browser-storage/index.js +23 -25
- package/dist/esm/plugins/responses-indexeddb/index.js +49 -67
- package/dist/esm/plugins/single-page-app/index.js +3 -3
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +19 -19
- package/dist/experience-instance-CsMhH0DN.cjs +1 -0
- package/dist/{experience-instance-Bg6BWuwI.js → experience-instance-DJCJUe0h.js} +227 -218
- package/dist/{supports-BjhuLJ8z.js → supports-DCSoenK6.js} +11 -11
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/plugins/data-layer/custom-event.d.ts +5 -0
- package/dist/types/plugins/data-layer/custom-event.d.ts.map +1 -0
- package/dist/types/plugins/data-layer/index.d.ts +2 -0
- package/dist/types/plugins/data-layer/index.d.ts.map +1 -0
- package/dist/types/plugins/data-layer/plugin.d.ts +55 -0
- package/dist/types/plugins/data-layer/plugin.d.ts.map +1 -0
- package/dist/types/plugins/data-layer/utils.d.ts +39 -0
- package/dist/types/plugins/data-layer/utils.d.ts.map +1 -0
- package/dist/types/utils/events.d.ts +7 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/user-session-DQh0BBTx.cjs +1 -0
- package/dist/user-session-XidjAPGf.js +747 -0
- package/package.json +11 -5
- package/dist/experience-instance-DBi45xr9.cjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createDomain as
|
|
2
|
-
import { createFactory as
|
|
3
|
-
import {
|
|
4
|
-
import { l as
|
|
5
|
-
import { i as
|
|
6
|
-
function
|
|
1
|
+
import { createDomain as xt, createEvent as k, combine as C, createApi as ct, createEffect as $, attach as F, sample as m, split as It } from "effector";
|
|
2
|
+
import { createFactory as ut, invoke as ft } from "@withease/factories";
|
|
3
|
+
import { h as Et, s as lt, a as kt } from "./supports-DCSoenK6.js";
|
|
4
|
+
import { l as x } from "./logger-C9a75KZn.js";
|
|
5
|
+
import { i as At } from "./object-JwZ58NOH.js";
|
|
6
|
+
function bt(t) {
|
|
7
7
|
return typeof t == "number" && !isNaN(t);
|
|
8
8
|
}
|
|
9
9
|
function H(t) {
|
|
@@ -12,21 +12,21 @@ function H(t) {
|
|
|
12
12
|
function N(t) {
|
|
13
13
|
return Array.isArray(t);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function dt(t) {
|
|
16
16
|
return t instanceof Promise;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function rt(t) {
|
|
19
19
|
return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
|
|
20
20
|
}
|
|
21
21
|
function g(t) {
|
|
22
|
-
if (
|
|
22
|
+
if (bt(t)) return t;
|
|
23
23
|
const e = parseFloat(`${t}`);
|
|
24
24
|
return isNaN(e) ? 0 : e;
|
|
25
25
|
}
|
|
26
26
|
function D(t) {
|
|
27
27
|
return `${t}`;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const vt = {
|
|
30
30
|
// eslint-disable-next-line eqeqeq
|
|
31
31
|
"==": (t, e) => t == e,
|
|
32
32
|
"===": (t, e) => t === e,
|
|
@@ -47,8 +47,8 @@ const Et = {
|
|
|
47
47
|
const a = g(r);
|
|
48
48
|
return n <= s && s <= a;
|
|
49
49
|
},
|
|
50
|
-
"!!": async (t) => await
|
|
51
|
-
"!": async (t) => !await
|
|
50
|
+
"!!": async (t) => await O(t),
|
|
51
|
+
"!": async (t) => !await O(t),
|
|
52
52
|
"%": (t, e) => g(t) % g(e),
|
|
53
53
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
54
|
log: (t) => (console.log(t), t),
|
|
@@ -142,31 +142,31 @@ const Et = {
|
|
|
142
142
|
};
|
|
143
143
|
async function p(t, e) {
|
|
144
144
|
if (!t) return t;
|
|
145
|
-
if (
|
|
145
|
+
if (dt(t))
|
|
146
146
|
return p(await t, e);
|
|
147
147
|
if (N(t))
|
|
148
148
|
return Promise.all(t.map((o) => p(o, e)));
|
|
149
|
-
if (!
|
|
150
|
-
const r =
|
|
149
|
+
if (!rt(t)) return t;
|
|
150
|
+
const r = Ot(t);
|
|
151
151
|
let n = r ? t[r] ?? [] : [];
|
|
152
152
|
switch (N(n) || (n = [n]), r) {
|
|
153
153
|
case "if":
|
|
154
154
|
case "?:":
|
|
155
155
|
for (let o = 0; o < n.length - 1; o += 2)
|
|
156
|
-
if (await
|
|
156
|
+
if (await O(await p(n[o], e)))
|
|
157
157
|
return p(n[o + 1], e);
|
|
158
158
|
return n.length % 2 === 1 ? p(n[n.length - 1], e) : null;
|
|
159
159
|
case "and": {
|
|
160
160
|
let o = null;
|
|
161
161
|
for (const c of n)
|
|
162
|
-
if (o = await p(c, e), !await
|
|
162
|
+
if (o = await p(c, e), !await O(o))
|
|
163
163
|
return o;
|
|
164
164
|
return o;
|
|
165
165
|
}
|
|
166
166
|
case "or": {
|
|
167
167
|
let o = null;
|
|
168
168
|
for (const c of n)
|
|
169
|
-
if (o = await p(c, e), await
|
|
169
|
+
if (o = await p(c, e), await O(o)) return o;
|
|
170
170
|
return o;
|
|
171
171
|
}
|
|
172
172
|
case "map": {
|
|
@@ -177,7 +177,7 @@ async function p(t, e) {
|
|
|
177
177
|
const o = await p(n[0], e);
|
|
178
178
|
return N(o) ? (await Promise.all(
|
|
179
179
|
o.map(async (d) => {
|
|
180
|
-
const S = await
|
|
180
|
+
const S = await O(await p(n[1], d));
|
|
181
181
|
return { item: d, shouldInclude: S };
|
|
182
182
|
})
|
|
183
183
|
)).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
|
|
@@ -188,52 +188,52 @@ async function p(t, e) {
|
|
|
188
188
|
return n.length > 2 ? await p(n[2], e) : null;
|
|
189
189
|
const c = n[1];
|
|
190
190
|
let S = n.length > 2 ? await p(n[2], e) : null;
|
|
191
|
-
for (const
|
|
192
|
-
S = await p(c, { current:
|
|
191
|
+
for (const A of o)
|
|
192
|
+
S = await p(c, { current: A, accumulator: S });
|
|
193
193
|
return S;
|
|
194
194
|
}
|
|
195
195
|
case "all": {
|
|
196
196
|
const o = await p(n[0], e);
|
|
197
197
|
if (!N(o) || o.length === 0) return !1;
|
|
198
198
|
for (const c of o)
|
|
199
|
-
if (!await
|
|
199
|
+
if (!await O(await p(n[1], c))) return !1;
|
|
200
200
|
return !0;
|
|
201
201
|
}
|
|
202
202
|
case "some": {
|
|
203
203
|
const o = await p(n[0], e);
|
|
204
204
|
if (!N(o)) return !1;
|
|
205
205
|
for (const c of o)
|
|
206
|
-
if (await
|
|
206
|
+
if (await O(await p(n[1], c))) return !0;
|
|
207
207
|
return !1;
|
|
208
208
|
}
|
|
209
209
|
case "none": {
|
|
210
210
|
const o = await p(n[0], e);
|
|
211
211
|
if (!N(o)) return !0;
|
|
212
212
|
for (const c of o)
|
|
213
|
-
if (await
|
|
213
|
+
if (await O(await p(n[1], c))) return !1;
|
|
214
214
|
return !0;
|
|
215
215
|
}
|
|
216
216
|
case "catch":
|
|
217
217
|
try {
|
|
218
218
|
return await p(n[0], e);
|
|
219
219
|
} catch (o) {
|
|
220
|
-
return
|
|
220
|
+
return rt(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
const s = await Promise.all(n.map((o) => p(o, e))), a = r ?
|
|
223
|
+
const s = await Promise.all(n.map((o) => p(o, e))), a = r ? vt[r] : void 0;
|
|
224
224
|
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
225
225
|
return a.apply(e, s);
|
|
226
226
|
}
|
|
227
|
-
async function
|
|
228
|
-
return
|
|
227
|
+
async function O(t) {
|
|
228
|
+
return dt(t) ? O(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function Ot(t) {
|
|
231
231
|
return Object.keys(t)[0];
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
return !
|
|
233
|
+
function Bt(t) {
|
|
234
|
+
return !At(t);
|
|
235
235
|
}
|
|
236
|
-
async function
|
|
236
|
+
async function ot(t, e, r) {
|
|
237
237
|
const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((c, d) => ({
|
|
238
238
|
...c,
|
|
239
239
|
[d.name]: (...S) => d.predicate({ ...n, args: S })
|
|
@@ -262,44 +262,44 @@ async function et(t, e, r) {
|
|
|
262
262
|
};
|
|
263
263
|
return await p(e, o);
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
return !
|
|
265
|
+
function Ft(t) {
|
|
266
|
+
return !kt() || !lt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
267
267
|
(e) => e instanceof HTMLElement
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
|
-
const
|
|
271
|
-
function
|
|
272
|
-
if (!
|
|
270
|
+
const _t = "open";
|
|
271
|
+
function $t(t) {
|
|
272
|
+
if (!Et())
|
|
273
273
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
274
|
-
return t.attachShadow({ mode:
|
|
274
|
+
return t.attachShadow({ mode: _t });
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function Qt() {
|
|
277
277
|
return new Promise((t, e) => {
|
|
278
|
-
if (!
|
|
278
|
+
if (!lt()) {
|
|
279
279
|
e();
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function Mt(t, e) {
|
|
286
286
|
const r = new MutationObserver((n) => {
|
|
287
287
|
document.contains(t) || (r.disconnect(), e());
|
|
288
288
|
});
|
|
289
289
|
r.observe(document.body, { childList: !0, subtree: !0 });
|
|
290
290
|
}
|
|
291
|
-
const
|
|
292
|
-
function
|
|
291
|
+
const W = "picked-root", G = "picked-target", Tt = "picked-root";
|
|
292
|
+
function Yt(t, e) {
|
|
293
293
|
return [
|
|
294
294
|
...t,
|
|
295
295
|
// Target and replace picked-root web components
|
|
296
296
|
{
|
|
297
|
-
selector: `${
|
|
297
|
+
selector: `${Tt}[experience-id="${e}"]`,
|
|
298
298
|
placement: "replace"
|
|
299
299
|
}
|
|
300
300
|
].flatMap((n) => {
|
|
301
|
-
const s =
|
|
302
|
-
(a) => !
|
|
301
|
+
const s = Ft(n.selector).filter(
|
|
302
|
+
(a) => !Lt(a, e) && !Dt(a, e)
|
|
303
303
|
);
|
|
304
304
|
return {
|
|
305
305
|
...n,
|
|
@@ -307,25 +307,25 @@ function Jt(t, e) {
|
|
|
307
307
|
};
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
return t.flatMap((r) => r.elements.map((n) =>
|
|
310
|
+
function Zt(t, e) {
|
|
311
|
+
return t.flatMap((r) => r.elements.map((n) => Pt(n, r.placement, e)));
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
t.classList.add(
|
|
313
|
+
function te(t, e) {
|
|
314
|
+
t.classList.add(G), t.classList.add(`${G}-${e}`);
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
return e ? t.classList.contains(`${
|
|
316
|
+
function Lt(t, e) {
|
|
317
|
+
return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(`${G}`);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
return e ? t.classList.contains(`${
|
|
319
|
+
function Dt(t, e) {
|
|
320
|
+
return e ? t.classList.contains(`${W}-${e}`) : t.classList.contains(W);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Rt(t) {
|
|
323
323
|
const e = document.createElement("div");
|
|
324
|
-
return e.style.display = "block", e.classList.add(
|
|
324
|
+
return e.style.display = "block", e.classList.add(W), e.classList.add(`${W}-${t}`), e;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function Pt(t, e, r) {
|
|
327
327
|
let n;
|
|
328
|
-
const s =
|
|
328
|
+
const s = Rt(r);
|
|
329
329
|
if (t instanceof Document)
|
|
330
330
|
n = t.body.appendChild(s);
|
|
331
331
|
else {
|
|
@@ -350,25 +350,25 @@ function Tt(t, e, r) {
|
|
|
350
350
|
}
|
|
351
351
|
return n;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function it(t) {
|
|
354
354
|
return t.type === "conditional";
|
|
355
355
|
}
|
|
356
356
|
function j(t) {
|
|
357
357
|
return t.type === "step";
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function st(t) {
|
|
360
360
|
return t.type === "experience";
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function z(t) {
|
|
363
363
|
return t.type === "origin";
|
|
364
364
|
}
|
|
365
|
-
function
|
|
365
|
+
function at(t) {
|
|
366
366
|
return t.type === "action";
|
|
367
367
|
}
|
|
368
|
-
const
|
|
368
|
+
const pt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), j(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
369
369
|
const c = t.find((d) => d.id === o.destinationNodeId);
|
|
370
|
-
return c ?
|
|
371
|
-
})),
|
|
370
|
+
return c ? pt(t, e, c, !1, s) : [];
|
|
371
|
+
})), Ct = (t, e, r) => pt(t, e, r, !0, /* @__PURE__ */ new Set()), gt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
|
|
372
372
|
if (s.has(r.id)) return [-1, -1];
|
|
373
373
|
s.add(r.id);
|
|
374
374
|
const a = e.filter((d) => d.sourceNodeId === r.id);
|
|
@@ -377,17 +377,17 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
377
377
|
for (const d of a) {
|
|
378
378
|
const S = t.find((R) => R.id === d.destinationNodeId);
|
|
379
379
|
if (!S) continue;
|
|
380
|
-
const [
|
|
380
|
+
const [A, _] = gt(
|
|
381
381
|
t,
|
|
382
382
|
e,
|
|
383
383
|
S,
|
|
384
384
|
!1,
|
|
385
385
|
new Set(s)
|
|
386
386
|
);
|
|
387
|
-
|
|
387
|
+
A !== -1 && (o = Math.min(o, A + 1), c = Math.max(c, _ + 1));
|
|
388
388
|
}
|
|
389
389
|
return o === 1 / 0 ? [-1, -1] : [o, c];
|
|
390
|
-
},
|
|
390
|
+
}, Ht = (t, e, r) => gt(t, e, r, !0, /* @__PURE__ */ new Set()), mt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
391
391
|
if (n.has(r.id)) return [-1, -1];
|
|
392
392
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
393
393
|
const s = e.filter((c) => c.destinationNodeId === r.id);
|
|
@@ -396,172 +396,182 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
396
396
|
for (const c of s) {
|
|
397
397
|
const d = t.find((_) => _.id === c.sourceNodeId);
|
|
398
398
|
if (!d) continue;
|
|
399
|
-
const [S,
|
|
399
|
+
const [S, A] = mt(
|
|
400
400
|
t,
|
|
401
401
|
e,
|
|
402
402
|
d,
|
|
403
403
|
new Set(n)
|
|
404
404
|
);
|
|
405
|
-
S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o,
|
|
405
|
+
S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o, A + 1));
|
|
406
406
|
}
|
|
407
407
|
return a === 1 / 0 ? [-1, -1] : [a, o];
|
|
408
|
-
},
|
|
408
|
+
}, jt = (t, e, r) => mt(t, e, r, /* @__PURE__ */ new Set()), St = (t) => t.find((r) => r.type === "origin") || null, J = (t, e, r) => {
|
|
409
409
|
if (!t)
|
|
410
|
-
return
|
|
410
|
+
return St(e);
|
|
411
411
|
const n = r.find((a) => a.sourceNodeId === t.id);
|
|
412
412
|
if (!n)
|
|
413
413
|
return null;
|
|
414
414
|
const s = e.find((a) => a.id === n.destinationNodeId);
|
|
415
415
|
return s || null;
|
|
416
416
|
};
|
|
417
|
-
async function
|
|
417
|
+
async function Ut(t, e, r, n) {
|
|
418
418
|
const s = t ? "true" : "false", a = n.find(
|
|
419
419
|
(o) => o.sourceNodeHandle === s && o.sourceNodeId === e
|
|
420
420
|
);
|
|
421
|
-
return r.find((o) => o.id ===
|
|
421
|
+
return r.find((o) => o.id === a?.destinationNodeId);
|
|
422
422
|
}
|
|
423
|
-
const
|
|
423
|
+
const Q = xt("experience-instance"), Wt = ut(
|
|
424
424
|
({
|
|
425
425
|
client: t,
|
|
426
426
|
experience: e,
|
|
427
427
|
target: r
|
|
428
428
|
}) => {
|
|
429
|
-
const n =
|
|
430
|
-
var f;
|
|
431
|
-
return ((f = i[i.length - 1]) == null ? void 0 : f.node) || null;
|
|
432
|
-
}), u = C(
|
|
429
|
+
const n = k(), s = k(), a = k(), o = k(), c = k(), d = k(), S = e.componentStore, A = Q.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), R = _.map((i) => i.filter((l) => j(l.node))), I = _.map((i) => i[i.length - 1]?.node || null), u = C(
|
|
433
430
|
e.treeStore,
|
|
434
|
-
|
|
435
|
-
({ steps: i },
|
|
431
|
+
I,
|
|
432
|
+
({ steps: i }, l) => i.find((f) => l && j(l) && f.id === l.stepId) || null
|
|
436
433
|
), h = C(
|
|
437
434
|
e.treeStore,
|
|
438
|
-
|
|
439
|
-
({ nodes: i, edges:
|
|
440
|
-
),
|
|
435
|
+
I,
|
|
436
|
+
({ nodes: i, edges: l }, f) => f ? Ct(i, l, f) : []
|
|
437
|
+
), b = C(
|
|
441
438
|
e.treeStore,
|
|
442
|
-
|
|
443
|
-
({ nodes: i, edges:
|
|
444
|
-
),
|
|
439
|
+
I,
|
|
440
|
+
({ nodes: i, edges: l }, f) => f ? jt(i, l, f) : [-1, -1]
|
|
441
|
+
), M = C(
|
|
445
442
|
e.treeStore,
|
|
446
|
-
|
|
447
|
-
({ nodes: i, edges:
|
|
448
|
-
),
|
|
443
|
+
I,
|
|
444
|
+
({ nodes: i, edges: l }, f) => f ? Ht(i, l, f) : [-1, -1]
|
|
445
|
+
), v = Q.store(!1), T = ct(v, {
|
|
449
446
|
open: () => !0,
|
|
450
447
|
close: () => !1,
|
|
451
448
|
toggle: (i) => !i,
|
|
452
|
-
set: (i,
|
|
453
|
-
}),
|
|
449
|
+
set: (i, l) => l
|
|
450
|
+
}), ht = $(async () => {
|
|
454
451
|
t.history.back({ experienceId: e.id });
|
|
455
|
-
}),
|
|
452
|
+
}), yt = F({
|
|
456
453
|
source: e.treeStore,
|
|
457
|
-
effect: async (i,
|
|
458
|
-
const
|
|
459
|
-
|
|
454
|
+
effect: async (i, l) => {
|
|
455
|
+
const f = i.nodes.find((w) => j(w) && w.stepId === l);
|
|
456
|
+
f && t.history.push({ experienceId: e.id, node: f });
|
|
460
457
|
}
|
|
461
|
-
}),
|
|
462
|
-
source:
|
|
458
|
+
}), Y = F({
|
|
459
|
+
source: I,
|
|
463
460
|
effect: (i) => {
|
|
464
461
|
}
|
|
465
|
-
}),
|
|
462
|
+
}), K = F({
|
|
466
463
|
source: e.treeStore,
|
|
467
|
-
effect: async ({ nodes: i }) =>
|
|
464
|
+
effect: async ({ nodes: i }) => St(i)
|
|
468
465
|
}), V = F({
|
|
469
466
|
source: e.treeStore,
|
|
470
|
-
effect: async ({ nodes: i, edges:
|
|
467
|
+
effect: async ({ nodes: i, edges: l }, f) => {
|
|
468
|
+
if (z(f))
|
|
469
|
+
return J(f, i, l);
|
|
470
|
+
}
|
|
471
471
|
}), q = F({
|
|
472
472
|
source: e.treeStore,
|
|
473
|
-
effect: async ({ nodes: i, edges:
|
|
474
|
-
if (!w)
|
|
473
|
+
effect: async ({ nodes: i, edges: l, conditionals: f }, w) => {
|
|
474
|
+
if (!it(w))
|
|
475
475
|
return;
|
|
476
|
-
const L =
|
|
476
|
+
const L = f.find((B) => B.id === w.conditionalId);
|
|
477
477
|
if (!L)
|
|
478
478
|
return;
|
|
479
|
-
const E = w.id, y = await
|
|
480
|
-
return
|
|
479
|
+
const E = w.id, y = await ot(t, L.condition);
|
|
480
|
+
return Ut(!!y, E, i, l);
|
|
481
481
|
}
|
|
482
|
-
}),
|
|
482
|
+
}), Z = F({
|
|
483
483
|
source: e.treeStore,
|
|
484
|
-
effect: async ({ nodes: i, edges:
|
|
485
|
-
if (!
|
|
484
|
+
effect: async ({ nodes: i, edges: l }, f) => {
|
|
485
|
+
if (!at(f))
|
|
486
486
|
return;
|
|
487
|
-
const w =
|
|
487
|
+
const w = f.action;
|
|
488
488
|
if (!w) {
|
|
489
|
-
|
|
489
|
+
x("warn", `Action node ${f.id} has no action name`);
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
const L = t.actions.getByName(w).getState();
|
|
493
493
|
if (!L) {
|
|
494
|
-
|
|
495
|
-
const E =
|
|
496
|
-
(y) => y.sourceNodeId ===
|
|
494
|
+
x("warn", `Action '${w}' not registered on client`);
|
|
495
|
+
const E = l.find(
|
|
496
|
+
(y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
|
|
497
497
|
);
|
|
498
498
|
return E ? i.find((y) => y.id === E.destinationNodeId) : null;
|
|
499
499
|
}
|
|
500
500
|
if (typeof L.action != "function") {
|
|
501
|
-
|
|
502
|
-
const E =
|
|
503
|
-
(y) => y.sourceNodeId ===
|
|
501
|
+
x("warn", `Action '${w}' is not a function`);
|
|
502
|
+
const E = l.find(
|
|
503
|
+
(y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
|
|
504
504
|
);
|
|
505
505
|
return E ? i.find((y) => y.id === E.destinationNodeId) : null;
|
|
506
506
|
}
|
|
507
507
|
try {
|
|
508
|
-
|
|
509
|
-
const E =
|
|
510
|
-
(
|
|
508
|
+
x("info", `Executing action: ${w}`), await L.action(w);
|
|
509
|
+
const E = l.find(
|
|
510
|
+
(B) => B.sourceNodeId === f.id && B.sourceNodeHandle === "true"
|
|
511
511
|
);
|
|
512
512
|
if (!E)
|
|
513
|
-
return
|
|
514
|
-
const y = i.find((
|
|
515
|
-
return
|
|
513
|
+
return x("warn", `No 'true' edge found for action node ${f.id}`), null;
|
|
514
|
+
const y = i.find((B) => B.id === E.destinationNodeId);
|
|
515
|
+
return x("info", `Action '${w}' succeeded, moving to node ${y?.id}`), y || null;
|
|
516
516
|
} catch (E) {
|
|
517
|
-
|
|
518
|
-
const y =
|
|
519
|
-
(
|
|
517
|
+
x("warn", `Action '${w}' failed:`, E);
|
|
518
|
+
const y = l.find(
|
|
519
|
+
(U) => U.sourceNodeId === f.id && U.sourceNodeHandle === "false"
|
|
520
520
|
);
|
|
521
521
|
if (!y)
|
|
522
|
-
return
|
|
523
|
-
const
|
|
524
|
-
return
|
|
522
|
+
return x("warn", `No 'false' edge found for action node ${f.id}`), null;
|
|
523
|
+
const B = i.find((U) => U.id === y.destinationNodeId);
|
|
524
|
+
return x("info", `Action '${w}' failed, moving to node ${B?.id}`), B || null;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
}),
|
|
528
|
-
if (i)
|
|
527
|
+
}), wt = $((i) => {
|
|
528
|
+
if (st(i))
|
|
529
529
|
return t.launchExperienceById(i.experienceId);
|
|
530
|
-
}),
|
|
531
|
-
source: [
|
|
532
|
-
effect: async ([i, { nodes:
|
|
530
|
+
}), tt = F({
|
|
531
|
+
source: [I, e.treeStore],
|
|
532
|
+
effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
|
|
533
533
|
}), P = F({
|
|
534
|
-
source: [
|
|
535
|
-
effect: async ([i, { nodes:
|
|
536
|
-
}),
|
|
534
|
+
source: [I, e.treeStore],
|
|
535
|
+
effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
|
|
536
|
+
}), Nt = $((i) => {
|
|
537
537
|
t.history.push({ experienceId: e.id, node: i });
|
|
538
|
-
}),
|
|
538
|
+
}), et = F({
|
|
539
539
|
source: e.configStore,
|
|
540
|
-
effect: async ({ initializeOpenLogic: i }) =>
|
|
541
|
-
});
|
|
542
|
-
return
|
|
543
|
-
source:
|
|
544
|
-
|
|
540
|
+
effect: async ({ initializeOpenLogic: i }) => Bt(i) ? !!await ot(t, i) : i ?? !1
|
|
541
|
+
}), X = k(), nt = k();
|
|
542
|
+
return m({
|
|
543
|
+
source: I,
|
|
544
|
+
target: X
|
|
545
|
+
}), m({
|
|
546
|
+
clock: X,
|
|
547
|
+
filter: (i) => i === null,
|
|
548
|
+
target: K
|
|
549
|
+
}), m({
|
|
550
|
+
clock: X,
|
|
551
|
+
filter: (i) => i !== null,
|
|
552
|
+
target: nt
|
|
553
|
+
}), It({
|
|
554
|
+
source: nt,
|
|
555
|
+
match: (i) => it(i) ? "condition" : j(i) ? "step" : st(i) ? "launchExperience" : z(i) ? "origin" : at(i) ? "action" : "other",
|
|
545
556
|
cases: {
|
|
546
|
-
none: U,
|
|
547
557
|
origin: V,
|
|
548
558
|
condition: q,
|
|
549
|
-
step:
|
|
550
|
-
launchExperience:
|
|
551
|
-
action:
|
|
552
|
-
__:
|
|
559
|
+
step: Y,
|
|
560
|
+
launchExperience: wt,
|
|
561
|
+
action: Z,
|
|
562
|
+
__: k()
|
|
553
563
|
}
|
|
554
564
|
}), m({
|
|
555
565
|
clock: [
|
|
556
566
|
q.doneData,
|
|
557
567
|
V.doneData,
|
|
558
|
-
|
|
568
|
+
K.doneData,
|
|
559
569
|
P.doneData,
|
|
560
|
-
|
|
561
|
-
|
|
570
|
+
tt.doneData,
|
|
571
|
+
Z.doneData
|
|
562
572
|
],
|
|
563
573
|
filter: Boolean,
|
|
564
|
-
target:
|
|
574
|
+
target: Nt
|
|
565
575
|
}), m({
|
|
566
576
|
clock: s,
|
|
567
577
|
target: P
|
|
@@ -594,18 +604,18 @@ const z = ht("experience-instance"), jt = it(
|
|
|
594
604
|
}))
|
|
595
605
|
}), m({
|
|
596
606
|
clock: a,
|
|
597
|
-
target:
|
|
598
|
-
}), m({ clock: o, target:
|
|
607
|
+
target: ht
|
|
608
|
+
}), m({ clock: o, target: yt }), m({
|
|
599
609
|
source: C([
|
|
600
610
|
q.pending,
|
|
601
611
|
V.pending,
|
|
602
|
-
|
|
612
|
+
K.pending,
|
|
603
613
|
P.pending
|
|
604
614
|
]),
|
|
605
615
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
606
|
-
target:
|
|
616
|
+
target: A
|
|
607
617
|
}), m({
|
|
608
|
-
clock:
|
|
618
|
+
clock: Y.doneData,
|
|
609
619
|
source: u,
|
|
610
620
|
filter: Boolean,
|
|
611
621
|
target: t.eventBus.prepend((i) => ({
|
|
@@ -615,29 +625,29 @@ const z = ht("experience-instance"), jt = it(
|
|
|
615
625
|
}))
|
|
616
626
|
}), m({
|
|
617
627
|
clock: d,
|
|
618
|
-
target:
|
|
628
|
+
target: et
|
|
619
629
|
}), m({
|
|
620
|
-
source:
|
|
630
|
+
source: et.doneData,
|
|
621
631
|
fn: Boolean,
|
|
622
|
-
target:
|
|
632
|
+
target: v
|
|
623
633
|
}), m({
|
|
624
|
-
source:
|
|
634
|
+
source: I,
|
|
625
635
|
clock: n,
|
|
626
|
-
filter: (i) => i ?
|
|
627
|
-
target:
|
|
636
|
+
filter: (i) => i ? z(i) : !0,
|
|
637
|
+
target: tt
|
|
628
638
|
}), m({
|
|
629
|
-
source:
|
|
639
|
+
source: v,
|
|
630
640
|
filter: Boolean,
|
|
631
641
|
target: n
|
|
632
642
|
}), m({
|
|
633
|
-
source:
|
|
643
|
+
source: v,
|
|
634
644
|
filter: Boolean,
|
|
635
645
|
target: t.eventBus.prepend(() => ({
|
|
636
646
|
type: "experience_open",
|
|
637
647
|
experience: e
|
|
638
648
|
}))
|
|
639
649
|
}), m({
|
|
640
|
-
source:
|
|
650
|
+
source: v,
|
|
641
651
|
filter: (i) => !i,
|
|
642
652
|
target: t.eventBus.prepend(() => ({
|
|
643
653
|
type: "experience_close",
|
|
@@ -654,20 +664,20 @@ const z = ht("experience-instance"), jt = it(
|
|
|
654
664
|
target: r,
|
|
655
665
|
componentStore: S,
|
|
656
666
|
// state
|
|
657
|
-
stateStore:
|
|
667
|
+
stateStore: A,
|
|
658
668
|
// open close
|
|
659
|
-
isOpenStore:
|
|
660
|
-
open:
|
|
661
|
-
close:
|
|
662
|
-
toggleOpen:
|
|
663
|
-
setOpen:
|
|
669
|
+
isOpenStore: v,
|
|
670
|
+
open: T.open,
|
|
671
|
+
close: T.close,
|
|
672
|
+
toggleOpen: T.toggle,
|
|
673
|
+
setOpen: T.set,
|
|
664
674
|
// nodes
|
|
665
675
|
treeStore: e.treeStore,
|
|
666
|
-
currentNodeStore:
|
|
676
|
+
currentNodeStore: I,
|
|
667
677
|
currentStepStore: u,
|
|
668
678
|
nextReachableStepNodesStore: h,
|
|
669
|
-
stepsToOriginStore:
|
|
670
|
-
stepsToLeafStore:
|
|
679
|
+
stepsToOriginStore: b,
|
|
680
|
+
stepsToLeafStore: M,
|
|
671
681
|
// history
|
|
672
682
|
goToNextStep: s,
|
|
673
683
|
goToPreviousStep: a,
|
|
@@ -676,69 +686,68 @@ const z = ht("experience-instance"), jt = it(
|
|
|
676
686
|
};
|
|
677
687
|
}
|
|
678
688
|
);
|
|
679
|
-
function
|
|
680
|
-
return
|
|
689
|
+
function Gt(t) {
|
|
690
|
+
return ft(Wt, t);
|
|
681
691
|
}
|
|
682
|
-
const
|
|
683
|
-
const e =
|
|
692
|
+
const Kt = ut(({ client: t }) => {
|
|
693
|
+
const e = Q.store({}), r = k(), n = k(), s = k(), a = ct(e, {
|
|
684
694
|
register(u, h) {
|
|
685
|
-
const
|
|
695
|
+
const b = [
|
|
686
696
|
...u[h.experienceId] ?? []
|
|
687
697
|
];
|
|
688
|
-
return
|
|
698
|
+
return b.push(h), {
|
|
689
699
|
...u,
|
|
690
|
-
[h.experienceId]:
|
|
700
|
+
[h.experienceId]: b
|
|
691
701
|
};
|
|
692
702
|
},
|
|
693
703
|
unregister(u, h) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
($) => $ !== h
|
|
704
|
+
const b = h.experienceId, M = u[b]?.filter(
|
|
705
|
+
(v) => v !== h
|
|
697
706
|
);
|
|
698
707
|
return {
|
|
699
708
|
...u,
|
|
700
|
-
[
|
|
709
|
+
[b]: M ?? []
|
|
701
710
|
};
|
|
702
711
|
}
|
|
703
|
-
}), o =
|
|
704
|
-
({ experience: u, target: h }) =>
|
|
705
|
-
), c =
|
|
712
|
+
}), o = $(
|
|
713
|
+
({ experience: u, target: h }) => Gt({ client: t, experience: u, target: h })
|
|
714
|
+
), c = $((u) => {
|
|
706
715
|
a.register(u);
|
|
707
|
-
}), d =
|
|
716
|
+
}), d = $(
|
|
708
717
|
(u) => {
|
|
709
|
-
u.target &&
|
|
718
|
+
u.target && Mt(u.target, () => {
|
|
710
719
|
s(u);
|
|
711
720
|
});
|
|
712
721
|
}
|
|
713
|
-
), S =
|
|
722
|
+
), S = $((u) => {
|
|
714
723
|
a.unregister(u);
|
|
715
|
-
}),
|
|
724
|
+
}), A = $((u) => {
|
|
716
725
|
const h = u.componentStore.getState();
|
|
717
726
|
if (!h) {
|
|
718
|
-
|
|
727
|
+
x("warn", "No app component registered. Skipping init.");
|
|
719
728
|
return;
|
|
720
729
|
}
|
|
721
|
-
const
|
|
722
|
-
if (!
|
|
723
|
-
|
|
730
|
+
const b = h.frameworkStore.getState();
|
|
731
|
+
if (!b) {
|
|
732
|
+
x(
|
|
724
733
|
"error",
|
|
725
734
|
`No framework registered for component '${h.name}'. Skipping rendering.`
|
|
726
735
|
);
|
|
727
736
|
return;
|
|
728
737
|
}
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
731
|
-
|
|
738
|
+
const M = u.target;
|
|
739
|
+
if (!M) {
|
|
740
|
+
x(
|
|
732
741
|
"error",
|
|
733
742
|
`No target element registered for experience '${u.experienceId}'. Skipping rendering.`
|
|
734
743
|
);
|
|
735
744
|
return;
|
|
736
745
|
}
|
|
737
|
-
const
|
|
746
|
+
const v = $t(M);
|
|
738
747
|
try {
|
|
739
|
-
|
|
740
|
-
} catch (
|
|
741
|
-
|
|
748
|
+
b.render(v, h.component, t, u);
|
|
749
|
+
} catch (T) {
|
|
750
|
+
x("error", T);
|
|
742
751
|
}
|
|
743
752
|
});
|
|
744
753
|
m({
|
|
@@ -762,33 +771,33 @@ const Gt = it(({ client: t }) => {
|
|
|
762
771
|
}))
|
|
763
772
|
}), m({
|
|
764
773
|
clock: n,
|
|
765
|
-
target:
|
|
774
|
+
target: A
|
|
766
775
|
});
|
|
767
776
|
function _(u, h) {
|
|
768
777
|
r({ experience: u, target: h });
|
|
769
778
|
}
|
|
770
779
|
const R = e.map((u) => Object.values(u).flat());
|
|
771
|
-
function
|
|
780
|
+
function I(u) {
|
|
772
781
|
return e.map((h) => h[u] || [], { skipVoid: !1 });
|
|
773
782
|
}
|
|
774
783
|
return {
|
|
775
784
|
spawn: _,
|
|
776
|
-
getByExperienceId:
|
|
785
|
+
getByExperienceId: I,
|
|
777
786
|
listStore: R
|
|
778
787
|
};
|
|
779
788
|
});
|
|
780
|
-
function
|
|
781
|
-
return
|
|
789
|
+
function ee(t) {
|
|
790
|
+
return ft(Kt, t);
|
|
782
791
|
}
|
|
783
792
|
export {
|
|
784
|
-
|
|
793
|
+
Gt as a,
|
|
785
794
|
Zt as b,
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
795
|
+
ee as c,
|
|
796
|
+
Qt as d,
|
|
797
|
+
ot as e,
|
|
798
|
+
Bt as f,
|
|
799
|
+
Yt as g,
|
|
800
|
+
j as h,
|
|
801
|
+
Dt as i,
|
|
802
|
+
te as t
|
|
794
803
|
};
|