@fluidframework/tree 2.4.0-299707 → 2.4.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 +192 -0
- package/api-report/tree.alpha.api.md +2 -1
- package/api-report/tree.beta.api.md +2 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +3 -3
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -1
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree-core/branch.js +1 -1
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/simple-tree/api/customTree.js +5 -5
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts +14 -2
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.js +23 -8
- package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
- package/dist/simple-tree/core/schemaCaching.js +1 -1
- package/dist/simple-tree/core/schemaCaching.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +7 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +2 -2
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +1 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.js +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree-core/branch.js +1 -1
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/simple-tree/api/customTree.js +5 -5
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts +14 -2
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.js +23 -8
- package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
- package/lib/simple-tree/core/schemaCaching.js +1 -1
- package/lib/simple-tree/core/schemaCaching.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +7 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +2 -2
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/package.json +20 -20
- package/src/feature-libraries/flex-tree/lazyField.ts +1 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +9 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +1 -1
- package/src/shared-tree/sharedTree.ts +1 -1
- package/src/shared-tree-core/branch.ts +1 -1
- package/src/simple-tree/api/customTree.ts +5 -5
- package/src/simple-tree/api/treeApiBeta.ts +65 -3
- package/src/simple-tree/core/schemaCaching.ts +1 -1
- package/src/simple-tree/core/treeNodeKernel.ts +10 -2
- package/src/simple-tree/core/unhydratedFlexTree.ts +1 -1
- package/src/simple-tree/toFlexSchema.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,197 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
+
## 2.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ✨ New! Alpha API for providing SharedTree configuration options ([#22701](https://github.com/microsoft/FluidFramework/pull/22701)) [40d3648ddf](https://github.com/microsoft/FluidFramework/commit/40d3648ddfb5223ef6daef49a4f5cab1cfa52b71)
|
|
8
|
+
|
|
9
|
+
A new alpha `configuredSharedTree` had been added.
|
|
10
|
+
This allows providing configuration options, primarily for debugging, testing and evaluation of upcoming features.
|
|
11
|
+
The resulting configured `SharedTree` object can then be used in-place of the regular `SharedTree` imported from `fluid-framework`.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
ForestType,
|
|
16
|
+
TreeCompressionStrategy,
|
|
17
|
+
configuredSharedTree,
|
|
18
|
+
typeboxValidator,
|
|
19
|
+
} from "@fluid-framework/alpha";
|
|
20
|
+
// Maximum debuggability and validation enabled:
|
|
21
|
+
const SharedTree = configuredSharedTree({
|
|
22
|
+
forest: ForestType.Expensive,
|
|
23
|
+
jsonValidator: typeboxValidator,
|
|
24
|
+
treeEncodeType: TreeCompressionStrategy.Uncompressed,
|
|
25
|
+
});
|
|
26
|
+
// Opts into the under development optimized tree storage planned to be the eventual default implementation:
|
|
27
|
+
const SharedTree = configuredSharedTree({
|
|
28
|
+
forest: ForestType.Optimized,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- ✨ New! Alpha API for snapshotting Schema ([#22733](https://github.com/microsoft/FluidFramework/pull/22733)) [920a65f66e](https://github.com/microsoft/FluidFramework/commit/920a65f66e0caad7e1b5e3df1e0afd3475a87c4a)
|
|
33
|
+
|
|
34
|
+
`extractPersistedSchema` can now be used to extra a JSON-compatible representation of the subset of a schema that gets stored in documents.
|
|
35
|
+
This can be used write tests which snapshot an applications schema.
|
|
36
|
+
Such tests can be used to detect schema changes which could would impact document compatibility,
|
|
37
|
+
and can be combined with the new `comparePersistedSchema` to measure what kind of compatibility impact the schema change has.
|
|
38
|
+
|
|
39
|
+
- Fix reading of `null` from unhydrated trees ([#22748](https://github.com/microsoft/FluidFramework/pull/22748)) [6a75bd0616](https://github.com/microsoft/FluidFramework/commit/6a75bd0616ecd315ae0e9458d88ba1c755dfd785)
|
|
40
|
+
|
|
41
|
+
Unhydrated trees containing object nodes with required fields set to `null` used to throw an error.
|
|
42
|
+
This was a bug: `null` is a valid value in tree's whose schema allow it, and this specific case now correctly returns `null` values when appropriate without erroring.
|
|
43
|
+
|
|
44
|
+
- Expose the view schema from the TreeView interface ([#22547](https://github.com/microsoft/FluidFramework/pull/22547)) [2aa29d9a13](https://github.com/microsoft/FluidFramework/commit/2aa29d9a13f099b129ec6834c8cbdaf6a25db114)
|
|
45
|
+
|
|
46
|
+
Users of TreeView can now access the type-safe view schema directly on the view object via `TreeView.schema`.
|
|
47
|
+
This allows users to avoid passing the schema around in addition to the view in scenarios where both are needed.
|
|
48
|
+
It also avoids scenarios in which code wants to accept both a view and its schema and thus must constrain both to be of the same schema type.
|
|
49
|
+
|
|
50
|
+
- Metadata can now be associated with Field Schema ([#22564](https://github.com/microsoft/FluidFramework/pull/22564)) [1d9f4c97ed](https://github.com/microsoft/FluidFramework/commit/1d9f4c97edf3f2bbf23ca30c35b67f0ec38b728d)
|
|
51
|
+
|
|
52
|
+
Users of TreeView can now specify metadata when creating Field Schema.
|
|
53
|
+
This includes system-understood metadata, i.e., `description`.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
class Point extends schemaFactory.object("Point", {
|
|
59
|
+
x: schemaFactory.required(schemaFactory.number, {
|
|
60
|
+
metadata: { description: "The horizontal component of the point." },
|
|
61
|
+
}),
|
|
62
|
+
y: schemaFactory.required(schemaFactory.number, {
|
|
63
|
+
metadata: { description: "The vertical component of the point." },
|
|
64
|
+
}),
|
|
65
|
+
}) {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Functionality like the experimental conversion of Tree Schema to [JSON Schema](https://json-schema.org/) (`getJsonSchema`) can leverage such system-understood metadata to generate useful information.
|
|
69
|
+
In the case of the `description` property, this is mapped directly to the `description` property supported by JSON Schema.
|
|
70
|
+
|
|
71
|
+
Custom, user-defined properties can also be specified.
|
|
72
|
+
These properties will not be leveraged by the system by default, but can be used as a handy means of associating common application-specific properties with Field Schema.
|
|
73
|
+
|
|
74
|
+
Example:
|
|
75
|
+
|
|
76
|
+
An application is implementing search functionality.
|
|
77
|
+
By default, the app author wishes for all app content to be indexable by search, unless otherwise specified.
|
|
78
|
+
They can leverage schema metadata to decorate fields that should be ignored by search, and leverage that information when walking the tree during a search.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
|
|
82
|
+
interface AppMetadata {
|
|
83
|
+
/**
|
|
84
|
+
* Whether or not the field should be ignored by search.
|
|
85
|
+
* @defaultValue `false`
|
|
86
|
+
*/
|
|
87
|
+
searchIgnore?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class Note extends schemaFactory.object("Note", {
|
|
91
|
+
position: schemaFactory.required(Point, {
|
|
92
|
+
metadata: {
|
|
93
|
+
description: "The position of the upper-left corner of the note."
|
|
94
|
+
custom: {
|
|
95
|
+
// Search doesn't care where the note is on the canvas.
|
|
96
|
+
// It only cares about the text content.
|
|
97
|
+
searchIgnore: true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
text: schemaFactory.required(schemaFactory.string, {
|
|
102
|
+
metadata: {
|
|
103
|
+
description: "The textual contents of the note."
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
}) {}
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Search can then be implemented to look for the appropriate metadata, and leverage it to omit the unwanted position data from search.
|
|
111
|
+
|
|
112
|
+
- ✨ New! Alpha SharedTree branching APIs ([#22550](https://github.com/microsoft/FluidFramework/pull/22550)) [8f4587c912](https://github.com/microsoft/FluidFramework/commit/8f4587c912f955c405d7bbbc5b42f3ffc3b497d7)
|
|
113
|
+
|
|
114
|
+
Several APIs have been added to allow for creating and coordinating "version-control"-style branches of the SharedTree.
|
|
115
|
+
Use the `getBranch` entry point function to acquire a branch.
|
|
116
|
+
For example:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
function makeEditOnBranch(mainView: TreeView<typeof MySchema>) {
|
|
120
|
+
mainView.root.myData = 3;
|
|
121
|
+
const mainBranch = getBranch(mainView); // This function accepts either a view of a SharedTree (acquired e.g. via `sharedTree.viewWith(...)`) or a `SharedTree` directly.
|
|
122
|
+
const forkBranch = mainBranch.branch(); // This creates a new branch based on the existing branch.
|
|
123
|
+
const forkView = forkBranch.viewWith(new TreeViewConfiguration({ schema: MySchema })); // Acquire a view of the forked branch in order to read or edit its tree.
|
|
124
|
+
forkView.root.myData = 4; // Set the value on the fork branch to be 4. The main branch still has a value of 3.
|
|
125
|
+
mainBranch.merge(forkBranch); // Merging the fork changes into the main branch causes the main branch to have a value of 4.
|
|
126
|
+
|
|
127
|
+
// Note: The main branch (and therefore, also the `forkView`) is automatically disposed by the merge.
|
|
128
|
+
// To prevent this, use `mainBranch.merge(forkBranch, false)`.
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Merging any number of commits into a target branch (via the `TreeBranch.merge` method) generates a revertible for each
|
|
133
|
+
commit on the target branch. See [#22644](https://github.com/microsoft/FluidFramework/pull/22644) for more information
|
|
134
|
+
about revertible support in the branching APIs.
|
|
135
|
+
|
|
136
|
+
- Unhydrated SharedTree nodes now emit change events when edited ([#22661](https://github.com/microsoft/FluidFramework/pull/22661)) [d1eade6547](https://github.com/microsoft/FluidFramework/commit/d1eade65477a4e7fb1f8062cb83dfa03a8b1d800)
|
|
137
|
+
|
|
138
|
+
Newly-created SharedTree nodes which have not yet been inserted into the tree will now emit `nodeChanged` and `treeChanged` events when they are mutated via editing operations.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const node = new Foo({ foo: 3 });
|
|
142
|
+
Tree.on(node, "nodeChanged", () => {
|
|
143
|
+
console.log("This will fire even before node is inserted!");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
node.foo = 4; // log: "This will fire even before node is inserted!";
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- SharedTree's `RestrictiveReadonlyRecord` is deprecated ([#22479](https://github.com/microsoft/FluidFramework/pull/22479)) [8be73d374d](https://github.com/microsoft/FluidFramework/commit/8be73d374de04ff6226c531ba8b562561572640f)
|
|
150
|
+
|
|
151
|
+
`RestrictiveReadonlyRecord` was an attempt to implement a version of TypeScript's built-in `Record<TKey, TValue>` type that would prohibit (instead of leaving unrestricted like Record does) values under keys that do not extend `TKey`.
|
|
152
|
+
|
|
153
|
+
The implementation of `RestrictiveReadonlyRecord` failed to accomplish this except for the edge cases where `TKey` was exactly `string` or exactly `symbol`.
|
|
154
|
+
Fixing this bug appears to be impossible within the current limitation of TypeScript, however this library does not require any case other than `TKey` being exactly `string`.
|
|
155
|
+
|
|
156
|
+
To reduce the risk of users of the tree library using the problematic `RestrictiveReadonlyRecord` type, it has been deprecated and replaced with a more specific type that avoids the bug, `RestrictiveStringRecord<TValue>`.
|
|
157
|
+
|
|
158
|
+
To highlight that this new type is not intended for direct use by users of tree, and instead is just used as part of the typing of its public API, `RestrictiveStringRecord` has been tagged with `@system`.
|
|
159
|
+
See [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels) for more details.
|
|
160
|
+
|
|
161
|
+
- Fix `.create` on structurally named MapNode and ArrayNode schema ([#22522](https://github.com/microsoft/FluidFramework/pull/22522)) [b3f91ae91c](https://github.com/microsoft/FluidFramework/commit/b3f91ae91cb750a6a7696ab5ea17c00895bb6d92)
|
|
162
|
+
|
|
163
|
+
Constructing a structurally named MapNode or ArrayNode schema (using the overload of `SchemaFactory.map` or `SchemaFactory.array` which does not take an explicit name), returned a `TreeNodeSchema` instead of a `TreeNodeSchemaNonClass`, which resulted in the `create` static method not being exposed.
|
|
164
|
+
This has been fixed, and can now be used as follows:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const MyMap = schemaFactory.map(schemaFactory.number);
|
|
168
|
+
type MyMap = NodeFromSchema<typeof MyMap>;
|
|
169
|
+
const _fromMap: MyMap = MyMap.create(new MyMap());
|
|
170
|
+
const _fromIterable: MyMap = MyMap.create([]);
|
|
171
|
+
const _fromObject: MyMap = MyMap.create({});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This change causes some types to reference `TreeNodeSchemaNonClass` which did not reference it before.
|
|
175
|
+
While `TreeNodeSchemaNonClass` is `@system` (See [Fluid Releases and API Support Levels
|
|
176
|
+
](https://fluidframework.com/docs/build/releases-and-apitags/) for details) and thus not intended to be referred to by users of Fluid,
|
|
177
|
+
this change caused the TypeScript compiler to generate references to it in more cases when compiling `d.ts` files.
|
|
178
|
+
Since the TypeScript compiler is unable to generate references to `TreeNodeSchemaNonClass` with how it was nested in `internalTypes.js`,
|
|
179
|
+
this change could break the build of packages exporting types referencing structurally named map and array schema.
|
|
180
|
+
This has been mitigated by moving `TreeNodeSchemaNonClass` out of `internalTypes.js`:
|
|
181
|
+
any code importing `TreeNodeSchemaNonClass` (and thus disregarding the `@system` restriction) can be fixed by importing it from the top level instead of the `internalTypes.js`
|
|
182
|
+
|
|
183
|
+
- Non-leaf field access has been optimized ([#22717](https://github.com/microsoft/FluidFramework/pull/22717)) [6a2b68103c](https://github.com/microsoft/FluidFramework/commit/6a2b68103cc3ad56a9ac0dfcaaa8546978ec29ac)
|
|
184
|
+
|
|
185
|
+
When reading non-leaf children which have been read previously, they are retrieved from cache faster.
|
|
186
|
+
Several operations on subtrees under arrays have been optimized, including reading of non-leaf nodes for the first time.
|
|
187
|
+
Overall this showed a roughly 5% speed up in a read heavy test application (the BubbleBench example) but gains are expected to vary a lot based on use-case.
|
|
188
|
+
|
|
189
|
+
- ✨ New! Alpha APIs for producing SharedTree schema from enums ([#20035](https://github.com/microsoft/FluidFramework/pull/20035)) [5f9bbe011a](https://github.com/microsoft/FluidFramework/commit/5f9bbe011a18ccac08a70340f6d20e60ce30c4a4)
|
|
190
|
+
|
|
191
|
+
`adaptEnum` and `enumFromStrings` have been added to `@fluidframework/tree/alpha` and `fluid-framework/alpha`.
|
|
192
|
+
These unstable alpha APIs are relatively simple helpers on-top of public APIs (source: [schemaCreationUtilities.ts](https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/simple-tree/schemaCreationUtilities.ts)):
|
|
193
|
+
thus if these change or stable alternatives are needed, an application can replicate this functionality using these implementations as an example.
|
|
194
|
+
|
|
3
195
|
## 2.3.0
|
|
4
196
|
|
|
5
197
|
### Minor Changes
|
|
@@ -583,7 +583,8 @@ export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAl
|
|
|
583
583
|
|
|
584
584
|
// @beta @sealed
|
|
585
585
|
export const TreeBeta: {
|
|
586
|
-
|
|
586
|
+
on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(node: TNode, eventName: K, listener: NoInfer<TreeChangeEventsBeta<TNode>[K]>): () => void;
|
|
587
|
+
clone<TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
|
|
587
588
|
};
|
|
588
589
|
|
|
589
590
|
// @alpha @sealed
|
|
@@ -421,7 +421,8 @@ export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAl
|
|
|
421
421
|
|
|
422
422
|
// @beta @sealed
|
|
423
423
|
export const TreeBeta: {
|
|
424
|
-
|
|
424
|
+
on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(node: TNode, eventName: K, listener: NoInfer<TreeChangeEventsBeta<TNode>[K]>): () => void;
|
|
425
|
+
clone<TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
|
|
425
426
|
};
|
|
426
427
|
|
|
427
428
|
// @public @sealed
|
|
@@ -253,7 +253,7 @@ function unboxedFlexNode(context, cursor, fieldAnchor) {
|
|
|
253
253
|
let child;
|
|
254
254
|
if (anchor !== undefined) {
|
|
255
255
|
const anchorNode = context.checkout.forest.anchors.locate(anchor);
|
|
256
|
-
(0, internal_1.assert)(anchorNode !== undefined,
|
|
256
|
+
(0, internal_1.assert)(anchorNode !== undefined, 0xa4c /* missing anchor */);
|
|
257
257
|
child = anchorNode.childIfAnchored(fieldAnchor.fieldKey, cursor.fieldIndex);
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyField.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,kDAc6B;AAC7B,kDAAuE;AACvE,yDAKoC;AAIpC,yDAY4B;AAC5B,mDAOyB;AACzB,+CAA4D;AAC5D,iDAAuE;AACvE,0DAAkF;AAElF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAwD,IAAI,OAAO,EAAE,CAAC;AAEtF,SAAgB,SAAS,CACxB,OAAgB,EAChB,MAA2B,EAC3B,MAA+B;IAE/B,MAAM,WAAW,G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CAAC,eAAe,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7E,CAAC;SAAM,CAAC;QACP,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;YAC5C,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,WAAW,CAAC,QAAQ;YACjC,WAAW,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,+BAAY,CAAC,CAAC;QAC7C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;IAED,OAAO,IAAA,sBAAQ,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC;AAlCD,0CAkCC","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\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorNode,\n\tCursorLocationType,\n\ttype ExclusiveMapTree,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\titerateCursorField,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { indexForAt, treeStatusFromAnchorCache } from \"./utilities.js\";\nimport { cursorForMapTreeField, cursorForMapTreeNode } from \"../mapTreeCursor.js\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FieldKindIdentifier,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * Base type for fields implementing {@link FlexTreeField} using cursors.\n */\nexport abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexTreeField {\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\tassert(\n\t\t\tthis.context.schemaPolicy.fieldKinds.get(kind.identifier) === kind,\n\t\t\t0xa26 /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnknownUnboxed {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor, this[anchorSymbol]),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t);\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) => makeTree(this.context, cursor));\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor, this[anchorSymbol]),\n\t\t);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (!this[isFreedSymbol]()) {\n\t\t\tif (\n\t\t\t\t// Only allow editing if we are the root document field...\n\t\t\t\t(this.parent === undefined && this[anchorSymbol].fieldKey === rootFieldKey) ||\n\t\t\t\t// ...or are under a node in the document\n\t\t\t\t(this.parent !== undefined &&\n\t\t\t\t\ttreeStatusFromAnchorCache(this.parent.anchorNode) === TreeStatus.InDocument)\n\t\t\t) {\n\t\t\t\treturn this.getFieldPath();\n\t\t\t}\n\t\t}\n\n\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t}\n}\n\nexport class LazySequence extends LazyField implements FlexTreeSequenceField {\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn this.atIndex(finalIndex);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnknownUnboxed[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic editor: SequenceFieldEditBuilder<ExclusiveMapTree[]> = {\n\t\tinsert: (index, newContent) => {\n\t\t\tthis.sequenceEditor().insert(index, cursorForMapTreeField(newContent));\n\t\t},\n\t\tremove: (index, count) => {\n\t\t\tthis.sequenceEditor().remove(index, count);\n\t\t},\n\t};\n\n\tprivate sequenceEditor(): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\treturn this.context.checkout.editor.sequenceField(fieldPath);\n\t}\n}\n\nexport class ReadonlyLazyValueField extends LazyField implements FlexTreeRequiredField {\n\tpublic editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tassert(false, 0xa0c /* Unexpected set of readonly field */);\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyValueField extends ReadonlyLazyValueField implements FlexTreeRequiredField {\n\tpublic override editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tthis.valueFieldEditor().set(cursorForMapTreeNode(newContent));\n\t\t},\n\t};\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyOptionalField extends LazyField implements FlexTreeOptionalField {\n\tpublic editor: OptionalFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent, wasEmpty) => {\n\t\t\tthis.optionalEditor().set(\n\t\t\t\tnewContent !== undefined ? cursorForMapTreeNode(newContent) : newContent,\n\t\t\t\twasEmpty,\n\t\t\t);\n\t\t},\n\t};\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n}\n\nexport class LazyForbiddenField extends LazyField {}\n\ntype Builder = new (\n\tcontext: Context,\n\t// Correct use of these builders requires the builder of the matching type to be used.\n\tschema: FieldKindIdentifier,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n) => LazyField;\n\nconst builderList: [FieldKindIdentifier, Builder][] = [\n\t[FieldKinds.forbidden.identifier, LazyForbiddenField],\n\t[FieldKinds.optional.identifier, LazyOptionalField],\n\t[FieldKinds.sequence.identifier, LazySequence],\n\t[FieldKinds.required.identifier, LazyValueField],\n\t[FieldKinds.identifier.identifier, LazyValueField],\n];\n\nconst kindToClass: ReadonlyMap<FieldKindIdentifier, Builder> = new Map(builderList);\n\n/**\n * Returns the flex tree node, or the value if it has one.\n */\nexport function unboxedFlexNode(\n\tcontext: Context,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n): FlexTreeUnknownUnboxed {\n\tconst value = cursor.value;\n\tif (value !== undefined) {\n\t\treturn value;\n\t}\n\n\t// Try accessing cached child node via anchors.\n\t// This avoids O(depth) related costs from makeTree in the cached case.\n\tconst anchor = fieldAnchor.parent;\n\tlet child: AnchorNode | undefined;\n\tif (anchor !== undefined) {\n\t\tconst anchorNode = context.checkout.forest.anchors.locate(anchor);\n\t\tassert(anchorNode !== undefined, \"missing anchor\");\n\t\tchild = anchorNode.childIfAnchored(fieldAnchor.fieldKey, cursor.fieldIndex);\n\t} else {\n\t\tchild = context.checkout.forest.anchors.find({\n\t\t\tparent: undefined,\n\t\t\tparentField: fieldAnchor.fieldKey,\n\t\t\tparentIndex: cursor.fieldIndex,\n\t\t});\n\t}\n\n\tif (child !== undefined) {\n\t\tconst cached = child.slots.get(flexTreeSlot);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t}\n\n\treturn makeTree(context, cursor);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lazyField.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,kDAc6B;AAC7B,kDAAuE;AACvE,yDAKoC;AAIpC,yDAY4B;AAC5B,mDAOyB;AACzB,+CAA4D;AAC5D,iDAAuE;AACvE,0DAAkF;AAElF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAwD,IAAI,OAAO,EAAE,CAAC;AAEtF,SAAgB,SAAS,CACxB,OAAgB,EAChB,MAA2B,EAC3B,MAA+B;IAE/B,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC9C,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,MAAM,iBAAiB,GAAG,GAAkB,EAAE;QAC7C,UAAU,GAAG,IAAI,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,eAAI,EAAC,8BAA8B,CAAC,CAAC,CAClF,OAAO,EACP,MAAM,EACN,MAAM,EACN,WAAW,CACX,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;IAEF,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAED,oGAAoG;IACpG,MAAM,UAAU,GACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,IAAA,eAAI,EAAC,gBAAgB,CAAC,CAAC;IAEtF,2HAA2H;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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorNode,\n\tCursorLocationType,\n\ttype ExclusiveMapTree,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\titerateCursorField,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { indexForAt, treeStatusFromAnchorCache } from \"./utilities.js\";\nimport { cursorForMapTreeField, cursorForMapTreeNode } from \"../mapTreeCursor.js\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FieldKindIdentifier,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * Base type for fields implementing {@link FlexTreeField} using cursors.\n */\nexport abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexTreeField {\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\tassert(\n\t\t\tthis.context.schemaPolicy.fieldKinds.get(kind.identifier) === kind,\n\t\t\t0xa26 /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnknownUnboxed {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor, this[anchorSymbol]),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t);\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) => makeTree(this.context, cursor));\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor, this[anchorSymbol]),\n\t\t);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (!this[isFreedSymbol]()) {\n\t\t\tif (\n\t\t\t\t// Only allow editing if we are the root document field...\n\t\t\t\t(this.parent === undefined && this[anchorSymbol].fieldKey === rootFieldKey) ||\n\t\t\t\t// ...or are under a node in the document\n\t\t\t\t(this.parent !== undefined &&\n\t\t\t\t\ttreeStatusFromAnchorCache(this.parent.anchorNode) === TreeStatus.InDocument)\n\t\t\t) {\n\t\t\t\treturn this.getFieldPath();\n\t\t\t}\n\t\t}\n\n\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t}\n}\n\nexport class LazySequence extends LazyField implements FlexTreeSequenceField {\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn this.atIndex(finalIndex);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnknownUnboxed[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic editor: SequenceFieldEditBuilder<ExclusiveMapTree[]> = {\n\t\tinsert: (index, newContent) => {\n\t\t\tthis.sequenceEditor().insert(index, cursorForMapTreeField(newContent));\n\t\t},\n\t\tremove: (index, count) => {\n\t\t\tthis.sequenceEditor().remove(index, count);\n\t\t},\n\t};\n\n\tprivate sequenceEditor(): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\treturn this.context.checkout.editor.sequenceField(fieldPath);\n\t}\n}\n\nexport class ReadonlyLazyValueField extends LazyField implements FlexTreeRequiredField {\n\tpublic editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tassert(false, 0xa0c /* Unexpected set of readonly field */);\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyValueField extends ReadonlyLazyValueField implements FlexTreeRequiredField {\n\tpublic override editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tthis.valueFieldEditor().set(cursorForMapTreeNode(newContent));\n\t\t},\n\t};\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyOptionalField extends LazyField implements FlexTreeOptionalField {\n\tpublic editor: OptionalFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent, wasEmpty) => {\n\t\t\tthis.optionalEditor().set(\n\t\t\t\tnewContent !== undefined ? cursorForMapTreeNode(newContent) : newContent,\n\t\t\t\twasEmpty,\n\t\t\t);\n\t\t},\n\t};\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n}\n\nexport class LazyForbiddenField extends LazyField {}\n\ntype Builder = new (\n\tcontext: Context,\n\t// Correct use of these builders requires the builder of the matching type to be used.\n\tschema: FieldKindIdentifier,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n) => LazyField;\n\nconst builderList: [FieldKindIdentifier, Builder][] = [\n\t[FieldKinds.forbidden.identifier, LazyForbiddenField],\n\t[FieldKinds.optional.identifier, LazyOptionalField],\n\t[FieldKinds.sequence.identifier, LazySequence],\n\t[FieldKinds.required.identifier, LazyValueField],\n\t[FieldKinds.identifier.identifier, LazyValueField],\n];\n\nconst kindToClass: ReadonlyMap<FieldKindIdentifier, Builder> = new Map(builderList);\n\n/**\n * Returns the flex tree node, or the value if it has one.\n */\nexport function unboxedFlexNode(\n\tcontext: Context,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n): FlexTreeUnknownUnboxed {\n\tconst value = cursor.value;\n\tif (value !== undefined) {\n\t\treturn value;\n\t}\n\n\t// Try accessing cached child node via anchors.\n\t// This avoids O(depth) related costs from makeTree in the cached case.\n\tconst anchor = fieldAnchor.parent;\n\tlet child: AnchorNode | undefined;\n\tif (anchor !== undefined) {\n\t\tconst anchorNode = context.checkout.forest.anchors.locate(anchor);\n\t\tassert(anchorNode !== undefined, 0xa4c /* missing anchor */);\n\t\tchild = anchorNode.childIfAnchored(fieldAnchor.fieldKey, cursor.fieldIndex);\n\t} else {\n\t\tchild = context.checkout.forest.anchors.find({\n\t\t\tparent: undefined,\n\t\t\tparentField: fieldAnchor.fieldKey,\n\t\t\tparentIndex: cursor.fieldIndex,\n\t\t});\n\t}\n\n\tif (child !== undefined) {\n\t\tconst cached = child.slots.get(flexTreeSlot);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t}\n\n\treturn makeTree(context, cursor);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularChangeFamily.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAIrB,KAAK,mBAAmB,EAGxB,KAAK,SAAS,EACd,WAAW,EAEX,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,K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,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,IAAI,GAC9D,kBAAkB;IAIrB,OAAO,CAAC,sBAAsB;IAKvB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"modularChangeFamily.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAIrB,KAAK,mBAAmB,EAGxB,KAAK,SAAS,EACd,WAAW,EAEX,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EAWX,MAAM,qBAAqB,CAAC;AAY7B,OAAO,EACN,KAAK,SAAS,EAId,MAAM,4BAA4B,CAAC;AAWpC,OAAO,EACN,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,0BAA0B,CAAC;AAGhF,OAAO,KAAK,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAGlB,cAAc,EACd,OAAO,EACP,gBAAgB,EAEhB,MAAM,EACN,UAAU,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;GAGG;AACH,qBAAa,mBACZ,YACC,YAAY,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAClD,aAAa,CAAC,gBAAgB,CAAC;aAQf,MAAM,EAAE,YAAY,CAAC,gBAAgB,EAA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AAE,CAAC,CAAC,CAElB"}
|
|
@@ -802,7 +802,7 @@ class ModularChangeFamily {
|
|
|
802
802
|
const numChildren = this.validateFieldChanges(change, node.fieldChanges, nodeId);
|
|
803
803
|
numNodes += numChildren;
|
|
804
804
|
}
|
|
805
|
-
(0, internal_1.assert)(numNodes === change.nodeChanges.size,
|
|
805
|
+
(0, internal_1.assert)(numNodes === change.nodeChanges.size, 0xa4d /* Node table contains unparented nodes */);
|
|
806
806
|
}
|
|
807
807
|
/**
|
|
808
808
|
* Asserts that each child and cross field key in each field has a correct entry in
|
|
@@ -816,14 +816,14 @@ class ModularChangeFamily {
|
|
|
816
816
|
const handler = getChangeHandler(this.fieldKinds, fieldChange.fieldKind);
|
|
817
817
|
for (const [child, _index] of handler.getNestedChanges(fieldChange.change)) {
|
|
818
818
|
const parentFieldId = getParentFieldId(change, child);
|
|
819
|
-
(0, internal_1.assert)(areEqualFieldIds(parentFieldId, fieldId),
|
|
819
|
+
(0, internal_1.assert)(areEqualFieldIds(parentFieldId, fieldId), 0xa4e /* Inconsistent node parentage */);
|
|
820
820
|
numChildren += 1;
|
|
821
821
|
}
|
|
822
822
|
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
823
823
|
const fields = getFieldsForCrossFieldKey(change, keyRange);
|
|
824
824
|
(0, internal_1.assert)(fields.length === 1 &&
|
|
825
825
|
fields[0] !== undefined &&
|
|
826
|
-
areEqualFieldIds(fields[0], fieldId),
|
|
826
|
+
areEqualFieldIds(fields[0], fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
return numChildren;
|