cogsbox-state 0.5.237 → 0.5.239
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 +482 -467
- package/dist/CogsState.jsx.map +1 -1
- package/dist/store.d.ts +0 -1
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +27 -10
- package/src/store.ts +0 -1
package/dist/CogsState.jsx
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as te, useRef as ee, useEffect as ce, useLayoutEffect as
|
|
4
|
-
import { transformStateFunc as
|
|
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 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
|
-
import { getGlobalStore as n, formRefStore as
|
|
10
|
-
import { useCogsConfig as
|
|
9
|
+
import { getGlobalStore as n, formRefStore as Se } from "./store.js";
|
|
10
|
+
import { useCogsConfig as Te } from "./CogsStateClient.jsx";
|
|
11
11
|
import { applyPatch as xe } from "fast-json-patch";
|
|
12
|
-
function
|
|
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
|
-
function
|
|
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 [
|
|
49
|
-
|
|
50
|
-
stateKey:
|
|
47
|
+
const b = (h, s) => {
|
|
48
|
+
const [p] = te(s?.componentId ?? de());
|
|
49
|
+
ye({
|
|
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
|
-
|
|
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
80
|
getKeyState: be,
|
|
81
|
-
getValidationErrors:
|
|
82
|
-
setStateLog:
|
|
83
|
-
updateInitialStateGlobal:
|
|
81
|
+
getValidationErrors: Oe,
|
|
82
|
+
setStateLog: je,
|
|
83
|
+
updateInitialStateGlobal: ge,
|
|
84
84
|
addValidationError: Fe,
|
|
85
|
-
removeValidationError:
|
|
86
|
-
setServerSyncActions:
|
|
87
|
-
} = n.getState(),
|
|
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
|
-
}, we = (e,
|
|
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,237 +179,237 @@ const et = (e, o) => {
|
|
|
179
179
|
return { oldValue: null, newValue: null };
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
-
function
|
|
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
|
-
|
|
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,
|
|
264
264
|
m?.status,
|
|
265
265
|
m?.data,
|
|
266
266
|
...r || []
|
|
267
|
-
]),
|
|
268
|
-
|
|
267
|
+
]), Ie(() => {
|
|
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(
|
|
400
|
-
}),
|
|
399
|
+
return Array.from(j.values());
|
|
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 [be(
|
|
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
|
-
|
|
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,18 +525,35 @@ 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
|
|
528
|
+
const u = `${e}////${S}`, t = n.getState().stateComponents.get(e);
|
|
529
529
|
if (t) {
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
const
|
|
533
|
-
let
|
|
534
|
-
for (const
|
|
535
|
-
if (
|
|
536
|
-
|
|
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
|
-
|
|
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);
|
|
556
|
+
}
|
|
540
557
|
}
|
|
541
558
|
}
|
|
542
559
|
}
|
|
@@ -547,65 +564,65 @@ function re(e, o, S, l) {
|
|
|
547
564
|
);
|
|
548
565
|
if (d === "sync" && r.length === 0)
|
|
549
566
|
return async function() {
|
|
550
|
-
const
|
|
567
|
+
const u = n.getState().getInitialOptions(e), t = u?.sync;
|
|
551
568
|
if (!t)
|
|
552
569
|
return console.error(`No mutation defined for state key "${e}"`), { success: !1, error: "No mutation defined" };
|
|
553
|
-
const
|
|
570
|
+
const o = n.getState().getNestedState(e, []), a = u?.validation?.key;
|
|
554
571
|
try {
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
n.getState().removeValidationError(
|
|
558
|
-
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(".");
|
|
559
576
|
n.getState().addValidationError(A, f.message);
|
|
560
577
|
});
|
|
561
|
-
const
|
|
562
|
-
|
|
578
|
+
const y = n.getState().stateComponents.get(e);
|
|
579
|
+
y && y.components.forEach((f) => {
|
|
563
580
|
f.forceUpdate();
|
|
564
581
|
});
|
|
565
582
|
}
|
|
566
|
-
return
|
|
567
|
-
} catch (
|
|
568
|
-
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 };
|
|
569
586
|
}
|
|
570
587
|
};
|
|
571
588
|
if (d === "_status") {
|
|
572
|
-
const
|
|
573
|
-
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";
|
|
574
591
|
}
|
|
575
592
|
if (d === "getStatus")
|
|
576
593
|
return function() {
|
|
577
|
-
const
|
|
594
|
+
const u = n().getNestedState(
|
|
578
595
|
e,
|
|
579
596
|
r
|
|
580
|
-
), t = n.getState().initialStateGlobal[e],
|
|
581
|
-
return G(
|
|
597
|
+
), t = n.getState().initialStateGlobal[e], o = W(t, r);
|
|
598
|
+
return G(u, o) ? "fresh" : "stale";
|
|
582
599
|
};
|
|
583
600
|
if (d === "removeStorage")
|
|
584
601
|
return () => {
|
|
585
|
-
const
|
|
586
|
-
|
|
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);
|
|
587
604
|
};
|
|
588
605
|
if (d === "showValidationErrors")
|
|
589
606
|
return () => {
|
|
590
|
-
const
|
|
591
|
-
if (!
|
|
607
|
+
const u = n.getState().getInitialOptions(e)?.validation;
|
|
608
|
+
if (!u?.key)
|
|
592
609
|
throw new Error("Validation key not found");
|
|
593
|
-
return n.getState().getValidationErrors(
|
|
610
|
+
return n.getState().getValidationErrors(u.key + "." + r.join("."));
|
|
594
611
|
};
|
|
595
|
-
if (Array.isArray(
|
|
596
|
-
const
|
|
597
|
-
item:
|
|
598
|
-
originalIndex: m.validIndices[
|
|
599
|
-
})) : n.getState().getNestedState(e, r).map((
|
|
600
|
-
item:
|
|
601
|
-
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
|
|
602
619
|
}));
|
|
603
620
|
if (d === "getSelected")
|
|
604
621
|
return () => {
|
|
605
622
|
const t = n.getState().getSelectedIndex(e, r.join("."));
|
|
606
623
|
if (t !== void 0)
|
|
607
624
|
return s(
|
|
608
|
-
|
|
625
|
+
p[t],
|
|
609
626
|
[...r, t.toString()],
|
|
610
627
|
m
|
|
611
628
|
);
|
|
@@ -618,39 +635,39 @@ function re(e, o, S, l) {
|
|
|
618
635
|
return () => n.getState().getSelectedIndex(e, r.join(".")) ?? -1;
|
|
619
636
|
if (d === "stateSort")
|
|
620
637
|
return (t) => {
|
|
621
|
-
const
|
|
638
|
+
const a = [...u()].sort(
|
|
622
639
|
(f, A) => t(f.item, A.item)
|
|
623
|
-
),
|
|
640
|
+
), g = a.map(({ item: f }) => f), y = {
|
|
624
641
|
...m,
|
|
625
|
-
validIndices:
|
|
642
|
+
validIndices: a.map(
|
|
626
643
|
({ originalIndex: f }) => f
|
|
627
644
|
)
|
|
628
645
|
};
|
|
629
|
-
return s(
|
|
646
|
+
return s(g, r, y);
|
|
630
647
|
};
|
|
631
648
|
if (d === "stateFilter")
|
|
632
649
|
return (t) => {
|
|
633
|
-
const
|
|
650
|
+
const a = u().filter(
|
|
634
651
|
({ item: f }, A) => t(f, A)
|
|
635
|
-
),
|
|
652
|
+
), g = a.map(({ item: f }) => f), y = {
|
|
636
653
|
...m,
|
|
637
|
-
validIndices:
|
|
654
|
+
validIndices: a.map(
|
|
638
655
|
({ originalIndex: f }) => f
|
|
639
656
|
)
|
|
640
657
|
};
|
|
641
|
-
return s(
|
|
658
|
+
return s(g, r, y);
|
|
642
659
|
};
|
|
643
660
|
if (d === "stateMap")
|
|
644
661
|
return (t) => {
|
|
645
|
-
const
|
|
646
|
-
return Array.isArray(
|
|
647
|
-
let
|
|
648
|
-
m?.validIndices && m.validIndices[
|
|
649
|
-
const f = [...r,
|
|
650
|
-
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, {
|
|
651
668
|
register: () => {
|
|
652
|
-
const [,
|
|
653
|
-
|
|
669
|
+
const [, w] = te({}), C = `${S}-${r.join(".")}-${y}`;
|
|
670
|
+
Ie(() => {
|
|
654
671
|
const $ = `${e}////${C}`, _ = n.getState().stateComponents.get(e) || {
|
|
655
672
|
components: /* @__PURE__ */ new Map(),
|
|
656
673
|
pathTrie: {
|
|
@@ -659,13 +676,12 @@ function re(e, o, S, l) {
|
|
|
659
676
|
}
|
|
660
677
|
};
|
|
661
678
|
return _.components.set($, {
|
|
662
|
-
forceUpdate: () =>
|
|
679
|
+
forceUpdate: () => w({}),
|
|
663
680
|
paths: /* @__PURE__ */ new Set([f.join(".")]),
|
|
664
681
|
deps: [],
|
|
665
682
|
depsFunction: void 0,
|
|
666
|
-
reactiveType: ["component"]
|
|
667
|
-
|
|
668
|
-
}), _.pathTrie && Te(
|
|
683
|
+
reactiveType: ["component"]
|
|
684
|
+
}), _.pathTrie && ue(
|
|
669
685
|
_.pathTrie,
|
|
670
686
|
f.join("."),
|
|
671
687
|
$
|
|
@@ -679,29 +695,29 @@ function re(e, o, S, l) {
|
|
|
679
695
|
};
|
|
680
696
|
}, [e, C]);
|
|
681
697
|
},
|
|
682
|
-
index:
|
|
683
|
-
originalIndex:
|
|
698
|
+
index: g,
|
|
699
|
+
originalIndex: y
|
|
684
700
|
});
|
|
685
701
|
}) : (console.warn(
|
|
686
702
|
`stateMap called on a non-array value at path: ${r.join(".")}. The current value is:`,
|
|
687
|
-
|
|
703
|
+
o
|
|
688
704
|
), null);
|
|
689
705
|
};
|
|
690
706
|
if (d === "stateMapNoRender")
|
|
691
|
-
return (t) =>
|
|
692
|
-
let
|
|
693
|
-
m?.validIndices && m.validIndices[
|
|
694
|
-
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);
|
|
695
711
|
return t(
|
|
696
|
-
|
|
712
|
+
a,
|
|
697
713
|
A,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
s(
|
|
714
|
+
g,
|
|
715
|
+
p,
|
|
716
|
+
s(p, r, m)
|
|
701
717
|
);
|
|
702
718
|
});
|
|
703
719
|
if (d === "$stateMap")
|
|
704
|
-
return (t) =>
|
|
720
|
+
return (t) => oe(Ge, {
|
|
705
721
|
proxy: {
|
|
706
722
|
_stateKey: e,
|
|
707
723
|
_path: r,
|
|
@@ -712,100 +728,100 @@ function re(e, o, S, l) {
|
|
|
712
728
|
});
|
|
713
729
|
if (d === "stateFlattenOn")
|
|
714
730
|
return (t) => {
|
|
715
|
-
const
|
|
716
|
-
c.clear(),
|
|
717
|
-
const
|
|
718
|
-
(
|
|
731
|
+
const o = p;
|
|
732
|
+
c.clear(), b++;
|
|
733
|
+
const a = o.flatMap(
|
|
734
|
+
(g) => g[t] ?? []
|
|
719
735
|
);
|
|
720
736
|
return s(
|
|
721
|
-
|
|
737
|
+
a,
|
|
722
738
|
[...r, "[*]", t],
|
|
723
739
|
m
|
|
724
740
|
);
|
|
725
741
|
};
|
|
726
742
|
if (d === "index")
|
|
727
743
|
return (t) => {
|
|
728
|
-
const
|
|
729
|
-
return s(
|
|
744
|
+
const o = p[t];
|
|
745
|
+
return s(o, [...r, t.toString()]);
|
|
730
746
|
};
|
|
731
747
|
if (d === "last")
|
|
732
748
|
return () => {
|
|
733
749
|
const t = n.getState().getNestedState(e, r);
|
|
734
750
|
if (t.length === 0) return;
|
|
735
|
-
const
|
|
736
|
-
return s(
|
|
751
|
+
const o = t.length - 1, a = t[o], g = [...r, o.toString()];
|
|
752
|
+
return s(a, g);
|
|
737
753
|
};
|
|
738
754
|
if (d === "insert")
|
|
739
|
-
return (t) => (I(r), se(
|
|
755
|
+
return (t) => (I(r), se(i, t, r, e), s(
|
|
740
756
|
n.getState().getNestedState(e, r),
|
|
741
757
|
r
|
|
742
758
|
));
|
|
743
759
|
if (d === "uniqueInsert")
|
|
744
|
-
return (t,
|
|
745
|
-
const
|
|
760
|
+
return (t, o, a) => {
|
|
761
|
+
const g = n.getState().getNestedState(e, r), y = z(t) ? t(g) : t;
|
|
746
762
|
let f = null;
|
|
747
|
-
if (!
|
|
748
|
-
if (
|
|
749
|
-
const C =
|
|
750
|
-
($) => G(
|
|
763
|
+
if (!g.some((T) => {
|
|
764
|
+
if (o) {
|
|
765
|
+
const C = o.every(
|
|
766
|
+
($) => G(T[$], y[$])
|
|
751
767
|
);
|
|
752
|
-
return C && (f =
|
|
768
|
+
return C && (f = T), C;
|
|
753
769
|
}
|
|
754
|
-
const
|
|
755
|
-
return
|
|
770
|
+
const w = G(T, y);
|
|
771
|
+
return w && (f = T), w;
|
|
756
772
|
}))
|
|
757
|
-
I(r), se(
|
|
758
|
-
else if (
|
|
759
|
-
const
|
|
760
|
-
(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
|
|
761
777
|
);
|
|
762
|
-
I(r), X(
|
|
778
|
+
I(r), X(i, w, r);
|
|
763
779
|
}
|
|
764
780
|
};
|
|
765
781
|
if (d === "cut")
|
|
766
|
-
return (t,
|
|
767
|
-
if (!
|
|
768
|
-
return I(r), K(
|
|
782
|
+
return (t, o) => {
|
|
783
|
+
if (!o?.waitForSync)
|
|
784
|
+
return I(r), K(i, r, e, t), s(
|
|
769
785
|
n.getState().getNestedState(e, r),
|
|
770
786
|
r
|
|
771
787
|
);
|
|
772
788
|
};
|
|
773
789
|
if (d === "cutByValue")
|
|
774
790
|
return (t) => {
|
|
775
|
-
for (let
|
|
776
|
-
|
|
791
|
+
for (let o = 0; o < p.length; o++)
|
|
792
|
+
p[o] === t && K(i, r, e, o);
|
|
777
793
|
};
|
|
778
794
|
if (d === "toggleByValue")
|
|
779
795
|
return (t) => {
|
|
780
|
-
const
|
|
781
|
-
|
|
796
|
+
const o = p.findIndex((a) => a === t);
|
|
797
|
+
o > -1 ? K(i, r, e, o) : se(i, t, r, e);
|
|
782
798
|
};
|
|
783
799
|
if (d === "stateFind")
|
|
784
800
|
return (t) => {
|
|
785
|
-
const
|
|
786
|
-
({ item:
|
|
801
|
+
const a = u().find(
|
|
802
|
+
({ item: y }, f) => t(y, f)
|
|
787
803
|
);
|
|
788
|
-
if (!
|
|
789
|
-
const
|
|
790
|
-
return s(
|
|
804
|
+
if (!a) return;
|
|
805
|
+
const g = [...r, a.originalIndex.toString()];
|
|
806
|
+
return s(a.item, g, m);
|
|
791
807
|
};
|
|
792
808
|
if (d === "findWith")
|
|
793
|
-
return (t,
|
|
794
|
-
const
|
|
795
|
-
({ item: f }) => f[t] ===
|
|
809
|
+
return (t, o) => {
|
|
810
|
+
const g = u().find(
|
|
811
|
+
({ item: f }) => f[t] === o
|
|
796
812
|
);
|
|
797
|
-
if (!
|
|
798
|
-
const
|
|
799
|
-
return s(
|
|
813
|
+
if (!g) return;
|
|
814
|
+
const y = [...r, g.originalIndex.toString()];
|
|
815
|
+
return s(g.item, y, m);
|
|
800
816
|
};
|
|
801
817
|
}
|
|
802
818
|
const L = r[r.length - 1];
|
|
803
819
|
if (!isNaN(Number(L))) {
|
|
804
|
-
const
|
|
820
|
+
const u = r.slice(0, -1), t = n.getState().getNestedState(e, u);
|
|
805
821
|
if (Array.isArray(t) && d === "cut")
|
|
806
822
|
return () => K(
|
|
807
|
-
|
|
808
|
-
|
|
823
|
+
i,
|
|
824
|
+
u,
|
|
809
825
|
e,
|
|
810
826
|
Number(L)
|
|
811
827
|
);
|
|
@@ -813,10 +829,10 @@ function re(e, o, S, l) {
|
|
|
813
829
|
if (d === "get")
|
|
814
830
|
return () => n.getState().getNestedState(e, r);
|
|
815
831
|
if (d === "$derive")
|
|
816
|
-
return (
|
|
832
|
+
return (u) => he({
|
|
817
833
|
_stateKey: e,
|
|
818
834
|
_path: r,
|
|
819
|
-
_effect:
|
|
835
|
+
_effect: u.toString()
|
|
820
836
|
});
|
|
821
837
|
if (d === "$get")
|
|
822
838
|
return () => he({
|
|
@@ -824,130 +840,130 @@ function re(e, o, S, l) {
|
|
|
824
840
|
_path: r
|
|
825
841
|
});
|
|
826
842
|
if (d === "lastSynced") {
|
|
827
|
-
const
|
|
828
|
-
return n.getState().getSyncInfo(
|
|
843
|
+
const u = `${e}:${r.join(".")}`;
|
|
844
|
+
return n.getState().getSyncInfo(u);
|
|
829
845
|
}
|
|
830
846
|
if (d == "getLocalStorage")
|
|
831
|
-
return (
|
|
847
|
+
return (u) => ae(l + "-" + e + "-" + u);
|
|
832
848
|
if (d === "_selected") {
|
|
833
|
-
const
|
|
834
|
-
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;
|
|
835
851
|
}
|
|
836
852
|
if (d === "setSelected")
|
|
837
|
-
return (
|
|
838
|
-
const t = r.slice(0, -1),
|
|
839
|
-
|
|
840
|
-
const
|
|
841
|
-
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);
|
|
842
858
|
};
|
|
843
859
|
if (d === "toggleSelected")
|
|
844
860
|
return () => {
|
|
845
|
-
const
|
|
861
|
+
const u = r.slice(0, -1), t = Number(r[r.length - 1]), o = u.join("."), a = n.getState().getSelectedIndex(e, o);
|
|
846
862
|
n.getState().setSelectedIndex(
|
|
847
863
|
e,
|
|
848
|
-
|
|
849
|
-
|
|
864
|
+
o,
|
|
865
|
+
a === t ? void 0 : t
|
|
850
866
|
);
|
|
851
|
-
const
|
|
852
|
-
X(
|
|
867
|
+
const g = n.getState().getNestedState(e, [...u]);
|
|
868
|
+
X(i, g, u), I(u);
|
|
853
869
|
};
|
|
854
870
|
if (r.length == 0) {
|
|
855
871
|
if (d === "applyJsonPatch")
|
|
856
|
-
return (
|
|
857
|
-
const t = n.getState().cogsStateStore[e],
|
|
872
|
+
return (u) => {
|
|
873
|
+
const t = n.getState().cogsStateStore[e], a = xe(t, u).newDocument;
|
|
858
874
|
we(
|
|
859
875
|
e,
|
|
860
876
|
n.getState().initialStateGlobal[e],
|
|
877
|
+
a,
|
|
861
878
|
i,
|
|
862
|
-
o,
|
|
863
879
|
S,
|
|
864
880
|
l
|
|
865
881
|
);
|
|
866
|
-
const
|
|
867
|
-
if (
|
|
868
|
-
const
|
|
882
|
+
const g = n.getState().stateComponents.get(e);
|
|
883
|
+
if (g) {
|
|
884
|
+
const y = le(t, a), f = new Set(y);
|
|
869
885
|
for (const [
|
|
870
886
|
A,
|
|
871
|
-
|
|
872
|
-
] of
|
|
873
|
-
let
|
|
874
|
-
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"];
|
|
875
891
|
if (!C.includes("none")) {
|
|
876
892
|
if (C.includes("all")) {
|
|
877
|
-
|
|
893
|
+
T.forceUpdate();
|
|
878
894
|
continue;
|
|
879
895
|
}
|
|
880
|
-
if (C.includes("component") && (
|
|
896
|
+
if (C.includes("component") && (T.paths.has("") && (w = !0), !w))
|
|
881
897
|
for (const $ of f) {
|
|
882
|
-
if (
|
|
883
|
-
|
|
898
|
+
if (T.paths.has($)) {
|
|
899
|
+
w = !0;
|
|
884
900
|
break;
|
|
885
901
|
}
|
|
886
902
|
let _ = $.lastIndexOf(".");
|
|
887
903
|
for (; _ !== -1; ) {
|
|
888
904
|
const F = $.substring(0, _);
|
|
889
|
-
if (
|
|
890
|
-
|
|
905
|
+
if (T.paths.has(F)) {
|
|
906
|
+
w = !0;
|
|
891
907
|
break;
|
|
892
908
|
}
|
|
893
|
-
const
|
|
909
|
+
const R = $.substring(
|
|
894
910
|
_ + 1
|
|
895
911
|
);
|
|
896
|
-
if (!isNaN(Number(
|
|
912
|
+
if (!isNaN(Number(R))) {
|
|
897
913
|
const E = F.lastIndexOf(".");
|
|
898
914
|
if (E !== -1) {
|
|
899
|
-
const
|
|
915
|
+
const j = F.substring(
|
|
900
916
|
0,
|
|
901
917
|
E
|
|
902
918
|
);
|
|
903
|
-
if (
|
|
904
|
-
|
|
919
|
+
if (T.paths.has(j)) {
|
|
920
|
+
w = !0;
|
|
905
921
|
break;
|
|
906
922
|
}
|
|
907
923
|
}
|
|
908
924
|
}
|
|
909
925
|
_ = F.lastIndexOf(".");
|
|
910
926
|
}
|
|
911
|
-
if (
|
|
927
|
+
if (w) break;
|
|
912
928
|
}
|
|
913
|
-
if (!
|
|
914
|
-
const $ =
|
|
929
|
+
if (!w && C.includes("deps") && T.depsFunction) {
|
|
930
|
+
const $ = T.depsFunction(a);
|
|
915
931
|
let _ = !1;
|
|
916
|
-
typeof $ == "boolean" ? $ && (_ = !0) : G(
|
|
932
|
+
typeof $ == "boolean" ? $ && (_ = !0) : G(T.deps, $) || (T.deps = $, _ = !0), _ && (w = !0);
|
|
917
933
|
}
|
|
918
|
-
|
|
934
|
+
w && T.forceUpdate();
|
|
919
935
|
}
|
|
920
936
|
}
|
|
921
937
|
}
|
|
922
938
|
};
|
|
923
939
|
if (d === "validateZodSchema")
|
|
924
940
|
return () => {
|
|
925
|
-
const
|
|
926
|
-
if (!
|
|
941
|
+
const u = n.getState().getInitialOptions(e)?.validation, t = n.getState().addValidationError;
|
|
942
|
+
if (!u?.zodSchema)
|
|
927
943
|
throw new Error("Zod schema not found");
|
|
928
|
-
if (!
|
|
944
|
+
if (!u?.key)
|
|
929
945
|
throw new Error("Validation key not found");
|
|
930
|
-
|
|
931
|
-
const
|
|
946
|
+
q(u.key);
|
|
947
|
+
const o = n.getState().cogsStateStore[e];
|
|
932
948
|
try {
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
949
|
+
const a = n.getState().getValidationErrors(u.key);
|
|
950
|
+
a && a.length > 0 && a.forEach(([y]) => {
|
|
951
|
+
y && y.startsWith(u.key) && q(y);
|
|
936
952
|
});
|
|
937
|
-
const
|
|
938
|
-
return
|
|
939
|
-
const A = f.path,
|
|
940
|
-
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);
|
|
941
957
|
}), ie(e), !1);
|
|
942
|
-
} catch (
|
|
943
|
-
return console.error("Zod schema validation failed",
|
|
958
|
+
} catch (a) {
|
|
959
|
+
return console.error("Zod schema validation failed", a), !1;
|
|
944
960
|
}
|
|
945
961
|
};
|
|
946
962
|
if (d === "_componentId") return S;
|
|
947
963
|
if (d === "getComponents")
|
|
948
964
|
return () => n().stateComponents.get(e);
|
|
949
965
|
if (d === "getAllFormRefs")
|
|
950
|
-
return () =>
|
|
966
|
+
return () => Se.getState().getFormRefsByStateKey(e);
|
|
951
967
|
if (d === "_initialState")
|
|
952
968
|
return n.getState().initialStateGlobal[e];
|
|
953
969
|
if (d === "_serverState")
|
|
@@ -955,17 +971,17 @@ function re(e, o, S, l) {
|
|
|
955
971
|
if (d === "_isLoading")
|
|
956
972
|
return n.getState().isLoadingGlobal[e];
|
|
957
973
|
if (d === "revertToInitialState")
|
|
958
|
-
return
|
|
959
|
-
if (d === "updateInitialState") return
|
|
960
|
-
if (d === "removeValidation") return
|
|
974
|
+
return h.revertToInitialState;
|
|
975
|
+
if (d === "updateInitialState") return h.updateInitialState;
|
|
976
|
+
if (d === "removeValidation") return h.removeValidation;
|
|
961
977
|
}
|
|
962
978
|
if (d === "getFormRef")
|
|
963
|
-
return () =>
|
|
979
|
+
return () => Se.getState().getFormRef(e + "." + r.join("."));
|
|
964
980
|
if (d === "validationWrapper")
|
|
965
981
|
return ({
|
|
966
|
-
children:
|
|
982
|
+
children: u,
|
|
967
983
|
hideMessage: t
|
|
968
|
-
}) => /* @__PURE__ */
|
|
984
|
+
}) => /* @__PURE__ */ fe(
|
|
969
985
|
Ce,
|
|
970
986
|
{
|
|
971
987
|
formOpts: t ? { validation: { message: "" } } : void 0,
|
|
@@ -973,83 +989,83 @@ function re(e, o, S, l) {
|
|
|
973
989
|
validationKey: n.getState().getInitialOptions(e)?.validation?.key || "",
|
|
974
990
|
stateKey: e,
|
|
975
991
|
validIndices: m?.validIndices,
|
|
976
|
-
children:
|
|
992
|
+
children: u
|
|
977
993
|
}
|
|
978
994
|
);
|
|
979
995
|
if (d === "_stateKey") return e;
|
|
980
996
|
if (d === "_path") return r;
|
|
981
|
-
if (d === "_isServerSynced") return
|
|
997
|
+
if (d === "_isServerSynced") return h._isServerSynced;
|
|
982
998
|
if (d === "update")
|
|
983
|
-
return (
|
|
999
|
+
return (u, t) => {
|
|
984
1000
|
if (t?.debounce)
|
|
985
|
-
|
|
986
|
-
X(
|
|
987
|
-
const
|
|
988
|
-
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);
|
|
989
1005
|
}, t.debounce);
|
|
990
1006
|
else {
|
|
991
|
-
X(
|
|
992
|
-
const
|
|
993
|
-
t?.afterUpdate && t.afterUpdate(
|
|
1007
|
+
X(i, u, r, "");
|
|
1008
|
+
const o = n.getState().getNestedState(e, r);
|
|
1009
|
+
t?.afterUpdate && t.afterUpdate(o);
|
|
994
1010
|
}
|
|
995
1011
|
I(r);
|
|
996
1012
|
};
|
|
997
1013
|
if (d === "formElement")
|
|
998
|
-
return (
|
|
1014
|
+
return (u, t) => /* @__PURE__ */ fe(
|
|
999
1015
|
_e,
|
|
1000
1016
|
{
|
|
1001
|
-
setState:
|
|
1017
|
+
setState: i,
|
|
1002
1018
|
stateKey: e,
|
|
1003
1019
|
path: r,
|
|
1004
|
-
child:
|
|
1020
|
+
child: u,
|
|
1005
1021
|
formOpts: t
|
|
1006
1022
|
}
|
|
1007
1023
|
);
|
|
1008
|
-
const
|
|
1009
|
-
return s(H,
|
|
1024
|
+
const k = [...r, d], H = n.getState().getNestedState(e, k);
|
|
1025
|
+
return s(H, k, m);
|
|
1010
1026
|
}
|
|
1011
|
-
},
|
|
1012
|
-
return c.set(
|
|
1013
|
-
proxy:
|
|
1014
|
-
stateVersion:
|
|
1015
|
-
}),
|
|
1027
|
+
}, M = new Proxy(x, O);
|
|
1028
|
+
return c.set(D, {
|
|
1029
|
+
proxy: M,
|
|
1030
|
+
stateVersion: b
|
|
1031
|
+
}), M;
|
|
1016
1032
|
}
|
|
1017
1033
|
return s(
|
|
1018
1034
|
n.getState().getNestedState(e, [])
|
|
1019
1035
|
);
|
|
1020
1036
|
}
|
|
1021
1037
|
function he(e) {
|
|
1022
|
-
return
|
|
1038
|
+
return oe(We, { proxy: e });
|
|
1023
1039
|
}
|
|
1024
1040
|
function Ge({
|
|
1025
1041
|
proxy: e,
|
|
1026
|
-
rebuildStateShape:
|
|
1042
|
+
rebuildStateShape: i
|
|
1027
1043
|
}) {
|
|
1028
1044
|
const S = n().getNestedState(e._stateKey, e._path);
|
|
1029
|
-
return Array.isArray(S) ?
|
|
1045
|
+
return Array.isArray(S) ? i(
|
|
1030
1046
|
S,
|
|
1031
1047
|
e._path
|
|
1032
1048
|
).stateMapNoRender(
|
|
1033
|
-
(c,
|
|
1049
|
+
(c, b, I, h, s) => e._mapFn(c, b, I, h, s)
|
|
1034
1050
|
) : null;
|
|
1035
1051
|
}
|
|
1036
1052
|
function We({
|
|
1037
1053
|
proxy: e
|
|
1038
1054
|
}) {
|
|
1039
|
-
const
|
|
1055
|
+
const i = ee(null), S = `${e._stateKey}-${e._path.join(".")}`;
|
|
1040
1056
|
return ce(() => {
|
|
1041
|
-
const l =
|
|
1057
|
+
const l = i.current;
|
|
1042
1058
|
if (!l || !l.parentElement) return;
|
|
1043
1059
|
const c = l.parentElement, I = Array.from(c.childNodes).indexOf(l);
|
|
1044
|
-
let
|
|
1045
|
-
|
|
1046
|
-
const
|
|
1060
|
+
let h = c.getAttribute("data-parent-id");
|
|
1061
|
+
h || (h = `parent-${crypto.randomUUID()}`, c.setAttribute("data-parent-id", h));
|
|
1062
|
+
const p = {
|
|
1047
1063
|
instanceId: `instance-${crypto.randomUUID()}`,
|
|
1048
|
-
parentId:
|
|
1064
|
+
parentId: h,
|
|
1049
1065
|
position: I,
|
|
1050
1066
|
effect: e._effect
|
|
1051
1067
|
};
|
|
1052
|
-
n.getState().addSignalElement(S,
|
|
1068
|
+
n.getState().addSignalElement(S, p);
|
|
1053
1069
|
const r = n.getState().getNestedState(e._stateKey, e._path);
|
|
1054
1070
|
let m;
|
|
1055
1071
|
if (e._effect)
|
|
@@ -1064,16 +1080,16 @@ function We({
|
|
|
1064
1080
|
else
|
|
1065
1081
|
m = r;
|
|
1066
1082
|
m !== null && typeof m == "object" && (m = JSON.stringify(m));
|
|
1067
|
-
const
|
|
1068
|
-
l.replaceWith(
|
|
1069
|
-
}, [e._stateKey, e._path.join("."), e._effect]),
|
|
1070
|
-
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,
|
|
1071
1087
|
style: { display: "none" },
|
|
1072
1088
|
"data-signal-id": S
|
|
1073
1089
|
});
|
|
1074
1090
|
}
|
|
1075
1091
|
function nt(e) {
|
|
1076
|
-
const
|
|
1092
|
+
const i = Ae(
|
|
1077
1093
|
(S) => {
|
|
1078
1094
|
const l = n.getState().stateComponents.get(e._stateKey) || {
|
|
1079
1095
|
components: /* @__PURE__ */ new Map(),
|
|
@@ -1087,9 +1103,8 @@ function nt(e) {
|
|
|
1087
1103
|
paths: /* @__PURE__ */ new Set([e._path.join(".")]),
|
|
1088
1104
|
deps: [],
|
|
1089
1105
|
depsFunction: void 0,
|
|
1090
|
-
reactiveType: ["component"]
|
|
1091
|
-
|
|
1092
|
-
}), l.pathTrie && Te(l.pathTrie, e._path.join("."), c), n.getState().stateComponents.set(e._stateKey, l), () => {
|
|
1106
|
+
reactiveType: ["component"]
|
|
1107
|
+
}), l.pathTrie && ue(l.pathTrie, e._path.join("."), c), n.getState().stateComponents.set(e._stateKey, l), () => {
|
|
1093
1108
|
l.components.delete(c), l.pathTrie && Ee(
|
|
1094
1109
|
l.pathTrie,
|
|
1095
1110
|
e._path.join("."),
|
|
@@ -1099,7 +1114,7 @@ function nt(e) {
|
|
|
1099
1114
|
},
|
|
1100
1115
|
() => n.getState().getNestedState(e._stateKey, e._path)
|
|
1101
1116
|
);
|
|
1102
|
-
return
|
|
1117
|
+
return oe("text", {}, String(i));
|
|
1103
1118
|
}
|
|
1104
1119
|
export {
|
|
1105
1120
|
he as $cogsSignal,
|
|
@@ -1107,6 +1122,6 @@ export {
|
|
|
1107
1122
|
Ke as addStateOptions,
|
|
1108
1123
|
et as createCogsState,
|
|
1109
1124
|
tt as notifyComponent,
|
|
1110
|
-
|
|
1125
|
+
Ue as useCogsStateFn
|
|
1111
1126
|
};
|
|
1112
1127
|
//# sourceMappingURL=CogsState.jsx.map
|