@fluidframework/tree 2.111.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/CHANGELOG.md +145 -0
- package/api-report/tree.alpha.api.md +48 -5
- package/api-report/tree.beta.api.md +1 -1
- package/api-report/tree.legacy.beta.api.md +1 -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/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/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- 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 +6 -18
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -16
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +3 -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/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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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 +11 -5
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +2 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +3 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +1 -0
- 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 +13 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -0
- 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/treeCheckout.d.ts +3 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +36 -62
- package/dist/shared-tree/treeCheckout.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/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/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 +24 -11
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +16 -2
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- 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/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.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +1 -2
- 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/tree.d.ts +22 -2
- 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/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/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/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 +69 -2
- package/dist/util/compressedIds.d.ts.map +1 -1
- package/dist/util/compressedIds.js +32 -1
- package/dist/util/compressedIds.js.map +1 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -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/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/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -1
- 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 +6 -18
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -17
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/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/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 +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- 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 +9 -3
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +2 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +1 -0
- 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 +13 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -0
- 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/treeCheckout.d.ts +3 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +18 -44
- package/lib/shared-tree/treeCheckout.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/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/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 +25 -12
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +16 -2
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- 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/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.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -3
- 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/tree.d.ts +22 -2
- 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/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/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/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 +69 -2
- package/lib/util/compressedIds.d.ts.map +1 -1
- package/lib/util/compressedIds.js +30 -0
- package/lib/util/compressedIds.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- 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 +22 -22
- package/src/componentApi.ts +354 -0
- package/src/entrypoints/alpha.ts +3 -0
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -27
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -44
- package/src/feature-libraries/index.ts +2 -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/schemaChecker.ts +86 -9
- package/src/index.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +35 -5
- package/src/shared-tree/index.ts +3 -0
- package/src/shared-tree/schematizingTreeView.ts +15 -5
- package/src/shared-tree/serializedChange.ts +127 -0
- package/src/shared-tree/sharedTree.ts +16 -0
- package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
- package/src/shared-tree/transactionMinimize.ts +74 -0
- package/src/shared-tree/treeCheckout.ts +42 -57
- package/src/shared-tree-core/editManager.ts +42 -6
- package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
- 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 +33 -10
- package/src/shared-tree-core/transaction.ts +19 -2
- package/src/simple-tree/api/index.ts +1 -1
- package/src/simple-tree/api/schemaCompatibilityTester.ts +36 -48
- 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 +2 -3
- package/src/simple-tree/api/storedSchema.ts +2 -3
- package/src/simple-tree/api/tree.ts +24 -2
- package/src/simple-tree/api/typesUnsafe.ts +2 -1
- package/src/simple-tree/index.ts +1 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
- package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
- package/src/treeFactory.ts +1 -1
- package/src/util/breakable.ts +8 -1
- package/src/util/compressedIds.ts +90 -2
- package/src/util/index.ts +3 -1
- package/src/util/nestedMap.ts +21 -4
- package/src/util/nestedSet.ts +1 -1
- package/src/util/utils.ts +0 -18
|
@@ -109,6 +109,14 @@ export interface TreeArrayNode<
|
|
|
109
109
|
> extends ReadonlyArrayNode<T> {
|
|
110
110
|
/**
|
|
111
111
|
* Inserts new item(s) at a specified location.
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* All items inserted by a single call to this method are inserted consecutively.
|
|
115
|
+
* The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified:
|
|
116
|
+
* Concurrently inserting `[A, B]` and `[X, Y]` at the same location may yield
|
|
117
|
+
* either `[A, B, X, Y]` or `[X, Y, A, B]`, regardless of the order in which those edits are sequenced.
|
|
118
|
+
* No other interleavings are possible. (e.g. `[A, X, B, Y]` is not possible.)
|
|
119
|
+
*
|
|
112
120
|
* @param index - The index at which to insert `value`.
|
|
113
121
|
* @param value - The content to insert.
|
|
114
122
|
* @throws Throws if `index` is not in the range [0, `array.length`).
|
|
@@ -117,12 +125,18 @@ export interface TreeArrayNode<
|
|
|
117
125
|
|
|
118
126
|
/**
|
|
119
127
|
* Inserts new item(s) at the start of the array.
|
|
128
|
+
* @remarks
|
|
129
|
+
* Equivalent to `insertAt(0, ...value)`:
|
|
130
|
+
* see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
|
|
120
131
|
* @param value - The content to insert.
|
|
121
132
|
*/
|
|
122
133
|
insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
123
134
|
|
|
124
135
|
/**
|
|
125
136
|
* Inserts new item(s) at the end of the array.
|
|
137
|
+
* @remarks
|
|
138
|
+
* Equivalent to `insertAt(array.length, ...value)`:
|
|
139
|
+
* see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
|
|
126
140
|
* @param value - The content to insert.
|
|
127
141
|
*/
|
|
128
142
|
insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
@@ -131,10 +145,10 @@ export interface TreeArrayNode<
|
|
|
131
145
|
* Inserts new item(s) at the end of the array.
|
|
132
146
|
*
|
|
133
147
|
* @remarks
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
148
|
+
* Unlike `Array.prototype.push`, this method does not return the new length of the array.
|
|
149
|
+
*
|
|
150
|
+
* Equivalent to `insertAt(array.length, ...value)`:
|
|
151
|
+
* see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
|
|
138
152
|
*
|
|
139
153
|
* @param value - The content to insert.
|
|
140
154
|
*/
|
|
@@ -460,6 +474,87 @@ export interface TreeArrayNodeAlpha<
|
|
|
460
474
|
? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
|
|
461
475
|
: InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>,
|
|
462
476
|
> extends TreeArrayNode<TAllowedTypes, T, TNew> {
|
|
477
|
+
/**
|
|
478
|
+
* Returns the item located at the specified index.
|
|
479
|
+
* @param index - The zero-based index of the item to retrieve.
|
|
480
|
+
* Negative indices count back from the last item in the array: for `index < 0`, `index + array.length` is used.
|
|
481
|
+
* @returns The item at the specified index, or `undefined` if the index is out of bounds.
|
|
482
|
+
*/
|
|
483
|
+
at(index: number): T | undefined;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Returns the last item in the array for which the given type guard returns `true`,
|
|
487
|
+
* searching from the last item to the first.
|
|
488
|
+
* @remarks
|
|
489
|
+
* The array's length is captured when the search begins; items are read live as the search progresses.
|
|
490
|
+
* If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
|
|
491
|
+
* @typeParam S - The subtype of `T` asserted by the `predicate` type guard.
|
|
492
|
+
* @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns `true`.
|
|
493
|
+
* Receives the item, its index, and the array being searched.
|
|
494
|
+
* @param thisArg - If provided, used as `this` when invoking `predicate`.
|
|
495
|
+
* @returns The last item for which `predicate` returns `true` (narrowed to the guarded type), or `undefined` if there is no such item.
|
|
496
|
+
*/
|
|
497
|
+
findLast<S extends T>(
|
|
498
|
+
predicate: (value: T, index: number, array: readonly T[]) => value is S,
|
|
499
|
+
thisArg?: unknown,
|
|
500
|
+
): S | undefined;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Returns the last item in the array for which the given predicate returns a truthy value,
|
|
504
|
+
* searching from the last item to the first.
|
|
505
|
+
* @remarks
|
|
506
|
+
* The array's length is captured when the search begins; items are read live as the search progresses.
|
|
507
|
+
* If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
|
|
508
|
+
* @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
|
|
509
|
+
* Receives the item, its index, and the array being searched.
|
|
510
|
+
* @param thisArg - If provided, used as `this` when invoking `predicate`.
|
|
511
|
+
* @returns The last item for which `predicate` returns a truthy value, or `undefined` if there is no such item.
|
|
512
|
+
*/
|
|
513
|
+
findLast(
|
|
514
|
+
predicate: (value: T, index: number, array: readonly T[]) => unknown,
|
|
515
|
+
thisArg?: unknown,
|
|
516
|
+
): T | undefined;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Returns the index of the last item in the array for which the given predicate returns a truthy value,
|
|
520
|
+
* searching from the last item to the first.
|
|
521
|
+
* @remarks
|
|
522
|
+
* The array's length is captured when the search begins; items are read live as the search progresses.
|
|
523
|
+
* If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.prototype.findLastIndex}.
|
|
524
|
+
* @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
|
|
525
|
+
* Receives the item, its index, and the array being searched.
|
|
526
|
+
* @param thisArg - If provided, used as `this` when invoking `predicate`.
|
|
527
|
+
* @returns The index of the last item for which `predicate` returns a truthy value, or `-1` if there is no such item.
|
|
528
|
+
*/
|
|
529
|
+
findLastIndex(
|
|
530
|
+
predicate: (value: T, index: number, array: readonly T[]) => unknown,
|
|
531
|
+
thisArg?: unknown,
|
|
532
|
+
): number;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Removes the last item from the array and returns it.
|
|
536
|
+
* @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
|
|
537
|
+
*/
|
|
538
|
+
pop(): T | undefined;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Removes the first item from the array and returns it.
|
|
542
|
+
* @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
|
|
543
|
+
*/
|
|
544
|
+
shift(): T | undefined;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Inserts new item(s) at the start of the array.
|
|
548
|
+
*
|
|
549
|
+
* @param value - The content to insert.
|
|
550
|
+
* @remarks
|
|
551
|
+
* Unlike `Array.prototype.unshift`, this method does not return the new length of the array.
|
|
552
|
+
*
|
|
553
|
+
* Equivalent to `insertAt(0, ...value)`:
|
|
554
|
+
* see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
|
|
555
|
+
*/
|
|
556
|
+
unshift(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
|
|
557
|
+
|
|
463
558
|
/**
|
|
464
559
|
* Removes existing item(s) and/or adds new item(s).
|
|
465
560
|
* @param start - The index at which to start changing the array. If negative, it is treated as `array.length + start`.
|
|
@@ -995,6 +1090,58 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
995
1090
|
|
|
996
1091
|
return getOrCreateNodeFromInnerNode(val) as TreeNodeFromImplicitAllowedTypes<T>;
|
|
997
1092
|
}
|
|
1093
|
+
public findLast<S extends TreeNodeFromImplicitAllowedTypes<T>>(
|
|
1094
|
+
predicate: (
|
|
1095
|
+
value: TreeNodeFromImplicitAllowedTypes<T>,
|
|
1096
|
+
index: number,
|
|
1097
|
+
array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
|
|
1098
|
+
) => value is S,
|
|
1099
|
+
thisArg?: unknown,
|
|
1100
|
+
): S | undefined;
|
|
1101
|
+
public findLast(
|
|
1102
|
+
predicate: (
|
|
1103
|
+
value: TreeNodeFromImplicitAllowedTypes<T>,
|
|
1104
|
+
index: number,
|
|
1105
|
+
array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
|
|
1106
|
+
) => unknown,
|
|
1107
|
+
thisArg?: unknown,
|
|
1108
|
+
): TreeNodeFromImplicitAllowedTypes<T> | undefined;
|
|
1109
|
+
public findLast(
|
|
1110
|
+
predicate: (
|
|
1111
|
+
value: TreeNodeFromImplicitAllowedTypes<T>,
|
|
1112
|
+
index: number,
|
|
1113
|
+
array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
|
|
1114
|
+
) => unknown,
|
|
1115
|
+
thisArg?: unknown,
|
|
1116
|
+
): TreeNodeFromImplicitAllowedTypes<T> | undefined {
|
|
1117
|
+
const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
|
|
1118
|
+
for (let index = this.length - 1; index >= 0; index--) {
|
|
1119
|
+
const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
|
|
1120
|
+
const matched = Boolean(predicate.call(thisArg, value, index, array));
|
|
1121
|
+
if (matched) {
|
|
1122
|
+
return value;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return undefined;
|
|
1126
|
+
}
|
|
1127
|
+
public findLastIndex(
|
|
1128
|
+
predicate: (
|
|
1129
|
+
value: TreeNodeFromImplicitAllowedTypes<T>,
|
|
1130
|
+
index: number,
|
|
1131
|
+
array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
|
|
1132
|
+
) => unknown,
|
|
1133
|
+
thisArg?: unknown,
|
|
1134
|
+
): number {
|
|
1135
|
+
const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
|
|
1136
|
+
for (let index = this.length - 1; index >= 0; index--) {
|
|
1137
|
+
const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
|
|
1138
|
+
const matched = Boolean(predicate.call(thisArg, value, index, array));
|
|
1139
|
+
if (matched) {
|
|
1140
|
+
return index;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return -1;
|
|
1144
|
+
}
|
|
998
1145
|
public insertAt(index: number, ...value: Insertable<T>): void {
|
|
999
1146
|
const field = getSequenceField(this);
|
|
1000
1147
|
validateIndex(index, field, "TreeArrayNode.insertAt", true);
|
|
@@ -1010,6 +1157,23 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
1010
1157
|
public push(...value: Insertable<T>): void {
|
|
1011
1158
|
this.insertAt(this.length, ...value);
|
|
1012
1159
|
}
|
|
1160
|
+
public unshift(...value: Insertable<T>): void {
|
|
1161
|
+
this.insertAt(0, ...value);
|
|
1162
|
+
}
|
|
1163
|
+
public pop(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
|
|
1164
|
+
const value = this.at(-1);
|
|
1165
|
+
if (value !== undefined) {
|
|
1166
|
+
this.removeAt(this.length - 1);
|
|
1167
|
+
}
|
|
1168
|
+
return value;
|
|
1169
|
+
}
|
|
1170
|
+
public shift(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
|
|
1171
|
+
const value = this.at(0);
|
|
1172
|
+
if (value !== undefined) {
|
|
1173
|
+
this.removeAt(0);
|
|
1174
|
+
}
|
|
1175
|
+
return value;
|
|
1176
|
+
}
|
|
1013
1177
|
public removeAt(index: number): void {
|
|
1014
1178
|
const field = getSequenceField(this);
|
|
1015
1179
|
validateIndex(index, field, "TreeArrayNode.removeAt");
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This file contains a format for serializing the compatibility impacting subset of simple schema.
|
|
8
8
|
|
|
9
9
|
* This format can be used for both view and stored simple schema.
|
|
10
|
-
* This only includes all parts of the schema that impact compatibility according to
|
|
10
|
+
* This only includes all parts of the schema that impact compatibility according to {@link checkSchemaCompatibility}.
|
|
11
11
|
* It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).
|
|
12
12
|
*/
|
|
13
13
|
|
package/src/treeFactory.ts
CHANGED
package/src/util/breakable.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
import { UsageError, type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* An object which can enter a "broken" state where trying to use it is a UsageError.
|
|
@@ -22,6 +22,13 @@ export class Breakable {
|
|
|
22
22
|
* This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.
|
|
23
23
|
*/
|
|
24
24
|
private readonly name: string,
|
|
25
|
+
/**
|
|
26
|
+
* Optional logger for telemetry.
|
|
27
|
+
* @remarks
|
|
28
|
+
* When provided, subsystems that have access to a Breakable can use this logger to emit telemetry
|
|
29
|
+
* without requiring additional plumbing.
|
|
30
|
+
*/
|
|
31
|
+
public readonly logger?: TelemetryLoggerExt,
|
|
25
32
|
) {}
|
|
26
33
|
|
|
27
34
|
/**
|
|
@@ -152,9 +152,10 @@ export function tryDecodeEncodedIdWithoutSession(
|
|
|
152
152
|
* the user-facing {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}
|
|
153
153
|
* option — see that option for the user-facing rationale and trade-offs.
|
|
154
154
|
*
|
|
155
|
-
* Carried by decode-side contexts (
|
|
155
|
+
* Carried by decode-side contexts ({@link IdDecoderOptionsOriginatorless},
|
|
156
|
+
* `ChangeEncodingContext.healing`,
|
|
156
157
|
* `EditManagerEncodingContext.healing`, etc.) when the workaround is enabled.
|
|
157
|
-
* Presence enables healing; `undefined`
|
|
158
|
+
* Presence enables healing; `undefined` means healing is disabled. There is no separate boolean,
|
|
158
159
|
* which makes it impossible to enable healing without supplying the namespace
|
|
159
160
|
* input.
|
|
160
161
|
*/
|
|
@@ -214,3 +215,90 @@ export function decompressIdentifierIfNeeded(
|
|
|
214
215
|
return decompressed;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Options for creating an {@link IdDecodingContext} without an originator.
|
|
221
|
+
* @remarks
|
|
222
|
+
* Decodes {@link OriginatorlessEncodedId} instances, and optionally has a {@link IdentifierHealingConfig} fallback for {@link OriginatorDependentEncodedId} instances.
|
|
223
|
+
*/
|
|
224
|
+
export interface IdDecoderOptionsOriginatorless {
|
|
225
|
+
readonly idCompressor: IIdCompressor;
|
|
226
|
+
/**
|
|
227
|
+
* Optional {@link IdentifierHealingConfig} to use for healing unresolvable identifiers.
|
|
228
|
+
* @privateRemarks
|
|
229
|
+
* This is a required field which can be undefined to make it explicit when this is not provided.
|
|
230
|
+
* This explicitness helps ensure we we don't accidentally drop the healing config as that would break
|
|
231
|
+
* an edge case which does not get a lot of testing.
|
|
232
|
+
*/
|
|
233
|
+
readonly healing: IdentifierHealingConfig | undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Options for creating an {@link IdDecodingContext} with an originator.
|
|
238
|
+
* @remarks
|
|
239
|
+
* Decodes {@link OriginatorDependentEncodedId} instances.
|
|
240
|
+
*/
|
|
241
|
+
export interface IdDecoderOptionsWithOriginator {
|
|
242
|
+
readonly idCompressor: IIdCompressor;
|
|
243
|
+
/**
|
|
244
|
+
* The ID of the session that encoded the ids.
|
|
245
|
+
*/
|
|
246
|
+
readonly originatorId: SessionId;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Context for decoding identifiers.
|
|
251
|
+
* @remarks
|
|
252
|
+
* Depended on how this is constructed, it may or may not handle {@link OriginatorDependentEncodedId} instances.
|
|
253
|
+
*
|
|
254
|
+
* This intentionally avoids exposing anything which depends on the underlying id-compressor's session ID to avoid confusion with the session ID of the compressor which encoded the data.
|
|
255
|
+
* If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.
|
|
256
|
+
*
|
|
257
|
+
* @privateRemarks
|
|
258
|
+
* We have code (FieldBatchDecodingContext) which sometimes has a session ID and sometimes doesn't, so we need a flexible decoding context.
|
|
259
|
+
* Additionally, since this is about serialized data, having stronger types is often counterproductive, as it just relies more on type casts when parsing.
|
|
260
|
+
* This is why we use this flexible pattern rather than code strongly typed over which kind of encoded ids are expected.
|
|
261
|
+
*/
|
|
262
|
+
export class IdDecodingContext {
|
|
263
|
+
/**
|
|
264
|
+
* Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
|
|
265
|
+
*/
|
|
266
|
+
protected readonly hasOriginatorSessionId: boolean;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.
|
|
270
|
+
*/
|
|
271
|
+
public readonly idCompressor: Pick<IIdCompressor, "decompress">;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Resolves an encoded op-space identifier to either a session-space ID
|
|
275
|
+
* (which {@link idCompressor} can decompress if needed)
|
|
276
|
+
* or a string (which passes through unchanged).
|
|
277
|
+
* @remarks
|
|
278
|
+
* In contexts where non-final identifiers can't be supported (where no originator session is available),
|
|
279
|
+
* if a non-final identifier is encountered, this may throw or perform a data healing workaround.
|
|
280
|
+
* See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.
|
|
281
|
+
*/
|
|
282
|
+
public readonly resolveEncodedId: (
|
|
283
|
+
id: OpSpaceCompressedId,
|
|
284
|
+
) => SessionSpaceCompressedId | string;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Creates a new instance of the context.
|
|
288
|
+
* @param options - The options for creating the context.
|
|
289
|
+
*/
|
|
290
|
+
public constructor(
|
|
291
|
+
options: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator,
|
|
292
|
+
) {
|
|
293
|
+
this.idCompressor = options.idCompressor;
|
|
294
|
+
if ("originatorId" in options) {
|
|
295
|
+
this.hasOriginatorSessionId = true;
|
|
296
|
+
this.resolveEncodedId = (id): SessionSpaceCompressedId | string =>
|
|
297
|
+
options.idCompressor.normalizeToSessionSpace(id, options.originatorId);
|
|
298
|
+
} else {
|
|
299
|
+
this.hasOriginatorSessionId = false;
|
|
300
|
+
this.resolveEncodedId = (id): SessionSpaceCompressedId | string =>
|
|
301
|
+
forceDecodeEncodedIdWithoutSession(id, options.idCompressor, options.healing);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
package/src/util/index.ts
CHANGED
|
@@ -106,7 +106,6 @@ export {
|
|
|
106
106
|
hasSingle,
|
|
107
107
|
defineLazyCachedProperty,
|
|
108
108
|
copyPropertyIfDefined as copyProperty,
|
|
109
|
-
getOrAddInMap,
|
|
110
109
|
iterableHasSome,
|
|
111
110
|
} from "./utils.js";
|
|
112
111
|
export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
|
|
@@ -179,4 +178,7 @@ export {
|
|
|
179
178
|
tryDecodeEncodedIdWithoutSession,
|
|
180
179
|
forceDecodeEncodedIdWithoutSession,
|
|
181
180
|
decompressIdentifierIfNeeded,
|
|
181
|
+
IdDecodingContext,
|
|
182
|
+
type IdDecoderOptionsOriginatorless,
|
|
183
|
+
type IdDecoderOptionsWithOriginator,
|
|
182
184
|
} from "./compressedIds.js";
|
package/src/util/nestedMap.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { oob } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getOrCreate } from "./utils.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A dictionary whose values are keyed off of two objects (key1, key2).
|
|
@@ -72,6 +72,23 @@ export function populateNestedMap<Key1, Key2, Value>(
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Sets the value at `key` in map to new Map if not already present.
|
|
77
|
+
* Returns the value at `key` after setting it.
|
|
78
|
+
*/
|
|
79
|
+
function getOrAddInMap<Key1, Key2, Value>(
|
|
80
|
+
map: NestedMap<Key1, Key2, Value>,
|
|
81
|
+
key1: Key1,
|
|
82
|
+
): Map<Key2, Value> {
|
|
83
|
+
const currentValue = map.get(key1);
|
|
84
|
+
if (currentValue !== undefined) {
|
|
85
|
+
return currentValue;
|
|
86
|
+
}
|
|
87
|
+
const value = new Map<Key2, Value>();
|
|
88
|
+
map.set(key1, value);
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
/**
|
|
76
93
|
* Sets the value at (key1, key2) in map to value.
|
|
77
94
|
* If there already is a value for (key1, key2), it is replaced with the provided one.
|
|
@@ -82,7 +99,7 @@ export function setInNestedMap<Key1, Key2, Value>(
|
|
|
82
99
|
key2: Key2,
|
|
83
100
|
value: Value,
|
|
84
101
|
): void {
|
|
85
|
-
const innerMap = getOrAddInMap(map, key1
|
|
102
|
+
const innerMap = getOrAddInMap(map, key1);
|
|
86
103
|
innerMap.set(key2, value);
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -95,7 +112,7 @@ export function getOrCreateInNestedMap<Key1, Key2, Value>(
|
|
|
95
112
|
key2: Key2,
|
|
96
113
|
defaultValue: (key1: Key1, key2: Key2) => Value,
|
|
97
114
|
): Value {
|
|
98
|
-
const innerMap = getOrAddInMap(map, key1
|
|
115
|
+
const innerMap = getOrAddInMap(map, key1);
|
|
99
116
|
return getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));
|
|
100
117
|
}
|
|
101
118
|
|
|
@@ -193,7 +210,7 @@ export function nestedMapFromFlatList<Key1, Key2, Value>(
|
|
|
193
210
|
): NestedMap<Key1, Key2, Value> {
|
|
194
211
|
const map = new Map<Key1, Map<Key2, Value>>();
|
|
195
212
|
for (const [key1, key2, val] of list) {
|
|
196
|
-
getOrAddInMap(map, key1
|
|
213
|
+
getOrAddInMap(map, key1).set(key2, val);
|
|
197
214
|
}
|
|
198
215
|
return map;
|
|
199
216
|
}
|
package/src/util/nestedSet.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js";
|
|
7
7
|
|
|
8
|
-
export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2,
|
|
8
|
+
export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, true>;
|
|
9
9
|
|
|
10
10
|
export function addToNestedSet<Key1, Key2>(
|
|
11
11
|
set: NestedSet<Key1, Key2>,
|
package/src/util/utils.ts
CHANGED
|
@@ -192,24 +192,6 @@ export function compareSets<T>({
|
|
|
192
192
|
return true;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/**
|
|
196
|
-
* Sets the value at `key` in map to value if not already present.
|
|
197
|
-
* Returns the value at `key` after setting it.
|
|
198
|
-
* This is equivalent to a get or default that adds the default to the map.
|
|
199
|
-
*/
|
|
200
|
-
export function getOrAddInMap<Key, Value>(
|
|
201
|
-
map: MapGetSet<Key, Value>,
|
|
202
|
-
key: Key,
|
|
203
|
-
value: Value,
|
|
204
|
-
): Value {
|
|
205
|
-
const currentValue = map.get(key);
|
|
206
|
-
if (currentValue !== undefined) {
|
|
207
|
-
return currentValue;
|
|
208
|
-
}
|
|
209
|
-
map.set(key, value);
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
195
|
/**
|
|
214
196
|
* Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
|
|
215
197
|
* @param map - The map to query/update
|