cogsbox-state 0.5.435 → 0.5.437
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 +38 -25
- package/dist/CogsState.d.ts.map +1 -0
- package/dist/CogsState.jsx +1292 -1181
- package/dist/CogsState.jsx.map +1 -1
- package/dist/CogsStateClient.d.ts +1 -0
- package/dist/CogsStateClient.d.ts.map +1 -0
- package/dist/CogsStateClient.jsx.map +1 -1
- package/dist/Functions.d.ts +2 -5
- package/dist/Functions.d.ts.map +1 -0
- package/dist/Functions.jsx +17 -48
- package/dist/Functions.jsx.map +1 -1
- package/dist/TRPCValidationLink.d.ts +1 -0
- package/dist/TRPCValidationLink.d.ts.map +1 -0
- package/dist/TRPCValidationLink.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/dist/store.d.ts +12 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +245 -185
- package/dist/store.js.map +1 -1
- package/dist/utility.d.ts +1 -0
- package/dist/utility.d.ts.map +1 -0
- package/dist/utility.js.map +1 -1
- package/package.json +7 -7
- package/src/CogsState.tsx +500 -179
- package/src/Functions.tsx +8 -241
- package/src/TRPCValidationLink.ts +12 -12
- package/src/index.ts +5 -4
- package/src/store.ts +195 -38
- package/dist/useValidateZodPath.d.ts +0 -34
- package/src/useValidateZodPath.ts +0 -231
package/dist/CogsState.jsx
CHANGED
|
@@ -1,260 +1,272 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { createRoot as
|
|
5
|
-
import { transformStateFunc as
|
|
6
|
-
import { ValidationWrapper as
|
|
7
|
-
import
|
|
8
|
-
import { v4 as
|
|
9
|
-
import { getGlobalStore as
|
|
10
|
-
import { useCogsConfig as
|
|
11
|
-
import { useInView as
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
...
|
|
16
|
-
...
|
|
2
|
+
import { jsx as ot, Fragment as Ut } from "react/jsx-runtime";
|
|
3
|
+
import { memo as Ot, useState as K, useRef as q, useCallback as ct, useEffect as Z, useLayoutEffect as dt, useMemo as St, createElement as lt, startTransition as Rt } from "react";
|
|
4
|
+
import { createRoot as At } from "react-dom/client";
|
|
5
|
+
import { transformStateFunc as Nt, isFunction as at, isArray as Tt, getDifferences as Ct, isDeepEqual as st } from "./utility.js";
|
|
6
|
+
import { ValidationWrapper as kt } from "./Functions.jsx";
|
|
7
|
+
import Ft from "superjson";
|
|
8
|
+
import { v4 as rt } from "uuid";
|
|
9
|
+
import { getGlobalStore as e, formRefStore as vt } from "./store.js";
|
|
10
|
+
import { useCogsConfig as Pt } from "./CogsStateClient.jsx";
|
|
11
|
+
import { useInView as jt } from "react-intersection-observer";
|
|
12
|
+
function yt(t, n) {
|
|
13
|
+
const g = e.getState().getInitialOptions, S = e.getState().setInitialStateOptions, y = g(t) || {};
|
|
14
|
+
S(t, {
|
|
15
|
+
...y,
|
|
16
|
+
...n
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
stateKey:
|
|
21
|
-
options:
|
|
22
|
-
initialOptionsPart:
|
|
19
|
+
function Et({
|
|
20
|
+
stateKey: t,
|
|
21
|
+
options: n,
|
|
22
|
+
initialOptionsPart: g
|
|
23
23
|
}) {
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
27
|
-
for (const
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const S = nt(t) || {}, y = g[t] || {}, I = e.getState().setInitialStateOptions, E = { ...y, ...S };
|
|
25
|
+
let u = !1;
|
|
26
|
+
if (n)
|
|
27
|
+
for (const f in n)
|
|
28
|
+
E.hasOwnProperty(f) ? (f == "localStorage" && n[f] && E[f].key !== n[f]?.key && (u = !0, E[f] = n[f]), f == "defaultState" && n[f] && E[f] !== n[f] && !st(E[f], n[f]) && (u = !0, E[f] = n[f])) : (u = !0, E[f] = n[f]);
|
|
29
|
+
u && I(t, E);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return { initialState:
|
|
31
|
+
function ie(t, { formElements: n, validation: g }) {
|
|
32
|
+
return { initialState: t, formElements: n, validation: g };
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
let
|
|
36
|
-
const [
|
|
37
|
-
Object.keys(
|
|
38
|
-
let
|
|
34
|
+
const Lt = (t, n) => {
|
|
35
|
+
let g = t;
|
|
36
|
+
const [S, y] = Nt(g);
|
|
37
|
+
n?.__fromSyncSchema && n?.__syncNotifications && e.getState().setInitialStateOptions("__notifications", n.__syncNotifications), Object.keys(S).forEach((u) => {
|
|
38
|
+
let f = y[u] || {};
|
|
39
39
|
const A = {
|
|
40
|
-
...
|
|
40
|
+
...f
|
|
41
41
|
};
|
|
42
|
-
if (
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
-
}),
|
|
46
|
-
...
|
|
47
|
-
...
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
...
|
|
42
|
+
if (n?.formElements && (A.formElements = {
|
|
43
|
+
...n.formElements,
|
|
44
|
+
...f.formElements || {}
|
|
45
|
+
}), n?.validation && (A.validation = {
|
|
46
|
+
...n.validation,
|
|
47
|
+
...f.validation || {}
|
|
48
|
+
}, n.validation.key && !f.validation?.key && (A.validation.key = `${n.validation.key}.${u}`)), Object.keys(A).length > 0) {
|
|
49
|
+
const w = nt(u);
|
|
50
|
+
w ? e.getState().setInitialStateOptions(u, {
|
|
51
|
+
...w,
|
|
52
52
|
...A
|
|
53
|
-
}) :
|
|
53
|
+
}) : e.getState().setInitialStateOptions(u, A);
|
|
54
54
|
}
|
|
55
|
-
}), Object.keys(
|
|
56
|
-
|
|
55
|
+
}), Object.keys(S).forEach((u) => {
|
|
56
|
+
e.getState().initializeShadowState(u, S[u]);
|
|
57
57
|
});
|
|
58
|
-
const
|
|
59
|
-
const [A] =
|
|
60
|
-
|
|
61
|
-
stateKey:
|
|
62
|
-
options:
|
|
63
|
-
initialOptionsPart:
|
|
58
|
+
const I = (u, f) => {
|
|
59
|
+
const [A] = K(f?.componentId ?? rt());
|
|
60
|
+
Et({
|
|
61
|
+
stateKey: u,
|
|
62
|
+
options: f,
|
|
63
|
+
initialOptionsPart: y
|
|
64
64
|
});
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
stateKey:
|
|
68
|
-
syncUpdate:
|
|
65
|
+
const w = e.getState().getShadowValue(u) || S[u], i = f?.modifyState ? f.modifyState(w) : w;
|
|
66
|
+
return zt(i, {
|
|
67
|
+
stateKey: u,
|
|
68
|
+
syncUpdate: f?.syncUpdate,
|
|
69
69
|
componentId: A,
|
|
70
|
-
localStorage:
|
|
71
|
-
middleware:
|
|
72
|
-
reactiveType:
|
|
73
|
-
reactiveDeps:
|
|
74
|
-
defaultState:
|
|
75
|
-
dependencies:
|
|
76
|
-
serverState:
|
|
70
|
+
localStorage: f?.localStorage,
|
|
71
|
+
middleware: f?.middleware,
|
|
72
|
+
reactiveType: f?.reactiveType,
|
|
73
|
+
reactiveDeps: f?.reactiveDeps,
|
|
74
|
+
defaultState: f?.defaultState,
|
|
75
|
+
dependencies: f?.dependencies,
|
|
76
|
+
serverState: f?.serverState
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
-
function
|
|
80
|
-
|
|
79
|
+
function E(u, f) {
|
|
80
|
+
Et({ stateKey: u, options: f, initialOptionsPart: y }), f.localStorage && xt(u, f), it(u);
|
|
81
81
|
}
|
|
82
|
-
return { useCogsState:
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
return { useCogsState: I, setCogsOptions: E };
|
|
83
|
+
};
|
|
84
|
+
function ce(t) {
|
|
85
|
+
const n = {};
|
|
86
|
+
for (const g in t.schemas) {
|
|
87
|
+
const S = t.schemas[g];
|
|
88
|
+
S.rawSchema ? n[g] = S.rawSchema : S.schemas?.defaults ? n[g] = S.schemas.defaults : n[g] = {};
|
|
89
|
+
}
|
|
90
|
+
return Lt(n, {
|
|
91
|
+
__fromSyncSchema: !0,
|
|
92
|
+
__syncNotifications: t.notifications
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const {
|
|
96
|
+
getInitialOptions: nt,
|
|
97
|
+
getValidationErrors: le,
|
|
98
|
+
setStateLog: Wt,
|
|
99
|
+
updateInitialStateGlobal: _t,
|
|
100
|
+
addValidationError: pt,
|
|
101
|
+
removeValidationError: ut
|
|
102
|
+
} = e.getState(), Ht = (t, n, g, S, y) => {
|
|
103
|
+
g?.log && console.log(
|
|
92
104
|
"saving to localstorage",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
n,
|
|
106
|
+
g.localStorage?.key,
|
|
107
|
+
S
|
|
96
108
|
);
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
let
|
|
109
|
+
const I = at(g?.localStorage?.key) ? g.localStorage?.key(t) : g?.localStorage?.key;
|
|
110
|
+
if (I && S) {
|
|
111
|
+
const E = `${S}-${n}-${I}`;
|
|
112
|
+
let u;
|
|
101
113
|
try {
|
|
102
|
-
|
|
114
|
+
u = gt(E)?.lastSyncedWithServer;
|
|
103
115
|
} catch {
|
|
104
116
|
}
|
|
105
|
-
const
|
|
106
|
-
state:
|
|
117
|
+
const f = e.getState().getShadowMetadata(n, []), A = {
|
|
118
|
+
state: t,
|
|
107
119
|
lastUpdated: Date.now(),
|
|
108
|
-
lastSyncedWithServer:
|
|
109
|
-
stateSource:
|
|
110
|
-
baseServerState:
|
|
111
|
-
},
|
|
120
|
+
lastSyncedWithServer: u,
|
|
121
|
+
stateSource: f?.stateSource,
|
|
122
|
+
baseServerState: f?.baseServerState
|
|
123
|
+
}, w = Ft.serialize(A);
|
|
112
124
|
window.localStorage.setItem(
|
|
113
|
-
|
|
114
|
-
JSON.stringify(
|
|
125
|
+
E,
|
|
126
|
+
JSON.stringify(w.json)
|
|
115
127
|
);
|
|
116
128
|
}
|
|
117
|
-
},
|
|
118
|
-
if (!
|
|
129
|
+
}, gt = (t) => {
|
|
130
|
+
if (!t) return null;
|
|
119
131
|
try {
|
|
120
|
-
const
|
|
121
|
-
return
|
|
122
|
-
} catch (
|
|
123
|
-
return console.error("Error loading from localStorage:",
|
|
132
|
+
const n = window.localStorage.getItem(t);
|
|
133
|
+
return n ? JSON.parse(n) : null;
|
|
134
|
+
} catch (n) {
|
|
135
|
+
return console.error("Error loading from localStorage:", n), null;
|
|
124
136
|
}
|
|
125
|
-
},
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
`${
|
|
137
|
+
}, xt = (t, n) => {
|
|
138
|
+
const g = e.getState().getShadowValue(t), { sessionId: S } = Pt(), y = at(n?.localStorage?.key) ? n.localStorage.key(g) : n?.localStorage?.key;
|
|
139
|
+
if (y && S) {
|
|
140
|
+
const I = gt(
|
|
141
|
+
`${S}-${t}-${y}`
|
|
130
142
|
);
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
143
|
+
if (I && I.lastUpdated > (I.lastSyncedWithServer || 0))
|
|
144
|
+
return it(t), !0;
|
|
133
145
|
}
|
|
134
146
|
return !1;
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
(
|
|
147
|
+
}, it = (t) => {
|
|
148
|
+
const n = e.getState().getShadowMetadata(t, []);
|
|
149
|
+
if (!n) return;
|
|
150
|
+
const g = /* @__PURE__ */ new Set();
|
|
151
|
+
n?.components?.forEach((S) => {
|
|
152
|
+
(S ? Array.isArray(S.reactiveType) ? S.reactiveType : [S.reactiveType || "component"] : null)?.includes("none") || g.add(() => S.forceUpdate());
|
|
141
153
|
}), queueMicrotask(() => {
|
|
142
|
-
|
|
154
|
+
g.forEach((S) => S());
|
|
143
155
|
});
|
|
144
|
-
},
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
if ((
|
|
156
|
+
}, ue = (t, n) => {
|
|
157
|
+
const g = e.getState().getShadowMetadata(t, []);
|
|
158
|
+
if (g) {
|
|
159
|
+
const S = `${t}////${n}`, y = g?.components?.get(S);
|
|
160
|
+
if ((y ? Array.isArray(y.reactiveType) ? y.reactiveType : [y.reactiveType || "component"] : null)?.includes("none"))
|
|
149
161
|
return;
|
|
150
|
-
|
|
162
|
+
y && y.forceUpdate();
|
|
151
163
|
}
|
|
152
164
|
};
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
...
|
|
165
|
+
function wt(t, n, g, S) {
|
|
166
|
+
const y = e.getState(), I = y.getShadowMetadata(t, n);
|
|
167
|
+
if (y.setShadowMetadata(t, n, {
|
|
168
|
+
...I,
|
|
157
169
|
isDirty: !1,
|
|
158
170
|
stateSource: "server",
|
|
159
|
-
lastServerSync:
|
|
160
|
-
}), Array.isArray(
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const A =
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
lastServerSync: S || Date.now()
|
|
172
|
+
}), Array.isArray(g)) {
|
|
173
|
+
const E = y.getShadowMetadata(t, n);
|
|
174
|
+
E?.arrayKeys && E.arrayKeys.forEach((u, f) => {
|
|
175
|
+
const A = u.split(".").slice(1), w = g[f];
|
|
176
|
+
w !== void 0 && wt(
|
|
177
|
+
t,
|
|
166
178
|
A,
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
w,
|
|
180
|
+
S
|
|
169
181
|
);
|
|
170
182
|
});
|
|
171
|
-
} else
|
|
172
|
-
const
|
|
173
|
-
|
|
183
|
+
} else g && typeof g == "object" && g.constructor === Object && Object.keys(g).forEach((E) => {
|
|
184
|
+
const u = [...n, E], f = g[E];
|
|
185
|
+
wt(t, u, f, S);
|
|
174
186
|
});
|
|
175
187
|
}
|
|
176
|
-
function
|
|
177
|
-
stateKey:
|
|
178
|
-
localStorage:
|
|
179
|
-
formElements:
|
|
180
|
-
reactiveDeps:
|
|
181
|
-
reactiveType:
|
|
182
|
-
componentId:
|
|
183
|
-
defaultState:
|
|
184
|
-
syncUpdate:
|
|
188
|
+
function zt(t, {
|
|
189
|
+
stateKey: n,
|
|
190
|
+
localStorage: g,
|
|
191
|
+
formElements: S,
|
|
192
|
+
reactiveDeps: y,
|
|
193
|
+
reactiveType: I,
|
|
194
|
+
componentId: E,
|
|
195
|
+
defaultState: u,
|
|
196
|
+
syncUpdate: f,
|
|
185
197
|
dependencies: A,
|
|
186
|
-
serverState:
|
|
198
|
+
serverState: w
|
|
187
199
|
} = {}) {
|
|
188
|
-
const [
|
|
189
|
-
let
|
|
190
|
-
const [c] =
|
|
200
|
+
const [i, h] = K({}), { sessionId: M } = Pt();
|
|
201
|
+
let z = !n;
|
|
202
|
+
const [c] = K(n ?? rt()), B = e.getState().stateLog[c], J = q(/* @__PURE__ */ new Set()), H = q(E ?? rt()), W = q(
|
|
191
203
|
null
|
|
192
204
|
);
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
timeStamp:
|
|
198
|
-
userId:
|
|
205
|
+
W.current = nt(c) ?? null, Z(() => {
|
|
206
|
+
if (f && f.stateKey === c && f.path?.[0]) {
|
|
207
|
+
const o = `${f.stateKey}:${f.path.join(".")}`;
|
|
208
|
+
e.getState().setSyncInfo(o, {
|
|
209
|
+
timeStamp: f.timeStamp,
|
|
210
|
+
userId: f.userId
|
|
199
211
|
});
|
|
200
212
|
}
|
|
201
|
-
}, [
|
|
202
|
-
const
|
|
203
|
-
(
|
|
204
|
-
const a =
|
|
213
|
+
}, [f]);
|
|
214
|
+
const m = ct(
|
|
215
|
+
(o) => {
|
|
216
|
+
const a = o ? { ...nt(c), ...o } : nt(c), d = a?.defaultState || u || t;
|
|
205
217
|
if (a?.serverState?.status === "success" && a?.serverState?.data !== void 0)
|
|
206
218
|
return {
|
|
207
219
|
value: a.serverState.data,
|
|
208
220
|
source: "server",
|
|
209
221
|
timestamp: a.serverState.timestamp || Date.now()
|
|
210
222
|
};
|
|
211
|
-
if (a?.localStorage?.key &&
|
|
212
|
-
const
|
|
213
|
-
`${
|
|
223
|
+
if (a?.localStorage?.key && M) {
|
|
224
|
+
const p = at(a.localStorage.key) ? a.localStorage.key(d) : a.localStorage.key, V = gt(
|
|
225
|
+
`${M}-${c}-${p}`
|
|
214
226
|
);
|
|
215
|
-
if (
|
|
227
|
+
if (V && V.lastUpdated > (a?.serverState?.timestamp || 0))
|
|
216
228
|
return {
|
|
217
|
-
value:
|
|
229
|
+
value: V.state,
|
|
218
230
|
source: "localStorage",
|
|
219
|
-
timestamp:
|
|
231
|
+
timestamp: V.lastUpdated
|
|
220
232
|
};
|
|
221
233
|
}
|
|
222
234
|
return {
|
|
223
|
-
value: d ||
|
|
235
|
+
value: d || t,
|
|
224
236
|
source: "default",
|
|
225
237
|
timestamp: Date.now()
|
|
226
238
|
};
|
|
227
239
|
},
|
|
228
|
-
[c,
|
|
240
|
+
[c, u, t, M]
|
|
229
241
|
);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}, [
|
|
242
|
+
Z(() => {
|
|
243
|
+
e.getState().setServerStateUpdate(c, w);
|
|
244
|
+
}, [w, c]), Z(() => e.getState().subscribeToPath(c, (r) => {
|
|
233
245
|
if (r?.type === "SERVER_STATE_UPDATE") {
|
|
234
246
|
const a = r.serverState;
|
|
235
247
|
if (a?.status === "success" && a.data !== void 0) {
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
), F =
|
|
242
|
-
F.length > 0 && F.forEach((
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
|
|
248
|
+
yt(c, { serverState: a });
|
|
249
|
+
const l = typeof a.merge == "object" ? a.merge : a.merge === !0 ? {} : null, p = e.getState().getShadowValue(c), V = a.data;
|
|
250
|
+
if (l && Array.isArray(p) && Array.isArray(V)) {
|
|
251
|
+
const U = l.key || "id", C = new Set(
|
|
252
|
+
p.map((x) => x[U])
|
|
253
|
+
), F = V.filter((x) => !C.has(x[U]));
|
|
254
|
+
F.length > 0 && F.forEach((x) => {
|
|
255
|
+
e.getState().insertShadowArrayElement(c, [], x);
|
|
256
|
+
const N = e.getState().getShadowMetadata(c, []);
|
|
257
|
+
if (N?.arrayKeys) {
|
|
258
|
+
const j = N.arrayKeys[N.arrayKeys.length - 1];
|
|
259
|
+
if (j) {
|
|
260
|
+
const b = j.split(".").slice(1);
|
|
261
|
+
e.getState().setShadowMetadata(c, b, {
|
|
250
262
|
isDirty: !1,
|
|
251
263
|
stateSource: "server",
|
|
252
264
|
lastServerSync: a.timestamp || Date.now()
|
|
253
265
|
});
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
|
|
266
|
+
const k = e.getState().getShadowValue(j);
|
|
267
|
+
k && typeof k == "object" && !Array.isArray(k) && Object.keys(k).forEach((P) => {
|
|
268
|
+
const O = [...b, P];
|
|
269
|
+
e.getState().setShadowMetadata(c, O, {
|
|
258
270
|
isDirty: !1,
|
|
259
271
|
stateSource: "server",
|
|
260
272
|
lastServerSync: a.timestamp || Date.now()
|
|
@@ -264,634 +276,620 @@ function Be(e, {
|
|
|
264
276
|
}
|
|
265
277
|
});
|
|
266
278
|
} else
|
|
267
|
-
|
|
279
|
+
e.getState().initializeShadowState(c, V), wt(
|
|
268
280
|
c,
|
|
269
281
|
[],
|
|
270
|
-
|
|
282
|
+
V,
|
|
271
283
|
a.timestamp
|
|
272
284
|
);
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
...
|
|
285
|
+
const _ = e.getState().getShadowMetadata(c, []);
|
|
286
|
+
e.getState().setShadowMetadata(c, [], {
|
|
287
|
+
..._,
|
|
276
288
|
stateSource: "server",
|
|
277
289
|
lastServerSync: a.timestamp || Date.now(),
|
|
278
290
|
isDirty: !1
|
|
279
291
|
});
|
|
280
292
|
}
|
|
281
293
|
}
|
|
282
|
-
}), [c,
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
294
|
+
}), [c, m]), Z(() => {
|
|
295
|
+
const o = e.getState().getShadowMetadata(c, []);
|
|
296
|
+
if (o && o.stateSource)
|
|
285
297
|
return;
|
|
286
|
-
const r =
|
|
287
|
-
if (r?.defaultState !== void 0 ||
|
|
288
|
-
const a = r?.defaultState ||
|
|
289
|
-
r?.defaultState ||
|
|
298
|
+
const r = nt(c);
|
|
299
|
+
if (r?.defaultState !== void 0 || u !== void 0) {
|
|
300
|
+
const a = r?.defaultState || u;
|
|
301
|
+
r?.defaultState || yt(c, {
|
|
290
302
|
defaultState: a
|
|
291
303
|
});
|
|
292
|
-
const { value: d, source:
|
|
293
|
-
|
|
294
|
-
stateSource:
|
|
295
|
-
lastServerSync:
|
|
304
|
+
const { value: d, source: l, timestamp: p } = m();
|
|
305
|
+
e.getState().initializeShadowState(c, d), e.getState().setShadowMetadata(c, [], {
|
|
306
|
+
stateSource: l,
|
|
307
|
+
lastServerSync: l === "server" ? p : void 0,
|
|
296
308
|
isDirty: !1,
|
|
297
|
-
baseServerState:
|
|
298
|
-
}),
|
|
309
|
+
baseServerState: l === "server" ? d : void 0
|
|
310
|
+
}), it(c);
|
|
299
311
|
}
|
|
300
|
-
}, [c, ...A || []]),
|
|
301
|
-
|
|
302
|
-
formElements:
|
|
303
|
-
defaultState:
|
|
304
|
-
localStorage:
|
|
305
|
-
middleware:
|
|
312
|
+
}, [c, ...A || []]), dt(() => {
|
|
313
|
+
z && yt(c, {
|
|
314
|
+
formElements: S,
|
|
315
|
+
defaultState: u,
|
|
316
|
+
localStorage: g,
|
|
317
|
+
middleware: W.current?.middleware
|
|
306
318
|
});
|
|
307
|
-
const
|
|
308
|
-
return a.set(
|
|
309
|
-
forceUpdate: () =>
|
|
310
|
-
reactiveType:
|
|
319
|
+
const o = `${c}////${H.current}`, r = e.getState().getShadowMetadata(c, []), a = r?.components || /* @__PURE__ */ new Map();
|
|
320
|
+
return a.set(o, {
|
|
321
|
+
forceUpdate: () => h({}),
|
|
322
|
+
reactiveType: I ?? ["component", "deps"],
|
|
311
323
|
paths: /* @__PURE__ */ new Set(),
|
|
312
|
-
depsFunction:
|
|
313
|
-
deps:
|
|
314
|
-
prevDeps:
|
|
315
|
-
}),
|
|
324
|
+
depsFunction: y || void 0,
|
|
325
|
+
deps: y ? y(e.getState().getShadowValue(c)) : [],
|
|
326
|
+
prevDeps: y ? y(e.getState().getShadowValue(c)) : []
|
|
327
|
+
}), e.getState().setShadowMetadata(c, [], {
|
|
316
328
|
...r,
|
|
317
329
|
components: a
|
|
318
|
-
}),
|
|
319
|
-
const d =
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
}), d?.components &&
|
|
330
|
+
}), h({}), () => {
|
|
331
|
+
const d = e.getState().getShadowMetadata(c, []), l = d?.components?.get(o);
|
|
332
|
+
l?.paths && l.paths.forEach((p) => {
|
|
333
|
+
const _ = p.split(".").slice(1), U = e.getState().getShadowMetadata(c, _);
|
|
334
|
+
U?.pathComponents && U.pathComponents.size === 0 && (delete U.pathComponents, e.getState().setShadowMetadata(c, _, U));
|
|
335
|
+
}), d?.components && e.getState().setShadowMetadata(c, [], d);
|
|
324
336
|
};
|
|
325
337
|
}, []);
|
|
326
|
-
const
|
|
327
|
-
const
|
|
338
|
+
const Y = q(null), Q = (o, r, a) => {
|
|
339
|
+
const d = [c, ...r].join(".");
|
|
328
340
|
if (Array.isArray(r)) {
|
|
329
|
-
const
|
|
330
|
-
|
|
341
|
+
const b = `${c}-${r.join(".")}`;
|
|
342
|
+
J.current.add(b);
|
|
331
343
|
}
|
|
332
|
-
const
|
|
344
|
+
const l = e.getState(), p = l.getShadowMetadata(c, r), V = l.getShadowValue(d), _ = a.updateType === "insert" && at(o) ? o({ state: V, uuid: rt() }) : at(o) ? o(V) : o, C = {
|
|
333
345
|
timeStamp: Date.now(),
|
|
334
346
|
stateKey: c,
|
|
335
347
|
path: r,
|
|
336
348
|
updateType: a.updateType,
|
|
337
349
|
status: "new",
|
|
338
|
-
oldValue:
|
|
339
|
-
newValue:
|
|
350
|
+
oldValue: V,
|
|
351
|
+
newValue: _
|
|
340
352
|
};
|
|
341
353
|
switch (a.updateType) {
|
|
342
354
|
case "insert": {
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
|
|
355
|
+
l.insertShadowArrayElement(c, r, C.newValue), l.markAsDirty(c, r, { bubble: !0 });
|
|
356
|
+
const b = l.getShadowMetadata(c, r);
|
|
357
|
+
if (b?.arrayKeys) {
|
|
358
|
+
const k = b.arrayKeys[b.arrayKeys.length - 1];
|
|
359
|
+
if (k) {
|
|
360
|
+
const P = k.split(".").slice(1);
|
|
361
|
+
l.markAsDirty(c, P, { bubble: !1 });
|
|
350
362
|
}
|
|
351
363
|
}
|
|
352
364
|
break;
|
|
353
365
|
}
|
|
354
366
|
case "cut": {
|
|
355
|
-
const
|
|
356
|
-
|
|
367
|
+
const b = r.slice(0, -1);
|
|
368
|
+
l.removeShadowArrayElement(c, r), l.markAsDirty(c, b, { bubble: !0 });
|
|
357
369
|
break;
|
|
358
370
|
}
|
|
359
371
|
case "update": {
|
|
360
|
-
|
|
372
|
+
l.updateShadowAtPath(c, r, C.newValue), l.markAsDirty(c, r, { bubble: !0 });
|
|
361
373
|
break;
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
|
-
if (
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
let
|
|
372
|
-
if (
|
|
376
|
+
if (a.sync !== !1 && Y.current && Y.current.connected && Y.current.updateState({ operation: C }), p?.signals && p.signals.length > 0) {
|
|
377
|
+
const b = a.updateType === "cut" ? null : _;
|
|
378
|
+
p.signals.forEach(({ parentId: k, position: P, effect: O }) => {
|
|
379
|
+
const v = document.querySelector(`[data-parent-id="${k}"]`);
|
|
380
|
+
if (v) {
|
|
381
|
+
const T = Array.from(v.childNodes);
|
|
382
|
+
if (T[P]) {
|
|
383
|
+
let $ = b;
|
|
384
|
+
if (O && b !== null)
|
|
373
385
|
try {
|
|
374
|
-
|
|
386
|
+
$ = new Function(
|
|
375
387
|
"state",
|
|
376
|
-
`return (${
|
|
377
|
-
)(
|
|
378
|
-
} catch (
|
|
379
|
-
console.error("Error evaluating effect function:",
|
|
388
|
+
`return (${O})(state)`
|
|
389
|
+
)(b);
|
|
390
|
+
} catch (D) {
|
|
391
|
+
console.error("Error evaluating effect function:", D);
|
|
380
392
|
}
|
|
381
|
-
|
|
393
|
+
$ != null && typeof $ == "object" && ($ = JSON.stringify($)), T[P].textContent = String($ ?? "");
|
|
382
394
|
}
|
|
383
395
|
}
|
|
384
396
|
});
|
|
385
397
|
}
|
|
386
|
-
if (a.updateType === "insert" &&
|
|
387
|
-
const
|
|
398
|
+
if (a.updateType === "insert" && p?.mapWrappers && p.mapWrappers.length > 0) {
|
|
399
|
+
const b = l.getShadowMetadata(c, r)?.arrayKeys || [], k = b[b.length - 1], P = l.getShadowValue(k), O = l.getShadowValue(
|
|
388
400
|
[c, ...r].join(".")
|
|
389
401
|
);
|
|
390
|
-
if (!
|
|
391
|
-
|
|
392
|
-
let
|
|
393
|
-
if (
|
|
394
|
-
for (const
|
|
395
|
-
if (
|
|
396
|
-
|
|
402
|
+
if (!k || P === void 0) return;
|
|
403
|
+
p.mapWrappers.forEach((v) => {
|
|
404
|
+
let T = !0, $ = -1;
|
|
405
|
+
if (v.meta?.transforms && v.meta.transforms.length > 0) {
|
|
406
|
+
for (const D of v.meta.transforms)
|
|
407
|
+
if (D.type === "filter" && !D.fn(P, -1)) {
|
|
408
|
+
T = !1;
|
|
397
409
|
break;
|
|
398
410
|
}
|
|
399
|
-
if (
|
|
400
|
-
const
|
|
411
|
+
if (T) {
|
|
412
|
+
const D = It(
|
|
401
413
|
c,
|
|
402
414
|
r,
|
|
403
|
-
|
|
404
|
-
),
|
|
405
|
-
(
|
|
415
|
+
v.meta.transforms
|
|
416
|
+
), R = v.meta.transforms.find(
|
|
417
|
+
(L) => L.type === "sort"
|
|
406
418
|
);
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
409
|
-
key:
|
|
410
|
-
value:
|
|
419
|
+
if (R) {
|
|
420
|
+
const L = D.map((G) => ({
|
|
421
|
+
key: G,
|
|
422
|
+
value: l.getShadowValue(G)
|
|
411
423
|
}));
|
|
412
|
-
|
|
413
|
-
(
|
|
424
|
+
L.push({ key: k, value: P }), L.sort((G, tt) => R.fn(G.value, tt.value)), $ = L.findIndex(
|
|
425
|
+
(G) => G.key === k
|
|
414
426
|
);
|
|
415
427
|
} else
|
|
416
|
-
|
|
428
|
+
$ = D.length;
|
|
417
429
|
}
|
|
418
430
|
} else
|
|
419
|
-
|
|
420
|
-
if (
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
) :
|
|
428
|
-
const
|
|
429
|
-
path:
|
|
430
|
-
currentState:
|
|
431
|
-
componentId:
|
|
432
|
-
meta:
|
|
431
|
+
T = !0, $ = b.length - 1;
|
|
432
|
+
if (T && v.containerRef && v.containerRef.isConnected) {
|
|
433
|
+
const D = document.createElement("div");
|
|
434
|
+
D.setAttribute("data-item-path", k);
|
|
435
|
+
const R = Array.from(v.containerRef.children);
|
|
436
|
+
$ >= 0 && $ < R.length ? v.containerRef.insertBefore(
|
|
437
|
+
D,
|
|
438
|
+
R[$]
|
|
439
|
+
) : v.containerRef.appendChild(D);
|
|
440
|
+
const L = At(D), G = rt(), tt = k.split(".").slice(1), et = v.rebuildStateShape({
|
|
441
|
+
path: v.path,
|
|
442
|
+
currentState: O,
|
|
443
|
+
componentId: v.componentId,
|
|
444
|
+
meta: v.meta
|
|
433
445
|
});
|
|
434
|
-
|
|
435
|
-
|
|
446
|
+
L.render(
|
|
447
|
+
lt(Mt, {
|
|
436
448
|
stateKey: c,
|
|
437
|
-
itemComponentId:
|
|
438
|
-
itemPath:
|
|
439
|
-
localIndex:
|
|
440
|
-
arraySetter:
|
|
441
|
-
rebuildStateShape:
|
|
442
|
-
renderFn:
|
|
449
|
+
itemComponentId: G,
|
|
450
|
+
itemPath: tt,
|
|
451
|
+
localIndex: $,
|
|
452
|
+
arraySetter: et,
|
|
453
|
+
rebuildStateShape: v.rebuildStateShape,
|
|
454
|
+
renderFn: v.mapFn
|
|
443
455
|
})
|
|
444
456
|
);
|
|
445
457
|
}
|
|
446
458
|
});
|
|
447
459
|
}
|
|
448
460
|
if (a.updateType === "cut") {
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
const
|
|
453
|
-
`[data-item-path="${
|
|
461
|
+
const b = r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
462
|
+
k?.mapWrappers && k.mapWrappers.length > 0 && k.mapWrappers.forEach((P) => {
|
|
463
|
+
if (P.containerRef && P.containerRef.isConnected) {
|
|
464
|
+
const O = P.containerRef.querySelector(
|
|
465
|
+
`[data-item-path="${d}"]`
|
|
454
466
|
);
|
|
455
|
-
|
|
467
|
+
O && O.remove();
|
|
456
468
|
}
|
|
457
469
|
});
|
|
458
470
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
const x = e.getState().getShadowValue(c), N = e.getState().getShadowMetadata(c, []), j = /* @__PURE__ */ new Set();
|
|
472
|
+
if (console.log(
|
|
473
|
+
"rootMeta",
|
|
474
|
+
c,
|
|
475
|
+
e.getState().shadowStateStore
|
|
476
|
+
), !N?.components)
|
|
477
|
+
return x;
|
|
478
|
+
if (a.updateType === "update") {
|
|
479
|
+
let b = [...r];
|
|
480
|
+
for (; ; ) {
|
|
481
|
+
const k = l.getShadowMetadata(c, b);
|
|
482
|
+
if (k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
483
|
+
if (j.has(P))
|
|
484
|
+
return;
|
|
485
|
+
const O = N.components?.get(P);
|
|
486
|
+
O && ((Array.isArray(O.reactiveType) ? O.reactiveType : [O.reactiveType || "component"]).includes("none") || (O.forceUpdate(), j.add(P)));
|
|
487
|
+
}), b.length === 0)
|
|
488
|
+
break;
|
|
489
|
+
b.pop();
|
|
473
490
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (a.updateType === "update")
|
|
479
|
-
P?.pathComponents && P.pathComponents.forEach((V) => {
|
|
480
|
-
if (B.has(V))
|
|
481
|
-
return;
|
|
482
|
-
const E = N.components?.get(V);
|
|
483
|
-
E && ((Array.isArray(E.reactiveType) ? E.reactiveType : [E.reactiveType || "component"]).includes("none") || (E.forceUpdate(), B.add(V)));
|
|
484
|
-
}), D && typeof D == "object" && !Te(D) && R && typeof R == "object" && !Te(R) && Pe(D, R).forEach((E) => {
|
|
485
|
-
const $ = E.split("."), I = [...r, ...$], y = m.getShadowMetadata(c, I);
|
|
486
|
-
y?.pathComponents && y.pathComponents.forEach((k) => {
|
|
487
|
-
if (B.has(k))
|
|
491
|
+
_ && typeof _ == "object" && !Tt(_) && V && typeof V == "object" && !Tt(V) && Ct(_, V).forEach((P) => {
|
|
492
|
+
const O = P.split("."), v = [...r, ...O], T = l.getShadowMetadata(c, v);
|
|
493
|
+
T?.pathComponents && T.pathComponents.forEach(($) => {
|
|
494
|
+
if (j.has($))
|
|
488
495
|
return;
|
|
489
|
-
const
|
|
490
|
-
|
|
496
|
+
const D = N.components?.get($);
|
|
497
|
+
D && ((Array.isArray(D.reactiveType) ? D.reactiveType : [D.reactiveType || "component"]).includes("none") || (D.forceUpdate(), j.add($)));
|
|
491
498
|
});
|
|
492
499
|
});
|
|
493
|
-
else if (a.updateType === "insert" || a.updateType === "cut") {
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
`[data-parent-id="${
|
|
500
|
+
} else if (a.updateType === "insert" || a.updateType === "cut") {
|
|
501
|
+
const b = a.updateType === "insert" ? r : r.slice(0, -1), k = l.getShadowMetadata(c, b);
|
|
502
|
+
if (k?.signals && k.signals.length > 0) {
|
|
503
|
+
const P = [c, ...b].join("."), O = l.getShadowValue(P);
|
|
504
|
+
k.signals.forEach(({ parentId: v, position: T, effect: $ }) => {
|
|
505
|
+
const D = document.querySelector(
|
|
506
|
+
`[data-parent-id="${v}"]`
|
|
500
507
|
);
|
|
501
|
-
if (
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
let
|
|
505
|
-
if (
|
|
508
|
+
if (D) {
|
|
509
|
+
const R = Array.from(D.childNodes);
|
|
510
|
+
if (R[T]) {
|
|
511
|
+
let L = O;
|
|
512
|
+
if ($)
|
|
506
513
|
try {
|
|
507
|
-
|
|
514
|
+
L = new Function(
|
|
508
515
|
"state",
|
|
509
|
-
`return (${
|
|
510
|
-
)(
|
|
511
|
-
} catch (
|
|
512
|
-
console.error("Error evaluating effect function:",
|
|
516
|
+
`return (${$})(state)`
|
|
517
|
+
)(O);
|
|
518
|
+
} catch (G) {
|
|
519
|
+
console.error("Error evaluating effect function:", G), L = O;
|
|
513
520
|
}
|
|
514
|
-
|
|
521
|
+
L != null && typeof L == "object" && (L = JSON.stringify(L)), R[T].textContent = String(L ?? "");
|
|
515
522
|
}
|
|
516
523
|
}
|
|
517
524
|
});
|
|
518
525
|
}
|
|
519
|
-
|
|
520
|
-
if (!
|
|
521
|
-
const
|
|
522
|
-
|
|
526
|
+
k?.pathComponents && k.pathComponents.forEach((P) => {
|
|
527
|
+
if (!j.has(P)) {
|
|
528
|
+
const O = N.components?.get(P);
|
|
529
|
+
O && (O.forceUpdate(), j.add(P));
|
|
523
530
|
}
|
|
524
531
|
});
|
|
525
532
|
}
|
|
526
|
-
return N.components.forEach((
|
|
527
|
-
if (
|
|
533
|
+
return N.components.forEach((b, k) => {
|
|
534
|
+
if (j.has(k))
|
|
528
535
|
return;
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
|
|
536
|
+
const P = Array.isArray(b.reactiveType) ? b.reactiveType : [b.reactiveType || "component"];
|
|
537
|
+
if (P.includes("all")) {
|
|
538
|
+
b.forceUpdate(), j.add(k);
|
|
532
539
|
return;
|
|
533
540
|
}
|
|
534
|
-
if (
|
|
535
|
-
const
|
|
536
|
-
let
|
|
537
|
-
|
|
541
|
+
if (P.includes("deps") && b.depsFunction) {
|
|
542
|
+
const O = l.getShadowValue(c), v = b.depsFunction(O);
|
|
543
|
+
let T = !1;
|
|
544
|
+
v === !0 ? T = !0 : Array.isArray(v) && (st(b.prevDeps, v) || (b.prevDeps = v, T = !0)), T && (b.forceUpdate(), j.add(k));
|
|
538
545
|
}
|
|
539
|
-
}),
|
|
540
|
-
const
|
|
541
|
-
return
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
}), Array.from(
|
|
545
|
-
}),
|
|
546
|
-
|
|
546
|
+
}), j.clear(), Wt(c, (b) => {
|
|
547
|
+
const k = [...b ?? [], C], P = /* @__PURE__ */ new Map();
|
|
548
|
+
return k.forEach((O) => {
|
|
549
|
+
const v = `${O.stateKey}:${JSON.stringify(O.path)}`, T = P.get(v);
|
|
550
|
+
T ? (T.timeStamp = Math.max(T.timeStamp, O.timeStamp), T.newValue = O.newValue, T.oldValue = T.oldValue ?? O.oldValue, T.updateType = O.updateType) : P.set(v, { ...O });
|
|
551
|
+
}), Array.from(P.values());
|
|
552
|
+
}), Ht(
|
|
553
|
+
_,
|
|
547
554
|
c,
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
),
|
|
551
|
-
updateLog:
|
|
552
|
-
update:
|
|
553
|
-
}),
|
|
555
|
+
W.current,
|
|
556
|
+
M
|
|
557
|
+
), W.current?.middleware && W.current.middleware({
|
|
558
|
+
updateLog: B,
|
|
559
|
+
update: C
|
|
560
|
+
}), x;
|
|
554
561
|
};
|
|
555
|
-
|
|
556
|
-
const
|
|
562
|
+
e.getState().initialStateGlobal[c] || _t(c, t);
|
|
563
|
+
const X = St(() => Dt(
|
|
557
564
|
c,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
), [c,
|
|
562
|
-
return s && (
|
|
565
|
+
Q,
|
|
566
|
+
H.current,
|
|
567
|
+
M
|
|
568
|
+
), [c, M]), s = W.current?.cogsSync;
|
|
569
|
+
return s && (Y.current = s(X)), X;
|
|
563
570
|
}
|
|
564
|
-
function
|
|
565
|
-
return !
|
|
566
|
-
(
|
|
571
|
+
function Bt(t) {
|
|
572
|
+
return !t || t.length === 0 ? "" : t.map(
|
|
573
|
+
(n) => (
|
|
567
574
|
// Safely stringify dependencies. An empty array becomes '[]'.
|
|
568
|
-
`${
|
|
575
|
+
`${n.type}${JSON.stringify(n.dependencies || [])}`
|
|
569
576
|
)
|
|
570
577
|
).join("");
|
|
571
578
|
}
|
|
572
|
-
const
|
|
573
|
-
let
|
|
574
|
-
if (!
|
|
575
|
-
return
|
|
576
|
-
let
|
|
577
|
-
key:
|
|
578
|
-
value:
|
|
579
|
+
const It = (t, n, g) => {
|
|
580
|
+
let S = e.getState().getShadowMetadata(t, n)?.arrayKeys || [];
|
|
581
|
+
if (!g || g.length === 0)
|
|
582
|
+
return S;
|
|
583
|
+
let y = S.map((I) => ({
|
|
584
|
+
key: I,
|
|
585
|
+
value: e.getState().getShadowValue(I)
|
|
579
586
|
}));
|
|
580
|
-
for (const
|
|
581
|
-
|
|
582
|
-
({ value:
|
|
583
|
-
) :
|
|
584
|
-
return
|
|
585
|
-
},
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
pathComponents: u
|
|
595
|
-
});
|
|
596
|
-
}, ye = (e, i, f) => {
|
|
597
|
-
const g = t.getState(), h = g.getShadowMetadata(e, []), p = /* @__PURE__ */ new Set();
|
|
598
|
-
h?.components && h.components.forEach((l, u) => {
|
|
599
|
-
(Array.isArray(l.reactiveType) ? l.reactiveType : [l.reactiveType || "component"]).includes("all") && (l.forceUpdate(), p.add(u));
|
|
600
|
-
}), g.getShadowMetadata(e, [...i, "getSelected"])?.pathComponents?.forEach((l) => {
|
|
601
|
-
h?.components?.get(l)?.forceUpdate();
|
|
587
|
+
for (const I of g)
|
|
588
|
+
I.type === "filter" ? y = y.filter(
|
|
589
|
+
({ value: E }, u) => I.fn(E, u)
|
|
590
|
+
) : I.type === "sort" && y.sort((E, u) => I.fn(E.value, u.value));
|
|
591
|
+
return y.map(({ key: I }) => I);
|
|
592
|
+
}, Vt = (t, n, g) => {
|
|
593
|
+
const S = `${t}////${n}`, { addPathComponent: y, getShadowMetadata: I } = e.getState(), u = I(t, [])?.components?.get(S);
|
|
594
|
+
!u || u.reactiveType === "none" || !(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType]).includes("component") || y(t, g, S);
|
|
595
|
+
}, ft = (t, n, g) => {
|
|
596
|
+
const S = e.getState(), y = S.getShadowMetadata(t, []), I = /* @__PURE__ */ new Set();
|
|
597
|
+
y?.components && y.components.forEach((u, f) => {
|
|
598
|
+
(Array.isArray(u.reactiveType) ? u.reactiveType : [u.reactiveType || "component"]).includes("all") && (u.forceUpdate(), I.add(f));
|
|
599
|
+
}), S.getShadowMetadata(t, [...n, "getSelected"])?.pathComponents?.forEach((u) => {
|
|
600
|
+
y?.components?.get(u)?.forceUpdate();
|
|
602
601
|
});
|
|
603
|
-
const
|
|
604
|
-
for (let
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
602
|
+
const E = S.getShadowMetadata(t, n);
|
|
603
|
+
for (let u of E?.arrayKeys || []) {
|
|
604
|
+
const f = u + ".selected", A = S.getShadowMetadata(
|
|
605
|
+
t,
|
|
606
|
+
f.split(".").slice(1)
|
|
608
607
|
);
|
|
609
|
-
|
|
610
|
-
|
|
608
|
+
u == g && A?.pathComponents?.forEach((w) => {
|
|
609
|
+
y?.components?.get(w)?.forceUpdate();
|
|
611
610
|
});
|
|
612
611
|
}
|
|
613
612
|
};
|
|
614
|
-
function
|
|
615
|
-
const
|
|
616
|
-
let
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
for (const [
|
|
620
|
-
(
|
|
621
|
-
|
|
613
|
+
function Dt(t, n, g, S) {
|
|
614
|
+
const y = /* @__PURE__ */ new Map();
|
|
615
|
+
let I = 0;
|
|
616
|
+
const E = (w) => {
|
|
617
|
+
const i = w.join(".");
|
|
618
|
+
for (const [h] of y)
|
|
619
|
+
(h === i || h.startsWith(i + ".")) && y.delete(h);
|
|
620
|
+
I++;
|
|
622
621
|
};
|
|
623
|
-
function
|
|
624
|
-
currentState:
|
|
625
|
-
path:
|
|
626
|
-
meta:
|
|
627
|
-
componentId:
|
|
622
|
+
function u({
|
|
623
|
+
currentState: w,
|
|
624
|
+
path: i = [],
|
|
625
|
+
meta: h,
|
|
626
|
+
componentId: M
|
|
628
627
|
}) {
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
return
|
|
633
|
-
},
|
|
634
|
-
apply(
|
|
628
|
+
const z = i.map(String).join("."), c = [t, ...i].join(".");
|
|
629
|
+
w = e.getState().getShadowValue(c, h?.validIds);
|
|
630
|
+
const B = function() {
|
|
631
|
+
return e().getShadowValue(t, i);
|
|
632
|
+
}, J = {
|
|
633
|
+
apply(W, m, Y) {
|
|
635
634
|
},
|
|
636
|
-
get(
|
|
637
|
-
if (
|
|
638
|
-
return
|
|
639
|
-
if (Object.getOwnPropertyNames(
|
|
640
|
-
return
|
|
641
|
-
if (
|
|
635
|
+
get(W, m) {
|
|
636
|
+
if (m === "_rebuildStateShape")
|
|
637
|
+
return u;
|
|
638
|
+
if (Object.getOwnPropertyNames(f).includes(m) && i.length === 0)
|
|
639
|
+
return f[m];
|
|
640
|
+
if (m === "getDifferences")
|
|
642
641
|
return () => {
|
|
643
|
-
const s =
|
|
642
|
+
const s = e.getState().getShadowMetadata(t, []), o = e.getState().getShadowValue(t);
|
|
644
643
|
let r;
|
|
645
|
-
return s?.stateSource === "server" && s.baseServerState ? r = s.baseServerState : r =
|
|
644
|
+
return s?.stateSource === "server" && s.baseServerState ? r = s.baseServerState : r = e.getState().initialStateGlobal[t], Ct(o, r);
|
|
646
645
|
};
|
|
647
|
-
if (
|
|
646
|
+
if (m === "sync" && i.length === 0)
|
|
648
647
|
return async function() {
|
|
649
|
-
const s =
|
|
650
|
-
if (!
|
|
651
|
-
return console.error(`No mutation defined for state key "${
|
|
652
|
-
const r =
|
|
648
|
+
const s = e.getState().getInitialOptions(t), o = s?.sync;
|
|
649
|
+
if (!o)
|
|
650
|
+
return console.error(`No mutation defined for state key "${t}"`), { success: !1, error: "No mutation defined" };
|
|
651
|
+
const r = e.getState().getShadowValue(t, []), a = s?.validation?.key;
|
|
653
652
|
try {
|
|
654
|
-
const d = await
|
|
655
|
-
if (d && !d.success && d.errors && a && (
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
}),
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
...
|
|
653
|
+
const d = await o.action(r);
|
|
654
|
+
if (d && !d.success && d.errors && a && (e.getState().removeValidationError(a), d.errors.forEach((l) => {
|
|
655
|
+
const p = [a, ...l.path].join(".");
|
|
656
|
+
e.getState().addValidationError(p, l.message);
|
|
657
|
+
}), it(t)), d?.success) {
|
|
658
|
+
const l = e.getState().getShadowMetadata(t, []);
|
|
659
|
+
e.getState().setShadowMetadata(t, [], {
|
|
660
|
+
...l,
|
|
662
661
|
isDirty: !1,
|
|
663
662
|
lastServerSync: Date.now(),
|
|
664
663
|
stateSource: "server",
|
|
665
664
|
baseServerState: r
|
|
666
665
|
// Update base server state
|
|
667
|
-
}),
|
|
668
|
-
} else !d?.success &&
|
|
666
|
+
}), o.onSuccess && o.onSuccess(d.data);
|
|
667
|
+
} else !d?.success && o.onError && o.onError(d.error);
|
|
669
668
|
return d;
|
|
670
669
|
} catch (d) {
|
|
671
|
-
return
|
|
670
|
+
return o.onError && o.onError(d), { success: !1, error: d };
|
|
672
671
|
}
|
|
673
672
|
};
|
|
674
|
-
if (
|
|
673
|
+
if (m === "_status" || m === "getStatus") {
|
|
675
674
|
const s = () => {
|
|
676
|
-
const
|
|
677
|
-
return
|
|
675
|
+
const o = e.getState().getShadowMetadata(t, i), r = e.getState().getShadowValue(c);
|
|
676
|
+
return o?.isDirty === !0 ? "dirty" : o?.isDirty === !1 || o?.stateSource === "server" ? "synced" : o?.stateSource === "localStorage" ? "restored" : o?.stateSource === "default" ? "fresh" : e.getState().getShadowMetadata(t, [])?.stateSource === "server" && !o?.isDirty ? "synced" : r !== void 0 && !o ? "fresh" : "unknown";
|
|
678
677
|
};
|
|
679
|
-
return
|
|
678
|
+
return m === "_status" ? s() : s;
|
|
680
679
|
}
|
|
681
|
-
if (
|
|
680
|
+
if (m === "removeStorage")
|
|
682
681
|
return () => {
|
|
683
|
-
const s =
|
|
682
|
+
const s = e.getState().initialStateGlobal[t], o = nt(t), r = at(o?.localStorage?.key) ? o.localStorage.key(s) : o?.localStorage?.key, a = `${S}-${t}-${r}`;
|
|
684
683
|
a && localStorage.removeItem(a);
|
|
685
684
|
};
|
|
686
|
-
if (
|
|
685
|
+
if (m === "showValidationErrors")
|
|
687
686
|
return () => {
|
|
688
|
-
const s =
|
|
689
|
-
|
|
690
|
-
return t.getState().getValidationErrors(s.key + "." + o.join("."));
|
|
687
|
+
const s = e.getState().getShadowMetadata(t, i);
|
|
688
|
+
return s?.validation?.status === "VALIDATION_FAILED" && s.validation.message ? [s.validation.message] : [];
|
|
691
689
|
};
|
|
692
|
-
if (Array.isArray(
|
|
693
|
-
if (
|
|
690
|
+
if (Array.isArray(w)) {
|
|
691
|
+
if (m === "getSelected")
|
|
694
692
|
return () => {
|
|
695
|
-
const s =
|
|
696
|
-
|
|
697
|
-
...
|
|
693
|
+
const s = t + "." + i.join(".");
|
|
694
|
+
Vt(t, M, [
|
|
695
|
+
...i,
|
|
698
696
|
"getSelected"
|
|
699
697
|
]);
|
|
700
|
-
const
|
|
701
|
-
if (!
|
|
698
|
+
const o = e.getState().selectedIndicesMap;
|
|
699
|
+
if (!o || !o.has(s))
|
|
702
700
|
return;
|
|
703
|
-
const r =
|
|
704
|
-
if (
|
|
701
|
+
const r = o.get(s);
|
|
702
|
+
if (h?.validIds && !h.validIds.includes(r))
|
|
705
703
|
return;
|
|
706
|
-
const a =
|
|
704
|
+
const a = e.getState().getShadowValue(r);
|
|
707
705
|
if (a)
|
|
708
|
-
return
|
|
706
|
+
return u({
|
|
709
707
|
currentState: a,
|
|
710
708
|
path: r.split(".").slice(1),
|
|
711
|
-
componentId:
|
|
709
|
+
componentId: M
|
|
712
710
|
});
|
|
713
711
|
};
|
|
714
|
-
if (
|
|
715
|
-
return () =>
|
|
716
|
-
|
|
717
|
-
|
|
712
|
+
if (m === "getSelectedIndex")
|
|
713
|
+
return () => e.getState().getSelectedIndex(
|
|
714
|
+
t + "." + i.join("."),
|
|
715
|
+
h?.validIds
|
|
718
716
|
);
|
|
719
|
-
if (
|
|
720
|
-
return
|
|
721
|
-
|
|
722
|
-
arrayKey:
|
|
717
|
+
if (m === "clearSelected")
|
|
718
|
+
return ft(t, i), () => {
|
|
719
|
+
e.getState().clearSelectedIndex({
|
|
720
|
+
arrayKey: t + "." + i.join(".")
|
|
723
721
|
});
|
|
724
722
|
};
|
|
725
|
-
if (
|
|
723
|
+
if (m === "useVirtualView")
|
|
726
724
|
return (s) => {
|
|
727
725
|
const {
|
|
728
|
-
itemHeight:
|
|
726
|
+
itemHeight: o = 50,
|
|
729
727
|
overscan: r = 6,
|
|
730
728
|
stickToBottom: a = !1,
|
|
731
729
|
scrollStickTolerance: d = 75
|
|
732
|
-
} = s,
|
|
730
|
+
} = s, l = q(null), [p, V] = K({
|
|
733
731
|
startIndex: 0,
|
|
734
732
|
endIndex: 10
|
|
735
|
-
}), [
|
|
733
|
+
}), [_, U] = K({}), C = q(!0), F = q({
|
|
736
734
|
isUserScrolling: !1,
|
|
737
735
|
lastScrollTop: 0,
|
|
738
736
|
scrollUpCount: 0,
|
|
739
737
|
isNearBottom: !0
|
|
740
|
-
}),
|
|
738
|
+
}), x = q(
|
|
741
739
|
/* @__PURE__ */ new Map()
|
|
742
740
|
);
|
|
743
|
-
|
|
744
|
-
if (!a || !
|
|
741
|
+
dt(() => {
|
|
742
|
+
if (!a || !l.current || F.current.isUserScrolling)
|
|
745
743
|
return;
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
top:
|
|
749
|
-
behavior:
|
|
744
|
+
const v = l.current;
|
|
745
|
+
v.scrollTo({
|
|
746
|
+
top: v.scrollHeight,
|
|
747
|
+
behavior: C.current ? "instant" : "smooth"
|
|
750
748
|
});
|
|
751
|
-
}, [
|
|
752
|
-
const
|
|
753
|
-
let
|
|
754
|
-
const
|
|
755
|
-
return (
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
height:
|
|
759
|
-
offset:
|
|
760
|
-
}),
|
|
761
|
-
}),
|
|
762
|
-
}, [
|
|
763
|
-
|
|
764
|
-
if (a &&
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
),
|
|
749
|
+
}, [_, a]);
|
|
750
|
+
const N = e.getState().getShadowMetadata(t, i)?.arrayKeys || [], { totalHeight: j, itemOffsets: b } = St(() => {
|
|
751
|
+
let v = 0;
|
|
752
|
+
const T = /* @__PURE__ */ new Map();
|
|
753
|
+
return (e.getState().getShadowMetadata(t, i)?.arrayKeys || []).forEach((D) => {
|
|
754
|
+
const R = D.split(".").slice(1), L = e.getState().getShadowMetadata(t, R)?.virtualizer?.itemHeight || o;
|
|
755
|
+
T.set(D, {
|
|
756
|
+
height: L,
|
|
757
|
+
offset: v
|
|
758
|
+
}), v += L;
|
|
759
|
+
}), x.current = T, { totalHeight: v, itemOffsets: T };
|
|
760
|
+
}, [N.length, o]);
|
|
761
|
+
dt(() => {
|
|
762
|
+
if (a && N.length > 0 && l.current && !F.current.isUserScrolling && C.current) {
|
|
763
|
+
const v = l.current, T = () => {
|
|
764
|
+
if (v.clientHeight > 0) {
|
|
765
|
+
const $ = Math.ceil(
|
|
766
|
+
v.clientHeight / o
|
|
767
|
+
), D = N.length - 1, R = Math.max(
|
|
770
768
|
0,
|
|
771
|
-
|
|
769
|
+
D - $ - r
|
|
772
770
|
);
|
|
773
|
-
|
|
774
|
-
|
|
771
|
+
V({ startIndex: R, endIndex: D }), requestAnimationFrame(() => {
|
|
772
|
+
P("instant"), C.current = !1;
|
|
775
773
|
});
|
|
776
774
|
} else
|
|
777
|
-
requestAnimationFrame(
|
|
775
|
+
requestAnimationFrame(T);
|
|
778
776
|
};
|
|
779
|
-
|
|
777
|
+
T();
|
|
780
778
|
}
|
|
781
|
-
}, [
|
|
782
|
-
const
|
|
783
|
-
const
|
|
784
|
-
if (!
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
let
|
|
788
|
-
for (let
|
|
789
|
-
const
|
|
790
|
-
if (
|
|
791
|
-
|
|
779
|
+
}, [N.length, a, o, r]);
|
|
780
|
+
const k = ct(() => {
|
|
781
|
+
const v = l.current;
|
|
782
|
+
if (!v) return;
|
|
783
|
+
const T = v.scrollTop, { scrollHeight: $, clientHeight: D } = v, R = F.current, L = $ - (T + D), G = R.isNearBottom;
|
|
784
|
+
R.isNearBottom = L <= d, T < R.lastScrollTop ? (R.scrollUpCount++, R.scrollUpCount > 3 && G && (R.isUserScrolling = !0, console.log("User scrolled away from bottom"))) : R.isNearBottom && (R.isUserScrolling = !1, R.scrollUpCount = 0), R.lastScrollTop = T;
|
|
785
|
+
let tt = 0;
|
|
786
|
+
for (let et = 0; et < N.length; et++) {
|
|
787
|
+
const ht = N[et], mt = x.current.get(ht);
|
|
788
|
+
if (mt && mt.offset + mt.height > T) {
|
|
789
|
+
tt = et;
|
|
792
790
|
break;
|
|
793
791
|
}
|
|
794
792
|
}
|
|
795
|
-
if (
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
startIndex: Math.max(0,
|
|
793
|
+
if (tt !== p.startIndex) {
|
|
794
|
+
const et = Math.ceil(D / o);
|
|
795
|
+
V({
|
|
796
|
+
startIndex: Math.max(0, tt - r),
|
|
799
797
|
endIndex: Math.min(
|
|
800
|
-
|
|
801
|
-
|
|
798
|
+
N.length - 1,
|
|
799
|
+
tt + et + r
|
|
802
800
|
)
|
|
803
801
|
});
|
|
804
802
|
}
|
|
805
803
|
}, [
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
804
|
+
N.length,
|
|
805
|
+
p.startIndex,
|
|
806
|
+
o,
|
|
809
807
|
r,
|
|
810
808
|
d
|
|
811
809
|
]);
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
if (!(!
|
|
815
|
-
return
|
|
810
|
+
Z(() => {
|
|
811
|
+
const v = l.current;
|
|
812
|
+
if (!(!v || !a))
|
|
813
|
+
return v.addEventListener("scroll", k, {
|
|
816
814
|
passive: !0
|
|
817
815
|
}), () => {
|
|
818
|
-
|
|
816
|
+
v.removeEventListener("scroll", k);
|
|
819
817
|
};
|
|
820
|
-
}, [
|
|
821
|
-
const
|
|
822
|
-
(
|
|
823
|
-
const
|
|
824
|
-
if (!
|
|
818
|
+
}, [k, a]);
|
|
819
|
+
const P = ct(
|
|
820
|
+
(v = "smooth") => {
|
|
821
|
+
const T = l.current;
|
|
822
|
+
if (!T) return;
|
|
825
823
|
F.current.isUserScrolling = !1, F.current.isNearBottom = !0, F.current.scrollUpCount = 0;
|
|
826
|
-
const
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
top:
|
|
832
|
-
behavior:
|
|
824
|
+
const $ = () => {
|
|
825
|
+
const D = (R = 0) => {
|
|
826
|
+
if (R > 5) return;
|
|
827
|
+
const L = T.scrollHeight, G = T.scrollTop, tt = T.clientHeight;
|
|
828
|
+
G + tt >= L - 1 || (T.scrollTo({
|
|
829
|
+
top: L,
|
|
830
|
+
behavior: v
|
|
833
831
|
}), setTimeout(() => {
|
|
834
|
-
const
|
|
835
|
-
(
|
|
832
|
+
const et = T.scrollHeight, ht = T.scrollTop;
|
|
833
|
+
(et !== L || ht + tt < et - 1) && D(R + 1);
|
|
836
834
|
}, 50));
|
|
837
835
|
};
|
|
838
|
-
|
|
836
|
+
D();
|
|
839
837
|
};
|
|
840
|
-
"requestIdleCallback" in window ? requestIdleCallback(
|
|
841
|
-
requestAnimationFrame(
|
|
838
|
+
"requestIdleCallback" in window ? requestIdleCallback($, { timeout: 100 }) : requestAnimationFrame(() => {
|
|
839
|
+
requestAnimationFrame($);
|
|
842
840
|
});
|
|
843
841
|
},
|
|
844
842
|
[]
|
|
845
843
|
);
|
|
846
|
-
return
|
|
847
|
-
if (!a || !
|
|
848
|
-
const
|
|
849
|
-
let
|
|
850
|
-
const
|
|
851
|
-
clearTimeout(
|
|
852
|
-
!
|
|
853
|
-
|
|
844
|
+
return Z(() => {
|
|
845
|
+
if (!a || !l.current) return;
|
|
846
|
+
const v = l.current, T = F.current;
|
|
847
|
+
let $;
|
|
848
|
+
const D = () => {
|
|
849
|
+
clearTimeout($), $ = setTimeout(() => {
|
|
850
|
+
!T.isUserScrolling && T.isNearBottom && P(
|
|
851
|
+
C.current ? "instant" : "smooth"
|
|
854
852
|
);
|
|
855
853
|
}, 100);
|
|
856
|
-
},
|
|
857
|
-
|
|
854
|
+
}, R = new MutationObserver(() => {
|
|
855
|
+
T.isUserScrolling || D();
|
|
858
856
|
});
|
|
859
|
-
|
|
857
|
+
R.observe(v, {
|
|
860
858
|
childList: !0,
|
|
861
859
|
subtree: !0,
|
|
862
860
|
attributes: !0,
|
|
863
861
|
attributeFilter: ["style", "class"]
|
|
864
862
|
// More specific than just 'height'
|
|
865
863
|
});
|
|
866
|
-
const
|
|
867
|
-
|
|
864
|
+
const L = (G) => {
|
|
865
|
+
G.target instanceof HTMLImageElement && !T.isUserScrolling && D();
|
|
868
866
|
};
|
|
869
|
-
return
|
|
870
|
-
|
|
871
|
-
}, 0) :
|
|
872
|
-
clearTimeout(
|
|
867
|
+
return v.addEventListener("load", L, !0), C.current ? setTimeout(() => {
|
|
868
|
+
P("instant");
|
|
869
|
+
}, 0) : D(), () => {
|
|
870
|
+
clearTimeout($), R.disconnect(), v.removeEventListener("load", L, !0);
|
|
873
871
|
};
|
|
874
|
-
}, [a,
|
|
875
|
-
virtualState:
|
|
876
|
-
const
|
|
877
|
-
[
|
|
878
|
-
),
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
),
|
|
882
|
-
|
|
883
|
-
|
|
872
|
+
}, [a, N.length, P]), {
|
|
873
|
+
virtualState: St(() => {
|
|
874
|
+
const v = e.getState(), T = v.getShadowValue(
|
|
875
|
+
[t, ...i].join(".")
|
|
876
|
+
), $ = v.getShadowMetadata(t, i)?.arrayKeys || [], D = T.slice(
|
|
877
|
+
p.startIndex,
|
|
878
|
+
p.endIndex + 1
|
|
879
|
+
), R = $.slice(
|
|
880
|
+
p.startIndex,
|
|
881
|
+
p.endIndex + 1
|
|
884
882
|
);
|
|
885
|
-
return
|
|
886
|
-
currentState:
|
|
887
|
-
path:
|
|
888
|
-
componentId:
|
|
889
|
-
meta: { ...
|
|
883
|
+
return u({
|
|
884
|
+
currentState: D,
|
|
885
|
+
path: i,
|
|
886
|
+
componentId: M,
|
|
887
|
+
meta: { ...h, validIds: R }
|
|
890
888
|
});
|
|
891
|
-
}, [
|
|
889
|
+
}, [p.startIndex, p.endIndex, N.length]),
|
|
892
890
|
virtualizerProps: {
|
|
893
891
|
outer: {
|
|
894
|
-
ref:
|
|
892
|
+
ref: l,
|
|
895
893
|
style: {
|
|
896
894
|
overflowY: "auto",
|
|
897
895
|
height: "100%",
|
|
@@ -900,100 +898,100 @@ function De(e, i, f, g) {
|
|
|
900
898
|
},
|
|
901
899
|
inner: {
|
|
902
900
|
style: {
|
|
903
|
-
height: `${
|
|
901
|
+
height: `${j}px`,
|
|
904
902
|
position: "relative"
|
|
905
903
|
}
|
|
906
904
|
},
|
|
907
905
|
list: {
|
|
908
906
|
style: {
|
|
909
|
-
transform: `translateY(${
|
|
910
|
-
|
|
907
|
+
transform: `translateY(${x.current.get(
|
|
908
|
+
N[p.startIndex]
|
|
911
909
|
)?.offset || 0}px)`
|
|
912
910
|
}
|
|
913
911
|
}
|
|
914
912
|
},
|
|
915
|
-
scrollToBottom:
|
|
916
|
-
scrollToIndex: (
|
|
917
|
-
if (
|
|
918
|
-
const
|
|
919
|
-
|
|
913
|
+
scrollToBottom: P,
|
|
914
|
+
scrollToIndex: (v, T = "smooth") => {
|
|
915
|
+
if (l.current && N[v]) {
|
|
916
|
+
const $ = x.current.get(N[v])?.offset || 0;
|
|
917
|
+
l.current.scrollTo({ top: $, behavior: T });
|
|
920
918
|
}
|
|
921
919
|
}
|
|
922
920
|
};
|
|
923
921
|
};
|
|
924
|
-
if (
|
|
922
|
+
if (m === "stateMap")
|
|
925
923
|
return (s) => {
|
|
926
|
-
const [
|
|
927
|
-
|
|
928
|
-
), a =
|
|
929
|
-
if (!
|
|
924
|
+
const [o, r] = K(
|
|
925
|
+
h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys
|
|
926
|
+
), a = e.getState().getShadowValue(c, h?.validIds);
|
|
927
|
+
if (!o)
|
|
930
928
|
throw new Error("No array keys found for mapping");
|
|
931
|
-
const d =
|
|
929
|
+
const d = u({
|
|
932
930
|
currentState: a,
|
|
933
|
-
path:
|
|
934
|
-
componentId:
|
|
935
|
-
meta:
|
|
931
|
+
path: i,
|
|
932
|
+
componentId: M,
|
|
933
|
+
meta: h
|
|
936
934
|
});
|
|
937
|
-
return a.map((
|
|
938
|
-
const
|
|
939
|
-
currentState:
|
|
940
|
-
path:
|
|
941
|
-
componentId:
|
|
942
|
-
meta:
|
|
935
|
+
return a.map((l, p) => {
|
|
936
|
+
const V = o[p]?.split(".").slice(1), _ = u({
|
|
937
|
+
currentState: l,
|
|
938
|
+
path: V,
|
|
939
|
+
componentId: M,
|
|
940
|
+
meta: h
|
|
943
941
|
});
|
|
944
942
|
return s(
|
|
945
|
-
|
|
946
|
-
|
|
943
|
+
_,
|
|
944
|
+
p,
|
|
947
945
|
d
|
|
948
946
|
);
|
|
949
947
|
});
|
|
950
948
|
};
|
|
951
|
-
if (
|
|
952
|
-
return (s) =>
|
|
949
|
+
if (m === "$stateMap")
|
|
950
|
+
return (s) => lt(qt, {
|
|
953
951
|
proxy: {
|
|
954
|
-
_stateKey:
|
|
955
|
-
_path:
|
|
952
|
+
_stateKey: t,
|
|
953
|
+
_path: i,
|
|
956
954
|
_mapFn: s,
|
|
957
|
-
_meta:
|
|
955
|
+
_meta: h
|
|
958
956
|
},
|
|
959
|
-
rebuildStateShape:
|
|
957
|
+
rebuildStateShape: u
|
|
960
958
|
});
|
|
961
|
-
if (
|
|
959
|
+
if (m === "stateFind")
|
|
962
960
|
return (s) => {
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
for (let r = 0; r <
|
|
966
|
-
const a =
|
|
961
|
+
const o = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
962
|
+
if (o)
|
|
963
|
+
for (let r = 0; r < o.length; r++) {
|
|
964
|
+
const a = o[r];
|
|
967
965
|
if (!a) continue;
|
|
968
|
-
const d =
|
|
966
|
+
const d = e.getState().getShadowValue(a);
|
|
969
967
|
if (s(d, r)) {
|
|
970
|
-
const
|
|
971
|
-
return
|
|
968
|
+
const l = a.split(".").slice(1);
|
|
969
|
+
return u({
|
|
972
970
|
currentState: d,
|
|
973
|
-
path:
|
|
974
|
-
componentId:
|
|
975
|
-
meta:
|
|
971
|
+
path: l,
|
|
972
|
+
componentId: M,
|
|
973
|
+
meta: h
|
|
976
974
|
// Pass along meta for potential further chaining
|
|
977
975
|
});
|
|
978
976
|
}
|
|
979
977
|
}
|
|
980
978
|
};
|
|
981
|
-
if (
|
|
979
|
+
if (m === "stateFilter")
|
|
982
980
|
return (s) => {
|
|
983
|
-
const
|
|
984
|
-
if (!
|
|
981
|
+
const o = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
982
|
+
if (!o)
|
|
985
983
|
throw new Error("No array keys found for filtering.");
|
|
986
|
-
const r = [], a =
|
|
987
|
-
(d,
|
|
984
|
+
const r = [], a = w.filter(
|
|
985
|
+
(d, l) => s(d, l) ? (r.push(o[l]), !0) : !1
|
|
988
986
|
);
|
|
989
|
-
return
|
|
987
|
+
return u({
|
|
990
988
|
currentState: a,
|
|
991
|
-
path:
|
|
992
|
-
componentId:
|
|
989
|
+
path: i,
|
|
990
|
+
componentId: M,
|
|
993
991
|
meta: {
|
|
994
992
|
validIds: r,
|
|
995
993
|
transforms: [
|
|
996
|
-
...
|
|
994
|
+
...h?.transforms || [],
|
|
997
995
|
{
|
|
998
996
|
type: "filter",
|
|
999
997
|
fn: s
|
|
@@ -1002,422 +1000,458 @@ function De(e, i, f, g) {
|
|
|
1002
1000
|
}
|
|
1003
1001
|
});
|
|
1004
1002
|
};
|
|
1005
|
-
if (
|
|
1003
|
+
if (m === "stateSort")
|
|
1006
1004
|
return (s) => {
|
|
1007
|
-
const
|
|
1008
|
-
if (!
|
|
1005
|
+
const o = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
1006
|
+
if (!o)
|
|
1009
1007
|
throw new Error("No array keys found for sorting");
|
|
1010
|
-
const r =
|
|
1008
|
+
const r = w.map((a, d) => ({
|
|
1011
1009
|
item: a,
|
|
1012
|
-
key:
|
|
1010
|
+
key: o[d]
|
|
1013
1011
|
}));
|
|
1014
|
-
return r.sort((a, d) => s(a.item, d.item)).filter(Boolean),
|
|
1012
|
+
return r.sort((a, d) => s(a.item, d.item)).filter(Boolean), u({
|
|
1015
1013
|
currentState: r.map((a) => a.item),
|
|
1016
|
-
path:
|
|
1017
|
-
componentId:
|
|
1014
|
+
path: i,
|
|
1015
|
+
componentId: M,
|
|
1018
1016
|
meta: {
|
|
1019
1017
|
validIds: r.map((a) => a.key),
|
|
1020
1018
|
transforms: [
|
|
1021
|
-
...
|
|
1019
|
+
...h?.transforms || [],
|
|
1022
1020
|
{ type: "sort", fn: s }
|
|
1023
1021
|
]
|
|
1024
1022
|
}
|
|
1025
1023
|
});
|
|
1026
1024
|
};
|
|
1027
|
-
if (
|
|
1025
|
+
if (m === "stream")
|
|
1028
1026
|
return function(s = {}) {
|
|
1029
1027
|
const {
|
|
1030
|
-
bufferSize:
|
|
1028
|
+
bufferSize: o = 100,
|
|
1031
1029
|
flushInterval: r = 100,
|
|
1032
1030
|
bufferStrategy: a = "accumulate",
|
|
1033
1031
|
store: d,
|
|
1034
|
-
onFlush:
|
|
1032
|
+
onFlush: l
|
|
1035
1033
|
} = s;
|
|
1036
|
-
let
|
|
1037
|
-
const
|
|
1038
|
-
if (!
|
|
1039
|
-
if (a === "sliding" &&
|
|
1040
|
-
|
|
1041
|
-
else if (a === "dropping" &&
|
|
1034
|
+
let p = [], V = !1, _ = null;
|
|
1035
|
+
const U = (j) => {
|
|
1036
|
+
if (!V) {
|
|
1037
|
+
if (a === "sliding" && p.length >= o)
|
|
1038
|
+
p.shift();
|
|
1039
|
+
else if (a === "dropping" && p.length >= o)
|
|
1042
1040
|
return;
|
|
1043
|
-
|
|
1041
|
+
p.push(j), p.length >= o && C();
|
|
1044
1042
|
}
|
|
1045
|
-
},
|
|
1046
|
-
if (
|
|
1047
|
-
const
|
|
1048
|
-
if (
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
|
|
1043
|
+
}, C = () => {
|
|
1044
|
+
if (p.length === 0) return;
|
|
1045
|
+
const j = [...p];
|
|
1046
|
+
if (p = [], d) {
|
|
1047
|
+
const b = d(j);
|
|
1048
|
+
b !== void 0 && (Array.isArray(b) ? b : [b]).forEach((P) => {
|
|
1049
|
+
n(P, i, {
|
|
1052
1050
|
updateType: "insert"
|
|
1053
1051
|
});
|
|
1054
1052
|
});
|
|
1055
1053
|
} else
|
|
1056
|
-
|
|
1057
|
-
|
|
1054
|
+
j.forEach((b) => {
|
|
1055
|
+
n(b, i, {
|
|
1058
1056
|
updateType: "insert"
|
|
1059
1057
|
});
|
|
1060
1058
|
});
|
|
1061
|
-
|
|
1059
|
+
l?.(j);
|
|
1062
1060
|
};
|
|
1063
|
-
r > 0 && (
|
|
1064
|
-
const F =
|
|
1065
|
-
return
|
|
1066
|
-
...
|
|
1067
|
-
streams:
|
|
1061
|
+
r > 0 && (_ = setInterval(C, r));
|
|
1062
|
+
const F = rt(), x = e.getState().getShadowMetadata(t, i) || {}, N = x.streams || /* @__PURE__ */ new Map();
|
|
1063
|
+
return N.set(F, { buffer: p, flushTimer: _ }), e.getState().setShadowMetadata(t, i, {
|
|
1064
|
+
...x,
|
|
1065
|
+
streams: N
|
|
1068
1066
|
}), {
|
|
1069
|
-
write: (
|
|
1070
|
-
writeMany: (
|
|
1071
|
-
flush: () =>
|
|
1067
|
+
write: (j) => U(j),
|
|
1068
|
+
writeMany: (j) => j.forEach(U),
|
|
1069
|
+
flush: () => C(),
|
|
1072
1070
|
pause: () => {
|
|
1073
|
-
|
|
1071
|
+
V = !0;
|
|
1074
1072
|
},
|
|
1075
1073
|
resume: () => {
|
|
1076
|
-
|
|
1074
|
+
V = !1, p.length > 0 && C();
|
|
1077
1075
|
},
|
|
1078
1076
|
close: () => {
|
|
1079
|
-
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1077
|
+
C(), _ && clearInterval(_);
|
|
1078
|
+
const j = e.getState().getShadowMetadata(t, i);
|
|
1079
|
+
j?.streams && j.streams.delete(F);
|
|
1082
1080
|
}
|
|
1083
1081
|
};
|
|
1084
1082
|
};
|
|
1085
|
-
if (
|
|
1086
|
-
return (s) => /* @__PURE__ */
|
|
1087
|
-
const r =
|
|
1088
|
-
const
|
|
1089
|
-
let
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
),
|
|
1095
|
-
validIds:
|
|
1083
|
+
if (m === "stateList")
|
|
1084
|
+
return (s) => /* @__PURE__ */ ot(() => {
|
|
1085
|
+
const r = q(/* @__PURE__ */ new Map()), a = h?.transforms && h.transforms.length > 0 ? `${M}-${Bt(h.transforms)}` : `${M}-base`, [d, l] = K({}), { validIds: p, arrayValues: V } = St(() => {
|
|
1086
|
+
const U = e.getState().getShadowMetadata(t, i)?.transformCaches?.get(a);
|
|
1087
|
+
let C;
|
|
1088
|
+
U && U.validIds ? C = U.validIds : (C = It(
|
|
1089
|
+
t,
|
|
1090
|
+
i,
|
|
1091
|
+
h?.transforms
|
|
1092
|
+
), e.getState().setTransformCache(t, i, a, {
|
|
1093
|
+
validIds: C,
|
|
1096
1094
|
computedAt: Date.now(),
|
|
1097
|
-
transforms:
|
|
1095
|
+
transforms: h?.transforms || []
|
|
1098
1096
|
}));
|
|
1099
|
-
const F =
|
|
1097
|
+
const F = e.getState().getShadowValue(c, C);
|
|
1100
1098
|
return {
|
|
1101
|
-
validIds:
|
|
1099
|
+
validIds: C,
|
|
1102
1100
|
arrayValues: F || []
|
|
1103
1101
|
};
|
|
1104
1102
|
}, [a, d]);
|
|
1105
|
-
if (
|
|
1106
|
-
const
|
|
1107
|
-
if (
|
|
1103
|
+
if (Z(() => {
|
|
1104
|
+
const U = e.getState().subscribeToPath(c, (C) => {
|
|
1105
|
+
if (C.type === "GET_SELECTED")
|
|
1108
1106
|
return;
|
|
1109
|
-
const
|
|
1110
|
-
if (
|
|
1111
|
-
for (const
|
|
1112
|
-
|
|
1113
|
-
(
|
|
1107
|
+
const x = e.getState().getShadowMetadata(t, i)?.transformCaches;
|
|
1108
|
+
if (x)
|
|
1109
|
+
for (const N of x.keys())
|
|
1110
|
+
N.startsWith(M) && x.delete(N);
|
|
1111
|
+
(C.type === "INSERT" || C.type === "REMOVE" || C.type === "CLEAR_SELECTION") && l({});
|
|
1114
1112
|
});
|
|
1115
1113
|
return () => {
|
|
1116
|
-
|
|
1114
|
+
U();
|
|
1117
1115
|
};
|
|
1118
|
-
}, [
|
|
1116
|
+
}, [M, c]), !Array.isArray(V))
|
|
1119
1117
|
return null;
|
|
1120
|
-
const
|
|
1121
|
-
currentState:
|
|
1122
|
-
path:
|
|
1123
|
-
componentId:
|
|
1118
|
+
const _ = u({
|
|
1119
|
+
currentState: V,
|
|
1120
|
+
path: i,
|
|
1121
|
+
componentId: M,
|
|
1124
1122
|
meta: {
|
|
1125
|
-
...
|
|
1126
|
-
validIds:
|
|
1123
|
+
...h,
|
|
1124
|
+
validIds: p
|
|
1127
1125
|
}
|
|
1128
1126
|
});
|
|
1129
|
-
return
|
|
1130
|
-
const F =
|
|
1127
|
+
return /* @__PURE__ */ ot(Ut, { children: V.map((U, C) => {
|
|
1128
|
+
const F = p[C];
|
|
1131
1129
|
if (!F)
|
|
1132
1130
|
return null;
|
|
1133
|
-
let
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1131
|
+
let x = r.current.get(F);
|
|
1132
|
+
x || (x = rt(), r.current.set(F, x));
|
|
1133
|
+
const N = F.split(".").slice(1);
|
|
1134
|
+
return lt(Mt, {
|
|
1137
1135
|
key: F,
|
|
1138
|
-
stateKey:
|
|
1139
|
-
itemComponentId:
|
|
1140
|
-
itemPath:
|
|
1141
|
-
localIndex:
|
|
1142
|
-
arraySetter:
|
|
1143
|
-
rebuildStateShape:
|
|
1136
|
+
stateKey: t,
|
|
1137
|
+
itemComponentId: x,
|
|
1138
|
+
itemPath: N,
|
|
1139
|
+
localIndex: C,
|
|
1140
|
+
arraySetter: _,
|
|
1141
|
+
rebuildStateShape: u,
|
|
1144
1142
|
renderFn: s
|
|
1145
1143
|
});
|
|
1146
1144
|
}) });
|
|
1147
1145
|
}, {});
|
|
1148
|
-
if (
|
|
1146
|
+
if (m === "stateFlattenOn")
|
|
1149
1147
|
return (s) => {
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
const r =
|
|
1148
|
+
const o = w;
|
|
1149
|
+
y.clear(), I++;
|
|
1150
|
+
const r = o.flatMap(
|
|
1153
1151
|
(a) => a[s] ?? []
|
|
1154
1152
|
);
|
|
1155
|
-
return
|
|
1153
|
+
return u({
|
|
1156
1154
|
currentState: r,
|
|
1157
|
-
path: [...
|
|
1158
|
-
componentId:
|
|
1159
|
-
meta:
|
|
1155
|
+
path: [...i, "[*]", s],
|
|
1156
|
+
componentId: M,
|
|
1157
|
+
meta: h
|
|
1160
1158
|
});
|
|
1161
1159
|
};
|
|
1162
|
-
if (
|
|
1160
|
+
if (m === "index")
|
|
1163
1161
|
return (s) => {
|
|
1164
|
-
const r =
|
|
1165
|
-
(
|
|
1162
|
+
const r = e.getState().getShadowMetadata(t, i)?.arrayKeys?.filter(
|
|
1163
|
+
(l) => !h?.validIds || h?.validIds && h?.validIds?.includes(l)
|
|
1166
1164
|
)?.[s];
|
|
1167
1165
|
if (!r) return;
|
|
1168
|
-
const a =
|
|
1169
|
-
return
|
|
1166
|
+
const a = e.getState().getShadowValue(r, h?.validIds);
|
|
1167
|
+
return u({
|
|
1170
1168
|
currentState: a,
|
|
1171
1169
|
path: r.split(".").slice(1),
|
|
1172
|
-
componentId:
|
|
1173
|
-
meta:
|
|
1170
|
+
componentId: M,
|
|
1171
|
+
meta: h
|
|
1174
1172
|
});
|
|
1175
1173
|
};
|
|
1176
|
-
if (
|
|
1174
|
+
if (m === "last")
|
|
1177
1175
|
return () => {
|
|
1178
|
-
const s =
|
|
1176
|
+
const s = e.getState().getShadowValue(t, i);
|
|
1179
1177
|
if (s.length === 0) return;
|
|
1180
|
-
const
|
|
1181
|
-
return
|
|
1178
|
+
const o = s.length - 1, r = s[o], a = [...i, o.toString()];
|
|
1179
|
+
return u({
|
|
1182
1180
|
currentState: r,
|
|
1183
1181
|
path: a,
|
|
1184
|
-
componentId:
|
|
1185
|
-
meta:
|
|
1182
|
+
componentId: M,
|
|
1183
|
+
meta: h
|
|
1186
1184
|
});
|
|
1187
1185
|
};
|
|
1188
|
-
if (
|
|
1189
|
-
return (s,
|
|
1190
|
-
currentState:
|
|
1191
|
-
path:
|
|
1192
|
-
componentId:
|
|
1193
|
-
meta:
|
|
1186
|
+
if (m === "insert")
|
|
1187
|
+
return (s, o) => (n(s, i, { updateType: "insert" }), u({
|
|
1188
|
+
currentState: e.getState().getShadowValue(t, i),
|
|
1189
|
+
path: i,
|
|
1190
|
+
componentId: M,
|
|
1191
|
+
meta: h
|
|
1194
1192
|
}));
|
|
1195
|
-
if (
|
|
1196
|
-
return (s,
|
|
1197
|
-
const a =
|
|
1198
|
-
let
|
|
1199
|
-
if (!a.some((
|
|
1200
|
-
const
|
|
1201
|
-
(
|
|
1202
|
-
) :
|
|
1203
|
-
return
|
|
1193
|
+
if (m === "uniqueInsert")
|
|
1194
|
+
return (s, o, r) => {
|
|
1195
|
+
const a = e.getState().getShadowValue(t, i), d = at(s) ? s(a) : s;
|
|
1196
|
+
let l = null;
|
|
1197
|
+
if (!a.some((V) => {
|
|
1198
|
+
const _ = o ? o.every(
|
|
1199
|
+
(U) => st(V[U], d[U])
|
|
1200
|
+
) : st(V, d);
|
|
1201
|
+
return _ && (l = V), _;
|
|
1204
1202
|
}))
|
|
1205
|
-
|
|
1206
|
-
else if (r &&
|
|
1207
|
-
const
|
|
1208
|
-
(
|
|
1203
|
+
E(i), n(d, i, { updateType: "insert" });
|
|
1204
|
+
else if (r && l) {
|
|
1205
|
+
const V = r(l), _ = a.map(
|
|
1206
|
+
(U) => st(U, l) ? V : U
|
|
1209
1207
|
);
|
|
1210
|
-
|
|
1208
|
+
E(i), n(_, i, {
|
|
1211
1209
|
updateType: "update"
|
|
1212
1210
|
});
|
|
1213
1211
|
}
|
|
1214
1212
|
};
|
|
1215
|
-
if (
|
|
1216
|
-
return (s,
|
|
1217
|
-
const r =
|
|
1213
|
+
if (m === "cut")
|
|
1214
|
+
return (s, o) => {
|
|
1215
|
+
const r = h?.validIds ?? e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
1218
1216
|
if (!r || r.length === 0) return;
|
|
1219
1217
|
const a = s == -1 ? r.length - 1 : s !== void 0 ? s : r.length - 1, d = r[a];
|
|
1220
1218
|
if (!d) return;
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1219
|
+
const l = d.split(".").slice(1);
|
|
1220
|
+
n(w, l, {
|
|
1223
1221
|
updateType: "cut"
|
|
1224
1222
|
});
|
|
1225
1223
|
};
|
|
1226
|
-
if (
|
|
1224
|
+
if (m === "cutSelected")
|
|
1227
1225
|
return () => {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
S?.transforms
|
|
1226
|
+
const s = It(
|
|
1227
|
+
t,
|
|
1228
|
+
i,
|
|
1229
|
+
h?.transforms
|
|
1233
1230
|
);
|
|
1234
|
-
if (
|
|
1235
|
-
const
|
|
1231
|
+
if (!s || s.length === 0) return;
|
|
1232
|
+
const o = e.getState().selectedIndicesMap.get(c);
|
|
1236
1233
|
let r = s.findIndex(
|
|
1237
|
-
(
|
|
1234
|
+
(l) => l === o
|
|
1238
1235
|
);
|
|
1239
|
-
console.log("indexToCut", r);
|
|
1240
1236
|
const a = s[r == -1 ? s.length - 1 : r]?.split(".").slice(1);
|
|
1241
|
-
|
|
1237
|
+
e.getState().clearSelectedIndex({ arrayKey: c });
|
|
1238
|
+
const d = a?.slice(0, -1);
|
|
1239
|
+
ft(t, d), n(w, a, {
|
|
1242
1240
|
updateType: "cut"
|
|
1243
1241
|
});
|
|
1244
1242
|
};
|
|
1245
|
-
if (
|
|
1243
|
+
if (m === "cutByValue")
|
|
1246
1244
|
return (s) => {
|
|
1247
|
-
const
|
|
1245
|
+
const o = e.getState().getShadowMetadata(t, i), r = h?.validIds ?? o?.arrayKeys;
|
|
1248
1246
|
if (!r) return;
|
|
1249
1247
|
let a = null;
|
|
1250
1248
|
for (const d of r)
|
|
1251
|
-
if (
|
|
1249
|
+
if (e.getState().getShadowValue(d) === s) {
|
|
1252
1250
|
a = d;
|
|
1253
1251
|
break;
|
|
1254
1252
|
}
|
|
1255
1253
|
if (a) {
|
|
1256
1254
|
const d = a.split(".").slice(1);
|
|
1257
|
-
|
|
1255
|
+
n(null, d, { updateType: "cut" });
|
|
1258
1256
|
}
|
|
1259
1257
|
};
|
|
1260
|
-
if (
|
|
1258
|
+
if (m === "toggleByValue")
|
|
1261
1259
|
return (s) => {
|
|
1262
|
-
const
|
|
1260
|
+
const o = e.getState().getShadowMetadata(t, i), r = h?.validIds ?? o?.arrayKeys;
|
|
1263
1261
|
if (!r) return;
|
|
1264
1262
|
let a = null;
|
|
1265
1263
|
for (const d of r) {
|
|
1266
|
-
const
|
|
1267
|
-
if (console.log("itemValue sdasdasdasd",
|
|
1264
|
+
const l = e.getState().getShadowValue(d);
|
|
1265
|
+
if (console.log("itemValue sdasdasdasd", l), l === s) {
|
|
1268
1266
|
a = d;
|
|
1269
1267
|
break;
|
|
1270
1268
|
}
|
|
1271
1269
|
}
|
|
1272
1270
|
if (console.log("itemValue keyToCut", a), a) {
|
|
1273
1271
|
const d = a.split(".").slice(1);
|
|
1274
|
-
console.log("itemValue keyToCut", a),
|
|
1272
|
+
console.log("itemValue keyToCut", a), n(s, d, {
|
|
1275
1273
|
updateType: "cut"
|
|
1276
1274
|
});
|
|
1277
1275
|
} else
|
|
1278
|
-
|
|
1276
|
+
n(s, i, { updateType: "insert" });
|
|
1279
1277
|
};
|
|
1280
|
-
if (
|
|
1281
|
-
return (s,
|
|
1282
|
-
const r =
|
|
1278
|
+
if (m === "findWith")
|
|
1279
|
+
return (s, o) => {
|
|
1280
|
+
const r = e.getState().getShadowMetadata(t, i)?.arrayKeys;
|
|
1283
1281
|
if (!r)
|
|
1284
1282
|
throw new Error("No array keys found for sorting");
|
|
1285
1283
|
let a = null, d = [];
|
|
1286
|
-
for (const
|
|
1287
|
-
let
|
|
1288
|
-
if (
|
|
1289
|
-
a =
|
|
1284
|
+
for (const l of r) {
|
|
1285
|
+
let p = e.getState().getShadowValue(l, h?.validIds);
|
|
1286
|
+
if (p && p[s] === o) {
|
|
1287
|
+
a = p, d = l.split(".").slice(1);
|
|
1290
1288
|
break;
|
|
1291
1289
|
}
|
|
1292
1290
|
}
|
|
1293
|
-
return
|
|
1291
|
+
return u({
|
|
1294
1292
|
currentState: a,
|
|
1295
1293
|
path: d,
|
|
1296
|
-
componentId:
|
|
1297
|
-
meta:
|
|
1294
|
+
componentId: M,
|
|
1295
|
+
meta: h
|
|
1298
1296
|
});
|
|
1299
1297
|
};
|
|
1300
1298
|
}
|
|
1301
|
-
if (
|
|
1302
|
-
let s =
|
|
1299
|
+
if (m === "cut") {
|
|
1300
|
+
let s = e.getState().getShadowValue(i.join("."));
|
|
1303
1301
|
return () => {
|
|
1304
|
-
|
|
1302
|
+
n(s, i, { updateType: "cut" });
|
|
1305
1303
|
};
|
|
1306
1304
|
}
|
|
1307
|
-
if (
|
|
1308
|
-
return () => (
|
|
1309
|
-
if (
|
|
1310
|
-
return (
|
|
1311
|
-
|
|
1312
|
-
|
|
1305
|
+
if (m === "get")
|
|
1306
|
+
return () => (Vt(t, M, i), e.getState().getShadowValue(c, h?.validIds));
|
|
1307
|
+
if (m === "getState")
|
|
1308
|
+
return () => e.getState().getShadowValue(c, h?.validIds);
|
|
1309
|
+
if (m === "$derive")
|
|
1310
|
+
return (s) => bt({
|
|
1311
|
+
_stateKey: t,
|
|
1312
|
+
_path: i,
|
|
1313
1313
|
_effect: s.toString(),
|
|
1314
|
-
_meta:
|
|
1314
|
+
_meta: h
|
|
1315
1315
|
});
|
|
1316
|
-
if (
|
|
1317
|
-
return () =>
|
|
1318
|
-
if (
|
|
1319
|
-
const s = `${
|
|
1320
|
-
return
|
|
1316
|
+
if (m === "$get")
|
|
1317
|
+
return () => bt({ _stateKey: t, _path: i, _meta: h });
|
|
1318
|
+
if (m === "lastSynced") {
|
|
1319
|
+
const s = `${t}:${i.join(".")}`;
|
|
1320
|
+
return e.getState().getSyncInfo(s);
|
|
1321
1321
|
}
|
|
1322
|
-
if (
|
|
1323
|
-
return (s) =>
|
|
1324
|
-
if (
|
|
1325
|
-
const s = [
|
|
1326
|
-
if (
|
|
1327
|
-
|
|
1322
|
+
if (m == "getLocalStorage")
|
|
1323
|
+
return (s) => gt(S + "-" + t + "-" + s);
|
|
1324
|
+
if (m === "isSelected") {
|
|
1325
|
+
const s = [t, ...i].slice(0, -1);
|
|
1326
|
+
if (ft(t, i, void 0), Array.isArray(
|
|
1327
|
+
e.getState().getShadowValue(s.join("."), h?.validIds)
|
|
1328
1328
|
)) {
|
|
1329
|
-
|
|
1330
|
-
const
|
|
1329
|
+
i[i.length - 1];
|
|
1330
|
+
const o = s.join("."), r = e.getState().selectedIndicesMap.get(o), a = t + "." + i.join(".");
|
|
1331
1331
|
return r === a;
|
|
1332
1332
|
}
|
|
1333
1333
|
return;
|
|
1334
1334
|
}
|
|
1335
|
-
if (
|
|
1335
|
+
if (m === "setSelected")
|
|
1336
1336
|
return (s) => {
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1337
|
+
const o = i.slice(0, -1), r = t + "." + o.join("."), a = t + "." + i.join(".");
|
|
1338
|
+
ft(t, o, void 0), e.getState().selectedIndicesMap.get(r), s && e.getState().setSelectedIndex(r, a);
|
|
1339
1339
|
};
|
|
1340
|
-
if (
|
|
1340
|
+
if (m === "toggleSelected")
|
|
1341
1341
|
return () => {
|
|
1342
|
-
const s =
|
|
1343
|
-
|
|
1342
|
+
const s = i.slice(0, -1), o = t + "." + s.join("."), r = t + "." + i.join(".");
|
|
1343
|
+
e.getState().selectedIndicesMap.get(o) === r ? e.getState().clearSelectedIndex({ arrayKey: o }) : e.getState().setSelectedIndex(o, r);
|
|
1344
1344
|
};
|
|
1345
|
-
if (
|
|
1346
|
-
return
|
|
1347
|
-
if (
|
|
1348
|
-
if (
|
|
1345
|
+
if (m === "_componentId")
|
|
1346
|
+
return M;
|
|
1347
|
+
if (i.length == 0) {
|
|
1348
|
+
if (m === "addValidation")
|
|
1349
1349
|
return (s) => {
|
|
1350
|
-
const
|
|
1351
|
-
if (!
|
|
1352
|
-
|
|
1353
|
-
const a = [
|
|
1354
|
-
|
|
1355
|
-
}),
|
|
1350
|
+
const o = e.getState().getInitialOptions(t)?.validation;
|
|
1351
|
+
if (!o?.key) throw new Error("Validation key not found");
|
|
1352
|
+
ut(o.key), s.forEach((r) => {
|
|
1353
|
+
const a = [o.key, ...r.path].join(".");
|
|
1354
|
+
pt(a, r.message);
|
|
1355
|
+
}), it(t);
|
|
1356
1356
|
};
|
|
1357
|
-
if (
|
|
1357
|
+
if (m === "applyJsonPatch")
|
|
1358
1358
|
return (s) => {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1359
|
+
const o = e.getState(), r = o.getShadowMetadata(t, []);
|
|
1360
|
+
if (!r?.components) return;
|
|
1361
|
+
const a = (l) => !l || l === "/" ? [] : l.split("/").slice(1).map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~")), d = /* @__PURE__ */ new Set();
|
|
1362
|
+
for (const l of s) {
|
|
1363
|
+
const p = a(l.path);
|
|
1364
|
+
switch (l.op) {
|
|
1363
1365
|
case "add":
|
|
1364
1366
|
case "replace": {
|
|
1365
|
-
const { value:
|
|
1366
|
-
|
|
1367
|
+
const { value: V } = l;
|
|
1368
|
+
o.updateShadowAtPath(t, p, V), o.markAsDirty(t, p, { bubble: !0 });
|
|
1369
|
+
let _ = [...p];
|
|
1370
|
+
for (; ; ) {
|
|
1371
|
+
const U = o.getShadowMetadata(
|
|
1372
|
+
t,
|
|
1373
|
+
_
|
|
1374
|
+
);
|
|
1375
|
+
if (console.log("pathMeta", U), U?.pathComponents && U.pathComponents.forEach((C) => {
|
|
1376
|
+
if (!d.has(C)) {
|
|
1377
|
+
const F = r.components?.get(C);
|
|
1378
|
+
F && (F.forceUpdate(), d.add(C));
|
|
1379
|
+
}
|
|
1380
|
+
}), _.length === 0) break;
|
|
1381
|
+
_.pop();
|
|
1382
|
+
}
|
|
1367
1383
|
break;
|
|
1368
1384
|
}
|
|
1369
1385
|
case "remove": {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1386
|
+
const V = p.slice(0, -1);
|
|
1387
|
+
o.removeShadowArrayElement(t, p), o.markAsDirty(t, V, { bubble: !0 });
|
|
1388
|
+
let _ = [...V];
|
|
1389
|
+
for (; ; ) {
|
|
1390
|
+
const U = o.getShadowMetadata(
|
|
1391
|
+
t,
|
|
1392
|
+
_
|
|
1393
|
+
);
|
|
1394
|
+
if (U?.pathComponents && U.pathComponents.forEach((C) => {
|
|
1395
|
+
if (!d.has(C)) {
|
|
1396
|
+
const F = r.components?.get(C);
|
|
1397
|
+
F && (F.forceUpdate(), d.add(C));
|
|
1398
|
+
}
|
|
1399
|
+
}), _.length === 0) break;
|
|
1400
|
+
_.pop();
|
|
1401
|
+
}
|
|
1373
1402
|
break;
|
|
1374
1403
|
}
|
|
1375
1404
|
}
|
|
1376
1405
|
}
|
|
1377
1406
|
};
|
|
1378
|
-
if (
|
|
1407
|
+
if (m === "validateZodSchema")
|
|
1379
1408
|
return () => {
|
|
1380
|
-
const s =
|
|
1381
|
-
if (!
|
|
1382
|
-
throw new Error(
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1409
|
+
const s = e.getState().getInitialOptions(t)?.validation, o = s?.zodSchemaV4 || s?.zodSchemaV3;
|
|
1410
|
+
if (!o || !s?.key)
|
|
1411
|
+
throw new Error(
|
|
1412
|
+
"Zod schema (v3 or v4) or validation key not found"
|
|
1413
|
+
);
|
|
1414
|
+
ut(s.key);
|
|
1415
|
+
const r = e.getState().getShadowValue(t), a = o.safeParse(r);
|
|
1416
|
+
return a.success ? !0 : ("issues" in a.error ? a.error.issues.forEach((d) => {
|
|
1417
|
+
const l = [s.key, ...d.path].join(".");
|
|
1418
|
+
pt(l, d.message);
|
|
1419
|
+
}) : a.error.errors.forEach((d) => {
|
|
1420
|
+
const l = [s.key, ...d.path].join(".");
|
|
1421
|
+
pt(l, d.message);
|
|
1422
|
+
}), it(t), !1);
|
|
1389
1423
|
};
|
|
1390
|
-
if (
|
|
1391
|
-
return () =>
|
|
1392
|
-
if (
|
|
1393
|
-
return () =>
|
|
1424
|
+
if (m === "getComponents")
|
|
1425
|
+
return () => e.getState().getShadowMetadata(t, [])?.components;
|
|
1426
|
+
if (m === "getAllFormRefs")
|
|
1427
|
+
return () => vt.getState().getFormRefsByStateKey(t);
|
|
1394
1428
|
}
|
|
1395
|
-
if (
|
|
1396
|
-
return () =>
|
|
1397
|
-
if (
|
|
1429
|
+
if (m === "getFormRef")
|
|
1430
|
+
return () => vt.getState().getFormRef(t + "." + i.join("."));
|
|
1431
|
+
if (m === "validationWrapper")
|
|
1398
1432
|
return ({
|
|
1399
1433
|
children: s,
|
|
1400
|
-
hideMessage:
|
|
1401
|
-
}) => /* @__PURE__ */
|
|
1402
|
-
|
|
1434
|
+
hideMessage: o
|
|
1435
|
+
}) => /* @__PURE__ */ ot(
|
|
1436
|
+
kt,
|
|
1403
1437
|
{
|
|
1404
|
-
formOpts:
|
|
1405
|
-
path:
|
|
1406
|
-
stateKey:
|
|
1438
|
+
formOpts: o ? { validation: { message: "" } } : void 0,
|
|
1439
|
+
path: i,
|
|
1440
|
+
stateKey: t,
|
|
1407
1441
|
children: s
|
|
1408
1442
|
}
|
|
1409
1443
|
);
|
|
1410
|
-
if (
|
|
1411
|
-
if (
|
|
1412
|
-
if (
|
|
1413
|
-
return (s) => (
|
|
1444
|
+
if (m === "_stateKey") return t;
|
|
1445
|
+
if (m === "_path") return i;
|
|
1446
|
+
if (m === "update")
|
|
1447
|
+
return (s) => (n(s, i, { updateType: "update" }), {
|
|
1414
1448
|
/**
|
|
1415
1449
|
* Marks this specific item, which was just updated, as 'synced' (not dirty).
|
|
1416
1450
|
*/
|
|
1417
1451
|
synced: () => {
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
...
|
|
1452
|
+
const o = e.getState().getShadowMetadata(t, i);
|
|
1453
|
+
e.getState().setShadowMetadata(t, i, {
|
|
1454
|
+
...o,
|
|
1421
1455
|
isDirty: !1,
|
|
1422
1456
|
// EXPLICITLY set to false, not just undefined
|
|
1423
1457
|
stateSource: "server",
|
|
@@ -1425,385 +1459,462 @@ function De(e, i, f, g) {
|
|
|
1425
1459
|
lastServerSync: Date.now()
|
|
1426
1460
|
// Add timestamp
|
|
1427
1461
|
});
|
|
1428
|
-
const r = [
|
|
1429
|
-
|
|
1462
|
+
const r = [t, ...i].join(".");
|
|
1463
|
+
e.getState().notifyPathSubscribers(r, {
|
|
1430
1464
|
type: "SYNC_STATUS_CHANGE",
|
|
1431
1465
|
isDirty: !1
|
|
1432
1466
|
});
|
|
1433
1467
|
}
|
|
1434
1468
|
});
|
|
1435
|
-
if (
|
|
1436
|
-
const s =
|
|
1437
|
-
if (console.log("currentValueAtPath", s), typeof
|
|
1469
|
+
if (m === "toggle") {
|
|
1470
|
+
const s = e.getState().getShadowValue([t, ...i].join("."));
|
|
1471
|
+
if (console.log("currentValueAtPath", s), typeof w != "boolean")
|
|
1438
1472
|
throw new Error("toggle() can only be used on boolean values");
|
|
1439
1473
|
return () => {
|
|
1440
|
-
|
|
1474
|
+
n(!s, i, {
|
|
1441
1475
|
updateType: "update"
|
|
1442
1476
|
});
|
|
1443
1477
|
};
|
|
1444
1478
|
}
|
|
1445
|
-
if (
|
|
1446
|
-
return (s,
|
|
1447
|
-
|
|
1479
|
+
if (m === "formElement")
|
|
1480
|
+
return (s, o) => /* @__PURE__ */ ot(
|
|
1481
|
+
Zt,
|
|
1448
1482
|
{
|
|
1449
|
-
|
|
1450
|
-
path:
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
stateKey: e,
|
|
1456
|
-
path: o,
|
|
1457
|
-
rebuildStateShape: l,
|
|
1458
|
-
setState: i,
|
|
1459
|
-
formOpts: n,
|
|
1460
|
-
renderFn: s
|
|
1461
|
-
}
|
|
1462
|
-
)
|
|
1483
|
+
stateKey: t,
|
|
1484
|
+
path: i,
|
|
1485
|
+
rebuildStateShape: u,
|
|
1486
|
+
setState: n,
|
|
1487
|
+
formOpts: o,
|
|
1488
|
+
renderFn: s
|
|
1463
1489
|
}
|
|
1464
1490
|
);
|
|
1465
|
-
const
|
|
1466
|
-
return
|
|
1467
|
-
currentState:
|
|
1468
|
-
path:
|
|
1469
|
-
componentId:
|
|
1470
|
-
meta:
|
|
1491
|
+
const Q = [...i, m], X = e.getState().getShadowValue(t, Q);
|
|
1492
|
+
return u({
|
|
1493
|
+
currentState: X,
|
|
1494
|
+
path: Q,
|
|
1495
|
+
componentId: M,
|
|
1496
|
+
meta: h
|
|
1471
1497
|
});
|
|
1472
1498
|
}
|
|
1473
|
-
},
|
|
1474
|
-
return
|
|
1475
|
-
proxy:
|
|
1476
|
-
stateVersion:
|
|
1477
|
-
}),
|
|
1499
|
+
}, H = new Proxy(B, J);
|
|
1500
|
+
return y.set(z, {
|
|
1501
|
+
proxy: H,
|
|
1502
|
+
stateVersion: I
|
|
1503
|
+
}), H;
|
|
1478
1504
|
}
|
|
1479
|
-
const
|
|
1480
|
-
removeValidation: (
|
|
1481
|
-
|
|
1505
|
+
const f = {
|
|
1506
|
+
removeValidation: (w) => {
|
|
1507
|
+
w?.validationKey && ut(w.validationKey);
|
|
1482
1508
|
},
|
|
1483
|
-
revertToInitialState: (
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
currentState:
|
|
1509
|
+
revertToInitialState: (w) => {
|
|
1510
|
+
const i = e.getState().getInitialOptions(t)?.validation;
|
|
1511
|
+
i?.key && ut(i.key), w?.validationKey && ut(w.validationKey);
|
|
1512
|
+
const h = e.getState().getShadowMetadata(t, []);
|
|
1513
|
+
h?.stateSource === "server" && h.baseServerState ? h.baseServerState : e.getState().initialStateGlobal[t];
|
|
1514
|
+
const M = e.getState().initialStateGlobal[t];
|
|
1515
|
+
e.getState().clearSelectedIndexesForState(t), y.clear(), I++, e.getState().initializeShadowState(t, M), u({
|
|
1516
|
+
currentState: M,
|
|
1491
1517
|
path: [],
|
|
1492
|
-
componentId:
|
|
1518
|
+
componentId: g
|
|
1493
1519
|
});
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
const
|
|
1497
|
-
return
|
|
1498
|
-
|
|
1499
|
-
}),
|
|
1520
|
+
const z = nt(t), c = at(z?.localStorage?.key) ? z?.localStorage?.key(M) : z?.localStorage?.key, B = `${S}-${t}-${c}`;
|
|
1521
|
+
B && localStorage.removeItem(B);
|
|
1522
|
+
const J = e.getState().getShadowMetadata(t, []);
|
|
1523
|
+
return J && J?.components?.forEach((H) => {
|
|
1524
|
+
H.forceUpdate();
|
|
1525
|
+
}), M;
|
|
1500
1526
|
},
|
|
1501
|
-
updateInitialState: (
|
|
1502
|
-
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
),
|
|
1509
|
-
return localStorage.getItem(c) && localStorage.removeItem(c),
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1527
|
+
updateInitialState: (w) => {
|
|
1528
|
+
y.clear(), I++;
|
|
1529
|
+
const i = Dt(
|
|
1530
|
+
t,
|
|
1531
|
+
n,
|
|
1532
|
+
g,
|
|
1533
|
+
S
|
|
1534
|
+
), h = e.getState().initialStateGlobal[t], M = nt(t), z = at(M?.localStorage?.key) ? M?.localStorage?.key(h) : M?.localStorage?.key, c = `${S}-${t}-${z}`;
|
|
1535
|
+
return localStorage.getItem(c) && localStorage.removeItem(c), Rt(() => {
|
|
1536
|
+
_t(t, w), e.getState().initializeShadowState(t, w);
|
|
1537
|
+
const B = e.getState().getShadowMetadata(t, []);
|
|
1538
|
+
B && B?.components?.forEach((J) => {
|
|
1539
|
+
J.forceUpdate();
|
|
1514
1540
|
});
|
|
1515
1541
|
}), {
|
|
1516
|
-
fetchId: (
|
|
1542
|
+
fetchId: (B) => i.get()[B]
|
|
1517
1543
|
};
|
|
1518
1544
|
}
|
|
1519
1545
|
};
|
|
1520
|
-
return
|
|
1521
|
-
currentState:
|
|
1522
|
-
componentId:
|
|
1546
|
+
return u({
|
|
1547
|
+
currentState: e.getState().getShadowValue(t, []),
|
|
1548
|
+
componentId: g,
|
|
1523
1549
|
path: []
|
|
1524
1550
|
});
|
|
1525
1551
|
}
|
|
1526
|
-
function
|
|
1527
|
-
return
|
|
1552
|
+
function bt(t) {
|
|
1553
|
+
return lt(Gt, { proxy: t });
|
|
1528
1554
|
}
|
|
1529
|
-
function
|
|
1530
|
-
proxy:
|
|
1531
|
-
rebuildStateShape:
|
|
1555
|
+
function qt({
|
|
1556
|
+
proxy: t,
|
|
1557
|
+
rebuildStateShape: n
|
|
1532
1558
|
}) {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
const
|
|
1536
|
-
if (!
|
|
1537
|
-
const
|
|
1538
|
-
const A =
|
|
1539
|
-
|
|
1540
|
-
instanceId:
|
|
1541
|
-
mapFn:
|
|
1542
|
-
containerRef:
|
|
1543
|
-
rebuildStateShape:
|
|
1544
|
-
path:
|
|
1545
|
-
componentId:
|
|
1546
|
-
meta:
|
|
1547
|
-
}),
|
|
1559
|
+
const g = q(null), S = q(`map-${crypto.randomUUID()}`), y = q(!1), I = q(/* @__PURE__ */ new Map());
|
|
1560
|
+
Z(() => {
|
|
1561
|
+
const u = g.current;
|
|
1562
|
+
if (!u || y.current) return;
|
|
1563
|
+
const f = setTimeout(() => {
|
|
1564
|
+
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, w = A.mapWrappers || [];
|
|
1565
|
+
w.push({
|
|
1566
|
+
instanceId: S.current,
|
|
1567
|
+
mapFn: t._mapFn,
|
|
1568
|
+
containerRef: u,
|
|
1569
|
+
rebuildStateShape: n,
|
|
1570
|
+
path: t._path,
|
|
1571
|
+
componentId: S.current,
|
|
1572
|
+
meta: t._meta
|
|
1573
|
+
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1548
1574
|
...A,
|
|
1549
|
-
mapWrappers:
|
|
1550
|
-
}),
|
|
1575
|
+
mapWrappers: w
|
|
1576
|
+
}), y.current = !0, E();
|
|
1551
1577
|
}, 0);
|
|
1552
1578
|
return () => {
|
|
1553
|
-
if (clearTimeout(
|
|
1554
|
-
const A =
|
|
1579
|
+
if (clearTimeout(f), S.current) {
|
|
1580
|
+
const A = e.getState().getShadowMetadata(t._stateKey, t._path) || {};
|
|
1555
1581
|
A.mapWrappers && (A.mapWrappers = A.mapWrappers.filter(
|
|
1556
|
-
(
|
|
1557
|
-
),
|
|
1582
|
+
(w) => w.instanceId !== S.current
|
|
1583
|
+
), e.getState().setShadowMetadata(t._stateKey, t._path, A));
|
|
1558
1584
|
}
|
|
1559
|
-
|
|
1585
|
+
I.current.forEach((A) => A.unmount());
|
|
1560
1586
|
};
|
|
1561
1587
|
}, []);
|
|
1562
|
-
const
|
|
1563
|
-
const
|
|
1564
|
-
if (!
|
|
1565
|
-
const
|
|
1566
|
-
[
|
|
1567
|
-
|
|
1588
|
+
const E = () => {
|
|
1589
|
+
const u = g.current;
|
|
1590
|
+
if (!u) return;
|
|
1591
|
+
const f = e.getState().getShadowValue(
|
|
1592
|
+
[t._stateKey, ...t._path].join("."),
|
|
1593
|
+
t._meta?.validIds
|
|
1568
1594
|
);
|
|
1569
|
-
if (!Array.isArray(
|
|
1570
|
-
const A =
|
|
1571
|
-
currentState:
|
|
1572
|
-
path:
|
|
1573
|
-
componentId:
|
|
1574
|
-
meta:
|
|
1595
|
+
if (!Array.isArray(f)) return;
|
|
1596
|
+
const A = t._meta?.validIds ?? e.getState().getShadowMetadata(t._stateKey, t._path)?.arrayKeys ?? [], w = n({
|
|
1597
|
+
currentState: f,
|
|
1598
|
+
path: t._path,
|
|
1599
|
+
componentId: S.current,
|
|
1600
|
+
meta: t._meta
|
|
1575
1601
|
});
|
|
1576
|
-
|
|
1577
|
-
const
|
|
1578
|
-
if (!
|
|
1579
|
-
const
|
|
1580
|
-
c.setAttribute("data-item-path",
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
stateKey:
|
|
1587
|
-
itemComponentId:
|
|
1588
|
-
itemPath:
|
|
1589
|
-
localIndex:
|
|
1590
|
-
arraySetter:
|
|
1591
|
-
rebuildStateShape:
|
|
1592
|
-
renderFn:
|
|
1602
|
+
f.forEach((i, h) => {
|
|
1603
|
+
const M = A[h];
|
|
1604
|
+
if (!M) return;
|
|
1605
|
+
const z = rt(), c = document.createElement("div");
|
|
1606
|
+
c.setAttribute("data-item-path", M), u.appendChild(c);
|
|
1607
|
+
const B = At(c);
|
|
1608
|
+
I.current.set(M, B);
|
|
1609
|
+
const J = M.split(".").slice(1);
|
|
1610
|
+
B.render(
|
|
1611
|
+
lt(Mt, {
|
|
1612
|
+
stateKey: t._stateKey,
|
|
1613
|
+
itemComponentId: z,
|
|
1614
|
+
itemPath: J,
|
|
1615
|
+
localIndex: h,
|
|
1616
|
+
arraySetter: w,
|
|
1617
|
+
rebuildStateShape: n,
|
|
1618
|
+
renderFn: t._mapFn
|
|
1593
1619
|
})
|
|
1594
1620
|
);
|
|
1595
1621
|
});
|
|
1596
1622
|
};
|
|
1597
|
-
return /* @__PURE__ */
|
|
1623
|
+
return /* @__PURE__ */ ot("div", { ref: g, "data-map-container": S.current });
|
|
1598
1624
|
}
|
|
1599
|
-
function
|
|
1600
|
-
proxy:
|
|
1625
|
+
function Gt({
|
|
1626
|
+
proxy: t
|
|
1601
1627
|
}) {
|
|
1602
|
-
const
|
|
1603
|
-
[
|
|
1604
|
-
|
|
1628
|
+
const n = q(null), g = q(null), S = q(!1), y = `${t._stateKey}-${t._path.join(".")}`, I = e.getState().getShadowValue(
|
|
1629
|
+
[t._stateKey, ...t._path].join("."),
|
|
1630
|
+
t._meta?.validIds
|
|
1605
1631
|
);
|
|
1606
|
-
return
|
|
1607
|
-
const
|
|
1608
|
-
if (!
|
|
1609
|
-
const
|
|
1610
|
-
if (!
|
|
1611
|
-
console.warn("Parent element not found for signal",
|
|
1632
|
+
return Z(() => {
|
|
1633
|
+
const E = n.current;
|
|
1634
|
+
if (!E || S.current) return;
|
|
1635
|
+
const u = setTimeout(() => {
|
|
1636
|
+
if (!E.parentElement) {
|
|
1637
|
+
console.warn("Parent element not found for signal", y);
|
|
1612
1638
|
return;
|
|
1613
1639
|
}
|
|
1614
|
-
const
|
|
1615
|
-
let
|
|
1616
|
-
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
instanceId:
|
|
1620
|
-
parentId:
|
|
1621
|
-
position:
|
|
1622
|
-
effect:
|
|
1623
|
-
}),
|
|
1624
|
-
...
|
|
1625
|
-
signals:
|
|
1640
|
+
const f = E.parentElement, w = Array.from(f.childNodes).indexOf(E);
|
|
1641
|
+
let i = f.getAttribute("data-parent-id");
|
|
1642
|
+
i || (i = `parent-${crypto.randomUUID()}`, f.setAttribute("data-parent-id", i)), g.current = `instance-${crypto.randomUUID()}`;
|
|
1643
|
+
const h = e.getState().getShadowMetadata(t._stateKey, t._path) || {}, M = h.signals || [];
|
|
1644
|
+
M.push({
|
|
1645
|
+
instanceId: g.current,
|
|
1646
|
+
parentId: i,
|
|
1647
|
+
position: w,
|
|
1648
|
+
effect: t._effect
|
|
1649
|
+
}), e.getState().setShadowMetadata(t._stateKey, t._path, {
|
|
1650
|
+
...h,
|
|
1651
|
+
signals: M
|
|
1626
1652
|
});
|
|
1627
|
-
let
|
|
1628
|
-
if (
|
|
1653
|
+
let z = I;
|
|
1654
|
+
if (t._effect)
|
|
1629
1655
|
try {
|
|
1630
|
-
|
|
1656
|
+
z = new Function(
|
|
1631
1657
|
"state",
|
|
1632
|
-
`return (${
|
|
1633
|
-
)(
|
|
1634
|
-
} catch (
|
|
1635
|
-
console.error("Error evaluating effect function:",
|
|
1658
|
+
`return (${t._effect})(state)`
|
|
1659
|
+
)(I);
|
|
1660
|
+
} catch (B) {
|
|
1661
|
+
console.error("Error evaluating effect function:", B);
|
|
1636
1662
|
}
|
|
1637
|
-
|
|
1638
|
-
const c = document.createTextNode(String(
|
|
1639
|
-
|
|
1663
|
+
z !== null && typeof z == "object" && (z = JSON.stringify(z));
|
|
1664
|
+
const c = document.createTextNode(String(z ?? ""));
|
|
1665
|
+
E.replaceWith(c), S.current = !0;
|
|
1640
1666
|
}, 0);
|
|
1641
1667
|
return () => {
|
|
1642
|
-
if (clearTimeout(
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1645
|
-
(A) => A.instanceId !==
|
|
1646
|
-
),
|
|
1668
|
+
if (clearTimeout(u), g.current) {
|
|
1669
|
+
const f = e.getState().getShadowMetadata(t._stateKey, t._path) || {};
|
|
1670
|
+
f.signals && (f.signals = f.signals.filter(
|
|
1671
|
+
(A) => A.instanceId !== g.current
|
|
1672
|
+
), e.getState().setShadowMetadata(t._stateKey, t._path, f));
|
|
1647
1673
|
}
|
|
1648
1674
|
};
|
|
1649
|
-
}, []),
|
|
1650
|
-
ref:
|
|
1675
|
+
}, []), lt("span", {
|
|
1676
|
+
ref: n,
|
|
1651
1677
|
style: { display: "contents" },
|
|
1652
|
-
"data-signal-id":
|
|
1678
|
+
"data-signal-id": y
|
|
1653
1679
|
});
|
|
1654
1680
|
}
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
(
|
|
1658
|
-
),
|
|
1659
|
-
const [
|
|
1660
|
-
return
|
|
1661
|
-
if (!
|
|
1662
|
-
|
|
1681
|
+
const Mt = Ot(
|
|
1682
|
+
Yt,
|
|
1683
|
+
(t, n) => t.itemPath.join(".") === n.itemPath.join(".") && t.stateKey === n.stateKey && t.itemComponentId === n.itemComponentId && t.localIndex === n.localIndex
|
|
1684
|
+
), Jt = (t) => {
|
|
1685
|
+
const [n, g] = K(!1);
|
|
1686
|
+
return dt(() => {
|
|
1687
|
+
if (!t.current) {
|
|
1688
|
+
g(!0);
|
|
1663
1689
|
return;
|
|
1664
1690
|
}
|
|
1665
|
-
const
|
|
1666
|
-
if (
|
|
1667
|
-
|
|
1691
|
+
const S = Array.from(t.current.querySelectorAll("img"));
|
|
1692
|
+
if (S.length === 0) {
|
|
1693
|
+
g(!0);
|
|
1668
1694
|
return;
|
|
1669
1695
|
}
|
|
1670
|
-
let
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1696
|
+
let y = 0;
|
|
1697
|
+
const I = () => {
|
|
1698
|
+
y++, y === S.length && g(!0);
|
|
1673
1699
|
};
|
|
1674
|
-
return
|
|
1675
|
-
|
|
1700
|
+
return S.forEach((E) => {
|
|
1701
|
+
E.complete ? I() : (E.addEventListener("load", I), E.addEventListener("error", I));
|
|
1676
1702
|
}), () => {
|
|
1677
|
-
|
|
1678
|
-
|
|
1703
|
+
S.forEach((E) => {
|
|
1704
|
+
E.removeEventListener("load", I), E.removeEventListener("error", I);
|
|
1679
1705
|
});
|
|
1680
1706
|
};
|
|
1681
|
-
}, [
|
|
1707
|
+
}, [t.current]), n;
|
|
1682
1708
|
};
|
|
1683
|
-
function
|
|
1684
|
-
stateKey:
|
|
1685
|
-
itemComponentId:
|
|
1686
|
-
itemPath:
|
|
1687
|
-
localIndex:
|
|
1688
|
-
arraySetter:
|
|
1689
|
-
rebuildStateShape:
|
|
1690
|
-
renderFn:
|
|
1709
|
+
function Yt({
|
|
1710
|
+
stateKey: t,
|
|
1711
|
+
itemComponentId: n,
|
|
1712
|
+
itemPath: g,
|
|
1713
|
+
localIndex: S,
|
|
1714
|
+
arraySetter: y,
|
|
1715
|
+
rebuildStateShape: I,
|
|
1716
|
+
renderFn: E
|
|
1691
1717
|
}) {
|
|
1692
|
-
const [,
|
|
1693
|
-
|
|
1694
|
-
const
|
|
1695
|
-
(
|
|
1696
|
-
|
|
1718
|
+
const [, u] = K({}), { ref: f, inView: A } = jt(), w = q(null), i = Jt(w), h = q(!1), M = [t, ...g].join(".");
|
|
1719
|
+
$t(t, n, u);
|
|
1720
|
+
const z = ct(
|
|
1721
|
+
(W) => {
|
|
1722
|
+
w.current = W, f(W);
|
|
1697
1723
|
},
|
|
1698
|
-
[
|
|
1724
|
+
[f]
|
|
1699
1725
|
);
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1726
|
+
Z(() => {
|
|
1727
|
+
e.getState().subscribeToPath(M, (W) => {
|
|
1728
|
+
u({});
|
|
1703
1729
|
});
|
|
1704
|
-
}, []),
|
|
1705
|
-
if (!A || !
|
|
1730
|
+
}, []), Z(() => {
|
|
1731
|
+
if (!A || !i || h.current)
|
|
1706
1732
|
return;
|
|
1707
|
-
const
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1733
|
+
const W = w.current;
|
|
1734
|
+
if (W && W.offsetHeight > 0) {
|
|
1735
|
+
h.current = !0;
|
|
1736
|
+
const m = W.offsetHeight;
|
|
1737
|
+
e.getState().setShadowMetadata(t, g, {
|
|
1712
1738
|
virtualizer: {
|
|
1713
|
-
itemHeight:
|
|
1714
|
-
domRef:
|
|
1739
|
+
itemHeight: m,
|
|
1740
|
+
domRef: W
|
|
1715
1741
|
}
|
|
1716
1742
|
});
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1743
|
+
const Y = g.slice(0, -1), Q = [t, ...Y].join(".");
|
|
1744
|
+
e.getState().notifyPathSubscribers(Q, {
|
|
1719
1745
|
type: "ITEMHEIGHT",
|
|
1720
|
-
itemKey:
|
|
1721
|
-
ref:
|
|
1746
|
+
itemKey: g.join("."),
|
|
1747
|
+
ref: w.current
|
|
1722
1748
|
});
|
|
1723
1749
|
}
|
|
1724
|
-
}, [A,
|
|
1725
|
-
const c = [
|
|
1726
|
-
if (
|
|
1750
|
+
}, [A, i, t, g]);
|
|
1751
|
+
const c = [t, ...g].join("."), B = e.getState().getShadowValue(c);
|
|
1752
|
+
if (B === void 0)
|
|
1727
1753
|
return null;
|
|
1728
|
-
const
|
|
1729
|
-
currentState:
|
|
1730
|
-
path:
|
|
1731
|
-
componentId:
|
|
1732
|
-
}),
|
|
1733
|
-
return /* @__PURE__ */
|
|
1754
|
+
const J = I({
|
|
1755
|
+
currentState: B,
|
|
1756
|
+
path: g,
|
|
1757
|
+
componentId: n
|
|
1758
|
+
}), H = E(J, S, y);
|
|
1759
|
+
return /* @__PURE__ */ ot("div", { ref: z, children: H });
|
|
1734
1760
|
}
|
|
1735
|
-
function
|
|
1736
|
-
stateKey:
|
|
1737
|
-
path:
|
|
1738
|
-
rebuildStateShape:
|
|
1739
|
-
renderFn:
|
|
1740
|
-
formOpts:
|
|
1741
|
-
setState:
|
|
1761
|
+
function Zt({
|
|
1762
|
+
stateKey: t,
|
|
1763
|
+
path: n,
|
|
1764
|
+
rebuildStateShape: g,
|
|
1765
|
+
renderFn: S,
|
|
1766
|
+
formOpts: y,
|
|
1767
|
+
setState: I
|
|
1742
1768
|
}) {
|
|
1743
|
-
const [
|
|
1744
|
-
|
|
1745
|
-
const A =
|
|
1746
|
-
|
|
1747
|
-
!
|
|
1748
|
-
}, [A]),
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1769
|
+
const [E] = K(() => rt()), [, u] = K({}), f = [t, ...n].join(".");
|
|
1770
|
+
$t(t, E, u);
|
|
1771
|
+
const A = e.getState().getShadowValue(f), [w, i] = K(A), h = q(!1), M = q(null);
|
|
1772
|
+
Z(() => {
|
|
1773
|
+
!h.current && !st(A, w) && i(A);
|
|
1774
|
+
}, [A]), Z(() => {
|
|
1775
|
+
const H = e.getState().subscribeToPath(f, (W) => {
|
|
1776
|
+
!h.current && w !== W && u({});
|
|
1751
1777
|
});
|
|
1752
1778
|
return () => {
|
|
1753
|
-
|
|
1779
|
+
H(), M.current && (clearTimeout(M.current), h.current = !1);
|
|
1754
1780
|
};
|
|
1755
1781
|
}, []);
|
|
1756
|
-
const
|
|
1757
|
-
(
|
|
1758
|
-
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1782
|
+
const z = ct(
|
|
1783
|
+
(H) => {
|
|
1784
|
+
typeof A === "number" && typeof H == "string" && (H = H === "" ? 0 : Number(H)), i(H), h.current = !0, M.current && clearTimeout(M.current);
|
|
1785
|
+
const m = y?.debounceTime ?? 200;
|
|
1786
|
+
M.current = setTimeout(() => {
|
|
1787
|
+
h.current = !1, I(H, n, { updateType: "update" });
|
|
1788
|
+
const { getInitialOptions: Y, setShadowMetadata: Q, getShadowMetadata: X } = e.getState(), s = Y(t)?.validation, o = s?.zodSchemaV4 || s?.zodSchemaV3;
|
|
1789
|
+
if (o) {
|
|
1790
|
+
const r = e.getState().getShadowValue(t), a = o.safeParse(r), d = X(t, n) || {};
|
|
1791
|
+
if (a.success)
|
|
1792
|
+
Q(t, n, {
|
|
1793
|
+
...d,
|
|
1794
|
+
validation: {
|
|
1795
|
+
status: "VALID_LIVE",
|
|
1796
|
+
validatedValue: H
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
else {
|
|
1800
|
+
const p = ("issues" in a.error ? a.error.issues : a.error.errors).filter(
|
|
1801
|
+
(V) => JSON.stringify(V.path) === JSON.stringify(n)
|
|
1802
|
+
);
|
|
1803
|
+
p.length > 0 ? Q(t, n, {
|
|
1804
|
+
...d,
|
|
1805
|
+
validation: {
|
|
1806
|
+
status: "INVALID_LIVE",
|
|
1807
|
+
message: p[0]?.message,
|
|
1808
|
+
validatedValue: H
|
|
1809
|
+
}
|
|
1810
|
+
}) : Q(t, n, {
|
|
1811
|
+
...d,
|
|
1812
|
+
validation: {
|
|
1813
|
+
status: "VALID_LIVE",
|
|
1814
|
+
validatedValue: H
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}, m), u({});
|
|
1763
1820
|
},
|
|
1764
|
-
[
|
|
1765
|
-
), c =
|
|
1766
|
-
|
|
1767
|
-
|
|
1821
|
+
[I, n, y?.debounceTime, t]
|
|
1822
|
+
), c = ct(async () => {
|
|
1823
|
+
console.log("handleBlur triggered"), M.current && (clearTimeout(M.current), M.current = null, h.current = !1, I(w, n, { updateType: "update" }));
|
|
1824
|
+
const { getInitialOptions: H } = e.getState(), W = H(t)?.validation, m = W?.zodSchemaV4 || W?.zodSchemaV3;
|
|
1825
|
+
if (!m) return;
|
|
1826
|
+
const Y = e.getState().getShadowMetadata(t, n);
|
|
1827
|
+
e.getState().setShadowMetadata(t, n, {
|
|
1828
|
+
...Y,
|
|
1829
|
+
validation: {
|
|
1830
|
+
status: "DIRTY",
|
|
1831
|
+
validatedValue: w
|
|
1832
|
+
}
|
|
1833
|
+
});
|
|
1834
|
+
const Q = e.getState().getShadowValue(t), X = m.safeParse(Q);
|
|
1835
|
+
if (console.log("result ", X), X.success)
|
|
1836
|
+
e.getState().setShadowMetadata(t, n, {
|
|
1837
|
+
...Y,
|
|
1838
|
+
validation: {
|
|
1839
|
+
status: "VALID_PENDING_SYNC",
|
|
1840
|
+
validatedValue: w
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
else {
|
|
1844
|
+
const s = "issues" in X.error ? X.error.issues : X.error.errors;
|
|
1845
|
+
console.log("All validation errors:", s), console.log("Current blur path:", n);
|
|
1846
|
+
const o = s.filter((r) => {
|
|
1847
|
+
if (console.log("Processing error:", r), n.some((d) => d.startsWith("id:"))) {
|
|
1848
|
+
console.log("Detected array path with ULID");
|
|
1849
|
+
const d = n[0].startsWith("id:") ? [] : n.slice(0, -1);
|
|
1850
|
+
console.log("Parent path:", d);
|
|
1851
|
+
const l = e.getState().getShadowMetadata(t, d);
|
|
1852
|
+
if (console.log("Array metadata:", l), l?.arrayKeys) {
|
|
1853
|
+
const p = [t, ...n.slice(0, -1)].join("."), V = l.arrayKeys.indexOf(p);
|
|
1854
|
+
console.log("Item key:", p, "Index:", V);
|
|
1855
|
+
const _ = [...d, V, ...n.slice(-1)], U = JSON.stringify(r.path) === JSON.stringify(_);
|
|
1856
|
+
return console.log("Zod path comparison:", {
|
|
1857
|
+
zodPath: _,
|
|
1858
|
+
errorPath: r.path,
|
|
1859
|
+
match: U
|
|
1860
|
+
}), U;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
const a = JSON.stringify(r.path) === JSON.stringify(n);
|
|
1864
|
+
return console.log("Direct path comparison:", {
|
|
1865
|
+
errorPath: r.path,
|
|
1866
|
+
currentPath: n,
|
|
1867
|
+
match: a
|
|
1868
|
+
}), a;
|
|
1869
|
+
});
|
|
1870
|
+
console.log("Filtered path errors:", o), e.getState().setShadowMetadata(t, n, {
|
|
1871
|
+
...Y,
|
|
1872
|
+
validation: {
|
|
1873
|
+
status: "VALIDATION_FAILED",
|
|
1874
|
+
message: o[0]?.message,
|
|
1875
|
+
validatedValue: w
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
u({});
|
|
1880
|
+
}, [t, n, w, I]), B = g({
|
|
1768
1881
|
currentState: A,
|
|
1769
|
-
path:
|
|
1770
|
-
componentId:
|
|
1771
|
-
}),
|
|
1772
|
-
get(
|
|
1773
|
-
return
|
|
1774
|
-
value:
|
|
1775
|
-
onChange: (
|
|
1776
|
-
|
|
1882
|
+
path: n,
|
|
1883
|
+
componentId: E
|
|
1884
|
+
}), J = new Proxy(B, {
|
|
1885
|
+
get(H, W) {
|
|
1886
|
+
return W === "inputProps" ? {
|
|
1887
|
+
value: w ?? "",
|
|
1888
|
+
onChange: (m) => {
|
|
1889
|
+
z(m.target.value);
|
|
1777
1890
|
},
|
|
1891
|
+
// 5. Wire the new onBlur handler to the input props.
|
|
1778
1892
|
onBlur: c,
|
|
1779
|
-
ref:
|
|
1780
|
-
} :
|
|
1893
|
+
ref: vt.getState().getFormRef(t + "." + n.join("."))
|
|
1894
|
+
} : H[W];
|
|
1781
1895
|
}
|
|
1782
1896
|
});
|
|
1783
|
-
return /* @__PURE__ */
|
|
1897
|
+
return /* @__PURE__ */ ot(kt, { formOpts: y, path: n, stateKey: t, children: S(J) });
|
|
1784
1898
|
}
|
|
1785
|
-
function
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
return
|
|
1790
|
-
forceUpdate: () =>
|
|
1899
|
+
function $t(t, n, g) {
|
|
1900
|
+
const S = `${t}////${n}`;
|
|
1901
|
+
dt(() => {
|
|
1902
|
+
const { registerComponent: y, unregisterComponent: I } = e.getState();
|
|
1903
|
+
return y(t, S, {
|
|
1904
|
+
forceUpdate: () => g({}),
|
|
1791
1905
|
paths: /* @__PURE__ */ new Set(),
|
|
1792
1906
|
reactiveType: ["component"]
|
|
1793
|
-
}), t.getState().setShadowMetadata(e, [], {
|
|
1794
|
-
...h,
|
|
1795
|
-
components: p
|
|
1796
1907
|
}), () => {
|
|
1797
|
-
|
|
1798
|
-
M?.components && M.components.delete(g);
|
|
1908
|
+
I(t, S);
|
|
1799
1909
|
};
|
|
1800
|
-
}, [
|
|
1910
|
+
}, [t, S]);
|
|
1801
1911
|
}
|
|
1802
1912
|
export {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1913
|
+
bt as $cogsSignal,
|
|
1914
|
+
ie as addStateOptions,
|
|
1915
|
+
Lt as createCogsState,
|
|
1916
|
+
ce as createCogsStateFromSync,
|
|
1917
|
+
ue as notifyComponent,
|
|
1918
|
+
zt as useCogsStateFn
|
|
1808
1919
|
};
|
|
1809
1920
|
//# sourceMappingURL=CogsState.jsx.map
|