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