@fluidframework/tree 2.90.0 → 2.91.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 +247 -0
- package/alpha.d.ts +2 -2
- package/api-extractor/api-extractor-lint-alpha.cjs.json +1 -1
- package/api-extractor/api-extractor-lint-alpha.esm.json +1 -1
- package/api-extractor/api-extractor-lint-beta.cjs.json +1 -1
- package/api-extractor/api-extractor-lint-beta.esm.json +1 -1
- package/api-extractor/api-extractor-lint-bundle.json +1 -1
- package/api-extractor/api-extractor-lint-legacy.cjs.json +1 -1
- package/api-extractor/api-extractor-lint-legacy.esm.json +1 -1
- package/api-extractor/api-extractor-lint-public.cjs.json +1 -1
- package/api-extractor/api-extractor-lint-public.esm.json +1 -1
- package/api-extractor/api-extractor.current.json +1 -1
- package/api-extractor/api-extractor.legacy.json +2 -1
- package/api-extractor.json +1 -0
- package/api-report/tree.alpha.api.md +81 -15
- package/beta.d.ts +2 -2
- package/dist/entrypoints/alpha.d.ts +6 -0
- package/dist/entrypoints/alpha.d.ts.map +1 -0
- package/dist/entrypoints/alpha.js +92 -0
- package/dist/entrypoints/alpha.js.map +1 -0
- package/dist/entrypoints/beta.d.ts +6 -0
- package/dist/entrypoints/beta.d.ts.map +1 -0
- package/dist/entrypoints/beta.js +43 -0
- package/dist/entrypoints/beta.js.map +1 -0
- package/dist/entrypoints/internal.d.ts +6 -0
- package/dist/entrypoints/internal.d.ts.map +1 -0
- package/dist/entrypoints/internal.js +28 -0
- package/dist/entrypoints/internal.js.map +1 -0
- package/dist/entrypoints/legacy.d.ts +6 -0
- package/dist/entrypoints/legacy.d.ts.map +1 -0
- package/dist/entrypoints/legacy.js +49 -0
- package/dist/entrypoints/legacy.js.map +1 -0
- package/dist/entrypoints/public.d.ts +6 -0
- package/dist/entrypoints/public.d.ts.map +1 -0
- package/dist/entrypoints/public.js +27 -0
- package/dist/entrypoints/public.js.map +1 -0
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +3 -3
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +1 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -6
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +7 -3
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +2 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts +43 -0
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +125 -28
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +72 -7
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +10 -11
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.js +13 -7
- package/dist/simple-tree/api/schemaStatics.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +23 -2
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +3 -2
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +3 -4
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +43 -7
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +26 -2
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +2 -4
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/util/rangeMap.d.ts +25 -18
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +24 -30
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/typeUtils.d.ts.map +1 -1
- package/dist/util/typeUtils.js.map +1 -1
- package/eslint.config.mts +10 -2
- package/internal.d.ts +2 -2
- package/legacy.d.ts +4 -3
- package/lib/entrypoints/alpha.d.ts +6 -0
- package/lib/entrypoints/alpha.d.ts.map +1 -0
- package/lib/entrypoints/alpha.js +12 -0
- package/lib/entrypoints/alpha.js.map +1 -0
- package/lib/entrypoints/beta.d.ts +6 -0
- package/lib/entrypoints/beta.d.ts.map +1 -0
- package/lib/entrypoints/beta.js +12 -0
- package/lib/entrypoints/beta.js.map +1 -0
- package/lib/entrypoints/internal.d.ts +6 -0
- package/lib/entrypoints/internal.d.ts.map +1 -0
- package/lib/entrypoints/internal.js +12 -0
- package/lib/entrypoints/internal.js.map +1 -0
- package/lib/entrypoints/legacy.d.ts +6 -0
- package/lib/entrypoints/legacy.d.ts.map +1 -0
- package/lib/entrypoints/legacy.js +15 -0
- package/lib/entrypoints/legacy.js.map +1 -0
- package/lib/entrypoints/public.d.ts +6 -0
- package/lib/entrypoints/public.d.ts.map +1 -0
- package/lib/entrypoints/public.js +10 -0
- package/lib/entrypoints/public.js.map +1 -0
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +3 -3
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +1 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -6
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +7 -3
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +2 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts +43 -0
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +125 -28
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +66 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +10 -11
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.js +14 -8
- package/lib/simple-tree/api/schemaStatics.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +23 -2
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +3 -2
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +3 -4
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +43 -7
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +26 -2
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +2 -4
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/util/rangeMap.d.ts +25 -18
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +25 -31
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/typeUtils.d.ts.map +1 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +46 -46
- package/scripts/generate-entrypoint-sources.sh +29 -0
- package/{dist/alpha.d.ts → src/entrypoints/alpha.ts} +12 -5
- package/{lib/beta.d.ts → src/entrypoints/beta.ts} +2 -5
- package/src/entrypoints/internal.ts +13 -0
- package/{dist/legacy.d.ts → src/entrypoints/legacy.ts} +2 -5
- package/{lib/public.d.ts → src/entrypoints/public.ts} +2 -5
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +3 -8
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +16 -8
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +9 -4
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +1 -1
- package/src/index.ts +19 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +2 -1
- package/src/simple-tree/api/eraseSchemaDetails.ts +60 -0
- package/src/simple-tree/api/index.ts +12 -1
- package/src/simple-tree/api/schemaFactory.ts +8 -1
- package/src/simple-tree/api/schemaFactoryAlpha.ts +262 -25
- package/src/simple-tree/api/schemaFactoryBeta.ts +10 -1
- package/src/simple-tree/api/schemaStatics.ts +79 -21
- package/src/simple-tree/api/typesUnsafe.ts +49 -1
- package/src/simple-tree/fieldSchema.ts +29 -5
- package/src/simple-tree/index.ts +10 -0
- package/src/simple-tree/node-kinds/index.ts +3 -0
- package/src/simple-tree/node-kinds/object/index.ts +3 -0
- package/src/simple-tree/node-kinds/object/objectNode.ts +69 -11
- package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +33 -2
- package/src/util/rangeMap.ts +54 -50
- package/src/util/typeCheck.ts +1 -0
- package/src/util/typeUtils.ts +4 -7
- package/dist/beta.d.ts +0 -152
- package/dist/public.d.ts +0 -94
- package/lib/alpha.d.ts +0 -304
- package/lib/legacy.d.ts +0 -159
package/src/util/rangeMap.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { BTree } from "@tylerbu/sorted-btree-es6";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -29,13 +29,13 @@ export class RangeMap<K, V> {
|
|
|
29
29
|
* When writing to a range of keys starting with `start`, the value of the nth key is interpreted to be
|
|
30
30
|
* `offsetValue(firstValue, n - 1)`.
|
|
31
31
|
* The same logic should be used when interpreting the values for keys after the first in a
|
|
32
|
-
* `RangeQueryResult` or `
|
|
32
|
+
* `RangeQueryResult` or `RangeMapEntry`.
|
|
33
33
|
*
|
|
34
34
|
* If `offsetValue` is left unspecified, all keys in a block will be given the same value.
|
|
35
35
|
*/
|
|
36
36
|
public constructor(
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
public readonly offsetKey: (key: K, offset: number) => K,
|
|
38
|
+
public readonly subtractKeys: (a: K, b: K) => number,
|
|
39
39
|
public readonly offsetValue: (value: V, offset: number) => V = defaultValueOffsetFn,
|
|
40
40
|
) {
|
|
41
41
|
this.tree = new BTree(undefined, subtractKeys);
|
|
@@ -44,8 +44,8 @@ export class RangeMap<K, V> {
|
|
|
44
44
|
/**
|
|
45
45
|
* Retrieves all entries from the RangeMap.
|
|
46
46
|
*/
|
|
47
|
-
public entries():
|
|
48
|
-
const entries:
|
|
47
|
+
public entries(): RangeMapEntry<K, V>[] {
|
|
48
|
+
const entries: RangeMapEntry<K, V>[] = [];
|
|
49
49
|
for (const [start, entry] of this.tree.entries()) {
|
|
50
50
|
entries.push({ start, length: entry.length, value: entry.value });
|
|
51
51
|
}
|
|
@@ -62,34 +62,22 @@ export class RangeMap<K, V> {
|
|
|
62
62
|
*
|
|
63
63
|
* @param start - The first key in the range being queried
|
|
64
64
|
* @param length - The length of the query range
|
|
65
|
-
* @returns A list of
|
|
66
|
-
* The
|
|
65
|
+
* @returns A list of fragments, each describing the value for a subrange of the query.
|
|
66
|
+
* The fragments are in the same order as the keys.
|
|
67
|
+
* The key for each fragment is `start` offset by `fragment.offset`.
|
|
67
68
|
*/
|
|
68
|
-
public getAll(start: K, length: number):
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
public getAll(start: K, length: number): RangeQueryResultFragment<V | undefined>[] {
|
|
70
|
+
let offset = 0;
|
|
71
|
+
const results: RangeQueryResultFragment<V | undefined>[] = [];
|
|
72
|
+
|
|
73
|
+
while (offset < length) {
|
|
74
|
+
const key = this.offsetKey(start, offset);
|
|
75
|
+
const result = this.getFirst(key, length - offset);
|
|
76
|
+
results.push({ offset, value: result.value, length: result.length });
|
|
77
|
+
offset += result.length;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
const lengthBefore = this.subtractKeys(start, firstEntry.start);
|
|
76
|
-
if (lengthBefore > 0) {
|
|
77
|
-
entries[0] = {
|
|
78
|
-
start,
|
|
79
|
-
length: firstEntry.length - lengthBefore,
|
|
80
|
-
value: this.offsetValue(firstEntry.value, lengthBefore),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const lastEntry = entries[entries.length - 1] ?? oob();
|
|
85
|
-
const lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);
|
|
86
|
-
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
87
|
-
const lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);
|
|
88
|
-
if (lengthAfter > 0) {
|
|
89
|
-
entries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return entries;
|
|
80
|
+
return results;
|
|
93
81
|
}
|
|
94
82
|
|
|
95
83
|
/**
|
|
@@ -100,7 +88,7 @@ export class RangeMap<K, V> {
|
|
|
100
88
|
* @returns A RangeQueryResult containing the value associated with `start`,
|
|
101
89
|
* and the number of consecutive keys with that same value (at least 1, at most `length`).
|
|
102
90
|
*/
|
|
103
|
-
public getFirst(start: K, length: number): RangeQueryResult<
|
|
91
|
+
public getFirst(start: K, length: number): RangeQueryResult<V | undefined> {
|
|
104
92
|
{
|
|
105
93
|
// We first check for an entry with a key less than or equal to `start`.
|
|
106
94
|
const entry = this.tree.getPairOrNextLower(start);
|
|
@@ -114,7 +102,6 @@ export class RangeMap<K, V> {
|
|
|
114
102
|
if (overlappingLength > 0) {
|
|
115
103
|
return {
|
|
116
104
|
value: this.offsetValue(value, lengthBeforeQuery),
|
|
117
|
-
start,
|
|
118
105
|
length: overlappingLength,
|
|
119
106
|
};
|
|
120
107
|
}
|
|
@@ -130,11 +117,11 @@ export class RangeMap<K, V> {
|
|
|
130
117
|
|
|
131
118
|
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
132
119
|
if (this.le(entryKey, lastQueryKey)) {
|
|
133
|
-
return { value: undefined,
|
|
120
|
+
return { value: undefined, length: this.subtractKeys(entryKey, start) };
|
|
134
121
|
}
|
|
135
122
|
}
|
|
136
123
|
|
|
137
|
-
return { value: undefined,
|
|
124
|
+
return { value: undefined, length };
|
|
138
125
|
}
|
|
139
126
|
}
|
|
140
127
|
|
|
@@ -213,9 +200,14 @@ export class RangeMap<K, V> {
|
|
|
213
200
|
|
|
214
201
|
/**
|
|
215
202
|
* Returns a new map which contains the entries from both input maps.
|
|
216
|
-
* Whenever both maps contain
|
|
203
|
+
* Whenever both maps contain entries for the same keys, the value is determined by calling `mergeFunc`.
|
|
204
|
+
* By default, `mergeFunc` chooses the value from `b`.
|
|
217
205
|
*/
|
|
218
|
-
public static union<K, V>(
|
|
206
|
+
public static union<K, V>(
|
|
207
|
+
a: RangeMap<K, V>,
|
|
208
|
+
b: RangeMap<K, V>,
|
|
209
|
+
mergeFunc: (key: K, valueA: V, valueB: V) => V = (_k, _a, valB) => valB,
|
|
210
|
+
): RangeMap<K, V> {
|
|
219
211
|
assert(
|
|
220
212
|
a.offsetKey === b.offsetKey &&
|
|
221
213
|
a.subtractKeys === b.subtractKeys &&
|
|
@@ -224,15 +216,22 @@ export class RangeMap<K, V> {
|
|
|
224
216
|
);
|
|
225
217
|
|
|
226
218
|
const merged = a.clone();
|
|
227
|
-
for (const
|
|
228
|
-
|
|
219
|
+
for (const entryB of b.entries()) {
|
|
220
|
+
for (const entryA of a.getAll(entryB.start, entryB.length)) {
|
|
221
|
+
const key = b.offsetKey(entryB.start, entryA.offset);
|
|
222
|
+
const valueB = b.offsetValue(entryB.value, entryA.offset);
|
|
223
|
+
const mergedValue =
|
|
224
|
+
entryA.value === undefined ? valueB : mergeFunc(key, entryA.value, valueB);
|
|
225
|
+
|
|
226
|
+
merged.set(key, entryA.length, mergedValue);
|
|
227
|
+
}
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
return merged;
|
|
232
231
|
}
|
|
233
232
|
|
|
234
|
-
private getIntersectingEntries(start: K, length: number):
|
|
235
|
-
const entries:
|
|
233
|
+
private getIntersectingEntries(start: K, length: number): RangeMapEntry<K, V>[] {
|
|
234
|
+
const entries: RangeMapEntry<K, V>[] = [];
|
|
236
235
|
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
237
236
|
{
|
|
238
237
|
const entry = this.tree.getPairOrNextLower(start);
|
|
@@ -300,17 +299,11 @@ interface RangeEntry<V> {
|
|
|
300
299
|
/**
|
|
301
300
|
* Describes the result of a range query, including the value and length of the matching prefix.
|
|
302
301
|
*/
|
|
303
|
-
export interface RangeQueryResult<
|
|
304
|
-
/**
|
|
305
|
-
* The key for the first element in the range.
|
|
306
|
-
*/
|
|
307
|
-
readonly start: K;
|
|
308
|
-
|
|
302
|
+
export interface RangeQueryResult<V> {
|
|
309
303
|
/**
|
|
310
304
|
* The value of the first key in the query range.
|
|
311
|
-
* If no matching range is found, this will be undefined.
|
|
312
305
|
*/
|
|
313
|
-
readonly value: V
|
|
306
|
+
readonly value: V;
|
|
314
307
|
|
|
315
308
|
/**
|
|
316
309
|
* The length of the prefix of the query range which has the same value.
|
|
@@ -320,8 +313,19 @@ export interface RangeQueryResult<K, V> {
|
|
|
320
313
|
readonly length: number;
|
|
321
314
|
}
|
|
322
315
|
|
|
323
|
-
export interface
|
|
316
|
+
export interface RangeQueryResultFragment<V> extends RangeQueryResult<V> {
|
|
317
|
+
/**
|
|
318
|
+
* The offset from the query key to the key this result is associated with.
|
|
319
|
+
* This is useful in the case where a query returns multiple `RangeQueryResults`
|
|
320
|
+
* addressing the key range.
|
|
321
|
+
*/
|
|
322
|
+
readonly offset: number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface RangeMapEntry<K, V> {
|
|
326
|
+
readonly start: K;
|
|
324
327
|
readonly value: V;
|
|
328
|
+
readonly length: number;
|
|
325
329
|
}
|
|
326
330
|
|
|
327
331
|
export function newIntegerRangeMap<V, K extends number = number>(): RangeMap<K, V> {
|
package/src/util/typeCheck.ts
CHANGED
|
@@ -84,6 +84,7 @@ export type { EnforceTypeCheckTests } from "./typeCheckTests.js";
|
|
|
84
84
|
* See: {@link https://dev.azure.com/intentional/intent/_wiki/wikis/NP%20Platform/7146/Nominal-vs-Structural-Types}
|
|
85
85
|
* @sealed @public
|
|
86
86
|
*/
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- Intentionally empty; used as a nominal type brand.
|
|
87
88
|
export interface MakeNominal {}
|
|
88
89
|
|
|
89
90
|
/**
|
package/src/util/typeUtils.ts
CHANGED
|
@@ -191,13 +191,10 @@ export type PopUnion<
|
|
|
191
191
|
* This implementation is inspired to those, but slightly different in implementation.
|
|
192
192
|
* @system @beta
|
|
193
193
|
*/
|
|
194
|
-
export type UnionToTuple<
|
|
195
|
-
Union
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
> = IsUnion<Union> extends true
|
|
199
|
-
? UnionToTuple<Exclude<Union, First>, [First, ...A]>
|
|
200
|
-
: [Union, ...A];
|
|
194
|
+
export type UnionToTuple<Union, A extends unknown[] = [], First = PopUnion<Union>> =
|
|
195
|
+
IsUnion<Union> extends true
|
|
196
|
+
? UnionToTuple<Exclude<Union, First>, [First, ...A]>
|
|
197
|
+
: [Union, ...A];
|
|
201
198
|
|
|
202
199
|
/**
|
|
203
200
|
* This is unsafe, meaning that the returned value might not match its type.
|
package/dist/beta.d.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
// #region Unrestricted APIs
|
|
13
|
-
InternalTypes,
|
|
14
|
-
// #endregion
|
|
15
|
-
|
|
16
|
-
// #region @public APIs
|
|
17
|
-
AllowedTypes,
|
|
18
|
-
CommitKind,
|
|
19
|
-
CommitMetadata,
|
|
20
|
-
FieldKind,
|
|
21
|
-
FieldProps,
|
|
22
|
-
FieldSchema,
|
|
23
|
-
FieldSchemaMetadata,
|
|
24
|
-
ITree,
|
|
25
|
-
ITreeConfigurationOptions,
|
|
26
|
-
ITreeViewConfiguration,
|
|
27
|
-
ImplicitAllowedTypes,
|
|
28
|
-
ImplicitFieldSchema,
|
|
29
|
-
Input,
|
|
30
|
-
InsertableTreeFieldFromImplicitField,
|
|
31
|
-
InsertableTreeNodeFromAllowedTypes,
|
|
32
|
-
InsertableTreeNodeFromImplicitAllowedTypes,
|
|
33
|
-
InsertableTypedNode,
|
|
34
|
-
InternalTreeNode,
|
|
35
|
-
IsListener,
|
|
36
|
-
IsUnion,
|
|
37
|
-
IterableTreeArrayContent,
|
|
38
|
-
LazyItem,
|
|
39
|
-
LeafSchema,
|
|
40
|
-
Listenable,
|
|
41
|
-
Listeners,
|
|
42
|
-
MakeNominal,
|
|
43
|
-
MapNodeInsertableData,
|
|
44
|
-
NodeFromSchema,
|
|
45
|
-
NodeInDocumentConstraint,
|
|
46
|
-
NodeKind,
|
|
47
|
-
NodeSchemaMetadata,
|
|
48
|
-
NodeSchemaOptions,
|
|
49
|
-
NumberKeys,
|
|
50
|
-
ObjectFromSchemaRecord,
|
|
51
|
-
Off,
|
|
52
|
-
ReadonlyArrayNode,
|
|
53
|
-
RestrictiveReadonlyRecord,
|
|
54
|
-
RestrictiveStringRecord,
|
|
55
|
-
Revertible,
|
|
56
|
-
RevertibleFactory,
|
|
57
|
-
RevertibleStatus,
|
|
58
|
-
RunTransaction,
|
|
59
|
-
SchemaCompatibilityStatus,
|
|
60
|
-
SchemaFactory,
|
|
61
|
-
SchemaFactory_base,
|
|
62
|
-
SchemaStatics,
|
|
63
|
-
SimpleNodeSchemaBase,
|
|
64
|
-
System_Unsafe,
|
|
65
|
-
TransactionConstraint,
|
|
66
|
-
Tree,
|
|
67
|
-
TreeArrayNode,
|
|
68
|
-
TreeChangeEvents,
|
|
69
|
-
TreeFieldFromImplicitField,
|
|
70
|
-
TreeLeafValue,
|
|
71
|
-
TreeMapNode,
|
|
72
|
-
TreeNode,
|
|
73
|
-
TreeNodeApi,
|
|
74
|
-
TreeNodeFromImplicitAllowedTypes,
|
|
75
|
-
TreeNodeSchema,
|
|
76
|
-
TreeNodeSchemaClass,
|
|
77
|
-
TreeNodeSchemaCore,
|
|
78
|
-
TreeNodeSchemaNonClass,
|
|
79
|
-
TreeObjectNode,
|
|
80
|
-
TreeStatus,
|
|
81
|
-
TreeView,
|
|
82
|
-
TreeViewConfiguration,
|
|
83
|
-
TreeViewEvents,
|
|
84
|
-
Unenforced,
|
|
85
|
-
Unhydrated,
|
|
86
|
-
UnionToIntersection,
|
|
87
|
-
ValidateRecursiveSchema,
|
|
88
|
-
ValidateRecursiveSchemaTemplate,
|
|
89
|
-
ViewableTree,
|
|
90
|
-
WithType,
|
|
91
|
-
rollback,
|
|
92
|
-
typeSchemaSymbol,
|
|
93
|
-
// #endregion
|
|
94
|
-
|
|
95
|
-
// #region @beta APIs
|
|
96
|
-
AllowedTypeMetadata,
|
|
97
|
-
AllowedTypesFull,
|
|
98
|
-
AllowedTypesFullEvaluated,
|
|
99
|
-
AllowedTypesFullFromMixed,
|
|
100
|
-
AllowedTypesFullFromMixedUnsafe,
|
|
101
|
-
AllowedTypesMetadata,
|
|
102
|
-
AnnotateAllowedTypesList,
|
|
103
|
-
AnnotateAllowedTypesListUnsafe,
|
|
104
|
-
AnnotatedAllowedType,
|
|
105
|
-
AnnotatedAllowedTypeUnsafe,
|
|
106
|
-
AnnotatedAllowedTypes,
|
|
107
|
-
AnnotatedAllowedTypesUnsafe,
|
|
108
|
-
CodecWriteOptionsBeta,
|
|
109
|
-
ConciseTree,
|
|
110
|
-
ExtensibleUnionNode,
|
|
111
|
-
FixRecursiveArraySchema,
|
|
112
|
-
FluidSerializableAsTree,
|
|
113
|
-
ForestOptions,
|
|
114
|
-
ForestType,
|
|
115
|
-
ForestTypeExpensiveDebug,
|
|
116
|
-
ForestTypeOptimized,
|
|
117
|
-
ForestTypeReference,
|
|
118
|
-
JsonCompatible,
|
|
119
|
-
JsonCompatibleObject,
|
|
120
|
-
KeyEncodingOptions,
|
|
121
|
-
NodeChangedData,
|
|
122
|
-
ObjectSchemaOptions,
|
|
123
|
-
PopUnion,
|
|
124
|
-
RecordNodeInsertableData,
|
|
125
|
-
SchemaFactoryBeta,
|
|
126
|
-
SchemaStaticsBeta,
|
|
127
|
-
SchemaUpgrade,
|
|
128
|
-
SharedTreeOptionsBeta,
|
|
129
|
-
SnapshotFileSystem,
|
|
130
|
-
SnapshotSchemaCompatibilityOptions,
|
|
131
|
-
System_TableSchema,
|
|
132
|
-
TableSchema,
|
|
133
|
-
TreeBeta,
|
|
134
|
-
TreeBranch,
|
|
135
|
-
TreeChangeEventsBeta,
|
|
136
|
-
TreeEncodingOptions,
|
|
137
|
-
TreeRecordNode,
|
|
138
|
-
TreeRecordNodeUnsafe,
|
|
139
|
-
TreeViewBeta,
|
|
140
|
-
UnannotateAllowedTypeUnsafe,
|
|
141
|
-
UnannotateAllowedTypesList,
|
|
142
|
-
UnannotateAllowedTypesListUnsafe,
|
|
143
|
-
UnionToTuple,
|
|
144
|
-
adaptEnum,
|
|
145
|
-
asBeta,
|
|
146
|
-
configuredSharedTreeBeta,
|
|
147
|
-
createIndependentTreeBeta,
|
|
148
|
-
enumFromStrings,
|
|
149
|
-
singletonSchema,
|
|
150
|
-
snapshotSchemaCompatibility
|
|
151
|
-
// #endregion
|
|
152
|
-
} from "./index.js";
|
package/dist/public.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
// #region Unrestricted APIs
|
|
13
|
-
InternalTypes,
|
|
14
|
-
// #endregion
|
|
15
|
-
|
|
16
|
-
// #region @public APIs
|
|
17
|
-
AllowedTypes,
|
|
18
|
-
CommitKind,
|
|
19
|
-
CommitMetadata,
|
|
20
|
-
FieldKind,
|
|
21
|
-
FieldProps,
|
|
22
|
-
FieldSchema,
|
|
23
|
-
FieldSchemaMetadata,
|
|
24
|
-
ITree,
|
|
25
|
-
ITreeConfigurationOptions,
|
|
26
|
-
ITreeViewConfiguration,
|
|
27
|
-
ImplicitAllowedTypes,
|
|
28
|
-
ImplicitFieldSchema,
|
|
29
|
-
Input,
|
|
30
|
-
InsertableTreeFieldFromImplicitField,
|
|
31
|
-
InsertableTreeNodeFromAllowedTypes,
|
|
32
|
-
InsertableTreeNodeFromImplicitAllowedTypes,
|
|
33
|
-
InsertableTypedNode,
|
|
34
|
-
InternalTreeNode,
|
|
35
|
-
IsListener,
|
|
36
|
-
IsUnion,
|
|
37
|
-
IterableTreeArrayContent,
|
|
38
|
-
LazyItem,
|
|
39
|
-
LeafSchema,
|
|
40
|
-
Listenable,
|
|
41
|
-
Listeners,
|
|
42
|
-
MakeNominal,
|
|
43
|
-
MapNodeInsertableData,
|
|
44
|
-
NodeFromSchema,
|
|
45
|
-
NodeInDocumentConstraint,
|
|
46
|
-
NodeKind,
|
|
47
|
-
NodeSchemaMetadata,
|
|
48
|
-
NodeSchemaOptions,
|
|
49
|
-
NumberKeys,
|
|
50
|
-
ObjectFromSchemaRecord,
|
|
51
|
-
Off,
|
|
52
|
-
ReadonlyArrayNode,
|
|
53
|
-
RestrictiveReadonlyRecord,
|
|
54
|
-
RestrictiveStringRecord,
|
|
55
|
-
Revertible,
|
|
56
|
-
RevertibleFactory,
|
|
57
|
-
RevertibleStatus,
|
|
58
|
-
RunTransaction,
|
|
59
|
-
SchemaCompatibilityStatus,
|
|
60
|
-
SchemaFactory,
|
|
61
|
-
SchemaFactory_base,
|
|
62
|
-
SchemaStatics,
|
|
63
|
-
SimpleNodeSchemaBase,
|
|
64
|
-
System_Unsafe,
|
|
65
|
-
TransactionConstraint,
|
|
66
|
-
Tree,
|
|
67
|
-
TreeArrayNode,
|
|
68
|
-
TreeChangeEvents,
|
|
69
|
-
TreeFieldFromImplicitField,
|
|
70
|
-
TreeLeafValue,
|
|
71
|
-
TreeMapNode,
|
|
72
|
-
TreeNode,
|
|
73
|
-
TreeNodeApi,
|
|
74
|
-
TreeNodeFromImplicitAllowedTypes,
|
|
75
|
-
TreeNodeSchema,
|
|
76
|
-
TreeNodeSchemaClass,
|
|
77
|
-
TreeNodeSchemaCore,
|
|
78
|
-
TreeNodeSchemaNonClass,
|
|
79
|
-
TreeObjectNode,
|
|
80
|
-
TreeStatus,
|
|
81
|
-
TreeView,
|
|
82
|
-
TreeViewConfiguration,
|
|
83
|
-
TreeViewEvents,
|
|
84
|
-
Unenforced,
|
|
85
|
-
Unhydrated,
|
|
86
|
-
UnionToIntersection,
|
|
87
|
-
ValidateRecursiveSchema,
|
|
88
|
-
ValidateRecursiveSchemaTemplate,
|
|
89
|
-
ViewableTree,
|
|
90
|
-
WithType,
|
|
91
|
-
rollback,
|
|
92
|
-
typeSchemaSymbol
|
|
93
|
-
// #endregion
|
|
94
|
-
} from "./index.js";
|