cogsbox-state 0.5.235 → 0.5.237
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.jsx +99 -97
- package/dist/CogsState.jsx.map +1 -1
- package/dist/utility.js +9 -9
- package/dist/utility.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +4 -0
- package/src/utility.ts +1 -1
package/dist/CogsState.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as ge } from "react/jsx-runtime";
|
|
3
3
|
import { useState as te, useRef as ee, useEffect as ce, useLayoutEffect as pe, useMemo as $e, createElement as ae, useSyncExternalStore as Ae, startTransition as Ve } from "react";
|
|
4
|
-
import { transformStateFunc as ke, isDeepEqual as
|
|
4
|
+
import { transformStateFunc as ke, isDeepEqual as G, isFunction as q, getNestedValue as W, getDifferences as le, debounce as Ne } from "./utility.js";
|
|
5
5
|
import { pushFunc as se, updateFn as X, cutFunc as K, ValidationWrapper as Ce, FormControlComponent as _e } from "./Functions.jsx";
|
|
6
6
|
import Pe from "superjson";
|
|
7
7
|
import { v4 as de } from "uuid";
|
|
@@ -21,13 +21,13 @@ function me({
|
|
|
21
21
|
options: o,
|
|
22
22
|
initialOptionsPart: S
|
|
23
23
|
}) {
|
|
24
|
-
const l = Z(e) || {}, c = S[e] || {},
|
|
24
|
+
const l = Z(e) || {}, c = S[e] || {}, w = n.getState().setInitialStateOptions, I = { ...c, ...l };
|
|
25
25
|
let p = !1;
|
|
26
26
|
if (o)
|
|
27
27
|
for (const s in o)
|
|
28
28
|
I.hasOwnProperty(s) ? (s == "localStorage" && o[s] && I[s].key !== o[s]?.key && (p = !0, I[s] = o[s]), s == "initialState" && o[s] && I[s] !== o[s] && // Different references
|
|
29
|
-
!
|
|
30
|
-
p &&
|
|
29
|
+
!G(I[s], o[s]) && (p = !0, I[s] = o[s])) : (p = !0, I[s] = o[s]);
|
|
30
|
+
p && w(e, I);
|
|
31
31
|
}
|
|
32
32
|
function Ke(e, { formElements: o, validation: S }) {
|
|
33
33
|
return { initialState: e, formElements: o, validation: S };
|
|
@@ -44,7 +44,7 @@ const et = (e, o) => {
|
|
|
44
44
|
// State-specific overrides
|
|
45
45
|
}, Z(p) || n.getState().setInitialStateOptions(p, c[p]);
|
|
46
46
|
}), n.getState().setInitialStates(l), n.getState().setCreatedState(l);
|
|
47
|
-
const
|
|
47
|
+
const w = (p, s) => {
|
|
48
48
|
const [v] = te(s?.componentId ?? de());
|
|
49
49
|
me({
|
|
50
50
|
stateKey: p,
|
|
@@ -72,12 +72,12 @@ const et = (e, o) => {
|
|
|
72
72
|
function I(p, s) {
|
|
73
73
|
me({ stateKey: p, options: s, initialOptionsPart: c }), s.localStorage && Ue(p, s), ie(p);
|
|
74
74
|
}
|
|
75
|
-
return { useCogsState:
|
|
75
|
+
return { useCogsState: w, setCogsOptions: I };
|
|
76
76
|
}, {
|
|
77
77
|
setUpdaterState: ne,
|
|
78
78
|
setState: J,
|
|
79
79
|
getInitialOptions: Z,
|
|
80
|
-
getKeyState:
|
|
80
|
+
getKeyState: be,
|
|
81
81
|
getValidationErrors: je,
|
|
82
82
|
setStateLog: Oe,
|
|
83
83
|
updateInitialStateGlobal: ue,
|
|
@@ -91,9 +91,9 @@ const et = (e, o) => {
|
|
|
91
91
|
S.localStorage?.key,
|
|
92
92
|
l
|
|
93
93
|
);
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const I = `${l}-${o}-${
|
|
94
|
+
const w = q(S?.localStorage?.key) ? S.localStorage?.key(e) : S?.localStorage?.key;
|
|
95
|
+
if (w && l) {
|
|
96
|
+
const I = `${l}-${o}-${w}`;
|
|
97
97
|
let p;
|
|
98
98
|
try {
|
|
99
99
|
p = oe(I)?.lastSyncedWithServer;
|
|
@@ -120,21 +120,21 @@ const et = (e, o) => {
|
|
|
120
120
|
}, Ue = (e, o) => {
|
|
121
121
|
const S = n.getState().cogsStateStore[e], { sessionId: l } = Ie(), c = q(o?.localStorage?.key) ? o.localStorage.key(S) : o?.localStorage?.key;
|
|
122
122
|
if (c && l) {
|
|
123
|
-
const
|
|
123
|
+
const w = oe(
|
|
124
124
|
`${l}-${e}-${c}`
|
|
125
125
|
);
|
|
126
|
-
if (
|
|
127
|
-
return J(e,
|
|
126
|
+
if (w && w.lastUpdated > (w.lastSyncedWithServer || 0))
|
|
127
|
+
return J(e, w.state), ie(e), !0;
|
|
128
128
|
}
|
|
129
129
|
return !1;
|
|
130
|
-
},
|
|
130
|
+
}, we = (e, o, S, l, c, w) => {
|
|
131
131
|
const I = {
|
|
132
132
|
initialState: o,
|
|
133
133
|
updaterState: re(
|
|
134
134
|
e,
|
|
135
135
|
l,
|
|
136
136
|
c,
|
|
137
|
-
|
|
137
|
+
w
|
|
138
138
|
),
|
|
139
139
|
state: S
|
|
140
140
|
};
|
|
@@ -160,18 +160,18 @@ const et = (e, o) => {
|
|
|
160
160
|
switch (e) {
|
|
161
161
|
case "update":
|
|
162
162
|
return {
|
|
163
|
-
oldValue:
|
|
164
|
-
newValue:
|
|
163
|
+
oldValue: W(o, l),
|
|
164
|
+
newValue: W(S, l)
|
|
165
165
|
};
|
|
166
166
|
case "insert":
|
|
167
167
|
return {
|
|
168
168
|
oldValue: null,
|
|
169
169
|
// or undefined
|
|
170
|
-
newValue:
|
|
170
|
+
newValue: W(S, l)
|
|
171
171
|
};
|
|
172
172
|
case "cut":
|
|
173
173
|
return {
|
|
174
|
-
oldValue:
|
|
174
|
+
oldValue: W(o, l),
|
|
175
175
|
newValue: null
|
|
176
176
|
// or undefined
|
|
177
177
|
};
|
|
@@ -179,38 +179,40 @@ const et = (e, o) => {
|
|
|
179
179
|
return { oldValue: null, newValue: null };
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
-
function
|
|
182
|
+
function Te(e, o, S) {
|
|
183
183
|
const l = o.split(".");
|
|
184
184
|
let c = e;
|
|
185
|
-
for (const
|
|
186
|
-
c.children.has(
|
|
185
|
+
for (const w of l)
|
|
186
|
+
c.children.has(w) || c.children.set(w, {
|
|
187
187
|
subscribers: /* @__PURE__ */ new Set(),
|
|
188
188
|
children: /* @__PURE__ */ new Map()
|
|
189
|
-
}), c = c.children.get(
|
|
189
|
+
}), c = c.children.get(w);
|
|
190
190
|
c.subscribers.add(S);
|
|
191
191
|
}
|
|
192
192
|
function Ee(e, o, S) {
|
|
193
193
|
const l = o.split(".");
|
|
194
194
|
let c = e;
|
|
195
|
-
for (const
|
|
196
|
-
if (c = c.children.get(
|
|
195
|
+
for (const w of l)
|
|
196
|
+
if (c = c.children.get(w), !c) return;
|
|
197
197
|
c.subscribers.delete(S);
|
|
198
198
|
}
|
|
199
199
|
function ve(e, o) {
|
|
200
|
+
console.log("Getting subscribers for path:", o);
|
|
200
201
|
const S = o.split("."), l = new Set(e.subscribers);
|
|
202
|
+
console.log("Root subscribers:", e.subscribers);
|
|
201
203
|
let c = e;
|
|
202
|
-
for (const
|
|
203
|
-
if (c = c.children?.get(
|
|
204
|
+
for (const w of S) {
|
|
205
|
+
if (c = c.children?.get(w), console.log(`Segment ${w} subscribers:`, c?.subscribers), !c) break;
|
|
204
206
|
c.subscribers.forEach((I) => l.add(I));
|
|
205
207
|
}
|
|
206
|
-
return l;
|
|
208
|
+
return console.log("Total subscribers found:", l), l;
|
|
207
209
|
}
|
|
208
210
|
function De(e, {
|
|
209
211
|
stateKey: o,
|
|
210
212
|
serverSync: S,
|
|
211
213
|
localStorage: l,
|
|
212
214
|
formElements: c,
|
|
213
|
-
reactiveDeps:
|
|
215
|
+
reactiveDeps: w,
|
|
214
216
|
reactiveType: I,
|
|
215
217
|
componentId: p,
|
|
216
218
|
initialState: s,
|
|
@@ -241,21 +243,21 @@ function De(e, {
|
|
|
241
243
|
initialState: s
|
|
242
244
|
});
|
|
243
245
|
const t = N.current, i = t?.serverState?.id !== void 0 && t?.serverState?.status === "success" && t?.serverState?.data, u = n.getState().initialStateGlobal[y];
|
|
244
|
-
if (!(u && !
|
|
246
|
+
if (!(u && !G(u, s) || !u) && !i)
|
|
245
247
|
return;
|
|
246
248
|
let f = null;
|
|
247
249
|
const A = q(t?.localStorage?.key) ? t?.localStorage?.key(s) : t?.localStorage?.key;
|
|
248
250
|
A && j && (f = oe(`${j}-${y}-${A}`));
|
|
249
|
-
let
|
|
251
|
+
let b = s, T = !1;
|
|
250
252
|
const C = i ? Date.now() : 0, $ = f?.lastUpdated || 0, _ = f?.lastSyncedWithServer || 0;
|
|
251
|
-
i && C > $ ? (
|
|
253
|
+
i && C > $ ? (b = t.serverState.data, T = !0) : f && $ > _ && (b = f.state, t?.localStorage?.onChange && t?.localStorage?.onChange(b)), we(
|
|
252
254
|
y,
|
|
253
255
|
s,
|
|
254
|
-
|
|
256
|
+
b,
|
|
255
257
|
H,
|
|
256
258
|
L.current,
|
|
257
259
|
j
|
|
258
|
-
),
|
|
260
|
+
), T && A && j && ye(b, y, t, j, Date.now()), ie(y), (Array.isArray(I) ? I : [I || "component"]).includes("none") || x({});
|
|
259
261
|
}
|
|
260
262
|
}, [
|
|
261
263
|
s,
|
|
@@ -281,7 +283,7 @@ function De(e, {
|
|
|
281
283
|
forceUpdate: () => x({}),
|
|
282
284
|
paths: /* @__PURE__ */ new Set(),
|
|
283
285
|
deps: [],
|
|
284
|
-
depsFunction:
|
|
286
|
+
depsFunction: w || void 0,
|
|
285
287
|
reactiveType: I ?? ["component", "deps"]
|
|
286
288
|
}), n.getState().stateComponents.set(y, a), x({}), () => {
|
|
287
289
|
const i = `${y}////${L.current}`;
|
|
@@ -298,7 +300,7 @@ function De(e, {
|
|
|
298
300
|
if (A) {
|
|
299
301
|
let M = !1, E = n.getState().signalDomElements.get(A);
|
|
300
302
|
if ((!E || E.size === 0) && (i.updateType === "insert" || i.updateType === "cut")) {
|
|
301
|
-
const O = a.slice(0, -1), D =
|
|
303
|
+
const O = a.slice(0, -1), D = W(f, O);
|
|
302
304
|
if (Array.isArray(D)) {
|
|
303
305
|
M = !0;
|
|
304
306
|
const V = `${y}-${O.join(".")}`;
|
|
@@ -306,7 +308,7 @@ function De(e, {
|
|
|
306
308
|
}
|
|
307
309
|
}
|
|
308
310
|
if (E) {
|
|
309
|
-
const O = M ?
|
|
311
|
+
const O = M ? W(f, a.slice(0, -1)) : W(f, a);
|
|
310
312
|
E.forEach(({ parentId: D, position: V, effect: k }) => {
|
|
311
313
|
const P = document.querySelector(
|
|
312
314
|
`[data-parent-id="${D}"]`
|
|
@@ -324,33 +326,33 @@ function De(e, {
|
|
|
324
326
|
i.updateType === "update" && (u || N.current?.validation?.key) && a && z(
|
|
325
327
|
(u || N.current?.validation?.key) + "." + a.join(".")
|
|
326
328
|
);
|
|
327
|
-
const
|
|
329
|
+
const b = a.slice(0, a.length - 1);
|
|
328
330
|
i.updateType === "cut" && N.current?.validation?.key && z(
|
|
329
|
-
N.current?.validation?.key + "." +
|
|
331
|
+
N.current?.validation?.key + "." + b.join(".")
|
|
330
332
|
), i.updateType === "insert" && N.current?.validation?.key && je(
|
|
331
|
-
N.current?.validation?.key + "." +
|
|
333
|
+
N.current?.validation?.key + "." + b.join(".")
|
|
332
334
|
).filter(([E, O]) => {
|
|
333
335
|
let D = E?.split(".").length;
|
|
334
|
-
if (E ==
|
|
335
|
-
let V = E + "." +
|
|
336
|
+
if (E == b.join(".") && D == b.length - 1) {
|
|
337
|
+
let V = E + "." + b;
|
|
336
338
|
z(E), Fe(V, O);
|
|
337
339
|
}
|
|
338
340
|
});
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
+
const T = n.getState().stateComponents.get(y);
|
|
342
|
+
if (T && T.pathTrie) {
|
|
341
343
|
const M = le(h, f), E = /* @__PURE__ */ new Set();
|
|
342
344
|
M.forEach((V) => {
|
|
343
345
|
ve(
|
|
344
|
-
|
|
346
|
+
T.pathTrie,
|
|
345
347
|
V
|
|
346
348
|
).forEach((P) => E.add(P));
|
|
347
349
|
});
|
|
348
350
|
const O = i.updateType === "update" ? a.join(".") : a.slice(0, -1).join(".") || "";
|
|
349
351
|
ve(
|
|
350
|
-
|
|
352
|
+
T.pathTrie,
|
|
351
353
|
O
|
|
352
354
|
).forEach((V) => E.add(V)), console.log("componentsToUpdate", E), E.forEach((V) => {
|
|
353
|
-
const k =
|
|
355
|
+
const k = T.components.get(V);
|
|
354
356
|
if (k) {
|
|
355
357
|
const P = Array.isArray(k.reactiveType) ? k.reactiveType : [k.reactiveType || "component"];
|
|
356
358
|
if (P.includes("none")) return;
|
|
@@ -361,7 +363,7 @@ function De(e, {
|
|
|
361
363
|
if (P.includes("deps") && k.depsFunction) {
|
|
362
364
|
const B = k.depsFunction(f);
|
|
363
365
|
let Y = !1;
|
|
364
|
-
if (typeof B == "boolean" ? B && (Y = !0) :
|
|
366
|
+
if (typeof B == "boolean" ? B && (Y = !0) : G(k.deps, B) || (k.deps = B, Y = !0), Y) {
|
|
365
367
|
k.forceUpdate();
|
|
366
368
|
return;
|
|
367
369
|
}
|
|
@@ -372,7 +374,7 @@ function De(e, {
|
|
|
372
374
|
}
|
|
373
375
|
const C = Date.now();
|
|
374
376
|
a = a.map((M, E) => {
|
|
375
|
-
const O = a.slice(0, -1), D =
|
|
377
|
+
const O = a.slice(0, -1), D = W(f, O);
|
|
376
378
|
return E === a.length - 1 && ["insert", "cut"].includes(i.updateType) ? (D.length - 1).toString() : M;
|
|
377
379
|
});
|
|
378
380
|
const { oldValue: $, newValue: _ } = Re(
|
|
@@ -430,16 +432,16 @@ function De(e, {
|
|
|
430
432
|
L.current,
|
|
431
433
|
j
|
|
432
434
|
), [y, j]);
|
|
433
|
-
return [
|
|
435
|
+
return [be(y), g];
|
|
434
436
|
}
|
|
435
437
|
function re(e, o, S, l) {
|
|
436
438
|
const c = /* @__PURE__ */ new Map();
|
|
437
|
-
let
|
|
439
|
+
let w = 0;
|
|
438
440
|
const I = (v) => {
|
|
439
441
|
const r = v.join(".");
|
|
440
442
|
for (const [m] of c)
|
|
441
443
|
(m === r || m.startsWith(r + ".")) && c.delete(m);
|
|
442
|
-
|
|
444
|
+
w++;
|
|
443
445
|
}, p = {
|
|
444
446
|
removeValidation: (v) => {
|
|
445
447
|
v?.validationKey && z(v.validationKey);
|
|
@@ -448,7 +450,7 @@ function re(e, o, S, l) {
|
|
|
448
450
|
const r = n.getState().getInitialOptions(e)?.validation;
|
|
449
451
|
r?.key && z(r?.key), v?.validationKey && z(v.validationKey);
|
|
450
452
|
const m = n.getState().initialStateGlobal[e];
|
|
451
|
-
n.getState().clearSelectedIndexesForState(e), c.clear(),
|
|
453
|
+
n.getState().clearSelectedIndexesForState(e), c.clear(), w++;
|
|
452
454
|
const U = s(m, []), x = Z(e), j = q(x?.localStorage?.key) ? x?.localStorage?.key(m) : x?.localStorage?.key, R = `${l}-${e}-${j}`;
|
|
453
455
|
R && localStorage.removeItem(R), ne(e, U), J(e, m);
|
|
454
456
|
const y = n.getState().stateComponents.get(e);
|
|
@@ -457,7 +459,7 @@ function re(e, o, S, l) {
|
|
|
457
459
|
}), m;
|
|
458
460
|
},
|
|
459
461
|
updateInitialState: (v) => {
|
|
460
|
-
c.clear(),
|
|
462
|
+
c.clear(), w++;
|
|
461
463
|
const r = re(
|
|
462
464
|
e,
|
|
463
465
|
o,
|
|
@@ -479,7 +481,7 @@ function re(e, o, S, l) {
|
|
|
479
481
|
_isLoading: n.getState().isLoadingGlobal[e],
|
|
480
482
|
_isServerSynced: () => {
|
|
481
483
|
const v = n.getState().serverState[e];
|
|
482
|
-
return !!(v &&
|
|
484
|
+
return !!(v && G(v, be(e)));
|
|
483
485
|
}
|
|
484
486
|
};
|
|
485
487
|
function s(v, r = [], m) {
|
|
@@ -567,16 +569,16 @@ function re(e, o, S, l) {
|
|
|
567
569
|
}
|
|
568
570
|
};
|
|
569
571
|
if (d === "_status") {
|
|
570
|
-
const g = n.getState().getNestedState(e, r), t = n.getState().initialStateGlobal[e], a =
|
|
571
|
-
return
|
|
572
|
+
const g = n.getState().getNestedState(e, r), t = n.getState().initialStateGlobal[e], a = W(t, r);
|
|
573
|
+
return G(g, a) ? "fresh" : "stale";
|
|
572
574
|
}
|
|
573
575
|
if (d === "getStatus")
|
|
574
576
|
return function() {
|
|
575
577
|
const g = n().getNestedState(
|
|
576
578
|
e,
|
|
577
579
|
r
|
|
578
|
-
), t = n.getState().initialStateGlobal[e], a =
|
|
579
|
-
return
|
|
580
|
+
), t = n.getState().initialStateGlobal[e], a = W(t, r);
|
|
581
|
+
return G(g, a) ? "fresh" : "stale";
|
|
580
582
|
};
|
|
581
583
|
if (d === "removeStorage")
|
|
582
584
|
return () => {
|
|
@@ -647,7 +649,7 @@ function re(e, o, S, l) {
|
|
|
647
649
|
const f = [...r, h.toString()], A = s(i, f, m);
|
|
648
650
|
return t(i, A, {
|
|
649
651
|
register: () => {
|
|
650
|
-
const [,
|
|
652
|
+
const [, T] = te({}), C = `${S}-${r.join(".")}-${h}`;
|
|
651
653
|
pe(() => {
|
|
652
654
|
const $ = `${e}////${C}`, _ = n.getState().stateComponents.get(e) || {
|
|
653
655
|
components: /* @__PURE__ */ new Map(),
|
|
@@ -657,13 +659,13 @@ function re(e, o, S, l) {
|
|
|
657
659
|
}
|
|
658
660
|
};
|
|
659
661
|
return _.components.set($, {
|
|
660
|
-
forceUpdate: () =>
|
|
662
|
+
forceUpdate: () => T({}),
|
|
661
663
|
paths: /* @__PURE__ */ new Set([f.join(".")]),
|
|
662
664
|
deps: [],
|
|
663
665
|
depsFunction: void 0,
|
|
664
666
|
reactiveType: ["component"],
|
|
665
667
|
pathsInitialized: !0
|
|
666
|
-
}), _.pathTrie &&
|
|
668
|
+
}), _.pathTrie && Te(
|
|
667
669
|
_.pathTrie,
|
|
668
670
|
f.join("."),
|
|
669
671
|
$
|
|
@@ -699,7 +701,7 @@ function re(e, o, S, l) {
|
|
|
699
701
|
);
|
|
700
702
|
});
|
|
701
703
|
if (d === "$stateMap")
|
|
702
|
-
return (t) => ae(
|
|
704
|
+
return (t) => ae(Ge, {
|
|
703
705
|
proxy: {
|
|
704
706
|
_stateKey: e,
|
|
705
707
|
_path: r,
|
|
@@ -711,7 +713,7 @@ function re(e, o, S, l) {
|
|
|
711
713
|
if (d === "stateFlattenOn")
|
|
712
714
|
return (t) => {
|
|
713
715
|
const a = v;
|
|
714
|
-
c.clear(),
|
|
716
|
+
c.clear(), w++;
|
|
715
717
|
const i = a.flatMap(
|
|
716
718
|
(u) => u[t] ?? []
|
|
717
719
|
);
|
|
@@ -742,22 +744,22 @@ function re(e, o, S, l) {
|
|
|
742
744
|
return (t, a, i) => {
|
|
743
745
|
const u = n.getState().getNestedState(e, r), h = q(t) ? t(u) : t;
|
|
744
746
|
let f = null;
|
|
745
|
-
if (!u.some((
|
|
747
|
+
if (!u.some((b) => {
|
|
746
748
|
if (a) {
|
|
747
749
|
const C = a.every(
|
|
748
|
-
($) =>
|
|
750
|
+
($) => G(b[$], h[$])
|
|
749
751
|
);
|
|
750
|
-
return C && (f =
|
|
752
|
+
return C && (f = b), C;
|
|
751
753
|
}
|
|
752
|
-
const
|
|
753
|
-
return
|
|
754
|
+
const T = G(b, h);
|
|
755
|
+
return T && (f = b), T;
|
|
754
756
|
}))
|
|
755
757
|
I(r), se(o, h, r, e);
|
|
756
758
|
else if (i && f) {
|
|
757
|
-
const
|
|
758
|
-
(C) =>
|
|
759
|
+
const b = i(f), T = u.map(
|
|
760
|
+
(C) => G(C, f) ? b : C
|
|
759
761
|
);
|
|
760
|
-
I(r), X(o,
|
|
762
|
+
I(r), X(o, T, r);
|
|
761
763
|
}
|
|
762
764
|
};
|
|
763
765
|
if (d === "cut")
|
|
@@ -853,7 +855,7 @@ function re(e, o, S, l) {
|
|
|
853
855
|
if (d === "applyJsonPatch")
|
|
854
856
|
return (g) => {
|
|
855
857
|
const t = n.getState().cogsStateStore[e], i = xe(t, g).newDocument;
|
|
856
|
-
|
|
858
|
+
we(
|
|
857
859
|
e,
|
|
858
860
|
n.getState().initialStateGlobal[e],
|
|
859
861
|
i,
|
|
@@ -866,26 +868,26 @@ function re(e, o, S, l) {
|
|
|
866
868
|
const h = le(t, i), f = new Set(h);
|
|
867
869
|
for (const [
|
|
868
870
|
A,
|
|
869
|
-
|
|
871
|
+
b
|
|
870
872
|
] of u.components.entries()) {
|
|
871
|
-
let
|
|
872
|
-
const C = Array.isArray(
|
|
873
|
+
let T = !1;
|
|
874
|
+
const C = Array.isArray(b.reactiveType) ? b.reactiveType : [b.reactiveType || "component"];
|
|
873
875
|
if (!C.includes("none")) {
|
|
874
876
|
if (C.includes("all")) {
|
|
875
|
-
|
|
877
|
+
b.forceUpdate();
|
|
876
878
|
continue;
|
|
877
879
|
}
|
|
878
|
-
if (C.includes("component") && (
|
|
880
|
+
if (C.includes("component") && (b.paths.has("") && (T = !0), !T))
|
|
879
881
|
for (const $ of f) {
|
|
880
|
-
if (
|
|
881
|
-
|
|
882
|
+
if (b.paths.has($)) {
|
|
883
|
+
T = !0;
|
|
882
884
|
break;
|
|
883
885
|
}
|
|
884
886
|
let _ = $.lastIndexOf(".");
|
|
885
887
|
for (; _ !== -1; ) {
|
|
886
888
|
const F = $.substring(0, _);
|
|
887
|
-
if (
|
|
888
|
-
|
|
889
|
+
if (b.paths.has(F)) {
|
|
890
|
+
T = !0;
|
|
889
891
|
break;
|
|
890
892
|
}
|
|
891
893
|
const M = $.substring(
|
|
@@ -898,22 +900,22 @@ function re(e, o, S, l) {
|
|
|
898
900
|
0,
|
|
899
901
|
E
|
|
900
902
|
);
|
|
901
|
-
if (
|
|
902
|
-
|
|
903
|
+
if (b.paths.has(O)) {
|
|
904
|
+
T = !0;
|
|
903
905
|
break;
|
|
904
906
|
}
|
|
905
907
|
}
|
|
906
908
|
}
|
|
907
909
|
_ = F.lastIndexOf(".");
|
|
908
910
|
}
|
|
909
|
-
if (
|
|
911
|
+
if (T) break;
|
|
910
912
|
}
|
|
911
|
-
if (!
|
|
912
|
-
const $ =
|
|
913
|
+
if (!T && C.includes("deps") && b.depsFunction) {
|
|
914
|
+
const $ = b.depsFunction(i);
|
|
913
915
|
let _ = !1;
|
|
914
|
-
typeof $ == "boolean" ? $ && (_ = !0) :
|
|
916
|
+
typeof $ == "boolean" ? $ && (_ = !0) : G(b.deps, $) || (b.deps = $, _ = !0), _ && (T = !0);
|
|
915
917
|
}
|
|
916
|
-
|
|
918
|
+
T && b.forceUpdate();
|
|
917
919
|
}
|
|
918
920
|
}
|
|
919
921
|
}
|
|
@@ -934,8 +936,8 @@ function re(e, o, S, l) {
|
|
|
934
936
|
});
|
|
935
937
|
const u = g.zodSchema.safeParse(a);
|
|
936
938
|
return u.success ? !0 : (u.error.errors.forEach((f) => {
|
|
937
|
-
const A = f.path,
|
|
938
|
-
t(
|
|
939
|
+
const A = f.path, b = f.message, T = [g.key, ...A].join(".");
|
|
940
|
+
t(T, b);
|
|
939
941
|
}), ie(e), !1);
|
|
940
942
|
} catch (i) {
|
|
941
943
|
return console.error("Zod schema validation failed", i), !1;
|
|
@@ -1009,7 +1011,7 @@ function re(e, o, S, l) {
|
|
|
1009
1011
|
}, R = new Proxy(x, j);
|
|
1010
1012
|
return c.set(U, {
|
|
1011
1013
|
proxy: R,
|
|
1012
|
-
stateVersion:
|
|
1014
|
+
stateVersion: w
|
|
1013
1015
|
}), R;
|
|
1014
1016
|
}
|
|
1015
1017
|
return s(
|
|
@@ -1017,9 +1019,9 @@ function re(e, o, S, l) {
|
|
|
1017
1019
|
);
|
|
1018
1020
|
}
|
|
1019
1021
|
function he(e) {
|
|
1020
|
-
return ae(
|
|
1022
|
+
return ae(We, { proxy: e });
|
|
1021
1023
|
}
|
|
1022
|
-
function
|
|
1024
|
+
function Ge({
|
|
1023
1025
|
proxy: e,
|
|
1024
1026
|
rebuildStateShape: o
|
|
1025
1027
|
}) {
|
|
@@ -1028,10 +1030,10 @@ function We({
|
|
|
1028
1030
|
S,
|
|
1029
1031
|
e._path
|
|
1030
1032
|
).stateMapNoRender(
|
|
1031
|
-
(c,
|
|
1033
|
+
(c, w, I, p, s) => e._mapFn(c, w, I, p, s)
|
|
1032
1034
|
) : null;
|
|
1033
1035
|
}
|
|
1034
|
-
function
|
|
1036
|
+
function We({
|
|
1035
1037
|
proxy: e
|
|
1036
1038
|
}) {
|
|
1037
1039
|
const o = ee(null), S = `${e._stateKey}-${e._path.join(".")}`;
|
|
@@ -1087,7 +1089,7 @@ function nt(e) {
|
|
|
1087
1089
|
depsFunction: void 0,
|
|
1088
1090
|
reactiveType: ["component"],
|
|
1089
1091
|
pathsInitialized: !0
|
|
1090
|
-
}), l.pathTrie &&
|
|
1092
|
+
}), l.pathTrie && Te(l.pathTrie, e._path.join("."), c), n.getState().stateComponents.set(e._stateKey, l), () => {
|
|
1091
1093
|
l.components.delete(c), l.pathTrie && Ee(
|
|
1092
1094
|
l.pathTrie,
|
|
1093
1095
|
e._path.join("."),
|