@picked/client 0.0.50-next.2 → 0.0.50-next.4

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 (51) hide show
  1. package/dist/api-C2lg7yBn.cjs +1 -0
  2. package/dist/api-CHaIe0uL.js +37 -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/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/plugins/window-object/index.js +1 -1
  13. package/dist/cjs/server/index.js +1 -1
  14. package/dist/esm/index.js +1126 -1220
  15. package/dist/esm/plugins/create-experience/index.js +461 -468
  16. package/dist/esm/plugins/dynamic-experiences/index.js +106 -123
  17. package/dist/esm/plugins/experience-browser-storage/index.js +32 -37
  18. package/dist/esm/plugins/history-browser-storage/index.js +23 -25
  19. package/dist/esm/plugins/responses-browser-storage/index.js +36 -39
  20. package/dist/esm/plugins/responses-indexeddb/index.js +81 -80
  21. package/dist/esm/plugins/single-page-app/index.js +31 -35
  22. package/dist/esm/plugins/web-components/index.js +18 -20
  23. package/dist/esm/plugins/window-object/index.js +9 -9
  24. package/dist/esm/server/index.js +95 -89
  25. package/dist/experience-instance-BRpI9I4s.js +710 -0
  26. package/dist/experience-instance-BUTnwbSJ.cjs +1 -0
  27. package/dist/id-BniPxOdF.js +4 -0
  28. package/dist/id-CIbS4P60.cjs +1 -0
  29. package/dist/logger-6z_gb4rA.js +4 -0
  30. package/dist/logger-fbvQC40v.cjs +1 -0
  31. package/dist/object-BReQiaSS.cjs +1 -0
  32. package/dist/object-Clj5zVr1.js +24 -0
  33. package/dist/storage-BFjb8azI.cjs +1 -0
  34. package/dist/storage-DyxpJ0pg.js +101 -0
  35. package/dist/supports-0XIfd4-R.js +85 -0
  36. package/dist/supports-Dsjg-82e.cjs +1 -0
  37. package/package.json +7 -7
  38. package/dist/api-6XSnv0Kv.cjs +0 -1
  39. package/dist/api-Bt6xz3mn.js +0 -32
  40. package/dist/experience-instance-BsXG5XJ4.cjs +0 -1
  41. package/dist/experience-instance-fvSEb72i.js +0 -819
  42. package/dist/id-BKIWbSTy.cjs +0 -1
  43. package/dist/id-BW-g3y32.js +0 -6
  44. package/dist/logger-BsmHUUw1.cjs +0 -1
  45. package/dist/logger-C9a75KZn.js +0 -5
  46. package/dist/object-BbFTsGh3.cjs +0 -1
  47. package/dist/object-JwZ58NOH.js +0 -28
  48. package/dist/storage-Be5xWNPC.cjs +0 -1
  49. package/dist/storage-Co_LbKr_.js +0 -239
  50. package/dist/supports-8YT4QKI7.js +0 -95
  51. package/dist/supports-YvpQZxbh.cjs +0 -1
@@ -1,137 +1,120 @@
1
- import { a as l } from "../../../api-Bt6xz3mn.js";
2
- import { c as S } from "../../../api-Bt6xz3mn.js";
3
- import { l as a } from "../../../logger-C9a75KZn.js";
4
- function d(e) {
5
- let r = 2166136261;
6
- for (let n = 0; n < e.length; n++)
7
- r ^= e.charCodeAt(n), r = Math.imul(r, 16777619);
8
- return r >>> 0;
1
+ import "../../../logger-6z_gb4rA.js";
2
+ import { i as e, t } from "../../../api-CHaIe0uL.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;
9
8
  }
10
- function p(e) {
11
- return d(e) % 100;
9
+ function r(e) {
10
+ return n(e) % 100;
12
11
  }
13
- function g(e, r) {
14
- return r <= 0 ? !1 : r >= 100 ? !0 : e < r;
12
+ function i(e, t) {
13
+ return t <= 0 ? !1 : t >= 100 ? !0 : e < t;
15
14
  }
16
- function h(e) {
17
- return typeof e != "object" || e === null || !("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";
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";
18
19
  }
19
- function f(e) {
20
- return typeof e != "object" || e === null || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(h);
20
+ function o(e) {
21
+ return typeof e != "object" || !e || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(a);
21
22
  }
22
- function m(e) {
23
- const r = e.searchParams["preview-token"];
24
- if (r && r.length > 0)
25
- return r[0];
23
+ function s(e) {
24
+ let t = e.searchParams["preview-token"];
25
+ if (t && t.length > 0) return t[0];
26
26
  }
27
- function w(e) {
28
- const r = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
29
- if (!n)
30
- return r;
31
- for (const o of n) {
32
- const t = o.indexOf(":");
33
- t > 0 && r.add(o.substring(0, t));
34
- }
35
- return r;
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;
36
35
  }
37
- function c(e, r, n) {
38
- const o = w(e), t = e.session?.id;
39
- if (!t)
40
- throw new Error("Session ID is required for feature registration");
41
- const i = p(t);
42
- for (const s of r.features)
43
- o.has(s.id) || y(e, s, n, i);
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);
44
41
  }
45
- function y(e, r, n, o) {
46
- e.registerFeature(r.id, {
47
- key: `v${r.version}`,
48
- name: r.name,
49
- storage: n ? "session" : "local",
50
- decide: () => r.enabled ? g(o, r.weight) : !1
51
- });
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
+ });
52
49
  }
53
- function v() {
54
- let e;
55
- try {
56
- e = __PICKED_PROJECT_CONFIG__;
57
- } catch {
58
- return;
59
- }
60
- if (e === void 0)
61
- return;
62
- let r;
63
- if (typeof e == "string")
64
- try {
65
- r = JSON.parse(e);
66
- } catch {
67
- a("warn", "Build-time project config is not valid JSON");
68
- return;
69
- }
70
- else
71
- r = e;
72
- if (f(r))
73
- return r;
74
- a("warn", "Build-time project config has invalid shape, falling back to runtime fetch");
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;
75
66
  }
76
- function j(e) {
77
- try {
78
- const r = new URL(e).hostname;
79
- return r === "localhost" || r === "127.0.0.1" || r === "::1";
80
- } catch {
81
- return !1;
82
- }
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
+ }
83
74
  }
84
- function b(e) {
85
- if (typeof e != "object" || e === null || !("cause" in e))
86
- return !1;
87
- const { cause: r } = e;
88
- return typeof r != "object" || r === null || !("code" in r) ? !1 : r.code === "ECONNREFUSED";
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";
89
79
  }
90
- async function u(e, r, n) {
91
- const o = n?.previewToken ? `projects/${r}?preview_token=${encodeURIComponent(n.previewToken)}` : `projects/${r}`;
92
- let t;
93
- try {
94
- t = await l(e, o, n?.headers);
95
- } catch (s) {
96
- return j(e) && b(s) || a("warn", "Failed to fetch project config", s), null;
97
- }
98
- if (!t.ok)
99
- return a("warn", `Project config request failed with status ${t.status.toString()}`), null;
100
- let i;
101
- try {
102
- i = await t.json();
103
- } catch {
104
- return a("warn", "Failed to parse project config response"), null;
105
- }
106
- return f(i) ? i : (a("warn", "Invalid project config response shape"), null);
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;
107
95
  }
108
- function k(e) {
109
- return {
110
- name: "dynamic-experiences",
111
- setup: (r) => {
112
- const n = e?.apiUrl ?? r.apiUrl;
113
- return {
114
- onStart: async () => {
115
- const o = m(r);
116
- if (o) {
117
- const s = await u(n, r.projectId, { previewToken: o });
118
- s && c(r, s, !0);
119
- return;
120
- }
121
- const t = e?.projectConfig ?? v();
122
- if (t) {
123
- c(r, t, !1);
124
- return;
125
- }
126
- const i = await u(n, r.projectId);
127
- i && c(r, i, !1);
128
- }
129
- };
130
- }
131
- };
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
+ };
132
118
  }
133
- export {
134
- S as createClientHeaders,
135
- k as dynamicExperiencesPlugin,
136
- u as fetchProject
137
- };
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-DyxpJ0pg.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-DyxpJ0pg.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-DyxpJ0pg.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 };
@@ -1,86 +1,87 @@
1
- import { createEffect as u, sample as d } from "effector";
2
- const x = "picked";
3
- async function p(r) {
4
- const { storeName: o, version: c = 1, keyPath: n = "id" } = r;
5
- return new Promise((a, t) => {
6
- const e = indexedDB.open(x, c);
7
- e.onupgradeneeded = () => {
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
- });
1
+ import { createEffect as e, sample as t } from "effector";
2
+ //#region src/utils/indexed-db.ts
3
+ var n = "picked";
4
+ async function r(e) {
5
+ let { storeName: t, version: r = 1, keyPath: i = "id" } = e;
6
+ return new Promise((e, a) => {
7
+ let o = indexedDB.open(n, r);
8
+ o.onupgradeneeded = () => {
9
+ let e = o.result;
10
+ e.objectStoreNames.contains(t) || e.createObjectStore(t, i ? { keyPath: i } : void 0);
11
+ }, o.onsuccess = () => e(o.result), o.onerror = () => a(Error(o.error?.message));
12
+ });
12
13
  }
13
- async function g(r, o) {
14
- return new Promise((c, n) => {
15
- const e = r.transaction(o, "readonly").objectStore(o).getAll();
16
- e.onsuccess = () => c(e.result), e.onerror = () => n(new Error(e.error?.message));
17
- });
14
+ async function i(e, t) {
15
+ return new Promise((n, r) => {
16
+ let i = e.transaction(t, "readonly").objectStore(t).getAll();
17
+ i.onsuccess = () => n(i.result), i.onerror = () => r(Error(i.error?.message));
18
+ });
18
19
  }
19
- async function y(r, o, c) {
20
- return new Promise((n, a) => {
21
- const s = r.transaction(o, "readwrite").objectStore(o).put(c);
22
- s.onsuccess = () => n(), s.onerror = () => a(new Error(s.error?.message));
23
- });
20
+ async function a(e, t, n) {
21
+ return new Promise((r, i) => {
22
+ let a = e.transaction(t, "readwrite").objectStore(t).put(n);
23
+ a.onsuccess = () => r(), a.onerror = () => i(Error(a.error?.message));
24
+ });
24
25
  }
25
- async function b(r, o, c) {
26
- return new Promise((n, a) => {
27
- const s = r.transaction(o, "readwrite").objectStore(o).delete(c);
28
- s.onsuccess = () => n(), s.onerror = () => a(new Error(s.error?.message));
29
- });
26
+ async function o(e, t, n) {
27
+ return new Promise((r, i) => {
28
+ let a = e.transaction(t, "readwrite").objectStore(t).delete(n);
29
+ a.onsuccess = () => r(), a.onerror = () => i(Error(a.error?.message));
30
+ });
30
31
  }
31
- async function S(r, o) {
32
- return new Promise((c, n) => {
33
- const e = r.transaction(o, "readwrite").objectStore(o).clear();
34
- e.onsuccess = () => c(), e.onerror = () => n(new Error(e.error?.message));
35
- });
32
+ async function s(e, t) {
33
+ return new Promise((n, r) => {
34
+ let i = e.transaction(t, "readwrite").objectStore(t).clear();
35
+ i.onsuccess = () => n(), i.onerror = () => r(Error(i.error?.message));
36
+ });
36
37
  }
37
- const l = "responses", m = { storeName: l, keyPath: "fieldId" }, I = () => ({
38
- name: "responses-indexdb-plugin",
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
- {}
44
- );
45
- await r.responses.commit(s);
46
- }), c = u(
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
- });
55
- }
56
- ), n = u(async () => {
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);
62
- });
63
- d({
64
- source: r.eventBus,
65
- filter: (t) => t.type === "load",
66
- target: o
67
- }), d({
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));
73
- },
74
- target: c
75
- }), d({
76
- clock: r.responses.clearAll,
77
- target: n
78
- }), d({
79
- clock: r.responses.clear,
80
- target: a
81
- });
82
- }
38
+ //#endregion
39
+ //#region src/plugins/responses-indexeddb/plugin.ts
40
+ var c = "responses", l = {
41
+ storeName: c,
42
+ keyPath: "fieldId"
43
+ }, u = () => ({
44
+ name: "responses-indexdb-plugin",
45
+ setup: (n) => {
46
+ let u = e(async () => {
47
+ let e = (await i(await r(l), c)).reduce((e, { fieldId: t, value: n }) => (e[t] = n, e), {});
48
+ await n.responses.commit(e);
49
+ }), d = e(async (e) => {
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
+ });
57
+ }), f = e(async () => {
58
+ await s(await r(l), c);
59
+ }), p = e(async (e) => {
60
+ await o(await r(l), c, e);
61
+ });
62
+ t({
63
+ source: n.eventBus,
64
+ filter: (e) => e.type === "load",
65
+ target: u
66
+ }), t({
67
+ clock: n.responses.listStore,
68
+ source: {
69
+ responses: n.responses.listStore,
70
+ fields: n.fields.listStore
71
+ },
72
+ fn: ({ responses: e, fields: t }) => {
73
+ let n = t.filter((e) => !e.policies?.doNotStoreValue);
74
+ return e.filter((e) => n.some((t) => t.id === e.fieldId));
75
+ },
76
+ target: d
77
+ }), t({
78
+ clock: n.responses.clearAll,
79
+ target: f
80
+ }), t({
81
+ clock: n.responses.clear,
82
+ target: p
83
+ });
84
+ }
83
85
  });
84
- export {
85
- I as responsesIndexedDBPlugin
86
- };
86
+ //#endregion
87
+ export { u as responsesIndexedDBPlugin };