document-model 1.0.28 → 1.0.30
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 +8 -7
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +13 -9
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +13 -8
- package/dist/browser/internal/{index-oR1tzXEU.js → index-B-7drCvN.js} +1 -1
- package/dist/browser/internal/{index-qiOnVXbI.js → index-BFLtpklA.js} +1 -1
- package/dist/browser/internal/index-FwxURTAn.js +39 -0
- package/dist/browser/internal/index-_gFM9c3z.js +1 -0
- package/dist/browser/internal/{object-P7bHOWu_.js → object-DCxjKS4C.js} +629 -611
- package/dist/browser/internal/object-g08kById.js +6 -0
- package/dist/browser/src/document/actions/index.d.ts +5 -1
- package/dist/browser/src/document/actions/types.d.ts +1 -0
- package/dist/browser/src/document/utils/base.d.ts +1 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +11 -10
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +17 -9
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +17 -8
- package/dist/node/internal/{index-r_Cve_NX.js → index-BNOB79wS.js} +1 -1
- package/dist/node/internal/index-BevT9mtU.js +1 -0
- package/dist/node/internal/{index-uFGJxYP7.js → index-CbWnG-mj.js} +1 -1
- package/dist/node/internal/index-JCxY4diP.js +39 -0
- package/dist/node/internal/object-DULiHJNK.js +1 -0
- package/dist/node/internal/{object-qR4Tf50L.js → object-l76vs_od.js} +229 -211
- package/dist/node/src/document/actions/index.d.ts +5 -1
- package/dist/node/src/document/actions/types.d.ts +1 -0
- package/dist/node/src/document/utils/base.d.ts +1 -0
- package/package.json +6 -5
- package/dist/browser/internal/index-FBdtB-Z0.js +0 -38
- package/dist/browser/internal/index-MQO6aDba.js +0 -1
- package/dist/browser/internal/object-RV2GJjkF.js +0 -6
- package/dist/node/internal/index-E6Dehju3.js +0 -1
- package/dist/node/internal/index-Rc3pWGDQ.js +0 -38
- package/dist/node/internal/object-51-uoy0f.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var bt = Object.defineProperty;
|
|
2
2
|
var wt = (e, t, i) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
-
var
|
|
4
|
-
import { produce as
|
|
3
|
+
var E = (e, t, i) => (wt(e, typeof t != "symbol" ? t + "" : t, i), i);
|
|
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
6
|
import { z as p } from "zod";
|
|
7
7
|
import Ot from "crypto";
|
|
8
8
|
import z from "fs";
|
|
9
|
-
import
|
|
10
|
-
import { join as
|
|
9
|
+
import kt from "https";
|
|
10
|
+
import { join as St } from "path";
|
|
11
11
|
import B from "jszip";
|
|
12
|
-
const Z = (e) => e != null, _t = p.any().refine((e) => Z(e)), H = p.enum(["LOAD_STATE"]), K = p.enum(["PRUNE"]),
|
|
12
|
+
const Z = (e) => e != null, _t = p.any().refine((e) => Z(e)), H = p.enum(["LOAD_STATE"]), K = p.enum(["PRUNE"]), V = p.enum(["REDO"]), G = p.enum(["SET_NAME"]), Q = p.enum(["UNDO"]);
|
|
13
13
|
function Et() {
|
|
14
14
|
return p.object({
|
|
15
15
|
__typename: p.literal("Action").optional(),
|
|
@@ -39,12 +39,12 @@ function Dt() {
|
|
|
39
39
|
}
|
|
40
40
|
function Y() {
|
|
41
41
|
return p.object({
|
|
42
|
-
input: p.lazy(() =>
|
|
42
|
+
input: p.lazy(() => P()),
|
|
43
43
|
type: H,
|
|
44
44
|
scope: S()
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function P() {
|
|
48
48
|
return p.object({
|
|
49
49
|
operations: p.number(),
|
|
50
50
|
state: p.lazy(() => tt())
|
|
@@ -67,22 +67,22 @@ function Nt() {
|
|
|
67
67
|
}
|
|
68
68
|
function et() {
|
|
69
69
|
return p.object({
|
|
70
|
-
input: p.lazy(() =>
|
|
70
|
+
input: p.lazy(() => F()),
|
|
71
71
|
type: K,
|
|
72
72
|
scope: S()
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function F() {
|
|
76
76
|
return p.object({
|
|
77
77
|
end: p.number().nullish(),
|
|
78
78
|
start: p.number().nullish()
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const I = p.number;
|
|
82
82
|
function it() {
|
|
83
83
|
return p.object({
|
|
84
|
-
input:
|
|
85
|
-
type:
|
|
84
|
+
input: I(),
|
|
85
|
+
type: V,
|
|
86
86
|
scope: S()
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -90,7 +90,7 @@ const R = p.string;
|
|
|
90
90
|
function at() {
|
|
91
91
|
return p.object({
|
|
92
92
|
input: R(),
|
|
93
|
-
type:
|
|
93
|
+
type: G,
|
|
94
94
|
scope: p.literal("global")
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -112,27 +112,27 @@ function nt() {
|
|
|
112
112
|
scope: S()
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
116
116
|
__proto__: null,
|
|
117
117
|
ActionSchema: Et,
|
|
118
118
|
BaseActionSchema: X,
|
|
119
119
|
DocumentFileSchema: Dt,
|
|
120
|
-
LoadStateActionInputSchema:
|
|
120
|
+
LoadStateActionInputSchema: P,
|
|
121
121
|
LoadStateActionSchema: Y,
|
|
122
122
|
LoadStateActionStateInputSchema: tt,
|
|
123
123
|
Load_StateSchema: H,
|
|
124
124
|
OperationSchema: Nt,
|
|
125
125
|
OperationScopeSchema: S,
|
|
126
|
-
PruneActionInputSchema:
|
|
126
|
+
PruneActionInputSchema: F,
|
|
127
127
|
PruneActionSchema: et,
|
|
128
128
|
PruneSchema: K,
|
|
129
|
-
RedoActionInputSchema:
|
|
129
|
+
RedoActionInputSchema: I,
|
|
130
130
|
RedoActionSchema: it,
|
|
131
|
-
RedoSchema:
|
|
131
|
+
RedoSchema: V,
|
|
132
132
|
SetNameActionInputSchema: R,
|
|
133
133
|
SetNameActionSchema: at,
|
|
134
134
|
SetNameOperationSchema: Tt,
|
|
135
|
-
Set_NameSchema:
|
|
135
|
+
Set_NameSchema: G,
|
|
136
136
|
UndoActionInputSchema: q,
|
|
137
137
|
UndoActionSchema: nt,
|
|
138
138
|
UndoSchema: Q,
|
|
@@ -143,8 +143,18 @@ function At(e, t) {
|
|
|
143
143
|
return { ...e, name: t };
|
|
144
144
|
}
|
|
145
145
|
function zt(e, t, i) {
|
|
146
|
+
const a = {
|
|
147
|
+
skip: i,
|
|
148
|
+
document: e
|
|
149
|
+
}, { scope: o } = t;
|
|
150
|
+
return !o || t.skip === void 0 ? a : k(a, (c) => {
|
|
151
|
+
const [n] = c.document.operations[o].slice(-1);
|
|
152
|
+
t.skip && t.skip > 0 && (c.skip = t.skip), n.type === "NOOP" && t.index === n.index && c.skip > n.skip && c.document.operations[o].pop();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function Mt(e, t, i) {
|
|
146
156
|
const { scope: a, input: o } = t;
|
|
147
|
-
return
|
|
157
|
+
return k({
|
|
148
158
|
document: e,
|
|
149
159
|
action: t,
|
|
150
160
|
skip: i
|
|
@@ -166,18 +176,18 @@ function zt(e, t, i) {
|
|
|
166
176
|
throw new Error(
|
|
167
177
|
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
168
178
|
);
|
|
169
|
-
const
|
|
170
|
-
let x = o,
|
|
171
|
-
for (; x > 0 &&
|
|
172
|
-
const
|
|
173
|
-
|
|
179
|
+
const l = n.document.operations[a].length - 1;
|
|
180
|
+
let x = o, m = r ? l - s.skip : l;
|
|
181
|
+
for (; x > 0 && m >= 0; ) {
|
|
182
|
+
const d = n.document.operations[a][m];
|
|
183
|
+
d.type === "NOOP" && d.skip > 0 ? (m = m - (d.skip + 1), n.skip += d.skip + 1) : (n.document.clipboard.push({ ...d }), x--, m--);
|
|
174
184
|
}
|
|
175
185
|
n.action = U(a);
|
|
176
186
|
});
|
|
177
187
|
}
|
|
178
|
-
function
|
|
188
|
+
function Pt(e, t, i) {
|
|
179
189
|
const { scope: a, input: o } = t;
|
|
180
|
-
return
|
|
190
|
+
return k({
|
|
181
191
|
document: e,
|
|
182
192
|
action: t,
|
|
183
193
|
skip: i
|
|
@@ -195,7 +205,7 @@ function Mt(e, t, i) {
|
|
|
195
205
|
if (n.document.clipboard.length < 1)
|
|
196
206
|
throw new Error("Cannot redo: no operations in the clipboard");
|
|
197
207
|
const s = n.document.clipboard.findLastIndex(
|
|
198
|
-
(
|
|
208
|
+
(l) => l.scope === a
|
|
199
209
|
);
|
|
200
210
|
if (s < 0)
|
|
201
211
|
throw new Error(
|
|
@@ -212,17 +222,17 @@ function Mt(e, t, i) {
|
|
|
212
222
|
function Ft(e, t, i) {
|
|
213
223
|
const { scope: a } = t, o = e.operations[a];
|
|
214
224
|
let {
|
|
215
|
-
input: { start:
|
|
225
|
+
input: { start: c, end: n }
|
|
216
226
|
} = t;
|
|
217
|
-
|
|
218
|
-
const s = o.slice(
|
|
227
|
+
c = c || 0, n = n || o.length;
|
|
228
|
+
const s = o.slice(c, n), r = o.slice(0, c), l = o.slice(n), x = M(
|
|
219
229
|
e.initialState,
|
|
220
230
|
{
|
|
221
231
|
...e.operations,
|
|
222
232
|
[a]: r.concat(s)
|
|
223
233
|
},
|
|
224
234
|
i
|
|
225
|
-
), { name:
|
|
235
|
+
), { name: m, state: d } = x, u = r.length, j = r.length ? r[r.length - 1].timestamp : l.length ? l[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
226
236
|
return M(
|
|
227
237
|
e.initialState,
|
|
228
238
|
{
|
|
@@ -231,16 +241,16 @@ function Ft(e, t, i) {
|
|
|
231
241
|
...r,
|
|
232
242
|
{
|
|
233
243
|
...L(
|
|
234
|
-
{ name:
|
|
244
|
+
{ name: m, state: d },
|
|
235
245
|
s.length
|
|
236
246
|
),
|
|
237
247
|
timestamp: j,
|
|
238
|
-
index:
|
|
239
|
-
hash: lt({ state:
|
|
248
|
+
index: u,
|
|
249
|
+
hash: lt({ state: d }, "global")
|
|
240
250
|
},
|
|
241
|
-
...
|
|
251
|
+
...l.map((h, T) => ({
|
|
242
252
|
...h,
|
|
243
|
-
index:
|
|
253
|
+
index: u + T + 1
|
|
244
254
|
}))
|
|
245
255
|
]
|
|
246
256
|
},
|
|
@@ -254,23 +264,23 @@ function It(e, t) {
|
|
|
254
264
|
state: t.state ?? { global: {}, local: {} }
|
|
255
265
|
};
|
|
256
266
|
}
|
|
257
|
-
const ot = "SET_NAME", w = "UNDO", v = "REDO",
|
|
258
|
-
function
|
|
267
|
+
const ot = "SET_NAME", w = "UNDO", v = "REDO", _ = "PRUNE", st = "LOAD_STATE", Rt = "NOOP";
|
|
268
|
+
function qt(e, t) {
|
|
259
269
|
const i = e.revision[t.scope];
|
|
260
|
-
return [w, v,
|
|
270
|
+
return [w, v, _].includes(t.type) ? i : i + 1;
|
|
261
271
|
}
|
|
262
|
-
function
|
|
272
|
+
function Lt(e, t) {
|
|
263
273
|
return {
|
|
264
274
|
...e,
|
|
265
275
|
revision: {
|
|
266
276
|
...e.revision,
|
|
267
|
-
[t.scope]:
|
|
277
|
+
[t.scope]: qt(e, t)
|
|
268
278
|
},
|
|
269
279
|
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
270
280
|
};
|
|
271
281
|
}
|
|
272
|
-
function
|
|
273
|
-
if ([w, v,
|
|
282
|
+
function Ut(e, t, i = 0) {
|
|
283
|
+
if ([w, v, _].includes(t.type))
|
|
274
284
|
return e;
|
|
275
285
|
const { scope: a } = t, o = e.operations[a].slice(
|
|
276
286
|
0,
|
|
@@ -288,15 +298,15 @@ function qt(e, t, i = 0) {
|
|
|
288
298
|
operations: { ...e.operations, [a]: o }
|
|
289
299
|
};
|
|
290
300
|
}
|
|
291
|
-
function
|
|
292
|
-
let a =
|
|
293
|
-
return a =
|
|
301
|
+
function Ct(e, t, i = 0) {
|
|
302
|
+
let a = Ut(e, t, i);
|
|
303
|
+
return a = Lt(a, t), a;
|
|
294
304
|
}
|
|
295
|
-
function
|
|
305
|
+
function $t(e, t, i) {
|
|
296
306
|
switch (X().parse(t), t.type) {
|
|
297
307
|
case ot:
|
|
298
308
|
return At(e, t.input);
|
|
299
|
-
case
|
|
309
|
+
case _:
|
|
300
310
|
return Ft(e, t, i);
|
|
301
311
|
case st:
|
|
302
312
|
return It(e, t.input.state);
|
|
@@ -304,114 +314,121 @@ function Ut(e, t, i) {
|
|
|
304
314
|
return e;
|
|
305
315
|
}
|
|
306
316
|
}
|
|
307
|
-
function
|
|
317
|
+
function Jt(e, t, i) {
|
|
308
318
|
switch (t.type) {
|
|
309
319
|
case w:
|
|
310
|
-
return zt(e, t, i);
|
|
311
|
-
case v:
|
|
312
320
|
return Mt(e, t, i);
|
|
321
|
+
case v:
|
|
322
|
+
return Pt(e, t, i);
|
|
313
323
|
default:
|
|
314
324
|
return { document: e, action: t, skip: i };
|
|
315
325
|
}
|
|
316
326
|
}
|
|
317
327
|
function pt(e, t, i, a, o = {}) {
|
|
318
|
-
const { skip:
|
|
319
|
-
let s = { ...t }, r =
|
|
328
|
+
const { skip: c, ignoreSkipOperations: n = !1 } = o;
|
|
329
|
+
let s = { ...t }, r = c || 0, l = e, x = [...e.clipboard];
|
|
330
|
+
if (Ht(s)) {
|
|
331
|
+
const { document: m, skip: d } = zt(l, s, r);
|
|
332
|
+
r = d, l = m;
|
|
333
|
+
}
|
|
320
334
|
if ($(s)) {
|
|
321
335
|
const {
|
|
322
|
-
skip:
|
|
323
|
-
action:
|
|
324
|
-
document:
|
|
325
|
-
} =
|
|
326
|
-
s =
|
|
327
|
-
}
|
|
328
|
-
return J(s) && (
|
|
329
|
-
|
|
330
|
-
|
|
336
|
+
skip: m,
|
|
337
|
+
action: d,
|
|
338
|
+
document: u
|
|
339
|
+
} = Jt(e, s, r);
|
|
340
|
+
s = d, r = m, l = u, x = [...l.clipboard];
|
|
341
|
+
}
|
|
342
|
+
return J(s) && (l = $t(l, s, i)), r > 0 && !n && (l = M(
|
|
343
|
+
l.initialState,
|
|
344
|
+
l.operations,
|
|
331
345
|
i,
|
|
332
346
|
void 0,
|
|
333
347
|
void 0,
|
|
334
348
|
void 0,
|
|
335
349
|
{ [s.scope]: r }
|
|
336
|
-
)),
|
|
337
|
-
const
|
|
338
|
-
|
|
350
|
+
)), l = Ct(l, s, r), l = k(l, (m) => {
|
|
351
|
+
const d = i(
|
|
352
|
+
m.state,
|
|
339
353
|
s,
|
|
340
354
|
a
|
|
341
|
-
),
|
|
342
|
-
if (
|
|
355
|
+
), u = $(t) ? [...x] : [];
|
|
356
|
+
if (d)
|
|
343
357
|
return A({
|
|
344
|
-
...
|
|
345
|
-
clipboard: [...
|
|
346
|
-
state:
|
|
358
|
+
...l,
|
|
359
|
+
clipboard: [...u],
|
|
360
|
+
state: d
|
|
347
361
|
});
|
|
348
|
-
|
|
349
|
-
}),
|
|
350
|
-
if ([w, v,
|
|
351
|
-
return
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
const { hash: j, ...h } =
|
|
355
|
-
|
|
362
|
+
m.clipboard = A([...u]);
|
|
363
|
+
}), k(l, (m) => {
|
|
364
|
+
if ([w, v, _].includes(s.type))
|
|
365
|
+
return m;
|
|
366
|
+
const d = s.scope || "global";
|
|
367
|
+
m.operations[d][m.operations[d].length - 1].hash = lt(m, d), !J(s) && s.attachments && s.attachments.forEach((u) => {
|
|
368
|
+
const { hash: j, ...h } = u;
|
|
369
|
+
m.attachments[j] = {
|
|
356
370
|
...h
|
|
357
371
|
};
|
|
358
372
|
});
|
|
359
373
|
});
|
|
360
374
|
}
|
|
361
|
-
function
|
|
362
|
-
const a =
|
|
363
|
-
return z.mkdirSync(e, { recursive: !0 }), new Promise((o,
|
|
375
|
+
function Wt(e, t, i) {
|
|
376
|
+
const a = St(e, t);
|
|
377
|
+
return z.mkdirSync(e, { recursive: !0 }), new Promise((o, c) => {
|
|
364
378
|
try {
|
|
365
379
|
z.writeFile(a, i, {}, (n) => {
|
|
366
|
-
n ?
|
|
380
|
+
n ? c(n) : o(a);
|
|
367
381
|
});
|
|
368
382
|
} catch (n) {
|
|
369
|
-
|
|
383
|
+
c(n);
|
|
370
384
|
}
|
|
371
385
|
});
|
|
372
386
|
}
|
|
373
387
|
function ct(e) {
|
|
374
388
|
return z.readFileSync(e);
|
|
375
389
|
}
|
|
376
|
-
function
|
|
390
|
+
function Bt(e) {
|
|
377
391
|
return new Promise((t, i) => {
|
|
378
|
-
|
|
379
|
-
const o = [],
|
|
392
|
+
kt.get(e, (a) => {
|
|
393
|
+
const o = [], c = a.headers["content-type"];
|
|
380
394
|
a.on("data", (n) => {
|
|
381
395
|
o.push(n);
|
|
382
396
|
}), a.on("end", () => {
|
|
383
|
-
t({ buffer: Buffer.concat(o), mimeType:
|
|
397
|
+
t({ buffer: Buffer.concat(o), mimeType: c });
|
|
384
398
|
});
|
|
385
399
|
}).on("error", (a) => {
|
|
386
400
|
i(a);
|
|
387
401
|
});
|
|
388
402
|
});
|
|
389
403
|
}
|
|
390
|
-
const
|
|
404
|
+
const Zt = async (e) => ct(e), N = (e, t = "sha1") => Ot.createHash(t).update(e).digest("base64");
|
|
405
|
+
function Ht(e) {
|
|
406
|
+
return e.type === Rt && e.skip !== void 0 && e.skip > 0 && e.hash !== void 0;
|
|
407
|
+
}
|
|
391
408
|
function $(e) {
|
|
392
409
|
return [w, v].includes(e.type);
|
|
393
410
|
}
|
|
394
411
|
function J(e) {
|
|
395
|
-
return [ot, w, v,
|
|
412
|
+
return [ot, w, v, _, st].includes(e.type);
|
|
396
413
|
}
|
|
397
414
|
function y(e, t, i, a, o = "global") {
|
|
398
415
|
if (!e)
|
|
399
416
|
throw new Error("Empty action type");
|
|
400
417
|
if (typeof e != "string")
|
|
401
418
|
throw new Error(`Invalid action type: ${e}`);
|
|
402
|
-
const
|
|
403
|
-
i && (
|
|
419
|
+
const c = { type: e, input: t, scope: o };
|
|
420
|
+
i && (c.attachments = i);
|
|
404
421
|
try {
|
|
405
|
-
a == null || a().parse(
|
|
422
|
+
a == null || a().parse(c.input);
|
|
406
423
|
} catch (n) {
|
|
407
424
|
throw new Error(`Invalid action input: ${n}`);
|
|
408
425
|
}
|
|
409
|
-
return
|
|
426
|
+
return c;
|
|
410
427
|
}
|
|
411
|
-
function
|
|
412
|
-
return (i, a, o,
|
|
428
|
+
function Kt(e, t = pt) {
|
|
429
|
+
return (i, a, o, c) => t(i, a, e, o, c);
|
|
413
430
|
}
|
|
414
|
-
const
|
|
431
|
+
const Vt = (e, t) => ({
|
|
415
432
|
name: "",
|
|
416
433
|
documentType: "",
|
|
417
434
|
revision: {
|
|
@@ -423,8 +440,8 @@ const Zt = (e, t) => ({
|
|
|
423
440
|
attachments: {},
|
|
424
441
|
...e,
|
|
425
442
|
state: (t == null ? void 0 : t(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
|
|
426
|
-
}),
|
|
427
|
-
const i =
|
|
443
|
+
}), Gt = (e, t) => {
|
|
444
|
+
const i = Vt(
|
|
428
445
|
e,
|
|
429
446
|
t
|
|
430
447
|
);
|
|
@@ -434,21 +451,21 @@ const Zt = (e, t) => ({
|
|
|
434
451
|
operations: { global: [], local: [] },
|
|
435
452
|
clipboard: []
|
|
436
453
|
};
|
|
437
|
-
}, lt = (e, t = "global") => N(jt(e.state[t])),
|
|
454
|
+
}, lt = (e, t = "global") => N(jt(e.state[t])), fe = (e, t = 1e3) => {
|
|
438
455
|
const i = Math.random() * t;
|
|
439
456
|
return N(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
440
457
|
};
|
|
441
|
-
function
|
|
458
|
+
function D(e) {
|
|
442
459
|
return vt(yt(e, !0));
|
|
443
460
|
}
|
|
444
|
-
function
|
|
461
|
+
function Qt(e, t) {
|
|
445
462
|
const i = [...e];
|
|
446
463
|
let a = t || 0, o = i.length > 0 ? i[i.length - 1].index : 0;
|
|
447
|
-
const
|
|
464
|
+
const c = [];
|
|
448
465
|
for (const n of i.reverse()) {
|
|
449
466
|
if (a > 0) {
|
|
450
|
-
const
|
|
451
|
-
a -=
|
|
467
|
+
const l = o - n.index;
|
|
468
|
+
a -= l;
|
|
452
469
|
}
|
|
453
470
|
if (a < 0)
|
|
454
471
|
throw new Error("Invalid operation index, missing operations");
|
|
@@ -457,25 +474,25 @@ function Kt(e, t) {
|
|
|
457
474
|
operation: n
|
|
458
475
|
}, r = n.skip > 0 ? n.skip + 1 : 0;
|
|
459
476
|
if (r > 0 && r > a) {
|
|
460
|
-
const
|
|
461
|
-
a = a +
|
|
477
|
+
const l = r - a;
|
|
478
|
+
a = a + l;
|
|
462
479
|
}
|
|
463
|
-
o = n.index,
|
|
480
|
+
o = n.index, c.push(s);
|
|
464
481
|
}
|
|
465
|
-
return
|
|
482
|
+
return c.reverse();
|
|
466
483
|
}
|
|
467
|
-
function
|
|
484
|
+
function xe(e) {
|
|
468
485
|
return Object.values(e).flatMap((t) => t).sort(
|
|
469
486
|
(t, i) => new Date(t.timestamp).getTime() - new Date(i.timestamp).getTime()
|
|
470
487
|
);
|
|
471
488
|
}
|
|
472
|
-
function
|
|
489
|
+
function Xt(e) {
|
|
473
490
|
return Object.values(e).flatMap((t) => t).sort(
|
|
474
491
|
(t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
475
492
|
);
|
|
476
493
|
}
|
|
477
|
-
function M(e, t, i, a, o,
|
|
478
|
-
const s =
|
|
494
|
+
function M(e, t, i, a, o, c = pt, n = {}) {
|
|
495
|
+
const s = Kt(i, c);
|
|
479
496
|
return rt(
|
|
480
497
|
e,
|
|
481
498
|
t,
|
|
@@ -485,47 +502,47 @@ function M(e, t, i, a, o, l = pt, n = {}) {
|
|
|
485
502
|
n
|
|
486
503
|
);
|
|
487
504
|
}
|
|
488
|
-
function rt(e, t, i, a, o,
|
|
489
|
-
const n =
|
|
490
|
-
const
|
|
505
|
+
function rt(e, t, i, a, o, c = {}) {
|
|
506
|
+
const n = Gt(e), s = Object.keys(t).reduce((m, d) => {
|
|
507
|
+
const u = d;
|
|
491
508
|
return {
|
|
492
|
-
...
|
|
493
|
-
[
|
|
509
|
+
...m,
|
|
510
|
+
[u]: t[u].slice(0, o == null ? void 0 : o.revision[u])
|
|
494
511
|
};
|
|
495
512
|
}, {}), r = Object.keys(s).reduce(
|
|
496
|
-
(
|
|
497
|
-
const
|
|
513
|
+
(m, d) => {
|
|
514
|
+
const u = d;
|
|
498
515
|
return {
|
|
499
|
-
...
|
|
500
|
-
[
|
|
501
|
-
s[
|
|
502
|
-
|
|
516
|
+
...m,
|
|
517
|
+
[u]: Qt(
|
|
518
|
+
s[u],
|
|
519
|
+
c[u]
|
|
503
520
|
)
|
|
504
521
|
};
|
|
505
522
|
},
|
|
506
523
|
{}
|
|
507
|
-
),
|
|
508
|
-
(
|
|
509
|
-
skip:
|
|
524
|
+
), l = Xt(r).reduce(
|
|
525
|
+
(m, { ignore: d, operation: u }) => d ? i(m, U(u.scope), a, {
|
|
526
|
+
skip: u.skip,
|
|
510
527
|
ignoreSkipOperations: !0
|
|
511
|
-
}) : i(
|
|
512
|
-
skip:
|
|
528
|
+
}) : i(m, u, a, {
|
|
529
|
+
skip: u.skip,
|
|
513
530
|
ignoreSkipOperations: !0
|
|
514
531
|
}),
|
|
515
532
|
n
|
|
516
533
|
), x = Object.keys(
|
|
517
|
-
|
|
534
|
+
l.operations
|
|
518
535
|
).reduce(
|
|
519
|
-
(
|
|
520
|
-
const
|
|
536
|
+
(m, d) => {
|
|
537
|
+
const u = d, j = o && o.revision[u] < t[u].length ? t[u].slice(o.revision[u]) : [];
|
|
521
538
|
return {
|
|
522
|
-
...
|
|
523
|
-
[
|
|
524
|
-
...
|
|
539
|
+
...m,
|
|
540
|
+
[u]: [
|
|
541
|
+
...l.operations[u].map((h, T) => {
|
|
525
542
|
var C;
|
|
526
543
|
return {
|
|
527
544
|
...h,
|
|
528
|
-
timestamp: ((C = t[
|
|
545
|
+
timestamp: ((C = t[u][T]) == null ? void 0 : C.timestamp) ?? h.timestamp
|
|
529
546
|
};
|
|
530
547
|
}),
|
|
531
548
|
...j
|
|
@@ -534,7 +551,7 @@ function rt(e, t, i, a, o, l = {}) {
|
|
|
534
551
|
},
|
|
535
552
|
{ global: [], local: [] }
|
|
536
553
|
);
|
|
537
|
-
return { ...
|
|
554
|
+
return { ...l, operations: x };
|
|
538
555
|
}
|
|
539
556
|
const mt = (e) => y(
|
|
540
557
|
"SET_NAME",
|
|
@@ -542,37 +559,37 @@ const mt = (e) => y(
|
|
|
542
559
|
void 0,
|
|
543
560
|
R,
|
|
544
561
|
void 0
|
|
545
|
-
),
|
|
562
|
+
), ut = (e = 1, t = "global") => y(
|
|
546
563
|
"UNDO",
|
|
547
564
|
e,
|
|
548
565
|
void 0,
|
|
549
566
|
q,
|
|
550
567
|
t
|
|
551
|
-
),
|
|
568
|
+
), dt = (e = 1, t = "global") => y(
|
|
552
569
|
"REDO",
|
|
553
570
|
e,
|
|
554
571
|
void 0,
|
|
555
|
-
|
|
572
|
+
I,
|
|
556
573
|
t
|
|
557
574
|
), ft = (e, t, i = "global") => y(
|
|
558
575
|
"PRUNE",
|
|
559
576
|
{ start: e, end: t },
|
|
560
577
|
void 0,
|
|
561
|
-
|
|
578
|
+
F,
|
|
562
579
|
i
|
|
563
580
|
), L = (e, t) => y(
|
|
564
581
|
"LOAD_STATE",
|
|
565
582
|
{ state: e, operations: t },
|
|
566
583
|
void 0,
|
|
567
|
-
|
|
568
|
-
), U = (e = "global") => y("NOOP", {}, void 0, void 0, e),
|
|
584
|
+
P
|
|
585
|
+
), U = (e = "global") => y("NOOP", {}, void 0, void 0, e), ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
569
586
|
__proto__: null,
|
|
570
587
|
loadState: L,
|
|
571
588
|
noop: U,
|
|
572
589
|
prune: ft,
|
|
573
|
-
redo:
|
|
590
|
+
redo: dt,
|
|
574
591
|
setName: mt,
|
|
575
|
-
undo:
|
|
592
|
+
undo: ut
|
|
576
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"] };
|
|
577
594
|
Object.freeze(xt);
|
|
578
595
|
var f = function(e, t, i, a) {
|
|
@@ -582,7 +599,7 @@ var f = function(e, t, i, a) {
|
|
|
582
599
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
583
600
|
return i === "m" ? a : i === "a" ? a.call(e) : a ? a.value : t.get(e);
|
|
584
601
|
}, b, O, g;
|
|
585
|
-
class
|
|
602
|
+
class Yt {
|
|
586
603
|
constructor(...t) {
|
|
587
604
|
b.set(this, /* @__PURE__ */ new Map()), O.set(this, /* @__PURE__ */ new Map()), g.set(this, /* @__PURE__ */ new Map());
|
|
588
605
|
for (const i of t)
|
|
@@ -591,15 +608,15 @@ class Vt {
|
|
|
591
608
|
define(t, i = !1) {
|
|
592
609
|
for (let [a, o] of Object.entries(t)) {
|
|
593
610
|
a = a.toLowerCase(), o = o.map((s) => s.toLowerCase()), f(this, g, "f").has(a) || f(this, g, "f").set(a, /* @__PURE__ */ new Set());
|
|
594
|
-
const
|
|
611
|
+
const c = f(this, g, "f").get(a);
|
|
595
612
|
let n = !0;
|
|
596
613
|
for (let s of o) {
|
|
597
614
|
const r = s.startsWith("*");
|
|
598
|
-
if (s = r ? s.slice(1) : s,
|
|
615
|
+
if (s = r ? s.slice(1) : s, c == null || c.add(s), n && f(this, O, "f").set(a, s), n = !1, r)
|
|
599
616
|
continue;
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
602
|
-
throw new Error(`"${a} -> ${s}" conflicts with "${
|
|
617
|
+
const l = f(this, b, "f").get(s);
|
|
618
|
+
if (l && l != a && !i)
|
|
619
|
+
throw new Error(`"${a} -> ${s}" conflicts with "${l} -> ${s}". Pass \`force=true\` to override this definition.`);
|
|
603
620
|
f(this, b, "f").set(s, a);
|
|
604
621
|
}
|
|
605
622
|
}
|
|
@@ -634,76 +651,76 @@ class Vt {
|
|
|
634
651
|
}
|
|
635
652
|
}
|
|
636
653
|
b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap();
|
|
637
|
-
const
|
|
638
|
-
const t = new B(), { name: i, revision: a, documentType: o, created:
|
|
654
|
+
const te = new Yt(xt)._freeze(), gt = async (e) => {
|
|
655
|
+
const t = new B(), { name: i, revision: a, documentType: o, created: c, lastModified: n } = e, s = {
|
|
639
656
|
name: i,
|
|
640
657
|
revision: a,
|
|
641
658
|
documentType: o,
|
|
642
|
-
created:
|
|
659
|
+
created: c,
|
|
643
660
|
lastModified: n
|
|
644
661
|
};
|
|
645
662
|
return t.file("header.json", JSON.stringify(s, null, 2)), t.file(
|
|
646
663
|
"state.json",
|
|
647
664
|
JSON.stringify(e.initialState || {}, null, 2)
|
|
648
|
-
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((
|
|
649
|
-
const { data: x, ...
|
|
650
|
-
t.file(
|
|
665
|
+
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((l) => {
|
|
666
|
+
const { data: x, ...m } = e.attachments[l];
|
|
667
|
+
t.file(l, x, {
|
|
651
668
|
base64: !0,
|
|
652
669
|
createFolders: !0,
|
|
653
|
-
comment: JSON.stringify(
|
|
670
|
+
comment: JSON.stringify(m)
|
|
654
671
|
});
|
|
655
672
|
}), t;
|
|
656
|
-
},
|
|
657
|
-
const
|
|
673
|
+
}, ee = async (e, t, i, a) => {
|
|
674
|
+
const c = await (await gt(e)).generateAsync({
|
|
658
675
|
type: "uint8array",
|
|
659
676
|
streamFiles: !0
|
|
660
677
|
}), n = a ?? e.name, s = `.${i}.zip`;
|
|
661
|
-
return
|
|
678
|
+
return Wt(
|
|
662
679
|
t,
|
|
663
680
|
n.endsWith(s) ? n : `${n}${s}`,
|
|
664
|
-
|
|
681
|
+
c
|
|
665
682
|
);
|
|
666
|
-
},
|
|
683
|
+
}, he = async (e, t) => {
|
|
667
684
|
const a = await (await gt(e)).generateAsync({ type: "blob" }), o = await t.createWritable();
|
|
668
685
|
await o.write(a), await o.close();
|
|
669
686
|
}, W = async (e, t) => {
|
|
670
687
|
const i = ct(e);
|
|
671
|
-
return
|
|
672
|
-
},
|
|
688
|
+
return ie(i, t);
|
|
689
|
+
}, ie = async (e, t) => {
|
|
673
690
|
const i = new B();
|
|
674
|
-
return await i.loadAsync(e),
|
|
691
|
+
return await i.loadAsync(e), ae(i, t);
|
|
675
692
|
};
|
|
676
|
-
async function
|
|
693
|
+
async function ae(e, t) {
|
|
677
694
|
const i = e.file("state.json");
|
|
678
695
|
if (!i)
|
|
679
696
|
throw new Error("Initial state not found");
|
|
680
|
-
const a = await i.async("string"), o = JSON.parse(a),
|
|
697
|
+
const a = await i.async("string"), o = JSON.parse(a), c = e.file("header.json");
|
|
681
698
|
let n;
|
|
682
|
-
|
|
699
|
+
c && (n = JSON.parse(await c.async("string")));
|
|
683
700
|
const s = e.file("operations.json");
|
|
684
701
|
if (!s)
|
|
685
702
|
throw new Error("Operations history not found");
|
|
686
703
|
const r = JSON.parse(
|
|
687
704
|
await s.async("string")
|
|
688
705
|
);
|
|
689
|
-
let
|
|
706
|
+
let l = rt(
|
|
690
707
|
o,
|
|
691
708
|
r,
|
|
692
709
|
t,
|
|
693
710
|
void 0,
|
|
694
711
|
n
|
|
695
712
|
);
|
|
696
|
-
return n && (
|
|
697
|
-
...
|
|
713
|
+
return n && (l = {
|
|
714
|
+
...l,
|
|
698
715
|
...n
|
|
699
|
-
}),
|
|
716
|
+
}), l;
|
|
700
717
|
}
|
|
701
718
|
function ht(e) {
|
|
702
719
|
const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
|
|
703
720
|
return { extension: t, fileName: i };
|
|
704
721
|
}
|
|
705
|
-
async function
|
|
706
|
-
const { buffer: t, mimeType: i = "application/octet-stream" } = await
|
|
722
|
+
async function be(e) {
|
|
723
|
+
const { buffer: t, mimeType: i = "application/octet-stream" } = await Bt(e), a = ht(e), o = t.toString("base64");
|
|
707
724
|
return {
|
|
708
725
|
data: o,
|
|
709
726
|
hash: N(o),
|
|
@@ -711,20 +728,20 @@ async function xe(e) {
|
|
|
711
728
|
...a
|
|
712
729
|
};
|
|
713
730
|
}
|
|
714
|
-
async function
|
|
715
|
-
const t = await
|
|
731
|
+
async function we(e) {
|
|
732
|
+
const t = await Zt(e), i = te.getType(e) || "application/octet-stream", a = ht(e), o = t.toString("base64");
|
|
716
733
|
return { data: o, hash: N(o), mimeType: i, ...a };
|
|
717
734
|
}
|
|
718
|
-
class
|
|
735
|
+
class ve {
|
|
719
736
|
/**
|
|
720
737
|
* Constructs a BaseDocument instance with an initial state.
|
|
721
738
|
* @param reducer - The reducer function that updates the state.
|
|
722
739
|
* @param document - The initial state of the document.
|
|
723
740
|
*/
|
|
724
741
|
constructor(t, i, a) {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
742
|
+
E(this, "_document");
|
|
743
|
+
E(this, "_reducer");
|
|
744
|
+
E(this, "_signalDispatch");
|
|
728
745
|
this._reducer = t, this._document = i, this._signalDispatch = a;
|
|
729
746
|
}
|
|
730
747
|
/**
|
|
@@ -747,7 +764,7 @@ class he {
|
|
|
747
764
|
* @returns The file path where the state was saved.
|
|
748
765
|
*/
|
|
749
766
|
saveToFile(t, i, a) {
|
|
750
|
-
return
|
|
767
|
+
return ee(this._document, t, i, a);
|
|
751
768
|
}
|
|
752
769
|
/**
|
|
753
770
|
* Loads the state of the document from a file.
|
|
@@ -769,13 +786,13 @@ class he {
|
|
|
769
786
|
* Gets the current state of the document.
|
|
770
787
|
*/
|
|
771
788
|
get state() {
|
|
772
|
-
return
|
|
789
|
+
return D(this._document.state);
|
|
773
790
|
}
|
|
774
791
|
/**
|
|
775
792
|
* Gets the list of operations performed on the document.
|
|
776
793
|
*/
|
|
777
794
|
get operations() {
|
|
778
|
-
return
|
|
795
|
+
return D(this._document.operations);
|
|
779
796
|
}
|
|
780
797
|
/**
|
|
781
798
|
* Gets the name of the document.
|
|
@@ -814,13 +831,13 @@ class he {
|
|
|
814
831
|
* Gets the initial state of the document.
|
|
815
832
|
*/
|
|
816
833
|
get initialState() {
|
|
817
|
-
return
|
|
834
|
+
return D(this._document.initialState);
|
|
818
835
|
}
|
|
819
836
|
/**
|
|
820
837
|
* Returns the current document as an object
|
|
821
838
|
*/
|
|
822
839
|
toDocument() {
|
|
823
|
-
return
|
|
840
|
+
return D(this._document);
|
|
824
841
|
}
|
|
825
842
|
/**
|
|
826
843
|
* Gets the attachment associated with the given key.
|
|
@@ -841,14 +858,14 @@ class he {
|
|
|
841
858
|
* @param count - The number of actions to revert.
|
|
842
859
|
*/
|
|
843
860
|
undo(t) {
|
|
844
|
-
return this.dispatch(
|
|
861
|
+
return this.dispatch(ut(t)), this;
|
|
845
862
|
}
|
|
846
863
|
/**
|
|
847
864
|
* Reapplies a number of actions to the document.
|
|
848
865
|
* @param count - The number of actions to reapply.
|
|
849
866
|
*/
|
|
850
867
|
redo(t) {
|
|
851
|
-
return this.dispatch(
|
|
868
|
+
return this.dispatch(dt(t)), this;
|
|
852
869
|
}
|
|
853
870
|
/**
|
|
854
871
|
* Removes a range of operations from the document.
|
|
@@ -867,7 +884,7 @@ class he {
|
|
|
867
884
|
return this.dispatch(L(t, i)), this;
|
|
868
885
|
}
|
|
869
886
|
}
|
|
870
|
-
function
|
|
887
|
+
function ye(e, t) {
|
|
871
888
|
t.forEach((i) => {
|
|
872
889
|
Object.getOwnPropertyNames(i.prototype).forEach((a) => {
|
|
873
890
|
Object.defineProperty(
|
|
@@ -881,31 +898,32 @@ function be(e, t) {
|
|
|
881
898
|
});
|
|
882
899
|
}
|
|
883
900
|
export {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
901
|
+
de as A,
|
|
902
|
+
ve as B,
|
|
903
|
+
Vt as a,
|
|
904
|
+
Gt as b,
|
|
905
|
+
Kt as c,
|
|
906
|
+
he as d,
|
|
907
|
+
ie as e,
|
|
890
908
|
y as f,
|
|
891
|
-
|
|
892
|
-
|
|
909
|
+
ye as g,
|
|
910
|
+
ge as h,
|
|
893
911
|
J as i,
|
|
894
912
|
gt as j,
|
|
895
|
-
|
|
913
|
+
we as k,
|
|
896
914
|
W as l,
|
|
897
|
-
|
|
915
|
+
be as m,
|
|
898
916
|
lt as n,
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
917
|
+
fe as o,
|
|
918
|
+
Ht as p,
|
|
919
|
+
$ as q,
|
|
920
|
+
Qt as r,
|
|
921
|
+
ee as s,
|
|
922
|
+
D as t,
|
|
923
|
+
rt as u,
|
|
924
|
+
M as v,
|
|
925
|
+
Xt as w,
|
|
926
|
+
xe as x,
|
|
927
|
+
pt as y,
|
|
928
|
+
Jt as z
|
|
911
929
|
};
|