@picked/client 0.0.1-dev.1773729274420 → 0.0.1-dev.1773807602703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-DuHeVrL4.js → api-GlH9T8_1.js} +1 -1
- package/dist/{api-47L967ES.cjs → api-GvmToTw0.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +738 -741
- package/dist/esm/plugins/create-experience/index.js +360 -286
- package/dist/esm/plugins/dynamic-experiences/index.js +145 -78
- 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/plugins/responses-indexeddb/index.js +46 -51
- package/dist/esm/plugins/single-page-app/index.js +24 -24
- package/dist/esm/server/index.js +7 -7
- package/dist/experience-instance-CxiOyYPf.cjs +1 -0
- package/dist/{experience-instance-DTyL1fNb.js → experience-instance-DCknHRkX.js} +328 -349
- package/dist/nodes-DQt4TfuO.js +26 -0
- package/dist/nodes-DsL8kMSX.cjs +1 -0
- package/dist/object-BbFTsGh3.cjs +1 -0
- package/dist/{object-CJssU1Pm.js → object-JwZ58NOH.js} +1 -1
- package/dist/storage-Be5xWNPC.cjs +1 -0
- package/dist/{storage-B2d81EOI.js → storage-Co_LbKr_.js} +30 -35
- package/dist/types/entities/action/action.d.ts +2 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +17 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +48 -31
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +23 -52
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +9 -7
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +20 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +8 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +41 -32
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +70 -43
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +1 -1
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +20 -5
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +46 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +3 -0
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +2 -2
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +1 -0
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +1 -2
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/key.d.ts +12 -0
- package/dist/types/utils/key.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +7 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +8 -0
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +2 -16
- package/dist/experience-instance-BX0aqKsC.cjs +0 -1
- package/dist/object-mwaxtjLG.cjs +0 -1
- package/dist/storage-58NoTSsc.cjs +0 -1
|
@@ -1,137 +1,204 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { c as
|
|
1
|
+
import { a as m } from "../../../api-GlH9T8_1.js";
|
|
2
|
+
import { c as U } from "../../../api-GlH9T8_1.js";
|
|
3
3
|
import { l as a } from "../../../logger-C9a75KZn.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { r as y } from "../../../nodes-DQt4TfuO.js";
|
|
5
|
+
function h(n) {
|
|
6
|
+
let e = 2166136261;
|
|
7
|
+
for (let t = 0; t < n.length; t++)
|
|
8
|
+
e ^= n.charCodeAt(t), e = Math.imul(e, 16777619);
|
|
9
|
+
return e >>> 0;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
11
|
+
function w(n) {
|
|
12
|
+
return h(n) % 100;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
14
|
+
function v(n, e) {
|
|
15
|
+
return e <= 0 ? !1 : e >= 100 ? !0 : n < e;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
return typeof
|
|
17
|
+
function j(n) {
|
|
18
|
+
return typeof n != "object" || n === null || !("id" in n && "name" in n && "enabled" in n && "weight" in n && "version" in n) ? !1 : typeof n.id == "string" && typeof n.name == "string" && typeof n.enabled == "boolean" && typeof n.weight == "number" && typeof n.version == "number";
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
return typeof
|
|
20
|
+
function g(n) {
|
|
21
|
+
return typeof n != "object" || n === null || !("features" in n) || !Array.isArray(n.features) ? !1 : n.features.every(j);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
if (r && r.length > 0)
|
|
25
|
-
return r[0];
|
|
23
|
+
function C(n) {
|
|
24
|
+
return typeof n != "object" || n === null ? !1 : "id" in n && "name" in n && "nodes" in n && "edges" in n && typeof n.id == "string" && typeof n.name == "string" && Array.isArray(n.nodes) && Array.isArray(n.edges);
|
|
26
25
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (!n)
|
|
30
|
-
return r;
|
|
26
|
+
function S(n, e) {
|
|
27
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
31
28
|
for (const o of n) {
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
if (o.type !== "conditional")
|
|
30
|
+
continue;
|
|
31
|
+
const i = o.conditionId ?? o.conditionalId;
|
|
32
|
+
if (!i || t.has(i))
|
|
33
|
+
continue;
|
|
34
|
+
t.add(i);
|
|
35
|
+
const s = e.get(i);
|
|
36
|
+
if (!s) {
|
|
37
|
+
a("warn", `Condition with id '${i}' not found in project conditions`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
r.push({ id: s.id, label: s.name, condition: s.condition });
|
|
34
41
|
}
|
|
35
42
|
return r;
|
|
36
43
|
}
|
|
37
|
-
function c(
|
|
38
|
-
|
|
44
|
+
function c(n, e) {
|
|
45
|
+
if (e.conditions)
|
|
46
|
+
for (const t of e.conditions)
|
|
47
|
+
n.registerCondition(t);
|
|
48
|
+
}
|
|
49
|
+
function b(n, e, t) {
|
|
50
|
+
if (!C(e)) {
|
|
51
|
+
a("warn", `Skipping invalid experience payload: ${JSON.stringify(e)}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const r = e.componentName ? n.components.listStore.getState().find((o) => o.name === e.componentName)?.component : void 0;
|
|
55
|
+
n.registerExperience({
|
|
56
|
+
id: e.id,
|
|
57
|
+
key: e.key,
|
|
58
|
+
name: e.name,
|
|
59
|
+
targets: e.targets ?? [],
|
|
60
|
+
steps: e.nodes.filter((o) => o.type === "step").map((o) => y(o)),
|
|
61
|
+
nodes: e.nodes,
|
|
62
|
+
edges: e.edges,
|
|
63
|
+
conditions: S(e.nodes, t),
|
|
64
|
+
actions: e.actions,
|
|
65
|
+
condition: e.condition,
|
|
66
|
+
initializeOpen: e.initializeOpen,
|
|
67
|
+
component: r
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function f(n, e) {
|
|
71
|
+
if (e.fields)
|
|
72
|
+
for (const t of e.fields)
|
|
73
|
+
n.registerField(t);
|
|
74
|
+
}
|
|
75
|
+
function u(n, e) {
|
|
76
|
+
if (e.steps)
|
|
77
|
+
for (const t of e.steps)
|
|
78
|
+
n.registerStep(t);
|
|
79
|
+
}
|
|
80
|
+
function d(n, e) {
|
|
81
|
+
const t = /* @__PURE__ */ new Map();
|
|
82
|
+
if (e.conditions)
|
|
83
|
+
for (const r of e.conditions)
|
|
84
|
+
t.set(r.id, r);
|
|
85
|
+
if (e.experiences)
|
|
86
|
+
for (const r of e.experiences)
|
|
87
|
+
b(n, r, t);
|
|
88
|
+
}
|
|
89
|
+
function k(n) {
|
|
90
|
+
const e = n.searchParams["preview-token"];
|
|
91
|
+
if (e && e.length > 0)
|
|
92
|
+
return e[0];
|
|
93
|
+
}
|
|
94
|
+
function I(n) {
|
|
95
|
+
const e = /* @__PURE__ */ new Set(), t = n.searchParams.feature;
|
|
39
96
|
if (!t)
|
|
97
|
+
return e;
|
|
98
|
+
for (const r of t) {
|
|
99
|
+
const o = r.indexOf(":");
|
|
100
|
+
o > 0 && e.add(r.substring(0, o));
|
|
101
|
+
}
|
|
102
|
+
return e;
|
|
103
|
+
}
|
|
104
|
+
function l(n, e, t) {
|
|
105
|
+
const r = I(n), o = n.session?.id;
|
|
106
|
+
if (!o)
|
|
40
107
|
throw new Error("Session ID is required for feature registration");
|
|
41
|
-
const i =
|
|
42
|
-
for (const s of
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
key: `v${
|
|
48
|
-
name:
|
|
49
|
-
storage:
|
|
50
|
-
decide: () =>
|
|
108
|
+
const i = w(o);
|
|
109
|
+
for (const s of e.features)
|
|
110
|
+
r.has(s.id) || P(n, s, t, i);
|
|
111
|
+
}
|
|
112
|
+
function P(n, e, t, r) {
|
|
113
|
+
n.registerFeature(e.id, {
|
|
114
|
+
key: `v${e.version}`,
|
|
115
|
+
name: e.name,
|
|
116
|
+
storage: t ? "session" : "local",
|
|
117
|
+
decide: () => e.enabled ? v(r, e.weight) : !1
|
|
51
118
|
});
|
|
52
119
|
}
|
|
53
|
-
function
|
|
54
|
-
let
|
|
120
|
+
function F() {
|
|
121
|
+
let n;
|
|
55
122
|
try {
|
|
56
|
-
|
|
123
|
+
n = __PICKED_PROJECT_CONFIG__;
|
|
57
124
|
} catch {
|
|
58
125
|
return;
|
|
59
126
|
}
|
|
60
|
-
if (
|
|
127
|
+
if (n === void 0)
|
|
61
128
|
return;
|
|
62
|
-
let
|
|
63
|
-
if (typeof
|
|
129
|
+
let e;
|
|
130
|
+
if (typeof n == "string")
|
|
64
131
|
try {
|
|
65
|
-
|
|
132
|
+
e = JSON.parse(n);
|
|
66
133
|
} catch {
|
|
67
134
|
a("warn", "Build-time project config is not valid JSON");
|
|
68
135
|
return;
|
|
69
136
|
}
|
|
70
137
|
else
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
138
|
+
e = n;
|
|
139
|
+
if (g(e))
|
|
140
|
+
return e;
|
|
74
141
|
a("warn", "Build-time project config has invalid shape, falling back to runtime fetch");
|
|
75
142
|
}
|
|
76
|
-
function
|
|
143
|
+
function E(n) {
|
|
77
144
|
try {
|
|
78
|
-
const
|
|
79
|
-
return
|
|
145
|
+
const e = new URL(n).hostname;
|
|
146
|
+
return e === "localhost" || e === "127.0.0.1" || e === "::1";
|
|
80
147
|
} catch {
|
|
81
148
|
return !1;
|
|
82
149
|
}
|
|
83
150
|
}
|
|
84
|
-
function
|
|
85
|
-
if (typeof
|
|
151
|
+
function O(n) {
|
|
152
|
+
if (typeof n != "object" || n === null || !("cause" in n))
|
|
86
153
|
return !1;
|
|
87
|
-
const { cause:
|
|
88
|
-
return typeof
|
|
154
|
+
const { cause: e } = n;
|
|
155
|
+
return typeof e != "object" || e === null || !("code" in e) ? !1 : e.code === "ECONNREFUSED";
|
|
89
156
|
}
|
|
90
|
-
async function
|
|
91
|
-
const
|
|
92
|
-
let
|
|
157
|
+
async function p(n, e, t) {
|
|
158
|
+
const r = t?.previewToken ? `projects/${e}?preview_token=${encodeURIComponent(t.previewToken)}` : `projects/${e}`;
|
|
159
|
+
let o;
|
|
93
160
|
try {
|
|
94
|
-
|
|
161
|
+
o = await m(n, r, t?.headers);
|
|
95
162
|
} catch (s) {
|
|
96
|
-
return
|
|
163
|
+
return E(n) && O(s) || a("warn", "Failed to fetch project config", s), null;
|
|
97
164
|
}
|
|
98
|
-
if (!
|
|
99
|
-
return a("warn", `Project config request failed with status ${
|
|
165
|
+
if (!o.ok)
|
|
166
|
+
return a("warn", `Project config request failed with status ${o.status.toString()}`), null;
|
|
100
167
|
let i;
|
|
101
168
|
try {
|
|
102
|
-
i = await
|
|
169
|
+
i = await o.json();
|
|
103
170
|
} catch {
|
|
104
171
|
return a("warn", "Failed to parse project config response"), null;
|
|
105
172
|
}
|
|
106
|
-
return
|
|
173
|
+
return g(i) ? i : (a("warn", "Invalid project config response shape"), null);
|
|
107
174
|
}
|
|
108
|
-
function
|
|
175
|
+
function T(n) {
|
|
109
176
|
return {
|
|
110
177
|
name: "dynamic-experiences",
|
|
111
|
-
setup: (
|
|
112
|
-
const
|
|
178
|
+
setup: (e) => {
|
|
179
|
+
const t = n?.apiUrl ?? e.apiUrl;
|
|
113
180
|
return {
|
|
114
181
|
onStart: async () => {
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
117
|
-
const s = await
|
|
118
|
-
s &&
|
|
182
|
+
const r = k(e);
|
|
183
|
+
if (r) {
|
|
184
|
+
const s = await p(t, e.projectId, { previewToken: r });
|
|
185
|
+
s && (l(e, s, !0), c(e, s), f(e, s), u(e, s), d(e, s));
|
|
119
186
|
return;
|
|
120
187
|
}
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
|
|
188
|
+
const o = n?.projectConfig ?? F();
|
|
189
|
+
if (o) {
|
|
190
|
+
l(e, o, !1), c(e, o), f(e, o), u(e, o), d(e, o);
|
|
124
191
|
return;
|
|
125
192
|
}
|
|
126
|
-
const i = await
|
|
127
|
-
i &&
|
|
193
|
+
const i = await p(t, e.projectId);
|
|
194
|
+
i && (l(e, i, !1), c(e, i), f(e, i), u(e, i), d(e, i));
|
|
128
195
|
}
|
|
129
196
|
};
|
|
130
197
|
}
|
|
131
198
|
};
|
|
132
199
|
}
|
|
133
200
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
201
|
+
U as createClientHeaders,
|
|
202
|
+
T as dynamicExperiencesPlugin,
|
|
203
|
+
p as fetchProject
|
|
137
204
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEffect as n, sample as i } from "effector";
|
|
2
|
-
import { c, l as g, s as S } from "../../../storage-
|
|
2
|
+
import { c, l as g, s as S } from "../../../storage-Co_LbKr_.js";
|
|
3
3
|
import { l as f } from "../../../logger-C9a75KZn.js";
|
|
4
4
|
const y = ({
|
|
5
5
|
storage: a = "local"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEffect as s, sample as r } from "effector";
|
|
2
|
-
import { c as l, l as y, s as g } from "../../../storage-
|
|
2
|
+
import { c as l, l as y, s as g } from "../../../storage-Co_LbKr_.js";
|
|
3
3
|
const a = l("history", "global"), f = ({
|
|
4
4
|
storage: i = "local"
|
|
5
5
|
} = {}) => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEffect as i, attach as f, sample as c } from "effector";
|
|
2
|
-
import { c as u, l as g, s as d } from "../../../storage-
|
|
2
|
+
import { c as u, l as g, s as d } from "../../../storage-Co_LbKr_.js";
|
|
3
3
|
const p = u("responses", "global"), S = (r, s) => {
|
|
4
4
|
const o = {};
|
|
5
5
|
return Object.entries(r).forEach(([t, n]) => {
|
|
@@ -1,91 +1,86 @@
|
|
|
1
1
|
import { createEffect as u, sample as d } from "effector";
|
|
2
2
|
const x = "picked";
|
|
3
|
-
async function p(
|
|
4
|
-
const { storeName:
|
|
5
|
-
return new Promise((a,
|
|
3
|
+
async function p(r) {
|
|
4
|
+
const { storeName: o, version: c = 1, keyPath: n = "id" } = r;
|
|
5
|
+
return new Promise((a, t) => {
|
|
6
6
|
const e = indexedDB.open(x, c);
|
|
7
7
|
e.onupgradeneeded = () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
}, e.onsuccess = () => a(e.result), e.onerror = () =>
|
|
8
|
+
const s = e.result;
|
|
9
|
+
s.objectStoreNames.contains(o) || s.createObjectStore(o, n ? { keyPath: n } : void 0);
|
|
10
|
+
}, e.onsuccess = () => a(e.result), e.onerror = () => t(new Error(e.error?.message));
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
async function g(
|
|
13
|
+
async function g(r, o) {
|
|
14
14
|
return new Promise((c, n) => {
|
|
15
|
-
const e =
|
|
15
|
+
const e = r.transaction(o, "readonly").objectStore(o).getAll();
|
|
16
16
|
e.onsuccess = () => c(e.result), e.onerror = () => n(new Error(e.error?.message));
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function y(
|
|
19
|
+
async function y(r, o, c) {
|
|
20
20
|
return new Promise((n, a) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const s = r.transaction(o, "readwrite").objectStore(o).put(c);
|
|
22
|
+
s.onsuccess = () => n(), s.onerror = () => a(new Error(s.error?.message));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function b(r, o, c) {
|
|
26
26
|
return new Promise((n, a) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const s = r.transaction(o, "readwrite").objectStore(o).delete(c);
|
|
28
|
+
s.onsuccess = () => n(), s.onerror = () => a(new Error(s.error?.message));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
31
|
+
async function S(r, o) {
|
|
32
32
|
return new Promise((c, n) => {
|
|
33
|
-
const e =
|
|
33
|
+
const e = r.transaction(o, "readwrite").objectStore(o).clear();
|
|
34
34
|
e.onsuccess = () => c(), e.onerror = () => n(new Error(e.error?.message));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const l = "responses",
|
|
37
|
+
const l = "responses", m = { storeName: l, keyPath: "fieldId" }, I = () => ({
|
|
38
38
|
name: "responses-indexdb-plugin",
|
|
39
|
-
setup: (
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
(i, { fieldId:
|
|
39
|
+
setup: (r) => {
|
|
40
|
+
const o = u(async () => {
|
|
41
|
+
const t = await p(m), s = (await g(t, l)).reduce(
|
|
42
|
+
(i, { fieldId: w, value: f }) => (i[w] = f, i),
|
|
43
43
|
{}
|
|
44
44
|
);
|
|
45
|
-
await
|
|
45
|
+
await r.responses.commit(s);
|
|
46
46
|
}), c = u(
|
|
47
|
-
async (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
})
|
|
57
|
-
);
|
|
47
|
+
async (t) => {
|
|
48
|
+
t.forEach((e) => {
|
|
49
|
+
p(m).then((s) => {
|
|
50
|
+
y(s, l, e);
|
|
51
|
+
}).catch((s) => {
|
|
52
|
+
console.error("Failed to store response in IndexedDB:", s);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
58
55
|
}
|
|
59
56
|
), n = u(async () => {
|
|
60
|
-
const
|
|
61
|
-
await
|
|
62
|
-
}), a = u(async (
|
|
63
|
-
const e = await p(
|
|
64
|
-
await
|
|
57
|
+
const t = await p(m);
|
|
58
|
+
await S(t, l);
|
|
59
|
+
}), a = u(async (t) => {
|
|
60
|
+
const e = await p(m);
|
|
61
|
+
await b(e, l, t);
|
|
65
62
|
});
|
|
66
63
|
d({
|
|
67
|
-
source:
|
|
68
|
-
filter: (
|
|
69
|
-
target:
|
|
64
|
+
source: r.eventBus,
|
|
65
|
+
filter: (t) => t.type === "load",
|
|
66
|
+
target: o
|
|
70
67
|
}), d({
|
|
71
|
-
clock:
|
|
72
|
-
source: { responses:
|
|
73
|
-
fn: ({ responses:
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
return r.filter((i) => o.has(i.fieldId));
|
|
68
|
+
clock: r.responses.listStore,
|
|
69
|
+
source: { responses: r.responses.listStore, fields: r.fields.listStore },
|
|
70
|
+
fn: ({ responses: t, fields: e }) => {
|
|
71
|
+
const s = e.filter((i) => !i.policies?.doNotStoreValue);
|
|
72
|
+
return t.filter((i) => s.some((w) => w.id === i.fieldId));
|
|
78
73
|
},
|
|
79
74
|
target: c
|
|
80
75
|
}), d({
|
|
81
|
-
clock:
|
|
76
|
+
clock: r.responses.clearAll,
|
|
82
77
|
target: n
|
|
83
78
|
}), d({
|
|
84
|
-
clock:
|
|
79
|
+
clock: r.responses.clear,
|
|
85
80
|
target: a
|
|
86
81
|
});
|
|
87
82
|
}
|
|
88
83
|
});
|
|
89
84
|
export {
|
|
90
|
-
|
|
85
|
+
I as responsesIndexedDBPlugin
|
|
91
86
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { p as
|
|
3
|
-
const
|
|
4
|
-
let
|
|
5
|
-
const
|
|
1
|
+
import { a as f, G as c, f as m } from "../../../supports-8YT4QKI7.js";
|
|
2
|
+
import { p as a } from "../../../object-JwZ58NOH.js";
|
|
3
|
+
const o = c;
|
|
4
|
+
let s;
|
|
5
|
+
const d = (r) => ({
|
|
6
6
|
name: "single-page-app",
|
|
7
|
-
setup: (
|
|
8
|
-
|
|
7
|
+
setup: (n) => {
|
|
8
|
+
r.instrumentHistory && f() && h(() => {
|
|
9
9
|
requestAnimationFrame(() => {
|
|
10
|
-
|
|
10
|
+
n.start();
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
}), !
|
|
15
|
+
function h(r) {
|
|
16
|
+
if (o.addEventListener("popstate", () => {
|
|
17
|
+
const e = o.location.href, t = s;
|
|
18
|
+
s = e, t !== e && r();
|
|
19
|
+
}), !m())
|
|
20
20
|
return;
|
|
21
|
-
function e
|
|
22
|
-
return function(...
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
|
|
21
|
+
function n(e) {
|
|
22
|
+
return function(...t) {
|
|
23
|
+
const i = t.length > 2 ? t[2] : void 0;
|
|
24
|
+
if (i) {
|
|
25
|
+
const u = s, p = String(i);
|
|
26
|
+
if (s = p, u === p)
|
|
27
|
+
return e.apply(this, t);
|
|
28
|
+
r();
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return e.apply(this, t);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
a(o.history, "pushState", n), a(o.history, "replaceState", n);
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
d as singlePageAppPlugin
|
|
37
37
|
};
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createEvent as i, createStore as
|
|
2
|
-
import {
|
|
1
|
+
import { createEvent as i, createStore as C, createEffect as S, sample as n, attach as h } from "effector";
|
|
2
|
+
import { f as F } from "../../experience-instance-DCknHRkX.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -11,19 +11,19 @@ function R() {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function w(c, p) {
|
|
14
|
-
const { promise: E, resolve: t } = R(), o = i(), s = i(), l = i(), u = i(), d = i(), g = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x =
|
|
14
|
+
const { promise: E, resolve: t } = R(), o = i(), s = i(), l = i(), u = i(), d = i(), g = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x = C({
|
|
15
15
|
currentExperienceIndex: 0,
|
|
16
16
|
renderedExperiences: [],
|
|
17
17
|
isComplete: !1
|
|
18
|
-
}), m =
|
|
18
|
+
}), m = S(
|
|
19
19
|
async ({
|
|
20
20
|
experience: e,
|
|
21
21
|
availableRenderers: r,
|
|
22
|
-
startRendererIndex:
|
|
22
|
+
startRendererIndex: v = 0
|
|
23
23
|
}) => {
|
|
24
24
|
if (!e)
|
|
25
25
|
return null;
|
|
26
|
-
for (let a =
|
|
26
|
+
for (let a = v; a < r.length; a++) {
|
|
27
27
|
const I = r[a], f = e.componentStore.getState();
|
|
28
28
|
if (f && I?.isValidComponent(f.component))
|
|
29
29
|
return { rendered: await I.render(f.component, c, e), rendererIndex: a };
|
|
@@ -75,7 +75,7 @@ function w(c, p) {
|
|
|
75
75
|
filter: ({ experiences: e, state: r }) => r.currentExperienceIndex >= e.length,
|
|
76
76
|
target: u
|
|
77
77
|
});
|
|
78
|
-
const k =
|
|
78
|
+
const k = h({
|
|
79
79
|
source: x,
|
|
80
80
|
effect: (e) => {
|
|
81
81
|
e.isComplete && t(e.renderedExperiences);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("effector"),U=require("@withease/factories"),E=require("./nodes-DsL8kMSX.cjs"),j=require("./supports-YvpQZxbh.cjs"),I=require("./logger-BsmHUUw1.cjs"),he=require("./object-BbFTsGh3.cjs");function ye(e){return typeof e=="number"&&!isNaN(e)}function P(e){return typeof e=="string"}function x(e){return Array.isArray(e)}function ie(e){return e instanceof Promise}function oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(ye(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function $(e){return`${e}`}const we={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>m(e)>m(t),">=":(e,t)=>m(e)>=m(t),"<":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<c;const a=m(r);return n<c&&c<a},"<=":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<=c;const a=m(r);return n<=c&&c<=a},"!!":async e=>await b(e),"!":async e=>!await b(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?P(t)?t.indexOf($(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map($).join(""),substr:(e,t,r)=>{const n=$(e),c=m(t);if(r===void 0)return n.substr(c);const a=m(r);if(a<0){const o=n.substr(c);return o.substr(0,o.length+a)}return n.substr(c,a)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>x(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=$(e);if(n===""||n===".")return this;const c=n.split(".");let a=this;for(const o of c){if(a==null)return r;if(Array.isArray(a)){const l=parseInt(o,10);isNaN(l)?a=a[o]:a=a[l]}else a=a[o]}return a!==void 0?a:r},async missing(...e){const t=x(e[0])?e[0]:e,r=[];for(const n of t){const c=await g({var:n},this);(c===null||c==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!x(r)||!x(t))return[];const n=r.filter(P);return t.filter(P).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(x(e)){const[a,o]=e;r=a,n=o}return!P(r)||!P(n)?!1:new RegExp(r,n).test($(t))},throw(e){throw new Error($(e))}};async function g(e,t){if(!e)return e;if(ie(e))return g(await e,t);if(x(e))return Promise.all(e.map(o=>g(o,t)));if(!oe(e))return e;const r=Ee(e);let n=r?e[r]??[]:[];switch(x(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await b(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const l of n)if(o=await g(l,t),!await b(o))return o;return o}case"or":{let o=null;for(const l of n)if(o=await g(l,t),await b(o))return o;return o}case"map":{const o=await g(n[0],t);return x(o)?await Promise.all(o.map(l=>g(n[1],l))):[]}case"filter":{const o=await g(n[0],t);return x(o)?(await Promise.all(o.map(async p=>{const h=await b(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!x(o))return n.length>2?await g(n[2],t):null;const l=n[1];let h=n.length>2?await g(n[2],t):null;for(const v of o)h=await g(l,{current:v,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!x(o)||o.length===0)return!1;for(const l of o)if(!await b(await g(n[1],l)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!x(o))return!1;for(const l of o)if(await b(await g(n[1],l)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!x(o))return!0;for(const l of o)if(await b(await g(n[1],l)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return oe(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const c=await Promise.all(n.map(o=>g(o,t))),a=r?we[r]:void 0;if(!a)throw new Error(`Unrecognized operation ${r}`);return a.apply(t,c)}async function b(e){return ie(e)?b(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function Ee(e){return Object.keys(e)[0]}function se(e){return!he.isEmpty(e)}async function Q(e,t,r){const n=e.getStateSnapshot(),c=e.predicates.listStore.getState().reduce((l,p)=>({...l,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),a=e.features.listStore.getState().reduce((l,p)=>({...l,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:c,features:a};return await g(t,o)}function Ne(e){return!j.supportsWindow()||!j.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const xe="open";function Ie(e){if(!j.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:xe})}function ke(){return new Promise((e,t)=>{if(!j.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function ve(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const q="picked-root",K="picked-target",be="picked-root";function Ae(e,t){return[...e,{selector:`${be}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const c=Ne(n.selector).filter(a=>!Be(a,t)&&!ce(a,t));return{...n,elements:c}})}function Oe(e,t){return e.flatMap(r=>r.elements.map(n=>Te(n,r.placement,t)))}function Fe(e,t){e.classList.add(K),e.classList.add(`${K}-${t}`)}function Be(e,t){return t?e.classList.contains(`${K}-${t}`):e.classList.contains(`${K}`)}function ce(e,t){return t?e.classList.contains(`${q}-${t}`):e.classList.contains(q)}function _e(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(q),t.classList.add(`${q}-${e}`),t}function Te(e,t,r){let n;const c=_e(r);if(e instanceof Document)n=e.body.appendChild(c);else{switch(t){case"replace":e.replaceWith(c);break;case"before":e.before(c);break;case"after":e.after(c);break;case"prepend":e.prepend(c);break;default:e.append(c);break}n=c}return n}const ae=(e,t,r,n,c=new Set)=>c.has(r.id)?[]:(c.add(r.id),E.isStepNode(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const l=e.find(p=>p.id===o.destinationNodeId);return l?ae(e,t,l,!1,c):[]})),Le=(e,t,r)=>ae(e,t,r,!0,new Set),ue=(e,t,r,n,c=new Set)=>{if(c.has(r.id))return[-1,-1];c.add(r.id);const a=t.filter(p=>p.sourceNodeId===r.id);if(a.length===0)return[0,0];let o=1/0,l=-1/0;for(const p of a){const h=e.find(T=>T.id===p.destinationNodeId);if(!h)continue;const[v,O]=ue(e,t,h,!1,new Set(c));v!==-1&&(o=Math.min(o,v+1),l=Math.max(l,O+1))}return o===1/0?[-1,-1]:[o,l]},Me=(e,t,r)=>ue(e,t,r,!0,new Set),le=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const c=t.filter(l=>l.destinationNodeId===r.id);if(c.length===0)return[-1,-1];let a=1/0,o=-1/0;for(const l of c){const p=e.find(O=>O.id===l.sourceNodeId);if(!p)continue;const[h,v]=le(e,t,p,new Set(n));h!==-1&&(a=Math.min(a,h+1),o=Math.max(o,v+1))}return a===1/0?[-1,-1]:[a,o]},$e=(e,t,r)=>le(e,t,r,new Set),fe=e=>e.find(r=>r.type==="origin")||null,J=(e,t,r)=>{if(!e)return fe(t);const n=r.find(a=>a.sourceNodeId===e.id);if(!n)return null;const c=t.find(a=>a.id===n.destinationNodeId);return c||null};async function De(e,t,r,n){const c=e?"true":"false",a=n.find(o=>o.sourceNodeHandle===c&&o.sourceNodeId===t);return r.find(o=>o.id===a?.destinationNodeId)}const Y=s.createDomain("experience-instance"),Re=U.createFactory(({client:e,experience:t,target:r,options:n})=>{const c=s.createEvent(),a=s.createEvent(),o=s.createEvent(),l=s.createEvent(),p=s.createEvent(),h=s.createEvent(),v=t.componentStore,O=Y.store("transitioning"),T=e.history.entriesStore.map(i=>i.filter(d=>d.experienceId===t.id)),C=T.map(i=>i.filter(d=>E.isStepNode(d.node))),u=T.map(i=>i.at(-1)?.node||null),S=s.combine(e.steps.listStore,u,(i,d)=>i.find(f=>d&&E.isStepNode(d)&&f.key===E.resolveStepKey(d))||null),N=s.combine(e.steps.listStore,C,(i,d)=>{const f=d.at(-2);if(!f||!E.isStepNode(f.node))return null;const y=f.node;return i.find(F=>F.key===E.resolveStepKey(y))||null}),L=s.combine(t.treeStore,u,({nodes:i,edges:d},f)=>f?Le(i,d,f):[]),D=s.combine(t.treeStore,u,({nodes:i,edges:d},f)=>f?$e(i,d,f):[-1,-1]),W=s.combine(t.treeStore,u,({nodes:i,edges:d},f)=>f?Me(i,d,f):[-1,-1]),M=Y.store(!1),H=s.createApi(M,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,d)=>d}),pe=s.createEffect(async()=>{e.history.back({experienceId:t.id})}),ge=s.attach({source:t.treeStore,effect:async(i,d)=>{const f=i.nodes.find(y=>E.isStepNode(y)&&E.resolveStepKey(y)===d);f&&e.history.push({experienceId:t.id,node:f})}}),Z=s.attach({source:u,effect:i=>{}}),G=s.attach({source:t.treeStore,effect:async({nodes:i})=>fe(i)}),V=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},f)=>{if(E.isOriginNode(f))return J(f,i,d)}}),z=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d,conditions:f},y)=>{if(!E.isConditionNode(y))return;const F=y.conditionId??y.conditionalId,w=e.conditions.listStore.getState().find(B=>B.id===F)?.condition??f.find(B=>B.id===F)?.condition;if(!w)return;const A=await Q(e,w);return De(!!A,y.id,i,d)}}),ee=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},f)=>{if(!E.isActionNode(f))return;const y=f.action;if(!y){I.logger("warn",`Action node ${f.id} has no action name`);return}const F=e.actions.getByName(y).getState();if(!F){I.logger("warn",`Action '${y}' not registered on client`);const k=d.find(w=>w.sourceNodeId===f.id&&w.sourceNodeHandle==="false");return k?i.find(w=>w.id===k.destinationNodeId):null}if(typeof F.action!="function"){I.logger("warn",`Action '${y}' is not a function`);const k=d.find(w=>w.sourceNodeId===f.id&&w.sourceNodeHandle==="false");return k?i.find(w=>w.id===k.destinationNodeId):null}try{I.logger("info",`Executing action: ${y}`),await F.action(y);const k=d.find(A=>A.sourceNodeId===f.id&&A.sourceNodeHandle==="true");if(!k)return I.logger("warn",`No 'true' edge found for action node ${f.id}`),null;const w=i.find(A=>A.id===k.destinationNodeId);return I.logger("info",`Action '${y}' succeeded, moving to node ${w?.id}`),w||null}catch(k){I.logger("warn",`Action '${y}' failed:`,k);const w=d.find(B=>B.sourceNodeId===f.id&&B.sourceNodeHandle==="false");if(!w)return I.logger("warn",`No 'false' edge found for action node ${f.id}`),null;const A=i.find(B=>B.id===w.destinationNodeId);return I.logger("info",`Action '${y}' failed, moving to node ${A?.id}`),A||null}}}),me=s.createEffect(i=>{E.isLaunchExperienceNode(i)&&e.experiences.launch({id:i.experienceId})}),te=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:f}])=>J(i,d,f)}),R=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:f}])=>J(i,d,f)}),Se=s.createEffect(i=>{e.history.push({experienceId:t.id,node:i})}),ne=s.attach({source:t.configStore,effect:async({initializeOpenLogic:i})=>n?.initialiseOpen!==void 0?n.initialiseOpen:se(i)?!!await Q(e,i):i??!1}),_=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:v,stateStore:O,isOpenStore:M,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,currentNodeStore:u,currentStepStore:S,previousStepStore:N,nextReachableStepNodesStore:L,stepsToOriginStore:D,stepsToLeafStore:W,goToNextStep:a,goToPreviousStep:o,goToStepById:l,stepsHistoryStore:C}),X=s.createEvent(),re=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:G}),s.sample({clock:X,filter:i=>i!==null,target:re}),s.split({source:re,match:i=>E.isConditionNode(i)?"condition":E.isStepNode(i)?"step":E.isLaunchExperienceNode(i)?"launchExperience":E.isOriginNode(i)?"origin":E.isActionNode(i)?"action":"other",cases:{origin:V,condition:z,step:Z,launchExperience:me,action:ee,__:s.createEvent()}}),s.sample({clock:[z.doneData,V.doneData,G.doneData,R.doneData,te.doneData,ee.doneData],filter:Boolean,target:Se}),s.sample({clock:a,target:R}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:_}))}),s.sample({clock:R.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:_}))}),s.sample({clock:R.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:_}))}),s.sample({clock:o,target:pe}),s.sample({clock:l,target:ge}),s.sample({source:s.combine([z.pending,V.pending,G.pending,R.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:O}),s.sample({clock:Z.doneData,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:_}))}),s.sample({clock:h,target:ne}),s.sample({source:ne.doneData,fn:Boolean,target:M}),s.sample({source:u,clock:c,filter:i=>i?E.isOriginNode(i):!0,target:te}),s.sample({source:M,filter:Boolean,target:c}),s.sample({source:M,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:_}))}),s.sample({source:M,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:_}))}),s.sample({clock:p,target:[h]}),p(),_});function de(e){return U.invoke(Re,e)}const Pe=U.createFactory(({client:e})=>{const t=Y.store({}),r=s.createEvent(),n=s.createEvent(),c=s.createEvent(),a=s.createApi(t,{register(u,S){const N=[...u[S.experienceId]??[]];return N.push(S),{...u,[S.experienceId]:N}},unregister(u,S){const N=S.experienceId,L=u[N]?.filter(D=>D!==S);return{...u,[N]:L??[]}}}),o=s.createEffect(({experience:u,target:S,options:N})=>de({client:e,experience:u,target:S,options:N})),l=s.createEffect(u=>{a.register(u)}),p=s.createEffect(u=>{u.target&&ve(u.target,()=>{c(u)})}),h=s.createEffect(u=>{a.unregister(u)}),v=s.createEffect(u=>{const S=u.componentStore.getState();if(!S){I.logger("warn","No app component registered. Skipping init.");return}const N=S.frameworkStore.getState();if(!N){I.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const L=u.target;if(!L){I.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const D=Ie(L);try{N.render(D,S.component,e,u)}catch(W){I.logger("error",W)}});s.sample({clock:r,target:o}),s.sample({clock:c,target:h}),s.sample({clock:o.doneData,target:[l,p,n]}),s.sample({clock:o.doneData,target:e.eventBus.prepend(u=>({type:"experience_initialize",experience:u}))}),s.sample({clock:n,target:v});function O(u,S,N){r({experience:u,target:S,options:N})}const T=t.map(u=>Object.values(u).flat());function C(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:O,getByExperienceId:C,listStore:T}});function Ce(e){return U.invoke(Pe,e)}exports.createAppHosts=Oe;exports.createExperienceInstance=de;exports.createExperienceInstanceIndex=Ce;exports.domInteractive=ke;exports.evaluateRuleLogic=Q;exports.getTargetElements=Ae;exports.isPickedRoot=ce;exports.isRulesLogic=se;exports.tagTargetElement=Fe;
|