cogsbox-state 0.5.407 → 0.5.408
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 +225 -223
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +22 -17
package/dist/CogsState.jsx
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as et, useRef as Q, useEffect as nt, useLayoutEffect as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import { pushFunc as
|
|
6
|
-
import
|
|
7
|
-
import { v4 as
|
|
2
|
+
import { jsx as It } from "react/jsx-runtime";
|
|
3
|
+
import { useState as et, useRef as Q, useEffect as nt, useLayoutEffect as Et, useMemo as pt, createElement as ct, useSyncExternalStore as Ot, startTransition as Ut, useCallback as $t } from "react";
|
|
4
|
+
import { transformStateFunc as Ft, isDeepEqual as J, isFunction as K, getNestedValue as Y, getDifferences as wt, debounce as Dt } from "./utility.js";
|
|
5
|
+
import { pushFunc as yt, updateFn as it, cutFunc as gt, ValidationWrapper as Wt, FormControlComponent as Lt } from "./Functions.jsx";
|
|
6
|
+
import Gt from "superjson";
|
|
7
|
+
import { v4 as Tt } from "uuid";
|
|
8
8
|
import "zod";
|
|
9
|
-
import { getGlobalStore as o, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { applyPatch as
|
|
12
|
-
import
|
|
13
|
-
function
|
|
9
|
+
import { getGlobalStore as o, formRefStore as bt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as Pt } from "./CogsStateClient.jsx";
|
|
11
|
+
import { applyPatch as Ht } from "fast-json-patch";
|
|
12
|
+
import Bt from "react-use-measure";
|
|
13
|
+
function xt(t, c) {
|
|
14
14
|
const S = o.getState().getInitialOptions, g = o.getState().setInitialStateOptions, y = S(t) || {};
|
|
15
15
|
g(t, {
|
|
16
16
|
...y,
|
|
17
17
|
...c
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Vt({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: c,
|
|
23
23
|
initialOptionsPart: S
|
|
@@ -30,12 +30,12 @@ function bt({
|
|
|
30
30
|
!J(w[s], c[s]) && (I = !0, w[s] = c[s])) : (I = !0, w[s] = c[s]);
|
|
31
31
|
I && x(t, w);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ge(t, { formElements: c, validation: S }) {
|
|
34
34
|
return { initialState: t, formElements: c, validation: S };
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const fe = (t, c) => {
|
|
37
37
|
let S = t;
|
|
38
|
-
const [g, y] =
|
|
38
|
+
const [g, y] = Ft(S);
|
|
39
39
|
(Object.keys(y).length > 0 || c && Object.keys(c).length > 0) && Object.keys(y).forEach((I) => {
|
|
40
40
|
y[I] = y[I] || {}, y[I].formElements = {
|
|
41
41
|
...c?.formElements,
|
|
@@ -46,13 +46,13 @@ const ge = (t, c) => {
|
|
|
46
46
|
}, at(I) || o.getState().setInitialStateOptions(I, y[I]);
|
|
47
47
|
}), o.getState().setInitialStates(g), o.getState().setCreatedState(g);
|
|
48
48
|
const x = (I, s) => {
|
|
49
|
-
const [h] = et(s?.componentId ??
|
|
50
|
-
|
|
49
|
+
const [h] = et(s?.componentId ?? Tt());
|
|
50
|
+
Vt({
|
|
51
51
|
stateKey: I,
|
|
52
52
|
options: s,
|
|
53
53
|
initialOptionsPart: y
|
|
54
54
|
});
|
|
55
|
-
const r = o.getState().cogsStateStore[I] || g[I], f = s?.modifyState ? s.modifyState(r) : r, [
|
|
55
|
+
const r = o.getState().cogsStateStore[I] || g[I], f = s?.modifyState ? s.modifyState(r) : r, [H, U] = Xt(
|
|
56
56
|
f,
|
|
57
57
|
{
|
|
58
58
|
stateKey: I,
|
|
@@ -68,24 +68,24 @@ const ge = (t, c) => {
|
|
|
68
68
|
serverState: s?.serverState
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
|
-
return
|
|
71
|
+
return U;
|
|
72
72
|
};
|
|
73
73
|
function w(I, s) {
|
|
74
|
-
|
|
74
|
+
Vt({ stateKey: I, options: s, initialOptionsPart: y }), s.localStorage && Yt(I, s), lt(I);
|
|
75
75
|
}
|
|
76
76
|
return { useCogsState: x, setCogsOptions: w };
|
|
77
77
|
}, {
|
|
78
78
|
setUpdaterState: ft,
|
|
79
79
|
setState: rt,
|
|
80
80
|
getInitialOptions: at,
|
|
81
|
-
getKeyState:
|
|
82
|
-
getValidationErrors:
|
|
83
|
-
setStateLog:
|
|
84
|
-
updateInitialStateGlobal:
|
|
85
|
-
addValidationError:
|
|
81
|
+
getKeyState: _t,
|
|
82
|
+
getValidationErrors: zt,
|
|
83
|
+
setStateLog: qt,
|
|
84
|
+
updateInitialStateGlobal: At,
|
|
85
|
+
addValidationError: Mt,
|
|
86
86
|
removeValidationError: X,
|
|
87
|
-
setServerSyncActions:
|
|
88
|
-
} = o.getState(),
|
|
87
|
+
setServerSyncActions: Jt
|
|
88
|
+
} = o.getState(), Nt = (t, c, S, g, y) => {
|
|
89
89
|
S?.log && console.log(
|
|
90
90
|
"saving to localstorage",
|
|
91
91
|
c,
|
|
@@ -104,7 +104,7 @@ const ge = (t, c) => {
|
|
|
104
104
|
state: t,
|
|
105
105
|
lastUpdated: Date.now(),
|
|
106
106
|
lastSyncedWithServer: y ?? I
|
|
107
|
-
}, h =
|
|
107
|
+
}, h = Gt.serialize(s);
|
|
108
108
|
window.localStorage.setItem(
|
|
109
109
|
w,
|
|
110
110
|
JSON.stringify(h.json)
|
|
@@ -118,8 +118,8 @@ const ge = (t, c) => {
|
|
|
118
118
|
} catch (c) {
|
|
119
119
|
return console.error("Error loading from localStorage:", c), null;
|
|
120
120
|
}
|
|
121
|
-
},
|
|
122
|
-
const S = o.getState().cogsStateStore[t], { sessionId: g } =
|
|
121
|
+
}, Yt = (t, c) => {
|
|
122
|
+
const S = o.getState().cogsStateStore[t], { sessionId: g } = Pt(), y = K(c?.localStorage?.key) ? c.localStorage.key(S) : c?.localStorage?.key;
|
|
123
123
|
if (y && g) {
|
|
124
124
|
const x = mt(
|
|
125
125
|
`${g}-${t}-${y}`
|
|
@@ -128,7 +128,7 @@ const ge = (t, c) => {
|
|
|
128
128
|
return rt(t, x.state), lt(t), !0;
|
|
129
129
|
}
|
|
130
130
|
return !1;
|
|
131
|
-
},
|
|
131
|
+
}, jt = (t, c, S, g, y, x) => {
|
|
132
132
|
const w = {
|
|
133
133
|
initialState: c,
|
|
134
134
|
updaterState: St(
|
|
@@ -139,7 +139,7 @@ const ge = (t, c) => {
|
|
|
139
139
|
),
|
|
140
140
|
state: S
|
|
141
141
|
};
|
|
142
|
-
|
|
142
|
+
At(t, w.initialState), ft(t, w.updaterState), rt(t, w.state);
|
|
143
143
|
}, lt = (t) => {
|
|
144
144
|
const c = o.getState().stateComponents.get(t);
|
|
145
145
|
if (!c) return;
|
|
@@ -149,7 +149,7 @@ const ge = (t, c) => {
|
|
|
149
149
|
}), queueMicrotask(() => {
|
|
150
150
|
S.forEach((g) => g());
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, Se = (t, c) => {
|
|
153
153
|
const S = o.getState().stateComponents.get(t);
|
|
154
154
|
if (S) {
|
|
155
155
|
const g = `${t}////${c}`, y = S.components.get(g);
|
|
@@ -157,7 +157,7 @@ const ge = (t, c) => {
|
|
|
157
157
|
return;
|
|
158
158
|
y && y.forceUpdate();
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, Zt = (t, c, S, g) => {
|
|
161
161
|
switch (t) {
|
|
162
162
|
case "update":
|
|
163
163
|
return {
|
|
@@ -180,7 +180,7 @@ const ge = (t, c) => {
|
|
|
180
180
|
return { oldValue: null, newValue: null };
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function Xt(t, {
|
|
184
184
|
stateKey: c,
|
|
185
185
|
serverSync: S,
|
|
186
186
|
localStorage: g,
|
|
@@ -193,9 +193,9 @@ function Jt(t, {
|
|
|
193
193
|
dependencies: r,
|
|
194
194
|
serverState: f
|
|
195
195
|
} = {}) {
|
|
196
|
-
const [
|
|
196
|
+
const [H, U] = et({}), { sessionId: F } = Pt();
|
|
197
197
|
let B = !c;
|
|
198
|
-
const [m] = et(c ??
|
|
198
|
+
const [m] = et(c ?? Tt()), l = o.getState().stateLog[m], dt = Q(/* @__PURE__ */ new Set()), tt = Q(I ?? Tt()), j = Q(
|
|
199
199
|
null
|
|
200
200
|
);
|
|
201
201
|
j.current = at(m) ?? null, nt(() => {
|
|
@@ -212,7 +212,7 @@ function Jt(t, {
|
|
|
212
212
|
}
|
|
213
213
|
}, [h]), nt(() => {
|
|
214
214
|
if (s) {
|
|
215
|
-
|
|
215
|
+
xt(m, {
|
|
216
216
|
initialState: s
|
|
217
217
|
});
|
|
218
218
|
const e = j.current, a = e?.serverState?.id !== void 0 && e?.serverState?.status === "success" && e?.serverState?.data, i = o.getState().initialStateGlobal[m];
|
|
@@ -220,25 +220,25 @@ function Jt(t, {
|
|
|
220
220
|
return;
|
|
221
221
|
let u = null;
|
|
222
222
|
const p = K(e?.localStorage?.key) ? e?.localStorage?.key(s) : e?.localStorage?.key;
|
|
223
|
-
p &&
|
|
223
|
+
p && F && (u = mt(`${F}-${m}-${p}`));
|
|
224
224
|
let T = s, A = !1;
|
|
225
|
-
const _ = a ? Date.now() : 0,
|
|
226
|
-
a && _ >
|
|
225
|
+
const _ = a ? Date.now() : 0, $ = u?.lastUpdated || 0, M = u?.lastSyncedWithServer || 0;
|
|
226
|
+
a && _ > $ ? (T = e.serverState.data, A = !0) : u && $ > M && (T = u.state, e?.localStorage?.onChange && e?.localStorage?.onChange(T)), o.getState().initializeShadowState(m, s), jt(
|
|
227
227
|
m,
|
|
228
228
|
s,
|
|
229
229
|
T,
|
|
230
230
|
st,
|
|
231
231
|
tt.current,
|
|
232
|
-
|
|
233
|
-
), A && p &&
|
|
232
|
+
F
|
|
233
|
+
), A && p && F && Nt(T, m, e, F, Date.now()), lt(m), (Array.isArray(w) ? w : [w || "component"]).includes("none") || U({});
|
|
234
234
|
}
|
|
235
235
|
}, [
|
|
236
236
|
s,
|
|
237
237
|
f?.status,
|
|
238
238
|
f?.data,
|
|
239
239
|
...r || []
|
|
240
|
-
]),
|
|
241
|
-
B &&
|
|
240
|
+
]), Et(() => {
|
|
241
|
+
B && xt(m, {
|
|
242
242
|
serverSync: S,
|
|
243
243
|
formElements: y,
|
|
244
244
|
initialState: s,
|
|
@@ -249,12 +249,12 @@ function Jt(t, {
|
|
|
249
249
|
components: /* @__PURE__ */ new Map()
|
|
250
250
|
};
|
|
251
251
|
return n.components.set(e, {
|
|
252
|
-
forceUpdate: () =>
|
|
252
|
+
forceUpdate: () => U({}),
|
|
253
253
|
paths: /* @__PURE__ */ new Set(),
|
|
254
254
|
deps: [],
|
|
255
255
|
depsFunction: x || void 0,
|
|
256
256
|
reactiveType: w ?? ["component", "deps"]
|
|
257
|
-
}), o.getState().stateComponents.set(m, n),
|
|
257
|
+
}), o.getState().stateComponents.set(m, n), U({}), () => {
|
|
258
258
|
n && (n.components.delete(e), n.components.size === 0 && o.getState().stateComponents.delete(m));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
@@ -269,8 +269,8 @@ function Jt(t, {
|
|
|
269
269
|
if (T) {
|
|
270
270
|
let b = !1, N = v.signalDomElements.get(T);
|
|
271
271
|
if ((!N || N.size === 0) && (a.updateType === "insert" || a.updateType === "cut")) {
|
|
272
|
-
const C = n.slice(0, -1),
|
|
273
|
-
if (Array.isArray(
|
|
272
|
+
const C = n.slice(0, -1), L = Y(p, C);
|
|
273
|
+
if (Array.isArray(L)) {
|
|
274
274
|
b = !0;
|
|
275
275
|
const E = `${m}-${C.join(".")}`;
|
|
276
276
|
N = v.signalDomElements.get(E);
|
|
@@ -278,15 +278,15 @@ function Jt(t, {
|
|
|
278
278
|
}
|
|
279
279
|
if (N) {
|
|
280
280
|
const C = b ? Y(p, n.slice(0, -1)) : Y(p, n);
|
|
281
|
-
N.forEach(({ parentId:
|
|
281
|
+
N.forEach(({ parentId: L, position: E, effect: D }) => {
|
|
282
282
|
const R = document.querySelector(
|
|
283
|
-
`[data-parent-id="${
|
|
283
|
+
`[data-parent-id="${L}"]`
|
|
284
284
|
);
|
|
285
285
|
if (R) {
|
|
286
286
|
const V = Array.from(R.childNodes);
|
|
287
287
|
if (V[E]) {
|
|
288
|
-
const
|
|
289
|
-
V[E].textContent = String(
|
|
288
|
+
const k = D ? new Function("state", `return (${D})(state)`)(C) : C;
|
|
289
|
+
V[E].textContent = String(k);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
});
|
|
@@ -298,78 +298,78 @@ function Jt(t, {
|
|
|
298
298
|
const A = n.slice(0, n.length - 1);
|
|
299
299
|
a.updateType === "cut" && j.current?.validation?.key && X(
|
|
300
300
|
j.current?.validation?.key + "." + A.join(".")
|
|
301
|
-
), a.updateType === "insert" && j.current?.validation?.key &&
|
|
301
|
+
), a.updateType === "insert" && j.current?.validation?.key && zt(
|
|
302
302
|
j.current?.validation?.key + "." + A.join(".")
|
|
303
303
|
).filter(([N, C]) => {
|
|
304
|
-
let
|
|
305
|
-
if (N == A.join(".") &&
|
|
304
|
+
let L = N?.split(".").length;
|
|
305
|
+
if (N == A.join(".") && L == A.length - 1) {
|
|
306
306
|
let E = N + "." + A;
|
|
307
|
-
X(N),
|
|
307
|
+
X(N), Mt(E, C);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
const _ = v.stateComponents.get(m);
|
|
311
311
|
if (console.log("stateEntry >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", _), _) {
|
|
312
|
-
const b =
|
|
312
|
+
const b = wt(u, p), N = new Set(b), C = a.updateType === "update" ? n.join(".") : n.slice(0, -1).join(".") || "";
|
|
313
313
|
for (const [
|
|
314
|
-
|
|
314
|
+
L,
|
|
315
315
|
E
|
|
316
316
|
] of _.components.entries()) {
|
|
317
|
-
let
|
|
317
|
+
let D = !1;
|
|
318
318
|
const R = Array.isArray(E.reactiveType) ? E.reactiveType : [E.reactiveType || "component"];
|
|
319
319
|
if (console.log("component", E), !R.includes("none")) {
|
|
320
320
|
if (R.includes("all")) {
|
|
321
321
|
E.forceUpdate();
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
if (R.includes("component") && ((E.paths.has(C) || E.paths.has("")) && (
|
|
324
|
+
if (R.includes("component") && ((E.paths.has(C) || E.paths.has("")) && (D = !0), !D))
|
|
325
325
|
for (const V of N) {
|
|
326
|
-
let
|
|
326
|
+
let k = V;
|
|
327
327
|
for (; ; ) {
|
|
328
|
-
if (E.paths.has(
|
|
329
|
-
|
|
328
|
+
if (E.paths.has(k)) {
|
|
329
|
+
D = !0;
|
|
330
330
|
break;
|
|
331
331
|
}
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
const
|
|
332
|
+
const W = k.lastIndexOf(".");
|
|
333
|
+
if (W !== -1) {
|
|
334
|
+
const G = k.substring(
|
|
335
335
|
0,
|
|
336
|
-
|
|
336
|
+
W
|
|
337
337
|
);
|
|
338
338
|
if (!isNaN(
|
|
339
|
-
Number(
|
|
340
|
-
) && E.paths.has(
|
|
341
|
-
|
|
339
|
+
Number(k.substring(W + 1))
|
|
340
|
+
) && E.paths.has(G)) {
|
|
341
|
+
D = !0;
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
k = G;
|
|
345
345
|
} else
|
|
346
|
-
|
|
347
|
-
if (
|
|
346
|
+
k = "";
|
|
347
|
+
if (k === "")
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
if (
|
|
350
|
+
if (D) break;
|
|
351
351
|
}
|
|
352
|
-
if (!
|
|
352
|
+
if (!D && R.includes("deps") && E.depsFunction) {
|
|
353
353
|
const V = E.depsFunction(p);
|
|
354
|
-
let
|
|
355
|
-
typeof V == "boolean" ? V && (
|
|
354
|
+
let k = !1;
|
|
355
|
+
typeof V == "boolean" ? V && (k = !0) : J(E.deps, V) || (E.deps = V, k = !0), k && (D = !0);
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
D && E.forceUpdate();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
const
|
|
361
|
+
const $ = Date.now();
|
|
362
362
|
n = n.map((b, N) => {
|
|
363
|
-
const C = n.slice(0, -1),
|
|
364
|
-
return N === n.length - 1 && ["insert", "cut"].includes(a.updateType) ? (
|
|
363
|
+
const C = n.slice(0, -1), L = Y(p, C);
|
|
364
|
+
return N === n.length - 1 && ["insert", "cut"].includes(a.updateType) ? (L.length - 1).toString() : b;
|
|
365
365
|
});
|
|
366
|
-
const { oldValue: M, newValue: P } =
|
|
366
|
+
const { oldValue: M, newValue: P } = Zt(
|
|
367
367
|
a.updateType,
|
|
368
368
|
u,
|
|
369
369
|
p,
|
|
370
370
|
n
|
|
371
|
-
),
|
|
372
|
-
timeStamp:
|
|
371
|
+
), z = {
|
|
372
|
+
timeStamp: $,
|
|
373
373
|
stateKey: m,
|
|
374
374
|
path: n,
|
|
375
375
|
updateType: a.updateType,
|
|
@@ -390,23 +390,23 @@ function Jt(t, {
|
|
|
390
390
|
v.removeShadowArrayElement(m, N, C);
|
|
391
391
|
break;
|
|
392
392
|
}
|
|
393
|
-
if (
|
|
394
|
-
const C = [...b ?? [],
|
|
395
|
-
const
|
|
396
|
-
return R ? (R.timeStamp = Math.max(R.timeStamp, E.timeStamp), R.newValue = E.newValue, R.oldValue = R.oldValue ?? E.oldValue, R.updateType = E.updateType) :
|
|
393
|
+
if (qt(m, (b) => {
|
|
394
|
+
const C = [...b ?? [], z].reduce((L, E) => {
|
|
395
|
+
const D = `${E.stateKey}:${JSON.stringify(E.path)}`, R = L.get(D);
|
|
396
|
+
return R ? (R.timeStamp = Math.max(R.timeStamp, E.timeStamp), R.newValue = E.newValue, R.oldValue = R.oldValue ?? E.oldValue, R.updateType = E.updateType) : L.set(D, { ...E }), L;
|
|
397
397
|
}, /* @__PURE__ */ new Map());
|
|
398
398
|
return Array.from(C.values());
|
|
399
|
-
}),
|
|
399
|
+
}), Nt(
|
|
400
400
|
p,
|
|
401
401
|
m,
|
|
402
402
|
j.current,
|
|
403
|
-
|
|
403
|
+
F
|
|
404
404
|
), j.current?.middleware && j.current.middleware({
|
|
405
405
|
updateLog: l,
|
|
406
|
-
update:
|
|
406
|
+
update: z
|
|
407
407
|
}), j.current?.serverSync) {
|
|
408
408
|
const b = v.serverState[m], N = j.current?.serverSync;
|
|
409
|
-
|
|
409
|
+
Jt(m, {
|
|
410
410
|
syncKey: typeof N.syncKey == "string" ? N.syncKey : N.syncKey({ state: p }),
|
|
411
411
|
rollBackState: b,
|
|
412
412
|
actionTimeStamp: Date.now() + (N.debounce ?? 3e3),
|
|
@@ -422,16 +422,16 @@ function Jt(t, {
|
|
|
422
422
|
m,
|
|
423
423
|
st,
|
|
424
424
|
tt.current,
|
|
425
|
-
|
|
425
|
+
F
|
|
426
426
|
)
|
|
427
|
-
), o.getState().cogsStateStore[m] || rt(m, t), o.getState().initialStateGlobal[m] ||
|
|
428
|
-
const d =
|
|
427
|
+
), o.getState().cogsStateStore[m] || rt(m, t), o.getState().initialStateGlobal[m] || At(m, t));
|
|
428
|
+
const d = pt(() => St(
|
|
429
429
|
m,
|
|
430
430
|
st,
|
|
431
431
|
tt.current,
|
|
432
|
-
|
|
433
|
-
), [m,
|
|
434
|
-
return [
|
|
432
|
+
F
|
|
433
|
+
), [m, F]);
|
|
434
|
+
return [_t(m), d];
|
|
435
435
|
}
|
|
436
436
|
function St(t, c, S, g) {
|
|
437
437
|
const y = /* @__PURE__ */ new Map();
|
|
@@ -450,8 +450,8 @@ function St(t, c, S, g) {
|
|
|
450
450
|
r?.key && X(r?.key), h?.validationKey && X(h.validationKey);
|
|
451
451
|
const f = o.getState().initialStateGlobal[t];
|
|
452
452
|
o.getState().clearSelectedIndexesForState(t), y.clear(), x++;
|
|
453
|
-
const
|
|
454
|
-
B && localStorage.removeItem(B), ft(t,
|
|
453
|
+
const H = s(f, []), U = at(t), F = K(U?.localStorage?.key) ? U?.localStorage?.key(f) : U?.localStorage?.key, B = `${g}-${t}-${F}`;
|
|
454
|
+
B && localStorage.removeItem(B), ft(t, H), rt(t, f);
|
|
455
455
|
const m = o.getState().stateComponents.get(t);
|
|
456
456
|
return m && m.components.forEach((l) => {
|
|
457
457
|
l.forceUpdate();
|
|
@@ -464,9 +464,9 @@ function St(t, c, S, g) {
|
|
|
464
464
|
c,
|
|
465
465
|
S,
|
|
466
466
|
g
|
|
467
|
-
), f = o.getState().initialStateGlobal[t],
|
|
468
|
-
return localStorage.getItem(
|
|
469
|
-
|
|
467
|
+
), f = o.getState().initialStateGlobal[t], H = at(t), U = K(H?.localStorage?.key) ? H?.localStorage?.key(f) : H?.localStorage?.key, F = `${g}-${t}-${U}`;
|
|
468
|
+
return localStorage.getItem(F) && localStorage.removeItem(F), Ut(() => {
|
|
469
|
+
At(t, h), o.getState().initializeShadowState(t, h), ft(t, r), rt(t, h);
|
|
470
470
|
const B = o.getState().stateComponents.get(t);
|
|
471
471
|
B && B.components.forEach((m) => {
|
|
472
472
|
m.forceUpdate();
|
|
@@ -480,19 +480,19 @@ function St(t, c, S, g) {
|
|
|
480
480
|
_isLoading: o.getState().isLoadingGlobal[t],
|
|
481
481
|
_isServerSynced: () => {
|
|
482
482
|
const h = o.getState().serverState[t];
|
|
483
|
-
return !!(h && J(h,
|
|
483
|
+
return !!(h && J(h, _t(t)));
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
function s(h, r = [], f) {
|
|
487
|
-
const
|
|
488
|
-
y.get(
|
|
489
|
-
const
|
|
487
|
+
const H = r.map(String).join(".");
|
|
488
|
+
y.get(H);
|
|
489
|
+
const U = function() {
|
|
490
490
|
return o().getNestedState(t, r);
|
|
491
491
|
};
|
|
492
492
|
Object.keys(I).forEach((m) => {
|
|
493
|
-
|
|
493
|
+
U[m] = I[m];
|
|
494
494
|
});
|
|
495
|
-
const
|
|
495
|
+
const F = {
|
|
496
496
|
apply(m, l, dt) {
|
|
497
497
|
return console.log(
|
|
498
498
|
`PROXY APPLY TRAP HIT: stateKey=${t}, path=${r.join(".")}`
|
|
@@ -540,7 +540,7 @@ function St(t, c, S, g) {
|
|
|
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
|
);
|
|
@@ -625,112 +625,114 @@ function St(t, c, S, g) {
|
|
|
625
625
|
} = e, u = Q(null), [p, T] = et({
|
|
626
626
|
startIndex: 0,
|
|
627
627
|
endIndex: 10
|
|
628
|
-
}), [A, _] = et(0),
|
|
628
|
+
}), [A, _] = et(0), $ = Q(!1), M = Q(!0), P = Q(
|
|
629
629
|
null
|
|
630
630
|
);
|
|
631
631
|
nt(() => o.getState().subscribeToShadowState(t, () => {
|
|
632
|
-
_((
|
|
632
|
+
_((k) => k + 1);
|
|
633
633
|
}), [t]);
|
|
634
|
-
const
|
|
634
|
+
const z = o().getNestedState(
|
|
635
635
|
t,
|
|
636
636
|
r
|
|
637
|
-
), b =
|
|
637
|
+
), b = z.length, { totalHeight: N, positions: C } = pt(() => {
|
|
638
638
|
const V = o.getState().getShadowMetadata(t, r) || [];
|
|
639
|
-
let
|
|
640
|
-
const
|
|
641
|
-
for (let
|
|
642
|
-
|
|
643
|
-
const Z = V[
|
|
644
|
-
|
|
639
|
+
let k = 0;
|
|
640
|
+
const W = [];
|
|
641
|
+
for (let G = 0; G < b; G++) {
|
|
642
|
+
W[G] = k;
|
|
643
|
+
const Z = V[G]?.virtualizer?.itemHeight;
|
|
644
|
+
k += Z || n;
|
|
645
645
|
}
|
|
646
|
-
return { totalHeight:
|
|
646
|
+
return { totalHeight: k, positions: W };
|
|
647
647
|
}, [
|
|
648
648
|
b,
|
|
649
649
|
t,
|
|
650
650
|
r.join("."),
|
|
651
651
|
n,
|
|
652
652
|
A
|
|
653
|
-
]),
|
|
654
|
-
const V = Math.max(0, p.startIndex),
|
|
655
|
-
{ length:
|
|
656
|
-
(Z,
|
|
657
|
-
),
|
|
658
|
-
return s(
|
|
653
|
+
]), L = pt(() => {
|
|
654
|
+
const V = Math.max(0, p.startIndex), k = Math.min(b, p.endIndex), W = Array.from(
|
|
655
|
+
{ length: k - V },
|
|
656
|
+
(Z, O) => V + O
|
|
657
|
+
), G = W.map((Z) => z[Z]);
|
|
658
|
+
return s(G, r, {
|
|
659
659
|
...f,
|
|
660
|
-
validIndices:
|
|
660
|
+
validIndices: W
|
|
661
661
|
});
|
|
662
|
-
}, [p.startIndex, p.endIndex,
|
|
662
|
+
}, [p.startIndex, p.endIndex, z, b]);
|
|
663
663
|
nt(() => {
|
|
664
664
|
if (!i || !u.current || b === 0 || !M.current) return;
|
|
665
665
|
P.current && clearInterval(P.current);
|
|
666
|
-
const V = 50,
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
const
|
|
666
|
+
const V = 50, k = p.endIndex < V, W = b > p.endIndex + V;
|
|
667
|
+
if (k || W) {
|
|
668
|
+
$.current = !0;
|
|
669
|
+
const O = {
|
|
670
670
|
startIndex: Math.max(0, b - 20),
|
|
671
671
|
endIndex: b
|
|
672
672
|
};
|
|
673
|
-
T(
|
|
674
|
-
|
|
673
|
+
T(O), setTimeout(() => {
|
|
674
|
+
$.current = !1;
|
|
675
675
|
}, 100);
|
|
676
676
|
}
|
|
677
|
-
let
|
|
677
|
+
let G = 0;
|
|
678
678
|
const Z = 50;
|
|
679
679
|
return P.current = setInterval(() => {
|
|
680
|
-
const
|
|
681
|
-
if (!
|
|
682
|
-
|
|
683
|
-
const { scrollTop:
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
680
|
+
const O = u.current;
|
|
681
|
+
if (!O) return;
|
|
682
|
+
G++;
|
|
683
|
+
const { scrollTop: ht, scrollHeight: ot, clientHeight: ut } = O, vt = ht + ut, kt = ot - vt < 50;
|
|
684
|
+
if (kt || G >= Z)
|
|
685
|
+
clearInterval(P.current), P.current = null, kt && O.scrollTop < O.scrollHeight - O.clientHeight && (O.scrollTop = O.scrollHeight);
|
|
686
|
+
else {
|
|
687
|
+
const Rt = O.scrollHeight - O.clientHeight;
|
|
688
|
+
Math.abs(O.scrollTop - Rt) > 1 && (O.scrollTop = O.scrollHeight);
|
|
689
|
+
}
|
|
687
690
|
}, 100), () => {
|
|
688
691
|
P.current && (clearInterval(P.current), P.current = null);
|
|
689
692
|
};
|
|
690
693
|
}, [b, i, p.startIndex, p.endIndex]), nt(() => {
|
|
691
694
|
const V = u.current;
|
|
692
695
|
if (!V) return;
|
|
693
|
-
const
|
|
694
|
-
if (
|
|
696
|
+
const k = () => {
|
|
697
|
+
if ($.current)
|
|
695
698
|
return;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
M.current = q;
|
|
699
|
+
const { scrollTop: W, scrollHeight: G, clientHeight: Z } = V, ht = G - W - Z < 50;
|
|
700
|
+
P.current && (clearInterval(P.current), P.current = null), M.current = ht;
|
|
699
701
|
let ot = 0;
|
|
700
|
-
for (let
|
|
701
|
-
if (C[
|
|
702
|
-
ot = Math.max(0,
|
|
702
|
+
for (let q = 0; q < C.length; q++)
|
|
703
|
+
if (C[q] > W - n * a) {
|
|
704
|
+
ot = Math.max(0, q - 1);
|
|
703
705
|
break;
|
|
704
706
|
}
|
|
705
707
|
let ut = ot;
|
|
706
|
-
const
|
|
707
|
-
for (let
|
|
708
|
-
ut =
|
|
708
|
+
const vt = W + Z;
|
|
709
|
+
for (let q = ot; q < C.length && !(C[q] > vt + n * a); q++)
|
|
710
|
+
ut = q;
|
|
709
711
|
T({
|
|
710
712
|
startIndex: Math.max(0, ot),
|
|
711
713
|
endIndex: Math.min(b, ut + 1 + a)
|
|
712
714
|
});
|
|
713
715
|
};
|
|
714
|
-
return V.addEventListener("scroll",
|
|
716
|
+
return V.addEventListener("scroll", k, {
|
|
715
717
|
passive: !0
|
|
716
|
-
}),
|
|
717
|
-
V.removeEventListener("scroll",
|
|
718
|
+
}), k(), () => {
|
|
719
|
+
V.removeEventListener("scroll", k);
|
|
718
720
|
};
|
|
719
721
|
}, [C, b, n, a]);
|
|
720
|
-
const E =
|
|
722
|
+
const E = $t(
|
|
721
723
|
(V = "auto") => {
|
|
722
|
-
M.current = !0,
|
|
723
|
-
|
|
724
|
+
M.current = !0, $.current = !0, u.current && (u.current.scrollTop = u.current.scrollHeight), setTimeout(() => {
|
|
725
|
+
$.current = !1;
|
|
724
726
|
}, 100);
|
|
725
727
|
},
|
|
726
728
|
[]
|
|
727
|
-
),
|
|
728
|
-
(V,
|
|
729
|
-
|
|
729
|
+
), D = $t(
|
|
730
|
+
(V, k = "smooth") => {
|
|
731
|
+
$.current = !0, u.current && C[V] !== void 0 && u.current.scrollTo({
|
|
730
732
|
top: C[V],
|
|
731
|
-
behavior:
|
|
733
|
+
behavior: k
|
|
732
734
|
}), setTimeout(() => {
|
|
733
|
-
|
|
735
|
+
$.current = !1;
|
|
734
736
|
}, 100);
|
|
735
737
|
},
|
|
736
738
|
[C]
|
|
@@ -752,10 +754,10 @@ function St(t, c, S, g) {
|
|
|
752
754
|
}
|
|
753
755
|
};
|
|
754
756
|
return {
|
|
755
|
-
virtualState:
|
|
757
|
+
virtualState: L,
|
|
756
758
|
virtualizerProps: R,
|
|
757
759
|
scrollToBottom: E,
|
|
758
|
-
scrollToIndex:
|
|
760
|
+
scrollToIndex: D
|
|
759
761
|
};
|
|
760
762
|
};
|
|
761
763
|
if (l === "stateSort")
|
|
@@ -789,19 +791,19 @@ function St(t, c, S, g) {
|
|
|
789
791
|
const u = n[i], p = [...r, i.toString()], T = s(u, p, f);
|
|
790
792
|
return e(u, T, {
|
|
791
793
|
register: () => {
|
|
792
|
-
const [, _] = et({}),
|
|
793
|
-
|
|
794
|
-
const M = `${t}////${
|
|
794
|
+
const [, _] = et({}), $ = `${S}-${r.join(".")}-${i}`;
|
|
795
|
+
Et(() => {
|
|
796
|
+
const M = `${t}////${$}`, P = o.getState().stateComponents.get(t) || {
|
|
795
797
|
components: /* @__PURE__ */ new Map()
|
|
796
798
|
};
|
|
797
799
|
return P.components.set(M, {
|
|
798
800
|
forceUpdate: () => _({}),
|
|
799
801
|
paths: /* @__PURE__ */ new Set([p.join(".")])
|
|
800
802
|
}), o.getState().stateComponents.set(t, P), () => {
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
+
const z = o.getState().stateComponents.get(t);
|
|
804
|
+
z && z.components.delete(M);
|
|
803
805
|
};
|
|
804
|
-
}, [t,
|
|
806
|
+
}, [t, $]);
|
|
805
807
|
},
|
|
806
808
|
index: v,
|
|
807
809
|
originalIndex: i
|
|
@@ -825,7 +827,7 @@ function St(t, c, S, g) {
|
|
|
825
827
|
);
|
|
826
828
|
});
|
|
827
829
|
if (l === "$stateMap")
|
|
828
|
-
return (e) => ct(
|
|
830
|
+
return (e) => ct(Qt, {
|
|
829
831
|
proxy: {
|
|
830
832
|
_stateKey: t,
|
|
831
833
|
_path: r,
|
|
@@ -839,7 +841,7 @@ function St(t, c, S, g) {
|
|
|
839
841
|
const n = o.getState().getNestedState(t, r);
|
|
840
842
|
return Array.isArray(n) ? (f?.validIndices || Array.from({ length: n.length }, (i, v) => v)).map((i, v) => {
|
|
841
843
|
const u = n[i], p = [...r, i.toString()], T = s(u, p, f), A = `${S}-${r.join(".")}-${i}`;
|
|
842
|
-
return ct(
|
|
844
|
+
return ct(te, {
|
|
843
845
|
key: i,
|
|
844
846
|
stateKey: t,
|
|
845
847
|
itemComponentId: A,
|
|
@@ -882,7 +884,7 @@ function St(t, c, S, g) {
|
|
|
882
884
|
return s(a, i);
|
|
883
885
|
};
|
|
884
886
|
if (l === "insert")
|
|
885
|
-
return (e) => (w(r),
|
|
887
|
+
return (e) => (w(r), yt(c, e, r, t), s(
|
|
886
888
|
o.getState().getNestedState(t, r),
|
|
887
889
|
r
|
|
888
890
|
));
|
|
@@ -893,14 +895,14 @@ function St(t, c, S, g) {
|
|
|
893
895
|
if (!i.some((T) => {
|
|
894
896
|
if (n) {
|
|
895
897
|
const _ = n.every(
|
|
896
|
-
(
|
|
898
|
+
($) => J(T[$], v[$])
|
|
897
899
|
);
|
|
898
900
|
return _ && (u = T), _;
|
|
899
901
|
}
|
|
900
902
|
const A = J(T, v);
|
|
901
903
|
return A && (u = T), A;
|
|
902
904
|
}))
|
|
903
|
-
w(r),
|
|
905
|
+
w(r), yt(c, v, r, t);
|
|
904
906
|
else if (a && u) {
|
|
905
907
|
const T = a(u), A = i.map(
|
|
906
908
|
(_) => J(_, u) ? T : _
|
|
@@ -924,7 +926,7 @@ function St(t, c, S, g) {
|
|
|
924
926
|
if (l === "toggleByValue")
|
|
925
927
|
return (e) => {
|
|
926
928
|
const n = h.findIndex((a) => a === e);
|
|
927
|
-
n > -1 ? gt(c, r, t, n) :
|
|
929
|
+
n > -1 ? gt(c, r, t, n) : yt(c, e, r, t);
|
|
928
930
|
};
|
|
929
931
|
if (l === "stateFind")
|
|
930
932
|
return (e) => {
|
|
@@ -965,13 +967,13 @@ function St(t, c, S, g) {
|
|
|
965
967
|
return o.getState().getNestedState(t, r);
|
|
966
968
|
};
|
|
967
969
|
if (l === "$derive")
|
|
968
|
-
return (d) =>
|
|
970
|
+
return (d) => Ct({
|
|
969
971
|
_stateKey: t,
|
|
970
972
|
_path: r,
|
|
971
973
|
_effect: d.toString()
|
|
972
974
|
});
|
|
973
975
|
if (l === "$get")
|
|
974
|
-
return () =>
|
|
976
|
+
return () => Ct({
|
|
975
977
|
_stateKey: t,
|
|
976
978
|
_path: r
|
|
977
979
|
});
|
|
@@ -1011,13 +1013,13 @@ function St(t, c, S, g) {
|
|
|
1011
1013
|
throw new Error("Validation key not found");
|
|
1012
1014
|
X(e.key), console.log("addValidationError", d), d.forEach((n) => {
|
|
1013
1015
|
const a = [e.key, ...n.path].join(".");
|
|
1014
|
-
console.log("fullErrorPath", a),
|
|
1016
|
+
console.log("fullErrorPath", a), Mt(a, n.message);
|
|
1015
1017
|
}), lt(t);
|
|
1016
1018
|
};
|
|
1017
1019
|
if (l === "applyJsonPatch")
|
|
1018
1020
|
return (d) => {
|
|
1019
|
-
const e = o.getState().cogsStateStore[t], a =
|
|
1020
|
-
|
|
1021
|
+
const e = o.getState().cogsStateStore[t], a = Ht(e, d).newDocument;
|
|
1022
|
+
jt(
|
|
1021
1023
|
t,
|
|
1022
1024
|
o.getState().initialStateGlobal[t],
|
|
1023
1025
|
a,
|
|
@@ -1027,7 +1029,7 @@ function St(t, c, S, g) {
|
|
|
1027
1029
|
);
|
|
1028
1030
|
const i = o.getState().stateComponents.get(t);
|
|
1029
1031
|
if (i) {
|
|
1030
|
-
const v =
|
|
1032
|
+
const v = wt(e, a), u = new Set(v);
|
|
1031
1033
|
for (const [
|
|
1032
1034
|
p,
|
|
1033
1035
|
T
|
|
@@ -1040,22 +1042,22 @@ function St(t, c, S, g) {
|
|
|
1040
1042
|
continue;
|
|
1041
1043
|
}
|
|
1042
1044
|
if (_.includes("component") && (T.paths.has("") && (A = !0), !A))
|
|
1043
|
-
for (const
|
|
1044
|
-
if (T.paths.has(
|
|
1045
|
+
for (const $ of u) {
|
|
1046
|
+
if (T.paths.has($)) {
|
|
1045
1047
|
A = !0;
|
|
1046
1048
|
break;
|
|
1047
1049
|
}
|
|
1048
|
-
let M =
|
|
1050
|
+
let M = $.lastIndexOf(".");
|
|
1049
1051
|
for (; M !== -1; ) {
|
|
1050
|
-
const P =
|
|
1052
|
+
const P = $.substring(0, M);
|
|
1051
1053
|
if (T.paths.has(P)) {
|
|
1052
1054
|
A = !0;
|
|
1053
1055
|
break;
|
|
1054
1056
|
}
|
|
1055
|
-
const
|
|
1057
|
+
const z = $.substring(
|
|
1056
1058
|
M + 1
|
|
1057
1059
|
);
|
|
1058
|
-
if (!isNaN(Number(
|
|
1060
|
+
if (!isNaN(Number(z))) {
|
|
1059
1061
|
const b = P.lastIndexOf(".");
|
|
1060
1062
|
if (b !== -1) {
|
|
1061
1063
|
const N = P.substring(
|
|
@@ -1073,9 +1075,9 @@ function St(t, c, S, g) {
|
|
|
1073
1075
|
if (A) break;
|
|
1074
1076
|
}
|
|
1075
1077
|
if (!A && _.includes("deps") && T.depsFunction) {
|
|
1076
|
-
const
|
|
1078
|
+
const $ = T.depsFunction(a);
|
|
1077
1079
|
let M = !1;
|
|
1078
|
-
typeof
|
|
1080
|
+
typeof $ == "boolean" ? $ && (M = !0) : J(T.deps, $) || (T.deps = $, M = !0), M && (A = !0);
|
|
1079
1081
|
}
|
|
1080
1082
|
A && T.forceUpdate();
|
|
1081
1083
|
}
|
|
@@ -1109,7 +1111,7 @@ function St(t, c, S, g) {
|
|
|
1109
1111
|
if (l === "getComponents")
|
|
1110
1112
|
return () => o().stateComponents.get(t);
|
|
1111
1113
|
if (l === "getAllFormRefs")
|
|
1112
|
-
return () =>
|
|
1114
|
+
return () => bt.getState().getFormRefsByStateKey(t);
|
|
1113
1115
|
if (l === "_initialState")
|
|
1114
1116
|
return o.getState().initialStateGlobal[t];
|
|
1115
1117
|
if (l === "_serverState")
|
|
@@ -1122,13 +1124,13 @@ function St(t, c, S, g) {
|
|
|
1122
1124
|
if (l === "removeValidation") return I.removeValidation;
|
|
1123
1125
|
}
|
|
1124
1126
|
if (l === "getFormRef")
|
|
1125
|
-
return () =>
|
|
1127
|
+
return () => bt.getState().getFormRef(t + "." + r.join("."));
|
|
1126
1128
|
if (l === "validationWrapper")
|
|
1127
1129
|
return ({
|
|
1128
1130
|
children: d,
|
|
1129
1131
|
hideMessage: e
|
|
1130
|
-
}) => /* @__PURE__ */
|
|
1131
|
-
|
|
1132
|
+
}) => /* @__PURE__ */ It(
|
|
1133
|
+
Wt,
|
|
1132
1134
|
{
|
|
1133
1135
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1134
1136
|
path: r,
|
|
@@ -1144,7 +1146,7 @@ function St(t, c, S, g) {
|
|
|
1144
1146
|
if (l === "update")
|
|
1145
1147
|
return (d, e) => {
|
|
1146
1148
|
if (e?.debounce)
|
|
1147
|
-
|
|
1149
|
+
Dt(() => {
|
|
1148
1150
|
it(c, d, r, "");
|
|
1149
1151
|
const n = o.getState().getNestedState(t, r);
|
|
1150
1152
|
e?.afterUpdate && e.afterUpdate(n);
|
|
@@ -1157,8 +1159,8 @@ function St(t, c, S, g) {
|
|
|
1157
1159
|
w(r);
|
|
1158
1160
|
};
|
|
1159
1161
|
if (l === "formElement")
|
|
1160
|
-
return (d, e) => /* @__PURE__ */
|
|
1161
|
-
|
|
1162
|
+
return (d, e) => /* @__PURE__ */ It(
|
|
1163
|
+
Lt,
|
|
1162
1164
|
{
|
|
1163
1165
|
setState: c,
|
|
1164
1166
|
stateKey: t,
|
|
@@ -1170,8 +1172,8 @@ function St(t, c, S, g) {
|
|
|
1170
1172
|
const j = [...r, l], st = o.getState().getNestedState(t, j);
|
|
1171
1173
|
return s(st, j, f);
|
|
1172
1174
|
}
|
|
1173
|
-
}, B = new Proxy(
|
|
1174
|
-
return y.set(
|
|
1175
|
+
}, B = new Proxy(U, F);
|
|
1176
|
+
return y.set(H, {
|
|
1175
1177
|
proxy: B,
|
|
1176
1178
|
stateVersion: x
|
|
1177
1179
|
}), B;
|
|
@@ -1180,10 +1182,10 @@ function St(t, c, S, g) {
|
|
|
1180
1182
|
o.getState().getNestedState(t, [])
|
|
1181
1183
|
);
|
|
1182
1184
|
}
|
|
1183
|
-
function
|
|
1184
|
-
return ct(
|
|
1185
|
+
function Ct(t) {
|
|
1186
|
+
return ct(Kt, { proxy: t });
|
|
1185
1187
|
}
|
|
1186
|
-
function
|
|
1188
|
+
function Qt({
|
|
1187
1189
|
proxy: t,
|
|
1188
1190
|
rebuildStateShape: c
|
|
1189
1191
|
}) {
|
|
@@ -1195,7 +1197,7 @@ function Yt({
|
|
|
1195
1197
|
(y, x, w, I, s) => t._mapFn(y, x, w, I, s)
|
|
1196
1198
|
) : null;
|
|
1197
1199
|
}
|
|
1198
|
-
function
|
|
1200
|
+
function Kt({
|
|
1199
1201
|
proxy: t
|
|
1200
1202
|
}) {
|
|
1201
1203
|
const c = Q(null), S = `${t._stateKey}-${t._path.join(".")}`;
|
|
@@ -1220,22 +1222,22 @@ function Zt({
|
|
|
1220
1222
|
"state",
|
|
1221
1223
|
`return (${t._effect})(state)`
|
|
1222
1224
|
)(r);
|
|
1223
|
-
} catch (
|
|
1224
|
-
console.error("Error evaluating effect function during mount:",
|
|
1225
|
+
} catch (U) {
|
|
1226
|
+
console.error("Error evaluating effect function during mount:", U), f = r;
|
|
1225
1227
|
}
|
|
1226
1228
|
else
|
|
1227
1229
|
f = r;
|
|
1228
1230
|
f !== null && typeof f == "object" && (f = JSON.stringify(f));
|
|
1229
|
-
const
|
|
1230
|
-
g.replaceWith(
|
|
1231
|
+
const H = document.createTextNode(String(f));
|
|
1232
|
+
g.replaceWith(H);
|
|
1231
1233
|
}, [t._stateKey, t._path.join("."), t._effect]), ct("span", {
|
|
1232
1234
|
ref: c,
|
|
1233
1235
|
style: { display: "none" },
|
|
1234
1236
|
"data-signal-id": S
|
|
1235
1237
|
});
|
|
1236
1238
|
}
|
|
1237
|
-
function
|
|
1238
|
-
const c =
|
|
1239
|
+
function me(t) {
|
|
1240
|
+
const c = Ot(
|
|
1239
1241
|
(S) => {
|
|
1240
1242
|
const g = o.getState().stateComponents.get(t._stateKey) || {
|
|
1241
1243
|
components: /* @__PURE__ */ new Map()
|
|
@@ -1249,20 +1251,20 @@ function Se(t) {
|
|
|
1249
1251
|
);
|
|
1250
1252
|
return ct("text", {}, String(c));
|
|
1251
1253
|
}
|
|
1252
|
-
function
|
|
1254
|
+
function te({
|
|
1253
1255
|
stateKey: t,
|
|
1254
1256
|
itemComponentId: c,
|
|
1255
1257
|
itemPath: S,
|
|
1256
1258
|
children: g
|
|
1257
1259
|
}) {
|
|
1258
|
-
const [, y] = et({}), [x, w] =
|
|
1260
|
+
const [, y] = et({}), [x, w] = Bt(), I = Q(null);
|
|
1259
1261
|
return nt(() => {
|
|
1260
1262
|
w.height > 0 && w.height !== I.current && (I.current = w.height, o.getState().setShadowMetadata(t, S, {
|
|
1261
1263
|
virtualizer: {
|
|
1262
1264
|
itemHeight: w.height
|
|
1263
1265
|
}
|
|
1264
1266
|
}));
|
|
1265
|
-
}, [w.height, t, S]),
|
|
1267
|
+
}, [w.height, t, S]), Et(() => {
|
|
1266
1268
|
const s = `${t}////${c}`, h = o.getState().stateComponents.get(t) || {
|
|
1267
1269
|
components: /* @__PURE__ */ new Map()
|
|
1268
1270
|
};
|
|
@@ -1273,14 +1275,14 @@ function Xt({
|
|
|
1273
1275
|
const r = o.getState().stateComponents.get(t);
|
|
1274
1276
|
r && r.components.delete(s);
|
|
1275
1277
|
};
|
|
1276
|
-
}, [t, c, S.join(".")]), /* @__PURE__ */
|
|
1278
|
+
}, [t, c, S.join(".")]), /* @__PURE__ */ It("div", { ref: x, children: g });
|
|
1277
1279
|
}
|
|
1278
1280
|
export {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1281
|
+
Ct as $cogsSignal,
|
|
1282
|
+
me as $cogsSignalStore,
|
|
1283
|
+
ge as addStateOptions,
|
|
1284
|
+
fe as createCogsState,
|
|
1285
|
+
Se as notifyComponent,
|
|
1286
|
+
Xt as useCogsStateFn
|
|
1285
1287
|
};
|
|
1286
1288
|
//# sourceMappingURL=CogsState.jsx.map
|