@stonecrop/stonecrop 0.8.13 → 0.9.0
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/stonecrop.d.ts +20 -3063
- package/dist/stonecrop.js +865 -1179
- package/dist/stonecrop.js.map +1 -1
- package/package.json +17 -18
- package/dist/stonecrop.umd.cjs +0 -6
- package/dist/stonecrop.umd.cjs.map +0 -1
- /package/dist/{src/tsdoc-metadata.json → tsdoc-metadata.json} +0 -0
package/dist/stonecrop.js
CHANGED
|
@@ -1,563 +1,249 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const me = (n) => G = n;
|
|
5
|
-
process.env.NODE_ENV;
|
|
6
|
-
const Pe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
|
|
7
|
-
/* istanbul ignore next */
|
|
8
|
-
/* @__PURE__ */ Symbol()
|
|
9
|
-
);
|
|
10
|
-
function Y(n) {
|
|
11
|
-
return n && typeof n == "object" && Object.prototype.toString.call(n) === "[object Object]" && typeof n.toJSON != "function";
|
|
12
|
-
}
|
|
13
|
-
var le;
|
|
14
|
-
(function(n) {
|
|
15
|
-
n.direct = "direct", n.patchObject = "patch object", n.patchFunction = "patch function";
|
|
16
|
-
})(le || (le = {}));
|
|
17
|
-
function He(n, e) {
|
|
18
|
-
for (const t in e) {
|
|
19
|
-
const r = e[t];
|
|
20
|
-
if (!(t in n))
|
|
21
|
-
continue;
|
|
22
|
-
const o = n[t];
|
|
23
|
-
Y(o) && Y(r) && !se(r) && !be(r) ? n[t] = He(o, r) : n[t] = r;
|
|
24
|
-
}
|
|
25
|
-
return n;
|
|
26
|
-
}
|
|
27
|
-
const ze = () => {
|
|
28
|
-
};
|
|
29
|
-
function Te(n, e, t, r = ze) {
|
|
30
|
-
n.add(e);
|
|
31
|
-
const o = () => {
|
|
32
|
-
n.delete(e) && r();
|
|
33
|
-
};
|
|
34
|
-
return !t && Xe() && et(o), o;
|
|
35
|
-
}
|
|
36
|
-
function ee(n, ...e) {
|
|
37
|
-
n.forEach((t) => {
|
|
38
|
-
t(...e);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
const nt = (n) => n(), Ie = /* @__PURE__ */ Symbol(), Ee = /* @__PURE__ */ Symbol();
|
|
42
|
-
function Ne(n, e) {
|
|
43
|
-
n instanceof Map && e instanceof Map ? e.forEach((t, r) => n.set(r, t)) : n instanceof Set && e instanceof Set && e.forEach(n.add, n);
|
|
44
|
-
for (const t in e) {
|
|
45
|
-
if (!e.hasOwnProperty(t))
|
|
46
|
-
continue;
|
|
47
|
-
const r = e[t], o = n[t];
|
|
48
|
-
Y(o) && Y(r) && n.hasOwnProperty(t) && !se(r) && !be(r) ? n[t] = Ne(o, r) : n[t] = r;
|
|
49
|
-
}
|
|
50
|
-
return n;
|
|
51
|
-
}
|
|
52
|
-
const ot = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
|
|
53
|
-
/* istanbul ignore next */
|
|
54
|
-
/* @__PURE__ */ Symbol()
|
|
55
|
-
);
|
|
56
|
-
function st(n) {
|
|
57
|
-
return !Y(n) || !Object.prototype.hasOwnProperty.call(n, ot);
|
|
58
|
-
}
|
|
59
|
-
const { assign: z } = Object;
|
|
60
|
-
function Ce(n) {
|
|
61
|
-
return !!(se(n) && n.effect);
|
|
62
|
-
}
|
|
63
|
-
function ke(n, e, t, r) {
|
|
64
|
-
const { state: o, actions: s, getters: i } = e, a = t.state.value[n];
|
|
65
|
-
let c;
|
|
66
|
-
function f() {
|
|
67
|
-
!a && (process.env.NODE_ENV === "production" || !r) && (t.state.value[n] = o ? o() : {});
|
|
68
|
-
const g = process.env.NODE_ENV !== "production" && r ? (
|
|
69
|
-
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
70
|
-
$e(B(o ? o() : {}).value)
|
|
71
|
-
) : $e(t.state.value[n]);
|
|
72
|
-
return z(g, s, Object.keys(i || {}).reduce((b, A) => (process.env.NODE_ENV !== "production" && A in g && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${A}" in store "${n}".`), b[A] = ae(W(() => {
|
|
73
|
-
me(t);
|
|
74
|
-
const $ = t._s.get(n);
|
|
75
|
-
return i[A].call($, $);
|
|
76
|
-
})), b), {}));
|
|
77
|
-
}
|
|
78
|
-
return c = _e(n, f, e, t, r, !0), c;
|
|
79
|
-
}
|
|
80
|
-
function _e(n, e, t = {}, r, o, s) {
|
|
81
|
-
let i;
|
|
82
|
-
const a = z({ actions: {} }, t);
|
|
83
|
-
if (process.env.NODE_ENV !== "production" && !r._e.active)
|
|
84
|
-
throw new Error("Pinia destroyed");
|
|
85
|
-
const c = { deep: !0 };
|
|
86
|
-
process.env.NODE_ENV !== "production" && (c.onTrigger = (d) => {
|
|
87
|
-
f ? $ = d : f == !1 && !v._hotUpdating && (Array.isArray($) ? $.push(d) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
88
|
-
});
|
|
89
|
-
let f, g, b = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Set(), $;
|
|
90
|
-
const k = r.state.value[n];
|
|
91
|
-
!s && !k && (process.env.NODE_ENV === "production" || !o) && (r.state.value[n] = {});
|
|
92
|
-
const x = B({});
|
|
93
|
-
let N;
|
|
94
|
-
function D(d) {
|
|
95
|
-
let p;
|
|
96
|
-
f = g = !1, process.env.NODE_ENV !== "production" && ($ = []), typeof d == "function" ? (d(r.state.value[n]), p = {
|
|
97
|
-
type: le.patchFunction,
|
|
98
|
-
storeId: n,
|
|
99
|
-
events: $
|
|
100
|
-
}) : (Ne(r.state.value[n], d), p = {
|
|
101
|
-
type: le.patchObject,
|
|
102
|
-
payload: d,
|
|
103
|
-
storeId: n,
|
|
104
|
-
events: $
|
|
105
|
-
});
|
|
106
|
-
const R = N = /* @__PURE__ */ Symbol();
|
|
107
|
-
de().then(() => {
|
|
108
|
-
N === R && (f = !0);
|
|
109
|
-
}), g = !0, ee(b, p, r.state.value[n]);
|
|
110
|
-
}
|
|
111
|
-
const P = s ? function() {
|
|
112
|
-
const { state: p } = t, R = p ? p() : {};
|
|
113
|
-
this.$patch((F) => {
|
|
114
|
-
z(F, R);
|
|
115
|
-
});
|
|
116
|
-
} : (
|
|
117
|
-
/* istanbul ignore next */
|
|
118
|
-
process.env.NODE_ENV !== "production" ? () => {
|
|
119
|
-
throw new Error(`🍍: Store "${n}" is built using the setup syntax and does not implement $reset().`);
|
|
120
|
-
} : ze
|
|
121
|
-
);
|
|
122
|
-
function S() {
|
|
123
|
-
i.stop(), b.clear(), A.clear(), r._s.delete(n);
|
|
124
|
-
}
|
|
125
|
-
const C = (d, p = "") => {
|
|
126
|
-
if (Ie in d)
|
|
127
|
-
return d[Ee] = p, d;
|
|
128
|
-
const R = function() {
|
|
129
|
-
me(r);
|
|
130
|
-
const F = Array.from(arguments), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set();
|
|
131
|
-
function L(m) {
|
|
132
|
-
w.add(m);
|
|
133
|
-
}
|
|
134
|
-
function y(m) {
|
|
135
|
-
T.add(m);
|
|
136
|
-
}
|
|
137
|
-
ee(A, {
|
|
138
|
-
args: F,
|
|
139
|
-
name: R[Ee],
|
|
140
|
-
store: v,
|
|
141
|
-
after: L,
|
|
142
|
-
onError: y
|
|
143
|
-
});
|
|
144
|
-
let E;
|
|
145
|
-
try {
|
|
146
|
-
E = d.apply(this && this.$id === n ? this : v, F);
|
|
147
|
-
} catch (m) {
|
|
148
|
-
throw ee(T, m), m;
|
|
149
|
-
}
|
|
150
|
-
return E instanceof Promise ? E.then((m) => (ee(w, m), m)).catch((m) => (ee(T, m), Promise.reject(m))) : (ee(w, E), E);
|
|
151
|
-
};
|
|
152
|
-
return R[Ie] = !0, R[Ee] = p, R;
|
|
153
|
-
}, O = /* @__PURE__ */ ae({
|
|
154
|
-
actions: {},
|
|
155
|
-
getters: {},
|
|
156
|
-
state: [],
|
|
157
|
-
hotState: x
|
|
158
|
-
}), _ = {
|
|
159
|
-
_p: r,
|
|
160
|
-
// _s: scope,
|
|
161
|
-
$id: n,
|
|
162
|
-
$onAction: Te.bind(null, A),
|
|
163
|
-
$patch: D,
|
|
164
|
-
$reset: P,
|
|
165
|
-
$subscribe(d, p = {}) {
|
|
166
|
-
const R = Te(b, d, p.detached, () => F()), F = i.run(() => U(() => r.state.value[n], (w) => {
|
|
167
|
-
(p.flush === "sync" ? g : f) && d({
|
|
168
|
-
storeId: n,
|
|
169
|
-
type: le.direct,
|
|
170
|
-
events: $
|
|
171
|
-
}, w);
|
|
172
|
-
}, z({}, c, p)));
|
|
173
|
-
return R;
|
|
174
|
-
},
|
|
175
|
-
$dispose: S
|
|
176
|
-
}, v = ye(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te ? z(
|
|
177
|
-
{
|
|
178
|
-
_hmrPayload: O,
|
|
179
|
-
_customProperties: ae(/* @__PURE__ */ new Set())
|
|
180
|
-
// devtools custom properties
|
|
181
|
-
},
|
|
182
|
-
_
|
|
183
|
-
// must be added later
|
|
184
|
-
// setupStore
|
|
185
|
-
) : _);
|
|
186
|
-
r._s.set(n, v);
|
|
187
|
-
const M = (r._a && r._a.runWithContext || nt)(() => r._e.run(() => (i = Ye()).run(() => e({ action: C }))));
|
|
188
|
-
for (const d in M) {
|
|
189
|
-
const p = M[d];
|
|
190
|
-
if (se(p) && !Ce(p) || be(p))
|
|
191
|
-
process.env.NODE_ENV !== "production" && o ? x.value[d] = ce(M, d) : s || (k && st(p) && (se(p) ? p.value = k[d] : Ne(p, k[d])), r.state.value[n][d] = p), process.env.NODE_ENV !== "production" && O.state.push(d);
|
|
192
|
-
else if (typeof p == "function") {
|
|
193
|
-
const R = process.env.NODE_ENV !== "production" && o ? p : C(p, d);
|
|
194
|
-
M[d] = R, process.env.NODE_ENV !== "production" && (O.actions[d] = p), a.actions[d] = p;
|
|
195
|
-
} else process.env.NODE_ENV !== "production" && Ce(p) && (O.getters[d] = s ? (
|
|
196
|
-
// @ts-expect-error
|
|
197
|
-
t.getters[d]
|
|
198
|
-
) : p, te && (M._getters || // @ts-expect-error: same
|
|
199
|
-
(M._getters = ae([]))).push(d));
|
|
200
|
-
}
|
|
201
|
-
if (z(v, M), z(Me(v), M), Object.defineProperty(v, "$state", {
|
|
202
|
-
get: () => process.env.NODE_ENV !== "production" && o ? x.value : r.state.value[n],
|
|
203
|
-
set: (d) => {
|
|
204
|
-
if (process.env.NODE_ENV !== "production" && o)
|
|
205
|
-
throw new Error("cannot set hotState");
|
|
206
|
-
D((p) => {
|
|
207
|
-
z(p, d);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}), process.env.NODE_ENV !== "production" && (v._hotUpdate = ae((d) => {
|
|
211
|
-
v._hotUpdating = !0, d._hmrPayload.state.forEach((p) => {
|
|
212
|
-
if (p in v.$state) {
|
|
213
|
-
const R = d.$state[p], F = v.$state[p];
|
|
214
|
-
typeof R == "object" && Y(R) && Y(F) ? He(R, F) : d.$state[p] = F;
|
|
215
|
-
}
|
|
216
|
-
v[p] = ce(d.$state, p);
|
|
217
|
-
}), Object.keys(v.$state).forEach((p) => {
|
|
218
|
-
p in d.$state || delete v[p];
|
|
219
|
-
}), f = !1, g = !1, r.state.value[n] = ce(d._hmrPayload, "hotState"), g = !0, de().then(() => {
|
|
220
|
-
f = !0;
|
|
221
|
-
});
|
|
222
|
-
for (const p in d._hmrPayload.actions) {
|
|
223
|
-
const R = d[p];
|
|
224
|
-
v[p] = //
|
|
225
|
-
C(R, p);
|
|
226
|
-
}
|
|
227
|
-
for (const p in d._hmrPayload.getters) {
|
|
228
|
-
const R = d._hmrPayload.getters[p], F = s ? (
|
|
229
|
-
// special handling of options api
|
|
230
|
-
W(() => (me(r), R.call(v, v)))
|
|
231
|
-
) : R;
|
|
232
|
-
v[p] = //
|
|
233
|
-
F;
|
|
234
|
-
}
|
|
235
|
-
Object.keys(v._hmrPayload.getters).forEach((p) => {
|
|
236
|
-
p in d._hmrPayload.getters || delete v[p];
|
|
237
|
-
}), Object.keys(v._hmrPayload.actions).forEach((p) => {
|
|
238
|
-
p in d._hmrPayload.actions || delete v[p];
|
|
239
|
-
}), v._hmrPayload = d._hmrPayload, v._getters = d._getters, v._hotUpdating = !1;
|
|
240
|
-
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te) {
|
|
241
|
-
const d = {
|
|
242
|
-
writable: !0,
|
|
243
|
-
configurable: !0,
|
|
244
|
-
// avoid warning on devtools trying to display this property
|
|
245
|
-
enumerable: !1
|
|
246
|
-
};
|
|
247
|
-
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p) => {
|
|
248
|
-
Object.defineProperty(v, p, z({ value: v[p] }, d));
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return r._p.forEach((d) => {
|
|
252
|
-
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && te) {
|
|
253
|
-
const p = i.run(() => d({
|
|
254
|
-
store: v,
|
|
255
|
-
app: r._a,
|
|
256
|
-
pinia: r,
|
|
257
|
-
options: a
|
|
258
|
-
}));
|
|
259
|
-
Object.keys(p || {}).forEach((R) => v._customProperties.add(R)), z(v, p);
|
|
260
|
-
} else
|
|
261
|
-
z(v, i.run(() => d({
|
|
262
|
-
store: v,
|
|
263
|
-
app: r._a,
|
|
264
|
-
pinia: r,
|
|
265
|
-
options: a
|
|
266
|
-
})));
|
|
267
|
-
}), process.env.NODE_ENV !== "production" && v.$state && typeof v.$state == "object" && typeof v.$state.constructor == "function" && !v.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
268
|
-
state: () => new MyClass()
|
|
269
|
-
Found in store "${v.$id}".`), k && s && t.hydrate && t.hydrate(v.$state, k), f = !0, g = !0, v;
|
|
270
|
-
}
|
|
271
|
-
// @__NO_SIDE_EFFECTS__
|
|
272
|
-
function it(n, e, t) {
|
|
273
|
-
let r;
|
|
274
|
-
const o = typeof e == "function";
|
|
275
|
-
r = o ? t : e;
|
|
276
|
-
function s(i, a) {
|
|
277
|
-
const c = Ae();
|
|
278
|
-
if (i = // in test mode, ignore the argument provided as we can always retrieve a
|
|
279
|
-
// pinia instance with getActivePinia()
|
|
280
|
-
(process.env.NODE_ENV === "test" && G && G._testing ? null : i) || (c ? oe(Pe, null) : null), i && me(i), process.env.NODE_ENV !== "production" && !G)
|
|
281
|
-
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
282
|
-
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
283
|
-
This will fail in production.`);
|
|
284
|
-
i = G, i._s.has(n) || (o ? _e(n, e, r, i) : ke(n, r, i), process.env.NODE_ENV !== "production" && (s._pinia = i));
|
|
285
|
-
const f = i._s.get(n);
|
|
286
|
-
if (process.env.NODE_ENV !== "production" && a) {
|
|
287
|
-
const g = "__hot:" + n, b = o ? _e(g, e, r, i, !0) : ke(g, z({}, r), i, !0);
|
|
288
|
-
a._hotUpdate(b), delete i.state.value[g], i._s.delete(g);
|
|
289
|
-
}
|
|
290
|
-
if (process.env.NODE_ENV !== "production" && te) {
|
|
291
|
-
const g = Fe();
|
|
292
|
-
if (g && g.proxy && // avoid adding stores that are just built for hot module replacement
|
|
293
|
-
!a) {
|
|
294
|
-
const b = g.proxy, A = "_pStores" in b ? b._pStores : b._pStores = {};
|
|
295
|
-
A[n] = f;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return f;
|
|
299
|
-
}
|
|
300
|
-
return s.$id = n, s;
|
|
301
|
-
}
|
|
302
|
-
function Ue(n) {
|
|
303
|
-
const e = Me(n), t = {};
|
|
304
|
-
for (const r in e) {
|
|
305
|
-
const o = e[r];
|
|
306
|
-
o.effect ? t[r] = // ...
|
|
307
|
-
W({
|
|
308
|
-
get: () => n[r],
|
|
309
|
-
set(s) {
|
|
310
|
-
n[r] = s;
|
|
311
|
-
}
|
|
312
|
-
}) : (se(o) || be(o)) && (t[r] = // ---
|
|
313
|
-
ce(n, r));
|
|
314
|
-
}
|
|
315
|
-
return t;
|
|
316
|
-
}
|
|
317
|
-
const at = typeof window < "u" && typeof document < "u";
|
|
1
|
+
import { watch as U, onMounted as me, nextTick as de, readonly as ye, getCurrentInstance as Pe, toRef as Ie, customRef as Ee, ref as L, reactive as ue, computed as B, toValue as H, shallowRef as Se, unref as Ce, inject as fe, provide as pe } from "vue";
|
|
2
|
+
import { defineStore as De, storeToRefs as be } from "pinia";
|
|
3
|
+
const ke = typeof window < "u" && typeof document < "u";
|
|
318
4
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
319
|
-
const
|
|
5
|
+
const Le = Object.prototype.toString, Me = (o) => Le.call(o) === "[object Object]", we = () => {
|
|
320
6
|
};
|
|
321
|
-
function
|
|
322
|
-
if (
|
|
323
|
-
const e =
|
|
324
|
-
return typeof e == "function" ?
|
|
7
|
+
function Fe(...o) {
|
|
8
|
+
if (o.length !== 1) return Ie(...o);
|
|
9
|
+
const e = o[0];
|
|
10
|
+
return typeof e == "function" ? ye(Ee(() => ({
|
|
325
11
|
get: e,
|
|
326
|
-
set:
|
|
327
|
-
}))) :
|
|
12
|
+
set: we
|
|
13
|
+
}))) : L(e);
|
|
328
14
|
}
|
|
329
|
-
function
|
|
15
|
+
function xe(o, e) {
|
|
330
16
|
function t(...r) {
|
|
331
|
-
return new Promise((
|
|
332
|
-
Promise.resolve(
|
|
17
|
+
return new Promise((n, i) => {
|
|
18
|
+
Promise.resolve(o(() => e.apply(this, r), {
|
|
333
19
|
fn: e,
|
|
334
20
|
thisArg: this,
|
|
335
21
|
args: r
|
|
336
|
-
})).then(
|
|
22
|
+
})).then(n).catch(i);
|
|
337
23
|
});
|
|
338
24
|
}
|
|
339
25
|
return t;
|
|
340
26
|
}
|
|
341
|
-
const
|
|
342
|
-
function
|
|
343
|
-
const { initialState: t = "active" } = e, r =
|
|
344
|
-
function
|
|
27
|
+
const Re = (o) => o();
|
|
28
|
+
function Ne(o = Re, e = {}) {
|
|
29
|
+
const { initialState: t = "active" } = e, r = Fe(t === "active");
|
|
30
|
+
function n() {
|
|
345
31
|
r.value = !1;
|
|
346
32
|
}
|
|
347
|
-
function
|
|
33
|
+
function i() {
|
|
348
34
|
r.value = !0;
|
|
349
35
|
}
|
|
350
|
-
const
|
|
351
|
-
r.value &&
|
|
36
|
+
const s = (...a) => {
|
|
37
|
+
r.value && o(...a);
|
|
352
38
|
};
|
|
353
39
|
return {
|
|
354
|
-
isActive:
|
|
355
|
-
pause:
|
|
356
|
-
resume:
|
|
357
|
-
eventFilter:
|
|
40
|
+
isActive: ye(r),
|
|
41
|
+
pause: n,
|
|
42
|
+
resume: i,
|
|
43
|
+
eventFilter: s
|
|
358
44
|
};
|
|
359
45
|
}
|
|
360
|
-
function
|
|
361
|
-
return Array.isArray(
|
|
46
|
+
function ce(o) {
|
|
47
|
+
return Array.isArray(o) ? o : [o];
|
|
362
48
|
}
|
|
363
|
-
function
|
|
364
|
-
return
|
|
49
|
+
function Be(o) {
|
|
50
|
+
return Pe();
|
|
365
51
|
}
|
|
366
|
-
function
|
|
367
|
-
const { eventFilter: r =
|
|
368
|
-
return U(
|
|
52
|
+
function _e(o, e, t = {}) {
|
|
53
|
+
const { eventFilter: r = Re, ...n } = t;
|
|
54
|
+
return U(o, xe(r, e), n);
|
|
369
55
|
}
|
|
370
|
-
function
|
|
371
|
-
const { eventFilter: r, initialState:
|
|
56
|
+
function Ve(o, e, t = {}) {
|
|
57
|
+
const { eventFilter: r, initialState: n = "active", ...i } = t, { eventFilter: s, pause: a, resume: c, isActive: d } = Ne(r, { initialState: n });
|
|
372
58
|
return {
|
|
373
|
-
stop:
|
|
374
|
-
...
|
|
375
|
-
eventFilter:
|
|
59
|
+
stop: _e(o, e, {
|
|
60
|
+
...i,
|
|
61
|
+
eventFilter: s
|
|
376
62
|
}),
|
|
377
63
|
pause: a,
|
|
378
64
|
resume: c,
|
|
379
|
-
isActive:
|
|
65
|
+
isActive: d
|
|
380
66
|
};
|
|
381
67
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
68
|
+
function We(o, e = !0, t) {
|
|
69
|
+
Be() ? me(o, t) : e ? o() : de(o);
|
|
384
70
|
}
|
|
385
|
-
function
|
|
386
|
-
return U(
|
|
71
|
+
function ze(o, e, t) {
|
|
72
|
+
return U(o, e, {
|
|
387
73
|
...t,
|
|
388
74
|
immediate: !0
|
|
389
75
|
});
|
|
390
76
|
}
|
|
391
|
-
function
|
|
392
|
-
return U(
|
|
393
|
-
|
|
77
|
+
function X(o, e, t) {
|
|
78
|
+
return U(o, (n, i, s) => {
|
|
79
|
+
n && e(n, i, s);
|
|
394
80
|
}, {
|
|
395
81
|
...t,
|
|
396
82
|
once: !1
|
|
397
83
|
});
|
|
398
84
|
}
|
|
399
|
-
const
|
|
400
|
-
function
|
|
85
|
+
const j = ke ? window : void 0;
|
|
86
|
+
function He(o) {
|
|
401
87
|
var e;
|
|
402
|
-
const t =
|
|
88
|
+
const t = H(o);
|
|
403
89
|
return (e = t?.$el) !== null && e !== void 0 ? e : t;
|
|
404
90
|
}
|
|
405
|
-
function
|
|
406
|
-
const e = (r,
|
|
407
|
-
const r =
|
|
408
|
-
return r.every((
|
|
91
|
+
function Q(...o) {
|
|
92
|
+
const e = (r, n, i, s) => (r.addEventListener(n, i, s), () => r.removeEventListener(n, i, s)), t = B(() => {
|
|
93
|
+
const r = ce(H(o[0])).filter((n) => n != null);
|
|
94
|
+
return r.every((n) => typeof n != "string") ? r : void 0;
|
|
409
95
|
});
|
|
410
|
-
return
|
|
411
|
-
var r,
|
|
96
|
+
return ze(() => {
|
|
97
|
+
var r, n;
|
|
412
98
|
return [
|
|
413
|
-
(r = (
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
99
|
+
(r = (n = t.value) === null || n === void 0 ? void 0 : n.map((i) => He(i))) !== null && r !== void 0 ? r : [j].filter((i) => i != null),
|
|
100
|
+
ce(H(t.value ? o[1] : o[0])),
|
|
101
|
+
ce(Ce(t.value ? o[2] : o[1])),
|
|
102
|
+
H(t.value ? o[3] : o[2])
|
|
417
103
|
];
|
|
418
|
-
}, ([r,
|
|
419
|
-
if (!r?.length || !
|
|
420
|
-
const
|
|
104
|
+
}, ([r, n, i, s], a, c) => {
|
|
105
|
+
if (!r?.length || !n?.length || !i?.length) return;
|
|
106
|
+
const d = Me(s) ? { ...s } : s, g = r.flatMap((S) => n.flatMap(($) => i.map((k) => e(S, $, k, d))));
|
|
421
107
|
c(() => {
|
|
422
|
-
g.forEach((
|
|
108
|
+
g.forEach((S) => S());
|
|
423
109
|
});
|
|
424
110
|
}, { flush: "post" });
|
|
425
111
|
}
|
|
426
|
-
const
|
|
427
|
-
function
|
|
428
|
-
return
|
|
112
|
+
const ne = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, oe = "__vueuse_ssr_handlers__", Ue = /* @__PURE__ */ Je();
|
|
113
|
+
function Je() {
|
|
114
|
+
return oe in ne || (ne[oe] = ne[oe] || {}), ne[oe];
|
|
429
115
|
}
|
|
430
|
-
function
|
|
431
|
-
return
|
|
116
|
+
function qe(o, e) {
|
|
117
|
+
return Ue[o] || e;
|
|
432
118
|
}
|
|
433
|
-
function
|
|
434
|
-
return
|
|
119
|
+
function Ke(o) {
|
|
120
|
+
return o == null ? "any" : o instanceof Set ? "set" : o instanceof Map ? "map" : o instanceof Date ? "date" : typeof o == "boolean" ? "boolean" : typeof o == "string" ? "string" : typeof o == "object" ? "object" : Number.isNaN(o) ? "any" : "number";
|
|
435
121
|
}
|
|
436
|
-
const
|
|
122
|
+
const je = {
|
|
437
123
|
boolean: {
|
|
438
|
-
read: (
|
|
439
|
-
write: (
|
|
124
|
+
read: (o) => o === "true",
|
|
125
|
+
write: (o) => String(o)
|
|
440
126
|
},
|
|
441
127
|
object: {
|
|
442
|
-
read: (
|
|
443
|
-
write: (
|
|
128
|
+
read: (o) => JSON.parse(o),
|
|
129
|
+
write: (o) => JSON.stringify(o)
|
|
444
130
|
},
|
|
445
131
|
number: {
|
|
446
|
-
read: (
|
|
447
|
-
write: (
|
|
132
|
+
read: (o) => Number.parseFloat(o),
|
|
133
|
+
write: (o) => String(o)
|
|
448
134
|
},
|
|
449
135
|
any: {
|
|
450
|
-
read: (
|
|
451
|
-
write: (
|
|
136
|
+
read: (o) => o,
|
|
137
|
+
write: (o) => String(o)
|
|
452
138
|
},
|
|
453
139
|
string: {
|
|
454
|
-
read: (
|
|
455
|
-
write: (
|
|
140
|
+
read: (o) => o,
|
|
141
|
+
write: (o) => String(o)
|
|
456
142
|
},
|
|
457
143
|
map: {
|
|
458
|
-
read: (
|
|
459
|
-
write: (
|
|
144
|
+
read: (o) => new Map(JSON.parse(o)),
|
|
145
|
+
write: (o) => JSON.stringify(Array.from(o.entries()))
|
|
460
146
|
},
|
|
461
147
|
set: {
|
|
462
|
-
read: (
|
|
463
|
-
write: (
|
|
148
|
+
read: (o) => new Set(JSON.parse(o)),
|
|
149
|
+
write: (o) => JSON.stringify(Array.from(o))
|
|
464
150
|
},
|
|
465
151
|
date: {
|
|
466
|
-
read: (
|
|
467
|
-
write: (
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
function
|
|
471
|
-
var
|
|
472
|
-
const { flush:
|
|
473
|
-
console.error(
|
|
474
|
-
}, initOnMounted:
|
|
152
|
+
read: (o) => new Date(o),
|
|
153
|
+
write: (o) => o.toISOString()
|
|
154
|
+
}
|
|
155
|
+
}, he = "vueuse-storage";
|
|
156
|
+
function Ge(o, e, t, r = {}) {
|
|
157
|
+
var n;
|
|
158
|
+
const { flush: i = "pre", deep: s = !0, listenToStorageChanges: a = !0, writeDefaults: c = !0, mergeDefaults: d = !1, shallow: g, window: S = j, eventFilter: $, onError: k = (v) => {
|
|
159
|
+
console.error(v);
|
|
160
|
+
}, initOnMounted: x } = r, F = (g ? Se : L)(e), R = B(() => H(o));
|
|
475
161
|
if (!t) try {
|
|
476
|
-
t =
|
|
477
|
-
} catch (
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
if (!t) return
|
|
481
|
-
const
|
|
482
|
-
flush:
|
|
483
|
-
deep:
|
|
484
|
-
eventFilter:
|
|
162
|
+
t = qe("getDefaultStorage", () => j?.localStorage)();
|
|
163
|
+
} catch (v) {
|
|
164
|
+
k(v);
|
|
165
|
+
}
|
|
166
|
+
if (!t) return F;
|
|
167
|
+
const O = H(e), w = Ke(O), h = (n = r.serializer) !== null && n !== void 0 ? n : je[w], { pause: E, resume: b } = Ve(F, (v) => N(v), {
|
|
168
|
+
flush: i,
|
|
169
|
+
deep: s,
|
|
170
|
+
eventFilter: $
|
|
485
171
|
});
|
|
486
|
-
U(
|
|
487
|
-
let
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
},
|
|
491
|
-
|
|
172
|
+
U(R, () => _(), { flush: i });
|
|
173
|
+
let A = !1;
|
|
174
|
+
const C = (v) => {
|
|
175
|
+
x && !A || _(v);
|
|
176
|
+
}, M = (v) => {
|
|
177
|
+
x && !A || G(v);
|
|
492
178
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}) :
|
|
496
|
-
function
|
|
497
|
-
if (
|
|
498
|
-
const
|
|
499
|
-
key:
|
|
500
|
-
oldValue:
|
|
501
|
-
newValue:
|
|
179
|
+
S && a && (t instanceof Storage ? Q(S, "storage", C, { passive: !0 }) : Q(S, he, M)), x ? We(() => {
|
|
180
|
+
A = !0, _();
|
|
181
|
+
}) : _();
|
|
182
|
+
function W(v, P) {
|
|
183
|
+
if (S) {
|
|
184
|
+
const D = {
|
|
185
|
+
key: R.value,
|
|
186
|
+
oldValue: v,
|
|
187
|
+
newValue: P,
|
|
502
188
|
storageArea: t
|
|
503
189
|
};
|
|
504
|
-
|
|
190
|
+
S.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", D) : new CustomEvent(he, { detail: D }));
|
|
505
191
|
}
|
|
506
192
|
}
|
|
507
|
-
function
|
|
193
|
+
function N(v) {
|
|
508
194
|
try {
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
|
|
195
|
+
const P = t.getItem(R.value);
|
|
196
|
+
if (v == null)
|
|
197
|
+
W(P, null), t.removeItem(R.value);
|
|
512
198
|
else {
|
|
513
|
-
const
|
|
514
|
-
|
|
199
|
+
const D = h.write(v);
|
|
200
|
+
P !== D && (t.setItem(R.value, D), W(P, D));
|
|
515
201
|
}
|
|
516
|
-
} catch (
|
|
517
|
-
|
|
202
|
+
} catch (P) {
|
|
203
|
+
k(P);
|
|
518
204
|
}
|
|
519
205
|
}
|
|
520
|
-
function
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
return c &&
|
|
524
|
-
if (!
|
|
525
|
-
const
|
|
526
|
-
return typeof
|
|
527
|
-
...
|
|
528
|
-
...
|
|
529
|
-
} :
|
|
530
|
-
} else return typeof
|
|
531
|
-
}
|
|
532
|
-
function
|
|
533
|
-
if (!(
|
|
534
|
-
if (
|
|
535
|
-
|
|
206
|
+
function q(v) {
|
|
207
|
+
const P = v ? v.newValue : t.getItem(R.value);
|
|
208
|
+
if (P == null)
|
|
209
|
+
return c && O != null && t.setItem(R.value, h.write(O)), O;
|
|
210
|
+
if (!v && d) {
|
|
211
|
+
const D = h.read(P);
|
|
212
|
+
return typeof d == "function" ? d(D, O) : w === "object" && !Array.isArray(D) ? {
|
|
213
|
+
...O,
|
|
214
|
+
...D
|
|
215
|
+
} : D;
|
|
216
|
+
} else return typeof P != "string" ? P : h.read(P);
|
|
217
|
+
}
|
|
218
|
+
function _(v) {
|
|
219
|
+
if (!(v && v.storageArea !== t)) {
|
|
220
|
+
if (v && v.key == null) {
|
|
221
|
+
F.value = O;
|
|
536
222
|
return;
|
|
537
223
|
}
|
|
538
|
-
if (!(
|
|
539
|
-
|
|
224
|
+
if (!(v && v.key !== R.value)) {
|
|
225
|
+
E();
|
|
540
226
|
try {
|
|
541
|
-
const
|
|
542
|
-
(
|
|
543
|
-
} catch (
|
|
544
|
-
|
|
227
|
+
const P = h.write(F.value);
|
|
228
|
+
(v === void 0 || v?.newValue !== P) && (F.value = q(v));
|
|
229
|
+
} catch (P) {
|
|
230
|
+
k(P);
|
|
545
231
|
} finally {
|
|
546
|
-
|
|
232
|
+
v ? de(b) : b();
|
|
547
233
|
}
|
|
548
234
|
}
|
|
549
235
|
}
|
|
550
236
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
237
|
+
function G(v) {
|
|
238
|
+
_(v.detail);
|
|
553
239
|
}
|
|
554
|
-
return
|
|
240
|
+
return F;
|
|
555
241
|
}
|
|
556
|
-
function
|
|
557
|
-
const { window: r =
|
|
558
|
-
return
|
|
242
|
+
function Ze(o, e, t = {}) {
|
|
243
|
+
const { window: r = j } = t;
|
|
244
|
+
return Ge(o, e, r?.localStorage, t);
|
|
559
245
|
}
|
|
560
|
-
const
|
|
246
|
+
const Qe = {
|
|
561
247
|
ctrl: "control",
|
|
562
248
|
command: "meta",
|
|
563
249
|
cmd: "meta",
|
|
@@ -567,143 +253,143 @@ const Pt = {
|
|
|
567
253
|
left: "arrowleft",
|
|
568
254
|
right: "arrowright"
|
|
569
255
|
};
|
|
570
|
-
function
|
|
571
|
-
const { reactive: e = !1, target: t =
|
|
256
|
+
function Ye(o = {}) {
|
|
257
|
+
const { reactive: e = !1, target: t = j, aliasMap: r = Qe, passive: n = !0, onEventFired: i = we } = o, s = ue(/* @__PURE__ */ new Set()), a = {
|
|
572
258
|
toJSON() {
|
|
573
259
|
return {};
|
|
574
260
|
},
|
|
575
|
-
current:
|
|
576
|
-
}, c = e ?
|
|
577
|
-
["Meta",
|
|
261
|
+
current: s
|
|
262
|
+
}, c = e ? ue(a) : a, d = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map([
|
|
263
|
+
["Meta", d],
|
|
578
264
|
["Shift", /* @__PURE__ */ new Set()],
|
|
579
265
|
["Alt", /* @__PURE__ */ new Set()]
|
|
580
|
-
]),
|
|
581
|
-
function
|
|
582
|
-
|
|
266
|
+
]), S = /* @__PURE__ */ new Set();
|
|
267
|
+
function $(w, h) {
|
|
268
|
+
w in c && (e ? c[w] = h : c[w].value = h);
|
|
583
269
|
}
|
|
584
|
-
function
|
|
585
|
-
|
|
586
|
-
for (const
|
|
270
|
+
function k() {
|
|
271
|
+
s.clear();
|
|
272
|
+
for (const w of S) $(w, !1);
|
|
587
273
|
}
|
|
588
|
-
function
|
|
589
|
-
if (!(!
|
|
590
|
-
for (const [
|
|
591
|
-
|
|
274
|
+
function x(w, h, E) {
|
|
275
|
+
if (!(!w || typeof h.getModifierState != "function")) {
|
|
276
|
+
for (const [b, A] of g) if (h.getModifierState(b)) {
|
|
277
|
+
E.forEach((C) => A.add(C));
|
|
592
278
|
break;
|
|
593
279
|
}
|
|
594
280
|
}
|
|
595
281
|
}
|
|
596
|
-
function
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
if (!["shift", "alt"].includes(
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}),
|
|
604
|
-
}
|
|
605
|
-
function
|
|
606
|
-
var
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
for (const
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}),
|
|
282
|
+
function F(w, h) {
|
|
283
|
+
if (w) return;
|
|
284
|
+
const E = `${h[0].toUpperCase()}${h.slice(1)}`, b = g.get(E);
|
|
285
|
+
if (!["shift", "alt"].includes(h) || !b) return;
|
|
286
|
+
const A = Array.from(b), C = A.indexOf(h);
|
|
287
|
+
A.forEach((M, W) => {
|
|
288
|
+
W >= C && (s.delete(M), $(M, !1));
|
|
289
|
+
}), b.clear();
|
|
290
|
+
}
|
|
291
|
+
function R(w, h) {
|
|
292
|
+
var E, b;
|
|
293
|
+
const A = (E = w.key) === null || E === void 0 ? void 0 : E.toLowerCase(), C = [(b = w.code) === null || b === void 0 ? void 0 : b.toLowerCase(), A].filter(Boolean);
|
|
294
|
+
if (A) {
|
|
295
|
+
A && (h ? s.add(A) : s.delete(A));
|
|
296
|
+
for (const M of C)
|
|
297
|
+
S.add(M), $(M, h);
|
|
298
|
+
x(h, w, [...s, ...C]), F(h, A), A === "meta" && !h && (d.forEach((M) => {
|
|
299
|
+
s.delete(M), $(M, !1);
|
|
300
|
+
}), d.clear());
|
|
615
301
|
}
|
|
616
302
|
}
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
if (typeof
|
|
620
|
-
if (
|
|
621
|
-
const
|
|
622
|
-
c[
|
|
623
|
-
} else c[
|
|
624
|
-
const
|
|
625
|
-
return e ?
|
|
303
|
+
Q(t, "keydown", (w) => (R(w, !0), i(w)), { passive: n }), Q(t, "keyup", (w) => (R(w, !1), i(w)), { passive: n }), Q("blur", k, { passive: n }), Q("focus", k, { passive: n });
|
|
304
|
+
const O = new Proxy(c, { get(w, h, E) {
|
|
305
|
+
if (typeof h != "string") return Reflect.get(w, h, E);
|
|
306
|
+
if (h = h.toLowerCase(), h in r && (h = r[h]), !(h in c)) if (/[+_-]/.test(h)) {
|
|
307
|
+
const A = h.split(/[+_-]/g).map((C) => C.trim());
|
|
308
|
+
c[h] = B(() => A.map((C) => H(O[C])).every(Boolean));
|
|
309
|
+
} else c[h] = Se(!1);
|
|
310
|
+
const b = Reflect.get(w, h, E);
|
|
311
|
+
return e ? H(b) : b;
|
|
626
312
|
} });
|
|
627
|
-
return
|
|
313
|
+
return O;
|
|
628
314
|
}
|
|
629
|
-
function
|
|
315
|
+
function le() {
|
|
630
316
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
631
317
|
}
|
|
632
|
-
function
|
|
318
|
+
function ie(o) {
|
|
633
319
|
const e = {
|
|
634
|
-
type:
|
|
635
|
-
clientId:
|
|
636
|
-
timestamp:
|
|
320
|
+
type: o.type,
|
|
321
|
+
clientId: o.clientId,
|
|
322
|
+
timestamp: o.timestamp.toISOString()
|
|
637
323
|
};
|
|
638
|
-
return
|
|
639
|
-
...
|
|
640
|
-
timestamp:
|
|
641
|
-
}),
|
|
324
|
+
return o.operation && (e.operation = {
|
|
325
|
+
...o.operation,
|
|
326
|
+
timestamp: o.operation.timestamp.toISOString()
|
|
327
|
+
}), o.operations && (e.operations = o.operations.map((t) => ({
|
|
642
328
|
...t,
|
|
643
329
|
timestamp: t.timestamp.toISOString()
|
|
644
330
|
}))), e;
|
|
645
331
|
}
|
|
646
|
-
function
|
|
332
|
+
function Xe(o) {
|
|
647
333
|
const e = {
|
|
648
|
-
type:
|
|
649
|
-
clientId:
|
|
650
|
-
timestamp: new Date(
|
|
334
|
+
type: o.type,
|
|
335
|
+
clientId: o.clientId,
|
|
336
|
+
timestamp: new Date(o.timestamp)
|
|
651
337
|
};
|
|
652
|
-
return
|
|
653
|
-
...
|
|
654
|
-
timestamp: new Date(
|
|
655
|
-
}),
|
|
338
|
+
return o.operation && (e.operation = {
|
|
339
|
+
...o.operation,
|
|
340
|
+
timestamp: new Date(o.operation.timestamp)
|
|
341
|
+
}), o.operations && (e.operations = o.operations.map((t) => ({
|
|
656
342
|
...t,
|
|
657
343
|
timestamp: new Date(t.timestamp)
|
|
658
344
|
}))), e;
|
|
659
345
|
}
|
|
660
|
-
const
|
|
661
|
-
const
|
|
346
|
+
const re = De("hst-operation-log", () => {
|
|
347
|
+
const o = L({
|
|
662
348
|
maxOperations: 100,
|
|
663
349
|
enableCrossTabSync: !0,
|
|
664
350
|
autoSyncInterval: 3e4,
|
|
665
351
|
enablePersistence: !1,
|
|
666
352
|
persistenceKeyPrefix: "stonecrop-ops"
|
|
667
|
-
}), e =
|
|
353
|
+
}), e = L([]), t = L(-1), r = L(le()), n = L(!1), i = L([]), s = L(null), a = B(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), c = B(() => t.value < e.value.length - 1), d = B(() => {
|
|
668
354
|
let u = 0;
|
|
669
355
|
for (let l = t.value; l >= 0 && e.value[l]?.reversible; l--)
|
|
670
356
|
u++;
|
|
671
357
|
return u;
|
|
672
|
-
}), g =
|
|
358
|
+
}), g = B(() => e.value.length - 1 - t.value), S = B(() => ({
|
|
673
359
|
canUndo: a.value,
|
|
674
360
|
canRedo: c.value,
|
|
675
|
-
undoCount:
|
|
361
|
+
undoCount: d.value,
|
|
676
362
|
redoCount: g.value,
|
|
677
363
|
currentIndex: t.value
|
|
678
364
|
}));
|
|
679
|
-
function
|
|
680
|
-
|
|
365
|
+
function $(u) {
|
|
366
|
+
o.value = { ...o.value, ...u }, o.value.enablePersistence && (p(), y()), o.value.enableCrossTabSync && q();
|
|
681
367
|
}
|
|
682
|
-
function
|
|
683
|
-
const
|
|
368
|
+
function k(u, l = "user") {
|
|
369
|
+
const f = {
|
|
684
370
|
...u,
|
|
685
|
-
id:
|
|
371
|
+
id: le(),
|
|
686
372
|
timestamp: /* @__PURE__ */ new Date(),
|
|
687
373
|
source: l,
|
|
688
|
-
userId:
|
|
374
|
+
userId: o.value.userId
|
|
689
375
|
};
|
|
690
|
-
if (
|
|
691
|
-
return
|
|
692
|
-
if (
|
|
693
|
-
return
|
|
694
|
-
if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(
|
|
695
|
-
const
|
|
696
|
-
e.value = e.value.slice(
|
|
376
|
+
if (o.value.operationFilter && !o.value.operationFilter(f))
|
|
377
|
+
return f.id;
|
|
378
|
+
if (n.value)
|
|
379
|
+
return i.value.push(f), f.id;
|
|
380
|
+
if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(f), t.value++, o.value.maxOperations && e.value.length > o.value.maxOperations) {
|
|
381
|
+
const T = e.value.length - o.value.maxOperations;
|
|
382
|
+
e.value = e.value.slice(T), t.value -= T;
|
|
697
383
|
}
|
|
698
|
-
return
|
|
384
|
+
return o.value.enableCrossTabSync && _(f), f.id;
|
|
699
385
|
}
|
|
700
|
-
function
|
|
701
|
-
|
|
386
|
+
function x() {
|
|
387
|
+
n.value = !0, i.value = [], s.value = le();
|
|
702
388
|
}
|
|
703
|
-
function
|
|
704
|
-
if (!
|
|
705
|
-
return
|
|
706
|
-
const l =
|
|
389
|
+
function F(u) {
|
|
390
|
+
if (!n.value || i.value.length === 0)
|
|
391
|
+
return n.value = !1, i.value = [], s.value = null, null;
|
|
392
|
+
const l = s.value, f = i.value.every((I) => I.reversible), T = {
|
|
707
393
|
id: l,
|
|
708
394
|
type: "batch",
|
|
709
395
|
path: "",
|
|
@@ -711,153 +397,153 @@ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
|
|
|
711
397
|
fieldname: "",
|
|
712
398
|
beforeValue: null,
|
|
713
399
|
afterValue: null,
|
|
714
|
-
doctype:
|
|
400
|
+
doctype: i.value[0]?.doctype || "",
|
|
715
401
|
timestamp: /* @__PURE__ */ new Date(),
|
|
716
402
|
source: "user",
|
|
717
|
-
reversible:
|
|
718
|
-
irreversibleReason:
|
|
719
|
-
childOperationIds:
|
|
403
|
+
reversible: f,
|
|
404
|
+
irreversibleReason: f ? void 0 : "Contains irreversible operations",
|
|
405
|
+
childOperationIds: i.value.map((I) => I.id),
|
|
720
406
|
metadata: { description: u }
|
|
721
407
|
};
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}), e.value.push(...
|
|
725
|
-
const
|
|
726
|
-
return
|
|
408
|
+
i.value.forEach((I) => {
|
|
409
|
+
I.parentOperationId = l;
|
|
410
|
+
}), e.value.push(...i.value, T), t.value = e.value.length - 1, o.value.enableCrossTabSync && G(i.value, T);
|
|
411
|
+
const V = l;
|
|
412
|
+
return n.value = !1, i.value = [], s.value = null, V;
|
|
727
413
|
}
|
|
728
|
-
function
|
|
729
|
-
|
|
414
|
+
function R() {
|
|
415
|
+
n.value = !1, i.value = [], s.value = null;
|
|
730
416
|
}
|
|
731
|
-
function
|
|
417
|
+
function O(u) {
|
|
732
418
|
if (!a.value) return !1;
|
|
733
419
|
const l = e.value[t.value];
|
|
734
420
|
if (!l.reversible)
|
|
735
421
|
return typeof console < "u" && l.irreversibleReason && console.warn("Cannot undo irreversible operation:", l.irreversibleReason), !1;
|
|
736
422
|
try {
|
|
737
423
|
if (l.type === "batch" && l.childOperationIds)
|
|
738
|
-
for (let
|
|
739
|
-
const
|
|
740
|
-
|
|
424
|
+
for (let f = l.childOperationIds.length - 1; f >= 0; f--) {
|
|
425
|
+
const T = l.childOperationIds[f], V = e.value.find((I) => I.id === T);
|
|
426
|
+
V && h(V, u);
|
|
741
427
|
}
|
|
742
428
|
else
|
|
743
|
-
|
|
744
|
-
return t.value--,
|
|
745
|
-
} catch (
|
|
746
|
-
return typeof console < "u" && console.error("Undo failed:",
|
|
429
|
+
h(l, u);
|
|
430
|
+
return t.value--, o.value.enableCrossTabSync && v(l), !0;
|
|
431
|
+
} catch (f) {
|
|
432
|
+
return typeof console < "u" && console.error("Undo failed:", f), !1;
|
|
747
433
|
}
|
|
748
434
|
}
|
|
749
|
-
function
|
|
435
|
+
function w(u) {
|
|
750
436
|
if (!c.value) return !1;
|
|
751
437
|
const l = e.value[t.value + 1];
|
|
752
438
|
try {
|
|
753
439
|
if (l.type === "batch" && l.childOperationIds)
|
|
754
|
-
for (const
|
|
755
|
-
const
|
|
756
|
-
|
|
440
|
+
for (const f of l.childOperationIds) {
|
|
441
|
+
const T = e.value.find((V) => V.id === f);
|
|
442
|
+
T && E(T, u);
|
|
757
443
|
}
|
|
758
444
|
else
|
|
759
|
-
|
|
760
|
-
return t.value++,
|
|
761
|
-
} catch (
|
|
762
|
-
return typeof console < "u" && console.error("Redo failed:",
|
|
445
|
+
E(l, u);
|
|
446
|
+
return t.value++, o.value.enableCrossTabSync && P(l), !0;
|
|
447
|
+
} catch (f) {
|
|
448
|
+
return typeof console < "u" && console.error("Redo failed:", f), !1;
|
|
763
449
|
}
|
|
764
450
|
}
|
|
765
|
-
function
|
|
451
|
+
function h(u, l) {
|
|
766
452
|
(u.type === "set" || u.type === "delete") && l && typeof l.set == "function" && l.set(u.path, u.beforeValue, "undo");
|
|
767
453
|
}
|
|
768
|
-
function
|
|
454
|
+
function E(u, l) {
|
|
769
455
|
(u.type === "set" || u.type === "delete") && l && typeof l.set == "function" && l.set(u.path, u.afterValue, "redo");
|
|
770
456
|
}
|
|
771
|
-
function
|
|
772
|
-
const u = e.value.filter((
|
|
457
|
+
function b() {
|
|
458
|
+
const u = e.value.filter((f) => f.reversible).length, l = e.value.map((f) => f.timestamp);
|
|
773
459
|
return {
|
|
774
460
|
operations: [...e.value],
|
|
775
461
|
currentIndex: t.value,
|
|
776
462
|
totalOperations: e.value.length,
|
|
777
463
|
reversibleOperations: u,
|
|
778
464
|
irreversibleOperations: e.value.length - u,
|
|
779
|
-
oldestOperation: l.length > 0 ? new Date(Math.min(...l.map((
|
|
780
|
-
newestOperation: l.length > 0 ? new Date(Math.max(...l.map((
|
|
465
|
+
oldestOperation: l.length > 0 ? new Date(Math.min(...l.map((f) => f.getTime()))) : void 0,
|
|
466
|
+
newestOperation: l.length > 0 ? new Date(Math.max(...l.map((f) => f.getTime()))) : void 0
|
|
781
467
|
};
|
|
782
468
|
}
|
|
783
|
-
function
|
|
469
|
+
function A() {
|
|
784
470
|
e.value = [], t.value = -1;
|
|
785
471
|
}
|
|
786
|
-
function
|
|
787
|
-
return e.value.filter((
|
|
472
|
+
function C(u, l) {
|
|
473
|
+
return e.value.filter((f) => f.doctype === u && (l === void 0 || f.recordId === l));
|
|
788
474
|
}
|
|
789
|
-
function
|
|
790
|
-
const
|
|
791
|
-
|
|
475
|
+
function M(u, l) {
|
|
476
|
+
const f = e.value.find((T) => T.id === u);
|
|
477
|
+
f && (f.reversible = !1, f.irreversibleReason = l);
|
|
792
478
|
}
|
|
793
|
-
function
|
|
794
|
-
const
|
|
479
|
+
function W(u, l, f, T = "success", V) {
|
|
480
|
+
const I = {
|
|
795
481
|
type: "action",
|
|
796
|
-
path:
|
|
482
|
+
path: f && f.length > 0 ? `${u}.${f[0]}` : u,
|
|
797
483
|
fieldname: "",
|
|
798
484
|
beforeValue: null,
|
|
799
485
|
afterValue: null,
|
|
800
486
|
doctype: u,
|
|
801
|
-
recordId:
|
|
487
|
+
recordId: f && f.length > 0 ? f[0] : void 0,
|
|
802
488
|
reversible: !1,
|
|
803
489
|
// Actions are typically not reversible
|
|
804
490
|
actionName: l,
|
|
805
|
-
actionRecordIds:
|
|
806
|
-
actionResult:
|
|
807
|
-
actionError:
|
|
491
|
+
actionRecordIds: f,
|
|
492
|
+
actionResult: T,
|
|
493
|
+
actionError: V
|
|
808
494
|
};
|
|
809
|
-
return
|
|
495
|
+
return k(I);
|
|
810
496
|
}
|
|
811
|
-
let
|
|
812
|
-
function
|
|
813
|
-
typeof window > "u" || !window.BroadcastChannel || (
|
|
497
|
+
let N = null;
|
|
498
|
+
function q() {
|
|
499
|
+
typeof window > "u" || !window.BroadcastChannel || (N = new BroadcastChannel("stonecrop-operation-log"), N.addEventListener("message", (u) => {
|
|
814
500
|
const l = u.data;
|
|
815
501
|
if (!l || typeof l != "object") return;
|
|
816
|
-
const
|
|
817
|
-
|
|
502
|
+
const f = Xe(l);
|
|
503
|
+
f.clientId !== r.value && (f.type === "operation" && f.operation ? (e.value.push({ ...f.operation, source: "sync" }), t.value = e.value.length - 1) : f.type === "operation" && f.operations && (e.value.push(...f.operations.map((T) => ({ ...T, source: "sync" }))), t.value = e.value.length - 1));
|
|
818
504
|
}));
|
|
819
505
|
}
|
|
820
|
-
function
|
|
821
|
-
if (!
|
|
506
|
+
function _(u) {
|
|
507
|
+
if (!N) return;
|
|
822
508
|
const l = {
|
|
823
509
|
type: "operation",
|
|
824
510
|
operation: u,
|
|
825
511
|
clientId: r.value,
|
|
826
512
|
timestamp: /* @__PURE__ */ new Date()
|
|
827
513
|
};
|
|
828
|
-
|
|
514
|
+
N.postMessage(ie(l));
|
|
829
515
|
}
|
|
830
|
-
function
|
|
831
|
-
if (!
|
|
832
|
-
const
|
|
516
|
+
function G(u, l) {
|
|
517
|
+
if (!N) return;
|
|
518
|
+
const f = {
|
|
833
519
|
type: "operation",
|
|
834
520
|
operations: [...u, l],
|
|
835
521
|
clientId: r.value,
|
|
836
522
|
timestamp: /* @__PURE__ */ new Date()
|
|
837
523
|
};
|
|
838
|
-
|
|
524
|
+
N.postMessage(ie(f));
|
|
839
525
|
}
|
|
840
|
-
function
|
|
841
|
-
if (!
|
|
526
|
+
function v(u) {
|
|
527
|
+
if (!N) return;
|
|
842
528
|
const l = {
|
|
843
529
|
type: "undo",
|
|
844
530
|
operation: u,
|
|
845
531
|
clientId: r.value,
|
|
846
532
|
timestamp: /* @__PURE__ */ new Date()
|
|
847
533
|
};
|
|
848
|
-
|
|
534
|
+
N.postMessage(ie(l));
|
|
849
535
|
}
|
|
850
|
-
function
|
|
851
|
-
if (!
|
|
536
|
+
function P(u) {
|
|
537
|
+
if (!N) return;
|
|
852
538
|
const l = {
|
|
853
539
|
type: "redo",
|
|
854
540
|
operation: u,
|
|
855
541
|
clientId: r.value,
|
|
856
542
|
timestamp: /* @__PURE__ */ new Date()
|
|
857
543
|
};
|
|
858
|
-
|
|
544
|
+
N.postMessage(ie(l));
|
|
859
545
|
}
|
|
860
|
-
const
|
|
546
|
+
const D = Ze("stonecrop-ops-operations", null, {
|
|
861
547
|
serializer: {
|
|
862
548
|
read: (u) => {
|
|
863
549
|
try {
|
|
@@ -869,10 +555,10 @@ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
|
|
|
869
555
|
write: (u) => u ? JSON.stringify(u) : ""
|
|
870
556
|
}
|
|
871
557
|
});
|
|
872
|
-
function
|
|
558
|
+
function p() {
|
|
873
559
|
if (!(typeof window > "u"))
|
|
874
560
|
try {
|
|
875
|
-
const u =
|
|
561
|
+
const u = D.value;
|
|
876
562
|
u && Array.isArray(u.operations) && (e.value = u.operations.map((l) => ({
|
|
877
563
|
...l,
|
|
878
564
|
timestamp: new Date(l.timestamp)
|
|
@@ -881,10 +567,10 @@ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
|
|
|
881
567
|
typeof console < "u" && console.error("Failed to load operations from persistence:", u);
|
|
882
568
|
}
|
|
883
569
|
}
|
|
884
|
-
function
|
|
570
|
+
function m() {
|
|
885
571
|
if (!(typeof window > "u"))
|
|
886
572
|
try {
|
|
887
|
-
|
|
573
|
+
D.value = {
|
|
888
574
|
operations: e.value.map((u) => ({
|
|
889
575
|
...u,
|
|
890
576
|
timestamp: u.timestamp.toISOString()
|
|
@@ -895,11 +581,11 @@ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
|
|
|
895
581
|
typeof console < "u" && console.error("Failed to save operations to persistence:", u);
|
|
896
582
|
}
|
|
897
583
|
}
|
|
898
|
-
function
|
|
584
|
+
function y() {
|
|
899
585
|
U(
|
|
900
586
|
[e, t],
|
|
901
587
|
() => {
|
|
902
|
-
|
|
588
|
+
o.value.enablePersistence && m();
|
|
903
589
|
},
|
|
904
590
|
{ deep: !0 }
|
|
905
591
|
);
|
|
@@ -908,30 +594,30 @@ const pe = /* @__PURE__ */ it("hst-operation-log", () => {
|
|
|
908
594
|
// State
|
|
909
595
|
operations: e,
|
|
910
596
|
currentIndex: t,
|
|
911
|
-
config:
|
|
597
|
+
config: o,
|
|
912
598
|
clientId: r,
|
|
913
|
-
undoRedoState:
|
|
599
|
+
undoRedoState: S,
|
|
914
600
|
// Computed
|
|
915
601
|
canUndo: a,
|
|
916
602
|
canRedo: c,
|
|
917
|
-
undoCount:
|
|
603
|
+
undoCount: d,
|
|
918
604
|
redoCount: g,
|
|
919
605
|
// Methods
|
|
920
|
-
configure:
|
|
921
|
-
addOperation:
|
|
922
|
-
startBatch:
|
|
923
|
-
commitBatch:
|
|
924
|
-
cancelBatch:
|
|
925
|
-
undo:
|
|
926
|
-
redo:
|
|
927
|
-
clear:
|
|
928
|
-
getOperationsFor:
|
|
929
|
-
getSnapshot:
|
|
930
|
-
markIrreversible:
|
|
931
|
-
logAction:
|
|
606
|
+
configure: $,
|
|
607
|
+
addOperation: k,
|
|
608
|
+
startBatch: x,
|
|
609
|
+
commitBatch: F,
|
|
610
|
+
cancelBatch: R,
|
|
611
|
+
undo: O,
|
|
612
|
+
redo: w,
|
|
613
|
+
clear: A,
|
|
614
|
+
getOperationsFor: C,
|
|
615
|
+
getSnapshot: b,
|
|
616
|
+
markIrreversible: M,
|
|
617
|
+
logAction: W
|
|
932
618
|
};
|
|
933
619
|
});
|
|
934
|
-
class
|
|
620
|
+
class ee {
|
|
935
621
|
/**
|
|
936
622
|
* The root FieldTriggerEngine instance
|
|
937
623
|
*/
|
|
@@ -952,9 +638,9 @@ class ue {
|
|
|
952
638
|
* @param options - Configuration options for the field trigger engine
|
|
953
639
|
*/
|
|
954
640
|
constructor(e = {}) {
|
|
955
|
-
if (
|
|
956
|
-
return
|
|
957
|
-
|
|
641
|
+
if (ee._root)
|
|
642
|
+
return ee._root;
|
|
643
|
+
ee._root = this, this.options = {
|
|
958
644
|
defaultTimeout: e.defaultTimeout ?? 5e3,
|
|
959
645
|
debug: e.debug ?? !1,
|
|
960
646
|
enableRollback: e.enableRollback ?? !0,
|
|
@@ -1000,25 +686,25 @@ class ue {
|
|
|
1000
686
|
*/
|
|
1001
687
|
registerDoctypeActions(e, t) {
|
|
1002
688
|
if (!t) return;
|
|
1003
|
-
const r = /* @__PURE__ */ new Map(),
|
|
689
|
+
const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1004
690
|
if (typeof t.entrySeq == "function")
|
|
1005
|
-
t.entrySeq().forEach(([
|
|
1006
|
-
this.categorizeAction(
|
|
691
|
+
t.entrySeq().forEach(([i, s]) => {
|
|
692
|
+
this.categorizeAction(i, s, r, n);
|
|
1007
693
|
});
|
|
1008
694
|
else if (t instanceof Map)
|
|
1009
|
-
for (const [
|
|
1010
|
-
this.categorizeAction(
|
|
1011
|
-
else t && typeof t == "object" && Object.entries(t).forEach(([
|
|
1012
|
-
this.categorizeAction(
|
|
695
|
+
for (const [i, s] of t)
|
|
696
|
+
this.categorizeAction(i, s, r, n);
|
|
697
|
+
else t && typeof t == "object" && Object.entries(t).forEach(([i, s]) => {
|
|
698
|
+
this.categorizeAction(i, s, r, n);
|
|
1013
699
|
});
|
|
1014
|
-
this.doctypeActions.set(e, r), this.doctypeTransitions.set(e,
|
|
700
|
+
this.doctypeActions.set(e, r), this.doctypeTransitions.set(e, n);
|
|
1015
701
|
}
|
|
1016
702
|
/**
|
|
1017
703
|
* Categorize an action as either a field trigger or XState transition
|
|
1018
704
|
* Uses uppercase convention: UPPERCASE = transition, lowercase/mixed = field trigger
|
|
1019
705
|
*/
|
|
1020
|
-
categorizeAction(e, t, r,
|
|
1021
|
-
this.isTransitionKey(e) ?
|
|
706
|
+
categorizeAction(e, t, r, n) {
|
|
707
|
+
this.isTransitionKey(e) ? n.set(e, t) : r.set(e, t);
|
|
1022
708
|
}
|
|
1023
709
|
/**
|
|
1024
710
|
* Determine if a key represents an XState transition
|
|
@@ -1033,8 +719,8 @@ class ue {
|
|
|
1033
719
|
* @param options - Execution options (timeout and enableRollback)
|
|
1034
720
|
*/
|
|
1035
721
|
async executeFieldTriggers(e, t = {}) {
|
|
1036
|
-
const { doctype: r, fieldname:
|
|
1037
|
-
if (
|
|
722
|
+
const { doctype: r, fieldname: n } = e, i = this.findFieldTriggers(r, n);
|
|
723
|
+
if (i.length === 0)
|
|
1038
724
|
return {
|
|
1039
725
|
path: e.path,
|
|
1040
726
|
actionResults: [],
|
|
@@ -1043,49 +729,49 @@ class ue {
|
|
|
1043
729
|
stoppedOnError: !1,
|
|
1044
730
|
rolledBack: !1
|
|
1045
731
|
};
|
|
1046
|
-
const
|
|
1047
|
-
let c = !1,
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
for (const
|
|
732
|
+
const s = performance.now(), a = [];
|
|
733
|
+
let c = !1, d = !1, g;
|
|
734
|
+
const S = this.getFieldRollback(r, n), $ = t.enableRollback ?? S ?? this.options.enableRollback;
|
|
735
|
+
$ && e.store && (g = this.captureSnapshot(e));
|
|
736
|
+
for (const R of i)
|
|
1051
737
|
try {
|
|
1052
|
-
const
|
|
1053
|
-
if (a.push(
|
|
738
|
+
const O = await this.executeAction(R, e, t.timeout);
|
|
739
|
+
if (a.push(O), !O.success) {
|
|
1054
740
|
c = !0;
|
|
1055
741
|
break;
|
|
1056
742
|
}
|
|
1057
|
-
} catch (
|
|
1058
|
-
const
|
|
743
|
+
} catch (O) {
|
|
744
|
+
const h = {
|
|
1059
745
|
success: !1,
|
|
1060
|
-
error:
|
|
746
|
+
error: O instanceof Error ? O : new Error(String(O)),
|
|
1061
747
|
executionTime: 0,
|
|
1062
|
-
action:
|
|
748
|
+
action: R
|
|
1063
749
|
};
|
|
1064
|
-
a.push(
|
|
750
|
+
a.push(h), c = !0;
|
|
1065
751
|
break;
|
|
1066
752
|
}
|
|
1067
|
-
if (
|
|
753
|
+
if ($ && c && g && e.store)
|
|
1068
754
|
try {
|
|
1069
|
-
this.restoreSnapshot(e, g),
|
|
1070
|
-
} catch (
|
|
1071
|
-
console.error("[FieldTriggers] Rollback failed:",
|
|
755
|
+
this.restoreSnapshot(e, g), d = !0;
|
|
756
|
+
} catch (R) {
|
|
757
|
+
console.error("[FieldTriggers] Rollback failed:", R);
|
|
1072
758
|
}
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
for (const
|
|
759
|
+
const k = performance.now() - s, x = a.filter((R) => !R.success);
|
|
760
|
+
if (x.length > 0 && this.options.errorHandler)
|
|
761
|
+
for (const R of x)
|
|
1076
762
|
try {
|
|
1077
|
-
this.options.errorHandler(
|
|
1078
|
-
} catch (
|
|
1079
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
763
|
+
this.options.errorHandler(R.error, e, R.action);
|
|
764
|
+
} catch (O) {
|
|
765
|
+
console.error("[FieldTriggers] Error in global error handler:", O);
|
|
1080
766
|
}
|
|
1081
767
|
return {
|
|
1082
768
|
path: e.path,
|
|
1083
769
|
actionResults: a,
|
|
1084
|
-
totalExecutionTime:
|
|
1085
|
-
allSucceeded: a.every((
|
|
770
|
+
totalExecutionTime: k,
|
|
771
|
+
allSucceeded: a.every((R) => R.success),
|
|
1086
772
|
stoppedOnError: c,
|
|
1087
|
-
rolledBack:
|
|
1088
|
-
snapshot: this.options.debug &&
|
|
773
|
+
rolledBack: d,
|
|
774
|
+
snapshot: this.options.debug && $ ? g : void 0
|
|
1089
775
|
// Only include snapshot in debug mode if rollback is enabled
|
|
1090
776
|
};
|
|
1091
777
|
}
|
|
@@ -1096,35 +782,35 @@ class ue {
|
|
|
1096
782
|
* @param options - Execution options (timeout)
|
|
1097
783
|
*/
|
|
1098
784
|
async executeTransitionActions(e, t = {}) {
|
|
1099
|
-
const { doctype: r, transition:
|
|
1100
|
-
if (
|
|
785
|
+
const { doctype: r, transition: n } = e, i = this.findTransitionActions(r, n);
|
|
786
|
+
if (i.length === 0)
|
|
1101
787
|
return [];
|
|
1102
|
-
const
|
|
1103
|
-
for (const c of
|
|
788
|
+
const s = [];
|
|
789
|
+
for (const c of i)
|
|
1104
790
|
try {
|
|
1105
|
-
const
|
|
1106
|
-
if (
|
|
791
|
+
const d = await this.executeTransitionAction(c, e, t.timeout);
|
|
792
|
+
if (s.push(d), !d.success)
|
|
1107
793
|
break;
|
|
1108
|
-
} catch (
|
|
1109
|
-
const
|
|
794
|
+
} catch (d) {
|
|
795
|
+
const S = {
|
|
1110
796
|
success: !1,
|
|
1111
|
-
error:
|
|
797
|
+
error: d instanceof Error ? d : new Error(String(d)),
|
|
1112
798
|
executionTime: 0,
|
|
1113
799
|
action: c,
|
|
1114
|
-
transition:
|
|
800
|
+
transition: n
|
|
1115
801
|
};
|
|
1116
|
-
|
|
802
|
+
s.push(S);
|
|
1117
803
|
break;
|
|
1118
804
|
}
|
|
1119
|
-
const a =
|
|
805
|
+
const a = s.filter((c) => !c.success);
|
|
1120
806
|
if (a.length > 0 && this.options.errorHandler)
|
|
1121
807
|
for (const c of a)
|
|
1122
808
|
try {
|
|
1123
809
|
this.options.errorHandler(c.error, e, c.action);
|
|
1124
|
-
} catch (
|
|
1125
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
810
|
+
} catch (d) {
|
|
811
|
+
console.error("[FieldTriggers] Error in global error handler:", d);
|
|
1126
812
|
}
|
|
1127
|
-
return
|
|
813
|
+
return s;
|
|
1128
814
|
}
|
|
1129
815
|
/**
|
|
1130
816
|
* Find transition actions for a specific doctype and transition
|
|
@@ -1137,26 +823,26 @@ class ue {
|
|
|
1137
823
|
* Execute a single transition action by name
|
|
1138
824
|
*/
|
|
1139
825
|
async executeTransitionAction(e, t, r) {
|
|
1140
|
-
const
|
|
826
|
+
const n = performance.now(), i = r ?? this.options.defaultTimeout;
|
|
1141
827
|
try {
|
|
1142
|
-
let
|
|
1143
|
-
if (!
|
|
828
|
+
let s = this.globalTransitionActions.get(e);
|
|
829
|
+
if (!s) {
|
|
1144
830
|
const c = this.globalActions.get(e);
|
|
1145
|
-
c && (
|
|
831
|
+
c && (s = c);
|
|
1146
832
|
}
|
|
1147
|
-
if (!
|
|
833
|
+
if (!s)
|
|
1148
834
|
throw new Error(`Transition action "${e}" not found in registry`);
|
|
1149
|
-
return await this.executeWithTimeout(
|
|
835
|
+
return await this.executeWithTimeout(s, t, i), {
|
|
1150
836
|
success: !0,
|
|
1151
|
-
executionTime: performance.now() -
|
|
837
|
+
executionTime: performance.now() - n,
|
|
1152
838
|
action: e,
|
|
1153
839
|
transition: t.transition
|
|
1154
840
|
};
|
|
1155
|
-
} catch (
|
|
1156
|
-
const a = performance.now() -
|
|
841
|
+
} catch (s) {
|
|
842
|
+
const a = performance.now() - n;
|
|
1157
843
|
return {
|
|
1158
844
|
success: !1,
|
|
1159
|
-
error:
|
|
845
|
+
error: s instanceof Error ? s : new Error(String(s)),
|
|
1160
846
|
executionTime: a,
|
|
1161
847
|
action: e,
|
|
1162
848
|
transition: t.transition
|
|
@@ -1170,10 +856,10 @@ class ue {
|
|
|
1170
856
|
findFieldTriggers(e, t) {
|
|
1171
857
|
const r = this.doctypeActions.get(e);
|
|
1172
858
|
if (!r) return [];
|
|
1173
|
-
const
|
|
1174
|
-
for (const [
|
|
1175
|
-
this.isFieldTriggerKey(
|
|
1176
|
-
return
|
|
859
|
+
const n = [];
|
|
860
|
+
for (const [i, s] of r)
|
|
861
|
+
this.isFieldTriggerKey(i, t) && n.push(...s);
|
|
862
|
+
return n;
|
|
1177
863
|
}
|
|
1178
864
|
/**
|
|
1179
865
|
* Determine if an action key represents a field trigger
|
|
@@ -1190,12 +876,12 @@ class ue {
|
|
|
1190
876
|
* Supports wildcards (*) for dynamic segments
|
|
1191
877
|
*/
|
|
1192
878
|
matchFieldPattern(e, t) {
|
|
1193
|
-
const r = e.split("."),
|
|
1194
|
-
if (r.length !==
|
|
879
|
+
const r = e.split("."), n = t.split(".");
|
|
880
|
+
if (r.length !== n.length)
|
|
1195
881
|
return !1;
|
|
1196
|
-
for (let
|
|
1197
|
-
const
|
|
1198
|
-
if (
|
|
882
|
+
for (let i = 0; i < r.length; i++) {
|
|
883
|
+
const s = r[i], a = n[i];
|
|
884
|
+
if (s !== "*" && s !== a)
|
|
1199
885
|
return !1;
|
|
1200
886
|
}
|
|
1201
887
|
return !0;
|
|
@@ -1204,21 +890,21 @@ class ue {
|
|
|
1204
890
|
* Execute a single action by name
|
|
1205
891
|
*/
|
|
1206
892
|
async executeAction(e, t, r) {
|
|
1207
|
-
const
|
|
893
|
+
const n = performance.now(), i = r ?? this.options.defaultTimeout;
|
|
1208
894
|
try {
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
895
|
+
const s = this.globalActions.get(e);
|
|
896
|
+
if (!s)
|
|
1211
897
|
throw new Error(`Action "${e}" not found in registry`);
|
|
1212
|
-
return await this.executeWithTimeout(
|
|
898
|
+
return await this.executeWithTimeout(s, t, i), {
|
|
1213
899
|
success: !0,
|
|
1214
|
-
executionTime: performance.now() -
|
|
900
|
+
executionTime: performance.now() - n,
|
|
1215
901
|
action: e
|
|
1216
902
|
};
|
|
1217
|
-
} catch (
|
|
1218
|
-
const a = performance.now() -
|
|
903
|
+
} catch (s) {
|
|
904
|
+
const a = performance.now() - n;
|
|
1219
905
|
return {
|
|
1220
906
|
success: !1,
|
|
1221
|
-
error:
|
|
907
|
+
error: s instanceof Error ? s : new Error(String(s)),
|
|
1222
908
|
executionTime: a,
|
|
1223
909
|
action: e
|
|
1224
910
|
};
|
|
@@ -1228,14 +914,14 @@ class ue {
|
|
|
1228
914
|
* Execute a function with timeout
|
|
1229
915
|
*/
|
|
1230
916
|
async executeWithTimeout(e, t, r) {
|
|
1231
|
-
return new Promise((
|
|
1232
|
-
const
|
|
1233
|
-
|
|
917
|
+
return new Promise((n, i) => {
|
|
918
|
+
const s = setTimeout(() => {
|
|
919
|
+
i(new Error(`Action timeout after ${r}ms`));
|
|
1234
920
|
}, r);
|
|
1235
921
|
Promise.resolve(e(t)).then((a) => {
|
|
1236
|
-
clearTimeout(
|
|
922
|
+
clearTimeout(s), n(a);
|
|
1237
923
|
}).catch((a) => {
|
|
1238
|
-
clearTimeout(
|
|
924
|
+
clearTimeout(s), i(a);
|
|
1239
925
|
});
|
|
1240
926
|
});
|
|
1241
927
|
}
|
|
@@ -1267,26 +953,26 @@ class ue {
|
|
|
1267
953
|
}
|
|
1268
954
|
}
|
|
1269
955
|
}
|
|
1270
|
-
function
|
|
1271
|
-
return new
|
|
956
|
+
function J(o) {
|
|
957
|
+
return new ee(o);
|
|
1272
958
|
}
|
|
1273
|
-
function
|
|
1274
|
-
|
|
959
|
+
function ct(o, e) {
|
|
960
|
+
J().registerAction(o, e);
|
|
1275
961
|
}
|
|
1276
|
-
function
|
|
1277
|
-
|
|
962
|
+
function lt(o, e) {
|
|
963
|
+
J().registerTransitionAction(o, e);
|
|
1278
964
|
}
|
|
1279
|
-
function
|
|
1280
|
-
|
|
965
|
+
function ut(o, e, t) {
|
|
966
|
+
J().setFieldRollback(o, e, t);
|
|
1281
967
|
}
|
|
1282
|
-
async function
|
|
1283
|
-
const r =
|
|
1284
|
-
path: t?.path || (t?.recordId ? `${
|
|
968
|
+
async function ft(o, e, t) {
|
|
969
|
+
const r = J(), n = {
|
|
970
|
+
path: t?.path || (t?.recordId ? `${o}.${t.recordId}` : o),
|
|
1285
971
|
fieldname: "",
|
|
1286
972
|
beforeValue: void 0,
|
|
1287
973
|
afterValue: void 0,
|
|
1288
974
|
operation: "set",
|
|
1289
|
-
doctype:
|
|
975
|
+
doctype: o,
|
|
1290
976
|
recordId: t?.recordId,
|
|
1291
977
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1292
978
|
transition: e,
|
|
@@ -1294,30 +980,30 @@ async function Ft(n, e, t) {
|
|
|
1294
980
|
targetState: t?.targetState,
|
|
1295
981
|
fsmContext: t?.fsmContext
|
|
1296
982
|
};
|
|
1297
|
-
return await r.executeTransitionActions(
|
|
983
|
+
return await r.executeTransitionActions(n);
|
|
1298
984
|
}
|
|
1299
|
-
function
|
|
1300
|
-
if (
|
|
985
|
+
function dt(o, e) {
|
|
986
|
+
if (o)
|
|
1301
987
|
try {
|
|
1302
|
-
|
|
988
|
+
re().markIrreversible(o, e);
|
|
1303
989
|
} catch {
|
|
1304
990
|
}
|
|
1305
991
|
}
|
|
1306
|
-
function
|
|
992
|
+
function ge() {
|
|
1307
993
|
try {
|
|
1308
|
-
return
|
|
994
|
+
return re();
|
|
1309
995
|
} catch {
|
|
1310
996
|
return null;
|
|
1311
997
|
}
|
|
1312
998
|
}
|
|
1313
|
-
class
|
|
999
|
+
class Y {
|
|
1314
1000
|
static instance;
|
|
1315
1001
|
/**
|
|
1316
1002
|
* Gets the singleton instance of HST
|
|
1317
1003
|
* @returns The HST singleton instance
|
|
1318
1004
|
*/
|
|
1319
1005
|
static getInstance() {
|
|
1320
|
-
return
|
|
1006
|
+
return Y.instance || (Y.instance = new Y()), Y.instance;
|
|
1321
1007
|
}
|
|
1322
1008
|
/**
|
|
1323
1009
|
* Gets the global registry instance
|
|
@@ -1351,23 +1037,23 @@ class ne {
|
|
|
1351
1037
|
return t.registry[e];
|
|
1352
1038
|
}
|
|
1353
1039
|
}
|
|
1354
|
-
class
|
|
1040
|
+
class se {
|
|
1355
1041
|
target;
|
|
1356
1042
|
parentPath;
|
|
1357
1043
|
rootNode;
|
|
1358
1044
|
doctype;
|
|
1359
1045
|
parentDoctype;
|
|
1360
1046
|
hst;
|
|
1361
|
-
constructor(e, t, r = "",
|
|
1362
|
-
return this.target = e, this.parentPath = r, this.rootNode =
|
|
1363
|
-
get(
|
|
1364
|
-
if (a in
|
|
1047
|
+
constructor(e, t, r = "", n = null, i) {
|
|
1048
|
+
return this.target = e, this.parentPath = r, this.rootNode = n || this, this.doctype = t, this.parentDoctype = i, this.hst = Y.getInstance(), new Proxy(this, {
|
|
1049
|
+
get(s, a) {
|
|
1050
|
+
if (a in s) return s[a];
|
|
1365
1051
|
const c = String(a);
|
|
1366
|
-
return
|
|
1052
|
+
return s.getNode(c);
|
|
1367
1053
|
},
|
|
1368
|
-
set(
|
|
1369
|
-
const
|
|
1370
|
-
return
|
|
1054
|
+
set(s, a, c) {
|
|
1055
|
+
const d = String(a);
|
|
1056
|
+
return s.set(d, c), !0;
|
|
1371
1057
|
}
|
|
1372
1058
|
});
|
|
1373
1059
|
}
|
|
@@ -1376,25 +1062,25 @@ class Se {
|
|
|
1376
1062
|
}
|
|
1377
1063
|
// Method to get a tree-wrapped node for navigation
|
|
1378
1064
|
getNode(e) {
|
|
1379
|
-
const t = this.resolvePath(e), r = this.resolveValue(e),
|
|
1380
|
-
let
|
|
1381
|
-
return this.doctype === "StonecropStore" &&
|
|
1065
|
+
const t = this.resolvePath(e), r = this.resolveValue(e), n = t.split(".");
|
|
1066
|
+
let i = this.doctype;
|
|
1067
|
+
return this.doctype === "StonecropStore" && n.length >= 1 && (i = n[0]), typeof r == "object" && r !== null && !this.isPrimitive(r) ? new se(r, i, t, this.rootNode, this.parentDoctype) : new se(r, i, t, this.rootNode, this.parentDoctype);
|
|
1382
1068
|
}
|
|
1383
1069
|
set(e, t, r = "user") {
|
|
1384
|
-
const
|
|
1070
|
+
const n = this.resolvePath(e), i = this.has(e) ? this.get(e) : void 0;
|
|
1385
1071
|
if (r !== "undo" && r !== "redo") {
|
|
1386
|
-
const
|
|
1387
|
-
if (
|
|
1388
|
-
const a =
|
|
1389
|
-
|
|
1072
|
+
const s = ge();
|
|
1073
|
+
if (s && typeof s.addOperation == "function") {
|
|
1074
|
+
const a = n.split("."), c = this.doctype === "StonecropStore" && a.length >= 1 ? a[0] : this.doctype, d = a.length >= 2 ? a[1] : void 0, g = a.slice(2).join(".") || a[a.length - 1], $ = t === void 0 && i !== void 0 ? "delete" : "set";
|
|
1075
|
+
s.addOperation(
|
|
1390
1076
|
{
|
|
1391
|
-
type:
|
|
1392
|
-
path:
|
|
1077
|
+
type: $,
|
|
1078
|
+
path: n,
|
|
1393
1079
|
fieldname: g,
|
|
1394
|
-
beforeValue:
|
|
1080
|
+
beforeValue: i,
|
|
1395
1081
|
afterValue: t,
|
|
1396
1082
|
doctype: c,
|
|
1397
|
-
recordId:
|
|
1083
|
+
recordId: d,
|
|
1398
1084
|
reversible: !0
|
|
1399
1085
|
// Default to reversible, can be changed by field triggers
|
|
1400
1086
|
},
|
|
@@ -1402,7 +1088,7 @@ class Se {
|
|
|
1402
1088
|
);
|
|
1403
1089
|
}
|
|
1404
1090
|
}
|
|
1405
|
-
this.updateValue(e, t), this.triggerFieldActions(
|
|
1091
|
+
this.updateValue(e, t), this.triggerFieldActions(n, i, t);
|
|
1406
1092
|
}
|
|
1407
1093
|
has(e) {
|
|
1408
1094
|
try {
|
|
@@ -1410,13 +1096,13 @@ class Se {
|
|
|
1410
1096
|
return !0;
|
|
1411
1097
|
const t = this.parsePath(e);
|
|
1412
1098
|
let r = this.target;
|
|
1413
|
-
for (let
|
|
1414
|
-
const
|
|
1099
|
+
for (let n = 0; n < t.length; n++) {
|
|
1100
|
+
const i = t[n];
|
|
1415
1101
|
if (r == null)
|
|
1416
1102
|
return !1;
|
|
1417
|
-
if (
|
|
1418
|
-
return this.isImmutable(r) ? r.has(
|
|
1419
|
-
r = this.getProperty(r,
|
|
1103
|
+
if (n === t.length - 1)
|
|
1104
|
+
return this.isImmutable(r) ? r.has(i) : this.isPiniaStore(r) && r.$state && i in r.$state || i in r;
|
|
1105
|
+
r = this.getProperty(r, i);
|
|
1420
1106
|
}
|
|
1421
1107
|
return !1;
|
|
1422
1108
|
} catch {
|
|
@@ -1445,9 +1131,9 @@ class Se {
|
|
|
1445
1131
|
* Trigger an XState transition with optional context data
|
|
1446
1132
|
*/
|
|
1447
1133
|
async triggerTransition(e, t) {
|
|
1448
|
-
const r =
|
|
1449
|
-
let
|
|
1450
|
-
this.doctype === "StonecropStore" &&
|
|
1134
|
+
const r = J(), n = this.parentPath.split(".");
|
|
1135
|
+
let i = this.doctype, s;
|
|
1136
|
+
this.doctype === "StonecropStore" && n.length >= 1 && (i = n[0]), n.length >= 2 && (s = n[1]);
|
|
1451
1137
|
const a = {
|
|
1452
1138
|
path: this.parentPath,
|
|
1453
1139
|
fieldname: "",
|
|
@@ -1455,15 +1141,15 @@ class Se {
|
|
|
1455
1141
|
beforeValue: void 0,
|
|
1456
1142
|
afterValue: void 0,
|
|
1457
1143
|
operation: "set",
|
|
1458
|
-
doctype:
|
|
1459
|
-
recordId:
|
|
1144
|
+
doctype: i,
|
|
1145
|
+
recordId: s,
|
|
1460
1146
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1461
1147
|
store: this.rootNode || void 0,
|
|
1462
1148
|
transition: e,
|
|
1463
1149
|
currentState: t?.currentState,
|
|
1464
1150
|
targetState: t?.targetState,
|
|
1465
1151
|
fsmContext: t?.fsmContext
|
|
1466
|
-
}, c =
|
|
1152
|
+
}, c = ge();
|
|
1467
1153
|
return c && typeof c.addOperation == "function" && c.addOperation(
|
|
1468
1154
|
{
|
|
1469
1155
|
type: "transition",
|
|
@@ -1471,8 +1157,8 @@ class Se {
|
|
|
1471
1157
|
fieldname: e,
|
|
1472
1158
|
beforeValue: t?.currentState,
|
|
1473
1159
|
afterValue: t?.targetState,
|
|
1474
|
-
doctype:
|
|
1475
|
-
recordId:
|
|
1160
|
+
doctype: i,
|
|
1161
|
+
recordId: s,
|
|
1476
1162
|
reversible: !1,
|
|
1477
1163
|
// FSM transitions are generally not reversible
|
|
1478
1164
|
metadata: {
|
|
@@ -1494,22 +1180,22 @@ class Se {
|
|
|
1494
1180
|
return this.target;
|
|
1495
1181
|
const t = this.parsePath(e);
|
|
1496
1182
|
let r = this.target;
|
|
1497
|
-
for (const
|
|
1183
|
+
for (const n of t) {
|
|
1498
1184
|
if (r == null)
|
|
1499
1185
|
return;
|
|
1500
|
-
r = this.getProperty(r,
|
|
1186
|
+
r = this.getProperty(r, n);
|
|
1501
1187
|
}
|
|
1502
1188
|
return r;
|
|
1503
1189
|
}
|
|
1504
1190
|
updateValue(e, t) {
|
|
1505
1191
|
if (e === "")
|
|
1506
1192
|
throw new Error("Cannot set value on empty path");
|
|
1507
|
-
const r = this.parsePath(e),
|
|
1508
|
-
let
|
|
1509
|
-
for (const
|
|
1510
|
-
if (
|
|
1193
|
+
const r = this.parsePath(e), n = r.pop();
|
|
1194
|
+
let i = this.target;
|
|
1195
|
+
for (const s of r)
|
|
1196
|
+
if (i = this.getProperty(i, s), i == null)
|
|
1511
1197
|
throw new Error(`Cannot set property on null/undefined path: ${e}`);
|
|
1512
|
-
this.setProperty(
|
|
1198
|
+
this.setProperty(i, n, t);
|
|
1513
1199
|
}
|
|
1514
1200
|
getProperty(e, t) {
|
|
1515
1201
|
return this.isImmutable(e) ? e.get(t) : this.isVueReactive(e) ? e[t] : this.isPiniaStore(e) ? e.$state?.[t] ?? e[t] : e[t];
|
|
@@ -1527,17 +1213,17 @@ class Se {
|
|
|
1527
1213
|
try {
|
|
1528
1214
|
if (!e || typeof e != "string")
|
|
1529
1215
|
return;
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1216
|
+
const n = e.split(".");
|
|
1217
|
+
if (n.length < 3)
|
|
1532
1218
|
return;
|
|
1533
|
-
const
|
|
1219
|
+
const i = J(), s = n.slice(2).join(".") || n[n.length - 1];
|
|
1534
1220
|
let a = this.doctype;
|
|
1535
|
-
this.doctype === "StonecropStore" &&
|
|
1221
|
+
this.doctype === "StonecropStore" && n.length >= 1 && (a = n[0]);
|
|
1536
1222
|
let c;
|
|
1537
|
-
|
|
1538
|
-
const
|
|
1223
|
+
n.length >= 2 && (c = n[1]);
|
|
1224
|
+
const d = {
|
|
1539
1225
|
path: e,
|
|
1540
|
-
fieldname:
|
|
1226
|
+
fieldname: s,
|
|
1541
1227
|
beforeValue: t,
|
|
1542
1228
|
afterValue: r,
|
|
1543
1229
|
operation: "set",
|
|
@@ -1547,9 +1233,9 @@ class Se {
|
|
|
1547
1233
|
store: this.rootNode || void 0
|
|
1548
1234
|
// Pass the root store for snapshot/rollback capabilities
|
|
1549
1235
|
};
|
|
1550
|
-
await
|
|
1551
|
-
} catch (
|
|
1552
|
-
|
|
1236
|
+
await i.executeFieldTriggers(d);
|
|
1237
|
+
} catch (n) {
|
|
1238
|
+
n instanceof Error && console.warn("Field trigger error:", n.message);
|
|
1553
1239
|
}
|
|
1554
1240
|
}
|
|
1555
1241
|
isVueReactive(e) {
|
|
@@ -1561,19 +1247,19 @@ class Se {
|
|
|
1561
1247
|
isImmutable(e) {
|
|
1562
1248
|
if (!e || typeof e != "object")
|
|
1563
1249
|
return !1;
|
|
1564
|
-
const t = "get" in e && typeof e.get == "function", r = "set" in e && typeof e.set == "function",
|
|
1565
|
-
let
|
|
1250
|
+
const t = "get" in e && typeof e.get == "function", r = "set" in e && typeof e.set == "function", n = "has" in e && typeof e.has == "function", i = "__ownerID" in e || "_map" in e || "_list" in e || "_origin" in e || "_capacity" in e || "_defaultValues" in e || "_tail" in e || "_root" in e || "size" in e && t && r;
|
|
1251
|
+
let s;
|
|
1566
1252
|
try {
|
|
1567
1253
|
const c = e;
|
|
1568
1254
|
if ("constructor" in c && c.constructor && typeof c.constructor == "object" && "name" in c.constructor) {
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1255
|
+
const d = c.constructor.name;
|
|
1256
|
+
s = typeof d == "string" ? d : void 0;
|
|
1571
1257
|
}
|
|
1572
1258
|
} catch {
|
|
1573
|
-
|
|
1259
|
+
s = void 0;
|
|
1574
1260
|
}
|
|
1575
|
-
const a =
|
|
1576
|
-
return !!(t && r &&
|
|
1261
|
+
const a = s && (s.includes("Map") || s.includes("List") || s.includes("Set") || s.includes("Stack") || s.includes("Seq")) && (t || r);
|
|
1262
|
+
return !!(t && r && n && i || t && r && a);
|
|
1577
1263
|
}
|
|
1578
1264
|
isPrimitive(e) {
|
|
1579
1265
|
return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
|
|
@@ -1587,10 +1273,10 @@ class Se {
|
|
|
1587
1273
|
return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((r) => r.length > 0) : [];
|
|
1588
1274
|
}
|
|
1589
1275
|
}
|
|
1590
|
-
function
|
|
1591
|
-
return new
|
|
1276
|
+
function et(o, e, t) {
|
|
1277
|
+
return new se(o, e, "", null, t);
|
|
1592
1278
|
}
|
|
1593
|
-
class
|
|
1279
|
+
class Ae {
|
|
1594
1280
|
hstStore;
|
|
1595
1281
|
_operationLogStore;
|
|
1596
1282
|
_operationLogConfig;
|
|
@@ -1609,7 +1295,7 @@ class Ke {
|
|
|
1609
1295
|
* @internal
|
|
1610
1296
|
*/
|
|
1611
1297
|
getOperationLogStore() {
|
|
1612
|
-
return this._operationLogStore || (this._operationLogStore =
|
|
1298
|
+
return this._operationLogStore || (this._operationLogStore = re(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
|
|
1613
1299
|
}
|
|
1614
1300
|
/**
|
|
1615
1301
|
* Initialize the HST store structure
|
|
@@ -1618,7 +1304,7 @@ class Ke {
|
|
|
1618
1304
|
const e = {};
|
|
1619
1305
|
Object.keys(this.registry.registry).forEach((t) => {
|
|
1620
1306
|
e[t] = {};
|
|
1621
|
-
}), this.hstStore =
|
|
1307
|
+
}), this.hstStore = et(ue(e), "StonecropStore");
|
|
1622
1308
|
}
|
|
1623
1309
|
/**
|
|
1624
1310
|
* Setup automatic sync with Registry when doctypes are added
|
|
@@ -1645,8 +1331,8 @@ class Ke {
|
|
|
1645
1331
|
* @param recordData - The record data
|
|
1646
1332
|
*/
|
|
1647
1333
|
addRecord(e, t, r) {
|
|
1648
|
-
const
|
|
1649
|
-
this.ensureDoctypeExists(
|
|
1334
|
+
const n = typeof e == "string" ? e : e.slug;
|
|
1335
|
+
this.ensureDoctypeExists(n), this.hstStore.set(`${n}.${t}`, r);
|
|
1650
1336
|
}
|
|
1651
1337
|
/**
|
|
1652
1338
|
* Get a specific record
|
|
@@ -1677,7 +1363,7 @@ class Ke {
|
|
|
1677
1363
|
const t = typeof e == "string" ? e : e.slug;
|
|
1678
1364
|
this.ensureDoctypeExists(t);
|
|
1679
1365
|
const r = this.hstStore.get(t);
|
|
1680
|
-
return !r || typeof r != "object" ? [] : Object.keys(r).filter((
|
|
1366
|
+
return !r || typeof r != "object" ? [] : Object.keys(r).filter((n) => r[n] !== void 0);
|
|
1681
1367
|
}
|
|
1682
1368
|
/**
|
|
1683
1369
|
* Clear all records for a doctype
|
|
@@ -1685,8 +1371,8 @@ class Ke {
|
|
|
1685
1371
|
*/
|
|
1686
1372
|
clearRecords(e) {
|
|
1687
1373
|
const t = typeof e == "string" ? e : e.slug;
|
|
1688
|
-
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((
|
|
1689
|
-
this.hstStore.set(`${t}.${
|
|
1374
|
+
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((n) => {
|
|
1375
|
+
this.hstStore.set(`${t}.${n}`, void 0);
|
|
1690
1376
|
});
|
|
1691
1377
|
}
|
|
1692
1378
|
/**
|
|
@@ -1704,19 +1390,19 @@ class Ke {
|
|
|
1704
1390
|
* @param args - Action arguments (typically record IDs)
|
|
1705
1391
|
*/
|
|
1706
1392
|
runAction(e, t, r) {
|
|
1707
|
-
const
|
|
1708
|
-
let c = "success",
|
|
1393
|
+
const i = this.registry.registry[e.slug]?.actions?.get(t), s = Array.isArray(r) ? r.filter((g) => typeof g == "string") : void 0, a = this.getOperationLogStore();
|
|
1394
|
+
let c = "success", d;
|
|
1709
1395
|
try {
|
|
1710
|
-
|
|
1396
|
+
i && i.length > 0 && i.forEach((g) => {
|
|
1711
1397
|
try {
|
|
1712
1398
|
new Function("args", g)(r);
|
|
1713
|
-
} catch (
|
|
1714
|
-
throw c = "failure",
|
|
1399
|
+
} catch (S) {
|
|
1400
|
+
throw c = "failure", d = S instanceof Error ? S.message : "Unknown error", S;
|
|
1715
1401
|
}
|
|
1716
1402
|
});
|
|
1717
1403
|
} catch {
|
|
1718
1404
|
} finally {
|
|
1719
|
-
a.logAction(e.doctype, t,
|
|
1405
|
+
a.logAction(e.doctype, t, s, c, d);
|
|
1720
1406
|
}
|
|
1721
1407
|
}
|
|
1722
1408
|
/**
|
|
@@ -1724,8 +1410,8 @@ class Ke {
|
|
|
1724
1410
|
* @param doctype - The doctype
|
|
1725
1411
|
*/
|
|
1726
1412
|
async getRecords(e) {
|
|
1727
|
-
(await (await fetch(`/${e.slug}`)).json()).forEach((
|
|
1728
|
-
|
|
1413
|
+
(await (await fetch(`/${e.slug}`)).json()).forEach((n) => {
|
|
1414
|
+
n.id && this.addRecord(e, n.id, n);
|
|
1729
1415
|
});
|
|
1730
1416
|
}
|
|
1731
1417
|
/**
|
|
@@ -1734,8 +1420,8 @@ class Ke {
|
|
|
1734
1420
|
* @param recordId - The record ID
|
|
1735
1421
|
*/
|
|
1736
1422
|
async getRecord(e, t) {
|
|
1737
|
-
const
|
|
1738
|
-
this.addRecord(e, t,
|
|
1423
|
+
const n = await (await fetch(`/${e.slug}/${t}`)).json();
|
|
1424
|
+
this.addRecord(e, t, n);
|
|
1739
1425
|
}
|
|
1740
1426
|
/**
|
|
1741
1427
|
* Ensure doctype section exists in HST store
|
|
@@ -1762,14 +1448,14 @@ class Ke {
|
|
|
1762
1448
|
return this.hstStore;
|
|
1763
1449
|
}
|
|
1764
1450
|
}
|
|
1765
|
-
function
|
|
1766
|
-
|
|
1767
|
-
const e =
|
|
1768
|
-
if (
|
|
1769
|
-
const
|
|
1770
|
-
c.value = e.resolveSchema(
|
|
1771
|
-
}
|
|
1772
|
-
const
|
|
1451
|
+
function pt(o) {
|
|
1452
|
+
o || (o = {});
|
|
1453
|
+
const e = o.registry || fe("$registry"), t = fe("$stonecrop"), r = L(), n = L(), i = L({}), s = L(), a = L(), c = L([]);
|
|
1454
|
+
if (o.doctype && e) {
|
|
1455
|
+
const p = o.doctype.schema ? Array.isArray(o.doctype.schema) ? o.doctype.schema : Array.from(o.doctype.schema) : [];
|
|
1456
|
+
c.value = e.resolveSchema(p);
|
|
1457
|
+
}
|
|
1458
|
+
const d = L([]), g = L(-1), S = B(() => r.value?.getOperationLogStore().canUndo ?? !1), $ = B(() => r.value?.getOperationLogStore().canRedo ?? !1), k = B(() => r.value?.getOperationLogStore().undoCount ?? 0), x = B(() => r.value?.getOperationLogStore().redoCount ?? 0), F = B(
|
|
1773
1459
|
() => r.value?.getOperationLogStore().undoRedoState ?? {
|
|
1774
1460
|
canUndo: !1,
|
|
1775
1461
|
canRedo: !1,
|
|
@@ -1777,204 +1463,204 @@ function jt(n) {
|
|
|
1777
1463
|
redoCount: 0,
|
|
1778
1464
|
currentIndex: -1
|
|
1779
1465
|
}
|
|
1780
|
-
),
|
|
1466
|
+
), R = (p) => r.value?.getOperationLogStore().undo(p) ?? !1, O = (p) => r.value?.getOperationLogStore().redo(p) ?? !1, w = () => {
|
|
1781
1467
|
r.value?.getOperationLogStore().startBatch();
|
|
1782
|
-
},
|
|
1468
|
+
}, h = (p) => r.value?.getOperationLogStore().commitBatch(p) ?? null, E = () => {
|
|
1783
1469
|
r.value?.getOperationLogStore().cancelBatch();
|
|
1784
|
-
},
|
|
1470
|
+
}, b = () => {
|
|
1785
1471
|
r.value?.getOperationLogStore().clear();
|
|
1786
|
-
},
|
|
1472
|
+
}, A = (p, m) => r.value?.getOperationLogStore().getOperationsFor(p, m) ?? [], C = () => r.value?.getOperationLogStore().getSnapshot() ?? {
|
|
1787
1473
|
operations: [],
|
|
1788
1474
|
currentIndex: -1,
|
|
1789
1475
|
totalOperations: 0,
|
|
1790
1476
|
reversibleOperations: 0,
|
|
1791
1477
|
irreversibleOperations: 0
|
|
1792
|
-
},
|
|
1793
|
-
r.value?.getOperationLogStore().markIrreversible(
|
|
1794
|
-
},
|
|
1795
|
-
r.value?.getOperationLogStore().configure(
|
|
1478
|
+
}, M = (p, m) => {
|
|
1479
|
+
r.value?.getOperationLogStore().markIrreversible(p, m);
|
|
1480
|
+
}, W = (p, m, y, u = "success", l) => r.value?.getOperationLogStore().logAction(p, m, y, u, l) ?? "", N = (p) => {
|
|
1481
|
+
r.value?.getOperationLogStore().configure(p);
|
|
1796
1482
|
};
|
|
1797
|
-
|
|
1483
|
+
me(async () => {
|
|
1798
1484
|
if (e) {
|
|
1799
|
-
r.value = t || new
|
|
1485
|
+
r.value = t || new Ae(e);
|
|
1800
1486
|
try {
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
() =>
|
|
1804
|
-
(
|
|
1805
|
-
|
|
1487
|
+
const p = r.value.getOperationLogStore(), m = be(p);
|
|
1488
|
+
d.value = m.operations.value, g.value = m.currentIndex.value, U(
|
|
1489
|
+
() => m.operations.value,
|
|
1490
|
+
(y) => {
|
|
1491
|
+
d.value = y;
|
|
1806
1492
|
}
|
|
1807
1493
|
), U(
|
|
1808
|
-
() =>
|
|
1809
|
-
(
|
|
1810
|
-
g.value =
|
|
1494
|
+
() => m.currentIndex.value,
|
|
1495
|
+
(y) => {
|
|
1496
|
+
g.value = y;
|
|
1811
1497
|
}
|
|
1812
1498
|
);
|
|
1813
1499
|
} catch {
|
|
1814
1500
|
}
|
|
1815
|
-
if (!
|
|
1816
|
-
const
|
|
1817
|
-
if (!
|
|
1818
|
-
const
|
|
1819
|
-
if (
|
|
1501
|
+
if (!o.doctype && e.router) {
|
|
1502
|
+
const p = e.router.currentRoute.value;
|
|
1503
|
+
if (!p.path) return;
|
|
1504
|
+
const m = p.path.split("/").filter((u) => u.length > 0), y = m[1]?.toLowerCase();
|
|
1505
|
+
if (m.length > 0) {
|
|
1820
1506
|
const u = {
|
|
1821
|
-
path:
|
|
1822
|
-
segments:
|
|
1507
|
+
path: p.path,
|
|
1508
|
+
segments: m
|
|
1823
1509
|
}, l = await e.getMeta?.(u);
|
|
1824
1510
|
if (l) {
|
|
1825
|
-
if (e.addDoctype(l), r.value.setup(l),
|
|
1826
|
-
const
|
|
1827
|
-
c.value = e.resolveSchema(
|
|
1511
|
+
if (e.addDoctype(l), r.value.setup(l), s.value = l, a.value = y, n.value = r.value.getStore(), e) {
|
|
1512
|
+
const f = l.schema ? Array.isArray(l.schema) ? l.schema : Array.from(l.schema) : [];
|
|
1513
|
+
c.value = e.resolveSchema(f);
|
|
1828
1514
|
}
|
|
1829
|
-
if (
|
|
1830
|
-
const
|
|
1831
|
-
if (
|
|
1832
|
-
|
|
1515
|
+
if (y && y !== "new") {
|
|
1516
|
+
const f = r.value.getRecordById(l, y);
|
|
1517
|
+
if (f)
|
|
1518
|
+
i.value = f.get("") || {};
|
|
1833
1519
|
else
|
|
1834
1520
|
try {
|
|
1835
|
-
await r.value.getRecord(l,
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1521
|
+
await r.value.getRecord(l, y);
|
|
1522
|
+
const T = r.value.getRecordById(l, y);
|
|
1523
|
+
T && (i.value = T.get("") || {});
|
|
1838
1524
|
} catch {
|
|
1839
|
-
|
|
1525
|
+
i.value = z(l);
|
|
1840
1526
|
}
|
|
1841
1527
|
} else
|
|
1842
|
-
|
|
1843
|
-
|
|
1528
|
+
i.value = z(l);
|
|
1529
|
+
n.value && ve(l, y || "new", i, n.value), r.value.runAction(l, "load", y ? [y] : void 0);
|
|
1844
1530
|
}
|
|
1845
1531
|
}
|
|
1846
1532
|
}
|
|
1847
|
-
if (
|
|
1848
|
-
|
|
1849
|
-
const
|
|
1850
|
-
if (
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1853
|
-
|
|
1533
|
+
if (o.doctype) {
|
|
1534
|
+
n.value = r.value.getStore();
|
|
1535
|
+
const p = o.doctype, m = o.recordId;
|
|
1536
|
+
if (m && m !== "new") {
|
|
1537
|
+
const y = r.value.getRecordById(p, m);
|
|
1538
|
+
if (y)
|
|
1539
|
+
i.value = y.get("") || {};
|
|
1854
1540
|
else
|
|
1855
1541
|
try {
|
|
1856
|
-
await r.value.getRecord(
|
|
1857
|
-
const u = r.value.getRecordById(
|
|
1858
|
-
u && (
|
|
1542
|
+
await r.value.getRecord(p, m);
|
|
1543
|
+
const u = r.value.getRecordById(p, m);
|
|
1544
|
+
u && (i.value = u.get("") || {});
|
|
1859
1545
|
} catch {
|
|
1860
|
-
|
|
1546
|
+
i.value = z(p);
|
|
1861
1547
|
}
|
|
1862
1548
|
} else
|
|
1863
|
-
|
|
1864
|
-
|
|
1549
|
+
i.value = z(p);
|
|
1550
|
+
n.value && ve(p, m || "new", i, n.value);
|
|
1865
1551
|
}
|
|
1866
1552
|
}
|
|
1867
1553
|
});
|
|
1868
|
-
const
|
|
1869
|
-
const
|
|
1870
|
-
if (!
|
|
1871
|
-
const u =
|
|
1872
|
-
return `${
|
|
1873
|
-
},
|
|
1874
|
-
const
|
|
1875
|
-
if (!(!
|
|
1554
|
+
const q = (p, m) => {
|
|
1555
|
+
const y = o.doctype || s.value;
|
|
1556
|
+
if (!y) return "";
|
|
1557
|
+
const u = m || o.recordId || a.value || "new";
|
|
1558
|
+
return `${y.slug}.${u}.${p}`;
|
|
1559
|
+
}, _ = (p) => {
|
|
1560
|
+
const m = o.doctype || s.value;
|
|
1561
|
+
if (!(!n.value || !r.value || !m))
|
|
1876
1562
|
try {
|
|
1877
|
-
const
|
|
1878
|
-
if (
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1881
|
-
const
|
|
1882
|
-
let
|
|
1883
|
-
for (let
|
|
1884
|
-
if (
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1563
|
+
const y = p.path.split(".");
|
|
1564
|
+
if (y.length >= 2) {
|
|
1565
|
+
const f = y[0], T = y[1];
|
|
1566
|
+
if (n.value.has(`${f}.${T}`) || r.value.addRecord(m, T, { ...i.value }), y.length > 3) {
|
|
1567
|
+
const V = `${f}.${T}`, I = y.slice(2);
|
|
1568
|
+
let K = V;
|
|
1569
|
+
for (let Z = 0; Z < I.length - 1; Z++)
|
|
1570
|
+
if (K += `.${I[Z]}`, !n.value.has(K)) {
|
|
1571
|
+
const ae = I[Z + 1], $e = !isNaN(Number(ae));
|
|
1572
|
+
n.value.set(K, $e ? [] : {});
|
|
1887
1573
|
}
|
|
1888
1574
|
}
|
|
1889
1575
|
}
|
|
1890
|
-
|
|
1891
|
-
const u =
|
|
1892
|
-
u.length === 1 ? l[u[0]] =
|
|
1576
|
+
n.value.set(p.path, p.value);
|
|
1577
|
+
const u = p.fieldname.split("."), l = { ...i.value };
|
|
1578
|
+
u.length === 1 ? l[u[0]] = p.value : tt(l, u, p.value), i.value = l;
|
|
1893
1579
|
} catch {
|
|
1894
1580
|
}
|
|
1895
1581
|
};
|
|
1896
|
-
(
|
|
1897
|
-
const
|
|
1582
|
+
(o.doctype || e?.router) && (pe("hstPathProvider", q), pe("hstChangeHandler", _));
|
|
1583
|
+
const G = (p, m, y) => {
|
|
1898
1584
|
if (!r.value)
|
|
1899
|
-
return
|
|
1900
|
-
if (
|
|
1585
|
+
return z(m);
|
|
1586
|
+
if (y)
|
|
1901
1587
|
try {
|
|
1902
|
-
const u =
|
|
1903
|
-
return u && typeof u == "object" ? u :
|
|
1588
|
+
const u = n.value?.get(p);
|
|
1589
|
+
return u && typeof u == "object" ? u : z(m);
|
|
1904
1590
|
} catch {
|
|
1905
|
-
return
|
|
1591
|
+
return z(m);
|
|
1906
1592
|
}
|
|
1907
|
-
return
|
|
1908
|
-
},
|
|
1909
|
-
if (!
|
|
1593
|
+
return z(m);
|
|
1594
|
+
}, v = async (p, m) => {
|
|
1595
|
+
if (!n.value || !r.value)
|
|
1910
1596
|
throw new Error("HST store not initialized");
|
|
1911
|
-
const
|
|
1912
|
-
(
|
|
1597
|
+
const y = `${p.slug}.${m}`, l = { ...n.value.get(y) || {} }, f = p.schema ? Array.isArray(p.schema) ? p.schema : Array.from(p.schema) : [], V = (e ? e.resolveSchema(f) : f).filter(
|
|
1598
|
+
(I) => "fieldtype" in I && I.fieldtype === "Doctype" && "schema" in I && Array.isArray(I.schema)
|
|
1913
1599
|
);
|
|
1914
|
-
for (const
|
|
1915
|
-
const
|
|
1916
|
-
l[
|
|
1600
|
+
for (const I of V) {
|
|
1601
|
+
const K = I, Z = `${y}.${K.fieldname}`, ae = Oe(K.schema, Z, n.value);
|
|
1602
|
+
l[K.fieldname] = ae;
|
|
1917
1603
|
}
|
|
1918
1604
|
return l;
|
|
1919
|
-
},
|
|
1920
|
-
provideHSTPath: (l) => `${
|
|
1605
|
+
}, P = (p, m) => ({
|
|
1606
|
+
provideHSTPath: (l) => `${p}.${l}`,
|
|
1921
1607
|
handleHSTChange: (l) => {
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1608
|
+
const f = l.path.startsWith(p) ? l.path : `${p}.${l.fieldname}`;
|
|
1609
|
+
_({
|
|
1924
1610
|
...l,
|
|
1925
|
-
path:
|
|
1611
|
+
path: f
|
|
1926
1612
|
});
|
|
1927
1613
|
}
|
|
1928
|
-
}),
|
|
1929
|
-
operations:
|
|
1614
|
+
}), D = {
|
|
1615
|
+
operations: d,
|
|
1930
1616
|
currentIndex: g,
|
|
1931
|
-
undoRedoState:
|
|
1932
|
-
canUndo:
|
|
1933
|
-
canRedo:
|
|
1934
|
-
undoCount:
|
|
1935
|
-
redoCount:
|
|
1936
|
-
undo:
|
|
1937
|
-
redo:
|
|
1938
|
-
startBatch:
|
|
1939
|
-
commitBatch:
|
|
1940
|
-
cancelBatch:
|
|
1941
|
-
clear:
|
|
1942
|
-
getOperationsFor:
|
|
1943
|
-
getSnapshot:
|
|
1944
|
-
markIrreversible:
|
|
1945
|
-
logAction:
|
|
1946
|
-
configure:
|
|
1617
|
+
undoRedoState: F,
|
|
1618
|
+
canUndo: S,
|
|
1619
|
+
canRedo: $,
|
|
1620
|
+
undoCount: k,
|
|
1621
|
+
redoCount: x,
|
|
1622
|
+
undo: R,
|
|
1623
|
+
redo: O,
|
|
1624
|
+
startBatch: w,
|
|
1625
|
+
commitBatch: h,
|
|
1626
|
+
cancelBatch: E,
|
|
1627
|
+
clear: b,
|
|
1628
|
+
getOperationsFor: A,
|
|
1629
|
+
getSnapshot: C,
|
|
1630
|
+
markIrreversible: M,
|
|
1631
|
+
logAction: W,
|
|
1632
|
+
configure: N
|
|
1947
1633
|
};
|
|
1948
|
-
return
|
|
1634
|
+
return o.doctype ? {
|
|
1949
1635
|
stonecrop: r,
|
|
1950
|
-
operationLog:
|
|
1951
|
-
provideHSTPath:
|
|
1952
|
-
handleHSTChange:
|
|
1953
|
-
hstStore:
|
|
1954
|
-
formData:
|
|
1636
|
+
operationLog: D,
|
|
1637
|
+
provideHSTPath: q,
|
|
1638
|
+
handleHSTChange: _,
|
|
1639
|
+
hstStore: n,
|
|
1640
|
+
formData: i,
|
|
1955
1641
|
resolvedSchema: c,
|
|
1956
|
-
loadNestedData:
|
|
1957
|
-
saveRecursive:
|
|
1958
|
-
createNestedContext:
|
|
1959
|
-
} : !
|
|
1642
|
+
loadNestedData: G,
|
|
1643
|
+
saveRecursive: v,
|
|
1644
|
+
createNestedContext: P
|
|
1645
|
+
} : !o.doctype && e?.router ? {
|
|
1960
1646
|
stonecrop: r,
|
|
1961
|
-
operationLog:
|
|
1962
|
-
provideHSTPath:
|
|
1963
|
-
handleHSTChange:
|
|
1964
|
-
hstStore:
|
|
1965
|
-
formData:
|
|
1647
|
+
operationLog: D,
|
|
1648
|
+
provideHSTPath: q,
|
|
1649
|
+
handleHSTChange: _,
|
|
1650
|
+
hstStore: n,
|
|
1651
|
+
formData: i,
|
|
1966
1652
|
resolvedSchema: c,
|
|
1967
|
-
loadNestedData:
|
|
1968
|
-
saveRecursive:
|
|
1969
|
-
createNestedContext:
|
|
1653
|
+
loadNestedData: G,
|
|
1654
|
+
saveRecursive: v,
|
|
1655
|
+
createNestedContext: P
|
|
1970
1656
|
} : {
|
|
1971
1657
|
stonecrop: r,
|
|
1972
|
-
operationLog:
|
|
1658
|
+
operationLog: D
|
|
1973
1659
|
};
|
|
1974
1660
|
}
|
|
1975
|
-
function
|
|
1661
|
+
function z(o) {
|
|
1976
1662
|
const e = {};
|
|
1977
|
-
return
|
|
1663
|
+
return o.schema && o.schema.forEach((t) => {
|
|
1978
1664
|
switch ("fieldtype" in t ? t.fieldtype : "Data") {
|
|
1979
1665
|
case "Data":
|
|
1980
1666
|
case "Text":
|
|
@@ -1998,15 +1684,15 @@ function J(n) {
|
|
|
1998
1684
|
}
|
|
1999
1685
|
}), e;
|
|
2000
1686
|
}
|
|
2001
|
-
function
|
|
1687
|
+
function ve(o, e, t, r) {
|
|
2002
1688
|
U(
|
|
2003
1689
|
t,
|
|
2004
|
-
(
|
|
2005
|
-
const
|
|
2006
|
-
Object.keys(
|
|
2007
|
-
const a = `${
|
|
1690
|
+
(n) => {
|
|
1691
|
+
const i = `${o.slug}.${e}`;
|
|
1692
|
+
Object.keys(n).forEach((s) => {
|
|
1693
|
+
const a = `${i}.${s}`;
|
|
2008
1694
|
try {
|
|
2009
|
-
r.set(a,
|
|
1695
|
+
r.set(a, n[s]);
|
|
2010
1696
|
} catch {
|
|
2011
1697
|
}
|
|
2012
1698
|
});
|
|
@@ -2014,110 +1700,110 @@ function xe(n, e, t, r) {
|
|
|
2014
1700
|
{ deep: !0 }
|
|
2015
1701
|
);
|
|
2016
1702
|
}
|
|
2017
|
-
function
|
|
2018
|
-
let r =
|
|
2019
|
-
for (let
|
|
2020
|
-
const
|
|
2021
|
-
(!(
|
|
2022
|
-
}
|
|
2023
|
-
const
|
|
2024
|
-
r[
|
|
1703
|
+
function tt(o, e, t) {
|
|
1704
|
+
let r = o;
|
|
1705
|
+
for (let i = 0; i < e.length - 1; i++) {
|
|
1706
|
+
const s = e[i];
|
|
1707
|
+
(!(s in r) || typeof r[s] != "object") && (r[s] = isNaN(Number(e[i + 1])) ? {} : []), r = r[s];
|
|
1708
|
+
}
|
|
1709
|
+
const n = e[e.length - 1];
|
|
1710
|
+
r[n] = t;
|
|
2025
1711
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const
|
|
2028
|
-
(
|
|
1712
|
+
function Oe(o, e, t) {
|
|
1713
|
+
const n = { ...t.get(e) || {} }, i = o.filter(
|
|
1714
|
+
(s) => "fieldtype" in s && s.fieldtype === "Doctype" && "schema" in s && Array.isArray(s.schema)
|
|
2029
1715
|
);
|
|
2030
|
-
for (const
|
|
2031
|
-
const a =
|
|
2032
|
-
|
|
1716
|
+
for (const s of i) {
|
|
1717
|
+
const a = s, c = `${e}.${a.fieldname}`, d = Oe(a.schema, c, t);
|
|
1718
|
+
n[a.fieldname] = d;
|
|
2033
1719
|
}
|
|
2034
|
-
return
|
|
1720
|
+
return n;
|
|
2035
1721
|
}
|
|
2036
|
-
function
|
|
2037
|
-
const t =
|
|
2038
|
-
|
|
2039
|
-
const { operations: r, currentIndex:
|
|
2040
|
-
function g(
|
|
2041
|
-
return t.undo(
|
|
1722
|
+
function Te(o) {
|
|
1723
|
+
const t = fe("$operationLogStore", void 0) || re();
|
|
1724
|
+
o && t.configure(o);
|
|
1725
|
+
const { operations: r, currentIndex: n, undoRedoState: i, canUndo: s, canRedo: a, undoCount: c, redoCount: d } = be(t);
|
|
1726
|
+
function g(b) {
|
|
1727
|
+
return t.undo(b);
|
|
2042
1728
|
}
|
|
2043
|
-
function b
|
|
2044
|
-
return t.redo(
|
|
1729
|
+
function S(b) {
|
|
1730
|
+
return t.redo(b);
|
|
2045
1731
|
}
|
|
2046
|
-
function
|
|
1732
|
+
function $() {
|
|
2047
1733
|
t.startBatch();
|
|
2048
1734
|
}
|
|
2049
|
-
function
|
|
2050
|
-
return t.commitBatch(
|
|
1735
|
+
function k(b) {
|
|
1736
|
+
return t.commitBatch(b);
|
|
2051
1737
|
}
|
|
2052
|
-
function
|
|
1738
|
+
function x() {
|
|
2053
1739
|
t.cancelBatch();
|
|
2054
1740
|
}
|
|
2055
|
-
function
|
|
1741
|
+
function F() {
|
|
2056
1742
|
t.clear();
|
|
2057
1743
|
}
|
|
2058
|
-
function
|
|
2059
|
-
return t.getOperationsFor(
|
|
1744
|
+
function R(b, A) {
|
|
1745
|
+
return t.getOperationsFor(b, A);
|
|
2060
1746
|
}
|
|
2061
|
-
function
|
|
1747
|
+
function O() {
|
|
2062
1748
|
return t.getSnapshot();
|
|
2063
1749
|
}
|
|
2064
|
-
function
|
|
2065
|
-
t.markIrreversible(
|
|
1750
|
+
function w(b, A) {
|
|
1751
|
+
t.markIrreversible(b, A);
|
|
2066
1752
|
}
|
|
2067
|
-
function
|
|
2068
|
-
return t.logAction(
|
|
1753
|
+
function h(b, A, C, M = "success", W) {
|
|
1754
|
+
return t.logAction(b, A, C, M, W);
|
|
2069
1755
|
}
|
|
2070
|
-
function
|
|
2071
|
-
t.configure(
|
|
1756
|
+
function E(b) {
|
|
1757
|
+
t.configure(b);
|
|
2072
1758
|
}
|
|
2073
1759
|
return {
|
|
2074
1760
|
// State
|
|
2075
1761
|
operations: r,
|
|
2076
|
-
currentIndex:
|
|
2077
|
-
undoRedoState:
|
|
2078
|
-
canUndo:
|
|
1762
|
+
currentIndex: n,
|
|
1763
|
+
undoRedoState: i,
|
|
1764
|
+
canUndo: s,
|
|
2079
1765
|
canRedo: a,
|
|
2080
1766
|
undoCount: c,
|
|
2081
|
-
redoCount:
|
|
1767
|
+
redoCount: d,
|
|
2082
1768
|
// Methods
|
|
2083
1769
|
undo: g,
|
|
2084
|
-
redo:
|
|
2085
|
-
startBatch:
|
|
2086
|
-
commitBatch:
|
|
2087
|
-
cancelBatch:
|
|
2088
|
-
clear:
|
|
2089
|
-
getOperationsFor:
|
|
2090
|
-
getSnapshot:
|
|
2091
|
-
markIrreversible:
|
|
2092
|
-
logAction:
|
|
2093
|
-
configure:
|
|
1770
|
+
redo: S,
|
|
1771
|
+
startBatch: $,
|
|
1772
|
+
commitBatch: k,
|
|
1773
|
+
cancelBatch: x,
|
|
1774
|
+
clear: F,
|
|
1775
|
+
getOperationsFor: R,
|
|
1776
|
+
getSnapshot: O,
|
|
1777
|
+
markIrreversible: w,
|
|
1778
|
+
logAction: h,
|
|
1779
|
+
configure: E
|
|
2094
1780
|
};
|
|
2095
1781
|
}
|
|
2096
|
-
function
|
|
1782
|
+
function ht(o, e = !0) {
|
|
2097
1783
|
if (!e) return;
|
|
2098
|
-
const { undo: t, redo: r, canUndo:
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
}),
|
|
2102
|
-
|
|
2103
|
-
}),
|
|
2104
|
-
|
|
2105
|
-
}),
|
|
2106
|
-
|
|
2107
|
-
}),
|
|
2108
|
-
|
|
1784
|
+
const { undo: t, redo: r, canUndo: n, canRedo: i } = Te(), s = Ye();
|
|
1785
|
+
X(s["Ctrl+Z"], () => {
|
|
1786
|
+
n.value && t(o);
|
|
1787
|
+
}), X(s["Meta+Z"], () => {
|
|
1788
|
+
n.value && t(o);
|
|
1789
|
+
}), X(s["Ctrl+Shift+Z"], () => {
|
|
1790
|
+
i.value && r(o);
|
|
1791
|
+
}), X(s["Meta+Shift+Z"], () => {
|
|
1792
|
+
i.value && r(o);
|
|
1793
|
+
}), X(s["Ctrl+Y"], () => {
|
|
1794
|
+
i.value && r(o);
|
|
2109
1795
|
});
|
|
2110
1796
|
}
|
|
2111
|
-
async function
|
|
2112
|
-
const { startBatch: t, commitBatch: r, cancelBatch:
|
|
1797
|
+
async function gt(o, e) {
|
|
1798
|
+
const { startBatch: t, commitBatch: r, cancelBatch: n } = Te();
|
|
2113
1799
|
t();
|
|
2114
1800
|
try {
|
|
2115
|
-
return await
|
|
2116
|
-
} catch (
|
|
2117
|
-
throw
|
|
1801
|
+
return await o(), r(e);
|
|
1802
|
+
} catch (i) {
|
|
1803
|
+
throw n(), i;
|
|
2118
1804
|
}
|
|
2119
1805
|
}
|
|
2120
|
-
class
|
|
1806
|
+
class vt {
|
|
2121
1807
|
/**
|
|
2122
1808
|
* The doctype name
|
|
2123
1809
|
* @public
|
|
@@ -2156,8 +1842,8 @@ class zt {
|
|
|
2156
1842
|
* @param actions - The doctype actions and field triggers
|
|
2157
1843
|
* @param component - Optional Vue component for rendering the doctype
|
|
2158
1844
|
*/
|
|
2159
|
-
constructor(e, t, r,
|
|
2160
|
-
this.doctype = e, this.schema = t, this.workflow = r, this.actions =
|
|
1845
|
+
constructor(e, t, r, n, i) {
|
|
1846
|
+
this.doctype = e, this.schema = t, this.workflow = r, this.actions = n, this.component = i;
|
|
2161
1847
|
}
|
|
2162
1848
|
/**
|
|
2163
1849
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
@@ -2179,7 +1865,7 @@ class zt {
|
|
|
2179
1865
|
return this.doctype.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
2180
1866
|
}
|
|
2181
1867
|
}
|
|
2182
|
-
class
|
|
1868
|
+
class te {
|
|
2183
1869
|
/**
|
|
2184
1870
|
* The root Registry instance
|
|
2185
1871
|
*/
|
|
@@ -2206,9 +1892,9 @@ class fe {
|
|
|
2206
1892
|
* @param getMeta - Optional function to fetch doctype metadata from an API
|
|
2207
1893
|
*/
|
|
2208
1894
|
constructor(e, t) {
|
|
2209
|
-
if (
|
|
2210
|
-
return
|
|
2211
|
-
|
|
1895
|
+
if (te._root)
|
|
1896
|
+
return te._root;
|
|
1897
|
+
te._root = this, this.name = "Registry", this.registry = {}, this.router = e, this.getMeta = t;
|
|
2212
1898
|
}
|
|
2213
1899
|
/**
|
|
2214
1900
|
* The getMeta function fetches doctype metadata from an API based on route context
|
|
@@ -2223,7 +1909,7 @@ class fe {
|
|
|
2223
1909
|
*/
|
|
2224
1910
|
addDoctype(e) {
|
|
2225
1911
|
e.doctype in Object.keys(this.registry) || (this.registry[e.slug] = e);
|
|
2226
|
-
const t =
|
|
1912
|
+
const t = J();
|
|
2227
1913
|
t.registerDoctypeActions(e.doctype, e.actions), e.slug !== e.doctype && t.registerDoctypeActions(e.slug, e.actions), e.component && this.router && !this.router.hasRoute(e.doctype) && this.router.addRoute({
|
|
2228
1914
|
path: `/${e.slug}`,
|
|
2229
1915
|
name: e.slug,
|
|
@@ -2262,38 +1948,38 @@ class fe {
|
|
|
2262
1948
|
*/
|
|
2263
1949
|
resolveSchema(e, t) {
|
|
2264
1950
|
const r = t || /* @__PURE__ */ new Set();
|
|
2265
|
-
return e.map((
|
|
2266
|
-
if ("fieldtype" in
|
|
2267
|
-
const
|
|
2268
|
-
if (r.has(
|
|
2269
|
-
return { ...
|
|
2270
|
-
const
|
|
2271
|
-
if (
|
|
2272
|
-
const a = Array.isArray(
|
|
2273
|
-
r.add(
|
|
1951
|
+
return e.map((n) => {
|
|
1952
|
+
if ("fieldtype" in n && n.fieldtype === "Doctype" && "options" in n && typeof n.options == "string") {
|
|
1953
|
+
const i = n.options;
|
|
1954
|
+
if (r.has(i))
|
|
1955
|
+
return { ...n };
|
|
1956
|
+
const s = this.registry[i];
|
|
1957
|
+
if (s && s.schema) {
|
|
1958
|
+
const a = Array.isArray(s.schema) ? s.schema : Array.from(s.schema);
|
|
1959
|
+
r.add(i);
|
|
2274
1960
|
const c = this.resolveSchema(a, r);
|
|
2275
|
-
return r.delete(
|
|
1961
|
+
return r.delete(i), { ...n, schema: c };
|
|
2276
1962
|
}
|
|
2277
1963
|
}
|
|
2278
|
-
if ("fieldtype" in
|
|
2279
|
-
const
|
|
2280
|
-
if (r.has(
|
|
2281
|
-
return { ...
|
|
2282
|
-
const
|
|
2283
|
-
if (
|
|
2284
|
-
const a = Array.isArray(
|
|
2285
|
-
return (!("columns" in
|
|
2286
|
-
name:
|
|
2287
|
-
fieldname:
|
|
2288
|
-
label: "label" in
|
|
2289
|
-
fieldtype: "fieldtype" in
|
|
2290
|
-
align: "align" in
|
|
2291
|
-
edit: "edit" in
|
|
2292
|
-
width: "width" in
|
|
2293
|
-
}))), c.component || (c.component = "ATable"), (!("config" in
|
|
1964
|
+
if ("fieldtype" in n && n.fieldtype === "Table" && "options" in n && typeof n.options == "string") {
|
|
1965
|
+
const i = n.options;
|
|
1966
|
+
if (r.has(i))
|
|
1967
|
+
return { ...n };
|
|
1968
|
+
const s = this.registry[i];
|
|
1969
|
+
if (s && s.schema) {
|
|
1970
|
+
const a = Array.isArray(s.schema) ? s.schema : Array.from(s.schema), c = { ...n };
|
|
1971
|
+
return (!("columns" in n) || !n.columns) && (c.columns = a.map((d) => ({
|
|
1972
|
+
name: d.fieldname,
|
|
1973
|
+
fieldname: d.fieldname,
|
|
1974
|
+
label: "label" in d && d.label || d.fieldname,
|
|
1975
|
+
fieldtype: "fieldtype" in d ? d.fieldtype : "Data",
|
|
1976
|
+
align: "align" in d && d.align || "left",
|
|
1977
|
+
edit: "edit" in d ? d.edit : !0,
|
|
1978
|
+
width: "width" in d && d.width || "20ch"
|
|
1979
|
+
}))), c.component || (c.component = "ATable"), (!("config" in n) || !n.config) && (c.config = { view: "list" }), (!("rows" in n) || !n.rows) && (c.rows = []), c;
|
|
2294
1980
|
}
|
|
2295
1981
|
}
|
|
2296
|
-
return { ...
|
|
1982
|
+
return { ...n };
|
|
2297
1983
|
});
|
|
2298
1984
|
}
|
|
2299
1985
|
/**
|
|
@@ -2368,38 +2054,38 @@ class fe {
|
|
|
2368
2054
|
// }
|
|
2369
2055
|
// }
|
|
2370
2056
|
}
|
|
2371
|
-
async function
|
|
2057
|
+
async function rt(o, e, t) {
|
|
2372
2058
|
await de();
|
|
2373
2059
|
try {
|
|
2374
|
-
await t(
|
|
2060
|
+
await t(o, e);
|
|
2375
2061
|
} catch {
|
|
2376
2062
|
}
|
|
2377
2063
|
}
|
|
2378
|
-
const
|
|
2379
|
-
install: (
|
|
2380
|
-
const t =
|
|
2381
|
-
!t && r &&
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2064
|
+
const mt = {
|
|
2065
|
+
install: (o, e) => {
|
|
2066
|
+
const t = o.config.globalProperties.$router, r = e?.router, n = t || r;
|
|
2067
|
+
!t && r && o.use(r);
|
|
2068
|
+
const i = new te(n, e?.getMeta);
|
|
2069
|
+
o.provide("$registry", i), o.config.globalProperties.$registry = i;
|
|
2070
|
+
const s = new Ae(i);
|
|
2071
|
+
o.provide("$stonecrop", s), o.config.globalProperties.$stonecrop = s;
|
|
2386
2072
|
try {
|
|
2387
|
-
const a =
|
|
2073
|
+
const a = o.config.globalProperties.$pinia;
|
|
2388
2074
|
if (a) {
|
|
2389
|
-
const c =
|
|
2390
|
-
|
|
2075
|
+
const c = re(a);
|
|
2076
|
+
o.provide("$operationLogStore", c), o.config.globalProperties.$operationLogStore = c;
|
|
2391
2077
|
}
|
|
2392
2078
|
} catch (a) {
|
|
2393
2079
|
console.warn("Pinia not available - operation log features will be disabled:", a);
|
|
2394
2080
|
}
|
|
2395
2081
|
if (e?.components)
|
|
2396
2082
|
for (const [a, c] of Object.entries(e.components))
|
|
2397
|
-
|
|
2398
|
-
e?.autoInitializeRouter && e.onRouterInitialized &&
|
|
2083
|
+
o.component(a, c);
|
|
2084
|
+
e?.autoInitializeRouter && e.onRouterInitialized && rt(i, s, e.onRouterInitialized);
|
|
2399
2085
|
}
|
|
2400
2086
|
};
|
|
2401
|
-
var
|
|
2402
|
-
class
|
|
2087
|
+
var nt = /* @__PURE__ */ ((o) => (o.ERROR = "error", o.WARNING = "warning", o.INFO = "info", o))(nt || {});
|
|
2088
|
+
class ot {
|
|
2403
2089
|
options;
|
|
2404
2090
|
/**
|
|
2405
2091
|
* Creates a new SchemaValidator instance
|
|
@@ -2422,28 +2108,28 @@ class Ct {
|
|
|
2422
2108
|
* @param actions - Optional actions map
|
|
2423
2109
|
* @returns Validation result
|
|
2424
2110
|
*/
|
|
2425
|
-
validate(e, t, r,
|
|
2426
|
-
const
|
|
2427
|
-
if (this.options.validateRequiredProperties &&
|
|
2428
|
-
const g =
|
|
2429
|
-
|
|
2111
|
+
validate(e, t, r, n) {
|
|
2112
|
+
const i = [], s = t ? Array.isArray(t) ? t : t.toArray() : [];
|
|
2113
|
+
if (this.options.validateRequiredProperties && i.push(...this.validateRequiredProperties(e, s)), this.options.validateLinkTargets && this.options.registry && i.push(...this.validateLinkFields(e, s, this.options.registry)), this.options.validateWorkflows && r && i.push(...this.validateWorkflow(e, r)), this.options.validateActions && n) {
|
|
2114
|
+
const g = n instanceof Map ? n : n.toObject();
|
|
2115
|
+
i.push(...this.validateActionRegistration(e, g));
|
|
2430
2116
|
}
|
|
2431
|
-
const a =
|
|
2117
|
+
const a = i.filter(
|
|
2432
2118
|
(g) => g.severity === "error"
|
|
2433
2119
|
/* ERROR */
|
|
2434
|
-
).length, c =
|
|
2120
|
+
).length, c = i.filter(
|
|
2435
2121
|
(g) => g.severity === "warning"
|
|
2436
2122
|
/* WARNING */
|
|
2437
|
-
).length,
|
|
2123
|
+
).length, d = i.filter(
|
|
2438
2124
|
(g) => g.severity === "info"
|
|
2439
2125
|
/* INFO */
|
|
2440
2126
|
).length;
|
|
2441
2127
|
return {
|
|
2442
2128
|
valid: a === 0,
|
|
2443
|
-
issues:
|
|
2129
|
+
issues: i,
|
|
2444
2130
|
errorCount: a,
|
|
2445
2131
|
warningCount: c,
|
|
2446
|
-
infoCount:
|
|
2132
|
+
infoCount: d
|
|
2447
2133
|
};
|
|
2448
2134
|
}
|
|
2449
2135
|
/**
|
|
@@ -2452,26 +2138,26 @@ class Ct {
|
|
|
2452
2138
|
*/
|
|
2453
2139
|
validateRequiredProperties(e, t) {
|
|
2454
2140
|
const r = [];
|
|
2455
|
-
for (const
|
|
2456
|
-
if (!
|
|
2141
|
+
for (const n of t) {
|
|
2142
|
+
if (!n.fieldname) {
|
|
2457
2143
|
r.push({
|
|
2458
2144
|
severity: "error",
|
|
2459
2145
|
rule: "required-fieldname",
|
|
2460
2146
|
message: "Field is missing required property: fieldname",
|
|
2461
2147
|
doctype: e,
|
|
2462
|
-
context: { field:
|
|
2148
|
+
context: { field: n }
|
|
2463
2149
|
});
|
|
2464
2150
|
continue;
|
|
2465
2151
|
}
|
|
2466
|
-
if (!
|
|
2152
|
+
if (!n.component && !("fieldtype" in n) && r.push({
|
|
2467
2153
|
severity: "error",
|
|
2468
2154
|
rule: "required-component-or-fieldtype",
|
|
2469
|
-
message: `Field "${
|
|
2155
|
+
message: `Field "${n.fieldname}" must have either component or fieldtype property`,
|
|
2470
2156
|
doctype: e,
|
|
2471
|
-
fieldname:
|
|
2472
|
-
}), "schema" in
|
|
2473
|
-
const
|
|
2474
|
-
r.push(...this.validateRequiredProperties(e,
|
|
2157
|
+
fieldname: n.fieldname
|
|
2158
|
+
}), "schema" in n) {
|
|
2159
|
+
const i = n.schema, s = Array.isArray(i) ? i : i.toArray?.() || [];
|
|
2160
|
+
r.push(...this.validateRequiredProperties(e, s));
|
|
2475
2161
|
}
|
|
2476
2162
|
}
|
|
2477
2163
|
return r;
|
|
@@ -2481,46 +2167,46 @@ class Ct {
|
|
|
2481
2167
|
* @internal
|
|
2482
2168
|
*/
|
|
2483
2169
|
validateLinkFields(e, t, r) {
|
|
2484
|
-
const
|
|
2485
|
-
for (const
|
|
2486
|
-
if (("fieldtype" in
|
|
2487
|
-
const a = "options" in
|
|
2170
|
+
const n = [];
|
|
2171
|
+
for (const i of t) {
|
|
2172
|
+
if (("fieldtype" in i ? i.fieldtype : void 0) === "Link") {
|
|
2173
|
+
const a = "options" in i ? i.options : void 0;
|
|
2488
2174
|
if (!a) {
|
|
2489
|
-
|
|
2175
|
+
n.push({
|
|
2490
2176
|
severity: "error",
|
|
2491
2177
|
rule: "link-missing-options",
|
|
2492
|
-
message: `Link field "${
|
|
2178
|
+
message: `Link field "${i.fieldname}" is missing options property (target doctype)`,
|
|
2493
2179
|
doctype: e,
|
|
2494
|
-
fieldname:
|
|
2180
|
+
fieldname: i.fieldname
|
|
2495
2181
|
});
|
|
2496
2182
|
continue;
|
|
2497
2183
|
}
|
|
2498
2184
|
const c = typeof a == "string" ? a : "";
|
|
2499
2185
|
if (!c) {
|
|
2500
|
-
|
|
2186
|
+
n.push({
|
|
2501
2187
|
severity: "error",
|
|
2502
2188
|
rule: "link-invalid-options",
|
|
2503
|
-
message: `Link field "${
|
|
2189
|
+
message: `Link field "${i.fieldname}" has invalid options format (expected string doctype name)`,
|
|
2504
2190
|
doctype: e,
|
|
2505
|
-
fieldname:
|
|
2191
|
+
fieldname: i.fieldname
|
|
2506
2192
|
});
|
|
2507
2193
|
continue;
|
|
2508
2194
|
}
|
|
2509
|
-
r.registry[c] || r.registry[c.toLowerCase()] ||
|
|
2195
|
+
r.registry[c] || r.registry[c.toLowerCase()] || n.push({
|
|
2510
2196
|
severity: "error",
|
|
2511
2197
|
rule: "link-invalid-target",
|
|
2512
|
-
message: `Link field "${
|
|
2198
|
+
message: `Link field "${i.fieldname}" references non-existent doctype: "${c}"`,
|
|
2513
2199
|
doctype: e,
|
|
2514
|
-
fieldname:
|
|
2200
|
+
fieldname: i.fieldname,
|
|
2515
2201
|
context: { targetDoctype: c }
|
|
2516
2202
|
});
|
|
2517
2203
|
}
|
|
2518
|
-
if ("schema" in
|
|
2519
|
-
const a =
|
|
2520
|
-
|
|
2204
|
+
if ("schema" in i) {
|
|
2205
|
+
const a = i.schema, c = Array.isArray(a) ? a : a.toArray?.() || [];
|
|
2206
|
+
n.push(...this.validateLinkFields(e, c, r));
|
|
2521
2207
|
}
|
|
2522
2208
|
}
|
|
2523
|
-
return
|
|
2209
|
+
return n;
|
|
2524
2210
|
}
|
|
2525
2211
|
/**
|
|
2526
2212
|
* Validates workflow state machine configuration
|
|
@@ -2547,29 +2233,29 @@ class Ct {
|
|
|
2547
2233
|
doctype: e,
|
|
2548
2234
|
context: { initialState: t.initial }
|
|
2549
2235
|
});
|
|
2550
|
-
const
|
|
2551
|
-
t.initial && typeof t.initial == "string" &&
|
|
2552
|
-
for (const [
|
|
2236
|
+
const n = Object.keys(t.states), i = /* @__PURE__ */ new Set();
|
|
2237
|
+
t.initial && typeof t.initial == "string" && i.add(t.initial);
|
|
2238
|
+
for (const [s, a] of Object.entries(t.states)) {
|
|
2553
2239
|
const c = a;
|
|
2554
2240
|
if (c.on) {
|
|
2555
|
-
for (const [
|
|
2241
|
+
for (const [d, g] of Object.entries(c.on))
|
|
2556
2242
|
if (typeof g == "string")
|
|
2557
|
-
|
|
2243
|
+
i.add(g);
|
|
2558
2244
|
else if (g && typeof g == "object") {
|
|
2559
|
-
const
|
|
2560
|
-
typeof
|
|
2561
|
-
typeof
|
|
2245
|
+
const S = "target" in g ? g.target : void 0;
|
|
2246
|
+
typeof S == "string" ? i.add(S) : Array.isArray(S) && S.forEach(($) => {
|
|
2247
|
+
typeof $ == "string" && i.add($);
|
|
2562
2248
|
});
|
|
2563
2249
|
}
|
|
2564
2250
|
}
|
|
2565
2251
|
}
|
|
2566
|
-
for (const
|
|
2567
|
-
|
|
2252
|
+
for (const s of n)
|
|
2253
|
+
i.has(s) || r.push({
|
|
2568
2254
|
severity: "warning",
|
|
2569
2255
|
rule: "workflow-unreachable-state",
|
|
2570
|
-
message: `Workflow state "${
|
|
2256
|
+
message: `Workflow state "${s}" may not be reachable`,
|
|
2571
2257
|
doctype: e,
|
|
2572
|
-
context: { stateName:
|
|
2258
|
+
context: { stateName: s }
|
|
2573
2259
|
});
|
|
2574
2260
|
return r;
|
|
2575
2261
|
}
|
|
@@ -2578,62 +2264,62 @@ class Ct {
|
|
|
2578
2264
|
* @internal
|
|
2579
2265
|
*/
|
|
2580
2266
|
validateActionRegistration(e, t) {
|
|
2581
|
-
const r = [],
|
|
2582
|
-
for (const [
|
|
2583
|
-
if (!Array.isArray(
|
|
2267
|
+
const r = [], n = J();
|
|
2268
|
+
for (const [i, s] of Object.entries(t)) {
|
|
2269
|
+
if (!Array.isArray(s)) {
|
|
2584
2270
|
r.push({
|
|
2585
2271
|
severity: "error",
|
|
2586
2272
|
rule: "action-invalid-format",
|
|
2587
|
-
message: `Action configuration for "${
|
|
2273
|
+
message: `Action configuration for "${i}" must be an array`,
|
|
2588
2274
|
doctype: e,
|
|
2589
|
-
context: { triggerName:
|
|
2275
|
+
context: { triggerName: i, actionNames: s }
|
|
2590
2276
|
});
|
|
2591
2277
|
continue;
|
|
2592
2278
|
}
|
|
2593
|
-
for (const a of
|
|
2594
|
-
const c =
|
|
2279
|
+
for (const a of s) {
|
|
2280
|
+
const c = n;
|
|
2595
2281
|
c.globalActions?.has(a) || c.globalTransitionActions?.has(a) || r.push({
|
|
2596
2282
|
severity: "warning",
|
|
2597
2283
|
rule: "action-not-registered",
|
|
2598
|
-
message: `Action "${a}" referenced in "${
|
|
2284
|
+
message: `Action "${a}" referenced in "${i}" is not registered in FieldTriggerEngine`,
|
|
2599
2285
|
doctype: e,
|
|
2600
|
-
context: { triggerName:
|
|
2286
|
+
context: { triggerName: i, actionName: a }
|
|
2601
2287
|
});
|
|
2602
2288
|
}
|
|
2603
2289
|
}
|
|
2604
2290
|
return r;
|
|
2605
2291
|
}
|
|
2606
2292
|
}
|
|
2607
|
-
function
|
|
2608
|
-
return new
|
|
2609
|
-
registry:
|
|
2293
|
+
function it(o, e) {
|
|
2294
|
+
return new ot({
|
|
2295
|
+
registry: o,
|
|
2610
2296
|
...e
|
|
2611
2297
|
});
|
|
2612
2298
|
}
|
|
2613
|
-
function
|
|
2614
|
-
return
|
|
2299
|
+
function yt(o, e, t, r, n) {
|
|
2300
|
+
return it(t).validate(o, e, r, n);
|
|
2615
2301
|
}
|
|
2616
2302
|
export {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2303
|
+
vt as DoctypeMeta,
|
|
2304
|
+
Y as HST,
|
|
2305
|
+
te as Registry,
|
|
2306
|
+
ot as SchemaValidator,
|
|
2307
|
+
Ae as Stonecrop,
|
|
2308
|
+
nt as ValidationSeverity,
|
|
2309
|
+
et as createHST,
|
|
2310
|
+
it as createValidator,
|
|
2311
|
+
mt as default,
|
|
2312
|
+
J as getGlobalTriggerEngine,
|
|
2313
|
+
dt as markOperationIrreversible,
|
|
2314
|
+
ct as registerGlobalAction,
|
|
2315
|
+
lt as registerTransitionAction,
|
|
2316
|
+
ut as setFieldRollback,
|
|
2317
|
+
ft as triggerTransition,
|
|
2318
|
+
Te as useOperationLog,
|
|
2319
|
+
re as useOperationLogStore,
|
|
2320
|
+
pt as useStonecrop,
|
|
2321
|
+
ht as useUndoRedoShortcuts,
|
|
2322
|
+
yt as validateSchema,
|
|
2323
|
+
gt as withBatch
|
|
2638
2324
|
};
|
|
2639
2325
|
//# sourceMappingURL=stonecrop.js.map
|