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