document-model 1.1.0-experimental.4 → 1.1.0-experimental.6

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/browser/cjs/document-model.js +21 -1
  3. package/dist/browser/cjs/document-model.js.map +1 -0
  4. package/dist/browser/cjs/document.js +18 -1
  5. package/dist/browser/cjs/document.js.map +1 -0
  6. package/dist/browser/cjs/index.js +18 -1
  7. package/dist/browser/cjs/index.js.map +1 -0
  8. package/dist/browser/cjs/internal/index-NVU298uP.js +49 -0
  9. package/dist/browser/cjs/internal/index-NVU298uP.js.map +1 -0
  10. package/dist/browser/cjs/internal/index-mGRVNAlq.js +2339 -0
  11. package/dist/browser/cjs/internal/index-mGRVNAlq.js.map +1 -0
  12. package/dist/browser/cjs/internal/object-Br60UD-O.js +4345 -0
  13. package/dist/browser/cjs/internal/object-Br60UD-O.js.map +1 -0
  14. package/dist/browser/es/document-model.js +16 -15
  15. package/dist/browser/es/document-model.js.map +1 -0
  16. package/dist/browser/es/document.js +13 -11
  17. package/dist/browser/es/document.js.map +1 -0
  18. package/dist/browser/es/index.js +13 -11
  19. package/dist/browser/es/index.js.map +1 -0
  20. package/dist/browser/es/internal/index-CUIVdtOX.js +2340 -0
  21. package/dist/browser/es/internal/index-CUIVdtOX.js.map +1 -0
  22. package/dist/browser/es/internal/index-DrVs-I4f.js +50 -0
  23. package/dist/browser/es/internal/index-DrVs-I4f.js.map +1 -0
  24. package/dist/browser/es/internal/object-CRn9ifD4.js +4346 -0
  25. package/dist/browser/es/internal/object-CRn9ifD4.js.map +1 -0
  26. package/dist/browser/src/document/object.d.ts +55 -5
  27. package/dist/browser/src/document/reducer.d.ts +13 -0
  28. package/dist/browser/src/document/types.d.ts +4 -0
  29. package/dist/browser/src/document/utils/base.d.ts +2 -1
  30. package/dist/browser/src/document/utils/document-helpers.d.ts +9 -0
  31. package/dist/node/cjs/document-model.js +25 -1
  32. package/dist/node/cjs/document-model.js.map +1 -0
  33. package/dist/node/cjs/document.js +22 -1
  34. package/dist/node/cjs/document.js.map +1 -0
  35. package/dist/node/cjs/index.js +22 -1
  36. package/dist/node/cjs/index.js.map +1 -0
  37. package/dist/node/cjs/internal/index-CUe2eK-w.js +49 -0
  38. package/dist/node/cjs/internal/index-CUe2eK-w.js.map +1 -0
  39. package/dist/node/cjs/internal/index-CXEcxd1A.js +2343 -0
  40. package/dist/node/cjs/internal/index-CXEcxd1A.js.map +1 -0
  41. package/dist/node/cjs/internal/object-BWoRFP9b.js +2347 -0
  42. package/dist/node/cjs/internal/object-BWoRFP9b.js.map +1 -0
  43. package/dist/node/es/document-model.js +15 -14
  44. package/dist/node/es/document-model.js.map +1 -0
  45. package/dist/node/es/document.js +13 -11
  46. package/dist/node/es/document.js.map +1 -0
  47. package/dist/node/es/index.js +13 -11
  48. package/dist/node/es/index.js.map +1 -0
  49. package/dist/node/es/internal/index-BrOKDV9w.js +50 -0
  50. package/dist/node/es/internal/index-BrOKDV9w.js.map +1 -0
  51. package/dist/node/es/internal/index-BzOhAlo9.js +2344 -0
  52. package/dist/node/es/internal/index-BzOhAlo9.js.map +1 -0
  53. package/dist/node/es/internal/object-tOQPLlfl.js +2348 -0
  54. package/dist/node/es/internal/object-tOQPLlfl.js.map +1 -0
  55. package/dist/node/src/document/object.d.ts +55 -5
  56. package/dist/node/src/document/reducer.d.ts +13 -0
  57. package/dist/node/src/document/types.d.ts +4 -0
  58. package/dist/node/src/document/utils/base.d.ts +2 -1
  59. package/dist/node/src/document/utils/document-helpers.d.ts +9 -0
  60. package/dist/src/document/object.d.ts +55 -5
  61. package/dist/src/document/reducer.d.ts +13 -0
  62. package/dist/src/document/types.d.ts +4 -0
  63. package/dist/src/document/utils/base.d.ts +2 -1
  64. package/dist/src/document/utils/document-helpers.d.ts +9 -0
  65. package/package.json +3 -1
  66. package/dist/browser/cjs/internal/index-BLpgsifL.js +0 -1
  67. package/dist/browser/cjs/internal/index-BTG_-qY6.js +0 -22
  68. package/dist/browser/cjs/internal/object-BHB7lY3H.js +0 -25
  69. package/dist/browser/es/internal/index-2Qq00NLA.js +0 -46
  70. package/dist/browser/es/internal/index-BD2hB9El.js +0 -2104
  71. package/dist/browser/es/internal/object-BW-G4r5m.js +0 -2798
  72. package/dist/node/cjs/internal/index-B31DqWHj.js +0 -1
  73. package/dist/node/cjs/internal/index-BBm_wnUa.js +0 -22
  74. package/dist/node/cjs/internal/object-CxVzP-Xe.js +0 -20
  75. package/dist/node/es/internal/index-BPCSW4M1.js +0 -2108
  76. package/dist/node/es/internal/index-C7I4OGkU.js +0 -46
  77. package/dist/node/es/internal/object-C-_SkpQ0.js +0 -1696
@@ -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,4 +1,4 @@
1
- import { baseReducer } from '../reducer';
1
+ import { baseReducer, mutableBaseReducer } from '../reducer';
2
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;
@@ -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.
@@ -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 {};
@@ -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 {};