@fluid-experimental/tree 2.81.1 → 2.82.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 +4 -0
- package/api-report/experimental-tree.alpha.api.md +0 -3
- package/biome.jsonc +1 -1
- package/dist/ChangeTypes.d.ts +23 -5
- package/dist/ChangeTypes.d.ts.map +1 -1
- package/dist/ChangeTypes.js +23 -5
- package/dist/ChangeTypes.js.map +1 -1
- package/dist/Checkout.d.ts +7 -3
- package/dist/Checkout.d.ts.map +1 -1
- package/dist/Checkout.js +7 -3
- package/dist/Checkout.js.map +1 -1
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +2 -0
- package/dist/Common.js.map +1 -1
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +3 -1
- package/dist/LogViewer.js.map +1 -1
- package/dist/id-compressor/AppendOnlySortedMap.d.ts +21 -21
- package/dist/id-compressor/AppendOnlySortedMap.js +21 -21
- package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/lib/ChangeTypes.d.ts +23 -5
- package/lib/ChangeTypes.d.ts.map +1 -1
- package/lib/ChangeTypes.js +23 -5
- package/lib/ChangeTypes.js.map +1 -1
- package/lib/Checkout.d.ts +7 -3
- package/lib/Checkout.d.ts.map +1 -1
- package/lib/Checkout.js +7 -3
- package/lib/Checkout.js.map +1 -1
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +2 -0
- package/lib/Common.js.map +1 -1
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +3 -1
- package/lib/LogViewer.js.map +1 -1
- package/lib/id-compressor/AppendOnlySortedMap.d.ts +21 -21
- package/lib/id-compressor/AppendOnlySortedMap.js +21 -21
- package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
- package/package.json +24 -24
- package/src/ChangeTypes.ts +23 -5
- package/src/Checkout.ts +7 -3
- package/src/Common.ts +4 -3
- package/src/LogViewer.ts +1 -0
- package/src/id-compressor/AppendOnlySortedMap.ts +21 -21
|
@@ -18,37 +18,37 @@ export class AppendOnlySortedMap {
|
|
|
18
18
|
this.elements = [];
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Gets the number of entries in this map
|
|
22
22
|
*/
|
|
23
23
|
get size() {
|
|
24
24
|
return this.elements.length / 2;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Gets the min key in the map.
|
|
28
28
|
*/
|
|
29
29
|
minKey() {
|
|
30
30
|
return this.elements[0];
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Gets the max key in the map.
|
|
34
34
|
*/
|
|
35
35
|
maxKey() {
|
|
36
36
|
return this.elements[this.elements.length - 2];
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Gets the min value in the map.
|
|
40
40
|
*/
|
|
41
41
|
minValue() {
|
|
42
42
|
return this.elements[1];
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Gets the max value in the map.
|
|
46
46
|
*/
|
|
47
47
|
maxValue() {
|
|
48
48
|
return this.elements[this.elements.length - 1];
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Gets the first entry in the map.
|
|
52
52
|
*/
|
|
53
53
|
first() {
|
|
54
54
|
const { elements } = this;
|
|
@@ -59,7 +59,7 @@ export class AppendOnlySortedMap {
|
|
|
59
59
|
return [elements[0], elements[1]];
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Gets the last entry in the map.
|
|
63
63
|
*/
|
|
64
64
|
last() {
|
|
65
65
|
const { elements } = this;
|
|
@@ -82,7 +82,7 @@ export class AppendOnlySortedMap {
|
|
|
82
82
|
return [elements[realIndex], elements[realIndex + 1]];
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Gets an iterable of the entries in the map.
|
|
86
86
|
*/
|
|
87
87
|
*entries() {
|
|
88
88
|
const { elements } = this;
|
|
@@ -91,7 +91,7 @@ export class AppendOnlySortedMap {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* Gets an iterable of the keys in the map.
|
|
95
95
|
*/
|
|
96
96
|
*keys() {
|
|
97
97
|
const { elements } = this;
|
|
@@ -100,7 +100,7 @@ export class AppendOnlySortedMap {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
103
|
+
* Gets an iterable of the values in the map.
|
|
104
104
|
*/
|
|
105
105
|
*values() {
|
|
106
106
|
const { elements } = this;
|
|
@@ -109,7 +109,7 @@ export class AppendOnlySortedMap {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* Gets an iterable of the entries in the map, reversed.
|
|
113
113
|
*/
|
|
114
114
|
*entriesReversed() {
|
|
115
115
|
const { elements } = this;
|
|
@@ -119,8 +119,8 @@ export class AppendOnlySortedMap {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Adds a new key/value pair to the map. `key` must be \> to all keys in the map.
|
|
122
|
-
* @param key -
|
|
123
|
-
* @param value -
|
|
122
|
+
* @param key - The key to add.
|
|
123
|
+
* @param value - The value to add.
|
|
124
124
|
*/
|
|
125
125
|
append(key, value) {
|
|
126
126
|
const { elements } = this;
|
|
@@ -132,8 +132,8 @@ export class AppendOnlySortedMap {
|
|
|
132
132
|
elements.push(value);
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @
|
|
135
|
+
* Gets the value associated with `key` if such an entry exists, and `undefined` otherwise.
|
|
136
|
+
* @param key - The key to lookup.
|
|
137
137
|
*/
|
|
138
138
|
get(key) {
|
|
139
139
|
const index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);
|
|
@@ -143,17 +143,17 @@ export class AppendOnlySortedMap {
|
|
|
143
143
|
return this.elements[index + 1];
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
146
|
+
* Gets the entry associated with `key` if such an entry exists, the entry associated with the next lower key if
|
|
147
|
+
* such an entry exists, and `undefined` otherwise.
|
|
148
|
+
* @param key - The key to lookup.
|
|
149
149
|
*/
|
|
150
150
|
getPairOrNextLower(key) {
|
|
151
151
|
return this.getPairOrNextLowerBy(key, this.comparator);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
154
|
+
* Gets the entry associated with `key` if such an entry exists, the entry associated with the next higher key if
|
|
155
|
+
* such an entry exists, and `undefined` otherwise.
|
|
156
|
+
* @param key - The key to lookup.
|
|
157
157
|
*/
|
|
158
158
|
getPairOrNextHigher(key) {
|
|
159
159
|
return this.getPairOrNextHigherBy(key, this.comparator);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppendOnlySortedMap.js","sourceRoot":"","sources":["../../src/id-compressor/AppendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG/B;;OAEG;IACH,YAAsC,UAAkC;QAAlC,eAAU,GAAV,UAAU,CAAwB;QALrD,aAAQ,GAAc,EAAE,CAAC;IAK+B,CAAC;IAE5E;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAkB,CAAC;IAC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CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAC1F,KAAK,CAAC,mCAAmC,CACzC,CAAC;YACH,CAAC;YACD,IAAI,GAAG,EAAE,CAAC;QACX,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from '@fluidframework/core-utils/internal';\n\nimport { fail } from '../Common.js';\n\n/**\n * A map in which entries are always added in key-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlySortedMap<K, V> {\n\tprotected readonly elements: (K | V)[] = [];\n\n\t/**\n\t * @param comparator - a comparator for keys\n\t */\n\tpublic constructor(protected readonly comparator: (a: K, b: K) => number) {}\n\n\t/**\n\t * @returns the number of entries in this map\n\t */\n\tpublic get size(): number {\n\t\treturn this.elements.length / 2;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic minKey(): K | undefined {\n\t\treturn this.elements[0] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic maxKey(): K | undefined {\n\t\treturn this.elements[this.elements.length - 2] as K | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic minValue(): V | undefined {\n\t\treturn this.elements[1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min value in the map.\n\t */\n\tpublic maxValue(): V | undefined {\n\t\treturn this.elements[this.elements.length - 1] as V | undefined;\n\t}\n\n\t/**\n\t * @returns the min key in the map.\n\t */\n\tpublic first(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[0] as K, elements[1] as V];\n\t}\n\n\t/**\n\t * @returns the max key in the map.\n\t */\n\tpublic last(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst lastKeyIndex = length - 2;\n\t\treturn [elements[lastKeyIndex] as K, elements[lastKeyIndex + 1] as V];\n\t}\n\n\t/**\n\t * Returns the element at the insertion index.\n\t */\n\tpublic getAtIndex(index: number): [K, V] | undefined {\n\t\tconst realIndex = index * 2;\n\t\tconst { elements } = this;\n\t\tif (realIndex < 0 || realIndex > elements.length - 1) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[realIndex] as K, elements[realIndex + 1] as V];\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map.\n\t */\n\tpublic *entries(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the keys in the map.\n\t */\n\tpublic *keys(): IterableIterator<K> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i] as K;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the values in the map.\n\t */\n\tpublic *values(): IterableIterator<V> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i + 1] as V;\n\t\t}\n\t}\n\n\t/**\n\t * @returns an iterable of the entries in the map, reversed.\n\t */\n\tpublic *entriesReversed(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = elements.length - 2; i >= 0; i -= 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new key/value pair to the map. `key` must be \\> to all keys in the map.\n\t * @param key - the key to add.\n\t * @param value - the value to add.\n\t */\n\tpublic append(key: K, value: V): void {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0 && this.comparator(key, this.maxKey() as K) <= 0) {\n\t\t\tfail('Inserted key must be > all others in the map.');\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the value associated with `key` if such an entry exists, and undefined otherwise.\n\t */\n\tpublic get(key: K): V | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);\n\t\tif (index < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.elements[index + 1] as V;\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextLower(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(key, this.comparator);\n\t}\n\n\t/**\n\t * @param key - the key to lookup.\n\t * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry\n\t * exists, and undefined otherwise.\n\t */\n\tpublic getPairOrNextHigher(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(key, this.comparator);\n\t}\n\n\t/**\n\t * Compares two `AppendOnlySortedMap`s.\n\t */\n\tpublic equals(other: AppendOnlySortedMap<K, V>, compareValues: (a: V, b: V) => boolean): boolean {\n\t\tif (other === this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.elements.length !== other.elements.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = this.elements.length - 2; i >= 0; i -= 2) {\n\t\t\tconst keyThis = this.elements[i] as K;\n\t\t\tconst valueThis = this.elements[i + 1] as V;\n\t\t\tconst keyOther = other.elements[i] as K;\n\t\t\tconst valueOther = other.elements[i + 1] as V;\n\t\t\tif (this.comparator(keyThis, keyOther) !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!compareValues(valueThis, valueOther)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tlet prev: readonly [K, unknown] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(this.comparator(kv[0], prev[0]) > 0, 0x63e /* Keys in map must be sorted. */);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n\n\t/**\n\t * Queries a range of entries.\n\t * @param from - the key to start the range query at, inclusive.\n\t * @param to - the key to end the range query at, inclusive.\n\t * @returns the range of entries.\n\t */\n\tpublic *getRange(from: K, to: K): IterableIterator<readonly [K, V]> {\n\t\tconst keyIndexFrom = this.getKeyIndexOfOrNextHigher(from, this.comparator);\n\t\tif (keyIndexFrom === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst keyIndexTo = this.getKeyIndexOfOrNextLower(to, this.comparator);\n\t\tif (keyIndexTo === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = keyIndexFrom; i <= keyIndexTo; i += 2) {\n\t\t\tyield [this.elements[i] as K, this.elements[i + 1] as V];\n\t\t}\n\t}\n\n\tprotected getPairOrNextLowerBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextLower(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextLower<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tif (elements.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex > 0) {\n\t\t\t\treturn keyIndex - 2;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\tprotected getPairOrNextHigherBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextHigher(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextHigher<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex < length) {\n\t\t\t\treturn keyIndex;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\t/**\n\t * The value xor'd with the result index when a search fails.\n\t */\n\tpublic static readonly failureXor = -1;\n\n\t/**\n\t * Performs a binary search on the sorted array.\n\t * @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd\n\t * with `failureXor`. Note that negating is not an adequate solution as that could result in -0.\n\t */\n\tpublic static keyIndexOf<T, K, V>(\n\t\telements: readonly (K | V)[],\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number {\n\t\t// Low, high, and mid are addresses of [K,V] pairs and *not* key indices\n\t\tlet low = 0;\n\t\tlet high = elements.length / 2;\n\t\tlet mid = high >> 1;\n\t\twhile (low < high) {\n\t\t\tconst keyIndex = mid * 2;\n\t\t\tconst c = comparator(search, elements[keyIndex] as K, elements[keyIndex + 1] as V);\n\t\t\tif (c > 0) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else if (c < 0) {\n\t\t\t\thigh = mid;\n\t\t\t} else if (c === 0) {\n\t\t\t\treturn keyIndex;\n\t\t\t} else {\n\t\t\t\tfail('Invalid comparator.');\n\t\t\t}\n\t\t\tmid = (low + high) >> 1;\n\t\t}\n\t\treturn (mid * 2) ^ AppendOnlySortedMap.failureXor;\n\t}\n}\n\n/**\n * A map in which entries are always added in both key-sorted and value-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlyDoublySortedMap<K, V, S> extends AppendOnlySortedMap<K, V> {\n\tpublic constructor(\n\t\tkeyComparator: (a: K, b: K) => number,\n\t\tprivate readonly extractSearchValue: (value: V) => S,\n\t\tprivate readonly valueComparator: (search: S, value: S) => number\n\t) {\n\t\tsuper(keyComparator);\n\t}\n\n\tpublic append(key: K, value: V): void {\n\t\tif (\n\t\t\tthis.elements.length !== 0 &&\n\t\t\tthis.valueComparator(this.extractSearchValue(value), this.extractSearchValue(this.maxValue() as V)) <= 0\n\t\t) {\n\t\t\tfail('Inserted value must be > all others in the map.');\n\t\t}\n\t\tsuper.append(key, value);\n\t}\n\n\tprivate readonly compareValues = (search: S, _: K, value: V): number => {\n\t\treturn this.valueComparator(search, this.extractSearchValue(value));\n\t};\n\n\t/**\n\t * @param value - the value to lookup.\n\t * @returns the key associated with `value` if such an entry exists, and undefined otherwise.\n\t */\n\tpublic getByValue(value: S): K | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, value, this.compareValues);\n\t\treturn this.elements[index]?.[0];\n\t}\n\n\t/**\n\t * @param searchValue - the search value to lookup.\n\t * @returns the entry who's value, when run through the extractor provided to the constructor, matches\n\t * `searchValue`. If no such entry exists, this method returns the next lower entry as determined by the value\n\t * comparator provided to the constructor. If no such entry exists, this method returns undefined.\n\t */\n\tpublic getPairOrNextLowerByValue(searchValue: S): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(searchValue, this.compareValues);\n\t}\n\n\t/**\n\t * @param searchValue - the search value to lookup.\n\t * @returns the entry who's value, when run through the extractor provided to the constructor, matches `searchValue`. If no such entry\n\t * exists, this method returns the next higher entry as determined by the value comparator provided to the constructor. If no such entry\n\t * exists, this method returns undefined.\n\t */\n\tpublic getPairOrNextHigherByValue(searchValue: S): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(searchValue, this.compareValues);\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tsuper.assertValid();\n\t\tlet prev: readonly [unknown, V] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.valueComparator(this.extractSearchValue(kv[1]), this.extractSearchValue(prev[1])) > 0,\n\t\t\t\t\t0x63f /* Values in map must be sorted. */\n\t\t\t\t);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AppendOnlySortedMap.js","sourceRoot":"","sources":["../../src/id-compressor/AppendOnlySortedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG/B;;OAEG;IACH,YAAsC,UAAkC;QAAlC,eAAU,GAAV,UAAU,CAAwB;QALrD,aAAQ,GAAc,EAAE,CAAC;IAK+B,CAAC;IAE5E;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAkB,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,QAAQ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,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAC1F,KAAK,CAAC,mCAAmC,CACzC,CAAC;YACH,CAAC;YACD,IAAI,GAAG,EAAE,CAAC;QACX,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from '@fluidframework/core-utils/internal';\n\nimport { fail } from '../Common.js';\n\n/**\n * A map in which entries are always added in key-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlySortedMap<K, V> {\n\tprotected readonly elements: (K | V)[] = [];\n\n\t/**\n\t * @param comparator - a comparator for keys\n\t */\n\tpublic constructor(protected readonly comparator: (a: K, b: K) => number) {}\n\n\t/**\n\t * Gets the number of entries in this map\n\t */\n\tpublic get size(): number {\n\t\treturn this.elements.length / 2;\n\t}\n\n\t/**\n\t * Gets the min key in the map.\n\t */\n\tpublic minKey(): K | undefined {\n\t\treturn this.elements[0] as K | undefined;\n\t}\n\n\t/**\n\t * Gets the max key in the map.\n\t */\n\tpublic maxKey(): K | undefined {\n\t\treturn this.elements[this.elements.length - 2] as K | undefined;\n\t}\n\n\t/**\n\t * Gets the min value in the map.\n\t */\n\tpublic minValue(): V | undefined {\n\t\treturn this.elements[1] as V | undefined;\n\t}\n\n\t/**\n\t * Gets the max value in the map.\n\t */\n\tpublic maxValue(): V | undefined {\n\t\treturn this.elements[this.elements.length - 1] as V | undefined;\n\t}\n\n\t/**\n\t * Gets the first entry in the map.\n\t */\n\tpublic first(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[0] as K, elements[1] as V];\n\t}\n\n\t/**\n\t * Gets the last entry in the map.\n\t */\n\tpublic last(): [K, V] | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst lastKeyIndex = length - 2;\n\t\treturn [elements[lastKeyIndex] as K, elements[lastKeyIndex + 1] as V];\n\t}\n\n\t/**\n\t * Returns the element at the insertion index.\n\t */\n\tpublic getAtIndex(index: number): [K, V] | undefined {\n\t\tconst realIndex = index * 2;\n\t\tconst { elements } = this;\n\t\tif (realIndex < 0 || realIndex > elements.length - 1) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [elements[realIndex] as K, elements[realIndex + 1] as V];\n\t}\n\n\t/**\n\t * Gets an iterable of the entries in the map.\n\t */\n\tpublic *entries(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * Gets an iterable of the keys in the map.\n\t */\n\tpublic *keys(): IterableIterator<K> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i] as K;\n\t\t}\n\t}\n\n\t/**\n\t * Gets an iterable of the values in the map.\n\t */\n\tpublic *values(): IterableIterator<V> {\n\t\tconst { elements } = this;\n\t\tfor (let i = 0; i < elements.length; i += 2) {\n\t\t\tyield elements[i + 1] as V;\n\t\t}\n\t}\n\n\t/**\n\t * Gets an iterable of the entries in the map, reversed.\n\t */\n\tpublic *entriesReversed(): IterableIterator<readonly [K, V]> {\n\t\tconst { elements } = this;\n\t\tfor (let i = elements.length - 2; i >= 0; i -= 2) {\n\t\t\tyield [elements[i] as K, elements[i + 1] as V];\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new key/value pair to the map. `key` must be \\> to all keys in the map.\n\t * @param key - The key to add.\n\t * @param value - The value to add.\n\t */\n\tpublic append(key: K, value: V): void {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length !== 0 && this.comparator(key, this.maxKey() as K) <= 0) {\n\t\t\tfail('Inserted key must be > all others in the map.');\n\t\t}\n\t\telements.push(key);\n\t\telements.push(value);\n\t}\n\n\t/**\n\t * Gets the value associated with `key` if such an entry exists, and `undefined` otherwise.\n\t * @param key - The key to lookup.\n\t */\n\tpublic get(key: K): V | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);\n\t\tif (index < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.elements[index + 1] as V;\n\t}\n\n\t/**\n\t * Gets the entry associated with `key` if such an entry exists, the entry associated with the next lower key if\n\t * such an entry exists, and `undefined` otherwise.\n\t * @param key - The key to lookup.\n\t */\n\tpublic getPairOrNextLower(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(key, this.comparator);\n\t}\n\n\t/**\n\t * Gets the entry associated with `key` if such an entry exists, the entry associated with the next higher key if\n\t * such an entry exists, and `undefined` otherwise.\n\t * @param key - The key to lookup.\n\t */\n\tpublic getPairOrNextHigher(key: K): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(key, this.comparator);\n\t}\n\n\t/**\n\t * Compares two `AppendOnlySortedMap`s.\n\t */\n\tpublic equals(other: AppendOnlySortedMap<K, V>, compareValues: (a: V, b: V) => boolean): boolean {\n\t\tif (other === this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.elements.length !== other.elements.length) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (let i = this.elements.length - 2; i >= 0; i -= 2) {\n\t\t\tconst keyThis = this.elements[i] as K;\n\t\t\tconst valueThis = this.elements[i + 1] as V;\n\t\t\tconst keyOther = other.elements[i] as K;\n\t\t\tconst valueOther = other.elements[i + 1] as V;\n\t\t\tif (this.comparator(keyThis, keyOther) !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!compareValues(valueThis, valueOther)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tlet prev: readonly [K, unknown] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(this.comparator(kv[0], prev[0]) > 0, 0x63e /* Keys in map must be sorted. */);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n\n\t/**\n\t * Queries a range of entries.\n\t * @param from - the key to start the range query at, inclusive.\n\t * @param to - the key to end the range query at, inclusive.\n\t * @returns the range of entries.\n\t */\n\tpublic *getRange(from: K, to: K): IterableIterator<readonly [K, V]> {\n\t\tconst keyIndexFrom = this.getKeyIndexOfOrNextHigher(from, this.comparator);\n\t\tif (keyIndexFrom === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst keyIndexTo = this.getKeyIndexOfOrNextLower(to, this.comparator);\n\t\tif (keyIndexTo === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let i = keyIndexFrom; i <= keyIndexTo; i += 2) {\n\t\t\tyield [this.elements[i] as K, this.elements[i + 1] as V];\n\t\t}\n\t}\n\n\tprotected getPairOrNextLowerBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextLower(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextLower<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tif (elements.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex > 0) {\n\t\t\t\treturn keyIndex - 2;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\tprotected getPairOrNextHigherBy<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): readonly [K, V] | undefined {\n\t\tconst keyIndex = this.getKeyIndexOfOrNextHigher(search, comparator);\n\t\tif (keyIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn [this.elements[keyIndex] as K, this.elements[keyIndex + 1] as V];\n\t}\n\n\tprivate getKeyIndexOfOrNextHigher<T>(\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number | undefined {\n\t\tconst { elements } = this;\n\t\tconst { length } = elements;\n\t\tif (length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet keyIndex = AppendOnlySortedMap.keyIndexOf(elements, search, comparator);\n\t\tif (keyIndex < 0) {\n\t\t\tkeyIndex ^= AppendOnlySortedMap.failureXor;\n\t\t\tif (keyIndex < length) {\n\t\t\t\treturn keyIndex;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn keyIndex;\n\t}\n\n\t/**\n\t * The value xor'd with the result index when a search fails.\n\t */\n\tpublic static readonly failureXor = -1;\n\n\t/**\n\t * Performs a binary search on the sorted array.\n\t * @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd\n\t * with `failureXor`. Note that negating is not an adequate solution as that could result in -0.\n\t */\n\tpublic static keyIndexOf<T, K, V>(\n\t\telements: readonly (K | V)[],\n\t\tsearch: T,\n\t\tcomparator: (search: T, key: K, value: V) => number\n\t): number {\n\t\t// Low, high, and mid are addresses of [K,V] pairs and *not* key indices\n\t\tlet low = 0;\n\t\tlet high = elements.length / 2;\n\t\tlet mid = high >> 1;\n\t\twhile (low < high) {\n\t\t\tconst keyIndex = mid * 2;\n\t\t\tconst c = comparator(search, elements[keyIndex] as K, elements[keyIndex + 1] as V);\n\t\t\tif (c > 0) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else if (c < 0) {\n\t\t\t\thigh = mid;\n\t\t\t} else if (c === 0) {\n\t\t\t\treturn keyIndex;\n\t\t\t} else {\n\t\t\t\tfail('Invalid comparator.');\n\t\t\t}\n\t\t\tmid = (low + high) >> 1;\n\t\t}\n\t\treturn (mid * 2) ^ AppendOnlySortedMap.failureXor;\n\t}\n}\n\n/**\n * A map in which entries are always added in both key-sorted and value-sorted order.\n * Supports appending and searching.\n */\nexport class AppendOnlyDoublySortedMap<K, V, S> extends AppendOnlySortedMap<K, V> {\n\tpublic constructor(\n\t\tkeyComparator: (a: K, b: K) => number,\n\t\tprivate readonly extractSearchValue: (value: V) => S,\n\t\tprivate readonly valueComparator: (search: S, value: S) => number\n\t) {\n\t\tsuper(keyComparator);\n\t}\n\n\tpublic append(key: K, value: V): void {\n\t\tif (\n\t\t\tthis.elements.length !== 0 &&\n\t\t\tthis.valueComparator(this.extractSearchValue(value), this.extractSearchValue(this.maxValue() as V)) <= 0\n\t\t) {\n\t\t\tfail('Inserted value must be > all others in the map.');\n\t\t}\n\t\tsuper.append(key, value);\n\t}\n\n\tprivate readonly compareValues = (search: S, _: K, value: V): number => {\n\t\treturn this.valueComparator(search, this.extractSearchValue(value));\n\t};\n\n\t/**\n\t * @param value - the value to lookup.\n\t * @returns the key associated with `value` if such an entry exists, and undefined otherwise.\n\t */\n\tpublic getByValue(value: S): K | undefined {\n\t\tconst index = AppendOnlySortedMap.keyIndexOf(this.elements, value, this.compareValues);\n\t\treturn this.elements[index]?.[0];\n\t}\n\n\t/**\n\t * @param searchValue - the search value to lookup.\n\t * @returns the entry who's value, when run through the extractor provided to the constructor, matches\n\t * `searchValue`. If no such entry exists, this method returns the next lower entry as determined by the value\n\t * comparator provided to the constructor. If no such entry exists, this method returns undefined.\n\t */\n\tpublic getPairOrNextLowerByValue(searchValue: S): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextLowerBy(searchValue, this.compareValues);\n\t}\n\n\t/**\n\t * @param searchValue - the search value to lookup.\n\t * @returns the entry who's value, when run through the extractor provided to the constructor, matches `searchValue`. If no such entry\n\t * exists, this method returns the next higher entry as determined by the value comparator provided to the constructor. If no such entry\n\t * exists, this method returns undefined.\n\t */\n\tpublic getPairOrNextHigherByValue(searchValue: S): readonly [K, V] | undefined {\n\t\treturn this.getPairOrNextHigherBy(searchValue, this.compareValues);\n\t}\n\n\t/**\n\t * Test-only expensive assertions to check the internal validity of the data structure.\n\t */\n\tpublic assertValid(): void {\n\t\tsuper.assertValid();\n\t\tlet prev: readonly [unknown, V] | undefined;\n\t\tfor (const kv of this.entries()) {\n\t\t\tif (prev !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.valueComparator(this.extractSearchValue(kv[1]), this.extractSearchValue(prev[1])) > 0,\n\t\t\t\t\t0x63f /* Values in map must be sorted. */\n\t\t\t\t);\n\t\t\t}\n\t\t\tprev = kv;\n\t\t}\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.82.0",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"main": "lib/index.js",
|
|
28
28
|
"types": "lib/index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@fluid-internal/client-utils": "~2.
|
|
31
|
-
"@fluidframework/container-definitions": "~2.
|
|
32
|
-
"@fluidframework/core-interfaces": "~2.
|
|
33
|
-
"@fluidframework/core-utils": "~2.
|
|
34
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
35
|
-
"@fluidframework/driver-definitions": "~2.
|
|
36
|
-
"@fluidframework/id-compressor": "~2.
|
|
37
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
38
|
-
"@fluidframework/runtime-utils": "~2.
|
|
39
|
-
"@fluidframework/shared-object-base": "~2.
|
|
40
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
41
|
-
"@fluidframework/tree": "~2.
|
|
30
|
+
"@fluid-internal/client-utils": "~2.82.0",
|
|
31
|
+
"@fluidframework/container-definitions": "~2.82.0",
|
|
32
|
+
"@fluidframework/core-interfaces": "~2.82.0",
|
|
33
|
+
"@fluidframework/core-utils": "~2.82.0",
|
|
34
|
+
"@fluidframework/datastore-definitions": "~2.82.0",
|
|
35
|
+
"@fluidframework/driver-definitions": "~2.82.0",
|
|
36
|
+
"@fluidframework/id-compressor": "~2.82.0",
|
|
37
|
+
"@fluidframework/runtime-definitions": "~2.82.0",
|
|
38
|
+
"@fluidframework/runtime-utils": "~2.82.0",
|
|
39
|
+
"@fluidframework/shared-object-base": "~2.82.0",
|
|
40
|
+
"@fluidframework/telemetry-utils": "~2.82.0",
|
|
41
|
+
"@fluidframework/tree": "~2.82.0",
|
|
42
42
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
43
43
|
"buffer": "^6.0.3",
|
|
44
44
|
"denque": "^1.5.1",
|
|
@@ -48,20 +48,20 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
50
50
|
"@biomejs/biome": "~1.9.3",
|
|
51
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
52
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
53
|
-
"@fluid-private/test-drivers": "~2.
|
|
51
|
+
"@fluid-internal/mocha-test-setup": "~2.82.0",
|
|
52
|
+
"@fluid-private/stochastic-test-utils": "~2.82.0",
|
|
53
|
+
"@fluid-private/test-drivers": "~2.82.0",
|
|
54
54
|
"@fluid-tools/benchmark": "^0.52.0",
|
|
55
55
|
"@fluidframework/build-common": "^2.0.3",
|
|
56
56
|
"@fluidframework/build-tools": "^0.63.0",
|
|
57
|
-
"@fluidframework/container-definitions": "~2.
|
|
58
|
-
"@fluidframework/container-loader": "~2.
|
|
59
|
-
"@fluidframework/container-runtime": "~2.
|
|
60
|
-
"@fluidframework/eslint-config-fluid": "~2.
|
|
61
|
-
"@fluidframework/runtime-utils": "~2.
|
|
62
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
63
|
-
"@fluidframework/test-utils": "~2.
|
|
64
|
-
"@fluidframework/undo-redo": "~2.
|
|
57
|
+
"@fluidframework/container-definitions": "~2.82.0",
|
|
58
|
+
"@fluidframework/container-loader": "~2.82.0",
|
|
59
|
+
"@fluidframework/container-runtime": "~2.82.0",
|
|
60
|
+
"@fluidframework/eslint-config-fluid": "~2.82.0",
|
|
61
|
+
"@fluidframework/runtime-utils": "~2.82.0",
|
|
62
|
+
"@fluidframework/test-runtime-utils": "~2.82.0",
|
|
63
|
+
"@fluidframework/test-utils": "~2.82.0",
|
|
64
|
+
"@fluidframework/undo-redo": "~2.82.0",
|
|
65
65
|
"@microsoft/api-extractor": "7.52.11",
|
|
66
66
|
"@types/chai": "^4.0.0",
|
|
67
67
|
"@types/lru-cache": "^5.1.0",
|
package/src/ChangeTypes.ts
CHANGED
|
@@ -246,12 +246,16 @@ export const Change = {
|
|
|
246
246
|
/** Helpers for making high-level composite operations */
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
*
|
|
249
|
+
* Deletes a range of nodes from the tree.
|
|
250
|
+
*
|
|
251
|
+
* @returns A change that deletes the supplied part of the tree.
|
|
250
252
|
*/
|
|
251
253
|
delete: (stableRange: StableRange): Change => Change.detach(stableRange),
|
|
252
254
|
|
|
253
255
|
/**
|
|
254
|
-
*
|
|
256
|
+
* Inserts nodes into the tree at the specified location.
|
|
257
|
+
*
|
|
258
|
+
* @returns The changes that insert 'nodes' into the specified location in the tree.
|
|
255
259
|
*/
|
|
256
260
|
insertTree: (nodes: BuildNode | TreeNodeSequence<BuildNode>, destination: StablePlace): Change[] => {
|
|
257
261
|
const build = Change.build(nodes, 0);
|
|
@@ -259,7 +263,9 @@ export const Change = {
|
|
|
259
263
|
},
|
|
260
264
|
|
|
261
265
|
/**
|
|
262
|
-
*
|
|
266
|
+
* Moves nodes from one location to another in the tree.
|
|
267
|
+
*
|
|
268
|
+
* @returns The changes that moves the specified content to a new location in the tree.
|
|
263
269
|
*/
|
|
264
270
|
move: (source: StableRange, destination: StablePlace): Change[] => {
|
|
265
271
|
const detach = Change.detach(source, 0);
|
|
@@ -348,6 +354,8 @@ export interface StableRange {
|
|
|
348
354
|
*/
|
|
349
355
|
export const StablePlace = {
|
|
350
356
|
/**
|
|
357
|
+
* Creates a stable place representing the location directly before a node.
|
|
358
|
+
*
|
|
351
359
|
* @returns The location directly before `node`.
|
|
352
360
|
*/
|
|
353
361
|
before: (node: NodeData<NodeId> | NodeId): StablePlace => ({
|
|
@@ -355,6 +363,8 @@ export const StablePlace = {
|
|
|
355
363
|
referenceSibling: getNodeId(node),
|
|
356
364
|
}),
|
|
357
365
|
/**
|
|
366
|
+
* Creates a stable place representing the location directly after a node.
|
|
367
|
+
*
|
|
358
368
|
* @returns The location directly after `node`.
|
|
359
369
|
*/
|
|
360
370
|
after: (node: NodeData<NodeId> | NodeId): StablePlace => ({
|
|
@@ -362,6 +372,8 @@ export const StablePlace = {
|
|
|
362
372
|
referenceSibling: getNodeId(node),
|
|
363
373
|
}),
|
|
364
374
|
/**
|
|
375
|
+
* Creates a stable place representing the location at the start of a trait.
|
|
376
|
+
*
|
|
365
377
|
* @returns The location at the start of `trait`.
|
|
366
378
|
*/
|
|
367
379
|
atStartOf: (trait: TraitLocation): StablePlace => ({
|
|
@@ -369,6 +381,8 @@ export const StablePlace = {
|
|
|
369
381
|
referenceTrait: trait,
|
|
370
382
|
}),
|
|
371
383
|
/**
|
|
384
|
+
* Creates a stable place representing the location at the end of a trait.
|
|
385
|
+
*
|
|
372
386
|
* @returns The location at the end of `trait`.
|
|
373
387
|
*/
|
|
374
388
|
atEndOf: (trait: TraitLocation): StablePlace => ({
|
|
@@ -407,7 +421,9 @@ export const StableRange = {
|
|
|
407
421
|
},
|
|
408
422
|
}),
|
|
409
423
|
/**
|
|
410
|
-
*
|
|
424
|
+
* Creates a `StableRange` which contains only the provided `node`.
|
|
425
|
+
*
|
|
426
|
+
* @remarks
|
|
411
427
|
* Both the start and end `StablePlace` objects used to anchor this `StableRange` are in terms of the passed in node.
|
|
412
428
|
*/
|
|
413
429
|
only: (node: NodeData<NodeId> | NodeId): StableRange => ({
|
|
@@ -415,7 +431,9 @@ export const StableRange = {
|
|
|
415
431
|
end: StablePlace.after(node),
|
|
416
432
|
}),
|
|
417
433
|
/**
|
|
418
|
-
*
|
|
434
|
+
* Creates a `StableRange` which contains everything in the trait.
|
|
435
|
+
*
|
|
436
|
+
* @remarks
|
|
419
437
|
* This is anchored using the provided `trait`, and is independent of the actual contents of the trait:
|
|
420
438
|
* it does not use sibling anchoring.
|
|
421
439
|
*/
|
package/src/Checkout.ts
CHANGED
|
@@ -142,7 +142,9 @@ export abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEv
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
145
|
+
* Gets the current view of the tree, including the result of changes applied so far during an edit.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
146
148
|
* Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.
|
|
147
149
|
*/
|
|
148
150
|
public get currentView(): TreeView {
|
|
@@ -150,7 +152,7 @@ export abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEv
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
/**
|
|
153
|
-
*
|
|
155
|
+
* Whether there is currently an open edit operation.
|
|
154
156
|
*/
|
|
155
157
|
public hasOpenEdit(): boolean {
|
|
156
158
|
return this.currentEdit !== undefined;
|
|
@@ -371,7 +373,9 @@ export abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEv
|
|
|
371
373
|
}
|
|
372
374
|
|
|
373
375
|
/**
|
|
374
|
-
*
|
|
376
|
+
* Gets the {@link EditStatus} of the current edit.
|
|
377
|
+
*
|
|
378
|
+
* @remarks
|
|
375
379
|
* Has no side effects.
|
|
376
380
|
* Can only be called if an edit is open.
|
|
377
381
|
*/
|
package/src/Common.ts
CHANGED
|
@@ -354,6 +354,8 @@ export function setPropertyIfDefined<TDst, P extends keyof TDst>(
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
+
* Returns an object indicating that iteration should break due to finding a difference.
|
|
358
|
+
*
|
|
357
359
|
* @example
|
|
358
360
|
*
|
|
359
361
|
* ```typescript
|
|
@@ -506,9 +508,8 @@ export type RecursiveMutable<T> = {
|
|
|
506
508
|
};
|
|
507
509
|
|
|
508
510
|
/** Type that produces a writeable map from a readonly map. */
|
|
509
|
-
export type MutableMap<T extends ReadonlyMap<unknown, unknown>> =
|
|
510
|
-
? Map<K, V>
|
|
511
|
-
: never;
|
|
511
|
+
export type MutableMap<T extends ReadonlyMap<unknown, unknown>> =
|
|
512
|
+
T extends ReadonlyMap<infer K, infer V> ? Map<K, V> : never;
|
|
512
513
|
|
|
513
514
|
/** Type that includes the property K: V on T */
|
|
514
515
|
export type With<T, K extends keyof never, V> = T & { [key in K]: V };
|
package/src/LogViewer.ts
CHANGED
|
@@ -478,6 +478,7 @@ export class CachingLogViewer extends TypedEventEmitter<ICachingLogViewerEvents>
|
|
|
478
478
|
let cached;
|
|
479
479
|
let reconciliationPath: ReconciliationPath = [];
|
|
480
480
|
if (
|
|
481
|
+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- TODO: ADO#58517 Code owners should verify if this code change is safe and make it if so or update this comment otherwise
|
|
481
482
|
this.cachedEditResult !== undefined &&
|
|
482
483
|
this.cachedEditResult.editId === edit.id &&
|
|
483
484
|
this.cachedEditResult.result.before === prevView
|
|
@@ -22,42 +22,42 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
22
22
|
public constructor(protected readonly comparator: (a: K, b: K) => number) {}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Gets the number of entries in this map
|
|
26
26
|
*/
|
|
27
27
|
public get size(): number {
|
|
28
28
|
return this.elements.length / 2;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Gets the min key in the map.
|
|
33
33
|
*/
|
|
34
34
|
public minKey(): K | undefined {
|
|
35
35
|
return this.elements[0] as K | undefined;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Gets the max key in the map.
|
|
40
40
|
*/
|
|
41
41
|
public maxKey(): K | undefined {
|
|
42
42
|
return this.elements[this.elements.length - 2] as K | undefined;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Gets the min value in the map.
|
|
47
47
|
*/
|
|
48
48
|
public minValue(): V | undefined {
|
|
49
49
|
return this.elements[1] as V | undefined;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Gets the max value in the map.
|
|
54
54
|
*/
|
|
55
55
|
public maxValue(): V | undefined {
|
|
56
56
|
return this.elements[this.elements.length - 1] as V | undefined;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Gets the first entry in the map.
|
|
61
61
|
*/
|
|
62
62
|
public first(): [K, V] | undefined {
|
|
63
63
|
const { elements } = this;
|
|
@@ -69,7 +69,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Gets the last entry in the map.
|
|
73
73
|
*/
|
|
74
74
|
public last(): [K, V] | undefined {
|
|
75
75
|
const { elements } = this;
|
|
@@ -94,7 +94,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* Gets an iterable of the entries in the map.
|
|
98
98
|
*/
|
|
99
99
|
public *entries(): IterableIterator<readonly [K, V]> {
|
|
100
100
|
const { elements } = this;
|
|
@@ -104,7 +104,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Gets an iterable of the keys in the map.
|
|
108
108
|
*/
|
|
109
109
|
public *keys(): IterableIterator<K> {
|
|
110
110
|
const { elements } = this;
|
|
@@ -114,7 +114,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
117
|
+
* Gets an iterable of the values in the map.
|
|
118
118
|
*/
|
|
119
119
|
public *values(): IterableIterator<V> {
|
|
120
120
|
const { elements } = this;
|
|
@@ -124,7 +124,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* Gets an iterable of the entries in the map, reversed.
|
|
128
128
|
*/
|
|
129
129
|
public *entriesReversed(): IterableIterator<readonly [K, V]> {
|
|
130
130
|
const { elements } = this;
|
|
@@ -135,8 +135,8 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* Adds a new key/value pair to the map. `key` must be \> to all keys in the map.
|
|
138
|
-
* @param key -
|
|
139
|
-
* @param value -
|
|
138
|
+
* @param key - The key to add.
|
|
139
|
+
* @param value - The value to add.
|
|
140
140
|
*/
|
|
141
141
|
public append(key: K, value: V): void {
|
|
142
142
|
const { elements } = this;
|
|
@@ -149,8 +149,8 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
152
|
+
* Gets the value associated with `key` if such an entry exists, and `undefined` otherwise.
|
|
153
|
+
* @param key - The key to lookup.
|
|
154
154
|
*/
|
|
155
155
|
public get(key: K): V | undefined {
|
|
156
156
|
const index = AppendOnlySortedMap.keyIndexOf(this.elements, key, this.comparator);
|
|
@@ -161,18 +161,18 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
164
|
+
* Gets the entry associated with `key` if such an entry exists, the entry associated with the next lower key if
|
|
165
|
+
* such an entry exists, and `undefined` otherwise.
|
|
166
|
+
* @param key - The key to lookup.
|
|
167
167
|
*/
|
|
168
168
|
public getPairOrNextLower(key: K): readonly [K, V] | undefined {
|
|
169
169
|
return this.getPairOrNextLowerBy(key, this.comparator);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
173
|
+
* Gets the entry associated with `key` if such an entry exists, the entry associated with the next higher key if
|
|
174
|
+
* such an entry exists, and `undefined` otherwise.
|
|
175
|
+
* @param key - The key to lookup.
|
|
176
176
|
*/
|
|
177
177
|
public getPairOrNextHigher(key: K): readonly [K, V] | undefined {
|
|
178
178
|
return this.getPairOrNextHigherBy(key, this.comparator);
|