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