@picked/client 0.0.1 → 0.0.2-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -0
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -0
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -0
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -0
- package/dist/cjs/plugins/window-object/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +26 -25
- package/dist/esm/plugins/{experience-browserstorage-plugin → experience-browser-storage}/index.js +1 -1
- package/dist/esm/plugins/{history-browserstorage-plugin → history-browser-storage}/index.js +1 -1
- package/dist/esm/plugins/{responses-browserstorage-plugin → responses-browser-storage}/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +1 -1
- package/dist/esm/plugins/web-components/index.js +21 -0
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-BA0EXYg5.js → experience-instance-DYZovD6a.js} +244 -237
- package/dist/experience-instance-DwO_yZK0.cjs +1 -0
- package/dist/supports-B6KShYPU.cjs +1 -0
- package/dist/{supports-BvrzQAVk.js → supports-yKVnaaMQ.js} +16 -8
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/index.d.ts.map +1 -0
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -0
- package/dist/types/plugins/history-browser-storage/index.d.ts.map +1 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -0
- package/dist/types/plugins/responses-browser-storage/index.d.ts.map +1 -0
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -0
- package/dist/types/plugins/responses-indexeddb/index.d.ts.map +1 -0
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -0
- package/dist/types/plugins/web-components/index.d.ts +2 -0
- package/dist/types/plugins/web-components/index.d.ts.map +1 -0
- package/dist/types/plugins/web-components/plugin.d.ts +3 -0
- package/dist/types/plugins/web-components/plugin.d.ts.map +1 -0
- package/dist/types/utils/dom.d.ts +5 -5
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/supports.d.ts +1 -0
- package/dist/types/utils/supports.d.ts.map +1 -1
- package/package.json +27 -21
- package/dist/cjs/plugins/experience-browserstorage-plugin/index.js +0 -1
- package/dist/cjs/plugins/history-browserstorage-plugin/index.js +0 -1
- package/dist/cjs/plugins/responses-browserstorage-plugin/index.js +0 -1
- package/dist/experience-instance-6ZKZS7dF.cjs +0 -1
- package/dist/supports-C0y3-V5V.cjs +0 -1
- package/dist/types/plugins/experience-browserstorage-plugin/index.d.ts.map +0 -1
- package/dist/types/plugins/experience-browserstorage-plugin/plugin.d.ts.map +0 -1
- package/dist/types/plugins/history-browserstorage-plugin/index.d.ts.map +0 -1
- package/dist/types/plugins/history-browserstorage-plugin/plugin.d.ts.map +0 -1
- package/dist/types/plugins/responses-browserstorage-plugin/index.d.ts.map +0 -1
- package/dist/types/plugins/responses-browserstorage-plugin/plugin.d.ts.map +0 -1
- package/dist/types/plugins/responses-indexeddb-plugin/index.d.ts.map +0 -1
- package/dist/types/plugins/responses-indexeddb-plugin/plugin.d.ts.map +0 -1
- /package/dist/cjs/plugins/{responses-indexeddb-plugin → responses-indexeddb}/index.js +0 -0
- /package/dist/esm/plugins/{responses-indexeddb-plugin → responses-indexeddb}/index.js +0 -0
- /package/dist/types/plugins/{experience-browserstorage-plugin → experience-browser-storage}/index.d.ts +0 -0
- /package/dist/types/plugins/{experience-browserstorage-plugin → experience-browser-storage}/plugin.d.ts +0 -0
- /package/dist/types/plugins/{history-browserstorage-plugin → history-browser-storage}/index.d.ts +0 -0
- /package/dist/types/plugins/{history-browserstorage-plugin → history-browser-storage}/plugin.d.ts +0 -0
- /package/dist/types/plugins/{responses-browserstorage-plugin → responses-browser-storage}/index.d.ts +0 -0
- /package/dist/types/plugins/{responses-browserstorage-plugin → responses-browser-storage}/plugin.d.ts +0 -0
- /package/dist/types/plugins/{responses-indexeddb-plugin → responses-indexeddb}/index.d.ts +0 -0
- /package/dist/types/plugins/{responses-indexeddb-plugin → responses-indexeddb}/plugin.d.ts +0 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { createDomain as ft, createEvent as b, combine as
|
|
2
|
-
import { createFactory as Q, invoke as
|
|
3
|
-
import { h as lt, s as
|
|
4
|
-
import { l as
|
|
5
|
-
import { i as
|
|
6
|
-
function
|
|
1
|
+
import { createDomain as ft, createEvent as b, combine as F, createApi as J, sample as S, createEffect as v, attach as _, split as pt } from "effector";
|
|
2
|
+
import { createFactory as Q, invoke as Y } from "@withease/factories";
|
|
3
|
+
import { h as lt, s as Z, a as dt } from "./supports-yKVnaaMQ.js";
|
|
4
|
+
import { l as D } from "./logger-C9a75KZn.js";
|
|
5
|
+
import { i as gt } from "./object-JwZ58NOH.js";
|
|
6
|
+
function mt(t) {
|
|
7
7
|
return typeof t == "number" && !isNaN(t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function O(t) {
|
|
10
10
|
return typeof t == "string";
|
|
11
11
|
}
|
|
12
12
|
function w(t) {
|
|
13
13
|
return Array.isArray(t);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function tt(t) {
|
|
16
16
|
return t instanceof Promise;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function z(t) {
|
|
19
19
|
return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
|
|
20
20
|
}
|
|
21
21
|
function d(t) {
|
|
22
|
-
if (
|
|
22
|
+
if (mt(t)) return t;
|
|
23
23
|
const e = parseFloat(`${t}`);
|
|
24
24
|
return isNaN(e) ? 0 : e;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function M(t) {
|
|
27
27
|
return `${t}`;
|
|
28
28
|
}
|
|
29
29
|
const ht = {
|
|
@@ -36,34 +36,34 @@ const ht = {
|
|
|
36
36
|
">": (t, e) => d(t) > d(e),
|
|
37
37
|
">=": (t, e) => d(t) >= d(e),
|
|
38
38
|
"<": (t, e, r) => {
|
|
39
|
-
const n = d(t),
|
|
40
|
-
if (r === void 0) return n <
|
|
41
|
-
const
|
|
42
|
-
return n <
|
|
39
|
+
const n = d(t), i = d(e);
|
|
40
|
+
if (r === void 0) return n < i;
|
|
41
|
+
const c = d(r);
|
|
42
|
+
return n < i && i < c;
|
|
43
43
|
},
|
|
44
44
|
"<=": (t, e, r) => {
|
|
45
|
-
const n = d(t),
|
|
46
|
-
if (r === void 0) return n <=
|
|
47
|
-
const
|
|
48
|
-
return n <=
|
|
45
|
+
const n = d(t), i = d(e);
|
|
46
|
+
if (r === void 0) return n <= i;
|
|
47
|
+
const c = d(r);
|
|
48
|
+
return n <= i && i <= c;
|
|
49
49
|
},
|
|
50
|
-
"!!": async (t) => await
|
|
51
|
-
"!": async (t) => !await
|
|
50
|
+
"!!": async (t) => await I(t),
|
|
51
|
+
"!": async (t) => !await I(t),
|
|
52
52
|
"%": (t, e) => d(t) % d(e),
|
|
53
53
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
54
|
log: (t) => (console.log(t), t),
|
|
55
|
-
in: (t, e) => e ?
|
|
56
|
-
cat: (...t) => t.map(
|
|
55
|
+
in: (t, e) => e ? O(e) ? e.indexOf(M(t)) !== -1 : w(e) ? e.includes(t) : !1 : !1,
|
|
56
|
+
cat: (...t) => t.map(M).join(""),
|
|
57
57
|
/* eslint-disable sonarjs/deprecation */
|
|
58
58
|
substr: (t, e, r) => {
|
|
59
|
-
const n =
|
|
60
|
-
if (r === void 0) return n.substr(
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const o = n.substr(
|
|
64
|
-
return o.substr(0, o.length +
|
|
59
|
+
const n = M(t), i = d(e);
|
|
60
|
+
if (r === void 0) return n.substr(i);
|
|
61
|
+
const c = d(r);
|
|
62
|
+
if (c < 0) {
|
|
63
|
+
const o = n.substr(i);
|
|
64
|
+
return o.substr(0, o.length + c);
|
|
65
65
|
}
|
|
66
|
-
return n.substr(
|
|
66
|
+
return n.substr(i, c);
|
|
67
67
|
},
|
|
68
68
|
/* eslint-enable sonarjs/deprecation */
|
|
69
69
|
"+": (...t) => t.reduce((e, r) => d(e) + d(r), 0),
|
|
@@ -82,35 +82,35 @@ const ht = {
|
|
|
82
82
|
return this;
|
|
83
83
|
if (typeof t == "number" && Array.isArray(this))
|
|
84
84
|
return t >= 0 && t < this.length ? this[t] : r;
|
|
85
|
-
const n =
|
|
85
|
+
const n = M(t);
|
|
86
86
|
if (n === "" || n === ".")
|
|
87
87
|
return this;
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
for (const o of
|
|
91
|
-
if (
|
|
88
|
+
const i = n.split(".");
|
|
89
|
+
let c = this;
|
|
90
|
+
for (const o of i) {
|
|
91
|
+
if (c == null)
|
|
92
92
|
return r;
|
|
93
|
-
if (Array.isArray(
|
|
93
|
+
if (Array.isArray(c)) {
|
|
94
94
|
const a = parseInt(o, 10);
|
|
95
|
-
isNaN(a) ?
|
|
95
|
+
isNaN(a) ? c = c[o] : c = c[a];
|
|
96
96
|
} else
|
|
97
|
-
|
|
97
|
+
c = c[o];
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return c !== void 0 ? c : r;
|
|
100
100
|
},
|
|
101
101
|
async missing(...t) {
|
|
102
102
|
const e = w(t[0]) ? t[0] : t, r = [];
|
|
103
103
|
for (const n of e) {
|
|
104
|
-
const
|
|
105
|
-
(
|
|
104
|
+
const i = await l({ var: n }, this);
|
|
105
|
+
(i === null || i === "") && r.push(`${n}`);
|
|
106
106
|
}
|
|
107
107
|
return r;
|
|
108
108
|
},
|
|
109
109
|
async missing_some(t, e) {
|
|
110
110
|
const r = await l({ missing: e }, this);
|
|
111
111
|
if (!w(r) || !w(e)) return [];
|
|
112
|
-
const n = r.filter(
|
|
113
|
-
return e.filter(
|
|
112
|
+
const n = r.filter(O);
|
|
113
|
+
return e.filter(O).length - n.length >= d(t) ? [] : n;
|
|
114
114
|
},
|
|
115
115
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
116
116
|
invoke(t) {
|
|
@@ -119,42 +119,42 @@ const ht = {
|
|
|
119
119
|
regexp_matches(t, e) {
|
|
120
120
|
let r = t, n = "";
|
|
121
121
|
if (w(t)) {
|
|
122
|
-
const [
|
|
123
|
-
r =
|
|
122
|
+
const [c, o] = t;
|
|
123
|
+
r = c, n = o;
|
|
124
124
|
}
|
|
125
|
-
return !
|
|
125
|
+
return !O(r) || !O(n) ? !1 : new RegExp(r, n).test(M(e));
|
|
126
126
|
},
|
|
127
127
|
throw(t) {
|
|
128
|
-
throw new Error(
|
|
128
|
+
throw new Error(M(t));
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
async function l(t, e) {
|
|
132
132
|
if (!t) return t;
|
|
133
|
-
if (
|
|
133
|
+
if (tt(t))
|
|
134
134
|
return l(await t, e);
|
|
135
135
|
if (w(t))
|
|
136
136
|
return Promise.all(t.map((o) => l(o, e)));
|
|
137
|
-
if (!
|
|
137
|
+
if (!z(t)) return t;
|
|
138
138
|
const r = St(t);
|
|
139
139
|
let n = r ? t[r] ?? [] : [];
|
|
140
140
|
switch (w(n) || (n = [n]), r) {
|
|
141
141
|
case "if":
|
|
142
142
|
case "?:":
|
|
143
143
|
for (let o = 0; o < n.length - 1; o += 2)
|
|
144
|
-
if (await
|
|
144
|
+
if (await I(await l(n[o], e)))
|
|
145
145
|
return l(n[o + 1], e);
|
|
146
146
|
return n.length % 2 === 1 ? l(n[n.length - 1], e) : null;
|
|
147
147
|
case "and": {
|
|
148
148
|
let o = null;
|
|
149
149
|
for (const a of n)
|
|
150
|
-
if (o = await l(a, e), !await
|
|
150
|
+
if (o = await l(a, e), !await I(o))
|
|
151
151
|
return o;
|
|
152
152
|
return o;
|
|
153
153
|
}
|
|
154
154
|
case "or": {
|
|
155
155
|
let o = null;
|
|
156
156
|
for (const a of n)
|
|
157
|
-
if (o = await l(a, e), await
|
|
157
|
+
if (o = await l(a, e), await I(o)) return o;
|
|
158
158
|
return o;
|
|
159
159
|
}
|
|
160
160
|
case "map": {
|
|
@@ -165,7 +165,7 @@ async function l(t, e) {
|
|
|
165
165
|
const o = await l(n[0], e);
|
|
166
166
|
return w(o) ? (await Promise.all(
|
|
167
167
|
o.map(async (u) => {
|
|
168
|
-
const h = await
|
|
168
|
+
const h = await I(await l(n[1], u));
|
|
169
169
|
return { item: u, shouldInclude: h };
|
|
170
170
|
})
|
|
171
171
|
)).filter(({ shouldInclude: u }) => u).map(({ item: u }) => u) : [];
|
|
@@ -176,56 +176,56 @@ async function l(t, e) {
|
|
|
176
176
|
return n.length > 2 ? await l(n[2], e) : null;
|
|
177
177
|
const a = n[1];
|
|
178
178
|
let h = n.length > 2 ? await l(n[2], e) : null;
|
|
179
|
-
for (const
|
|
180
|
-
h = await l(a, { current:
|
|
179
|
+
for (const E of o)
|
|
180
|
+
h = await l(a, { current: E, accumulator: h });
|
|
181
181
|
return h;
|
|
182
182
|
}
|
|
183
183
|
case "all": {
|
|
184
184
|
const o = await l(n[0], e);
|
|
185
185
|
if (!w(o) || o.length === 0) return !1;
|
|
186
186
|
for (const a of o)
|
|
187
|
-
if (!await
|
|
187
|
+
if (!await I(await l(n[1], a))) return !1;
|
|
188
188
|
return !0;
|
|
189
189
|
}
|
|
190
190
|
case "some": {
|
|
191
191
|
const o = await l(n[0], e);
|
|
192
192
|
if (!w(o)) return !1;
|
|
193
193
|
for (const a of o)
|
|
194
|
-
if (await
|
|
194
|
+
if (await I(await l(n[1], a))) return !0;
|
|
195
195
|
return !1;
|
|
196
196
|
}
|
|
197
197
|
case "none": {
|
|
198
198
|
const o = await l(n[0], e);
|
|
199
199
|
if (!w(o)) return !0;
|
|
200
200
|
for (const a of o)
|
|
201
|
-
if (await
|
|
201
|
+
if (await I(await l(n[1], a))) return !1;
|
|
202
202
|
return !0;
|
|
203
203
|
}
|
|
204
204
|
case "catch":
|
|
205
205
|
try {
|
|
206
206
|
return await l(n[0], e);
|
|
207
207
|
} catch (o) {
|
|
208
|
-
return
|
|
208
|
+
return z(o) ? await l(o, e) : n[1] ? await l(n[1], o) : o instanceof Error ? o.message : o;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
213
|
-
return
|
|
211
|
+
const i = await Promise.all(n.map((o) => l(o, e))), c = r ? ht[r] : void 0;
|
|
212
|
+
if (!c) throw new Error(`Unrecognized operation ${r}`);
|
|
213
|
+
return c.apply(e, i);
|
|
214
214
|
}
|
|
215
|
-
async function
|
|
216
|
-
return
|
|
215
|
+
async function I(t) {
|
|
216
|
+
return tt(t) ? I(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
|
|
217
217
|
}
|
|
218
218
|
function St(t) {
|
|
219
219
|
return Object.keys(t)[0];
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
return !
|
|
221
|
+
function jt(t) {
|
|
222
|
+
return !gt(t);
|
|
223
223
|
}
|
|
224
224
|
async function yt(t, e, r) {
|
|
225
|
-
const n = t.getStateSnapshot(),
|
|
225
|
+
const n = t.getStateSnapshot(), i = t.predicates.listStore.getState().reduce((a, u) => ({
|
|
226
226
|
...a,
|
|
227
227
|
[u.name]: () => u.predicate(n)
|
|
228
|
-
}), {}),
|
|
228
|
+
}), {}), c = t.features.listStore.getState().reduce((a, u) => ({
|
|
229
229
|
...a,
|
|
230
230
|
[u.id]: async () => {
|
|
231
231
|
const { bucket: h } = await u.getBucket();
|
|
@@ -245,184 +245,191 @@ async function yt(t, e, r) {
|
|
|
245
245
|
protocol: n.location.protocol,
|
|
246
246
|
search: n.location.search
|
|
247
247
|
} : void 0,
|
|
248
|
-
predicates:
|
|
249
|
-
features:
|
|
248
|
+
predicates: i,
|
|
249
|
+
features: c
|
|
250
250
|
};
|
|
251
251
|
return await l(e, o);
|
|
252
252
|
}
|
|
253
253
|
function wt(t) {
|
|
254
|
-
return !dt() || !
|
|
254
|
+
return !dt() || !Z() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
255
255
|
(e) => e instanceof HTMLElement
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
function xt(t) {
|
|
259
259
|
if (!lt())
|
|
260
260
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
261
|
-
return t.attachShadow({ mode: "
|
|
261
|
+
return t.attachShadow({ mode: "closed" });
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function Gt() {
|
|
264
264
|
return new Promise((t, e) => {
|
|
265
|
-
if (!
|
|
265
|
+
if (!Z()) {
|
|
266
266
|
e();
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Et(t, e) {
|
|
273
273
|
const r = new MutationObserver((n) => {
|
|
274
274
|
document.contains(t) || (r.disconnect(), e());
|
|
275
275
|
});
|
|
276
276
|
r.observe(document.body, { childList: !0, subtree: !0 });
|
|
277
277
|
}
|
|
278
|
-
const
|
|
279
|
-
function
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
const P = "picked-root", R = "picked-target", kt = "picked-root";
|
|
279
|
+
function Kt(t, e) {
|
|
280
|
+
return [
|
|
281
|
+
...t,
|
|
282
|
+
// Target and replace picked-root web components
|
|
283
|
+
{
|
|
284
|
+
selector: `${kt}[experience-id="${e}"]`,
|
|
285
|
+
placement: "replace"
|
|
286
|
+
}
|
|
287
|
+
].flatMap((n) => {
|
|
288
|
+
const i = wt(n.selector).filter(
|
|
289
|
+
(c) => !It(c, e) && !Nt(c, e)
|
|
283
290
|
);
|
|
284
291
|
return {
|
|
285
|
-
...
|
|
286
|
-
elements:
|
|
292
|
+
...n,
|
|
293
|
+
elements: i
|
|
287
294
|
};
|
|
288
295
|
});
|
|
289
296
|
}
|
|
290
|
-
function Ut(t) {
|
|
291
|
-
return t.flatMap((
|
|
297
|
+
function Ut(t, e) {
|
|
298
|
+
return t.flatMap((r) => r.elements.map((n) => vt(n, r.placement, e)));
|
|
292
299
|
}
|
|
293
300
|
function Vt(t, e) {
|
|
294
|
-
t.classList.add(
|
|
301
|
+
t.classList.add(R), t.classList.add(`${R}-${e}`);
|
|
295
302
|
}
|
|
296
|
-
function
|
|
297
|
-
return t.classList.contains(`${
|
|
303
|
+
function It(t, e) {
|
|
304
|
+
return e ? t.classList.contains(`${R}-${e}`) : t.classList.contains(`${R}`);
|
|
298
305
|
}
|
|
299
|
-
function
|
|
300
|
-
return t.classList.contains(
|
|
306
|
+
function Nt(t, e) {
|
|
307
|
+
return e ? t.classList.contains(`${P}-${e}`) : t.classList.contains(P);
|
|
301
308
|
}
|
|
302
|
-
function
|
|
303
|
-
const
|
|
304
|
-
return
|
|
309
|
+
function bt(t) {
|
|
310
|
+
const e = document.createElement("div");
|
|
311
|
+
return e.style.display = "block", e.classList.add(P), e.classList.add(`${P}-${t}`), e;
|
|
305
312
|
}
|
|
306
|
-
function
|
|
307
|
-
let
|
|
308
|
-
const
|
|
313
|
+
function vt(t, e, r) {
|
|
314
|
+
let n;
|
|
315
|
+
const i = bt(r);
|
|
309
316
|
if (t instanceof Document)
|
|
310
|
-
|
|
317
|
+
n = t.body.appendChild(i);
|
|
311
318
|
else {
|
|
312
319
|
switch (e) {
|
|
313
320
|
case "replace":
|
|
314
|
-
t.replaceWith(
|
|
321
|
+
t.replaceWith(i);
|
|
315
322
|
break;
|
|
316
323
|
case "before":
|
|
317
|
-
t.before(
|
|
324
|
+
t.before(i);
|
|
318
325
|
break;
|
|
319
326
|
case "after":
|
|
320
|
-
t.after(
|
|
327
|
+
t.after(i);
|
|
321
328
|
break;
|
|
322
329
|
case "prepend":
|
|
323
|
-
t.prepend(
|
|
330
|
+
t.prepend(i);
|
|
324
331
|
break;
|
|
325
332
|
default:
|
|
326
|
-
t.append(
|
|
333
|
+
t.append(i);
|
|
327
334
|
break;
|
|
328
335
|
}
|
|
329
|
-
|
|
336
|
+
n = i;
|
|
330
337
|
}
|
|
331
|
-
return
|
|
338
|
+
return n;
|
|
332
339
|
}
|
|
333
|
-
function
|
|
340
|
+
function _t(t) {
|
|
334
341
|
return t.type === "conditional";
|
|
335
342
|
}
|
|
336
|
-
function
|
|
343
|
+
function $(t) {
|
|
337
344
|
return t.type === "step";
|
|
338
345
|
}
|
|
339
|
-
function
|
|
346
|
+
function At(t) {
|
|
340
347
|
return t.type === "experience";
|
|
341
348
|
}
|
|
342
|
-
function
|
|
349
|
+
function X(t) {
|
|
343
350
|
return t.type === "origin";
|
|
344
351
|
}
|
|
345
|
-
const et = (t, e, r, n,
|
|
352
|
+
const et = (t, e, r, n, i = /* @__PURE__ */ new Set()) => i.has(r.id) ? [] : (i.add(r.id), $(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
346
353
|
const a = t.find((u) => u.id === o.destinationNodeId);
|
|
347
|
-
return a ? et(t, e, a, !1,
|
|
348
|
-
})),
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
354
|
+
return a ? et(t, e, a, !1, i) : [];
|
|
355
|
+
})), Lt = (t, e, r) => et(t, e, r, !0, /* @__PURE__ */ new Set()), nt = (t, e, r, n, i = /* @__PURE__ */ new Set()) => {
|
|
356
|
+
if (i.has(r.id)) return [-1, -1];
|
|
357
|
+
i.add(r.id);
|
|
358
|
+
const c = e.filter((u) => u.sourceNodeId === r.id);
|
|
359
|
+
if (c.length === 0) return [0, 0];
|
|
353
360
|
let o = 1 / 0, a = -1 / 0;
|
|
354
|
-
for (const u of
|
|
361
|
+
for (const u of c) {
|
|
355
362
|
const h = t.find((k) => k.id === u.destinationNodeId);
|
|
356
363
|
if (!h) continue;
|
|
357
|
-
const [
|
|
364
|
+
const [E, y] = nt(
|
|
358
365
|
t,
|
|
359
366
|
e,
|
|
360
367
|
h,
|
|
361
368
|
!1,
|
|
362
|
-
new Set(
|
|
369
|
+
new Set(i)
|
|
363
370
|
);
|
|
364
|
-
|
|
371
|
+
E !== -1 && (o = Math.min(o, E + 1), a = Math.max(a, y + 1));
|
|
365
372
|
}
|
|
366
373
|
return o === 1 / 0 ? [-1, -1] : [o, a];
|
|
367
|
-
},
|
|
374
|
+
}, Mt = (t, e, r) => nt(t, e, r, !0, /* @__PURE__ */ new Set()), rt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
368
375
|
if (n.has(r.id)) return [-1, -1];
|
|
369
376
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
let
|
|
373
|
-
for (const a of
|
|
377
|
+
const i = e.filter((a) => a.destinationNodeId === r.id);
|
|
378
|
+
if (i.length === 0) return [-1, -1];
|
|
379
|
+
let c = 1 / 0, o = -1 / 0;
|
|
380
|
+
for (const a of i) {
|
|
374
381
|
const u = t.find((y) => y.id === a.sourceNodeId);
|
|
375
382
|
if (!u) continue;
|
|
376
|
-
const [h,
|
|
383
|
+
const [h, E] = rt(
|
|
377
384
|
t,
|
|
378
385
|
e,
|
|
379
386
|
u,
|
|
380
387
|
new Set(n)
|
|
381
388
|
);
|
|
382
|
-
h !== -1 && (
|
|
389
|
+
h !== -1 && (c = Math.min(c, h + 1), o = Math.max(o, E + 1));
|
|
383
390
|
}
|
|
384
|
-
return
|
|
385
|
-
},
|
|
391
|
+
return c === 1 / 0 ? [-1, -1] : [c, o];
|
|
392
|
+
}, Tt = (t, e, r) => rt(t, e, r, /* @__PURE__ */ new Set()), ot = (t) => t.find((r) => r.type === "origin") || null, K = (t, e, r) => {
|
|
386
393
|
if (!t)
|
|
387
394
|
return ot(e);
|
|
388
|
-
const n = r.find((
|
|
395
|
+
const n = r.find((c) => c.sourceNodeId === t.id);
|
|
389
396
|
if (!n)
|
|
390
397
|
return null;
|
|
391
|
-
const
|
|
392
|
-
return
|
|
398
|
+
const i = e.find((c) => c.id === n.destinationNodeId);
|
|
399
|
+
return i || null;
|
|
393
400
|
};
|
|
394
401
|
async function Bt(t, e, r, n) {
|
|
395
|
-
const
|
|
396
|
-
(o) => o.sourceNodeHandle ===
|
|
402
|
+
const i = t ? "true" : "false", c = n.find(
|
|
403
|
+
(o) => o.sourceNodeHandle === i && o.sourceNodeId === e
|
|
397
404
|
);
|
|
398
|
-
return r.find((o) => o.id === (
|
|
405
|
+
return r.find((o) => o.id === (c == null ? void 0 : c.destinationNodeId));
|
|
399
406
|
}
|
|
400
|
-
const
|
|
407
|
+
const U = ft("experience-instance"), Ft = Q(
|
|
401
408
|
({
|
|
402
409
|
client: t,
|
|
403
410
|
experience: e,
|
|
404
411
|
target: r
|
|
405
412
|
}) => {
|
|
406
|
-
const n = b(),
|
|
413
|
+
const n = b(), i = b(), c = b(), o = b(), a = e.componentStore, u = U.store("transitioning"), h = t.history.entriesStore.map((s) => s.filter((p) => p.experienceId === e.id)), E = h.map((s) => s.filter((p) => $(p.node))), y = h.map((s) => {
|
|
407
414
|
var p;
|
|
408
415
|
return ((p = s[s.length - 1]) == null ? void 0 : p.node) || null;
|
|
409
|
-
}), k =
|
|
416
|
+
}), k = F(
|
|
410
417
|
e.treeStore,
|
|
411
418
|
y,
|
|
412
|
-
({ steps: s }, p) => s.find((
|
|
413
|
-
),
|
|
419
|
+
({ steps: s }, p) => s.find((g) => p && $(p) && g.id === p.stepId) || null
|
|
420
|
+
), C = F(
|
|
414
421
|
e.treeStore,
|
|
415
422
|
y,
|
|
416
|
-
({ nodes: s, edges: p },
|
|
417
|
-
), f =
|
|
423
|
+
({ nodes: s, edges: p }, g) => g ? Lt(s, p, g) : []
|
|
424
|
+
), f = F(
|
|
418
425
|
e.treeStore,
|
|
419
426
|
y,
|
|
420
|
-
({ nodes: s, edges: p },
|
|
421
|
-
),
|
|
427
|
+
({ nodes: s, edges: p }, g) => g ? Tt(s, p, g) : [-1, -1]
|
|
428
|
+
), m = F(
|
|
422
429
|
e.treeStore,
|
|
423
430
|
y,
|
|
424
|
-
({ nodes: s, edges: p },
|
|
425
|
-
), x =
|
|
431
|
+
({ nodes: s, edges: p }, g) => g ? Mt(s, p, g) : [-1, -1]
|
|
432
|
+
), x = U.store(!0), N = J(x, {
|
|
426
433
|
open: () => !0,
|
|
427
434
|
close: () => !1,
|
|
428
435
|
toggle: (s) => !s,
|
|
@@ -443,73 +450,73 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
443
450
|
experience: e
|
|
444
451
|
}))
|
|
445
452
|
});
|
|
446
|
-
const
|
|
453
|
+
const A = v(async () => {
|
|
447
454
|
t.history.back({ experienceId: e.id });
|
|
448
|
-
}),
|
|
455
|
+
}), T = _({
|
|
449
456
|
source: e.treeStore,
|
|
450
457
|
effect: async (s, p) => {
|
|
451
|
-
const
|
|
452
|
-
|
|
458
|
+
const g = s.nodes.find((L) => $(L) && L.stepId === p);
|
|
459
|
+
g && t.history.push({ experienceId: e.id, node: g });
|
|
453
460
|
}
|
|
454
|
-
}),
|
|
461
|
+
}), V = _({
|
|
455
462
|
source: y,
|
|
456
463
|
effect: (s) => {
|
|
457
464
|
}
|
|
458
|
-
}),
|
|
465
|
+
}), H = _({
|
|
459
466
|
source: e.treeStore,
|
|
460
467
|
effect: async ({ nodes: s }) => ot(s)
|
|
461
|
-
}),
|
|
468
|
+
}), j = _({
|
|
462
469
|
source: e.treeStore,
|
|
463
|
-
effect: async ({ nodes: s, edges: p },
|
|
464
|
-
}),
|
|
470
|
+
effect: async ({ nodes: s, edges: p }, g) => K(g, s, p)
|
|
471
|
+
}), G = _({
|
|
465
472
|
source: e.treeStore,
|
|
466
|
-
effect: async ({ nodes: s, edges: p, conditionals:
|
|
467
|
-
if (!
|
|
473
|
+
effect: async ({ nodes: s, edges: p, conditionals: g }, L) => {
|
|
474
|
+
if (!L)
|
|
468
475
|
return;
|
|
469
|
-
const
|
|
470
|
-
if (!
|
|
476
|
+
const q = g.find((ut) => ut.id === L.conditionalId);
|
|
477
|
+
if (!q)
|
|
471
478
|
return;
|
|
472
|
-
const ct =
|
|
479
|
+
const ct = L.id, at = await yt(t, q.condition);
|
|
473
480
|
return Bt(!!at, ct, s, p);
|
|
474
481
|
}
|
|
475
482
|
}), st = v((s) => {
|
|
476
483
|
if (s)
|
|
477
484
|
return t.launchExperienceById(s.experienceId);
|
|
478
|
-
}),
|
|
485
|
+
}), W = _({
|
|
479
486
|
source: [y, e.treeStore],
|
|
480
|
-
effect: async ([s, { nodes: p, edges:
|
|
481
|
-
}),
|
|
487
|
+
effect: async ([s, { nodes: p, edges: g }]) => K(s, p, g)
|
|
488
|
+
}), B = _({
|
|
482
489
|
source: [y, e.treeStore],
|
|
483
|
-
effect: async ([s, { nodes: p, edges:
|
|
490
|
+
effect: async ([s, { nodes: p, edges: g }]) => K(s, p, g)
|
|
484
491
|
}), it = v((s) => {
|
|
485
492
|
t.history.push({ experienceId: e.id, node: s });
|
|
486
493
|
});
|
|
487
494
|
return pt({
|
|
488
495
|
source: y,
|
|
489
|
-
match: (s) => s ?
|
|
496
|
+
match: (s) => s ? _t(s) ? "condition" : $(s) ? "step" : At(s) ? "launchExperience" : X(s) ? "origin" : "other" : "none",
|
|
490
497
|
cases: {
|
|
491
|
-
none:
|
|
492
|
-
origin:
|
|
493
|
-
condition:
|
|
494
|
-
step:
|
|
498
|
+
none: H,
|
|
499
|
+
origin: j,
|
|
500
|
+
condition: G,
|
|
501
|
+
step: V,
|
|
495
502
|
launchExperience: st,
|
|
496
503
|
__: b()
|
|
497
504
|
}
|
|
498
505
|
}), S({
|
|
499
506
|
clock: [
|
|
507
|
+
G.doneData,
|
|
508
|
+
j.doneData,
|
|
500
509
|
H.doneData,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
L.doneData,
|
|
504
|
-
z.doneData
|
|
510
|
+
B.doneData,
|
|
511
|
+
W.doneData
|
|
505
512
|
],
|
|
506
513
|
filter: Boolean,
|
|
507
514
|
target: it
|
|
508
515
|
}), S({
|
|
509
|
-
clock:
|
|
510
|
-
target:
|
|
516
|
+
clock: i,
|
|
517
|
+
target: B
|
|
511
518
|
}), S({
|
|
512
|
-
clock:
|
|
519
|
+
clock: i,
|
|
513
520
|
source: k,
|
|
514
521
|
target: t.eventBus.prepend((s) => ({
|
|
515
522
|
type: "step_submit",
|
|
@@ -517,7 +524,7 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
517
524
|
experience: e
|
|
518
525
|
}))
|
|
519
526
|
}), S({
|
|
520
|
-
clock:
|
|
527
|
+
clock: B.done,
|
|
521
528
|
source: k,
|
|
522
529
|
target: t.eventBus.prepend((s) => ({
|
|
523
530
|
type: "step_submit_success",
|
|
@@ -525,7 +532,7 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
525
532
|
experience: e
|
|
526
533
|
}))
|
|
527
534
|
}), S({
|
|
528
|
-
clock:
|
|
535
|
+
clock: B.fail,
|
|
529
536
|
source: k,
|
|
530
537
|
target: t.eventBus.prepend((s) => ({
|
|
531
538
|
type: "step_submit_error",
|
|
@@ -533,27 +540,27 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
533
540
|
experience: e
|
|
534
541
|
}))
|
|
535
542
|
}), S({
|
|
536
|
-
clock:
|
|
537
|
-
target:
|
|
543
|
+
clock: c,
|
|
544
|
+
target: A
|
|
538
545
|
}), S({
|
|
539
|
-
clock:
|
|
546
|
+
clock: c,
|
|
540
547
|
source: k,
|
|
541
548
|
target: t.eventBus.prepend((s) => ({
|
|
542
549
|
type: "step_submit",
|
|
543
550
|
step: s ?? void 0,
|
|
544
551
|
experience: e
|
|
545
552
|
}))
|
|
546
|
-
}), S({ clock: o, target:
|
|
547
|
-
source:
|
|
553
|
+
}), S({ clock: o, target: T }), S({
|
|
554
|
+
source: F([
|
|
555
|
+
G.pending,
|
|
556
|
+
j.pending,
|
|
548
557
|
H.pending,
|
|
549
|
-
|
|
550
|
-
C.pending,
|
|
551
|
-
L.pending
|
|
558
|
+
B.pending
|
|
552
559
|
]),
|
|
553
560
|
fn: (s) => s.some(Boolean) ? "transitioning" : "ready",
|
|
554
561
|
target: u
|
|
555
562
|
}), S({
|
|
556
|
-
clock:
|
|
563
|
+
clock: V.doneData,
|
|
557
564
|
source: k,
|
|
558
565
|
target: t.eventBus.prepend((s) => ({
|
|
559
566
|
type: "step_enter",
|
|
@@ -563,8 +570,8 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
563
570
|
}), S({
|
|
564
571
|
source: y,
|
|
565
572
|
clock: n,
|
|
566
|
-
filter: (s) => s ?
|
|
567
|
-
target:
|
|
573
|
+
filter: (s) => s ? X(s) : !0,
|
|
574
|
+
target: W
|
|
568
575
|
}), n(), {
|
|
569
576
|
// config
|
|
570
577
|
experienceId: e.id,
|
|
@@ -583,35 +590,35 @@ const V = ft("experience-instance"), Mt = Q(
|
|
|
583
590
|
treeStore: e.treeStore,
|
|
584
591
|
currentNodeStore: y,
|
|
585
592
|
currentStepStore: k,
|
|
586
|
-
nextReachableStepNodesStore:
|
|
593
|
+
nextReachableStepNodesStore: C,
|
|
587
594
|
stepsToOriginStore: f,
|
|
588
|
-
stepsToLeafStore:
|
|
595
|
+
stepsToLeafStore: m,
|
|
589
596
|
// history
|
|
590
|
-
goToNextStep:
|
|
591
|
-
goToPreviousStep:
|
|
597
|
+
goToNextStep: i,
|
|
598
|
+
goToPreviousStep: c,
|
|
592
599
|
goToStepById: o,
|
|
593
|
-
stepsHistoryStore:
|
|
600
|
+
stepsHistoryStore: E
|
|
594
601
|
};
|
|
595
602
|
}
|
|
596
603
|
);
|
|
597
|
-
function
|
|
598
|
-
return
|
|
604
|
+
function Ot(t) {
|
|
605
|
+
return Y(Ft, t);
|
|
599
606
|
}
|
|
600
|
-
const
|
|
601
|
-
const e =
|
|
602
|
-
register(f,
|
|
607
|
+
const $t = Q(({ client: t }) => {
|
|
608
|
+
const e = U.store({}), r = b(), n = b(), i = b(), c = J(e, {
|
|
609
|
+
register(f, m) {
|
|
603
610
|
const x = [
|
|
604
|
-
...f[
|
|
611
|
+
...f[m.experienceId] ?? []
|
|
605
612
|
];
|
|
606
|
-
return x.push(
|
|
613
|
+
return x.push(m), {
|
|
607
614
|
...f,
|
|
608
|
-
[
|
|
615
|
+
[m.experienceId]: x
|
|
609
616
|
};
|
|
610
617
|
},
|
|
611
|
-
unregister(f,
|
|
612
|
-
var
|
|
613
|
-
const x =
|
|
614
|
-
(
|
|
618
|
+
unregister(f, m) {
|
|
619
|
+
var A;
|
|
620
|
+
const x = m.experienceId, N = (A = f[x]) == null ? void 0 : A.filter(
|
|
621
|
+
(T) => T !== m
|
|
615
622
|
);
|
|
616
623
|
return {
|
|
617
624
|
...f,
|
|
@@ -619,51 +626,51 @@ const Ot = Q(({ client: t }) => {
|
|
|
619
626
|
};
|
|
620
627
|
}
|
|
621
628
|
}), o = v(
|
|
622
|
-
({ experience: f, target:
|
|
629
|
+
({ experience: f, target: m }) => Ot({ client: t, experience: f, target: m })
|
|
623
630
|
), a = v((f) => {
|
|
624
|
-
|
|
631
|
+
c.register(f);
|
|
625
632
|
}), u = v(
|
|
626
633
|
(f) => {
|
|
627
|
-
f.target &&
|
|
628
|
-
|
|
634
|
+
f.target && Et(f.target, () => {
|
|
635
|
+
i(f);
|
|
629
636
|
});
|
|
630
637
|
}
|
|
631
638
|
), h = v((f) => {
|
|
632
|
-
|
|
633
|
-
}),
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
|
|
639
|
+
c.unregister(f);
|
|
640
|
+
}), E = v((f) => {
|
|
641
|
+
const m = f.componentStore.getState();
|
|
642
|
+
if (!m) {
|
|
643
|
+
D("warn", "No app component registered. Skipping init.");
|
|
637
644
|
return;
|
|
638
645
|
}
|
|
639
|
-
const x =
|
|
646
|
+
const x = m.frameworkStore.getState();
|
|
640
647
|
if (!x) {
|
|
641
|
-
|
|
648
|
+
D(
|
|
642
649
|
"error",
|
|
643
|
-
`No framework registered for component '${
|
|
650
|
+
`No framework registered for component '${m.name}'. Skipping rendering.`
|
|
644
651
|
);
|
|
645
652
|
return;
|
|
646
653
|
}
|
|
647
654
|
const N = f.target;
|
|
648
655
|
if (!N) {
|
|
649
|
-
|
|
656
|
+
D(
|
|
650
657
|
"error",
|
|
651
658
|
`No target element registered for experience '${f.experienceId}'. Skipping rendering.`
|
|
652
659
|
);
|
|
653
660
|
return;
|
|
654
661
|
}
|
|
655
|
-
const
|
|
662
|
+
const A = xt(N);
|
|
656
663
|
try {
|
|
657
|
-
x.render(
|
|
658
|
-
} catch (
|
|
659
|
-
|
|
664
|
+
x.render(A, m.component, t, f);
|
|
665
|
+
} catch (T) {
|
|
666
|
+
D("error", T);
|
|
660
667
|
}
|
|
661
668
|
});
|
|
662
669
|
S({
|
|
663
670
|
clock: r,
|
|
664
671
|
target: o
|
|
665
672
|
}), S({
|
|
666
|
-
clock:
|
|
673
|
+
clock: i,
|
|
667
674
|
target: h
|
|
668
675
|
}), S({
|
|
669
676
|
clock: o.doneData,
|
|
@@ -680,33 +687,33 @@ const Ot = Q(({ client: t }) => {
|
|
|
680
687
|
}))
|
|
681
688
|
}), S({
|
|
682
689
|
clock: n,
|
|
683
|
-
target:
|
|
690
|
+
target: E
|
|
684
691
|
});
|
|
685
|
-
function y(f,
|
|
686
|
-
r({ experience: f, target:
|
|
692
|
+
function y(f, m) {
|
|
693
|
+
r({ experience: f, target: m });
|
|
687
694
|
}
|
|
688
695
|
const k = e.map((f) => Object.values(f).flat());
|
|
689
|
-
function
|
|
690
|
-
return e.map((
|
|
696
|
+
function C(f) {
|
|
697
|
+
return e.map((m) => m[f] || [], { skipVoid: !1 });
|
|
691
698
|
}
|
|
692
699
|
return {
|
|
693
700
|
spawn: y,
|
|
694
|
-
getByExperienceId:
|
|
701
|
+
getByExperienceId: C,
|
|
695
702
|
listStore: k
|
|
696
703
|
};
|
|
697
704
|
});
|
|
698
|
-
function
|
|
699
|
-
return
|
|
705
|
+
function Wt(t) {
|
|
706
|
+
return Y($t, t);
|
|
700
707
|
}
|
|
701
708
|
export {
|
|
702
|
-
|
|
703
|
-
|
|
709
|
+
$ as a,
|
|
710
|
+
Wt as b,
|
|
704
711
|
Ut as c,
|
|
705
|
-
|
|
712
|
+
Gt as d,
|
|
706
713
|
yt as e,
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
714
|
+
Nt as f,
|
|
715
|
+
Kt as g,
|
|
716
|
+
Ot as h,
|
|
717
|
+
jt as i,
|
|
711
718
|
Vt as t
|
|
712
719
|
};
|