@fluidframework/merge-tree 0.59.2000-63294 → 0.59.3000-66610
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/.eslintrc.js +0 -1
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -33
- package/dist/client.js.map +1 -1
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/localReference.d.ts +58 -2
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js +60 -35
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts +25 -21
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +72 -79
- package/dist/mergeTree.js.map +1 -1
- package/dist/partialLengths.js +10 -10
- package/dist/partialLengths.js.map +1 -1
- package/dist/referencePositions.d.ts +54 -0
- package/dist/referencePositions.d.ts.map +1 -0
- package/dist/referencePositions.js +90 -0
- package/dist/referencePositions.js.map +1 -0
- package/dist/segmentGroupCollection.js +1 -1
- package/dist/segmentGroupCollection.js.map +1 -1
- package/dist/segmentPropertiesManager.js +5 -5
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotChunks.js.map +1 -1
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js +9 -9
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/snapshotV1.js +7 -7
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.js +5 -5
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js.map +1 -1
- package/lib/client.d.ts +4 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +10 -4
- package/lib/client.js.map +1 -1
- package/lib/collections.d.ts.map +1 -1
- package/lib/collections.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/localReference.d.ts +58 -2
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js +54 -29
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts +25 -21
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +39 -42
- package/lib/mergeTree.js.map +1 -1
- package/lib/referencePositions.d.ts +54 -0
- package/lib/referencePositions.d.ts.map +1 -0
- package/lib/referencePositions.js +78 -0
- package/lib/referencePositions.js.map +1 -0
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotChunks.js.map +1 -1
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js.map +1 -1
- package/package.json +83 -14
- package/src/client.ts +19 -17
- package/src/collections.ts +26 -52
- package/src/index.ts +1 -0
- package/src/localReference.ts +69 -36
- package/src/mergeTree.ts +71 -90
- package/src/referencePositions.ts +122 -0
- package/src/snapshotChunks.ts +8 -8
- package/src/snapshotLoader.ts +4 -4
- package/src/snapshotV1.ts +1 -1
- package/src/snapshotlegacy.ts +1 -1
- package/src/sortedSegmentSet.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/merge-tree",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.3000-66610",
|
|
4
4
|
"description": "Merge tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,19 +63,20 @@
|
|
|
63
63
|
"@fluidframework/common-utils": "^0.32.1",
|
|
64
64
|
"@fluidframework/container-definitions": "^0.48.1000",
|
|
65
65
|
"@fluidframework/core-interfaces": "^0.43.1000",
|
|
66
|
-
"@fluidframework/datastore-definitions": "0.59.
|
|
66
|
+
"@fluidframework/datastore-definitions": "0.59.3000-66610",
|
|
67
67
|
"@fluidframework/protocol-definitions": "^0.1028.1000",
|
|
68
|
-
"@fluidframework/runtime-definitions": "0.59.
|
|
69
|
-
"@fluidframework/runtime-utils": "0.59.
|
|
70
|
-
"@fluidframework/shared-object-base": "0.59.
|
|
71
|
-
"@fluidframework/telemetry-utils": "0.59.
|
|
68
|
+
"@fluidframework/runtime-definitions": "0.59.3000-66610",
|
|
69
|
+
"@fluidframework/runtime-utils": "0.59.3000-66610",
|
|
70
|
+
"@fluidframework/shared-object-base": "0.59.3000-66610",
|
|
71
|
+
"@fluidframework/telemetry-utils": "0.59.3000-66610"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@fluidframework/build-common": "^0.23.0",
|
|
75
|
-
"@fluidframework/
|
|
76
|
-
"@fluidframework/
|
|
77
|
-
"@fluidframework/
|
|
78
|
-
"@fluidframework/test-
|
|
75
|
+
"@fluidframework/build-tools": "^0.2.66048",
|
|
76
|
+
"@fluidframework/eslint-config-fluid": "^0.28.2000-0",
|
|
77
|
+
"@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@0.59.2000",
|
|
78
|
+
"@fluidframework/mocha-test-setup": "0.59.3000-66610",
|
|
79
|
+
"@fluidframework/test-runtime-utils": "0.59.3000-66610",
|
|
79
80
|
"@microsoft/api-extractor": "^7.22.2",
|
|
80
81
|
"@rushstack/eslint-config": "^2.5.1",
|
|
81
82
|
"@types/diff": "^3.5.1",
|
|
@@ -103,12 +104,80 @@
|
|
|
103
104
|
"random-js": "^1.0.8",
|
|
104
105
|
"rimraf": "^2.6.2",
|
|
105
106
|
"source-map-support": "^0.5.16",
|
|
106
|
-
"typescript": "~4.
|
|
107
|
+
"typescript": "~4.5.5",
|
|
107
108
|
"typescript-formatter": "7.1.0"
|
|
108
109
|
},
|
|
109
110
|
"typeValidation": {
|
|
110
|
-
"version": "0.59.
|
|
111
|
-
"broken": {
|
|
112
|
-
|
|
111
|
+
"version": "0.59.3000",
|
|
112
|
+
"broken": {
|
|
113
|
+
"InterfaceDeclaration_IMergeTreeAnnotateMsg": {
|
|
114
|
+
"forwardCompat": false,
|
|
115
|
+
"backCompat": false
|
|
116
|
+
},
|
|
117
|
+
"InterfaceDeclaration_IMergeTreeDelta": {
|
|
118
|
+
"forwardCompat": false,
|
|
119
|
+
"backCompat": false
|
|
120
|
+
},
|
|
121
|
+
"InterfaceDeclaration_IMergeTreeDeltaCallbackArgs": {
|
|
122
|
+
"forwardCompat": false,
|
|
123
|
+
"backCompat": false
|
|
124
|
+
},
|
|
125
|
+
"TypeAliasDeclaration_IMergeTreeDeltaOp": {
|
|
126
|
+
"forwardCompat": false,
|
|
127
|
+
"backCompat": false
|
|
128
|
+
},
|
|
129
|
+
"InterfaceDeclaration_IMergeTreeDeltaOpArgs": {
|
|
130
|
+
"forwardCompat": false,
|
|
131
|
+
"backCompat": false
|
|
132
|
+
},
|
|
133
|
+
"InterfaceDeclaration_IMergeTreeGroupMsg": {
|
|
134
|
+
"forwardCompat": false,
|
|
135
|
+
"backCompat": false
|
|
136
|
+
},
|
|
137
|
+
"InterfaceDeclaration_IMergeTreeInsertMsg": {
|
|
138
|
+
"forwardCompat": false,
|
|
139
|
+
"backCompat": false
|
|
140
|
+
},
|
|
141
|
+
"InterfaceDeclaration_IMergeTreeMaintenanceCallbackArgs": {
|
|
142
|
+
"forwardCompat": false,
|
|
143
|
+
"backCompat": false
|
|
144
|
+
},
|
|
145
|
+
"TypeAliasDeclaration_IMergeTreeOp": {
|
|
146
|
+
"forwardCompat": false,
|
|
147
|
+
"backCompat": false
|
|
148
|
+
},
|
|
149
|
+
"InterfaceDeclaration_IMergeTreeRemoveMsg": {
|
|
150
|
+
"forwardCompat": false,
|
|
151
|
+
"backCompat": false
|
|
152
|
+
},
|
|
153
|
+
"TypeAliasDeclaration_IntervalNode": {
|
|
154
|
+
"forwardCompat": false,
|
|
155
|
+
"backCompat": false
|
|
156
|
+
},
|
|
157
|
+
"TypeAliasDeclaration_MergeTreeDeltaOperationType": {
|
|
158
|
+
"forwardCompat": false,
|
|
159
|
+
"backCompat": false
|
|
160
|
+
},
|
|
161
|
+
"TypeAliasDeclaration_MergeTreeDeltaOperationTypes": {
|
|
162
|
+
"forwardCompat": false,
|
|
163
|
+
"backCompat": false
|
|
164
|
+
},
|
|
165
|
+
"EnumDeclaration_MergeTreeDeltaType": {
|
|
166
|
+
"forwardCompat": false,
|
|
167
|
+
"backCompat": false
|
|
168
|
+
},
|
|
169
|
+
"EnumDeclaration_MergeTreeMaintenanceType": {
|
|
170
|
+
"forwardCompat": false,
|
|
171
|
+
"backCompat": false
|
|
172
|
+
},
|
|
173
|
+
"EnumDeclaration_RBColor": {
|
|
174
|
+
"forwardCompat": false,
|
|
175
|
+
"backCompat": false
|
|
176
|
+
},
|
|
177
|
+
"InterfaceDeclaration_RBNode": {
|
|
178
|
+
"forwardCompat": false,
|
|
179
|
+
"backCompat": false
|
|
180
|
+
}
|
|
181
|
+
}
|
|
113
182
|
}
|
|
114
183
|
}
|
package/src/client.ts
CHANGED
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
ISegmentAction,
|
|
26
26
|
Marker,
|
|
27
27
|
MergeTree,
|
|
28
|
-
RangeStackMap,
|
|
29
28
|
SegmentGroup,
|
|
30
29
|
} from "./mergeTree";
|
|
31
30
|
import { MergeTreeDeltaCallback } from "./mergeTreeDeltaCallback";
|
|
@@ -53,11 +52,11 @@ import { SnapshotLegacy } from "./snapshotlegacy";
|
|
|
53
52
|
import { SnapshotLoader } from "./snapshotLoader";
|
|
54
53
|
import { MergeTreeTextHelper } from "./textSegment";
|
|
55
54
|
import { SnapshotV1 } from "./snapshotV1";
|
|
55
|
+
import { ReferencePosition, RangeStackMap } from "./referencePositions";
|
|
56
56
|
import {
|
|
57
57
|
IMergeTreeClientSequenceArgs,
|
|
58
58
|
IMergeTreeDeltaOpArgs,
|
|
59
59
|
MergeTreeMaintenanceCallback,
|
|
60
|
-
ReferencePosition,
|
|
61
60
|
} from "./index";
|
|
62
61
|
|
|
63
62
|
function elapsedMicroseconds(trace: Trace) {
|
|
@@ -629,8 +628,7 @@ export class Client {
|
|
|
629
628
|
getLongClientId(shortClientId: number) {
|
|
630
629
|
if (shortClientId >= 0) {
|
|
631
630
|
return this.shortClientIdMap[shortClientId];
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
631
|
+
} else {
|
|
634
632
|
return "original";
|
|
635
633
|
}
|
|
636
634
|
}
|
|
@@ -780,22 +778,29 @@ export class Client {
|
|
|
780
778
|
|
|
781
779
|
public applyStashedOp(op: IMergeTreeDeltaOp): SegmentGroup;
|
|
782
780
|
public applyStashedOp(op: IMergeTreeGroupMsg): SegmentGroup[];
|
|
783
|
-
public applyStashedOp(op: IMergeTreeOp)
|
|
781
|
+
public applyStashedOp(op: IMergeTreeOp): SegmentGroup | SegmentGroup[];
|
|
782
|
+
public applyStashedOp(op: IMergeTreeOp): SegmentGroup | SegmentGroup[] {
|
|
783
|
+
let metadata: SegmentGroup | SegmentGroup[] | undefined;
|
|
784
784
|
switch (op.type) {
|
|
785
785
|
case MergeTreeDeltaType.INSERT:
|
|
786
786
|
this.applyInsertOp({ op });
|
|
787
|
-
|
|
787
|
+
metadata = this.peekPendingSegmentGroups();
|
|
788
|
+
break;
|
|
788
789
|
case MergeTreeDeltaType.REMOVE:
|
|
789
790
|
this.applyRemoveRangeOp({ op });
|
|
790
|
-
|
|
791
|
+
metadata = this.peekPendingSegmentGroups();
|
|
792
|
+
break;
|
|
791
793
|
case MergeTreeDeltaType.ANNOTATE:
|
|
792
794
|
this.applyAnnotateRangeOp({ op });
|
|
793
|
-
|
|
795
|
+
metadata = this.peekPendingSegmentGroups();
|
|
796
|
+
break;
|
|
794
797
|
case MergeTreeDeltaType.GROUP:
|
|
795
798
|
return op.ops.map((o) => this.applyStashedOp(o));
|
|
796
799
|
default:
|
|
797
800
|
unreachableCase(op, "unrecognized op type");
|
|
798
801
|
}
|
|
802
|
+
assert(!!metadata, 0x2db /* "Applying op must generate a pending segment" */);
|
|
803
|
+
return metadata;
|
|
799
804
|
}
|
|
800
805
|
|
|
801
806
|
public applyMsg(msg: ISequencedDocumentMessage, local: boolean = false) {
|
|
@@ -809,8 +814,7 @@ export class Client {
|
|
|
809
814
|
};
|
|
810
815
|
if (opArgs.sequencedMessage?.clientId === this.longClientId || local) {
|
|
811
816
|
this.ackPendingSegment(opArgs);
|
|
812
|
-
}
|
|
813
|
-
else {
|
|
817
|
+
} else {
|
|
814
818
|
this.applyRemoteOp(opArgs);
|
|
815
819
|
}
|
|
816
820
|
}
|
|
@@ -915,7 +919,7 @@ export class Client {
|
|
|
915
919
|
assert(
|
|
916
920
|
catchUpMsgs === undefined || catchUpMsgs.length === 0,
|
|
917
921
|
0x03f /* "New format should not emit catchup ops" */);
|
|
918
|
-
const snap = new SnapshotV1(this.mergeTree, this.logger, (id)=>this.getLongClientId(id));
|
|
922
|
+
const snap = new SnapshotV1(this.mergeTree, this.logger, (id) => this.getLongClientId(id));
|
|
919
923
|
snap.extractSync();
|
|
920
924
|
return snap.emit(serializer, handle);
|
|
921
925
|
} else {
|
|
@@ -929,7 +933,7 @@ export class Client {
|
|
|
929
933
|
runtime: IFluidDataStoreRuntime,
|
|
930
934
|
storage: IChannelStorageService,
|
|
931
935
|
serializer: IFluidSerializer,
|
|
932
|
-
): Promise<{ catchupOpsP: Promise<ISequencedDocumentMessage[]
|
|
936
|
+
): Promise<{ catchupOpsP: Promise<ISequencedDocumentMessage[]>; }> {
|
|
933
937
|
const loader = new SnapshotLoader(runtime, this, this.mergeTree, this.logger, serializer);
|
|
934
938
|
|
|
935
939
|
return loader.initialize(storage);
|
|
@@ -943,8 +947,7 @@ export class Client {
|
|
|
943
947
|
const segWindow = this.getCollabWindow();
|
|
944
948
|
if (segWindow.collaborating) {
|
|
945
949
|
return UnassignedSequenceNumber;
|
|
946
|
-
}
|
|
947
|
-
else {
|
|
950
|
+
} else {
|
|
948
951
|
return UniversalSequenceNumber;
|
|
949
952
|
}
|
|
950
953
|
}
|
|
@@ -998,9 +1001,8 @@ export class Client {
|
|
|
998
1001
|
let clientId: number;
|
|
999
1002
|
if (op) {
|
|
1000
1003
|
clientId = this.getOrAddShortClientId(op.clientId);
|
|
1001
|
-
seq = op.
|
|
1002
|
-
}
|
|
1003
|
-
else {
|
|
1004
|
+
seq = op.referenceSequenceNumber;
|
|
1005
|
+
} else {
|
|
1004
1006
|
const segWindow = this.mergeTree.getCollabWindow();
|
|
1005
1007
|
seq = segWindow.currentSeq;
|
|
1006
1008
|
clientId = segWindow.clientId;
|
package/src/collections.ts
CHANGED
|
@@ -38,11 +38,9 @@ export class Stack<T> {
|
|
|
38
38
|
function ListRemoveEntry<U>(entry: List<U>): List<U> | undefined {
|
|
39
39
|
if (entry === undefined) {
|
|
40
40
|
return undefined;
|
|
41
|
-
}
|
|
42
|
-
else if (entry.isHead) {
|
|
41
|
+
} else if (entry.isHead) {
|
|
43
42
|
return undefined;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
43
|
+
} else {
|
|
46
44
|
entry.next.prev = entry.prev;
|
|
47
45
|
entry.prev.next = entry.next;
|
|
48
46
|
}
|
|
@@ -286,11 +284,9 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
286
284
|
const cmp = this.compareKeys(key, _node.key);
|
|
287
285
|
if (cmp < 0) {
|
|
288
286
|
_node = _node.left;
|
|
289
|
-
}
|
|
290
|
-
else if (cmp > 0) {
|
|
287
|
+
} else if (cmp > 0) {
|
|
291
288
|
_node = _node.right;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
289
|
+
} else {
|
|
294
290
|
return _node;
|
|
295
291
|
}
|
|
296
292
|
}
|
|
@@ -387,8 +383,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
387
383
|
if (key !== undefined) {
|
|
388
384
|
if (data === undefined) {
|
|
389
385
|
this.remove(key);
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
386
|
+
} else {
|
|
392
387
|
this.root = this.nodePut(this.root, key, data, conflict);
|
|
393
388
|
this.root.color = RBColor.BLACK;
|
|
394
389
|
}
|
|
@@ -403,16 +398,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
403
398
|
let _node = node;
|
|
404
399
|
if (!_node) {
|
|
405
400
|
return this.makeNode(key, data, RBColor.RED, 1);
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
401
|
+
} else {
|
|
408
402
|
const cmp = this.compareKeys(key, _node.key);
|
|
409
403
|
if (cmp < 0) {
|
|
410
404
|
_node.left = this.nodePut(_node.left, key, data, conflict);
|
|
411
|
-
}
|
|
412
|
-
else if (cmp > 0) {
|
|
405
|
+
} else if (cmp > 0) {
|
|
413
406
|
_node.right = this.nodePut(_node.right, key, data, conflict);
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
407
|
+
} else {
|
|
416
408
|
if (conflict) {
|
|
417
409
|
const kd = conflict(key, _node.key, data, _node.data);
|
|
418
410
|
if (kd.key) {
|
|
@@ -423,8 +415,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
423
415
|
} else {
|
|
424
416
|
_node.data = data;
|
|
425
417
|
}
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
418
|
+
} else {
|
|
428
419
|
_node.data = data;
|
|
429
420
|
}
|
|
430
421
|
}
|
|
@@ -504,8 +495,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
504
495
|
}
|
|
505
496
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
506
497
|
_node.left = this.nodeRemove(_node.left!, key);
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
498
|
+
} else {
|
|
509
499
|
if (this.isRed(_node.left)) {
|
|
510
500
|
_node = this.rotateRight(_node);
|
|
511
501
|
}
|
|
@@ -523,8 +513,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
523
513
|
_node.data = subtreeMin.data;
|
|
524
514
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
525
515
|
_node.right = this.nodeRemoveMin(_node.right!);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
516
|
+
} else {
|
|
528
517
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
529
518
|
_node.right = this.nodeRemove(_node.right!, key);
|
|
530
519
|
}
|
|
@@ -543,16 +532,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
543
532
|
const cmp = this.compareKeys(key, node.key);
|
|
544
533
|
if (cmp === 0) {
|
|
545
534
|
return node;
|
|
546
|
-
}
|
|
547
|
-
else if (cmp < 0) {
|
|
535
|
+
} else if (cmp < 0) {
|
|
548
536
|
return this.nodeFloor(node.left, key);
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
537
|
+
} else {
|
|
551
538
|
const rightFloor = this.nodeFloor(node.right, key);
|
|
552
539
|
if (rightFloor) {
|
|
553
540
|
return rightFloor;
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
541
|
+
} else {
|
|
556
542
|
return node;
|
|
557
543
|
}
|
|
558
544
|
}
|
|
@@ -570,16 +556,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
570
556
|
const cmp = this.compareKeys(key, node.key);
|
|
571
557
|
if (cmp === 0) {
|
|
572
558
|
return node;
|
|
573
|
-
}
|
|
574
|
-
else if (cmp > 0) {
|
|
559
|
+
} else if (cmp > 0) {
|
|
575
560
|
return this.nodeCeil(node.right, key);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
561
|
+
} else {
|
|
578
562
|
const leftCeil = this.nodeCeil(node.left, key);
|
|
579
563
|
if (leftCeil) {
|
|
580
564
|
return leftCeil;
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
565
|
+
} else {
|
|
583
566
|
return node;
|
|
584
567
|
}
|
|
585
568
|
}
|
|
@@ -595,8 +578,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
595
578
|
private nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {
|
|
596
579
|
if (!node.left) {
|
|
597
580
|
return node;
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
581
|
+
} else {
|
|
600
582
|
return this.nodeMin(node.left);
|
|
601
583
|
}
|
|
602
584
|
}
|
|
@@ -610,8 +592,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
610
592
|
private nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {
|
|
611
593
|
if (!node.right) {
|
|
612
594
|
return node;
|
|
613
|
-
}
|
|
614
|
-
else {
|
|
595
|
+
} else {
|
|
615
596
|
return this.nodeMax(node.right);
|
|
616
597
|
}
|
|
617
598
|
}
|
|
@@ -985,14 +966,11 @@ export class TST<T> {
|
|
|
985
966
|
const c = key.charAt(d);
|
|
986
967
|
if (c < x.c) {
|
|
987
968
|
return this.nodeGet(x.left, key, d);
|
|
988
|
-
}
|
|
989
|
-
else if (c > x.c) {
|
|
969
|
+
} else if (c > x.c) {
|
|
990
970
|
return this.nodeGet(x.right, key, d);
|
|
991
|
-
}
|
|
992
|
-
else if (d < (key.length - 1)) {
|
|
971
|
+
} else if (d < (key.length - 1)) {
|
|
993
972
|
return this.nodeGet(x.mid, key, d + 1);
|
|
994
|
-
}
|
|
995
|
-
else { return x; }
|
|
973
|
+
} else { return x; }
|
|
996
974
|
}
|
|
997
975
|
|
|
998
976
|
public put(key: string, val: T) {
|
|
@@ -1010,14 +988,11 @@ export class TST<T> {
|
|
|
1010
988
|
}
|
|
1011
989
|
if (c < _x.c) {
|
|
1012
990
|
_x.left = this.nodePut(_x.left, key, val, d);
|
|
1013
|
-
}
|
|
1014
|
-
else if (c > _x.c) {
|
|
991
|
+
} else if (c > _x.c) {
|
|
1015
992
|
_x.right = this.nodePut(_x.right, key, val, d);
|
|
1016
|
-
}
|
|
1017
|
-
else if (d < (key.length - 1)) {
|
|
993
|
+
} else if (d < (key.length - 1)) {
|
|
1018
994
|
_x.mid = this.nodePut(_x.mid, key, val, d + 1);
|
|
1019
|
-
}
|
|
1020
|
-
else {
|
|
995
|
+
} else {
|
|
1021
996
|
_x.val = val;
|
|
1022
997
|
}
|
|
1023
998
|
return _x;
|
|
@@ -1124,8 +1099,7 @@ export class TST<T> {
|
|
|
1124
1099
|
const recurD = (d < (pattern.length - 1)) ? d + 1 : d;
|
|
1125
1100
|
if (c === x.c) {
|
|
1126
1101
|
this.nodeProximity(x.mid, { text: prefix.text + x.c }, recurD, pattern, distance, q);
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1102
|
+
} else {
|
|
1129
1103
|
this.nodeProximity(x.mid, { text: prefix.text + x.c }, recurD, pattern, distance - 1, q);
|
|
1130
1104
|
}
|
|
1131
1105
|
if ((distance > 0) || (c > x.c)) {
|
package/src/index.ts
CHANGED
package/src/localReference.ts
CHANGED
|
@@ -7,61 +7,79 @@ import { assert } from "@fluidframework/common-utils";
|
|
|
7
7
|
import { Client } from "./client";
|
|
8
8
|
import {
|
|
9
9
|
ISegment,
|
|
10
|
+
} from "./mergeTree";
|
|
11
|
+
import { ICombiningOp, ReferenceType } from "./ops";
|
|
12
|
+
import { addProperties, PropertySet } from "./properties";
|
|
13
|
+
import { minReferencePosition,
|
|
14
|
+
maxReferencePosition,
|
|
15
|
+
compareReferencePositions,
|
|
16
|
+
refHasTileLabels,
|
|
17
|
+
refHasRangeLabels,
|
|
10
18
|
ReferencePosition,
|
|
11
19
|
refGetRangeLabels,
|
|
12
20
|
refGetTileLabels,
|
|
13
21
|
refHasRangeLabel,
|
|
14
22
|
refHasTileLabel,
|
|
15
|
-
} from "./
|
|
16
|
-
import { ICombiningOp, ReferenceType } from "./ops";
|
|
17
|
-
import { addProperties, PropertySet } from "./properties";
|
|
23
|
+
} from "./referencePositions";
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated - Use ReferencePosition
|
|
27
|
+
*/
|
|
28
|
+
export class LocalReference implements ReferencePosition {
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated - use DetachedReferencePosition
|
|
31
|
+
*/
|
|
20
32
|
public static readonly DetachedPosition: number = -1;
|
|
21
33
|
|
|
22
34
|
public properties: PropertySet | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated - use properties to store pair
|
|
37
|
+
*/
|
|
23
38
|
public pairedRef?: LocalReference;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated - use getSegment
|
|
41
|
+
*/
|
|
24
42
|
public segment: ISegment | undefined;
|
|
25
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated - use createReferencePosition
|
|
46
|
+
*/
|
|
26
47
|
constructor(
|
|
27
48
|
private readonly client: Client,
|
|
28
49
|
initSegment: ISegment,
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated - use getOffset
|
|
52
|
+
*/
|
|
29
53
|
public offset = 0,
|
|
30
54
|
public refType = ReferenceType.Simple,
|
|
55
|
+
properties?: PropertySet,
|
|
31
56
|
) {
|
|
32
57
|
this.segment = initSegment;
|
|
58
|
+
this.properties = properties;
|
|
33
59
|
}
|
|
34
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated - use minReferencePosition
|
|
63
|
+
*/
|
|
35
64
|
public min(b: LocalReference) {
|
|
36
|
-
|
|
37
|
-
return this;
|
|
38
|
-
} else {
|
|
39
|
-
return b;
|
|
40
|
-
}
|
|
65
|
+
return minReferencePosition(this, b);
|
|
41
66
|
}
|
|
42
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated - use maxReferencePosition
|
|
69
|
+
*/
|
|
43
70
|
public max(b: LocalReference) {
|
|
44
|
-
|
|
45
|
-
return this;
|
|
46
|
-
} else {
|
|
47
|
-
return b;
|
|
48
|
-
}
|
|
71
|
+
return maxReferencePosition(this, b);
|
|
49
72
|
}
|
|
50
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated - use compareReferencePositions
|
|
75
|
+
*/
|
|
51
76
|
public compare(b: LocalReference) {
|
|
52
|
-
|
|
53
|
-
return this.offset - b.offset;
|
|
54
|
-
} else {
|
|
55
|
-
if (this.segment === undefined
|
|
56
|
-
|| (b.segment !== undefined &&
|
|
57
|
-
this.segment.ordinal < b.segment.ordinal)) {
|
|
58
|
-
return -1;
|
|
59
|
-
} else {
|
|
60
|
-
return 1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
77
|
+
return compareReferencePositions(this, b);
|
|
63
78
|
}
|
|
64
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated - use getLocalReferencePosition
|
|
82
|
+
*/
|
|
65
83
|
public toPosition() {
|
|
66
84
|
if (this.segment && this.segment.parent) {
|
|
67
85
|
return this.getOffset() + this.client.getPosition(this.segment);
|
|
@@ -70,26 +88,39 @@ export class LocalReference implements ReferencePosition {
|
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated - use refHasTileLabels
|
|
93
|
+
*/
|
|
73
94
|
public hasTileLabels() {
|
|
74
|
-
return
|
|
95
|
+
return refHasTileLabels(this);
|
|
75
96
|
}
|
|
76
|
-
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated - use refHasRangeLabels
|
|
99
|
+
*/
|
|
77
100
|
public hasRangeLabels() {
|
|
78
|
-
return
|
|
101
|
+
return refHasRangeLabels(this);
|
|
79
102
|
}
|
|
80
|
-
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated - use refHasTileLabel
|
|
105
|
+
*/
|
|
81
106
|
public hasTileLabel(label: string): boolean {
|
|
82
107
|
return refHasTileLabel(this, label);
|
|
83
108
|
}
|
|
84
|
-
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated - use refHasRangeLabel
|
|
111
|
+
*/
|
|
85
112
|
public hasRangeLabel(label: string): boolean {
|
|
86
113
|
return refHasRangeLabel(this, label);
|
|
87
114
|
}
|
|
88
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated - use refGetTileLabels
|
|
117
|
+
*/
|
|
89
118
|
public getTileLabels(): string[] | undefined {
|
|
90
119
|
return refGetTileLabels(this);
|
|
91
120
|
}
|
|
92
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated - use refGetRangeLabels
|
|
123
|
+
*/
|
|
93
124
|
public getRangeLabels(): string[] | undefined {
|
|
94
125
|
return refGetRangeLabels(this);
|
|
95
126
|
}
|
|
@@ -102,6 +133,9 @@ export class LocalReference implements ReferencePosition {
|
|
|
102
133
|
this.properties = addProperties(this.properties, newProps, op);
|
|
103
134
|
}
|
|
104
135
|
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated - no longer supported
|
|
138
|
+
*/
|
|
105
139
|
public getClient() {
|
|
106
140
|
return this.client;
|
|
107
141
|
}
|
|
@@ -140,8 +174,7 @@ export class LocalReferenceCollection {
|
|
|
140
174
|
assert(seg1.localRefs.refsByOffset.length === seg1.cachedLength,
|
|
141
175
|
0x2be /* "LocalReferences array contains a gap" */);
|
|
142
176
|
seg1.localRefs.append(seg2.localRefs);
|
|
143
|
-
}
|
|
144
|
-
else if (seg1.localRefs) {
|
|
177
|
+
} else if (seg1.localRefs) {
|
|
145
178
|
// Since creating the LocalReferenceCollection, we may have appended
|
|
146
179
|
// segments that had no local references. Account for them now by padding the array.
|
|
147
180
|
seg1.localRefs.refsByOffset.length += seg2.cachedLength;
|