@fluidframework/tree 2.41.0 → 2.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +33 -0
- package/api-report/tree.alpha.api.md +11 -7
- package/dist/alpha.d.ts +1 -0
- package/dist/codec/codec.d.ts +23 -3
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +35 -2
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +38 -3
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +2 -2
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +5 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/mapTree.d.ts +2 -1
- package/dist/core/tree/mapTree.d.ts.map +1 -1
- package/dist/core/tree/mapTree.js +11 -5
- package/dist/core/tree/mapTree.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +2 -2
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +4 -3
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +14 -6
- 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 +34 -14
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +6 -6
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +7 -7
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts +39 -3
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +45 -7
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts +5 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +8 -2
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -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/schematizingTreeView.d.ts +11 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +36 -22
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +1 -0
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js +8 -24
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +2 -3
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +13 -15
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +5 -2
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +2 -2
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +9 -4
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +29 -16
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +4 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +9 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +1 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +10 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +38 -9
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +14 -3
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +32 -17
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +12 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +2 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -2
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +3 -4
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +15 -25
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +26 -33
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +169 -182
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -5
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -6
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js +1 -2
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/index.js +1 -2
- package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +12 -43
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +20 -6
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +26 -19
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +8 -8
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +6 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +6 -3
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
- package/dist/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +103 -185
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +6 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/utils.d.ts +4 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +8 -1
- package/dist/util/utils.js.map +1 -1
- package/docs/user-facing/schema-evolution.md +1 -1
- package/lib/alpha.d.ts +1 -0
- package/lib/codec/codec.d.ts +23 -3
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +35 -2
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +36 -2
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +2 -2
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +6 -2
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/mapTree.d.ts +2 -1
- package/lib/core/tree/mapTree.d.ts.map +1 -1
- package/lib/core/tree/mapTree.js +11 -5
- package/lib/core/tree/mapTree.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +2 -2
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +4 -3
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +14 -6
- 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 +34 -14
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +6 -6
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.d.ts +39 -3
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +43 -7
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts +5 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +8 -2
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -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/schematizingTreeView.d.ts +11 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +34 -21
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js +2 -18
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +2 -3
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +4 -6
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +6 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +2 -2
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +9 -4
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +22 -9
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +4 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +7 -0
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +10 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +40 -11
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +14 -3
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +35 -20
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +13 -10
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +3 -2
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -2
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +15 -25
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +24 -32
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +166 -181
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +3 -3
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +4 -5
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -3
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/index.js +1 -1
- package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -33
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +20 -6
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +25 -19
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +8 -8
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +6 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +4 -1
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
- package/lib/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +105 -186
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +6 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/utils.d.ts +4 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +6 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +24 -3
- package/src/codec/index.ts +1 -0
- package/src/codec/versioned/codec.ts +42 -5
- package/src/core/tree/detachedFieldIndex.ts +13 -4
- package/src/core/tree/mapTree.ts +22 -7
- package/src/core/tree/visitorUtils.ts +2 -2
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +3 -2
- package/src/feature-libraries/default-schema/schemaChecker.ts +7 -6
- package/src/feature-libraries/flex-tree/context.ts +17 -7
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +36 -15
- package/src/feature-libraries/flex-tree/index.ts +4 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +8 -6
- package/src/feature-libraries/flex-tree/lazyNode.ts +6 -2
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +3 -2
- package/src/feature-libraries/index.ts +9 -0
- package/src/feature-libraries/mapTreeCursor.ts +103 -16
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +9 -5
- package/src/feature-libraries/treeCursorUtils.ts +21 -10
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +40 -22
- package/src/shared-tree/sharedTree.ts +9 -3
- package/src/shared-tree/tree.ts +5 -20
- package/src/shared-tree/treeAlpha.ts +17 -11
- package/src/shared-tree/treeCheckout.ts +6 -3
- package/src/simple-tree/api/configuration.ts +3 -3
- package/src/simple-tree/api/create.ts +49 -19
- package/src/simple-tree/api/customTree.ts +10 -0
- package/src/simple-tree/api/index.ts +1 -4
- package/src/simple-tree/api/schemaFactory.ts +62 -13
- package/src/simple-tree/api/treeNodeApi.ts +48 -27
- package/src/simple-tree/api/verboseTree.ts +15 -12
- package/src/simple-tree/core/getOrCreateNode.ts +4 -2
- package/src/simple-tree/core/index.ts +2 -3
- package/src/simple-tree/core/treeNodeKernel.ts +37 -54
- package/src/simple-tree/core/unhydratedFlexTree.ts +222 -261
- package/src/simple-tree/index.ts +3 -3
- package/src/simple-tree/node-kinds/array/arrayNode.ts +12 -13
- package/src/simple-tree/node-kinds/index.ts +0 -1
- package/src/simple-tree/node-kinds/map/mapNode.ts +6 -9
- package/src/simple-tree/node-kinds/object/index.ts +0 -1
- package/src/simple-tree/node-kinds/object/objectNode.ts +7 -49
- package/src/simple-tree/prepareForInsertion.ts +49 -42
- package/src/simple-tree/schemaTypes.ts +9 -8
- package/src/simple-tree/toStoredSchema.ts +7 -1
- package/src/simple-tree/{toMapTree.ts → unhydratedFlexTreeFromInsertable.ts} +134 -226
- package/src/treeFactory.ts +6 -1
- package/src/util/index.ts +1 -0
- package/src/util/utils.ts +7 -0
- package/dist/simple-tree/toMapTree.d.ts.map +0 -1
- package/dist/simple-tree/toMapTree.js.map +0 -1
- package/lib/simple-tree/toMapTree.d.ts.map +0 -1
- package/lib/simple-tree/toMapTree.js.map +0 -1
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
6
6
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
8
|
import { aboveRootPlaceholder, EmptyKey, keyAsDetachedField, } from "../../core/index.js";
|
|
8
9
|
import { brand } from "../../util/index.js";
|
|
9
10
|
import { NodeKind } from "../core/index.js";
|
|
10
11
|
import { isTreeValue, stackTreeFieldCursor, stackTreeNodeCursor, } from "../../feature-libraries/index.js";
|
|
11
12
|
import { booleanSchema, handleSchema, nullSchema, numberSchema, stringSchema, } from "../leafNodeSchema.js";
|
|
12
13
|
import { isObjectNodeSchema } from "../node-kinds/index.js";
|
|
13
|
-
import { customFromCursor, replaceHandles, } from "./customTree.js";
|
|
14
|
+
import { customFromCursor, replaceHandles, unknownTypeError, } from "./customTree.js";
|
|
14
15
|
import { getUnhydratedContext } from "../createContext.js";
|
|
15
16
|
/**
|
|
16
17
|
* Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.
|
|
@@ -45,10 +46,12 @@ export function applySchemaToParserOptions(schema, options) {
|
|
|
45
46
|
return key;
|
|
46
47
|
},
|
|
47
48
|
parse: (type, inputKey) => {
|
|
48
|
-
const simpleNodeSchema = context.schema.get(brand(type)) ??
|
|
49
|
+
const simpleNodeSchema = context.schema.get(brand(type)) ?? unknownTypeError(type);
|
|
49
50
|
if (isObjectNodeSchema(simpleNodeSchema)) {
|
|
50
|
-
const info = simpleNodeSchema.flexKeyMap.get(inputKey)
|
|
51
|
-
|
|
51
|
+
const info = simpleNodeSchema.flexKeyMap.get(inputKey);
|
|
52
|
+
if (info === undefined) {
|
|
53
|
+
throw new UsageError(`Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`);
|
|
54
|
+
}
|
|
52
55
|
return info.storedKey;
|
|
53
56
|
}
|
|
54
57
|
return brand(inputKey);
|
|
@@ -80,19 +83,19 @@ function verboseTreeAdapter(options) {
|
|
|
80
83
|
type: (node) => {
|
|
81
84
|
switch (typeof node) {
|
|
82
85
|
case "number":
|
|
83
|
-
return numberSchema.identifier;
|
|
86
|
+
return brand(numberSchema.identifier);
|
|
84
87
|
case "string":
|
|
85
|
-
return stringSchema.identifier;
|
|
88
|
+
return brand(stringSchema.identifier);
|
|
86
89
|
case "boolean":
|
|
87
|
-
return booleanSchema.identifier;
|
|
90
|
+
return brand(booleanSchema.identifier);
|
|
88
91
|
default:
|
|
89
92
|
if (node === null) {
|
|
90
|
-
return nullSchema.identifier;
|
|
93
|
+
return brand(nullSchema.identifier);
|
|
91
94
|
}
|
|
92
95
|
if (isFluidHandle(node)) {
|
|
93
|
-
return handleSchema.identifier;
|
|
96
|
+
return brand(handleSchema.identifier);
|
|
94
97
|
}
|
|
95
|
-
return node.type;
|
|
98
|
+
return brand(node.type);
|
|
96
99
|
}
|
|
97
100
|
},
|
|
98
101
|
keysFromNode: (node) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verboseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EACN,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,GAKlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAM5C,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,WAAW,EACX,oBAAoB,EACpB,mBAAmB,GAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACN,gBAAgB,EAChB,cAAc,GAKd,MAAM,iBAAiB,C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1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAsC,EACtC,MAA2C;IAE3C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACjF,MAAM,UAAU,GACf,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAChF,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,MAAuB,CAAC;IAChC,CAAC;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAqC;KAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\taboveRootPlaceholder,\n\tEmptyKey,\n\tkeyAsDetachedField,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type {\n\tTreeLeafValue,\n\tImplicitFieldSchema,\n\tImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n} from \"../../feature-libraries/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\ttype CustomTreeNode,\n\ttype HandleConverter,\n\ttype SchemalessParseOptions,\n\ttype TreeEncodingOptions,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type VerboseTree<THandle = IFluidHandle> =\n\t| VerboseTreeNode<THandle>\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle;\n\n/**\n * Verbose encoding of a {@link TreeNode}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} has an explicit `type` property, and `fields`.\n * This allowed VerboseTreeNode to be unambiguous regarding which type each node is without relying on symbols or hidden state.\n *\n * Any IFluidHandle values have been replaced by `THandle`. If the `THandle` is JSON compatible, then this type is JSON compatible as well.\n *\n * @privateRemarks\n * This type is only used for data which is copied into and out of the tree.\n * When being copied out, its fine to have the data be mutable since its a copy.\n *\n * When being copied in, we don't need to mutate, so we could use a readonly variant of this type.\n * however the copy in case (createFromVerbose) probably isn't harmed much by just reusing this type as is,\n * since if the caller has immutable data, TypeScript doesn't prevent assigning immutable data to a mutable type anyway.\n * Also relaxing the input methods to take readonly data would be a non-breaking change so it can be done later if desired.\n *\n * This format is simple-tree specialized alternative to {@link JsonableTree}.\n * This format allows for all simple-tree compatible trees to be represented.\n *\n * Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.\n * Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)\n * replicating the behavior of simple-tree ArrayNodes.\n * @alpha\n */\nexport interface VerboseTreeNode<THandle = IFluidHandle> {\n\t/**\n\t * The meaning of this node.\n\t * Provides contexts/semantics for this node and its content.\n\t * @remarks\n\t * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).\n\t * When used with this package's schema system, it will be the {@link TreeNodeSchemaCore.identifier}.\n\t */\n\ttype: string;\n\n\t/**\n\t * Content of this node.\n\t * For array nodes, an array of children.\n\t * For map and object nodes, an object which children under keys.\n\t * @remarks\n\t * For object nodes, the keys could be either the stored keys, or the property keys depending on usage.\n\t */\n\tfields:\n\t\t| VerboseTree<THandle>[]\n\t\t| {\n\t\t\t\t[key: string]: VerboseTree<THandle>;\n\t\t };\n}\n\n/**\n * Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.\n */\nexport function applySchemaToParserOptions(\n\tschema: ImplicitFieldSchema,\n\toptions: TreeEncodingOptions,\n): SchemalessParseOptions {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst context = getUnhydratedContext(schema);\n\n\treturn {\n\t\tkeyConverter: config.useStoredKeys\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tencode: (type, key: FieldKey): string => {\n\t\t\t\t\t\t// translate stored key into property key.\n\t\t\t\t\t\tconst simpleNodeSchema =\n\t\t\t\t\t\t\tcontext.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);\n\t\t\t\t\t\t\tif (propertyKey !== undefined) {\n\t\t\t\t\t\t\t\treturn propertyKey;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Looking up an out of schema key.\n\t\t\t\t\t\t\t// This must point to a non-existent field.\n\t\t\t\t\t\t\t// It's possible that the key, if we returned it unmodified, could point to some data\n\t\t\t\t\t\t\t// (for example if looking up a key which is a stored key already when using property keys).\n\t\t\t\t\t\t\t// Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:\n\t\t\t\t\t\t\tconst arbitrary = \"arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90\";\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t!simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),\n\t\t\t\t\t\t\t\t0xa13 /* arbitrarily selected unused key was actually used */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn arbitrary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn key;\n\t\t\t\t\t},\n\t\t\t\t\tparse: (type, inputKey): FieldKey => {\n\t\t\t\t\t\tconst simpleNodeSchema =\n\t\t\t\t\t\t\tcontext.schema.get(brand(type)) ?? fail(0xb3a /* missing schema */);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst info =\n\t\t\t\t\t\t\t\tsimpleNodeSchema.flexKeyMap.get(inputKey) ??\n\t\t\t\t\t\t\t\tfail(0xb3b /* missing field info */);\n\t\t\t\t\t\t\treturn info.storedKey;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn brand(inputKey);\n\t\t\t\t\t},\n\t\t\t\t},\n\t};\n}\n\n/**\n * Used to read a VerboseTree as a node cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single node in nodes mode.\n */\nexport function cursorFromVerbose(\n\tdata: VerboseTree,\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeNodeCursor(verboseTreeAdapter(options), data);\n}\n\n/**\n * Used to read a VerboseTree[] as a field cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single field in fields mode.\n */\nexport function fieldCursorFromVerbose(\n\tdata: VerboseTree[],\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeFieldCursor(\n\t\tverboseTreeAdapter(options),\n\t\t{ type: aboveRootPlaceholder, fields: data },\n\t\tkeyAsDetachedField(EmptyKey),\n\t);\n}\n\nfunction verboseTreeAdapter(options: SchemalessParseOptions): CursorAdapter<VerboseTree> {\n\treturn {\n\t\tvalue: (node: VerboseTree) => {\n\t\t\treturn isTreeValue(node) ? node : undefined;\n\t\t},\n\t\ttype: (node: VerboseTree) => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn numberSchema.identifier as TreeNodeSchemaIdentifier;\n\t\t\t\tcase \"string\":\n\t\t\t\t\treturn stringSchema.identifier as TreeNodeSchemaIdentifier;\n\t\t\t\tcase \"boolean\":\n\t\t\t\t\treturn booleanSchema.identifier as TreeNodeSchemaIdentifier;\n\t\t\t\tdefault:\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn nullSchema.identifier as TreeNodeSchemaIdentifier;\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn handleSchema.identifier as TreeNodeSchemaIdentifier;\n\t\t\t\t\t}\n\t\t\t\t\treturn node.type as TreeNodeSchemaIdentifier;\n\t\t\t}\n\t\t},\n\t\tkeysFromNode: (node: VerboseTree): readonly FieldKey[] => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"object\": {\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\t\t\treturn node.fields.length === 0 ? [] : [EmptyKey];\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inputKeys = Object.keys(node.fields);\n\t\t\t\t\tconst converter = options.keyConverter;\n\t\t\t\t\tif (converter === undefined) {\n\t\t\t\t\t\treturn inputKeys as FieldKey[];\n\t\t\t\t\t}\n\t\t\t\t\treturn inputKeys.map((k) => converter.parse(node.type, k));\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\tgetFieldFromNode: (node: VerboseTree, key: FieldKey): readonly VerboseTree[] => {\n\t\t\t// Object.prototype.hasOwnProperty can return true for strings (ex: with key \"0\"), so we have to filter them out.\n\t\t\t// Rather than just special casing strings, we can handle them with an early return for all primitives.\n\t\t\tif (typeof node !== \"object\") {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (node === null) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (isFluidHandle(node)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\treturn key === EmptyKey ? node.fields : [];\n\t\t\t}\n\n\t\t\tconst convertedKey =\n\t\t\t\toptions.keyConverter === undefined ? key : options.keyConverter.encode(node.type, key);\n\n\t\t\tif (Object.prototype.hasOwnProperty.call(node.fields, convertedKey)) {\n\t\t\t\tconst field = node.fields[convertedKey];\n\t\t\t\treturn field === undefined ? [] : [field];\n\t\t\t}\n\n\t\t\treturn [];\n\t\t},\n\t};\n}\n\n/**\n * Used to read a node cursor as a VerboseTree.\n */\nexport function verboseFromCursor(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: TreeEncodingOptions,\n): VerboseTree {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\n\treturn verboseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction verboseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): VerboseTree {\n\tconst fields = customFromCursor(reader, options, schema, verboseFromCursorInner);\n\tconst nodeSchema =\n\t\tschema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);\n\tif (nodeSchema.kind === NodeKind.Leaf) {\n\t\treturn fields as TreeLeafValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<VerboseTree>,\n\t};\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * A strongly types version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceVerboseTreeHandles<T>(\n\ttree: VerboseTree,\n\treplacer: HandleConverter<T>,\n): VerboseTree<T> {\n\treturn replaceHandles(tree, replacer) as VerboseTree<T>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verboseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,GAIlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAM5C,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,WAAW,EACX,oBAAoB,EACpB,mBAAmB,GAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GAKhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAkE3D;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,MAA2B,EAC3B,OAA4B;IAE5B,MA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AAG,OAAO;KACV,CAAC;IAEF,MAAM,SAAS,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;IAE1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAsC,EACtC,MAA2C;IAE3C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACjF,MAAM,UAAU,GACf,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAChF,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,MAAuB,CAAC;IAChC,CAAC;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAqC;KAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\taboveRootPlaceholder,\n\tEmptyKey,\n\tkeyAsDetachedField,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type {\n\tTreeLeafValue,\n\tImplicitFieldSchema,\n\tImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tisTreeValue,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n} from \"../../feature-libraries/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\tunknownTypeError,\n\ttype CustomTreeNode,\n\ttype HandleConverter,\n\ttype SchemalessParseOptions,\n\ttype TreeEncodingOptions,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Verbose encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} is a {@link VerboseTreeNode}.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type VerboseTree<THandle = IFluidHandle> =\n\t| VerboseTreeNode<THandle>\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle;\n\n/**\n * Verbose encoding of a {@link TreeNode}.\n * @remarks\n * This is verbose meaning that every {@link TreeNode} has an explicit `type` property, and `fields`.\n * This allowed VerboseTreeNode to be unambiguous regarding which type each node is without relying on symbols or hidden state.\n *\n * Any IFluidHandle values have been replaced by `THandle`. If the `THandle` is JSON compatible, then this type is JSON compatible as well.\n *\n * @privateRemarks\n * This type is only used for data which is copied into and out of the tree.\n * When being copied out, its fine to have the data be mutable since its a copy.\n *\n * When being copied in, we don't need to mutate, so we could use a readonly variant of this type.\n * however the copy in case (createFromVerbose) probably isn't harmed much by just reusing this type as is,\n * since if the caller has immutable data, TypeScript doesn't prevent assigning immutable data to a mutable type anyway.\n * Also relaxing the input methods to take readonly data would be a non-breaking change so it can be done later if desired.\n *\n * This format is simple-tree specialized alternative to {@link JsonableTree}.\n * This format allows for all simple-tree compatible trees to be represented.\n *\n * Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.\n * Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)\n * replicating the behavior of simple-tree ArrayNodes.\n * @alpha\n */\nexport interface VerboseTreeNode<THandle = IFluidHandle> {\n\t/**\n\t * The meaning of this node.\n\t * Provides contexts/semantics for this node and its content.\n\t * @remarks\n\t * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).\n\t * When used with this package's schema system, it will be the {@link TreeNodeSchemaCore.identifier}.\n\t */\n\ttype: string;\n\n\t/**\n\t * Content of this node.\n\t * For array nodes, an array of children.\n\t * For map and object nodes, an object which children under keys.\n\t * @remarks\n\t * For object nodes, the keys could be either the stored keys, or the property keys depending on usage.\n\t */\n\tfields:\n\t\t| VerboseTree<THandle>[]\n\t\t| {\n\t\t\t\t[key: string]: VerboseTree<THandle>;\n\t\t };\n}\n\n/**\n * Use info from `schema` to convert `options` to {@link SchemalessParseOptions}.\n */\nexport function applySchemaToParserOptions(\n\tschema: ImplicitFieldSchema,\n\toptions: TreeEncodingOptions,\n): SchemalessParseOptions {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst context = getUnhydratedContext(schema);\n\n\treturn {\n\t\tkeyConverter: config.useStoredKeys\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tencode: (type, key: FieldKey): string => {\n\t\t\t\t\t\t// translate stored key into property key.\n\t\t\t\t\t\tconst simpleNodeSchema =\n\t\t\t\t\t\t\tcontext.schema.get(brand(type)) ?? fail(0xb39 /* missing schema */);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst propertyKey = simpleNodeSchema.storedKeyToPropertyKey.get(key);\n\t\t\t\t\t\t\tif (propertyKey !== undefined) {\n\t\t\t\t\t\t\t\treturn propertyKey;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Looking up an out of schema key.\n\t\t\t\t\t\t\t// This must point to a non-existent field.\n\t\t\t\t\t\t\t// It's possible that the key, if we returned it unmodified, could point to some data\n\t\t\t\t\t\t\t// (for example if looking up a key which is a stored key already when using property keys).\n\t\t\t\t\t\t\t// Thus return an arbitrary key that was selected randomly, so should not exist on non-adversarial data:\n\t\t\t\t\t\t\tconst arbitrary = \"arbitrary unused key: fe71614a-bf3e-43b3-b7b0-4cef39538e90\";\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t!simpleNodeSchema.storedKeyToPropertyKey.has(brand(arbitrary)),\n\t\t\t\t\t\t\t\t0xa13 /* arbitrarily selected unused key was actually used */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn arbitrary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn key;\n\t\t\t\t\t},\n\t\t\t\t\tparse: (type, inputKey): FieldKey => {\n\t\t\t\t\t\tconst simpleNodeSchema = context.schema.get(brand(type)) ?? unknownTypeError(type);\n\t\t\t\t\t\tif (isObjectNodeSchema(simpleNodeSchema)) {\n\t\t\t\t\t\t\tconst info = simpleNodeSchema.flexKeyMap.get(inputKey);\n\t\t\t\t\t\t\tif (info === undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t`Failed to parse VerboseTree due to unexpected key ${JSON.stringify(inputKey)} on type ${JSON.stringify(type)}.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn info.storedKey;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn brand(inputKey);\n\t\t\t\t\t},\n\t\t\t\t},\n\t};\n}\n\n/**\n * Used to read a VerboseTree as a node cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single node in nodes mode.\n */\nexport function cursorFromVerbose(\n\tdata: VerboseTree,\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeNodeCursor(verboseTreeAdapter(options), data);\n}\n\n/**\n * Used to read a VerboseTree[] as a field cursor.\n *\n * @returns an {@link ITreeCursorSynchronous} for a single field in fields mode.\n */\nexport function fieldCursorFromVerbose(\n\tdata: VerboseTree[],\n\toptions: SchemalessParseOptions,\n): ITreeCursorSynchronous {\n\treturn stackTreeFieldCursor(\n\t\tverboseTreeAdapter(options),\n\t\t{ type: aboveRootPlaceholder, fields: data },\n\t\tkeyAsDetachedField(EmptyKey),\n\t);\n}\n\nfunction verboseTreeAdapter(options: SchemalessParseOptions): CursorAdapter<VerboseTree> {\n\treturn {\n\t\tvalue: (node: VerboseTree) => {\n\t\t\treturn isTreeValue(node) ? node : undefined;\n\t\t},\n\t\ttype: (node: VerboseTree) => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"number\":\n\t\t\t\t\treturn brand(numberSchema.identifier);\n\t\t\t\tcase \"string\":\n\t\t\t\t\treturn brand(stringSchema.identifier);\n\t\t\t\tcase \"boolean\":\n\t\t\t\t\treturn brand(booleanSchema.identifier);\n\t\t\t\tdefault:\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn brand(nullSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn brand(handleSchema.identifier);\n\t\t\t\t\t}\n\t\t\t\t\treturn brand(node.type);\n\t\t\t}\n\t\t},\n\t\tkeysFromNode: (node: VerboseTree): readonly FieldKey[] => {\n\t\t\tswitch (typeof node) {\n\t\t\t\tcase \"object\": {\n\t\t\t\t\tif (node === null) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (isFluidHandle(node)) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\t\t\treturn node.fields.length === 0 ? [] : [EmptyKey];\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inputKeys = Object.keys(node.fields);\n\t\t\t\t\tconst converter = options.keyConverter;\n\t\t\t\t\tif (converter === undefined) {\n\t\t\t\t\t\treturn inputKeys as FieldKey[];\n\t\t\t\t\t}\n\t\t\t\t\treturn inputKeys.map((k) => converter.parse(node.type, k));\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\tgetFieldFromNode: (node: VerboseTree, key: FieldKey): readonly VerboseTree[] => {\n\t\t\t// Object.prototype.hasOwnProperty can return true for strings (ex: with key \"0\"), so we have to filter them out.\n\t\t\t// Rather than just special casing strings, we can handle them with an early return for all primitives.\n\t\t\tif (typeof node !== \"object\") {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (node === null) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (isFluidHandle(node)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (Array.isArray(node.fields)) {\n\t\t\t\treturn key === EmptyKey ? node.fields : [];\n\t\t\t}\n\n\t\t\tconst convertedKey =\n\t\t\t\toptions.keyConverter === undefined ? key : options.keyConverter.encode(node.type, key);\n\n\t\t\tif (Object.prototype.hasOwnProperty.call(node.fields, convertedKey)) {\n\t\t\t\tconst field = node.fields[convertedKey];\n\t\t\t\treturn field === undefined ? [] : [field];\n\t\t\t}\n\n\t\t\treturn [];\n\t\t},\n\t};\n}\n\n/**\n * Used to read a node cursor as a VerboseTree.\n */\nexport function verboseFromCursor(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: TreeEncodingOptions,\n): VerboseTree {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\n\treturn verboseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction verboseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): VerboseTree {\n\tconst fields = customFromCursor(reader, options, schema, verboseFromCursorInner);\n\tconst nodeSchema =\n\t\tschema.get(reader.type) ?? fail(0xb3c /* missing schema for type in cursor */);\n\tif (nodeSchema.kind === NodeKind.Leaf) {\n\t\treturn fields as TreeLeafValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<VerboseTree>,\n\t};\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * A strongly types version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceVerboseTreeHandles<T>(\n\ttree: VerboseTree,\n\treplacer: HandleConverter<T>,\n): VerboseTree<T> {\n\treturn replaceHandles(tree, replacer) as VerboseTree<T>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOrCreateNode.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/getOrCreateNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACN,KAAK,SAAS,EAId,MAAM,qBAAqB,CAAC;AAG7B;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"getOrCreateNode.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/getOrCreateNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACN,KAAK,SAAS,EAId,MAAM,qBAAqB,CAAC;AAG7B;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAatF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { simpleTreeNodeSlot, createTreeNodeFromInner, splitInnerNodeType, } from "./treeNodeKernel.js";
|
|
6
6
|
import { UnhydratedFlexTreeNode } from "./unhydratedFlexTree.js";
|
|
7
7
|
/**
|
|
8
8
|
* Returns the TreeNode or TreeValue for the provided {@link InnerNode}.
|
|
@@ -11,8 +11,9 @@ import { UnhydratedFlexTreeNode } from "./unhydratedFlexTree.js";
|
|
|
11
11
|
* This supports both hydrated and unhydrated nodes.
|
|
12
12
|
*/
|
|
13
13
|
export function getOrCreateNodeFromInnerNode(flexNode) {
|
|
14
|
+
splitInnerNodeType(flexNode);
|
|
14
15
|
const cached = flexNode instanceof UnhydratedFlexTreeNode
|
|
15
|
-
?
|
|
16
|
+
? flexNode.treeNode
|
|
16
17
|
: flexNode.anchorNode.slots.get(simpleTreeNodeSlot);
|
|
17
18
|
if (cached !== undefined) {
|
|
18
19
|
return cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOrCreateNode.js","sourceRoot":"","sources":["../../../src/simple-tree/core/getOrCreateNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,
|
|
1
|
+
{"version":3,"file":"getOrCreateNode.js","sourceRoot":"","sources":["../../../src/simple-tree/core/getOrCreateNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAmB;IAC/D,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE7B,MAAM,MAAM,GACX,QAAQ,YAAY,sBAAsB;QACzC,CAAC,CAAC,QAAQ,CAAC,QAAQ;QACnB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAEtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IACf,CAAC;IAED,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeValue } from \"../../core/index.js\";\n\nimport type { TreeNode } from \"./treeNode.js\";\nimport {\n\ttype InnerNode,\n\tsimpleTreeNodeSlot,\n\tcreateTreeNodeFromInner,\n\tsplitInnerNodeType,\n} from \"./treeNodeKernel.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\n/**\n * Returns the TreeNode or TreeValue for the provided {@link InnerNode}.\n * This will allocate a new one if needed, and otherwise return one from cache.\n * @remarks\n * This supports both hydrated and unhydrated nodes.\n */\nexport function getOrCreateNodeFromInnerNode(flexNode: InnerNode): TreeNode | TreeValue {\n\tsplitInnerNodeType(flexNode);\n\n\tconst cached =\n\t\tflexNode instanceof UnhydratedFlexTreeNode\n\t\t\t? flexNode.treeNode\n\t\t\t: flexNode.anchorNode.slots.get(simpleTreeNodeSlot);\n\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\treturn createTreeNodeFromInner(flexNode);\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { isTreeNode, TreeNodeKernel, getKernel, tryGetTreeNodeSchema, type InnerNode, tryDisposeTreeNode,
|
|
5
|
+
export { isTreeNode, TreeNodeKernel, getKernel, tryGetTreeNodeSchema, type InnerNode, tryDisposeTreeNode, getOrCreateInnerNode, treeNodeFromAnchor, getSimpleNodeSchemaFromInnerNode, } from "./treeNodeKernel.js";
|
|
6
6
|
export { type WithType, typeNameSymbol, typeSchemaSymbol } from "./withType.js";
|
|
7
7
|
export { type Unhydrated, type InternalTreeNode, } from "./types.js";
|
|
8
8
|
export { TreeNode, privateToken, inPrototypeChain, } from "./treeNode.js";
|
|
@@ -10,5 +10,5 @@ export { type TreeNodeSchema, NodeKind, type TreeNodeSchemaClass, type TreeNodeS
|
|
|
10
10
|
export { walkAllowedTypes, type SchemaVisitor } from "./walkSchema.js";
|
|
11
11
|
export { Context, HydratedContext, SimpleContextSlot } from "./context.js";
|
|
12
12
|
export { getOrCreateNodeFromInnerNode } from "./getOrCreateNode.js";
|
|
13
|
-
export { UnhydratedFlexTreeNode,
|
|
13
|
+
export { UnhydratedFlexTreeNode, UnhydratedSequenceField, UnhydratedContext, createField, } from "./unhydratedFlexTree.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,KAAK,SAAS,EACd,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,KAAK,SAAS,EACd,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { isTreeNode, TreeNodeKernel, getKernel, tryGetTreeNodeSchema, tryDisposeTreeNode,
|
|
5
|
+
export { isTreeNode, TreeNodeKernel, getKernel, tryGetTreeNodeSchema, tryDisposeTreeNode, getOrCreateInnerNode, treeNodeFromAnchor, getSimpleNodeSchemaFromInnerNode, } from "./treeNodeKernel.js";
|
|
6
6
|
export { typeNameSymbol, typeSchemaSymbol } from "./withType.js";
|
|
7
7
|
export { TreeNode, privateToken, inPrototypeChain, } from "./treeNode.js";
|
|
8
8
|
export { NodeKind, } from "./treeNodeSchema.js";
|
|
9
9
|
export { walkAllowedTypes } from "./walkSchema.js";
|
|
10
10
|
export { Context, HydratedContext, SimpleContextSlot } from "./context.js";
|
|
11
11
|
export { getOrCreateNodeFromInnerNode } from "./getOrCreateNode.js";
|
|
12
|
-
export { UnhydratedFlexTreeNode,
|
|
12
|
+
export { UnhydratedFlexTreeNode, UnhydratedSequenceField, UnhydratedContext, createField, } from "./unhydratedFlexTree.js";
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EAEpB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,UAAU,EACV,cAAc,EACd,SAAS,EACT,oBAAoB,EAEpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKhF,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,QAAQ,GAKR,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACX,MAAM,yBAAyB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisTreeNode,\n\tTreeNodeKernel,\n\tgetKernel,\n\ttryGetTreeNodeSchema,\n\ttype InnerNode,\n\ttryDisposeTreeNode,\n\tgetOrCreateInnerNode,\n\ttreeNodeFromAnchor,\n\tgetSimpleNodeSchemaFromInnerNode,\n} from \"./treeNodeKernel.js\";\nexport { type WithType, typeNameSymbol, typeSchemaSymbol } from \"./withType.js\";\nexport {\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n} from \"./types.js\";\nexport {\n\tTreeNode,\n\tprivateToken,\n\tinPrototypeChain,\n} from \"./treeNode.js\";\nexport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeNodeSchemaBoth,\n} from \"./treeNodeSchema.js\";\nexport { walkAllowedTypes, type SchemaVisitor } from \"./walkSchema.js\";\nexport { Context, HydratedContext, SimpleContextSlot } from \"./context.js\";\nexport { getOrCreateNodeFromInnerNode } from \"./getOrCreateNode.js\";\nexport {\n\tUnhydratedFlexTreeNode,\n\tUnhydratedSequenceField,\n\tUnhydratedContext,\n\tcreateField,\n} from \"./unhydratedFlexTree.js\";\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Listenable } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { type AnchorEvents, type AnchorNode, type AnchorSet, type TreeValue, type UpPath } from "../../core/index.js";
|
|
7
|
-
import { TreeStatus, type FlexTreeNode } from "../../feature-libraries/index.js";
|
|
7
|
+
import { TreeStatus, type FlexTreeNode, type HydratedFlexTreeNode } from "../../feature-libraries/index.js";
|
|
8
8
|
import { type Context, type HydratedContext } from "./context.js";
|
|
9
9
|
import type { TreeNode } from "./treeNode.js";
|
|
10
10
|
import type { TreeNodeSchema } from "./treeNodeSchema.js";
|
|
@@ -84,44 +84,34 @@ export declare class TreeNodeKernel {
|
|
|
84
84
|
};
|
|
85
85
|
get anchorNode(): AnchorNode | undefined;
|
|
86
86
|
/**
|
|
87
|
-
* Retrieves the flex node associated with the given target
|
|
87
|
+
* Retrieves the flex node associated with the given target.
|
|
88
88
|
* @remarks
|
|
89
89
|
* For {@link Unhydrated} nodes, this returns the MapTreeNode.
|
|
90
90
|
*
|
|
91
91
|
* For hydrated nodes it returns a FlexTreeNode backed by the forest.
|
|
92
92
|
* Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
|
|
93
93
|
*
|
|
94
|
-
*
|
|
94
|
+
* @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.
|
|
95
95
|
*/
|
|
96
|
-
getOrCreateInnerNode(
|
|
96
|
+
getOrCreateInnerNode(): InnerNode;
|
|
97
97
|
/**
|
|
98
|
-
* Retrieves the
|
|
99
|
-
* @remarks
|
|
100
|
-
* If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.
|
|
101
|
-
* If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.
|
|
102
|
-
* If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.
|
|
98
|
+
* Retrieves the {@link UnhydratedFlexTreeNode} if unhydrated. otherwise undefined.
|
|
103
99
|
*/
|
|
104
|
-
|
|
100
|
+
getInnerNodeIfUnhydrated(): UnhydratedFlexTreeNode | undefined;
|
|
105
101
|
}
|
|
106
102
|
declare const kernelEvents: readonly ["childrenChangedAfterBatch", "subtreeChangedAfterBatch"];
|
|
107
103
|
type KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;
|
|
108
104
|
/**
|
|
109
|
-
* For "cooked" nodes this is a
|
|
110
|
-
* For {@link Unhydrated} nodes this is a
|
|
111
|
-
* For "marinated" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.
|
|
105
|
+
* For "cooked" nodes this is a HydratedFlexTreeNode thats a projection of forest content.
|
|
106
|
+
* For {@link Unhydrated} nodes this is a UnhydratedFlexTreeNode.
|
|
112
107
|
*
|
|
113
|
-
*
|
|
114
|
-
* Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.
|
|
115
|
-
* TODO: Code should be migrating toward using this type to distinguish to two use-cases.
|
|
116
|
-
*
|
|
117
|
-
* TODO: The inconsistent handling of "marinated" cases should be cleaned up.
|
|
118
|
-
* Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?
|
|
108
|
+
* For "marinated" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.
|
|
119
109
|
*/
|
|
120
|
-
export type InnerNode = FlexTreeNode
|
|
110
|
+
export type InnerNode = FlexTreeNode;
|
|
121
111
|
/**
|
|
122
|
-
*
|
|
112
|
+
* Narrows innerNode to either {@link UnhydratedFlexTreeNode} or {@link HydratedFlexTreeNode}.
|
|
123
113
|
*/
|
|
124
|
-
export declare
|
|
114
|
+
export declare function splitInnerNodeType(innerNode: InnerNode): asserts innerNode is UnhydratedFlexTreeNode | HydratedFlexTreeNode;
|
|
125
115
|
/**
|
|
126
116
|
* An anchor slot which associates an anchor with its corresponding {@link TreeNode}, if there is one.
|
|
127
117
|
* @remarks
|
|
@@ -142,16 +132,16 @@ export declare function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode):
|
|
|
142
132
|
*/
|
|
143
133
|
export declare function getSimpleContextFromInnerNode(innerNode: InnerNode): Context;
|
|
144
134
|
/**
|
|
145
|
-
* Retrieves the flex node associated with the given target
|
|
135
|
+
* Retrieves the flex node associated with the given target.
|
|
146
136
|
* @remarks
|
|
147
137
|
* For {@link Unhydrated} nodes, this returns the MapTreeNode.
|
|
148
138
|
*
|
|
149
139
|
* For hydrated nodes it returns a FlexTreeNode backed by the forest.
|
|
150
140
|
* Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
|
|
151
141
|
*
|
|
152
|
-
*
|
|
142
|
+
* @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.
|
|
153
143
|
*/
|
|
154
|
-
export declare function getOrCreateInnerNode(treeNode: TreeNode
|
|
144
|
+
export declare function getOrCreateInnerNode(treeNode: TreeNode): InnerNode;
|
|
155
145
|
/**
|
|
156
146
|
* Gets a tree node from an anchor node
|
|
157
147
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeNodeKernel.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,iCAAiC,CAAC;AAIvE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAKN,UAAU,EAEV,KAAK,YAAY,EACjB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAqB,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAIxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,cAAc,CAG/E;AA0BD;;;;GAIG;AACH,qBAAa,cAAc;;aAoCT,IAAI,EAAE,QAAQ;aACd,MAAM,EAAE,cAAc;IAEtC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAtChC,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;;;;;OASG;IACI,gBAAgB,EAAE,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AAG,cAAc,CAGrF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAU3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAGlE;AAmBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAQ/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAQlF"}
|
|
@@ -102,11 +102,13 @@ export class TreeNodeKernel {
|
|
|
102
102
|
* since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).
|
|
103
103
|
*/
|
|
104
104
|
_TreeNodeKernel_unhydratedEvents.set(this, new Lazy((createEmitter)));
|
|
105
|
+
splitInnerNodeType(innerNode);
|
|
105
106
|
assert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);
|
|
106
107
|
treeNodeToKernel.set(node, this);
|
|
107
108
|
if (innerNode instanceof UnhydratedFlexTreeNode) {
|
|
108
109
|
// Unhydrated case
|
|
109
|
-
|
|
110
|
+
debugAssert(() => innerNode.treeNode === undefined);
|
|
111
|
+
innerNode.treeNode = node;
|
|
110
112
|
// Register for change events from the unhydrated flex node.
|
|
111
113
|
// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.
|
|
112
114
|
__classPrivateFieldSet(this, _TreeNodeKernel_hydrationState, {
|
|
@@ -117,7 +119,7 @@ export class TreeNodeKernel {
|
|
|
117
119
|
});
|
|
118
120
|
let unhydratedNode = innerNode;
|
|
119
121
|
while (unhydratedNode !== undefined) {
|
|
120
|
-
const treeNode =
|
|
122
|
+
const treeNode = unhydratedNode.treeNode;
|
|
121
123
|
if (treeNode !== undefined) {
|
|
122
124
|
const kernel = getKernel(treeNode);
|
|
123
125
|
__classPrivateFieldGet(kernel, _TreeNodeKernel_unhydratedEvents, "f").value.emit("subtreeChangedAfterBatch");
|
|
@@ -132,6 +134,7 @@ export class TreeNodeKernel {
|
|
|
132
134
|
else {
|
|
133
135
|
// Hydrated case
|
|
134
136
|
__classPrivateFieldSet(this, _TreeNodeKernel_hydrationState, this.createHydratedState(innerNode.anchorNode), "f");
|
|
137
|
+
__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = innerNode;
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
get context() {
|
|
@@ -152,7 +155,6 @@ export class TreeNodeKernel {
|
|
|
152
155
|
hydrate(anchors, path) {
|
|
153
156
|
assert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);
|
|
154
157
|
assert(!isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f")), 0xa2b /* hydration should only happen once */);
|
|
155
|
-
unhydratedFlexTreeNodeToTreeNodeInternal.delete(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
|
|
156
158
|
const anchor = anchors.track(path);
|
|
157
159
|
const anchorNode = anchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);
|
|
158
160
|
__classPrivateFieldSet(this, _TreeNodeKernel_hydrationState, this.createHydratedState(anchorNode), "f");
|
|
@@ -224,21 +226,24 @@ export class TreeNodeKernel {
|
|
|
224
226
|
return isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f")) ? __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode : undefined;
|
|
225
227
|
}
|
|
226
228
|
/**
|
|
227
|
-
* Retrieves the flex node associated with the given target
|
|
229
|
+
* Retrieves the flex node associated with the given target.
|
|
228
230
|
* @remarks
|
|
229
231
|
* For {@link Unhydrated} nodes, this returns the MapTreeNode.
|
|
230
232
|
*
|
|
231
233
|
* For hydrated nodes it returns a FlexTreeNode backed by the forest.
|
|
232
234
|
* Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
|
|
233
235
|
*
|
|
234
|
-
*
|
|
236
|
+
* @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.
|
|
235
237
|
*/
|
|
236
|
-
getOrCreateInnerNode(
|
|
238
|
+
getOrCreateInnerNode() {
|
|
237
239
|
if (!isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
|
|
238
240
|
debugAssert(() => __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode?.context.isDisposed() === false ||
|
|
239
241
|
"Unhydrated node should never be disposed");
|
|
240
242
|
return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode; // Unhydrated case
|
|
241
243
|
}
|
|
244
|
+
if (this.disposed) {
|
|
245
|
+
throw new UsageError("Cannot access a deleted node.");
|
|
246
|
+
}
|
|
242
247
|
if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode === undefined) {
|
|
243
248
|
// Marinated case -> cooked
|
|
244
249
|
const anchorNode = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode;
|
|
@@ -255,29 +260,17 @@ export class TreeNodeKernel {
|
|
|
255
260
|
context.checkout.forest.moveCursorToPath(anchorNode, cursor);
|
|
256
261
|
__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = makeTree(context, cursor);
|
|
257
262
|
cursor.free();
|
|
258
|
-
|
|
259
|
-
assertFlexTreeEntityNotFreed(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (!allowDeleted) {
|
|
264
|
-
if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode.context.isDisposed()) {
|
|
265
|
-
throw new UsageError("Cannot access a Deleted node.");
|
|
263
|
+
assertFlexTreeEntityNotFreed(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
|
|
266
264
|
}
|
|
267
265
|
}
|
|
268
266
|
return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode;
|
|
269
267
|
}
|
|
270
268
|
/**
|
|
271
|
-
* Retrieves the
|
|
272
|
-
* @remarks
|
|
273
|
-
* If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.
|
|
274
|
-
* If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.
|
|
275
|
-
* If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.
|
|
269
|
+
* Retrieves the {@link UnhydratedFlexTreeNode} if unhydrated. otherwise undefined.
|
|
276
270
|
*/
|
|
277
|
-
|
|
271
|
+
getInnerNodeIfUnhydrated() {
|
|
278
272
|
if (isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
|
|
279
|
-
return
|
|
280
|
-
__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode.slots.get(flexTreeSlot));
|
|
273
|
+
return undefined;
|
|
281
274
|
}
|
|
282
275
|
return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode;
|
|
283
276
|
}
|
|
@@ -285,13 +278,11 @@ export class TreeNodeKernel {
|
|
|
285
278
|
_TreeNodeKernel_hydrationState = new WeakMap(), _TreeNodeKernel_unhydratedEvents = new WeakMap();
|
|
286
279
|
const kernelEvents = ["childrenChangedAfterBatch", "subtreeChangedAfterBatch"];
|
|
287
280
|
/**
|
|
288
|
-
*
|
|
289
|
-
*/
|
|
290
|
-
const unhydratedFlexTreeNodeToTreeNodeInternal = new WeakMap();
|
|
291
|
-
/**
|
|
292
|
-
* Retrieves the {@link TreeNode} associated with the given {@link UnhydratedFlexTreeNode} if any.
|
|
281
|
+
* Narrows innerNode to either {@link UnhydratedFlexTreeNode} or {@link HydratedFlexTreeNode}.
|
|
293
282
|
*/
|
|
294
|
-
export
|
|
283
|
+
export function splitInnerNodeType(innerNode) {
|
|
284
|
+
assert(innerNode instanceof UnhydratedFlexTreeNode || innerNode.isHydrated(), "Invalid inner node type");
|
|
285
|
+
}
|
|
295
286
|
/**
|
|
296
287
|
* An anchor slot which associates an anchor with its corresponding {@link TreeNode}, if there is one.
|
|
297
288
|
* @remarks
|
|
@@ -321,6 +312,7 @@ export function getSimpleNodeSchemaFromInnerNode(innerNode) {
|
|
|
321
312
|
* Gets the {@link Context} for the {@link InnerNode}.
|
|
322
313
|
*/
|
|
323
314
|
export function getSimpleContextFromInnerNode(innerNode) {
|
|
315
|
+
splitInnerNodeType(innerNode);
|
|
324
316
|
if (innerNode instanceof UnhydratedFlexTreeNode) {
|
|
325
317
|
return innerNode.simpleContext;
|
|
326
318
|
}
|
|
@@ -329,18 +321,18 @@ export function getSimpleContextFromInnerNode(innerNode) {
|
|
|
329
321
|
return context;
|
|
330
322
|
}
|
|
331
323
|
/**
|
|
332
|
-
* Retrieves the flex node associated with the given target
|
|
324
|
+
* Retrieves the flex node associated with the given target.
|
|
333
325
|
* @remarks
|
|
334
326
|
* For {@link Unhydrated} nodes, this returns the MapTreeNode.
|
|
335
327
|
*
|
|
336
328
|
* For hydrated nodes it returns a FlexTreeNode backed by the forest.
|
|
337
329
|
* Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.
|
|
338
330
|
*
|
|
339
|
-
*
|
|
331
|
+
* @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.
|
|
340
332
|
*/
|
|
341
|
-
export function getOrCreateInnerNode(treeNode
|
|
333
|
+
export function getOrCreateInnerNode(treeNode) {
|
|
342
334
|
const kernel = getKernel(treeNode);
|
|
343
|
-
return kernel.getOrCreateInnerNode(
|
|
335
|
+
return kernel.getOrCreateInnerNode();
|
|
344
336
|
}
|
|
345
337
|
/**
|
|
346
338
|
* Gets a flex node from an anchor node
|