cogsbox-state 0.5.214 → 0.5.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CogsState.jsx +615 -595
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +24 -2
package/dist/CogsState.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as ye } from "react/jsx-runtime";
|
|
3
|
-
import { useState as de, useRef as te, useEffect as ue, useLayoutEffect as $e, useMemo as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import { pushFunc as ce, updateFn as
|
|
3
|
+
import { useState as de, useRef as te, useEffect as ue, useLayoutEffect as $e, useMemo as Te, createElement as ae, useSyncExternalStore as Ve, startTransition as Ne } from "react";
|
|
4
|
+
import { transformStateFunc as Ae, isDeepEqual as G, isFunction as J, getNestedValue as W, getDifferences as fe, debounce as be } from "./utility.js";
|
|
5
|
+
import { pushFunc as ce, updateFn as Q, cutFunc as ee, ValidationWrapper as Pe, FormControlComponent as _e } from "./Functions.jsx";
|
|
6
6
|
import xe from "superjson";
|
|
7
7
|
import { v4 as ge } from "uuid";
|
|
8
8
|
import "zod";
|
|
@@ -10,53 +10,53 @@ import { getGlobalStore as r, formRefStore as ve } from "./store.js";
|
|
|
10
10
|
import { useCogsConfig as we } from "./CogsStateClient.jsx";
|
|
11
11
|
import { applyPatch as Ce } from "fast-json-patch";
|
|
12
12
|
function he(e, i) {
|
|
13
|
-
const
|
|
13
|
+
const v = r.getState().getInitialOptions, u = r.getState().setInitialStateOptions, S = v(e) || {};
|
|
14
14
|
u(e, {
|
|
15
|
-
...
|
|
15
|
+
...S,
|
|
16
16
|
...i
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function Ie({
|
|
20
20
|
stateKey: e,
|
|
21
21
|
options: i,
|
|
22
|
-
initialOptionsPart:
|
|
22
|
+
initialOptionsPart: v
|
|
23
23
|
}) {
|
|
24
|
-
const u = Y(e) || {},
|
|
25
|
-
let
|
|
24
|
+
const u = Y(e) || {}, S = v[e] || {}, E = r.getState().setInitialStateOptions, p = { ...S, ...u };
|
|
25
|
+
let h = !1;
|
|
26
26
|
if (i)
|
|
27
27
|
for (const s in i)
|
|
28
|
-
p.hasOwnProperty(s) ? (s == "localStorage" && i[s] && p[s].key !== i[s]?.key && (
|
|
29
|
-
!G(p[s], i[s]) && (
|
|
30
|
-
|
|
28
|
+
p.hasOwnProperty(s) ? (s == "localStorage" && i[s] && p[s].key !== i[s]?.key && (h = !0, p[s] = i[s]), s == "initialState" && i[s] && p[s] !== i[s] && // Different references
|
|
29
|
+
!G(p[s], i[s]) && (h = !0, p[s] = i[s])) : (h = !0, p[s] = i[s]);
|
|
30
|
+
h && E(e, p);
|
|
31
31
|
}
|
|
32
|
-
function Ke(e, { formElements: i, validation:
|
|
33
|
-
return { initialState: e, formElements: i, validation:
|
|
32
|
+
function Ke(e, { formElements: i, validation: v }) {
|
|
33
|
+
return { initialState: e, formElements: i, validation: v };
|
|
34
34
|
}
|
|
35
35
|
const et = (e, i) => {
|
|
36
|
-
let
|
|
37
|
-
const [u,
|
|
38
|
-
(Object.keys(
|
|
39
|
-
|
|
36
|
+
let v = e;
|
|
37
|
+
const [u, S] = Ae(v);
|
|
38
|
+
(Object.keys(S).length > 0 || i && Object.keys(i).length > 0) && Object.keys(S).forEach((h) => {
|
|
39
|
+
S[h] = S[h] || {}, S[h].formElements = {
|
|
40
40
|
...i?.formElements,
|
|
41
41
|
// Global defaults first
|
|
42
42
|
...i?.validation,
|
|
43
|
-
...
|
|
43
|
+
...S[h].formElements || {}
|
|
44
44
|
// State-specific overrides
|
|
45
|
-
}, Y(
|
|
45
|
+
}, Y(h) || r.getState().setInitialStateOptions(h, S[h]);
|
|
46
46
|
}), r.getState().setInitialStates(u), r.getState().setCreatedState(u);
|
|
47
|
-
const
|
|
48
|
-
const [
|
|
47
|
+
const E = (h, s) => {
|
|
48
|
+
const [m] = de(s?.componentId ?? ge());
|
|
49
49
|
Ie({
|
|
50
|
-
stateKey:
|
|
50
|
+
stateKey: h,
|
|
51
51
|
options: s,
|
|
52
|
-
initialOptionsPart:
|
|
52
|
+
initialOptionsPart: S
|
|
53
53
|
});
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const n = r.getState().cogsStateStore[h] || u[h], y = s?.modifyState ? s.modifyState(n) : n, [j, _] = De(
|
|
55
|
+
y,
|
|
56
56
|
{
|
|
57
|
-
stateKey:
|
|
57
|
+
stateKey: h,
|
|
58
58
|
syncUpdate: s?.syncUpdate,
|
|
59
|
-
componentId:
|
|
59
|
+
componentId: m,
|
|
60
60
|
localStorage: s?.localStorage,
|
|
61
61
|
middleware: s?.middleware,
|
|
62
62
|
enabledSync: s?.enabledSync,
|
|
@@ -67,12 +67,12 @@ const et = (e, i) => {
|
|
|
67
67
|
serverState: s?.serverState
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
|
-
return
|
|
70
|
+
return _;
|
|
71
71
|
};
|
|
72
|
-
function p(
|
|
73
|
-
Ie({ stateKey:
|
|
72
|
+
function p(h, s) {
|
|
73
|
+
Ie({ stateKey: h, options: s, initialOptionsPart: S }), s.localStorage && Ue(h, s), ie(h);
|
|
74
74
|
}
|
|
75
|
-
return { useCogsState:
|
|
75
|
+
return { useCogsState: E, setCogsOptions: p };
|
|
76
76
|
}, {
|
|
77
77
|
setUpdaterState: ne,
|
|
78
78
|
setState: H,
|
|
@@ -82,31 +82,31 @@ const et = (e, i) => {
|
|
|
82
82
|
setStateLog: Fe,
|
|
83
83
|
updateInitialStateGlobal: Se,
|
|
84
84
|
addValidationError: Re,
|
|
85
|
-
removeValidationError:
|
|
85
|
+
removeValidationError: B,
|
|
86
86
|
setServerSyncActions: je
|
|
87
|
-
} = r.getState(), pe = (e, i,
|
|
88
|
-
|
|
87
|
+
} = r.getState(), pe = (e, i, v, u, S) => {
|
|
88
|
+
v?.log && console.log(
|
|
89
89
|
"saving to localstorage",
|
|
90
90
|
i,
|
|
91
|
-
|
|
91
|
+
v.localStorage?.key,
|
|
92
92
|
u
|
|
93
93
|
);
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
const p = `${u}-${i}-${
|
|
97
|
-
let
|
|
94
|
+
const E = J(v?.localStorage?.key) ? v.localStorage?.key(e) : v?.localStorage?.key;
|
|
95
|
+
if (E && u) {
|
|
96
|
+
const p = `${u}-${i}-${E}`;
|
|
97
|
+
let h;
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
h = oe(p)?.lastSyncedWithServer;
|
|
100
100
|
} catch {
|
|
101
101
|
}
|
|
102
102
|
const s = {
|
|
103
103
|
state: e,
|
|
104
104
|
lastUpdated: Date.now(),
|
|
105
|
-
lastSyncedWithServer:
|
|
106
|
-
},
|
|
105
|
+
lastSyncedWithServer: S ?? h
|
|
106
|
+
}, m = xe.serialize(s);
|
|
107
107
|
window.localStorage.setItem(
|
|
108
108
|
p,
|
|
109
|
-
JSON.stringify(
|
|
109
|
+
JSON.stringify(m.json)
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
}, oe = (e) => {
|
|
@@ -118,56 +118,56 @@ const et = (e, i) => {
|
|
|
118
118
|
return console.error("Error loading from localStorage:", i), null;
|
|
119
119
|
}
|
|
120
120
|
}, Ue = (e, i) => {
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
const
|
|
124
|
-
`${u}-${e}-${
|
|
121
|
+
const v = r.getState().cogsStateStore[e], { sessionId: u } = we(), S = J(i?.localStorage?.key) ? i.localStorage.key(v) : i?.localStorage?.key;
|
|
122
|
+
if (S && u) {
|
|
123
|
+
const E = oe(
|
|
124
|
+
`${u}-${e}-${S}`
|
|
125
125
|
);
|
|
126
|
-
if (
|
|
127
|
-
return H(e,
|
|
126
|
+
if (E && E.lastUpdated > (E.lastSyncedWithServer || 0))
|
|
127
|
+
return H(e, E.state), ie(e), !0;
|
|
128
128
|
}
|
|
129
129
|
return !1;
|
|
130
|
-
}, ke = (e, i,
|
|
130
|
+
}, ke = (e, i, v, u, S, E) => {
|
|
131
131
|
const p = {
|
|
132
132
|
initialState: i,
|
|
133
133
|
updaterState: re(
|
|
134
134
|
e,
|
|
135
135
|
u,
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
S,
|
|
137
|
+
E
|
|
138
138
|
),
|
|
139
|
-
state:
|
|
139
|
+
state: v
|
|
140
140
|
};
|
|
141
141
|
Se(e, p.initialState), ne(e, p.updaterState), H(e, p.state);
|
|
142
142
|
}, ie = (e) => {
|
|
143
143
|
const i = r.getState().stateComponents.get(e);
|
|
144
144
|
if (!i) return;
|
|
145
|
-
const
|
|
145
|
+
const v = /* @__PURE__ */ new Set();
|
|
146
146
|
i.components.forEach((u) => {
|
|
147
|
-
(u ? Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType || "component"] : null)?.includes("none") ||
|
|
147
|
+
(u ? Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType || "component"] : null)?.includes("none") || v.add(() => u.forceUpdate());
|
|
148
148
|
}), queueMicrotask(() => {
|
|
149
|
-
|
|
149
|
+
v.forEach((u) => u());
|
|
150
150
|
});
|
|
151
151
|
}, tt = (e, i) => {
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const u = `${e}////${i}`,
|
|
155
|
-
if ((
|
|
152
|
+
const v = r.getState().stateComponents.get(e);
|
|
153
|
+
if (v) {
|
|
154
|
+
const u = `${e}////${i}`, S = v.components.get(u);
|
|
155
|
+
if ((S ? Array.isArray(S.reactiveType) ? S.reactiveType : [S.reactiveType || "component"] : null)?.includes("none"))
|
|
156
156
|
return;
|
|
157
|
-
|
|
157
|
+
S && S.forceUpdate();
|
|
158
158
|
}
|
|
159
|
-
},
|
|
159
|
+
}, Me = (e, i, v, u) => {
|
|
160
160
|
switch (e) {
|
|
161
161
|
case "update":
|
|
162
162
|
return {
|
|
163
163
|
oldValue: W(i, u),
|
|
164
|
-
newValue: W(
|
|
164
|
+
newValue: W(v, u)
|
|
165
165
|
};
|
|
166
166
|
case "insert":
|
|
167
167
|
return {
|
|
168
168
|
oldValue: null,
|
|
169
169
|
// or undefined
|
|
170
|
-
newValue: W(
|
|
170
|
+
newValue: W(v, u)
|
|
171
171
|
};
|
|
172
172
|
case "cut":
|
|
173
173
|
return {
|
|
@@ -179,777 +179,797 @@ const et = (e, i) => {
|
|
|
179
179
|
return { oldValue: null, newValue: null };
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
-
function
|
|
182
|
+
function De(e, {
|
|
183
183
|
stateKey: i,
|
|
184
|
-
serverSync:
|
|
184
|
+
serverSync: v,
|
|
185
185
|
localStorage: u,
|
|
186
|
-
formElements:
|
|
187
|
-
reactiveDeps:
|
|
186
|
+
formElements: S,
|
|
187
|
+
reactiveDeps: E,
|
|
188
188
|
reactiveType: p,
|
|
189
|
-
componentId:
|
|
189
|
+
componentId: h,
|
|
190
190
|
initialState: s,
|
|
191
|
-
syncUpdate:
|
|
192
|
-
dependencies:
|
|
193
|
-
serverState:
|
|
191
|
+
syncUpdate: m,
|
|
192
|
+
dependencies: n,
|
|
193
|
+
serverState: y
|
|
194
194
|
} = {}) {
|
|
195
|
-
const [
|
|
196
|
-
let
|
|
197
|
-
const [
|
|
195
|
+
const [j, _] = de({}), { sessionId: x } = we();
|
|
196
|
+
let U = !i;
|
|
197
|
+
const [g] = de(i ?? ge()), c = r.getState().stateLog[g], K = te(/* @__PURE__ */ new Set()), L = te(h ?? ge()), A = te(
|
|
198
198
|
null
|
|
199
199
|
);
|
|
200
|
-
|
|
201
|
-
if (
|
|
202
|
-
H(
|
|
200
|
+
A.current = Y(g) ?? null, ue(() => {
|
|
201
|
+
if (m && m.stateKey === g && m.path?.[0]) {
|
|
202
|
+
H(g, (a) => ({
|
|
203
203
|
...a,
|
|
204
|
-
[
|
|
204
|
+
[m.path[0]]: m.newValue
|
|
205
205
|
}));
|
|
206
|
-
const
|
|
207
|
-
r.getState().setSyncInfo(
|
|
208
|
-
timeStamp:
|
|
209
|
-
userId:
|
|
206
|
+
const t = `${m.stateKey}:${m.path.join(".")}`;
|
|
207
|
+
r.getState().setSyncInfo(t, {
|
|
208
|
+
timeStamp: m.timeStamp,
|
|
209
|
+
userId: m.userId
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
}, [
|
|
212
|
+
}, [m]), ue(() => {
|
|
213
213
|
if (s) {
|
|
214
|
-
he(
|
|
214
|
+
he(g, {
|
|
215
215
|
initialState: s
|
|
216
216
|
});
|
|
217
|
-
const
|
|
218
|
-
if (!(
|
|
217
|
+
const t = A.current, o = t?.serverState?.id !== void 0 && t?.serverState?.status === "success" && t?.serverState?.data, d = r.getState().initialStateGlobal[g];
|
|
218
|
+
if (!(d && !G(d, s) || !d) && !o)
|
|
219
219
|
return;
|
|
220
|
-
let
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
let f = null;
|
|
221
|
+
const N = J(t?.localStorage?.key) ? t?.localStorage?.key(s) : t?.localStorage?.key;
|
|
222
|
+
N && x && (f = oe(`${x}-${g}-${N}`));
|
|
223
|
+
let w = s, $ = !1;
|
|
224
|
+
const F = o ? Date.now() : 0, b = f?.lastUpdated || 0, M = f?.lastSyncedWithServer || 0;
|
|
225
|
+
o && F > b ? (w = t.serverState.data, $ = !0) : f && b > M && (w = f.state, t?.localStorage?.onChange && t?.localStorage?.onChange(w)), ke(
|
|
226
|
+
g,
|
|
227
227
|
s,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
w,
|
|
229
|
+
X,
|
|
230
230
|
L.current,
|
|
231
|
-
|
|
232
|
-
),
|
|
231
|
+
x
|
|
232
|
+
), $ && N && x && pe(w, g, t, x, Date.now()), ie(g), (Array.isArray(p) ? p : [p || "component"]).includes("none") || _({});
|
|
233
233
|
}
|
|
234
234
|
}, [
|
|
235
235
|
s,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
...
|
|
236
|
+
y?.status,
|
|
237
|
+
y?.data,
|
|
238
|
+
...n || []
|
|
239
239
|
]), $e(() => {
|
|
240
|
-
|
|
241
|
-
serverSync:
|
|
242
|
-
formElements:
|
|
240
|
+
U && he(g, {
|
|
241
|
+
serverSync: v,
|
|
242
|
+
formElements: S,
|
|
243
243
|
initialState: s,
|
|
244
244
|
localStorage: u,
|
|
245
|
-
middleware:
|
|
245
|
+
middleware: A.current?.middleware
|
|
246
246
|
});
|
|
247
|
-
const
|
|
247
|
+
const t = `${g}////${L.current}`, a = r.getState().stateComponents.get(g) || {
|
|
248
248
|
components: /* @__PURE__ */ new Map()
|
|
249
249
|
};
|
|
250
|
-
return a.components.set(
|
|
251
|
-
forceUpdate: () =>
|
|
250
|
+
return a.components.set(t, {
|
|
251
|
+
forceUpdate: () => _({}),
|
|
252
252
|
paths: /* @__PURE__ */ new Set(),
|
|
253
253
|
deps: [],
|
|
254
|
-
depsFunction:
|
|
254
|
+
depsFunction: E || void 0,
|
|
255
255
|
reactiveType: p ?? ["component", "deps"]
|
|
256
|
-
}), r.getState().stateComponents.set(
|
|
257
|
-
const
|
|
258
|
-
a && (a.components.delete(
|
|
256
|
+
}), r.getState().stateComponents.set(g, a), _({}), () => {
|
|
257
|
+
const o = `${g}////${L.current}`;
|
|
258
|
+
a && (a.components.delete(o), a.components.size === 0 && r.getState().stateComponents.delete(g));
|
|
259
259
|
};
|
|
260
260
|
}, []);
|
|
261
|
-
const
|
|
261
|
+
const X = (t, a, o, d) => {
|
|
262
262
|
if (Array.isArray(a)) {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const I = `${g}-${a.join(".")}`;
|
|
264
|
+
K.current.add(I);
|
|
265
265
|
}
|
|
266
|
-
H(
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
let
|
|
270
|
-
if ((!
|
|
271
|
-
const
|
|
272
|
-
if (Array.isArray(
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
266
|
+
H(g, (I) => {
|
|
267
|
+
const f = J(t) ? t(I) : t, N = `${g}-${a.join(".")}`;
|
|
268
|
+
if (N) {
|
|
269
|
+
let R = !1, k = r.getState().signalDomElements.get(N);
|
|
270
|
+
if ((!k || k.size === 0) && (o.updateType === "insert" || o.updateType === "cut")) {
|
|
271
|
+
const O = a.slice(0, -1), C = W(f, O);
|
|
272
|
+
if (Array.isArray(C)) {
|
|
273
|
+
R = !0;
|
|
274
|
+
const P = `${g}-${O.join(".")}`;
|
|
275
|
+
k = r.getState().signalDomElements.get(P);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
if (
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
`[data-parent-id="${
|
|
278
|
+
if (k) {
|
|
279
|
+
const O = R ? W(f, a.slice(0, -1)) : W(f, a);
|
|
280
|
+
k.forEach(({ parentId: C, position: P, effect: T }) => {
|
|
281
|
+
const V = document.querySelector(
|
|
282
|
+
`[data-parent-id="${C}"]`
|
|
283
283
|
);
|
|
284
|
-
if (
|
|
285
|
-
const Z = Array.from(
|
|
286
|
-
if (Z[
|
|
287
|
-
const z = T ? new Function("state", `return (${T})(state)`)(
|
|
288
|
-
Z[
|
|
284
|
+
if (V) {
|
|
285
|
+
const Z = Array.from(V.childNodes);
|
|
286
|
+
if (Z[P]) {
|
|
287
|
+
const z = T ? new Function("state", `return (${T})(state)`)(O) : O;
|
|
288
|
+
Z[P].textContent = String(z);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
(
|
|
294
|
+
o.updateType === "update" && (d || A.current?.validation?.key) && a && B(
|
|
295
|
+
(d || A.current?.validation?.key) + "." + a.join(".")
|
|
296
296
|
);
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
),
|
|
301
|
-
|
|
302
|
-
).filter(([
|
|
303
|
-
let
|
|
304
|
-
if (
|
|
305
|
-
let
|
|
306
|
-
|
|
297
|
+
const w = a.slice(0, a.length - 1);
|
|
298
|
+
o.updateType === "cut" && A.current?.validation?.key && B(
|
|
299
|
+
A.current?.validation?.key + "." + w.join(".")
|
|
300
|
+
), o.updateType === "insert" && A.current?.validation?.key && Oe(
|
|
301
|
+
A.current?.validation?.key + "." + w.join(".")
|
|
302
|
+
).filter(([k, O]) => {
|
|
303
|
+
let C = k?.split(".").length;
|
|
304
|
+
if (k == w.join(".") && C == w.length - 1) {
|
|
305
|
+
let P = k + "." + w;
|
|
306
|
+
B(k), Re(P, O);
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
309
|
+
const $ = r.getState().stateComponents.get(g);
|
|
310
|
+
if ($) {
|
|
311
|
+
const R = fe(I, f), k = new Set(R), O = o.updateType === "update" ? a.join(".") : a.slice(0, -1).join(".") || "", C = [];
|
|
312
312
|
for (const [
|
|
313
|
-
|
|
313
|
+
P,
|
|
314
314
|
T
|
|
315
|
-
] of
|
|
316
|
-
let
|
|
315
|
+
] of $.components.entries()) {
|
|
316
|
+
let V = !1;
|
|
317
317
|
const Z = Array.isArray(T.reactiveType) ? T.reactiveType : [T.reactiveType || "component"];
|
|
318
318
|
if (!Z.includes("none")) {
|
|
319
319
|
if (Z.includes("all")) {
|
|
320
|
-
|
|
320
|
+
C.push(T.forceUpdate);
|
|
321
321
|
continue;
|
|
322
322
|
}
|
|
323
|
-
if (Z.includes("component") && ((T.paths.has(
|
|
324
|
-
for (const z of
|
|
325
|
-
let
|
|
323
|
+
if (Z.includes("component") && ((T.paths.has(O) || T.paths.has("")) && (V = !0), !V))
|
|
324
|
+
for (const z of k) {
|
|
325
|
+
let D = z;
|
|
326
326
|
for (; ; ) {
|
|
327
|
-
if (T.paths.has(
|
|
328
|
-
|
|
327
|
+
if (T.paths.has(D)) {
|
|
328
|
+
V = !0;
|
|
329
329
|
break;
|
|
330
330
|
}
|
|
331
|
-
const se =
|
|
331
|
+
const se = D.lastIndexOf(".");
|
|
332
332
|
if (se !== -1) {
|
|
333
|
-
const me =
|
|
333
|
+
const me = D.substring(
|
|
334
334
|
0,
|
|
335
335
|
se
|
|
336
336
|
);
|
|
337
337
|
if (!isNaN(
|
|
338
|
-
Number(
|
|
338
|
+
Number(D.substring(se + 1))
|
|
339
339
|
) && T.paths.has(me)) {
|
|
340
|
-
|
|
340
|
+
V = !0;
|
|
341
341
|
break;
|
|
342
342
|
}
|
|
343
|
-
|
|
343
|
+
D = me;
|
|
344
344
|
} else
|
|
345
|
-
|
|
346
|
-
if (
|
|
345
|
+
D = "";
|
|
346
|
+
if (D === "")
|
|
347
347
|
break;
|
|
348
348
|
}
|
|
349
|
-
if (
|
|
349
|
+
if (V) break;
|
|
350
350
|
}
|
|
351
|
-
if (!
|
|
352
|
-
const z = T.depsFunction(
|
|
353
|
-
let
|
|
354
|
-
typeof z == "boolean" ? z && (
|
|
351
|
+
if (!V && Z.includes("deps") && T.depsFunction) {
|
|
352
|
+
const z = T.depsFunction(f);
|
|
353
|
+
let D = !1;
|
|
354
|
+
typeof z == "boolean" ? z && (D = !0) : G(T.deps, z) || (T.deps = z, D = !0), D && (V = !0);
|
|
355
355
|
}
|
|
356
|
-
|
|
356
|
+
V && C.push(T.forceUpdate);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
|
|
360
|
-
|
|
359
|
+
C.length > 0 && queueMicrotask(() => {
|
|
360
|
+
C.forEach((P) => P());
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
|
-
const
|
|
364
|
-
a = a.map((
|
|
365
|
-
const
|
|
366
|
-
return
|
|
363
|
+
const F = Date.now();
|
|
364
|
+
a = a.map((R, k) => {
|
|
365
|
+
const O = a.slice(0, -1), C = W(f, O);
|
|
366
|
+
return k === a.length - 1 && ["insert", "cut"].includes(o.updateType) ? (C.length - 1).toString() : R;
|
|
367
367
|
});
|
|
368
|
-
const { oldValue:
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
368
|
+
const { oldValue: b, newValue: M } = Me(
|
|
369
|
+
o.updateType,
|
|
370
|
+
I,
|
|
371
|
+
f,
|
|
372
372
|
a
|
|
373
|
-
),
|
|
374
|
-
timeStamp:
|
|
375
|
-
stateKey:
|
|
373
|
+
), q = {
|
|
374
|
+
timeStamp: F,
|
|
375
|
+
stateKey: g,
|
|
376
376
|
path: a,
|
|
377
|
-
updateType:
|
|
377
|
+
updateType: o.updateType,
|
|
378
378
|
status: "new",
|
|
379
|
-
oldValue:
|
|
380
|
-
newValue:
|
|
379
|
+
oldValue: b,
|
|
380
|
+
newValue: M
|
|
381
381
|
};
|
|
382
|
-
if (Fe(
|
|
383
|
-
const
|
|
384
|
-
const T = `${
|
|
385
|
-
return
|
|
382
|
+
if (Fe(g, (R) => {
|
|
383
|
+
const O = [...R ?? [], q].reduce((C, P) => {
|
|
384
|
+
const T = `${P.stateKey}:${JSON.stringify(P.path)}`, V = C.get(T);
|
|
385
|
+
return V ? (V.timeStamp = Math.max(V.timeStamp, P.timeStamp), V.newValue = P.newValue, V.oldValue = V.oldValue ?? P.oldValue, V.updateType = P.updateType) : C.set(T, { ...P }), C;
|
|
386
386
|
}, /* @__PURE__ */ new Map());
|
|
387
|
-
return Array.from(
|
|
387
|
+
return Array.from(O.values());
|
|
388
388
|
}), pe(
|
|
389
|
-
E,
|
|
390
389
|
f,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
390
|
+
g,
|
|
391
|
+
A.current,
|
|
392
|
+
x
|
|
393
|
+
), A.current?.middleware && A.current.middleware({
|
|
394
|
+
updateLog: c,
|
|
395
|
+
update: q
|
|
396
|
+
}), A.current?.serverSync) {
|
|
397
|
+
const R = r.getState().serverState[g], k = A.current?.serverSync;
|
|
398
|
+
je(g, {
|
|
399
|
+
syncKey: typeof k.syncKey == "string" ? k.syncKey : k.syncKey({ state: f }),
|
|
400
|
+
rollBackState: R,
|
|
401
|
+
actionTimeStamp: Date.now() + (k.debounce ?? 3e3),
|
|
402
402
|
status: "waiting"
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
-
return
|
|
405
|
+
return f;
|
|
406
406
|
});
|
|
407
407
|
};
|
|
408
|
-
r.getState().updaterState[
|
|
409
|
-
|
|
408
|
+
r.getState().updaterState[g] || (ne(
|
|
409
|
+
g,
|
|
410
410
|
re(
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
g,
|
|
412
|
+
X,
|
|
413
413
|
L.current,
|
|
414
|
-
|
|
414
|
+
x
|
|
415
415
|
)
|
|
416
|
-
), r.getState().cogsStateStore[
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
), r.getState().cogsStateStore[g] || H(g, e), r.getState().initialStateGlobal[g] || Se(g, e));
|
|
417
|
+
const l = Te(() => re(
|
|
418
|
+
g,
|
|
419
|
+
X,
|
|
420
420
|
L.current,
|
|
421
|
-
|
|
422
|
-
), [
|
|
423
|
-
return [Ee(
|
|
421
|
+
x
|
|
422
|
+
), [g, x]);
|
|
423
|
+
return [Ee(g), l];
|
|
424
424
|
}
|
|
425
|
-
function re(e, i,
|
|
426
|
-
const
|
|
427
|
-
let
|
|
428
|
-
const p = (
|
|
429
|
-
const
|
|
430
|
-
for (const [
|
|
431
|
-
(
|
|
432
|
-
|
|
433
|
-
},
|
|
434
|
-
removeValidation: (
|
|
435
|
-
|
|
425
|
+
function re(e, i, v, u) {
|
|
426
|
+
const S = /* @__PURE__ */ new Map();
|
|
427
|
+
let E = 0;
|
|
428
|
+
const p = (m) => {
|
|
429
|
+
const n = m.join(".");
|
|
430
|
+
for (const [y] of S)
|
|
431
|
+
(y === n || y.startsWith(n + ".")) && S.delete(y);
|
|
432
|
+
E++;
|
|
433
|
+
}, h = {
|
|
434
|
+
removeValidation: (m) => {
|
|
435
|
+
m?.validationKey && B(m.validationKey);
|
|
436
436
|
},
|
|
437
|
-
revertToInitialState: (
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
r.getState().clearSelectedIndexesForState(e),
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
return
|
|
446
|
-
|
|
447
|
-
}),
|
|
437
|
+
revertToInitialState: (m) => {
|
|
438
|
+
const n = r.getState().getInitialOptions(e)?.validation;
|
|
439
|
+
n?.key && B(n?.key), m?.validationKey && B(m.validationKey);
|
|
440
|
+
const y = r.getState().initialStateGlobal[e];
|
|
441
|
+
r.getState().clearSelectedIndexesForState(e), S.clear(), E++;
|
|
442
|
+
const j = s(y, []), _ = Y(e), x = J(_?.localStorage?.key) ? _?.localStorage?.key(y) : _?.localStorage?.key, U = `${u}-${e}-${x}`;
|
|
443
|
+
U && localStorage.removeItem(U), ne(e, j), H(e, y);
|
|
444
|
+
const g = r.getState().stateComponents.get(e);
|
|
445
|
+
return g && g.components.forEach((c) => {
|
|
446
|
+
c.forceUpdate();
|
|
447
|
+
}), y;
|
|
448
448
|
},
|
|
449
|
-
updateInitialState: (
|
|
450
|
-
|
|
451
|
-
const
|
|
449
|
+
updateInitialState: (m) => {
|
|
450
|
+
S.clear(), E++;
|
|
451
|
+
const n = re(
|
|
452
452
|
e,
|
|
453
453
|
i,
|
|
454
|
-
|
|
454
|
+
v,
|
|
455
455
|
u
|
|
456
|
-
),
|
|
457
|
-
return localStorage.getItem(
|
|
458
|
-
Se(e,
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
456
|
+
), y = r.getState().initialStateGlobal[e], j = Y(e), _ = J(j?.localStorage?.key) ? j?.localStorage?.key(y) : j?.localStorage?.key, x = `${u}-${e}-${_}`;
|
|
457
|
+
return localStorage.getItem(x) && localStorage.removeItem(x), Ne(() => {
|
|
458
|
+
Se(e, m), ne(e, n), H(e, m);
|
|
459
|
+
const U = r.getState().stateComponents.get(e);
|
|
460
|
+
U && U.components.forEach((g) => {
|
|
461
|
+
g.forceUpdate();
|
|
462
462
|
});
|
|
463
463
|
}), {
|
|
464
|
-
fetchId: (
|
|
464
|
+
fetchId: (U) => n.get()[U]
|
|
465
465
|
};
|
|
466
466
|
},
|
|
467
467
|
_initialState: r.getState().initialStateGlobal[e],
|
|
468
468
|
_serverState: r.getState().serverState[e],
|
|
469
469
|
_isLoading: r.getState().isLoadingGlobal[e],
|
|
470
470
|
_isServerSynced: () => {
|
|
471
|
-
const
|
|
472
|
-
return !!(
|
|
471
|
+
const m = r.getState().serverState[e];
|
|
472
|
+
return !!(m && G(m, Ee(e)));
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
|
-
function s(
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
return r().getNestedState(e,
|
|
475
|
+
function s(m, n = [], y) {
|
|
476
|
+
const j = n.map(String).join(".");
|
|
477
|
+
S.get(j);
|
|
478
|
+
const _ = function() {
|
|
479
|
+
return r().getNestedState(e, n);
|
|
480
480
|
};
|
|
481
|
-
Object.keys(
|
|
482
|
-
|
|
481
|
+
Object.keys(h).forEach((g) => {
|
|
482
|
+
_[g] = h[g];
|
|
483
483
|
});
|
|
484
|
-
const
|
|
485
|
-
apply(
|
|
484
|
+
const x = {
|
|
485
|
+
apply(g, c, K) {
|
|
486
486
|
return console.log(
|
|
487
|
-
`PROXY APPLY TRAP HIT: stateKey=${e}, path=${
|
|
488
|
-
), console.trace("Apply trap stack trace"), r().getNestedState(e,
|
|
487
|
+
`PROXY APPLY TRAP HIT: stateKey=${e}, path=${n.join(".")}`
|
|
488
|
+
), console.trace("Apply trap stack trace"), r().getNestedState(e, n);
|
|
489
489
|
},
|
|
490
|
-
get(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
490
|
+
get(g, c) {
|
|
491
|
+
y?.validIndices && !Array.isArray(m) && (y = { ...y, validIndices: void 0 });
|
|
492
|
+
const K = /* @__PURE__ */ new Set([
|
|
493
|
+
"insert",
|
|
494
|
+
"cut",
|
|
495
|
+
"cutByValue",
|
|
496
|
+
"toggleByValue",
|
|
497
|
+
"uniqueInsert",
|
|
498
|
+
"update",
|
|
499
|
+
"applyJsonPatch",
|
|
500
|
+
"setSelected",
|
|
501
|
+
"toggleSelected",
|
|
502
|
+
"clearSelected",
|
|
503
|
+
"sync",
|
|
504
|
+
"validateZodSchema",
|
|
505
|
+
"revertToInitialState",
|
|
506
|
+
"updateInitialState",
|
|
507
|
+
"removeValidation",
|
|
508
|
+
"setValidation",
|
|
509
|
+
"removeStorage",
|
|
510
|
+
"middleware"
|
|
511
|
+
]);
|
|
512
|
+
if (!(c === "then" || c[0] === "$" || c === "stateMapNoRender" || K.has(c))) {
|
|
513
|
+
const l = `${e}////${v}`, t = r.getState().stateComponents.get(e);
|
|
514
|
+
if (t) {
|
|
515
|
+
const a = t.components.get(l);
|
|
516
|
+
if (a && !a.paths.has("")) {
|
|
517
|
+
if (n.length === 0 && c === "get")
|
|
518
|
+
a.paths.add("");
|
|
519
|
+
else if (n.length > 0) {
|
|
520
|
+
const o = n.join(".");
|
|
521
|
+
if (a.paths.size === 0)
|
|
522
|
+
a.paths.add(o);
|
|
503
523
|
else {
|
|
504
|
-
let
|
|
505
|
-
for (const I of
|
|
506
|
-
if (I ===
|
|
507
|
-
|
|
524
|
+
let d = !0;
|
|
525
|
+
for (const I of a.paths) {
|
|
526
|
+
if (I === o) {
|
|
527
|
+
d = !1;
|
|
508
528
|
break;
|
|
509
529
|
}
|
|
510
|
-
if (I.length <
|
|
511
|
-
|
|
530
|
+
if (I.length < o.length && o[I.length] === "." && o.substring(0, I.length) === I) {
|
|
531
|
+
d = !1;
|
|
512
532
|
break;
|
|
513
533
|
}
|
|
514
534
|
}
|
|
515
|
-
|
|
535
|
+
d && a.paths.add(o);
|
|
516
536
|
}
|
|
517
537
|
}
|
|
518
538
|
}
|
|
519
539
|
}
|
|
520
540
|
}
|
|
521
|
-
if (
|
|
541
|
+
if (c === "getDifferences")
|
|
522
542
|
return () => fe(
|
|
523
543
|
r.getState().cogsStateStore[e],
|
|
524
544
|
r.getState().initialStateGlobal[e]
|
|
525
545
|
);
|
|
526
|
-
if (
|
|
546
|
+
if (c === "sync" && n.length === 0)
|
|
527
547
|
return async function() {
|
|
528
|
-
const
|
|
529
|
-
if (!
|
|
548
|
+
const l = r.getState().getInitialOptions(e), t = l?.sync;
|
|
549
|
+
if (!t)
|
|
530
550
|
return console.error(`No mutation defined for state key "${e}"`), { success: !1, error: "No mutation defined" };
|
|
531
|
-
const
|
|
551
|
+
const a = r.getState().getNestedState(e, []), o = l?.validation?.key;
|
|
532
552
|
try {
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
r.getState().removeValidationError(
|
|
536
|
-
const
|
|
537
|
-
r.getState().addValidationError(
|
|
553
|
+
const d = await t.action(a);
|
|
554
|
+
if (d && !d.success && d.errors && o) {
|
|
555
|
+
r.getState().removeValidationError(o), d.errors.forEach((f) => {
|
|
556
|
+
const N = [o, ...f.path].join(".");
|
|
557
|
+
r.getState().addValidationError(N, f.message);
|
|
538
558
|
});
|
|
539
559
|
const I = r.getState().stateComponents.get(e);
|
|
540
|
-
I && I.components.forEach((
|
|
541
|
-
|
|
560
|
+
I && I.components.forEach((f) => {
|
|
561
|
+
f.forceUpdate();
|
|
542
562
|
});
|
|
543
563
|
}
|
|
544
|
-
return
|
|
545
|
-
} catch (
|
|
546
|
-
return
|
|
564
|
+
return d?.success && t.onSuccess ? t.onSuccess(d.data) : !d?.success && t.onError && t.onError(d.error), d;
|
|
565
|
+
} catch (d) {
|
|
566
|
+
return t.onError && t.onError(d), { success: !1, error: d };
|
|
547
567
|
}
|
|
548
568
|
};
|
|
549
|
-
if (
|
|
550
|
-
const
|
|
551
|
-
return G(
|
|
569
|
+
if (c === "_status") {
|
|
570
|
+
const l = r.getState().getNestedState(e, n), t = r.getState().initialStateGlobal[e], a = W(t, n);
|
|
571
|
+
return G(l, a) ? "fresh" : "stale";
|
|
552
572
|
}
|
|
553
|
-
if (
|
|
573
|
+
if (c === "getStatus")
|
|
554
574
|
return function() {
|
|
555
|
-
const
|
|
575
|
+
const l = r().getNestedState(
|
|
556
576
|
e,
|
|
557
|
-
|
|
558
|
-
),
|
|
559
|
-
return G(
|
|
577
|
+
n
|
|
578
|
+
), t = r.getState().initialStateGlobal[e], a = W(t, n);
|
|
579
|
+
return G(l, a) ? "fresh" : "stale";
|
|
560
580
|
};
|
|
561
|
-
if (
|
|
581
|
+
if (c === "removeStorage")
|
|
562
582
|
return () => {
|
|
563
|
-
const
|
|
564
|
-
|
|
583
|
+
const l = r.getState().initialStateGlobal[e], t = Y(e), a = J(t?.localStorage?.key) ? t?.localStorage?.key(l) : t?.localStorage?.key, o = `${u}-${e}-${a}`;
|
|
584
|
+
o && localStorage.removeItem(o);
|
|
565
585
|
};
|
|
566
|
-
if (
|
|
586
|
+
if (c === "showValidationErrors")
|
|
567
587
|
return () => {
|
|
568
|
-
const
|
|
569
|
-
if (!
|
|
588
|
+
const l = r.getState().getInitialOptions(e)?.validation;
|
|
589
|
+
if (!l?.key)
|
|
570
590
|
throw new Error("Validation key not found");
|
|
571
|
-
return r.getState().getValidationErrors(
|
|
591
|
+
return r.getState().getValidationErrors(l.key + "." + n.join("."));
|
|
572
592
|
};
|
|
573
|
-
if (Array.isArray(
|
|
574
|
-
const
|
|
575
|
-
item:
|
|
576
|
-
originalIndex:
|
|
577
|
-
})) : r.getState().getNestedState(e,
|
|
578
|
-
item:
|
|
579
|
-
originalIndex:
|
|
593
|
+
if (Array.isArray(m)) {
|
|
594
|
+
const l = () => y?.validIndices ? m.map((a, o) => ({
|
|
595
|
+
item: a,
|
|
596
|
+
originalIndex: y.validIndices[o]
|
|
597
|
+
})) : r.getState().getNestedState(e, n).map((a, o) => ({
|
|
598
|
+
item: a,
|
|
599
|
+
originalIndex: o
|
|
580
600
|
}));
|
|
581
|
-
if (
|
|
601
|
+
if (c === "getSelected")
|
|
582
602
|
return () => {
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
603
|
+
const t = r.getState().getSelectedIndex(e, n.join("."));
|
|
604
|
+
if (t !== void 0)
|
|
585
605
|
return s(
|
|
586
|
-
|
|
587
|
-
[...
|
|
588
|
-
|
|
606
|
+
m[t],
|
|
607
|
+
[...n, t.toString()],
|
|
608
|
+
y
|
|
589
609
|
);
|
|
590
610
|
};
|
|
591
|
-
if (
|
|
611
|
+
if (c === "clearSelected")
|
|
592
612
|
return () => {
|
|
593
|
-
r.getState().clearSelectedIndex({ stateKey: e, path:
|
|
613
|
+
r.getState().clearSelectedIndex({ stateKey: e, path: n });
|
|
594
614
|
};
|
|
595
|
-
if (
|
|
596
|
-
return () => r.getState().getSelectedIndex(e,
|
|
597
|
-
if (
|
|
598
|
-
return (
|
|
599
|
-
const
|
|
600
|
-
(
|
|
601
|
-
),
|
|
602
|
-
...
|
|
603
|
-
validIndices:
|
|
604
|
-
({ originalIndex:
|
|
615
|
+
if (c === "getSelectedIndex")
|
|
616
|
+
return () => r.getState().getSelectedIndex(e, n.join(".")) ?? -1;
|
|
617
|
+
if (c === "stateSort")
|
|
618
|
+
return (t) => {
|
|
619
|
+
const o = [...l()].sort(
|
|
620
|
+
(f, N) => t(f.item, N.item)
|
|
621
|
+
), d = o.map(({ item: f }) => f), I = {
|
|
622
|
+
...y,
|
|
623
|
+
validIndices: o.map(
|
|
624
|
+
({ originalIndex: f }) => f
|
|
605
625
|
)
|
|
606
626
|
};
|
|
607
|
-
return s(
|
|
627
|
+
return s(d, n, I);
|
|
608
628
|
};
|
|
609
|
-
if (
|
|
610
|
-
return (
|
|
611
|
-
const
|
|
612
|
-
({ item:
|
|
613
|
-
),
|
|
614
|
-
...
|
|
615
|
-
validIndices:
|
|
616
|
-
({ originalIndex:
|
|
629
|
+
if (c === "stateFilter")
|
|
630
|
+
return (t) => {
|
|
631
|
+
const o = l().filter(
|
|
632
|
+
({ item: f }, N) => t(f, N)
|
|
633
|
+
), d = o.map(({ item: f }) => f), I = {
|
|
634
|
+
...y,
|
|
635
|
+
validIndices: o.map(
|
|
636
|
+
({ originalIndex: f }) => f
|
|
617
637
|
)
|
|
618
638
|
};
|
|
619
|
-
return s(
|
|
639
|
+
return s(d, n, I);
|
|
620
640
|
};
|
|
621
|
-
if (
|
|
622
|
-
return (
|
|
641
|
+
if (c === "stateMap" || c === "stateMapNoRender")
|
|
642
|
+
return (t) => m.map((o, d) => {
|
|
623
643
|
let I;
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
return
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
s(
|
|
644
|
+
y?.validIndices && y.validIndices[d] !== void 0 ? I = y.validIndices[d] : I = d;
|
|
645
|
+
const f = [...n, I.toString()], N = s(o, f, y);
|
|
646
|
+
return t(
|
|
647
|
+
o,
|
|
648
|
+
N,
|
|
649
|
+
d,
|
|
650
|
+
m,
|
|
651
|
+
s(m, n, y)
|
|
632
652
|
);
|
|
633
653
|
});
|
|
634
|
-
if (
|
|
635
|
-
return (
|
|
654
|
+
if (c === "$stateMap")
|
|
655
|
+
return (t) => ae(Ge, {
|
|
636
656
|
proxy: {
|
|
637
657
|
_stateKey: e,
|
|
638
|
-
_path:
|
|
639
|
-
_mapFn:
|
|
658
|
+
_path: n,
|
|
659
|
+
_mapFn: t
|
|
640
660
|
// Pass the actual function, not string
|
|
641
661
|
},
|
|
642
662
|
rebuildStateShape: s
|
|
643
663
|
});
|
|
644
|
-
if (
|
|
645
|
-
return (
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
(
|
|
664
|
+
if (c === "stateFlattenOn")
|
|
665
|
+
return (t) => {
|
|
666
|
+
const a = m;
|
|
667
|
+
S.clear(), E++;
|
|
668
|
+
const o = a.flatMap(
|
|
669
|
+
(d) => d[t] ?? []
|
|
650
670
|
);
|
|
651
671
|
return s(
|
|
652
|
-
|
|
653
|
-
[...
|
|
654
|
-
|
|
672
|
+
o,
|
|
673
|
+
[...n, "[*]", t],
|
|
674
|
+
y
|
|
655
675
|
);
|
|
656
676
|
};
|
|
657
|
-
if (
|
|
658
|
-
return (
|
|
659
|
-
const
|
|
660
|
-
return s(
|
|
677
|
+
if (c === "index")
|
|
678
|
+
return (t) => {
|
|
679
|
+
const a = m[t];
|
|
680
|
+
return s(a, [...n, t.toString()]);
|
|
661
681
|
};
|
|
662
|
-
if (
|
|
682
|
+
if (c === "last")
|
|
663
683
|
return () => {
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
667
|
-
return s(
|
|
684
|
+
const t = r.getState().getNestedState(e, n);
|
|
685
|
+
if (t.length === 0) return;
|
|
686
|
+
const a = t.length - 1, o = t[a], d = [...n, a.toString()];
|
|
687
|
+
return s(o, d);
|
|
668
688
|
};
|
|
669
|
-
if (
|
|
670
|
-
return (
|
|
671
|
-
r.getState().getNestedState(e,
|
|
672
|
-
|
|
689
|
+
if (c === "insert")
|
|
690
|
+
return (t) => (p(n), ce(i, t, n, e), s(
|
|
691
|
+
r.getState().getNestedState(e, n),
|
|
692
|
+
n
|
|
673
693
|
));
|
|
674
|
-
if (
|
|
675
|
-
return (
|
|
676
|
-
const
|
|
677
|
-
let
|
|
678
|
-
if (!
|
|
679
|
-
if (
|
|
680
|
-
const
|
|
681
|
-
(
|
|
694
|
+
if (c === "uniqueInsert")
|
|
695
|
+
return (t, a, o) => {
|
|
696
|
+
const d = r.getState().getNestedState(e, n), I = J(t) ? t(d) : t;
|
|
697
|
+
let f = null;
|
|
698
|
+
if (!d.some((w) => {
|
|
699
|
+
if (a) {
|
|
700
|
+
const F = a.every(
|
|
701
|
+
(b) => G(w[b], I[b])
|
|
682
702
|
);
|
|
683
|
-
return
|
|
703
|
+
return F && (f = w), F;
|
|
684
704
|
}
|
|
685
|
-
const
|
|
686
|
-
return
|
|
705
|
+
const $ = G(w, I);
|
|
706
|
+
return $ && (f = w), $;
|
|
687
707
|
}))
|
|
688
|
-
p(
|
|
689
|
-
else if (
|
|
690
|
-
const w =
|
|
691
|
-
(
|
|
708
|
+
p(n), ce(i, I, n, e);
|
|
709
|
+
else if (o && f) {
|
|
710
|
+
const w = o(f), $ = d.map(
|
|
711
|
+
(F) => G(F, f) ? w : F
|
|
692
712
|
);
|
|
693
|
-
p(
|
|
713
|
+
p(n), Q(i, $, n);
|
|
694
714
|
}
|
|
695
715
|
};
|
|
696
|
-
if (
|
|
697
|
-
return (
|
|
698
|
-
if (!
|
|
699
|
-
return p(
|
|
700
|
-
r.getState().getNestedState(e,
|
|
701
|
-
|
|
716
|
+
if (c === "cut")
|
|
717
|
+
return (t, a) => {
|
|
718
|
+
if (!a?.waitForSync)
|
|
719
|
+
return p(n), ee(i, n, e, t), s(
|
|
720
|
+
r.getState().getNestedState(e, n),
|
|
721
|
+
n
|
|
702
722
|
);
|
|
703
723
|
};
|
|
704
|
-
if (
|
|
705
|
-
return (
|
|
706
|
-
for (let
|
|
707
|
-
|
|
724
|
+
if (c === "cutByValue")
|
|
725
|
+
return (t) => {
|
|
726
|
+
for (let a = 0; a < m.length; a++)
|
|
727
|
+
m[a] === t && ee(i, n, e, a);
|
|
708
728
|
};
|
|
709
|
-
if (
|
|
710
|
-
return (
|
|
711
|
-
const
|
|
712
|
-
|
|
729
|
+
if (c === "toggleByValue")
|
|
730
|
+
return (t) => {
|
|
731
|
+
const a = m.findIndex((o) => o === t);
|
|
732
|
+
a > -1 ? ee(i, n, e, a) : ce(i, t, n, e);
|
|
713
733
|
};
|
|
714
|
-
if (
|
|
715
|
-
return (
|
|
716
|
-
const
|
|
717
|
-
({ item: I },
|
|
734
|
+
if (c === "stateFind")
|
|
735
|
+
return (t) => {
|
|
736
|
+
const o = l().find(
|
|
737
|
+
({ item: I }, f) => t(I, f)
|
|
718
738
|
);
|
|
719
|
-
if (!
|
|
720
|
-
const
|
|
721
|
-
return s(
|
|
739
|
+
if (!o) return;
|
|
740
|
+
const d = [...n, o.originalIndex.toString()];
|
|
741
|
+
return s(o.item, d, y);
|
|
722
742
|
};
|
|
723
|
-
if (
|
|
724
|
-
return (
|
|
725
|
-
const
|
|
726
|
-
({ item:
|
|
743
|
+
if (c === "findWith")
|
|
744
|
+
return (t, a) => {
|
|
745
|
+
const d = l().find(
|
|
746
|
+
({ item: f }) => f[t] === a
|
|
727
747
|
);
|
|
728
|
-
if (!
|
|
729
|
-
const I = [...
|
|
730
|
-
return s(
|
|
748
|
+
if (!d) return;
|
|
749
|
+
const I = [...n, d.originalIndex.toString()];
|
|
750
|
+
return s(d.item, I, y);
|
|
731
751
|
};
|
|
732
752
|
}
|
|
733
|
-
const
|
|
734
|
-
if (!isNaN(Number(
|
|
735
|
-
const
|
|
736
|
-
if (Array.isArray(
|
|
753
|
+
const L = n[n.length - 1];
|
|
754
|
+
if (!isNaN(Number(L))) {
|
|
755
|
+
const l = n.slice(0, -1), t = r.getState().getNestedState(e, l);
|
|
756
|
+
if (Array.isArray(t) && c === "cut")
|
|
737
757
|
return () => ee(
|
|
738
758
|
i,
|
|
739
|
-
|
|
759
|
+
l,
|
|
740
760
|
e,
|
|
741
|
-
Number(
|
|
761
|
+
Number(L)
|
|
742
762
|
);
|
|
743
763
|
}
|
|
744
|
-
if (
|
|
745
|
-
return () => r.getState().getNestedState(e,
|
|
746
|
-
if (
|
|
747
|
-
return (
|
|
764
|
+
if (c === "get")
|
|
765
|
+
return () => r.getState().getNestedState(e, n);
|
|
766
|
+
if (c === "$derive")
|
|
767
|
+
return (l) => le({
|
|
748
768
|
_stateKey: e,
|
|
749
|
-
_path:
|
|
750
|
-
_effect:
|
|
769
|
+
_path: n,
|
|
770
|
+
_effect: l.toString()
|
|
751
771
|
});
|
|
752
|
-
if (
|
|
753
|
-
return (
|
|
772
|
+
if (c === "$derive")
|
|
773
|
+
return (l) => le({
|
|
754
774
|
_stateKey: e,
|
|
755
|
-
_path:
|
|
756
|
-
_effect:
|
|
775
|
+
_path: n,
|
|
776
|
+
_effect: l.toString()
|
|
757
777
|
});
|
|
758
|
-
if (
|
|
778
|
+
if (c === "$get")
|
|
759
779
|
return () => le({
|
|
760
780
|
_stateKey: e,
|
|
761
|
-
_path:
|
|
781
|
+
_path: n
|
|
762
782
|
});
|
|
763
|
-
if (
|
|
764
|
-
const
|
|
765
|
-
return r.getState().getSyncInfo(
|
|
783
|
+
if (c === "lastSynced") {
|
|
784
|
+
const l = `${e}:${n.join(".")}`;
|
|
785
|
+
return r.getState().getSyncInfo(l);
|
|
766
786
|
}
|
|
767
|
-
if (
|
|
768
|
-
return (
|
|
769
|
-
if (
|
|
770
|
-
const
|
|
771
|
-
return Array.isArray(
|
|
787
|
+
if (c == "getLocalStorage")
|
|
788
|
+
return (l) => oe(u + "-" + e + "-" + l);
|
|
789
|
+
if (c === "_selected") {
|
|
790
|
+
const l = n.slice(0, -1), t = l.join("."), a = r.getState().getNestedState(e, l);
|
|
791
|
+
return Array.isArray(a) ? Number(n[n.length - 1]) === r.getState().getSelectedIndex(e, t) : void 0;
|
|
772
792
|
}
|
|
773
|
-
if (
|
|
774
|
-
return (
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
const
|
|
778
|
-
|
|
793
|
+
if (c === "setSelected")
|
|
794
|
+
return (l) => {
|
|
795
|
+
const t = n.slice(0, -1), a = Number(n[n.length - 1]), o = t.join(".");
|
|
796
|
+
l ? r.getState().setSelectedIndex(e, o, a) : r.getState().setSelectedIndex(e, o, void 0);
|
|
797
|
+
const d = r.getState().getNestedState(e, [...t]);
|
|
798
|
+
Q(i, d, t), p(t);
|
|
779
799
|
};
|
|
780
|
-
if (
|
|
800
|
+
if (c === "toggleSelected")
|
|
781
801
|
return () => {
|
|
782
|
-
const
|
|
802
|
+
const l = n.slice(0, -1), t = Number(n[n.length - 1]), a = l.join("."), o = r.getState().getSelectedIndex(e, a);
|
|
783
803
|
r.getState().setSelectedIndex(
|
|
784
804
|
e,
|
|
785
|
-
|
|
786
|
-
|
|
805
|
+
a,
|
|
806
|
+
o === t ? void 0 : t
|
|
787
807
|
);
|
|
788
|
-
const
|
|
789
|
-
|
|
808
|
+
const d = r.getState().getNestedState(e, [...l]);
|
|
809
|
+
Q(i, d, l), p(l);
|
|
790
810
|
};
|
|
791
|
-
if (
|
|
792
|
-
if (
|
|
793
|
-
return (
|
|
794
|
-
const
|
|
811
|
+
if (n.length == 0) {
|
|
812
|
+
if (c === "applyJsonPatch")
|
|
813
|
+
return (l) => {
|
|
814
|
+
const t = r.getState().cogsStateStore[e], o = Ce(t, l).newDocument;
|
|
795
815
|
ke(
|
|
796
816
|
e,
|
|
797
817
|
r.getState().initialStateGlobal[e],
|
|
798
|
-
|
|
818
|
+
o,
|
|
799
819
|
i,
|
|
800
|
-
|
|
820
|
+
v,
|
|
801
821
|
u
|
|
802
822
|
);
|
|
803
|
-
const
|
|
804
|
-
if (
|
|
805
|
-
const I = fe(
|
|
823
|
+
const d = r.getState().stateComponents.get(e);
|
|
824
|
+
if (d) {
|
|
825
|
+
const I = fe(t, o), f = new Set(I);
|
|
806
826
|
for (const [
|
|
807
|
-
|
|
827
|
+
N,
|
|
808
828
|
w
|
|
809
|
-
] of
|
|
810
|
-
let
|
|
811
|
-
const
|
|
812
|
-
if (!
|
|
813
|
-
if (
|
|
829
|
+
] of d.components.entries()) {
|
|
830
|
+
let $ = !1;
|
|
831
|
+
const F = Array.isArray(w.reactiveType) ? w.reactiveType : [w.reactiveType || "component"];
|
|
832
|
+
if (!F.includes("none")) {
|
|
833
|
+
if (F.includes("all")) {
|
|
814
834
|
w.forceUpdate();
|
|
815
835
|
continue;
|
|
816
836
|
}
|
|
817
|
-
if (
|
|
818
|
-
for (const
|
|
819
|
-
if (w.paths.has(
|
|
820
|
-
|
|
837
|
+
if (F.includes("component") && (w.paths.has("") && ($ = !0), !$))
|
|
838
|
+
for (const b of f) {
|
|
839
|
+
if (w.paths.has(b)) {
|
|
840
|
+
$ = !0;
|
|
821
841
|
break;
|
|
822
842
|
}
|
|
823
|
-
let
|
|
824
|
-
for (;
|
|
825
|
-
const q =
|
|
843
|
+
let M = b.lastIndexOf(".");
|
|
844
|
+
for (; M !== -1; ) {
|
|
845
|
+
const q = b.substring(0, M);
|
|
826
846
|
if (w.paths.has(q)) {
|
|
827
|
-
|
|
847
|
+
$ = !0;
|
|
828
848
|
break;
|
|
829
849
|
}
|
|
830
|
-
const
|
|
831
|
-
|
|
850
|
+
const R = b.substring(
|
|
851
|
+
M + 1
|
|
832
852
|
);
|
|
833
|
-
if (!isNaN(Number(
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
836
|
-
const
|
|
853
|
+
if (!isNaN(Number(R))) {
|
|
854
|
+
const k = q.lastIndexOf(".");
|
|
855
|
+
if (k !== -1) {
|
|
856
|
+
const O = q.substring(
|
|
837
857
|
0,
|
|
838
|
-
|
|
858
|
+
k
|
|
839
859
|
);
|
|
840
|
-
if (w.paths.has(
|
|
841
|
-
|
|
860
|
+
if (w.paths.has(O)) {
|
|
861
|
+
$ = !0;
|
|
842
862
|
break;
|
|
843
863
|
}
|
|
844
864
|
}
|
|
845
865
|
}
|
|
846
|
-
|
|
866
|
+
M = q.lastIndexOf(".");
|
|
847
867
|
}
|
|
848
|
-
if (
|
|
868
|
+
if ($) break;
|
|
849
869
|
}
|
|
850
|
-
if (
|
|
851
|
-
const
|
|
852
|
-
let
|
|
853
|
-
typeof
|
|
870
|
+
if (!$ && F.includes("deps") && w.depsFunction) {
|
|
871
|
+
const b = w.depsFunction(o);
|
|
872
|
+
let M = !1;
|
|
873
|
+
typeof b == "boolean" ? b && (M = !0) : G(w.deps, b) || (w.deps = b, M = !0), M && ($ = !0);
|
|
854
874
|
}
|
|
855
|
-
|
|
875
|
+
$ && w.forceUpdate();
|
|
856
876
|
}
|
|
857
877
|
}
|
|
858
878
|
}
|
|
859
879
|
};
|
|
860
|
-
if (
|
|
880
|
+
if (c === "validateZodSchema")
|
|
861
881
|
return () => {
|
|
862
|
-
const
|
|
863
|
-
if (!
|
|
882
|
+
const l = r.getState().getInitialOptions(e)?.validation, t = r.getState().addValidationError;
|
|
883
|
+
if (!l?.zodSchema)
|
|
864
884
|
throw new Error("Zod schema not found");
|
|
865
|
-
if (!
|
|
885
|
+
if (!l?.key)
|
|
866
886
|
throw new Error("Validation key not found");
|
|
867
|
-
|
|
868
|
-
const
|
|
887
|
+
B(l.key);
|
|
888
|
+
const a = r.getState().cogsStateStore[e];
|
|
869
889
|
try {
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
I && I.startsWith(
|
|
890
|
+
const o = r.getState().getValidationErrors(l.key);
|
|
891
|
+
o && o.length > 0 && o.forEach(([I]) => {
|
|
892
|
+
I && I.startsWith(l.key) && B(I);
|
|
873
893
|
});
|
|
874
|
-
const
|
|
875
|
-
return
|
|
876
|
-
const
|
|
877
|
-
|
|
894
|
+
const d = l.zodSchema.safeParse(a);
|
|
895
|
+
return d.success ? !0 : (d.error.errors.forEach((f) => {
|
|
896
|
+
const N = f.path, w = f.message, $ = [l.key, ...N].join(".");
|
|
897
|
+
t($, w);
|
|
878
898
|
}), ie(e), !1);
|
|
879
|
-
} catch (
|
|
880
|
-
return console.error("Zod schema validation failed",
|
|
899
|
+
} catch (o) {
|
|
900
|
+
return console.error("Zod schema validation failed", o), !1;
|
|
881
901
|
}
|
|
882
902
|
};
|
|
883
|
-
if (
|
|
884
|
-
if (
|
|
903
|
+
if (c === "_componentId") return v;
|
|
904
|
+
if (c === "getComponents")
|
|
885
905
|
return () => r().stateComponents.get(e);
|
|
886
|
-
if (
|
|
906
|
+
if (c === "getAllFormRefs")
|
|
887
907
|
return () => ve.getState().getFormRefsByStateKey(e);
|
|
888
|
-
if (
|
|
908
|
+
if (c === "_initialState")
|
|
889
909
|
return r.getState().initialStateGlobal[e];
|
|
890
|
-
if (
|
|
910
|
+
if (c === "_serverState")
|
|
891
911
|
return r.getState().serverState[e];
|
|
892
|
-
if (
|
|
912
|
+
if (c === "_isLoading")
|
|
893
913
|
return r.getState().isLoadingGlobal[e];
|
|
894
|
-
if (
|
|
895
|
-
return
|
|
896
|
-
if (
|
|
897
|
-
if (
|
|
914
|
+
if (c === "revertToInitialState")
|
|
915
|
+
return h.revertToInitialState;
|
|
916
|
+
if (c === "updateInitialState") return h.updateInitialState;
|
|
917
|
+
if (c === "removeValidation") return h.removeValidation;
|
|
898
918
|
}
|
|
899
|
-
if (
|
|
900
|
-
return () => ve.getState().getFormRef(e + "." +
|
|
901
|
-
if (
|
|
919
|
+
if (c === "getFormRef")
|
|
920
|
+
return () => ve.getState().getFormRef(e + "." + n.join("."));
|
|
921
|
+
if (c === "validationWrapper")
|
|
902
922
|
return ({
|
|
903
|
-
children:
|
|
904
|
-
hideMessage:
|
|
923
|
+
children: l,
|
|
924
|
+
hideMessage: t
|
|
905
925
|
}) => /* @__PURE__ */ ye(
|
|
906
|
-
|
|
926
|
+
Pe,
|
|
907
927
|
{
|
|
908
|
-
formOpts:
|
|
909
|
-
path:
|
|
928
|
+
formOpts: t ? { validation: { message: "" } } : void 0,
|
|
929
|
+
path: n,
|
|
910
930
|
validationKey: r.getState().getInitialOptions(e)?.validation?.key || "",
|
|
911
931
|
stateKey: e,
|
|
912
|
-
validIndices:
|
|
913
|
-
children:
|
|
932
|
+
validIndices: y?.validIndices,
|
|
933
|
+
children: l
|
|
914
934
|
}
|
|
915
935
|
);
|
|
916
|
-
if (
|
|
917
|
-
if (
|
|
918
|
-
if (
|
|
919
|
-
if (
|
|
920
|
-
return (
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
},
|
|
936
|
+
if (c === "_stateKey") return e;
|
|
937
|
+
if (c === "_path") return n;
|
|
938
|
+
if (c === "_isServerSynced") return h._isServerSynced;
|
|
939
|
+
if (c === "update")
|
|
940
|
+
return (l, t) => {
|
|
941
|
+
if (t?.debounce)
|
|
942
|
+
be(() => {
|
|
943
|
+
Q(i, l, n, "");
|
|
944
|
+
const a = r.getState().getNestedState(e, n);
|
|
945
|
+
t?.afterUpdate && t.afterUpdate(a);
|
|
946
|
+
}, t.debounce);
|
|
927
947
|
else {
|
|
928
|
-
|
|
929
|
-
const
|
|
930
|
-
|
|
948
|
+
Q(i, l, n, "");
|
|
949
|
+
const a = r.getState().getNestedState(e, n);
|
|
950
|
+
t?.afterUpdate && t.afterUpdate(a);
|
|
931
951
|
}
|
|
932
|
-
p(
|
|
952
|
+
p(n);
|
|
933
953
|
};
|
|
934
|
-
if (
|
|
935
|
-
return (
|
|
936
|
-
|
|
954
|
+
if (c === "formElement")
|
|
955
|
+
return (l, t) => /* @__PURE__ */ ye(
|
|
956
|
+
_e,
|
|
937
957
|
{
|
|
938
958
|
setState: i,
|
|
939
959
|
stateKey: e,
|
|
940
|
-
path:
|
|
941
|
-
child:
|
|
942
|
-
formOpts:
|
|
960
|
+
path: n,
|
|
961
|
+
child: l,
|
|
962
|
+
formOpts: t
|
|
943
963
|
}
|
|
944
964
|
);
|
|
945
|
-
const
|
|
946
|
-
return s(
|
|
965
|
+
const A = [...n, c], X = r.getState().getNestedState(e, A);
|
|
966
|
+
return s(X, A, y);
|
|
947
967
|
}
|
|
948
|
-
},
|
|
949
|
-
return
|
|
950
|
-
proxy:
|
|
951
|
-
stateVersion:
|
|
952
|
-
}),
|
|
968
|
+
}, U = new Proxy(_, x);
|
|
969
|
+
return S.set(j, {
|
|
970
|
+
proxy: U,
|
|
971
|
+
stateVersion: E
|
|
972
|
+
}), U;
|
|
953
973
|
}
|
|
954
974
|
return s(
|
|
955
975
|
r.getState().getNestedState(e, [])
|
|
@@ -962,61 +982,61 @@ function Ge({
|
|
|
962
982
|
proxy: e,
|
|
963
983
|
rebuildStateShape: i
|
|
964
984
|
}) {
|
|
965
|
-
const
|
|
966
|
-
return Array.isArray(
|
|
967
|
-
|
|
985
|
+
const v = r().getNestedState(e._stateKey, e._path);
|
|
986
|
+
return Array.isArray(v) ? i(
|
|
987
|
+
v,
|
|
968
988
|
e._path
|
|
969
989
|
).stateMapNoRender(
|
|
970
|
-
(
|
|
990
|
+
(S, E, p, h, s) => e._mapFn(S, E, p, h, s)
|
|
971
991
|
) : null;
|
|
972
992
|
}
|
|
973
993
|
function We({
|
|
974
994
|
proxy: e
|
|
975
995
|
}) {
|
|
976
|
-
const i = te(null),
|
|
996
|
+
const i = te(null), v = `${e._stateKey}-${e._path.join(".")}`;
|
|
977
997
|
return ue(() => {
|
|
978
998
|
const u = i.current;
|
|
979
999
|
if (!u || !u.parentElement) return;
|
|
980
|
-
const
|
|
981
|
-
let
|
|
982
|
-
|
|
983
|
-
const
|
|
1000
|
+
const S = u.parentElement, p = Array.from(S.childNodes).indexOf(u);
|
|
1001
|
+
let h = S.getAttribute("data-parent-id");
|
|
1002
|
+
h || (h = `parent-${crypto.randomUUID()}`, S.setAttribute("data-parent-id", h));
|
|
1003
|
+
const m = {
|
|
984
1004
|
instanceId: `instance-${crypto.randomUUID()}`,
|
|
985
|
-
parentId:
|
|
1005
|
+
parentId: h,
|
|
986
1006
|
position: p,
|
|
987
1007
|
effect: e._effect
|
|
988
1008
|
};
|
|
989
|
-
r.getState().addSignalElement(
|
|
990
|
-
const
|
|
991
|
-
let
|
|
1009
|
+
r.getState().addSignalElement(v, m);
|
|
1010
|
+
const n = r.getState().getNestedState(e._stateKey, e._path);
|
|
1011
|
+
let y;
|
|
992
1012
|
if (e._effect)
|
|
993
1013
|
try {
|
|
994
|
-
|
|
1014
|
+
y = new Function(
|
|
995
1015
|
"state",
|
|
996
1016
|
`return (${e._effect})(state)`
|
|
997
|
-
)(
|
|
998
|
-
} catch (
|
|
999
|
-
console.error("Error evaluating effect function during mount:",
|
|
1017
|
+
)(n);
|
|
1018
|
+
} catch (_) {
|
|
1019
|
+
console.error("Error evaluating effect function during mount:", _), y = n;
|
|
1000
1020
|
}
|
|
1001
1021
|
else
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const
|
|
1005
|
-
u.replaceWith(
|
|
1022
|
+
y = n;
|
|
1023
|
+
y !== null && typeof y == "object" && (y = JSON.stringify(y));
|
|
1024
|
+
const j = document.createTextNode(String(y));
|
|
1025
|
+
u.replaceWith(j);
|
|
1006
1026
|
}, [e._stateKey, e._path.join("."), e._effect]), ae("span", {
|
|
1007
1027
|
ref: i,
|
|
1008
1028
|
style: { display: "none" },
|
|
1009
|
-
"data-signal-id":
|
|
1029
|
+
"data-signal-id": v
|
|
1010
1030
|
});
|
|
1011
1031
|
}
|
|
1012
1032
|
function nt(e) {
|
|
1013
|
-
const i =
|
|
1014
|
-
(
|
|
1033
|
+
const i = Ve(
|
|
1034
|
+
(v) => {
|
|
1015
1035
|
const u = r.getState().stateComponents.get(e._stateKey) || {
|
|
1016
1036
|
components: /* @__PURE__ */ new Map()
|
|
1017
1037
|
};
|
|
1018
1038
|
return u.components.set(e._stateKey, {
|
|
1019
|
-
forceUpdate:
|
|
1039
|
+
forceUpdate: v,
|
|
1020
1040
|
paths: /* @__PURE__ */ new Set([e._path.join(".")])
|
|
1021
1041
|
}), () => u.components.delete(e._stateKey);
|
|
1022
1042
|
},
|
|
@@ -1030,6 +1050,6 @@ export {
|
|
|
1030
1050
|
Ke as addStateOptions,
|
|
1031
1051
|
et as createCogsState,
|
|
1032
1052
|
tt as notifyComponent,
|
|
1033
|
-
|
|
1053
|
+
De as useCogsStateFn
|
|
1034
1054
|
};
|
|
1035
1055
|
//# sourceMappingURL=CogsState.jsx.map
|