@fluidframework/tree 2.53.1 → 2.60.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/.eslintrc.cjs +0 -19
- package/.mocharc.customBenchmarks.cjs +1 -9
- package/CHANGELOG.md +56 -0
- package/api-report/tree.alpha.api.md +50 -36
- package/api-report/tree.beta.api.md +15 -1
- package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +5 -5
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- package/dist/alpha.d.ts +8 -2
- package/dist/beta.d.ts +3 -0
- package/dist/codec/codec.d.ts +43 -6
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +22 -2
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +4 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/external-utilities/index.d.ts +1 -1
- package/dist/external-utilities/index.d.ts.map +1 -1
- package/dist/external-utilities/index.js +2 -1
- package/dist/external-utilities/index.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.d.ts +6 -1
- package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/dist/external-utilities/typeboxValidator.js +7 -1
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
- 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.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +3 -0
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
- package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +2 -1
- package/dist/feature-libraries/forest-summary/index.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/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
- package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCompressionUtils.js +16 -1
- package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +1 -1
- package/dist/jsonDomainSchema.d.ts.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +23 -6
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +4 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js +3 -0
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +9 -11
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -2
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +13 -0
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/sharedTreeAttributes.d.ts +2 -2
- package/dist/sharedTreeAttributes.js +2 -2
- package/dist/sharedTreeAttributes.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +39 -11
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +79 -19
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
- package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.js +1 -0
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +8 -7
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +68 -74
- 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/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +3 -3
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
- package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +3 -4
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +0 -3
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +12 -0
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +0 -3
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +0 -3
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +11 -80
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +200 -117
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -2
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -2
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +8 -2
- package/lib/beta.d.ts +3 -0
- package/lib/codec/codec.d.ts +43 -6
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +19 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/external-utilities/index.d.ts +1 -1
- package/lib/external-utilities/index.d.ts.map +1 -1
- package/lib/external-utilities/index.js +1 -1
- package/lib/external-utilities/index.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.d.ts +6 -1
- package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/lib/external-utilities/typeboxValidator.js +6 -0
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
- 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.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +3 -0
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
- package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +1 -1
- package/lib/feature-libraries/forest-summary/index.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/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
- package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCompressionUtils.js +15 -0
- package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +1 -1
- package/lib/jsonDomainSchema.d.ts.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +23 -6
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +4 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js +3 -0
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +9 -11
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -2
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +13 -0
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/sharedTreeAttributes.d.ts +2 -2
- package/lib/sharedTreeAttributes.js +2 -2
- package/lib/sharedTreeAttributes.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js +2 -2
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +39 -11
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +79 -19
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
- package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.js +1 -0
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +6 -6
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +68 -74
- 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/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +4 -4
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
- package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +3 -4
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +0 -3
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- 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/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +12 -0
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +0 -3
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +0 -3
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +11 -80
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +201 -118
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -2
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -2
- package/lib/treeFactory.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +52 -7
- package/src/codec/index.ts +4 -0
- package/src/external-utilities/index.ts +1 -1
- package/src/external-utilities/typeboxValidator.ts +7 -1
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
- package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
- package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
- package/src/feature-libraries/chunked-forest/index.ts +2 -0
- package/src/feature-libraries/forest-summary/codec.ts +3 -0
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
- package/src/feature-libraries/forest-summary/index.ts +1 -1
- package/src/feature-libraries/index.ts +5 -1
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
- package/src/feature-libraries/treeCompressionUtils.ts +19 -0
- package/src/index.ts +6 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +1 -1
- package/src/shared-tree/sharedTree.ts +37 -4
- package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
- package/src/shared-tree/tree.ts +3 -0
- package/src/shared-tree/treeAlpha.ts +10 -11
- package/src/shared-tree/treeCheckout.ts +2 -2
- package/src/shared-tree-core/sharedTreeCore.ts +17 -0
- package/src/sharedTreeAttributes.ts +2 -2
- package/src/simple-tree/api/conciseTree.ts +2 -1
- package/src/simple-tree/api/customTree.ts +102 -32
- package/src/simple-tree/api/getJsonSchema.ts +7 -2
- package/src/simple-tree/api/index.ts +3 -0
- package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
- package/src/simple-tree/api/schemaFactory.ts +21 -14
- package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
- package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
- package/src/simple-tree/api/transactionTypes.ts +1 -0
- package/src/simple-tree/api/tree.ts +75 -81
- package/src/simple-tree/api/verboseTree.ts +42 -39
- package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
- package/src/simple-tree/fieldSchema.ts +3 -4
- package/src/simple-tree/index.ts +3 -0
- package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
- package/src/simple-tree/simpleSchema.ts +12 -0
- package/src/simple-tree/toStoredSchema.ts +0 -3
- package/src/tableSchema.ts +261 -243
- package/src/treeFactory.ts +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeChangeFamily.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTreeChangeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAInE,OAAO,EASN,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEN,mBAAmB,EAInB,uBAAuB,EACvB,UAAU,EACV,4BAA4B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGN,cAAc,EACd,SAAS,EACT,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,+BAA+B,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AAwF;IACxF,2CAA2C;IAC3C,+GAA+G;IAC/G,6FAA6F;IAC7F,mHAAmH;IACnH,8EAA8E;IAC9E,uDAAuD;IACvD,mEAAmE;IACnE,kHAAkH;IAClH,4CAA4C;IAC5C,sGAAsG;IACtG,mHAAmH;IACnH,mGAAmG;IAEnG,kFAAkF;IAClF,MAAM,aAAa,GAA+C,IAAI,GAAG,EAAE,CAAC;IAC5E,SAAS,0BAA0B,CAAC,EAAuB;QAC1D,cAAc,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IACD,QAAQ,CAAC,CAAC,mBAAmB,CAC5B,QAAuC;QAEvC,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,EAAE,CAAC;YACV,CAAC;QACF,CAAC;IACF,CAAC;IACD,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,KAAK,CAAC;YAC1B,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,YAAY,EACZ,IAAI,CACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACP,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecFamily, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategy,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: ICodecOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\tnewRevision: RevisionTag | undefined,\n\t\trollbackOf?: RevisionTag,\n\t): SharedTreeChange {\n\t\treturn {\n\t\t\tchanges: change.changes.map((inner) => {\n\t\t\t\treturn inner.type === \"data\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...inner,\n\t\t\t\t\t\t\tinnerChange: this.modularChangeFamily.rebaser.changeRevision(\n\t\t\t\t\t\t\t\tinner.innerChange,\n\t\t\t\t\t\t\t\tnewRevision,\n\t\t\t\t\t\t\t\trollbackOf,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: inner;\n\t\t\t}),\n\t\t};\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
|
|
1
|
+
{"version":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AC,UAAU,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACvB,iBAAiB,GAAG,KAAK,CAAC;YAC1B,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,YAAY,EACZ,IAAI,CACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACP,OAAO,0BAA0B,CAChC,UAAU,EACV,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CAAC,EACjC,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecFamily, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeRebaser,\n\ttype DeltaDetachedNodeId,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TaggedChange,\n\tmapTaggedChange,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\ttype TreeChunk,\n\ttype TreeCompressionStrategyPrivate,\n\tfieldKindConfigurations,\n\tfieldKinds,\n\tmakeModularChangeCodecFamily,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype Mutable,\n\ttype NestedSet,\n\taddToNestedSet,\n\thasSingle,\n\tnestedSetContains,\n} from \"../util/index.js\";\n\nimport { makeSharedTreeChangeCodecFamily } from \"./sharedTreeChangeCodecs.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Implementation of {@link ChangeFamily} that combines edits to fields and schema changes.\n *\n * @sealed\n */\nexport class SharedTreeChangeFamily\n\timplements\n\t\tChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tChangeRebaser<SharedTreeChange>\n{\n\tpublic static readonly emptyChange: SharedTreeChange = {\n\t\tchanges: [],\n\t};\n\n\tpublic readonly codecs: ICodecFamily<SharedTreeChange, ChangeEncodingContext>;\n\tprivate readonly modularChangeFamily: ModularChangeFamily;\n\n\tpublic constructor(\n\t\trevisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tcodecOptions: ICodecOptions,\n\t\tchunkCompressionStrategy?: TreeCompressionStrategyPrivate,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tconst modularChangeCodec = makeModularChangeCodecFamily(\n\t\t\tfieldKindConfigurations,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tcodecOptions,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t\tthis.modularChangeFamily = new ModularChangeFamily(fieldKinds, modularChangeCodec);\n\t\tthis.codecs = makeSharedTreeChangeCodecFamily(\n\t\t\tthis.modularChangeFamily.codecs,\n\t\t\tcodecOptions,\n\t\t);\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<SharedTreeChange>) => void,\n\t): SharedTreeEditBuilder {\n\t\treturn new SharedTreeEditBuilder(\n\t\t\tthis.modularChangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tchangeReceiver,\n\t\t);\n\t}\n\n\tpublic compose(changes: TaggedChange<SharedTreeChange>[]): SharedTreeChange {\n\t\tconst newChanges: Mutable<SharedTreeChange[\"changes\"]> = [];\n\t\tconst dataChangeRun: TaggedChange<ModularChangeset>[] = [];\n\n\t\tconst flushDataChangeRun = (): void => {\n\t\t\tif (dataChangeRun.length > 0) {\n\t\t\t\tnewChanges.push({\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.compose(dataChangeRun),\n\t\t\t\t});\n\t\t\t\tdataChangeRun.length = 0;\n\t\t\t}\n\t\t};\n\n\t\tfor (const topChange of changes) {\n\t\t\tfor (const change of topChange.change.changes) {\n\t\t\t\tif (change.type === \"schema\") {\n\t\t\t\t\tflushDataChangeRun();\n\t\t\t\t\tnewChanges.push(change);\n\t\t\t\t} else {\n\t\t\t\t\tdataChangeRun.push(mapTaggedChange(topChange, change.innerChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tflushDataChangeRun();\n\t\treturn { changes: newChanges };\n\t}\n\n\tpublic invert(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tisRollback: boolean,\n\t\trevision: RevisionTag,\n\t): SharedTreeChange {\n\t\tconst invertInnerChange: (\n\t\t\tinnerChange: SharedTreeChange[\"changes\"][number],\n\t\t) => SharedTreeChange[\"changes\"][number] = (innerChange) => {\n\t\t\tswitch (innerChange.type) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tinnerChange: this.modularChangeFamily.invert(\n\t\t\t\t\t\t\tmapTaggedChange(change, innerChange.innerChange),\n\t\t\t\t\t\t\tisRollback,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\tcase \"schema\": {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"schema\",\n\t\t\t\t\t\tinnerChange: {\n\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\tnew: innerChange.innerChange.schema.old,\n\t\t\t\t\t\t\t\told: innerChange.innerChange.schema.new,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tisInverse: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tfail(0xacc /* Unknown SharedTree change type. */);\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\tchanges: change.change.changes.map(invertInnerChange).reverse(),\n\t\t};\n\t}\n\n\tpublic rebase(\n\t\tchange: TaggedChange<SharedTreeChange>,\n\t\tover: TaggedChange<SharedTreeChange>,\n\t\trevisionMetadata: RevisionMetadataSource,\n\t): SharedTreeChange {\n\t\tif (change.change.changes.length === 0 || over.change.changes.length === 0) {\n\t\t\treturn change.change;\n\t\t}\n\n\t\tif (hasSchemaChange(change.change) || hasSchemaChange(over.change)) {\n\t\t\t// Any SharedTreeChange (a list of sub-changes) that contains a schema change will cause ANY change that rebases over it to conflict.\n\t\t\t// Similarly, any SharedTreeChange containing a schema change will fail to rebase over ANY change.\n\t\t\t// Those two combine to mean: no concurrency with schema changes is supported.\n\t\t\t// This is fine because it's an open problem. Example: a tree with an A at the root and a schema that allows an A | B at the root will\n\t\t\t// become out of schema if a schema changes to restrict root types to just A is concurrent with a data change that sets it to a B.\n\t\t\t// We don't have an efficient way to detect this document-wide and there are varying opinions on restricting schema changes to prevent this.\n\t\t\t// A SharedTreeChange containing a schema change will NOT conflict in a non-concurrency case, as the \"meatless sandwich\" optimization\n\t\t\t// will result in rebase never being called.\n\t\t\treturn SharedTreeChangeFamily.emptyChange;\n\t\t}\n\t\tassert(\n\t\t\thasSingle(change.change.changes) && hasSingle(over.change.changes),\n\t\t\t0x884 /* SharedTreeChange should have exactly one inner change if no schema change is present. */,\n\t\t);\n\n\t\tconst dataChangeIntention = change.change.changes[0];\n\t\tconst dataChangeOver = over.change.changes[0];\n\t\tassert(\n\t\t\tdataChangeIntention.type === \"data\" && dataChangeOver.type === \"data\",\n\t\t\t0x885 /* Data change should be present. */,\n\t\t);\n\n\t\treturn {\n\t\t\tchanges: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: this.modularChangeFamily.rebase(\n\t\t\t\t\t\tmapTaggedChange(change, dataChangeIntention.innerChange),\n\t\t\t\t\t\tmapTaggedChange(over, dataChangeOver.innerChange),\n\t\t\t\t\t\trevisionMetadata,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\tpublic changeRevision(\n\t\tchange: SharedTreeChange,\n\t\tnewRevision: RevisionTag | undefined,\n\t\trollbackOf?: RevisionTag,\n\t): SharedTreeChange {\n\t\treturn {\n\t\t\tchanges: change.changes.map((inner) => {\n\t\t\t\treturn inner.type === \"data\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...inner,\n\t\t\t\t\t\t\tinnerChange: this.modularChangeFamily.rebaser.changeRevision(\n\t\t\t\t\t\t\t\tinner.innerChange,\n\t\t\t\t\t\t\t\tnewRevision,\n\t\t\t\t\t\t\t\trollbackOf,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: inner;\n\t\t\t}),\n\t\t};\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<SharedTreeChange> {\n\t\treturn this;\n\t}\n}\n\nexport function hasSchemaChange(change: SharedTreeChange): boolean {\n\treturn change.changes.some((innerChange) => innerChange.type === \"schema\");\n}\n\nfunction mapDataChanges(\n\tchange: SharedTreeChange,\n\tmap: (change: ModularChangeset) => ModularChangeset,\n): SharedTreeChange {\n\treturn {\n\t\tchanges: change.changes.map((dataOrSchemaChange) => {\n\t\t\tif (dataOrSchemaChange.type === \"data\") {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"data\",\n\t\t\t\t\tinnerChange: map(dataOrSchemaChange.innerChange),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn dataOrSchemaChange;\n\t\t}),\n\t};\n}\n\n/**\n * Produces an equivalent change with an updated set of appropriate refreshers.\n * @param change - The change to compute refreshers for. Not mutated.\n * @param getDetachedNode - retrieves a {@link TreeChunk} for the corresponding detached node id.\n * Is expected to read from a forest in a state that corresponds to the input context of the given change.\n * @returns An equivalent change with an updated set of appropriate refreshers.\n */\nexport function updateRefreshers(\n\tchange: SharedTreeChange,\n\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\trelevantRemovedRootsFromDataChange: (\n\t\ttaggedChange: ModularChangeset,\n\t) => Iterable<DeltaDetachedNodeId>,\n\tupdateDataChangeRefreshers: (\n\t\tchange: ModularChangeset,\n\t\tgetDetachedNode: (id: DeltaDetachedNodeId) => TreeChunk | undefined,\n\t\tremovedRoots: Iterable<DeltaDetachedNodeId>,\n\t\trequireRefreshers: boolean,\n\t) => ModularChangeset,\n): SharedTreeChange {\n\t// Adding refreshers to a SharedTreeChange is not as simple as adding refreshers to each of its data changes.\n\t// This is because earlier data changes affect the state of the forest in ways that can influence the refreshers\n\t// needed for later data changes. This can happen in two ways:\n\t// 1. By removing a tree that is a relevant root to a later data change.\n\t// 2. By changing the contents of a tree that is a relevant root to a later data change.\n\t// (Note that these two cases can compound)\n\t// Thankfully, in both of these cases, refreshers can be omitted from the later data changes because the forest\n\t// applying those data changes is guaranteed to still have have the relevant trees in memory.\n\t// This means that for the first data change, all required refreshers should be added (and none should be missing).\n\t// While for later data changes, we should not include refreshers that either:\n\t// A) were already included in the earlier data changes\n\t// B) correspond to trees that were removed by earlier data changes\n\t// Set A is excluded by tracking which roots have already been included in the earlier data changes, and filtering\n\t// them out from the relevant removed roots.\n\t// Set B is excluded because the `getDetachedNode` is bound to return `undefined` for them, which tell\n\t// `defaultUpdateRefreshers` to ignore. One downside of this approach is that it prevents `defaultUpdateRefreshers`\n\t// from detecting cases where a detached node is missing for another reason (which would be a bug).\n\n\t// The roots that have been included as refreshers across all data changes so far.\n\tconst includedRoots: NestedSet<RevisionTag | undefined, number> = new Map();\n\tfunction getAndRememberDetachedNode(id: DeltaDetachedNodeId): TreeChunk | undefined {\n\t\taddToNestedSet(includedRoots, id.major, id.minor);\n\t\treturn getDetachedNode(id);\n\t}\n\tfunction* filterIncludedRoots(\n\t\ttoFilter: Iterable<DeltaDetachedNodeId>,\n\t): Iterable<DeltaDetachedNodeId> {\n\t\tfor (const id of toFilter) {\n\t\t\tif (!nestedSetContains(includedRoots, id.major, id.minor)) {\n\t\t\t\tyield id;\n\t\t\t}\n\t\t}\n\t}\n\tlet isFirstDataChange = true;\n\treturn mapDataChanges(change, (dataChange) => {\n\t\tconst removedRoots = relevantRemovedRootsFromDataChange(dataChange);\n\t\tif (isFirstDataChange) {\n\t\t\tisFirstDataChange = false;\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tremovedRoots,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t} else {\n\t\t\treturn updateDataChangeRefreshers(\n\t\t\t\tdataChange,\n\t\t\t\tgetAndRememberDetachedNode,\n\t\t\t\tfilterIncludedRoots(removedRoots),\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EAGb,QAAQ,EACR,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AASjC;;;;;GAKG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CACnD;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EAGb,QAAQ,EACR,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AASjC;;;;;GAKG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;I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,OAAO,GAAG,OAAO,QAAQ,EAC/D,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,OAAO,GAAG,OAAO,QAAQ,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,CAAC,KAAK,SAAS,QAAQ,EACtB,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,EAClC,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,IAAI,CAAC;IACR;;;;;;;;;;;;;;;;;;;;OAoBG;IAGH,CAAC,KAAK,SAAS,QAAQ,CAAC,GAAG,CAAC,EAC3B,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAC1C,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,IAAI,CAAC;CACR;AAiBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,KAAK,SAAS,QAAQ,EACtB,KAAK,SAAS,mBAAmB,EACjC,OAAO,EAEP,UAAU,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EACnC,WAAW,EACR,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,QAAQ,CAAC,GAC5C,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,QAAQ,CAAC,EAC/C,aAAa,GAAE,SAAS,qBAAqB,EAAO,GAClD,OAAO,GAAG,OAAO,QAAQ,CAoB3B"}
|
package/lib/shared-tree/tree.js
CHANGED
|
@@ -13,6 +13,9 @@ import { Context } from "../feature-libraries/index.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export const Tree = {
|
|
15
15
|
...treeNodeApi,
|
|
16
|
+
// Note: the implementation details of `createRunTransaction` are deprecated.
|
|
17
|
+
// We have introduced replacement `@alpha` APIs on `TreeBranch`, but until they are `@public`, we can't reasonably deprecated this.
|
|
18
|
+
// Once they have been promoted to public, we can deprecate this API.
|
|
16
19
|
runTransaction: createRunTransaction(),
|
|
17
20
|
contains(parent, child) {
|
|
18
21
|
let toCheck = child;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAKN,oBAAoB,EACpB,WAAW,EACX,QAAQ,GAER,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,2BAA2B,EAC3B,0BAA0B,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA+BxD;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACzB,GAAG,WAAW;IAEd,cAAc,EAAE,oBAAoB,EAAE;IAEtC,QAAQ,CAAC,MAAgB,EAAE,KAAe;QACzC,IAAI,OAAO,GAAyB,KAAK,CAAC;QAC1C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC;AA0UF,uCAAuC;AAEvC,6HAA6H;AAC7H,SAAS,oBAAoB;IAC5B,wHAAwH;IACxH,SAAS,sBAAsB,CAC9B,MAAS;QAET,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,OAAO,MAAoD,CAAC;IAC7D,CAAC;IAED,OAAO,sBAAsB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE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AE,CAAC;QAC7B,MAAM,KAAK,CAAC;IACb,CAAC;IAED,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n\trollback,\n\ttype TransactionConstraint,\n} from \"../simple-tree/index.js\";\n\nimport {\n\taddConstraintsToTransaction,\n\tSchematizingSimpleTreeView,\n} from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\nimport { Context } from \"../feature-libraries/index.js\";\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the {@link (Tree:variable)} export.\n * @system @sealed @public\n */\nexport interface Tree extends TreeNodeApi {\n\t/**\n\t * Run a {@link RunTransaction | transaction}.\n\t */\n\treadonly runTransaction: RunTransaction;\n\t/**\n\t * Check if the subtree defined by `node` contains `other`.\n\t *\n\t * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.\n\t * @remarks\n\t * This includes direct and indirect children:\n\t * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.\n\t *\n\t * `node` is considered to contain itself, so the case where `node === other` returns true.\n\t *\n\t * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.\n\t *\n\t * This check walks the parents of `other` looking for `node`,\n\t * and thus runs in time proportional to the depth of child in the tree.\n\t */\n\tcontains(node: TreeNode, other: TreeNode): boolean;\n}\n\n/**\n * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const Tree: Tree = {\n\t...treeNodeApi,\n\n\trunTransaction: createRunTransaction(),\n\n\tcontains(parent: TreeNode, child: TreeNode): boolean {\n\t\tlet toCheck: TreeNode | undefined = child;\n\t\twhile (toCheck !== undefined) {\n\t\t\tif (toCheck === parent) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ttoCheck = Tree.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A function which runs a transaction in a SharedTree.\n * @privateRemarks\n * This interface exists so that the (generously) overloaded `Tree.runTransaction` function can have the \"rollback\" property hanging off of it.\n * The rollback property being available on the function itself gives users a convenient option for rolling back a transaction without having to import another symbol.\n * @sealed @public\n */\nexport interface RunTransaction {\n\t/**\n\t * The {@link rollback} object used to roll back a transaction.\n\t */\n\treadonly rollback: typeof rollback;\n\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// 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).\n\t// 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.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(tree: TView, transaction: (root: TView[\"root\"]) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n// TODO: Add more constraint types here\n\n/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */\nfunction createRunTransaction(): RunTransaction {\n\t/** A type-safe helper to add a \"rollback\" property (as required by the `RunTransaction` interface) to a given object */\n\tfunction defineRollbackProperty<T extends object>(\n\t\ttarget: T,\n\t): T & { rollback: typeof rollback } {\n\t\tReflect.defineProperty(target, \"rollback\", { value: rollback });\n\t\treturn target as T & { readonly rollback: typeof rollback };\n\t}\n\n\treturn defineRollbackProperty(runTransaction.bind({}));\n}\n\n/**\n * Run the given transaction.\n * @remarks\n * This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.\n */\nexport function runTransaction<\n\tTNode extends TreeNode,\n\tTRoot extends ImplicitFieldSchema,\n\tTResult,\n>(\n\ttreeOrNode: TNode | TreeView<TRoot>,\n\ttransaction:\n\t\t| ((node: TNode) => TResult | typeof rollback)\n\t\t| ((root: TRoot) => TResult | typeof rollback),\n\tpreconditions: readonly TransactionConstraint[] = [],\n): TResult | typeof rollback {\n\tif (treeOrNode instanceof SchematizingSimpleTreeView) {\n\t\tconst t = transaction as (root: TRoot) => TResult | typeof rollback;\n\t\treturn runTransactionInCheckout(\n\t\t\ttreeOrNode.checkout,\n\t\t\t() => t(treeOrNode.root as TRoot),\n\t\t\tpreconditions,\n\t\t);\n\t} else {\n\t\tconst node = treeOrNode as TNode;\n\t\tconst t = transaction as (node: TNode) => TResult | typeof rollback;\n\t\tconst context = getOrCreateInnerNode(node).context;\n\t\tif (context.isHydrated() === false) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.\",\n\t\t\t);\n\t\t}\n\t\tassert(context instanceof Context, 0xbe3 /* Expected context to be a Context instance. */);\n\t\treturn runTransactionInCheckout(context.checkout, () => t(node), preconditions);\n\t}\n}\n\n/**\n * Run the given transaction.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.\n */\nfunction runTransactionInCheckout<TResult>(\n\tcheckout: ITreeCheckout,\n\ttransaction: () => TResult | typeof rollback,\n\tpreconditions: readonly TransactionConstraint[],\n): TResult | typeof rollback {\n\tcheckout.transaction.start();\n\taddConstraintsToTransaction(checkout, false, preconditions);\n\n\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (error) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\t// This might try and modify the tree or trigger events while things are in an inconsistent state.\n\t\t// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).\n\t\tcheckout.transaction.abort();\n\t\tthrow error;\n\t}\n\n\tif (result === rollback) {\n\t\tcheckout.transaction.abort();\n\t} else {\n\t\tcheckout.transaction.commit();\n\t}\n\n\treturn result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAKN,oBAAoB,EACpB,WAAW,EACX,QAAQ,GAER,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,2BAA2B,EAC3B,0BAA0B,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA+BxD;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACzB,GAAG,WAAW;IAEd,6EAA6E;IAC7E,mIAAmI;IACnI,qEAAqE;IACrE,cAAc,EAAE,oBAAoB,EAAE;IAEtC,QAAQ,CAAC,MAAgB,EAAE,KAAe;QACzC,IAAI,OAAO,GAAyB,KAAK,CAAC;QAC1C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC;AA0UF,uCAAuC;AAEvC,6HAA6H;AAC7H,SAAS,oBAAoB;IAC5B,wHAAwH;IACxH,SAAS,sBAAsB,CAC9B,MAAS;QAET,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,OAAO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B,qHAAqH;QACrH,kGAAkG;QAClG,uJAAuJ;QACvJ,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC;IACb,CAAC;IAED,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n\trollback,\n\ttype TransactionConstraint,\n} from \"../simple-tree/index.js\";\n\nimport {\n\taddConstraintsToTransaction,\n\tSchematizingSimpleTreeView,\n} from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\nimport { Context } from \"../feature-libraries/index.js\";\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the {@link (Tree:variable)} export.\n * @system @sealed @public\n */\nexport interface Tree extends TreeNodeApi {\n\t/**\n\t * Run a {@link RunTransaction | transaction}.\n\t */\n\treadonly runTransaction: RunTransaction;\n\t/**\n\t * Check if the subtree defined by `node` contains `other`.\n\t *\n\t * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.\n\t * @remarks\n\t * This includes direct and indirect children:\n\t * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.\n\t *\n\t * `node` is considered to contain itself, so the case where `node === other` returns true.\n\t *\n\t * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.\n\t *\n\t * This check walks the parents of `other` looking for `node`,\n\t * and thus runs in time proportional to the depth of child in the tree.\n\t */\n\tcontains(node: TreeNode, other: TreeNode): boolean;\n}\n\n/**\n * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const Tree: Tree = {\n\t...treeNodeApi,\n\n\t// Note: the implementation details of `createRunTransaction` are deprecated.\n\t// We have introduced replacement `@alpha` APIs on `TreeBranch`, but until they are `@public`, we can't reasonably deprecated this.\n\t// Once they have been promoted to public, we can deprecate this API.\n\trunTransaction: createRunTransaction(),\n\n\tcontains(parent: TreeNode, child: TreeNode): boolean {\n\t\tlet toCheck: TreeNode | undefined = child;\n\t\twhile (toCheck !== undefined) {\n\t\t\tif (toCheck === parent) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ttoCheck = Tree.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A function which runs a transaction in a SharedTree.\n * @privateRemarks\n * This interface exists so that the (generously) overloaded `Tree.runTransaction` function can have the \"rollback\" property hanging off of it.\n * The rollback property being available on the function itself gives users a convenient option for rolling back a transaction without having to import another symbol.\n * @sealed @public\n */\nexport interface RunTransaction {\n\t/**\n\t * The {@link rollback} object used to roll back a transaction.\n\t */\n\treadonly rollback: typeof rollback;\n\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// 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).\n\t// 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.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(tree: TView, transaction: (root: TView[\"root\"]) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * 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.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * 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.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n// TODO: Add more constraint types here\n\n/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */\nfunction createRunTransaction(): RunTransaction {\n\t/** A type-safe helper to add a \"rollback\" property (as required by the `RunTransaction` interface) to a given object */\n\tfunction defineRollbackProperty<T extends object>(\n\t\ttarget: T,\n\t): T & { rollback: typeof rollback } {\n\t\tReflect.defineProperty(target, \"rollback\", { value: rollback });\n\t\treturn target as T & { readonly rollback: typeof rollback };\n\t}\n\n\treturn defineRollbackProperty(runTransaction.bind({}));\n}\n\n/**\n * Run the given transaction.\n * @remarks\n * This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.\n */\nexport function runTransaction<\n\tTNode extends TreeNode,\n\tTRoot extends ImplicitFieldSchema,\n\tTResult,\n>(\n\ttreeOrNode: TNode | TreeView<TRoot>,\n\ttransaction:\n\t\t| ((node: TNode) => TResult | typeof rollback)\n\t\t| ((root: TRoot) => TResult | typeof rollback),\n\tpreconditions: readonly TransactionConstraint[] = [],\n): TResult | typeof rollback {\n\tif (treeOrNode instanceof SchematizingSimpleTreeView) {\n\t\tconst t = transaction as (root: TRoot) => TResult | typeof rollback;\n\t\treturn runTransactionInCheckout(\n\t\t\ttreeOrNode.checkout,\n\t\t\t() => t(treeOrNode.root as TRoot),\n\t\t\tpreconditions,\n\t\t);\n\t} else {\n\t\tconst node = treeOrNode as TNode;\n\t\tconst t = transaction as (node: TNode) => TResult | typeof rollback;\n\t\tconst context = getOrCreateInnerNode(node).context;\n\t\tif (context.isHydrated() === false) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.\",\n\t\t\t);\n\t\t}\n\t\tassert(context instanceof Context, 0xbe3 /* Expected context to be a Context instance. */);\n\t\treturn runTransactionInCheckout(context.checkout, () => t(node), preconditions);\n\t}\n}\n\n/**\n * Run the given transaction.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.\n */\nfunction runTransactionInCheckout<TResult>(\n\tcheckout: ITreeCheckout,\n\ttransaction: () => TResult | typeof rollback,\n\tpreconditions: readonly TransactionConstraint[],\n): TResult | typeof rollback {\n\tcheckout.transaction.start();\n\taddConstraintsToTransaction(checkout, false, preconditions);\n\n\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (error) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\t// This might try and modify the tree or trigger events while things are in an inconsistent state.\n\t\t// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).\n\t\tcheckout.transaction.abort();\n\t\tthrow error;\n\t}\n\n\tif (result === rollback) {\n\t\tcheckout.transaction.abort();\n\t} else {\n\t\tcheckout.transaction.commit();\n\t}\n\n\treturn result;\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
6
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
7
|
-
import { type TreeNode, type Unhydrated, type ImplicitFieldSchema, type InsertableField, type TreeFieldFromImplicitField, type TreeLeafValue, type UnsafeUnknownSchema, type ConciseTree, type TreeEncodingOptions, type VerboseTree, type TreeBranch } from "../simple-tree/index.js";
|
|
7
|
+
import { type TreeNode, type Unhydrated, type ImplicitFieldSchema, type InsertableField, type TreeFieldFromImplicitField, type TreeLeafValue, type UnsafeUnknownSchema, type ConciseTree, type TreeEncodingOptions, type VerboseTree, type TreeBranch, type TreeParsingOptions } from "../simple-tree/index.js";
|
|
8
8
|
import { type JsonCompatible } from "../util/index.js";
|
|
9
9
|
import { type ICodecOptions, type CodecWriteOptions } from "../codec/index.js";
|
|
10
10
|
/**
|
|
@@ -88,7 +88,7 @@ export interface TreeIdentifierUtils {
|
|
|
88
88
|
* Note that {@link (TreeBeta:interface).clone} can create an unhydrated node with unknown optional fields, as it uses the source node's stored schema (if any).
|
|
89
89
|
*
|
|
90
90
|
* Export APIs in this interface include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}
|
|
91
|
-
* if they are using {@link
|
|
91
|
+
* if they are using {@link KeyEncodingOptions.allStoredKeys}.
|
|
92
92
|
*
|
|
93
93
|
* @privateRemarks
|
|
94
94
|
* TODO:
|
|
@@ -139,15 +139,13 @@ export interface TreeAlpha {
|
|
|
139
139
|
* @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
|
|
140
140
|
* @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.
|
|
141
141
|
* @remarks
|
|
142
|
-
* This currently does not support input containing
|
|
143
|
-
* @
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* Does it robustly validate? How do you use it with schema evolution features like staged allowed types and allowUnknownOptionalFields? Which errors are deferred until insertion/hydration?
|
|
148
|
-
* Ensure whatever policy is chosen is documented, enforces, tested and applied consistently to all import code paths.
|
|
142
|
+
* This currently does not support input containing
|
|
143
|
+
* {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields| unknown optional fields} but does support
|
|
144
|
+
* {@link SchemaStaticsAlpha.staged | staged} allowed types.
|
|
145
|
+
* Non-empty default values for fields are currently not supported (must be provided in the input).
|
|
146
|
+
* The content will be validated against the schema and an error will be thrown if out of schema.
|
|
149
147
|
*/
|
|
150
|
-
importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?:
|
|
148
|
+
importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: TreeParsingOptions): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
151
149
|
/**
|
|
152
150
|
* Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.
|
|
153
151
|
*/
|
|
@@ -177,7 +175,7 @@ export interface TreeAlpha {
|
|
|
177
175
|
* If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
|
|
178
176
|
*
|
|
179
177
|
* Always uses "stored" keys.
|
|
180
|
-
* See {@link
|
|
178
|
+
* See {@link KeyEncodingOptions.allStoredKeys} for details.
|
|
181
179
|
* @privateRemarks
|
|
182
180
|
* TODO: It is currently not clear how to work with the idCompressors correctly in the package API.
|
|
183
181
|
* Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeAlpha.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAGN,KAAK,QAAQ,EACb,KAAK,UAAU,EAMf,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAIhB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAEhB,KAAK,UAAU,EAiBf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,MAAM,mBAAmB,CAAC;AAsD3B;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;OAKG;IACH,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAErC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAExE;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7D;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAE7C;;;;;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;IAClC,CAAC;IACD,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,sDAAsD;IACtD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tdebugAssert,\n\tfail,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tasIndex,\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\ttype TreeBranch,\n\tTreeViewConfigurationAlpha,\n\tgetStoredKey,\n\tgetPropertyKeyFromStoredKey,\n\ttreeNodeApi,\n\tgetIdentifierFromNode,\n\tunhydratedFlexTreeFromInsertable,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetOrCreateInnerNode,\n\tNodeKind,\n\ttryGetTreeNodeForField,\n\tisObjectNodeSchema,\n\tisTreeNode,\n\ttoInitialSchema,\n\tconvertField,\n\ttoUnhydratedSchema,\n} from \"../simple-tree/index.js\";\nimport { brand, extractFromOpaque, type JsonCompatible } from \"../util/index.js\";\nimport {\n\tFluidClientVersion,\n\tnoopValidator,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n} from \"../codec/index.js\";\nimport { EmptyKey, type ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype LocalNodeIdentifier,\n\ttype FlexTreeSequenceField,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\nconst identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {\n\tconst nodeIdentifier = getIdentifierFromNode(node, \"uncompressed\");\n\tif (typeof nodeIdentifier === \"number\") {\n\t\tthrow new TypeError(\"identifier should be uncompressed.\");\n\t}\n\treturn nodeIdentifier;\n};\n\nidentifier.shorten = (branch: TreeBranch, nodeIdentifier: string): number | undefined => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\tconst localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);\n\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;\n};\n\nidentifier.lengthen = (branch: TreeBranch, nodeIdentifier: number): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(\n\t\tnodeIdentifier as unknown as LocalNodeIdentifier,\n\t);\n};\n\nidentifier.getShort = (node: TreeNode): number | undefined => {\n\tconst shortIdentifier = getIdentifierFromNode(node, \"compressed\");\n\treturn typeof shortIdentifier === \"number\" ? shortIdentifier : undefined;\n};\n\nidentifier.create = (branch: TreeBranch): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(nodeKeyManager.generateLocalNodeIdentifier());\n};\n\nObject.freeze(identifier);\n\n/**\n * A utility interface for retrieving or converting node identifiers.\n *\n * @remarks\n * This provides methods to:\n *\n * - Retrieve long or short identifiers from nodes\n *\n * - Convert between long identifiers and short identifiers\n *\n * - Generates long identifiers\n *\n * @alpha @sealed\n */\nexport interface TreeIdentifierUtils {\n\t/**\n\t * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.\n\t * If the identifier field does not exist, returns undefined.\n\t *\n\t * @param node - The TreeNode you want to get the identifier from,\n\t */\n\t(node: TreeNode): string | undefined;\n\n\t/**\n\t * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.\n\t * Otherwise, it will return the original string identifier provided.\n\t * If the id does not exist, or is unknown by the id compressor, it returns undefined.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.\n\t *\n\t * @param branch - TreeBranch from where you get the idCompressor to do the decompression.\n\t * @param nodeIdentifier - the stable identifier that needs to be shortened.\n\t */\n\tshorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;\n\n\t/**\n\t * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.\n\t * @param nodeIdentifier - The local identifier that needs to be expanded.\n\t */\n\tlengthen(branch: TreeBranch, nodeIdentifier: number): string;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return undefined.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tgetShort(node: TreeNode): number | undefined;\n\n\t/**\n\t * Creates and returns a long identifier.\n\t * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.\n\t */\n\tcreate(branch: TreeBranch): string;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeAlpha:variable)} singleton.\n *\n * The unhydrated node creation APIs in this interface do not support {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}.\n * This is because unknown optional fields still must have a schema: its just that the schema may come from the document's stored schema.\n * Unhydrated nodes created via this interface are not associated with any document, so there is nowhere for them to get schema for unknown optional fields.\n * Note that {@link (TreeBeta:interface).clone} can create an unhydrated node with unknown optional fields, as it uses the source node's stored schema (if any).\n *\n * Export APIs in this interface include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}\n * if they are using {@link TreeEncodingOptions.useStoredKeys | stored keys}.\n *\n * @privateRemarks\n * TODO:\n * There should be a way to provide a source for defaulted identifiers for unhydrated node creation, either via these APIs or some way to add them to its output later.\n * If an option were added to these APIs, it could also be used to enable unknown optional fields.\n *\n * @system @sealed @alpha\n */\nexport interface TreeAlpha {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.\n\t * @remarks\n\t * This currently does not support input containing {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields| unknown optional fields}.\n\t * @privateRemarks\n\t * See TODOs in {@link TreeEncodingOptions}.\n\t *\n\t * TODO: clarify how this handles out of schema data.\n\t * Does it robustly validate? How do you use it with schema evolution features like staged allowed types and allowUnknownOptionalFields? Which errors are deferred until insertion/hydration?\n\t * Ensure whatever policy is chosen is documented, enforces, tested and applied consistently to all import code paths.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<TreeEncodingOptions>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link TreeEncodingOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public API for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.\n\t * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t *\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t *\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * APIs for creating, converting, and retrieving identifiers.\n\t */\n\treadonly identifier: TreeIdentifierUtils;\n\n\t/**\n\t * The key of the given node under its parent.\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * If `node` is the root node, this returns undefined.\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t */\n\tkey2(node: TreeNode): string | number | undefined;\n\n\t/**\n\t * Gets the child of the given node with the given property key if a child exists under that key.\n\t *\n\t * @remarks {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes will not be returned by this method.\n\t *\n\t * @param node - The parent node whose child is being requested.\n\t * @param key - The property key under the node under which the child is being requested.\n\t * For Object nodes, this is the developer-facing \"property key\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @returns The child node or leaf value under the given key, or `undefined` if no such child exists.\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchild(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;\n\n\t/**\n\t * Gets the children of the provided node, paired with their property keys under the node.\n\t *\n\t * @remarks\n\t * No guarantees are made regarding the order of the children in the returned array.\n\t *\n\t * Optional properties of Object nodes with no value are not included in the result.\n\t *\n\t * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes are not included in the result.\n\t *\n\t * @param node - The node whose children are being requested.\n\t *\n\t * @returns\n\t * An array of pairs of the form `[propertyKey, child]`.\n\t *\n\t * For Array nodes, the `propertyKey` is the index of the child in the array.\n\t *\n\t * For Object nodes, the returned `propertyKey`s are the developer-facing \"property keys\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchildren(\n\t\tnode: TreeNode,\n\t): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.\n * @see {@link (TreeAlpha:interface)}.\n * @alpha\n */\nexport const TreeAlpha: TreeAlpha = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\t// `importConcise` does not need to support all the formats that `create` does.\n\t\t// Perhaps it should error instead of hydrating nodes for example.\n\t\t// For now however, it is a simple wrapper around `create`.\n\t\treturn this.create(schema, data as InsertableField<TSchema>);\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tconvertField(normalizeFieldSchema(schema), toUnhydratedSchema),\n\t\t);\n\t},\n\n\texportConcise,\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {\n\t\tif (isTreeValue(node)) {\n\t\t\treturn node;\n\t\t}\n\t\tconst config: TreeEncodingOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\tconst kernel = getKernel(node);\n\t\treturn verboseFromCursor(cursor, kernel.context, config);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\n\t\t// Grabbing an existing stored schema from the node is important to ensure that unknown optional fields can be preserved.\n\t\t// Note that if the node is unhydrated, this can result in all staged allowed types being included in the schema, which might be undesired.\n\t\tconst storedSchema = isTreeNode(node)\n\t\t\t? getKernel(node).context.flexContext.schema\n\t\t\t: toInitialSchema(schema);\n\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: storedSchema, policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config = new TreeViewConfigurationAlpha({ schema });\n\t\tconst content: ViewContent = {\n\t\t\t// Always use a v1 schema codec for consistency.\n\t\t\t// TODO: reevaluate how staged schema should behave in schema import/export APIs before stabilizing this.\n\t\t\tschema: extractPersistedSchema(config.schema, FluidClientVersion.v2_0, () => true),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n\n\tidentifier,\n\n\tkey2(node: TreeNode): string | number | undefined {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\treturn getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t},\n\n\tchild: (\n\t\tnode: TreeNode,\n\t\tpropertyKey: string | number,\n\t): TreeNode | TreeLeafValue | undefined => {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\n\t\t\t\t// Empty sequence - cannot have children.\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst index =\n\t\t\t\t\ttypeof propertyKey === \"number\"\n\t\t\t\t\t\t? propertyKey\n\t\t\t\t\t\t: asIndex(propertyKey, Number.POSITIVE_INFINITY);\n\n\t\t\t\t// If the key is not a valid index, then there is no corresponding child.\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst childFlexTree = sequence.at(index);\n\n\t\t\t\t// No child at the given index.\n\t\t\t\tif (childFlexTree === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\t\tif (typeof propertyKey !== \"string\") {\n\t\t\t\t\t// Map nodes only support string keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t// Fall through\n\t\t\tcase NodeKind.Record:\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tlet storedKey: string | number = propertyKey;\n\t\t\t\tif (isObjectNodeSchema(schema)) {\n\t\t\t\t\tconst fieldSchema = schema.fields.get(String(propertyKey));\n\t\t\t\t\tif (fieldSchema === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tstoredKey = fieldSchema.storedKey;\n\t\t\t\t}\n\n\t\t\t\tconst field = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc3 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t},\n\n\tchildren(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tconst result: [string | number, TreeNode | TreeLeafValue][] = [];\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tfor (let index = 0; index < sequence.length; index++) {\n\t\t\t\t\tconst childFlexTree = sequence.at(index);\n\t\t\t\t\tassert(childFlexTree !== undefined, 0xbc4 /* Sequence child was undefined. */);\n\t\t\t\t\tconst childTree = getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t\t\tresult.push([index, childTree]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tfor (const [key, flexField] of flexNode.fields) {\n\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\tif (childTreeNode !== undefined) {\n\t\t\t\t\t\tresult.push([key, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbc5 /* Expected object schema. */);\n\t\t\t\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\t\t\t\tconst storedKey = fieldSchema.storedKey;\n\t\t\t\t\tconst flexField = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\t\tif (flexField !== undefined) {\n\t\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildTreeNode !== undefined,\n\t\t\t\t\t\t\t0xbc6 /* Expected child tree node for field. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.push([propertyKey, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc7 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n};\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * Borrow a cursor from a field.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue | undefined,\n): ITreeCursorSynchronous {\n\tif (node === undefined) {\n\t\treturn cursorForMapTreeField([]);\n\t}\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy: borrow cursor from field instead.\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"treeAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,eAAe,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAItE,OAAO,EACN,OAAO,EACP,SAAS,EAGT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EAMpB,iBAAiB,EAEjB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAGjB,sBAAsB,EAEtB,0BAA0B,EAC1B,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,qBAAqB,EACrB,gCAAgC,EAChC,4BAA4B,EAC5B,mCAAmC,EACnC,oBAAoB,EACpB,QAAQ,EACR,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,GAElB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAuB,MAAM,k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AO,MAAM,CAAC;IACf,CAAC;CACD,CAAC;AAYF,SAAS,aAAa,CACrB,IAA0C,EAC1C,OAA6B;IAE7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,MAAM,GAAwB,EAAE,GAAG,OAAO,EAAE,CAAC;IAEnD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,SAAS,+BAA+B,CACvC,IAA8B;IAE9B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;IAC5D,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,oCAAoC,CAC5C,IAA0C;IAE1C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,sDAAsD;IACtD,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tdebugAssert,\n\tfail,\n\tunreachableCase,\n} from \"@fluidframework/core-utils/internal\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tasIndex,\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\ttype TreeBranch,\n\tTreeViewConfigurationAlpha,\n\tgetStoredKey,\n\tgetPropertyKeyFromStoredKey,\n\ttreeNodeApi,\n\tgetIdentifierFromNode,\n\tunhydratedFlexTreeFromInsertable,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetOrCreateInnerNode,\n\tNodeKind,\n\ttryGetTreeNodeForField,\n\tisObjectNodeSchema,\n\tisTreeNode,\n\ttoInitialSchema,\n\tconvertField,\n\ttoUnhydratedSchema,\n\ttype TreeParsingOptions,\n} from \"../simple-tree/index.js\";\nimport { brand, extractFromOpaque, type JsonCompatible } from \"../util/index.js\";\nimport {\n\tFluidClientVersion,\n\tnoopValidator,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n} from \"../codec/index.js\";\nimport { EmptyKey, type ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype LocalNodeIdentifier,\n\ttype FlexTreeSequenceField,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\n\nconst identifier: TreeIdentifierUtils = (node: TreeNode): string | undefined => {\n\tconst nodeIdentifier = getIdentifierFromNode(node, \"uncompressed\");\n\tif (typeof nodeIdentifier === \"number\") {\n\t\tthrow new TypeError(\"identifier should be uncompressed.\");\n\t}\n\treturn nodeIdentifier;\n};\n\nidentifier.shorten = (branch: TreeBranch, nodeIdentifier: string): number | undefined => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\tconst localNodeKey = nodeKeyManager.tryLocalizeNodeIdentifier(nodeIdentifier);\n\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;\n};\n\nidentifier.lengthen = (branch: TreeBranch, nodeIdentifier: number): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(\n\t\tnodeIdentifier as unknown as LocalNodeIdentifier,\n\t);\n};\n\nidentifier.getShort = (node: TreeNode): number | undefined => {\n\tconst shortIdentifier = getIdentifierFromNode(node, \"compressed\");\n\treturn typeof shortIdentifier === \"number\" ? shortIdentifier : undefined;\n};\n\nidentifier.create = (branch: TreeBranch): string => {\n\tconst nodeKeyManager = (branch as SchematizingSimpleTreeView<ImplicitFieldSchema>)\n\t\t.nodeKeyManager;\n\treturn nodeKeyManager.stabilizeNodeIdentifier(nodeKeyManager.generateLocalNodeIdentifier());\n};\n\nObject.freeze(identifier);\n\n/**\n * A utility interface for retrieving or converting node identifiers.\n *\n * @remarks\n * This provides methods to:\n *\n * - Retrieve long or short identifiers from nodes\n *\n * - Convert between long identifiers and short identifiers\n *\n * - Generates long identifiers\n *\n * @alpha @sealed\n */\nexport interface TreeIdentifierUtils {\n\t/**\n\t * Returns the contents of a node's {@link SchemaFactory.identifier} field as a stable identifier.\n\t * If the identifier field does not exist, returns undefined.\n\t *\n\t * @param node - The TreeNode you want to get the identifier from,\n\t */\n\t(node: TreeNode): string | undefined;\n\n\t/**\n\t * Returns the shortened identifier as a number given long identifier known by the id compressor on the branch if possible.\n\t * Otherwise, it will return the original string identifier provided.\n\t * If the id does not exist, or is unknown by the id compressor, it returns undefined.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.lengthen}. If you shorten an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.lengthen}, you will get the original string back.\n\t *\n\t * @param branch - TreeBranch from where you get the idCompressor to do the decompression.\n\t * @param nodeIdentifier - the stable identifier that needs to be shortened.\n\t */\n\tshorten(branch: TreeBranch, nodeIdentifier: string): number | undefined;\n\n\t/**\n\t * Returns the stable id as a string if the identifier is decompressible and known by the id compressor. Otherwise, it will throw an error.\n\t *\n\t * This method is the inverse of {@link TreeIdentifierUtils.shorten}. If you lengthen an identifier\n\t * and then immediately pass it to {@link TreeIdentifierUtils.shorten}, you will get the original short identifier back.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to do the decompression.\n\t * @param nodeIdentifier - The local identifier that needs to be expanded.\n\t */\n\tlengthen(branch: TreeBranch, nodeIdentifier: number): string;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return undefined.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tgetShort(node: TreeNode): number | undefined;\n\n\t/**\n\t * Creates and returns a long identifier.\n\t * The long identifier is a compressible, stable identifier generated by the tree's ID compressor.\n\t *\n\t * @param branch - TreeBranch from where you want to get the id compressor to generate the identifier from.\n\t */\n\tcreate(branch: TreeBranch): string;\n}\n\n/**\n * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeAlpha:variable)} singleton.\n *\n * The unhydrated node creation APIs in this interface do not support {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}.\n * This is because unknown optional fields still must have a schema: its just that the schema may come from the document's stored schema.\n * Unhydrated nodes created via this interface are not associated with any document, so there is nowhere for them to get schema for unknown optional fields.\n * Note that {@link (TreeBeta:interface).clone} can create an unhydrated node with unknown optional fields, as it uses the source node's stored schema (if any).\n *\n * Export APIs in this interface include {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | unknown optional fields}\n * if they are using {@link KeyEncodingOptions.allStoredKeys}.\n *\n * @privateRemarks\n * TODO:\n * There should be a way to provide a source for defaulted identifiers for unhydrated node creation, either via these APIs or some way to add them to its output later.\n * If an option were added to these APIs, it could also be used to enable unknown optional fields.\n *\n * @system @sealed @alpha\n */\nexport interface TreeAlpha {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.\n\t * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.\n\t * @remarks\n\t * This currently does not support input containing\n\t * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields| unknown optional fields} but does support\n\t * {@link SchemaStaticsAlpha.staged | staged} allowed types.\n\t * Non-empty default values for fields are currently not supported (must be provided in the input).\n\t * The content will be validated against the schema and an error will be thrown if out of schema.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeParsingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link KeyEncodingOptions.allStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * Add in a stable public API for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.\n\t * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t *\n\t * 2. A \"try\" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).\n\t *\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * APIs for creating, converting, and retrieving identifiers.\n\t */\n\treadonly identifier: TreeIdentifierUtils;\n\n\t/**\n\t * The key of the given node under its parent.\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * If `node` is the root node, this returns undefined.\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t */\n\tkey2(node: TreeNode): string | number | undefined;\n\n\t/**\n\t * Gets the child of the given node with the given property key if a child exists under that key.\n\t *\n\t * @remarks {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes will not be returned by this method.\n\t *\n\t * @param node - The parent node whose child is being requested.\n\t * @param key - The property key under the node under which the child is being requested.\n\t * For Object nodes, this is the developer-facing \"property key\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @returns The child node or leaf value under the given key, or `undefined` if no such child exists.\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchild(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;\n\n\t/**\n\t * Gets the children of the provided node, paired with their property keys under the node.\n\t *\n\t * @remarks\n\t * No guarantees are made regarding the order of the children in the returned array.\n\t *\n\t * Optional properties of Object nodes with no value are not included in the result.\n\t *\n\t * {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields | Unknown optional fields} of Object nodes are not included in the result.\n\t *\n\t * @param node - The node whose children are being requested.\n\t *\n\t * @returns\n\t * An array of pairs of the form `[propertyKey, child]`.\n\t *\n\t * For Array nodes, the `propertyKey` is the index of the child in the array.\n\t *\n\t * For Object nodes, the returned `propertyKey`s are the developer-facing \"property keys\", not the \"{@link SimpleObjectFieldSchema.storedKey | stored keys}\".\n\t *\n\t * @see {@link (TreeAlpha:interface).key2}\n\t * @see {@link (TreeNodeApi:interface).parent}\n\t */\n\tchildren(\n\t\tnode: TreeNode,\n\t): Iterable<[propertyKey: string | number, child: TreeNode | TreeLeafValue]>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.\n * @see {@link (TreeAlpha:interface)}.\n * @alpha\n */\nexport const TreeAlpha: TreeAlpha = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\tconst mapTree = unhydratedFlexTreeFromInsertable(\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t\tschema,\n\t\t);\n\t\tconst result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);\n\t\treturn result as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\t// `importConcise` does not need to support all the formats that `create` does.\n\t\t// Perhaps it should error instead of hydrating nodes for example.\n\t\t// For now however, it is a simple wrapper around `create`.\n\t\treturn this.create(schema, data as InsertableField<TSchema>);\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeParsingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tconvertField(normalizeFieldSchema(schema), toUnhydratedSchema),\n\t\t);\n\t},\n\n\texportConcise,\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {\n\t\tif (isTreeValue(node)) {\n\t\t\treturn node;\n\t\t}\n\t\tconst config: TreeEncodingOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\tconst kernel = getKernel(node);\n\t\treturn verboseFromCursor(cursor, kernel.context, config);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: { idCompressor?: IIdCompressor } & Pick<\n\t\t\tCodecWriteOptions,\n\t\t\t\"oldestCompatibleClient\"\n\t\t>,\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = fluidVersionToFieldBatchCodecWriteVersion(options.oldestCompatibleClient);\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\n\t\t// Grabbing an existing stored schema from the node is important to ensure that unknown optional fields can be preserved.\n\t\t// Note that if the node is unhydrated, this can result in all staged allowed types being included in the schema, which might be undesired.\n\t\tconst storedSchema = isTreeNode(node)\n\t\t\t? getKernel(node).context.flexContext.schema\n\t\t\t: toInitialSchema(schema);\n\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: storedSchema, policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config = new TreeViewConfigurationAlpha({ schema });\n\t\tconst content: ViewContent = {\n\t\t\t// Always use a v1 schema codec for consistency.\n\t\t\t// TODO: reevaluate how staged schema should behave in schema import/export APIs before stabilizing this.\n\t\t\tschema: extractPersistedSchema(config.schema, FluidClientVersion.v2_0, () => true),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n\n\tidentifier,\n\n\tkey2(node: TreeNode): string | number | undefined {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\treturn getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t},\n\n\tchild: (\n\t\tnode: TreeNode,\n\t\tpropertyKey: string | number,\n\t): TreeNode | TreeLeafValue | undefined => {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\n\t\t\t\t// Empty sequence - cannot have children.\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst index =\n\t\t\t\t\ttypeof propertyKey === \"number\"\n\t\t\t\t\t\t? propertyKey\n\t\t\t\t\t\t: asIndex(propertyKey, Number.POSITIVE_INFINITY);\n\n\t\t\t\t// If the key is not a valid index, then there is no corresponding child.\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst childFlexTree = sequence.at(index);\n\n\t\t\t\t// No child at the given index.\n\t\t\t\tif (childFlexTree === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\t\tif (typeof propertyKey !== \"string\") {\n\t\t\t\t\t// Map nodes only support string keys.\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t// Fall through\n\t\t\tcase NodeKind.Record:\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tlet storedKey: string | number = propertyKey;\n\t\t\t\tif (isObjectNodeSchema(schema)) {\n\t\t\t\t\tconst fieldSchema = schema.fields.get(String(propertyKey));\n\t\t\t\t\tif (fieldSchema === undefined) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tstoredKey = fieldSchema.storedKey;\n\t\t\t\t}\n\n\t\t\t\tconst field = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc3 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t},\n\n\tchildren(node: TreeNode): [propertyKey: string | number, child: TreeNode | TreeLeafValue][] {\n\t\tconst flexNode = getOrCreateInnerNode(node);\n\t\tdebugAssert(\n\t\t\t() => !flexNode.context.isDisposed() || \"The provided tree node has been disposed.\",\n\t\t);\n\n\t\tconst schema = treeNodeApi.schema(node);\n\n\t\tconst result: [string | number, TreeNode | TreeLeafValue][] = [];\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst sequence = flexNode.tryGetField(EmptyKey) as FlexTreeSequenceField | undefined;\n\t\t\t\tif (sequence === undefined) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tfor (let index = 0; index < sequence.length; index++) {\n\t\t\t\t\tconst childFlexTree = sequence.at(index);\n\t\t\t\t\tassert(childFlexTree !== undefined, 0xbc4 /* Sequence child was undefined. */);\n\t\t\t\t\tconst childTree = getOrCreateNodeFromInnerUnboxedNode(childFlexTree);\n\t\t\t\t\tresult.push([index, childTree]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Map:\n\t\t\tcase NodeKind.Record: {\n\t\t\t\tfor (const [key, flexField] of flexNode.fields) {\n\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\tif (childTreeNode !== undefined) {\n\t\t\t\t\t\tresult.push([key, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tassert(isObjectNodeSchema(schema), 0xbc5 /* Expected object schema. */);\n\t\t\t\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\t\t\t\tconst storedKey = fieldSchema.storedKey;\n\t\t\t\t\tconst flexField = flexNode.tryGetField(brand(String(storedKey)));\n\t\t\t\t\tif (flexField !== undefined) {\n\t\t\t\t\t\tconst childTreeNode = tryGetTreeNodeForField(flexField);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildTreeNode !== undefined,\n\t\t\t\t\t\t\t0xbc6 /* Expected child tree node for field. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.push([propertyKey, childTreeNode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tfail(0xbc7 /* Leaf schema associated with non-leaf tree node. */);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(schema.kind);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n};\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (!isTreeNode(node)) {\n\t\treturn node;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst kernel = getKernel(node);\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(cursor, kernel.context, config);\n}\n\n/**\n * Borrow a cursor from a node.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromVerbose(node, {});\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\n/**\n * Borrow a cursor from a field.\n * @remarks\n * The cursor must be put back to its original location before the node is used again.\n */\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue | undefined,\n): ITreeCursorSynchronous {\n\tif (node === undefined) {\n\t\treturn cursorForMapTreeField([]);\n\t}\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy: borrow cursor from field instead.\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import type { Listenable } from "@fluidframework/core-interfaces/internal";
|
|
|
6
6
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
7
7
|
import { type ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
import { type Anchor, type AnchorLocator, type AnchorNode, type AnchorSetRootEvents, type ChangeFamily, type CommitMetadata, type DetachedFieldIndex, type IEditableForest, type IForestSubscription, type JsonableTree, type RevisionTag, type RevisionTagCodec, type TreeStoredSchema, TreeStoredSchemaRepository, type TreeStoredSchemaSubscription, type RevertibleAlphaFactory, type GraphCommit } from "../core/index.js";
|
|
9
|
-
import { type FieldBatchCodec, type
|
|
9
|
+
import { type FieldBatchCodec, type TreeCompressionStrategyPrivate } from "../feature-libraries/index.js";
|
|
10
10
|
import { SharedTreeBranch, type SharedTreeBranchChange, type Transactor } from "../shared-tree-core/index.js";
|
|
11
11
|
import { Breakable, disposeSymbol, type WithBreakable } from "../util/index.js";
|
|
12
12
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
@@ -186,7 +186,7 @@ export declare function createTreeCheckout(idCompressor: IIdCompressor, mintRevi
|
|
|
186
186
|
forest?: IEditableForest;
|
|
187
187
|
fieldBatchCodec?: FieldBatchCodec;
|
|
188
188
|
removedRoots?: DetachedFieldIndex;
|
|
189
|
-
chunkCompressionStrategy?:
|
|
189
|
+
chunkCompressionStrategy?: TreeCompressionStrategyPrivate;
|
|
190
190
|
logger?: ITelemetryLoggerExt;
|
|
191
191
|
breaker?: Breakable;
|
|
192
192
|
disposeForksAfterTransaction?: boolean;
|