cogsbox-state 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CogsState.d.ts +25 -21
- package/dist/CogsState.jsx +491 -442
- package/dist/CogsState.jsx.map +1 -1
- package/dist/Functions.jsx +175 -0
- package/dist/Functions.jsx.map +1 -0
- package/dist/store.d.ts +4 -0
- package/dist/store.js.map +1 -1
- package/package.json +7 -4
- package/dist/examples/index.d.ts +0 -1
- package/dist/updaterFunctions.jsx +0 -177
- package/dist/updaterFunctions.jsx.map +0 -1
- /package/dist/{updaterFunctions.d.ts → Functions.d.ts} +0 -0
package/dist/CogsState.jsx
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { j as
|
|
3
|
-
import { r as
|
|
4
|
-
import { transformStateFunc as
|
|
5
|
-
import {
|
|
2
|
+
import { j as Y } from "./node_modules/react/jsx-runtime.jsx";
|
|
3
|
+
import { r as w } from "./node_modules/react/index.js";
|
|
4
|
+
import { transformStateFunc as ut, isFunction as at, getNestedValue as R, isDeepEqual as L } from "./utility.js";
|
|
5
|
+
import { pushFunc as Z, cutFunc as K, updateFn as tt, ValidationWrapper as St, FormControlComponent as gt } from "./Functions.jsx";
|
|
6
6
|
import "zod";
|
|
7
|
-
import { getGlobalStore as
|
|
8
|
-
import { useCogsConfig as
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
return { initialState: t, formElements: i, zodSchema:
|
|
7
|
+
import { getGlobalStore as a } from "./store.js";
|
|
8
|
+
import { useCogsConfig as ft } from "./CogsStateClient.jsx";
|
|
9
|
+
import k from "./node_modules/uuid/dist/esm-browser/v4.js";
|
|
10
|
+
function Mt(t, { formElements: i, zodSchema: d }) {
|
|
11
|
+
return { initialState: t, formElements: i, zodSchema: d };
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function et(t, i) {
|
|
14
|
+
const d = a.getState().getInitialOptions, u = a.getState().setInitialStateOptions, S = d(t) || {};
|
|
15
15
|
u(t, {
|
|
16
|
-
...
|
|
16
|
+
...S,
|
|
17
17
|
...i
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function nt({
|
|
21
21
|
stateKey: t,
|
|
22
22
|
options: i,
|
|
23
|
-
initialOptionsPart:
|
|
23
|
+
initialOptionsPart: d
|
|
24
24
|
}) {
|
|
25
|
-
const u =
|
|
26
|
-
let
|
|
25
|
+
const u = z(t) || {}, S = d[t] || {}, I = a.getState().setInitialStateOptions, _ = { ...S, ...u };
|
|
26
|
+
let E = !1;
|
|
27
27
|
if (i)
|
|
28
|
-
for (const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
for (const y in i)
|
|
29
|
+
_.hasOwnProperty(y) || (E = !0, _[y] = i[y]);
|
|
30
|
+
E && I(t, _);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
let
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const [
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
32
|
+
const Ot = (t, i) => {
|
|
33
|
+
let d = t;
|
|
34
|
+
const [u, S] = ut(d);
|
|
35
|
+
a.getState().setInitialStates(u);
|
|
36
|
+
const I = (E, y) => {
|
|
37
|
+
const [p] = w.useState(k());
|
|
38
|
+
nt({ stateKey: E, options: y, initialOptionsPart: S });
|
|
39
|
+
const o = a.getState().cogsStateStore[E] || u[E], r = y?.modifyState ? y.modifyState(o) : o, [v, N] = wt(
|
|
40
|
+
r,
|
|
41
41
|
{
|
|
42
|
-
stateKey:
|
|
43
|
-
syncUpdate:
|
|
44
|
-
componentId:
|
|
45
|
-
localStorage:
|
|
46
|
-
middleware:
|
|
47
|
-
enabledSync:
|
|
48
|
-
reactiveDeps:
|
|
49
|
-
initState:
|
|
42
|
+
stateKey: E,
|
|
43
|
+
syncUpdate: y?.syncUpdate,
|
|
44
|
+
componentId: p,
|
|
45
|
+
localStorage: y?.localStorage,
|
|
46
|
+
middleware: y?.middleware,
|
|
47
|
+
enabledSync: y?.enabledSync,
|
|
48
|
+
reactiveDeps: y?.reactiveDeps,
|
|
49
|
+
initState: y?.initState
|
|
50
50
|
}
|
|
51
51
|
);
|
|
52
|
-
return
|
|
52
|
+
return N;
|
|
53
53
|
};
|
|
54
|
-
function E
|
|
55
|
-
|
|
54
|
+
function _(E, y) {
|
|
55
|
+
nt({ stateKey: E, options: y, initialOptionsPart: S });
|
|
56
56
|
}
|
|
57
|
-
return { useCogsState:
|
|
57
|
+
return { useCogsState: I, setCogsOptions: _ };
|
|
58
58
|
}, {
|
|
59
|
-
setUpdaterState:
|
|
60
|
-
setState:
|
|
61
|
-
getInitialOptions:
|
|
62
|
-
getKeyState:
|
|
63
|
-
getValidationErrors:
|
|
64
|
-
setStateLog:
|
|
59
|
+
setUpdaterState: G,
|
|
60
|
+
setState: M,
|
|
61
|
+
getInitialOptions: z,
|
|
62
|
+
getKeyState: it,
|
|
63
|
+
getValidationErrors: mt,
|
|
64
|
+
setStateLog: yt,
|
|
65
65
|
updateInitialStateGlobal: J,
|
|
66
|
-
addValidationError:
|
|
67
|
-
removeValidationError:
|
|
68
|
-
setServerSyncActions:
|
|
69
|
-
} =
|
|
66
|
+
addValidationError: pt,
|
|
67
|
+
removeValidationError: U,
|
|
68
|
+
setServerSyncActions: vt
|
|
69
|
+
} = a.getState(), ot = (t) => {
|
|
70
70
|
if (!t) return null;
|
|
71
71
|
try {
|
|
72
72
|
const i = window.localStorage.getItem(t);
|
|
@@ -74,535 +74,584 @@ const ht = (t) => {
|
|
|
74
74
|
} catch (i) {
|
|
75
75
|
return console.error("Error loading from localStorage:", i), null;
|
|
76
76
|
}
|
|
77
|
-
}, It = (t, i,
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
77
|
+
}, It = (t, i, d, u) => {
|
|
78
|
+
if (d?.initState) {
|
|
79
|
+
const S = {
|
|
80
80
|
state: t,
|
|
81
81
|
lastUpdated: Date.now(),
|
|
82
|
-
lastSyncedWithServer:
|
|
83
|
-
baseServerState:
|
|
84
|
-
},
|
|
85
|
-
window.localStorage.setItem(
|
|
82
|
+
lastSyncedWithServer: a.getState().serverSyncLog[i]?.[0]?.timeStamp,
|
|
83
|
+
baseServerState: a.getState().serverState[i]
|
|
84
|
+
}, I = d.initState ? `${u}-${i}-${d.initState.localStorageKey}` : i;
|
|
85
|
+
window.localStorage.setItem(I, JSON.stringify(S));
|
|
86
86
|
}
|
|
87
|
-
},
|
|
88
|
-
const
|
|
87
|
+
}, _t = (t, i, d, u, S, I) => {
|
|
88
|
+
const _ = {
|
|
89
89
|
initialState: i,
|
|
90
|
-
updaterState:
|
|
90
|
+
updaterState: W(
|
|
91
91
|
t,
|
|
92
92
|
u,
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
S,
|
|
94
|
+
I
|
|
95
95
|
),
|
|
96
|
-
state:
|
|
96
|
+
state: d
|
|
97
97
|
};
|
|
98
|
-
|
|
99
|
-
J(t,
|
|
98
|
+
w.startTransition(() => {
|
|
99
|
+
J(t, _.initialState), G(t, _.updaterState), M(t, _.state);
|
|
100
100
|
});
|
|
101
|
-
},
|
|
102
|
-
const i =
|
|
101
|
+
}, Et = (t) => {
|
|
102
|
+
const i = a.getState().stateComponents.get(t);
|
|
103
103
|
if (!i) return;
|
|
104
|
-
const
|
|
104
|
+
const d = /* @__PURE__ */ new Set();
|
|
105
105
|
i.components.forEach((u) => {
|
|
106
|
-
|
|
106
|
+
d.add(() => u.forceUpdate());
|
|
107
107
|
}), queueMicrotask(() => {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
w.startTransition(() => {
|
|
109
|
+
d.forEach((u) => u());
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
|
-
function
|
|
113
|
+
function wt(t, {
|
|
114
114
|
stateKey: i,
|
|
115
|
-
serverSync:
|
|
115
|
+
serverSync: d,
|
|
116
116
|
zodSchema: u,
|
|
117
|
-
localStorage:
|
|
118
|
-
formElements:
|
|
119
|
-
middleware:
|
|
120
|
-
reactiveDeps:
|
|
121
|
-
componentId:
|
|
122
|
-
initState:
|
|
123
|
-
syncUpdate:
|
|
117
|
+
localStorage: S,
|
|
118
|
+
formElements: I,
|
|
119
|
+
middleware: _,
|
|
120
|
+
reactiveDeps: E,
|
|
121
|
+
componentId: y,
|
|
122
|
+
initState: p,
|
|
123
|
+
syncUpdate: o
|
|
124
124
|
} = {}) {
|
|
125
|
-
const [
|
|
126
|
-
let
|
|
127
|
-
const [c] =
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
...
|
|
132
|
-
[
|
|
125
|
+
const [r, v] = w.useState({}), { sessionId: N } = ft();
|
|
126
|
+
let F = !i;
|
|
127
|
+
const [c] = w.useState(i ?? k()), b = a.getState().stateLog[c], B = w.useRef(/* @__PURE__ */ new Set()), s = w.useRef(y ?? k()), A = w.useRef(null);
|
|
128
|
+
A.current = z(c), w.useEffect(() => {
|
|
129
|
+
if (o && o.stateKey === c && o.path?.[0]) {
|
|
130
|
+
M(c, (n) => ({
|
|
131
|
+
...n,
|
|
132
|
+
[o.path[0]]: o.newValue
|
|
133
133
|
}));
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
timeStamp:
|
|
137
|
-
userId:
|
|
134
|
+
const e = `${o.stateKey}:${o.path.join(".")}`;
|
|
135
|
+
a.getState().setSyncInfo(e, {
|
|
136
|
+
timeStamp: o.timeStamp,
|
|
137
|
+
userId: o.userId
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
}, [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
j && K(c, {
|
|
161
|
-
serverSync: S,
|
|
162
|
-
formElements: E,
|
|
140
|
+
}, [o]), w.useEffect(() => {
|
|
141
|
+
et(c, {
|
|
142
|
+
initState: p
|
|
143
|
+
});
|
|
144
|
+
const e = ot(
|
|
145
|
+
N + "-" + c + "-" + p?.localStorageKey
|
|
146
|
+
);
|
|
147
|
+
let n = null;
|
|
148
|
+
p?.initialState && (n = p?.initialState, e && e.lastUpdated > (e.lastSyncedWithServer || 0) && (n = e.state), _t(
|
|
149
|
+
c,
|
|
150
|
+
p?.initialState,
|
|
151
|
+
n,
|
|
152
|
+
h,
|
|
153
|
+
s.current,
|
|
154
|
+
N
|
|
155
|
+
)), Et(c);
|
|
156
|
+
}, [p?.localStorageKey, ...p?.dependencies || []]), w.useEffect(() => {
|
|
157
|
+
F && et(c, {
|
|
158
|
+
serverSync: d,
|
|
159
|
+
formElements: I,
|
|
163
160
|
zodSchema: u,
|
|
164
|
-
initState:
|
|
165
|
-
localStorage:
|
|
166
|
-
middleware:
|
|
161
|
+
initState: p,
|
|
162
|
+
localStorage: S,
|
|
163
|
+
middleware: _
|
|
167
164
|
});
|
|
168
|
-
const
|
|
165
|
+
const e = `${c}////${s.current}`, n = a.getState().stateComponents.get(c) || {
|
|
169
166
|
components: /* @__PURE__ */ new Map()
|
|
170
167
|
};
|
|
171
|
-
return
|
|
168
|
+
return n.components.set(e, {
|
|
172
169
|
forceUpdate: () => v({}),
|
|
173
170
|
paths: /* @__PURE__ */ new Set(),
|
|
174
171
|
deps: [],
|
|
175
|
-
depsFunction:
|
|
176
|
-
}),
|
|
177
|
-
const
|
|
178
|
-
|
|
172
|
+
depsFunction: E || void 0
|
|
173
|
+
}), a.getState().stateComponents.set(c, n), () => {
|
|
174
|
+
const l = `${c}////${s.current}`;
|
|
175
|
+
n && (n.components.delete(l), n.components.size === 0 && a.getState().stateComponents.delete(c));
|
|
179
176
|
};
|
|
180
177
|
}, []);
|
|
181
|
-
const
|
|
182
|
-
if (Array.isArray(
|
|
183
|
-
const
|
|
184
|
-
|
|
178
|
+
const h = (e, n, l, g) => {
|
|
179
|
+
if (Array.isArray(n)) {
|
|
180
|
+
const m = `${c}-${n.join(".")}`;
|
|
181
|
+
B.current.add(m);
|
|
185
182
|
}
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
183
|
+
M(c, (m) => {
|
|
184
|
+
const $ = at(e) ? e(m) : e, P = `${c}-${n.join(".")}`;
|
|
185
|
+
if (P) {
|
|
186
|
+
let j = !1, f = a.getState().signalDomElements.get(P);
|
|
187
|
+
if ((!f || f.size === 0) && (l.updateType === "insert" || l.updateType === "cut")) {
|
|
188
|
+
const V = n.slice(0, -1), x = R($, V);
|
|
189
|
+
if (Array.isArray(x)) {
|
|
190
|
+
j = !0;
|
|
191
|
+
const T = `${c}-${V.join(".")}`;
|
|
192
|
+
f = a.getState().signalDomElements.get(T);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (f) {
|
|
196
|
+
const V = j ? R($, n.slice(0, -1)) : R($, n);
|
|
197
|
+
f.forEach(({ parentId: x, position: T, effect: D }) => {
|
|
193
198
|
const C = document.querySelector(
|
|
194
|
-
`[data-parent-id="${
|
|
199
|
+
`[data-parent-id="${x}"]`
|
|
195
200
|
);
|
|
196
201
|
if (C) {
|
|
197
|
-
const
|
|
198
|
-
|
|
202
|
+
const X = Array.from(C.childNodes);
|
|
203
|
+
if (X[T]) {
|
|
204
|
+
const dt = D ? new Function(
|
|
205
|
+
"state",
|
|
206
|
+
`return (${D})(state)`
|
|
207
|
+
)(V) : V;
|
|
208
|
+
X[T].textContent = String(dt);
|
|
209
|
+
}
|
|
199
210
|
}
|
|
200
211
|
});
|
|
201
212
|
}
|
|
202
213
|
}
|
|
203
|
-
|
|
204
|
-
(
|
|
214
|
+
l.updateType === "update" && (g || A.current?.validationKey) && n && U(
|
|
215
|
+
(g || A.current?.validationKey) + "." + n.join(".")
|
|
205
216
|
);
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
),
|
|
210
|
-
|
|
211
|
-
).filter(([
|
|
212
|
-
let
|
|
213
|
-
if (
|
|
214
|
-
let
|
|
215
|
-
|
|
217
|
+
const O = n.slice(0, n.length - 1);
|
|
218
|
+
l.updateType === "cut" && A.current?.validationKey && U(
|
|
219
|
+
A.current?.validationKey + "." + O.join(".")
|
|
220
|
+
), l.updateType === "insert" && A.current?.validationKey && mt(
|
|
221
|
+
A.current?.validationKey + "." + O.join(".")
|
|
222
|
+
).filter(([f, V]) => {
|
|
223
|
+
let x = f?.split(".").length;
|
|
224
|
+
if (f == O.join(".") && x == O.length - 1) {
|
|
225
|
+
let T = f + "." + O;
|
|
226
|
+
U(f), pt(T, V);
|
|
216
227
|
}
|
|
217
228
|
});
|
|
218
|
-
const
|
|
229
|
+
const st = R(m, n), ct = R($, n), lt = l.updateType === "update" ? n.join(".") : [...n].slice(0, -1).join("."), H = a.getState().stateComponents.get(c);
|
|
219
230
|
if (H) {
|
|
220
231
|
for (const [
|
|
221
|
-
|
|
222
|
-
|
|
232
|
+
j,
|
|
233
|
+
f
|
|
223
234
|
] of H.components.entries())
|
|
224
|
-
if (
|
|
225
|
-
if (
|
|
226
|
-
const
|
|
227
|
-
typeof
|
|
235
|
+
if (f.depsFunction || f.paths && f.paths.has(lt))
|
|
236
|
+
if (f.depsFunction) {
|
|
237
|
+
const V = f.depsFunction($);
|
|
238
|
+
typeof V == "boolean" ? V && f.forceUpdate() : L(f.deps, V) || (f.deps = V, f.forceUpdate());
|
|
228
239
|
} else
|
|
229
|
-
|
|
240
|
+
f.forceUpdate();
|
|
230
241
|
}
|
|
231
242
|
const Q = {
|
|
232
243
|
timeStamp: Date.now(),
|
|
233
244
|
stateKey: c,
|
|
234
|
-
path:
|
|
235
|
-
updateType:
|
|
245
|
+
path: n,
|
|
246
|
+
updateType: l.updateType,
|
|
236
247
|
status: "new",
|
|
237
|
-
oldValue:
|
|
238
|
-
newValue:
|
|
248
|
+
oldValue: st,
|
|
249
|
+
newValue: ct
|
|
239
250
|
};
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
),
|
|
251
|
+
if (yt(c, (j) => {
|
|
252
|
+
const V = [...j ?? [], Q].reduce((x, T) => {
|
|
253
|
+
const D = `${T.stateKey}:${JSON.stringify(T.path)}`, C = x.get(D);
|
|
254
|
+
return C ? (C.timeStamp = Math.max(
|
|
255
|
+
C.timeStamp,
|
|
256
|
+
T.timeStamp
|
|
257
|
+
), C.newValue = T.newValue, C.oldValue = C.oldValue ?? T.oldValue, C.updateType = T.updateType) : x.set(D, { ...T }), x;
|
|
247
258
|
}, /* @__PURE__ */ new Map());
|
|
248
|
-
return Array.from(
|
|
259
|
+
return Array.from(V.values());
|
|
249
260
|
}), It(
|
|
250
|
-
|
|
261
|
+
$,
|
|
251
262
|
c,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
),
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
syncKey: typeof
|
|
258
|
-
rollBackState:
|
|
259
|
-
actionTimeStamp: Date.now() + (
|
|
263
|
+
A.current,
|
|
264
|
+
N
|
|
265
|
+
), _ && _({ updateLog: b, update: Q }), A.current?.serverSync) {
|
|
266
|
+
const j = a.getState().serverState[c], f = A.current?.serverSync;
|
|
267
|
+
vt(c, {
|
|
268
|
+
syncKey: typeof f.syncKey == "string" ? f.syncKey : f.syncKey({ state: $ }),
|
|
269
|
+
rollBackState: j,
|
|
270
|
+
actionTimeStamp: Date.now() + (f.debounce ?? 3e3),
|
|
260
271
|
status: "waiting"
|
|
261
272
|
});
|
|
262
273
|
}
|
|
263
|
-
return
|
|
274
|
+
return $;
|
|
264
275
|
});
|
|
265
276
|
};
|
|
266
|
-
|
|
277
|
+
a.getState().updaterState[c] || (console.log("Initializing state for", c, t), G(
|
|
267
278
|
c,
|
|
268
|
-
|
|
279
|
+
W(
|
|
269
280
|
c,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
281
|
+
h,
|
|
282
|
+
s.current,
|
|
283
|
+
N
|
|
273
284
|
)
|
|
274
|
-
),
|
|
275
|
-
const
|
|
285
|
+
), a.getState().cogsStateStore[c] || M(c, t), a.getState().initialStateGlobal[c] || J(c, t));
|
|
286
|
+
const q = w.useMemo(() => W(
|
|
276
287
|
c,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
288
|
+
h,
|
|
289
|
+
s.current,
|
|
290
|
+
N
|
|
280
291
|
), [c]);
|
|
281
|
-
return [
|
|
282
|
-
}
|
|
283
|
-
function _t({
|
|
284
|
-
proxy: t
|
|
285
|
-
}) {
|
|
286
|
-
const i = _.useRef(null), S = `${t._stateKey}-${t._path.join(".")}`;
|
|
287
|
-
return _.useEffect(() => {
|
|
288
|
-
const u = i.current;
|
|
289
|
-
if (!u || !u.parentElement) {
|
|
290
|
-
console.log("No element or parent");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const g = u.parentElement, f = Array.from(g.childNodes).indexOf(u);
|
|
294
|
-
let m = g.getAttribute("data-parent-id");
|
|
295
|
-
m || (m = `parent-${crypto.randomUUID()}`, g.setAttribute("data-parent-id", m));
|
|
296
|
-
const I = { instanceId: `instance-${crypto.randomUUID()}`, parentId: m, position: f };
|
|
297
|
-
n.getState().addSignalElement(S, I);
|
|
298
|
-
const s = document.createTextNode(
|
|
299
|
-
String(
|
|
300
|
-
n.getState().getNestedState(t._stateKey, t._path)
|
|
301
|
-
)
|
|
302
|
-
);
|
|
303
|
-
u.replaceWith(s);
|
|
304
|
-
}, [t._stateKey, t._path.join(".")]), _.createElement("span", {
|
|
305
|
-
ref: i,
|
|
306
|
-
style: { display: "none" }
|
|
307
|
-
});
|
|
292
|
+
return [it(c), q];
|
|
308
293
|
}
|
|
309
|
-
function
|
|
310
|
-
const
|
|
311
|
-
let
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
for (const [v] of
|
|
315
|
-
(v ===
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
removeValidation: (
|
|
319
|
-
|
|
294
|
+
function W(t, i, d, u) {
|
|
295
|
+
const S = /* @__PURE__ */ new Map();
|
|
296
|
+
let I = 0;
|
|
297
|
+
const _ = (o) => {
|
|
298
|
+
const r = o.join(".");
|
|
299
|
+
for (const [v] of S)
|
|
300
|
+
(v === r || v.startsWith(r + ".")) && S.delete(v);
|
|
301
|
+
I++;
|
|
302
|
+
}, E = /* @__PURE__ */ new Map(), y = {
|
|
303
|
+
removeValidation: (o) => {
|
|
304
|
+
o?.validationKey && U(o.validationKey);
|
|
320
305
|
},
|
|
321
|
-
revertToInitialState: (
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const v =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
306
|
+
revertToInitialState: (o) => {
|
|
307
|
+
o?.validationKey && U(o.validationKey);
|
|
308
|
+
const r = a.getState().initialStateGlobal[t];
|
|
309
|
+
S.clear(), I++;
|
|
310
|
+
const v = p(r, []);
|
|
311
|
+
w.startTransition(() => {
|
|
312
|
+
G(t, v), M(t, r);
|
|
313
|
+
const N = a.getState().stateComponents.get(t);
|
|
314
|
+
N && N.components.forEach((c) => {
|
|
330
315
|
c.forceUpdate();
|
|
331
316
|
});
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
317
|
+
const F = z(t);
|
|
318
|
+
F?.initState && localStorage.removeItem(
|
|
319
|
+
F?.initState ? u + "-" + t + "-" + F?.initState.localStorageKey : t
|
|
335
320
|
), localStorage.removeItem(t);
|
|
336
321
|
});
|
|
337
322
|
},
|
|
338
|
-
updateInitialState: (
|
|
339
|
-
|
|
340
|
-
const
|
|
323
|
+
updateInitialState: (o) => {
|
|
324
|
+
S.clear(), I++;
|
|
325
|
+
const r = W(
|
|
341
326
|
t,
|
|
342
327
|
i,
|
|
343
|
-
|
|
328
|
+
d,
|
|
344
329
|
u
|
|
345
330
|
);
|
|
346
|
-
return
|
|
347
|
-
J(t,
|
|
348
|
-
const v =
|
|
349
|
-
v && v.components.forEach((
|
|
350
|
-
|
|
331
|
+
return w.startTransition(() => {
|
|
332
|
+
J(t, o), G(t, r), M(t, o);
|
|
333
|
+
const v = a.getState().stateComponents.get(t);
|
|
334
|
+
v && v.components.forEach((N) => {
|
|
335
|
+
N.forceUpdate();
|
|
351
336
|
}), localStorage.removeItem(t);
|
|
352
337
|
}), {
|
|
353
|
-
fetchId: (v) =>
|
|
338
|
+
fetchId: (v) => r.get()[v]
|
|
354
339
|
};
|
|
355
340
|
},
|
|
356
|
-
_initialState:
|
|
357
|
-
_serverState:
|
|
358
|
-
_isLoading:
|
|
341
|
+
_initialState: a.getState().initialStateGlobal[t],
|
|
342
|
+
_serverState: a.getState().serverState[t],
|
|
343
|
+
_isLoading: a.getState().isLoadingGlobal[t],
|
|
359
344
|
_isServerSynced: () => {
|
|
360
|
-
const
|
|
361
|
-
return !!(
|
|
345
|
+
const o = a.getState().serverState[t];
|
|
346
|
+
return !!(o && L(o, it(t)));
|
|
362
347
|
}
|
|
363
348
|
};
|
|
364
|
-
function
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
return
|
|
349
|
+
function p(o, r = [], v) {
|
|
350
|
+
const N = r.map(String).join("."), F = S.get(N);
|
|
351
|
+
if (F?.stateVersion === I)
|
|
352
|
+
return F.proxy;
|
|
368
353
|
const c = {
|
|
369
|
-
get(
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
|
|
354
|
+
get(B, s) {
|
|
355
|
+
if (s !== "then" && !s.startsWith("$")) {
|
|
356
|
+
const e = r.join("."), n = `${t}////${d}`, l = a.getState().stateComponents.get(t);
|
|
357
|
+
if (l && e) {
|
|
358
|
+
const g = l.components.get(n);
|
|
359
|
+
g && g.paths.add(e);
|
|
375
360
|
}
|
|
376
361
|
}
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
return n.getState().getSyncInfo(o);
|
|
380
|
-
}
|
|
381
|
-
if (l === "_selected") {
|
|
382
|
-
const o = e.slice(0, -1), a = o.join("."), r = n.getState().getNestedState(t, o);
|
|
383
|
-
return Array.isArray(r) ? Number(e[e.length - 1]) === m.get(a) : void 0;
|
|
384
|
-
}
|
|
385
|
-
if (l == "getLocalStorage")
|
|
386
|
-
return (o) => ot(
|
|
387
|
-
u + "-" + t + "-" + o
|
|
388
|
-
);
|
|
389
|
-
if (l === "setSelected")
|
|
390
|
-
return (o) => {
|
|
391
|
-
const a = e.slice(0, -1), r = Number(e[e.length - 1]), d = a.join(".");
|
|
392
|
-
o ? m.set(d, r) : m.delete(d);
|
|
393
|
-
const p = n.getState().getNestedState(t, [...a]);
|
|
394
|
-
Y(i, p, a), f(a);
|
|
395
|
-
};
|
|
396
|
-
if (e.length == 0) {
|
|
397
|
-
if (l == "_componentId") return S;
|
|
398
|
-
if (l === "_initialState")
|
|
399
|
-
return n.getState().initialStateGlobal[t];
|
|
400
|
-
if (l === "_serverState")
|
|
401
|
-
return n.getState().serverState[t];
|
|
402
|
-
if (l === "_isLoading")
|
|
403
|
-
return n.getState().isLoadingGlobal[t];
|
|
404
|
-
if (l === "revertToInitialState")
|
|
405
|
-
return w.revertToInitialState;
|
|
406
|
-
if (l === "updateInitialState")
|
|
407
|
-
return w.updateInitialState;
|
|
408
|
-
if (l === "removeValidation")
|
|
409
|
-
return w.removeValidation;
|
|
410
|
-
}
|
|
411
|
-
if (l === "validationWrapper")
|
|
412
|
-
return ({
|
|
413
|
-
children: o,
|
|
414
|
-
hideMessage: a
|
|
415
|
-
}) => /* @__PURE__ */ X.jsx(
|
|
416
|
-
lt,
|
|
417
|
-
{
|
|
418
|
-
formOpts: a ? { validation: { message: "" } } : void 0,
|
|
419
|
-
path: e,
|
|
420
|
-
validationKey: n.getState().getInitialOptions(t)?.validationKey || "",
|
|
421
|
-
stateKey: t,
|
|
422
|
-
validIndices: v?.validIndices,
|
|
423
|
-
children: o
|
|
424
|
-
}
|
|
425
|
-
);
|
|
426
|
-
if (l === "_stateKey") return t;
|
|
427
|
-
if (l === "_path") return e;
|
|
428
|
-
if (l === "_isServerSynced") return w._isServerSynced;
|
|
429
|
-
if (l === "update")
|
|
430
|
-
return (o, a) => {
|
|
431
|
-
f(e), Y(i, o, e, "");
|
|
432
|
-
};
|
|
433
|
-
if (l === "get")
|
|
434
|
-
return () => n.getState().getNestedState(t, e);
|
|
435
|
-
if (l === "$get")
|
|
436
|
-
return () => et({ _stateKey: t, _path: e });
|
|
437
|
-
if (l === "formElement")
|
|
438
|
-
return (o, a, r) => /* @__PURE__ */ X.jsx(
|
|
439
|
-
dt,
|
|
440
|
-
{
|
|
441
|
-
setState: i,
|
|
442
|
-
validationKey: o,
|
|
443
|
-
stateKey: t,
|
|
444
|
-
path: e,
|
|
445
|
-
child: a,
|
|
446
|
-
formOpts: r
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
if (Array.isArray(s)) {
|
|
450
|
-
if (l === "getSelected")
|
|
362
|
+
if (Array.isArray(o)) {
|
|
363
|
+
if (s === "getSelected")
|
|
451
364
|
return () => {
|
|
452
|
-
const
|
|
453
|
-
|
|
365
|
+
const e = E.get(
|
|
366
|
+
r.join(".")
|
|
454
367
|
);
|
|
455
|
-
if (
|
|
456
|
-
return
|
|
457
|
-
|
|
458
|
-
[...
|
|
368
|
+
if (e !== void 0)
|
|
369
|
+
return p(
|
|
370
|
+
o[e],
|
|
371
|
+
[...r, e.toString()],
|
|
459
372
|
v
|
|
460
373
|
);
|
|
461
374
|
};
|
|
462
|
-
if (
|
|
463
|
-
return () =>
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
d,
|
|
472
|
-
[...e, $.toString()],
|
|
375
|
+
if (s === "stateMap")
|
|
376
|
+
return (e) => {
|
|
377
|
+
const n = v?.filtered?.some(
|
|
378
|
+
(g) => g.join(".") === r.join(".")
|
|
379
|
+
), l = n ? o : a.getState().getNestedState(t, r);
|
|
380
|
+
return S.clear(), I++, l.map((g, m) => {
|
|
381
|
+
const $ = n && g.__origIndex ? g.__origIndex : m, P = p(
|
|
382
|
+
g,
|
|
383
|
+
[...r, $.toString()],
|
|
473
384
|
v
|
|
474
385
|
);
|
|
475
|
-
return
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
386
|
+
return e(
|
|
387
|
+
g,
|
|
388
|
+
P,
|
|
389
|
+
m,
|
|
390
|
+
o,
|
|
391
|
+
p(
|
|
392
|
+
o,
|
|
393
|
+
r,
|
|
483
394
|
v
|
|
484
395
|
)
|
|
485
396
|
);
|
|
486
397
|
});
|
|
487
398
|
};
|
|
488
|
-
if (
|
|
489
|
-
return (
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
399
|
+
if (s === "$stateMap")
|
|
400
|
+
return (e) => w.createElement($t, {
|
|
401
|
+
proxy: {
|
|
402
|
+
_stateKey: t,
|
|
403
|
+
_path: r,
|
|
404
|
+
_mapFn: e
|
|
405
|
+
// Pass the actual function, not string
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
if (s === "stateFlattenOn")
|
|
409
|
+
return (e) => {
|
|
410
|
+
const l = v?.filtered?.some(
|
|
411
|
+
(m) => m.join(".") === r.join(".")
|
|
412
|
+
) ? o : a.getState().getNestedState(t, r);
|
|
413
|
+
S.clear(), I++;
|
|
414
|
+
const g = l.flatMap(
|
|
415
|
+
(m, $) => m[e] ?? []
|
|
496
416
|
);
|
|
497
|
-
return
|
|
498
|
-
|
|
499
|
-
[...
|
|
417
|
+
return p(
|
|
418
|
+
g,
|
|
419
|
+
[...r, "[*]", e],
|
|
500
420
|
v
|
|
501
421
|
);
|
|
502
422
|
};
|
|
503
|
-
if (
|
|
504
|
-
return (
|
|
505
|
-
const
|
|
506
|
-
($) => $[
|
|
423
|
+
if (s === "findWith")
|
|
424
|
+
return (e, n) => {
|
|
425
|
+
const l = o.findIndex(
|
|
426
|
+
($) => $[e] === n
|
|
507
427
|
);
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
return
|
|
428
|
+
if (l === -1) return;
|
|
429
|
+
const g = o[l], m = [...r, l.toString()];
|
|
430
|
+
return S.clear(), I++, S.clear(), I++, p(g, m);
|
|
511
431
|
};
|
|
512
|
-
if (
|
|
513
|
-
return (
|
|
514
|
-
const
|
|
515
|
-
return
|
|
516
|
-
...
|
|
517
|
-
|
|
432
|
+
if (s === "index")
|
|
433
|
+
return (e) => {
|
|
434
|
+
const n = o[e];
|
|
435
|
+
return p(n, [
|
|
436
|
+
...r,
|
|
437
|
+
e.toString()
|
|
518
438
|
]);
|
|
519
439
|
};
|
|
520
|
-
if (
|
|
521
|
-
return (
|
|
440
|
+
if (s === "insert")
|
|
441
|
+
return (e) => (_(r), Z(
|
|
522
442
|
i,
|
|
523
|
-
o,
|
|
524
443
|
e,
|
|
444
|
+
r,
|
|
525
445
|
t
|
|
526
|
-
),
|
|
527
|
-
|
|
446
|
+
), p(
|
|
447
|
+
a.getState().cogsStateStore[t],
|
|
528
448
|
[]
|
|
529
449
|
));
|
|
530
|
-
if (
|
|
531
|
-
return (
|
|
532
|
-
const
|
|
533
|
-
!
|
|
534
|
-
(
|
|
535
|
-
$[
|
|
536
|
-
|
|
450
|
+
if (s === "uniqueInsert")
|
|
451
|
+
return (e, n) => {
|
|
452
|
+
const l = a.getState().getNestedState(t, r), g = at(e) ? e(l) : e;
|
|
453
|
+
!l.some(($) => n ? n.every(
|
|
454
|
+
(P) => L(
|
|
455
|
+
$[P],
|
|
456
|
+
g[P]
|
|
537
457
|
)
|
|
538
|
-
) :
|
|
458
|
+
) : L($, g)) && (_(r), Z(
|
|
539
459
|
i,
|
|
540
|
-
|
|
541
|
-
|
|
460
|
+
g,
|
|
461
|
+
r,
|
|
542
462
|
t
|
|
543
463
|
));
|
|
544
464
|
};
|
|
545
|
-
if (
|
|
546
|
-
return (
|
|
547
|
-
|
|
465
|
+
if (s === "cut")
|
|
466
|
+
return (e, n) => {
|
|
467
|
+
n?.waitForSync || (_(r), K(i, r, t, e));
|
|
548
468
|
};
|
|
549
|
-
if (
|
|
550
|
-
return (
|
|
551
|
-
const
|
|
552
|
-
(
|
|
553
|
-
...
|
|
469
|
+
if (s === "stateFilter")
|
|
470
|
+
return (e) => {
|
|
471
|
+
const n = o.map(
|
|
472
|
+
(m, $) => ({
|
|
473
|
+
...m,
|
|
554
474
|
__origIndex: $.toString()
|
|
555
475
|
})
|
|
556
|
-
),
|
|
557
|
-
for (let
|
|
558
|
-
|
|
559
|
-
return
|
|
560
|
-
|
|
561
|
-
|
|
476
|
+
), l = [], g = [];
|
|
477
|
+
for (let m = 0; m < n.length; m++)
|
|
478
|
+
e(n[m], m) && (l.push(m), g.push(n[m]));
|
|
479
|
+
return S.clear(), I++, p(
|
|
480
|
+
g,
|
|
481
|
+
r,
|
|
562
482
|
{
|
|
563
|
-
filtered: [...v?.filtered || [],
|
|
564
|
-
validIndices:
|
|
483
|
+
filtered: [...v?.filtered || [], r],
|
|
484
|
+
validIndices: l
|
|
565
485
|
// Pass through the meta
|
|
566
486
|
}
|
|
567
487
|
);
|
|
568
488
|
};
|
|
569
489
|
}
|
|
570
|
-
const
|
|
571
|
-
|
|
490
|
+
const A = r[r.length - 1];
|
|
491
|
+
if (!isNaN(Number(A))) {
|
|
492
|
+
const e = r.slice(0, -1), n = a.getState().getNestedState(t, e);
|
|
493
|
+
if (Array.isArray(n) && s === "cut")
|
|
494
|
+
return () => K(
|
|
495
|
+
i,
|
|
496
|
+
e,
|
|
497
|
+
t,
|
|
498
|
+
Number(A)
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
if (s === "get")
|
|
502
|
+
return () => a.getState().getNestedState(t, r);
|
|
503
|
+
if (s === "$effect")
|
|
504
|
+
return (e) => rt({
|
|
505
|
+
_stateKey: t,
|
|
506
|
+
_path: r,
|
|
507
|
+
_effect: e.toString()
|
|
508
|
+
});
|
|
509
|
+
if (s === "$get")
|
|
510
|
+
return () => rt({
|
|
511
|
+
_stateKey: t,
|
|
512
|
+
_path: r
|
|
513
|
+
});
|
|
514
|
+
if (s === "lastSynced") {
|
|
515
|
+
const e = `${t}:${r.join(".")}`;
|
|
516
|
+
return a.getState().getSyncInfo(e);
|
|
517
|
+
}
|
|
518
|
+
if (s === "_selected") {
|
|
519
|
+
const e = r.slice(0, -1), n = e.join("."), l = a.getState().getNestedState(t, e);
|
|
520
|
+
return Array.isArray(l) ? Number(r[r.length - 1]) === E.get(n) : void 0;
|
|
521
|
+
}
|
|
522
|
+
if (s == "getLocalStorage")
|
|
523
|
+
return (e) => ot(
|
|
524
|
+
u + "-" + t + "-" + e
|
|
525
|
+
);
|
|
526
|
+
if (s === "setSelected")
|
|
527
|
+
return (e) => {
|
|
528
|
+
const n = r.slice(0, -1), l = Number(r[r.length - 1]), g = n.join(".");
|
|
529
|
+
e ? E.set(g, l) : E.delete(g);
|
|
530
|
+
const m = a.getState().getNestedState(t, [...n]);
|
|
531
|
+
tt(i, m, n), _(n);
|
|
532
|
+
};
|
|
533
|
+
if (r.length == 0) {
|
|
534
|
+
if (s == "_componentId") return d;
|
|
535
|
+
if (s === "_initialState")
|
|
536
|
+
return a.getState().initialStateGlobal[t];
|
|
537
|
+
if (s === "_serverState")
|
|
538
|
+
return a.getState().serverState[t];
|
|
539
|
+
if (s === "_isLoading")
|
|
540
|
+
return a.getState().isLoadingGlobal[t];
|
|
541
|
+
if (s === "revertToInitialState")
|
|
542
|
+
return y.revertToInitialState;
|
|
543
|
+
if (s === "updateInitialState")
|
|
544
|
+
return y.updateInitialState;
|
|
545
|
+
if (s === "removeValidation")
|
|
546
|
+
return y.removeValidation;
|
|
547
|
+
}
|
|
548
|
+
if (s === "validationWrapper")
|
|
549
|
+
return ({
|
|
550
|
+
children: e,
|
|
551
|
+
hideMessage: n
|
|
552
|
+
}) => /* @__PURE__ */ Y.jsx(
|
|
553
|
+
St,
|
|
554
|
+
{
|
|
555
|
+
formOpts: n ? { validation: { message: "" } } : void 0,
|
|
556
|
+
path: r,
|
|
557
|
+
validationKey: a.getState().getInitialOptions(t)?.validationKey || "",
|
|
558
|
+
stateKey: t,
|
|
559
|
+
validIndices: v?.validIndices,
|
|
560
|
+
children: e
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
if (s === "_stateKey") return t;
|
|
564
|
+
if (s === "_path") return r;
|
|
565
|
+
if (s === "_isServerSynced") return y._isServerSynced;
|
|
566
|
+
if (s === "update")
|
|
567
|
+
return (e, n) => {
|
|
568
|
+
_(r), tt(i, e, r, "");
|
|
569
|
+
};
|
|
570
|
+
if (s === "formElement")
|
|
571
|
+
return (e, n, l) => /* @__PURE__ */ Y.jsx(
|
|
572
|
+
gt,
|
|
573
|
+
{
|
|
574
|
+
setState: i,
|
|
575
|
+
validationKey: e,
|
|
576
|
+
stateKey: t,
|
|
577
|
+
path: r,
|
|
578
|
+
child: n,
|
|
579
|
+
formOpts: l
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
const h = [...r, s], q = a.getState().getNestedState(t, h);
|
|
583
|
+
return p(q, h, v);
|
|
572
584
|
}
|
|
573
|
-
},
|
|
574
|
-
return
|
|
575
|
-
proxy:
|
|
576
|
-
stateVersion:
|
|
577
|
-
}),
|
|
585
|
+
}, b = new Proxy(y, c);
|
|
586
|
+
return S.set(N, {
|
|
587
|
+
proxy: b,
|
|
588
|
+
stateVersion: I
|
|
589
|
+
}), b;
|
|
578
590
|
}
|
|
579
|
-
return
|
|
580
|
-
|
|
591
|
+
return p(
|
|
592
|
+
a.getState().getNestedState(t, [])
|
|
581
593
|
);
|
|
582
594
|
}
|
|
583
|
-
function
|
|
584
|
-
return
|
|
595
|
+
function rt(t) {
|
|
596
|
+
return w.createElement(Nt, { proxy: t });
|
|
597
|
+
}
|
|
598
|
+
function $t({
|
|
599
|
+
proxy: t
|
|
600
|
+
}) {
|
|
601
|
+
const i = a().getNestedState(t._stateKey, t._path);
|
|
602
|
+
return console.log("value", i), Array.isArray(i) ? i.map((d, u) => t._mapFn(
|
|
603
|
+
d,
|
|
604
|
+
a.getState().updaterState[t._stateKey],
|
|
605
|
+
u,
|
|
606
|
+
i,
|
|
607
|
+
a.getState().updaterState[t._stateKey]
|
|
608
|
+
)) : null;
|
|
609
|
+
}
|
|
610
|
+
function Nt({
|
|
611
|
+
proxy: t
|
|
612
|
+
}) {
|
|
613
|
+
const i = w.useRef(null), d = `${t._stateKey}-${t._path.join(".")}`;
|
|
614
|
+
return console.log("SignalRenderer", d), w.useEffect(() => {
|
|
615
|
+
const u = i.current;
|
|
616
|
+
if (!u || !u.parentElement) return;
|
|
617
|
+
const S = u.parentElement, _ = Array.from(S.childNodes).indexOf(u);
|
|
618
|
+
let E = S.getAttribute("data-parent-id");
|
|
619
|
+
E || (E = `parent-${crypto.randomUUID()}`, S.setAttribute("data-parent-id", E));
|
|
620
|
+
const p = {
|
|
621
|
+
instanceId: `instance-${crypto.randomUUID()}`,
|
|
622
|
+
parentId: E,
|
|
623
|
+
position: _,
|
|
624
|
+
effect: t._effect
|
|
625
|
+
};
|
|
626
|
+
a.getState().addSignalElement(d, p);
|
|
627
|
+
const o = a.getState().getNestedState(t._stateKey, t._path), r = document.createTextNode(String(o));
|
|
628
|
+
u.replaceWith(r);
|
|
629
|
+
}, [t._stateKey, t._path.join("."), t._effect]), w.createElement("span", {
|
|
630
|
+
ref: i,
|
|
631
|
+
style: { display: "none" },
|
|
632
|
+
"data-signal-id": d
|
|
633
|
+
});
|
|
585
634
|
}
|
|
586
|
-
function
|
|
587
|
-
const i =
|
|
588
|
-
(
|
|
589
|
-
const u =
|
|
635
|
+
function Dt(t) {
|
|
636
|
+
const i = w.useSyncExternalStore(
|
|
637
|
+
(d) => {
|
|
638
|
+
const u = a.getState().stateComponents.get(t._stateKey) || {
|
|
590
639
|
components: /* @__PURE__ */ new Map()
|
|
591
640
|
};
|
|
592
641
|
return u.components.set(t._stateKey, {
|
|
593
|
-
forceUpdate:
|
|
642
|
+
forceUpdate: d,
|
|
594
643
|
paths: /* @__PURE__ */ new Set([t._path.join(".")])
|
|
595
644
|
}), () => u.components.delete(t._stateKey);
|
|
596
645
|
},
|
|
597
|
-
() =>
|
|
646
|
+
() => a.getState().getNestedState(t._stateKey, t._path)
|
|
598
647
|
);
|
|
599
|
-
return
|
|
648
|
+
return w.createElement("text", {}, String(i));
|
|
600
649
|
}
|
|
601
650
|
export {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
651
|
+
rt as $cogsSignal,
|
|
652
|
+
Dt as $cogsSignalStore,
|
|
653
|
+
Mt as addStateOptions,
|
|
654
|
+
Ot as createCogsState,
|
|
655
|
+
wt as useCogsStateFn
|
|
607
656
|
};
|
|
608
657
|
//# sourceMappingURL=CogsState.jsx.map
|