@picked/client 0.0.38-next.1 → 0.0.38-next.3
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/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/server/index.js +1 -1
- package/dist/esm/index.js +218 -217
- 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 +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-CsMhH0DN.cjs → experience-instance-CVIXiBiy.cjs} +1 -1
- package/dist/{experience-instance-CwXYJkRx.js → experience-instance-Dl8KzR7C.js} +1 -0
- package/dist/storage-Be5xWNPC.cjs +1 -0
- package/dist/storage-Co_LbKr_.js +239 -0
- package/dist/types/entities/experience/experience.d.ts +3 -0
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +3 -0
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/picked.d.ts +4 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts +357 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/storage-BLmAhfhl.js +0 -94
- package/dist/storage-YlR83AWP.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createDomain as b, createApi as F, createStore as H, createEffect as R, sample as I, attach as X, combine as O, createEvent as D } from "effector";
|
|
2
2
|
import { createFactory as w, invoke as v } from "@withease/factories";
|
|
3
|
-
import { g as q, t as Z, c as ee, i as te, e as j, a as re, b as ne, d as se } from "../experience-instance-
|
|
4
|
-
import { f as jt } from "../experience-instance-
|
|
3
|
+
import { g as q, t as Z, c as ee, i as te, e as j, a as re, b as ne, d as se } from "../experience-instance-Dl8KzR7C.js";
|
|
4
|
+
import { f as jt } from "../experience-instance-Dl8KzR7C.js";
|
|
5
5
|
import { l as k } from "../logger-C9a75KZn.js";
|
|
6
|
-
import { c as A, l as C, s as z } from "../storage-
|
|
7
|
-
import { a as At } from "../storage-
|
|
6
|
+
import { c as A, l as C, s as z } from "../storage-Co_LbKr_.js";
|
|
7
|
+
import { a as At } from "../storage-Co_LbKr_.js";
|
|
8
8
|
import { g as ie } from "../id-BW-g3y32.js";
|
|
9
9
|
import { i as oe } from "../object-JwZ58NOH.js";
|
|
10
10
|
import { s as U, a as V, b as ae, c as ce, d as ue } from "../supports-COb-sl36.js";
|
|
@@ -12,32 +12,33 @@ import { h as Rt, f as $t, j as Ct, e as zt, g as Ot, i as Dt, k as Ut } from ".
|
|
|
12
12
|
const K = b("experience"), de = w(
|
|
13
13
|
({ client: t, experience: e }) => {
|
|
14
14
|
const r = K.store(e), n = F(r, {
|
|
15
|
-
merge(
|
|
15
|
+
merge(p, h) {
|
|
16
16
|
return {
|
|
17
|
-
...
|
|
18
|
-
...
|
|
17
|
+
...p,
|
|
18
|
+
...h.experience
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
}), i = r.map((
|
|
22
|
-
name:
|
|
23
|
-
decisionLogic:
|
|
24
|
-
targetSelectors:
|
|
21
|
+
}), i = r.map((p) => ({
|
|
22
|
+
name: p.name,
|
|
23
|
+
decisionLogic: p.condition ?? p.decide,
|
|
24
|
+
targetSelectors: p.targets,
|
|
25
25
|
initializeOpenLogic: e.initializeOpen
|
|
26
|
-
})),
|
|
27
|
-
(
|
|
26
|
+
})), c = t.components.listStore.map(
|
|
27
|
+
(p) => p.find((h) => h.name === `experience:${e.id}`) || p.find((h) => h.name === "experience"),
|
|
28
28
|
{ skipVoid: !1 }
|
|
29
|
-
), o = r.map((
|
|
30
|
-
steps:
|
|
31
|
-
nodes:
|
|
32
|
-
edges:
|
|
33
|
-
conditionals:
|
|
34
|
-
})), s = e.actions ?? [];
|
|
29
|
+
), o = r.map((p) => ({
|
|
30
|
+
steps: p.steps,
|
|
31
|
+
nodes: p.nodes,
|
|
32
|
+
edges: p.edges,
|
|
33
|
+
conditionals: p.conditionals
|
|
34
|
+
})), s = r.map((p) => p.fields), d = e.actions ?? [];
|
|
35
35
|
return {
|
|
36
36
|
id: e.id,
|
|
37
37
|
configStore: i,
|
|
38
38
|
treeStore: o,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
fieldsStore: s,
|
|
40
|
+
componentStore: c,
|
|
41
|
+
actions: d,
|
|
41
42
|
merge: n.merge
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -60,16 +61,16 @@ const pe = w(({ client: t }) => {
|
|
|
60
61
|
s.merge({ experience: o, strategy: "override" });
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
const
|
|
64
|
-
r.register(
|
|
64
|
+
const d = le({ client: t, experience: o });
|
|
65
|
+
r.register(d);
|
|
65
66
|
}
|
|
66
67
|
const i = e.map((o) => Object.values(o));
|
|
67
|
-
function
|
|
68
|
+
function c(o) {
|
|
68
69
|
return e.map((s) => s[o], { skipVoid: !1 });
|
|
69
70
|
}
|
|
70
71
|
return {
|
|
71
72
|
register: n,
|
|
72
|
-
getById:
|
|
73
|
+
getById: c,
|
|
73
74
|
listStore: i
|
|
74
75
|
};
|
|
75
76
|
});
|
|
@@ -81,9 +82,9 @@ const ge = (t, e) => {
|
|
|
81
82
|
}, W = (t, e) => {
|
|
82
83
|
const { targetSelectors: r } = e.configStore.getState(), n = q(r, e.id);
|
|
83
84
|
n.forEach(
|
|
84
|
-
({ elements:
|
|
85
|
-
), ee(n, e.id).forEach((
|
|
86
|
-
t.experienceInstances.spawn(e,
|
|
85
|
+
({ elements: c }) => c.forEach((o) => Z(o, e.id))
|
|
86
|
+
), ee(n, e.id).forEach((c) => {
|
|
87
|
+
t.experienceInstances.spawn(e, c);
|
|
87
88
|
});
|
|
88
89
|
}, M = async (t) => {
|
|
89
90
|
await Promise.all(
|
|
@@ -97,8 +98,8 @@ const ge = (t, e) => {
|
|
|
97
98
|
}, he = (t, e, r) => {
|
|
98
99
|
const n = e.name, i = e.setup(t);
|
|
99
100
|
if (i) {
|
|
100
|
-
const
|
|
101
|
-
r[n] = Object.freeze({ ...
|
|
101
|
+
const c = r[n] ?? {};
|
|
102
|
+
r[n] = Object.freeze({ ...c, ...i });
|
|
102
103
|
}
|
|
103
104
|
}, ye = b("component"), Se = w(
|
|
104
105
|
({ client: t, component: e, name: r }) => {
|
|
@@ -127,16 +128,16 @@ const we = w(({ client: t }) => {
|
|
|
127
128
|
"warn",
|
|
128
129
|
`Component '${o}' already registered. Registering again will override the previous registration.`
|
|
129
130
|
);
|
|
130
|
-
const
|
|
131
|
-
r.register(
|
|
131
|
+
const p = ke({ client: t, name: o, component: s });
|
|
132
|
+
r.register(p);
|
|
132
133
|
}
|
|
133
134
|
const i = e.map((o) => Object.values(o));
|
|
134
|
-
function
|
|
135
|
+
function c(o) {
|
|
135
136
|
return e.map((s) => s[o], { skipVoid: !1 });
|
|
136
137
|
}
|
|
137
138
|
return {
|
|
138
139
|
register: n,
|
|
139
|
-
getByName:
|
|
140
|
+
getByName: c,
|
|
140
141
|
listStore: i
|
|
141
142
|
};
|
|
142
143
|
});
|
|
@@ -161,12 +162,12 @@ const T = (t, e, r) => {
|
|
|
161
162
|
), r.register({ name: o, framework: s });
|
|
162
163
|
}
|
|
163
164
|
const i = e.map((o) => Object.values(o));
|
|
164
|
-
function
|
|
165
|
+
function c(o) {
|
|
165
166
|
return e.map((s) => s[o], { skipVoid: !1 });
|
|
166
167
|
}
|
|
167
168
|
return {
|
|
168
169
|
register: n,
|
|
169
|
-
getByName:
|
|
170
|
+
getByName: c,
|
|
170
171
|
listStore: i
|
|
171
172
|
};
|
|
172
173
|
});
|
|
@@ -181,13 +182,13 @@ const Ee = (t, e) => {
|
|
|
181
182
|
let n = 0;
|
|
182
183
|
if (r.isSet() && (n = r.json() ?? 0), n && e - n < xe)
|
|
183
184
|
return !0;
|
|
184
|
-
const i = Pe(t.apiUrl),
|
|
185
|
+
const i = Pe(t.apiUrl), c = {
|
|
185
186
|
projectId: t.projectId,
|
|
186
187
|
path: window.location.pathname
|
|
187
|
-
}, o = JSON.stringify(
|
|
188
|
+
}, o = JSON.stringify(c), s = {
|
|
188
189
|
"Content-Type": "application/json"
|
|
189
|
-
},
|
|
190
|
-
|
|
190
|
+
}, p = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
191
|
+
p && (s["x-vercel-protection-bypass"] = p);
|
|
191
192
|
const S = (await fetch(i, {
|
|
192
193
|
method: "POST",
|
|
193
194
|
headers: s,
|
|
@@ -212,32 +213,32 @@ function Y(t) {
|
|
|
212
213
|
}
|
|
213
214
|
const Be = b("predicate"), Re = w(({ client: t }) => {
|
|
214
215
|
const e = Be.store({}), r = F(e, {
|
|
215
|
-
register(s,
|
|
216
|
+
register(s, d) {
|
|
216
217
|
return {
|
|
217
218
|
...s,
|
|
218
|
-
[
|
|
219
|
-
name:
|
|
220
|
-
predicate:
|
|
219
|
+
[d.name]: {
|
|
220
|
+
name: d.name,
|
|
221
|
+
predicate: d.predicate
|
|
221
222
|
}
|
|
222
223
|
};
|
|
223
224
|
}
|
|
224
225
|
});
|
|
225
|
-
function n(s,
|
|
226
|
+
function n(s, d) {
|
|
226
227
|
e.getState()[s] && k(
|
|
227
228
|
"warn",
|
|
228
229
|
`Predicate '${s}' already registered. Registering again will override the previous registration.`
|
|
229
|
-
), r.register(Object.freeze({ name: s, predicate:
|
|
230
|
+
), r.register(Object.freeze({ name: s, predicate: d }));
|
|
230
231
|
}
|
|
231
232
|
const i = e.map((s) => Object.values(s));
|
|
232
|
-
function
|
|
233
|
-
return e.map((
|
|
233
|
+
function c(s) {
|
|
234
|
+
return e.map((d) => d[s]?.predicate, { skipVoid: !1 });
|
|
234
235
|
}
|
|
235
236
|
function o(s) {
|
|
236
|
-
const
|
|
237
|
+
const d = H(() => {
|
|
237
238
|
}, {
|
|
238
239
|
skipVoid: !1
|
|
239
|
-
}),
|
|
240
|
-
const h =
|
|
240
|
+
}), p = R(async () => {
|
|
241
|
+
const h = c(s).getState();
|
|
241
242
|
if (!h)
|
|
242
243
|
return;
|
|
243
244
|
const S = Y(t);
|
|
@@ -245,16 +246,16 @@ const Be = b("predicate"), Re = w(({ client: t }) => {
|
|
|
245
246
|
});
|
|
246
247
|
return I({
|
|
247
248
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
248
|
-
target:
|
|
249
|
+
target: p
|
|
249
250
|
}), I({
|
|
250
|
-
clock:
|
|
251
|
+
clock: p.doneData,
|
|
251
252
|
filter: (h) => h !== void 0,
|
|
252
|
-
target:
|
|
253
|
-
}),
|
|
253
|
+
target: d
|
|
254
|
+
}), p(), d;
|
|
254
255
|
}
|
|
255
256
|
return {
|
|
256
257
|
register: n,
|
|
257
|
-
getByName:
|
|
258
|
+
getByName: c,
|
|
258
259
|
listStore: i,
|
|
259
260
|
getEvokablePredicate: o
|
|
260
261
|
};
|
|
@@ -266,157 +267,157 @@ const Ce = (t, e, r) => {
|
|
|
266
267
|
r.register(t, e);
|
|
267
268
|
}, _ = b("feature"), ze = w(({ client: t }) => {
|
|
268
269
|
const e = _.store({}), r = _.store([]), n = F(e, {
|
|
269
|
-
register(
|
|
270
|
+
register(a, u) {
|
|
270
271
|
return {
|
|
271
|
-
...
|
|
272
|
-
[
|
|
272
|
+
...a,
|
|
273
|
+
[u.id]: u.feature
|
|
273
274
|
};
|
|
274
275
|
}
|
|
275
276
|
});
|
|
276
|
-
function i(
|
|
277
|
-
e.getState()[
|
|
277
|
+
function i(a, u) {
|
|
278
|
+
e.getState()[a] && k(
|
|
278
279
|
"warn",
|
|
279
|
-
`Feature '${
|
|
280
|
+
`Feature '${a}' already registered. Registering again will override the previous registration.`
|
|
280
281
|
);
|
|
281
282
|
const l = {
|
|
282
|
-
id:
|
|
283
|
+
id: a,
|
|
283
284
|
feature: {
|
|
284
|
-
...
|
|
285
|
-
id:
|
|
285
|
+
...u,
|
|
286
|
+
id: a
|
|
286
287
|
}
|
|
287
288
|
};
|
|
288
289
|
n.register(
|
|
289
290
|
Object.freeze({
|
|
290
|
-
id:
|
|
291
|
+
id: a,
|
|
291
292
|
feature: l
|
|
292
293
|
})
|
|
293
294
|
);
|
|
294
295
|
}
|
|
295
|
-
const
|
|
296
|
+
const c = R(
|
|
296
297
|
async ({
|
|
297
|
-
id:
|
|
298
|
-
key:
|
|
299
|
-
storage:
|
|
298
|
+
id: a,
|
|
299
|
+
key: u,
|
|
300
|
+
storage: f = "local"
|
|
300
301
|
}) => {
|
|
301
|
-
const l = A(`feature:${
|
|
302
|
-
return y === null ? null : { id:
|
|
302
|
+
const l = A(`feature:${a}:${u}`, "global"), y = (f === "session" ? z : C).get(l).boolean();
|
|
303
|
+
return y === null ? null : { id: a, key: u, bucket: y, storage: f };
|
|
303
304
|
}
|
|
304
|
-
), o = R((
|
|
305
|
-
if (!
|
|
305
|
+
), o = R((a) => {
|
|
306
|
+
if (!a)
|
|
306
307
|
return null;
|
|
307
|
-
const
|
|
308
|
-
(
|
|
309
|
-
}), s = /* @__PURE__ */ new Map(),
|
|
308
|
+
const u = A(`feature:${a.id}:${a.key}`, "global");
|
|
309
|
+
(a.storage === "session" ? z : C).set(u, a.bucket);
|
|
310
|
+
}), s = /* @__PURE__ */ new Map(), d = X({
|
|
310
311
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
311
|
-
effect: async ({ allFeaturesStore:
|
|
312
|
-
const y =
|
|
313
|
-
(B) => B.id ===
|
|
312
|
+
effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: u }, { id: f, decide: l, key: m }) => {
|
|
313
|
+
const y = u.find(
|
|
314
|
+
(B) => B.id === f && B.key === m
|
|
314
315
|
);
|
|
315
316
|
if (y)
|
|
316
317
|
return y;
|
|
317
|
-
const E =
|
|
318
|
+
const E = a[f];
|
|
318
319
|
if (!E)
|
|
319
|
-
throw new Error(`Feature with id '${
|
|
320
|
-
const x = s.get(`${
|
|
320
|
+
throw new Error(`Feature with id '${f}' not found`);
|
|
321
|
+
const x = s.get(`${f}:${m}`);
|
|
321
322
|
if (x !== void 0) {
|
|
322
323
|
const B = await x;
|
|
323
324
|
return { id: E.id, bucket: B, key: m, storage: E.feature.storage };
|
|
324
325
|
}
|
|
325
326
|
const N = l();
|
|
326
|
-
s.set(`${
|
|
327
|
+
s.set(`${f}:${m}`, N);
|
|
327
328
|
const Q = await N;
|
|
328
329
|
return { id: E.id, bucket: Q, key: m, storage: E.feature.storage };
|
|
329
330
|
}
|
|
330
331
|
});
|
|
331
332
|
I({
|
|
332
333
|
clock: n.register,
|
|
333
|
-
fn: (
|
|
334
|
-
const { id:
|
|
335
|
-
return { id:
|
|
334
|
+
fn: (a) => {
|
|
335
|
+
const { id: u, feature: f } = a;
|
|
336
|
+
return { id: u, key: f.feature.key, storage: f.feature.storage };
|
|
336
337
|
},
|
|
337
|
-
target:
|
|
338
|
+
target: c
|
|
338
339
|
}), I({
|
|
339
340
|
source: e,
|
|
340
|
-
clock:
|
|
341
|
-
fn: (
|
|
342
|
-
const { id:
|
|
343
|
-
return y ? { key: y, id:
|
|
341
|
+
clock: d.doneData,
|
|
342
|
+
fn: (a, u) => {
|
|
343
|
+
const { id: f, bucket: l, storage: m } = u, y = a[f]?.feature.key;
|
|
344
|
+
return y ? { key: y, id: f, bucket: l, storage: m } : null;
|
|
344
345
|
},
|
|
345
346
|
target: o
|
|
346
347
|
});
|
|
347
|
-
const
|
|
348
|
+
const p = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
348
349
|
({
|
|
349
|
-
allFeaturesStore:
|
|
350
|
-
resolvedFeaturesStore:
|
|
351
|
-
}) => Object.values(
|
|
352
|
-
const l =
|
|
353
|
-
(m) => m.id ===
|
|
350
|
+
allFeaturesStore: a,
|
|
351
|
+
resolvedFeaturesStore: u
|
|
352
|
+
}) => Object.values(a).map((f) => {
|
|
353
|
+
const l = u.find(
|
|
354
|
+
(m) => m.id === f.id && m.key === f.feature.key
|
|
354
355
|
);
|
|
355
356
|
return l ? {
|
|
356
|
-
id:
|
|
357
|
-
name:
|
|
358
|
-
key:
|
|
359
|
-
getBucket: () => ({ id:
|
|
357
|
+
id: f.id,
|
|
358
|
+
name: f.feature.name,
|
|
359
|
+
key: f.feature.key,
|
|
360
|
+
getBucket: () => ({ id: f.id, bucket: l.bucket }),
|
|
360
361
|
isResolved: !0
|
|
361
362
|
} : {
|
|
362
|
-
id:
|
|
363
|
-
name:
|
|
364
|
-
key:
|
|
365
|
-
getBucket: async () => await
|
|
363
|
+
id: f.id,
|
|
364
|
+
name: f.feature.name,
|
|
365
|
+
key: f.feature.key,
|
|
366
|
+
getBucket: async () => await d(f.feature),
|
|
366
367
|
isResolved: !1
|
|
367
368
|
};
|
|
368
369
|
})
|
|
369
370
|
);
|
|
370
371
|
I({
|
|
371
|
-
clock:
|
|
372
|
+
clock: d.doneData,
|
|
372
373
|
source: { resolvedFeatures: r },
|
|
373
|
-
filter: ({ resolvedFeatures:
|
|
374
|
-
(m) => m.id ===
|
|
374
|
+
filter: ({ resolvedFeatures: a }, { id: u, key: f }) => !a.some(
|
|
375
|
+
(m) => m.id === u && m.key === f
|
|
375
376
|
),
|
|
376
|
-
fn: (
|
|
377
|
-
target: t.eventBus.prepend((
|
|
377
|
+
fn: (a, u) => u,
|
|
378
|
+
target: t.eventBus.prepend((a) => ({
|
|
378
379
|
type: "feature_decide",
|
|
379
|
-
feature:
|
|
380
|
+
feature: a
|
|
380
381
|
}))
|
|
381
382
|
}), I({
|
|
382
|
-
clock: [
|
|
383
|
+
clock: [c.doneData, d.doneData],
|
|
383
384
|
source: r,
|
|
384
|
-
fn: (
|
|
385
|
-
(l) => l.id ===
|
|
386
|
-
) ?
|
|
385
|
+
fn: (a, u) => !u || a.some(
|
|
386
|
+
(l) => l.id === u.id && l.key === u.key
|
|
387
|
+
) ? a : [...a, u],
|
|
387
388
|
target: r
|
|
388
389
|
});
|
|
389
|
-
function h(
|
|
390
|
-
return
|
|
390
|
+
function h(a) {
|
|
391
|
+
return p.map((u) => u.find((f) => f.id === a));
|
|
391
392
|
}
|
|
392
|
-
function S(
|
|
393
|
-
return e.map((
|
|
393
|
+
function S(a) {
|
|
394
|
+
return e.map((u) => u[a], { skipVoid: !1 });
|
|
394
395
|
}
|
|
395
|
-
function g(
|
|
396
|
-
const
|
|
396
|
+
function g(a) {
|
|
397
|
+
const u = H(
|
|
397
398
|
async () => {
|
|
398
399
|
},
|
|
399
400
|
{ skipVoid: !1 }
|
|
400
|
-
),
|
|
401
|
-
const l = h(
|
|
401
|
+
), f = R(async () => {
|
|
402
|
+
const l = h(a).getState();
|
|
402
403
|
if (l)
|
|
403
404
|
return async () => (await l.getBucket()).bucket;
|
|
404
405
|
});
|
|
405
406
|
return I({
|
|
406
407
|
source: r,
|
|
407
|
-
filter: (l) => l.some((m) => m.id ===
|
|
408
|
-
target:
|
|
408
|
+
filter: (l) => l.some((m) => m.id === a),
|
|
409
|
+
target: f
|
|
409
410
|
}), I({
|
|
410
|
-
clock:
|
|
411
|
+
clock: f.doneData,
|
|
411
412
|
filter: (l) => l !== void 0,
|
|
412
|
-
target:
|
|
413
|
-
}),
|
|
413
|
+
target: u
|
|
414
|
+
}), f(), u;
|
|
414
415
|
}
|
|
415
416
|
return {
|
|
416
417
|
register: i,
|
|
417
418
|
getById: h,
|
|
418
419
|
getByName: S,
|
|
419
|
-
listStore:
|
|
420
|
+
listStore: p,
|
|
420
421
|
getEvokableFeature: g
|
|
421
422
|
};
|
|
422
423
|
});
|
|
@@ -445,25 +446,25 @@ const Ue = w(() => {
|
|
|
445
446
|
L(s.experienceId, s.node)
|
|
446
447
|
]
|
|
447
448
|
})), t.on(i, (o, s) => s);
|
|
448
|
-
function
|
|
449
|
-
const
|
|
450
|
-
for (let
|
|
451
|
-
const h = o[
|
|
449
|
+
function c(o, s) {
|
|
450
|
+
const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
451
|
+
for (let p = o.length - 1; p >= 0; p--) {
|
|
452
|
+
const h = o[p], S = h?.node;
|
|
452
453
|
if (!(!S || !re(S)) && !(s && h?.experienceId !== s))
|
|
453
|
-
if (
|
|
454
|
-
|
|
454
|
+
if (d.lastStepIndex === -1)
|
|
455
|
+
d.lastStepIndex = p;
|
|
455
456
|
else {
|
|
456
|
-
|
|
457
|
+
d.secondLastStepIndex = p;
|
|
457
458
|
break;
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
|
-
return
|
|
461
|
+
return d;
|
|
461
462
|
}
|
|
462
463
|
return t.on(n, (o, s) => {
|
|
463
|
-
const { secondLastStepIndex:
|
|
464
|
+
const { secondLastStepIndex: d } = c(o.entries, s.experienceId), p = d !== -1 ? o.entries.slice(0, d + 1) : o.entries;
|
|
464
465
|
return {
|
|
465
466
|
...o,
|
|
466
|
-
entries:
|
|
467
|
+
entries: p
|
|
467
468
|
};
|
|
468
469
|
}), {
|
|
469
470
|
push: e,
|
|
@@ -478,36 +479,36 @@ function Ve() {
|
|
|
478
479
|
}
|
|
479
480
|
const Ne = () => D(), Me = b("field"), Te = w(() => {
|
|
480
481
|
const t = Me.store({}), e = F(t, {
|
|
481
|
-
register(s,
|
|
482
|
+
register(s, d) {
|
|
482
483
|
return {
|
|
483
484
|
...s,
|
|
484
|
-
[
|
|
485
|
+
[d.field.id]: d.field
|
|
485
486
|
};
|
|
486
487
|
}
|
|
487
488
|
});
|
|
488
489
|
function r(s) {
|
|
489
490
|
e.register({ field: s });
|
|
490
491
|
}
|
|
491
|
-
function n(s,
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
492
|
+
function n(s, d) {
|
|
493
|
+
const p = c(s).getState();
|
|
494
|
+
if (!p)
|
|
494
495
|
return;
|
|
495
|
-
const h = Object.assign({},
|
|
496
|
-
...
|
|
496
|
+
const h = Object.assign({}, p, {
|
|
497
|
+
...d
|
|
497
498
|
});
|
|
498
499
|
e.register({ field: { ...h } });
|
|
499
500
|
}
|
|
500
501
|
const i = t.map((s) => Object.values(s));
|
|
501
|
-
function
|
|
502
|
-
return t.map((
|
|
502
|
+
function c(s) {
|
|
503
|
+
return t.map((d) => d[s] || null);
|
|
503
504
|
}
|
|
504
505
|
function o(s) {
|
|
505
|
-
return t.map((
|
|
506
|
+
return t.map((d) => Object.values(d).find((p) => p.name === s) || null);
|
|
506
507
|
}
|
|
507
508
|
return {
|
|
508
509
|
register: r,
|
|
509
510
|
update: n,
|
|
510
|
-
getById:
|
|
511
|
+
getById: c,
|
|
511
512
|
listStore: i,
|
|
512
513
|
getByName: o
|
|
513
514
|
};
|
|
@@ -536,11 +537,11 @@ const Le = (t, e) => {
|
|
|
536
537
|
function i(o) {
|
|
537
538
|
return t.map((s) => s[o], { skipVoid: !1 });
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function c(o) {
|
|
540
541
|
return t.map(
|
|
541
542
|
(s) => {
|
|
542
|
-
const
|
|
543
|
-
return
|
|
543
|
+
const d = s[o];
|
|
544
|
+
return d ? d.action : void 0;
|
|
544
545
|
},
|
|
545
546
|
{ skipVoid: !1 }
|
|
546
547
|
);
|
|
@@ -549,7 +550,7 @@ const Le = (t, e) => {
|
|
|
549
550
|
register: r,
|
|
550
551
|
getByName: i,
|
|
551
552
|
listStore: n,
|
|
552
|
-
getEvokableAction:
|
|
553
|
+
getEvokableAction: c
|
|
553
554
|
};
|
|
554
555
|
});
|
|
555
556
|
function qe() {
|
|
@@ -563,45 +564,45 @@ function G(t) {
|
|
|
563
564
|
}
|
|
564
565
|
const We = b("response"), Ye = w(({ client: t }) => {
|
|
565
566
|
const e = We.store({}), r = D(), n = D(), i = F(e, {
|
|
566
|
-
register(g,
|
|
567
|
+
register(g, a) {
|
|
567
568
|
return {
|
|
568
569
|
...g,
|
|
569
|
-
[
|
|
570
|
+
[a.fieldId]: a.response
|
|
570
571
|
};
|
|
571
572
|
},
|
|
572
|
-
registerBatch(g,
|
|
573
|
+
registerBatch(g, a) {
|
|
573
574
|
return {
|
|
574
575
|
...g,
|
|
575
|
-
...
|
|
576
|
+
...a
|
|
576
577
|
};
|
|
577
578
|
},
|
|
578
|
-
clear(g,
|
|
579
|
-
const { [
|
|
580
|
-
return
|
|
579
|
+
clear(g, a) {
|
|
580
|
+
const { [a]: u, ...f } = g;
|
|
581
|
+
return f;
|
|
581
582
|
},
|
|
582
583
|
clearAll() {
|
|
583
584
|
return {};
|
|
584
585
|
}
|
|
585
586
|
});
|
|
586
|
-
function
|
|
587
|
+
function c(g, a) {
|
|
587
588
|
if (typeof g == "string") {
|
|
588
|
-
if (
|
|
589
|
+
if (a === void 0)
|
|
589
590
|
throw new Error("Response is required when registering a single field");
|
|
590
|
-
i.register({ fieldId: g, response:
|
|
591
|
+
i.register({ fieldId: g, response: a });
|
|
591
592
|
} else
|
|
592
593
|
i.registerBatch(g);
|
|
593
594
|
}
|
|
594
595
|
async function o(g) {
|
|
595
|
-
const
|
|
596
|
+
const a = [];
|
|
596
597
|
return await Promise.allSettled(
|
|
597
|
-
Object.entries(g).map(async ([
|
|
598
|
-
let l =
|
|
599
|
-
const m = t.fields.getById(
|
|
598
|
+
Object.entries(g).map(async ([u, f]) => {
|
|
599
|
+
let l = f;
|
|
600
|
+
const m = t.fields.getById(u).getState();
|
|
600
601
|
if (!m) {
|
|
601
|
-
|
|
602
|
-
fieldId:
|
|
603
|
-
userMessage: `Field '${
|
|
604
|
-
systemMessage: `No field with ID '${
|
|
602
|
+
a.push({
|
|
603
|
+
fieldId: u,
|
|
604
|
+
userMessage: `Field '${u}' not found`,
|
|
605
|
+
systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
605
606
|
value: l
|
|
606
607
|
});
|
|
607
608
|
return;
|
|
@@ -611,8 +612,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
611
612
|
$input: l
|
|
612
613
|
});
|
|
613
614
|
if (typeof y == "string") {
|
|
614
|
-
|
|
615
|
-
fieldId:
|
|
615
|
+
a.push({
|
|
616
|
+
fieldId: u,
|
|
616
617
|
userMessage: y,
|
|
617
618
|
systemMessage: `Field validation resulted in an error: ${y}.`,
|
|
618
619
|
value: l
|
|
@@ -620,8 +621,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
620
621
|
return;
|
|
621
622
|
}
|
|
622
623
|
if (y === !1) {
|
|
623
|
-
|
|
624
|
-
fieldId:
|
|
624
|
+
a.push({
|
|
625
|
+
fieldId: u,
|
|
625
626
|
userMessage: "This field is invalid",
|
|
626
627
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
627
628
|
value: l
|
|
@@ -630,8 +631,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
630
631
|
}
|
|
631
632
|
}
|
|
632
633
|
if (m.required && G(l)) {
|
|
633
|
-
|
|
634
|
-
fieldId:
|
|
634
|
+
a.push({
|
|
635
|
+
fieldId: u,
|
|
635
636
|
userMessage: "This field is required",
|
|
636
637
|
systemMessage: "Field is required.",
|
|
637
638
|
value: l
|
|
@@ -639,8 +640,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
639
640
|
return;
|
|
640
641
|
}
|
|
641
642
|
if (!m.multiple && Array.isArray(l) && l.length > 1) {
|
|
642
|
-
|
|
643
|
-
fieldId:
|
|
643
|
+
a.push({
|
|
644
|
+
fieldId: u,
|
|
644
645
|
userMessage: "This field expects a single response",
|
|
645
646
|
systemMessage: "Field expects a single response.",
|
|
646
647
|
value: l
|
|
@@ -649,33 +650,33 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
649
650
|
}
|
|
650
651
|
if (m.options) {
|
|
651
652
|
const y = m.options.map((x) => x.value), E = Array.isArray(l) ? l : [l];
|
|
652
|
-
Array.isArray(l) && (E.every((x) => y.includes(x)) ||
|
|
653
|
-
fieldId:
|
|
653
|
+
Array.isArray(l) && (E.every((x) => y.includes(x)) || a.push({
|
|
654
|
+
fieldId: u,
|
|
654
655
|
userMessage: "This field expects a valid option",
|
|
655
656
|
systemMessage: `Field expects a valid option. Valid options are: ${y.join(", ")}`,
|
|
656
657
|
value: l
|
|
657
658
|
}));
|
|
658
659
|
}
|
|
659
660
|
})
|
|
660
|
-
), { responsesToCommit: g, validationErrors:
|
|
661
|
+
), { responsesToCommit: g, validationErrors: a };
|
|
661
662
|
}
|
|
662
663
|
async function s(g) {
|
|
663
|
-
const { responsesToCommit:
|
|
664
|
-
return
|
|
664
|
+
const { responsesToCommit: a, validationErrors: u } = await o(g);
|
|
665
|
+
return u.length ? { errors: u } : (i.registerBatch(a), { errors: [] });
|
|
665
666
|
}
|
|
666
|
-
const
|
|
667
|
-
fieldId:
|
|
668
|
-
value: g[
|
|
667
|
+
const d = e.map((g) => g), p = e.map((g) => Object.keys(g).map((u) => ({
|
|
668
|
+
fieldId: u,
|
|
669
|
+
value: g[u]
|
|
669
670
|
})));
|
|
670
671
|
function h(g) {
|
|
671
|
-
const
|
|
672
|
-
return O({ f:
|
|
672
|
+
const a = t.fields.getById(g), u = e.map((f) => f[g] || null);
|
|
673
|
+
return O({ f: a, r: u }, ({ f, r: l }) => l || (f?.defaultValue ? f.defaultValue : null));
|
|
673
674
|
}
|
|
674
675
|
function S(g) {
|
|
675
|
-
const
|
|
676
|
-
return O({ f:
|
|
677
|
-
const l =
|
|
678
|
-
return l || (
|
|
676
|
+
const a = t.fields.getByName(g);
|
|
677
|
+
return O({ f: a, s: e }, ({ f: u, s: f }) => {
|
|
678
|
+
const l = u && f[u.id] || null;
|
|
679
|
+
return l || (u?.defaultValue ? u.defaultValue : null);
|
|
679
680
|
});
|
|
680
681
|
}
|
|
681
682
|
return I({
|
|
@@ -685,13 +686,13 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
685
686
|
clock: n,
|
|
686
687
|
target: i.clear
|
|
687
688
|
}), {
|
|
688
|
-
register:
|
|
689
|
+
register: c,
|
|
689
690
|
clearAll: r,
|
|
690
691
|
clear: n,
|
|
691
692
|
commit: s,
|
|
692
693
|
getResponsesToCommit: o,
|
|
693
|
-
listStore:
|
|
694
|
-
getAllStore:
|
|
694
|
+
listStore: p,
|
|
695
|
+
getAllStore: d,
|
|
695
696
|
getByFieldId: h,
|
|
696
697
|
getByFieldName: S
|
|
697
698
|
};
|
|
@@ -699,7 +700,7 @@ const We = b("response"), Ye = w(({ client: t }) => {
|
|
|
699
700
|
function Je(t) {
|
|
700
701
|
return v(Ye, t);
|
|
701
702
|
}
|
|
702
|
-
const Qe = () => "0.0.38-next.
|
|
703
|
+
const Qe = () => "0.0.38-next.3";
|
|
703
704
|
function Xe() {
|
|
704
705
|
if (U()) {
|
|
705
706
|
const t = [
|
|
@@ -722,8 +723,8 @@ function Ze() {
|
|
|
722
723
|
for (const [i] of t.entries())
|
|
723
724
|
i.startsWith("picked-") && r.add(i);
|
|
724
725
|
for (const i of r) {
|
|
725
|
-
const
|
|
726
|
-
e[
|
|
726
|
+
const c = i.replace("picked-", "");
|
|
727
|
+
e[c] = t.getAll(i);
|
|
727
728
|
}
|
|
728
729
|
const n = A("s");
|
|
729
730
|
if (r.size > 0)
|
|
@@ -756,12 +757,12 @@ const tt = A("session", "global"), rt = () => {
|
|
|
756
757
|
setIsUser(i) {
|
|
757
758
|
this.isUser = i, r(this);
|
|
758
759
|
},
|
|
759
|
-
setIdentifier(i,
|
|
760
|
-
this.identifiers = { ...this.identifiers, [i]:
|
|
760
|
+
setIdentifier(i, c) {
|
|
761
|
+
this.identifiers = { ...this.identifiers, [i]: c }, r(this);
|
|
761
762
|
},
|
|
762
763
|
removeIdentifier(i) {
|
|
763
764
|
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
764
|
-
Object.entries(this.identifiers).filter(([
|
|
765
|
+
Object.entries(this.identifiers).filter(([c]) => c !== i)
|
|
765
766
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
766
767
|
}
|
|
767
768
|
};
|
|
@@ -840,11 +841,11 @@ function dt(t, e) {
|
|
|
840
841
|
return typeof r == "function" ? r() : r;
|
|
841
842
|
}
|
|
842
843
|
function lt(t, e) {
|
|
843
|
-
const r = t.split("|").map((
|
|
844
|
+
const r = t.split("|").map((c) => c.trim()), n = r.shift() ?? "";
|
|
844
845
|
let i = dt(n, e);
|
|
845
|
-
for (const
|
|
846
|
-
const [o, ...s] =
|
|
847
|
-
h && (i = h(i,
|
|
846
|
+
for (const c of r) {
|
|
847
|
+
const [o, ...s] = c.split(":"), d = o?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = ct[d];
|
|
848
|
+
h && (i = h(i, p));
|
|
848
849
|
}
|
|
849
850
|
return $(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
|
|
850
851
|
}
|
|
@@ -905,8 +906,8 @@ class ft {
|
|
|
905
906
|
r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await j(this, this.condition) === !0);
|
|
906
907
|
const i = r && n === !0;
|
|
907
908
|
if (typeof n == "boolean" && this.session) {
|
|
908
|
-
const
|
|
909
|
-
this.session.setIsUser(
|
|
909
|
+
const c = n;
|
|
910
|
+
this.session.setIsUser(c), this.eventBus({ type: "user_decide", value: c });
|
|
910
911
|
}
|
|
911
912
|
this.eventBus({ type: "initialize" }), document.body && i && M(this), await se(), i && M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
912
913
|
})();
|
|
@@ -981,13 +982,13 @@ class ft {
|
|
|
981
982
|
const [n, i] = r.split(":");
|
|
982
983
|
if (!n || !i)
|
|
983
984
|
return;
|
|
984
|
-
let
|
|
985
|
-
|
|
986
|
-
key: `${
|
|
985
|
+
let c = i;
|
|
986
|
+
c === "true" && (c = !0), c === "false" && (c = !1), this.registerFeature(n, {
|
|
987
|
+
key: `${c}`,
|
|
987
988
|
// use the assigned bucket value as the key
|
|
988
989
|
name: n,
|
|
989
990
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
990
|
-
decide: () =>
|
|
991
|
+
decide: () => c,
|
|
991
992
|
storage: "session"
|
|
992
993
|
});
|
|
993
994
|
} catch {
|
|
@@ -1060,7 +1061,7 @@ class ft {
|
|
|
1060
1061
|
* // => "Fruits: apple, banana, and cherry"
|
|
1061
1062
|
*/
|
|
1062
1063
|
renderString = (e, r) => {
|
|
1063
|
-
const n = this.responses.listStore.getState().reduce((i,
|
|
1064
|
+
const n = this.responses.listStore.getState().reduce((i, c) => (i[c.fieldId] = c.value, i), {});
|
|
1064
1065
|
return pt(e, {
|
|
1065
1066
|
...r,
|
|
1066
1067
|
responses: n
|
|
@@ -1081,8 +1082,8 @@ async function bt(t, e) {
|
|
|
1081
1082
|
if (!n.options || !J(n))
|
|
1082
1083
|
return n;
|
|
1083
1084
|
const o = (await Promise.all(
|
|
1084
|
-
n.options.map(async (
|
|
1085
|
-
)).filter((
|
|
1085
|
+
n.options.map(async (d) => d.condition ? await j(t, d.condition) ? d : null : d)
|
|
1086
|
+
)).filter((d) => d !== null);
|
|
1086
1087
|
return o.length === n.options.length ? n : o.length === 0 ? null : { ...n, options: o };
|
|
1087
1088
|
})
|
|
1088
1089
|
)).filter((n) => n !== null);
|