@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type Listenable } from "../../events/index.js";
|
|
6
|
-
import { type Brand, type BrandedKey, type BrandedMapSubset, type Opaque } from "../../util/index.js";
|
|
6
|
+
import { type Brand, type BrandedKey, type BrandedMapSubset, type Opaque, ReferenceCountedBase } from "../../util/index.js";
|
|
7
7
|
import type { FieldKey } from "../schema-stored/index.js";
|
|
8
8
|
import type { UpPath } from "./pathTree.js";
|
|
9
9
|
import type { DeltaVisitor } from "./visitDelta.js";
|
|
@@ -185,6 +185,12 @@ export interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents>
|
|
|
185
185
|
*
|
|
186
186
|
*/
|
|
187
187
|
child(key: FieldKey, index: number): UpPath<AnchorNode>;
|
|
188
|
+
/**
|
|
189
|
+
* Gets the child AnchorNode if already exists.
|
|
190
|
+
*
|
|
191
|
+
* Does NOT add a ref, so the returned AnchorNode must be used with care.
|
|
192
|
+
*/
|
|
193
|
+
childIfAnchored(key: FieldKey, index: number): AnchorNode | undefined;
|
|
188
194
|
/**
|
|
189
195
|
* Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.
|
|
190
196
|
* Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.
|
|
@@ -276,8 +282,10 @@ export declare class AnchorSet implements Listenable<AnchorSetRootEvents>, Ancho
|
|
|
276
282
|
private trackInner;
|
|
277
283
|
/**
|
|
278
284
|
* Finds a path node if it already exists.
|
|
285
|
+
*
|
|
286
|
+
* Does not add a ref!
|
|
279
287
|
*/
|
|
280
|
-
|
|
288
|
+
find(path: UpPath): PathNode | undefined;
|
|
281
289
|
/**
|
|
282
290
|
* Returns an equivalent path making as much of it with PathNodes as possible.
|
|
283
291
|
* This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.
|
|
@@ -364,4 +372,153 @@ export declare class AnchorSet implements Listenable<AnchorSetRootEvents>, Ancho
|
|
|
364
372
|
*/
|
|
365
373
|
acquireVisitor(): AnnouncedVisitor & DeltaVisitor;
|
|
366
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Indicates the status of a `NodePath`.
|
|
377
|
+
*/
|
|
378
|
+
declare enum Status {
|
|
379
|
+
/**
|
|
380
|
+
* Indicates the `NodePath` is being maintained and corresponds to a valid
|
|
381
|
+
* (i.e., not removed) node in the document.
|
|
382
|
+
*/
|
|
383
|
+
Alive = 0,
|
|
384
|
+
/**
|
|
385
|
+
* Indicates the `NodePath` is not being maintained by the `AnchorSet`.
|
|
386
|
+
* The `NodePath` may or may not correspond to a valid node in the document.
|
|
387
|
+
*
|
|
388
|
+
* Accessing such a node is invalid.
|
|
389
|
+
* Nodes in this state are retained to detect use-after-free bugs.
|
|
390
|
+
*/
|
|
391
|
+
Disposed = 1,
|
|
392
|
+
/**
|
|
393
|
+
* Indicates the `NodePath` corresponds to a removed node in the document.
|
|
394
|
+
* Such `NodePath`s are not maintained by the `AnchorSet` (other than updating
|
|
395
|
+
* their status to `Disposed` when appropriate).
|
|
396
|
+
*
|
|
397
|
+
* Accessing such a node is invalid.
|
|
398
|
+
* Nodes in this state are retained to detect use-after-free bugs.
|
|
399
|
+
*/
|
|
400
|
+
Dangling = 2
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Tree of anchors.
|
|
404
|
+
*
|
|
405
|
+
* Contains both child and parent pointers, which are kept in sync.
|
|
406
|
+
*
|
|
407
|
+
* Each anchor is equivalent to a path through the tree.
|
|
408
|
+
* This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree
|
|
409
|
+
* prefix-tree style.
|
|
410
|
+
*
|
|
411
|
+
* These anchors are used instead of just holding onto the node objects in forests for several reasons:
|
|
412
|
+
*
|
|
413
|
+
* - Update policy might be more complex than just tracking a node object in the forest.
|
|
414
|
+
*
|
|
415
|
+
* - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.
|
|
416
|
+
*
|
|
417
|
+
* - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the
|
|
418
|
+
* forest.
|
|
419
|
+
*
|
|
420
|
+
* - Forest in general do not need to support up pointers, but they are needed for anchors.
|
|
421
|
+
*
|
|
422
|
+
* Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,
|
|
423
|
+
* plus the parent paths for them.
|
|
424
|
+
*
|
|
425
|
+
* ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).
|
|
426
|
+
* Kept alive as if any of the follow are true:
|
|
427
|
+
* 1. there are children.
|
|
428
|
+
* 2. refcount is non-zero.
|
|
429
|
+
* 3. events are registered.
|
|
430
|
+
*/
|
|
431
|
+
declare class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorNode {
|
|
432
|
+
readonly anchorSet: AnchorSet;
|
|
433
|
+
parentField: FieldKey;
|
|
434
|
+
parentIndex: number;
|
|
435
|
+
/**
|
|
436
|
+
* The parent of this `PathNode` (an up pointer in the `PathNode` tree).
|
|
437
|
+
* If the status of this node is `Alive`, then there must be a corresponding down pointer from the
|
|
438
|
+
* `parentPath` node to this node.
|
|
439
|
+
* When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.
|
|
440
|
+
*
|
|
441
|
+
* When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent
|
|
442
|
+
* (updating down pointers first), but must ensure they are consistent before the editing operation returns
|
|
443
|
+
* to non-`AnchorSet` code.
|
|
444
|
+
* This consistency guarantee only applies to nodes that are `Alive`.
|
|
445
|
+
*/
|
|
446
|
+
parentPath: PathNode | undefined;
|
|
447
|
+
status: Status;
|
|
448
|
+
/**
|
|
449
|
+
* Event emitter for this anchor.
|
|
450
|
+
*/
|
|
451
|
+
readonly events: Listenable<AnchorEvents> & import("../../events/emitter.js").IEmitter<AnchorEvents> & import("../../events/emitter.js").HasListeners<AnchorEvents>;
|
|
452
|
+
/**
|
|
453
|
+
* PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.
|
|
454
|
+
* Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)
|
|
455
|
+
*
|
|
456
|
+
* Performance Note:
|
|
457
|
+
* Large child lists could be updated more efficiently here using a data-structure optimized
|
|
458
|
+
* for efficient prefix sum updates, such as a Fenwick tree or Finger tree.
|
|
459
|
+
* This would be complicated by the need for parent pointers (including indexes),
|
|
460
|
+
* but is possible to do.
|
|
461
|
+
*/
|
|
462
|
+
readonly children: Map<FieldKey, PathNode[]>;
|
|
463
|
+
readonly slots: BrandedMapSubset<AnchorSlot<any>>;
|
|
464
|
+
/**
|
|
465
|
+
* Construct a PathNode with refcount 1.
|
|
466
|
+
* @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet
|
|
467
|
+
* to early out UpPath walking.
|
|
468
|
+
*/
|
|
469
|
+
constructor(anchorSet: AnchorSet, parentField: FieldKey, parentIndex: number,
|
|
470
|
+
/**
|
|
471
|
+
* The parent of this `PathNode` (an up pointer in the `PathNode` tree).
|
|
472
|
+
* If the status of this node is `Alive`, then there must be a corresponding down pointer from the
|
|
473
|
+
* `parentPath` node to this node.
|
|
474
|
+
* When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.
|
|
475
|
+
*
|
|
476
|
+
* When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent
|
|
477
|
+
* (updating down pointers first), but must ensure they are consistent before the editing operation returns
|
|
478
|
+
* to non-`AnchorSet` code.
|
|
479
|
+
* This consistency guarantee only applies to nodes that are `Alive`.
|
|
480
|
+
*/
|
|
481
|
+
parentPath: PathNode | undefined);
|
|
482
|
+
on<K extends keyof AnchorEvents>(eventName: K, listener: AnchorEvents[K]): () => void;
|
|
483
|
+
child(key: FieldKey, index: number): UpPath<AnchorNode>;
|
|
484
|
+
getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];
|
|
485
|
+
/**
|
|
486
|
+
* @returns true iff this PathNode is the special root node that sits above all the detached fields.
|
|
487
|
+
* In this case, the fields are detached sequences.
|
|
488
|
+
* Note that the special root node should never appear in an UpPath
|
|
489
|
+
* since UpPaths represent this root as `undefined`.
|
|
490
|
+
*/
|
|
491
|
+
private isRoot;
|
|
492
|
+
get parent(): PathNode | undefined;
|
|
493
|
+
addRef(count?: number): void;
|
|
494
|
+
removeRef(count?: number): void;
|
|
495
|
+
protected onUnreferenced(): void;
|
|
496
|
+
/**
|
|
497
|
+
* Gets a child, adding a ref to it.
|
|
498
|
+
* Creates child (with 1 ref) if needed.
|
|
499
|
+
*/
|
|
500
|
+
getOrCreateChild(key: FieldKey, index: number): PathNode;
|
|
501
|
+
childIfAnchored(key: FieldKey, index: number): PathNode | undefined;
|
|
502
|
+
/**
|
|
503
|
+
* Removes reference from this to `child`.
|
|
504
|
+
* Since PathNodes are doubly linked,
|
|
505
|
+
* the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).
|
|
506
|
+
*/
|
|
507
|
+
removeChild(child: PathNode): void;
|
|
508
|
+
/**
|
|
509
|
+
* Call this after directly editing the child array for a field to be empty.
|
|
510
|
+
* Handles cleaning up unneeded data
|
|
511
|
+
* (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)
|
|
512
|
+
*/
|
|
513
|
+
afterEmptyField(key: FieldKey): void;
|
|
514
|
+
/**
|
|
515
|
+
* If node is no longer needed (has no references, no children and no events):
|
|
516
|
+
* removes this from parent if alive, and sets this to disposed.
|
|
517
|
+
* Must only be called when .
|
|
518
|
+
*
|
|
519
|
+
* Allowed when dangling (but not when disposed).
|
|
520
|
+
*/
|
|
521
|
+
private considerDispose;
|
|
522
|
+
}
|
|
523
|
+
export {};
|
|
367
524
|
//# sourceMappingURL=anchorSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorSet.d.ts","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"anchorSet.d.ts","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AA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;IAO9E;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IAId,IAAW,MAAM,IAAI,QAAQ,GAAG,SAAS,CAWxC;IAEM,MAAM,CAAC,KAAK,SAAI,GAAG,IAAI;IAKvB,SAAS,CAAC,KAAK,SAAI,GAAG,IAAI;IAOjC,SAAS,CAAC,cAAc,IAAI,IAAI;IAIhC;;;OAGG;IACI,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ;IAmBxD,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAO1E;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAczC;;;;OAIG;IACI,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAM3C;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CASvB"}
|
|
@@ -157,6 +157,8 @@ export class AnchorSet {
|
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Finds a path node if it already exists.
|
|
160
|
+
*
|
|
161
|
+
* Does not add a ref!
|
|
160
162
|
*/
|
|
161
163
|
find(path) {
|
|
162
164
|
if (path instanceof PathNode) {
|
|
@@ -166,7 +168,7 @@ export class AnchorSet {
|
|
|
166
168
|
}
|
|
167
169
|
const parent = path.parent ?? this.root;
|
|
168
170
|
const parentPath = this.find(parent);
|
|
169
|
-
return parentPath?.
|
|
171
|
+
return parentPath?.childIfAnchored(path.parentField, path.parentIndex);
|
|
170
172
|
}
|
|
171
173
|
/**
|
|
172
174
|
* Returns an equivalent path making as much of it with PathNodes as possible.
|
|
@@ -193,7 +195,7 @@ export class AnchorSet {
|
|
|
193
195
|
while ((wrapWith = stack.pop()) !== undefined) {
|
|
194
196
|
if (path === undefined || path instanceof PathNode) {
|
|
195
197
|
// If path already has an anchor, get an anchor for it's child if there is one:
|
|
196
|
-
const child = (path ?? this.root).
|
|
198
|
+
const child = (path ?? this.root).childIfAnchored(wrapWith.parentField, wrapWith.parentIndex);
|
|
197
199
|
if (child !== undefined) {
|
|
198
200
|
path = child;
|
|
199
201
|
continue;
|
|
@@ -833,7 +835,11 @@ class PathNode extends ReferenceCountedBase {
|
|
|
833
835
|
}
|
|
834
836
|
child(key, index) {
|
|
835
837
|
// Fast path: if child exists, return it.
|
|
836
|
-
return (this.
|
|
838
|
+
return (this.childIfAnchored(key, index) ?? {
|
|
839
|
+
parent: this,
|
|
840
|
+
parentField: key,
|
|
841
|
+
parentIndex: index,
|
|
842
|
+
});
|
|
837
843
|
}
|
|
838
844
|
getOrCreateChildRef(key, index) {
|
|
839
845
|
const anchor = this.anchorSet.track(this.child(key, index));
|
|
@@ -882,8 +888,7 @@ class PathNode extends ReferenceCountedBase {
|
|
|
882
888
|
field = [];
|
|
883
889
|
this.children.set(key, field);
|
|
884
890
|
}
|
|
885
|
-
|
|
886
|
-
let child = field.find((c) => c.parentIndex === index);
|
|
891
|
+
let child = binaryFind(field, index);
|
|
887
892
|
if (child === undefined) {
|
|
888
893
|
child = new PathNode(this.anchorSet, key, index, this);
|
|
889
894
|
field.push(child);
|
|
@@ -895,15 +900,10 @@ class PathNode extends ReferenceCountedBase {
|
|
|
895
900
|
}
|
|
896
901
|
return child;
|
|
897
902
|
}
|
|
898
|
-
|
|
899
|
-
* Gets a child if it exists.
|
|
900
|
-
* Does NOT add a ref.
|
|
901
|
-
*/
|
|
902
|
-
tryGetChild(key, index) {
|
|
903
|
+
childIfAnchored(key, index) {
|
|
903
904
|
assert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);
|
|
904
905
|
const field = this.children.get(key);
|
|
905
|
-
|
|
906
|
-
return field?.find((c) => c.parentIndex === index);
|
|
906
|
+
return field === undefined ? undefined : binaryFind(field, index);
|
|
907
907
|
}
|
|
908
908
|
/**
|
|
909
909
|
* Removes reference from this to `child`.
|
|
@@ -950,4 +950,46 @@ class PathNode extends ReferenceCountedBase {
|
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
+
/**
|
|
954
|
+
* Find a child PathNode by index using a binary search.
|
|
955
|
+
* @param sorted - array of PathNode's sorted by parentIndex.
|
|
956
|
+
* @param index - index being looked for.
|
|
957
|
+
* @returns child with the requested parentIndex, or undefined.
|
|
958
|
+
* @privateRemarks
|
|
959
|
+
* This function is very commonly used with small arrays (length 0 or one for all non sequence fields),
|
|
960
|
+
* and is currently a hot path due to how flex tree leaves to excessive cursor to anchor and anchor to cursor translations,
|
|
961
|
+
* both of which walk paths down the AnchorSet.
|
|
962
|
+
* Additionally current usages tends to fully populate the anchor tree leading the correct array index to be the requested parent index.
|
|
963
|
+
* This makes the performance of this performance both important in small cases and easy to overly tune to the current usage patterns.
|
|
964
|
+
* This lead to not implementing a general purpose reusable binary search.
|
|
965
|
+
* Once this function is not so heavily overused due to inefficient patterns in flex-tree,
|
|
966
|
+
* replacing it with a standard binary search is likely fine.
|
|
967
|
+
* Until then, care and benchmarking should be used when messing with this function.
|
|
968
|
+
*/
|
|
969
|
+
function binaryFind(sorted, index) {
|
|
970
|
+
// Try guessing the list is not sparse as a starter:
|
|
971
|
+
const guess = sorted[index];
|
|
972
|
+
if (guess !== undefined && guess.parentIndex === index) {
|
|
973
|
+
return guess;
|
|
974
|
+
}
|
|
975
|
+
// inclusive
|
|
976
|
+
let min = 0;
|
|
977
|
+
// exclusive
|
|
978
|
+
let max = sorted.length;
|
|
979
|
+
while (min !== max) {
|
|
980
|
+
const mid = Math.floor((min + max) / 2);
|
|
981
|
+
const item = sorted[mid];
|
|
982
|
+
const found = item.parentIndex;
|
|
983
|
+
if (found === index) {
|
|
984
|
+
return item; // Found the target, return it.
|
|
985
|
+
}
|
|
986
|
+
else if (found > index) {
|
|
987
|
+
max = mid; // Continue search on lower half.
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
min = mid + 1; // Continue search on left half.
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
return undefined; // If we reach here, target is not in array (or array was not sorted)
|
|
994
|
+
}
|
|
953
995
|
//# sourceMappingURL=anchorSet.js.map
|