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