@fluid-experimental/tree 2.81.1 → 2.83.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-report/experimental-tree.alpha.api.md +0 -3
  3. package/biome.jsonc +1 -1
  4. package/dist/ChangeTypes.d.ts +23 -5
  5. package/dist/ChangeTypes.d.ts.map +1 -1
  6. package/dist/ChangeTypes.js +23 -5
  7. package/dist/ChangeTypes.js.map +1 -1
  8. package/dist/Checkout.d.ts +7 -3
  9. package/dist/Checkout.d.ts.map +1 -1
  10. package/dist/Checkout.js +7 -3
  11. package/dist/Checkout.js.map +1 -1
  12. package/dist/Common.d.ts.map +1 -1
  13. package/dist/Common.js +5 -1
  14. package/dist/Common.js.map +1 -1
  15. package/dist/Forest.d.ts.map +1 -1
  16. package/dist/Forest.js +3 -1
  17. package/dist/Forest.js.map +1 -1
  18. package/dist/LogViewer.d.ts.map +1 -1
  19. package/dist/LogViewer.js +3 -1
  20. package/dist/LogViewer.js.map +1 -1
  21. package/dist/id-compressor/AppendOnlySortedMap.d.ts +21 -21
  22. package/dist/id-compressor/AppendOnlySortedMap.js +21 -21
  23. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  24. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  25. package/dist/id-compressor/IdCompressor.js +3 -1
  26. package/dist/id-compressor/IdCompressor.js.map +1 -1
  27. package/lib/ChangeTypes.d.ts +23 -5
  28. package/lib/ChangeTypes.d.ts.map +1 -1
  29. package/lib/ChangeTypes.js +23 -5
  30. package/lib/ChangeTypes.js.map +1 -1
  31. package/lib/Checkout.d.ts +7 -3
  32. package/lib/Checkout.d.ts.map +1 -1
  33. package/lib/Checkout.js +7 -3
  34. package/lib/Checkout.js.map +1 -1
  35. package/lib/Common.d.ts.map +1 -1
  36. package/lib/Common.js +5 -1
  37. package/lib/Common.js.map +1 -1
  38. package/lib/Forest.d.ts.map +1 -1
  39. package/lib/Forest.js +3 -1
  40. package/lib/Forest.js.map +1 -1
  41. package/lib/LogViewer.d.ts.map +1 -1
  42. package/lib/LogViewer.js +3 -1
  43. package/lib/LogViewer.js.map +1 -1
  44. package/lib/id-compressor/AppendOnlySortedMap.d.ts +21 -21
  45. package/lib/id-compressor/AppendOnlySortedMap.js +21 -21
  46. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  47. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  48. package/lib/id-compressor/IdCompressor.js +3 -1
  49. package/lib/id-compressor/IdCompressor.js.map +1 -1
  50. package/package.json +25 -25
  51. package/src/ChangeTypes.ts +23 -5
  52. package/src/Checkout.ts +7 -3
  53. package/src/Common.ts +7 -4
  54. package/src/Forest.ts +4 -1
  55. package/src/LogViewer.ts +1 -0
  56. package/src/id-compressor/AppendOnlySortedMap.ts +21 -21
  57. package/src/id-compressor/IdCompressor.ts +4 -1
  58. package/api-extractor-lint.json +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/tree",
3
- "version": "2.81.1",
3
+ "version": "2.83.0",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -27,19 +27,19 @@
27
27
  "main": "lib/index.js",
28
28
  "types": "lib/index.d.ts",
29
29
  "dependencies": {
30
- "@fluid-internal/client-utils": "~2.81.1",
31
- "@fluidframework/container-definitions": "~2.81.1",
32
- "@fluidframework/core-interfaces": "~2.81.1",
33
- "@fluidframework/core-utils": "~2.81.1",
34
- "@fluidframework/datastore-definitions": "~2.81.1",
35
- "@fluidframework/driver-definitions": "~2.81.1",
36
- "@fluidframework/id-compressor": "~2.81.1",
37
- "@fluidframework/runtime-definitions": "~2.81.1",
38
- "@fluidframework/runtime-utils": "~2.81.1",
39
- "@fluidframework/shared-object-base": "~2.81.1",
40
- "@fluidframework/telemetry-utils": "~2.81.1",
41
- "@fluidframework/tree": "~2.81.1",
42
- "@tylerbu/sorted-btree-es6": "^1.8.0",
30
+ "@fluid-internal/client-utils": "~2.83.0",
31
+ "@fluidframework/container-definitions": "~2.83.0",
32
+ "@fluidframework/core-interfaces": "~2.83.0",
33
+ "@fluidframework/core-utils": "~2.83.0",
34
+ "@fluidframework/datastore-definitions": "~2.83.0",
35
+ "@fluidframework/driver-definitions": "~2.83.0",
36
+ "@fluidframework/id-compressor": "~2.83.0",
37
+ "@fluidframework/runtime-definitions": "~2.83.0",
38
+ "@fluidframework/runtime-utils": "~2.83.0",
39
+ "@fluidframework/shared-object-base": "~2.83.0",
40
+ "@fluidframework/telemetry-utils": "~2.83.0",
41
+ "@fluidframework/tree": "~2.83.0",
42
+ "@tylerbu/sorted-btree-es6": "^2.1.1",
43
43
  "buffer": "^6.0.3",
44
44
  "denque": "^1.5.1",
45
45
  "lru-cache": "^6.0.0",
@@ -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.81.1",
52
- "@fluid-private/stochastic-test-utils": "~2.81.1",
53
- "@fluid-private/test-drivers": "~2.81.1",
51
+ "@fluid-internal/mocha-test-setup": "~2.83.0",
52
+ "@fluid-private/stochastic-test-utils": "~2.83.0",
53
+ "@fluid-private/test-drivers": "~2.83.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.81.1",
58
- "@fluidframework/container-loader": "~2.81.1",
59
- "@fluidframework/container-runtime": "~2.81.1",
60
- "@fluidframework/eslint-config-fluid": "~2.81.1",
61
- "@fluidframework/runtime-utils": "~2.81.1",
62
- "@fluidframework/test-runtime-utils": "~2.81.1",
63
- "@fluidframework/test-utils": "~2.81.1",
64
- "@fluidframework/undo-redo": "~2.81.1",
57
+ "@fluidframework/container-definitions": "~2.83.0",
58
+ "@fluidframework/container-loader": "~2.83.0",
59
+ "@fluidframework/container-runtime": "~2.83.0",
60
+ "@fluidframework/eslint-config-fluid": "~2.83.0",
61
+ "@fluidframework/runtime-utils": "~2.83.0",
62
+ "@fluidframework/test-runtime-utils": "~2.83.0",
63
+ "@fluidframework/test-utils": "~2.83.0",
64
+ "@fluidframework/undo-redo": "~2.83.0",
65
65
  "@microsoft/api-extractor": "7.52.11",
66
66
  "@types/chai": "^4.0.0",
67
67
  "@types/lru-cache": "^5.1.0",
@@ -246,12 +246,16 @@ export const Change = {
246
246
  /** Helpers for making high-level composite operations */
247
247
 
248
248
  /**
249
- * @returns a change that deletes the supplied part of the tree.
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
- * @returns changes that insert 'nodes' into the specified location in the tree.
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
- * @returns changes that moves the specified content to a new location in the tree.
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
- * @returns a `StableRange` which contains only the provided `node`.
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
- * @returns a `StableRange` which contains everything in the trait.
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
- * @returns the current view of the tree, including the result of changes applied so far during an edit.
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
- * @returns true iff there is an open edit.
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
- * @returns the {@link EditStatus} of the current edit.
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
@@ -5,6 +5,8 @@
5
5
 
6
6
  import { ITelemetryBaseEvent, ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
7
7
  import { BTree } from '@tylerbu/sorted-btree-es6';
8
+ // eslint-disable-next-line import-x/no-internal-modules
9
+ import { diffAgainst } from '@tylerbu/sorted-btree-es6/extended/diffAgainst';
8
10
 
9
11
  const defaultFailMessage = 'Assertion failed';
10
12
 
@@ -354,6 +356,8 @@ export function setPropertyIfDefined<TDst, P extends keyof TDst>(
354
356
  }
355
357
 
356
358
  /**
359
+ * Returns an object indicating that iteration should break due to finding a difference.
360
+ *
357
361
  * @example
358
362
  *
359
363
  * ```typescript
@@ -380,7 +384,7 @@ export function compareBtrees<K, V>(
380
384
  treeB: BTree<K, V>,
381
385
  compare: (valA: V, valB: V) => boolean
382
386
  ): boolean {
383
- const diff = treeA.diffAgainst(treeB, breakOnDifference, breakOnDifference, (_, valA, valB) => {
387
+ const diff = diffAgainst(treeA, treeB, breakOnDifference, breakOnDifference, (_, valA, valB) => {
384
388
  if (!compare(valA, valB)) {
385
389
  return { break: true };
386
390
  }
@@ -506,9 +510,8 @@ export type RecursiveMutable<T> = {
506
510
  };
507
511
 
508
512
  /** Type that produces a writeable map from a readonly map. */
509
- export type MutableMap<T extends ReadonlyMap<unknown, unknown>> = T extends ReadonlyMap<infer K, infer V>
510
- ? Map<K, V>
511
- : never;
513
+ export type MutableMap<T extends ReadonlyMap<unknown, unknown>> =
514
+ T extends ReadonlyMap<infer K, infer V> ? Map<K, V> : never;
512
515
 
513
516
  /** Type that includes the property K: V on T */
514
517
  export type With<T, K extends keyof never, V> = T & { [key in K]: V };
package/src/Forest.ts CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  import { assert } from '@fluidframework/core-utils/internal';
7
7
  import { BTree } from '@tylerbu/sorted-btree-es6';
8
+ // eslint-disable-next-line import-x/no-internal-modules
9
+ import { diffAgainst } from '@tylerbu/sorted-btree-es6/extended/diffAgainst';
8
10
 
9
11
  import { compareBtrees, compareFiniteNumbers, copyPropertyIfDefined, fail } from './Common.js';
10
12
  import { NodeId, TraitLabel } from './Identifiers.js';
@@ -481,7 +483,8 @@ export class Forest {
481
483
  const changed: NodeId[] = [];
482
484
  const removed: NodeId[] = [];
483
485
  const added: NodeId[] = [];
484
- this.nodes.diffAgainst(
486
+ diffAgainst(
487
+ this.nodes,
485
488
  forest.nodes,
486
489
  (id) => {
487
490
  removed.push(id);
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
- * @returns the number of entries in this map
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
- * @returns the min key in the map.
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
- * @returns the max key in the map.
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
- * @returns the min value in the map.
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
- * @returns the min value in the map.
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
- * @returns the min key in the map.
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
- * @returns the max key in the map.
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
- * @returns an iterable of the entries in the map.
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
- * @returns an iterable of the keys in the map.
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
- * @returns an iterable of the values in the map.
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
- * @returns an iterable of the entries in the map, reversed.
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 - the key to add.
139
- * @param value - the value to add.
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
- * @param key - the key to lookup.
153
- * @returns the value associated with `key` if such an entry exists, and undefined otherwise.
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
- * @param key - the key to lookup.
165
- * @returns the entry associated with `key` if such an entry exists, the entry associated with the next lower key if such an entry
166
- * exists, and undefined otherwise.
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
- * @param key - the key to lookup.
174
- * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry
175
- * exists, and undefined otherwise.
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);
@@ -7,6 +7,8 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
7
7
  import { assert } from '@fluidframework/core-utils/internal';
8
8
  import { ITelemetryLoggerExt, createChildLogger } from '@fluidframework/telemetry-utils/internal';
9
9
  import { BTree } from '@tylerbu/sorted-btree-es6';
10
+ // eslint-disable-next-line import-x/no-internal-modules
11
+ import { diffAgainst } from '@tylerbu/sorted-btree-es6/extended/diffAgainst';
10
12
 
11
13
  import {
12
14
  Mutable,
@@ -1416,7 +1418,8 @@ export class IdCompressor {
1416
1418
  return true;
1417
1419
  };
1418
1420
 
1419
- const diff = this.clustersAndOverridesInversion.diffAgainst(
1421
+ const diff = diffAgainst(
1422
+ this.clustersAndOverridesInversion,
1420
1423
  other.clustersAndOverridesInversion,
1421
1424
  missingInOne,
1422
1425
  missingInOne,
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-lint.json"
4
- }