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