@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774244905386

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 (119) hide show
  1. package/dist/{api-oudcFuUX.js → api-ENA5t36y.js} +1 -1
  2. package/dist/{api-BEXzPJHZ.cjs → api-dkMxUUe0.cjs} +1 -1
  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/plugins/responses-indexeddb/index.js +1 -1
  10. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  11. package/dist/cjs/plugins/web-components/index.js +1 -1
  12. package/dist/cjs/server/index.js +1 -1
  13. package/dist/esm/index.js +503 -426
  14. package/dist/esm/plugins/create-experience/index.js +329 -294
  15. package/dist/esm/plugins/dynamic-experiences/index.js +53 -30
  16. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  17. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  18. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  19. package/dist/esm/plugins/responses-indexeddb/index.js +9 -5
  20. package/dist/esm/plugins/single-page-app/index.js +4 -4
  21. package/dist/esm/plugins/web-components/index.js +1 -1
  22. package/dist/esm/server/index.js +1 -1
  23. package/dist/experience-instance-BODAwa-_.js +713 -0
  24. package/dist/experience-instance-DImQh64e.cjs +1 -0
  25. package/dist/object-BReQiaSS.cjs +1 -0
  26. package/dist/{object-C82v79xc.js → object-Clj5zVr1.js} +1 -2
  27. package/dist/storage-BFjb8azI.cjs +1 -0
  28. package/dist/{storage-6Xk0uAxB.js → storage-DyxpJ0pg.js} +1 -3
  29. package/dist/types/entities/action/action.d.ts.map +1 -1
  30. package/dist/types/entities/condition/condition.d.ts +17 -0
  31. package/dist/types/entities/condition/condition.d.ts.map +1 -0
  32. package/dist/types/entities/experience/experience.d.ts +36 -59
  33. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  34. package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
  35. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  36. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  37. package/dist/types/entities/field/field.d.ts +17 -12
  38. package/dist/types/entities/field/field.d.ts.map +1 -1
  39. package/dist/types/entities/history/history.d.ts.map +1 -1
  40. package/dist/types/entities/project/project.d.ts +9 -0
  41. package/dist/types/entities/project/project.d.ts.map +1 -0
  42. package/dist/types/entities/response/response.d.ts +10 -7
  43. package/dist/types/entities/response/response.d.ts.map +1 -1
  44. package/dist/types/entities/step/step.d.ts +38 -0
  45. package/dist/types/entities/step/step.d.ts.map +1 -0
  46. package/dist/types/index.d.ts +3 -1
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/logic-engine.d.ts +8 -2
  49. package/dist/types/logic-engine.d.ts.map +1 -1
  50. package/dist/types/picked.d.ts +61 -52
  51. package/dist/types/picked.d.ts.map +1 -1
  52. package/dist/types/plugins/create-experience/create-experience.d.ts +61 -29
  53. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  54. package/dist/types/plugins/create-experience/index.d.ts +2 -2
  55. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  56. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  57. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
  58. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  59. package/dist/types/plugins/dynamic-experiences/types.d.ts +47 -0
  60. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  61. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
  62. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  63. package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -1
  64. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  65. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
  66. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  67. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  68. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  69. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  70. package/dist/types/utils/dom.d.ts +3 -0
  71. package/dist/types/utils/dom.d.ts.map +1 -1
  72. package/dist/types/utils/events.d.ts +2 -2
  73. package/dist/types/utils/events.d.ts.map +1 -1
  74. package/dist/types/utils/global-obj.d.ts +1 -0
  75. package/dist/types/utils/global-obj.d.ts.map +1 -1
  76. package/dist/types/utils/indexed-db.d.ts +1 -2
  77. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  78. package/dist/types/utils/key.d.ts +12 -0
  79. package/dist/types/utils/key.d.ts.map +1 -0
  80. package/dist/types/utils/logger.d.ts.map +1 -1
  81. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  82. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  83. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
  84. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  85. package/dist/types/utils/nodes.d.ts +25 -2
  86. package/dist/types/utils/nodes.d.ts.map +1 -1
  87. package/dist/types/utils/object.d.ts +8 -0
  88. package/dist/types/utils/object.d.ts.map +1 -1
  89. package/dist/types/utils/picked-config.d.ts +1 -1
  90. package/dist/types/utils/picked-config.d.ts.map +1 -1
  91. package/dist/types/utils/search-params.d.ts.map +1 -1
  92. package/dist/types/utils/storage.d.ts.map +1 -1
  93. package/package.json +1 -11
  94. package/dist/cjs/form/index.js +0 -1
  95. package/dist/esm/form/index.js +0 -428
  96. package/dist/experience-instance-DZiAwXph.js +0 -481
  97. package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
  98. package/dist/object-CUJOjanb.cjs +0 -1
  99. package/dist/rules-logic-B7vJrWyO.js +0 -231
  100. package/dist/rules-logic-CXr4wXcG.cjs +0 -1
  101. package/dist/storage-B6lQtc4-.cjs +0 -1
  102. package/dist/types/form/build-responses.d.ts +0 -14
  103. package/dist/types/form/build-responses.d.ts.map +0 -1
  104. package/dist/types/form/create-field-evaluator.d.ts +0 -19
  105. package/dist/types/form/create-field-evaluator.d.ts.map +0 -1
  106. package/dist/types/form/create-field-validation.d.ts +0 -44
  107. package/dist/types/form/create-field-validation.d.ts.map +0 -1
  108. package/dist/types/form/create-form.d.ts +0 -66
  109. package/dist/types/form/create-form.d.ts.map +0 -1
  110. package/dist/types/form/create-submit-pipeline.d.ts +0 -58
  111. package/dist/types/form/create-submit-pipeline.d.ts.map +0 -1
  112. package/dist/types/form/get-step-fields.d.ts +0 -5
  113. package/dist/types/form/get-step-fields.d.ts.map +0 -1
  114. package/dist/types/form/index.d.ts +0 -10
  115. package/dist/types/form/index.d.ts.map +0 -1
  116. package/dist/types/plugins/create-experience/serialization.d.ts +0 -6
  117. package/dist/types/plugins/create-experience/serialization.d.ts.map +0 -1
  118. /package/dist/{id-CRqy981z.js → id-BniPxOdF.js} +0 -0
  119. /package/dist/{id-Bv44ilEo.cjs → id-CIbS4P60.cjs} +0 -0
@@ -1,5 +1,5 @@
1
1
  import "../../../logger-6z_gb4rA.js";
2
- import { i as e, t } from "../../../api-oudcFuUX.js";
2
+ import { i as e, t } from "../../../api-ENA5t36y.js";
3
3
  //#region src/plugins/dynamic-experiences/hash.ts
4
4
  function n(e) {
5
5
  let t = 2166136261;
@@ -15,16 +15,39 @@ function i(e, t) {
15
15
  //#endregion
16
16
  //#region src/plugins/dynamic-experiences/plugin.ts
17
17
  function a(e) {
18
- return typeof e != "object" || !e || !("id" in e && "name" in e && "enabled" in e && "weight" in e && "version" in e) ? !1 : typeof e.id == "string" && typeof e.name == "string" && typeof e.enabled == "boolean" && typeof e.weight == "number" && typeof e.version == "number";
18
+ return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
19
19
  }
20
- function o(e) {
21
- return typeof e != "object" || !e || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(a);
20
+ function o(e, t) {
21
+ if (t.conditions) for (let n of t.conditions) e.registerCondition(n);
22
22
  }
23
- function s(e) {
23
+ function s(e, t) {
24
+ e.registerExperience({
25
+ id: t.id,
26
+ key: t.key,
27
+ name: t.name,
28
+ targets: t.targets ?? [],
29
+ nodes: t.nodes,
30
+ edges: t.edges,
31
+ actions: t.actions,
32
+ condition: t.condition,
33
+ initializeOpen: t.initializeOpen,
34
+ componentName: t.componentName
35
+ });
36
+ }
37
+ function c(e, t) {
38
+ if (t.fields) for (let n of t.fields) e.registerField(n);
39
+ }
40
+ function l(e, t) {
41
+ if (t.steps) for (let n of t.steps) e.registerStep(n);
42
+ }
43
+ function u(e, t) {
44
+ if (t.experiences) for (let n of t.experiences) s(e, n);
45
+ }
46
+ function d(e) {
24
47
  let t = e.searchParams["preview-token"];
25
48
  if (t && t.length > 0) return t[0];
26
49
  }
27
- function c(e) {
50
+ function f(e) {
28
51
  let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
29
52
  if (!n) return t;
30
53
  for (let e of n) {
@@ -33,13 +56,13 @@ function c(e) {
33
56
  }
34
57
  return t;
35
58
  }
36
- function l(e, t, n) {
37
- let i = c(e), a = e.session?.id;
59
+ function p(e, t, n) {
60
+ let i = f(e), a = e.session?.id;
38
61
  if (!a) throw Error("Session ID is required for feature registration");
39
62
  let o = r(a);
40
- for (let r of t.features) i.has(r.id) || u(e, r, n, o);
63
+ for (let r of t.features) i.has(r.id) || m(e, r, n, o);
41
64
  }
42
- function u(e, t, n, r) {
65
+ function m(e, t, n, r) {
43
66
  e.registerFeature(t.id, {
44
67
  key: `v${t.version}`,
45
68
  name: t.name,
@@ -47,7 +70,7 @@ function u(e, t, n, r) {
47
70
  decide: () => t.enabled ? i(r, t.weight) : !1
48
71
  });
49
72
  }
50
- function d() {
73
+ function h() {
51
74
  let e;
52
75
  try {
53
76
  e = __PICKED_PROJECT_CONFIG__;
@@ -62,9 +85,9 @@ function d() {
62
85
  return;
63
86
  }
64
87
  else t = e;
65
- if (o(t)) return t;
88
+ if (a(t)) return t;
66
89
  }
67
- function f(e) {
90
+ function g(e) {
68
91
  try {
69
92
  let t = new URL(e).hostname;
70
93
  return t === "localhost" || t === "127.0.0.1" || t === "::1";
@@ -72,49 +95,49 @@ function f(e) {
72
95
  return !1;
73
96
  }
74
97
  }
75
- function p(e) {
98
+ function _(e) {
76
99
  if (typeof e != "object" || !e || !("cause" in e)) return !1;
77
100
  let { cause: t } = e;
78
101
  return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
79
102
  }
80
- async function m(e, n, r) {
81
- let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
103
+ async function v(e, n, r) {
104
+ let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, o;
82
105
  try {
83
- a = await t(e, i, r?.headers);
106
+ o = await t(e, i, r?.headers);
84
107
  } catch (t) {
85
- return f(e) && p(t), null;
108
+ return g(e) && _(t), null;
86
109
  }
87
- if (!a.ok) return `${a.status.toString()}`, null;
110
+ if (!o.ok) return `${o.status.toString()}`, null;
88
111
  let s;
89
112
  try {
90
- s = await a.json();
113
+ s = await o.json();
91
114
  } catch {
92
115
  return null;
93
116
  }
94
- return o(s) ? s : null;
117
+ return a(s) ? s : null;
95
118
  }
96
- function h(e) {
119
+ function y(e) {
97
120
  return {
98
121
  name: "dynamic-experiences",
99
122
  setup: (t) => {
100
123
  let n = e?.apiUrl ?? t.apiUrl;
101
124
  return { onStart: async () => {
102
- let r = s(t);
125
+ let r = d(t);
103
126
  if (r) {
104
- let e = await m(n, t.projectId, { previewToken: r });
105
- e && l(t, e, !0);
127
+ let e = await v(n, t.projectId, { previewToken: r });
128
+ e && (p(t, e, !0), o(t, e), c(t, e), l(t, e), u(t, e));
106
129
  return;
107
130
  }
108
- let i = e?.projectConfig ?? d();
131
+ let i = e?.projectConfig ?? h();
109
132
  if (i) {
110
- l(t, i, !1);
133
+ p(t, i, !1), o(t, i), c(t, i), l(t, i), u(t, i);
111
134
  return;
112
135
  }
113
- let a = await m(n, t.projectId);
114
- a && l(t, a, !1);
136
+ let a = await v(n, t.projectId);
137
+ a && (p(t, a, !1), o(t, a), c(t, a), l(t, a), u(t, a));
115
138
  } };
116
139
  }
117
140
  };
118
141
  }
119
142
  //#endregion
120
- export { e as createClientHeaders, h as dynamicExperiencesPlugin, m as fetchProject };
143
+ export { e as createClientHeaders, y as dynamicExperiencesPlugin, v as fetchProject };
@@ -1,5 +1,5 @@
1
1
  import "../../../logger-6z_gb4rA.js";
2
- import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
2
+ import { n as e, r as t, t as n } from "../../../storage-DyxpJ0pg.js";
3
3
  import { createEffect as r, sample as i } from "effector";
4
4
  //#region src/plugins/experience-browser-storage/plugin.ts
5
5
  var a = ({ storage: a = "local" } = {}) => ({
@@ -1,4 +1,4 @@
1
- import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
1
+ import { n as e, r as t, t as n } from "../../../storage-DyxpJ0pg.js";
2
2
  import { createEffect as r, sample as i } from "effector";
3
3
  //#region src/plugins/history-browser-storage/plugin.ts
4
4
  var a = n("history", "global"), o = ({ storage: n = "local" } = {}) => ({
@@ -1,4 +1,4 @@
1
- import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
1
+ import { n as e, r as t, t as n } from "../../../storage-DyxpJ0pg.js";
2
2
  import { attach as r, createEffect as i, sample as a } from "effector";
3
3
  //#region src/plugins/responses-browser-storage/plugin.ts
4
4
  var o = n("responses", "global"), s = (e, t) => {
@@ -47,9 +47,13 @@ var c = "responses", l = {
47
47
  let e = (await i(await r(l), c)).reduce((e, { fieldId: t, value: n }) => (e[t] = n, e), {});
48
48
  await n.responses.commit(e);
49
49
  }), d = e(async (e) => {
50
- await Promise.allSettled(e.map(async (e) => {
51
- await a(await r(l), c, e);
52
- }));
50
+ e.forEach((e) => {
51
+ r(l).then((t) => {
52
+ a(t, c, e);
53
+ }).catch((e) => {
54
+ console.error("Failed to store response in IndexedDB:", e);
55
+ });
56
+ });
53
57
  }), f = e(async () => {
54
58
  await s(await r(l), c);
55
59
  }), p = e(async (e) => {
@@ -66,8 +70,8 @@ var c = "responses", l = {
66
70
  fields: n.fields.listStore
67
71
  },
68
72
  fn: ({ responses: e, fields: t }) => {
69
- let n = new Set(t.filter((e) => !e.policies?.doNotStoreValue).map((e) => e.id));
70
- return e.filter((e) => n.has(e.fieldId));
73
+ let n = t.filter((e) => !e.policies?.doNotStoreValue);
74
+ return e.filter((e) => n.some((t) => t.id === e.fieldId));
71
75
  },
72
76
  target: d
73
77
  }), t({
@@ -1,12 +1,12 @@
1
- import { n as e } from "../../../object-C82v79xc.js";
1
+ import { n as e } from "../../../object-Clj5zVr1.js";
2
2
  import { d as t, f as n, i as r } from "../../../supports-0XIfd4-R.js";
3
3
  //#region src/plugins/single-page-app/plugin.ts
4
4
  var i = n, a, o = (e) => ({
5
5
  name: "single-page-app",
6
- setup: (e) => {
7
- t() && s(() => {
6
+ setup: (n) => {
7
+ e.instrumentHistory && t() && s(() => {
8
8
  requestAnimationFrame(() => {
9
- e.start();
9
+ n.start();
10
10
  });
11
11
  });
12
12
  }
@@ -9,7 +9,7 @@ var n = () => ({
9
9
  class i extends HTMLElement {
10
10
  connectedCallback() {
11
11
  let e = this.getAttribute("experience-id");
12
- n.isReady && e && n.experiences.launch({ id: e });
12
+ n.isReady && e && n.experiences.launch({ key: e });
13
13
  }
14
14
  }
15
15
  window.customElements.define(r, i);
@@ -1,4 +1,4 @@
1
- import { t as e } from "../../experience-instance-DZiAwXph.js";
1
+ import { t as e } from "../../experience-instance-BODAwa-_.js";
2
2
  import { attach as t, createEffect as n, createEvent as r, createStore as i, sample as a } from "effector";
3
3
  //#region src/server/index.ts
4
4
  function o() {