document-model 1.0.24 → 1.0.25
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-Xpydy6AU.js → index-3haD_DrE.js} +1 -1
- package/dist/browser/internal/index-7bSWIChK.js +38 -0
- package/dist/browser/internal/index-DQNkZhvL.js +1 -0
- package/dist/browser/internal/{index-sfNIE5tQ.js → index-TAPWNyA9.js} +2 -2
- package/dist/browser/internal/object-1BuggAcr.js +6 -0
- package/dist/browser/internal/object-jGU_rY7z.js +1895 -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 +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/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 +8 -7
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +4 -4
- package/dist/node/internal/index-FmPDtpIY.js +38 -0
- package/dist/node/internal/{index-sNi-u40H.js → index-GpOpKG2W.js} +2 -2
- package/dist/node/internal/index-lh4jt_0f.js +1 -0
- package/dist/node/internal/{index-PkGY1BML.js → index-pZl431ni.js} +1 -1
- package/dist/node/internal/{object-T2hpMYZ4.js → object-evJm9vYN.js} +475 -411
- package/dist/node/internal/object-pZF_UDWv.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 +1 -0
- package/dist/node/src/document/types.d.ts +9 -0
- package/dist/node/src/document/utils/base.d.ts +7 -4
- package/package.json +1 -1
- package/dist/browser/internal/index-e4O5HJBs.js +0 -1
- package/dist/browser/internal/index-v3lMuqpK.js +0 -36
- package/dist/browser/internal/object-U8CbkcSV.js +0 -6
- package/dist/browser/internal/object-YlWt1S0J.js +0 -1831
- package/dist/jest.config.d.ts +0 -8
- package/dist/node/internal/index-HgkfWSZk.js +0 -36
- package/dist/node/internal/index-aihhQ-ya.js +0 -1
- package/dist/node/internal/object-Nz1iEXFy.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 -447
- package/dist/src/document/reducer.d.ts +0 -16
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -180
- 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 -201
- package/dist/src/document/utils/base.d.ts +0 -74
- 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 -2
- 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/browser/test/document/{redo.test.d.ts → undo-redo.test.d.ts} +0 -0
- /package/dist/{browser/test/document/undo.test.d.ts → node/test/document/undo-redo.test.d.ts} +0 -0
package/dist/jest.config.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { f as e, b as a, a as s, c as t, j as o, k as r, m as n, n as i, o as l, i as c, l as p, e as d, p as u, r as m, q as y, t as O, s as b, d as _, u as g, v as F, B as f, h as D, g as S, w as h, z as j } from "./object-T2hpMYZ4.js";
|
|
2
|
-
const v = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
createAction: e,
|
|
5
|
-
createDocument: a,
|
|
6
|
-
createExtendedState: s,
|
|
7
|
-
createReducer: t,
|
|
8
|
-
createZip: o,
|
|
9
|
-
getLocalFile: r,
|
|
10
|
-
getRemoteFile: n,
|
|
11
|
-
hashDocument: i,
|
|
12
|
-
hashKey: l,
|
|
13
|
-
isBaseAction: c,
|
|
14
|
-
loadFromFile: p,
|
|
15
|
-
loadFromInput: d,
|
|
16
|
-
mapSkippedOperations: u,
|
|
17
|
-
readOnly: m,
|
|
18
|
-
replayDocument: y,
|
|
19
|
-
replayOperations: O,
|
|
20
|
-
saveToFile: b,
|
|
21
|
-
saveToFileHandle: _,
|
|
22
|
-
sortMappedOperations: g,
|
|
23
|
-
sortOperations: F
|
|
24
|
-
}, Symbol.toStringTag, { value: "Module" })), x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
25
|
-
__proto__: null,
|
|
26
|
-
BaseDocument: f,
|
|
27
|
-
actions: D,
|
|
28
|
-
applyMixins: S,
|
|
29
|
-
baseReducer: h,
|
|
30
|
-
utils: v,
|
|
31
|
-
z: j
|
|
32
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
33
|
-
export {
|
|
34
|
-
x as D,
|
|
35
|
-
v as i
|
|
36
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-Nz1iEXFy.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var vt=Object.defineProperty;var bt=(t,e,i)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var O=(t,e,i)=>(bt(t,typeof e!="symbol"?e+"":e,i),i);const yt=require("json-stringify-deterministic"),f=require("immer"),o=require("zod"),$=require("jszip"),jt=require("crypto"),E=require("fs"),wt=require("https"),zt=require("path"),B=t=>t!=null,St=o.z.any().refine(t=>B(t)),C=o.z.enum(["LOAD_STATE"]),Z=o.z.enum(["PRUNE"]),H=o.z.enum(["REDO"]),K=o.z.enum(["SET_NAME"]),W=o.z.enum(["UNDO"]);function Ot(){return o.z.object({__typename:o.z.literal("Action").optional(),type:o.z.string()})}function v(){return o.z.literal("global").or(o.z.literal("local"))}function G(){return o.z.union([Q(),X(),Y(),tt(),et()])}function _t(){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 Q(){return o.z.object({input:o.z.lazy(()=>N()),type:C,scope:v()})}function N(){return o.z.object({operations:o.z.number(),state:o.z.lazy(()=>V())})}function V(){return o.z.object({data:o.z.unknown().nullish(),name:o.z.string()})}function Dt(){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 X(){return o.z.object({input:o.z.lazy(()=>F()),type:Z,scope:v()})}function F(){return o.z.object({end:o.z.number().nullish(),start:o.z.number().nullish()})}const q=o.z.number;function Y(){return o.z.object({input:q(),type:H,scope:v()})}const M=o.z.string;function tt(){return o.z.object({input:M(),type:K,scope:o.z.literal("global")})}function kt(){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 I=o.z.number;function et(){return o.z.object({input:I(),type:W,scope:v()})}const Et=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ot,BaseActionSchema:G,DocumentFileSchema:_t,LoadStateActionInputSchema:N,LoadStateActionSchema:Q,LoadStateActionStateInputSchema:V,Load_StateSchema:C,OperationSchema:Dt,OperationScopeSchema:v,PruneActionInputSchema:F,PruneActionSchema:X,PruneSchema:Z,RedoActionInputSchema:q,RedoActionSchema:Y,RedoSchema:H,SetNameActionInputSchema:M,SetNameActionSchema:tt,SetNameOperationSchema:kt,Set_NameSchema:K,UndoActionInputSchema:I,UndoActionSchema:et,UndoSchema:W,definedNonNullAnySchema:St,isDefinedNonNullAny:B},Symbol.toStringTag,{value:"Module"}));function At(t,e){return{...t,name:e}}function Tt(t,e,i){const{scope:a,input:n}=e,s=t.revision[e.scope],p=Math.min(n,s),c=t.operations[a].slice(0,s-p);return{...h(t.initialState,{...t.operations,[a]:c},i),operations:t.operations,revision:{...t.revision,[a]:t.revision[a]-p}}}function Nt(t,e,i){const{scope:a,input:n}=e,s=t.operations[a].length-t.revision[a];if(!s)throw new Error("There is no UNDO operation to REDO");const p=n<s?n:s,c=t.operations[a].slice(0,t.revision[a]+p);return{...h(t.initialState,{...t.operations,[a]:c},i),operations:t.operations,revision:{...t.revision,[a]:t.revision[a]+p}}}function Ft(t,e,i){const{scope:a}=e,n=t.operations[a];let{input:{start:s,end:p}}=e;s=s||0,p=p||n.length;const c=n.slice(s,p),l=n.slice(0,s),m=n.slice(p),u=h(t.initialState,{...t.operations,[a]:l.concat(c)},i),{name:d,state:r}=u,w=l.length,z=l.length?l[l.length-1].timestamp:m.length?m[0].timestamp:new Date().toISOString();return h(t.initialState,{...t.operations,[a]:[...l,{...J({name:d,state:r},c.length),timestamp:z,index:w,hash:L({state:r},"global")},...m.map((k,S)=>({...k,index:w+S+1}))]},i)}function qt(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const it="SET_NAME",b="UNDO",y="REDO",j="PRUNE",at="LOAD_STATE";function Mt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}_.prototype.define=function(t,e){for(let i in t){let a=t[i].map(function(n){return n.toLowerCase()});i=i.toLowerCase();for(let n=0;n<a.length;n++){const s=a[n];if(s[0]!=="*"){if(!e&&s in this._types)throw new Error('Attempt to change mapping for "'+s+'" extension from "'+this._types[s]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+s+'" from the list of extensions for "'+i+'".');this._types[s]=i}}if(e||!this._extensions[i]){const n=a[0];this._extensions[i]=n[0]!=="*"?n:n.substr(1)}}};_.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),a=e.length<t.length;return(i.length<e.length-1||!a)&&this._types[i]||null};_.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var It=_,Pt={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let Rt=It;var Lt=new Rt(Pt);const Ut=Mt(Lt);function Jt(t,e,i){const a=zt.join(t,e);return E.mkdirSync(t,{recursive:!0}),new Promise((n,s)=>{try{E.writeFile(a,i,{},p=>{p?s(p):n(a)})}catch(p){s(p)}})}function nt(t){return E.readFileSync(t)}function $t(t){return new Promise((e,i)=>{wt.get(t,a=>{const n=[],s=a.headers["content-type"];a.on("data",p=>{n.push(p)}),a.on("end",()=>{e({buffer:Buffer.concat(n),mimeType:s})})}).on("error",a=>{i(a)})})}const Bt=async t=>nt(t),D=(t,e="sha1")=>jt.createHash(e).update(t).digest("base64"),P=async t=>{const e=new $,{name:i,revision:a,documentType:n,created:s,lastModified:p}=t,c={name:i,revision:a,documentType:n,created:s,lastModified:p};return e.file("header.json",JSON.stringify(c,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(m=>{const{data:u,...d}=t.attachments[m];e.file(m,u,{base64:!0,createFolders:!0,comment:JSON.stringify(d)})}),e},ot=async(t,e,i,a)=>{const s=await(await P(t)).generateAsync({type:"uint8array",streamFiles:!0}),p=a??t.name,c=`.${i}.zip`;return Jt(e,p.endsWith(c)?p:`${p}${c}`,s)},Ct=async(t,e)=>{const a=await(await P(t)).generateAsync({type:"blob"}),n=await e.createWritable();await n.write(a),await n.close()},A=async(t,e)=>{const i=nt(t);return st(i,e)},st=async(t,e)=>{const i=new $;return await i.loadAsync(t),Zt(i,e)};async function Zt(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const a=await i.async("string"),n=JSON.parse(a),s=t.file("header.json");let p;s&&(p=JSON.parse(await s.async("string")));const c=t.file("operations.json");if(!c)throw new Error("Operations history not found");const l=JSON.parse(await c.async("string"));let m=U(n,l,e,void 0,p);return p&&(m={...m,...p}),m}function pt(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Ht(t){const{buffer:e,mimeType:i="application/octet-stream"}=await $t(t),a=pt(t),n=e.toString("base64");return{data:n,hash:D(n),mimeType:i,...a}}async function Kt(t){const e=await Bt(t),i=Ut.getType(t)||"application/octet-stream",a=pt(t),n=e.toString("base64");return{data:n,hash:D(n),mimeType:i,...a}}function Wt(t,e){const i=t.revision[e.scope];return[b,y,j].includes(e.type)?i:i+1}function Gt(t,e){return{...t,revision:{...t.revision,[e.scope]:Wt(t,e)},lastModified:new Date().toISOString()}}function Qt(t,e,i=0){if([b,y,j].includes(e.type))return t;const{scope:a}=e,n=t.operations[a].slice(0,t.revision[a]);return n.push({...e,index:n.length,timestamp:new Date().toISOString(),hash:"",scope:a,skip:i}),{...t,operations:{...t.operations,[a]:n}}}function Vt(t,e,i=0){let a=Qt(t,e,i);return a=Gt(a,e),a}function Xt(t,e,i){switch(G().parse(e),e.type){case it:return At(t,e.input);case b:return Tt(t,e,i);case y:return Nt(t,e,i);case j:return Ft(t,e,i);case at:return qt(t,e.input.state);default:return t}}function R(t,e,i,a,n={}){const{skip:s=0}=n;let p=t;return T(e)&&(p=Xt(p,e,i)),p=Vt(p,e,s),p=f.produce(p,c=>{const l=i(c.state,e,a);if(l)return f.castDraft({...p,state:l})}),f.produce(p,c=>{if([b,y,j].includes(e.type))return c;const l=e.scope||"global";c.operations[l][c.operations[l].length-1].hash=L(c,l),!T(e)&&e.attachments&&e.attachments.forEach(m=>{const{hash:u,...d}=m;c.attachments[u]={...d}})})}function T(t){return[it,b,y,j,at].includes(t.type)}function x(t,e,i,a,n="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${t}`);const s={type:t,input:e,scope:n};i&&(s.attachments=i);try{a==null||a().parse(s.input)}catch(p){throw new Error(`Invalid action input: ${p}`)}return s}function ct(t,e=R){return(i,a,n,s)=>e(i,a,t,n,s)}const lt=(t,e)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),rt=(t,e)=>{const i=lt(t,e);return{...i,initialState:i,operations:{global:[],local:[]}}},L=(t,e="global")=>D(yt(t.state[e])),Yt=(t,e=1e3)=>{const i=Math.random()*e;return D(`${(t??new Date).toISOString()}${i}`)};function g(t){return f.castImmutable(f.freeze(t,!0))}function mt(t){const e=[...t];let i=0,a=e.length>0?e[e.length-1].index:0;const n=[];for(const s of e.reverse()){if(i>0){const c=a-s.index;i-=c}if(i<0)throw new Error("Invalid operation index, missing operations");const p={ignore:i>0,operation:s};s.skip>0&&(i=i+(s.skip+1)),a=s.index,n.push(p)}return n.reverse()}function te(t){return Object.values(t).flatMap(e=>e).sort((e,i)=>new Date(e.timestamp).getTime()-new Date(i.timestamp).getTime())}function ut(t){return Object.values(t).flatMap(e=>e).sort((e,i)=>new Date(e.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function h(t,e,i,a,n,s=R){const p=ct(i,s);return U(t,e,p,a,n)}function U(t,e,i,a,n){const s=rt(t),p=Object.keys(e).reduce((u,d)=>{const r=d;return{...u,[r]:e[r].slice(0,n==null?void 0:n.revision[r])}},{}),c=Object.keys(p).reduce((u,d)=>{const r=d;return{...u,[r]:mt(p[r])}},{}),l=ut(c).reduce((u,{ignore:d,operation:r})=>d?i(u,ht(r.scope),a,{skip:r.skip}):i(u,r,a),s),m=Object.keys(l.operations).reduce((u,d)=>{const r=d,w=n&&n.revision[r]<e[r].length?e[r].slice(n.revision[r]):[];return{...u,[r]:[...l.operations[r].map((z,k)=>{var S;return{...z,timestamp:((S=e[r][k])==null?void 0:S.timestamp)??z.timestamp}}),...w]}},{global:[],local:[]});return{...l,operations:m}}const dt=t=>x("SET_NAME",t,void 0,M,void 0),xt=(t=1,e="global")=>x("UNDO",t,void 0,I,e),gt=(t=1,e="global")=>x("REDO",t,void 0,q,e),ft=(t,e,i="global")=>x("PRUNE",{start:t,end:e},void 0,F,i),J=(t,e)=>x("LOAD_STATE",{state:t,operations:e},void 0,N),ht=(t="global")=>x("NOOP",{},void 0,void 0,t),ee=Object.freeze(Object.defineProperty({__proto__:null,loadState:J,noop:ht,prune:ft,redo:gt,setName:dt,undo:xt},Symbol.toStringTag,{value:"Module"}));class ie{constructor(e,i,a){O(this,"_document");O(this,"_reducer");O(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=a}dispatch(e,i){return this._document=this._reducer(this._document,e,this._signalDispatch,i),this}saveToFile(e,i,a){return ot(this._document,e,i,a)}async loadFromFile(e){this._document=await A(e,this._reducer)}static async stateFromFile(e,i){return await A(e,i)}get state(){return g(this._document.state)}get operations(){return g(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(e){return this._document.revision[e]}get initialState(){return g(this._document.initialState)}toDocument(){return g(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(dt(e)),this}undo(e){return this.dispatch(xt(e)),this}redo(e){return this.dispatch(gt(e)),this}prune(e,i){return this.dispatch(ft(e,i)),this}loadState(e,i){return this.dispatch(J(e,i)),this}}function ae(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(a=>{Object.defineProperty(t.prototype,a,Object.getOwnPropertyDescriptor(i.prototype,a)||Object.create(null))})})}exports.BaseActions=ee;exports.BaseDocument=ie;exports.applyMixins=ae;exports.baseReducer=R;exports.createAction=x;exports.createDocument=rt;exports.createExtendedState=lt;exports.createReducer=ct;exports.createZip=P;exports.getLocalFile=Kt;exports.getRemoteFile=Ht;exports.hashDocument=L;exports.hashKey=Yt;exports.isBaseAction=T;exports.loadFromFile=A;exports.loadFromInput=st;exports.mapSkippedOperations=mt;exports.readOnly=g;exports.replayDocument=U;exports.replayOperations=h;exports.saveToFile=ot;exports.saveToFileHandle=Ct;exports.sortMappedOperations=ut;exports.sortOperations=te;exports.zod=Et;
|
|
@@ -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 } 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, 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
|
-
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,447 +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
|
-
};
|
|
404
|
-
/**
|
|
405
|
-
* Gets the attachment associated with the given key.
|
|
406
|
-
* @param attachment - The key of the attachment to retrieve.
|
|
407
|
-
*/
|
|
408
|
-
getAttachment(attachment: AttachmentRef): import("./types").Attachment;
|
|
409
|
-
/**
|
|
410
|
-
* Sets the name of the document.
|
|
411
|
-
* @param name - The new name of the document.
|
|
412
|
-
*/
|
|
413
|
-
setName(name: string): this;
|
|
414
|
-
/**
|
|
415
|
-
* Reverts a number of actions from the document.
|
|
416
|
-
* @param count - The number of actions to revert.
|
|
417
|
-
*/
|
|
418
|
-
undo(count: number): this;
|
|
419
|
-
/**
|
|
420
|
-
* Reapplies a number of actions to the document.
|
|
421
|
-
* @param count - The number of actions to reapply.
|
|
422
|
-
*/
|
|
423
|
-
redo(count: number): this;
|
|
424
|
-
/**
|
|
425
|
-
* Removes a range of operations from the document.
|
|
426
|
-
* @param start - The starting index of the range to remove.
|
|
427
|
-
* @param end - The ending index of the range to remove.
|
|
428
|
-
*/
|
|
429
|
-
prune(start?: number | undefined, end?: number | undefined): this;
|
|
430
|
-
/**
|
|
431
|
-
* Loads a document state and a set of operations.
|
|
432
|
-
* @param state - The state to load.
|
|
433
|
-
* @param operations - The operations to apply to the document.
|
|
434
|
-
*/
|
|
435
|
-
loadState(state: Pick<ExtendedState<T, L>, 'state' | 'name'>, operations: number): this;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Applies multiple mixins to a base class.
|
|
439
|
-
* Used to have separate mixins to group methods by actions.
|
|
440
|
-
*
|
|
441
|
-
* @remarks
|
|
442
|
-
* {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}
|
|
443
|
-
*
|
|
444
|
-
* @param derivedCtor - The class to apply the mixins to.
|
|
445
|
-
* @param constructors - The constructors of the mixins.
|
|
446
|
-
*/
|
|
447
|
-
export declare function applyMixins(derivedCtor: any, constructors: any[]): void;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseAction } from './actions/types';
|
|
2
|
-
import { Action, Document, ImmutableStateReducer, ReducerOptions } from './types';
|
|
3
|
-
import { SignalDispatch } from './signal';
|
|
4
|
-
/**
|
|
5
|
-
* Base document reducer that wraps a custom document reducer and handles
|
|
6
|
-
* document-level actions such as undo, redo, prune, and set name.
|
|
7
|
-
*
|
|
8
|
-
* @template T - The type of the state of the custom reducer.
|
|
9
|
-
* @template A - The type of the actions of the custom reducer.
|
|
10
|
-
* @param state - The current state of the document.
|
|
11
|
-
* @param action - The action object to apply to the state.
|
|
12
|
-
* @param customReducer - The custom reducer that implements the application logic
|
|
13
|
-
* specific to the document's state.
|
|
14
|
-
* @returns The new state of the document.
|
|
15
|
-
*/
|
|
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>;
|