@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
package/src/simple-tree/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ export {
|
|
|
22
22
|
HydratedContext,
|
|
23
23
|
SimpleContextSlot,
|
|
24
24
|
getOrCreateInnerNode,
|
|
25
|
+
getOrCreateNodeFromInnerNode,
|
|
25
26
|
getKernel,
|
|
26
27
|
} from "./core/index.js";
|
|
27
28
|
export {
|
|
@@ -120,7 +121,6 @@ export {
|
|
|
120
121
|
type FixRecursiveRecursionLimit,
|
|
121
122
|
schemaStatics,
|
|
122
123
|
type TreeChangeEvents,
|
|
123
|
-
createFromMapTree,
|
|
124
124
|
} from "./api/index.js";
|
|
125
125
|
export type {
|
|
126
126
|
SimpleTreeSchema,
|
|
@@ -207,11 +207,11 @@ export {
|
|
|
207
207
|
createUnknownOptionalFieldPolicy,
|
|
208
208
|
} from "./node-kinds/index.js";
|
|
209
209
|
export {
|
|
210
|
-
|
|
210
|
+
unhydratedFlexTreeFromInsertable,
|
|
211
211
|
type InsertableContent,
|
|
212
212
|
type FactoryContent,
|
|
213
213
|
type FactoryContentObject,
|
|
214
|
-
} from "./
|
|
214
|
+
} from "./unhydratedFlexTreeFromInsertable.js";
|
|
215
215
|
export {
|
|
216
216
|
prepareForInsertion,
|
|
217
217
|
prepareForInsertionContextless,
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
import { Lazy, oob, fail } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
|
|
9
|
-
import { EmptyKey
|
|
9
|
+
import { EmptyKey } from "../../../core/index.js";
|
|
10
10
|
import {
|
|
11
|
+
type FlexibleFieldContent,
|
|
11
12
|
type FlexTreeNode,
|
|
12
13
|
type FlexTreeSequenceField,
|
|
13
14
|
isFlexTreeNode,
|
|
@@ -37,14 +38,15 @@ import {
|
|
|
37
38
|
getSimpleNodeSchemaFromInnerNode,
|
|
38
39
|
getOrCreateInnerNode,
|
|
39
40
|
type TreeNodeSchemaClass,
|
|
40
|
-
} from "../../core/index.js";
|
|
41
|
-
import { type InsertableContent, mapTreeFromNodeData } from "../../toMapTree.js";
|
|
42
|
-
import { prepareArrayContentForInsertion } from "../../prepareForInsertion.js";
|
|
43
|
-
import {
|
|
44
41
|
getKernel,
|
|
45
|
-
UnhydratedFlexTreeNode,
|
|
46
|
-
|
|
42
|
+
type UnhydratedFlexTreeNode,
|
|
43
|
+
UnhydratedSequenceField,
|
|
47
44
|
} from "../../core/index.js";
|
|
45
|
+
import {
|
|
46
|
+
type InsertableContent,
|
|
47
|
+
unhydratedFlexTreeFromInsertable,
|
|
48
|
+
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
49
|
+
import { prepareArrayContentForInsertion } from "../../prepareForInsertion.js";
|
|
48
50
|
import { TreeNodeValid, type MostDerivedData } from "../../treeNodeValid.js";
|
|
49
51
|
import { getUnhydratedContext } from "../../createContext.js";
|
|
50
52
|
import type { System_Unsafe } from "../../api/index.js";
|
|
@@ -852,7 +854,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
852
854
|
super(input ?? []);
|
|
853
855
|
}
|
|
854
856
|
|
|
855
|
-
#mapTreesFromFieldData(value: Insertable<T>):
|
|
857
|
+
#mapTreesFromFieldData(value: Insertable<T>): FlexibleFieldContent {
|
|
856
858
|
const sequenceField = getSequenceField(this);
|
|
857
859
|
const content = value as readonly (
|
|
858
860
|
| InsertableContent
|
|
@@ -1014,7 +1016,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
1014
1016
|
|
|
1015
1017
|
const movedCount = sourceEnd - sourceStart;
|
|
1016
1018
|
if (!destinationField.context.isHydrated()) {
|
|
1017
|
-
if (!(sourceField instanceof
|
|
1019
|
+
if (!(sourceField instanceof UnhydratedSequenceField)) {
|
|
1018
1020
|
throw new UsageError(
|
|
1019
1021
|
"Cannot move elements from a hydrated array to an unhydrated array.",
|
|
1020
1022
|
);
|
|
@@ -1139,10 +1141,7 @@ export function arraySchema<
|
|
|
1139
1141
|
instance: TreeNodeValid<T2>,
|
|
1140
1142
|
input: T2,
|
|
1141
1143
|
): UnhydratedFlexTreeNode {
|
|
1142
|
-
return
|
|
1143
|
-
unhydratedContext,
|
|
1144
|
-
mapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),
|
|
1145
|
-
);
|
|
1144
|
+
return unhydratedFlexTreeFromInsertable(input as object, this as typeof Schema);
|
|
1146
1145
|
}
|
|
1147
1146
|
|
|
1148
1147
|
public static get allowedTypesIdentifiers(): ReadonlySet<string> {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import type {
|
|
8
|
+
FlexibleNodeContent,
|
|
8
9
|
FlexTreeNode,
|
|
9
10
|
FlexTreeOptionalField,
|
|
10
11
|
OptionalFieldEditBuilder,
|
|
@@ -32,19 +33,18 @@ import {
|
|
|
32
33
|
type TreeNode,
|
|
33
34
|
typeSchemaSymbol,
|
|
34
35
|
type Context,
|
|
35
|
-
UnhydratedFlexTreeNode,
|
|
36
36
|
getOrCreateInnerNode,
|
|
37
37
|
type InternalTreeNode,
|
|
38
|
+
type UnhydratedFlexTreeNode,
|
|
38
39
|
} from "../../core/index.js";
|
|
39
40
|
import {
|
|
40
|
-
|
|
41
|
+
unhydratedFlexTreeFromInsertable,
|
|
41
42
|
type FactoryContent,
|
|
42
43
|
type InsertableContent,
|
|
43
|
-
} from "../../
|
|
44
|
+
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
44
45
|
import { prepareForInsertion } from "../../prepareForInsertion.js";
|
|
45
46
|
import { brand, count, type RestrictiveStringRecord } from "../../../util/index.js";
|
|
46
47
|
import { TreeNodeValid, type MostDerivedData } from "../../treeNodeValid.js";
|
|
47
|
-
import type { ExclusiveMapTree } from "../../../core/index.js";
|
|
48
48
|
import { getUnhydratedContext } from "../../createContext.js";
|
|
49
49
|
import type { MapNodeCustomizableSchema, MapNodePojoEmulationSchema } from "./mapNodeTypes.js";
|
|
50
50
|
|
|
@@ -158,7 +158,7 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
158
158
|
return getOrCreateInnerNode(this);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
private editor(key: string): OptionalFieldEditBuilder<
|
|
161
|
+
private editor(key: string): OptionalFieldEditBuilder<FlexibleNodeContent> {
|
|
162
162
|
const field = this.innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;
|
|
163
163
|
return field.editor;
|
|
164
164
|
}
|
|
@@ -271,10 +271,7 @@ export function mapSchema<
|
|
|
271
271
|
instance: TreeNodeValid<T2>,
|
|
272
272
|
input: T2,
|
|
273
273
|
): UnhydratedFlexTreeNode {
|
|
274
|
-
return
|
|
275
|
-
unhydratedContext,
|
|
276
|
-
mapTreeFromNodeData(input as FactoryContent, this as unknown as ImplicitAllowedTypes),
|
|
277
|
-
);
|
|
274
|
+
return unhydratedFlexTreeFromInsertable(input as FactoryContent, this as typeof Schema);
|
|
278
275
|
}
|
|
279
276
|
|
|
280
277
|
public static get allowedTypesIdentifiers(): ReadonlySet<string> {
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert, Lazy, fail, debugAssert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
-
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
9
|
-
import { createIdCompressor } from "@fluidframework/id-compressor/internal";
|
|
10
8
|
|
|
11
9
|
import type { FieldKey, SchemaPolicy } from "../../../core/index.js";
|
|
12
10
|
import {
|
|
@@ -16,7 +14,7 @@ import {
|
|
|
16
14
|
type FlexTreeOptionalField,
|
|
17
15
|
type FlexTreeRequiredField,
|
|
18
16
|
} from "../../../feature-libraries/index.js";
|
|
19
|
-
import {
|
|
17
|
+
import type { RestrictiveStringRecord, FlattenKeys } from "../../../util/index.js";
|
|
20
18
|
|
|
21
19
|
import {
|
|
22
20
|
type TreeNodeSchema,
|
|
@@ -28,7 +26,7 @@ import {
|
|
|
28
26
|
type InternalTreeNode,
|
|
29
27
|
type TreeNode,
|
|
30
28
|
type Context,
|
|
31
|
-
UnhydratedFlexTreeNode,
|
|
29
|
+
type UnhydratedFlexTreeNode,
|
|
32
30
|
getOrCreateInnerNode,
|
|
33
31
|
} from "../../core/index.js";
|
|
34
32
|
import { getUnhydratedContext } from "../../createContext.js";
|
|
@@ -47,7 +45,6 @@ import {
|
|
|
47
45
|
type InsertableTreeFieldFromImplicitField,
|
|
48
46
|
type FieldSchema,
|
|
49
47
|
normalizeFieldSchema,
|
|
50
|
-
type ImplicitAllowedTypes,
|
|
51
48
|
FieldKind,
|
|
52
49
|
type NodeSchemaMetadata,
|
|
53
50
|
type FieldSchemaAlpha,
|
|
@@ -57,9 +54,11 @@ import {
|
|
|
57
54
|
type UnannotateSchemaRecord,
|
|
58
55
|
} from "../../schemaTypes.js";
|
|
59
56
|
import type { SimpleObjectFieldSchema } from "../../simpleSchema.js";
|
|
60
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
unhydratedFlexTreeFromInsertable,
|
|
59
|
+
type InsertableContent,
|
|
60
|
+
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
61
61
|
import { TreeNodeValid, type MostDerivedData } from "../../treeNodeValid.js";
|
|
62
|
-
import { stringSchema } from "../../leafNodeSchema.js";
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* Generates the properties for an ObjectNode from its field schema object.
|
|
@@ -201,37 +200,6 @@ function createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): Simp
|
|
|
201
200
|
return keyMap;
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
const globalIdentifierAllocator: IIdCompressor = createIdCompressor();
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Modify `flexNode` to add a newly generated identifier under the given `storedKey`.
|
|
208
|
-
* @remarks
|
|
209
|
-
* This is used after checking if the user is trying to read an identifier field of an unhydrated node, but the identifier is not present.
|
|
210
|
-
* This means the identifier is an "auto-generated identifier", because otherwise it would have been supplied by the user at construction time and would have been successfully read just above.
|
|
211
|
-
* In this case, it is categorically impossible to provide an identifier (auto-generated identifiers can't be created until hydration/insertion time), so we emit an error.
|
|
212
|
-
* @privateRemarks
|
|
213
|
-
* TODO: this special case logic should move to the inner node (who's schema claims it has an identifier), rather than here, after we already read undefined out of a required field.
|
|
214
|
-
* TODO: unify this with a more general defaults mechanism.
|
|
215
|
-
*/
|
|
216
|
-
export function lazilyAllocateIdentifier(
|
|
217
|
-
flexNode: UnhydratedFlexTreeNode,
|
|
218
|
-
storedKey: FieldKey,
|
|
219
|
-
): string {
|
|
220
|
-
debugAssert(() => !flexNode.mapTree.fields.has(storedKey) || "Identifier field already set");
|
|
221
|
-
const value = globalIdentifierAllocator.decompress(
|
|
222
|
-
globalIdentifierAllocator.generateCompressedId(),
|
|
223
|
-
);
|
|
224
|
-
flexNode.mapTree.fields.set(storedKey, [
|
|
225
|
-
{
|
|
226
|
-
type: brand(stringSchema.identifier),
|
|
227
|
-
value,
|
|
228
|
-
fields: new Map(),
|
|
229
|
-
},
|
|
230
|
-
]);
|
|
231
|
-
|
|
232
|
-
return value;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
203
|
/**
|
|
236
204
|
* Creates a proxy handler for the given schema.
|
|
237
205
|
*
|
|
@@ -265,13 +233,6 @@ function createProxyHandler(
|
|
|
265
233
|
return getTreeNodeForField(field);
|
|
266
234
|
}
|
|
267
235
|
|
|
268
|
-
if (
|
|
269
|
-
fieldInfo.schema.kind === FieldKind.Identifier &&
|
|
270
|
-
flexNode instanceof UnhydratedFlexTreeNode
|
|
271
|
-
) {
|
|
272
|
-
return lazilyAllocateIdentifier(flexNode, fieldInfo.storedKey);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
236
|
return undefined;
|
|
276
237
|
}
|
|
277
238
|
|
|
@@ -495,10 +456,7 @@ export function objectSchema<
|
|
|
495
456
|
instance: TreeNodeValid<T2>,
|
|
496
457
|
input: T2,
|
|
497
458
|
): UnhydratedFlexTreeNode {
|
|
498
|
-
return
|
|
499
|
-
unhydratedContext,
|
|
500
|
-
mapTreeFromNodeData(input as object, this as unknown as ImplicitAllowedTypes),
|
|
501
|
-
);
|
|
459
|
+
return unhydratedFlexTreeFromInsertable(input as object, this as Output);
|
|
502
460
|
}
|
|
503
461
|
|
|
504
462
|
protected static override constructorCached: MostDerivedData | undefined = undefined;
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type {
|
|
7
|
-
ExclusiveMapTree,
|
|
8
7
|
SchemaAndPolicy,
|
|
9
8
|
IForestSubscription,
|
|
10
|
-
MapTree,
|
|
11
9
|
UpPath,
|
|
12
10
|
NodeIndex,
|
|
13
11
|
FieldKey,
|
|
@@ -17,23 +15,23 @@ import type {
|
|
|
17
15
|
import {
|
|
18
16
|
type FlexTreeContext,
|
|
19
17
|
getSchemaAndPolicy,
|
|
20
|
-
type
|
|
18
|
+
type FlexTreeHydratedContextMinimal,
|
|
21
19
|
FieldKinds,
|
|
20
|
+
type FlexibleFieldContent,
|
|
21
|
+
type FlexibleNodeContent,
|
|
22
22
|
} from "../feature-libraries/index.js";
|
|
23
23
|
import {
|
|
24
24
|
normalizeFieldSchema,
|
|
25
25
|
type ImplicitAllowedTypes,
|
|
26
26
|
type ImplicitFieldSchema,
|
|
27
27
|
} from "./schemaTypes.js";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
type InsertableContent,
|
|
30
|
+
unhydratedFlexTreeFromInsertable,
|
|
31
|
+
} from "./unhydratedFlexTreeFromInsertable.js";
|
|
29
32
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
30
33
|
import { brand } from "../util/index.js";
|
|
31
|
-
import {
|
|
32
|
-
getKernel,
|
|
33
|
-
type TreeNode,
|
|
34
|
-
tryUnhydratedFlexTreeNode,
|
|
35
|
-
unhydratedFlexTreeNodeToTreeNode,
|
|
36
|
-
} from "./core/index.js";
|
|
34
|
+
import { getKernel, type TreeNode, type UnhydratedFlexTreeNode } from "./core/index.js";
|
|
37
35
|
import { debugAssert, oob } from "@fluidframework/core-utils/internal";
|
|
38
36
|
import { inSchemaOrThrow, isFieldInSchema } from "../feature-libraries/index.js";
|
|
39
37
|
import { convertField } from "./toStoredSchema.js";
|
|
@@ -50,7 +48,7 @@ export function prepareForInsertion<TIn extends InsertableContent | undefined>(
|
|
|
50
48
|
data: TIn,
|
|
51
49
|
schema: ImplicitFieldSchema,
|
|
52
50
|
destinationContext: FlexTreeContext,
|
|
53
|
-
): TIn extends undefined ? undefined :
|
|
51
|
+
): TIn extends undefined ? undefined : FlexibleNodeContent {
|
|
54
52
|
return prepareForInsertionContextless(
|
|
55
53
|
data,
|
|
56
54
|
schema,
|
|
@@ -76,13 +74,9 @@ export function prepareArrayContentForInsertion(
|
|
|
76
74
|
data: readonly InsertableContent[],
|
|
77
75
|
schema: ImplicitAllowedTypes,
|
|
78
76
|
destinationContext: FlexTreeContext,
|
|
79
|
-
):
|
|
80
|
-
const mapTrees:
|
|
81
|
-
|
|
82
|
-
item,
|
|
83
|
-
schema,
|
|
84
|
-
destinationContext.isHydrated() ? destinationContext.nodeKeyManager : undefined,
|
|
85
|
-
),
|
|
77
|
+
): FlexibleFieldContent {
|
|
78
|
+
const mapTrees: UnhydratedFlexTreeNode[] = data.map((item) =>
|
|
79
|
+
unhydratedFlexTreeFromInsertable(item, schema),
|
|
86
80
|
);
|
|
87
81
|
|
|
88
82
|
const fieldSchema = convertField(normalizeFieldSchema(schema));
|
|
@@ -110,9 +104,9 @@ export function prepareForInsertionContextless<TIn extends InsertableContent | u
|
|
|
110
104
|
data: TIn,
|
|
111
105
|
schema: ImplicitFieldSchema,
|
|
112
106
|
schemaAndPolicy: SchemaAndPolicy,
|
|
113
|
-
hydratedData:
|
|
114
|
-
): TIn extends undefined ? undefined :
|
|
115
|
-
const mapTree =
|
|
107
|
+
hydratedData: FlexTreeHydratedContextMinimal | undefined,
|
|
108
|
+
): TIn extends undefined ? undefined : FlexibleNodeContent {
|
|
109
|
+
const mapTree = unhydratedFlexTreeFromInsertable(data, schema);
|
|
116
110
|
|
|
117
111
|
const contentArray = mapTree === undefined ? [] : [mapTree];
|
|
118
112
|
const fieldSchema = convertField(normalizeFieldSchema(schema));
|
|
@@ -129,16 +123,19 @@ export function prepareForInsertionContextless<TIn extends InsertableContent | u
|
|
|
129
123
|
*/
|
|
130
124
|
function validateAndPrepare(
|
|
131
125
|
schemaAndPolicy: SchemaAndPolicy,
|
|
132
|
-
hydratedData:
|
|
126
|
+
hydratedData: FlexTreeHydratedContextMinimal | undefined,
|
|
133
127
|
fieldSchema: TreeFieldStoredSchema,
|
|
134
|
-
mapTrees:
|
|
128
|
+
mapTrees: readonly UnhydratedFlexTreeNode[],
|
|
135
129
|
): void {
|
|
136
130
|
if (hydratedData !== undefined) {
|
|
131
|
+
// Run `prepareContentForHydration` before walking the tree in `isFieldInSchema`.
|
|
132
|
+
// This ensures that when `isFieldInSchema` requests identifiers (or any other contextual defaults),
|
|
133
|
+
// they were already creating used the more specific context we have access to from `hydratedData`.
|
|
134
|
+
prepareContentForHydration(mapTrees, hydratedData.checkout.forest, hydratedData);
|
|
137
135
|
if (schemaAndPolicy.policy.validateSchema === true) {
|
|
138
136
|
const maybeError = isFieldInSchema(mapTrees, fieldSchema, schemaAndPolicy);
|
|
139
137
|
inSchemaOrThrow(maybeError);
|
|
140
138
|
}
|
|
141
|
-
prepareContentForHydration(mapTrees, hydratedData.checkout.forest);
|
|
142
139
|
}
|
|
143
140
|
}
|
|
144
141
|
|
|
@@ -176,17 +173,21 @@ interface LocatedNodesBatch {
|
|
|
176
173
|
const placeholderKey: DetachedField & FieldKey = brand("placeholder" as const);
|
|
177
174
|
|
|
178
175
|
/**
|
|
179
|
-
* Records any
|
|
180
|
-
*
|
|
176
|
+
* Records any {@link TreeNode}s in the given `content` tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.
|
|
177
|
+
* Additionally populates any {@link UnhydratedFlexTreeField.pendingDefault}s using the provided `context`.
|
|
178
|
+
*
|
|
179
|
+
* @remarks If the content tree contains has any associated {@link TreeNode}s, this function must be called just prior to inserting the content into the tree.
|
|
181
180
|
* Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.
|
|
182
181
|
* The insertion of `content` must occur or else this function will cause memory leaks.
|
|
182
|
+
*
|
|
183
|
+
* Exported for testing purposes: otherwise should not be used outside this module.
|
|
183
184
|
* @param content - the content subsequence to be inserted, of which might deeply contain {@link TreeNode}s which need to be hydrated.
|
|
184
185
|
* @param forest - the forest the content is being inserted into.
|
|
185
|
-
* See {@link extractFactoryContent} for more details.
|
|
186
186
|
*/
|
|
187
|
-
function prepareContentForHydration(
|
|
188
|
-
content: readonly
|
|
187
|
+
export function prepareContentForHydration(
|
|
188
|
+
content: readonly UnhydratedFlexTreeNode[],
|
|
189
189
|
forest: IForestSubscription,
|
|
190
|
+
context: FlexTreeHydratedContextMinimal,
|
|
190
191
|
): void {
|
|
191
192
|
const batches: LocatedNodesBatch[] = [];
|
|
192
193
|
for (const item of content) {
|
|
@@ -199,39 +200,45 @@ function prepareContentForHydration(
|
|
|
199
200
|
paths: [],
|
|
200
201
|
};
|
|
201
202
|
batches.push(batch);
|
|
202
|
-
walkMapTree(
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
walkMapTree(
|
|
204
|
+
item,
|
|
205
|
+
batch.rootPath,
|
|
206
|
+
(p, node) => {
|
|
207
|
+
batch.paths.push({ path: p, node });
|
|
208
|
+
},
|
|
209
|
+
context,
|
|
210
|
+
);
|
|
205
211
|
}
|
|
206
212
|
|
|
207
213
|
scheduleHydration(batches, forest);
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
function walkMapTree(
|
|
211
|
-
|
|
217
|
+
root: UnhydratedFlexTreeNode,
|
|
212
218
|
path: UpPath,
|
|
213
219
|
onVisitTreeNode: (path: UpPath, treeNode: TreeNode) => void,
|
|
220
|
+
context: FlexTreeHydratedContextMinimal,
|
|
214
221
|
): void {
|
|
215
|
-
if (
|
|
222
|
+
if (root.parentField.parent.parent !== undefined) {
|
|
216
223
|
throw new UsageError(
|
|
217
224
|
"Attempted to insert a node which is already under a parent. If this is desired, remove the node from its parent before inserting it elsewhere.",
|
|
218
225
|
);
|
|
219
226
|
}
|
|
220
227
|
|
|
221
|
-
type Next = [path: UpPath, tree:
|
|
228
|
+
type Next = [path: UpPath, tree: UnhydratedFlexTreeNode];
|
|
222
229
|
const nexts: Next[] = [];
|
|
223
|
-
for (let next: Next | undefined = [path,
|
|
224
|
-
const [p,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const treeNode = unhydratedFlexTreeNodeToTreeNode.get(mapTreeNode);
|
|
230
|
+
for (let next: Next | undefined = [path, root]; next !== undefined; next = nexts.pop()) {
|
|
231
|
+
const [p, node] = next;
|
|
232
|
+
if (node !== undefined) {
|
|
233
|
+
const treeNode = node.treeNode;
|
|
228
234
|
if (treeNode !== undefined) {
|
|
229
235
|
onVisitTreeNode(p, treeNode);
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
|
|
233
|
-
for (const [key, field] of
|
|
234
|
-
|
|
239
|
+
for (const [key, field] of node.allFieldsLazy) {
|
|
240
|
+
field.fillPendingDefaults(context);
|
|
241
|
+
for (const [i, child] of field.children.entries()) {
|
|
235
242
|
nexts.push([
|
|
236
243
|
{
|
|
237
244
|
parent: p,
|
|
@@ -8,7 +8,7 @@ import { Lazy } from "@fluidframework/core-utils/internal";
|
|
|
8
8
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
|
|
10
10
|
import type { FieldKey } from "../core/index.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { FlexTreeHydratedContextMinimal } from "../feature-libraries/index.js";
|
|
12
12
|
import {
|
|
13
13
|
type MakeNominal,
|
|
14
14
|
brand,
|
|
@@ -30,12 +30,13 @@ import type {
|
|
|
30
30
|
TreeNode,
|
|
31
31
|
TreeNodeSchemaCore,
|
|
32
32
|
TreeNodeSchemaNonClass,
|
|
33
|
+
UnhydratedFlexTreeNode,
|
|
33
34
|
} from "./core/index.js";
|
|
34
35
|
import { inPrototypeChain } from "./core/index.js";
|
|
35
36
|
import { isLazy, type FlexListToUnion, type LazyItem } from "./flexList.js";
|
|
36
37
|
import { LeafNodeSchema } from "./leafNodeSchema.js";
|
|
37
38
|
import type { SimpleFieldSchema, SimpleObjectFieldSchema } from "./simpleSchema.js";
|
|
38
|
-
import type { InsertableContent } from "./
|
|
39
|
+
import type { InsertableContent } from "./unhydratedFlexTreeFromInsertable.js";
|
|
39
40
|
import { TreeNodeValid } from "./treeNodeValid.js";
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -296,17 +297,17 @@ export interface FieldProps<TCustomMetadata = unknown> {
|
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
/**
|
|
299
|
-
* A {@link FieldProvider} which
|
|
300
|
+
* A {@link FieldProvider} which prefers to have additional context in order to produce its content.
|
|
300
301
|
*/
|
|
301
302
|
export type ContextualFieldProvider = (
|
|
302
|
-
context:
|
|
303
|
-
) =>
|
|
303
|
+
context: FlexTreeHydratedContextMinimal | "UseGlobalContext",
|
|
304
|
+
) => UnhydratedFlexTreeNode[];
|
|
304
305
|
/**
|
|
305
|
-
* A {@link FieldProvider} which can produce its content in a vacuum
|
|
306
|
+
* A {@link FieldProvider} which can produce its content in a vacuum.
|
|
306
307
|
*/
|
|
307
|
-
export type ConstantFieldProvider = () =>
|
|
308
|
+
export type ConstantFieldProvider = () => UnhydratedFlexTreeNode[];
|
|
308
309
|
/**
|
|
309
|
-
* A function which produces content for a field every time that it is called
|
|
310
|
+
* A function which produces content for a field every time that it is called.
|
|
310
311
|
*/
|
|
311
312
|
export type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;
|
|
312
313
|
/**
|
|
@@ -93,7 +93,13 @@ export function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {
|
|
|
93
93
|
return { kind, types };
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
/**
|
|
97
|
+
* A map that converts {@link FieldKind} to {@link FlexFieldKind}.
|
|
98
|
+
*/
|
|
99
|
+
export const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<
|
|
100
|
+
FieldKind,
|
|
101
|
+
FlexFieldKind
|
|
102
|
+
>([
|
|
97
103
|
[FieldKind.Optional, FieldKinds.optional],
|
|
98
104
|
[FieldKind.Required, FieldKinds.required],
|
|
99
105
|
[FieldKind.Identifier, FieldKinds.identifier],
|