@picked/client 0.0.31 → 0.0.32-next.2
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/responses-browser-storage/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +582 -518
- package/dist/esm/plugins/responses-browser-storage/index.js +23 -22
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-C4INDX6a.js → experience-instance-Bg6BWuwI.js} +100 -88
- package/dist/experience-instance-DBi45xr9.cjs +1 -0
- package/dist/types/entities/action/action.d.ts +5 -3
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts +6 -3
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/predicate/predicate.d.ts +7 -6
- package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +4 -1
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +11 -7
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-DjjpHk0t.cjs +0 -1
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { createEffect as
|
|
2
|
-
import { c as
|
|
3
|
-
const p =
|
|
4
|
-
|
|
1
|
+
import { createEffect as u, attach as f, sample as c } from "effector";
|
|
2
|
+
import { c as g, l as S, s as b } from "../../../storage-BLmAhfhl.js";
|
|
3
|
+
const p = g("responses", "global"), d = (n, e) => {
|
|
4
|
+
const o = {};
|
|
5
|
+
return Object.entries(n).forEach(([t, a]) => {
|
|
6
|
+
var r;
|
|
7
|
+
const s = e.find((i) => i.id === t);
|
|
8
|
+
!((r = s == null ? void 0 : s.policies) != null && r.doNotStoreValue) && (o[t] = a);
|
|
9
|
+
}), o;
|
|
10
|
+
}, h = ({
|
|
11
|
+
storage: n = "local"
|
|
5
12
|
} = {}) => ({
|
|
6
13
|
name: "responses-browser-storage-plugin",
|
|
7
14
|
setup: (e) => {
|
|
8
|
-
const
|
|
9
|
-
const s =
|
|
15
|
+
const o = n === "local" ? S : b, t = u(async () => {
|
|
16
|
+
const s = o.get(p).json();
|
|
10
17
|
if (!s)
|
|
11
18
|
return null;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
}), f = m({
|
|
19
|
+
e.responses.register(s);
|
|
20
|
+
}), a = f({
|
|
16
21
|
source: {
|
|
17
22
|
responses: e.responses.getAllStore,
|
|
18
23
|
fields: e.fields.listStore
|
|
19
24
|
},
|
|
20
|
-
effect: ({ responses: s, fields:
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
var c;
|
|
24
|
-
const t = r.find((S) => S.id === a);
|
|
25
|
-
!((c = t == null ? void 0 : t.policies) != null && c.doNotStoreValue) && (o[a] = g);
|
|
26
|
-
}), n.set(p, o);
|
|
25
|
+
effect: ({ responses: s, fields: l }) => {
|
|
26
|
+
const r = d(s, l);
|
|
27
|
+
o.set(p, r);
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
+
c({
|
|
30
31
|
source: e.eventBus,
|
|
31
32
|
filter: (s) => s.type === "load",
|
|
32
|
-
target:
|
|
33
|
-
}),
|
|
33
|
+
target: t
|
|
34
|
+
}), c({
|
|
34
35
|
source: e.responses.getAllStore,
|
|
35
|
-
target:
|
|
36
|
+
target: a
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
export {
|
|
40
|
-
|
|
41
|
+
h as responsesBrowserStoragePlugin
|
|
41
42
|
};
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
|
|
2
|
-
import { h as F } from "../../experience-instance-
|
|
2
|
+
import { h as F } from "../../experience-instance-Bg6BWuwI.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createDomain as ht, createEvent as O, combine as C, createApi as ot, createEffect as M, attach as
|
|
1
|
+
import { createDomain as ht, createEvent as O, combine as C, createApi as ot, createEffect as M, attach as F, split as yt, sample as m } from "effector";
|
|
2
2
|
import { createFactory as it, invoke as st } from "@withease/factories";
|
|
3
3
|
import { i as wt, s as at, a as Nt } from "./supports-BjhuLJ8z.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
@@ -112,9 +112,21 @@ const Et = {
|
|
|
112
112
|
const n = r.filter(H);
|
|
113
113
|
return e.filter(H).length - n.length >= g(t) ? [] : n;
|
|
114
114
|
},
|
|
115
|
+
/**
|
|
116
|
+
* Invoke operator - executes a function with optional arguments
|
|
117
|
+
*
|
|
118
|
+
* Object format (no arguments):
|
|
119
|
+
* { "invoke": { "var": "functionName" } }
|
|
120
|
+
*
|
|
121
|
+
* Array format (with arguments):
|
|
122
|
+
* { "invoke": [{ "var": "functionName" }, arg1, arg2, ...] }
|
|
123
|
+
*
|
|
124
|
+
* Arguments are evaluated as JSONLogic expressions before being passed to the function.
|
|
125
|
+
*/
|
|
115
126
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
116
|
-
invoke(t) {
|
|
117
|
-
|
|
127
|
+
invoke(...t) {
|
|
128
|
+
const [e, ...r] = t;
|
|
129
|
+
return typeof e != "function" ? null : Reflect.apply(e, null, r);
|
|
118
130
|
},
|
|
119
131
|
regexp_matches(t, e) {
|
|
120
132
|
let r = t, n = "";
|
|
@@ -165,8 +177,8 @@ async function p(t, e) {
|
|
|
165
177
|
const o = await p(n[0], e);
|
|
166
178
|
return N(o) ? (await Promise.all(
|
|
167
179
|
o.map(async (d) => {
|
|
168
|
-
const
|
|
169
|
-
return { item: d, shouldInclude:
|
|
180
|
+
const S = await B(await p(n[1], d));
|
|
181
|
+
return { item: d, shouldInclude: S };
|
|
170
182
|
})
|
|
171
183
|
)).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
|
|
172
184
|
}
|
|
@@ -175,10 +187,10 @@ async function p(t, e) {
|
|
|
175
187
|
if (!N(o))
|
|
176
188
|
return n.length > 2 ? await p(n[2], e) : null;
|
|
177
189
|
const c = n[1];
|
|
178
|
-
let
|
|
190
|
+
let S = n.length > 2 ? await p(n[2], e) : null;
|
|
179
191
|
for (const k of o)
|
|
180
|
-
|
|
181
|
-
return
|
|
192
|
+
S = await p(c, { current: k, accumulator: S });
|
|
193
|
+
return S;
|
|
182
194
|
}
|
|
183
195
|
case "all": {
|
|
184
196
|
const o = await p(n[0], e);
|
|
@@ -224,12 +236,12 @@ function At(t) {
|
|
|
224
236
|
async function et(t, e, r) {
|
|
225
237
|
const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((c, d) => ({
|
|
226
238
|
...c,
|
|
227
|
-
[d.name]: () => d.predicate(n)
|
|
239
|
+
[d.name]: (...S) => d.predicate({ ...n, args: S })
|
|
228
240
|
}), {}), a = t.features.listStore.getState().reduce((c, d) => ({
|
|
229
241
|
...c,
|
|
230
242
|
[d.id]: async () => {
|
|
231
|
-
const { bucket:
|
|
232
|
-
return
|
|
243
|
+
const { bucket: S } = await d.getBucket();
|
|
244
|
+
return S;
|
|
233
245
|
}
|
|
234
246
|
}), {}), o = {
|
|
235
247
|
...r,
|
|
@@ -276,18 +288,18 @@ function Bt(t, e) {
|
|
|
276
288
|
});
|
|
277
289
|
r.observe(document.body, { childList: !0, subtree: !0 });
|
|
278
290
|
}
|
|
279
|
-
const G = "picked-root", K = "picked-target",
|
|
291
|
+
const G = "picked-root", K = "picked-target", Ft = "picked-root";
|
|
280
292
|
function Jt(t, e) {
|
|
281
293
|
return [
|
|
282
294
|
...t,
|
|
283
295
|
// Target and replace picked-root web components
|
|
284
296
|
{
|
|
285
|
-
selector: `${
|
|
297
|
+
selector: `${Ft}[experience-id="${e}"]`,
|
|
286
298
|
placement: "replace"
|
|
287
299
|
}
|
|
288
300
|
].flatMap((n) => {
|
|
289
301
|
const s = bt(n.selector).filter(
|
|
290
|
-
(a) =>
|
|
302
|
+
(a) => !_t(a, e) && !$t(a, e)
|
|
291
303
|
);
|
|
292
304
|
return {
|
|
293
305
|
...n,
|
|
@@ -301,10 +313,10 @@ function Qt(t, e) {
|
|
|
301
313
|
function Yt(t, e) {
|
|
302
314
|
t.classList.add(K), t.classList.add(`${K}-${e}`);
|
|
303
315
|
}
|
|
304
|
-
function
|
|
316
|
+
function _t(t, e) {
|
|
305
317
|
return e ? t.classList.contains(`${K}-${e}`) : t.classList.contains(`${K}`);
|
|
306
318
|
}
|
|
307
|
-
function
|
|
319
|
+
function $t(t, e) {
|
|
308
320
|
return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(G);
|
|
309
321
|
}
|
|
310
322
|
function Mt(t) {
|
|
@@ -356,41 +368,41 @@ function rt(t) {
|
|
|
356
368
|
const ut = (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) => {
|
|
357
369
|
const c = t.find((d) => d.id === o.destinationNodeId);
|
|
358
370
|
return c ? ut(t, e, c, !1, s) : [];
|
|
359
|
-
})),
|
|
371
|
+
})), Rt = (t, e, r) => ut(t, e, r, !0, /* @__PURE__ */ new Set()), ft = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
|
|
360
372
|
if (s.has(r.id)) return [-1, -1];
|
|
361
373
|
s.add(r.id);
|
|
362
374
|
const a = e.filter((d) => d.sourceNodeId === r.id);
|
|
363
375
|
if (a.length === 0) return [0, 0];
|
|
364
376
|
let o = 1 / 0, c = -1 / 0;
|
|
365
377
|
for (const d of a) {
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
const [k,
|
|
378
|
+
const S = t.find((R) => R.id === d.destinationNodeId);
|
|
379
|
+
if (!S) continue;
|
|
380
|
+
const [k, _] = ft(
|
|
369
381
|
t,
|
|
370
382
|
e,
|
|
371
|
-
|
|
383
|
+
S,
|
|
372
384
|
!1,
|
|
373
385
|
new Set(s)
|
|
374
386
|
);
|
|
375
|
-
k !== -1 && (o = Math.min(o, k + 1), c = Math.max(c,
|
|
387
|
+
k !== -1 && (o = Math.min(o, k + 1), c = Math.max(c, _ + 1));
|
|
376
388
|
}
|
|
377
389
|
return o === 1 / 0 ? [-1, -1] : [o, c];
|
|
378
|
-
},
|
|
390
|
+
}, Pt = (t, e, r) => ft(t, e, r, !0, /* @__PURE__ */ new Set()), lt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
379
391
|
if (n.has(r.id)) return [-1, -1];
|
|
380
392
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
381
393
|
const s = e.filter((c) => c.destinationNodeId === r.id);
|
|
382
394
|
if (s.length === 0) return [-1, -1];
|
|
383
395
|
let a = 1 / 0, o = -1 / 0;
|
|
384
396
|
for (const c of s) {
|
|
385
|
-
const d = t.find((
|
|
397
|
+
const d = t.find((_) => _.id === c.sourceNodeId);
|
|
386
398
|
if (!d) continue;
|
|
387
|
-
const [
|
|
399
|
+
const [S, k] = lt(
|
|
388
400
|
t,
|
|
389
401
|
e,
|
|
390
402
|
d,
|
|
391
403
|
new Set(n)
|
|
392
404
|
);
|
|
393
|
-
|
|
405
|
+
S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o, k + 1));
|
|
394
406
|
}
|
|
395
407
|
return a === 1 / 0 ? [-1, -1] : [a, o];
|
|
396
408
|
}, Ct = (t, e, r) => lt(t, e, r, /* @__PURE__ */ new Set()), dt = (t) => t.find((r) => r.type === "origin") || null, X = (t, e, r) => {
|
|
@@ -414,17 +426,17 @@ const z = ht("experience-instance"), jt = it(
|
|
|
414
426
|
experience: e,
|
|
415
427
|
target: r
|
|
416
428
|
}) => {
|
|
417
|
-
const n = O(), s = O(), a = O(), o = O(), c = O(), d = O(),
|
|
429
|
+
const n = O(), s = O(), a = O(), o = O(), c = O(), d = O(), S = e.componentStore, k = z.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((f) => f.experienceId === e.id)), R = _.map((i) => i.filter((f) => j(f.node))), x = _.map((i) => {
|
|
418
430
|
var f;
|
|
419
431
|
return ((f = i[i.length - 1]) == null ? void 0 : f.node) || null;
|
|
420
432
|
}), u = C(
|
|
421
433
|
e.treeStore,
|
|
422
434
|
x,
|
|
423
435
|
({ steps: i }, f) => i.find((l) => f && j(f) && l.id === f.stepId) || null
|
|
424
|
-
),
|
|
436
|
+
), h = C(
|
|
425
437
|
e.treeStore,
|
|
426
438
|
x,
|
|
427
|
-
({ nodes: i, edges: f }, l) => l ?
|
|
439
|
+
({ nodes: i, edges: f }, l) => l ? Rt(i, f, l) : []
|
|
428
440
|
), v = C(
|
|
429
441
|
e.treeStore,
|
|
430
442
|
x,
|
|
@@ -432,31 +444,31 @@ const z = ht("experience-instance"), jt = it(
|
|
|
432
444
|
), T = C(
|
|
433
445
|
e.treeStore,
|
|
434
446
|
x,
|
|
435
|
-
({ nodes: i, edges: f }, l) => l ?
|
|
436
|
-
), A = z.store(!1),
|
|
447
|
+
({ nodes: i, edges: f }, l) => l ? Pt(i, f, l) : [-1, -1]
|
|
448
|
+
), A = z.store(!1), $ = ot(A, {
|
|
437
449
|
open: () => !0,
|
|
438
450
|
close: () => !1,
|
|
439
451
|
toggle: (i) => !i,
|
|
440
452
|
set: (i, f) => f
|
|
441
453
|
}), pt = M(async () => {
|
|
442
454
|
t.history.back({ experienceId: e.id });
|
|
443
|
-
}), gt =
|
|
455
|
+
}), gt = F({
|
|
444
456
|
source: e.treeStore,
|
|
445
457
|
effect: async (i, f) => {
|
|
446
458
|
const l = i.nodes.find((w) => j(w) && w.stepId === f);
|
|
447
459
|
l && t.history.push({ experienceId: e.id, node: l });
|
|
448
460
|
}
|
|
449
|
-
}), J =
|
|
461
|
+
}), J = F({
|
|
450
462
|
source: x,
|
|
451
463
|
effect: (i) => {
|
|
452
464
|
}
|
|
453
|
-
}), U =
|
|
465
|
+
}), U = F({
|
|
454
466
|
source: e.treeStore,
|
|
455
467
|
effect: async ({ nodes: i }) => dt(i)
|
|
456
|
-
}), V =
|
|
468
|
+
}), V = F({
|
|
457
469
|
source: e.treeStore,
|
|
458
470
|
effect: async ({ nodes: i, edges: f }, l) => X(l, i, f)
|
|
459
|
-
}), q =
|
|
471
|
+
}), q = F({
|
|
460
472
|
source: e.treeStore,
|
|
461
473
|
effect: async ({ nodes: i, edges: f, conditionals: l }, w) => {
|
|
462
474
|
if (!w)
|
|
@@ -464,10 +476,10 @@ const z = ht("experience-instance"), jt = it(
|
|
|
464
476
|
const L = l.find((b) => b.id === w.conditionalId);
|
|
465
477
|
if (!L)
|
|
466
478
|
return;
|
|
467
|
-
const E = w.id,
|
|
468
|
-
return Ht(!!
|
|
479
|
+
const E = w.id, y = await et(t, L.condition);
|
|
480
|
+
return Ht(!!y, E, i, f);
|
|
469
481
|
}
|
|
470
|
-
}), Q =
|
|
482
|
+
}), Q = F({
|
|
471
483
|
source: e.treeStore,
|
|
472
484
|
effect: async ({ nodes: i, edges: f }, l) => {
|
|
473
485
|
if (!l || !rt(l))
|
|
@@ -481,49 +493,49 @@ const z = ht("experience-instance"), jt = it(
|
|
|
481
493
|
if (!L) {
|
|
482
494
|
I("warn", `Action '${w}' not registered on client`);
|
|
483
495
|
const E = f.find(
|
|
484
|
-
(
|
|
496
|
+
(y) => y.sourceNodeId === l.id && y.sourceNodeHandle === "false"
|
|
485
497
|
);
|
|
486
|
-
return E ? i.find((
|
|
498
|
+
return E ? i.find((y) => y.id === E.destinationNodeId) : null;
|
|
487
499
|
}
|
|
488
500
|
if (typeof L.action != "function") {
|
|
489
501
|
I("warn", `Action '${w}' is not a function`);
|
|
490
502
|
const E = f.find(
|
|
491
|
-
(
|
|
503
|
+
(y) => y.sourceNodeId === l.id && y.sourceNodeHandle === "false"
|
|
492
504
|
);
|
|
493
|
-
return E ? i.find((
|
|
505
|
+
return E ? i.find((y) => y.id === E.destinationNodeId) : null;
|
|
494
506
|
}
|
|
495
507
|
try {
|
|
496
|
-
I("info", `Executing action: ${w}`), await L.action();
|
|
508
|
+
I("info", `Executing action: ${w}`), await L.action(w);
|
|
497
509
|
const E = f.find(
|
|
498
510
|
(b) => b.sourceNodeId === l.id && b.sourceNodeHandle === "true"
|
|
499
511
|
);
|
|
500
512
|
if (!E)
|
|
501
513
|
return I("warn", `No 'true' edge found for action node ${l.id}`), null;
|
|
502
|
-
const
|
|
503
|
-
return I("info", `Action '${w}' succeeded, moving to node ${
|
|
514
|
+
const y = i.find((b) => b.id === E.destinationNodeId);
|
|
515
|
+
return I("info", `Action '${w}' succeeded, moving to node ${y == null ? void 0 : y.id}`), y || null;
|
|
504
516
|
} catch (E) {
|
|
505
517
|
I("warn", `Action '${w}' failed:`, E);
|
|
506
|
-
const
|
|
518
|
+
const y = f.find(
|
|
507
519
|
(W) => W.sourceNodeId === l.id && W.sourceNodeHandle === "false"
|
|
508
520
|
);
|
|
509
|
-
if (!
|
|
521
|
+
if (!y)
|
|
510
522
|
return I("warn", `No 'false' edge found for action node ${l.id}`), null;
|
|
511
|
-
const b = i.find((W) => W.id ===
|
|
523
|
+
const b = i.find((W) => W.id === y.destinationNodeId);
|
|
512
524
|
return I("info", `Action '${w}' failed, moving to node ${b == null ? void 0 : b.id}`), b || null;
|
|
513
525
|
}
|
|
514
526
|
}
|
|
515
527
|
}), mt = M((i) => {
|
|
516
528
|
if (i)
|
|
517
529
|
return t.launchExperienceById(i.experienceId);
|
|
518
|
-
}), Y =
|
|
530
|
+
}), Y = F({
|
|
519
531
|
source: [x, e.treeStore],
|
|
520
532
|
effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
|
|
521
|
-
}),
|
|
533
|
+
}), P = F({
|
|
522
534
|
source: [x, e.treeStore],
|
|
523
535
|
effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
|
|
524
536
|
}), St = M((i) => {
|
|
525
537
|
t.history.push({ experienceId: e.id, node: i });
|
|
526
|
-
}), Z =
|
|
538
|
+
}), Z = F({
|
|
527
539
|
source: e.configStore,
|
|
528
540
|
effect: async ({ initializeOpenLogic: i }) => At(i) ? !!await et(t, i) : i ?? !1
|
|
529
541
|
});
|
|
@@ -544,7 +556,7 @@ const z = ht("experience-instance"), jt = it(
|
|
|
544
556
|
q.doneData,
|
|
545
557
|
V.doneData,
|
|
546
558
|
U.doneData,
|
|
547
|
-
|
|
559
|
+
P.doneData,
|
|
548
560
|
Y.doneData,
|
|
549
561
|
Q.doneData
|
|
550
562
|
],
|
|
@@ -552,7 +564,7 @@ const z = ht("experience-instance"), jt = it(
|
|
|
552
564
|
target: St
|
|
553
565
|
}), m({
|
|
554
566
|
clock: s,
|
|
555
|
-
target:
|
|
567
|
+
target: P
|
|
556
568
|
}), m({
|
|
557
569
|
clock: s,
|
|
558
570
|
source: u,
|
|
@@ -563,7 +575,7 @@ const z = ht("experience-instance"), jt = it(
|
|
|
563
575
|
experience: e
|
|
564
576
|
}))
|
|
565
577
|
}), m({
|
|
566
|
-
clock:
|
|
578
|
+
clock: P.done,
|
|
567
579
|
source: u,
|
|
568
580
|
filter: Boolean,
|
|
569
581
|
target: t.eventBus.prepend((i) => ({
|
|
@@ -572,7 +584,7 @@ const z = ht("experience-instance"), jt = it(
|
|
|
572
584
|
experience: e
|
|
573
585
|
}))
|
|
574
586
|
}), m({
|
|
575
|
-
clock:
|
|
587
|
+
clock: P.fail,
|
|
576
588
|
source: u,
|
|
577
589
|
filter: Boolean,
|
|
578
590
|
target: t.eventBus.prepend((i) => ({
|
|
@@ -588,7 +600,7 @@ const z = ht("experience-instance"), jt = it(
|
|
|
588
600
|
q.pending,
|
|
589
601
|
V.pending,
|
|
590
602
|
U.pending,
|
|
591
|
-
|
|
603
|
+
P.pending
|
|
592
604
|
]),
|
|
593
605
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
594
606
|
target: k
|
|
@@ -640,27 +652,27 @@ const z = ht("experience-instance"), jt = it(
|
|
|
640
652
|
experienceId: e.id,
|
|
641
653
|
configStore: e.configStore,
|
|
642
654
|
target: r,
|
|
643
|
-
componentStore:
|
|
655
|
+
componentStore: S,
|
|
644
656
|
// state
|
|
645
657
|
stateStore: k,
|
|
646
658
|
// open close
|
|
647
659
|
isOpenStore: A,
|
|
648
|
-
open:
|
|
649
|
-
close:
|
|
650
|
-
toggleOpen:
|
|
651
|
-
setOpen:
|
|
660
|
+
open: $.open,
|
|
661
|
+
close: $.close,
|
|
662
|
+
toggleOpen: $.toggle,
|
|
663
|
+
setOpen: $.set,
|
|
652
664
|
// nodes
|
|
653
665
|
treeStore: e.treeStore,
|
|
654
666
|
currentNodeStore: x,
|
|
655
667
|
currentStepStore: u,
|
|
656
|
-
nextReachableStepNodesStore:
|
|
668
|
+
nextReachableStepNodesStore: h,
|
|
657
669
|
stepsToOriginStore: v,
|
|
658
670
|
stepsToLeafStore: T,
|
|
659
671
|
// history
|
|
660
672
|
goToNextStep: s,
|
|
661
673
|
goToPreviousStep: a,
|
|
662
674
|
goToStepById: o,
|
|
663
|
-
stepsHistoryStore:
|
|
675
|
+
stepsHistoryStore: R
|
|
664
676
|
};
|
|
665
677
|
}
|
|
666
678
|
);
|
|
@@ -669,19 +681,19 @@ function Wt(t) {
|
|
|
669
681
|
}
|
|
670
682
|
const Gt = it(({ client: t }) => {
|
|
671
683
|
const e = z.store({}), r = O(), n = O(), s = O(), a = ot(e, {
|
|
672
|
-
register(u,
|
|
684
|
+
register(u, h) {
|
|
673
685
|
const v = [
|
|
674
|
-
...u[
|
|
686
|
+
...u[h.experienceId] ?? []
|
|
675
687
|
];
|
|
676
|
-
return v.push(
|
|
688
|
+
return v.push(h), {
|
|
677
689
|
...u,
|
|
678
|
-
[
|
|
690
|
+
[h.experienceId]: v
|
|
679
691
|
};
|
|
680
692
|
},
|
|
681
|
-
unregister(u,
|
|
693
|
+
unregister(u, h) {
|
|
682
694
|
var A;
|
|
683
|
-
const v =
|
|
684
|
-
(
|
|
695
|
+
const v = h.experienceId, T = (A = u[v]) == null ? void 0 : A.filter(
|
|
696
|
+
($) => $ !== h
|
|
685
697
|
);
|
|
686
698
|
return {
|
|
687
699
|
...u,
|
|
@@ -689,7 +701,7 @@ const Gt = it(({ client: t }) => {
|
|
|
689
701
|
};
|
|
690
702
|
}
|
|
691
703
|
}), o = M(
|
|
692
|
-
({ experience: u, target:
|
|
704
|
+
({ experience: u, target: h }) => Wt({ client: t, experience: u, target: h })
|
|
693
705
|
), c = M((u) => {
|
|
694
706
|
a.register(u);
|
|
695
707
|
}), d = M(
|
|
@@ -698,19 +710,19 @@ const Gt = it(({ client: t }) => {
|
|
|
698
710
|
s(u);
|
|
699
711
|
});
|
|
700
712
|
}
|
|
701
|
-
),
|
|
713
|
+
), S = M((u) => {
|
|
702
714
|
a.unregister(u);
|
|
703
715
|
}), k = M((u) => {
|
|
704
|
-
const
|
|
705
|
-
if (!
|
|
716
|
+
const h = u.componentStore.getState();
|
|
717
|
+
if (!h) {
|
|
706
718
|
I("warn", "No app component registered. Skipping init.");
|
|
707
719
|
return;
|
|
708
720
|
}
|
|
709
|
-
const v =
|
|
721
|
+
const v = h.frameworkStore.getState();
|
|
710
722
|
if (!v) {
|
|
711
723
|
I(
|
|
712
724
|
"error",
|
|
713
|
-
`No framework registered for component '${
|
|
725
|
+
`No framework registered for component '${h.name}'. Skipping rendering.`
|
|
714
726
|
);
|
|
715
727
|
return;
|
|
716
728
|
}
|
|
@@ -724,9 +736,9 @@ const Gt = it(({ client: t }) => {
|
|
|
724
736
|
}
|
|
725
737
|
const A = Ot(T);
|
|
726
738
|
try {
|
|
727
|
-
v.render(A,
|
|
728
|
-
} catch (
|
|
729
|
-
I("error",
|
|
739
|
+
v.render(A, h.component, t, u);
|
|
740
|
+
} catch ($) {
|
|
741
|
+
I("error", $);
|
|
730
742
|
}
|
|
731
743
|
});
|
|
732
744
|
m({
|
|
@@ -734,7 +746,7 @@ const Gt = it(({ client: t }) => {
|
|
|
734
746
|
target: o
|
|
735
747
|
}), m({
|
|
736
748
|
clock: s,
|
|
737
|
-
target:
|
|
749
|
+
target: S
|
|
738
750
|
}), m({
|
|
739
751
|
clock: o.doneData,
|
|
740
752
|
target: [
|
|
@@ -752,17 +764,17 @@ const Gt = it(({ client: t }) => {
|
|
|
752
764
|
clock: n,
|
|
753
765
|
target: k
|
|
754
766
|
});
|
|
755
|
-
function
|
|
756
|
-
r({ experience: u, target:
|
|
767
|
+
function _(u, h) {
|
|
768
|
+
r({ experience: u, target: h });
|
|
757
769
|
}
|
|
758
|
-
const
|
|
770
|
+
const R = e.map((u) => Object.values(u).flat());
|
|
759
771
|
function x(u) {
|
|
760
|
-
return e.map((
|
|
772
|
+
return e.map((h) => h[u] || [], { skipVoid: !1 });
|
|
761
773
|
}
|
|
762
774
|
return {
|
|
763
|
-
spawn:
|
|
775
|
+
spawn: _,
|
|
764
776
|
getByExperienceId: x,
|
|
765
|
-
listStore:
|
|
777
|
+
listStore: R
|
|
766
778
|
};
|
|
767
779
|
});
|
|
768
780
|
function Zt(t) {
|
|
@@ -774,7 +786,7 @@ export {
|
|
|
774
786
|
Qt as c,
|
|
775
787
|
zt as d,
|
|
776
788
|
et as e,
|
|
777
|
-
|
|
789
|
+
$t as f,
|
|
778
790
|
Jt as g,
|
|
779
791
|
Wt as h,
|
|
780
792
|
At as i,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("effector"),q=require("@withease/factories"),H=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),ge=require("./object-BbFTsGh3.cjs");function me(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function E(e){return Array.isArray(e)}function ne(e){return e instanceof Promise}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(me(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function T(e){return`${e}`}const he={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>m(e)>m(t),">=":(e,t)=>m(e)>=m(t),"<":(e,t,r)=>{const n=m(e),a=m(t);if(r===void 0)return n<a;const c=m(r);return n<a&&a<c},"<=":(e,t,r)=>{const n=m(e),a=m(t);if(r===void 0)return n<=a;const c=m(r);return n<=a&&a<=c},"!!":async e=>await O(e),"!":async e=>!await O(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(T(e))!==-1:E(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(T).join(""),substr:(e,t,r)=>{const n=T(e),a=m(t);if(r===void 0)return n.substr(a);const c=m(r);if(c<0){const o=n.substr(a);return o.substr(0,o.length+c)}return n.substr(a,c)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>E(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=T(e);if(n===""||n===".")return this;const a=n.split(".");let c=this;for(const o of a){if(c==null)return r;if(Array.isArray(c)){const u=parseInt(o,10);isNaN(u)?c=c[o]:c=c[u]}else c=c[o]}return c!==void 0?c:r},async missing(...e){const t=E(e[0])?e[0]:e,r=[];for(const n of t){const a=await g({var:n},this);(a===null||a==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!E(r)||!E(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(E(e)){const[c,o]=e;r=c,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(T(t))},throw(e){throw new Error(T(e))}};async function g(e,t){if(!e)return e;if(ne(e))return g(await e,t);if(E(e))return Promise.all(e.map(o=>g(o,t)));if(!Z(e))return e;const r=Se(e);let n=r?e[r]??[]:[];switch(E(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await O(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const u of n)if(o=await g(u,t),!await O(o))return o;return o}case"or":{let o=null;for(const u of n)if(o=await g(u,t),await O(o))return o;return o}case"map":{const o=await g(n[0],t);return E(o)?await Promise.all(o.map(u=>g(n[1],u))):[]}case"filter":{const o=await g(n[0],t);return E(o)?(await Promise.all(o.map(async p=>{const h=await O(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!E(o))return n.length>2?await g(n[2],t):null;const u=n[1];let h=n.length>2?await g(n[2],t):null;for(const k of o)h=await g(u,{current:k,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!E(o)||o.length===0)return!1;for(const u of o)if(!await O(await g(n[1],u)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!E(o))return!1;for(const u of o)if(await O(await g(n[1],u)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!E(o))return!0;for(const u of o)if(await O(await g(n[1],u)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return Z(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const a=await Promise.all(n.map(o=>g(o,t))),c=r?he[r]:void 0;if(!c)throw new Error(`Unrecognized operation ${r}`);return c.apply(t,a)}async function O(e){return ne(e)?O(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function Se(e){return Object.keys(e)[0]}function re(e){return!ge.isEmpty(e)}async function V(e,t,r){const n=e.getStateSnapshot(),a=e.predicates.listStore.getState().reduce((u,p)=>({...u,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),c=e.features.listStore.getState().reduce((u,p)=>({...u,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:a,features:c};return await g(t,o)}function ye(e){return!H.supportsWindow()||!H.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const we="open";function Ee(e){if(!H.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:we})}function Ne(){return new Promise((e,t)=>{if(!H.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Ie(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const C="picked-root",j="picked-target",xe="picked-root";function ke(e,t){return[...e,{selector:`${xe}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const a=ye(n.selector).filter(c=>!Ae(c,t)&&!oe(c,t));return{...n,elements:a}})}function ve(e,t){return e.flatMap(r=>r.elements.map(n=>Fe(n,r.placement,t)))}function be(e,t){e.classList.add(j),e.classList.add(`${j}-${t}`)}function Ae(e,t){return t?e.classList.contains(`${j}-${t}`):e.classList.contains(`${j}`)}function oe(e,t){return t?e.classList.contains(`${C}-${t}`):e.classList.contains(C)}function Oe(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(C),t.classList.add(`${C}-${e}`),t}function Fe(e,t,r){let n;const a=Oe(r);if(e instanceof Document)n=e.body.appendChild(a);else{switch(t){case"replace":e.replaceWith(a);break;case"before":e.before(a);break;case"after":e.after(a);break;case"prepend":e.prepend(a);break;default:e.append(a);break}n=a}return n}function Be(e){return e.type==="conditional"}function M(e){return e.type==="step"}function _e(e){return e.type==="experience"}function ee(e){return e.type==="origin"}function te(e){return e.type==="action"}const se=(e,t,r,n,a=new Set)=>a.has(r.id)?[]:(a.add(r.id),M(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const u=e.find(p=>p.id===o.destinationNodeId);return u?se(e,t,u,!1,a):[]})),$e=(e,t,r)=>se(e,t,r,!0,new Set),ie=(e,t,r,n,a=new Set)=>{if(a.has(r.id))return[-1,-1];a.add(r.id);const c=t.filter(p=>p.sourceNodeId===r.id);if(c.length===0)return[0,0];let o=1/0,u=-1/0;for(const p of c){const h=e.find(L=>L.id===p.destinationNodeId);if(!h)continue;const[k,F]=ie(e,t,h,!1,new Set(a));k!==-1&&(o=Math.min(o,k+1),u=Math.max(u,F+1))}return o===1/0?[-1,-1]:[o,u]},Te=(e,t,r)=>ie(e,t,r,!0,new Set),ae=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const a=t.filter(u=>u.destinationNodeId===r.id);if(a.length===0)return[-1,-1];let c=1/0,o=-1/0;for(const u of a){const p=e.find(F=>F.id===u.sourceNodeId);if(!p)continue;const[h,k]=ae(e,t,p,new Set(n));h!==-1&&(c=Math.min(c,h+1),o=Math.max(o,k+1))}return c===1/0?[-1,-1]:[c,o]},Me=(e,t,r)=>ae(e,t,r,new Set),ce=e=>e.find(r=>r.type==="origin")||null,U=(e,t,r)=>{if(!e)return ce(t);const n=r.find(c=>c.sourceNodeId===e.id);if(!n)return null;const a=t.find(c=>c.id===n.destinationNodeId);return a||null};async function Le(e,t,r,n){const a=e?"true":"false",c=n.find(o=>o.sourceNodeHandle===a&&o.sourceNodeId===t);return r.find(o=>o.id===(c==null?void 0:c.destinationNodeId))}const X=i.createDomain("experience-instance"),De=q.createFactory(({client:e,experience:t,target:r})=>{const n=i.createEvent(),a=i.createEvent(),c=i.createEvent(),o=i.createEvent(),u=i.createEvent(),p=i.createEvent(),h=t.componentStore,k=X.store("transitioning"),F=e.history.entriesStore.map(s=>s.filter(l=>l.experienceId===t.id)),L=F.map(s=>s.filter(l=>M(l.node))),I=F.map(s=>{var l;return((l=s[s.length-1])==null?void 0:l.node)||null}),f=i.combine(t.treeStore,I,({steps:s},l)=>s.find(d=>l&&M(l)&&d.id===l.stepId)||null),S=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?$e(s,l,d):[]),A=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?Me(s,l,d):[-1,-1]),_=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?Te(s,l,d):[-1,-1]),v=X.store(!1),B=i.createApi(v,{open:()=>!0,close:()=>!1,toggle:s=>!s,set:(s,l)=>l}),fe=i.createEffect(async()=>{e.history.back({experienceId:t.id})}),le=i.attach({source:t.treeStore,effect:async(s,l)=>{const d=s.nodes.find(w=>M(w)&&w.stepId===l);d&&e.history.push({experienceId:t.id,node:d})}}),z=i.attach({source:I,effect:s=>{}}),W=i.attach({source:t.treeStore,effect:async({nodes:s})=>ce(s)}),G=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l},d)=>U(d,s,l)}),K=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l,conditionals:d},w)=>{if(!w)return;const $=d.find(b=>b.id===w.conditionalId);if(!$)return;const x=w.id,y=await V(e,$.condition);return Le(!!y,x,s,l)}}),J=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l},d)=>{if(!d||!te(d))return;const w=d.action;if(!w){N.logger("warn",`Action node ${d.id} has no action name`);return}const $=e.actions.getByName(w).getState();if(!$){N.logger("warn",`Action '${w}' not registered on client`);const x=l.find(y=>y.sourceNodeId===d.id&&y.sourceNodeHandle==="false");return x?s.find(y=>y.id===x.destinationNodeId):null}if(typeof $.action!="function"){N.logger("warn",`Action '${w}' is not a function`);const x=l.find(y=>y.sourceNodeId===d.id&&y.sourceNodeHandle==="false");return x?s.find(y=>y.id===x.destinationNodeId):null}try{N.logger("info",`Executing action: ${w}`),await $.action(w);const x=l.find(b=>b.sourceNodeId===d.id&&b.sourceNodeHandle==="true");if(!x)return N.logger("warn",`No 'true' edge found for action node ${d.id}`),null;const y=s.find(b=>b.id===x.destinationNodeId);return N.logger("info",`Action '${w}' succeeded, moving to node ${y==null?void 0:y.id}`),y||null}catch(x){N.logger("warn",`Action '${w}' failed:`,x);const y=l.find(P=>P.sourceNodeId===d.id&&P.sourceNodeHandle==="false");if(!y)return N.logger("warn",`No 'false' edge found for action node ${d.id}`),null;const b=s.find(P=>P.id===y.destinationNodeId);return N.logger("info",`Action '${w}' failed, moving to node ${b==null?void 0:b.id}`),b||null}}}),de=i.createEffect(s=>{if(s)return e.launchExperienceById(s.experienceId)}),Q=i.attach({source:[I,t.treeStore],effect:async([s,{nodes:l,edges:d}])=>U(s,l,d)}),D=i.attach({source:[I,t.treeStore],effect:async([s,{nodes:l,edges:d}])=>U(s,l,d)}),pe=i.createEffect(s=>{e.history.push({experienceId:t.id,node:s})}),Y=i.attach({source:t.configStore,effect:async({initializeOpenLogic:s})=>re(s)?!!await V(e,s):s??!1});return i.split({source:I,match:s=>s?Be(s)?"condition":M(s)?"step":_e(s)?"launchExperience":ee(s)?"origin":te(s)?"action":"other":"none",cases:{none:W,origin:G,condition:K,step:z,launchExperience:de,action:J,__:i.createEvent()}}),i.sample({clock:[K.doneData,G.doneData,W.doneData,D.doneData,Q.doneData,J.doneData],filter:Boolean,target:pe}),i.sample({clock:a,target:D}),i.sample({clock:a,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit",step:s,experience:t}))}),i.sample({clock:D.done,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_success",step:s,experience:t}))}),i.sample({clock:D.fail,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_error",step:s,experience:t}))}),i.sample({clock:c,target:fe}),i.sample({clock:o,target:le}),i.sample({source:i.combine([K.pending,G.pending,W.pending,D.pending]),fn:s=>s.some(Boolean)?"transitioning":"ready",target:k}),i.sample({clock:z.doneData,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_enter",step:s,experience:t}))}),i.sample({clock:p,target:Y}),i.sample({source:Y.doneData,fn:Boolean,target:v}),i.sample({source:I,clock:n,filter:s=>s?ee(s):!0,target:Q}),i.sample({source:v,filter:Boolean,target:n}),i.sample({source:v,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:t}))}),i.sample({source:v,filter:s=>!s,target:e.eventBus.prepend(()=>({type:"experience_close",experience:t}))}),i.sample({clock:u,target:[p]}),u(),{id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:h,stateStore:k,isOpenStore:v,open:B.open,close:B.close,toggleOpen:B.toggle,setOpen:B.set,treeStore:t.treeStore,currentNodeStore:I,currentStepStore:f,nextReachableStepNodesStore:S,stepsToOriginStore:A,stepsToLeafStore:_,goToNextStep:a,goToPreviousStep:c,goToStepById:o,stepsHistoryStore:L}});function ue(e){return q.invoke(De,e)}const Re=q.createFactory(({client:e})=>{const t=X.store({}),r=i.createEvent(),n=i.createEvent(),a=i.createEvent(),c=i.createApi(t,{register(f,S){const A=[...f[S.experienceId]??[]];return A.push(S),{...f,[S.experienceId]:A}},unregister(f,S){var v;const A=S.experienceId,_=(v=f[A])==null?void 0:v.filter(B=>B!==S);return{...f,[A]:_??[]}}}),o=i.createEffect(({experience:f,target:S})=>ue({client:e,experience:f,target:S})),u=i.createEffect(f=>{c.register(f)}),p=i.createEffect(f=>{f.target&&Ie(f.target,()=>{a(f)})}),h=i.createEffect(f=>{c.unregister(f)}),k=i.createEffect(f=>{const S=f.componentStore.getState();if(!S){N.logger("warn","No app component registered. Skipping init.");return}const A=S.frameworkStore.getState();if(!A){N.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const _=f.target;if(!_){N.logger("error",`No target element registered for experience '${f.experienceId}'. Skipping rendering.`);return}const v=Ee(_);try{A.render(v,S.component,e,f)}catch(B){N.logger("error",B)}});i.sample({clock:r,target:o}),i.sample({clock:a,target:h}),i.sample({clock:o.doneData,target:[u,p,n]}),i.sample({clock:o.doneData,target:e.eventBus.prepend(f=>({type:"experience_initialize",experienceInstance:f}))}),i.sample({clock:n,target:k});function F(f,S){r({experience:f,target:S})}const L=t.map(f=>Object.values(f).flat());function I(f){return t.map(S=>S[f]||[],{skipVoid:!1})}return{spawn:F,getByExperienceId:I,listStore:L}});function Pe(e){return q.invoke(Re,e)}exports.createAppHosts=ve;exports.createExperienceInstance=ue;exports.createExperienceInstanceIndex=Pe;exports.domInteractive=Ne;exports.evaluateRuleLogic=V;exports.getTargetElements=ke;exports.isPickedRoot=oe;exports.isRulesLogic=re;exports.isStepNode=M;exports.tagTargetElement=be;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Store } from 'effector';
|
|
2
|
+
export type Action = <T = void>(params?: T) => void;
|
|
2
3
|
export type ActionsStore = ReturnType<typeof createActionIndexFactory>;
|
|
3
4
|
export interface ActionIndexItem {
|
|
4
5
|
name: string;
|
|
@@ -6,8 +7,9 @@ export interface ActionIndexItem {
|
|
|
6
7
|
}
|
|
7
8
|
declare const createActionIndexFactory: () => {
|
|
8
9
|
register: (name: string, action: Action) => void;
|
|
9
|
-
getByName: (name: string) =>
|
|
10
|
-
listStore:
|
|
10
|
+
getByName: (name: string) => Store<ActionIndexItem | undefined>;
|
|
11
|
+
listStore: Store<ActionIndexItem[]>;
|
|
12
|
+
getEvokableAction: (actionName: string) => Store<(<T = void>(params?: T) => void) | undefined>;
|
|
11
13
|
};
|
|
12
14
|
export declare function createActionIndex(): ReturnType<typeof createActionIndexFactory>;
|
|
13
15
|
export declare const setupAction: (name: string, action: Action, actions: ActionsStore) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAG9D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;AACnD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAItE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,QAAA,MAAM,wBAAwB;qBAiBJ,MAAM,UAAU,MAAM,KAAG,IAAI;sBAQ5B,MAAM;;oCAIQ,MAAM,KAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAgBnG,CAAA;AAEF,wBAAgB,iBAAiB,IAAI,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAE/E;AAED,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,YAAY,KAAG,IAEjF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Store } from 'effector';
|
|
1
2
|
import { Picked } from '../../picked';
|
|
2
3
|
export interface Feature {
|
|
3
4
|
key: string;
|
|
@@ -5,7 +6,7 @@ export interface Feature {
|
|
|
5
6
|
decide: () => boolean | Promise<boolean> | string | Promise<string>;
|
|
6
7
|
storage?: 'local' | 'session';
|
|
7
8
|
}
|
|
8
|
-
export type FeaturesStore = ReturnType<typeof
|
|
9
|
+
export type FeaturesStore = ReturnType<typeof createFeatureIndexFactory>;
|
|
9
10
|
export interface FeatureIndexItem {
|
|
10
11
|
id: string;
|
|
11
12
|
feature: Feature & {
|
|
@@ -42,8 +43,10 @@ declare const createFeatureIndexFactory: ({ client }: {
|
|
|
42
43
|
client: Picked;
|
|
43
44
|
}) => {
|
|
44
45
|
register: (id: string, feature: Feature) => void;
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
getById: (id: string) => Store<FeatureBucket | undefined>;
|
|
47
|
+
getByName: (name: string) => Store<FeatureIndexItem | undefined>;
|
|
48
|
+
listStore: Store<FeatureBucket[]>;
|
|
49
|
+
getEvokableFeature: (featureName: string) => Store<() => Promise<boolean | string | undefined>>;
|
|
47
50
|
};
|
|
48
51
|
export declare function createFeatureIndex<T extends Parameters<typeof createFeatureIndexFactory>[0]>(params: T): ReturnType<typeof createFeatureIndexFactory>;
|
|
49
52
|
export declare const setupFeature: (name: string, feature: Feature, features: FeaturesStore) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/entities/feature/feature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/entities/feature/feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAExE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,UAAU,EAAE,KAAK,CAAA;IACjB,SAAS,EAAE,MAAM,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAA;CACnE;AAED,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS,EAAE,MAAM;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;CAC1D;AAED,MAAM,MAAM,aAAa,GAAG,uBAAuB,GAAG,qBAAqB,CAAA;AAK3E,QAAA,MAAM,yBAAyB,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;mBAgBvD,MAAM,WAAW,OAAO,KAAG,IAAI;kBAwMhC,MAAM;sBAOF,MAAM;;sCAKhB,MAAM,KAClB,KAAK,CAAC,MAAM,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;CA2CrD,CAAA;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAC1F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAE9C;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,SAAS,OAAO,EAAE,UAAU,aAAa,SAEnF,CAAA"}
|