document-model 1.1.0-experimental.4 → 1.1.0-experimental.5
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/CHANGELOG.md +7 -0
- package/dist/browser/cjs/document-model.js +21 -1
- package/dist/browser/cjs/document-model.js.map +1 -0
- package/dist/browser/cjs/document.js +18 -1
- package/dist/browser/cjs/document.js.map +1 -0
- package/dist/browser/cjs/index.js +18 -1
- package/dist/browser/cjs/index.js.map +1 -0
- package/dist/browser/cjs/internal/index-1o9ymQ-0.js +2339 -0
- package/dist/browser/cjs/internal/index-1o9ymQ-0.js.map +1 -0
- package/dist/browser/cjs/internal/index-BUtd0hAV.js +49 -0
- package/dist/browser/cjs/internal/index-BUtd0hAV.js.map +1 -0
- package/dist/browser/cjs/internal/object-D19DRCyd.js +4351 -0
- package/dist/browser/cjs/internal/object-D19DRCyd.js.map +1 -0
- package/dist/browser/es/document-model.js +16 -15
- package/dist/browser/es/document-model.js.map +1 -0
- package/dist/browser/es/document.js +13 -11
- package/dist/browser/es/document.js.map +1 -0
- package/dist/browser/es/index.js +13 -11
- package/dist/browser/es/index.js.map +1 -0
- package/dist/browser/es/internal/index-Chr1cTqP.js +50 -0
- package/dist/browser/es/internal/index-Chr1cTqP.js.map +1 -0
- package/dist/browser/es/internal/index-D-FR4sw9.js +2340 -0
- package/dist/browser/es/internal/index-D-FR4sw9.js.map +1 -0
- package/dist/browser/es/internal/object-BXimXhmt.js +4352 -0
- package/dist/browser/es/internal/object-BXimXhmt.js.map +1 -0
- package/dist/browser/src/document/actions/index.d.ts +2 -2
- package/dist/browser/src/document/object.d.ts +55 -5
- package/dist/browser/src/document/reducer.d.ts +13 -0
- package/dist/browser/src/document/types.d.ts +4 -0
- package/dist/browser/src/document/utils/base.d.ts +4 -3
- package/dist/browser/src/document/utils/document-helpers.d.ts +9 -0
- package/dist/node/cjs/document-model.js +25 -1
- package/dist/node/cjs/document-model.js.map +1 -0
- package/dist/node/cjs/document.js +22 -1
- package/dist/node/cjs/document.js.map +1 -0
- package/dist/node/cjs/index.js +22 -1
- package/dist/node/cjs/index.js.map +1 -0
- package/dist/node/cjs/internal/index-CPkAfk27.js +49 -0
- package/dist/node/cjs/internal/index-CPkAfk27.js.map +1 -0
- package/dist/node/cjs/internal/index-Vr62psRC.js +2343 -0
- package/dist/node/cjs/internal/index-Vr62psRC.js.map +1 -0
- package/dist/node/cjs/internal/object-Bur9CrCb.js +2353 -0
- package/dist/node/cjs/internal/object-Bur9CrCb.js.map +1 -0
- package/dist/node/es/document-model.js +15 -14
- package/dist/node/es/document-model.js.map +1 -0
- package/dist/node/es/document.js +13 -11
- package/dist/node/es/document.js.map +1 -0
- package/dist/node/es/index.js +13 -11
- package/dist/node/es/index.js.map +1 -0
- package/dist/node/es/internal/index-C1HCcE55.js +2344 -0
- package/dist/node/es/internal/index-C1HCcE55.js.map +1 -0
- package/dist/node/es/internal/index-CWmk_0Sq.js +50 -0
- package/dist/node/es/internal/index-CWmk_0Sq.js.map +1 -0
- package/dist/node/es/internal/object-BqsV7nYl.js +2354 -0
- package/dist/node/es/internal/object-BqsV7nYl.js.map +1 -0
- package/dist/node/src/document/actions/index.d.ts +2 -2
- package/dist/node/src/document/object.d.ts +55 -5
- package/dist/node/src/document/reducer.d.ts +13 -0
- package/dist/node/src/document/types.d.ts +4 -0
- package/dist/node/src/document/utils/base.d.ts +4 -3
- package/dist/node/src/document/utils/document-helpers.d.ts +9 -0
- package/dist/src/document/object.d.ts +55 -5
- package/dist/src/document/reducer.d.ts +13 -0
- package/dist/src/document/types.d.ts +4 -0
- package/dist/src/document/utils/base.d.ts +2 -1
- package/dist/src/document/utils/document-helpers.d.ts +9 -0
- package/package.json +3 -1
- package/dist/browser/cjs/internal/index-BLpgsifL.js +0 -1
- package/dist/browser/cjs/internal/index-BTG_-qY6.js +0 -22
- package/dist/browser/cjs/internal/object-BHB7lY3H.js +0 -25
- package/dist/browser/es/internal/index-2Qq00NLA.js +0 -46
- package/dist/browser/es/internal/index-BD2hB9El.js +0 -2104
- package/dist/browser/es/internal/object-BW-G4r5m.js +0 -2798
- package/dist/node/cjs/internal/index-B31DqWHj.js +0 -1
- package/dist/node/cjs/internal/index-BBm_wnUa.js +0 -22
- package/dist/node/cjs/internal/object-CxVzP-Xe.js +0 -20
- package/dist/node/es/internal/index-BPCSW4M1.js +0 -2108
- package/dist/node/es/internal/index-C7I4OGkU.js +0 -46
- package/dist/node/es/internal/object-C-_SkpQ0.js +0 -1696
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, Document,
|
|
1
|
+
import { Action, Document, Operation, PruneAction, RedoAction, State, StateReducer, UndoAction, UndoRedoProcessResult } from '../types';
|
|
2
2
|
export declare function setNameOperation<T>(document: T, name: string): T;
|
|
3
3
|
export declare function noopOperation<T, A extends Action, L>(document: Document<T, A, L>, action: Partial<Operation>, skip: number): {
|
|
4
4
|
skip: number;
|
|
@@ -6,7 +6,7 @@ export declare function noopOperation<T, A extends Action, L>(document: Document
|
|
|
6
6
|
};
|
|
7
7
|
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
8
8
|
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
9
|
-
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer:
|
|
9
|
+
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer: StateReducer<T, A, L>): Document<T, A, L>;
|
|
10
10
|
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
11
11
|
name: string;
|
|
12
12
|
state?: State<T, L>;
|
|
@@ -90,6 +90,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
90
90
|
readonly skip: number;
|
|
91
91
|
readonly error?: string | undefined;
|
|
92
92
|
readonly resultingState?: unknown;
|
|
93
|
+
readonly id?: string | undefined;
|
|
93
94
|
} | {
|
|
94
95
|
readonly type: "PRUNE";
|
|
95
96
|
readonly input: {
|
|
@@ -124,6 +125,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
124
125
|
readonly skip: number;
|
|
125
126
|
readonly error?: string | undefined;
|
|
126
127
|
readonly resultingState?: unknown;
|
|
128
|
+
readonly id?: string | undefined;
|
|
127
129
|
} | {
|
|
128
130
|
readonly type: "REDO";
|
|
129
131
|
readonly input: number;
|
|
@@ -155,6 +157,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
155
157
|
readonly skip: number;
|
|
156
158
|
readonly error?: string | undefined;
|
|
157
159
|
readonly resultingState?: unknown;
|
|
160
|
+
readonly id?: string | undefined;
|
|
158
161
|
} | {
|
|
159
162
|
readonly type: "SET_NAME";
|
|
160
163
|
readonly input: string;
|
|
@@ -186,6 +189,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
186
189
|
readonly skip: number;
|
|
187
190
|
readonly error?: string | undefined;
|
|
188
191
|
readonly resultingState?: unknown;
|
|
192
|
+
readonly id?: string | undefined;
|
|
189
193
|
} | {
|
|
190
194
|
readonly type: "UNDO";
|
|
191
195
|
readonly input: number;
|
|
@@ -217,6 +221,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
217
221
|
readonly skip: number;
|
|
218
222
|
readonly error?: string | undefined;
|
|
219
223
|
readonly resultingState?: unknown;
|
|
224
|
+
readonly id?: string | undefined;
|
|
220
225
|
} | {
|
|
221
226
|
readonly type: "NOOP";
|
|
222
227
|
readonly input: unknown;
|
|
@@ -248,13 +253,18 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
248
253
|
readonly skip: number;
|
|
249
254
|
readonly error?: string | undefined;
|
|
250
255
|
readonly resultingState?: unknown;
|
|
256
|
+
readonly id?: string | undefined;
|
|
251
257
|
} | import("immer").Immutable<A & {
|
|
252
258
|
index: number;
|
|
253
259
|
timestamp: string;
|
|
254
260
|
hash: string;
|
|
255
|
-
skip: number;
|
|
261
|
+
skip: number; /**
|
|
262
|
+
* Reapplies a number of actions to the document.
|
|
263
|
+
* @param count - The number of actions to reapply.
|
|
264
|
+
*/
|
|
256
265
|
error?: string | undefined;
|
|
257
266
|
resultingState?: unknown;
|
|
267
|
+
id?: string | undefined;
|
|
258
268
|
}>)[];
|
|
259
269
|
readonly local: readonly ({
|
|
260
270
|
readonly type: "LOAD_STATE";
|
|
@@ -293,6 +303,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
293
303
|
readonly skip: number;
|
|
294
304
|
readonly error?: string | undefined;
|
|
295
305
|
readonly resultingState?: unknown;
|
|
306
|
+
readonly id?: string | undefined;
|
|
296
307
|
} | {
|
|
297
308
|
readonly type: "PRUNE";
|
|
298
309
|
readonly input: {
|
|
@@ -327,6 +338,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
327
338
|
readonly skip: number;
|
|
328
339
|
readonly error?: string | undefined;
|
|
329
340
|
readonly resultingState?: unknown;
|
|
341
|
+
readonly id?: string | undefined;
|
|
330
342
|
} | {
|
|
331
343
|
readonly type: "REDO";
|
|
332
344
|
readonly input: number;
|
|
@@ -358,6 +370,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
358
370
|
readonly skip: number;
|
|
359
371
|
readonly error?: string | undefined;
|
|
360
372
|
readonly resultingState?: unknown;
|
|
373
|
+
readonly id?: string | undefined;
|
|
361
374
|
} | {
|
|
362
375
|
readonly type: "SET_NAME";
|
|
363
376
|
readonly input: string;
|
|
@@ -389,6 +402,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
389
402
|
readonly skip: number;
|
|
390
403
|
readonly error?: string | undefined;
|
|
391
404
|
readonly resultingState?: unknown;
|
|
405
|
+
readonly id?: string | undefined;
|
|
392
406
|
} | {
|
|
393
407
|
readonly type: "UNDO";
|
|
394
408
|
readonly input: number;
|
|
@@ -420,6 +434,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
420
434
|
readonly skip: number;
|
|
421
435
|
readonly error?: string | undefined;
|
|
422
436
|
readonly resultingState?: unknown;
|
|
437
|
+
readonly id?: string | undefined;
|
|
423
438
|
} | {
|
|
424
439
|
readonly type: "NOOP";
|
|
425
440
|
readonly input: unknown;
|
|
@@ -451,13 +466,18 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
451
466
|
readonly skip: number;
|
|
452
467
|
readonly error?: string | undefined;
|
|
453
468
|
readonly resultingState?: unknown;
|
|
469
|
+
readonly id?: string | undefined;
|
|
454
470
|
} | import("immer").Immutable<A & {
|
|
455
471
|
index: number;
|
|
456
472
|
timestamp: string;
|
|
457
473
|
hash: string;
|
|
458
|
-
skip: number;
|
|
474
|
+
skip: number; /**
|
|
475
|
+
* Reapplies a number of actions to the document.
|
|
476
|
+
* @param count - The number of actions to reapply.
|
|
477
|
+
*/
|
|
459
478
|
error?: string | undefined;
|
|
460
479
|
resultingState?: unknown;
|
|
480
|
+
id?: string | undefined;
|
|
461
481
|
}>)[];
|
|
462
482
|
};
|
|
463
483
|
/**
|
|
@@ -568,6 +588,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
568
588
|
readonly skip: number;
|
|
569
589
|
readonly error?: string | undefined;
|
|
570
590
|
readonly resultingState?: unknown;
|
|
591
|
+
readonly id?: string | undefined;
|
|
571
592
|
} | {
|
|
572
593
|
readonly type: "PRUNE";
|
|
573
594
|
readonly input: {
|
|
@@ -602,6 +623,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
602
623
|
readonly skip: number;
|
|
603
624
|
readonly error?: string | undefined;
|
|
604
625
|
readonly resultingState?: unknown;
|
|
626
|
+
readonly id?: string | undefined;
|
|
605
627
|
} | {
|
|
606
628
|
readonly type: "REDO";
|
|
607
629
|
readonly input: number;
|
|
@@ -633,6 +655,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
633
655
|
readonly skip: number;
|
|
634
656
|
readonly error?: string | undefined;
|
|
635
657
|
readonly resultingState?: unknown;
|
|
658
|
+
readonly id?: string | undefined;
|
|
636
659
|
} | {
|
|
637
660
|
readonly type: "SET_NAME";
|
|
638
661
|
readonly input: string;
|
|
@@ -664,6 +687,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
664
687
|
readonly skip: number;
|
|
665
688
|
readonly error?: string | undefined;
|
|
666
689
|
readonly resultingState?: unknown;
|
|
690
|
+
readonly id?: string | undefined;
|
|
667
691
|
} | {
|
|
668
692
|
readonly type: "UNDO";
|
|
669
693
|
readonly input: number;
|
|
@@ -695,6 +719,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
695
719
|
readonly skip: number;
|
|
696
720
|
readonly error?: string | undefined;
|
|
697
721
|
readonly resultingState?: unknown;
|
|
722
|
+
readonly id?: string | undefined;
|
|
698
723
|
} | {
|
|
699
724
|
readonly type: "NOOP";
|
|
700
725
|
readonly input: unknown;
|
|
@@ -726,13 +751,18 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
726
751
|
readonly skip: number;
|
|
727
752
|
readonly error?: string | undefined;
|
|
728
753
|
readonly resultingState?: unknown;
|
|
754
|
+
readonly id?: string | undefined;
|
|
729
755
|
} | import("immer").Immutable<A & {
|
|
730
756
|
index: number;
|
|
731
757
|
timestamp: string;
|
|
732
758
|
hash: string;
|
|
733
|
-
skip: number;
|
|
759
|
+
skip: number; /**
|
|
760
|
+
* Reapplies a number of actions to the document.
|
|
761
|
+
* @param count - The number of actions to reapply.
|
|
762
|
+
*/
|
|
734
763
|
error?: string | undefined;
|
|
735
764
|
resultingState?: unknown;
|
|
765
|
+
id?: string | undefined;
|
|
736
766
|
}>)[];
|
|
737
767
|
readonly local: readonly ({
|
|
738
768
|
readonly type: "LOAD_STATE";
|
|
@@ -771,6 +801,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
771
801
|
readonly skip: number;
|
|
772
802
|
readonly error?: string | undefined;
|
|
773
803
|
readonly resultingState?: unknown;
|
|
804
|
+
readonly id?: string | undefined;
|
|
774
805
|
} | {
|
|
775
806
|
readonly type: "PRUNE";
|
|
776
807
|
readonly input: {
|
|
@@ -805,6 +836,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
805
836
|
readonly skip: number;
|
|
806
837
|
readonly error?: string | undefined;
|
|
807
838
|
readonly resultingState?: unknown;
|
|
839
|
+
readonly id?: string | undefined;
|
|
808
840
|
} | {
|
|
809
841
|
readonly type: "REDO";
|
|
810
842
|
readonly input: number;
|
|
@@ -836,6 +868,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
836
868
|
readonly skip: number;
|
|
837
869
|
readonly error?: string | undefined;
|
|
838
870
|
readonly resultingState?: unknown;
|
|
871
|
+
readonly id?: string | undefined;
|
|
839
872
|
} | {
|
|
840
873
|
readonly type: "SET_NAME";
|
|
841
874
|
readonly input: string;
|
|
@@ -867,6 +900,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
867
900
|
readonly skip: number;
|
|
868
901
|
readonly error?: string | undefined;
|
|
869
902
|
readonly resultingState?: unknown;
|
|
903
|
+
readonly id?: string | undefined;
|
|
870
904
|
} | {
|
|
871
905
|
readonly type: "UNDO";
|
|
872
906
|
readonly input: number;
|
|
@@ -898,6 +932,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
898
932
|
readonly skip: number;
|
|
899
933
|
readonly error?: string | undefined;
|
|
900
934
|
readonly resultingState?: unknown;
|
|
935
|
+
readonly id?: string | undefined;
|
|
901
936
|
} | {
|
|
902
937
|
readonly type: "NOOP";
|
|
903
938
|
readonly input: unknown;
|
|
@@ -929,13 +964,18 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
929
964
|
readonly skip: number;
|
|
930
965
|
readonly error?: string | undefined;
|
|
931
966
|
readonly resultingState?: unknown;
|
|
967
|
+
readonly id?: string | undefined;
|
|
932
968
|
} | import("immer").Immutable<A & {
|
|
933
969
|
index: number;
|
|
934
970
|
timestamp: string;
|
|
935
971
|
hash: string;
|
|
936
|
-
skip: number;
|
|
972
|
+
skip: number; /**
|
|
973
|
+
* Reapplies a number of actions to the document.
|
|
974
|
+
* @param count - The number of actions to reapply.
|
|
975
|
+
*/
|
|
937
976
|
error?: string | undefined;
|
|
938
977
|
resultingState?: unknown;
|
|
978
|
+
id?: string | undefined;
|
|
939
979
|
}>)[];
|
|
940
980
|
};
|
|
941
981
|
readonly initialState: {
|
|
@@ -997,6 +1037,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
997
1037
|
readonly skip: number;
|
|
998
1038
|
readonly error?: string | undefined;
|
|
999
1039
|
readonly resultingState?: unknown;
|
|
1040
|
+
readonly id?: string | undefined;
|
|
1000
1041
|
} | {
|
|
1001
1042
|
readonly type: "PRUNE";
|
|
1002
1043
|
readonly input: {
|
|
@@ -1031,6 +1072,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1031
1072
|
readonly skip: number;
|
|
1032
1073
|
readonly error?: string | undefined;
|
|
1033
1074
|
readonly resultingState?: unknown;
|
|
1075
|
+
readonly id?: string | undefined;
|
|
1034
1076
|
} | {
|
|
1035
1077
|
readonly type: "REDO";
|
|
1036
1078
|
readonly input: number;
|
|
@@ -1062,6 +1104,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1062
1104
|
readonly skip: number;
|
|
1063
1105
|
readonly error?: string | undefined;
|
|
1064
1106
|
readonly resultingState?: unknown;
|
|
1107
|
+
readonly id?: string | undefined;
|
|
1065
1108
|
} | {
|
|
1066
1109
|
readonly type: "SET_NAME";
|
|
1067
1110
|
readonly input: string;
|
|
@@ -1093,6 +1136,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1093
1136
|
readonly skip: number;
|
|
1094
1137
|
readonly error?: string | undefined;
|
|
1095
1138
|
readonly resultingState?: unknown;
|
|
1139
|
+
readonly id?: string | undefined;
|
|
1096
1140
|
} | {
|
|
1097
1141
|
readonly type: "UNDO";
|
|
1098
1142
|
readonly input: number;
|
|
@@ -1124,6 +1168,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1124
1168
|
readonly skip: number;
|
|
1125
1169
|
readonly error?: string | undefined;
|
|
1126
1170
|
readonly resultingState?: unknown;
|
|
1171
|
+
readonly id?: string | undefined;
|
|
1127
1172
|
} | {
|
|
1128
1173
|
readonly type: "NOOP";
|
|
1129
1174
|
readonly input: unknown;
|
|
@@ -1155,13 +1200,18 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1155
1200
|
readonly skip: number;
|
|
1156
1201
|
readonly error?: string | undefined;
|
|
1157
1202
|
readonly resultingState?: unknown;
|
|
1203
|
+
readonly id?: string | undefined;
|
|
1158
1204
|
} | import("immer").Immutable<A & {
|
|
1159
1205
|
index: number;
|
|
1160
1206
|
timestamp: string;
|
|
1161
1207
|
hash: string;
|
|
1162
|
-
skip: number;
|
|
1208
|
+
skip: number; /**
|
|
1209
|
+
* Reapplies a number of actions to the document.
|
|
1210
|
+
* @param count - The number of actions to reapply.
|
|
1211
|
+
*/
|
|
1163
1212
|
error?: string | undefined;
|
|
1164
1213
|
resultingState?: unknown;
|
|
1214
|
+
id?: string | undefined;
|
|
1165
1215
|
}>)[];
|
|
1166
1216
|
};
|
|
1167
1217
|
/**
|
|
@@ -57,4 +57,17 @@ export declare function baseReducer<T, A extends Action, L>(document: Document<T
|
|
|
57
57
|
initialState: import("./types").ExtendedState<T, L>;
|
|
58
58
|
clipboard: Operation<BaseAction | A>[];
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Base document reducer that wraps a custom document reducer and handles
|
|
62
|
+
* document-level actions such as undo, redo, prune, and set name.
|
|
63
|
+
*
|
|
64
|
+
* @template T - The type of the state of the custom reducer.
|
|
65
|
+
* @template A - The type of the actions of the custom reducer.
|
|
66
|
+
* @param state - The current state of the document.
|
|
67
|
+
* @param action - The action object to apply to the state.
|
|
68
|
+
* @param customReducer - The custom reducer that implements the application logic
|
|
69
|
+
* specific to the document's state.
|
|
70
|
+
* @returns The new state of the document.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mutableBaseReducer<T, A extends Action, L>(document: Document<T, A, L>, action: A | BaseAction | Operation, customReducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, options?: ReducerOptions): Document<T, A, L>;
|
|
60
73
|
export {};
|
|
@@ -79,6 +79,8 @@ export type Reducer<State, A extends Action, LocalState> = (state: Document<Stat
|
|
|
79
79
|
*/
|
|
80
80
|
export type ImmutableReducer<State, A extends Action, LocalState> = (state: Draft<Document<State, A, LocalState>>, action: A | BaseAction, dispatch?: SignalDispatch) => Document<State, A, LocalState> | undefined;
|
|
81
81
|
export type ImmutableStateReducer<S, A extends Action, L = unknown> = (state: Draft<State<S, L>>, action: A, dispatch?: SignalDispatch) => State<S, L> | undefined;
|
|
82
|
+
export type MutableStateReducer<S, A extends Action, L = unknown> = (state: State<S, L>, action: A, dispatch?: SignalDispatch) => State<S, L> | undefined;
|
|
83
|
+
export type StateReducer<S, A extends Action, L = unknown> = ImmutableStateReducer<S, A, L> | MutableStateReducer<S, A, L>;
|
|
82
84
|
/**
|
|
83
85
|
* Scope of an operation.
|
|
84
86
|
* Global: The operation is synchronized everywhere in the network. This is the default document operation.
|
|
@@ -108,6 +110,8 @@ export type Operation<A extends Action = Action> = A & {
|
|
|
108
110
|
error?: string;
|
|
109
111
|
/** The resulting state after the operation */
|
|
110
112
|
resultingState?: unknown;
|
|
113
|
+
/** Unique operation id */
|
|
114
|
+
id?: string;
|
|
111
115
|
};
|
|
112
116
|
/**
|
|
113
117
|
* The base attributes of a {@link Document}.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation, ReducerOptions } from '../types';
|
|
1
|
+
import { baseReducer, mutableBaseReducer } from '../reducer';
|
|
2
|
+
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation, ReducerOptions, StateReducer } 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;
|
|
@@ -46,6 +46,7 @@ export declare function createAction<A extends Action>(type: A['type'], input?:
|
|
|
46
46
|
* @returns The new reducer.
|
|
47
47
|
*/
|
|
48
48
|
export declare function createReducer<S = unknown, A extends Action = Action, L = unknown>(reducer: ImmutableStateReducer<S, A, L>, documentReducer?: typeof baseReducer): Reducer<S, A, L>;
|
|
49
|
+
export declare function createUnsafeReducer<S = unknown, A extends Action = Action, L = unknown>(reducer: ImmutableStateReducer<S, A, L>, documentReducer?: typeof mutableBaseReducer): Reducer<S, A, L>;
|
|
49
50
|
export declare const createExtendedState: <S, L>(initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>> | undefined, createState?: CreateState<S, L> | undefined) => ExtendedState<S, L>;
|
|
50
51
|
/**
|
|
51
52
|
* Builds the initial document state from the provided data.
|
|
@@ -74,7 +75,7 @@ export declare function mapSkippedOperations<A extends Action>(operations: Opera
|
|
|
74
75
|
export declare function calculateSkipsLeft<A extends Action>(operations: Operation<BaseAction | A>[], currentIndex: number, skip: number): number;
|
|
75
76
|
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
|
|
76
77
|
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:
|
|
78
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, clearedOperations: DocumentOperations<A>, reducer: StateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?: ReducerOptions): Document<T, A, L>;
|
|
78
79
|
export type SkipHeaderOperations = Partial<Record<OperationScope, number>>;
|
|
79
80
|
export type ReplayDocumentOptions = {
|
|
80
81
|
checkHashes?: boolean;
|
|
@@ -50,4 +50,13 @@ export type SkipHeaderOperationIndex = Partial<Pick<OperationIndex, 'index'>> &
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function skipHeaderOperations<A extends OperationIndex>(operations: A[], skipHeaderOperation: SkipHeaderOperationIndex): A[];
|
|
52
52
|
export declare function garbageCollectDocumentOperations<A extends Action>(documentOperations: DocumentOperations<A>): DocumentOperations<A>;
|
|
53
|
+
/**
|
|
54
|
+
* Filters out duplicated operations from the target operations array based on their IDs.
|
|
55
|
+
* If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.
|
|
56
|
+
* If an operation does not have an ID, it is considered unique and will not be filtered out.
|
|
57
|
+
* @param targetOperations - The array of target operations to filter.
|
|
58
|
+
* @param sourceOperations - The array of source operations to compare against.
|
|
59
|
+
* @returns An array of operations with duplicates filtered out.
|
|
60
|
+
*/
|
|
61
|
+
export declare function filterDuplicatedOperations(targetOperations: Operation[], sourceOperations: Operation[]): Operation[];
|
|
53
62
|
export {};
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./internal/object-Bur9CrCb.js");
|
|
4
|
+
require("immer");
|
|
5
|
+
require("jszip");
|
|
6
|
+
require("crypto");
|
|
7
|
+
require("fs");
|
|
8
|
+
require("https");
|
|
9
|
+
require("path");
|
|
10
|
+
const documentModel = require("./internal/index-Vr62psRC.js");
|
|
11
|
+
require("zod");
|
|
12
|
+
exports.Document = documentModel.Document;
|
|
13
|
+
exports.DocumentModel = documentModel.DocumentModel$1;
|
|
14
|
+
exports.actions = documentModel.actions;
|
|
15
|
+
exports.documentModel = documentModel.documentModel;
|
|
16
|
+
exports.module = documentModel.module;
|
|
17
|
+
exports.reducer = documentModel.reducer;
|
|
18
|
+
exports.utils = documentModel.utils;
|
|
19
|
+
exports.validateInitialState = documentModel.validateInitialState;
|
|
20
|
+
exports.validateModule = documentModel.validateModule;
|
|
21
|
+
exports.validateModuleOperation = documentModel.validateModuleOperation;
|
|
22
|
+
exports.validateModules = documentModel.validateModules;
|
|
23
|
+
exports.validateStateSchemaName = documentModel.validateStateSchemaName;
|
|
24
|
+
exports.z = documentModel.zod;
|
|
25
|
+
//# sourceMappingURL=document-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-model.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const object = require("./internal/object-Bur9CrCb.js");
|
|
4
|
+
const document = require("./internal/index-CPkAfk27.js");
|
|
5
|
+
require("immer");
|
|
6
|
+
require("zod");
|
|
7
|
+
require("jszip");
|
|
8
|
+
require("crypto");
|
|
9
|
+
require("fs");
|
|
10
|
+
require("https");
|
|
11
|
+
require("path");
|
|
12
|
+
exports.BaseDocument = object.BaseDocument;
|
|
13
|
+
exports.actions = object.BaseActions;
|
|
14
|
+
exports.applyMixins = object.applyMixins;
|
|
15
|
+
exports.baseReducer = object.baseReducer;
|
|
16
|
+
exports.mutableBaseReducer = object.mutableBaseReducer;
|
|
17
|
+
exports.processUndoRedo = object.processUndoRedo;
|
|
18
|
+
exports.updateDocument = object.updateDocument;
|
|
19
|
+
exports.updateHeader = object.updateHeader;
|
|
20
|
+
exports.z = object.zod;
|
|
21
|
+
exports.utils = document.index;
|
|
22
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/node/cjs/index.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const document = require("./internal/index-CPkAfk27.js");
|
|
4
|
+
const documentModel = require("./internal/index-Vr62psRC.js");
|
|
5
|
+
require("./internal/object-Bur9CrCb.js");
|
|
6
|
+
require("immer");
|
|
7
|
+
require("zod");
|
|
8
|
+
require("jszip");
|
|
9
|
+
require("crypto");
|
|
10
|
+
require("fs");
|
|
11
|
+
require("https");
|
|
12
|
+
require("path");
|
|
13
|
+
const DocumentModels = {
|
|
14
|
+
"powerhouse/document": document.Document,
|
|
15
|
+
"powerhouse/document-model": documentModel.DocumentModel
|
|
16
|
+
};
|
|
17
|
+
const index = { Document: document.Document, DocumentModel: documentModel.DocumentModel };
|
|
18
|
+
exports.Document = document.Document;
|
|
19
|
+
exports.DocumentModel = documentModel.DocumentModel;
|
|
20
|
+
exports.DocumentModels = DocumentModels;
|
|
21
|
+
exports.default = index;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":["import * as Document from './document';\nimport * as DocumentModel from './document-model';\n\n/**\n * This module exports all the public types, functions, and objects\n * from the document module. It provides an easy-to-use interface\n * for managing documents, and can be used in any Redux-based\n * application. This module exports:\n * - All action creators for the base document actions.\n * - The Document object, which is used to for creating and\n * manipulating documents in an object-oriented way.\n * - The baseReducer function, which is a reducer for managing\n * documents\n * - Various utility functions to be used by Document Models.\n */\nexport { Document };\nexport { DocumentModel };\n\nexport const DocumentModels = {\n 'powerhouse/document': Document,\n 'powerhouse/document-model': DocumentModel,\n};\n\nexport default { Document, DocumentModel };\n"],"names":["Document","DocumentModel"],"mappings":";;;;;;;;;;;;AAkBO,MAAM,iBAAiB;AAAA,EAC1B,uBAAuBA,SAAA;AAAA,EACvB,6BAA6BC,cAAA;AACjC;AAEA,MAAA,QAAe,EAAED,UAAAA,SAAAA,UAAUC,eAAAA,cAAAA,cAAc;;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const object = require("./object-Bur9CrCb.js");
|
|
3
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
|
+
__proto__: null,
|
|
5
|
+
calculateSkipsLeft: object.calculateSkipsLeft,
|
|
6
|
+
createAction: object.createAction,
|
|
7
|
+
createDocument: object.createDocument,
|
|
8
|
+
createExtendedState: object.createExtendedState,
|
|
9
|
+
createReducer: object.createReducer,
|
|
10
|
+
createUnsafeReducer: object.createUnsafeReducer,
|
|
11
|
+
createZip: object.createZip,
|
|
12
|
+
documentHelpers: object.documentHelpers,
|
|
13
|
+
getLocalFile: object.getLocalFile,
|
|
14
|
+
getRemoteFile: object.getRemoteFile,
|
|
15
|
+
hashDocument: object.hashDocument,
|
|
16
|
+
hashKey: object.hashKey,
|
|
17
|
+
isBaseAction: object.isBaseAction,
|
|
18
|
+
isNoopOperation: object.isNoopOperation,
|
|
19
|
+
isSameDocument: object.isSameDocument,
|
|
20
|
+
isUndoRedo: object.isUndoRedo,
|
|
21
|
+
loadFromFile: object.loadFromFile,
|
|
22
|
+
loadFromInput: object.loadFromInput,
|
|
23
|
+
mapSkippedOperations: object.mapSkippedOperations,
|
|
24
|
+
parseResultingState: object.parseResultingState,
|
|
25
|
+
readOnly: object.readOnly,
|
|
26
|
+
replayDocument: object.replayDocument,
|
|
27
|
+
replayOperations: object.replayOperations,
|
|
28
|
+
saveToFile: object.saveToFile,
|
|
29
|
+
saveToFileHandle: object.saveToFileHandle,
|
|
30
|
+
sortMappedOperations: object.sortMappedOperations,
|
|
31
|
+
sortOperations: object.sortOperations,
|
|
32
|
+
validateOperations: object.validateOperations
|
|
33
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
34
|
+
const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
35
|
+
__proto__: null,
|
|
36
|
+
BaseDocument: object.BaseDocument,
|
|
37
|
+
actions: object.BaseActions,
|
|
38
|
+
applyMixins: object.applyMixins,
|
|
39
|
+
baseReducer: object.baseReducer,
|
|
40
|
+
mutableBaseReducer: object.mutableBaseReducer,
|
|
41
|
+
processUndoRedo: object.processUndoRedo,
|
|
42
|
+
updateDocument: object.updateDocument,
|
|
43
|
+
updateHeader: object.updateHeader,
|
|
44
|
+
utils: index,
|
|
45
|
+
z: object.zod
|
|
46
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
47
|
+
exports.Document = Document;
|
|
48
|
+
exports.index = index;
|
|
49
|
+
//# sourceMappingURL=index-CPkAfk27.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CPkAfk27.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|