document-model 1.0.55 → 1.1.0-experimental.1
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/browser/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/browser/cjs/internal/index-DZx9eknf.js +1 -0
- package/dist/browser/cjs/internal/{index-C_OFq7P5.js → index-DypcJuba.js} +1 -1
- package/dist/browser/cjs/internal/object-BU2CI8g7.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +2 -2
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/index-BP3Z2ZVF.js +43 -0
- package/dist/browser/es/internal/{index-DvHnaqeu.js → index-CyBZ1dJQ.js} +1 -1
- package/dist/browser/es/internal/object-CPDHmXxz.js +2712 -0
- package/dist/browser/src/document/reducer.d.ts +13 -2
- package/dist/browser/src/document/utils/base.d.ts +1 -1
- package/dist/browser/src/document/utils/document-helpers.d.ts +53 -0
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/node/cjs/internal/{index-GZsLKtHl.js → index-Bt4KwBzM.js} +1 -1
- package/dist/node/cjs/internal/index-CwTTSCCW.js +1 -0
- package/dist/node/cjs/internal/object-Bc_eSRcx.js +20 -0
- package/dist/node/es/document-model.js +3 -3
- package/dist/node/es/document.js +3 -3
- package/dist/node/es/index.js +4 -4
- package/dist/node/es/internal/{index-Chx4C-Xl.js → index-6nUwJlFL.js} +2 -2
- package/dist/node/es/internal/index-CLgAZiia.js +43 -0
- package/dist/node/es/internal/object-DofGWMf1.js +1610 -0
- package/dist/node/src/document/reducer.d.ts +13 -2
- package/dist/node/src/document/utils/base.d.ts +1 -1
- package/dist/node/src/document/utils/document-helpers.d.ts +53 -0
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/package.json +7 -2
- package/dist/browser/cjs/internal/index-Dwhv4k_6.js +0 -1
- package/dist/browser/cjs/internal/object-CeLE3akL.js +0 -25
- package/dist/browser/es/internal/index-Xcvn-MUq.js +0 -42
- package/dist/browser/es/internal/object-BDWVt0Zy.js +0 -2504
- package/dist/node/cjs/internal/index-Bi9yeV3W.js +0 -1
- package/dist/node/cjs/internal/object-CnhDksx1.js +0 -20
- package/dist/node/es/internal/index-B6iEYnbQ.js +0 -42
- package/dist/node/es/internal/object-CnV5hY_A.js +0 -1402
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -14
- package/dist/src/document/actions/types.d.ts +0 -15
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -1175
- package/dist/src/document/reducer.d.ts +0 -32
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -176
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -29
- package/dist/src/document/types.d.ts +0 -249
- package/dist/src/document/utils/base.d.ts +0 -85
- package/dist/src/document/utils/file.d.ts +0 -48
- package/dist/src/document/utils/index.d.ts +0 -4
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document/utils/validation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/src/document-model/custom/utils.d.ts +0 -7
- package/dist/src/document-model/gen/actions.d.ts +0 -15
- package/dist/src/document-model/gen/creators.d.ts +0 -7
- package/dist/src/document-model/gen/document-model.d.ts +0 -2
- package/dist/src/document-model/gen/header/actions.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts +0 -8
- package/dist/src/document-model/gen/header/object.d.ts +0 -12
- package/dist/src/document-model/gen/header/operations.d.ts +0 -10
- package/dist/src/document-model/gen/index.d.ts +0 -5
- package/dist/src/document-model/gen/module/actions.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts +0 -7
- package/dist/src/document-model/gen/module/object.d.ts +0 -11
- package/dist/src/document-model/gen/module/operations.d.ts +0 -9
- package/dist/src/document-model/gen/object.d.ts +0 -28
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/src/document-model/gen/operation/object.d.ts +0 -16
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/src/document-model/gen/reducer.d.ts +0 -5
- package/dist/src/document-model/gen/schema/index.d.ts +0 -2
- package/dist/src/document-model/gen/schema/types.d.ts +0 -453
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/src/document-model/gen/state/actions.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts +0 -8
- package/dist/src/document-model/gen/state/object.d.ts +0 -12
- package/dist/src/document-model/gen/state/operations.d.ts +0 -10
- package/dist/src/document-model/gen/types.d.ts +0 -8
- package/dist/src/document-model/gen/utils.d.ts +0 -6
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/src/document-model/index.d.ts +0 -80
- package/dist/src/index.d.ts +0 -25
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
|
@@ -0,0 +1,1610 @@
|
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var pe = (t, e, n) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var st = (t, e, n) => (pe(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
import { produce as pt, castDraft as at, castImmutable as ce, freeze as le } from "immer";
|
|
5
|
+
import { z as u } from "zod";
|
|
6
|
+
import Dt from "jszip";
|
|
7
|
+
import me from "crypto";
|
|
8
|
+
import ut from "fs";
|
|
9
|
+
import ue from "https";
|
|
10
|
+
import { join as fe } from "path";
|
|
11
|
+
const _t = (t) => t != null, de = u.any().refine((t) => _t(t)), Tt = u.enum(["LOAD_STATE"]), Nt = u.enum(["PRUNE"]), vt = u.enum(["REDO"]), It = u.enum(["SET_NAME"]), At = u.enum(["UNDO"]);
|
|
12
|
+
function ge() {
|
|
13
|
+
return u.object({
|
|
14
|
+
__typename: u.literal("Action").optional(),
|
|
15
|
+
type: u.string()
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function Y() {
|
|
19
|
+
return u.literal("global").or(u.literal("local"));
|
|
20
|
+
}
|
|
21
|
+
function Pt() {
|
|
22
|
+
return u.union([
|
|
23
|
+
Mt(),
|
|
24
|
+
Ct(),
|
|
25
|
+
Ft(),
|
|
26
|
+
Lt(),
|
|
27
|
+
Rt()
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
function he() {
|
|
31
|
+
return u.object({
|
|
32
|
+
__typename: u.literal("DocumentFile").optional(),
|
|
33
|
+
data: u.string(),
|
|
34
|
+
extension: u.string().nullable(),
|
|
35
|
+
fileName: u.string().nullable(),
|
|
36
|
+
mimeType: u.string()
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function Mt() {
|
|
40
|
+
return u.object({
|
|
41
|
+
input: u.lazy(() => ht()),
|
|
42
|
+
type: Tt,
|
|
43
|
+
scope: Y()
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function ht() {
|
|
47
|
+
return u.object({
|
|
48
|
+
operations: u.number(),
|
|
49
|
+
state: u.lazy(() => zt())
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function zt() {
|
|
53
|
+
return u.object({
|
|
54
|
+
data: u.unknown().nullish(),
|
|
55
|
+
name: u.string()
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function xe() {
|
|
59
|
+
return u.object({
|
|
60
|
+
__typename: u.literal("Operation").optional(),
|
|
61
|
+
hash: u.string(),
|
|
62
|
+
index: u.number(),
|
|
63
|
+
timestamp: u.string().datetime(),
|
|
64
|
+
type: u.string()
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function Ct() {
|
|
68
|
+
return u.object({
|
|
69
|
+
input: u.lazy(() => xt()),
|
|
70
|
+
type: Nt,
|
|
71
|
+
scope: Y()
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function xt() {
|
|
75
|
+
return u.object({
|
|
76
|
+
end: u.number().nullish(),
|
|
77
|
+
start: u.number().nullish()
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const yt = u.number;
|
|
81
|
+
function Ft() {
|
|
82
|
+
return u.object({
|
|
83
|
+
input: yt(),
|
|
84
|
+
type: vt,
|
|
85
|
+
scope: Y()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const bt = u.string;
|
|
89
|
+
function Lt() {
|
|
90
|
+
return u.object({
|
|
91
|
+
input: bt(),
|
|
92
|
+
type: It,
|
|
93
|
+
scope: u.literal("global")
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ye() {
|
|
97
|
+
return u.object({
|
|
98
|
+
__typename: u.literal("SetNameOperation").optional(),
|
|
99
|
+
hash: u.string(),
|
|
100
|
+
index: u.number(),
|
|
101
|
+
input: u.string(),
|
|
102
|
+
timestamp: u.string().datetime(),
|
|
103
|
+
type: u.string()
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const wt = u.number;
|
|
107
|
+
function Rt() {
|
|
108
|
+
return u.object({
|
|
109
|
+
input: wt(),
|
|
110
|
+
type: At,
|
|
111
|
+
scope: Y()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
115
|
+
__proto__: null,
|
|
116
|
+
ActionSchema: ge,
|
|
117
|
+
BaseActionSchema: Pt,
|
|
118
|
+
DocumentFileSchema: he,
|
|
119
|
+
LoadStateActionInputSchema: ht,
|
|
120
|
+
LoadStateActionSchema: Mt,
|
|
121
|
+
LoadStateActionStateInputSchema: zt,
|
|
122
|
+
Load_StateSchema: Tt,
|
|
123
|
+
OperationSchema: xe,
|
|
124
|
+
OperationScopeSchema: Y,
|
|
125
|
+
PruneActionInputSchema: xt,
|
|
126
|
+
PruneActionSchema: Ct,
|
|
127
|
+
PruneSchema: Nt,
|
|
128
|
+
RedoActionInputSchema: yt,
|
|
129
|
+
RedoActionSchema: Ft,
|
|
130
|
+
RedoSchema: vt,
|
|
131
|
+
SetNameActionInputSchema: bt,
|
|
132
|
+
SetNameActionSchema: Lt,
|
|
133
|
+
SetNameOperationSchema: ye,
|
|
134
|
+
Set_NameSchema: It,
|
|
135
|
+
UndoActionInputSchema: wt,
|
|
136
|
+
UndoActionSchema: Rt,
|
|
137
|
+
UndoSchema: At,
|
|
138
|
+
definedNonNullAnySchema: de,
|
|
139
|
+
isDefinedNonNullAny: _t
|
|
140
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
141
|
+
function be(t) {
|
|
142
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
143
|
+
}
|
|
144
|
+
var ft = { exports: {} };
|
|
145
|
+
(function(t, e) {
|
|
146
|
+
const { hasOwnProperty: n } = Object.prototype, i = R();
|
|
147
|
+
i.configure = R, i.stringify = i, i.default = i, e.stringify = i, e.configure = R, t.exports = i;
|
|
148
|
+
const o = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
|
|
149
|
+
function a(l) {
|
|
150
|
+
return l.length < 5e3 && !o.test(l) ? `"${l}"` : JSON.stringify(l);
|
|
151
|
+
}
|
|
152
|
+
function r(l) {
|
|
153
|
+
if (l.length > 200)
|
|
154
|
+
return l.sort();
|
|
155
|
+
for (let m = 1; m < l.length; m++) {
|
|
156
|
+
const j = l[m];
|
|
157
|
+
let A = m;
|
|
158
|
+
for (; A !== 0 && l[A - 1] > j; )
|
|
159
|
+
l[A] = l[A - 1], A--;
|
|
160
|
+
l[A] = j;
|
|
161
|
+
}
|
|
162
|
+
return l;
|
|
163
|
+
}
|
|
164
|
+
const p = Object.getOwnPropertyDescriptor(
|
|
165
|
+
Object.getPrototypeOf(
|
|
166
|
+
Object.getPrototypeOf(
|
|
167
|
+
new Int8Array()
|
|
168
|
+
)
|
|
169
|
+
),
|
|
170
|
+
Symbol.toStringTag
|
|
171
|
+
).get;
|
|
172
|
+
function c(l) {
|
|
173
|
+
return p.call(l) !== void 0 && l.length !== 0;
|
|
174
|
+
}
|
|
175
|
+
function f(l, m, j) {
|
|
176
|
+
l.length < j && (j = l.length);
|
|
177
|
+
const A = m === "," ? "" : " ";
|
|
178
|
+
let H = `"0":${A}${l[0]}`;
|
|
179
|
+
for (let C = 1; C < j; C++)
|
|
180
|
+
H += `${m}"${C}":${A}${l[C]}`;
|
|
181
|
+
return H;
|
|
182
|
+
}
|
|
183
|
+
function x(l) {
|
|
184
|
+
if (n.call(l, "circularValue")) {
|
|
185
|
+
const m = l.circularValue;
|
|
186
|
+
if (typeof m == "string")
|
|
187
|
+
return `"${m}"`;
|
|
188
|
+
if (m == null)
|
|
189
|
+
return m;
|
|
190
|
+
if (m === Error || m === TypeError)
|
|
191
|
+
return {
|
|
192
|
+
toString() {
|
|
193
|
+
throw new TypeError("Converting circular structure to JSON");
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
|
|
197
|
+
}
|
|
198
|
+
return '"[Circular]"';
|
|
199
|
+
}
|
|
200
|
+
function E(l, m) {
|
|
201
|
+
let j;
|
|
202
|
+
if (n.call(l, m) && (j = l[m], typeof j != "boolean"))
|
|
203
|
+
throw new TypeError(`The "${m}" argument must be of type boolean`);
|
|
204
|
+
return j === void 0 ? !0 : j;
|
|
205
|
+
}
|
|
206
|
+
function w(l, m) {
|
|
207
|
+
let j;
|
|
208
|
+
if (n.call(l, m)) {
|
|
209
|
+
if (j = l[m], typeof j != "number")
|
|
210
|
+
throw new TypeError(`The "${m}" argument must be of type number`);
|
|
211
|
+
if (!Number.isInteger(j))
|
|
212
|
+
throw new TypeError(`The "${m}" argument must be an integer`);
|
|
213
|
+
if (j < 1)
|
|
214
|
+
throw new RangeError(`The "${m}" argument must be >= 1`);
|
|
215
|
+
}
|
|
216
|
+
return j === void 0 ? 1 / 0 : j;
|
|
217
|
+
}
|
|
218
|
+
function y(l) {
|
|
219
|
+
return l === 1 ? "1 item" : `${l} items`;
|
|
220
|
+
}
|
|
221
|
+
function T(l) {
|
|
222
|
+
const m = /* @__PURE__ */ new Set();
|
|
223
|
+
for (const j of l)
|
|
224
|
+
(typeof j == "string" || typeof j == "number") && m.add(String(j));
|
|
225
|
+
return m;
|
|
226
|
+
}
|
|
227
|
+
function v(l) {
|
|
228
|
+
if (n.call(l, "strict")) {
|
|
229
|
+
const m = l.strict;
|
|
230
|
+
if (typeof m != "boolean")
|
|
231
|
+
throw new TypeError('The "strict" argument must be of type boolean');
|
|
232
|
+
if (m)
|
|
233
|
+
return (j) => {
|
|
234
|
+
let A = `Object can not safely be stringified. Received type ${typeof j}`;
|
|
235
|
+
throw typeof j != "function" && (A += ` (${j.toString()})`), new Error(A);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function R(l) {
|
|
240
|
+
l = { ...l };
|
|
241
|
+
const m = v(l);
|
|
242
|
+
m && (l.bigint === void 0 && (l.bigint = !1), "circularValue" in l || (l.circularValue = Error));
|
|
243
|
+
const j = x(l), A = E(l, "bigint"), H = E(l, "deterministic"), C = w(l, "maximumDepth"), D = w(l, "maximumBreadth");
|
|
244
|
+
function nt(P, s, d, b, h, S) {
|
|
245
|
+
let g = s[P];
|
|
246
|
+
switch (typeof g == "object" && g !== null && typeof g.toJSON == "function" && (g = g.toJSON(P)), g = b.call(s, P, g), typeof g) {
|
|
247
|
+
case "string":
|
|
248
|
+
return a(g);
|
|
249
|
+
case "object": {
|
|
250
|
+
if (g === null)
|
|
251
|
+
return "null";
|
|
252
|
+
if (d.indexOf(g) !== -1)
|
|
253
|
+
return j;
|
|
254
|
+
let O = "", k = ",";
|
|
255
|
+
const _ = S;
|
|
256
|
+
if (Array.isArray(g)) {
|
|
257
|
+
if (g.length === 0)
|
|
258
|
+
return "[]";
|
|
259
|
+
if (C < d.length + 1)
|
|
260
|
+
return '"[Array]"';
|
|
261
|
+
d.push(g), h !== "" && (S += h, O += `
|
|
262
|
+
${S}`, k = `,
|
|
263
|
+
${S}`);
|
|
264
|
+
const z = Math.min(g.length, D);
|
|
265
|
+
let q = 0;
|
|
266
|
+
for (; q < z - 1; q++) {
|
|
267
|
+
const ot = nt(String(q), g, d, b, h, S);
|
|
268
|
+
O += ot !== void 0 ? ot : "null", O += k;
|
|
269
|
+
}
|
|
270
|
+
const U = nt(String(q), g, d, b, h, S);
|
|
271
|
+
if (O += U !== void 0 ? U : "null", g.length - 1 > D) {
|
|
272
|
+
const ot = g.length - D - 1;
|
|
273
|
+
O += `${k}"... ${y(ot)} not stringified"`;
|
|
274
|
+
}
|
|
275
|
+
return h !== "" && (O += `
|
|
276
|
+
${_}`), d.pop(), `[${O}]`;
|
|
277
|
+
}
|
|
278
|
+
let N = Object.keys(g);
|
|
279
|
+
const I = N.length;
|
|
280
|
+
if (I === 0)
|
|
281
|
+
return "{}";
|
|
282
|
+
if (C < d.length + 1)
|
|
283
|
+
return '"[Object]"';
|
|
284
|
+
let $ = "", M = "";
|
|
285
|
+
h !== "" && (S += h, k = `,
|
|
286
|
+
${S}`, $ = " ");
|
|
287
|
+
const L = Math.min(I, D);
|
|
288
|
+
H && !c(g) && (N = r(N)), d.push(g);
|
|
289
|
+
for (let z = 0; z < L; z++) {
|
|
290
|
+
const q = N[z], U = nt(q, g, d, b, h, S);
|
|
291
|
+
U !== void 0 && (O += `${M}${a(q)}:${$}${U}`, M = k);
|
|
292
|
+
}
|
|
293
|
+
if (I > D) {
|
|
294
|
+
const z = I - D;
|
|
295
|
+
O += `${M}"...":${$}"${y(z)} not stringified"`, M = k;
|
|
296
|
+
}
|
|
297
|
+
return h !== "" && M.length > 1 && (O = `
|
|
298
|
+
${S}${O}
|
|
299
|
+
${_}`), d.pop(), `{${O}}`;
|
|
300
|
+
}
|
|
301
|
+
case "number":
|
|
302
|
+
return isFinite(g) ? String(g) : m ? m(g) : "null";
|
|
303
|
+
case "boolean":
|
|
304
|
+
return g === !0 ? "true" : "false";
|
|
305
|
+
case "undefined":
|
|
306
|
+
return;
|
|
307
|
+
case "bigint":
|
|
308
|
+
if (A)
|
|
309
|
+
return String(g);
|
|
310
|
+
default:
|
|
311
|
+
return m ? m(g) : void 0;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function it(P, s, d, b, h, S) {
|
|
315
|
+
switch (typeof s == "object" && s !== null && typeof s.toJSON == "function" && (s = s.toJSON(P)), typeof s) {
|
|
316
|
+
case "string":
|
|
317
|
+
return a(s);
|
|
318
|
+
case "object": {
|
|
319
|
+
if (s === null)
|
|
320
|
+
return "null";
|
|
321
|
+
if (d.indexOf(s) !== -1)
|
|
322
|
+
return j;
|
|
323
|
+
const g = S;
|
|
324
|
+
let O = "", k = ",";
|
|
325
|
+
if (Array.isArray(s)) {
|
|
326
|
+
if (s.length === 0)
|
|
327
|
+
return "[]";
|
|
328
|
+
if (C < d.length + 1)
|
|
329
|
+
return '"[Array]"';
|
|
330
|
+
d.push(s), h !== "" && (S += h, O += `
|
|
331
|
+
${S}`, k = `,
|
|
332
|
+
${S}`);
|
|
333
|
+
const I = Math.min(s.length, D);
|
|
334
|
+
let $ = 0;
|
|
335
|
+
for (; $ < I - 1; $++) {
|
|
336
|
+
const L = it(String($), s[$], d, b, h, S);
|
|
337
|
+
O += L !== void 0 ? L : "null", O += k;
|
|
338
|
+
}
|
|
339
|
+
const M = it(String($), s[$], d, b, h, S);
|
|
340
|
+
if (O += M !== void 0 ? M : "null", s.length - 1 > D) {
|
|
341
|
+
const L = s.length - D - 1;
|
|
342
|
+
O += `${k}"... ${y(L)} not stringified"`;
|
|
343
|
+
}
|
|
344
|
+
return h !== "" && (O += `
|
|
345
|
+
${g}`), d.pop(), `[${O}]`;
|
|
346
|
+
}
|
|
347
|
+
d.push(s);
|
|
348
|
+
let _ = "";
|
|
349
|
+
h !== "" && (S += h, k = `,
|
|
350
|
+
${S}`, _ = " ");
|
|
351
|
+
let N = "";
|
|
352
|
+
for (const I of b) {
|
|
353
|
+
const $ = it(I, s[I], d, b, h, S);
|
|
354
|
+
$ !== void 0 && (O += `${N}${a(I)}:${_}${$}`, N = k);
|
|
355
|
+
}
|
|
356
|
+
return h !== "" && N.length > 1 && (O = `
|
|
357
|
+
${S}${O}
|
|
358
|
+
${g}`), d.pop(), `{${O}}`;
|
|
359
|
+
}
|
|
360
|
+
case "number":
|
|
361
|
+
return isFinite(s) ? String(s) : m ? m(s) : "null";
|
|
362
|
+
case "boolean":
|
|
363
|
+
return s === !0 ? "true" : "false";
|
|
364
|
+
case "undefined":
|
|
365
|
+
return;
|
|
366
|
+
case "bigint":
|
|
367
|
+
if (A)
|
|
368
|
+
return String(s);
|
|
369
|
+
default:
|
|
370
|
+
return m ? m(s) : void 0;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function G(P, s, d, b, h) {
|
|
374
|
+
switch (typeof s) {
|
|
375
|
+
case "string":
|
|
376
|
+
return a(s);
|
|
377
|
+
case "object": {
|
|
378
|
+
if (s === null)
|
|
379
|
+
return "null";
|
|
380
|
+
if (typeof s.toJSON == "function") {
|
|
381
|
+
if (s = s.toJSON(P), typeof s != "object")
|
|
382
|
+
return G(P, s, d, b, h);
|
|
383
|
+
if (s === null)
|
|
384
|
+
return "null";
|
|
385
|
+
}
|
|
386
|
+
if (d.indexOf(s) !== -1)
|
|
387
|
+
return j;
|
|
388
|
+
const S = h;
|
|
389
|
+
if (Array.isArray(s)) {
|
|
390
|
+
if (s.length === 0)
|
|
391
|
+
return "[]";
|
|
392
|
+
if (C < d.length + 1)
|
|
393
|
+
return '"[Array]"';
|
|
394
|
+
d.push(s), h += b;
|
|
395
|
+
let $ = `
|
|
396
|
+
${h}`;
|
|
397
|
+
const M = `,
|
|
398
|
+
${h}`, L = Math.min(s.length, D);
|
|
399
|
+
let z = 0;
|
|
400
|
+
for (; z < L - 1; z++) {
|
|
401
|
+
const U = G(String(z), s[z], d, b, h);
|
|
402
|
+
$ += U !== void 0 ? U : "null", $ += M;
|
|
403
|
+
}
|
|
404
|
+
const q = G(String(z), s[z], d, b, h);
|
|
405
|
+
if ($ += q !== void 0 ? q : "null", s.length - 1 > D) {
|
|
406
|
+
const U = s.length - D - 1;
|
|
407
|
+
$ += `${M}"... ${y(U)} not stringified"`;
|
|
408
|
+
}
|
|
409
|
+
return $ += `
|
|
410
|
+
${S}`, d.pop(), `[${$}]`;
|
|
411
|
+
}
|
|
412
|
+
let g = Object.keys(s);
|
|
413
|
+
const O = g.length;
|
|
414
|
+
if (O === 0)
|
|
415
|
+
return "{}";
|
|
416
|
+
if (C < d.length + 1)
|
|
417
|
+
return '"[Object]"';
|
|
418
|
+
h += b;
|
|
419
|
+
const k = `,
|
|
420
|
+
${h}`;
|
|
421
|
+
let _ = "", N = "", I = Math.min(O, D);
|
|
422
|
+
c(s) && (_ += f(s, k, D), g = g.slice(s.length), I -= s.length, N = k), H && (g = r(g)), d.push(s);
|
|
423
|
+
for (let $ = 0; $ < I; $++) {
|
|
424
|
+
const M = g[$], L = G(M, s[M], d, b, h);
|
|
425
|
+
L !== void 0 && (_ += `${N}${a(M)}: ${L}`, N = k);
|
|
426
|
+
}
|
|
427
|
+
if (O > D) {
|
|
428
|
+
const $ = O - D;
|
|
429
|
+
_ += `${N}"...": "${y($)} not stringified"`, N = k;
|
|
430
|
+
}
|
|
431
|
+
return N !== "" && (_ = `
|
|
432
|
+
${h}${_}
|
|
433
|
+
${S}`), d.pop(), `{${_}}`;
|
|
434
|
+
}
|
|
435
|
+
case "number":
|
|
436
|
+
return isFinite(s) ? String(s) : m ? m(s) : "null";
|
|
437
|
+
case "boolean":
|
|
438
|
+
return s === !0 ? "true" : "false";
|
|
439
|
+
case "undefined":
|
|
440
|
+
return;
|
|
441
|
+
case "bigint":
|
|
442
|
+
if (A)
|
|
443
|
+
return String(s);
|
|
444
|
+
default:
|
|
445
|
+
return m ? m(s) : void 0;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function Z(P, s, d) {
|
|
449
|
+
switch (typeof s) {
|
|
450
|
+
case "string":
|
|
451
|
+
return a(s);
|
|
452
|
+
case "object": {
|
|
453
|
+
if (s === null)
|
|
454
|
+
return "null";
|
|
455
|
+
if (typeof s.toJSON == "function") {
|
|
456
|
+
if (s = s.toJSON(P), typeof s != "object")
|
|
457
|
+
return Z(P, s, d);
|
|
458
|
+
if (s === null)
|
|
459
|
+
return "null";
|
|
460
|
+
}
|
|
461
|
+
if (d.indexOf(s) !== -1)
|
|
462
|
+
return j;
|
|
463
|
+
let b = "";
|
|
464
|
+
if (Array.isArray(s)) {
|
|
465
|
+
if (s.length === 0)
|
|
466
|
+
return "[]";
|
|
467
|
+
if (C < d.length + 1)
|
|
468
|
+
return '"[Array]"';
|
|
469
|
+
d.push(s);
|
|
470
|
+
const k = Math.min(s.length, D);
|
|
471
|
+
let _ = 0;
|
|
472
|
+
for (; _ < k - 1; _++) {
|
|
473
|
+
const I = Z(String(_), s[_], d);
|
|
474
|
+
b += I !== void 0 ? I : "null", b += ",";
|
|
475
|
+
}
|
|
476
|
+
const N = Z(String(_), s[_], d);
|
|
477
|
+
if (b += N !== void 0 ? N : "null", s.length - 1 > D) {
|
|
478
|
+
const I = s.length - D - 1;
|
|
479
|
+
b += `,"... ${y(I)} not stringified"`;
|
|
480
|
+
}
|
|
481
|
+
return d.pop(), `[${b}]`;
|
|
482
|
+
}
|
|
483
|
+
let h = Object.keys(s);
|
|
484
|
+
const S = h.length;
|
|
485
|
+
if (S === 0)
|
|
486
|
+
return "{}";
|
|
487
|
+
if (C < d.length + 1)
|
|
488
|
+
return '"[Object]"';
|
|
489
|
+
let g = "", O = Math.min(S, D);
|
|
490
|
+
c(s) && (b += f(s, ",", D), h = h.slice(s.length), O -= s.length, g = ","), H && (h = r(h)), d.push(s);
|
|
491
|
+
for (let k = 0; k < O; k++) {
|
|
492
|
+
const _ = h[k], N = Z(_, s[_], d);
|
|
493
|
+
N !== void 0 && (b += `${g}${a(_)}:${N}`, g = ",");
|
|
494
|
+
}
|
|
495
|
+
if (S > D) {
|
|
496
|
+
const k = S - D;
|
|
497
|
+
b += `${g}"...":"${y(k)} not stringified"`;
|
|
498
|
+
}
|
|
499
|
+
return d.pop(), `{${b}}`;
|
|
500
|
+
}
|
|
501
|
+
case "number":
|
|
502
|
+
return isFinite(s) ? String(s) : m ? m(s) : "null";
|
|
503
|
+
case "boolean":
|
|
504
|
+
return s === !0 ? "true" : "false";
|
|
505
|
+
case "undefined":
|
|
506
|
+
return;
|
|
507
|
+
case "bigint":
|
|
508
|
+
if (A)
|
|
509
|
+
return String(s);
|
|
510
|
+
default:
|
|
511
|
+
return m ? m(s) : void 0;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function re(P, s, d) {
|
|
515
|
+
if (arguments.length > 1) {
|
|
516
|
+
let b = "";
|
|
517
|
+
if (typeof d == "number" ? b = " ".repeat(Math.min(d, 10)) : typeof d == "string" && (b = d.slice(0, 10)), s != null) {
|
|
518
|
+
if (typeof s == "function")
|
|
519
|
+
return nt("", { "": P }, [], s, b, "");
|
|
520
|
+
if (Array.isArray(s))
|
|
521
|
+
return it("", P, [], T(s), b, "");
|
|
522
|
+
}
|
|
523
|
+
if (b.length !== 0)
|
|
524
|
+
return G("", P, [], b, "");
|
|
525
|
+
}
|
|
526
|
+
return Z("", P, []);
|
|
527
|
+
}
|
|
528
|
+
return re;
|
|
529
|
+
}
|
|
530
|
+
})(ft, ft.exports);
|
|
531
|
+
var we = ft.exports;
|
|
532
|
+
const K = /* @__PURE__ */ be(we);
|
|
533
|
+
K.configure;
|
|
534
|
+
function Oe(t, e) {
|
|
535
|
+
return { ...t, name: e };
|
|
536
|
+
}
|
|
537
|
+
function je(t, e, n) {
|
|
538
|
+
const { scope: i, input: o } = e;
|
|
539
|
+
return pt({
|
|
540
|
+
document: t,
|
|
541
|
+
action: e,
|
|
542
|
+
skip: n
|
|
543
|
+
}, (r) => {
|
|
544
|
+
if (r.document.operations[i].length < 1)
|
|
545
|
+
throw new Error(
|
|
546
|
+
`Cannot undo: no operations in history for scope "${i}"`
|
|
547
|
+
);
|
|
548
|
+
if (o < 1)
|
|
549
|
+
throw new Error(
|
|
550
|
+
"Invalid UNDO action: input value must be greater than 0"
|
|
551
|
+
);
|
|
552
|
+
if (r.skip > 0)
|
|
553
|
+
throw new Error(
|
|
554
|
+
"Cannot undo: skip value from reducer cannot be used with UNDO action"
|
|
555
|
+
);
|
|
556
|
+
const p = r.document.operations[i].at(-1), c = p && p.type === "NOOP" && p.skip > 0;
|
|
557
|
+
if (r.skip += o, c) {
|
|
558
|
+
r.skip += p.skip;
|
|
559
|
+
const w = r.document.operations[i][r.document.operations[i].length - 2];
|
|
560
|
+
w && p.index - w.index === 1 && r.document.operations[i].pop();
|
|
561
|
+
}
|
|
562
|
+
if (r.document.operations[i].length < r.skip)
|
|
563
|
+
throw new Error(
|
|
564
|
+
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
565
|
+
);
|
|
566
|
+
const f = r.document.operations[i].length - 1;
|
|
567
|
+
let x = o, E = c ? f - p.skip : f;
|
|
568
|
+
for (; x > 0 && E >= 0; ) {
|
|
569
|
+
const w = r.document.operations[i][E];
|
|
570
|
+
if (!w) {
|
|
571
|
+
x--, E--;
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
w.type === "NOOP" && w.skip > 0 ? (E = E - (w.skip + 1), r.skip += w.skip + 1) : (r.document.clipboard.push({ ...w }), x--, E--);
|
|
575
|
+
}
|
|
576
|
+
r.action = se(i);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
function Se(t, e, n) {
|
|
580
|
+
const { scope: i, input: o } = e;
|
|
581
|
+
return pt({
|
|
582
|
+
document: t,
|
|
583
|
+
action: e,
|
|
584
|
+
skip: n
|
|
585
|
+
}, (r) => {
|
|
586
|
+
if (r.skip > 0)
|
|
587
|
+
throw new Error(
|
|
588
|
+
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
589
|
+
);
|
|
590
|
+
if (o > 1)
|
|
591
|
+
throw new Error(
|
|
592
|
+
"Cannot redo: you can only redo one operation at a time"
|
|
593
|
+
);
|
|
594
|
+
if (o < 1)
|
|
595
|
+
throw new Error("Invalid REDO action: invalid redo input value");
|
|
596
|
+
if (r.document.clipboard.length < 1)
|
|
597
|
+
throw new Error("Cannot redo: no operations in the clipboard");
|
|
598
|
+
const p = r.document.clipboard.findLastIndex(
|
|
599
|
+
(f) => f.scope === i
|
|
600
|
+
);
|
|
601
|
+
if (p < 0)
|
|
602
|
+
throw new Error(
|
|
603
|
+
`Cannot redo: no operations in clipboard for scope "${i}"`
|
|
604
|
+
);
|
|
605
|
+
const c = r.document.clipboard.splice(p, 1)[0];
|
|
606
|
+
r.action = at({
|
|
607
|
+
type: c.type,
|
|
608
|
+
scope: c.scope,
|
|
609
|
+
input: c.input
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function Ee(t, e, n) {
|
|
614
|
+
const { scope: i } = e, o = t.operations[i];
|
|
615
|
+
let {
|
|
616
|
+
input: { start: a, end: r }
|
|
617
|
+
} = e;
|
|
618
|
+
a = a || 0, r = r || o.length;
|
|
619
|
+
const p = o.slice(a, r), c = o.slice(0, a), f = o.slice(r), x = gt(
|
|
620
|
+
t.initialState,
|
|
621
|
+
{
|
|
622
|
+
...t.operations,
|
|
623
|
+
[i]: c.concat(p)
|
|
624
|
+
},
|
|
625
|
+
n
|
|
626
|
+
), { name: E, state: w } = x, y = c.length, T = c.length ? c[c.length - 1].timestamp : f.length ? f[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
627
|
+
return gt(
|
|
628
|
+
t.initialState,
|
|
629
|
+
{
|
|
630
|
+
...t.operations,
|
|
631
|
+
[i]: [
|
|
632
|
+
...c,
|
|
633
|
+
{
|
|
634
|
+
...Et(
|
|
635
|
+
{ name: E, state: w },
|
|
636
|
+
p.length
|
|
637
|
+
),
|
|
638
|
+
timestamp: T,
|
|
639
|
+
index: y,
|
|
640
|
+
hash: St({ state: w }, "global")
|
|
641
|
+
},
|
|
642
|
+
...f.map((v, R) => ({
|
|
643
|
+
...v,
|
|
644
|
+
index: y + R + 1
|
|
645
|
+
}))
|
|
646
|
+
]
|
|
647
|
+
},
|
|
648
|
+
n
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
function $e(t, e) {
|
|
652
|
+
return {
|
|
653
|
+
...t,
|
|
654
|
+
name: e.name,
|
|
655
|
+
state: e.state ?? { global: {}, local: {} }
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
const qt = "SET_NAME", tt = "UNDO", et = "REDO", ct = "PRUNE", Ut = "LOAD_STATE", ke = "NOOP", Jt = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
|
|
659
|
+
Object.freeze(Jt);
|
|
660
|
+
var F = function(t, e, n, i) {
|
|
661
|
+
if (n === "a" && !i)
|
|
662
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
663
|
+
if (typeof e == "function" ? t !== e || !i : !e.has(t))
|
|
664
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
665
|
+
return n === "m" ? i : n === "a" ? i.call(t) : i ? i.value : e.get(t);
|
|
666
|
+
}, B, Q, X;
|
|
667
|
+
class De {
|
|
668
|
+
constructor(...e) {
|
|
669
|
+
B.set(this, /* @__PURE__ */ new Map()), Q.set(this, /* @__PURE__ */ new Map()), X.set(this, /* @__PURE__ */ new Map());
|
|
670
|
+
for (const n of e)
|
|
671
|
+
this.define(n);
|
|
672
|
+
}
|
|
673
|
+
define(e, n = !1) {
|
|
674
|
+
for (let [i, o] of Object.entries(e)) {
|
|
675
|
+
i = i.toLowerCase(), o = o.map((p) => p.toLowerCase()), F(this, X, "f").has(i) || F(this, X, "f").set(i, /* @__PURE__ */ new Set());
|
|
676
|
+
const a = F(this, X, "f").get(i);
|
|
677
|
+
let r = !0;
|
|
678
|
+
for (let p of o) {
|
|
679
|
+
const c = p.startsWith("*");
|
|
680
|
+
if (p = c ? p.slice(1) : p, a == null || a.add(p), r && F(this, Q, "f").set(i, p), r = !1, c)
|
|
681
|
+
continue;
|
|
682
|
+
const f = F(this, B, "f").get(p);
|
|
683
|
+
if (f && f != i && !n)
|
|
684
|
+
throw new Error(`"${i} -> ${p}" conflicts with "${f} -> ${p}". Pass \`force=true\` to override this definition.`);
|
|
685
|
+
F(this, B, "f").set(p, i);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return this;
|
|
689
|
+
}
|
|
690
|
+
getType(e) {
|
|
691
|
+
if (typeof e != "string")
|
|
692
|
+
return null;
|
|
693
|
+
const n = e.replace(/^.*[/\\]/, "").toLowerCase(), i = n.replace(/^.*\./, "").toLowerCase(), o = n.length < e.length;
|
|
694
|
+
return !(i.length < n.length - 1) && o ? null : F(this, B, "f").get(i) ?? null;
|
|
695
|
+
}
|
|
696
|
+
getExtension(e) {
|
|
697
|
+
var n;
|
|
698
|
+
return typeof e != "string" ? null : (e = (n = e == null ? void 0 : e.split) == null ? void 0 : n.call(e, ";")[0], (e && F(this, Q, "f").get(e.trim().toLowerCase())) ?? null);
|
|
699
|
+
}
|
|
700
|
+
getAllExtensions(e) {
|
|
701
|
+
return typeof e != "string" ? null : F(this, X, "f").get(e.toLowerCase()) ?? null;
|
|
702
|
+
}
|
|
703
|
+
_freeze() {
|
|
704
|
+
this.define = () => {
|
|
705
|
+
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
706
|
+
}, Object.freeze(this);
|
|
707
|
+
for (const e of F(this, X, "f").values())
|
|
708
|
+
Object.freeze(e);
|
|
709
|
+
return this;
|
|
710
|
+
}
|
|
711
|
+
_getTestState() {
|
|
712
|
+
return {
|
|
713
|
+
types: F(this, B, "f"),
|
|
714
|
+
extensions: F(this, Q, "f")
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
B = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap();
|
|
719
|
+
const _e = new De(Jt)._freeze();
|
|
720
|
+
function Te(t, e, n) {
|
|
721
|
+
const i = fe(t, e);
|
|
722
|
+
return ut.mkdirSync(t, { recursive: !0 }), new Promise((o, a) => {
|
|
723
|
+
try {
|
|
724
|
+
ut.writeFile(i, n, {}, (r) => {
|
|
725
|
+
r ? a(r) : o(i);
|
|
726
|
+
});
|
|
727
|
+
} catch (r) {
|
|
728
|
+
a(r);
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function Vt(t) {
|
|
733
|
+
return ut.readFileSync(t);
|
|
734
|
+
}
|
|
735
|
+
function Ne(t) {
|
|
736
|
+
return new Promise((e, n) => {
|
|
737
|
+
ue.get(t, (i) => {
|
|
738
|
+
const o = [], a = i.headers["content-type"];
|
|
739
|
+
i.on("data", (r) => {
|
|
740
|
+
o.push(r);
|
|
741
|
+
}), i.on("end", () => {
|
|
742
|
+
e({ buffer: Buffer.concat(o), mimeType: a });
|
|
743
|
+
});
|
|
744
|
+
}).on("error", (i) => {
|
|
745
|
+
n(i);
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
const ve = async (t) => Vt(t), lt = (t, e = "sha1") => me.createHash(e).update(t).digest("base64");
|
|
750
|
+
function Ie(t) {
|
|
751
|
+
const e = [], n = Object.keys(t);
|
|
752
|
+
for (const i of n) {
|
|
753
|
+
const o = t[i].sort((a, r) => a.index - r.index);
|
|
754
|
+
for (let a = 0; a < o.length; a++)
|
|
755
|
+
o[a].index !== a && e.push({
|
|
756
|
+
message: `Invalid operation index ${o[a].index} at position ${a}`,
|
|
757
|
+
details: {
|
|
758
|
+
position: a,
|
|
759
|
+
operation: o[a],
|
|
760
|
+
scope: o[a].scope
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
return e;
|
|
765
|
+
}
|
|
766
|
+
const Xt = async (t) => {
|
|
767
|
+
const e = new Dt(), { name: n, revision: i, documentType: o, created: a, lastModified: r } = t, p = {
|
|
768
|
+
name: n,
|
|
769
|
+
revision: i,
|
|
770
|
+
documentType: o,
|
|
771
|
+
created: a,
|
|
772
|
+
lastModified: r
|
|
773
|
+
};
|
|
774
|
+
return e.file("header.json", JSON.stringify(p, null, 2)), e.file(
|
|
775
|
+
"state.json",
|
|
776
|
+
JSON.stringify(t.initialState || {}, null, 2)
|
|
777
|
+
), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((f) => {
|
|
778
|
+
const { data: x, ...E } = t.attachments[f];
|
|
779
|
+
e.file(f, x, {
|
|
780
|
+
base64: !0,
|
|
781
|
+
createFolders: !0,
|
|
782
|
+
comment: JSON.stringify(E)
|
|
783
|
+
});
|
|
784
|
+
}), e;
|
|
785
|
+
}, Ae = async (t, e, n, i) => {
|
|
786
|
+
const a = await (await Xt(t)).generateAsync({
|
|
787
|
+
type: "uint8array",
|
|
788
|
+
streamFiles: !0
|
|
789
|
+
}), r = i ?? t.name, p = `.${n}.zip`;
|
|
790
|
+
return Te(
|
|
791
|
+
e,
|
|
792
|
+
r.endsWith(p) ? r : `${r}${p}`,
|
|
793
|
+
a
|
|
794
|
+
);
|
|
795
|
+
}, ln = async (t, e) => {
|
|
796
|
+
const i = await (await Xt(t)).generateAsync({ type: "blob" }), o = await e.createWritable();
|
|
797
|
+
await o.write(i), await o.close();
|
|
798
|
+
}, $t = async (t, e, n) => {
|
|
799
|
+
const i = Vt(t);
|
|
800
|
+
return Pe(i, e, n);
|
|
801
|
+
}, Pe = async (t, e, n) => {
|
|
802
|
+
const i = new Dt();
|
|
803
|
+
return await i.loadAsync(t), Me(i, e, n);
|
|
804
|
+
};
|
|
805
|
+
async function Me(t, e, n) {
|
|
806
|
+
const i = t.file("state.json");
|
|
807
|
+
if (!i)
|
|
808
|
+
throw new Error("Initial state not found");
|
|
809
|
+
const o = await i.async("string"), a = JSON.parse(o), r = t.file("header.json");
|
|
810
|
+
let p;
|
|
811
|
+
r && (p = JSON.parse(await r.async("string")));
|
|
812
|
+
const c = t.file("operations.json");
|
|
813
|
+
if (!c)
|
|
814
|
+
throw new Error("Operations history not found");
|
|
815
|
+
const f = JSON.parse(
|
|
816
|
+
await c.async("string")
|
|
817
|
+
), x = Ie(f);
|
|
818
|
+
if (x.length) {
|
|
819
|
+
const w = x.map((y) => y.message);
|
|
820
|
+
throw new Error(w.join(`
|
|
821
|
+
`));
|
|
822
|
+
}
|
|
823
|
+
let E = te(
|
|
824
|
+
a,
|
|
825
|
+
f,
|
|
826
|
+
e,
|
|
827
|
+
void 0,
|
|
828
|
+
p,
|
|
829
|
+
{},
|
|
830
|
+
n
|
|
831
|
+
);
|
|
832
|
+
return p && (E = {
|
|
833
|
+
...E,
|
|
834
|
+
...p
|
|
835
|
+
}), E;
|
|
836
|
+
}
|
|
837
|
+
function Ht(t) {
|
|
838
|
+
const e = t.replace(/^.*\./, "") || void 0, n = t.replace(/^.*[/\\]/, "") || void 0;
|
|
839
|
+
return { extension: e, fileName: n };
|
|
840
|
+
}
|
|
841
|
+
async function mn(t) {
|
|
842
|
+
const { buffer: e, mimeType: n = "application/octet-stream" } = await Ne(t), i = Ht(t), o = e.toString("base64");
|
|
843
|
+
return {
|
|
844
|
+
data: o,
|
|
845
|
+
hash: lt(o),
|
|
846
|
+
mimeType: n,
|
|
847
|
+
...i
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
async function un(t) {
|
|
851
|
+
const e = await ve(t), n = _e.getType(t) || "application/octet-stream", i = Ht(t), o = e.toString("base64");
|
|
852
|
+
return { data: o, hash: lt(o), mimeType: n, ...i };
|
|
853
|
+
}
|
|
854
|
+
var Bt = /* @__PURE__ */ ((t) => (t.UNEXPECTED_INDEX = "UNEXPECTED_INDEX", t))(Bt || {}), Kt = /* @__PURE__ */ ((t) => (t.DUPLICATED_INDEX = "DUPLICATED_INDEX", t.MISSING_INDEX = "MISSING_INDEX", t))(Kt || {});
|
|
855
|
+
function Ot(t) {
|
|
856
|
+
const e = [];
|
|
857
|
+
let n = -1;
|
|
858
|
+
for (const i of t) {
|
|
859
|
+
const o = i.index - i.skip;
|
|
860
|
+
o !== n + 1 && e.push({
|
|
861
|
+
operation: {
|
|
862
|
+
index: i.index,
|
|
863
|
+
skip: i.skip
|
|
864
|
+
},
|
|
865
|
+
issue: "UNEXPECTED_INDEX",
|
|
866
|
+
category: o > n + 1 ? "MISSING_INDEX" : "DUPLICATED_INDEX",
|
|
867
|
+
message: `Expected index ${n + 1} with skip 0 or equivalent, got index ${i.index} with skip ${i.skip}`
|
|
868
|
+
}), n = i.index;
|
|
869
|
+
}
|
|
870
|
+
return e;
|
|
871
|
+
}
|
|
872
|
+
function J(t) {
|
|
873
|
+
var i, o, a;
|
|
874
|
+
const e = [];
|
|
875
|
+
let n = t.length - 1;
|
|
876
|
+
for (; n > -1; ) {
|
|
877
|
+
e.unshift(t[n]);
|
|
878
|
+
const r = (((i = t[n]) == null ? void 0 : i.index) || 0) - (((o = t[n]) == null ? void 0 : o.skip) || 0) - 1;
|
|
879
|
+
let p = n - 1;
|
|
880
|
+
for (; p > -1 && (((a = t[p]) == null ? void 0 : a.index) || 0) > r; )
|
|
881
|
+
p--;
|
|
882
|
+
n = p;
|
|
883
|
+
}
|
|
884
|
+
return e;
|
|
885
|
+
}
|
|
886
|
+
function ze(t) {
|
|
887
|
+
const e = [...t], n = e[e.length - 1];
|
|
888
|
+
return n && (n.type === "NOOP" ? e.push({
|
|
889
|
+
...n,
|
|
890
|
+
index: n.index,
|
|
891
|
+
type: "NOOP",
|
|
892
|
+
skip: Zt(t)
|
|
893
|
+
}) : e.push({
|
|
894
|
+
type: "NOOP",
|
|
895
|
+
index: n.index + 1,
|
|
896
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
897
|
+
input: {},
|
|
898
|
+
skip: 1,
|
|
899
|
+
scope: n.scope,
|
|
900
|
+
hash: n.hash
|
|
901
|
+
})), e;
|
|
902
|
+
}
|
|
903
|
+
function V(t) {
|
|
904
|
+
return t.slice().sort((e, n) => e.skip - n.skip).sort((e, n) => e.index - n.index);
|
|
905
|
+
}
|
|
906
|
+
const Ce = (t, e, n) => [...e, ...n].sort(
|
|
907
|
+
(i, o) => new Date(i.timestamp).getTime() - new Date(o.timestamp).getTime()
|
|
908
|
+
).map((i, o) => ({
|
|
909
|
+
...i,
|
|
910
|
+
index: t.index + o,
|
|
911
|
+
skip: o === 0 ? t.skip : 0
|
|
912
|
+
})), Fe = (t, e, n) => [...e, ...n].sort(
|
|
913
|
+
(i, o) => new Date(i.timestamp).getTime() - new Date(o.timestamp).getTime()
|
|
914
|
+
).sort((i, o) => i.index - o.index).map((i, o) => ({
|
|
915
|
+
...i,
|
|
916
|
+
index: t.index + o,
|
|
917
|
+
skip: o === 0 ? t.skip : 0
|
|
918
|
+
}));
|
|
919
|
+
function jt(t, e) {
|
|
920
|
+
return K(t) === K(e);
|
|
921
|
+
}
|
|
922
|
+
function Le(t, e) {
|
|
923
|
+
const n = J(V(t.slice())), i = J(V(e.slice()));
|
|
924
|
+
if (n.length < 1)
|
|
925
|
+
return [i, []];
|
|
926
|
+
const o = [];
|
|
927
|
+
let a = !1;
|
|
928
|
+
for (; i.length > 0; ) {
|
|
929
|
+
const r = i[0];
|
|
930
|
+
let p = n.shift();
|
|
931
|
+
for (; p && Wt(p, r); )
|
|
932
|
+
o.push(p), p = n.shift();
|
|
933
|
+
if (p ? a || (jt(p, r) ? (i.shift(), o.push(p)) : (n.unshift(p), a = !0)) : a = !0, a) {
|
|
934
|
+
let c = i.shift();
|
|
935
|
+
for (; c; )
|
|
936
|
+
o.push(c), c = i.shift();
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (!a) {
|
|
940
|
+
let r = n.shift();
|
|
941
|
+
for (; r; )
|
|
942
|
+
o.push(r), r = n.shift();
|
|
943
|
+
}
|
|
944
|
+
return [J(o), n];
|
|
945
|
+
}
|
|
946
|
+
function Wt(t, e) {
|
|
947
|
+
return t.index < e.index || t.index === e.index && t.skip < e.skip;
|
|
948
|
+
}
|
|
949
|
+
function Gt(t, e) {
|
|
950
|
+
const n = [], i = [], o = [], a = Math.max(
|
|
951
|
+
t.length,
|
|
952
|
+
e.length
|
|
953
|
+
);
|
|
954
|
+
let r = !1;
|
|
955
|
+
for (let p = 0; p < a; p++) {
|
|
956
|
+
const c = t[p], f = e[p];
|
|
957
|
+
c && f ? !r && jt(c, f) ? n.push(c) : (r = !0, i.push(c), o.push(f)) : c ? i.push(c) : f && o.push(f);
|
|
958
|
+
}
|
|
959
|
+
return [n, i, o];
|
|
960
|
+
}
|
|
961
|
+
function Re(t, e, n) {
|
|
962
|
+
const [i, o, a] = Gt(
|
|
963
|
+
J(t),
|
|
964
|
+
J(e)
|
|
965
|
+
), r = mt(i), p = 1 + Math.max(
|
|
966
|
+
r,
|
|
967
|
+
mt(o),
|
|
968
|
+
mt(a)
|
|
969
|
+
), c = n(
|
|
970
|
+
{
|
|
971
|
+
index: p,
|
|
972
|
+
skip: p - (r + 1)
|
|
973
|
+
},
|
|
974
|
+
o,
|
|
975
|
+
a
|
|
976
|
+
);
|
|
977
|
+
return i.concat(c);
|
|
978
|
+
}
|
|
979
|
+
function mt(t) {
|
|
980
|
+
const e = t[t.length - 1];
|
|
981
|
+
return e ? e.index : -1;
|
|
982
|
+
}
|
|
983
|
+
function Zt(t) {
|
|
984
|
+
var i, o, a;
|
|
985
|
+
if (t.length < 1)
|
|
986
|
+
return -1;
|
|
987
|
+
const e = J(t);
|
|
988
|
+
let n = (((i = e[e.length - 1]) == null ? void 0 : i.skip) || 0) + 1;
|
|
989
|
+
return e.length > 1 && (n += ((o = e[e.length - 2]) == null ? void 0 : o.skip) || 0), (((a = e[e.length - 1]) == null ? void 0 : a.index) || -1) < n ? -1 : n;
|
|
990
|
+
}
|
|
991
|
+
const qe = (t) => Ot(
|
|
992
|
+
J(V(t))
|
|
993
|
+
), Ue = (t) => t.reduce((n, i) => {
|
|
994
|
+
var o;
|
|
995
|
+
return n[i.scope] || (n[i.scope] = []), (o = n[i.scope]) == null || o.push(i), n;
|
|
996
|
+
}, {}), Je = (t, e) => {
|
|
997
|
+
var c;
|
|
998
|
+
const n = {
|
|
999
|
+
integrityIssues: [],
|
|
1000
|
+
validOperations: [],
|
|
1001
|
+
invalidOperations: [],
|
|
1002
|
+
duplicatedOperations: []
|
|
1003
|
+
}, i = V(t), o = V(e), a = Ot([
|
|
1004
|
+
...i,
|
|
1005
|
+
...o
|
|
1006
|
+
]), p = (c = [...a.filter(
|
|
1007
|
+
(f) => f.category === "MISSING_INDEX"
|
|
1008
|
+
/* MISSING_INDEX */
|
|
1009
|
+
)].sort((f, x) => x.operation.index - f.operation.index).pop()) == null ? void 0 : c.operation;
|
|
1010
|
+
for (const f of o) {
|
|
1011
|
+
if (p && f.index >= p.index) {
|
|
1012
|
+
n.invalidOperations.push(f);
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
if (a.some((E) => E.operation.index === f.index && E.operation.skip === f.skip && E.category === "DUPLICATED_INDEX")) {
|
|
1016
|
+
n.duplicatedOperations.push(f);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
n.validOperations.push(f);
|
|
1020
|
+
}
|
|
1021
|
+
return n.integrityIssues.push(...a), n;
|
|
1022
|
+
};
|
|
1023
|
+
function Ve(t, e) {
|
|
1024
|
+
return t.filter((n) => !e.some((i) => n.type === "NOOP" && n.skip === 0 && n.index === i.index || n.index === i.index && n.skip === i.skip && n.scope === i.scope && n.hash === i.hash && n.type === i.type));
|
|
1025
|
+
}
|
|
1026
|
+
function Qt(t, e) {
|
|
1027
|
+
const [n] = V(t).slice(-1), i = (n == null ? void 0 : n.index) ?? -1, o = i + 1, a = {
|
|
1028
|
+
...e,
|
|
1029
|
+
index: e.index ?? o
|
|
1030
|
+
};
|
|
1031
|
+
if (a.index < i)
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
`The skip header operation index must be greater than or equal to ${i}`
|
|
1034
|
+
);
|
|
1035
|
+
return (J(
|
|
1036
|
+
V([...t, a])
|
|
1037
|
+
) || []).slice(0, -1);
|
|
1038
|
+
}
|
|
1039
|
+
function dt(t) {
|
|
1040
|
+
return {
|
|
1041
|
+
...Object.entries(t).reduce(
|
|
1042
|
+
(n, i) => {
|
|
1043
|
+
const [o, a] = i;
|
|
1044
|
+
return {
|
|
1045
|
+
...n,
|
|
1046
|
+
[o]: J(V(a))
|
|
1047
|
+
};
|
|
1048
|
+
},
|
|
1049
|
+
{}
|
|
1050
|
+
)
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1054
|
+
__proto__: null,
|
|
1055
|
+
IntegrityIssueSubType: Kt,
|
|
1056
|
+
IntegrityIssueType: Bt,
|
|
1057
|
+
addUndo: ze,
|
|
1058
|
+
attachBranch: Le,
|
|
1059
|
+
checkCleanedOperationsIntegrity: Ot,
|
|
1060
|
+
checkOperationsIntegrity: qe,
|
|
1061
|
+
garbageCollect: J,
|
|
1062
|
+
grabageCollectDocumentOperations: dt,
|
|
1063
|
+
groupOperationsByScope: Ue,
|
|
1064
|
+
merge: Re,
|
|
1065
|
+
nextSkipNumber: Zt,
|
|
1066
|
+
operationsAreEqual: jt,
|
|
1067
|
+
precedes: Wt,
|
|
1068
|
+
prepareOperations: Je,
|
|
1069
|
+
removeExistingOperations: Ve,
|
|
1070
|
+
reshuffleByTimestamp: Ce,
|
|
1071
|
+
reshuffleByTimestampAndIndex: Fe,
|
|
1072
|
+
skipHeaderOperations: Qt,
|
|
1073
|
+
sortOperations: V,
|
|
1074
|
+
split: Gt
|
|
1075
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1076
|
+
function Xe(t, e) {
|
|
1077
|
+
let n;
|
|
1078
|
+
return "index" in e ? n = { ...e } : n = t.operations[e.scope].at(-1), ((n == null ? void 0 : n.index) ?? -1) + 1;
|
|
1079
|
+
}
|
|
1080
|
+
function He(t, e) {
|
|
1081
|
+
return {
|
|
1082
|
+
...t,
|
|
1083
|
+
revision: {
|
|
1084
|
+
...t.revision,
|
|
1085
|
+
[e.scope]: Xe(t, e)
|
|
1086
|
+
},
|
|
1087
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function Be(t, e, n = 0) {
|
|
1091
|
+
if ([tt, et, ct].includes(e.type))
|
|
1092
|
+
return t;
|
|
1093
|
+
const { scope: i } = e, o = t.operations[i].slice(
|
|
1094
|
+
0,
|
|
1095
|
+
t.revision[i]
|
|
1096
|
+
), a = [...o].pop();
|
|
1097
|
+
let r = ((a == null ? void 0 : a.index) ?? -1) + 1;
|
|
1098
|
+
if ("index" in e) {
|
|
1099
|
+
if (e.index - n > r)
|
|
1100
|
+
throw new Error(
|
|
1101
|
+
`Missing operations: expected ${r} with skip 0 or equivalent, got index ${e.index} with skip ${n}`
|
|
1102
|
+
);
|
|
1103
|
+
r = e.index;
|
|
1104
|
+
}
|
|
1105
|
+
return o.push({
|
|
1106
|
+
...e,
|
|
1107
|
+
index: r,
|
|
1108
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1109
|
+
hash: "",
|
|
1110
|
+
scope: i,
|
|
1111
|
+
skip: n,
|
|
1112
|
+
error: void 0
|
|
1113
|
+
}), {
|
|
1114
|
+
...t,
|
|
1115
|
+
operations: { ...t.operations, [i]: o }
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function Ke(t, e, n = 0) {
|
|
1119
|
+
let i = Be(t, e, n);
|
|
1120
|
+
return i = He(i, e), i;
|
|
1121
|
+
}
|
|
1122
|
+
function We(t, e, n) {
|
|
1123
|
+
switch (Pt().parse(e), e.type) {
|
|
1124
|
+
case qt:
|
|
1125
|
+
return Oe(t, e.input);
|
|
1126
|
+
case ct:
|
|
1127
|
+
return Ee(t, e, n);
|
|
1128
|
+
case Ut:
|
|
1129
|
+
return $e(t, e.input.state);
|
|
1130
|
+
default:
|
|
1131
|
+
return t;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
function dn(t, e, n) {
|
|
1135
|
+
switch (e.type) {
|
|
1136
|
+
case tt:
|
|
1137
|
+
return je(t, e, n);
|
|
1138
|
+
case et:
|
|
1139
|
+
return Se(t, e, n);
|
|
1140
|
+
default:
|
|
1141
|
+
return { document: t, action: e, skip: n };
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function Ge(t, e, n, i) {
|
|
1145
|
+
const o = e.scope, a = t.operations[o].at(-1);
|
|
1146
|
+
if (!a)
|
|
1147
|
+
return t;
|
|
1148
|
+
const r = dt(
|
|
1149
|
+
{
|
|
1150
|
+
...t.operations,
|
|
1151
|
+
[o]: Qt(
|
|
1152
|
+
t.operations[o],
|
|
1153
|
+
a
|
|
1154
|
+
)
|
|
1155
|
+
}
|
|
1156
|
+
), { state: p } = gt(
|
|
1157
|
+
t.initialState,
|
|
1158
|
+
r,
|
|
1159
|
+
n,
|
|
1160
|
+
void 0,
|
|
1161
|
+
void 0,
|
|
1162
|
+
void 0
|
|
1163
|
+
);
|
|
1164
|
+
return {
|
|
1165
|
+
...t,
|
|
1166
|
+
state: p,
|
|
1167
|
+
operations: dt({
|
|
1168
|
+
...t.operations
|
|
1169
|
+
})
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
function Yt(t, e, n, i, o = {}) {
|
|
1173
|
+
const { skip: a, ignoreSkipOperations: r = !1, reuseHash: p = !1 } = o, c = { ...e }, f = a || 0;
|
|
1174
|
+
let x = { ...t };
|
|
1175
|
+
const E = !r && (f > 0 || "index" in c && c.skip > 0);
|
|
1176
|
+
return kt(c) && (x = We(x, c, n)), x = Ke(x, c, f), E && (x = Ge(
|
|
1177
|
+
x,
|
|
1178
|
+
c,
|
|
1179
|
+
n
|
|
1180
|
+
)), x = pt(x, (w) => {
|
|
1181
|
+
try {
|
|
1182
|
+
const y = n(
|
|
1183
|
+
w.state,
|
|
1184
|
+
c,
|
|
1185
|
+
i
|
|
1186
|
+
);
|
|
1187
|
+
if (y)
|
|
1188
|
+
return at({
|
|
1189
|
+
...x,
|
|
1190
|
+
// clipboard: [...clipboardValue],
|
|
1191
|
+
state: y
|
|
1192
|
+
});
|
|
1193
|
+
} catch (y) {
|
|
1194
|
+
const T = x.operations[c.scope].length - 1;
|
|
1195
|
+
w.operations[c.scope][T].error = y.message, w.operations[c.scope][T].skip = 0, E && (w.state = at({ ...t.state }), w.operations = at({
|
|
1196
|
+
...t.operations,
|
|
1197
|
+
[c.scope]: [
|
|
1198
|
+
...t.operations[c.scope],
|
|
1199
|
+
{
|
|
1200
|
+
...w.operations[c.scope][T]
|
|
1201
|
+
}
|
|
1202
|
+
]
|
|
1203
|
+
}));
|
|
1204
|
+
}
|
|
1205
|
+
}), pt(x, (w) => {
|
|
1206
|
+
if ([tt, et, ct].includes(c.type))
|
|
1207
|
+
return w;
|
|
1208
|
+
const y = c.scope || "global", T = p && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : St(w, y);
|
|
1209
|
+
w.operations[y][w.operations[y].length - 1].hash = T, !kt(c) && c.attachments && c.attachments.forEach((v) => {
|
|
1210
|
+
const { hash: R, ...l } = v;
|
|
1211
|
+
w.attachments[R] = {
|
|
1212
|
+
...l
|
|
1213
|
+
};
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
function gn(t) {
|
|
1218
|
+
return t.type === ke && t.skip !== void 0 && t.skip > 0 && t.hash !== void 0;
|
|
1219
|
+
}
|
|
1220
|
+
function hn(t) {
|
|
1221
|
+
return [tt, et].includes(t.type);
|
|
1222
|
+
}
|
|
1223
|
+
function kt(t) {
|
|
1224
|
+
return [qt, tt, et, ct, Ut].includes(t.type);
|
|
1225
|
+
}
|
|
1226
|
+
function W(t, e, n, i, o = "global") {
|
|
1227
|
+
if (!t)
|
|
1228
|
+
throw new Error("Empty action type");
|
|
1229
|
+
if (typeof t != "string")
|
|
1230
|
+
throw new Error(`Invalid action type: ${JSON.stringify(t)}`);
|
|
1231
|
+
const a = { type: t, input: e, scope: o };
|
|
1232
|
+
n && (a.attachments = n);
|
|
1233
|
+
try {
|
|
1234
|
+
i == null || i().parse(a.input);
|
|
1235
|
+
} catch (r) {
|
|
1236
|
+
throw new Error(`Invalid action input: ${r}`);
|
|
1237
|
+
}
|
|
1238
|
+
return a;
|
|
1239
|
+
}
|
|
1240
|
+
function Ze(t, e = Yt) {
|
|
1241
|
+
return (n, i, o, a) => e(n, i, t, o, a);
|
|
1242
|
+
}
|
|
1243
|
+
const Qe = (t, e) => ({
|
|
1244
|
+
name: "",
|
|
1245
|
+
documentType: "",
|
|
1246
|
+
revision: {
|
|
1247
|
+
global: 0,
|
|
1248
|
+
local: 0
|
|
1249
|
+
},
|
|
1250
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1251
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1252
|
+
attachments: {},
|
|
1253
|
+
...t,
|
|
1254
|
+
state: (e == null ? void 0 : e(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
|
|
1255
|
+
}), Ye = (t, e) => {
|
|
1256
|
+
const n = Qe(
|
|
1257
|
+
t,
|
|
1258
|
+
e
|
|
1259
|
+
);
|
|
1260
|
+
return {
|
|
1261
|
+
...n,
|
|
1262
|
+
initialState: n,
|
|
1263
|
+
operations: { global: [], local: [] },
|
|
1264
|
+
clipboard: []
|
|
1265
|
+
};
|
|
1266
|
+
}, St = (t, e = "global") => lt(K(t.state[e] || "")), xn = (t, e = 1e3) => {
|
|
1267
|
+
const n = Math.random() * e;
|
|
1268
|
+
return lt(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${n}`);
|
|
1269
|
+
};
|
|
1270
|
+
function rt(t) {
|
|
1271
|
+
return ce(le(t, !0));
|
|
1272
|
+
}
|
|
1273
|
+
function yn(t, e) {
|
|
1274
|
+
const n = [...t];
|
|
1275
|
+
let i = e || 0, o = n.length > 0 ? n[n.length - 1].index : 0;
|
|
1276
|
+
const a = [];
|
|
1277
|
+
for (const r of n.reverse()) {
|
|
1278
|
+
if (i > 0) {
|
|
1279
|
+
const f = o - r.index;
|
|
1280
|
+
i -= f;
|
|
1281
|
+
}
|
|
1282
|
+
if (i < 0)
|
|
1283
|
+
throw new Error("Invalid operation index, missing operations");
|
|
1284
|
+
const p = {
|
|
1285
|
+
ignore: i > 0,
|
|
1286
|
+
operation: r
|
|
1287
|
+
}, c = r.skip > 0 ? r.skip + 1 : 0;
|
|
1288
|
+
if (c > 0 && c > i) {
|
|
1289
|
+
const f = c - i;
|
|
1290
|
+
i = i + f;
|
|
1291
|
+
}
|
|
1292
|
+
o = r.index, a.push(p);
|
|
1293
|
+
}
|
|
1294
|
+
return a.reverse();
|
|
1295
|
+
}
|
|
1296
|
+
function bn(t, e, n) {
|
|
1297
|
+
const i = t.slice().sort((p, c) => p.skip - c.skip).sort((p, c) => p.index - c.index);
|
|
1298
|
+
let o = n, a = 0, r = e;
|
|
1299
|
+
for (const p of i.reverse()) {
|
|
1300
|
+
const c = r - p.index;
|
|
1301
|
+
if (o = o - c, o > -1)
|
|
1302
|
+
a++, r = p.index;
|
|
1303
|
+
else
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
return a;
|
|
1307
|
+
}
|
|
1308
|
+
function wn(t) {
|
|
1309
|
+
return Object.values(t).flatMap((e) => e).sort(
|
|
1310
|
+
(e, n) => new Date(e.timestamp).getTime() - new Date(n.timestamp).getTime()
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
function On(t) {
|
|
1314
|
+
return Object.values(t).flatMap((e) => e).sort(
|
|
1315
|
+
(e, n) => new Date(e.operation.timestamp).getTime() - new Date(n.operation.timestamp).getTime()
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1318
|
+
function gt(t, e, n, i, o, a = Yt, r = {}, p) {
|
|
1319
|
+
const c = Ze(n, a);
|
|
1320
|
+
return te(
|
|
1321
|
+
t,
|
|
1322
|
+
e,
|
|
1323
|
+
c,
|
|
1324
|
+
i,
|
|
1325
|
+
o,
|
|
1326
|
+
r,
|
|
1327
|
+
p
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
function te(t, e, n, i, o, a = {}, r) {
|
|
1331
|
+
const p = (r == null ? void 0 : r.checkHashes) ?? !0, c = Ye(t), f = Object.values(e).flat(), x = f.reduce((y, T) => n(y, T, i, {
|
|
1332
|
+
skip: T.skip,
|
|
1333
|
+
ignoreSkipOperations: !0,
|
|
1334
|
+
reuseHash: !p
|
|
1335
|
+
}), c);
|
|
1336
|
+
if (!p)
|
|
1337
|
+
for (const y of Object.keys(x.state))
|
|
1338
|
+
for (let T = f.length - 1; T >= 0; T--) {
|
|
1339
|
+
const v = f[T];
|
|
1340
|
+
if (v.scope === y) {
|
|
1341
|
+
if (v.hash !== St(x, y))
|
|
1342
|
+
throw new Error(`Hash mismatch for scope ${y}`);
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
const E = Object.keys(
|
|
1347
|
+
x.operations
|
|
1348
|
+
).reduce(
|
|
1349
|
+
(y, T) => {
|
|
1350
|
+
const v = T;
|
|
1351
|
+
return {
|
|
1352
|
+
...y,
|
|
1353
|
+
[v]: [
|
|
1354
|
+
...x.operations[v].map((R, l) => {
|
|
1355
|
+
var m;
|
|
1356
|
+
return {
|
|
1357
|
+
...R,
|
|
1358
|
+
timestamp: ((m = e[v][l]) == null ? void 0 : m.timestamp) ?? R.timestamp
|
|
1359
|
+
};
|
|
1360
|
+
})
|
|
1361
|
+
]
|
|
1362
|
+
};
|
|
1363
|
+
},
|
|
1364
|
+
{ global: [], local: [] }
|
|
1365
|
+
), w = Object.values(E).reduce((y, T) => {
|
|
1366
|
+
const v = T[T.length - 1];
|
|
1367
|
+
return (v == null ? void 0 : v.timestamp) > y && (y = v.timestamp), y;
|
|
1368
|
+
}, t.lastModified);
|
|
1369
|
+
return { ...x, operations: E, lastModified: w };
|
|
1370
|
+
}
|
|
1371
|
+
function jn(t, e) {
|
|
1372
|
+
return K(t) === K(e);
|
|
1373
|
+
}
|
|
1374
|
+
const ee = (t) => W(
|
|
1375
|
+
"SET_NAME",
|
|
1376
|
+
t,
|
|
1377
|
+
void 0,
|
|
1378
|
+
bt,
|
|
1379
|
+
void 0
|
|
1380
|
+
), ne = (t = 1, e = "global") => W(
|
|
1381
|
+
"UNDO",
|
|
1382
|
+
t,
|
|
1383
|
+
void 0,
|
|
1384
|
+
wt,
|
|
1385
|
+
e
|
|
1386
|
+
), ie = (t = 1, e = "global") => W(
|
|
1387
|
+
"REDO",
|
|
1388
|
+
t,
|
|
1389
|
+
void 0,
|
|
1390
|
+
yt,
|
|
1391
|
+
e
|
|
1392
|
+
), oe = (t, e, n = "global") => W(
|
|
1393
|
+
"PRUNE",
|
|
1394
|
+
{ start: t, end: e },
|
|
1395
|
+
void 0,
|
|
1396
|
+
xt,
|
|
1397
|
+
n
|
|
1398
|
+
), Et = (t, e) => W(
|
|
1399
|
+
"LOAD_STATE",
|
|
1400
|
+
{ state: t, operations: e },
|
|
1401
|
+
void 0,
|
|
1402
|
+
ht
|
|
1403
|
+
), se = (t = "global") => W("NOOP", {}, void 0, void 0, t), Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1404
|
+
__proto__: null,
|
|
1405
|
+
loadState: Et,
|
|
1406
|
+
noop: se,
|
|
1407
|
+
prune: oe,
|
|
1408
|
+
redo: ie,
|
|
1409
|
+
setName: ee,
|
|
1410
|
+
undo: ne
|
|
1411
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1412
|
+
class En {
|
|
1413
|
+
/**
|
|
1414
|
+
* Constructs a BaseDocument instance with an initial state.
|
|
1415
|
+
* @param reducer - The reducer function that updates the state.
|
|
1416
|
+
* @param document - The initial state of the document.
|
|
1417
|
+
*/
|
|
1418
|
+
constructor(e, n, i) {
|
|
1419
|
+
st(this, "_document");
|
|
1420
|
+
st(this, "_reducer");
|
|
1421
|
+
st(this, "_signalDispatch");
|
|
1422
|
+
this._reducer = e, this._document = n, this._signalDispatch = i;
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Dispatches an action to update the state of the document.
|
|
1426
|
+
* @param action - The action to dispatch.
|
|
1427
|
+
* @returns The Document instance.
|
|
1428
|
+
*/
|
|
1429
|
+
dispatch(e, n) {
|
|
1430
|
+
return this._document = this._reducer(
|
|
1431
|
+
this._document,
|
|
1432
|
+
e,
|
|
1433
|
+
this._signalDispatch,
|
|
1434
|
+
n
|
|
1435
|
+
), this;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Saves the state of the document to a file.
|
|
1439
|
+
* @param path - The file path where the state should be saved.
|
|
1440
|
+
* @param extension - The file extension to use when saving the state.
|
|
1441
|
+
* @returns The file path where the state was saved.
|
|
1442
|
+
*/
|
|
1443
|
+
saveToFile(e, n, i) {
|
|
1444
|
+
return Ae(this._document, e, n, i);
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Loads the state of the document from a file.
|
|
1448
|
+
* @param path - The file path where the state is stored.
|
|
1449
|
+
*/
|
|
1450
|
+
async loadFromFile(e) {
|
|
1451
|
+
this._document = await $t(e, this._reducer);
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Loads the state of the document from a file and returns it.
|
|
1455
|
+
* @param path - The file path where the state is stored.
|
|
1456
|
+
* @param reducer - The reducer function that updates the state.
|
|
1457
|
+
* @returns The state of the document.
|
|
1458
|
+
*/
|
|
1459
|
+
static async stateFromFile(e, n) {
|
|
1460
|
+
return await $t(e, n);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Gets the current state of the document.
|
|
1464
|
+
*/
|
|
1465
|
+
get state() {
|
|
1466
|
+
return rt(this._document.state);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Gets the list of operations performed on the document.
|
|
1470
|
+
*/
|
|
1471
|
+
get operations() {
|
|
1472
|
+
return rt(this._document.operations);
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Gets the name of the document.
|
|
1476
|
+
*/
|
|
1477
|
+
get name() {
|
|
1478
|
+
return this._document.name;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Gets the type of document.
|
|
1482
|
+
*/
|
|
1483
|
+
get documentType() {
|
|
1484
|
+
return this._document.documentType;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Gets the timestamp of the date the document was created.
|
|
1488
|
+
*/
|
|
1489
|
+
get created() {
|
|
1490
|
+
return this._document.created;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Gets the timestamp of the date the document was last modified.
|
|
1494
|
+
*/
|
|
1495
|
+
get lastModified() {
|
|
1496
|
+
return this._document.lastModified;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Gets the global revision number of the document.
|
|
1500
|
+
*/
|
|
1501
|
+
get revision() {
|
|
1502
|
+
return this._document.revision.global;
|
|
1503
|
+
}
|
|
1504
|
+
getRevision(e) {
|
|
1505
|
+
return this._document.revision[e];
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Gets the initial state of the document.
|
|
1509
|
+
*/
|
|
1510
|
+
get initialState() {
|
|
1511
|
+
return rt(this._document.initialState);
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Returns the current document as an object
|
|
1515
|
+
*/
|
|
1516
|
+
toDocument() {
|
|
1517
|
+
return rt(this._document);
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Gets the attachment associated with the given key.
|
|
1521
|
+
* @param attachment - The key of the attachment to retrieve.
|
|
1522
|
+
*/
|
|
1523
|
+
getAttachment(e) {
|
|
1524
|
+
return this._document.attachments[e];
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Sets the name of the document.
|
|
1528
|
+
* @param name - The new name of the document.
|
|
1529
|
+
*/
|
|
1530
|
+
setName(e) {
|
|
1531
|
+
return this.dispatch(ee(e)), this;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Reverts a number of actions from the document.
|
|
1535
|
+
* @param count - The number of actions to revert.
|
|
1536
|
+
*/
|
|
1537
|
+
undo(e) {
|
|
1538
|
+
return this.dispatch(ne(e)), this;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Reapplies a number of actions to the document.
|
|
1542
|
+
* @param count - The number of actions to reapply.
|
|
1543
|
+
*/
|
|
1544
|
+
redo(e) {
|
|
1545
|
+
return this.dispatch(ie(e)), this;
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Removes a range of operations from the document.
|
|
1549
|
+
* @param start - The starting index of the range to remove.
|
|
1550
|
+
* @param end - The ending index of the range to remove.
|
|
1551
|
+
*/
|
|
1552
|
+
prune(e, n) {
|
|
1553
|
+
return this.dispatch(oe(e, n)), this;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Loads a document state and a set of operations.
|
|
1557
|
+
* @param state - The state to load.
|
|
1558
|
+
* @param operations - The operations to apply to the document.
|
|
1559
|
+
*/
|
|
1560
|
+
loadState(e, n) {
|
|
1561
|
+
return this.dispatch(Et(e, n)), this;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function $n(t, e) {
|
|
1565
|
+
e.forEach((n) => {
|
|
1566
|
+
Object.getOwnPropertyNames(n.prototype).forEach((i) => {
|
|
1567
|
+
Object.defineProperty(
|
|
1568
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1569
|
+
t.prototype,
|
|
1570
|
+
i,
|
|
1571
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
1572
|
+
Object.getOwnPropertyDescriptor(n.prototype, i) || /* @__PURE__ */ Object.create(null)
|
|
1573
|
+
);
|
|
1574
|
+
});
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
export {
|
|
1578
|
+
wn as A,
|
|
1579
|
+
En as B,
|
|
1580
|
+
Ie as C,
|
|
1581
|
+
Yt as D,
|
|
1582
|
+
dn as E,
|
|
1583
|
+
cn as F,
|
|
1584
|
+
Qe as a,
|
|
1585
|
+
Ye as b,
|
|
1586
|
+
Ze as c,
|
|
1587
|
+
ln as d,
|
|
1588
|
+
Pe as e,
|
|
1589
|
+
W as f,
|
|
1590
|
+
$n as g,
|
|
1591
|
+
Sn as h,
|
|
1592
|
+
kt as i,
|
|
1593
|
+
bn as j,
|
|
1594
|
+
Xt as k,
|
|
1595
|
+
$t as l,
|
|
1596
|
+
fn as m,
|
|
1597
|
+
un as n,
|
|
1598
|
+
mn as o,
|
|
1599
|
+
St as p,
|
|
1600
|
+
xn as q,
|
|
1601
|
+
gn as r,
|
|
1602
|
+
Ae as s,
|
|
1603
|
+
jn as t,
|
|
1604
|
+
hn as u,
|
|
1605
|
+
yn as v,
|
|
1606
|
+
rt as w,
|
|
1607
|
+
te as x,
|
|
1608
|
+
gt as y,
|
|
1609
|
+
On as z
|
|
1610
|
+
};
|