document-model 1.0.51 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/{node/cjs/internal/index-CRjFLQNR.js → browser/cjs/internal/index-BVWyYyNE.js} +1 -1
- package/dist/browser/cjs/internal/{index-CPJM383s.js → index-CnVGNZ9_.js} +1 -1
- package/dist/browser/cjs/internal/object-5l5_pTNL.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +2 -2
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/{index-tEH7iGUj.js → index-CF0d1_Cg.js} +1 -1
- package/dist/browser/es/internal/{index-BzIVYv7p.js → index-aS_vqu4O.js} +1 -1
- package/dist/browser/es/internal/{object-Dev4WFVH.js → object-BdaEhPk1.js} +770 -771
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +2 -0
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/{browser/cjs/internal/index-REU04m7f.js → node/cjs/internal/index-B9gc2lPN.js} +1 -1
- package/dist/node/cjs/internal/{index-BX95XaQ_.js → index-JtuONOcD.js} +1 -1
- package/dist/node/cjs/internal/object-D6wRzEDN.js +20 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +2 -2
- package/dist/node/es/index.js +3 -3
- package/dist/node/es/internal/{index-BzNCX_-9.js → index-BclkoIYP.js} +1 -1
- package/dist/node/es/internal/{index-DpH4_29z.js → index-EY0PPZnJ.js} +1 -1
- package/dist/node/es/internal/{object-BFkXGmt6.js → object-BxC3xMqY.js} +509 -510
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/browser/cjs/internal/object-DkoS83BB.js +0 -25
- package/dist/node/cjs/internal/object-CGt7Qacd.js +0 -20
|
@@ -2,24 +2,24 @@ var Gt = Object.defineProperty;
|
|
|
2
2
|
var Qt = (e, t, i) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
3
|
var nt = (e, t, i) => (Qt(e, typeof t != "symbol" ? t + "" : t, i), i);
|
|
4
4
|
import { produce as G, castDraft as pt, castImmutable as Xt, freeze as Yt } from "immer";
|
|
5
|
-
import { z as
|
|
5
|
+
import { z as m } from "zod";
|
|
6
6
|
import te from "crypto";
|
|
7
7
|
import ct from "fs";
|
|
8
8
|
import ee from "https";
|
|
9
9
|
import { join as ie } from "path";
|
|
10
|
-
import
|
|
11
|
-
const $t = (e) => e != null, ne =
|
|
10
|
+
import Ot from "jszip";
|
|
11
|
+
const $t = (e) => e != null, ne = m.any().refine((e) => $t(e)), Et = m.enum(["LOAD_STATE"]), vt = m.enum(["PRUNE"]), Tt = m.enum(["REDO"]), _t = m.enum(["SET_NAME"]), kt = m.enum(["UNDO"]);
|
|
12
12
|
function oe() {
|
|
13
|
-
return
|
|
14
|
-
__typename:
|
|
15
|
-
type:
|
|
13
|
+
return m.object({
|
|
14
|
+
__typename: m.literal("Action").optional(),
|
|
15
|
+
type: m.string()
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
function Q() {
|
|
19
|
-
return
|
|
19
|
+
return m.literal("global").or(m.literal("local"));
|
|
20
20
|
}
|
|
21
21
|
function At() {
|
|
22
|
-
return
|
|
22
|
+
return m.union([
|
|
23
23
|
Nt(),
|
|
24
24
|
Mt(),
|
|
25
25
|
Pt(),
|
|
@@ -27,87 +27,87 @@ function At() {
|
|
|
27
27
|
zt()
|
|
28
28
|
]);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
32
|
-
__typename:
|
|
33
|
-
data:
|
|
34
|
-
extension:
|
|
35
|
-
fileName:
|
|
36
|
-
mimeType:
|
|
30
|
+
function re() {
|
|
31
|
+
return m.object({
|
|
32
|
+
__typename: m.literal("DocumentFile").optional(),
|
|
33
|
+
data: m.string(),
|
|
34
|
+
extension: m.string().nullable(),
|
|
35
|
+
fileName: m.string().nullable(),
|
|
36
|
+
mimeType: m.string()
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
function Nt() {
|
|
40
|
-
return
|
|
41
|
-
input:
|
|
40
|
+
return m.object({
|
|
41
|
+
input: m.lazy(() => ut()),
|
|
42
42
|
type: Et,
|
|
43
43
|
scope: Q()
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
function ut() {
|
|
47
|
-
return
|
|
48
|
-
operations:
|
|
49
|
-
state:
|
|
47
|
+
return m.object({
|
|
48
|
+
operations: m.number(),
|
|
49
|
+
state: m.lazy(() => Dt())
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
function Dt() {
|
|
53
|
-
return
|
|
54
|
-
data:
|
|
55
|
-
name:
|
|
53
|
+
return m.object({
|
|
54
|
+
data: m.unknown().nullish(),
|
|
55
|
+
name: m.string()
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return
|
|
60
|
-
__typename:
|
|
61
|
-
hash:
|
|
62
|
-
index:
|
|
63
|
-
timestamp:
|
|
64
|
-
type:
|
|
58
|
+
function se() {
|
|
59
|
+
return m.object({
|
|
60
|
+
__typename: m.literal("Operation").optional(),
|
|
61
|
+
hash: m.string(),
|
|
62
|
+
index: m.number(),
|
|
63
|
+
timestamp: m.string().datetime(),
|
|
64
|
+
type: m.string()
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
function Mt() {
|
|
68
|
-
return
|
|
69
|
-
input:
|
|
68
|
+
return m.object({
|
|
69
|
+
input: m.lazy(() => ft()),
|
|
70
70
|
type: vt,
|
|
71
71
|
scope: Q()
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
function ft() {
|
|
75
|
-
return
|
|
76
|
-
end:
|
|
77
|
-
start:
|
|
75
|
+
return m.object({
|
|
76
|
+
end: m.number().nullish(),
|
|
77
|
+
start: m.number().nullish()
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
const dt =
|
|
80
|
+
const dt = m.number;
|
|
81
81
|
function Pt() {
|
|
82
|
-
return
|
|
82
|
+
return m.object({
|
|
83
83
|
input: dt(),
|
|
84
84
|
type: Tt,
|
|
85
85
|
scope: Q()
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
const gt =
|
|
88
|
+
const gt = m.string;
|
|
89
89
|
function It() {
|
|
90
|
-
return
|
|
90
|
+
return m.object({
|
|
91
91
|
input: gt(),
|
|
92
|
-
type:
|
|
93
|
-
scope:
|
|
92
|
+
type: _t,
|
|
93
|
+
scope: m.literal("global")
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
function ae() {
|
|
97
|
-
return
|
|
98
|
-
__typename:
|
|
99
|
-
hash:
|
|
100
|
-
index:
|
|
101
|
-
input:
|
|
102
|
-
timestamp:
|
|
103
|
-
type:
|
|
97
|
+
return m.object({
|
|
98
|
+
__typename: m.literal("SetNameOperation").optional(),
|
|
99
|
+
hash: m.string(),
|
|
100
|
+
index: m.number(),
|
|
101
|
+
input: m.string(),
|
|
102
|
+
timestamp: m.string().datetime(),
|
|
103
|
+
type: m.string()
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
const ht =
|
|
106
|
+
const ht = m.number;
|
|
107
107
|
function zt() {
|
|
108
|
-
return
|
|
108
|
+
return m.object({
|
|
109
109
|
input: ht(),
|
|
110
|
-
type:
|
|
110
|
+
type: kt,
|
|
111
111
|
scope: Q()
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -115,12 +115,12 @@ const We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
115
115
|
__proto__: null,
|
|
116
116
|
ActionSchema: oe,
|
|
117
117
|
BaseActionSchema: At,
|
|
118
|
-
DocumentFileSchema:
|
|
118
|
+
DocumentFileSchema: re,
|
|
119
119
|
LoadStateActionInputSchema: ut,
|
|
120
120
|
LoadStateActionSchema: Nt,
|
|
121
121
|
LoadStateActionStateInputSchema: Dt,
|
|
122
122
|
Load_StateSchema: Et,
|
|
123
|
-
OperationSchema:
|
|
123
|
+
OperationSchema: se,
|
|
124
124
|
OperationScopeSchema: Q,
|
|
125
125
|
PruneActionInputSchema: ft,
|
|
126
126
|
PruneActionSchema: Mt,
|
|
@@ -131,10 +131,10 @@ const We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
131
131
|
SetNameActionInputSchema: gt,
|
|
132
132
|
SetNameActionSchema: It,
|
|
133
133
|
SetNameOperationSchema: ae,
|
|
134
|
-
Set_NameSchema:
|
|
134
|
+
Set_NameSchema: _t,
|
|
135
135
|
UndoActionInputSchema: ht,
|
|
136
136
|
UndoActionSchema: zt,
|
|
137
|
-
UndoSchema:
|
|
137
|
+
UndoSchema: kt,
|
|
138
138
|
definedNonNullAnySchema: ne,
|
|
139
139
|
isDefinedNonNullAny: $t
|
|
140
140
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -143,23 +143,23 @@ function pe(e) {
|
|
|
143
143
|
}
|
|
144
144
|
var lt = { exports: {} };
|
|
145
145
|
(function(e, t) {
|
|
146
|
-
const { hasOwnProperty: i } = Object.prototype, n =
|
|
147
|
-
n.configure =
|
|
146
|
+
const { hasOwnProperty: i } = Object.prototype, n = E();
|
|
147
|
+
n.configure = E, n.stringify = n, n.default = n, t.stringify = n, t.configure = E, e.exports = n;
|
|
148
148
|
const a = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
|
|
149
|
-
function
|
|
150
|
-
return
|
|
149
|
+
function s(c) {
|
|
150
|
+
return c.length < 5e3 && !a.test(c) ? `"${c}"` : JSON.stringify(c);
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
155
|
-
for (let
|
|
156
|
-
const
|
|
157
|
-
let
|
|
158
|
-
for (;
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
function r(c) {
|
|
153
|
+
if (c.length > 200)
|
|
154
|
+
return c.sort();
|
|
155
|
+
for (let u = 1; u < c.length; u++) {
|
|
156
|
+
const y = c[u];
|
|
157
|
+
let P = u;
|
|
158
|
+
for (; P !== 0 && c[P - 1] > y; )
|
|
159
|
+
c[P] = c[P - 1], P--;
|
|
160
|
+
c[P] = y;
|
|
161
161
|
}
|
|
162
|
-
return
|
|
162
|
+
return c;
|
|
163
163
|
}
|
|
164
164
|
const l = Object.getOwnPropertyDescriptor(
|
|
165
165
|
Object.getPrototypeOf(
|
|
@@ -169,25 +169,25 @@ var lt = { exports: {} };
|
|
|
169
169
|
),
|
|
170
170
|
Symbol.toStringTag
|
|
171
171
|
).get;
|
|
172
|
-
function c
|
|
173
|
-
return l.call(
|
|
172
|
+
function p(c) {
|
|
173
|
+
return l.call(c) !== void 0 && c.length !== 0;
|
|
174
174
|
}
|
|
175
|
-
function x(
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
let
|
|
179
|
-
for (let R = 1; R <
|
|
180
|
-
|
|
181
|
-
return
|
|
175
|
+
function x(c, u, y) {
|
|
176
|
+
c.length < y && (y = c.length);
|
|
177
|
+
const P = u === "," ? "" : " ";
|
|
178
|
+
let V = `"0":${P}${c[0]}`;
|
|
179
|
+
for (let R = 1; R < y; R++)
|
|
180
|
+
V += `${u}"${R}":${P}${c[R]}`;
|
|
181
|
+
return V;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
if (i.call(
|
|
185
|
-
const
|
|
186
|
-
if (typeof
|
|
187
|
-
return `"${
|
|
188
|
-
if (
|
|
189
|
-
return
|
|
190
|
-
if (
|
|
183
|
+
function b(c) {
|
|
184
|
+
if (i.call(c, "circularValue")) {
|
|
185
|
+
const u = c.circularValue;
|
|
186
|
+
if (typeof u == "string")
|
|
187
|
+
return `"${u}"`;
|
|
188
|
+
if (u == null)
|
|
189
|
+
return u;
|
|
190
|
+
if (u === Error || u === TypeError)
|
|
191
191
|
return {
|
|
192
192
|
toString() {
|
|
193
193
|
throw new TypeError("Converting circular structure to JSON");
|
|
@@ -197,83 +197,83 @@ var lt = { exports: {} };
|
|
|
197
197
|
}
|
|
198
198
|
return '"[Circular]"';
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
let
|
|
202
|
-
if (i.call(
|
|
203
|
-
throw new TypeError(`The "${
|
|
204
|
-
return
|
|
200
|
+
function v(c, u) {
|
|
201
|
+
let y;
|
|
202
|
+
if (i.call(c, u) && (y = c[u], typeof y != "boolean"))
|
|
203
|
+
throw new TypeError(`The "${u}" argument must be of type boolean`);
|
|
204
|
+
return y === void 0 ? !0 : y;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
let
|
|
208
|
-
if (i.call(
|
|
209
|
-
if (
|
|
210
|
-
throw new TypeError(`The "${
|
|
211
|
-
if (!Number.isInteger(
|
|
212
|
-
throw new TypeError(`The "${
|
|
213
|
-
if (
|
|
214
|
-
throw new RangeError(`The "${
|
|
206
|
+
function h(c, u) {
|
|
207
|
+
let y;
|
|
208
|
+
if (i.call(c, u)) {
|
|
209
|
+
if (y = c[u], typeof y != "number")
|
|
210
|
+
throw new TypeError(`The "${u}" argument must be of type number`);
|
|
211
|
+
if (!Number.isInteger(y))
|
|
212
|
+
throw new TypeError(`The "${u}" argument must be an integer`);
|
|
213
|
+
if (y < 1)
|
|
214
|
+
throw new RangeError(`The "${u}" argument must be >= 1`);
|
|
215
215
|
}
|
|
216
|
-
return
|
|
216
|
+
return y === void 0 ? 1 / 0 : y;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
218
|
+
function O(c) {
|
|
219
|
+
return c === 1 ? "1 item" : `${c} items`;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
for (const
|
|
224
|
-
(typeof
|
|
225
|
-
return
|
|
221
|
+
function $(c) {
|
|
222
|
+
const u = /* @__PURE__ */ new Set();
|
|
223
|
+
for (const y of c)
|
|
224
|
+
(typeof y == "string" || typeof y == "number") && u.add(String(y));
|
|
225
|
+
return u;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
if (i.call(
|
|
229
|
-
const
|
|
230
|
-
if (typeof
|
|
227
|
+
function D(c) {
|
|
228
|
+
if (i.call(c, "strict")) {
|
|
229
|
+
const u = c.strict;
|
|
230
|
+
if (typeof u != "boolean")
|
|
231
231
|
throw new TypeError('The "strict" argument must be of type boolean');
|
|
232
|
-
if (
|
|
233
|
-
return (
|
|
234
|
-
let
|
|
235
|
-
throw typeof
|
|
232
|
+
if (u)
|
|
233
|
+
return (y) => {
|
|
234
|
+
let P = `Object can not safely be stringified. Received type ${typeof y}`;
|
|
235
|
+
throw typeof y != "function" && (P += ` (${y.toString()})`), new Error(P);
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
function tt(
|
|
245
|
-
let d = o[
|
|
246
|
-
switch (typeof d == "object" && d !== null && typeof d.toJSON == "function" && (d = d.toJSON(
|
|
239
|
+
function E(c) {
|
|
240
|
+
c = { ...c };
|
|
241
|
+
const u = D(c);
|
|
242
|
+
u && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
|
|
243
|
+
const y = b(c), P = v(c, "bigint"), V = v(c, "deterministic"), R = h(c, "maximumDepth"), k = h(c, "maximumBreadth");
|
|
244
|
+
function tt(I, o, f, w, g, S) {
|
|
245
|
+
let d = o[I];
|
|
246
|
+
switch (typeof d == "object" && d !== null && typeof d.toJSON == "function" && (d = d.toJSON(I)), d = w.call(o, I, d), typeof d) {
|
|
247
247
|
case "string":
|
|
248
|
-
return
|
|
248
|
+
return s(d);
|
|
249
249
|
case "object": {
|
|
250
250
|
if (d === null)
|
|
251
251
|
return "null";
|
|
252
252
|
if (f.indexOf(d) !== -1)
|
|
253
|
-
return
|
|
254
|
-
let
|
|
255
|
-
const
|
|
253
|
+
return y;
|
|
254
|
+
let j = "", _ = ",";
|
|
255
|
+
const A = S;
|
|
256
256
|
if (Array.isArray(d)) {
|
|
257
257
|
if (d.length === 0)
|
|
258
258
|
return "[]";
|
|
259
259
|
if (R < f.length + 1)
|
|
260
260
|
return '"[Array]"';
|
|
261
|
-
f.push(d),
|
|
262
|
-
${
|
|
263
|
-
${
|
|
264
|
-
const
|
|
265
|
-
let
|
|
266
|
-
for (;
|
|
267
|
-
const it = tt(String(
|
|
268
|
-
|
|
261
|
+
f.push(d), g !== "" && (S += g, j += `
|
|
262
|
+
${S}`, _ = `,
|
|
263
|
+
${S}`);
|
|
264
|
+
const F = Math.min(d.length, k);
|
|
265
|
+
let J = 0;
|
|
266
|
+
for (; J < F - 1; J++) {
|
|
267
|
+
const it = tt(String(J), d, f, w, g, S);
|
|
268
|
+
j += it !== void 0 ? it : "null", j += _;
|
|
269
269
|
}
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const it = d.length -
|
|
273
|
-
|
|
270
|
+
const C = tt(String(J), d, f, w, g, S);
|
|
271
|
+
if (j += C !== void 0 ? C : "null", d.length - 1 > k) {
|
|
272
|
+
const it = d.length - k - 1;
|
|
273
|
+
j += `${_}"... ${O(it)} not stringified"`;
|
|
274
274
|
}
|
|
275
|
-
return
|
|
276
|
-
${
|
|
275
|
+
return g !== "" && (j += `
|
|
276
|
+
${A}`), f.pop(), `[${j}]`;
|
|
277
277
|
}
|
|
278
278
|
let N = Object.keys(d);
|
|
279
279
|
const M = N.length;
|
|
@@ -281,256 +281,256 @@ ${k}`), f.pop(), `[${w}]`;
|
|
|
281
281
|
return "{}";
|
|
282
282
|
if (R < f.length + 1)
|
|
283
283
|
return '"[Object]"';
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
${
|
|
287
|
-
const q = Math.min(M,
|
|
288
|
-
|
|
289
|
-
for (let
|
|
290
|
-
const
|
|
291
|
-
|
|
284
|
+
let T = "", z = "";
|
|
285
|
+
g !== "" && (S += g, _ = `,
|
|
286
|
+
${S}`, T = " ");
|
|
287
|
+
const q = Math.min(M, k);
|
|
288
|
+
V && !p(d) && (N = r(N)), f.push(d);
|
|
289
|
+
for (let F = 0; F < q; F++) {
|
|
290
|
+
const J = N[F], C = tt(J, d, f, w, g, S);
|
|
291
|
+
C !== void 0 && (j += `${z}${s(J)}:${T}${C}`, z = _);
|
|
292
292
|
}
|
|
293
|
-
if (M >
|
|
294
|
-
const
|
|
295
|
-
|
|
293
|
+
if (M > k) {
|
|
294
|
+
const F = M - k;
|
|
295
|
+
j += `${z}"...":${T}"${O(F)} not stringified"`, z = _;
|
|
296
296
|
}
|
|
297
|
-
return
|
|
298
|
-
${
|
|
299
|
-
${
|
|
297
|
+
return g !== "" && z.length > 1 && (j = `
|
|
298
|
+
${S}${j}
|
|
299
|
+
${A}`), f.pop(), `{${j}}`;
|
|
300
300
|
}
|
|
301
301
|
case "number":
|
|
302
|
-
return isFinite(d) ? String(d) :
|
|
302
|
+
return isFinite(d) ? String(d) : u ? u(d) : "null";
|
|
303
303
|
case "boolean":
|
|
304
304
|
return d === !0 ? "true" : "false";
|
|
305
305
|
case "undefined":
|
|
306
306
|
return;
|
|
307
307
|
case "bigint":
|
|
308
|
-
if (
|
|
308
|
+
if (P)
|
|
309
309
|
return String(d);
|
|
310
310
|
default:
|
|
311
|
-
return
|
|
311
|
+
return u ? u(d) : void 0;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
function et(
|
|
315
|
-
switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(
|
|
314
|
+
function et(I, o, f, w, g, S) {
|
|
315
|
+
switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(I)), typeof o) {
|
|
316
316
|
case "string":
|
|
317
|
-
return
|
|
317
|
+
return s(o);
|
|
318
318
|
case "object": {
|
|
319
319
|
if (o === null)
|
|
320
320
|
return "null";
|
|
321
321
|
if (f.indexOf(o) !== -1)
|
|
322
|
-
return
|
|
323
|
-
const d =
|
|
324
|
-
let
|
|
322
|
+
return y;
|
|
323
|
+
const d = S;
|
|
324
|
+
let j = "", _ = ",";
|
|
325
325
|
if (Array.isArray(o)) {
|
|
326
326
|
if (o.length === 0)
|
|
327
327
|
return "[]";
|
|
328
328
|
if (R < f.length + 1)
|
|
329
329
|
return '"[Array]"';
|
|
330
|
-
f.push(o),
|
|
331
|
-
${
|
|
332
|
-
${
|
|
333
|
-
const M = Math.min(o.length,
|
|
334
|
-
let
|
|
335
|
-
for (;
|
|
336
|
-
const q = et(String(
|
|
337
|
-
|
|
330
|
+
f.push(o), g !== "" && (S += g, j += `
|
|
331
|
+
${S}`, _ = `,
|
|
332
|
+
${S}`);
|
|
333
|
+
const M = Math.min(o.length, k);
|
|
334
|
+
let T = 0;
|
|
335
|
+
for (; T < M - 1; T++) {
|
|
336
|
+
const q = et(String(T), o[T], f, w, g, S);
|
|
337
|
+
j += q !== void 0 ? q : "null", j += _;
|
|
338
338
|
}
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const q = o.length -
|
|
342
|
-
|
|
339
|
+
const z = et(String(T), o[T], f, w, g, S);
|
|
340
|
+
if (j += z !== void 0 ? z : "null", o.length - 1 > k) {
|
|
341
|
+
const q = o.length - k - 1;
|
|
342
|
+
j += `${_}"... ${O(q)} not stringified"`;
|
|
343
343
|
}
|
|
344
|
-
return
|
|
345
|
-
${d}`), f.pop(), `[${
|
|
344
|
+
return g !== "" && (j += `
|
|
345
|
+
${d}`), f.pop(), `[${j}]`;
|
|
346
346
|
}
|
|
347
347
|
f.push(o);
|
|
348
|
-
let
|
|
349
|
-
|
|
350
|
-
${
|
|
348
|
+
let A = "";
|
|
349
|
+
g !== "" && (S += g, _ = `,
|
|
350
|
+
${S}`, A = " ");
|
|
351
351
|
let N = "";
|
|
352
|
-
for (const M of
|
|
353
|
-
const
|
|
354
|
-
|
|
352
|
+
for (const M of w) {
|
|
353
|
+
const T = et(M, o[M], f, w, g, S);
|
|
354
|
+
T !== void 0 && (j += `${N}${s(M)}:${A}${T}`, N = _);
|
|
355
355
|
}
|
|
356
|
-
return
|
|
357
|
-
${
|
|
358
|
-
${d}`), f.pop(), `{${
|
|
356
|
+
return g !== "" && N.length > 1 && (j = `
|
|
357
|
+
${S}${j}
|
|
358
|
+
${d}`), f.pop(), `{${j}}`;
|
|
359
359
|
}
|
|
360
360
|
case "number":
|
|
361
|
-
return isFinite(o) ? String(o) :
|
|
361
|
+
return isFinite(o) ? String(o) : u ? u(o) : "null";
|
|
362
362
|
case "boolean":
|
|
363
363
|
return o === !0 ? "true" : "false";
|
|
364
364
|
case "undefined":
|
|
365
365
|
return;
|
|
366
366
|
case "bigint":
|
|
367
|
-
if (
|
|
367
|
+
if (P)
|
|
368
368
|
return String(o);
|
|
369
369
|
default:
|
|
370
|
-
return
|
|
370
|
+
return u ? u(o) : void 0;
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
function W(
|
|
373
|
+
function W(I, o, f, w, g) {
|
|
374
374
|
switch (typeof o) {
|
|
375
375
|
case "string":
|
|
376
|
-
return
|
|
376
|
+
return s(o);
|
|
377
377
|
case "object": {
|
|
378
378
|
if (o === null)
|
|
379
379
|
return "null";
|
|
380
380
|
if (typeof o.toJSON == "function") {
|
|
381
|
-
if (o = o.toJSON(
|
|
382
|
-
return W(
|
|
381
|
+
if (o = o.toJSON(I), typeof o != "object")
|
|
382
|
+
return W(I, o, f, w, g);
|
|
383
383
|
if (o === null)
|
|
384
384
|
return "null";
|
|
385
385
|
}
|
|
386
386
|
if (f.indexOf(o) !== -1)
|
|
387
|
-
return
|
|
388
|
-
const
|
|
387
|
+
return y;
|
|
388
|
+
const S = g;
|
|
389
389
|
if (Array.isArray(o)) {
|
|
390
390
|
if (o.length === 0)
|
|
391
391
|
return "[]";
|
|
392
392
|
if (R < f.length + 1)
|
|
393
393
|
return '"[Array]"';
|
|
394
|
-
f.push(o),
|
|
395
|
-
let
|
|
396
|
-
${
|
|
397
|
-
const
|
|
398
|
-
${
|
|
399
|
-
let
|
|
400
|
-
for (;
|
|
401
|
-
const
|
|
402
|
-
|
|
394
|
+
f.push(o), g += w;
|
|
395
|
+
let T = `
|
|
396
|
+
${g}`;
|
|
397
|
+
const z = `,
|
|
398
|
+
${g}`, q = Math.min(o.length, k);
|
|
399
|
+
let F = 0;
|
|
400
|
+
for (; F < q - 1; F++) {
|
|
401
|
+
const C = W(String(F), o[F], f, w, g);
|
|
402
|
+
T += C !== void 0 ? C : "null", T += z;
|
|
403
403
|
}
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const
|
|
407
|
-
|
|
404
|
+
const J = W(String(F), o[F], f, w, g);
|
|
405
|
+
if (T += J !== void 0 ? J : "null", o.length - 1 > k) {
|
|
406
|
+
const C = o.length - k - 1;
|
|
407
|
+
T += `${z}"... ${O(C)} not stringified"`;
|
|
408
408
|
}
|
|
409
|
-
return
|
|
410
|
-
${
|
|
409
|
+
return T += `
|
|
410
|
+
${S}`, f.pop(), `[${T}]`;
|
|
411
411
|
}
|
|
412
412
|
let d = Object.keys(o);
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
413
|
+
const j = d.length;
|
|
414
|
+
if (j === 0)
|
|
415
415
|
return "{}";
|
|
416
416
|
if (R < f.length + 1)
|
|
417
417
|
return '"[Object]"';
|
|
418
|
-
|
|
419
|
-
const
|
|
420
|
-
${
|
|
421
|
-
let
|
|
422
|
-
|
|
423
|
-
for (let
|
|
424
|
-
const
|
|
425
|
-
q !== void 0 && (
|
|
418
|
+
g += w;
|
|
419
|
+
const _ = `,
|
|
420
|
+
${g}`;
|
|
421
|
+
let A = "", N = "", M = Math.min(j, k);
|
|
422
|
+
p(o) && (A += x(o, _, k), d = d.slice(o.length), M -= o.length, N = _), V && (d = r(d)), f.push(o);
|
|
423
|
+
for (let T = 0; T < M; T++) {
|
|
424
|
+
const z = d[T], q = W(z, o[z], f, w, g);
|
|
425
|
+
q !== void 0 && (A += `${N}${s(z)}: ${q}`, N = _);
|
|
426
426
|
}
|
|
427
|
-
if (
|
|
428
|
-
const
|
|
429
|
-
|
|
427
|
+
if (j > k) {
|
|
428
|
+
const T = j - k;
|
|
429
|
+
A += `${N}"...": "${O(T)} not stringified"`, N = _;
|
|
430
430
|
}
|
|
431
|
-
return N !== "" && (
|
|
432
|
-
${
|
|
433
|
-
${
|
|
431
|
+
return N !== "" && (A = `
|
|
432
|
+
${g}${A}
|
|
433
|
+
${S}`), f.pop(), `{${A}}`;
|
|
434
434
|
}
|
|
435
435
|
case "number":
|
|
436
|
-
return isFinite(o) ? String(o) :
|
|
436
|
+
return isFinite(o) ? String(o) : u ? u(o) : "null";
|
|
437
437
|
case "boolean":
|
|
438
438
|
return o === !0 ? "true" : "false";
|
|
439
439
|
case "undefined":
|
|
440
440
|
return;
|
|
441
441
|
case "bigint":
|
|
442
|
-
if (
|
|
442
|
+
if (P)
|
|
443
443
|
return String(o);
|
|
444
444
|
default:
|
|
445
|
-
return
|
|
445
|
+
return u ? u(o) : void 0;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
function B(
|
|
448
|
+
function B(I, o, f) {
|
|
449
449
|
switch (typeof o) {
|
|
450
450
|
case "string":
|
|
451
|
-
return
|
|
451
|
+
return s(o);
|
|
452
452
|
case "object": {
|
|
453
453
|
if (o === null)
|
|
454
454
|
return "null";
|
|
455
455
|
if (typeof o.toJSON == "function") {
|
|
456
|
-
if (o = o.toJSON(
|
|
457
|
-
return B(
|
|
456
|
+
if (o = o.toJSON(I), typeof o != "object")
|
|
457
|
+
return B(I, o, f);
|
|
458
458
|
if (o === null)
|
|
459
459
|
return "null";
|
|
460
460
|
}
|
|
461
461
|
if (f.indexOf(o) !== -1)
|
|
462
|
-
return
|
|
463
|
-
let
|
|
462
|
+
return y;
|
|
463
|
+
let w = "";
|
|
464
464
|
if (Array.isArray(o)) {
|
|
465
465
|
if (o.length === 0)
|
|
466
466
|
return "[]";
|
|
467
467
|
if (R < f.length + 1)
|
|
468
468
|
return '"[Array]"';
|
|
469
469
|
f.push(o);
|
|
470
|
-
const
|
|
471
|
-
let
|
|
472
|
-
for (;
|
|
473
|
-
const M = B(String(
|
|
474
|
-
|
|
470
|
+
const _ = Math.min(o.length, k);
|
|
471
|
+
let A = 0;
|
|
472
|
+
for (; A < _ - 1; A++) {
|
|
473
|
+
const M = B(String(A), o[A], f);
|
|
474
|
+
w += M !== void 0 ? M : "null", w += ",";
|
|
475
475
|
}
|
|
476
|
-
const N = B(String(
|
|
477
|
-
if (
|
|
478
|
-
const M = o.length -
|
|
479
|
-
|
|
476
|
+
const N = B(String(A), o[A], f);
|
|
477
|
+
if (w += N !== void 0 ? N : "null", o.length - 1 > k) {
|
|
478
|
+
const M = o.length - k - 1;
|
|
479
|
+
w += `,"... ${O(M)} not stringified"`;
|
|
480
480
|
}
|
|
481
|
-
return f.pop(), `[${
|
|
481
|
+
return f.pop(), `[${w}]`;
|
|
482
482
|
}
|
|
483
|
-
let
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
483
|
+
let g = Object.keys(o);
|
|
484
|
+
const S = g.length;
|
|
485
|
+
if (S === 0)
|
|
486
486
|
return "{}";
|
|
487
487
|
if (R < f.length + 1)
|
|
488
488
|
return '"[Object]"';
|
|
489
|
-
let d = "",
|
|
490
|
-
|
|
491
|
-
for (let
|
|
492
|
-
const
|
|
493
|
-
N !== void 0 && (
|
|
489
|
+
let d = "", j = Math.min(S, k);
|
|
490
|
+
p(o) && (w += x(o, ",", k), g = g.slice(o.length), j -= o.length, d = ","), V && (g = r(g)), f.push(o);
|
|
491
|
+
for (let _ = 0; _ < j; _++) {
|
|
492
|
+
const A = g[_], N = B(A, o[A], f);
|
|
493
|
+
N !== void 0 && (w += `${d}${s(A)}:${N}`, d = ",");
|
|
494
494
|
}
|
|
495
|
-
if (
|
|
496
|
-
const
|
|
497
|
-
|
|
495
|
+
if (S > k) {
|
|
496
|
+
const _ = S - k;
|
|
497
|
+
w += `${d}"...":"${O(_)} not stringified"`;
|
|
498
498
|
}
|
|
499
|
-
return f.pop(), `{${
|
|
499
|
+
return f.pop(), `{${w}}`;
|
|
500
500
|
}
|
|
501
501
|
case "number":
|
|
502
|
-
return isFinite(o) ? String(o) :
|
|
502
|
+
return isFinite(o) ? String(o) : u ? u(o) : "null";
|
|
503
503
|
case "boolean":
|
|
504
504
|
return o === !0 ? "true" : "false";
|
|
505
505
|
case "undefined":
|
|
506
506
|
return;
|
|
507
507
|
case "bigint":
|
|
508
|
-
if (
|
|
508
|
+
if (P)
|
|
509
509
|
return String(o);
|
|
510
510
|
default:
|
|
511
|
-
return
|
|
511
|
+
return u ? u(o) : void 0;
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
function Zt(
|
|
514
|
+
function Zt(I, o, f) {
|
|
515
515
|
if (arguments.length > 1) {
|
|
516
|
-
let
|
|
517
|
-
if (typeof f == "number" ?
|
|
516
|
+
let w = "";
|
|
517
|
+
if (typeof f == "number" ? w = " ".repeat(Math.min(f, 10)) : typeof f == "string" && (w = f.slice(0, 10)), o != null) {
|
|
518
518
|
if (typeof o == "function")
|
|
519
|
-
return tt("", { "":
|
|
519
|
+
return tt("", { "": I }, [], o, w, "");
|
|
520
520
|
if (Array.isArray(o))
|
|
521
|
-
return et("",
|
|
521
|
+
return et("", I, [], $(o), w, "");
|
|
522
522
|
}
|
|
523
|
-
if (
|
|
524
|
-
return W("",
|
|
523
|
+
if (w.length !== 0)
|
|
524
|
+
return W("", I, [], w, "");
|
|
525
525
|
}
|
|
526
|
-
return B("",
|
|
526
|
+
return B("", I, []);
|
|
527
527
|
}
|
|
528
528
|
return Zt;
|
|
529
529
|
}
|
|
530
530
|
})(lt, lt.exports);
|
|
531
531
|
var ce = lt.exports;
|
|
532
|
-
const
|
|
533
|
-
|
|
532
|
+
const rt = /* @__PURE__ */ pe(ce);
|
|
533
|
+
rt.configure;
|
|
534
534
|
function le(e, t) {
|
|
535
535
|
return { ...e, name: t };
|
|
536
536
|
}
|
|
@@ -539,9 +539,9 @@ function me(e, t, i) {
|
|
|
539
539
|
skip: i,
|
|
540
540
|
document: e
|
|
541
541
|
}, { scope: a } = t;
|
|
542
|
-
return !a || t.skip === void 0 ? n : G(n, (
|
|
543
|
-
const [
|
|
544
|
-
t.skip && t.skip > 0 && (
|
|
542
|
+
return !a || t.skip === void 0 ? n : G(n, (s) => {
|
|
543
|
+
const [r] = s.document.operations[a].slice(-1);
|
|
544
|
+
t.skip && t.skip > 0 && (s.skip = t.skip), r.type === "NOOP" && t.index === r.index && s.skip > r.skip && s.document.operations[a].pop();
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
547
|
function ue(e, t, i) {
|
|
@@ -550,8 +550,8 @@ function ue(e, t, i) {
|
|
|
550
550
|
document: e,
|
|
551
551
|
action: t,
|
|
552
552
|
skip: i
|
|
553
|
-
}, (
|
|
554
|
-
if (
|
|
553
|
+
}, (r) => {
|
|
554
|
+
if (r.document.operations[n].length < 1)
|
|
555
555
|
throw new Error(
|
|
556
556
|
`Cannot undo: no operations in history for scope "${n}"`
|
|
557
557
|
);
|
|
@@ -559,31 +559,31 @@ function ue(e, t, i) {
|
|
|
559
559
|
throw new Error(
|
|
560
560
|
"Invalid UNDO action: input value must be greater than 0"
|
|
561
561
|
);
|
|
562
|
-
if (
|
|
562
|
+
if (r.skip > 0)
|
|
563
563
|
throw new Error(
|
|
564
564
|
"Cannot undo: skip value from reducer cannot be used with UNDO action"
|
|
565
565
|
);
|
|
566
|
-
const [l] =
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
566
|
+
const [l] = r.document.operations[n].slice(-1), p = l.type === "NOOP" && l.skip > 0;
|
|
567
|
+
if (r.skip += a, p) {
|
|
568
|
+
r.skip += l.skip;
|
|
569
|
+
const h = r.document.operations[n][r.document.operations[n].length - 2];
|
|
570
|
+
h && l.index - h.index === 1 && r.document.operations[n].pop();
|
|
571
571
|
}
|
|
572
|
-
if (
|
|
572
|
+
if (r.document.operations[n].length < r.skip)
|
|
573
573
|
throw new Error(
|
|
574
574
|
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
575
575
|
);
|
|
576
|
-
const x =
|
|
577
|
-
let
|
|
578
|
-
for (;
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
581
|
-
|
|
576
|
+
const x = r.document.operations[n].length - 1;
|
|
577
|
+
let b = a, v = p ? x - l.skip : x;
|
|
578
|
+
for (; b > 0 && v >= 0; ) {
|
|
579
|
+
const h = r.document.operations[n][v];
|
|
580
|
+
if (!h) {
|
|
581
|
+
b--, v--;
|
|
582
582
|
continue;
|
|
583
583
|
}
|
|
584
|
-
|
|
584
|
+
h.type === "NOOP" && h.skip > 0 ? (v = v - (h.skip + 1), r.skip += h.skip + 1) : (r.document.clipboard.push({ ...h }), b--, v--);
|
|
585
585
|
}
|
|
586
|
-
|
|
586
|
+
r.action = yt(n);
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
589
|
function fe(e, t, i) {
|
|
@@ -592,8 +592,8 @@ function fe(e, t, i) {
|
|
|
592
592
|
document: e,
|
|
593
593
|
action: t,
|
|
594
594
|
skip: i
|
|
595
|
-
}, (
|
|
596
|
-
if (
|
|
595
|
+
}, (r) => {
|
|
596
|
+
if (r.skip > 0)
|
|
597
597
|
throw new Error(
|
|
598
598
|
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
599
599
|
);
|
|
@@ -603,55 +603,55 @@ function fe(e, t, i) {
|
|
|
603
603
|
);
|
|
604
604
|
if (a < 1)
|
|
605
605
|
throw new Error("Invalid REDO action: invalid redo input value");
|
|
606
|
-
if (
|
|
606
|
+
if (r.document.clipboard.length < 1)
|
|
607
607
|
throw new Error("Cannot redo: no operations in the clipboard");
|
|
608
|
-
const l =
|
|
608
|
+
const l = r.document.clipboard.findLastIndex(
|
|
609
609
|
(x) => x.scope === n
|
|
610
610
|
);
|
|
611
611
|
if (l < 0)
|
|
612
612
|
throw new Error(
|
|
613
613
|
`Cannot redo: no operations in clipboard for scope "${n}"`
|
|
614
614
|
);
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
type:
|
|
618
|
-
scope:
|
|
619
|
-
input:
|
|
615
|
+
const p = r.document.clipboard.splice(l, 1)[0];
|
|
616
|
+
r.action = pt({
|
|
617
|
+
type: p.type,
|
|
618
|
+
scope: p.scope,
|
|
619
|
+
input: p.input
|
|
620
620
|
});
|
|
621
621
|
});
|
|
622
622
|
}
|
|
623
623
|
function de(e, t, i) {
|
|
624
624
|
const { scope: n } = t, a = e.operations[n];
|
|
625
625
|
let {
|
|
626
|
-
input: { start:
|
|
626
|
+
input: { start: s, end: r }
|
|
627
627
|
} = t;
|
|
628
|
-
|
|
629
|
-
const l = a.slice(
|
|
628
|
+
s = s || 0, r = r || a.length;
|
|
629
|
+
const l = a.slice(s, r), p = a.slice(0, s), x = a.slice(r), b = mt(
|
|
630
630
|
e.initialState,
|
|
631
631
|
{
|
|
632
632
|
...e.operations,
|
|
633
|
-
[n]:
|
|
633
|
+
[n]: p.concat(l)
|
|
634
634
|
},
|
|
635
635
|
i
|
|
636
|
-
), { name:
|
|
636
|
+
), { name: v, state: h } = b, O = p.length, $ = p.length ? p[p.length - 1].timestamp : x.length ? x[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
637
637
|
return mt(
|
|
638
638
|
e.initialState,
|
|
639
639
|
{
|
|
640
640
|
...e.operations,
|
|
641
641
|
[n]: [
|
|
642
|
-
...
|
|
642
|
+
...p,
|
|
643
643
|
{
|
|
644
644
|
...bt(
|
|
645
|
-
{ name:
|
|
645
|
+
{ name: v, state: h },
|
|
646
646
|
l.length
|
|
647
647
|
),
|
|
648
|
-
timestamp:
|
|
649
|
-
index:
|
|
650
|
-
hash: xt({ state:
|
|
648
|
+
timestamp: $,
|
|
649
|
+
index: O,
|
|
650
|
+
hash: xt({ state: h }, "global")
|
|
651
651
|
},
|
|
652
|
-
...x.map((
|
|
653
|
-
...
|
|
654
|
-
index:
|
|
652
|
+
...x.map((D, E) => ({
|
|
653
|
+
...D,
|
|
654
|
+
index: O + E + 1
|
|
655
655
|
}))
|
|
656
656
|
]
|
|
657
657
|
},
|
|
@@ -665,7 +665,7 @@ function ge(e, t) {
|
|
|
665
665
|
state: t.state ?? { global: {}, local: {} }
|
|
666
666
|
};
|
|
667
667
|
}
|
|
668
|
-
const Ft = "SET_NAME", X = "UNDO", Y = "REDO",
|
|
668
|
+
const Ft = "SET_NAME", X = "UNDO", Y = "REDO", st = "PRUNE", Rt = "LOAD_STATE", he = "NOOP";
|
|
669
669
|
function xe(e, t) {
|
|
670
670
|
let i;
|
|
671
671
|
return "index" in t ? i = { ...t } : i = e.operations[t.scope].slice(-1)[0], ((i == null ? void 0 : i.index) ?? -1) + 1;
|
|
@@ -681,27 +681,28 @@ function be(e, t) {
|
|
|
681
681
|
};
|
|
682
682
|
}
|
|
683
683
|
function ye(e, t, i = 0) {
|
|
684
|
-
if ([X, Y,
|
|
684
|
+
if ([X, Y, st].includes(t.type))
|
|
685
685
|
return e;
|
|
686
686
|
const { scope: n } = t, a = e.operations[n].slice(
|
|
687
687
|
0,
|
|
688
688
|
e.revision[n]
|
|
689
|
-
),
|
|
690
|
-
let
|
|
689
|
+
), s = [...a].pop();
|
|
690
|
+
let r = ((s == null ? void 0 : s.index) ?? -1) + 1;
|
|
691
691
|
if ("index" in t) {
|
|
692
|
-
if (t.index >
|
|
692
|
+
if (t.index > r + i)
|
|
693
693
|
throw new Error(
|
|
694
|
-
`Missing operations: expected ${
|
|
694
|
+
`Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
|
|
695
695
|
);
|
|
696
|
-
|
|
696
|
+
r = t.index;
|
|
697
697
|
}
|
|
698
698
|
return a.push({
|
|
699
699
|
...t,
|
|
700
|
-
index:
|
|
700
|
+
index: r,
|
|
701
701
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
702
702
|
hash: "",
|
|
703
703
|
scope: n,
|
|
704
|
-
skip: i
|
|
704
|
+
skip: i,
|
|
705
|
+
error: void 0
|
|
705
706
|
}), {
|
|
706
707
|
...e,
|
|
707
708
|
operations: { ...e.operations, [n]: a }
|
|
@@ -715,7 +716,7 @@ function je(e, t, i) {
|
|
|
715
716
|
switch (At().parse(t), t.type) {
|
|
716
717
|
case Ft:
|
|
717
718
|
return le(e, t.input);
|
|
718
|
-
case
|
|
719
|
+
case st:
|
|
719
720
|
return de(e, t, i);
|
|
720
721
|
case Rt:
|
|
721
722
|
return ge(e, t.input.state);
|
|
@@ -723,7 +724,7 @@ function je(e, t, i) {
|
|
|
723
724
|
return e;
|
|
724
725
|
}
|
|
725
726
|
}
|
|
726
|
-
function
|
|
727
|
+
function Se(e, t, i) {
|
|
727
728
|
switch (t.type) {
|
|
728
729
|
case X:
|
|
729
730
|
return ue(e, t, i);
|
|
@@ -734,71 +735,79 @@ function Oe(e, t, i) {
|
|
|
734
735
|
}
|
|
735
736
|
}
|
|
736
737
|
function Lt(e, t, i, n, a = {}) {
|
|
737
|
-
const { skip:
|
|
738
|
-
let
|
|
739
|
-
if (ve(
|
|
740
|
-
const { document:
|
|
741
|
-
x =
|
|
738
|
+
const { skip: s, ignoreSkipOperations: r = !1, reuseHash: l = !1 } = a;
|
|
739
|
+
let p = { ...t }, x = s || 0, b = e, v = [...e.clipboard];
|
|
740
|
+
if (ve(p)) {
|
|
741
|
+
const { document: h, skip: O } = me(b, p, x);
|
|
742
|
+
x = O, b = h;
|
|
742
743
|
}
|
|
743
|
-
if (wt(
|
|
744
|
+
if (wt(p)) {
|
|
744
745
|
const {
|
|
745
|
-
skip:
|
|
746
|
-
action:
|
|
747
|
-
document:
|
|
748
|
-
} =
|
|
749
|
-
|
|
746
|
+
skip: h,
|
|
747
|
+
action: O,
|
|
748
|
+
document: $
|
|
749
|
+
} = Se(e, p, x);
|
|
750
|
+
p = O, x = h, b = $, v = [...b.clipboard];
|
|
750
751
|
}
|
|
751
|
-
if (jt(
|
|
752
|
-
let
|
|
753
|
-
"index" in
|
|
754
|
-
|
|
755
|
-
|
|
752
|
+
if (jt(p) && (b = je(b, p, i)), x > 0 && !r) {
|
|
753
|
+
let h = x;
|
|
754
|
+
"index" in p && (h = Ne(
|
|
755
|
+
b.operations[p.scope],
|
|
756
|
+
p.index,
|
|
756
757
|
x
|
|
757
|
-
)),
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
)), b = mt(
|
|
759
|
+
b.initialState,
|
|
760
|
+
b.operations,
|
|
760
761
|
i,
|
|
761
762
|
void 0,
|
|
762
763
|
void 0,
|
|
763
764
|
void 0,
|
|
764
|
-
{ [
|
|
765
|
+
{ [p.scope]: h }
|
|
765
766
|
// TODO reuse hash?
|
|
766
767
|
);
|
|
767
768
|
}
|
|
768
|
-
return
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
769
|
+
return b = we(b, p, x), b = G(b, (h) => {
|
|
770
|
+
try {
|
|
771
|
+
const O = i(
|
|
772
|
+
h.state,
|
|
773
|
+
p,
|
|
774
|
+
n
|
|
775
|
+
), $ = wt(t) ? [...v] : [];
|
|
776
|
+
if (O)
|
|
777
|
+
return pt({
|
|
778
|
+
...b,
|
|
779
|
+
clipboard: [...$],
|
|
780
|
+
state: O
|
|
781
|
+
});
|
|
782
|
+
h.clipboard = pt([...$]);
|
|
783
|
+
} catch (O) {
|
|
784
|
+
const $ = b.operations[p.scope].length - 1;
|
|
785
|
+
h.operations[p.scope][$].error = O.message, console.error(
|
|
786
|
+
`Error thrown in reducer. Action: ${JSON.stringify(p)}, Error:`,
|
|
787
|
+
O
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
}), G(b, (h) => {
|
|
791
|
+
if ([X, Y, st].includes(p.type))
|
|
792
|
+
return h;
|
|
793
|
+
const O = p.scope || "global", $ = l && Object.prototype.hasOwnProperty.call(p, "hash") ? p.hash : xt(h, O);
|
|
794
|
+
h.operations[O][h.operations[O].length - 1].hash = $, !jt(p) && p.attachments && p.attachments.forEach((D) => {
|
|
795
|
+
const { hash: E, ...c } = D;
|
|
796
|
+
h.attachments[E] = {
|
|
797
|
+
...c
|
|
789
798
|
};
|
|
790
799
|
});
|
|
791
800
|
});
|
|
792
801
|
}
|
|
793
|
-
function
|
|
802
|
+
function Oe(e, t, i) {
|
|
794
803
|
const n = ie(e, t);
|
|
795
|
-
return ct.mkdirSync(e, { recursive: !0 }), new Promise((a,
|
|
804
|
+
return ct.mkdirSync(e, { recursive: !0 }), new Promise((a, s) => {
|
|
796
805
|
try {
|
|
797
|
-
ct.writeFile(n, i, {}, (
|
|
798
|
-
|
|
806
|
+
ct.writeFile(n, i, {}, (r) => {
|
|
807
|
+
r ? s(r) : a(n);
|
|
799
808
|
});
|
|
800
|
-
} catch (
|
|
801
|
-
|
|
809
|
+
} catch (r) {
|
|
810
|
+
s(r);
|
|
802
811
|
}
|
|
803
812
|
});
|
|
804
813
|
}
|
|
@@ -808,11 +817,11 @@ function qt(e) {
|
|
|
808
817
|
function $e(e) {
|
|
809
818
|
return new Promise((t, i) => {
|
|
810
819
|
ee.get(e, (n) => {
|
|
811
|
-
const a = [],
|
|
812
|
-
n.on("data", (
|
|
813
|
-
a.push(
|
|
820
|
+
const a = [], s = n.headers["content-type"];
|
|
821
|
+
n.on("data", (r) => {
|
|
822
|
+
a.push(r);
|
|
814
823
|
}), n.on("end", () => {
|
|
815
|
-
t({ buffer: Buffer.concat(a), mimeType:
|
|
824
|
+
t({ buffer: Buffer.concat(a), mimeType: s });
|
|
816
825
|
});
|
|
817
826
|
}).on("error", (n) => {
|
|
818
827
|
i(n);
|
|
@@ -827,26 +836,26 @@ function wt(e) {
|
|
|
827
836
|
return [X, Y].includes(e.type);
|
|
828
837
|
}
|
|
829
838
|
function jt(e) {
|
|
830
|
-
return [Ft, X, Y,
|
|
839
|
+
return [Ft, X, Y, st, Rt].includes(e.type);
|
|
831
840
|
}
|
|
832
841
|
function H(e, t, i, n, a = "global") {
|
|
833
842
|
if (!e)
|
|
834
843
|
throw new Error("Empty action type");
|
|
835
844
|
if (typeof e != "string")
|
|
836
845
|
throw new Error(`Invalid action type: ${JSON.stringify(e)}`);
|
|
837
|
-
const
|
|
838
|
-
i && (
|
|
846
|
+
const s = { type: e, input: t, scope: a };
|
|
847
|
+
i && (s.attachments = i);
|
|
839
848
|
try {
|
|
840
|
-
n == null || n().parse(
|
|
841
|
-
} catch (
|
|
842
|
-
throw new Error(`Invalid action input: ${
|
|
849
|
+
n == null || n().parse(s.input);
|
|
850
|
+
} catch (r) {
|
|
851
|
+
throw new Error(`Invalid action input: ${r}`);
|
|
843
852
|
}
|
|
844
|
-
return
|
|
853
|
+
return s;
|
|
845
854
|
}
|
|
846
855
|
function Te(e, t = Lt) {
|
|
847
|
-
return (i, n, a,
|
|
856
|
+
return (i, n, a, s) => t(i, n, e, a, s);
|
|
848
857
|
}
|
|
849
|
-
const
|
|
858
|
+
const _e = (e, t) => ({
|
|
850
859
|
name: "",
|
|
851
860
|
documentType: "",
|
|
852
861
|
revision: {
|
|
@@ -858,8 +867,8 @@ const ke = (e, t) => ({
|
|
|
858
867
|
attachments: {},
|
|
859
868
|
...e,
|
|
860
869
|
state: (t == null ? void 0 : t(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
|
|
861
|
-
}),
|
|
862
|
-
const i =
|
|
870
|
+
}), ke = (e, t) => {
|
|
871
|
+
const i = _e(
|
|
863
872
|
e,
|
|
864
873
|
t
|
|
865
874
|
);
|
|
@@ -869,7 +878,7 @@ const ke = (e, t) => ({
|
|
|
869
878
|
operations: { global: [], local: [] },
|
|
870
879
|
clipboard: []
|
|
871
880
|
};
|
|
872
|
-
}, xt = (e, t = "global") => at(
|
|
881
|
+
}, xt = (e, t = "global") => at(rt(e.state[t] || "")), Be = (e, t = 1e3) => {
|
|
873
882
|
const i = Math.random() * t;
|
|
874
883
|
return at(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
875
884
|
};
|
|
@@ -879,37 +888,37 @@ function ot(e) {
|
|
|
879
888
|
function Ae(e, t) {
|
|
880
889
|
const i = [...e];
|
|
881
890
|
let n = t || 0, a = i.length > 0 ? i[i.length - 1].index : 0;
|
|
882
|
-
const
|
|
883
|
-
for (const
|
|
891
|
+
const s = [];
|
|
892
|
+
for (const r of i.reverse()) {
|
|
884
893
|
if (n > 0) {
|
|
885
|
-
const x = a -
|
|
894
|
+
const x = a - r.index;
|
|
886
895
|
n -= x;
|
|
887
896
|
}
|
|
888
897
|
if (n < 0)
|
|
889
898
|
throw new Error("Invalid operation index, missing operations");
|
|
890
899
|
const l = {
|
|
891
900
|
ignore: n > 0,
|
|
892
|
-
operation:
|
|
893
|
-
},
|
|
894
|
-
if (
|
|
895
|
-
const x =
|
|
901
|
+
operation: r
|
|
902
|
+
}, p = r.skip > 0 ? r.skip + 1 : 0;
|
|
903
|
+
if (p > 0 && p > n) {
|
|
904
|
+
const x = p - n;
|
|
896
905
|
n = n + x;
|
|
897
906
|
}
|
|
898
|
-
a =
|
|
907
|
+
a = r.index, s.push(l);
|
|
899
908
|
}
|
|
900
|
-
return
|
|
909
|
+
return s.reverse();
|
|
901
910
|
}
|
|
902
911
|
function Ne(e, t, i) {
|
|
903
|
-
const n = e.slice().sort((l,
|
|
904
|
-
let a = i,
|
|
912
|
+
const n = e.slice().sort((l, p) => l.skip - p.skip).sort((l, p) => l.index - p.index);
|
|
913
|
+
let a = i, s = 0, r = t;
|
|
905
914
|
for (const l of n.reverse()) {
|
|
906
|
-
const
|
|
907
|
-
if (a = a -
|
|
908
|
-
|
|
915
|
+
const p = r - l.index;
|
|
916
|
+
if (a = a - p, a > -1)
|
|
917
|
+
s++, r = l.index;
|
|
909
918
|
else
|
|
910
919
|
break;
|
|
911
920
|
}
|
|
912
|
-
return
|
|
921
|
+
return s;
|
|
913
922
|
}
|
|
914
923
|
function Ze(e) {
|
|
915
924
|
return Object.values(e).flatMap((t) => t).sort(
|
|
@@ -921,89 +930,79 @@ function De(e) {
|
|
|
921
930
|
(t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
922
931
|
);
|
|
923
932
|
}
|
|
924
|
-
function mt(e, t, i, n, a,
|
|
925
|
-
const
|
|
926
|
-
return
|
|
933
|
+
function mt(e, t, i, n, a, s = Lt, r = {}, l) {
|
|
934
|
+
const p = Te(i, s);
|
|
935
|
+
return Jt(
|
|
927
936
|
e,
|
|
928
937
|
t,
|
|
929
|
-
|
|
938
|
+
p,
|
|
930
939
|
n,
|
|
931
940
|
a,
|
|
932
|
-
|
|
941
|
+
r,
|
|
933
942
|
l
|
|
934
943
|
);
|
|
935
944
|
}
|
|
936
|
-
function
|
|
937
|
-
const l = (
|
|
938
|
-
const
|
|
945
|
+
function Jt(e, t, i, n, a, s = {}, r) {
|
|
946
|
+
const l = (r == null ? void 0 : r.checkHashes) ?? !0, p = ke(e), x = Object.keys(t).reduce(($, D) => {
|
|
947
|
+
const E = D;
|
|
939
948
|
return {
|
|
940
|
-
|
|
941
|
-
[
|
|
949
|
+
...$,
|
|
950
|
+
[E]: Ae(
|
|
951
|
+
t[E],
|
|
952
|
+
s[E]
|
|
953
|
+
)
|
|
942
954
|
};
|
|
943
|
-
}, {}),
|
|
944
|
-
(
|
|
945
|
-
|
|
946
|
-
return {
|
|
947
|
-
..._,
|
|
948
|
-
[r]: Ae(
|
|
949
|
-
x[r],
|
|
950
|
-
p[r]
|
|
951
|
-
)
|
|
952
|
-
};
|
|
953
|
-
},
|
|
954
|
-
{}
|
|
955
|
-
), E = De(j), g = E.reduce(
|
|
956
|
-
(_, { ignore: A, operation: r }, m, b) => A ? i(_, yt(r.scope), n, {
|
|
957
|
-
skip: r.skip,
|
|
955
|
+
}, {}), b = De(x), v = b.reduce(
|
|
956
|
+
($, { ignore: D, operation: E }) => D ? i($, yt(E.scope), n, {
|
|
957
|
+
skip: E.skip,
|
|
958
958
|
ignoreSkipOperations: !0
|
|
959
959
|
// TODO: reuse hash?
|
|
960
|
-
}) : i(
|
|
961
|
-
skip:
|
|
960
|
+
}) : i($, E, n, {
|
|
961
|
+
skip: E.skip,
|
|
962
962
|
ignoreSkipOperations: !0,
|
|
963
963
|
reuseHash: !l
|
|
964
964
|
}),
|
|
965
|
-
|
|
965
|
+
p
|
|
966
966
|
);
|
|
967
|
-
if (!l)
|
|
968
|
-
for (const
|
|
969
|
-
for (let
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
967
|
+
if (!l)
|
|
968
|
+
for (const $ of Object.keys(v.state))
|
|
969
|
+
for (let D = b.length - 1; D >= 0; D--) {
|
|
970
|
+
const { ignore: E, operation: c } = b[D];
|
|
971
|
+
if (!(E || c.scope !== $)) {
|
|
972
|
+
if (c.hash !== xt(v, $))
|
|
973
|
+
throw new Error(`Hash mismatch for scope ${$}`);
|
|
973
974
|
break;
|
|
974
975
|
}
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
976
|
+
}
|
|
977
|
+
const h = Object.keys(
|
|
978
|
+
v.operations
|
|
978
979
|
).reduce(
|
|
979
|
-
(
|
|
980
|
-
const
|
|
980
|
+
($, D) => {
|
|
981
|
+
const E = D;
|
|
981
982
|
return {
|
|
982
|
-
|
|
983
|
-
[
|
|
984
|
-
...
|
|
985
|
-
var
|
|
983
|
+
...$,
|
|
984
|
+
[E]: [
|
|
985
|
+
...v.operations[E].map((c, u) => {
|
|
986
|
+
var y;
|
|
986
987
|
return {
|
|
987
|
-
...
|
|
988
|
-
timestamp: ((
|
|
988
|
+
...c,
|
|
989
|
+
timestamp: ((y = t[E][u]) == null ? void 0 : y.timestamp) ?? c.timestamp
|
|
989
990
|
};
|
|
990
|
-
})
|
|
991
|
-
...m
|
|
991
|
+
})
|
|
992
992
|
]
|
|
993
993
|
};
|
|
994
994
|
},
|
|
995
995
|
{ global: [], local: [] }
|
|
996
|
-
),
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
return _;
|
|
996
|
+
), O = Object.values(h).reduce(($, D) => {
|
|
997
|
+
const E = D[D.length - 1];
|
|
998
|
+
return (E == null ? void 0 : E.timestamp) > $ && ($ = E.timestamp), $;
|
|
1000
999
|
}, e.lastModified);
|
|
1001
|
-
return { ...
|
|
1000
|
+
return { ...v, operations: h, lastModified: O };
|
|
1002
1001
|
}
|
|
1003
1002
|
function Ge(e, t) {
|
|
1004
|
-
return
|
|
1003
|
+
return rt(e) === rt(t);
|
|
1005
1004
|
}
|
|
1006
|
-
const
|
|
1005
|
+
const Ct = (e) => H(
|
|
1007
1006
|
"SET_NAME",
|
|
1008
1007
|
e,
|
|
1009
1008
|
void 0,
|
|
@@ -1038,7 +1037,7 @@ const Jt = (e) => H(
|
|
|
1038
1037
|
noop: yt,
|
|
1039
1038
|
prune: Kt,
|
|
1040
1039
|
redo: Vt,
|
|
1041
|
-
setName:
|
|
1040
|
+
setName: Ct,
|
|
1042
1041
|
undo: Ut
|
|
1043
1042
|
}, Symbol.toStringTag, { value: "Module" })), Ht = { "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"] };
|
|
1044
1043
|
Object.freeze(Ht);
|
|
@@ -1048,21 +1047,21 @@ var L = function(e, t, i, n) {
|
|
|
1048
1047
|
if (typeof t == "function" ? e !== t || !n : !t.has(e))
|
|
1049
1048
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1050
1049
|
return i === "m" ? n : i === "a" ? n.call(e) : n ? n.value : t.get(e);
|
|
1051
|
-
}, K, Z,
|
|
1050
|
+
}, K, Z, U;
|
|
1052
1051
|
class Me {
|
|
1053
1052
|
constructor(...t) {
|
|
1054
|
-
K.set(this, /* @__PURE__ */ new Map()), Z.set(this, /* @__PURE__ */ new Map()),
|
|
1053
|
+
K.set(this, /* @__PURE__ */ new Map()), Z.set(this, /* @__PURE__ */ new Map()), U.set(this, /* @__PURE__ */ new Map());
|
|
1055
1054
|
for (const i of t)
|
|
1056
1055
|
this.define(i);
|
|
1057
1056
|
}
|
|
1058
1057
|
define(t, i = !1) {
|
|
1059
1058
|
for (let [n, a] of Object.entries(t)) {
|
|
1060
|
-
n = n.toLowerCase(), a = a.map((l) => l.toLowerCase()), L(this,
|
|
1061
|
-
const
|
|
1062
|
-
let
|
|
1059
|
+
n = n.toLowerCase(), a = a.map((l) => l.toLowerCase()), L(this, U, "f").has(n) || L(this, U, "f").set(n, /* @__PURE__ */ new Set());
|
|
1060
|
+
const s = L(this, U, "f").get(n);
|
|
1061
|
+
let r = !0;
|
|
1063
1062
|
for (let l of a) {
|
|
1064
|
-
const
|
|
1065
|
-
if (l =
|
|
1063
|
+
const p = l.startsWith("*");
|
|
1064
|
+
if (l = p ? l.slice(1) : l, s == null || s.add(l), r && L(this, Z, "f").set(n, l), r = !1, p)
|
|
1066
1065
|
continue;
|
|
1067
1066
|
const x = L(this, K, "f").get(l);
|
|
1068
1067
|
if (x && x != n && !i)
|
|
@@ -1083,13 +1082,13 @@ class Me {
|
|
|
1083
1082
|
return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && L(this, Z, "f").get(t.trim().toLowerCase())) ?? null);
|
|
1084
1083
|
}
|
|
1085
1084
|
getAllExtensions(t) {
|
|
1086
|
-
return typeof t != "string" ? null : L(this,
|
|
1085
|
+
return typeof t != "string" ? null : L(this, U, "f").get(t.toLowerCase()) ?? null;
|
|
1087
1086
|
}
|
|
1088
1087
|
_freeze() {
|
|
1089
1088
|
this.define = () => {
|
|
1090
1089
|
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
1091
1090
|
}, Object.freeze(this);
|
|
1092
|
-
for (const t of L(this,
|
|
1091
|
+
for (const t of L(this, U, "f").values())
|
|
1093
1092
|
Object.freeze(t);
|
|
1094
1093
|
return this;
|
|
1095
1094
|
}
|
|
@@ -1100,83 +1099,83 @@ class Me {
|
|
|
1100
1099
|
};
|
|
1101
1100
|
}
|
|
1102
1101
|
}
|
|
1103
|
-
K = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(),
|
|
1102
|
+
K = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap();
|
|
1104
1103
|
const Pe = new Me(Ht)._freeze();
|
|
1105
1104
|
function Ie(e) {
|
|
1106
1105
|
const t = [], i = Object.keys(e);
|
|
1107
1106
|
for (const n of i) {
|
|
1108
|
-
const a = e[n].sort((
|
|
1109
|
-
for (let
|
|
1110
|
-
a[
|
|
1111
|
-
message: `Invalid operation index ${a[
|
|
1107
|
+
const a = e[n].sort((s, r) => s.index - r.index);
|
|
1108
|
+
for (let s = 0; s < a.length; s++)
|
|
1109
|
+
a[s].index !== s && t.push({
|
|
1110
|
+
message: `Invalid operation index ${a[s].index} at position ${s}`,
|
|
1112
1111
|
details: {
|
|
1113
|
-
position:
|
|
1114
|
-
operation: a[
|
|
1115
|
-
scope: a[
|
|
1112
|
+
position: s,
|
|
1113
|
+
operation: a[s],
|
|
1114
|
+
scope: a[s].scope
|
|
1116
1115
|
}
|
|
1117
1116
|
});
|
|
1118
1117
|
}
|
|
1119
1118
|
return t;
|
|
1120
1119
|
}
|
|
1121
1120
|
const Wt = async (e) => {
|
|
1122
|
-
const t = new
|
|
1121
|
+
const t = new Ot(), { name: i, revision: n, documentType: a, created: s, lastModified: r } = e, l = {
|
|
1123
1122
|
name: i,
|
|
1124
1123
|
revision: n,
|
|
1125
1124
|
documentType: a,
|
|
1126
|
-
created:
|
|
1127
|
-
lastModified:
|
|
1125
|
+
created: s,
|
|
1126
|
+
lastModified: r
|
|
1128
1127
|
};
|
|
1129
1128
|
return t.file("header.json", JSON.stringify(l, null, 2)), t.file(
|
|
1130
1129
|
"state.json",
|
|
1131
1130
|
JSON.stringify(e.initialState || {}, null, 2)
|
|
1132
1131
|
), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((x) => {
|
|
1133
|
-
const { data:
|
|
1134
|
-
t.file(x,
|
|
1132
|
+
const { data: b, ...v } = e.attachments[x];
|
|
1133
|
+
t.file(x, b, {
|
|
1135
1134
|
base64: !0,
|
|
1136
1135
|
createFolders: !0,
|
|
1137
|
-
comment: JSON.stringify(
|
|
1136
|
+
comment: JSON.stringify(v)
|
|
1138
1137
|
});
|
|
1139
1138
|
}), t;
|
|
1140
1139
|
}, ze = async (e, t, i, n) => {
|
|
1141
|
-
const
|
|
1140
|
+
const s = await (await Wt(e)).generateAsync({
|
|
1142
1141
|
type: "uint8array",
|
|
1143
1142
|
streamFiles: !0
|
|
1144
|
-
}),
|
|
1145
|
-
return
|
|
1143
|
+
}), r = n ?? e.name, l = `.${i}.zip`;
|
|
1144
|
+
return Oe(
|
|
1146
1145
|
t,
|
|
1147
|
-
|
|
1148
|
-
|
|
1146
|
+
r.endsWith(l) ? r : `${r}${l}`,
|
|
1147
|
+
s
|
|
1149
1148
|
);
|
|
1150
1149
|
}, Xe = async (e, t) => {
|
|
1151
1150
|
const n = await (await Wt(e)).generateAsync({ type: "blob" }), a = await t.createWritable();
|
|
1152
1151
|
await a.write(n), await a.close();
|
|
1153
|
-
},
|
|
1152
|
+
}, St = async (e, t, i) => {
|
|
1154
1153
|
const n = qt(e);
|
|
1155
1154
|
return Fe(n, t, i);
|
|
1156
1155
|
}, Fe = async (e, t, i) => {
|
|
1157
|
-
const n = new
|
|
1156
|
+
const n = new Ot();
|
|
1158
1157
|
return await n.loadAsync(e), Re(n, t, i);
|
|
1159
1158
|
};
|
|
1160
1159
|
async function Re(e, t, i) {
|
|
1161
1160
|
const n = e.file("state.json");
|
|
1162
1161
|
if (!n)
|
|
1163
1162
|
throw new Error("Initial state not found");
|
|
1164
|
-
const a = await n.async("string"),
|
|
1163
|
+
const a = await n.async("string"), s = JSON.parse(a), r = e.file("header.json");
|
|
1165
1164
|
let l;
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
if (!
|
|
1165
|
+
r && (l = JSON.parse(await r.async("string")));
|
|
1166
|
+
const p = e.file("operations.json");
|
|
1167
|
+
if (!p)
|
|
1169
1168
|
throw new Error("Operations history not found");
|
|
1170
1169
|
const x = JSON.parse(
|
|
1171
|
-
await
|
|
1172
|
-
),
|
|
1173
|
-
if (
|
|
1174
|
-
const
|
|
1175
|
-
throw new Error(
|
|
1170
|
+
await p.async("string")
|
|
1171
|
+
), b = Ie(x);
|
|
1172
|
+
if (b.length) {
|
|
1173
|
+
const h = b.map((O) => O.message);
|
|
1174
|
+
throw new Error(h.join(`
|
|
1176
1175
|
`));
|
|
1177
1176
|
}
|
|
1178
|
-
let
|
|
1179
|
-
|
|
1177
|
+
let v = Jt(
|
|
1178
|
+
s,
|
|
1180
1179
|
x,
|
|
1181
1180
|
t,
|
|
1182
1181
|
void 0,
|
|
@@ -1184,10 +1183,10 @@ async function Re(e, t, i) {
|
|
|
1184
1183
|
{},
|
|
1185
1184
|
i
|
|
1186
1185
|
);
|
|
1187
|
-
return l && (
|
|
1188
|
-
...
|
|
1186
|
+
return l && (v = {
|
|
1187
|
+
...v,
|
|
1189
1188
|
...l
|
|
1190
|
-
}),
|
|
1189
|
+
}), v;
|
|
1191
1190
|
}
|
|
1192
1191
|
function Bt(e) {
|
|
1193
1192
|
const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
|
|
@@ -1245,7 +1244,7 @@ class ei {
|
|
|
1245
1244
|
* @param path - The file path where the state is stored.
|
|
1246
1245
|
*/
|
|
1247
1246
|
async loadFromFile(t) {
|
|
1248
|
-
this._document = await
|
|
1247
|
+
this._document = await St(t, this._reducer);
|
|
1249
1248
|
}
|
|
1250
1249
|
/**
|
|
1251
1250
|
* Loads the state of the document from a file and returns it.
|
|
@@ -1254,7 +1253,7 @@ class ei {
|
|
|
1254
1253
|
* @returns The state of the document.
|
|
1255
1254
|
*/
|
|
1256
1255
|
static async stateFromFile(t, i) {
|
|
1257
|
-
return await
|
|
1256
|
+
return await St(t, i);
|
|
1258
1257
|
}
|
|
1259
1258
|
/**
|
|
1260
1259
|
* Gets the current state of the document.
|
|
@@ -1325,7 +1324,7 @@ class ei {
|
|
|
1325
1324
|
* @param name - The new name of the document.
|
|
1326
1325
|
*/
|
|
1327
1326
|
setName(t) {
|
|
1328
|
-
return this.dispatch(
|
|
1327
|
+
return this.dispatch(Ct(t)), this;
|
|
1329
1328
|
}
|
|
1330
1329
|
/**
|
|
1331
1330
|
* Reverts a number of actions from the document.
|
|
@@ -1375,10 +1374,10 @@ export {
|
|
|
1375
1374
|
Ie as A,
|
|
1376
1375
|
ei as B,
|
|
1377
1376
|
Lt as C,
|
|
1378
|
-
|
|
1377
|
+
Se as D,
|
|
1379
1378
|
We as E,
|
|
1380
|
-
|
|
1381
|
-
|
|
1379
|
+
_e as a,
|
|
1380
|
+
ke as b,
|
|
1382
1381
|
Te as c,
|
|
1383
1382
|
Xe as d,
|
|
1384
1383
|
Fe as e,
|
|
@@ -1388,7 +1387,7 @@ export {
|
|
|
1388
1387
|
jt as i,
|
|
1389
1388
|
Ne as j,
|
|
1390
1389
|
Wt as k,
|
|
1391
|
-
|
|
1390
|
+
St as l,
|
|
1392
1391
|
ti as m,
|
|
1393
1392
|
Ye as n,
|
|
1394
1393
|
xt as o,
|
|
@@ -1399,7 +1398,7 @@ export {
|
|
|
1399
1398
|
wt as t,
|
|
1400
1399
|
Ae as u,
|
|
1401
1400
|
ot as v,
|
|
1402
|
-
|
|
1401
|
+
Jt as w,
|
|
1403
1402
|
mt as x,
|
|
1404
1403
|
De as y,
|
|
1405
1404
|
Ze as z
|