cogsbox-state 0.5.316 → 0.5.318
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 +397 -374
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +80 -57
package/dist/CogsState.jsx
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { transformStateFunc as Rt, isDeepEqual as
|
|
5
|
-
import { pushFunc as
|
|
2
|
+
import { jsx as It } from "react/jsx-runtime";
|
|
3
|
+
import { useState as et, useRef as X, useEffect as st, useLayoutEffect as gt, useMemo as pt, createElement as it, useSyncExternalStore as _t, startTransition as Mt, useCallback as Et } from "react";
|
|
4
|
+
import { transformStateFunc as Rt, isDeepEqual as Y, isFunction as K, getNestedValue as Z, getDifferences as wt, debounce as jt } from "./utility.js";
|
|
5
|
+
import { pushFunc as yt, updateFn as at, cutFunc as ut, ValidationWrapper as Ot, FormControlComponent as Ut } from "./Functions.jsx";
|
|
6
6
|
import Ft from "superjson";
|
|
7
|
-
import { v4 as
|
|
7
|
+
import { v4 as $t } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
9
|
+
import { getGlobalStore as o, formRefStore as Vt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as xt } from "./CogsStateClient.jsx";
|
|
11
11
|
import { applyPatch as Dt } from "fast-json-patch";
|
|
12
12
|
import Wt from "react-use-measure";
|
|
13
|
-
function
|
|
13
|
+
function bt(t, c) {
|
|
14
14
|
const m = o.getState().getInitialOptions, f = o.getState().setInitialStateOptions, y = m(t) || {};
|
|
15
15
|
f(t, {
|
|
16
16
|
...y,
|
|
17
17
|
...c
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function At({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: c,
|
|
23
23
|
initialOptionsPart: m
|
|
24
24
|
}) {
|
|
25
|
-
const f = rt(t) || {}, y = m[t] || {},
|
|
25
|
+
const f = rt(t) || {}, y = m[t] || {}, k = o.getState().setInitialStateOptions, p = { ...y, ...f };
|
|
26
26
|
let I = !1;
|
|
27
27
|
if (c)
|
|
28
28
|
for (const a in c)
|
|
29
29
|
p.hasOwnProperty(a) ? (a == "localStorage" && c[a] && p[a].key !== c[a]?.key && (I = !0, p[a] = c[a]), a == "initialState" && c[a] && p[a] !== c[a] && // Different references
|
|
30
|
-
!
|
|
31
|
-
I &&
|
|
30
|
+
!Y(p[a], c[a]) && (I = !0, p[a] = c[a])) : (I = !0, p[a] = c[a]);
|
|
31
|
+
I && k(t, p);
|
|
32
32
|
}
|
|
33
33
|
function le(t, { formElements: c, validation: m }) {
|
|
34
34
|
return { initialState: t, formElements: c, validation: m };
|
|
@@ -45,14 +45,14 @@ const de = (t, c) => {
|
|
|
45
45
|
// State-specific overrides
|
|
46
46
|
}, rt(I) || o.getState().setInitialStateOptions(I, y[I]);
|
|
47
47
|
}), o.getState().setInitialStates(f), o.getState().setCreatedState(f);
|
|
48
|
-
const
|
|
49
|
-
const [v] =
|
|
50
|
-
|
|
48
|
+
const k = (I, a) => {
|
|
49
|
+
const [v] = et(a?.componentId ?? $t());
|
|
50
|
+
At({
|
|
51
51
|
stateKey: I,
|
|
52
52
|
options: a,
|
|
53
53
|
initialOptionsPart: y
|
|
54
54
|
});
|
|
55
|
-
const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [
|
|
55
|
+
const n = o.getState().cogsStateStore[I] || f[I], S = a?.modifyState ? a.modifyState(n) : n, [z, j] = Jt(
|
|
56
56
|
S,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -68,22 +68,22 @@ const de = (t, c) => {
|
|
|
68
68
|
serverState: a?.serverState
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
|
-
return
|
|
71
|
+
return j;
|
|
72
72
|
};
|
|
73
73
|
function p(I, a) {
|
|
74
|
-
|
|
74
|
+
At({ stateKey: I, options: a, initialOptionsPart: y }), a.localStorage && Bt(I, a), ht(I);
|
|
75
75
|
}
|
|
76
|
-
return { useCogsState:
|
|
76
|
+
return { useCogsState: k, setCogsOptions: p };
|
|
77
77
|
}, {
|
|
78
|
-
setUpdaterState:
|
|
79
|
-
setState:
|
|
78
|
+
setUpdaterState: ft,
|
|
79
|
+
setState: nt,
|
|
80
80
|
getInitialOptions: rt,
|
|
81
81
|
getKeyState: Nt,
|
|
82
82
|
getValidationErrors: Lt,
|
|
83
83
|
setStateLog: Gt,
|
|
84
|
-
updateInitialStateGlobal:
|
|
84
|
+
updateInitialStateGlobal: Tt,
|
|
85
85
|
addValidationError: Ht,
|
|
86
|
-
removeValidationError:
|
|
86
|
+
removeValidationError: Q,
|
|
87
87
|
setServerSyncActions: zt
|
|
88
88
|
} = o.getState(), kt = (t, c, m, f, y) => {
|
|
89
89
|
m?.log && console.log(
|
|
@@ -92,12 +92,12 @@ const de = (t, c) => {
|
|
|
92
92
|
m.localStorage?.key,
|
|
93
93
|
f
|
|
94
94
|
);
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const p = `${f}-${c}-${
|
|
95
|
+
const k = K(m?.localStorage?.key) ? m.localStorage?.key(t) : m?.localStorage?.key;
|
|
96
|
+
if (k && f) {
|
|
97
|
+
const p = `${f}-${c}-${k}`;
|
|
98
98
|
let I;
|
|
99
99
|
try {
|
|
100
|
-
I =
|
|
100
|
+
I = mt(p)?.lastSyncedWithServer;
|
|
101
101
|
} catch {
|
|
102
102
|
}
|
|
103
103
|
const a = {
|
|
@@ -110,7 +110,7 @@ const de = (t, c) => {
|
|
|
110
110
|
JSON.stringify(v.json)
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
-
},
|
|
113
|
+
}, mt = (t) => {
|
|
114
114
|
if (!t) return null;
|
|
115
115
|
try {
|
|
116
116
|
const c = window.localStorage.getItem(t);
|
|
@@ -119,28 +119,28 @@ const de = (t, c) => {
|
|
|
119
119
|
return console.error("Error loading from localStorage:", c), null;
|
|
120
120
|
}
|
|
121
121
|
}, Bt = (t, c) => {
|
|
122
|
-
const m = o.getState().cogsStateStore[t], { sessionId: f } =
|
|
122
|
+
const m = o.getState().cogsStateStore[t], { sessionId: f } = xt(), y = K(c?.localStorage?.key) ? c.localStorage.key(m) : c?.localStorage?.key;
|
|
123
123
|
if (y && f) {
|
|
124
|
-
const
|
|
124
|
+
const k = mt(
|
|
125
125
|
`${f}-${t}-${y}`
|
|
126
126
|
);
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
127
|
+
if (k && k.lastUpdated > (k.lastSyncedWithServer || 0))
|
|
128
|
+
return nt(t, k.state), ht(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, Pt = (t, c, m, f, y, k) => {
|
|
132
132
|
const p = {
|
|
133
133
|
initialState: c,
|
|
134
|
-
updaterState:
|
|
134
|
+
updaterState: St(
|
|
135
135
|
t,
|
|
136
136
|
f,
|
|
137
137
|
y,
|
|
138
|
-
|
|
138
|
+
k
|
|
139
139
|
),
|
|
140
140
|
state: m
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
},
|
|
142
|
+
Tt(t, p.initialState), ft(t, p.updaterState), nt(t, p.state);
|
|
143
|
+
}, ht = (t) => {
|
|
144
144
|
const c = o.getState().stateComponents.get(t);
|
|
145
145
|
if (!c) return;
|
|
146
146
|
const m = /* @__PURE__ */ new Set();
|
|
@@ -161,18 +161,18 @@ const de = (t, c) => {
|
|
|
161
161
|
switch (t) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
164
|
-
oldValue:
|
|
165
|
-
newValue:
|
|
164
|
+
oldValue: Z(c, f),
|
|
165
|
+
newValue: Z(m, f)
|
|
166
166
|
};
|
|
167
167
|
case "insert":
|
|
168
168
|
return {
|
|
169
169
|
oldValue: null,
|
|
170
170
|
// or undefined
|
|
171
|
-
newValue:
|
|
171
|
+
newValue: Z(m, f)
|
|
172
172
|
};
|
|
173
173
|
case "cut":
|
|
174
174
|
return {
|
|
175
|
-
oldValue:
|
|
175
|
+
oldValue: Z(c, f),
|
|
176
176
|
newValue: null
|
|
177
177
|
// or undefined
|
|
178
178
|
};
|
|
@@ -185,7 +185,7 @@ function Jt(t, {
|
|
|
185
185
|
serverSync: m,
|
|
186
186
|
localStorage: f,
|
|
187
187
|
formElements: y,
|
|
188
|
-
reactiveDeps:
|
|
188
|
+
reactiveDeps: k,
|
|
189
189
|
reactiveType: p,
|
|
190
190
|
componentId: I,
|
|
191
191
|
initialState: a,
|
|
@@ -193,14 +193,14 @@ function Jt(t, {
|
|
|
193
193
|
dependencies: n,
|
|
194
194
|
serverState: S
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
197
|
-
let
|
|
198
|
-
const [h] =
|
|
196
|
+
const [z, j] = et({}), { sessionId: O } = xt();
|
|
197
|
+
let B = !c;
|
|
198
|
+
const [h] = et(c ?? $t()), l = o.getState().stateLog[h], ct = X(/* @__PURE__ */ new Set()), tt = X(I ?? $t()), M = X(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
|
-
|
|
201
|
+
M.current = rt(h) ?? null, st(() => {
|
|
202
202
|
if (v && v.stateKey === h && v.path?.[0]) {
|
|
203
|
-
|
|
203
|
+
nt(h, (r) => ({
|
|
204
204
|
...r,
|
|
205
205
|
[v.path[0]]: v.newValue
|
|
206
206
|
}));
|
|
@@ -210,165 +210,165 @@ function Jt(t, {
|
|
|
210
210
|
userId: v.userId
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
}, [v]),
|
|
213
|
+
}, [v]), st(() => {
|
|
214
214
|
if (a) {
|
|
215
|
-
|
|
215
|
+
bt(h, {
|
|
216
216
|
initialState: a
|
|
217
217
|
});
|
|
218
|
-
const e =
|
|
219
|
-
if (!(i && !
|
|
218
|
+
const e = M.current, s = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, i = o.getState().initialStateGlobal[h];
|
|
219
|
+
if (!(i && !Y(i, a) || !i) && !s)
|
|
220
220
|
return;
|
|
221
|
-
let
|
|
222
|
-
const T =
|
|
223
|
-
T &&
|
|
224
|
-
let w = a,
|
|
225
|
-
const
|
|
226
|
-
s &&
|
|
221
|
+
let d = null;
|
|
222
|
+
const T = K(e?.localStorage?.key) ? e?.localStorage?.key(a) : e?.localStorage?.key;
|
|
223
|
+
T && O && (d = mt(`${O}-${h}-${T}`));
|
|
224
|
+
let w = a, b = !1;
|
|
225
|
+
const N = s ? Date.now() : 0, C = d?.lastUpdated || 0, P = d?.lastSyncedWithServer || 0;
|
|
226
|
+
s && N > C ? (w = e.serverState.data, b = !0) : d && C > P && (w = d.state, e?.localStorage?.onChange && e?.localStorage?.onChange(w)), o.getState().initializeShadowState(h, a), Pt(
|
|
227
227
|
h,
|
|
228
228
|
a,
|
|
229
229
|
w,
|
|
230
230
|
ot,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
),
|
|
231
|
+
tt.current,
|
|
232
|
+
O
|
|
233
|
+
), b && T && O && kt(w, h, e, O, Date.now()), ht(h), (Array.isArray(p) ? p : [p || "component"]).includes("none") || j({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
a,
|
|
237
237
|
S?.status,
|
|
238
238
|
S?.data,
|
|
239
239
|
...n || []
|
|
240
|
-
]),
|
|
241
|
-
|
|
240
|
+
]), gt(() => {
|
|
241
|
+
B && bt(h, {
|
|
242
242
|
serverSync: m,
|
|
243
243
|
formElements: y,
|
|
244
244
|
initialState: a,
|
|
245
245
|
localStorage: f,
|
|
246
|
-
middleware:
|
|
246
|
+
middleware: M.current?.middleware
|
|
247
247
|
});
|
|
248
|
-
const e = `${h}////${
|
|
248
|
+
const e = `${h}////${tt.current}`, r = o.getState().stateComponents.get(h) || {
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return r.components.set(e, {
|
|
252
|
-
forceUpdate: () =>
|
|
252
|
+
forceUpdate: () => j({}),
|
|
253
253
|
paths: /* @__PURE__ */ new Set(),
|
|
254
254
|
deps: [],
|
|
255
|
-
depsFunction:
|
|
255
|
+
depsFunction: k || void 0,
|
|
256
256
|
reactiveType: p ?? ["component", "deps"]
|
|
257
|
-
}), o.getState().stateComponents.set(h, r),
|
|
257
|
+
}), o.getState().stateComponents.set(h, r), j({}), () => {
|
|
258
258
|
r && (r.components.delete(e), r.components.size === 0 && o.getState().stateComponents.delete(h));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
261
261
|
const ot = (e, r, s, i) => {
|
|
262
262
|
if (Array.isArray(r)) {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const d = `${h}-${r.join(".")}`;
|
|
264
|
+
ct.current.add(d);
|
|
265
265
|
}
|
|
266
266
|
const g = o.getState();
|
|
267
|
-
|
|
268
|
-
const T =
|
|
267
|
+
nt(h, (d) => {
|
|
268
|
+
const T = K(e) ? e(d) : e, w = `${h}-${r.join(".")}`;
|
|
269
269
|
if (w) {
|
|
270
270
|
let _ = !1, E = g.signalDomElements.get(w);
|
|
271
271
|
if ((!E || E.size === 0) && (s.updateType === "insert" || s.updateType === "cut")) {
|
|
272
|
-
const
|
|
272
|
+
const U = r.slice(0, -1), W = Z(T, U);
|
|
273
273
|
if (Array.isArray(W)) {
|
|
274
274
|
_ = !0;
|
|
275
|
-
const
|
|
276
|
-
E = g.signalDomElements.get(
|
|
275
|
+
const V = `${h}-${U.join(".")}`;
|
|
276
|
+
E = g.signalDomElements.get(V);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
if (E) {
|
|
280
|
-
const
|
|
281
|
-
E.forEach(({ parentId: W, position:
|
|
282
|
-
const
|
|
280
|
+
const U = _ ? Z(T, r.slice(0, -1)) : Z(T, r);
|
|
281
|
+
E.forEach(({ parentId: W, position: V, effect: F }) => {
|
|
282
|
+
const R = document.querySelector(
|
|
283
283
|
`[data-parent-id="${W}"]`
|
|
284
284
|
);
|
|
285
|
-
if (
|
|
286
|
-
const $ = Array.from(
|
|
287
|
-
if ($[
|
|
288
|
-
const
|
|
289
|
-
$[
|
|
285
|
+
if (R) {
|
|
286
|
+
const $ = Array.from(R.childNodes);
|
|
287
|
+
if ($[V]) {
|
|
288
|
+
const A = F ? new Function("state", `return (${F})(state)`)(U) : U;
|
|
289
|
+
$[V].textContent = String(A);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
console.log("shadowState", g.shadowStateStore), s.updateType === "update" && (i ||
|
|
296
|
-
(i ||
|
|
295
|
+
console.log("shadowState", g.shadowStateStore), s.updateType === "update" && (i || M.current?.validation?.key) && r && Q(
|
|
296
|
+
(i || M.current?.validation?.key) + "." + r.join(".")
|
|
297
297
|
);
|
|
298
|
-
const
|
|
299
|
-
s.updateType === "cut" &&
|
|
300
|
-
|
|
301
|
-
), s.updateType === "insert" &&
|
|
302
|
-
|
|
303
|
-
).filter(([E,
|
|
298
|
+
const b = r.slice(0, r.length - 1);
|
|
299
|
+
s.updateType === "cut" && M.current?.validation?.key && Q(
|
|
300
|
+
M.current?.validation?.key + "." + b.join(".")
|
|
301
|
+
), s.updateType === "insert" && M.current?.validation?.key && Lt(
|
|
302
|
+
M.current?.validation?.key + "." + b.join(".")
|
|
303
|
+
).filter(([E, U]) => {
|
|
304
304
|
let W = E?.split(".").length;
|
|
305
|
-
if (E ==
|
|
306
|
-
let
|
|
307
|
-
|
|
305
|
+
if (E == b.join(".") && W == b.length - 1) {
|
|
306
|
+
let V = E + "." + b;
|
|
307
|
+
Q(E), Ht(V, U);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
|
-
const
|
|
311
|
-
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
312
|
-
const _ =
|
|
310
|
+
const N = g.stateComponents.get(h);
|
|
311
|
+
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", N), N) {
|
|
312
|
+
const _ = wt(d, T), E = new Set(_), U = s.updateType === "update" ? r.join(".") : r.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
314
|
W,
|
|
315
|
-
|
|
316
|
-
] of
|
|
315
|
+
V
|
|
316
|
+
] of N.components.entries()) {
|
|
317
317
|
let F = !1;
|
|
318
|
-
const
|
|
319
|
-
if (console.log("component",
|
|
320
|
-
if (
|
|
321
|
-
|
|
318
|
+
const R = Array.isArray(V.reactiveType) ? V.reactiveType : [V.reactiveType || "component"];
|
|
319
|
+
if (console.log("component", V), !R.includes("none")) {
|
|
320
|
+
if (R.includes("all")) {
|
|
321
|
+
V.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (
|
|
324
|
+
if (R.includes("component") && ((V.paths.has(U) || V.paths.has("")) && (F = !0), !F))
|
|
325
325
|
for (const $ of E) {
|
|
326
|
-
let
|
|
326
|
+
let A = $;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (
|
|
328
|
+
if (V.paths.has(A)) {
|
|
329
329
|
F = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
const L =
|
|
332
|
+
const L = A.lastIndexOf(".");
|
|
333
333
|
if (L !== -1) {
|
|
334
|
-
const
|
|
334
|
+
const q = A.substring(
|
|
335
335
|
0,
|
|
336
336
|
L
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
|
-
Number(
|
|
340
|
-
) &&
|
|
339
|
+
Number(A.substring(L + 1))
|
|
340
|
+
) && V.paths.has(q)) {
|
|
341
341
|
F = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
A = q;
|
|
345
345
|
} else
|
|
346
|
-
|
|
347
|
-
if (
|
|
346
|
+
A = "";
|
|
347
|
+
if (A === "")
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
350
|
if (F) break;
|
|
351
351
|
}
|
|
352
|
-
if (!F &&
|
|
353
|
-
const $ =
|
|
354
|
-
let
|
|
355
|
-
typeof $ == "boolean" ? $ && (
|
|
352
|
+
if (!F && R.includes("deps") && V.depsFunction) {
|
|
353
|
+
const $ = V.depsFunction(T);
|
|
354
|
+
let A = !1;
|
|
355
|
+
typeof $ == "boolean" ? $ && (A = !0) : Y(V.deps, $) || (V.deps = $, A = !0), A && (F = !0);
|
|
356
356
|
}
|
|
357
|
-
F &&
|
|
357
|
+
F && V.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
const C = Date.now();
|
|
362
362
|
r = r.map((_, E) => {
|
|
363
|
-
const
|
|
363
|
+
const U = r.slice(0, -1), W = Z(T, U);
|
|
364
364
|
return E === r.length - 1 && ["insert", "cut"].includes(s.updateType) ? (W.length - 1).toString() : _;
|
|
365
365
|
});
|
|
366
366
|
const { oldValue: P, newValue: D } = qt(
|
|
367
367
|
s.updateType,
|
|
368
|
-
|
|
368
|
+
d,
|
|
369
369
|
T,
|
|
370
370
|
r
|
|
371
|
-
),
|
|
371
|
+
), x = {
|
|
372
372
|
timeStamp: C,
|
|
373
373
|
stateKey: h,
|
|
374
374
|
path: r,
|
|
@@ -386,26 +386,26 @@ function Jt(t, {
|
|
|
386
386
|
g.insertShadowArrayElement(h, _, D);
|
|
387
387
|
break;
|
|
388
388
|
case "cut":
|
|
389
|
-
const E = r.slice(0, -1),
|
|
390
|
-
g.removeShadowArrayElement(h, E,
|
|
389
|
+
const E = r.slice(0, -1), U = parseInt(r[r.length - 1]);
|
|
390
|
+
g.removeShadowArrayElement(h, E, U);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
393
|
if (Gt(h, (_) => {
|
|
394
|
-
const
|
|
395
|
-
const F = `${
|
|
396
|
-
return
|
|
394
|
+
const U = [..._ ?? [], x].reduce((W, V) => {
|
|
395
|
+
const F = `${V.stateKey}:${JSON.stringify(V.path)}`, R = W.get(F);
|
|
396
|
+
return R ? (R.timeStamp = Math.max(R.timeStamp, V.timeStamp), R.newValue = V.newValue, R.oldValue = R.oldValue ?? V.oldValue, R.updateType = V.updateType) : W.set(F, { ...V }), W;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
|
-
return Array.from(
|
|
398
|
+
return Array.from(U.values());
|
|
399
399
|
}), kt(
|
|
400
400
|
T,
|
|
401
401
|
h,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
),
|
|
402
|
+
M.current,
|
|
403
|
+
O
|
|
404
|
+
), M.current?.middleware && M.current.middleware({
|
|
405
405
|
updateLog: l,
|
|
406
|
-
update:
|
|
407
|
-
}),
|
|
408
|
-
const _ = g.serverState[h], E =
|
|
406
|
+
update: x
|
|
407
|
+
}), M.current?.serverSync) {
|
|
408
|
+
const _ = g.serverState[h], E = M.current?.serverSync;
|
|
409
409
|
zt(h, {
|
|
410
410
|
syncKey: typeof E.syncKey == "string" ? E.syncKey : E.syncKey({ state: T }),
|
|
411
411
|
rollBackState: _,
|
|
@@ -416,63 +416,63 @@ function Jt(t, {
|
|
|
416
416
|
return T;
|
|
417
417
|
});
|
|
418
418
|
};
|
|
419
|
-
o.getState().updaterState[h] || (
|
|
419
|
+
o.getState().updaterState[h] || (ft(
|
|
420
420
|
h,
|
|
421
|
-
|
|
421
|
+
St(
|
|
422
422
|
h,
|
|
423
423
|
ot,
|
|
424
|
-
|
|
425
|
-
|
|
424
|
+
tt.current,
|
|
425
|
+
O
|
|
426
426
|
)
|
|
427
|
-
), o.getState().cogsStateStore[h] ||
|
|
428
|
-
const
|
|
427
|
+
), o.getState().cogsStateStore[h] || nt(h, t), o.getState().initialStateGlobal[h] || Tt(h, t));
|
|
428
|
+
const u = pt(() => St(
|
|
429
429
|
h,
|
|
430
430
|
ot,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
), [h,
|
|
434
|
-
return [Nt(h),
|
|
431
|
+
tt.current,
|
|
432
|
+
O
|
|
433
|
+
), [h, O]);
|
|
434
|
+
return [Nt(h), u];
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function St(t, c, m, f) {
|
|
437
437
|
const y = /* @__PURE__ */ new Map();
|
|
438
|
-
let
|
|
438
|
+
let k = 0;
|
|
439
439
|
const p = (v) => {
|
|
440
440
|
const n = v.join(".");
|
|
441
441
|
for (const [S] of y)
|
|
442
442
|
(S === n || S.startsWith(n + ".")) && y.delete(S);
|
|
443
|
-
|
|
443
|
+
k++;
|
|
444
444
|
}, I = {
|
|
445
445
|
removeValidation: (v) => {
|
|
446
|
-
v?.validationKey &&
|
|
446
|
+
v?.validationKey && Q(v.validationKey);
|
|
447
447
|
},
|
|
448
448
|
revertToInitialState: (v) => {
|
|
449
449
|
const n = o.getState().getInitialOptions(t)?.validation;
|
|
450
|
-
n?.key &&
|
|
450
|
+
n?.key && Q(n?.key), v?.validationKey && Q(v.validationKey);
|
|
451
451
|
const S = o.getState().initialStateGlobal[t];
|
|
452
|
-
o.getState().clearSelectedIndexesForState(t), y.clear(),
|
|
453
|
-
const
|
|
454
|
-
|
|
452
|
+
o.getState().clearSelectedIndexesForState(t), y.clear(), k++;
|
|
453
|
+
const z = a(S, []), j = rt(t), O = K(j?.localStorage?.key) ? j?.localStorage?.key(S) : j?.localStorage?.key, B = `${f}-${t}-${O}`;
|
|
454
|
+
B && localStorage.removeItem(B), ft(t, z), nt(t, S);
|
|
455
455
|
const h = o.getState().stateComponents.get(t);
|
|
456
456
|
return h && h.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
458
458
|
}), S;
|
|
459
459
|
},
|
|
460
460
|
updateInitialState: (v) => {
|
|
461
|
-
y.clear(),
|
|
462
|
-
const n =
|
|
461
|
+
y.clear(), k++;
|
|
462
|
+
const n = St(
|
|
463
463
|
t,
|
|
464
464
|
c,
|
|
465
465
|
m,
|
|
466
466
|
f
|
|
467
|
-
), S = o.getState().initialStateGlobal[t],
|
|
468
|
-
return localStorage.getItem(
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
467
|
+
), S = o.getState().initialStateGlobal[t], z = rt(t), j = K(z?.localStorage?.key) ? z?.localStorage?.key(S) : z?.localStorage?.key, O = `${f}-${t}-${j}`;
|
|
468
|
+
return localStorage.getItem(O) && localStorage.removeItem(O), Mt(() => {
|
|
469
|
+
Tt(t, v), o.getState().initializeShadowState(t, v), ft(t, n), nt(t, v);
|
|
470
|
+
const B = o.getState().stateComponents.get(t);
|
|
471
|
+
B && B.components.forEach((h) => {
|
|
472
472
|
h.forceUpdate();
|
|
473
473
|
});
|
|
474
474
|
}), {
|
|
475
|
-
fetchId: (
|
|
475
|
+
fetchId: (B) => n.get()[B]
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
478
|
_initialState: o.getState().initialStateGlobal[t],
|
|
@@ -480,27 +480,27 @@ function ft(t, c, m, f) {
|
|
|
480
480
|
_isLoading: o.getState().isLoadingGlobal[t],
|
|
481
481
|
_isServerSynced: () => {
|
|
482
482
|
const v = o.getState().serverState[t];
|
|
483
|
-
return !!(v &&
|
|
483
|
+
return !!(v && Y(v, Nt(t)));
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function a(v, n = [], S) {
|
|
487
|
-
const
|
|
488
|
-
y.get(
|
|
489
|
-
const
|
|
487
|
+
const z = n.map(String).join(".");
|
|
488
|
+
y.get(z);
|
|
489
|
+
const j = function() {
|
|
490
490
|
return o().getNestedState(t, n);
|
|
491
491
|
};
|
|
492
492
|
Object.keys(I).forEach((h) => {
|
|
493
|
-
|
|
493
|
+
j[h] = I[h];
|
|
494
494
|
});
|
|
495
|
-
const
|
|
496
|
-
apply(h, l,
|
|
495
|
+
const O = {
|
|
496
|
+
apply(h, l, ct) {
|
|
497
497
|
return console.log(
|
|
498
498
|
`PROXY APPLY TRAP HIT: stateKey=${t}, path=${n.join(".")}`
|
|
499
499
|
), console.trace("Apply trap stack trace"), o().getNestedState(t, n);
|
|
500
500
|
},
|
|
501
501
|
get(h, l) {
|
|
502
502
|
S?.validIndices && !Array.isArray(v) && (S = { ...S, validIndices: void 0 });
|
|
503
|
-
const
|
|
503
|
+
const ct = /* @__PURE__ */ new Set([
|
|
504
504
|
"insert",
|
|
505
505
|
"cut",
|
|
506
506
|
"cutByValue",
|
|
@@ -523,10 +523,10 @@ function ft(t, c, m, f) {
|
|
|
523
523
|
"_stateKey",
|
|
524
524
|
"getComponents"
|
|
525
525
|
]);
|
|
526
|
-
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !
|
|
527
|
-
const
|
|
526
|
+
if (l !== "then" && !l.startsWith("$") && l !== "stateMapNoRender" && !ct.has(l)) {
|
|
527
|
+
const u = `${t}////${m}`, e = o.getState().stateComponents.get(t);
|
|
528
528
|
if (e) {
|
|
529
|
-
const r = e.components.get(
|
|
529
|
+
const r = e.components.get(u);
|
|
530
530
|
if (r && !r.paths.has("")) {
|
|
531
531
|
const s = n.join(".");
|
|
532
532
|
let i = !0;
|
|
@@ -540,26 +540,26 @@ function ft(t, c, m, f) {
|
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
if (l === "getDifferences")
|
|
543
|
-
return () =>
|
|
543
|
+
return () => wt(
|
|
544
544
|
o.getState().cogsStateStore[t],
|
|
545
545
|
o.getState().initialStateGlobal[t]
|
|
546
546
|
);
|
|
547
547
|
if (l === "sync" && n.length === 0)
|
|
548
548
|
return async function() {
|
|
549
|
-
const
|
|
549
|
+
const u = o.getState().getInitialOptions(t), e = u?.sync;
|
|
550
550
|
if (!e)
|
|
551
551
|
return console.error(`No mutation defined for state key "${t}"`), { success: !1, error: "No mutation defined" };
|
|
552
|
-
const r = o.getState().getNestedState(t, []), s =
|
|
552
|
+
const r = o.getState().getNestedState(t, []), s = u?.validation?.key;
|
|
553
553
|
try {
|
|
554
554
|
const i = await e.action(r);
|
|
555
555
|
if (i && !i.success && i.errors && s) {
|
|
556
|
-
o.getState().removeValidationError(s), i.errors.forEach((
|
|
557
|
-
const T = [s, ...
|
|
558
|
-
o.getState().addValidationError(T,
|
|
556
|
+
o.getState().removeValidationError(s), i.errors.forEach((d) => {
|
|
557
|
+
const T = [s, ...d.path].join(".");
|
|
558
|
+
o.getState().addValidationError(T, d.message);
|
|
559
559
|
});
|
|
560
560
|
const g = o.getState().stateComponents.get(t);
|
|
561
|
-
g && g.components.forEach((
|
|
562
|
-
|
|
561
|
+
g && g.components.forEach((d) => {
|
|
562
|
+
d.forceUpdate();
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
565
|
return i?.success && e.onSuccess ? e.onSuccess(i.data) : !i?.success && e.onError && e.onError(i.error), i;
|
|
@@ -568,31 +568,31 @@ function ft(t, c, m, f) {
|
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
570
|
if (l === "_status") {
|
|
571
|
-
const
|
|
572
|
-
return
|
|
571
|
+
const u = o.getState().getNestedState(t, n), e = o.getState().initialStateGlobal[t], r = Z(e, n);
|
|
572
|
+
return Y(u, r) ? "fresh" : "stale";
|
|
573
573
|
}
|
|
574
574
|
if (l === "getStatus")
|
|
575
575
|
return function() {
|
|
576
|
-
const
|
|
576
|
+
const u = o().getNestedState(
|
|
577
577
|
t,
|
|
578
578
|
n
|
|
579
|
-
), e = o.getState().initialStateGlobal[t], r =
|
|
580
|
-
return
|
|
579
|
+
), e = o.getState().initialStateGlobal[t], r = Z(e, n);
|
|
580
|
+
return Y(u, r) ? "fresh" : "stale";
|
|
581
581
|
};
|
|
582
582
|
if (l === "removeStorage")
|
|
583
583
|
return () => {
|
|
584
|
-
const
|
|
584
|
+
const u = o.getState().initialStateGlobal[t], e = rt(t), r = K(e?.localStorage?.key) ? e?.localStorage?.key(u) : e?.localStorage?.key, s = `${f}-${t}-${r}`;
|
|
585
585
|
s && localStorage.removeItem(s);
|
|
586
586
|
};
|
|
587
587
|
if (l === "showValidationErrors")
|
|
588
588
|
return () => {
|
|
589
|
-
const
|
|
590
|
-
if (!
|
|
589
|
+
const u = o.getState().getInitialOptions(t)?.validation;
|
|
590
|
+
if (!u?.key)
|
|
591
591
|
throw new Error("Validation key not found");
|
|
592
|
-
return o.getState().getValidationErrors(
|
|
592
|
+
return o.getState().getValidationErrors(u.key + "." + n.join("."));
|
|
593
593
|
};
|
|
594
594
|
if (Array.isArray(v)) {
|
|
595
|
-
const
|
|
595
|
+
const u = () => S?.validIndices ? v.map((r, s) => ({
|
|
596
596
|
item: r,
|
|
597
597
|
originalIndex: S.validIndices[s]
|
|
598
598
|
})) : o.getState().getNestedState(t, n).map((r, s) => ({
|
|
@@ -621,95 +621,118 @@ function ft(t, c, m, f) {
|
|
|
621
621
|
itemHeight: r = 50,
|
|
622
622
|
overscan: s = 5,
|
|
623
623
|
stickToBottom: i = !1
|
|
624
|
-
} = e, g =
|
|
624
|
+
} = e, g = X(null), [d, T] = et({
|
|
625
625
|
startIndex: 0,
|
|
626
626
|
endIndex: 10
|
|
627
|
-
}), w =
|
|
628
|
-
|
|
627
|
+
}), w = X(i), [b, N] = et(0), C = X(!1), P = X(0);
|
|
628
|
+
st(() => {
|
|
629
629
|
let $ = 0;
|
|
630
630
|
return o.getState().subscribeToShadowState(t, () => {
|
|
631
631
|
$++, $ <= 5 && console.log(
|
|
632
632
|
`[VirtualView] Shadow update #${$}`
|
|
633
|
-
),
|
|
633
|
+
), N((L) => L + 1);
|
|
634
634
|
});
|
|
635
635
|
}, [t]);
|
|
636
636
|
const D = o().getNestedState(
|
|
637
637
|
t,
|
|
638
638
|
n
|
|
639
|
-
),
|
|
639
|
+
), x = D.length;
|
|
640
640
|
console.log(
|
|
641
|
-
`[VirtualView] Initial setup - totalCount: ${
|
|
642
|
-
),
|
|
643
|
-
`[VirtualView] Array size changed from ${P.current} to ${
|
|
644
|
-
), C.current = !1, P.current =
|
|
645
|
-
const { totalHeight: _, positions: E,
|
|
641
|
+
`[VirtualView] Initial setup - totalCount: ${x}, itemHeight: ${r}, stickToBottom: ${i}`
|
|
642
|
+
), x !== P.current && (console.log(
|
|
643
|
+
`[VirtualView] Array size changed from ${P.current} to ${x}`
|
|
644
|
+
), C.current = !1, P.current = x);
|
|
645
|
+
const { totalHeight: _, positions: E, visibleMeasured: U } = pt(() => {
|
|
646
646
|
const $ = o.getState().getShadowMetadata(t, n) || [];
|
|
647
|
-
let
|
|
647
|
+
let A = 0;
|
|
648
648
|
const L = [];
|
|
649
|
-
let
|
|
650
|
-
for (let
|
|
651
|
-
L[
|
|
652
|
-
const
|
|
653
|
-
|
|
649
|
+
let q = 0, J = 0;
|
|
650
|
+
for (let H = 0; H < x; H++) {
|
|
651
|
+
L[H] = A;
|
|
652
|
+
const dt = $[H]?.virtualizer?.itemHeight;
|
|
653
|
+
dt && (q++, H >= d.startIndex && H < d.endIndex && J++), A += dt || r;
|
|
654
654
|
}
|
|
655
|
-
const
|
|
655
|
+
const G = d.endIndex - d.startIndex, lt = J === G && G > 0;
|
|
656
656
|
return console.log(
|
|
657
|
-
`[VirtualView] Heights calc - measured: ${
|
|
658
|
-
), {
|
|
657
|
+
`[VirtualView] Heights calc - measured: ${q}/${x}, visible measured: ${J}/${G}, totalHeight: ${A}`
|
|
658
|
+
), {
|
|
659
|
+
totalHeight: A,
|
|
660
|
+
positions: L,
|
|
661
|
+
visibleMeasured: lt
|
|
662
|
+
};
|
|
659
663
|
}, [
|
|
660
|
-
|
|
664
|
+
x,
|
|
661
665
|
t,
|
|
662
666
|
n.join("."),
|
|
663
667
|
r,
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
668
|
+
b,
|
|
669
|
+
d
|
|
670
|
+
// Add range dependency
|
|
671
|
+
]), W = pt(() => {
|
|
672
|
+
const $ = Math.max(0, d.startIndex), A = Math.min(x, d.endIndex);
|
|
667
673
|
console.log(
|
|
668
|
-
`[VirtualView] Creating virtual slice - range: ${$}-${
|
|
674
|
+
`[VirtualView] Creating virtual slice - range: ${$}-${A} (${A - $} items)`
|
|
669
675
|
);
|
|
670
676
|
const L = Array.from(
|
|
671
|
-
{ length:
|
|
672
|
-
(
|
|
673
|
-
),
|
|
674
|
-
return a(
|
|
677
|
+
{ length: A - $ },
|
|
678
|
+
(J, G) => $ + G
|
|
679
|
+
), q = L.map((J) => D[J]);
|
|
680
|
+
return a(q, n, {
|
|
675
681
|
...S,
|
|
676
682
|
validIndices: L
|
|
677
683
|
});
|
|
678
|
-
}, [
|
|
679
|
-
|
|
684
|
+
}, [d.startIndex, d.endIndex, D, x]);
|
|
685
|
+
gt(() => {
|
|
680
686
|
const $ = g.current;
|
|
681
687
|
if (!$) return;
|
|
682
|
-
const
|
|
688
|
+
const A = () => {
|
|
683
689
|
if (!$) return;
|
|
684
|
-
const { scrollTop:
|
|
685
|
-
let
|
|
686
|
-
for (;
|
|
687
|
-
const
|
|
688
|
-
E[
|
|
690
|
+
const { scrollTop: q } = $;
|
|
691
|
+
let J = 0, G = x - 1;
|
|
692
|
+
for (; J <= G; ) {
|
|
693
|
+
const vt = Math.floor((J + G) / 2);
|
|
694
|
+
E[vt] < q ? J = vt + 1 : G = vt - 1;
|
|
689
695
|
}
|
|
690
|
-
const
|
|
691
|
-
let
|
|
692
|
-
const
|
|
693
|
-
for (;
|
|
694
|
-
|
|
695
|
-
|
|
696
|
+
const lt = Math.max(0, G - s);
|
|
697
|
+
let H = lt;
|
|
698
|
+
const dt = q + $.clientHeight;
|
|
699
|
+
for (; H < x && E[H] < dt; )
|
|
700
|
+
H++;
|
|
701
|
+
H = Math.min(x, H + s), T({ startIndex: lt, endIndex: H });
|
|
696
702
|
}, L = () => {
|
|
697
|
-
w.current = $.scrollHeight - $.scrollTop - $.clientHeight < 1,
|
|
703
|
+
w.current = $.scrollHeight - $.scrollTop - $.clientHeight < 1, A();
|
|
698
704
|
};
|
|
699
|
-
|
|
705
|
+
if ($.addEventListener("scroll", L, {
|
|
700
706
|
passive: !0
|
|
701
|
-
}), i && !C.current &&
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
707
|
+
}), i && !C.current && x > 0)
|
|
708
|
+
if (d.endIndex >= x - 5)
|
|
709
|
+
console.log(
|
|
710
|
+
"[VirtualView] At end of list, scrolling to bottom"
|
|
711
|
+
), C.current = !0, setTimeout(() => {
|
|
712
|
+
const G = $.scrollHeight + 1e3;
|
|
713
|
+
$.scrollTo({
|
|
714
|
+
top: G,
|
|
715
|
+
behavior: "auto"
|
|
716
|
+
}), w.current = !0;
|
|
717
|
+
}, 50);
|
|
718
|
+
else {
|
|
719
|
+
console.log(
|
|
720
|
+
"[VirtualView] Jumping near bottom to trigger measurements"
|
|
721
|
+
);
|
|
722
|
+
const G = Math.max(
|
|
723
|
+
0,
|
|
724
|
+
(x - 20) * r
|
|
725
|
+
);
|
|
726
|
+
$.scrollTo({
|
|
727
|
+
top: G,
|
|
728
|
+
behavior: "auto"
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
return A(), () => {
|
|
709
732
|
$.removeEventListener("scroll", L);
|
|
710
733
|
};
|
|
711
|
-
}, [
|
|
712
|
-
const
|
|
734
|
+
}, [x, E, i]);
|
|
735
|
+
const V = Et(
|
|
713
736
|
($ = "smooth") => {
|
|
714
737
|
g.current && (w.current = !0, g.current.scrollTo({
|
|
715
738
|
top: g.current.scrollHeight,
|
|
@@ -717,15 +740,15 @@ function ft(t, c, m, f) {
|
|
|
717
740
|
}));
|
|
718
741
|
},
|
|
719
742
|
[]
|
|
720
|
-
), F =
|
|
721
|
-
($,
|
|
743
|
+
), F = Et(
|
|
744
|
+
($, A = "smooth") => {
|
|
722
745
|
g.current && E[$] !== void 0 && (w.current = !1, g.current.scrollTo({
|
|
723
746
|
top: E[$],
|
|
724
|
-
behavior:
|
|
747
|
+
behavior: A
|
|
725
748
|
}));
|
|
726
749
|
},
|
|
727
750
|
[E]
|
|
728
|
-
),
|
|
751
|
+
), R = {
|
|
729
752
|
outer: {
|
|
730
753
|
ref: g,
|
|
731
754
|
style: { overflowY: "auto", height: "100%" }
|
|
@@ -738,37 +761,37 @@ function ft(t, c, m, f) {
|
|
|
738
761
|
},
|
|
739
762
|
list: {
|
|
740
763
|
style: {
|
|
741
|
-
transform: `translateY(${E[
|
|
764
|
+
transform: `translateY(${E[d.startIndex] || 0}px)`
|
|
742
765
|
}
|
|
743
766
|
}
|
|
744
767
|
};
|
|
745
768
|
return {
|
|
746
769
|
virtualState: W,
|
|
747
|
-
virtualizerProps:
|
|
748
|
-
scrollToBottom:
|
|
770
|
+
virtualizerProps: R,
|
|
771
|
+
scrollToBottom: V,
|
|
749
772
|
scrollToIndex: F
|
|
750
773
|
};
|
|
751
774
|
};
|
|
752
775
|
if (l === "stateSort")
|
|
753
776
|
return (e) => {
|
|
754
|
-
const s = [...
|
|
755
|
-
(
|
|
756
|
-
), i = s.map(({ item:
|
|
777
|
+
const s = [...u()].sort(
|
|
778
|
+
(d, T) => e(d.item, T.item)
|
|
779
|
+
), i = s.map(({ item: d }) => d), g = {
|
|
757
780
|
...S,
|
|
758
781
|
validIndices: s.map(
|
|
759
|
-
({ originalIndex:
|
|
782
|
+
({ originalIndex: d }) => d
|
|
760
783
|
)
|
|
761
784
|
};
|
|
762
785
|
return a(i, n, g);
|
|
763
786
|
};
|
|
764
787
|
if (l === "stateFilter")
|
|
765
788
|
return (e) => {
|
|
766
|
-
const s =
|
|
767
|
-
({ item:
|
|
768
|
-
), i = s.map(({ item:
|
|
789
|
+
const s = u().filter(
|
|
790
|
+
({ item: d }, T) => e(d, T)
|
|
791
|
+
), i = s.map(({ item: d }) => d), g = {
|
|
769
792
|
...S,
|
|
770
793
|
validIndices: s.map(
|
|
771
|
-
({ originalIndex:
|
|
794
|
+
({ originalIndex: d }) => d
|
|
772
795
|
)
|
|
773
796
|
};
|
|
774
797
|
return a(i, n, g);
|
|
@@ -777,20 +800,20 @@ function ft(t, c, m, f) {
|
|
|
777
800
|
return (e) => {
|
|
778
801
|
const r = o.getState().getNestedState(t, n);
|
|
779
802
|
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
|
|
780
|
-
const
|
|
781
|
-
return e(
|
|
803
|
+
const d = r[i], T = [...n, i.toString()], w = a(d, T, S);
|
|
804
|
+
return e(d, w, {
|
|
782
805
|
register: () => {
|
|
783
|
-
const [,
|
|
784
|
-
|
|
806
|
+
const [, N] = et({}), C = `${m}-${n.join(".")}-${i}`;
|
|
807
|
+
gt(() => {
|
|
785
808
|
const P = `${t}////${C}`, D = o.getState().stateComponents.get(t) || {
|
|
786
809
|
components: /* @__PURE__ */ new Map()
|
|
787
810
|
};
|
|
788
811
|
return D.components.set(P, {
|
|
789
|
-
forceUpdate: () =>
|
|
812
|
+
forceUpdate: () => N({}),
|
|
790
813
|
paths: /* @__PURE__ */ new Set([T.join(".")])
|
|
791
814
|
}), o.getState().stateComponents.set(t, D), () => {
|
|
792
|
-
const
|
|
793
|
-
|
|
815
|
+
const x = o.getState().stateComponents.get(t);
|
|
816
|
+
x && x.components.delete(P);
|
|
794
817
|
};
|
|
795
818
|
}, [t, C]);
|
|
796
819
|
},
|
|
@@ -806,7 +829,7 @@ function ft(t, c, m, f) {
|
|
|
806
829
|
return (e) => v.map((s, i) => {
|
|
807
830
|
let g;
|
|
808
831
|
S?.validIndices && S.validIndices[i] !== void 0 ? g = S.validIndices[i] : g = i;
|
|
809
|
-
const
|
|
832
|
+
const d = [...n, g.toString()], T = a(s, d, S);
|
|
810
833
|
return e(
|
|
811
834
|
s,
|
|
812
835
|
T,
|
|
@@ -816,7 +839,7 @@ function ft(t, c, m, f) {
|
|
|
816
839
|
);
|
|
817
840
|
});
|
|
818
841
|
if (l === "$stateMap")
|
|
819
|
-
return (e) =>
|
|
842
|
+
return (e) => it(Yt, {
|
|
820
843
|
proxy: {
|
|
821
844
|
_stateKey: t,
|
|
822
845
|
_path: n,
|
|
@@ -829,14 +852,14 @@ function ft(t, c, m, f) {
|
|
|
829
852
|
return (e) => {
|
|
830
853
|
const r = o.getState().getNestedState(t, n);
|
|
831
854
|
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
|
|
832
|
-
const
|
|
833
|
-
return
|
|
855
|
+
const d = r[i], T = [...n, i.toString()], w = a(d, T, S), b = `${m}-${n.join(".")}-${i}`;
|
|
856
|
+
return it(Xt, {
|
|
834
857
|
key: i,
|
|
835
858
|
stateKey: t,
|
|
836
|
-
itemComponentId:
|
|
859
|
+
itemComponentId: b,
|
|
837
860
|
itemPath: T,
|
|
838
861
|
children: e(
|
|
839
|
-
|
|
862
|
+
d,
|
|
840
863
|
w,
|
|
841
864
|
g,
|
|
842
865
|
r,
|
|
@@ -850,7 +873,7 @@ function ft(t, c, m, f) {
|
|
|
850
873
|
if (l === "stateFlattenOn")
|
|
851
874
|
return (e) => {
|
|
852
875
|
const r = v;
|
|
853
|
-
y.clear(),
|
|
876
|
+
y.clear(), k++;
|
|
854
877
|
const s = r.flatMap(
|
|
855
878
|
(i) => i[e] ?? []
|
|
856
879
|
);
|
|
@@ -873,36 +896,36 @@ function ft(t, c, m, f) {
|
|
|
873
896
|
return a(s, i);
|
|
874
897
|
};
|
|
875
898
|
if (l === "insert")
|
|
876
|
-
return (e) => (p(n),
|
|
899
|
+
return (e) => (p(n), yt(c, e, n, t), a(
|
|
877
900
|
o.getState().getNestedState(t, n),
|
|
878
901
|
n
|
|
879
902
|
));
|
|
880
903
|
if (l === "uniqueInsert")
|
|
881
904
|
return (e, r, s) => {
|
|
882
|
-
const i = o.getState().getNestedState(t, n), g =
|
|
883
|
-
let
|
|
905
|
+
const i = o.getState().getNestedState(t, n), g = K(e) ? e(i) : e;
|
|
906
|
+
let d = null;
|
|
884
907
|
if (!i.some((w) => {
|
|
885
908
|
if (r) {
|
|
886
|
-
const
|
|
887
|
-
(C) =>
|
|
909
|
+
const N = r.every(
|
|
910
|
+
(C) => Y(w[C], g[C])
|
|
888
911
|
);
|
|
889
|
-
return
|
|
912
|
+
return N && (d = w), N;
|
|
890
913
|
}
|
|
891
|
-
const
|
|
892
|
-
return
|
|
914
|
+
const b = Y(w, g);
|
|
915
|
+
return b && (d = w), b;
|
|
893
916
|
}))
|
|
894
|
-
p(n),
|
|
895
|
-
else if (s &&
|
|
896
|
-
const w = s(
|
|
897
|
-
(
|
|
917
|
+
p(n), yt(c, g, n, t);
|
|
918
|
+
else if (s && d) {
|
|
919
|
+
const w = s(d), b = i.map(
|
|
920
|
+
(N) => Y(N, d) ? w : N
|
|
898
921
|
);
|
|
899
|
-
p(n),
|
|
922
|
+
p(n), at(c, b, n);
|
|
900
923
|
}
|
|
901
924
|
};
|
|
902
925
|
if (l === "cut")
|
|
903
926
|
return (e, r) => {
|
|
904
927
|
if (!r?.waitForSync)
|
|
905
|
-
return p(n),
|
|
928
|
+
return p(n), ut(c, n, t, e), a(
|
|
906
929
|
o.getState().getNestedState(t, n),
|
|
907
930
|
n
|
|
908
931
|
);
|
|
@@ -910,17 +933,17 @@ function ft(t, c, m, f) {
|
|
|
910
933
|
if (l === "cutByValue")
|
|
911
934
|
return (e) => {
|
|
912
935
|
for (let r = 0; r < v.length; r++)
|
|
913
|
-
v[r] === e &&
|
|
936
|
+
v[r] === e && ut(c, n, t, r);
|
|
914
937
|
};
|
|
915
938
|
if (l === "toggleByValue")
|
|
916
939
|
return (e) => {
|
|
917
940
|
const r = v.findIndex((s) => s === e);
|
|
918
|
-
r > -1 ?
|
|
941
|
+
r > -1 ? ut(c, n, t, r) : yt(c, e, n, t);
|
|
919
942
|
};
|
|
920
943
|
if (l === "stateFind")
|
|
921
944
|
return (e) => {
|
|
922
|
-
const s =
|
|
923
|
-
({ item: g },
|
|
945
|
+
const s = u().find(
|
|
946
|
+
({ item: g }, d) => e(g, d)
|
|
924
947
|
);
|
|
925
948
|
if (!s) return;
|
|
926
949
|
const i = [...n, s.originalIndex.toString()];
|
|
@@ -928,77 +951,77 @@ function ft(t, c, m, f) {
|
|
|
928
951
|
};
|
|
929
952
|
if (l === "findWith")
|
|
930
953
|
return (e, r) => {
|
|
931
|
-
const i =
|
|
932
|
-
({ item:
|
|
954
|
+
const i = u().find(
|
|
955
|
+
({ item: d }) => d[e] === r
|
|
933
956
|
);
|
|
934
957
|
if (!i) return;
|
|
935
958
|
const g = [...n, i.originalIndex.toString()];
|
|
936
959
|
return a(i.item, g, S);
|
|
937
960
|
};
|
|
938
961
|
}
|
|
939
|
-
const
|
|
940
|
-
if (!isNaN(Number(
|
|
941
|
-
const
|
|
962
|
+
const tt = n[n.length - 1];
|
|
963
|
+
if (!isNaN(Number(tt))) {
|
|
964
|
+
const u = n.slice(0, -1), e = o.getState().getNestedState(t, u);
|
|
942
965
|
if (Array.isArray(e) && l === "cut")
|
|
943
|
-
return () =>
|
|
966
|
+
return () => ut(
|
|
944
967
|
c,
|
|
945
|
-
|
|
968
|
+
u,
|
|
946
969
|
t,
|
|
947
|
-
Number(
|
|
970
|
+
Number(tt)
|
|
948
971
|
);
|
|
949
972
|
}
|
|
950
973
|
if (l === "get")
|
|
951
974
|
return () => {
|
|
952
975
|
if (S?.validIndices && Array.isArray(v)) {
|
|
953
|
-
const
|
|
954
|
-
return S.validIndices.map((e) =>
|
|
976
|
+
const u = o.getState().getNestedState(t, n);
|
|
977
|
+
return S.validIndices.map((e) => u[e]);
|
|
955
978
|
}
|
|
956
979
|
return o.getState().getNestedState(t, n);
|
|
957
980
|
};
|
|
958
981
|
if (l === "$derive")
|
|
959
|
-
return (
|
|
982
|
+
return (u) => Ct({
|
|
960
983
|
_stateKey: t,
|
|
961
984
|
_path: n,
|
|
962
|
-
_effect:
|
|
985
|
+
_effect: u.toString()
|
|
963
986
|
});
|
|
964
987
|
if (l === "$get")
|
|
965
|
-
return () =>
|
|
988
|
+
return () => Ct({
|
|
966
989
|
_stateKey: t,
|
|
967
990
|
_path: n
|
|
968
991
|
});
|
|
969
992
|
if (l === "lastSynced") {
|
|
970
|
-
const
|
|
971
|
-
return o.getState().getSyncInfo(
|
|
993
|
+
const u = `${t}:${n.join(".")}`;
|
|
994
|
+
return o.getState().getSyncInfo(u);
|
|
972
995
|
}
|
|
973
996
|
if (l == "getLocalStorage")
|
|
974
|
-
return (
|
|
997
|
+
return (u) => mt(f + "-" + t + "-" + u);
|
|
975
998
|
if (l === "_selected") {
|
|
976
|
-
const
|
|
999
|
+
const u = n.slice(0, -1), e = u.join("."), r = o.getState().getNestedState(t, u);
|
|
977
1000
|
return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
|
|
978
1001
|
}
|
|
979
1002
|
if (l === "setSelected")
|
|
980
|
-
return (
|
|
1003
|
+
return (u) => {
|
|
981
1004
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), s = e.join(".");
|
|
982
|
-
|
|
1005
|
+
u ? o.getState().setSelectedIndex(t, s, r) : o.getState().setSelectedIndex(t, s, void 0);
|
|
983
1006
|
const i = o.getState().getNestedState(t, [...e]);
|
|
984
|
-
|
|
1007
|
+
at(c, i, e), p(e);
|
|
985
1008
|
};
|
|
986
1009
|
if (l === "toggleSelected")
|
|
987
1010
|
return () => {
|
|
988
|
-
const
|
|
1011
|
+
const u = n.slice(0, -1), e = Number(n[n.length - 1]), r = u.join("."), s = o.getState().getSelectedIndex(t, r);
|
|
989
1012
|
o.getState().setSelectedIndex(
|
|
990
1013
|
t,
|
|
991
1014
|
r,
|
|
992
1015
|
s === e ? void 0 : e
|
|
993
1016
|
);
|
|
994
|
-
const i = o.getState().getNestedState(t, [...
|
|
995
|
-
|
|
1017
|
+
const i = o.getState().getNestedState(t, [...u]);
|
|
1018
|
+
at(c, i, u), p(u);
|
|
996
1019
|
};
|
|
997
1020
|
if (n.length == 0) {
|
|
998
1021
|
if (l === "applyJsonPatch")
|
|
999
|
-
return (
|
|
1000
|
-
const e = o.getState().cogsStateStore[t], s = Dt(e,
|
|
1001
|
-
|
|
1022
|
+
return (u) => {
|
|
1023
|
+
const e = o.getState().cogsStateStore[t], s = Dt(e, u).newDocument;
|
|
1024
|
+
Pt(
|
|
1002
1025
|
t,
|
|
1003
1026
|
o.getState().initialStateGlobal[t],
|
|
1004
1027
|
s,
|
|
@@ -1008,35 +1031,35 @@ function ft(t, c, m, f) {
|
|
|
1008
1031
|
);
|
|
1009
1032
|
const i = o.getState().stateComponents.get(t);
|
|
1010
1033
|
if (i) {
|
|
1011
|
-
const g =
|
|
1034
|
+
const g = wt(e, s), d = new Set(g);
|
|
1012
1035
|
for (const [
|
|
1013
1036
|
T,
|
|
1014
1037
|
w
|
|
1015
1038
|
] of i.components.entries()) {
|
|
1016
|
-
let
|
|
1017
|
-
const
|
|
1018
|
-
if (!
|
|
1019
|
-
if (
|
|
1039
|
+
let b = !1;
|
|
1040
|
+
const N = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
|
|
1041
|
+
if (!N.includes("none")) {
|
|
1042
|
+
if (N.includes("all")) {
|
|
1020
1043
|
w.forceUpdate();
|
|
1021
1044
|
continue;
|
|
1022
1045
|
}
|
|
1023
|
-
if (
|
|
1024
|
-
for (const C of
|
|
1046
|
+
if (N.includes("component") && (w.paths.has("") && (b = !0), !b))
|
|
1047
|
+
for (const C of d) {
|
|
1025
1048
|
if (w.paths.has(C)) {
|
|
1026
|
-
|
|
1049
|
+
b = !0;
|
|
1027
1050
|
break;
|
|
1028
1051
|
}
|
|
1029
1052
|
let P = C.lastIndexOf(".");
|
|
1030
1053
|
for (; P !== -1; ) {
|
|
1031
1054
|
const D = C.substring(0, P);
|
|
1032
1055
|
if (w.paths.has(D)) {
|
|
1033
|
-
|
|
1056
|
+
b = !0;
|
|
1034
1057
|
break;
|
|
1035
1058
|
}
|
|
1036
|
-
const
|
|
1059
|
+
const x = C.substring(
|
|
1037
1060
|
P + 1
|
|
1038
1061
|
);
|
|
1039
|
-
if (!isNaN(Number(
|
|
1062
|
+
if (!isNaN(Number(x))) {
|
|
1040
1063
|
const _ = D.lastIndexOf(".");
|
|
1041
1064
|
if (_ !== -1) {
|
|
1042
1065
|
const E = D.substring(
|
|
@@ -1044,44 +1067,44 @@ function ft(t, c, m, f) {
|
|
|
1044
1067
|
_
|
|
1045
1068
|
);
|
|
1046
1069
|
if (w.paths.has(E)) {
|
|
1047
|
-
|
|
1070
|
+
b = !0;
|
|
1048
1071
|
break;
|
|
1049
1072
|
}
|
|
1050
1073
|
}
|
|
1051
1074
|
}
|
|
1052
1075
|
P = D.lastIndexOf(".");
|
|
1053
1076
|
}
|
|
1054
|
-
if (
|
|
1077
|
+
if (b) break;
|
|
1055
1078
|
}
|
|
1056
|
-
if (!
|
|
1079
|
+
if (!b && N.includes("deps") && w.depsFunction) {
|
|
1057
1080
|
const C = w.depsFunction(s);
|
|
1058
1081
|
let P = !1;
|
|
1059
|
-
typeof C == "boolean" ? C && (P = !0) :
|
|
1082
|
+
typeof C == "boolean" ? C && (P = !0) : Y(w.deps, C) || (w.deps = C, P = !0), P && (b = !0);
|
|
1060
1083
|
}
|
|
1061
|
-
|
|
1084
|
+
b && w.forceUpdate();
|
|
1062
1085
|
}
|
|
1063
1086
|
}
|
|
1064
1087
|
}
|
|
1065
1088
|
};
|
|
1066
1089
|
if (l === "validateZodSchema")
|
|
1067
1090
|
return () => {
|
|
1068
|
-
const
|
|
1069
|
-
if (!
|
|
1091
|
+
const u = o.getState().getInitialOptions(t)?.validation, e = o.getState().addValidationError;
|
|
1092
|
+
if (!u?.zodSchema)
|
|
1070
1093
|
throw new Error("Zod schema not found");
|
|
1071
|
-
if (!
|
|
1094
|
+
if (!u?.key)
|
|
1072
1095
|
throw new Error("Validation key not found");
|
|
1073
|
-
|
|
1096
|
+
Q(u.key);
|
|
1074
1097
|
const r = o.getState().cogsStateStore[t];
|
|
1075
1098
|
try {
|
|
1076
|
-
const s = o.getState().getValidationErrors(
|
|
1099
|
+
const s = o.getState().getValidationErrors(u.key);
|
|
1077
1100
|
s && s.length > 0 && s.forEach(([g]) => {
|
|
1078
|
-
g && g.startsWith(
|
|
1101
|
+
g && g.startsWith(u.key) && Q(g);
|
|
1079
1102
|
});
|
|
1080
|
-
const i =
|
|
1081
|
-
return i.success ? !0 : (i.error.errors.forEach((
|
|
1082
|
-
const T =
|
|
1083
|
-
e(
|
|
1084
|
-
}),
|
|
1103
|
+
const i = u.zodSchema.safeParse(r);
|
|
1104
|
+
return i.success ? !0 : (i.error.errors.forEach((d) => {
|
|
1105
|
+
const T = d.path, w = d.message, b = [u.key, ...T].join(".");
|
|
1106
|
+
e(b, w);
|
|
1107
|
+
}), ht(t), !1);
|
|
1085
1108
|
} catch (s) {
|
|
1086
1109
|
return console.error("Zod schema validation failed", s), !1;
|
|
1087
1110
|
}
|
|
@@ -1090,7 +1113,7 @@ function ft(t, c, m, f) {
|
|
|
1090
1113
|
if (l === "getComponents")
|
|
1091
1114
|
return () => o().stateComponents.get(t);
|
|
1092
1115
|
if (l === "getAllFormRefs")
|
|
1093
|
-
return () =>
|
|
1116
|
+
return () => Vt.getState().getFormRefsByStateKey(t);
|
|
1094
1117
|
if (l === "_initialState")
|
|
1095
1118
|
return o.getState().initialStateGlobal[t];
|
|
1096
1119
|
if (l === "_serverState")
|
|
@@ -1103,12 +1126,12 @@ function ft(t, c, m, f) {
|
|
|
1103
1126
|
if (l === "removeValidation") return I.removeValidation;
|
|
1104
1127
|
}
|
|
1105
1128
|
if (l === "getFormRef")
|
|
1106
|
-
return () =>
|
|
1129
|
+
return () => Vt.getState().getFormRef(t + "." + n.join("."));
|
|
1107
1130
|
if (l === "validationWrapper")
|
|
1108
1131
|
return ({
|
|
1109
|
-
children:
|
|
1132
|
+
children: u,
|
|
1110
1133
|
hideMessage: e
|
|
1111
|
-
}) => /* @__PURE__ */
|
|
1134
|
+
}) => /* @__PURE__ */ It(
|
|
1112
1135
|
Ot,
|
|
1113
1136
|
{
|
|
1114
1137
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
@@ -1116,53 +1139,53 @@ function ft(t, c, m, f) {
|
|
|
1116
1139
|
validationKey: o.getState().getInitialOptions(t)?.validation?.key || "",
|
|
1117
1140
|
stateKey: t,
|
|
1118
1141
|
validIndices: S?.validIndices,
|
|
1119
|
-
children:
|
|
1142
|
+
children: u
|
|
1120
1143
|
}
|
|
1121
1144
|
);
|
|
1122
1145
|
if (l === "_stateKey") return t;
|
|
1123
1146
|
if (l === "_path") return n;
|
|
1124
1147
|
if (l === "_isServerSynced") return I._isServerSynced;
|
|
1125
1148
|
if (l === "update")
|
|
1126
|
-
return (
|
|
1149
|
+
return (u, e) => {
|
|
1127
1150
|
if (e?.debounce)
|
|
1128
1151
|
jt(() => {
|
|
1129
|
-
|
|
1152
|
+
at(c, u, n, "");
|
|
1130
1153
|
const r = o.getState().getNestedState(t, n);
|
|
1131
1154
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1132
1155
|
}, e.debounce);
|
|
1133
1156
|
else {
|
|
1134
|
-
|
|
1157
|
+
at(c, u, n, "");
|
|
1135
1158
|
const r = o.getState().getNestedState(t, n);
|
|
1136
1159
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1137
1160
|
}
|
|
1138
1161
|
p(n);
|
|
1139
1162
|
};
|
|
1140
1163
|
if (l === "formElement")
|
|
1141
|
-
return (
|
|
1164
|
+
return (u, e) => /* @__PURE__ */ It(
|
|
1142
1165
|
Ut,
|
|
1143
1166
|
{
|
|
1144
1167
|
setState: c,
|
|
1145
1168
|
stateKey: t,
|
|
1146
1169
|
path: n,
|
|
1147
|
-
child:
|
|
1170
|
+
child: u,
|
|
1148
1171
|
formOpts: e
|
|
1149
1172
|
}
|
|
1150
1173
|
);
|
|
1151
|
-
const
|
|
1152
|
-
return a(ot,
|
|
1174
|
+
const M = [...n, l], ot = o.getState().getNestedState(t, M);
|
|
1175
|
+
return a(ot, M, S);
|
|
1153
1176
|
}
|
|
1154
|
-
},
|
|
1155
|
-
return y.set(
|
|
1156
|
-
proxy:
|
|
1157
|
-
stateVersion:
|
|
1158
|
-
}),
|
|
1177
|
+
}, B = new Proxy(j, O);
|
|
1178
|
+
return y.set(z, {
|
|
1179
|
+
proxy: B,
|
|
1180
|
+
stateVersion: k
|
|
1181
|
+
}), B;
|
|
1159
1182
|
}
|
|
1160
1183
|
return a(
|
|
1161
1184
|
o.getState().getNestedState(t, [])
|
|
1162
1185
|
);
|
|
1163
1186
|
}
|
|
1164
|
-
function
|
|
1165
|
-
return
|
|
1187
|
+
function Ct(t) {
|
|
1188
|
+
return it(Zt, { proxy: t });
|
|
1166
1189
|
}
|
|
1167
1190
|
function Yt({
|
|
1168
1191
|
proxy: t,
|
|
@@ -1173,14 +1196,14 @@ function Yt({
|
|
|
1173
1196
|
m,
|
|
1174
1197
|
t._path
|
|
1175
1198
|
).stateMapNoRender(
|
|
1176
|
-
(y,
|
|
1199
|
+
(y, k, p, I, a) => t._mapFn(y, k, p, I, a)
|
|
1177
1200
|
) : null;
|
|
1178
1201
|
}
|
|
1179
1202
|
function Zt({
|
|
1180
1203
|
proxy: t
|
|
1181
1204
|
}) {
|
|
1182
|
-
const c =
|
|
1183
|
-
return
|
|
1205
|
+
const c = X(null), m = `${t._stateKey}-${t._path.join(".")}`;
|
|
1206
|
+
return st(() => {
|
|
1184
1207
|
const f = c.current;
|
|
1185
1208
|
if (!f || !f.parentElement) return;
|
|
1186
1209
|
const y = f.parentElement, p = Array.from(y.childNodes).indexOf(f);
|
|
@@ -1201,15 +1224,15 @@ function Zt({
|
|
|
1201
1224
|
"state",
|
|
1202
1225
|
`return (${t._effect})(state)`
|
|
1203
1226
|
)(n);
|
|
1204
|
-
} catch (
|
|
1205
|
-
console.error("Error evaluating effect function during mount:",
|
|
1227
|
+
} catch (j) {
|
|
1228
|
+
console.error("Error evaluating effect function during mount:", j), S = n;
|
|
1206
1229
|
}
|
|
1207
1230
|
else
|
|
1208
1231
|
S = n;
|
|
1209
1232
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1210
|
-
const
|
|
1211
|
-
f.replaceWith(
|
|
1212
|
-
}, [t._stateKey, t._path.join("."), t._effect]),
|
|
1233
|
+
const z = document.createTextNode(String(S));
|
|
1234
|
+
f.replaceWith(z);
|
|
1235
|
+
}, [t._stateKey, t._path.join("."), t._effect]), it("span", {
|
|
1213
1236
|
ref: c,
|
|
1214
1237
|
style: { display: "none" },
|
|
1215
1238
|
"data-signal-id": m
|
|
@@ -1228,7 +1251,7 @@ function ge(t) {
|
|
|
1228
1251
|
},
|
|
1229
1252
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1230
1253
|
);
|
|
1231
|
-
return
|
|
1254
|
+
return it("text", {}, String(c));
|
|
1232
1255
|
}
|
|
1233
1256
|
function Xt({
|
|
1234
1257
|
stateKey: t,
|
|
@@ -1236,14 +1259,14 @@ function Xt({
|
|
|
1236
1259
|
itemPath: m,
|
|
1237
1260
|
children: f
|
|
1238
1261
|
}) {
|
|
1239
|
-
const [, y] =
|
|
1240
|
-
return
|
|
1262
|
+
const [, y] = et({}), [k, p] = Wt(), I = X(null);
|
|
1263
|
+
return st(() => {
|
|
1241
1264
|
p.height > 0 && p.height !== I.current && (I.current = p.height, o.getState().setShadowMetadata(t, m, {
|
|
1242
1265
|
virtualizer: {
|
|
1243
1266
|
itemHeight: p.height
|
|
1244
1267
|
}
|
|
1245
1268
|
}));
|
|
1246
|
-
}, [p.height, t, m]),
|
|
1269
|
+
}, [p.height, t, m]), gt(() => {
|
|
1247
1270
|
const a = `${t}////${c}`, v = o.getState().stateComponents.get(t) || {
|
|
1248
1271
|
components: /* @__PURE__ */ new Map()
|
|
1249
1272
|
};
|
|
@@ -1254,10 +1277,10 @@ function Xt({
|
|
|
1254
1277
|
const n = o.getState().stateComponents.get(t);
|
|
1255
1278
|
n && n.components.delete(a);
|
|
1256
1279
|
};
|
|
1257
|
-
}, [t, c, m.join(".")]), /* @__PURE__ */
|
|
1280
|
+
}, [t, c, m.join(".")]), /* @__PURE__ */ It("div", { ref: k, children: f });
|
|
1258
1281
|
}
|
|
1259
1282
|
export {
|
|
1260
|
-
|
|
1283
|
+
Ct as $cogsSignal,
|
|
1261
1284
|
ge as $cogsSignalStore,
|
|
1262
1285
|
le as addStateOptions,
|
|
1263
1286
|
de as createCogsState,
|