@picked/client 0.0.6 → 0.0.7-next.1
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 +1 -1
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +263 -244
- package/dist/esm/plugins/create-experience/index.js +34 -32
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DYZovD6a.js → experience-instance-C1Ky25uw.js} +17 -16
- package/dist/{experience-instance-DwO_yZK0.cjs → experience-instance-DNI5sbjx.cjs} +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/entities/field/field.d.ts +1 -0
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +8 -0
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts +12 -6
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +2 -0
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/utils/get-step-fields.d.ts +4 -0
- package/dist/types/utils/get-step-fields.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var q = Object.defineProperty;
|
|
2
2
|
var W = (t, e, s) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
|
-
var
|
|
4
|
-
import { createDomain as
|
|
5
|
-
import { createFactory as
|
|
6
|
-
import { g as z, t as J, c as Y, e as
|
|
7
|
-
import { f as
|
|
8
|
-
import { l as
|
|
9
|
-
import { c as j, s as
|
|
10
|
-
import { a as
|
|
3
|
+
var y = (t, e, s) => W(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { createDomain as F, createApi as b, createEffect as D, attach as G, sample as P, combine as A, createEvent as C } from "effector";
|
|
5
|
+
import { createFactory as k, invoke as x } from "@withease/factories";
|
|
6
|
+
import { g as z, t as J, c as Y, e as B, i as Q, a as X, b as Z, d as ee } from "../experience-instance-C1Ky25uw.js";
|
|
7
|
+
import { f as ot } from "../experience-instance-C1Ky25uw.js";
|
|
8
|
+
import { l as v } from "../logger-C9a75KZn.js";
|
|
9
|
+
import { c as j, s as R, l as O } from "../storage-D87xFySf.js";
|
|
10
|
+
import { a as at } from "../storage-D87xFySf.js";
|
|
11
11
|
import { g as te } from "../id-BW-g3y32.js";
|
|
12
12
|
import { i as re } from "../object-JwZ58NOH.js";
|
|
13
13
|
import { s as _, a as se, b as ne } from "../supports-yKVnaaMQ.js";
|
|
14
|
-
import { g as
|
|
15
|
-
const U =
|
|
14
|
+
import { g as ut, d as lt, i as dt, e as pt, c as gt, f as ft, h as mt, j as yt } from "../supports-yKVnaaMQ.js";
|
|
15
|
+
const U = F("experience"), oe = k(
|
|
16
16
|
({ client: t, experience: e }) => {
|
|
17
17
|
const s = U.store(e), o = b(s, {
|
|
18
18
|
merge(n, g) {
|
|
@@ -26,7 +26,7 @@ const U = x("experience"), oe = v(
|
|
|
26
26
|
name: n.name,
|
|
27
27
|
decisionLogic: n.decide,
|
|
28
28
|
targetSelectors: n.targets
|
|
29
|
-
})),
|
|
29
|
+
})), l = t.components.listStore.map(
|
|
30
30
|
(n) => n.find((g) => g.name === `experience:${e.id}`) || n.find((g) => g.name === "experience"),
|
|
31
31
|
{ skipVoid: !1 }
|
|
32
32
|
), r = s.map((n) => ({
|
|
@@ -39,15 +39,15 @@ const U = x("experience"), oe = v(
|
|
|
39
39
|
id: e.id,
|
|
40
40
|
configStore: i,
|
|
41
41
|
treeStore: r,
|
|
42
|
-
componentStore:
|
|
42
|
+
componentStore: l,
|
|
43
43
|
merge: o.merge
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
function ie(t) {
|
|
48
|
-
return
|
|
48
|
+
return x(oe, t);
|
|
49
49
|
}
|
|
50
|
-
const ae =
|
|
50
|
+
const ae = k(({ client: t }) => {
|
|
51
51
|
const e = U.store({}), s = b(e, {
|
|
52
52
|
register(r, n) {
|
|
53
53
|
return {
|
|
@@ -66,28 +66,28 @@ const ae = v(({ client: t }) => {
|
|
|
66
66
|
s.register(g);
|
|
67
67
|
}
|
|
68
68
|
const i = e.map((r) => Object.values(r));
|
|
69
|
-
function
|
|
69
|
+
function l(r) {
|
|
70
70
|
return e.map((n) => n[r], { skipVoid: !1 });
|
|
71
71
|
}
|
|
72
72
|
return {
|
|
73
73
|
register: o,
|
|
74
|
-
getById:
|
|
74
|
+
getById: l,
|
|
75
75
|
listStore: i
|
|
76
76
|
};
|
|
77
77
|
});
|
|
78
78
|
function ce(t) {
|
|
79
|
-
return
|
|
79
|
+
return x(ae, t);
|
|
80
80
|
}
|
|
81
81
|
const ue = (t, e) => {
|
|
82
82
|
e.register(t);
|
|
83
83
|
}, H = (t, e) => {
|
|
84
84
|
const { targetSelectors: s } = e.configStore.getState(), o = z(s, e.id);
|
|
85
85
|
o.forEach(
|
|
86
|
-
({ elements:
|
|
87
|
-
), Y(o, e.id).forEach((
|
|
88
|
-
t.experienceInstances.spawn(e,
|
|
86
|
+
({ elements: l }) => l.forEach((r) => J(r, e.id))
|
|
87
|
+
), Y(o, e.id).forEach((l) => {
|
|
88
|
+
t.experienceInstances.spawn(e, l);
|
|
89
89
|
});
|
|
90
|
-
},
|
|
90
|
+
}, T = async (t) => {
|
|
91
91
|
await Promise.all(
|
|
92
92
|
t.experiences.listStore.getState().map(async (e) => {
|
|
93
93
|
await le(t, e) && H(t, e);
|
|
@@ -95,14 +95,14 @@ const ue = (t, e) => {
|
|
|
95
95
|
);
|
|
96
96
|
}, le = async (t, e) => {
|
|
97
97
|
const { type: s, decisionLogic: o, targetSelectors: i } = e.configStore.getState();
|
|
98
|
-
return z(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await
|
|
98
|
+
return z(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await B(t, o) === !0 : !1 : i.length === 0 ? !1 : Q(o) ? await B(t, o) === !0 : !0;
|
|
99
99
|
}, de = (t, e, s) => {
|
|
100
100
|
const o = e.name, i = e.setup(t);
|
|
101
101
|
if (i) {
|
|
102
|
-
const
|
|
103
|
-
s[o] = Object.freeze({ ...
|
|
102
|
+
const l = s[o] ?? {};
|
|
103
|
+
s[o] = Object.freeze({ ...l, ...i });
|
|
104
104
|
}
|
|
105
|
-
}, pe =
|
|
105
|
+
}, pe = F("component"), ge = k(
|
|
106
106
|
({ client: t, component: e, name: s }) => {
|
|
107
107
|
const o = t.frameworks.getByName(e.frameworkName);
|
|
108
108
|
return {
|
|
@@ -113,9 +113,9 @@ const ue = (t, e) => {
|
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
function fe(t) {
|
|
116
|
-
return
|
|
116
|
+
return x(ge, t);
|
|
117
117
|
}
|
|
118
|
-
const me =
|
|
118
|
+
const me = k(({ client: t }) => {
|
|
119
119
|
const e = pe.store({}), s = b(e, {
|
|
120
120
|
register(r, n) {
|
|
121
121
|
return {
|
|
@@ -125,7 +125,7 @@ const me = v(({ client: t }) => {
|
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
function o(r, n) {
|
|
128
|
-
e.getState()[r] &&
|
|
128
|
+
e.getState()[r] && v(
|
|
129
129
|
"warn",
|
|
130
130
|
`Component '${r}' already registered. Registering again will override the previous registration.`
|
|
131
131
|
);
|
|
@@ -133,21 +133,21 @@ const me = v(({ client: t }) => {
|
|
|
133
133
|
s.register(h);
|
|
134
134
|
}
|
|
135
135
|
const i = e.map((r) => Object.values(r));
|
|
136
|
-
function
|
|
136
|
+
function l(r) {
|
|
137
137
|
return e.map((n) => n[r], { skipVoid: !1 });
|
|
138
138
|
}
|
|
139
139
|
return {
|
|
140
140
|
register: o,
|
|
141
|
-
getByName:
|
|
141
|
+
getByName: l,
|
|
142
142
|
listStore: i
|
|
143
143
|
};
|
|
144
144
|
});
|
|
145
145
|
function ye(t) {
|
|
146
|
-
return
|
|
146
|
+
return x(me, t);
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const V = (t, e, s) => {
|
|
149
149
|
s.register(t, e);
|
|
150
|
-
}, he =
|
|
150
|
+
}, he = F("framework"), Se = k(({ client: t }) => {
|
|
151
151
|
const e = he.store({}), s = b(e, {
|
|
152
152
|
register(r, n) {
|
|
153
153
|
return {
|
|
@@ -157,49 +157,49 @@ const M = (t, e, s) => {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
function o(r, n) {
|
|
160
|
-
e.getState()[r] &&
|
|
160
|
+
e.getState()[r] && v(
|
|
161
161
|
"warn",
|
|
162
162
|
`Framework '${r}' already registered. Registering again will override the previous registration.`
|
|
163
163
|
), s.register({ name: r, framework: n });
|
|
164
164
|
}
|
|
165
165
|
const i = e.map((r) => Object.values(r));
|
|
166
|
-
function
|
|
166
|
+
function l(r) {
|
|
167
167
|
return e.map((n) => n[r], { skipVoid: !1 });
|
|
168
168
|
}
|
|
169
169
|
return {
|
|
170
170
|
register: o,
|
|
171
|
-
getByName:
|
|
171
|
+
getByName: l,
|
|
172
172
|
listStore: i
|
|
173
173
|
};
|
|
174
174
|
});
|
|
175
175
|
function we(t) {
|
|
176
|
-
return
|
|
176
|
+
return x(Se, t);
|
|
177
177
|
}
|
|
178
178
|
const ve = (t, e) => {
|
|
179
179
|
e.register(t.name, t);
|
|
180
|
-
}, ke = 6e3,
|
|
180
|
+
}, ke = 6e3, M = j("last_ping", "global"), xe = (t) => `${t}/api/v1/ping`, Fe = async (t) => {
|
|
181
181
|
try {
|
|
182
|
-
const e = Date.now(), s = localStorage.getItem(
|
|
182
|
+
const e = Date.now(), s = localStorage.getItem(M);
|
|
183
183
|
if (s && e - parseInt(s) < ke)
|
|
184
184
|
return !0;
|
|
185
185
|
const o = xe(t.apiUrl), i = {
|
|
186
186
|
projectId: t.projectId,
|
|
187
187
|
path: window.location.pathname
|
|
188
|
-
},
|
|
188
|
+
}, l = JSON.stringify(i), r = {
|
|
189
189
|
"Content-Type": "application/json"
|
|
190
190
|
}, n = document.getElementById("picked_script"), g = n == null ? void 0 : n.dataset.verceltoken;
|
|
191
191
|
g && (r["x-vercel-protection-bypass"] = g);
|
|
192
|
-
const
|
|
192
|
+
const c = (await fetch(o, {
|
|
193
193
|
method: "POST",
|
|
194
194
|
headers: r,
|
|
195
|
-
body:
|
|
195
|
+
body: l
|
|
196
196
|
})).ok;
|
|
197
|
-
return
|
|
197
|
+
return c && localStorage.setItem(M, e.toString()), c;
|
|
198
198
|
} catch (e) {
|
|
199
|
-
return
|
|
199
|
+
return v("error", e), !1;
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
|
-
function
|
|
202
|
+
function be(t) {
|
|
203
203
|
const e = typeof window < "u", s = {
|
|
204
204
|
client: t,
|
|
205
205
|
responses: t.responses.listStore.getState(),
|
|
@@ -211,7 +211,7 @@ function Fe(t) {
|
|
|
211
211
|
};
|
|
212
212
|
return Object.freeze(s);
|
|
213
213
|
}
|
|
214
|
-
const Ie =
|
|
214
|
+
const Ie = F("predicate"), Ee = k(({ client: t }) => {
|
|
215
215
|
const e = Ie.store({}), s = b(e, {
|
|
216
216
|
register(r, n) {
|
|
217
217
|
return {
|
|
@@ -224,122 +224,122 @@ const Ie = x("predicate"), Ee = v(({ client: t }) => {
|
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
226
|
function o(r, n) {
|
|
227
|
-
e.getState()[r] &&
|
|
227
|
+
e.getState()[r] && v(
|
|
228
228
|
"warn",
|
|
229
229
|
`Predicate '${r}' already registered. Registering again will override the previous registration.`
|
|
230
230
|
), s.register(Object.freeze({ name: r, predicate: n }));
|
|
231
231
|
}
|
|
232
232
|
const i = e.map((r) => Object.values(r));
|
|
233
|
-
function
|
|
233
|
+
function l(r) {
|
|
234
234
|
return e.map((n) => n[r], { skipVoid: !1 });
|
|
235
235
|
}
|
|
236
236
|
return {
|
|
237
237
|
register: o,
|
|
238
|
-
getByName:
|
|
238
|
+
getByName: l,
|
|
239
239
|
listStore: i
|
|
240
240
|
};
|
|
241
241
|
});
|
|
242
242
|
function Pe(t) {
|
|
243
|
-
return
|
|
243
|
+
return x(Ee, t);
|
|
244
244
|
}
|
|
245
|
-
const
|
|
245
|
+
const Be = (t, e, s) => {
|
|
246
246
|
s.register(t, e);
|
|
247
|
-
},
|
|
248
|
-
const t =
|
|
249
|
-
register(
|
|
247
|
+
}, N = F("feature"), je = k(() => {
|
|
248
|
+
const t = N.store({}), e = N.store([]), s = b(t, {
|
|
249
|
+
register(c, f) {
|
|
250
250
|
return {
|
|
251
|
-
...
|
|
252
|
-
[
|
|
251
|
+
...c,
|
|
252
|
+
[f.id]: f.feature
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
255
|
});
|
|
256
|
-
function o(
|
|
257
|
-
t.getState()[
|
|
256
|
+
function o(c, f) {
|
|
257
|
+
t.getState()[c] && v(
|
|
258
258
|
"warn",
|
|
259
|
-
`Feature '${
|
|
259
|
+
`Feature '${c}' already registered. Registering again will override the previous registration.`
|
|
260
260
|
);
|
|
261
|
-
const
|
|
262
|
-
id:
|
|
261
|
+
const d = {
|
|
262
|
+
id: c,
|
|
263
263
|
feature: {
|
|
264
|
-
...
|
|
265
|
-
id:
|
|
264
|
+
...f,
|
|
265
|
+
id: c
|
|
266
266
|
}
|
|
267
267
|
};
|
|
268
268
|
s.register(
|
|
269
269
|
Object.freeze({
|
|
270
|
-
id:
|
|
271
|
-
feature:
|
|
270
|
+
id: c,
|
|
271
|
+
feature: d
|
|
272
272
|
})
|
|
273
273
|
);
|
|
274
274
|
}
|
|
275
|
-
const i =
|
|
275
|
+
const i = D(
|
|
276
276
|
async ({
|
|
277
|
-
id:
|
|
278
|
-
key:
|
|
277
|
+
id: c,
|
|
278
|
+
key: f,
|
|
279
279
|
storage: a = "local"
|
|
280
280
|
}) => {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
return { id:
|
|
281
|
+
const d = j(`feature:${c}:${f}`, "global"), m = (a === "session" ? R : O).get(d).boolean();
|
|
282
|
+
if (m !== null)
|
|
283
|
+
return { id: c, bucket: m };
|
|
284
284
|
}
|
|
285
|
-
),
|
|
286
|
-
if (!
|
|
285
|
+
), l = D((c) => {
|
|
286
|
+
if (!c)
|
|
287
287
|
return null;
|
|
288
|
-
const
|
|
289
|
-
(
|
|
288
|
+
const f = j(`feature:${c.id}:${c.key}`, "global");
|
|
289
|
+
(c.storage === "session" ? R : O).set(f, c.bucket);
|
|
290
290
|
}), r = /* @__PURE__ */ new Map(), n = G({
|
|
291
291
|
source: { allFeaturesStore: t, resolvedFeaturesStore: e },
|
|
292
|
-
effect: async ({ allFeaturesStore:
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
return
|
|
296
|
-
const
|
|
297
|
-
if (!
|
|
292
|
+
effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: f }, { id: a, decide: d, key: p }) => {
|
|
293
|
+
const m = f.find((I) => I.id === a);
|
|
294
|
+
if (m)
|
|
295
|
+
return m;
|
|
296
|
+
const u = c[a];
|
|
297
|
+
if (!u)
|
|
298
298
|
throw new Error(`Feature with id '${a}' not found`);
|
|
299
|
-
const S = r.get(`${a}:${
|
|
299
|
+
const S = r.get(`${a}:${p}`);
|
|
300
300
|
if (S) {
|
|
301
|
-
const
|
|
302
|
-
return { id:
|
|
301
|
+
const I = await S;
|
|
302
|
+
return { id: u.id, bucket: I, storage: u.feature.storage };
|
|
303
303
|
}
|
|
304
|
-
const
|
|
305
|
-
r.set(`${a}:${
|
|
306
|
-
const
|
|
307
|
-
return { id:
|
|
304
|
+
const w = d();
|
|
305
|
+
r.set(`${a}:${p}`, w);
|
|
306
|
+
const $ = await w;
|
|
307
|
+
return { id: u.id, bucket: $, storage: u.feature.storage };
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
|
|
310
|
+
P({
|
|
311
311
|
clock: s.register,
|
|
312
|
-
fn: (
|
|
313
|
-
const { id:
|
|
314
|
-
return { id:
|
|
312
|
+
fn: (c) => {
|
|
313
|
+
const { id: f, feature: a } = c;
|
|
314
|
+
return { id: f, key: a.feature.key, storage: a.feature.storage };
|
|
315
315
|
},
|
|
316
316
|
target: i
|
|
317
|
-
}),
|
|
317
|
+
}), P({
|
|
318
318
|
source: e,
|
|
319
319
|
clock: [i.doneData, n.doneData],
|
|
320
|
-
fn: (
|
|
320
|
+
fn: (c, f) => !f || c.some((a) => a.id === f.id) ? c : [...c, f],
|
|
321
321
|
target: e
|
|
322
|
-
}),
|
|
322
|
+
}), P({
|
|
323
323
|
source: t,
|
|
324
324
|
clock: n.doneData,
|
|
325
|
-
fn: (
|
|
326
|
-
var
|
|
327
|
-
const { id: a, bucket:
|
|
328
|
-
return
|
|
325
|
+
fn: (c, f) => {
|
|
326
|
+
var u;
|
|
327
|
+
const { id: a, bucket: d, storage: p } = f, m = (u = c[a]) == null ? void 0 : u.feature.key;
|
|
328
|
+
return m ? { key: m, id: a, bucket: d, storage: p } : null;
|
|
329
329
|
},
|
|
330
|
-
target:
|
|
330
|
+
target: l
|
|
331
331
|
});
|
|
332
|
-
const g =
|
|
332
|
+
const g = A({ allFeaturesStore: t, resolvedFeaturesStore: e }).map(
|
|
333
333
|
({
|
|
334
|
-
allFeaturesStore:
|
|
335
|
-
resolvedFeaturesStore:
|
|
336
|
-
}) => Object.values(
|
|
337
|
-
const
|
|
338
|
-
return
|
|
334
|
+
allFeaturesStore: c,
|
|
335
|
+
resolvedFeaturesStore: f
|
|
336
|
+
}) => Object.values(c).map((a) => {
|
|
337
|
+
const d = f.find((p) => p.id === a.id);
|
|
338
|
+
return d ? {
|
|
339
339
|
id: a.id,
|
|
340
340
|
name: a.feature.name,
|
|
341
341
|
key: a.feature.key,
|
|
342
|
-
getBucket: () => ({ id: a.id, bucket:
|
|
342
|
+
getBucket: () => ({ id: a.id, bucket: d.bucket }),
|
|
343
343
|
isResolved: !0
|
|
344
344
|
} : {
|
|
345
345
|
id: a.id,
|
|
@@ -350,8 +350,8 @@ const je = (t, e, s) => {
|
|
|
350
350
|
};
|
|
351
351
|
})
|
|
352
352
|
);
|
|
353
|
-
function h(
|
|
354
|
-
return t.map((
|
|
353
|
+
function h(c) {
|
|
354
|
+
return t.map((f) => f[c], { skipVoid: !1 });
|
|
355
355
|
}
|
|
356
356
|
return {
|
|
357
357
|
register: o,
|
|
@@ -359,12 +359,12 @@ const je = (t, e, s) => {
|
|
|
359
359
|
listStore: g
|
|
360
360
|
};
|
|
361
361
|
});
|
|
362
|
-
function
|
|
363
|
-
return
|
|
362
|
+
function Re() {
|
|
363
|
+
return x(je);
|
|
364
364
|
}
|
|
365
|
-
const
|
|
365
|
+
const $e = (t, e, s) => {
|
|
366
366
|
s.register(t, e);
|
|
367
|
-
},
|
|
367
|
+
}, E = F("history");
|
|
368
368
|
function L(t, e) {
|
|
369
369
|
return {
|
|
370
370
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
@@ -374,8 +374,8 @@ function L(t, e) {
|
|
|
374
374
|
experienceId: t
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
const Ae =
|
|
378
|
-
const t =
|
|
377
|
+
const Ae = k(() => {
|
|
378
|
+
const t = E.store({ entries: [] }), e = E.event(), s = E.event(), o = E.event(), i = E.event();
|
|
379
379
|
t.on(e, (r, n) => ({
|
|
380
380
|
entries: [...r.entries, L(n.experienceId, n.node)]
|
|
381
381
|
})), t.on(s, (r, n) => ({
|
|
@@ -384,11 +384,11 @@ const Ae = v(() => {
|
|
|
384
384
|
L(n.experienceId, n.node)
|
|
385
385
|
]
|
|
386
386
|
})), t.on(i, (r, n) => n);
|
|
387
|
-
function
|
|
387
|
+
function l(r, n) {
|
|
388
388
|
const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
389
389
|
for (let h = r.length - 1; h >= 0; h--) {
|
|
390
|
-
const
|
|
391
|
-
if (!(!
|
|
390
|
+
const c = r[h], f = c == null ? void 0 : c.node;
|
|
391
|
+
if (!(!f || !X(f)) && !(n && (c == null ? void 0 : c.experienceId) !== n))
|
|
392
392
|
if (g.lastStepIndex === -1)
|
|
393
393
|
g.lastStepIndex = h;
|
|
394
394
|
else {
|
|
@@ -399,7 +399,7 @@ const Ae = v(() => {
|
|
|
399
399
|
return g;
|
|
400
400
|
}
|
|
401
401
|
return t.on(o, (r, n) => {
|
|
402
|
-
const { secondLastStepIndex: g } =
|
|
402
|
+
const { secondLastStepIndex: g } = l(r.entries, n.experienceId), h = g !== -1 ? r.entries.slice(0, g + 1) : r.entries;
|
|
403
403
|
return {
|
|
404
404
|
...r,
|
|
405
405
|
entries: h
|
|
@@ -412,11 +412,11 @@ const Ae = v(() => {
|
|
|
412
412
|
entriesStore: t.map((r) => r.entries)
|
|
413
413
|
};
|
|
414
414
|
});
|
|
415
|
-
function
|
|
416
|
-
return
|
|
415
|
+
function Ce() {
|
|
416
|
+
return x(Ae);
|
|
417
417
|
}
|
|
418
|
-
const
|
|
419
|
-
const t =
|
|
418
|
+
const De = () => C(), Oe = F("field"), Te = k(() => {
|
|
419
|
+
const t = Oe.store({}), e = b(t, {
|
|
420
420
|
register(r, n) {
|
|
421
421
|
return {
|
|
422
422
|
...r,
|
|
@@ -431,146 +431,155 @@ const Oe = () => A(), Ce = x("field"), Ve = v(() => {
|
|
|
431
431
|
function i(r) {
|
|
432
432
|
return t.map((n) => n[r] || null);
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function l(r) {
|
|
435
435
|
return t.map((n) => Object.values(n).find((g) => g.name === r) || null);
|
|
436
436
|
}
|
|
437
437
|
return {
|
|
438
438
|
register: s,
|
|
439
439
|
getById: i,
|
|
440
440
|
listStore: o,
|
|
441
|
-
getByName:
|
|
441
|
+
getByName: l
|
|
442
442
|
};
|
|
443
443
|
});
|
|
444
|
-
function
|
|
445
|
-
return
|
|
444
|
+
function Ve() {
|
|
445
|
+
return x(Te);
|
|
446
446
|
}
|
|
447
|
-
const
|
|
447
|
+
const Me = (t, e) => {
|
|
448
448
|
e.register(t);
|
|
449
|
-
},
|
|
450
|
-
const e =
|
|
451
|
-
register(
|
|
449
|
+
}, Ne = F("response"), Le = k(({ client: t }) => {
|
|
450
|
+
const e = Ne.store({}), s = C(), o = C(), i = b(e, {
|
|
451
|
+
register(a, d) {
|
|
452
452
|
return {
|
|
453
|
-
...
|
|
454
|
-
[
|
|
453
|
+
...a,
|
|
454
|
+
[d.fieldId]: d.response
|
|
455
455
|
};
|
|
456
456
|
},
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
457
|
+
registerBatch(a, d) {
|
|
458
|
+
return {
|
|
459
|
+
...a,
|
|
460
|
+
...d
|
|
461
|
+
};
|
|
462
|
+
},
|
|
463
|
+
clear(a, d) {
|
|
464
|
+
const { [d]: p, ...m } = a;
|
|
465
|
+
return m;
|
|
460
466
|
},
|
|
461
467
|
clearAll() {
|
|
462
468
|
return {};
|
|
463
469
|
}
|
|
464
470
|
});
|
|
465
|
-
function
|
|
466
|
-
i.register({ fieldId:
|
|
471
|
+
function l(a, d) {
|
|
472
|
+
i.register({ fieldId: a, response: d });
|
|
467
473
|
}
|
|
468
|
-
async function r(
|
|
469
|
-
const
|
|
474
|
+
async function r(a) {
|
|
475
|
+
const d = [];
|
|
470
476
|
return await Promise.allSettled(
|
|
471
|
-
Object.entries(
|
|
472
|
-
let
|
|
473
|
-
const
|
|
474
|
-
if (!
|
|
475
|
-
|
|
477
|
+
Object.entries(a).map(async ([p, m]) => {
|
|
478
|
+
let u = m;
|
|
479
|
+
const S = t.fields.getById(p).getState();
|
|
480
|
+
if (!S) {
|
|
481
|
+
d.push({
|
|
476
482
|
fieldId: p,
|
|
477
483
|
userMessage: `Field '${p}' not found`,
|
|
478
484
|
systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
479
|
-
value:
|
|
485
|
+
value: u
|
|
480
486
|
});
|
|
481
487
|
return;
|
|
482
488
|
}
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
$input:
|
|
489
|
+
if (S.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), !re(S.validation)) {
|
|
490
|
+
const w = await B(t, S.validation, {
|
|
491
|
+
$input: u
|
|
486
492
|
});
|
|
487
|
-
if (typeof
|
|
488
|
-
|
|
493
|
+
if (typeof w == "string") {
|
|
494
|
+
d.push({
|
|
489
495
|
fieldId: p,
|
|
490
|
-
userMessage:
|
|
491
|
-
systemMessage: `Field validation resulted in an error: ${
|
|
492
|
-
value:
|
|
496
|
+
userMessage: w,
|
|
497
|
+
systemMessage: `Field validation resulted in an error: ${w}.`,
|
|
498
|
+
value: u
|
|
493
499
|
});
|
|
494
500
|
return;
|
|
495
501
|
}
|
|
496
|
-
if (
|
|
497
|
-
|
|
502
|
+
if (w === !1) {
|
|
503
|
+
d.push({
|
|
498
504
|
fieldId: p,
|
|
499
505
|
userMessage: "This field is invalid",
|
|
500
506
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
501
|
-
value:
|
|
507
|
+
value: u
|
|
502
508
|
});
|
|
503
509
|
return;
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
|
-
if (
|
|
507
|
-
|
|
512
|
+
if (S.required && (typeof u > "u" || u === null || u === "" || Array.isArray(u) && !u.length)) {
|
|
513
|
+
d.push({
|
|
508
514
|
fieldId: p,
|
|
509
515
|
userMessage: "This field is required",
|
|
510
516
|
systemMessage: "Field is required.",
|
|
511
|
-
value:
|
|
517
|
+
value: u
|
|
512
518
|
});
|
|
513
519
|
return;
|
|
514
520
|
}
|
|
515
|
-
if (!
|
|
516
|
-
|
|
521
|
+
if (!S.multiple && Array.isArray(u) && u.length > 1) {
|
|
522
|
+
d.push({
|
|
517
523
|
fieldId: p,
|
|
518
524
|
userMessage: "This field expects a single response",
|
|
519
525
|
systemMessage: "Field expects a single response.",
|
|
520
|
-
value:
|
|
526
|
+
value: u
|
|
521
527
|
});
|
|
522
528
|
return;
|
|
523
529
|
}
|
|
524
|
-
if (
|
|
525
|
-
const
|
|
526
|
-
Array.isArray(
|
|
530
|
+
if (S.options) {
|
|
531
|
+
const w = S.options.map((I) => I.value), $ = Array.isArray(u) ? u : [u];
|
|
532
|
+
Array.isArray(u) && ($.every((I) => w.includes(I)) || d.push({
|
|
527
533
|
fieldId: p,
|
|
528
534
|
userMessage: "This field expects a valid option",
|
|
529
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
530
|
-
value:
|
|
535
|
+
systemMessage: `Field expects a valid option. Valid options are: ${w.join(", ")}`,
|
|
536
|
+
value: u
|
|
531
537
|
}));
|
|
532
538
|
}
|
|
533
539
|
})
|
|
534
|
-
),
|
|
535
|
-
|
|
536
|
-
|
|
540
|
+
), { responsesToCommit: a, validationErrors: d };
|
|
541
|
+
}
|
|
542
|
+
async function n(a) {
|
|
543
|
+
const { responsesToCommit: d, validationErrors: p } = await r(a);
|
|
544
|
+
return p.length ? { errors: p } : (i.registerBatch(d), { errors: [] });
|
|
537
545
|
}
|
|
538
|
-
const
|
|
546
|
+
const g = e.map((a) => a), h = e.map((a) => Object.keys(a).map((p) => ({
|
|
539
547
|
fieldId: p,
|
|
540
|
-
value:
|
|
548
|
+
value: a[p]
|
|
541
549
|
})));
|
|
542
|
-
function
|
|
543
|
-
const
|
|
544
|
-
return
|
|
545
|
-
}
|
|
546
|
-
function
|
|
547
|
-
const
|
|
548
|
-
return
|
|
549
|
-
const
|
|
550
|
-
return
|
|
550
|
+
function c(a) {
|
|
551
|
+
const d = t.fields.getById(a), p = e.map((m) => m[a] || null);
|
|
552
|
+
return A({ f: d, r: p }, ({ f: m, r: u }) => u || (m != null && m.defaultValue ? m.defaultValue : null));
|
|
553
|
+
}
|
|
554
|
+
function f(a) {
|
|
555
|
+
const d = t.fields.getByName(a);
|
|
556
|
+
return A({ f: d, s: e }, ({ f: p, s: m }) => {
|
|
557
|
+
const u = p && m[p.id] || null;
|
|
558
|
+
return u || (p != null && p.defaultValue ? p.defaultValue : null);
|
|
551
559
|
});
|
|
552
560
|
}
|
|
553
|
-
return
|
|
561
|
+
return P({
|
|
554
562
|
clock: s,
|
|
555
563
|
target: i.clearAll
|
|
556
|
-
}),
|
|
564
|
+
}), P({
|
|
557
565
|
clock: o,
|
|
558
566
|
target: i.clear
|
|
559
567
|
}), {
|
|
560
|
-
register:
|
|
568
|
+
register: l,
|
|
561
569
|
clearAll: s,
|
|
562
570
|
clear: o,
|
|
563
|
-
commit:
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
571
|
+
commit: n,
|
|
572
|
+
getResponsesToCommit: r,
|
|
573
|
+
listStore: h,
|
|
574
|
+
getAllStore: g,
|
|
575
|
+
getByFieldId: c,
|
|
576
|
+
getByFieldName: f
|
|
568
577
|
};
|
|
569
578
|
});
|
|
570
579
|
function ze(t) {
|
|
571
|
-
return
|
|
580
|
+
return x(Le, t);
|
|
572
581
|
}
|
|
573
|
-
const _e = () => "0.0.
|
|
582
|
+
const _e = () => "0.0.7-next.1";
|
|
574
583
|
function Ue() {
|
|
575
584
|
if (_()) {
|
|
576
585
|
const t = [
|
|
@@ -593,14 +602,14 @@ function He() {
|
|
|
593
602
|
for (const [i] of t.entries())
|
|
594
603
|
i.startsWith("picked-") && s.add(i);
|
|
595
604
|
for (const i of s) {
|
|
596
|
-
const
|
|
597
|
-
e[
|
|
605
|
+
const l = i.replace("picked-", "");
|
|
606
|
+
e[l] = t.getAll(i);
|
|
598
607
|
}
|
|
599
608
|
const o = j("s");
|
|
600
609
|
if (s.size > 0)
|
|
601
|
-
|
|
610
|
+
R.set(o, e);
|
|
602
611
|
else {
|
|
603
|
-
const i =
|
|
612
|
+
const i = R.get(o);
|
|
604
613
|
if (i)
|
|
605
614
|
return i.json() || {};
|
|
606
615
|
}
|
|
@@ -608,59 +617,59 @@ function He() {
|
|
|
608
617
|
}
|
|
609
618
|
class K {
|
|
610
619
|
constructor(e) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
620
|
+
y(this, "options");
|
|
621
|
+
y(this, "isReady", !1);
|
|
622
|
+
y(this, "project");
|
|
623
|
+
y(this, "plugins", {});
|
|
624
|
+
y(this, "eventBus", De());
|
|
625
|
+
y(this, "organizationId");
|
|
626
|
+
y(this, "projectId");
|
|
627
|
+
y(this, "apiUrl");
|
|
628
|
+
y(this, "searchParams", He());
|
|
629
|
+
y(this, "history", Ce());
|
|
630
|
+
y(this, "components", ye({ client: this }));
|
|
631
|
+
y(this, "experienceInstances", Z({ client: this }));
|
|
632
|
+
y(this, "experiences", ce({ client: this }));
|
|
633
|
+
y(this, "frameworks", we({ client: this }));
|
|
634
|
+
y(this, "predicates", Pe({ client: this }));
|
|
635
|
+
y(this, "features", Re());
|
|
636
|
+
y(this, "responses", ze({ client: this }));
|
|
637
|
+
y(this, "fields", Ve());
|
|
638
|
+
v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: _e() }), v("info", "Picked client initialized.");
|
|
630
639
|
}
|
|
631
640
|
start() {
|
|
632
|
-
|
|
633
|
-
_() && (document.body && await
|
|
641
|
+
Fe(this), (async () => {
|
|
642
|
+
_() && (document.body && await T(this), await ee(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0);
|
|
634
643
|
})();
|
|
635
644
|
}
|
|
636
645
|
registerFramework(e) {
|
|
637
646
|
ve(e, this.frameworks);
|
|
638
647
|
}
|
|
639
648
|
registerComponent(e, s) {
|
|
640
|
-
|
|
649
|
+
V(e, s, this.components);
|
|
641
650
|
}
|
|
642
651
|
registerPlugin(e) {
|
|
643
652
|
de(this, e, this.plugins);
|
|
644
653
|
}
|
|
645
654
|
registerFeature(e, s) {
|
|
646
|
-
|
|
655
|
+
$e(e, s, this.features);
|
|
647
656
|
}
|
|
648
657
|
registerPredicate(e, s) {
|
|
649
|
-
|
|
658
|
+
Be(e, s, this.predicates);
|
|
650
659
|
}
|
|
651
660
|
registerField(e) {
|
|
652
|
-
|
|
661
|
+
Me(e, this.fields);
|
|
653
662
|
}
|
|
654
663
|
registerExperience(e) {
|
|
655
|
-
e.component &&
|
|
664
|
+
e.component && V(`experience:${e.id}`, e.component, this.components), ue(e, this.experiences);
|
|
656
665
|
}
|
|
657
666
|
getStateSnapshot() {
|
|
658
|
-
return
|
|
667
|
+
return be(this);
|
|
659
668
|
}
|
|
660
669
|
async launchExperienceById(e) {
|
|
661
670
|
const s = this.experiences.getById(e).getState();
|
|
662
671
|
if (!s) {
|
|
663
|
-
|
|
672
|
+
v("warn", `Experience with id '${e}' not found.`);
|
|
664
673
|
return;
|
|
665
674
|
}
|
|
666
675
|
H(this, s);
|
|
@@ -701,13 +710,13 @@ class K {
|
|
|
701
710
|
const [o, i] = s.split(":");
|
|
702
711
|
if (!o || !i)
|
|
703
712
|
return;
|
|
704
|
-
let
|
|
705
|
-
|
|
706
|
-
key: `${
|
|
713
|
+
let l = i;
|
|
714
|
+
l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(o, {
|
|
715
|
+
key: `${l}`,
|
|
707
716
|
// use the assigned bucket value as the key
|
|
708
717
|
name: o,
|
|
709
718
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
710
|
-
decide: () =>
|
|
719
|
+
decide: () => l,
|
|
711
720
|
storage: "session"
|
|
712
721
|
});
|
|
713
722
|
} catch {
|
|
@@ -718,7 +727,7 @@ class K {
|
|
|
718
727
|
const e = this.options.predicates;
|
|
719
728
|
e && Object.entries(e).forEach(([s, o]) => {
|
|
720
729
|
if (typeof o != "function") {
|
|
721
|
-
|
|
730
|
+
v("warn", `Predicate "${s}" is not a function.`);
|
|
722
731
|
return;
|
|
723
732
|
}
|
|
724
733
|
this.registerPredicate(s, o);
|
|
@@ -728,27 +737,37 @@ class K {
|
|
|
728
737
|
return this.plugins[e] ?? {};
|
|
729
738
|
}
|
|
730
739
|
}
|
|
731
|
-
|
|
732
|
-
|
|
740
|
+
y(K, "logger", v);
|
|
741
|
+
function Ke(t) {
|
|
742
|
+
return t.some((e) => "condition" in e);
|
|
743
|
+
}
|
|
744
|
+
async function tt(t, e) {
|
|
745
|
+
return !Ke(e) || e.length === 0 ? e : (await Promise.all(
|
|
746
|
+
e.map(async (o) => o.condition ? await B(t, o.condition) ? o : null : o)
|
|
747
|
+
)).filter((o) => o !== null);
|
|
748
|
+
}
|
|
749
|
+
const rt = (t) => {
|
|
733
750
|
const e = new K(t);
|
|
734
751
|
return ne(e), e;
|
|
735
752
|
};
|
|
736
753
|
export {
|
|
737
754
|
K as Picked,
|
|
738
|
-
|
|
755
|
+
rt as createClient,
|
|
739
756
|
j as createStorageKey,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
757
|
+
B as evaluateRuleLogic,
|
|
758
|
+
tt as getStepFields,
|
|
759
|
+
ot as isPickedRoot,
|
|
760
|
+
O as localStore,
|
|
761
|
+
R as sessionStore,
|
|
762
|
+
at as subscribe,
|
|
763
|
+
ut as supportsCookies,
|
|
745
764
|
_ as supportsDocument,
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
765
|
+
lt as supportsHistory,
|
|
766
|
+
dt as supportsIntersectionObserver,
|
|
767
|
+
pt as supportsLocalStorage,
|
|
768
|
+
gt as supportsLocation,
|
|
769
|
+
ft as supportsSessionStorage,
|
|
770
|
+
mt as supportsShadowRoot,
|
|
771
|
+
yt as supportsWebComponents,
|
|
753
772
|
se as supportsWindow
|
|
754
773
|
};
|