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