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

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 (74) hide show
  1. package/dist/api-BEXzPJHZ.cjs +1 -0
  2. package/dist/api-oudcFuUX.js +37 -0
  3. package/dist/cjs/form/index.js +1 -1
  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 +416 -381
  16. package/dist/esm/index.js +1138 -1204
  17. package/dist/esm/plugins/create-experience/index.js +461 -434
  18. package/dist/esm/plugins/dynamic-experiences/index.js +106 -123
  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 -85
  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/field/field.d.ts +1 -1
  42. package/dist/types/entities/field/field.d.ts.map +1 -1
  43. package/dist/types/entities/response/response.d.ts.map +1 -1
  44. package/dist/types/form/create-form.d.ts +13 -3
  45. package/dist/types/form/create-form.d.ts.map +1 -1
  46. package/dist/types/form/create-submit-pipeline.d.ts +4 -4
  47. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
  48. package/dist/types/index.d.ts +0 -1
  49. package/dist/types/index.d.ts.map +1 -1
  50. package/dist/types/picked.d.ts +0 -1
  51. package/dist/types/picked.d.ts.map +1 -1
  52. package/dist/types/plugins/create-experience/create-experience.d.ts +21 -26
  53. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  54. package/dist/types/plugins/history-browser-storage/plugin.d.ts +2 -2
  55. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  56. package/package.json +7 -21
  57. package/dist/api-4YC7Dkcf.js +0 -32
  58. package/dist/api-dQTozK5u.cjs +0 -1
  59. package/dist/experience-instance-Bd4kkjE6.js +0 -559
  60. package/dist/experience-instance-UAZPiG2b.cjs +0 -1
  61. package/dist/id-BKIWbSTy.cjs +0 -1
  62. package/dist/id-BW-g3y32.js +0 -6
  63. package/dist/logger-BsmHUUw1.cjs +0 -1
  64. package/dist/logger-C9a75KZn.js +0 -5
  65. package/dist/object-CJssU1Pm.js +0 -28
  66. package/dist/object-mwaxtjLG.cjs +0 -1
  67. package/dist/rules-logic-CZfip-Wl.js +0 -265
  68. package/dist/rules-logic-Cgia6n5p.cjs +0 -1
  69. package/dist/storage-58NoTSsc.cjs +0 -1
  70. package/dist/storage-B2d81EOI.js +0 -244
  71. package/dist/supports-8YT4QKI7.js +0 -95
  72. package/dist/supports-YvpQZxbh.cjs +0 -1
  73. package/dist/types/entities/project/project.d.ts +0 -9
  74. package/dist/types/entities/project/project.d.ts.map +0 -1
@@ -1,137 +1,120 @@
1
- import { a as l } from "../../../api-4YC7Dkcf.js";
2
- import { c as S } from "../../../api-4YC7Dkcf.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-oudcFuUX.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-B2d81EOI.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-B2d81EOI.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-B2d81EOI.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 };
@@ -1,91 +1,83 @@
1
- import { createEffect as u, sample as d } from "effector";
2
- const x = "picked";
3
- async function p(s) {
4
- const { storeName: t, version: c = 1, keyPath: n = "id" } = s;
5
- return new Promise((a, r) => {
6
- const e = indexedDB.open(x, c);
7
- e.onupgradeneeded = () => {
8
- const o = e.result;
9
- o.objectStoreNames.contains(t) || o.createObjectStore(t, n ? { keyPath: n } : void 0);
10
- }, e.onsuccess = () => a(e.result), e.onerror = () => r(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(s, t) {
14
- return new Promise((c, n) => {
15
- const e = s.transaction(t, "readonly").objectStore(t).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(s, t, c) {
20
- return new Promise((n, a) => {
21
- const o = s.transaction(t, "readwrite").objectStore(t).put(c);
22
- o.onsuccess = () => n(), o.onerror = () => a(new Error(o.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 S(s, t, c) {
26
- return new Promise((n, a) => {
27
- const o = s.transaction(t, "readwrite").objectStore(t).delete(c);
28
- o.onsuccess = () => n(), o.onerror = () => a(new Error(o.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 b(s, t) {
32
- return new Promise((c, n) => {
33
- const e = s.transaction(t, "readwrite").objectStore(t).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", w = { storeName: l, keyPath: "fieldId" }, E = () => ({
38
- name: "responses-indexdb-plugin",
39
- setup: (s) => {
40
- const t = u(async () => {
41
- const r = await p(w), o = (await g(r, l)).reduce(
42
- (i, { fieldId: m, value: f }) => (i[m] = f, i),
43
- {}
44
- );
45
- await s.responses.commit(o);
46
- }), c = u(
47
- async (r) => {
48
- await Promise.allSettled(
49
- r.map(async (e) => {
50
- const o = await p(w);
51
- await y(
52
- o,
53
- l,
54
- e
55
- );
56
- })
57
- );
58
- }
59
- ), n = u(async () => {
60
- const r = await p(w);
61
- await b(r, l);
62
- }), a = u(async (r) => {
63
- const e = await p(w);
64
- await S(e, l, r);
65
- });
66
- d({
67
- source: s.eventBus,
68
- filter: (r) => r.type === "load",
69
- target: t
70
- }), d({
71
- clock: s.responses.listStore,
72
- source: { responses: s.responses.listStore, fields: s.fields.listStore },
73
- fn: ({ responses: r, fields: e }) => {
74
- const o = new Set(
75
- e.filter((i) => !i.policies?.doNotStoreValue).map((i) => i.id)
76
- );
77
- return r.filter((i) => o.has(i.fieldId));
78
- },
79
- target: c
80
- }), d({
81
- clock: s.responses.clearAll,
82
- target: n
83
- }), d({
84
- clock: s.responses.clear,
85
- target: a
86
- });
87
- }
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
+ await Promise.allSettled(e.map(async (e) => {
51
+ await a(await r(l), c, e);
52
+ }));
53
+ }), f = e(async () => {
54
+ await s(await r(l), c);
55
+ }), p = e(async (e) => {
56
+ await o(await r(l), c, e);
57
+ });
58
+ t({
59
+ source: n.eventBus,
60
+ filter: (e) => e.type === "load",
61
+ target: u
62
+ }), t({
63
+ clock: n.responses.listStore,
64
+ source: {
65
+ responses: n.responses.listStore,
66
+ fields: n.fields.listStore
67
+ },
68
+ 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));
71
+ },
72
+ target: d
73
+ }), t({
74
+ clock: n.responses.clearAll,
75
+ target: f
76
+ }), t({
77
+ clock: n.responses.clear,
78
+ target: p
79
+ });
80
+ }
88
81
  });
89
- export {
90
- E as responsesIndexedDBPlugin
91
- };
82
+ //#endregion
83
+ export { u as responsesIndexedDBPlugin };