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