@stonecrop/stonecrop 0.6.1 → 0.6.3
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/composable.js +348 -0
- package/dist/composables/operation-log.js +221 -0
- package/dist/doctype.js +73 -0
- package/dist/exceptions.js +16 -0
- package/dist/field-triggers.js +564 -0
- package/dist/index.js +18 -0
- package/dist/operation-log-DB-dGNT9.js +593 -0
- package/dist/operation-log-DB-dGNT9.js.map +1 -0
- package/dist/plugins/index.js +90 -0
- package/dist/registry.js +72 -0
- package/dist/src/stores/data.d.ts +11 -0
- package/dist/src/stores/data.d.ts.map +1 -0
- package/dist/src/stores/xstate.d.ts +31 -0
- package/dist/src/stores/xstate.d.ts.map +1 -0
- package/dist/src/tsdoc-metadata.json +1 -1
- package/dist/stonecrop.d.ts +47 -58
- package/dist/stonecrop.js +851 -859
- package/dist/stonecrop.js.map +1 -1
- package/dist/stonecrop.umd.cjs +3 -7
- package/dist/stonecrop.umd.cjs.map +1 -1
- package/dist/stores/data.js +7 -0
- package/dist/stores/hst.js +483 -0
- package/dist/stores/index.js +12 -0
- package/dist/stores/operation-log.js +571 -0
- package/dist/stores/xstate.js +29 -0
- package/dist/types/field-triggers.js +4 -0
- package/dist/types/index.js +4 -0
- package/dist/types/operation-log.js +0 -0
- package/dist/types/registry.js +0 -0
- package/package.json +4 -4
package/dist/stonecrop.js
CHANGED
|
@@ -1,574 +1,564 @@
|
|
|
1
|
-
import { hasInjectionContext as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
let re;
|
|
8
|
-
const ge = (r) => re = r, Ye = process.env.NODE_ENV !== "production" ? Symbol("pinia") : (
|
|
1
|
+
import { hasInjectionContext as we, inject as te, getCurrentInstance as ke, toRaw as Fe, computed as B, isRef as re, isReactive as ye, toRef as se, ref as L, reactive as Ee, markRaw as ne, effectScope as Ke, nextTick as ue, getCurrentScope as Ze, onScopeDispose as qe, watch as H, toRefs as Pe, onMounted as Me, readonly as Le, customRef as Ge, toValue as J, shallowRef as xe, unref as Ye, provide as Ne } from "vue";
|
|
2
|
+
const Q = typeof window < "u";
|
|
3
|
+
let K;
|
|
4
|
+
const ge = (o) => K = o;
|
|
5
|
+
process.env.NODE_ENV;
|
|
6
|
+
const Oe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
|
|
9
7
|
/* istanbul ignore next */
|
|
10
|
-
Symbol()
|
|
8
|
+
/* @__PURE__ */ Symbol()
|
|
11
9
|
);
|
|
12
|
-
function
|
|
13
|
-
return
|
|
10
|
+
function q(o) {
|
|
11
|
+
return o && typeof o == "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON != "function";
|
|
14
12
|
}
|
|
15
|
-
var
|
|
16
|
-
(function(
|
|
17
|
-
|
|
18
|
-
})(
|
|
19
|
-
|
|
20
|
-
function Be(r, e) {
|
|
13
|
+
var ie;
|
|
14
|
+
(function(o) {
|
|
15
|
+
o.direct = "direct", o.patchObject = "patch object", o.patchFunction = "patch function";
|
|
16
|
+
})(ie || (ie = {}));
|
|
17
|
+
function Be(o, e) {
|
|
21
18
|
for (const t in e) {
|
|
22
|
-
const
|
|
23
|
-
if (!(t in
|
|
19
|
+
const r = e[t];
|
|
20
|
+
if (!(t in o))
|
|
24
21
|
continue;
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
const n = o[t];
|
|
23
|
+
q(n) && q(r) && !re(r) && !ye(r) ? o[t] = Be(n, r) : o[t] = r;
|
|
27
24
|
}
|
|
28
|
-
return
|
|
25
|
+
return o;
|
|
29
26
|
}
|
|
30
27
|
const je = () => {
|
|
31
28
|
};
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
s > -1 && (r.splice(s, 1), n());
|
|
29
|
+
function Ie(o, e, t, r = je) {
|
|
30
|
+
o.add(e);
|
|
31
|
+
const n = () => {
|
|
32
|
+
o.delete(e) && r();
|
|
37
33
|
};
|
|
38
|
-
return !t &&
|
|
34
|
+
return !t && Ze() && qe(n), n;
|
|
39
35
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
36
|
+
function Y(o, ...e) {
|
|
37
|
+
o.forEach((t) => {
|
|
42
38
|
t(...e);
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
|
-
const Qe = (
|
|
46
|
-
function
|
|
47
|
-
|
|
41
|
+
const Qe = (o) => o(), De = /* @__PURE__ */ Symbol(), me = /* @__PURE__ */ Symbol();
|
|
42
|
+
function Re(o, e) {
|
|
43
|
+
o instanceof Map && e instanceof Map ? e.forEach((t, r) => o.set(r, t)) : o instanceof Set && e instanceof Set && e.forEach(o.add, o);
|
|
48
44
|
for (const t in e) {
|
|
49
45
|
if (!e.hasOwnProperty(t))
|
|
50
46
|
continue;
|
|
51
|
-
const
|
|
52
|
-
|
|
47
|
+
const r = e[t], n = o[t];
|
|
48
|
+
q(n) && q(r) && o.hasOwnProperty(t) && !re(r) && !ye(r) ? o[t] = Re(n, r) : o[t] = r;
|
|
53
49
|
}
|
|
54
|
-
return
|
|
50
|
+
return o;
|
|
55
51
|
}
|
|
56
|
-
const Xe = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : (
|
|
52
|
+
const Xe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
|
|
57
53
|
/* istanbul ignore next */
|
|
58
|
-
Symbol()
|
|
54
|
+
/* @__PURE__ */ Symbol()
|
|
59
55
|
);
|
|
60
|
-
function et(
|
|
61
|
-
return !
|
|
56
|
+
function et(o) {
|
|
57
|
+
return !q(o) || !Object.prototype.hasOwnProperty.call(o, Xe);
|
|
62
58
|
}
|
|
63
59
|
const { assign: U } = Object;
|
|
64
|
-
function
|
|
65
|
-
return !!(
|
|
60
|
+
function $e(o) {
|
|
61
|
+
return !!(re(o) && o.effect);
|
|
66
62
|
}
|
|
67
|
-
function
|
|
68
|
-
const { state:
|
|
63
|
+
function Te(o, e, t, r) {
|
|
64
|
+
const { state: n, actions: s, getters: i } = e, a = t.state.value[o];
|
|
69
65
|
let c;
|
|
70
|
-
function
|
|
71
|
-
!a && (process.env.NODE_ENV === "production" || !
|
|
72
|
-
const
|
|
66
|
+
function h() {
|
|
67
|
+
!a && (process.env.NODE_ENV === "production" || !r) && (t.state.value[o] = n ? n() : {});
|
|
68
|
+
const b = process.env.NODE_ENV !== "production" && r ? (
|
|
73
69
|
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
74
|
-
|
|
75
|
-
) :
|
|
76
|
-
return U(
|
|
70
|
+
Pe(L(n ? n() : {}).value)
|
|
71
|
+
) : Pe(t.state.value[o]);
|
|
72
|
+
return U(b, s, Object.keys(i || {}).reduce((w, P) => (process.env.NODE_ENV !== "production" && P in b && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${P}" in store "${o}".`), w[P] = ne(B(() => {
|
|
77
73
|
ge(t);
|
|
78
|
-
const
|
|
79
|
-
return i[P].call(
|
|
74
|
+
const D = t._s.get(o);
|
|
75
|
+
return i[P].call(D, D);
|
|
80
76
|
})), w), {}));
|
|
81
77
|
}
|
|
82
|
-
return c =
|
|
78
|
+
return c = _e(o, h, e, t, r, !0), c;
|
|
83
79
|
}
|
|
84
|
-
function
|
|
80
|
+
function _e(o, e, t = {}, r, n, s) {
|
|
85
81
|
let i;
|
|
86
82
|
const a = U({ actions: {} }, t);
|
|
87
|
-
if (process.env.NODE_ENV !== "production" && !
|
|
83
|
+
if (process.env.NODE_ENV !== "production" && !r._e.active)
|
|
88
84
|
throw new Error("Pinia destroyed");
|
|
89
85
|
const c = { deep: !0 };
|
|
90
86
|
process.env.NODE_ENV !== "production" && (c.onTrigger = (u) => {
|
|
91
|
-
|
|
87
|
+
h ? D = u : h == !1 && !g._hotUpdating && (Array.isArray(D) ? D.push(u) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
92
88
|
});
|
|
93
|
-
let
|
|
94
|
-
const
|
|
95
|
-
!s && !
|
|
96
|
-
const
|
|
89
|
+
let h, b, w = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Set(), D;
|
|
90
|
+
const C = r.state.value[o];
|
|
91
|
+
!s && !C && (process.env.NODE_ENV === "production" || !n) && (r.state.value[o] = {});
|
|
92
|
+
const F = L({});
|
|
97
93
|
let _;
|
|
98
|
-
function
|
|
99
|
-
let
|
|
100
|
-
|
|
101
|
-
type:
|
|
102
|
-
storeId:
|
|
103
|
-
events:
|
|
104
|
-
}) : (
|
|
105
|
-
type:
|
|
94
|
+
function $(u) {
|
|
95
|
+
let l;
|
|
96
|
+
h = b = !1, process.env.NODE_ENV !== "production" && (D = []), typeof u == "function" ? (u(r.state.value[o]), l = {
|
|
97
|
+
type: ie.patchFunction,
|
|
98
|
+
storeId: o,
|
|
99
|
+
events: D
|
|
100
|
+
}) : (Re(r.state.value[o], u), l = {
|
|
101
|
+
type: ie.patchObject,
|
|
106
102
|
payload: u,
|
|
107
|
-
storeId:
|
|
108
|
-
events:
|
|
103
|
+
storeId: o,
|
|
104
|
+
events: D
|
|
109
105
|
});
|
|
110
|
-
const O = _ = Symbol();
|
|
111
|
-
|
|
112
|
-
_ === O && (
|
|
113
|
-
}),
|
|
106
|
+
const O = _ = /* @__PURE__ */ Symbol();
|
|
107
|
+
ue().then(() => {
|
|
108
|
+
_ === O && (h = !0);
|
|
109
|
+
}), b = !0, Y(w, l, r.state.value[o]);
|
|
114
110
|
}
|
|
115
111
|
const R = s ? function() {
|
|
116
|
-
const { state:
|
|
112
|
+
const { state: l } = t, O = l ? l() : {};
|
|
117
113
|
this.$patch((y) => {
|
|
118
114
|
U(y, O);
|
|
119
115
|
});
|
|
120
116
|
} : (
|
|
121
117
|
/* istanbul ignore next */
|
|
122
118
|
process.env.NODE_ENV !== "production" ? () => {
|
|
123
|
-
throw new Error(`🍍: Store "${
|
|
119
|
+
throw new Error(`🍍: Store "${o}" is built using the setup syntax and does not implement $reset().`);
|
|
124
120
|
} : je
|
|
125
121
|
);
|
|
126
|
-
function
|
|
127
|
-
i.stop(), w
|
|
122
|
+
function S() {
|
|
123
|
+
i.stop(), w.clear(), P.clear(), r._s.delete(o);
|
|
128
124
|
}
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
return u[me] =
|
|
125
|
+
const T = (u, l = "") => {
|
|
126
|
+
if (De in u)
|
|
127
|
+
return u[me] = l, u;
|
|
132
128
|
const O = function() {
|
|
133
|
-
ge(
|
|
134
|
-
const y = Array.from(arguments),
|
|
135
|
-
function
|
|
136
|
-
|
|
129
|
+
ge(r);
|
|
130
|
+
const y = Array.from(arguments), f = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set();
|
|
131
|
+
function I(V) {
|
|
132
|
+
f.add(V);
|
|
137
133
|
}
|
|
138
134
|
function A(V) {
|
|
139
|
-
m.
|
|
135
|
+
m.add(V);
|
|
140
136
|
}
|
|
141
|
-
|
|
137
|
+
Y(P, {
|
|
142
138
|
args: y,
|
|
143
139
|
name: O[me],
|
|
144
140
|
store: g,
|
|
145
|
-
after:
|
|
141
|
+
after: I,
|
|
146
142
|
onError: A
|
|
147
143
|
});
|
|
148
144
|
let j;
|
|
149
145
|
try {
|
|
150
|
-
j = u.apply(this && this.$id ===
|
|
146
|
+
j = u.apply(this && this.$id === o ? this : g, y);
|
|
151
147
|
} catch (V) {
|
|
152
|
-
throw
|
|
148
|
+
throw Y(m, V), V;
|
|
153
149
|
}
|
|
154
|
-
return j instanceof Promise ? j.then((V) => (
|
|
150
|
+
return j instanceof Promise ? j.then((V) => (Y(f, V), V)).catch((V) => (Y(m, V), Promise.reject(V))) : (Y(f, j), j);
|
|
155
151
|
};
|
|
156
|
-
return O[
|
|
157
|
-
}, E = /* @__PURE__ */
|
|
152
|
+
return O[De] = !0, O[me] = l, O;
|
|
153
|
+
}, E = /* @__PURE__ */ ne({
|
|
158
154
|
actions: {},
|
|
159
155
|
getters: {},
|
|
160
156
|
state: [],
|
|
161
|
-
hotState:
|
|
162
|
-
}),
|
|
163
|
-
_p:
|
|
157
|
+
hotState: F
|
|
158
|
+
}), N = {
|
|
159
|
+
_p: r,
|
|
164
160
|
// _s: scope,
|
|
165
|
-
$id:
|
|
166
|
-
$onAction:
|
|
167
|
-
$patch:
|
|
161
|
+
$id: o,
|
|
162
|
+
$onAction: Ie.bind(null, P),
|
|
163
|
+
$patch: $,
|
|
168
164
|
$reset: R,
|
|
169
|
-
$subscribe(u,
|
|
170
|
-
const O =
|
|
171
|
-
(
|
|
172
|
-
storeId:
|
|
173
|
-
type:
|
|
174
|
-
events:
|
|
175
|
-
},
|
|
176
|
-
}, U({}, c,
|
|
165
|
+
$subscribe(u, l = {}) {
|
|
166
|
+
const O = Ie(w, u, l.detached, () => y()), y = i.run(() => H(() => r.state.value[o], (f) => {
|
|
167
|
+
(l.flush === "sync" ? b : h) && u({
|
|
168
|
+
storeId: o,
|
|
169
|
+
type: ie.direct,
|
|
170
|
+
events: D
|
|
171
|
+
}, f);
|
|
172
|
+
}, U({}, c, l)));
|
|
177
173
|
return O;
|
|
178
174
|
},
|
|
179
|
-
$dispose:
|
|
180
|
-
}, g =
|
|
175
|
+
$dispose: S
|
|
176
|
+
}, g = Ee(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q ? U(
|
|
181
177
|
{
|
|
182
178
|
_hmrPayload: E,
|
|
183
|
-
_customProperties:
|
|
179
|
+
_customProperties: ne(/* @__PURE__ */ new Set())
|
|
184
180
|
// devtools custom properties
|
|
185
181
|
},
|
|
186
|
-
|
|
182
|
+
N
|
|
187
183
|
// must be added later
|
|
188
184
|
// setupStore
|
|
189
|
-
) :
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
for (const u in
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
process.env.NODE_ENV !== "production" &&
|
|
196
|
-
else if (typeof
|
|
197
|
-
const O = process.env.NODE_ENV !== "production" &&
|
|
198
|
-
|
|
199
|
-
} else process.env.NODE_ENV !== "production" &&
|
|
185
|
+
) : N);
|
|
186
|
+
r._s.set(o, g);
|
|
187
|
+
const M = (r._a && r._a.runWithContext || Qe)(() => r._e.run(() => (i = Ke()).run(() => e({ action: T }))));
|
|
188
|
+
for (const u in M) {
|
|
189
|
+
const l = M[u];
|
|
190
|
+
if (re(l) && !$e(l) || ye(l))
|
|
191
|
+
process.env.NODE_ENV !== "production" && n ? F.value[u] = se(M, u) : s || (C && et(l) && (re(l) ? l.value = C[u] : Re(l, C[u])), r.state.value[o][u] = l), process.env.NODE_ENV !== "production" && E.state.push(u);
|
|
192
|
+
else if (typeof l == "function") {
|
|
193
|
+
const O = process.env.NODE_ENV !== "production" && n ? l : T(l, u);
|
|
194
|
+
M[u] = O, process.env.NODE_ENV !== "production" && (E.actions[u] = l), a.actions[u] = l;
|
|
195
|
+
} else process.env.NODE_ENV !== "production" && $e(l) && (E.getters[u] = s ? (
|
|
200
196
|
// @ts-expect-error
|
|
201
197
|
t.getters[u]
|
|
202
|
-
) :
|
|
203
|
-
(
|
|
198
|
+
) : l, Q && (M._getters || // @ts-expect-error: same
|
|
199
|
+
(M._getters = ne([]))).push(u));
|
|
204
200
|
}
|
|
205
|
-
if (U(g,
|
|
206
|
-
get: () => process.env.NODE_ENV !== "production" &&
|
|
201
|
+
if (U(g, M), U(Fe(g), M), Object.defineProperty(g, "$state", {
|
|
202
|
+
get: () => process.env.NODE_ENV !== "production" && n ? F.value : r.state.value[o],
|
|
207
203
|
set: (u) => {
|
|
208
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
204
|
+
if (process.env.NODE_ENV !== "production" && n)
|
|
209
205
|
throw new Error("cannot set hotState");
|
|
210
|
-
|
|
211
|
-
U(
|
|
206
|
+
$((l) => {
|
|
207
|
+
U(l, u);
|
|
212
208
|
});
|
|
213
209
|
}
|
|
214
|
-
}), process.env.NODE_ENV !== "production" && (g._hotUpdate =
|
|
215
|
-
g._hotUpdating = !0, u._hmrPayload.state.forEach((
|
|
216
|
-
if (
|
|
217
|
-
const O = u.$state[
|
|
218
|
-
typeof O == "object" &&
|
|
210
|
+
}), process.env.NODE_ENV !== "production" && (g._hotUpdate = ne((u) => {
|
|
211
|
+
g._hotUpdating = !0, u._hmrPayload.state.forEach((l) => {
|
|
212
|
+
if (l in g.$state) {
|
|
213
|
+
const O = u.$state[l], y = g.$state[l];
|
|
214
|
+
typeof O == "object" && q(O) && q(y) ? Be(O, y) : u.$state[l] = y;
|
|
219
215
|
}
|
|
220
|
-
g[
|
|
221
|
-
}), Object.keys(g.$state).forEach((
|
|
222
|
-
|
|
223
|
-
}),
|
|
224
|
-
|
|
216
|
+
g[l] = se(u.$state, l);
|
|
217
|
+
}), Object.keys(g.$state).forEach((l) => {
|
|
218
|
+
l in u.$state || delete g[l];
|
|
219
|
+
}), h = !1, b = !1, r.state.value[o] = se(u._hmrPayload, "hotState"), b = !0, ue().then(() => {
|
|
220
|
+
h = !0;
|
|
225
221
|
});
|
|
226
|
-
for (const
|
|
227
|
-
const O = u[
|
|
228
|
-
g[
|
|
229
|
-
|
|
222
|
+
for (const l in u._hmrPayload.actions) {
|
|
223
|
+
const O = u[l];
|
|
224
|
+
g[l] = //
|
|
225
|
+
T(O, l);
|
|
230
226
|
}
|
|
231
|
-
for (const
|
|
232
|
-
const O = u._hmrPayload.getters[
|
|
227
|
+
for (const l in u._hmrPayload.getters) {
|
|
228
|
+
const O = u._hmrPayload.getters[l], y = s ? (
|
|
233
229
|
// special handling of options api
|
|
234
|
-
B(() => (ge(
|
|
230
|
+
B(() => (ge(r), O.call(g, g)))
|
|
235
231
|
) : O;
|
|
236
|
-
g[
|
|
232
|
+
g[l] = //
|
|
237
233
|
y;
|
|
238
234
|
}
|
|
239
|
-
Object.keys(g._hmrPayload.getters).forEach((
|
|
240
|
-
|
|
241
|
-
}), Object.keys(g._hmrPayload.actions).forEach((
|
|
242
|
-
|
|
235
|
+
Object.keys(g._hmrPayload.getters).forEach((l) => {
|
|
236
|
+
l in u._hmrPayload.getters || delete g[l];
|
|
237
|
+
}), Object.keys(g._hmrPayload.actions).forEach((l) => {
|
|
238
|
+
l in u._hmrPayload.actions || delete g[l];
|
|
243
239
|
}), g._hmrPayload = u._hmrPayload, g._getters = u._getters, g._hotUpdating = !1;
|
|
244
|
-
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" &&
|
|
240
|
+
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q) {
|
|
245
241
|
const u = {
|
|
246
242
|
writable: !0,
|
|
247
243
|
configurable: !0,
|
|
248
244
|
// avoid warning on devtools trying to display this property
|
|
249
245
|
enumerable: !1
|
|
250
246
|
};
|
|
251
|
-
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((
|
|
252
|
-
Object.defineProperty(g,
|
|
247
|
+
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((l) => {
|
|
248
|
+
Object.defineProperty(g, l, U({ value: g[l] }, u));
|
|
253
249
|
});
|
|
254
250
|
}
|
|
255
|
-
return
|
|
256
|
-
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" &&
|
|
257
|
-
const
|
|
251
|
+
return r._p.forEach((u) => {
|
|
252
|
+
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Q) {
|
|
253
|
+
const l = i.run(() => u({
|
|
258
254
|
store: g,
|
|
259
|
-
app:
|
|
260
|
-
pinia:
|
|
255
|
+
app: r._a,
|
|
256
|
+
pinia: r,
|
|
261
257
|
options: a
|
|
262
258
|
}));
|
|
263
|
-
Object.keys(
|
|
259
|
+
Object.keys(l || {}).forEach((O) => g._customProperties.add(O)), U(g, l);
|
|
264
260
|
} else
|
|
265
261
|
U(g, i.run(() => u({
|
|
266
262
|
store: g,
|
|
267
|
-
app:
|
|
268
|
-
pinia:
|
|
263
|
+
app: r._a,
|
|
264
|
+
pinia: r,
|
|
269
265
|
options: a
|
|
270
266
|
})));
|
|
271
267
|
}), process.env.NODE_ENV !== "production" && g.$state && typeof g.$state == "object" && typeof g.$state.constructor == "function" && !g.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
272
268
|
state: () => new MyClass()
|
|
273
|
-
Found in store "${g.$id}".`),
|
|
269
|
+
Found in store "${g.$id}".`), C && s && t.hydrate && t.hydrate(g.$state, C), h = !0, b = !0, g;
|
|
274
270
|
}
|
|
275
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
276
271
|
// @__NO_SIDE_EFFECTS__
|
|
277
|
-
function tt(
|
|
278
|
-
let
|
|
279
|
-
const
|
|
280
|
-
|
|
272
|
+
function tt(o, e, t) {
|
|
273
|
+
let r;
|
|
274
|
+
const n = typeof e == "function";
|
|
275
|
+
r = n ? t : e;
|
|
281
276
|
function s(i, a) {
|
|
282
|
-
const c =
|
|
277
|
+
const c = we();
|
|
283
278
|
if (i = // in test mode, ignore the argument provided as we can always retrieve a
|
|
284
279
|
// pinia instance with getActivePinia()
|
|
285
|
-
(process.env.NODE_ENV === "test" &&
|
|
280
|
+
(process.env.NODE_ENV === "test" && K && K._testing ? null : i) || (c ? te(Oe, null) : null), i && ge(i), process.env.NODE_ENV !== "production" && !K)
|
|
286
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)"?
|
|
287
282
|
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
288
283
|
This will fail in production.`);
|
|
289
|
-
i =
|
|
290
|
-
const
|
|
284
|
+
i = K, i._s.has(o) || (n ? _e(o, e, r, i) : Te(o, r, i), process.env.NODE_ENV !== "production" && (s._pinia = i));
|
|
285
|
+
const h = i._s.get(o);
|
|
291
286
|
if (process.env.NODE_ENV !== "production" && a) {
|
|
292
|
-
const
|
|
293
|
-
a._hotUpdate(w), delete i.state.value[
|
|
287
|
+
const b = "__hot:" + o, w = n ? _e(b, e, r, i, !0) : Te(b, U({}, r), i, !0);
|
|
288
|
+
a._hotUpdate(w), delete i.state.value[b], i._s.delete(b);
|
|
294
289
|
}
|
|
295
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
290
|
+
if (process.env.NODE_ENV !== "production" && Q) {
|
|
291
|
+
const b = ke();
|
|
292
|
+
if (b && b.proxy && // avoid adding stores that are just built for hot module replacement
|
|
298
293
|
!a) {
|
|
299
|
-
const w =
|
|
300
|
-
P[
|
|
294
|
+
const w = b.proxy, P = "_pStores" in w ? w._pStores : w._pStores = {};
|
|
295
|
+
P[o] = h;
|
|
301
296
|
}
|
|
302
297
|
}
|
|
303
|
-
return
|
|
298
|
+
return h;
|
|
304
299
|
}
|
|
305
|
-
return s.$id =
|
|
300
|
+
return s.$id = o, s;
|
|
306
301
|
}
|
|
307
|
-
function Ue(
|
|
308
|
-
const e =
|
|
309
|
-
for (const
|
|
310
|
-
const
|
|
311
|
-
|
|
302
|
+
function Ue(o) {
|
|
303
|
+
const e = Fe(o), t = {};
|
|
304
|
+
for (const r in e) {
|
|
305
|
+
const n = e[r];
|
|
306
|
+
n.effect ? t[r] = // ...
|
|
312
307
|
B({
|
|
313
|
-
get: () => r
|
|
308
|
+
get: () => o[r],
|
|
314
309
|
set(s) {
|
|
315
|
-
r
|
|
310
|
+
o[r] = s;
|
|
316
311
|
}
|
|
317
|
-
}) : (
|
|
318
|
-
|
|
312
|
+
}) : (re(n) || ye(n)) && (t[r] = // ---
|
|
313
|
+
se(o, r));
|
|
319
314
|
}
|
|
320
315
|
return t;
|
|
321
316
|
}
|
|
322
|
-
|
|
323
|
-
return Fe() ? (ke(r, e), !0) : !1;
|
|
324
|
-
}
|
|
325
|
-
const nt = typeof window < "u" && typeof document < "u";
|
|
317
|
+
const rt = typeof window < "u" && typeof document < "u";
|
|
326
318
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
327
|
-
const ot = Object.prototype.toString,
|
|
319
|
+
const ot = Object.prototype.toString, nt = (o) => ot.call(o) === "[object Object]", We = () => {
|
|
328
320
|
};
|
|
329
|
-
function
|
|
330
|
-
if (
|
|
331
|
-
const e =
|
|
332
|
-
return typeof e == "function" ?
|
|
321
|
+
function st(...o) {
|
|
322
|
+
if (o.length !== 1) return se(...o);
|
|
323
|
+
const e = o[0];
|
|
324
|
+
return typeof e == "function" ? Le(Ge(() => ({
|
|
333
325
|
get: e,
|
|
334
326
|
set: We
|
|
335
|
-
}))) :
|
|
327
|
+
}))) : L(e);
|
|
336
328
|
}
|
|
337
|
-
function
|
|
338
|
-
function t(...
|
|
339
|
-
return new Promise((
|
|
340
|
-
Promise.resolve(
|
|
329
|
+
function it(o, e) {
|
|
330
|
+
function t(...r) {
|
|
331
|
+
return new Promise((n, s) => {
|
|
332
|
+
Promise.resolve(o(() => e.apply(this, r), {
|
|
341
333
|
fn: e,
|
|
342
334
|
thisArg: this,
|
|
343
|
-
args:
|
|
344
|
-
})).then(
|
|
335
|
+
args: r
|
|
336
|
+
})).then(n).catch(s);
|
|
345
337
|
});
|
|
346
338
|
}
|
|
347
339
|
return t;
|
|
348
340
|
}
|
|
349
|
-
const ze = (
|
|
350
|
-
function
|
|
351
|
-
const { initialState: t = "active" } = e,
|
|
352
|
-
function
|
|
353
|
-
|
|
341
|
+
const ze = (o) => o();
|
|
342
|
+
function at(o = ze, e = {}) {
|
|
343
|
+
const { initialState: t = "active" } = e, r = st(t === "active");
|
|
344
|
+
function n() {
|
|
345
|
+
r.value = !1;
|
|
354
346
|
}
|
|
355
347
|
function s() {
|
|
356
|
-
|
|
348
|
+
r.value = !0;
|
|
357
349
|
}
|
|
358
350
|
const i = (...a) => {
|
|
359
|
-
|
|
351
|
+
r.value && o(...a);
|
|
360
352
|
};
|
|
361
353
|
return {
|
|
362
|
-
isActive:
|
|
363
|
-
pause:
|
|
354
|
+
isActive: Le(r),
|
|
355
|
+
pause: n,
|
|
364
356
|
resume: s,
|
|
365
357
|
eventFilter: i
|
|
366
358
|
};
|
|
367
359
|
}
|
|
368
|
-
function Se(
|
|
369
|
-
return Array.isArray(
|
|
360
|
+
function Se(o) {
|
|
361
|
+
return Array.isArray(o) ? o : [o];
|
|
370
362
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
363
|
+
function ct(o) {
|
|
364
|
+
return ke();
|
|
373
365
|
}
|
|
374
|
-
function
|
|
375
|
-
const { eventFilter:
|
|
376
|
-
return H(
|
|
366
|
+
function ut(o, e, t = {}) {
|
|
367
|
+
const { eventFilter: r = ze, ...n } = t;
|
|
368
|
+
return H(o, it(r, e), n);
|
|
377
369
|
}
|
|
378
|
-
function
|
|
379
|
-
const { eventFilter:
|
|
370
|
+
function lt(o, e, t = {}) {
|
|
371
|
+
const { eventFilter: r, initialState: n = "active", ...s } = t, { eventFilter: i, pause: a, resume: c, isActive: h } = at(r, { initialState: n });
|
|
380
372
|
return {
|
|
381
|
-
stop:
|
|
373
|
+
stop: ut(o, e, {
|
|
382
374
|
...s,
|
|
383
375
|
eventFilter: i
|
|
384
376
|
}),
|
|
385
377
|
pause: a,
|
|
386
378
|
resume: c,
|
|
387
|
-
isActive:
|
|
379
|
+
isActive: h
|
|
388
380
|
};
|
|
389
381
|
}
|
|
390
|
-
const
|
|
391
|
-
function
|
|
392
|
-
|
|
382
|
+
const ft = lt;
|
|
383
|
+
function dt(o, e = !0, t) {
|
|
384
|
+
ct() ? Me(o, t) : e ? o() : ue(o);
|
|
393
385
|
}
|
|
394
|
-
function
|
|
395
|
-
return H(
|
|
386
|
+
function pt(o, e, t) {
|
|
387
|
+
return H(o, e, {
|
|
396
388
|
...t,
|
|
397
389
|
immediate: !0
|
|
398
390
|
});
|
|
399
391
|
}
|
|
400
|
-
function
|
|
401
|
-
return H(
|
|
402
|
-
|
|
392
|
+
function oe(o, e, t) {
|
|
393
|
+
return H(o, (n, s, i) => {
|
|
394
|
+
n && e(n, s, i);
|
|
403
395
|
}, {
|
|
404
396
|
...t,
|
|
405
397
|
once: !1
|
|
406
398
|
});
|
|
407
399
|
}
|
|
408
|
-
const
|
|
409
|
-
function
|
|
400
|
+
const Z = rt ? window : void 0;
|
|
401
|
+
function ht(o) {
|
|
410
402
|
var e;
|
|
411
|
-
const t = J(
|
|
403
|
+
const t = J(o);
|
|
412
404
|
return (e = t?.$el) !== null && e !== void 0 ? e : t;
|
|
413
405
|
}
|
|
414
|
-
function
|
|
415
|
-
const e =
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
var a, c;
|
|
406
|
+
function X(...o) {
|
|
407
|
+
const e = (r, n, s, i) => (r.addEventListener(n, s, i), () => r.removeEventListener(n, s, i)), t = B(() => {
|
|
408
|
+
const r = Se(J(o[0])).filter((n) => n != null);
|
|
409
|
+
return r.every((n) => typeof n != "string") ? r : void 0;
|
|
410
|
+
});
|
|
411
|
+
return pt(() => {
|
|
412
|
+
var r, n;
|
|
422
413
|
return [
|
|
423
|
-
(
|
|
424
|
-
Se(J(
|
|
425
|
-
Se(
|
|
426
|
-
J(
|
|
414
|
+
(r = (n = t.value) === null || n === void 0 ? void 0 : n.map((s) => ht(s))) !== null && r !== void 0 ? r : [Z].filter((s) => s != null),
|
|
415
|
+
Se(J(t.value ? o[1] : o[0])),
|
|
416
|
+
Se(Ye(t.value ? o[2] : o[1])),
|
|
417
|
+
J(t.value ? o[3] : o[2])
|
|
427
418
|
];
|
|
428
|
-
}, ([
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
};
|
|
435
|
-
return rt(t), i;
|
|
419
|
+
}, ([r, n, s, i], a, c) => {
|
|
420
|
+
if (!r?.length || !n?.length || !s?.length) return;
|
|
421
|
+
const h = nt(i) ? { ...i } : i, b = r.flatMap((w) => n.flatMap((P) => s.map((D) => e(w, P, D, h))));
|
|
422
|
+
c(() => {
|
|
423
|
+
b.forEach((w) => w());
|
|
424
|
+
});
|
|
425
|
+
}, { flush: "post" });
|
|
436
426
|
}
|
|
437
|
-
const
|
|
438
|
-
function
|
|
439
|
-
return
|
|
427
|
+
const fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, de = "__vueuse_ssr_handlers__", gt = /* @__PURE__ */ vt();
|
|
428
|
+
function vt() {
|
|
429
|
+
return de in fe || (fe[de] = fe[de] || {}), fe[de];
|
|
440
430
|
}
|
|
441
|
-
function
|
|
442
|
-
return
|
|
431
|
+
function yt(o, e) {
|
|
432
|
+
return gt[o] || e;
|
|
443
433
|
}
|
|
444
|
-
function
|
|
445
|
-
return
|
|
434
|
+
function mt(o) {
|
|
435
|
+
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";
|
|
446
436
|
}
|
|
447
|
-
const
|
|
437
|
+
const St = {
|
|
448
438
|
boolean: {
|
|
449
|
-
read: (
|
|
450
|
-
write: (
|
|
439
|
+
read: (o) => o === "true",
|
|
440
|
+
write: (o) => String(o)
|
|
451
441
|
},
|
|
452
442
|
object: {
|
|
453
|
-
read: (
|
|
454
|
-
write: (
|
|
443
|
+
read: (o) => JSON.parse(o),
|
|
444
|
+
write: (o) => JSON.stringify(o)
|
|
455
445
|
},
|
|
456
446
|
number: {
|
|
457
|
-
read: (
|
|
458
|
-
write: (
|
|
447
|
+
read: (o) => Number.parseFloat(o),
|
|
448
|
+
write: (o) => String(o)
|
|
459
449
|
},
|
|
460
450
|
any: {
|
|
461
|
-
read: (
|
|
462
|
-
write: (
|
|
451
|
+
read: (o) => o,
|
|
452
|
+
write: (o) => String(o)
|
|
463
453
|
},
|
|
464
454
|
string: {
|
|
465
|
-
read: (
|
|
466
|
-
write: (
|
|
455
|
+
read: (o) => o,
|
|
456
|
+
write: (o) => String(o)
|
|
467
457
|
},
|
|
468
458
|
map: {
|
|
469
|
-
read: (
|
|
470
|
-
write: (
|
|
459
|
+
read: (o) => new Map(JSON.parse(o)),
|
|
460
|
+
write: (o) => JSON.stringify(Array.from(o.entries()))
|
|
471
461
|
},
|
|
472
462
|
set: {
|
|
473
|
-
read: (
|
|
474
|
-
write: (
|
|
463
|
+
read: (o) => new Set(JSON.parse(o)),
|
|
464
|
+
write: (o) => JSON.stringify(Array.from(o))
|
|
475
465
|
},
|
|
476
466
|
date: {
|
|
477
|
-
read: (
|
|
478
|
-
write: (
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
function
|
|
482
|
-
var
|
|
483
|
-
const { flush: s = "pre", deep: i = !0, listenToStorageChanges: a = !0, writeDefaults: c = !0, mergeDefaults:
|
|
484
|
-
console.error(
|
|
485
|
-
}, initOnMounted:
|
|
467
|
+
read: (o) => new Date(o),
|
|
468
|
+
write: (o) => o.toISOString()
|
|
469
|
+
}
|
|
470
|
+
}, Ce = "vueuse-storage";
|
|
471
|
+
function bt(o, e, t, r = {}) {
|
|
472
|
+
var n;
|
|
473
|
+
const { flush: s = "pre", deep: i = !0, listenToStorageChanges: a = !0, writeDefaults: c = !0, mergeDefaults: h = !1, shallow: b, window: w = Z, eventFilter: P, onError: D = (f) => {
|
|
474
|
+
console.error(f);
|
|
475
|
+
}, initOnMounted: C } = r, F = (b ? xe : L)(e), _ = B(() => J(o));
|
|
486
476
|
if (!t) try {
|
|
487
|
-
t =
|
|
488
|
-
} catch (
|
|
489
|
-
|
|
477
|
+
t = yt("getDefaultStorage", () => Z?.localStorage)();
|
|
478
|
+
} catch (f) {
|
|
479
|
+
D(f);
|
|
490
480
|
}
|
|
491
|
-
if (!t) return
|
|
492
|
-
const
|
|
481
|
+
if (!t) return F;
|
|
482
|
+
const $ = J(e), R = mt($), S = (n = r.serializer) !== null && n !== void 0 ? n : St[R], { pause: T, resume: E } = ft(F, (f) => u(f), {
|
|
493
483
|
flush: s,
|
|
494
484
|
deep: i,
|
|
495
485
|
eventFilter: P
|
|
496
486
|
});
|
|
497
487
|
H(_, () => O(), { flush: s });
|
|
498
|
-
let
|
|
499
|
-
const g = (
|
|
500
|
-
|
|
501
|
-
}, x = (
|
|
502
|
-
|
|
488
|
+
let N = !1;
|
|
489
|
+
const g = (f) => {
|
|
490
|
+
C && !N || O(f);
|
|
491
|
+
}, x = (f) => {
|
|
492
|
+
C && !N || y(f);
|
|
503
493
|
};
|
|
504
|
-
w && a && (t instanceof Storage ?
|
|
505
|
-
|
|
494
|
+
w && a && (t instanceof Storage ? X(w, "storage", g, { passive: !0 }) : X(w, Ce, x)), C ? dt(() => {
|
|
495
|
+
N = !0, O();
|
|
506
496
|
}) : O();
|
|
507
|
-
function
|
|
497
|
+
function M(f, m) {
|
|
508
498
|
if (w) {
|
|
509
|
-
const
|
|
499
|
+
const I = {
|
|
510
500
|
key: _.value,
|
|
511
|
-
oldValue:
|
|
501
|
+
oldValue: f,
|
|
512
502
|
newValue: m,
|
|
513
503
|
storageArea: t
|
|
514
504
|
};
|
|
515
|
-
w.dispatchEvent(t instanceof Storage ? new StorageEvent("storage",
|
|
505
|
+
w.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", I) : new CustomEvent(Ce, { detail: I }));
|
|
516
506
|
}
|
|
517
507
|
}
|
|
518
|
-
function u(
|
|
508
|
+
function u(f) {
|
|
519
509
|
try {
|
|
520
510
|
const m = t.getItem(_.value);
|
|
521
|
-
if (
|
|
522
|
-
|
|
511
|
+
if (f == null)
|
|
512
|
+
M(m, null), t.removeItem(_.value);
|
|
523
513
|
else {
|
|
524
|
-
const
|
|
525
|
-
m !==
|
|
514
|
+
const I = S.write(f);
|
|
515
|
+
m !== I && (t.setItem(_.value, I), M(m, I));
|
|
526
516
|
}
|
|
527
517
|
} catch (m) {
|
|
528
|
-
|
|
518
|
+
D(m);
|
|
529
519
|
}
|
|
530
520
|
}
|
|
531
|
-
function f
|
|
532
|
-
const m =
|
|
521
|
+
function l(f) {
|
|
522
|
+
const m = f ? f.newValue : t.getItem(_.value);
|
|
533
523
|
if (m == null)
|
|
534
|
-
return c &&
|
|
535
|
-
if (!
|
|
536
|
-
const
|
|
537
|
-
return typeof
|
|
538
|
-
|
|
539
|
-
...
|
|
540
|
-
} :
|
|
541
|
-
} else return typeof m != "string" ? m :
|
|
542
|
-
}
|
|
543
|
-
function O(
|
|
544
|
-
if (!(
|
|
545
|
-
if (
|
|
546
|
-
|
|
524
|
+
return c && $ != null && t.setItem(_.value, S.write($)), $;
|
|
525
|
+
if (!f && h) {
|
|
526
|
+
const I = S.read(m);
|
|
527
|
+
return typeof h == "function" ? h(I, $) : R === "object" && !Array.isArray(I) ? {
|
|
528
|
+
...$,
|
|
529
|
+
...I
|
|
530
|
+
} : I;
|
|
531
|
+
} else return typeof m != "string" ? m : S.read(m);
|
|
532
|
+
}
|
|
533
|
+
function O(f) {
|
|
534
|
+
if (!(f && f.storageArea !== t)) {
|
|
535
|
+
if (f && f.key == null) {
|
|
536
|
+
F.value = $;
|
|
547
537
|
return;
|
|
548
538
|
}
|
|
549
|
-
if (!(
|
|
550
|
-
|
|
539
|
+
if (!(f && f.key !== _.value)) {
|
|
540
|
+
T();
|
|
551
541
|
try {
|
|
552
|
-
const m =
|
|
553
|
-
(
|
|
542
|
+
const m = S.write(F.value);
|
|
543
|
+
(f === void 0 || f?.newValue !== m) && (F.value = l(f));
|
|
554
544
|
} catch (m) {
|
|
555
|
-
|
|
545
|
+
D(m);
|
|
556
546
|
} finally {
|
|
557
|
-
|
|
547
|
+
f ? ue(E) : E();
|
|
558
548
|
}
|
|
559
549
|
}
|
|
560
550
|
}
|
|
561
551
|
}
|
|
562
|
-
function y(
|
|
563
|
-
O(
|
|
552
|
+
function y(f) {
|
|
553
|
+
O(f.detail);
|
|
564
554
|
}
|
|
565
|
-
return
|
|
555
|
+
return F;
|
|
566
556
|
}
|
|
567
|
-
function
|
|
568
|
-
const { window:
|
|
569
|
-
return
|
|
557
|
+
function wt(o, e, t = {}) {
|
|
558
|
+
const { window: r = Z } = t;
|
|
559
|
+
return bt(o, e, r?.localStorage, t);
|
|
570
560
|
}
|
|
571
|
-
const
|
|
561
|
+
const Et = {
|
|
572
562
|
ctrl: "control",
|
|
573
563
|
command: "meta",
|
|
574
564
|
cmd: "meta",
|
|
@@ -578,142 +568,144 @@ const Ot = {
|
|
|
578
568
|
left: "arrowleft",
|
|
579
569
|
right: "arrowright"
|
|
580
570
|
};
|
|
581
|
-
function
|
|
582
|
-
const { reactive: e = !1, target: t =
|
|
571
|
+
function Ot(o = {}) {
|
|
572
|
+
const { reactive: e = !1, target: t = Z, aliasMap: r = Et, passive: n = !0, onEventFired: s = We } = o, i = Ee(/* @__PURE__ */ new Set()), a = {
|
|
583
573
|
toJSON() {
|
|
584
574
|
return {};
|
|
585
575
|
},
|
|
586
576
|
current: i
|
|
587
|
-
}, c = e ?
|
|
588
|
-
["Meta",
|
|
577
|
+
}, c = e ? Ee(a) : a, h = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map([
|
|
578
|
+
["Meta", h],
|
|
589
579
|
["Shift", /* @__PURE__ */ new Set()],
|
|
590
580
|
["Alt", /* @__PURE__ */ new Set()]
|
|
591
581
|
]), w = /* @__PURE__ */ new Set();
|
|
592
|
-
function P(R,
|
|
593
|
-
R in c && (e ? c[R] =
|
|
582
|
+
function P(R, S) {
|
|
583
|
+
R in c && (e ? c[R] = S : c[R].value = S);
|
|
594
584
|
}
|
|
595
|
-
function
|
|
585
|
+
function D() {
|
|
596
586
|
i.clear();
|
|
597
587
|
for (const R of w) P(R, !1);
|
|
598
588
|
}
|
|
599
|
-
function
|
|
600
|
-
if (!(!R || typeof
|
|
601
|
-
for (const [E,
|
|
602
|
-
|
|
589
|
+
function C(R, S, T) {
|
|
590
|
+
if (!(!R || typeof S.getModifierState != "function")) {
|
|
591
|
+
for (const [E, N] of b) if (S.getModifierState(E)) {
|
|
592
|
+
T.forEach((g) => N.add(g));
|
|
603
593
|
break;
|
|
604
594
|
}
|
|
605
595
|
}
|
|
606
596
|
}
|
|
607
|
-
function
|
|
597
|
+
function F(R, S) {
|
|
608
598
|
if (R) return;
|
|
609
|
-
const
|
|
610
|
-
if (!["shift", "alt"].includes(
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
599
|
+
const T = `${S[0].toUpperCase()}${S.slice(1)}`, E = b.get(T);
|
|
600
|
+
if (!["shift", "alt"].includes(S) || !E) return;
|
|
601
|
+
const N = Array.from(E), g = N.indexOf(S);
|
|
602
|
+
N.forEach((x, M) => {
|
|
603
|
+
M >= g && (i.delete(x), P(x, !1));
|
|
614
604
|
}), E.clear();
|
|
615
605
|
}
|
|
616
|
-
function _(R,
|
|
617
|
-
var
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
i
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
606
|
+
function _(R, S) {
|
|
607
|
+
var T, E;
|
|
608
|
+
const N = (T = R.key) === null || T === void 0 ? void 0 : T.toLowerCase(), g = [(E = R.code) === null || E === void 0 ? void 0 : E.toLowerCase(), N].filter(Boolean);
|
|
609
|
+
if (N !== "") {
|
|
610
|
+
N && (S ? i.add(N) : i.delete(N));
|
|
611
|
+
for (const x of g)
|
|
612
|
+
w.add(x), P(x, S);
|
|
613
|
+
C(S, R, [...i, ...g]), F(S, N), N === "meta" && !S && (h.forEach((x) => {
|
|
614
|
+
i.delete(x), P(x, !1);
|
|
615
|
+
}), h.clear());
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
X(t, "keydown", (R) => (_(R, !0), s(R)), { passive: n }), X(t, "keyup", (R) => (_(R, !1), s(R)), { passive: n }), X("blur", D, { passive: n }), X("focus", D, { passive: n });
|
|
619
|
+
const $ = new Proxy(c, { get(R, S, T) {
|
|
620
|
+
if (typeof S != "string") return Reflect.get(R, S, T);
|
|
621
|
+
if (S = S.toLowerCase(), S in r && (S = r[S]), !(S in c)) if (/[+_-]/.test(S)) {
|
|
622
|
+
const N = S.split(/[+_-]/g).map((g) => g.trim());
|
|
623
|
+
c[S] = B(() => N.map((g) => J($[g])).every(Boolean));
|
|
624
|
+
} else c[S] = xe(!1);
|
|
625
|
+
const E = Reflect.get(R, S, T);
|
|
634
626
|
return e ? J(E) : E;
|
|
635
627
|
} });
|
|
636
|
-
return
|
|
628
|
+
return $;
|
|
637
629
|
}
|
|
638
630
|
function be() {
|
|
639
631
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
640
632
|
}
|
|
641
|
-
function
|
|
633
|
+
function pe(o) {
|
|
642
634
|
const e = {
|
|
643
|
-
type:
|
|
644
|
-
clientId:
|
|
645
|
-
timestamp:
|
|
635
|
+
type: o.type,
|
|
636
|
+
clientId: o.clientId,
|
|
637
|
+
timestamp: o.timestamp.toISOString()
|
|
646
638
|
};
|
|
647
|
-
return
|
|
648
|
-
...
|
|
649
|
-
timestamp:
|
|
650
|
-
}),
|
|
639
|
+
return o.operation && (e.operation = {
|
|
640
|
+
...o.operation,
|
|
641
|
+
timestamp: o.operation.timestamp.toISOString()
|
|
642
|
+
}), o.operations && (e.operations = o.operations.map((t) => ({
|
|
651
643
|
...t,
|
|
652
644
|
timestamp: t.timestamp.toISOString()
|
|
653
645
|
}))), e;
|
|
654
646
|
}
|
|
655
|
-
function
|
|
647
|
+
function Rt(o) {
|
|
656
648
|
const e = {
|
|
657
|
-
type:
|
|
658
|
-
clientId:
|
|
659
|
-
timestamp: new Date(
|
|
649
|
+
type: o.type,
|
|
650
|
+
clientId: o.clientId,
|
|
651
|
+
timestamp: new Date(o.timestamp)
|
|
660
652
|
};
|
|
661
|
-
return
|
|
662
|
-
...
|
|
663
|
-
timestamp: new Date(
|
|
664
|
-
}),
|
|
653
|
+
return o.operation && (e.operation = {
|
|
654
|
+
...o.operation,
|
|
655
|
+
timestamp: new Date(o.operation.timestamp)
|
|
656
|
+
}), o.operations && (e.operations = o.operations.map((t) => ({
|
|
665
657
|
...t,
|
|
666
658
|
timestamp: new Date(t.timestamp)
|
|
667
659
|
}))), e;
|
|
668
660
|
}
|
|
669
|
-
const
|
|
670
|
-
const
|
|
661
|
+
const le = /* @__PURE__ */ tt("hst-operation-log", () => {
|
|
662
|
+
const o = L({
|
|
671
663
|
maxOperations: 100,
|
|
672
664
|
enableCrossTabSync: !0,
|
|
673
665
|
autoSyncInterval: 3e4,
|
|
674
666
|
enablePersistence: !1,
|
|
675
667
|
persistenceKeyPrefix: "stonecrop-ops"
|
|
676
|
-
}), e =
|
|
677
|
-
let
|
|
678
|
-
for (let
|
|
679
|
-
|
|
680
|
-
return
|
|
681
|
-
}),
|
|
668
|
+
}), e = L([]), t = L(-1), r = L(be()), n = L(!1), s = L([]), i = L(null), a = B(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), c = B(() => t.value < e.value.length - 1), h = B(() => {
|
|
669
|
+
let d = 0;
|
|
670
|
+
for (let p = t.value; p >= 0 && e.value[p]?.reversible; p--)
|
|
671
|
+
d++;
|
|
672
|
+
return d;
|
|
673
|
+
}), b = B(() => e.value.length - 1 - t.value), w = B(() => ({
|
|
682
674
|
canUndo: a.value,
|
|
683
675
|
canRedo: c.value,
|
|
684
|
-
undoCount:
|
|
685
|
-
redoCount:
|
|
676
|
+
undoCount: h.value,
|
|
677
|
+
redoCount: b.value,
|
|
686
678
|
currentIndex: t.value
|
|
687
679
|
}));
|
|
688
|
-
function P(
|
|
689
|
-
|
|
680
|
+
function P(d) {
|
|
681
|
+
o.value = { ...o.value, ...d }, o.value.enablePersistence && (A(), V()), o.value.enableCrossTabSync && l();
|
|
690
682
|
}
|
|
691
|
-
function
|
|
683
|
+
function D(d, p = "user") {
|
|
692
684
|
const v = {
|
|
693
|
-
...
|
|
685
|
+
...d,
|
|
694
686
|
id: be(),
|
|
695
687
|
timestamp: /* @__PURE__ */ new Date(),
|
|
696
|
-
source:
|
|
697
|
-
userId:
|
|
688
|
+
source: p,
|
|
689
|
+
userId: o.value.userId
|
|
698
690
|
};
|
|
699
|
-
if (
|
|
691
|
+
if (o.value.operationFilter && !o.value.operationFilter(v))
|
|
700
692
|
return v.id;
|
|
701
|
-
if (
|
|
693
|
+
if (n.value)
|
|
702
694
|
return s.value.push(v), v.id;
|
|
703
|
-
if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(v), t.value++,
|
|
704
|
-
const
|
|
705
|
-
e.value = e.value.slice(
|
|
695
|
+
if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(v), t.value++, o.value.maxOperations && e.value.length > o.value.maxOperations) {
|
|
696
|
+
const k = e.value.length - o.value.maxOperations;
|
|
697
|
+
e.value = e.value.slice(k), t.value -= k;
|
|
706
698
|
}
|
|
707
|
-
return
|
|
699
|
+
return o.value.enableCrossTabSync && O(v), v.id;
|
|
708
700
|
}
|
|
709
|
-
function
|
|
710
|
-
|
|
701
|
+
function C() {
|
|
702
|
+
n.value = !0, s.value = [], i.value = be();
|
|
711
703
|
}
|
|
712
|
-
function
|
|
713
|
-
if (!
|
|
714
|
-
return
|
|
715
|
-
const
|
|
716
|
-
id:
|
|
704
|
+
function F(d) {
|
|
705
|
+
if (!n.value || s.value.length === 0)
|
|
706
|
+
return n.value = !1, s.value = [], i.value = null, null;
|
|
707
|
+
const p = i.value, v = s.value.every((W) => W.reversible), k = {
|
|
708
|
+
id: p,
|
|
717
709
|
type: "batch",
|
|
718
710
|
path: "",
|
|
719
711
|
// Batch doesn't have a single path
|
|
@@ -726,189 +718,189 @@ const ue = /* @__PURE__ */ tt("hst-operation-log", () => {
|
|
|
726
718
|
reversible: v,
|
|
727
719
|
irreversibleReason: v ? void 0 : "Contains irreversible operations",
|
|
728
720
|
childOperationIds: s.value.map((W) => W.id),
|
|
729
|
-
metadata: { description:
|
|
721
|
+
metadata: { description: d }
|
|
730
722
|
};
|
|
731
723
|
s.value.forEach((W) => {
|
|
732
|
-
W.parentOperationId =
|
|
733
|
-
}), e.value.push(...s.value,
|
|
734
|
-
const z =
|
|
735
|
-
return
|
|
724
|
+
W.parentOperationId = p;
|
|
725
|
+
}), e.value.push(...s.value, k), t.value = e.value.length - 1, o.value.enableCrossTabSync && y(s.value, k);
|
|
726
|
+
const z = p;
|
|
727
|
+
return n.value = !1, s.value = [], i.value = null, z;
|
|
736
728
|
}
|
|
737
729
|
function _() {
|
|
738
|
-
|
|
730
|
+
n.value = !1, s.value = [], i.value = null;
|
|
739
731
|
}
|
|
740
|
-
function
|
|
732
|
+
function $(d) {
|
|
741
733
|
if (!a.value) return !1;
|
|
742
|
-
const
|
|
743
|
-
if (!
|
|
744
|
-
return typeof console < "u" &&
|
|
734
|
+
const p = e.value[t.value];
|
|
735
|
+
if (!p.reversible)
|
|
736
|
+
return typeof console < "u" && p.irreversibleReason && console.warn("Cannot undo irreversible operation:", p.irreversibleReason), !1;
|
|
745
737
|
try {
|
|
746
|
-
if (
|
|
747
|
-
for (let v =
|
|
748
|
-
const
|
|
749
|
-
z &&
|
|
738
|
+
if (p.type === "batch" && p.childOperationIds)
|
|
739
|
+
for (let v = p.childOperationIds.length - 1; v >= 0; v--) {
|
|
740
|
+
const k = p.childOperationIds[v], z = e.value.find((W) => W.id === k);
|
|
741
|
+
z && S(z, d);
|
|
750
742
|
}
|
|
751
743
|
else
|
|
752
|
-
|
|
753
|
-
return t.value--,
|
|
744
|
+
S(p, d);
|
|
745
|
+
return t.value--, o.value.enableCrossTabSync && f(p), !0;
|
|
754
746
|
} catch (v) {
|
|
755
747
|
return typeof console < "u" && console.error("Undo failed:", v), !1;
|
|
756
748
|
}
|
|
757
749
|
}
|
|
758
|
-
function R(
|
|
750
|
+
function R(d) {
|
|
759
751
|
if (!c.value) return !1;
|
|
760
|
-
const
|
|
752
|
+
const p = e.value[t.value + 1];
|
|
761
753
|
try {
|
|
762
|
-
if (
|
|
763
|
-
for (const v of
|
|
764
|
-
const
|
|
765
|
-
|
|
754
|
+
if (p.type === "batch" && p.childOperationIds)
|
|
755
|
+
for (const v of p.childOperationIds) {
|
|
756
|
+
const k = e.value.find((z) => z.id === v);
|
|
757
|
+
k && T(k, d);
|
|
766
758
|
}
|
|
767
759
|
else
|
|
768
|
-
|
|
769
|
-
return t.value++,
|
|
760
|
+
T(p, d);
|
|
761
|
+
return t.value++, o.value.enableCrossTabSync && m(p), !0;
|
|
770
762
|
} catch (v) {
|
|
771
763
|
return typeof console < "u" && console.error("Redo failed:", v), !1;
|
|
772
764
|
}
|
|
773
765
|
}
|
|
774
|
-
function
|
|
775
|
-
(
|
|
766
|
+
function S(d, p) {
|
|
767
|
+
(d.type === "set" || d.type === "delete") && p && typeof p.set == "function" && p.set(d.path, d.beforeValue, "undo");
|
|
776
768
|
}
|
|
777
|
-
function
|
|
778
|
-
(
|
|
769
|
+
function T(d, p) {
|
|
770
|
+
(d.type === "set" || d.type === "delete") && p && typeof p.set == "function" && p.set(d.path, d.afterValue, "redo");
|
|
779
771
|
}
|
|
780
772
|
function E() {
|
|
781
|
-
const
|
|
773
|
+
const d = e.value.filter((v) => v.reversible).length, p = e.value.map((v) => v.timestamp);
|
|
782
774
|
return {
|
|
783
775
|
operations: [...e.value],
|
|
784
776
|
currentIndex: t.value,
|
|
785
777
|
totalOperations: e.value.length,
|
|
786
|
-
reversibleOperations:
|
|
787
|
-
irreversibleOperations: e.value.length -
|
|
788
|
-
oldestOperation:
|
|
789
|
-
newestOperation:
|
|
778
|
+
reversibleOperations: d,
|
|
779
|
+
irreversibleOperations: e.value.length - d,
|
|
780
|
+
oldestOperation: p.length > 0 ? new Date(Math.min(...p.map((v) => v.getTime()))) : void 0,
|
|
781
|
+
newestOperation: p.length > 0 ? new Date(Math.max(...p.map((v) => v.getTime()))) : void 0
|
|
790
782
|
};
|
|
791
783
|
}
|
|
792
|
-
function
|
|
784
|
+
function N() {
|
|
793
785
|
e.value = [], t.value = -1;
|
|
794
786
|
}
|
|
795
|
-
function g(
|
|
796
|
-
return e.value.filter((v) => v.doctype ===
|
|
787
|
+
function g(d, p) {
|
|
788
|
+
return e.value.filter((v) => v.doctype === d && (p === void 0 || v.recordId === p));
|
|
797
789
|
}
|
|
798
|
-
function x(
|
|
799
|
-
const v = e.value.find((
|
|
800
|
-
v && (v.reversible = !1, v.irreversibleReason =
|
|
790
|
+
function x(d, p) {
|
|
791
|
+
const v = e.value.find((k) => k.id === d);
|
|
792
|
+
v && (v.reversible = !1, v.irreversibleReason = p);
|
|
801
793
|
}
|
|
802
|
-
function
|
|
794
|
+
function M(d, p, v, k = "success", z) {
|
|
803
795
|
const W = {
|
|
804
796
|
type: "action",
|
|
805
|
-
path: v && v.length > 0 ? `${
|
|
797
|
+
path: v && v.length > 0 ? `${d}.${v[0]}` : d,
|
|
806
798
|
fieldname: "",
|
|
807
799
|
beforeValue: null,
|
|
808
800
|
afterValue: null,
|
|
809
|
-
doctype:
|
|
801
|
+
doctype: d,
|
|
810
802
|
recordId: v && v.length > 0 ? v[0] : void 0,
|
|
811
803
|
reversible: !1,
|
|
812
804
|
// Actions are typically not reversible
|
|
813
|
-
actionName:
|
|
805
|
+
actionName: p,
|
|
814
806
|
actionRecordIds: v,
|
|
815
|
-
actionResult:
|
|
807
|
+
actionResult: k,
|
|
816
808
|
actionError: z
|
|
817
809
|
};
|
|
818
|
-
return
|
|
810
|
+
return D(W);
|
|
819
811
|
}
|
|
820
812
|
let u = null;
|
|
821
|
-
function
|
|
822
|
-
typeof window > "u" || !window.BroadcastChannel || (u = new BroadcastChannel("stonecrop-operation-log"), u.addEventListener("message", (
|
|
823
|
-
const
|
|
824
|
-
if (!
|
|
825
|
-
const v =
|
|
826
|
-
v.clientId !==
|
|
813
|
+
function l() {
|
|
814
|
+
typeof window > "u" || !window.BroadcastChannel || (u = new BroadcastChannel("stonecrop-operation-log"), u.addEventListener("message", (d) => {
|
|
815
|
+
const p = d.data;
|
|
816
|
+
if (!p || typeof p != "object") return;
|
|
817
|
+
const v = Rt(p);
|
|
818
|
+
v.clientId !== r.value && (v.type === "operation" && v.operation ? (e.value.push({ ...v.operation, source: "sync" }), t.value = e.value.length - 1) : v.type === "operation" && v.operations && (e.value.push(...v.operations.map((k) => ({ ...k, source: "sync" }))), t.value = e.value.length - 1));
|
|
827
819
|
}));
|
|
828
820
|
}
|
|
829
|
-
function O(
|
|
821
|
+
function O(d) {
|
|
830
822
|
if (!u) return;
|
|
831
|
-
const
|
|
823
|
+
const p = {
|
|
832
824
|
type: "operation",
|
|
833
|
-
operation:
|
|
834
|
-
clientId:
|
|
825
|
+
operation: d,
|
|
826
|
+
clientId: r.value,
|
|
835
827
|
timestamp: /* @__PURE__ */ new Date()
|
|
836
828
|
};
|
|
837
|
-
u.postMessage(
|
|
829
|
+
u.postMessage(pe(p));
|
|
838
830
|
}
|
|
839
|
-
function y(
|
|
831
|
+
function y(d, p) {
|
|
840
832
|
if (!u) return;
|
|
841
833
|
const v = {
|
|
842
834
|
type: "operation",
|
|
843
|
-
operations: [...
|
|
844
|
-
clientId:
|
|
835
|
+
operations: [...d, p],
|
|
836
|
+
clientId: r.value,
|
|
845
837
|
timestamp: /* @__PURE__ */ new Date()
|
|
846
838
|
};
|
|
847
|
-
u.postMessage(
|
|
839
|
+
u.postMessage(pe(v));
|
|
848
840
|
}
|
|
849
|
-
function d
|
|
841
|
+
function f(d) {
|
|
850
842
|
if (!u) return;
|
|
851
|
-
const
|
|
843
|
+
const p = {
|
|
852
844
|
type: "undo",
|
|
853
|
-
operation:
|
|
854
|
-
clientId:
|
|
845
|
+
operation: d,
|
|
846
|
+
clientId: r.value,
|
|
855
847
|
timestamp: /* @__PURE__ */ new Date()
|
|
856
848
|
};
|
|
857
|
-
u.postMessage(
|
|
849
|
+
u.postMessage(pe(p));
|
|
858
850
|
}
|
|
859
|
-
function m(
|
|
851
|
+
function m(d) {
|
|
860
852
|
if (!u) return;
|
|
861
|
-
const
|
|
853
|
+
const p = {
|
|
862
854
|
type: "redo",
|
|
863
|
-
operation:
|
|
864
|
-
clientId:
|
|
855
|
+
operation: d,
|
|
856
|
+
clientId: r.value,
|
|
865
857
|
timestamp: /* @__PURE__ */ new Date()
|
|
866
858
|
};
|
|
867
|
-
u.postMessage(
|
|
859
|
+
u.postMessage(pe(p));
|
|
868
860
|
}
|
|
869
|
-
const
|
|
861
|
+
const I = wt("stonecrop-ops-operations", null, {
|
|
870
862
|
serializer: {
|
|
871
|
-
read: (
|
|
863
|
+
read: (d) => {
|
|
872
864
|
try {
|
|
873
|
-
return JSON.parse(
|
|
865
|
+
return JSON.parse(d);
|
|
874
866
|
} catch {
|
|
875
867
|
return null;
|
|
876
868
|
}
|
|
877
869
|
},
|
|
878
|
-
write: (
|
|
870
|
+
write: (d) => d ? JSON.stringify(d) : ""
|
|
879
871
|
}
|
|
880
872
|
});
|
|
881
873
|
function A() {
|
|
882
874
|
if (!(typeof window > "u"))
|
|
883
875
|
try {
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
...
|
|
887
|
-
timestamp: new Date(
|
|
888
|
-
})), t.value =
|
|
889
|
-
} catch (
|
|
890
|
-
typeof console < "u" && console.error("Failed to load operations from persistence:",
|
|
876
|
+
const d = I.value;
|
|
877
|
+
d && Array.isArray(d.operations) && (e.value = d.operations.map((p) => ({
|
|
878
|
+
...p,
|
|
879
|
+
timestamp: new Date(p.timestamp)
|
|
880
|
+
})), t.value = d.currentIndex ?? -1);
|
|
881
|
+
} catch (d) {
|
|
882
|
+
typeof console < "u" && console.error("Failed to load operations from persistence:", d);
|
|
891
883
|
}
|
|
892
884
|
}
|
|
893
885
|
function j() {
|
|
894
886
|
if (!(typeof window > "u"))
|
|
895
887
|
try {
|
|
896
|
-
|
|
897
|
-
operations: e.value.map((
|
|
898
|
-
...
|
|
899
|
-
timestamp:
|
|
888
|
+
I.value = {
|
|
889
|
+
operations: e.value.map((d) => ({
|
|
890
|
+
...d,
|
|
891
|
+
timestamp: d.timestamp.toISOString()
|
|
900
892
|
})),
|
|
901
893
|
currentIndex: t.value
|
|
902
894
|
};
|
|
903
|
-
} catch (
|
|
904
|
-
typeof console < "u" && console.error("Failed to save operations to persistence:",
|
|
895
|
+
} catch (d) {
|
|
896
|
+
typeof console < "u" && console.error("Failed to save operations to persistence:", d);
|
|
905
897
|
}
|
|
906
898
|
}
|
|
907
899
|
function V() {
|
|
908
900
|
H(
|
|
909
901
|
[e, t],
|
|
910
902
|
() => {
|
|
911
|
-
|
|
903
|
+
o.value.enablePersistence && j();
|
|
912
904
|
},
|
|
913
905
|
{ deep: !0 }
|
|
914
906
|
);
|
|
@@ -917,30 +909,30 @@ const ue = /* @__PURE__ */ tt("hst-operation-log", () => {
|
|
|
917
909
|
// State
|
|
918
910
|
operations: e,
|
|
919
911
|
currentIndex: t,
|
|
920
|
-
config:
|
|
921
|
-
clientId:
|
|
912
|
+
config: o,
|
|
913
|
+
clientId: r,
|
|
922
914
|
undoRedoState: w,
|
|
923
915
|
// Computed
|
|
924
916
|
canUndo: a,
|
|
925
917
|
canRedo: c,
|
|
926
|
-
undoCount:
|
|
927
|
-
redoCount:
|
|
918
|
+
undoCount: h,
|
|
919
|
+
redoCount: b,
|
|
928
920
|
// Methods
|
|
929
921
|
configure: P,
|
|
930
|
-
addOperation:
|
|
931
|
-
startBatch:
|
|
932
|
-
commitBatch:
|
|
922
|
+
addOperation: D,
|
|
923
|
+
startBatch: C,
|
|
924
|
+
commitBatch: F,
|
|
933
925
|
cancelBatch: _,
|
|
934
|
-
undo:
|
|
926
|
+
undo: $,
|
|
935
927
|
redo: R,
|
|
936
|
-
clear:
|
|
928
|
+
clear: N,
|
|
937
929
|
getOperationsFor: g,
|
|
938
930
|
getSnapshot: E,
|
|
939
931
|
markIrreversible: x,
|
|
940
|
-
logAction:
|
|
932
|
+
logAction: M
|
|
941
933
|
};
|
|
942
934
|
});
|
|
943
|
-
class
|
|
935
|
+
class ae {
|
|
944
936
|
/**
|
|
945
937
|
* The root FieldTriggerEngine instance
|
|
946
938
|
*/
|
|
@@ -961,9 +953,9 @@ class ie {
|
|
|
961
953
|
* @param options - Configuration options for the field trigger engine
|
|
962
954
|
*/
|
|
963
955
|
constructor(e = {}) {
|
|
964
|
-
if (
|
|
965
|
-
return
|
|
966
|
-
|
|
956
|
+
if (ae._root)
|
|
957
|
+
return ae._root;
|
|
958
|
+
ae._root = this, this.options = {
|
|
967
959
|
defaultTimeout: e.defaultTimeout ?? 5e3,
|
|
968
960
|
debug: e.debug ?? !1,
|
|
969
961
|
enableRollback: e.enableRollback ?? !0,
|
|
@@ -992,8 +984,8 @@ class ie {
|
|
|
992
984
|
* @param fieldname - The field name
|
|
993
985
|
* @param enableRollback - Whether to enable rollback
|
|
994
986
|
*/
|
|
995
|
-
setFieldRollback(e, t,
|
|
996
|
-
this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(t,
|
|
987
|
+
setFieldRollback(e, t, r) {
|
|
988
|
+
this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(t, r);
|
|
997
989
|
}
|
|
998
990
|
/**
|
|
999
991
|
* Get rollback configuration for a specific field trigger
|
|
@@ -1009,25 +1001,25 @@ class ie {
|
|
|
1009
1001
|
*/
|
|
1010
1002
|
registerDoctypeActions(e, t) {
|
|
1011
1003
|
if (!t) return;
|
|
1012
|
-
const
|
|
1004
|
+
const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1013
1005
|
if (typeof t.entrySeq == "function")
|
|
1014
1006
|
t.entrySeq().forEach(([s, i]) => {
|
|
1015
|
-
this.categorizeAction(s, i,
|
|
1007
|
+
this.categorizeAction(s, i, r, n);
|
|
1016
1008
|
});
|
|
1017
1009
|
else if (t instanceof Map)
|
|
1018
1010
|
for (const [s, i] of t)
|
|
1019
|
-
this.categorizeAction(s, i,
|
|
1011
|
+
this.categorizeAction(s, i, r, n);
|
|
1020
1012
|
else t && typeof t == "object" && Object.entries(t).forEach(([s, i]) => {
|
|
1021
|
-
this.categorizeAction(s, i,
|
|
1013
|
+
this.categorizeAction(s, i, r, n);
|
|
1022
1014
|
});
|
|
1023
|
-
this.doctypeActions.set(e,
|
|
1015
|
+
this.doctypeActions.set(e, r), this.doctypeTransitions.set(e, n);
|
|
1024
1016
|
}
|
|
1025
1017
|
/**
|
|
1026
1018
|
* Categorize an action as either a field trigger or XState transition
|
|
1027
1019
|
* Uses uppercase convention: UPPERCASE = transition, lowercase/mixed = field trigger
|
|
1028
1020
|
*/
|
|
1029
|
-
categorizeAction(e, t,
|
|
1030
|
-
this.isTransitionKey(e) ?
|
|
1021
|
+
categorizeAction(e, t, r, n) {
|
|
1022
|
+
this.isTransitionKey(e) ? n.set(e, t) : r.set(e, t);
|
|
1031
1023
|
}
|
|
1032
1024
|
/**
|
|
1033
1025
|
* Determine if a key represents an XState transition
|
|
@@ -1042,7 +1034,7 @@ class ie {
|
|
|
1042
1034
|
* @param options - Execution options (timeout and enableRollback)
|
|
1043
1035
|
*/
|
|
1044
1036
|
async executeFieldTriggers(e, t = {}) {
|
|
1045
|
-
const { doctype:
|
|
1037
|
+
const { doctype: r, fieldname: n } = e, s = this.findFieldTriggers(r, n);
|
|
1046
1038
|
if (s.length === 0)
|
|
1047
1039
|
return {
|
|
1048
1040
|
path: e.path,
|
|
@@ -1053,48 +1045,48 @@ class ie {
|
|
|
1053
1045
|
rolledBack: !1
|
|
1054
1046
|
};
|
|
1055
1047
|
const i = performance.now(), a = [];
|
|
1056
|
-
let c = !1,
|
|
1057
|
-
const w = this.getFieldRollback(
|
|
1058
|
-
P && e.store && (
|
|
1048
|
+
let c = !1, h = !1, b;
|
|
1049
|
+
const w = this.getFieldRollback(r, n), P = t.enableRollback ?? w ?? this.options.enableRollback;
|
|
1050
|
+
P && e.store && (b = this.captureSnapshot(e));
|
|
1059
1051
|
for (const _ of s)
|
|
1060
1052
|
try {
|
|
1061
|
-
const
|
|
1062
|
-
if (a.push(
|
|
1053
|
+
const $ = await this.executeAction(_, e, t.timeout);
|
|
1054
|
+
if (a.push($), !$.success) {
|
|
1063
1055
|
c = !0;
|
|
1064
1056
|
break;
|
|
1065
1057
|
}
|
|
1066
|
-
} catch (
|
|
1067
|
-
const
|
|
1058
|
+
} catch ($) {
|
|
1059
|
+
const S = {
|
|
1068
1060
|
success: !1,
|
|
1069
|
-
error:
|
|
1061
|
+
error: $ instanceof Error ? $ : new Error(String($)),
|
|
1070
1062
|
executionTime: 0,
|
|
1071
1063
|
action: _
|
|
1072
1064
|
};
|
|
1073
|
-
a.push(
|
|
1065
|
+
a.push(S), c = !0;
|
|
1074
1066
|
break;
|
|
1075
1067
|
}
|
|
1076
|
-
if (P && c &&
|
|
1068
|
+
if (P && c && b && e.store)
|
|
1077
1069
|
try {
|
|
1078
|
-
this.restoreSnapshot(e,
|
|
1070
|
+
this.restoreSnapshot(e, b), h = !0;
|
|
1079
1071
|
} catch (_) {
|
|
1080
1072
|
console.error("[FieldTriggers] Rollback failed:", _);
|
|
1081
1073
|
}
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
for (const _ of
|
|
1074
|
+
const D = performance.now() - i, C = a.filter((_) => !_.success);
|
|
1075
|
+
if (C.length > 0 && this.options.errorHandler)
|
|
1076
|
+
for (const _ of C)
|
|
1085
1077
|
try {
|
|
1086
1078
|
this.options.errorHandler(_.error, e, _.action);
|
|
1087
|
-
} catch (
|
|
1088
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
1079
|
+
} catch ($) {
|
|
1080
|
+
console.error("[FieldTriggers] Error in global error handler:", $);
|
|
1089
1081
|
}
|
|
1090
1082
|
return {
|
|
1091
1083
|
path: e.path,
|
|
1092
1084
|
actionResults: a,
|
|
1093
|
-
totalExecutionTime:
|
|
1085
|
+
totalExecutionTime: D,
|
|
1094
1086
|
allSucceeded: a.every((_) => _.success),
|
|
1095
1087
|
stoppedOnError: c,
|
|
1096
|
-
rolledBack:
|
|
1097
|
-
snapshot: this.options.debug && P ?
|
|
1088
|
+
rolledBack: h,
|
|
1089
|
+
snapshot: this.options.debug && P ? b : void 0
|
|
1098
1090
|
// Only include snapshot in debug mode if rollback is enabled
|
|
1099
1091
|
};
|
|
1100
1092
|
}
|
|
@@ -1105,22 +1097,22 @@ class ie {
|
|
|
1105
1097
|
* @param options - Execution options (timeout)
|
|
1106
1098
|
*/
|
|
1107
1099
|
async executeTransitionActions(e, t = {}) {
|
|
1108
|
-
const { doctype:
|
|
1100
|
+
const { doctype: r, transition: n } = e, s = this.findTransitionActions(r, n);
|
|
1109
1101
|
if (s.length === 0)
|
|
1110
1102
|
return [];
|
|
1111
1103
|
const i = [];
|
|
1112
1104
|
for (const c of s)
|
|
1113
1105
|
try {
|
|
1114
|
-
const
|
|
1115
|
-
if (i.push(
|
|
1106
|
+
const h = await this.executeTransitionAction(c, e, t.timeout);
|
|
1107
|
+
if (i.push(h), !h.success)
|
|
1116
1108
|
break;
|
|
1117
|
-
} catch (
|
|
1109
|
+
} catch (h) {
|
|
1118
1110
|
const w = {
|
|
1119
1111
|
success: !1,
|
|
1120
|
-
error:
|
|
1112
|
+
error: h instanceof Error ? h : new Error(String(h)),
|
|
1121
1113
|
executionTime: 0,
|
|
1122
1114
|
action: c,
|
|
1123
|
-
transition:
|
|
1115
|
+
transition: n
|
|
1124
1116
|
};
|
|
1125
1117
|
i.push(w);
|
|
1126
1118
|
break;
|
|
@@ -1130,8 +1122,8 @@ class ie {
|
|
|
1130
1122
|
for (const c of a)
|
|
1131
1123
|
try {
|
|
1132
1124
|
this.options.errorHandler(c.error, e, c.action);
|
|
1133
|
-
} catch (
|
|
1134
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
1125
|
+
} catch (h) {
|
|
1126
|
+
console.error("[FieldTriggers] Error in global error handler:", h);
|
|
1135
1127
|
}
|
|
1136
1128
|
return i;
|
|
1137
1129
|
}
|
|
@@ -1139,14 +1131,14 @@ class ie {
|
|
|
1139
1131
|
* Find transition actions for a specific doctype and transition
|
|
1140
1132
|
*/
|
|
1141
1133
|
findTransitionActions(e, t) {
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1134
|
+
const r = this.doctypeTransitions.get(e);
|
|
1135
|
+
return r ? r.get(t) || [] : [];
|
|
1144
1136
|
}
|
|
1145
1137
|
/**
|
|
1146
1138
|
* Execute a single transition action by name
|
|
1147
1139
|
*/
|
|
1148
|
-
async executeTransitionAction(e, t,
|
|
1149
|
-
const
|
|
1140
|
+
async executeTransitionAction(e, t, r) {
|
|
1141
|
+
const n = performance.now(), s = r ?? this.options.defaultTimeout;
|
|
1150
1142
|
try {
|
|
1151
1143
|
let i = this.globalTransitionActions.get(e);
|
|
1152
1144
|
if (!i) {
|
|
@@ -1157,12 +1149,12 @@ class ie {
|
|
|
1157
1149
|
throw new Error(`Transition action "${e}" not found in registry`);
|
|
1158
1150
|
return await this.executeWithTimeout(i, t, s), {
|
|
1159
1151
|
success: !0,
|
|
1160
|
-
executionTime: performance.now() -
|
|
1152
|
+
executionTime: performance.now() - n,
|
|
1161
1153
|
action: e,
|
|
1162
1154
|
transition: t.transition
|
|
1163
1155
|
};
|
|
1164
1156
|
} catch (i) {
|
|
1165
|
-
const a = performance.now() -
|
|
1157
|
+
const a = performance.now() - n;
|
|
1166
1158
|
return {
|
|
1167
1159
|
success: !1,
|
|
1168
1160
|
error: i instanceof Error ? i : new Error(String(i)),
|
|
@@ -1177,12 +1169,12 @@ class ie {
|
|
|
1177
1169
|
* Field triggers are identified by keys that look like field paths (contain dots or match field names)
|
|
1178
1170
|
*/
|
|
1179
1171
|
findFieldTriggers(e, t) {
|
|
1180
|
-
const
|
|
1181
|
-
if (!
|
|
1182
|
-
const
|
|
1183
|
-
for (const [s, i] of
|
|
1184
|
-
this.isFieldTriggerKey(s, t) &&
|
|
1185
|
-
return
|
|
1172
|
+
const r = this.doctypeActions.get(e);
|
|
1173
|
+
if (!r) return [];
|
|
1174
|
+
const n = [];
|
|
1175
|
+
for (const [s, i] of r)
|
|
1176
|
+
this.isFieldTriggerKey(s, t) && n.push(...i);
|
|
1177
|
+
return n;
|
|
1186
1178
|
}
|
|
1187
1179
|
/**
|
|
1188
1180
|
* Determine if an action key represents a field trigger
|
|
@@ -1199,11 +1191,11 @@ class ie {
|
|
|
1199
1191
|
* Supports wildcards (*) for dynamic segments
|
|
1200
1192
|
*/
|
|
1201
1193
|
matchFieldPattern(e, t) {
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1194
|
+
const r = e.split("."), n = t.split(".");
|
|
1195
|
+
if (r.length !== n.length)
|
|
1204
1196
|
return !1;
|
|
1205
|
-
for (let s = 0; s <
|
|
1206
|
-
const i =
|
|
1197
|
+
for (let s = 0; s < r.length; s++) {
|
|
1198
|
+
const i = r[s], a = n[s];
|
|
1207
1199
|
if (i !== "*" && i !== a)
|
|
1208
1200
|
return !1;
|
|
1209
1201
|
}
|
|
@@ -1212,19 +1204,19 @@ class ie {
|
|
|
1212
1204
|
/**
|
|
1213
1205
|
* Execute a single action by name
|
|
1214
1206
|
*/
|
|
1215
|
-
async executeAction(e, t,
|
|
1216
|
-
const
|
|
1207
|
+
async executeAction(e, t, r) {
|
|
1208
|
+
const n = performance.now(), s = r ?? this.options.defaultTimeout;
|
|
1217
1209
|
try {
|
|
1218
1210
|
const i = this.globalActions.get(e);
|
|
1219
1211
|
if (!i)
|
|
1220
1212
|
throw new Error(`Action "${e}" not found in registry`);
|
|
1221
1213
|
return await this.executeWithTimeout(i, t, s), {
|
|
1222
1214
|
success: !0,
|
|
1223
|
-
executionTime: performance.now() -
|
|
1215
|
+
executionTime: performance.now() - n,
|
|
1224
1216
|
action: e
|
|
1225
1217
|
};
|
|
1226
1218
|
} catch (i) {
|
|
1227
|
-
const a = performance.now() -
|
|
1219
|
+
const a = performance.now() - n;
|
|
1228
1220
|
return {
|
|
1229
1221
|
success: !1,
|
|
1230
1222
|
error: i instanceof Error ? i : new Error(String(i)),
|
|
@@ -1236,13 +1228,13 @@ class ie {
|
|
|
1236
1228
|
/**
|
|
1237
1229
|
* Execute a function with timeout
|
|
1238
1230
|
*/
|
|
1239
|
-
async executeWithTimeout(e, t,
|
|
1240
|
-
return new Promise((
|
|
1231
|
+
async executeWithTimeout(e, t, r) {
|
|
1232
|
+
return new Promise((n, s) => {
|
|
1241
1233
|
const i = setTimeout(() => {
|
|
1242
|
-
s(new Error(`Action timeout after ${
|
|
1243
|
-
},
|
|
1234
|
+
s(new Error(`Action timeout after ${r}ms`));
|
|
1235
|
+
}, r);
|
|
1244
1236
|
Promise.resolve(e(t)).then((a) => {
|
|
1245
|
-
clearTimeout(i),
|
|
1237
|
+
clearTimeout(i), n(a);
|
|
1246
1238
|
}).catch((a) => {
|
|
1247
1239
|
clearTimeout(i), s(a);
|
|
1248
1240
|
});
|
|
@@ -1255,8 +1247,8 @@ class ie {
|
|
|
1255
1247
|
captureSnapshot(e) {
|
|
1256
1248
|
if (!(!e.store || !e.doctype || !e.recordId))
|
|
1257
1249
|
try {
|
|
1258
|
-
const t = `${e.doctype}.${e.recordId}`,
|
|
1259
|
-
return !
|
|
1250
|
+
const t = `${e.doctype}.${e.recordId}`, r = e.store.get(t);
|
|
1251
|
+
return !r || typeof r != "object" ? void 0 : JSON.parse(JSON.stringify(r));
|
|
1260
1252
|
} catch (t) {
|
|
1261
1253
|
this.options.debug && console.warn("[FieldTriggers] Failed to capture snapshot:", t);
|
|
1262
1254
|
return;
|
|
@@ -1269,33 +1261,33 @@ class ie {
|
|
|
1269
1261
|
restoreSnapshot(e, t) {
|
|
1270
1262
|
if (!(!e.store || !e.doctype || !e.recordId || !t))
|
|
1271
1263
|
try {
|
|
1272
|
-
const
|
|
1273
|
-
e.store.set(
|
|
1274
|
-
} catch (
|
|
1275
|
-
throw console.error("[FieldTriggers] Failed to restore snapshot:",
|
|
1264
|
+
const r = `${e.doctype}.${e.recordId}`;
|
|
1265
|
+
e.store.set(r, t), this.options.debug && console.log(`[FieldTriggers] Rolled back ${r} to previous state`);
|
|
1266
|
+
} catch (r) {
|
|
1267
|
+
throw console.error("[FieldTriggers] Failed to restore snapshot:", r), r;
|
|
1276
1268
|
}
|
|
1277
1269
|
}
|
|
1278
1270
|
}
|
|
1279
|
-
function G(
|
|
1280
|
-
return new
|
|
1271
|
+
function G(o) {
|
|
1272
|
+
return new ae(o);
|
|
1281
1273
|
}
|
|
1282
|
-
function Dt(
|
|
1283
|
-
G().registerAction(
|
|
1274
|
+
function Dt(o, e) {
|
|
1275
|
+
G().registerAction(o, e);
|
|
1284
1276
|
}
|
|
1285
|
-
function
|
|
1286
|
-
G().registerTransitionAction(
|
|
1277
|
+
function $t(o, e) {
|
|
1278
|
+
G().registerTransitionAction(o, e);
|
|
1287
1279
|
}
|
|
1288
|
-
function
|
|
1289
|
-
G().setFieldRollback(
|
|
1280
|
+
function Tt(o, e, t) {
|
|
1281
|
+
G().setFieldRollback(o, e, t);
|
|
1290
1282
|
}
|
|
1291
|
-
async function
|
|
1292
|
-
const
|
|
1293
|
-
path: t?.path || (t?.recordId ? `${
|
|
1283
|
+
async function Ct(o, e, t) {
|
|
1284
|
+
const r = G(), n = {
|
|
1285
|
+
path: t?.path || (t?.recordId ? `${o}.${t.recordId}` : o),
|
|
1294
1286
|
fieldname: "",
|
|
1295
1287
|
beforeValue: void 0,
|
|
1296
1288
|
afterValue: void 0,
|
|
1297
1289
|
operation: "set",
|
|
1298
|
-
doctype:
|
|
1290
|
+
doctype: o,
|
|
1299
1291
|
recordId: t?.recordId,
|
|
1300
1292
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1301
1293
|
transition: e,
|
|
@@ -1303,30 +1295,30 @@ async function At(r, e, t) {
|
|
|
1303
1295
|
targetState: t?.targetState,
|
|
1304
1296
|
fsmContext: t?.fsmContext
|
|
1305
1297
|
};
|
|
1306
|
-
return await
|
|
1298
|
+
return await r.executeTransitionActions(n);
|
|
1307
1299
|
}
|
|
1308
|
-
function
|
|
1309
|
-
if (
|
|
1300
|
+
function At(o, e) {
|
|
1301
|
+
if (o)
|
|
1310
1302
|
try {
|
|
1311
|
-
|
|
1303
|
+
le().markIrreversible(o, e);
|
|
1312
1304
|
} catch {
|
|
1313
1305
|
}
|
|
1314
1306
|
}
|
|
1315
|
-
function
|
|
1307
|
+
function Ae() {
|
|
1316
1308
|
try {
|
|
1317
|
-
return
|
|
1309
|
+
return le();
|
|
1318
1310
|
} catch {
|
|
1319
1311
|
return null;
|
|
1320
1312
|
}
|
|
1321
1313
|
}
|
|
1322
|
-
class
|
|
1314
|
+
class ee {
|
|
1323
1315
|
static instance;
|
|
1324
1316
|
/**
|
|
1325
1317
|
* Gets the singleton instance of HST
|
|
1326
1318
|
* @returns The HST singleton instance
|
|
1327
1319
|
*/
|
|
1328
1320
|
static getInstance() {
|
|
1329
|
-
return
|
|
1321
|
+
return ee.instance || (ee.instance = new ee()), ee.instance;
|
|
1330
1322
|
}
|
|
1331
1323
|
/**
|
|
1332
1324
|
* Gets the global registry instance
|
|
@@ -1367,16 +1359,16 @@ class ve {
|
|
|
1367
1359
|
doctype;
|
|
1368
1360
|
parentDoctype;
|
|
1369
1361
|
hst;
|
|
1370
|
-
constructor(e, t,
|
|
1371
|
-
return this.target = e, this.parentPath =
|
|
1362
|
+
constructor(e, t, r = "", n = null, s) {
|
|
1363
|
+
return this.target = e, this.parentPath = r, this.rootNode = n || this, this.doctype = t, this.parentDoctype = s, this.hst = ee.getInstance(), new Proxy(this, {
|
|
1372
1364
|
get(i, a) {
|
|
1373
1365
|
if (a in i) return i[a];
|
|
1374
1366
|
const c = String(a);
|
|
1375
1367
|
return i.getNode(c);
|
|
1376
1368
|
},
|
|
1377
1369
|
set(i, a, c) {
|
|
1378
|
-
const
|
|
1379
|
-
return i.set(
|
|
1370
|
+
const h = String(a);
|
|
1371
|
+
return i.set(h, c), !0;
|
|
1380
1372
|
}
|
|
1381
1373
|
});
|
|
1382
1374
|
}
|
|
@@ -1385,47 +1377,47 @@ class ve {
|
|
|
1385
1377
|
}
|
|
1386
1378
|
// Method to get a tree-wrapped node for navigation
|
|
1387
1379
|
getNode(e) {
|
|
1388
|
-
const t = this.resolvePath(e),
|
|
1380
|
+
const t = this.resolvePath(e), r = this.resolveValue(e), n = t.split(".");
|
|
1389
1381
|
let s = this.doctype;
|
|
1390
|
-
return this.doctype === "StonecropStore" &&
|
|
1382
|
+
return this.doctype === "StonecropStore" && n.length >= 1 && (s = n[0]), typeof r == "object" && r !== null && !this.isPrimitive(r) ? new ve(r, s, t, this.rootNode, this.parentDoctype) : new ve(r, s, t, this.rootNode, this.parentDoctype);
|
|
1391
1383
|
}
|
|
1392
|
-
set(e, t,
|
|
1393
|
-
const
|
|
1394
|
-
if (
|
|
1395
|
-
const i =
|
|
1384
|
+
set(e, t, r = "user") {
|
|
1385
|
+
const n = this.resolvePath(e), s = this.has(e) ? this.get(e) : void 0;
|
|
1386
|
+
if (r !== "undo" && r !== "redo") {
|
|
1387
|
+
const i = Ae();
|
|
1396
1388
|
if (i && typeof i.addOperation == "function") {
|
|
1397
|
-
const a =
|
|
1389
|
+
const a = n.split("."), c = this.doctype === "StonecropStore" && a.length >= 1 ? a[0] : this.doctype, h = a.length >= 2 ? a[1] : void 0, b = a.slice(2).join(".") || a[a.length - 1], P = t === void 0 && s !== void 0 ? "delete" : "set";
|
|
1398
1390
|
i.addOperation(
|
|
1399
1391
|
{
|
|
1400
1392
|
type: P,
|
|
1401
|
-
path:
|
|
1402
|
-
fieldname:
|
|
1393
|
+
path: n,
|
|
1394
|
+
fieldname: b,
|
|
1403
1395
|
beforeValue: s,
|
|
1404
1396
|
afterValue: t,
|
|
1405
1397
|
doctype: c,
|
|
1406
|
-
recordId:
|
|
1398
|
+
recordId: h,
|
|
1407
1399
|
reversible: !0
|
|
1408
1400
|
// Default to reversible, can be changed by field triggers
|
|
1409
1401
|
},
|
|
1410
|
-
|
|
1402
|
+
r
|
|
1411
1403
|
);
|
|
1412
1404
|
}
|
|
1413
1405
|
}
|
|
1414
|
-
this.updateValue(e, t), this.triggerFieldActions(
|
|
1406
|
+
this.updateValue(e, t), this.triggerFieldActions(n, s, t);
|
|
1415
1407
|
}
|
|
1416
1408
|
has(e) {
|
|
1417
1409
|
try {
|
|
1418
1410
|
if (e === "")
|
|
1419
1411
|
return !0;
|
|
1420
1412
|
const t = this.parsePath(e);
|
|
1421
|
-
let
|
|
1422
|
-
for (let
|
|
1423
|
-
const s = t[
|
|
1424
|
-
if (
|
|
1413
|
+
let r = this.target;
|
|
1414
|
+
for (let n = 0; n < t.length; n++) {
|
|
1415
|
+
const s = t[n];
|
|
1416
|
+
if (r == null)
|
|
1425
1417
|
return !1;
|
|
1426
|
-
if (
|
|
1427
|
-
return this.isImmutable(
|
|
1428
|
-
|
|
1418
|
+
if (n === t.length - 1)
|
|
1419
|
+
return this.isImmutable(r) ? r.has(s) : this.isPiniaStore(r) && r.$state && s in r.$state || s in r;
|
|
1420
|
+
r = this.getProperty(r, s);
|
|
1429
1421
|
}
|
|
1430
1422
|
return !1;
|
|
1431
1423
|
} catch {
|
|
@@ -1454,9 +1446,9 @@ class ve {
|
|
|
1454
1446
|
* Trigger an XState transition with optional context data
|
|
1455
1447
|
*/
|
|
1456
1448
|
async triggerTransition(e, t) {
|
|
1457
|
-
const
|
|
1449
|
+
const r = G(), n = this.parentPath.split(".");
|
|
1458
1450
|
let s = this.doctype, i;
|
|
1459
|
-
this.doctype === "StonecropStore" &&
|
|
1451
|
+
this.doctype === "StonecropStore" && n.length >= 1 && (s = n[0]), n.length >= 2 && (i = n[1]);
|
|
1460
1452
|
const a = {
|
|
1461
1453
|
path: this.parentPath,
|
|
1462
1454
|
fieldname: "",
|
|
@@ -1472,7 +1464,7 @@ class ve {
|
|
|
1472
1464
|
currentState: t?.currentState,
|
|
1473
1465
|
targetState: t?.targetState,
|
|
1474
1466
|
fsmContext: t?.fsmContext
|
|
1475
|
-
}, c =
|
|
1467
|
+
}, c = Ae();
|
|
1476
1468
|
return c && typeof c.addOperation == "function" && c.addOperation(
|
|
1477
1469
|
{
|
|
1478
1470
|
type: "transition",
|
|
@@ -1492,7 +1484,7 @@ class ve {
|
|
|
1492
1484
|
}
|
|
1493
1485
|
},
|
|
1494
1486
|
"user"
|
|
1495
|
-
), await
|
|
1487
|
+
), await r.executeTransitionActions(a);
|
|
1496
1488
|
}
|
|
1497
1489
|
// Private helper methods
|
|
1498
1490
|
resolvePath(e) {
|
|
@@ -1502,53 +1494,53 @@ class ve {
|
|
|
1502
1494
|
if (e === "")
|
|
1503
1495
|
return this.target;
|
|
1504
1496
|
const t = this.parsePath(e);
|
|
1505
|
-
let
|
|
1506
|
-
for (const
|
|
1507
|
-
if (
|
|
1497
|
+
let r = this.target;
|
|
1498
|
+
for (const n of t) {
|
|
1499
|
+
if (r == null)
|
|
1508
1500
|
return;
|
|
1509
|
-
|
|
1501
|
+
r = this.getProperty(r, n);
|
|
1510
1502
|
}
|
|
1511
|
-
return
|
|
1503
|
+
return r;
|
|
1512
1504
|
}
|
|
1513
1505
|
updateValue(e, t) {
|
|
1514
1506
|
if (e === "")
|
|
1515
1507
|
throw new Error("Cannot set value on empty path");
|
|
1516
|
-
const
|
|
1508
|
+
const r = this.parsePath(e), n = r.pop();
|
|
1517
1509
|
let s = this.target;
|
|
1518
|
-
for (const i of
|
|
1510
|
+
for (const i of r)
|
|
1519
1511
|
if (s = this.getProperty(s, i), s == null)
|
|
1520
1512
|
throw new Error(`Cannot set property on null/undefined path: ${e}`);
|
|
1521
|
-
this.setProperty(s,
|
|
1513
|
+
this.setProperty(s, n, t);
|
|
1522
1514
|
}
|
|
1523
1515
|
getProperty(e, t) {
|
|
1524
1516
|
return this.isImmutable(e) ? e.get(t) : this.isVueReactive(e) ? e[t] : this.isPiniaStore(e) ? e.$state?.[t] ?? e[t] : e[t];
|
|
1525
1517
|
}
|
|
1526
|
-
setProperty(e, t,
|
|
1518
|
+
setProperty(e, t, r) {
|
|
1527
1519
|
if (this.isImmutable(e))
|
|
1528
1520
|
throw new Error("Cannot directly mutate immutable objects. Use immutable update methods instead.");
|
|
1529
1521
|
if (this.isPiniaStore(e)) {
|
|
1530
|
-
e.$patch ? e.$patch({ [t]:
|
|
1522
|
+
e.$patch ? e.$patch({ [t]: r }) : e[t] = r;
|
|
1531
1523
|
return;
|
|
1532
1524
|
}
|
|
1533
|
-
e[t] =
|
|
1525
|
+
e[t] = r;
|
|
1534
1526
|
}
|
|
1535
|
-
async triggerFieldActions(e, t,
|
|
1527
|
+
async triggerFieldActions(e, t, r) {
|
|
1536
1528
|
try {
|
|
1537
1529
|
if (!e || typeof e != "string")
|
|
1538
1530
|
return;
|
|
1539
|
-
const
|
|
1540
|
-
if (
|
|
1531
|
+
const n = e.split(".");
|
|
1532
|
+
if (n.length < 3)
|
|
1541
1533
|
return;
|
|
1542
|
-
const s = G(), i =
|
|
1534
|
+
const s = G(), i = n.slice(2).join(".") || n[n.length - 1];
|
|
1543
1535
|
let a = this.doctype;
|
|
1544
|
-
this.doctype === "StonecropStore" &&
|
|
1536
|
+
this.doctype === "StonecropStore" && n.length >= 1 && (a = n[0]);
|
|
1545
1537
|
let c;
|
|
1546
|
-
|
|
1547
|
-
const
|
|
1538
|
+
n.length >= 2 && (c = n[1]);
|
|
1539
|
+
const h = {
|
|
1548
1540
|
path: e,
|
|
1549
1541
|
fieldname: i,
|
|
1550
1542
|
beforeValue: t,
|
|
1551
|
-
afterValue:
|
|
1543
|
+
afterValue: r,
|
|
1552
1544
|
operation: "set",
|
|
1553
1545
|
doctype: a,
|
|
1554
1546
|
recordId: c,
|
|
@@ -1556,9 +1548,9 @@ class ve {
|
|
|
1556
1548
|
store: this.rootNode || void 0
|
|
1557
1549
|
// Pass the root store for snapshot/rollback capabilities
|
|
1558
1550
|
};
|
|
1559
|
-
await s.executeFieldTriggers(
|
|
1560
|
-
} catch (
|
|
1561
|
-
|
|
1551
|
+
await s.executeFieldTriggers(h);
|
|
1552
|
+
} catch (n) {
|
|
1553
|
+
n instanceof Error && console.warn("Field trigger error:", n.message);
|
|
1562
1554
|
}
|
|
1563
1555
|
}
|
|
1564
1556
|
isVueReactive(e) {
|
|
@@ -1570,19 +1562,19 @@ class ve {
|
|
|
1570
1562
|
isImmutable(e) {
|
|
1571
1563
|
if (!e || typeof e != "object")
|
|
1572
1564
|
return !1;
|
|
1573
|
-
const t = "get" in e && typeof e.get == "function",
|
|
1565
|
+
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", s = "__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;
|
|
1574
1566
|
let i;
|
|
1575
1567
|
try {
|
|
1576
1568
|
const c = e;
|
|
1577
1569
|
if ("constructor" in c && c.constructor && typeof c.constructor == "object" && "name" in c.constructor) {
|
|
1578
|
-
const
|
|
1579
|
-
i = typeof
|
|
1570
|
+
const h = c.constructor.name;
|
|
1571
|
+
i = typeof h == "string" ? h : void 0;
|
|
1580
1572
|
}
|
|
1581
1573
|
} catch {
|
|
1582
1574
|
i = void 0;
|
|
1583
1575
|
}
|
|
1584
|
-
const a = i && (i.includes("Map") || i.includes("List") || i.includes("Set") || i.includes("Stack") || i.includes("Seq")) && (t ||
|
|
1585
|
-
return !!(t &&
|
|
1576
|
+
const a = i && (i.includes("Map") || i.includes("List") || i.includes("Set") || i.includes("Stack") || i.includes("Seq")) && (t || r);
|
|
1577
|
+
return !!(t && r && n && s || t && r && a);
|
|
1586
1578
|
}
|
|
1587
1579
|
isPrimitive(e) {
|
|
1588
1580
|
return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
|
|
@@ -1591,8 +1583,8 @@ class ve {
|
|
|
1591
1583
|
return e ? e.split(".").filter((t) => t.length > 0) : [];
|
|
1592
1584
|
}
|
|
1593
1585
|
}
|
|
1594
|
-
function
|
|
1595
|
-
return new ve(
|
|
1586
|
+
function _t(o, e, t) {
|
|
1587
|
+
return new ve(o, e, "", null, t);
|
|
1596
1588
|
}
|
|
1597
1589
|
class He {
|
|
1598
1590
|
hstStore;
|
|
@@ -1613,7 +1605,7 @@ class He {
|
|
|
1613
1605
|
* @internal
|
|
1614
1606
|
*/
|
|
1615
1607
|
getOperationLogStore() {
|
|
1616
|
-
return this._operationLogStore || (this._operationLogStore =
|
|
1608
|
+
return this._operationLogStore || (this._operationLogStore = le(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
|
|
1617
1609
|
}
|
|
1618
1610
|
/**
|
|
1619
1611
|
* Initialize the HST store structure
|
|
@@ -1622,7 +1614,7 @@ class He {
|
|
|
1622
1614
|
const e = {};
|
|
1623
1615
|
Object.keys(this.registry.registry).forEach((t) => {
|
|
1624
1616
|
e[t] = {};
|
|
1625
|
-
}), this.hstStore =
|
|
1617
|
+
}), this.hstStore = _t(e, "StonecropStore");
|
|
1626
1618
|
}
|
|
1627
1619
|
/**
|
|
1628
1620
|
* Setup automatic sync with Registry when doctypes are added
|
|
@@ -1648,9 +1640,9 @@ class He {
|
|
|
1648
1640
|
* @param recordId - The record ID
|
|
1649
1641
|
* @param recordData - The record data
|
|
1650
1642
|
*/
|
|
1651
|
-
addRecord(e, t,
|
|
1652
|
-
const
|
|
1653
|
-
this.ensureDoctypeExists(
|
|
1643
|
+
addRecord(e, t, r) {
|
|
1644
|
+
const n = typeof e == "string" ? e : e.slug;
|
|
1645
|
+
this.ensureDoctypeExists(n), this.hstStore.set(`${n}.${t}`, r);
|
|
1654
1646
|
}
|
|
1655
1647
|
/**
|
|
1656
1648
|
* Get a specific record
|
|
@@ -1659,9 +1651,9 @@ class He {
|
|
|
1659
1651
|
* @returns HST node for the record or undefined
|
|
1660
1652
|
*/
|
|
1661
1653
|
getRecordById(e, t) {
|
|
1662
|
-
const
|
|
1663
|
-
if (this.ensureDoctypeExists(
|
|
1664
|
-
return this.hstStore.getNode(`${
|
|
1654
|
+
const r = typeof e == "string" ? e : e.slug;
|
|
1655
|
+
if (this.ensureDoctypeExists(r), !(!this.hstStore.has(`${r}.${t}`) || this.hstStore.get(`${r}.${t}`) === void 0))
|
|
1656
|
+
return this.hstStore.getNode(`${r}.${t}`);
|
|
1665
1657
|
}
|
|
1666
1658
|
/**
|
|
1667
1659
|
* Remove a record from the store
|
|
@@ -1669,8 +1661,8 @@ class He {
|
|
|
1669
1661
|
* @param recordId - The record ID
|
|
1670
1662
|
*/
|
|
1671
1663
|
removeRecord(e, t) {
|
|
1672
|
-
const
|
|
1673
|
-
this.ensureDoctypeExists(
|
|
1664
|
+
const r = typeof e == "string" ? e : e.slug;
|
|
1665
|
+
this.ensureDoctypeExists(r), this.hstStore.has(`${r}.${t}`) && this.hstStore.set(`${r}.${t}`, void 0);
|
|
1674
1666
|
}
|
|
1675
1667
|
/**
|
|
1676
1668
|
* Get all record IDs for a doctype
|
|
@@ -1680,8 +1672,8 @@ class He {
|
|
|
1680
1672
|
getRecordIds(e) {
|
|
1681
1673
|
const t = typeof e == "string" ? e : e.slug;
|
|
1682
1674
|
this.ensureDoctypeExists(t);
|
|
1683
|
-
const
|
|
1684
|
-
return !
|
|
1675
|
+
const r = this.hstStore.get(t);
|
|
1676
|
+
return !r || typeof r != "object" ? [] : Object.keys(r).filter((n) => r[n] !== void 0);
|
|
1685
1677
|
}
|
|
1686
1678
|
/**
|
|
1687
1679
|
* Clear all records for a doctype
|
|
@@ -1689,8 +1681,8 @@ class He {
|
|
|
1689
1681
|
*/
|
|
1690
1682
|
clearRecords(e) {
|
|
1691
1683
|
const t = typeof e == "string" ? e : e.slug;
|
|
1692
|
-
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((
|
|
1693
|
-
this.hstStore.set(`${t}.${
|
|
1684
|
+
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((n) => {
|
|
1685
|
+
this.hstStore.set(`${t}.${n}`, void 0);
|
|
1694
1686
|
});
|
|
1695
1687
|
}
|
|
1696
1688
|
/**
|
|
@@ -1707,20 +1699,20 @@ class He {
|
|
|
1707
1699
|
* @param action - The action to run
|
|
1708
1700
|
* @param args - Action arguments (typically record IDs)
|
|
1709
1701
|
*/
|
|
1710
|
-
runAction(e, t,
|
|
1711
|
-
const s = this.registry.registry[e.slug]?.actions?.get(t), i = Array.isArray(
|
|
1712
|
-
let c = "success",
|
|
1702
|
+
runAction(e, t, r) {
|
|
1703
|
+
const s = this.registry.registry[e.slug]?.actions?.get(t), i = Array.isArray(r) ? r.filter((b) => typeof b == "string") : void 0, a = this.getOperationLogStore();
|
|
1704
|
+
let c = "success", h;
|
|
1713
1705
|
try {
|
|
1714
|
-
s && s.length > 0 && s.forEach((
|
|
1706
|
+
s && s.length > 0 && s.forEach((b) => {
|
|
1715
1707
|
try {
|
|
1716
|
-
new Function("args",
|
|
1708
|
+
new Function("args", b)(r);
|
|
1717
1709
|
} catch (w) {
|
|
1718
|
-
throw c = "failure",
|
|
1710
|
+
throw c = "failure", h = w instanceof Error ? w.message : "Unknown error", w;
|
|
1719
1711
|
}
|
|
1720
1712
|
});
|
|
1721
1713
|
} catch {
|
|
1722
1714
|
} finally {
|
|
1723
|
-
a.logAction(e.doctype, t, i, c,
|
|
1715
|
+
a.logAction(e.doctype, t, i, c, h);
|
|
1724
1716
|
}
|
|
1725
1717
|
}
|
|
1726
1718
|
/**
|
|
@@ -1728,8 +1720,8 @@ class He {
|
|
|
1728
1720
|
* @param doctype - The doctype
|
|
1729
1721
|
*/
|
|
1730
1722
|
async getRecords(e) {
|
|
1731
|
-
(await (await fetch(`/${e.slug}`)).json()).forEach((
|
|
1732
|
-
|
|
1723
|
+
(await (await fetch(`/${e.slug}`)).json()).forEach((n) => {
|
|
1724
|
+
n.id && this.addRecord(e, n.id, n);
|
|
1733
1725
|
});
|
|
1734
1726
|
}
|
|
1735
1727
|
/**
|
|
@@ -1738,8 +1730,8 @@ class He {
|
|
|
1738
1730
|
* @param recordId - The record ID
|
|
1739
1731
|
*/
|
|
1740
1732
|
async getRecord(e, t) {
|
|
1741
|
-
const
|
|
1742
|
-
this.addRecord(e, t,
|
|
1733
|
+
const n = await (await fetch(`/${e.slug}/${t}`)).json();
|
|
1734
|
+
this.addRecord(e, t, n);
|
|
1743
1735
|
}
|
|
1744
1736
|
/**
|
|
1745
1737
|
* Ensure doctype section exists in HST store
|
|
@@ -1766,171 +1758,171 @@ class He {
|
|
|
1766
1758
|
return this.hstStore;
|
|
1767
1759
|
}
|
|
1768
1760
|
}
|
|
1769
|
-
function
|
|
1770
|
-
|
|
1771
|
-
const e =
|
|
1772
|
-
() =>
|
|
1761
|
+
function Vt(o) {
|
|
1762
|
+
o || (o = {});
|
|
1763
|
+
const e = o.registry || te("$registry"), t = te("$stonecrop"), r = L(), n = L(), s = L({}), i = L(), a = L(), c = L([]), h = L(-1), b = B(() => r.value?.getOperationLogStore().canUndo ?? !1), w = B(() => r.value?.getOperationLogStore().canRedo ?? !1), P = B(() => r.value?.getOperationLogStore().undoCount ?? 0), D = B(() => r.value?.getOperationLogStore().redoCount ?? 0), C = B(
|
|
1764
|
+
() => r.value?.getOperationLogStore().undoRedoState ?? {
|
|
1773
1765
|
canUndo: !1,
|
|
1774
1766
|
canRedo: !1,
|
|
1775
1767
|
undoCount: 0,
|
|
1776
1768
|
redoCount: 0,
|
|
1777
1769
|
currentIndex: -1
|
|
1778
1770
|
}
|
|
1779
|
-
),
|
|
1780
|
-
|
|
1781
|
-
}, R = (y) =>
|
|
1782
|
-
|
|
1783
|
-
},
|
|
1784
|
-
|
|
1785
|
-
}, E = (y,
|
|
1771
|
+
), F = (y) => r.value?.getOperationLogStore().undo(y) ?? !1, _ = (y) => r.value?.getOperationLogStore().redo(y) ?? !1, $ = () => {
|
|
1772
|
+
r.value?.getOperationLogStore().startBatch();
|
|
1773
|
+
}, R = (y) => r.value?.getOperationLogStore().commitBatch(y) ?? null, S = () => {
|
|
1774
|
+
r.value?.getOperationLogStore().cancelBatch();
|
|
1775
|
+
}, T = () => {
|
|
1776
|
+
r.value?.getOperationLogStore().clear();
|
|
1777
|
+
}, E = (y, f) => r.value?.getOperationLogStore().getOperationsFor(y, f) ?? [], N = () => r.value?.getOperationLogStore().getSnapshot() ?? {
|
|
1786
1778
|
operations: [],
|
|
1787
1779
|
currentIndex: -1,
|
|
1788
1780
|
totalOperations: 0,
|
|
1789
1781
|
reversibleOperations: 0,
|
|
1790
1782
|
irreversibleOperations: 0
|
|
1791
|
-
}, g = (y,
|
|
1792
|
-
|
|
1793
|
-
}, x = (y,
|
|
1794
|
-
|
|
1783
|
+
}, g = (y, f) => {
|
|
1784
|
+
r.value?.getOperationLogStore().markIrreversible(y, f);
|
|
1785
|
+
}, x = (y, f, m, I = "success", A) => r.value?.getOperationLogStore().logAction(y, f, m, I, A) ?? "", M = (y) => {
|
|
1786
|
+
r.value?.getOperationLogStore().configure(y);
|
|
1795
1787
|
};
|
|
1796
|
-
|
|
1788
|
+
Me(async () => {
|
|
1797
1789
|
if (e) {
|
|
1798
|
-
|
|
1790
|
+
r.value = t || new He(e);
|
|
1799
1791
|
try {
|
|
1800
|
-
const y =
|
|
1801
|
-
c.value =
|
|
1802
|
-
() =>
|
|
1792
|
+
const y = r.value.getOperationLogStore(), f = Ue(y);
|
|
1793
|
+
c.value = f.operations.value, h.value = f.currentIndex.value, H(
|
|
1794
|
+
() => f.operations.value,
|
|
1803
1795
|
(m) => {
|
|
1804
1796
|
c.value = m;
|
|
1805
1797
|
}
|
|
1806
1798
|
), H(
|
|
1807
|
-
() =>
|
|
1799
|
+
() => f.currentIndex.value,
|
|
1808
1800
|
(m) => {
|
|
1809
|
-
|
|
1801
|
+
h.value = m;
|
|
1810
1802
|
}
|
|
1811
1803
|
);
|
|
1812
1804
|
} catch {
|
|
1813
1805
|
}
|
|
1814
|
-
if (!
|
|
1806
|
+
if (!o.doctype && e.router) {
|
|
1815
1807
|
const y = e.router.currentRoute.value;
|
|
1816
1808
|
if (!y.path) return;
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
1819
|
-
const
|
|
1809
|
+
const f = y.path.split("/").filter((I) => I.length > 0), m = f[1]?.toLowerCase();
|
|
1810
|
+
if (f.length > 0) {
|
|
1811
|
+
const I = {
|
|
1820
1812
|
path: y.path,
|
|
1821
|
-
segments:
|
|
1822
|
-
}, A = await e.getMeta?.(
|
|
1813
|
+
segments: f
|
|
1814
|
+
}, A = await e.getMeta?.(I);
|
|
1823
1815
|
if (A) {
|
|
1824
|
-
if (e.addDoctype(A),
|
|
1825
|
-
const j =
|
|
1816
|
+
if (e.addDoctype(A), r.value.setup(A), i.value = A, a.value = m, n.value = r.value.getStore(), m && m !== "new") {
|
|
1817
|
+
const j = r.value.getRecordById(A, m);
|
|
1826
1818
|
if (j)
|
|
1827
1819
|
s.value = j.get("") || {};
|
|
1828
1820
|
else
|
|
1829
1821
|
try {
|
|
1830
|
-
await
|
|
1831
|
-
const V =
|
|
1822
|
+
await r.value.getRecord(A, m);
|
|
1823
|
+
const V = r.value.getRecordById(A, m);
|
|
1832
1824
|
V && (s.value = V.get("") || {});
|
|
1833
1825
|
} catch {
|
|
1834
|
-
s.value =
|
|
1826
|
+
s.value = he(A);
|
|
1835
1827
|
}
|
|
1836
1828
|
} else
|
|
1837
|
-
s.value =
|
|
1838
|
-
|
|
1829
|
+
s.value = he(A);
|
|
1830
|
+
n.value && Ve(A, m || "new", s, n.value), r.value.runAction(A, "load", m ? [m] : void 0);
|
|
1839
1831
|
}
|
|
1840
1832
|
}
|
|
1841
1833
|
}
|
|
1842
|
-
if (
|
|
1843
|
-
|
|
1844
|
-
const y =
|
|
1845
|
-
if (
|
|
1846
|
-
const m =
|
|
1834
|
+
if (o.doctype) {
|
|
1835
|
+
n.value = r.value.getStore();
|
|
1836
|
+
const y = o.doctype, f = o.recordId;
|
|
1837
|
+
if (f && f !== "new") {
|
|
1838
|
+
const m = r.value.getRecordById(y, f);
|
|
1847
1839
|
if (m)
|
|
1848
1840
|
s.value = m.get("") || {};
|
|
1849
1841
|
else
|
|
1850
1842
|
try {
|
|
1851
|
-
await
|
|
1852
|
-
const
|
|
1853
|
-
|
|
1843
|
+
await r.value.getRecord(y, f);
|
|
1844
|
+
const I = r.value.getRecordById(y, f);
|
|
1845
|
+
I && (s.value = I.get("") || {});
|
|
1854
1846
|
} catch {
|
|
1855
|
-
s.value =
|
|
1847
|
+
s.value = he(y);
|
|
1856
1848
|
}
|
|
1857
1849
|
} else
|
|
1858
|
-
s.value =
|
|
1859
|
-
|
|
1850
|
+
s.value = he(y);
|
|
1851
|
+
n.value && Ve(y, f || "new", s, n.value);
|
|
1860
1852
|
}
|
|
1861
1853
|
}
|
|
1862
1854
|
});
|
|
1863
|
-
const u = (y,
|
|
1864
|
-
const m =
|
|
1855
|
+
const u = (y, f) => {
|
|
1856
|
+
const m = o.doctype || i.value;
|
|
1865
1857
|
if (!m) return "";
|
|
1866
|
-
const
|
|
1867
|
-
return `${m.slug}.${
|
|
1868
|
-
},
|
|
1869
|
-
const
|
|
1870
|
-
if (!(!
|
|
1858
|
+
const I = f || o.recordId || a.value || "new";
|
|
1859
|
+
return `${m.slug}.${I}.${y}`;
|
|
1860
|
+
}, l = (y) => {
|
|
1861
|
+
const f = o.doctype || i.value;
|
|
1862
|
+
if (!(!n.value || !r.value || !f))
|
|
1871
1863
|
try {
|
|
1872
1864
|
const m = y.path.split(".");
|
|
1873
1865
|
if (m.length >= 2) {
|
|
1874
1866
|
const j = m[0], V = m[1];
|
|
1875
|
-
if (
|
|
1876
|
-
const
|
|
1877
|
-
let v =
|
|
1878
|
-
for (let
|
|
1879
|
-
if (v += `.${
|
|
1880
|
-
const z =
|
|
1881
|
-
|
|
1867
|
+
if (n.value.has(`${j}.${V}`) || r.value.addRecord(f, V, { ...s.value }), m.length > 3) {
|
|
1868
|
+
const d = `${j}.${V}`, p = m.slice(2);
|
|
1869
|
+
let v = d;
|
|
1870
|
+
for (let k = 0; k < p.length - 1; k++)
|
|
1871
|
+
if (v += `.${p[k]}`, !n.value.has(v)) {
|
|
1872
|
+
const z = p[k + 1], W = !isNaN(Number(z));
|
|
1873
|
+
n.value.set(v, W ? [] : {});
|
|
1882
1874
|
}
|
|
1883
1875
|
}
|
|
1884
1876
|
}
|
|
1885
|
-
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1877
|
+
n.value.set(y.path, y.value);
|
|
1878
|
+
const I = y.fieldname.split("."), A = { ...s.value };
|
|
1879
|
+
I.length === 1 ? A[I[0]] = y.value : Pt(A, I, y.value), s.value = A;
|
|
1888
1880
|
} catch {
|
|
1889
1881
|
}
|
|
1890
1882
|
};
|
|
1891
|
-
(
|
|
1883
|
+
(o.doctype || e?.router) && (Ne("hstPathProvider", u), Ne("hstChangeHandler", l));
|
|
1892
1884
|
const O = {
|
|
1893
1885
|
operations: c,
|
|
1894
|
-
currentIndex:
|
|
1895
|
-
undoRedoState:
|
|
1896
|
-
canUndo:
|
|
1886
|
+
currentIndex: h,
|
|
1887
|
+
undoRedoState: C,
|
|
1888
|
+
canUndo: b,
|
|
1897
1889
|
canRedo: w,
|
|
1898
1890
|
undoCount: P,
|
|
1899
|
-
redoCount:
|
|
1900
|
-
undo:
|
|
1891
|
+
redoCount: D,
|
|
1892
|
+
undo: F,
|
|
1901
1893
|
redo: _,
|
|
1902
|
-
startBatch:
|
|
1894
|
+
startBatch: $,
|
|
1903
1895
|
commitBatch: R,
|
|
1904
|
-
cancelBatch:
|
|
1905
|
-
clear:
|
|
1896
|
+
cancelBatch: S,
|
|
1897
|
+
clear: T,
|
|
1906
1898
|
getOperationsFor: E,
|
|
1907
|
-
getSnapshot:
|
|
1899
|
+
getSnapshot: N,
|
|
1908
1900
|
markIrreversible: g,
|
|
1909
1901
|
logAction: x,
|
|
1910
|
-
configure:
|
|
1902
|
+
configure: M
|
|
1911
1903
|
};
|
|
1912
|
-
return
|
|
1913
|
-
stonecrop:
|
|
1904
|
+
return o.doctype ? {
|
|
1905
|
+
stonecrop: r,
|
|
1914
1906
|
operationLog: O,
|
|
1915
1907
|
provideHSTPath: u,
|
|
1916
|
-
handleHSTChange:
|
|
1917
|
-
hstStore:
|
|
1908
|
+
handleHSTChange: l,
|
|
1909
|
+
hstStore: n,
|
|
1918
1910
|
formData: s
|
|
1919
|
-
} : !
|
|
1920
|
-
stonecrop:
|
|
1911
|
+
} : !o.doctype && e?.router ? {
|
|
1912
|
+
stonecrop: r,
|
|
1921
1913
|
operationLog: O,
|
|
1922
1914
|
provideHSTPath: u,
|
|
1923
|
-
handleHSTChange:
|
|
1924
|
-
hstStore:
|
|
1915
|
+
handleHSTChange: l,
|
|
1916
|
+
hstStore: n,
|
|
1925
1917
|
formData: s
|
|
1926
1918
|
} : {
|
|
1927
|
-
stonecrop:
|
|
1919
|
+
stonecrop: r,
|
|
1928
1920
|
operationLog: O
|
|
1929
1921
|
};
|
|
1930
1922
|
}
|
|
1931
|
-
function
|
|
1923
|
+
function he(o) {
|
|
1932
1924
|
const e = {};
|
|
1933
|
-
return
|
|
1925
|
+
return o.schema && o.schema.forEach((t) => {
|
|
1934
1926
|
switch ("fieldtype" in t ? t.fieldtype : "Data") {
|
|
1935
1927
|
case "Data":
|
|
1936
1928
|
case "Text":
|
|
@@ -1954,15 +1946,15 @@ function pe(r) {
|
|
|
1954
1946
|
}
|
|
1955
1947
|
}), e;
|
|
1956
1948
|
}
|
|
1957
|
-
function
|
|
1949
|
+
function Ve(o, e, t, r) {
|
|
1958
1950
|
H(
|
|
1959
1951
|
t,
|
|
1960
|
-
(
|
|
1961
|
-
const s = `${
|
|
1962
|
-
Object.keys(
|
|
1952
|
+
(n) => {
|
|
1953
|
+
const s = `${o.slug}.${e}`;
|
|
1954
|
+
Object.keys(n).forEach((i) => {
|
|
1963
1955
|
const a = `${s}.${i}`;
|
|
1964
1956
|
try {
|
|
1965
|
-
|
|
1957
|
+
r.set(a, n[i]);
|
|
1966
1958
|
} catch {
|
|
1967
1959
|
}
|
|
1968
1960
|
});
|
|
@@ -1970,20 +1962,20 @@ function Ce(r, e, t, n) {
|
|
|
1970
1962
|
{ deep: !0 }
|
|
1971
1963
|
);
|
|
1972
1964
|
}
|
|
1973
|
-
function
|
|
1974
|
-
let
|
|
1965
|
+
function Pt(o, e, t) {
|
|
1966
|
+
let r = o;
|
|
1975
1967
|
for (let s = 0; s < e.length - 1; s++) {
|
|
1976
1968
|
const i = e[s];
|
|
1977
|
-
(!(i in
|
|
1969
|
+
(!(i in r) || typeof r[i] != "object") && (r[i] = isNaN(Number(e[s + 1])) ? {} : []), r = r[i];
|
|
1978
1970
|
}
|
|
1979
|
-
const
|
|
1980
|
-
n
|
|
1971
|
+
const n = e[e.length - 1];
|
|
1972
|
+
r[n] = t;
|
|
1981
1973
|
}
|
|
1982
|
-
function Je(
|
|
1983
|
-
const t =
|
|
1984
|
-
|
|
1985
|
-
const { operations:
|
|
1986
|
-
function
|
|
1974
|
+
function Je(o) {
|
|
1975
|
+
const t = te("$operationLogStore", void 0) || le();
|
|
1976
|
+
o && t.configure(o);
|
|
1977
|
+
const { operations: r, currentIndex: n, undoRedoState: s, canUndo: i, canRedo: a, undoCount: c, redoCount: h } = Ue(t);
|
|
1978
|
+
function b(E) {
|
|
1987
1979
|
return t.undo(E);
|
|
1988
1980
|
}
|
|
1989
1981
|
function w(E) {
|
|
@@ -1992,75 +1984,75 @@ function Je(r) {
|
|
|
1992
1984
|
function P() {
|
|
1993
1985
|
t.startBatch();
|
|
1994
1986
|
}
|
|
1995
|
-
function
|
|
1987
|
+
function D(E) {
|
|
1996
1988
|
return t.commitBatch(E);
|
|
1997
1989
|
}
|
|
1998
|
-
function
|
|
1990
|
+
function C() {
|
|
1999
1991
|
t.cancelBatch();
|
|
2000
1992
|
}
|
|
2001
|
-
function
|
|
1993
|
+
function F() {
|
|
2002
1994
|
t.clear();
|
|
2003
1995
|
}
|
|
2004
|
-
function _(E,
|
|
2005
|
-
return t.getOperationsFor(E,
|
|
1996
|
+
function _(E, N) {
|
|
1997
|
+
return t.getOperationsFor(E, N);
|
|
2006
1998
|
}
|
|
2007
|
-
function
|
|
1999
|
+
function $() {
|
|
2008
2000
|
return t.getSnapshot();
|
|
2009
2001
|
}
|
|
2010
|
-
function R(E,
|
|
2011
|
-
t.markIrreversible(E,
|
|
2002
|
+
function R(E, N) {
|
|
2003
|
+
t.markIrreversible(E, N);
|
|
2012
2004
|
}
|
|
2013
|
-
function
|
|
2014
|
-
return t.logAction(E,
|
|
2005
|
+
function S(E, N, g, x = "success", M) {
|
|
2006
|
+
return t.logAction(E, N, g, x, M);
|
|
2015
2007
|
}
|
|
2016
|
-
function
|
|
2008
|
+
function T(E) {
|
|
2017
2009
|
t.configure(E);
|
|
2018
2010
|
}
|
|
2019
2011
|
return {
|
|
2020
2012
|
// State
|
|
2021
|
-
operations:
|
|
2022
|
-
currentIndex:
|
|
2013
|
+
operations: r,
|
|
2014
|
+
currentIndex: n,
|
|
2023
2015
|
undoRedoState: s,
|
|
2024
2016
|
canUndo: i,
|
|
2025
2017
|
canRedo: a,
|
|
2026
2018
|
undoCount: c,
|
|
2027
|
-
redoCount:
|
|
2019
|
+
redoCount: h,
|
|
2028
2020
|
// Methods
|
|
2029
|
-
undo:
|
|
2021
|
+
undo: b,
|
|
2030
2022
|
redo: w,
|
|
2031
2023
|
startBatch: P,
|
|
2032
|
-
commitBatch:
|
|
2033
|
-
cancelBatch:
|
|
2034
|
-
clear:
|
|
2024
|
+
commitBatch: D,
|
|
2025
|
+
cancelBatch: C,
|
|
2026
|
+
clear: F,
|
|
2035
2027
|
getOperationsFor: _,
|
|
2036
|
-
getSnapshot:
|
|
2028
|
+
getSnapshot: $,
|
|
2037
2029
|
markIrreversible: R,
|
|
2038
|
-
logAction:
|
|
2039
|
-
configure:
|
|
2030
|
+
logAction: S,
|
|
2031
|
+
configure: T
|
|
2040
2032
|
};
|
|
2041
2033
|
}
|
|
2042
|
-
function kt(
|
|
2034
|
+
function kt(o, e = !0) {
|
|
2043
2035
|
if (!e) return;
|
|
2044
|
-
const { undo: t, redo:
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
}),
|
|
2048
|
-
|
|
2049
|
-
}),
|
|
2050
|
-
s.value &&
|
|
2051
|
-
}),
|
|
2052
|
-
s.value &&
|
|
2053
|
-
}),
|
|
2054
|
-
s.value &&
|
|
2036
|
+
const { undo: t, redo: r, canUndo: n, canRedo: s } = Je(), i = Ot();
|
|
2037
|
+
oe(i["Ctrl+Z"], () => {
|
|
2038
|
+
n.value && t(o);
|
|
2039
|
+
}), oe(i["Meta+Z"], () => {
|
|
2040
|
+
n.value && t(o);
|
|
2041
|
+
}), oe(i["Ctrl+Shift+Z"], () => {
|
|
2042
|
+
s.value && r(o);
|
|
2043
|
+
}), oe(i["Meta+Shift+Z"], () => {
|
|
2044
|
+
s.value && r(o);
|
|
2045
|
+
}), oe(i["Ctrl+Y"], () => {
|
|
2046
|
+
s.value && r(o);
|
|
2055
2047
|
});
|
|
2056
2048
|
}
|
|
2057
|
-
async function
|
|
2058
|
-
const { startBatch: t, commitBatch:
|
|
2049
|
+
async function Ft(o, e) {
|
|
2050
|
+
const { startBatch: t, commitBatch: r, cancelBatch: n } = Je();
|
|
2059
2051
|
t();
|
|
2060
2052
|
try {
|
|
2061
|
-
return await
|
|
2053
|
+
return await o(), r(e);
|
|
2062
2054
|
} catch (s) {
|
|
2063
|
-
throw
|
|
2055
|
+
throw n(), s;
|
|
2064
2056
|
}
|
|
2065
2057
|
}
|
|
2066
2058
|
class Mt {
|
|
@@ -2102,8 +2094,8 @@ class Mt {
|
|
|
2102
2094
|
* @param actions - The doctype actions and field triggers
|
|
2103
2095
|
* @param component - Optional Vue component for rendering the doctype
|
|
2104
2096
|
*/
|
|
2105
|
-
constructor(e, t,
|
|
2106
|
-
this.doctype = e, this.schema = t, this.workflow =
|
|
2097
|
+
constructor(e, t, r, n, s) {
|
|
2098
|
+
this.doctype = e, this.schema = t, this.workflow = r, this.actions = n, this.component = s;
|
|
2107
2099
|
}
|
|
2108
2100
|
/**
|
|
2109
2101
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
@@ -2125,7 +2117,7 @@ class Mt {
|
|
|
2125
2117
|
return this.doctype.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
2126
2118
|
}
|
|
2127
2119
|
}
|
|
2128
|
-
class
|
|
2120
|
+
class ce {
|
|
2129
2121
|
/**
|
|
2130
2122
|
* The root Registry instance
|
|
2131
2123
|
*/
|
|
@@ -2152,9 +2144,9 @@ class ae {
|
|
|
2152
2144
|
* @param getMeta - Optional function to fetch doctype metadata from an API
|
|
2153
2145
|
*/
|
|
2154
2146
|
constructor(e, t) {
|
|
2155
|
-
if (
|
|
2156
|
-
return
|
|
2157
|
-
|
|
2147
|
+
if (ce._root)
|
|
2148
|
+
return ce._root;
|
|
2149
|
+
ce._root = this, this.name = "Registry", this.registry = {}, this.router = e, this.getMeta = t;
|
|
2158
2150
|
}
|
|
2159
2151
|
/**
|
|
2160
2152
|
* The getMeta function fetches doctype metadata from an API based on route context
|
|
@@ -2189,53 +2181,53 @@ class ae {
|
|
|
2189
2181
|
// }
|
|
2190
2182
|
// }
|
|
2191
2183
|
}
|
|
2192
|
-
async function
|
|
2193
|
-
await
|
|
2184
|
+
async function Nt(o, e, t) {
|
|
2185
|
+
await ue();
|
|
2194
2186
|
try {
|
|
2195
|
-
await t(
|
|
2187
|
+
await t(o, e);
|
|
2196
2188
|
} catch {
|
|
2197
2189
|
}
|
|
2198
2190
|
}
|
|
2199
|
-
const
|
|
2200
|
-
install: (
|
|
2201
|
-
const t =
|
|
2202
|
-
!t &&
|
|
2203
|
-
const s = new
|
|
2204
|
-
|
|
2191
|
+
const Lt = {
|
|
2192
|
+
install: (o, e) => {
|
|
2193
|
+
const t = o.config.globalProperties.$router, r = e?.router, n = t || r;
|
|
2194
|
+
!t && r && o.use(r);
|
|
2195
|
+
const s = new ce(n, e?.getMeta);
|
|
2196
|
+
o.provide("$registry", s), o.config.globalProperties.$registry = s;
|
|
2205
2197
|
const i = new He(s);
|
|
2206
|
-
|
|
2198
|
+
o.provide("$stonecrop", i), o.config.globalProperties.$stonecrop = i;
|
|
2207
2199
|
try {
|
|
2208
|
-
const a =
|
|
2200
|
+
const a = o.config.globalProperties.$pinia;
|
|
2209
2201
|
if (a) {
|
|
2210
|
-
const c =
|
|
2211
|
-
|
|
2202
|
+
const c = le(a);
|
|
2203
|
+
o.provide("$operationLogStore", c), o.config.globalProperties.$operationLogStore = c;
|
|
2212
2204
|
}
|
|
2213
2205
|
} catch (a) {
|
|
2214
2206
|
console.warn("Pinia not available - operation log features will be disabled:", a);
|
|
2215
2207
|
}
|
|
2216
2208
|
if (e?.components)
|
|
2217
2209
|
for (const [a, c] of Object.entries(e.components))
|
|
2218
|
-
|
|
2219
|
-
e?.autoInitializeRouter && e.onRouterInitialized &&
|
|
2210
|
+
o.component(a, c);
|
|
2211
|
+
e?.autoInitializeRouter && e.onRouterInitialized && Nt(s, i, e.onRouterInitialized);
|
|
2220
2212
|
}
|
|
2221
2213
|
};
|
|
2222
2214
|
export {
|
|
2223
2215
|
Mt as DoctypeMeta,
|
|
2224
|
-
|
|
2225
|
-
|
|
2216
|
+
ee as HST,
|
|
2217
|
+
ce as Registry,
|
|
2226
2218
|
He as Stonecrop,
|
|
2227
|
-
|
|
2228
|
-
|
|
2219
|
+
_t as createHST,
|
|
2220
|
+
Lt as default,
|
|
2229
2221
|
G as getGlobalTriggerEngine,
|
|
2230
|
-
|
|
2222
|
+
At as markOperationIrreversible,
|
|
2231
2223
|
Dt as registerGlobalAction,
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2224
|
+
$t as registerTransitionAction,
|
|
2225
|
+
Tt as setFieldRollback,
|
|
2226
|
+
Ct as triggerTransition,
|
|
2235
2227
|
Je as useOperationLog,
|
|
2236
|
-
|
|
2237
|
-
|
|
2228
|
+
le as useOperationLogStore,
|
|
2229
|
+
Vt as useStonecrop,
|
|
2238
2230
|
kt as useUndoRedoShortcuts,
|
|
2239
|
-
|
|
2231
|
+
Ft as withBatch
|
|
2240
2232
|
};
|
|
2241
2233
|
//# sourceMappingURL=stonecrop.js.map
|