document-model 1.1.0-experimental.1 → 1.1.0-experimental.2
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/browser/cjs/internal/{index-DypcJuba.js → index-DLodkpOq.js} +1 -1
- package/dist/browser/cjs/internal/index-azT4DEce.js +1 -0
- package/dist/browser/cjs/internal/{object-BU2CI8g7.js → object-CMr-_AP8.js} +21 -21
- 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-BzNpRs2a.js +44 -0
- package/dist/browser/es/internal/{index-CyBZ1dJQ.js → index-CL_1ivGq.js} +1 -1
- package/dist/browser/es/internal/{object-CPDHmXxz.js → object-FFc9n_3I.js} +917 -840
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +6 -0
- package/dist/browser/src/document/utils/base.d.ts +5 -4
- package/dist/browser/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/browser/src/document/utils/index.d.ts +1 -1
- 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/node/cjs/internal/{index-Bt4KwBzM.js → index-CPeTtUsk.js} +1 -1
- package/dist/node/cjs/internal/index-CTavCc1t.js +1 -0
- package/dist/node/cjs/internal/object-DhI24-1e.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-8lUz8qED.js +44 -0
- package/dist/node/es/internal/{index-6nUwJlFL.js → index-A880In4b.js} +1 -1
- package/dist/node/es/internal/{object-DofGWMf1.js → object-C9n9Ijnt.js} +675 -598
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +6 -0
- package/dist/node/src/document/utils/base.d.ts +5 -4
- package/dist/node/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/node/src/document/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/browser/cjs/internal/index-DZx9eknf.js +0 -1
- package/dist/browser/es/internal/index-BP3Z2ZVF.js +0 -43
- package/dist/node/cjs/internal/index-CwTTSCCW.js +0 -1
- package/dist/node/cjs/internal/object-Bc_eSRcx.js +0 -20
- package/dist/node/es/internal/index-CLgAZiia.js +0 -43
|
@@ -89,6 +89,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
89
89
|
readonly hash: string;
|
|
90
90
|
readonly skip: number;
|
|
91
91
|
readonly error?: string | undefined;
|
|
92
|
+
readonly resultingState?: unknown;
|
|
92
93
|
} | {
|
|
93
94
|
readonly type: "PRUNE";
|
|
94
95
|
readonly input: {
|
|
@@ -122,6 +123,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
122
123
|
readonly hash: string;
|
|
123
124
|
readonly skip: number;
|
|
124
125
|
readonly error?: string | undefined;
|
|
126
|
+
readonly resultingState?: unknown;
|
|
125
127
|
} | {
|
|
126
128
|
readonly type: "REDO";
|
|
127
129
|
readonly input: number;
|
|
@@ -152,6 +154,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
152
154
|
readonly hash: string;
|
|
153
155
|
readonly skip: number;
|
|
154
156
|
readonly error?: string | undefined;
|
|
157
|
+
readonly resultingState?: unknown;
|
|
155
158
|
} | {
|
|
156
159
|
readonly type: "SET_NAME";
|
|
157
160
|
readonly input: string;
|
|
@@ -182,6 +185,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
182
185
|
readonly hash: string;
|
|
183
186
|
readonly skip: number;
|
|
184
187
|
readonly error?: string | undefined;
|
|
188
|
+
readonly resultingState?: unknown;
|
|
185
189
|
} | {
|
|
186
190
|
readonly type: "UNDO";
|
|
187
191
|
readonly input: number;
|
|
@@ -212,6 +216,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
212
216
|
readonly hash: string;
|
|
213
217
|
readonly skip: number;
|
|
214
218
|
readonly error?: string | undefined;
|
|
219
|
+
readonly resultingState?: unknown;
|
|
215
220
|
} | {
|
|
216
221
|
readonly type: "NOOP";
|
|
217
222
|
readonly input: unknown;
|
|
@@ -242,12 +247,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
242
247
|
readonly hash: string;
|
|
243
248
|
readonly skip: number;
|
|
244
249
|
readonly error?: string | undefined;
|
|
250
|
+
readonly resultingState?: unknown;
|
|
245
251
|
} | import("immer").Immutable<A & {
|
|
246
252
|
index: number;
|
|
247
253
|
timestamp: string;
|
|
248
254
|
hash: string;
|
|
249
255
|
skip: number;
|
|
250
256
|
error?: string | undefined;
|
|
257
|
+
resultingState?: unknown;
|
|
251
258
|
}>)[];
|
|
252
259
|
readonly local: readonly ({
|
|
253
260
|
readonly type: "LOAD_STATE";
|
|
@@ -285,6 +292,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
285
292
|
readonly hash: string;
|
|
286
293
|
readonly skip: number;
|
|
287
294
|
readonly error?: string | undefined;
|
|
295
|
+
readonly resultingState?: unknown;
|
|
288
296
|
} | {
|
|
289
297
|
readonly type: "PRUNE";
|
|
290
298
|
readonly input: {
|
|
@@ -318,6 +326,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
318
326
|
readonly hash: string;
|
|
319
327
|
readonly skip: number;
|
|
320
328
|
readonly error?: string | undefined;
|
|
329
|
+
readonly resultingState?: unknown;
|
|
321
330
|
} | {
|
|
322
331
|
readonly type: "REDO";
|
|
323
332
|
readonly input: number;
|
|
@@ -348,6 +357,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
348
357
|
readonly hash: string;
|
|
349
358
|
readonly skip: number;
|
|
350
359
|
readonly error?: string | undefined;
|
|
360
|
+
readonly resultingState?: unknown;
|
|
351
361
|
} | {
|
|
352
362
|
readonly type: "SET_NAME";
|
|
353
363
|
readonly input: string;
|
|
@@ -378,6 +388,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
378
388
|
readonly hash: string;
|
|
379
389
|
readonly skip: number;
|
|
380
390
|
readonly error?: string | undefined;
|
|
391
|
+
readonly resultingState?: unknown;
|
|
381
392
|
} | {
|
|
382
393
|
readonly type: "UNDO";
|
|
383
394
|
readonly input: number;
|
|
@@ -408,6 +419,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
408
419
|
readonly hash: string;
|
|
409
420
|
readonly skip: number;
|
|
410
421
|
readonly error?: string | undefined;
|
|
422
|
+
readonly resultingState?: unknown;
|
|
411
423
|
} | {
|
|
412
424
|
readonly type: "NOOP";
|
|
413
425
|
readonly input: unknown;
|
|
@@ -438,12 +450,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
438
450
|
readonly hash: string;
|
|
439
451
|
readonly skip: number;
|
|
440
452
|
readonly error?: string | undefined;
|
|
453
|
+
readonly resultingState?: unknown;
|
|
441
454
|
} | import("immer").Immutable<A & {
|
|
442
455
|
index: number;
|
|
443
456
|
timestamp: string;
|
|
444
457
|
hash: string;
|
|
445
458
|
skip: number;
|
|
446
459
|
error?: string | undefined;
|
|
460
|
+
resultingState?: unknown;
|
|
447
461
|
}>)[];
|
|
448
462
|
};
|
|
449
463
|
/**
|
|
@@ -553,6 +567,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
553
567
|
readonly hash: string;
|
|
554
568
|
readonly skip: number;
|
|
555
569
|
readonly error?: string | undefined;
|
|
570
|
+
readonly resultingState?: unknown;
|
|
556
571
|
} | {
|
|
557
572
|
readonly type: "PRUNE";
|
|
558
573
|
readonly input: {
|
|
@@ -586,6 +601,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
586
601
|
readonly hash: string;
|
|
587
602
|
readonly skip: number;
|
|
588
603
|
readonly error?: string | undefined;
|
|
604
|
+
readonly resultingState?: unknown;
|
|
589
605
|
} | {
|
|
590
606
|
readonly type: "REDO";
|
|
591
607
|
readonly input: number;
|
|
@@ -616,6 +632,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
616
632
|
readonly hash: string;
|
|
617
633
|
readonly skip: number;
|
|
618
634
|
readonly error?: string | undefined;
|
|
635
|
+
readonly resultingState?: unknown;
|
|
619
636
|
} | {
|
|
620
637
|
readonly type: "SET_NAME";
|
|
621
638
|
readonly input: string;
|
|
@@ -646,6 +663,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
646
663
|
readonly hash: string;
|
|
647
664
|
readonly skip: number;
|
|
648
665
|
readonly error?: string | undefined;
|
|
666
|
+
readonly resultingState?: unknown;
|
|
649
667
|
} | {
|
|
650
668
|
readonly type: "UNDO";
|
|
651
669
|
readonly input: number;
|
|
@@ -676,6 +694,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
676
694
|
readonly hash: string;
|
|
677
695
|
readonly skip: number;
|
|
678
696
|
readonly error?: string | undefined;
|
|
697
|
+
readonly resultingState?: unknown;
|
|
679
698
|
} | {
|
|
680
699
|
readonly type: "NOOP";
|
|
681
700
|
readonly input: unknown;
|
|
@@ -706,12 +725,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
706
725
|
readonly hash: string;
|
|
707
726
|
readonly skip: number;
|
|
708
727
|
readonly error?: string | undefined;
|
|
728
|
+
readonly resultingState?: unknown;
|
|
709
729
|
} | import("immer").Immutable<A & {
|
|
710
730
|
index: number;
|
|
711
731
|
timestamp: string;
|
|
712
732
|
hash: string;
|
|
713
733
|
skip: number;
|
|
714
734
|
error?: string | undefined;
|
|
735
|
+
resultingState?: unknown;
|
|
715
736
|
}>)[];
|
|
716
737
|
readonly local: readonly ({
|
|
717
738
|
readonly type: "LOAD_STATE";
|
|
@@ -749,6 +770,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
749
770
|
readonly hash: string;
|
|
750
771
|
readonly skip: number;
|
|
751
772
|
readonly error?: string | undefined;
|
|
773
|
+
readonly resultingState?: unknown;
|
|
752
774
|
} | {
|
|
753
775
|
readonly type: "PRUNE";
|
|
754
776
|
readonly input: {
|
|
@@ -782,6 +804,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
782
804
|
readonly hash: string;
|
|
783
805
|
readonly skip: number;
|
|
784
806
|
readonly error?: string | undefined;
|
|
807
|
+
readonly resultingState?: unknown;
|
|
785
808
|
} | {
|
|
786
809
|
readonly type: "REDO";
|
|
787
810
|
readonly input: number;
|
|
@@ -812,6 +835,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
812
835
|
readonly hash: string;
|
|
813
836
|
readonly skip: number;
|
|
814
837
|
readonly error?: string | undefined;
|
|
838
|
+
readonly resultingState?: unknown;
|
|
815
839
|
} | {
|
|
816
840
|
readonly type: "SET_NAME";
|
|
817
841
|
readonly input: string;
|
|
@@ -842,6 +866,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
842
866
|
readonly hash: string;
|
|
843
867
|
readonly skip: number;
|
|
844
868
|
readonly error?: string | undefined;
|
|
869
|
+
readonly resultingState?: unknown;
|
|
845
870
|
} | {
|
|
846
871
|
readonly type: "UNDO";
|
|
847
872
|
readonly input: number;
|
|
@@ -872,6 +897,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
872
897
|
readonly hash: string;
|
|
873
898
|
readonly skip: number;
|
|
874
899
|
readonly error?: string | undefined;
|
|
900
|
+
readonly resultingState?: unknown;
|
|
875
901
|
} | {
|
|
876
902
|
readonly type: "NOOP";
|
|
877
903
|
readonly input: unknown;
|
|
@@ -902,12 +928,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
902
928
|
readonly hash: string;
|
|
903
929
|
readonly skip: number;
|
|
904
930
|
readonly error?: string | undefined;
|
|
931
|
+
readonly resultingState?: unknown;
|
|
905
932
|
} | import("immer").Immutable<A & {
|
|
906
933
|
index: number;
|
|
907
934
|
timestamp: string;
|
|
908
935
|
hash: string;
|
|
909
936
|
skip: number;
|
|
910
937
|
error?: string | undefined;
|
|
938
|
+
resultingState?: unknown;
|
|
911
939
|
}>)[];
|
|
912
940
|
};
|
|
913
941
|
readonly initialState: {
|
|
@@ -968,6 +996,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
968
996
|
readonly hash: string;
|
|
969
997
|
readonly skip: number;
|
|
970
998
|
readonly error?: string | undefined;
|
|
999
|
+
readonly resultingState?: unknown;
|
|
971
1000
|
} | {
|
|
972
1001
|
readonly type: "PRUNE";
|
|
973
1002
|
readonly input: {
|
|
@@ -1001,6 +1030,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1001
1030
|
readonly hash: string;
|
|
1002
1031
|
readonly skip: number;
|
|
1003
1032
|
readonly error?: string | undefined;
|
|
1033
|
+
readonly resultingState?: unknown;
|
|
1004
1034
|
} | {
|
|
1005
1035
|
readonly type: "REDO";
|
|
1006
1036
|
readonly input: number;
|
|
@@ -1031,6 +1061,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1031
1061
|
readonly hash: string;
|
|
1032
1062
|
readonly skip: number;
|
|
1033
1063
|
readonly error?: string | undefined;
|
|
1064
|
+
readonly resultingState?: unknown;
|
|
1034
1065
|
} | {
|
|
1035
1066
|
readonly type: "SET_NAME";
|
|
1036
1067
|
readonly input: string;
|
|
@@ -1061,6 +1092,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1061
1092
|
readonly hash: string;
|
|
1062
1093
|
readonly skip: number;
|
|
1063
1094
|
readonly error?: string | undefined;
|
|
1095
|
+
readonly resultingState?: unknown;
|
|
1064
1096
|
} | {
|
|
1065
1097
|
readonly type: "UNDO";
|
|
1066
1098
|
readonly input: number;
|
|
@@ -1091,6 +1123,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1091
1123
|
readonly hash: string;
|
|
1092
1124
|
readonly skip: number;
|
|
1093
1125
|
readonly error?: string | undefined;
|
|
1126
|
+
readonly resultingState?: unknown;
|
|
1094
1127
|
} | {
|
|
1095
1128
|
readonly type: "NOOP";
|
|
1096
1129
|
readonly input: unknown;
|
|
@@ -1121,12 +1154,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1121
1154
|
readonly hash: string;
|
|
1122
1155
|
readonly skip: number;
|
|
1123
1156
|
readonly error?: string | undefined;
|
|
1157
|
+
readonly resultingState?: unknown;
|
|
1124
1158
|
} | import("immer").Immutable<A & {
|
|
1125
1159
|
index: number;
|
|
1126
1160
|
timestamp: string;
|
|
1127
1161
|
hash: string;
|
|
1128
1162
|
skip: number;
|
|
1129
1163
|
error?: string | undefined;
|
|
1164
|
+
resultingState?: unknown;
|
|
1130
1165
|
}>)[];
|
|
1131
1166
|
};
|
|
1132
1167
|
/**
|
|
@@ -52,6 +52,10 @@ export type ReducerOptions = {
|
|
|
52
52
|
ignoreSkipOperations?: boolean;
|
|
53
53
|
/** if true reuses the provided action hash */
|
|
54
54
|
reuseHash?: boolean;
|
|
55
|
+
/** if true reuses the provided action resulting state instead of replaying it */
|
|
56
|
+
reuseOperationResultingState?: boolean;
|
|
57
|
+
/** Optional parser for the operation resulting state, uses JSON.parse by default */
|
|
58
|
+
operationResultingStateParser?: (state: unknown) => object;
|
|
55
59
|
};
|
|
56
60
|
/**
|
|
57
61
|
* A pure function that takes an action and the previous state
|
|
@@ -102,6 +106,8 @@ export type Operation<A extends Action = Action> = A & {
|
|
|
102
106
|
skip: number;
|
|
103
107
|
/** Error message for a failed action */
|
|
104
108
|
error?: string;
|
|
109
|
+
/** The resulting state after the operation */
|
|
110
|
+
resultingState?: unknown;
|
|
105
111
|
};
|
|
106
112
|
/**
|
|
107
113
|
* The base attributes of a {@link Document}.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation } from '../types';
|
|
2
|
+
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation, ReducerOptions } from '../types';
|
|
3
3
|
import { SignalDispatch } from '../signal';
|
|
4
4
|
export declare function isNoopOperation(op: Partial<Operation>): boolean;
|
|
5
5
|
export declare function isUndoRedo(action: Action): action is UndoRedoAction;
|
|
@@ -74,12 +74,13 @@ export declare function mapSkippedOperations<A extends Action>(operations: Opera
|
|
|
74
74
|
export declare function calculateSkipsLeft<A extends Action>(operations: Operation<BaseAction | A>[], currentIndex: number, skip: number): number;
|
|
75
75
|
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
|
|
76
76
|
export declare function sortMappedOperations<A extends Action>(operations: DocumentOperationsIgnoreMap<A>): MappedOperation<A>[];
|
|
77
|
-
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, clearedOperations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?:
|
|
78
|
-
checkHashes?: boolean;
|
|
79
|
-
}): Document<T, A, L>;
|
|
77
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, clearedOperations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?: ReducerOptions): Document<T, A, L>;
|
|
80
78
|
export type SkipHeaderOperations = Partial<Record<OperationScope, number>>;
|
|
81
79
|
export type ReplayDocumentOptions = {
|
|
82
80
|
checkHashes?: boolean;
|
|
81
|
+
reuseOperationResultingState?: boolean;
|
|
82
|
+
operationResultingStateParser?: (state: unknown) => object;
|
|
83
83
|
};
|
|
84
84
|
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): Document<T, A, L>;
|
|
85
85
|
export declare function isSameDocument(documentA: Document, documentB: Document): boolean;
|
|
86
|
+
export declare function parseResultingState(state: unknown): object;
|
|
@@ -49,5 +49,5 @@ export type SkipHeaderOperationIndex = Partial<Pick<OperationIndex, 'index'>> &
|
|
|
49
49
|
* @returns The remaining operations after skipping header operations.
|
|
50
50
|
*/
|
|
51
51
|
export declare function skipHeaderOperations<A extends OperationIndex>(operations: A[], skipHeaderOperation: SkipHeaderOperationIndex): A[];
|
|
52
|
-
export declare function
|
|
52
|
+
export declare function garbageCollectDocumentOperations<A extends Action>(documentOperations: DocumentOperations<A>): DocumentOperations<A>;
|
|
53
53
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './base';
|
|
2
|
-
export { createAction, createDocument, createExtendedState, createReducer, hashDocument, hashKey, isBaseAction, mapSkippedOperations, readOnly, replayDocument, replayOperations, sortMappedOperations, sortOperations, } from './base';
|
|
2
|
+
export { createAction, createDocument, createExtendedState, createReducer, hashDocument, hashKey, isBaseAction, mapSkippedOperations, parseResultingState, readOnly, replayDocument, replayOperations, sortMappedOperations, sortOperations, } from './base';
|
|
3
3
|
export * from './file';
|
|
4
4
|
export * from './validation';
|
|
5
5
|
export * as documentHelpers from './document-helpers';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-BU2CI8g7.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,documentHelpers:e.documentHelpers,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,43 +0,0 @@
|
|
|
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, q as p, i as d, r as u, t as m, u as O, l as y, e as b, v as D, w as F, x as S, y as _, s as f, d as g, z as v, A as h, C as j, B as x, h as z, g as R, D as A, E as B, F as M } from "./object-CPDHmXxz.js";
|
|
2
|
-
const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
calculateSkipsLeft: e,
|
|
5
|
-
createAction: a,
|
|
6
|
-
createDocument: s,
|
|
7
|
-
createExtendedState: o,
|
|
8
|
-
createReducer: t,
|
|
9
|
-
createZip: r,
|
|
10
|
-
documentHelpers: i,
|
|
11
|
-
getLocalFile: n,
|
|
12
|
-
getRemoteFile: c,
|
|
13
|
-
hashDocument: l,
|
|
14
|
-
hashKey: p,
|
|
15
|
-
isBaseAction: d,
|
|
16
|
-
isNoopOperation: u,
|
|
17
|
-
isSameDocument: m,
|
|
18
|
-
isUndoRedo: O,
|
|
19
|
-
loadFromFile: y,
|
|
20
|
-
loadFromInput: b,
|
|
21
|
-
mapSkippedOperations: D,
|
|
22
|
-
readOnly: F,
|
|
23
|
-
replayDocument: S,
|
|
24
|
-
replayOperations: _,
|
|
25
|
-
saveToFile: f,
|
|
26
|
-
saveToFileHandle: g,
|
|
27
|
-
sortMappedOperations: v,
|
|
28
|
-
sortOperations: h,
|
|
29
|
-
validateOperations: j
|
|
30
|
-
}, Symbol.toStringTag, { value: "Module" })), E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
31
|
-
__proto__: null,
|
|
32
|
-
BaseDocument: x,
|
|
33
|
-
actions: z,
|
|
34
|
-
applyMixins: R,
|
|
35
|
-
baseReducer: A,
|
|
36
|
-
processUndoRedo: B,
|
|
37
|
-
utils: T,
|
|
38
|
-
z: M
|
|
39
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
40
|
-
export {
|
|
41
|
-
E as D,
|
|
42
|
-
T as i
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-Bc_eSRcx.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,documentHelpers:e.documentHelpers,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,20 +0,0 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty;var fe=(t,e,n)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var at=(t,e,n)=>(fe(t,typeof e!="symbol"?e+"":e,n),n);const J=require("immer"),u=require("zod"),Tt=require("jszip"),de=require("crypto"),ft=require("fs"),ge=require("https"),he=require("path"),_t=t=>t!=null,xe=u.z.any().refine(t=>_t(t)),Nt=u.z.enum(["LOAD_STATE"]),vt=u.z.enum(["PRUNE"]),It=u.z.enum(["REDO"]),At=u.z.enum(["SET_NAME"]),Mt=u.z.enum(["UNDO"]);function ye(){return u.z.object({__typename:u.z.literal("Action").optional(),type:u.z.string()})}function et(){return u.z.literal("global").or(u.z.literal("local"))}function Pt(){return u.z.union([Ft(),qt(),Ct(),Lt(),Ut()])}function be(){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 Ft(){return u.z.object({input:u.z.lazy(()=>yt()),type:Nt,scope:et()})}function yt(){return u.z.object({operations:u.z.number(),state:u.z.lazy(()=>Rt())})}function Rt(){return u.z.object({data:u.z.unknown().nullish(),name:u.z.string()})}function we(){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 qt(){return u.z.object({input:u.z.lazy(()=>bt()),type:vt,scope:et()})}function bt(){return u.z.object({end:u.z.number().nullish(),start:u.z.number().nullish()})}const wt=u.z.number;function Ct(){return u.z.object({input:wt(),type:It,scope:et()})}const Ot=u.z.string;function Lt(){return u.z.object({input:Ot(),type:At,scope:u.z.literal("global")})}function Oe(){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 St=u.z.number;function Ut(){return u.z.object({input:St(),type:Mt,scope:et()})}const Se=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:ye,BaseActionSchema:Pt,DocumentFileSchema:be,LoadStateActionInputSchema:yt,LoadStateActionSchema:Ft,LoadStateActionStateInputSchema:Rt,Load_StateSchema:Nt,OperationSchema:we,OperationScopeSchema:et,PruneActionInputSchema:bt,PruneActionSchema:qt,PruneSchema:vt,RedoActionInputSchema:wt,RedoActionSchema:Ct,RedoSchema:It,SetNameActionInputSchema:Ot,SetNameActionSchema:Lt,SetNameOperationSchema:Oe,Set_NameSchema:At,UndoActionInputSchema:St,UndoActionSchema:Ut,UndoSchema:Mt,definedNonNullAnySchema:xe,isDefinedNonNullAny:_t},Symbol.toStringTag,{value:"Module"}));function je(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var dt={exports:{}};(function(t,e){const{hasOwnProperty:n}=Object.prototype,i=C();i.configure=C,i.stringify=i,i.default=i,e.stringify=i,e.configure=C,t.exports=i;const o=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function r(l){return l.length<5e3&&!o.test(l)?`"${l}"`:JSON.stringify(l)}function a(l){if(l.length>200)return l.sort();for(let m=1;m<l.length;m++){const S=l[m];let I=m;for(;I!==0&&l[I-1]>S;)l[I]=l[I-1],I--;l[I]=S}return l}const p=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(l){return p.call(l)!==void 0&&l.length!==0}function f(l,m,S){l.length<S&&(S=l.length);const I=m===","?"":" ";let K=`"0":${I}${l[0]}`;for(let F=1;F<S;F++)K+=`${m}"${F}":${I}${l[F]}`;return K}function x(l){if(n.call(l,"circularValue")){const m=l.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 E(l,m){let S;if(n.call(l,m)&&(S=l[m],typeof S!="boolean"))throw new TypeError(`The "${m}" argument must be of type boolean`);return S===void 0?!0:S}function w(l,m){let S;if(n.call(l,m)){if(S=l[m],typeof S!="number")throw new TypeError(`The "${m}" argument must be of type number`);if(!Number.isInteger(S))throw new TypeError(`The "${m}" argument must be an integer`);if(S<1)throw new RangeError(`The "${m}" argument must be >= 1`)}return S===void 0?1/0:S}function y(l){return l===1?"1 item":`${l} items`}function T(l){const m=new Set;for(const S of l)(typeof S=="string"||typeof S=="number")&&m.add(String(S));return m}function N(l){if(n.call(l,"strict")){const m=l.strict;if(typeof m!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(m)return S=>{let I=`Object can not safely be stringified. Received type ${typeof S}`;throw typeof S!="function"&&(I+=` (${S.toString()})`),new Error(I)}}}function C(l){l={...l};const m=N(l);m&&(l.bigint===void 0&&(l.bigint=!1),"circularValue"in l||(l.circularValue=Error));const S=x(l),I=E(l,"bigint"),K=E(l,"deterministic"),F=w(l,"maximumDepth"),k=w(l,"maximumBreadth");function ot(A,s,d,b,h,j){let g=s[A];switch(typeof g=="object"&&g!==null&&typeof g.toJSON=="function"&&(g=g.toJSON(A)),g=b.call(s,A,g),typeof g){case"string":return r(g);case"object":{if(g===null)return"null";if(d.indexOf(g)!==-1)return S;let O="",D=",";const z=j;if(Array.isArray(g)){if(g.length===0)return"[]";if(F<d.length+1)return'"[Array]"';d.push(g),h!==""&&(j+=h,O+=`
|
|
2
|
-
${j}`,D=`,
|
|
3
|
-
${j}`);const P=Math.min(g.length,k);let L=0;for(;L<P-1;L++){const rt=ot(String(L),g,d,b,h,j);O+=rt!==void 0?rt:"null",O+=D}const U=ot(String(L),g,d,b,h,j);if(O+=U!==void 0?U:"null",g.length-1>k){const rt=g.length-k-1;O+=`${D}"... ${y(rt)} not stringified"`}return h!==""&&(O+=`
|
|
4
|
-
${z}`),d.pop(),`[${O}]`}let _=Object.keys(g);const v=_.length;if(v===0)return"{}";if(F<d.length+1)return'"[Object]"';let $="",M="";h!==""&&(j+=h,D=`,
|
|
5
|
-
${j}`,$=" ");const q=Math.min(v,k);K&&!c(g)&&(_=a(_)),d.push(g);for(let P=0;P<q;P++){const L=_[P],U=ot(L,g,d,b,h,j);U!==void 0&&(O+=`${M}${r(L)}:${$}${U}`,M=D)}if(v>k){const P=v-k;O+=`${M}"...":${$}"${y(P)} not stringified"`,M=D}return h!==""&&M.length>1&&(O=`
|
|
6
|
-
${j}${O}
|
|
7
|
-
${z}`),d.pop(),`{${O}}`}case"number":return isFinite(g)?String(g):m?m(g):"null";case"boolean":return g===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(g);default:return m?m(g):void 0}}function st(A,s,d,b,h,j){switch(typeof s=="object"&&s!==null&&typeof s.toJSON=="function"&&(s=s.toJSON(A)),typeof s){case"string":return r(s);case"object":{if(s===null)return"null";if(d.indexOf(s)!==-1)return S;const g=j;let O="",D=",";if(Array.isArray(s)){if(s.length===0)return"[]";if(F<d.length+1)return'"[Array]"';d.push(s),h!==""&&(j+=h,O+=`
|
|
8
|
-
${j}`,D=`,
|
|
9
|
-
${j}`);const v=Math.min(s.length,k);let $=0;for(;$<v-1;$++){const q=st(String($),s[$],d,b,h,j);O+=q!==void 0?q:"null",O+=D}const M=st(String($),s[$],d,b,h,j);if(O+=M!==void 0?M:"null",s.length-1>k){const q=s.length-k-1;O+=`${D}"... ${y(q)} not stringified"`}return h!==""&&(O+=`
|
|
10
|
-
${g}`),d.pop(),`[${O}]`}d.push(s);let z="";h!==""&&(j+=h,D=`,
|
|
11
|
-
${j}`,z=" ");let _="";for(const v of b){const $=st(v,s[v],d,b,h,j);$!==void 0&&(O+=`${_}${r(v)}:${z}${$}`,_=D)}return h!==""&&_.length>1&&(O=`
|
|
12
|
-
${j}${O}
|
|
13
|
-
${g}`),d.pop(),`{${O}}`}case"number":return isFinite(s)?String(s):m?m(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(s);default:return m?m(s):void 0}}function Z(A,s,d,b,h){switch(typeof s){case"string":return r(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(A),typeof s!="object")return Z(A,s,d,b,h);if(s===null)return"null"}if(d.indexOf(s)!==-1)return S;const j=h;if(Array.isArray(s)){if(s.length===0)return"[]";if(F<d.length+1)return'"[Array]"';d.push(s),h+=b;let $=`
|
|
14
|
-
${h}`;const M=`,
|
|
15
|
-
${h}`,q=Math.min(s.length,k);let P=0;for(;P<q-1;P++){const U=Z(String(P),s[P],d,b,h);$+=U!==void 0?U:"null",$+=M}const L=Z(String(P),s[P],d,b,h);if($+=L!==void 0?L:"null",s.length-1>k){const U=s.length-k-1;$+=`${M}"... ${y(U)} not stringified"`}return $+=`
|
|
16
|
-
${j}`,d.pop(),`[${$}]`}let g=Object.keys(s);const O=g.length;if(O===0)return"{}";if(F<d.length+1)return'"[Object]"';h+=b;const D=`,
|
|
17
|
-
${h}`;let z="",_="",v=Math.min(O,k);c(s)&&(z+=f(s,D,k),g=g.slice(s.length),v-=s.length,_=D),K&&(g=a(g)),d.push(s);for(let $=0;$<v;$++){const M=g[$],q=Z(M,s[M],d,b,h);q!==void 0&&(z+=`${_}${r(M)}: ${q}`,_=D)}if(O>k){const $=O-k;z+=`${_}"...": "${y($)} not stringified"`,_=D}return _!==""&&(z=`
|
|
18
|
-
${h}${z}
|
|
19
|
-
${j}`),d.pop(),`{${z}}`}case"number":return isFinite(s)?String(s):m?m(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(s);default:return m?m(s):void 0}}function Q(A,s,d){switch(typeof s){case"string":return r(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(A),typeof s!="object")return Q(A,s,d);if(s===null)return"null"}if(d.indexOf(s)!==-1)return S;let b="";if(Array.isArray(s)){if(s.length===0)return"[]";if(F<d.length+1)return'"[Array]"';d.push(s);const D=Math.min(s.length,k);let z=0;for(;z<D-1;z++){const v=Q(String(z),s[z],d);b+=v!==void 0?v:"null",b+=","}const _=Q(String(z),s[z],d);if(b+=_!==void 0?_:"null",s.length-1>k){const v=s.length-k-1;b+=`,"... ${y(v)} not stringified"`}return d.pop(),`[${b}]`}let h=Object.keys(s);const j=h.length;if(j===0)return"{}";if(F<d.length+1)return'"[Object]"';let g="",O=Math.min(j,k);c(s)&&(b+=f(s,",",k),h=h.slice(s.length),O-=s.length,g=","),K&&(h=a(h)),d.push(s);for(let D=0;D<O;D++){const z=h[D],_=Q(z,s[z],d);_!==void 0&&(b+=`${g}${r(z)}:${_}`,g=",")}if(j>k){const D=j-k;b+=`${g}"...":"${y(D)} not stringified"`}return d.pop(),`{${b}}`}case"number":return isFinite(s)?String(s):m?m(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(s);default:return m?m(s):void 0}}function me(A,s,d){if(arguments.length>1){let b="";if(typeof d=="number"?b=" ".repeat(Math.min(d,10)):typeof d=="string"&&(b=d.slice(0,10)),s!=null){if(typeof s=="function")return ot("",{"":A},[],s,b,"");if(Array.isArray(s))return st("",A,[],T(s),b,"")}if(b.length!==0)return Z("",A,[],b,"")}return Q("",A,[])}return me}})(dt,dt.exports);var Ee=dt.exports;const G=je(Ee);G.configure;function $e(t,e){return{...t,name:e}}function De(t,e,n){const{scope:i,input:o}=e,r={document:t,action:e,skip:n};return J.produce(r,a=>{if(a.document.operations[i].length<1)throw new Error(`Cannot undo: no operations in history for scope "${i}"`);if(o<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(a.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const p=a.document.operations[i].at(-1),c=p&&p.type==="NOOP"&&p.skip>0;if(a.skip+=o,c){a.skip+=p.skip;const w=a.document.operations[i][a.document.operations[i].length-2];w&&p.index-w.index===1&&a.document.operations[i].pop()}if(a.document.operations[i].length<a.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const f=a.document.operations[i].length-1;let x=o,E=c?f-p.skip:f;for(;x>0&&E>=0;){const w=a.document.operations[i][E];if(!w){x--,E--;continue}w.type==="NOOP"&&w.skip>0?(E=E-(w.skip+1),a.skip+=w.skip+1):(a.document.clipboard.push({...w}),x--,E--)}a.action=le(i)})}function ke(t,e,n){const{scope:i,input:o}=e,r={document:t,action:e,skip:n};return J.produce(r,a=>{if(a.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(o>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(o<1)throw new Error("Invalid REDO action: invalid redo input value");if(a.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=a.document.clipboard.findLastIndex(f=>f.scope===i);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${i}"`);const c=a.document.clipboard.splice(p,1)[0];a.action=J.castDraft({type:c.type,scope:c.scope,input:c.input})})}function ze(t,e,n){const{scope:i}=e,o=t.operations[i];let{input:{start:r,end:a}}=e;r=r||0,a=a||o.length;const p=o.slice(r,a),c=o.slice(0,r),f=o.slice(a),x=pt(t.initialState,{...t.operations,[i]:c.concat(p)},n),{name:E,state:w}=x,y=c.length,T=c.length?c[c.length-1].timestamp:f.length?f[0].timestamp:new Date().toISOString();return pt(t.initialState,{...t.operations,[i]:[...c,{...zt({name:E,state:w},p.length),timestamp:T,index:y,hash:mt({state:w},"global")},...f.map((N,C)=>({...N,index:y+C+1}))]},n)}function Te(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const Jt="SET_NAME",nt="UNDO",it="REDO",ct="PRUNE",Ht="LOAD_STATE",_e="NOOP",Vt={"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(Vt);var R=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},W,Y,B;class Ne{constructor(...e){W.set(this,new Map),Y.set(this,new Map),B.set(this,new Map);for(const n of e)this.define(n)}define(e,n=!1){for(let[i,o]of Object.entries(e)){i=i.toLowerCase(),o=o.map(p=>p.toLowerCase()),R(this,B,"f").has(i)||R(this,B,"f").set(i,new Set);const r=R(this,B,"f").get(i);let a=!0;for(let p of o){const c=p.startsWith("*");if(p=c?p.slice(1):p,r==null||r.add(p),a&&R(this,Y,"f").set(i,p),a=!1,c)continue;const f=R(this,W,"f").get(p);if(f&&f!=i&&!n)throw new Error(`"${i} -> ${p}" conflicts with "${f} -> ${p}". Pass \`force=true\` to override this definition.`);R(this,W,"f").set(p,i)}}return this}getType(e){if(typeof e!="string")return null;const n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),o=n.length<e.length;return!(i.length<n.length-1)&&o?null:R(this,W,"f").get(i)??null}getExtension(e){var n;return typeof e!="string"?null:(e=(n=e==null?void 0:e.split)==null?void 0:n.call(e,";")[0],(e&&R(this,Y,"f").get(e.trim().toLowerCase()))??null)}getAllExtensions(e){return typeof e!="string"?null:R(this,B,"f").get(e.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 e of R(this,B,"f").values())Object.freeze(e);return this}_getTestState(){return{types:R(this,W,"f"),extensions:R(this,Y,"f")}}}W=new WeakMap,Y=new WeakMap,B=new WeakMap;const ve=new Ne(Vt)._freeze();function Ie(t,e,n){const i=he.join(t,e);return ft.mkdirSync(t,{recursive:!0}),new Promise((o,r)=>{try{ft.writeFile(i,n,{},a=>{a?r(a):o(i)})}catch(a){r(a)}})}function Bt(t){return ft.readFileSync(t)}function Ae(t){return new Promise((e,n)=>{ge.get(t,i=>{const o=[],r=i.headers["content-type"];i.on("data",a=>{o.push(a)}),i.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:r})})}).on("error",i=>{n(i)})})}const Me=async t=>Bt(t),lt=(t,e="sha1")=>de.createHash(e).update(t).digest("base64");function Xt(t){const e=[],n=Object.keys(t);for(const i of n){const o=t[i].sort((r,a)=>r.index-a.index);for(let r=0;r<o.length;r++)o[r].index!==r&&e.push({message:`Invalid operation index ${o[r].index} at position ${r}`,details:{position:r,operation:o[r],scope:o[r].scope}})}return e}const jt=async t=>{const e=new Tt,{name:n,revision:i,documentType:o,created:r,lastModified:a}=t,p={name:n,revision:i,documentType:o,created:r,lastModified:a};return e.file("header.json",JSON.stringify(p,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(f=>{const{data:x,...E}=t.attachments[f];e.file(f,x,{base64:!0,createFolders:!0,comment:JSON.stringify(E)})}),e},Kt=async(t,e,n,i)=>{const r=await(await jt(t)).generateAsync({type:"uint8array",streamFiles:!0}),a=i??t.name,p=`.${n}.zip`;return Ie(e,a.endsWith(p)?a:`${a}${p}`,r)},Pe=async(t,e)=>{const i=await(await jt(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(i),await o.close()},gt=async(t,e,n)=>{const i=Bt(t);return Wt(i,e,n)},Wt=async(t,e,n)=>{const i=new Tt;return await i.loadAsync(t),Fe(i,e,n)};async function Fe(t,e,n){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const o=await i.async("string"),r=JSON.parse(o),a=t.file("header.json");let p;a&&(p=JSON.parse(await a.async("string")));const c=t.file("operations.json");if(!c)throw new Error("Operations history not found");const f=JSON.parse(await c.async("string")),x=Xt(f);if(x.length){const w=x.map(y=>y.message);throw new Error(w.join(`
|
|
20
|
-
`))}let E=kt(r,f,e,void 0,p,{},n);return p&&(E={...E,...p}),E}function Gt(t){const e=t.replace(/^.*\./,"")||void 0,n=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:n}}async function Re(t){const{buffer:e,mimeType:n="application/octet-stream"}=await Ae(t),i=Gt(t),o=e.toString("base64");return{data:o,hash:lt(o),mimeType:n,...i}}async function qe(t){const e=await Me(t),n=ve.getType(t)||"application/octet-stream",i=Gt(t),o=e.toString("base64");return{data:o,hash:lt(o),mimeType:n,...i}}var Zt=(t=>(t.UNEXPECTED_INDEX="UNEXPECTED_INDEX",t))(Zt||{}),Qt=(t=>(t.DUPLICATED_INDEX="DUPLICATED_INDEX",t.MISSING_INDEX="MISSING_INDEX",t))(Qt||{});function Et(t){const e=[];let n=-1;for(const i of t){const o=i.index-i.skip;o!==n+1&&e.push({operation:{index:i.index,skip:i.skip},issue:"UNEXPECTED_INDEX",category:o>n+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${n+1} with skip 0 or equivalent, got index ${i.index} with skip ${i.skip}`}),n=i.index}return e}function H(t){var i,o,r;const e=[];let n=t.length-1;for(;n>-1;){e.unshift(t[n]);const a=(((i=t[n])==null?void 0:i.index)||0)-(((o=t[n])==null?void 0:o.skip)||0)-1;let p=n-1;for(;p>-1&&(((r=t[p])==null?void 0:r.index)||0)>a;)p--;n=p}return e}function Ce(t){const e=[...t],n=e[e.length-1];return n&&(n.type==="NOOP"?e.push({...n,index:n.index,type:"NOOP",skip:ee(t)}):e.push({type:"NOOP",index:n.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:n.scope,hash:n.hash})),e}function V(t){return t.slice().sort((e,n)=>e.skip-n.skip).sort((e,n)=>e.index-n.index)}const Le=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0})),Ue=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).sort((i,o)=>i.index-o.index).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0}));function $t(t,e){return G(t)===G(e)}function Je(t,e){const n=H(V(t.slice())),i=H(V(e.slice()));if(n.length<1)return[i,[]];const o=[];let r=!1;for(;i.length>0;){const a=i[0];let p=n.shift();for(;p&&Yt(p,a);)o.push(p),p=n.shift();if(p?r||($t(p,a)?(i.shift(),o.push(p)):(n.unshift(p),r=!0)):r=!0,r){let c=i.shift();for(;c;)o.push(c),c=i.shift()}}if(!r){let a=n.shift();for(;a;)o.push(a),a=n.shift()}return[H(o),n]}function Yt(t,e){return t.index<e.index||t.index===e.index&&t.skip<e.skip}function te(t,e){const n=[],i=[],o=[],r=Math.max(t.length,e.length);let a=!1;for(let p=0;p<r;p++){const c=t[p],f=e[p];c&&f?!a&&$t(c,f)?n.push(c):(a=!0,i.push(c),o.push(f)):c?i.push(c):f&&o.push(f)}return[n,i,o]}function He(t,e,n){const[i,o,r]=te(H(t),H(e)),a=ut(i),p=1+Math.max(a,ut(o),ut(r)),c=n({index:p,skip:p-(a+1)},o,r);return i.concat(c)}function ut(t){const e=t[t.length-1];return e?e.index:-1}function ee(t){var i,o,r;if(t.length<1)return-1;const e=H(t);let n=(((i=e[e.length-1])==null?void 0:i.skip)||0)+1;return e.length>1&&(n+=((o=e[e.length-2])==null?void 0:o.skip)||0),(((r=e[e.length-1])==null?void 0:r.index)||-1)<n?-1:n}const Ve=t=>Et(H(V(t))),Be=t=>t.reduce((n,i)=>{var o;return n[i.scope]||(n[i.scope]=[]),(o=n[i.scope])==null||o.push(i),n},{}),Xe=(t,e)=>{var c;const n={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},i=V(t),o=V(e),r=Et([...i,...o]),p=(c=[...r.filter(f=>f.category==="MISSING_INDEX")].sort((f,x)=>x.operation.index-f.operation.index).pop())==null?void 0:c.operation;for(const f of o){if(p&&f.index>=p.index){n.invalidOperations.push(f);continue}if(r.some(E=>E.operation.index===f.index&&E.operation.skip===f.skip&&E.category==="DUPLICATED_INDEX")){n.duplicatedOperations.push(f);continue}n.validOperations.push(f)}return n.integrityIssues.push(...r),n};function Ke(t,e){return t.filter(n=>!e.some(i=>n.type==="NOOP"&&n.skip===0&&n.index===i.index||n.index===i.index&&n.skip===i.skip&&n.scope===i.scope&&n.hash===i.hash&&n.type===i.type))}function ne(t,e){const[n]=V(t).slice(-1),i=(n==null?void 0:n.index)??-1,o=i+1,r={...e,index:e.index??o};if(r.index<i)throw new Error(`The skip header operation index must be greater than or equal to ${i}`);return(H(V([...t,r]))||[]).slice(0,-1)}function ht(t){return{...Object.entries(t).reduce((n,i)=>{const[o,r]=i;return{...n,[o]:H(V(r))}},{})}}const We=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:Qt,IntegrityIssueType:Zt,addUndo:Ce,attachBranch:Je,checkCleanedOperationsIntegrity:Et,checkOperationsIntegrity:Ve,garbageCollect:H,grabageCollectDocumentOperations:ht,groupOperationsByScope:Be,merge:He,nextSkipNumber:ee,operationsAreEqual:$t,precedes:Yt,prepareOperations:Xe,removeExistingOperations:Ke,reshuffleByTimestamp:Le,reshuffleByTimestampAndIndex:Ue,skipHeaderOperations:ne,sortOperations:V,split:te},Symbol.toStringTag,{value:"Module"}));function Ge(t,e){let n;return"index"in e?n={...e}:n=t.operations[e.scope].at(-1),((n==null?void 0:n.index)??-1)+1}function Ze(t,e){return{...t,revision:{...t.revision,[e.scope]:Ge(t,e)},lastModified:new Date().toISOString()}}function Qe(t,e,n=0){if([nt,it,ct].includes(e.type))return t;const{scope:i}=e,o=t.operations[i].slice(0,t.revision[i]),r=[...o].pop();let a=((r==null?void 0:r.index)??-1)+1;if("index"in e){if(e.index-n>a)throw new Error(`Missing operations: expected ${a} with skip 0 or equivalent, got index ${e.index} with skip ${n}`);a=e.index}return o.push({...e,index:a,timestamp:new Date().toISOString(),hash:"",scope:i,skip:n,error:void 0}),{...t,operations:{...t.operations,[i]:o}}}function Ye(t,e,n=0){let i=Qe(t,e,n);return i=Ze(i,e),i}function tn(t,e,n){switch(Pt().parse(e),e.type){case Jt:return $e(t,e.input);case ct:return ze(t,e,n);case Ht:return Te(t,e.input.state);default:return t}}function en(t,e,n){switch(e.type){case nt:return De(t,e,n);case it:return ke(t,e,n);default:return{document:t,action:e,skip:n}}}function nn(t,e,n,i){const o=e.scope,r=t.operations[o].at(-1);if(!r)return t;const a=ht({...t.operations,[o]:ne(t.operations[o],r)}),{state:p}=pt(t.initialState,a,n,void 0,void 0,void 0);return{...t,state:p,operations:ht({...t.operations})}}function Dt(t,e,n,i,o={}){const{skip:r,ignoreSkipOperations:a=!1,reuseHash:p=!1}=o,c={...e},f=r||0;let x={...t};const E=!a&&(f>0||"index"in c&&c.skip>0);return xt(c)&&(x=tn(x,c,n)),x=Ye(x,c,f),E&&(x=nn(x,c,n)),x=J.produce(x,w=>{try{const y=n(w.state,c,i);if(y)return J.castDraft({...x,state:y})}catch(y){const T=x.operations[c.scope].length-1;w.operations[c.scope][T].error=y.message,w.operations[c.scope][T].skip=0,E&&(w.state=J.castDraft({...t.state}),w.operations=J.castDraft({...t.operations,[c.scope]:[...t.operations[c.scope],{...w.operations[c.scope][T]}]}))}}),J.produce(x,w=>{if([nt,it,ct].includes(c.type))return w;const y=c.scope||"global",T=p&&Object.prototype.hasOwnProperty.call(c,"hash")?c.hash:mt(w,y);w.operations[y][w.operations[y].length-1].hash=T,!xt(c)&&c.attachments&&c.attachments.forEach(N=>{const{hash:C,...l}=N;w.attachments[C]={...l}})})}function on(t){return t.type===_e&&t.skip!==void 0&&t.skip>0&&t.hash!==void 0}function sn(t){return[nt,it].includes(t.type)}function xt(t){return[Jt,nt,it,ct,Ht].includes(t.type)}function X(t,e,n,i,o="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${JSON.stringify(t)}`);const r={type:t,input:e,scope:o};n&&(r.attachments=n);try{i==null||i().parse(r.input)}catch(a){throw new Error(`Invalid action input: ${a}`)}return r}function ie(t,e=Dt){return(n,i,o,r)=>e(n,i,t,o,r)}const oe=(t,e)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),se=(t,e)=>{const n=oe(t,e);return{...n,initialState:n,operations:{global:[],local:[]},clipboard:[]}},mt=(t,e="global")=>lt(G(t.state[e]||"")),rn=(t,e=1e3)=>{const n=Math.random()*e;return lt(`${(t??new Date).toISOString()}${n}`)};function tt(t){return J.castImmutable(J.freeze(t,!0))}function an(t,e){const n=[...t];let i=e||0,o=n.length>0?n[n.length-1].index:0;const r=[];for(const a of n.reverse()){if(i>0){const f=o-a.index;i-=f}if(i<0)throw new Error("Invalid operation index, missing operations");const p={ignore:i>0,operation:a},c=a.skip>0?a.skip+1:0;if(c>0&&c>i){const f=c-i;i=i+f}o=a.index,r.push(p)}return r.reverse()}function pn(t,e,n){const i=t.slice().sort((p,c)=>p.skip-c.skip).sort((p,c)=>p.index-c.index);let o=n,r=0,a=e;for(const p of i.reverse()){const c=a-p.index;if(o=o-c,o>-1)r++,a=p.index;else break}return r}function cn(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.timestamp).getTime()-new Date(n.timestamp).getTime())}function ln(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.operation.timestamp).getTime()-new Date(n.operation.timestamp).getTime())}function pt(t,e,n,i,o,r=Dt,a={},p){const c=ie(n,r);return kt(t,e,c,i,o,a,p)}function kt(t,e,n,i,o,r={},a){const p=(a==null?void 0:a.checkHashes)??!0,c=se(t),f=Object.values(e).flat(),x=f.reduce((y,T)=>n(y,T,i,{skip:T.skip,ignoreSkipOperations:!0,reuseHash:!p}),c);if(!p)for(const y of Object.keys(x.state))for(let T=f.length-1;T>=0;T--){const N=f[T];if(N.scope===y){if(N.hash!==mt(x,y))throw new Error(`Hash mismatch for scope ${y}`);break}}const E=Object.keys(x.operations).reduce((y,T)=>{const N=T;return{...y,[N]:[...x.operations[N].map((C,l)=>{var m;return{...C,timestamp:((m=e[N][l])==null?void 0:m.timestamp)??C.timestamp}})]}},{global:[],local:[]}),w=Object.values(E).reduce((y,T)=>{const N=T[T.length-1];return(N==null?void 0:N.timestamp)>y&&(y=N.timestamp),y},t.lastModified);return{...x,operations:E,lastModified:w}}function mn(t,e){return G(t)===G(e)}const re=t=>X("SET_NAME",t,void 0,Ot,void 0),ae=(t=1,e="global")=>X("UNDO",t,void 0,St,e),pe=(t=1,e="global")=>X("REDO",t,void 0,wt,e),ce=(t,e,n="global")=>X("PRUNE",{start:t,end:e},void 0,bt,n),zt=(t,e)=>X("LOAD_STATE",{state:t,operations:e},void 0,yt),le=(t="global")=>X("NOOP",{},void 0,void 0,t),un=Object.freeze(Object.defineProperty({__proto__:null,loadState:zt,noop:le,prune:ce,redo:pe,setName:re,undo:ae},Symbol.toStringTag,{value:"Module"}));class fn{constructor(e,n,i){at(this,"_document");at(this,"_reducer");at(this,"_signalDispatch");this._reducer=e,this._document=n,this._signalDispatch=i}dispatch(e,n){return this._document=this._reducer(this._document,e,this._signalDispatch,n),this}saveToFile(e,n,i){return Kt(this._document,e,n,i)}async loadFromFile(e){this._document=await gt(e,this._reducer)}static async stateFromFile(e,n){return await gt(e,n)}get state(){return tt(this._document.state)}get operations(){return tt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(e){return this._document.revision[e]}get initialState(){return tt(this._document.initialState)}toDocument(){return tt(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(re(e)),this}undo(e){return this.dispatch(ae(e)),this}redo(e){return this.dispatch(pe(e)),this}prune(e,n){return this.dispatch(ce(e,n)),this}loadState(e,n){return this.dispatch(zt(e,n)),this}}function dn(t,e){e.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(i=>{Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(n.prototype,i)||Object.create(null))})})}exports.BaseActions=un;exports.BaseDocument=fn;exports.applyMixins=dn;exports.baseReducer=Dt;exports.calculateSkipsLeft=pn;exports.createAction=X;exports.createDocument=se;exports.createExtendedState=oe;exports.createReducer=ie;exports.createZip=jt;exports.documentHelpers=We;exports.getLocalFile=qe;exports.getRemoteFile=Re;exports.hashDocument=mt;exports.hashKey=rn;exports.isBaseAction=xt;exports.isNoopOperation=on;exports.isSameDocument=mn;exports.isUndoRedo=sn;exports.loadFromFile=gt;exports.loadFromInput=Wt;exports.mapSkippedOperations=an;exports.processUndoRedo=en;exports.readOnly=tt;exports.replayDocument=kt;exports.replayOperations=pt;exports.saveToFile=Kt;exports.saveToFileHandle=Pe;exports.sortMappedOperations=ln;exports.sortOperations=cn;exports.validateOperations=Xt;exports.zod=Se;
|
|
@@ -1,43 +0,0 @@
|
|
|
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, q as p, i as d, r as u, t as m, u as O, l as y, e as b, v as D, w as F, x as S, y as _, s as f, d as g, z as v, A as h, C as j, B as x, h as z, g as R, D as A, E as B, F as M } from "./object-DofGWMf1.js";
|
|
2
|
-
const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
calculateSkipsLeft: e,
|
|
5
|
-
createAction: a,
|
|
6
|
-
createDocument: s,
|
|
7
|
-
createExtendedState: o,
|
|
8
|
-
createReducer: t,
|
|
9
|
-
createZip: r,
|
|
10
|
-
documentHelpers: i,
|
|
11
|
-
getLocalFile: n,
|
|
12
|
-
getRemoteFile: c,
|
|
13
|
-
hashDocument: l,
|
|
14
|
-
hashKey: p,
|
|
15
|
-
isBaseAction: d,
|
|
16
|
-
isNoopOperation: u,
|
|
17
|
-
isSameDocument: m,
|
|
18
|
-
isUndoRedo: O,
|
|
19
|
-
loadFromFile: y,
|
|
20
|
-
loadFromInput: b,
|
|
21
|
-
mapSkippedOperations: D,
|
|
22
|
-
readOnly: F,
|
|
23
|
-
replayDocument: S,
|
|
24
|
-
replayOperations: _,
|
|
25
|
-
saveToFile: f,
|
|
26
|
-
saveToFileHandle: g,
|
|
27
|
-
sortMappedOperations: v,
|
|
28
|
-
sortOperations: h,
|
|
29
|
-
validateOperations: j
|
|
30
|
-
}, Symbol.toStringTag, { value: "Module" })), E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
31
|
-
__proto__: null,
|
|
32
|
-
BaseDocument: x,
|
|
33
|
-
actions: z,
|
|
34
|
-
applyMixins: R,
|
|
35
|
-
baseReducer: A,
|
|
36
|
-
processUndoRedo: B,
|
|
37
|
-
utils: T,
|
|
38
|
-
z: M
|
|
39
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
40
|
-
export {
|
|
41
|
-
E as D,
|
|
42
|
-
T as i
|
|
43
|
-
};
|