cogsbox-state 0.5.476 → 0.5.478
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/README.md +92 -0
- package/dist/CogsState.d.ts +78 -33
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.js +920 -841
- package/dist/CogsState.js.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +110 -108
- package/dist/Components.js.map +1 -1
- package/dist/PluginRunner.d.ts.map +1 -1
- package/dist/PluginRunner.js +0 -1
- package/dist/PluginRunner.js.map +1 -1
- package/dist/index.js +35 -34
- package/dist/plugins.d.ts +1404 -198
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +141 -59
- package/dist/plugins.js.map +1 -1
- package/dist/store.d.ts +3 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +470 -417
- package/dist/store.js.map +1 -1
- package/dist/utility.d.ts +1 -3
- package/dist/utility.d.ts.map +1 -1
- package/dist/utility.js +63 -73
- package/dist/utility.js.map +1 -1
- package/package.json +3 -3
- package/src/CogsState.tsx +286 -83
- package/src/Components.tsx +3 -1
- package/src/PluginRunner.tsx +2 -2
- package/src/plugins.ts +338 -28
- package/src/store.ts +131 -3
- package/src/utility.ts +1 -33
package/dist/store.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
function
|
|
3
|
-
if (!
|
|
4
|
-
let
|
|
1
|
+
import { create as N } from "zustand";
|
|
2
|
+
function v(f, o = "zod4") {
|
|
3
|
+
if (!f) return null;
|
|
4
|
+
let t = f, e = !1, n = !1, a, s = !1;
|
|
5
5
|
for (let l = 0; l < 20; l++) {
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
|
|
6
|
+
const d = t?.def || t?._def;
|
|
7
|
+
if (!d) break;
|
|
8
|
+
const y = d.typeName || d.type || t._type;
|
|
9
|
+
if (y === "ZodUnion" || y === "union")
|
|
10
|
+
if (d.options && d.options.length > 0) {
|
|
11
|
+
t = d.options[0];
|
|
12
12
|
continue;
|
|
13
13
|
} else
|
|
14
14
|
break;
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
else if (
|
|
18
|
-
|
|
19
|
-
else if (
|
|
20
|
-
s = !0,
|
|
21
|
-
else if (
|
|
15
|
+
if (y === "ZodOptional" || y === "optional")
|
|
16
|
+
n = !0;
|
|
17
|
+
else if (y === "ZodNullable" || y === "nullable")
|
|
18
|
+
e = !0;
|
|
19
|
+
else if (y === "ZodDefault" || y === "default")
|
|
20
|
+
s = !0, a = typeof d.defaultValue == "function" ? d.defaultValue() : d.defaultValue;
|
|
21
|
+
else if (y !== "ZodEffects" && y !== "effects")
|
|
22
22
|
break;
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
23
|
+
const h = d.innerType || d.schema || t._inner;
|
|
24
|
+
if (!h || h === t)
|
|
25
25
|
break;
|
|
26
|
-
|
|
26
|
+
t = h;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const i = t, r = i?.def || i?._def, u = r?.typeName || r?.type || i?._type;
|
|
29
|
+
return u === "ZodNumber" || u === "number" ? {
|
|
30
30
|
type: "number",
|
|
31
|
-
schema:
|
|
31
|
+
schema: f,
|
|
32
32
|
source: o,
|
|
33
|
-
default: s ?
|
|
34
|
-
nullable:
|
|
35
|
-
optional:
|
|
36
|
-
} :
|
|
33
|
+
default: s ? a : 0,
|
|
34
|
+
nullable: e,
|
|
35
|
+
optional: n
|
|
36
|
+
} : u === "ZodString" || u === "string" ? {
|
|
37
37
|
type: "string",
|
|
38
|
-
schema:
|
|
38
|
+
schema: f,
|
|
39
39
|
source: o,
|
|
40
|
-
default: s ?
|
|
41
|
-
nullable:
|
|
42
|
-
optional:
|
|
43
|
-
} :
|
|
40
|
+
default: s ? a : "",
|
|
41
|
+
nullable: e,
|
|
42
|
+
optional: n
|
|
43
|
+
} : u === "ZodBoolean" || u === "boolean" ? {
|
|
44
44
|
type: "boolean",
|
|
45
|
-
schema:
|
|
45
|
+
schema: f,
|
|
46
46
|
source: o,
|
|
47
|
-
default: s ?
|
|
48
|
-
nullable:
|
|
49
|
-
optional:
|
|
50
|
-
} :
|
|
47
|
+
default: s ? a : !1,
|
|
48
|
+
nullable: e,
|
|
49
|
+
optional: n
|
|
50
|
+
} : u === "ZodArray" || u === "array" ? {
|
|
51
51
|
type: "array",
|
|
52
|
-
schema:
|
|
52
|
+
schema: f,
|
|
53
53
|
source: o,
|
|
54
|
-
default: s ?
|
|
55
|
-
nullable:
|
|
56
|
-
optional:
|
|
57
|
-
} :
|
|
54
|
+
default: s ? a : [],
|
|
55
|
+
nullable: e,
|
|
56
|
+
optional: n
|
|
57
|
+
} : u === "ZodObject" || u === "object" ? {
|
|
58
58
|
type: "object",
|
|
59
|
-
schema:
|
|
59
|
+
schema: f,
|
|
60
60
|
source: o,
|
|
61
|
-
default: s ?
|
|
62
|
-
nullable:
|
|
63
|
-
optional:
|
|
64
|
-
} :
|
|
61
|
+
default: s ? a : {},
|
|
62
|
+
nullable: e,
|
|
63
|
+
optional: n
|
|
64
|
+
} : u === "ZodDate" || u === "date" ? {
|
|
65
65
|
type: "date",
|
|
66
|
-
schema:
|
|
66
|
+
schema: f,
|
|
67
67
|
source: o,
|
|
68
|
-
default: s ?
|
|
69
|
-
nullable:
|
|
70
|
-
optional:
|
|
68
|
+
default: s ? a : /* @__PURE__ */ new Date(),
|
|
69
|
+
nullable: e,
|
|
70
|
+
optional: n
|
|
71
71
|
} : null;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
if (
|
|
73
|
+
function A(f) {
|
|
74
|
+
if (f === null)
|
|
75
75
|
return {
|
|
76
76
|
type: "unknown",
|
|
77
77
|
schema: null,
|
|
@@ -79,7 +79,7 @@ function E(u) {
|
|
|
79
79
|
default: null,
|
|
80
80
|
nullable: !0
|
|
81
81
|
};
|
|
82
|
-
if (
|
|
82
|
+
if (f === void 0)
|
|
83
83
|
return {
|
|
84
84
|
type: "unknown",
|
|
85
85
|
schema: null,
|
|
@@ -87,557 +87,610 @@ function E(u) {
|
|
|
87
87
|
default: void 0,
|
|
88
88
|
optional: !0
|
|
89
89
|
};
|
|
90
|
-
const o = typeof
|
|
91
|
-
return o === "number" ? { type: "number", schema: null, source: "runtime", default:
|
|
90
|
+
const o = typeof f;
|
|
91
|
+
return o === "number" ? { type: "number", schema: null, source: "runtime", default: f } : o === "string" ? { type: "string", schema: null, source: "runtime", default: f } : o === "boolean" ? { type: "boolean", schema: null, source: "runtime", default: f } : Array.isArray(f) ? { type: "array", schema: null, source: "runtime", default: [] } : f instanceof Date ? { type: "date", schema: null, source: "runtime", default: f } : o === "object" ? { type: "object", schema: null, source: "runtime", default: {} } : { type: "unknown", schema: null, source: "runtime", default: f };
|
|
92
92
|
}
|
|
93
|
-
function _(
|
|
93
|
+
function _(f, o, t) {
|
|
94
94
|
if (o == null || typeof o != "object") {
|
|
95
|
-
const
|
|
96
|
-
return
|
|
95
|
+
const e = { _meta: { value: o } };
|
|
96
|
+
return e._meta.typeInfo = I(o, t), e;
|
|
97
97
|
}
|
|
98
98
|
if (Array.isArray(o)) {
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
const s =
|
|
102
|
-
...
|
|
103
|
-
path: [...
|
|
99
|
+
const e = { _meta: { arrayKeys: [] } };
|
|
100
|
+
return e._meta.typeInfo = I(o, t), o.forEach((n, a) => {
|
|
101
|
+
const s = w(), i = t ? {
|
|
102
|
+
...t,
|
|
103
|
+
path: [...t.path, a.toString()]
|
|
104
104
|
} : void 0;
|
|
105
|
-
|
|
106
|
-
}),
|
|
105
|
+
e[s] = _(f, n, i), e._meta.arrayKeys.push(s);
|
|
106
|
+
}), e;
|
|
107
107
|
}
|
|
108
108
|
if (o.constructor === Object) {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
for (const
|
|
112
|
-
if (Object.prototype.hasOwnProperty.call(o,
|
|
113
|
-
const
|
|
114
|
-
...
|
|
115
|
-
path: [...
|
|
109
|
+
const e = { _meta: {} };
|
|
110
|
+
e._meta.typeInfo = I(o, t);
|
|
111
|
+
for (const n in o)
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(o, n)) {
|
|
113
|
+
const a = t ? {
|
|
114
|
+
...t,
|
|
115
|
+
path: [...t.path, n]
|
|
116
116
|
} : void 0;
|
|
117
|
-
|
|
117
|
+
e[n] = _(f, o[n], a);
|
|
118
118
|
}
|
|
119
|
-
return
|
|
119
|
+
return e;
|
|
120
120
|
}
|
|
121
121
|
return {
|
|
122
122
|
_meta: {
|
|
123
123
|
value: o,
|
|
124
|
-
typeInfo:
|
|
124
|
+
typeInfo: A(o)
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
function I(
|
|
128
|
+
function I(f, o) {
|
|
129
129
|
if (o) {
|
|
130
|
-
let
|
|
130
|
+
let t = null;
|
|
131
131
|
if (o.schemas.zodV4) {
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const e = o.path.length === 0 ? o.schemas.zodV4 : E(o.schemas.zodV4, o.path);
|
|
133
|
+
e && (t = v(e, "zod4"));
|
|
134
134
|
}
|
|
135
|
-
if (!
|
|
136
|
-
const
|
|
137
|
-
|
|
135
|
+
if (!t && o.schemas.zodV3) {
|
|
136
|
+
const e = o.path.length === 0 ? o.schemas.zodV3 : E(o.schemas.zodV3, o.path);
|
|
137
|
+
e && (t = v(e, "zod3"));
|
|
138
138
|
}
|
|
139
|
-
if (!
|
|
139
|
+
if (!t && o.schemas.sync?.[o.stateKey] && (t = A(f), t.source = "sync"), t) return t;
|
|
140
140
|
}
|
|
141
|
-
return
|
|
141
|
+
return A(f);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
146
|
-
function a
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
...
|
|
153
|
-
schema:
|
|
143
|
+
function j(f, o, t) {
|
|
144
|
+
const e = b.get(f) || b.get(`[${f}`);
|
|
145
|
+
if (!e) return;
|
|
146
|
+
function n(a, s) {
|
|
147
|
+
if (!a || typeof a != "object") return;
|
|
148
|
+
const i = E(o, s);
|
|
149
|
+
if (i) {
|
|
150
|
+
const r = v(i, t);
|
|
151
|
+
r && (a._meta || (a._meta = {}), a._meta.typeInfo = {
|
|
152
|
+
...r,
|
|
153
|
+
schema: i
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}) :
|
|
159
|
-
|
|
156
|
+
a._meta?.arrayKeys ? a._meta.arrayKeys.forEach((r) => {
|
|
157
|
+
a[r] && n(a[r], [...s, "0"]);
|
|
158
|
+
}) : a._meta?.hasOwnProperty("value") || Object.keys(a).forEach((r) => {
|
|
159
|
+
r !== "_meta" && n(a[r], [...s, r]);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
n(e, []);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
let o =
|
|
164
|
+
function K(f) {
|
|
165
|
+
let o = f;
|
|
166
166
|
for (; o; ) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
o =
|
|
167
|
+
const t = o.def || o._def, e = t?.typeName || t?.type || o._type;
|
|
168
|
+
if (e === "ZodOptional" || e === "optional" || e === "ZodNullable" || e === "nullable" || e === "ZodDefault" || e === "default" || e === "ZodEffects" || e === "effects")
|
|
169
|
+
o = t.innerType || t.schema || o._inner || o.unwrap?.();
|
|
170
170
|
else
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
173
|
return o;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
if (!
|
|
177
|
-
if (o.length === 0) return
|
|
178
|
-
let
|
|
179
|
-
for (const
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const
|
|
175
|
+
function E(f, o) {
|
|
176
|
+
if (!f) return null;
|
|
177
|
+
if (o.length === 0) return f;
|
|
178
|
+
let t = f;
|
|
179
|
+
for (const e of o) {
|
|
180
|
+
const n = K(t);
|
|
181
|
+
if (!n) return null;
|
|
182
|
+
const a = n.def || n._def, s = a?.typeName || a?.type || n._type;
|
|
183
183
|
if (s === "ZodObject" || s === "object")
|
|
184
|
-
|
|
184
|
+
t = (a?.shape || n.shape || n._shape)?.[e];
|
|
185
185
|
else if (s === "ZodArray" || s === "array")
|
|
186
|
-
|
|
186
|
+
t = n.element || a?.type;
|
|
187
187
|
else
|
|
188
188
|
return null;
|
|
189
|
-
if (!
|
|
189
|
+
if (!t)
|
|
190
190
|
return null;
|
|
191
191
|
}
|
|
192
|
-
return
|
|
192
|
+
return t;
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
let
|
|
194
|
+
const b = /* @__PURE__ */ new Map();
|
|
195
|
+
let z = 0;
|
|
196
196
|
const V = Date.now().toString(36);
|
|
197
|
-
function
|
|
198
|
-
return `id:local_${V}_${(
|
|
197
|
+
function w(f) {
|
|
198
|
+
return `id:local_${V}_${(z++).toString(36)}`;
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
getPluginMetaDataMap: (
|
|
202
|
-
setPluginMetaData: (e,
|
|
203
|
-
const s = o().getShadowMetadata(
|
|
204
|
-
|
|
200
|
+
const C = N((f, o) => ({
|
|
201
|
+
getPluginMetaDataMap: (t, e) => o().getShadowMetadata(t, e)?.pluginMetaData,
|
|
202
|
+
setPluginMetaData: (t, e, n, a) => {
|
|
203
|
+
const s = o().getShadowMetadata(t, e) || {}, i = new Map(s.pluginMetaData || []), r = i.get(n) || {};
|
|
204
|
+
i.set(n, { ...r, ...a }), o().setShadowMetadata(t, e, { ...s, pluginMetaData: i }), o().notifyPathSubscribers([t, ...e].join("."), {
|
|
205
205
|
type: "METADATA_UPDATE"
|
|
206
206
|
});
|
|
207
207
|
},
|
|
208
|
-
removePluginMetaData: (
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
211
|
-
const s = new Map(
|
|
212
|
-
s.delete(
|
|
208
|
+
removePluginMetaData: (t, e, n) => {
|
|
209
|
+
const a = o().getShadowMetadata(t, e);
|
|
210
|
+
if (!a?.pluginMetaData) return;
|
|
211
|
+
const s = new Map(a.pluginMetaData);
|
|
212
|
+
s.delete(n), o().setShadowMetadata(t, e, { ...a, pluginMetaData: s });
|
|
213
213
|
},
|
|
214
|
-
setTransformCache: (e,
|
|
215
|
-
const s = o().getShadowMetadata(
|
|
216
|
-
s.transformCaches || (s.transformCaches = /* @__PURE__ */ new Map()), s.transformCaches.set(
|
|
214
|
+
setTransformCache: (t, e, n, a) => {
|
|
215
|
+
const s = o().getShadowMetadata(t, e) || {};
|
|
216
|
+
s.transformCaches || (s.transformCaches = /* @__PURE__ */ new Map()), s.transformCaches.set(n, a), o().setShadowMetadata(t, e, {
|
|
217
217
|
transformCaches: s.transformCaches
|
|
218
218
|
});
|
|
219
219
|
},
|
|
220
220
|
// Replace your entire `initializeAndMergeShadowState` function with this one.
|
|
221
|
-
initializeAndMergeShadowState: (
|
|
222
|
-
const
|
|
223
|
-
let
|
|
221
|
+
initializeAndMergeShadowState: (t, e) => {
|
|
222
|
+
const a = e?._meta?.arrayKeys !== void 0 ? `[${t}` : t, s = b.get(a) || b.get(t) || b.get(`[${t}`);
|
|
223
|
+
let i = {};
|
|
224
224
|
if (s?._meta) {
|
|
225
225
|
const {
|
|
226
|
-
components:
|
|
227
|
-
features:
|
|
228
|
-
lastServerSync:
|
|
229
|
-
stateSource:
|
|
230
|
-
baseServerState:
|
|
231
|
-
pathComponents:
|
|
232
|
-
signals:
|
|
226
|
+
components: d,
|
|
227
|
+
features: y,
|
|
228
|
+
lastServerSync: h,
|
|
229
|
+
stateSource: p,
|
|
230
|
+
baseServerState: c,
|
|
231
|
+
pathComponents: m,
|
|
232
|
+
signals: S,
|
|
233
233
|
validation: g
|
|
234
234
|
} = s._meta;
|
|
235
|
-
|
|
235
|
+
d && (i.components = d), y && (i.features = y), h && (i.lastServerSync = h), p && (i.stateSource = p), c && (i.baseServerState = c), m && (i.pathComponents = m), S && (i.signals = S), g && (i.validation = g);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
|
|
237
|
+
function r(d, y) {
|
|
238
|
+
if (y._meta || d._meta) {
|
|
239
|
+
const c = d._meta || {}, m = y._meta || {}, S = { ...c, ...m };
|
|
240
|
+
c.typeInfo?.schema && !m.typeInfo?.schema && (S.typeInfo = c.typeInfo), c.validation && !m.validation && (S.validation = c.validation), c.components && (S.components = c.components), c.clientActivityState && !m.clientActivityState && (S.clientActivityState = c.clientActivityState), c.pluginMetaData && !m.pluginMetaData && (S.pluginMetaData = c.pluginMetaData), d._meta = S;
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
243
|
-
for (const
|
|
244
|
-
|
|
242
|
+
if (y._meta?.hasOwnProperty("value")) {
|
|
243
|
+
for (const c in d)
|
|
244
|
+
c !== "_meta" && delete d[c];
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
const
|
|
248
|
-
Object.keys(
|
|
249
|
-
),
|
|
250
|
-
Object.keys(
|
|
247
|
+
const h = new Set(
|
|
248
|
+
Object.keys(y).filter((c) => c !== "_meta")
|
|
249
|
+
), p = new Set(
|
|
250
|
+
Object.keys(d).filter((c) => c !== "_meta")
|
|
251
251
|
);
|
|
252
|
-
for (const
|
|
253
|
-
|
|
254
|
-
for (const
|
|
255
|
-
const
|
|
256
|
-
|
|
252
|
+
for (const c of p)
|
|
253
|
+
h.has(c) || delete d[c];
|
|
254
|
+
for (const c of h) {
|
|
255
|
+
const m = y[c], S = d[c];
|
|
256
|
+
S && typeof S == "object" && m && typeof m == "object" ? r(S, m) : d[c] = m;
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
s ? (
|
|
260
|
-
const
|
|
261
|
-
(
|
|
259
|
+
s ? (r(s, e), s._meta || (s._meta = {}), Object.assign(s._meta, i), b.set(a, s)) : (i && Object.keys(i).length > 0 && (e._meta || (e._meta = {}), Object.assign(e._meta, i)), b.set(a, e));
|
|
260
|
+
const u = o().getInitialOptions(t);
|
|
261
|
+
(u?.validation?.zodSchemaV4 || u?.validation?.zodSchemaV3) && (u.validation?.zodSchemaV4 ? j(t, u.validation.zodSchemaV4, "zod4") : u.validation?.zodSchemaV3 && j(t, u.validation.zodSchemaV3, "zod3")), a === t ? b.delete(`[${t}`) : b.delete(t);
|
|
262
262
|
},
|
|
263
|
-
initializeShadowState: (
|
|
264
|
-
const
|
|
265
|
-
let
|
|
266
|
-
|
|
263
|
+
initializeShadowState: (t, e) => {
|
|
264
|
+
const n = b.get(t) || b.get(`[${t}`);
|
|
265
|
+
let a = {};
|
|
266
|
+
const s = /* @__PURE__ */ new Map();
|
|
267
|
+
if (n) {
|
|
268
|
+
const h = (p, c) => {
|
|
269
|
+
if (!(!p || typeof p != "object")) {
|
|
270
|
+
(p._meta?.clientActivityState || p._meta?.pluginMetaData) && s.set(c.join("\0"), {
|
|
271
|
+
clientActivityState: p._meta.clientActivityState,
|
|
272
|
+
pluginMetaData: p._meta.pluginMetaData
|
|
273
|
+
});
|
|
274
|
+
for (const m in p)
|
|
275
|
+
m !== "_meta" && h(p[m], [...c, m]);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
h(n, []);
|
|
279
|
+
}
|
|
280
|
+
if (n?._meta) {
|
|
267
281
|
const {
|
|
268
|
-
components:
|
|
282
|
+
components: h,
|
|
269
283
|
features: p,
|
|
270
|
-
lastServerSync:
|
|
284
|
+
lastServerSync: c,
|
|
271
285
|
stateSource: m,
|
|
272
|
-
baseServerState:
|
|
273
|
-
} =
|
|
274
|
-
|
|
286
|
+
baseServerState: S
|
|
287
|
+
} = n._meta;
|
|
288
|
+
h && (a.components = h), p && (a.features = p), c && (a.lastServerSync = c), m && (a.stateSource = m), S && (a.baseServerState = S);
|
|
275
289
|
}
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
stateKey:
|
|
290
|
+
b.delete(t), b.delete(`[${t}`);
|
|
291
|
+
const i = o().getInitialOptions(t), r = o().getInitialOptions("__syncSchemas"), u = {
|
|
292
|
+
stateKey: t,
|
|
279
293
|
path: [],
|
|
280
294
|
schemas: {
|
|
281
295
|
sync: r,
|
|
282
|
-
zodV4:
|
|
283
|
-
zodV3:
|
|
296
|
+
zodV4: i?.validation?.zodSchemaV4,
|
|
297
|
+
zodV3: i?.validation?.zodSchemaV3
|
|
284
298
|
}
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
299
|
+
}, l = _(t, e, u);
|
|
300
|
+
l._meta || (l._meta = {}), Object.assign(l._meta, a);
|
|
301
|
+
const d = (h, p) => {
|
|
302
|
+
if (!h || typeof h != "object") return;
|
|
303
|
+
const c = p.join("\0"), m = s.get(c);
|
|
304
|
+
m && (h._meta || (h._meta = {}), m.clientActivityState && (h._meta.clientActivityState = m.clientActivityState), m.pluginMetaData && (h._meta.pluginMetaData = m.pluginMetaData));
|
|
305
|
+
for (const S in h)
|
|
306
|
+
S !== "_meta" && d(h[S], [...p, S]);
|
|
307
|
+
};
|
|
308
|
+
d(l, []);
|
|
309
|
+
const y = Array.isArray(e) ? `[${t}` : t;
|
|
310
|
+
b.set(y, l);
|
|
289
311
|
},
|
|
290
|
-
getShadowNode: (
|
|
291
|
-
let
|
|
292
|
-
if (
|
|
293
|
-
if (
|
|
294
|
-
for (const
|
|
295
|
-
if (typeof
|
|
296
|
-
return
|
|
312
|
+
getShadowNode: (t, e) => {
|
|
313
|
+
let n = b.get(t) || b.get(`[${t}`);
|
|
314
|
+
if (n) {
|
|
315
|
+
if (e.length === 0) return n;
|
|
316
|
+
for (const a of e)
|
|
317
|
+
if (typeof n != "object" || n === null || (n = n[a], n === void 0)) return;
|
|
318
|
+
return n;
|
|
297
319
|
}
|
|
298
320
|
},
|
|
299
|
-
getShadowMetadata: (
|
|
300
|
-
setShadowMetadata: (
|
|
301
|
-
const
|
|
302
|
-
let s =
|
|
321
|
+
getShadowMetadata: (t, e) => o().getShadowNode(t, e)?._meta,
|
|
322
|
+
setShadowMetadata: (t, e, n) => {
|
|
323
|
+
const a = b.has(`[${t}`) ? `[${t}` : t;
|
|
324
|
+
let s = b.get(a);
|
|
303
325
|
if (!s) {
|
|
304
|
-
s = { _meta:
|
|
326
|
+
s = { _meta: n }, b.set(a, s);
|
|
305
327
|
return;
|
|
306
328
|
}
|
|
307
|
-
let
|
|
308
|
-
for (const
|
|
309
|
-
r
|
|
310
|
-
|
|
329
|
+
let i = s;
|
|
330
|
+
for (const r of e)
|
|
331
|
+
i[r] || (i[r] = {}), i = i[r];
|
|
332
|
+
i._meta || (i._meta = {}), Object.assign(i._meta, n);
|
|
311
333
|
},
|
|
312
|
-
getShadowValue: (
|
|
313
|
-
const
|
|
314
|
-
if (!
|
|
334
|
+
getShadowValue: (t, e, n) => {
|
|
335
|
+
const a = o().getShadowNode(t, e);
|
|
336
|
+
if (!a)
|
|
315
337
|
return;
|
|
316
|
-
const s = {},
|
|
317
|
-
[
|
|
338
|
+
const s = {}, i = [
|
|
339
|
+
[a, s, "final"]
|
|
318
340
|
];
|
|
319
|
-
for (;
|
|
320
|
-
const [
|
|
321
|
-
if (
|
|
322
|
-
|
|
341
|
+
for (; i.length > 0; ) {
|
|
342
|
+
const [r, u, l] = i.pop();
|
|
343
|
+
if (r._meta?.hasOwnProperty("value")) {
|
|
344
|
+
u[l] = r._meta.value;
|
|
323
345
|
continue;
|
|
324
346
|
}
|
|
325
|
-
if (
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
for (let
|
|
329
|
-
const
|
|
330
|
-
|
|
347
|
+
if (r._meta?.arrayKeys) {
|
|
348
|
+
const h = n || r._meta.arrayKeys, p = [];
|
|
349
|
+
u[l] = p;
|
|
350
|
+
for (let c = h.length - 1; c >= 0; c--) {
|
|
351
|
+
const m = h[c];
|
|
352
|
+
r[m] && i.push([r[m], p, c]);
|
|
331
353
|
}
|
|
332
354
|
continue;
|
|
333
355
|
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
for (const
|
|
338
|
-
|
|
356
|
+
const d = {};
|
|
357
|
+
u[l] = d;
|
|
358
|
+
const y = Object.keys(r);
|
|
359
|
+
for (const h of y)
|
|
360
|
+
h !== "_meta" && i.push([r[h], d, h]);
|
|
339
361
|
}
|
|
340
362
|
return s.final;
|
|
341
363
|
},
|
|
342
|
-
updateShadowAtPath: (
|
|
343
|
-
const
|
|
344
|
-
let s =
|
|
364
|
+
updateShadowAtPath: (t, e, n) => {
|
|
365
|
+
const a = b.has(`[${t}`) ? `[${t}` : t;
|
|
366
|
+
let s = b.get(a);
|
|
345
367
|
if (!s) return;
|
|
346
|
-
let
|
|
347
|
-
for (let l = 0; l <
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
function
|
|
351
|
-
if (typeof
|
|
352
|
-
const
|
|
353
|
-
for (const
|
|
354
|
-
|
|
355
|
-
l._meta = { ...
|
|
368
|
+
let i = s;
|
|
369
|
+
for (let l = 0; l < e.length - 1; l++)
|
|
370
|
+
i[e[l]] || (i[e[l]] = {}), i = i[e[l]];
|
|
371
|
+
const r = e.length === 0 ? i : i[e[e.length - 1]];
|
|
372
|
+
function u(l, d, y) {
|
|
373
|
+
if (typeof d != "object" || d === null || d instanceof Date) {
|
|
374
|
+
const p = l._meta || {};
|
|
375
|
+
for (const c in l)
|
|
376
|
+
c !== "_meta" && delete l[c];
|
|
377
|
+
l._meta = { ...p, value: d };
|
|
356
378
|
return;
|
|
357
379
|
}
|
|
358
|
-
if (Array.isArray(
|
|
380
|
+
if (Array.isArray(d)) {
|
|
359
381
|
l._meta || (l._meta = {}), l._meta.arrayKeys || (l._meta.arrayKeys = []);
|
|
360
|
-
const
|
|
361
|
-
for (let
|
|
362
|
-
const g =
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
...
|
|
367
|
-
|
|
368
|
-
]),
|
|
382
|
+
const p = l._meta.arrayKeys, c = d, m = [];
|
|
383
|
+
for (let S = 0; S < c.length; S++) {
|
|
384
|
+
const g = c[S];
|
|
385
|
+
if (S < p.length) {
|
|
386
|
+
const M = p[S];
|
|
387
|
+
u(l[M], g, [
|
|
388
|
+
...y,
|
|
389
|
+
M
|
|
390
|
+
]), m.push(M);
|
|
369
391
|
} else {
|
|
370
|
-
const
|
|
371
|
-
stateKey:
|
|
372
|
-
path: [...
|
|
392
|
+
const M = w(), O = o().getInitialOptions(t), D = {
|
|
393
|
+
stateKey: t,
|
|
394
|
+
path: [...y, "0"],
|
|
373
395
|
// Use '0' for array element schema lookup
|
|
374
396
|
schemas: {
|
|
375
|
-
zodV4:
|
|
376
|
-
zodV3:
|
|
397
|
+
zodV4: O?.validation?.zodSchemaV4,
|
|
398
|
+
zodV3: O?.validation?.zodSchemaV3
|
|
377
399
|
}
|
|
378
400
|
};
|
|
379
|
-
l[
|
|
380
|
-
|
|
401
|
+
l[M] = _(
|
|
402
|
+
t,
|
|
381
403
|
g,
|
|
382
|
-
|
|
383
|
-
),
|
|
404
|
+
D
|
|
405
|
+
), m.push(M);
|
|
384
406
|
}
|
|
385
407
|
}
|
|
386
|
-
|
|
408
|
+
p.length > c.length && p.slice(c.length).forEach((g) => {
|
|
387
409
|
delete l[g];
|
|
388
|
-
}), l._meta.arrayKeys =
|
|
410
|
+
}), l._meta.arrayKeys = m;
|
|
389
411
|
return;
|
|
390
412
|
}
|
|
391
|
-
const
|
|
413
|
+
const h = new Set(Object.keys(d));
|
|
392
414
|
l._meta?.hasOwnProperty("value") && delete l._meta.value;
|
|
393
|
-
for (const
|
|
394
|
-
const
|
|
395
|
-
if (l[
|
|
396
|
-
|
|
397
|
-
...
|
|
398
|
-
|
|
415
|
+
for (const p of h) {
|
|
416
|
+
const c = d[p];
|
|
417
|
+
if (l[p])
|
|
418
|
+
u(l[p], c, [
|
|
419
|
+
...y,
|
|
420
|
+
p
|
|
399
421
|
]);
|
|
400
422
|
else {
|
|
401
|
-
const
|
|
402
|
-
stateKey:
|
|
403
|
-
path: [...
|
|
423
|
+
const m = o().getInitialOptions(t), S = {
|
|
424
|
+
stateKey: t,
|
|
425
|
+
path: [...y, p],
|
|
404
426
|
schemas: {
|
|
405
|
-
zodV4:
|
|
406
|
-
zodV3:
|
|
427
|
+
zodV4: m?.validation?.zodSchemaV4,
|
|
428
|
+
zodV3: m?.validation?.zodSchemaV3
|
|
407
429
|
}
|
|
408
430
|
};
|
|
409
|
-
l[
|
|
431
|
+
l[p] = _(t, c, S);
|
|
410
432
|
}
|
|
411
433
|
}
|
|
412
|
-
for (const
|
|
413
|
-
|
|
434
|
+
for (const p in l)
|
|
435
|
+
p === "_meta" || !Object.prototype.hasOwnProperty.call(l, p) || h.has(p) || delete l[p];
|
|
414
436
|
}
|
|
415
|
-
|
|
437
|
+
r ? u(r, n, e) : i[e[e.length - 1]] = _(t, n), o().notifyPathSubscribers([t, ...e].join("."), {
|
|
416
438
|
type: "UPDATE",
|
|
417
|
-
newValue:
|
|
439
|
+
newValue: n
|
|
418
440
|
});
|
|
419
441
|
},
|
|
420
|
-
addItemsToArrayNode: (
|
|
421
|
-
const
|
|
422
|
-
let s =
|
|
442
|
+
addItemsToArrayNode: (t, e, n) => {
|
|
443
|
+
const a = b.has(`[${t}`) ? `[${t}` : t;
|
|
444
|
+
let s = b.get(a);
|
|
423
445
|
if (!s) {
|
|
424
|
-
console.error("Root not found for state key:",
|
|
446
|
+
console.error("Root not found for state key:", t);
|
|
425
447
|
return;
|
|
426
448
|
}
|
|
427
|
-
let
|
|
428
|
-
for (const
|
|
429
|
-
r
|
|
430
|
-
Object.assign(
|
|
449
|
+
let i = s;
|
|
450
|
+
for (const r of e)
|
|
451
|
+
i[r] || (i[r] = {}), i = i[r];
|
|
452
|
+
Object.assign(i, n);
|
|
431
453
|
},
|
|
432
|
-
insertShadowArrayElement: (e,
|
|
433
|
-
const
|
|
434
|
-
if (!
|
|
454
|
+
insertShadowArrayElement: (t, e, n, a, s) => {
|
|
455
|
+
const i = o().getShadowNode(t, e);
|
|
456
|
+
if (!i?._meta?.arrayKeys)
|
|
435
457
|
throw new Error(
|
|
436
|
-
`Array not found at path: ${[
|
|
458
|
+
`Array not found at path: ${[t, ...e].join(".")}`
|
|
437
459
|
);
|
|
438
|
-
const
|
|
439
|
-
r
|
|
440
|
-
const
|
|
441
|
-
l >=
|
|
442
|
-
const
|
|
443
|
-
return o().notifyPathSubscribers(
|
|
460
|
+
const r = s || `${w()}`;
|
|
461
|
+
i[r] = _(t, n);
|
|
462
|
+
const u = i._meta.arrayKeys, l = a !== void 0 && a >= 0 && a <= u.length ? a : u.length;
|
|
463
|
+
l >= u.length ? u.push(r) : u.splice(l, 0, r);
|
|
464
|
+
const d = [t, ...e].join(".");
|
|
465
|
+
return o().notifyPathSubscribers(d, {
|
|
444
466
|
type: "INSERT",
|
|
445
|
-
path:
|
|
446
|
-
itemKey: `${
|
|
467
|
+
path: d,
|
|
468
|
+
itemKey: `${d}.${r}`,
|
|
447
469
|
index: l
|
|
448
|
-
}),
|
|
470
|
+
}), r;
|
|
449
471
|
},
|
|
450
|
-
insertManyShadowArrayElements: (e,
|
|
451
|
-
if (!
|
|
472
|
+
insertManyShadowArrayElements: (t, e, n, a) => {
|
|
473
|
+
if (!n || n.length === 0)
|
|
452
474
|
return;
|
|
453
|
-
const s = o().getShadowNode(
|
|
475
|
+
const s = o().getShadowNode(t, e);
|
|
454
476
|
if (!s?._meta?.arrayKeys) {
|
|
455
477
|
console.error(
|
|
456
|
-
`Array not found at path: ${[
|
|
478
|
+
`Array not found at path: ${[t, ...e].join(".")}`
|
|
457
479
|
);
|
|
458
480
|
return;
|
|
459
481
|
}
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
482
|
+
const i = [];
|
|
483
|
+
n.forEach((d) => {
|
|
484
|
+
const y = `${w()}`;
|
|
485
|
+
i.push(y), s[y] = _(t, d);
|
|
464
486
|
});
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
const l = [
|
|
487
|
+
const r = s._meta.arrayKeys, u = a !== void 0 && a >= 0 && a <= r.length ? a : r.length;
|
|
488
|
+
u >= r.length ? r.push(...i) : r.splice(u, 0, ...i);
|
|
489
|
+
const l = [t, ...e].join(".");
|
|
468
490
|
o().notifyPathSubscribers(l, {
|
|
469
491
|
type: "INSERT_MANY",
|
|
470
492
|
path: l,
|
|
471
|
-
count:
|
|
472
|
-
index:
|
|
493
|
+
count: n.length,
|
|
494
|
+
index: u
|
|
473
495
|
});
|
|
474
496
|
},
|
|
475
|
-
removeShadowArrayElement: (
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
if (!
|
|
479
|
-
const s = o().getShadowNode(
|
|
497
|
+
removeShadowArrayElement: (t, e) => {
|
|
498
|
+
if (e.length === 0) return;
|
|
499
|
+
const n = e.slice(0, -1), a = e[e.length - 1];
|
|
500
|
+
if (!a?.startsWith("id:")) return;
|
|
501
|
+
const s = o().getShadowNode(t, n);
|
|
480
502
|
if (!s?._meta?.arrayKeys) return;
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
o().notifyPathSubscribers(
|
|
503
|
+
const i = s._meta.arrayKeys, r = i.indexOf(a);
|
|
504
|
+
if (r === -1) return;
|
|
505
|
+
r === i.length - 1 ? i.pop() : r === 0 ? i.shift() : i.splice(r, 1), delete s[a];
|
|
506
|
+
const u = [t, ...n].join(".");
|
|
507
|
+
o().notifyPathSubscribers(u, {
|
|
486
508
|
type: "REMOVE",
|
|
487
|
-
path:
|
|
488
|
-
itemKey: `${
|
|
509
|
+
path: u,
|
|
510
|
+
itemKey: `${u}.${a}`
|
|
489
511
|
});
|
|
490
512
|
},
|
|
491
|
-
registerComponent: (
|
|
492
|
-
const
|
|
493
|
-
s.set(
|
|
513
|
+
registerComponent: (t, e, n) => {
|
|
514
|
+
const a = o().getShadowMetadata(t, []) || {}, s = new Map(a.components);
|
|
515
|
+
s.set(e, n), o().setShadowMetadata(t, [], { components: s });
|
|
494
516
|
},
|
|
495
|
-
unregisterComponent: (
|
|
496
|
-
const
|
|
497
|
-
if (!
|
|
498
|
-
const
|
|
499
|
-
|
|
517
|
+
unregisterComponent: (t, e) => {
|
|
518
|
+
const n = o().getShadowMetadata(t, []);
|
|
519
|
+
if (!n?.components) return;
|
|
520
|
+
const a = new Map(n.components);
|
|
521
|
+
a.delete(e) && o().setShadowMetadata(t, [], { components: a });
|
|
500
522
|
},
|
|
501
|
-
addPathComponent: (
|
|
502
|
-
const
|
|
503
|
-
s.add(
|
|
523
|
+
addPathComponent: (t, e, n) => {
|
|
524
|
+
const a = o().getShadowMetadata(t, e) || {}, s = new Set(a.pathComponents);
|
|
525
|
+
s.add(n), o().setShadowMetadata(t, e, {
|
|
504
526
|
pathComponents: s
|
|
505
527
|
});
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
l.add(
|
|
512
|
-
const
|
|
513
|
-
|
|
528
|
+
const i = o().getShadowMetadata(t, []);
|
|
529
|
+
if (i?.components) {
|
|
530
|
+
const r = i.components.get(n);
|
|
531
|
+
if (r) {
|
|
532
|
+
const u = [t, ...e].join("."), l = new Set(r.paths);
|
|
533
|
+
l.add(u);
|
|
534
|
+
const d = { ...r, paths: l }, y = new Map(i.components);
|
|
535
|
+
y.set(n, d), o().setShadowMetadata(t, [], { components: y });
|
|
514
536
|
}
|
|
515
537
|
}
|
|
516
538
|
},
|
|
517
|
-
markAsDirty: (
|
|
518
|
-
let
|
|
519
|
-
if (!
|
|
520
|
-
let s =
|
|
521
|
-
for (const
|
|
522
|
-
if (s = s[
|
|
523
|
-
if (s._meta || (s._meta = {}), s._meta.isDirty = !0, !
|
|
524
|
-
let
|
|
525
|
-
for (let
|
|
526
|
-
if (
|
|
539
|
+
markAsDirty: (t, e, n = { bubble: !0 }) => {
|
|
540
|
+
let a = o().getShadowNode(t, []);
|
|
541
|
+
if (!a) return;
|
|
542
|
+
let s = a;
|
|
543
|
+
for (const r of e)
|
|
544
|
+
if (s = s[r], !s) return;
|
|
545
|
+
if (s._meta || (s._meta = {}), s._meta.isDirty = !0, !n.bubble) return;
|
|
546
|
+
let i = a;
|
|
547
|
+
for (let r = 0; r < e.length; r++) {
|
|
548
|
+
if (i._meta?.isDirty)
|
|
527
549
|
return;
|
|
528
|
-
|
|
550
|
+
i._meta || (i._meta = {}), i._meta.isDirty = !0, i = i[e[r]];
|
|
529
551
|
}
|
|
530
552
|
},
|
|
531
553
|
// Keep these in Zustand as they need React reactivity
|
|
532
554
|
serverStateUpdates: /* @__PURE__ */ new Map(),
|
|
533
|
-
setServerStateUpdate: (
|
|
534
|
-
|
|
535
|
-
serverStateUpdates: new Map(
|
|
536
|
-
|
|
537
|
-
|
|
555
|
+
setServerStateUpdate: (t, e) => {
|
|
556
|
+
f((n) => ({
|
|
557
|
+
serverStateUpdates: new Map(n.serverStateUpdates).set(
|
|
558
|
+
t,
|
|
559
|
+
e
|
|
538
560
|
)
|
|
539
|
-
})), o().notifyPathSubscribers(
|
|
561
|
+
})), o().notifyPathSubscribers(t, {
|
|
540
562
|
type: "SERVER_STATE_UPDATE",
|
|
541
|
-
serverState:
|
|
563
|
+
serverState: e
|
|
542
564
|
});
|
|
543
565
|
},
|
|
544
566
|
pathSubscribers: /* @__PURE__ */ new Map(),
|
|
545
|
-
subscribeToPath: (
|
|
546
|
-
const
|
|
547
|
-
return
|
|
548
|
-
const s = o().pathSubscribers.get(
|
|
549
|
-
s && (s.delete(
|
|
567
|
+
subscribeToPath: (t, e) => {
|
|
568
|
+
const n = o().pathSubscribers, a = n.get(t) || /* @__PURE__ */ new Set();
|
|
569
|
+
return a.add(e), n.set(t, a), () => {
|
|
570
|
+
const s = o().pathSubscribers.get(t);
|
|
571
|
+
s && (s.delete(e), s.size === 0 && o().pathSubscribers.delete(t));
|
|
550
572
|
};
|
|
551
573
|
},
|
|
552
|
-
notifyPathSubscribers: (
|
|
553
|
-
const
|
|
554
|
-
|
|
574
|
+
notifyPathSubscribers: (t, e) => {
|
|
575
|
+
const a = o().pathSubscribers.get(t);
|
|
576
|
+
a && a.forEach((s) => s(e));
|
|
555
577
|
},
|
|
556
578
|
selectedIndicesMap: /* @__PURE__ */ new Map(),
|
|
557
|
-
getSelectedIndex: (
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
), s =
|
|
564
|
-
return s ? s.indexOf(
|
|
579
|
+
getSelectedIndex: (t, e) => {
|
|
580
|
+
const n = o().selectedIndicesMap.get(t);
|
|
581
|
+
if (!n) return -1;
|
|
582
|
+
const a = o().getShadowMetadata(
|
|
583
|
+
t.split(".")[0],
|
|
584
|
+
t.split(".").slice(1)
|
|
585
|
+
), s = e || a?.arrayKeys;
|
|
586
|
+
return s ? s.indexOf(n) : -1;
|
|
565
587
|
},
|
|
566
|
-
setSelectedIndex: (
|
|
567
|
-
|
|
568
|
-
const
|
|
569
|
-
return
|
|
588
|
+
setSelectedIndex: (t, e) => {
|
|
589
|
+
f((n) => {
|
|
590
|
+
const a = new Map(n.selectedIndicesMap);
|
|
591
|
+
return e === void 0 ? a.delete(t) : (a.has(t) && o().notifyPathSubscribers(a.get(t), {
|
|
570
592
|
type: "THIS_UNSELECTED"
|
|
571
|
-
}),
|
|
572
|
-
...
|
|
573
|
-
selectedIndicesMap:
|
|
593
|
+
}), a.set(t, e), o().notifyPathSubscribers(e, { type: "THIS_SELECTED" })), o().notifyPathSubscribers(t, { type: "GET_SELECTED" }), {
|
|
594
|
+
...n,
|
|
595
|
+
selectedIndicesMap: a
|
|
574
596
|
};
|
|
575
597
|
});
|
|
576
598
|
},
|
|
577
|
-
clearSelectedIndex: ({ arrayKey:
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
return
|
|
599
|
+
clearSelectedIndex: ({ arrayKey: t }) => {
|
|
600
|
+
f((e) => {
|
|
601
|
+
const n = new Map(e.selectedIndicesMap), a = n.get(t);
|
|
602
|
+
return a && o().notifyPathSubscribers(a, {
|
|
581
603
|
type: "CLEAR_SELECTION"
|
|
582
|
-
}),
|
|
604
|
+
}), n.delete(t), o().notifyPathSubscribers(t, {
|
|
583
605
|
type: "CLEAR_SELECTION"
|
|
584
606
|
}), {
|
|
585
|
-
...
|
|
586
|
-
selectedIndicesMap:
|
|
607
|
+
...e,
|
|
608
|
+
selectedIndicesMap: n
|
|
587
609
|
};
|
|
588
610
|
});
|
|
589
611
|
},
|
|
590
|
-
clearSelectedIndexesForState: (
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
let
|
|
594
|
-
for (const s of
|
|
595
|
-
(s ===
|
|
596
|
-
return
|
|
612
|
+
clearSelectedIndexesForState: (t) => {
|
|
613
|
+
f((e) => {
|
|
614
|
+
const n = new Map(e.selectedIndicesMap);
|
|
615
|
+
let a = !1;
|
|
616
|
+
for (const s of n.keys())
|
|
617
|
+
(s === t || s.startsWith(t + ".")) && (n.delete(s), a = !0);
|
|
618
|
+
return a ? { selectedIndicesMap: n } : {};
|
|
597
619
|
});
|
|
598
620
|
},
|
|
599
621
|
initialStateOptions: {},
|
|
600
622
|
stateLog: /* @__PURE__ */ new Map(),
|
|
601
623
|
initialStateGlobal: {},
|
|
602
|
-
addStateLog: (
|
|
603
|
-
!
|
|
604
|
-
const
|
|
605
|
-
for (const s of
|
|
606
|
-
const
|
|
607
|
-
|
|
624
|
+
addStateLog: (t) => {
|
|
625
|
+
!t || t.length === 0 || f((e) => {
|
|
626
|
+
const n = new Map(e.stateLog), a = /* @__PURE__ */ new Map();
|
|
627
|
+
for (const s of t) {
|
|
628
|
+
const i = a.get(s.stateKey) || [];
|
|
629
|
+
i.push(s), a.set(s.stateKey, i);
|
|
608
630
|
}
|
|
609
|
-
for (const [s,
|
|
610
|
-
const
|
|
611
|
-
for (const
|
|
612
|
-
|
|
613
|
-
|
|
631
|
+
for (const [s, i] of a.entries()) {
|
|
632
|
+
const r = new Map(n.get(s));
|
|
633
|
+
for (const u of i)
|
|
634
|
+
r.set(JSON.stringify(u.path), { ...u });
|
|
635
|
+
n.set(s, r);
|
|
614
636
|
}
|
|
615
|
-
return { stateLog:
|
|
637
|
+
return { stateLog: n };
|
|
616
638
|
});
|
|
617
639
|
},
|
|
618
|
-
getInitialOptions: (
|
|
619
|
-
setInitialStateOptions: (
|
|
620
|
-
|
|
621
|
-
initialStateOptions: { ...
|
|
640
|
+
getInitialOptions: (t) => o().initialStateOptions[t],
|
|
641
|
+
setInitialStateOptions: (t, e) => {
|
|
642
|
+
f((n) => ({
|
|
643
|
+
initialStateOptions: { ...n.initialStateOptions, [t]: e }
|
|
622
644
|
}));
|
|
623
645
|
},
|
|
624
|
-
updateInitialStateGlobal: (
|
|
625
|
-
|
|
626
|
-
initialStateGlobal: { ...
|
|
646
|
+
updateInitialStateGlobal: (t, e) => {
|
|
647
|
+
f((n) => ({
|
|
648
|
+
initialStateGlobal: { ...n.initialStateGlobal, [t]: e }
|
|
627
649
|
}));
|
|
628
650
|
},
|
|
629
651
|
syncInfoStore: /* @__PURE__ */ new Map(),
|
|
630
|
-
setSyncInfo: (
|
|
631
|
-
const
|
|
632
|
-
return
|
|
652
|
+
setSyncInfo: (t, e) => f((n) => {
|
|
653
|
+
const a = new Map(n.syncInfoStore);
|
|
654
|
+
return a.set(t, e), { syncInfoStore: a };
|
|
633
655
|
}),
|
|
634
|
-
getSyncInfo: (
|
|
656
|
+
getSyncInfo: (t) => o().syncInfoStore.get(t) || null
|
|
635
657
|
}));
|
|
658
|
+
function P(f) {
|
|
659
|
+
const o = [], t = b.get(f) || b.get(`[${f}`);
|
|
660
|
+
if (!t) return o;
|
|
661
|
+
const e = (n) => {
|
|
662
|
+
if (!(!n || typeof n != "object")) {
|
|
663
|
+
n._meta?.clientActivityState?.elements && n._meta.clientActivityState.elements.forEach((a) => {
|
|
664
|
+
a.domRef?.current && o.push(a.domRef.current);
|
|
665
|
+
});
|
|
666
|
+
for (const a in n)
|
|
667
|
+
a !== "_meta" && e(n[a]);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
return e(t), o;
|
|
671
|
+
}
|
|
672
|
+
function R(f, o) {
|
|
673
|
+
const t = b.get(f) || b.get(`[${f}`);
|
|
674
|
+
if (!t) return;
|
|
675
|
+
const e = (n) => {
|
|
676
|
+
if (!(!n || typeof n != "object")) {
|
|
677
|
+
n._meta?.clientActivityState?.elements && n._meta.clientActivityState.elements.forEach((a) => {
|
|
678
|
+
const s = a.domRef?.current;
|
|
679
|
+
s && ("disabled" in s ? s.disabled = o : (s.style.pointerEvents = o ? "none" : "", s.setAttribute("aria-disabled", String(o))));
|
|
680
|
+
});
|
|
681
|
+
for (const a in n)
|
|
682
|
+
a !== "_meta" && e(n[a]);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
e(t);
|
|
686
|
+
}
|
|
636
687
|
export {
|
|
637
688
|
_ as buildShadowNode,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
689
|
+
w as generateId,
|
|
690
|
+
P as getAllFieldElements,
|
|
691
|
+
C as getGlobalStore,
|
|
692
|
+
R as setAllFieldsDisabled,
|
|
693
|
+
b as shadowStateStore,
|
|
694
|
+
j as updateShadowTypeInfo
|
|
642
695
|
};
|
|
643
696
|
//# sourceMappingURL=store.js.map
|