document-model 1.0.19 → 1.0.21
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/package.json +16 -15
- package/dist/browser/document/actions/creators.d.ts +0 -46
- package/dist/browser/document/actions/index.d.ts +0 -10
- package/dist/browser/document/actions/types.d.ts +0 -8
- package/dist/browser/document/index.d.ts +0 -6
- package/dist/browser/document/object.d.ts +0 -285
- package/dist/browser/document/reducer.d.ts +0 -16
- package/dist/browser/document/schema/index.d.ts +0 -2
- package/dist/browser/document/schema/types.d.ts +0 -173
- package/dist/browser/document/schema/zod.d.ts +0 -111
- package/dist/browser/document/signal.d.ts +0 -22
- package/dist/browser/document/types.d.ts +0 -193
- package/dist/browser/document/utils/base.d.ts +0 -61
- package/dist/browser/document/utils/file.d.ts +0 -47
- package/dist/browser/document/utils/index.d.ts +0 -2
- package/dist/browser/document/utils/node.d.ts +0 -9
- package/dist/browser/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/browser/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/browser/document-model/custom/utils.d.ts +0 -1
- package/dist/browser/document-model/gen/actions.d.ts +0 -15
- package/dist/browser/document-model/gen/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/document-model.d.ts +0 -2
- package/dist/browser/document-model/gen/header/actions.d.ts +0 -9
- package/dist/browser/document-model/gen/header/creators.d.ts +0 -8
- package/dist/browser/document-model/gen/header/object.d.ts +0 -11
- package/dist/browser/document-model/gen/header/operations.d.ts +0 -10
- package/dist/browser/document-model/gen/index.d.ts +0 -5
- package/dist/browser/document-model/gen/module/actions.d.ts +0 -8
- package/dist/browser/document-model/gen/module/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/module/object.d.ts +0 -10
- package/dist/browser/document-model/gen/module/operations.d.ts +0 -9
- package/dist/browser/document-model/gen/object.d.ts +0 -28
- package/dist/browser/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/browser/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/browser/document-model/gen/operation/object.d.ts +0 -15
- package/dist/browser/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/browser/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/browser/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/browser/document-model/gen/operation-error/object.d.ts +0 -12
- package/dist/browser/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/browser/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/browser/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/browser/document-model/gen/operation-example/object.d.ts +0 -9
- package/dist/browser/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/browser/document-model/gen/reducer.d.ts +0 -3
- package/dist/browser/document-model/gen/schema/index.d.ts +0 -2
- package/dist/browser/document-model/gen/schema/types.d.ts +0 -453
- package/dist/browser/document-model/gen/schema/zod.d.ts +0 -451
- package/dist/browser/document-model/gen/state/actions.d.ts +0 -9
- package/dist/browser/document-model/gen/state/creators.d.ts +0 -8
- package/dist/browser/document-model/gen/state/object.d.ts +0 -11
- package/dist/browser/document-model/gen/state/operations.d.ts +0 -10
- package/dist/browser/document-model/gen/types.d.ts +0 -8
- package/dist/browser/document-model/gen/utils.d.ts +0 -6
- package/dist/browser/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/browser/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/browser/document-model/gen/versioning/object.d.ts +0 -10
- package/dist/browser/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/browser/document-model/index.d.ts +0 -74
- package/dist/browser/document-model.cjs +0 -1
- package/dist/browser/document-model.d.ts +0 -1
- package/dist/browser/document-model.js +0 -16
- package/dist/browser/document.cjs +0 -1
- package/dist/browser/document.d.ts +0 -1
- package/dist/browser/document.js +0 -14
- package/dist/browser/index.cjs +0 -1
- package/dist/browser/index.d.ts +0 -25
- package/dist/browser/index.js +0 -17
- package/dist/browser/internal/index-1ad32a2e.js +0 -22
- package/dist/browser/internal/index-2551382e.js +0 -34
- package/dist/browser/internal/index-46b68530.js +0 -1922
- package/dist/browser/internal/index-869c5d0d.js +0 -1
- package/dist/browser/internal/object-1fdba77d.js +0 -6
- package/dist/browser/internal/object-d50f7d2f.js +0 -1741
- package/dist/node/document/actions/creators.d.ts +0 -46
- package/dist/node/document/actions/index.d.ts +0 -10
- package/dist/node/document/actions/types.d.ts +0 -8
- package/dist/node/document/index.d.ts +0 -6
- package/dist/node/document/object.d.ts +0 -285
- package/dist/node/document/reducer.d.ts +0 -16
- package/dist/node/document/schema/index.d.ts +0 -2
- package/dist/node/document/schema/types.d.ts +0 -173
- package/dist/node/document/schema/zod.d.ts +0 -111
- package/dist/node/document/signal.d.ts +0 -22
- package/dist/node/document/types.d.ts +0 -193
- package/dist/node/document/utils/base.d.ts +0 -61
- package/dist/node/document/utils/file.d.ts +0 -47
- package/dist/node/document/utils/index.d.ts +0 -2
- package/dist/node/document/utils/node.d.ts +0 -9
- package/dist/node/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/node/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/node/document-model/custom/utils.d.ts +0 -1
- package/dist/node/document-model/gen/actions.d.ts +0 -15
- package/dist/node/document-model/gen/creators.d.ts +0 -7
- package/dist/node/document-model/gen/document-model.d.ts +0 -2
- package/dist/node/document-model/gen/header/actions.d.ts +0 -9
- package/dist/node/document-model/gen/header/creators.d.ts +0 -8
- package/dist/node/document-model/gen/header/object.d.ts +0 -11
- package/dist/node/document-model/gen/header/operations.d.ts +0 -10
- package/dist/node/document-model/gen/index.d.ts +0 -5
- package/dist/node/document-model/gen/module/actions.d.ts +0 -8
- package/dist/node/document-model/gen/module/creators.d.ts +0 -7
- package/dist/node/document-model/gen/module/object.d.ts +0 -10
- package/dist/node/document-model/gen/module/operations.d.ts +0 -9
- package/dist/node/document-model/gen/object.d.ts +0 -28
- package/dist/node/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/node/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/node/document-model/gen/operation/object.d.ts +0 -15
- package/dist/node/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/node/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/node/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/node/document-model/gen/operation-error/object.d.ts +0 -12
- package/dist/node/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/node/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/node/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/node/document-model/gen/operation-example/object.d.ts +0 -9
- package/dist/node/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/node/document-model/gen/reducer.d.ts +0 -3
- package/dist/node/document-model/gen/schema/index.d.ts +0 -2
- package/dist/node/document-model/gen/schema/types.d.ts +0 -453
- package/dist/node/document-model/gen/schema/zod.d.ts +0 -451
- package/dist/node/document-model/gen/state/actions.d.ts +0 -9
- package/dist/node/document-model/gen/state/creators.d.ts +0 -8
- package/dist/node/document-model/gen/state/object.d.ts +0 -11
- package/dist/node/document-model/gen/state/operations.d.ts +0 -10
- package/dist/node/document-model/gen/types.d.ts +0 -8
- package/dist/node/document-model/gen/utils.d.ts +0 -6
- package/dist/node/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/node/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/node/document-model/gen/versioning/object.d.ts +0 -10
- package/dist/node/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/node/document-model/index.d.ts +0 -74
- package/dist/node/document-model.cjs +0 -1
- package/dist/node/document-model.d.ts +0 -1
- package/dist/node/document-model.js +0 -20
- package/dist/node/document.cjs +0 -1
- package/dist/node/document.d.ts +0 -1
- package/dist/node/document.js +0 -18
- package/dist/node/index.cjs +0 -1
- package/dist/node/index.d.ts +0 -25
- package/dist/node/index.js +0 -21
- package/dist/node/internal/index-631ba7bf.js +0 -22
- package/dist/node/internal/index-6477ee0a.js +0 -1
- package/dist/node/internal/index-8d582c48.js +0 -1926
- package/dist/node/internal/index-f235f9be.js +0 -34
- package/dist/node/internal/object-08bd169a.js +0 -1
- package/dist/node/internal/object-773231ca.js +0 -743
|
@@ -1,743 +0,0 @@
|
|
|
1
|
-
var pt = Object.defineProperty;
|
|
2
|
-
var lt = (t, i, e) => i in t ? pt(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
|
|
3
|
-
var h = (t, i, e) => (lt(t, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
|
-
import ct from "json-stringify-deterministic";
|
|
5
|
-
import { produce as T, castDraft as rt, castImmutable as mt, freeze as ut } from "immer";
|
|
6
|
-
import { z as o } from "zod";
|
|
7
|
-
import P from "jszip";
|
|
8
|
-
import dt from "crypto";
|
|
9
|
-
import O from "fs";
|
|
10
|
-
import xt from "https";
|
|
11
|
-
import { join as gt } from "path";
|
|
12
|
-
const q = (t) => t != null, ft = o.any().refine((t) => q(t)), I = o.enum(["LOAD_STATE"]), M = o.enum(["PRUNE"]), R = o.enum(["REDO"]), L = o.enum(["SET_NAME"]), U = o.enum(["UNDO"]);
|
|
13
|
-
function ht() {
|
|
14
|
-
return o.object({
|
|
15
|
-
__typename: o.literal("Action").optional(),
|
|
16
|
-
type: o.string()
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function J() {
|
|
20
|
-
return o.union([
|
|
21
|
-
$(),
|
|
22
|
-
B(),
|
|
23
|
-
Z(),
|
|
24
|
-
H(),
|
|
25
|
-
K()
|
|
26
|
-
]);
|
|
27
|
-
}
|
|
28
|
-
function bt() {
|
|
29
|
-
return o.object({
|
|
30
|
-
__typename: o.literal("DocumentFile").optional(),
|
|
31
|
-
data: o.string(),
|
|
32
|
-
extension: o.string().nullable(),
|
|
33
|
-
fileName: o.string().nullable(),
|
|
34
|
-
mimeType: o.string()
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function $() {
|
|
38
|
-
return o.object({
|
|
39
|
-
input: o.lazy(() => _()),
|
|
40
|
-
type: I,
|
|
41
|
-
scope: o.literal("global")
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function _() {
|
|
45
|
-
return o.object({
|
|
46
|
-
operations: o.number(),
|
|
47
|
-
state: o.lazy(() => C())
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function C() {
|
|
51
|
-
return o.object({
|
|
52
|
-
data: o.unknown().nullish(),
|
|
53
|
-
name: o.string()
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function vt() {
|
|
57
|
-
return o.object({
|
|
58
|
-
__typename: o.literal("Operation").optional(),
|
|
59
|
-
hash: o.string(),
|
|
60
|
-
index: o.number(),
|
|
61
|
-
timestamp: o.string().datetime(),
|
|
62
|
-
type: o.string()
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function B() {
|
|
66
|
-
return o.object({
|
|
67
|
-
input: o.lazy(() => D()),
|
|
68
|
-
type: M,
|
|
69
|
-
scope: o.literal("global")
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function D() {
|
|
73
|
-
return o.object({
|
|
74
|
-
end: o.number().nullish(),
|
|
75
|
-
start: o.number().nullish()
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const k = o.number;
|
|
79
|
-
function Z() {
|
|
80
|
-
return o.object({
|
|
81
|
-
input: k(),
|
|
82
|
-
type: R,
|
|
83
|
-
scope: o.literal("global")
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const E = o.string;
|
|
87
|
-
function H() {
|
|
88
|
-
return o.object({
|
|
89
|
-
input: E(),
|
|
90
|
-
type: L,
|
|
91
|
-
scope: o.literal("global")
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function yt() {
|
|
95
|
-
return o.object({
|
|
96
|
-
__typename: o.literal("SetNameOperation").optional(),
|
|
97
|
-
hash: o.string(),
|
|
98
|
-
index: o.number(),
|
|
99
|
-
input: o.string(),
|
|
100
|
-
timestamp: o.string().datetime(),
|
|
101
|
-
type: o.string()
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
const N = o.number;
|
|
105
|
-
function K() {
|
|
106
|
-
return o.object({
|
|
107
|
-
input: N(),
|
|
108
|
-
type: U,
|
|
109
|
-
scope: o.literal("global")
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
113
|
-
__proto__: null,
|
|
114
|
-
ActionSchema: ht,
|
|
115
|
-
BaseActionSchema: J,
|
|
116
|
-
DocumentFileSchema: bt,
|
|
117
|
-
LoadStateActionInputSchema: _,
|
|
118
|
-
LoadStateActionSchema: $,
|
|
119
|
-
LoadStateActionStateInputSchema: C,
|
|
120
|
-
Load_StateSchema: I,
|
|
121
|
-
OperationSchema: vt,
|
|
122
|
-
PruneActionInputSchema: D,
|
|
123
|
-
PruneActionSchema: B,
|
|
124
|
-
PruneSchema: M,
|
|
125
|
-
RedoActionInputSchema: k,
|
|
126
|
-
RedoActionSchema: Z,
|
|
127
|
-
RedoSchema: R,
|
|
128
|
-
SetNameActionInputSchema: E,
|
|
129
|
-
SetNameActionSchema: H,
|
|
130
|
-
SetNameOperationSchema: yt,
|
|
131
|
-
Set_NameSchema: L,
|
|
132
|
-
UndoActionInputSchema: N,
|
|
133
|
-
UndoActionSchema: K,
|
|
134
|
-
UndoSchema: U,
|
|
135
|
-
definedNonNullAnySchema: ft,
|
|
136
|
-
isDefinedNonNullAny: q
|
|
137
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
138
|
-
function jt(t, i) {
|
|
139
|
-
return { ...t, name: i };
|
|
140
|
-
}
|
|
141
|
-
function wt(t, i, e) {
|
|
142
|
-
const n = Math.min(i, t.revision), a = t.operations.global.slice(
|
|
143
|
-
0,
|
|
144
|
-
t.revision - n
|
|
145
|
-
);
|
|
146
|
-
return {
|
|
147
|
-
...v(
|
|
148
|
-
t.initialState,
|
|
149
|
-
{
|
|
150
|
-
global: a,
|
|
151
|
-
local: t.operations.local
|
|
152
|
-
},
|
|
153
|
-
e
|
|
154
|
-
),
|
|
155
|
-
operations: t.operations,
|
|
156
|
-
revision: t.revision - n
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function St(t, i, e) {
|
|
160
|
-
const n = t.operations.global.length - t.revision;
|
|
161
|
-
if (!n)
|
|
162
|
-
throw new Error("There is no UNDO operation to REDO");
|
|
163
|
-
const a = i < n ? i : n, s = t.operations.global.slice(
|
|
164
|
-
0,
|
|
165
|
-
t.revision + a
|
|
166
|
-
);
|
|
167
|
-
return {
|
|
168
|
-
...v(
|
|
169
|
-
t.initialState,
|
|
170
|
-
{
|
|
171
|
-
global: s,
|
|
172
|
-
local: t.operations.local
|
|
173
|
-
},
|
|
174
|
-
e
|
|
175
|
-
),
|
|
176
|
-
operations: t.operations,
|
|
177
|
-
revision: t.revision + a
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function Ot(t, i, e, n) {
|
|
181
|
-
i = i || 0, e = e || t.operations.global.length;
|
|
182
|
-
const a = t.operations.global.slice(i, e), s = t.operations.global.slice(0, i), p = t.operations.global.slice(e), l = v(
|
|
183
|
-
t.initialState,
|
|
184
|
-
{
|
|
185
|
-
global: s.concat(a),
|
|
186
|
-
local: t.operations.local
|
|
187
|
-
},
|
|
188
|
-
n
|
|
189
|
-
), { name: r, state: c } = l, m = s.length, u = s.length ? s[s.length - 1].timestamp : p.length ? p[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
190
|
-
return v(
|
|
191
|
-
t.initialState,
|
|
192
|
-
{
|
|
193
|
-
global: [
|
|
194
|
-
...s,
|
|
195
|
-
{
|
|
196
|
-
...A(
|
|
197
|
-
{ name: r, state: c },
|
|
198
|
-
a.length
|
|
199
|
-
),
|
|
200
|
-
timestamp: u,
|
|
201
|
-
index: m,
|
|
202
|
-
hash: tt({ state: c }, "global")
|
|
203
|
-
},
|
|
204
|
-
...p.map((w, S) => ({
|
|
205
|
-
...w,
|
|
206
|
-
index: m + S + 1
|
|
207
|
-
}))
|
|
208
|
-
],
|
|
209
|
-
local: t.operations.local
|
|
210
|
-
},
|
|
211
|
-
n
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
function _t(t, i) {
|
|
215
|
-
return {
|
|
216
|
-
...t,
|
|
217
|
-
name: i.name,
|
|
218
|
-
state: i.state ?? { global: {}, local: {} }
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
const W = "SET_NAME", d = "UNDO", x = "REDO", g = "PRUNE", G = "LOAD_STATE";
|
|
222
|
-
function Dt(t) {
|
|
223
|
-
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
224
|
-
}
|
|
225
|
-
function y() {
|
|
226
|
-
this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
|
|
227
|
-
for (let t = 0; t < arguments.length; t++)
|
|
228
|
-
this.define(arguments[t]);
|
|
229
|
-
this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
|
|
230
|
-
}
|
|
231
|
-
y.prototype.define = function(t, i) {
|
|
232
|
-
for (let e in t) {
|
|
233
|
-
let n = t[e].map(function(a) {
|
|
234
|
-
return a.toLowerCase();
|
|
235
|
-
});
|
|
236
|
-
e = e.toLowerCase();
|
|
237
|
-
for (let a = 0; a < n.length; a++) {
|
|
238
|
-
const s = n[a];
|
|
239
|
-
if (s[0] !== "*") {
|
|
240
|
-
if (!i && s in this._types)
|
|
241
|
-
throw new Error(
|
|
242
|
-
'Attempt to change mapping for "' + s + '" extension from "' + this._types[s] + '" to "' + e + '". Pass `force=true` to allow this, otherwise remove "' + s + '" from the list of extensions for "' + e + '".'
|
|
243
|
-
);
|
|
244
|
-
this._types[s] = e;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (i || !this._extensions[e]) {
|
|
248
|
-
const a = n[0];
|
|
249
|
-
this._extensions[e] = a[0] !== "*" ? a : a.substr(1);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
y.prototype.getType = function(t) {
|
|
254
|
-
t = String(t);
|
|
255
|
-
let i = t.replace(/^.*[/\\]/, "").toLowerCase(), e = i.replace(/^.*\./, "").toLowerCase(), n = i.length < t.length;
|
|
256
|
-
return (e.length < i.length - 1 || !n) && this._types[e] || null;
|
|
257
|
-
};
|
|
258
|
-
y.prototype.getExtension = function(t) {
|
|
259
|
-
return t = /^\s*([^;\s]*)/.test(t) && RegExp.$1, t && this._extensions[t.toLowerCase()] || null;
|
|
260
|
-
};
|
|
261
|
-
var kt = y, Et = { "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"] };
|
|
262
|
-
let Nt = kt;
|
|
263
|
-
var At = new Nt(Et);
|
|
264
|
-
const Tt = /* @__PURE__ */ Dt(At);
|
|
265
|
-
function zt(t, i, e) {
|
|
266
|
-
const n = gt(t, i);
|
|
267
|
-
return O.mkdirSync(t, { recursive: !0 }), new Promise((a, s) => {
|
|
268
|
-
try {
|
|
269
|
-
O.writeFile(n, e, {}, (p) => {
|
|
270
|
-
p ? s(p) : a(n);
|
|
271
|
-
});
|
|
272
|
-
} catch (p) {
|
|
273
|
-
s(p);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
function Q(t) {
|
|
278
|
-
return O.readFileSync(t);
|
|
279
|
-
}
|
|
280
|
-
function Ft(t) {
|
|
281
|
-
return new Promise((i, e) => {
|
|
282
|
-
xt.get(t, (n) => {
|
|
283
|
-
const a = [], s = n.headers["content-type"];
|
|
284
|
-
n.on("data", (p) => {
|
|
285
|
-
a.push(p);
|
|
286
|
-
}), n.on("end", () => {
|
|
287
|
-
i({ buffer: Buffer.concat(a), mimeType: s });
|
|
288
|
-
});
|
|
289
|
-
}).on("error", (n) => {
|
|
290
|
-
e(n);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
const Pt = async (t) => Q(t), j = (t, i = "sha1") => dt.createHash(i).update(t).digest("base64"), V = async (t) => {
|
|
295
|
-
const i = new P(), { name: e, revision: n, documentType: a, created: s, lastModified: p } = t, l = {
|
|
296
|
-
name: e,
|
|
297
|
-
revision: n,
|
|
298
|
-
documentType: a,
|
|
299
|
-
created: s,
|
|
300
|
-
lastModified: p
|
|
301
|
-
};
|
|
302
|
-
return i.file("header.json", JSON.stringify(l, null, 2)), i.file(
|
|
303
|
-
"state.json",
|
|
304
|
-
JSON.stringify(t.initialState || {}, null, 2)
|
|
305
|
-
), i.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((c) => {
|
|
306
|
-
const { data: m, ...u } = t.attachments[c];
|
|
307
|
-
i.file(c, m, {
|
|
308
|
-
base64: !0,
|
|
309
|
-
createFolders: !0,
|
|
310
|
-
comment: JSON.stringify(u)
|
|
311
|
-
});
|
|
312
|
-
}), i;
|
|
313
|
-
}, qt = async (t, i, e, n) => {
|
|
314
|
-
const s = await (await V(t)).generateAsync({
|
|
315
|
-
type: "uint8array",
|
|
316
|
-
streamFiles: !0
|
|
317
|
-
}), p = n ?? t.name, l = `.${e}.zip`;
|
|
318
|
-
return zt(
|
|
319
|
-
i,
|
|
320
|
-
p.endsWith(l) ? p : `${p}${l}`,
|
|
321
|
-
s
|
|
322
|
-
);
|
|
323
|
-
}, ai = async (t, i) => {
|
|
324
|
-
const n = await (await V(t)).generateAsync({ type: "blob" }), a = await i.createWritable();
|
|
325
|
-
await a.write(n), await a.close();
|
|
326
|
-
}, z = async (t, i) => {
|
|
327
|
-
const e = Q(t);
|
|
328
|
-
return It(e, i);
|
|
329
|
-
}, It = async (t, i) => {
|
|
330
|
-
const e = new P();
|
|
331
|
-
return await e.loadAsync(t), Mt(e, i);
|
|
332
|
-
};
|
|
333
|
-
async function Mt(t, i) {
|
|
334
|
-
const e = t.file("state.json");
|
|
335
|
-
if (!e)
|
|
336
|
-
throw new Error("Initial state not found");
|
|
337
|
-
const n = await e.async("string"), a = JSON.parse(n), s = t.file("header.json");
|
|
338
|
-
let p;
|
|
339
|
-
s && (p = JSON.parse(await s.async("string")));
|
|
340
|
-
const l = t.file("operations.json");
|
|
341
|
-
if (!l)
|
|
342
|
-
throw new Error("Operations history not found");
|
|
343
|
-
const r = JSON.parse(
|
|
344
|
-
await l.async("string")
|
|
345
|
-
);
|
|
346
|
-
let c = it(
|
|
347
|
-
a,
|
|
348
|
-
r,
|
|
349
|
-
i,
|
|
350
|
-
void 0,
|
|
351
|
-
p
|
|
352
|
-
);
|
|
353
|
-
return p && (c = {
|
|
354
|
-
...c,
|
|
355
|
-
...p
|
|
356
|
-
}), c;
|
|
357
|
-
}
|
|
358
|
-
function X(t) {
|
|
359
|
-
const i = t.replace(/^.*\./, "") || void 0, e = t.replace(/^.*[/\\]/, "") || void 0;
|
|
360
|
-
return { extension: i, fileName: e };
|
|
361
|
-
}
|
|
362
|
-
async function ni(t) {
|
|
363
|
-
const { buffer: i, mimeType: e = "application/octet-stream" } = await Ft(t), n = X(t), a = i.toString("base64");
|
|
364
|
-
return {
|
|
365
|
-
data: a,
|
|
366
|
-
hash: j(a),
|
|
367
|
-
mimeType: e,
|
|
368
|
-
...n
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
async function oi(t) {
|
|
372
|
-
const i = await Pt(t), e = Tt.getType(t) || "application/octet-stream", n = X(t), a = i.toString("base64");
|
|
373
|
-
return { data: a, hash: j(a), mimeType: e, ...n };
|
|
374
|
-
}
|
|
375
|
-
function Rt(t, i) {
|
|
376
|
-
return [d, x, g].includes(i.type) ? t.revision : t.revision + 1;
|
|
377
|
-
}
|
|
378
|
-
function Lt(t, i) {
|
|
379
|
-
return {
|
|
380
|
-
...t,
|
|
381
|
-
revision: Rt(t, i),
|
|
382
|
-
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function Ut(t, i) {
|
|
386
|
-
if ([d, x, g].includes(i.type))
|
|
387
|
-
return t;
|
|
388
|
-
const e = t.operations.global.slice(
|
|
389
|
-
0,
|
|
390
|
-
t.revision
|
|
391
|
-
), n = i.scope || "global", a = n === "global" ? e : t.operations[n];
|
|
392
|
-
return a.push({
|
|
393
|
-
...i,
|
|
394
|
-
index: a.length,
|
|
395
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
396
|
-
hash: "",
|
|
397
|
-
scope: n
|
|
398
|
-
}), {
|
|
399
|
-
...t,
|
|
400
|
-
operations: { ...t.operations, [n]: a }
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function Jt(t, i) {
|
|
404
|
-
let e = Ut(t, i);
|
|
405
|
-
return (!i.scope || i.scope === "global") && (e = Lt(e, i)), e;
|
|
406
|
-
}
|
|
407
|
-
function $t(t, i, e) {
|
|
408
|
-
switch (J().parse(i), i.type) {
|
|
409
|
-
case W:
|
|
410
|
-
return jt(t, i.input);
|
|
411
|
-
case d:
|
|
412
|
-
return wt(t, i.input, e);
|
|
413
|
-
case x:
|
|
414
|
-
return St(t, i.input, e);
|
|
415
|
-
case g:
|
|
416
|
-
return Ot(
|
|
417
|
-
t,
|
|
418
|
-
i.input.start,
|
|
419
|
-
i.input.end,
|
|
420
|
-
e
|
|
421
|
-
);
|
|
422
|
-
case G:
|
|
423
|
-
return _t(t, i.input.state);
|
|
424
|
-
default:
|
|
425
|
-
return t;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
function Y(t, i, e, n) {
|
|
429
|
-
let a = t;
|
|
430
|
-
return F(i) && (a = $t(a, i, e)), a = Jt(a, i), a = T(a, (s) => {
|
|
431
|
-
const p = e(s.state, i, n);
|
|
432
|
-
if (p)
|
|
433
|
-
return rt({
|
|
434
|
-
...a,
|
|
435
|
-
state: p
|
|
436
|
-
});
|
|
437
|
-
}), T(a, (s) => {
|
|
438
|
-
if ([d, x, g].includes(i.type))
|
|
439
|
-
return s;
|
|
440
|
-
const p = i.scope || "global";
|
|
441
|
-
s.operations[p][s.operations[p].length - 1].hash = tt(s, p), !F(i) && i.attachments && i.attachments.forEach((l) => {
|
|
442
|
-
const { hash: r, ...c } = l;
|
|
443
|
-
s.attachments[r] = {
|
|
444
|
-
...c
|
|
445
|
-
};
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
function F(t) {
|
|
450
|
-
return [W, d, x, g, G].includes(t.type);
|
|
451
|
-
}
|
|
452
|
-
function f(t, i, e, n, a = "global") {
|
|
453
|
-
if (!t)
|
|
454
|
-
throw new Error("Empty action type");
|
|
455
|
-
if (typeof t != "string")
|
|
456
|
-
throw new Error(`Invalid action type: ${t}`);
|
|
457
|
-
const s = { type: t, input: i, scope: a };
|
|
458
|
-
e && (s.attachments = e);
|
|
459
|
-
try {
|
|
460
|
-
n == null || n().parse(s.input);
|
|
461
|
-
} catch (p) {
|
|
462
|
-
throw new Error(`Invalid action input: ${p}`);
|
|
463
|
-
}
|
|
464
|
-
return s;
|
|
465
|
-
}
|
|
466
|
-
function Ct(t, i = Y) {
|
|
467
|
-
return (e, n, a) => i(e, n, t, a);
|
|
468
|
-
}
|
|
469
|
-
const Bt = (t, i) => ({
|
|
470
|
-
name: "",
|
|
471
|
-
documentType: "",
|
|
472
|
-
revision: 0,
|
|
473
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
474
|
-
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
475
|
-
attachments: {},
|
|
476
|
-
...t,
|
|
477
|
-
state: (i == null ? void 0 : i(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
|
|
478
|
-
}), Zt = (t, i) => {
|
|
479
|
-
const e = Bt(
|
|
480
|
-
t,
|
|
481
|
-
i
|
|
482
|
-
);
|
|
483
|
-
return {
|
|
484
|
-
...e,
|
|
485
|
-
initialState: e,
|
|
486
|
-
operations: { global: [], local: [] }
|
|
487
|
-
};
|
|
488
|
-
}, tt = (t, i = "global") => j(ct(t.state[i])), si = (t, i = 1e3) => {
|
|
489
|
-
const e = Math.random() * i;
|
|
490
|
-
return j(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${e}`);
|
|
491
|
-
};
|
|
492
|
-
function b(t) {
|
|
493
|
-
return mt(ut(t, !0));
|
|
494
|
-
}
|
|
495
|
-
function Ht(t) {
|
|
496
|
-
return Object.values(t).flatMap((i) => i).sort(
|
|
497
|
-
(i, e) => new Date(i.timestamp).getTime() - new Date(e.timestamp).getTime()
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
function v(t, i, e, n, a, s = Y) {
|
|
501
|
-
const p = Ct(e, s);
|
|
502
|
-
return it(
|
|
503
|
-
t,
|
|
504
|
-
i,
|
|
505
|
-
p,
|
|
506
|
-
n,
|
|
507
|
-
a
|
|
508
|
-
);
|
|
509
|
-
}
|
|
510
|
-
function it(t, i, e, n, a) {
|
|
511
|
-
const s = Zt(t), p = {
|
|
512
|
-
...i,
|
|
513
|
-
global: i.global.slice(0, a == null ? void 0 : a.revision)
|
|
514
|
-
}, l = Ht(p).reduce(
|
|
515
|
-
(c, m) => e(c, m, n),
|
|
516
|
-
s
|
|
517
|
-
), r = Object.keys(
|
|
518
|
-
l.operations
|
|
519
|
-
).reduce(
|
|
520
|
-
(c, m) => {
|
|
521
|
-
const u = m, w = u === "global" && a && a.revision < i.global.length ? i.global.slice(a == null ? void 0 : a.revision) : [];
|
|
522
|
-
return {
|
|
523
|
-
...c,
|
|
524
|
-
[u]: [
|
|
525
|
-
...l.operations[u].map((S, st) => ({
|
|
526
|
-
...S,
|
|
527
|
-
timestamp: i[u][st].timestamp
|
|
528
|
-
})),
|
|
529
|
-
...w
|
|
530
|
-
]
|
|
531
|
-
};
|
|
532
|
-
},
|
|
533
|
-
{ global: [], local: [] }
|
|
534
|
-
);
|
|
535
|
-
return { ...l, operations: r };
|
|
536
|
-
}
|
|
537
|
-
const et = (t) => f(
|
|
538
|
-
"SET_NAME",
|
|
539
|
-
t,
|
|
540
|
-
void 0,
|
|
541
|
-
E
|
|
542
|
-
), at = (t = 1) => f("UNDO", t, void 0, N), nt = (t = 1) => f("REDO", t, void 0, k), ot = (t, i) => f(
|
|
543
|
-
"PRUNE",
|
|
544
|
-
{ start: t, end: i },
|
|
545
|
-
void 0,
|
|
546
|
-
D
|
|
547
|
-
), A = (t, i) => f(
|
|
548
|
-
"LOAD_STATE",
|
|
549
|
-
{ state: t, operations: i },
|
|
550
|
-
void 0,
|
|
551
|
-
_
|
|
552
|
-
), pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
553
|
-
__proto__: null,
|
|
554
|
-
loadState: A,
|
|
555
|
-
prune: ot,
|
|
556
|
-
redo: nt,
|
|
557
|
-
setName: et,
|
|
558
|
-
undo: at
|
|
559
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
560
|
-
class li {
|
|
561
|
-
/**
|
|
562
|
-
* Constructs a BaseDocument instance with an initial state.
|
|
563
|
-
* @param reducer - The reducer function that updates the state.
|
|
564
|
-
* @param document - The initial state of the document.
|
|
565
|
-
*/
|
|
566
|
-
constructor(i, e, n) {
|
|
567
|
-
h(this, "_document");
|
|
568
|
-
h(this, "_reducer");
|
|
569
|
-
h(this, "_signalDispatch");
|
|
570
|
-
this._reducer = i, this._document = e, this._signalDispatch = n;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Dispatches an action to update the state of the document.
|
|
574
|
-
* @param action - The action to dispatch.
|
|
575
|
-
* @returns The Document instance.
|
|
576
|
-
*/
|
|
577
|
-
dispatch(i) {
|
|
578
|
-
return this._document = this._reducer(
|
|
579
|
-
this._document,
|
|
580
|
-
i,
|
|
581
|
-
this._signalDispatch
|
|
582
|
-
), this;
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Saves the state of the document to a file.
|
|
586
|
-
* @param path - The file path where the state should be saved.
|
|
587
|
-
* @param extension - The file extension to use when saving the state.
|
|
588
|
-
* @returns The file path where the state was saved.
|
|
589
|
-
*/
|
|
590
|
-
saveToFile(i, e, n) {
|
|
591
|
-
return qt(this._document, i, e, n);
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Loads the state of the document from a file.
|
|
595
|
-
* @param path - The file path where the state is stored.
|
|
596
|
-
*/
|
|
597
|
-
async loadFromFile(i) {
|
|
598
|
-
this._document = await z(i, this._reducer);
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* Loads the state of the document from a file and returns it.
|
|
602
|
-
* @param path - The file path where the state is stored.
|
|
603
|
-
* @param reducer - The reducer function that updates the state.
|
|
604
|
-
* @returns The state of the document.
|
|
605
|
-
*/
|
|
606
|
-
static async stateFromFile(i, e) {
|
|
607
|
-
return await z(i, e);
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Gets the current state of the document.
|
|
611
|
-
*/
|
|
612
|
-
get state() {
|
|
613
|
-
return b(this._document.state);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Gets the list of operations performed on the document.
|
|
617
|
-
*/
|
|
618
|
-
get operations() {
|
|
619
|
-
return b(this._document.operations);
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Gets the name of the document.
|
|
623
|
-
*/
|
|
624
|
-
get name() {
|
|
625
|
-
return this._document.name;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Gets the type of document.
|
|
629
|
-
*/
|
|
630
|
-
get documentType() {
|
|
631
|
-
return this._document.documentType;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Gets the timestamp of the date the document was created.
|
|
635
|
-
*/
|
|
636
|
-
get created() {
|
|
637
|
-
return this._document.created;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Gets the timestamp of the date the document was last modified.
|
|
641
|
-
*/
|
|
642
|
-
get lastModified() {
|
|
643
|
-
return this._document.lastModified;
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Gets the revision number of the document.
|
|
647
|
-
*/
|
|
648
|
-
get revision() {
|
|
649
|
-
return this._document.revision;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Gets the initial state of the document.
|
|
653
|
-
*/
|
|
654
|
-
get initialState() {
|
|
655
|
-
return b(this._document.initialState);
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Returns the current document as an object
|
|
659
|
-
*/
|
|
660
|
-
toDocument() {
|
|
661
|
-
return b(this._document);
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Gets the attachment associated with the given key.
|
|
665
|
-
* @param attachment - The key of the attachment to retrieve.
|
|
666
|
-
*/
|
|
667
|
-
getAttachment(i) {
|
|
668
|
-
return this._document.attachments[i];
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Sets the name of the document.
|
|
672
|
-
* @param name - The new name of the document.
|
|
673
|
-
*/
|
|
674
|
-
setName(i) {
|
|
675
|
-
return this.dispatch(et(i)), this;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* Reverts a number of actions from the document.
|
|
679
|
-
* @param count - The number of actions to revert.
|
|
680
|
-
*/
|
|
681
|
-
undo(i) {
|
|
682
|
-
return this.dispatch(at(i)), this;
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Reapplies a number of actions to the document.
|
|
686
|
-
* @param count - The number of actions to reapply.
|
|
687
|
-
*/
|
|
688
|
-
redo(i) {
|
|
689
|
-
return this.dispatch(nt(i)), this;
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Removes a range of operations from the document.
|
|
693
|
-
* @param start - The starting index of the range to remove.
|
|
694
|
-
* @param end - The ending index of the range to remove.
|
|
695
|
-
*/
|
|
696
|
-
prune(i, e) {
|
|
697
|
-
return this.dispatch(ot(i, e)), this;
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Loads a document state and a set of operations.
|
|
701
|
-
* @param state - The state to load.
|
|
702
|
-
* @param operations - The operations to apply to the document.
|
|
703
|
-
*/
|
|
704
|
-
loadState(i, e) {
|
|
705
|
-
return this.dispatch(A(i, e)), this;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
function ci(t, i) {
|
|
709
|
-
i.forEach((e) => {
|
|
710
|
-
Object.getOwnPropertyNames(e.prototype).forEach((n) => {
|
|
711
|
-
Object.defineProperty(
|
|
712
|
-
t.prototype,
|
|
713
|
-
n,
|
|
714
|
-
Object.getOwnPropertyDescriptor(e.prototype, n) || /* @__PURE__ */ Object.create(null)
|
|
715
|
-
);
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
export {
|
|
720
|
-
li as B,
|
|
721
|
-
Bt as a,
|
|
722
|
-
Zt as b,
|
|
723
|
-
Ct as c,
|
|
724
|
-
ai as d,
|
|
725
|
-
It as e,
|
|
726
|
-
f,
|
|
727
|
-
ci as g,
|
|
728
|
-
pi as h,
|
|
729
|
-
F as i,
|
|
730
|
-
V as j,
|
|
731
|
-
oi as k,
|
|
732
|
-
z as l,
|
|
733
|
-
ni as m,
|
|
734
|
-
tt as n,
|
|
735
|
-
si as o,
|
|
736
|
-
it as p,
|
|
737
|
-
v as q,
|
|
738
|
-
b as r,
|
|
739
|
-
qt as s,
|
|
740
|
-
Ht as t,
|
|
741
|
-
Y as u,
|
|
742
|
-
ei as z
|
|
743
|
-
};
|