cogsbox-state 0.5.462 → 0.5.464
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.
- package/dist/CogsState.d.ts +1 -1
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +1057 -1047
- package/dist/CogsState.jsx.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +188 -167
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +78 -48
- package/src/store.ts +86 -98
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EAEd,QAAQ,EACR,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,KAAK,UAAU,GAAG,GAAG,CAAC;AAEtB,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACjE,UAAU,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BAAoB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,IAAI,CAAC;IAE9D,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE7D,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC;CAC/C,CAAC;AAcF,eAAO,MAAM,cAAc,8EAynBxB,CAAC"}
|
package/dist/store.js
CHANGED
|
@@ -1,177 +1,179 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
import { ulid as
|
|
3
|
-
import { startTransition as
|
|
4
|
-
const
|
|
1
|
+
import { create as M } from "zustand";
|
|
2
|
+
import { ulid as b } from "ulid";
|
|
3
|
+
import { startTransition as g } from "react";
|
|
4
|
+
const j = M((f, c) => ({
|
|
5
5
|
formRefs: /* @__PURE__ */ new Map(),
|
|
6
|
-
registerFormRef: (e,
|
|
6
|
+
registerFormRef: (e, s) => f((o) => {
|
|
7
7
|
const t = new Map(o.formRefs);
|
|
8
|
-
return t.set(e,
|
|
8
|
+
return t.set(e, s), { formRefs: t };
|
|
9
9
|
}),
|
|
10
|
-
getFormRef: (e) =>
|
|
11
|
-
removeFormRef: (e) =>
|
|
12
|
-
const o = new Map(
|
|
10
|
+
getFormRef: (e) => c().formRefs.get(e),
|
|
11
|
+
removeFormRef: (e) => f((s) => {
|
|
12
|
+
const o = new Map(s.formRefs);
|
|
13
13
|
return o.delete(e), { formRefs: o };
|
|
14
14
|
}),
|
|
15
15
|
// Get all refs that start with the stateKey prefix
|
|
16
16
|
getFormRefsByStateKey: (e) => {
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
(a.startsWith(o) || a === e) && t.set(a,
|
|
17
|
+
const s = c().formRefs, o = e + ".", t = /* @__PURE__ */ new Map();
|
|
18
|
+
return s.forEach((n, a) => {
|
|
19
|
+
(a.startsWith(o) || a === e) && t.set(a, n);
|
|
20
20
|
}), t;
|
|
21
21
|
}
|
|
22
|
-
})),
|
|
22
|
+
})), m = (f) => f === null || typeof f != "object" ? !1 : !!(Array.isArray(f) || f.constructor === Object), E = M((f, c) => ({
|
|
23
23
|
updateQueue: /* @__PURE__ */ new Set(),
|
|
24
24
|
// A flag to ensure we only schedule the flush once per event-loop tick.
|
|
25
25
|
isFlushScheduled: !1,
|
|
26
26
|
// This function is called by queueMicrotask to execute all queued updates.
|
|
27
27
|
flushUpdates: () => {
|
|
28
|
-
const { updateQueue: e } =
|
|
29
|
-
e.size > 0 &&
|
|
30
|
-
e.forEach((
|
|
31
|
-
}),
|
|
28
|
+
const { updateQueue: e } = c();
|
|
29
|
+
e.size > 0 && g(() => {
|
|
30
|
+
e.forEach((s) => s());
|
|
31
|
+
}), f({ updateQueue: /* @__PURE__ */ new Set(), isFlushScheduled: !1 });
|
|
32
32
|
},
|
|
33
|
-
addPathComponent: (e,
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
S.add(o),
|
|
37
|
-
const
|
|
33
|
+
addPathComponent: (e, s, o) => {
|
|
34
|
+
f((t) => {
|
|
35
|
+
const n = new Map(t.shadowStateStore), a = [e, ...s].join("."), r = n.get(a) || {}, S = new Set(r.pathComponents);
|
|
36
|
+
S.add(o), n.set(a, { ...r, pathComponents: S });
|
|
37
|
+
const i = n.get(e) || {}, p = i.components?.get(o);
|
|
38
38
|
if (p) {
|
|
39
39
|
const d = new Set(p.paths);
|
|
40
40
|
d.add(a);
|
|
41
|
-
const h = { ...p, paths: d },
|
|
42
|
-
|
|
43
|
-
...
|
|
44
|
-
components:
|
|
41
|
+
const h = { ...p, paths: d }, l = new Map(i.components);
|
|
42
|
+
l.set(o, h), n.set(e, {
|
|
43
|
+
...i,
|
|
44
|
+
components: l
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
return { shadowStateStore:
|
|
47
|
+
return { shadowStateStore: n };
|
|
48
48
|
});
|
|
49
49
|
},
|
|
50
|
-
registerComponent: (e,
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
return r.set(
|
|
50
|
+
registerComponent: (e, s, o) => {
|
|
51
|
+
f((t) => {
|
|
52
|
+
const n = new Map(t.shadowStateStore), a = n.get(e) || {}, r = new Map(a.components);
|
|
53
|
+
return r.set(s, o), n.set(e, { ...a, components: r }), { shadowStateStore: n };
|
|
54
54
|
});
|
|
55
55
|
},
|
|
56
|
-
unregisterComponent: (e,
|
|
57
|
-
|
|
58
|
-
const t = new Map(o.shadowStateStore),
|
|
59
|
-
if (!
|
|
56
|
+
unregisterComponent: (e, s) => {
|
|
57
|
+
f((o) => {
|
|
58
|
+
const t = new Map(o.shadowStateStore), n = t.get(e);
|
|
59
|
+
if (!n?.components)
|
|
60
60
|
return o;
|
|
61
|
-
const a = new Map(
|
|
62
|
-
return a.delete(
|
|
61
|
+
const a = new Map(n.components);
|
|
62
|
+
return a.delete(s) ? (t.set(e, { ...n, components: a }), { shadowStateStore: t }) : o;
|
|
63
63
|
});
|
|
64
64
|
},
|
|
65
|
-
markAsDirty: (e,
|
|
66
|
-
const t = new Map(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const S = [e, ...r].join("."), c = t.get(S);
|
|
70
|
-
c && c.isDirty !== !0 ? (t.set(S, { ...c, isDirty: !0 }), s = !0) : c || (t.set(S, { isDirty: !0 }), s = !0);
|
|
65
|
+
markAsDirty: (e, s, o = { bubble: !0 }) => {
|
|
66
|
+
const { shadowStateStore: t } = c(), n = /* @__PURE__ */ new Map(), a = (r) => {
|
|
67
|
+
const S = [e, ...r].join("."), i = t.get(S) || {};
|
|
68
|
+
return i.isDirty === !0 ? !0 : (n.set(S, { ...i, isDirty: !0 }), !1);
|
|
71
69
|
};
|
|
72
|
-
if (a(
|
|
73
|
-
let r = [...
|
|
74
|
-
for (; r.length > 0; )
|
|
75
|
-
|
|
70
|
+
if (a(s), o.bubble) {
|
|
71
|
+
let r = [...s];
|
|
72
|
+
for (; r.length > 0 && (r.pop(), !a(r)); )
|
|
73
|
+
;
|
|
76
74
|
}
|
|
77
|
-
|
|
75
|
+
n.size > 0 && f((r) => (n.forEach((S, i) => {
|
|
76
|
+
r.shadowStateStore.set(i, S);
|
|
77
|
+
}), r));
|
|
78
78
|
},
|
|
79
79
|
serverStateUpdates: /* @__PURE__ */ new Map(),
|
|
80
|
-
setServerStateUpdate: (e,
|
|
81
|
-
|
|
80
|
+
setServerStateUpdate: (e, s) => {
|
|
81
|
+
f((o) => {
|
|
82
82
|
const t = new Map(o.serverStateUpdates);
|
|
83
|
-
return t.set(e,
|
|
84
|
-
}),
|
|
83
|
+
return t.set(e, s), { serverStateUpdates: t };
|
|
84
|
+
}), c().notifyPathSubscribers(e, {
|
|
85
85
|
type: "SERVER_STATE_UPDATE",
|
|
86
|
-
serverState:
|
|
86
|
+
serverState: s
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
shadowStateStore: /* @__PURE__ */ new Map(),
|
|
90
|
-
getShadowNode: (e) =>
|
|
90
|
+
getShadowNode: (e) => c().shadowStateStore.get(e),
|
|
91
91
|
pathSubscribers: /* @__PURE__ */ new Map(),
|
|
92
|
-
subscribeToPath: (e,
|
|
93
|
-
const o =
|
|
94
|
-
return t.add(
|
|
95
|
-
const
|
|
96
|
-
|
|
92
|
+
subscribeToPath: (e, s) => {
|
|
93
|
+
const o = c().pathSubscribers, t = o.get(e) || /* @__PURE__ */ new Set();
|
|
94
|
+
return t.add(s), o.set(e, t), () => {
|
|
95
|
+
const n = c().pathSubscribers.get(e);
|
|
96
|
+
n && (n.delete(s), n.size === 0 && c().pathSubscribers.delete(e));
|
|
97
97
|
};
|
|
98
98
|
},
|
|
99
|
-
notifyPathSubscribers: (e,
|
|
100
|
-
const t =
|
|
101
|
-
t && t.forEach((
|
|
99
|
+
notifyPathSubscribers: (e, s) => {
|
|
100
|
+
const t = c().pathSubscribers.get(e);
|
|
101
|
+
t && t.forEach((n) => n(s));
|
|
102
102
|
},
|
|
103
|
-
initializeShadowState: (e,
|
|
104
|
-
|
|
105
|
-
const t = new Map(o.shadowStateStore)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
103
|
+
initializeShadowState: (e, s) => {
|
|
104
|
+
f((o) => {
|
|
105
|
+
const t = new Map(o.shadowStateStore);
|
|
106
|
+
console.log("initializeShadowState");
|
|
107
|
+
const a = t.get(e)?.components, r = e + ".";
|
|
108
|
+
for (const i of Array.from(t.keys()))
|
|
109
|
+
(i === e || i.startsWith(r)) && t.delete(i);
|
|
110
|
+
const S = (i, p) => {
|
|
109
111
|
const d = [e, ...p].join(".");
|
|
110
|
-
if (Array.isArray(
|
|
112
|
+
if (Array.isArray(i)) {
|
|
111
113
|
const h = [];
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
h.push(d + "." +
|
|
115
|
-
}), t.set(d, { arrayKeys: h }),
|
|
116
|
-
const
|
|
117
|
-
S(
|
|
114
|
+
i.forEach(() => {
|
|
115
|
+
const l = `id:${b()}`;
|
|
116
|
+
h.push(d + "." + l);
|
|
117
|
+
}), t.set(d, { arrayKeys: h }), i.forEach((l, u) => {
|
|
118
|
+
const w = h[u].split(".").pop();
|
|
119
|
+
S(l, [...p, w]);
|
|
118
120
|
});
|
|
119
|
-
} else if (
|
|
121
|
+
} else if (m(i)) {
|
|
120
122
|
const h = Object.fromEntries(
|
|
121
|
-
Object.keys(
|
|
123
|
+
Object.keys(i).map((l) => [l, d + "." + l])
|
|
122
124
|
);
|
|
123
|
-
t.set(d, { fields: h }), Object.keys(
|
|
124
|
-
S(
|
|
125
|
+
t.set(d, { fields: h }), Object.keys(i).forEach((l) => {
|
|
126
|
+
S(i[l], [...p, l]);
|
|
125
127
|
});
|
|
126
128
|
} else
|
|
127
|
-
t.set(d, { value:
|
|
129
|
+
t.set(d, { value: i });
|
|
128
130
|
};
|
|
129
|
-
if (S(
|
|
130
|
-
const
|
|
131
|
+
if (S(s, []), a) {
|
|
132
|
+
const i = t.get(e) || {};
|
|
131
133
|
t.set(e, {
|
|
132
|
-
...
|
|
134
|
+
...i,
|
|
133
135
|
components: a
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
return { shadowStateStore: t };
|
|
137
139
|
});
|
|
138
140
|
},
|
|
139
|
-
getShadowValue: (e,
|
|
140
|
-
const o = /* @__PURE__ */ new Map(), t = (
|
|
141
|
-
if (o.has(
|
|
142
|
-
return o.get(
|
|
143
|
-
const r =
|
|
141
|
+
getShadowValue: (e, s) => {
|
|
142
|
+
const o = /* @__PURE__ */ new Map(), t = (n, a) => {
|
|
143
|
+
if (o.has(n))
|
|
144
|
+
return o.get(n);
|
|
145
|
+
const r = c().shadowStateStore.get(n);
|
|
144
146
|
if (!r)
|
|
145
147
|
return;
|
|
146
148
|
if (r.value !== void 0)
|
|
147
149
|
return r.value;
|
|
148
150
|
let S;
|
|
149
151
|
if (r.arrayKeys) {
|
|
150
|
-
const
|
|
151
|
-
S = [], o.set(
|
|
152
|
+
const i = a ?? r.arrayKeys;
|
|
153
|
+
S = [], o.set(n, S), i.forEach((p) => {
|
|
152
154
|
S.push(t(p));
|
|
153
155
|
});
|
|
154
|
-
} else r.fields ? (S = {}, o.set(
|
|
155
|
-
S[
|
|
156
|
+
} else r.fields ? (S = {}, o.set(n, S), Object.entries(r.fields).forEach(([i, p]) => {
|
|
157
|
+
S[i] = t(p);
|
|
156
158
|
})) : S = void 0;
|
|
157
159
|
return S;
|
|
158
160
|
};
|
|
159
|
-
return t(e,
|
|
161
|
+
return t(e, s);
|
|
160
162
|
},
|
|
161
|
-
getShadowMetadata: (e,
|
|
162
|
-
const
|
|
163
|
-
return
|
|
163
|
+
getShadowMetadata: (e, s) => {
|
|
164
|
+
const o = [e, ...s].join(".");
|
|
165
|
+
return c().shadowStateStore.get(o);
|
|
164
166
|
},
|
|
165
|
-
setShadowMetadata: (e,
|
|
166
|
-
const t = [e, ...
|
|
167
|
-
|
|
167
|
+
setShadowMetadata: (e, s, o) => {
|
|
168
|
+
const t = [e, ...s].join("."), n = c().shadowStateStore.get(t);
|
|
169
|
+
n?.components && !o.components && (console.group(
|
|
168
170
|
"%c🚨 RACE CONDITION DETECTED! 🚨",
|
|
169
171
|
"color: red; font-size: 18px; font-weight: bold;"
|
|
170
172
|
), console.error(
|
|
171
|
-
`An overwrite is about to happen on stateKey: "${e}" at path: [${
|
|
173
|
+
`An overwrite is about to happen on stateKey: "${e}" at path: [${s.join(", ")}]`
|
|
172
174
|
), console.log(
|
|
173
175
|
"The EXISTING metadata had a components map:",
|
|
174
|
-
|
|
176
|
+
n.components
|
|
175
177
|
), console.log(
|
|
176
178
|
"The NEW metadata is trying to save WITHOUT a components map:",
|
|
177
179
|
o
|
|
@@ -179,90 +181,109 @@ const O = b((i, f) => ({
|
|
|
179
181
|
"%cStack trace to the function that caused this overwrite:",
|
|
180
182
|
"font-weight: bold;"
|
|
181
183
|
), console.trace(), console.groupEnd());
|
|
182
|
-
const a = new Map(
|
|
183
|
-
a.set(t, r),
|
|
184
|
+
const a = new Map(c().shadowStateStore), r = { ...n || {}, ...o };
|
|
185
|
+
a.set(t, r), f({ shadowStateStore: a });
|
|
184
186
|
},
|
|
185
|
-
setTransformCache: (e,
|
|
186
|
-
const
|
|
187
|
-
r.transformCaches || (r.transformCaches = /* @__PURE__ */ new Map()), r.transformCaches.set(o, t), a.set(
|
|
187
|
+
setTransformCache: (e, s, o, t) => {
|
|
188
|
+
const n = [e, ...s].join("."), a = new Map(c().shadowStateStore), r = a.get(n) || {};
|
|
189
|
+
r.transformCaches || (r.transformCaches = /* @__PURE__ */ new Map()), r.transformCaches.set(o, t), a.set(n, r), f({ shadowStateStore: a });
|
|
188
190
|
},
|
|
189
|
-
insertShadowArrayElement: (e,
|
|
190
|
-
const t = new Map(
|
|
191
|
+
insertShadowArrayElement: (e, s, o) => {
|
|
192
|
+
const t = new Map(c().shadowStateStore), n = [e, ...s].join("."), a = t.get(n);
|
|
191
193
|
if (!a || !a.arrayKeys) return;
|
|
192
|
-
const r = `id:${
|
|
193
|
-
|
|
194
|
+
const r = `id:${b()}`, S = n + "." + r, i = [...a.arrayKeys];
|
|
195
|
+
i.push(S), t.set(n, { ...a, arrayKeys: i });
|
|
194
196
|
const p = (d, h) => {
|
|
195
|
-
const
|
|
197
|
+
const l = [e, ...h].join(".");
|
|
196
198
|
if (!Array.isArray(d)) if (typeof d == "object" && d !== null) {
|
|
197
|
-
const
|
|
198
|
-
Object.keys(d).map((
|
|
199
|
+
const u = Object.fromEntries(
|
|
200
|
+
Object.keys(d).map((w) => [w, l + "." + w])
|
|
199
201
|
);
|
|
200
|
-
t.set(
|
|
201
|
-
p(
|
|
202
|
+
t.set(l, { fields: u }), Object.entries(d).forEach(([w, y]) => {
|
|
203
|
+
p(y, [...h, w]);
|
|
202
204
|
});
|
|
203
205
|
} else
|
|
204
|
-
t.set(
|
|
206
|
+
t.set(l, { value: d });
|
|
205
207
|
};
|
|
206
|
-
p(o, [...
|
|
208
|
+
p(o, [...s, r]), f({ shadowStateStore: t }), c().notifyPathSubscribers(n, {
|
|
207
209
|
type: "INSERT",
|
|
208
|
-
path:
|
|
210
|
+
path: n,
|
|
209
211
|
itemKey: S
|
|
210
212
|
});
|
|
211
213
|
},
|
|
212
|
-
removeShadowArrayElement: (e,
|
|
213
|
-
const o = new Map(
|
|
214
|
+
removeShadowArrayElement: (e, s) => {
|
|
215
|
+
const o = new Map(c().shadowStateStore), t = [e, ...s].join("."), n = s.slice(0, -1), a = [e, ...n].join("."), r = o.get(a);
|
|
214
216
|
if (r && r.arrayKeys && r.arrayKeys.findIndex(
|
|
215
|
-
(
|
|
217
|
+
(i) => i === t
|
|
216
218
|
) !== -1) {
|
|
217
|
-
const
|
|
219
|
+
const i = r.arrayKeys.filter(
|
|
218
220
|
(d) => d !== t
|
|
219
221
|
);
|
|
220
222
|
o.set(a, {
|
|
221
223
|
...r,
|
|
222
|
-
arrayKeys:
|
|
224
|
+
arrayKeys: i
|
|
223
225
|
});
|
|
224
226
|
const p = t + ".";
|
|
225
227
|
for (const d of Array.from(o.keys()))
|
|
226
228
|
(d === t || d.startsWith(p)) && o.delete(d);
|
|
227
229
|
}
|
|
228
|
-
|
|
230
|
+
f({ shadowStateStore: o }), c().notifyPathSubscribers(a, {
|
|
229
231
|
type: "REMOVE",
|
|
230
232
|
path: a,
|
|
231
233
|
itemKey: t
|
|
232
234
|
// The exact ID of the removed item
|
|
233
235
|
});
|
|
234
236
|
},
|
|
235
|
-
updateShadowAtPath: (e,
|
|
236
|
-
const t =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
updateShadowAtPath: (e, s, o) => {
|
|
238
|
+
const t = [e, ...s].join(".");
|
|
239
|
+
c().shadowStateStore.get(t)?.value === o && !m(o) || f((a) => {
|
|
240
|
+
const r = a.shadowStateStore;
|
|
241
|
+
if (m(o)) {
|
|
242
|
+
const S = (i, p) => {
|
|
243
|
+
const d = [e, ...i].join("."), h = r.get(d);
|
|
244
|
+
if (h && h.fields) {
|
|
245
|
+
for (const l in p)
|
|
246
|
+
if (Object.prototype.hasOwnProperty.call(p, l)) {
|
|
247
|
+
const u = p[l], w = h.fields[l];
|
|
248
|
+
if (w)
|
|
249
|
+
if (m(u))
|
|
250
|
+
S(
|
|
251
|
+
w.split(".").slice(1),
|
|
252
|
+
u
|
|
253
|
+
);
|
|
254
|
+
else {
|
|
255
|
+
const y = r.get(w) || {};
|
|
256
|
+
r.set(w, {
|
|
257
|
+
...y,
|
|
258
|
+
value: u
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
243
262
|
}
|
|
263
|
+
};
|
|
264
|
+
S(s, o);
|
|
244
265
|
} else {
|
|
245
|
-
const
|
|
246
|
-
|
|
266
|
+
const S = r.get(t) || {};
|
|
267
|
+
r.set(t, { ...S, value: o });
|
|
247
268
|
}
|
|
248
|
-
|
|
249
|
-
|
|
269
|
+
return c().notifyPathSubscribers(t, { type: "UPDATE", newValue: o }), a;
|
|
270
|
+
});
|
|
250
271
|
},
|
|
251
272
|
selectedIndicesMap: /* @__PURE__ */ new Map(),
|
|
252
|
-
getSelectedIndex: (e,
|
|
253
|
-
const o =
|
|
273
|
+
getSelectedIndex: (e, s) => {
|
|
274
|
+
const o = c().selectedIndicesMap.get(e);
|
|
254
275
|
if (!o) return -1;
|
|
255
|
-
const t =
|
|
276
|
+
const t = s || E.getState().getShadowMetadata(e, [])?.arrayKeys;
|
|
256
277
|
return t ? t.indexOf(o) : -1;
|
|
257
278
|
},
|
|
258
|
-
setSelectedIndex: (e,
|
|
259
|
-
|
|
279
|
+
setSelectedIndex: (e, s) => {
|
|
280
|
+
f((o) => {
|
|
260
281
|
const t = o.selectedIndicesMap;
|
|
261
|
-
return
|
|
282
|
+
return s === void 0 ? t.delete(e) : (t.has(e) && c().notifyPathSubscribers(t.get(e), {
|
|
262
283
|
type: "THIS_UNSELECTED"
|
|
263
|
-
}), t.set(e,
|
|
284
|
+
}), t.set(e, s), c().notifyPathSubscribers(s, {
|
|
264
285
|
type: "THIS_SELECTED"
|
|
265
|
-
})),
|
|
286
|
+
})), c().notifyPathSubscribers(e, {
|
|
266
287
|
type: "GET_SELECTED"
|
|
267
288
|
}), {
|
|
268
289
|
...o,
|
|
@@ -271,21 +292,21 @@ const O = b((i, f) => ({
|
|
|
271
292
|
});
|
|
272
293
|
},
|
|
273
294
|
clearSelectedIndex: ({ arrayKey: e }) => {
|
|
274
|
-
|
|
275
|
-
const o =
|
|
276
|
-
return t &&
|
|
295
|
+
f((s) => {
|
|
296
|
+
const o = s.selectedIndicesMap, t = o.get(e);
|
|
297
|
+
return t && c().notifyPathSubscribers(t, {
|
|
277
298
|
type: "CLEAR_SELECTION"
|
|
278
|
-
}), o.delete(e),
|
|
299
|
+
}), o.delete(e), c().notifyPathSubscribers(e, {
|
|
279
300
|
type: "CLEAR_SELECTION"
|
|
280
301
|
}), {
|
|
281
|
-
...
|
|
302
|
+
...s,
|
|
282
303
|
selectedIndicesMap: o
|
|
283
304
|
};
|
|
284
305
|
});
|
|
285
306
|
},
|
|
286
307
|
clearSelectedIndexesForState: (e) => {
|
|
287
|
-
|
|
288
|
-
const o = new Map(
|
|
308
|
+
f((s) => {
|
|
309
|
+
const o = new Map(s.selectedIndicesMap);
|
|
289
310
|
return o.delete(e) ? { selectedIndicesMap: o } : {};
|
|
290
311
|
});
|
|
291
312
|
},
|
|
@@ -295,38 +316,38 @@ const O = b((i, f) => ({
|
|
|
295
316
|
stateLog: /* @__PURE__ */ new Map(),
|
|
296
317
|
initialStateGlobal: {},
|
|
297
318
|
validationErrors: /* @__PURE__ */ new Map(),
|
|
298
|
-
addStateLog: (e,
|
|
299
|
-
|
|
300
|
-
const t = new Map(o.stateLog),
|
|
301
|
-
return r ? (r.newValue =
|
|
319
|
+
addStateLog: (e, s) => {
|
|
320
|
+
f((o) => {
|
|
321
|
+
const t = new Map(o.stateLog), n = new Map(t.get(e)), a = JSON.stringify(s.path), r = n.get(a);
|
|
322
|
+
return r ? (r.newValue = s.newValue, r.timeStamp = s.timeStamp) : n.set(a, { ...s }), t.set(e, n), { stateLog: t };
|
|
302
323
|
});
|
|
303
324
|
},
|
|
304
|
-
getInitialOptions: (e) =>
|
|
305
|
-
setInitialStateOptions: (e,
|
|
306
|
-
|
|
325
|
+
getInitialOptions: (e) => c().initialStateOptions[e],
|
|
326
|
+
setInitialStateOptions: (e, s) => {
|
|
327
|
+
f((o) => ({
|
|
307
328
|
initialStateOptions: {
|
|
308
329
|
...o.initialStateOptions,
|
|
309
|
-
[e]:
|
|
330
|
+
[e]: s
|
|
310
331
|
}
|
|
311
332
|
}));
|
|
312
333
|
},
|
|
313
|
-
updateInitialStateGlobal: (e,
|
|
314
|
-
|
|
334
|
+
updateInitialStateGlobal: (e, s) => {
|
|
335
|
+
f((o) => ({
|
|
315
336
|
initialStateGlobal: {
|
|
316
337
|
...o.initialStateGlobal,
|
|
317
|
-
[e]:
|
|
338
|
+
[e]: s
|
|
318
339
|
}
|
|
319
340
|
}));
|
|
320
341
|
},
|
|
321
342
|
syncInfoStore: /* @__PURE__ */ new Map(),
|
|
322
|
-
setSyncInfo: (e,
|
|
343
|
+
setSyncInfo: (e, s) => f((o) => {
|
|
323
344
|
const t = new Map(o.syncInfoStore);
|
|
324
|
-
return t.set(e,
|
|
345
|
+
return t.set(e, s), { ...o, syncInfoStore: t };
|
|
325
346
|
}),
|
|
326
|
-
getSyncInfo: (e) =>
|
|
347
|
+
getSyncInfo: (e) => c().syncInfoStore.get(e) || null
|
|
327
348
|
}));
|
|
328
349
|
export {
|
|
329
|
-
|
|
330
|
-
|
|
350
|
+
j as formRefStore,
|
|
351
|
+
E as getGlobalStore
|
|
331
352
|
};
|
|
332
353
|
//# sourceMappingURL=store.js.map
|