@picked/client 0.0.1-dev.1773371977114 → 0.0.1-dev.1773724362573
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-CLwLE-DW.js → api-B3x8PEp4.js} +1 -1
- package/dist/{api-Cn-rv5A5.cjs → api-Z3Hn2Kw-.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/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +723 -662
- package/dist/esm/plugins/create-experience/index.js +238 -279
- package/dist/esm/plugins/dynamic-experiences/index.js +12 -12
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +17 -18
- package/dist/esm/plugins/responses-indexeddb/index.js +51 -46
- package/dist/esm/plugins/single-page-app/index.js +24 -24
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BX0aqKsC.cjs +1 -0
- package/dist/{experience-instance-fvSEb72i.js → experience-instance-DTyL1fNb.js} +205 -199
- package/dist/{object-JwZ58NOH.js → object-CJssU1Pm.js} +1 -1
- package/dist/object-mwaxtjLG.cjs +1 -0
- package/dist/storage-58NoTSsc.cjs +1 -0
- package/dist/{storage-Co_LbKr_.js → storage-B2d81EOI.js} +35 -30
- package/dist/types/entities/action/action.d.ts +5 -2
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +2 -3
- 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/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +52 -36
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +6 -10
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +0 -1
- package/dist/types/exports.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 +2 -8
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +18 -14
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +26 -36
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -3
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -3
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +0 -1
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +2 -1
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +0 -8
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +10 -14
- package/dist/experience-instance-BsXG5XJ4.cjs +0 -1
- package/dist/object-BbFTsGh3.cjs +0 -1
- package/dist/storage-Be5xWNPC.cjs +0 -1
- package/dist/to-kebab-case-BPnCZjhB.js +0 -6
- package/dist/to-kebab-case-BsOQ8CON.cjs +0 -1
- package/dist/types/utils/get-step-fields.d.ts +0 -4
- package/dist/types/utils/get-step-fields.d.ts.map +0 -1
- package/dist/types/utils/to-kebab-case.d.ts +0 -9
- package/dist/types/utils/to-kebab-case.d.ts.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createDomain as kt, createEvent as
|
|
1
|
+
import { createDomain as kt, createEvent as b, combine as D, createApi as lt, createEffect as B, attach as O, sample as S, split as bt } from "effector";
|
|
2
2
|
import { createFactory as dt, invoke as pt } from "@withease/factories";
|
|
3
3
|
import { a as vt, s as gt, j as At } from "./supports-8YT4QKI7.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
5
|
-
import { i as Ot } from "./object-
|
|
5
|
+
import { i as Ot } from "./object-CJssU1Pm.js";
|
|
6
6
|
function Ft(t) {
|
|
7
7
|
return typeof t == "number" && !isNaN(t);
|
|
8
8
|
}
|
|
9
9
|
function j(t) {
|
|
10
10
|
return typeof t == "string";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function E(t) {
|
|
13
13
|
return Array.isArray(t);
|
|
14
14
|
}
|
|
15
15
|
function mt(t) {
|
|
@@ -18,7 +18,7 @@ function mt(t) {
|
|
|
18
18
|
function st(t) {
|
|
19
19
|
return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function m(t) {
|
|
22
22
|
if (Ft(t)) return t;
|
|
23
23
|
const e = parseFloat(`${t}`);
|
|
24
24
|
return isNaN(e) ? 0 : e;
|
|
@@ -26,39 +26,39 @@ function g(t) {
|
|
|
26
26
|
function R(t) {
|
|
27
27
|
return `${t}`;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const _t = {
|
|
30
30
|
// eslint-disable-next-line eqeqeq
|
|
31
31
|
"==": (t, e) => t == e,
|
|
32
32
|
"===": (t, e) => t === e,
|
|
33
33
|
// eslint-disable-next-line eqeqeq
|
|
34
34
|
"!=": (t, e) => t != e,
|
|
35
35
|
"!==": (t, e) => t !== e,
|
|
36
|
-
">": (t, e) =>
|
|
37
|
-
">=": (t, e) =>
|
|
36
|
+
">": (t, e) => m(t) > m(e),
|
|
37
|
+
">=": (t, e) => m(t) >= m(e),
|
|
38
38
|
"<": (t, e, r) => {
|
|
39
|
-
const n =
|
|
39
|
+
const n = m(t), s = m(e);
|
|
40
40
|
if (r === void 0) return n < s;
|
|
41
|
-
const a =
|
|
41
|
+
const a = m(r);
|
|
42
42
|
return n < s && s < a;
|
|
43
43
|
},
|
|
44
44
|
"<=": (t, e, r) => {
|
|
45
|
-
const n =
|
|
45
|
+
const n = m(t), s = m(e);
|
|
46
46
|
if (r === void 0) return n <= s;
|
|
47
|
-
const a =
|
|
47
|
+
const a = m(r);
|
|
48
48
|
return n <= s && s <= a;
|
|
49
49
|
},
|
|
50
50
|
"!!": async (t) => await v(t),
|
|
51
51
|
"!": async (t) => !await v(t),
|
|
52
|
-
"%": (t, e) =>
|
|
52
|
+
"%": (t, e) => m(t) % m(e),
|
|
53
53
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
54
|
log: (t) => (console.log(t), t),
|
|
55
|
-
in: (t, e) => e ? j(e) ? e.indexOf(R(t)) !== -1 :
|
|
55
|
+
in: (t, e) => e ? j(e) ? e.indexOf(R(t)) !== -1 : E(e) ? e.includes(t) : !1 : !1,
|
|
56
56
|
cat: (...t) => t.map(R).join(""),
|
|
57
57
|
/* eslint-disable sonarjs/deprecation */
|
|
58
58
|
substr: (t, e, r) => {
|
|
59
|
-
const n = R(t), s =
|
|
59
|
+
const n = R(t), s = m(e);
|
|
60
60
|
if (r === void 0) return n.substr(s);
|
|
61
|
-
const a =
|
|
61
|
+
const a = m(r);
|
|
62
62
|
if (a < 0) {
|
|
63
63
|
const o = n.substr(s);
|
|
64
64
|
return o.substr(0, o.length + a);
|
|
@@ -66,16 +66,17 @@ const Bt = {
|
|
|
66
66
|
return n.substr(s, a);
|
|
67
67
|
},
|
|
68
68
|
/* eslint-enable sonarjs/deprecation */
|
|
69
|
-
"+": (...t) => t.reduce((e, r) =>
|
|
70
|
-
"*": (...t) => t.reduce((e, r) =>
|
|
69
|
+
"+": (...t) => t.reduce((e, r) => m(e) + m(r), 0),
|
|
70
|
+
"*": (...t) => t.reduce((e, r) => m(e) * m(r), 1),
|
|
71
71
|
"-": (t, e) => {
|
|
72
|
-
const r =
|
|
73
|
-
return e === void 0 ? -r : r -
|
|
72
|
+
const r = m(t);
|
|
73
|
+
return e === void 0 ? -r : r - m(e);
|
|
74
74
|
},
|
|
75
|
-
"/": (t, e) =>
|
|
76
|
-
min: (...t) => Math.min(...t.map(
|
|
77
|
-
max: (...t) => Math.max(...t.map(
|
|
78
|
-
merge: (...t) => t.reduce((e, r) =>
|
|
75
|
+
"/": (t, e) => m(t) / m(e),
|
|
76
|
+
min: (...t) => Math.min(...t.map(m)),
|
|
77
|
+
max: (...t) => Math.max(...t.map(m)),
|
|
78
|
+
merge: (...t) => t.reduce((e, r) => E(r) ? e.concat(r) : e.concat([r]), []),
|
|
79
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- JSONLogic var operator requires complex path traversal logic
|
|
79
80
|
var(t, e) {
|
|
80
81
|
const r = arguments.length > 1 ? e : null;
|
|
81
82
|
if (t === "" || t === "." || t === null || t === void 0)
|
|
@@ -91,15 +92,15 @@ const Bt = {
|
|
|
91
92
|
if (a == null)
|
|
92
93
|
return r;
|
|
93
94
|
if (Array.isArray(a)) {
|
|
94
|
-
const
|
|
95
|
-
isNaN(
|
|
95
|
+
const f = parseInt(o, 10);
|
|
96
|
+
isNaN(f) ? a = a[o] : a = a[f];
|
|
96
97
|
} else
|
|
97
98
|
a = a[o];
|
|
98
99
|
}
|
|
99
100
|
return a !== void 0 ? a : r;
|
|
100
101
|
},
|
|
101
102
|
async missing(...t) {
|
|
102
|
-
const e =
|
|
103
|
+
const e = E(t[0]) ? t[0] : t, r = [];
|
|
103
104
|
for (const n of e) {
|
|
104
105
|
const s = await p({ var: n }, this);
|
|
105
106
|
(s === null || s === "") && r.push(`${n}`);
|
|
@@ -108,9 +109,9 @@ const Bt = {
|
|
|
108
109
|
},
|
|
109
110
|
async missing_some(t, e) {
|
|
110
111
|
const r = await p({ missing: e }, this);
|
|
111
|
-
if (!
|
|
112
|
+
if (!E(r) || !E(e)) return [];
|
|
112
113
|
const n = r.filter(j);
|
|
113
|
-
return e.filter(j).length - n.length >=
|
|
114
|
+
return e.filter(j).length - n.length >= m(t) ? [] : n;
|
|
114
115
|
},
|
|
115
116
|
/**
|
|
116
117
|
* Invoke operator - executes a function with optional arguments
|
|
@@ -130,7 +131,7 @@ const Bt = {
|
|
|
130
131
|
},
|
|
131
132
|
regexp_matches(t, e) {
|
|
132
133
|
let r = t, n = "";
|
|
133
|
-
if (
|
|
134
|
+
if (E(t)) {
|
|
134
135
|
const [a, o] = t;
|
|
135
136
|
r = a, n = o;
|
|
136
137
|
}
|
|
@@ -144,12 +145,12 @@ async function p(t, e) {
|
|
|
144
145
|
if (!t) return t;
|
|
145
146
|
if (mt(t))
|
|
146
147
|
return p(await t, e);
|
|
147
|
-
if (
|
|
148
|
+
if (E(t))
|
|
148
149
|
return Promise.all(t.map((o) => p(o, e)));
|
|
149
150
|
if (!st(t)) return t;
|
|
150
|
-
const r =
|
|
151
|
+
const r = Bt(t);
|
|
151
152
|
let n = r ? t[r] ?? [] : [];
|
|
152
|
-
switch (
|
|
153
|
+
switch (E(n) || (n = [n]), r) {
|
|
153
154
|
case "if":
|
|
154
155
|
case "?:":
|
|
155
156
|
for (let o = 0; o < n.length - 1; o += 2)
|
|
@@ -158,59 +159,59 @@ async function p(t, e) {
|
|
|
158
159
|
return n.length % 2 === 1 ? p(n[n.length - 1], e) : null;
|
|
159
160
|
case "and": {
|
|
160
161
|
let o = null;
|
|
161
|
-
for (const
|
|
162
|
-
if (o = await p(
|
|
162
|
+
for (const f of n)
|
|
163
|
+
if (o = await p(f, e), !await v(o))
|
|
163
164
|
return o;
|
|
164
165
|
return o;
|
|
165
166
|
}
|
|
166
167
|
case "or": {
|
|
167
168
|
let o = null;
|
|
168
|
-
for (const
|
|
169
|
-
if (o = await p(
|
|
169
|
+
for (const f of n)
|
|
170
|
+
if (o = await p(f, e), await v(o)) return o;
|
|
170
171
|
return o;
|
|
171
172
|
}
|
|
172
173
|
case "map": {
|
|
173
174
|
const o = await p(n[0], e);
|
|
174
|
-
return
|
|
175
|
+
return E(o) ? await Promise.all(o.map((f) => p(n[1], f))) : [];
|
|
175
176
|
}
|
|
176
177
|
case "filter": {
|
|
177
178
|
const o = await p(n[0], e);
|
|
178
|
-
return
|
|
179
|
+
return E(o) ? (await Promise.all(
|
|
179
180
|
o.map(async (d) => {
|
|
180
|
-
const
|
|
181
|
-
return { item: d, shouldInclude:
|
|
181
|
+
const g = await v(await p(n[1], d));
|
|
182
|
+
return { item: d, shouldInclude: g };
|
|
182
183
|
})
|
|
183
184
|
)).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
|
|
184
185
|
}
|
|
185
186
|
case "reduce": {
|
|
186
187
|
const o = await p(n[0], e);
|
|
187
|
-
if (!
|
|
188
|
+
if (!E(o))
|
|
188
189
|
return n.length > 2 ? await p(n[2], e) : null;
|
|
189
|
-
const
|
|
190
|
-
let
|
|
191
|
-
for (const
|
|
192
|
-
|
|
193
|
-
return
|
|
190
|
+
const f = n[1];
|
|
191
|
+
let g = n.length > 2 ? await p(n[2], e) : null;
|
|
192
|
+
for (const x of o)
|
|
193
|
+
g = await p(f, { current: x, accumulator: g });
|
|
194
|
+
return g;
|
|
194
195
|
}
|
|
195
196
|
case "all": {
|
|
196
197
|
const o = await p(n[0], e);
|
|
197
|
-
if (!
|
|
198
|
-
for (const
|
|
199
|
-
if (!await v(await p(n[1],
|
|
198
|
+
if (!E(o) || o.length === 0) return !1;
|
|
199
|
+
for (const f of o)
|
|
200
|
+
if (!await v(await p(n[1], f))) return !1;
|
|
200
201
|
return !0;
|
|
201
202
|
}
|
|
202
203
|
case "some": {
|
|
203
204
|
const o = await p(n[0], e);
|
|
204
|
-
if (!
|
|
205
|
-
for (const
|
|
206
|
-
if (await v(await p(n[1],
|
|
205
|
+
if (!E(o)) return !1;
|
|
206
|
+
for (const f of o)
|
|
207
|
+
if (await v(await p(n[1], f))) return !0;
|
|
207
208
|
return !1;
|
|
208
209
|
}
|
|
209
210
|
case "none": {
|
|
210
211
|
const o = await p(n[0], e);
|
|
211
|
-
if (!
|
|
212
|
-
for (const
|
|
213
|
-
if (await v(await p(n[1],
|
|
212
|
+
if (!E(o)) return !0;
|
|
213
|
+
for (const f of o)
|
|
214
|
+
if (await v(await p(n[1], f))) return !1;
|
|
214
215
|
return !0;
|
|
215
216
|
}
|
|
216
217
|
case "catch":
|
|
@@ -220,31 +221,33 @@ async function p(t, e) {
|
|
|
220
221
|
return st(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))), a = r ?
|
|
224
|
+
const s = await Promise.all(n.map((o) => p(o, e))), a = r ? _t[r] : void 0;
|
|
224
225
|
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
225
226
|
return a.apply(e, s);
|
|
226
227
|
}
|
|
227
228
|
async function v(t) {
|
|
228
229
|
return mt(t) ? v(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function Bt(t) {
|
|
231
232
|
return Object.keys(t)[0];
|
|
232
233
|
}
|
|
233
234
|
function $t(t) {
|
|
234
235
|
return !Ot(t);
|
|
235
236
|
}
|
|
236
237
|
async function at(t, e, r) {
|
|
237
|
-
const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((
|
|
238
|
-
...
|
|
239
|
-
[
|
|
240
|
-
}), {}), a = t.features.listStore.getState().reduce((
|
|
241
|
-
...
|
|
242
|
-
[
|
|
243
|
-
const { bucket:
|
|
244
|
-
return
|
|
238
|
+
const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((d, g) => ({
|
|
239
|
+
...d,
|
|
240
|
+
[g.name]: (...x) => g.predicate({ ...n, args: x })
|
|
241
|
+
}), {}), a = t.features.listStore.getState().reduce((d, g) => ({
|
|
242
|
+
...d,
|
|
243
|
+
[g.id]: async () => {
|
|
244
|
+
const { bucket: x } = await g.getBucket();
|
|
245
|
+
return x;
|
|
245
246
|
}
|
|
246
|
-
}), {}), o = {
|
|
247
|
-
...
|
|
247
|
+
}), {}), o = t.actions.listStore.getState().reduce((d, g) => ({
|
|
248
|
+
...d,
|
|
249
|
+
[g.name]: (x) => g.action(x)
|
|
250
|
+
}), {}), f = {
|
|
248
251
|
responses: t.responses.getAllStore.getState(),
|
|
249
252
|
location: typeof n.location == "object" ? {
|
|
250
253
|
hash: n.location.hash,
|
|
@@ -258,9 +261,11 @@ async function at(t, e, r) {
|
|
|
258
261
|
search: n.location.search
|
|
259
262
|
} : void 0,
|
|
260
263
|
predicates: s,
|
|
261
|
-
features: a
|
|
264
|
+
features: a,
|
|
265
|
+
actions: o,
|
|
266
|
+
...r
|
|
262
267
|
};
|
|
263
|
-
return await p(e,
|
|
268
|
+
return await p(e, f);
|
|
264
269
|
}
|
|
265
270
|
function Mt(t) {
|
|
266
271
|
return !vt() || !gt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
@@ -342,7 +347,7 @@ function jt(t, e, r) {
|
|
|
342
347
|
case "prepend":
|
|
343
348
|
t.prepend(s);
|
|
344
349
|
break;
|
|
345
|
-
|
|
350
|
+
case "append":
|
|
346
351
|
t.append(s);
|
|
347
352
|
break;
|
|
348
353
|
}
|
|
@@ -366,43 +371,43 @@ function ft(t) {
|
|
|
366
371
|
return t.type === "action";
|
|
367
372
|
}
|
|
368
373
|
const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), P(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
369
|
-
const
|
|
370
|
-
return
|
|
374
|
+
const f = t.find((d) => d.id === o.destinationNodeId);
|
|
375
|
+
return f ? St(t, e, f, !1, s) : [];
|
|
371
376
|
})), Ut = (t, e, r) => St(t, e, r, !0, /* @__PURE__ */ new Set()), yt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
|
|
372
377
|
if (s.has(r.id)) return [-1, -1];
|
|
373
378
|
s.add(r.id);
|
|
374
379
|
const a = e.filter((d) => d.sourceNodeId === r.id);
|
|
375
380
|
if (a.length === 0) return [0, 0];
|
|
376
|
-
let o = 1 / 0,
|
|
381
|
+
let o = 1 / 0, f = -1 / 0;
|
|
377
382
|
for (const d of a) {
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
380
|
-
const [
|
|
383
|
+
const g = t.find((M) => M.id === d.destinationNodeId);
|
|
384
|
+
if (!g) continue;
|
|
385
|
+
const [x, F] = yt(
|
|
381
386
|
t,
|
|
382
387
|
e,
|
|
383
|
-
|
|
388
|
+
g,
|
|
384
389
|
!1,
|
|
385
390
|
new Set(s)
|
|
386
391
|
);
|
|
387
|
-
|
|
392
|
+
x !== -1 && (o = Math.min(o, x + 1), f = Math.max(f, F + 1));
|
|
388
393
|
}
|
|
389
|
-
return o === 1 / 0 ? [-1, -1] : [o,
|
|
394
|
+
return o === 1 / 0 ? [-1, -1] : [o, f];
|
|
390
395
|
}, Wt = (t, e, r) => yt(t, e, r, !0, /* @__PURE__ */ new Set()), ht = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
391
396
|
if (n.has(r.id)) return [-1, -1];
|
|
392
397
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
393
|
-
const s = e.filter((
|
|
398
|
+
const s = e.filter((f) => f.destinationNodeId === r.id);
|
|
394
399
|
if (s.length === 0) return [-1, -1];
|
|
395
400
|
let a = 1 / 0, o = -1 / 0;
|
|
396
|
-
for (const
|
|
397
|
-
const d = t.find((F) => F.id ===
|
|
401
|
+
for (const f of s) {
|
|
402
|
+
const d = t.find((F) => F.id === f.sourceNodeId);
|
|
398
403
|
if (!d) continue;
|
|
399
|
-
const [
|
|
404
|
+
const [g, x] = ht(
|
|
400
405
|
t,
|
|
401
406
|
e,
|
|
402
407
|
d,
|
|
403
408
|
new Set(n)
|
|
404
409
|
);
|
|
405
|
-
|
|
410
|
+
g !== -1 && (a = Math.min(a, g + 1), o = Math.max(o, x + 1));
|
|
406
411
|
}
|
|
407
412
|
return a === 1 / 0 ? [-1, -1] : [a, o];
|
|
408
413
|
}, Gt = (t, e, r) => ht(t, e, r, /* @__PURE__ */ new Set()), wt = (t) => t.find((r) => r.type === "origin") || null, Z = (t, e, r) => {
|
|
@@ -427,44 +432,44 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
427
432
|
target: r,
|
|
428
433
|
options: n
|
|
429
434
|
}) => {
|
|
430
|
-
const s =
|
|
435
|
+
const s = b(), a = b(), o = b(), f = b(), d = b(), g = b(), x = e.componentStore, F = tt.store("transitioning"), M = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), U = M.map((i) => i.filter((l) => P(l.node))), c = M.map((i) => i.at(-1)?.node || null), y = D(
|
|
431
436
|
e.treeStore,
|
|
432
437
|
c,
|
|
433
|
-
({ steps: i }, l) => i.find((
|
|
434
|
-
),
|
|
438
|
+
({ steps: i }, l) => i.find((u) => l && P(l) && u.id === l.stepId) || null
|
|
439
|
+
), N = D(
|
|
435
440
|
e.treeStore,
|
|
436
441
|
U,
|
|
437
442
|
({ steps: i }, l) => {
|
|
438
|
-
const
|
|
439
|
-
if (!
|
|
443
|
+
const u = l.at(-2);
|
|
444
|
+
if (!u || !P(u.node))
|
|
440
445
|
return null;
|
|
441
|
-
const h =
|
|
442
|
-
return i.find((
|
|
446
|
+
const h = u.node;
|
|
447
|
+
return i.find((_) => _.id === h.stepId) || null;
|
|
443
448
|
}
|
|
444
449
|
), T = D(
|
|
445
450
|
e.treeStore,
|
|
446
451
|
c,
|
|
447
|
-
({ nodes: i, edges: l },
|
|
452
|
+
({ nodes: i, edges: l }, u) => u ? Ut(i, l, u) : []
|
|
448
453
|
), C = D(
|
|
449
454
|
e.treeStore,
|
|
450
455
|
c,
|
|
451
|
-
({ nodes: i, edges: l },
|
|
456
|
+
({ nodes: i, edges: l }, u) => u ? Gt(i, l, u) : [-1, -1]
|
|
452
457
|
), q = D(
|
|
453
458
|
e.treeStore,
|
|
454
459
|
c,
|
|
455
|
-
({ nodes: i, edges: l },
|
|
460
|
+
({ nodes: i, edges: l }, u) => u ? Wt(i, l, u) : [-1, -1]
|
|
456
461
|
), L = tt.store(!1), W = lt(L, {
|
|
457
462
|
open: () => !0,
|
|
458
463
|
close: () => !1,
|
|
459
464
|
toggle: (i) => !i,
|
|
460
465
|
set: (i, l) => l
|
|
461
|
-
}), xt =
|
|
466
|
+
}), xt = B(async () => {
|
|
462
467
|
t.history.back({ experienceId: e.id });
|
|
463
468
|
}), Nt = O({
|
|
464
469
|
source: e.treeStore,
|
|
465
470
|
effect: async (i, l) => {
|
|
466
|
-
const
|
|
467
|
-
|
|
471
|
+
const u = i.nodes.find((h) => P(h) && h.stepId === l);
|
|
472
|
+
u && t.history.push({ experienceId: e.id, node: u });
|
|
468
473
|
}
|
|
469
474
|
}), et = O({
|
|
470
475
|
source: c,
|
|
@@ -475,86 +480,87 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
475
480
|
effect: async ({ nodes: i }) => wt(i)
|
|
476
481
|
}), X = O({
|
|
477
482
|
source: e.treeStore,
|
|
478
|
-
effect: async ({ nodes: i, edges: l },
|
|
479
|
-
if (Y(
|
|
480
|
-
return Z(
|
|
483
|
+
effect: async ({ nodes: i, edges: l }, u) => {
|
|
484
|
+
if (Y(u))
|
|
485
|
+
return Z(u, i, l);
|
|
481
486
|
}
|
|
482
487
|
}), J = O({
|
|
483
488
|
source: e.treeStore,
|
|
484
|
-
effect: async ({ nodes: i, edges: l, conditionals:
|
|
489
|
+
effect: async ({ nodes: i, edges: l, conditionals: u }, h) => {
|
|
485
490
|
if (!ct(h))
|
|
486
491
|
return;
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
492
|
+
const _ = u.find((A) => A.id === h.conditionalId);
|
|
493
|
+
if (!_)
|
|
489
494
|
return;
|
|
490
|
-
const
|
|
491
|
-
return Kt(!!w,
|
|
495
|
+
const k = h.id, w = await at(t, _.condition);
|
|
496
|
+
return Kt(!!w, k, i, l);
|
|
492
497
|
}
|
|
493
498
|
}), nt = O({
|
|
494
499
|
source: e.treeStore,
|
|
495
|
-
effect: async ({ nodes: i, edges: l },
|
|
496
|
-
if (!ft(
|
|
500
|
+
effect: async ({ nodes: i, edges: l }, u) => {
|
|
501
|
+
if (!ft(u))
|
|
497
502
|
return;
|
|
498
|
-
const h =
|
|
503
|
+
const h = u.action;
|
|
499
504
|
if (!h) {
|
|
500
|
-
I("warn", `Action node ${
|
|
505
|
+
I("warn", `Action node ${u.id} has no action name`);
|
|
501
506
|
return;
|
|
502
507
|
}
|
|
503
|
-
const
|
|
504
|
-
if (!
|
|
508
|
+
const _ = t.actions.getByName(h).getState();
|
|
509
|
+
if (!_) {
|
|
505
510
|
I("warn", `Action '${h}' not registered on client`);
|
|
506
|
-
const
|
|
507
|
-
(w) => w.sourceNodeId ===
|
|
511
|
+
const k = l.find(
|
|
512
|
+
(w) => w.sourceNodeId === u.id && w.sourceNodeHandle === "false"
|
|
508
513
|
);
|
|
509
|
-
return
|
|
514
|
+
return k ? i.find((w) => w.id === k.destinationNodeId) : null;
|
|
510
515
|
}
|
|
511
|
-
if (typeof
|
|
516
|
+
if (typeof _.action != "function") {
|
|
512
517
|
I("warn", `Action '${h}' is not a function`);
|
|
513
|
-
const
|
|
514
|
-
(w) => w.sourceNodeId ===
|
|
518
|
+
const k = l.find(
|
|
519
|
+
(w) => w.sourceNodeId === u.id && w.sourceNodeHandle === "false"
|
|
515
520
|
);
|
|
516
|
-
return
|
|
521
|
+
return k ? i.find((w) => w.id === k.destinationNodeId) : null;
|
|
517
522
|
}
|
|
518
523
|
try {
|
|
519
|
-
I("info", `Executing action: ${h}`), await
|
|
520
|
-
const
|
|
521
|
-
(A) => A.sourceNodeId ===
|
|
524
|
+
I("info", `Executing action: ${h}`), await _.action(h);
|
|
525
|
+
const k = l.find(
|
|
526
|
+
(A) => A.sourceNodeId === u.id && A.sourceNodeHandle === "true"
|
|
522
527
|
);
|
|
523
|
-
if (!
|
|
524
|
-
return I("warn", `No 'true' edge found for action node ${
|
|
525
|
-
const w = i.find((A) => A.id ===
|
|
528
|
+
if (!k)
|
|
529
|
+
return I("warn", `No 'true' edge found for action node ${u.id}`), null;
|
|
530
|
+
const w = i.find((A) => A.id === k.destinationNodeId);
|
|
526
531
|
return I("info", `Action '${h}' succeeded, moving to node ${w?.id}`), w || null;
|
|
527
|
-
} catch (
|
|
528
|
-
I("warn", `Action '${h}' failed:`,
|
|
532
|
+
} catch (k) {
|
|
533
|
+
I("warn", `Action '${h}' failed:`, k);
|
|
529
534
|
const w = l.find(
|
|
530
|
-
(G) => G.sourceNodeId ===
|
|
535
|
+
(G) => G.sourceNodeId === u.id && G.sourceNodeHandle === "false"
|
|
531
536
|
);
|
|
532
537
|
if (!w)
|
|
533
|
-
return I("warn", `No 'false' edge found for action node ${
|
|
538
|
+
return I("warn", `No 'false' edge found for action node ${u.id}`), null;
|
|
534
539
|
const A = i.find((G) => G.id === w.destinationNodeId);
|
|
535
540
|
return I("info", `Action '${h}' failed, moving to node ${A?.id}`), A || null;
|
|
536
541
|
}
|
|
537
542
|
}
|
|
538
|
-
}),
|
|
543
|
+
}), Et = B((i) => {
|
|
539
544
|
ut(i) && t.experiences.launch({ id: i.experienceId });
|
|
540
545
|
}), rt = O({
|
|
541
546
|
source: [c, e.treeStore],
|
|
542
|
-
effect: async ([i, { nodes: l, edges:
|
|
547
|
+
effect: async ([i, { nodes: l, edges: u }]) => Z(i, l, u)
|
|
543
548
|
}), H = O({
|
|
544
549
|
source: [c, e.treeStore],
|
|
545
|
-
effect: async ([i, { nodes: l, edges:
|
|
546
|
-
}),
|
|
550
|
+
effect: async ([i, { nodes: l, edges: u }]) => Z(i, l, u)
|
|
551
|
+
}), It = B((i) => {
|
|
547
552
|
t.history.push({ experienceId: e.id, node: i });
|
|
548
553
|
}), ot = O({
|
|
549
554
|
source: e.configStore,
|
|
550
555
|
effect: async ({ initializeOpenLogic: i }) => n?.initialiseOpen !== void 0 ? n.initialiseOpen : $t(i) ? !!await at(t, i) : i ?? !1
|
|
551
556
|
}), $ = Object.freeze({
|
|
557
|
+
// eslint-disable-next-line sonarjs/pseudo-random -- non-security use: generating a unique runtime ID for UI tracking
|
|
552
558
|
id: Math.random().toString(36).substring(7),
|
|
553
559
|
// config
|
|
554
560
|
experienceId: e.id,
|
|
555
561
|
configStore: e.configStore,
|
|
556
562
|
target: r,
|
|
557
|
-
componentStore:
|
|
563
|
+
componentStore: x,
|
|
558
564
|
// state
|
|
559
565
|
stateStore: F,
|
|
560
566
|
// open close
|
|
@@ -567,25 +573,25 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
567
573
|
treeStore: e.treeStore,
|
|
568
574
|
fieldsStore: e.fieldsStore,
|
|
569
575
|
currentNodeStore: c,
|
|
570
|
-
currentStepStore:
|
|
571
|
-
previousStepStore:
|
|
576
|
+
currentStepStore: y,
|
|
577
|
+
previousStepStore: N,
|
|
572
578
|
nextReachableStepNodesStore: T,
|
|
573
579
|
stepsToOriginStore: C,
|
|
574
580
|
stepsToLeafStore: q,
|
|
575
581
|
// history
|
|
576
582
|
goToNextStep: a,
|
|
577
583
|
goToPreviousStep: o,
|
|
578
|
-
goToStepById:
|
|
584
|
+
goToStepById: f,
|
|
579
585
|
stepsHistoryStore: U
|
|
580
|
-
}), Q =
|
|
581
|
-
return
|
|
586
|
+
}), Q = b(), it = b();
|
|
587
|
+
return S({
|
|
582
588
|
source: c,
|
|
583
589
|
target: Q
|
|
584
|
-
}),
|
|
590
|
+
}), S({
|
|
585
591
|
clock: Q,
|
|
586
592
|
filter: (i) => i === null,
|
|
587
593
|
target: z
|
|
588
|
-
}),
|
|
594
|
+
}), S({
|
|
589
595
|
clock: Q,
|
|
590
596
|
filter: (i) => i !== null,
|
|
591
597
|
target: it
|
|
@@ -596,11 +602,11 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
596
602
|
origin: X,
|
|
597
603
|
condition: J,
|
|
598
604
|
step: et,
|
|
599
|
-
launchExperience:
|
|
605
|
+
launchExperience: Et,
|
|
600
606
|
action: nt,
|
|
601
|
-
__:
|
|
607
|
+
__: b()
|
|
602
608
|
}
|
|
603
|
-
}),
|
|
609
|
+
}), S({
|
|
604
610
|
clock: [
|
|
605
611
|
J.doneData,
|
|
606
612
|
X.doneData,
|
|
@@ -610,41 +616,41 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
610
616
|
nt.doneData
|
|
611
617
|
],
|
|
612
618
|
filter: Boolean,
|
|
613
|
-
target:
|
|
614
|
-
}),
|
|
619
|
+
target: It
|
|
620
|
+
}), S({
|
|
615
621
|
clock: a,
|
|
616
622
|
target: H
|
|
617
|
-
}),
|
|
623
|
+
}), S({
|
|
618
624
|
clock: a,
|
|
619
|
-
source:
|
|
625
|
+
source: y,
|
|
620
626
|
filter: Boolean,
|
|
621
627
|
target: t.eventBus.prepend((i) => ({
|
|
622
628
|
type: "step_submit",
|
|
623
629
|
step: i,
|
|
624
630
|
experience: $
|
|
625
631
|
}))
|
|
626
|
-
}),
|
|
632
|
+
}), S({
|
|
627
633
|
clock: H.done,
|
|
628
|
-
source:
|
|
634
|
+
source: y,
|
|
629
635
|
filter: Boolean,
|
|
630
636
|
target: t.eventBus.prepend((i) => ({
|
|
631
637
|
type: "step_submit_success",
|
|
632
638
|
step: i,
|
|
633
639
|
experience: $
|
|
634
640
|
}))
|
|
635
|
-
}),
|
|
641
|
+
}), S({
|
|
636
642
|
clock: H.fail,
|
|
637
|
-
source:
|
|
643
|
+
source: y,
|
|
638
644
|
filter: Boolean,
|
|
639
645
|
target: t.eventBus.prepend((i) => ({
|
|
640
646
|
type: "step_submit_error",
|
|
641
647
|
step: i,
|
|
642
648
|
experience: $
|
|
643
649
|
}))
|
|
644
|
-
}),
|
|
650
|
+
}), S({
|
|
645
651
|
clock: o,
|
|
646
652
|
target: xt
|
|
647
|
-
}),
|
|
653
|
+
}), S({ clock: f, target: Nt }), S({
|
|
648
654
|
source: D([
|
|
649
655
|
J.pending,
|
|
650
656
|
X.pending,
|
|
@@ -653,48 +659,48 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
653
659
|
]),
|
|
654
660
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
655
661
|
target: F
|
|
656
|
-
}),
|
|
662
|
+
}), S({
|
|
657
663
|
clock: et.doneData,
|
|
658
|
-
source:
|
|
664
|
+
source: y,
|
|
659
665
|
filter: Boolean,
|
|
660
666
|
target: t.eventBus.prepend((i) => ({
|
|
661
667
|
type: "step_enter",
|
|
662
668
|
step: i,
|
|
663
669
|
experience: $
|
|
664
670
|
}))
|
|
665
|
-
}),
|
|
666
|
-
clock:
|
|
671
|
+
}), S({
|
|
672
|
+
clock: g,
|
|
667
673
|
target: ot
|
|
668
|
-
}),
|
|
674
|
+
}), S({
|
|
669
675
|
source: ot.doneData,
|
|
670
676
|
fn: Boolean,
|
|
671
677
|
target: L
|
|
672
|
-
}),
|
|
678
|
+
}), S({
|
|
673
679
|
source: c,
|
|
674
680
|
clock: s,
|
|
675
681
|
filter: (i) => i ? Y(i) : !0,
|
|
676
682
|
target: rt
|
|
677
|
-
}),
|
|
683
|
+
}), S({
|
|
678
684
|
source: L,
|
|
679
685
|
filter: Boolean,
|
|
680
686
|
target: s
|
|
681
|
-
}),
|
|
687
|
+
}), S({
|
|
682
688
|
source: L,
|
|
683
689
|
filter: Boolean,
|
|
684
690
|
target: t.eventBus.prepend(() => ({
|
|
685
691
|
type: "experience_open",
|
|
686
692
|
experience: $
|
|
687
693
|
}))
|
|
688
|
-
}),
|
|
694
|
+
}), S({
|
|
689
695
|
source: L,
|
|
690
696
|
filter: (i) => !i,
|
|
691
697
|
target: t.eventBus.prepend(() => ({
|
|
692
698
|
type: "experience_close",
|
|
693
699
|
experience: $
|
|
694
700
|
}))
|
|
695
|
-
}),
|
|
701
|
+
}), S({
|
|
696
702
|
clock: d,
|
|
697
|
-
target: [
|
|
703
|
+
target: [g]
|
|
698
704
|
}), d(), $;
|
|
699
705
|
}
|
|
700
706
|
);
|
|
@@ -702,52 +708,52 @@ function qt(t) {
|
|
|
702
708
|
return pt(Vt, t);
|
|
703
709
|
}
|
|
704
710
|
const zt = dt(({ client: t }) => {
|
|
705
|
-
const e = tt.store({}), r =
|
|
706
|
-
register(c,
|
|
707
|
-
const
|
|
708
|
-
...c[
|
|
711
|
+
const e = tt.store({}), r = b(), n = b(), s = b(), a = lt(e, {
|
|
712
|
+
register(c, y) {
|
|
713
|
+
const N = [
|
|
714
|
+
...c[y.experienceId] ?? []
|
|
709
715
|
];
|
|
710
|
-
return
|
|
716
|
+
return N.push(y), {
|
|
711
717
|
...c,
|
|
712
|
-
[
|
|
718
|
+
[y.experienceId]: N
|
|
713
719
|
};
|
|
714
720
|
},
|
|
715
|
-
unregister(c,
|
|
716
|
-
const
|
|
717
|
-
(C) => C !==
|
|
721
|
+
unregister(c, y) {
|
|
722
|
+
const N = y.experienceId, T = c[N]?.filter(
|
|
723
|
+
(C) => C !== y
|
|
718
724
|
);
|
|
719
725
|
return {
|
|
720
726
|
...c,
|
|
721
|
-
[
|
|
727
|
+
[N]: T ?? []
|
|
722
728
|
};
|
|
723
729
|
}
|
|
724
|
-
}), o =
|
|
730
|
+
}), o = B(
|
|
725
731
|
({
|
|
726
732
|
experience: c,
|
|
727
|
-
target:
|
|
728
|
-
options:
|
|
729
|
-
}) => qt({ client: t, experience: c, target:
|
|
730
|
-
),
|
|
733
|
+
target: y,
|
|
734
|
+
options: N
|
|
735
|
+
}) => qt({ client: t, experience: c, target: y, options: N })
|
|
736
|
+
), f = B((c) => {
|
|
731
737
|
a.register(c);
|
|
732
|
-
}), d =
|
|
738
|
+
}), d = B(
|
|
733
739
|
(c) => {
|
|
734
740
|
c.target && Dt(c.target, () => {
|
|
735
741
|
s(c);
|
|
736
742
|
});
|
|
737
743
|
}
|
|
738
|
-
),
|
|
744
|
+
), g = B((c) => {
|
|
739
745
|
a.unregister(c);
|
|
740
|
-
}),
|
|
741
|
-
const
|
|
742
|
-
if (!
|
|
746
|
+
}), x = B((c) => {
|
|
747
|
+
const y = c.componentStore.getState();
|
|
748
|
+
if (!y) {
|
|
743
749
|
I("warn", "No app component registered. Skipping init.");
|
|
744
750
|
return;
|
|
745
751
|
}
|
|
746
|
-
const
|
|
747
|
-
if (!
|
|
752
|
+
const N = y.frameworkStore.getState();
|
|
753
|
+
if (!N) {
|
|
748
754
|
I(
|
|
749
755
|
"error",
|
|
750
|
-
`No framework registered for component '${
|
|
756
|
+
`No framework registered for component '${y.name}'. Skipping rendering.`
|
|
751
757
|
);
|
|
752
758
|
return;
|
|
753
759
|
}
|
|
@@ -761,40 +767,40 @@ const zt = dt(({ client: t }) => {
|
|
|
761
767
|
}
|
|
762
768
|
const C = Lt(T);
|
|
763
769
|
try {
|
|
764
|
-
|
|
770
|
+
N.render(C, y.component, t, c);
|
|
765
771
|
} catch (q) {
|
|
766
772
|
I("error", q);
|
|
767
773
|
}
|
|
768
774
|
});
|
|
769
|
-
|
|
775
|
+
S({
|
|
770
776
|
clock: r,
|
|
771
777
|
target: o
|
|
772
|
-
}),
|
|
778
|
+
}), S({
|
|
773
779
|
clock: s,
|
|
774
|
-
target:
|
|
775
|
-
}),
|
|
780
|
+
target: g
|
|
781
|
+
}), S({
|
|
776
782
|
clock: o.doneData,
|
|
777
783
|
target: [
|
|
778
|
-
|
|
784
|
+
f,
|
|
779
785
|
d,
|
|
780
786
|
n
|
|
781
787
|
]
|
|
782
|
-
}),
|
|
788
|
+
}), S({
|
|
783
789
|
clock: o.doneData,
|
|
784
790
|
target: t.eventBus.prepend((c) => ({
|
|
785
791
|
type: "experience_initialize",
|
|
786
792
|
experience: c
|
|
787
793
|
}))
|
|
788
|
-
}),
|
|
794
|
+
}), S({
|
|
789
795
|
clock: n,
|
|
790
|
-
target:
|
|
796
|
+
target: x
|
|
791
797
|
});
|
|
792
|
-
function F(c,
|
|
793
|
-
r({ experience: c, target:
|
|
798
|
+
function F(c, y, N) {
|
|
799
|
+
r({ experience: c, target: y, options: N });
|
|
794
800
|
}
|
|
795
801
|
const M = e.map((c) => Object.values(c).flat());
|
|
796
802
|
function U(c) {
|
|
797
|
-
return e.map((
|
|
803
|
+
return e.map((y) => y[c] || [], { skipVoid: !1 });
|
|
798
804
|
}
|
|
799
805
|
return {
|
|
800
806
|
spawn: F,
|