@fluidframework/tree 2.62.0-356644 → 2.62.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 +162 -0
- package/api-report/tree.alpha.api.md +23 -21
- package/api-report/tree.beta.api.md +15 -0
- package/api-report/tree.legacy.beta.api.md +18 -0
- package/dist/alpha.d.ts +8 -8
- package/dist/api.d.ts +17 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +24 -0
- package/dist/api.js.map +1 -0
- package/dist/beta.d.ts +5 -0
- package/dist/codec/codec.d.ts +3 -5
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +9 -2
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +0 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +1 -3
- package/dist/codec/index.js.map +1 -1
- package/dist/core/rebase/utils.js +1 -1
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +1 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/external-utilities/index.d.ts +1 -1
- package/dist/external-utilities/index.d.ts.map +1 -1
- package/dist/external-utilities/index.js +1 -2
- package/dist/external-utilities/index.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.d.ts +0 -13
- package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/dist/external-utilities/typeboxValidator.js +3 -5
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +4 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +15 -8
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.d.ts +32 -0
- package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -0
- package/dist/feature-libraries/flex-tree/observer.js +33 -0
- package/dist/feature-libraries/flex-tree/observer.js.map +1 -0
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +3 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +7 -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/index.d.ts +2 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +9 -4
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +5 -4
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +114 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +140 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +2 -2
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +9 -4
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +41 -28
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +3 -3
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV5.js +3 -3
- package/dist/shared-tree-core/editManagerCodecsV5.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV5.js +1 -1
- package/dist/shared-tree-core/messageCodecV5.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +15 -10
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +7 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +2 -0
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +7 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/treeFactory.d.ts +38 -9
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +44 -9
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +8 -8
- package/lib/api.d.ts +17 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/beta.d.ts +5 -0
- package/lib/codec/codec.d.ts +3 -5
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +8 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +0 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +0 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/rebase/utils.js +1 -1
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +2 -2
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/external-utilities/index.d.ts +1 -1
- package/lib/external-utilities/index.d.ts.map +1 -1
- package/lib/external-utilities/index.js +1 -1
- package/lib/external-utilities/index.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.d.ts +0 -13
- package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/lib/external-utilities/typeboxValidator.js +1 -3
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -0
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +15 -8
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.d.ts +32 -0
- package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -0
- package/lib/feature-libraries/flex-tree/observer.js +40 -0
- package/lib/feature-libraries/flex-tree/observer.js.map +1 -0
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +7 -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/index.d.ts +2 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +9 -4
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +6 -5
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +114 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +143 -4
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +3 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +9 -4
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +41 -28
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -3
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV5.js +3 -3
- package/lib/shared-tree-core/editManagerCodecsV5.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV5.js +1 -1
- package/lib/shared-tree-core/messageCodecV5.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +15 -10
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +7 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +2 -0
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +8 -2
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/treeFactory.d.ts +38 -9
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +41 -8
- package/lib/treeFactory.js.map +1 -1
- package/package.json +25 -25
- package/src/api.ts +30 -0
- package/src/codec/codec.ts +12 -6
- package/src/codec/index.ts +0 -1
- package/src/core/rebase/utils.ts +1 -1
- package/src/core/tree/detachedFieldIndex.ts +2 -2
- package/src/external-utilities/index.ts +1 -1
- package/src/external-utilities/typeboxValidator.ts +1 -3
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -0
- package/src/feature-libraries/flex-tree/index.ts +2 -0
- package/src/feature-libraries/flex-tree/lazyNode.ts +13 -3
- package/src/feature-libraries/flex-tree/observer.ts +64 -0
- package/src/feature-libraries/index.ts +3 -0
- package/src/index.ts +6 -4
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/sharedTree.ts +13 -6
- package/src/shared-tree/treeAlpha.ts +309 -4
- package/src/shared-tree/treeCheckout.ts +6 -3
- package/src/shared-tree-core/editManager.ts +57 -30
- package/src/shared-tree-core/editManagerCodecsCommons.ts +12 -3
- package/src/shared-tree-core/editManagerCodecsV5.ts +9 -3
- package/src/shared-tree-core/messageCodecV1ToV4.ts +5 -2
- package/src/shared-tree-core/messageCodecV5.ts +4 -1
- package/src/shared-tree-core/sharedTreeCore.ts +20 -10
- package/src/simple-tree/api/tree.ts +8 -0
- package/src/simple-tree/core/unhydratedFlexTree.ts +11 -2
- package/src/treeFactory.ts +48 -8
- package/dist/codec/noopValidator.d.ts +0 -13
- package/dist/codec/noopValidator.d.ts.map +0 -1
- package/dist/codec/noopValidator.js +0 -17
- package/dist/codec/noopValidator.js.map +0 -1
- package/docs/user-facing/schema-evolution.md +0 -309
- package/lib/codec/noopValidator.d.ts +0 -13
- package/lib/codec/noopValidator.d.ts.map +0 -1
- package/lib/codec/noopValidator.js +0 -14
- package/lib/codec/noopValidator.js.map +0 -1
- package/src/codec/noopValidator.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,167 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
+
## 2.62.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `asTreeViewAlpha` has been deprecated in favor of `asAlpha`. ([#25512](https://github.com/microsoft/FluidFramework/pull/25512)) [7f1cb9174c](https://github.com/microsoft/FluidFramework/commit/7f1cb9174c78c7888d7d7e290ea9320a746784d7)
|
|
8
|
+
|
|
9
|
+
Please replace usages with of `asTreeViewAlpha` with `asAlpha` - the function signature remains the same.
|
|
10
|
+
|
|
11
|
+
- Add configuredSharedTreeBeta ([#25531](https://github.com/microsoft/FluidFramework/pull/25531)) [1e2d48fd8c](https://github.com/microsoft/FluidFramework/commit/1e2d48fd8cf34e63310718c2ffa68bb919d8131a)
|
|
12
|
+
|
|
13
|
+
A limited subset of the options from the existing `@alpha` [`configuredSharedTree`](https://fluidframework.com/docs/api/fluid-framework#configuredsharedtree-function) API have been stabilized to `@beta` in the form of `configuredSharedTreeBeta`.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import {
|
|
17
|
+
configuredSharedTreeBeta,
|
|
18
|
+
ForestTypeExpensiveDebug,
|
|
19
|
+
} from "fluid-framework/beta";
|
|
20
|
+
const SharedTree = configuredSharedTreeBeta({
|
|
21
|
+
forest: ForestTypeExpensiveDebug,
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Remove JsonValidator ([#25381](https://github.com/microsoft/FluidFramework/pull/25381)) [64a9b88b00](https://github.com/microsoft/FluidFramework/commit/64a9b88b001aeed19311d403c7cf2ac304787d90)
|
|
26
|
+
|
|
27
|
+
The `@alpha` API `JsonValidator` has been removed: its replacement `FormatValidator` must now be used.
|
|
28
|
+
|
|
29
|
+
As part of this:
|
|
30
|
+
|
|
31
|
+
- `typeboxValidator` has been replaced with `FormatValidatorBasic`.
|
|
32
|
+
- `noopValidator` has been replaced with `FormatValidatorNoOp`.
|
|
33
|
+
|
|
34
|
+
- Added APIs for tracking observations of SharedTree content for automatic invalidation ([#25459](https://github.com/microsoft/FluidFramework/pull/25459)) [21d45d5948](https://github.com/microsoft/FluidFramework/commit/21d45d5948b961a82c77ed5154fc42e456d85ee4)
|
|
35
|
+
|
|
36
|
+
`TreeAlpha.trackObservations` and `TreeAlpha.trackObservationsOnce` have been added.
|
|
37
|
+
These provide a way to run some operation which reads content from [TreeNodes](https://fluidframework.com/docs/api/tree/treenode-class), then run a call back when anything observed by that operation changes.
|
|
38
|
+
|
|
39
|
+
This functionality has also been exposed in the form of React hooks and React higher order components via the `@fluid-experimental/tree-react-api` package.
|
|
40
|
+
It is now possible to use these utilities to implement React applications which pass TreeNodes in their props and get all necessary invalidation from tree changes handled automatically.
|
|
41
|
+
The recommended pattern for doing this is to use `treeDataObject` or `TreeViewComponent` at the root, then `withTreeObservations` or `withMemoizedTreeObservations` for any sub-components which read from TreeNodes.
|
|
42
|
+
Alternatively more localized changes can be made by using `PropNode` to type erase TreeNodes passed in props, then use one of the `usePropTreeNode` or `usePropTreeRecord` hooks to read from them.
|
|
43
|
+
|
|
44
|
+
These APIs work with both hydrated and [un-hydrated](https://fluidframework.com/docs/api/tree/unhydrated-typealias) TreeNodes.
|
|
45
|
+
|
|
46
|
+
#### React Support
|
|
47
|
+
|
|
48
|
+
Here is a simple example of a React components which has an invalidation bug due to reading a mutable field from a TreeNode that was provided in a prop:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const builder = new SchemaFactory("example");
|
|
52
|
+
class Item extends builder.object("Item", { text: SchemaFactory.string }) {}
|
|
53
|
+
const ItemComponentBug = ({ item }: { item: Item }): JSX.Element => (
|
|
54
|
+
<span>{item.text}</span> // Reading `text`, a mutable value from a React prop, causes an invalidation bug.
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This bug can now easily be fixed using `withTreeObservations` or `withMemoizedTreeObservations`:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const ItemComponent = withTreeObservations(
|
|
62
|
+
({ item }: { item: Item }): JSX.Element => <span>{item.text}</span>,
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For components which take in TreeNodes, but merely forward them and do not read their properties, they can use `PropTreeNode` as shown:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const ItemParentComponent = ({ item }: { item: PropTreeNode<Item> }): JSX.Element => (
|
|
70
|
+
<ItemComponent item={item} />
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If such a component reads from the TreeNode, it gets a compile error instead of an invalidation bug.
|
|
75
|
+
In this case the invalidation bug would be that if `item.text` is modified, the component would not re-render.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const InvalidItemParentComponent = ({
|
|
79
|
+
item,
|
|
80
|
+
}: { item: PropTreeNode<Item> }): JSX.Element => (
|
|
81
|
+
// @ts-expect-error PropTreeNode turns this invalidation bug into a compile error
|
|
82
|
+
<span>{item.text}</span>
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To provide access to TreeNode content in only part of a component the `usePropTreeNode` or `usePropTreeRecord` hooks can be used.
|
|
87
|
+
|
|
88
|
+
#### TreeAlpha.trackObservationsOnce Examples
|
|
89
|
+
|
|
90
|
+
Here is a rather minimal example of how `TreeAlpha.trackObservationsOnce` can be used:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
cachedFoo ??= TreeAlpha.trackObservationsOnce(
|
|
94
|
+
() => {
|
|
95
|
+
cachedFoo = undefined;
|
|
96
|
+
},
|
|
97
|
+
() => nodeA.someChild.bar + nodeB.someChild.baz,
|
|
98
|
+
).result;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
That is equivalent to doing the following:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
if (cachedFoo === undefined) {
|
|
105
|
+
cachedFoo = nodeA.someChild.bar + nodeB.someChild.baz;
|
|
106
|
+
const invalidate = (): void => {
|
|
107
|
+
cachedFoo = undefined;
|
|
108
|
+
for (const u of unsubscribe) {
|
|
109
|
+
u();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const unsubscribe: (() => void)[] = [
|
|
113
|
+
TreeBeta.on(nodeA, "nodeChanged", (data) => {
|
|
114
|
+
if (data.changedProperties.has("someChild")) {
|
|
115
|
+
invalidate();
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
TreeBeta.on(nodeB, "nodeChanged", (data) => {
|
|
119
|
+
if (data.changedProperties.has("someChild")) {
|
|
120
|
+
invalidate();
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
TreeBeta.on(nodeA.someChild, "nodeChanged", (data) => {
|
|
124
|
+
if (data.changedProperties.has("bar")) {
|
|
125
|
+
invalidate();
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
TreeBeta.on(nodeB.someChild, "nodeChanged", (data) => {
|
|
129
|
+
if (data.changedProperties.has("baz")) {
|
|
130
|
+
invalidate();
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Here is more complete example showing how to use `TreeAlpha.trackObservationsOnce` invalidate a property derived from its tree fields.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const factory = new SchemaFactory("com.example");
|
|
141
|
+
class Vector extends factory.object("Vector", {
|
|
142
|
+
x: SchemaFactory.number,
|
|
143
|
+
y: SchemaFactory.number,
|
|
144
|
+
}) {
|
|
145
|
+
#length: number | undefined = undefined;
|
|
146
|
+
public length(): number {
|
|
147
|
+
if (this.#length === undefined) {
|
|
148
|
+
const result = TreeAlpha.trackObservationsOnce(
|
|
149
|
+
() => {
|
|
150
|
+
this.#length = undefined;
|
|
151
|
+
},
|
|
152
|
+
() => Math.hypot(this.x, this.y),
|
|
153
|
+
);
|
|
154
|
+
this.#length = result.result;
|
|
155
|
+
}
|
|
156
|
+
return this.#length;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const vec = new Vector({ x: 3, y: 4 });
|
|
160
|
+
assert.equal(vec.length(), 5);
|
|
161
|
+
vec.x = 0;
|
|
162
|
+
assert.equal(vec.length(), 4);
|
|
163
|
+
```
|
|
164
|
+
|
|
3
165
|
## 2.61.0
|
|
4
166
|
|
|
5
167
|
Dependency updates only.
|
|
@@ -79,6 +79,9 @@ export const ArrayNodeSchema: {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
// @alpha
|
|
82
|
+
export function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;
|
|
83
|
+
|
|
84
|
+
// @alpha @deprecated
|
|
82
85
|
export function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;
|
|
83
86
|
|
|
84
87
|
// @alpha @sealed
|
|
@@ -121,6 +124,9 @@ export type ConciseTree<THandle = IFluidHandle> = Exclude<TreeLeafValue, IFluidH
|
|
|
121
124
|
[key: string]: ConciseTree<THandle>;
|
|
122
125
|
};
|
|
123
126
|
|
|
127
|
+
// @beta
|
|
128
|
+
export function configuredSharedTreeBeta(options: SharedTreeOptionsBeta): SharedObjectKind<ITree>;
|
|
129
|
+
|
|
124
130
|
// @alpha
|
|
125
131
|
export function createIdentifierIndex<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): IdentifierIndex;
|
|
126
132
|
|
|
@@ -272,13 +278,13 @@ export interface ForestOptions {
|
|
|
272
278
|
export interface ForestType extends ErasedType<"ForestType"> {
|
|
273
279
|
}
|
|
274
280
|
|
|
275
|
-
// @
|
|
281
|
+
// @beta
|
|
276
282
|
export const ForestTypeExpensiveDebug: ForestType;
|
|
277
283
|
|
|
278
|
-
// @
|
|
284
|
+
// @beta
|
|
279
285
|
export const ForestTypeOptimized: ForestType;
|
|
280
286
|
|
|
281
|
-
// @
|
|
287
|
+
// @beta
|
|
282
288
|
export const ForestTypeReference: ForestType;
|
|
283
289
|
|
|
284
290
|
// @alpha @sealed
|
|
@@ -311,7 +317,7 @@ export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
|
|
|
311
317
|
|
|
312
318
|
// @alpha @input
|
|
313
319
|
export interface ICodecOptions {
|
|
314
|
-
readonly jsonValidator:
|
|
320
|
+
readonly jsonValidator: FormatValidator;
|
|
315
321
|
}
|
|
316
322
|
|
|
317
323
|
// @alpha
|
|
@@ -425,6 +431,7 @@ export interface ITreeAlpha extends ITree {
|
|
|
425
431
|
createSharedBranch(): string;
|
|
426
432
|
exportSimpleSchema(): SimpleTreeSchema;
|
|
427
433
|
exportVerbose(): VerboseTree | undefined;
|
|
434
|
+
getSharedBranchIds(): string[];
|
|
428
435
|
viewSharedBranchWith<TRoot extends ImplicitFieldSchema>(branchId: string, config: TreeViewConfiguration<TRoot>): TreeView<TRoot>;
|
|
429
436
|
}
|
|
430
437
|
|
|
@@ -548,11 +555,6 @@ export type JsonTreeSchema = JsonFieldSchema & {
|
|
|
548
555
|
readonly $defs: Record<JsonSchemaId, JsonNodeSchema>;
|
|
549
556
|
};
|
|
550
557
|
|
|
551
|
-
// @alpha @input
|
|
552
|
-
export interface JsonValidator {
|
|
553
|
-
compile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
558
|
// @alpha @input
|
|
557
559
|
export enum KeyEncodingOptions {
|
|
558
560
|
allStoredKeys = "allStoredKeys",
|
|
@@ -651,9 +653,6 @@ export interface NodeSchemaOptionsAlpha<out TCustomMetadata = unknown> extends N
|
|
|
651
653
|
readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
|
|
652
654
|
}
|
|
653
655
|
|
|
654
|
-
// @alpha
|
|
655
|
-
export const noopValidator: JsonValidator;
|
|
656
|
-
|
|
657
656
|
// @alpha @sealed
|
|
658
657
|
export interface NormalizedAnnotatedAllowedTypes extends AnnotatedAllowedTypes<TreeNodeSchema> {
|
|
659
658
|
}
|
|
@@ -673,6 +672,12 @@ export const ObjectNodeSchema: {
|
|
|
673
672
|
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ObjectNodeSchema<string, RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>, boolean, unknown>;
|
|
674
673
|
};
|
|
675
674
|
|
|
675
|
+
// @alpha @sealed
|
|
676
|
+
export interface ObservationResults<TResult> {
|
|
677
|
+
readonly result: TResult;
|
|
678
|
+
readonly unsubscribe: () => void;
|
|
679
|
+
}
|
|
680
|
+
|
|
676
681
|
// @public @deprecated
|
|
677
682
|
export type Off = Off_2;
|
|
678
683
|
|
|
@@ -906,11 +911,6 @@ export class SchemaUpgrade {
|
|
|
906
911
|
protected _typeCheck: MakeNominal;
|
|
907
912
|
}
|
|
908
913
|
|
|
909
|
-
// @alpha @input
|
|
910
|
-
export interface SchemaValidationFunction<Schema extends TSchema> {
|
|
911
|
-
check(data: unknown): data is Static<Schema>;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
914
|
// @public @system
|
|
915
915
|
type ScopedSchemaName<TScope extends string | undefined, TName extends number | string> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
|
|
916
916
|
|
|
@@ -933,7 +933,10 @@ export const SharedTreeFormatVersion: {
|
|
|
933
933
|
export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
|
|
934
934
|
|
|
935
935
|
// @alpha @input
|
|
936
|
-
export type SharedTreeOptions = Partial<CodecWriteOptions> & Partial<SharedTreeFormatOptions> &
|
|
936
|
+
export type SharedTreeOptions = Partial<CodecWriteOptions> & Partial<SharedTreeFormatOptions> & SharedTreeOptionsBeta;
|
|
937
|
+
|
|
938
|
+
// @beta @input
|
|
939
|
+
export type SharedTreeOptionsBeta = ForestOptions;
|
|
937
940
|
|
|
938
941
|
// @alpha @sealed
|
|
939
942
|
export interface SimpleArrayNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Array, TCustomMetadata> {
|
|
@@ -1296,6 +1299,8 @@ export interface TreeAlpha {
|
|
|
1296
1299
|
importConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: ConciseTree | undefined): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
|
|
1297
1300
|
importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: TreeParsingOptions): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
1298
1301
|
key2(node: TreeNode): string | number | undefined;
|
|
1302
|
+
trackObservations<TResult>(onInvalidation: () => void, trackDuring: () => TResult): ObservationResults<TResult>;
|
|
1303
|
+
trackObservationsOnce<TResult>(onInvalidation: () => void, trackDuring: () => TResult): ObservationResults<TResult>;
|
|
1299
1304
|
}
|
|
1300
1305
|
|
|
1301
1306
|
// @alpha
|
|
@@ -1561,9 +1566,6 @@ export interface TreeViewEvents {
|
|
|
1561
1566
|
schemaChanged(): void;
|
|
1562
1567
|
}
|
|
1563
1568
|
|
|
1564
|
-
// @alpha
|
|
1565
|
-
export const typeboxValidator: JsonValidator;
|
|
1566
|
-
|
|
1567
1569
|
// @public @deprecated @system
|
|
1568
1570
|
const typeNameSymbol: unique symbol;
|
|
1569
1571
|
|
|
@@ -43,6 +43,9 @@ export interface CommitMetadata {
|
|
|
43
43
|
readonly kind: CommitKind;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// @beta
|
|
47
|
+
export function configuredSharedTreeBeta(options: SharedTreeOptionsBeta): SharedObjectKind<ITree>;
|
|
48
|
+
|
|
46
49
|
// @public @sealed @system
|
|
47
50
|
interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
|
|
48
51
|
}
|
|
@@ -121,6 +124,15 @@ export interface ForestOptions {
|
|
|
121
124
|
export interface ForestType extends ErasedType<"ForestType"> {
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
// @beta
|
|
128
|
+
export const ForestTypeExpensiveDebug: ForestType;
|
|
129
|
+
|
|
130
|
+
// @beta
|
|
131
|
+
export const ForestTypeOptimized: ForestType;
|
|
132
|
+
|
|
133
|
+
// @beta
|
|
134
|
+
export const ForestTypeReference: ForestType;
|
|
135
|
+
|
|
124
136
|
// @public
|
|
125
137
|
export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
126
138
|
|
|
@@ -395,6 +407,9 @@ export interface SchemaStatics {
|
|
|
395
407
|
// @public @system
|
|
396
408
|
type ScopedSchemaName<TScope extends string | undefined, TName extends number | string> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
|
|
397
409
|
|
|
410
|
+
// @beta @input
|
|
411
|
+
export type SharedTreeOptionsBeta = ForestOptions;
|
|
412
|
+
|
|
398
413
|
// @public @sealed @system
|
|
399
414
|
export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
|
|
400
415
|
readonly kind: TNodeKind;
|
|
@@ -43,6 +43,12 @@ export interface CommitMetadata {
|
|
|
43
43
|
readonly kind: CommitKind;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// @beta
|
|
47
|
+
export function configuredSharedTreeBeta(options: SharedTreeOptionsBeta): SharedObjectKind<ITree>;
|
|
48
|
+
|
|
49
|
+
// @beta @legacy
|
|
50
|
+
export function configuredSharedTreeBetaLegacy(options: SharedTreeOptionsBeta): ISharedObjectKind<ITree> & SharedObjectKind<ITree>;
|
|
51
|
+
|
|
46
52
|
// @public @sealed @system
|
|
47
53
|
interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
|
|
48
54
|
}
|
|
@@ -121,6 +127,15 @@ export interface ForestOptions {
|
|
|
121
127
|
export interface ForestType extends ErasedType<"ForestType"> {
|
|
122
128
|
}
|
|
123
129
|
|
|
130
|
+
// @beta
|
|
131
|
+
export const ForestTypeExpensiveDebug: ForestType;
|
|
132
|
+
|
|
133
|
+
// @beta
|
|
134
|
+
export const ForestTypeOptimized: ForestType;
|
|
135
|
+
|
|
136
|
+
// @beta
|
|
137
|
+
export const ForestTypeReference: ForestType;
|
|
138
|
+
|
|
124
139
|
// @public
|
|
125
140
|
export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
|
|
126
141
|
|
|
@@ -404,6 +419,9 @@ export const SharedTreeAttributes: IChannelAttributes;
|
|
|
404
419
|
// @beta @legacy
|
|
405
420
|
export const SharedTreeFactoryType = "https://graph.microsoft.com/types/tree";
|
|
406
421
|
|
|
422
|
+
// @beta @input
|
|
423
|
+
export type SharedTreeOptionsBeta = ForestOptions;
|
|
424
|
+
|
|
407
425
|
// @public @sealed @system
|
|
408
426
|
export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
|
|
409
427
|
readonly kind: TNodeKind;
|
package/dist/alpha.d.ts
CHANGED
|
@@ -94,13 +94,18 @@ export {
|
|
|
94
94
|
// #region @beta APIs
|
|
95
95
|
ForestOptions,
|
|
96
96
|
ForestType,
|
|
97
|
+
ForestTypeExpensiveDebug,
|
|
98
|
+
ForestTypeOptimized,
|
|
99
|
+
ForestTypeReference,
|
|
97
100
|
NodeChangedData,
|
|
98
101
|
PopUnion,
|
|
99
102
|
SchemaFactoryBeta,
|
|
103
|
+
SharedTreeOptionsBeta,
|
|
100
104
|
TreeBeta,
|
|
101
105
|
TreeChangeEventsBeta,
|
|
102
106
|
UnionToTuple,
|
|
103
107
|
adaptEnum,
|
|
108
|
+
configuredSharedTreeBeta,
|
|
104
109
|
enumFromStrings,
|
|
105
110
|
singletonSchema,
|
|
106
111
|
// #endregion
|
|
@@ -126,9 +131,6 @@ export {
|
|
|
126
131
|
FieldSchemaAlphaUnsafe,
|
|
127
132
|
FixRecursiveArraySchema,
|
|
128
133
|
FluidClientVersion,
|
|
129
|
-
ForestTypeExpensiveDebug,
|
|
130
|
-
ForestTypeOptimized,
|
|
131
|
-
ForestTypeReference,
|
|
132
134
|
FormatValidator,
|
|
133
135
|
FormatValidatorBasic,
|
|
134
136
|
FormatValidatorNoOp,
|
|
@@ -162,7 +164,6 @@ export {
|
|
|
162
164
|
JsonSchemaType,
|
|
163
165
|
JsonStringKeyPatternProperties,
|
|
164
166
|
JsonTreeSchema,
|
|
165
|
-
JsonValidator,
|
|
166
167
|
KeyEncodingOptions,
|
|
167
168
|
MapNodeCustomizableSchema,
|
|
168
169
|
MapNodeCustomizableSchemaUnsafe,
|
|
@@ -171,6 +172,7 @@ export {
|
|
|
171
172
|
NodeSchemaOptionsAlpha,
|
|
172
173
|
NormalizedAnnotatedAllowedTypes,
|
|
173
174
|
ObjectNodeSchema,
|
|
175
|
+
ObservationResults,
|
|
174
176
|
ReadSchema,
|
|
175
177
|
ReadableField,
|
|
176
178
|
RecordNodeCustomizableSchema,
|
|
@@ -184,7 +186,6 @@ export {
|
|
|
184
186
|
SchemaFactoryObjectOptions,
|
|
185
187
|
SchemaStaticsAlpha,
|
|
186
188
|
SchemaUpgrade,
|
|
187
|
-
SchemaValidationFunction,
|
|
188
189
|
SharedTreeFormatOptions,
|
|
189
190
|
SharedTreeFormatVersion,
|
|
190
191
|
SharedTreeOptions,
|
|
@@ -236,6 +237,7 @@ export {
|
|
|
236
237
|
ViewContent,
|
|
237
238
|
VoidTransactionCallbackStatus,
|
|
238
239
|
allowUnused,
|
|
240
|
+
asAlpha,
|
|
239
241
|
asTreeViewAlpha,
|
|
240
242
|
cloneWithReplacements,
|
|
241
243
|
comparePersistedSchema,
|
|
@@ -249,12 +251,10 @@ export {
|
|
|
249
251
|
getSimpleSchema,
|
|
250
252
|
independentInitializedView,
|
|
251
253
|
independentView,
|
|
252
|
-
noopValidator,
|
|
253
254
|
persistedToSimpleSchema,
|
|
254
255
|
replaceConciseTreeHandles,
|
|
255
256
|
replaceHandles,
|
|
256
257
|
replaceVerboseTreeHandles,
|
|
257
|
-
trackDirtyNodes
|
|
258
|
-
typeboxValidator
|
|
258
|
+
trackDirtyNodes
|
|
259
259
|
// #endregion
|
|
260
260
|
} from "./index.js";
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type TreeView, type TreeViewAlpha, type ImplicitFieldSchema } from "./simple-tree/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Module entry points for retrieving alternate (alpha/beta) versions of tree APIs.
|
|
8
|
+
* For each API (usually a class) that has an alpha/beta version, add overloads to the function(s) below.
|
|
9
|
+
* In the future, `asBeta` may be added here too.
|
|
10
|
+
* These functions should only be used by external consumers, not referenced internally within the tree package, to avoid circular import dependencies.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.
|
|
14
|
+
* @alpha
|
|
15
|
+
*/
|
|
16
|
+
export declare function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;
|
|
17
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAGxB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,mBAAmB,EAC1D,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GACrB,aAAa,CAAC,OAAO,CAAC,CAGxB"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.asAlpha = void 0;
|
|
8
|
+
const index_js_1 = require("./simple-tree/index.js");
|
|
9
|
+
/**
|
|
10
|
+
* Module entry points for retrieving alternate (alpha/beta) versions of tree APIs.
|
|
11
|
+
* For each API (usually a class) that has an alpha/beta version, add overloads to the function(s) below.
|
|
12
|
+
* In the future, `asBeta` may be added here too.
|
|
13
|
+
* These functions should only be used by external consumers, not referenced internally within the tree package, to avoid circular import dependencies.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
function asAlpha(view) {
|
|
20
|
+
// eslint-disable-next-line import/no-deprecated
|
|
21
|
+
return (0, index_js_1.asTreeViewAlpha)(view);
|
|
22
|
+
}
|
|
23
|
+
exports.asAlpha = asAlpha;
|
|
24
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAMgC;AAEhC;;;;;GAKG;AAEH;;;GAGG;AACH,SAAgB,OAAO,CACtB,IAAuB;IAEvB,gDAAgD;IAChD,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AALD,0BAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype TreeView,\n\ttype TreeViewAlpha,\n\ttype ImplicitFieldSchema,\n\t// eslint-disable-next-line import/no-deprecated\n\tasTreeViewAlpha,\n} from \"./simple-tree/index.js\";\n\n/**\n * Module entry points for retrieving alternate (alpha/beta) versions of tree APIs.\n * For each API (usually a class) that has an alpha/beta version, add overloads to the function(s) below.\n * In the future, `asBeta` may be added here too.\n * These functions should only be used by external consumers, not referenced internally within the tree package, to avoid circular import dependencies.\n */\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n */\nexport function asAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\t// eslint-disable-next-line import/no-deprecated\n\treturn asTreeViewAlpha(view);\n}\n"]}
|
package/dist/beta.d.ts
CHANGED
|
@@ -94,13 +94,18 @@ export {
|
|
|
94
94
|
// #region @beta APIs
|
|
95
95
|
ForestOptions,
|
|
96
96
|
ForestType,
|
|
97
|
+
ForestTypeExpensiveDebug,
|
|
98
|
+
ForestTypeOptimized,
|
|
99
|
+
ForestTypeReference,
|
|
97
100
|
NodeChangedData,
|
|
98
101
|
PopUnion,
|
|
99
102
|
SchemaFactoryBeta,
|
|
103
|
+
SharedTreeOptionsBeta,
|
|
100
104
|
TreeBeta,
|
|
101
105
|
TreeChangeEventsBeta,
|
|
102
106
|
UnionToTuple,
|
|
103
107
|
adaptEnum,
|
|
108
|
+
configuredSharedTreeBeta,
|
|
104
109
|
enumFromStrings,
|
|
105
110
|
singletonSchema
|
|
106
111
|
// #endregion
|
package/dist/codec/codec.d.ts
CHANGED
|
@@ -30,7 +30,6 @@ export interface IDecoder<TDecoded, TEncoded, TContext> {
|
|
|
30
30
|
/**
|
|
31
31
|
* Validates data complies with some particular schema.
|
|
32
32
|
* Implementations are typically created by a {@link JsonValidator}.
|
|
33
|
-
* @alpha @input
|
|
34
33
|
*/
|
|
35
34
|
export interface SchemaValidationFunction<Schema extends TSchema> {
|
|
36
35
|
/**
|
|
@@ -106,11 +105,10 @@ export interface ICodecOptions {
|
|
|
106
105
|
* SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)
|
|
107
106
|
* whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,
|
|
108
107
|
* which reduces the risk of unrecoverable data corruption.
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* it is recommended to use {@link FormatValidator} instead.
|
|
108
|
+
* @privateRemarks
|
|
109
|
+
* This property should probably be renamed to `validator` before stabilizing the API.
|
|
112
110
|
*/
|
|
113
|
-
readonly jsonValidator:
|
|
111
|
+
readonly jsonValidator: FormatValidator;
|
|
114
112
|
}
|
|
115
113
|
/**
|
|
116
114
|
* Options relating to encoding of persisted data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"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EAAE,sBAAsB,EAAE,sBAAsB,EAAE,QAAQ,CAAC,CAEvF;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,CACxC,CAAC,EACD,sBAAsB,EACtB,sBAAsB,EACtB,OAAO,CAUP,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,eAAe,EACf,aAAa,SAAS,OAAO,EAC7B,cAAc,GAAG,sBAAsB,EACvC,SAAS,GAAG,cAAc,EAC1B,QAAQ,GAAG,qBAAqB,EAEhC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,CAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,EACvE,SAAS,CAAC,EAAE,aAAa,GAAG,eAAe,GACzC,UAAU,CAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAqBlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,oBAAY,kBAAkB;IAC7B;;;;;;OAMG;IAGH,4CAA4C;IAC5C,IAAI,IAAM;IAEV,4CAA4C;IAM5C,6CAA6C;IAG7C,KAAK,QAAQ;IAEb;;;;;;;;OAQG;IACH,sBAAiD;CACjD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,kBAA4C,CAAC"}
|
package/dist/codec/codec.js
CHANGED
|
@@ -7,12 +7,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.ensureBinaryEncoding = exports.withDefaultBinaryEncoding = exports.makeCodecFamily = exports.extractJsonValidator = exports.toFormatValidator = exports.FormatValidatorNoOp = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.
|
|
12
|
+
* @privateRemarks Having this as an option unifies opting out of validation with selection of
|
|
13
|
+
* validators, simplifying code performing validation.
|
|
14
|
+
*/
|
|
15
|
+
const noopValidator = {
|
|
16
|
+
compile: () => ({ check: (data) => true }),
|
|
17
|
+
};
|
|
11
18
|
/**
|
|
12
19
|
* A {@link FormatValidator} which does no validation.
|
|
13
20
|
* @alpha
|
|
14
21
|
*/
|
|
15
|
-
exports.FormatValidatorNoOp = toFormatValidator(
|
|
22
|
+
exports.FormatValidatorNoOp = toFormatValidator(noopValidator);
|
|
16
23
|
/**
|
|
17
24
|
* Type erase a {@link JsonValidator} to a {@link FormatValidator}.
|
|
18
25
|
*/
|