@picked/client 0.0.62-next.12 → 0.0.62-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{api-BTbEUnGh.js → api-DnsQgAfY.js} +1 -1
  2. package/dist/api-Dy5cTzV6.cjs +1 -0
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  7. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/docs/image-optimisation-service.md +6 -6
  11. package/dist/docs/sdk/content-security-policy.md +7 -8
  12. package/dist/docs/sdk/fields.md +2 -2
  13. package/dist/docs/workspaces.mdx +1 -1
  14. package/dist/esm/index.js +277 -342
  15. package/dist/esm/plugins/create-experience/index.js +1 -1
  16. package/dist/esm/plugins/dynamic-experiences/index.js +38 -109
  17. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  18. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  19. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  20. package/dist/esm/server/index.js +1 -1
  21. package/dist/experience-instance-BrLWgVAN.js +501 -0
  22. package/dist/experience-instance-Ct3ogC7n.cjs +1 -0
  23. package/dist/types/entities/experience/experience.d.ts +2 -22
  24. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  25. package/dist/types/entities/step/step.d.ts +2 -17
  26. package/dist/types/entities/step/step.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +0 -2
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
  30. package/dist/types/picked.d.ts +0 -39
  31. package/dist/types/picked.d.ts.map +1 -1
  32. package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -2
  33. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  34. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -18
  35. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  36. package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -63
  37. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  38. package/package.json +1 -11
  39. package/dist/api-DDd_Zf11.cjs +0 -1
  40. package/dist/cjs/plugins/dom-observer/index.js +0 -1
  41. package/dist/dom-C3C6Fmwz.cjs +0 -1
  42. package/dist/dom-DGePXPpM.js +0 -84
  43. package/dist/esm/plugins/dom-observer/index.js +0 -87
  44. package/dist/experience-instance-DImym3m_.js +0 -419
  45. package/dist/experience-instance-DygAdzbn.cjs +0 -1
  46. package/dist/types/entities/content/content.d.ts +0 -37
  47. package/dist/types/entities/content/content.d.ts.map +0 -1
  48. package/dist/types/plugins/dom-observer/index.d.ts +0 -3
  49. package/dist/types/plugins/dom-observer/index.d.ts.map +0 -1
  50. package/dist/types/plugins/dom-observer/plugin.d.ts +0 -50
  51. package/dist/types/plugins/dom-observer/plugin.d.ts.map +0 -1
  52. /package/dist/{id-Cg7fVl1O.cjs → id-Bv44ilEo.cjs} +0 -0
  53. /package/dist/{id-n2yrHvNo.js → id-CRqy981z.js} +0 -0
  54. /package/dist/{storage-hOHCCXvP.js → storage-6Xk0uAxB.js} +0 -0
  55. /package/dist/{storage-BXSlLTRa.cjs → storage-B6lQtc4-.cjs} +0 -0
@@ -1,419 +0,0 @@
1
- import { n as e, t } from "./rules-logic-D_CVBuv7.js";
2
- import "./logger-6z_gb4rA.js";
3
- import { n, o as r } from "./dom-DGePXPpM.js";
4
- import { attach as i, combine as a, createApi as o, createDomain as s, createEffect as c, createEvent as l, sample as u, split as d } from "effector";
5
- import { createFactory as f, invoke as p } from "@withease/factories";
6
- //#region src/utils/nodes.ts
7
- function m(e) {
8
- return e.type === "condition";
9
- }
10
- function h(e) {
11
- return e.type === "step";
12
- }
13
- function g(e) {
14
- return e.type === "experience";
15
- }
16
- function _(e) {
17
- return e.type === "origin";
18
- }
19
- function v(e) {
20
- return e.type === "action";
21
- }
22
- //#endregion
23
- //#region src/utils/node-tree/next-reachable-step-nodes.ts
24
- var y = (e, t, n, r, i = /* @__PURE__ */ new Set()) => i.has(n.id) ? [] : (i.add(n.id), h(n) && !r ? [n] : t.filter((e) => e.sourceNodeId === n.id).flatMap((n) => {
25
- let r = e.find((e) => e.id === n.destinationNodeId);
26
- return r ? y(e, t, r, !1, i) : [];
27
- })), ee = (e, t, n) => y(e, t, n, !0, /* @__PURE__ */ new Set()), b = (e, t, n, r, i = /* @__PURE__ */ new Set()) => {
28
- if (i.has(n.id)) return [-1, -1];
29
- i.add(n.id);
30
- let a = t.filter((e) => e.sourceNodeId === n.id);
31
- if (a.length === 0) return [0, 0];
32
- let o = Infinity, s = -Infinity;
33
- for (let n of a) {
34
- let r = e.find((e) => e.id === n.destinationNodeId);
35
- if (!r) continue;
36
- let [a, c] = b(e, t, r, !1, new Set(i));
37
- a !== -1 && (o = Math.min(o, a + 1), s = Math.max(s, c + 1));
38
- }
39
- return o === Infinity ? [-1, -1] : [o, s];
40
- }, te = (e, t, n) => b(e, t, n, !0, /* @__PURE__ */ new Set()), x = (e, t, n, r = /* @__PURE__ */ new Set()) => {
41
- if (r.has(n.id)) return [-1, -1];
42
- if (r.add(n.id), n.type === "origin") return [0, 0];
43
- let i = t.filter((e) => e.destinationNodeId === n.id);
44
- if (i.length === 0) return [-1, -1];
45
- let a = Infinity, o = -Infinity;
46
- for (let n of i) {
47
- let i = e.find((e) => e.id === n.sourceNodeId);
48
- if (!i) continue;
49
- let [s, c] = x(e, t, i, new Set(r));
50
- s !== -1 && (a = Math.min(a, s + 1), o = Math.max(o, c + 1));
51
- }
52
- return a === Infinity ? [-1, -1] : [a, o];
53
- }, S = (e, t, n) => x(e, t, n, /* @__PURE__ */ new Set()), C = (e) => e.find((e) => e.type === "origin") || null, w = (e, t, n) => {
54
- if (!e) return C(t);
55
- let r = n.find((t) => t.sourceNodeId === e.id);
56
- return r && t.find((e) => e.id === r.destinationNodeId) || null;
57
- };
58
- //#endregion
59
- //#region src/utils/node-tree/get-next-node-from-condition.ts
60
- async function ne(e, t, n, r) {
61
- let i = e ? "true" : "false", a = r.find((e) => e.sourceHandle === i && e.sourceNodeId === t);
62
- return n.find((e) => e.id === a?.destinationNodeId);
63
- }
64
- //#endregion
65
- //#region src/entities/experience-instance/experience-instance.ts
66
- var T = s("experience-instance"), E = f(({ client: r, experience: s, target: f, options: p }) => {
67
- let y = l(), b = l(), x = l(), E = l(), D = l(), O = l(), k = s.componentStore, A = T.store("transitioning"), j = r.history.entriesStore.map((e) => e.filter((e) => e.experienceId === s.id)), M = j.map((e) => e.filter((e) => h(e.node))), N = j.map((e) => e.at(-1)?.node || null), P = a(r.steps.listStore, N, (e, t) => e.find((e) => t && h(t) && e.id === t.stepId) || null), re = a(r.steps.listStore, M, (e, t) => {
68
- let n = t.at(-2);
69
- if (!n || !h(n.node)) return null;
70
- let r = n.node;
71
- return e.find((e) => e.id === r.stepId) || null;
72
- }), F = a(s.treeStore, N, ({ nodes: e, edges: t }, n) => n ? ee(e, t, n) : []), I = a(s.treeStore, N, ({ nodes: e, edges: t }, n) => n ? S(e, t, n) : [-1, -1]), L = a(s.treeStore, N, ({ nodes: e, edges: t }, n) => n ? te(e, t, n) : [-1, -1]), R = T.store(!1), z = o(R, {
73
- open: () => !0,
74
- close: () => !1,
75
- toggle: (e) => !e,
76
- set: (e, t) => t
77
- }), B = c(async () => {
78
- r.history.back({ experienceId: s.id });
79
- }), V = i({
80
- source: s.treeStore,
81
- effect: async (e, t) => {
82
- let n = e.nodes.find((e) => h(e) && e.stepId === t);
83
- n && r.history.push({
84
- experienceId: s.id,
85
- node: n
86
- });
87
- }
88
- }), H = i({
89
- source: N,
90
- effect: (e) => {}
91
- }), U = i({
92
- source: s.treeStore,
93
- effect: async ({ nodes: e }) => C(e)
94
- }), W = i({
95
- source: s.treeStore,
96
- effect: async ({ nodes: e, edges: t }, n) => {
97
- if (_(n)) return w(n, e, t);
98
- }
99
- }), G = i({
100
- source: s.treeStore,
101
- effect: async ({ nodes: e, edges: n, conditions: i }, a) => {
102
- if (!m(a)) return;
103
- let o = i.find((e) => e.id === a.conditionId)?.logic;
104
- return o ? ne(!!await t(r, o), a.id, e, n) : void 0;
105
- }
106
- }), K = i({
107
- source: {
108
- tree: s.treeStore,
109
- actions: r.actions.listStore,
110
- snapshot: r.stateSnapshotStore
111
- },
112
- effect: async ({ tree: e, actions: t, snapshot: n }, r) => {
113
- let { nodes: i, edges: a } = e;
114
- if (!v(r)) return;
115
- let o = r.actionKey;
116
- if (!o) {
117
- `${r.id}`;
118
- return;
119
- }
120
- let s = t.find((e) => e.key === o)?.action;
121
- if (!s) {
122
- `${o}`;
123
- let e = a.find((e) => e.sourceNodeId === r.id && e.sourceHandle === "false");
124
- return e ? i.find((t) => t.id === e.destinationNodeId) : null;
125
- }
126
- if (typeof s != "function") {
127
- `${o}`;
128
- let e = a.find((e) => e.sourceNodeId === r.id && e.sourceHandle === "false");
129
- return e ? i.find((t) => t.id === e.destinationNodeId) : null;
130
- }
131
- try {
132
- `${o}`, await s({
133
- ...n,
134
- args: []
135
- }, { experience: Z });
136
- let e = a.find((e) => e.sourceNodeId === r.id && e.sourceHandle === "true");
137
- if (!e) return `${r.id}`, null;
138
- let t = i.find((t) => t.id === e.destinationNodeId);
139
- return `${o}${t?.id}`, t || null;
140
- } catch {
141
- `${o}`;
142
- let e = a.find((e) => e.sourceNodeId === r.id && e.sourceHandle === "false");
143
- if (!e) return `${r.id}`, null;
144
- let t = i.find((t) => t.id === e.destinationNodeId);
145
- return `${o}${t?.id}`, t || null;
146
- }
147
- }
148
- }), ie = c((e) => {
149
- g(e) && r.experiences.launch({ key: e.experienceKey });
150
- }), q = i({
151
- source: [N, s.treeStore],
152
- effect: async ([e, { nodes: t, edges: n }]) => w(e, t, n)
153
- }), J = i({
154
- source: [N, s.treeStore],
155
- effect: async ([e, { nodes: t, edges: n }]) => w(e, t, n)
156
- }), ae = c((e) => {
157
- r.history.push({
158
- experienceId: s.id,
159
- node: e
160
- });
161
- }), Y = i({
162
- source: s.configStore,
163
- effect: async ({ initializeOpenLogic: n }) => p?.initialiseOpen === void 0 ? e(n) ? !!await t(r, n) : n ?? !1 : p.initialiseOpen
164
- }), X = a(k, r.frameworks.listStore, (e, t) => {
165
- if (!e) return null;
166
- let n = t.find((t) => t.name === e.component.frameworkName);
167
- return n ? {
168
- component: e,
169
- framework: n
170
- } : null;
171
- }, { skipVoid: !1 }), Z, oe = i({
172
- source: X,
173
- effect: (e) => {
174
- if (!e) return;
175
- if (!f) {
176
- `${s.id}`;
177
- return;
178
- }
179
- let t = n(f);
180
- try {
181
- e.framework.render(t, e.component.component, r, Z);
182
- } catch {}
183
- }
184
- });
185
- Z = Object.freeze({
186
- id: Math.random().toString(36).substring(7),
187
- experienceKey: s.key,
188
- experienceId: s.id,
189
- experienceName: s.name,
190
- configStore: s.configStore,
191
- target: f,
192
- componentStore: k,
193
- componentAndFrameworkStore: X,
194
- stateStore: A,
195
- isOpenStore: R,
196
- open: z.open,
197
- close: z.close,
198
- toggleOpen: z.toggle,
199
- setOpen: z.set,
200
- treeStore: s.treeStore,
201
- currentNodeStore: N,
202
- currentStepStore: P,
203
- previousStepStore: re,
204
- nextReachableStepNodesStore: F,
205
- stepsToOriginStore: I,
206
- stepsToLeafStore: L,
207
- goToNextStep: b,
208
- goToPreviousStep: x,
209
- goToStepById: E,
210
- stepsHistoryStore: M,
211
- mountFx: oe
212
- });
213
- let Q = l(), $ = l();
214
- return u({
215
- clock: N,
216
- target: Q
217
- }), u({
218
- clock: Q,
219
- filter: (e) => e === null,
220
- target: U
221
- }), u({
222
- clock: Q,
223
- filter: (e) => e !== null,
224
- target: $
225
- }), d({
226
- source: $,
227
- match: (e) => m(e) ? "condition" : h(e) ? "step" : g(e) ? "launchExperience" : _(e) ? "origin" : v(e) ? "action" : "other",
228
- cases: {
229
- origin: W,
230
- condition: G,
231
- step: H,
232
- launchExperience: ie,
233
- action: K,
234
- __: l()
235
- }
236
- }), u({
237
- clock: [
238
- G.doneData,
239
- W.doneData,
240
- U.doneData,
241
- J.doneData,
242
- q.doneData,
243
- K.doneData
244
- ],
245
- filter: Boolean,
246
- target: ae
247
- }), u({
248
- clock: b,
249
- target: J
250
- }), u({
251
- clock: b,
252
- source: P,
253
- filter: Boolean,
254
- target: r.eventBus.prepend((e) => ({
255
- type: "step_submit",
256
- step: e,
257
- experience: Z
258
- }))
259
- }), u({
260
- clock: J.done,
261
- source: P,
262
- filter: Boolean,
263
- target: r.eventBus.prepend((e) => ({
264
- type: "step_submit_success",
265
- step: e,
266
- experience: Z
267
- }))
268
- }), u({
269
- clock: J.fail,
270
- source: P,
271
- filter: Boolean,
272
- target: r.eventBus.prepend((e) => ({
273
- type: "step_submit_error",
274
- step: e,
275
- experience: Z
276
- }))
277
- }), u({
278
- clock: x,
279
- target: B
280
- }), u({
281
- clock: E,
282
- target: V
283
- }), u({
284
- source: a([
285
- G.pending,
286
- W.pending,
287
- U.pending,
288
- J.pending
289
- ]),
290
- fn: (e) => e.some(Boolean) ? "transitioning" : "ready",
291
- target: A
292
- }), u({
293
- clock: H.doneData,
294
- source: P,
295
- filter: Boolean,
296
- target: r.eventBus.prepend((e) => ({
297
- type: "step_enter",
298
- step: e,
299
- experience: Z
300
- }))
301
- }), u({
302
- clock: O,
303
- target: Y
304
- }), u({
305
- source: Y.doneData,
306
- fn: Boolean,
307
- target: R
308
- }), u({
309
- source: N,
310
- clock: y,
311
- filter: (e) => e ? _(e) : !0,
312
- target: q
313
- }), u({
314
- source: R,
315
- filter: Boolean,
316
- target: y
317
- }), u({
318
- source: R,
319
- filter: Boolean,
320
- target: r.eventBus.prepend(() => ({
321
- type: "experience_open",
322
- experience: Z
323
- }))
324
- }), u({
325
- source: R,
326
- filter: (e) => !e,
327
- target: r.eventBus.prepend(() => ({
328
- type: "experience_close",
329
- experience: Z
330
- }))
331
- }), u({
332
- clock: D,
333
- target: [O]
334
- }), D(), Z;
335
- });
336
- function D(e) {
337
- return p(E, e);
338
- }
339
- var O = f(({ client: e }) => {
340
- let t = T.store({}), n = l(), i = l(), a = l(), s = o(t, {
341
- register(e, t) {
342
- let n = [...e[t.experienceId] ?? []];
343
- return n.push(t), {
344
- ...e,
345
- [t.experienceId]: n
346
- };
347
- },
348
- unregister(e, t) {
349
- let n = t.experienceId, r = e[n]?.filter((e) => e !== t);
350
- return {
351
- ...e,
352
- [n]: r ?? []
353
- };
354
- }
355
- }), d = c(({ experience: t, target: n, options: r }) => D({
356
- client: e,
357
- experience: t,
358
- target: n,
359
- options: r
360
- })), f = c((e) => {
361
- s.register(e);
362
- }), p = c((e) => {
363
- e.target && r(e.target, () => {
364
- a(e);
365
- });
366
- }), m = c((e) => {
367
- s.unregister(e);
368
- }), h = c(async (e) => {
369
- await e.mountFx();
370
- });
371
- u({
372
- clock: n,
373
- target: d
374
- }), u({
375
- clock: a,
376
- target: m
377
- }), u({
378
- clock: d.doneData,
379
- target: [
380
- f,
381
- p,
382
- i
383
- ]
384
- }), u({
385
- clock: d.doneData,
386
- target: e.eventBus.prepend((e) => ({
387
- type: "experience_initialize",
388
- experience: e
389
- }))
390
- }), u({
391
- clock: i,
392
- target: h
393
- });
394
- function g(e, t, r) {
395
- n({
396
- experience: e,
397
- target: t,
398
- options: r
399
- });
400
- }
401
- let _ = t.map((e) => Object.values(e).flat());
402
- function v(e) {
403
- return _.map((t) => t.filter((t) => t.experienceKey === e), { skipVoid: !1 });
404
- }
405
- function y(e) {
406
- return t.map((t) => t[e] || [], { skipVoid: !1 });
407
- }
408
- return {
409
- spawn: g,
410
- getByExperienceKey: v,
411
- getByExperienceId: y,
412
- listStore: _
413
- };
414
- });
415
- function k(e) {
416
- return p(O, e);
417
- }
418
- //#endregion
419
- export { h as i, k as n, m as r, D as t };
@@ -1 +0,0 @@
1
- const e=require(`./rules-logic-H6P8xwHF.cjs`);require(`./logger-fbvQC40v.cjs`);const t=require(`./dom-C3C6Fmwz.cjs`);let n=require(`effector`),r=require(`@withease/factories`);function i(e){return e.type===`condition`}function a(e){return e.type===`step`}function o(e){return e.type===`experience`}function s(e){return e.type===`origin`}function c(e){return e.type===`action`}var l=(e,t,n,r,i=new Set)=>i.has(n.id)?[]:(i.add(n.id),a(n)&&!r?[n]:t.filter(e=>e.sourceNodeId===n.id).flatMap(n=>{let r=e.find(e=>e.id===n.destinationNodeId);return r?l(e,t,r,!1,i):[]})),u=(e,t,n)=>l(e,t,n,!0,new Set),d=(e,t,n,r,i=new Set)=>{if(i.has(n.id))return[-1,-1];i.add(n.id);let a=t.filter(e=>e.sourceNodeId===n.id);if(a.length===0)return[0,0];let o=1/0,s=-1/0;for(let n of a){let r=e.find(e=>e.id===n.destinationNodeId);if(!r)continue;let[a,c]=d(e,t,r,!1,new Set(i));a!==-1&&(o=Math.min(o,a+1),s=Math.max(s,c+1))}return o===1/0?[-1,-1]:[o,s]},f=(e,t,n)=>d(e,t,n,!0,new Set),p=(e,t,n,r=new Set)=>{if(r.has(n.id))return[-1,-1];if(r.add(n.id),n.type===`origin`)return[0,0];let i=t.filter(e=>e.destinationNodeId===n.id);if(i.length===0)return[-1,-1];let a=1/0,o=-1/0;for(let n of i){let i=e.find(e=>e.id===n.sourceNodeId);if(!i)continue;let[s,c]=p(e,t,i,new Set(r));s!==-1&&(a=Math.min(a,s+1),o=Math.max(o,c+1))}return a===1/0?[-1,-1]:[a,o]},m=(e,t,n)=>p(e,t,n,new Set),h=e=>e.find(e=>e.type===`origin`)||null,g=(e,t,n)=>{if(!e)return h(t);let r=n.find(t=>t.sourceNodeId===e.id);return r&&t.find(e=>e.id===r.destinationNodeId)||null};async function _(e,t,n,r){let i=e?`true`:`false`,a=r.find(e=>e.sourceHandle===i&&e.sourceNodeId===t);return n.find(e=>e.id===a?.destinationNodeId)}var v=(0,n.createDomain)(`experience-instance`),y=(0,r.createFactory)(({client:r,experience:l,target:d,options:p})=>{let y=(0,n.createEvent)(),b=(0,n.createEvent)(),x=(0,n.createEvent)(),S=(0,n.createEvent)(),C=(0,n.createEvent)(),w=(0,n.createEvent)(),T=l.componentStore,E=v.store(`transitioning`),D=r.history.entriesStore.map(e=>e.filter(e=>e.experienceId===l.id)),O=D.map(e=>e.filter(e=>a(e.node))),k=D.map(e=>e.at(-1)?.node||null),A=(0,n.combine)(r.steps.listStore,k,(e,t)=>e.find(e=>t&&a(t)&&e.id===t.stepId)||null),j=(0,n.combine)(r.steps.listStore,O,(e,t)=>{let n=t.at(-2);if(!n||!a(n.node))return null;let r=n.node;return e.find(e=>e.id===r.stepId)||null}),M=(0,n.combine)(l.treeStore,k,({nodes:e,edges:t},n)=>n?u(e,t,n):[]),N=(0,n.combine)(l.treeStore,k,({nodes:e,edges:t},n)=>n?m(e,t,n):[-1,-1]),P=(0,n.combine)(l.treeStore,k,({nodes:e,edges:t},n)=>n?f(e,t,n):[-1,-1]),F=v.store(!1),I=(0,n.createApi)(F,{open:()=>!0,close:()=>!1,toggle:e=>!e,set:(e,t)=>t}),L=(0,n.createEffect)(async()=>{r.history.back({experienceId:l.id})}),R=(0,n.attach)({source:l.treeStore,effect:async(e,t)=>{let n=e.nodes.find(e=>a(e)&&e.stepId===t);n&&r.history.push({experienceId:l.id,node:n})}}),z=(0,n.attach)({source:k,effect:e=>{}}),B=(0,n.attach)({source:l.treeStore,effect:async({nodes:e})=>h(e)}),V=(0,n.attach)({source:l.treeStore,effect:async({nodes:e,edges:t},n)=>{if(s(n))return g(n,e,t)}}),H=(0,n.attach)({source:l.treeStore,effect:async({nodes:t,edges:n,conditions:a},o)=>{if(!i(o))return;let s=a.find(e=>e.id===o.conditionId)?.logic;return s?_(!!await e.t(r,s),o.id,t,n):void 0}}),U=(0,n.attach)({source:{tree:l.treeStore,actions:r.actions.listStore,snapshot:r.stateSnapshotStore},effect:async({tree:e,actions:t,snapshot:n},r)=>{let{nodes:i,edges:a}=e;if(!c(r))return;let o=r.actionKey;if(!o){`${r.id}`;return}let s=t.find(e=>e.key===o)?.action;if(!s){`${o}`;let e=a.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);return e?i.find(t=>t.id===e.destinationNodeId):null}if(typeof s!=`function`){`${o}`;let e=a.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);return e?i.find(t=>t.id===e.destinationNodeId):null}try{`${o}`,await s({...n,args:[]},{experience:X});let e=a.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`true`);if(!e)return`${r.id}`,null;let t=i.find(t=>t.id===e.destinationNodeId);return`${o}${t?.id}`,t||null}catch{`${o}`;let e=a.find(e=>e.sourceNodeId===r.id&&e.sourceHandle===`false`);if(!e)return`${r.id}`,null;let t=i.find(t=>t.id===e.destinationNodeId);return`${o}${t?.id}`,t||null}}}),W=(0,n.createEffect)(e=>{o(e)&&r.experiences.launch({key:e.experienceKey})}),G=(0,n.attach)({source:[k,l.treeStore],effect:async([e,{nodes:t,edges:n}])=>g(e,t,n)}),K=(0,n.attach)({source:[k,l.treeStore],effect:async([e,{nodes:t,edges:n}])=>g(e,t,n)}),q=(0,n.createEffect)(e=>{r.history.push({experienceId:l.id,node:e})}),J=(0,n.attach)({source:l.configStore,effect:async({initializeOpenLogic:t})=>p?.initialiseOpen===void 0?e.n(t)?!!await e.t(r,t):t??!1:p.initialiseOpen}),Y=(0,n.combine)(T,r.frameworks.listStore,(e,t)=>{if(!e)return null;let n=t.find(t=>t.name===e.component.frameworkName);return n?{component:e,framework:n}:null},{skipVoid:!1}),X,Z=(0,n.attach)({source:Y,effect:e=>{if(!e)return;if(!d){`${l.id}`;return}let n=t.n(d);try{e.framework.render(n,e.component.component,r,X)}catch{}}});X=Object.freeze({id:Math.random().toString(36).substring(7),experienceKey:l.key,experienceId:l.id,experienceName:l.name,configStore:l.configStore,target:d,componentStore:T,componentAndFrameworkStore:Y,stateStore:E,isOpenStore:F,open:I.open,close:I.close,toggleOpen:I.toggle,setOpen:I.set,treeStore:l.treeStore,currentNodeStore:k,currentStepStore:A,previousStepStore:j,nextReachableStepNodesStore:M,stepsToOriginStore:N,stepsToLeafStore:P,goToNextStep:b,goToPreviousStep:x,goToStepById:S,stepsHistoryStore:O,mountFx:Z});let Q=(0,n.createEvent)(),$=(0,n.createEvent)();return(0,n.sample)({clock:k,target:Q}),(0,n.sample)({clock:Q,filter:e=>e===null,target:B}),(0,n.sample)({clock:Q,filter:e=>e!==null,target:$}),(0,n.split)({source:$,match:e=>i(e)?`condition`:a(e)?`step`:o(e)?`launchExperience`:s(e)?`origin`:c(e)?`action`:`other`,cases:{origin:V,condition:H,step:z,launchExperience:W,action:U,__:(0,n.createEvent)()}}),(0,n.sample)({clock:[H.doneData,V.doneData,B.doneData,K.doneData,G.doneData,U.doneData],filter:Boolean,target:q}),(0,n.sample)({clock:b,target:K}),(0,n.sample)({clock:b,source:A,filter:Boolean,target:r.eventBus.prepend(e=>({type:`step_submit`,step:e,experience:X}))}),(0,n.sample)({clock:K.done,source:A,filter:Boolean,target:r.eventBus.prepend(e=>({type:`step_submit_success`,step:e,experience:X}))}),(0,n.sample)({clock:K.fail,source:A,filter:Boolean,target:r.eventBus.prepend(e=>({type:`step_submit_error`,step:e,experience:X}))}),(0,n.sample)({clock:x,target:L}),(0,n.sample)({clock:S,target:R}),(0,n.sample)({source:(0,n.combine)([H.pending,V.pending,B.pending,K.pending]),fn:e=>e.some(Boolean)?`transitioning`:`ready`,target:E}),(0,n.sample)({clock:z.doneData,source:A,filter:Boolean,target:r.eventBus.prepend(e=>({type:`step_enter`,step:e,experience:X}))}),(0,n.sample)({clock:w,target:J}),(0,n.sample)({source:J.doneData,fn:Boolean,target:F}),(0,n.sample)({source:k,clock:y,filter:e=>e?s(e):!0,target:G}),(0,n.sample)({source:F,filter:Boolean,target:y}),(0,n.sample)({source:F,filter:Boolean,target:r.eventBus.prepend(()=>({type:`experience_open`,experience:X}))}),(0,n.sample)({source:F,filter:e=>!e,target:r.eventBus.prepend(()=>({type:`experience_close`,experience:X}))}),(0,n.sample)({clock:C,target:[w]}),C(),X});function b(e){return(0,r.invoke)(y,e)}var x=(0,r.createFactory)(({client:e})=>{let r=v.store({}),i=(0,n.createEvent)(),a=(0,n.createEvent)(),o=(0,n.createEvent)(),s=(0,n.createApi)(r,{register(e,t){let n=[...e[t.experienceId]??[]];return n.push(t),{...e,[t.experienceId]:n}},unregister(e,t){let n=t.experienceId,r=e[n]?.filter(e=>e!==t);return{...e,[n]:r??[]}}}),c=(0,n.createEffect)(({experience:t,target:n,options:r})=>b({client:e,experience:t,target:n,options:r})),l=(0,n.createEffect)(e=>{s.register(e)}),u=(0,n.createEffect)(e=>{e.target&&t.o(e.target,()=>{o(e)})}),d=(0,n.createEffect)(e=>{s.unregister(e)}),f=(0,n.createEffect)(async e=>{await e.mountFx()});(0,n.sample)({clock:i,target:c}),(0,n.sample)({clock:o,target:d}),(0,n.sample)({clock:c.doneData,target:[l,u,a]}),(0,n.sample)({clock:c.doneData,target:e.eventBus.prepend(e=>({type:`experience_initialize`,experience:e}))}),(0,n.sample)({clock:a,target:f});function p(e,t,n){i({experience:e,target:t,options:n})}let m=r.map(e=>Object.values(e).flat());function h(e){return m.map(t=>t.filter(t=>t.experienceKey===e),{skipVoid:!1})}function g(e){return r.map(t=>t[e]||[],{skipVoid:!1})}return{spawn:p,getByExperienceKey:h,getByExperienceId:g,listStore:m}});function S(e){return(0,r.invoke)(x,e)}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}});
@@ -1,37 +0,0 @@
1
- import { Store } from 'effector';
2
- export interface Content {
3
- id: string;
4
- data: Record<string, unknown>;
5
- }
6
- export type ContentsStore = ReturnType<typeof createContentIndex>;
7
- declare const createContentIndexFactory: () => {
8
- register: (content: Content) => void;
9
- getById: (id: Content["id"]) => Store<Content | null>;
10
- listStore: Store<Content[]>;
11
- indexStore: import('effector').StoreWritable<{
12
- [id: string]: Content;
13
- }>;
14
- };
15
- /**
16
- * Creates an Effector-based index for registering and retrieving content records.
17
- *
18
- * @returns {ContentsStore} A content index with register, getById, and listStore.
19
- * @example
20
- * ```typescript
21
- * const contents = createContentIndex()
22
- * ```
23
- */
24
- export declare function createContentIndex(): ReturnType<typeof createContentIndexFactory>;
25
- /**
26
- * Registers a content record with the given index via the helper function.
27
- *
28
- * @param {Content} content - The content record to register.
29
- * @param {ContentsStore} index - The content index to register the record with.
30
- * @example
31
- * ```typescript
32
- * setupContent(content, index)
33
- * ```
34
- */
35
- export declare function setupContent(content: Content, index: ContentsStore): void;
36
- export {};
37
- //# sourceMappingURL=content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/content.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAK9D,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEjE,QAAA,MAAM,yBAAyB;wBAuBF,OAAO,KAAG,IAAI;kBAmBpB,OAAO,CAAC,IAAI,CAAC,KAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;;;;;CAU1D,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAEjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAEzE"}
@@ -1,3 +0,0 @@
1
- /** @file Public entrypoint for the dom-observer plugin. */
2
- export { domObserverPlugin } from './plugin';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA"}
@@ -1,50 +0,0 @@
1
- import { Plugin } from '../../entities/plugin/plugin';
2
- /**
3
- * Watches the document for `childList` mutations and reconciles experiences
4
- * whose declared target selectors match newly added DOM subtrees. Each
5
- * matching experience runs through its per-experience `shouldInitialiseFx`,
6
- * and on `true` is handed to its `initialiseFx(undefined)`.
7
- *
8
- * Scope: lazy-mounted target hosts that arrive after the initial bulk init
9
- * in `picked.ts`. Route-driven re-initialisation (decisionLogic depending
10
- * on `location.pathname`, lifecycle event re-fires, plugin start hooks)
11
- * is the responsibility of `singlePageAppPlugin`, which calls
12
- * `client.start()` on history events. Pair the two plugins to cover both.
13
- *
14
- * Pipeline:
15
- * - Each experience's `configStore.watch()` pushes its trimmed selectors
16
- * into a reactive `Store<Map<id, string[]>>`. Empty / whitespace-only
17
- * selectors are filtered out.
18
- * - A single `MutationObserver` collects `Element` instances from
19
- * `childList.addedNodes` across one animation frame, then fires a
20
- * single `mutationObserved` event carrying the collected elements.
21
- * - `sample` filters registered experiences to those whose selectors
22
- * match at least one added element via `el.matches` or
23
- * `el.querySelector`. Malformed selectors are skipped per-experience
24
- * without poisoning the rest of the batch. The matched array is
25
- * routed straight into `reconcileMatchedFx` via `sample.target`.
26
- * - `reconcileMatchedFx` invokes each experience's
27
- * `shouldInitialiseFx`, and on `true` its `initialiseFx(undefined)`.
28
- * `initialiseFx` is idempotent: tagged target elements are skipped
29
- * on subsequent passes.
30
- *
31
- * Setup is deferred until `document.body` is parsed, so SDKs loaded from
32
- * `<head>` without `defer` (the standard Shopify-theme / GTM-template
33
- * pattern) still install once the body becomes available.
34
- *
35
- * No-ops outside browser environments and on partial-DOM runtimes that
36
- * lack `MutationObserver` or `requestAnimationFrame`. `MutationObserver`
37
- * does not cross shadow root or iframe boundaries, so experiences whose
38
- * target lives inside a shadow tree or a cross-origin frame are not
39
- * reconciled by this plugin.
40
- *
41
- * @returns {Plugin} The plugin.
42
- * @example
43
- * ```typescript
44
- * createClient({
45
- * plugins: [domObserverPlugin()]
46
- * })
47
- * ```
48
- */
49
- export declare const domObserverPlugin: () => Plugin;
50
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAiBpC,CAAA"}
File without changes
File without changes