@fluidframework/tree 2.110.0 → 2.112.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/.vscode/settings.json +1 -0
- package/CHANGELOG.md +193 -0
- package/api-report/tree.alpha.api.md +96 -36
- package/api-report/tree.beta.api.md +39 -1
- package/api-report/tree.legacy.beta.api.md +39 -1
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- package/dist/componentApi.d.ts +198 -0
- package/dist/componentApi.d.ts.map +1 -0
- package/dist/componentApi.js +138 -0
- package/dist/componentApi.js.map +1 -0
- package/dist/core/change-family/changeFamily.d.ts +3 -10
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/rebase/types.d.ts +2 -2
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
- package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js +4 -2
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/entrypoints/beta.d.ts +1 -1
- package/dist/entrypoints/beta.d.ts.map +1 -1
- package/dist/entrypoints/beta.js.map +1 -1
- package/dist/entrypoints/legacy.d.ts +1 -1
- package/dist/entrypoints/legacy.d.ts.map +1 -1
- package/dist/entrypoints/legacy.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -20
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +13 -32
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +76 -9
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +11 -0
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.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 +2 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +3 -3
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -6
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -0
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +3 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts +22 -3
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +48 -5
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.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/independentView.d.ts +17 -4
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +15 -12
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +3 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +6 -5
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +6 -3
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/serializedChange.d.ts +41 -0
- package/dist/shared-tree/serializedChange.d.ts.map +1 -0
- package/dist/shared-tree/serializedChange.js +87 -0
- package/dist/shared-tree/serializedChange.js.map +1 -0
- package/dist/shared-tree/sharedTree.d.ts +18 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +9 -4
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/transactionMinimize.d.ts +35 -0
- package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
- package/dist/shared-tree/transactionMinimize.js +65 -0
- package/dist/shared-tree/transactionMinimize.js.map +1 -0
- package/dist/shared-tree/transactionPostProcessor.d.ts +28 -0
- package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -0
- package/dist/shared-tree/transactionPostProcessor.js +28 -0
- package/dist/shared-tree/transactionPostProcessor.js.map +1 -0
- package/dist/shared-tree/treeAlpha.js +3 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +19 -13
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +54 -71
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.d.ts +5 -5
- package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +6 -3
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +35 -14
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -2
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -4
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +5 -9
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +5 -10
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +1 -1
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +3 -2
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +1 -1
- package/dist/shared-tree-core/messageFormat.js +1 -1
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
- package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageTypes.d.ts +1 -0
- package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/dist/shared-tree-core/messageTypes.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +27 -12
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +84 -9
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +88 -7
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -44
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactory.js +2 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +3 -4
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +1 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +91 -28
- 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 +108 -24
- 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/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -7
- package/dist/simple-tree/core/treeNodeSchema.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 +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +3 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +69 -758
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +275 -322
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/text/textDomainFormattedDefault.d.ts +273 -0
- package/dist/text/textDomainFormattedDefault.d.ts.map +1 -0
- package/dist/text/textDomainFormattedDefault.js +94 -0
- package/dist/text/textDomainFormattedDefault.js.map +1 -0
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +16 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +9 -1
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/compressedIds.d.ts +185 -0
- package/dist/util/compressedIds.d.ts.map +1 -0
- package/dist/util/compressedIds.js +164 -0
- package/dist/util/compressedIds.js.map +1 -0
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +10 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +16 -3
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/nestedSet.d.ts +1 -1
- package/dist/util/nestedSet.d.ts.map +1 -1
- package/dist/util/nestedSet.js.map +1 -1
- package/dist/util/utils.d.ts +0 -6
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +1 -15
- package/dist/util/utils.js.map +1 -1
- package/lib/componentApi.d.ts +198 -0
- package/lib/componentApi.d.ts.map +1 -0
- package/lib/componentApi.js +135 -0
- package/lib/componentApi.js.map +1 -0
- package/lib/core/change-family/changeFamily.d.ts +3 -10
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/rebase/types.d.ts +2 -2
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
- package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/entrypoints/beta.d.ts +1 -1
- package/lib/entrypoints/beta.d.ts.map +1 -1
- package/lib/entrypoints/beta.js.map +1 -1
- package/lib/entrypoints/legacy.d.ts +1 -1
- package/lib/entrypoints/legacy.d.ts.map +1 -1
- package/lib/entrypoints/legacy.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -20
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +14 -33
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +73 -28
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +75 -9
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +12 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.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 +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +3 -3
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -6
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -0
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -0
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -10
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts +22 -3
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +48 -5
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.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/independentView.d.ts +17 -4
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +13 -10
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +3 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +6 -5
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +7 -4
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/serializedChange.d.ts +41 -0
- package/lib/shared-tree/serializedChange.d.ts.map +1 -0
- package/lib/shared-tree/serializedChange.js +84 -0
- package/lib/shared-tree/serializedChange.js.map +1 -0
- package/lib/shared-tree/sharedTree.d.ts +18 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +10 -5
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/transactionMinimize.d.ts +35 -0
- package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
- package/lib/shared-tree/transactionMinimize.js +62 -0
- package/lib/shared-tree/transactionMinimize.js.map +1 -0
- package/lib/shared-tree/transactionPostProcessor.d.ts +28 -0
- package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -0
- package/lib/shared-tree/transactionPostProcessor.js +23 -0
- package/lib/shared-tree/transactionPostProcessor.js.map +1 -0
- package/lib/shared-tree/treeAlpha.js +3 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +19 -13
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +36 -53
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.d.ts +5 -5
- package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +6 -3
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +36 -15
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -2
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -5
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +5 -9
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +5 -10
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +1 -1
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +1 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +1 -1
- package/lib/shared-tree-core/messageFormat.js +1 -1
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
- package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageTypes.d.ts +1 -0
- package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/lib/shared-tree-core/messageTypes.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +28 -13
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +84 -9
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +87 -6
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +29 -42
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +4 -5
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -3
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +91 -28
- 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 +108 -24
- 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/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -7
- package/lib/simple-tree/core/treeNodeSchema.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/array/arrayNode.d.ts +83 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/lib/text/index.d.ts +1 -0
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +1 -0
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +69 -758
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +277 -324
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/text/textDomainFormattedDefault.d.ts +273 -0
- package/lib/text/textDomainFormattedDefault.d.ts.map +1 -0
- package/lib/text/textDomainFormattedDefault.js +91 -0
- package/lib/text/textDomainFormattedDefault.js.map +1 -0
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +16 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +9 -1
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/compressedIds.d.ts +185 -0
- package/lib/util/compressedIds.d.ts.map +1 -0
- package/lib/util/compressedIds.js +154 -0
- package/lib/util/compressedIds.js.map +1 -0
- package/lib/util/index.d.ts +2 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +17 -4
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/nestedSet.d.ts +1 -1
- package/lib/util/nestedSet.d.ts.map +1 -1
- package/lib/util/nestedSet.js.map +1 -1
- package/lib/util/utils.d.ts +0 -6
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +0 -13
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/componentApi.ts +354 -0
- package/src/core/change-family/changeFamily.ts +3 -12
- package/src/core/rebase/types.ts +2 -2
- package/src/core/schema-stored/storedSchemaRepository.ts +2 -2
- package/src/entrypoints/alpha.ts +15 -8
- package/src/entrypoints/beta.ts +8 -0
- package/src/entrypoints/legacy.ts +8 -0
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +22 -72
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +110 -41
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +32 -4
- package/src/feature-libraries/chunked-forest/codec/index.ts +1 -0
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +7 -19
- package/src/feature-libraries/chunked-forest/index.ts +3 -0
- package/src/feature-libraries/forest-summary/codec.ts +5 -3
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -5
- package/src/feature-libraries/index.ts +5 -0
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +13 -9
- package/src/feature-libraries/schemaChecker.ts +86 -9
- package/src/index.ts +16 -8
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +40 -15
- package/src/shared-tree/index.ts +4 -0
- package/src/shared-tree/schematizingTreeView.ts +40 -30
- package/src/shared-tree/serializedChange.ts +127 -0
- package/src/shared-tree/sharedTree.ts +32 -4
- package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
- package/src/shared-tree/transactionMinimize.ts +74 -0
- package/src/shared-tree/transactionPostProcessor.ts +40 -0
- package/src/shared-tree/treeAlpha.ts +3 -3
- package/src/shared-tree/treeCheckout.ts +103 -101
- package/src/shared-tree/unhydratedTreeContext.ts +18 -15
- package/src/shared-tree-core/editManager.ts +42 -6
- package/src/shared-tree-core/editManagerCodecs.ts +3 -2
- package/src/shared-tree-core/editManagerCodecsCommons.ts +10 -14
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -2
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -2
- package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
- package/src/shared-tree-core/editManagerSummarizer.ts +5 -9
- package/src/shared-tree-core/index.ts +8 -5
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
- package/src/shared-tree-core/messageFormat.ts +1 -1
- package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
- package/src/shared-tree-core/messageTypes.ts +1 -0
- package/src/shared-tree-core/sharedTreeCore.ts +36 -12
- package/src/shared-tree-core/transaction.ts +165 -18
- package/src/simple-tree/api/index.ts +14 -10
- package/src/simple-tree/api/schemaCompatibilityTester.ts +36 -48
- package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
- package/src/simple-tree/api/schemaFactory.ts +2 -2
- package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
- package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -5
- package/src/simple-tree/api/storedSchema.ts +2 -3
- package/src/simple-tree/api/transactionTypes.ts +111 -39
- package/src/simple-tree/api/tree.ts +165 -49
- package/src/simple-tree/api/treeBeta.ts +2 -0
- package/src/simple-tree/api/typesUnsafe.ts +2 -1
- package/src/simple-tree/core/treeNodeSchema.ts +7 -7
- package/src/simple-tree/index.ts +13 -9
- package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
- package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
- package/src/text/index.ts +1 -0
- package/src/text/textDomainFormatted.ts +520 -415
- package/src/text/textDomainFormattedDefault.ts +150 -0
- package/src/treeFactory.ts +1 -1
- package/src/util/breakable.ts +8 -1
- package/src/util/compressedIds.ts +304 -0
- package/src/util/index.ts +18 -1
- package/src/util/nestedMap.ts +21 -4
- package/src/util/nestedSet.ts +1 -1
- package/src/util/utils.ts +0 -18
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Utilities for composing application "components" which contribute to a shared configuration.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Nothing in this namespace is specific to tree schema,
|
|
10
|
+
* however it is designed to be able to handle the needs of components which work with {@link TreeSchema}.
|
|
11
|
+
*
|
|
12
|
+
* This is mainly used to implement "open polymorphism", where the set of allowed types
|
|
13
|
+
* for a field or collection can be extended by independently authored libraries (components) instead of being
|
|
14
|
+
* fixed up front.
|
|
15
|
+
*
|
|
16
|
+
* This basically amounts to dependency injection, where the "injection" is done at "composition" time to build the schema.
|
|
17
|
+
*
|
|
18
|
+
* Tree's schema do not natively support open polymorphism: all possible implementations must be explicitly listed.
|
|
19
|
+
* These tools work around these limitations by carefully controlling evaluation order:
|
|
20
|
+
* the source code can be structured in an open polymorphism style which at runtime evaluates into closed polymorphism
|
|
21
|
+
* by having each component register its implementations into a central collection (typically an
|
|
22
|
+
* {@link AllowedTypes} array).
|
|
23
|
+
*
|
|
24
|
+
* Each component is expressed as a {@link Component.Factory}: a function which receives a lazy reference to the
|
|
25
|
+
* composed configuration and returns the content that component contributes.
|
|
26
|
+
* Because the configuration is provided lazily, components may reference (including recursively) types contributed by
|
|
27
|
+
* other components, as long as nothing evaluates the lazy references until composition has completed.
|
|
28
|
+
* Use {@link Component.(compose:1)} to combine a set of components into a {@link Component.Composed}.
|
|
29
|
+
*
|
|
30
|
+
* See {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/openPolymorphism.integration.ts|openPolymorphism.integration.ts} for worked examples of this pattern.
|
|
31
|
+
*
|
|
32
|
+
* @privateRemarks
|
|
33
|
+
* The examples and integration tests for this pattern live in `openPolymorphism.integration.ts`.
|
|
34
|
+
* Those tests and the docs here should be kept in sync.
|
|
35
|
+
*
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
export declare namespace Component {
|
|
39
|
+
/**
|
|
40
|
+
* A function which takes in a lazy configuration and returns the content a component contributes.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* The lazy configuration allows the component to reference items from the composed configuration, which can
|
|
44
|
+
* include items the component itself contributes (allowing recursive references between components).
|
|
45
|
+
*
|
|
46
|
+
* The execution of the factory must not evaluate `lazyConfiguration` (doing so will error):
|
|
47
|
+
* instead the returned `TComponent` can capture `lazyConfiguration` and evaluate it at a later time
|
|
48
|
+
* (after all components have been composed).
|
|
49
|
+
*
|
|
50
|
+
* @typeParam TComponent - The content a component contributes.
|
|
51
|
+
* @typeParam TConfig - The composed configuration type made available to components.
|
|
52
|
+
* Defaults to the {@link Component.Composed} produced by composition: the common case where
|
|
53
|
+
* components read composed content directly from the composition and no custom configuration type is needed.
|
|
54
|
+
*
|
|
55
|
+
* @input
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
58
|
+
type Factory<TComponent, TConfig = ComposedDefault<TComponent>> = (lazyConfiguration: () => TConfig) => TComponent;
|
|
59
|
+
/**
|
|
60
|
+
* A function which returns an array of lazy values which each evaluate to `T`.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* This mirrors the shape of {@link AllowedTypes} where all of the values are lazy:
|
|
64
|
+
* the outer function and inner functions defer evaluation until after composition is complete.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam T - The type each lazy value evaluates to.
|
|
67
|
+
*
|
|
68
|
+
* @alpha
|
|
69
|
+
*/
|
|
70
|
+
type LazyArray<T> = () => readonly (() => T)[];
|
|
71
|
+
/**
|
|
72
|
+
* Wrap a 0 argument function to cache the result.
|
|
73
|
+
* @remarks
|
|
74
|
+
* Do not use for impure functions.
|
|
75
|
+
*
|
|
76
|
+
* Generally {@link Component} utilities have built in caching in most cases,
|
|
77
|
+
* but this is occasionally helpful when manually implementing laziness.
|
|
78
|
+
*
|
|
79
|
+
* Note that this takes a different approach than use in {@link evaluateLazySchema} where the function evaluation is done using a utility that adds caching.
|
|
80
|
+
*
|
|
81
|
+
* @param factory - The factory function to memoize.
|
|
82
|
+
* @returns A function that returns the cached result of the factory.
|
|
83
|
+
* @alpha
|
|
84
|
+
*/
|
|
85
|
+
const memoize: <T>(factory: () => T) => (() => T);
|
|
86
|
+
/**
|
|
87
|
+
* An item which can be configured (evaluated) against a composed configuration to produce a result.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* Use {@link Component.Composed.getConfigured} to evaluate a `Configurable`.
|
|
91
|
+
* The result is cached, so a given `Configurable` is only evaluated once per composition.
|
|
92
|
+
*
|
|
93
|
+
* @typeParam TConfigPartial - The configuration type made available when configuring.
|
|
94
|
+
* @typeParam TResult - The result produced by configuring.
|
|
95
|
+
* @typeParam TComponent - The content components contribute.
|
|
96
|
+
*
|
|
97
|
+
* @alpha
|
|
98
|
+
*/
|
|
99
|
+
interface Configurable<TConfigPartial, out TResult, TComponent> {
|
|
100
|
+
/**
|
|
101
|
+
* Produce the configured result.
|
|
102
|
+
* @param config - The composed configuration.
|
|
103
|
+
* @param components - The composed components.
|
|
104
|
+
*/
|
|
105
|
+
configure(config: TConfigPartial, components: Composed<TComponent, TConfigPartial>): TResult;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Combine multiple {@link Component.Factory|components} into a single {@link Component.Composed}.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* The {@link Component.Composed} itself is used as the configuration made available to components:
|
|
112
|
+
* the simple case where components read composed content directly from the composition.
|
|
113
|
+
* To produce a custom aggregated configuration, use the overload which takes a `lazyConfiguration` builder.
|
|
114
|
+
*
|
|
115
|
+
* @param allComponents - The components to compose.
|
|
116
|
+
* @returns The composed components, from which configuration and per-component content can be read.
|
|
117
|
+
*
|
|
118
|
+
* @typeParam TComponent - The content each component contributes.
|
|
119
|
+
*
|
|
120
|
+
* @alpha
|
|
121
|
+
*/
|
|
122
|
+
function compose<TComponent>(allComponents: readonly Factory<TComponent>[]): Composed<TComponent>;
|
|
123
|
+
/**
|
|
124
|
+
* Combine multiple {@link Component.Factory|components} into a single {@link Component.Composed}.
|
|
125
|
+
*
|
|
126
|
+
* @param allComponents - The components to compose.
|
|
127
|
+
* @param lazyConfiguration - Builds the composed configuration from the composed components.
|
|
128
|
+
* This is invoked once, after all components have been created, and can aggregate content contributed by the
|
|
129
|
+
* components (for example via {@link Component.Composed.getComposed}).
|
|
130
|
+
* @returns The composed components, from which configuration and per-component content can be read.
|
|
131
|
+
*
|
|
132
|
+
* @typeParam TComponent - The content each component contributes.
|
|
133
|
+
* @typeParam TConfig - The composed configuration type made available to components.
|
|
134
|
+
*
|
|
135
|
+
* @alpha
|
|
136
|
+
*/
|
|
137
|
+
function compose<TComponent, TConfig>(allComponents: readonly Factory<TComponent, TConfig>[], lazyConfiguration: (composed: Composed<TComponent, TConfig>) => TConfig): Composed<TComponent, TConfig>;
|
|
138
|
+
/**
|
|
139
|
+
* The default configuration type for a composition.
|
|
140
|
+
* Also the type of Composed when using the default composition.
|
|
141
|
+
* @privateRemarks
|
|
142
|
+
* Declaring this as its own type makes the recursion possible instead of having to list the config parameter as unknown.
|
|
143
|
+
* This makes it easier to understand what is going on when seeing this type in the intellisense.
|
|
144
|
+
* @sealed @alpha
|
|
145
|
+
*/
|
|
146
|
+
type ComposedDefault<TComponent> = Composed<TComponent, ComposedDefault<TComponent>>;
|
|
147
|
+
/**
|
|
148
|
+
* The result of composing multiple components.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Create using {@link Component.(compose:1)}.
|
|
152
|
+
*
|
|
153
|
+
* @typeParam TComponent - The content each component contributes.
|
|
154
|
+
* @typeParam TConfig - The composed configuration type made available to components.
|
|
155
|
+
* Defaults to the composition itself: the common case where no custom configuration type is needed.
|
|
156
|
+
*
|
|
157
|
+
* @sealed @alpha
|
|
158
|
+
*/
|
|
159
|
+
interface Composed<TComponent, TConfig = ComposedDefault<TComponent>> {
|
|
160
|
+
/**
|
|
161
|
+
* The components which were composed.
|
|
162
|
+
*/
|
|
163
|
+
readonly components: readonly TComponent[];
|
|
164
|
+
/**
|
|
165
|
+
* The configuration which was produced when composing.
|
|
166
|
+
*/
|
|
167
|
+
readonly config: TConfig;
|
|
168
|
+
/**
|
|
169
|
+
* Get a component by its factory.
|
|
170
|
+
*
|
|
171
|
+
* @param factory - The factory used to look up the component. Must have been provided when composing.
|
|
172
|
+
* @returns The content created by the provided factory.
|
|
173
|
+
* This result is cached during composition and not reevaluated.
|
|
174
|
+
*/
|
|
175
|
+
getComponent<TFactory extends Factory<TComponent, TConfig>>(factory: TFactory): ReturnType<TFactory>;
|
|
176
|
+
/**
|
|
177
|
+
* Configure a {@link Component.Configurable}.
|
|
178
|
+
* @remarks
|
|
179
|
+
* The result is cached when first evaluated, so subsequent calls with the same `configurable` return the
|
|
180
|
+
* same result.
|
|
181
|
+
* @param configurable - The item to configure against this composition.
|
|
182
|
+
*/
|
|
183
|
+
getConfigured<TConfigurable extends Configurable<TConfig, unknown, TComponent>>(configurable: TConfigurable): ReturnType<TConfigurable["configure"]>;
|
|
184
|
+
/**
|
|
185
|
+
* Compose the contents of a {@link Component.LazyArray} property from all components.
|
|
186
|
+
* @remarks
|
|
187
|
+
* The result is cached when first evaluated, so subsequent calls with the same `property` return the
|
|
188
|
+
* same result.
|
|
189
|
+
* @param property - The property of the components to compose.
|
|
190
|
+
* @returns The concatenation of the lazy values contributed by each component for `property`.
|
|
191
|
+
* Components which omit the property contribute nothing.
|
|
192
|
+
*/
|
|
193
|
+
getComposed<TKey extends keyof {
|
|
194
|
+
[Property in keyof TComponent as TComponent[Property] extends LazyArray<unknown> | undefined ? Property : never]: boolean;
|
|
195
|
+
}>(property: TKey): readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U> ? () => U : never)[];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=componentApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentApi.d.ts","sourceRoot":"","sources":["../src/componentApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,yBAAiB,SAAS,CAAC;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAY,OAAO,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,UAAU,CAAC,IAAI,CACxE,iBAAiB,EAAE,MAAM,OAAO,KAC5B,UAAU,CAAC;IAEhB;;;;;;;;;;OAUG;IACH,KAAY,SAAS,CAAC,CAAC,IAAI,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAEtD;;;;;;;;;;;;;OAaG;IACI,MAAM,OAAO,eAAgB,MAAM,CAAC,KAAG,CAAC,MAAM,CAAC,CAUrD,CAAC;IAEF;;;;;;;;;;;;OAYG;IACH,UAAiB,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,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C;;;;;;;;WAQG;QACH,WAAW,CACV,IAAI,SAAS,MAAM;aACjB,QAAQ,IAAI,MAAM,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,SAClD,SAAS,CAAC,OAAO,CAAC,GAClB,SAAS,GACT,QAAQ,GACR,KAAK,GAAG,OAAO;SAClB,EAED,QAAQ,EAAE,IAAI,GACZ,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GACzE,MAAM,CAAC,GACP,KAAK,CAAC,EAAE,CAAC;KACZ;CACD"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
6
|
+
import { getOrCreate } from "./util/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Utilities for composing application "components" which contribute to a shared configuration.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Nothing in this namespace is specific to tree schema,
|
|
12
|
+
* however it is designed to be able to handle the needs of components which work with {@link TreeSchema}.
|
|
13
|
+
*
|
|
14
|
+
* This is mainly used to implement "open polymorphism", where the set of allowed types
|
|
15
|
+
* for a field or collection can be extended by independently authored libraries (components) instead of being
|
|
16
|
+
* fixed up front.
|
|
17
|
+
*
|
|
18
|
+
* This basically amounts to dependency injection, where the "injection" is done at "composition" time to build the schema.
|
|
19
|
+
*
|
|
20
|
+
* Tree's schema do not natively support open polymorphism: all possible implementations must be explicitly listed.
|
|
21
|
+
* These tools work around these limitations by carefully controlling evaluation order:
|
|
22
|
+
* the source code can be structured in an open polymorphism style which at runtime evaluates into closed polymorphism
|
|
23
|
+
* by having each component register its implementations into a central collection (typically an
|
|
24
|
+
* {@link AllowedTypes} array).
|
|
25
|
+
*
|
|
26
|
+
* Each component is expressed as a {@link Component.Factory}: a function which receives a lazy reference to the
|
|
27
|
+
* composed configuration and returns the content that component contributes.
|
|
28
|
+
* Because the configuration is provided lazily, components may reference (including recursively) types contributed by
|
|
29
|
+
* other components, as long as nothing evaluates the lazy references until composition has completed.
|
|
30
|
+
* Use {@link Component.(compose:1)} to combine a set of components into a {@link Component.Composed}.
|
|
31
|
+
*
|
|
32
|
+
* See {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/openPolymorphism.integration.ts|openPolymorphism.integration.ts} for worked examples of this pattern.
|
|
33
|
+
*
|
|
34
|
+
* @privateRemarks
|
|
35
|
+
* The examples and integration tests for this pattern live in `openPolymorphism.integration.ts`.
|
|
36
|
+
* Those tests and the docs here should be kept in sync.
|
|
37
|
+
*
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
export var Component;
|
|
41
|
+
(function (Component) {
|
|
42
|
+
/**
|
|
43
|
+
* Wrap a 0 argument function to cache the result.
|
|
44
|
+
* @remarks
|
|
45
|
+
* Do not use for impure functions.
|
|
46
|
+
*
|
|
47
|
+
* Generally {@link Component} utilities have built in caching in most cases,
|
|
48
|
+
* but this is occasionally helpful when manually implementing laziness.
|
|
49
|
+
*
|
|
50
|
+
* Note that this takes a different approach than use in {@link evaluateLazySchema} where the function evaluation is done using a utility that adds caching.
|
|
51
|
+
*
|
|
52
|
+
* @param factory - The factory function to memoize.
|
|
53
|
+
* @returns A function that returns the cached result of the factory.
|
|
54
|
+
* @alpha
|
|
55
|
+
*/
|
|
56
|
+
Component.memoize = (factory) => {
|
|
57
|
+
let run = false;
|
|
58
|
+
let cached;
|
|
59
|
+
return () => {
|
|
60
|
+
if (!run) {
|
|
61
|
+
cached = factory();
|
|
62
|
+
run = true;
|
|
63
|
+
}
|
|
64
|
+
return cached;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Implementation of {@link Component.Composed}.
|
|
69
|
+
*/
|
|
70
|
+
class Config {
|
|
71
|
+
constructor(allComponents, lazyConfiguration) {
|
|
72
|
+
/**
|
|
73
|
+
* Cache of results produced by {@link Component.Composed.getConfigured}.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Maps each {@link Component.Configurable} to the result of evaluating it against this composition.
|
|
77
|
+
* This ensures a given `Configurable` is only configured once: subsequent lookups return the cached result.
|
|
78
|
+
*/
|
|
79
|
+
this.evaluatedMap = new Map();
|
|
80
|
+
/**
|
|
81
|
+
* Cache of results produced by {@link Component.Composed.getComposed}.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Maps each composed property to the array produced for it.
|
|
85
|
+
* This ensures a given property is only composed once: subsequent lookups return the same array
|
|
86
|
+
* (including the same lazy values), so repeated calls with the same property are reference-stable.
|
|
87
|
+
*/
|
|
88
|
+
this.composedMap = new Map();
|
|
89
|
+
// eslint-disable-next-line no-undef-init -- Explicitly undefined: `config` is populated below, after all components have been constructed, and is read lazily via `lazyConfigInner`.
|
|
90
|
+
let config = undefined;
|
|
91
|
+
const lazyConfigInner = () => {
|
|
92
|
+
if (config === undefined) {
|
|
93
|
+
throw new UsageError("Configuration not yet available: components must not evaluate the lazy configuration during composition.");
|
|
94
|
+
}
|
|
95
|
+
return config;
|
|
96
|
+
};
|
|
97
|
+
this.componentsMap = new Map(allComponents.map((c) => [c, c(lazyConfigInner)]));
|
|
98
|
+
this.components = [...this.componentsMap.values()];
|
|
99
|
+
config = lazyConfiguration(this);
|
|
100
|
+
this.config = config;
|
|
101
|
+
}
|
|
102
|
+
getComponent(factory) {
|
|
103
|
+
const found = this.componentsMap.get(factory);
|
|
104
|
+
if (found === undefined) {
|
|
105
|
+
throw new UsageError("Requested component not included in this configuration");
|
|
106
|
+
}
|
|
107
|
+
return found;
|
|
108
|
+
}
|
|
109
|
+
getConfigured(configurable) {
|
|
110
|
+
const configured = getOrCreate(this.evaluatedMap, configurable, (c) => {
|
|
111
|
+
const result = c.configure(this.config, this);
|
|
112
|
+
if (result === undefined) {
|
|
113
|
+
throw new UsageError("Configurable must not return undefined");
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
});
|
|
117
|
+
return configured;
|
|
118
|
+
}
|
|
119
|
+
getComposed(property) {
|
|
120
|
+
const result = getOrCreate(this.composedMap, property, () => this.components.flatMap((c) => {
|
|
121
|
+
const prop = c[property];
|
|
122
|
+
if (prop === undefined) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
return prop();
|
|
126
|
+
}));
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function compose(allComponents, lazyConfiguration = (composed) => composed) {
|
|
131
|
+
return new Config(allComponents, lazyConfiguration);
|
|
132
|
+
}
|
|
133
|
+
Component.compose = compose;
|
|
134
|
+
})(Component || (Component = {}));
|
|
135
|
+
//# sourceMappingURL=componentApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentApi.js","sourceRoot":"","sources":["../src/componentApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,KAAW,SAAS,CAuTzB;AAvTD,WAAiB,SAAS;IAqCzB;;;;;;;;;;;;;OAaG;IACU,iBAAO,GAAG,CAAI,OAAgB,EAAa,EAAE;QACzD,IAAI,GAAG,GAAG,KAAK,CAAC;QAChB,IAAI,MAAS,CAAC;QACd,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,GAAG,EAAE,CAAC;gBACV,MAAM,GAAG,OAAO,EAAE,CAAC;gBACnB,GAAG,GAAG,IAAI,CAAC;YACZ,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC,CAAC;IACH,CAAC,CAAC;IA2BF;;OAEG;IACH,MAAM,MA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AC9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC1B,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;gBAChE,CAAC;gBACD,OAAO,MAAM,CAAC;YACf,CAAC,CAAC,CAAC;YACH,OAAO,UAAoD,CAAC;QAC7D,CAAC;QAEM,WAAW,CASjB,QAAc;YAId,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,CAC3D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC7B,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAmC,CAAC;gBAC3D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;oBACxB,OAAO,EAAE,CAAC;gBACX,CAAC;gBACD,OAAO,IAAI,EAAE,CAAC;YACf,CAAC,CAAC,CACF,CAAC;YACF,OAAO,MAEI,CAAC;QACb,CAAC;KACD;IAsCD,SAAgB,OAAO,CACtB,aAAsD,EACtD,oBAA0E,CAAC,QAAQ,EAAE,EAAE,CACtF,QAA8B;QAE/B,OAAO,IAAI,MAAM,CAAsB,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC1E,CAAC;IANe,iBAAO,UAMtB,CAAA;AAgFF,CAAC,EAvTgB,SAAS,KAAT,SAAS,QAuTzB","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\";\n\nimport { getOrCreate } from \"./util/index.js\";\n\n/**\n * Utilities for composing application \"components\" which contribute to a shared configuration.\n *\n * @remarks\n * Nothing in this namespace is specific to tree schema,\n * however it is designed to be able to handle the needs of components which work with {@link TreeSchema}.\n *\n * This is mainly used to implement \"open polymorphism\", where the set of allowed types\n * for a field or collection can be extended by independently authored libraries (components) instead of being\n * fixed up front.\n *\n * This basically amounts to dependency injection, where the \"injection\" is done at \"composition\" time to build the schema.\n *\n * Tree's schema do not natively support open polymorphism: all possible implementations must be explicitly listed.\n * These tools work around these limitations by carefully controlling evaluation order:\n * the source code can be structured in an open polymorphism style which at runtime evaluates into closed polymorphism\n * by having each component register its implementations into a central collection (typically an\n * {@link AllowedTypes} array).\n *\n * Each component is expressed as a {@link Component.Factory}: a function which receives a lazy reference to the\n * composed configuration and returns the content that component contributes.\n * Because the configuration is provided lazily, components may reference (including recursively) types contributed by\n * other components, as long as nothing evaluates the lazy references until composition has completed.\n * Use {@link Component.(compose:1)} to combine a set of components into a {@link Component.Composed}.\n *\n * See {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/openPolymorphism.integration.ts|openPolymorphism.integration.ts} for worked examples of this pattern.\n *\n * @privateRemarks\n * The examples and integration tests for this pattern live in `openPolymorphism.integration.ts`.\n * Those tests and the docs here should be kept in sync.\n *\n * @alpha\n */\nexport namespace Component {\n\t/**\n\t * A function which takes in a lazy configuration and returns the content a component contributes.\n\t *\n\t * @remarks\n\t * The lazy configuration allows the component to reference items from the composed configuration, which can\n\t * include items the component itself contributes (allowing recursive references between components).\n\t *\n\t * The execution of the factory must not evaluate `lazyConfiguration` (doing so will error):\n\t * instead the returned `TComponent` can capture `lazyConfiguration` and evaluate it at a later time\n\t * (after all components have been composed).\n\t *\n\t * @typeParam TComponent - The content a component contributes.\n\t * @typeParam TConfig - The composed configuration type made available to components.\n\t * Defaults to the {@link Component.Composed} produced by composition: the common case where\n\t * components read composed content directly from the composition and no custom configuration type is needed.\n\t *\n\t * @input\n\t * @alpha\n\t */\n\texport type Factory<TComponent, TConfig = ComposedDefault<TComponent>> = (\n\t\tlazyConfiguration: () => TConfig,\n\t) => TComponent;\n\n\t/**\n\t * A function which returns an array of lazy values which each evaluate to `T`.\n\t *\n\t * @remarks\n\t * This mirrors the shape of {@link AllowedTypes} where all of the values are lazy:\n\t * the outer function and inner functions defer evaluation until after composition is complete.\n\t *\n\t * @typeParam T - The type each lazy value evaluates to.\n\t *\n\t * @alpha\n\t */\n\texport type LazyArray<T> = () => readonly (() => T)[];\n\n\t/**\n\t * Wrap a 0 argument function to cache the result.\n\t * @remarks\n\t * Do not use for impure functions.\n\t *\n\t * Generally {@link Component} utilities have built in caching in most cases,\n\t * but this is occasionally helpful when manually implementing laziness.\n\t *\n\t * Note that this takes a different approach than use in {@link evaluateLazySchema} where the function evaluation is done using a utility that adds caching.\n\t *\n\t * @param factory - The factory function to memoize.\n\t * @returns A function that returns the cached result of the factory.\n\t * @alpha\n\t */\n\texport const memoize = <T>(factory: () => T): (() => T) => {\n\t\tlet run = false;\n\t\tlet cached: T;\n\t\treturn () => {\n\t\t\tif (!run) {\n\t\t\t\tcached = factory();\n\t\t\t\trun = true;\n\t\t\t}\n\t\t\treturn cached;\n\t\t};\n\t};\n\n\t/**\n\t * An item which can be configured (evaluated) against a composed configuration to produce a result.\n\t *\n\t * @remarks\n\t * Use {@link Component.Composed.getConfigured} to evaluate a `Configurable`.\n\t * The result is cached, so a given `Configurable` is only evaluated once per composition.\n\t *\n\t * @typeParam TConfigPartial - The configuration type made available when configuring.\n\t * @typeParam TResult - The result produced by configuring.\n\t * @typeParam TComponent - The content components contribute.\n\t *\n\t * @alpha\n\t */\n\texport interface Configurable<TConfigPartial, out TResult, TComponent> {\n\t\t/**\n\t\t * Produce the configured result.\n\t\t * @param config - The composed configuration.\n\t\t * @param components - The composed components.\n\t\t */\n\t\tconfigure(\n\t\t\tconfig: TConfigPartial,\n\t\t\tcomponents: Composed<TComponent, TConfigPartial>,\n\t\t): TResult;\n\t}\n\n\t/**\n\t * Implementation of {@link Component.Composed}.\n\t */\n\tclass Config<TConfig, TComponent> implements Composed<TComponent, TConfig> {\n\t\tpublic readonly componentsMap: ReadonlyMap<Factory<TComponent, TConfig>, TComponent>;\n\n\t\t/**\n\t\t * Cache of results produced by {@link Component.Composed.getConfigured}.\n\t\t *\n\t\t * @remarks\n\t\t * Maps each {@link Component.Configurable} to the result of evaluating it against this composition.\n\t\t * This ensures a given `Configurable` is only configured once: subsequent lookups return the cached result.\n\t\t */\n\t\tprivate readonly evaluatedMap: Map<Configurable<TConfig, unknown, TComponent>, unknown> =\n\t\t\tnew Map();\n\n\t\t/**\n\t\t * Cache of results produced by {@link Component.Composed.getComposed}.\n\t\t *\n\t\t * @remarks\n\t\t * Maps each composed property to the array produced for it.\n\t\t * This ensures a given property is only composed once: subsequent lookups return the same array\n\t\t * (including the same lazy values), so repeated calls with the same property are reference-stable.\n\t\t */\n\t\tprivate readonly composedMap: Map<keyof TComponent, readonly unknown[]> = new Map();\n\n\t\tpublic readonly components: readonly TComponent[];\n\n\t\tpublic readonly config: TConfig;\n\n\t\tpublic constructor(\n\t\t\tallComponents: readonly Factory<TComponent, TConfig>[],\n\t\t\tlazyConfiguration: (composed: Composed<TComponent, TConfig>) => TConfig,\n\t\t) {\n\t\t\t// eslint-disable-next-line no-undef-init -- Explicitly undefined: `config` is populated below, after all components have been constructed, and is read lazily via `lazyConfigInner`.\n\t\t\tlet config: TConfig | undefined = undefined;\n\t\t\tconst lazyConfigInner = (): TConfig => {\n\t\t\t\tif (config === undefined) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Configuration not yet available: components must not evaluate the lazy configuration during composition.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn config;\n\t\t\t};\n\t\t\tthis.componentsMap = new Map(allComponents.map((c) => [c, c(lazyConfigInner)]));\n\t\t\tthis.components = [...this.componentsMap.values()];\n\t\t\tconfig = lazyConfiguration(this);\n\t\t\tthis.config = config;\n\t\t}\n\n\t\tpublic getComponent<TFactory extends Factory<TComponent, TConfig>>(\n\t\t\tfactory: TFactory,\n\t\t): ReturnType<TFactory> {\n\t\t\tconst found = this.componentsMap.get(factory);\n\t\t\tif (found === undefined) {\n\t\t\t\tthrow new UsageError(\"Requested component not included in this configuration\");\n\t\t\t}\n\t\t\treturn found as ReturnType<TFactory>;\n\t\t}\n\n\t\tpublic getConfigured<TConfigurable extends Configurable<TConfig, unknown, TComponent>>(\n\t\t\tconfigurable: TConfigurable,\n\t\t): ReturnType<TConfigurable[\"configure\"]> {\n\t\t\tconst configured: unknown = getOrCreate(this.evaluatedMap, configurable, (c) => {\n\t\t\t\tconst result = c.configure(this.config, this);\n\t\t\t\tif (result === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Configurable must not return undefined\");\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t});\n\t\t\treturn configured as ReturnType<TConfigurable[\"configure\"]>;\n\t\t}\n\n\t\tpublic getComposed<\n\t\t\tTKey extends keyof {\n\t\t\t\t[Property in keyof TComponent as TComponent[Property] extends\n\t\t\t\t\t| LazyArray<unknown>\n\t\t\t\t\t| undefined\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: boolean;\n\t\t\t},\n\t\t>(\n\t\t\tproperty: TKey,\n\t\t): readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U>\n\t\t\t? () => U\n\t\t\t: never)[] {\n\t\t\tconst result = getOrCreate(this.composedMap, property, () =>\n\t\t\t\tthis.components.flatMap((c) => {\n\t\t\t\t\tconst prop = c[property] as LazyArray<unknown> | undefined;\n\t\t\t\t\tif (prop === undefined) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\treturn prop();\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn result as (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U>\n\t\t\t\t? () => U\n\t\t\t\t: never)[];\n\t\t}\n\t}\n\n\t/**\n\t * Combine multiple {@link Component.Factory|components} into a single {@link Component.Composed}.\n\t *\n\t * @remarks\n\t * The {@link Component.Composed} itself is used as the configuration made available to components:\n\t * the simple case where components read composed content directly from the composition.\n\t * To produce a custom aggregated configuration, use the overload which takes a `lazyConfiguration` builder.\n\t *\n\t * @param allComponents - The components to compose.\n\t * @returns The composed components, from which configuration and per-component content can be read.\n\t *\n\t * @typeParam TComponent - The content each component contributes.\n\t *\n\t * @alpha\n\t */\n\texport function compose<TComponent>(\n\t\tallComponents: readonly Factory<TComponent>[],\n\t): Composed<TComponent>;\n\t/**\n\t * Combine multiple {@link Component.Factory|components} into a single {@link Component.Composed}.\n\t *\n\t * @param allComponents - The components to compose.\n\t * @param lazyConfiguration - Builds the composed configuration from the composed components.\n\t * This is invoked once, after all components have been created, and can aggregate content contributed by the\n\t * components (for example via {@link Component.Composed.getComposed}).\n\t * @returns The composed components, from which configuration and per-component content can be read.\n\t *\n\t * @typeParam TComponent - The content each component contributes.\n\t * @typeParam TConfig - The composed configuration type made available to components.\n\t *\n\t * @alpha\n\t */\n\texport function compose<TComponent, TConfig>(\n\t\tallComponents: readonly Factory<TComponent, TConfig>[],\n\t\tlazyConfiguration: (composed: Composed<TComponent, TConfig>) => TConfig,\n\t): Composed<TComponent, TConfig>;\n\texport function compose<TComponent, TConfig>(\n\t\tallComponents: readonly Factory<TComponent, TConfig>[],\n\t\tlazyConfiguration: (composed: Composed<TComponent, TConfig>) => TConfig = (composed) =>\n\t\t\tcomposed as unknown as TConfig,\n\t): Composed<TComponent, TConfig> {\n\t\treturn new Config<TConfig, TComponent>(allComponents, lazyConfiguration);\n\t}\n\n\t/**\n\t * The default configuration type for a composition.\n\t * Also the type of Composed when using the default composition.\n\t * @privateRemarks\n\t * Declaring this as its own type makes the recursion possible instead of having to list the config parameter as unknown.\n\t * This makes it easier to understand what is going on when seeing this type in the intellisense.\n\t * @sealed @alpha\n\t */\n\texport type ComposedDefault<TComponent> = Composed<TComponent, ComposedDefault<TComponent>>;\n\n\t/**\n\t * The result of composing multiple components.\n\t *\n\t * @remarks\n\t * Create using {@link Component.(compose:1)}.\n\t *\n\t * @typeParam TComponent - The content each component contributes.\n\t * @typeParam TConfig - The composed configuration type made available to components.\n\t * Defaults to the composition itself: the common case where no custom configuration type is needed.\n\t *\n\t * @sealed @alpha\n\t */\n\texport interface Composed<TComponent, TConfig = ComposedDefault<TComponent>> {\n\t\t/**\n\t\t * The components which were composed.\n\t\t */\n\t\treadonly components: readonly TComponent[];\n\n\t\t/**\n\t\t * The configuration which was produced when composing.\n\t\t */\n\t\treadonly config: TConfig;\n\n\t\t/**\n\t\t * Get a component by its factory.\n\t\t *\n\t\t * @param factory - The factory used to look up the component. Must have been provided when composing.\n\t\t * @returns The content created by the provided factory.\n\t\t * This result is cached during composition and not reevaluated.\n\t\t */\n\t\tgetComponent<TFactory extends Factory<TComponent, TConfig>>(\n\t\t\tfactory: TFactory,\n\t\t): ReturnType<TFactory>;\n\n\t\t/**\n\t\t * Configure a {@link Component.Configurable}.\n\t\t * @remarks\n\t\t * The result is cached when first evaluated, so subsequent calls with the same `configurable` return the\n\t\t * same result.\n\t\t * @param configurable - The item to configure against this composition.\n\t\t */\n\t\tgetConfigured<TConfigurable extends Configurable<TConfig, unknown, TComponent>>(\n\t\t\tconfigurable: TConfigurable,\n\t\t): ReturnType<TConfigurable[\"configure\"]>;\n\n\t\t/**\n\t\t * Compose the contents of a {@link Component.LazyArray} property from all components.\n\t\t * @remarks\n\t\t * The result is cached when first evaluated, so subsequent calls with the same `property` return the\n\t\t * same result.\n\t\t * @param property - The property of the components to compose.\n\t\t * @returns The concatenation of the lazy values contributed by each component for `property`.\n\t\t * Components which omit the property contribute nothing.\n\t\t */\n\t\tgetComposed<\n\t\t\tTKey extends keyof {\n\t\t\t\t[Property in keyof TComponent as TComponent[Property] extends\n\t\t\t\t\t| LazyArray<unknown>\n\t\t\t\t\t| undefined\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: boolean;\n\t\t\t},\n\t\t>(\n\t\t\tproperty: TKey,\n\t\t): readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U>\n\t\t\t? () => U\n\t\t\t: never)[];\n\t}\n}\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
|
|
6
6
|
import type { ICodecFamily, IJsonCodec } from "../../codec/index.js";
|
|
7
7
|
import type { SchemaAndPolicy } from "../../core/index.js";
|
|
8
|
-
import type { JsonCompatibleReadOnly } from "../../util/index.js";
|
|
8
|
+
import type { IdentifierHealingConfig, JsonCompatibleReadOnly } from "../../util/index.js";
|
|
9
9
|
import type { ChangeRebaser, RevisionTag, TaggedChange } from "../rebase/index.js";
|
|
10
10
|
export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
|
|
11
11
|
buildEditor(mintRevisionTag: () => RevisionTag, changeReceiver: (change: TaggedChange<TChange>) => void): TEditor;
|
|
@@ -29,17 +29,10 @@ export interface ChangeEncodingContext {
|
|
|
29
29
|
*/
|
|
30
30
|
readonly isSummary: boolean;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* during decode are healed into deterministic stable UUIDs instead of
|
|
34
|
-
* throwing. See {@link FieldBatchEncodingContext.healUnresolvableIdentifiersOnDecode}.
|
|
32
|
+
* Heal-on-decode workaround configuration. See {@link IdentifierHealingConfig}.
|
|
35
33
|
* Only takes effect when `isSummary` is also `true`.
|
|
36
34
|
*/
|
|
37
|
-
readonly
|
|
38
|
-
/**
|
|
39
|
-
* The SharedTree's shared-object id, used as input to the deterministic
|
|
40
|
-
* UUID derivation when {@link healUnresolvableIdentifiersOnDecode} triggers.
|
|
41
|
-
*/
|
|
42
|
-
readonly sharedObjectId?: string;
|
|
35
|
+
readonly healing?: IdentifierHealingConfig;
|
|
43
36
|
}
|
|
44
37
|
export type ChangeFamilyCodec<TChange> = IJsonCodec<TChange, JsonCompatibleReadOnly, JsonCompatibleReadOnly, ChangeEncodingContext>;
|
|
45
38
|
export interface ChangeFamilyEditor {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFamily.d.ts","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MA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MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI,UAAU,CAClD,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,CACrB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAClC;;;;;;;OAOG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB;;;;;;;OAOG;IACH,eAAe,IAAI,IAAI,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFamily.js","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecFamily, IJsonCodec } from \"../../codec/index.js\";\nimport type { SchemaAndPolicy } from \"../../core/index.js\";\
|
|
1
|
+
{"version":3,"file":"changeFamily.js","sourceRoot":"","sources":["../../../src/core/change-family/changeFamily.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecFamily, IJsonCodec } from \"../../codec/index.js\";\nimport type { SchemaAndPolicy } from \"../../core/index.js\";\nimport type { IdentifierHealingConfig, JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport type { ChangeRebaser, RevisionTag, TaggedChange } from \"../rebase/index.js\";\n\nexport interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {\n\tbuildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<TChange>) => void,\n\t): TEditor;\n\n\treadonly rebaser: ChangeRebaser<TChange>;\n\treadonly codecs: ICodecFamily<TChange, ChangeEncodingContext>;\n}\n\nexport interface ChangeEncodingContext {\n\treadonly originatorId: SessionId;\n\treadonly revision: RevisionTag | undefined;\n\treadonly idCompressor: IIdCompressor;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * `true` when this context is encoding to or decoding from a summary blob.\n\t * `false` when this context is for an op (or any other non-summary path,\n\t * including utility encoders that aren't tied to persistence).\n\t *\n\t * @remarks\n\t * Used to gate decode-time recovery behavior — for example, healing of\n\t * unresolvable identifier IDs — that should only run when loading a\n\t * (possibly broken) attach-summary blob, never when applying ops.\n\t */\n\treadonly isSummary: boolean;\n\t/**\n\t * Heal-on-decode workaround configuration. See {@link IdentifierHealingConfig}.\n\t * Only takes effect when `isSummary` is also `true`.\n\t */\n\treadonly healing?: IdentifierHealingConfig;\n}\n\nexport type ChangeFamilyCodec<TChange> = IJsonCodec<\n\tTChange,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tChangeEncodingContext\n>;\n\nexport interface ChangeFamilyEditor {\n\t/**\n\t * Must be called when a new transaction starts.\n\t *\n\t * Note: transactions are an optional feature. It is valid to make edits outside of a transaction.\n\t *\n\t * For each call to this function, a matching call to `exitTransaction` must be made at a later time.\n\t * Can be called repeatedly to indicate the start of nesting transactions.\n\t */\n\tenterTransaction(): void;\n\n\t/**\n\t * Must be called when a transaction ends.\n\t *\n\t * Note: transactions are an optional feature. It is valid to make edits outside of a transaction.\n\t *\n\t * For each call to this function, a matching call to `enterTransaction` must be made at an earlier time.\n\t * Can be called repeatedly to indicate the end of nesting transactions.\n\t */\n\texitTransaction(): void;\n}\n"]}
|
|
@@ -144,7 +144,7 @@ export interface LocalChangeMetadata extends CommitMetadata {
|
|
|
144
144
|
*/
|
|
145
145
|
readonly label?: unknown;
|
|
146
146
|
/**
|
|
147
|
-
* A set of {@link
|
|
147
|
+
* A set of {@link RunTransactionParamsBeta.label | labels} for all transactions (nested or otherwise)
|
|
148
148
|
* that made up this change.
|
|
149
149
|
* This can be used to identify, group, or filter changes — for example, to decide whether a change
|
|
150
150
|
* should be included in an undo/redo stack.
|
|
@@ -185,7 +185,7 @@ export interface LocalChangeMetadata extends CommitMetadata {
|
|
|
185
185
|
*
|
|
186
186
|
* @remarks
|
|
187
187
|
* Each transaction contributes a node whose {@link LabelTree.label} is its
|
|
188
|
-
* {@link
|
|
188
|
+
* {@link RunTransactionParamsBeta.label | label} (or `undefined` if no label was provided).
|
|
189
189
|
* When transactions are nested, inner transaction nodes become {@link LabelTree.sublabels | sublabels}
|
|
190
190
|
* of outer ones.
|
|
191
191
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/rebase/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAIN,QAAQ,EACR,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,EAAa,CAAC;AAW9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,iBAAiB,EAAuC;CACxD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAkC5C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,CAAe,EAAE,CAAe;IACrE,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,CAA2B,EAC3B,CAA2B;IAE3B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,qBAAqB,CAAC,CAAC,EA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AC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;SAAM,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC,CAAC;IACX,CAAC;IAED,OAAO,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"@fluidframework/id-compressor\";\nimport * as Type from \"@sinclair/typebox\";\n\nimport {\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tRangeMap,\n\tbrand,\n\tbrandedNumberType,\n\tbrandedStringType,\n\tcomparePartialStrings,\n} from \"../../util/index.js\";\nimport type { RevertibleAlpha } from \"../revertible.js\";\n\n/**\n * The identifier for a particular session/user/client that can generate `GraphCommit`s\n */\nexport const SessionIdSchema = brandedStringType<SessionId>();\n\n/**\n * A unique identifier for a commit. Commits that have been rebased, but are semantically\n * the same, will share the same revision tag.\n *\n * The constant 'root' is reserved for the trunk base: minting a SessionSpaceCompressedId is not\n * possible on readonly clients. These clients generally don't need ids, but must be done at tree initialization time.\n */\nexport type RevisionTag = SessionSpaceCompressedId | \"root\";\nexport type EncodedRevisionTag = Brand<OpSpaceCompressedId, \"EncodedRevisionTag\"> | \"root\";\nexport const RevisionTagSchema = Type.Union([\n\tType.Literal(\"root\"),\n\tbrandedNumberType<Exclude<EncodedRevisionTag, string>>(),\n]);\n\nexport type EncodedStableId = Brand<StableId, \"EncodedStableId\">;\nexport const StableIdSchema = Type.String();\n\n/**\n * An ID which is unique within a revision of a `ModularChangeset`.\n * @remarks\n * Always a real number (never `NaN` or +/- `Infinity`).\n *\n * A `ModularChangeset` which is a composition of multiple revisions may contain duplicate `ChangesetLocalId`s,\n * but they are unique when qualified by the revision of the change they are used in.\n */\nexport type ChangesetLocalId = Brand<number, \"ChangesetLocalId\">;\n\n/**\n * A globally unique ID for an atom of change, or a node associated with the atom of change.\n * *\n * @privateRemarks\n * TODO: Rename this to be more general.\n */\nexport interface ChangeAtomId {\n\t/**\n\t * Uniquely identifies the changeset within which the change was made.\n\t * Only undefined when referring to an anonymous changesets.\n\t */\n\treadonly revision?: RevisionTag;\n\t/**\n\t * Uniquely identifies, in the scope of the changeset, the change made to the field.\n\t */\n\treadonly localId: ChangesetLocalId;\n}\n\nexport type EncodedChangeAtomId = [ChangesetLocalId, EncodedRevisionTag] | ChangesetLocalId;\n\nexport type ChangeAtomIdMap<T> = NestedMap<RevisionTag | undefined, ChangesetLocalId, T>;\n\n/**\n * Returns true iff `a` and `b` are the same.\n */\nexport function areEqualChangeAtomIds(a: ChangeAtomId, b: ChangeAtomId): boolean {\n\treturn a.localId === b.localId && a.revision === b.revision;\n}\n\nexport function areEqualChangeAtomIdOpts(\n\ta: ChangeAtomId | undefined,\n\tb: ChangeAtomId | undefined,\n): boolean {\n\tif (a === undefined || b === undefined) {\n\t\treturn a === b;\n\t}\n\n\treturn areEqualChangeAtomIds(a, b);\n}\n\n/**\n * Returns a ChangeAtomId with the given revision and local ID.\n */\nexport function makeChangeAtomId(\n\tlocalId: ChangesetLocalId,\n\trevision?: RevisionTag,\n): ChangeAtomId {\n\treturn revision === undefined ? { localId } : { localId, revision };\n}\n\nexport function asChangeAtomId(id: ChangesetLocalId | ChangeAtomId): ChangeAtomId {\n\treturn typeof id === \"object\" ? id : { localId: id };\n}\n\nexport function taggedAtomId(\n\tid: ChangeAtomId,\n\trevision: RevisionTag | undefined,\n): ChangeAtomId {\n\treturn makeChangeAtomId(id.localId, id.revision ?? revision);\n}\n\nexport function taggedOptAtomId(\n\tid: ChangeAtomId | undefined,\n\trevision: RevisionTag | undefined,\n): ChangeAtomId | undefined {\n\tif (id === undefined) {\n\t\treturn undefined;\n\t}\n\treturn taggedAtomId(id, revision);\n}\n\nexport function offsetChangeAtomId<T extends ChangeAtomId>(id: T, offset: number): T {\n\treturn { ...id, localId: brand(id.localId + offset) };\n}\n\n// #region These comparison functions are used instead of e.g. `compareNumbers` as a performance optimization\n\nexport function compareChangesetLocalIds(a: ChangesetLocalId, b: ChangesetLocalId): number {\n\treturn a - b; // No need to consider `NaN` or `Infinity` since ChangesetLocalId is always a real number\n}\n\nexport function comparePartialChangesetLocalIds(\n\ta: ChangesetLocalId | undefined,\n\tb: ChangesetLocalId | undefined,\n): number {\n\tif (a === undefined) {\n\t\treturn b === undefined ? 0 : -1;\n\t} else if (b === undefined) {\n\t\treturn 1;\n\t}\n\treturn compareChangesetLocalIds(a, b);\n}\n\n// #endregion\n\n/**\n * A node in a graph of commits. A commit's parent is the commit on which it was based.\n */\nexport interface GraphCommit<TChange> {\n\t/**\n\t * The tag for this commit.\n\t * @remarks\n\t * If this commit is rebased, the corresponding rebased commit will retain this tag.\n\t * With the exception of transaction commits (which all share the same tag), this tag is unique within a given branch history.\n\t */\n\treadonly revision: RevisionTag;\n\t/** The change that will result from applying this commit */\n\treadonly change: TChange;\n\t/** The parent of this commit, on whose change this commit's change is based */\n\treadonly parent?: GraphCommit<TChange>;\n}\n\n/**\n * The type of a commit. This is used to describe the context in which the commit was created.\n *\n * @public\n */\nexport enum CommitKind {\n\t/** A commit corresponding to a change that is not the result of an undo/redo from this client. */\n\tDefault,\n\t/** A commit that is the result of an undo from this client. */\n\tUndo,\n\t/** A commit that is the result of a redo from this client. */\n\tRedo,\n}\n\n/**\n * Information about a commit that has been applied.\n *\n * @sealed @public\n */\nexport interface CommitMetadata {\n\t/**\n\t * A {@link CommitKind} enum value describing whether the commit represents an Edit, an Undo, or a Redo.\n\t */\n\treadonly kind: CommitKind;\n\t/**\n\t * Indicates whether the commit is a local edit\n\t */\n\treadonly isLocal: boolean;\n}\n\n/**\n * Information about a change that has been applied by the local client.\n * @sealed @alpha\n */\nexport interface LocalChangeMetadata extends CommitMetadata {\n\t/**\n\t * Whether the change was made on the local machine/client or received from a remote client.\n\t */\n\treadonly isLocal: true;\n\t/**\n\t * Returns a serializable object that encodes the change.\n\t * @remarks This is only available for local changes.\n\t * This change object can be {@link TreeBranchAlpha.applyChange | applied to another branch} in the same state as the one which generated it.\n\t * The change object must be applied to a SharedTree with the same IdCompressor session ID as it was created from.\n\t * @privateRemarks\n\t * This is a `SerializedChange` from treeCheckout.ts.\n\t */\n\tgetChange(): JsonCompatibleReadOnly;\n\t/**\n\t * Returns an object (a {@link RevertibleAlpha | \"revertible\"}) that can be used to revert the change that produced this event.\n\t * @remarks This is only available for local changes.\n\t * If the change is not revertible (for example, it was a change to the application schema), then this will return `undefined`.\n\t * Revertibles should be disposed when they are no longer needed.\n\t * @param onDisposed - A callback that will be invoked when the `Revertible` is disposed.\n\t * This happens when the `Revertible` is disposed manually or when the `TreeView` that the `Revertible` belongs to is disposed - whichever happens first.\n\t * This is typically used to clean up any resources associated with the `Revertible` in the host application.\n\t * @throws Throws an error if called outside the scope of the `changed` event that provided it.\n\t */\n\tgetRevertible(\n\t\tonDisposed?: (revertible: RevertibleAlpha) => void,\n\t): RevertibleAlpha | undefined;\n\n\t/**\n\t * Optional label provided by the user when commit was created.\n\t * This can be used by undo/redo to group or classify edits.\n\t */\n\treadonly label?: unknown;\n\n\t/**\n\t * A set of {@link RunTransactionParams.label | labels} for all transactions (nested or otherwise)\n\t * that made up this change.\n\t * This can be used to identify, group, or filter changes — for example, to decide whether a change\n\t * should be included in an undo/redo stack.\n\t *\n\t * @remarks\n\t * The optional {@link TransactionLabels.tree | tree} property provides the structural nesting\n\t * of the transactions as a {@link LabelTree}.\n\t *\n\t * The `tree` property is present whenever the change was produced by a transaction that\n\t * includes at least one label. If the change was unlabeled,\n\t * `tree` is `undefined` and the set is empty.\n\t *\n\t * @example\n\t * Checking whether a change was produced by a specific kind of transaction:\n\t * ```typescript\n\t * branch.events.on(\"changed\", (metadata) => {\n\t * if (metadata.labels.has(\"testLabel\")) {\n\t * // This change came from a transaction labeled \"testLabel\"\n\t * }\n\t * });\n\t * ```\n\t *\n\t * @example\n\t * A nested transaction produces a tree that reflects the nesting:\n\t * ```typescript\n\t * tree.runTransaction(() => {\n\t * tree.runTransaction(() => { ... }, { label: \"inner\" });\n\t * }, { label: \"outer\" });\n\t * // metadata.labels.has(\"inner\") === true\n\t * // metadata.labels.tree will be:\n\t * // { label: \"outer\", sublabels: [{ label: \"inner\", sublabels: [] }] }\n\t * ```\n\t */\n\treadonly labels: TransactionLabels;\n}\n\n/**\n * A tree representing the nesting structure of transaction labels.\n *\n * @remarks\n * Each transaction contributes a node whose {@link LabelTree.label} is its\n * {@link RunTransactionParams.label | label} (or `undefined` if no label was provided).\n * When transactions are nested, inner transaction nodes become {@link LabelTree.sublabels | sublabels}\n * of outer ones.\n *\n * @sealed @alpha\n */\nexport interface LabelTree {\n\t/**\n\t * The label for this transaction, or `undefined` if no label was provided.\n\t */\n\tlabel: unknown;\n\n\t/**\n\t * The label trees of any nested transactions within this one.\n\t */\n\tsublabels: LabelTree[];\n}\n\n/**\n * A set of transaction labels with an optional structural tree.\n *\n * @remarks\n * The set contains all label values from the transactions that produced the change.\n * Use standard {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set | Set}\n * methods to check for specific labels.\n *\n * The optional {@link TransactionLabels.tree | tree} property provides the structural nesting\n * of the transactions as a {@link LabelTree}.\n *\n * @sealed @alpha\n */\nexport type TransactionLabels = Set<unknown> & { tree?: LabelTree };\n\n/**\n * Information about a change that has been applied by a remote client.\n * @sealed @alpha\n */\nexport interface RemoteChangeMetadata extends CommitMetadata {\n\t/**\n\t * Whether the change was made on the local machine/client or received from a remote client.\n\t */\n\treadonly isLocal: false;\n\t/**\n\t * Returns a serializable object that encodes the change.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly getChange?: undefined;\n\t/**\n\t * Returns an object (a {@link RevertibleAlpha | \"revertible\"}) that can be used to revert the change that produced this event.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly getRevertible?: undefined;\n\t/**\n\t * Label provided by the user when commit was created.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly label?: undefined;\n\t/**\n\t * A set of labels from nested transaction labels.\n\t * @remarks This is always empty for remote changes. Labels are only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly labels: TransactionLabels;\n}\n\n/**\n * Information about a {@link LocalChangeMetadata | local} or {@link RemoteChangeMetadata | remote} change that has been applied.\n * @sealed @alpha\n */\nexport type ChangeMetadata = LocalChangeMetadata | RemoteChangeMetadata;\n\n/**\n * Creates a new graph commit object. This is useful for creating copies of commits with different parentage.\n * @param parent - the parent of the new commit\n * @param commit - the contents of the new commit object\n * @returns the new commit object\n */\n// Note that this function is synchronous, and therefore it is not a Promise.\n// However, it is still a strong commit-mint.\nexport function mintCommit<TChange>(\n\tparent: GraphCommit<TChange>,\n\tcommit: Omit<GraphCommit<TChange>, \"parent\">,\n): GraphCommit<TChange> {\n\tconst { revision, change } = commit;\n\treturn {\n\t\trevision,\n\t\tchange,\n\t\tparent,\n\t};\n}\n\nexport type ChangeAtomIdRangeMap<V> = RangeMap<ChangeAtomId, V>;\n\nexport function newChangeAtomIdRangeMap<V>(\n\toffsetValue?: (value: V, offset: number) => V,\n): ChangeAtomIdRangeMap<V> {\n\treturn new RangeMap(offsetChangeAtomId, subtractChangeAtomIds, offsetValue);\n}\n\nexport function subtractChangeAtomIds(a: ChangeAtomId, b: ChangeAtomId): number {\n\tconst cmp = comparePartialRevisions(a.revision, b.revision);\n\tif (cmp !== 0) {\n\t\treturn cmp * Number.POSITIVE_INFINITY;\n\t}\n\n\treturn a.localId - b.localId;\n}\n\n/**\n * Compares two {@link RevisionTag}s to form a strict total ordering.\n * @remarks This function tolerates arbitrary strings, not just the string \"root\".\n * It sorts as follows: `undefined` \\< `string` \\< `number`\n */\nexport function comparePartialRevisions(\n\ta: RevisionTag | undefined,\n\tb: RevisionTag | undefined,\n): number {\n\tif (typeof a === \"number\") {\n\t\treturn typeof b === \"number\" ? a - b : 1;\n\t} else if (typeof b === \"number\") {\n\t\treturn -1;\n\t}\n\n\treturn comparePartialStrings(a, b);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/rebase/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAIN,QAAQ,EACR,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,EAAa,CAAC;AAW9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,iBAAiB,EAAuC;CACxD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAkC5C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,CAAe,EAAE,CAAe;IACrE,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,CAA2B,EAC3B,CAA2B;IAE3B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAAyB,EACzB,QAAsB;IAEtB,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE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;IAED,OAAO,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"@fluidframework/id-compressor\";\nimport * as Type from \"@sinclair/typebox\";\n\nimport {\n\ttype Brand,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tRangeMap,\n\tbrand,\n\tbrandedNumberType,\n\tbrandedStringType,\n\tcomparePartialStrings,\n} from \"../../util/index.js\";\nimport type { RevertibleAlpha } from \"../revertible.js\";\n\n/**\n * The identifier for a particular session/user/client that can generate `GraphCommit`s\n */\nexport const SessionIdSchema = brandedStringType<SessionId>();\n\n/**\n * A unique identifier for a commit. Commits that have been rebased, but are semantically\n * the same, will share the same revision tag.\n *\n * The constant 'root' is reserved for the trunk base: minting a SessionSpaceCompressedId is not\n * possible on readonly clients. These clients generally don't need ids, but must be done at tree initialization time.\n */\nexport type RevisionTag = SessionSpaceCompressedId | \"root\";\nexport type EncodedRevisionTag = Brand<OpSpaceCompressedId, \"EncodedRevisionTag\"> | \"root\";\nexport const RevisionTagSchema = Type.Union([\n\tType.Literal(\"root\"),\n\tbrandedNumberType<Exclude<EncodedRevisionTag, string>>(),\n]);\n\nexport type EncodedStableId = Brand<StableId, \"EncodedStableId\">;\nexport const StableIdSchema = Type.String();\n\n/**\n * An ID which is unique within a revision of a `ModularChangeset`.\n * @remarks\n * Always a real number (never `NaN` or +/- `Infinity`).\n *\n * A `ModularChangeset` which is a composition of multiple revisions may contain duplicate `ChangesetLocalId`s,\n * but they are unique when qualified by the revision of the change they are used in.\n */\nexport type ChangesetLocalId = Brand<number, \"ChangesetLocalId\">;\n\n/**\n * A globally unique ID for an atom of change, or a node associated with the atom of change.\n * *\n * @privateRemarks\n * TODO: Rename this to be more general.\n */\nexport interface ChangeAtomId {\n\t/**\n\t * Uniquely identifies the changeset within which the change was made.\n\t * Only undefined when referring to an anonymous changesets.\n\t */\n\treadonly revision?: RevisionTag;\n\t/**\n\t * Uniquely identifies, in the scope of the changeset, the change made to the field.\n\t */\n\treadonly localId: ChangesetLocalId;\n}\n\nexport type EncodedChangeAtomId = [ChangesetLocalId, EncodedRevisionTag] | ChangesetLocalId;\n\nexport type ChangeAtomIdMap<T> = NestedMap<RevisionTag | undefined, ChangesetLocalId, T>;\n\n/**\n * Returns true iff `a` and `b` are the same.\n */\nexport function areEqualChangeAtomIds(a: ChangeAtomId, b: ChangeAtomId): boolean {\n\treturn a.localId === b.localId && a.revision === b.revision;\n}\n\nexport function areEqualChangeAtomIdOpts(\n\ta: ChangeAtomId | undefined,\n\tb: ChangeAtomId | undefined,\n): boolean {\n\tif (a === undefined || b === undefined) {\n\t\treturn a === b;\n\t}\n\n\treturn areEqualChangeAtomIds(a, b);\n}\n\n/**\n * Returns a ChangeAtomId with the given revision and local ID.\n */\nexport function makeChangeAtomId(\n\tlocalId: ChangesetLocalId,\n\trevision?: RevisionTag,\n): ChangeAtomId {\n\treturn revision === undefined ? { localId } : { localId, revision };\n}\n\nexport function asChangeAtomId(id: ChangesetLocalId | ChangeAtomId): ChangeAtomId {\n\treturn typeof id === \"object\" ? id : { localId: id };\n}\n\nexport function taggedAtomId(\n\tid: ChangeAtomId,\n\trevision: RevisionTag | undefined,\n): ChangeAtomId {\n\treturn makeChangeAtomId(id.localId, id.revision ?? revision);\n}\n\nexport function taggedOptAtomId(\n\tid: ChangeAtomId | undefined,\n\trevision: RevisionTag | undefined,\n): ChangeAtomId | undefined {\n\tif (id === undefined) {\n\t\treturn undefined;\n\t}\n\treturn taggedAtomId(id, revision);\n}\n\nexport function offsetChangeAtomId<T extends ChangeAtomId>(id: T, offset: number): T {\n\treturn { ...id, localId: brand(id.localId + offset) };\n}\n\n// #region These comparison functions are used instead of e.g. `compareNumbers` as a performance optimization\n\nexport function compareChangesetLocalIds(a: ChangesetLocalId, b: ChangesetLocalId): number {\n\treturn a - b; // No need to consider `NaN` or `Infinity` since ChangesetLocalId is always a real number\n}\n\nexport function comparePartialChangesetLocalIds(\n\ta: ChangesetLocalId | undefined,\n\tb: ChangesetLocalId | undefined,\n): number {\n\tif (a === undefined) {\n\t\treturn b === undefined ? 0 : -1;\n\t} else if (b === undefined) {\n\t\treturn 1;\n\t}\n\treturn compareChangesetLocalIds(a, b);\n}\n\n// #endregion\n\n/**\n * A node in a graph of commits. A commit's parent is the commit on which it was based.\n */\nexport interface GraphCommit<TChange> {\n\t/**\n\t * The tag for this commit.\n\t * @remarks\n\t * If this commit is rebased, the corresponding rebased commit will retain this tag.\n\t * With the exception of transaction commits (which all share the same tag), this tag is unique within a given branch history.\n\t */\n\treadonly revision: RevisionTag;\n\t/** The change that will result from applying this commit */\n\treadonly change: TChange;\n\t/** The parent of this commit, on whose change this commit's change is based */\n\treadonly parent?: GraphCommit<TChange>;\n}\n\n/**\n * The type of a commit. This is used to describe the context in which the commit was created.\n *\n * @public\n */\nexport enum CommitKind {\n\t/** A commit corresponding to a change that is not the result of an undo/redo from this client. */\n\tDefault,\n\t/** A commit that is the result of an undo from this client. */\n\tUndo,\n\t/** A commit that is the result of a redo from this client. */\n\tRedo,\n}\n\n/**\n * Information about a commit that has been applied.\n *\n * @sealed @public\n */\nexport interface CommitMetadata {\n\t/**\n\t * A {@link CommitKind} enum value describing whether the commit represents an Edit, an Undo, or a Redo.\n\t */\n\treadonly kind: CommitKind;\n\t/**\n\t * Indicates whether the commit is a local edit\n\t */\n\treadonly isLocal: boolean;\n}\n\n/**\n * Information about a change that has been applied by the local client.\n * @sealed @alpha\n */\nexport interface LocalChangeMetadata extends CommitMetadata {\n\t/**\n\t * Whether the change was made on the local machine/client or received from a remote client.\n\t */\n\treadonly isLocal: true;\n\t/**\n\t * Returns a serializable object that encodes the change.\n\t * @remarks This is only available for local changes.\n\t * This change object can be {@link TreeBranchAlpha.applyChange | applied to another branch} in the same state as the one which generated it.\n\t * The change object must be applied to a SharedTree with the same IdCompressor session ID as it was created from.\n\t * @privateRemarks\n\t * This is a `SerializedChange` from treeCheckout.ts.\n\t */\n\tgetChange(): JsonCompatibleReadOnly;\n\t/**\n\t * Returns an object (a {@link RevertibleAlpha | \"revertible\"}) that can be used to revert the change that produced this event.\n\t * @remarks This is only available for local changes.\n\t * If the change is not revertible (for example, it was a change to the application schema), then this will return `undefined`.\n\t * Revertibles should be disposed when they are no longer needed.\n\t * @param onDisposed - A callback that will be invoked when the `Revertible` is disposed.\n\t * This happens when the `Revertible` is disposed manually or when the `TreeView` that the `Revertible` belongs to is disposed - whichever happens first.\n\t * This is typically used to clean up any resources associated with the `Revertible` in the host application.\n\t * @throws Throws an error if called outside the scope of the `changed` event that provided it.\n\t */\n\tgetRevertible(\n\t\tonDisposed?: (revertible: RevertibleAlpha) => void,\n\t): RevertibleAlpha | undefined;\n\n\t/**\n\t * Optional label provided by the user when commit was created.\n\t * This can be used by undo/redo to group or classify edits.\n\t */\n\treadonly label?: unknown;\n\n\t/**\n\t * A set of {@link RunTransactionParamsBeta.label | labels} for all transactions (nested or otherwise)\n\t * that made up this change.\n\t * This can be used to identify, group, or filter changes — for example, to decide whether a change\n\t * should be included in an undo/redo stack.\n\t *\n\t * @remarks\n\t * The optional {@link TransactionLabels.tree | tree} property provides the structural nesting\n\t * of the transactions as a {@link LabelTree}.\n\t *\n\t * The `tree` property is present whenever the change was produced by a transaction that\n\t * includes at least one label. If the change was unlabeled,\n\t * `tree` is `undefined` and the set is empty.\n\t *\n\t * @example\n\t * Checking whether a change was produced by a specific kind of transaction:\n\t * ```typescript\n\t * branch.events.on(\"changed\", (metadata) => {\n\t * if (metadata.labels.has(\"testLabel\")) {\n\t * // This change came from a transaction labeled \"testLabel\"\n\t * }\n\t * });\n\t * ```\n\t *\n\t * @example\n\t * A nested transaction produces a tree that reflects the nesting:\n\t * ```typescript\n\t * tree.runTransaction(() => {\n\t * tree.runTransaction(() => { ... }, { label: \"inner\" });\n\t * }, { label: \"outer\" });\n\t * // metadata.labels.has(\"inner\") === true\n\t * // metadata.labels.tree will be:\n\t * // { label: \"outer\", sublabels: [{ label: \"inner\", sublabels: [] }] }\n\t * ```\n\t */\n\treadonly labels: TransactionLabels;\n}\n\n/**\n * A tree representing the nesting structure of transaction labels.\n *\n * @remarks\n * Each transaction contributes a node whose {@link LabelTree.label} is its\n * {@link RunTransactionParamsBeta.label | label} (or `undefined` if no label was provided).\n * When transactions are nested, inner transaction nodes become {@link LabelTree.sublabels | sublabels}\n * of outer ones.\n *\n * @sealed @alpha\n */\nexport interface LabelTree {\n\t/**\n\t * The label for this transaction, or `undefined` if no label was provided.\n\t */\n\tlabel: unknown;\n\n\t/**\n\t * The label trees of any nested transactions within this one.\n\t */\n\tsublabels: LabelTree[];\n}\n\n/**\n * A set of transaction labels with an optional structural tree.\n *\n * @remarks\n * The set contains all label values from the transactions that produced the change.\n * Use standard {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set | Set}\n * methods to check for specific labels.\n *\n * The optional {@link TransactionLabels.tree | tree} property provides the structural nesting\n * of the transactions as a {@link LabelTree}.\n *\n * @sealed @alpha\n */\nexport type TransactionLabels = Set<unknown> & { tree?: LabelTree };\n\n/**\n * Information about a change that has been applied by a remote client.\n * @sealed @alpha\n */\nexport interface RemoteChangeMetadata extends CommitMetadata {\n\t/**\n\t * Whether the change was made on the local machine/client or received from a remote client.\n\t */\n\treadonly isLocal: false;\n\t/**\n\t * Returns a serializable object that encodes the change.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly getChange?: undefined;\n\t/**\n\t * Returns an object (a {@link RevertibleAlpha | \"revertible\"}) that can be used to revert the change that produced this event.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly getRevertible?: undefined;\n\t/**\n\t * Label provided by the user when commit was created.\n\t * @remarks This is only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly label?: undefined;\n\t/**\n\t * A set of labels from nested transaction labels.\n\t * @remarks This is always empty for remote changes. Labels are only available for {@link LocalChangeMetadata | local changes}.\n\t */\n\treadonly labels: TransactionLabels;\n}\n\n/**\n * Information about a {@link LocalChangeMetadata | local} or {@link RemoteChangeMetadata | remote} change that has been applied.\n * @sealed @alpha\n */\nexport type ChangeMetadata = LocalChangeMetadata | RemoteChangeMetadata;\n\n/**\n * Creates a new graph commit object. This is useful for creating copies of commits with different parentage.\n * @param parent - the parent of the new commit\n * @param commit - the contents of the new commit object\n * @returns the new commit object\n */\n// Note that this function is synchronous, and therefore it is not a Promise.\n// However, it is still a strong commit-mint.\nexport function mintCommit<TChange>(\n\tparent: GraphCommit<TChange>,\n\tcommit: Omit<GraphCommit<TChange>, \"parent\">,\n): GraphCommit<TChange> {\n\tconst { revision, change } = commit;\n\treturn {\n\t\trevision,\n\t\tchange,\n\t\tparent,\n\t};\n}\n\nexport type ChangeAtomIdRangeMap<V> = RangeMap<ChangeAtomId, V>;\n\nexport function newChangeAtomIdRangeMap<V>(\n\toffsetValue?: (value: V, offset: number) => V,\n): ChangeAtomIdRangeMap<V> {\n\treturn new RangeMap(offsetChangeAtomId, subtractChangeAtomIds, offsetValue);\n}\n\nexport function subtractChangeAtomIds(a: ChangeAtomId, b: ChangeAtomId): number {\n\tconst cmp = comparePartialRevisions(a.revision, b.revision);\n\tif (cmp !== 0) {\n\t\treturn cmp * Number.POSITIVE_INFINITY;\n\t}\n\n\treturn a.localId - b.localId;\n}\n\n/**\n * Compares two {@link RevisionTag}s to form a strict total ordering.\n * @remarks This function tolerates arbitrary strings, not just the string \"root\".\n * It sorts as follows: `undefined` \\< `string` \\< `number`\n */\nexport function comparePartialRevisions(\n\ta: RevisionTag | undefined,\n\tb: RevisionTag | undefined,\n): number {\n\tif (typeof a === \"number\") {\n\t\treturn typeof b === \"number\" ? a - b : 1;\n\t} else if (typeof b === \"number\") {\n\t\treturn -1;\n\t}\n\n\treturn comparePartialStrings(a, b);\n}\n"]}
|
|
@@ -36,8 +36,8 @@ export interface TreeStoredSchemaSubscription extends TreeStoredSchema {
|
|
|
36
36
|
export interface MutableTreeStoredSchema extends TreeStoredSchemaSubscription {
|
|
37
37
|
/**
|
|
38
38
|
* Mutates the stored schema.
|
|
39
|
-
* Replaces all
|
|
40
|
-
* Can
|
|
39
|
+
* Replaces all schemas with the provided schema.
|
|
40
|
+
* Can overwrite preexisting schemas, and removes unmentioned schemas.
|
|
41
41
|
*/
|
|
42
42
|
apply(newSchema: TreeStoredSchema): void;
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storedSchemaRepository.js","sourceRoot":"","sources":["../../../src/core/schema-stored/storedSchemaRepository.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAKN,sBAAsB,GACtB,MAAM,aAAa,CAAC;AAyCrB;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAMtC;;;;;;;;;;;;OAYG;IACH,YAAmB,IAAuB;QAhBvB,YAAO,GAAG,aAAa,EAAgB,CAAC;QAC3C,WAAM,GAA6B,IAAI,CAAC,OAAO,CAAC;QAgB/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,mBAAmB,GAAG,sBAAsB,CAAC;YAClD,IAAI,CAAC,cAAc,GAAG,IAAI,KAAK,CAC9B,EAAE,EACF,cAAc,CACd,CAAC;QACH,CAAC;aAAM,CAAC;YACP,IAAI,IAAI,YAAY,0BAA0B,EAAE,CAAC;gBAChD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC;gBAChD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC;gBAChD,IAAI,CAAC,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAW,UAAU;QACpB,wDAAwD;QACxD,OAAO,IAAI,CAAC,cAGX,CAAC;IACH,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,SAA2B;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,0BAA0B,CAAC,SAAS,CAAC,CAAC;QACxD,wFAAwF;QACxF,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACD;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAsB;IACvD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB,CAC3B,UAAgD;IAEhD,kGAAkG;IAClG,MAAM,OAAO,GAAuD;QACnE,GAAG,UAAU,CAAC,OAAO,EAAE;KACvB,CAAC;IACF,OAAO,IAAI,KAAK,CAAiD,OAAO,EAAE,cAAc,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport { compareStrings } from \"../../util/index.js\";\n\nimport type { TreeNodeSchemaIdentifier } from \"./formatV1.js\";\nimport {\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tstoredEmptyFieldSchema,\n} from \"./schema.js\";\n\n/**\n * Events for {@link TreeStoredSchemaSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n */\nexport interface SchemaEvents {\n\t/**\n\t * Schema change is about to be applied.\n\t */\n\tbeforeSchemaChange(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Schema change was just applied.\n\t */\n\tafterSchemaChange(newSchema: TreeStoredSchema): void;\n}\n\n/**\n * A collection of stored schema that fires events in response to changes.\n */\nexport interface TreeStoredSchemaSubscription extends TreeStoredSchema {\n\t/**\n\t * Events for this schema subscription.\n\t */\n\treadonly events: Listenable<SchemaEvents>;\n}\n\n/**\n * Mutable collection of stored schema.\n */\nexport interface MutableTreeStoredSchema extends TreeStoredSchemaSubscription {\n\t/**\n\t * Mutates the stored schema.\n\t * Replaces all
|
|
1
|
+
{"version":3,"file":"storedSchemaRepository.js","sourceRoot":"","sources":["../../../src/core/schema-stored/storedSchemaRepository.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAKN,sBAAsB,GACtB,MAAM,aAAa,CAAC;AAyCrB;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAMtC;;;;;;;;;;;;OAYG;IACH,YAAmB,IAAuB;QAhBvB,YAAO,GAAG,aAAa,EAAgB,CAAC;QAC3C,WAAM,GAA6B,IAAI,CAAC,O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C,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB,CAC3B,UAAgD;IAEhD,kGAAkG;IAClG,MAAM,OAAO,GAAuD;QACnE,GAAG,UAAU,CAAC,OAAO,EAAE;KACvB,CAAC;IACF,OAAO,IAAI,KAAK,CAAiD,OAAO,EAAE,cAAc,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport { compareStrings } from \"../../util/index.js\";\n\nimport type { TreeNodeSchemaIdentifier } from \"./formatV1.js\";\nimport {\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\tstoredEmptyFieldSchema,\n} from \"./schema.js\";\n\n/**\n * Events for {@link TreeStoredSchemaSubscription}.\n *\n * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).\n */\nexport interface SchemaEvents {\n\t/**\n\t * Schema change is about to be applied.\n\t */\n\tbeforeSchemaChange(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Schema change was just applied.\n\t */\n\tafterSchemaChange(newSchema: TreeStoredSchema): void;\n}\n\n/**\n * A collection of stored schema that fires events in response to changes.\n */\nexport interface TreeStoredSchemaSubscription extends TreeStoredSchema {\n\t/**\n\t * Events for this schema subscription.\n\t */\n\treadonly events: Listenable<SchemaEvents>;\n}\n\n/**\n * Mutable collection of stored schema.\n */\nexport interface MutableTreeStoredSchema extends TreeStoredSchemaSubscription {\n\t/**\n\t * Mutates the stored schema.\n\t * Replaces all schemas with the provided schema.\n\t * Can overwrite preexisting schemas, and removes unmentioned schemas.\n\t */\n\tapply(newSchema: TreeStoredSchema): void;\n}\n\n/**\n * Mutable TreeStoredSchema repository.\n */\nexport class TreeStoredSchemaRepository implements MutableTreeStoredSchema {\n\tprotected nodeSchemaData: BTree<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n\tprotected rootFieldSchemaData: TreeFieldStoredSchema;\n\tprotected readonly _events = createEmitter<SchemaEvents>();\n\tpublic readonly events: Listenable<SchemaEvents> = this._events;\n\n\t/**\n\t * Copies in the provided schema. If `data` is an TreeStoredSchemaRepository, it will be cheap-cloned.\n\t * Otherwise, it will be deep-cloned.\n\t *\n\t * We might not want to store schema in maps long term, as we might want a way to reserve a\n\t * large space of schema IDs within a schema.\n\t * The way mapFields has been structured mitigates the need for this, but it still might be useful.\n\t *\n\t * (ex: someone using data as field identifiers might want to\n\t * reserve all fields identifiers starting with \"foo.\" to have a specific schema).\n\t * Combined with support for such namespaces in the allowed sets in the schema objects,\n\t * that might provide a decent alternative to mapFields (which is a bit odd).\n\t */\n\tpublic constructor(data?: TreeStoredSchema) {\n\t\tif (data === undefined) {\n\t\t\tthis.rootFieldSchemaData = storedEmptyFieldSchema;\n\t\t\tthis.nodeSchemaData = new BTree<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>(\n\t\t\t\t[],\n\t\t\t\tcompareStrings,\n\t\t\t);\n\t\t} else {\n\t\t\tif (data instanceof TreeStoredSchemaRepository) {\n\t\t\t\tthis.rootFieldSchemaData = data.rootFieldSchema;\n\t\t\t\tthis.nodeSchemaData = data.nodeSchemaData.clone();\n\t\t\t} else {\n\t\t\t\tthis.rootFieldSchemaData = data.rootFieldSchema;\n\t\t\t\tthis.nodeSchemaData = cloneNodeSchemaData(data.nodeSchema);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get nodeSchema(): ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> {\n\t\t// Btree implements iterator, but not in a type-safe way\n\t\treturn this.nodeSchemaData as unknown as ReadonlyMap<\n\t\t\tTreeNodeSchemaIdentifier,\n\t\t\tTreeNodeStoredSchema\n\t\t>;\n\t}\n\n\tpublic get rootFieldSchema(): TreeFieldStoredSchema {\n\t\treturn this.rootFieldSchemaData;\n\t}\n\n\tpublic apply(newSchema: TreeStoredSchema): void {\n\t\tthis._events.emit(\"beforeSchemaChange\", newSchema);\n\t\tconst clone = new TreeStoredSchemaRepository(newSchema);\n\t\t// In the future, we could use btree's delta functionality to do a more efficient update\n\t\tthis.rootFieldSchemaData = clone.rootFieldSchemaData;\n\t\tthis.nodeSchemaData = clone.nodeSchemaData;\n\t\tthis._events.emit(\"afterSchemaChange\", newSchema);\n\t}\n\n\tpublic clone(): TreeStoredSchemaRepository {\n\t\treturn new TreeStoredSchemaRepository(this);\n\t}\n}\n\nexport function schemaDataIsEmpty(data: TreeStoredSchema): boolean {\n\treturn data.nodeSchema.size === 0;\n}\n\nfunction cloneNodeSchemaData(\n\tnodeSchema: StoredSchemaCollection[\"nodeSchema\"],\n): BTree<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> {\n\t// Schema objects are immutable (unlike stored schema repositories), so this shallow copy is fine.\n\tconst entries: [TreeNodeSchemaIdentifier, TreeNodeStoredSchema][] = [\n\t\t...nodeSchema.entries(),\n\t];\n\treturn new BTree<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>(entries, compareStrings);\n}\n"]}
|