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