@fluidframework/tree 2.63.0-359962 → 2.70.0-360374

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 (127) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/api-report/tree.alpha.api.md +7 -8
  3. package/dist/codec/codec.d.ts +10 -27
  4. package/dist/codec/codec.d.ts.map +1 -1
  5. package/dist/codec/codec.js +9 -28
  6. package/dist/codec/codec.js.map +1 -1
  7. package/dist/codec/versioned/codec.d.ts +6 -5
  8. package/dist/codec/versioned/codec.d.ts.map +1 -1
  9. package/dist/codec/versioned/codec.js +4 -4
  10. package/dist/codec/versioned/codec.js.map +1 -1
  11. package/dist/core/tree/detachedFieldIndex.js +1 -1
  12. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  13. package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
  14. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  15. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -3
  16. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  17. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  18. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  19. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  20. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  21. package/dist/feature-libraries/schema-index/codec.d.ts +6 -5
  22. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  23. package/dist/feature-libraries/schema-index/codec.js +3 -3
  24. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  29. package/dist/shared-tree/schematizingTreeView.js +4 -4
  30. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  31. package/dist/shared-tree/sharedTree.js +1 -1
  32. package/dist/shared-tree/sharedTree.js.map +1 -1
  33. package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -1
  34. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  35. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  36. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  37. package/dist/shared-tree/treeAlpha.js +1 -1
  38. package/dist/shared-tree/treeAlpha.js.map +1 -1
  39. package/dist/shared-tree/treeCheckout.js +1 -1
  40. package/dist/shared-tree/treeCheckout.js.map +1 -1
  41. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  42. package/dist/shared-tree-core/defaultResubmitMachine.js +3 -2
  43. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  44. package/dist/simple-tree/api/storedSchema.d.ts +4 -3
  45. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  46. package/dist/simple-tree/api/storedSchema.js +3 -3
  47. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  48. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  49. package/dist/simple-tree/core/allowedTypes.js +1 -1
  50. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  51. package/dist/simple-tree/prepareForInsertion.js +1 -1
  52. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  53. package/dist/treeFactory.d.ts.map +1 -1
  54. package/dist/treeFactory.js +13 -4
  55. package/dist/treeFactory.js.map +1 -1
  56. package/lib/codec/codec.d.ts +10 -27
  57. package/lib/codec/codec.d.ts.map +1 -1
  58. package/lib/codec/codec.js +8 -27
  59. package/lib/codec/codec.js.map +1 -1
  60. package/lib/codec/versioned/codec.d.ts +6 -5
  61. package/lib/codec/versioned/codec.d.ts.map +1 -1
  62. package/lib/codec/versioned/codec.js +4 -4
  63. package/lib/codec/versioned/codec.js.map +1 -1
  64. package/lib/core/tree/detachedFieldIndex.js +1 -1
  65. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  66. package/lib/core/tree/detachedFieldIndexCodecs.js +1 -1
  67. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  68. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -3
  69. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  70. package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  71. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  72. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  73. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  74. package/lib/feature-libraries/schema-index/codec.d.ts +6 -5
  75. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  76. package/lib/feature-libraries/schema-index/codec.js +3 -3
  77. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  78. package/lib/packageVersion.d.ts +1 -1
  79. package/lib/packageVersion.js +1 -1
  80. package/lib/packageVersion.js.map +1 -1
  81. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  82. package/lib/shared-tree/schematizingTreeView.js +4 -4
  83. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  84. package/lib/shared-tree/sharedTree.js +1 -1
  85. package/lib/shared-tree/sharedTree.js.map +1 -1
  86. package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -1
  87. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  88. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  89. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  90. package/lib/shared-tree/treeAlpha.js +1 -1
  91. package/lib/shared-tree/treeAlpha.js.map +1 -1
  92. package/lib/shared-tree/treeCheckout.js +1 -1
  93. package/lib/shared-tree/treeCheckout.js.map +1 -1
  94. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  95. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  96. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  97. package/lib/simple-tree/api/storedSchema.d.ts +4 -3
  98. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  99. package/lib/simple-tree/api/storedSchema.js +3 -3
  100. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  101. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  102. package/lib/simple-tree/core/allowedTypes.js +1 -1
  103. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  104. package/lib/simple-tree/prepareForInsertion.js +1 -1
  105. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  106. package/lib/treeFactory.d.ts.map +1 -1
  107. package/lib/treeFactory.js +13 -4
  108. package/lib/treeFactory.js.map +1 -1
  109. package/package.json +21 -20
  110. package/src/codec/codec.ts +11 -29
  111. package/src/codec/versioned/codec.ts +6 -6
  112. package/src/core/tree/detachedFieldIndex.ts +1 -1
  113. package/src/core/tree/detachedFieldIndexCodecs.ts +1 -1
  114. package/src/feature-libraries/chunked-forest/codec/codecs.ts +3 -3
  115. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  116. package/src/feature-libraries/schema-index/codec.ts +5 -5
  117. package/src/packageVersion.ts +1 -1
  118. package/src/shared-tree/schematizingTreeView.ts +10 -4
  119. package/src/shared-tree/sharedTree.ts +1 -1
  120. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -1
  121. package/src/shared-tree/treeAlpha.ts +3 -9
  122. package/src/shared-tree/treeCheckout.ts +1 -1
  123. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  124. package/src/simple-tree/api/storedSchema.ts +5 -4
  125. package/src/simple-tree/core/allowedTypes.ts +4 -1
  126. package/src/simple-tree/prepareForInsertion.ts +1 -1
  127. package/src/treeFactory.ts +17 -4
@@ -8,7 +8,6 @@ import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
8
8
 
9
9
  import {
10
10
  type CodecTree,
11
- type FluidClientVersion,
12
11
  type ICodecOptions,
13
12
  type IJsonCodec,
14
13
  makeVersionedValidatedCodec,
@@ -35,6 +34,7 @@ import type { FieldBatch } from "./fieldBatch.js";
35
34
  import { EncodedFieldBatch, validVersions, type FieldBatchFormatVersion } from "./format.js";
36
35
  import { schemaCompressedEncode } from "./schemaBasedEncode.js";
37
36
  import { uncompressedEncode } from "./uncompressedEncode.js";
37
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
38
38
  import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
39
39
 
40
40
  /**
@@ -115,12 +115,12 @@ export type FieldBatchCodec = IJsonCodec<
115
115
  >;
116
116
 
117
117
  /**
118
- * Get the write version for {@link makeFieldBatchCodec} based on the `oldestCompatibleClient` version.
118
+ * Get the write version for {@link makeFieldBatchCodec} based on the `minVersionForCollab` version.
119
119
  * @privateRemarks
120
120
  * TODO: makeFieldBatchCodec (and makeVersionDispatchingCodec transitively) should bake in this versionToFormat logic and the resulting codec can then support use with FluidClientVersion directly.
121
121
  */
122
122
  export function fluidVersionToFieldBatchCodecWriteVersion(
123
- oldestCompatibleClient: FluidClientVersion,
123
+ minVersionForCollab: MinimumVersionForCollab,
124
124
  ): number {
125
125
  // There is currently on only 1 version.
126
126
  return 1;
@@ -262,7 +262,7 @@ export function getCodecTreeForModularChangeFormat(
262
262
  version: ModularChangeFormatVersion,
263
263
  ): CodecTree {
264
264
  const dependencies =
265
- fieldKindConfigurations.get(version) ?? fail("Unknown modular change format");
265
+ fieldKindConfigurations.get(version) ?? fail(0xc7c /* Unknown modular change format */);
266
266
  const children: CodecTree[] = Array.from(dependencies.entries()).map(
267
267
  ([key, { formatVersion }]) => ({
268
268
  name: `FieldKind:${key}`,
@@ -7,7 +7,6 @@ import { fail, unreachableCase } from "@fluidframework/core-utils/internal";
7
7
 
8
8
  import {
9
9
  type CodecTree,
10
- type FluidClientVersion,
11
10
  type ICodecFamily,
12
11
  type ICodecOptions,
13
12
  type IJsonCodec,
@@ -29,14 +28,15 @@ import { brand, type JsonCompatible } from "../../util/index.js";
29
28
 
30
29
  import { Format as FormatV1 } from "./formatV1.js";
31
30
  import { Format as FormatV2 } from "./formatV2.js";
31
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
32
32
 
33
33
  /**
34
- * Convert a FluidClientVersion to a SchemaVersion.
35
- * @param clientVersion - The FluidClientVersion to convert.
36
- * @returns The SchemaVersion that corresponds to the provided FluidClientVersion.
34
+ * Convert a MinimumVersionForCollab to a SchemaVersion.
35
+ * @param clientVersion - The MinimumVersionForCollab to convert.
36
+ * @returns The SchemaVersion that corresponds to the provided MinimumVersionForCollab.
37
37
  */
38
38
  export function clientVersionToSchemaVersion(
39
- clientVersion: FluidClientVersion,
39
+ clientVersion: MinimumVersionForCollab,
40
40
  ): SchemaVersion {
41
41
  // Only one version of the schema codec is currently supported.
42
42
  return SchemaVersion.v1;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.63.0-359962";
9
+ export const pkgVersion = "2.70.0-360374";
@@ -200,9 +200,15 @@ export class SchematizingSimpleTreeView<
200
200
  this,
201
201
  schema.rootFieldSchema,
202
202
  (batches, doHydration) => {
203
- assert(this.pendingHydration === undefined, "pendingHydration already set");
203
+ assert(
204
+ this.pendingHydration === undefined,
205
+ 0xc74 /* pendingHydration already set */,
206
+ );
204
207
  this.pendingHydration = () => {
205
- assert(batches.length <= 1, "initialize should at most one hydration batch");
208
+ assert(
209
+ batches.length <= 1,
210
+ 0xc75 /* initialize should at most one hydration batch */,
211
+ );
206
212
  for (const batch of batches) {
207
213
  doHydration(batch, {
208
214
  parent: undefined,
@@ -408,7 +414,7 @@ export class SchematizingSimpleTreeView<
408
414
  if (!this.midUpgrade) {
409
415
  assert(
410
416
  this.pendingHydration === undefined,
411
- "no nodes should be pending hydration when triggering events that could access nodes",
417
+ 0xc76 /* no nodes should be pending hydration when triggering events that could access nodes */,
412
418
  );
413
419
  this.events.emit("schemaChanged");
414
420
  this.events.emit("rootChanged");
@@ -477,7 +483,7 @@ export class SchematizingSimpleTreeView<
477
483
  view.root.is(FieldKinds.optional) ||
478
484
  view.root.is(FieldKinds.required) ||
479
485
  view.root.is(FieldKinds.identifier),
480
- "unexpected root field kind",
486
+ 0xc77 /* unexpected root field kind */,
481
487
  );
482
488
  return view.root;
483
489
  }
@@ -942,7 +942,7 @@ export function buildConfiguredForest(
942
942
 
943
943
  export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
944
944
  jsonValidator: FormatValidatorNoOp,
945
- oldestCompatibleClient: FluidClientVersion.v2_0,
945
+ minVersionForCollab: FluidClientVersion.v2_0,
946
946
  forest: ForestTypeReference,
947
947
  treeEncodeType: TreeCompressionStrategy.Compressed,
948
948
  formatVersion: SharedTreeFormatVersion.v3,
@@ -94,7 +94,7 @@ export function getCodecTreeForChangeFormat(
94
94
  version: SharedTreeChangeFormatVersion,
95
95
  ): CodecTree {
96
96
  const { modularChange, schemaChange } =
97
- dependenciesForChangeFormat.get(version) ?? fail("Unknown change format");
97
+ dependenciesForChangeFormat.get(version) ?? fail(0xc78 /* Unknown change format */);
98
98
  return {
99
99
  name: "SharedTreeChange",
100
100
  version,
@@ -331,10 +331,7 @@ export interface TreeAlpha {
331
331
  */
332
332
  exportCompressed(
333
333
  tree: TreeNode | TreeLeafValue,
334
- options: { idCompressor?: IIdCompressor } & Pick<
335
- CodecWriteOptions,
336
- "oldestCompatibleClient"
337
- >,
334
+ options: { idCompressor?: IIdCompressor } & Pick<CodecWriteOptions, "minVersionForCollab">,
338
335
  ): JsonCompatible<IFluidHandle>;
339
336
 
340
337
  /**
@@ -812,13 +809,10 @@ export const TreeAlpha: TreeAlpha = {
812
809
 
813
810
  exportCompressed(
814
811
  node: TreeNode | TreeLeafValue,
815
- options: { idCompressor?: IIdCompressor } & Pick<
816
- CodecWriteOptions,
817
- "oldestCompatibleClient"
818
- >,
812
+ options: { idCompressor?: IIdCompressor } & Pick<CodecWriteOptions, "minVersionForCollab">,
819
813
  ): JsonCompatible<IFluidHandle> {
820
814
  const schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);
821
- const format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);
815
+ const format = fluidVersionToFieldBatchCodecWriteVersion(options.minVersionForCollab);
822
816
  const codec = makeFieldBatchCodec({ jsonValidator: FormatValidatorNoOp }, format);
823
817
  const cursor = borrowFieldCursorFromTreeNodeOrValue(node);
824
818
  const batch: FieldBatch = [cursor];
@@ -298,7 +298,7 @@ export function createTreeCheckout(
298
298
  const forest = args?.forest ?? buildForest(breaker, schema);
299
299
  const defaultCodecOptions = {
300
300
  jsonValidator: FormatValidatorNoOp,
301
- oldestCompatibleClient: FluidClientVersion.v2_0,
301
+ minVersionForCollab: FluidClientVersion.v2_0,
302
302
  };
303
303
  const defaultFieldBatchVersion = 1;
304
304
  const changeFamily =
@@ -70,7 +70,7 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
70
70
  const localCommits = getLocalCommits();
71
71
  assert(
72
72
  localCommits[0]?.revision === revision,
73
- "Expected local commits to start with specified revision",
73
+ 0xc79 /* Expected local commits to start with specified revision */,
74
74
  );
75
75
 
76
76
  // Some in-flight commits have stale enrichments, so we recompute them.
@@ -128,7 +128,8 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
128
128
 
129
129
  private getPendingChange(revision: RevisionTag): PendingChange<TChange> {
130
130
  return (
131
- this.pendingChanges.get(revision) ?? fail("No pending change stored for this revision")
131
+ this.pendingChanges.get(revision) ??
132
+ fail(0xc7a /* No pending change stored for this revision */)
132
133
  );
133
134
  }
134
135
 
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { FluidClientVersion, ICodecOptions } from "../../codec/index.js";
6
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
7
+ import type { ICodecOptions } from "../../codec/index.js";
7
8
  import { SchemaVersion } from "../../core/index.js";
8
9
  import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index.js";
9
10
  import {
@@ -24,7 +25,7 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
24
25
  * Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
25
26
  *
26
27
  * @param schema - The schema to dump.
27
- * @param oldestCompatibleClient - The oldest client version which can read the schema: impacts the format used.
28
+ * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.
28
29
  * @param includeStaged - filter for selecting which staged allowed types to include in the output.
29
30
  *
30
31
  * @remarks
@@ -54,11 +55,11 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
54
55
  */
55
56
  export function extractPersistedSchema(
56
57
  schema: ImplicitFieldSchema,
57
- oldestCompatibleClient: FluidClientVersion,
58
+ minVersionForCollab: MinimumVersionForCollab,
58
59
  includeStaged: (upgrade: SchemaUpgrade) => boolean,
59
60
  ): JsonCompatible {
60
61
  const stored = toStoredSchema(schema, { includeStaged });
61
- const schemaWriteVersion = clientVersionToSchemaVersion(oldestCompatibleClient);
62
+ const schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);
62
63
  return encodeTreeSchema(stored, schemaWriteVersion);
63
64
  }
64
65
 
@@ -539,7 +539,10 @@ export function normalizeAllowedTypesInternal(
539
539
  return getOrCreate(cachedNormalize, type, () => {
540
540
  // Due to more specific internal type, the above does not narrow sufficiently, so more narrowing is needed.
541
541
  // It is possible this will give a false error if a TreeNodeSchema which matches this check is used.
542
- assert(!("types" in type && "metadata" in type), "invalid AnnotatedAllowedTypes");
542
+ assert(
543
+ !("types" in type && "metadata" in type),
544
+ 0xc7d /* invalid AnnotatedAllowedTypes */,
545
+ );
543
546
 
544
547
  const annotatedTypes: AnnotatedAllowedType[] = (isReadonlyArray(type) ? type : [type]).map(
545
548
  normalizeToAnnotatedAllowedType,
@@ -343,7 +343,7 @@ function hydrator(
343
343
  // Find or create one as necessary.
344
344
  for (const { path, node } of batch.paths) {
345
345
  const anchor = forest.anchors.track(path);
346
- const anchorNode = forest.anchors.locate(anchor) ?? fail("missing anchor");
346
+ const anchorNode = forest.anchors.locate(anchor) ?? fail(0xc7b /* missing anchor */);
347
347
 
348
348
  let flexNode = anchorNode.slots.get(flexTreeSlot);
349
349
  if (flexNode === undefined) {
@@ -49,10 +49,23 @@ function treeKernelFactory(
49
49
  if (args.idCompressor === undefined) {
50
50
  throw new UsageError("IdCompressor must be enabled to use SharedTree");
51
51
  }
52
- const adjustedOptions = { ...options };
53
- // TODO: get default from runtime once something like runtime.oldestCompatibleClient exists.
54
- // Using default of 2.0 since that is the oldest version that supports SharedTree.
55
- adjustedOptions.oldestCompatibleClient ??= FluidClientVersion.v2_0;
52
+
53
+ const { minVersionForCollab, ...otherOptions } = options;
54
+
55
+ const adjustedOptions = {
56
+ ...otherOptions,
57
+ // Cases:
58
+ // A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.
59
+ // This value is set when:
60
+ // - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.
61
+ // There is currently no way to set it via the declarative API, but it could be added in the future.
62
+ // - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab
63
+ // B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.
64
+ // C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.
65
+ minVersionForCollab:
66
+ minVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,
67
+ };
68
+
56
69
  return new SharedTreeKernel(
57
70
  new Breakable("SharedTree"),
58
71
  args.sharedObject,