document-model 1.0.24 → 1.0.25
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 +3 -3
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +7 -6
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +4 -4
- package/dist/browser/internal/{index-Xpydy6AU.js → index-3haD_DrE.js} +1 -1
- package/dist/browser/internal/index-7bSWIChK.js +38 -0
- package/dist/browser/internal/index-DQNkZhvL.js +1 -0
- package/dist/browser/internal/{index-sfNIE5tQ.js → index-TAPWNyA9.js} +2 -2
- package/dist/browser/internal/object-1BuggAcr.js +6 -0
- package/dist/browser/internal/object-jGU_rY7z.js +1895 -0
- package/dist/browser/src/document/actions/index.d.ts +3 -3
- package/dist/browser/src/document/object.d.ts +63 -0
- package/dist/browser/src/document/reducer.d.ts +16 -0
- package/dist/browser/src/document/schema/types.d.ts +1 -0
- package/dist/browser/src/document/types.d.ts +9 -0
- package/dist/browser/src/document/utils/base.d.ts +7 -4
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +3 -3
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +8 -7
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +4 -4
- package/dist/node/internal/index-FmPDtpIY.js +38 -0
- package/dist/node/internal/{index-sNi-u40H.js → index-GpOpKG2W.js} +2 -2
- package/dist/node/internal/index-lh4jt_0f.js +1 -0
- package/dist/node/internal/{index-PkGY1BML.js → index-pZl431ni.js} +1 -1
- package/dist/node/internal/{object-T2hpMYZ4.js → object-evJm9vYN.js} +475 -411
- package/dist/node/internal/object-pZF_UDWv.js +1 -0
- package/dist/node/src/document/actions/index.d.ts +3 -3
- package/dist/node/src/document/object.d.ts +63 -0
- package/dist/node/src/document/reducer.d.ts +16 -0
- package/dist/node/src/document/schema/types.d.ts +1 -0
- package/dist/node/src/document/types.d.ts +9 -0
- package/dist/node/src/document/utils/base.d.ts +7 -4
- package/package.json +1 -1
- package/dist/browser/internal/index-e4O5HJBs.js +0 -1
- package/dist/browser/internal/index-v3lMuqpK.js +0 -36
- package/dist/browser/internal/object-U8CbkcSV.js +0 -6
- package/dist/browser/internal/object-YlWt1S0J.js +0 -1831
- package/dist/jest.config.d.ts +0 -8
- package/dist/node/internal/index-HgkfWSZk.js +0 -36
- package/dist/node/internal/index-aihhQ-ya.js +0 -1
- package/dist/node/internal/object-Nz1iEXFy.js +0 -1
- package/dist/node/test/document/redo.test.d.ts +0 -1
- package/dist/node/test/document/undo.test.d.ts +0 -1
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -10
- package/dist/src/document/actions/types.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -447
- package/dist/src/document/reducer.d.ts +0 -16
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -180
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -28
- package/dist/src/document/types.d.ts +0 -201
- package/dist/src/document/utils/base.d.ts +0 -74
- package/dist/src/document/utils/browser.d.ts +0 -10
- package/dist/src/document/utils/file.d.ts +0 -47
- package/dist/src/document/utils/index.d.ts +0 -2
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/src/document-model/custom/utils.d.ts +0 -1
- package/dist/src/document-model/gen/actions.d.ts +0 -15
- package/dist/src/document-model/gen/creators.d.ts +0 -7
- package/dist/src/document-model/gen/document-model.d.ts +0 -2
- package/dist/src/document-model/gen/header/actions.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts +0 -8
- package/dist/src/document-model/gen/header/object.d.ts +0 -12
- package/dist/src/document-model/gen/header/operations.d.ts +0 -10
- package/dist/src/document-model/gen/index.d.ts +0 -5
- package/dist/src/document-model/gen/module/actions.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts +0 -7
- package/dist/src/document-model/gen/module/object.d.ts +0 -11
- package/dist/src/document-model/gen/module/operations.d.ts +0 -9
- package/dist/src/document-model/gen/object.d.ts +0 -28
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/src/document-model/gen/operation/object.d.ts +0 -16
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/src/document-model/gen/reducer.d.ts +0 -5
- package/dist/src/document-model/gen/schema/index.d.ts +0 -2
- package/dist/src/document-model/gen/schema/types.d.ts +0 -453
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/src/document-model/gen/state/actions.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts +0 -8
- package/dist/src/document-model/gen/state/object.d.ts +0 -12
- package/dist/src/document-model/gen/state/operations.d.ts +0 -10
- package/dist/src/document-model/gen/types.d.ts +0 -8
- package/dist/src/document-model/gen/utils.d.ts +0 -6
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/src/document-model/index.d.ts +0 -75
- package/dist/src/index.d.ts +0 -25
- package/dist/test/document/local.test.d.ts +0 -1
- package/dist/test/document/object.test.d.ts +0 -1
- package/dist/test/document/prune.test.d.ts +0 -1
- package/dist/test/document/redo.test.d.ts +0 -1
- package/dist/test/document/reducer.test.d.ts +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -1
- package/dist/test/document/undo.test.d.ts +0 -1
- package/dist/test/document/utils.test.d.ts +0 -1
- package/dist/test/document-model/object.test.d.ts +0 -1
- package/dist/test/document-model/skip-operations.test.d.ts +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -1
- package/dist/test/helpers.d.ts +0 -32
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
- /package/dist/browser/test/document/{redo.test.d.ts → undo-redo.test.d.ts} +0 -0
- /package/dist/{browser/test/document/undo.test.d.ts → node/test/document/undo-redo.test.d.ts} +0 -0
|
@@ -1,261 +1,283 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { z as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { join as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
return
|
|
15
|
-
__typename:
|
|
16
|
-
type:
|
|
1
|
+
var xt = Object.defineProperty;
|
|
2
|
+
var ft = (t, e, i) => e in t ? xt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var j = (t, e, i) => (ft(t, typeof e != "symbol" ? e + "" : e, i), i);
|
|
4
|
+
import { produce as S, castDraft as D, castImmutable as gt, freeze as ht } from "immer";
|
|
5
|
+
import bt from "json-stringify-deterministic";
|
|
6
|
+
import { z as s } from "zod";
|
|
7
|
+
import $ from "jszip";
|
|
8
|
+
import vt from "crypto";
|
|
9
|
+
import N from "fs";
|
|
10
|
+
import yt from "https";
|
|
11
|
+
import { join as wt } from "path";
|
|
12
|
+
const J = (t) => t != null, jt = s.any().refine((t) => J(t)), B = s.enum(["LOAD_STATE"]), Z = s.enum(["PRUNE"]), H = s.enum(["REDO"]), K = s.enum(["SET_NAME"]), W = s.enum(["UNDO"]);
|
|
13
|
+
function Ot() {
|
|
14
|
+
return s.object({
|
|
15
|
+
__typename: s.literal("Action").optional(),
|
|
16
|
+
type: s.string()
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function y() {
|
|
20
|
+
return s.literal("global").or(s.literal("local"));
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
H(),
|
|
25
|
-
W(),
|
|
22
|
+
function V() {
|
|
23
|
+
return s.union([
|
|
26
24
|
G(),
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
X(),
|
|
26
|
+
Y(),
|
|
27
|
+
tt(),
|
|
28
|
+
et()
|
|
29
29
|
]);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
33
|
-
__typename:
|
|
34
|
-
data:
|
|
35
|
-
extension:
|
|
36
|
-
fileName:
|
|
37
|
-
mimeType:
|
|
31
|
+
function St() {
|
|
32
|
+
return s.object({
|
|
33
|
+
__typename: s.literal("DocumentFile").optional(),
|
|
34
|
+
data: s.string(),
|
|
35
|
+
extension: s.string().nullable(),
|
|
36
|
+
fileName: s.string().nullable(),
|
|
37
|
+
mimeType: s.string()
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
42
|
-
input:
|
|
43
|
-
type:
|
|
44
|
-
scope:
|
|
40
|
+
function G() {
|
|
41
|
+
return s.object({
|
|
42
|
+
input: s.lazy(() => T()),
|
|
43
|
+
type: B,
|
|
44
|
+
scope: y()
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
49
|
-
operations:
|
|
50
|
-
state:
|
|
47
|
+
function T() {
|
|
48
|
+
return s.object({
|
|
49
|
+
operations: s.number(),
|
|
50
|
+
state: s.lazy(() => Q())
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
55
|
-
data:
|
|
56
|
-
name:
|
|
53
|
+
function Q() {
|
|
54
|
+
return s.object({
|
|
55
|
+
data: s.unknown().nullish(),
|
|
56
|
+
name: s.string()
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
61
|
-
__typename:
|
|
62
|
-
hash:
|
|
63
|
-
index:
|
|
64
|
-
timestamp:
|
|
65
|
-
type:
|
|
59
|
+
function kt() {
|
|
60
|
+
return s.object({
|
|
61
|
+
__typename: s.literal("Operation").optional(),
|
|
62
|
+
hash: s.string(),
|
|
63
|
+
index: s.number(),
|
|
64
|
+
timestamp: s.string().datetime(),
|
|
65
|
+
type: s.string()
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
70
|
-
input:
|
|
71
|
-
type:
|
|
72
|
-
scope:
|
|
68
|
+
function X() {
|
|
69
|
+
return s.object({
|
|
70
|
+
input: s.lazy(() => z()),
|
|
71
|
+
type: Z,
|
|
72
|
+
scope: y()
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
77
|
-
end:
|
|
78
|
-
start:
|
|
75
|
+
function z() {
|
|
76
|
+
return s.object({
|
|
77
|
+
end: s.number().nullish(),
|
|
78
|
+
start: s.number().nullish()
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
input:
|
|
85
|
-
type:
|
|
86
|
-
scope:
|
|
81
|
+
const I = s.number;
|
|
82
|
+
function Y() {
|
|
83
|
+
return s.object({
|
|
84
|
+
input: I(),
|
|
85
|
+
type: H,
|
|
86
|
+
scope: y()
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
91
|
-
return
|
|
92
|
-
input:
|
|
93
|
-
type:
|
|
94
|
-
scope:
|
|
89
|
+
const F = s.string;
|
|
90
|
+
function tt() {
|
|
91
|
+
return s.object({
|
|
92
|
+
input: F(),
|
|
93
|
+
type: K,
|
|
94
|
+
scope: s.literal("global")
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
99
|
-
__typename:
|
|
100
|
-
hash:
|
|
101
|
-
index:
|
|
102
|
-
input:
|
|
103
|
-
timestamp:
|
|
104
|
-
type:
|
|
97
|
+
function _t() {
|
|
98
|
+
return s.object({
|
|
99
|
+
__typename: s.literal("SetNameOperation").optional(),
|
|
100
|
+
hash: s.string(),
|
|
101
|
+
index: s.number(),
|
|
102
|
+
input: s.string(),
|
|
103
|
+
timestamp: s.string().datetime(),
|
|
104
|
+
type: s.string()
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
109
|
-
return
|
|
110
|
-
input:
|
|
111
|
-
type:
|
|
112
|
-
scope:
|
|
107
|
+
const R = s.number;
|
|
108
|
+
function et() {
|
|
109
|
+
return s.object({
|
|
110
|
+
input: R(),
|
|
111
|
+
type: W,
|
|
112
|
+
scope: y()
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
116
116
|
__proto__: null,
|
|
117
|
-
ActionSchema:
|
|
118
|
-
BaseActionSchema:
|
|
119
|
-
DocumentFileSchema:
|
|
120
|
-
LoadStateActionInputSchema:
|
|
121
|
-
LoadStateActionSchema:
|
|
122
|
-
LoadStateActionStateInputSchema:
|
|
123
|
-
Load_StateSchema:
|
|
124
|
-
OperationSchema:
|
|
125
|
-
OperationScopeSchema:
|
|
126
|
-
PruneActionInputSchema:
|
|
127
|
-
PruneActionSchema:
|
|
128
|
-
PruneSchema:
|
|
129
|
-
RedoActionInputSchema:
|
|
130
|
-
RedoActionSchema:
|
|
131
|
-
RedoSchema:
|
|
132
|
-
SetNameActionInputSchema:
|
|
133
|
-
SetNameActionSchema:
|
|
134
|
-
SetNameOperationSchema:
|
|
135
|
-
Set_NameSchema:
|
|
136
|
-
UndoActionInputSchema:
|
|
137
|
-
UndoActionSchema:
|
|
138
|
-
UndoSchema:
|
|
139
|
-
definedNonNullAnySchema:
|
|
140
|
-
isDefinedNonNullAny:
|
|
117
|
+
ActionSchema: Ot,
|
|
118
|
+
BaseActionSchema: V,
|
|
119
|
+
DocumentFileSchema: St,
|
|
120
|
+
LoadStateActionInputSchema: T,
|
|
121
|
+
LoadStateActionSchema: G,
|
|
122
|
+
LoadStateActionStateInputSchema: Q,
|
|
123
|
+
Load_StateSchema: B,
|
|
124
|
+
OperationSchema: kt,
|
|
125
|
+
OperationScopeSchema: y,
|
|
126
|
+
PruneActionInputSchema: z,
|
|
127
|
+
PruneActionSchema: X,
|
|
128
|
+
PruneSchema: Z,
|
|
129
|
+
RedoActionInputSchema: I,
|
|
130
|
+
RedoActionSchema: Y,
|
|
131
|
+
RedoSchema: H,
|
|
132
|
+
SetNameActionInputSchema: F,
|
|
133
|
+
SetNameActionSchema: tt,
|
|
134
|
+
SetNameOperationSchema: _t,
|
|
135
|
+
Set_NameSchema: K,
|
|
136
|
+
UndoActionInputSchema: R,
|
|
137
|
+
UndoActionSchema: et,
|
|
138
|
+
UndoSchema: W,
|
|
139
|
+
definedNonNullAnySchema: jt,
|
|
140
|
+
isDefinedNonNullAny: J
|
|
141
141
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
142
|
-
function
|
|
142
|
+
function Et(t, e) {
|
|
143
143
|
return { ...t, name: e };
|
|
144
144
|
}
|
|
145
|
-
function kt(t, e, i) {
|
|
146
|
-
const { scope: a, input: n } = e, s = t.revision[e.scope], p = Math.min(n, s), l = t.operations[a].slice(
|
|
147
|
-
0,
|
|
148
|
-
s - p
|
|
149
|
-
);
|
|
150
|
-
return {
|
|
151
|
-
...O(
|
|
152
|
-
t.initialState,
|
|
153
|
-
{
|
|
154
|
-
...t.operations,
|
|
155
|
-
[a]: l
|
|
156
|
-
},
|
|
157
|
-
i
|
|
158
|
-
),
|
|
159
|
-
operations: t.operations,
|
|
160
|
-
revision: {
|
|
161
|
-
...t.revision,
|
|
162
|
-
[a]: t.revision[a] - p
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
145
|
function Dt(t, e, i) {
|
|
167
|
-
const { scope: a, input: n } = e
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
146
|
+
const { scope: a, input: n } = e;
|
|
147
|
+
return S({
|
|
148
|
+
document: t,
|
|
149
|
+
action: e,
|
|
150
|
+
skip: i
|
|
151
|
+
}, (o) => {
|
|
152
|
+
if (o.document.operations[a].length < 1)
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Cannot undo: no operations in history for scope "${a}"`
|
|
155
|
+
);
|
|
156
|
+
if (n < 1)
|
|
157
|
+
throw new Error(
|
|
158
|
+
"Invalid UNDO action: input value must be greater than 0"
|
|
159
|
+
);
|
|
160
|
+
if (o.skip > 0)
|
|
161
|
+
throw new Error(
|
|
162
|
+
"Cannot undo: skip value from reducer cannot be used with UNDO action"
|
|
163
|
+
);
|
|
164
|
+
const [c] = o.document.operations[a].slice(-1), u = c.type === "NOOP" && c.skip > 0;
|
|
165
|
+
if (o.skip += n, u && (o.skip += c.skip, o.document.operations[a].pop()), o.document.operations[a].length < o.skip)
|
|
166
|
+
throw new Error(
|
|
167
|
+
"Cannot undo: you can't undo more operations than the ones in the scope history"
|
|
168
|
+
);
|
|
169
|
+
const l = o.document.operations[a].length - 1;
|
|
170
|
+
let x = n, m = u ? l - c.skip : l;
|
|
171
|
+
for (; x > 0 && m >= 0; ) {
|
|
172
|
+
const d = o.document.operations[a][m];
|
|
173
|
+
d.type === "NOOP" && d.skip > 0 ? (m = m - (d.skip + 1), o.skip += d.skip + 1) : (o.document.clipboard.push({ ...d }), x--, m--);
|
|
187
174
|
}
|
|
188
|
-
|
|
175
|
+
o.action = M(a);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function Nt(t, e, i) {
|
|
179
|
+
const { scope: a, input: n } = e;
|
|
180
|
+
return S({
|
|
181
|
+
document: t,
|
|
182
|
+
action: e,
|
|
183
|
+
skip: i
|
|
184
|
+
}, (o) => {
|
|
185
|
+
if (o.skip > 0)
|
|
186
|
+
throw new Error(
|
|
187
|
+
"Cannot redo: skip value from reducer cannot be used with REDO action"
|
|
188
|
+
);
|
|
189
|
+
if (n > 1)
|
|
190
|
+
throw new Error(
|
|
191
|
+
"Cannot redo: you can only redo one operation at a time"
|
|
192
|
+
);
|
|
193
|
+
if (n < 1)
|
|
194
|
+
throw new Error("Invalid REDO action: invalid redo input value");
|
|
195
|
+
if (o.document.clipboard.length < 1)
|
|
196
|
+
throw new Error("Cannot redo: no operations in the clipboard");
|
|
197
|
+
const c = o.document.clipboard.findLastIndex(
|
|
198
|
+
(l) => l.scope === a
|
|
199
|
+
);
|
|
200
|
+
if (c < 0)
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Cannot redo: no operations in clipboard for scope "${a}"`
|
|
203
|
+
);
|
|
204
|
+
const u = o.document.clipboard.splice(c, 1)[0];
|
|
205
|
+
o.action = D({
|
|
206
|
+
type: u.type,
|
|
207
|
+
scope: u.scope,
|
|
208
|
+
input: u.input
|
|
209
|
+
});
|
|
210
|
+
});
|
|
189
211
|
}
|
|
190
|
-
function
|
|
212
|
+
function At(t, e, i) {
|
|
191
213
|
const { scope: a } = e, n = t.operations[a];
|
|
192
214
|
let {
|
|
193
|
-
input: { start:
|
|
215
|
+
input: { start: p, end: o }
|
|
194
216
|
} = e;
|
|
195
|
-
|
|
196
|
-
const
|
|
217
|
+
p = p || 0, o = o || n.length;
|
|
218
|
+
const c = n.slice(p, o), u = n.slice(0, p), l = n.slice(o), x = A(
|
|
197
219
|
t.initialState,
|
|
198
220
|
{
|
|
199
221
|
...t.operations,
|
|
200
|
-
[a]:
|
|
222
|
+
[a]: u.concat(c)
|
|
201
223
|
},
|
|
202
224
|
i
|
|
203
|
-
), { name:
|
|
204
|
-
return
|
|
225
|
+
), { name: m, state: d } = x, r = u.length, v = u.length ? u[u.length - 1].timestamp : l.length ? l[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
226
|
+
return A(
|
|
205
227
|
t.initialState,
|
|
206
228
|
{
|
|
207
229
|
...t.operations,
|
|
208
230
|
[a]: [
|
|
209
|
-
...
|
|
231
|
+
...u,
|
|
210
232
|
{
|
|
211
|
-
...
|
|
212
|
-
{ name:
|
|
213
|
-
|
|
233
|
+
...P(
|
|
234
|
+
{ name: m, state: d },
|
|
235
|
+
c.length
|
|
214
236
|
),
|
|
215
|
-
timestamp:
|
|
216
|
-
index:
|
|
217
|
-
hash:
|
|
237
|
+
timestamp: v,
|
|
238
|
+
index: r,
|
|
239
|
+
hash: ct({ state: d }, "global")
|
|
218
240
|
},
|
|
219
|
-
...
|
|
220
|
-
...
|
|
221
|
-
index:
|
|
241
|
+
...l.map((f, E) => ({
|
|
242
|
+
...f,
|
|
243
|
+
index: r + E + 1
|
|
222
244
|
}))
|
|
223
245
|
]
|
|
224
246
|
},
|
|
225
247
|
i
|
|
226
248
|
);
|
|
227
249
|
}
|
|
228
|
-
function
|
|
250
|
+
function Tt(t, e) {
|
|
229
251
|
return {
|
|
230
252
|
...t,
|
|
231
253
|
name: e.name,
|
|
232
254
|
state: e.state ?? { global: {}, local: {} }
|
|
233
255
|
};
|
|
234
256
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
257
|
+
const it = "SET_NAME", g = "UNDO", h = "REDO", w = "PRUNE", at = "LOAD_STATE";
|
|
258
|
+
function zt(t) {
|
|
237
259
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
238
260
|
}
|
|
239
|
-
function
|
|
261
|
+
function k() {
|
|
240
262
|
this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
|
|
241
263
|
for (let t = 0; t < arguments.length; t++)
|
|
242
264
|
this.define(arguments[t]);
|
|
243
265
|
this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
|
|
244
266
|
}
|
|
245
|
-
|
|
267
|
+
k.prototype.define = function(t, e) {
|
|
246
268
|
for (let i in t) {
|
|
247
269
|
let a = t[i].map(function(n) {
|
|
248
270
|
return n.toLowerCase();
|
|
249
271
|
});
|
|
250
272
|
i = i.toLowerCase();
|
|
251
273
|
for (let n = 0; n < a.length; n++) {
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
254
|
-
if (!e &&
|
|
274
|
+
const p = a[n];
|
|
275
|
+
if (p[0] !== "*") {
|
|
276
|
+
if (!e && p in this._types)
|
|
255
277
|
throw new Error(
|
|
256
|
-
'Attempt to change mapping for "' +
|
|
278
|
+
'Attempt to change mapping for "' + p + '" extension from "' + this._types[p] + '" to "' + i + '". Pass `force=true` to allow this, otherwise remove "' + p + '" from the list of extensions for "' + i + '".'
|
|
257
279
|
);
|
|
258
|
-
this._types[
|
|
280
|
+
this._types[p] = i;
|
|
259
281
|
}
|
|
260
282
|
}
|
|
261
283
|
if (e || !this._extensions[i]) {
|
|
@@ -264,144 +286,144 @@ _.prototype.define = function(t, e) {
|
|
|
264
286
|
}
|
|
265
287
|
}
|
|
266
288
|
};
|
|
267
|
-
|
|
289
|
+
k.prototype.getType = function(t) {
|
|
268
290
|
t = String(t);
|
|
269
291
|
let e = t.replace(/^.*[/\\]/, "").toLowerCase(), i = e.replace(/^.*\./, "").toLowerCase(), a = e.length < t.length;
|
|
270
292
|
return (i.length < e.length - 1 || !a) && this._types[i] || null;
|
|
271
293
|
};
|
|
272
|
-
|
|
294
|
+
k.prototype.getExtension = function(t) {
|
|
273
295
|
return t = /^\s*([^;\s]*)/.test(t) && RegExp.$1, t && this._extensions[t.toLowerCase()] || null;
|
|
274
296
|
};
|
|
275
|
-
var At = _, zt = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "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/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/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "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", "mjs"], "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/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": ["mp4s", "m4p"], "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-signature": ["asc", "sig"], "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/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/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/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/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/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "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"], "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/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "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/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "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/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"] };
|
|
276
|
-
let
|
|
277
|
-
var
|
|
278
|
-
const Mt = /* @__PURE__ */
|
|
279
|
-
function
|
|
280
|
-
const a =
|
|
281
|
-
return
|
|
297
|
+
var It = k, Ft = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "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/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/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "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", "mjs"], "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/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": ["mp4s", "m4p"], "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-signature": ["asc", "sig"], "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/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/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/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/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/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "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"], "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/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "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/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "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/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"] };
|
|
298
|
+
let Rt = It;
|
|
299
|
+
var Pt = new Rt(Ft);
|
|
300
|
+
const Mt = /* @__PURE__ */ zt(Pt);
|
|
301
|
+
function qt(t, e, i) {
|
|
302
|
+
const a = wt(t, e);
|
|
303
|
+
return N.mkdirSync(t, { recursive: !0 }), new Promise((n, p) => {
|
|
282
304
|
try {
|
|
283
|
-
|
|
284
|
-
|
|
305
|
+
N.writeFile(a, i, {}, (o) => {
|
|
306
|
+
o ? p(o) : n(a);
|
|
285
307
|
});
|
|
286
|
-
} catch (
|
|
287
|
-
|
|
308
|
+
} catch (o) {
|
|
309
|
+
p(o);
|
|
288
310
|
}
|
|
289
311
|
});
|
|
290
312
|
}
|
|
291
|
-
function
|
|
292
|
-
return
|
|
313
|
+
function nt(t) {
|
|
314
|
+
return N.readFileSync(t);
|
|
293
315
|
}
|
|
294
|
-
function
|
|
316
|
+
function Lt(t) {
|
|
295
317
|
return new Promise((e, i) => {
|
|
296
|
-
|
|
297
|
-
const n = [],
|
|
298
|
-
a.on("data", (
|
|
299
|
-
n.push(
|
|
318
|
+
yt.get(t, (a) => {
|
|
319
|
+
const n = [], p = a.headers["content-type"];
|
|
320
|
+
a.on("data", (o) => {
|
|
321
|
+
n.push(o);
|
|
300
322
|
}), a.on("end", () => {
|
|
301
|
-
e({ buffer: Buffer.concat(n), mimeType:
|
|
323
|
+
e({ buffer: Buffer.concat(n), mimeType: p });
|
|
302
324
|
});
|
|
303
325
|
}).on("error", (a) => {
|
|
304
326
|
i(a);
|
|
305
327
|
});
|
|
306
328
|
});
|
|
307
329
|
}
|
|
308
|
-
const
|
|
309
|
-
const e = new
|
|
330
|
+
const Ut = async (t) => nt(t), _ = (t, e = "sha1") => vt.createHash(e).update(t).digest("base64"), ot = async (t) => {
|
|
331
|
+
const e = new $(), { name: i, revision: a, documentType: n, created: p, lastModified: o } = t, c = {
|
|
310
332
|
name: i,
|
|
311
333
|
revision: a,
|
|
312
334
|
documentType: n,
|
|
313
|
-
created:
|
|
314
|
-
lastModified:
|
|
335
|
+
created: p,
|
|
336
|
+
lastModified: o
|
|
315
337
|
};
|
|
316
|
-
return e.file("header.json", JSON.stringify(
|
|
338
|
+
return e.file("header.json", JSON.stringify(c, null, 2)), e.file(
|
|
317
339
|
"state.json",
|
|
318
340
|
JSON.stringify(t.initialState || {}, null, 2)
|
|
319
|
-
), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((
|
|
320
|
-
const { data:
|
|
321
|
-
e.file(
|
|
341
|
+
), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((l) => {
|
|
342
|
+
const { data: x, ...m } = t.attachments[l];
|
|
343
|
+
e.file(l, x, {
|
|
322
344
|
base64: !0,
|
|
323
345
|
createFolders: !0,
|
|
324
|
-
comment: JSON.stringify(
|
|
346
|
+
comment: JSON.stringify(m)
|
|
325
347
|
});
|
|
326
348
|
}), e;
|
|
327
|
-
},
|
|
328
|
-
const
|
|
349
|
+
}, Ct = async (t, e, i, a) => {
|
|
350
|
+
const p = await (await ot(t)).generateAsync({
|
|
329
351
|
type: "uint8array",
|
|
330
352
|
streamFiles: !0
|
|
331
|
-
}),
|
|
332
|
-
return
|
|
353
|
+
}), o = a ?? t.name, c = `.${i}.zip`;
|
|
354
|
+
return qt(
|
|
333
355
|
e,
|
|
334
|
-
|
|
335
|
-
|
|
356
|
+
o.endsWith(c) ? o : `${o}${c}`,
|
|
357
|
+
p
|
|
336
358
|
);
|
|
337
|
-
},
|
|
338
|
-
const a = await (await
|
|
359
|
+
}, me = async (t, e) => {
|
|
360
|
+
const a = await (await ot(t)).generateAsync({ type: "blob" }), n = await e.createWritable();
|
|
339
361
|
await n.write(a), await n.close();
|
|
340
|
-
},
|
|
341
|
-
const i =
|
|
342
|
-
return
|
|
343
|
-
},
|
|
344
|
-
const i = new
|
|
362
|
+
}, L = async (t, e) => {
|
|
363
|
+
const i = nt(t);
|
|
364
|
+
return $t(i, e);
|
|
365
|
+
}, $t = async (t, e) => {
|
|
366
|
+
const i = new $();
|
|
345
367
|
return await i.loadAsync(t), Jt(i, e);
|
|
346
368
|
};
|
|
347
369
|
async function Jt(t, e) {
|
|
348
370
|
const i = t.file("state.json");
|
|
349
371
|
if (!i)
|
|
350
372
|
throw new Error("Initial state not found");
|
|
351
|
-
const a = await i.async("string"), n = JSON.parse(a),
|
|
352
|
-
let
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
373
|
+
const a = await i.async("string"), n = JSON.parse(a), p = t.file("header.json");
|
|
374
|
+
let o;
|
|
375
|
+
p && (o = JSON.parse(await p.async("string")));
|
|
376
|
+
const c = t.file("operations.json");
|
|
377
|
+
if (!c)
|
|
356
378
|
throw new Error("Operations history not found");
|
|
357
|
-
const
|
|
358
|
-
await
|
|
379
|
+
const u = JSON.parse(
|
|
380
|
+
await c.async("string")
|
|
359
381
|
);
|
|
360
|
-
let
|
|
382
|
+
let l = lt(
|
|
361
383
|
n,
|
|
362
|
-
|
|
384
|
+
u,
|
|
363
385
|
e,
|
|
364
386
|
void 0,
|
|
365
|
-
|
|
387
|
+
o
|
|
366
388
|
);
|
|
367
|
-
return
|
|
368
|
-
...
|
|
369
|
-
...
|
|
370
|
-
}),
|
|
389
|
+
return o && (l = {
|
|
390
|
+
...l,
|
|
391
|
+
...o
|
|
392
|
+
}), l;
|
|
371
393
|
}
|
|
372
|
-
function
|
|
394
|
+
function st(t) {
|
|
373
395
|
const e = t.replace(/^.*\./, "") || void 0, i = t.replace(/^.*[/\\]/, "") || void 0;
|
|
374
396
|
return { extension: e, fileName: i };
|
|
375
397
|
}
|
|
376
|
-
async function
|
|
377
|
-
const { buffer: e, mimeType: i = "application/octet-stream" } = await
|
|
398
|
+
async function ue(t) {
|
|
399
|
+
const { buffer: e, mimeType: i = "application/octet-stream" } = await Lt(t), a = st(t), n = e.toString("base64");
|
|
378
400
|
return {
|
|
379
401
|
data: n,
|
|
380
|
-
hash:
|
|
402
|
+
hash: _(n),
|
|
381
403
|
mimeType: i,
|
|
382
404
|
...a
|
|
383
405
|
};
|
|
384
406
|
}
|
|
385
|
-
async function
|
|
386
|
-
const e = await
|
|
387
|
-
return { data: n, hash:
|
|
407
|
+
async function de(t) {
|
|
408
|
+
const e = await Ut(t), i = Mt.getType(t) || "application/octet-stream", a = st(t), n = e.toString("base64");
|
|
409
|
+
return { data: n, hash: _(n), mimeType: i, ...a };
|
|
388
410
|
}
|
|
389
|
-
function
|
|
411
|
+
function Bt(t, e) {
|
|
390
412
|
const i = t.revision[e.scope];
|
|
391
|
-
return [
|
|
413
|
+
return [g, h, w].includes(e.type) ? i : i + 1;
|
|
392
414
|
}
|
|
393
|
-
function
|
|
415
|
+
function Zt(t, e) {
|
|
394
416
|
return {
|
|
395
417
|
...t,
|
|
396
418
|
revision: {
|
|
397
419
|
...t.revision,
|
|
398
|
-
[e.scope]:
|
|
420
|
+
[e.scope]: Bt(t, e)
|
|
399
421
|
},
|
|
400
422
|
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
401
423
|
};
|
|
402
424
|
}
|
|
403
|
-
function
|
|
404
|
-
if ([
|
|
425
|
+
function Ht(t, e, i = 0) {
|
|
426
|
+
if ([g, h, w].includes(e.type))
|
|
405
427
|
return t;
|
|
406
428
|
const { scope: a } = e, n = t.operations[a].slice(
|
|
407
429
|
0,
|
|
@@ -419,71 +441,100 @@ function Bt(t, e, i = 0) {
|
|
|
419
441
|
operations: { ...t.operations, [a]: n }
|
|
420
442
|
};
|
|
421
443
|
}
|
|
422
|
-
function
|
|
423
|
-
let a =
|
|
424
|
-
return a =
|
|
444
|
+
function Kt(t, e, i = 0) {
|
|
445
|
+
let a = Ht(t, e, i);
|
|
446
|
+
return a = Zt(a, e), a;
|
|
447
|
+
}
|
|
448
|
+
function Wt(t, e, i) {
|
|
449
|
+
switch (V().parse(e), e.type) {
|
|
450
|
+
case it:
|
|
451
|
+
return Et(t, e.input);
|
|
452
|
+
case w:
|
|
453
|
+
return At(t, e, i);
|
|
454
|
+
case at:
|
|
455
|
+
return Tt(t, e.input.state);
|
|
456
|
+
default:
|
|
457
|
+
return t;
|
|
458
|
+
}
|
|
425
459
|
}
|
|
426
|
-
function
|
|
427
|
-
switch (
|
|
428
|
-
case
|
|
429
|
-
return _t(t, e.input);
|
|
430
|
-
case f:
|
|
431
|
-
return kt(t, e, i);
|
|
432
|
-
case h:
|
|
460
|
+
function Vt(t, e, i) {
|
|
461
|
+
switch (e.type) {
|
|
462
|
+
case g:
|
|
433
463
|
return Dt(t, e, i);
|
|
434
|
-
case
|
|
435
|
-
return
|
|
436
|
-
case Y:
|
|
437
|
-
return Nt(t, e.input.state);
|
|
464
|
+
case h:
|
|
465
|
+
return Nt(t, e, i);
|
|
438
466
|
default:
|
|
439
|
-
return t;
|
|
467
|
+
return { document: t, action: e, skip: i };
|
|
440
468
|
}
|
|
441
469
|
}
|
|
442
|
-
function
|
|
443
|
-
const {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
470
|
+
function pt(t, e, i, a, n = {}) {
|
|
471
|
+
const { skip: p, ignoreSkipOperations: o = !1 } = n;
|
|
472
|
+
let c = { ...e }, u = p || 0, l = t, x = [...t.clipboard];
|
|
473
|
+
if (U(c)) {
|
|
474
|
+
const {
|
|
475
|
+
skip: m,
|
|
476
|
+
action: d,
|
|
477
|
+
document: r
|
|
478
|
+
} = Vt(t, c, u);
|
|
479
|
+
c = d, u = m, l = r, x = [...l.clipboard];
|
|
480
|
+
}
|
|
481
|
+
return C(c) && (l = Wt(l, c, i)), u > 0 && !o && (l = A(
|
|
482
|
+
l.initialState,
|
|
483
|
+
l.operations,
|
|
484
|
+
i,
|
|
485
|
+
void 0,
|
|
486
|
+
void 0,
|
|
487
|
+
void 0,
|
|
488
|
+
{ [c.scope]: u }
|
|
489
|
+
)), l = Kt(l, c, u), l = S(l, (m) => {
|
|
490
|
+
const d = i(
|
|
491
|
+
m.state,
|
|
492
|
+
c,
|
|
493
|
+
a
|
|
494
|
+
), r = U(e) ? [...x] : [];
|
|
495
|
+
if (d)
|
|
496
|
+
return D({
|
|
497
|
+
...l,
|
|
498
|
+
clipboard: [...r],
|
|
499
|
+
state: d
|
|
453
500
|
});
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
501
|
+
m.clipboard = D([...r]);
|
|
502
|
+
}), S(l, (m) => {
|
|
503
|
+
if ([g, h, w].includes(c.type))
|
|
504
|
+
return m;
|
|
505
|
+
const d = c.scope || "global";
|
|
506
|
+
m.operations[d][m.operations[d].length - 1].hash = ct(m, d), !C(c) && c.attachments && c.attachments.forEach((r) => {
|
|
507
|
+
const { hash: v, ...f } = r;
|
|
508
|
+
m.attachments[v] = {
|
|
509
|
+
...f
|
|
462
510
|
};
|
|
463
511
|
});
|
|
464
512
|
});
|
|
465
513
|
}
|
|
466
|
-
function
|
|
467
|
-
return [
|
|
514
|
+
function U(t) {
|
|
515
|
+
return [g, h].includes(t.type);
|
|
516
|
+
}
|
|
517
|
+
function C(t) {
|
|
518
|
+
return [it, g, h, w, at].includes(t.type);
|
|
468
519
|
}
|
|
469
|
-
function
|
|
520
|
+
function b(t, e, i, a, n = "global") {
|
|
470
521
|
if (!t)
|
|
471
522
|
throw new Error("Empty action type");
|
|
472
523
|
if (typeof t != "string")
|
|
473
524
|
throw new Error(`Invalid action type: ${t}`);
|
|
474
|
-
const
|
|
475
|
-
i && (
|
|
525
|
+
const p = { type: t, input: e, scope: n };
|
|
526
|
+
i && (p.attachments = i);
|
|
476
527
|
try {
|
|
477
|
-
a == null || a().parse(
|
|
478
|
-
} catch (
|
|
479
|
-
throw new Error(`Invalid action input: ${
|
|
528
|
+
a == null || a().parse(p.input);
|
|
529
|
+
} catch (o) {
|
|
530
|
+
throw new Error(`Invalid action input: ${o}`);
|
|
480
531
|
}
|
|
481
|
-
return
|
|
532
|
+
return p;
|
|
482
533
|
}
|
|
483
|
-
function
|
|
484
|
-
return (i, a, n,
|
|
534
|
+
function Gt(t, e = pt) {
|
|
535
|
+
return (i, a, n, p) => e(i, a, t, n, p);
|
|
485
536
|
}
|
|
486
|
-
const
|
|
537
|
+
const Qt = (t, e) => ({
|
|
487
538
|
name: "",
|
|
488
539
|
documentType: "",
|
|
489
540
|
revision: {
|
|
@@ -495,160 +546,171 @@ const Wt = (t, e) => ({
|
|
|
495
546
|
attachments: {},
|
|
496
547
|
...t,
|
|
497
548
|
state: (e == null ? void 0 : e(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
|
|
498
|
-
}),
|
|
499
|
-
const i =
|
|
549
|
+
}), Xt = (t, e) => {
|
|
550
|
+
const i = Qt(
|
|
500
551
|
t,
|
|
501
552
|
e
|
|
502
553
|
);
|
|
503
554
|
return {
|
|
504
555
|
...i,
|
|
505
556
|
initialState: i,
|
|
506
|
-
operations: { global: [], local: [] }
|
|
557
|
+
operations: { global: [], local: [] },
|
|
558
|
+
clipboard: []
|
|
507
559
|
};
|
|
508
|
-
},
|
|
560
|
+
}, ct = (t, e = "global") => _(bt(t.state[e])), xe = (t, e = 1e3) => {
|
|
509
561
|
const i = Math.random() * e;
|
|
510
|
-
return
|
|
562
|
+
return _(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
|
|
511
563
|
};
|
|
512
|
-
function
|
|
513
|
-
return gt(
|
|
514
|
-
}
|
|
515
|
-
function
|
|
516
|
-
const
|
|
517
|
-
let
|
|
518
|
-
const
|
|
519
|
-
for (const
|
|
520
|
-
if (
|
|
521
|
-
const l =
|
|
522
|
-
|
|
564
|
+
function O(t) {
|
|
565
|
+
return gt(ht(t, !0));
|
|
566
|
+
}
|
|
567
|
+
function Yt(t, e) {
|
|
568
|
+
const i = [...t];
|
|
569
|
+
let a = e || 0, n = i.length > 0 ? i[i.length - 1].index : 0;
|
|
570
|
+
const p = [];
|
|
571
|
+
for (const o of i.reverse()) {
|
|
572
|
+
if (a > 0) {
|
|
573
|
+
const l = n - o.index;
|
|
574
|
+
a -= l;
|
|
523
575
|
}
|
|
524
|
-
if (
|
|
576
|
+
if (a < 0)
|
|
525
577
|
throw new Error("Invalid operation index, missing operations");
|
|
526
|
-
const
|
|
527
|
-
ignore:
|
|
528
|
-
operation:
|
|
529
|
-
};
|
|
530
|
-
|
|
578
|
+
const c = {
|
|
579
|
+
ignore: a > 0,
|
|
580
|
+
operation: o
|
|
581
|
+
}, u = o.skip > 0 ? o.skip + 1 : 0;
|
|
582
|
+
if (u > 0 && u > a) {
|
|
583
|
+
const l = u - a;
|
|
584
|
+
a = a + l;
|
|
585
|
+
}
|
|
586
|
+
n = o.index, p.push(c);
|
|
531
587
|
}
|
|
532
|
-
return
|
|
588
|
+
return p.reverse();
|
|
533
589
|
}
|
|
534
|
-
function
|
|
590
|
+
function fe(t) {
|
|
535
591
|
return Object.values(t).flatMap((e) => e).sort(
|
|
536
592
|
(e, i) => new Date(e.timestamp).getTime() - new Date(i.timestamp).getTime()
|
|
537
593
|
);
|
|
538
594
|
}
|
|
539
|
-
function
|
|
595
|
+
function te(t) {
|
|
540
596
|
return Object.values(t).flatMap((e) => e).sort(
|
|
541
597
|
(e, i) => new Date(e.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
|
|
542
598
|
);
|
|
543
599
|
}
|
|
544
|
-
function
|
|
545
|
-
const
|
|
546
|
-
return
|
|
600
|
+
function A(t, e, i, a, n, p = pt, o = {}) {
|
|
601
|
+
const c = Gt(i, p);
|
|
602
|
+
return lt(
|
|
547
603
|
t,
|
|
548
604
|
e,
|
|
549
|
-
|
|
605
|
+
c,
|
|
550
606
|
a,
|
|
551
|
-
n
|
|
607
|
+
n,
|
|
608
|
+
o
|
|
552
609
|
);
|
|
553
610
|
}
|
|
554
|
-
function
|
|
555
|
-
const
|
|
611
|
+
function lt(t, e, i, a, n, p = {}) {
|
|
612
|
+
const o = Xt(t), c = Object.keys(e).reduce((m, d) => {
|
|
556
613
|
const r = d;
|
|
557
614
|
return {
|
|
558
|
-
...
|
|
615
|
+
...m,
|
|
559
616
|
[r]: e[r].slice(0, n == null ? void 0 : n.revision[r])
|
|
560
617
|
};
|
|
561
|
-
}, {}),
|
|
618
|
+
}, {}), u = Object.keys(c).reduce((m, d) => {
|
|
562
619
|
const r = d;
|
|
563
620
|
return {
|
|
564
|
-
...
|
|
565
|
-
[r]:
|
|
621
|
+
...m,
|
|
622
|
+
[r]: Yt(c[r], p[r])
|
|
566
623
|
};
|
|
567
|
-
}, {}),
|
|
568
|
-
(
|
|
569
|
-
|
|
570
|
-
|
|
624
|
+
}, {}), l = te(u).reduce(
|
|
625
|
+
(m, { ignore: d, operation: r }) => d ? i(
|
|
626
|
+
m,
|
|
627
|
+
M(r.scope),
|
|
628
|
+
a,
|
|
629
|
+
{ skip: r.skip, ignoreSkipOperations: !0 }
|
|
630
|
+
) : i(
|
|
631
|
+
m,
|
|
632
|
+
r,
|
|
571
633
|
a,
|
|
572
|
-
{ skip: r.skip }
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
),
|
|
576
|
-
|
|
634
|
+
{ skip: r.skip, ignoreSkipOperations: !0 }
|
|
635
|
+
),
|
|
636
|
+
o
|
|
637
|
+
), x = Object.keys(
|
|
638
|
+
l.operations
|
|
577
639
|
).reduce(
|
|
578
|
-
(
|
|
579
|
-
const r = d,
|
|
640
|
+
(m, d) => {
|
|
641
|
+
const r = d, v = n && n.revision[r] < e[r].length ? e[r].slice(n.revision[r]) : [];
|
|
580
642
|
return {
|
|
581
|
-
...
|
|
643
|
+
...m,
|
|
582
644
|
[r]: [
|
|
583
|
-
...
|
|
584
|
-
var
|
|
645
|
+
...l.operations[r].map((f, E) => {
|
|
646
|
+
var q;
|
|
585
647
|
return {
|
|
586
|
-
...
|
|
587
|
-
timestamp: ((
|
|
648
|
+
...f,
|
|
649
|
+
timestamp: ((q = e[r][E]) == null ? void 0 : q.timestamp) ?? f.timestamp
|
|
588
650
|
};
|
|
589
651
|
}),
|
|
590
|
-
...
|
|
652
|
+
...v
|
|
591
653
|
]
|
|
592
654
|
};
|
|
593
655
|
},
|
|
594
656
|
{ global: [], local: [] }
|
|
595
657
|
);
|
|
596
|
-
return { ...
|
|
658
|
+
return { ...l, operations: x };
|
|
597
659
|
}
|
|
598
|
-
const
|
|
660
|
+
const rt = (t) => b(
|
|
599
661
|
"SET_NAME",
|
|
600
662
|
t,
|
|
601
663
|
void 0,
|
|
602
|
-
|
|
664
|
+
F,
|
|
603
665
|
void 0
|
|
604
|
-
),
|
|
666
|
+
), mt = (t = 1, e = "global") => b(
|
|
605
667
|
"UNDO",
|
|
606
668
|
t,
|
|
607
669
|
void 0,
|
|
608
|
-
|
|
670
|
+
R,
|
|
609
671
|
e
|
|
610
|
-
),
|
|
672
|
+
), ut = (t = 1, e = "global") => b(
|
|
611
673
|
"REDO",
|
|
612
674
|
t,
|
|
613
675
|
void 0,
|
|
614
|
-
|
|
676
|
+
I,
|
|
615
677
|
e
|
|
616
|
-
),
|
|
678
|
+
), dt = (t, e, i = "global") => b(
|
|
617
679
|
"PRUNE",
|
|
618
680
|
{ start: t, end: e },
|
|
619
681
|
void 0,
|
|
620
|
-
|
|
682
|
+
z,
|
|
621
683
|
i
|
|
622
|
-
),
|
|
684
|
+
), P = (t, e) => b(
|
|
623
685
|
"LOAD_STATE",
|
|
624
686
|
{ state: t, operations: e },
|
|
625
687
|
void 0,
|
|
626
|
-
|
|
627
|
-
),
|
|
688
|
+
T
|
|
689
|
+
), M = (t = "global") => b(
|
|
628
690
|
"NOOP",
|
|
629
691
|
{},
|
|
630
692
|
void 0,
|
|
631
693
|
void 0,
|
|
632
694
|
t
|
|
633
|
-
),
|
|
695
|
+
), ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
634
696
|
__proto__: null,
|
|
635
|
-
loadState:
|
|
636
|
-
noop:
|
|
637
|
-
prune:
|
|
638
|
-
redo:
|
|
639
|
-
setName:
|
|
640
|
-
undo:
|
|
697
|
+
loadState: P,
|
|
698
|
+
noop: M,
|
|
699
|
+
prune: dt,
|
|
700
|
+
redo: ut,
|
|
701
|
+
setName: rt,
|
|
702
|
+
undo: mt
|
|
641
703
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
642
|
-
class
|
|
704
|
+
class he {
|
|
643
705
|
/**
|
|
644
706
|
* Constructs a BaseDocument instance with an initial state.
|
|
645
707
|
* @param reducer - The reducer function that updates the state.
|
|
646
708
|
* @param document - The initial state of the document.
|
|
647
709
|
*/
|
|
648
710
|
constructor(e, i, a) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
711
|
+
j(this, "_document");
|
|
712
|
+
j(this, "_reducer");
|
|
713
|
+
j(this, "_signalDispatch");
|
|
652
714
|
this._reducer = e, this._document = i, this._signalDispatch = a;
|
|
653
715
|
}
|
|
654
716
|
/**
|
|
@@ -671,14 +733,14 @@ class xe {
|
|
|
671
733
|
* @returns The file path where the state was saved.
|
|
672
734
|
*/
|
|
673
735
|
saveToFile(e, i, a) {
|
|
674
|
-
return
|
|
736
|
+
return Ct(this._document, e, i, a);
|
|
675
737
|
}
|
|
676
738
|
/**
|
|
677
739
|
* Loads the state of the document from a file.
|
|
678
740
|
* @param path - The file path where the state is stored.
|
|
679
741
|
*/
|
|
680
742
|
async loadFromFile(e) {
|
|
681
|
-
this._document = await
|
|
743
|
+
this._document = await L(e, this._reducer);
|
|
682
744
|
}
|
|
683
745
|
/**
|
|
684
746
|
* Loads the state of the document from a file and returns it.
|
|
@@ -687,19 +749,19 @@ class xe {
|
|
|
687
749
|
* @returns The state of the document.
|
|
688
750
|
*/
|
|
689
751
|
static async stateFromFile(e, i) {
|
|
690
|
-
return await
|
|
752
|
+
return await L(e, i);
|
|
691
753
|
}
|
|
692
754
|
/**
|
|
693
755
|
* Gets the current state of the document.
|
|
694
756
|
*/
|
|
695
757
|
get state() {
|
|
696
|
-
return
|
|
758
|
+
return O(this._document.state);
|
|
697
759
|
}
|
|
698
760
|
/**
|
|
699
761
|
* Gets the list of operations performed on the document.
|
|
700
762
|
*/
|
|
701
763
|
get operations() {
|
|
702
|
-
return
|
|
764
|
+
return O(this._document.operations);
|
|
703
765
|
}
|
|
704
766
|
/**
|
|
705
767
|
* Gets the name of the document.
|
|
@@ -738,13 +800,13 @@ class xe {
|
|
|
738
800
|
* Gets the initial state of the document.
|
|
739
801
|
*/
|
|
740
802
|
get initialState() {
|
|
741
|
-
return
|
|
803
|
+
return O(this._document.initialState);
|
|
742
804
|
}
|
|
743
805
|
/**
|
|
744
806
|
* Returns the current document as an object
|
|
745
807
|
*/
|
|
746
808
|
toDocument() {
|
|
747
|
-
return
|
|
809
|
+
return O(this._document);
|
|
748
810
|
}
|
|
749
811
|
/**
|
|
750
812
|
* Gets the attachment associated with the given key.
|
|
@@ -758,21 +820,21 @@ class xe {
|
|
|
758
820
|
* @param name - The new name of the document.
|
|
759
821
|
*/
|
|
760
822
|
setName(e) {
|
|
761
|
-
return this.dispatch(
|
|
823
|
+
return this.dispatch(rt(e)), this;
|
|
762
824
|
}
|
|
763
825
|
/**
|
|
764
826
|
* Reverts a number of actions from the document.
|
|
765
827
|
* @param count - The number of actions to revert.
|
|
766
828
|
*/
|
|
767
829
|
undo(e) {
|
|
768
|
-
return this.dispatch(
|
|
830
|
+
return this.dispatch(mt(e)), this;
|
|
769
831
|
}
|
|
770
832
|
/**
|
|
771
833
|
* Reapplies a number of actions to the document.
|
|
772
834
|
* @param count - The number of actions to reapply.
|
|
773
835
|
*/
|
|
774
836
|
redo(e) {
|
|
775
|
-
return this.dispatch(
|
|
837
|
+
return this.dispatch(ut(e)), this;
|
|
776
838
|
}
|
|
777
839
|
/**
|
|
778
840
|
* Removes a range of operations from the document.
|
|
@@ -780,7 +842,7 @@ class xe {
|
|
|
780
842
|
* @param end - The ending index of the range to remove.
|
|
781
843
|
*/
|
|
782
844
|
prune(e, i) {
|
|
783
|
-
return this.dispatch(
|
|
845
|
+
return this.dispatch(dt(e, i)), this;
|
|
784
846
|
}
|
|
785
847
|
/**
|
|
786
848
|
* Loads a document state and a set of operations.
|
|
@@ -788,10 +850,10 @@ class xe {
|
|
|
788
850
|
* @param operations - The operations to apply to the document.
|
|
789
851
|
*/
|
|
790
852
|
loadState(e, i) {
|
|
791
|
-
return this.dispatch(
|
|
853
|
+
return this.dispatch(P(e, i)), this;
|
|
792
854
|
}
|
|
793
855
|
}
|
|
794
|
-
function
|
|
856
|
+
function be(t, e) {
|
|
795
857
|
e.forEach((i) => {
|
|
796
858
|
Object.getOwnPropertyNames(i.prototype).forEach((a) => {
|
|
797
859
|
Object.defineProperty(
|
|
@@ -805,29 +867,31 @@ function ge(t, e) {
|
|
|
805
867
|
});
|
|
806
868
|
}
|
|
807
869
|
export {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
870
|
+
he as B,
|
|
871
|
+
Qt as a,
|
|
872
|
+
Xt as b,
|
|
873
|
+
Gt as c,
|
|
874
|
+
me as d,
|
|
875
|
+
$t as e,
|
|
876
|
+
b as f,
|
|
877
|
+
be as g,
|
|
878
|
+
ge as h,
|
|
879
|
+
C as i,
|
|
880
|
+
ot as j,
|
|
881
|
+
de as k,
|
|
882
|
+
L as l,
|
|
883
|
+
ue as m,
|
|
884
|
+
ct as n,
|
|
885
|
+
xe as o,
|
|
886
|
+
U as p,
|
|
887
|
+
Yt as q,
|
|
888
|
+
O as r,
|
|
889
|
+
Ct as s,
|
|
890
|
+
lt as t,
|
|
891
|
+
A as u,
|
|
892
|
+
te as v,
|
|
893
|
+
fe as w,
|
|
894
|
+
pt as x,
|
|
895
|
+
Vt as y,
|
|
896
|
+
re as z
|
|
833
897
|
};
|