@fluid-experimental/tree 0.59.3003 → 0.59.4000-71128
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/Forest.js +1 -1
- package/dist/Forest.js.map +1 -1
- package/dist/SharedTree.d.ts +89 -30
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +93 -58
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +1 -1
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +19 -45
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +151 -151
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.d.ts +1 -16
- package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/dist/id-compressor/SessionIdNormalizer.js +23 -21
- package/dist/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +23 -4
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Forest.js +1 -1
- package/lib/Forest.js.map +1 -1
- package/lib/SharedTree.d.ts +89 -30
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +94 -59
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +1 -1
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +19 -45
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +152 -152
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.d.ts +1 -16
- package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -1
- package/lib/id-compressor/SessionIdNormalizer.js +23 -21
- package/lib/id-compressor/SessionIdNormalizer.js.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.d.ts +23 -4
- package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
- package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/test/IdCompressor.perf.tests.js +47 -67
- package/lib/test/IdCompressor.perf.tests.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +196 -101
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/Summary.tests.d.ts +0 -1
- package/lib/test/Summary.tests.d.ts.map +1 -1
- package/lib/test/Summary.tests.js +0 -3
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/Virtualization.tests.js +0 -4
- package/lib/test/Virtualization.tests.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +3 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts +14 -7
- package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/IdCompressorTestUtilities.js +40 -20
- package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +27 -51
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +19 -19
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js +1 -1
- package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
- package/lib/test/utilities/TestCommon.d.ts +4 -0
- package/lib/test/utilities/TestCommon.d.ts.map +1 -1
- package/lib/test/utilities/TestCommon.js +6 -0
- package/lib/test/utilities/TestCommon.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +4 -6
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +24 -19
- package/src/Forest.ts +1 -1
- package/src/SharedTree.ts +195 -46
- package/src/SharedTreeEncoder.ts +1 -1
- package/src/id-compressor/IdCompressor.ts +171 -198
- package/src/id-compressor/SessionIdNormalizer.ts +29 -41
- package/src/id-compressor/persisted-types/0.0.1.ts +25 -4
- package/src/index.ts +4 -0
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { assert, compareFiniteNumbers, compareFiniteNumbersReversed, fail, Mutable } from '../Common';
|
|
9
9
|
import { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers';
|
|
10
10
|
import { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap';
|
|
11
|
+
import { SerializedSessionIdNormalizer } from './persisted-types';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
|
|
@@ -319,7 +320,7 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
public serialize(): SerializedSessionIdNormalizer {
|
|
322
|
-
const serialized: Mutable<SerializedSessionIdNormalizer> = { localRanges: [] };
|
|
323
|
+
const serialized: Mutable<SerializedSessionIdNormalizer> = { localRanges: [], nextLocalId: this.nextLocalId };
|
|
323
324
|
const localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;
|
|
324
325
|
for (const [firstLocal, finalRanges] of this.idRanges.entries()) {
|
|
325
326
|
const [lastLocal, finalRangesTable] = finalRanges;
|
|
@@ -358,6 +359,7 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
358
359
|
}
|
|
359
360
|
idRanges.append(firstLocal, [lastLocal, finalRanges]);
|
|
360
361
|
}
|
|
362
|
+
normalizer.nextLocalId = serialized.nextLocalId;
|
|
361
363
|
return normalizer;
|
|
362
364
|
}
|
|
363
365
|
|
|
@@ -365,52 +367,38 @@ export class SessionIdNormalizer<TRangeObject> {
|
|
|
365
367
|
other: SessionIdNormalizer<TRangeObject>,
|
|
366
368
|
compareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b
|
|
367
369
|
): boolean {
|
|
368
|
-
return
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
return (
|
|
371
|
+
this.nextLocalId === other.nextLocalId &&
|
|
372
|
+
this.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {
|
|
373
|
+
const [lastLocalA, finalRangesA] = localRangeA;
|
|
374
|
+
const [lastLocalB, finalRangesB] = localRangeB;
|
|
375
|
+
if (finalRangesA === undefined || finalRangesB === undefined) {
|
|
376
|
+
return finalRangesA === finalRangesB;
|
|
377
|
+
}
|
|
374
378
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
379
|
+
const rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>) => {
|
|
380
|
+
const [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;
|
|
381
|
+
const [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;
|
|
382
|
+
return (
|
|
383
|
+
firstFinalA === firstFinalB &&
|
|
384
|
+
lastFinalA === lastFinalB &&
|
|
385
|
+
compareRangeObjects(rangeObjectA, rangeObjectB)
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
if (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {
|
|
390
|
+
if (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
return rangeEquals(finalRangesA, finalRangesB);
|
|
388
394
|
}
|
|
389
|
-
return rangeEquals(finalRangesA, finalRangesB);
|
|
390
|
-
}
|
|
391
395
|
|
|
392
|
-
|
|
393
|
-
|
|
396
|
+
return lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);
|
|
397
|
+
})
|
|
398
|
+
);
|
|
394
399
|
}
|
|
395
400
|
}
|
|
396
401
|
|
|
397
|
-
/**
|
|
398
|
-
* Serialized table for normalizing IDs made by the local session.
|
|
399
|
-
*
|
|
400
|
-
* TODO: Move this into ID compressor persisted types when integrated.
|
|
401
|
-
*/
|
|
402
|
-
export interface SerializedSessionIdNormalizer {
|
|
403
|
-
readonly localRanges: readonly (readonly [
|
|
404
|
-
firstLocal: LocalCompressedId,
|
|
405
|
-
lastLocal: LocalCompressedId,
|
|
406
|
-
finalRanges?: readonly (readonly [
|
|
407
|
-
alignedLocal: LocalCompressedId,
|
|
408
|
-
firstFinal: FinalCompressedId,
|
|
409
|
-
lastFinal: FinalCompressedId
|
|
410
|
-
])[]
|
|
411
|
-
])[];
|
|
412
|
-
}
|
|
413
|
-
|
|
414
402
|
type FinalRange<TRangeObject> = [
|
|
415
403
|
firstFinal: FinalCompressedId,
|
|
416
404
|
lastFinal: FinalCompressedId,
|
|
@@ -63,22 +63,43 @@ export type SerializedCluster = readonly [
|
|
|
63
63
|
overrides?: SerializedClusterOverrides
|
|
64
64
|
];
|
|
65
65
|
|
|
66
|
-
export type SerializedLocalOverrides = readonly [LocalCompressedId, string][];
|
|
66
|
+
export type SerializedLocalOverrides = readonly (readonly [LocalCompressedId, string])[];
|
|
67
67
|
|
|
68
68
|
export interface SerializedLocalState {
|
|
69
69
|
/**
|
|
70
70
|
* The total number of local IDs created by this session
|
|
71
71
|
*/
|
|
72
|
-
localIdCount: number;
|
|
72
|
+
readonly localIdCount: number;
|
|
73
73
|
/**
|
|
74
74
|
* Overrides generated by this session. Omitted if no local overrides exist in the session.
|
|
75
75
|
*/
|
|
76
|
-
overrides?: SerializedLocalOverrides;
|
|
76
|
+
readonly overrides?: SerializedLocalOverrides;
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* The most recent local ID in a range returned by `takeNextCreationRange`.
|
|
80
80
|
*/
|
|
81
|
-
lastTakenLocalId: LocalCompressedId | undefined;
|
|
81
|
+
readonly lastTakenLocalId: LocalCompressedId | undefined;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Serialized table for normalizing IDs made by the local session.
|
|
85
|
+
*/
|
|
86
|
+
readonly sessionNormalizer: SerializedSessionIdNormalizer;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Serialized table for normalizing IDs made by the local session.
|
|
91
|
+
*/
|
|
92
|
+
export interface SerializedSessionIdNormalizer {
|
|
93
|
+
readonly nextLocalId: LocalCompressedId;
|
|
94
|
+
readonly localRanges: readonly (readonly [
|
|
95
|
+
firstLocal: LocalCompressedId,
|
|
96
|
+
lastLocal: LocalCompressedId,
|
|
97
|
+
finalRanges?: readonly (readonly [
|
|
98
|
+
alignedLocal: LocalCompressedId,
|
|
99
|
+
firstFinal: FinalCompressedId,
|
|
100
|
+
lastFinal: FinalCompressedId
|
|
101
|
+
])[]
|
|
102
|
+
])[];
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
/**
|
package/src/index.ts
CHANGED