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