@fluidframework/tree 2.23.0 → 2.30.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 +38 -0
- package/api-report/tree.alpha.api.md +28 -12
- package/dist/alpha.d.ts +6 -0
- package/dist/core/forest/editableForest.d.ts +1 -14
- package/dist/core/forest/editableForest.d.ts.map +1 -1
- package/dist/core/forest/editableForest.js +1 -28
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/forest/forest.d.ts +16 -3
- package/dist/core/forest/forest.d.ts.map +1 -1
- package/dist/core/forest/forest.js +4 -1
- package/dist/core/forest/forest.js.map +1 -1
- package/dist/core/forest/index.d.ts +1 -1
- package/dist/core/forest/index.d.ts.map +1 -1
- package/dist/core/forest/index.js +1 -2
- package/dist/core/forest/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +8 -3
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +12 -5
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/delta.d.ts +8 -23
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/deltaUtil.d.ts +3 -3
- package/dist/core/tree/deltaUtil.d.ts.map +1 -1
- package/dist/core/tree/deltaUtil.js +2 -2
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -2
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +2 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/pathTree.d.ts +54 -1
- package/dist/core/tree/pathTree.d.ts.map +1 -1
- package/dist/core/tree/pathTree.js +8 -1
- package/dist/core/tree/pathTree.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts +7 -5
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +19 -9
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +5 -23
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +8 -5
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +10 -7
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +5 -2
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +3 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -0
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js +3 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
- package/dist/feature-libraries/deltaUtils.js +1 -1
- package/dist/feature-libraries/deltaUtils.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +9 -6
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +9 -7
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/initializeForest.d.ts +18 -0
- package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
- package/dist/feature-libraries/initializeForest.js +35 -0
- package/dist/feature-libraries/initializeForest.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +9 -15
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
- package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
- package/dist/feature-libraries/node-identifier/index.js +16 -0
- package/dist/feature-libraries/node-identifier/index.js.map +1 -0
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
- package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
- package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
- package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +6 -2
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +1 -1
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- 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/checkoutFlexTreeView.d.ts +3 -3
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +3 -18
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +3 -2
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +11 -7
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts +6 -31
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeApiAlpha.js +3 -18
- package/dist/shared-tree/treeApiAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +8 -2
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js +10 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +3 -3
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +42 -12
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +30 -2
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +4 -3
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +6 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +12 -9
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +16 -26
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaFromSimple.js +60 -0
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
- package/dist/simple-tree/api/simpleSchema.d.ts +3 -0
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +11 -5
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +11 -2
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +2 -17
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +15 -15
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +16 -25
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +15 -10
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/flexList.d.ts +4 -5
- package/dist/simple-tree/flexList.d.ts.map +1 -1
- package/dist/simple-tree/flexList.js +1 -14
- package/dist/simple-tree/flexList.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +7 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +2 -0
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +34 -2
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +55 -2
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +4 -4
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +1 -5
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts +7 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +13 -5
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/util/cloneWithReplacements.d.ts +21 -0
- package/dist/util/cloneWithReplacements.d.ts.map +1 -0
- package/dist/util/cloneWithReplacements.js +38 -0
- package/dist/util/cloneWithReplacements.js.map +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +3 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/referenceCounting.d.ts +18 -0
- package/dist/util/referenceCounting.d.ts.map +1 -1
- package/dist/util/referenceCounting.js.map +1 -1
- package/lib/alpha.d.ts +6 -0
- package/lib/core/forest/editableForest.d.ts +1 -14
- package/lib/core/forest/editableForest.d.ts.map +1 -1
- package/lib/core/forest/editableForest.js +0 -26
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/forest/forest.d.ts +16 -3
- package/lib/core/forest/forest.d.ts.map +1 -1
- package/lib/core/forest/forest.js +4 -1
- package/lib/core/forest/forest.js.map +1 -1
- package/lib/core/forest/index.d.ts +1 -1
- package/lib/core/forest/index.d.ts.map +1 -1
- package/lib/core/forest/index.js +1 -1
- package/lib/core/forest/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +8 -3
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +12 -5
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/delta.d.ts +8 -23
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/deltaUtil.d.ts +3 -3
- package/lib/core/tree/deltaUtil.d.ts.map +1 -1
- package/lib/core/tree/deltaUtil.js +2 -2
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -2
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/pathTree.d.ts +54 -1
- package/lib/core/tree/pathTree.d.ts.map +1 -1
- package/lib/core/tree/pathTree.js +6 -0
- package/lib/core/tree/pathTree.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts +7 -5
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +19 -9
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +5 -23
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +8 -5
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +11 -8
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -3
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -0
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js +1 -0
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
- package/lib/feature-libraries/deltaUtils.js +1 -1
- package/lib/feature-libraries/deltaUtils.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -8
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/initializeForest.d.ts +18 -0
- package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
- package/lib/feature-libraries/initializeForest.js +31 -0
- package/lib/feature-libraries/initializeForest.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -16
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
- package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
- package/lib/feature-libraries/node-identifier/index.js +8 -0
- package/lib/feature-libraries/node-identifier/index.js.map +1 -0
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
- package/lib/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +16 -16
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
- package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
- package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +6 -2
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +1 -1
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +3 -3
- 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/checkoutFlexTreeView.d.ts +3 -3
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +5 -20
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +3 -2
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +9 -6
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts +6 -31
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeApiAlpha.js +3 -18
- package/lib/shared-tree/treeApiAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.js +2 -2
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +8 -2
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js +9 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +3 -3
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +42 -12
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +29 -2
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +4 -3
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +4 -3
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +12 -9
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +14 -23
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaFromSimple.js +56 -0
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
- package/lib/simple-tree/api/simpleSchema.d.ts +3 -0
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +11 -5
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +12 -3
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +4 -19
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +15 -15
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +16 -25
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +14 -10
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/flexList.d.ts +4 -5
- package/lib/simple-tree/flexList.d.ts.map +1 -1
- package/lib/simple-tree/flexList.js +0 -12
- package/lib/simple-tree/flexList.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +2 -0
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +34 -2
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +54 -3
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +4 -4
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +3 -7
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts +7 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +13 -5
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/util/cloneWithReplacements.d.ts +21 -0
- package/lib/util/cloneWithReplacements.d.ts.map +1 -0
- package/lib/util/cloneWithReplacements.js +34 -0
- package/lib/util/cloneWithReplacements.js.map +1 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/referenceCounting.d.ts +18 -0
- package/lib/util/referenceCounting.d.ts.map +1 -1
- package/lib/util/referenceCounting.js.map +1 -1
- package/package.json +22 -22
- package/src/core/forest/editableForest.ts +1 -52
- package/src/core/forest/forest.ts +17 -2
- package/src/core/forest/index.ts +0 -1
- package/src/core/index.ts +4 -2
- package/src/core/tree/anchorSet.ts +41 -10
- package/src/core/tree/delta.ts +8 -25
- package/src/core/tree/deltaUtil.ts +5 -5
- package/src/core/tree/index.ts +4 -1
- package/src/core/tree/pathTree.ts +72 -1
- package/src/core/tree/visitDelta.ts +38 -17
- package/src/core/tree/visitorUtils.ts +22 -36
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/chunkTree.ts +19 -8
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +9 -4
- package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -2
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
- package/src/feature-libraries/default-schema/index.ts +2 -0
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
- package/src/feature-libraries/deltaUtils.ts +1 -1
- package/src/feature-libraries/flex-tree/context.ts +4 -4
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
- package/src/feature-libraries/flex-tree/lazyField.ts +19 -10
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
- package/src/feature-libraries/index.ts +10 -8
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
- package/src/feature-libraries/initializeForest.ts +55 -0
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +12 -28
- package/src/feature-libraries/node-identifier/README.md +11 -0
- package/src/feature-libraries/node-identifier/index.ts +17 -0
- package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
- package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
- package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
- package/src/feature-libraries/object-forest/objectForest.ts +10 -3
- package/src/feature-libraries/treeCursorUtils.ts +1 -1
- package/src/index.ts +17 -10
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
- package/src/shared-tree/independentView.ts +5 -29
- package/src/shared-tree/index.ts +1 -0
- package/src/shared-tree/schematizeTree.ts +3 -2
- package/src/shared-tree/schematizingTreeView.ts +3 -3
- package/src/shared-tree/sharedTree.ts +13 -9
- package/src/shared-tree/sharedTreeChangeFamily.ts +0 -1
- package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
- package/src/shared-tree/treeApiAlpha.ts +15 -78
- package/src/shared-tree/treeCheckout.ts +2 -2
- package/src/simple-tree/api/conciseTree.ts +25 -8
- package/src/simple-tree/api/create.ts +3 -3
- package/src/simple-tree/api/customTree.ts +59 -16
- package/src/simple-tree/api/index.ts +10 -1
- package/src/simple-tree/api/schemaFactory.ts +18 -32
- package/src/simple-tree/api/schemaFactoryAlpha.ts +12 -0
- package/src/simple-tree/api/schemaFromSimple.ts +68 -0
- package/src/simple-tree/api/simpleSchema.ts +10 -0
- package/src/simple-tree/api/tree.ts +13 -8
- package/src/simple-tree/api/treeNodeApi.ts +4 -17
- package/src/simple-tree/api/typesUnsafe.ts +15 -15
- package/src/simple-tree/api/verboseTree.ts +43 -55
- package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
- package/src/simple-tree/flexList.ts +4 -14
- package/src/simple-tree/index.ts +6 -0
- package/src/simple-tree/objectNode.ts +3 -0
- package/src/simple-tree/schemaTypes.ts +70 -4
- package/src/simple-tree/toMapTree.ts +6 -6
- package/src/simple-tree/toStoredSchema.ts +3 -6
- package/src/simple-tree/treeNodeValid.ts +16 -5
- package/src/util/cloneWithReplacements.ts +41 -0
- package/src/util/index.ts +2 -0
- package/src/util/referenceCounting.ts +18 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
- package/dist/feature-libraries/node-key/index.d.ts +0 -8
- package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/index.js +0 -16
- package/dist/feature-libraries/node-key/index.js.map +0 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
- package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
- package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
- package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/nodeKey.js +0 -26
- package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
- package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
- package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
- package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
- package/lib/feature-libraries/node-key/index.d.ts +0 -8
- package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/index.js +0 -8
- package/lib/feature-libraries/node-key/index.js.map +0 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
- package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
- package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
- package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/nodeKey.js +0 -22
- package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
- package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
- package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
- package/src/feature-libraries/node-key/README.md +0 -11
- package/src/feature-libraries/node-key/index.ts +0 -17
- package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
- package/src/feature-libraries/node-key/nodeKey.ts +0 -47
- package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
- /package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { NormalizedFieldUpPath, NormalizedUpPath } from "../../core/index.js";
|
|
7
|
+
import type {
|
|
8
|
+
IDefaultEditBuilder,
|
|
9
|
+
OptionalFieldEditBuilder,
|
|
10
|
+
SequenceFieldEditBuilder,
|
|
11
|
+
ValueFieldEditBuilder,
|
|
12
|
+
} from "./defaultEditBuilder.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* An IDefaultEditBuilder implementation based on another IDefaultEditBuilder that uses a different content type for insertions.
|
|
16
|
+
*/
|
|
17
|
+
export class MappedEditBuilder<TBase, TAdapted> implements IDefaultEditBuilder<TAdapted> {
|
|
18
|
+
public constructor(
|
|
19
|
+
private readonly baseBuilder: IDefaultEditBuilder<TBase>,
|
|
20
|
+
private readonly mapDelegate: (input: TAdapted) => TBase,
|
|
21
|
+
) {}
|
|
22
|
+
public valueField(field: NormalizedFieldUpPath): ValueFieldEditBuilder<TAdapted> {
|
|
23
|
+
const baseField = this.baseBuilder.valueField(field);
|
|
24
|
+
return {
|
|
25
|
+
set: (newContent: TAdapted): void => {
|
|
26
|
+
const mappedContent = this.mapDelegate(newContent);
|
|
27
|
+
baseField.set(mappedContent);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
public optionalField(field: NormalizedFieldUpPath): OptionalFieldEditBuilder<TAdapted> {
|
|
32
|
+
const baseField = this.baseBuilder.optionalField(field);
|
|
33
|
+
return {
|
|
34
|
+
set: (newContent: TAdapted | undefined, wasEmpty: boolean): void => {
|
|
35
|
+
const mappedContent =
|
|
36
|
+
newContent === undefined ? undefined : this.mapDelegate(newContent);
|
|
37
|
+
baseField.set(mappedContent, wasEmpty);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
public sequenceField(field: NormalizedFieldUpPath): SequenceFieldEditBuilder<TAdapted> {
|
|
42
|
+
const baseField = this.baseBuilder.sequenceField(field);
|
|
43
|
+
return {
|
|
44
|
+
insert: (index: number, content: TAdapted): void => {
|
|
45
|
+
const mappedContent = this.mapDelegate(content);
|
|
46
|
+
baseField.insert(index, mappedContent);
|
|
47
|
+
},
|
|
48
|
+
remove: (index: number, count: number): void => {
|
|
49
|
+
baseField.remove(index, count);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
public move(
|
|
54
|
+
sourceField: NormalizedFieldUpPath,
|
|
55
|
+
sourceIndex: number,
|
|
56
|
+
count: number,
|
|
57
|
+
destinationField: NormalizedFieldUpPath,
|
|
58
|
+
destinationIndex: number,
|
|
59
|
+
): void {
|
|
60
|
+
this.baseBuilder.move(sourceField, sourceIndex, count, destinationField, destinationIndex);
|
|
61
|
+
}
|
|
62
|
+
public addNodeExistsConstraint(path: NormalizedUpPath): void {
|
|
63
|
+
this.baseBuilder.addNodeExistsConstraint(path);
|
|
64
|
+
}
|
|
65
|
+
public addNodeExistsConstraintOnRevert(path: NormalizedUpPath): void {
|
|
66
|
+
this.baseBuilder.addNodeExistsConstraintOnRevert(path);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "../../core/index.js";
|
|
15
15
|
import type { Listenable } from "@fluidframework/core-interfaces";
|
|
16
16
|
import { type IDisposable, disposeSymbol } from "../../util/index.js";
|
|
17
|
-
import type {
|
|
17
|
+
import type { NodeIdentifierManager } from "../node-identifier/index.js";
|
|
18
18
|
|
|
19
19
|
import type { FlexTreeField } from "./flexTreeTypes.js";
|
|
20
20
|
import { type LazyEntity, prepareForEditSymbol } from "./lazyEntity.js";
|
|
@@ -56,7 +56,7 @@ export interface FlexTreeHydratedContext extends FlexTreeContext {
|
|
|
56
56
|
*/
|
|
57
57
|
get root(): FlexTreeField;
|
|
58
58
|
|
|
59
|
-
readonly nodeKeyManager:
|
|
59
|
+
readonly nodeKeyManager: NodeIdentifierManager;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* The checkout object associated with this context.
|
|
@@ -90,7 +90,7 @@ export class Context implements FlexTreeHydratedContext, IDisposable {
|
|
|
90
90
|
public constructor(
|
|
91
91
|
public readonly schemaPolicy: SchemaPolicy,
|
|
92
92
|
public readonly checkout: ITreeCheckout,
|
|
93
|
-
public readonly nodeKeyManager:
|
|
93
|
+
public readonly nodeKeyManager: NodeIdentifierManager,
|
|
94
94
|
) {
|
|
95
95
|
this.eventUnregister = [
|
|
96
96
|
this.checkout.forest.events.on("beforeChange", () => {
|
|
@@ -178,7 +178,7 @@ export class Context implements FlexTreeHydratedContext, IDisposable {
|
|
|
178
178
|
export function getTreeContext(
|
|
179
179
|
schema: SchemaPolicy,
|
|
180
180
|
checkout: ITreeCheckout,
|
|
181
|
-
nodeKeyManager:
|
|
181
|
+
nodeKeyManager: NodeIdentifierManager,
|
|
182
182
|
): Context {
|
|
183
183
|
return new Context(schema, checkout, nodeKeyManager);
|
|
184
184
|
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
type ExclusiveMapTree,
|
|
9
9
|
type FieldKey,
|
|
10
10
|
type FieldKindIdentifier,
|
|
11
|
-
type FieldUpPath,
|
|
12
11
|
type ITreeCursorSynchronous,
|
|
12
|
+
type NormalizedFieldUpPath,
|
|
13
13
|
type TreeNodeSchemaIdentifier,
|
|
14
14
|
type TreeValue,
|
|
15
15
|
anchorSlot,
|
|
@@ -255,7 +255,7 @@ export interface FlexTreeField extends FlexTreeEntity {
|
|
|
255
255
|
/**
|
|
256
256
|
* Gets the FieldUpPath of a field.
|
|
257
257
|
*/
|
|
258
|
-
getFieldPath():
|
|
258
|
+
getFieldPath(): NormalizedFieldUpPath;
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
261
|
* Schema for this entity.
|
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
type FieldAnchor,
|
|
14
14
|
type FieldKey,
|
|
15
15
|
type FieldKindIdentifier,
|
|
16
|
-
type FieldUpPath,
|
|
17
16
|
type ITreeCursorSynchronous,
|
|
18
17
|
type ITreeSubscriptionCursor,
|
|
18
|
+
type NormalizedFieldUpPath,
|
|
19
19
|
type TreeNavigationResult,
|
|
20
20
|
inCursorNode,
|
|
21
21
|
iterateCursorField,
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
import { disposeSymbol, fail, getOrCreate } from "../../util/index.js";
|
|
25
25
|
import {
|
|
26
26
|
FieldKinds,
|
|
27
|
+
MappedEditBuilder,
|
|
28
|
+
type IDefaultEditBuilder,
|
|
27
29
|
type OptionalFieldEditBuilder,
|
|
28
30
|
type SequenceFieldEditBuilder,
|
|
29
31
|
type ValueFieldEditBuilder,
|
|
@@ -54,7 +56,7 @@ import {
|
|
|
54
56
|
} from "./lazyEntity.js";
|
|
55
57
|
import { type LazyTreeNode, makeTree } from "./lazyNode.js";
|
|
56
58
|
import { indexForAt, treeStatusFromAnchorCache } from "./utilities.js";
|
|
57
|
-
import { cursorForMapTreeField
|
|
59
|
+
import { cursorForMapTreeField } from "../mapTreeCursor.js";
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* Reuse fields.
|
|
@@ -224,15 +226,15 @@ export abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexT
|
|
|
224
226
|
);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
public getFieldPath():
|
|
228
|
-
return this
|
|
229
|
+
public getFieldPath(): NormalizedFieldUpPath {
|
|
230
|
+
return { parent: this.parent?.anchorNode, field: this.key };
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
/**
|
|
232
234
|
* Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.
|
|
233
235
|
* This path is not valid to hold onto across edits: this must be recalled for each edit.
|
|
234
236
|
*/
|
|
235
|
-
public getFieldPathForEditing():
|
|
237
|
+
public getFieldPathForEditing(): NormalizedFieldUpPath {
|
|
236
238
|
if (!this[isFreedSymbol]()) {
|
|
237
239
|
if (
|
|
238
240
|
// Only allow editing if we are the root document field...
|
|
@@ -247,6 +249,13 @@ export abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexT
|
|
|
247
249
|
|
|
248
250
|
throw new UsageError("Editing only allowed on fields with TreeStatus.InDocument status");
|
|
249
251
|
}
|
|
252
|
+
|
|
253
|
+
protected getEditor(): IDefaultEditBuilder<ITreeCursorSynchronous> {
|
|
254
|
+
return new MappedEditBuilder(
|
|
255
|
+
this.context.checkout.editor,
|
|
256
|
+
(cursor: ITreeCursorSynchronous) => this.context.checkout.forest.chunkField(cursor),
|
|
257
|
+
);
|
|
258
|
+
}
|
|
250
259
|
}
|
|
251
260
|
|
|
252
261
|
export class LazySequence extends LazyField implements FlexTreeSequenceField {
|
|
@@ -274,7 +283,7 @@ export class LazySequence extends LazyField implements FlexTreeSequenceField {
|
|
|
274
283
|
|
|
275
284
|
private sequenceEditor(): SequenceFieldEditBuilder<ITreeCursorSynchronous> {
|
|
276
285
|
const fieldPath = this.getFieldPathForEditing();
|
|
277
|
-
return this.
|
|
286
|
+
return this.getEditor().sequenceField(fieldPath);
|
|
278
287
|
}
|
|
279
288
|
}
|
|
280
289
|
|
|
@@ -293,13 +302,13 @@ export class ReadonlyLazyValueField extends LazyField implements FlexTreeRequire
|
|
|
293
302
|
export class LazyValueField extends ReadonlyLazyValueField implements FlexTreeRequiredField {
|
|
294
303
|
public override editor: ValueFieldEditBuilder<ExclusiveMapTree> = {
|
|
295
304
|
set: (newContent) => {
|
|
296
|
-
this.valueFieldEditor().set(
|
|
305
|
+
this.valueFieldEditor().set(cursorForMapTreeField([newContent]));
|
|
297
306
|
},
|
|
298
307
|
};
|
|
299
308
|
|
|
300
309
|
private valueFieldEditor(): ValueFieldEditBuilder<ITreeCursorSynchronous> {
|
|
301
310
|
const fieldPath = this.getFieldPathForEditing();
|
|
302
|
-
const fieldEditor = this.
|
|
311
|
+
const fieldEditor = this.getEditor().valueField(fieldPath);
|
|
303
312
|
return fieldEditor;
|
|
304
313
|
}
|
|
305
314
|
|
|
@@ -312,7 +321,7 @@ export class LazyOptionalField extends LazyField implements FlexTreeOptionalFiel
|
|
|
312
321
|
public editor: OptionalFieldEditBuilder<ExclusiveMapTree> = {
|
|
313
322
|
set: (newContent, wasEmpty) => {
|
|
314
323
|
this.optionalEditor().set(
|
|
315
|
-
newContent !== undefined ?
|
|
324
|
+
newContent !== undefined ? cursorForMapTreeField([newContent]) : newContent,
|
|
316
325
|
wasEmpty,
|
|
317
326
|
);
|
|
318
327
|
},
|
|
@@ -320,7 +329,7 @@ export class LazyOptionalField extends LazyField implements FlexTreeOptionalFiel
|
|
|
320
329
|
|
|
321
330
|
private optionalEditor(): OptionalFieldEditBuilder<ITreeCursorSynchronous> {
|
|
322
331
|
const fieldPath = this.getFieldPathForEditing();
|
|
323
|
-
const fieldEditor = this.
|
|
332
|
+
const fieldEditor = this.getEditor().optionalField(fieldPath);
|
|
324
333
|
return fieldEditor;
|
|
325
334
|
}
|
|
326
335
|
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
applyDelta,
|
|
26
26
|
forEachField,
|
|
27
27
|
makeDetachedFieldIndex,
|
|
28
|
-
mapCursorField,
|
|
29
28
|
} from "../../core/index.js";
|
|
30
29
|
import type {
|
|
31
30
|
Summarizable,
|
|
@@ -34,7 +33,7 @@ import type {
|
|
|
34
33
|
} from "../../shared-tree-core/index.js";
|
|
35
34
|
import { idAllocatorFromMaxId } from "../../util/index.js";
|
|
36
35
|
// eslint-disable-next-line import/no-internal-modules
|
|
37
|
-
import {
|
|
36
|
+
import { chunkFieldSingle, defaultChunkPolicy } from "../chunked-forest/chunkTree.js";
|
|
38
37
|
import type { FieldBatchCodec, FieldBatchEncodingContext } from "../chunked-forest/index.js";
|
|
39
38
|
|
|
40
39
|
import { type ForestCodec, makeForestSummarizerCodec } from "./codec.js";
|
|
@@ -127,19 +126,16 @@ export class ForestSummarizer implements Summarizable {
|
|
|
127
126
|
const fieldChanges: [FieldKey, DeltaFieldChanges][] = [];
|
|
128
127
|
const build: DeltaDetachedNodeBuild[] = [];
|
|
129
128
|
for (const [fieldKey, field] of fields) {
|
|
130
|
-
const chunked =
|
|
129
|
+
const chunked = chunkFieldSingle(field, {
|
|
131
130
|
policy: defaultChunkPolicy,
|
|
132
131
|
idCompressor: this.idCompressor,
|
|
133
132
|
});
|
|
134
|
-
const
|
|
135
|
-
mapCursorField(chunk.cursor(), (cursor) => cursor.fork()),
|
|
136
|
-
);
|
|
137
|
-
const buildId = { minor: allocator.allocate(nodeCursors.length) };
|
|
133
|
+
const buildId = { minor: allocator.allocate(chunked.topLevelLength) };
|
|
138
134
|
build.push({
|
|
139
135
|
id: buildId,
|
|
140
|
-
trees:
|
|
136
|
+
trees: chunked,
|
|
141
137
|
});
|
|
142
|
-
fieldChanges.push([fieldKey, [{ count:
|
|
138
|
+
fieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
assert(this.forest.isEmpty, 0x797 /* forest must be empty */);
|
|
@@ -107,15 +107,15 @@ export {
|
|
|
107
107
|
} from "./chunked-forest/index.js";
|
|
108
108
|
|
|
109
109
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
type
|
|
114
|
-
|
|
115
|
-
type
|
|
110
|
+
compareLocalNodeIdentifiers,
|
|
111
|
+
createNodeIdentifierManager,
|
|
112
|
+
isStableNodeIdentifier,
|
|
113
|
+
type LocalNodeIdentifier,
|
|
114
|
+
MockNodeIdentifierManager,
|
|
115
|
+
type NodeIdentifierManager,
|
|
116
116
|
nodeKeyTreeIdentifier,
|
|
117
|
-
type
|
|
118
|
-
} from "./node-
|
|
117
|
+
type StableNodeIdentifier,
|
|
118
|
+
} from "./node-identifier/index.js";
|
|
119
119
|
|
|
120
120
|
export {
|
|
121
121
|
FieldKinds,
|
|
@@ -193,3 +193,5 @@ export {
|
|
|
193
193
|
type TreeIndexKey,
|
|
194
194
|
type TreeIndexNodes,
|
|
195
195
|
} from "./indexing/index.js";
|
|
196
|
+
|
|
197
|
+
export { initializeForest } from "./initializeForest.js";
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
CursorLocationType,
|
|
20
20
|
rootField,
|
|
21
21
|
type UpPath,
|
|
22
|
-
type ProtoNodes,
|
|
23
22
|
keyAsDetachedField,
|
|
24
23
|
compareUpPaths,
|
|
25
24
|
TreeNavigationResult,
|
|
25
|
+
type ITreeCursorSynchronous,
|
|
26
26
|
} from "../../core/index.js";
|
|
27
27
|
import type { TreeIndex, TreeIndexKey, TreeIndexNodes } from "./types.js";
|
|
28
28
|
import { TreeStatus } from "../flex-tree/index.js";
|
|
@@ -123,7 +123,7 @@ export class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>
|
|
|
123
123
|
|
|
124
124
|
return createAnnouncedVisitor({
|
|
125
125
|
// nodes (and their entire subtrees) are added to the index as soon as they are created
|
|
126
|
-
afterCreate: (content:
|
|
126
|
+
afterCreate: (content: readonly ITreeCursorSynchronous[], destination: FieldKey) => {
|
|
127
127
|
const detachedCursor = this.forest.allocateCursor();
|
|
128
128
|
assert(
|
|
129
129
|
this.forest.tryMoveCursorToField(
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SessionSpaceCompressedId, IIdCompressor } from "@fluidframework/id-compressor";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type DeltaRoot,
|
|
11
|
+
type IEditableForest,
|
|
12
|
+
type ITreeCursorSynchronous,
|
|
13
|
+
type RevisionTagCodec,
|
|
14
|
+
combineVisitors,
|
|
15
|
+
deltaForRootInitialization,
|
|
16
|
+
makeDetachedFieldIndex,
|
|
17
|
+
visitDelta,
|
|
18
|
+
} from "../core/index.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the given forest with the given content.
|
|
22
|
+
* @remarks The forest must be empty when this function is called.
|
|
23
|
+
* This does not perform an edit in the typical sense.
|
|
24
|
+
* Instead, it creates a delta expressing a creation and insertion of the `content` under the {@link rootFieldKey}, and then applies the delta to the forest.
|
|
25
|
+
* If `visitAnchors` is enabled, then the delta will also be applied to the forest's {@link AnchorSet} (in which case there must be no existing anchors when this function is called).
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* This does not perform an edit: it updates the forest content as if there was an edit that did that.
|
|
29
|
+
*/
|
|
30
|
+
export function initializeForest(
|
|
31
|
+
forest: IEditableForest,
|
|
32
|
+
content: ITreeCursorSynchronous,
|
|
33
|
+
revisionTagCodec: RevisionTagCodec,
|
|
34
|
+
idCompressor: IIdCompressor,
|
|
35
|
+
visitAnchors = false,
|
|
36
|
+
): void {
|
|
37
|
+
assert(forest.isEmpty, 0x747 /* forest must be empty */);
|
|
38
|
+
const delta: DeltaRoot = deltaForRootInitialization(forest.chunkField(content));
|
|
39
|
+
let visitor = forest.acquireVisitor();
|
|
40
|
+
if (visitAnchors) {
|
|
41
|
+
assert(forest.anchors.isEmpty(), 0x9b7 /* anchor set must be empty */);
|
|
42
|
+
const anchorVisitor = forest.anchors.acquireVisitor();
|
|
43
|
+
visitor = combineVisitors([visitor, anchorVisitor]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// any detached trees built here are immediately attached so the revision used here doesn't matter
|
|
47
|
+
// we use a dummy revision to make correctness checks in the detached field index easier
|
|
48
|
+
visitDelta(
|
|
49
|
+
delta,
|
|
50
|
+
visitor,
|
|
51
|
+
makeDetachedFieldIndex("init", revisionTagCodec, idCompressor),
|
|
52
|
+
0 as SessionSpaceCompressedId,
|
|
53
|
+
);
|
|
54
|
+
visitor.free();
|
|
55
|
+
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type ChangeFamilyEditor,
|
|
14
14
|
type ChangeRebaser,
|
|
15
15
|
type ChangesetLocalId,
|
|
16
|
-
CursorLocationType,
|
|
17
16
|
type DeltaDetachedNodeBuild,
|
|
18
17
|
type DeltaDetachedNodeDestruction,
|
|
19
18
|
type DeltaDetachedNodeId,
|
|
@@ -24,14 +23,12 @@ import {
|
|
|
24
23
|
type FieldKey,
|
|
25
24
|
type FieldKindIdentifier,
|
|
26
25
|
type FieldUpPath,
|
|
27
|
-
type ITreeCursorSynchronous,
|
|
28
26
|
type RevisionInfo,
|
|
29
27
|
type RevisionMetadataSource,
|
|
30
28
|
type RevisionTag,
|
|
31
29
|
type TaggedChange,
|
|
32
30
|
type UpPath,
|
|
33
31
|
makeDetachedNodeId,
|
|
34
|
-
mapCursorField,
|
|
35
32
|
replaceAtomRevisions,
|
|
36
33
|
revisionMetadataSourceFromInfo,
|
|
37
34
|
areEqualChangeAtomIds,
|
|
@@ -59,13 +56,7 @@ import {
|
|
|
59
56
|
RangeMap,
|
|
60
57
|
balancedReduce,
|
|
61
58
|
} from "../../util/index.js";
|
|
62
|
-
import {
|
|
63
|
-
type TreeChunk,
|
|
64
|
-
chunkFieldSingle,
|
|
65
|
-
chunkTree,
|
|
66
|
-
defaultChunkPolicy,
|
|
67
|
-
} from "../chunked-forest/index.js";
|
|
68
|
-
import { cursorForMapTreeNode, mapTreeFromCursor } from "../mapTreeCursor.js";
|
|
59
|
+
import type { TreeChunk } from "../chunked-forest/index.js";
|
|
69
60
|
|
|
70
61
|
import {
|
|
71
62
|
type CrossFieldManager,
|
|
@@ -96,7 +87,6 @@ import {
|
|
|
96
87
|
type NodeChangeset,
|
|
97
88
|
type NodeId,
|
|
98
89
|
} from "./modularChangeTypes.js";
|
|
99
|
-
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
100
90
|
|
|
101
91
|
/**
|
|
102
92
|
* Implementation of ChangeFamily which delegates work in a given field to the appropriate FieldKind
|
|
@@ -2044,12 +2034,10 @@ function copyDetachedNodes(
|
|
|
2044
2034
|
const copiedDetachedNodes: DeltaDetachedNodeBuild[] = [];
|
|
2045
2035
|
for (const [[major, minor], chunk] of detachedNodes.entries()) {
|
|
2046
2036
|
if (chunk.topLevelLength > 0) {
|
|
2047
|
-
|
|
2048
|
-
cursorForMapTreeNode(mapTreeFromCursor(c)),
|
|
2049
|
-
);
|
|
2037
|
+
chunk.referenceAdded();
|
|
2050
2038
|
copiedDetachedNodes.push({
|
|
2051
2039
|
id: makeDetachedNodeId(major, minor),
|
|
2052
|
-
trees,
|
|
2040
|
+
trees: chunk,
|
|
2053
2041
|
});
|
|
2054
2042
|
}
|
|
2055
2043
|
}
|
|
@@ -2665,29 +2653,25 @@ export class ModularEditBuilder extends EditBuilder<ModularChangeset> {
|
|
|
2665
2653
|
|
|
2666
2654
|
/**
|
|
2667
2655
|
* @param firstId - The ID to associate with the first node
|
|
2668
|
-
* @param content - The node(s) to build.
|
|
2656
|
+
* @param content - The node(s) to build.
|
|
2669
2657
|
* @param revision - The revision to use for the build.
|
|
2670
2658
|
* @returns A description of the edit that can be passed to `submitChanges`.
|
|
2659
|
+
* The returned object may contain an owning reference to the given TreeChunk.
|
|
2671
2660
|
*/
|
|
2672
2661
|
public buildTrees(
|
|
2673
2662
|
firstId: ChangesetLocalId,
|
|
2674
|
-
content:
|
|
2663
|
+
content: TreeChunk,
|
|
2675
2664
|
revision: RevisionTag,
|
|
2676
|
-
idCompressor?: IIdCompressor,
|
|
2677
2665
|
): GlobalEditDescription {
|
|
2678
|
-
if (content.
|
|
2666
|
+
if (content.topLevelLength === 0) {
|
|
2679
2667
|
return { type: "global", revision };
|
|
2680
2668
|
}
|
|
2669
|
+
|
|
2670
|
+
// This content will be added to a GlobalEditDescription whose lifetime exceeds the scope of this function.
|
|
2671
|
+
content.referenceAdded();
|
|
2672
|
+
|
|
2681
2673
|
const builds: ChangeAtomIdBTree<TreeChunk> = newTupleBTree();
|
|
2682
|
-
|
|
2683
|
-
policy: defaultChunkPolicy,
|
|
2684
|
-
idCompressor,
|
|
2685
|
-
};
|
|
2686
|
-
const chunk =
|
|
2687
|
-
content.mode === CursorLocationType.Fields
|
|
2688
|
-
? chunkFieldSingle(content, chunkCompressor)
|
|
2689
|
-
: chunkTree(content, chunkCompressor);
|
|
2690
|
-
builds.set([revision, firstId], chunk);
|
|
2674
|
+
builds.set([revision, firstId], content);
|
|
2691
2675
|
|
|
2692
2676
|
return {
|
|
2693
2677
|
type: "global",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Node Identifier
|
|
2
|
+
|
|
3
|
+
Nodes identifiers provide references to nodes in a shared tree.
|
|
4
|
+
|
|
5
|
+
## Local Node Identifier
|
|
6
|
+
|
|
7
|
+
Local node identifiers are an efficient representation of a node identifier and are unique within the local session (machine memory).
|
|
8
|
+
|
|
9
|
+
## Stable Node Identifier
|
|
10
|
+
|
|
11
|
+
Stable node identifiers are UUIDs that are globally unique and can be persisted outside of the document.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { MockNodeIdentifierManager } from "./mockNodeIdentifierManager.js";
|
|
7
|
+
export {
|
|
8
|
+
compareLocalNodeIdentifiers,
|
|
9
|
+
type LocalNodeIdentifier,
|
|
10
|
+
type StableNodeIdentifier,
|
|
11
|
+
nodeKeyTreeIdentifier,
|
|
12
|
+
} from "./nodeIdentifier.js";
|
|
13
|
+
export {
|
|
14
|
+
createNodeIdentifierManager,
|
|
15
|
+
isStableNodeIdentifier,
|
|
16
|
+
type NodeIdentifierManager,
|
|
17
|
+
} from "./nodeIdentifierManager.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { SessionSpaceCompressedId, StableId } from "@fluidframework/id-compressor";
|
|
8
|
+
import { assertIsStableId } from "@fluidframework/id-compressor/internal";
|
|
9
|
+
import type { LocalNodeIdentifier, StableNodeIdentifier } from "./nodeIdentifier.js";
|
|
10
|
+
import {
|
|
11
|
+
isStableNodeIdentifier,
|
|
12
|
+
type NodeIdentifierManager,
|
|
13
|
+
} from "./nodeIdentifierManager.js";
|
|
14
|
+
import { brand, extractFromOpaque, fail } from "../../util/index.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Mock {@link NodeIdentifierManager} that generates deterministic {@link StableNodeIdentifier}s and {@link LocalNodeIdentifier}s.
|
|
18
|
+
* @remarks This is useful for test environments because it will always yield the same keys in the same order.
|
|
19
|
+
* It should not be used for production environments for the same reason; the {@link StableNodeIdentifier}s are not universally unique.
|
|
20
|
+
*/
|
|
21
|
+
export class MockNodeIdentifierManager implements NodeIdentifierManager {
|
|
22
|
+
private count = 0;
|
|
23
|
+
|
|
24
|
+
public generateStableNodeIdentifier(): StableNodeIdentifier {
|
|
25
|
+
return brand(this.getId(this.count++));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public generateLocalNodeIdentifier(): LocalNodeIdentifier {
|
|
29
|
+
return this.localizeNodeIdentifier(this.generateStableNodeIdentifier());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public localizeNodeIdentifier(key: StableNodeIdentifier): LocalNodeIdentifier {
|
|
33
|
+
return (
|
|
34
|
+
this.tryLocalizeNodeIdentifier(key) ?? fail(0xb26 /* Identifier is not compressible */)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public stabilizeNodeIdentifier(key: LocalNodeIdentifier): StableNodeIdentifier {
|
|
39
|
+
return brand(this.getId(extractFromOpaque(key)));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public tryLocalizeNodeIdentifier(key: string): LocalNodeIdentifier | undefined {
|
|
43
|
+
if (!isStableNodeIdentifier(key) || !key.startsWith("a110ca7e-add1-4000-8000-")) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const localNodeIdentifier = Number.parseInt(key.substring(24), 16);
|
|
47
|
+
return localNodeIdentifier < this.count
|
|
48
|
+
? brand(localNodeIdentifier as SessionSpaceCompressedId)
|
|
49
|
+
: undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public getId(offset: number): StableId {
|
|
53
|
+
assert(offset >= 0, 0x6e7 /* UUID offset may not be negative */);
|
|
54
|
+
assert(offset < 281_474_976_710_656, 0x6e8 /* UUID offset must be at most 16^12 */);
|
|
55
|
+
return assertIsStableId(
|
|
56
|
+
`a110ca7e-add1-4000-8000-${Math.round(offset).toString(16).padStart(12, "0")}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SessionSpaceCompressedId, StableId } from "@fluidframework/id-compressor";
|
|
7
|
+
|
|
8
|
+
import type { TreeNodeSchemaIdentifier } from "../../core/index.js";
|
|
9
|
+
import { type Brand, type Opaque, brand } from "../../util/index.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An identifier which uniquely identifies a node in the tree within this session.
|
|
13
|
+
* @remarks {@link LocalNodeIdentifier}s must not be serialized and stored as data without first being converted into a {@link StableNodeIdentifier}.
|
|
14
|
+
* They are local to the current session and equivalent nodes in another session will not necessarily have the same {@link LocalNodeIdentifier}.
|
|
15
|
+
* However, they are otherwise preferential to use over {@link StableNodeIdentifier}s as they are much smaller.
|
|
16
|
+
* For example, they are more efficient than {@link StableNodeIdentifier}s when used as keys in a map.
|
|
17
|
+
* {@link LocalNodeIdentifier}s may be compared or equated via {@link compareLocalNodeIdentifiers}.
|
|
18
|
+
*/
|
|
19
|
+
export interface LocalNodeIdentifier
|
|
20
|
+
extends Opaque<Brand<SessionSpaceCompressedId, "Local Node Identifier">> {}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A UUID which identifies a node in the tree.
|
|
24
|
+
* This key is universally unique and stable forever; therefore it is safe to persist as data in a SharedTree or other DDS/database.
|
|
25
|
+
* When not persisted or serialized, it is preferable to use a {@link LocalNodeIdentifier} instead for better performance.
|
|
26
|
+
*/
|
|
27
|
+
export type StableNodeIdentifier = Brand<StableId, "Stable Node Identifier">;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Compares two {@link LocalNodeIdentifier}s.
|
|
31
|
+
* All {@link LocalNodeIdentifier}s retrieved from a single SharedTree client can be totally ordered using this comparator.
|
|
32
|
+
* @param a - the first identifier to compare
|
|
33
|
+
* @param b - the second identifier to compare
|
|
34
|
+
* @returns `0` if `a` and `b` are the same identifier, otherwise `-1` if `a` is ordered before `b` or `1` if `a` is ordered after `b`.
|
|
35
|
+
*/
|
|
36
|
+
export function compareLocalNodeIdentifiers(
|
|
37
|
+
a: LocalNodeIdentifier,
|
|
38
|
+
b: LocalNodeIdentifier,
|
|
39
|
+
): -1 | 0 | 1 {
|
|
40
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The TreeNodeSchemaIdentifier for node identifiers.
|
|
45
|
+
* @privateRemarks TODO: Come up with a unified and collision-resistant naming schema for types defined by the system.
|
|
46
|
+
* For now, we'll use `__` to reduce the change of collision, since this is what other internal properties use in Fluid.
|
|
47
|
+
*/
|
|
48
|
+
export const nodeKeyTreeIdentifier: TreeNodeSchemaIdentifier = brand(
|
|
49
|
+
"com.fluidframework.nodeIdentifier.NodeIdentifier",
|
|
50
|
+
);
|