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