@fluidframework/tree 2.63.0-359734 → 2.63.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 +81 -0
- package/api-report/tree.alpha.api.md +42 -8
- package/dist/alpha.d.ts +7 -0
- package/dist/codec/codec.d.ts +10 -27
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +9 -28
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +6 -5
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +4 -4
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +1 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +67 -13
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +70 -35
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -8
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +23 -0
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js +15 -0
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -0
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +3 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -2
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
- 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/forest-summary/forestSummarizer.d.ts +3 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -11
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -6
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- 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 +2 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +6 -5
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +3 -3
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.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/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +2 -2
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +5 -0
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +37 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +6 -8
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +7 -9
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/tree.js +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +3 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +3 -2
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +37 -2
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +34 -14
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.js +3 -0
- package/dist/simple-tree/api/schemaStatics.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +4 -3
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +3 -3
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +2 -2
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +3 -3
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +60 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -2
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +7 -11
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +24 -47
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +1 -1
- package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +2 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +3 -3
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +6 -6
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +36 -4
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +43 -15
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +13 -4
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +7 -0
- package/lib/codec/codec.d.ts +10 -27
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +8 -27
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +6 -5
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +4 -4
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +1 -1
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +67 -13
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +68 -32
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -8
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +23 -0
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js +11 -0
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -0
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +1 -0
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -2
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
- 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/forest-summary/forestSummarizer.d.ts +3 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +3 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -11
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -6
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- 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/feature-libraries/schema-index/codec.d.ts +6 -5
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +3 -3
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.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/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +3 -3
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +5 -0
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +40 -10
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +6 -8
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +8 -10
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/tree.js +2 -2
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +4 -4
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +37 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +34 -14
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.js +3 -0
- package/lib/simple-tree/api/schemaStatics.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +4 -3
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +3 -3
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +2 -2
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +4 -4
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +60 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +7 -11
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +23 -46
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +1 -1
- package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -3
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -3
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +4 -4
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +7 -7
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +36 -4
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +45 -17
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +13 -4
- package/lib/treeFactory.js.map +1 -1
- package/package.json +21 -20
- package/src/codec/codec.ts +11 -29
- package/src/codec/versioned/codec.ts +6 -6
- package/src/core/tree/detachedFieldIndex.ts +1 -1
- package/src/core/tree/detachedFieldIndexCodecs.ts +1 -1
- package/src/feature-libraries/chunked-forest/chunkTree.ts +112 -45
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +7 -12
- package/src/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.ts +33 -0
- package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +4 -7
- package/src/feature-libraries/chunked-forest/index.ts +2 -0
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +1 -1
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +8 -12
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +3 -12
- package/src/feature-libraries/index.ts +2 -0
- package/src/feature-libraries/schema-index/codec.ts +5 -5
- package/src/index.ts +7 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +3 -0
- package/src/shared-tree/schematizingTreeView.ts +63 -8
- package/src/shared-tree/sharedTree.ts +34 -21
- package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -1
- package/src/shared-tree/tree.ts +2 -2
- package/src/shared-tree/treeAlpha.ts +6 -12
- package/src/shared-tree/treeCheckout.ts +1 -1
- package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
- package/src/simple-tree/api/index.ts +7 -0
- package/src/simple-tree/api/schemaFactoryAlpha.ts +79 -19
- package/src/simple-tree/api/schemaStatics.ts +3 -0
- package/src/simple-tree/api/storedSchema.ts +5 -4
- package/src/simple-tree/api/treeBeta.ts +2 -2
- package/src/simple-tree/api/treeNodeApi.ts +4 -4
- package/src/simple-tree/api/typesUnsafe.ts +81 -0
- package/src/simple-tree/core/TreeNodeBinding.md +14 -70
- package/src/simple-tree/core/allowedTypes.ts +4 -1
- package/src/simple-tree/core/index.ts +1 -1
- package/src/simple-tree/core/treeNodeKernel.ts +25 -59
- package/src/simple-tree/getTreeNodeForField.ts +1 -1
- package/src/simple-tree/index.ts +8 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +3 -3
- package/src/simple-tree/node-kinds/map/mapNode.ts +3 -3
- package/src/simple-tree/node-kinds/object/objectNode.ts +4 -4
- package/src/simple-tree/node-kinds/record/recordNode.ts +7 -7
- package/src/simple-tree/prepareForInsertion.ts +87 -25
- package/src/treeFactory.ts +17 -4
|
@@ -12,13 +12,17 @@ import type {
|
|
|
12
12
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
13
13
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
14
14
|
|
|
15
|
-
import { anchorSlot } from "../core/index.js";
|
|
15
|
+
import { anchorSlot, rootFieldKey } from "../core/index.js";
|
|
16
16
|
import {
|
|
17
17
|
type NodeIdentifierManager,
|
|
18
18
|
defaultSchemaPolicy,
|
|
19
19
|
cursorForMapTreeField,
|
|
20
20
|
TreeStatus,
|
|
21
21
|
Context,
|
|
22
|
+
type FlexTreeOptionalField,
|
|
23
|
+
type FlexTreeUnknownUnboxed,
|
|
24
|
+
FieldKinds,
|
|
25
|
+
type FlexTreeRequiredField,
|
|
22
26
|
} from "../feature-libraries/index.js";
|
|
23
27
|
import {
|
|
24
28
|
type ImplicitFieldSchema,
|
|
@@ -38,7 +42,7 @@ import {
|
|
|
38
42
|
type UnsafeUnknownSchema,
|
|
39
43
|
type TreeBranch,
|
|
40
44
|
type TreeBranchEvents,
|
|
41
|
-
|
|
45
|
+
getInnerNode,
|
|
42
46
|
getKernel,
|
|
43
47
|
type VoidTransactionCallbackStatus,
|
|
44
48
|
type TransactionCallbackStatus,
|
|
@@ -117,6 +121,11 @@ export class SchematizingSimpleTreeView<
|
|
|
117
121
|
*/
|
|
118
122
|
private midUpgrade = false;
|
|
119
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Hydration work deferred until Context has been created.
|
|
126
|
+
*/
|
|
127
|
+
private pendingHydration?: () => void;
|
|
128
|
+
|
|
120
129
|
private readonly rootFieldSchema: FieldSchema;
|
|
121
130
|
public readonly breaker: Breakable;
|
|
122
131
|
|
|
@@ -174,6 +183,13 @@ export class SchematizingSimpleTreeView<
|
|
|
174
183
|
|
|
175
184
|
this.runSchemaEdit(() => {
|
|
176
185
|
const schema = toInitialSchema(this.config.schema);
|
|
186
|
+
// This has to be the contextless version, since when "initialize" is called (right after this),
|
|
187
|
+
// it will do a schema change which would dispose of the current context (see inside `update`).
|
|
188
|
+
// Thus using the current context (if any) would hydrate nodes then
|
|
189
|
+
// immediately dispose them instead of having them actually be useable after initialize.
|
|
190
|
+
// For this to work,
|
|
191
|
+
// the hydration must be deferred until after the content is inserted into the tree and the final schema change is done (for required roots),
|
|
192
|
+
// but before any user event could could run.
|
|
177
193
|
const mapTree = prepareForInsertionContextless(
|
|
178
194
|
content as InsertableContent | undefined,
|
|
179
195
|
this.rootFieldSchema,
|
|
@@ -183,6 +199,25 @@ export class SchematizingSimpleTreeView<
|
|
|
183
199
|
},
|
|
184
200
|
this,
|
|
185
201
|
schema.rootFieldSchema,
|
|
202
|
+
(batches, doHydration) => {
|
|
203
|
+
assert(
|
|
204
|
+
this.pendingHydration === undefined,
|
|
205
|
+
0xc74 /* pendingHydration already set */,
|
|
206
|
+
);
|
|
207
|
+
this.pendingHydration = () => {
|
|
208
|
+
assert(
|
|
209
|
+
batches.length <= 1,
|
|
210
|
+
0xc75 /* initialize should at most one hydration batch */,
|
|
211
|
+
);
|
|
212
|
+
for (const batch of batches) {
|
|
213
|
+
doHydration(batch, {
|
|
214
|
+
parent: undefined,
|
|
215
|
+
parentField: rootFieldKey,
|
|
216
|
+
parentIndex: 0,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
},
|
|
186
221
|
);
|
|
187
222
|
|
|
188
223
|
this.checkout.transaction.start();
|
|
@@ -350,7 +385,10 @@ export class SchematizingSimpleTreeView<
|
|
|
350
385
|
// TODO: provide a better event: this.view.flexTree.on(????) and/or integrate with with the normal event code paths.
|
|
351
386
|
|
|
352
387
|
// Track what the root was before to be able to detect changes.
|
|
353
|
-
|
|
388
|
+
// This uses the flex tree root to avoid demanding the simple-tree TreeNode when it might not be hydrated yet.
|
|
389
|
+
let lastRoot: FlexTreeUnknownUnboxed | undefined = (
|
|
390
|
+
this.flexTreeContext.root as FlexTreeOptionalField
|
|
391
|
+
).content;
|
|
354
392
|
|
|
355
393
|
this.flexTreeViewUnregisterCallbacks.add(
|
|
356
394
|
this.checkout.events.on("afterBatch", () => {
|
|
@@ -359,8 +397,8 @@ export class SchematizingSimpleTreeView<
|
|
|
359
397
|
// - The rootChanged event will already be raised at the end of the current upgrade
|
|
360
398
|
// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade
|
|
361
399
|
// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)
|
|
362
|
-
if (!this.midUpgrade && lastRoot !== this.
|
|
363
|
-
lastRoot = this.
|
|
400
|
+
if (!this.midUpgrade && lastRoot !== this.flexRoot.content) {
|
|
401
|
+
lastRoot = this.flexRoot.content;
|
|
364
402
|
this.events.emit("rootChanged");
|
|
365
403
|
}
|
|
366
404
|
}),
|
|
@@ -374,6 +412,10 @@ export class SchematizingSimpleTreeView<
|
|
|
374
412
|
);
|
|
375
413
|
|
|
376
414
|
if (!this.midUpgrade) {
|
|
415
|
+
assert(
|
|
416
|
+
this.pendingHydration === undefined,
|
|
417
|
+
0xc76 /* no nodes should be pending hydration when triggering events that could access nodes */,
|
|
418
|
+
);
|
|
377
419
|
this.events.emit("schemaChanged");
|
|
378
420
|
this.events.emit("rootChanged");
|
|
379
421
|
}
|
|
@@ -386,6 +428,9 @@ export class SchematizingSimpleTreeView<
|
|
|
386
428
|
} finally {
|
|
387
429
|
this.midUpgrade = false;
|
|
388
430
|
}
|
|
431
|
+
// Ensure hydration is flushed before events run which could access nodes.
|
|
432
|
+
this.pendingHydration?.();
|
|
433
|
+
this.pendingHydration = undefined;
|
|
389
434
|
this.events.emit("schemaChanged");
|
|
390
435
|
this.events.emit("rootChanged");
|
|
391
436
|
}
|
|
@@ -426,7 +471,7 @@ export class SchematizingSimpleTreeView<
|
|
|
426
471
|
}
|
|
427
472
|
}
|
|
428
473
|
|
|
429
|
-
|
|
474
|
+
private get flexRoot(): FlexTreeOptionalField | FlexTreeRequiredField {
|
|
430
475
|
this.breaker.use();
|
|
431
476
|
if (!this.compatibility.canView) {
|
|
432
477
|
throw new UsageError(
|
|
@@ -434,7 +479,17 @@ export class SchematizingSimpleTreeView<
|
|
|
434
479
|
);
|
|
435
480
|
}
|
|
436
481
|
const view = this.getFlexTreeContext();
|
|
437
|
-
|
|
482
|
+
assert(
|
|
483
|
+
view.root.is(FieldKinds.optional) ||
|
|
484
|
+
view.root.is(FieldKinds.required) ||
|
|
485
|
+
view.root.is(FieldKinds.identifier),
|
|
486
|
+
0xc77 /* unexpected root field kind */,
|
|
487
|
+
);
|
|
488
|
+
return view.root;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
public get root(): ReadableField<TRootSchema> {
|
|
492
|
+
return tryGetTreeNodeForField(this.flexRoot) as ReadableField<TRootSchema>;
|
|
438
493
|
}
|
|
439
494
|
|
|
440
495
|
public set root(newRoot: InsertableField<TRootSchema>) {
|
|
@@ -499,7 +554,7 @@ export function addConstraintsToTransaction(
|
|
|
499
554
|
for (const constraint of constraints) {
|
|
500
555
|
switch (constraint.type) {
|
|
501
556
|
case "nodeInDocument": {
|
|
502
|
-
const node =
|
|
557
|
+
const node = getInnerNode(constraint.node);
|
|
503
558
|
const nodeStatus = getKernel(constraint.node).getStatus();
|
|
504
559
|
if (nodeStatus !== TreeStatus.InDocument) {
|
|
505
560
|
const revertText = constraintsOnRevert ? " on revert" : "";
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
type SchemaFormatVersion,
|
|
39
39
|
SchemaVersion,
|
|
40
40
|
type TreeFieldStoredSchema,
|
|
41
|
-
type TreeNodeSchemaIdentifier,
|
|
42
41
|
type TreeNodeStoredSchema,
|
|
43
42
|
type TreeStoredSchema,
|
|
44
43
|
TreeStoredSchemaRepository,
|
|
@@ -55,6 +54,7 @@ import {
|
|
|
55
54
|
TreeCompressionStrategy,
|
|
56
55
|
buildChunkedForest,
|
|
57
56
|
buildForest,
|
|
57
|
+
defaultIncrementalEncodingPolicy,
|
|
58
58
|
defaultSchemaPolicy,
|
|
59
59
|
getCodecTreeForFieldBatchFormat,
|
|
60
60
|
getCodecTreeForForestFormat,
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
makeMitigatedChangeFamily,
|
|
65
65
|
makeSchemaCodec,
|
|
66
66
|
makeTreeChunker,
|
|
67
|
+
type IncrementalEncodingPolicy,
|
|
67
68
|
type FieldBatchFormatVersion,
|
|
68
69
|
type ForestFormatVersion,
|
|
69
70
|
type TreeCompressionStrategyPrivate,
|
|
@@ -305,7 +306,13 @@ export class SharedTreeKernel
|
|
|
305
306
|
const options = { ...defaultSharedTreeOptions, ...optionsParam };
|
|
306
307
|
const codecVersions = getCodecVersions(options.formatVersion);
|
|
307
308
|
const schema = new TreeStoredSchemaRepository();
|
|
308
|
-
const forest = buildConfiguredForest(
|
|
309
|
+
const forest = buildConfiguredForest(
|
|
310
|
+
breaker,
|
|
311
|
+
options.forest,
|
|
312
|
+
schema,
|
|
313
|
+
idCompressor,
|
|
314
|
+
options.shouldEncodeIncrementally,
|
|
315
|
+
);
|
|
309
316
|
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
310
317
|
const removedRoots = makeDetachedFieldIndex(
|
|
311
318
|
"repair",
|
|
@@ -339,7 +346,7 @@ export class SharedTreeKernel
|
|
|
339
346
|
encoderContext,
|
|
340
347
|
options,
|
|
341
348
|
idCompressor,
|
|
342
|
-
options.
|
|
349
|
+
options.shouldEncodeIncrementally,
|
|
343
350
|
);
|
|
344
351
|
const removedRootsSummarizer = new DetachedFieldIndexSummarizer(removedRoots);
|
|
345
352
|
const innerChangeFamily = new SharedTreeChangeFamily(
|
|
@@ -794,16 +801,11 @@ export interface SharedTreeOptionsInternal
|
|
|
794
801
|
Partial<SharedTreeFormatOptionsInternal> {
|
|
795
802
|
disposeForksAfterTransaction?: boolean;
|
|
796
803
|
/**
|
|
797
|
-
* Returns whether a field should be incrementally encoded.
|
|
798
|
-
* @param nodeIdentifier - The identifier of the node containing the field.
|
|
799
|
-
* @param fieldKey - The key of the field to check.
|
|
804
|
+
* Returns whether a node / field should be incrementally encoded.
|
|
800
805
|
* @remarks
|
|
801
|
-
*
|
|
806
|
+
* See {@link IncrementalEncodingPolicy}.
|
|
802
807
|
*/
|
|
803
|
-
|
|
804
|
-
nodeIdentifier: TreeNodeSchemaIdentifier,
|
|
805
|
-
fieldKey: FieldKey,
|
|
806
|
-
): boolean;
|
|
808
|
+
shouldEncodeIncrementally?: IncrementalEncodingPolicy;
|
|
807
809
|
}
|
|
808
810
|
/**
|
|
809
811
|
* Configuration options for SharedTree's internal tree storage.
|
|
@@ -882,8 +884,17 @@ export const ForestTypeReference = toForestType(
|
|
|
882
884
|
* @beta
|
|
883
885
|
*/
|
|
884
886
|
export const ForestTypeOptimized = toForestType(
|
|
885
|
-
(
|
|
886
|
-
|
|
887
|
+
(
|
|
888
|
+
breaker: Breakable,
|
|
889
|
+
schema: TreeStoredSchemaSubscription,
|
|
890
|
+
idCompressor: IIdCompressor,
|
|
891
|
+
shouldEncodeIncrementally: IncrementalEncodingPolicy,
|
|
892
|
+
) =>
|
|
893
|
+
buildChunkedForest(
|
|
894
|
+
makeTreeChunker(schema, defaultSchemaPolicy, shouldEncodeIncrementally),
|
|
895
|
+
undefined,
|
|
896
|
+
idCompressor,
|
|
897
|
+
),
|
|
887
898
|
);
|
|
888
899
|
|
|
889
900
|
/**
|
|
@@ -904,6 +915,7 @@ type ForestFactory = (
|
|
|
904
915
|
breaker: Breakable,
|
|
905
916
|
schema: TreeStoredSchemaSubscription,
|
|
906
917
|
idCompressor: IIdCompressor,
|
|
918
|
+
shouldEncodeIncrementally: IncrementalEncodingPolicy,
|
|
907
919
|
) => IEditableForest;
|
|
908
920
|
|
|
909
921
|
function toForestType(factory: ForestFactory): ForestType {
|
|
@@ -918,23 +930,24 @@ export function buildConfiguredForest(
|
|
|
918
930
|
factory: ForestType,
|
|
919
931
|
schema: TreeStoredSchemaSubscription,
|
|
920
932
|
idCompressor: IIdCompressor,
|
|
933
|
+
shouldEncodeIncrementally: IncrementalEncodingPolicy,
|
|
921
934
|
): IEditableForest {
|
|
922
|
-
return (factory as unknown as ForestFactory)(
|
|
935
|
+
return (factory as unknown as ForestFactory)(
|
|
936
|
+
breaker,
|
|
937
|
+
schema,
|
|
938
|
+
idCompressor,
|
|
939
|
+
shouldEncodeIncrementally,
|
|
940
|
+
);
|
|
923
941
|
}
|
|
924
942
|
|
|
925
943
|
export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
|
|
926
944
|
jsonValidator: FormatValidatorNoOp,
|
|
927
|
-
|
|
945
|
+
minVersionForCollab: FluidClientVersion.v2_0,
|
|
928
946
|
forest: ForestTypeReference,
|
|
929
947
|
treeEncodeType: TreeCompressionStrategy.Compressed,
|
|
930
948
|
formatVersion: SharedTreeFormatVersion.v3,
|
|
931
949
|
disposeForksAfterTransaction: true,
|
|
932
|
-
|
|
933
|
-
nodeIdentifier: TreeNodeSchemaIdentifier,
|
|
934
|
-
fieldKey: FieldKey,
|
|
935
|
-
): boolean => {
|
|
936
|
-
return false;
|
|
937
|
-
},
|
|
950
|
+
shouldEncodeIncrementally: defaultIncrementalEncodingPolicy,
|
|
938
951
|
};
|
|
939
952
|
|
|
940
953
|
function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFieldSchema {
|
|
@@ -94,7 +94,7 @@ export function getCodecTreeForChangeFormat(
|
|
|
94
94
|
version: SharedTreeChangeFormatVersion,
|
|
95
95
|
): CodecTree {
|
|
96
96
|
const { modularChange, schemaChange } =
|
|
97
|
-
dependenciesForChangeFormat.get(version) ?? fail(
|
|
97
|
+
dependenciesForChangeFormat.get(version) ?? fail(0xc78 /* Unknown change format */);
|
|
98
98
|
return {
|
|
99
99
|
name: "SharedTreeChange",
|
|
100
100
|
version,
|
package/src/shared-tree/tree.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type TreeNode,
|
|
12
12
|
type TreeNodeApi,
|
|
13
13
|
type TreeView,
|
|
14
|
-
|
|
14
|
+
getInnerNode,
|
|
15
15
|
treeNodeApi,
|
|
16
16
|
rollback,
|
|
17
17
|
type TransactionConstraint,
|
|
@@ -447,7 +447,7 @@ export function runTransaction<
|
|
|
447
447
|
} else {
|
|
448
448
|
const node = treeOrNode as TNode;
|
|
449
449
|
const t = transaction as (node: TNode) => TResult | typeof rollback;
|
|
450
|
-
const context =
|
|
450
|
+
const context = getInnerNode(node).context;
|
|
451
451
|
if (context.isHydrated() === false) {
|
|
452
452
|
throw new UsageError(
|
|
453
453
|
"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.",
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
unhydratedFlexTreeFromInsertable,
|
|
45
45
|
getOrCreateNodeFromInnerNode,
|
|
46
46
|
getOrCreateNodeFromInnerUnboxedNode,
|
|
47
|
-
|
|
47
|
+
getInnerNode,
|
|
48
48
|
NodeKind,
|
|
49
49
|
tryGetTreeNodeForField,
|
|
50
50
|
isObjectNodeSchema,
|
|
@@ -331,10 +331,7 @@ export interface TreeAlpha {
|
|
|
331
331
|
*/
|
|
332
332
|
exportCompressed(
|
|
333
333
|
tree: TreeNode | TreeLeafValue,
|
|
334
|
-
options: { idCompressor?: IIdCompressor } & Pick<
|
|
335
|
-
CodecWriteOptions,
|
|
336
|
-
"oldestCompatibleClient"
|
|
337
|
-
>,
|
|
334
|
+
options: { idCompressor?: IIdCompressor } & Pick<CodecWriteOptions, "minVersionForCollab">,
|
|
338
335
|
): JsonCompatible<IFluidHandle>;
|
|
339
336
|
|
|
340
337
|
/**
|
|
@@ -812,13 +809,10 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
812
809
|
|
|
813
810
|
exportCompressed(
|
|
814
811
|
node: TreeNode | TreeLeafValue,
|
|
815
|
-
options: { idCompressor?: IIdCompressor } & Pick<
|
|
816
|
-
CodecWriteOptions,
|
|
817
|
-
"oldestCompatibleClient"
|
|
818
|
-
>,
|
|
812
|
+
options: { idCompressor?: IIdCompressor } & Pick<CodecWriteOptions, "minVersionForCollab">,
|
|
819
813
|
): JsonCompatible<IFluidHandle> {
|
|
820
814
|
const schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);
|
|
821
|
-
const format = fluidVersionToFieldBatchCodecWriteVersion(options.
|
|
815
|
+
const format = fluidVersionToFieldBatchCodecWriteVersion(options.minVersionForCollab);
|
|
822
816
|
const codec = makeFieldBatchCodec({ jsonValidator: FormatValidatorNoOp }, format);
|
|
823
817
|
const cursor = borrowFieldCursorFromTreeNodeOrValue(node);
|
|
824
818
|
const batch: FieldBatch = [cursor];
|
|
@@ -881,7 +875,7 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
881
875
|
node: TreeNode,
|
|
882
876
|
propertyKey: string | number,
|
|
883
877
|
): TreeNode | TreeLeafValue | undefined => {
|
|
884
|
-
const flexNode =
|
|
878
|
+
const flexNode = getInnerNode(node);
|
|
885
879
|
debugAssert(
|
|
886
880
|
() => !flexNode.context.isDisposed() || "The provided tree node has been disposed.",
|
|
887
881
|
);
|
|
@@ -951,7 +945,7 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
951
945
|
},
|
|
952
946
|
|
|
953
947
|
children(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {
|
|
954
|
-
const flexNode =
|
|
948
|
+
const flexNode = getInnerNode(node);
|
|
955
949
|
debugAssert(
|
|
956
950
|
() => !flexNode.context.isDisposed() || "The provided tree node has been disposed.",
|
|
957
951
|
);
|
|
@@ -298,7 +298,7 @@ export function createTreeCheckout(
|
|
|
298
298
|
const forest = args?.forest ?? buildForest(breaker, schema);
|
|
299
299
|
const defaultCodecOptions = {
|
|
300
300
|
jsonValidator: FormatValidatorNoOp,
|
|
301
|
-
|
|
301
|
+
minVersionForCollab: FluidClientVersion.v2_0,
|
|
302
302
|
};
|
|
303
303
|
const defaultFieldBatchVersion = 1;
|
|
304
304
|
const changeFamily =
|
|
@@ -70,7 +70,7 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
|
|
|
70
70
|
const localCommits = getLocalCommits();
|
|
71
71
|
assert(
|
|
72
72
|
localCommits[0]?.revision === revision,
|
|
73
|
-
|
|
73
|
+
0xc79 /* Expected local commits to start with specified revision */,
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
// Some in-flight commits have stale enrichments, so we recompute them.
|
|
@@ -128,7 +128,8 @@ export class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange>
|
|
|
128
128
|
|
|
129
129
|
private getPendingChange(revision: RevisionTag): PendingChange<TChange> {
|
|
130
130
|
return (
|
|
131
|
-
this.pendingChanges.get(revision) ??
|
|
131
|
+
this.pendingChanges.get(revision) ??
|
|
132
|
+
fail(0xc7a /* No pending change stored for this revision */)
|
|
132
133
|
);
|
|
133
134
|
}
|
|
134
135
|
|
|
@@ -90,6 +90,13 @@ export type {
|
|
|
90
90
|
MapNodeCustomizableSchemaUnsafe,
|
|
91
91
|
System_Unsafe,
|
|
92
92
|
TreeRecordNodeUnsafe,
|
|
93
|
+
UnannotateAllowedTypeUnsafe,
|
|
94
|
+
AnnotatedAllowedTypeUnsafe,
|
|
95
|
+
AnnotatedAllowedTypesUnsafe,
|
|
96
|
+
AllowedTypesFullUnsafe,
|
|
97
|
+
AllowedTypesFullFromMixedUnsafe,
|
|
98
|
+
UnannotateAllowedTypesListUnsafe,
|
|
99
|
+
AnnotateAllowedTypesListUnsafe,
|
|
93
100
|
} from "./typesUnsafe.js";
|
|
94
101
|
|
|
95
102
|
export {
|
|
@@ -40,10 +40,14 @@ import {
|
|
|
40
40
|
AnnotatedAllowedTypesInternal,
|
|
41
41
|
} from "../core/index.js";
|
|
42
42
|
import type {
|
|
43
|
+
AllowedTypesFullFromMixedUnsafe,
|
|
44
|
+
AnnotatedAllowedTypeUnsafe,
|
|
43
45
|
ArrayNodeCustomizableSchemaUnsafe,
|
|
44
46
|
MapNodeCustomizableSchemaUnsafe,
|
|
45
47
|
System_Unsafe,
|
|
46
48
|
TreeRecordNodeUnsafe,
|
|
49
|
+
UnannotateAllowedTypeUnsafe,
|
|
50
|
+
Unenforced,
|
|
47
51
|
} from "./typesUnsafe.js";
|
|
48
52
|
import type { SimpleObjectNodeSchema } from "../simpleSchema.js";
|
|
49
53
|
import { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
|
|
@@ -113,28 +117,64 @@ export interface SchemaStaticsAlpha {
|
|
|
113
117
|
t: T,
|
|
114
118
|
metadata?: AllowedTypesMetadata,
|
|
115
119
|
) => AllowedTypesFullFromMixed<T>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* {@link SchemaStaticsAlpha.staged} except tweaked to work better for recursive types.
|
|
123
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
124
|
+
* @remarks
|
|
125
|
+
* This version of {@link SchemaStaticsAlpha.staged} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
126
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
127
|
+
*/
|
|
128
|
+
stagedRecursive: <
|
|
129
|
+
const T extends Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>,
|
|
130
|
+
>(
|
|
131
|
+
t: T,
|
|
132
|
+
) => AnnotatedAllowedTypeUnsafe<UnannotateAllowedTypeUnsafe<T>>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* {@link SchemaStaticsAlpha.types} except tweaked to work better for recursive types.
|
|
136
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
137
|
+
* @remarks
|
|
138
|
+
* This version of {@link SchemaStaticsAlpha.types} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
139
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
140
|
+
* @privateRemarks
|
|
141
|
+
* If all inputs (at least recursive ones) were required to be annotated, this could be typed more strongly.
|
|
142
|
+
* In that case it could use `T extends readonly (AnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>)[]`.
|
|
143
|
+
*/
|
|
144
|
+
readonly typesRecursive: <
|
|
145
|
+
const T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],
|
|
146
|
+
>(
|
|
147
|
+
t: T,
|
|
148
|
+
metadata?: AllowedTypesMetadata,
|
|
149
|
+
) => AllowedTypesFullFromMixedUnsafe<T>;
|
|
116
150
|
}
|
|
117
151
|
|
|
152
|
+
const staged = <const T extends LazyItem<TreeNodeSchema>>(
|
|
153
|
+
t: T | AnnotatedAllowedType<T>,
|
|
154
|
+
): AnnotatedAllowedType<T> => {
|
|
155
|
+
const annotatedType = normalizeToAnnotatedAllowedType(t);
|
|
156
|
+
return {
|
|
157
|
+
type: annotatedType.type,
|
|
158
|
+
metadata: {
|
|
159
|
+
...annotatedType.metadata,
|
|
160
|
+
stagedSchemaUpgrade: createSchemaUpgrade(),
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const types = <const T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]>(
|
|
166
|
+
t: T,
|
|
167
|
+
metadata: AllowedTypesMetadata = {},
|
|
168
|
+
): AllowedTypesFullFromMixed<T> => {
|
|
169
|
+
return AnnotatedAllowedTypesInternal.createMixed<T>(t, metadata);
|
|
170
|
+
};
|
|
171
|
+
|
|
118
172
|
const schemaStaticsAlpha: SchemaStaticsAlpha = {
|
|
119
|
-
staged
|
|
120
|
-
|
|
121
|
-
): AnnotatedAllowedType<T> => {
|
|
122
|
-
const annotatedType = normalizeToAnnotatedAllowedType(t);
|
|
123
|
-
return {
|
|
124
|
-
type: annotatedType.type,
|
|
125
|
-
metadata: {
|
|
126
|
-
...annotatedType.metadata,
|
|
127
|
-
stagedSchemaUpgrade: createSchemaUpgrade(),
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
},
|
|
173
|
+
staged,
|
|
174
|
+
types,
|
|
131
175
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
metadata: AllowedTypesMetadata = {},
|
|
135
|
-
): AllowedTypesFullFromMixed<T> => {
|
|
136
|
-
return AnnotatedAllowedTypesInternal.createMixed<T>(t, metadata);
|
|
137
|
-
},
|
|
176
|
+
stagedRecursive: staged as SchemaStaticsAlpha["stagedRecursive"],
|
|
177
|
+
typesRecursive: types as unknown as SchemaStaticsAlpha["typesRecursive"],
|
|
138
178
|
};
|
|
139
179
|
|
|
140
180
|
/**
|
|
@@ -310,6 +350,16 @@ export class SchemaFactoryAlpha<
|
|
|
310
350
|
*/
|
|
311
351
|
public staged = schemaStaticsAlpha.staged;
|
|
312
352
|
|
|
353
|
+
/**
|
|
354
|
+
* {@inheritDoc SchemaStaticsAlpha.stagedRecursive}
|
|
355
|
+
*/
|
|
356
|
+
public static stagedRecursive = schemaStaticsAlpha.stagedRecursive;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* {@inheritDoc SchemaStaticsAlpha.stagedRecursive}
|
|
360
|
+
*/
|
|
361
|
+
public stagedRecursive = schemaStaticsAlpha.stagedRecursive;
|
|
362
|
+
|
|
313
363
|
/**
|
|
314
364
|
* {@inheritDoc SchemaStaticsAlpha.types}
|
|
315
365
|
*/
|
|
@@ -320,6 +370,16 @@ export class SchemaFactoryAlpha<
|
|
|
320
370
|
*/
|
|
321
371
|
public types = schemaStaticsAlpha.types;
|
|
322
372
|
|
|
373
|
+
/**
|
|
374
|
+
* {@inheritDoc SchemaStaticsAlpha.typesRecursive}
|
|
375
|
+
*/
|
|
376
|
+
public static typesRecursive = schemaStaticsAlpha.typesRecursive;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* {@inheritDoc SchemaStaticsAlpha.typesRecursive}
|
|
380
|
+
*/
|
|
381
|
+
public typesRecursive = schemaStaticsAlpha.typesRecursive;
|
|
382
|
+
|
|
323
383
|
/**
|
|
324
384
|
* Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
|
|
325
385
|
*
|
|
@@ -405,7 +465,7 @@ export class SchemaFactoryAlpha<
|
|
|
405
465
|
}
|
|
406
466
|
|
|
407
467
|
/**
|
|
408
|
-
* {@
|
|
468
|
+
* {@link SchemaFactory.arrayRecursive} but with support for some alpha features.
|
|
409
469
|
*/
|
|
410
470
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
411
471
|
public override arrayRecursive<
|
|
@@ -228,6 +228,9 @@ export const schemaStatics = {
|
|
|
228
228
|
},
|
|
229
229
|
} as const;
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* {@link Unenforced} version of {@link createFieldSchema}.
|
|
233
|
+
*/
|
|
231
234
|
function createFieldSchemaUnsafe<
|
|
232
235
|
Kind extends FieldKind,
|
|
233
236
|
Types extends System_Unsafe.ImplicitAllowedTypesUnsafe,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
+
import type { ICodecOptions } from "../../codec/index.js";
|
|
7
8
|
import { SchemaVersion } from "../../core/index.js";
|
|
8
9
|
import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index.js";
|
|
9
10
|
import {
|
|
@@ -24,7 +25,7 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
|
24
25
|
* Dumps the "persisted" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.
|
|
25
26
|
*
|
|
26
27
|
* @param schema - The schema to dump.
|
|
27
|
-
* @param
|
|
28
|
+
* @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.
|
|
28
29
|
* @param includeStaged - filter for selecting which staged allowed types to include in the output.
|
|
29
30
|
*
|
|
30
31
|
* @remarks
|
|
@@ -54,11 +55,11 @@ import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
|
54
55
|
*/
|
|
55
56
|
export function extractPersistedSchema(
|
|
56
57
|
schema: ImplicitFieldSchema,
|
|
57
|
-
|
|
58
|
+
minVersionForCollab: MinimumVersionForCollab,
|
|
58
59
|
includeStaged: (upgrade: SchemaUpgrade) => boolean,
|
|
59
60
|
): JsonCompatible {
|
|
60
61
|
const stored = toStoredSchema(schema, { includeStaged });
|
|
61
|
-
const schemaWriteVersion = clientVersionToSchemaVersion(
|
|
62
|
+
const schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);
|
|
62
63
|
return encodeTreeSchema(stored, schemaWriteVersion);
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -238,7 +238,7 @@ export function borrowCursorFromTreeNodeOrValue(
|
|
|
238
238
|
return cursorFromVerbose(node, {});
|
|
239
239
|
}
|
|
240
240
|
const kernel = getKernel(node);
|
|
241
|
-
const cursor = kernel.
|
|
241
|
+
const cursor = kernel.getInnerNode().borrowCursor();
|
|
242
242
|
return cursor;
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -339,7 +339,7 @@ export const TreeBeta: TreeBeta = {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
const kernel = getKernel(node);
|
|
342
|
-
const cursor = kernel.
|
|
342
|
+
const cursor = kernel.getInnerNode().borrowCursor();
|
|
343
343
|
|
|
344
344
|
// To handle when the node transitively contains unknown optional fields,
|
|
345
345
|
// derive the context from the source node's stored schema which has stored schema for any such fields and their contents.
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
tryGetTreeNodeSchema,
|
|
29
29
|
getOrCreateNodeFromInnerNode,
|
|
30
30
|
typeSchemaSymbol,
|
|
31
|
-
|
|
31
|
+
getInnerNode,
|
|
32
32
|
type TreeLeafValue,
|
|
33
33
|
type ImplicitAllowedTypes,
|
|
34
34
|
type TreeNodeFromImplicitAllowedTypes,
|
|
@@ -141,7 +141,7 @@ export interface TreeNodeApi {
|
|
|
141
141
|
*/
|
|
142
142
|
export const treeNodeApi: TreeNodeApi = {
|
|
143
143
|
parent(node: TreeNode): TreeNode | undefined {
|
|
144
|
-
const editNode =
|
|
144
|
+
const editNode = getInnerNode(node).parentField.parent.parent;
|
|
145
145
|
if (editNode === undefined) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
@@ -306,7 +306,7 @@ export function getIdentifierFromNode(
|
|
|
306
306
|
return undefined;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
const flexNode =
|
|
309
|
+
const flexNode = getInnerNode(node);
|
|
310
310
|
const identifierFieldKeys = schema.identifierFieldKeys;
|
|
311
311
|
|
|
312
312
|
switch (identifierFieldKeys.length) {
|
|
@@ -361,7 +361,7 @@ export function getIdentifierFromNode(
|
|
|
361
361
|
export function getStoredKey(node: TreeNode): string | number {
|
|
362
362
|
// Note: the flex domain strictly works with "stored keys", and knows nothing about the developer-facing
|
|
363
363
|
// "property keys".
|
|
364
|
-
const parentField =
|
|
364
|
+
const parentField = getInnerNode(node).parentField;
|
|
365
365
|
if (parentField.parent.schema === FieldKinds.sequence.identifier) {
|
|
366
366
|
// The parent of `node` is an array node
|
|
367
367
|
assert(
|