@stonecrop/desktop 0.6.2 → 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/actions-Bg0Mh5s7.js +137 -0
- package/dist/actions-Bg0Mh5s7.js.map +1 -0
- package/dist/desktop.css +1 -1
- package/dist/desktop.js +1103 -1104
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.umd.cjs +26 -30
- package/dist/desktop.umd.cjs.map +1 -1
- package/dist/index-C3nXTrEd.js +1895 -0
- package/dist/index-C3nXTrEd.js.map +1 -0
- package/dist/operation-log-DB-dGNT9-C9cIr4-e.js +592 -0
- package/dist/operation-log-DB-dGNT9-C9cIr4-e.js.map +1 -0
- package/dist/src/tsdoc-metadata.json +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { hasInjectionContext as ye, inject as me, getCurrentInstance as ge, ref as D, reactive as be, markRaw as A, effectScope as Ee, isRef as H, isReactive as oe, toRef as z, toRaw as _e, nextTick as ae, computed as j, getCurrentScope as we, onScopeDispose as Oe, watch as le, toRefs as re } from "vue";
|
|
2
|
+
/*!
|
|
3
|
+
* pinia v3.0.3
|
|
4
|
+
* (c) 2025 Eduardo San Martin Morote
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
let M;
|
|
8
|
+
const Q = (e) => M = e, Ne = process.env.NODE_ENV !== "production" ? Symbol("pinia") : (
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
Symbol()
|
|
11
|
+
);
|
|
12
|
+
function x(e) {
|
|
13
|
+
return e && typeof e == "object" && Object.prototype.toString.call(e) === "[object Object]" && typeof e.toJSON != "function";
|
|
14
|
+
}
|
|
15
|
+
var K;
|
|
16
|
+
(function(e) {
|
|
17
|
+
e.direct = "direct", e.patchObject = "patch object", e.patchFunction = "patch function";
|
|
18
|
+
})(K || (K = {}));
|
|
19
|
+
const J = typeof window < "u";
|
|
20
|
+
function pe(e, n) {
|
|
21
|
+
for (const a in n) {
|
|
22
|
+
const r = n[a];
|
|
23
|
+
if (!(a in e))
|
|
24
|
+
continue;
|
|
25
|
+
const p = e[a];
|
|
26
|
+
x(p) && x(r) && !H(r) && !oe(r) ? e[a] = pe(p, r) : e[a] = r;
|
|
27
|
+
}
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
const ve = () => {
|
|
31
|
+
};
|
|
32
|
+
function se(e, n, a, r = ve) {
|
|
33
|
+
e.push(n);
|
|
34
|
+
const p = () => {
|
|
35
|
+
const d = e.indexOf(n);
|
|
36
|
+
d > -1 && (e.splice(d, 1), r());
|
|
37
|
+
};
|
|
38
|
+
return !a && we() && Oe(p), p;
|
|
39
|
+
}
|
|
40
|
+
function B(e, ...n) {
|
|
41
|
+
e.slice().forEach((a) => {
|
|
42
|
+
a(...n);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const Se = (e) => e(), ie = Symbol(), G = Symbol();
|
|
46
|
+
function te(e, n) {
|
|
47
|
+
e instanceof Map && n instanceof Map ? n.forEach((a, r) => e.set(r, a)) : e instanceof Set && n instanceof Set && n.forEach(e.add, e);
|
|
48
|
+
for (const a in n) {
|
|
49
|
+
if (!n.hasOwnProperty(a))
|
|
50
|
+
continue;
|
|
51
|
+
const r = n[a], p = e[a];
|
|
52
|
+
x(p) && x(r) && e.hasOwnProperty(a) && !H(r) && !oe(r) ? e[a] = te(p, r) : e[a] = r;
|
|
53
|
+
}
|
|
54
|
+
return e;
|
|
55
|
+
}
|
|
56
|
+
const De = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : (
|
|
57
|
+
/* istanbul ignore next */
|
|
58
|
+
Symbol()
|
|
59
|
+
);
|
|
60
|
+
function Ie(e) {
|
|
61
|
+
return !x(e) || !Object.prototype.hasOwnProperty.call(e, De);
|
|
62
|
+
}
|
|
63
|
+
const { assign: O } = Object;
|
|
64
|
+
function ce(e) {
|
|
65
|
+
return !!(H(e) && e.effect);
|
|
66
|
+
}
|
|
67
|
+
function ue(e, n, a, r) {
|
|
68
|
+
const { state: p, actions: d, getters: l } = n, m = a.state.value[e];
|
|
69
|
+
let N;
|
|
70
|
+
function h() {
|
|
71
|
+
!m && (process.env.NODE_ENV === "production" || !r) && (a.state.value[e] = p ? p() : {});
|
|
72
|
+
const f = process.env.NODE_ENV !== "production" && r ? (
|
|
73
|
+
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
74
|
+
re(D(p ? p() : {}).value)
|
|
75
|
+
) : re(a.state.value[e]);
|
|
76
|
+
return O(f, d, Object.keys(l || {}).reduce((g, E) => (process.env.NODE_ENV !== "production" && E in f && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${E}" in store "${e}".`), g[E] = A(j(() => {
|
|
77
|
+
Q(a);
|
|
78
|
+
const _ = a._s.get(e);
|
|
79
|
+
return l[E].call(_, _);
|
|
80
|
+
})), g), {}));
|
|
81
|
+
}
|
|
82
|
+
return N = ne(e, h, n, a, r, !0), N;
|
|
83
|
+
}
|
|
84
|
+
function ne(e, n, a = {}, r, p, d) {
|
|
85
|
+
let l;
|
|
86
|
+
const m = O({ actions: {} }, a);
|
|
87
|
+
if (process.env.NODE_ENV !== "production" && !r._e.active)
|
|
88
|
+
throw new Error("Pinia destroyed");
|
|
89
|
+
const N = { deep: !0 };
|
|
90
|
+
process.env.NODE_ENV !== "production" && (N.onTrigger = (s) => {
|
|
91
|
+
h ? _ = s : h == !1 && !u._hotUpdating && (Array.isArray(_) ? _.push(s) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
92
|
+
});
|
|
93
|
+
let h, f, g = [], E = [], _;
|
|
94
|
+
const I = r.state.value[e];
|
|
95
|
+
!d && !I && (process.env.NODE_ENV === "production" || !p) && (r.state.value[e] = {});
|
|
96
|
+
const U = D({});
|
|
97
|
+
let L;
|
|
98
|
+
function q(s) {
|
|
99
|
+
let o;
|
|
100
|
+
h = f = !1, process.env.NODE_ENV !== "production" && (_ = []), typeof s == "function" ? (s(r.state.value[e]), o = {
|
|
101
|
+
type: K.patchFunction,
|
|
102
|
+
storeId: e,
|
|
103
|
+
events: _
|
|
104
|
+
}) : (te(r.state.value[e], s), o = {
|
|
105
|
+
type: K.patchObject,
|
|
106
|
+
payload: s,
|
|
107
|
+
storeId: e,
|
|
108
|
+
events: _
|
|
109
|
+
});
|
|
110
|
+
const v = L = Symbol();
|
|
111
|
+
ae().then(() => {
|
|
112
|
+
L === v && (h = !0);
|
|
113
|
+
}), f = !0, B(g, o, r.state.value[e]);
|
|
114
|
+
}
|
|
115
|
+
const W = d ? function() {
|
|
116
|
+
const { state: s } = a, o = s ? s() : {};
|
|
117
|
+
this.$patch((v) => {
|
|
118
|
+
O(v, o);
|
|
119
|
+
});
|
|
120
|
+
} : (
|
|
121
|
+
/* istanbul ignore next */
|
|
122
|
+
process.env.NODE_ENV !== "production" ? () => {
|
|
123
|
+
throw new Error(`🍍: Store "${e}" is built using the setup syntax and does not implement $reset().`);
|
|
124
|
+
} : ve
|
|
125
|
+
);
|
|
126
|
+
function X() {
|
|
127
|
+
l.stop(), g = [], E = [], r._s.delete(e);
|
|
128
|
+
}
|
|
129
|
+
const T = (s, o = "") => {
|
|
130
|
+
if (ie in s)
|
|
131
|
+
return s[G] = o, s;
|
|
132
|
+
const v = function() {
|
|
133
|
+
Q(r);
|
|
134
|
+
const w = Array.from(arguments), P = [], F = [];
|
|
135
|
+
function Y(b) {
|
|
136
|
+
P.push(b);
|
|
137
|
+
}
|
|
138
|
+
function Z(b) {
|
|
139
|
+
F.push(b);
|
|
140
|
+
}
|
|
141
|
+
B(E, {
|
|
142
|
+
args: w,
|
|
143
|
+
name: v[G],
|
|
144
|
+
store: u,
|
|
145
|
+
after: Y,
|
|
146
|
+
onError: Z
|
|
147
|
+
});
|
|
148
|
+
let $;
|
|
149
|
+
try {
|
|
150
|
+
$ = s.apply(this && this.$id === e ? this : u, w);
|
|
151
|
+
} catch (b) {
|
|
152
|
+
throw B(F, b), b;
|
|
153
|
+
}
|
|
154
|
+
return $ instanceof Promise ? $.then((b) => (B(P, b), b)).catch((b) => (B(F, b), Promise.reject(b))) : (B(P, $), $);
|
|
155
|
+
};
|
|
156
|
+
return v[ie] = !0, v[G] = o, v;
|
|
157
|
+
}, V = /* @__PURE__ */ A({
|
|
158
|
+
actions: {},
|
|
159
|
+
getters: {},
|
|
160
|
+
state: [],
|
|
161
|
+
hotState: U
|
|
162
|
+
}), k = {
|
|
163
|
+
_p: r,
|
|
164
|
+
// _s: scope,
|
|
165
|
+
$id: e,
|
|
166
|
+
$onAction: se.bind(null, E),
|
|
167
|
+
$patch: q,
|
|
168
|
+
$reset: W,
|
|
169
|
+
$subscribe(s, o = {}) {
|
|
170
|
+
const v = se(g, s, o.detached, () => w()), w = l.run(() => le(() => r.state.value[e], (P) => {
|
|
171
|
+
(o.flush === "sync" ? f : h) && s({
|
|
172
|
+
storeId: e,
|
|
173
|
+
type: K.direct,
|
|
174
|
+
events: _
|
|
175
|
+
}, P);
|
|
176
|
+
}, O({}, N, o)));
|
|
177
|
+
return v;
|
|
178
|
+
},
|
|
179
|
+
$dispose: X
|
|
180
|
+
}, u = be(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && J ? O(
|
|
181
|
+
{
|
|
182
|
+
_hmrPayload: V,
|
|
183
|
+
_customProperties: A(/* @__PURE__ */ new Set())
|
|
184
|
+
// devtools custom properties
|
|
185
|
+
},
|
|
186
|
+
k
|
|
187
|
+
// must be added later
|
|
188
|
+
// setupStore
|
|
189
|
+
) : k);
|
|
190
|
+
r._s.set(e, u);
|
|
191
|
+
const S = (r._a && r._a.runWithContext || Se)(() => r._e.run(() => (l = Ee()).run(() => n({ action: T }))));
|
|
192
|
+
for (const s in S) {
|
|
193
|
+
const o = S[s];
|
|
194
|
+
if (H(o) && !ce(o) || oe(o))
|
|
195
|
+
process.env.NODE_ENV !== "production" && p ? U.value[s] = z(S, s) : d || (I && Ie(o) && (H(o) ? o.value = I[s] : te(o, I[s])), r.state.value[e][s] = o), process.env.NODE_ENV !== "production" && V.state.push(s);
|
|
196
|
+
else if (typeof o == "function") {
|
|
197
|
+
const v = process.env.NODE_ENV !== "production" && p ? o : T(o, s);
|
|
198
|
+
S[s] = v, process.env.NODE_ENV !== "production" && (V.actions[s] = o), m.actions[s] = o;
|
|
199
|
+
} else process.env.NODE_ENV !== "production" && ce(o) && (V.getters[s] = d ? (
|
|
200
|
+
// @ts-expect-error
|
|
201
|
+
a.getters[s]
|
|
202
|
+
) : o, J && (S._getters || // @ts-expect-error: same
|
|
203
|
+
(S._getters = A([]))).push(s));
|
|
204
|
+
}
|
|
205
|
+
if (O(u, S), O(_e(u), S), Object.defineProperty(u, "$state", {
|
|
206
|
+
get: () => process.env.NODE_ENV !== "production" && p ? U.value : r.state.value[e],
|
|
207
|
+
set: (s) => {
|
|
208
|
+
if (process.env.NODE_ENV !== "production" && p)
|
|
209
|
+
throw new Error("cannot set hotState");
|
|
210
|
+
q((o) => {
|
|
211
|
+
O(o, s);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}), process.env.NODE_ENV !== "production" && (u._hotUpdate = A((s) => {
|
|
215
|
+
u._hotUpdating = !0, s._hmrPayload.state.forEach((o) => {
|
|
216
|
+
if (o in u.$state) {
|
|
217
|
+
const v = s.$state[o], w = u.$state[o];
|
|
218
|
+
typeof v == "object" && x(v) && x(w) ? pe(v, w) : s.$state[o] = w;
|
|
219
|
+
}
|
|
220
|
+
u[o] = z(s.$state, o);
|
|
221
|
+
}), Object.keys(u.$state).forEach((o) => {
|
|
222
|
+
o in s.$state || delete u[o];
|
|
223
|
+
}), h = !1, f = !1, r.state.value[e] = z(s._hmrPayload, "hotState"), f = !0, ae().then(() => {
|
|
224
|
+
h = !0;
|
|
225
|
+
});
|
|
226
|
+
for (const o in s._hmrPayload.actions) {
|
|
227
|
+
const v = s[o];
|
|
228
|
+
u[o] = //
|
|
229
|
+
T(v, o);
|
|
230
|
+
}
|
|
231
|
+
for (const o in s._hmrPayload.getters) {
|
|
232
|
+
const v = s._hmrPayload.getters[o], w = d ? (
|
|
233
|
+
// special handling of options api
|
|
234
|
+
j(() => (Q(r), v.call(u, u)))
|
|
235
|
+
) : v;
|
|
236
|
+
u[o] = //
|
|
237
|
+
w;
|
|
238
|
+
}
|
|
239
|
+
Object.keys(u._hmrPayload.getters).forEach((o) => {
|
|
240
|
+
o in s._hmrPayload.getters || delete u[o];
|
|
241
|
+
}), Object.keys(u._hmrPayload.actions).forEach((o) => {
|
|
242
|
+
o in s._hmrPayload.actions || delete u[o];
|
|
243
|
+
}), u._hmrPayload = s._hmrPayload, u._getters = s._getters, u._hotUpdating = !1;
|
|
244
|
+
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && J) {
|
|
245
|
+
const s = {
|
|
246
|
+
writable: !0,
|
|
247
|
+
configurable: !0,
|
|
248
|
+
// avoid warning on devtools trying to display this property
|
|
249
|
+
enumerable: !1
|
|
250
|
+
};
|
|
251
|
+
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((o) => {
|
|
252
|
+
Object.defineProperty(u, o, O({ value: u[o] }, s));
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return r._p.forEach((s) => {
|
|
256
|
+
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && J) {
|
|
257
|
+
const o = l.run(() => s({
|
|
258
|
+
store: u,
|
|
259
|
+
app: r._a,
|
|
260
|
+
pinia: r,
|
|
261
|
+
options: m
|
|
262
|
+
}));
|
|
263
|
+
Object.keys(o || {}).forEach((v) => u._customProperties.add(v)), O(u, o);
|
|
264
|
+
} else
|
|
265
|
+
O(u, l.run(() => s({
|
|
266
|
+
store: u,
|
|
267
|
+
app: r._a,
|
|
268
|
+
pinia: r,
|
|
269
|
+
options: m
|
|
270
|
+
})));
|
|
271
|
+
}), process.env.NODE_ENV !== "production" && u.$state && typeof u.$state == "object" && typeof u.$state.constructor == "function" && !u.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
272
|
+
state: () => new MyClass()
|
|
273
|
+
Found in store "${u.$id}".`), I && d && a.hydrate && a.hydrate(u.$state, I), h = !0, f = !0, u;
|
|
274
|
+
}
|
|
275
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
276
|
+
// @__NO_SIDE_EFFECTS__
|
|
277
|
+
function Ve(e, n, a) {
|
|
278
|
+
let r;
|
|
279
|
+
const p = typeof n == "function";
|
|
280
|
+
r = p ? a : n;
|
|
281
|
+
function d(l, m) {
|
|
282
|
+
const N = ye();
|
|
283
|
+
if (l = // in test mode, ignore the argument provided as we can always retrieve a
|
|
284
|
+
// pinia instance with getActivePinia()
|
|
285
|
+
(process.env.NODE_ENV === "test" && M && M._testing ? null : l) || (N ? me(Ne, null) : null), l && Q(l), process.env.NODE_ENV !== "production" && !M)
|
|
286
|
+
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
|
+
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
288
|
+
This will fail in production.`);
|
|
289
|
+
l = M, l._s.has(e) || (p ? ne(e, n, r, l) : ue(e, r, l), process.env.NODE_ENV !== "production" && (d._pinia = l));
|
|
290
|
+
const h = l._s.get(e);
|
|
291
|
+
if (process.env.NODE_ENV !== "production" && m) {
|
|
292
|
+
const f = "__hot:" + e, g = p ? ne(f, n, r, l, !0) : ue(f, O({}, r), l, !0);
|
|
293
|
+
m._hotUpdate(g), delete l.state.value[f], l._s.delete(f);
|
|
294
|
+
}
|
|
295
|
+
if (process.env.NODE_ENV !== "production" && J) {
|
|
296
|
+
const f = ge();
|
|
297
|
+
if (f && f.proxy && // avoid adding stores that are just built for hot module replacement
|
|
298
|
+
!m) {
|
|
299
|
+
const g = f.proxy, E = "_pStores" in g ? g._pStores : g._pStores = {};
|
|
300
|
+
E[e] = h;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return h;
|
|
304
|
+
}
|
|
305
|
+
return d.$id = e, d;
|
|
306
|
+
}
|
|
307
|
+
function ee() {
|
|
308
|
+
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
309
|
+
}
|
|
310
|
+
const $e = /* @__PURE__ */ Ve("hst-operation-log", () => {
|
|
311
|
+
const e = D({
|
|
312
|
+
maxOperations: 100,
|
|
313
|
+
enableCrossTabSync: !0,
|
|
314
|
+
enableServerSync: !1,
|
|
315
|
+
autoSyncInterval: 3e4,
|
|
316
|
+
enablePersistence: !1,
|
|
317
|
+
persistenceKeyPrefix: "stonecrop-ops"
|
|
318
|
+
}), n = D([]), a = D(-1), r = D(ee()), p = D(/* @__PURE__ */ new Date()), d = D(!1), l = D([]), m = D(null), N = j(() => a.value < 0 ? !1 : n.value[a.value]?.reversible ?? !1), h = j(() => a.value < n.value.length - 1), f = j(() => {
|
|
319
|
+
let i = 0;
|
|
320
|
+
for (let t = a.value; t >= 0 && n.value[t]?.reversible; t--)
|
|
321
|
+
i++;
|
|
322
|
+
return i;
|
|
323
|
+
}), g = j(() => n.value.length - 1 - a.value), E = j(() => ({
|
|
324
|
+
canUndo: N.value,
|
|
325
|
+
canRedo: h.value,
|
|
326
|
+
undoCount: f.value,
|
|
327
|
+
redoCount: g.value,
|
|
328
|
+
currentIndex: a.value
|
|
329
|
+
}));
|
|
330
|
+
function _(i) {
|
|
331
|
+
e.value = { ...e.value, ...i }, e.value.enablePersistence && (b(), fe()), e.value.enableCrossTabSync && P(), e.value.enableServerSync && e.value.autoSyncInterval && he();
|
|
332
|
+
}
|
|
333
|
+
function I(i, t = "user") {
|
|
334
|
+
const c = {
|
|
335
|
+
...i,
|
|
336
|
+
id: ee(),
|
|
337
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
338
|
+
source: t,
|
|
339
|
+
userId: e.value.userId
|
|
340
|
+
};
|
|
341
|
+
if (e.value.operationFilter && !e.value.operationFilter(c))
|
|
342
|
+
return c.id;
|
|
343
|
+
if (d.value)
|
|
344
|
+
return l.value.push(c), c.id;
|
|
345
|
+
if (a.value < n.value.length - 1 && (n.value = n.value.slice(0, a.value + 1)), n.value.push(c), a.value++, e.value.maxOperations && n.value.length > e.value.maxOperations) {
|
|
346
|
+
const y = n.value.length - e.value.maxOperations;
|
|
347
|
+
n.value = n.value.slice(y), a.value -= y;
|
|
348
|
+
}
|
|
349
|
+
return e.value.enableCrossTabSync && F(c), c.id;
|
|
350
|
+
}
|
|
351
|
+
function U() {
|
|
352
|
+
d.value = !0, l.value = [], m.value = ee();
|
|
353
|
+
}
|
|
354
|
+
function L(i) {
|
|
355
|
+
if (!d.value || l.value.length === 0)
|
|
356
|
+
return d.value = !1, l.value = [], m.value = null, null;
|
|
357
|
+
const t = m.value, c = l.value.every((C) => C.reversible), y = {
|
|
358
|
+
id: t,
|
|
359
|
+
type: "batch",
|
|
360
|
+
path: "",
|
|
361
|
+
// Batch doesn't have a single path
|
|
362
|
+
fieldname: "",
|
|
363
|
+
beforeValue: null,
|
|
364
|
+
afterValue: null,
|
|
365
|
+
doctype: l.value[0]?.doctype || "",
|
|
366
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
367
|
+
source: "user",
|
|
368
|
+
reversible: c,
|
|
369
|
+
irreversibleReason: c ? void 0 : "Contains irreversible operations",
|
|
370
|
+
childOperationIds: l.value.map((C) => C.id),
|
|
371
|
+
metadata: { description: i }
|
|
372
|
+
};
|
|
373
|
+
l.value.forEach((C) => {
|
|
374
|
+
C.parentOperationId = t;
|
|
375
|
+
}), n.value.push(...l.value, y), a.value = n.value.length - 1, e.value.enableCrossTabSync && Y(l.value, y);
|
|
376
|
+
const R = t;
|
|
377
|
+
return d.value = !1, l.value = [], m.value = null, R;
|
|
378
|
+
}
|
|
379
|
+
function q() {
|
|
380
|
+
d.value = !1, l.value = [], m.value = null;
|
|
381
|
+
}
|
|
382
|
+
function W(i) {
|
|
383
|
+
if (!N.value) return !1;
|
|
384
|
+
const t = n.value[a.value];
|
|
385
|
+
if (!t.reversible)
|
|
386
|
+
return typeof console < "u" && t.irreversibleReason && console.warn("Cannot undo irreversible operation:", t.irreversibleReason), !1;
|
|
387
|
+
try {
|
|
388
|
+
if (t.type === "batch" && t.childOperationIds)
|
|
389
|
+
for (let c = t.childOperationIds.length - 1; c >= 0; c--) {
|
|
390
|
+
const y = t.childOperationIds[c], R = n.value.find((C) => C.id === y);
|
|
391
|
+
R && T(R, i);
|
|
392
|
+
}
|
|
393
|
+
else
|
|
394
|
+
T(t, i);
|
|
395
|
+
return a.value--, e.value.enableCrossTabSync && Z(t), !0;
|
|
396
|
+
} catch (c) {
|
|
397
|
+
return typeof console < "u" && console.error("Undo failed:", c), !1;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function X(i) {
|
|
401
|
+
if (!h.value) return !1;
|
|
402
|
+
const t = n.value[a.value + 1];
|
|
403
|
+
try {
|
|
404
|
+
if (t.type === "batch" && t.childOperationIds)
|
|
405
|
+
for (const c of t.childOperationIds) {
|
|
406
|
+
const y = n.value.find((R) => R.id === c);
|
|
407
|
+
y && V(y, i);
|
|
408
|
+
}
|
|
409
|
+
else
|
|
410
|
+
V(t, i);
|
|
411
|
+
return a.value++, e.value.enableCrossTabSync && $(t), !0;
|
|
412
|
+
} catch (c) {
|
|
413
|
+
return typeof console < "u" && console.error("Redo failed:", c), !1;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function T(i, t) {
|
|
417
|
+
i.type === "set" && t && typeof t.set == "function" && t.set(i.path, i.beforeValue);
|
|
418
|
+
}
|
|
419
|
+
function V(i, t) {
|
|
420
|
+
i.type === "set" && t && typeof t.set == "function" && t.set(i.path, i.afterValue);
|
|
421
|
+
}
|
|
422
|
+
function k(i) {
|
|
423
|
+
return n.value.filter((t) => t.timestamp > i && t.source !== "sync");
|
|
424
|
+
}
|
|
425
|
+
function u() {
|
|
426
|
+
return {
|
|
427
|
+
operations: k(p.value),
|
|
428
|
+
lastSyncTimestamp: p.value,
|
|
429
|
+
currentTimestamp: /* @__PURE__ */ new Date(),
|
|
430
|
+
clientId: r.value
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function S(i) {
|
|
434
|
+
i.operations.forEach((t) => {
|
|
435
|
+
const c = { ...t, source: "sync" };
|
|
436
|
+
n.value.push(c);
|
|
437
|
+
}), p.value = i.currentTimestamp, a.value = n.value.length - 1;
|
|
438
|
+
}
|
|
439
|
+
function s() {
|
|
440
|
+
const i = n.value.filter((c) => c.reversible).length, t = n.value.map((c) => c.timestamp);
|
|
441
|
+
return {
|
|
442
|
+
operations: [...n.value],
|
|
443
|
+
currentIndex: a.value,
|
|
444
|
+
totalOperations: n.value.length,
|
|
445
|
+
reversibleOperations: i,
|
|
446
|
+
irreversibleOperations: n.value.length - i,
|
|
447
|
+
oldestOperation: t.length > 0 ? new Date(Math.min(...t.map((c) => c.getTime()))) : void 0,
|
|
448
|
+
newestOperation: t.length > 0 ? new Date(Math.max(...t.map((c) => c.getTime()))) : void 0
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function o() {
|
|
452
|
+
n.value = [], a.value = -1, p.value = /* @__PURE__ */ new Date();
|
|
453
|
+
}
|
|
454
|
+
function v(i, t) {
|
|
455
|
+
return n.value.filter(
|
|
456
|
+
(c) => c.doctype === i && (t === void 0 || c.recordId === t)
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
function w(i, t) {
|
|
460
|
+
const c = n.value.find((y) => y.id === i);
|
|
461
|
+
c && (c.reversible = !1, c.irreversibleReason = t);
|
|
462
|
+
}
|
|
463
|
+
function P() {
|
|
464
|
+
typeof window > "u" || !window.BroadcastChannel || new BroadcastChannel("stonecrop-operation-log").addEventListener("message", (i) => {
|
|
465
|
+
const t = i.data;
|
|
466
|
+
t.clientId !== r.value && t.type === "operation" && t.operation && (n.value.push({ ...t.operation, source: "sync" }), a.value = n.value.length - 1);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function F(i) {
|
|
470
|
+
if (typeof window > "u" || !window.BroadcastChannel) return;
|
|
471
|
+
const t = new BroadcastChannel("stonecrop-operation-log"), c = {
|
|
472
|
+
type: "operation",
|
|
473
|
+
operation: i,
|
|
474
|
+
clientId: r.value,
|
|
475
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
476
|
+
};
|
|
477
|
+
t.postMessage(c);
|
|
478
|
+
}
|
|
479
|
+
function Y(i, t) {
|
|
480
|
+
if (typeof window > "u" || !window.BroadcastChannel) return;
|
|
481
|
+
const c = new BroadcastChannel("stonecrop-operation-log"), y = {
|
|
482
|
+
type: "operation",
|
|
483
|
+
operations: [...i, t],
|
|
484
|
+
clientId: r.value,
|
|
485
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
486
|
+
};
|
|
487
|
+
c.postMessage(y);
|
|
488
|
+
}
|
|
489
|
+
function Z(i) {
|
|
490
|
+
if (typeof window > "u" || !window.BroadcastChannel) return;
|
|
491
|
+
const t = new BroadcastChannel("stonecrop-operation-log"), c = {
|
|
492
|
+
type: "undo",
|
|
493
|
+
operation: i,
|
|
494
|
+
clientId: r.value,
|
|
495
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
496
|
+
};
|
|
497
|
+
t.postMessage(c);
|
|
498
|
+
}
|
|
499
|
+
function $(i) {
|
|
500
|
+
if (typeof window > "u" || !window.BroadcastChannel) return;
|
|
501
|
+
const t = new BroadcastChannel("stonecrop-operation-log"), c = {
|
|
502
|
+
type: "redo",
|
|
503
|
+
operation: i,
|
|
504
|
+
clientId: r.value,
|
|
505
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
506
|
+
};
|
|
507
|
+
t.postMessage(c);
|
|
508
|
+
}
|
|
509
|
+
function b() {
|
|
510
|
+
if (!(typeof window > "u"))
|
|
511
|
+
try {
|
|
512
|
+
const i = `${e.value.persistenceKeyPrefix}-operations`, t = localStorage.getItem(i);
|
|
513
|
+
if (t) {
|
|
514
|
+
const c = JSON.parse(t);
|
|
515
|
+
c && Array.isArray(c.operations) && (n.value = c.operations.map((y) => ({
|
|
516
|
+
...y,
|
|
517
|
+
timestamp: new Date(y.timestamp)
|
|
518
|
+
})), a.value = c.currentIndex ?? -1);
|
|
519
|
+
}
|
|
520
|
+
} catch (i) {
|
|
521
|
+
typeof console < "u" && console.error("Failed to load operations from persistence:", i);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function de() {
|
|
525
|
+
if (!(typeof window > "u"))
|
|
526
|
+
try {
|
|
527
|
+
const i = `${e.value.persistenceKeyPrefix}-operations`, t = {
|
|
528
|
+
operations: n.value,
|
|
529
|
+
currentIndex: a.value
|
|
530
|
+
};
|
|
531
|
+
localStorage.setItem(i, JSON.stringify(t));
|
|
532
|
+
} catch (i) {
|
|
533
|
+
typeof console < "u" && console.error("Failed to save operations to persistence:", i);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function fe() {
|
|
537
|
+
le(
|
|
538
|
+
[n, a],
|
|
539
|
+
() => {
|
|
540
|
+
e.value.enablePersistence && de();
|
|
541
|
+
},
|
|
542
|
+
{ deep: !0 }
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
function he() {
|
|
546
|
+
!e.value.serverSyncEndpoint || !e.value.autoSyncInterval || setInterval(async () => {
|
|
547
|
+
try {
|
|
548
|
+
const i = u();
|
|
549
|
+
if (i.operations.length === 0) return;
|
|
550
|
+
(await fetch(e.value.serverSyncEndpoint, {
|
|
551
|
+
method: "POST",
|
|
552
|
+
headers: { "Content-Type": "application/json" },
|
|
553
|
+
body: JSON.stringify(i)
|
|
554
|
+
})).ok && (p.value = /* @__PURE__ */ new Date());
|
|
555
|
+
} catch (i) {
|
|
556
|
+
typeof console < "u" && console.error("Server sync failed:", i);
|
|
557
|
+
}
|
|
558
|
+
}, e.value.autoSyncInterval);
|
|
559
|
+
}
|
|
560
|
+
return {
|
|
561
|
+
// State
|
|
562
|
+
operations: n,
|
|
563
|
+
currentIndex: a,
|
|
564
|
+
config: e,
|
|
565
|
+
clientId: r,
|
|
566
|
+
undoRedoState: E,
|
|
567
|
+
// Computed
|
|
568
|
+
canUndo: N,
|
|
569
|
+
canRedo: h,
|
|
570
|
+
undoCount: f,
|
|
571
|
+
redoCount: g,
|
|
572
|
+
// Methods
|
|
573
|
+
configure: _,
|
|
574
|
+
addOperation: I,
|
|
575
|
+
startBatch: U,
|
|
576
|
+
commitBatch: L,
|
|
577
|
+
cancelBatch: q,
|
|
578
|
+
undo: W,
|
|
579
|
+
redo: X,
|
|
580
|
+
clear: o,
|
|
581
|
+
getOperationsFor: v,
|
|
582
|
+
getOperationsSince: k,
|
|
583
|
+
createSyncDelta: u,
|
|
584
|
+
applySyncDelta: S,
|
|
585
|
+
getSnapshot: s,
|
|
586
|
+
markIrreversible: w
|
|
587
|
+
};
|
|
588
|
+
});
|
|
589
|
+
export {
|
|
590
|
+
$e as useOperationLogStore
|
|
591
|
+
};
|
|
592
|
+
//# sourceMappingURL=operation-log-DB-dGNT9-C9cIr4-e.js.map
|