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