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