@fluidframework/tree 2.4.0-297385 → 2.4.0-299374
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/.dependency-cruiser-known-violations.json +0 -14
- package/.vscode/settings.json +9 -1
- package/api-report/tree.alpha.api.md +178 -21
- package/api-report/tree.beta.api.md +46 -21
- package/api-report/tree.legacy.alpha.api.md +46 -21
- package/api-report/tree.legacy.public.api.md +46 -21
- package/api-report/tree.public.api.md +46 -21
- package/dist/alpha.d.ts +29 -1
- package/dist/beta.d.ts +2 -0
- package/dist/codec/codec.d.ts +4 -4
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/noopValidator.d.ts +1 -1
- package/dist/codec/noopValidator.js +1 -1
- package/dist/codec/noopValidator.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +159 -2
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +54 -12
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.d.ts +1 -1
- package/dist/external-utilities/typeboxValidator.js +1 -1
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +4 -0
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +38 -6
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +0 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +46 -49
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/treeCompressionUtils.d.ts +1 -1
- package/dist/feature-libraries/treeCompressionUtils.js +1 -1
- package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +2 -2
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/shared-tree/index.d.ts +2 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +5 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -14
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +24 -9
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +20 -8
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +6 -6
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +29 -0
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -0
- package/dist/simple-tree/api/conciseTree.js +25 -0
- package/dist/simple-tree/api/conciseTree.js.map +1 -0
- package/dist/simple-tree/api/customTree.d.ts +44 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -0
- package/dist/simple-tree/api/customTree.js +63 -0
- package/dist/simple-tree/api/customTree.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +7 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +5 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +43 -15
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +8 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +78 -0
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -0
- package/dist/simple-tree/api/storedSchema.js +107 -0
- package/dist/simple-tree/api/storedSchema.js.map +1 -0
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/dist/simple-tree/api/tree.d.ts +12 -3
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +5 -5
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -0
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -0
- package/dist/simple-tree/api/verboseTree.d.ts +6 -20
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +10 -48
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +14 -3
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +1 -2
- package/dist/simple-tree/arrayNode.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 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +14 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +6 -5
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +3 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/flexList.d.ts.map +1 -0
- package/dist/simple-tree/flexList.js.map +1 -0
- package/dist/simple-tree/index.d.ts +6 -7
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +2 -3
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +3 -4
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +60 -7
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +11 -6
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +13 -15
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +4 -2
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js +3 -3
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +2 -1
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -0
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -0
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/utils.d.ts +10 -8
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/docs/main/detached-trees.md +8 -8
- package/lib/alpha.d.ts +29 -1
- package/lib/beta.d.ts +2 -0
- package/lib/codec/codec.d.ts +4 -4
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/noopValidator.d.ts +1 -1
- package/lib/codec/noopValidator.js +1 -1
- package/lib/codec/noopValidator.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +159 -2
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +54 -12
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.d.ts +1 -1
- package/lib/external-utilities/typeboxValidator.js +1 -1
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +4 -0
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +36 -5
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +0 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +0 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/treeCompressionUtils.d.ts +1 -1
- package/lib/feature-libraries/treeCompressionUtils.js +1 -1
- package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +2 -2
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -0
- package/lib/shared-tree/index.d.ts +2 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +2 -15
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +24 -9
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +19 -8
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +6 -6
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +29 -0
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -0
- package/lib/simple-tree/api/conciseTree.js +21 -0
- package/lib/simple-tree/api/conciseTree.js.map +1 -0
- package/lib/simple-tree/api/customTree.d.ts +44 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -0
- package/lib/simple-tree/api/customTree.js +59 -0
- package/lib/simple-tree/api/customTree.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +7 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +43 -15
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +78 -0
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -0
- package/lib/simple-tree/api/storedSchema.js +101 -0
- package/lib/simple-tree/api/storedSchema.js.map +1 -0
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
- package/lib/simple-tree/api/tree.d.ts +12 -3
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +3 -3
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +58 -10
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -0
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -0
- package/lib/simple-tree/api/verboseTree.d.ts +6 -20
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +11 -49
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +14 -3
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +1 -2
- package/lib/simple-tree/arrayNode.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 +9 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +12 -0
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +6 -5
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +3 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +3 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/flexList.d.ts.map +1 -0
- package/lib/simple-tree/flexList.js.map +1 -0
- package/lib/simple-tree/index.d.ts +6 -7
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +3 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +1 -2
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +1 -2
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +60 -7
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +6 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +1 -3
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +4 -2
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js +3 -3
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +2 -1
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -0
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -0
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/utils.d.ts +10 -8
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +41 -24
- package/src/codec/codec.ts +4 -4
- package/src/codec/noopValidator.ts +1 -1
- package/src/core/tree/anchorSet.ts +63 -13
- package/src/external-utilities/typeboxValidator.ts +1 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +44 -7
- package/src/feature-libraries/index.ts +0 -10
- package/src/feature-libraries/treeCompressionUtils.ts +1 -1
- package/src/index.ts +26 -6
- package/src/internalTypes.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +5 -0
- package/src/shared-tree/schematizingTreeView.ts +7 -16
- package/src/shared-tree/sharedTree.ts +52 -22
- package/src/shared-tree/treeApi.ts +19 -9
- package/src/simple-tree/api/conciseTree.ts +58 -0
- package/src/simple-tree/api/customTree.ts +119 -0
- package/src/simple-tree/api/index.ts +39 -1
- package/src/simple-tree/api/schemaCreationUtilities.ts +55 -36
- package/src/simple-tree/api/schemaFactory.ts +4 -6
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -2
- package/src/simple-tree/api/storedSchema.ts +126 -0
- package/src/simple-tree/api/tree.ts +24 -2
- package/src/simple-tree/api/treeNodeApi.ts +3 -8
- package/src/simple-tree/{typesUnsafe.ts → api/typesUnsafe.ts} +95 -21
- package/src/simple-tree/api/verboseTree.ts +21 -76
- package/src/simple-tree/arrayNode.ts +35 -15
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +13 -0
- package/src/simple-tree/core/treeNodeSchema.ts +7 -5
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -1
- package/src/simple-tree/core/withType.ts +10 -1
- package/src/simple-tree/index.ts +41 -21
- package/src/simple-tree/mapNode.ts +1 -1
- package/src/simple-tree/objectNode.ts +1 -1
- package/src/simple-tree/schemaTypes.ts +70 -11
- package/src/simple-tree/toFlexSchema.ts +1 -3
- package/src/simple-tree/toMapTree.ts +7 -4
- package/src/simple-tree/treeNodeValid.ts +2 -1
- package/src/treeFactory.ts +1 -0
- package/src/util/utils.ts +10 -8
- package/dist/feature-libraries/flex-tree/unboxed.d.ts +0 -12
- package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
- package/dist/feature-libraries/flex-tree/unboxed.js +0 -20
- package/dist/feature-libraries/flex-tree/unboxed.js.map +0 -1
- package/dist/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/flexList.js.map +0 -1
- package/dist/feature-libraries/typed-schema/index.d.ts +0 -7
- package/dist/feature-libraries/typed-schema/index.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/index.js +0 -12
- package/dist/feature-libraries/typed-schema/index.js.map +0 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -7
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
- package/dist/simple-tree/proxyBinding.d.ts +0 -15
- package/dist/simple-tree/proxyBinding.d.ts.map +0 -1
- package/dist/simple-tree/proxyBinding.js +0 -22
- package/dist/simple-tree/proxyBinding.js.map +0 -1
- package/dist/simple-tree/typesUnsafe.d.ts.map +0 -1
- package/dist/simple-tree/typesUnsafe.js.map +0 -1
- package/lib/feature-libraries/flex-tree/unboxed.d.ts +0 -12
- package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
- package/lib/feature-libraries/flex-tree/unboxed.js +0 -16
- package/lib/feature-libraries/flex-tree/unboxed.js.map +0 -1
- package/lib/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/flexList.js.map +0 -1
- package/lib/feature-libraries/typed-schema/index.d.ts +0 -7
- package/lib/feature-libraries/typed-schema/index.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/index.js +0 -6
- package/lib/feature-libraries/typed-schema/index.js.map +0 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +0 -6
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
- package/lib/simple-tree/proxyBinding.d.ts +0 -15
- package/lib/simple-tree/proxyBinding.d.ts.map +0 -1
- package/lib/simple-tree/proxyBinding.js +0 -18
- package/lib/simple-tree/proxyBinding.js.map +0 -1
- package/lib/simple-tree/typesUnsafe.d.ts.map +0 -1
- package/lib/simple-tree/typesUnsafe.js.map +0 -1
- package/src/feature-libraries/flex-tree/unboxed.ts +0 -24
- package/src/feature-libraries/typed-schema/README.md +0 -6
- package/src/feature-libraries/typed-schema/index.ts +0 -16
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -14
- package/src/simple-tree/proxyBinding.ts +0 -20
- /package/dist/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
- /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
- /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
- /package/lib/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
- /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
- /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
- /package/src/simple-tree/{ProxyBinding.md → core/TreeNodeBinding.md} +0 -0
- /package/src/{feature-libraries/typed-schema → simple-tree}/flexList.ts +0 -0
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
type TreeViewConfiguration,
|
|
42
42
|
mapTreeFromNodeData,
|
|
43
43
|
prepareContentForHydration,
|
|
44
|
+
comparePersistedSchemaInternal,
|
|
44
45
|
toStoredSchema,
|
|
45
46
|
} from "../simple-tree/index.js";
|
|
46
47
|
import { Breakable, breakingClass, disposeSymbol, type WithBreakable } from "../util/index.js";
|
|
@@ -225,22 +226,12 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
225
226
|
private update(): void {
|
|
226
227
|
this.disposeView();
|
|
227
228
|
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const canView =
|
|
235
|
-
result.write === Compatibility.Compatible && result.read === Compatibility.Compatible;
|
|
236
|
-
const canUpgrade = result.read === Compatibility.Compatible;
|
|
237
|
-
const isEquivalent = canView && canUpgrade;
|
|
238
|
-
const compatibility: SchemaCompatibilityStatus = {
|
|
239
|
-
canView,
|
|
240
|
-
canUpgrade,
|
|
241
|
-
isEquivalent,
|
|
242
|
-
canInitialize: canInitialize(this.checkout),
|
|
243
|
-
};
|
|
229
|
+
const compatibility = comparePersistedSchemaInternal(
|
|
230
|
+
this.checkout.storedSchema,
|
|
231
|
+
this.viewSchema,
|
|
232
|
+
canInitialize(this.checkout),
|
|
233
|
+
);
|
|
234
|
+
|
|
244
235
|
let lastRoot =
|
|
245
236
|
this.compatibility.canView && this.view !== undefined ? this.root : undefined;
|
|
246
237
|
this.currentCompatibility = compatibility;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import type {
|
|
8
8
|
IChannelAttributes,
|
|
9
9
|
IChannelFactory,
|
|
@@ -16,11 +16,13 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
16
16
|
|
|
17
17
|
import { type ICodecOptions, noopValidator } from "../codec/index.js";
|
|
18
18
|
import {
|
|
19
|
+
type IEditableForest,
|
|
19
20
|
type JsonableTree,
|
|
20
21
|
RevisionTagCodec,
|
|
21
22
|
type TaggedChange,
|
|
22
23
|
type TreeStoredSchema,
|
|
23
24
|
TreeStoredSchemaRepository,
|
|
25
|
+
type TreeStoredSchemaSubscription,
|
|
24
26
|
makeDetachedFieldIndex,
|
|
25
27
|
moveToDetachedField,
|
|
26
28
|
} from "../core/index.js";
|
|
@@ -67,6 +69,7 @@ import {
|
|
|
67
69
|
createTreeCheckout,
|
|
68
70
|
} from "./treeCheckout.js";
|
|
69
71
|
import { breakingClass, throwIfBroken } from "../util/index.js";
|
|
72
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
75
|
* Copy of data from an {@link ISharedTree} at some point in time.
|
|
@@ -150,6 +153,30 @@ function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
|
|
|
150
153
|
return versions;
|
|
151
154
|
}
|
|
152
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Build and return a forest of the requested type.
|
|
158
|
+
*/
|
|
159
|
+
export function buildConfiguredForest(
|
|
160
|
+
type: ForestType,
|
|
161
|
+
schema: TreeStoredSchemaSubscription,
|
|
162
|
+
idCompressor: IIdCompressor,
|
|
163
|
+
): IEditableForest {
|
|
164
|
+
switch (type) {
|
|
165
|
+
case ForestType.Optimized:
|
|
166
|
+
return buildChunkedForest(
|
|
167
|
+
makeTreeChunker(schema, defaultSchemaPolicy),
|
|
168
|
+
undefined,
|
|
169
|
+
idCompressor,
|
|
170
|
+
);
|
|
171
|
+
case ForestType.Reference:
|
|
172
|
+
return buildForest();
|
|
173
|
+
case ForestType.Expensive:
|
|
174
|
+
return buildForest(undefined, true);
|
|
175
|
+
default:
|
|
176
|
+
unreachableCase(type);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
153
180
|
/**
|
|
154
181
|
* Shared tree, configured with a good set of indexes and field kinds which will maintain compatibility over time.
|
|
155
182
|
*
|
|
@@ -182,16 +209,7 @@ export class SharedTree
|
|
|
182
209
|
const options = { ...defaultSharedTreeOptions, ...optionsParam };
|
|
183
210
|
const codecVersions = getCodecVersions(options.formatVersion);
|
|
184
211
|
const schema = new TreeStoredSchemaRepository();
|
|
185
|
-
const forest =
|
|
186
|
-
options.forest === ForestType.Optimized
|
|
187
|
-
? buildChunkedForest(
|
|
188
|
-
makeTreeChunker(schema, defaultSchemaPolicy),
|
|
189
|
-
undefined,
|
|
190
|
-
runtime.idCompressor,
|
|
191
|
-
)
|
|
192
|
-
: options.forest === ForestType.Reference
|
|
193
|
-
? buildForest()
|
|
194
|
-
: buildForest(undefined, true);
|
|
212
|
+
const forest = buildConfiguredForest(options.forest, schema, runtime.idCompressor);
|
|
195
213
|
const revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);
|
|
196
214
|
const removedRoots = makeDetachedFieldIndex(
|
|
197
215
|
"repair",
|
|
@@ -350,7 +368,7 @@ export function getBranch(treeOrView: ITree | TreeView<ImplicitFieldSchema>): Tr
|
|
|
350
368
|
* Format versions supported by SharedTree.
|
|
351
369
|
*
|
|
352
370
|
* Each version documents a required minimum version of the \@fluidframework/tree package.
|
|
353
|
-
* @
|
|
371
|
+
* @alpha
|
|
354
372
|
*/
|
|
355
373
|
export const SharedTreeFormatVersion = {
|
|
356
374
|
/**
|
|
@@ -376,26 +394,38 @@ export const SharedTreeFormatVersion = {
|
|
|
376
394
|
* Format versions supported by SharedTree.
|
|
377
395
|
*
|
|
378
396
|
* Each version documents a required minimum version of the \@fluidframework/tree package.
|
|
379
|
-
* @
|
|
397
|
+
* @alpha
|
|
380
398
|
* @privateRemarks
|
|
381
399
|
* See packages/dds/tree/docs/main/compatibility.md for information on how to add support for a new format.
|
|
400
|
+
*
|
|
401
|
+
* TODO: Before this gets promoted past Alpha,
|
|
402
|
+
* a separate abstraction more suited for use in the public API should be adopted rather than reusing the same types used internally.
|
|
403
|
+
* Such an abstraction should probably be in the form of a Fluid-Framework wide compatibility enum.
|
|
382
404
|
*/
|
|
383
405
|
export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
|
|
384
406
|
|
|
385
407
|
/**
|
|
386
|
-
*
|
|
408
|
+
* Configuration options for SharedTree.
|
|
409
|
+
* @alpha
|
|
387
410
|
*/
|
|
388
411
|
export type SharedTreeOptions = Partial<ICodecOptions> &
|
|
389
|
-
Partial<SharedTreeFormatOptions> &
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
412
|
+
Partial<SharedTreeFormatOptions> &
|
|
413
|
+
ForestOptions;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Configuration options for SharedTree's internal tree storage.
|
|
417
|
+
* @alpha
|
|
418
|
+
*/
|
|
419
|
+
export interface ForestOptions {
|
|
420
|
+
/**
|
|
421
|
+
* The {@link ForestType} indicating which forest type should be created for the SharedTree.
|
|
422
|
+
*/
|
|
423
|
+
readonly forest?: ForestType;
|
|
424
|
+
}
|
|
395
425
|
|
|
396
426
|
/**
|
|
397
427
|
* Options for configuring the persisted format SharedTree uses.
|
|
398
|
-
* @
|
|
428
|
+
* @alpha
|
|
399
429
|
*/
|
|
400
430
|
export interface SharedTreeFormatOptions {
|
|
401
431
|
/**
|
|
@@ -419,7 +449,7 @@ export interface SharedTreeFormatOptions {
|
|
|
419
449
|
|
|
420
450
|
/**
|
|
421
451
|
* Used to distinguish between different forest types.
|
|
422
|
-
* @
|
|
452
|
+
* @alpha
|
|
423
453
|
*/
|
|
424
454
|
export enum ForestType {
|
|
425
455
|
/**
|
|
@@ -78,7 +78,10 @@ export interface RunTransaction {
|
|
|
78
78
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
79
79
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
// TODO: TreeView is invariant over the schema, so to accept any view, `any` is the only real option unless a non generic (or covariant) base type for view is introduced (which is planned).
|
|
82
|
+
// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
<TView extends TreeView<any>, TResult>(
|
|
82
85
|
tree: TView,
|
|
83
86
|
transaction: (root: TView["root"]) => TResult,
|
|
84
87
|
): TResult;
|
|
@@ -123,7 +126,9 @@ export interface RunTransaction {
|
|
|
123
126
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
124
127
|
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
|
125
128
|
*/
|
|
126
|
-
|
|
129
|
+
// See comment on previous overload about use of any here.
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
<TView extends TreeView<any>, TResult>(
|
|
127
132
|
tree: TView,
|
|
128
133
|
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
|
129
134
|
): TResult | typeof rollback;
|
|
@@ -161,10 +166,9 @@ export interface RunTransaction {
|
|
|
161
166
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
162
167
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
163
168
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
): void;
|
|
169
|
+
// See comment on previous overload about use of any here.
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
+
<TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void): void;
|
|
168
172
|
/**
|
|
169
173
|
* Apply one or more edits to the tree as a single atomic unit.
|
|
170
174
|
* @param node - The node that will be passed to `transaction`.
|
|
@@ -211,7 +215,9 @@ export interface RunTransaction {
|
|
|
211
215
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
212
216
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
213
217
|
*/
|
|
214
|
-
|
|
218
|
+
// See comment on previous overload about use of any here.
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
220
|
+
<TView extends TreeView<any>, TResult>(
|
|
215
221
|
tree: TView,
|
|
216
222
|
transaction: (root: TView["root"]) => TResult,
|
|
217
223
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -264,7 +270,9 @@ export interface RunTransaction {
|
|
|
264
270
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
265
271
|
* If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.
|
|
266
272
|
*/
|
|
267
|
-
|
|
273
|
+
// See comment on previous overload about use of any here.
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
275
|
+
<TView extends TreeView<any>, TResult>(
|
|
268
276
|
tree: TView,
|
|
269
277
|
transaction: (root: TView["root"]) => TResult | typeof rollback,
|
|
270
278
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -313,7 +321,9 @@ export interface RunTransaction {
|
|
|
313
321
|
* If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.
|
|
314
322
|
* If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
|
|
315
323
|
*/
|
|
316
|
-
|
|
324
|
+
// See comment on previous overload about use of any here.
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
|
+
<TView extends TreeView<any>>(
|
|
317
327
|
tree: TView,
|
|
318
328
|
transaction: (root: TView["root"]) => void,
|
|
319
329
|
preconditions?: readonly TransactionConstraint[],
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
|
|
8
|
+
import type { ITreeCursor } from "../../core/index.js";
|
|
9
|
+
import type { TreeLeafValue, ImplicitAllowedTypes } from "../schemaTypes.js";
|
|
10
|
+
import type { TreeNodeSchema } from "../core/index.js";
|
|
11
|
+
import { customFromCursorInner, type EncodeOptions } from "./customTree.js";
|
|
12
|
+
import { getUnhydratedContext } from "../createContext.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Concise encoding of a {@link TreeNode} or {@link TreeLeafValue}.
|
|
16
|
+
* @remarks
|
|
17
|
+
* This is "concise" meaning that explicit type information is omitted.
|
|
18
|
+
* If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},
|
|
19
|
+
* types will be lossless and compatible with {@link TreeBeta.create} (unless the options are used to customize it).
|
|
20
|
+
*
|
|
21
|
+
* Every {@link TreeNode} is an array or object.
|
|
22
|
+
* Any IFluidHandle values have been replaced by `THandle`.
|
|
23
|
+
* @privateRemarks
|
|
24
|
+
* This can store all possible simple trees,
|
|
25
|
+
* but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
|
|
26
|
+
*/
|
|
27
|
+
export type ConciseTree<THandle = IFluidHandle> =
|
|
28
|
+
| Exclude<TreeLeafValue, IFluidHandle>
|
|
29
|
+
| THandle
|
|
30
|
+
| ConciseTree<THandle>[]
|
|
31
|
+
| {
|
|
32
|
+
[key: string]: ConciseTree<THandle>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Used to read a node cursor as a ConciseTree.
|
|
37
|
+
*/
|
|
38
|
+
export function conciseFromCursor<TCustom>(
|
|
39
|
+
reader: ITreeCursor,
|
|
40
|
+
rootSchema: ImplicitAllowedTypes,
|
|
41
|
+
options: EncodeOptions<TCustom>,
|
|
42
|
+
): ConciseTree<TCustom> {
|
|
43
|
+
const config: Required<EncodeOptions<TCustom>> = {
|
|
44
|
+
useStoredKeys: false,
|
|
45
|
+
...options,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const schemaMap = getUnhydratedContext(rootSchema).schema;
|
|
49
|
+
return conciseFromCursorInner(reader, config, schemaMap);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function conciseFromCursorInner<TCustom>(
|
|
53
|
+
reader: ITreeCursor,
|
|
54
|
+
options: Required<EncodeOptions<TCustom>>,
|
|
55
|
+
schema: ReadonlyMap<string, TreeNodeSchema>,
|
|
56
|
+
): ConciseTree<TCustom> {
|
|
57
|
+
return customFromCursorInner(reader, options, schema, conciseFromCursorInner);
|
|
58
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
8
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
EmptyKey,
|
|
12
|
+
forEachField,
|
|
13
|
+
inCursorField,
|
|
14
|
+
mapCursorField,
|
|
15
|
+
type ITreeCursor,
|
|
16
|
+
} from "../../core/index.js";
|
|
17
|
+
import { fail } from "../../util/index.js";
|
|
18
|
+
import type { TreeLeafValue } from "../schemaTypes.js";
|
|
19
|
+
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
20
|
+
import {
|
|
21
|
+
booleanSchema,
|
|
22
|
+
handleSchema,
|
|
23
|
+
nullSchema,
|
|
24
|
+
numberSchema,
|
|
25
|
+
stringSchema,
|
|
26
|
+
} from "../leafNodeSchema.js";
|
|
27
|
+
import { isObjectNodeSchema } from "../objectNodeTypes.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Options for how to encode a tree.
|
|
31
|
+
*/
|
|
32
|
+
export interface EncodeOptions<TCustom> {
|
|
33
|
+
/**
|
|
34
|
+
* How to encode any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the tree.
|
|
35
|
+
* @remarks
|
|
36
|
+
* See note on {@link ParseOptions.valueConverter}.
|
|
37
|
+
*/
|
|
38
|
+
valueConverter(data: IFluidHandle): TCustom;
|
|
39
|
+
/**
|
|
40
|
+
* If true, interpret the input keys of object nodes as stored keys.
|
|
41
|
+
* If false, interpret them as property keys.
|
|
42
|
+
* @defaultValue false.
|
|
43
|
+
*/
|
|
44
|
+
readonly useStoredKeys?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Tree representation with fields as properties and customized handle and child representations.
|
|
49
|
+
*/
|
|
50
|
+
export type CustomTree<TChild, THandle> = CustomTreeNode<TChild> | CustomTreeValue<THandle>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* TreeLeafValue except the handle type is customized.
|
|
54
|
+
*/
|
|
55
|
+
export type CustomTreeValue<THandle> = Exclude<TreeLeafValue, IFluidHandle> | THandle;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tree node representation with fields as properties and customized child representation.
|
|
59
|
+
*/
|
|
60
|
+
export type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Builds an {@link CustomTree} from a cursor in Nodes mode.
|
|
64
|
+
*/
|
|
65
|
+
export function customFromCursorInner<TChild, THandle>(
|
|
66
|
+
reader: ITreeCursor,
|
|
67
|
+
options: Required<EncodeOptions<THandle>>,
|
|
68
|
+
schema: ReadonlyMap<string, TreeNodeSchema>,
|
|
69
|
+
childHandler: (
|
|
70
|
+
reader: ITreeCursor,
|
|
71
|
+
options: Required<EncodeOptions<THandle>>,
|
|
72
|
+
schema: ReadonlyMap<string, TreeNodeSchema>,
|
|
73
|
+
) => TChild,
|
|
74
|
+
): CustomTree<TChild, THandle> {
|
|
75
|
+
const type = reader.type;
|
|
76
|
+
const nodeSchema = schema.get(type) ?? fail("missing schema for type in cursor");
|
|
77
|
+
|
|
78
|
+
switch (type) {
|
|
79
|
+
case numberSchema.identifier:
|
|
80
|
+
case booleanSchema.identifier:
|
|
81
|
+
case nullSchema.identifier:
|
|
82
|
+
case stringSchema.identifier:
|
|
83
|
+
assert(reader.value !== undefined, "out of schema: missing value");
|
|
84
|
+
assert(!isFluidHandle(reader.value), "out of schema: unexpected FluidHandle");
|
|
85
|
+
return reader.value;
|
|
86
|
+
case handleSchema.identifier:
|
|
87
|
+
assert(reader.value !== undefined, "out of schema: missing value");
|
|
88
|
+
assert(isFluidHandle(reader.value), "out of schema: expected FluidHandle");
|
|
89
|
+
return options.valueConverter(reader.value);
|
|
90
|
+
default: {
|
|
91
|
+
assert(reader.value === undefined, "out of schema: unexpected value");
|
|
92
|
+
if (nodeSchema.kind === NodeKind.Array) {
|
|
93
|
+
const fields = inCursorField(reader, EmptyKey, () =>
|
|
94
|
+
mapCursorField(reader, () => childHandler(reader, options, schema)),
|
|
95
|
+
);
|
|
96
|
+
return fields;
|
|
97
|
+
} else {
|
|
98
|
+
const fields: Record<string, TChild> = {};
|
|
99
|
+
forEachField(reader, () => {
|
|
100
|
+
const children = mapCursorField(reader, () => childHandler(reader, options, schema));
|
|
101
|
+
if (children.length === 1) {
|
|
102
|
+
const storedKey = reader.getFieldKey();
|
|
103
|
+
const key =
|
|
104
|
+
isObjectNodeSchema(nodeSchema) && !options.useStoredKeys
|
|
105
|
+
? nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
|
|
106
|
+
fail("missing property key")
|
|
107
|
+
: storedKey;
|
|
108
|
+
// Length is checked above.
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
110
|
+
fields[key] = children[0]!;
|
|
111
|
+
} else {
|
|
112
|
+
assert(children.length === 0, 0xa19 /* invalid children number */);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return fields;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -12,6 +12,7 @@ export {
|
|
|
12
12
|
type ITreeViewConfiguration,
|
|
13
13
|
type SchemaCompatibilityStatus,
|
|
14
14
|
type ITreeConfigurationOptions,
|
|
15
|
+
type TreeViewAlpha,
|
|
15
16
|
} from "./tree.js";
|
|
16
17
|
export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
|
|
17
18
|
export type {
|
|
@@ -23,7 +24,6 @@ export {
|
|
|
23
24
|
enumFromStrings,
|
|
24
25
|
singletonSchema,
|
|
25
26
|
typedObjectValues,
|
|
26
|
-
type EmptyObject,
|
|
27
27
|
} from "./schemaCreationUtilities.js";
|
|
28
28
|
export { treeNodeApi, type TreeNodeApi } from "./treeNodeApi.js";
|
|
29
29
|
export { createFromInsertable, cursorFromInsertable } from "./create.js";
|
|
@@ -46,9 +46,47 @@ export {
|
|
|
46
46
|
export { getJsonSchema } from "./getJsonSchema.js";
|
|
47
47
|
export { getSimpleSchema } from "./getSimpleSchema.js";
|
|
48
48
|
export { ViewSchema } from "./view.js";
|
|
49
|
+
export type {
|
|
50
|
+
Unenforced,
|
|
51
|
+
FieldHasDefaultUnsafe,
|
|
52
|
+
ObjectFromSchemaRecordUnsafe,
|
|
53
|
+
TreeObjectNodeUnsafe,
|
|
54
|
+
TreeFieldFromImplicitFieldUnsafe,
|
|
55
|
+
TreeNodeFromImplicitAllowedTypesUnsafe,
|
|
56
|
+
FieldSchemaUnsafe,
|
|
57
|
+
InsertableTreeNodeFromImplicitAllowedTypesUnsafe,
|
|
58
|
+
TreeArrayNodeUnsafe,
|
|
59
|
+
TreeMapNodeUnsafe,
|
|
60
|
+
InsertableObjectFromSchemaRecordUnsafe,
|
|
61
|
+
InsertableTreeFieldFromImplicitFieldUnsafe,
|
|
62
|
+
InsertableTypedNodeUnsafe,
|
|
63
|
+
NodeBuilderDataUnsafe,
|
|
64
|
+
NodeFromSchemaUnsafe,
|
|
65
|
+
ReadonlyMapInlined,
|
|
66
|
+
TreeNodeSchemaClassUnsafe,
|
|
67
|
+
TreeNodeSchemaUnsafe,
|
|
68
|
+
AllowedTypesUnsafe,
|
|
69
|
+
TreeNodeSchemaNonClassUnsafe,
|
|
70
|
+
} from "./typesUnsafe.js";
|
|
71
|
+
|
|
72
|
+
export type {
|
|
73
|
+
VerboseTreeNode,
|
|
74
|
+
ParseOptions,
|
|
75
|
+
VerboseTree,
|
|
76
|
+
} from "./verboseTree.js";
|
|
77
|
+
|
|
78
|
+
export type { EncodeOptions } from "./customTree.js";
|
|
79
|
+
|
|
80
|
+
export type { ConciseTree } from "./conciseTree.js";
|
|
49
81
|
|
|
50
82
|
export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js";
|
|
51
83
|
|
|
84
|
+
export {
|
|
85
|
+
extractPersistedSchema,
|
|
86
|
+
comparePersistedSchemaInternal,
|
|
87
|
+
comparePersistedSchema,
|
|
88
|
+
} from "./storedSchema.js";
|
|
89
|
+
|
|
52
90
|
// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.
|
|
53
91
|
// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639
|
|
54
92
|
export {
|
|
@@ -9,27 +9,29 @@ import { fail } from "../../util/index.js";
|
|
|
9
9
|
|
|
10
10
|
import type { SchemaFactory, ScopedSchemaName } from "./schemaFactory.js";
|
|
11
11
|
import type { NodeFromSchema } from "../schemaTypes.js";
|
|
12
|
-
import type { NodeKind, TreeNodeSchemaClass, TreeNode } from "../core/index.js";
|
|
13
12
|
import type {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
InternalTreeNode,
|
|
14
|
+
NodeKind,
|
|
15
|
+
TreeNode,
|
|
16
|
+
TreeNodeSchemaClass,
|
|
17
|
+
} from "../core/index.js";
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* This file does two things:
|
|
21
|
+
*
|
|
22
|
+
* 1. Provides tools for making schema for cases like enums.
|
|
23
|
+
*
|
|
24
|
+
* 2. Demonstrates the kinds of schema utilities apps can write.
|
|
25
|
+
* Nothing in here needs access to package internal APIs.
|
|
21
26
|
*/
|
|
22
|
-
// Using {} instead of interface {} or Record<string, never> for empty object here produces better IntelliSense in the generated types than `Record<string, never>` recommended by the linter.
|
|
23
|
-
// Making this a type instead of an interface prevents it from showing up in IntelliSense, and also avoids breaking the typing somehow.
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/consistent-type-definitions
|
|
25
|
-
export type EmptyObject = {};
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Create a schema for a node with no state.
|
|
29
30
|
* @remarks
|
|
30
31
|
* This is commonly used in unions when the only information needed is which kind of node the value is.
|
|
31
32
|
* Enums are a common example of this pattern.
|
|
32
|
-
* @
|
|
33
|
+
* @see {@link adaptEnum}
|
|
34
|
+
* @alpha
|
|
33
35
|
*/
|
|
34
36
|
// Return type is intentionally derived.
|
|
35
37
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
@@ -38,7 +40,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
38
40
|
name: TName,
|
|
39
41
|
) {
|
|
40
42
|
class SingletonSchema extends factory.object(name, {}) {
|
|
41
|
-
public constructor(data?:
|
|
43
|
+
public constructor(data?: InternalTreeNode) {
|
|
42
44
|
super(data ?? {});
|
|
43
45
|
}
|
|
44
46
|
public get value(): TName {
|
|
@@ -46,9 +48,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
type NodeType =
|
|
50
|
-
TreeNode &
|
|
51
|
-
ObjectFromSchemaRecord<EmptyObject> & { readonly value: TName };
|
|
51
|
+
type NodeType = TreeNode & { readonly value: TName };
|
|
52
52
|
|
|
53
53
|
// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
|
|
54
54
|
// for the private brand field of TreeNode.
|
|
@@ -59,7 +59,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
59
59
|
ScopedSchemaName<TScope, TName>,
|
|
60
60
|
NodeKind.Object,
|
|
61
61
|
NodeType,
|
|
62
|
-
|
|
62
|
+
never,
|
|
63
63
|
true
|
|
64
64
|
> &
|
|
65
65
|
(new () => NodeType) = SingletonSchema;
|
|
@@ -71,33 +71,50 @@ export function singletonSchema<TScope extends string, TName extends string | nu
|
|
|
71
71
|
* Converts an enum into a collection of schema which can be used in a union.
|
|
72
72
|
* @remarks
|
|
73
73
|
* Currently only supports `string` enums.
|
|
74
|
+
* The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique.
|
|
75
|
+
* Consider making a dedicated schema factory with a nested scope to avoid the enum members colliding with other schema.
|
|
74
76
|
* @example
|
|
75
77
|
* ```typescript
|
|
78
|
+
* const schemaFactory = new SchemaFactory("com.myApp");
|
|
79
|
+
* // An enum for use in the tree. Must have string keys.
|
|
76
80
|
* enum Mode {
|
|
77
81
|
* a = "A",
|
|
78
82
|
* b = "B",
|
|
79
83
|
* }
|
|
80
|
-
*
|
|
84
|
+
* // Define the schema for each member of the enum using a nested scope to group them together.
|
|
85
|
+
* const ModeNodes = adaptEnum(new SchemaFactory(`${schemaFactory.scope}.Mode`), Mode);
|
|
86
|
+
* // Defined the types of the nodes which correspond to this the schema.
|
|
81
87
|
* type ModeNodes = NodeFromSchema<(typeof ModeNodes)[keyof typeof ModeNodes]>;
|
|
82
|
-
*
|
|
83
|
-
* const nodeFromSchema: ModeNodes = new ModeNodes.a();
|
|
84
|
-
* const nameFromNode: Mode = nodeFromSchema.value;
|
|
88
|
+
* // An example schema which has an enum as a child.
|
|
85
89
|
* class Parent extends schemaFactory.object("Parent", {
|
|
90
|
+
* // typedObjectValues extracts a list of all the fields of ModeNodes, which are the schema for each enum member.
|
|
91
|
+
* // This means any member of the enum is allowed in this field.
|
|
86
92
|
* mode: typedObjectValues(ModeNodes),
|
|
87
93
|
* }) {}
|
|
94
|
+
*
|
|
95
|
+
* // Example usage of enum-based nodes, showing what type to use and that `.value` can be used to read out the enum value.
|
|
96
|
+
* function getValue(node: ModeNodes): Mode {
|
|
97
|
+
* return node.value;
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* // Example constructing a tree containing an enum node from an enum value.
|
|
101
|
+
* // The syntax `new ModeNodes.a()` is also supported.
|
|
102
|
+
* function setValue(node: Parent): void {
|
|
103
|
+
* node.mode = ModeNodes(Mode.a);
|
|
104
|
+
* }
|
|
88
105
|
* ```
|
|
89
106
|
* @privateRemarks
|
|
90
107
|
* TODO:
|
|
91
|
-
*
|
|
92
|
-
* Maybe
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
108
|
+
* Extend this to support numeric enums.
|
|
109
|
+
* Maybe provide `SchemaFactory.nested` to ease creating nested scopes?
|
|
110
|
+
* @see {@link enumFromStrings} for a similar function that works on arrays of strings instead of an enum.
|
|
111
|
+
* @alpha
|
|
95
112
|
*/
|
|
96
113
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
97
|
-
export function adaptEnum<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
) {
|
|
114
|
+
export function adaptEnum<
|
|
115
|
+
TScope extends string,
|
|
116
|
+
const TEnum extends Record<string, string | number>,
|
|
117
|
+
>(factory: SchemaFactory<TScope>, members: TEnum) {
|
|
101
118
|
type Values = TEnum[keyof TEnum];
|
|
102
119
|
const values = Object.values(members) as Values[];
|
|
103
120
|
const inverse = new Map(Object.entries(members).map(([key, value]) => [value, key])) as Map<
|
|
@@ -116,7 +133,7 @@ export function adaptEnum<TScope extends string, const TEnum extends Record<stri
|
|
|
116
133
|
};
|
|
117
134
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
118
135
|
const factoryOut = <TValue extends Values>(value: TValue) => {
|
|
119
|
-
return new out[inverse.get(value) ?? fail("missing enum value")](
|
|
136
|
+
return new out[inverse.get(value) ?? fail("missing enum value")]() as NodeFromSchema<
|
|
120
137
|
ReturnType<typeof singletonSchema<TScope, TValue>>
|
|
121
138
|
>;
|
|
122
139
|
};
|
|
@@ -135,7 +152,9 @@ export function adaptEnum<TScope extends string, const TEnum extends Record<stri
|
|
|
135
152
|
|
|
136
153
|
/**
|
|
137
154
|
* `Object.values`, but with more specific types.
|
|
138
|
-
* @
|
|
155
|
+
* @remarks
|
|
156
|
+
* Useful with collections of schema, like those returned by {@link adaptEnum} or {@link enumFromStrings}.
|
|
157
|
+
* @alpha
|
|
139
158
|
*/
|
|
140
159
|
export function typedObjectValues<TKey extends string, TValues>(
|
|
141
160
|
object: Record<TKey, TValues>,
|
|
@@ -160,7 +179,8 @@ export function typedObjectValues<TKey extends string, TValues>(
|
|
|
160
179
|
*
|
|
161
180
|
* class Parent extends schemaFactory.object("Parent", { mode: typedObjectValues(Mode) }) {}
|
|
162
181
|
* ```
|
|
163
|
-
* @
|
|
182
|
+
* @see {@link adaptEnum} for a similar function that works on enums instead of arrays of strings.
|
|
183
|
+
* @alpha
|
|
164
184
|
*/
|
|
165
185
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
166
186
|
export function enumFromStrings<TScope extends string, const Members extends string>(
|
|
@@ -175,7 +195,7 @@ export function enumFromStrings<TScope extends string, const Members extends str
|
|
|
175
195
|
type TOut = Record<Members, ReturnType<typeof singletonSchema<TScope, Members>>>;
|
|
176
196
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
177
197
|
const factoryOut = <TValue extends Members>(value: TValue) => {
|
|
178
|
-
return new out[value](
|
|
198
|
+
return new out[value]() as NodeFromSchema<
|
|
179
199
|
ReturnType<typeof singletonSchema<TScope, TValue>>
|
|
180
200
|
>;
|
|
181
201
|
};
|
|
@@ -192,8 +212,7 @@ export function enumFromStrings<TScope extends string, const Members extends str
|
|
|
192
212
|
return out;
|
|
193
213
|
}
|
|
194
214
|
|
|
195
|
-
// TODO:
|
|
196
|
-
// Tracked by https://github.com/microsoft/TypeScript/issues/58688
|
|
215
|
+
// TODO: This generates an invalid d.ts file if exported due to a bug https://github.com/microsoft/TypeScript/issues/58688.
|
|
197
216
|
// TODO: replace enumFromStrings above with this simpler implementation when the TypeScript bug is resolved.
|
|
198
217
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
199
218
|
function _enumFromStrings2<TScope extends string, const Members extends readonly string[]>(
|