@fluidframework/tree 2.10.0-307399 → 2.10.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 CHANGED
@@ -1,5 +1,83 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Fix typing bug in `adaptEnum` and `enumFromStrings` ([#23077](https://github.com/microsoft/FluidFramework/pull/23077)) [cfb68388cb](https://github.com/microsoft/FluidFramework/commit/cfb68388cb6b88a0ef670633b3afa46a82c99972)
8
+
9
+ When using the return value from [`adaptEnum`](https://fluidframework.com/docs/api/v2/tree#adaptenum-function) as a function, passing in a value who's type is a union no longer produced an incorrectly typed return value. This has been fixed.
10
+
11
+ Additionally [`enumFromStrings`](https://fluidframework.com/docs/api/v2/tree#enumfromstrings-function) has improved the typing of its schema, ensuring the returned object's members have sufficiently specific types.
12
+ Part of this improvement was fixing the `.schema` property to be a tuple over each of the schema where it was previously a tuple of a single combined schema due to a bug.
13
+
14
+ One side-effect of these fixes is that narrowing of the `value` field of a node typed from the `.schema` behaves slightly different, such that the node type is now a union instead of it being a single type with a `.value` that is a union.
15
+ This means that narrowing based on `.value` property narrows which node type you have, not just the value property.
16
+ This mainly matters when matching all cases like the switch statement below:
17
+
18
+ ```typescript
19
+ const Mode = enumFromStrings(schema, ["Fun", "Bonus"]);
20
+ type Mode = TreeNodeFromImplicitAllowedTypes<typeof Mode.schema>;
21
+ const node = new Mode.Bonus() as Mode;
22
+
23
+ switch (node.value) {
24
+ case "Fun": {
25
+ assert.fail();
26
+ }
27
+ case "Bonus": {
28
+ // This one runs
29
+ break;
30
+ }
31
+ default:
32
+ // Before this change, "node.value" was never here, now "node" is never.
33
+ unreachableCase(node);
34
+ }
35
+ ```
36
+
37
+ - SharedTree event listeners that implement `Listenable` now allow deregistration of event listeners via an `off()` function. ([#23046](https://github.com/microsoft/FluidFramework/pull/23046)) [c59225db03](https://github.com/microsoft/FluidFramework/commit/c59225db033a516ee20e459ae31567d97ce8776c)
38
+
39
+ The ability to deregister events via a callback returned by `on()` remains the same.
40
+ Both strategies will remain supported and consumers of SharedTree events may choose which method of deregistration they prefer in a given instance.
41
+
42
+ ```typescript
43
+ // The new behavior
44
+ function deregisterViaOff(view: TreeView<MySchema>): {
45
+ const listener = () => { /* ... */ };
46
+ view.events.on("commitApplied", listener); // Register
47
+ view.events.off("commitApplied", listener); // Deregister
48
+ }
49
+
50
+ // The existing behavior (still supported)
51
+ function deregisterViaCallback(view: TreeView<MySchema>): {
52
+ const off = view.events.on("commitApplied", () => { /* ... */ }); // Register
53
+ off(); // Deregister
54
+ }
55
+ ```
56
+
57
+ - Allow constructing recursive maps from objects ([#23070](https://github.com/microsoft/FluidFramework/pull/23070)) [0185a08c6f](https://github.com/microsoft/FluidFramework/commit/0185a08c6f8bf6e922a6467f11da049503c4d215)
58
+
59
+ Previously only non-recursive maps could be constructed from objects.
60
+ Now all maps nodes can constructed from objects:
61
+
62
+ ```typescript
63
+ class MapRecursive extends sf.mapRecursive("Map", [() => MapRecursive]) {}
64
+ {
65
+ type _check = ValidateRecursiveSchema<typeof MapRecursive>;
66
+ }
67
+ // New:
68
+ const fromObject = new MapRecursive({ x: new MapRecursive() });
69
+ // Existing:
70
+ const fromIterator = new MapRecursive([["x", new MapRecursive()]]);
71
+ const fromMap = new MapRecursive(new Map([["x", new MapRecursive()]]));
72
+ const fromNothing = new MapRecursive();
73
+ const fromUndefined = new MapRecursive(undefined);
74
+ ```
75
+
76
+ - Provide more comprehensive replacement to the `commitApplied` event ([#22977](https://github.com/microsoft/FluidFramework/pull/22977)) [e51c94da32](https://github.com/microsoft/FluidFramework/commit/e51c94da3248868de3c0c7fdce568cc425204155)
77
+
78
+ Adds a new `changed` event to the (currently alpha) `TreeBranchEvents` that replaces the `commitApplied` event on `TreeViewEvents`.
79
+ This new event is fired for both local and remote changes and maintains the existing functionality of `commitApplied` that is used for obtaining `Revertibles`.
80
+
3
81
  ## 2.5.0
4
82
 
5
83
  ### Minor Changes
@@ -336,7 +336,7 @@ function comparePosetElements(a, b, realizer) {
336
336
  for (const extension of realizer) {
337
337
  const aIndex = extension.get(a);
338
338
  const bIndex = extension.get(b);
339
- (0, internal_1.assert)(aIndex !== undefined && bIndex !== undefined, "Invalid realizer");
339
+ (0, internal_1.assert)(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);
340
340
  if (aIndex < bIndex) {
341
341
  hasLessThanResult = true;
342
342
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAY6B;AAC7B,kDAA4C;AAyF5C,SAAS,iBAAiB,CAAC,UAAgC;IAC1D,IAAI,UAAU,YAAY,iCAAsB,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC;IACjB,CAAC;SAAM,IAAI,UAAU,YAAY,8BAAmB,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,UAAU,YAAY,+BAAoB,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC;IACf,CAAC;IACD,wBAAwB,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,QAAe,CAAC,CAAC,8BAA8B,CAC9C,IAAsB,EACtB,MAAwB;IAExB,kCAAkC;IAClC,KAAK,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAE3E,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACtE,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACf,MAAM,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licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in comparison.ts.\n// Rather than both existing, one of which just returns boolean and the other which returns additional details, a simple comparison which returns everything needed should be used.\n\n/**\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\n\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\nexport interface AllowedTypeDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"allowedTypes\";\n\t/**\n\t * List of allowed type identifiers in viewed schema\n\t */\n\tview: string[];\n\t/**\n\t * List of allowed type identifiers in stored schema\n\t */\n\tstored: string[];\n}\n\nexport interface FieldKindDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"fieldKind\";\n\tview: FieldKindIdentifier;\n\tstored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind = \"object\" | \"leaf\" | \"map\";\n\nfunction getNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn \"object\";\n\t} else if (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn \"map\";\n\t} else if (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn \"leaf\";\n\t}\n\tthrowUnsupportedNodeType(nodeSchema.constructor.name);\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * The workflow for finding schema incompatibilities:\n * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.\n *\n * 2. For each node schema in the `view`:\n * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are\n * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`\n * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`\n * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.\n *\n * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already\n * addressed in the previous step.\n *\n * @returns the discrepancies between two TreeStoredSchema objects\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: TreeStoredSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);\n\n\tfor (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tconst viewType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: viewType,\n\t\t\t\t\tstored: undefined,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tconst storedType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: undefined,\n\t\t\t\t\tstored: storedType,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeStoredSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tconst viewType = getNodeSchemaType(view);\n\tconst storedType = getNodeSchemaType(stored);\n\tif (viewType !== storedType) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: viewType,\n\t\t\tstored: storedType,\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (viewType) {\n\t\tcase \"object\": {\n\t\t\tconst differences = Array.from(\n\t\t\t\ttrackObjectNodeDiscrepancies(\n\t\t\t\t\tview as ObjectNodeStoredSchema,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"map\":\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\t(view as MapNodeStoredSchema).mapFields,\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"leaf\": {\n\t\t\tconst viewValue = (view as LeafNodeStoredSchema).leafValue;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * The function to track the discrepancies between two field stored schemas.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: TreeFieldStoredSchema,\n\tstored: TreeFieldStoredSchema,\n\tkeyOrRoot?: string,\n): Iterable<FieldDiscrepancy> {\n\t// Only track the symmetric differences of two sets.\n\tconst findSetDiscrepancies = (\n\t\ta: TreeTypeSet,\n\t\tb: TreeTypeSet,\n\t): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {\n\t\tconst aDiff = [...a].filter((value) => !b.has(value));\n\t\tconst bDiff = [...b].filter((value) => !a.has(value));\n\t\treturn [aDiff, bDiff];\n\t};\n\n\tconst [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tif (view.kind !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\nfunction* trackObjectNodeDiscrepancies(\n\tview: ObjectNodeStoredSchema,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tfor (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {\n\t\tconst fieldKey = result.key;\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: result.value.kind,\n\t\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: result.value.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction* compareMaps<K, V1, V2>(\n\ta: ReadonlyMap<K, V1>,\n\tb: ReadonlyMap<K, V2>,\n): Iterable<\n\t| { type: \"aExtra\"; key: K; value: V1 }\n\t| { type: \"bExtra\"; key: K; value: V2 }\n\t| { type: \"both\"; key: K; valueA: V1; valueB: V2 }\n> {\n\tfor (const [key, valueA] of a) {\n\t\tconst valueB = b.get(key);\n\t\tyield valueB === undefined\n\t\t\t? { type: \"aExtra\", key, value: valueA }\n\t\t\t: { type: \"both\", key, valueA, valueB };\n\t}\n\tfor (const [key, valueB] of b) {\n\t\tif (!a.has(key)) {\n\t\t\tyield { type: \"bExtra\", key, value: valueB };\n\t\t}\n\t}\n}\n/**\n * @remarks\n *\n * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines\n * whether the `view` schema allows a superset of the documents that the `stored` schema allows.\n * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:\n * 1. Adding an optional field to an object node.\n * 2. Expanding the set of allowed types for a field.\n * 3. Relaxing a field kind to a more general field kind.\n *\n * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios\n * where the inconsistency will occur:\n *\n * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),\n * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue\n * validating internal fields.\n */\nexport function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean {\n\tconst discrepancies = getAllowedContentDiscrepancies(view, stored);\n\n\tfor (const discrepancy of discrepancies) {\n\t\tswitch (discrepancy.mismatch) {\n\t\t\tcase \"nodeKind\": {\n\t\t\t\tif (discrepancy.stored !== undefined) {\n\t\t\t\t\t// It's fine for the view schema to know of a node type that the stored schema doesn't know about.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"valueSchema\":\n\t\t\tcase \"allowedTypes\":\n\t\t\tcase \"fieldKind\": {\n\t\t\t\tif (!isFieldDiscrepancyCompatible(discrepancy)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"fields\": {\n\t\t\t\tif (\n\t\t\t\t\tdiscrepancy.differences.some(\n\t\t\t\t\t\t(difference) => !isFieldDiscrepancyCompatible(difference),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFieldDiscrepancyCompatible(discrepancy: FieldDiscrepancy): boolean {\n\tswitch (discrepancy.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\t// Since we only track the symmetric difference between the allowed types in the view and\n\t\t\t// stored schemas, it's sufficient to check if any extra allowed types still exist in the\n\t\t\t// stored schema.\n\t\t\treturn discrepancy.stored.length === 0;\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn false;\n\t\t}\n\t\t// No default\n\t}\n\treturn false;\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\ntype LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\ntype Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nconst fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nconst PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\nfunction comparePosetElements<T>(a: T, b: T, realizer: Realizer<T>): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, \"Invalid realizer\");\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n\nfunction posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean {\n\tconst comparison = comparePosetElements(a, b, realizer);\n\treturn (\n\t\tcomparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal\n\t);\n}\n\nfunction throwUnsupportedNodeType(type: string): never {\n\tthrow new TypeError(`Unsupported node stored schema type: ${type}`);\n}\n"]}
1
+ {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/discrepancies.ts"],"names":[],"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AG,MAAM,EAAE,CAAC;YACrB,iBAAiB,GAAG,IAAI,CAAC;QAC1B,CAAC;aAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YAC5B,oBAAoB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,iBAAiB;QACvB,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,YAAY;YACpC,CAAC,CAAC,qBAAqB,CAAC,IAAI;QAC7B,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,OAAO;YAC/B,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAI,CAAI,EAAE,CAAI,EAAE,QAAqB;IACrD,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,CACN,UAAU,KAAK,qBAAqB,CAAC,IAAI,IAAI,UAAU,KAAK,qBAAqB,CAAC,KAAK,CACvF,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY;IAC7C,MAAM,IAAI,SAAS,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in comparison.ts.\n// Rather than both existing, one of which just returns boolean and the other which returns additional details, a simple comparison which returns everything needed should be used.\n\n/**\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\n\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\nexport interface AllowedTypeDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"allowedTypes\";\n\t/**\n\t * List of allowed type identifiers in viewed schema\n\t */\n\tview: string[];\n\t/**\n\t * List of allowed type identifiers in stored schema\n\t */\n\tstored: string[];\n}\n\nexport interface FieldKindDiscrepancy {\n\tidentifier: string | undefined; // undefined indicates root field schema\n\tmismatch: \"fieldKind\";\n\tview: FieldKindIdentifier;\n\tstored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: string;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind = \"object\" | \"leaf\" | \"map\";\n\nfunction getNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn \"object\";\n\t} else if (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn \"map\";\n\t} else if (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn \"leaf\";\n\t}\n\tthrowUnsupportedNodeType(nodeSchema.constructor.name);\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * The workflow for finding schema incompatibilities:\n * 1. Compare the two root schemas to identify any `FieldDiscrepancy`.\n *\n * 2. For each node schema in the `view`:\n * - Verify if the node schema exists in the stored. If it does, ensure that the `SchemaFactoryNodeKind` are\n * consistent. Otherwise this difference is treated as `NodeKindDiscrepancy`\n * - If a node schema with the same identifier exists in both view and stored, and their `SchemaFactoryNodeKind`\n * are consistent, perform a exhaustive validation to identify all `FieldDiscrepancy`.\n *\n * 3. For each node schema in the stored, verify if it exists in the view. The overlapping parts were already\n * addressed in the previous step.\n *\n * @returns the discrepancies between two TreeStoredSchema objects\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: TreeStoredSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema);\n\n\tfor (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tconst viewType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: viewType,\n\t\t\t\t\tstored: undefined,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tconst storedType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: undefined,\n\t\t\t\t\tstored: storedType,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeStoredSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tconst viewType = getNodeSchemaType(view);\n\tconst storedType = getNodeSchemaType(stored);\n\tif (viewType !== storedType) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: viewType,\n\t\t\tstored: storedType,\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (viewType) {\n\t\tcase \"object\": {\n\t\t\tconst differences = Array.from(\n\t\t\t\ttrackObjectNodeDiscrepancies(\n\t\t\t\t\tview as ObjectNodeStoredSchema,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"map\":\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\t(view as MapNodeStoredSchema).mapFields,\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"leaf\": {\n\t\t\tconst viewValue = (view as LeafNodeStoredSchema).leafValue;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * The function to track the discrepancies between two field stored schemas.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: TreeFieldStoredSchema,\n\tstored: TreeFieldStoredSchema,\n\tkeyOrRoot?: string,\n): Iterable<FieldDiscrepancy> {\n\t// Only track the symmetric differences of two sets.\n\tconst findSetDiscrepancies = (\n\t\ta: TreeTypeSet,\n\t\tb: TreeTypeSet,\n\t): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {\n\t\tconst aDiff = [...a].filter((value) => !b.has(value));\n\t\tconst bDiff = [...b].filter((value) => !a.has(value));\n\t\treturn [aDiff, bDiff];\n\t};\n\n\tconst [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tif (view.kind !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier: keyOrRoot,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\nfunction* trackObjectNodeDiscrepancies(\n\tview: ObjectNodeStoredSchema,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tfor (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {\n\t\tconst fieldKey = result.key;\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: result.value.kind,\n\t\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: fieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: result.value.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getFieldDiscrepancies(result.valueA, result.valueB, fieldKey);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction* compareMaps<K, V1, V2>(\n\ta: ReadonlyMap<K, V1>,\n\tb: ReadonlyMap<K, V2>,\n): Iterable<\n\t| { type: \"aExtra\"; key: K; value: V1 }\n\t| { type: \"bExtra\"; key: K; value: V2 }\n\t| { type: \"both\"; key: K; valueA: V1; valueB: V2 }\n> {\n\tfor (const [key, valueA] of a) {\n\t\tconst valueB = b.get(key);\n\t\tyield valueB === undefined\n\t\t\t? { type: \"aExtra\", key, value: valueA }\n\t\t\t: { type: \"both\", key, valueA, valueB };\n\t}\n\tfor (const [key, valueB] of b) {\n\t\tif (!a.has(key)) {\n\t\t\tyield { type: \"bExtra\", key, value: valueB };\n\t\t}\n\t}\n}\n/**\n * @remarks\n *\n * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines\n * whether the `view` schema allows a superset of the documents that the `stored` schema allows.\n * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:\n * 1. Adding an optional field to an object node.\n * 2. Expanding the set of allowed types for a field.\n * 3. Relaxing a field kind to a more general field kind.\n *\n * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios\n * where the inconsistency will occur:\n *\n * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),\n * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue\n * validating internal fields.\n */\nexport function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean {\n\tconst discrepancies = getAllowedContentDiscrepancies(view, stored);\n\n\tfor (const discrepancy of discrepancies) {\n\t\tswitch (discrepancy.mismatch) {\n\t\t\tcase \"nodeKind\": {\n\t\t\t\tif (discrepancy.stored !== undefined) {\n\t\t\t\t\t// It's fine for the view schema to know of a node type that the stored schema doesn't know about.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"valueSchema\":\n\t\t\tcase \"allowedTypes\":\n\t\t\tcase \"fieldKind\": {\n\t\t\t\tif (!isFieldDiscrepancyCompatible(discrepancy)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"fields\": {\n\t\t\t\tif (\n\t\t\t\t\tdiscrepancy.differences.some(\n\t\t\t\t\t\t(difference) => !isFieldDiscrepancyCompatible(difference),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFieldDiscrepancyCompatible(discrepancy: FieldDiscrepancy): boolean {\n\tswitch (discrepancy.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\t// Since we only track the symmetric difference between the allowed types in the view and\n\t\t\t// stored schemas, it's sufficient to check if any extra allowed types still exist in the\n\t\t\t// stored schema.\n\t\t\treturn discrepancy.stored.length === 0;\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn false;\n\t\t}\n\t\t// No default\n\t}\n\treturn false;\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\ntype LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\ntype Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nconst fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nconst PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\nfunction comparePosetElements<T>(a: T, b: T, realizer: Realizer<T>): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n\nfunction posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean {\n\tconst comparison = comparePosetElements(a, b, realizer);\n\treturn (\n\t\tcomparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal\n\t);\n}\n\nfunction throwUnsupportedNodeType(type: string): never {\n\tthrow new TypeError(`Unsupported node stored schema type: ${type}`);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/tree";
8
- export declare const pkgVersion = "2.10.0-307399";
8
+ export declare const pkgVersion = "2.10.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,WAAW,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/tree";
11
- exports.pkgVersion = "2.10.0-307399";
11
+ exports.pkgVersion = "2.10.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.10.0-307399\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.10.0\";\n"]}
@@ -300,6 +300,10 @@ export declare class TreeCheckout implements ITreeCheckoutFork {
300
300
  private disposeRevertible;
301
301
  private revertRevertible;
302
302
  private assertNoUntrackedRoots;
303
+ /**
304
+ * `true` iff the given branch change event is due to a remote change
305
+ */
306
+ private isRemoteChangeEvent;
303
307
  }
304
308
  /**
305
309
  * Run a synchronous transaction on the given shared tree view.
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAGjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,0BAA0B,EAC1B,KAAK,4BAA4B,EAOjC,KAAK,iBAAiB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAM5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAwB,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAQ,MAAM,kBAAkB,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EACX,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,M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AC,KAAK,CAAC;IAkBlB,IAAW,UAAU,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAEvD;IAED,IAAW,MAAM,IAAI,iBAAiB,CAGrC;IAEM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK9C,MAAM,IAAI,YAAY;IA0BtB,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAkBpC,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAOzC,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IACnC,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IAsB3D,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAK/C,OAAO,IAAI,IAAI;IAIf,CAAC,aAAa,CAAC,IAAI,IAAI;IAYvB,eAAe,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE;IAiB/E;;;OAGG;IACI,2BAA2B,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAI/D,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,gBAAgB;IAmDxB,OAAO,CAAC,sBAAsB;IAsB9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAW3B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,iBAAiB,GAAG,IAAI,GAC5D,iBAAiB,CAMnB"}
@@ -223,7 +223,7 @@ class TreeCheckout {
223
223
  withinEventContext = false;
224
224
  }
225
225
  }
226
- else if (event.type === "replace") {
226
+ else if (this.isRemoteChangeEvent(event)) {
227
227
  // TODO: figure out how to plumb through commit kind info for remote changes
228
228
  this.events.emit("changed", { isLocal: false, kind: index_js_2.CommitKind.Default });
229
229
  }
@@ -402,6 +402,19 @@ class TreeCheckout {
402
402
  rootFields.delete(field);
403
403
  } while (cursor.nextField());
404
404
  }
405
+ /**
406
+ * `true` iff the given branch change event is due to a remote change
407
+ */
408
+ isRemoteChangeEvent(event) {
409
+ return (
410
+ // remote changes are only ever applied to the main branch
411
+ !this.isBranch &&
412
+ // remote changes are applied to the main branch by rebasing it onto the trunk,
413
+ // no other rebases are allowed on the main branch so this means any replaces that are not
414
+ // transaction commits are remote changes
415
+ event.type === "replace" &&
416
+ (0, index_js_5.getChangeReplaceType)(event) !== "transactionCommit");
417
+ }
405
418
  }
406
419
  exports.TreeCheckout = TreeCheckout;
407
420
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,uEAGkD;AAClD,gDAAkD;AAClD,+CA4B0B;AAC1B,iDAK4B;AAC5B,4DAQuC;AACvC,2DAAsF;AACtF,+CAAqF;AAErF,2EAAsF;AAYtF,uEAAuE;AA2JvE;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,YAA2B,EAC3B,eAAkC,EAClC,gBAAkC,EAClC,IAaC;IAED,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAA,sBAAW,GAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,qCAA0B,EAAE,CAAC;IAChE,MAAM,mBAAmB,GAAG,EAAE,aAAa,EAAE,wBAAa,EAAE,CAAC;IAC7D,MAAM,wBAAwB,GAAG,CAAC,CAAC;IACnC,MAAM,YAAY,GACjB,IAAI,EAAE,YAAY;QAClB,IAAI,kDAAsB,CACzB,gBAAgB,EAChB,IAAI,EAAE,eAAe;YACpB,IAAA,8BAAmB,EAAC,mBAAmB,EAAE,wBAAwB,CAAC,EACnE,EAAE,aAAa,EAAE,wBAAa,EAAE,EAChC,IAAI,EAAE,wBAAwB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OAAO,MAAM,KAAK,4BAAiB,CAAC,KAAK;QACxC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleFactory,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tcreateNodeKeyManager,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport { SharedTreeBranch, getChangeReplaceType } from \"../shared-tree-core/index.js\";\nimport { Breakable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tImplicitFieldSchema,\n\tReadSchema,\n\tTreeView,\n\tTreeViewConfiguration,\n\tUnsafeUnknownSchema,\n\tViewableTree,\n} from \"../simple-tree/index.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): void;\n}\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator, ViewableTree {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t\tbreaker?: Breakable;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t\tidCompressor,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tfalse,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t\targs?.breaker,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout {\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tpublic disposed = false;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * copies of the removed roots used as snapshots for reverting to previous state when transactions are aborted\n\t */\n\tprivate readonly removedRootsSnapshots: DetachedFieldIndex[] = [];\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\t/** True if and only if this checkout is for a forked branch and not the \"main branch\" of the tree. */\n\t\tpublic readonly isBranch: boolean,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t\tprivate readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t) {\n\t\t// when a transaction is started, take a snapshot of the current state of removed roots\n\t\t_branch.events.on(\"transactionStarted\", () => {\n\t\t\tthis.removedRootsSnapshots.push(this.removedRoots.clone());\n\t\t});\n\t\t// when a transaction is committed, the latest snapshot of removed roots can be discarded\n\t\t_branch.events.on(\"transactionCommitted\", () => {\n\t\t\tthis.removedRootsSnapshots.pop();\n\t\t});\n\t\t// after a transaction is rolled back, revert removed roots back to the latest snapshot\n\t\t_branch.events.on(\"transactionRolledBack\", () => {\n\t\t\tconst snapshot = this.removedRootsSnapshots.pop();\n\t\t\tassert(snapshot !== undefined, 0x9ae /* a snapshot for removed roots does not exist */);\n\t\t\tthis.removedRoots = snapshot;\n\t\t});\n\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\t_branch.events.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\tconst revision =\n\t\t\t\t\tevent.type === \"replace\"\n\t\t\t\t\t\t? // Change events will always contain new commits\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tevent.newCommits[event.newCommits.length - 1]!.revision\n\t\t\t\t\t\t: event.change.revision;\n\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst firstCommit = event.newCommits[0] ?? oob();\n\t\t\t\tconst transactionRevision = firstCommit.revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t_branch.events.on(\"afterChange\", (event) => {\n\t\t\t// The following logic allows revertibles to be generated for the change.\n\t\t\t// Currently only appends (including merges) and transaction commits are supported.\n\t\t\tif (!_branch.isTransacting()) {\n\t\t\t\tif (\n\t\t\t\t\tevent.type === \"append\" ||\n\t\t\t\t\t(event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\")\n\t\t\t\t) {\n\t\t\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, kind);\n\t\t\t\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, _branch.fork(commit));\n\t\t\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\tlet withinEventContext = true;\n\t\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: true, kind }, getRevertible);\n\t\t\t\t\t\twithinEventContext = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (event.type === \"replace\") {\n\t\t\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\t_branch.events.on(\"ancestryTrimmed\", (revisions) => {\n\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\trevisions.forEach((revision) => {\n\t\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\t\tconst roots = this.removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\t\tfor (const root of roots) {\n\t\t\t\t\t\tvisitor.destroy(this.removedRoots.toFieldKey(root), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(usageError?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.idCompressor),\n\t\t\tthis.breaker,\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this._branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this._branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\ttrue,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t\tthis.breaker,\n\t\t);\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tassert(\n\t\t\t!checkout.transaction.inProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\tcheckout.isBranch,\n\t\t\t0xa5d /* The main branch cannot be rebased onto another branch. */,\n\t\t);\n\t\tcheckout._branch.rebaseOnto(this._branch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tassert(\n\t\t\t!this.transaction.inProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (checkout.transaction.inProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis._branch.merge(checkout._branch);\n\t\tif (disposeMerged && checkout.isBranch) {\n\t\t\t// Dispose the merged checkout unless it is the main branch.\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis._branch.dispose();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tthis.assertNoUntrackedRoots();\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This sets the tip revision as the latest relevant revision for any removed roots that are loaded from a summary.\n\t * This needs to be called right after loading {@link this.removedRoots} from a summary to allow loaded data to be garbage collected.\n\t */\n\tpublic setTipRevisionForLoadedData(revision: RevisionTag): void {\n\t\tthis.removedRoots.setRevisionsForLoadedData(revision);\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this._branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\n\t\t);\n\n\t\tconst headCommit = this._branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = tagChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis._branch.apply(\n\t\t\tchange,\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n\n\tprivate assertNoUntrackedRoots(): void {\n\t\tconst cursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst rootFields = new Set([rootFieldKey]);\n\t\tfor (const { root } of this.removedRoots.entries()) {\n\t\t\trootFields.add(this.removedRoots.toFieldKey(root));\n\t\t}\n\n\t\tif (!cursor.firstField()) {\n\t\t\treturn;\n\t\t}\n\n\t\tdo {\n\t\t\tconst field = cursor.getFieldKey();\n\t\t\tassert(\n\t\t\t\trootFields.has(field),\n\t\t\t\t0xa22 /* Forest has a root field which is unknown to the detached field index */,\n\t\t\t);\n\n\t\t\trootFields.delete(field);\n\t\t} while (cursor.nextField());\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}
1
+ {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,uEAGk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U,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;YAC1B,OAAO;QACR,CAAC;QAED,GAAG,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACnC,IAAA,iBAAM,EACL,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EACrB,KAAK,CAAC,0EAA0E,CAChF,CAAC;YAEF,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC,QAAQ,MAAM,CAAC,SAAS,EAAE,EAAE;IAC9B,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,KAA+C;QAC1E,OAAO;QACN,0DAA0D;QAC1D,CAAC,IAAI,CAAC,QAAQ;YACd,+EAA+E;YAC/E,0FAA0F;YAC1F,yCAAyC;YACzC,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,IAAA,+BAAoB,EAAC,KAAK,CAAC,KAAK,mBAAmB,CACnD,CAAC;IACH,CAAC;;AA/eF,oCAgfC;AAvdA;;;GAGG;AACoB,qCAAwB,GAAG,kBAAkB,AAArB,CAAsB;AAqdtE;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC7B,IAAmB,EACnB,WAA8D;IAE9D,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,KAAK,4BAAiB,CAAC,KAAK;QACxC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleFactory,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tcreateNodeKeyManager,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport {\n\tSharedTreeBranch,\n\tgetChangeReplaceType,\n\ttype SharedTreeBranchChange,\n} from \"../shared-tree-core/index.js\";\nimport { Breakable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tImplicitFieldSchema,\n\tReadSchema,\n\tTreeView,\n\tTreeViewConfiguration,\n\tUnsafeUnknownSchema,\n\tViewableTree,\n} from \"../simple-tree/index.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): void;\n}\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator, ViewableTree {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t\tbreaker?: Breakable;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t\tidCompressor,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tfalse,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t\targs?.breaker,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout {\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tpublic disposed = false;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * copies of the removed roots used as snapshots for reverting to previous state when transactions are aborted\n\t */\n\tprivate readonly removedRootsSnapshots: DetachedFieldIndex[] = [];\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\t/** True if and only if this checkout is for a forked branch and not the \"main branch\" of the tree. */\n\t\tpublic readonly isBranch: boolean,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t\tprivate readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t) {\n\t\t// when a transaction is started, take a snapshot of the current state of removed roots\n\t\t_branch.events.on(\"transactionStarted\", () => {\n\t\t\tthis.removedRootsSnapshots.push(this.removedRoots.clone());\n\t\t});\n\t\t// when a transaction is committed, the latest snapshot of removed roots can be discarded\n\t\t_branch.events.on(\"transactionCommitted\", () => {\n\t\t\tthis.removedRootsSnapshots.pop();\n\t\t});\n\t\t// after a transaction is rolled back, revert removed roots back to the latest snapshot\n\t\t_branch.events.on(\"transactionRolledBack\", () => {\n\t\t\tconst snapshot = this.removedRootsSnapshots.pop();\n\t\t\tassert(snapshot !== undefined, 0x9ae /* a snapshot for removed roots does not exist */);\n\t\t\tthis.removedRoots = snapshot;\n\t\t});\n\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\t_branch.events.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\tconst revision =\n\t\t\t\t\tevent.type === \"replace\"\n\t\t\t\t\t\t? // Change events will always contain new commits\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tevent.newCommits[event.newCommits.length - 1]!.revision\n\t\t\t\t\t\t: event.change.revision;\n\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst firstCommit = event.newCommits[0] ?? oob();\n\t\t\t\tconst transactionRevision = firstCommit.revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t_branch.events.on(\"afterChange\", (event) => {\n\t\t\t// The following logic allows revertibles to be generated for the change.\n\t\t\t// Currently only appends (including merges) and transaction commits are supported.\n\t\t\tif (!_branch.isTransacting()) {\n\t\t\t\tif (\n\t\t\t\t\tevent.type === \"append\" ||\n\t\t\t\t\t(event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\")\n\t\t\t\t) {\n\t\t\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, kind);\n\t\t\t\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, _branch.fork(commit));\n\t\t\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\tlet withinEventContext = true;\n\t\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: true, kind }, getRevertible);\n\t\t\t\t\t\twithinEventContext = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (this.isRemoteChangeEvent(event)) {\n\t\t\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\t_branch.events.on(\"ancestryTrimmed\", (revisions) => {\n\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\trevisions.forEach((revision) => {\n\t\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\t\tconst roots = this.removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\t\tfor (const root of roots) {\n\t\t\t\t\t\tvisitor.destroy(this.removedRoots.toFieldKey(root), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(usageError?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.idCompressor),\n\t\t\tthis.breaker,\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this._branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this._branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\ttrue,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t\tthis.breaker,\n\t\t);\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tassert(\n\t\t\t!checkout.transaction.inProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\tcheckout.isBranch,\n\t\t\t0xa5d /* The main branch cannot be rebased onto another branch. */,\n\t\t);\n\t\tcheckout._branch.rebaseOnto(this._branch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tassert(\n\t\t\t!this.transaction.inProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (checkout.transaction.inProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis._branch.merge(checkout._branch);\n\t\tif (disposeMerged && checkout.isBranch) {\n\t\t\t// Dispose the merged checkout unless it is the main branch.\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis._branch.dispose();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tthis.assertNoUntrackedRoots();\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This sets the tip revision as the latest relevant revision for any removed roots that are loaded from a summary.\n\t * This needs to be called right after loading {@link this.removedRoots} from a summary to allow loaded data to be garbage collected.\n\t */\n\tpublic setTipRevisionForLoadedData(revision: RevisionTag): void {\n\t\tthis.removedRoots.setRevisionsForLoadedData(revision);\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this._branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\n\t\t);\n\n\t\tconst headCommit = this._branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = tagChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis._branch.apply(\n\t\t\tchange,\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n\n\tprivate assertNoUntrackedRoots(): void {\n\t\tconst cursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst rootFields = new Set([rootFieldKey]);\n\t\tfor (const { root } of this.removedRoots.entries()) {\n\t\t\trootFields.add(this.removedRoots.toFieldKey(root));\n\t\t}\n\n\t\tif (!cursor.firstField()) {\n\t\t\treturn;\n\t\t}\n\n\t\tdo {\n\t\t\tconst field = cursor.getFieldKey();\n\t\t\tassert(\n\t\t\t\trootFields.has(field),\n\t\t\t\t0xa22 /* Forest has a root field which is unknown to the detached field index */,\n\t\t\t);\n\n\t\t\trootFields.delete(field);\n\t\t} while (cursor.nextField());\n\t}\n\n\t/**\n\t * `true` iff the given branch change event is due to a remote change\n\t */\n\tprivate isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {\n\t\treturn (\n\t\t\t// remote changes are only ever applied to the main branch\n\t\t\t!this.isBranch &&\n\t\t\t// remote changes are applied to the main branch by rebasing it onto the trunk,\n\t\t\t// no other rebases are allowed on the main branch so this means any replaces that are not\n\t\t\t// transaction commits are remote changes\n\t\t\tevent.type === \"replace\" &&\n\t\t\tgetChangeReplaceType(event) !== \"transactionCommit\"\n\t\t);\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}
@@ -331,7 +331,7 @@ function comparePosetElements(a, b, realizer) {
331
331
  for (const extension of realizer) {
332
332
  const aIndex = extension.get(a);
333
333
  const bIndex = extension.get(b);
334
- assert(aIndex !== undefined && bIndex !== undefined, "Invalid realizer");
334
+ assert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);
335
335
  if (aIndex < bIndex) {
336
336
  hasLessThanResult = true;
337
337
  }