@picked/client 0.0.1-dev.1773804563218 → 0.0.1-dev.1773807602703
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/{api-CQ1Lb-dB.js → api-GlH9T8_1.js} +1 -1
- package/dist/{api-C90ugp6M.cjs → api-GvmToTw0.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +26 -25
- package/dist/esm/plugins/create-experience/index.js +1 -0
- package/dist/esm/plugins/dynamic-experiences/index.js +56 -55
- package/dist/esm/server/index.js +7 -7
- package/dist/experience-instance-CxiOyYPf.cjs +1 -0
- package/dist/{experience-instance-8P1fJuPC.js → experience-instance-DCknHRkX.js} +214 -229
- package/dist/nodes-DQt4TfuO.js +26 -0
- package/dist/nodes-DsL8kMSX.cjs +1 -0
- package/dist/types/entities/experience/experience.d.ts +2 -0
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +5 -0
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-Bi3-1tP5.cjs +0 -1
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { createDomain as
|
|
2
|
-
import { createFactory as
|
|
3
|
-
import { a as
|
|
1
|
+
import { createDomain as bt, createEvent as I, combine as R, createApi as dt, createEffect as $, attach as O, sample as m, split as vt } from "effector";
|
|
2
|
+
import { createFactory as pt, invoke as gt } from "@withease/factories";
|
|
3
|
+
import { i as C, r as Y, a as Z, b as at, c as ct, d as ut } from "./nodes-DQt4TfuO.js";
|
|
4
|
+
import { a as At, s as mt, j as Ot } from "./supports-8YT4QKI7.js";
|
|
4
5
|
import { l as E } from "./logger-C9a75KZn.js";
|
|
5
|
-
import { i as
|
|
6
|
-
function
|
|
6
|
+
import { i as Ft } from "./object-JwZ58NOH.js";
|
|
7
|
+
function Bt(t) {
|
|
7
8
|
return typeof t == "number" && !isNaN(t);
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function U(t) {
|
|
10
11
|
return typeof t == "string";
|
|
11
12
|
}
|
|
12
13
|
function N(t) {
|
|
13
14
|
return Array.isArray(t);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function St(t) {
|
|
16
17
|
return t instanceof Promise;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function ft(t) {
|
|
19
20
|
return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
|
|
20
21
|
}
|
|
21
22
|
function g(t) {
|
|
22
|
-
if (
|
|
23
|
+
if (Bt(t)) return t;
|
|
23
24
|
const e = parseFloat(`${t}`);
|
|
24
25
|
return isNaN(e) ? 0 : e;
|
|
25
26
|
}
|
|
26
27
|
function P(t) {
|
|
27
28
|
return `${t}`;
|
|
28
29
|
}
|
|
29
|
-
const
|
|
30
|
+
const _t = {
|
|
30
31
|
// eslint-disable-next-line eqeqeq
|
|
31
32
|
"==": (t, e) => t == e,
|
|
32
33
|
"===": (t, e) => t === e,
|
|
@@ -38,32 +39,32 @@ const Bt = {
|
|
|
38
39
|
"<": (t, e, r) => {
|
|
39
40
|
const n = g(t), s = g(e);
|
|
40
41
|
if (r === void 0) return n < s;
|
|
41
|
-
const
|
|
42
|
-
return n < s && s <
|
|
42
|
+
const a = g(r);
|
|
43
|
+
return n < s && s < a;
|
|
43
44
|
},
|
|
44
45
|
"<=": (t, e, r) => {
|
|
45
46
|
const n = g(t), s = g(e);
|
|
46
47
|
if (r === void 0) return n <= s;
|
|
47
|
-
const
|
|
48
|
-
return n <= s && s <=
|
|
48
|
+
const a = g(r);
|
|
49
|
+
return n <= s && s <= a;
|
|
49
50
|
},
|
|
50
51
|
"!!": async (t) => await v(t),
|
|
51
52
|
"!": async (t) => !await v(t),
|
|
52
53
|
"%": (t, e) => g(t) % g(e),
|
|
53
54
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
55
|
log: (t) => (console.log(t), t),
|
|
55
|
-
in: (t, e) => e ?
|
|
56
|
+
in: (t, e) => e ? U(e) ? e.indexOf(P(t)) !== -1 : N(e) ? e.includes(t) : !1 : !1,
|
|
56
57
|
cat: (...t) => t.map(P).join(""),
|
|
57
58
|
/* eslint-disable sonarjs/deprecation */
|
|
58
59
|
substr: (t, e, r) => {
|
|
59
60
|
const n = P(t), s = g(e);
|
|
60
61
|
if (r === void 0) return n.substr(s);
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
62
|
+
const a = g(r);
|
|
63
|
+
if (a < 0) {
|
|
63
64
|
const o = n.substr(s);
|
|
64
|
-
return o.substr(0, o.length +
|
|
65
|
+
return o.substr(0, o.length + a);
|
|
65
66
|
}
|
|
66
|
-
return n.substr(s,
|
|
67
|
+
return n.substr(s, a);
|
|
67
68
|
},
|
|
68
69
|
/* eslint-enable sonarjs/deprecation */
|
|
69
70
|
"+": (...t) => t.reduce((e, r) => g(e) + g(r), 0),
|
|
@@ -86,17 +87,17 @@ const Bt = {
|
|
|
86
87
|
if (n === "" || n === ".")
|
|
87
88
|
return this;
|
|
88
89
|
const s = n.split(".");
|
|
89
|
-
let
|
|
90
|
+
let a = this;
|
|
90
91
|
for (const o of s) {
|
|
91
|
-
if (
|
|
92
|
+
if (a == null)
|
|
92
93
|
return r;
|
|
93
|
-
if (Array.isArray(
|
|
94
|
+
if (Array.isArray(a)) {
|
|
94
95
|
const u = parseInt(o, 10);
|
|
95
|
-
isNaN(u) ?
|
|
96
|
+
isNaN(u) ? a = a[o] : a = a[u];
|
|
96
97
|
} else
|
|
97
|
-
|
|
98
|
+
a = a[o];
|
|
98
99
|
}
|
|
99
|
-
return
|
|
100
|
+
return a !== void 0 ? a : r;
|
|
100
101
|
},
|
|
101
102
|
async missing(...t) {
|
|
102
103
|
const e = N(t[0]) ? t[0] : t, r = [];
|
|
@@ -109,8 +110,8 @@ const Bt = {
|
|
|
109
110
|
async missing_some(t, e) {
|
|
110
111
|
const r = await p({ missing: e }, this);
|
|
111
112
|
if (!N(r) || !N(e)) return [];
|
|
112
|
-
const n = r.filter(
|
|
113
|
-
return e.filter(
|
|
113
|
+
const n = r.filter(U);
|
|
114
|
+
return e.filter(U).length - n.length >= g(t) ? [] : n;
|
|
114
115
|
},
|
|
115
116
|
/**
|
|
116
117
|
* Invoke operator - executes a function with optional arguments
|
|
@@ -131,10 +132,10 @@ const Bt = {
|
|
|
131
132
|
regexp_matches(t, e) {
|
|
132
133
|
let r = t, n = "";
|
|
133
134
|
if (N(t)) {
|
|
134
|
-
const [
|
|
135
|
-
r =
|
|
135
|
+
const [a, o] = t;
|
|
136
|
+
r = a, n = o;
|
|
136
137
|
}
|
|
137
|
-
return !
|
|
138
|
+
return !U(r) || !U(n) ? !1 : new RegExp(r, n).test(P(e));
|
|
138
139
|
},
|
|
139
140
|
throw(t) {
|
|
140
141
|
throw new Error(P(t));
|
|
@@ -142,12 +143,12 @@ const Bt = {
|
|
|
142
143
|
};
|
|
143
144
|
async function p(t, e) {
|
|
144
145
|
if (!t) return t;
|
|
145
|
-
if (
|
|
146
|
+
if (St(t))
|
|
146
147
|
return p(await t, e);
|
|
147
148
|
if (N(t))
|
|
148
149
|
return Promise.all(t.map((o) => p(o, e)));
|
|
149
|
-
if (!
|
|
150
|
-
const r =
|
|
150
|
+
if (!ft(t)) return t;
|
|
151
|
+
const r = $t(t);
|
|
151
152
|
let n = r ? t[r] ?? [] : [];
|
|
152
153
|
switch (N(n) || (n = [n]), r) {
|
|
153
154
|
case "if":
|
|
@@ -177,8 +178,8 @@ async function p(t, e) {
|
|
|
177
178
|
const o = await p(n[0], e);
|
|
178
179
|
return N(o) ? (await Promise.all(
|
|
179
180
|
o.map(async (d) => {
|
|
180
|
-
const
|
|
181
|
-
return { item: d, shouldInclude:
|
|
181
|
+
const h = await v(await p(n[1], d));
|
|
182
|
+
return { item: d, shouldInclude: h };
|
|
182
183
|
})
|
|
183
184
|
)).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
|
|
184
185
|
}
|
|
@@ -187,10 +188,10 @@ async function p(t, e) {
|
|
|
187
188
|
if (!N(o))
|
|
188
189
|
return n.length > 2 ? await p(n[2], e) : null;
|
|
189
190
|
const u = n[1];
|
|
190
|
-
let
|
|
191
|
+
let h = n.length > 2 ? await p(n[2], e) : null;
|
|
191
192
|
for (const b of o)
|
|
192
|
-
|
|
193
|
-
return
|
|
193
|
+
h = await p(u, { current: b, accumulator: h });
|
|
194
|
+
return h;
|
|
194
195
|
}
|
|
195
196
|
case "all": {
|
|
196
197
|
const o = await p(n[0], e);
|
|
@@ -217,31 +218,31 @@ async function p(t, e) {
|
|
|
217
218
|
try {
|
|
218
219
|
return await p(n[0], e);
|
|
219
220
|
} catch (o) {
|
|
220
|
-
return
|
|
221
|
+
return ft(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
|
-
const s = await Promise.all(n.map((o) => p(o, e))),
|
|
224
|
-
if (!
|
|
225
|
-
return
|
|
224
|
+
const s = await Promise.all(n.map((o) => p(o, e))), a = r ? _t[r] : void 0;
|
|
225
|
+
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
226
|
+
return a.apply(e, s);
|
|
226
227
|
}
|
|
227
228
|
async function v(t) {
|
|
228
|
-
return
|
|
229
|
+
return St(t) ? v(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function $t(t) {
|
|
231
232
|
return Object.keys(t)[0];
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
-
return !
|
|
234
|
+
function Mt(t) {
|
|
235
|
+
return !Ft(t);
|
|
235
236
|
}
|
|
236
|
-
async function
|
|
237
|
+
async function lt(t, e, r) {
|
|
237
238
|
const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((u, d) => ({
|
|
238
239
|
...u,
|
|
239
|
-
[d.name]: (...
|
|
240
|
-
}), {}),
|
|
240
|
+
[d.name]: (...h) => d.predicate({ ...n, args: h })
|
|
241
|
+
}), {}), a = t.features.listStore.getState().reduce((u, d) => ({
|
|
241
242
|
...u,
|
|
242
243
|
[d.id]: async () => {
|
|
243
|
-
const { bucket:
|
|
244
|
-
return
|
|
244
|
+
const { bucket: h } = await d.getBucket();
|
|
245
|
+
return h;
|
|
245
246
|
}
|
|
246
247
|
}), {}), o = {
|
|
247
248
|
...r,
|
|
@@ -258,48 +259,48 @@ async function ct(t, e, r) {
|
|
|
258
259
|
search: n.location.search
|
|
259
260
|
} : void 0,
|
|
260
261
|
predicates: s,
|
|
261
|
-
features:
|
|
262
|
+
features: a
|
|
262
263
|
};
|
|
263
264
|
return await p(e, o);
|
|
264
265
|
}
|
|
265
|
-
function
|
|
266
|
-
return !
|
|
266
|
+
function Tt(t) {
|
|
267
|
+
return !At() || !mt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
267
268
|
(e) => e instanceof HTMLElement
|
|
268
269
|
);
|
|
269
270
|
}
|
|
270
|
-
const
|
|
271
|
-
function
|
|
272
|
-
if (!
|
|
271
|
+
const Lt = "open";
|
|
272
|
+
function Dt(t) {
|
|
273
|
+
if (!Ot())
|
|
273
274
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
274
|
-
return t.attachShadow({ mode:
|
|
275
|
+
return t.attachShadow({ mode: Lt });
|
|
275
276
|
}
|
|
276
|
-
function
|
|
277
|
+
function ne() {
|
|
277
278
|
return new Promise((t, e) => {
|
|
278
|
-
if (!
|
|
279
|
+
if (!mt()) {
|
|
279
280
|
e();
|
|
280
281
|
return;
|
|
281
282
|
}
|
|
282
283
|
document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
|
|
283
284
|
});
|
|
284
285
|
}
|
|
285
|
-
function
|
|
286
|
+
function Rt(t, e) {
|
|
286
287
|
const r = new MutationObserver((n) => {
|
|
287
288
|
document.contains(t) || (r.disconnect(), e());
|
|
288
289
|
});
|
|
289
290
|
r.observe(document.body, { childList: !0, subtree: !0 });
|
|
290
291
|
}
|
|
291
|
-
const G = "picked-root", V = "picked-target",
|
|
292
|
-
function
|
|
292
|
+
const G = "picked-root", V = "picked-target", Pt = "picked-root";
|
|
293
|
+
function re(t, e) {
|
|
293
294
|
return [
|
|
294
295
|
...t,
|
|
295
296
|
// Target and replace picked-root web components
|
|
296
297
|
{
|
|
297
|
-
selector: `${
|
|
298
|
+
selector: `${Pt}[experience-id="${e}"]`,
|
|
298
299
|
placement: "replace"
|
|
299
300
|
}
|
|
300
301
|
].flatMap((n) => {
|
|
301
|
-
const s =
|
|
302
|
-
(
|
|
302
|
+
const s = Tt(n.selector).filter(
|
|
303
|
+
(a) => !Ct(a, e) && !Ht(a, e)
|
|
303
304
|
);
|
|
304
305
|
return {
|
|
305
306
|
...n,
|
|
@@ -307,25 +308,25 @@ function ee(t, e) {
|
|
|
307
308
|
};
|
|
308
309
|
});
|
|
309
310
|
}
|
|
310
|
-
function
|
|
311
|
-
return t.flatMap((r) => r.elements.map((n) =>
|
|
311
|
+
function oe(t, e) {
|
|
312
|
+
return t.flatMap((r) => r.elements.map((n) => Ut(n, r.placement, e)));
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
+
function ie(t, e) {
|
|
314
315
|
t.classList.add(V), t.classList.add(`${V}-${e}`);
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
+
function Ct(t, e) {
|
|
317
318
|
return e ? t.classList.contains(`${V}-${e}`) : t.classList.contains(`${V}`);
|
|
318
319
|
}
|
|
319
|
-
function
|
|
320
|
+
function Ht(t, e) {
|
|
320
321
|
return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(G);
|
|
321
322
|
}
|
|
322
|
-
function
|
|
323
|
+
function jt(t) {
|
|
323
324
|
const e = document.createElement("div");
|
|
324
325
|
return e.style.display = "block", e.classList.add(G), e.classList.add(`${G}-${t}`), e;
|
|
325
326
|
}
|
|
326
|
-
function
|
|
327
|
+
function Ut(t, e, r) {
|
|
327
328
|
let n;
|
|
328
|
-
const s =
|
|
329
|
+
const s = jt(r);
|
|
329
330
|
if (t instanceof Document)
|
|
330
331
|
n = t.body.appendChild(s);
|
|
331
332
|
else {
|
|
@@ -350,204 +351,189 @@ function jt(t, e, r) {
|
|
|
350
351
|
}
|
|
351
352
|
return n;
|
|
352
353
|
}
|
|
353
|
-
|
|
354
|
-
return t.type === "conditional";
|
|
355
|
-
}
|
|
356
|
-
function C(t) {
|
|
357
|
-
return t.type === "step";
|
|
358
|
-
}
|
|
359
|
-
function ut(t) {
|
|
360
|
-
return t.type === "experience";
|
|
361
|
-
}
|
|
362
|
-
function Y(t) {
|
|
363
|
-
return t.type === "origin";
|
|
364
|
-
}
|
|
365
|
-
function ft(t) {
|
|
366
|
-
return t.type === "action";
|
|
367
|
-
}
|
|
368
|
-
const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), C(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
354
|
+
const ht = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), C(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
369
355
|
const u = t.find((d) => d.id === o.destinationNodeId);
|
|
370
|
-
return u ?
|
|
371
|
-
})), Kt = (t, e, r) =>
|
|
356
|
+
return u ? ht(t, e, u, !1, s) : [];
|
|
357
|
+
})), Kt = (t, e, r) => ht(t, e, r, !0, /* @__PURE__ */ new Set()), yt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
|
|
372
358
|
if (s.has(r.id)) return [-1, -1];
|
|
373
359
|
s.add(r.id);
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
360
|
+
const a = e.filter((d) => d.sourceNodeId === r.id);
|
|
361
|
+
if (a.length === 0) return [0, 0];
|
|
376
362
|
let o = 1 / 0, u = -1 / 0;
|
|
377
|
-
for (const d of
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
363
|
+
for (const d of a) {
|
|
364
|
+
const h = t.find((T) => T.id === d.destinationNodeId);
|
|
365
|
+
if (!h) continue;
|
|
380
366
|
const [b, F] = yt(
|
|
381
367
|
t,
|
|
382
368
|
e,
|
|
383
|
-
|
|
369
|
+
h,
|
|
384
370
|
!1,
|
|
385
371
|
new Set(s)
|
|
386
372
|
);
|
|
387
373
|
b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u, F + 1));
|
|
388
374
|
}
|
|
389
375
|
return o === 1 / 0 ? [-1, -1] : [o, u];
|
|
390
|
-
},
|
|
376
|
+
}, Wt = (t, e, r) => yt(t, e, r, !0, /* @__PURE__ */ new Set()), wt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
391
377
|
if (n.has(r.id)) return [-1, -1];
|
|
392
378
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
393
379
|
const s = e.filter((u) => u.destinationNodeId === r.id);
|
|
394
380
|
if (s.length === 0) return [-1, -1];
|
|
395
|
-
let
|
|
381
|
+
let a = 1 / 0, o = -1 / 0;
|
|
396
382
|
for (const u of s) {
|
|
397
383
|
const d = t.find((F) => F.id === u.sourceNodeId);
|
|
398
384
|
if (!d) continue;
|
|
399
|
-
const [
|
|
385
|
+
const [h, b] = wt(
|
|
400
386
|
t,
|
|
401
387
|
e,
|
|
402
388
|
d,
|
|
403
389
|
new Set(n)
|
|
404
390
|
);
|
|
405
|
-
|
|
391
|
+
h !== -1 && (a = Math.min(a, h + 1), o = Math.max(o, b + 1));
|
|
406
392
|
}
|
|
407
|
-
return
|
|
408
|
-
},
|
|
393
|
+
return a === 1 / 0 ? [-1, -1] : [a, o];
|
|
394
|
+
}, Gt = (t, e, r) => wt(t, e, r, /* @__PURE__ */ new Set()), xt = (t) => t.find((r) => r.type === "origin") || null, tt = (t, e, r) => {
|
|
409
395
|
if (!t)
|
|
410
|
-
return
|
|
411
|
-
const n = r.find((
|
|
396
|
+
return xt(e);
|
|
397
|
+
const n = r.find((a) => a.sourceNodeId === t.id);
|
|
412
398
|
if (!n)
|
|
413
399
|
return null;
|
|
414
|
-
const s = e.find((
|
|
400
|
+
const s = e.find((a) => a.id === n.destinationNodeId);
|
|
415
401
|
return s || null;
|
|
416
402
|
};
|
|
417
|
-
async function
|
|
418
|
-
const s = t ? "true" : "false",
|
|
403
|
+
async function Vt(t, e, r, n) {
|
|
404
|
+
const s = t ? "true" : "false", a = n.find(
|
|
419
405
|
(o) => o.sourceNodeHandle === s && o.sourceNodeId === e
|
|
420
406
|
);
|
|
421
|
-
return r.find((o) => o.id ===
|
|
407
|
+
return r.find((o) => o.id === a?.destinationNodeId);
|
|
422
408
|
}
|
|
423
|
-
const
|
|
409
|
+
const et = bt("experience-instance"), qt = pt(
|
|
424
410
|
({
|
|
425
411
|
client: t,
|
|
426
412
|
experience: e,
|
|
427
413
|
target: r,
|
|
428
414
|
options: n
|
|
429
415
|
}) => {
|
|
430
|
-
const s = I(),
|
|
416
|
+
const s = I(), a = I(), o = I(), u = I(), d = I(), h = I(), b = e.componentStore, F = et.store("transitioning"), T = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), K = T.map((i) => i.filter((l) => C(l.node))), c = T.map((i) => i.at(-1)?.node || null), S = R(
|
|
431
417
|
t.steps.listStore,
|
|
432
|
-
|
|
433
|
-
(i, l) => i.find((f) => l && C(l) && f.key === l
|
|
418
|
+
c,
|
|
419
|
+
(i, l) => i.find((f) => l && C(l) && f.key === Y(l)) || null
|
|
434
420
|
), x = R(
|
|
435
421
|
t.steps.listStore,
|
|
436
|
-
|
|
422
|
+
K,
|
|
437
423
|
(i, l) => {
|
|
438
424
|
const f = l.at(-2);
|
|
439
425
|
if (!f || !C(f.node))
|
|
440
426
|
return null;
|
|
441
|
-
const
|
|
442
|
-
return i.find((B) => B.key ===
|
|
427
|
+
const y = f.node;
|
|
428
|
+
return i.find((B) => B.key === Y(y)) || null;
|
|
443
429
|
}
|
|
444
430
|
), L = R(
|
|
445
431
|
e.treeStore,
|
|
446
|
-
|
|
432
|
+
c,
|
|
447
433
|
({ nodes: i, edges: l }, f) => f ? Kt(i, l, f) : []
|
|
448
434
|
), H = R(
|
|
449
435
|
e.treeStore,
|
|
450
|
-
|
|
451
|
-
({ nodes: i, edges: l }, f) => f ?
|
|
436
|
+
c,
|
|
437
|
+
({ nodes: i, edges: l }, f) => f ? Gt(i, l, f) : [-1, -1]
|
|
452
438
|
), q = R(
|
|
453
439
|
e.treeStore,
|
|
454
|
-
|
|
455
|
-
({ nodes: i, edges: l }, f) => f ?
|
|
456
|
-
), D =
|
|
440
|
+
c,
|
|
441
|
+
({ nodes: i, edges: l }, f) => f ? Wt(i, l, f) : [-1, -1]
|
|
442
|
+
), D = et.store(!1), W = dt(D, {
|
|
457
443
|
open: () => !0,
|
|
458
444
|
close: () => !1,
|
|
459
445
|
toggle: (i) => !i,
|
|
460
446
|
set: (i, l) => l
|
|
461
|
-
}),
|
|
447
|
+
}), Nt = $(async () => {
|
|
462
448
|
t.history.back({ experienceId: e.id });
|
|
463
|
-
}),
|
|
449
|
+
}), Et = O({
|
|
464
450
|
source: e.treeStore,
|
|
465
451
|
effect: async (i, l) => {
|
|
466
|
-
const f = i.nodes.find((
|
|
452
|
+
const f = i.nodes.find((y) => C(y) && Y(y) === l);
|
|
467
453
|
f && t.history.push({ experienceId: e.id, node: f });
|
|
468
454
|
}
|
|
469
|
-
}),
|
|
470
|
-
source:
|
|
455
|
+
}), nt = O({
|
|
456
|
+
source: c,
|
|
471
457
|
effect: (i) => {
|
|
472
458
|
}
|
|
473
459
|
}), z = O({
|
|
474
460
|
source: e.treeStore,
|
|
475
|
-
effect: async ({ nodes: i }) =>
|
|
461
|
+
effect: async ({ nodes: i }) => xt(i)
|
|
476
462
|
}), X = O({
|
|
477
463
|
source: e.treeStore,
|
|
478
464
|
effect: async ({ nodes: i, edges: l }, f) => {
|
|
479
|
-
if (
|
|
480
|
-
return
|
|
465
|
+
if (Z(f))
|
|
466
|
+
return tt(f, i, l);
|
|
481
467
|
}
|
|
482
468
|
}), J = O({
|
|
483
469
|
source: e.treeStore,
|
|
484
|
-
effect: async ({ nodes: i, edges: l, conditions: f },
|
|
485
|
-
if (!at(
|
|
470
|
+
effect: async ({ nodes: i, edges: l, conditions: f }, y) => {
|
|
471
|
+
if (!at(y))
|
|
486
472
|
return;
|
|
487
|
-
const B =
|
|
473
|
+
const B = y.conditionId ?? y.conditionalId, w = t.conditions.listStore.getState().find((_) => _.id === B)?.condition ?? f.find((_) => _.id === B)?.condition;
|
|
488
474
|
if (!w)
|
|
489
475
|
return;
|
|
490
|
-
const A = await
|
|
491
|
-
return
|
|
476
|
+
const A = await lt(t, w);
|
|
477
|
+
return Vt(!!A, y.id, i, l);
|
|
492
478
|
}
|
|
493
|
-
}),
|
|
479
|
+
}), rt = O({
|
|
494
480
|
source: e.treeStore,
|
|
495
481
|
effect: async ({ nodes: i, edges: l }, f) => {
|
|
496
|
-
if (!
|
|
482
|
+
if (!ct(f))
|
|
497
483
|
return;
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
484
|
+
const y = f.action;
|
|
485
|
+
if (!y) {
|
|
500
486
|
E("warn", `Action node ${f.id} has no action name`);
|
|
501
487
|
return;
|
|
502
488
|
}
|
|
503
|
-
const B = t.actions.getByName(
|
|
489
|
+
const B = t.actions.getByName(y).getState();
|
|
504
490
|
if (!B) {
|
|
505
|
-
E("warn", `Action '${
|
|
491
|
+
E("warn", `Action '${y}' not registered on client`);
|
|
506
492
|
const k = l.find(
|
|
507
493
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
508
494
|
);
|
|
509
495
|
return k ? i.find((w) => w.id === k.destinationNodeId) : null;
|
|
510
496
|
}
|
|
511
497
|
if (typeof B.action != "function") {
|
|
512
|
-
E("warn", `Action '${
|
|
498
|
+
E("warn", `Action '${y}' is not a function`);
|
|
513
499
|
const k = l.find(
|
|
514
500
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
515
501
|
);
|
|
516
502
|
return k ? i.find((w) => w.id === k.destinationNodeId) : null;
|
|
517
503
|
}
|
|
518
504
|
try {
|
|
519
|
-
E("info", `Executing action: ${
|
|
505
|
+
E("info", `Executing action: ${y}`), await B.action(y);
|
|
520
506
|
const k = l.find(
|
|
521
507
|
(A) => A.sourceNodeId === f.id && A.sourceNodeHandle === "true"
|
|
522
508
|
);
|
|
523
509
|
if (!k)
|
|
524
510
|
return E("warn", `No 'true' edge found for action node ${f.id}`), null;
|
|
525
511
|
const w = i.find((A) => A.id === k.destinationNodeId);
|
|
526
|
-
return E("info", `Action '${
|
|
512
|
+
return E("info", `Action '${y}' succeeded, moving to node ${w?.id}`), w || null;
|
|
527
513
|
} catch (k) {
|
|
528
|
-
E("warn", `Action '${
|
|
514
|
+
E("warn", `Action '${y}' failed:`, k);
|
|
529
515
|
const w = l.find(
|
|
530
516
|
(_) => _.sourceNodeId === f.id && _.sourceNodeHandle === "false"
|
|
531
517
|
);
|
|
532
518
|
if (!w)
|
|
533
519
|
return E("warn", `No 'false' edge found for action node ${f.id}`), null;
|
|
534
520
|
const A = i.find((_) => _.id === w.destinationNodeId);
|
|
535
|
-
return E("info", `Action '${
|
|
521
|
+
return E("info", `Action '${y}' failed, moving to node ${A?.id}`), A || null;
|
|
536
522
|
}
|
|
537
523
|
}
|
|
538
|
-
}),
|
|
524
|
+
}), It = $((i) => {
|
|
539
525
|
ut(i) && t.experiences.launch({ id: i.experienceId });
|
|
540
|
-
}),
|
|
541
|
-
source: [
|
|
542
|
-
effect: async ([i, { nodes: l, edges: f }]) =>
|
|
526
|
+
}), ot = O({
|
|
527
|
+
source: [c, e.treeStore],
|
|
528
|
+
effect: async ([i, { nodes: l, edges: f }]) => tt(i, l, f)
|
|
543
529
|
}), j = O({
|
|
544
|
-
source: [
|
|
545
|
-
effect: async ([i, { nodes: l, edges: f }]) =>
|
|
546
|
-
}),
|
|
530
|
+
source: [c, e.treeStore],
|
|
531
|
+
effect: async ([i, { nodes: l, edges: f }]) => tt(i, l, f)
|
|
532
|
+
}), kt = $((i) => {
|
|
547
533
|
t.history.push({ experienceId: e.id, node: i });
|
|
548
|
-
}),
|
|
534
|
+
}), it = O({
|
|
549
535
|
source: e.configStore,
|
|
550
|
-
effect: async ({ initializeOpenLogic: i }) => n?.initialiseOpen !== void 0 ? n.initialiseOpen :
|
|
536
|
+
effect: async ({ initializeOpenLogic: i }) => n?.initialiseOpen !== void 0 ? n.initialiseOpen : Mt(i) ? !!await lt(t, i) : i ?? !1
|
|
551
537
|
}), M = Object.freeze({
|
|
552
538
|
// eslint-disable-next-line sonarjs/pseudo-random -- instance ID is non-security-sensitive
|
|
553
539
|
id: Math.random().toString(36).substring(7),
|
|
@@ -566,20 +552,20 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
566
552
|
setOpen: W.set,
|
|
567
553
|
// nodes
|
|
568
554
|
treeStore: e.treeStore,
|
|
569
|
-
currentNodeStore:
|
|
555
|
+
currentNodeStore: c,
|
|
570
556
|
currentStepStore: S,
|
|
571
557
|
previousStepStore: x,
|
|
572
558
|
nextReachableStepNodesStore: L,
|
|
573
559
|
stepsToOriginStore: H,
|
|
574
560
|
stepsToLeafStore: q,
|
|
575
561
|
// history
|
|
576
|
-
goToNextStep:
|
|
562
|
+
goToNextStep: a,
|
|
577
563
|
goToPreviousStep: o,
|
|
578
564
|
goToStepById: u,
|
|
579
|
-
stepsHistoryStore:
|
|
580
|
-
}), Q = I(),
|
|
565
|
+
stepsHistoryStore: K
|
|
566
|
+
}), Q = I(), st = I();
|
|
581
567
|
return m({
|
|
582
|
-
source:
|
|
568
|
+
source: c,
|
|
583
569
|
target: Q
|
|
584
570
|
}), m({
|
|
585
571
|
clock: Q,
|
|
@@ -588,16 +574,16 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
588
574
|
}), m({
|
|
589
575
|
clock: Q,
|
|
590
576
|
filter: (i) => i !== null,
|
|
591
|
-
target:
|
|
592
|
-
}),
|
|
593
|
-
source:
|
|
594
|
-
match: (i) => at(i) ? "condition" : C(i) ? "step" : ut(i) ? "launchExperience" :
|
|
577
|
+
target: st
|
|
578
|
+
}), vt({
|
|
579
|
+
source: st,
|
|
580
|
+
match: (i) => at(i) ? "condition" : C(i) ? "step" : ut(i) ? "launchExperience" : Z(i) ? "origin" : ct(i) ? "action" : "other",
|
|
595
581
|
cases: {
|
|
596
582
|
origin: X,
|
|
597
583
|
condition: J,
|
|
598
|
-
step:
|
|
599
|
-
launchExperience:
|
|
600
|
-
action:
|
|
584
|
+
step: nt,
|
|
585
|
+
launchExperience: It,
|
|
586
|
+
action: rt,
|
|
601
587
|
__: I()
|
|
602
588
|
}
|
|
603
589
|
}), m({
|
|
@@ -606,16 +592,16 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
606
592
|
X.doneData,
|
|
607
593
|
z.doneData,
|
|
608
594
|
j.doneData,
|
|
609
|
-
|
|
610
|
-
|
|
595
|
+
ot.doneData,
|
|
596
|
+
rt.doneData
|
|
611
597
|
],
|
|
612
598
|
filter: Boolean,
|
|
613
|
-
target:
|
|
599
|
+
target: kt
|
|
614
600
|
}), m({
|
|
615
|
-
clock:
|
|
601
|
+
clock: a,
|
|
616
602
|
target: j
|
|
617
603
|
}), m({
|
|
618
|
-
clock:
|
|
604
|
+
clock: a,
|
|
619
605
|
source: S,
|
|
620
606
|
filter: Boolean,
|
|
621
607
|
target: t.eventBus.prepend((i) => ({
|
|
@@ -643,8 +629,8 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
643
629
|
}))
|
|
644
630
|
}), m({
|
|
645
631
|
clock: o,
|
|
646
|
-
target:
|
|
647
|
-
}), m({ clock: u, target:
|
|
632
|
+
target: Nt
|
|
633
|
+
}), m({ clock: u, target: Et }), m({
|
|
648
634
|
source: R([
|
|
649
635
|
J.pending,
|
|
650
636
|
X.pending,
|
|
@@ -654,7 +640,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
654
640
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
655
641
|
target: F
|
|
656
642
|
}), m({
|
|
657
|
-
clock:
|
|
643
|
+
clock: nt.doneData,
|
|
658
644
|
source: S,
|
|
659
645
|
filter: Boolean,
|
|
660
646
|
target: t.eventBus.prepend((i) => ({
|
|
@@ -663,17 +649,17 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
663
649
|
experience: M
|
|
664
650
|
}))
|
|
665
651
|
}), m({
|
|
666
|
-
clock:
|
|
667
|
-
target:
|
|
652
|
+
clock: h,
|
|
653
|
+
target: it
|
|
668
654
|
}), m({
|
|
669
|
-
source:
|
|
655
|
+
source: it.doneData,
|
|
670
656
|
fn: Boolean,
|
|
671
657
|
target: D
|
|
672
658
|
}), m({
|
|
673
|
-
source:
|
|
659
|
+
source: c,
|
|
674
660
|
clock: s,
|
|
675
|
-
filter: (i) => i ?
|
|
676
|
-
target:
|
|
661
|
+
filter: (i) => i ? Z(i) : !0,
|
|
662
|
+
target: ot
|
|
677
663
|
}), m({
|
|
678
664
|
source: D,
|
|
679
665
|
filter: Boolean,
|
|
@@ -694,51 +680,51 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
694
680
|
}))
|
|
695
681
|
}), m({
|
|
696
682
|
clock: d,
|
|
697
|
-
target: [
|
|
683
|
+
target: [h]
|
|
698
684
|
}), d(), M;
|
|
699
685
|
}
|
|
700
686
|
);
|
|
701
|
-
function
|
|
702
|
-
return
|
|
687
|
+
function zt(t) {
|
|
688
|
+
return gt(qt, t);
|
|
703
689
|
}
|
|
704
|
-
const
|
|
705
|
-
const e =
|
|
706
|
-
register(
|
|
690
|
+
const Xt = pt(({ client: t }) => {
|
|
691
|
+
const e = et.store({}), r = I(), n = I(), s = I(), a = dt(e, {
|
|
692
|
+
register(c, S) {
|
|
707
693
|
const x = [
|
|
708
|
-
...
|
|
694
|
+
...c[S.experienceId] ?? []
|
|
709
695
|
];
|
|
710
696
|
return x.push(S), {
|
|
711
|
-
...
|
|
697
|
+
...c,
|
|
712
698
|
[S.experienceId]: x
|
|
713
699
|
};
|
|
714
700
|
},
|
|
715
|
-
unregister(
|
|
716
|
-
const x = S.experienceId, L =
|
|
701
|
+
unregister(c, S) {
|
|
702
|
+
const x = S.experienceId, L = c[x]?.filter(
|
|
717
703
|
(H) => H !== S
|
|
718
704
|
);
|
|
719
705
|
return {
|
|
720
|
-
...
|
|
706
|
+
...c,
|
|
721
707
|
[x]: L ?? []
|
|
722
708
|
};
|
|
723
709
|
}
|
|
724
710
|
}), o = $(
|
|
725
711
|
({
|
|
726
|
-
experience:
|
|
712
|
+
experience: c,
|
|
727
713
|
target: S,
|
|
728
714
|
options: x
|
|
729
|
-
}) =>
|
|
730
|
-
), u = $((
|
|
731
|
-
|
|
715
|
+
}) => zt({ client: t, experience: c, target: S, options: x })
|
|
716
|
+
), u = $((c) => {
|
|
717
|
+
a.register(c);
|
|
732
718
|
}), d = $(
|
|
733
|
-
(
|
|
734
|
-
|
|
735
|
-
s(
|
|
719
|
+
(c) => {
|
|
720
|
+
c.target && Rt(c.target, () => {
|
|
721
|
+
s(c);
|
|
736
722
|
});
|
|
737
723
|
}
|
|
738
|
-
),
|
|
739
|
-
|
|
740
|
-
}), b = $((
|
|
741
|
-
const S =
|
|
724
|
+
), h = $((c) => {
|
|
725
|
+
a.unregister(c);
|
|
726
|
+
}), b = $((c) => {
|
|
727
|
+
const S = c.componentStore.getState();
|
|
742
728
|
if (!S) {
|
|
743
729
|
E("warn", "No app component registered. Skipping init.");
|
|
744
730
|
return;
|
|
@@ -751,17 +737,17 @@ const zt = dt(({ client: t }) => {
|
|
|
751
737
|
);
|
|
752
738
|
return;
|
|
753
739
|
}
|
|
754
|
-
const L =
|
|
740
|
+
const L = c.target;
|
|
755
741
|
if (!L) {
|
|
756
742
|
E(
|
|
757
743
|
"error",
|
|
758
|
-
`No target element registered for experience '${
|
|
744
|
+
`No target element registered for experience '${c.experienceId}'. Skipping rendering.`
|
|
759
745
|
);
|
|
760
746
|
return;
|
|
761
747
|
}
|
|
762
|
-
const H =
|
|
748
|
+
const H = Dt(L);
|
|
763
749
|
try {
|
|
764
|
-
x.render(H, S.component, t,
|
|
750
|
+
x.render(H, S.component, t, c);
|
|
765
751
|
} catch (q) {
|
|
766
752
|
E("error", q);
|
|
767
753
|
}
|
|
@@ -771,7 +757,7 @@ const zt = dt(({ client: t }) => {
|
|
|
771
757
|
target: o
|
|
772
758
|
}), m({
|
|
773
759
|
clock: s,
|
|
774
|
-
target:
|
|
760
|
+
target: h
|
|
775
761
|
}), m({
|
|
776
762
|
clock: o.doneData,
|
|
777
763
|
target: [
|
|
@@ -781,39 +767,38 @@ const zt = dt(({ client: t }) => {
|
|
|
781
767
|
]
|
|
782
768
|
}), m({
|
|
783
769
|
clock: o.doneData,
|
|
784
|
-
target: t.eventBus.prepend((
|
|
770
|
+
target: t.eventBus.prepend((c) => ({
|
|
785
771
|
type: "experience_initialize",
|
|
786
|
-
experience:
|
|
772
|
+
experience: c
|
|
787
773
|
}))
|
|
788
774
|
}), m({
|
|
789
775
|
clock: n,
|
|
790
776
|
target: b
|
|
791
777
|
});
|
|
792
|
-
function F(
|
|
793
|
-
r({ experience:
|
|
778
|
+
function F(c, S, x) {
|
|
779
|
+
r({ experience: c, target: S, options: x });
|
|
794
780
|
}
|
|
795
|
-
const T = e.map((
|
|
796
|
-
function
|
|
797
|
-
return e.map((S) => S[
|
|
781
|
+
const T = e.map((c) => Object.values(c).flat());
|
|
782
|
+
function K(c) {
|
|
783
|
+
return e.map((S) => S[c] || [], { skipVoid: !1 });
|
|
798
784
|
}
|
|
799
785
|
return {
|
|
800
786
|
spawn: F,
|
|
801
|
-
getByExperienceId:
|
|
787
|
+
getByExperienceId: K,
|
|
802
788
|
listStore: T
|
|
803
789
|
};
|
|
804
790
|
});
|
|
805
|
-
function
|
|
806
|
-
return
|
|
791
|
+
function se(t) {
|
|
792
|
+
return gt(Xt, t);
|
|
807
793
|
}
|
|
808
794
|
export {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
re as t
|
|
795
|
+
se as a,
|
|
796
|
+
Ht as b,
|
|
797
|
+
oe as c,
|
|
798
|
+
ne as d,
|
|
799
|
+
lt as e,
|
|
800
|
+
zt as f,
|
|
801
|
+
re as g,
|
|
802
|
+
Mt as i,
|
|
803
|
+
ie as t
|
|
819
804
|
};
|