document-model 1.0.34 → 1.0.36
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 +13 -8
- 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-CDGYwLIP.js → index-4Z_H8F_J.js} +572 -405
- package/dist/browser/internal/index-6u2yDIEF.js +22 -0
- package/dist/browser/internal/index-DQeD1Q-a.js +42 -0
- package/dist/browser/internal/index-QJX_Fa1V.js +1 -0
- package/dist/browser/internal/object-EriwiDIs.js +7 -0
- package/dist/browser/internal/{object-B-Aw8ilC.js → object-Fq6PThAX.js} +301 -263
- package/dist/browser/src/document/reducer.d.ts +2 -2
- package/dist/browser/src/document/utils/base.d.ts +1 -0
- package/dist/browser/src/document-model/custom/utils.d.ts +7 -1
- package/dist/browser/src/document-model/index.d.ts +5 -0
- package/dist/browser/test/document/event-vs-command.test.d.ts +1 -0
- package/dist/browser/test/document-model/validation.test.d.ts +1 -0
- package/dist/browser/test/helpers.d.ts +5 -3
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +12 -7
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +3 -3
- package/dist/node/internal/{index-CEkeEja8.js → index-A6Rqm2SZ.js} +572 -405
- package/dist/node/internal/index-BpBnSlTZ.js +22 -0
- package/dist/node/internal/index-Dl5T5qdc.js +42 -0
- package/dist/node/internal/index-DyCS1h0M.js +1 -0
- package/dist/node/internal/{object-CvntAblp.js → object-S6TngMa9.js} +324 -286
- package/dist/node/internal/object-ifvac9k2.js +2 -0
- package/dist/node/src/document/reducer.d.ts +2 -2
- package/dist/node/src/document/utils/base.d.ts +1 -0
- package/dist/node/src/document-model/custom/utils.d.ts +7 -1
- package/dist/node/src/document-model/index.d.ts +5 -0
- package/dist/node/test/document/event-vs-command.test.d.ts +1 -0
- package/dist/node/test/document-model/validation.test.d.ts +1 -0
- package/dist/node/test/helpers.d.ts +5 -3
- package/package.json +2 -1
- package/dist/browser/internal/index-368Qgjhp.js +0 -22
- package/dist/browser/internal/index-A_QX9cy_.js +0 -41
- package/dist/browser/internal/index-CZWjb-hc.js +0 -1
- package/dist/browser/internal/object-C8B-mq5Y.js +0 -7
- package/dist/node/internal/index-D_eCXEyL.js +0 -41
- package/dist/node/internal/index-DjP2tO7C.js +0 -1
- package/dist/node/internal/index-qa67kbhM.js +0 -22
- package/dist/node/internal/object-B5Lf9AWl.js +0 -2
|
@@ -23,8 +23,8 @@ function Y() {
|
|
|
23
23
|
return c.union([
|
|
24
24
|
tt(),
|
|
25
25
|
it(),
|
|
26
|
-
at(),
|
|
27
26
|
nt(),
|
|
27
|
+
at(),
|
|
28
28
|
ot()
|
|
29
29
|
]);
|
|
30
30
|
}
|
|
@@ -39,12 +39,12 @@ function Nt() {
|
|
|
39
39
|
}
|
|
40
40
|
function tt() {
|
|
41
41
|
return c.object({
|
|
42
|
-
input: c.lazy(() =>
|
|
42
|
+
input: c.lazy(() => P()),
|
|
43
43
|
type: K,
|
|
44
44
|
scope: S()
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function P() {
|
|
48
48
|
return c.object({
|
|
49
49
|
operations: c.number(),
|
|
50
50
|
state: c.lazy(() => et())
|
|
@@ -79,17 +79,17 @@ function F() {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const R = c.number;
|
|
82
|
-
function
|
|
82
|
+
function nt() {
|
|
83
83
|
return c.object({
|
|
84
84
|
input: R(),
|
|
85
85
|
type: G,
|
|
86
86
|
scope: S()
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
89
|
+
const L = c.string;
|
|
90
|
+
function at() {
|
|
91
91
|
return c.object({
|
|
92
|
-
input:
|
|
92
|
+
input: L(),
|
|
93
93
|
type: Q,
|
|
94
94
|
scope: c.literal("global")
|
|
95
95
|
});
|
|
@@ -104,20 +104,20 @@ function At() {
|
|
|
104
104
|
type: c.string()
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
const
|
|
107
|
+
const q = c.number;
|
|
108
108
|
function ot() {
|
|
109
109
|
return c.object({
|
|
110
|
-
input:
|
|
110
|
+
input: q(),
|
|
111
111
|
type: X,
|
|
112
112
|
scope: S()
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
116
116
|
__proto__: null,
|
|
117
117
|
ActionSchema: Dt,
|
|
118
118
|
BaseActionSchema: Y,
|
|
119
119
|
DocumentFileSchema: Nt,
|
|
120
|
-
LoadStateActionInputSchema:
|
|
120
|
+
LoadStateActionInputSchema: P,
|
|
121
121
|
LoadStateActionSchema: tt,
|
|
122
122
|
LoadStateActionStateInputSchema: et,
|
|
123
123
|
Load_StateSchema: K,
|
|
@@ -127,13 +127,13 @@ const xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
127
127
|
PruneActionSchema: it,
|
|
128
128
|
PruneSchema: V,
|
|
129
129
|
RedoActionInputSchema: R,
|
|
130
|
-
RedoActionSchema:
|
|
130
|
+
RedoActionSchema: nt,
|
|
131
131
|
RedoSchema: G,
|
|
132
|
-
SetNameActionInputSchema:
|
|
133
|
-
SetNameActionSchema:
|
|
132
|
+
SetNameActionInputSchema: L,
|
|
133
|
+
SetNameActionSchema: at,
|
|
134
134
|
SetNameOperationSchema: At,
|
|
135
135
|
Set_NameSchema: Q,
|
|
136
|
-
UndoActionInputSchema:
|
|
136
|
+
UndoActionInputSchema: q,
|
|
137
137
|
UndoActionSchema: ot,
|
|
138
138
|
UndoSchema: X,
|
|
139
139
|
definedNonNullAnySchema: Et,
|
|
@@ -143,76 +143,85 @@ function zt(e, t) {
|
|
|
143
143
|
return { ...e, name: t };
|
|
144
144
|
}
|
|
145
145
|
function Mt(e, t, i) {
|
|
146
|
-
const
|
|
146
|
+
const n = {
|
|
147
147
|
skip: i,
|
|
148
148
|
document: e
|
|
149
|
-
}, { scope:
|
|
150
|
-
return !
|
|
151
|
-
const [
|
|
152
|
-
t.skip && t.skip > 0 && (
|
|
149
|
+
}, { scope: o } = t;
|
|
150
|
+
return !o || t.skip === void 0 ? n : k(n, (p) => {
|
|
151
|
+
const [a] = p.document.operations[o].slice(-1);
|
|
152
|
+
t.skip && t.skip > 0 && (p.skip = t.skip), a.type === "NOOP" && t.index === a.index && p.skip > a.skip && p.document.operations[o].pop();
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
const { scope:
|
|
155
|
+
function It(e, t, i) {
|
|
156
|
+
const { scope: n, input: o } = t;
|
|
157
157
|
return k({
|
|
158
158
|
document: e,
|
|
159
159
|
action: t,
|
|
160
160
|
skip: i
|
|
161
|
-
}, (
|
|
162
|
-
if (
|
|
161
|
+
}, (a) => {
|
|
162
|
+
if (a.document.operations[n].length < 1)
|
|
163
163
|
throw new Error(
|
|
164
|
-
`Cannot undo: no operations in history for scope "${
|
|
164
|
+
`Cannot undo: no operations in history for scope "${n}"`
|
|
165
165
|
);
|
|
166
|
-
if (
|
|
166
|
+
if (o < 1)
|
|
167
167
|
throw new Error(
|
|
168
168
|
"Invalid UNDO action: input value must be greater than 0"
|
|
169
169
|
);
|
|
170
|
-
if (
|
|
170
|
+
if (a.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 [s] = a.document.operations[n].slice(-1), l = s.type === "NOOP" && s.skip > 0;
|
|
175
|
+
if (a.skip += o, l) {
|
|
176
|
+
a.skip += s.skip;
|
|
177
|
+
const m = a.document.operations[n][a.document.operations[n].length - 2];
|
|
178
|
+
m && s.index - m.index === 1 && a.document.operations[n].pop();
|
|
179
|
+
}
|
|
180
|
+
if (a.document.operations[n].length < a.skip)
|
|
176
181
|
throw new Error(
|
|
177
182
|
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
178
183
|
);
|
|
179
|
-
const r =
|
|
180
|
-
let x =
|
|
181
|
-
for (; x > 0 &&
|
|
182
|
-
const m =
|
|
183
|
-
|
|
184
|
+
const r = a.document.operations[n].length - 1;
|
|
185
|
+
let x = o, d = l ? r - s.skip : r;
|
|
186
|
+
for (; x > 0 && d >= 0; ) {
|
|
187
|
+
const m = a.document.operations[n][d];
|
|
188
|
+
if (!m) {
|
|
189
|
+
x--, d--;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
m.type === "NOOP" && m.skip > 0 ? (d = d - (m.skip + 1), a.skip += m.skip + 1) : (a.document.clipboard.push({ ...m }), x--, d--);
|
|
184
193
|
}
|
|
185
|
-
|
|
194
|
+
a.action = U(n);
|
|
186
195
|
});
|
|
187
196
|
}
|
|
188
|
-
function
|
|
189
|
-
const { scope:
|
|
197
|
+
function Pt(e, t, i) {
|
|
198
|
+
const { scope: n, input: o } = t;
|
|
190
199
|
return k({
|
|
191
200
|
document: e,
|
|
192
201
|
action: t,
|
|
193
202
|
skip: i
|
|
194
|
-
}, (
|
|
195
|
-
if (
|
|
203
|
+
}, (a) => {
|
|
204
|
+
if (a.skip > 0)
|
|
196
205
|
throw new Error(
|
|
197
206
|
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
198
207
|
);
|
|
199
|
-
if (
|
|
208
|
+
if (o > 1)
|
|
200
209
|
throw new Error(
|
|
201
210
|
"Cannot redo: you can only redo one operation at a time"
|
|
202
211
|
);
|
|
203
|
-
if (
|
|
212
|
+
if (o < 1)
|
|
204
213
|
throw new Error("Invalid REDO action: invalid redo input value");
|
|
205
|
-
if (
|
|
214
|
+
if (a.document.clipboard.length < 1)
|
|
206
215
|
throw new Error("Cannot redo: no operations in the clipboard");
|
|
207
|
-
const
|
|
208
|
-
(r) => r.scope ===
|
|
216
|
+
const s = a.document.clipboard.findLastIndex(
|
|
217
|
+
(r) => r.scope === n
|
|
209
218
|
);
|
|
210
|
-
if (
|
|
219
|
+
if (s < 0)
|
|
211
220
|
throw new Error(
|
|
212
|
-
`Cannot redo: no operations in clipboard for scope "${
|
|
221
|
+
`Cannot redo: no operations in clipboard for scope "${n}"`
|
|
213
222
|
);
|
|
214
|
-
const l =
|
|
215
|
-
|
|
223
|
+
const l = a.document.clipboard.splice(s, 1)[0];
|
|
224
|
+
a.action = A({
|
|
216
225
|
type: l.type,
|
|
217
226
|
scope: l.scope,
|
|
218
227
|
input: l.input
|
|
@@ -220,31 +229,31 @@ function It(e, t, i) {
|
|
|
220
229
|
});
|
|
221
230
|
}
|
|
222
231
|
function Ft(e, t, i) {
|
|
223
|
-
const { scope:
|
|
232
|
+
const { scope: n } = t, o = e.operations[n];
|
|
224
233
|
let {
|
|
225
|
-
input: { start:
|
|
234
|
+
input: { start: p, end: a }
|
|
226
235
|
} = t;
|
|
227
|
-
|
|
228
|
-
const
|
|
236
|
+
p = p || 0, a = a || o.length;
|
|
237
|
+
const s = o.slice(p, a), l = o.slice(0, p), r = o.slice(a), x = I(
|
|
229
238
|
e.initialState,
|
|
230
239
|
{
|
|
231
240
|
...e.operations,
|
|
232
|
-
[
|
|
241
|
+
[n]: l.concat(s)
|
|
233
242
|
},
|
|
234
243
|
i
|
|
235
|
-
), { name:
|
|
236
|
-
return
|
|
244
|
+
), { name: d, state: m } = x, f = l.length, u = l.length ? l[l.length - 1].timestamp : r.length ? r[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
245
|
+
return I(
|
|
237
246
|
e.initialState,
|
|
238
247
|
{
|
|
239
248
|
...e.operations,
|
|
240
|
-
[
|
|
249
|
+
[n]: [
|
|
241
250
|
...l,
|
|
242
251
|
{
|
|
243
|
-
|
|
244
|
-
{ name:
|
|
245
|
-
|
|
252
|
+
...$(
|
|
253
|
+
{ name: d, state: m },
|
|
254
|
+
s.length
|
|
246
255
|
),
|
|
247
|
-
timestamp:
|
|
256
|
+
timestamp: u,
|
|
248
257
|
index: f,
|
|
249
258
|
hash: lt({ state: m }, "global")
|
|
250
259
|
},
|
|
@@ -264,43 +273,51 @@ function Rt(e, t) {
|
|
|
264
273
|
state: t.state ?? { global: {}, local: {} }
|
|
265
274
|
};
|
|
266
275
|
}
|
|
267
|
-
const st = "SET_NAME", w = "UNDO", v = "REDO", _ = "PRUNE", pt = "LOAD_STATE",
|
|
268
|
-
function
|
|
276
|
+
const st = "SET_NAME", w = "UNDO", v = "REDO", _ = "PRUNE", pt = "LOAD_STATE", Lt = "NOOP";
|
|
277
|
+
function qt(e, t) {
|
|
269
278
|
const i = e.revision[t.scope];
|
|
270
279
|
return [w, v, _].includes(t.type) ? i : i + 1;
|
|
271
280
|
}
|
|
272
|
-
function
|
|
281
|
+
function $t(e, t) {
|
|
273
282
|
return {
|
|
274
283
|
...e,
|
|
275
284
|
revision: {
|
|
276
285
|
...e.revision,
|
|
277
|
-
[t.scope]:
|
|
286
|
+
[t.scope]: qt(e, t)
|
|
278
287
|
},
|
|
279
288
|
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
280
289
|
};
|
|
281
290
|
}
|
|
282
|
-
function
|
|
291
|
+
function Ut(e, t, i = 0) {
|
|
283
292
|
if ([w, v, _].includes(t.type))
|
|
284
293
|
return e;
|
|
285
|
-
const { scope:
|
|
294
|
+
const { scope: n } = t, o = e.operations[n].slice(
|
|
286
295
|
0,
|
|
287
|
-
e.revision[
|
|
288
|
-
);
|
|
289
|
-
|
|
296
|
+
e.revision[n]
|
|
297
|
+
), p = [...o].pop();
|
|
298
|
+
let a = ((p == null ? void 0 : p.index) ?? -1) + 1;
|
|
299
|
+
if ("index" in t) {
|
|
300
|
+
if (t.index > a + i)
|
|
301
|
+
throw new Error(
|
|
302
|
+
`Missing operations: expected ${a} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
|
|
303
|
+
);
|
|
304
|
+
a = t.index;
|
|
305
|
+
}
|
|
306
|
+
return o.push({
|
|
290
307
|
...t,
|
|
291
|
-
index:
|
|
308
|
+
index: a,
|
|
292
309
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
293
310
|
hash: "",
|
|
294
|
-
scope:
|
|
311
|
+
scope: n,
|
|
295
312
|
skip: i
|
|
296
313
|
}), {
|
|
297
314
|
...e,
|
|
298
|
-
operations: { ...e.operations, [
|
|
315
|
+
operations: { ...e.operations, [n]: o }
|
|
299
316
|
};
|
|
300
317
|
}
|
|
301
318
|
function Ct(e, t, i = 0) {
|
|
302
|
-
let
|
|
303
|
-
return
|
|
319
|
+
let n = Ut(e, t, i);
|
|
320
|
+
return n = $t(n, t), n;
|
|
304
321
|
}
|
|
305
322
|
function Jt(e, t, i) {
|
|
306
323
|
switch (Y().parse(t), t.type) {
|
|
@@ -317,41 +334,49 @@ function Jt(e, t, i) {
|
|
|
317
334
|
function Wt(e, t, i) {
|
|
318
335
|
switch (t.type) {
|
|
319
336
|
case w:
|
|
320
|
-
return Pt(e, t, i);
|
|
321
|
-
case v:
|
|
322
337
|
return It(e, t, i);
|
|
338
|
+
case v:
|
|
339
|
+
return Pt(e, t, i);
|
|
323
340
|
default:
|
|
324
341
|
return { document: e, action: t, skip: i };
|
|
325
342
|
}
|
|
326
343
|
}
|
|
327
|
-
function ct(e, t, i,
|
|
328
|
-
const { skip:
|
|
329
|
-
let
|
|
330
|
-
if (Kt(
|
|
331
|
-
const { document:
|
|
332
|
-
l = m, r =
|
|
344
|
+
function ct(e, t, i, n, o = {}) {
|
|
345
|
+
const { skip: p, ignoreSkipOperations: a = !1 } = o;
|
|
346
|
+
let s = { ...t }, l = p || 0, r = e, x = [...e.clipboard];
|
|
347
|
+
if (Kt(s)) {
|
|
348
|
+
const { document: d, skip: m } = Mt(r, s, l);
|
|
349
|
+
l = m, r = d;
|
|
333
350
|
}
|
|
334
|
-
if (J(
|
|
351
|
+
if (J(s)) {
|
|
335
352
|
const {
|
|
336
|
-
skip:
|
|
353
|
+
skip: d,
|
|
337
354
|
action: m,
|
|
338
355
|
document: f
|
|
339
|
-
} = Wt(e,
|
|
340
|
-
|
|
356
|
+
} = Wt(e, s, l);
|
|
357
|
+
s = m, l = d, r = f, x = [...r.clipboard];
|
|
358
|
+
}
|
|
359
|
+
if (W(s) && (r = Jt(r, s, i)), l > 0 && !a) {
|
|
360
|
+
let d = l;
|
|
361
|
+
"index" in s && (d = Yt(
|
|
362
|
+
r.operations[s.scope],
|
|
363
|
+
s.index,
|
|
364
|
+
l
|
|
365
|
+
)), r = I(
|
|
366
|
+
r.initialState,
|
|
367
|
+
r.operations,
|
|
368
|
+
i,
|
|
369
|
+
void 0,
|
|
370
|
+
void 0,
|
|
371
|
+
void 0,
|
|
372
|
+
{ [s.scope]: d }
|
|
373
|
+
);
|
|
341
374
|
}
|
|
342
|
-
return
|
|
343
|
-
r.initialState,
|
|
344
|
-
r.operations,
|
|
345
|
-
i,
|
|
346
|
-
void 0,
|
|
347
|
-
void 0,
|
|
348
|
-
void 0,
|
|
349
|
-
{ [p.scope]: l }
|
|
350
|
-
)), r = Ct(r, p, l), r = k(r, (u) => {
|
|
375
|
+
return r = Ct(r, s, l), r = k(r, (d) => {
|
|
351
376
|
const m = i(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
377
|
+
d.state,
|
|
378
|
+
s,
|
|
379
|
+
n
|
|
355
380
|
), f = J(t) ? [...x] : [];
|
|
356
381
|
if (m)
|
|
357
382
|
return A({
|
|
@@ -359,28 +384,28 @@ function ct(e, t, i, a, n = {}) {
|
|
|
359
384
|
clipboard: [...f],
|
|
360
385
|
state: m
|
|
361
386
|
});
|
|
362
|
-
|
|
363
|
-
}), k(r, (
|
|
364
|
-
if ([w, v, _].includes(
|
|
365
|
-
return
|
|
366
|
-
const m =
|
|
367
|
-
|
|
368
|
-
const { hash:
|
|
369
|
-
|
|
387
|
+
d.clipboard = A([...f]);
|
|
388
|
+
}), k(r, (d) => {
|
|
389
|
+
if ([w, v, _].includes(s.type))
|
|
390
|
+
return d;
|
|
391
|
+
const m = s.scope || "global";
|
|
392
|
+
d.operations[m][d.operations[m].length - 1].hash = lt(d, m), !W(s) && s.attachments && s.attachments.forEach((f) => {
|
|
393
|
+
const { hash: u, ...j } = f;
|
|
394
|
+
d.attachments[u] = {
|
|
370
395
|
...j
|
|
371
396
|
};
|
|
372
397
|
});
|
|
373
398
|
});
|
|
374
399
|
}
|
|
375
400
|
function Bt(e, t, i) {
|
|
376
|
-
const
|
|
377
|
-
return M.mkdirSync(e, { recursive: !0 }), new Promise((
|
|
401
|
+
const n = _t(e, t);
|
|
402
|
+
return M.mkdirSync(e, { recursive: !0 }), new Promise((o, p) => {
|
|
378
403
|
try {
|
|
379
|
-
M.writeFile(
|
|
380
|
-
|
|
404
|
+
M.writeFile(n, i, {}, (a) => {
|
|
405
|
+
a ? p(a) : o(n);
|
|
381
406
|
});
|
|
382
|
-
} catch (
|
|
383
|
-
|
|
407
|
+
} catch (a) {
|
|
408
|
+
p(a);
|
|
384
409
|
}
|
|
385
410
|
});
|
|
386
411
|
}
|
|
@@ -389,21 +414,21 @@ function rt(e) {
|
|
|
389
414
|
}
|
|
390
415
|
function Zt(e) {
|
|
391
416
|
return new Promise((t, i) => {
|
|
392
|
-
St.get(e, (
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}),
|
|
397
|
-
t({ buffer: Buffer.concat(
|
|
417
|
+
St.get(e, (n) => {
|
|
418
|
+
const o = [], p = n.headers["content-type"];
|
|
419
|
+
n.on("data", (a) => {
|
|
420
|
+
o.push(a);
|
|
421
|
+
}), n.on("end", () => {
|
|
422
|
+
t({ buffer: Buffer.concat(o), mimeType: p });
|
|
398
423
|
});
|
|
399
|
-
}).on("error", (
|
|
400
|
-
i(
|
|
424
|
+
}).on("error", (n) => {
|
|
425
|
+
i(n);
|
|
401
426
|
});
|
|
402
427
|
});
|
|
403
428
|
}
|
|
404
429
|
const Ht = async (e) => rt(e), T = (e, t = "sha1") => kt.createHash(t).update(e).digest("base64");
|
|
405
430
|
function Kt(e) {
|
|
406
|
-
return e.type ===
|
|
431
|
+
return e.type === Lt && e.skip !== void 0 && e.skip > 0 && e.hash !== void 0;
|
|
407
432
|
}
|
|
408
433
|
function J(e) {
|
|
409
434
|
return [w, v].includes(e.type);
|
|
@@ -411,22 +436,22 @@ function J(e) {
|
|
|
411
436
|
function W(e) {
|
|
412
437
|
return [st, w, v, _, pt].includes(e.type);
|
|
413
438
|
}
|
|
414
|
-
function y(e, t, i,
|
|
439
|
+
function y(e, t, i, n, o = "global") {
|
|
415
440
|
if (!e)
|
|
416
441
|
throw new Error("Empty action type");
|
|
417
442
|
if (typeof e != "string")
|
|
418
443
|
throw new Error(`Invalid action type: ${e}`);
|
|
419
|
-
const
|
|
420
|
-
i && (
|
|
444
|
+
const p = { type: e, input: t, scope: o };
|
|
445
|
+
i && (p.attachments = i);
|
|
421
446
|
try {
|
|
422
|
-
|
|
423
|
-
} catch (
|
|
424
|
-
throw new Error(`Invalid action input: ${
|
|
447
|
+
n == null || n().parse(p.input);
|
|
448
|
+
} catch (a) {
|
|
449
|
+
throw new Error(`Invalid action input: ${a}`);
|
|
425
450
|
}
|
|
426
|
-
return
|
|
451
|
+
return p;
|
|
427
452
|
}
|
|
428
453
|
function Vt(e, t = ct) {
|
|
429
|
-
return (i,
|
|
454
|
+
return (i, n, o, p) => t(i, n, e, o, p);
|
|
430
455
|
}
|
|
431
456
|
const Gt = (e, t) => ({
|
|
432
457
|
name: "",
|
|
@@ -451,7 +476,7 @@ const Gt = (e, t) => ({
|
|
|
451
476
|
operations: { global: [], local: [] },
|
|
452
477
|
clipboard: []
|
|
453
478
|
};
|
|
454
|
-
}, lt = (e, t = "global") => T(z(e.state[t])),
|
|
479
|
+
}, lt = (e, t = "global") => T(z(e.state[t])), he = (e, t = 1e3) => {
|
|
455
480
|
const i = Math.random() * t;
|
|
456
481
|
return T(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
457
482
|
};
|
|
@@ -460,89 +485,101 @@ function N(e) {
|
|
|
460
485
|
}
|
|
461
486
|
function Xt(e, t) {
|
|
462
487
|
const i = [...e];
|
|
463
|
-
let
|
|
464
|
-
const
|
|
465
|
-
for (const
|
|
466
|
-
if (
|
|
467
|
-
const r =
|
|
468
|
-
|
|
488
|
+
let n = t || 0, o = i.length > 0 ? i[i.length - 1].index : 0;
|
|
489
|
+
const p = [];
|
|
490
|
+
for (const a of i.reverse()) {
|
|
491
|
+
if (n > 0) {
|
|
492
|
+
const r = o - a.index;
|
|
493
|
+
n -= r;
|
|
469
494
|
}
|
|
470
|
-
if (
|
|
495
|
+
if (n < 0)
|
|
471
496
|
throw new Error("Invalid operation index, missing operations");
|
|
472
|
-
const
|
|
473
|
-
ignore:
|
|
474
|
-
operation:
|
|
475
|
-
}, l =
|
|
476
|
-
if (l > 0 && l >
|
|
477
|
-
const r = l -
|
|
478
|
-
|
|
497
|
+
const s = {
|
|
498
|
+
ignore: n > 0,
|
|
499
|
+
operation: a
|
|
500
|
+
}, l = a.skip > 0 ? a.skip + 1 : 0;
|
|
501
|
+
if (l > 0 && l > n) {
|
|
502
|
+
const r = l - n;
|
|
503
|
+
n = n + r;
|
|
479
504
|
}
|
|
480
|
-
|
|
505
|
+
o = a.index, p.push(s);
|
|
506
|
+
}
|
|
507
|
+
return p.reverse();
|
|
508
|
+
}
|
|
509
|
+
function Yt(e, t, i) {
|
|
510
|
+
const n = e.slice().sort((s, l) => s.skip - l.skip).sort((s, l) => s.index - l.index);
|
|
511
|
+
let o = i, p = 0, a = t;
|
|
512
|
+
for (const s of n.reverse()) {
|
|
513
|
+
const l = a - s.index;
|
|
514
|
+
if (o = o - l, o > -1)
|
|
515
|
+
p++, a = s.index;
|
|
516
|
+
else
|
|
517
|
+
break;
|
|
481
518
|
}
|
|
482
|
-
return
|
|
519
|
+
return p;
|
|
483
520
|
}
|
|
484
|
-
function
|
|
521
|
+
function be(e) {
|
|
485
522
|
return Object.values(e).flatMap((t) => t).sort(
|
|
486
523
|
(t, i) => new Date(t.timestamp).getTime() - new Date(i.timestamp).getTime()
|
|
487
524
|
);
|
|
488
525
|
}
|
|
489
|
-
function
|
|
526
|
+
function te(e) {
|
|
490
527
|
return Object.values(e).flatMap((t) => t).sort(
|
|
491
528
|
(t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
492
529
|
);
|
|
493
530
|
}
|
|
494
|
-
function
|
|
495
|
-
const
|
|
531
|
+
function I(e, t, i, n, o, p = ct, a = {}) {
|
|
532
|
+
const s = Vt(i, p);
|
|
496
533
|
return mt(
|
|
497
534
|
e,
|
|
498
535
|
t,
|
|
499
|
-
|
|
500
|
-
a,
|
|
536
|
+
s,
|
|
501
537
|
n,
|
|
502
|
-
o
|
|
538
|
+
o,
|
|
539
|
+
a
|
|
503
540
|
);
|
|
504
541
|
}
|
|
505
|
-
function mt(e, t, i,
|
|
506
|
-
const
|
|
507
|
-
const
|
|
542
|
+
function mt(e, t, i, n, o, p = {}) {
|
|
543
|
+
const a = Qt(e), s = Object.keys(t).reduce((m, f) => {
|
|
544
|
+
const u = f;
|
|
508
545
|
return {
|
|
509
546
|
...m,
|
|
510
|
-
[
|
|
547
|
+
[u]: t[u].slice(0, o == null ? void 0 : o.revision[u])
|
|
511
548
|
};
|
|
512
|
-
}, {}), l = Object.keys(
|
|
549
|
+
}, {}), l = Object.keys(s).reduce(
|
|
513
550
|
(m, f) => {
|
|
514
|
-
const
|
|
551
|
+
const u = f;
|
|
515
552
|
return {
|
|
516
553
|
...m,
|
|
517
|
-
[
|
|
518
|
-
|
|
519
|
-
|
|
554
|
+
[u]: Xt(
|
|
555
|
+
s[u],
|
|
556
|
+
p[u]
|
|
520
557
|
)
|
|
521
558
|
};
|
|
522
559
|
},
|
|
523
560
|
{}
|
|
524
|
-
), r =
|
|
525
|
-
(m, { ignore: f, operation:
|
|
526
|
-
skip:
|
|
561
|
+
), r = te(l).reduce(
|
|
562
|
+
(m, { ignore: f, operation: u }) => f ? i(m, U(u.scope), n, {
|
|
563
|
+
skip: u.skip,
|
|
527
564
|
ignoreSkipOperations: !0
|
|
528
|
-
}) : i(m,
|
|
529
|
-
skip:
|
|
565
|
+
}) : i(m, u, n, {
|
|
566
|
+
skip: u.skip,
|
|
530
567
|
ignoreSkipOperations: !0
|
|
531
568
|
}),
|
|
532
|
-
|
|
569
|
+
a
|
|
533
570
|
), x = Object.keys(
|
|
534
571
|
r.operations
|
|
535
572
|
).reduce(
|
|
536
573
|
(m, f) => {
|
|
537
|
-
const
|
|
574
|
+
const u = f, j = o && o.revision[u] < t[u].length ? t[u].slice(o.revision[u]) : [];
|
|
538
575
|
return {
|
|
539
576
|
...m,
|
|
540
|
-
[
|
|
541
|
-
...r.operations[
|
|
577
|
+
[u]: [
|
|
578
|
+
...r.operations[u].map((E, wt) => {
|
|
542
579
|
var C;
|
|
543
580
|
return {
|
|
544
581
|
...E,
|
|
545
|
-
timestamp: ((C = t[
|
|
582
|
+
timestamp: ((C = t[u][wt]) == null ? void 0 : C.timestamp) ?? E.timestamp
|
|
546
583
|
};
|
|
547
584
|
}),
|
|
548
585
|
...j
|
|
@@ -550,27 +587,27 @@ function mt(e, t, i, a, n, s = {}) {
|
|
|
550
587
|
};
|
|
551
588
|
},
|
|
552
589
|
{ global: [], local: [] }
|
|
553
|
-
),
|
|
554
|
-
for (const
|
|
555
|
-
|
|
590
|
+
), d = Object.values(x).reduce((m, f) => {
|
|
591
|
+
for (const u of f)
|
|
592
|
+
u.timestamp > m && (m = u.timestamp);
|
|
556
593
|
return m;
|
|
557
594
|
}, e.lastModified);
|
|
558
|
-
return { ...r, operations: x, lastModified:
|
|
595
|
+
return { ...r, operations: x, lastModified: d };
|
|
559
596
|
}
|
|
560
|
-
function
|
|
597
|
+
function we(e, t) {
|
|
561
598
|
return z(e) === z(t);
|
|
562
599
|
}
|
|
563
600
|
const dt = (e) => y(
|
|
564
601
|
"SET_NAME",
|
|
565
602
|
e,
|
|
566
603
|
void 0,
|
|
567
|
-
|
|
604
|
+
L,
|
|
568
605
|
void 0
|
|
569
606
|
), ut = (e = 1, t = "global") => y(
|
|
570
607
|
"UNDO",
|
|
571
608
|
e,
|
|
572
609
|
void 0,
|
|
573
|
-
|
|
610
|
+
q,
|
|
574
611
|
t
|
|
575
612
|
), ft = (e = 1, t = "global") => y(
|
|
576
613
|
"REDO",
|
|
@@ -584,47 +621,47 @@ const dt = (e) => y(
|
|
|
584
621
|
void 0,
|
|
585
622
|
F,
|
|
586
623
|
i
|
|
587
|
-
),
|
|
624
|
+
), $ = (e, t) => y(
|
|
588
625
|
"LOAD_STATE",
|
|
589
626
|
{ state: e, operations: t },
|
|
590
627
|
void 0,
|
|
591
|
-
|
|
592
|
-
),
|
|
628
|
+
P
|
|
629
|
+
), U = (e = "global") => y("NOOP", {}, void 0, void 0, e), ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
593
630
|
__proto__: null,
|
|
594
|
-
loadState:
|
|
595
|
-
noop:
|
|
631
|
+
loadState: $,
|
|
632
|
+
noop: U,
|
|
596
633
|
prune: xt,
|
|
597
634
|
redo: ft,
|
|
598
635
|
setName: dt,
|
|
599
636
|
undo: ut
|
|
600
637
|
}, Symbol.toStringTag, { value: "Module" })), gt = { "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"] };
|
|
601
638
|
Object.freeze(gt);
|
|
602
|
-
var g = function(e, t, i,
|
|
603
|
-
if (i === "a" && !
|
|
639
|
+
var g = function(e, t, i, n) {
|
|
640
|
+
if (i === "a" && !n)
|
|
604
641
|
throw new TypeError("Private accessor was defined without a getter");
|
|
605
|
-
if (typeof t == "function" ? e !== t || !
|
|
642
|
+
if (typeof t == "function" ? e !== t || !n : !t.has(e))
|
|
606
643
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
607
|
-
return i === "m" ?
|
|
644
|
+
return i === "m" ? n : i === "a" ? n.call(e) : n ? n.value : t.get(e);
|
|
608
645
|
}, b, O, h;
|
|
609
|
-
class
|
|
646
|
+
class ee {
|
|
610
647
|
constructor(...t) {
|
|
611
648
|
b.set(this, /* @__PURE__ */ new Map()), O.set(this, /* @__PURE__ */ new Map()), h.set(this, /* @__PURE__ */ new Map());
|
|
612
649
|
for (const i of t)
|
|
613
650
|
this.define(i);
|
|
614
651
|
}
|
|
615
652
|
define(t, i = !1) {
|
|
616
|
-
for (let [
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
let
|
|
620
|
-
for (let
|
|
621
|
-
const l =
|
|
622
|
-
if (
|
|
653
|
+
for (let [n, o] of Object.entries(t)) {
|
|
654
|
+
n = n.toLowerCase(), o = o.map((s) => s.toLowerCase()), g(this, h, "f").has(n) || g(this, h, "f").set(n, /* @__PURE__ */ new Set());
|
|
655
|
+
const p = g(this, h, "f").get(n);
|
|
656
|
+
let a = !0;
|
|
657
|
+
for (let s of o) {
|
|
658
|
+
const l = s.startsWith("*");
|
|
659
|
+
if (s = l ? s.slice(1) : s, p == null || p.add(s), a && g(this, O, "f").set(n, s), a = !1, l)
|
|
623
660
|
continue;
|
|
624
|
-
const r = g(this, b, "f").get(
|
|
625
|
-
if (r && r !=
|
|
626
|
-
throw new Error(`"${
|
|
627
|
-
g(this, b, "f").set(
|
|
661
|
+
const r = g(this, b, "f").get(s);
|
|
662
|
+
if (r && r != n && !i)
|
|
663
|
+
throw new Error(`"${n} -> ${s}" conflicts with "${r} -> ${s}". Pass \`force=true\` to override this definition.`);
|
|
664
|
+
g(this, b, "f").set(s, n);
|
|
628
665
|
}
|
|
629
666
|
}
|
|
630
667
|
return this;
|
|
@@ -632,8 +669,8 @@ class te {
|
|
|
632
669
|
getType(t) {
|
|
633
670
|
if (typeof t != "string")
|
|
634
671
|
return null;
|
|
635
|
-
const i = t.replace(/^.*[/\\]/, "").toLowerCase(),
|
|
636
|
-
return !(
|
|
672
|
+
const i = t.replace(/^.*[/\\]/, "").toLowerCase(), n = i.replace(/^.*\./, "").toLowerCase(), o = i.length < t.length;
|
|
673
|
+
return !(n.length < i.length - 1) && o ? null : g(this, b, "f").get(n) ?? null;
|
|
637
674
|
}
|
|
638
675
|
getExtension(t) {
|
|
639
676
|
var i;
|
|
@@ -658,120 +695,120 @@ class te {
|
|
|
658
695
|
}
|
|
659
696
|
}
|
|
660
697
|
b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap();
|
|
661
|
-
const
|
|
662
|
-
function
|
|
698
|
+
const ie = new ee(gt)._freeze();
|
|
699
|
+
function ne(e) {
|
|
663
700
|
const t = [], i = Object.keys(e);
|
|
664
|
-
for (const
|
|
665
|
-
const
|
|
666
|
-
for (let
|
|
667
|
-
|
|
668
|
-
message: `Invalid operation index ${
|
|
701
|
+
for (const n of i) {
|
|
702
|
+
const o = e[n].sort((p, a) => p.index - a.index);
|
|
703
|
+
for (let p = 0; p < o.length; p++)
|
|
704
|
+
o[p].index !== p && t.push({
|
|
705
|
+
message: `Invalid operation index ${o[p].index} at position ${p}`,
|
|
669
706
|
details: {
|
|
670
|
-
position:
|
|
671
|
-
operation:
|
|
672
|
-
scope:
|
|
707
|
+
position: p,
|
|
708
|
+
operation: o[p],
|
|
709
|
+
scope: o[p].scope
|
|
673
710
|
}
|
|
674
711
|
});
|
|
675
712
|
}
|
|
676
713
|
return t;
|
|
677
714
|
}
|
|
678
715
|
const ht = async (e) => {
|
|
679
|
-
const t = new Z(), { name: i, revision:
|
|
716
|
+
const t = new Z(), { name: i, revision: n, documentType: o, created: p, lastModified: a } = e, s = {
|
|
680
717
|
name: i,
|
|
681
|
-
revision:
|
|
682
|
-
documentType:
|
|
683
|
-
created:
|
|
684
|
-
lastModified:
|
|
718
|
+
revision: n,
|
|
719
|
+
documentType: o,
|
|
720
|
+
created: p,
|
|
721
|
+
lastModified: a
|
|
685
722
|
};
|
|
686
|
-
return t.file("header.json", JSON.stringify(
|
|
723
|
+
return t.file("header.json", JSON.stringify(s, null, 2)), t.file(
|
|
687
724
|
"state.json",
|
|
688
725
|
JSON.stringify(e.initialState || {}, null, 2)
|
|
689
726
|
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((r) => {
|
|
690
|
-
const { data: x, ...
|
|
727
|
+
const { data: x, ...d } = e.attachments[r];
|
|
691
728
|
t.file(r, x, {
|
|
692
729
|
base64: !0,
|
|
693
730
|
createFolders: !0,
|
|
694
|
-
comment: JSON.stringify(
|
|
731
|
+
comment: JSON.stringify(d)
|
|
695
732
|
});
|
|
696
733
|
}), t;
|
|
697
|
-
}, ae = async (e, t, i,
|
|
698
|
-
const
|
|
734
|
+
}, ae = async (e, t, i, n) => {
|
|
735
|
+
const p = await (await ht(e)).generateAsync({
|
|
699
736
|
type: "uint8array",
|
|
700
737
|
streamFiles: !0
|
|
701
|
-
}),
|
|
738
|
+
}), a = n ?? e.name, s = `.${i}.zip`;
|
|
702
739
|
return Bt(
|
|
703
740
|
t,
|
|
704
|
-
|
|
705
|
-
|
|
741
|
+
a.endsWith(s) ? a : `${a}${s}`,
|
|
742
|
+
p
|
|
706
743
|
);
|
|
707
|
-
},
|
|
708
|
-
const
|
|
709
|
-
await
|
|
744
|
+
}, ye = async (e, t) => {
|
|
745
|
+
const n = await (await ht(e)).generateAsync({ type: "blob" }), o = await t.createWritable();
|
|
746
|
+
await o.write(n), await o.close();
|
|
710
747
|
}, B = async (e, t) => {
|
|
711
748
|
const i = rt(e);
|
|
712
|
-
return
|
|
713
|
-
},
|
|
749
|
+
return oe(i, t);
|
|
750
|
+
}, oe = async (e, t) => {
|
|
714
751
|
const i = new Z();
|
|
715
|
-
return await i.loadAsync(e),
|
|
752
|
+
return await i.loadAsync(e), se(i, t);
|
|
716
753
|
};
|
|
717
|
-
async function
|
|
754
|
+
async function se(e, t) {
|
|
718
755
|
const i = e.file("state.json");
|
|
719
756
|
if (!i)
|
|
720
757
|
throw new Error("Initial state not found");
|
|
721
|
-
const
|
|
722
|
-
let
|
|
723
|
-
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
758
|
+
const n = await i.async("string"), o = JSON.parse(n), p = e.file("header.json");
|
|
759
|
+
let a;
|
|
760
|
+
p && (a = JSON.parse(await p.async("string")));
|
|
761
|
+
const s = e.file("operations.json");
|
|
762
|
+
if (!s)
|
|
726
763
|
throw new Error("Operations history not found");
|
|
727
764
|
const l = JSON.parse(
|
|
728
|
-
await
|
|
729
|
-
), r =
|
|
765
|
+
await s.async("string")
|
|
766
|
+
), r = ne(l);
|
|
730
767
|
if (r.length) {
|
|
731
|
-
const
|
|
732
|
-
throw new Error(
|
|
768
|
+
const d = r.map((m) => m.message);
|
|
769
|
+
throw new Error(d.join(`
|
|
733
770
|
`));
|
|
734
771
|
}
|
|
735
772
|
let x = mt(
|
|
736
|
-
|
|
773
|
+
o,
|
|
737
774
|
l,
|
|
738
775
|
t,
|
|
739
776
|
void 0,
|
|
740
|
-
|
|
777
|
+
a
|
|
741
778
|
);
|
|
742
|
-
return
|
|
779
|
+
return a && (x = {
|
|
743
780
|
...x,
|
|
744
|
-
...
|
|
781
|
+
...a
|
|
745
782
|
}), x;
|
|
746
783
|
}
|
|
747
784
|
function bt(e) {
|
|
748
785
|
const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
|
|
749
786
|
return { extension: t, fileName: i };
|
|
750
787
|
}
|
|
751
|
-
async function
|
|
752
|
-
const { buffer: t, mimeType: i = "application/octet-stream" } = await Zt(e),
|
|
788
|
+
async function je(e) {
|
|
789
|
+
const { buffer: t, mimeType: i = "application/octet-stream" } = await Zt(e), n = bt(e), o = t.toString("base64");
|
|
753
790
|
return {
|
|
754
|
-
data:
|
|
755
|
-
hash: T(
|
|
791
|
+
data: o,
|
|
792
|
+
hash: T(o),
|
|
756
793
|
mimeType: i,
|
|
757
|
-
...
|
|
794
|
+
...n
|
|
758
795
|
};
|
|
759
796
|
}
|
|
760
|
-
async function
|
|
761
|
-
const t = await Ht(e), i =
|
|
762
|
-
return { data:
|
|
797
|
+
async function Oe(e) {
|
|
798
|
+
const t = await Ht(e), i = ie.getType(e) || "application/octet-stream", n = bt(e), o = t.toString("base64");
|
|
799
|
+
return { data: o, hash: T(o), mimeType: i, ...n };
|
|
763
800
|
}
|
|
764
|
-
class
|
|
801
|
+
class ke {
|
|
765
802
|
/**
|
|
766
803
|
* Constructs a BaseDocument instance with an initial state.
|
|
767
804
|
* @param reducer - The reducer function that updates the state.
|
|
768
805
|
* @param document - The initial state of the document.
|
|
769
806
|
*/
|
|
770
|
-
constructor(t, i,
|
|
807
|
+
constructor(t, i, n) {
|
|
771
808
|
D(this, "_document");
|
|
772
809
|
D(this, "_reducer");
|
|
773
810
|
D(this, "_signalDispatch");
|
|
774
|
-
this._reducer = t, this._document = i, this._signalDispatch =
|
|
811
|
+
this._reducer = t, this._document = i, this._signalDispatch = n;
|
|
775
812
|
}
|
|
776
813
|
/**
|
|
777
814
|
* Dispatches an action to update the state of the document.
|
|
@@ -792,8 +829,8 @@ class Oe {
|
|
|
792
829
|
* @param extension - The file extension to use when saving the state.
|
|
793
830
|
* @returns The file path where the state was saved.
|
|
794
831
|
*/
|
|
795
|
-
saveToFile(t, i,
|
|
796
|
-
return ae(this._document, t, i,
|
|
832
|
+
saveToFile(t, i, n) {
|
|
833
|
+
return ae(this._document, t, i, n);
|
|
797
834
|
}
|
|
798
835
|
/**
|
|
799
836
|
* Loads the state of the document from a file.
|
|
@@ -910,51 +947,52 @@ class Oe {
|
|
|
910
947
|
* @param operations - The operations to apply to the document.
|
|
911
948
|
*/
|
|
912
949
|
loadState(t, i) {
|
|
913
|
-
return this.dispatch(
|
|
950
|
+
return this.dispatch($(t, i)), this;
|
|
914
951
|
}
|
|
915
952
|
}
|
|
916
|
-
function
|
|
953
|
+
function Se(e, t) {
|
|
917
954
|
t.forEach((i) => {
|
|
918
|
-
Object.getOwnPropertyNames(i.prototype).forEach((
|
|
955
|
+
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
919
956
|
Object.defineProperty(
|
|
920
957
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
921
958
|
e.prototype,
|
|
922
|
-
|
|
959
|
+
n,
|
|
923
960
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
924
|
-
Object.getOwnPropertyDescriptor(i.prototype,
|
|
961
|
+
Object.getOwnPropertyDescriptor(i.prototype, n) || /* @__PURE__ */ Object.create(null)
|
|
925
962
|
);
|
|
926
963
|
});
|
|
927
964
|
});
|
|
928
965
|
}
|
|
929
966
|
export {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
967
|
+
ne as A,
|
|
968
|
+
ke as B,
|
|
969
|
+
ct as C,
|
|
970
|
+
Wt as D,
|
|
971
|
+
ge as E,
|
|
934
972
|
Gt as a,
|
|
935
973
|
Qt as b,
|
|
936
974
|
Vt as c,
|
|
937
|
-
|
|
938
|
-
|
|
975
|
+
ye as d,
|
|
976
|
+
oe as e,
|
|
939
977
|
y as f,
|
|
940
|
-
|
|
941
|
-
|
|
978
|
+
Se as g,
|
|
979
|
+
ve as h,
|
|
942
980
|
W as i,
|
|
943
|
-
|
|
944
|
-
|
|
981
|
+
Yt as j,
|
|
982
|
+
ht as k,
|
|
945
983
|
B as l,
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
984
|
+
Oe as m,
|
|
985
|
+
je as n,
|
|
986
|
+
lt as o,
|
|
987
|
+
he as p,
|
|
988
|
+
Kt as q,
|
|
989
|
+
we as r,
|
|
952
990
|
ae as s,
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
991
|
+
J as t,
|
|
992
|
+
Xt as u,
|
|
993
|
+
N as v,
|
|
994
|
+
mt as w,
|
|
995
|
+
I as x,
|
|
996
|
+
te as y,
|
|
997
|
+
be as z
|
|
960
998
|
};
|