document-model 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +3 -2
- package/dist/browser/cjs/document-model.js.map +1 -1
- package/dist/browser/cjs/document.js +11 -10
- package/dist/browser/cjs/document.js.map +1 -1
- package/dist/browser/cjs/index.js +2 -2
- package/dist/browser/cjs/internal/{object-BdIbCX0K.js → creators-BFR88wjA.js} +32 -180
- package/dist/browser/cjs/internal/creators-BFR88wjA.js.map +1 -0
- package/dist/browser/cjs/internal/index-B4JwoOCW.js +19 -0
- package/dist/browser/cjs/internal/index-B4JwoOCW.js.map +1 -0
- package/dist/browser/cjs/internal/index-CQbaipWs.js +46 -0
- package/dist/browser/cjs/internal/index-CQbaipWs.js.map +1 -0
- package/dist/browser/cjs/internal/{index-hPntrUvN.js → index-sKyQchiV.js} +56 -55
- package/dist/{node/cjs/internal/index-Bsyn7lZ0.js.map → browser/cjs/internal/index-sKyQchiV.js.map} +1 -1
- package/dist/browser/cjs/internal/object-Cffgxa2p.js +183 -0
- package/dist/browser/cjs/internal/object-Cffgxa2p.js.map +1 -0
- package/dist/browser/cjs/utils.js +43 -0
- package/dist/browser/cjs/utils.js.map +1 -0
- package/dist/browser/es/document-model.js +3 -2
- package/dist/browser/es/document-model.js.map +1 -1
- package/dist/browser/es/document.js +12 -11
- package/dist/browser/es/document.js.map +1 -1
- package/dist/browser/es/index.js +2 -2
- package/dist/browser/es/internal/{object-oB7gkKNr.js → creators-B8Nq9c1o.js} +67 -215
- package/dist/browser/es/internal/creators-B8Nq9c1o.js.map +1 -0
- package/dist/browser/es/internal/index-BBMtae0d.js +20 -0
- package/dist/browser/es/internal/index-BBMtae0d.js.map +1 -0
- package/dist/browser/es/internal/index-BH94ELCG.js +47 -0
- package/dist/browser/es/internal/index-BH94ELCG.js.map +1 -0
- package/dist/browser/es/internal/{index-D_fwH6L3.js → index-BoZSovTG.js} +4 -3
- package/dist/{node/es/internal/index-D4oqm7Ua.js.map → browser/es/internal/index-BoZSovTG.js.map} +1 -1
- package/dist/browser/es/internal/object-4B35tX7x.js +184 -0
- package/dist/browser/es/internal/object-4B35tX7x.js.map +1 -0
- package/dist/browser/es/utils.js +43 -0
- package/dist/browser/es/utils.js.map +1 -0
- package/dist/browser/src/document/utils/base.d.ts.map +1 -1
- package/dist/browser/src/document/utils/errors.d.ts +10 -0
- package/dist/browser/src/document/utils/errors.d.ts.map +1 -0
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/browser/src/document/utils/index.d.ts.map +1 -1
- package/dist/browser/utils.d.ts +2 -0
- package/dist/browser/vite.config.d.ts.map +1 -1
- package/dist/node/cjs/document-model.js +3 -2
- package/dist/node/cjs/document-model.js.map +1 -1
- package/dist/node/cjs/document.js +11 -10
- package/dist/node/cjs/document.js.map +1 -1
- package/dist/node/cjs/index.js +2 -2
- package/dist/node/cjs/internal/{object-DqFXYK4g.js → creators-cVAOzgAh.js} +32 -180
- package/dist/node/cjs/internal/creators-cVAOzgAh.js.map +1 -0
- package/dist/node/cjs/internal/index-TqZ14nZp.js +19 -0
- package/dist/node/cjs/internal/index-TqZ14nZp.js.map +1 -0
- package/dist/node/cjs/internal/index-Zf6dGXol.js +46 -0
- package/dist/node/cjs/internal/index-Zf6dGXol.js.map +1 -0
- package/dist/node/cjs/internal/{index-Bsyn7lZ0.js → index-kuBJXCvW.js} +56 -55
- package/dist/{browser/cjs/internal/index-hPntrUvN.js.map → node/cjs/internal/index-kuBJXCvW.js.map} +1 -1
- package/dist/node/cjs/internal/object-DrxUkgaL.js +183 -0
- package/dist/node/cjs/internal/object-DrxUkgaL.js.map +1 -0
- package/dist/node/cjs/utils.js +43 -0
- package/dist/node/cjs/utils.js.map +1 -0
- package/dist/node/es/document-model.js +3 -2
- package/dist/node/es/document-model.js.map +1 -1
- package/dist/node/es/document.js +12 -11
- package/dist/node/es/document.js.map +1 -1
- package/dist/node/es/index.js +2 -2
- package/dist/node/es/internal/{object-2XgKQb4s.js → creators-Cb-W0me8.js} +67 -215
- package/dist/node/es/internal/creators-Cb-W0me8.js.map +1 -0
- package/dist/node/es/internal/index-D3XxyPtg.js +20 -0
- package/dist/node/es/internal/index-D3XxyPtg.js.map +1 -0
- package/dist/node/es/internal/index-DaOQbHFb.js +47 -0
- package/dist/node/es/internal/index-DaOQbHFb.js.map +1 -0
- package/dist/node/es/internal/{index-D4oqm7Ua.js → index-nspj7nvI.js} +4 -3
- package/dist/{browser/es/internal/index-D_fwH6L3.js.map → node/es/internal/index-nspj7nvI.js.map} +1 -1
- package/dist/node/es/internal/object-8ji4ZOox.js +184 -0
- package/dist/node/es/internal/object-8ji4ZOox.js.map +1 -0
- package/dist/node/es/utils.js +43 -0
- package/dist/node/es/utils.js.map +1 -0
- package/dist/node/src/document/utils/base.d.ts.map +1 -1
- package/dist/node/src/document/utils/errors.d.ts +10 -0
- package/dist/node/src/document/utils/errors.d.ts.map +1 -0
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/dist/node/src/document/utils/index.d.ts.map +1 -1
- package/dist/node/utils.d.ts +2 -0
- package/dist/node/vite.config.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/browser/cjs/internal/index-B62DRxDu.js +0 -58
- package/dist/browser/cjs/internal/index-B62DRxDu.js.map +0 -1
- package/dist/browser/cjs/internal/object-BdIbCX0K.js.map +0 -1
- package/dist/browser/es/internal/index-CPWf201E.js +0 -59
- package/dist/browser/es/internal/index-CPWf201E.js.map +0 -1
- package/dist/browser/es/internal/object-oB7gkKNr.js.map +0 -1
- package/dist/node/cjs/internal/index-DozfRrse.js +0 -58
- package/dist/node/cjs/internal/index-DozfRrse.js.map +0 -1
- package/dist/node/cjs/internal/object-DqFXYK4g.js.map +0 -1
- package/dist/node/es/internal/index-Bf87b5UD.js +0 -59
- package/dist/node/es/internal/index-Bf87b5UD.js.map +0 -1
- package/dist/node/es/internal/object-2XgKQb4s.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import JSZip from "jszip";
|
|
5
|
+
import { z, ZodError } from "zod";
|
|
4
6
|
import { create, castDraft, unsafe } from "mutative";
|
|
5
|
-
import { z } from "zod";
|
|
6
7
|
import crypto$1 from "crypto";
|
|
7
8
|
import fs from "fs";
|
|
8
9
|
import https from "https";
|
|
9
10
|
import { join } from "path";
|
|
10
|
-
import JSZip from "jszip";
|
|
11
11
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
12
12
|
const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
13
13
|
const Load_StateSchema = z.enum(["LOAD_STATE"]);
|
|
@@ -907,6 +907,23 @@ async function verifyOperationSignature(signature, signer, verifyHandler) {
|
|
|
907
907
|
const expectedMessage = buildOperationSignatureMessage(params);
|
|
908
908
|
return verifyHandler(publicKey, signatureBytes, expectedMessage);
|
|
909
909
|
}
|
|
910
|
+
class InvalidActionInputError extends Error {
|
|
911
|
+
constructor(data) {
|
|
912
|
+
super();
|
|
913
|
+
__publicField(this, "data");
|
|
914
|
+
this.name = "InvalidActionInputError";
|
|
915
|
+
this.data = data;
|
|
916
|
+
this.message = this.message || `Invalid action input: ${JSON.stringify(data, null, 2)}`;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
class InvalidActionInputZodError extends InvalidActionInputError {
|
|
920
|
+
constructor(issues) {
|
|
921
|
+
super(issues);
|
|
922
|
+
__publicField(this, "issues");
|
|
923
|
+
this.issues = issues;
|
|
924
|
+
this.name = "InvalidActionInputZodError";
|
|
925
|
+
}
|
|
926
|
+
}
|
|
910
927
|
const types = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
|
|
911
928
|
Object.freeze(types);
|
|
912
929
|
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
@@ -2005,7 +2022,11 @@ function createAction(type, input, attachments, validator, scope = "global") {
|
|
|
2005
2022
|
try {
|
|
2006
2023
|
validator == null ? void 0 : validator().parse(action.input);
|
|
2007
2024
|
} catch (error) {
|
|
2008
|
-
|
|
2025
|
+
if (error instanceof ZodError) {
|
|
2026
|
+
throw new InvalidActionInputZodError(error.issues);
|
|
2027
|
+
} else {
|
|
2028
|
+
throw new InvalidActionInputError(error);
|
|
2029
|
+
}
|
|
2009
2030
|
}
|
|
2010
2031
|
return action;
|
|
2011
2032
|
}
|
|
@@ -2277,226 +2298,57 @@ const BaseActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
|
|
|
2277
2298
|
setName,
|
|
2278
2299
|
undo
|
|
2279
2300
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2280
|
-
class BaseDocument {
|
|
2281
|
-
/**
|
|
2282
|
-
* Constructs a BaseDocument instance with an initial state.
|
|
2283
|
-
* @param reducer - The reducer function that updates the state.
|
|
2284
|
-
* @param document - The initial state of the document.
|
|
2285
|
-
*/
|
|
2286
|
-
constructor(reducer, document, signalDispatch) {
|
|
2287
|
-
__publicField(this, "_document");
|
|
2288
|
-
__publicField(this, "_reducer");
|
|
2289
|
-
__publicField(this, "_signalDispatch");
|
|
2290
|
-
this._reducer = reducer;
|
|
2291
|
-
this._document = document;
|
|
2292
|
-
this._signalDispatch = signalDispatch;
|
|
2293
|
-
}
|
|
2294
|
-
/**
|
|
2295
|
-
* Dispatches an action to update the state of the document.
|
|
2296
|
-
* @param action - The action to dispatch.
|
|
2297
|
-
* @returns The Document instance.
|
|
2298
|
-
*/
|
|
2299
|
-
dispatch(action, options) {
|
|
2300
|
-
this._document = this._reducer(
|
|
2301
|
-
this._document,
|
|
2302
|
-
action,
|
|
2303
|
-
this._signalDispatch,
|
|
2304
|
-
options
|
|
2305
|
-
);
|
|
2306
|
-
return this;
|
|
2307
|
-
}
|
|
2308
|
-
/**
|
|
2309
|
-
* Saves the state of the document to a file.
|
|
2310
|
-
* @param path - The file path where the state should be saved.
|
|
2311
|
-
* @param extension - The file extension to use when saving the state.
|
|
2312
|
-
* @returns The file path where the state was saved.
|
|
2313
|
-
*/
|
|
2314
|
-
saveToFile(path, extension, name) {
|
|
2315
|
-
return saveToFile(this._document, path, extension, name);
|
|
2316
|
-
}
|
|
2317
|
-
/**
|
|
2318
|
-
* Loads the state of the document from a file.
|
|
2319
|
-
* @param path - The file path where the state is stored.
|
|
2320
|
-
*/
|
|
2321
|
-
async loadFromFile(path) {
|
|
2322
|
-
this._document = await loadFromFile(path, this._reducer);
|
|
2323
|
-
}
|
|
2324
|
-
/**
|
|
2325
|
-
* Loads the state of the document from a file and returns it.
|
|
2326
|
-
* @param path - The file path where the state is stored.
|
|
2327
|
-
* @param reducer - The reducer function that updates the state.
|
|
2328
|
-
* @returns The state of the document.
|
|
2329
|
-
*/
|
|
2330
|
-
static async stateFromFile(path, reducer) {
|
|
2331
|
-
const state = await loadFromFile(path, reducer);
|
|
2332
|
-
return state;
|
|
2333
|
-
}
|
|
2334
|
-
/**
|
|
2335
|
-
* Gets the current state of the document.
|
|
2336
|
-
*/
|
|
2337
|
-
get state() {
|
|
2338
|
-
return readOnly(this._document.state);
|
|
2339
|
-
}
|
|
2340
|
-
/**
|
|
2341
|
-
* Gets the list of operations performed on the document.
|
|
2342
|
-
*/
|
|
2343
|
-
get operations() {
|
|
2344
|
-
return readOnly(this._document.operations);
|
|
2345
|
-
}
|
|
2346
|
-
/**
|
|
2347
|
-
* Gets the name of the document.
|
|
2348
|
-
*/
|
|
2349
|
-
get name() {
|
|
2350
|
-
return this._document.name;
|
|
2351
|
-
}
|
|
2352
|
-
/**
|
|
2353
|
-
* Gets the type of document.
|
|
2354
|
-
*/
|
|
2355
|
-
get documentType() {
|
|
2356
|
-
return this._document.documentType;
|
|
2357
|
-
}
|
|
2358
|
-
/**
|
|
2359
|
-
* Gets the timestamp of the date the document was created.
|
|
2360
|
-
*/
|
|
2361
|
-
get created() {
|
|
2362
|
-
return this._document.created;
|
|
2363
|
-
}
|
|
2364
|
-
/**
|
|
2365
|
-
* Gets the timestamp of the date the document was last modified.
|
|
2366
|
-
*/
|
|
2367
|
-
get lastModified() {
|
|
2368
|
-
return this._document.lastModified;
|
|
2369
|
-
}
|
|
2370
|
-
/**
|
|
2371
|
-
* Gets the global revision number of the document.
|
|
2372
|
-
*/
|
|
2373
|
-
get revision() {
|
|
2374
|
-
return this._document.revision.global;
|
|
2375
|
-
}
|
|
2376
|
-
getRevision(scope) {
|
|
2377
|
-
return this._document.revision[scope];
|
|
2378
|
-
}
|
|
2379
|
-
/**
|
|
2380
|
-
* Gets the initial state of the document.
|
|
2381
|
-
*/
|
|
2382
|
-
get initialState() {
|
|
2383
|
-
return readOnly(this._document.initialState);
|
|
2384
|
-
}
|
|
2385
|
-
/**
|
|
2386
|
-
* Returns the current document as an object
|
|
2387
|
-
*/
|
|
2388
|
-
toDocument() {
|
|
2389
|
-
return readOnly(this._document);
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* Gets the attachment associated with the given key.
|
|
2393
|
-
* @param attachment - The key of the attachment to retrieve.
|
|
2394
|
-
*/
|
|
2395
|
-
getAttachment(attachment) {
|
|
2396
|
-
return this._document.attachments[attachment];
|
|
2397
|
-
}
|
|
2398
|
-
/**
|
|
2399
|
-
* Sets the name of the document.
|
|
2400
|
-
* @param name - The new name of the document.
|
|
2401
|
-
*/
|
|
2402
|
-
setName(name) {
|
|
2403
|
-
this.dispatch(setName(name));
|
|
2404
|
-
return this;
|
|
2405
|
-
}
|
|
2406
|
-
/**
|
|
2407
|
-
* Reverts a number of actions from the document.
|
|
2408
|
-
* @param count - The number of actions to revert.
|
|
2409
|
-
*/
|
|
2410
|
-
undo(count) {
|
|
2411
|
-
this.dispatch(undo(count));
|
|
2412
|
-
return this;
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Reapplies a number of actions to the document.
|
|
2416
|
-
* @param count - The number of actions to reapply.
|
|
2417
|
-
*/
|
|
2418
|
-
redo(count) {
|
|
2419
|
-
this.dispatch(redo(count));
|
|
2420
|
-
return this;
|
|
2421
|
-
}
|
|
2422
|
-
/**
|
|
2423
|
-
* Removes a range of operations from the document.
|
|
2424
|
-
* @param start - The starting index of the range to remove.
|
|
2425
|
-
* @param end - The ending index of the range to remove.
|
|
2426
|
-
*/
|
|
2427
|
-
prune(start, end) {
|
|
2428
|
-
this.dispatch(prune(start, end));
|
|
2429
|
-
return this;
|
|
2430
|
-
}
|
|
2431
|
-
/**
|
|
2432
|
-
* Loads a document state and a set of operations.
|
|
2433
|
-
* @param state - The state to load.
|
|
2434
|
-
* @param operations - The operations to apply to the document.
|
|
2435
|
-
*/
|
|
2436
|
-
loadState(state, operations) {
|
|
2437
|
-
this.dispatch(loadState(state, operations));
|
|
2438
|
-
return this;
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
function applyMixins(derivedCtor, constructors) {
|
|
2442
|
-
constructors.forEach((baseCtor) => {
|
|
2443
|
-
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
2444
|
-
Object.defineProperty(
|
|
2445
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2446
|
-
derivedCtor.prototype,
|
|
2447
|
-
name,
|
|
2448
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
2449
|
-
Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || /* @__PURE__ */ Object.create(null)
|
|
2450
|
-
);
|
|
2451
|
-
});
|
|
2452
|
-
});
|
|
2453
|
-
}
|
|
2454
2301
|
export {
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2302
|
+
buildSignedOperation as A,
|
|
2303
|
+
BaseActions as B,
|
|
2304
|
+
createUnsafeReducer as C,
|
|
2305
|
+
createZip as D,
|
|
2306
|
+
documentHelpers as E,
|
|
2307
|
+
getDocumentLastModified as F,
|
|
2308
|
+
getLocalFile as G,
|
|
2309
|
+
getRemoteFile as H,
|
|
2310
|
+
InvalidActionInputError as I,
|
|
2311
|
+
getUnixTimestamp as J,
|
|
2312
|
+
hashDocument as K,
|
|
2313
|
+
hashKey as L,
|
|
2314
|
+
hex2ab as M,
|
|
2315
|
+
isNoopOperation as N,
|
|
2316
|
+
isSameDocument as O,
|
|
2317
|
+
isUndo as P,
|
|
2318
|
+
isUndoRedo as Q,
|
|
2319
|
+
mapSkippedOperations as R,
|
|
2320
|
+
parseResultingState as S,
|
|
2321
|
+
replayDocument as T,
|
|
2322
|
+
replayOperations as U,
|
|
2323
|
+
sortMappedOperations as V,
|
|
2324
|
+
sortOperations as W,
|
|
2325
|
+
validateOperations as X,
|
|
2326
|
+
verifyOperationSignature as Y,
|
|
2475
2327
|
createExtendedState as a,
|
|
2476
2328
|
createDocument as b,
|
|
2477
2329
|
createReducer as c,
|
|
2478
2330
|
saveToFileHandle as d,
|
|
2479
2331
|
loadFromInput as e,
|
|
2480
2332
|
createAction as f,
|
|
2481
|
-
|
|
2482
|
-
|
|
2333
|
+
baseReducer as g,
|
|
2334
|
+
updateHeader as h,
|
|
2483
2335
|
isBaseAction as i,
|
|
2484
|
-
|
|
2485
|
-
|
|
2336
|
+
setName as j,
|
|
2337
|
+
undo as k,
|
|
2486
2338
|
loadFromFile as l,
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2339
|
+
mutableBaseReducer as m,
|
|
2340
|
+
redo as n,
|
|
2341
|
+
prune as o,
|
|
2342
|
+
processUndoRedo as p,
|
|
2343
|
+
loadState as q,
|
|
2344
|
+
readOnly as r,
|
|
2493
2345
|
saveToFile as s,
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2346
|
+
InvalidActionInputZodError as t,
|
|
2347
|
+
updateDocument as u,
|
|
2348
|
+
ab2hex as v,
|
|
2349
|
+
buildOperationSignature as w,
|
|
2350
|
+
buildOperationSignatureMessage as x,
|
|
2351
|
+
buildOperationSignatureParams as y,
|
|
2352
|
+
zod as z
|
|
2501
2353
|
};
|
|
2502
|
-
//# sourceMappingURL=
|
|
2354
|
+
//# sourceMappingURL=creators-Cb-W0me8.js.map
|