document-model 1.0.44 → 1.0.46
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 → cjs/document-model.js} +1 -1
- package/dist/browser/{document.cjs → cjs/document.js} +1 -1
- package/dist/browser/{index.cjs → cjs/index.js} +1 -1
- package/dist/browser/{internal/index-eSGNXD4L.js → cjs/internal/index-CPJM383s.js} +1 -1
- package/dist/browser/{internal/index-CvQOfeml.js → cjs/internal/index-REU04m7f.js} +1 -1
- package/dist/browser/{internal/object-NkahWZEb.js → cjs/internal/object-DkoS83BB.js} +3 -3
- package/dist/browser/cjs/package.json +1 -0
- package/dist/browser/{document-model.js → es/document-model.js} +2 -2
- package/dist/browser/{document.js → es/document.js} +2 -2
- package/dist/browser/{index.js → es/index.js} +3 -3
- package/dist/browser/{internal/index-CJWLwwNi.js → es/internal/index-BzIVYv7p.js} +1 -1
- package/dist/browser/{internal/index-QMhrjNyi.js → es/internal/index-tEH7iGUj.js} +1 -1
- package/dist/browser/{internal/object-ChusgY57.js → es/internal/object-Dev4WFVH.js} +16 -14
- package/dist/browser/es/package.json +1 -0
- package/dist/node/{document-model.cjs → cjs/document-model.js} +1 -1
- package/dist/node/{document.cjs → cjs/document.js} +1 -1
- package/dist/node/{index.cjs → cjs/index.js} +1 -1
- package/dist/node/{internal/index-CkYTa7KK.js → cjs/internal/index-BX95XaQ_.js} +1 -1
- package/dist/node/{internal/index-CKwU8URS.js → cjs/internal/index-CRjFLQNR.js} +1 -1
- package/dist/node/cjs/internal/object-CGt7Qacd.js +20 -0
- package/dist/node/cjs/package.json +1 -0
- package/dist/node/{document-model.js → es/document-model.js} +2 -2
- package/dist/node/{document.js → es/document.js} +2 -2
- package/dist/node/{index.js → es/index.js} +3 -3
- package/dist/node/{internal/index-CAadnKaJ.js → es/internal/index-BzNCX_-9.js} +1 -1
- package/dist/node/{internal/index-DphjSNet.js → es/internal/index-DpH4_29z.js} +1 -1
- package/dist/node/{internal/object-BsCssWq4.js → es/internal/object-BFkXGmt6.js} +16 -14
- package/dist/node/es/package.json +1 -0
- package/package.json +14 -13
- package/dist/browser/test/document/event-vs-command.test.d.ts +0 -1
- package/dist/browser/test/document/local.test.d.ts +0 -1
- package/dist/browser/test/document/object.test.d.ts +0 -1
- package/dist/browser/test/document/prune.test.d.ts +0 -1
- package/dist/browser/test/document/reducer.test.d.ts +0 -1
- package/dist/browser/test/document/skip-operations.test.d.ts +0 -1
- package/dist/browser/test/document/undo-redo.test.d.ts +0 -1
- package/dist/browser/test/document/utils.test.d.ts +0 -1
- package/dist/browser/test/document-model/object.test.d.ts +0 -1
- package/dist/browser/test/document-model/skip-operations.test.d.ts +0 -1
- package/dist/browser/test/document-model/validation.test.d.ts +0 -1
- package/dist/browser/test/document-model/zip.test.d.ts +0 -1
- package/dist/browser/test/helpers.d.ts +0 -34
- package/dist/node/internal/object-BLNJYMtQ.js +0 -20
- package/dist/node/test/document/event-vs-command.test.d.ts +0 -1
- package/dist/node/test/document/local.test.d.ts +0 -1
- package/dist/node/test/document/object.test.d.ts +0 -1
- package/dist/node/test/document/prune.test.d.ts +0 -1
- package/dist/node/test/document/reducer.test.d.ts +0 -1
- package/dist/node/test/document/skip-operations.test.d.ts +0 -1
- package/dist/node/test/document/undo-redo.test.d.ts +0 -1
- package/dist/node/test/document/utils.test.d.ts +0 -1
- package/dist/node/test/document-model/object.test.d.ts +0 -1
- package/dist/node/test/document-model/skip-operations.test.d.ts +0 -1
- package/dist/node/test/document-model/validation.test.d.ts +0 -1
- package/dist/node/test/document-model/zip.test.d.ts +0 -1
- package/dist/node/test/helpers.d.ts +0 -34
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -14
- package/dist/src/document/actions/types.d.ts +0 -15
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -1140
- package/dist/src/document/reducer.d.ts +0 -32
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -176
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -29
- package/dist/src/document/types.d.ts +0 -245
- package/dist/src/document/utils/base.d.ts +0 -80
- 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 -4
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document/utils/validation.d.ts +0 -2
- 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 -7
- 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 -80
- package/dist/src/index.d.ts +0 -25
- package/dist/test/document/event-vs-command.test.d.ts +0 -1
- 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/reducer.test.d.ts +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -1
- package/dist/test/document/undo-redo.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/validation.test.d.ts +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -1
- package/dist/test/helpers.d.ts +0 -34
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-CGt7Qacd.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
|
|
2
2
|
"id": "",
|
|
3
3
|
"name": "",
|
|
4
4
|
"extension": "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./object-
|
|
1
|
+
"use strict";const e=require("./object-CGt7Qacd.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,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,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,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,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";var se=Object.defineProperty;var ae=(e,t,i)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ot=(e,t,i)=>(ae(e,typeof t!="symbol"?t+"":t,i),i);const U=require("immer"),u=require("zod"),pe=require("crypto"),lt=require("fs"),ce=require("https"),le=require("path"),zt=require("jszip"),Et=e=>e!=null,me=u.z.any().refine(e=>Et(e)),vt=u.z.enum(["LOAD_STATE"]),Tt=u.z.enum(["PRUNE"]),kt=u.z.enum(["REDO"]),_t=u.z.enum(["SET_NAME"]),Dt=u.z.enum(["UNDO"]);function ue(){return u.z.object({__typename:u.z.literal("Action").optional(),type:u.z.string()})}function X(){return u.z.literal("global").or(u.z.literal("local"))}function At(){return u.z.union([Nt(),Pt(),Ft(),It(),Rt()])}function fe(){return u.z.object({__typename:u.z.literal("DocumentFile").optional(),data:u.z.string(),extension:u.z.string().nullable(),fileName:u.z.string().nullable(),mimeType:u.z.string()})}function Nt(){return u.z.object({input:u.z.lazy(()=>gt()),type:vt,scope:X()})}function gt(){return u.z.object({operations:u.z.number(),state:u.z.lazy(()=>Mt())})}function Mt(){return u.z.object({data:u.z.unknown().nullish(),name:u.z.string()})}function de(){return u.z.object({__typename:u.z.literal("Operation").optional(),hash:u.z.string(),index:u.z.number(),timestamp:u.z.string().datetime(),type:u.z.string()})}function Pt(){return u.z.object({input:u.z.lazy(()=>ht()),type:Tt,scope:X()})}function ht(){return u.z.object({end:u.z.number().nullish(),start:u.z.number().nullish()})}const xt=u.z.number;function Ft(){return u.z.object({input:xt(),type:kt,scope:X()})}const yt=u.z.string;function It(){return u.z.object({input:yt(),type:_t,scope:u.z.literal("global")})}function ge(){return u.z.object({__typename:u.z.literal("SetNameOperation").optional(),hash:u.z.string(),index:u.z.number(),input:u.z.string(),timestamp:u.z.string().datetime(),type:u.z.string()})}const bt=u.z.number;function Rt(){return u.z.object({input:bt(),type:Dt,scope:X()})}const he=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:ue,BaseActionSchema:At,DocumentFileSchema:fe,LoadStateActionInputSchema:gt,LoadStateActionSchema:Nt,LoadStateActionStateInputSchema:Mt,Load_StateSchema:vt,OperationSchema:de,OperationScopeSchema:X,PruneActionInputSchema:ht,PruneActionSchema:Pt,PruneSchema:Tt,RedoActionInputSchema:xt,RedoActionSchema:Ft,RedoSchema:kt,SetNameActionInputSchema:yt,SetNameActionSchema:It,SetNameOperationSchema:ge,Set_NameSchema:_t,UndoActionInputSchema:bt,UndoActionSchema:Rt,UndoSchema:Dt,definedNonNullAnySchema:me,isDefinedNonNullAny:Et},Symbol.toStringTag,{value:"Module"}));function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mt={exports:{}};(function(e,t){const{hasOwnProperty:i}=Object.prototype,n=_();n.configure=_,n.stringify=n,n.default=n,t.stringify=n,t.configure=_,e.exports=n;const a=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function p(s){return s.length<5e3&&!a.test(s)?`"${s}"`:JSON.stringify(s)}function r(s){if(s.length>200)return s.sort();for(let m=1;m<s.length;m++){const y=s[m];let A=m;for(;A!==0&&s[A-1]>y;)s[A]=s[A-1],A--;s[A]=y}return s}const l=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(s){return l.call(s)!==void 0&&s.length!==0}function x(s,m,y){s.length<y&&(y=s.length);const A=m===","?"":" ";let V=`"0":${A}${s[0]}`;for(let R=1;R<y;R++)V+=`${m}"${R}":${A}${s[R]}`;return V}function j(s){if(i.call(s,"circularValue")){const m=s.circularValue;if(typeof m=="string")return`"${m}"`;if(m==null)return m;if(m===Error||m===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function z(s,m){let y;if(i.call(s,m)&&(y=s[m],typeof y!="boolean"))throw new TypeError(`The "${m}" argument must be of type boolean`);return y===void 0?!0:y}function g(s,m){let y;if(i.call(s,m)){if(y=s[m],typeof y!="number")throw new TypeError(`The "${m}" argument must be of type number`);if(!Number.isInteger(y))throw new TypeError(`The "${m}" argument must be an integer`);if(y<1)throw new RangeError(`The "${m}" argument must be >= 1`)}return y===void 0?1/0:y}function S(s){return s===1?"1 item":`${s} items`}function I(s){const m=new Set;for(const y of s)(typeof y=="string"||typeof y=="number")&&m.add(String(y));return m}function k(s){if(i.call(s,"strict")){const m=s.strict;if(typeof m!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(m)return y=>{let A=`Object can not safely be stringified. Received type ${typeof y}`;throw typeof y!="function"&&(A+=` (${y.toString()})`),new Error(A)}}}function _(s){s={...s};const m=k(s);m&&(s.bigint===void 0&&(s.bigint=!1),"circularValue"in s||(s.circularValue=Error));const y=j(s),A=z(s,"bigint"),V=z(s,"deterministic"),R=g(s,"maximumDepth"),v=g(s,"maximumBreadth");function et(M,o,f,b,h,O){let d=o[M];switch(typeof d=="object"&&d!==null&&typeof d.toJSON=="function"&&(d=d.toJSON(M)),d=b.call(o,M,d),typeof d){case"string":return p(d);case"object":{if(d===null)return"null";if(f.indexOf(d)!==-1)return y;let w="",E=",";const T=O;if(Array.isArray(d)){if(d.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(d),h!==""&&(O+=h,w+=`
|
|
2
|
+
${O}`,E=`,
|
|
3
|
+
${O}`);const F=Math.min(d.length,v);let J=0;for(;J<F-1;J++){const nt=et(String(J),d,f,b,h,O);w+=nt!==void 0?nt:"null",w+=E}const C=et(String(J),d,f,b,h,O);if(w+=C!==void 0?C:"null",d.length-1>v){const nt=d.length-v-1;w+=`${E}"... ${S(nt)} not stringified"`}return h!==""&&(w+=`
|
|
4
|
+
${T}`),f.pop(),`[${w}]`}let D=Object.keys(d);const N=D.length;if(N===0)return"{}";if(R<f.length+1)return'"[Object]"';let $="",P="";h!==""&&(O+=h,E=`,
|
|
5
|
+
${O}`,$=" ");const L=Math.min(N,v);V&&!c(d)&&(D=r(D)),f.push(d);for(let F=0;F<L;F++){const J=D[F],C=et(J,d,f,b,h,O);C!==void 0&&(w+=`${P}${p(J)}:${$}${C}`,P=E)}if(N>v){const F=N-v;w+=`${P}"...":${$}"${S(F)} not stringified"`,P=E}return h!==""&&P.length>1&&(w=`
|
|
6
|
+
${O}${w}
|
|
7
|
+
${T}`),f.pop(),`{${w}}`}case"number":return isFinite(d)?String(d):m?m(d):"null";case"boolean":return d===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(d);default:return m?m(d):void 0}}function it(M,o,f,b,h,O){switch(typeof o=="object"&&o!==null&&typeof o.toJSON=="function"&&(o=o.toJSON(M)),typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(f.indexOf(o)!==-1)return y;const d=O;let w="",E=",";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h!==""&&(O+=h,w+=`
|
|
8
|
+
${O}`,E=`,
|
|
9
|
+
${O}`);const N=Math.min(o.length,v);let $=0;for(;$<N-1;$++){const L=it(String($),o[$],f,b,h,O);w+=L!==void 0?L:"null",w+=E}const P=it(String($),o[$],f,b,h,O);if(w+=P!==void 0?P:"null",o.length-1>v){const L=o.length-v-1;w+=`${E}"... ${S(L)} not stringified"`}return h!==""&&(w+=`
|
|
10
|
+
${d}`),f.pop(),`[${w}]`}f.push(o);let T="";h!==""&&(O+=h,E=`,
|
|
11
|
+
${O}`,T=" ");let D="";for(const N of b){const $=it(N,o[N],f,b,h,O);$!==void 0&&(w+=`${D}${p(N)}:${T}${$}`,D=E)}return h!==""&&D.length>1&&(w=`
|
|
12
|
+
${O}${w}
|
|
13
|
+
${d}`),f.pop(),`{${w}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function W(M,o,f,b,h){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return W(M,o,f,b,h);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;const O=h;if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h+=b;let $=`
|
|
14
|
+
${h}`;const P=`,
|
|
15
|
+
${h}`,L=Math.min(o.length,v);let F=0;for(;F<L-1;F++){const C=W(String(F),o[F],f,b,h);$+=C!==void 0?C:"null",$+=P}const J=W(String(F),o[F],f,b,h);if($+=J!==void 0?J:"null",o.length-1>v){const C=o.length-v-1;$+=`${P}"... ${S(C)} not stringified"`}return $+=`
|
|
16
|
+
${O}`,f.pop(),`[${$}]`}let d=Object.keys(o);const w=d.length;if(w===0)return"{}";if(R<f.length+1)return'"[Object]"';h+=b;const E=`,
|
|
17
|
+
${h}`;let T="",D="",N=Math.min(w,v);c(o)&&(T+=x(o,E,v),d=d.slice(o.length),N-=o.length,D=E),V&&(d=r(d)),f.push(o);for(let $=0;$<N;$++){const P=d[$],L=W(P,o[P],f,b,h);L!==void 0&&(T+=`${D}${p(P)}: ${L}`,D=E)}if(w>v){const $=w-v;T+=`${D}"...": "${S($)} not stringified"`,D=E}return D!==""&&(T=`
|
|
18
|
+
${h}${T}
|
|
19
|
+
${O}`),f.pop(),`{${T}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function Z(M,o,f){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return Z(M,o,f);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;let b="";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o);const E=Math.min(o.length,v);let T=0;for(;T<E-1;T++){const N=Z(String(T),o[T],f);b+=N!==void 0?N:"null",b+=","}const D=Z(String(T),o[T],f);if(b+=D!==void 0?D:"null",o.length-1>v){const N=o.length-v-1;b+=`,"... ${S(N)} not stringified"`}return f.pop(),`[${b}]`}let h=Object.keys(o);const O=h.length;if(O===0)return"{}";if(R<f.length+1)return'"[Object]"';let d="",w=Math.min(O,v);c(o)&&(b+=x(o,",",v),h=h.slice(o.length),w-=o.length,d=","),V&&(h=r(h)),f.push(o);for(let E=0;E<w;E++){const T=h[E],D=Z(T,o[T],f);D!==void 0&&(b+=`${d}${p(T)}:${D}`,d=",")}if(O>v){const E=O-v;b+=`${d}"...":"${S(E)} not stringified"`}return f.pop(),`{${b}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function re(M,o,f){if(arguments.length>1){let b="";if(typeof f=="number"?b=" ".repeat(Math.min(f,10)):typeof f=="string"&&(b=f.slice(0,10)),o!=null){if(typeof o=="function")return et("",{"":M},[],o,b,"");if(Array.isArray(o))return it("",M,[],I(o),b,"")}if(b.length!==0)return W("",M,[],b,"")}return Z("",M,[])}return re}})(mt,mt.exports);var ye=mt.exports;const rt=xe(ye);rt.configure;function be(e,t){return{...e,name:t}}function we(e,t,i){const n={skip:i,document:e},{scope:a}=t;return!a||t.skip===void 0?n:U.produce(n,p=>{const[r]=p.document.operations[a].slice(-1);t.skip&&t.skip>0&&(p.skip=t.skip),r.type==="NOOP"&&t.index===r.index&&p.skip>r.skip&&p.document.operations[a].pop()})}function je(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.document.operations[n].length<1)throw new Error(`Cannot undo: no operations in history for scope "${n}"`);if(a<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(r.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[l]=r.document.operations[n].slice(-1),c=l.type==="NOOP"&&l.skip>0;if(r.skip+=a,c){r.skip+=l.skip;const g=r.document.operations[n][r.document.operations[n].length-2];g&&l.index-g.index===1&&r.document.operations[n].pop()}if(r.document.operations[n].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const x=r.document.operations[n].length-1;let j=a,z=c?x-l.skip:x;for(;j>0&&z>=0;){const g=r.document.operations[n][z];if(!g){j--,z--;continue}g.type==="NOOP"&&g.skip>0?(z=z-(g.skip+1),r.skip+=g.skip+1):(r.document.clipboard.push({...g}),j--,z--)}r.action=St(n)})}function Oe(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(a>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(a<1)throw new Error("Invalid REDO action: invalid redo input value");if(r.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const l=r.document.clipboard.findLastIndex(x=>x.scope===n);if(l<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${n}"`);const c=r.document.clipboard.splice(l,1)[0];r.action=U.castDraft({type:c.type,scope:c.scope,input:c.input})})}function Se(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:p,end:r}}=t;p=p||0,r=r||a.length;const l=a.slice(p,r),c=a.slice(0,p),x=a.slice(r),j=st(e.initialState,{...e.operations,[n]:c.concat(l)},i),{name:z,state:g}=j,S=c.length,I=c.length?c[c.length-1].timestamp:x.length?x[0].timestamp:new Date().toISOString();return st(e.initialState,{...e.operations,[n]:[...c,{...Ot({name:z,state:g},l.length),timestamp:I,index:S,hash:ct({state:g},"global")},...x.map((k,_)=>({...k,index:S+_+1}))]},i)}function $e(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const qt="SET_NAME",Y="UNDO",tt="REDO",at="PRUNE",Lt="LOAD_STATE",ze="NOOP";function Ee(e,t){let i;return"index"in t?i={...t}:i=e.operations[t.scope].slice(-1)[0],((i==null?void 0:i.index)??-1)+1}function ve(e,t){return{...e,revision:{...e.revision,[t.scope]:Ee(e,t)},lastModified:new Date().toISOString()}}function Te(e,t,i=0){if([Y,tt,at].includes(t.type))return e;const{scope:n}=t,a=e.operations[n].slice(0,e.revision[n]),p=[...a].pop();let r=((p==null?void 0:p.index)??-1)+1;if("index"in t){if(t.index>r+i)throw new Error(`Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`);r=t.index}return a.push({...t,index:r,timestamp:new Date().toISOString(),hash:"",scope:n,skip:i}),{...e,operations:{...e.operations,[n]:a}}}function ke(e,t,i=0){let n=Te(e,t,i);return n=ve(n,t),n}function _e(e,t,i){switch(At().parse(t),t.type){case qt:return be(e,t.input);case at:return Se(e,t,i);case Lt:return $e(e,t.input.state);default:return e}}function Jt(e,t,i){switch(t.type){case Y:return je(e,t,i);case tt:return Oe(e,t,i);default:return{document:e,action:t,skip:i}}}function wt(e,t,i,n,a={}){const{skip:p,ignoreSkipOperations:r=!1,reuseHash:l=!1}=a;let c={...t},x=p||0,j=e,z=[...e.clipboard];if(Ut(c)){const{document:g,skip:S}=we(j,c,x);x=S,j=g}if(ut(c)){const{skip:g,action:S,document:I}=Jt(e,c,x);c=S,x=g,j=I,z=[...j.clipboard]}if(ft(c)&&(j=_e(j,c,i)),x>0&&!r){let g=x;"index"in c&&(g=Wt(j.operations[c.scope],c.index,x)),j=st(j.initialState,j.operations,i,void 0,void 0,void 0,{[c.scope]:g})}return j=ke(j,c,x),j=U.produce(j,g=>{const S=i(g.state,c,n),I=ut(t)?[...z]:[];if(S)return U.castDraft({...j,clipboard:[...I],state:S});g.clipboard=U.castDraft([...I])}),U.produce(j,g=>{if([Y,tt,at].includes(c.type))return g;const S=c.scope||"global",I=l&&Object.prototype.hasOwnProperty.call(c,"hash")?c.hash:ct(g,S);g.operations[S][g.operations[S].length-1].hash=I,!ft(c)&&c.attachments&&c.attachments.forEach(k=>{const{hash:_,...s}=k;g.attachments[_]={...s}})})}function De(e,t,i){const n=le.join(e,t);return lt.mkdirSync(e,{recursive:!0}),new Promise((a,p)=>{try{lt.writeFile(n,i,{},r=>{r?p(r):a(n)})}catch(r){p(r)}})}function Ct(e){return lt.readFileSync(e)}function Ae(e){return new Promise((t,i)=>{ce.get(e,n=>{const a=[],p=n.headers["content-type"];n.on("data",r=>{a.push(r)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:p})})}).on("error",n=>{i(n)})})}const Ne=async e=>Ct(e),pt=(e,t="sha1")=>pe.createHash(t).update(e).digest("base64");function Ut(e){return e.type===ze&&e.skip!==void 0&&e.skip>0&&e.hash!==void 0}function ut(e){return[Y,tt].includes(e.type)}function ft(e){return[qt,Y,tt,at,Lt].includes(e.type)}function B(e,t,i,n,a="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${JSON.stringify(e)}`);const p={type:e,input:t,scope:a};i&&(p.attachments=i);try{n==null||n().parse(p.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return p}function Vt(e,t=wt){return(i,n,a,p)=>t(i,n,e,a,p)}const Kt=(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:{}}}),Bt=(e,t)=>{const i=Kt(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},ct=(e,t="global")=>pt(rt(e.state[t]||"")),Me=(e,t=1e3)=>{const i=Math.random()*t;return pt(`${(e??new Date).toISOString()}${i}`)};function G(e){return U.castImmutable(U.freeze(e,!0))}function Ht(e,t){const i=[...e];let n=t||0,a=i.length>0?i[i.length-1].index:0;const p=[];for(const r of i.reverse()){if(n>0){const x=a-r.index;n-=x}if(n<0)throw new Error("Invalid operation index, missing operations");const l={ignore:n>0,operation:r},c=r.skip>0?r.skip+1:0;if(c>0&&c>n){const x=c-n;n=n+x}a=r.index,p.push(l)}return p.reverse()}function Wt(e,t,i){const n=e.slice().sort((l,c)=>l.skip-c.skip).sort((l,c)=>l.index-c.index);let a=i,p=0,r=t;for(const l of n.reverse()){const c=r-l.index;if(a=a-c,a>-1)p++,r=l.index;else break}return p}function Pe(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function Zt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function st(e,t,i,n,a,p=wt,r={},l){const c=Vt(i,p);return jt(e,t,c,n,a,r,l)}function jt(e,t,i,n,a,p={},r){const l=(r==null?void 0:r.checkHashes)??!0,c=Bt(e),x=Object.keys(t).reduce((k,_)=>{const s=_;return{...k,[s]:t[s].slice(0,a==null?void 0:a.revision[s])}},{}),j=Object.keys(x).reduce((k,_)=>{const s=_;return{...k,[s]:Ht(x[s],p[s])}},{}),z=Zt(j),g=z.reduce((k,{ignore:_,operation:s},m,y)=>_?i(k,St(s.scope),n,{skip:s.skip,ignoreSkipOperations:!0}):i(k,s,n,{skip:s.skip,ignoreSkipOperations:!0,reuseHash:!l}),c);if(!l){for(const k of Object.keys(g.state))for(let _=z.length-1;_>=0;_--)if(z[_].operation.scope===k){if(z[_].operation.hash!==ct(g,k))throw new Error(`Hash mismatch for scope ${k}`);break}}const S=Object.keys(g.operations).reduce((k,_)=>{const s=_,m=a&&a.revision[s]<t[s].length?t[s].slice(a.revision[s]):[];return{...k,[s]:[...g.operations[s].map((y,A)=>{var V;return{...y,timestamp:((V=t[s][A])==null?void 0:V.timestamp)??y.timestamp}}),...m]}},{global:[],local:[]}),I=Object.values(S).reduce((k,_)=>{for(const s of _)s.timestamp>k&&(k=s.timestamp);return k},e.lastModified);return{...g,operations:S,lastModified:I}}function Fe(e,t){return rt(e)===rt(t)}const Gt=e=>B("SET_NAME",e,void 0,yt,void 0),Qt=(e=1,t="global")=>B("UNDO",e,void 0,bt,t),Xt=(e=1,t="global")=>B("REDO",e,void 0,xt,t),Yt=(e,t,i="global")=>B("PRUNE",{start:e,end:t},void 0,ht,i),Ot=(e,t)=>B("LOAD_STATE",{state:e,operations:t},void 0,gt),St=(e="global")=>B("NOOP",{},void 0,void 0,e),Ie=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ot,noop:St,prune:Yt,redo:Xt,setName:Gt,undo:Qt},Symbol.toStringTag,{value:"Module"})),te={"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(te);var q=function(e,t,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:t.get(e)},H,Q,K;class Re{constructor(...t){H.set(this,new Map),Q.set(this,new Map),K.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[n,a]of Object.entries(t)){n=n.toLowerCase(),a=a.map(l=>l.toLowerCase()),q(this,K,"f").has(n)||q(this,K,"f").set(n,new Set);const p=q(this,K,"f").get(n);let r=!0;for(let l of a){const c=l.startsWith("*");if(l=c?l.slice(1):l,p==null||p.add(l),r&&q(this,Q,"f").set(n,l),r=!1,c)continue;const x=q(this,H,"f").get(l);if(x&&x!=n&&!i)throw new Error(`"${n} -> ${l}" conflicts with "${x} -> ${l}". Pass \`force=true\` to override this definition.`);q(this,H,"f").set(l,n)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),n=i.replace(/^.*\./,"").toLowerCase(),a=i.length<t.length;return!(n.length<i.length-1)&&a?null:q(this,H,"f").get(n)??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&&q(this,Q,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:q(this,K,"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 q(this,K,"f").values())Object.freeze(t);return this}_getTestState(){return{types:q(this,H,"f"),extensions:q(this,Q,"f")}}}H=new WeakMap,Q=new WeakMap,K=new WeakMap;const qe=new Re(te)._freeze();function ee(e){const t=[],i=Object.keys(e);for(const n of i){const a=e[n].sort((p,r)=>p.index-r.index);for(let p=0;p<a.length;p++)a[p].index!==p&&t.push({message:`Invalid operation index ${a[p].index} at position ${p}`,details:{position:p,operation:a[p],scope:a[p].scope}})}return t}const $t=async e=>{const t=new zt,{name:i,revision:n,documentType:a,created:p,lastModified:r}=e,l={name:i,revision:n,documentType:a,created:p,lastModified:r};return t.file("header.json",JSON.stringify(l,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(x=>{const{data:j,...z}=e.attachments[x];t.file(x,j,{base64:!0,createFolders:!0,comment:JSON.stringify(z)})}),t},ie=async(e,t,i,n)=>{const p=await(await $t(e)).generateAsync({type:"uint8array",streamFiles:!0}),r=n??e.name,l=`.${i}.zip`;return De(t,r.endsWith(l)?r:`${r}${l}`,p)},Le=async(e,t)=>{const n=await(await $t(e)).generateAsync({type:"blob"}),a=await t.createWritable();await a.write(n),await a.close()},dt=async(e,t,i)=>{const n=Ct(e);return ne(n,t,i)},ne=async(e,t,i)=>{const n=new zt;return await n.loadAsync(e),Je(n,t,i)};async function Je(e,t,i){const n=e.file("state.json");if(!n)throw new Error("Initial state not found");const a=await n.async("string"),p=JSON.parse(a),r=e.file("header.json");let l;r&&(l=JSON.parse(await r.async("string")));const c=e.file("operations.json");if(!c)throw new Error("Operations history not found");const x=JSON.parse(await c.async("string")),j=ee(x);if(j.length){const g=j.map(S=>S.message);throw new Error(g.join(`
|
|
20
|
+
`))}let z=jt(p,x,t,void 0,l,{},i);return l&&(z={...z,...l}),z}function oe(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function Ce(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Ae(e),n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}async function Ue(e){const t=await Ne(e),i=qe.getType(e)||"application/octet-stream",n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}class Ve{constructor(t,i,n){ot(this,"_document");ot(this,"_reducer");ot(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=n}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,n){return ie(this._document,t,i,n)}async loadFromFile(t){this._document=await dt(t,this._reducer)}static async stateFromFile(t,i){return await dt(t,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(t){return this._document.revision[t]}get initialState(){return G(this._document.initialState)}toDocument(){return G(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(Gt(t)),this}undo(t){return this.dispatch(Qt(t)),this}redo(t){return this.dispatch(Xt(t)),this}prune(t,i){return this.dispatch(Yt(t,i)),this}loadState(t,i){return this.dispatch(Ot(t,i)),this}}function Ke(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=Ie;exports.BaseDocument=Ve;exports.applyMixins=Ke;exports.baseReducer=wt;exports.calculateSkipsLeft=Wt;exports.createAction=B;exports.createDocument=Bt;exports.createExtendedState=Kt;exports.createReducer=Vt;exports.createZip=$t;exports.getLocalFile=Ue;exports.getRemoteFile=Ce;exports.hashDocument=ct;exports.hashKey=Me;exports.isBaseAction=ft;exports.isNoopOperation=Ut;exports.isSameDocument=Fe;exports.isUndoRedo=ut;exports.loadFromFile=dt;exports.loadFromInput=ne;exports.mapSkippedOperations=Ht;exports.processUndoRedo=Jt;exports.readOnly=G;exports.replayDocument=jt;exports.replayOperations=st;exports.saveToFile=ie;exports.saveToFileHandle=Le;exports.sortMappedOperations=Zt;exports.sortOperations=Pe;exports.validateOperations=ee;exports.zod=he;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-BFkXGmt6.js";
|
|
2
2
|
import "immer";
|
|
3
3
|
import "crypto";
|
|
4
4
|
import "fs";
|
|
5
5
|
import "https";
|
|
6
6
|
import "path";
|
|
7
7
|
import "jszip";
|
|
8
|
-
import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-
|
|
8
|
+
import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-BzNCX_-9.js";
|
|
9
9
|
import "zod";
|
|
10
10
|
export {
|
|
11
11
|
p as Document,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as c, h as n, g as d, C as u, D as x, E as f } from "./internal/object-
|
|
2
|
-
import { i as B } from "./internal/index-
|
|
1
|
+
import { B as c, h as n, g as d, C as u, D as x, E as f } from "./internal/object-BFkXGmt6.js";
|
|
2
|
+
import { i as B } from "./internal/index-DpH4_29z.js";
|
|
3
3
|
import "immer";
|
|
4
4
|
import "zod";
|
|
5
5
|
import "crypto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as o } from "./internal/index-
|
|
2
|
-
import { D as t } from "./internal/index-
|
|
3
|
-
import "./internal/object-
|
|
1
|
+
import { D as o } from "./internal/index-DpH4_29z.js";
|
|
2
|
+
import { D as t } from "./internal/index-BzNCX_-9.js";
|
|
3
|
+
import "./internal/object-BFkXGmt6.js";
|
|
4
4
|
import "immer";
|
|
5
5
|
import "zod";
|
|
6
6
|
import "crypto";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Rt = Object.defineProperty;
|
|
2
2
|
var xt = (t, e, r) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var Ee = (t, e, r) => (xt(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
-
import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-
|
|
4
|
+
import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-BFkXGmt6.js";
|
|
5
5
|
import "immer";
|
|
6
6
|
import "crypto";
|
|
7
7
|
import "fs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-
|
|
1
|
+
import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-BFkXGmt6.js";
|
|
2
2
|
const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
calculateSkipsLeft: e,
|
|
@@ -781,10 +781,8 @@ function Lt(e, t, i, n, a = {}) {
|
|
|
781
781
|
}), G(j, (g) => {
|
|
782
782
|
if ([X, Y, rt].includes(c.type))
|
|
783
783
|
return g;
|
|
784
|
-
const S = c.scope || "global";
|
|
785
|
-
|
|
786
|
-
const F = l && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : xt(g, S);
|
|
787
|
-
console.timeEnd("hash"), g.operations[S][g.operations[S].length - 1].hash = F, !jt(c) && c.attachments && c.attachments.forEach((_) => {
|
|
784
|
+
const S = c.scope || "global", F = l && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : xt(g, S);
|
|
785
|
+
g.operations[S][g.operations[S].length - 1].hash = F, !jt(c) && c.attachments && c.attachments.forEach((_) => {
|
|
788
786
|
const { hash: A, ...r } = _;
|
|
789
787
|
g.attachments[A] = {
|
|
790
788
|
...r
|
|
@@ -966,13 +964,15 @@ function Ct(e, t, i, n, a, p = {}, s) {
|
|
|
966
964
|
}),
|
|
967
965
|
c
|
|
968
966
|
);
|
|
969
|
-
|
|
970
|
-
for (
|
|
971
|
-
|
|
972
|
-
if (E[A].operation.
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
967
|
+
if (!l) {
|
|
968
|
+
for (const _ of Object.keys(g.state))
|
|
969
|
+
for (let A = E.length - 1; A >= 0; A--)
|
|
970
|
+
if (E[A].operation.scope === _) {
|
|
971
|
+
if (E[A].operation.hash !== xt(g, _))
|
|
972
|
+
throw new Error(`Hash mismatch for scope ${_}`);
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
976
|
const S = Object.keys(
|
|
977
977
|
g.operations
|
|
978
978
|
).reduce(
|
|
@@ -1152,10 +1152,10 @@ const Wt = async (e) => {
|
|
|
1152
1152
|
await a.write(n), await a.close();
|
|
1153
1153
|
}, Ot = async (e, t, i) => {
|
|
1154
1154
|
const n = qt(e);
|
|
1155
|
-
return Fe(n, t);
|
|
1155
|
+
return Fe(n, t, i);
|
|
1156
1156
|
}, Fe = async (e, t, i) => {
|
|
1157
1157
|
const n = new St();
|
|
1158
|
-
return await n.loadAsync(e), Re(n, t);
|
|
1158
|
+
return await n.loadAsync(e), Re(n, t, i);
|
|
1159
1159
|
};
|
|
1160
1160
|
async function Re(e, t, i) {
|
|
1161
1161
|
const n = e.file("state.json");
|
|
@@ -1180,7 +1180,9 @@ async function Re(e, t, i) {
|
|
|
1180
1180
|
x,
|
|
1181
1181
|
t,
|
|
1182
1182
|
void 0,
|
|
1183
|
-
l
|
|
1183
|
+
l,
|
|
1184
|
+
{},
|
|
1185
|
+
i
|
|
1184
1186
|
);
|
|
1185
1187
|
return l && (E = {
|
|
1186
1188
|
...E,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
@@ -23,32 +23,32 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"node": {
|
|
26
|
-
"import": "./dist/node/index.js",
|
|
27
|
-
"require": "./dist/node/index.cjs",
|
|
26
|
+
"import": "./dist/node/es/index.js",
|
|
27
|
+
"require": "./dist/node/cjs/index.cjs",
|
|
28
28
|
"types": "./dist/node/index.d.ts"
|
|
29
29
|
},
|
|
30
|
-
"import": "./dist/browser/index.js",
|
|
31
|
-
"require": "./dist/browser/index.cjs",
|
|
30
|
+
"import": "./dist/browser/es/index.js",
|
|
31
|
+
"require": "./dist/browser/cjs/index.cjs",
|
|
32
32
|
"types": "./dist/browser/index.d.ts"
|
|
33
33
|
},
|
|
34
34
|
"./document": {
|
|
35
35
|
"node": {
|
|
36
|
-
"import": "./dist/node/document.js",
|
|
37
|
-
"require": "./dist/node/document.
|
|
36
|
+
"import": "./dist/node/es/document.js",
|
|
37
|
+
"require": "./dist/node/cjs/document.js",
|
|
38
38
|
"types": "./dist/node/document.d.ts"
|
|
39
39
|
},
|
|
40
|
-
"import": "./dist/browser/document.js",
|
|
41
|
-
"require": "./dist/browser/document.
|
|
40
|
+
"import": "./dist/browser/es/document.js",
|
|
41
|
+
"require": "./dist/browser/cjs/document.js",
|
|
42
42
|
"types": "./dist/browser/document.d.ts"
|
|
43
43
|
},
|
|
44
44
|
"./document-model": {
|
|
45
45
|
"node": {
|
|
46
|
-
"import": "./dist/node/document-model.js",
|
|
47
|
-
"require": "./dist/node/document-model.
|
|
46
|
+
"import": "./dist/node/es/document-model.js",
|
|
47
|
+
"require": "./dist/node/cjs/document-model.js",
|
|
48
48
|
"types": "./dist/node/document-model.d.ts"
|
|
49
49
|
},
|
|
50
|
-
"import": "./dist/browser/document-model.js",
|
|
51
|
-
"require": "./dist/browser/document-model.
|
|
50
|
+
"import": "./dist/browser/es/document-model.js",
|
|
51
|
+
"require": "./dist/browser/cjs/document-model.js",
|
|
52
52
|
"types": "./dist/browser/document-model.d.ts"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"typescript": "^5.3.3",
|
|
76
76
|
"vite": "^5.0.11",
|
|
77
77
|
"vite-plugin-dts": "^3.7.1",
|
|
78
|
+
"vite-plugin-generate-file": "^0.1.1",
|
|
78
79
|
"vite-plugin-node-polyfills": "^0.19.0",
|
|
79
80
|
"vitest": "^1.5.0"
|
|
80
81
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SignalDispatch } from '../src/document';
|
|
2
|
-
import { Document, Action, BaseAction, ImmutableStateReducer, Operation, OperationScope, ReducerOptions } from '../src/document/types';
|
|
3
|
-
export declare const emptyReducer: import("../src/document").Reducer<unknown, Action, unknown>;
|
|
4
|
-
export declare const wrappedEmptyReducer: (state: Document<unknown, Action>, action: Action | BaseAction | Operation, dispatch?: SignalDispatch, options?: ReducerOptions) => Document<unknown, Action, unknown>;
|
|
5
|
-
export interface IncrementAction extends Action {
|
|
6
|
-
type: 'INCREMENT';
|
|
7
|
-
}
|
|
8
|
-
export interface DecrementAction extends Action {
|
|
9
|
-
type: 'DECREMENT';
|
|
10
|
-
}
|
|
11
|
-
export interface SetLocalNameAction extends Action {
|
|
12
|
-
type: 'SET_LOCAL_NAME';
|
|
13
|
-
input: string;
|
|
14
|
-
}
|
|
15
|
-
export type CountAction = IncrementAction | DecrementAction | SetLocalNameAction;
|
|
16
|
-
export type CountState = {
|
|
17
|
-
count: number;
|
|
18
|
-
};
|
|
19
|
-
export type CountLocalState = {
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
export declare const increment: () => IncrementAction;
|
|
23
|
-
export declare const decrement: () => DecrementAction;
|
|
24
|
-
export declare const setLocalName: (name: string) => SetLocalNameAction;
|
|
25
|
-
export declare const baseCountReducer: ImmutableStateReducer<CountState, CountAction, CountLocalState>;
|
|
26
|
-
export declare const countReducer: import("../src/document").Reducer<CountState, CountAction, CountLocalState>;
|
|
27
|
-
export declare const mapOperations: (operations: Operation[]) => {
|
|
28
|
-
input: unknown;
|
|
29
|
-
type: string;
|
|
30
|
-
index: number;
|
|
31
|
-
scope: OperationScope;
|
|
32
|
-
skip: number;
|
|
33
|
-
}[];
|
|
34
|
-
export declare const createFakeOperation: (index?: number, skip?: number, scope?: OperationScope) => Operation;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";var se=Object.defineProperty;var ae=(e,t,i)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ot=(e,t,i)=>(ae(e,typeof t!="symbol"?t+"":t,i),i);const U=require("immer"),u=require("zod"),pe=require("crypto"),lt=require("fs"),ce=require("https"),le=require("path"),zt=require("jszip"),Et=e=>e!=null,me=u.z.any().refine(e=>Et(e)),vt=u.z.enum(["LOAD_STATE"]),Tt=u.z.enum(["PRUNE"]),kt=u.z.enum(["REDO"]),_t=u.z.enum(["SET_NAME"]),Dt=u.z.enum(["UNDO"]);function ue(){return u.z.object({__typename:u.z.literal("Action").optional(),type:u.z.string()})}function X(){return u.z.literal("global").or(u.z.literal("local"))}function At(){return u.z.union([Nt(),Pt(),Ft(),It(),Rt()])}function fe(){return u.z.object({__typename:u.z.literal("DocumentFile").optional(),data:u.z.string(),extension:u.z.string().nullable(),fileName:u.z.string().nullable(),mimeType:u.z.string()})}function Nt(){return u.z.object({input:u.z.lazy(()=>gt()),type:vt,scope:X()})}function gt(){return u.z.object({operations:u.z.number(),state:u.z.lazy(()=>Mt())})}function Mt(){return u.z.object({data:u.z.unknown().nullish(),name:u.z.string()})}function de(){return u.z.object({__typename:u.z.literal("Operation").optional(),hash:u.z.string(),index:u.z.number(),timestamp:u.z.string().datetime(),type:u.z.string()})}function Pt(){return u.z.object({input:u.z.lazy(()=>ht()),type:Tt,scope:X()})}function ht(){return u.z.object({end:u.z.number().nullish(),start:u.z.number().nullish()})}const xt=u.z.number;function Ft(){return u.z.object({input:xt(),type:kt,scope:X()})}const yt=u.z.string;function It(){return u.z.object({input:yt(),type:_t,scope:u.z.literal("global")})}function ge(){return u.z.object({__typename:u.z.literal("SetNameOperation").optional(),hash:u.z.string(),index:u.z.number(),input:u.z.string(),timestamp:u.z.string().datetime(),type:u.z.string()})}const bt=u.z.number;function Rt(){return u.z.object({input:bt(),type:Dt,scope:X()})}const he=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:ue,BaseActionSchema:At,DocumentFileSchema:fe,LoadStateActionInputSchema:gt,LoadStateActionSchema:Nt,LoadStateActionStateInputSchema:Mt,Load_StateSchema:vt,OperationSchema:de,OperationScopeSchema:X,PruneActionInputSchema:ht,PruneActionSchema:Pt,PruneSchema:Tt,RedoActionInputSchema:xt,RedoActionSchema:Ft,RedoSchema:kt,SetNameActionInputSchema:yt,SetNameActionSchema:It,SetNameOperationSchema:ge,Set_NameSchema:_t,UndoActionInputSchema:bt,UndoActionSchema:Rt,UndoSchema:Dt,definedNonNullAnySchema:me,isDefinedNonNullAny:Et},Symbol.toStringTag,{value:"Module"}));function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mt={exports:{}};(function(e,t){const{hasOwnProperty:i}=Object.prototype,n=_();n.configure=_,n.stringify=n,n.default=n,t.stringify=n,t.configure=_,e.exports=n;const a=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function p(s){return s.length<5e3&&!a.test(s)?`"${s}"`:JSON.stringify(s)}function r(s){if(s.length>200)return s.sort();for(let m=1;m<s.length;m++){const y=s[m];let A=m;for(;A!==0&&s[A-1]>y;)s[A]=s[A-1],A--;s[A]=y}return s}const l=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(s){return l.call(s)!==void 0&&s.length!==0}function x(s,m,y){s.length<y&&(y=s.length);const A=m===","?"":" ";let V=`"0":${A}${s[0]}`;for(let R=1;R<y;R++)V+=`${m}"${R}":${A}${s[R]}`;return V}function j(s){if(i.call(s,"circularValue")){const m=s.circularValue;if(typeof m=="string")return`"${m}"`;if(m==null)return m;if(m===Error||m===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function z(s,m){let y;if(i.call(s,m)&&(y=s[m],typeof y!="boolean"))throw new TypeError(`The "${m}" argument must be of type boolean`);return y===void 0?!0:y}function g(s,m){let y;if(i.call(s,m)){if(y=s[m],typeof y!="number")throw new TypeError(`The "${m}" argument must be of type number`);if(!Number.isInteger(y))throw new TypeError(`The "${m}" argument must be an integer`);if(y<1)throw new RangeError(`The "${m}" argument must be >= 1`)}return y===void 0?1/0:y}function S(s){return s===1?"1 item":`${s} items`}function I(s){const m=new Set;for(const y of s)(typeof y=="string"||typeof y=="number")&&m.add(String(y));return m}function k(s){if(i.call(s,"strict")){const m=s.strict;if(typeof m!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(m)return y=>{let A=`Object can not safely be stringified. Received type ${typeof y}`;throw typeof y!="function"&&(A+=` (${y.toString()})`),new Error(A)}}}function _(s){s={...s};const m=k(s);m&&(s.bigint===void 0&&(s.bigint=!1),"circularValue"in s||(s.circularValue=Error));const y=j(s),A=z(s,"bigint"),V=z(s,"deterministic"),R=g(s,"maximumDepth"),v=g(s,"maximumBreadth");function et(M,o,f,b,h,O){let d=o[M];switch(typeof d=="object"&&d!==null&&typeof d.toJSON=="function"&&(d=d.toJSON(M)),d=b.call(o,M,d),typeof d){case"string":return p(d);case"object":{if(d===null)return"null";if(f.indexOf(d)!==-1)return y;let w="",E=",";const T=O;if(Array.isArray(d)){if(d.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(d),h!==""&&(O+=h,w+=`
|
|
2
|
-
${O}`,E=`,
|
|
3
|
-
${O}`);const F=Math.min(d.length,v);let J=0;for(;J<F-1;J++){const nt=et(String(J),d,f,b,h,O);w+=nt!==void 0?nt:"null",w+=E}const C=et(String(J),d,f,b,h,O);if(w+=C!==void 0?C:"null",d.length-1>v){const nt=d.length-v-1;w+=`${E}"... ${S(nt)} not stringified"`}return h!==""&&(w+=`
|
|
4
|
-
${T}`),f.pop(),`[${w}]`}let D=Object.keys(d);const N=D.length;if(N===0)return"{}";if(R<f.length+1)return'"[Object]"';let $="",P="";h!==""&&(O+=h,E=`,
|
|
5
|
-
${O}`,$=" ");const L=Math.min(N,v);V&&!c(d)&&(D=r(D)),f.push(d);for(let F=0;F<L;F++){const J=D[F],C=et(J,d,f,b,h,O);C!==void 0&&(w+=`${P}${p(J)}:${$}${C}`,P=E)}if(N>v){const F=N-v;w+=`${P}"...":${$}"${S(F)} not stringified"`,P=E}return h!==""&&P.length>1&&(w=`
|
|
6
|
-
${O}${w}
|
|
7
|
-
${T}`),f.pop(),`{${w}}`}case"number":return isFinite(d)?String(d):m?m(d):"null";case"boolean":return d===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(d);default:return m?m(d):void 0}}function it(M,o,f,b,h,O){switch(typeof o=="object"&&o!==null&&typeof o.toJSON=="function"&&(o=o.toJSON(M)),typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(f.indexOf(o)!==-1)return y;const d=O;let w="",E=",";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h!==""&&(O+=h,w+=`
|
|
8
|
-
${O}`,E=`,
|
|
9
|
-
${O}`);const N=Math.min(o.length,v);let $=0;for(;$<N-1;$++){const L=it(String($),o[$],f,b,h,O);w+=L!==void 0?L:"null",w+=E}const P=it(String($),o[$],f,b,h,O);if(w+=P!==void 0?P:"null",o.length-1>v){const L=o.length-v-1;w+=`${E}"... ${S(L)} not stringified"`}return h!==""&&(w+=`
|
|
10
|
-
${d}`),f.pop(),`[${w}]`}f.push(o);let T="";h!==""&&(O+=h,E=`,
|
|
11
|
-
${O}`,T=" ");let D="";for(const N of b){const $=it(N,o[N],f,b,h,O);$!==void 0&&(w+=`${D}${p(N)}:${T}${$}`,D=E)}return h!==""&&D.length>1&&(w=`
|
|
12
|
-
${O}${w}
|
|
13
|
-
${d}`),f.pop(),`{${w}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function W(M,o,f,b,h){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return W(M,o,f,b,h);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;const O=h;if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h+=b;let $=`
|
|
14
|
-
${h}`;const P=`,
|
|
15
|
-
${h}`,L=Math.min(o.length,v);let F=0;for(;F<L-1;F++){const C=W(String(F),o[F],f,b,h);$+=C!==void 0?C:"null",$+=P}const J=W(String(F),o[F],f,b,h);if($+=J!==void 0?J:"null",o.length-1>v){const C=o.length-v-1;$+=`${P}"... ${S(C)} not stringified"`}return $+=`
|
|
16
|
-
${O}`,f.pop(),`[${$}]`}let d=Object.keys(o);const w=d.length;if(w===0)return"{}";if(R<f.length+1)return'"[Object]"';h+=b;const E=`,
|
|
17
|
-
${h}`;let T="",D="",N=Math.min(w,v);c(o)&&(T+=x(o,E,v),d=d.slice(o.length),N-=o.length,D=E),V&&(d=r(d)),f.push(o);for(let $=0;$<N;$++){const P=d[$],L=W(P,o[P],f,b,h);L!==void 0&&(T+=`${D}${p(P)}: ${L}`,D=E)}if(w>v){const $=w-v;T+=`${D}"...": "${S($)} not stringified"`,D=E}return D!==""&&(T=`
|
|
18
|
-
${h}${T}
|
|
19
|
-
${O}`),f.pop(),`{${T}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function Z(M,o,f){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return Z(M,o,f);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;let b="";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o);const E=Math.min(o.length,v);let T=0;for(;T<E-1;T++){const N=Z(String(T),o[T],f);b+=N!==void 0?N:"null",b+=","}const D=Z(String(T),o[T],f);if(b+=D!==void 0?D:"null",o.length-1>v){const N=o.length-v-1;b+=`,"... ${S(N)} not stringified"`}return f.pop(),`[${b}]`}let h=Object.keys(o);const O=h.length;if(O===0)return"{}";if(R<f.length+1)return'"[Object]"';let d="",w=Math.min(O,v);c(o)&&(b+=x(o,",",v),h=h.slice(o.length),w-=o.length,d=","),V&&(h=r(h)),f.push(o);for(let E=0;E<w;E++){const T=h[E],D=Z(T,o[T],f);D!==void 0&&(b+=`${d}${p(T)}:${D}`,d=",")}if(O>v){const E=O-v;b+=`${d}"...":"${S(E)} not stringified"`}return f.pop(),`{${b}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function re(M,o,f){if(arguments.length>1){let b="";if(typeof f=="number"?b=" ".repeat(Math.min(f,10)):typeof f=="string"&&(b=f.slice(0,10)),o!=null){if(typeof o=="function")return et("",{"":M},[],o,b,"");if(Array.isArray(o))return it("",M,[],I(o),b,"")}if(b.length!==0)return W("",M,[],b,"")}return Z("",M,[])}return re}})(mt,mt.exports);var ye=mt.exports;const rt=xe(ye);rt.configure;function be(e,t){return{...e,name:t}}function we(e,t,i){const n={skip:i,document:e},{scope:a}=t;return!a||t.skip===void 0?n:U.produce(n,p=>{const[r]=p.document.operations[a].slice(-1);t.skip&&t.skip>0&&(p.skip=t.skip),r.type==="NOOP"&&t.index===r.index&&p.skip>r.skip&&p.document.operations[a].pop()})}function je(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.document.operations[n].length<1)throw new Error(`Cannot undo: no operations in history for scope "${n}"`);if(a<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(r.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[l]=r.document.operations[n].slice(-1),c=l.type==="NOOP"&&l.skip>0;if(r.skip+=a,c){r.skip+=l.skip;const g=r.document.operations[n][r.document.operations[n].length-2];g&&l.index-g.index===1&&r.document.operations[n].pop()}if(r.document.operations[n].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const x=r.document.operations[n].length-1;let j=a,z=c?x-l.skip:x;for(;j>0&&z>=0;){const g=r.document.operations[n][z];if(!g){j--,z--;continue}g.type==="NOOP"&&g.skip>0?(z=z-(g.skip+1),r.skip+=g.skip+1):(r.document.clipboard.push({...g}),j--,z--)}r.action=St(n)})}function Oe(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(a>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(a<1)throw new Error("Invalid REDO action: invalid redo input value");if(r.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const l=r.document.clipboard.findLastIndex(x=>x.scope===n);if(l<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${n}"`);const c=r.document.clipboard.splice(l,1)[0];r.action=U.castDraft({type:c.type,scope:c.scope,input:c.input})})}function Se(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:p,end:r}}=t;p=p||0,r=r||a.length;const l=a.slice(p,r),c=a.slice(0,p),x=a.slice(r),j=st(e.initialState,{...e.operations,[n]:c.concat(l)},i),{name:z,state:g}=j,S=c.length,I=c.length?c[c.length-1].timestamp:x.length?x[0].timestamp:new Date().toISOString();return st(e.initialState,{...e.operations,[n]:[...c,{...Ot({name:z,state:g},l.length),timestamp:I,index:S,hash:ct({state:g},"global")},...x.map((k,_)=>({...k,index:S+_+1}))]},i)}function $e(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const qt="SET_NAME",Y="UNDO",tt="REDO",at="PRUNE",Lt="LOAD_STATE",ze="NOOP";function Ee(e,t){let i;return"index"in t?i={...t}:i=e.operations[t.scope].slice(-1)[0],((i==null?void 0:i.index)??-1)+1}function ve(e,t){return{...e,revision:{...e.revision,[t.scope]:Ee(e,t)},lastModified:new Date().toISOString()}}function Te(e,t,i=0){if([Y,tt,at].includes(t.type))return e;const{scope:n}=t,a=e.operations[n].slice(0,e.revision[n]),p=[...a].pop();let r=((p==null?void 0:p.index)??-1)+1;if("index"in t){if(t.index>r+i)throw new Error(`Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`);r=t.index}return a.push({...t,index:r,timestamp:new Date().toISOString(),hash:"",scope:n,skip:i}),{...e,operations:{...e.operations,[n]:a}}}function ke(e,t,i=0){let n=Te(e,t,i);return n=ve(n,t),n}function _e(e,t,i){switch(At().parse(t),t.type){case qt:return be(e,t.input);case at:return Se(e,t,i);case Lt:return $e(e,t.input.state);default:return e}}function Jt(e,t,i){switch(t.type){case Y:return je(e,t,i);case tt:return Oe(e,t,i);default:return{document:e,action:t,skip:i}}}function wt(e,t,i,n,a={}){const{skip:p,ignoreSkipOperations:r=!1,reuseHash:l=!1}=a;let c={...t},x=p||0,j=e,z=[...e.clipboard];if(Ut(c)){const{document:g,skip:S}=we(j,c,x);x=S,j=g}if(ut(c)){const{skip:g,action:S,document:I}=Jt(e,c,x);c=S,x=g,j=I,z=[...j.clipboard]}if(ft(c)&&(j=_e(j,c,i)),x>0&&!r){let g=x;"index"in c&&(g=Wt(j.operations[c.scope],c.index,x)),j=st(j.initialState,j.operations,i,void 0,void 0,void 0,{[c.scope]:g})}return j=ke(j,c,x),j=U.produce(j,g=>{const S=i(g.state,c,n),I=ut(t)?[...z]:[];if(S)return U.castDraft({...j,clipboard:[...I],state:S});g.clipboard=U.castDraft([...I])}),U.produce(j,g=>{if([Y,tt,at].includes(c.type))return g;const S=c.scope||"global";console.time("hash");const I=l&&Object.prototype.hasOwnProperty.call(c,"hash")?c.hash:ct(g,S);console.timeEnd("hash"),g.operations[S][g.operations[S].length-1].hash=I,!ft(c)&&c.attachments&&c.attachments.forEach(k=>{const{hash:_,...s}=k;g.attachments[_]={...s}})})}function De(e,t,i){const n=le.join(e,t);return lt.mkdirSync(e,{recursive:!0}),new Promise((a,p)=>{try{lt.writeFile(n,i,{},r=>{r?p(r):a(n)})}catch(r){p(r)}})}function Ct(e){return lt.readFileSync(e)}function Ae(e){return new Promise((t,i)=>{ce.get(e,n=>{const a=[],p=n.headers["content-type"];n.on("data",r=>{a.push(r)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:p})})}).on("error",n=>{i(n)})})}const Ne=async e=>Ct(e),pt=(e,t="sha1")=>pe.createHash(t).update(e).digest("base64");function Ut(e){return e.type===ze&&e.skip!==void 0&&e.skip>0&&e.hash!==void 0}function ut(e){return[Y,tt].includes(e.type)}function ft(e){return[qt,Y,tt,at,Lt].includes(e.type)}function B(e,t,i,n,a="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${JSON.stringify(e)}`);const p={type:e,input:t,scope:a};i&&(p.attachments=i);try{n==null||n().parse(p.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return p}function Vt(e,t=wt){return(i,n,a,p)=>t(i,n,e,a,p)}const Kt=(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:{}}}),Bt=(e,t)=>{const i=Kt(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},ct=(e,t="global")=>pt(rt(e.state[t]||"")),Me=(e,t=1e3)=>{const i=Math.random()*t;return pt(`${(e??new Date).toISOString()}${i}`)};function G(e){return U.castImmutable(U.freeze(e,!0))}function Ht(e,t){const i=[...e];let n=t||0,a=i.length>0?i[i.length-1].index:0;const p=[];for(const r of i.reverse()){if(n>0){const x=a-r.index;n-=x}if(n<0)throw new Error("Invalid operation index, missing operations");const l={ignore:n>0,operation:r},c=r.skip>0?r.skip+1:0;if(c>0&&c>n){const x=c-n;n=n+x}a=r.index,p.push(l)}return p.reverse()}function Wt(e,t,i){const n=e.slice().sort((l,c)=>l.skip-c.skip).sort((l,c)=>l.index-c.index);let a=i,p=0,r=t;for(const l of n.reverse()){const c=r-l.index;if(a=a-c,a>-1)p++,r=l.index;else break}return p}function Pe(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function Zt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function st(e,t,i,n,a,p=wt,r={},l){const c=Vt(i,p);return jt(e,t,c,n,a,r,l)}function jt(e,t,i,n,a,p={},r){const l=(r==null?void 0:r.checkHashes)??!0,c=Bt(e),x=Object.keys(t).reduce((k,_)=>{const s=_;return{...k,[s]:t[s].slice(0,a==null?void 0:a.revision[s])}},{}),j=Object.keys(x).reduce((k,_)=>{const s=_;return{...k,[s]:Ht(x[s],p[s])}},{}),z=Zt(j),g=z.reduce((k,{ignore:_,operation:s},m,y)=>_?i(k,St(s.scope),n,{skip:s.skip,ignoreSkipOperations:!0}):i(k,s,n,{skip:s.skip,ignoreSkipOperations:!0,reuseHash:!l}),c);for(const k of Object.keys(g.state))for(let _=z.length-1;_>=0;_--)if(z[_].operation.scope===k){if(z[_].operation.hash!==ct(g,k))throw new Error(`Hash mismatch for scope ${k}`);break}const S=Object.keys(g.operations).reduce((k,_)=>{const s=_,m=a&&a.revision[s]<t[s].length?t[s].slice(a.revision[s]):[];return{...k,[s]:[...g.operations[s].map((y,A)=>{var V;return{...y,timestamp:((V=t[s][A])==null?void 0:V.timestamp)??y.timestamp}}),...m]}},{global:[],local:[]}),I=Object.values(S).reduce((k,_)=>{for(const s of _)s.timestamp>k&&(k=s.timestamp);return k},e.lastModified);return{...g,operations:S,lastModified:I}}function Fe(e,t){return rt(e)===rt(t)}const Gt=e=>B("SET_NAME",e,void 0,yt,void 0),Qt=(e=1,t="global")=>B("UNDO",e,void 0,bt,t),Xt=(e=1,t="global")=>B("REDO",e,void 0,xt,t),Yt=(e,t,i="global")=>B("PRUNE",{start:e,end:t},void 0,ht,i),Ot=(e,t)=>B("LOAD_STATE",{state:e,operations:t},void 0,gt),St=(e="global")=>B("NOOP",{},void 0,void 0,e),Ie=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ot,noop:St,prune:Yt,redo:Xt,setName:Gt,undo:Qt},Symbol.toStringTag,{value:"Module"})),te={"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(te);var q=function(e,t,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:t.get(e)},H,Q,K;class Re{constructor(...t){H.set(this,new Map),Q.set(this,new Map),K.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[n,a]of Object.entries(t)){n=n.toLowerCase(),a=a.map(l=>l.toLowerCase()),q(this,K,"f").has(n)||q(this,K,"f").set(n,new Set);const p=q(this,K,"f").get(n);let r=!0;for(let l of a){const c=l.startsWith("*");if(l=c?l.slice(1):l,p==null||p.add(l),r&&q(this,Q,"f").set(n,l),r=!1,c)continue;const x=q(this,H,"f").get(l);if(x&&x!=n&&!i)throw new Error(`"${n} -> ${l}" conflicts with "${x} -> ${l}". Pass \`force=true\` to override this definition.`);q(this,H,"f").set(l,n)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),n=i.replace(/^.*\./,"").toLowerCase(),a=i.length<t.length;return!(n.length<i.length-1)&&a?null:q(this,H,"f").get(n)??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&&q(this,Q,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:q(this,K,"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 q(this,K,"f").values())Object.freeze(t);return this}_getTestState(){return{types:q(this,H,"f"),extensions:q(this,Q,"f")}}}H=new WeakMap,Q=new WeakMap,K=new WeakMap;const qe=new Re(te)._freeze();function ee(e){const t=[],i=Object.keys(e);for(const n of i){const a=e[n].sort((p,r)=>p.index-r.index);for(let p=0;p<a.length;p++)a[p].index!==p&&t.push({message:`Invalid operation index ${a[p].index} at position ${p}`,details:{position:p,operation:a[p],scope:a[p].scope}})}return t}const $t=async e=>{const t=new zt,{name:i,revision:n,documentType:a,created:p,lastModified:r}=e,l={name:i,revision:n,documentType:a,created:p,lastModified:r};return t.file("header.json",JSON.stringify(l,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(x=>{const{data:j,...z}=e.attachments[x];t.file(x,j,{base64:!0,createFolders:!0,comment:JSON.stringify(z)})}),t},ie=async(e,t,i,n)=>{const p=await(await $t(e)).generateAsync({type:"uint8array",streamFiles:!0}),r=n??e.name,l=`.${i}.zip`;return De(t,r.endsWith(l)?r:`${r}${l}`,p)},Le=async(e,t)=>{const n=await(await $t(e)).generateAsync({type:"blob"}),a=await t.createWritable();await a.write(n),await a.close()},dt=async(e,t,i)=>{const n=Ct(e);return ne(n,t)},ne=async(e,t,i)=>{const n=new zt;return await n.loadAsync(e),Je(n,t)};async function Je(e,t,i){const n=e.file("state.json");if(!n)throw new Error("Initial state not found");const a=await n.async("string"),p=JSON.parse(a),r=e.file("header.json");let l;r&&(l=JSON.parse(await r.async("string")));const c=e.file("operations.json");if(!c)throw new Error("Operations history not found");const x=JSON.parse(await c.async("string")),j=ee(x);if(j.length){const g=j.map(S=>S.message);throw new Error(g.join(`
|
|
20
|
-
`))}let z=jt(p,x,t,void 0,l);return l&&(z={...z,...l}),z}function oe(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function Ce(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Ae(e),n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}async function Ue(e){const t=await Ne(e),i=qe.getType(e)||"application/octet-stream",n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}class Ve{constructor(t,i,n){ot(this,"_document");ot(this,"_reducer");ot(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=n}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,n){return ie(this._document,t,i,n)}async loadFromFile(t){this._document=await dt(t,this._reducer)}static async stateFromFile(t,i){return await dt(t,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(t){return this._document.revision[t]}get initialState(){return G(this._document.initialState)}toDocument(){return G(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(Gt(t)),this}undo(t){return this.dispatch(Qt(t)),this}redo(t){return this.dispatch(Xt(t)),this}prune(t,i){return this.dispatch(Yt(t,i)),this}loadState(t,i){return this.dispatch(Ot(t,i)),this}}function Ke(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=Ie;exports.BaseDocument=Ve;exports.applyMixins=Ke;exports.baseReducer=wt;exports.calculateSkipsLeft=Wt;exports.createAction=B;exports.createDocument=Bt;exports.createExtendedState=Kt;exports.createReducer=Vt;exports.createZip=$t;exports.getLocalFile=Ue;exports.getRemoteFile=Ce;exports.hashDocument=ct;exports.hashKey=Me;exports.isBaseAction=ft;exports.isNoopOperation=Ut;exports.isSameDocument=Fe;exports.isUndoRedo=ut;exports.loadFromFile=dt;exports.loadFromInput=ne;exports.mapSkippedOperations=Ht;exports.processUndoRedo=Jt;exports.readOnly=G;exports.replayDocument=jt;exports.replayOperations=st;exports.saveToFile=ie;exports.saveToFileHandle=Le;exports.sortMappedOperations=Zt;exports.sortOperations=Pe;exports.validateOperations=ee;exports.zod=he;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|