@picked/client 0.0.1-dev.1770178792114 → 0.0.1-dev.1770256874555

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 (28) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/cjs/plugins/create-experience/index.js +1 -1
  3. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  4. package/dist/cjs/server/index.js +1 -1
  5. package/dist/esm/index.js +549 -468
  6. package/dist/esm/plugins/create-experience/index.js +90 -82
  7. package/dist/esm/plugins/experience-browser-storage/index.js +12 -13
  8. package/dist/esm/plugins/single-page-app/index.js +1 -1
  9. package/dist/esm/plugins/web-components/index.js +1 -1
  10. package/dist/esm/plugins/window-object/index.js +1 -1
  11. package/dist/esm/server/index.js +1 -1
  12. package/dist/experience-instance-D0bQ9DzM.js +815 -0
  13. package/dist/experience-instance-D8RtqKEZ.cjs +1 -0
  14. package/dist/{supports-COb-sl36.js → supports-8YT4QKI7.js} +5 -5
  15. package/dist/types/entities/experience-instance/experience-instance.d.ts +30 -115
  16. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  17. package/dist/types/entities/field/field.d.ts +33 -2
  18. package/dist/types/entities/field/field.d.ts.map +1 -1
  19. package/dist/types/entities/response/response.d.ts.map +1 -1
  20. package/dist/types/picked.d.ts +2 -76
  21. package/dist/types/picked.d.ts.map +1 -1
  22. package/dist/types/plugins/create-experience/create-experience.d.ts +1 -1
  23. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  24. package/dist/types/utils/events.d.ts +10 -18
  25. package/dist/types/utils/events.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/dist/experience-instance-DXLWzNXG.cjs +0 -1
  28. package/dist/experience-instance-eADy3oIy.js +0 -810
@@ -6,42 +6,42 @@ const r = {
6
6
  deserialize(e) {
7
7
  return JSON.parse(e);
8
8
  }
9
- }, v = (e) => ({
9
+ }, x = (e) => ({
10
10
  name: "create-experience",
11
11
  setup: (o) => {
12
- e.experiences.forEach((n) => {
13
- const s = n.serialize(), d = r.deserialize(s);
14
- d.component = n.component, o.registerExperience(d), d.fields.forEach((N) => {
12
+ e.experiences.forEach((s) => {
13
+ const n = s.serialize(), d = r.deserialize(n);
14
+ d.component = s.component, o.registerExperience(d), d.fields.forEach((N) => {
15
15
  o.registerField(N);
16
16
  });
17
17
  });
18
18
  }
19
- }), g = (e, o) => ({
19
+ }), y = (e, o) => ({
20
20
  id: f("node"),
21
21
  position: [0, 0],
22
22
  experience: o,
23
23
  type: "action",
24
24
  action: e.action,
25
- addNext(s) {
26
- if (!s.node) throw new Error("Cannot connect to node");
25
+ addNext(n) {
26
+ if (!n.node) throw new Error("Cannot connect to node");
27
27
  const d = h(
28
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: null },
28
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: null },
29
29
  o
30
30
  );
31
31
  o.edges.push(d);
32
32
  },
33
- onSuccess(s) {
34
- if (!s.node) throw new Error("Cannot connect to node");
33
+ onSuccess(n) {
34
+ if (!n.node) throw new Error("Cannot connect to node");
35
35
  const d = h(
36
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: "true" },
36
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "true" },
37
37
  o
38
38
  );
39
39
  o.edges.push(d);
40
40
  },
41
- onFail(s) {
42
- if (!s.node) throw new Error("Cannot connect to node");
41
+ onFail(n) {
42
+ if (!n.node) throw new Error("Cannot connect to node");
43
43
  const d = h(
44
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: "false" },
44
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "false" },
45
45
  o
46
46
  );
47
47
  o.edges.push(d);
@@ -54,51 +54,51 @@ const r = {
54
54
  position: this.position
55
55
  });
56
56
  }
57
- }), E = (e) => ({
57
+ }), V = (e) => ({
58
58
  id: e.id ?? f("step"),
59
59
  label: e.label,
60
60
  fields: e.fields ?? [],
61
61
  addField(o) {
62
- const n = "serialize" in o ? o : m(o);
63
- return this.fields?.includes(n) || this.fields?.push(n), n;
62
+ const s = "serialize" in o ? o : m(o);
63
+ return this.fields?.includes(s) || this.fields?.push(s), s;
64
64
  }
65
- }), y = (e, o) => {
66
- const n = {
65
+ }), z = (e, o) => {
66
+ const s = {
67
67
  id: e.id ?? f("step"),
68
68
  label: e.label,
69
69
  experience: o,
70
70
  fields: e.fields ?? [],
71
71
  node: null,
72
- nextStep(s) {
73
- return this.experience.addStep(s, this);
72
+ nextStep(n) {
73
+ return this.experience.addStep(n, this);
74
74
  },
75
- nextConditional(s) {
76
- return this.experience.addConditional(s, this);
75
+ nextConditional(n) {
76
+ return this.experience.addConditional(n, this);
77
77
  },
78
- addNextExperience(s) {
79
- return this.experience.addExperience(s, this);
78
+ addNextExperience(n) {
79
+ return this.experience.addExperience(n, this);
80
80
  },
81
- addField(s) {
82
- return this.experience.addField(s, this);
81
+ addField(n) {
82
+ return this.experience.addField(n, this);
83
83
  },
84
84
  serialize() {
85
85
  return r.serialize({
86
86
  id: this.id,
87
87
  label: this.label,
88
- fieldIds: this.fields.map((s) => s.id)
88
+ fieldIds: this.fields.map((n) => n.id)
89
89
  });
90
90
  }
91
91
  };
92
- return p({ step: n, type: "step" }, o), n;
93
- }, z = () => [0, 0], p = (e, o) => {
94
- const n = {
92
+ return p({ step: s, type: "step" }, o), s;
93
+ }, g = () => [0, 0], p = (e, o) => {
94
+ const s = {
95
95
  id: f("node"),
96
- position: z(),
96
+ position: g(),
97
97
  experience: o
98
98
  };
99
99
  if (e.type === "step") {
100
100
  const d = {
101
- ...n,
101
+ ...s,
102
102
  type: "step",
103
103
  connectedStep: e.step,
104
104
  serialize() {
@@ -115,7 +115,7 @@ const r = {
115
115
  }
116
116
  if (e.type === "conditional") {
117
117
  const d = {
118
- ...n,
118
+ ...s,
119
119
  type: "conditional",
120
120
  connectedConditional: e.conditional,
121
121
  serialize() {
@@ -130,7 +130,7 @@ const r = {
130
130
  return d.connectedConditional.node = d, d;
131
131
  }
132
132
  return e.type === "experience" ? {
133
- ...n,
133
+ ...s,
134
134
  type: "experience",
135
135
  connectedExperience: e.experience,
136
136
  serialize() {
@@ -142,7 +142,7 @@ const r = {
142
142
  });
143
143
  }
144
144
  } : {
145
- ...n,
145
+ ...s,
146
146
  type: "origin",
147
147
  serialize() {
148
148
  return r.serialize({
@@ -167,25 +167,25 @@ const r = {
167
167
  });
168
168
  }
169
169
  }), b = (e, o) => {
170
- const n = {
170
+ const s = {
171
171
  id: f("conditional"),
172
172
  condition: e.condition,
173
173
  node: null,
174
174
  experience: o,
175
- addTrue(s) {
176
- if (!this.node || !s.node)
175
+ addTrue(n) {
176
+ if (!this.node || !n.node)
177
177
  throw new Error("todo no node");
178
178
  const d = h(
179
- { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
179
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "true" },
180
180
  this.experience
181
181
  );
182
182
  this.experience.edges.push(d);
183
183
  },
184
- addFalse(s) {
185
- if (!this.node || !s.node)
184
+ addFalse(n) {
185
+ if (!this.node || !n.node)
186
186
  throw new Error("todo no node");
187
187
  const d = h(
188
- { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
188
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "false" },
189
189
  this.experience
190
190
  );
191
191
  this.experience.edges.push(d);
@@ -197,7 +197,7 @@ const r = {
197
197
  });
198
198
  }
199
199
  };
200
- return p({ conditional: n, type: "conditional" }, o), n;
200
+ return p({ conditional: s, type: "conditional" }, o), s;
201
201
  }, m = (e) => ({
202
202
  id: e.id,
203
203
  name: e.name,
@@ -211,12 +211,12 @@ const r = {
211
211
  validation: e.validation ?? {},
212
212
  condition: e.condition,
213
213
  required: e.required,
214
- options: e.options?.map((n) => ({
215
- ...n
214
+ options: e.options?.map((s) => ({
215
+ ...s
216
216
  })) ?? null,
217
217
  policies: e.policies,
218
218
  serialize() {
219
- const n = {
219
+ const s = {
220
220
  id: this.id,
221
221
  name: this.name,
222
222
  label: this.label,
@@ -227,7 +227,7 @@ const r = {
227
227
  validation: this.validation,
228
228
  condition: this.condition,
229
229
  policies: this.policies
230
- }, s = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
230
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
231
231
  switch (this.type) {
232
232
  case "text":
233
233
  if (this.multiple) {
@@ -239,7 +239,7 @@ const r = {
239
239
  t.length === 0 && (t = void 0);
240
240
  }
241
241
  return r.serialize({
242
- ...n,
242
+ ...s,
243
243
  type: "text",
244
244
  multiple: !0,
245
245
  defaultValue: t,
@@ -252,10 +252,10 @@ const r = {
252
252
  });
253
253
  }
254
254
  return r.serialize({
255
- ...n,
255
+ ...s,
256
256
  type: "text",
257
257
  multiple: !1,
258
- defaultValue: s,
258
+ defaultValue: n,
259
259
  options: this.options ? this.options.map((t) => ({
260
260
  id: t.id,
261
261
  label: t.label,
@@ -273,7 +273,7 @@ const r = {
273
273
  t.length === 0 && (t = void 0);
274
274
  }
275
275
  return r.serialize({
276
- ...n,
276
+ ...s,
277
277
  type: "number",
278
278
  multiple: !0,
279
279
  defaultValue: t,
@@ -286,7 +286,7 @@ const r = {
286
286
  });
287
287
  }
288
288
  return r.serialize({
289
- ...n,
289
+ ...s,
290
290
  type: "number",
291
291
  multiple: !1,
292
292
  defaultValue: d,
@@ -307,7 +307,7 @@ const r = {
307
307
  t.length === 0 && (t = void 0);
308
308
  }
309
309
  return r.serialize({
310
- ...n,
310
+ ...s,
311
311
  type: "boolean",
312
312
  multiple: !0,
313
313
  defaultValue: t,
@@ -320,7 +320,7 @@ const r = {
320
320
  });
321
321
  }
322
322
  return r.serialize({
323
- ...n,
323
+ ...s,
324
324
  type: "boolean",
325
325
  multiple: !1,
326
326
  defaultValue: N,
@@ -331,30 +331,38 @@ const r = {
331
331
  condition: t.condition
332
332
  })) : null
333
333
  });
334
- // todo: support for object type fields
335
- // case 'object':
336
- // if (this.multiple) {
337
- // return serialization.serialize({
338
- // ...baseField,
339
- // type: 'object',
340
- // multiple: true,
341
- // defaultValue: this.defaultValue,
342
- // options: this.options,
343
- // })
344
- // }
345
- // return serialization.serialize({
346
- // ...baseField,
347
- // type: 'object',
348
- // multiple: false,
349
- // defaultValue: this.defaultValue,
350
- // options: this.options,
351
- // })
334
+ case "object":
335
+ return this.multiple ? r.serialize({
336
+ ...s,
337
+ type: "object",
338
+ multiple: !0,
339
+ defaultValue: this.defaultValue,
340
+ options: this.options ? this.options.map((t) => ({
341
+ id: t.id,
342
+ label: t.label,
343
+ description: t.description,
344
+ value: t.value,
345
+ condition: t.condition
346
+ })) : null
347
+ }) : r.serialize({
348
+ ...s,
349
+ type: "object",
350
+ multiple: !1,
351
+ defaultValue: this.defaultValue,
352
+ options: this.options ? this.options.map((t) => ({
353
+ id: t.id,
354
+ label: t.label,
355
+ description: t.description,
356
+ value: t.value,
357
+ condition: t.condition
358
+ })) : null
359
+ });
352
360
  default:
353
361
  throw new Error("Unsupported field type");
354
362
  }
355
363
  }
356
- }), V = (e) => {
357
- const o = [], n = [], s = [], d = [], N = [], t = e.condition ?? e.decide;
364
+ }), E = (e) => {
365
+ const o = [], s = [], n = [], d = [], N = [], t = e.condition ?? e.decide;
358
366
  return {
359
367
  id: e.id,
360
368
  component: e.component,
@@ -364,14 +372,14 @@ const r = {
364
372
  decide: e.decide,
365
373
  targets: e.targets,
366
374
  steps: o,
367
- nodes: n,
368
- edges: s,
375
+ nodes: s,
376
+ edges: n,
369
377
  fields: N,
370
378
  conditionals: d,
371
379
  addStep(i, u) {
372
380
  let l = u?.node;
373
381
  this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
374
- const a = "serialize" in i ? i : y(i, this);
382
+ const a = "serialize" in i ? i : z(i, this);
375
383
  if (l) {
376
384
  if (!a.node)
377
385
  throw new Error("todo no node");
@@ -388,7 +396,7 @@ const r = {
388
396
  addAction(i, u) {
389
397
  let l = u?.node;
390
398
  this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
391
- const a = "serialize" in i ? i : g(i, this);
399
+ const a = "serialize" in i ? i : y(i, this);
392
400
  if (l) {
393
401
  const c = h(
394
402
  { sourceNode: l, destinationNode: a, sourceNodeHandle: null },
@@ -456,10 +464,10 @@ const r = {
456
464
  export {
457
465
  b as createConditional,
458
466
  h as createEdge,
459
- V as createExperience,
460
- v as createExperiencePlugin,
467
+ E as createExperience,
468
+ x as createExperiencePlugin,
461
469
  m as createField,
462
470
  p as createNode,
463
- E as createStep,
471
+ V as createStep,
464
472
  r as serialization
465
473
  };
@@ -1,35 +1,34 @@
1
- import { createEffect as r, sample as i } from "effector";
1
+ import { createEffect as n, sample as i } from "effector";
2
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"
6
6
  } = {}) => ({
7
7
  name: "experience-browser-storage-plugin",
8
- setup: (n) => {
9
- const o = a === "local" ? g : S, p = r(async (e) => {
8
+ setup: (s) => {
9
+ const r = a === "local" ? g : S, p = n(async (e) => {
10
10
  if (!e) {
11
11
  f("warn", "No experience instance provided to loadExperienceVisiblityFx.");
12
12
  return;
13
13
  }
14
- const t = c("open-close", "experience", e), s = o.get(t).boolean();
15
- e.setOpen(s ?? e.isOpenStore.getState());
14
+ const t = c("open-close", "experience", e), o = r.get(t).boolean();
15
+ e.setOpen(o ?? e.isOpenStore.getState());
16
16
  });
17
17
  i({
18
- source: n.eventBus,
19
- filter: (e) => e.type === "experience_initialize" && "experienceInstance" in e,
20
- // @ts-ignore todo
21
- fn: (e) => e.experienceInstance,
18
+ source: s.eventBus,
19
+ filter: (e) => e.type === "experience_initialize" && "experience" in e,
20
+ fn: (e) => e.experience,
22
21
  target: p
23
22
  });
24
- const l = r(async (e) => {
25
- const t = c("open-close", "experience", e), s = e.isOpenStore.getState();
26
- o.set(t, s);
23
+ const l = n(async (e) => {
24
+ const t = c("open-close", "experience", e), o = e.isOpenStore.getState();
25
+ r.set(t, o);
27
26
  }), x = (e) => i({
28
27
  source: e.isOpenStore,
29
28
  fn: () => e,
30
29
  target: l
31
30
  });
32
- n.experienceInstances.listStore.watch((e) => {
31
+ s.experienceInstances.listStore.watch((e) => {
33
32
  e.forEach((t) => x(t));
34
33
  });
35
34
  }
@@ -1,4 +1,4 @@
1
- import { a as f, G as c, f as m } from "../../../supports-COb-sl36.js";
1
+ import { a as f, G as c, f as m } from "../../../supports-8YT4QKI7.js";
2
2
  import { p as a } from "../../../object-JwZ58NOH.js";
3
3
  const o = c;
4
4
  let s;
@@ -1,4 +1,4 @@
1
- import { a as s, k as i } from "../../../supports-COb-sl36.js";
1
+ import { a as s, k as i } from "../../../supports-8YT4QKI7.js";
2
2
  const p = () => ({
3
3
  name: "web-components",
4
4
  setup: (e) => {
@@ -1,4 +1,4 @@
1
- import { a as i } from "../../../supports-COb-sl36.js";
1
+ import { a as i } from "../../../supports-8YT4QKI7.js";
2
2
  const t = () => ({
3
3
  name: "window",
4
4
  setup: (o) => {
@@ -1,5 +1,5 @@
1
1
  import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
2
- import { h as F } from "../../experience-instance-eADy3oIy.js";
2
+ import { h as F } from "../../experience-instance-D0bQ9DzM.js";
3
3
  function R() {
4
4
  let c, p;
5
5
  return {