@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
|
@@ -32,13 +32,82 @@ export enum SchemaValidationError {
|
|
|
32
32
|
Node_MissingSchema,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Additional context about a schema validation error.
|
|
37
|
+
* @remarks
|
|
38
|
+
* Not all fields are populated for every error type — only those relevant to the specific error.
|
|
39
|
+
*/
|
|
40
|
+
export interface SchemaValidationErrorContext {
|
|
41
|
+
/**
|
|
42
|
+
* The type identifier of the node that failed validation.
|
|
43
|
+
*/
|
|
44
|
+
readonly nodeType?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The set of type identifiers allowed in the field, if applicable.
|
|
47
|
+
*/
|
|
48
|
+
readonly allowedTypes?: ReadonlySet<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Field keys on the node that were not recognized by its schema.
|
|
51
|
+
*/
|
|
52
|
+
readonly unexpectedFields?: ReadonlySet<string>;
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
/**
|
|
36
56
|
* Throws a UsageError indicating a tree is out of schema.
|
|
37
57
|
*/
|
|
38
|
-
export function throwOutOfSchema(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
export function throwOutOfSchema(
|
|
59
|
+
maybeError: SchemaValidationError,
|
|
60
|
+
context?: SchemaValidationErrorContext,
|
|
61
|
+
): never {
|
|
62
|
+
throw new UsageError(formatSchemaValidationError(maybeError, context));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Not exported: internal helper used by throwOutOfSchema.
|
|
66
|
+
function formatSchemaValidationError(
|
|
67
|
+
error: SchemaValidationError,
|
|
68
|
+
context: SchemaValidationErrorContext | undefined,
|
|
69
|
+
): string {
|
|
70
|
+
switch (error) {
|
|
71
|
+
case SchemaValidationError.Field_NodeTypeNotAllowed: {
|
|
72
|
+
const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
|
|
73
|
+
const allowedDesc =
|
|
74
|
+
context?.allowedTypes === undefined
|
|
75
|
+
? "unknown"
|
|
76
|
+
: `[${[...context.allowedTypes].map((t) => `"${t}"`).join(", ")}]`;
|
|
77
|
+
return (
|
|
78
|
+
`Tree does not conform to schema. ` +
|
|
79
|
+
`A node of type ${nodeDesc} is not allowed in this field. Allowed types: ${allowedDesc}. ` +
|
|
80
|
+
`If using a staged allowed type, the stored schema has not been upgraded to include this type yet. ` +
|
|
81
|
+
`Either upgrade the schema to enable the staged type or avoid inserting content of this type until the schema is upgraded.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
case SchemaValidationError.Node_MissingSchema: {
|
|
85
|
+
const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
|
|
86
|
+
return (
|
|
87
|
+
`Tree does not conform to schema. ` +
|
|
88
|
+
`No schema definition was found for node type ${nodeDesc}. ` +
|
|
89
|
+
`Ensure the node's type is included in the schema and that the stored schema has been upgraded if needed.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
case SchemaValidationError.ObjectNode_FieldNotInSchema: {
|
|
93
|
+
const nodeDesc = context?.nodeType === undefined ? "unknown" : `"${context.nodeType}"`;
|
|
94
|
+
const fieldsDesc =
|
|
95
|
+
context?.unexpectedFields === undefined || context.unexpectedFields.size === 0
|
|
96
|
+
? undefined
|
|
97
|
+
: `[${[...context.unexpectedFields].map((f) => `"${f}"`).join(", ")}]`;
|
|
98
|
+
const fieldsPart =
|
|
99
|
+
fieldsDesc === undefined
|
|
100
|
+
? "The node has fields that are not defined in its schema."
|
|
101
|
+
: `Unexpected fields: ${fieldsDesc}.`;
|
|
102
|
+
return (
|
|
103
|
+
`Tree does not conform to schema. ` +
|
|
104
|
+
`A node of type ${nodeDesc} has fields not defined in its schema. ${fieldsPart}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
default: {
|
|
108
|
+
return `Tree does not conform to schema: ${SchemaValidationError[error]}.`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
42
111
|
}
|
|
43
112
|
|
|
44
113
|
type NotUndefined = number | string | boolean | bigint | symbol | object;
|
|
@@ -53,12 +122,14 @@ type NotUndefined = number | string | boolean | bigint | symbol | object;
|
|
|
53
122
|
export function isNodeInSchema<T extends NotUndefined>(
|
|
54
123
|
node: MinimalMapTreeNodeView,
|
|
55
124
|
schemaAndPolicy: SchemaAndPolicy,
|
|
56
|
-
onError: (error: SchemaValidationError) => T,
|
|
125
|
+
onError: (error: SchemaValidationError, context?: SchemaValidationErrorContext) => T,
|
|
57
126
|
): T | undefined {
|
|
58
127
|
// Validate the schema declared by the node exists
|
|
59
128
|
const schema = schemaAndPolicy.schema.nodeSchema.get(node.type);
|
|
60
129
|
if (schema === undefined) {
|
|
61
|
-
return onError(SchemaValidationError.Node_MissingSchema
|
|
130
|
+
return onError(SchemaValidationError.Node_MissingSchema, {
|
|
131
|
+
nodeType: node.type,
|
|
132
|
+
});
|
|
62
133
|
}
|
|
63
134
|
|
|
64
135
|
// Validate the node is well formed according to its schema
|
|
@@ -95,7 +166,10 @@ export function isNodeInSchema<T extends NotUndefined>(
|
|
|
95
166
|
// Code using this with a stored schema derived from a view schema rather than the document can be problematic because it may be missing unknown fields that the actual document has.
|
|
96
167
|
// Other schema evolution features like "staged" allowed types will likely cause similar issues elsewhere in this checker.
|
|
97
168
|
if (uncheckedFieldsFromNode.size > 0) {
|
|
98
|
-
return onError(SchemaValidationError.ObjectNode_FieldNotInSchema
|
|
169
|
+
return onError(SchemaValidationError.ObjectNode_FieldNotInSchema, {
|
|
170
|
+
nodeType: node.type,
|
|
171
|
+
unexpectedFields: uncheckedFieldsFromNode,
|
|
172
|
+
});
|
|
99
173
|
}
|
|
100
174
|
} else if (schema instanceof MapNodeStoredSchema) {
|
|
101
175
|
for (const [_key, field] of node.fields) {
|
|
@@ -128,7 +202,7 @@ export function isFieldInSchema<T extends NotUndefined>(
|
|
|
128
202
|
childNodes: MapTreeFieldViewGeneric<MinimalMapTreeNodeView>,
|
|
129
203
|
schema: TreeFieldStoredSchema,
|
|
130
204
|
schemaAndPolicy: SchemaAndPolicy,
|
|
131
|
-
onError: (error: SchemaValidationError) => T,
|
|
205
|
+
onError: (error: SchemaValidationError, context?: SchemaValidationErrorContext) => T,
|
|
132
206
|
): T | undefined {
|
|
133
207
|
// Validate that the field kind is handled by the schema policy
|
|
134
208
|
const kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);
|
|
@@ -147,7 +221,10 @@ export function isFieldInSchema<T extends NotUndefined>(
|
|
|
147
221
|
for (const node of childNodes) {
|
|
148
222
|
// Validate the type declared by the node is allowed in this field
|
|
149
223
|
if (schema.types !== undefined && !schema.types.has(node.type)) {
|
|
150
|
-
return onError(SchemaValidationError.Field_NodeTypeNotAllowed
|
|
224
|
+
return onError(SchemaValidationError.Field_NodeTypeNotAllowed, {
|
|
225
|
+
nodeType: node.type,
|
|
226
|
+
allowedTypes: schema.types,
|
|
227
|
+
});
|
|
151
228
|
}
|
|
152
229
|
|
|
153
230
|
// Validate the node complies with the type it declares to be.
|
package/src/index.ts
CHANGED
|
@@ -78,12 +78,14 @@ export {
|
|
|
78
78
|
type TreeIdentifierUtils,
|
|
79
79
|
independentView,
|
|
80
80
|
type IndependentViewOptions,
|
|
81
|
+
type IndependentViewTelemetryOptions,
|
|
81
82
|
createIndependentTreeBeta,
|
|
82
83
|
createIndependentTreeAlpha,
|
|
83
84
|
type CreateIndependentTreeAlphaOptions,
|
|
84
85
|
ForestTypeOptimized,
|
|
85
86
|
ForestTypeExpensiveDebug,
|
|
86
87
|
ForestTypeReference,
|
|
88
|
+
minimize,
|
|
87
89
|
} from "./shared-tree/index.js";
|
|
88
90
|
|
|
89
91
|
export {
|
|
@@ -273,17 +275,21 @@ export {
|
|
|
273
275
|
type NodeSchemaMetadata,
|
|
274
276
|
type SchemaStatics,
|
|
275
277
|
type ITreeAlpha,
|
|
278
|
+
type NoChangeConstraint,
|
|
279
|
+
type NodeInDocumentConstraint,
|
|
280
|
+
type RunTransactionParamsAlpha,
|
|
281
|
+
type RunTransactionParamsBeta,
|
|
282
|
+
type TransactionCallbackStatusAlpha,
|
|
283
|
+
type TransactionCallbackStatusBeta,
|
|
276
284
|
type TransactionConstraint,
|
|
277
285
|
type TransactionConstraintAlpha,
|
|
278
|
-
type
|
|
279
|
-
type NoChangeConstraint,
|
|
280
|
-
type RunTransactionParams,
|
|
281
|
-
type VoidTransactionCallbackStatus,
|
|
282
|
-
type TransactionCallbackStatus,
|
|
283
|
-
type TransactionResult,
|
|
284
|
-
type TransactionResultExt,
|
|
285
|
-
type TransactionResultSuccess,
|
|
286
|
+
type TransactionPostProcessor,
|
|
286
287
|
type TransactionResultFailed,
|
|
288
|
+
type TransactionResultSuccess,
|
|
289
|
+
type TransactionValueResult,
|
|
290
|
+
type TransactionVoidResult,
|
|
291
|
+
type VoidTransactionCallbackStatusAlpha,
|
|
292
|
+
type VoidTransactionCallbackStatusBeta,
|
|
287
293
|
rollback,
|
|
288
294
|
generateSchemaFromSimpleSchema,
|
|
289
295
|
evaluateLazySchema,
|
|
@@ -406,7 +412,9 @@ export { asAlpha, asBeta } from "./api.js";
|
|
|
406
412
|
export {
|
|
407
413
|
TextAsTree,
|
|
408
414
|
FormattedTextAsTree,
|
|
415
|
+
FormattedTextAsTreeDefault,
|
|
409
416
|
codePointCount,
|
|
410
417
|
utf16LengthForCodePoints,
|
|
411
418
|
} from "./text/index.js";
|
|
412
419
|
export { ExtensibleUnionNode } from "./extensibleUnionNode.js";
|
|
420
|
+
export { Component } from "./componentApi.js";
|
package/src/packageVersion.ts
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IFluidHandle, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import {
|
|
9
9
|
type IIdCompressor,
|
|
10
10
|
createIdCompressor,
|
|
11
11
|
} from "@fluidframework/id-compressor/internal";
|
|
12
|
+
import {
|
|
13
|
+
createChildLogger,
|
|
14
|
+
extractTelemetryLoggerExt,
|
|
15
|
+
} from "@fluidframework/telemetry-utils/internal";
|
|
12
16
|
|
|
13
17
|
import type { CodecWriteOptions, ICodecOptions } from "../codec/index.js";
|
|
14
18
|
import {
|
|
@@ -19,13 +23,11 @@ import {
|
|
|
19
23
|
import {
|
|
20
24
|
createNodeIdentifierManager,
|
|
21
25
|
fieldBatchCodecBuilder,
|
|
22
|
-
|
|
23
|
-
defaultSchemaPolicy,
|
|
24
|
-
TreeCompressionStrategy,
|
|
26
|
+
FieldBatchDecodingContext,
|
|
25
27
|
defaultIncrementalEncodingPolicy,
|
|
26
28
|
schemaCodecBuilder,
|
|
29
|
+
combineChunks,
|
|
27
30
|
} from "../feature-libraries/index.js";
|
|
28
|
-
import { combineChunks } from "../feature-libraries/index.js";
|
|
29
31
|
import type {
|
|
30
32
|
TreeViewConfiguration,
|
|
31
33
|
ImplicitFieldSchema,
|
|
@@ -54,11 +56,28 @@ import {
|
|
|
54
56
|
} from "./sharedTree.js";
|
|
55
57
|
import { createTreeCheckout } from "./treeCheckout.js";
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Options for supplying a telemetry logger to an independent tree view.
|
|
61
|
+
* @remarks
|
|
62
|
+
* Events emitted by the independent tree are tagged with the `independentView` namespace.
|
|
63
|
+
* If no logger is provided, telemetry events are dropped.
|
|
64
|
+
* @alpha @input
|
|
65
|
+
*/
|
|
66
|
+
export interface IndependentViewTelemetryOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Optional logger for telemetry.
|
|
69
|
+
*/
|
|
70
|
+
readonly logger?: ITelemetryBaseLogger | undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
/**
|
|
58
74
|
* {@link independentView} options.
|
|
59
75
|
* @alpha @input
|
|
60
76
|
*/
|
|
61
|
-
export interface IndependentViewOptions
|
|
77
|
+
export interface IndependentViewOptions
|
|
78
|
+
extends ForestOptions,
|
|
79
|
+
Partial<CodecWriteOptions>,
|
|
80
|
+
IndependentViewTelemetryOptions {
|
|
62
81
|
/**
|
|
63
82
|
* Optional ID compressor for generating and compressing identifiers.
|
|
64
83
|
* If not provided, a new one will be created.
|
|
@@ -71,6 +90,7 @@ export interface IndependentViewOptions extends ForestOptions, Partial<CodecWrit
|
|
|
71
90
|
* @alpha
|
|
72
91
|
*/
|
|
73
92
|
export type CreateIndependentTreeAlphaOptions = ForestOptions &
|
|
93
|
+
IndependentViewTelemetryOptions &
|
|
74
94
|
(
|
|
75
95
|
| (IndependentViewOptions & {
|
|
76
96
|
/**
|
|
@@ -122,7 +142,7 @@ export function independentView<const TSchema extends ImplicitFieldSchema>(
|
|
|
122
142
|
*/
|
|
123
143
|
export function independentInitializedView<const TSchema extends ImplicitFieldSchema>(
|
|
124
144
|
config: TreeViewConfiguration<TSchema>,
|
|
125
|
-
options: ForestOptions & ICodecOptions,
|
|
145
|
+
options: ForestOptions & ICodecOptions & IndependentViewTelemetryOptions,
|
|
126
146
|
content: ViewContent,
|
|
127
147
|
): TreeViewAlpha<TSchema> {
|
|
128
148
|
return createIndependentTreeAlpha({ ...options, content }).viewWith(
|
|
@@ -204,7 +224,13 @@ export function createIndependentTreeBeta<const TSchema extends ImplicitFieldSch
|
|
|
204
224
|
export function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSchema>(
|
|
205
225
|
options?: CreateIndependentTreeAlphaOptions,
|
|
206
226
|
): ViewableTree & Pick<ITreeAlpha, "exportVerbose" | "exportSimpleSchema"> {
|
|
207
|
-
const
|
|
227
|
+
const logger = extractTelemetryLoggerExt(
|
|
228
|
+
createChildLogger({
|
|
229
|
+
logger: options?.logger,
|
|
230
|
+
namespace: "independentView",
|
|
231
|
+
}),
|
|
232
|
+
);
|
|
233
|
+
const breaker = new Breakable("independentView", logger);
|
|
208
234
|
const idCompressor: IIdCompressor =
|
|
209
235
|
options?.idCompressor ?? options?.content?.idCompressor ?? createIdCompressor();
|
|
210
236
|
const mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();
|
|
@@ -225,6 +251,7 @@ export function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSc
|
|
|
225
251
|
forest,
|
|
226
252
|
schema: schemaRepository,
|
|
227
253
|
breaker,
|
|
254
|
+
logger,
|
|
228
255
|
codecOptions: options,
|
|
229
256
|
});
|
|
230
257
|
|
|
@@ -233,14 +260,12 @@ export function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSc
|
|
|
233
260
|
const fieldBatchCodec = fieldBatchCodecBuilder.buildDecoder(options);
|
|
234
261
|
const newSchema = schemaCodec.decode(options.content.schema);
|
|
235
262
|
|
|
236
|
-
|
|
237
|
-
|
|
263
|
+
// TreeAlpha.exportCompressed encodes this payload in originatorless-safe form
|
|
264
|
+
// (finalized compressed ids or strings), so summary-style decode is correct.
|
|
265
|
+
const context = FieldBatchDecodingContext.forSummary({
|
|
238
266
|
idCompressor,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// Not a summary blob — this is a synthetic decode of inline content.
|
|
242
|
-
isSummary: false,
|
|
243
|
-
};
|
|
267
|
+
healing: undefined,
|
|
268
|
+
});
|
|
244
269
|
const fieldCursors = fieldBatchCodec.decode(
|
|
245
270
|
options.content.tree as JsonCompatibleReadOnly,
|
|
246
271
|
context,
|
package/src/shared-tree/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export {
|
|
|
30
30
|
TreeCheckout,
|
|
31
31
|
type ITreeCheckout,
|
|
32
32
|
type CheckoutEvents,
|
|
33
|
+
type TreeTransactor,
|
|
33
34
|
} from "./treeCheckout.js";
|
|
34
35
|
|
|
35
36
|
export { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
@@ -42,6 +43,8 @@ export type {
|
|
|
42
43
|
SharedTreeEditBuilder,
|
|
43
44
|
} from "./sharedTreeEditBuilder.js";
|
|
44
45
|
|
|
46
|
+
export { minimize } from "./transactionMinimize.js";
|
|
47
|
+
|
|
45
48
|
export { Tree } from "./tree.js";
|
|
46
49
|
export type { RunTransaction } from "./tree.js";
|
|
47
50
|
|
|
@@ -56,6 +59,7 @@ export {
|
|
|
56
59
|
type ViewContent,
|
|
57
60
|
independentView,
|
|
58
61
|
type IndependentViewOptions,
|
|
62
|
+
type IndependentViewTelemetryOptions,
|
|
59
63
|
createIndependentTreeBeta,
|
|
60
64
|
createIndependentTreeAlpha,
|
|
61
65
|
type CreateIndependentTreeAlphaOptions,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
tryGetTreeNodeForField,
|
|
33
33
|
setField,
|
|
34
34
|
normalizeFieldSchema,
|
|
35
|
-
|
|
35
|
+
checkSchemaCompatibility,
|
|
36
36
|
type InsertableContent,
|
|
37
37
|
type TreeViewConfiguration,
|
|
38
38
|
type TreeViewAlpha,
|
|
@@ -41,11 +41,11 @@ import {
|
|
|
41
41
|
type ReadSchema,
|
|
42
42
|
type UnsafeUnknownSchema,
|
|
43
43
|
type TreeBranchEvents,
|
|
44
|
-
type
|
|
45
|
-
type
|
|
46
|
-
type
|
|
47
|
-
type
|
|
48
|
-
type
|
|
44
|
+
type VoidTransactionCallbackStatusAlpha,
|
|
45
|
+
type TransactionCallbackStatusAlpha,
|
|
46
|
+
type TransactionVoidResult,
|
|
47
|
+
type TransactionValueResult,
|
|
48
|
+
type RunTransactionParamsAlpha,
|
|
49
49
|
HydratedContext,
|
|
50
50
|
SimpleContextSlot,
|
|
51
51
|
areImplicitFieldSchemaEqual,
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
toInitialSchema,
|
|
58
58
|
toUpgradeSchema,
|
|
59
59
|
type TreeBranchAlpha,
|
|
60
|
+
type TreeSchema,
|
|
60
61
|
} from "../simple-tree/index.js";
|
|
61
62
|
import {
|
|
62
63
|
type Breakable,
|
|
@@ -98,7 +99,7 @@ export class SchematizingSimpleTreeView<
|
|
|
98
99
|
IEmitter<TreeViewEvents & TreeBranchEvents> &
|
|
99
100
|
HasListeners<TreeViewEvents & TreeBranchEvents> = createEmitter();
|
|
100
101
|
|
|
101
|
-
private readonly viewSchema:
|
|
102
|
+
private readonly viewSchema: TreeSchema;
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
105
|
* Events to unregister upon flex-tree view disposal.
|
|
@@ -143,7 +144,7 @@ export class SchematizingSimpleTreeView<
|
|
|
143
144
|
|
|
144
145
|
const configAlpha = new TreeViewConfigurationAlpha({ schema: config.schema });
|
|
145
146
|
|
|
146
|
-
this.viewSchema =
|
|
147
|
+
this.viewSchema = configAlpha;
|
|
147
148
|
// This must be initialized before `update` can be called.
|
|
148
149
|
this.currentCompatibility = {
|
|
149
150
|
canView: false,
|
|
@@ -258,7 +259,7 @@ export class SchematizingSimpleTreeView<
|
|
|
258
259
|
);
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
const newSchema = toUpgradeSchema(this.viewSchema.
|
|
262
|
+
const newSchema = toUpgradeSchema(this.viewSchema.root);
|
|
262
263
|
this.runSchemaEdit(() => this.checkout.updateSchema(newSchema));
|
|
263
264
|
}
|
|
264
265
|
|
|
@@ -272,40 +273,40 @@ export class SchematizingSimpleTreeView<
|
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
public runTransaction<TSuccessValue, TFailureValue>(
|
|
275
|
-
transaction: () =>
|
|
276
|
-
params?:
|
|
277
|
-
):
|
|
276
|
+
transaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,
|
|
277
|
+
params?: RunTransactionParamsAlpha,
|
|
278
|
+
): TransactionValueResult<TSuccessValue, TFailureValue>;
|
|
278
279
|
public runTransaction(
|
|
279
|
-
transaction: () =>
|
|
280
|
-
params?:
|
|
281
|
-
):
|
|
280
|
+
transaction: () => VoidTransactionCallbackStatusAlpha | void,
|
|
281
|
+
params?: RunTransactionParamsAlpha,
|
|
282
|
+
): TransactionVoidResult;
|
|
282
283
|
public runTransaction<TSuccessValue, TFailureValue>(
|
|
283
284
|
transaction: () =>
|
|
284
|
-
|
|
|
285
|
-
|
|
|
285
|
+
| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>
|
|
286
|
+
| VoidTransactionCallbackStatusAlpha
|
|
286
287
|
| void,
|
|
287
|
-
params?:
|
|
288
|
-
):
|
|
288
|
+
params?: RunTransactionParamsAlpha,
|
|
289
|
+
): TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult {
|
|
289
290
|
this.ensureUndisposed();
|
|
290
291
|
return this.checkout.runTransaction(transaction, params);
|
|
291
292
|
}
|
|
292
293
|
|
|
293
294
|
public runTransactionAsync<TSuccessValue, TFailureValue>(
|
|
294
|
-
transaction: () => Promise<
|
|
295
|
-
params?:
|
|
296
|
-
): Promise<
|
|
295
|
+
transaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,
|
|
296
|
+
params?: RunTransactionParamsAlpha,
|
|
297
|
+
): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;
|
|
297
298
|
public runTransactionAsync(
|
|
298
|
-
transaction: () => Promise<
|
|
299
|
-
params?:
|
|
300
|
-
): Promise<
|
|
299
|
+
transaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,
|
|
300
|
+
params?: RunTransactionParamsAlpha,
|
|
301
|
+
): Promise<TransactionVoidResult>;
|
|
301
302
|
public async runTransactionAsync<TSuccessValue, TFailureValue>(
|
|
302
303
|
transaction: () => Promise<
|
|
303
|
-
|
|
|
304
|
-
|
|
|
304
|
+
| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>
|
|
305
|
+
| VoidTransactionCallbackStatusAlpha
|
|
305
306
|
| void
|
|
306
307
|
>,
|
|
307
|
-
params:
|
|
308
|
-
): Promise<
|
|
308
|
+
params: RunTransactionParamsAlpha | undefined,
|
|
309
|
+
): Promise<TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult> {
|
|
309
310
|
this.ensureUndisposed();
|
|
310
311
|
if (this.checkout.transaction.size > 0) {
|
|
311
312
|
// breaker.break() sets brokenBy synchronously before throwing.
|
|
@@ -347,7 +348,10 @@ export class SchematizingSimpleTreeView<
|
|
|
347
348
|
private update(): void {
|
|
348
349
|
this.disposeFlexView();
|
|
349
350
|
|
|
350
|
-
const compatibility =
|
|
351
|
+
const compatibility = checkSchemaCompatibility(
|
|
352
|
+
this.viewSchema,
|
|
353
|
+
this.checkout.storedSchema,
|
|
354
|
+
);
|
|
351
355
|
|
|
352
356
|
this.currentCompatibility = {
|
|
353
357
|
...compatibility,
|
|
@@ -533,5 +537,11 @@ export class SchematizingSimpleTreeView<
|
|
|
533
537
|
return this.checkout.isMissingEditsFrom(context);
|
|
534
538
|
}
|
|
535
539
|
|
|
540
|
+
public computeNetChangeIfRebasedOnto(
|
|
541
|
+
context: TreeBranchAlpha,
|
|
542
|
+
): JsonCompatibleReadOnly | undefined {
|
|
543
|
+
return this.checkout.computeNetChangeIfRebasedOnto(context);
|
|
544
|
+
}
|
|
545
|
+
|
|
536
546
|
// #endregion Branching
|
|
537
547
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
|
|
7
|
+
import { isStableId } from "@fluidframework/id-compressor/internal";
|
|
8
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
type ChangeFamily,
|
|
12
|
+
type RevisionTag,
|
|
13
|
+
tagChange,
|
|
14
|
+
type ChangeEncodingContext,
|
|
15
|
+
type TaggedChange,
|
|
16
|
+
} from "../core/index.js";
|
|
17
|
+
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
18
|
+
|
|
19
|
+
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
20
|
+
import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
21
|
+
import { SharedTreeChangeFormatVersion } from "./sharedTreeChangeCodecs.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents a serialized change for SharedTree.
|
|
25
|
+
*
|
|
26
|
+
* Data in this format is not expected to be durable beyond the scope of a single session.
|
|
27
|
+
*/
|
|
28
|
+
interface SerializedChange {
|
|
29
|
+
readonly version: 1;
|
|
30
|
+
readonly revision: RevisionTag;
|
|
31
|
+
readonly change: JsonCompatibleReadOnly;
|
|
32
|
+
readonly originatorId: SessionId;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isSerializedChangeV1(value: unknown): value is SerializedChange {
|
|
36
|
+
if (typeof value !== "object" || value === null) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const change = value as Partial<SerializedChange>;
|
|
40
|
+
return (
|
|
41
|
+
change.version === 1 &&
|
|
42
|
+
(change.revision === "root" || typeof change.revision === "number") &&
|
|
43
|
+
typeof change.originatorId === "string" &&
|
|
44
|
+
isStableId(change.originatorId) &&
|
|
45
|
+
change.change !== undefined
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function encodeSerializedChangeV1(
|
|
50
|
+
idCompressor: IIdCompressor,
|
|
51
|
+
changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
|
|
52
|
+
change: SharedTreeChange,
|
|
53
|
+
changeRevision: RevisionTag,
|
|
54
|
+
contextRevision?: RevisionTag,
|
|
55
|
+
): JsonCompatibleReadOnly {
|
|
56
|
+
const context: ChangeEncodingContext = {
|
|
57
|
+
idCompressor,
|
|
58
|
+
originatorId: idCompressor.localSessionId,
|
|
59
|
+
revision: contextRevision,
|
|
60
|
+
isSummary: false,
|
|
61
|
+
};
|
|
62
|
+
const encodedChange = changeFamily.codecs
|
|
63
|
+
.resolve(SharedTreeChangeFormatVersion.v4)
|
|
64
|
+
.encode(change, context);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
version: 1,
|
|
68
|
+
revision: changeRevision,
|
|
69
|
+
originatorId: idCompressor.localSessionId,
|
|
70
|
+
change: encodedChange,
|
|
71
|
+
} satisfies SerializedChange;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function decodeSerializedChangeV1(
|
|
75
|
+
idCompressor: IIdCompressor,
|
|
76
|
+
changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
|
|
77
|
+
serializedChange: JsonCompatibleReadOnly,
|
|
78
|
+
): TaggedChange<SharedTreeChange> {
|
|
79
|
+
if (!isSerializedChangeV1(serializedChange)) {
|
|
80
|
+
throw new UsageError(`Cannot apply change. Invalid serialized change format.`);
|
|
81
|
+
}
|
|
82
|
+
const { revision, originatorId, change } = serializedChange;
|
|
83
|
+
if (originatorId !== idCompressor.localSessionId) {
|
|
84
|
+
throw new UsageError(
|
|
85
|
+
`Cannot apply change. A serialized changed must be applied to the same SharedTree as it was created from.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const context: ChangeEncodingContext = {
|
|
89
|
+
idCompressor,
|
|
90
|
+
originatorId: idCompressor.localSessionId,
|
|
91
|
+
revision,
|
|
92
|
+
isSummary: false,
|
|
93
|
+
};
|
|
94
|
+
const treeChange = changeFamily.codecs
|
|
95
|
+
.resolve(SharedTreeChangeFormatVersion.v4)
|
|
96
|
+
.decode(change, context);
|
|
97
|
+
return tagChange(treeChange, revision);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Provides utilities for serializing and deserializing SharedTree changes.
|
|
102
|
+
*
|
|
103
|
+
* @remarks Such changes are not expected to be durable beyond the scope of a single session.
|
|
104
|
+
*/
|
|
105
|
+
export const SerializedChange = {
|
|
106
|
+
/** Utilities for version 1 of the serialized change format. */
|
|
107
|
+
V1: {
|
|
108
|
+
/**
|
|
109
|
+
* Encodes a SharedTree change into the version 1 serialized change format.
|
|
110
|
+
* @param idCompressor - The ID compressor to use for encoding.
|
|
111
|
+
* @param changeFamily - The change family to use for encoding.
|
|
112
|
+
* @param change - The change to encode.
|
|
113
|
+
* @param changeRevision - The revision tag for the change.
|
|
114
|
+
* @param contextRevision - The optional context revision tag.
|
|
115
|
+
* @returns The encoded change in the version 1 serialized change format.
|
|
116
|
+
*/
|
|
117
|
+
encode: encodeSerializedChangeV1,
|
|
118
|
+
/**
|
|
119
|
+
* Decodes a version 1 serialized change into a SharedTree change.
|
|
120
|
+
* @param idCompressor - The ID compressor to use for decoding.
|
|
121
|
+
* @param changeFamily - The change family to use for decoding.
|
|
122
|
+
* @param serializedChange - The serialized change to decode.
|
|
123
|
+
* @returns The decoded SharedTree change.
|
|
124
|
+
*/
|
|
125
|
+
decode: decodeSerializedChangeV1,
|
|
126
|
+
},
|
|
127
|
+
} as const;
|