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