@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitorUtils.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"visitorUtils.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAkB,IAAI,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM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K,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5E,aAAa,CACZ,UAAU,EAAE,QAAQ,EACpB,UAAU,EAAE,KAAK,EACjB,qBAAqB,EAAE,QAAQ,GAC7B,IAAI,CAAC;IACR,YAAY,CAAC,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACzC,gBAAgB,CAsBlB"}
|
|
@@ -53,16 +53,19 @@ function combineVisitors(visitors, announcedVisitors = []) {
|
|
|
53
53
|
attach: (source, count, destination) => {
|
|
54
54
|
announcedVisitors.forEach((v) => v.beforeAttach(source, count, destination));
|
|
55
55
|
visitors.forEach((v) => v.attach(source, count, destination));
|
|
56
|
-
announcedVisitors.forEach((v) => v.afterAttach(source, {
|
|
56
|
+
announcedVisitors.forEach((v) => v.afterAttach(source, {
|
|
57
|
+
start: destination,
|
|
58
|
+
end: destination + count,
|
|
59
|
+
}));
|
|
57
60
|
},
|
|
58
|
-
detach: (source, destination) => {
|
|
61
|
+
detach: (source, destination, id) => {
|
|
59
62
|
announcedVisitors.forEach((v) => v.beforeDetach(source, destination));
|
|
60
|
-
visitors.forEach((v) => v.detach(source, destination));
|
|
63
|
+
visitors.forEach((v) => v.detach(source, destination, id));
|
|
61
64
|
announcedVisitors.forEach((v) => v.afterDetach(source.start, source.end - source.start, destination));
|
|
62
65
|
},
|
|
63
|
-
replace: (newContent, oldContent, oldContentDestination) => {
|
|
66
|
+
replace: (newContent, oldContent, oldContentDestination, oldContentId) => {
|
|
64
67
|
announcedVisitors.forEach((v) => v.beforeReplace(newContent, oldContent, oldContentDestination));
|
|
65
|
-
visitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination));
|
|
68
|
+
visitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination, oldContentId));
|
|
66
69
|
announcedVisitors.forEach((v) => v.afterReplace(newContent, oldContent, oldContentDestination));
|
|
67
70
|
},
|
|
68
71
|
enterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitorUtils.js","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,kDAA6E;AAK7E,mEAA6D;AAG7D,mDAAgE;AAGhE,SAAgB,sBAAsB,CACrC,SAAiB,MAAM,EACvB,gBAAkC,EAClC,YAA2B,EAC3B,OAAuB;IAEvB,OAAO,IAAI,0CAAkB,CAC5B,MAAM,EACN,IAAA,+BAAoB,GAA+B,EACnD,gBAAgB,EAChB,YAAY,EACZ,OAAO,CACP,CAAC;AACH,CAAC;AAbD,wDAaC;AAED,SAAgB,UAAU,CACzB,KAAW,EACX,cAAuC,EACvC,cAAsD,EACtD,kBAAsC;IAEtC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IAChD,IAAA,0BAAU,EAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AATD,gCASC;AAED,SAAgB,aAAa,CAC5B,KAAW,EACX,cAAuC,EACvC,cAAyE,EACzE,kBAAsC;IAEtC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IAChD,IAAA,0BAAU,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAC7F,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AATD,sCASC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC9B,QAAiC,EACjC,oBAAiD,EAAE;IAEnD,CAAC;QACA,M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AAY,IAAI,IAAI;QACnD,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,aAAa,EAAE,gBAAgB,CAAC,aAAa,IAAI,IAAI;QACrD,OAAO,EAAE,gBAAgB,CAAC,OAAO,IAAI,IAAI;QACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;QAC7C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,IAAI,IAAI;QAC3C,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI;QAC/C,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;KAC7C,CAAC;AACH,CAAC;AAjDD,wDAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ICodecOptions } from \"../../codec/index.js\";\nimport { type IdAllocator, idAllocatorFromMaxId } from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { ProtoNodes, Root } from \"./delta.js\";\nimport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\nimport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport function makeDetachedFieldIndex(\n\tprefix: string = \"Temp\",\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\toptions?: ICodecOptions,\n): DetachedFieldIndex {\n\treturn new DetachedFieldIndex(\n\t\tprefix,\n\t\tidAllocatorFromMaxId() as IdAllocator<ForestRootId>,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\toptions,\n\t);\n}\n\nexport function applyDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, visitor, detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\nexport function announceDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor & AnnouncedVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, combineVisitors([visitor], [visitor]), detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\n/**\n * @param visitors - The returned visitor invokes the corresponding events for all these visitors, in order.\n * @param announcedVisitors - Subset of `visitors` to also call {@link AnnouncedVisitor} methods on.\n * This must be a subset of `visitors`: if not the visitor will not have its path correctly set when the events are triggered.\n * When `visitors` are making changes to data, `announcedVisitors` can be used to get extra events before or after all the changes from all the visitors have been made.\n * This can, for example, enable visitors to have access to the tree in these extra events despite multiple separate visitors updating different tree related data-structures.\n * @returns a DeltaVisitor combining all `visitors`.\n */\nexport function combineVisitors(\n\tvisitors: readonly DeltaVisitor[],\n\tannouncedVisitors: readonly AnnouncedVisitor[] = [],\n): DeltaVisitor {\n\t{\n\t\tconst set = new Set(visitors);\n\t\tfor (const item of announcedVisitors) {\n\t\t\tassert(set.has(item), 0x8c8 /* AnnouncedVisitor would not get traversed */);\n\t\t}\n\t}\n\treturn {\n\t\tfree: () => visitors.forEach((v) => v.free()),\n\t\tcreate: (...args) => {\n\t\t\tvisitors.forEach((v) => v.create(...args));\n\t\t\tannouncedVisitors.forEach((v) => v.afterCreate(...args));\n\t\t},\n\t\tdestroy: (...args) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDestroy(...args));\n\t\t\tvisitors.forEach((v) => v.destroy(...args));\n\t\t},\n\t\tattach: (source: FieldKey, count: number, destination: PlaceIndex) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeAttach(source, count, destination));\n\t\t\tvisitors.forEach((v) => v.attach(source, count, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterAttach(source, { start: destination, end: destination + count }),\n\t\t\t);\n\t\t},\n\t\tdetach: (source: Range, destination: FieldKey) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDetach(source, destination));\n\t\t\tvisitors.forEach((v) => v.detach(source, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterDetach(source.start, source.end - source.start, destination),\n\t\t\t);\n\t\t},\n\t\treplace: (newContent: FieldKey, oldContent: Range, oldContentDestination: FieldKey) => {\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.beforeReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t\tvisitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t},\n\t\tenterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),\n\t\texitNode: (...args) => visitors.forEach((v) => v.exitNode(...args)),\n\t\tenterField: (...args) => visitors.forEach((v) => v.enterField(...args)),\n\t\texitField: (...args) => visitors.forEach((v) => v.exitField(...args)),\n\t};\n}\n\n/**\n * Visitor that is notified of changes before, after, and when changes are made.\n * Must be freed after use.\n */\nexport interface AnnouncedVisitor extends DeltaVisitor {\n\t/**\n\t * A hook that is called after all nodes have been created.\n\t */\n\tafterCreate(content: ProtoNodes, destination: FieldKey): void;\n\tbeforeDestroy(field: FieldKey, count: number): void;\n\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\tafterAttach(source: FieldKey, destination: Range): void;\n\tbeforeDetach(source: Range, destination: FieldKey): void;\n\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void;\n\tbeforeReplace(\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t): void;\n\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void;\n}\n\n/**\n * Creates an announced visitor with only the provided functions and uses a no op for the rest.\n * This is provided to make some of the delta visitor definitions cleaner.\n */\nexport function createAnnouncedVisitor(visitorFunctions: {\n\tfree?: () => void;\n\tcreate?: (content: ProtoNodes, destination: FieldKey) => void;\n\tafterCreate?: (content: ProtoNodes, destination: FieldKey) => void;\n\tbeforeDestroy?: (field: FieldKey, count: number) => void;\n\tdestroy?: (detachedField: FieldKey, count: number) => void;\n\tbeforeAttach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;\n\tattach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;\n\tafterAttach?: (source: FieldKey, destination: Range) => void;\n\tbeforeDetach?: (source: Range, destination: FieldKey) => void;\n\tafterDetach?: (source: PlaceIndex, count: number, destination: FieldKey) => void;\n\tdetach?: (source: Range, destination: FieldKey) => void;\n\tbeforeReplace?: (\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t) => void;\n\treplace?: (\n\t\tnewContentSource: FieldKey,\n\t\trange: Range,\n\t\toldContentDestination: FieldKey,\n\t) => void;\n\tafterReplace?: (newContentSource: FieldKey, newContent: Range, oldContent: FieldKey) => void;\n\tenterNode?: (index: NodeIndex) => void;\n\texitNode?: (index: NodeIndex) => void;\n\tenterField?: (key: FieldKey) => void;\n\texitField?: (key: FieldKey) => void;\n}): AnnouncedVisitor {\n\tconst noOp = (): void => {};\n\treturn {\n\t\tfree: visitorFunctions.free ?? noOp,\n\t\tcreate: visitorFunctions.create ?? noOp,\n\t\tafterCreate: visitorFunctions.afterCreate ?? noOp,\n\t\tbeforeDestroy: visitorFunctions.beforeDestroy ?? noOp,\n\t\tdestroy: visitorFunctions.destroy ?? noOp,\n\t\tbeforeAttach: visitorFunctions.beforeAttach ?? noOp,\n\t\tattach: visitorFunctions.attach ?? noOp,\n\t\tafterAttach: visitorFunctions.afterAttach ?? noOp,\n\t\tbeforeDetach: visitorFunctions.beforeDetach ?? noOp,\n\t\tdetach: visitorFunctions.detach ?? noOp,\n\t\tafterDetach: visitorFunctions.afterDetach ?? noOp,\n\t\tbeforeReplace: visitorFunctions.beforeReplace ?? noOp,\n\t\treplace: visitorFunctions.replace ?? noOp,\n\t\tafterReplace: visitorFunctions.afterReplace ?? noOp,\n\t\tenterNode: visitorFunctions.enterNode ?? noOp,\n\t\texitNode: visitorFunctions.exitNode ?? noOp,\n\t\tenterField: visitorFunctions.enterField ?? noOp,\n\t\texitField: visitorFunctions.exitField ?? noOp,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"visitorUtils.js","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,kDAA6E;AAK7E,mEAA6D;AAG7D,mDAAgE;AAIhE,SAAgB,sBAAsB,CACrC,SAAiB,MAAM,EACvB,gBAAkC,EAClC,YAA2B,EAC3B,OAAuB;IAEvB,OAAO,IAAI,0CAAkB,CAC5B,MAAM,EACN,IAAA,+BAAoB,GAA+B,EACnD,gBAAgB,EAChB,YAAY,EACZ,OAAO,CACP,CAAC;AACH,CAAC;AAbD,wDAaC;AAED,SAAgB,UAAU,CACzB,KAAW,EACX,cAAuC,EACvC,cAAsD,EACtD,kBAAsC;IAEtC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IAChD,IAAA,0BAAU,EAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AATD,gCASC;AAED,SAAgB,aAAa,CAC5B,KAAW,EACX,cAAuC,EACvC,cAAyE,EACzE,kBAAsC;IAE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AI;QACnC,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,aAAa,EAAE,gBAAgB,CAAC,aAAa,IAAI,IAAI;QACrD,OAAO,EAAE,gBAAgB,CAAC,OAAO,IAAI,IAAI;QACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,aAAa,EAAE,gBAAgB,CAAC,aAAa,IAAI,IAAI;QACrD,OAAO,EAAE,gBAAgB,CAAC,OAAO,IAAI,IAAI;QACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;QAC7C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,IAAI,IAAI;QAC3C,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI;QAC/C,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;KAC7C,CAAC;AACH,CAAC;AAxBD,wDAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ICodecOptions } from \"../../codec/index.js\";\nimport { type IdAllocator, idAllocatorFromMaxId } from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { DetachedNodeId, Root } from \"./delta.js\";\nimport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\nimport type { PlaceIndex, Range } from \"./pathTree.js\";\nimport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ITreeCursorSynchronous } from \"./cursor.js\";\n\nexport function makeDetachedFieldIndex(\n\tprefix: string = \"Temp\",\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\toptions?: ICodecOptions,\n): DetachedFieldIndex {\n\treturn new DetachedFieldIndex(\n\t\tprefix,\n\t\tidAllocatorFromMaxId() as IdAllocator<ForestRootId>,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\toptions,\n\t);\n}\n\nexport function applyDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, visitor, detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\nexport function announceDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor & AnnouncedVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, combineVisitors([visitor], [visitor]), detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\n/**\n * @param visitors - The returned visitor invokes the corresponding events for all these visitors, in order.\n * @param announcedVisitors - Subset of `visitors` to also call {@link AnnouncedVisitor} methods on.\n * This must be a subset of `visitors`: if not the visitor will not have its path correctly set when the events are triggered.\n * When `visitors` are making changes to data, `announcedVisitors` can be used to get extra events before or after all the changes from all the visitors have been made.\n * This can, for example, enable visitors to have access to the tree in these extra events despite multiple separate visitors updating different tree related data-structures.\n * @returns a DeltaVisitor combining all `visitors`.\n */\nexport function combineVisitors(\n\tvisitors: readonly DeltaVisitor[],\n\tannouncedVisitors: readonly AnnouncedVisitor[] = [],\n): DeltaVisitor {\n\t{\n\t\tconst set = new Set(visitors);\n\t\tfor (const item of announcedVisitors) {\n\t\t\tassert(set.has(item), 0x8c8 /* AnnouncedVisitor would not get traversed */);\n\t\t}\n\t}\n\treturn {\n\t\tfree: () => visitors.forEach((v) => v.free()),\n\t\tcreate: (...args) => {\n\t\t\tvisitors.forEach((v) => v.create(...args));\n\t\t\tannouncedVisitors.forEach((v) => v.afterCreate(...args));\n\t\t},\n\t\tdestroy: (...args) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDestroy(...args));\n\t\t\tvisitors.forEach((v) => v.destroy(...args));\n\t\t},\n\t\tattach: (source: FieldKey, count: number, destination: PlaceIndex) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeAttach(source, count, destination));\n\t\t\tvisitors.forEach((v) => v.attach(source, count, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterAttach(source, {\n\t\t\t\t\tstart: destination,\n\t\t\t\t\tend: destination + count,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t\tdetach: (source: Range, destination: FieldKey, id: DetachedNodeId) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDetach(source, destination));\n\t\t\tvisitors.forEach((v) => v.detach(source, destination, id));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterDetach(source.start, source.end - source.start, destination),\n\t\t\t);\n\t\t},\n\t\treplace: (\n\t\t\tnewContent: FieldKey,\n\t\t\toldContent: Range,\n\t\t\toldContentDestination: FieldKey,\n\t\t\toldContentId: DetachedNodeId,\n\t\t) => {\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.beforeReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t\tvisitors.forEach((v) =>\n\t\t\t\tv.replace(newContent, oldContent, oldContentDestination, oldContentId),\n\t\t\t);\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t},\n\t\tenterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),\n\t\texitNode: (...args) => visitors.forEach((v) => v.exitNode(...args)),\n\t\tenterField: (...args) => visitors.forEach((v) => v.enterField(...args)),\n\t\texitField: (...args) => visitors.forEach((v) => v.exitField(...args)),\n\t};\n}\n\n/**\n * Visitor that is notified of changes before, after, and when changes are made.\n * Must be freed after use.\n */\nexport interface AnnouncedVisitor extends DeltaVisitor {\n\t/**\n\t * A hook that is called after all nodes have been created.\n\t */\n\tafterCreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\tbeforeDestroy(field: FieldKey, count: number): void;\n\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\tafterAttach(source: FieldKey, destination: Range): void;\n\tbeforeDetach(source: Range, destination: FieldKey): void;\n\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void;\n\tbeforeReplace(\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t): void;\n\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void;\n}\n\n/**\n * Creates an announced visitor with only the provided functions and uses a no op for the rest.\n * This is provided to make some of the delta visitor definitions cleaner.\n */\nexport function createAnnouncedVisitor(\n\tvisitorFunctions: Partial<AnnouncedVisitor>,\n): AnnouncedVisitor {\n\tconst noOp = (): void => {};\n\treturn {\n\t\tfree: visitorFunctions.free ?? noOp,\n\t\tcreate: visitorFunctions.create ?? noOp,\n\t\tafterCreate: visitorFunctions.afterCreate ?? noOp,\n\t\tbeforeDestroy: visitorFunctions.beforeDestroy ?? noOp,\n\t\tdestroy: visitorFunctions.destroy ?? noOp,\n\t\tbeforeAttach: visitorFunctions.beforeAttach ?? noOp,\n\t\tattach: visitorFunctions.attach ?? noOp,\n\t\tafterAttach: visitorFunctions.afterAttach ?? noOp,\n\t\tbeforeDetach: visitorFunctions.beforeDetach ?? noOp,\n\t\tdetach: visitorFunctions.detach ?? noOp,\n\t\tafterDetach: visitorFunctions.afterDetach ?? noOp,\n\t\tbeforeReplace: visitorFunctions.beforeReplace ?? noOp,\n\t\treplace: visitorFunctions.replace ?? noOp,\n\t\tafterReplace: visitorFunctions.afterReplace ?? noOp,\n\t\tenterNode: visitorFunctions.enterNode ?? noOp,\n\t\texitNode: visitorFunctions.exitNode ?? noOp,\n\t\tenterField: visitorFunctions.enterField ?? noOp,\n\t\texitField: visitorFunctions.exitField ?? noOp,\n\t};\n}\n"]}
|
|
@@ -52,7 +52,7 @@ export type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];
|
|
|
52
52
|
* Cursor over basic chunks.
|
|
53
53
|
*
|
|
54
54
|
* @remarks This implementation is similar to StackCursor, however it is distinct because:
|
|
55
|
-
* 1. The children are chunks, which might have a top level length that greater than 1.
|
|
55
|
+
* 1. The children are chunks, which might have a top level length that's greater than 1.
|
|
56
56
|
* 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).
|
|
57
57
|
*
|
|
58
58
|
* TODO:
|
|
@@ -65,7 +65,7 @@ exports.BasicChunk = BasicChunk;
|
|
|
65
65
|
* Cursor over basic chunks.
|
|
66
66
|
*
|
|
67
67
|
* @remarks This implementation is similar to StackCursor, however it is distinct because:
|
|
68
|
-
* 1. The children are chunks, which might have a top level length that greater than 1.
|
|
68
|
+
* 1. The children are chunks, which might have a top level length that's greater than 1.
|
|
69
69
|
* 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).
|
|
70
70
|
*
|
|
71
71
|
* TODO:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAc6B;AAC7B,kDAAiE;AACjE,8DAAsE;AAEt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CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD;AA/eD,4CA+eC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * Caller must have already accounted for references via `fields` to the children in the fields map (via `referenceAdded`).\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\t/**\n\t\t * Fields of this node.\n\t\t * @remarks\n\t\t * This object has exclusive deep ownership of this map (which might mutate it in the future).\n\t\t * Any code editing this map must update child reference counts.\n\t\t *\n\t\t * Like with {@link MapTree}, fields with no nodes must be removed from the map.\n\t\t */\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\t/**\n\t\t * The value on this node, if any.\n\t\t */\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(0xaee /* nested cursors should not be root */)\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(0xaef /* nested cursors should not be root */);\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? (prefix?.rootFieldOverride ?? this.getFieldKey())\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf0 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf1 /* Unexpected indexStack.length */);\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf2 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf3 /* Unexpected indexStack.length */);\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(0xaf4 /* Unexpected indexOfChunkStack.length */);\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ??\n\t\t\tfail(0xaf5 /* Unexpected indexWithinChunkStack.length */);\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAc6B;AAC7B,kDAAiE;AACjE,8DAAsE;AAEtE;;GAEG;AACH,MAAa,UAAW,SAAQ,+BAAoB;IAGnD;;;;OAIG;IACH,YACQ,IAA8B;IACrC;;;;;;;OAOG;IACI,MAAkC;IACzC;;OAEG;IACI,KAAiB;QAExB,KAAK,EAAE,CAAC;QAfD,SAAI,GAAJ,IAAI,CAA0B;QAS9B,WAAM,GAAN,MAAM,CAA4B;QAIlC,UAAK,GAAL,KAAK,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AAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED;;;OAGG;IACK,YAAY;QACnB,IAAA,iBAAM,EAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1F,IAAA,iBAAM,EACL,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC/B,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,YAAY,CAAC,UAAU,EACvD,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAC3C,CAAC;IAED,IAAW,UAAU;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,WAAW;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD;AA/eD,4CA+eC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * Caller must have already accounted for references via `fields` to the children in the fields map (via `referenceAdded`).\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\t/**\n\t\t * Fields of this node.\n\t\t * @remarks\n\t\t * This object has exclusive deep ownership of this map (which might mutate it in the future).\n\t\t * Any code editing this map must update child reference counts.\n\t\t *\n\t\t * Like with {@link MapTree}, fields with no nodes must be removed from the map.\n\t\t */\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\t/**\n\t\t * The value on this node, if any.\n\t\t */\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that's greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(0xaee /* nested cursors should not be root */)\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(0xaef /* nested cursors should not be root */);\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? (prefix?.rootFieldOverride ?? this.getFieldKey())\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf0 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf1 /* Unexpected indexStack.length */);\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf2 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf3 /* Unexpected indexStack.length */);\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(0xaf4 /* Unexpected indexOfChunkStack.length */);\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ??\n\t\t\tfail(0xaf5 /* Unexpected indexWithinChunkStack.length */);\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
|
|
@@ -145,10 +145,12 @@ export interface ChunkCompressor {
|
|
|
145
145
|
readonly idCompressor: IIdCompressor | undefined;
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
148
|
+
* Chunk a portion of a field.
|
|
149
|
+
*
|
|
150
|
+
* @param cursor - cursor at the starting node in the field.
|
|
149
151
|
* @param policy - heuristics to impact chunking
|
|
150
|
-
* @param length - how many nodes to process (at the top level)
|
|
151
|
-
* @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.
|
|
152
|
+
* @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)
|
|
153
|
+
* @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.
|
|
152
154
|
*/
|
|
153
155
|
export declare function chunkRange(cursor: ITreeCursorSynchronous, chunkCompressor: ChunkCompressor, length: number, skipLastNavigation: boolean): TreeChunk[];
|
|
154
156
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkTree.d.ts","sourceRoot":"","sources":["../../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js_1 = require("./sequenceChunk.js");
|
|
13
13
|
const uniformChunk_js_1 = require("./uniformChunk.js");
|
|
14
|
-
const index_js_3 = require("../node-
|
|
14
|
+
const index_js_3 = require("../node-identifier/index.js");
|
|
15
15
|
/**
|
|
16
16
|
* Creates a ChunkPolicy which responds to schema changes.
|
|
17
17
|
*/
|
|
@@ -97,7 +97,7 @@ exports.chunkTree = chunkTree;
|
|
|
97
97
|
function chunkField(cursor, policy) {
|
|
98
98
|
const length = cursor.getFieldLength();
|
|
99
99
|
const started = cursor.firstNode();
|
|
100
|
-
(0, internal_1.
|
|
100
|
+
(0, internal_1.debugAssert)(() => started === (length !== 0) || "only 0 length fields should not have nodes");
|
|
101
101
|
return chunkRange(cursor, policy, length, false);
|
|
102
102
|
}
|
|
103
103
|
exports.chunkField = chunkField;
|
|
@@ -221,13 +221,16 @@ function newBasicChunkTree(cursor, policy) {
|
|
|
221
221
|
return new basicChunk_js_1.BasicChunk(cursor.type, new Map((0, index_js_1.mapCursorFields)(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])), cursor.value);
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
|
-
*
|
|
224
|
+
* Chunk a portion of a field.
|
|
225
|
+
*
|
|
226
|
+
* @param cursor - cursor at the starting node in the field.
|
|
225
227
|
* @param policy - heuristics to impact chunking
|
|
226
|
-
* @param length - how many nodes to process (at the top level)
|
|
227
|
-
* @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.
|
|
228
|
+
* @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)
|
|
229
|
+
* @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.
|
|
228
230
|
*/
|
|
229
231
|
function chunkRange(cursor, chunkCompressor, length, skipLastNavigation) {
|
|
230
|
-
(0, internal_1.assert)(
|
|
232
|
+
(0, internal_1.assert)(!(skipLastNavigation && length === 0), 0xb58 /* Cannot skip last navigation if length is 0 and thus last navigation already occurred. */);
|
|
233
|
+
(0, internal_1.assert)((cursor.mode === 0 /* CursorLocationType.Nodes */) === length > 0, 0xb59 /* Should be in nodes mode if not past end */);
|
|
231
234
|
let output = [];
|
|
232
235
|
let remaining = length;
|
|
233
236
|
while (remaining > 0) {
|
|
@@ -319,7 +322,7 @@ function insertValues(cursor, shape, values, idCompressor) {
|
|
|
319
322
|
if (shape.hasValue) {
|
|
320
323
|
if (typeof cursor.value === "string" &&
|
|
321
324
|
idCompressor !== undefined &&
|
|
322
|
-
(0, index_js_3.
|
|
325
|
+
(0, index_js_3.isStableNodeIdentifier)(cursor.value)) {
|
|
323
326
|
values.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);
|
|
324
327
|
}
|
|
325
328
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,kDAkB6B;AAC7B,kDAAwD;AAGxD,mDAA6C;AAC7C,yDAAmD;AACnD,uDAA6E;AAC7E,mDAAuD;AAUvD;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAwB;IAExB,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,qBAAqB,EACxC,kBAAkB,CAClB,CAAC;AACH,CAAC;AAZD,0CAYC;AAaD;;;;;;;;GAQG;AACH,kEAAkE;AAClE,MAAa,WAAW;CAAG;AAA3B,kCAA2B;AAE3B;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAQ7C,MAAa,OAAO;IAUnB,YACiB,MAAoC,EACpC,MAAwB,EACxB,2BAAmC,EACnC,4BAAoC,EACpC,qBAA6B;IAC7C,wDAAwD;IACvC,kBAKH;QAXE,WAAM,GA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,iBAAiB,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,CAAC;YACD,MAAM;QACP,CAAC;QACD,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM;QACP,CAAC;QACD,cAAc,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,8BAAY,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACzF,CAAC;AA3BD,wDA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchema,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n\tValueSchema,\n\ttype TreeChunk,\n\ttryGetChunk,\n} from \"../../core/index.js\";\nimport { fail, getOrCreate } from \"../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\nimport { isStableNodeKey } from \"../node-key/index.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: FullSchemaPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\ttryShapeFromSchema,\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromSchema: (\n\t\t\tschema: TreeStoredSchema,\n\t\t\tpolicy: FullSchemaPolicy,\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.events.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromSchema(this.schema, this.policy, schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tassert(started, 0x57c /* field to chunk should have at least one node */);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport function shapesFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n): Map<TreeNodeSchemaIdentifier, ShapeInfo> {\n\tconst shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\tfor (const identifier of schema.nodeSchema.keys()) {\n\t\ttryShapeFromSchema(schema, policy, identifier, shapes);\n\t}\n\treturn shapes;\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeNodeSchemaIdentifier,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): ShapeInfo {\n\treturn getOrCreate(shapes, type, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(type) ?? fail(0xaf9 /* missing schema */);\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\t// Allow all string values (but only string values) to be compressed by the id compressor.\n\t\t\t// This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.\n\t\t\t// Attempting to compress other string shouldn't have significant overhead,\n\t\t\t// and if any of them do end up compressing, that's a benefit not a bug.\n\t\t\treturn treeSchema.leafValue === ValueSchema.String\n\t\t\t\t? new TreeShape(type, true, [], true)\n\t\t\t\t: new TreeShape(type, true, [], false);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, field] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(schema, policy, field, key, shapes);\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(type, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromFieldSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeFieldStoredSchema,\n\tkey: FieldKey,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): FieldShape | undefined {\n\tconst kind = policy.fieldKinds.get(type.kind) ?? fail(0xafa /* missing FieldKind */);\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (type.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...type.types][0] ?? oob();\n\tconst childShape = tryShapeFromSchema(schema, policy, childType, shapes);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nexport interface ChunkCompressor {\n\treadonly policy: ChunkPolicy;\n\t/**\n\t * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.\n\t * @remarks\n\t * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.\n\t * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n}\n\nfunction newBasicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * @param cursor - cursor in nodes mode\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tchunkCompressor: ChunkCompressor,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x57e /* should be in nodes */);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = chunkCompressor.policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t\tchunkCompressor.idCompressor,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, chunkCompressor));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(\n\t\t\toutput.length / chunkCompressor.policy.sequenceChunkSplitThreshold,\n\t\t);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n/**\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n\tidCompressor?: IIdCompressor,\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tif (\n\t\t\ttypeof cursor.value === \"string\" &&\n\t\t\tidCompressor !== undefined &&\n\t\t\tisStableNodeKey(cursor.value)\n\t\t) {\n\t\t\tvalues.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);\n\t\t} else {\n\t\t\tvalues.push(cursor.value);\n\t\t}\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values, idCompressor);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n *\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n\tidCompressor?: IIdCompressor,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values, idCompressor);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA+E;AAE/E,kDAkB6B;AAC7B,kDAAwD;AAGxD,mDAA6C;AAC7C,yDAAmD;AACnD,uDAA6E;AAC7E,0DAAqE;AAUrE;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAwB;IAExB,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,qBAAqB,EACxC,kBAAkB,CAClB,CAAC;AACH,CAAC;AAZD,0CAYC;AAaD;;;;;;;;GAQG;AACH,kEAAkE;AAClE,MAAa,WAAW;CAAG;AAA3B,kCAA2B;AAE3B;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAQ7C,MAAa,OAAO;IAUnB,YACiB,MAAoC,EACpC,MAAwB,EACxB,2BAAmC,EACnC,4BAAoC,EACpC,qBAA6B;IAC7C,wDAAwD;IACvC,kBAKH;QAXE,WAAM,GAAN,MAAM,CAA8B;QACpC,WAAM,GAAN,MAAM,CAAkB;QACxB,gCAA2B,GAA3B,2BAA2B,CAAQ;QACnC,iCAA4B,GAA5B,4BAA4B,CAAQ;QACpC,0BAAqB,GAArB,qBAAqB,CAAQ;QAE5B,uBAAkB,GAAlB,kBAAkB,CAKrB;QArBf;;;;WAIG;QACc,eAAU,GAA6C,IAAI,GAAG,EAAE,CAAC;IAiB/E,CAAC;IAEG,KAAK,CAAC,MAAoC;QAChD,oCAAoC;QACpC,sIAAsI;QACtI,OAAO,IAAI,OAAO,CACjB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AAC;QAClB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM;QACP,CAAC;QACD,cAAc,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,8BAAY,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACzF,CAAC;AA3BD,wDA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchema,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n\tValueSchema,\n\ttype TreeChunk,\n\ttryGetChunk,\n} from \"../../core/index.js\";\nimport { fail, getOrCreate } from \"../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\nimport { isStableNodeIdentifier } from \"../node-identifier/index.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: FullSchemaPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\ttryShapeFromSchema,\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromSchema: (\n\t\t\tschema: TreeStoredSchema,\n\t\t\tpolicy: FullSchemaPolicy,\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.events.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromSchema(this.schema, this.policy, schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tdebugAssert(\n\t\t() => started === (length !== 0) || \"only 0 length fields should not have nodes\",\n\t);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport function shapesFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n): Map<TreeNodeSchemaIdentifier, ShapeInfo> {\n\tconst shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\tfor (const identifier of schema.nodeSchema.keys()) {\n\t\ttryShapeFromSchema(schema, policy, identifier, shapes);\n\t}\n\treturn shapes;\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeNodeSchemaIdentifier,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): ShapeInfo {\n\treturn getOrCreate(shapes, type, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(type) ?? fail(0xaf9 /* missing schema */);\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\t// Allow all string values (but only string values) to be compressed by the id compressor.\n\t\t\t// This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.\n\t\t\t// Attempting to compress other string shouldn't have significant overhead,\n\t\t\t// and if any of them do end up compressing, that's a benefit not a bug.\n\t\t\treturn treeSchema.leafValue === ValueSchema.String\n\t\t\t\t? new TreeShape(type, true, [], true)\n\t\t\t\t: new TreeShape(type, true, [], false);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, field] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(schema, policy, field, key, shapes);\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(type, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * If `schema` has only one shape, return it.\n *\n * Note that this does not tolerate optional or sequence fields, nor does it optimize for patterns of specific values.\n */\nexport function tryShapeFromFieldSchema(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\ttype: TreeFieldStoredSchema,\n\tkey: FieldKey,\n\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n): FieldShape | undefined {\n\tconst kind = policy.fieldKinds.get(type.kind) ?? fail(0xafa /* missing FieldKind */);\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (type.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...type.types][0] ?? oob();\n\tconst childShape = tryShapeFromSchema(schema, policy, childType, shapes);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nexport interface ChunkCompressor {\n\treadonly policy: ChunkPolicy;\n\t/**\n\t * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.\n\t * @remarks\n\t * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.\n\t * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n}\n\nfunction newBasicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * Chunk a portion of a field.\n *\n * @param cursor - cursor at the starting node in the field.\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tchunkCompressor: ChunkCompressor,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(\n\t\t!(skipLastNavigation && length === 0),\n\t\t0xb58 /* Cannot skip last navigation if length is 0 and thus last navigation already occurred. */,\n\t);\n\tassert(\n\t\t(cursor.mode === CursorLocationType.Nodes) === length > 0,\n\t\t0xb59 /* Should be in nodes mode if not past end */,\n\t);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = chunkCompressor.policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t\tchunkCompressor.idCompressor,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, chunkCompressor));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(\n\t\t\toutput.length / chunkCompressor.policy.sequenceChunkSplitThreshold,\n\t\t);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n/**\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n\tidCompressor?: IIdCompressor,\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tif (\n\t\t\ttypeof cursor.value === \"string\" &&\n\t\t\tidCompressor !== undefined &&\n\t\t\tisStableNodeIdentifier(cursor.value)\n\t\t) {\n\t\t\tvalues.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);\n\t\t} else {\n\t\t\tvalues.push(cursor.value);\n\t\t}\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values, idCompressor);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n *\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n\tidCompressor?: IIdCompressor,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values, idCompressor);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);\n}\n"]}
|
|
@@ -31,6 +31,7 @@ export declare class ChunkedForest implements IEditableForest {
|
|
|
31
31
|
constructor(roots: BasicChunk, schema: TreeStoredSchemaSubscription, chunker: IChunker, anchors?: AnchorSet, idCompressor?: IIdCompressor | undefined);
|
|
32
32
|
get isEmpty(): boolean;
|
|
33
33
|
clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): ChunkedForest;
|
|
34
|
+
chunkField(cursor: ITreeCursorSynchronous): TreeChunk;
|
|
34
35
|
forgetAnchor(anchor: Anchor): void;
|
|
35
36
|
registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;
|
|
36
37
|
deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkedForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkedForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACN,KAAK,MAAM,EACX,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,4BAA4B,
|
|
1
|
+
{"version":3,"file":"chunkedForest.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkedForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM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SAAS,EACnB,YAAY,CAAC,EAAE,aAAa,GAC1B,aAAa,CAEf"}
|
|
@@ -50,6 +50,9 @@ class ChunkedForest {
|
|
|
50
50
|
this.roots.referenceAdded();
|
|
51
51
|
return new ChunkedForest(this.roots, schema, this.chunker.clone(schema), anchors);
|
|
52
52
|
}
|
|
53
|
+
chunkField(cursor) {
|
|
54
|
+
return (0, chunkTree_js_1.chunkFieldSingle)(cursor, { idCompressor: this.idCompressor, policy: this.chunker });
|
|
55
|
+
}
|
|
53
56
|
forgetAnchor(anchor) {
|
|
54
57
|
this.anchors.forget(anchor);
|
|
55
58
|
}
|
|
@@ -96,7 +99,7 @@ class ChunkedForest {
|
|
|
96
99
|
attach(source, count, destination) {
|
|
97
100
|
this.attachEdit(source, count, destination);
|
|
98
101
|
},
|
|
99
|
-
detach(source, destination) {
|
|
102
|
+
detach(source, destination, id) {
|
|
100
103
|
this.detachEdit(source, destination);
|
|
101
104
|
},
|
|
102
105
|
/**
|
|
@@ -147,7 +150,7 @@ class ChunkedForest {
|
|
|
147
150
|
parent.mutableChunk.fields.delete(parent.key);
|
|
148
151
|
}
|
|
149
152
|
},
|
|
150
|
-
replace(newContentSource, range, oldContentDestination) {
|
|
153
|
+
replace(newContentSource, range, oldContentDestination, oldContentId) {
|
|
151
154
|
(0, internal_1.assert)(newContentSource !== oldContentDestination, 0x7b0 /* Replace detached source field and detached destination field must be different */);
|
|
152
155
|
// TODO: optimize this to: perform in-place replace in uniform chunks when possible.
|
|
153
156
|
// This should result in 3 cases:
|