@picked/client 0.0.1-dev.1773807602703 → 0.0.1-dev.1774224866171

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 (135) hide show
  1. package/dist/api-WKe5XBeR.cjs +1 -0
  2. package/dist/api-ZK-H-MlI.js +37 -0
  3. package/dist/cjs/form/index.js +1 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  11. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  12. package/dist/cjs/plugins/web-components/index.js +1 -1
  13. package/dist/cjs/plugins/window-object/index.js +1 -1
  14. package/dist/cjs/server/index.js +1 -1
  15. package/dist/esm/form/index.js +428 -0
  16. package/dist/esm/index.js +1138 -1291
  17. package/dist/esm/plugins/create-experience/index.js +424 -509
  18. package/dist/esm/plugins/dynamic-experiences/index.js +120 -204
  19. package/dist/esm/plugins/experience-browser-storage/index.js +32 -37
  20. package/dist/esm/plugins/history-browser-storage/index.js +23 -25
  21. package/dist/esm/plugins/responses-browser-storage/index.js +36 -39
  22. package/dist/esm/plugins/responses-indexeddb/index.js +77 -80
  23. package/dist/esm/plugins/single-page-app/index.js +31 -35
  24. package/dist/esm/plugins/web-components/index.js +18 -20
  25. package/dist/esm/plugins/window-object/index.js +9 -9
  26. package/dist/esm/server/index.js +95 -89
  27. package/dist/experience-instance-DZiAwXph.js +481 -0
  28. package/dist/experience-instance-Ddk4Jktn.cjs +1 -0
  29. package/dist/id-Bv44ilEo.cjs +1 -0
  30. package/dist/id-CRqy981z.js +4 -0
  31. package/dist/logger-6z_gb4rA.js +4 -0
  32. package/dist/logger-fbvQC40v.cjs +1 -0
  33. package/dist/object-C82v79xc.js +25 -0
  34. package/dist/object-CUJOjanb.cjs +1 -0
  35. package/dist/rules-logic-B7vJrWyO.js +231 -0
  36. package/dist/rules-logic-CXr4wXcG.cjs +1 -0
  37. package/dist/storage-6Xk0uAxB.js +103 -0
  38. package/dist/storage-B6lQtc4-.cjs +1 -0
  39. package/dist/supports-0XIfd4-R.js +85 -0
  40. package/dist/supports-Dsjg-82e.cjs +1 -0
  41. package/dist/types/entities/action/action.d.ts.map +1 -1
  42. package/dist/types/entities/experience/experience.d.ts +31 -48
  43. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  44. package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
  45. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  46. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  47. package/dist/types/entities/field/field.d.ts +12 -17
  48. package/dist/types/entities/field/field.d.ts.map +1 -1
  49. package/dist/types/entities/history/history.d.ts.map +1 -1
  50. package/dist/types/entities/response/response.d.ts +7 -9
  51. package/dist/types/entities/response/response.d.ts.map +1 -1
  52. package/dist/types/form/build-responses.d.ts +14 -0
  53. package/dist/types/form/build-responses.d.ts.map +1 -0
  54. package/dist/types/form/create-field-evaluator.d.ts +19 -0
  55. package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
  56. package/dist/types/form/create-field-validation.d.ts +44 -0
  57. package/dist/types/form/create-field-validation.d.ts.map +1 -0
  58. package/dist/types/form/create-form.d.ts +66 -0
  59. package/dist/types/form/create-form.d.ts.map +1 -0
  60. package/dist/types/form/create-submit-pipeline.d.ts +58 -0
  61. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
  62. package/dist/types/form/get-step-fields.d.ts +5 -0
  63. package/dist/types/form/get-step-fields.d.ts.map +1 -0
  64. package/dist/types/form/index.d.ts +10 -0
  65. package/dist/types/form/index.d.ts.map +1 -0
  66. package/dist/types/index.d.ts +1 -3
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/types/logic-engine.d.ts +2 -8
  69. package/dist/types/logic-engine.d.ts.map +1 -1
  70. package/dist/types/picked.d.ts +23 -42
  71. package/dist/types/picked.d.ts.map +1 -1
  72. package/dist/types/plugins/create-experience/create-experience.d.ts +37 -70
  73. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  74. package/dist/types/plugins/create-experience/index.d.ts +1 -1
  75. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  76. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  77. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +5 -20
  78. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  79. package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -46
  80. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  81. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
  82. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  83. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
  84. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  85. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
  86. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  87. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  88. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  89. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  90. package/dist/types/utils/dom.d.ts +0 -3
  91. package/dist/types/utils/dom.d.ts.map +1 -1
  92. package/dist/types/utils/events.d.ts +2 -2
  93. package/dist/types/utils/events.d.ts.map +1 -1
  94. package/dist/types/utils/global-obj.d.ts +0 -1
  95. package/dist/types/utils/global-obj.d.ts.map +1 -1
  96. package/dist/types/utils/indexed-db.d.ts +2 -1
  97. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  98. package/dist/types/utils/logger.d.ts.map +1 -1
  99. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  100. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  101. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
  102. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  103. package/dist/types/utils/nodes.d.ts +2 -7
  104. package/dist/types/utils/nodes.d.ts.map +1 -1
  105. package/dist/types/utils/object.d.ts +0 -8
  106. package/dist/types/utils/object.d.ts.map +1 -1
  107. package/dist/types/utils/picked-config.d.ts +1 -1
  108. package/dist/types/utils/picked-config.d.ts.map +1 -1
  109. package/dist/types/utils/search-params.d.ts.map +1 -1
  110. package/dist/types/utils/storage.d.ts.map +1 -1
  111. package/package.json +18 -8
  112. package/dist/api-GlH9T8_1.js +0 -32
  113. package/dist/api-GvmToTw0.cjs +0 -1
  114. package/dist/experience-instance-CxiOyYPf.cjs +0 -1
  115. package/dist/experience-instance-DCknHRkX.js +0 -804
  116. package/dist/id-BKIWbSTy.cjs +0 -1
  117. package/dist/id-BW-g3y32.js +0 -6
  118. package/dist/logger-BsmHUUw1.cjs +0 -1
  119. package/dist/logger-C9a75KZn.js +0 -5
  120. package/dist/nodes-DQt4TfuO.js +0 -26
  121. package/dist/nodes-DsL8kMSX.cjs +0 -1
  122. package/dist/object-BbFTsGh3.cjs +0 -1
  123. package/dist/object-JwZ58NOH.js +0 -28
  124. package/dist/storage-Be5xWNPC.cjs +0 -1
  125. package/dist/storage-Co_LbKr_.js +0 -239
  126. package/dist/supports-8YT4QKI7.js +0 -95
  127. package/dist/supports-YvpQZxbh.cjs +0 -1
  128. package/dist/types/entities/condition/condition.d.ts +0 -17
  129. package/dist/types/entities/condition/condition.d.ts.map +0 -1
  130. package/dist/types/entities/project/project.d.ts +0 -9
  131. package/dist/types/entities/project/project.d.ts.map +0 -1
  132. package/dist/types/entities/step/step.d.ts +0 -20
  133. package/dist/types/entities/step/step.d.ts.map +0 -1
  134. package/dist/types/utils/key.d.ts +0 -12
  135. package/dist/types/utils/key.d.ts.map +0 -1
@@ -1,204 +1,120 @@
1
- import { a as m } from "../../../api-GlH9T8_1.js";
2
- import { c as U } from "../../../api-GlH9T8_1.js";
3
- import { l as a } from "../../../logger-C9a75KZn.js";
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;
10
- }
11
- function w(n) {
12
- return h(n) % 100;
13
- }
14
- function v(n, e) {
15
- return e <= 0 ? !1 : e >= 100 ? !0 : n < e;
16
- }
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";
19
- }
20
- function g(n) {
21
- return typeof n != "object" || n === null || !("features" in n) || !Array.isArray(n.features) ? !1 : n.features.every(j);
22
- }
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);
25
- }
26
- function S(n, e) {
27
- const t = /* @__PURE__ */ new Set(), r = [];
28
- for (const o of n) {
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 });
41
- }
42
- return r;
43
- }
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;
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)
107
- throw new Error("Session ID is required for feature registration");
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
118
- });
119
- }
120
- function F() {
121
- let n;
122
- try {
123
- n = __PICKED_PROJECT_CONFIG__;
124
- } catch {
125
- return;
126
- }
127
- if (n === void 0)
128
- return;
129
- let e;
130
- if (typeof n == "string")
131
- try {
132
- e = JSON.parse(n);
133
- } catch {
134
- a("warn", "Build-time project config is not valid JSON");
135
- return;
136
- }
137
- else
138
- e = n;
139
- if (g(e))
140
- return e;
141
- a("warn", "Build-time project config has invalid shape, falling back to runtime fetch");
142
- }
143
- function E(n) {
144
- try {
145
- const e = new URL(n).hostname;
146
- return e === "localhost" || e === "127.0.0.1" || e === "::1";
147
- } catch {
148
- return !1;
149
- }
150
- }
151
- function O(n) {
152
- if (typeof n != "object" || n === null || !("cause" in n))
153
- return !1;
154
- const { cause: e } = n;
155
- return typeof e != "object" || e === null || !("code" in e) ? !1 : e.code === "ECONNREFUSED";
156
- }
157
- async function p(n, e, t) {
158
- const r = t?.previewToken ? `projects/${e}?preview_token=${encodeURIComponent(t.previewToken)}` : `projects/${e}`;
159
- let o;
160
- try {
161
- o = await m(n, r, t?.headers);
162
- } catch (s) {
163
- return E(n) && O(s) || a("warn", "Failed to fetch project config", s), null;
164
- }
165
- if (!o.ok)
166
- return a("warn", `Project config request failed with status ${o.status.toString()}`), null;
167
- let i;
168
- try {
169
- i = await o.json();
170
- } catch {
171
- return a("warn", "Failed to parse project config response"), null;
172
- }
173
- return g(i) ? i : (a("warn", "Invalid project config response shape"), null);
174
- }
175
- function T(n) {
176
- return {
177
- name: "dynamic-experiences",
178
- setup: (e) => {
179
- const t = n?.apiUrl ?? e.apiUrl;
180
- return {
181
- onStart: async () => {
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));
186
- return;
187
- }
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);
191
- return;
192
- }
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));
195
- }
196
- };
197
- }
198
- };
199
- }
200
- export {
201
- U as createClientHeaders,
202
- T as dynamicExperiencesPlugin,
203
- p as fetchProject
204
- };
1
+ import "../../../logger-6z_gb4rA.js";
2
+ import { i as e, t } from "../../../api-ZK-H-MlI.js";
3
+ //#region src/plugins/dynamic-experiences/hash.ts
4
+ function n(e) {
5
+ let t = 2166136261;
6
+ for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
7
+ return t >>> 0;
8
+ }
9
+ function r(e) {
10
+ return n(e) % 100;
11
+ }
12
+ function i(e, t) {
13
+ return t <= 0 ? !1 : t >= 100 ? !0 : e < t;
14
+ }
15
+ //#endregion
16
+ //#region src/plugins/dynamic-experiences/plugin.ts
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";
19
+ }
20
+ function o(e) {
21
+ return typeof e != "object" || !e || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(a);
22
+ }
23
+ function s(e) {
24
+ let t = e.searchParams["preview-token"];
25
+ if (t && t.length > 0) return t[0];
26
+ }
27
+ function c(e) {
28
+ let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
29
+ if (!n) return t;
30
+ for (let e of n) {
31
+ let n = e.indexOf(":");
32
+ n > 0 && t.add(e.substring(0, n));
33
+ }
34
+ return t;
35
+ }
36
+ function l(e, t, n) {
37
+ let i = c(e), a = e.session?.id;
38
+ if (!a) throw Error("Session ID is required for feature registration");
39
+ let o = r(a);
40
+ for (let r of t.features) i.has(r.id) || u(e, r, n, o);
41
+ }
42
+ function u(e, t, n, r) {
43
+ e.registerFeature(t.id, {
44
+ key: `v${t.version}`,
45
+ name: t.name,
46
+ storage: n ? "session" : "local",
47
+ decide: () => t.enabled ? i(r, t.weight) : !1
48
+ });
49
+ }
50
+ function d() {
51
+ let e;
52
+ try {
53
+ e = __PICKED_PROJECT_CONFIG__;
54
+ } catch {
55
+ return;
56
+ }
57
+ if (e === void 0) return;
58
+ let t;
59
+ if (typeof e == "string") try {
60
+ t = JSON.parse(e);
61
+ } catch {
62
+ return;
63
+ }
64
+ else t = e;
65
+ if (o(t)) return t;
66
+ }
67
+ function f(e) {
68
+ try {
69
+ let t = new URL(e).hostname;
70
+ return t === "localhost" || t === "127.0.0.1" || t === "::1";
71
+ } catch {
72
+ return !1;
73
+ }
74
+ }
75
+ function p(e) {
76
+ if (typeof e != "object" || !e || !("cause" in e)) return !1;
77
+ let { cause: t } = e;
78
+ return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
79
+ }
80
+ async function m(e, n, r) {
81
+ let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
82
+ try {
83
+ a = await t(e, i, r?.headers);
84
+ } catch (t) {
85
+ return f(e) && p(t), null;
86
+ }
87
+ if (!a.ok) return `${a.status.toString()}`, null;
88
+ let s;
89
+ try {
90
+ s = await a.json();
91
+ } catch {
92
+ return null;
93
+ }
94
+ return o(s) ? s : null;
95
+ }
96
+ function h(e) {
97
+ return {
98
+ name: "dynamic-experiences",
99
+ setup: (t) => {
100
+ let n = e?.apiUrl ?? t.apiUrl;
101
+ return { onStart: async () => {
102
+ let r = s(t);
103
+ if (r) {
104
+ let e = await m(n, t.projectId, { previewToken: r });
105
+ e && l(t, e, !0);
106
+ return;
107
+ }
108
+ let i = e?.projectConfig ?? d();
109
+ if (i) {
110
+ l(t, i, !1);
111
+ return;
112
+ }
113
+ let a = await m(n, t.projectId);
114
+ a && l(t, a, !1);
115
+ } };
116
+ }
117
+ };
118
+ }
119
+ //#endregion
120
+ export { e as createClientHeaders, h as dynamicExperiencesPlugin, m as fetchProject };
@@ -1,38 +1,33 @@
1
- import { createEffect as n, sample as i } from "effector";
2
- import { c, l as g, s as S } from "../../../storage-Co_LbKr_.js";
3
- import { l as f } from "../../../logger-C9a75KZn.js";
4
- const y = ({
5
- storage: a = "local"
6
- } = {}) => ({
7
- name: "experience-browser-storage-plugin",
8
- setup: (s) => {
9
- const r = a === "local" ? g : S, p = n(async (e) => {
10
- if (!e) {
11
- f("warn", "No experience instance provided to loadExperienceVisiblityFx.");
12
- return;
13
- }
14
- const t = c("open-close", "experience", e), o = r.get(t).boolean();
15
- e.setOpen(o ?? e.isOpenStore.getState());
16
- });
17
- i({
18
- source: s.eventBus,
19
- filter: (e) => e.type === "experience_initialize" && "experience" in e,
20
- fn: (e) => e.experience,
21
- target: p
22
- });
23
- const l = n(async (e) => {
24
- const t = c("open-close", "experience", e), o = e.isOpenStore.getState();
25
- r.set(t, o);
26
- }), x = (e) => i({
27
- source: e.isOpenStore,
28
- fn: () => e,
29
- target: l
30
- });
31
- s.experienceInstances.listStore.watch((e) => {
32
- e.forEach((t) => x(t));
33
- });
34
- }
1
+ import "../../../logger-6z_gb4rA.js";
2
+ import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
3
+ import { createEffect as r, sample as i } from "effector";
4
+ //#region src/plugins/experience-browser-storage/plugin.ts
5
+ var a = ({ storage: a = "local" } = {}) => ({
6
+ name: "experience-browser-storage-plugin",
7
+ setup: (o) => {
8
+ let s = a === "local" ? e : t, c = r(async (e) => {
9
+ if (!e) return;
10
+ let t = n("open-close", "experience", e), r = s.get(t).boolean();
11
+ e.setOpen(r ?? e.isOpenStore.getState());
12
+ });
13
+ i({
14
+ source: o.eventBus,
15
+ filter: (e) => e.type === "experience_initialize" && "experience" in e,
16
+ fn: (e) => e.experience,
17
+ target: c
18
+ });
19
+ let l = r(async (e) => {
20
+ let t = n("open-close", "experience", e), r = e.isOpenStore.getState();
21
+ s.set(t, r);
22
+ }), u = (e) => i({
23
+ source: e.isOpenStore,
24
+ fn: () => e,
25
+ target: l
26
+ });
27
+ o.experienceInstances.listStore.watch((e) => {
28
+ e.forEach((e) => u(e));
29
+ });
30
+ }
35
31
  });
36
- export {
37
- y as experienceBrowserStoragePlugin
38
- };
32
+ //#endregion
33
+ export { a as experienceBrowserStoragePlugin };
@@ -1,26 +1,24 @@
1
- import { createEffect as s, sample as r } from "effector";
2
- import { c as l, l as y, s as g } from "../../../storage-Co_LbKr_.js";
3
- const a = l("history", "global"), f = ({
4
- storage: i = "local"
5
- } = {}) => ({
6
- name: "history-browser-storage-plugin",
7
- setup: (o) => {
8
- const e = i === "local" ? y : g, n = s(async () => {
9
- const t = e.get(a).json();
10
- t && o.history.restore({ entries: t });
11
- }), c = s(async (t) => {
12
- e.set(a, t);
13
- });
14
- r({
15
- source: o.eventBus,
16
- filter: (t) => t.type === "load",
17
- target: n
18
- }), r({
19
- source: o.history.entriesStore,
20
- target: c
21
- });
22
- }
1
+ import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
2
+ import { createEffect as r, sample as i } from "effector";
3
+ //#region src/plugins/history-browser-storage/plugin.ts
4
+ var a = n("history", "global"), o = ({ storage: n = "local" } = {}) => ({
5
+ name: "history-browser-storage-plugin",
6
+ setup: (o) => {
7
+ let s = n === "local" ? e : t, c = r(async () => {
8
+ let e = s.get(a).json();
9
+ e && o.history.restore({ entries: e });
10
+ }), l = r(async (e) => {
11
+ s.set(a, e);
12
+ });
13
+ i({
14
+ source: o.eventBus,
15
+ filter: (e) => e.type === "load",
16
+ target: c
17
+ }), i({
18
+ source: o.history.entriesStore,
19
+ target: l
20
+ });
21
+ }
23
22
  });
24
- export {
25
- f as historyBrowserStoragePlugin
26
- };
23
+ //#endregion
24
+ export { o as historyBrowserStoragePlugin };
@@ -1,40 +1,37 @@
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-Co_LbKr_.js";
3
- const p = u("responses", "global"), S = (r, s) => {
4
- const o = {};
5
- return Object.entries(r).forEach(([t, n]) => {
6
- !s.find((l) => l.id === t)?.policies?.doNotStoreValue && (o[t] = n);
7
- }), o;
8
- }, R = ({
9
- storage: r = "local"
10
- } = {}) => ({
11
- name: "responses-browser-storage-plugin",
12
- setup: (s) => {
13
- const o = r === "local" ? g : d, t = i(async () => {
14
- const e = o.get(p).json();
15
- if (!e)
16
- return null;
17
- s.responses.register(e);
18
- }), n = f({
19
- source: {
20
- responses: s.responses.getAllStore,
21
- fields: s.fields.listStore
22
- },
23
- effect: ({ responses: e, fields: a }) => {
24
- const l = S(e, a);
25
- o.set(p, l);
26
- }
27
- });
28
- c({
29
- source: s.eventBus,
30
- filter: (e) => e.type === "load",
31
- target: t
32
- }), c({
33
- source: s.responses.getAllStore,
34
- target: n
35
- });
36
- }
1
+ import { n as e, r as t, t as n } from "../../../storage-6Xk0uAxB.js";
2
+ import { attach as r, createEffect as i, sample as a } from "effector";
3
+ //#region src/plugins/responses-browser-storage/plugin.ts
4
+ var o = n("responses", "global"), s = (e, t) => {
5
+ let n = {};
6
+ return Object.entries(e).forEach(([e, r]) => {
7
+ t.find((t) => t.id === e)?.policies?.doNotStoreValue || (n[e] = r);
8
+ }), n;
9
+ }, c = ({ storage: n = "local" } = {}) => ({
10
+ name: "responses-browser-storage-plugin",
11
+ setup: (c) => {
12
+ let l = n === "local" ? e : t, u = i(async () => {
13
+ let e = l.get(o).json();
14
+ if (!e) return null;
15
+ c.responses.register(e);
16
+ }), d = r({
17
+ source: {
18
+ responses: c.responses.getAllStore,
19
+ fields: c.fields.listStore
20
+ },
21
+ effect: ({ responses: e, fields: t }) => {
22
+ let n = s(e, t);
23
+ l.set(o, n);
24
+ }
25
+ });
26
+ a({
27
+ source: c.eventBus,
28
+ filter: (e) => e.type === "load",
29
+ target: u
30
+ }), a({
31
+ source: c.responses.getAllStore,
32
+ target: d
33
+ });
34
+ }
37
35
  });
38
- export {
39
- R as responsesBrowserStoragePlugin
40
- };
36
+ //#endregion
37
+ export { c as responsesBrowserStoragePlugin };