document-model 1.0.26 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +3 -3
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +7 -6
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +4 -4
- package/dist/browser/internal/{index-IVF7gvRz.js → index-99f8b333.js} +2 -2
- package/dist/browser/internal/index-df4df518.js +38 -0
- package/dist/browser/internal/index-e019b5aa.js +1 -0
- package/dist/browser/internal/{index-gREVUw-G.js → index-ff67644b.js} +1 -1
- package/dist/browser/internal/object-4b5800c0.js +1891 -0
- package/dist/browser/internal/object-be1b0c52.js +6 -0
- package/dist/browser/src/document/actions/index.d.ts +3 -3
- package/dist/browser/src/document/object.d.ts +63 -0
- package/dist/browser/src/document/reducer.d.ts +16 -0
- package/dist/browser/src/document/schema/types.d.ts +9 -12
- package/dist/browser/src/document/signal.d.ts +1 -0
- package/dist/browser/src/document/types.d.ts +9 -0
- package/dist/browser/src/document/utils/base.d.ts +7 -4
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/browser/vitest.config.d.ts +1 -1
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +4 -4
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +9 -8
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +5 -5
- package/dist/node/internal/index-2d55ed8c.js +38 -0
- package/dist/node/internal/{index-VzErJ06c.js → index-433d6a9b.js} +1 -1
- package/dist/node/internal/index-78c035e1.js +1 -0
- package/dist/node/internal/{index-AWkBpPdl.js → index-a46dcf07.js} +3 -3
- package/dist/node/internal/object-305e4c59.js +893 -0
- package/dist/node/internal/object-ff6617a2.js +1 -0
- package/dist/node/src/document/actions/index.d.ts +3 -3
- package/dist/node/src/document/object.d.ts +63 -0
- package/dist/node/src/document/reducer.d.ts +16 -0
- package/dist/node/src/document/schema/types.d.ts +9 -12
- package/dist/node/src/document/signal.d.ts +1 -0
- package/dist/node/src/document/types.d.ts +9 -0
- package/dist/node/src/document/utils/base.d.ts +7 -4
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/dist/node/vitest.config.d.ts +1 -1
- package/package.json +1 -1
- package/dist/browser/internal/index-JkTAMqR0.js +0 -36
- package/dist/browser/internal/index-ZuT5Pi3Z.js +0 -1
- package/dist/browser/internal/object-1Edh7roc.js +0 -1844
- package/dist/browser/internal/object-v0zgcnse.js +0 -6
- package/dist/browser/test/document/undo.test.d.ts +0 -1
- package/dist/jest.config.d.ts +0 -8
- package/dist/node/internal/index-8_P5_maf.js +0 -1
- package/dist/node/internal/index-y-8qoZvC.js +0 -36
- package/dist/node/internal/object-6KU11KDZ.js +0 -843
- package/dist/node/internal/object-YfG4E2oW.js +0 -1
- package/dist/node/test/document/redo.test.d.ts +0 -1
- package/dist/node/test/document/undo.test.d.ts +0 -1
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -10
- package/dist/src/document/actions/types.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -510
- package/dist/src/document/reducer.d.ts +0 -32
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -177
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -28
- package/dist/src/document/types.d.ts +0 -210
- package/dist/src/document/utils/base.d.ts +0 -77
- package/dist/src/document/utils/browser.d.ts +0 -10
- package/dist/src/document/utils/file.d.ts +0 -47
- package/dist/src/document/utils/index.d.ts +0 -3
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/src/document-model/custom/utils.d.ts +0 -1
- package/dist/src/document-model/gen/actions.d.ts +0 -15
- package/dist/src/document-model/gen/creators.d.ts +0 -7
- package/dist/src/document-model/gen/document-model.d.ts +0 -2
- package/dist/src/document-model/gen/header/actions.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts +0 -8
- package/dist/src/document-model/gen/header/object.d.ts +0 -12
- package/dist/src/document-model/gen/header/operations.d.ts +0 -10
- package/dist/src/document-model/gen/index.d.ts +0 -5
- package/dist/src/document-model/gen/module/actions.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts +0 -7
- package/dist/src/document-model/gen/module/object.d.ts +0 -11
- package/dist/src/document-model/gen/module/operations.d.ts +0 -9
- package/dist/src/document-model/gen/object.d.ts +0 -28
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/src/document-model/gen/operation/object.d.ts +0 -16
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/src/document-model/gen/reducer.d.ts +0 -5
- package/dist/src/document-model/gen/schema/index.d.ts +0 -2
- package/dist/src/document-model/gen/schema/types.d.ts +0 -453
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/src/document-model/gen/state/actions.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts +0 -8
- package/dist/src/document-model/gen/state/object.d.ts +0 -12
- package/dist/src/document-model/gen/state/operations.d.ts +0 -10
- package/dist/src/document-model/gen/types.d.ts +0 -8
- package/dist/src/document-model/gen/utils.d.ts +0 -6
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/src/document-model/index.d.ts +0 -75
- package/dist/src/index.d.ts +0 -25
- package/dist/test/document/local.test.d.ts +0 -1
- package/dist/test/document/object.test.d.ts +0 -1
- package/dist/test/document/prune.test.d.ts +0 -1
- package/dist/test/document/redo.test.d.ts +0 -1
- package/dist/test/document/reducer.test.d.ts +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -1
- package/dist/test/document/undo.test.d.ts +0 -1
- package/dist/test/document/utils.test.d.ts +0 -1
- package/dist/test/document-model/object.test.d.ts +0 -1
- package/dist/test/document-model/skip-operations.test.d.ts +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -1
- package/dist/test/helpers.d.ts +0 -32
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
- /package/dist/{test → browser/test}/document/undo-redo.test.d.ts +0 -0
- /package/dist/{browser/test/document/redo.test.d.ts → node/test/document/undo-redo.test.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var yt=Object.defineProperty;var zt=(e,t,i)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var E=(e,t,i)=>(zt(e,typeof t!="symbol"?t+"":t,i),i);const St=require("json-stringify-deterministic"),w=require("immer"),o=require("zod"),W=require("jszip"),Ot=require("crypto"),N=require("fs"),_t=require("https"),kt=require("path"),Z=e=>e!=null,Dt=o.z.any().refine(e=>Z(e)),H=o.z.enum(["LOAD_STATE"]),K=o.z.enum(["PRUNE"]),G=o.z.enum(["REDO"]),Q=o.z.enum(["SET_NAME"]),V=o.z.enum(["UNDO"]);function Et(){return o.z.object({__typename:o.z.literal("Action").optional(),type:o.z.string()})}function y(){return o.z.literal("global").or(o.z.literal("local"))}function X(){return o.z.union([Y(),et(),it(),at(),nt()])}function Tt(){return o.z.object({__typename:o.z.literal("DocumentFile").optional(),data:o.z.string(),extension:o.z.string().nullable(),fileName:o.z.string().nullable(),mimeType:o.z.string()})}function Y(){return o.z.object({input:o.z.lazy(()=>q()),type:H,scope:y()})}function q(){return o.z.object({operations:o.z.number(),state:o.z.lazy(()=>tt())})}function tt(){return o.z.object({data:o.z.unknown().nullish(),name:o.z.string()})}function At(){return o.z.object({__typename:o.z.literal("Operation").optional(),hash:o.z.string(),index:o.z.number(),timestamp:o.z.string().datetime(),type:o.z.string()})}function et(){return o.z.object({input:o.z.lazy(()=>I()),type:K,scope:y()})}function I(){return o.z.object({end:o.z.number().nullish(),start:o.z.number().nullish()})}const P=o.z.number;function it(){return o.z.object({input:P(),type:G,scope:y()})}const R=o.z.string;function at(){return o.z.object({input:R(),type:Q,scope:o.z.literal("global")})}function Nt(){return o.z.object({__typename:o.z.literal("SetNameOperation").optional(),hash:o.z.string(),index:o.z.number(),input:o.z.string(),timestamp:o.z.string().datetime(),type:o.z.string()})}const L=o.z.number;function nt(){return o.z.object({input:L(),type:V,scope:y()})}const Ft=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Et,BaseActionSchema:X,DocumentFileSchema:Tt,LoadStateActionInputSchema:q,LoadStateActionSchema:Y,LoadStateActionStateInputSchema:tt,Load_StateSchema:H,OperationSchema:At,OperationScopeSchema:y,PruneActionInputSchema:I,PruneActionSchema:et,PruneSchema:K,RedoActionInputSchema:P,RedoActionSchema:it,RedoSchema:G,SetNameActionInputSchema:R,SetNameActionSchema:at,SetNameOperationSchema:Nt,Set_NameSchema:Q,UndoActionInputSchema:L,UndoActionSchema:nt,UndoSchema:V,definedNonNullAnySchema:Dt,isDefinedNonNullAny:Z},Symbol.toStringTag,{value:"Module"}));function Mt(e,t){return{...e,name:t}}function qt(e,t,i){const{scope:a,input:n}=t,p=e.revision[t.scope],s=Math.min(n,p),c=e.operations[a].slice(0,p-s);return{...j(e.initialState,{...e.operations,[a]:c},i),operations:e.operations,revision:{...e.revision,[a]:e.revision[a]-s}}}function It(e,t,i){const{scope:a,input:n}=t,p=e.operations[a].length-e.revision[a];if(!p)throw new Error("There is no UNDO operation to REDO");const s=n<p?n:p,c=e.operations[a].slice(0,e.revision[a]+s);return{...j(e.initialState,{...e.operations,[a]:c},i),operations:e.operations,revision:{...e.revision,[a]:e.revision[a]+s}}}function Pt(e,t,i){const{scope:a}=t,n=e.operations[a];let{input:{start:p,end:s}}=t;p=p||0,s=s||n.length;const c=n.slice(p,s),l=n.slice(0,p),m=n.slice(s),u=j(e.initialState,{...e.operations,[a]:l.concat(c)},i),{name:d,state:r}=u,_=l.length,k=l.length?l[l.length-1].timestamp:m.length?m[0].timestamp:new Date().toISOString();return j(e.initialState,{...e.operations,[a]:[...l,{...B({name:d,state:r},c.length),timestamp:k,index:_,hash:C({state:r},"global")},...m.map((A,D)=>({...A,index:_+D+1}))]},i)}function Rt(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const ot="SET_NAME",z="UNDO",S="REDO",O="PRUNE",st="LOAD_STATE",pt={"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"]};Object.freeze(pt);var x=function(e,t,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(e):a?a.value:t.get(e)},h,b,f;class Lt{constructor(...t){h.set(this,new Map),b.set(this,new Map),f.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[a,n]of Object.entries(t)){a=a.toLowerCase(),n=n.map(c=>c.toLowerCase()),x(this,f,"f").has(a)||x(this,f,"f").set(a,new Set);const p=x(this,f,"f").get(a);let s=!0;for(let c of n){const l=c.startsWith("*");if(c=l?c.slice(1):c,p==null||p.add(c),s&&x(this,b,"f").set(a,c),s=!1,l)continue;const m=x(this,h,"f").get(c);if(m&&m!=a&&!i)throw new Error(`"${a} -> ${c}" conflicts with "${m} -> ${c}". Pass \`force=true\` to override this definition.`);x(this,h,"f").set(c,a)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),a=i.replace(/^.*\./,"").toLowerCase(),n=i.length<t.length;return!(a.length<i.length-1)&&n?null:x(this,h,"f").get(a)??null}getExtension(t){var i;return typeof t!="string"?null:(t=(i=t==null?void 0:t.split)==null?void 0:i.call(t,";")[0],(t&&x(this,b,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:x(this,f,"f").get(t.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const t of x(this,f,"f").values())Object.freeze(t);return this}_getTestState(){return{types:x(this,h,"f"),extensions:x(this,b,"f")}}}h=new WeakMap,b=new WeakMap,f=new WeakMap;const Ut=new Lt(pt)._freeze();function $t(e,t,i){const a=kt.join(e,t);return N.mkdirSync(e,{recursive:!0}),new Promise((n,p)=>{try{N.writeFile(a,i,{},s=>{s?p(s):n(a)})}catch(s){p(s)}})}function ct(e){return N.readFileSync(e)}function Ct(e){return new Promise((t,i)=>{_t.get(e,a=>{const n=[],p=a.headers["content-type"];a.on("data",s=>{n.push(s)}),a.on("end",()=>{t({buffer:Buffer.concat(n),mimeType:p})})}).on("error",a=>{i(a)})})}const Jt=async e=>ct(e),T=(e,t="sha1")=>Ot.createHash(t).update(e).digest("base64"),U=async e=>{const t=new W,{name:i,revision:a,documentType:n,created:p,lastModified:s}=e,c={name:i,revision:a,documentType:n,created:p,lastModified:s};return t.file("header.json",JSON.stringify(c,null,2)),t.file("state.json",JSON.stringify(e.initialState||{},null,2)),t.file("operations.json",JSON.stringify(e.operations,null,2)),Object.keys(e.attachments).forEach(m=>{const{data:u,...d}=e.attachments[m];t.file(m,u,{base64:!0,createFolders:!0,comment:JSON.stringify(d)})}),t},lt=async(e,t,i,a)=>{const p=await(await U(e)).generateAsync({type:"uint8array",streamFiles:!0}),s=a??e.name,c=`.${i}.zip`;return $t(t,s.endsWith(c)?s:`${s}${c}`,p)},Bt=async(e,t)=>{const a=await(await U(e)).generateAsync({type:"blob"}),n=await t.createWritable();await n.write(a),await n.close()},F=async(e,t)=>{const i=ct(e);return rt(i,t)},rt=async(e,t)=>{const i=new W;return await i.loadAsync(e),Wt(i,t)};async function Wt(e,t){const i=e.file("state.json");if(!i)throw new Error("Initial state not found");const a=await i.async("string"),n=JSON.parse(a),p=e.file("header.json");let s;p&&(s=JSON.parse(await p.async("string")));const c=e.file("operations.json");if(!c)throw new Error("Operations history not found");const l=JSON.parse(await c.async("string"));let m=J(n,l,t,void 0,s);return s&&(m={...m,...s}),m}function mt(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function Zt(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Ct(e),a=mt(e),n=t.toString("base64");return{data:n,hash:T(n),mimeType:i,...a}}async function Ht(e){const t=await Jt(e),i=Ut.getType(e)||"application/octet-stream",a=mt(e),n=t.toString("base64");return{data:n,hash:T(n),mimeType:i,...a}}function Kt(e,t){const i=e.revision[t.scope];return[z,S,O].includes(t.type)?i:i+1}function Gt(e,t){return{...e,revision:{...e.revision,[t.scope]:Kt(e,t)},lastModified:new Date().toISOString()}}function Qt(e,t,i=0){if([z,S,O].includes(t.type))return e;const{scope:a}=t,n=e.operations[a].slice(0,e.revision[a]);return n.push({...t,index:n.length,timestamp:new Date().toISOString(),hash:"",scope:a,skip:i}),{...e,operations:{...e.operations,[a]:n}}}function Vt(e,t,i=0){let a=Qt(e,t,i);return a=Gt(a,t),a}function Xt(e,t,i){switch(X().parse(t),t.type){case ot:return Mt(e,t.input);case z:return qt(e,t,i);case S:return It(e,t,i);case O:return Pt(e,t,i);case st:return Rt(e,t.input.state);default:return e}}function $(e,t,i,a,n={}){const{skip:p=0}=n;let s=e;return M(t)&&(s=Xt(s,t,i)),s=Vt(s,t,p),s=w.produce(s,c=>{const l=i(c.state,t,a);if(l)return w.castDraft({...s,state:l})}),w.produce(s,c=>{if([z,S,O].includes(t.type))return c;const l=t.scope||"global";c.operations[l][c.operations[l].length-1].hash=C(c,l),!M(t)&&t.attachments&&t.attachments.forEach(m=>{const{hash:u,...d}=m;c.attachments[u]={...d}})})}function M(e){return[ot,z,S,O,st].includes(e.type)}function g(e,t,i,a,n="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${e}`);const p={type:e,input:t,scope:n};i&&(p.attachments=i);try{a==null||a().parse(p.input)}catch(s){throw new Error(`Invalid action input: ${s}`)}return p}function ut(e,t=$){return(i,a,n,p)=>t(i,a,e,n,p)}const dt=(e,t)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...e,state:(t==null?void 0:t(e==null?void 0:e.state))??(e==null?void 0:e.state)??{global:{},local:{}}}),xt=(e,t)=>{const i=dt(e,t);return{...i,initialState:i,operations:{global:[],local:[]}}},C=(e,t="global")=>T(St(e.state[t])),Yt=(e,t=1e3)=>{const i=Math.random()*t;return T(`${(e??new Date).toISOString()}${i}`)};function v(e){return w.castImmutable(w.freeze(e,!0))}function ft(e){const t=[...e];let i=0,a=t.length>0?t[t.length-1].index:0;const n=[];for(const p of t.reverse()){if(i>0){const c=a-p.index;i-=c}if(i<0)throw new Error("Invalid operation index, missing operations");const s={ignore:i>0,operation:p};p.skip>0&&(i=i+(p.skip+1)),a=p.index,n.push(s)}return n.reverse()}function te(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function gt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function j(e,t,i,a,n,p=$){const s=ut(i,p);return J(e,t,s,a,n)}function J(e,t,i,a,n){const p=xt(e),s=Object.keys(t).reduce((u,d)=>{const r=d;return{...u,[r]:t[r].slice(0,n==null?void 0:n.revision[r])}},{}),c=Object.keys(s).reduce((u,d)=>{const r=d;return{...u,[r]:ft(s[r])}},{}),l=gt(c).reduce((u,{ignore:d,operation:r})=>d?i(u,jt(r.scope),a,{skip:r.skip}):i(u,r,a),p),m=Object.keys(l.operations).reduce((u,d)=>{const r=d,_=n&&n.revision[r]<t[r].length?t[r].slice(n.revision[r]):[];return{...u,[r]:[...l.operations[r].map((k,A)=>{var D;return{...k,timestamp:((D=t[r][A])==null?void 0:D.timestamp)??k.timestamp}}),..._]}},{global:[],local:[]});return{...l,operations:m}}const ht=e=>g("SET_NAME",e,void 0,R,void 0),bt=(e=1,t="global")=>g("UNDO",e,void 0,L,t),vt=(e=1,t="global")=>g("REDO",e,void 0,P,t),wt=(e,t,i="global")=>g("PRUNE",{start:e,end:t},void 0,I,i),B=(e,t)=>g("LOAD_STATE",{state:e,operations:t},void 0,q),jt=(e="global")=>g("NOOP",{},void 0,void 0,e),ee=Object.freeze(Object.defineProperty({__proto__:null,loadState:B,noop:jt,prune:wt,redo:vt,setName:ht,undo:bt},Symbol.toStringTag,{value:"Module"}));class ie{constructor(t,i,a){E(this,"_document");E(this,"_reducer");E(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=a}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,a){return lt(this._document,t,i,a)}async loadFromFile(t){this._document=await F(t,this._reducer)}static async stateFromFile(t,i){return await F(t,i)}get state(){return v(this._document.state)}get operations(){return v(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(t){return this._document.revision[t]}get initialState(){return v(this._document.initialState)}toDocument(){return v(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(ht(t)),this}undo(t){return this.dispatch(bt(t)),this}redo(t){return this.dispatch(vt(t)),this}prune(t,i){return this.dispatch(wt(t,i)),this}loadState(t,i){return this.dispatch(B(t,i)),this}}function ae(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(a=>{Object.defineProperty(e.prototype,a,Object.getOwnPropertyDescriptor(i.prototype,a)||Object.create(null))})})}exports.BaseActions=ee;exports.BaseDocument=ie;exports.applyMixins=ae;exports.baseReducer=$;exports.createAction=g;exports.createDocument=xt;exports.createExtendedState=dt;exports.createReducer=ut;exports.createZip=U;exports.getLocalFile=Ht;exports.getRemoteFile=Zt;exports.hashDocument=C;exports.hashKey=Yt;exports.isBaseAction=M;exports.loadFromFile=F;exports.loadFromInput=rt;exports.mapSkippedOperations=ft;exports.readOnly=v;exports.replayDocument=J;exports.replayOperations=j;exports.saveToFile=lt;exports.saveToFileHandle=Bt;exports.sortMappedOperations=gt;exports.sortOperations=te;exports.zod=Ft;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ExtendedState, OperationScope } from '../types';
|
|
2
|
-
import { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction, NOOPAction } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Changes the name of the document.
|
|
5
|
-
*
|
|
6
|
-
* @param name - The name to be set in the document.
|
|
7
|
-
* @category Actions
|
|
8
|
-
*/
|
|
9
|
-
export declare const setName: (name: string) => SetNameAction;
|
|
10
|
-
/**
|
|
11
|
-
* Cancels the last `count` operations.
|
|
12
|
-
*
|
|
13
|
-
* @param count - Number of operations to cancel
|
|
14
|
-
* @category Actions
|
|
15
|
-
*/
|
|
16
|
-
export declare const undo: (skip?: number, scope?: OperationScope) => UndoAction;
|
|
17
|
-
/**
|
|
18
|
-
* Cancels the last `count` {@link undo | UNDO} operations.
|
|
19
|
-
*
|
|
20
|
-
* @param count - Number of UNDO operations to cancel
|
|
21
|
-
* @category Actions
|
|
22
|
-
*/
|
|
23
|
-
export declare const redo: (count?: number, scope?: OperationScope) => RedoAction;
|
|
24
|
-
/**
|
|
25
|
-
* Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* Useful to keep operations history smaller. Operations to prune are selected by index,
|
|
29
|
-
* similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
|
|
30
|
-
*
|
|
31
|
-
* @param start - Index of the first operation to prune
|
|
32
|
-
* @param end - Index of the last operation to prune
|
|
33
|
-
* @category Actions
|
|
34
|
-
*/
|
|
35
|
-
export declare const prune: (start?: number | undefined, end?: number | undefined, scope?: OperationScope) => PruneAction;
|
|
36
|
-
/**
|
|
37
|
-
* Replaces the state of the document.
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* This action shouldn't be used directly. It is dispatched by the {@link prune} action.
|
|
41
|
-
*
|
|
42
|
-
* @param state - State to be set in the document.
|
|
43
|
-
* @param operations - Number of operations that were removed from the previous state.
|
|
44
|
-
* @category Actions
|
|
45
|
-
*/
|
|
46
|
-
export declare const loadState: <S, T>(state: Pick<ExtendedState<S, T>, "name" | "state">, operations: number) => LoadStateAction;
|
|
47
|
-
export declare const noop: (scope?: OperationScope) => NOOPAction;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction, UndoRedoProcessResult } from '../types';
|
|
2
|
-
export declare function setNameOperation<T>(document: T, name: string): T;
|
|
3
|
-
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
4
|
-
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
5
|
-
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
6
|
-
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
7
|
-
name: string;
|
|
8
|
-
state?: State<T, L>;
|
|
9
|
-
}): Document<T, A, L>;
|
|
10
|
-
export * from './creators';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseAction } from '../types';
|
|
2
|
-
export declare const SET_NAME = "SET_NAME";
|
|
3
|
-
export declare const UNDO = "UNDO";
|
|
4
|
-
export declare const REDO = "REDO";
|
|
5
|
-
export declare const PRUNE = "PRUNE";
|
|
6
|
-
export declare const LOAD_STATE = "LOAD_STATE";
|
|
7
|
-
export { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction, NOOPAction, } from '../types';
|
|
8
|
-
export type { BaseAction };
|
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import type { BaseAction } from './actions/types';
|
|
2
|
-
import type { SignalDispatch } from './signal';
|
|
3
|
-
import type { Action, AttachmentRef, Document, ExtendedState, OperationScope, Reducer, ReducerOptions } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* This is an abstract class representing a document and provides methods
|
|
6
|
-
* for creating and manipulating documents.
|
|
7
|
-
* @typeparam T - The type of data stored in the document.
|
|
8
|
-
* @typeparam A - The type of action the document can take.
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
11
|
-
protected _document: Document<T, A, L>;
|
|
12
|
-
private _reducer;
|
|
13
|
-
private _signalDispatch?;
|
|
14
|
-
/**
|
|
15
|
-
* Constructs a BaseDocument instance with an initial state.
|
|
16
|
-
* @param reducer - The reducer function that updates the state.
|
|
17
|
-
* @param document - The initial state of the document.
|
|
18
|
-
*/
|
|
19
|
-
constructor(reducer: Reducer<T, A, L>, document: Document<T, A, L>, signalDispatch?: SignalDispatch);
|
|
20
|
-
/**
|
|
21
|
-
* Dispatches an action to update the state of the document.
|
|
22
|
-
* @param action - The action to dispatch.
|
|
23
|
-
* @returns The Document instance.
|
|
24
|
-
*/
|
|
25
|
-
protected dispatch(action: A | BaseAction, options?: ReducerOptions): this;
|
|
26
|
-
/**
|
|
27
|
-
* Saves the state of the document to a file.
|
|
28
|
-
* @param path - The file path where the state should be saved.
|
|
29
|
-
* @param extension - The file extension to use when saving the state.
|
|
30
|
-
* @returns The file path where the state was saved.
|
|
31
|
-
*/
|
|
32
|
-
protected saveToFile(path: string, extension: string, name?: string): Promise<string>;
|
|
33
|
-
/**
|
|
34
|
-
* Loads the state of the document from a file.
|
|
35
|
-
* @param path - The file path where the state is stored.
|
|
36
|
-
*/
|
|
37
|
-
loadFromFile(path: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Loads the state of the document from a file and returns it.
|
|
40
|
-
* @param path - The file path where the state is stored.
|
|
41
|
-
* @param reducer - The reducer function that updates the state.
|
|
42
|
-
* @returns The state of the document.
|
|
43
|
-
*/
|
|
44
|
-
protected static stateFromFile<T, A extends Action, L>(path: string, reducer: Reducer<T, A, L>): Promise<Document<T, A, L>>;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the current state of the document.
|
|
47
|
-
*/
|
|
48
|
-
get state(): {
|
|
49
|
-
readonly global: import("immer").Immutable<T>;
|
|
50
|
-
readonly local: import("immer").Immutable<L>;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Gets the list of operations performed on the document.
|
|
54
|
-
*/
|
|
55
|
-
get operations(): {
|
|
56
|
-
readonly global: readonly ({
|
|
57
|
-
readonly input: {
|
|
58
|
-
readonly operations: number;
|
|
59
|
-
readonly state: {
|
|
60
|
-
readonly data?: unknown;
|
|
61
|
-
readonly name: string;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
readonly type: "LOAD_STATE";
|
|
65
|
-
readonly scope: OperationScope;
|
|
66
|
-
readonly index: number;
|
|
67
|
-
readonly timestamp: string;
|
|
68
|
-
readonly hash: string;
|
|
69
|
-
readonly skip: number;
|
|
70
|
-
} | {
|
|
71
|
-
readonly input: {
|
|
72
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
73
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
74
|
-
};
|
|
75
|
-
readonly type: "PRUNE";
|
|
76
|
-
readonly scope: OperationScope;
|
|
77
|
-
readonly index: number;
|
|
78
|
-
readonly timestamp: string;
|
|
79
|
-
readonly hash: string;
|
|
80
|
-
readonly skip: number;
|
|
81
|
-
} | {
|
|
82
|
-
readonly input: number;
|
|
83
|
-
readonly type: "REDO";
|
|
84
|
-
readonly scope: OperationScope;
|
|
85
|
-
readonly index: number;
|
|
86
|
-
readonly timestamp: string;
|
|
87
|
-
readonly hash: string;
|
|
88
|
-
readonly skip: number;
|
|
89
|
-
} | {
|
|
90
|
-
readonly input: string;
|
|
91
|
-
readonly type: "SET_NAME";
|
|
92
|
-
readonly scope: "global";
|
|
93
|
-
readonly index: number;
|
|
94
|
-
readonly timestamp: string;
|
|
95
|
-
readonly hash: string;
|
|
96
|
-
readonly skip: number;
|
|
97
|
-
} | {
|
|
98
|
-
readonly input: number;
|
|
99
|
-
readonly type: "UNDO";
|
|
100
|
-
readonly scope: OperationScope;
|
|
101
|
-
readonly index: number;
|
|
102
|
-
readonly timestamp: string;
|
|
103
|
-
readonly hash: string;
|
|
104
|
-
readonly skip: number;
|
|
105
|
-
} | {
|
|
106
|
-
readonly input: unknown;
|
|
107
|
-
readonly type: "NOOP";
|
|
108
|
-
readonly scope: OperationScope;
|
|
109
|
-
readonly index: number;
|
|
110
|
-
readonly timestamp: string;
|
|
111
|
-
readonly hash: string;
|
|
112
|
-
readonly skip: number;
|
|
113
|
-
} | import("immer").Immutable<A & {
|
|
114
|
-
index: number;
|
|
115
|
-
timestamp: string;
|
|
116
|
-
hash: string;
|
|
117
|
-
skip: number;
|
|
118
|
-
}>)[];
|
|
119
|
-
readonly local: readonly ({
|
|
120
|
-
readonly input: {
|
|
121
|
-
readonly operations: number;
|
|
122
|
-
readonly state: {
|
|
123
|
-
readonly data?: unknown;
|
|
124
|
-
readonly name: string;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
readonly type: "LOAD_STATE";
|
|
128
|
-
readonly scope: OperationScope;
|
|
129
|
-
readonly index: number;
|
|
130
|
-
readonly timestamp: string;
|
|
131
|
-
readonly hash: string;
|
|
132
|
-
readonly skip: number;
|
|
133
|
-
} | {
|
|
134
|
-
readonly input: {
|
|
135
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
136
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
137
|
-
};
|
|
138
|
-
readonly type: "PRUNE";
|
|
139
|
-
readonly scope: OperationScope;
|
|
140
|
-
readonly index: number;
|
|
141
|
-
readonly timestamp: string;
|
|
142
|
-
readonly hash: string;
|
|
143
|
-
readonly skip: number;
|
|
144
|
-
} | {
|
|
145
|
-
readonly input: number;
|
|
146
|
-
readonly type: "REDO";
|
|
147
|
-
readonly scope: OperationScope;
|
|
148
|
-
readonly index: number;
|
|
149
|
-
readonly timestamp: string;
|
|
150
|
-
readonly hash: string;
|
|
151
|
-
readonly skip: number;
|
|
152
|
-
} | {
|
|
153
|
-
readonly input: string;
|
|
154
|
-
readonly type: "SET_NAME";
|
|
155
|
-
readonly scope: "global";
|
|
156
|
-
readonly index: number;
|
|
157
|
-
readonly timestamp: string;
|
|
158
|
-
readonly hash: string;
|
|
159
|
-
readonly skip: number;
|
|
160
|
-
} | {
|
|
161
|
-
readonly input: number;
|
|
162
|
-
readonly type: "UNDO";
|
|
163
|
-
readonly scope: OperationScope;
|
|
164
|
-
readonly index: number;
|
|
165
|
-
readonly timestamp: string;
|
|
166
|
-
readonly hash: string;
|
|
167
|
-
readonly skip: number;
|
|
168
|
-
} | {
|
|
169
|
-
readonly input: unknown;
|
|
170
|
-
readonly type: "NOOP";
|
|
171
|
-
readonly scope: OperationScope;
|
|
172
|
-
readonly index: number;
|
|
173
|
-
readonly timestamp: string;
|
|
174
|
-
readonly hash: string;
|
|
175
|
-
readonly skip: number;
|
|
176
|
-
} | import("immer").Immutable<A & {
|
|
177
|
-
index: number;
|
|
178
|
-
timestamp: string;
|
|
179
|
-
hash: string;
|
|
180
|
-
skip: number;
|
|
181
|
-
}>)[];
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* Gets the name of the document.
|
|
185
|
-
*/
|
|
186
|
-
get name(): string;
|
|
187
|
-
/**
|
|
188
|
-
* Gets the type of document.
|
|
189
|
-
*/
|
|
190
|
-
get documentType(): string;
|
|
191
|
-
/**
|
|
192
|
-
* Gets the timestamp of the date the document was created.
|
|
193
|
-
*/
|
|
194
|
-
get created(): string;
|
|
195
|
-
/**
|
|
196
|
-
* Gets the timestamp of the date the document was last modified.
|
|
197
|
-
*/
|
|
198
|
-
get lastModified(): string;
|
|
199
|
-
/**
|
|
200
|
-
* Gets the global revision number of the document.
|
|
201
|
-
*/
|
|
202
|
-
get revision(): number;
|
|
203
|
-
getRevision(scope: OperationScope): number;
|
|
204
|
-
/**
|
|
205
|
-
* Gets the initial state of the document.
|
|
206
|
-
*/
|
|
207
|
-
get initialState(): {
|
|
208
|
-
readonly name: string;
|
|
209
|
-
readonly revision: {
|
|
210
|
-
readonly global: number;
|
|
211
|
-
readonly local: number;
|
|
212
|
-
};
|
|
213
|
-
readonly documentType: string;
|
|
214
|
-
readonly created: string;
|
|
215
|
-
readonly lastModified: string;
|
|
216
|
-
readonly state: {
|
|
217
|
-
readonly global: import("immer").Immutable<T>;
|
|
218
|
-
readonly local: import("immer").Immutable<L>;
|
|
219
|
-
};
|
|
220
|
-
readonly attachments: {
|
|
221
|
-
readonly [x: string]: {
|
|
222
|
-
readonly data: string;
|
|
223
|
-
readonly mimeType: string;
|
|
224
|
-
readonly extension?: string | null | undefined;
|
|
225
|
-
readonly fileName?: string | null | undefined;
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* Returns the current document as an object
|
|
231
|
-
*/
|
|
232
|
-
toDocument(): {
|
|
233
|
-
readonly name: string;
|
|
234
|
-
readonly revision: {
|
|
235
|
-
readonly global: number;
|
|
236
|
-
readonly local: number;
|
|
237
|
-
};
|
|
238
|
-
readonly documentType: string;
|
|
239
|
-
readonly created: string;
|
|
240
|
-
readonly lastModified: string;
|
|
241
|
-
readonly state: {
|
|
242
|
-
readonly global: import("immer").Immutable<T>;
|
|
243
|
-
readonly local: import("immer").Immutable<L>;
|
|
244
|
-
};
|
|
245
|
-
readonly attachments: {
|
|
246
|
-
readonly [x: string]: {
|
|
247
|
-
readonly data: string;
|
|
248
|
-
readonly mimeType: string;
|
|
249
|
-
readonly extension?: string | null | undefined;
|
|
250
|
-
readonly fileName?: string | null | undefined;
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
readonly operations: {
|
|
254
|
-
readonly global: readonly ({
|
|
255
|
-
readonly input: {
|
|
256
|
-
readonly operations: number;
|
|
257
|
-
readonly state: {
|
|
258
|
-
readonly data?: unknown;
|
|
259
|
-
readonly name: string;
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
readonly type: "LOAD_STATE";
|
|
263
|
-
readonly scope: OperationScope;
|
|
264
|
-
readonly index: number;
|
|
265
|
-
readonly timestamp: string;
|
|
266
|
-
readonly hash: string;
|
|
267
|
-
readonly skip: number;
|
|
268
|
-
} | {
|
|
269
|
-
readonly input: {
|
|
270
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
271
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
272
|
-
};
|
|
273
|
-
readonly type: "PRUNE";
|
|
274
|
-
readonly scope: OperationScope;
|
|
275
|
-
readonly index: number;
|
|
276
|
-
readonly timestamp: string;
|
|
277
|
-
readonly hash: string;
|
|
278
|
-
readonly skip: number;
|
|
279
|
-
} | {
|
|
280
|
-
readonly input: number;
|
|
281
|
-
readonly type: "REDO";
|
|
282
|
-
readonly scope: OperationScope;
|
|
283
|
-
readonly index: number;
|
|
284
|
-
readonly timestamp: string;
|
|
285
|
-
readonly hash: string;
|
|
286
|
-
readonly skip: number;
|
|
287
|
-
} | {
|
|
288
|
-
readonly input: string;
|
|
289
|
-
readonly type: "SET_NAME";
|
|
290
|
-
readonly scope: "global";
|
|
291
|
-
readonly index: number;
|
|
292
|
-
readonly timestamp: string;
|
|
293
|
-
readonly hash: string;
|
|
294
|
-
readonly skip: number;
|
|
295
|
-
} | {
|
|
296
|
-
readonly input: number;
|
|
297
|
-
readonly type: "UNDO";
|
|
298
|
-
readonly scope: OperationScope;
|
|
299
|
-
readonly index: number;
|
|
300
|
-
readonly timestamp: string;
|
|
301
|
-
readonly hash: string;
|
|
302
|
-
readonly skip: number;
|
|
303
|
-
} | {
|
|
304
|
-
readonly input: unknown;
|
|
305
|
-
readonly type: "NOOP";
|
|
306
|
-
readonly scope: OperationScope;
|
|
307
|
-
readonly index: number;
|
|
308
|
-
readonly timestamp: string;
|
|
309
|
-
readonly hash: string;
|
|
310
|
-
readonly skip: number;
|
|
311
|
-
} | import("immer").Immutable<A & {
|
|
312
|
-
index: number;
|
|
313
|
-
timestamp: string;
|
|
314
|
-
hash: string;
|
|
315
|
-
skip: number;
|
|
316
|
-
}>)[];
|
|
317
|
-
readonly local: readonly ({
|
|
318
|
-
readonly input: {
|
|
319
|
-
readonly operations: number;
|
|
320
|
-
readonly state: {
|
|
321
|
-
readonly data?: unknown;
|
|
322
|
-
readonly name: string;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
readonly type: "LOAD_STATE";
|
|
326
|
-
readonly scope: OperationScope;
|
|
327
|
-
readonly index: number;
|
|
328
|
-
readonly timestamp: string;
|
|
329
|
-
readonly hash: string;
|
|
330
|
-
readonly skip: number;
|
|
331
|
-
} | {
|
|
332
|
-
readonly input: {
|
|
333
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
334
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
335
|
-
};
|
|
336
|
-
readonly type: "PRUNE";
|
|
337
|
-
readonly scope: OperationScope;
|
|
338
|
-
readonly index: number;
|
|
339
|
-
readonly timestamp: string;
|
|
340
|
-
readonly hash: string;
|
|
341
|
-
readonly skip: number;
|
|
342
|
-
} | {
|
|
343
|
-
readonly input: number;
|
|
344
|
-
readonly type: "REDO";
|
|
345
|
-
readonly scope: OperationScope;
|
|
346
|
-
readonly index: number;
|
|
347
|
-
readonly timestamp: string;
|
|
348
|
-
readonly hash: string;
|
|
349
|
-
readonly skip: number;
|
|
350
|
-
} | {
|
|
351
|
-
readonly input: string;
|
|
352
|
-
readonly type: "SET_NAME";
|
|
353
|
-
readonly scope: "global";
|
|
354
|
-
readonly index: number;
|
|
355
|
-
readonly timestamp: string;
|
|
356
|
-
readonly hash: string;
|
|
357
|
-
readonly skip: number;
|
|
358
|
-
} | {
|
|
359
|
-
readonly input: number;
|
|
360
|
-
readonly type: "UNDO";
|
|
361
|
-
readonly scope: OperationScope;
|
|
362
|
-
readonly index: number;
|
|
363
|
-
readonly timestamp: string;
|
|
364
|
-
readonly hash: string;
|
|
365
|
-
readonly skip: number;
|
|
366
|
-
} | {
|
|
367
|
-
readonly input: unknown;
|
|
368
|
-
readonly type: "NOOP";
|
|
369
|
-
readonly scope: OperationScope;
|
|
370
|
-
readonly index: number;
|
|
371
|
-
readonly timestamp: string;
|
|
372
|
-
readonly hash: string;
|
|
373
|
-
readonly skip: number;
|
|
374
|
-
} | import("immer").Immutable<A & {
|
|
375
|
-
index: number;
|
|
376
|
-
timestamp: string;
|
|
377
|
-
hash: string;
|
|
378
|
-
skip: number;
|
|
379
|
-
}>)[];
|
|
380
|
-
};
|
|
381
|
-
readonly initialState: {
|
|
382
|
-
readonly name: string;
|
|
383
|
-
readonly revision: {
|
|
384
|
-
readonly global: number;
|
|
385
|
-
readonly local: number;
|
|
386
|
-
};
|
|
387
|
-
readonly documentType: string;
|
|
388
|
-
readonly created: string;
|
|
389
|
-
readonly lastModified: string;
|
|
390
|
-
readonly state: {
|
|
391
|
-
readonly global: import("immer").Immutable<T>;
|
|
392
|
-
readonly local: import("immer").Immutable<L>;
|
|
393
|
-
};
|
|
394
|
-
readonly attachments: {
|
|
395
|
-
readonly [x: string]: {
|
|
396
|
-
readonly data: string;
|
|
397
|
-
readonly mimeType: string;
|
|
398
|
-
readonly extension?: string | null | undefined;
|
|
399
|
-
readonly fileName?: string | null | undefined;
|
|
400
|
-
};
|
|
401
|
-
};
|
|
402
|
-
};
|
|
403
|
-
readonly clipboard: readonly ({
|
|
404
|
-
readonly input: {
|
|
405
|
-
readonly operations: number;
|
|
406
|
-
readonly state: {
|
|
407
|
-
readonly data?: unknown;
|
|
408
|
-
readonly name: string;
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
readonly type: "LOAD_STATE";
|
|
412
|
-
readonly scope: OperationScope;
|
|
413
|
-
readonly index: number;
|
|
414
|
-
readonly timestamp: string;
|
|
415
|
-
readonly hash: string;
|
|
416
|
-
readonly skip: number;
|
|
417
|
-
} | {
|
|
418
|
-
readonly input: {
|
|
419
|
-
readonly end?: import("./types").InputMaybe<number>;
|
|
420
|
-
readonly start?: import("./types").InputMaybe<number>;
|
|
421
|
-
};
|
|
422
|
-
readonly type: "PRUNE";
|
|
423
|
-
readonly scope: OperationScope;
|
|
424
|
-
readonly index: number;
|
|
425
|
-
readonly timestamp: string;
|
|
426
|
-
readonly hash: string;
|
|
427
|
-
readonly skip: number;
|
|
428
|
-
} | {
|
|
429
|
-
readonly input: number;
|
|
430
|
-
readonly type: "REDO";
|
|
431
|
-
readonly scope: OperationScope;
|
|
432
|
-
readonly index: number;
|
|
433
|
-
readonly timestamp: string;
|
|
434
|
-
readonly hash: string;
|
|
435
|
-
readonly skip: number;
|
|
436
|
-
} | {
|
|
437
|
-
readonly input: string;
|
|
438
|
-
readonly type: "SET_NAME";
|
|
439
|
-
readonly scope: "global";
|
|
440
|
-
readonly index: number;
|
|
441
|
-
readonly timestamp: string;
|
|
442
|
-
readonly hash: string;
|
|
443
|
-
readonly skip: number;
|
|
444
|
-
} | {
|
|
445
|
-
readonly input: number;
|
|
446
|
-
readonly type: "UNDO";
|
|
447
|
-
readonly scope: OperationScope;
|
|
448
|
-
readonly index: number;
|
|
449
|
-
readonly timestamp: string;
|
|
450
|
-
readonly hash: string;
|
|
451
|
-
readonly skip: number;
|
|
452
|
-
} | {
|
|
453
|
-
readonly input: unknown;
|
|
454
|
-
readonly type: "NOOP";
|
|
455
|
-
readonly scope: OperationScope;
|
|
456
|
-
readonly index: number;
|
|
457
|
-
readonly timestamp: string;
|
|
458
|
-
readonly hash: string;
|
|
459
|
-
readonly skip: number;
|
|
460
|
-
} | import("immer").Immutable<A & {
|
|
461
|
-
index: number;
|
|
462
|
-
timestamp: string;
|
|
463
|
-
hash: string;
|
|
464
|
-
skip: number;
|
|
465
|
-
}>)[];
|
|
466
|
-
};
|
|
467
|
-
/**
|
|
468
|
-
* Gets the attachment associated with the given key.
|
|
469
|
-
* @param attachment - The key of the attachment to retrieve.
|
|
470
|
-
*/
|
|
471
|
-
getAttachment(attachment: AttachmentRef): import("./types").Attachment;
|
|
472
|
-
/**
|
|
473
|
-
* Sets the name of the document.
|
|
474
|
-
* @param name - The new name of the document.
|
|
475
|
-
*/
|
|
476
|
-
setName(name: string): this;
|
|
477
|
-
/**
|
|
478
|
-
* Reverts a number of actions from the document.
|
|
479
|
-
* @param count - The number of actions to revert.
|
|
480
|
-
*/
|
|
481
|
-
undo(count: number): this;
|
|
482
|
-
/**
|
|
483
|
-
* Reapplies a number of actions to the document.
|
|
484
|
-
* @param count - The number of actions to reapply.
|
|
485
|
-
*/
|
|
486
|
-
redo(count: number): this;
|
|
487
|
-
/**
|
|
488
|
-
* Removes a range of operations from the document.
|
|
489
|
-
* @param start - The starting index of the range to remove.
|
|
490
|
-
* @param end - The ending index of the range to remove.
|
|
491
|
-
*/
|
|
492
|
-
prune(start?: number | undefined, end?: number | undefined): this;
|
|
493
|
-
/**
|
|
494
|
-
* Loads a document state and a set of operations.
|
|
495
|
-
* @param state - The state to load.
|
|
496
|
-
* @param operations - The operations to apply to the document.
|
|
497
|
-
*/
|
|
498
|
-
loadState(state: Pick<ExtendedState<T, L>, 'state' | 'name'>, operations: number): this;
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Applies multiple mixins to a base class.
|
|
502
|
-
* Used to have separate mixins to group methods by actions.
|
|
503
|
-
*
|
|
504
|
-
* @remarks
|
|
505
|
-
* {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}
|
|
506
|
-
*
|
|
507
|
-
* @param derivedCtor - The class to apply the mixins to.
|
|
508
|
-
* @param constructors - The constructors of the mixins.
|
|
509
|
-
*/
|
|
510
|
-
export declare function applyMixins(derivedCtor: any, constructors: any[]): void;
|