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