document-model 1.0.25 → 1.0.26
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 +6 -7
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +4 -4
- package/dist/browser/internal/{index-TAPWNyA9.js → index-IVF7gvRz.js} +17 -7
- package/dist/browser/internal/index-JkTAMqR0.js +36 -0
- package/dist/browser/internal/index-ZuT5Pi3Z.js +1 -0
- package/dist/browser/internal/{index-3haD_DrE.js → index-gREVUw-G.js} +1 -1
- package/dist/browser/internal/object-1Edh7roc.js +1844 -0
- package/dist/browser/internal/object-v0zgcnse.js +6 -0
- package/dist/browser/src/document/actions/index.d.ts +3 -3
- package/dist/browser/src/document/object.d.ts +0 -63
- package/dist/browser/src/document/reducer.d.ts +0 -16
- package/dist/browser/src/document/schema/index.d.ts +2 -2
- package/dist/browser/src/document/schema/types.d.ts +0 -1
- package/dist/browser/src/document/types.d.ts +0 -9
- package/dist/browser/src/document/utils/base.d.ts +4 -7
- package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +4 -4
- package/dist/browser/vitest.config.d.ts +2 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +3 -3
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +7 -8
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +4 -4
- package/dist/node/internal/index-8_P5_maf.js +1 -0
- package/dist/node/internal/{index-GpOpKG2W.js → index-AWkBpPdl.js} +17 -7
- package/dist/node/internal/{index-pZl431ni.js → index-VzErJ06c.js} +1 -1
- package/dist/node/internal/index-y-8qoZvC.js +36 -0
- package/dist/node/internal/object-6KU11KDZ.js +843 -0
- package/dist/node/internal/object-YfG4E2oW.js +1 -0
- package/dist/node/src/document/actions/index.d.ts +3 -3
- package/dist/node/src/document/object.d.ts +0 -63
- package/dist/node/src/document/reducer.d.ts +0 -16
- package/dist/node/src/document/schema/index.d.ts +2 -2
- package/dist/node/src/document/schema/types.d.ts +0 -1
- package/dist/node/src/document/types.d.ts +0 -9
- package/dist/node/src/document/utils/base.d.ts +4 -7
- package/dist/node/src/document-model/custom/reducers/versioning.d.ts +4 -4
- package/dist/node/test/document/redo.test.d.ts +1 -0
- package/dist/node/test/document/undo.test.d.ts +1 -0
- package/dist/node/vitest.config.d.ts +2 -0
- package/dist/src/document/actions/creators.d.ts +47 -0
- package/dist/src/document/actions/index.d.ts +10 -0
- package/dist/src/document/actions/types.d.ts +8 -0
- package/dist/src/document/index.d.ts +6 -0
- package/dist/src/document/object.d.ts +510 -0
- package/dist/src/document/reducer.d.ts +32 -0
- package/dist/src/document/schema/index.d.ts +2 -0
- package/dist/src/document/schema/types.d.ts +177 -0
- package/dist/src/document/schema/zod.d.ts +113 -0
- package/dist/src/document/signal.d.ts +28 -0
- package/dist/src/document/types.d.ts +210 -0
- package/dist/src/document/utils/base.d.ts +77 -0
- package/dist/src/document/utils/browser.d.ts +10 -0
- package/dist/src/document/utils/file.d.ts +47 -0
- package/dist/src/document/utils/index.d.ts +3 -0
- package/dist/src/document/utils/node.d.ts +9 -0
- package/dist/src/document-model/custom/reducers/header.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/module.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/operation.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/state.d.ts +2 -0
- package/dist/src/document-model/custom/reducers/versioning.d.ts +7 -0
- package/dist/src/document-model/custom/utils.d.ts +1 -0
- package/dist/src/document-model/gen/actions.d.ts +15 -0
- package/dist/src/document-model/gen/creators.d.ts +7 -0
- package/dist/src/document-model/gen/document-model.d.ts +2 -0
- package/dist/src/document-model/gen/header/actions.d.ts +9 -0
- package/dist/src/document-model/gen/header/creators.d.ts +8 -0
- package/dist/src/document-model/gen/header/object.d.ts +12 -0
- package/dist/src/document-model/gen/header/operations.d.ts +10 -0
- package/dist/src/document-model/gen/index.d.ts +5 -0
- package/dist/src/document-model/gen/module/actions.d.ts +8 -0
- package/dist/src/document-model/gen/module/creators.d.ts +7 -0
- package/dist/src/document-model/gen/module/object.d.ts +11 -0
- package/dist/src/document-model/gen/module/operations.d.ts +9 -0
- package/dist/src/document-model/gen/object.d.ts +28 -0
- package/dist/src/document-model/gen/operation/actions.d.ts +13 -0
- package/dist/src/document-model/gen/operation/creators.d.ts +12 -0
- package/dist/src/document-model/gen/operation/object.d.ts +16 -0
- package/dist/src/document-model/gen/operation/operations.d.ts +14 -0
- package/dist/src/document-model/gen/operation-error/actions.d.ts +10 -0
- package/dist/src/document-model/gen/operation-error/creators.d.ts +9 -0
- package/dist/src/document-model/gen/operation-error/object.d.ts +13 -0
- package/dist/src/document-model/gen/operation-error/operations.d.ts +11 -0
- package/dist/src/document-model/gen/operation-example/actions.d.ts +7 -0
- package/dist/src/document-model/gen/operation-example/creators.d.ts +6 -0
- package/dist/src/document-model/gen/operation-example/object.d.ts +10 -0
- package/dist/src/document-model/gen/operation-example/operations.d.ts +8 -0
- package/dist/src/document-model/gen/reducer.d.ts +5 -0
- package/dist/src/document-model/gen/schema/index.d.ts +2 -0
- package/dist/src/document-model/gen/schema/types.d.ts +453 -0
- package/dist/src/document-model/gen/schema/zod.d.ts +453 -0
- package/dist/src/document-model/gen/state/actions.d.ts +9 -0
- package/dist/src/document-model/gen/state/creators.d.ts +8 -0
- package/dist/src/document-model/gen/state/object.d.ts +12 -0
- package/dist/src/document-model/gen/state/operations.d.ts +10 -0
- package/dist/src/document-model/gen/types.d.ts +8 -0
- package/dist/src/document-model/gen/utils.d.ts +6 -0
- package/dist/src/document-model/gen/versioning/actions.d.ts +8 -0
- package/dist/src/document-model/gen/versioning/creators.d.ts +7 -0
- package/dist/src/document-model/gen/versioning/object.d.ts +11 -0
- package/dist/src/document-model/gen/versioning/operations.d.ts +9 -0
- package/dist/src/document-model/index.d.ts +75 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/test/document/local.test.d.ts +1 -0
- package/dist/test/document/object.test.d.ts +1 -0
- package/dist/test/document/prune.test.d.ts +1 -0
- package/dist/test/document/redo.test.d.ts +1 -0
- package/dist/test/document/reducer.test.d.ts +1 -0
- package/dist/test/document/skip-operations.test.d.ts +1 -0
- package/dist/test/document/undo-redo.test.d.ts +1 -0
- package/dist/test/document/undo.test.d.ts +1 -0
- package/dist/test/document/utils.test.d.ts +1 -0
- package/dist/test/document-model/object.test.d.ts +1 -0
- package/dist/test/document-model/skip-operations.test.d.ts +1 -0
- package/dist/test/document-model/zip.test.d.ts +1 -0
- package/dist/test/helpers.d.ts +32 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +23 -17
- package/dist/browser/internal/index-7bSWIChK.js +0 -38
- package/dist/browser/internal/index-DQNkZhvL.js +0 -1
- package/dist/browser/internal/object-1BuggAcr.js +0 -6
- package/dist/browser/internal/object-jGU_rY7z.js +0 -1895
- package/dist/node/internal/index-FmPDtpIY.js +0 -38
- package/dist/node/internal/index-lh4jt_0f.js +0 -1
- package/dist/node/internal/object-evJm9vYN.js +0 -897
- package/dist/node/internal/object-pZF_UDWv.js +0 -1
- package/dist/node/jest.config.d.ts +0 -8
- /package/dist/browser/test/document/{undo-redo.test.d.ts → redo.test.d.ts} +0 -0
- /package/dist/{node/test/document/undo-redo.test.d.ts → browser/test/document/undo.test.d.ts} +0 -0
- /package/dist/{browser/jest.config.d.ts → jest.config.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction
|
|
1
|
+
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction } from '../types';
|
|
2
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,
|
|
4
|
-
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction,
|
|
3
|
+
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
4
|
+
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
5
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
6
|
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
7
7
|
name: string;
|
|
@@ -400,69 +400,6 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
400
400
|
};
|
|
401
401
|
};
|
|
402
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
403
|
};
|
|
467
404
|
/**
|
|
468
405
|
* Gets the attachment associated with the given key.
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { BaseAction } from './actions/types';
|
|
2
|
-
import { UndoRedoAction } from './schema';
|
|
3
2
|
import { Action, Document, ImmutableStateReducer, ReducerOptions } from './types';
|
|
4
3
|
import { SignalDispatch } from './signal';
|
|
5
|
-
type UndoRedoProcessResult<T, A extends Action, L> = {
|
|
6
|
-
document: Document<T, A, L>;
|
|
7
|
-
action: A | BaseAction;
|
|
8
|
-
skip: number;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Processes an UNDO or REDO action.
|
|
12
|
-
*
|
|
13
|
-
* @param document The current state of the document.
|
|
14
|
-
* @param action The action being applied to the document.
|
|
15
|
-
* @param skip The number of operations to skip before applying the action.
|
|
16
|
-
* @returns The updated document, calculated skip value and transformed action (if apply).
|
|
17
|
-
*/
|
|
18
|
-
export declare function processUndoRedo<T, A extends Action, L>(document: Document<T, A, L>, action: UndoRedoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
19
4
|
/**
|
|
20
5
|
* Base document reducer that wraps a custom document reducer and handles
|
|
21
6
|
* document-level actions such as undo, redo, prune, and set name.
|
|
@@ -29,4 +14,3 @@ export declare function processUndoRedo<T, A extends Action, L>(document: Docume
|
|
|
29
14
|
* @returns The new state of the document.
|
|
30
15
|
*/
|
|
31
16
|
export declare function baseReducer<T, A extends Action, L>(document: Document<T, A, L>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, options?: ReducerOptions): Document<T, A, L>;
|
|
32
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * as z from
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * as z from './zod';
|
|
@@ -64,7 +64,6 @@ export type Action = IAction & {
|
|
|
64
64
|
type: Scalars['String']['output'];
|
|
65
65
|
};
|
|
66
66
|
export type BaseAction = LoadStateAction | PruneAction | RedoAction | SetNameAction | UndoAction | NOOPAction;
|
|
67
|
-
export type UndoRedoAction = RedoAction | UndoAction;
|
|
68
67
|
export type DocumentFile = {
|
|
69
68
|
__typename?: 'DocumentFile';
|
|
70
69
|
data: Scalars['String']['output'];
|
|
@@ -30,8 +30,6 @@ export type ActionWithAttachment<T extends string = string, I = unknown, S exten
|
|
|
30
30
|
export type ReducerOptions = {
|
|
31
31
|
/** The number of operations to skip before this new action is applied */
|
|
32
32
|
skip?: number;
|
|
33
|
-
/** When true the skip count is ignored and the action is applied regardless of the skip count */
|
|
34
|
-
ignoreSkipOperations?: boolean;
|
|
35
33
|
};
|
|
36
34
|
/**
|
|
37
35
|
* A pure function that takes an action and the previous state
|
|
@@ -153,8 +151,6 @@ ExtendedState<GlobalState, LocalState> & {
|
|
|
153
151
|
operations: DocumentOperations<A>;
|
|
154
152
|
/** The initial state of the document, enabling replaying operations. */
|
|
155
153
|
initialState: ExtendedState<GlobalState, LocalState>;
|
|
156
|
-
/** A list of undone operations */
|
|
157
|
-
clipboard: Operation<BaseAction | A>[];
|
|
158
154
|
};
|
|
159
155
|
/**
|
|
160
156
|
* String type representing an attachment in a Document.
|
|
@@ -203,8 +199,3 @@ export type DocumentModelLib = {
|
|
|
203
199
|
documentModels: DocumentModel[];
|
|
204
200
|
editors: Editor[];
|
|
205
201
|
};
|
|
206
|
-
export type UndoRedoProcessResult<T, A extends Action, L> = {
|
|
207
|
-
document: Document<T, A, L>;
|
|
208
|
-
action: A | BaseAction;
|
|
209
|
-
skip: number;
|
|
210
|
-
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction,
|
|
2
|
+
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation } from '../types';
|
|
3
3
|
import { SignalDispatch } from '../signal';
|
|
4
|
-
export declare function isUndoRedo(action: Action): action is UndoRedoAction;
|
|
5
4
|
export declare function isBaseAction(action: Action): action is BaseAction;
|
|
6
5
|
/**
|
|
7
6
|
* Helper function to be used by action creators.
|
|
@@ -65,13 +64,11 @@ export declare function readOnly<T>(value: T): Immutable<T>;
|
|
|
65
64
|
* Maps skipped operations in an array of operations.
|
|
66
65
|
* Skipped operations are operations that are ignored during processing.
|
|
67
66
|
* @param operations - The array of operations to map.
|
|
68
|
-
* @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.
|
|
69
67
|
* @returns An array of mapped operations with ignore flag indicating if the operation is skipped.
|
|
70
68
|
* @throws Error if the operation index is invalid and there are missing operations.
|
|
71
69
|
*/
|
|
72
|
-
export declare function mapSkippedOperations<A extends Action>(operations: Operation<BaseAction | A>[]
|
|
70
|
+
export declare function mapSkippedOperations<A extends Action>(operations: Operation<BaseAction | A>[]): MappedOperation<A>[];
|
|
73
71
|
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
|
|
74
72
|
export declare function sortMappedOperations<A extends Action>(operations: DocumentOperationsIgnoreMap<A>): MappedOperation<A>[];
|
|
75
|
-
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer
|
|
76
|
-
export
|
|
77
|
-
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations): Document<T, A, L>;
|
|
73
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer): Document<T, A, L>;
|
|
74
|
+
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader): Document<T, A, L>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This is a scaffold file meant for customization:
|
|
3
|
-
* - modify it by implementing the reducer functions
|
|
4
|
-
* - delete the file and run the code generator again to have it reset
|
|
5
|
-
*/
|
|
2
|
+
* This is a scaffold file meant for customization:
|
|
3
|
+
* - modify it by implementing the reducer functions
|
|
4
|
+
* - delete the file and run the code generator again to have it reset
|
|
5
|
+
*/
|
|
6
6
|
import { DocumentModelVersioningOperations } from '../../gen/versioning/operations';
|
|
7
7
|
export declare const reducer: DocumentModelVersioningOperations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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';
|
|
@@ -0,0 +1,8 @@
|
|
|
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 };
|