@fluidframework/merge-tree 0.57.0 → 0.58.0-55983
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +0 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js.map +1 -1
- package/dist/client.d.ts +3 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +14 -36
- package/dist/client.js.map +1 -1
- package/dist/collections.d.ts +1 -4
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +8 -24
- package/dist/collections.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/mergeTree.d.ts +8 -30
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +17 -326
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeDeltaCallback.d.ts.map +1 -1
- package/dist/mergeTreeDeltaCallback.js.map +1 -1
- package/dist/ops.d.ts +0 -6
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +1 -8
- package/dist/ops.js.map +1 -1
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +14 -26
- package/dist/partialLengths.js.map +1 -1
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +2 -15
- package/dist/properties.js.map +1 -1
- package/dist/segmentPropertiesManager.js +1 -5
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotChunks.js +3 -3
- package/dist/snapshotChunks.js.map +1 -1
- package/dist/snapshotV1.d.ts +2 -1
- package/dist/snapshotV1.d.ts.map +1 -1
- package/dist/snapshotV1.js +4 -4
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +3 -6
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts +3 -3
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js +12 -12
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/textSegment.d.ts.map +1 -1
- package/dist/textSegment.js +3 -17
- package/dist/textSegment.js.map +1 -1
- package/lib/base.d.ts +0 -1
- package/lib/base.d.ts.map +1 -1
- package/lib/base.js.map +1 -1
- package/lib/client.d.ts +3 -5
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +11 -33
- package/lib/client.js.map +1 -1
- package/lib/collections.d.ts +1 -4
- package/lib/collections.d.ts.map +1 -1
- package/lib/collections.js +8 -24
- package/lib/collections.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/mergeTree.d.ts +8 -30
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +16 -322
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeDeltaCallback.d.ts.map +1 -1
- package/lib/mergeTreeDeltaCallback.js.map +1 -1
- package/lib/ops.d.ts +0 -6
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js +0 -7
- package/lib/ops.js.map +1 -1
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +14 -26
- package/lib/partialLengths.js.map +1 -1
- package/lib/properties.d.ts.map +1 -1
- package/lib/properties.js +2 -15
- package/lib/properties.js.map +1 -1
- package/lib/segmentPropertiesManager.js +1 -5
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotChunks.js +3 -3
- package/lib/snapshotChunks.js.map +1 -1
- package/lib/snapshotV1.d.ts +2 -1
- package/lib/snapshotV1.d.ts.map +1 -1
- package/lib/snapshotV1.js +4 -4
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +3 -6
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts +3 -3
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js +12 -12
- package/lib/sortedSegmentSet.js.map +1 -1
- package/lib/textSegment.d.ts.map +1 -1
- package/lib/textSegment.js +4 -18
- package/lib/textSegment.js.map +1 -1
- package/package.json +11 -11
- package/src/base.ts +2 -3
- package/src/client.ts +11 -36
- package/src/collections.ts +9 -26
- package/src/index.ts +0 -1
- package/src/mergeTree.ts +32 -357
- package/src/mergeTreeDeltaCallback.ts +0 -1
- package/src/ops.ts +0 -7
- package/src/partialLengths.ts +17 -27
- package/src/properties.ts +7 -15
- package/src/segmentPropertiesManager.ts +5 -5
- package/src/snapshotChunks.ts +3 -3
- package/src/snapshotV1.ts +3 -3
- package/src/snapshotlegacy.ts +4 -6
- package/src/sortedSegmentSet.ts +12 -12
- package/src/textSegment.ts +5 -20
- package/dist/text.d.ts +0 -8
- package/dist/text.d.ts.map +0 -1
- package/dist/text.js +0 -78
- package/dist/text.js.map +0 -1
- package/lib/text.d.ts +0 -8
- package/lib/text.d.ts.map +0 -1
- package/lib/text.js +0 -73
- package/lib/text.js.map +0 -1
- package/src/text.ts +0 -83
|
@@ -75,7 +75,6 @@ export interface IMergeTreeClientSequenceArgs {
|
|
|
75
75
|
export type MergeTreeDeltaCallback =
|
|
76
76
|
(opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs) => void;
|
|
77
77
|
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
79
78
|
export interface IMergeTreeMaintenanceCallbackArgs extends IMergeTreeDeltaCallbackArgs<MergeTreeMaintenanceType> { }
|
|
80
79
|
|
|
81
80
|
export type MergeTreeMaintenanceCallback =
|
package/src/ops.ts
CHANGED
package/src/partialLengths.ts
CHANGED
|
@@ -177,8 +177,8 @@ export class PartialSequenceLengths {
|
|
|
177
177
|
// Find next earliest sequence number
|
|
178
178
|
if (indices[k] < childPartialsCounts[k]) {
|
|
179
179
|
const cpLen = childPartials[k].partialLengths[indices[k]];
|
|
180
|
-
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
180
|
+
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
182
182
|
if ((outerIndexOfEarliest < 0) || (cpLen.seq < earliestPartialLength!.seq)) {
|
|
183
183
|
outerIndexOfEarliest = k;
|
|
184
184
|
earliestPartialLength = cpLen;
|
|
@@ -186,8 +186,8 @@ export class PartialSequenceLengths {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
if (outerIndexOfEarliest >= 0) {
|
|
189
|
-
|
|
190
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
189
|
+
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
191
191
|
addNext(earliestPartialLength!);
|
|
192
192
|
indices[outerIndexOfEarliest]++;
|
|
193
193
|
}
|
|
@@ -198,8 +198,6 @@ export class PartialSequenceLengths {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
// TODO: incremental zamboni during build
|
|
201
|
-
// console.log(combinedPartialLengths.toString());
|
|
202
|
-
// console.log(`ZZZ...(min ${segmentWindow.minSeq})`);
|
|
203
201
|
if (PartialSequenceLengths.options.zamboni) {
|
|
204
202
|
combinedPartialLengths.zamboni(collabWindow);
|
|
205
203
|
}
|
|
@@ -208,7 +206,6 @@ export class PartialSequenceLengths {
|
|
|
208
206
|
combinedPartialLengths.verify();
|
|
209
207
|
}
|
|
210
208
|
|
|
211
|
-
// console.log(combinedPartialLengths.toString());
|
|
212
209
|
return combinedPartialLengths;
|
|
213
210
|
}
|
|
214
211
|
|
|
@@ -227,9 +224,6 @@ export class PartialSequenceLengths {
|
|
|
227
224
|
if (child.isLeaf()) {
|
|
228
225
|
// Leaf segment
|
|
229
226
|
const segment = child;
|
|
230
|
-
// eslint-disable-next-line max-len
|
|
231
|
-
// console.log(`seg br ${segBranchId} cli ${glc(mergeTree, segment.clientId)} me ${glc(mergeTree, mergeTree.collabWindow.clientId)}`);
|
|
232
|
-
|
|
233
227
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
234
228
|
if (seqLTE(segment.seq!, collabWindow.minSeq)) {
|
|
235
229
|
combinedPartialLengths.minLength += segment.cachedLength;
|
|
@@ -269,9 +263,9 @@ export class PartialSequenceLengths {
|
|
|
269
263
|
}
|
|
270
264
|
}
|
|
271
265
|
|
|
272
|
-
private static getOverlapClients(
|
|
266
|
+
private static getOverlapClients(overlapClientIds: number[], seglen: number) {
|
|
273
267
|
const bst = new RedBlackTree<number, IOverlapClient>(compareNumbers);
|
|
274
|
-
for (const clientId of
|
|
268
|
+
for (const clientId of overlapClientIds) {
|
|
275
269
|
bst.put(clientId, { clientId, seglen });
|
|
276
270
|
}
|
|
277
271
|
return bst;
|
|
@@ -283,11 +277,11 @@ export class PartialSequenceLengths {
|
|
|
283
277
|
seglen: number) {
|
|
284
278
|
if (partialLength.overlapRemoveClients) {
|
|
285
279
|
for (const clientId of overlapRemoveClientIds) {
|
|
286
|
-
const
|
|
287
|
-
if (!
|
|
280
|
+
const overlapClientNode = partialLength.overlapRemoveClients.get(clientId);
|
|
281
|
+
if (!overlapClientNode) {
|
|
288
282
|
partialLength.overlapRemoveClients.put(clientId, { clientId, seglen });
|
|
289
283
|
} else {
|
|
290
|
-
|
|
284
|
+
overlapClientNode.data.seglen += seglen;
|
|
291
285
|
}
|
|
292
286
|
}
|
|
293
287
|
} else {
|
|
@@ -373,7 +367,7 @@ export class PartialSequenceLengths {
|
|
|
373
367
|
}
|
|
374
368
|
}
|
|
375
369
|
if (seqPartialLen === undefined) {
|
|
376
|
-
|
|
370
|
+
|
|
377
371
|
seqPartialLen = {
|
|
378
372
|
clientId,
|
|
379
373
|
seglen: seqSeglen,
|
|
@@ -448,28 +442,25 @@ export class PartialSequenceLengths {
|
|
|
448
442
|
this.clientSeqNumbers[clientId] = [];
|
|
449
443
|
}
|
|
450
444
|
PartialSequenceLengths.addSeq(this.clientSeqNumbers[clientId], seq, seqSeglen);
|
|
451
|
-
// console.log(this.toString());
|
|
452
445
|
if (PartialSequenceLengths.options.zamboni) {
|
|
453
446
|
this.zamboni(collabWindow);
|
|
454
447
|
}
|
|
455
448
|
if (PartialSequenceLengths.options.verify) {
|
|
456
449
|
this.verify();
|
|
457
450
|
}
|
|
458
|
-
// console.log('ZZZ');
|
|
459
|
-
// console.log(this.toString());
|
|
460
451
|
}
|
|
461
452
|
|
|
462
453
|
public getPartialLength(refSeq: number, clientId: number) {
|
|
463
454
|
let pLen = this.minLength;
|
|
464
455
|
const seqIndex = latestLEQ(this.partialLengths, refSeq);
|
|
465
|
-
const
|
|
456
|
+
const cliLatestIndex = this.cliLatest(clientId);
|
|
466
457
|
const cliSeq = this.clientSeqNumbers[clientId];
|
|
467
458
|
if (seqIndex >= 0) {
|
|
468
459
|
// Add the partial length up to refSeq
|
|
469
460
|
pLen += this.partialLengths[seqIndex].len;
|
|
470
461
|
|
|
471
|
-
if (
|
|
472
|
-
const cliLatest = cliSeq[
|
|
462
|
+
if (cliLatestIndex >= 0) {
|
|
463
|
+
const cliLatest = cliSeq[cliLatestIndex];
|
|
473
464
|
|
|
474
465
|
if (cliLatest.seq > refSeq) {
|
|
475
466
|
// The client has local edits after refSeq, add in the length adjustments
|
|
@@ -483,8 +474,8 @@ export class PartialSequenceLengths {
|
|
|
483
474
|
} else {
|
|
484
475
|
// RefSeq is before any of the partial lengths
|
|
485
476
|
// so just add in all local edits of that client (which should all be after the refSeq)
|
|
486
|
-
if (
|
|
487
|
-
const cliLatest = cliSeq[
|
|
477
|
+
if (cliLatestIndex >= 0) {
|
|
478
|
+
const cliLatest = cliSeq[cliLatestIndex];
|
|
488
479
|
pLen += cliLatest.len;
|
|
489
480
|
}
|
|
490
481
|
}
|
|
@@ -497,7 +488,7 @@ export class PartialSequenceLengths {
|
|
|
497
488
|
buf += `(${partial.seq},${partial.len}) `;
|
|
498
489
|
}
|
|
499
490
|
|
|
500
|
-
// eslint-disable-next-line @typescript-eslint/no-for-in-array
|
|
491
|
+
// eslint-disable-next-line @typescript-eslint/no-for-in-array
|
|
501
492
|
for (const clientId in this.clientSeqNumbers) {
|
|
502
493
|
if (this.clientSeqNumbers[clientId].length > 0) {
|
|
503
494
|
buf += `Client `;
|
|
@@ -522,7 +513,6 @@ export class PartialSequenceLengths {
|
|
|
522
513
|
function copyDown(partialLengths: PartialSequenceLength[]) {
|
|
523
514
|
const mindex = latestLEQ(partialLengths, segmentWindow.minSeq);
|
|
524
515
|
let minLength = 0;
|
|
525
|
-
// console.log(`mindex ${mindex}`);
|
|
526
516
|
if (mindex >= 0) {
|
|
527
517
|
minLength = partialLengths[mindex].len;
|
|
528
518
|
const seqCount = partialLengths.length;
|
|
@@ -540,7 +530,7 @@ export class PartialSequenceLengths {
|
|
|
540
530
|
return minLength;
|
|
541
531
|
}
|
|
542
532
|
this.minLength += copyDown(this.partialLengths);
|
|
543
|
-
// eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in
|
|
544
534
|
for (const clientId in this.clientSeqNumbers) {
|
|
545
535
|
const cliPartials = this.clientSeqNumbers[clientId];
|
|
546
536
|
if (cliPartials) {
|
package/src/properties.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function combine(combiningInfo: ICombiningOp, currentValue: any, newValue
|
|
|
28
28
|
_currentValue = combiningInfo.defaultValue;
|
|
29
29
|
}
|
|
30
30
|
// Fixed set of operations for now
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
switch (combiningInfo.name) {
|
|
33
33
|
case "incr":
|
|
34
34
|
_currentValue += newValue as number;
|
|
@@ -56,8 +56,7 @@ export function combine(combiningInfo: ICombiningOp, currentValue: any, newValue
|
|
|
56
56
|
}
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
59
|
+
|
|
61
60
|
return _currentValue;
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -67,7 +66,7 @@ export function matchProperties(a: PropertySet | undefined, b: PropertySet | und
|
|
|
67
66
|
return false;
|
|
68
67
|
} else {
|
|
69
68
|
// For now, straightforward; later use hashing
|
|
70
|
-
|
|
69
|
+
|
|
71
70
|
for (const key in a) {
|
|
72
71
|
if (b[key] === undefined) {
|
|
73
72
|
return false;
|
|
@@ -79,7 +78,7 @@ export function matchProperties(a: PropertySet | undefined, b: PropertySet | und
|
|
|
79
78
|
return false;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
|
-
|
|
81
|
+
|
|
83
82
|
for (const key in b) {
|
|
84
83
|
if (a[key] === undefined) {
|
|
85
84
|
return false;
|
|
@@ -101,14 +100,10 @@ export function extend<T>(
|
|
|
101
100
|
seq?: number,
|
|
102
101
|
) {
|
|
103
102
|
if (extension !== undefined) {
|
|
104
|
-
|
|
105
|
-
console.log(`oh my ${extension}`);
|
|
106
|
-
}
|
|
107
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
103
|
+
// eslint-disable-next-line guard-for-in
|
|
108
104
|
for (const key in extension) {
|
|
109
105
|
const v = extension[key];
|
|
110
106
|
if (v === null) {
|
|
111
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
112
107
|
delete base[key];
|
|
113
108
|
} else {
|
|
114
109
|
if (combiningOp && (combiningOp.name !== "rewrite")) {
|
|
@@ -127,7 +122,7 @@ export function clone<T>(extension: MapLike<T> | undefined) {
|
|
|
127
122
|
return undefined;
|
|
128
123
|
}
|
|
129
124
|
const cloneMap = createMap<T>();
|
|
130
|
-
// eslint-disable-next-line guard-for-in
|
|
125
|
+
// eslint-disable-next-line guard-for-in
|
|
131
126
|
for (const key in extension) {
|
|
132
127
|
const v = extension[key];
|
|
133
128
|
if (v !== null) {
|
|
@@ -153,10 +148,7 @@ export function addProperties(
|
|
|
153
148
|
|
|
154
149
|
export function extendIfUndefined<T>(base: MapLike<T>, extension: MapLike<T> | undefined) {
|
|
155
150
|
if (extension !== undefined) {
|
|
156
|
-
|
|
157
|
-
console.log(`oh my ${extension}`);
|
|
158
|
-
}
|
|
159
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
151
|
+
|
|
160
152
|
for (const key in extension) {
|
|
161
153
|
if (base[key] === undefined) {
|
|
162
154
|
base[key] = extension[key];
|
|
@@ -33,7 +33,7 @@ export class PropertiesManager {
|
|
|
33
33
|
0x05c /* "Trying to update more annotate props than do exist!" */);
|
|
34
34
|
this.pendingKeyUpdateCount[key]--;
|
|
35
35
|
if (this.pendingKeyUpdateCount?.[key] === 0) {
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
delete this.pendingKeyUpdateCount[key];
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -72,12 +72,12 @@ export class PropertiesManager {
|
|
|
72
72
|
if (collaborating && seq === UnassignedSequenceNumber) {
|
|
73
73
|
this.pendingRewriteCount++;
|
|
74
74
|
}
|
|
75
|
-
// We are re-
|
|
75
|
+
// We are re-writing so delete all the properties
|
|
76
76
|
// not in the new props
|
|
77
77
|
for (const key of Object.keys(oldProps)) {
|
|
78
78
|
if (!newProps[key] && shouldModifyKey(key)) {
|
|
79
79
|
deltas[key] = oldProps[key];
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
delete oldProps[key];
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -105,7 +105,7 @@ export class PropertiesManager {
|
|
|
105
105
|
newValue = newProps[key];
|
|
106
106
|
}
|
|
107
107
|
if (newValue === null) {
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
delete oldProps[key];
|
|
110
110
|
} else {
|
|
111
111
|
oldProps[key] = newValue;
|
|
@@ -122,7 +122,7 @@ export class PropertiesManager {
|
|
|
122
122
|
): PropertySet | undefined {
|
|
123
123
|
if (oldProps) {
|
|
124
124
|
if (!newProps) {
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
newProps = createMap<any>();
|
|
127
127
|
}
|
|
128
128
|
if (!newManager) {
|
package/src/snapshotChunks.ts
CHANGED
|
@@ -94,7 +94,7 @@ export function serializeAsMinSupportedVersion(
|
|
|
94
94
|
switch (chunk.version) {
|
|
95
95
|
case undefined:
|
|
96
96
|
targetChuck = chunk as MergeTreeChunkLegacy;
|
|
97
|
-
targetChuck.headerMetadata =
|
|
97
|
+
targetChuck.headerMetadata = buildHeaderMetadataForLegacyChunk(path, targetChuck, options);
|
|
98
98
|
break;
|
|
99
99
|
|
|
100
100
|
case "1":
|
|
@@ -143,7 +143,7 @@ export function toLatestVersion(
|
|
|
143
143
|
version: "1",
|
|
144
144
|
length: chunkLegacy.chunkLengthChars,
|
|
145
145
|
segmentCount: chunkLegacy.chunkSegmentCount,
|
|
146
|
-
headerMetadata:
|
|
146
|
+
headerMetadata: buildHeaderMetadataForLegacyChunk(path, chunkLegacy, options),
|
|
147
147
|
segments: chunkLegacy.segmentTexts,
|
|
148
148
|
startIndex: chunkLegacy.chunkStartSegmentIndex,
|
|
149
149
|
};
|
|
@@ -156,7 +156,7 @@ export function toLatestVersion(
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
function
|
|
159
|
+
function buildHeaderMetadataForLegacyChunk(
|
|
160
160
|
path: string, chunk: MergeTreeChunkLegacy, options: PropertySet | undefined): MergeTreeHeaderMetadata | undefined {
|
|
161
161
|
if (path === SnapshotLegacy.header) {
|
|
162
162
|
if (chunk.headerMetadata !== undefined) {
|
package/src/snapshotV1.ts
CHANGED
|
@@ -48,6 +48,7 @@ export class SnapshotV1 {
|
|
|
48
48
|
constructor(
|
|
49
49
|
public mergeTree: MergeTree,
|
|
50
50
|
logger: ITelemetryLogger,
|
|
51
|
+
private readonly getLongClientId: (id: number) => string,
|
|
51
52
|
public filename?: string,
|
|
52
53
|
public onCompletion?: () => void,
|
|
53
54
|
) {
|
|
@@ -209,8 +210,7 @@ export class SnapshotV1 {
|
|
|
209
210
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
210
211
|
if (segment.seq! > minSeq) {
|
|
211
212
|
raw.seq = segment.seq;
|
|
212
|
-
|
|
213
|
-
raw.client = mergeTree.getLongClientId!(segment.clientId);
|
|
213
|
+
raw.client = this.getLongClientId(segment.clientId);
|
|
214
214
|
}
|
|
215
215
|
// We have already dispensed with removed segments below the MSN and removed segments with unassigned
|
|
216
216
|
// sequence numbers. Any remaining removal info should be preserved.
|
|
@@ -219,7 +219,7 @@ export class SnapshotV1 {
|
|
|
219
219
|
0x065 /* "On removal info preservation, segment has invalid removed sequence number!" */);
|
|
220
220
|
raw.removedSeq = segment.removedSeq;
|
|
221
221
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
222
|
-
raw.removedClient =
|
|
222
|
+
raw.removedClient = this.getLongClientId(segment.removedClientId!);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Sanity check that we are preserving either the seq < minSeq or a removed segment's info.
|
package/src/snapshotlegacy.ts
CHANGED
|
@@ -154,10 +154,8 @@ export class SnapshotLegacy {
|
|
|
154
154
|
const extractSegment =
|
|
155
155
|
// eslint-disable-next-line max-len
|
|
156
156
|
(segment: ISegment, pos: number, refSeq: number, clientId: number, start: number | undefined, end: number | undefined) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// eslint-disable-next-line eqeqeq
|
|
160
|
-
((segment.removedSeq === undefined) || (segment.removedSeq == UnassignedSequenceNumber) ||
|
|
157
|
+
if ((segment.seq !== UnassignedSequenceNumber) && (segment.seq! <= this.seq!) &&
|
|
158
|
+
((segment.removedSeq === undefined) || (segment.removedSeq === UnassignedSequenceNumber) ||
|
|
161
159
|
(segment.removedSeq > this.seq!))) {
|
|
162
160
|
if (prev && prev.canAppend(segment)
|
|
163
161
|
&& matchProperties(prev.properties, segment.properties)
|
|
@@ -192,8 +190,8 @@ export class SnapshotLegacy {
|
|
|
192
190
|
// When this condition happens, we might not write out all segments in getSeqLengthSegs()
|
|
193
191
|
// when writing out "body". Issue #1995 tracks following up on the core of the problem.
|
|
194
192
|
// In the meantime, this code makes sure we will write out all segments properly
|
|
195
|
-
|
|
196
|
-
if (this.header.segmentsTotalLength
|
|
193
|
+
|
|
194
|
+
if (this.header.segmentsTotalLength !== totalLength) {
|
|
197
195
|
this.logger.sendErrorEvent({
|
|
198
196
|
eventName: "SegmentsTotalLengthMismatch",
|
|
199
197
|
totalLength,
|
package/src/sortedSegmentSet.ts
CHANGED
|
@@ -10,37 +10,37 @@ import { ISegment } from "./mergeTree";
|
|
|
10
10
|
*
|
|
11
11
|
* This differs from a normal sorted set in that the keys are not fixed.
|
|
12
12
|
* The segments are sorted via their ordinals which can change as the merge tree is modified.
|
|
13
|
-
*
|
|
13
|
+
* Even though the values of the ordinals can change their ordering and uniqueness cannot, so the order of a set of
|
|
14
14
|
* segments ordered by their ordinals will always have the same order even if the ordinal values on
|
|
15
|
-
* the segments changes. This
|
|
15
|
+
* the segments changes. This invariant allows ensure the segments stay ordered and unique, and that new segments
|
|
16
16
|
* can be inserted into that order.
|
|
17
17
|
*/
|
|
18
18
|
export class SortedSegmentSet<T extends ISegment | { readonly segment: ISegment } = ISegment> {
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly ordinalSortedItems: T[] = [];
|
|
20
20
|
|
|
21
21
|
public get size(): number {
|
|
22
|
-
return this.
|
|
22
|
+
return this.ordinalSortedItems.length;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public get items(): readonly T[] {
|
|
26
|
-
return this.
|
|
26
|
+
return this.ordinalSortedItems;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public addOrUpdate(newItem: T, update?: (existingItem: T, newItem: T) => T) {
|
|
30
30
|
const position = this.findOrdinalPosition(this.getOrdinal(newItem));
|
|
31
31
|
if (position.exists) {
|
|
32
32
|
if (update) {
|
|
33
|
-
update(this.
|
|
33
|
+
update(this.ordinalSortedItems[position.index], newItem);
|
|
34
34
|
}
|
|
35
35
|
} else {
|
|
36
|
-
this.
|
|
36
|
+
this.ordinalSortedItems.splice(position.index, 0, newItem);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public remove(item: T): boolean {
|
|
41
41
|
const position = this.findOrdinalPosition(this.getOrdinal(item));
|
|
42
42
|
if (position.exists) {
|
|
43
|
-
this.
|
|
43
|
+
this.ordinalSortedItems.splice(position.index, 1);
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
return false;
|
|
@@ -62,19 +62,19 @@ export class SortedSegmentSet<T extends ISegment | { readonly segment: ISegment
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
private findOrdinalPosition(ordinal: string, start?: number, end?: number): { exists: boolean, index: number } {
|
|
65
|
-
if (this.
|
|
65
|
+
if (this.ordinalSortedItems.length === 0) {
|
|
66
66
|
return { exists: false, index: 0 };
|
|
67
67
|
}
|
|
68
68
|
if (start === undefined || end === undefined) {
|
|
69
|
-
return this.findOrdinalPosition(ordinal, 0, this.
|
|
69
|
+
return this.findOrdinalPosition(ordinal, 0, this.ordinalSortedItems.length - 1);
|
|
70
70
|
}
|
|
71
71
|
const index = start + Math.floor((end - start) / 2);
|
|
72
|
-
if (this.getOrdinal(this.
|
|
72
|
+
if (this.getOrdinal(this.ordinalSortedItems[index]) > ordinal) {
|
|
73
73
|
if (start === index) {
|
|
74
74
|
return { exists: false, index };
|
|
75
75
|
}
|
|
76
76
|
return this.findOrdinalPosition(ordinal, start, index - 1);
|
|
77
|
-
} else if (this.getOrdinal(this.
|
|
77
|
+
} else if (this.getOrdinal(this.ordinalSortedItems[index]) < ordinal) {
|
|
78
78
|
if (index === end) {
|
|
79
79
|
return { exists: false, index: index + 1 };
|
|
80
80
|
}
|
package/src/textSegment.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IIntegerRange } from "./base";
|
|
7
|
-
import { BaseSegment,
|
|
7
|
+
import { BaseSegment, ISegment, Marker, MergeTree } from "./mergeTree";
|
|
8
8
|
import { IJSONSegment } from "./ops";
|
|
9
9
|
import { PropertySet } from "./properties";
|
|
10
10
|
import { LocalReferenceCollection } from "./localReference";
|
|
@@ -31,11 +31,11 @@ export class TextSegment extends BaseSegment {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
public static make(text: string, props?: PropertySet) {
|
|
34
|
-
const
|
|
34
|
+
const seg = new TextSegment(text);
|
|
35
35
|
if (props) {
|
|
36
|
-
|
|
36
|
+
seg.addProperties(props);
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return seg;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public static fromJSONObject(spec: any) {
|
|
@@ -154,11 +154,6 @@ export class MergeTreeTextHelper {
|
|
|
154
154
|
textSegment: new TextSegment(""),
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
if (MergeTree.traceGatherText) {
|
|
158
|
-
console.log(
|
|
159
|
-
`get text on cli ${glc(this.mergeTree, this.mergeTree.collabWindow.clientId)} ` +
|
|
160
|
-
`ref cli ${glc(this.mergeTree, clientId)} refSeq ${refSeq}`);
|
|
161
|
-
}
|
|
162
157
|
this.mergeTree.mapRange<ITextAndMarkerAccumulator>(
|
|
163
158
|
{ leaf: this.gatherText },
|
|
164
159
|
refSeq,
|
|
@@ -175,11 +170,6 @@ export class MergeTreeTextHelper {
|
|
|
175
170
|
|
|
176
171
|
const accum: ITextAccumulator = { textSegment: new TextSegment(""), placeholder };
|
|
177
172
|
|
|
178
|
-
if (MergeTree.traceGatherText) {
|
|
179
|
-
console.log(
|
|
180
|
-
`get text on cli ${glc(this.mergeTree, this.mergeTree.collabWindow.clientId)} ` +
|
|
181
|
-
`ref cli ${glc(this.mergeTree, clientId)} refSeq ${refSeq}`);
|
|
182
|
-
}
|
|
183
173
|
this.mergeTree.mapRange<ITextAccumulator>(
|
|
184
174
|
{ leaf: this.gatherText },
|
|
185
175
|
refSeq,
|
|
@@ -207,12 +197,7 @@ export class MergeTreeTextHelper {
|
|
|
207
197
|
end: number, accumText: ITextAccumulatorType) => {
|
|
208
198
|
let _start = start;
|
|
209
199
|
if (TextSegment.is(segment)) {
|
|
210
|
-
|
|
211
|
-
console.log(
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
213
|
-
`@cli ${this.mergeTree.getLongClientId!(this.mergeTree.collabWindow.clientId)} ` +
|
|
214
|
-
`gather seg seq ${segment.seq} rseq ${segment.removedSeq} text ${segment.text}`);
|
|
215
|
-
}
|
|
200
|
+
|
|
216
201
|
let beginTags = "";
|
|
217
202
|
let endTags = "";
|
|
218
203
|
if (isTextAndMarkerAccumulator(accumText)) {
|
package/dist/text.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { ISegment, MergeTree } from "./mergeTree";
|
|
6
|
-
export declare function loadSegments(content: string, segLimit: number, markers?: boolean, withProps?: boolean): ISegment[];
|
|
7
|
-
export declare function loadText(content: string, mergeTree: MergeTree, segLimit: number, markers?: boolean): MergeTree;
|
|
8
|
-
//# sourceMappingURL=text.d.ts.map
|
package/dist/text.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EAER,SAAS,EAEZ,MAAM,aAAa,CAAC;AAIrB,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,EAAE,SAAS,GAAE,OAAc,cA2DlH;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,UAAQ,aAOhG"}
|
package/dist/text.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.loadText = exports.loadSegments = void 0;
|
|
8
|
-
const mergeTree_1 = require("./mergeTree");
|
|
9
|
-
const ops_1 = require("./ops");
|
|
10
|
-
const textSegment_1 = require("./textSegment");
|
|
11
|
-
function loadSegments(content, segLimit, markers = false, withProps = true) {
|
|
12
|
-
const BOMFreeContent = content.replace(/^\uFEFF/, "");
|
|
13
|
-
const paragraphs = BOMFreeContent.split(/\r?\n/);
|
|
14
|
-
for (let i = 0, len = paragraphs.length; i < len; i++) {
|
|
15
|
-
paragraphs[i] = paragraphs[i]
|
|
16
|
-
.replace(/\r?\n/g, " ")
|
|
17
|
-
.replace(/\u201c|\u201d/g, '"')
|
|
18
|
-
.replace(/\u2019/g, "'");
|
|
19
|
-
if (!markers && i !== paragraphs.length - 1) {
|
|
20
|
-
paragraphs[i] += "\n";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const segments = [];
|
|
24
|
-
for (const paragraph of paragraphs) {
|
|
25
|
-
let pgMarker;
|
|
26
|
-
if (markers) {
|
|
27
|
-
pgMarker = mergeTree_1.Marker.make(ops_1.ReferenceType.Tile, { [mergeTree_1.reservedTileLabelsKey]: ["pg"] });
|
|
28
|
-
}
|
|
29
|
-
if (withProps) {
|
|
30
|
-
if ((paragraph.includes("Chapter")) || (paragraph.includes("PRIDE AND PREJ"))) {
|
|
31
|
-
if (pgMarker) {
|
|
32
|
-
pgMarker.addProperties({ header: 2 });
|
|
33
|
-
segments.push(new textSegment_1.TextSegment(paragraph));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
segments.push(textSegment_1.TextSegment.make(paragraph, { fontSize: "140%", lineHeight: "150%" }));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const emphStrings = paragraph.split("_");
|
|
41
|
-
for (let i = 0, len = emphStrings.length; i < len; i++) {
|
|
42
|
-
// eslint-disable-next-line no-bitwise
|
|
43
|
-
if (i & 1) {
|
|
44
|
-
if (emphStrings[i].length > 0) {
|
|
45
|
-
segments.push(textSegment_1.TextSegment.make(emphStrings[i], { fontStyle: "italic" }));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
if (emphStrings[i].length > 0) {
|
|
50
|
-
segments.push(new textSegment_1.TextSegment(emphStrings[i]));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
segments.push(new textSegment_1.TextSegment(paragraph));
|
|
58
|
-
}
|
|
59
|
-
if (pgMarker) {
|
|
60
|
-
segments.push(pgMarker);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (segLimit > 0) {
|
|
64
|
-
segments.length = segLimit;
|
|
65
|
-
}
|
|
66
|
-
return segments;
|
|
67
|
-
}
|
|
68
|
-
exports.loadSegments = loadSegments;
|
|
69
|
-
function loadText(content, mergeTree, segLimit, markers = false) {
|
|
70
|
-
const segments = loadSegments(content, segLimit, markers);
|
|
71
|
-
mergeTree.reloadFromSegments(segments);
|
|
72
|
-
// console.log(`Number of Segments: ${segments.length}`);
|
|
73
|
-
// console.log(`Height: ${mergeTree.getStats().maxHeight}`);
|
|
74
|
-
// console.log(segTree.toString());
|
|
75
|
-
return mergeTree;
|
|
76
|
-
}
|
|
77
|
-
exports.loadText = loadText;
|
|
78
|
-
//# sourceMappingURL=text.js.map
|
package/dist/text.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ISegment,\n Marker,\n MergeTree,\n reservedTileLabelsKey,\n} from \"./mergeTree\";\nimport { ReferenceType } from \"./ops\";\nimport { TextSegment } from \"./textSegment\";\n\nexport function loadSegments(content: string, segLimit: number, markers: boolean = false, withProps: boolean = true) {\n const BOMFreeContent = content.replace(/^\\uFEFF/, \"\");\n\n const paragraphs = BOMFreeContent.split(/\\r?\\n/);\n for (let i = 0, len = paragraphs.length; i < len; i++) {\n paragraphs[i] = paragraphs[i]\n .replace(/\\r?\\n/g, \" \")\n .replace(/\\u201c|\\u201d/g, '\"')\n .replace(/\\u2019/g, \"'\");\n if (!markers && i !== paragraphs.length - 1) {\n paragraphs[i] += \"\\n\";\n }\n }\n\n const segments = [] as ISegment[];\n for (const paragraph of paragraphs) {\n let pgMarker: Marker | undefined;\n if (markers) {\n pgMarker = Marker.make(ReferenceType.Tile,\n { [reservedTileLabelsKey]: [\"pg\"] });\n }\n if (withProps) {\n if ((paragraph.includes(\"Chapter\")) || (paragraph.includes(\"PRIDE AND PREJ\"))) {\n if (pgMarker) {\n pgMarker.addProperties({ header: 2 });\n segments.push(new TextSegment(paragraph));\n } else {\n segments.push(\n TextSegment.make(paragraph, { fontSize: \"140%\", lineHeight: \"150%\" }));\n }\n } else {\n const emphStrings = paragraph.split(\"_\");\n for (let i = 0, len = emphStrings.length; i < len; i++) {\n // eslint-disable-next-line no-bitwise\n if (i & 1) {\n if (emphStrings[i].length > 0) {\n segments.push(\n TextSegment.make(emphStrings[i], { fontStyle: \"italic\" }));\n }\n } else {\n if (emphStrings[i].length > 0) {\n segments.push(new TextSegment(emphStrings[i]));\n }\n }\n }\n }\n } else {\n segments.push(new TextSegment(paragraph));\n }\n if (pgMarker) {\n segments.push(pgMarker);\n }\n }\n\n if (segLimit > 0) {\n segments.length = segLimit;\n }\n\n return segments;\n}\n\nexport function loadText(content: string, mergeTree: MergeTree, segLimit: number, markers = false) {\n const segments = loadSegments(content, segLimit, markers);\n mergeTree.reloadFromSegments(segments);\n // console.log(`Number of Segments: ${segments.length}`);\n // console.log(`Height: ${mergeTree.getStats().maxHeight}`);\n // console.log(segTree.toString());\n return mergeTree;\n}\n"]}
|
package/lib/text.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { ISegment, MergeTree } from "./mergeTree";
|
|
6
|
-
export declare function loadSegments(content: string, segLimit: number, markers?: boolean, withProps?: boolean): ISegment[];
|
|
7
|
-
export declare function loadText(content: string, mergeTree: MergeTree, segLimit: number, markers?: boolean): MergeTree;
|
|
8
|
-
//# sourceMappingURL=text.d.ts.map
|
package/lib/text.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EAER,SAAS,EAEZ,MAAM,aAAa,CAAC;AAIrB,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,EAAE,SAAS,GAAE,OAAc,cA2DlH;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,UAAQ,aAOhG"}
|