document-model 1.0.40 → 1.0.42
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/document-model.cjs +1 -1
- package/dist/browser/document-model.js +14 -15
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +9 -10
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +6 -7
- package/dist/browser/internal/{index-4Z_H8F_J.js → index-CDcO7NCS.js} +3 -4
- package/dist/{node/internal/index-DyCS1h0M.js → browser/internal/index-CfgX2mMt.js} +1 -1
- package/dist/browser/internal/{index-6u2yDIEF.js → index-DhzefrNj.js} +1 -1
- package/dist/{node/internal/index-Dl5T5qdc.js → browser/internal/index-EdTViyyq.js} +1 -1
- package/dist/browser/internal/object-BkewFVld.js +25 -0
- package/dist/browser/internal/object-CrDRbO7a.js +2492 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +15 -16
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +9 -10
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +7 -8
- package/dist/node/internal/{index-BpBnSlTZ.js → index-BWW7KbVk.js} +2 -2
- package/dist/node/internal/{index-A6Rqm2SZ.js → index-Cz8HaIxu.js} +3 -4
- package/dist/{browser/internal/index-DQeD1Q-a.js → node/internal/index-D_LMFQg7.js} +1 -1
- package/dist/{browser/internal/index-QJX_Fa1V.js → node/internal/index-fctxJxHD.js} +1 -1
- package/dist/node/internal/object-BDRv-l-h.js +1390 -0
- package/dist/node/internal/object-Br6jYeW0.js +20 -0
- package/dist/src/document/actions/creators.d.ts +47 -0
- package/dist/src/document/actions/index.d.ts +14 -0
- package/dist/src/document/actions/types.d.ts +15 -0
- package/dist/src/document/index.d.ts +6 -0
- package/dist/src/document/object.d.ts +1140 -0
- package/dist/src/document/reducer.d.ts +32 -0
- package/dist/src/document/schema/index.d.ts +2 -0
- package/dist/src/document/schema/types.d.ts +176 -0
- package/dist/src/document/schema/zod.d.ts +113 -0
- package/dist/src/document/signal.d.ts +29 -0
- package/dist/src/document/types.d.ts +245 -0
- package/dist/src/document/utils/base.d.ts +80 -0
- package/dist/src/document/utils/browser.d.ts +10 -0
- package/dist/src/document/utils/file.d.ts +47 -0
- package/dist/src/document/utils/index.d.ts +4 -0
- package/dist/src/document/utils/node.d.ts +9 -0
- package/dist/src/document/utils/validation.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/header.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/module.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/state.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/versioning.d.ts +7 -0
- package/dist/src/document-model/custom/utils.d.ts +7 -0
- package/dist/src/document-model/gen/actions.d.ts +15 -0
- package/dist/src/document-model/gen/creators.d.ts +7 -0
- package/dist/src/document-model/gen/document-model.d.ts +2 -0
- package/dist/src/document-model/gen/header/actions.d.ts +9 -0
- package/dist/src/document-model/gen/header/creators.d.ts +8 -0
- package/dist/src/document-model/gen/header/object.d.ts +12 -0
- package/dist/src/document-model/gen/header/operations.d.ts +10 -0
- package/dist/src/document-model/gen/index.d.ts +5 -0
- package/dist/src/document-model/gen/module/actions.d.ts +8 -0
- package/dist/src/document-model/gen/module/creators.d.ts +7 -0
- package/dist/src/document-model/gen/module/object.d.ts +11 -0
- package/dist/src/document-model/gen/module/operations.d.ts +9 -0
- package/dist/src/document-model/gen/object.d.ts +28 -0
- package/dist/src/document-model/gen/operation/actions.d.ts +13 -0
- package/dist/src/document-model/gen/operation/creators.d.ts +12 -0
- package/dist/src/document-model/gen/operation/object.d.ts +16 -0
- package/dist/src/document-model/gen/operation/operations.d.ts +14 -0
- package/dist/src/document-model/gen/operation-error/actions.d.ts +10 -0
- package/dist/src/document-model/gen/operation-error/creators.d.ts +9 -0
- package/dist/src/document-model/gen/operation-error/object.d.ts +13 -0
- package/dist/src/document-model/gen/operation-error/operations.d.ts +11 -0
- package/dist/src/document-model/gen/operation-example/actions.d.ts +7 -0
- package/dist/src/document-model/gen/operation-example/creators.d.ts +6 -0
- package/dist/src/document-model/gen/operation-example/object.d.ts +10 -0
- package/dist/src/document-model/gen/operation-example/operations.d.ts +8 -0
- package/dist/src/document-model/gen/reducer.d.ts +5 -0
- package/dist/src/document-model/gen/schema/index.d.ts +2 -0
- package/dist/src/document-model/gen/schema/types.d.ts +453 -0
- package/dist/src/document-model/gen/schema/zod.d.ts +453 -0
- package/dist/src/document-model/gen/state/actions.d.ts +9 -0
- package/dist/src/document-model/gen/state/creators.d.ts +8 -0
- package/dist/src/document-model/gen/state/object.d.ts +12 -0
- package/dist/src/document-model/gen/state/operations.d.ts +10 -0
- package/dist/src/document-model/gen/types.d.ts +8 -0
- package/dist/src/document-model/gen/utils.d.ts +6 -0
- package/dist/src/document-model/gen/versioning/actions.d.ts +8 -0
- package/dist/src/document-model/gen/versioning/creators.d.ts +7 -0
- package/dist/src/document-model/gen/versioning/object.d.ts +11 -0
- package/dist/src/document-model/gen/versioning/operations.d.ts +9 -0
- package/dist/src/document-model/index.d.ts +80 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/test/document/event-vs-command.test.d.ts +1 -0
- package/dist/test/document/local.test.d.ts +1 -0
- package/dist/test/document/object.test.d.ts +1 -0
- package/dist/test/document/prune.test.d.ts +1 -0
- package/dist/test/document/reducer.test.d.ts +1 -0
- package/dist/test/document/skip-operations.test.d.ts +1 -0
- package/dist/test/document/undo-redo.test.d.ts +1 -0
- package/dist/test/document/utils.test.d.ts +1 -0
- package/dist/test/document-model/object.test.d.ts +1 -0
- package/dist/test/document-model/skip-operations.test.d.ts +1 -0
- package/dist/test/document-model/validation.test.d.ts +1 -0
- package/dist/test/document-model/zip.test.d.ts +1 -0
- package/dist/test/helpers.d.ts +34 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +2 -2
- package/dist/browser/internal/object-EriwiDIs.js +0 -7
- package/dist/browser/internal/object-Fq6PThAX.js +0 -1999
- package/dist/node/internal/object-S6TngMa9.js +0 -998
- package/dist/node/internal/object-ifvac9k2.js +0 -2
|
@@ -0,0 +1,1390 @@
|
|
|
1
|
+
var Ht = Object.defineProperty;
|
|
2
|
+
var Qt = (e, t, i) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var nt = (e, t, i) => (Qt(e, typeof t != "symbol" ? t + "" : t, i), i);
|
|
4
|
+
import { produce as H, castDraft as pt, castImmutable as Xt, freeze as Yt } from "immer";
|
|
5
|
+
import { z as m } from "zod";
|
|
6
|
+
import te from "crypto";
|
|
7
|
+
import ct from "fs";
|
|
8
|
+
import ee from "https";
|
|
9
|
+
import { join as ie } from "path";
|
|
10
|
+
import St from "jszip";
|
|
11
|
+
const Ot = (e) => e != null, ne = m.any().refine((e) => Ot(e)), $t = m.enum(["LOAD_STATE"]), Et = m.enum(["PRUNE"]), vt = m.enum(["REDO"]), Tt = m.enum(["SET_NAME"]), _t = m.enum(["UNDO"]);
|
|
12
|
+
function oe() {
|
|
13
|
+
return m.object({
|
|
14
|
+
__typename: m.literal("Action").optional(),
|
|
15
|
+
type: m.string()
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function Q() {
|
|
19
|
+
return m.literal("global").or(m.literal("local"));
|
|
20
|
+
}
|
|
21
|
+
function kt() {
|
|
22
|
+
return m.union([
|
|
23
|
+
At(),
|
|
24
|
+
Dt(),
|
|
25
|
+
Mt(),
|
|
26
|
+
Pt(),
|
|
27
|
+
It()
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
function re() {
|
|
31
|
+
return m.object({
|
|
32
|
+
__typename: m.literal("DocumentFile").optional(),
|
|
33
|
+
data: m.string(),
|
|
34
|
+
extension: m.string().nullable(),
|
|
35
|
+
fileName: m.string().nullable(),
|
|
36
|
+
mimeType: m.string()
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function At() {
|
|
40
|
+
return m.object({
|
|
41
|
+
input: m.lazy(() => ut()),
|
|
42
|
+
type: $t,
|
|
43
|
+
scope: Q()
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function ut() {
|
|
47
|
+
return m.object({
|
|
48
|
+
operations: m.number(),
|
|
49
|
+
state: m.lazy(() => Nt())
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function Nt() {
|
|
53
|
+
return m.object({
|
|
54
|
+
data: m.unknown().nullish(),
|
|
55
|
+
name: m.string()
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function se() {
|
|
59
|
+
return m.object({
|
|
60
|
+
__typename: m.literal("Operation").optional(),
|
|
61
|
+
hash: m.string(),
|
|
62
|
+
index: m.number(),
|
|
63
|
+
timestamp: m.string().datetime(),
|
|
64
|
+
type: m.string()
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function Dt() {
|
|
68
|
+
return m.object({
|
|
69
|
+
input: m.lazy(() => ft()),
|
|
70
|
+
type: Et,
|
|
71
|
+
scope: Q()
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function ft() {
|
|
75
|
+
return m.object({
|
|
76
|
+
end: m.number().nullish(),
|
|
77
|
+
start: m.number().nullish()
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const dt = m.number;
|
|
81
|
+
function Mt() {
|
|
82
|
+
return m.object({
|
|
83
|
+
input: dt(),
|
|
84
|
+
type: vt,
|
|
85
|
+
scope: Q()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const gt = m.string;
|
|
89
|
+
function Pt() {
|
|
90
|
+
return m.object({
|
|
91
|
+
input: gt(),
|
|
92
|
+
type: Tt,
|
|
93
|
+
scope: m.literal("global")
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ae() {
|
|
97
|
+
return m.object({
|
|
98
|
+
__typename: m.literal("SetNameOperation").optional(),
|
|
99
|
+
hash: m.string(),
|
|
100
|
+
index: m.number(),
|
|
101
|
+
input: m.string(),
|
|
102
|
+
timestamp: m.string().datetime(),
|
|
103
|
+
type: m.string()
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const ht = m.number;
|
|
107
|
+
function It() {
|
|
108
|
+
return m.object({
|
|
109
|
+
input: ht(),
|
|
110
|
+
type: _t,
|
|
111
|
+
scope: Q()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
115
|
+
__proto__: null,
|
|
116
|
+
ActionSchema: oe,
|
|
117
|
+
BaseActionSchema: kt,
|
|
118
|
+
DocumentFileSchema: re,
|
|
119
|
+
LoadStateActionInputSchema: ut,
|
|
120
|
+
LoadStateActionSchema: At,
|
|
121
|
+
LoadStateActionStateInputSchema: Nt,
|
|
122
|
+
Load_StateSchema: $t,
|
|
123
|
+
OperationSchema: se,
|
|
124
|
+
OperationScopeSchema: Q,
|
|
125
|
+
PruneActionInputSchema: ft,
|
|
126
|
+
PruneActionSchema: Dt,
|
|
127
|
+
PruneSchema: Et,
|
|
128
|
+
RedoActionInputSchema: dt,
|
|
129
|
+
RedoActionSchema: Mt,
|
|
130
|
+
RedoSchema: vt,
|
|
131
|
+
SetNameActionInputSchema: gt,
|
|
132
|
+
SetNameActionSchema: Pt,
|
|
133
|
+
SetNameOperationSchema: ae,
|
|
134
|
+
Set_NameSchema: Tt,
|
|
135
|
+
UndoActionInputSchema: ht,
|
|
136
|
+
UndoActionSchema: It,
|
|
137
|
+
UndoSchema: _t,
|
|
138
|
+
definedNonNullAnySchema: ne,
|
|
139
|
+
isDefinedNonNullAny: Ot
|
|
140
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
141
|
+
function pe(e) {
|
|
142
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
143
|
+
}
|
|
144
|
+
var lt = { exports: {} };
|
|
145
|
+
(function(e, t) {
|
|
146
|
+
const { hasOwnProperty: i } = Object.prototype, n = C();
|
|
147
|
+
n.configure = C, n.stringify = n, n.default = n, t.stringify = n, t.configure = C, e.exports = n;
|
|
148
|
+
const s = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
|
|
149
|
+
function a(c) {
|
|
150
|
+
return c.length < 5e3 && !s.test(c) ? `"${c}"` : JSON.stringify(c);
|
|
151
|
+
}
|
|
152
|
+
function r(c) {
|
|
153
|
+
if (c.length > 200)
|
|
154
|
+
return c.sort();
|
|
155
|
+
for (let l = 1; l < c.length; l++) {
|
|
156
|
+
const j = c[l];
|
|
157
|
+
let D = l;
|
|
158
|
+
for (; D !== 0 && c[D - 1] > j; )
|
|
159
|
+
c[D] = c[D - 1], D--;
|
|
160
|
+
c[D] = j;
|
|
161
|
+
}
|
|
162
|
+
return c;
|
|
163
|
+
}
|
|
164
|
+
const p = Object.getOwnPropertyDescriptor(
|
|
165
|
+
Object.getPrototypeOf(
|
|
166
|
+
Object.getPrototypeOf(
|
|
167
|
+
new Int8Array()
|
|
168
|
+
)
|
|
169
|
+
),
|
|
170
|
+
Symbol.toStringTag
|
|
171
|
+
).get;
|
|
172
|
+
function d(c) {
|
|
173
|
+
return p.call(c) !== void 0 && c.length !== 0;
|
|
174
|
+
}
|
|
175
|
+
function f(c, l, j) {
|
|
176
|
+
c.length < j && (j = c.length);
|
|
177
|
+
const D = l === "," ? "" : " ";
|
|
178
|
+
let V = `"0":${D}${c[0]}`;
|
|
179
|
+
for (let z = 1; z < j; z++)
|
|
180
|
+
V += `${l}"${z}":${D}${c[z]}`;
|
|
181
|
+
return V;
|
|
182
|
+
}
|
|
183
|
+
function A(c) {
|
|
184
|
+
if (i.call(c, "circularValue")) {
|
|
185
|
+
const l = c.circularValue;
|
|
186
|
+
if (typeof l == "string")
|
|
187
|
+
return `"${l}"`;
|
|
188
|
+
if (l == null)
|
|
189
|
+
return l;
|
|
190
|
+
if (l === Error || l === 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 b(c, l) {
|
|
201
|
+
let j;
|
|
202
|
+
if (i.call(c, l) && (j = c[l], typeof j != "boolean"))
|
|
203
|
+
throw new TypeError(`The "${l}" argument must be of type boolean`);
|
|
204
|
+
return j === void 0 ? !0 : j;
|
|
205
|
+
}
|
|
206
|
+
function h(c, l) {
|
|
207
|
+
let j;
|
|
208
|
+
if (i.call(c, l)) {
|
|
209
|
+
if (j = c[l], typeof j != "number")
|
|
210
|
+
throw new TypeError(`The "${l}" argument must be of type number`);
|
|
211
|
+
if (!Number.isInteger(j))
|
|
212
|
+
throw new TypeError(`The "${l}" argument must be an integer`);
|
|
213
|
+
if (j < 1)
|
|
214
|
+
throw new RangeError(`The "${l}" argument must be >= 1`);
|
|
215
|
+
}
|
|
216
|
+
return j === void 0 ? 1 / 0 : j;
|
|
217
|
+
}
|
|
218
|
+
function $(c) {
|
|
219
|
+
return c === 1 ? "1 item" : `${c} items`;
|
|
220
|
+
}
|
|
221
|
+
function S(c) {
|
|
222
|
+
const l = /* @__PURE__ */ new Set();
|
|
223
|
+
for (const j of c)
|
|
224
|
+
(typeof j == "string" || typeof j == "number") && l.add(String(j));
|
|
225
|
+
return l;
|
|
226
|
+
}
|
|
227
|
+
function J(c) {
|
|
228
|
+
if (i.call(c, "strict")) {
|
|
229
|
+
const l = c.strict;
|
|
230
|
+
if (typeof l != "boolean")
|
|
231
|
+
throw new TypeError('The "strict" argument must be of type boolean');
|
|
232
|
+
if (l)
|
|
233
|
+
return (j) => {
|
|
234
|
+
let D = `Object can not safely be stringified. Received type ${typeof j}`;
|
|
235
|
+
throw typeof j != "function" && (D += ` (${j.toString()})`), new Error(D);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function C(c) {
|
|
240
|
+
c = { ...c };
|
|
241
|
+
const l = J(c);
|
|
242
|
+
l && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
|
|
243
|
+
const j = A(c), D = b(c, "bigint"), V = b(c, "deterministic"), z = h(c, "maximumDepth"), T = h(c, "maximumBreadth");
|
|
244
|
+
function tt(M, o, u, y, x, O) {
|
|
245
|
+
let g = o[M];
|
|
246
|
+
switch (typeof g == "object" && g !== null && typeof g.toJSON == "function" && (g = g.toJSON(M)), g = y.call(o, M, g), typeof g) {
|
|
247
|
+
case "string":
|
|
248
|
+
return a(g);
|
|
249
|
+
case "object": {
|
|
250
|
+
if (g === null)
|
|
251
|
+
return "null";
|
|
252
|
+
if (u.indexOf(g) !== -1)
|
|
253
|
+
return j;
|
|
254
|
+
let w = "", v = ",";
|
|
255
|
+
const _ = O;
|
|
256
|
+
if (Array.isArray(g)) {
|
|
257
|
+
if (g.length === 0)
|
|
258
|
+
return "[]";
|
|
259
|
+
if (z < u.length + 1)
|
|
260
|
+
return '"[Array]"';
|
|
261
|
+
u.push(g), x !== "" && (O += x, w += `
|
|
262
|
+
${O}`, v = `,
|
|
263
|
+
${O}`);
|
|
264
|
+
const I = Math.min(g.length, T);
|
|
265
|
+
let L = 0;
|
|
266
|
+
for (; L < I - 1; L++) {
|
|
267
|
+
const it = tt(String(L), g, u, y, x, O);
|
|
268
|
+
w += it !== void 0 ? it : "null", w += v;
|
|
269
|
+
}
|
|
270
|
+
const q = tt(String(L), g, u, y, x, O);
|
|
271
|
+
if (w += q !== void 0 ? q : "null", g.length - 1 > T) {
|
|
272
|
+
const it = g.length - T - 1;
|
|
273
|
+
w += `${v}"... ${$(it)} not stringified"`;
|
|
274
|
+
}
|
|
275
|
+
return x !== "" && (w += `
|
|
276
|
+
${_}`), u.pop(), `[${w}]`;
|
|
277
|
+
}
|
|
278
|
+
let k = Object.keys(g);
|
|
279
|
+
const N = k.length;
|
|
280
|
+
if (N === 0)
|
|
281
|
+
return "{}";
|
|
282
|
+
if (z < u.length + 1)
|
|
283
|
+
return '"[Object]"';
|
|
284
|
+
let E = "", P = "";
|
|
285
|
+
x !== "" && (O += x, v = `,
|
|
286
|
+
${O}`, E = " ");
|
|
287
|
+
const R = Math.min(N, T);
|
|
288
|
+
V && !d(g) && (k = r(k)), u.push(g);
|
|
289
|
+
for (let I = 0; I < R; I++) {
|
|
290
|
+
const L = k[I], q = tt(L, g, u, y, x, O);
|
|
291
|
+
q !== void 0 && (w += `${P}${a(L)}:${E}${q}`, P = v);
|
|
292
|
+
}
|
|
293
|
+
if (N > T) {
|
|
294
|
+
const I = N - T;
|
|
295
|
+
w += `${P}"...":${E}"${$(I)} not stringified"`, P = v;
|
|
296
|
+
}
|
|
297
|
+
return x !== "" && P.length > 1 && (w = `
|
|
298
|
+
${O}${w}
|
|
299
|
+
${_}`), u.pop(), `{${w}}`;
|
|
300
|
+
}
|
|
301
|
+
case "number":
|
|
302
|
+
return isFinite(g) ? String(g) : l ? l(g) : "null";
|
|
303
|
+
case "boolean":
|
|
304
|
+
return g === !0 ? "true" : "false";
|
|
305
|
+
case "undefined":
|
|
306
|
+
return;
|
|
307
|
+
case "bigint":
|
|
308
|
+
if (D)
|
|
309
|
+
return String(g);
|
|
310
|
+
default:
|
|
311
|
+
return l ? l(g) : void 0;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function et(M, o, u, y, x, O) {
|
|
315
|
+
switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(M)), typeof o) {
|
|
316
|
+
case "string":
|
|
317
|
+
return a(o);
|
|
318
|
+
case "object": {
|
|
319
|
+
if (o === null)
|
|
320
|
+
return "null";
|
|
321
|
+
if (u.indexOf(o) !== -1)
|
|
322
|
+
return j;
|
|
323
|
+
const g = O;
|
|
324
|
+
let w = "", v = ",";
|
|
325
|
+
if (Array.isArray(o)) {
|
|
326
|
+
if (o.length === 0)
|
|
327
|
+
return "[]";
|
|
328
|
+
if (z < u.length + 1)
|
|
329
|
+
return '"[Array]"';
|
|
330
|
+
u.push(o), x !== "" && (O += x, w += `
|
|
331
|
+
${O}`, v = `,
|
|
332
|
+
${O}`);
|
|
333
|
+
const N = Math.min(o.length, T);
|
|
334
|
+
let E = 0;
|
|
335
|
+
for (; E < N - 1; E++) {
|
|
336
|
+
const R = et(String(E), o[E], u, y, x, O);
|
|
337
|
+
w += R !== void 0 ? R : "null", w += v;
|
|
338
|
+
}
|
|
339
|
+
const P = et(String(E), o[E], u, y, x, O);
|
|
340
|
+
if (w += P !== void 0 ? P : "null", o.length - 1 > T) {
|
|
341
|
+
const R = o.length - T - 1;
|
|
342
|
+
w += `${v}"... ${$(R)} not stringified"`;
|
|
343
|
+
}
|
|
344
|
+
return x !== "" && (w += `
|
|
345
|
+
${g}`), u.pop(), `[${w}]`;
|
|
346
|
+
}
|
|
347
|
+
u.push(o);
|
|
348
|
+
let _ = "";
|
|
349
|
+
x !== "" && (O += x, v = `,
|
|
350
|
+
${O}`, _ = " ");
|
|
351
|
+
let k = "";
|
|
352
|
+
for (const N of y) {
|
|
353
|
+
const E = et(N, o[N], u, y, x, O);
|
|
354
|
+
E !== void 0 && (w += `${k}${a(N)}:${_}${E}`, k = v);
|
|
355
|
+
}
|
|
356
|
+
return x !== "" && k.length > 1 && (w = `
|
|
357
|
+
${O}${w}
|
|
358
|
+
${g}`), u.pop(), `{${w}}`;
|
|
359
|
+
}
|
|
360
|
+
case "number":
|
|
361
|
+
return isFinite(o) ? String(o) : l ? l(o) : "null";
|
|
362
|
+
case "boolean":
|
|
363
|
+
return o === !0 ? "true" : "false";
|
|
364
|
+
case "undefined":
|
|
365
|
+
return;
|
|
366
|
+
case "bigint":
|
|
367
|
+
if (D)
|
|
368
|
+
return String(o);
|
|
369
|
+
default:
|
|
370
|
+
return l ? l(o) : void 0;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function B(M, o, u, y, x) {
|
|
374
|
+
switch (typeof o) {
|
|
375
|
+
case "string":
|
|
376
|
+
return a(o);
|
|
377
|
+
case "object": {
|
|
378
|
+
if (o === null)
|
|
379
|
+
return "null";
|
|
380
|
+
if (typeof o.toJSON == "function") {
|
|
381
|
+
if (o = o.toJSON(M), typeof o != "object")
|
|
382
|
+
return B(M, o, u, y, x);
|
|
383
|
+
if (o === null)
|
|
384
|
+
return "null";
|
|
385
|
+
}
|
|
386
|
+
if (u.indexOf(o) !== -1)
|
|
387
|
+
return j;
|
|
388
|
+
const O = x;
|
|
389
|
+
if (Array.isArray(o)) {
|
|
390
|
+
if (o.length === 0)
|
|
391
|
+
return "[]";
|
|
392
|
+
if (z < u.length + 1)
|
|
393
|
+
return '"[Array]"';
|
|
394
|
+
u.push(o), x += y;
|
|
395
|
+
let E = `
|
|
396
|
+
${x}`;
|
|
397
|
+
const P = `,
|
|
398
|
+
${x}`, R = Math.min(o.length, T);
|
|
399
|
+
let I = 0;
|
|
400
|
+
for (; I < R - 1; I++) {
|
|
401
|
+
const q = B(String(I), o[I], u, y, x);
|
|
402
|
+
E += q !== void 0 ? q : "null", E += P;
|
|
403
|
+
}
|
|
404
|
+
const L = B(String(I), o[I], u, y, x);
|
|
405
|
+
if (E += L !== void 0 ? L : "null", o.length - 1 > T) {
|
|
406
|
+
const q = o.length - T - 1;
|
|
407
|
+
E += `${P}"... ${$(q)} not stringified"`;
|
|
408
|
+
}
|
|
409
|
+
return E += `
|
|
410
|
+
${O}`, u.pop(), `[${E}]`;
|
|
411
|
+
}
|
|
412
|
+
let g = Object.keys(o);
|
|
413
|
+
const w = g.length;
|
|
414
|
+
if (w === 0)
|
|
415
|
+
return "{}";
|
|
416
|
+
if (z < u.length + 1)
|
|
417
|
+
return '"[Object]"';
|
|
418
|
+
x += y;
|
|
419
|
+
const v = `,
|
|
420
|
+
${x}`;
|
|
421
|
+
let _ = "", k = "", N = Math.min(w, T);
|
|
422
|
+
d(o) && (_ += f(o, v, T), g = g.slice(o.length), N -= o.length, k = v), V && (g = r(g)), u.push(o);
|
|
423
|
+
for (let E = 0; E < N; E++) {
|
|
424
|
+
const P = g[E], R = B(P, o[P], u, y, x);
|
|
425
|
+
R !== void 0 && (_ += `${k}${a(P)}: ${R}`, k = v);
|
|
426
|
+
}
|
|
427
|
+
if (w > T) {
|
|
428
|
+
const E = w - T;
|
|
429
|
+
_ += `${k}"...": "${$(E)} not stringified"`, k = v;
|
|
430
|
+
}
|
|
431
|
+
return k !== "" && (_ = `
|
|
432
|
+
${x}${_}
|
|
433
|
+
${O}`), u.pop(), `{${_}}`;
|
|
434
|
+
}
|
|
435
|
+
case "number":
|
|
436
|
+
return isFinite(o) ? String(o) : l ? l(o) : "null";
|
|
437
|
+
case "boolean":
|
|
438
|
+
return o === !0 ? "true" : "false";
|
|
439
|
+
case "undefined":
|
|
440
|
+
return;
|
|
441
|
+
case "bigint":
|
|
442
|
+
if (D)
|
|
443
|
+
return String(o);
|
|
444
|
+
default:
|
|
445
|
+
return l ? l(o) : void 0;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function Z(M, o, u) {
|
|
449
|
+
switch (typeof o) {
|
|
450
|
+
case "string":
|
|
451
|
+
return a(o);
|
|
452
|
+
case "object": {
|
|
453
|
+
if (o === null)
|
|
454
|
+
return "null";
|
|
455
|
+
if (typeof o.toJSON == "function") {
|
|
456
|
+
if (o = o.toJSON(M), typeof o != "object")
|
|
457
|
+
return Z(M, o, u);
|
|
458
|
+
if (o === null)
|
|
459
|
+
return "null";
|
|
460
|
+
}
|
|
461
|
+
if (u.indexOf(o) !== -1)
|
|
462
|
+
return j;
|
|
463
|
+
let y = "";
|
|
464
|
+
if (Array.isArray(o)) {
|
|
465
|
+
if (o.length === 0)
|
|
466
|
+
return "[]";
|
|
467
|
+
if (z < u.length + 1)
|
|
468
|
+
return '"[Array]"';
|
|
469
|
+
u.push(o);
|
|
470
|
+
const v = Math.min(o.length, T);
|
|
471
|
+
let _ = 0;
|
|
472
|
+
for (; _ < v - 1; _++) {
|
|
473
|
+
const N = Z(String(_), o[_], u);
|
|
474
|
+
y += N !== void 0 ? N : "null", y += ",";
|
|
475
|
+
}
|
|
476
|
+
const k = Z(String(_), o[_], u);
|
|
477
|
+
if (y += k !== void 0 ? k : "null", o.length - 1 > T) {
|
|
478
|
+
const N = o.length - T - 1;
|
|
479
|
+
y += `,"... ${$(N)} not stringified"`;
|
|
480
|
+
}
|
|
481
|
+
return u.pop(), `[${y}]`;
|
|
482
|
+
}
|
|
483
|
+
let x = Object.keys(o);
|
|
484
|
+
const O = x.length;
|
|
485
|
+
if (O === 0)
|
|
486
|
+
return "{}";
|
|
487
|
+
if (z < u.length + 1)
|
|
488
|
+
return '"[Object]"';
|
|
489
|
+
let g = "", w = Math.min(O, T);
|
|
490
|
+
d(o) && (y += f(o, ",", T), x = x.slice(o.length), w -= o.length, g = ","), V && (x = r(x)), u.push(o);
|
|
491
|
+
for (let v = 0; v < w; v++) {
|
|
492
|
+
const _ = x[v], k = Z(_, o[_], u);
|
|
493
|
+
k !== void 0 && (y += `${g}${a(_)}:${k}`, g = ",");
|
|
494
|
+
}
|
|
495
|
+
if (O > T) {
|
|
496
|
+
const v = O - T;
|
|
497
|
+
y += `${g}"...":"${$(v)} not stringified"`;
|
|
498
|
+
}
|
|
499
|
+
return u.pop(), `{${y}}`;
|
|
500
|
+
}
|
|
501
|
+
case "number":
|
|
502
|
+
return isFinite(o) ? String(o) : l ? l(o) : "null";
|
|
503
|
+
case "boolean":
|
|
504
|
+
return o === !0 ? "true" : "false";
|
|
505
|
+
case "undefined":
|
|
506
|
+
return;
|
|
507
|
+
case "bigint":
|
|
508
|
+
if (D)
|
|
509
|
+
return String(o);
|
|
510
|
+
default:
|
|
511
|
+
return l ? l(o) : void 0;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function Gt(M, o, u) {
|
|
515
|
+
if (arguments.length > 1) {
|
|
516
|
+
let y = "";
|
|
517
|
+
if (typeof u == "number" ? y = " ".repeat(Math.min(u, 10)) : typeof u == "string" && (y = u.slice(0, 10)), o != null) {
|
|
518
|
+
if (typeof o == "function")
|
|
519
|
+
return tt("", { "": M }, [], o, y, "");
|
|
520
|
+
if (Array.isArray(o))
|
|
521
|
+
return et("", M, [], S(o), y, "");
|
|
522
|
+
}
|
|
523
|
+
if (y.length !== 0)
|
|
524
|
+
return B("", M, [], y, "");
|
|
525
|
+
}
|
|
526
|
+
return Z("", M, []);
|
|
527
|
+
}
|
|
528
|
+
return Gt;
|
|
529
|
+
}
|
|
530
|
+
})(lt, lt.exports);
|
|
531
|
+
var ce = lt.exports;
|
|
532
|
+
const rt = /* @__PURE__ */ pe(ce);
|
|
533
|
+
rt.configure;
|
|
534
|
+
function le(e, t) {
|
|
535
|
+
return { ...e, name: t };
|
|
536
|
+
}
|
|
537
|
+
function me(e, t, i) {
|
|
538
|
+
const n = {
|
|
539
|
+
skip: i,
|
|
540
|
+
document: e
|
|
541
|
+
}, { scope: s } = t;
|
|
542
|
+
return !s || t.skip === void 0 ? n : H(n, (a) => {
|
|
543
|
+
const [r] = a.document.operations[s].slice(-1);
|
|
544
|
+
t.skip && t.skip > 0 && (a.skip = t.skip), r.type === "NOOP" && t.index === r.index && a.skip > r.skip && a.document.operations[s].pop();
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function ue(e, t, i) {
|
|
548
|
+
const { scope: n, input: s } = t;
|
|
549
|
+
return H({
|
|
550
|
+
document: e,
|
|
551
|
+
action: t,
|
|
552
|
+
skip: i
|
|
553
|
+
}, (r) => {
|
|
554
|
+
if (r.document.operations[n].length < 1)
|
|
555
|
+
throw new Error(
|
|
556
|
+
`Cannot undo: no operations in history for scope "${n}"`
|
|
557
|
+
);
|
|
558
|
+
if (s < 1)
|
|
559
|
+
throw new Error(
|
|
560
|
+
"Invalid UNDO action: input value must be greater than 0"
|
|
561
|
+
);
|
|
562
|
+
if (r.skip > 0)
|
|
563
|
+
throw new Error(
|
|
564
|
+
"Cannot undo: skip value from reducer cannot be used with UNDO action"
|
|
565
|
+
);
|
|
566
|
+
const [p] = r.document.operations[n].slice(-1), d = p.type === "NOOP" && p.skip > 0;
|
|
567
|
+
if (r.skip += s, d) {
|
|
568
|
+
r.skip += p.skip;
|
|
569
|
+
const h = r.document.operations[n][r.document.operations[n].length - 2];
|
|
570
|
+
h && p.index - h.index === 1 && r.document.operations[n].pop();
|
|
571
|
+
}
|
|
572
|
+
if (r.document.operations[n].length < r.skip)
|
|
573
|
+
throw new Error(
|
|
574
|
+
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
575
|
+
);
|
|
576
|
+
const f = r.document.operations[n].length - 1;
|
|
577
|
+
let A = s, b = d ? f - p.skip : f;
|
|
578
|
+
for (; A > 0 && b >= 0; ) {
|
|
579
|
+
const h = r.document.operations[n][b];
|
|
580
|
+
if (!h) {
|
|
581
|
+
A--, b--;
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
h.type === "NOOP" && h.skip > 0 ? (b = b - (h.skip + 1), r.skip += h.skip + 1) : (r.document.clipboard.push({ ...h }), A--, b--);
|
|
585
|
+
}
|
|
586
|
+
r.action = bt(n);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function fe(e, t, i) {
|
|
590
|
+
const { scope: n, input: s } = t;
|
|
591
|
+
return H({
|
|
592
|
+
document: e,
|
|
593
|
+
action: t,
|
|
594
|
+
skip: i
|
|
595
|
+
}, (r) => {
|
|
596
|
+
if (r.skip > 0)
|
|
597
|
+
throw new Error(
|
|
598
|
+
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
599
|
+
);
|
|
600
|
+
if (s > 1)
|
|
601
|
+
throw new Error(
|
|
602
|
+
"Cannot redo: you can only redo one operation at a time"
|
|
603
|
+
);
|
|
604
|
+
if (s < 1)
|
|
605
|
+
throw new Error("Invalid REDO action: invalid redo input value");
|
|
606
|
+
if (r.document.clipboard.length < 1)
|
|
607
|
+
throw new Error("Cannot redo: no operations in the clipboard");
|
|
608
|
+
const p = r.document.clipboard.findLastIndex(
|
|
609
|
+
(f) => f.scope === n
|
|
610
|
+
);
|
|
611
|
+
if (p < 0)
|
|
612
|
+
throw new Error(
|
|
613
|
+
`Cannot redo: no operations in clipboard for scope "${n}"`
|
|
614
|
+
);
|
|
615
|
+
const d = r.document.clipboard.splice(p, 1)[0];
|
|
616
|
+
r.action = pt({
|
|
617
|
+
type: d.type,
|
|
618
|
+
scope: d.scope,
|
|
619
|
+
input: d.input
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function de(e, t, i) {
|
|
624
|
+
const { scope: n } = t, s = e.operations[n];
|
|
625
|
+
let {
|
|
626
|
+
input: { start: a, end: r }
|
|
627
|
+
} = t;
|
|
628
|
+
a = a || 0, r = r || s.length;
|
|
629
|
+
const p = s.slice(a, r), d = s.slice(0, a), f = s.slice(r), A = mt(
|
|
630
|
+
e.initialState,
|
|
631
|
+
{
|
|
632
|
+
...e.operations,
|
|
633
|
+
[n]: d.concat(p)
|
|
634
|
+
},
|
|
635
|
+
i
|
|
636
|
+
), { name: b, state: h } = A, $ = d.length, S = d.length ? d[d.length - 1].timestamp : f.length ? f[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
637
|
+
return mt(
|
|
638
|
+
e.initialState,
|
|
639
|
+
{
|
|
640
|
+
...e.operations,
|
|
641
|
+
[n]: [
|
|
642
|
+
...d,
|
|
643
|
+
{
|
|
644
|
+
...xt(
|
|
645
|
+
{ name: b, state: h },
|
|
646
|
+
p.length
|
|
647
|
+
),
|
|
648
|
+
timestamp: S,
|
|
649
|
+
index: $,
|
|
650
|
+
hash: qt({ state: h }, "global")
|
|
651
|
+
},
|
|
652
|
+
...f.map((J, C) => ({
|
|
653
|
+
...J,
|
|
654
|
+
index: $ + C + 1
|
|
655
|
+
}))
|
|
656
|
+
]
|
|
657
|
+
},
|
|
658
|
+
i
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
function ge(e, t) {
|
|
662
|
+
return {
|
|
663
|
+
...e,
|
|
664
|
+
name: t.name,
|
|
665
|
+
state: t.state ?? { global: {}, local: {} }
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
const zt = "SET_NAME", X = "UNDO", Y = "REDO", st = "PRUNE", Ft = "LOAD_STATE", he = "NOOP";
|
|
669
|
+
function xe(e, t) {
|
|
670
|
+
let i;
|
|
671
|
+
return "index" in t ? i = { ...t } : i = e.operations[t.scope].slice(-1)[0], ((i == null ? void 0 : i.index) ?? -1) + 1;
|
|
672
|
+
}
|
|
673
|
+
function be(e, t) {
|
|
674
|
+
return {
|
|
675
|
+
...e,
|
|
676
|
+
revision: {
|
|
677
|
+
...e.revision,
|
|
678
|
+
[t.scope]: xe(e, t)
|
|
679
|
+
},
|
|
680
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function ye(e, t, i = 0) {
|
|
684
|
+
if ([X, Y, st].includes(t.type))
|
|
685
|
+
return e;
|
|
686
|
+
const { scope: n } = t, s = e.operations[n].slice(
|
|
687
|
+
0,
|
|
688
|
+
e.revision[n]
|
|
689
|
+
), a = [...s].pop();
|
|
690
|
+
let r = ((a == null ? void 0 : a.index) ?? -1) + 1;
|
|
691
|
+
if ("index" in t) {
|
|
692
|
+
if (t.index > r + i)
|
|
693
|
+
throw new Error(
|
|
694
|
+
`Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
|
|
695
|
+
);
|
|
696
|
+
r = t.index;
|
|
697
|
+
}
|
|
698
|
+
return s.push({
|
|
699
|
+
...t,
|
|
700
|
+
index: r,
|
|
701
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
702
|
+
hash: "",
|
|
703
|
+
scope: n,
|
|
704
|
+
skip: i
|
|
705
|
+
}), {
|
|
706
|
+
...e,
|
|
707
|
+
operations: { ...e.operations, [n]: s }
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function we(e, t, i = 0) {
|
|
711
|
+
let n = ye(e, t, i);
|
|
712
|
+
return n = be(n, t), n;
|
|
713
|
+
}
|
|
714
|
+
function je(e, t, i) {
|
|
715
|
+
switch (kt().parse(t), t.type) {
|
|
716
|
+
case zt:
|
|
717
|
+
return le(e, t.input);
|
|
718
|
+
case st:
|
|
719
|
+
return de(e, t, i);
|
|
720
|
+
case Ft:
|
|
721
|
+
return ge(e, t.input.state);
|
|
722
|
+
default:
|
|
723
|
+
return e;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function Se(e, t, i) {
|
|
727
|
+
switch (t.type) {
|
|
728
|
+
case X:
|
|
729
|
+
return ue(e, t, i);
|
|
730
|
+
case Y:
|
|
731
|
+
return fe(e, t, i);
|
|
732
|
+
default:
|
|
733
|
+
return { document: e, action: t, skip: i };
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function Rt(e, t, i, n, s = {}) {
|
|
737
|
+
const { skip: a, ignoreSkipOperations: r = !1 } = s;
|
|
738
|
+
let p = { ...t }, d = a || 0, f = e, A = [...e.clipboard];
|
|
739
|
+
if (ve(p)) {
|
|
740
|
+
const { document: b, skip: h } = me(f, p, d);
|
|
741
|
+
d = h, f = b;
|
|
742
|
+
}
|
|
743
|
+
if (yt(p)) {
|
|
744
|
+
const {
|
|
745
|
+
skip: b,
|
|
746
|
+
action: h,
|
|
747
|
+
document: $
|
|
748
|
+
} = Se(e, p, d);
|
|
749
|
+
p = h, d = b, f = $, A = [...f.clipboard];
|
|
750
|
+
}
|
|
751
|
+
if (wt(p) && (f = je(f, p, i)), d > 0 && !r) {
|
|
752
|
+
let b = d;
|
|
753
|
+
"index" in p && (b = Ne(
|
|
754
|
+
f.operations[p.scope],
|
|
755
|
+
p.index,
|
|
756
|
+
d
|
|
757
|
+
)), f = mt(
|
|
758
|
+
f.initialState,
|
|
759
|
+
f.operations,
|
|
760
|
+
i,
|
|
761
|
+
void 0,
|
|
762
|
+
void 0,
|
|
763
|
+
void 0,
|
|
764
|
+
{ [p.scope]: b }
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
return f = we(f, p, d), f = H(f, (b) => {
|
|
768
|
+
const h = i(
|
|
769
|
+
b.state,
|
|
770
|
+
p,
|
|
771
|
+
n
|
|
772
|
+
), $ = yt(t) ? [...A] : [];
|
|
773
|
+
if (h)
|
|
774
|
+
return pt({
|
|
775
|
+
...f,
|
|
776
|
+
clipboard: [...$],
|
|
777
|
+
state: h
|
|
778
|
+
});
|
|
779
|
+
b.clipboard = pt([...$]);
|
|
780
|
+
}), H(f, (b) => {
|
|
781
|
+
if ([X, Y, st].includes(p.type))
|
|
782
|
+
return b;
|
|
783
|
+
const h = p.scope || "global";
|
|
784
|
+
b.operations[h][b.operations[h].length - 1].hash = qt(b, h), !wt(p) && p.attachments && p.attachments.forEach(($) => {
|
|
785
|
+
const { hash: S, ...J } = $;
|
|
786
|
+
b.attachments[S] = {
|
|
787
|
+
...J
|
|
788
|
+
};
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
function Oe(e, t, i) {
|
|
793
|
+
const n = ie(e, t);
|
|
794
|
+
return ct.mkdirSync(e, { recursive: !0 }), new Promise((s, a) => {
|
|
795
|
+
try {
|
|
796
|
+
ct.writeFile(n, i, {}, (r) => {
|
|
797
|
+
r ? a(r) : s(n);
|
|
798
|
+
});
|
|
799
|
+
} catch (r) {
|
|
800
|
+
a(r);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
function Lt(e) {
|
|
805
|
+
return ct.readFileSync(e);
|
|
806
|
+
}
|
|
807
|
+
function $e(e) {
|
|
808
|
+
return new Promise((t, i) => {
|
|
809
|
+
ee.get(e, (n) => {
|
|
810
|
+
const s = [], a = n.headers["content-type"];
|
|
811
|
+
n.on("data", (r) => {
|
|
812
|
+
s.push(r);
|
|
813
|
+
}), n.on("end", () => {
|
|
814
|
+
t({ buffer: Buffer.concat(s), mimeType: a });
|
|
815
|
+
});
|
|
816
|
+
}).on("error", (n) => {
|
|
817
|
+
i(n);
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
const Ee = async (e) => Lt(e), at = (e, t = "sha1") => te.createHash(t).update(e).digest("base64");
|
|
822
|
+
function ve(e) {
|
|
823
|
+
return e.type === he && e.skip !== void 0 && e.skip > 0 && e.hash !== void 0;
|
|
824
|
+
}
|
|
825
|
+
function yt(e) {
|
|
826
|
+
return [X, Y].includes(e.type);
|
|
827
|
+
}
|
|
828
|
+
function wt(e) {
|
|
829
|
+
return [zt, X, Y, st, Ft].includes(e.type);
|
|
830
|
+
}
|
|
831
|
+
function W(e, t, i, n, s = "global") {
|
|
832
|
+
if (!e)
|
|
833
|
+
throw new Error("Empty action type");
|
|
834
|
+
if (typeof e != "string")
|
|
835
|
+
throw new Error(`Invalid action type: ${e}`);
|
|
836
|
+
const a = { type: e, input: t, scope: s };
|
|
837
|
+
i && (a.attachments = i);
|
|
838
|
+
try {
|
|
839
|
+
n == null || n().parse(a.input);
|
|
840
|
+
} catch (r) {
|
|
841
|
+
throw new Error(`Invalid action input: ${r}`);
|
|
842
|
+
}
|
|
843
|
+
return a;
|
|
844
|
+
}
|
|
845
|
+
function Te(e, t = Rt) {
|
|
846
|
+
return (i, n, s, a) => t(i, n, e, s, a);
|
|
847
|
+
}
|
|
848
|
+
const _e = (e, t) => ({
|
|
849
|
+
name: "",
|
|
850
|
+
documentType: "",
|
|
851
|
+
revision: {
|
|
852
|
+
global: 0,
|
|
853
|
+
local: 0
|
|
854
|
+
},
|
|
855
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
856
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
857
|
+
attachments: {},
|
|
858
|
+
...e,
|
|
859
|
+
state: (t == null ? void 0 : t(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
|
|
860
|
+
}), ke = (e, t) => {
|
|
861
|
+
const i = _e(
|
|
862
|
+
e,
|
|
863
|
+
t
|
|
864
|
+
);
|
|
865
|
+
return {
|
|
866
|
+
...i,
|
|
867
|
+
initialState: i,
|
|
868
|
+
operations: { global: [], local: [] },
|
|
869
|
+
clipboard: []
|
|
870
|
+
};
|
|
871
|
+
}, qt = (e, t = "global") => at(rt(e.state[t] || "")), Ze = (e, t = 1e3) => {
|
|
872
|
+
const i = Math.random() * t;
|
|
873
|
+
return at(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
874
|
+
};
|
|
875
|
+
function ot(e) {
|
|
876
|
+
return Xt(Yt(e, !0));
|
|
877
|
+
}
|
|
878
|
+
function Ae(e, t) {
|
|
879
|
+
const i = [...e];
|
|
880
|
+
let n = t || 0, s = i.length > 0 ? i[i.length - 1].index : 0;
|
|
881
|
+
const a = [];
|
|
882
|
+
for (const r of i.reverse()) {
|
|
883
|
+
if (n > 0) {
|
|
884
|
+
const f = s - r.index;
|
|
885
|
+
n -= f;
|
|
886
|
+
}
|
|
887
|
+
if (n < 0)
|
|
888
|
+
throw new Error("Invalid operation index, missing operations");
|
|
889
|
+
const p = {
|
|
890
|
+
ignore: n > 0,
|
|
891
|
+
operation: r
|
|
892
|
+
}, d = r.skip > 0 ? r.skip + 1 : 0;
|
|
893
|
+
if (d > 0 && d > n) {
|
|
894
|
+
const f = d - n;
|
|
895
|
+
n = n + f;
|
|
896
|
+
}
|
|
897
|
+
s = r.index, a.push(p);
|
|
898
|
+
}
|
|
899
|
+
return a.reverse();
|
|
900
|
+
}
|
|
901
|
+
function Ne(e, t, i) {
|
|
902
|
+
const n = e.slice().sort((p, d) => p.skip - d.skip).sort((p, d) => p.index - d.index);
|
|
903
|
+
let s = i, a = 0, r = t;
|
|
904
|
+
for (const p of n.reverse()) {
|
|
905
|
+
const d = r - p.index;
|
|
906
|
+
if (s = s - d, s > -1)
|
|
907
|
+
a++, r = p.index;
|
|
908
|
+
else
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
return a;
|
|
912
|
+
}
|
|
913
|
+
function Ge(e) {
|
|
914
|
+
return Object.values(e).flatMap((t) => t).sort(
|
|
915
|
+
(t, i) => new Date(t.timestamp).getTime() - new Date(i.timestamp).getTime()
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
function De(e) {
|
|
919
|
+
return Object.values(e).flatMap((t) => t).sort(
|
|
920
|
+
(t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
function mt(e, t, i, n, s, a = Rt, r = {}) {
|
|
924
|
+
const p = Te(i, a);
|
|
925
|
+
return Ct(
|
|
926
|
+
e,
|
|
927
|
+
t,
|
|
928
|
+
p,
|
|
929
|
+
n,
|
|
930
|
+
s,
|
|
931
|
+
r
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
function Ct(e, t, i, n, s, a = {}) {
|
|
935
|
+
const r = ke(e), p = Object.keys(t).reduce((h, $) => {
|
|
936
|
+
const S = $;
|
|
937
|
+
return {
|
|
938
|
+
...h,
|
|
939
|
+
[S]: t[S].slice(0, s == null ? void 0 : s.revision[S])
|
|
940
|
+
};
|
|
941
|
+
}, {}), d = Object.keys(p).reduce(
|
|
942
|
+
(h, $) => {
|
|
943
|
+
const S = $;
|
|
944
|
+
return {
|
|
945
|
+
...h,
|
|
946
|
+
[S]: Ae(
|
|
947
|
+
p[S],
|
|
948
|
+
a[S]
|
|
949
|
+
)
|
|
950
|
+
};
|
|
951
|
+
},
|
|
952
|
+
{}
|
|
953
|
+
), f = De(d).reduce(
|
|
954
|
+
(h, { ignore: $, operation: S }) => $ ? i(h, bt(S.scope), n, {
|
|
955
|
+
skip: S.skip,
|
|
956
|
+
ignoreSkipOperations: !0
|
|
957
|
+
}) : i(h, S, n, {
|
|
958
|
+
skip: S.skip,
|
|
959
|
+
ignoreSkipOperations: !0
|
|
960
|
+
}),
|
|
961
|
+
r
|
|
962
|
+
), A = Object.keys(
|
|
963
|
+
f.operations
|
|
964
|
+
).reduce(
|
|
965
|
+
(h, $) => {
|
|
966
|
+
const S = $, J = s && s.revision[S] < t[S].length ? t[S].slice(s.revision[S]) : [];
|
|
967
|
+
return {
|
|
968
|
+
...h,
|
|
969
|
+
[S]: [
|
|
970
|
+
...f.operations[S].map((C, c) => {
|
|
971
|
+
var l;
|
|
972
|
+
return {
|
|
973
|
+
...C,
|
|
974
|
+
timestamp: ((l = t[S][c]) == null ? void 0 : l.timestamp) ?? C.timestamp
|
|
975
|
+
};
|
|
976
|
+
}),
|
|
977
|
+
...J
|
|
978
|
+
]
|
|
979
|
+
};
|
|
980
|
+
},
|
|
981
|
+
{ global: [], local: [] }
|
|
982
|
+
), b = Object.values(A).reduce((h, $) => {
|
|
983
|
+
for (const S of $)
|
|
984
|
+
S.timestamp > h && (h = S.timestamp);
|
|
985
|
+
return h;
|
|
986
|
+
}, e.lastModified);
|
|
987
|
+
return { ...f, operations: A, lastModified: b };
|
|
988
|
+
}
|
|
989
|
+
function He(e, t) {
|
|
990
|
+
return rt(e) === rt(t);
|
|
991
|
+
}
|
|
992
|
+
const Jt = (e) => W(
|
|
993
|
+
"SET_NAME",
|
|
994
|
+
e,
|
|
995
|
+
void 0,
|
|
996
|
+
gt,
|
|
997
|
+
void 0
|
|
998
|
+
), Ut = (e = 1, t = "global") => W(
|
|
999
|
+
"UNDO",
|
|
1000
|
+
e,
|
|
1001
|
+
void 0,
|
|
1002
|
+
ht,
|
|
1003
|
+
t
|
|
1004
|
+
), Vt = (e = 1, t = "global") => W(
|
|
1005
|
+
"REDO",
|
|
1006
|
+
e,
|
|
1007
|
+
void 0,
|
|
1008
|
+
dt,
|
|
1009
|
+
t
|
|
1010
|
+
), Kt = (e, t, i = "global") => W(
|
|
1011
|
+
"PRUNE",
|
|
1012
|
+
{ start: e, end: t },
|
|
1013
|
+
void 0,
|
|
1014
|
+
ft,
|
|
1015
|
+
i
|
|
1016
|
+
), xt = (e, t) => W(
|
|
1017
|
+
"LOAD_STATE",
|
|
1018
|
+
{ state: e, operations: t },
|
|
1019
|
+
void 0,
|
|
1020
|
+
ut
|
|
1021
|
+
), bt = (e = "global") => W("NOOP", {}, void 0, void 0, e), Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1022
|
+
__proto__: null,
|
|
1023
|
+
loadState: xt,
|
|
1024
|
+
noop: bt,
|
|
1025
|
+
prune: Kt,
|
|
1026
|
+
redo: Vt,
|
|
1027
|
+
setName: Jt,
|
|
1028
|
+
undo: Ut
|
|
1029
|
+
}, Symbol.toStringTag, { value: "Module" })), Wt = { "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"] };
|
|
1030
|
+
Object.freeze(Wt);
|
|
1031
|
+
var F = function(e, t, i, n) {
|
|
1032
|
+
if (i === "a" && !n)
|
|
1033
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
1034
|
+
if (typeof t == "function" ? e !== t || !n : !t.has(e))
|
|
1035
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1036
|
+
return i === "m" ? n : i === "a" ? n.call(e) : n ? n.value : t.get(e);
|
|
1037
|
+
}, K, G, U;
|
|
1038
|
+
class Me {
|
|
1039
|
+
constructor(...t) {
|
|
1040
|
+
K.set(this, /* @__PURE__ */ new Map()), G.set(this, /* @__PURE__ */ new Map()), U.set(this, /* @__PURE__ */ new Map());
|
|
1041
|
+
for (const i of t)
|
|
1042
|
+
this.define(i);
|
|
1043
|
+
}
|
|
1044
|
+
define(t, i = !1) {
|
|
1045
|
+
for (let [n, s] of Object.entries(t)) {
|
|
1046
|
+
n = n.toLowerCase(), s = s.map((p) => p.toLowerCase()), F(this, U, "f").has(n) || F(this, U, "f").set(n, /* @__PURE__ */ new Set());
|
|
1047
|
+
const a = F(this, U, "f").get(n);
|
|
1048
|
+
let r = !0;
|
|
1049
|
+
for (let p of s) {
|
|
1050
|
+
const d = p.startsWith("*");
|
|
1051
|
+
if (p = d ? p.slice(1) : p, a == null || a.add(p), r && F(this, G, "f").set(n, p), r = !1, d)
|
|
1052
|
+
continue;
|
|
1053
|
+
const f = F(this, K, "f").get(p);
|
|
1054
|
+
if (f && f != n && !i)
|
|
1055
|
+
throw new Error(`"${n} -> ${p}" conflicts with "${f} -> ${p}". Pass \`force=true\` to override this definition.`);
|
|
1056
|
+
F(this, K, "f").set(p, n);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return this;
|
|
1060
|
+
}
|
|
1061
|
+
getType(t) {
|
|
1062
|
+
if (typeof t != "string")
|
|
1063
|
+
return null;
|
|
1064
|
+
const i = t.replace(/^.*[/\\]/, "").toLowerCase(), n = i.replace(/^.*\./, "").toLowerCase(), s = i.length < t.length;
|
|
1065
|
+
return !(n.length < i.length - 1) && s ? null : F(this, K, "f").get(n) ?? null;
|
|
1066
|
+
}
|
|
1067
|
+
getExtension(t) {
|
|
1068
|
+
var i;
|
|
1069
|
+
return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && F(this, G, "f").get(t.trim().toLowerCase())) ?? null);
|
|
1070
|
+
}
|
|
1071
|
+
getAllExtensions(t) {
|
|
1072
|
+
return typeof t != "string" ? null : F(this, U, "f").get(t.toLowerCase()) ?? null;
|
|
1073
|
+
}
|
|
1074
|
+
_freeze() {
|
|
1075
|
+
this.define = () => {
|
|
1076
|
+
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
1077
|
+
}, Object.freeze(this);
|
|
1078
|
+
for (const t of F(this, U, "f").values())
|
|
1079
|
+
Object.freeze(t);
|
|
1080
|
+
return this;
|
|
1081
|
+
}
|
|
1082
|
+
_getTestState() {
|
|
1083
|
+
return {
|
|
1084
|
+
types: F(this, K, "f"),
|
|
1085
|
+
extensions: F(this, G, "f")
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap();
|
|
1090
|
+
const Pe = new Me(Wt)._freeze();
|
|
1091
|
+
function Ie(e) {
|
|
1092
|
+
const t = [], i = Object.keys(e);
|
|
1093
|
+
for (const n of i) {
|
|
1094
|
+
const s = e[n].sort((a, r) => a.index - r.index);
|
|
1095
|
+
for (let a = 0; a < s.length; a++)
|
|
1096
|
+
s[a].index !== a && t.push({
|
|
1097
|
+
message: `Invalid operation index ${s[a].index} at position ${a}`,
|
|
1098
|
+
details: {
|
|
1099
|
+
position: a,
|
|
1100
|
+
operation: s[a],
|
|
1101
|
+
scope: s[a].scope
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
return t;
|
|
1106
|
+
}
|
|
1107
|
+
const Bt = async (e) => {
|
|
1108
|
+
const t = new St(), { name: i, revision: n, documentType: s, created: a, lastModified: r } = e, p = {
|
|
1109
|
+
name: i,
|
|
1110
|
+
revision: n,
|
|
1111
|
+
documentType: s,
|
|
1112
|
+
created: a,
|
|
1113
|
+
lastModified: r
|
|
1114
|
+
};
|
|
1115
|
+
return t.file("header.json", JSON.stringify(p, null, 2)), t.file(
|
|
1116
|
+
"state.json",
|
|
1117
|
+
JSON.stringify(e.initialState || {}, null, 2)
|
|
1118
|
+
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((f) => {
|
|
1119
|
+
const { data: A, ...b } = e.attachments[f];
|
|
1120
|
+
t.file(f, A, {
|
|
1121
|
+
base64: !0,
|
|
1122
|
+
createFolders: !0,
|
|
1123
|
+
comment: JSON.stringify(b)
|
|
1124
|
+
});
|
|
1125
|
+
}), t;
|
|
1126
|
+
}, ze = async (e, t, i, n) => {
|
|
1127
|
+
const a = await (await Bt(e)).generateAsync({
|
|
1128
|
+
type: "uint8array",
|
|
1129
|
+
streamFiles: !0
|
|
1130
|
+
}), r = n ?? e.name, p = `.${i}.zip`;
|
|
1131
|
+
return Oe(
|
|
1132
|
+
t,
|
|
1133
|
+
r.endsWith(p) ? r : `${r}${p}`,
|
|
1134
|
+
a
|
|
1135
|
+
);
|
|
1136
|
+
}, Xe = async (e, t) => {
|
|
1137
|
+
const n = await (await Bt(e)).generateAsync({ type: "blob" }), s = await t.createWritable();
|
|
1138
|
+
await s.write(n), await s.close();
|
|
1139
|
+
}, jt = async (e, t) => {
|
|
1140
|
+
const i = Lt(e);
|
|
1141
|
+
return Fe(i, t);
|
|
1142
|
+
}, Fe = async (e, t) => {
|
|
1143
|
+
const i = new St();
|
|
1144
|
+
return await i.loadAsync(e), Re(i, t);
|
|
1145
|
+
};
|
|
1146
|
+
async function Re(e, t) {
|
|
1147
|
+
const i = e.file("state.json");
|
|
1148
|
+
if (!i)
|
|
1149
|
+
throw new Error("Initial state not found");
|
|
1150
|
+
const n = await i.async("string"), s = JSON.parse(n), a = e.file("header.json");
|
|
1151
|
+
let r;
|
|
1152
|
+
a && (r = JSON.parse(await a.async("string")));
|
|
1153
|
+
const p = e.file("operations.json");
|
|
1154
|
+
if (!p)
|
|
1155
|
+
throw new Error("Operations history not found");
|
|
1156
|
+
const d = JSON.parse(
|
|
1157
|
+
await p.async("string")
|
|
1158
|
+
), f = Ie(d);
|
|
1159
|
+
if (f.length) {
|
|
1160
|
+
const b = f.map((h) => h.message);
|
|
1161
|
+
throw new Error(b.join(`
|
|
1162
|
+
`));
|
|
1163
|
+
}
|
|
1164
|
+
let A = Ct(
|
|
1165
|
+
s,
|
|
1166
|
+
d,
|
|
1167
|
+
t,
|
|
1168
|
+
void 0,
|
|
1169
|
+
r
|
|
1170
|
+
);
|
|
1171
|
+
return r && (A = {
|
|
1172
|
+
...A,
|
|
1173
|
+
...r
|
|
1174
|
+
}), A;
|
|
1175
|
+
}
|
|
1176
|
+
function Zt(e) {
|
|
1177
|
+
const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
|
|
1178
|
+
return { extension: t, fileName: i };
|
|
1179
|
+
}
|
|
1180
|
+
async function Ye(e) {
|
|
1181
|
+
const { buffer: t, mimeType: i = "application/octet-stream" } = await $e(e), n = Zt(e), s = t.toString("base64");
|
|
1182
|
+
return {
|
|
1183
|
+
data: s,
|
|
1184
|
+
hash: at(s),
|
|
1185
|
+
mimeType: i,
|
|
1186
|
+
...n
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
async function ti(e) {
|
|
1190
|
+
const t = await Ee(e), i = Pe.getType(e) || "application/octet-stream", n = Zt(e), s = t.toString("base64");
|
|
1191
|
+
return { data: s, hash: at(s), mimeType: i, ...n };
|
|
1192
|
+
}
|
|
1193
|
+
class ei {
|
|
1194
|
+
/**
|
|
1195
|
+
* Constructs a BaseDocument instance with an initial state.
|
|
1196
|
+
* @param reducer - The reducer function that updates the state.
|
|
1197
|
+
* @param document - The initial state of the document.
|
|
1198
|
+
*/
|
|
1199
|
+
constructor(t, i, n) {
|
|
1200
|
+
nt(this, "_document");
|
|
1201
|
+
nt(this, "_reducer");
|
|
1202
|
+
nt(this, "_signalDispatch");
|
|
1203
|
+
this._reducer = t, this._document = i, this._signalDispatch = n;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Dispatches an action to update the state of the document.
|
|
1207
|
+
* @param action - The action to dispatch.
|
|
1208
|
+
* @returns The Document instance.
|
|
1209
|
+
*/
|
|
1210
|
+
dispatch(t, i) {
|
|
1211
|
+
return this._document = this._reducer(
|
|
1212
|
+
this._document,
|
|
1213
|
+
t,
|
|
1214
|
+
this._signalDispatch,
|
|
1215
|
+
i
|
|
1216
|
+
), this;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Saves the state of the document to a file.
|
|
1220
|
+
* @param path - The file path where the state should be saved.
|
|
1221
|
+
* @param extension - The file extension to use when saving the state.
|
|
1222
|
+
* @returns The file path where the state was saved.
|
|
1223
|
+
*/
|
|
1224
|
+
saveToFile(t, i, n) {
|
|
1225
|
+
return ze(this._document, t, i, n);
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Loads the state of the document from a file.
|
|
1229
|
+
* @param path - The file path where the state is stored.
|
|
1230
|
+
*/
|
|
1231
|
+
async loadFromFile(t) {
|
|
1232
|
+
this._document = await jt(t, this._reducer);
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Loads the state of the document from a file and returns it.
|
|
1236
|
+
* @param path - The file path where the state is stored.
|
|
1237
|
+
* @param reducer - The reducer function that updates the state.
|
|
1238
|
+
* @returns The state of the document.
|
|
1239
|
+
*/
|
|
1240
|
+
static async stateFromFile(t, i) {
|
|
1241
|
+
return await jt(t, i);
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Gets the current state of the document.
|
|
1245
|
+
*/
|
|
1246
|
+
get state() {
|
|
1247
|
+
return ot(this._document.state);
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Gets the list of operations performed on the document.
|
|
1251
|
+
*/
|
|
1252
|
+
get operations() {
|
|
1253
|
+
return ot(this._document.operations);
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Gets the name of the document.
|
|
1257
|
+
*/
|
|
1258
|
+
get name() {
|
|
1259
|
+
return this._document.name;
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Gets the type of document.
|
|
1263
|
+
*/
|
|
1264
|
+
get documentType() {
|
|
1265
|
+
return this._document.documentType;
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Gets the timestamp of the date the document was created.
|
|
1269
|
+
*/
|
|
1270
|
+
get created() {
|
|
1271
|
+
return this._document.created;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Gets the timestamp of the date the document was last modified.
|
|
1275
|
+
*/
|
|
1276
|
+
get lastModified() {
|
|
1277
|
+
return this._document.lastModified;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Gets the global revision number of the document.
|
|
1281
|
+
*/
|
|
1282
|
+
get revision() {
|
|
1283
|
+
return this._document.revision.global;
|
|
1284
|
+
}
|
|
1285
|
+
getRevision(t) {
|
|
1286
|
+
return this._document.revision[t];
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Gets the initial state of the document.
|
|
1290
|
+
*/
|
|
1291
|
+
get initialState() {
|
|
1292
|
+
return ot(this._document.initialState);
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Returns the current document as an object
|
|
1296
|
+
*/
|
|
1297
|
+
toDocument() {
|
|
1298
|
+
return ot(this._document);
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Gets the attachment associated with the given key.
|
|
1302
|
+
* @param attachment - The key of the attachment to retrieve.
|
|
1303
|
+
*/
|
|
1304
|
+
getAttachment(t) {
|
|
1305
|
+
return this._document.attachments[t];
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Sets the name of the document.
|
|
1309
|
+
* @param name - The new name of the document.
|
|
1310
|
+
*/
|
|
1311
|
+
setName(t) {
|
|
1312
|
+
return this.dispatch(Jt(t)), this;
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Reverts a number of actions from the document.
|
|
1316
|
+
* @param count - The number of actions to revert.
|
|
1317
|
+
*/
|
|
1318
|
+
undo(t) {
|
|
1319
|
+
return this.dispatch(Ut(t)), this;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Reapplies a number of actions to the document.
|
|
1323
|
+
* @param count - The number of actions to reapply.
|
|
1324
|
+
*/
|
|
1325
|
+
redo(t) {
|
|
1326
|
+
return this.dispatch(Vt(t)), this;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Removes a range of operations from the document.
|
|
1330
|
+
* @param start - The starting index of the range to remove.
|
|
1331
|
+
* @param end - The ending index of the range to remove.
|
|
1332
|
+
*/
|
|
1333
|
+
prune(t, i) {
|
|
1334
|
+
return this.dispatch(Kt(t, i)), this;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Loads a document state and a set of operations.
|
|
1338
|
+
* @param state - The state to load.
|
|
1339
|
+
* @param operations - The operations to apply to the document.
|
|
1340
|
+
*/
|
|
1341
|
+
loadState(t, i) {
|
|
1342
|
+
return this.dispatch(xt(t, i)), this;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
function ii(e, t) {
|
|
1346
|
+
t.forEach((i) => {
|
|
1347
|
+
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
1348
|
+
Object.defineProperty(
|
|
1349
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1350
|
+
e.prototype,
|
|
1351
|
+
n,
|
|
1352
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
1353
|
+
Object.getOwnPropertyDescriptor(i.prototype, n) || /* @__PURE__ */ Object.create(null)
|
|
1354
|
+
);
|
|
1355
|
+
});
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
export {
|
|
1359
|
+
Ie as A,
|
|
1360
|
+
ei as B,
|
|
1361
|
+
Rt as C,
|
|
1362
|
+
Se as D,
|
|
1363
|
+
Be as E,
|
|
1364
|
+
_e as a,
|
|
1365
|
+
ke as b,
|
|
1366
|
+
Te as c,
|
|
1367
|
+
Xe as d,
|
|
1368
|
+
Fe as e,
|
|
1369
|
+
W as f,
|
|
1370
|
+
ii as g,
|
|
1371
|
+
Qe as h,
|
|
1372
|
+
wt as i,
|
|
1373
|
+
Ne as j,
|
|
1374
|
+
Bt as k,
|
|
1375
|
+
jt as l,
|
|
1376
|
+
ti as m,
|
|
1377
|
+
Ye as n,
|
|
1378
|
+
qt as o,
|
|
1379
|
+
Ze as p,
|
|
1380
|
+
ve as q,
|
|
1381
|
+
He as r,
|
|
1382
|
+
ze as s,
|
|
1383
|
+
yt as t,
|
|
1384
|
+
Ae as u,
|
|
1385
|
+
ot as v,
|
|
1386
|
+
Ct as w,
|
|
1387
|
+
mt as x,
|
|
1388
|
+
De as y,
|
|
1389
|
+
Ge as z
|
|
1390
|
+
};
|