@fluidframework/merge-tree 2.13.0 → 2.20.0
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 +42 -0
- package/api-report/merge-tree.legacy.alpha.api.md +0 -108
- package/dist/endOfTreeSegment.d.ts.map +1 -1
- package/dist/endOfTreeSegment.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +0 -4
- package/dist/localReference.d.ts +5 -7
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js +1 -3
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +2 -17
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +15 -189
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +1 -23
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/opBuilder.d.ts +0 -5
- package/dist/opBuilder.d.ts.map +1 -1
- package/dist/opBuilder.js +0 -5
- package/dist/opBuilder.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +1 -5
- package/dist/partialLengths.js.map +1 -1
- package/dist/perspective.d.ts.map +1 -1
- package/dist/perspective.js +2 -6
- package/dist/perspective.js.map +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +0 -3
- package/dist/revertibles.js.map +1 -1
- package/dist/segmentInfos.d.ts +0 -6
- package/dist/segmentInfos.d.ts.map +1 -1
- package/dist/segmentInfos.js.map +1 -1
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js +1 -3
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/testClient.d.ts.map +1 -1
- package/dist/test/testClient.js +0 -1
- package/dist/test/testClient.js.map +1 -1
- package/lib/endOfTreeSegment.d.ts.map +1 -1
- package/lib/endOfTreeSegment.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +0 -4
- package/lib/localReference.d.ts +5 -7
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js +1 -3
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +3 -20
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +15 -189
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +3 -25
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/opBuilder.d.ts +0 -5
- package/lib/opBuilder.d.ts.map +1 -1
- package/lib/opBuilder.js +0 -5
- package/lib/opBuilder.js.map +1 -1
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +1 -5
- package/lib/partialLengths.js.map +1 -1
- package/lib/perspective.d.ts.map +1 -1
- package/lib/perspective.js +2 -6
- package/lib/perspective.js.map +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +0 -3
- package/lib/revertibles.js.map +1 -1
- package/lib/segmentInfos.d.ts +0 -6
- package/lib/segmentInfos.d.ts.map +1 -1
- package/lib/segmentInfos.js.map +1 -1
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js +1 -3
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/test/index.d.ts +1 -1
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js.map +1 -1
- package/lib/test/testClient.d.ts.map +1 -1
- package/lib/test/testClient.js +0 -1
- package/lib/test/testClient.js.map +1 -1
- package/package.json +76 -18
- package/src/endOfTreeSegment.ts +0 -2
- package/src/index.ts +0 -5
- package/src/localReference.ts +6 -8
- package/src/mergeTree.ts +1 -21
- package/src/mergeTreeNodes.ts +25 -223
- package/src/opBuilder.ts +0 -5
- package/src/partialLengths.ts +0 -4
- package/src/perspective.ts +0 -4
- package/src/revertibles.ts +0 -3
- package/src/segmentInfos.ts +0 -6
- package/src/snapshotLoader.ts +1 -5
package/lib/mergeTreeNodes.d.ts
CHANGED
|
@@ -11,26 +11,8 @@ import type { PartialSequenceLengths } from "./partialLengths.js";
|
|
|
11
11
|
import { PropertySet, type MapLike } from "./properties.js";
|
|
12
12
|
import { ReferencePosition } from "./referencePositions.js";
|
|
13
13
|
import { SegmentGroupCollection } from "./segmentGroupCollection.js";
|
|
14
|
-
import { type IInsertionInfo, type IMergeNodeInfo, type
|
|
14
|
+
import { type IInsertionInfo, type IMergeNodeInfo, type SegmentWithInfo } from "./segmentInfos.js";
|
|
15
15
|
import { PropertiesManager } from "./segmentPropertiesManager.js";
|
|
16
|
-
/**
|
|
17
|
-
* Common properties for a node in a merge tree.
|
|
18
|
-
* @legacy
|
|
19
|
-
* @alpha
|
|
20
|
-
* @deprecated - This interface will be removed in 2.20 with no replacement.
|
|
21
|
-
*/
|
|
22
|
-
export interface IMergeNodeCommon {
|
|
23
|
-
/**
|
|
24
|
-
* The index of this node in its parent's list of children.
|
|
25
|
-
*/
|
|
26
|
-
index: number;
|
|
27
|
-
/**
|
|
28
|
-
* A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.
|
|
29
|
-
* `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.
|
|
30
|
-
*/
|
|
31
|
-
ordinal: string;
|
|
32
|
-
isLeaf(): this is ISegment;
|
|
33
|
-
}
|
|
34
16
|
/**
|
|
35
17
|
* This interface exposes internal things to dds that leverage merge tree,
|
|
36
18
|
* like sequence and matrix.
|
|
@@ -44,9 +26,19 @@ export interface IMergeNodeCommon {
|
|
|
44
26
|
*
|
|
45
27
|
* @internal
|
|
46
28
|
*/
|
|
47
|
-
export
|
|
29
|
+
export interface ISegmentInternal extends ISegment {
|
|
48
30
|
localRefs?: LocalReferenceCollection;
|
|
49
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Whether or not this segment is a special segment denoting the start or
|
|
33
|
+
* end of the tree
|
|
34
|
+
*
|
|
35
|
+
* Endpoint segments are imaginary segments positioned immediately before or
|
|
36
|
+
* after the tree. These segments cannot be referenced by regular operations
|
|
37
|
+
* and exist primarily as a bucket for local references to slide onto during
|
|
38
|
+
* deletion of regular segments.
|
|
39
|
+
*/
|
|
40
|
+
readonly endpointType?: "start" | "end";
|
|
41
|
+
}
|
|
50
42
|
/**
|
|
51
43
|
* We use tiered interface to control visibility of segment properties.
|
|
52
44
|
* This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.
|
|
@@ -58,8 +50,7 @@ export type ISegmentInternal = Omit<ISegment, keyof IRemovalInfo | keyof IMoveIn
|
|
|
58
50
|
* someday we may split tree leaves from segments, but for now they are the same
|
|
59
51
|
* this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node
|
|
60
52
|
*/
|
|
61
|
-
export
|
|
62
|
-
Partial<IInsertionInfo & IMergeNodeInfo> & {
|
|
53
|
+
export interface ISegmentPrivate extends ISegmentInternal {
|
|
63
54
|
segmentGroups?: SegmentGroupCollection;
|
|
64
55
|
propertyManager?: PropertiesManager;
|
|
65
56
|
/**
|
|
@@ -68,17 +59,7 @@ Partial<IInsertionInfo & IMergeNodeInfo> & {
|
|
|
68
59
|
* then the segment is not obliterated because it is aware of the latest obliteration.
|
|
69
60
|
*/
|
|
70
61
|
prevObliterateByInserter?: ObliterateInfo;
|
|
71
|
-
|
|
72
|
-
* Whether or not this segment is a special segment denoting the start or
|
|
73
|
-
* end of the tree
|
|
74
|
-
*
|
|
75
|
-
* Endpoint segments are imaginary segments positioned immediately before or
|
|
76
|
-
* after the tree. These segments cannot be referenced by regular operations
|
|
77
|
-
* and exist primarily as a bucket for local references to slide onto during
|
|
78
|
-
* deletion of regular segments.
|
|
79
|
-
*/
|
|
80
|
-
readonly endpointType?: "start" | "end";
|
|
81
|
-
};
|
|
62
|
+
}
|
|
82
63
|
/**
|
|
83
64
|
* Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they
|
|
84
65
|
* are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'
|
|
@@ -130,17 +111,6 @@ export type IMergeNode = MergeBlock | ISegmentLeaf;
|
|
|
130
111
|
export interface ISegment {
|
|
131
112
|
readonly type: string;
|
|
132
113
|
readonly trackingCollection: TrackingGroupCollection;
|
|
133
|
-
/**
|
|
134
|
-
* Whether or not this segment is a special segment denoting the start or
|
|
135
|
-
* end of the tree
|
|
136
|
-
*
|
|
137
|
-
* Endpoint segments are imaginary segments positioned immediately before or
|
|
138
|
-
* after the tree. These segments cannot be referenced by regular operations
|
|
139
|
-
* and exist primarily as a bucket for local references to slide onto during
|
|
140
|
-
* deletion of regular segments.
|
|
141
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
142
|
-
*/
|
|
143
|
-
readonly endpointType?: "start" | "end";
|
|
144
114
|
/**
|
|
145
115
|
* The length of the contents of the node.
|
|
146
116
|
*/
|
|
@@ -161,32 +131,6 @@ export interface ISegment {
|
|
|
161
131
|
* or only attribute certain property modifications, etc.)
|
|
162
132
|
*/
|
|
163
133
|
attribution?: IAttributionCollection<AttributionKey>;
|
|
164
|
-
/**
|
|
165
|
-
* Local seq at which this segment was inserted.
|
|
166
|
-
* This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.
|
|
167
|
-
* Once the segment is acked, this field is cleared.
|
|
168
|
-
*
|
|
169
|
-
* @privateRemarks
|
|
170
|
-
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
171
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
172
|
-
*/
|
|
173
|
-
localSeq?: number;
|
|
174
|
-
/**
|
|
175
|
-
* Seq at which this segment was inserted.
|
|
176
|
-
* If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.
|
|
177
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
178
|
-
*/
|
|
179
|
-
seq?: number;
|
|
180
|
-
/**
|
|
181
|
-
* Short clientId for the client that inserted this segment.
|
|
182
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
183
|
-
*/
|
|
184
|
-
clientId: number;
|
|
185
|
-
/**
|
|
186
|
-
* Local references added to this segment.
|
|
187
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
188
|
-
*/
|
|
189
|
-
localRefs?: LocalReferenceCollection;
|
|
190
134
|
/**
|
|
191
135
|
* Properties that have been added to this segment via annotation.
|
|
192
136
|
*/
|
|
@@ -197,68 +141,6 @@ export interface ISegment {
|
|
|
197
141
|
splitAt(pos: number): ISegment | undefined;
|
|
198
142
|
toJSONObject(): any;
|
|
199
143
|
isLeaf(): this is ISegment;
|
|
200
|
-
/**
|
|
201
|
-
* {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.index}
|
|
202
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
203
|
-
*/
|
|
204
|
-
index: number;
|
|
205
|
-
/**
|
|
206
|
-
* {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.ordinal}
|
|
207
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
208
|
-
*/
|
|
209
|
-
ordinal: string;
|
|
210
|
-
/**
|
|
211
|
-
* Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to
|
|
212
|
-
* UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`
|
|
213
|
-
* will be updated to the seq at which that client removed this segment.
|
|
214
|
-
*
|
|
215
|
-
* Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.
|
|
216
|
-
*
|
|
217
|
-
* @privateRemarks
|
|
218
|
-
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
219
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
220
|
-
*/
|
|
221
|
-
localRemovedSeq?: number;
|
|
222
|
-
/**
|
|
223
|
-
* {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedSeq}
|
|
224
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
225
|
-
*/
|
|
226
|
-
removedSeq?: number;
|
|
227
|
-
/**
|
|
228
|
-
* {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedClientIds}
|
|
229
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
230
|
-
*/
|
|
231
|
-
removedClientIds?: number[];
|
|
232
|
-
/**
|
|
233
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.localMovedSeq}
|
|
234
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
235
|
-
*/
|
|
236
|
-
localMovedSeq?: number;
|
|
237
|
-
/**
|
|
238
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeq}
|
|
239
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
240
|
-
*/
|
|
241
|
-
movedSeq?: number;
|
|
242
|
-
/**
|
|
243
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeqs}
|
|
244
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
245
|
-
*/
|
|
246
|
-
movedSeqs?: number[];
|
|
247
|
-
/**
|
|
248
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.moveDst}
|
|
249
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
250
|
-
*/
|
|
251
|
-
moveDst?: ReferencePosition;
|
|
252
|
-
/**
|
|
253
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedClientIds}
|
|
254
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
255
|
-
*/
|
|
256
|
-
movedClientIds?: number[];
|
|
257
|
-
/**
|
|
258
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.wasMovedOnInsert}
|
|
259
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
260
|
-
*/
|
|
261
|
-
wasMovedOnInsert?: boolean;
|
|
262
144
|
}
|
|
263
145
|
/**
|
|
264
146
|
* Determine if a segment has been removed.
|
|
@@ -345,68 +227,12 @@ export declare function seqLTE(seq: number, minOrRefSeq: number): boolean;
|
|
|
345
227
|
* @alpha
|
|
346
228
|
*/
|
|
347
229
|
export declare abstract class BaseSegment implements ISegment {
|
|
348
|
-
/**
|
|
349
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
350
|
-
*/
|
|
351
|
-
clientId: number;
|
|
352
|
-
/**
|
|
353
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
354
|
-
*/
|
|
355
|
-
seq: number;
|
|
356
|
-
/**
|
|
357
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
358
|
-
*/
|
|
359
|
-
removedSeq?: number;
|
|
360
|
-
/**
|
|
361
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
362
|
-
*/
|
|
363
|
-
removedClientIds?: number[];
|
|
364
|
-
/**
|
|
365
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
366
|
-
*/
|
|
367
|
-
movedSeq?: number;
|
|
368
|
-
/**
|
|
369
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
370
|
-
*/
|
|
371
|
-
movedSeqs?: number[];
|
|
372
|
-
/**
|
|
373
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
374
|
-
*/
|
|
375
|
-
movedClientIds?: number[];
|
|
376
|
-
/**
|
|
377
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
378
|
-
*/
|
|
379
|
-
wasMovedOnInsert?: boolean | undefined;
|
|
380
|
-
/**
|
|
381
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
382
|
-
*/
|
|
383
|
-
index: number;
|
|
384
|
-
/**
|
|
385
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
386
|
-
*/
|
|
387
|
-
ordinal: string;
|
|
388
230
|
cachedLength: number;
|
|
389
231
|
readonly trackingCollection: TrackingGroupCollection;
|
|
390
232
|
/***/
|
|
391
233
|
attribution?: IAttributionCollection<AttributionKey>;
|
|
392
234
|
properties?: PropertySet;
|
|
393
|
-
/**
|
|
394
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
395
|
-
*/
|
|
396
|
-
localRefs?: LocalReferenceCollection;
|
|
397
235
|
abstract readonly type: string;
|
|
398
|
-
/**
|
|
399
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
400
|
-
*/
|
|
401
|
-
localSeq?: number;
|
|
402
|
-
/**
|
|
403
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
404
|
-
*/
|
|
405
|
-
localRemovedSeq?: number;
|
|
406
|
-
/**
|
|
407
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
408
|
-
*/
|
|
409
|
-
localMovedSeq?: number;
|
|
410
236
|
constructor(properties?: PropertySet);
|
|
411
237
|
hasProperty(key: string): boolean;
|
|
412
238
|
isLeaf(): this is ISegment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTreeNodes.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"mergeTreeNodes.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8DG;IACH,QAAQ,SAAK;IAEb,QAAQ,CAAC,CAAC,EAAE,mBAAmB,GAAG,IAAI;CAMtC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,MAAO,MAAM,KAAK,MAAM,KAAG,MAAe,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,cAAc,MAAO,MAAM,KAAK,MAAM,KAAG,MAA4B,CAAC"}
|
package/lib/mergeTreeNodes.js
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
-
import { LocalClientId, UnassignedSequenceNumber
|
|
7
|
-
// eslint-disable-next-line import/no-deprecated
|
|
6
|
+
import { LocalClientId, UnassignedSequenceNumber } from "./constants.js";
|
|
8
7
|
import { LocalReferenceCollection } from "./localReference.js";
|
|
9
8
|
import { TrackingGroupCollection } from "./mergeTreeTracking.js";
|
|
10
9
|
import { computeHierarchicalOrdinal } from "./ordinal.js";
|
|
11
10
|
import { clone, createMap } from "./properties.js";
|
|
12
|
-
import { isInserted, isMergeNodeInfo as isMergeNode, isMoved, isRemoved, overwriteInfo, } from "./segmentInfos.js";
|
|
11
|
+
import { hasProp, isInserted, isMergeNodeInfo as isMergeNode, isMoved, isRemoved, overwriteInfo, } from "./segmentInfos.js";
|
|
13
12
|
/**
|
|
14
13
|
* A type-guard which determines if the segment has segment leaf, and
|
|
15
14
|
* returns true if it does, along with applying strong typing.
|
|
@@ -73,7 +72,7 @@ export function assignChild(parent, child, index, updateOrdinal = true) {
|
|
|
73
72
|
const node = Object.assign(child, {
|
|
74
73
|
parent,
|
|
75
74
|
index,
|
|
76
|
-
ordinal: child.ordinal
|
|
75
|
+
ordinal: hasProp(child, "ordinal", "string") ? child.ordinal : "",
|
|
77
76
|
});
|
|
78
77
|
if (updateOrdinal) {
|
|
79
78
|
parent.setOrdinal(node, index);
|
|
@@ -89,22 +88,6 @@ export function seqLTE(seq, minOrRefSeq) {
|
|
|
89
88
|
*/
|
|
90
89
|
export class BaseSegment {
|
|
91
90
|
constructor(properties) {
|
|
92
|
-
/**
|
|
93
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
94
|
-
*/
|
|
95
|
-
this.clientId = LocalClientId;
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
98
|
-
*/
|
|
99
|
-
this.seq = UniversalSequenceNumber;
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
102
|
-
*/
|
|
103
|
-
this.index = 0;
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
106
|
-
*/
|
|
107
|
-
this.ordinal = "";
|
|
108
91
|
this.cachedLength = 0;
|
|
109
92
|
this.trackingCollection = new TrackingGroupCollection(this);
|
|
110
93
|
if (properties !== undefined) {
|
|
@@ -128,14 +111,12 @@ export class BaseSegment {
|
|
|
128
111
|
// TODO: deep clone properties
|
|
129
112
|
seg.properties = clone(this.properties);
|
|
130
113
|
if (isRemoved(this)) {
|
|
131
|
-
// eslint-disable-next-line import/no-deprecated
|
|
132
114
|
overwriteInfo(seg, {
|
|
133
115
|
removedSeq: this.removedSeq,
|
|
134
116
|
removedClientIds: [...this.removedClientIds],
|
|
135
117
|
});
|
|
136
118
|
}
|
|
137
119
|
if (isMoved(this)) {
|
|
138
|
-
// eslint-disable-next-line import/no-deprecated
|
|
139
120
|
overwriteInfo(seg, {
|
|
140
121
|
movedSeq: this.movedSeq,
|
|
141
122
|
movedSeqs: [...this.movedSeqs],
|
|
@@ -182,7 +163,6 @@ export class BaseSegment {
|
|
|
182
163
|
});
|
|
183
164
|
}
|
|
184
165
|
if (isRemoved(this)) {
|
|
185
|
-
// eslint-disable-next-line import/no-deprecated
|
|
186
166
|
overwriteInfo(leafSegment, {
|
|
187
167
|
removedClientIds: [...this.removedClientIds],
|
|
188
168
|
removedSeq: this.removedSeq,
|
|
@@ -190,7 +170,6 @@ export class BaseSegment {
|
|
|
190
170
|
});
|
|
191
171
|
}
|
|
192
172
|
if (isMoved(this)) {
|
|
193
|
-
// eslint-disable-next-line import/no-deprecated
|
|
194
173
|
overwriteInfo(leafSegment, {
|
|
195
174
|
movedClientIds: [...this.movedClientIds],
|
|
196
175
|
movedSeq: this.movedSeq,
|
|
@@ -208,7 +187,6 @@ export class BaseSegment {
|
|
|
208
187
|
append(other) {
|
|
209
188
|
// Note: Must call 'appendLocalRefs' before modifying this segment's length as
|
|
210
189
|
// 'this.cachedLength' is used to adjust the offsets of the local refs.
|
|
211
|
-
// eslint-disable-next-line import/no-deprecated
|
|
212
190
|
LocalReferenceCollection.append(this, other);
|
|
213
191
|
if (this.attribution) {
|
|
214
192
|
assert(other.attribution !== undefined, 0x4bd /* attribution should be set on appendee */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,gBAAgB,CAAC;AACxB,gDAAgD;AAChD,OAAO,EAAE,wBAAwB,EAA+B,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAe,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACN,UAAU,EACV,eAAe,IAAI,WAAW,EAC9B,OAAO,EACP,SAAS,EACT,aAAa,GAQb,MAAM,mBAAmB,CAAC;AAuF3B;;;;;GAKG;AACH,MAAM,CAAC,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AAE,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IAttributionCollection } from \"./attributionCollection.js\";\nimport {\n\tLocalClientId,\n\tUnassignedSequenceNumber,\n\tUniversalSequenceNumber,\n} from \"./constants.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { IJSONSegment, IMarkerDef, ReferenceType } from \"./ops.js\";\nimport { computeHierarchicalOrdinal } from \"./ordinal.js\";\nimport type { PartialSequenceLengths } from \"./partialLengths.js\";\nimport { PropertySet, clone, createMap, type MapLike } from \"./properties.js\";\nimport { ReferencePosition } from \"./referencePositions.js\";\nimport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\nimport {\n\tisInserted,\n\tisMergeNodeInfo as isMergeNode,\n\tisMoved,\n\tisRemoved,\n\toverwriteInfo,\n\ttype IInsertionInfo,\n\ttype IMergeNodeInfo,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype IMoveInfo,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype IRemovalInfo,\n\ttype SegmentWithInfo,\n} from \"./segmentInfos.js\";\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\n\n/**\n * Common properties for a node in a merge tree.\n * @legacy\n * @alpha\n * @deprecated - This interface will be removed in 2.20 with no replacement.\n */\nexport interface IMergeNodeCommon {\n\t/**\n\t * The index of this node in its parent's list of children.\n\t */\n\tindex: number;\n\t/**\n\t * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.\n\t * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.\n\t */\n\tordinal: string;\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * This interface exposes internal things to dds that leverage merge tree,\n * like sequence and matrix.\n *\n * We use tiered interface to control visibility of segment properties.\n * This sits between ISegment and ISegmentPrivate. It should only expose\n * things tagged internal.\n *\n * Everything added here beyond ISegment should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * @internal\n */\nexport type ISegmentInternal = Omit<\n\tISegment,\n\t// eslint-disable-next-line import/no-deprecated\n\tkeyof IRemovalInfo | keyof IMoveInfo\n> & {\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n};\n\n/**\n * We use tiered interface to control visibility of segment properties.\n * This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.\n * It should only expose unexported things.\n *\n * Everything added here beyond ISegmentInternal should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * someday we may split tree leaves from segments, but for now they are the same\n * this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node\n */\nexport type ISegmentPrivate = ISegmentInternal & // eslint-disable-next-line import/no-deprecated\n\tPartial<IInsertionInfo & IMergeNodeInfo> & {\n\t\tsegmentGroups?: SegmentGroupCollection;\n\t\tpropertyManager?: PropertiesManager;\n\t\t/**\n\t\t * If a segment is inserted into an obliterated range,\n\t\t * but the newest obliteration of that range was by the inserting client,\n\t\t * then the segment is not obliterated because it is aware of the latest obliteration.\n\t\t */\n\t\tprevObliterateByInserter?: ObliterateInfo;\n\t\t/**\n\t\t * Whether or not this segment is a special segment denoting the start or\n\t\t * end of the tree\n\t\t *\n\t\t * Endpoint segments are imaginary segments positioned immediately before or\n\t\t * after the tree. These segments cannot be referenced by regular operations\n\t\t * and exist primarily as a bucket for local references to slide onto during\n\t\t * deletion of regular segments.\n\t\t */\n\t\treadonly endpointType?: \"start\" | \"end\";\n\t};\n\n/**\n * Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they\n * are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'\n * children are either a segment leaf, or another merge block for interior nodes of the tree. When working\n * within the tree it is generally unnecessary to use type coercions methods common to the infos, and segment\n * leafs, as the children of MergeBlocks are already well typed. However, when segments come from outside the\n * merge tree, like via client's public methods, it becomes necessary to use the type coercions methods\n * to ensure the passed in segment objects are correctly bound to the merge tree.\n */\nexport type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IInsertionInfo>;\n/**\n * A type-guard which determines if the segment has segment leaf, and\n * returns true if it does, along with applying strong typing.\n * @param nodeLike - The segment-like object to check.\n * @returns True if the segment is a segment leaf, otherwise false.\n */\nexport const isSegmentLeaf = (segmentLike: unknown): segmentLike is ISegmentLeaf =>\n\tisInserted(segmentLike) && isMergeNode(segmentLike);\n\n/**\n * Converts a segment-like object to a segment leaf object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The segment leaf if the conversion is possible, otherwise undefined.\n */\nexport const toSegmentLeaf = (segmentLike: unknown): ISegmentLeaf | undefined =>\n\tisSegmentLeaf(segmentLike) ? segmentLike : undefined;\n/**\n * Asserts that the segment is a segment leaf. Usage of this function should not produce a user facing error.\n *\n * @param segmentLike - The segment-like object to check.\n * @throws Will throw an error if the segment is not a segment leaf.\n */\nexport const assertSegmentLeaf: (segmentLike: unknown) => asserts segmentLike is ISegmentLeaf =\n\t(segmentLike) => assert(isSegmentLeaf(segmentLike), 0xaab /* must be segment leaf */);\n/**\n * This type is used for building MergeBlocks from segments and other MergeBlocks. We need this\n * type as segments may not yet be bound to the tree, so lack merge node info which is required for\n * segment leafs.\n */\nexport type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IInsertionInfo>;\n\n/**\n * This type is used by MergeBlocks to define their children, which are either segments or other\n * MergeBlocks.\n */\nexport type IMergeNode = MergeBlock | ISegmentLeaf;\n\n/**\n * A segment representing a portion of the merge tree.\n * Segments are leaf nodes of the merge tree and contain data.\n * @legacy\n * @alpha\n */\nexport interface ISegment {\n\treadonly type: string;\n\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this segment is a special segment denoting the start or\n\t * end of the tree\n\t *\n\t * Endpoint segments are imaginary segments positioned immediately before or\n\t * after the tree. These segments cannot be referenced by regular operations\n\t * and exist primarily as a bucket for local references to slide onto during\n\t * deletion of regular segments.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\treadonly endpointType?: \"start\" | \"end\";\n\n\t/**\n\t * The length of the contents of the node.\n\t */\n\tcachedLength: number;\n\t/**\n\t * Stores attribution keys associated with offsets of this segment.\n\t * This data is only persisted if MergeTree's `attributions.track` flag is set to true.\n\t * Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have\n\t * `attribution === undefined` until ack.\n\t *\n\t * Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.\n\t * @remarks There are plans to make the shape of the data stored extensible in a couple ways:\n\t *\n\t * 1. Injection of custom attribution information associated with the segment (ex: copy-paste of\n\t * content but keeping the old attribution information).\n\t *\n\t * 2. Storage of multiple \"channels\" of information (ex: track property changes separately from insertion,\n\t * or only attribute certain property modifications, etc.)\n\t */\n\tattribution?: IAttributionCollection<AttributionKey>;\n\n\t/**\n\t * Local seq at which this segment was inserted.\n\t * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.\n\t * Once the segment is acked, this field is cleared.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalSeq?: number;\n\t/**\n\t * Seq at which this segment was inserted.\n\t * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tseq?: number;\n\t/**\n\t * Short clientId for the client that inserted this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tclientId: number;\n\t/**\n\t * Local references added to this segment.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tlocalRefs?: LocalReferenceCollection;\n\t/**\n\t * Properties that have been added to this segment via annotation.\n\t */\n\tproperties?: PropertySet;\n\n\tclone(): ISegment;\n\tcanAppend(segment: ISegment): boolean;\n\tappend(segment: ISegment): void;\n\tsplitAt(pos: number): ISegment | undefined;\n\t// Changing this to something other than any would break consumers.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\ttoJSONObject(): any;\n\tisLeaf(): this is ISegment;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.index}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tindex: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.ordinal}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tordinal: string;\n\n\t/**\n\t * Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to\n\t * UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`\n\t * will be updated to the seq at which that client removed this segment.\n\t *\n\t * Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.\n\t *\n\t * @privateRemarks\n\t * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalRemovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tremovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.localMovedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tlocalMovedSeq?: number;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeq}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeq?: number;\n\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeqs}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedSeqs?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.moveDst}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmoveDst?: ReferencePosition;\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedClientIds}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tmovedClientIds?: number[];\n\t/**\n\t * {@inheritDoc @fluidframework/merge-tree#IMoveInfo.wasMovedOnInsert}\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\twasMovedOnInsert?: boolean;\n}\n\n/**\n * Determine if a segment has been removed.\n * @legacy\n * @alpha\n */\nexport function segmentIsRemoved(segment: ISegment): boolean {\n\treturn isRemoved(segment);\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISegmentAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tsegment: ISegment,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number,\n\t\tend: number,\n\t\taccum: TClientData,\n\t): boolean;\n}\nexport interface ISegmentChanges {\n\tnext?: SegmentWithInfo<IInsertionInfo>;\n\treplaceCurrent?: SegmentWithInfo<IInsertionInfo>;\n}\n\nexport interface InsertContext {\n\tcandidateSegment?: SegmentWithInfo<IInsertionInfo>;\n\tleaf: (segment: ISegmentLeaf | undefined, pos: number, ic: InsertContext) => ISegmentChanges;\n\tcontinuePredicate?: (continueFromBlock: MergeBlock) => boolean;\n}\n\nexport interface ObliterateInfo {\n\tstart: LocalReferencePosition;\n\tend: LocalReferencePosition;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tlocalSeq: number | undefined;\n\tsegmentGroup: SegmentGroup | undefined;\n}\n\nexport interface SegmentGroup {\n\tsegments: ISegmentLeaf[];\n\tpreviousProps?: PropertySet[];\n\tlocalSeq?: number;\n\trefSeq: number;\n\tobliterateInfo?: ObliterateInfo;\n}\n\n/**\n * Note that the actual branching factor of the MergeTree is `MaxNodesInBlock - 1`. This is because\n * the MergeTree always inserts first, then checks for overflow and splits if the child count equals\n * `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to\n * facilitate splits.)\n */\nexport const MaxNodesInBlock = 8;\nexport class MergeBlock implements Partial<IMergeNodeInfo> {\n\tpublic children: IMergeNode[];\n\tpublic needsScour?: boolean;\n\tpublic parent?: MergeBlock;\n\tpublic index: number = 0;\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number | undefined = 0;\n\n\t/**\n\t * Maps each tile label in this block to the rightmost (i.e. furthest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic rightmostTiles: Readonly<MapLike<Marker>>;\n\t/**\n\t * Maps each tile label in this block to the leftmost (i.e. nearest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic leftmostTiles: Readonly<MapLike<Marker>>;\n\n\tisLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Supports querying the total length of all descendants of this IMergeBlock from the perspective of any\n\t * (clientId, seq) within the collab window.\n\t *\n\t * @remarks This is only optional for implementation reasons (internal nodes can be created/moved without\n\t * immediately initializing the partial lengths). Aside from mid-update on tree operations, these lengths\n\t * objects are always defined.\n\t */\n\tpartialLengths?: PartialSequenceLengths;\n\n\tpublic constructor(public childCount: number) {\n\t\t// Suppression needed due to the way the merge tree children are initalized - we\n\t\t// allocate 8 children blocks, but any unused blocks are not counted in the childCount.\n\t\t// Using Array.from leads to unused children being undefined, which are counted in childCount.\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tthis.children = new Array<IMergeNode>(MaxNodesInBlock);\n\t\tthis.rightmostTiles = createMap<Marker>();\n\t\tthis.leftmostTiles = createMap<Marker>();\n\t}\n\n\tpublic setOrdinal(child: IMergeNode, index: number): void {\n\t\tconst childCount = this.childCount;\n\t\tassert(\n\t\t\tchildCount >= 1 && childCount <= MaxNodesInBlock,\n\t\t\t0x040 /* \"Child count is not within [1,8] range!\" */,\n\t\t);\n\t\tchild.ordinal = computeHierarchicalOrdinal(\n\t\t\tMaxNodesInBlock,\n\t\t\tchildCount,\n\t\t\tthis.ordinal,\n\t\t\tindex === 0 ? undefined : this.children[index - 1]?.ordinal,\n\t\t);\n\t}\n}\nexport function assignChild<C extends IMergeNodeBuilder>(\n\tparent: MergeBlock,\n\tchild: C,\n\tindex: number,\n\tupdateOrdinal = true,\n): asserts child is C & IMergeNodeInfo {\n\tconst node = Object.assign<C, IMergeNodeInfo>(child, {\n\t\tparent,\n\t\tindex,\n\t\tordinal: child.ordinal ?? \"\",\n\t});\n\tif (updateOrdinal) {\n\t\tparent.setOrdinal(node, index);\n\t}\n\tparent.children[index] = node;\n}\n\nexport function seqLTE(seq: number, minOrRefSeq: number): boolean {\n\treturn seq !== UnassignedSequenceNumber && seq <= minOrRefSeq;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport abstract class BaseSegment implements ISegment {\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic clientId: number = LocalClientId;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic seq: number = UniversalSequenceNumber;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic removedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedSeqs?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic movedClientIds?: number[];\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic wasMovedOnInsert?: boolean | undefined;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic index: number = 0;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number = 0;\n\n\tpublic readonly trackingCollection: TrackingGroupCollection = new TrackingGroupCollection(\n\t\tthis,\n\t);\n\t/***/\n\tpublic attribution?: IAttributionCollection<AttributionKey>;\n\n\tpublic properties?: PropertySet;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic localRefs?: LocalReferenceCollection;\n\tpublic abstract readonly type: string;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localRemovedSeq?: number;\n\t/**\n\t * @deprecated - This property will be removed in 2.20 with no replacement.\n\t */\n\tpublic localMovedSeq?: number;\n\n\tpublic constructor(properties?: PropertySet) {\n\t\tif (properties !== undefined) {\n\t\t\tthis.properties = clone(properties);\n\t\t}\n\t}\n\n\tpublic hasProperty(key: string): boolean {\n\t\treturn !!this.properties && this.properties[key] !== undefined;\n\t}\n\n\tpublic isLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected cloneInto(b: ISegment): void {\n\t\tconst seg: ISegmentPrivate = b;\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(seg, {\n\t\t\t\tclientId: this.clientId,\n\t\t\t\tseq: this.seq,\n\t\t\t});\n\t\t}\n\t\t// TODO: deep clone properties\n\t\tseg.properties = clone(this.properties);\n\t\tif (isRemoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IRemovalInfo>(seg, {\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IMoveInfo>(seg, {\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t});\n\t\t}\n\t\tseg.attribution = this.attribution?.clone();\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tprotected addSerializedProps(jseg: IJSONSegment): void {\n\t\tif (this.properties) {\n\t\t\tjseg.props = { ...this.properties };\n\t\t}\n\t}\n\t// This has to return any type because the return type is different for different segment types.\n\t// TODO: If possible, change the return type to match what should be returned for each segment type.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic abstract toJSONObject(): any;\n\n\tpublic splitAt(pos: number): ISegment | undefined {\n\t\tif (pos <= 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst leafSegment: ISegmentPrivate | undefined = this.createSplitSegmentAt(pos);\n\n\t\tif (!leafSegment) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (isMergeNode(this)) {\n\t\t\toverwriteInfo<IMergeNodeInfo>(leafSegment, {\n\t\t\t\tindex: this.index + 1,\n\t\t\t\t// Give the leaf a temporary yet valid ordinal.\n\t\t\t\t// when this segment is put in the tree, it will get its real ordinal,\n\t\t\t\t// but this ordinal meets all the necessary invariants for now.\n\t\t\t\t// Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.\n\t\t\t\t// The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.\n\t\t\t\t// eslint-disable-next-line unicorn/prefer-code-point\n\t\t\t\tordinal: this.ordinal + String.fromCharCode(0),\n\t\t\t\tparent: this.parent,\n\t\t\t});\n\t\t}\n\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(leafSegment, {\n\t\t\t\tseq: this.seq,\n\t\t\t\tlocalSeq: this.localSeq,\n\t\t\t\tclientId: this.clientId,\n\t\t\t});\n\t\t}\n\t\tif (isRemoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IRemovalInfo>(leafSegment, {\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tlocalRemovedSeq: this.localRemovedSeq,\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\toverwriteInfo<IMoveInfo>(leafSegment, {\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\tlocalMovedSeq: this.localMovedSeq,\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t});\n\t\t}\n\n\t\tthis.trackingCollection.copyTo(leafSegment);\n\t\tif (this.attribution) {\n\t\t\tleafSegment.attribution = this.attribution.splitAt(pos);\n\t\t}\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic abstract clone(): ISegment;\n\n\tpublic append(other: ISegment): void {\n\t\t// Note: Must call 'appendLocalRefs' before modifying this segment's length as\n\t\t// 'this.cachedLength' is used to adjust the offsets of the local refs.\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tLocalReferenceCollection.append(this, other);\n\t\tif (this.attribution) {\n\t\t\tassert(\n\t\t\t\tother.attribution !== undefined,\n\t\t\t\t0x4bd /* attribution should be set on appendee */,\n\t\t\t);\n\t\t\tthis.attribution.append(other.attribution);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tother.attribution === undefined,\n\t\t\t\t0x4be /* attribution should not be set on appendee */,\n\t\t\t);\n\t\t}\n\n\t\tthis.cachedLength ??= 0;\n\t\tthis.cachedLength += other.cachedLength;\n\t}\n\n\tprotected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;\n}\n\n/**\n * The special-cased property key that tracks the id of a {@link Marker}.\n *\n * @remarks In general, marker ids should be accessed using the inherent method\n * {@link Marker.getId}. Marker ids should not be updated after creation.\n * @legacy\n * @alpha\n */\nexport const reservedMarkerIdKey = \"markerId\";\n\n/**\n * @internal\n */\nexport const reservedMarkerSimpleTypeKey = \"markerSimpleType\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IJSONMarkerSegment extends IJSONSegment {\n\tmarker: IMarkerDef;\n}\n\n/**\n * Markers are a special kind of segment that do not hold any content.\n *\n * Markers with a reference type of {@link ReferenceType.Tile} support spatially\n * accelerated queries for finding the next marker to the left or right of it in\n * sub-linear time. This is useful, for example, in the case of jumping from the\n * start of a paragraph to the end, assuming a paragraph is bound by markers at\n * the start and end.\n *\n * @legacy\n * @alpha\n */\nexport class Marker extends BaseSegment implements ReferencePosition, ISegment {\n\tpublic static readonly type = \"Marker\";\n\tpublic static is(segment: ISegment): segment is Marker {\n\t\treturn segment.type === Marker.type;\n\t}\n\tpublic readonly type = Marker.type;\n\n\tpublic static make(refType: ReferenceType, props?: PropertySet): Marker {\n\t\treturn new Marker(refType, props);\n\t}\n\n\tconstructor(\n\t\tpublic refType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tsuper(props);\n\t\tthis.cachedLength = 1;\n\t}\n\n\ttoJSONObject(): IJSONMarkerSegment {\n\t\tconst obj: IJSONMarkerSegment = { marker: { refType: this.refType } };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tstatic fromJSONObject(spec: IJSONSegment): Marker | undefined {\n\t\tif (spec && typeof spec === \"object\" && \"marker\" in spec) {\n\t\t\treturn Marker.make((spec.marker as Marker).refType, spec.props as PropertySet);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tclone(): Marker {\n\t\tconst b = Marker.make(this.refType, this.properties);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tgetSegment(): Marker {\n\t\treturn this;\n\t}\n\n\tgetOffset(): number {\n\t\treturn 0;\n\t}\n\n\tgetProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n\n\tgetId(): string | undefined {\n\t\treturn this.properties?.[reservedMarkerIdKey] as string;\n\t}\n\n\ttoString(): string {\n\t\treturn `M${this.getId()}`;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): undefined {\n\t\treturn undefined;\n\t}\n\n\tcanAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tappend(): void {\n\t\tthrow new Error(\"Can not append to marker\");\n\t}\n}\n\n/**\n * This class is used to track facts about the current window of collaboration. This window is defined by the server\n * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding\n * local operations.\n * @internal\n */\nexport class CollaborationWindow {\n\tclientId = LocalClientId;\n\tcollaborating = false;\n\n\t/**\n\t * Lowest-numbered segment in window; no client can reference a state before this one\n\t */\n\tminSeq = 0;\n\t/**\n\t * Highest-numbered segment in window and current reference sequence number for this client.\n\t */\n\tcurrentSeq = 0;\n\n\t/**\n\t * Highest-numbered localSeq used for a pending segment.\n\t * Semantically, `localSeq`s provide an ordering on in-flight merge-tree operations:\n\t * for operations stamped with localSeqs `a` and `b`, `a < b` if and only if `a` was submitted before `b`.\n\t *\n\t * @remarks - This field is analogous to the `clientSequenceNumber` field on ops, but it's accessible to merge-tree\n\t * at op submission time rather than only at ack time. This enables more natural state tracking for in-flight ops.\n\t *\n\t * It's useful to stamp ops with such an incrementing counter because it enables reasoning about which segments existed from\n\t * the perspective of the local client at a given point in 'un-acked' time, which is necessary to support the reconnect flow.\n\t *\n\t * For example, imagine a client with initial state \"123456\" submits some ops to create the text \"123456ABC\".\n\t * If they insert the \"C\" first, then \"B\", then \"A\", their local segment state might look like this:\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t * (note that localSeq tracks the localSeq at which a segment was inserted)\n\t *\n\t * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate\n\t * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.\n\t *\n\t * It will generate the ops\n\t * 1. \\{ pos: 6, text: \"C\" \\}\n\t * 2. \\{ pos: 6, text: \"B\" \\}\n\t * 3. \\{ pos: 6, text: \"A\" \\}\n\t *\n\t * since when submitting the first op, remote clients don't know that this client is about to submit the \"A\" and \"B\".\n\t *\n\t * On the other hand, imagine if the client had originally submitted the ops in the order \"A\", \"B\", \"C\"\n\t * such that the segments' local state was instead:\n\t *\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t *\n\t * The resubmitted ops should instead be:\n\t * 1. \\{ pos: 6, text: \"A\" \\}\n\t * 2. \\{ pos: 7, text: \"B\" \\}\n\t * 3. \\{ pos: 8, text: \"C\" \\}\n\t *\n\t * since remote clients will have seen the \"A\" when processing the \"B\" as well as both the \"A\" and \"B\" when processing the \"C\".\n\t * As can be seen, the list of resubmitted ops is different in the two cases despite the merge-tree's segment state only differing\n\t * in `localSeq`.\n\t *\n\t * This example is a bit simplified from the general scenario: since no remote clients modified the merge-tree while the client\n\t * was disconnected, the resubmitted ops end up matching the original ops exactly.\n\t * However, this is not generally true: the production reconnect code takes into account visibility of segments based on both acked\n\t * and local information as appropriate.\n\t * Nonetheless, this simple scenario is enough to understand why it's useful to be able to determine if a segment should be visible\n\t * from a given (seq, localSeq) perspective.\n\t */\n\tlocalSeq = 0;\n\n\tloadFrom(a: CollaborationWindow): void {\n\t\tthis.clientId = a.clientId;\n\t\tthis.collaborating = a.collaborating;\n\t\tthis.minSeq = a.minSeq;\n\t\tthis.currentSeq = a.currentSeq;\n\t}\n}\n\n/**\n * Compares two numbers.\n */\nexport const compareNumbers = (a: number, b: number): number => a - b;\n\n/**\n * Compares two strings.\n */\nexport const compareStrings = (a: string, b: string): number => a.localeCompare(b);\n"]}
|
|
1
|
+
{"version":3,"file":"mergeTreeNodes.js","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAA+B,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAe,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACN,OAAO,EACP,UAAU,EACV,eAAe,IAAI,WAAW,EAC9B,OAAO,EACP,SAAS,EACT,aAAa,GAMb,MAAM,mBAAmB,CAAC;AA6D3B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAoB,EAA+B,EAAE,CAClF,UAAU,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC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import { assert } from \"@fluidframework/core-utils/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { IAttributionCollection } from \"./attributionCollection.js\";\nimport { LocalClientId, UnassignedSequenceNumber } from \"./constants.js\";\nimport { LocalReferenceCollection, type LocalReferencePosition } from \"./localReference.js\";\nimport { TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { IJSONSegment, IMarkerDef, ReferenceType } from \"./ops.js\";\nimport { computeHierarchicalOrdinal } from \"./ordinal.js\";\nimport type { PartialSequenceLengths } from \"./partialLengths.js\";\nimport { PropertySet, clone, createMap, type MapLike } from \"./properties.js\";\nimport { ReferencePosition } from \"./referencePositions.js\";\nimport { SegmentGroupCollection } from \"./segmentGroupCollection.js\";\nimport {\n\thasProp,\n\tisInserted,\n\tisMergeNodeInfo as isMergeNode,\n\tisMoved,\n\tisRemoved,\n\toverwriteInfo,\n\ttype IInsertionInfo,\n\ttype IMergeNodeInfo,\n\ttype IMoveInfo,\n\ttype IRemovalInfo,\n\ttype SegmentWithInfo,\n} from \"./segmentInfos.js\";\nimport { PropertiesManager } from \"./segmentPropertiesManager.js\";\n\n/**\n * This interface exposes internal things to dds that leverage merge tree,\n * like sequence and matrix.\n *\n * We use tiered interface to control visibility of segment properties.\n * This sits between ISegment and ISegmentPrivate. It should only expose\n * things tagged internal.\n *\n * Everything added here beyond ISegment should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * @internal\n */\nexport interface ISegmentInternal extends ISegment {\n\tlocalRefs?: LocalReferenceCollection;\n\t/**\n\t * Whether or not this segment is a special segment denoting the start or\n\t * end of the tree\n\t *\n\t * Endpoint segments are imaginary segments positioned immediately before or\n\t * after the tree. These segments cannot be referenced by regular operations\n\t * and exist primarily as a bucket for local references to slide onto during\n\t * deletion of regular segments.\n\t */\n\treadonly endpointType?: \"start\" | \"end\";\n}\n\n/**\n * We use tiered interface to control visibility of segment properties.\n * This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.\n * It should only expose unexported things.\n *\n * Everything added here beyond ISegmentInternal should be optional to keep the ability\n * to implicitly convert between the tiered interfaces.\n *\n * someday we may split tree leaves from segments, but for now they are the same\n * this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node\n */\nexport interface ISegmentPrivate extends ISegmentInternal {\n\tsegmentGroups?: SegmentGroupCollection;\n\tpropertyManager?: PropertiesManager;\n\t/**\n\t * If a segment is inserted into an obliterated range,\n\t * but the newest obliteration of that range was by the inserting client,\n\t * then the segment is not obliterated because it is aware of the latest obliteration.\n\t */\n\tprevObliterateByInserter?: ObliterateInfo;\n}\n/**\n * Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they\n * are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'\n * children are either a segment leaf, or another merge block for interior nodes of the tree. When working\n * within the tree it is generally unnecessary to use type coercions methods common to the infos, and segment\n * leafs, as the children of MergeBlocks are already well typed. However, when segments come from outside the\n * merge tree, like via client's public methods, it becomes necessary to use the type coercions methods\n * to ensure the passed in segment objects are correctly bound to the merge tree.\n */\nexport type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IInsertionInfo>;\n/**\n * A type-guard which determines if the segment has segment leaf, and\n * returns true if it does, along with applying strong typing.\n * @param nodeLike - The segment-like object to check.\n * @returns True if the segment is a segment leaf, otherwise false.\n */\nexport const isSegmentLeaf = (segmentLike: unknown): segmentLike is ISegmentLeaf =>\n\tisInserted(segmentLike) && isMergeNode(segmentLike);\n\n/**\n * Converts a segment-like object to a segment leaf object if possible.\n *\n * @param segmentLike - The segment-like object to convert.\n * @returns The segment leaf if the conversion is possible, otherwise undefined.\n */\nexport const toSegmentLeaf = (segmentLike: unknown): ISegmentLeaf | undefined =>\n\tisSegmentLeaf(segmentLike) ? segmentLike : undefined;\n/**\n * Asserts that the segment is a segment leaf. Usage of this function should not produce a user facing error.\n *\n * @param segmentLike - The segment-like object to check.\n * @throws Will throw an error if the segment is not a segment leaf.\n */\nexport const assertSegmentLeaf: (segmentLike: unknown) => asserts segmentLike is ISegmentLeaf =\n\t(segmentLike) => assert(isSegmentLeaf(segmentLike), 0xaab /* must be segment leaf */);\n/**\n * This type is used for building MergeBlocks from segments and other MergeBlocks. We need this\n * type as segments may not yet be bound to the tree, so lack merge node info which is required for\n * segment leafs.\n */\nexport type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IInsertionInfo>;\n\n/**\n * This type is used by MergeBlocks to define their children, which are either segments or other\n * MergeBlocks.\n */\nexport type IMergeNode = MergeBlock | ISegmentLeaf;\n\n/**\n * A segment representing a portion of the merge tree.\n * Segments are leaf nodes of the merge tree and contain data.\n * @legacy\n * @alpha\n */\nexport interface ISegment {\n\treadonly type: string;\n\n\treadonly trackingCollection: TrackingGroupCollection;\n\n\t/**\n\t * The length of the contents of the node.\n\t */\n\tcachedLength: number;\n\t/**\n\t * Stores attribution keys associated with offsets of this segment.\n\t * This data is only persisted if MergeTree's `attributions.track` flag is set to true.\n\t * Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have\n\t * `attribution === undefined` until ack.\n\t *\n\t * Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.\n\t * @remarks There are plans to make the shape of the data stored extensible in a couple ways:\n\t *\n\t * 1. Injection of custom attribution information associated with the segment (ex: copy-paste of\n\t * content but keeping the old attribution information).\n\t *\n\t * 2. Storage of multiple \"channels\" of information (ex: track property changes separately from insertion,\n\t * or only attribute certain property modifications, etc.)\n\t */\n\tattribution?: IAttributionCollection<AttributionKey>;\n\n\t/**\n\t * Properties that have been added to this segment via annotation.\n\t */\n\tproperties?: PropertySet;\n\n\tclone(): ISegment;\n\tcanAppend(segment: ISegment): boolean;\n\tappend(segment: ISegment): void;\n\tsplitAt(pos: number): ISegment | undefined;\n\t// Changing this to something other than any would break consumers.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\ttoJSONObject(): any;\n\tisLeaf(): this is ISegment;\n}\n\n/**\n * Determine if a segment has been removed.\n * @legacy\n * @alpha\n */\nexport function segmentIsRemoved(segment: ISegment): boolean {\n\treturn isRemoved(segment);\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISegmentAction<TClientData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(\n\t\tsegment: ISegment,\n\t\tpos: number,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tstart: number,\n\t\tend: number,\n\t\taccum: TClientData,\n\t): boolean;\n}\nexport interface ISegmentChanges {\n\tnext?: SegmentWithInfo<IInsertionInfo>;\n\treplaceCurrent?: SegmentWithInfo<IInsertionInfo>;\n}\n\nexport interface InsertContext {\n\tcandidateSegment?: SegmentWithInfo<IInsertionInfo>;\n\tleaf: (segment: ISegmentLeaf | undefined, pos: number, ic: InsertContext) => ISegmentChanges;\n\tcontinuePredicate?: (continueFromBlock: MergeBlock) => boolean;\n}\n\nexport interface ObliterateInfo {\n\tstart: LocalReferencePosition;\n\tend: LocalReferencePosition;\n\trefSeq: number;\n\tclientId: number;\n\tseq: number;\n\tlocalSeq: number | undefined;\n\tsegmentGroup: SegmentGroup | undefined;\n}\n\nexport interface SegmentGroup {\n\tsegments: ISegmentLeaf[];\n\tpreviousProps?: PropertySet[];\n\tlocalSeq?: number;\n\trefSeq: number;\n\tobliterateInfo?: ObliterateInfo;\n}\n\n/**\n * Note that the actual branching factor of the MergeTree is `MaxNodesInBlock - 1`. This is because\n * the MergeTree always inserts first, then checks for overflow and splits if the child count equals\n * `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to\n * facilitate splits.)\n */\nexport const MaxNodesInBlock = 8;\nexport class MergeBlock implements Partial<IMergeNodeInfo> {\n\tpublic children: IMergeNode[];\n\tpublic needsScour?: boolean;\n\tpublic parent?: MergeBlock;\n\tpublic index: number = 0;\n\tpublic ordinal: string = \"\";\n\tpublic cachedLength: number | undefined = 0;\n\n\t/**\n\t * Maps each tile label in this block to the rightmost (i.e. furthest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic rightmostTiles: Readonly<MapLike<Marker>>;\n\t/**\n\t * Maps each tile label in this block to the leftmost (i.e. nearest) marker associated with that tile label.\n\t * When combined with the tree structure of MergeBlocks, this allows accelerated queries for nearest tile\n\t * with a certain label before a given position\n\t */\n\tpublic leftmostTiles: Readonly<MapLike<Marker>>;\n\n\tisLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Supports querying the total length of all descendants of this IMergeBlock from the perspective of any\n\t * (clientId, seq) within the collab window.\n\t *\n\t * @remarks This is only optional for implementation reasons (internal nodes can be created/moved without\n\t * immediately initializing the partial lengths). Aside from mid-update on tree operations, these lengths\n\t * objects are always defined.\n\t */\n\tpartialLengths?: PartialSequenceLengths;\n\n\tpublic constructor(public childCount: number) {\n\t\t// Suppression needed due to the way the merge tree children are initalized - we\n\t\t// allocate 8 children blocks, but any unused blocks are not counted in the childCount.\n\t\t// Using Array.from leads to unused children being undefined, which are counted in childCount.\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tthis.children = new Array<IMergeNode>(MaxNodesInBlock);\n\t\tthis.rightmostTiles = createMap<Marker>();\n\t\tthis.leftmostTiles = createMap<Marker>();\n\t}\n\n\tpublic setOrdinal(child: IMergeNode, index: number): void {\n\t\tconst childCount = this.childCount;\n\t\tassert(\n\t\t\tchildCount >= 1 && childCount <= MaxNodesInBlock,\n\t\t\t0x040 /* \"Child count is not within [1,8] range!\" */,\n\t\t);\n\t\tchild.ordinal = computeHierarchicalOrdinal(\n\t\t\tMaxNodesInBlock,\n\t\t\tchildCount,\n\t\t\tthis.ordinal,\n\t\t\tindex === 0 ? undefined : this.children[index - 1]?.ordinal,\n\t\t);\n\t}\n}\nexport function assignChild<C extends IMergeNodeBuilder>(\n\tparent: MergeBlock,\n\tchild: C,\n\tindex: number,\n\tupdateOrdinal = true,\n): asserts child is C & IMergeNodeInfo {\n\tconst node = Object.assign<C, IMergeNodeInfo>(child, {\n\t\tparent,\n\t\tindex,\n\t\tordinal: hasProp(child, \"ordinal\", \"string\") ? child.ordinal : \"\",\n\t});\n\tif (updateOrdinal) {\n\t\tparent.setOrdinal(node, index);\n\t}\n\tparent.children[index] = node;\n}\n\nexport function seqLTE(seq: number, minOrRefSeq: number): boolean {\n\treturn seq !== UnassignedSequenceNumber && seq <= minOrRefSeq;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport abstract class BaseSegment implements ISegment {\n\tpublic cachedLength: number = 0;\n\n\tpublic readonly trackingCollection: TrackingGroupCollection = new TrackingGroupCollection(\n\t\tthis,\n\t);\n\t/***/\n\tpublic attribution?: IAttributionCollection<AttributionKey>;\n\n\tpublic properties?: PropertySet;\n\tpublic abstract readonly type: string;\n\tpublic constructor(properties?: PropertySet) {\n\t\tif (properties !== undefined) {\n\t\t\tthis.properties = clone(properties);\n\t\t}\n\t}\n\n\tpublic hasProperty(key: string): boolean {\n\t\treturn !!this.properties && this.properties[key] !== undefined;\n\t}\n\n\tpublic isLeaf(): this is ISegment {\n\t\treturn true;\n\t}\n\n\tprotected cloneInto(b: ISegment): void {\n\t\tconst seg: ISegmentPrivate = b;\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(seg, {\n\t\t\t\tclientId: this.clientId,\n\t\t\t\tseq: this.seq,\n\t\t\t});\n\t\t}\n\t\t// TODO: deep clone properties\n\t\tseg.properties = clone(this.properties);\n\t\tif (isRemoved(this)) {\n\t\t\toverwriteInfo<IRemovalInfo>(seg, {\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\toverwriteInfo<IMoveInfo>(seg, {\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t});\n\t\t}\n\t\tseg.attribution = this.attribution?.clone();\n\t}\n\n\tpublic canAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tprotected addSerializedProps(jseg: IJSONSegment): void {\n\t\tif (this.properties) {\n\t\t\tjseg.props = { ...this.properties };\n\t\t}\n\t}\n\t// This has to return any type because the return type is different for different segment types.\n\t// TODO: If possible, change the return type to match what should be returned for each segment type.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic abstract toJSONObject(): any;\n\n\tpublic splitAt(pos: number): ISegment | undefined {\n\t\tif (pos <= 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst leafSegment: ISegmentPrivate | undefined = this.createSplitSegmentAt(pos);\n\n\t\tif (!leafSegment) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (isMergeNode(this)) {\n\t\t\toverwriteInfo<IMergeNodeInfo>(leafSegment, {\n\t\t\t\tindex: this.index + 1,\n\t\t\t\t// Give the leaf a temporary yet valid ordinal.\n\t\t\t\t// when this segment is put in the tree, it will get its real ordinal,\n\t\t\t\t// but this ordinal meets all the necessary invariants for now.\n\t\t\t\t// Ordinals exist purely for lexicographical sort order and use a small set of valid bytes for each string character.\n\t\t\t\t// The extra handling fromCodePoint has for things like surrogate pairs is therefore unnecessary.\n\t\t\t\t// eslint-disable-next-line unicorn/prefer-code-point\n\t\t\t\tordinal: this.ordinal + String.fromCharCode(0),\n\t\t\t\tparent: this.parent,\n\t\t\t});\n\t\t}\n\n\t\tif (isInserted(this)) {\n\t\t\toverwriteInfo<IInsertionInfo>(leafSegment, {\n\t\t\t\tseq: this.seq,\n\t\t\t\tlocalSeq: this.localSeq,\n\t\t\t\tclientId: this.clientId,\n\t\t\t});\n\t\t}\n\t\tif (isRemoved(this)) {\n\t\t\toverwriteInfo<IRemovalInfo>(leafSegment, {\n\t\t\t\tremovedClientIds: [...this.removedClientIds],\n\t\t\t\tremovedSeq: this.removedSeq,\n\t\t\t\tlocalRemovedSeq: this.localRemovedSeq,\n\t\t\t});\n\t\t}\n\t\tif (isMoved(this)) {\n\t\t\toverwriteInfo<IMoveInfo>(leafSegment, {\n\t\t\t\tmovedClientIds: [...this.movedClientIds],\n\t\t\t\tmovedSeq: this.movedSeq,\n\t\t\t\tmovedSeqs: [...this.movedSeqs],\n\t\t\t\tlocalMovedSeq: this.localMovedSeq,\n\t\t\t\twasMovedOnInsert: this.wasMovedOnInsert,\n\t\t\t});\n\t\t}\n\n\t\tthis.trackingCollection.copyTo(leafSegment);\n\t\tif (this.attribution) {\n\t\t\tleafSegment.attribution = this.attribution.splitAt(pos);\n\t\t}\n\n\t\treturn leafSegment;\n\t}\n\n\tpublic abstract clone(): ISegment;\n\n\tpublic append(other: ISegment): void {\n\t\t// Note: Must call 'appendLocalRefs' before modifying this segment's length as\n\t\t// 'this.cachedLength' is used to adjust the offsets of the local refs.\n\t\tLocalReferenceCollection.append(this, other);\n\t\tif (this.attribution) {\n\t\t\tassert(\n\t\t\t\tother.attribution !== undefined,\n\t\t\t\t0x4bd /* attribution should be set on appendee */,\n\t\t\t);\n\t\t\tthis.attribution.append(other.attribution);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tother.attribution === undefined,\n\t\t\t\t0x4be /* attribution should not be set on appendee */,\n\t\t\t);\n\t\t}\n\n\t\tthis.cachedLength ??= 0;\n\t\tthis.cachedLength += other.cachedLength;\n\t}\n\n\tprotected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;\n}\n\n/**\n * The special-cased property key that tracks the id of a {@link Marker}.\n *\n * @remarks In general, marker ids should be accessed using the inherent method\n * {@link Marker.getId}. Marker ids should not be updated after creation.\n * @legacy\n * @alpha\n */\nexport const reservedMarkerIdKey = \"markerId\";\n\n/**\n * @internal\n */\nexport const reservedMarkerSimpleTypeKey = \"markerSimpleType\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IJSONMarkerSegment extends IJSONSegment {\n\tmarker: IMarkerDef;\n}\n\n/**\n * Markers are a special kind of segment that do not hold any content.\n *\n * Markers with a reference type of {@link ReferenceType.Tile} support spatially\n * accelerated queries for finding the next marker to the left or right of it in\n * sub-linear time. This is useful, for example, in the case of jumping from the\n * start of a paragraph to the end, assuming a paragraph is bound by markers at\n * the start and end.\n *\n * @legacy\n * @alpha\n */\nexport class Marker extends BaseSegment implements ReferencePosition, ISegment {\n\tpublic static readonly type = \"Marker\";\n\tpublic static is(segment: ISegment): segment is Marker {\n\t\treturn segment.type === Marker.type;\n\t}\n\tpublic readonly type = Marker.type;\n\n\tpublic static make(refType: ReferenceType, props?: PropertySet): Marker {\n\t\treturn new Marker(refType, props);\n\t}\n\n\tconstructor(\n\t\tpublic refType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tsuper(props);\n\t\tthis.cachedLength = 1;\n\t}\n\n\ttoJSONObject(): IJSONMarkerSegment {\n\t\tconst obj: IJSONMarkerSegment = { marker: { refType: this.refType } };\n\t\tsuper.addSerializedProps(obj);\n\t\treturn obj;\n\t}\n\n\tstatic fromJSONObject(spec: IJSONSegment): Marker | undefined {\n\t\tif (spec && typeof spec === \"object\" && \"marker\" in spec) {\n\t\t\treturn Marker.make((spec.marker as Marker).refType, spec.props as PropertySet);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tclone(): Marker {\n\t\tconst b = Marker.make(this.refType, this.properties);\n\t\tthis.cloneInto(b);\n\t\treturn b;\n\t}\n\n\tgetSegment(): Marker {\n\t\treturn this;\n\t}\n\n\tgetOffset(): number {\n\t\treturn 0;\n\t}\n\n\tgetProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n\n\tgetId(): string | undefined {\n\t\treturn this.properties?.[reservedMarkerIdKey] as string;\n\t}\n\n\ttoString(): string {\n\t\treturn `M${this.getId()}`;\n\t}\n\n\tprotected createSplitSegmentAt(pos: number): undefined {\n\t\treturn undefined;\n\t}\n\n\tcanAppend(segment: ISegment): boolean {\n\t\treturn false;\n\t}\n\n\tappend(): void {\n\t\tthrow new Error(\"Can not append to marker\");\n\t}\n}\n\n/**\n * This class is used to track facts about the current window of collaboration. This window is defined by the server\n * specified minimum sequence number to the last sequence number seen. Additionally, it track state for outstanding\n * local operations.\n * @internal\n */\nexport class CollaborationWindow {\n\tclientId = LocalClientId;\n\tcollaborating = false;\n\n\t/**\n\t * Lowest-numbered segment in window; no client can reference a state before this one\n\t */\n\tminSeq = 0;\n\t/**\n\t * Highest-numbered segment in window and current reference sequence number for this client.\n\t */\n\tcurrentSeq = 0;\n\n\t/**\n\t * Highest-numbered localSeq used for a pending segment.\n\t * Semantically, `localSeq`s provide an ordering on in-flight merge-tree operations:\n\t * for operations stamped with localSeqs `a` and `b`, `a < b` if and only if `a` was submitted before `b`.\n\t *\n\t * @remarks - This field is analogous to the `clientSequenceNumber` field on ops, but it's accessible to merge-tree\n\t * at op submission time rather than only at ack time. This enables more natural state tracking for in-flight ops.\n\t *\n\t * It's useful to stamp ops with such an incrementing counter because it enables reasoning about which segments existed from\n\t * the perspective of the local client at a given point in 'un-acked' time, which is necessary to support the reconnect flow.\n\t *\n\t * For example, imagine a client with initial state \"123456\" submits some ops to create the text \"123456ABC\".\n\t * If they insert the \"C\" first, then \"B\", then \"A\", their local segment state might look like this:\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t * (note that localSeq tracks the localSeq at which a segment was inserted)\n\t *\n\t * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate\n\t * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.\n\t *\n\t * It will generate the ops\n\t * 1. \\{ pos: 6, text: \"C\" \\}\n\t * 2. \\{ pos: 6, text: \"B\" \\}\n\t * 3. \\{ pos: 6, text: \"A\" \\}\n\t *\n\t * since when submitting the first op, remote clients don't know that this client is about to submit the \"A\" and \"B\".\n\t *\n\t * On the other hand, imagine if the client had originally submitted the ops in the order \"A\", \"B\", \"C\"\n\t * such that the segments' local state was instead:\n\t *\n\t * ```js\n\t * [\n\t * { seq: 0, text: \"1234\" },\n\t * { seq: 5, text: \"56\" },\n\t * { localSeq: 1, seq: UnassignedSequenceNumber, text: \"A\" },\n\t * { localSeq: 2, seq: UnassignedSequenceNumber, text: \"B\" },\n\t * { localSeq: 3, seq: UnassignedSequenceNumber, text: \"C\" },\n\t * ]\n\t * ```\n\t *\n\t * The resubmitted ops should instead be:\n\t * 1. \\{ pos: 6, text: \"A\" \\}\n\t * 2. \\{ pos: 7, text: \"B\" \\}\n\t * 3. \\{ pos: 8, text: \"C\" \\}\n\t *\n\t * since remote clients will have seen the \"A\" when processing the \"B\" as well as both the \"A\" and \"B\" when processing the \"C\".\n\t * As can be seen, the list of resubmitted ops is different in the two cases despite the merge-tree's segment state only differing\n\t * in `localSeq`.\n\t *\n\t * This example is a bit simplified from the general scenario: since no remote clients modified the merge-tree while the client\n\t * was disconnected, the resubmitted ops end up matching the original ops exactly.\n\t * However, this is not generally true: the production reconnect code takes into account visibility of segments based on both acked\n\t * and local information as appropriate.\n\t * Nonetheless, this simple scenario is enough to understand why it's useful to be able to determine if a segment should be visible\n\t * from a given (seq, localSeq) perspective.\n\t */\n\tlocalSeq = 0;\n\n\tloadFrom(a: CollaborationWindow): void {\n\t\tthis.clientId = a.clientId;\n\t\tthis.collaborating = a.collaborating;\n\t\tthis.minSeq = a.minSeq;\n\t\tthis.currentSeq = a.currentSeq;\n\t}\n}\n\n/**\n * Compares two numbers.\n */\nexport const compareNumbers = (a: number, b: number): number => a - b;\n\n/**\n * Compares two strings.\n */\nexport const compareStrings = (a: string, b: string): number => a.localeCompare(b);\n"]}
|
package/lib/opBuilder.d.ts
CHANGED
|
@@ -87,11 +87,6 @@ export declare function createInsertOp(pos: number, segSpec: unknown): IMergeTre
|
|
|
87
87
|
*
|
|
88
88
|
* @param ops - The ops to group
|
|
89
89
|
*
|
|
90
|
-
* @deprecated The ability to create group ops will be removed in an upcoming
|
|
91
|
-
* release, as group ops are redundant with he native batching capabilities of
|
|
92
|
-
* the runtime
|
|
93
|
-
*
|
|
94
|
-
* @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with he native batching capabilities of the runtime
|
|
95
90
|
* @internal
|
|
96
91
|
*/
|
|
97
92
|
export declare function createGroupOp(...ops: IMergeTreeDeltaOp[]): IMergeTreeGroupMsg;
|
package/lib/opBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opBuilder.d.ts","sourceRoot":"","sources":["../src/opBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EAEjB,kBAAkB,EAClB,mBAAmB,EAEnB,uBAAuB,EACvB,mBAAmB,EAEnB,KAAK,YAAY,EACjB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,GAChB,qBAAqB,GAAG,SAAS,CAYnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,WAAW,GAChB,qBAAqB,CAOvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX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H,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,WAAW,GAChB,qBAAqB,CAOvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAC3B,2BAA2B,CAO7B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAMnF;AAED;;;;;;;GAOG;AAEH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAM3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,aAAa,GAChB,4BAA4B,CAa9B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,mBAAmB,CAEzF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAMjF;AAED;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,GAAG,GAAG,EAAE,iBAAiB,EAAE,GAAG,kBAAkB,CAK7E"}
|
package/lib/opBuilder.js
CHANGED
|
@@ -143,11 +143,6 @@ export function createInsertOp(pos, segSpec) {
|
|
|
143
143
|
*
|
|
144
144
|
* @param ops - The ops to group
|
|
145
145
|
*
|
|
146
|
-
* @deprecated The ability to create group ops will be removed in an upcoming
|
|
147
|
-
* release, as group ops are redundant with he native batching capabilities of
|
|
148
|
-
* the runtime
|
|
149
|
-
*
|
|
150
|
-
* @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with he native batching capabilities of the runtime
|
|
151
146
|
* @internal
|
|
152
147
|
*/
|
|
153
148
|
// eslint-disable-next-line import/no-deprecated
|
package/lib/opBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opBuilder.js","sourceRoot":"","sources":["../src/opBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EASN,kBAAkB,GAIlB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,IAAI,EAAsB,MAAM,oBAAoB,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAAc,EACd,KAAkB;IAElB,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO;QACN,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE;QACnB,YAAY,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAClC,YAAY,EAAE,EAAE,EAAE,EAAE;QACpB,IAAI,EAAE,kBAAkB,CAAC,QAAQ;KACjC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACpC,KAAa,EACb,GAAW,EACX,KAAkB;IAElB,OAAO;QACN,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE;QACnB,IAAI,EAAE,kBAAkB,CAAC,QAAQ;KACjC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAClC,KAAa,EACb,GAAW,EACX,MAA6B;IAE7B,OAAO;QACN,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE;QACrB,IAAI,EAAE,kBAAkB,CAAC,QAAQ;KACjC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MA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AAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAgB;IAC3D,OAAO;QACN,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,kBAAkB,CAAC,MAAM;KAC/B,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,gDAAgD;AAChD,MAAM,UAAU,aAAa,CAAC,GAAG,GAAwB;IACxD,OAAO;QACN,GAAG;QACH,IAAI,EAAE,kBAAkB,CAAC,KAAK;KAC9B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISegment, Marker } from \"./mergeTreeNodes.js\";\nimport {\n\tIMergeTreeAnnotateMsg,\n\tIMergeTreeDeltaOp,\n\t// eslint-disable-next-line import/no-deprecated\n\tIMergeTreeGroupMsg,\n\tIMergeTreeInsertMsg,\n\t// eslint-disable-next-line import/no-deprecated\n\tIMergeTreeObliterateMsg,\n\tIMergeTreeRemoveMsg,\n\tMergeTreeDeltaType,\n\ttype AdjustParams,\n\ttype IMergeTreeAnnotateAdjustMsg,\n\ttype IMergeTreeObliterateSidedMsg,\n} from \"./ops.js\";\nimport { PropertySet, type MapLike } from \"./properties.js\";\nimport { normalizePlace, Side, type SequencePlace } from \"./sequencePlace.js\";\n\n/**\n * Creates the op for annotating the markers with the provided properties\n * @param marker - The marker to annotate\n * @param props - The properties to annotate the marker with\n * @returns The annotate op\n *\n * @internal\n */\nexport function createAnnotateMarkerOp(\n\tmarker: Marker,\n\tprops: PropertySet,\n): IMergeTreeAnnotateMsg | undefined {\n\tconst id = marker.getId();\n\tif (!id) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tprops: { ...props },\n\t\trelativePos1: { id, before: true },\n\t\trelativePos2: { id },\n\t\ttype: MergeTreeDeltaType.ANNOTATE,\n\t};\n}\n\n/**\n * Creates the op for annotating the range with the provided properties\n * @param start - The inclusive start position of the range to annotate\n * @param end - The exclusive end position of the range to annotate\n * @param props - The properties to annotate the range with\n * @returns The annotate op\n *\n * @internal\n */\nexport function createAnnotateRangeOp(\n\tstart: number,\n\tend: number,\n\tprops: PropertySet,\n): IMergeTreeAnnotateMsg {\n\treturn {\n\t\tpos1: start,\n\t\tpos2: end,\n\t\tprops: { ...props },\n\t\ttype: MergeTreeDeltaType.ANNOTATE,\n\t};\n}\n\n/**\n * Creates the op for annotating the range with the provided properties\n * @param start - The inclusive start position of the range to annotate\n * @param end - The exclusive end position of the range to annotate\n * @param props - The properties to annotate the range with\n * @returns The annotate op\n *\n * @internal\n */\nexport function createAdjustRangeOp(\n\tstart: number,\n\tend: number,\n\tadjust: MapLike<AdjustParams>,\n): IMergeTreeAnnotateAdjustMsg {\n\treturn {\n\t\tpos1: start,\n\t\tpos2: end,\n\t\tadjust: { ...adjust },\n\t\ttype: MergeTreeDeltaType.ANNOTATE,\n\t};\n}\n\n/**\n * Creates the op to remove a range\n *\n * @param start - The inclusive start of the range to remove\n * @param end - The exclusive end of the range to remove\n *\n * @internal\n */\nexport function createRemoveRangeOp(start: number, end: number): IMergeTreeRemoveMsg {\n\treturn {\n\t\tpos1: start,\n\t\tpos2: end,\n\t\ttype: MergeTreeDeltaType.REMOVE,\n\t};\n}\n\n/**\n * Creates the op to obliterate a range\n *\n * @param start - The inclusive start of the range to obliterate\n * @param end - The exclusive end of the range to obliterate\n *\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport function createObliterateRangeOp(start: number, end: number): IMergeTreeObliterateMsg {\n\treturn {\n\t\tpos1: start,\n\t\tpos2: end,\n\t\ttype: MergeTreeDeltaType.OBLITERATE,\n\t};\n}\n\n/**\n * Creates the op to obliterate a range\n *\n * @param start - The start of the range to obliterate.\n * If a number is provided, the range will start before that index.\n * @param end - The end of the range to obliterate.\n * If a number is provided, the range will end after that index -1.\n * This preserves the previous behavior of not expanding obliteration ranges at the endpoints\n * for uses which predate the availability of endpoint expansion.\n *\n * @internal\n */\nexport function createObliterateRangeOpSided(\n\tstart: SequencePlace,\n\tend: SequencePlace,\n): IMergeTreeObliterateSidedMsg {\n\tconst startPlace = normalizePlace(start);\n\t// If a number is provided, default to after the previous index.\n\t// This preserves the behavior of obliterate prior to the introduction of endpoint expansion.\n\tconst endPlace =\n\t\ttypeof end === \"number\"\n\t\t\t? { pos: end - 1, side: Side.After } // default to inclusive bounds\n\t\t\t: normalizePlace(end);\n\treturn {\n\t\ttype: MergeTreeDeltaType.OBLITERATE_SIDED,\n\t\tpos1: { pos: startPlace.pos, before: startPlace.side === Side.Before },\n\t\tpos2: { pos: endPlace.pos, before: endPlace.side === Side.Before },\n\t};\n}\n\n/**\n * Creates an op for inserting a segment at the specified position.\n *\n * @param pos - The position to insert the segment at\n * @param segment - The segment to insert\n *\n * @internal\n */\nexport function createInsertSegmentOp(pos: number, segment: ISegment): IMergeTreeInsertMsg {\n\treturn createInsertOp(pos, segment.toJSONObject());\n}\n\n/**\n * Creates the op for inserting a segment from its JSON representation at\n * the specified position.\n *\n * @internal\n */\nexport function createInsertOp(pos: number, segSpec: unknown): IMergeTreeInsertMsg {\n\treturn {\n\t\tpos1: pos,\n\t\tseg: segSpec,\n\t\ttype: MergeTreeDeltaType.INSERT,\n\t};\n}\n\n/**\n * Creates a group op from the provided ops.\n *\n * @param ops - The ops to group\n *\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport function createGroupOp(...ops: IMergeTreeDeltaOp[]): IMergeTreeGroupMsg {\n\treturn {\n\t\tops,\n\t\ttype: MergeTreeDeltaType.GROUP,\n\t};\n}\n"]}
|