cogsbox-state 0.5.284 → 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 -499
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +54 -69
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,120 +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().getNestedState(
|
|
633
|
-
t,
|
|
634
|
-
n
|
|
635
|
-
);
|
|
636
|
-
let b = 0;
|
|
637
|
-
const G = [];
|
|
638
|
-
for (let z = 0; z < $.length; z++)
|
|
639
|
-
G[z] = b, b += w(z);
|
|
640
|
-
return { totalHeight: b, positions: G };
|
|
641
|
-
}, [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(
|
|
642
629
|
t,
|
|
643
630
|
n
|
|
644
|
-
),
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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, {
|
|
650
646
|
...S,
|
|
651
|
-
validIndices:
|
|
647
|
+
validIndices: _
|
|
652
648
|
});
|
|
653
|
-
}, [u.startIndex, u.endIndex,
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
if (
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
const
|
|
660
|
-
const { scrollTop:
|
|
661
|
-
|
|
662
|
-
let
|
|
663
|
-
for (;
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
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);
|
|
673
668
|
};
|
|
674
|
-
return
|
|
669
|
+
return E.addEventListener("scroll", M, {
|
|
675
670
|
passive: !0
|
|
676
|
-
}), i && (
|
|
677
|
-
top:
|
|
671
|
+
}), i && (P.current ? E.scrollTo({
|
|
672
|
+
top: E.scrollHeight,
|
|
678
673
|
behavior: "auto"
|
|
679
|
-
}) :
|
|
680
|
-
|
|
681
|
-
top:
|
|
674
|
+
}) : V && _ && requestAnimationFrame(() => {
|
|
675
|
+
E.scrollTo({
|
|
676
|
+
top: E.scrollHeight,
|
|
682
677
|
behavior: "smooth"
|
|
683
678
|
});
|
|
684
|
-
})),
|
|
685
|
-
}, [
|
|
686
|
-
const
|
|
687
|
-
(
|
|
679
|
+
})), P.current = !1, M(), () => E.removeEventListener("scroll", M);
|
|
680
|
+
}, [b, s, i, C]);
|
|
681
|
+
const O = mt(
|
|
682
|
+
(E = "smooth") => {
|
|
688
683
|
g.current && g.current.scrollTo({
|
|
689
684
|
top: g.current.scrollHeight,
|
|
690
|
-
behavior:
|
|
685
|
+
behavior: E
|
|
691
686
|
});
|
|
692
687
|
},
|
|
693
688
|
[]
|
|
694
|
-
),
|
|
695
|
-
(
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
behavior: b
|
|
701
|
-
});
|
|
702
|
-
}
|
|
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
|
+
});
|
|
703
695
|
},
|
|
704
|
-
[
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
positions: T
|
|
708
|
-
} = A(), F = T[u.startIndex] || 0, j = {
|
|
696
|
+
[C]
|
|
697
|
+
// Depends on the calculated positions
|
|
698
|
+
), $ = {
|
|
709
699
|
outer: {
|
|
710
700
|
ref: g,
|
|
711
701
|
style: { overflowY: "auto", height: "100%" }
|
|
712
702
|
},
|
|
713
703
|
inner: {
|
|
714
704
|
style: {
|
|
715
|
-
height: `${
|
|
705
|
+
height: `${B}px`,
|
|
716
706
|
position: "relative"
|
|
717
707
|
}
|
|
718
708
|
},
|
|
719
709
|
list: {
|
|
720
710
|
style: {
|
|
721
|
-
transform: `translateY(${
|
|
711
|
+
transform: `translateY(${C[u.startIndex] || 0}px)`
|
|
722
712
|
}
|
|
723
713
|
}
|
|
724
714
|
};
|
|
725
715
|
return {
|
|
726
|
-
virtualState:
|
|
727
|
-
virtualizerProps:
|
|
728
|
-
scrollToBottom:
|
|
729
|
-
scrollToIndex:
|
|
716
|
+
virtualState: N,
|
|
717
|
+
virtualizerProps: $,
|
|
718
|
+
scrollToBottom: O,
|
|
719
|
+
scrollToIndex: D
|
|
730
720
|
};
|
|
731
721
|
};
|
|
732
722
|
if (l === "stateSort")
|
|
733
723
|
return (e) => {
|
|
734
724
|
const s = [...d()].sort(
|
|
735
|
-
(u,
|
|
725
|
+
(u, A) => e(u.item, A.item)
|
|
736
726
|
), i = s.map(({ item: u }) => u), g = {
|
|
737
727
|
...S,
|
|
738
728
|
validIndices: s.map(
|
|
@@ -744,7 +734,7 @@ function mt(t, c, h, f) {
|
|
|
744
734
|
if (l === "stateFilter")
|
|
745
735
|
return (e) => {
|
|
746
736
|
const s = d().filter(
|
|
747
|
-
({ item: u },
|
|
737
|
+
({ item: u }, A) => e(u, A)
|
|
748
738
|
), i = s.map(({ item: u }) => u), g = {
|
|
749
739
|
...S,
|
|
750
740
|
validIndices: s.map(
|
|
@@ -757,22 +747,22 @@ function mt(t, c, h, f) {
|
|
|
757
747
|
return (e) => {
|
|
758
748
|
const r = o.getState().getNestedState(t, n);
|
|
759
749
|
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
|
|
760
|
-
const u = r[i],
|
|
750
|
+
const u = r[i], A = [...n, i.toString()], w = a(u, A, S);
|
|
761
751
|
return e(u, w, {
|
|
762
752
|
register: () => {
|
|
763
|
-
const [,
|
|
764
|
-
|
|
765
|
-
const
|
|
753
|
+
const [, P] = rt({}), x = `${v}-${n.join(".")}-${i}`;
|
|
754
|
+
dt(() => {
|
|
755
|
+
const b = `${t}////${x}`, U = o.getState().stateComponents.get(t) || {
|
|
766
756
|
components: /* @__PURE__ */ new Map()
|
|
767
757
|
};
|
|
768
|
-
return U.components.set(
|
|
769
|
-
forceUpdate: () =>
|
|
770
|
-
paths: /* @__PURE__ */ new Set([
|
|
758
|
+
return U.components.set(b, {
|
|
759
|
+
forceUpdate: () => P({}),
|
|
760
|
+
paths: /* @__PURE__ */ new Set([A.join(".")])
|
|
771
761
|
}), o.getState().stateComponents.set(t, U), () => {
|
|
772
|
-
const
|
|
773
|
-
|
|
762
|
+
const B = o.getState().stateComponents.get(t);
|
|
763
|
+
B && B.components.delete(b);
|
|
774
764
|
};
|
|
775
|
-
}, [t,
|
|
765
|
+
}, [t, x]);
|
|
776
766
|
},
|
|
777
767
|
index: g,
|
|
778
768
|
originalIndex: i
|
|
@@ -783,20 +773,20 @@ function mt(t, c, h, f) {
|
|
|
783
773
|
), null);
|
|
784
774
|
};
|
|
785
775
|
if (l === "stateMapNoRender")
|
|
786
|
-
return (e) =>
|
|
776
|
+
return (e) => m.map((s, i) => {
|
|
787
777
|
let g;
|
|
788
778
|
S?.validIndices && S.validIndices[i] !== void 0 ? g = S.validIndices[i] : g = i;
|
|
789
|
-
const u = [...n, g.toString()],
|
|
779
|
+
const u = [...n, g.toString()], A = a(s, u, S);
|
|
790
780
|
return e(
|
|
791
781
|
s,
|
|
792
|
-
|
|
782
|
+
A,
|
|
793
783
|
i,
|
|
794
|
-
|
|
795
|
-
a(
|
|
784
|
+
m,
|
|
785
|
+
a(m, n, S)
|
|
796
786
|
);
|
|
797
787
|
});
|
|
798
788
|
if (l === "$stateMap")
|
|
799
|
-
return (e) =>
|
|
789
|
+
return (e) => st(qt, {
|
|
800
790
|
proxy: {
|
|
801
791
|
_stateKey: t,
|
|
802
792
|
_path: n,
|
|
@@ -809,12 +799,12 @@ function mt(t, c, h, f) {
|
|
|
809
799
|
return (e) => {
|
|
810
800
|
const r = o.getState().getNestedState(t, n);
|
|
811
801
|
return Array.isArray(r) ? (S?.validIndices || Array.from({ length: r.length }, (i, g) => g)).map((i, g) => {
|
|
812
|
-
const u = r[i],
|
|
813
|
-
return
|
|
802
|
+
const u = r[i], A = [...n, i.toString()], w = a(u, A, S), T = `${v}-${n.join(".")}-${i}`;
|
|
803
|
+
return st(Yt, {
|
|
814
804
|
key: i,
|
|
815
805
|
stateKey: t,
|
|
816
|
-
itemComponentId:
|
|
817
|
-
itemPath:
|
|
806
|
+
itemComponentId: T,
|
|
807
|
+
itemPath: A,
|
|
818
808
|
children: e(
|
|
819
809
|
u,
|
|
820
810
|
w,
|
|
@@ -829,8 +819,8 @@ function mt(t, c, h, f) {
|
|
|
829
819
|
};
|
|
830
820
|
if (l === "stateFlattenOn")
|
|
831
821
|
return (e) => {
|
|
832
|
-
const r =
|
|
833
|
-
|
|
822
|
+
const r = m;
|
|
823
|
+
y.clear(), k++;
|
|
834
824
|
const s = r.flatMap(
|
|
835
825
|
(i) => i[e] ?? []
|
|
836
826
|
);
|
|
@@ -842,7 +832,7 @@ function mt(t, c, h, f) {
|
|
|
842
832
|
};
|
|
843
833
|
if (l === "index")
|
|
844
834
|
return (e) => {
|
|
845
|
-
const r =
|
|
835
|
+
const r = m[e];
|
|
846
836
|
return a(r, [...n, e.toString()]);
|
|
847
837
|
};
|
|
848
838
|
if (l === "last")
|
|
@@ -853,49 +843,49 @@ function mt(t, c, h, f) {
|
|
|
853
843
|
return a(s, i);
|
|
854
844
|
};
|
|
855
845
|
if (l === "insert")
|
|
856
|
-
return (e) => (p(n),
|
|
846
|
+
return (e) => (p(n), ht(c, e, n, t), a(
|
|
857
847
|
o.getState().getNestedState(t, n),
|
|
858
848
|
n
|
|
859
849
|
));
|
|
860
850
|
if (l === "uniqueInsert")
|
|
861
851
|
return (e, r, s) => {
|
|
862
|
-
const i = o.getState().getNestedState(t, n), g =
|
|
852
|
+
const i = o.getState().getNestedState(t, n), g = Z(e) ? e(i) : e;
|
|
863
853
|
let u = null;
|
|
864
854
|
if (!i.some((w) => {
|
|
865
855
|
if (r) {
|
|
866
|
-
const
|
|
867
|
-
(
|
|
856
|
+
const P = r.every(
|
|
857
|
+
(x) => H(w[x], g[x])
|
|
868
858
|
);
|
|
869
|
-
return
|
|
859
|
+
return P && (u = w), P;
|
|
870
860
|
}
|
|
871
|
-
const
|
|
872
|
-
return
|
|
861
|
+
const T = H(w, g);
|
|
862
|
+
return T && (u = w), T;
|
|
873
863
|
}))
|
|
874
|
-
p(n),
|
|
864
|
+
p(n), ht(c, g, n, t);
|
|
875
865
|
else if (s && u) {
|
|
876
|
-
const w = s(u),
|
|
877
|
-
(
|
|
866
|
+
const w = s(u), T = i.map(
|
|
867
|
+
(P) => H(P, u) ? w : P
|
|
878
868
|
);
|
|
879
|
-
p(n),
|
|
869
|
+
p(n), at(c, T, n);
|
|
880
870
|
}
|
|
881
871
|
};
|
|
882
872
|
if (l === "cut")
|
|
883
873
|
return (e, r) => {
|
|
884
874
|
if (!r?.waitForSync)
|
|
885
|
-
return p(n),
|
|
875
|
+
return p(n), ct(c, n, t, e), a(
|
|
886
876
|
o.getState().getNestedState(t, n),
|
|
887
877
|
n
|
|
888
878
|
);
|
|
889
879
|
};
|
|
890
880
|
if (l === "cutByValue")
|
|
891
881
|
return (e) => {
|
|
892
|
-
for (let r = 0; r <
|
|
893
|
-
|
|
882
|
+
for (let r = 0; r < m.length; r++)
|
|
883
|
+
m[r] === e && ct(c, n, t, r);
|
|
894
884
|
};
|
|
895
885
|
if (l === "toggleByValue")
|
|
896
886
|
return (e) => {
|
|
897
|
-
const r =
|
|
898
|
-
r > -1 ?
|
|
887
|
+
const r = m.findIndex((s) => s === e);
|
|
888
|
+
r > -1 ? ct(c, n, t, r) : ht(c, e, n, t);
|
|
899
889
|
};
|
|
900
890
|
if (l === "stateFind")
|
|
901
891
|
return (e) => {
|
|
@@ -916,33 +906,33 @@ function mt(t, c, h, f) {
|
|
|
916
906
|
return a(i.item, g, S);
|
|
917
907
|
};
|
|
918
908
|
}
|
|
919
|
-
const
|
|
920
|
-
if (!isNaN(Number(
|
|
909
|
+
const X = n[n.length - 1];
|
|
910
|
+
if (!isNaN(Number(X))) {
|
|
921
911
|
const d = n.slice(0, -1), e = o.getState().getNestedState(t, d);
|
|
922
912
|
if (Array.isArray(e) && l === "cut")
|
|
923
|
-
return () =>
|
|
913
|
+
return () => ct(
|
|
924
914
|
c,
|
|
925
915
|
d,
|
|
926
916
|
t,
|
|
927
|
-
Number(
|
|
917
|
+
Number(X)
|
|
928
918
|
);
|
|
929
919
|
}
|
|
930
920
|
if (l === "get")
|
|
931
921
|
return () => {
|
|
932
|
-
if (S?.validIndices && Array.isArray(
|
|
922
|
+
if (S?.validIndices && Array.isArray(m)) {
|
|
933
923
|
const d = o.getState().getNestedState(t, n);
|
|
934
924
|
return S.validIndices.map((e) => d[e]);
|
|
935
925
|
}
|
|
936
926
|
return o.getState().getNestedState(t, n);
|
|
937
927
|
};
|
|
938
928
|
if (l === "$derive")
|
|
939
|
-
return (d) =>
|
|
929
|
+
return (d) => kt({
|
|
940
930
|
_stateKey: t,
|
|
941
931
|
_path: n,
|
|
942
932
|
_effect: d.toString()
|
|
943
933
|
});
|
|
944
934
|
if (l === "$get")
|
|
945
|
-
return () =>
|
|
935
|
+
return () => kt({
|
|
946
936
|
_stateKey: t,
|
|
947
937
|
_path: n
|
|
948
938
|
});
|
|
@@ -951,7 +941,7 @@ function mt(t, c, h, f) {
|
|
|
951
941
|
return o.getState().getSyncInfo(d);
|
|
952
942
|
}
|
|
953
943
|
if (l == "getLocalStorage")
|
|
954
|
-
return (d) =>
|
|
944
|
+
return (d) => ft(f + "-" + t + "-" + d);
|
|
955
945
|
if (l === "_selected") {
|
|
956
946
|
const d = n.slice(0, -1), e = d.join("."), r = o.getState().getNestedState(t, d);
|
|
957
947
|
return Array.isArray(r) ? Number(n[n.length - 1]) === o.getState().getSelectedIndex(t, e) : void 0;
|
|
@@ -961,7 +951,7 @@ function mt(t, c, h, f) {
|
|
|
961
951
|
const e = n.slice(0, -1), r = Number(n[n.length - 1]), s = e.join(".");
|
|
962
952
|
d ? o.getState().setSelectedIndex(t, s, r) : o.getState().setSelectedIndex(t, s, void 0);
|
|
963
953
|
const i = o.getState().getNestedState(t, [...e]);
|
|
964
|
-
|
|
954
|
+
at(c, i, e), p(e);
|
|
965
955
|
};
|
|
966
956
|
if (l === "toggleSelected")
|
|
967
957
|
return () => {
|
|
@@ -972,73 +962,73 @@ function mt(t, c, h, f) {
|
|
|
972
962
|
s === e ? void 0 : e
|
|
973
963
|
);
|
|
974
964
|
const i = o.getState().getNestedState(t, [...d]);
|
|
975
|
-
|
|
965
|
+
at(c, i, d), p(d);
|
|
976
966
|
};
|
|
977
967
|
if (n.length == 0) {
|
|
978
968
|
if (l === "applyJsonPatch")
|
|
979
969
|
return (d) => {
|
|
980
|
-
const e = o.getState().cogsStateStore[t], s =
|
|
981
|
-
|
|
970
|
+
const e = o.getState().cogsStateStore[t], s = Ft(e, d).newDocument;
|
|
971
|
+
Ct(
|
|
982
972
|
t,
|
|
983
973
|
o.getState().initialStateGlobal[t],
|
|
984
974
|
s,
|
|
985
975
|
c,
|
|
986
|
-
|
|
976
|
+
v,
|
|
987
977
|
f
|
|
988
978
|
);
|
|
989
979
|
const i = o.getState().stateComponents.get(t);
|
|
990
980
|
if (i) {
|
|
991
|
-
const g =
|
|
981
|
+
const g = It(e, s), u = new Set(g);
|
|
992
982
|
for (const [
|
|
993
|
-
|
|
983
|
+
A,
|
|
994
984
|
w
|
|
995
985
|
] of i.components.entries()) {
|
|
996
|
-
let
|
|
997
|
-
const
|
|
998
|
-
if (!
|
|
999
|
-
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")) {
|
|
1000
990
|
w.forceUpdate();
|
|
1001
991
|
continue;
|
|
1002
992
|
}
|
|
1003
|
-
if (
|
|
1004
|
-
for (const
|
|
1005
|
-
if (w.paths.has(
|
|
1006
|
-
|
|
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;
|
|
1007
997
|
break;
|
|
1008
998
|
}
|
|
1009
|
-
let
|
|
1010
|
-
for (;
|
|
1011
|
-
const U =
|
|
999
|
+
let b = x.lastIndexOf(".");
|
|
1000
|
+
for (; b !== -1; ) {
|
|
1001
|
+
const U = x.substring(0, b);
|
|
1012
1002
|
if (w.paths.has(U)) {
|
|
1013
|
-
|
|
1003
|
+
T = !0;
|
|
1014
1004
|
break;
|
|
1015
1005
|
}
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1006
|
+
const B = x.substring(
|
|
1007
|
+
b + 1
|
|
1018
1008
|
);
|
|
1019
|
-
if (!isNaN(Number(
|
|
1020
|
-
const
|
|
1021
|
-
if (
|
|
1009
|
+
if (!isNaN(Number(B))) {
|
|
1010
|
+
const C = U.lastIndexOf(".");
|
|
1011
|
+
if (C !== -1) {
|
|
1022
1012
|
const N = U.substring(
|
|
1023
1013
|
0,
|
|
1024
|
-
|
|
1014
|
+
C
|
|
1025
1015
|
);
|
|
1026
1016
|
if (w.paths.has(N)) {
|
|
1027
|
-
|
|
1017
|
+
T = !0;
|
|
1028
1018
|
break;
|
|
1029
1019
|
}
|
|
1030
1020
|
}
|
|
1031
1021
|
}
|
|
1032
|
-
|
|
1022
|
+
b = U.lastIndexOf(".");
|
|
1033
1023
|
}
|
|
1034
|
-
if (
|
|
1024
|
+
if (T) break;
|
|
1035
1025
|
}
|
|
1036
|
-
if (!
|
|
1037
|
-
const
|
|
1038
|
-
let
|
|
1039
|
-
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);
|
|
1040
1030
|
}
|
|
1041
|
-
|
|
1031
|
+
T && w.forceUpdate();
|
|
1042
1032
|
}
|
|
1043
1033
|
}
|
|
1044
1034
|
}
|
|
@@ -1050,27 +1040,27 @@ function mt(t, c, h, f) {
|
|
|
1050
1040
|
throw new Error("Zod schema not found");
|
|
1051
1041
|
if (!d?.key)
|
|
1052
1042
|
throw new Error("Validation key not found");
|
|
1053
|
-
|
|
1043
|
+
J(d.key);
|
|
1054
1044
|
const r = o.getState().cogsStateStore[t];
|
|
1055
1045
|
try {
|
|
1056
1046
|
const s = o.getState().getValidationErrors(d.key);
|
|
1057
1047
|
s && s.length > 0 && s.forEach(([g]) => {
|
|
1058
|
-
g && g.startsWith(d.key) &&
|
|
1048
|
+
g && g.startsWith(d.key) && J(g);
|
|
1059
1049
|
});
|
|
1060
1050
|
const i = d.zodSchema.safeParse(r);
|
|
1061
1051
|
return i.success ? !0 : (i.error.errors.forEach((u) => {
|
|
1062
|
-
const
|
|
1063
|
-
e(
|
|
1064
|
-
}),
|
|
1052
|
+
const A = u.path, w = u.message, T = [d.key, ...A].join(".");
|
|
1053
|
+
e(T, w);
|
|
1054
|
+
}), St(t), !1);
|
|
1065
1055
|
} catch (s) {
|
|
1066
1056
|
return console.error("Zod schema validation failed", s), !1;
|
|
1067
1057
|
}
|
|
1068
1058
|
};
|
|
1069
|
-
if (l === "_componentId") return
|
|
1059
|
+
if (l === "_componentId") return v;
|
|
1070
1060
|
if (l === "getComponents")
|
|
1071
1061
|
return () => o().stateComponents.get(t);
|
|
1072
1062
|
if (l === "getAllFormRefs")
|
|
1073
|
-
return () =>
|
|
1063
|
+
return () => Et.getState().getFormRefsByStateKey(t);
|
|
1074
1064
|
if (l === "_initialState")
|
|
1075
1065
|
return o.getState().initialStateGlobal[t];
|
|
1076
1066
|
if (l === "_serverState")
|
|
@@ -1083,13 +1073,13 @@ function mt(t, c, h, f) {
|
|
|
1083
1073
|
if (l === "removeValidation") return I.removeValidation;
|
|
1084
1074
|
}
|
|
1085
1075
|
if (l === "getFormRef")
|
|
1086
|
-
return () =>
|
|
1076
|
+
return () => Et.getState().getFormRef(t + "." + n.join("."));
|
|
1087
1077
|
if (l === "validationWrapper")
|
|
1088
1078
|
return ({
|
|
1089
1079
|
children: d,
|
|
1090
1080
|
hideMessage: e
|
|
1091
|
-
}) => /* @__PURE__ */
|
|
1092
|
-
|
|
1081
|
+
}) => /* @__PURE__ */ vt(
|
|
1082
|
+
jt,
|
|
1093
1083
|
{
|
|
1094
1084
|
formOpts: e ? { validation: { message: "" } } : void 0,
|
|
1095
1085
|
path: n,
|
|
@@ -1105,21 +1095,21 @@ function mt(t, c, h, f) {
|
|
|
1105
1095
|
if (l === "update")
|
|
1106
1096
|
return (d, e) => {
|
|
1107
1097
|
if (e?.debounce)
|
|
1108
|
-
|
|
1109
|
-
|
|
1098
|
+
Mt(() => {
|
|
1099
|
+
at(c, d, n, "");
|
|
1110
1100
|
const r = o.getState().getNestedState(t, n);
|
|
1111
1101
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1112
1102
|
}, e.debounce);
|
|
1113
1103
|
else {
|
|
1114
|
-
|
|
1104
|
+
at(c, d, n, "");
|
|
1115
1105
|
const r = o.getState().getNestedState(t, n);
|
|
1116
1106
|
e?.afterUpdate && e.afterUpdate(r);
|
|
1117
1107
|
}
|
|
1118
1108
|
p(n);
|
|
1119
1109
|
};
|
|
1120
1110
|
if (l === "formElement")
|
|
1121
|
-
return (d, e) => /* @__PURE__ */
|
|
1122
|
-
|
|
1111
|
+
return (d, e) => /* @__PURE__ */ vt(
|
|
1112
|
+
Ot,
|
|
1123
1113
|
{
|
|
1124
1114
|
setState: c,
|
|
1125
1115
|
stateKey: t,
|
|
@@ -1128,51 +1118,51 @@ function mt(t, c, h, f) {
|
|
|
1128
1118
|
formOpts: e
|
|
1129
1119
|
}
|
|
1130
1120
|
);
|
|
1131
|
-
const
|
|
1132
|
-
return a(
|
|
1121
|
+
const j = [...n, l], ot = o.getState().getNestedState(t, j);
|
|
1122
|
+
return a(ot, j, S);
|
|
1133
1123
|
}
|
|
1134
|
-
},
|
|
1135
|
-
return
|
|
1136
|
-
proxy:
|
|
1124
|
+
}, G = new Proxy(R, F);
|
|
1125
|
+
return y.set(W, {
|
|
1126
|
+
proxy: G,
|
|
1137
1127
|
stateVersion: k
|
|
1138
|
-
}),
|
|
1128
|
+
}), G;
|
|
1139
1129
|
}
|
|
1140
1130
|
return a(
|
|
1141
1131
|
o.getState().getNestedState(t, [])
|
|
1142
1132
|
);
|
|
1143
1133
|
}
|
|
1144
|
-
function
|
|
1145
|
-
return
|
|
1134
|
+
function kt(t) {
|
|
1135
|
+
return st(Jt, { proxy: t });
|
|
1146
1136
|
}
|
|
1147
|
-
function
|
|
1137
|
+
function qt({
|
|
1148
1138
|
proxy: t,
|
|
1149
1139
|
rebuildStateShape: c
|
|
1150
1140
|
}) {
|
|
1151
|
-
const
|
|
1152
|
-
return Array.isArray(
|
|
1153
|
-
|
|
1141
|
+
const v = o().getNestedState(t._stateKey, t._path);
|
|
1142
|
+
return Array.isArray(v) ? c(
|
|
1143
|
+
v,
|
|
1154
1144
|
t._path
|
|
1155
1145
|
).stateMapNoRender(
|
|
1156
|
-
(
|
|
1146
|
+
(y, k, p, I, a) => t._mapFn(y, k, p, I, a)
|
|
1157
1147
|
) : null;
|
|
1158
1148
|
}
|
|
1159
|
-
function
|
|
1149
|
+
function Jt({
|
|
1160
1150
|
proxy: t
|
|
1161
1151
|
}) {
|
|
1162
|
-
const c =
|
|
1163
|
-
return
|
|
1152
|
+
const c = Y(null), v = `${t._stateKey}-${t._path.join(".")}`;
|
|
1153
|
+
return lt(() => {
|
|
1164
1154
|
const f = c.current;
|
|
1165
1155
|
if (!f || !f.parentElement) return;
|
|
1166
|
-
const
|
|
1167
|
-
let I =
|
|
1168
|
-
I || (I = `parent-${crypto.randomUUID()}`,
|
|
1169
|
-
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 = {
|
|
1170
1160
|
instanceId: `instance-${crypto.randomUUID()}`,
|
|
1171
1161
|
parentId: I,
|
|
1172
1162
|
position: p,
|
|
1173
1163
|
effect: t._effect
|
|
1174
1164
|
};
|
|
1175
|
-
o.getState().addSignalElement(
|
|
1165
|
+
o.getState().addSignalElement(v, m);
|
|
1176
1166
|
const n = o.getState().getNestedState(t._stateKey, t._path);
|
|
1177
1167
|
let S;
|
|
1178
1168
|
if (t._effect)
|
|
@@ -1181,67 +1171,67 @@ function te({
|
|
|
1181
1171
|
"state",
|
|
1182
1172
|
`return (${t._effect})(state)`
|
|
1183
1173
|
)(n);
|
|
1184
|
-
} catch (
|
|
1185
|
-
console.error("Error evaluating effect function during mount:",
|
|
1174
|
+
} catch (R) {
|
|
1175
|
+
console.error("Error evaluating effect function during mount:", R), S = n;
|
|
1186
1176
|
}
|
|
1187
1177
|
else
|
|
1188
1178
|
S = n;
|
|
1189
1179
|
S !== null && typeof S == "object" && (S = JSON.stringify(S));
|
|
1190
|
-
const
|
|
1191
|
-
f.replaceWith(
|
|
1192
|
-
}, [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", {
|
|
1193
1183
|
ref: c,
|
|
1194
1184
|
style: { display: "none" },
|
|
1195
|
-
"data-signal-id":
|
|
1185
|
+
"data-signal-id": v
|
|
1196
1186
|
});
|
|
1197
1187
|
}
|
|
1198
|
-
function
|
|
1199
|
-
const c =
|
|
1200
|
-
(
|
|
1188
|
+
function de(t) {
|
|
1189
|
+
const c = xt(
|
|
1190
|
+
(v) => {
|
|
1201
1191
|
const f = o.getState().stateComponents.get(t._stateKey) || {
|
|
1202
1192
|
components: /* @__PURE__ */ new Map()
|
|
1203
1193
|
};
|
|
1204
1194
|
return f.components.set(t._stateKey, {
|
|
1205
|
-
forceUpdate:
|
|
1195
|
+
forceUpdate: v,
|
|
1206
1196
|
paths: /* @__PURE__ */ new Set([t._path.join(".")])
|
|
1207
1197
|
}), () => f.components.delete(t._stateKey);
|
|
1208
1198
|
},
|
|
1209
1199
|
() => o.getState().getNestedState(t._stateKey, t._path)
|
|
1210
1200
|
);
|
|
1211
|
-
return
|
|
1201
|
+
return st("text", {}, String(c));
|
|
1212
1202
|
}
|
|
1213
|
-
function
|
|
1203
|
+
function Yt({
|
|
1214
1204
|
stateKey: t,
|
|
1215
1205
|
itemComponentId: c,
|
|
1216
|
-
itemPath:
|
|
1206
|
+
itemPath: v,
|
|
1217
1207
|
children: f
|
|
1218
1208
|
}) {
|
|
1219
|
-
const [,
|
|
1220
|
-
return
|
|
1221
|
-
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, {
|
|
1222
1212
|
virtualizer: {
|
|
1223
1213
|
itemHeight: p.height
|
|
1224
1214
|
}
|
|
1225
1215
|
});
|
|
1226
|
-
}, [p.height]),
|
|
1216
|
+
}, [p.height]), dt(() => {
|
|
1227
1217
|
const I = `${t}////${c}`, a = o.getState().stateComponents.get(t) || {
|
|
1228
1218
|
components: /* @__PURE__ */ new Map()
|
|
1229
1219
|
};
|
|
1230
1220
|
return a.components.set(I, {
|
|
1231
|
-
forceUpdate: () =>
|
|
1232
|
-
paths: /* @__PURE__ */ new Set([
|
|
1221
|
+
forceUpdate: () => y({}),
|
|
1222
|
+
paths: /* @__PURE__ */ new Set([v.join(".")])
|
|
1233
1223
|
}), o.getState().stateComponents.set(t, a), () => {
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1224
|
+
const m = o.getState().stateComponents.get(t);
|
|
1225
|
+
m && m.components.delete(I);
|
|
1236
1226
|
};
|
|
1237
|
-
}, [t, c,
|
|
1227
|
+
}, [t, c, v.join(".")]), /* @__PURE__ */ vt("div", { ref: k, children: f });
|
|
1238
1228
|
}
|
|
1239
1229
|
export {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1230
|
+
kt as $cogsSignal,
|
|
1231
|
+
de as $cogsSignalStore,
|
|
1232
|
+
ie as addStateOptions,
|
|
1233
|
+
ce as createCogsState,
|
|
1234
|
+
le as notifyComponent,
|
|
1235
|
+
Bt as useCogsStateFn
|
|
1246
1236
|
};
|
|
1247
1237
|
//# sourceMappingURL=CogsState.jsx.map
|