document-model 1.0.51 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/{node/cjs/internal/index-CRjFLQNR.js → browser/cjs/internal/index-BVWyYyNE.js} +1 -1
- package/dist/browser/cjs/internal/{index-CPJM383s.js → index-CnVGNZ9_.js} +1 -1
- package/dist/browser/cjs/internal/object-5l5_pTNL.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +2 -2
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/{index-tEH7iGUj.js → index-CF0d1_Cg.js} +1 -1
- package/dist/browser/es/internal/{index-BzIVYv7p.js → index-aS_vqu4O.js} +1 -1
- package/dist/browser/es/internal/{object-Dev4WFVH.js → object-BdaEhPk1.js} +770 -771
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +2 -0
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/{browser/cjs/internal/index-REU04m7f.js → node/cjs/internal/index-B9gc2lPN.js} +1 -1
- package/dist/node/cjs/internal/{index-BX95XaQ_.js → index-JtuONOcD.js} +1 -1
- package/dist/node/cjs/internal/object-D6wRzEDN.js +20 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +2 -2
- package/dist/node/es/index.js +3 -3
- package/dist/node/es/internal/{index-BzNCX_-9.js → index-BclkoIYP.js} +1 -1
- package/dist/node/es/internal/{index-DpH4_29z.js → index-EY0PPZnJ.js} +1 -1
- package/dist/node/es/internal/{object-BFkXGmt6.js → object-BxC3xMqY.js} +509 -510
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/browser/cjs/internal/object-DkoS83BB.js +0 -25
- package/dist/node/cjs/internal/object-CGt7Qacd.js +0 -20
|
@@ -88,6 +88,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
88
88
|
readonly timestamp: string;
|
|
89
89
|
readonly hash: string;
|
|
90
90
|
readonly skip: number;
|
|
91
|
+
readonly error?: string | undefined;
|
|
91
92
|
} | {
|
|
92
93
|
readonly type: "PRUNE";
|
|
93
94
|
readonly input: {
|
|
@@ -120,6 +121,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
120
121
|
readonly timestamp: string;
|
|
121
122
|
readonly hash: string;
|
|
122
123
|
readonly skip: number;
|
|
124
|
+
readonly error?: string | undefined;
|
|
123
125
|
} | {
|
|
124
126
|
readonly type: "REDO";
|
|
125
127
|
readonly input: number;
|
|
@@ -149,6 +151,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
149
151
|
readonly timestamp: string;
|
|
150
152
|
readonly hash: string;
|
|
151
153
|
readonly skip: number;
|
|
154
|
+
readonly error?: string | undefined;
|
|
152
155
|
} | {
|
|
153
156
|
readonly type: "SET_NAME";
|
|
154
157
|
readonly input: string;
|
|
@@ -178,6 +181,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
178
181
|
readonly timestamp: string;
|
|
179
182
|
readonly hash: string;
|
|
180
183
|
readonly skip: number;
|
|
184
|
+
readonly error?: string | undefined;
|
|
181
185
|
} | {
|
|
182
186
|
readonly type: "UNDO";
|
|
183
187
|
readonly input: number;
|
|
@@ -207,6 +211,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
207
211
|
readonly timestamp: string;
|
|
208
212
|
readonly hash: string;
|
|
209
213
|
readonly skip: number;
|
|
214
|
+
readonly error?: string | undefined;
|
|
210
215
|
} | {
|
|
211
216
|
readonly type: "NOOP";
|
|
212
217
|
readonly input: unknown;
|
|
@@ -236,11 +241,13 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
236
241
|
readonly timestamp: string;
|
|
237
242
|
readonly hash: string;
|
|
238
243
|
readonly skip: number;
|
|
244
|
+
readonly error?: string | undefined;
|
|
239
245
|
} | import("immer").Immutable<A & {
|
|
240
246
|
index: number;
|
|
241
247
|
timestamp: string;
|
|
242
248
|
hash: string;
|
|
243
249
|
skip: number;
|
|
250
|
+
error?: string | undefined;
|
|
244
251
|
}>)[];
|
|
245
252
|
readonly local: readonly ({
|
|
246
253
|
readonly type: "LOAD_STATE";
|
|
@@ -277,6 +284,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
277
284
|
readonly timestamp: string;
|
|
278
285
|
readonly hash: string;
|
|
279
286
|
readonly skip: number;
|
|
287
|
+
readonly error?: string | undefined;
|
|
280
288
|
} | {
|
|
281
289
|
readonly type: "PRUNE";
|
|
282
290
|
readonly input: {
|
|
@@ -309,6 +317,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
309
317
|
readonly timestamp: string;
|
|
310
318
|
readonly hash: string;
|
|
311
319
|
readonly skip: number;
|
|
320
|
+
readonly error?: string | undefined;
|
|
312
321
|
} | {
|
|
313
322
|
readonly type: "REDO";
|
|
314
323
|
readonly input: number;
|
|
@@ -338,6 +347,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
338
347
|
readonly timestamp: string;
|
|
339
348
|
readonly hash: string;
|
|
340
349
|
readonly skip: number;
|
|
350
|
+
readonly error?: string | undefined;
|
|
341
351
|
} | {
|
|
342
352
|
readonly type: "SET_NAME";
|
|
343
353
|
readonly input: string;
|
|
@@ -367,6 +377,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
367
377
|
readonly timestamp: string;
|
|
368
378
|
readonly hash: string;
|
|
369
379
|
readonly skip: number;
|
|
380
|
+
readonly error?: string | undefined;
|
|
370
381
|
} | {
|
|
371
382
|
readonly type: "UNDO";
|
|
372
383
|
readonly input: number;
|
|
@@ -396,6 +407,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
396
407
|
readonly timestamp: string;
|
|
397
408
|
readonly hash: string;
|
|
398
409
|
readonly skip: number;
|
|
410
|
+
readonly error?: string | undefined;
|
|
399
411
|
} | {
|
|
400
412
|
readonly type: "NOOP";
|
|
401
413
|
readonly input: unknown;
|
|
@@ -425,11 +437,13 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
425
437
|
readonly timestamp: string;
|
|
426
438
|
readonly hash: string;
|
|
427
439
|
readonly skip: number;
|
|
440
|
+
readonly error?: string | undefined;
|
|
428
441
|
} | import("immer").Immutable<A & {
|
|
429
442
|
index: number;
|
|
430
443
|
timestamp: string;
|
|
431
444
|
hash: string;
|
|
432
445
|
skip: number;
|
|
446
|
+
error?: string | undefined;
|
|
433
447
|
}>)[];
|
|
434
448
|
};
|
|
435
449
|
/**
|
|
@@ -538,6 +552,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
538
552
|
readonly timestamp: string;
|
|
539
553
|
readonly hash: string;
|
|
540
554
|
readonly skip: number;
|
|
555
|
+
readonly error?: string | undefined;
|
|
541
556
|
} | {
|
|
542
557
|
readonly type: "PRUNE";
|
|
543
558
|
readonly input: {
|
|
@@ -570,6 +585,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
570
585
|
readonly timestamp: string;
|
|
571
586
|
readonly hash: string;
|
|
572
587
|
readonly skip: number;
|
|
588
|
+
readonly error?: string | undefined;
|
|
573
589
|
} | {
|
|
574
590
|
readonly type: "REDO";
|
|
575
591
|
readonly input: number;
|
|
@@ -599,6 +615,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
599
615
|
readonly timestamp: string;
|
|
600
616
|
readonly hash: string;
|
|
601
617
|
readonly skip: number;
|
|
618
|
+
readonly error?: string | undefined;
|
|
602
619
|
} | {
|
|
603
620
|
readonly type: "SET_NAME";
|
|
604
621
|
readonly input: string;
|
|
@@ -628,6 +645,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
628
645
|
readonly timestamp: string;
|
|
629
646
|
readonly hash: string;
|
|
630
647
|
readonly skip: number;
|
|
648
|
+
readonly error?: string | undefined;
|
|
631
649
|
} | {
|
|
632
650
|
readonly type: "UNDO";
|
|
633
651
|
readonly input: number;
|
|
@@ -657,6 +675,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
657
675
|
readonly timestamp: string;
|
|
658
676
|
readonly hash: string;
|
|
659
677
|
readonly skip: number;
|
|
678
|
+
readonly error?: string | undefined;
|
|
660
679
|
} | {
|
|
661
680
|
readonly type: "NOOP";
|
|
662
681
|
readonly input: unknown;
|
|
@@ -686,11 +705,13 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
686
705
|
readonly timestamp: string;
|
|
687
706
|
readonly hash: string;
|
|
688
707
|
readonly skip: number;
|
|
708
|
+
readonly error?: string | undefined;
|
|
689
709
|
} | import("immer").Immutable<A & {
|
|
690
710
|
index: number;
|
|
691
711
|
timestamp: string;
|
|
692
712
|
hash: string;
|
|
693
713
|
skip: number;
|
|
714
|
+
error?: string | undefined;
|
|
694
715
|
}>)[];
|
|
695
716
|
readonly local: readonly ({
|
|
696
717
|
readonly type: "LOAD_STATE";
|
|
@@ -727,6 +748,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
727
748
|
readonly timestamp: string;
|
|
728
749
|
readonly hash: string;
|
|
729
750
|
readonly skip: number;
|
|
751
|
+
readonly error?: string | undefined;
|
|
730
752
|
} | {
|
|
731
753
|
readonly type: "PRUNE";
|
|
732
754
|
readonly input: {
|
|
@@ -759,6 +781,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
759
781
|
readonly timestamp: string;
|
|
760
782
|
readonly hash: string;
|
|
761
783
|
readonly skip: number;
|
|
784
|
+
readonly error?: string | undefined;
|
|
762
785
|
} | {
|
|
763
786
|
readonly type: "REDO";
|
|
764
787
|
readonly input: number;
|
|
@@ -788,6 +811,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
788
811
|
readonly timestamp: string;
|
|
789
812
|
readonly hash: string;
|
|
790
813
|
readonly skip: number;
|
|
814
|
+
readonly error?: string | undefined;
|
|
791
815
|
} | {
|
|
792
816
|
readonly type: "SET_NAME";
|
|
793
817
|
readonly input: string;
|
|
@@ -817,6 +841,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
817
841
|
readonly timestamp: string;
|
|
818
842
|
readonly hash: string;
|
|
819
843
|
readonly skip: number;
|
|
844
|
+
readonly error?: string | undefined;
|
|
820
845
|
} | {
|
|
821
846
|
readonly type: "UNDO";
|
|
822
847
|
readonly input: number;
|
|
@@ -846,6 +871,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
846
871
|
readonly timestamp: string;
|
|
847
872
|
readonly hash: string;
|
|
848
873
|
readonly skip: number;
|
|
874
|
+
readonly error?: string | undefined;
|
|
849
875
|
} | {
|
|
850
876
|
readonly type: "NOOP";
|
|
851
877
|
readonly input: unknown;
|
|
@@ -875,11 +901,13 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
875
901
|
readonly timestamp: string;
|
|
876
902
|
readonly hash: string;
|
|
877
903
|
readonly skip: number;
|
|
904
|
+
readonly error?: string | undefined;
|
|
878
905
|
} | import("immer").Immutable<A & {
|
|
879
906
|
index: number;
|
|
880
907
|
timestamp: string;
|
|
881
908
|
hash: string;
|
|
882
909
|
skip: number;
|
|
910
|
+
error?: string | undefined;
|
|
883
911
|
}>)[];
|
|
884
912
|
};
|
|
885
913
|
readonly initialState: {
|
|
@@ -939,6 +967,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
939
967
|
readonly timestamp: string;
|
|
940
968
|
readonly hash: string;
|
|
941
969
|
readonly skip: number;
|
|
970
|
+
readonly error?: string | undefined;
|
|
942
971
|
} | {
|
|
943
972
|
readonly type: "PRUNE";
|
|
944
973
|
readonly input: {
|
|
@@ -971,6 +1000,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
971
1000
|
readonly timestamp: string;
|
|
972
1001
|
readonly hash: string;
|
|
973
1002
|
readonly skip: number;
|
|
1003
|
+
readonly error?: string | undefined;
|
|
974
1004
|
} | {
|
|
975
1005
|
readonly type: "REDO";
|
|
976
1006
|
readonly input: number;
|
|
@@ -1000,6 +1030,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1000
1030
|
readonly timestamp: string;
|
|
1001
1031
|
readonly hash: string;
|
|
1002
1032
|
readonly skip: number;
|
|
1033
|
+
readonly error?: string | undefined;
|
|
1003
1034
|
} | {
|
|
1004
1035
|
readonly type: "SET_NAME";
|
|
1005
1036
|
readonly input: string;
|
|
@@ -1029,6 +1060,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1029
1060
|
readonly timestamp: string;
|
|
1030
1061
|
readonly hash: string;
|
|
1031
1062
|
readonly skip: number;
|
|
1063
|
+
readonly error?: string | undefined;
|
|
1032
1064
|
} | {
|
|
1033
1065
|
readonly type: "UNDO";
|
|
1034
1066
|
readonly input: number;
|
|
@@ -1058,6 +1090,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1058
1090
|
readonly timestamp: string;
|
|
1059
1091
|
readonly hash: string;
|
|
1060
1092
|
readonly skip: number;
|
|
1093
|
+
readonly error?: string | undefined;
|
|
1061
1094
|
} | {
|
|
1062
1095
|
readonly type: "NOOP";
|
|
1063
1096
|
readonly input: unknown;
|
|
@@ -1087,11 +1120,13 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1087
1120
|
readonly timestamp: string;
|
|
1088
1121
|
readonly hash: string;
|
|
1089
1122
|
readonly skip: number;
|
|
1123
|
+
readonly error?: string | undefined;
|
|
1090
1124
|
} | import("immer").Immutable<A & {
|
|
1091
1125
|
index: number;
|
|
1092
1126
|
timestamp: string;
|
|
1093
1127
|
hash: string;
|
|
1094
1128
|
skip: number;
|
|
1129
|
+
error?: string | undefined;
|
|
1095
1130
|
}>)[];
|
|
1096
1131
|
};
|
|
1097
1132
|
/**
|
|
@@ -100,6 +100,8 @@ export type Operation<A extends Action = Action> = A & {
|
|
|
100
100
|
hash: string;
|
|
101
101
|
/** The number of operations skipped with this Operation */
|
|
102
102
|
skip: number;
|
|
103
|
+
/** Error message for a failed action */
|
|
104
|
+
error?: string;
|
|
103
105
|
};
|
|
104
106
|
/**
|
|
105
107
|
* The base attributes of a {@link Document}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-D6wRzEDN.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-JtuONOcD.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-D6wRzEDN.js"),r=require("./internal/index-B9gc2lPN.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
|
package/dist/node/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-B9gc2lPN.js"),o=require("./internal/index-JtuONOcD.js");require("./internal/object-D6wRzEDN.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./object-
|
|
1
|
+
"use strict";const e=require("./object-D6wRzEDN.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;
|
|
@@ -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-D6wRzEDN.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": "",
|
|
@@ -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"),m=require("zod"),pe=require("crypto"),lt=require("fs"),ce=require("https"),le=require("path"),zt=require("jszip"),Et=e=>e!=null,me=m.z.any().refine(e=>Et(e)),vt=m.z.enum(["LOAD_STATE"]),Tt=m.z.enum(["PRUNE"]),kt=m.z.enum(["REDO"]),_t=m.z.enum(["SET_NAME"]),At=m.z.enum(["UNDO"]);function ue(){return m.z.object({__typename:m.z.literal("Action").optional(),type:m.z.string()})}function X(){return m.z.literal("global").or(m.z.literal("local"))}function Dt(){return m.z.union([Nt(),It(),Pt(),Ft(),Rt()])}function fe(){return m.z.object({__typename:m.z.literal("DocumentFile").optional(),data:m.z.string(),extension:m.z.string().nullable(),fileName:m.z.string().nullable(),mimeType:m.z.string()})}function Nt(){return m.z.object({input:m.z.lazy(()=>gt()),type:vt,scope:X()})}function gt(){return m.z.object({operations:m.z.number(),state:m.z.lazy(()=>Mt())})}function Mt(){return m.z.object({data:m.z.unknown().nullish(),name:m.z.string()})}function de(){return m.z.object({__typename:m.z.literal("Operation").optional(),hash:m.z.string(),index:m.z.number(),timestamp:m.z.string().datetime(),type:m.z.string()})}function It(){return m.z.object({input:m.z.lazy(()=>ht()),type:Tt,scope:X()})}function ht(){return m.z.object({end:m.z.number().nullish(),start:m.z.number().nullish()})}const xt=m.z.number;function Pt(){return m.z.object({input:xt(),type:kt,scope:X()})}const yt=m.z.string;function Ft(){return m.z.object({input:yt(),type:_t,scope:m.z.literal("global")})}function ge(){return m.z.object({__typename:m.z.literal("SetNameOperation").optional(),hash:m.z.string(),index:m.z.number(),input:m.z.string(),timestamp:m.z.string().datetime(),type:m.z.string()})}const bt=m.z.number;function Rt(){return m.z.object({input:bt(),type:At,scope:X()})}const he=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:ue,BaseActionSchema:Dt,DocumentFileSchema:fe,LoadStateActionInputSchema:gt,LoadStateActionSchema:Nt,LoadStateActionStateInputSchema:Mt,Load_StateSchema:vt,OperationSchema:de,OperationScopeSchema:X,PruneActionInputSchema:ht,PruneActionSchema:It,PruneSchema:Tt,RedoActionInputSchema:xt,RedoActionSchema:Pt,RedoSchema:kt,SetNameActionInputSchema:yt,SetNameActionSchema:Ft,SetNameOperationSchema:ge,Set_NameSchema:_t,UndoActionInputSchema:bt,UndoActionSchema:Rt,UndoSchema:At,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=z();n.configure=z,n.stringify=n,n.default=n,t.stringify=n,t.configure=z,e.exports=n;const a=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function s(c){return c.length<5e3&&!a.test(c)?`"${c}"`:JSON.stringify(c)}function r(c){if(c.length>200)return c.sort();for(let u=1;u<c.length;u++){const b=c[u];let M=u;for(;M!==0&&c[M-1]>b;)c[M]=c[M-1],M--;c[M]=b}return c}const l=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function p(c){return l.call(c)!==void 0&&c.length!==0}function x(c,u,b){c.length<b&&(b=c.length);const M=u===","?"":" ";let B=`"0":${M}${c[0]}`;for(let R=1;R<b;R++)B+=`${u}"${R}":${M}${c[R]}`;return B}function y(c){if(i.call(c,"circularValue")){const u=c.circularValue;if(typeof u=="string")return`"${u}"`;if(u==null)return u;if(u===Error||u===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 E(c,u){let b;if(i.call(c,u)&&(b=c[u],typeof b!="boolean"))throw new TypeError(`The "${u}" argument must be of type boolean`);return b===void 0?!0:b}function h(c,u){let b;if(i.call(c,u)){if(b=c[u],typeof b!="number")throw new TypeError(`The "${u}" argument must be of type number`);if(!Number.isInteger(b))throw new TypeError(`The "${u}" argument must be an integer`);if(b<1)throw new RangeError(`The "${u}" argument must be >= 1`)}return b===void 0?1/0:b}function S(c){return c===1?"1 item":`${c} items`}function $(c){const u=new Set;for(const b of c)(typeof b=="string"||typeof b=="number")&&u.add(String(b));return u}function D(c){if(i.call(c,"strict")){const u=c.strict;if(typeof u!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(u)return b=>{let M=`Object can not safely be stringified. Received type ${typeof b}`;throw typeof b!="function"&&(M+=` (${b.toString()})`),new Error(M)}}}function z(c){c={...c};const u=D(c);u&&(c.bigint===void 0&&(c.bigint=!1),"circularValue"in c||(c.circularValue=Error));const b=y(c),M=E(c,"bigint"),B=E(c,"deterministic"),R=h(c,"maximumDepth"),k=h(c,"maximumBreadth");function et(I,o,f,w,g,O){let d=o[I];switch(typeof d=="object"&&d!==null&&typeof d.toJSON=="function"&&(d=d.toJSON(I)),d=w.call(o,I,d),typeof d){case"string":return s(d);case"object":{if(d===null)return"null";if(f.indexOf(d)!==-1)return b;let j="",T=",";const _=O;if(Array.isArray(d)){if(d.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(d),g!==""&&(O+=g,j+=`
|
|
2
|
+
${O}`,T=`,
|
|
3
|
+
${O}`);const F=Math.min(d.length,k);let J=0;for(;J<F-1;J++){const nt=et(String(J),d,f,w,g,O);j+=nt!==void 0?nt:"null",j+=T}const C=et(String(J),d,f,w,g,O);if(j+=C!==void 0?C:"null",d.length-1>k){const nt=d.length-k-1;j+=`${T}"... ${S(nt)} not stringified"`}return g!==""&&(j+=`
|
|
4
|
+
${_}`),f.pop(),`[${j}]`}let A=Object.keys(d);const N=A.length;if(N===0)return"{}";if(R<f.length+1)return'"[Object]"';let v="",P="";g!==""&&(O+=g,T=`,
|
|
5
|
+
${O}`,v=" ");const L=Math.min(N,k);B&&!p(d)&&(A=r(A)),f.push(d);for(let F=0;F<L;F++){const J=A[F],C=et(J,d,f,w,g,O);C!==void 0&&(j+=`${P}${s(J)}:${v}${C}`,P=T)}if(N>k){const F=N-k;j+=`${P}"...":${v}"${S(F)} not stringified"`,P=T}return g!==""&&P.length>1&&(j=`
|
|
6
|
+
${O}${j}
|
|
7
|
+
${_}`),f.pop(),`{${j}}`}case"number":return isFinite(d)?String(d):u?u(d):"null";case"boolean":return d===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(d);default:return u?u(d):void 0}}function it(I,o,f,w,g,O){switch(typeof o=="object"&&o!==null&&typeof o.toJSON=="function"&&(o=o.toJSON(I)),typeof o){case"string":return s(o);case"object":{if(o===null)return"null";if(f.indexOf(o)!==-1)return b;const d=O;let j="",T=",";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),g!==""&&(O+=g,j+=`
|
|
8
|
+
${O}`,T=`,
|
|
9
|
+
${O}`);const N=Math.min(o.length,k);let v=0;for(;v<N-1;v++){const L=it(String(v),o[v],f,w,g,O);j+=L!==void 0?L:"null",j+=T}const P=it(String(v),o[v],f,w,g,O);if(j+=P!==void 0?P:"null",o.length-1>k){const L=o.length-k-1;j+=`${T}"... ${S(L)} not stringified"`}return g!==""&&(j+=`
|
|
10
|
+
${d}`),f.pop(),`[${j}]`}f.push(o);let _="";g!==""&&(O+=g,T=`,
|
|
11
|
+
${O}`,_=" ");let A="";for(const N of w){const v=it(N,o[N],f,w,g,O);v!==void 0&&(j+=`${A}${s(N)}:${_}${v}`,A=T)}return g!==""&&A.length>1&&(j=`
|
|
12
|
+
${O}${j}
|
|
13
|
+
${d}`),f.pop(),`{${j}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(o);default:return u?u(o):void 0}}function W(I,o,f,w,g){switch(typeof o){case"string":return s(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(I),typeof o!="object")return W(I,o,f,w,g);if(o===null)return"null"}if(f.indexOf(o)!==-1)return b;const O=g;if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),g+=w;let v=`
|
|
14
|
+
${g}`;const P=`,
|
|
15
|
+
${g}`,L=Math.min(o.length,k);let F=0;for(;F<L-1;F++){const C=W(String(F),o[F],f,w,g);v+=C!==void 0?C:"null",v+=P}const J=W(String(F),o[F],f,w,g);if(v+=J!==void 0?J:"null",o.length-1>k){const C=o.length-k-1;v+=`${P}"... ${S(C)} not stringified"`}return v+=`
|
|
16
|
+
${O}`,f.pop(),`[${v}]`}let d=Object.keys(o);const j=d.length;if(j===0)return"{}";if(R<f.length+1)return'"[Object]"';g+=w;const T=`,
|
|
17
|
+
${g}`;let _="",A="",N=Math.min(j,k);p(o)&&(_+=x(o,T,k),d=d.slice(o.length),N-=o.length,A=T),B&&(d=r(d)),f.push(o);for(let v=0;v<N;v++){const P=d[v],L=W(P,o[P],f,w,g);L!==void 0&&(_+=`${A}${s(P)}: ${L}`,A=T)}if(j>k){const v=j-k;_+=`${A}"...": "${S(v)} not stringified"`,A=T}return A!==""&&(_=`
|
|
18
|
+
${g}${_}
|
|
19
|
+
${O}`),f.pop(),`{${_}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(o);default:return u?u(o):void 0}}function Z(I,o,f){switch(typeof o){case"string":return s(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(I),typeof o!="object")return Z(I,o,f);if(o===null)return"null"}if(f.indexOf(o)!==-1)return b;let w="";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o);const T=Math.min(o.length,k);let _=0;for(;_<T-1;_++){const N=Z(String(_),o[_],f);w+=N!==void 0?N:"null",w+=","}const A=Z(String(_),o[_],f);if(w+=A!==void 0?A:"null",o.length-1>k){const N=o.length-k-1;w+=`,"... ${S(N)} not stringified"`}return f.pop(),`[${w}]`}let g=Object.keys(o);const O=g.length;if(O===0)return"{}";if(R<f.length+1)return'"[Object]"';let d="",j=Math.min(O,k);p(o)&&(w+=x(o,",",k),g=g.slice(o.length),j-=o.length,d=","),B&&(g=r(g)),f.push(o);for(let T=0;T<j;T++){const _=g[T],A=Z(_,o[_],f);A!==void 0&&(w+=`${d}${s(_)}:${A}`,d=",")}if(O>k){const T=O-k;w+=`${d}"...":"${S(T)} not stringified"`}return f.pop(),`{${w}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(o);default:return u?u(o):void 0}}function re(I,o,f){if(arguments.length>1){let w="";if(typeof f=="number"?w=" ".repeat(Math.min(f,10)):typeof f=="string"&&(w=f.slice(0,10)),o!=null){if(typeof o=="function")return et("",{"":I},[],o,w,"");if(Array.isArray(o))return it("",I,[],$(o),w,"")}if(w.length!==0)return W("",I,[],w,"")}return Z("",I,[])}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,s=>{const[r]=s.document.operations[a].slice(-1);t.skip&&t.skip>0&&(s.skip=t.skip),r.type==="NOOP"&&t.index===r.index&&s.skip>r.skip&&s.document.operations[a].pop()})}function je(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return U.produce(s,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),p=l.type==="NOOP"&&l.skip>0;if(r.skip+=a,p){r.skip+=l.skip;const h=r.document.operations[n][r.document.operations[n].length-2];h&&l.index-h.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 y=a,E=p?x-l.skip:x;for(;y>0&&E>=0;){const h=r.document.operations[n][E];if(!h){y--,E--;continue}h.type==="NOOP"&&h.skip>0?(E=E-(h.skip+1),r.skip+=h.skip+1):(r.document.clipboard.push({...h}),y--,E--)}r.action=St(n)})}function Oe(e,t,i){const{scope:n,input:a}=t,s={document:e,action:t,skip:i};return U.produce(s,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 p=r.document.clipboard.splice(l,1)[0];r.action=U.castDraft({type:p.type,scope:p.scope,input:p.input})})}function Se(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:s,end:r}}=t;s=s||0,r=r||a.length;const l=a.slice(s,r),p=a.slice(0,s),x=a.slice(r),y=st(e.initialState,{...e.operations,[n]:p.concat(l)},i),{name:E,state:h}=y,S=p.length,$=p.length?p[p.length-1].timestamp:x.length?x[0].timestamp:new Date().toISOString();return st(e.initialState,{...e.operations,[n]:[...p,{...Ot({name:E,state:h},l.length),timestamp:$,index:S,hash:ct({state:h},"global")},...x.map((D,z)=>({...D,index:S+z+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]),s=[...a].pop();let r=((s==null?void 0:s.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,error:void 0}),{...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(Dt().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:s,ignoreSkipOperations:r=!1,reuseHash:l=!1}=a;let p={...t},x=s||0,y=e,E=[...e.clipboard];if(Ut(p)){const{document:h,skip:S}=we(y,p,x);x=S,y=h}if(ut(p)){const{skip:h,action:S,document:$}=Jt(e,p,x);p=S,x=h,y=$,E=[...y.clipboard]}if(ft(p)&&(y=_e(y,p,i)),x>0&&!r){let h=x;"index"in p&&(h=Wt(y.operations[p.scope],p.index,x)),y=st(y.initialState,y.operations,i,void 0,void 0,void 0,{[p.scope]:h})}return y=ke(y,p,x),y=U.produce(y,h=>{try{const S=i(h.state,p,n),$=ut(t)?[...E]:[];if(S)return U.castDraft({...y,clipboard:[...$],state:S});h.clipboard=U.castDraft([...$])}catch(S){const $=y.operations[p.scope].length-1;h.operations[p.scope][$].error=S.message,console.error(`Error thrown in reducer. Action: ${JSON.stringify(p)}, Error:`,S)}}),U.produce(y,h=>{if([Y,tt,at].includes(p.type))return h;const S=p.scope||"global",$=l&&Object.prototype.hasOwnProperty.call(p,"hash")?p.hash:ct(h,S);h.operations[S][h.operations[S].length-1].hash=$,!ft(p)&&p.attachments&&p.attachments.forEach(D=>{const{hash:z,...c}=D;h.attachments[z]={...c}})})}function Ae(e,t,i){const n=le.join(e,t);return lt.mkdirSync(e,{recursive:!0}),new Promise((a,s)=>{try{lt.writeFile(n,i,{},r=>{r?s(r):a(n)})}catch(r){s(r)}})}function Ct(e){return lt.readFileSync(e)}function De(e){return new Promise((t,i)=>{ce.get(e,n=>{const a=[],s=n.headers["content-type"];n.on("data",r=>{a.push(r)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:s})})}).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 K(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 s={type:e,input:t,scope:a};i&&(s.attachments=i);try{n==null||n().parse(s.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return s}function Vt(e,t=wt){return(i,n,a,s)=>t(i,n,e,a,s)}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 s=[];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},p=r.skip>0?r.skip+1:0;if(p>0&&p>n){const x=p-n;n=n+x}a=r.index,s.push(l)}return s.reverse()}function Wt(e,t,i){const n=e.slice().sort((l,p)=>l.skip-p.skip).sort((l,p)=>l.index-p.index);let a=i,s=0,r=t;for(const l of n.reverse()){const p=r-l.index;if(a=a-p,a>-1)s++,r=l.index;else break}return s}function Ie(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,s=wt,r={},l){const p=Vt(i,s);return jt(e,t,p,n,a,r,l)}function jt(e,t,i,n,a,s={},r){const l=(r==null?void 0:r.checkHashes)??!0,p=Bt(e),x=Object.keys(t).reduce(($,D)=>{const z=D;return{...$,[z]:Ht(t[z],s[z])}},{}),y=Zt(x),E=y.reduce(($,{ignore:D,operation:z})=>D?i($,St(z.scope),n,{skip:z.skip,ignoreSkipOperations:!0}):i($,z,n,{skip:z.skip,ignoreSkipOperations:!0,reuseHash:!l}),p);if(!l)for(const $ of Object.keys(E.state))for(let D=y.length-1;D>=0;D--){const{ignore:z,operation:c}=y[D];if(!(z||c.scope!==$)){if(c.hash!==ct(E,$))throw new Error(`Hash mismatch for scope ${$}`);break}}const h=Object.keys(E.operations).reduce(($,D)=>{const z=D;return{...$,[z]:[...E.operations[z].map((c,u)=>{var b;return{...c,timestamp:((b=t[z][u])==null?void 0:b.timestamp)??c.timestamp}})]}},{global:[],local:[]}),S=Object.values(h).reduce(($,D)=>{const z=D[D.length-1];return(z==null?void 0:z.timestamp)>$&&($=z.timestamp),$},e.lastModified);return{...E,operations:h,lastModified:S}}function Pe(e,t){return rt(e)===rt(t)}const Gt=e=>K("SET_NAME",e,void 0,yt,void 0),Qt=(e=1,t="global")=>K("UNDO",e,void 0,bt,t),Xt=(e=1,t="global")=>K("REDO",e,void 0,xt,t),Yt=(e,t,i="global")=>K("PRUNE",{start:e,end:t},void 0,ht,i),Ot=(e,t)=>K("LOAD_STATE",{state:e,operations:t},void 0,gt),St=(e="global")=>K("NOOP",{},void 0,void 0,e),Fe=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,V;class Re{constructor(...t){H.set(this,new Map),Q.set(this,new Map),V.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,V,"f").has(n)||q(this,V,"f").set(n,new Set);const s=q(this,V,"f").get(n);let r=!0;for(let l of a){const p=l.startsWith("*");if(l=p?l.slice(1):l,s==null||s.add(l),r&&q(this,Q,"f").set(n,l),r=!1,p)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,V,"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,V,"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,V=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((s,r)=>s.index-r.index);for(let s=0;s<a.length;s++)a[s].index!==s&&t.push({message:`Invalid operation index ${a[s].index} at position ${s}`,details:{position:s,operation:a[s],scope:a[s].scope}})}return t}const $t=async e=>{const t=new zt,{name:i,revision:n,documentType:a,created:s,lastModified:r}=e,l={name:i,revision:n,documentType:a,created:s,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:y,...E}=e.attachments[x];t.file(x,y,{base64:!0,createFolders:!0,comment:JSON.stringify(E)})}),t},ie=async(e,t,i,n)=>{const s=await(await $t(e)).generateAsync({type:"uint8array",streamFiles:!0}),r=n??e.name,l=`.${i}.zip`;return Ae(t,r.endsWith(l)?r:`${r}${l}`,s)},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"),s=JSON.parse(a),r=e.file("header.json");let l;r&&(l=JSON.parse(await r.async("string")));const p=e.file("operations.json");if(!p)throw new Error("Operations history not found");const x=JSON.parse(await p.async("string")),y=ee(x);if(y.length){const h=y.map(S=>S.message);throw new Error(h.join(`
|
|
20
|
+
`))}let E=jt(s,x,t,void 0,l,{},i);return l&&(E={...E,...l}),E}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 De(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=Fe;exports.BaseDocument=Ve;exports.applyMixins=Ke;exports.baseReducer=wt;exports.calculateSkipsLeft=Wt;exports.createAction=K;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=Pe;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=Ie;exports.validateOperations=ee;exports.zod=he;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-BxC3xMqY.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-BclkoIYP.js";
|
|
9
9
|
import "zod";
|
|
10
10
|
export {
|
|
11
11
|
p as Document,
|
package/dist/node/es/document.js
CHANGED
|
@@ -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-BxC3xMqY.js";
|
|
2
|
+
import { i as B } from "./internal/index-EY0PPZnJ.js";
|
|
3
3
|
import "immer";
|
|
4
4
|
import "zod";
|
|
5
5
|
import "crypto";
|
package/dist/node/es/index.js
CHANGED
|
@@ -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-EY0PPZnJ.js";
|
|
2
|
+
import { D as t } from "./internal/index-BclkoIYP.js";
|
|
3
|
+
import "./internal/object-BxC3xMqY.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-BxC3xMqY.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-BxC3xMqY.js";
|
|
2
2
|
const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
calculateSkipsLeft: e,
|