document-model 1.0.30 → 1.0.32
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 +2 -2
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +2 -2
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +3 -3
- package/dist/browser/internal/{index-B-7drCvN.js → index-B7qIPXoz.js} +1 -1
- package/dist/browser/internal/{index-BFLtpklA.js → index-BFOiHt6I.js} +1 -1
- package/dist/{node/internal/index-BevT9mtU.js → browser/internal/index-BVR8cGlp.js} +1 -1
- package/dist/browser/internal/index-DtMGoFXU.js +40 -0
- package/dist/browser/internal/{object-DCxjKS4C.js → object-Diya-yJS.js} +297 -274
- package/dist/browser/internal/{object-g08kById.js → object-O_qdzVL-.js} +3 -2
- package/dist/browser/src/document/types.d.ts +7 -1
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/browser/src/document/utils/validation.d.ts +2 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +2 -2
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +3 -3
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +3 -3
- package/dist/{browser/internal/index-_gFM9c3z.js → node/internal/index-Bxw-tgFs.js} +1 -1
- package/dist/node/internal/{index-CbWnG-mj.js → index-C-NbJIDm.js} +1 -1
- package/dist/node/internal/{index-BNOB79wS.js → index-CsNA2GBY.js} +1 -1
- package/dist/node/internal/index-Ly6V0vGQ.js +40 -0
- package/dist/node/internal/object-DyU92wWO.js +2 -0
- package/dist/node/internal/{object-l76vs_od.js → object-usT57J9v.js} +289 -266
- package/dist/node/src/document/types.d.ts +7 -1
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/dist/node/src/document/utils/validation.d.ts +2 -0
- package/package.json +1 -1
- package/dist/browser/internal/index-FwxURTAn.js +0 -39
- package/dist/node/internal/index-JCxY4diP.js +0 -39
- package/dist/node/internal/object-DULiHJNK.js +0 -1
|
@@ -3,24 +3,24 @@ var wt = (e, t, i) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var E = (e, t, i) => (wt(e, typeof t != "symbol" ? t + "" : t, i), i);
|
|
4
4
|
import { produce as k, castDraft as A, castImmutable as vt, freeze as yt } from "immer";
|
|
5
5
|
import jt from "json-stringify-deterministic";
|
|
6
|
-
import { z as
|
|
6
|
+
import { z as c } from "zod";
|
|
7
7
|
import Ot from "crypto";
|
|
8
8
|
import z from "fs";
|
|
9
9
|
import kt from "https";
|
|
10
10
|
import { join as St } from "path";
|
|
11
11
|
import B from "jszip";
|
|
12
|
-
const Z = (e) => e != null, _t =
|
|
12
|
+
const Z = (e) => e != null, _t = c.any().refine((e) => Z(e)), H = c.enum(["LOAD_STATE"]), K = c.enum(["PRUNE"]), V = c.enum(["REDO"]), G = c.enum(["SET_NAME"]), Q = c.enum(["UNDO"]);
|
|
13
13
|
function Et() {
|
|
14
|
-
return
|
|
15
|
-
__typename:
|
|
16
|
-
type:
|
|
14
|
+
return c.object({
|
|
15
|
+
__typename: c.literal("Action").optional(),
|
|
16
|
+
type: c.string()
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function S() {
|
|
20
|
-
return
|
|
20
|
+
return c.literal("global").or(c.literal("local"));
|
|
21
21
|
}
|
|
22
22
|
function X() {
|
|
23
|
-
return
|
|
23
|
+
return c.union([
|
|
24
24
|
Y(),
|
|
25
25
|
et(),
|
|
26
26
|
it(),
|
|
@@ -29,90 +29,90 @@ function X() {
|
|
|
29
29
|
]);
|
|
30
30
|
}
|
|
31
31
|
function Dt() {
|
|
32
|
-
return
|
|
33
|
-
__typename:
|
|
34
|
-
data:
|
|
35
|
-
extension:
|
|
36
|
-
fileName:
|
|
37
|
-
mimeType:
|
|
32
|
+
return c.object({
|
|
33
|
+
__typename: c.literal("DocumentFile").optional(),
|
|
34
|
+
data: c.string(),
|
|
35
|
+
extension: c.string().nullable(),
|
|
36
|
+
fileName: c.string().nullable(),
|
|
37
|
+
mimeType: c.string()
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function Y() {
|
|
41
|
-
return
|
|
42
|
-
input:
|
|
41
|
+
return c.object({
|
|
42
|
+
input: c.lazy(() => P()),
|
|
43
43
|
type: H,
|
|
44
44
|
scope: S()
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
function P() {
|
|
48
|
-
return
|
|
49
|
-
operations:
|
|
50
|
-
state:
|
|
48
|
+
return c.object({
|
|
49
|
+
operations: c.number(),
|
|
50
|
+
state: c.lazy(() => tt())
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
function tt() {
|
|
54
|
-
return
|
|
55
|
-
data:
|
|
56
|
-
name:
|
|
54
|
+
return c.object({
|
|
55
|
+
data: c.unknown().nullish(),
|
|
56
|
+
name: c.string()
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
function Nt() {
|
|
60
|
-
return
|
|
61
|
-
__typename:
|
|
62
|
-
hash:
|
|
63
|
-
index:
|
|
64
|
-
timestamp:
|
|
65
|
-
type:
|
|
60
|
+
return c.object({
|
|
61
|
+
__typename: c.literal("Operation").optional(),
|
|
62
|
+
hash: c.string(),
|
|
63
|
+
index: c.number(),
|
|
64
|
+
timestamp: c.string().datetime(),
|
|
65
|
+
type: c.string()
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
function et() {
|
|
69
|
-
return
|
|
70
|
-
input:
|
|
69
|
+
return c.object({
|
|
70
|
+
input: c.lazy(() => I()),
|
|
71
71
|
type: K,
|
|
72
72
|
scope: S()
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
77
|
-
end:
|
|
78
|
-
start:
|
|
75
|
+
function I() {
|
|
76
|
+
return c.object({
|
|
77
|
+
end: c.number().nullish(),
|
|
78
|
+
start: c.number().nullish()
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const F = c.number;
|
|
82
82
|
function it() {
|
|
83
|
-
return
|
|
84
|
-
input:
|
|
83
|
+
return c.object({
|
|
84
|
+
input: F(),
|
|
85
85
|
type: V,
|
|
86
86
|
scope: S()
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const R =
|
|
89
|
+
const R = c.string;
|
|
90
90
|
function at() {
|
|
91
|
-
return
|
|
91
|
+
return c.object({
|
|
92
92
|
input: R(),
|
|
93
93
|
type: G,
|
|
94
|
-
scope:
|
|
94
|
+
scope: c.literal("global")
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function Tt() {
|
|
98
|
-
return
|
|
99
|
-
__typename:
|
|
100
|
-
hash:
|
|
101
|
-
index:
|
|
102
|
-
input:
|
|
103
|
-
timestamp:
|
|
104
|
-
type:
|
|
98
|
+
return c.object({
|
|
99
|
+
__typename: c.literal("SetNameOperation").optional(),
|
|
100
|
+
hash: c.string(),
|
|
101
|
+
index: c.number(),
|
|
102
|
+
input: c.string(),
|
|
103
|
+
timestamp: c.string().datetime(),
|
|
104
|
+
type: c.string()
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
const q =
|
|
107
|
+
const q = c.number;
|
|
108
108
|
function nt() {
|
|
109
|
-
return
|
|
109
|
+
return c.object({
|
|
110
110
|
input: q(),
|
|
111
111
|
type: Q,
|
|
112
112
|
scope: S()
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
116
116
|
__proto__: null,
|
|
117
117
|
ActionSchema: Et,
|
|
118
118
|
BaseActionSchema: X,
|
|
@@ -123,10 +123,10 @@ const de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
123
123
|
Load_StateSchema: H,
|
|
124
124
|
OperationSchema: Nt,
|
|
125
125
|
OperationScopeSchema: S,
|
|
126
|
-
PruneActionInputSchema:
|
|
126
|
+
PruneActionInputSchema: I,
|
|
127
127
|
PruneActionSchema: et,
|
|
128
128
|
PruneSchema: K,
|
|
129
|
-
RedoActionInputSchema:
|
|
129
|
+
RedoActionInputSchema: F,
|
|
130
130
|
RedoActionSchema: it,
|
|
131
131
|
RedoSchema: V,
|
|
132
132
|
SetNameActionInputSchema: R,
|
|
@@ -146,93 +146,93 @@ function zt(e, t, i) {
|
|
|
146
146
|
const a = {
|
|
147
147
|
skip: i,
|
|
148
148
|
document: e
|
|
149
|
-
}, { scope:
|
|
150
|
-
return !
|
|
151
|
-
const [
|
|
152
|
-
t.skip && t.skip > 0 && (
|
|
149
|
+
}, { scope: n } = t;
|
|
150
|
+
return !n || t.skip === void 0 ? a : k(a, (s) => {
|
|
151
|
+
const [o] = s.document.operations[n].slice(-1);
|
|
152
|
+
t.skip && t.skip > 0 && (s.skip = t.skip), o.type === "NOOP" && t.index === o.index && s.skip > o.skip && s.document.operations[n].pop();
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
function Mt(e, t, i) {
|
|
156
|
-
const { scope: a, input:
|
|
156
|
+
const { scope: a, input: n } = t;
|
|
157
157
|
return k({
|
|
158
158
|
document: e,
|
|
159
159
|
action: t,
|
|
160
160
|
skip: i
|
|
161
|
-
}, (
|
|
162
|
-
if (
|
|
161
|
+
}, (o) => {
|
|
162
|
+
if (o.document.operations[a].length < 1)
|
|
163
163
|
throw new Error(
|
|
164
164
|
`Cannot undo: no operations in history for scope "${a}"`
|
|
165
165
|
);
|
|
166
|
-
if (
|
|
166
|
+
if (n < 1)
|
|
167
167
|
throw new Error(
|
|
168
168
|
"Invalid UNDO action: input value must be greater than 0"
|
|
169
169
|
);
|
|
170
|
-
if (
|
|
170
|
+
if (o.skip > 0)
|
|
171
171
|
throw new Error(
|
|
172
172
|
"Cannot undo: skip value from reducer cannot be used with UNDO action"
|
|
173
173
|
);
|
|
174
|
-
const [
|
|
175
|
-
if (
|
|
174
|
+
const [p] = o.document.operations[a].slice(-1), r = p.type === "NOOP" && p.skip > 0;
|
|
175
|
+
if (o.skip += n, r && (o.skip += p.skip, o.document.operations[a].pop()), o.document.operations[a].length < o.skip)
|
|
176
176
|
throw new Error(
|
|
177
177
|
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
178
178
|
);
|
|
179
|
-
const l =
|
|
180
|
-
let
|
|
181
|
-
for (;
|
|
182
|
-
const
|
|
183
|
-
|
|
179
|
+
const l = o.document.operations[a].length - 1;
|
|
180
|
+
let f = n, m = r ? l - p.skip : l;
|
|
181
|
+
for (; f > 0 && m >= 0; ) {
|
|
182
|
+
const u = o.document.operations[a][m];
|
|
183
|
+
u.type === "NOOP" && u.skip > 0 ? (m = m - (u.skip + 1), o.skip += u.skip + 1) : (o.document.clipboard.push({ ...u }), f--, m--);
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
o.action = U(a);
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
function Pt(e, t, i) {
|
|
189
|
-
const { scope: a, input:
|
|
189
|
+
const { scope: a, input: n } = t;
|
|
190
190
|
return k({
|
|
191
191
|
document: e,
|
|
192
192
|
action: t,
|
|
193
193
|
skip: i
|
|
194
|
-
}, (
|
|
195
|
-
if (
|
|
194
|
+
}, (o) => {
|
|
195
|
+
if (o.skip > 0)
|
|
196
196
|
throw new Error(
|
|
197
197
|
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
198
198
|
);
|
|
199
|
-
if (
|
|
199
|
+
if (n > 1)
|
|
200
200
|
throw new Error(
|
|
201
201
|
"Cannot redo: you can only redo one operation at a time"
|
|
202
202
|
);
|
|
203
|
-
if (
|
|
203
|
+
if (n < 1)
|
|
204
204
|
throw new Error("Invalid REDO action: invalid redo input value");
|
|
205
|
-
if (
|
|
205
|
+
if (o.document.clipboard.length < 1)
|
|
206
206
|
throw new Error("Cannot redo: no operations in the clipboard");
|
|
207
|
-
const
|
|
207
|
+
const p = o.document.clipboard.findLastIndex(
|
|
208
208
|
(l) => l.scope === a
|
|
209
209
|
);
|
|
210
|
-
if (
|
|
210
|
+
if (p < 0)
|
|
211
211
|
throw new Error(
|
|
212
212
|
`Cannot redo: no operations in clipboard for scope "${a}"`
|
|
213
213
|
);
|
|
214
|
-
const r =
|
|
215
|
-
|
|
214
|
+
const r = o.document.clipboard.splice(p, 1)[0];
|
|
215
|
+
o.action = A({
|
|
216
216
|
type: r.type,
|
|
217
217
|
scope: r.scope,
|
|
218
218
|
input: r.input
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
const { scope: a } = t,
|
|
222
|
+
function It(e, t, i) {
|
|
223
|
+
const { scope: a } = t, n = e.operations[a];
|
|
224
224
|
let {
|
|
225
|
-
input: { start:
|
|
225
|
+
input: { start: s, end: o }
|
|
226
226
|
} = t;
|
|
227
|
-
|
|
228
|
-
const
|
|
227
|
+
s = s || 0, o = o || n.length;
|
|
228
|
+
const p = n.slice(s, o), r = n.slice(0, s), l = n.slice(o), f = M(
|
|
229
229
|
e.initialState,
|
|
230
230
|
{
|
|
231
231
|
...e.operations,
|
|
232
|
-
[a]: r.concat(
|
|
232
|
+
[a]: r.concat(p)
|
|
233
233
|
},
|
|
234
234
|
i
|
|
235
|
-
), { name: m, state:
|
|
235
|
+
), { name: m, state: u } = f, d = r.length, j = r.length ? r[r.length - 1].timestamp : l.length ? l[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
236
236
|
return M(
|
|
237
237
|
e.initialState,
|
|
238
238
|
{
|
|
@@ -241,23 +241,23 @@ function Ft(e, t, i) {
|
|
|
241
241
|
...r,
|
|
242
242
|
{
|
|
243
243
|
...L(
|
|
244
|
-
{ name: m, state:
|
|
245
|
-
|
|
244
|
+
{ name: m, state: u },
|
|
245
|
+
p.length
|
|
246
246
|
),
|
|
247
247
|
timestamp: j,
|
|
248
|
-
index:
|
|
249
|
-
hash: lt({ state:
|
|
248
|
+
index: d,
|
|
249
|
+
hash: lt({ state: u }, "global")
|
|
250
250
|
},
|
|
251
251
|
...l.map((h, T) => ({
|
|
252
252
|
...h,
|
|
253
|
-
index:
|
|
253
|
+
index: d + T + 1
|
|
254
254
|
}))
|
|
255
255
|
]
|
|
256
256
|
},
|
|
257
257
|
i
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ft(e, t) {
|
|
261
261
|
return {
|
|
262
262
|
...e,
|
|
263
263
|
name: t.name,
|
|
@@ -282,34 +282,34 @@ function Lt(e, t) {
|
|
|
282
282
|
function Ut(e, t, i = 0) {
|
|
283
283
|
if ([w, v, _].includes(t.type))
|
|
284
284
|
return e;
|
|
285
|
-
const { scope: a } = t,
|
|
285
|
+
const { scope: a } = t, n = e.operations[a].slice(
|
|
286
286
|
0,
|
|
287
287
|
e.revision[a]
|
|
288
288
|
);
|
|
289
|
-
return
|
|
289
|
+
return n.push({
|
|
290
290
|
...t,
|
|
291
|
-
index:
|
|
291
|
+
index: n.length,
|
|
292
292
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
293
293
|
hash: "",
|
|
294
294
|
scope: a,
|
|
295
295
|
skip: i
|
|
296
296
|
}), {
|
|
297
297
|
...e,
|
|
298
|
-
operations: { ...e.operations, [a]:
|
|
298
|
+
operations: { ...e.operations, [a]: n }
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function $t(e, t, i = 0) {
|
|
302
302
|
let a = Ut(e, t, i);
|
|
303
303
|
return a = Lt(a, t), a;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function Ct(e, t, i) {
|
|
306
306
|
switch (X().parse(t), t.type) {
|
|
307
307
|
case ot:
|
|
308
308
|
return At(e, t.input);
|
|
309
309
|
case _:
|
|
310
|
-
return
|
|
310
|
+
return It(e, t, i);
|
|
311
311
|
case st:
|
|
312
|
-
return
|
|
312
|
+
return Ft(e, t.input.state);
|
|
313
313
|
default:
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
@@ -324,48 +324,48 @@ function Jt(e, t, i) {
|
|
|
324
324
|
return { document: e, action: t, skip: i };
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
function pt(e, t, i, a,
|
|
328
|
-
const { skip:
|
|
329
|
-
let
|
|
330
|
-
if (Ht(
|
|
331
|
-
const { document: m, skip:
|
|
332
|
-
r =
|
|
327
|
+
function pt(e, t, i, a, n = {}) {
|
|
328
|
+
const { skip: s, ignoreSkipOperations: o = !1 } = n;
|
|
329
|
+
let p = { ...t }, r = s || 0, l = e, f = [...e.clipboard];
|
|
330
|
+
if (Ht(p)) {
|
|
331
|
+
const { document: m, skip: u } = zt(l, p, r);
|
|
332
|
+
r = u, l = m;
|
|
333
333
|
}
|
|
334
|
-
if (
|
|
334
|
+
if (C(p)) {
|
|
335
335
|
const {
|
|
336
336
|
skip: m,
|
|
337
|
-
action:
|
|
338
|
-
document:
|
|
339
|
-
} = Jt(e,
|
|
340
|
-
|
|
337
|
+
action: u,
|
|
338
|
+
document: d
|
|
339
|
+
} = Jt(e, p, r);
|
|
340
|
+
p = u, r = m, l = d, f = [...l.clipboard];
|
|
341
341
|
}
|
|
342
|
-
return J(
|
|
342
|
+
return J(p) && (l = Ct(l, p, i)), r > 0 && !o && (l = M(
|
|
343
343
|
l.initialState,
|
|
344
344
|
l.operations,
|
|
345
345
|
i,
|
|
346
346
|
void 0,
|
|
347
347
|
void 0,
|
|
348
348
|
void 0,
|
|
349
|
-
{ [
|
|
350
|
-
)), l =
|
|
351
|
-
const
|
|
349
|
+
{ [p.scope]: r }
|
|
350
|
+
)), l = $t(l, p, r), l = k(l, (m) => {
|
|
351
|
+
const u = i(
|
|
352
352
|
m.state,
|
|
353
|
-
|
|
353
|
+
p,
|
|
354
354
|
a
|
|
355
|
-
),
|
|
356
|
-
if (
|
|
355
|
+
), d = C(t) ? [...f] : [];
|
|
356
|
+
if (u)
|
|
357
357
|
return A({
|
|
358
358
|
...l,
|
|
359
|
-
clipboard: [...
|
|
360
|
-
state:
|
|
359
|
+
clipboard: [...d],
|
|
360
|
+
state: u
|
|
361
361
|
});
|
|
362
|
-
m.clipboard = A([...
|
|
362
|
+
m.clipboard = A([...d]);
|
|
363
363
|
}), k(l, (m) => {
|
|
364
|
-
if ([w, v, _].includes(
|
|
364
|
+
if ([w, v, _].includes(p.type))
|
|
365
365
|
return m;
|
|
366
|
-
const
|
|
367
|
-
m.operations[
|
|
368
|
-
const { hash: j, ...h } =
|
|
366
|
+
const u = p.scope || "global";
|
|
367
|
+
m.operations[u][m.operations[u].length - 1].hash = lt(m, u), !J(p) && p.attachments && p.attachments.forEach((d) => {
|
|
368
|
+
const { hash: j, ...h } = d;
|
|
369
369
|
m.attachments[j] = {
|
|
370
370
|
...h
|
|
371
371
|
};
|
|
@@ -374,13 +374,13 @@ function pt(e, t, i, a, o = {}) {
|
|
|
374
374
|
}
|
|
375
375
|
function Wt(e, t, i) {
|
|
376
376
|
const a = St(e, t);
|
|
377
|
-
return z.mkdirSync(e, { recursive: !0 }), new Promise((
|
|
377
|
+
return z.mkdirSync(e, { recursive: !0 }), new Promise((n, s) => {
|
|
378
378
|
try {
|
|
379
|
-
z.writeFile(a, i, {}, (
|
|
380
|
-
|
|
379
|
+
z.writeFile(a, i, {}, (o) => {
|
|
380
|
+
o ? s(o) : n(a);
|
|
381
381
|
});
|
|
382
|
-
} catch (
|
|
383
|
-
|
|
382
|
+
} catch (o) {
|
|
383
|
+
s(o);
|
|
384
384
|
}
|
|
385
385
|
});
|
|
386
386
|
}
|
|
@@ -390,11 +390,11 @@ function ct(e) {
|
|
|
390
390
|
function Bt(e) {
|
|
391
391
|
return new Promise((t, i) => {
|
|
392
392
|
kt.get(e, (a) => {
|
|
393
|
-
const
|
|
394
|
-
a.on("data", (
|
|
395
|
-
|
|
393
|
+
const n = [], s = a.headers["content-type"];
|
|
394
|
+
a.on("data", (o) => {
|
|
395
|
+
n.push(o);
|
|
396
396
|
}), a.on("end", () => {
|
|
397
|
-
t({ buffer: Buffer.concat(
|
|
397
|
+
t({ buffer: Buffer.concat(n), mimeType: s });
|
|
398
398
|
});
|
|
399
399
|
}).on("error", (a) => {
|
|
400
400
|
i(a);
|
|
@@ -405,28 +405,28 @@ const Zt = async (e) => ct(e), N = (e, t = "sha1") => Ot.createHash(t).update(e)
|
|
|
405
405
|
function Ht(e) {
|
|
406
406
|
return e.type === Rt && e.skip !== void 0 && e.skip > 0 && e.hash !== void 0;
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function C(e) {
|
|
409
409
|
return [w, v].includes(e.type);
|
|
410
410
|
}
|
|
411
411
|
function J(e) {
|
|
412
412
|
return [ot, w, v, _, st].includes(e.type);
|
|
413
413
|
}
|
|
414
|
-
function y(e, t, i, a,
|
|
414
|
+
function y(e, t, i, a, n = "global") {
|
|
415
415
|
if (!e)
|
|
416
416
|
throw new Error("Empty action type");
|
|
417
417
|
if (typeof e != "string")
|
|
418
418
|
throw new Error(`Invalid action type: ${e}`);
|
|
419
|
-
const
|
|
420
|
-
i && (
|
|
419
|
+
const s = { type: e, input: t, scope: n };
|
|
420
|
+
i && (s.attachments = i);
|
|
421
421
|
try {
|
|
422
|
-
a == null || a().parse(
|
|
423
|
-
} catch (
|
|
424
|
-
throw new Error(`Invalid action input: ${
|
|
422
|
+
a == null || a().parse(s.input);
|
|
423
|
+
} catch (o) {
|
|
424
|
+
throw new Error(`Invalid action input: ${o}`);
|
|
425
425
|
}
|
|
426
|
-
return
|
|
426
|
+
return s;
|
|
427
427
|
}
|
|
428
428
|
function Kt(e, t = pt) {
|
|
429
|
-
return (i, a,
|
|
429
|
+
return (i, a, n, s) => t(i, a, e, n, s);
|
|
430
430
|
}
|
|
431
431
|
const Vt = (e, t) => ({
|
|
432
432
|
name: "",
|
|
@@ -451,7 +451,7 @@ const Vt = (e, t) => ({
|
|
|
451
451
|
operations: { global: [], local: [] },
|
|
452
452
|
clipboard: []
|
|
453
453
|
};
|
|
454
|
-
}, lt = (e, t = "global") => N(jt(e.state[t])),
|
|
454
|
+
}, lt = (e, t = "global") => N(jt(e.state[t])), xe = (e, t = 1e3) => {
|
|
455
455
|
const i = Math.random() * t;
|
|
456
456
|
return N(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
457
457
|
};
|
|
@@ -460,28 +460,28 @@ function D(e) {
|
|
|
460
460
|
}
|
|
461
461
|
function Qt(e, t) {
|
|
462
462
|
const i = [...e];
|
|
463
|
-
let a = t || 0,
|
|
464
|
-
const
|
|
465
|
-
for (const
|
|
463
|
+
let a = t || 0, n = i.length > 0 ? i[i.length - 1].index : 0;
|
|
464
|
+
const s = [];
|
|
465
|
+
for (const o of i.reverse()) {
|
|
466
466
|
if (a > 0) {
|
|
467
|
-
const l =
|
|
467
|
+
const l = n - o.index;
|
|
468
468
|
a -= l;
|
|
469
469
|
}
|
|
470
470
|
if (a < 0)
|
|
471
471
|
throw new Error("Invalid operation index, missing operations");
|
|
472
|
-
const
|
|
472
|
+
const p = {
|
|
473
473
|
ignore: a > 0,
|
|
474
|
-
operation:
|
|
475
|
-
}, r =
|
|
474
|
+
operation: o
|
|
475
|
+
}, r = o.skip > 0 ? o.skip + 1 : 0;
|
|
476
476
|
if (r > 0 && r > a) {
|
|
477
477
|
const l = r - a;
|
|
478
478
|
a = a + l;
|
|
479
479
|
}
|
|
480
|
-
|
|
480
|
+
n = o.index, s.push(p);
|
|
481
481
|
}
|
|
482
|
-
return
|
|
482
|
+
return s.reverse();
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function ge(e) {
|
|
485
485
|
return Object.values(e).flatMap((t) => t).sort(
|
|
486
486
|
(t, i) => new Date(t.timestamp).getTime() - new Date(i.timestamp).getTime()
|
|
487
487
|
);
|
|
@@ -491,58 +491,58 @@ function Xt(e) {
|
|
|
491
491
|
(t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
|
-
function M(e, t, i, a,
|
|
495
|
-
const
|
|
494
|
+
function M(e, t, i, a, n, s = pt, o = {}) {
|
|
495
|
+
const p = Kt(i, s);
|
|
496
496
|
return rt(
|
|
497
497
|
e,
|
|
498
498
|
t,
|
|
499
|
-
|
|
499
|
+
p,
|
|
500
500
|
a,
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
n,
|
|
502
|
+
o
|
|
503
503
|
);
|
|
504
504
|
}
|
|
505
|
-
function rt(e, t, i, a,
|
|
506
|
-
const
|
|
507
|
-
const
|
|
505
|
+
function rt(e, t, i, a, n, s = {}) {
|
|
506
|
+
const o = Gt(e), p = Object.keys(t).reduce((m, u) => {
|
|
507
|
+
const d = u;
|
|
508
508
|
return {
|
|
509
509
|
...m,
|
|
510
|
-
[
|
|
510
|
+
[d]: t[d].slice(0, n == null ? void 0 : n.revision[d])
|
|
511
511
|
};
|
|
512
|
-
}, {}), r = Object.keys(
|
|
513
|
-
(m,
|
|
514
|
-
const
|
|
512
|
+
}, {}), r = Object.keys(p).reduce(
|
|
513
|
+
(m, u) => {
|
|
514
|
+
const d = u;
|
|
515
515
|
return {
|
|
516
516
|
...m,
|
|
517
|
-
[
|
|
518
|
-
|
|
519
|
-
|
|
517
|
+
[d]: Qt(
|
|
518
|
+
p[d],
|
|
519
|
+
s[d]
|
|
520
520
|
)
|
|
521
521
|
};
|
|
522
522
|
},
|
|
523
523
|
{}
|
|
524
524
|
), l = Xt(r).reduce(
|
|
525
|
-
(m, { ignore:
|
|
526
|
-
skip:
|
|
525
|
+
(m, { ignore: u, operation: d }) => u ? i(m, U(d.scope), a, {
|
|
526
|
+
skip: d.skip,
|
|
527
527
|
ignoreSkipOperations: !0
|
|
528
|
-
}) : i(m,
|
|
529
|
-
skip:
|
|
528
|
+
}) : i(m, d, a, {
|
|
529
|
+
skip: d.skip,
|
|
530
530
|
ignoreSkipOperations: !0
|
|
531
531
|
}),
|
|
532
|
-
|
|
533
|
-
),
|
|
532
|
+
o
|
|
533
|
+
), f = Object.keys(
|
|
534
534
|
l.operations
|
|
535
535
|
).reduce(
|
|
536
|
-
(m,
|
|
537
|
-
const
|
|
536
|
+
(m, u) => {
|
|
537
|
+
const d = u, j = n && n.revision[d] < t[d].length ? t[d].slice(n.revision[d]) : [];
|
|
538
538
|
return {
|
|
539
539
|
...m,
|
|
540
|
-
[
|
|
541
|
-
...l.operations[
|
|
542
|
-
var
|
|
540
|
+
[d]: [
|
|
541
|
+
...l.operations[d].map((h, T) => {
|
|
542
|
+
var $;
|
|
543
543
|
return {
|
|
544
544
|
...h,
|
|
545
|
-
timestamp: ((
|
|
545
|
+
timestamp: (($ = t[d][T]) == null ? void 0 : $.timestamp) ?? h.timestamp
|
|
546
546
|
};
|
|
547
547
|
}),
|
|
548
548
|
...j
|
|
@@ -551,7 +551,7 @@ function rt(e, t, i, a, o, c = {}) {
|
|
|
551
551
|
},
|
|
552
552
|
{ global: [], local: [] }
|
|
553
553
|
);
|
|
554
|
-
return { ...l, operations:
|
|
554
|
+
return { ...l, operations: f };
|
|
555
555
|
}
|
|
556
556
|
const mt = (e) => y(
|
|
557
557
|
"SET_NAME",
|
|
@@ -559,40 +559,40 @@ const mt = (e) => y(
|
|
|
559
559
|
void 0,
|
|
560
560
|
R,
|
|
561
561
|
void 0
|
|
562
|
-
),
|
|
562
|
+
), dt = (e = 1, t = "global") => y(
|
|
563
563
|
"UNDO",
|
|
564
564
|
e,
|
|
565
565
|
void 0,
|
|
566
566
|
q,
|
|
567
567
|
t
|
|
568
|
-
),
|
|
568
|
+
), ut = (e = 1, t = "global") => y(
|
|
569
569
|
"REDO",
|
|
570
570
|
e,
|
|
571
571
|
void 0,
|
|
572
|
-
|
|
572
|
+
F,
|
|
573
573
|
t
|
|
574
574
|
), ft = (e, t, i = "global") => y(
|
|
575
575
|
"PRUNE",
|
|
576
576
|
{ start: e, end: t },
|
|
577
577
|
void 0,
|
|
578
|
-
|
|
578
|
+
I,
|
|
579
579
|
i
|
|
580
580
|
), L = (e, t) => y(
|
|
581
581
|
"LOAD_STATE",
|
|
582
582
|
{ state: e, operations: t },
|
|
583
583
|
void 0,
|
|
584
584
|
P
|
|
585
|
-
), U = (e = "global") => y("NOOP", {}, void 0, void 0, e),
|
|
585
|
+
), U = (e = "global") => y("NOOP", {}, void 0, void 0, e), he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
586
586
|
__proto__: null,
|
|
587
587
|
loadState: L,
|
|
588
588
|
noop: U,
|
|
589
589
|
prune: ft,
|
|
590
|
-
redo:
|
|
590
|
+
redo: ut,
|
|
591
591
|
setName: mt,
|
|
592
|
-
undo:
|
|
592
|
+
undo: dt
|
|
593
593
|
}, Symbol.toStringTag, { value: "Module" })), xt = { "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"] };
|
|
594
594
|
Object.freeze(xt);
|
|
595
|
-
var
|
|
595
|
+
var x = function(e, t, i, a) {
|
|
596
596
|
if (i === "a" && !a)
|
|
597
597
|
throw new TypeError("Private accessor was defined without a getter");
|
|
598
598
|
if (typeof t == "function" ? e !== t || !a : !t.has(e))
|
|
@@ -606,18 +606,18 @@ class Yt {
|
|
|
606
606
|
this.define(i);
|
|
607
607
|
}
|
|
608
608
|
define(t, i = !1) {
|
|
609
|
-
for (let [a,
|
|
610
|
-
a = a.toLowerCase(),
|
|
611
|
-
const
|
|
612
|
-
let
|
|
613
|
-
for (let
|
|
614
|
-
const r =
|
|
615
|
-
if (
|
|
609
|
+
for (let [a, n] of Object.entries(t)) {
|
|
610
|
+
a = a.toLowerCase(), n = n.map((p) => p.toLowerCase()), x(this, g, "f").has(a) || x(this, g, "f").set(a, /* @__PURE__ */ new Set());
|
|
611
|
+
const s = x(this, g, "f").get(a);
|
|
612
|
+
let o = !0;
|
|
613
|
+
for (let p of n) {
|
|
614
|
+
const r = p.startsWith("*");
|
|
615
|
+
if (p = r ? p.slice(1) : p, s == null || s.add(p), o && x(this, O, "f").set(a, p), o = !1, r)
|
|
616
616
|
continue;
|
|
617
|
-
const l =
|
|
617
|
+
const l = x(this, b, "f").get(p);
|
|
618
618
|
if (l && l != a && !i)
|
|
619
|
-
throw new Error(`"${a} -> ${
|
|
620
|
-
|
|
619
|
+
throw new Error(`"${a} -> ${p}" conflicts with "${l} -> ${p}". Pass \`force=true\` to override this definition.`);
|
|
620
|
+
x(this, b, "f").set(p, a);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
return this;
|
|
@@ -625,114 +625,136 @@ class Yt {
|
|
|
625
625
|
getType(t) {
|
|
626
626
|
if (typeof t != "string")
|
|
627
627
|
return null;
|
|
628
|
-
const i = t.replace(/^.*[/\\]/, "").toLowerCase(), a = i.replace(/^.*\./, "").toLowerCase(),
|
|
629
|
-
return !(a.length < i.length - 1) &&
|
|
628
|
+
const i = t.replace(/^.*[/\\]/, "").toLowerCase(), a = i.replace(/^.*\./, "").toLowerCase(), n = i.length < t.length;
|
|
629
|
+
return !(a.length < i.length - 1) && n ? null : x(this, b, "f").get(a) ?? null;
|
|
630
630
|
}
|
|
631
631
|
getExtension(t) {
|
|
632
632
|
var i;
|
|
633
|
-
return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t &&
|
|
633
|
+
return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && x(this, O, "f").get(t.trim().toLowerCase())) ?? null);
|
|
634
634
|
}
|
|
635
635
|
getAllExtensions(t) {
|
|
636
|
-
return typeof t != "string" ? null :
|
|
636
|
+
return typeof t != "string" ? null : x(this, g, "f").get(t.toLowerCase()) ?? null;
|
|
637
637
|
}
|
|
638
638
|
_freeze() {
|
|
639
639
|
this.define = () => {
|
|
640
640
|
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
641
641
|
}, Object.freeze(this);
|
|
642
|
-
for (const t of
|
|
642
|
+
for (const t of x(this, g, "f").values())
|
|
643
643
|
Object.freeze(t);
|
|
644
644
|
return this;
|
|
645
645
|
}
|
|
646
646
|
_getTestState() {
|
|
647
647
|
return {
|
|
648
|
-
types:
|
|
649
|
-
extensions:
|
|
648
|
+
types: x(this, b, "f"),
|
|
649
|
+
extensions: x(this, O, "f")
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap();
|
|
654
|
-
const te = new Yt(xt)._freeze()
|
|
655
|
-
|
|
654
|
+
const te = new Yt(xt)._freeze();
|
|
655
|
+
function ee(e) {
|
|
656
|
+
const t = [], i = Object.keys(e);
|
|
657
|
+
for (const a of i) {
|
|
658
|
+
const n = e[a].sort((s, o) => s.index - o.index);
|
|
659
|
+
for (let s = 0; s < n.length; s++)
|
|
660
|
+
n[s].index !== s && t.push({
|
|
661
|
+
message: `Invalid operation index ${n[s].index} at position ${s}`,
|
|
662
|
+
details: {
|
|
663
|
+
position: s,
|
|
664
|
+
operation: n[s],
|
|
665
|
+
scope: n[s].scope
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
return t;
|
|
670
|
+
}
|
|
671
|
+
const gt = async (e) => {
|
|
672
|
+
const t = new B(), { name: i, revision: a, documentType: n, created: s, lastModified: o } = e, p = {
|
|
656
673
|
name: i,
|
|
657
674
|
revision: a,
|
|
658
|
-
documentType:
|
|
659
|
-
created:
|
|
660
|
-
lastModified:
|
|
675
|
+
documentType: n,
|
|
676
|
+
created: s,
|
|
677
|
+
lastModified: o
|
|
661
678
|
};
|
|
662
|
-
return t.file("header.json", JSON.stringify(
|
|
679
|
+
return t.file("header.json", JSON.stringify(p, null, 2)), t.file(
|
|
663
680
|
"state.json",
|
|
664
681
|
JSON.stringify(e.initialState || {}, null, 2)
|
|
665
682
|
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((l) => {
|
|
666
|
-
const { data:
|
|
667
|
-
t.file(l,
|
|
683
|
+
const { data: f, ...m } = e.attachments[l];
|
|
684
|
+
t.file(l, f, {
|
|
668
685
|
base64: !0,
|
|
669
686
|
createFolders: !0,
|
|
670
687
|
comment: JSON.stringify(m)
|
|
671
688
|
});
|
|
672
689
|
}), t;
|
|
673
|
-
},
|
|
674
|
-
const
|
|
690
|
+
}, ie = async (e, t, i, a) => {
|
|
691
|
+
const s = await (await gt(e)).generateAsync({
|
|
675
692
|
type: "uint8array",
|
|
676
693
|
streamFiles: !0
|
|
677
|
-
}),
|
|
694
|
+
}), o = a ?? e.name, p = `.${i}.zip`;
|
|
678
695
|
return Wt(
|
|
679
696
|
t,
|
|
680
|
-
|
|
681
|
-
|
|
697
|
+
o.endsWith(p) ? o : `${o}${p}`,
|
|
698
|
+
s
|
|
682
699
|
);
|
|
683
|
-
},
|
|
684
|
-
const a = await (await gt(e)).generateAsync({ type: "blob" }),
|
|
685
|
-
await
|
|
700
|
+
}, be = async (e, t) => {
|
|
701
|
+
const a = await (await gt(e)).generateAsync({ type: "blob" }), n = await t.createWritable();
|
|
702
|
+
await n.write(a), await n.close();
|
|
686
703
|
}, W = async (e, t) => {
|
|
687
704
|
const i = ct(e);
|
|
688
|
-
return
|
|
689
|
-
},
|
|
705
|
+
return ae(i, t);
|
|
706
|
+
}, ae = async (e, t) => {
|
|
690
707
|
const i = new B();
|
|
691
|
-
return await i.loadAsync(e),
|
|
708
|
+
return await i.loadAsync(e), ne(i, t);
|
|
692
709
|
};
|
|
693
|
-
async function
|
|
710
|
+
async function ne(e, t) {
|
|
694
711
|
const i = e.file("state.json");
|
|
695
712
|
if (!i)
|
|
696
713
|
throw new Error("Initial state not found");
|
|
697
|
-
const a = await i.async("string"),
|
|
698
|
-
let
|
|
699
|
-
|
|
700
|
-
const
|
|
701
|
-
if (!
|
|
714
|
+
const a = await i.async("string"), n = JSON.parse(a), s = e.file("header.json");
|
|
715
|
+
let o;
|
|
716
|
+
s && (o = JSON.parse(await s.async("string")));
|
|
717
|
+
const p = e.file("operations.json");
|
|
718
|
+
if (!p)
|
|
702
719
|
throw new Error("Operations history not found");
|
|
703
720
|
const r = JSON.parse(
|
|
704
|
-
await
|
|
705
|
-
);
|
|
706
|
-
|
|
707
|
-
|
|
721
|
+
await p.async("string")
|
|
722
|
+
), l = ee(r);
|
|
723
|
+
if (l.length) {
|
|
724
|
+
const m = l.map((u) => u.message);
|
|
725
|
+
throw new Error(m.join(`
|
|
726
|
+
`));
|
|
727
|
+
}
|
|
728
|
+
let f = rt(
|
|
729
|
+
n,
|
|
708
730
|
r,
|
|
709
731
|
t,
|
|
710
732
|
void 0,
|
|
711
|
-
|
|
733
|
+
o
|
|
712
734
|
);
|
|
713
|
-
return
|
|
714
|
-
...
|
|
715
|
-
...
|
|
716
|
-
}),
|
|
735
|
+
return o && (f = {
|
|
736
|
+
...f,
|
|
737
|
+
...o
|
|
738
|
+
}), f;
|
|
717
739
|
}
|
|
718
740
|
function ht(e) {
|
|
719
741
|
const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
|
|
720
742
|
return { extension: t, fileName: i };
|
|
721
743
|
}
|
|
722
|
-
async function
|
|
723
|
-
const { buffer: t, mimeType: i = "application/octet-stream" } = await Bt(e), a = ht(e),
|
|
744
|
+
async function we(e) {
|
|
745
|
+
const { buffer: t, mimeType: i = "application/octet-stream" } = await Bt(e), a = ht(e), n = t.toString("base64");
|
|
724
746
|
return {
|
|
725
|
-
data:
|
|
726
|
-
hash: N(
|
|
747
|
+
data: n,
|
|
748
|
+
hash: N(n),
|
|
727
749
|
mimeType: i,
|
|
728
750
|
...a
|
|
729
751
|
};
|
|
730
752
|
}
|
|
731
|
-
async function
|
|
732
|
-
const t = await Zt(e), i = te.getType(e) || "application/octet-stream", a = ht(e),
|
|
733
|
-
return { data:
|
|
753
|
+
async function ve(e) {
|
|
754
|
+
const t = await Zt(e), i = te.getType(e) || "application/octet-stream", a = ht(e), n = t.toString("base64");
|
|
755
|
+
return { data: n, hash: N(n), mimeType: i, ...a };
|
|
734
756
|
}
|
|
735
|
-
class
|
|
757
|
+
class ye {
|
|
736
758
|
/**
|
|
737
759
|
* Constructs a BaseDocument instance with an initial state.
|
|
738
760
|
* @param reducer - The reducer function that updates the state.
|
|
@@ -764,7 +786,7 @@ class ve {
|
|
|
764
786
|
* @returns The file path where the state was saved.
|
|
765
787
|
*/
|
|
766
788
|
saveToFile(t, i, a) {
|
|
767
|
-
return
|
|
789
|
+
return ie(this._document, t, i, a);
|
|
768
790
|
}
|
|
769
791
|
/**
|
|
770
792
|
* Loads the state of the document from a file.
|
|
@@ -858,14 +880,14 @@ class ve {
|
|
|
858
880
|
* @param count - The number of actions to revert.
|
|
859
881
|
*/
|
|
860
882
|
undo(t) {
|
|
861
|
-
return this.dispatch(
|
|
883
|
+
return this.dispatch(dt(t)), this;
|
|
862
884
|
}
|
|
863
885
|
/**
|
|
864
886
|
* Reapplies a number of actions to the document.
|
|
865
887
|
* @param count - The number of actions to reapply.
|
|
866
888
|
*/
|
|
867
889
|
redo(t) {
|
|
868
|
-
return this.dispatch(
|
|
890
|
+
return this.dispatch(ut(t)), this;
|
|
869
891
|
}
|
|
870
892
|
/**
|
|
871
893
|
* Removes a range of operations from the document.
|
|
@@ -884,7 +906,7 @@ class ve {
|
|
|
884
906
|
return this.dispatch(L(t, i)), this;
|
|
885
907
|
}
|
|
886
908
|
}
|
|
887
|
-
function
|
|
909
|
+
function je(e, t) {
|
|
888
910
|
t.forEach((i) => {
|
|
889
911
|
Object.getOwnPropertyNames(i.prototype).forEach((a) => {
|
|
890
912
|
Object.defineProperty(
|
|
@@ -898,32 +920,33 @@ function ye(e, t) {
|
|
|
898
920
|
});
|
|
899
921
|
}
|
|
900
922
|
export {
|
|
901
|
-
|
|
902
|
-
|
|
923
|
+
Jt as A,
|
|
924
|
+
ye as B,
|
|
925
|
+
fe as C,
|
|
903
926
|
Vt as a,
|
|
904
927
|
Gt as b,
|
|
905
928
|
Kt as c,
|
|
906
|
-
|
|
907
|
-
|
|
929
|
+
be as d,
|
|
930
|
+
ae as e,
|
|
908
931
|
y as f,
|
|
909
|
-
|
|
910
|
-
|
|
932
|
+
je as g,
|
|
933
|
+
he as h,
|
|
911
934
|
J as i,
|
|
912
935
|
gt as j,
|
|
913
|
-
|
|
936
|
+
ve as k,
|
|
914
937
|
W as l,
|
|
915
|
-
|
|
938
|
+
we as m,
|
|
916
939
|
lt as n,
|
|
917
|
-
|
|
940
|
+
xe as o,
|
|
918
941
|
Ht as p,
|
|
919
|
-
|
|
942
|
+
C as q,
|
|
920
943
|
Qt as r,
|
|
921
|
-
|
|
944
|
+
ie as s,
|
|
922
945
|
D as t,
|
|
923
946
|
rt as u,
|
|
924
947
|
M as v,
|
|
925
948
|
Xt as w,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
949
|
+
ge as x,
|
|
950
|
+
ee as y,
|
|
951
|
+
pt as z
|
|
929
952
|
};
|