@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,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.getPossibleTypes = exports.unhydratedFlexTreeFromInsertable = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
10
|
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
@@ -16,10 +16,14 @@ const schemaTypes_js_1 = require("./schemaTypes.js");
|
|
|
16
16
|
const index_js_4 = require("./core/index.js");
|
|
17
17
|
// Required to prevent the introduction of new circular dependencies
|
|
18
18
|
// TODO: Having the schema provide their own policy functions for compatibility which
|
|
19
|
-
//
|
|
19
|
+
// unhydratedFlexTreeFromInsertable invokes instead of manually handling each kind would remove this bad
|
|
20
20
|
// dependency, and reduce coupling.
|
|
21
21
|
// eslint-disable-next-line import/no-internal-modules
|
|
22
22
|
const objectNodeTypes_js_1 = require("./node-kinds/object/objectNodeTypes.js");
|
|
23
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
24
|
+
const unhydratedFlexTree_js_1 = require("./core/unhydratedFlexTree.js");
|
|
25
|
+
const toStoredSchema_js_1 = require("./toStoredSchema.js");
|
|
26
|
+
const createContext_js_1 = require("./createContext.js");
|
|
23
27
|
/**
|
|
24
28
|
* Module notes:
|
|
25
29
|
*
|
|
@@ -31,7 +35,7 @@ const objectNodeTypes_js_1 = require("./node-kinds/object/objectNodeTypes.js");
|
|
|
31
35
|
* schema than on the input data.
|
|
32
36
|
*/
|
|
33
37
|
/**
|
|
34
|
-
* Transforms an input {@link TypedNode} tree to
|
|
38
|
+
* Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.
|
|
35
39
|
* @param data - The input tree to be converted.
|
|
36
40
|
* If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,
|
|
37
41
|
* otherwise an error will be thrown.
|
|
@@ -48,14 +52,15 @@ const objectNodeTypes_js_1 = require("./node-kinds/object/objectNodeTypes.js");
|
|
|
48
52
|
* If `context` is not provided, defaults which require a context will be left empty which can be out of schema.
|
|
49
53
|
*
|
|
50
54
|
* @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.
|
|
51
|
-
* @
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.
|
|
57
|
+
*
|
|
58
|
+
* Often throws UsageErrors for invalid data, but may miss some cases.
|
|
59
|
+
*
|
|
60
|
+
* Output should comply with the provided view schema, but this is not explicitly validated:
|
|
61
|
+
* validation against stored schema (to guard against document corruption) is done elsewhere.
|
|
57
62
|
*/
|
|
58
|
-
function
|
|
63
|
+
function unhydratedFlexTreeFromInsertable(data, allowedTypes) {
|
|
59
64
|
const normalizedFieldSchema = (0, schemaTypes_js_1.normalizeFieldSchema)(allowedTypes);
|
|
60
65
|
if (data === undefined) {
|
|
61
66
|
// TODO: this code-path should support defaults
|
|
@@ -64,60 +69,47 @@ function mapTreeFromNodeData(data, allowedTypes, context) {
|
|
|
64
69
|
}
|
|
65
70
|
return undefined;
|
|
66
71
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
addDefaultsToMapTree(mapTree, normalizedFieldSchema.allowedTypes, context);
|
|
70
|
-
return mapTree;
|
|
72
|
+
const flexTree = unhydratedFlexTreeFromInsertableNode(data, normalizedFieldSchema.allowedTypeSet);
|
|
73
|
+
return flexTree;
|
|
71
74
|
}
|
|
72
|
-
exports.
|
|
75
|
+
exports.unhydratedFlexTreeFromInsertable = unhydratedFlexTreeFromInsertable;
|
|
73
76
|
/**
|
|
74
|
-
* Copy content from `data` into a
|
|
75
|
-
* Does NOT generate and default values for fields.
|
|
76
|
-
* Often throws UsageErrors for invalid data, but may miss some cases.
|
|
77
|
-
* @remarks
|
|
78
|
-
* Output is likely out of schema even for valid input due to missing defaults.
|
|
77
|
+
* Copy content from `data` into a UnhydratedFlexTreeNode.
|
|
79
78
|
*/
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (innerNode instanceof index_js_4.UnhydratedFlexTreeNode) {
|
|
86
|
-
if (!allowedTypes.has((0, index_js_4.getSimpleNodeSchemaFromInnerNode)(innerNode))) {
|
|
87
|
-
throw new internal_2.UsageError("Invalid schema for this context.");
|
|
88
|
-
}
|
|
89
|
-
// TODO: mapTreeFromNodeData modifies the trees it gets to add defaults.
|
|
90
|
-
// Using a cached value here can result in this tree having defaults applied to it more than once.
|
|
91
|
-
// This is unnecessary and inefficient, but should be a no-op if all calls provide the same context (which they might not).
|
|
92
|
-
// A cleaner design (avoiding this cast) might be to apply defaults eagerly if they don't need a context, and lazily (when hydrating) if they do.
|
|
93
|
-
// This could avoid having to mutate the map tree to apply defaults, removing the need for this cast.
|
|
94
|
-
return innerNode.mapTree;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
79
|
+
function unhydratedFlexTreeFromInsertableNode(data, allowedTypes) {
|
|
80
|
+
if ((0, index_js_4.isTreeNode)(data)) {
|
|
81
|
+
const kernel = (0, index_js_4.getKernel)(data);
|
|
82
|
+
const inner = kernel.getInnerNodeIfUnhydrated();
|
|
83
|
+
if (inner === undefined) {
|
|
97
84
|
// The node is already hydrated, meaning that it already got inserted into the tree previously
|
|
98
85
|
throw new internal_2.UsageError("A node may not be inserted into the tree more than once");
|
|
99
86
|
}
|
|
87
|
+
else {
|
|
88
|
+
if (!allowedTypes.has(kernel.schema)) {
|
|
89
|
+
throw new internal_2.UsageError("Invalid schema for this context.");
|
|
90
|
+
}
|
|
91
|
+
return inner;
|
|
92
|
+
}
|
|
100
93
|
}
|
|
101
|
-
(0, internal_1.assert)(!(0, index_js_4.isTreeNode)(data), 0xa23 /* data without an inner node cannot be TreeNode */);
|
|
102
94
|
const schema = getType(data, allowedTypes);
|
|
103
95
|
let result;
|
|
104
96
|
switch (schema.kind) {
|
|
105
97
|
case index_js_4.NodeKind.Leaf:
|
|
106
|
-
result =
|
|
98
|
+
result = leafToFlexContent(data, schema, allowedTypes);
|
|
107
99
|
break;
|
|
108
100
|
case index_js_4.NodeKind.Array:
|
|
109
|
-
result =
|
|
101
|
+
result = arrayToFlexContent(data, schema);
|
|
110
102
|
break;
|
|
111
103
|
case index_js_4.NodeKind.Map:
|
|
112
|
-
result =
|
|
104
|
+
result = mapToFlexContent(data, schema);
|
|
113
105
|
break;
|
|
114
106
|
case index_js_4.NodeKind.Object:
|
|
115
|
-
result =
|
|
107
|
+
result = objectToFlexContent(data, schema);
|
|
116
108
|
break;
|
|
117
109
|
default:
|
|
118
110
|
(0, internal_1.unreachableCase)(schema.kind);
|
|
119
111
|
}
|
|
120
|
-
return result;
|
|
112
|
+
return new index_js_4.UnhydratedFlexTreeNode(...result, (0, createContext_js_1.getUnhydratedContext)(schema));
|
|
121
113
|
}
|
|
122
114
|
/**
|
|
123
115
|
* Transforms data under a Leaf schema.
|
|
@@ -126,7 +118,7 @@ function nodeDataToMapTree(data, allowedTypes) {
|
|
|
126
118
|
* @param allowedTypes - The allowed types specified by the parent.
|
|
127
119
|
* Used to determine which fallback values may be appropriate.
|
|
128
120
|
*/
|
|
129
|
-
function
|
|
121
|
+
function leafToFlexContent(data, schema, allowedTypes) {
|
|
130
122
|
(0, internal_1.assert)(schema.kind === index_js_4.NodeKind.Leaf, 0x921 /* Expected a leaf schema. */);
|
|
131
123
|
if (!(0, index_js_2.isTreeValue)(data)) {
|
|
132
124
|
// This rule exists to protect against useless `toString` output like `[object Object]`.
|
|
@@ -137,11 +129,13 @@ function leafToMapTree(data, schema, allowedTypes) {
|
|
|
137
129
|
const mappedValue = mapValueWithFallbacks(data, allowedTypes);
|
|
138
130
|
const mappedSchema = getType(mappedValue, allowedTypes);
|
|
139
131
|
(0, internal_1.assert)(allowsValue(mappedSchema, mappedValue), 0x84a /* Unsupported schema for provided primitive. */);
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
value: mappedValue,
|
|
135
|
+
type: (0, index_js_3.brand)(mappedSchema.identifier),
|
|
136
|
+
},
|
|
137
|
+
new Map(),
|
|
138
|
+
];
|
|
145
139
|
}
|
|
146
140
|
/**
|
|
147
141
|
* Checks an incoming {@link TreeLeafValue} to ensure it is compatible with its requirements.
|
|
@@ -192,7 +186,7 @@ function mapValueWithFallbacks(value, allowedTypes) {
|
|
|
192
186
|
* @param data - The tree data to be transformed.
|
|
193
187
|
* @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.
|
|
194
188
|
*/
|
|
195
|
-
function
|
|
189
|
+
function arrayChildToFlexTree(child, allowedTypes) {
|
|
196
190
|
// We do not support undefined sequence entries.
|
|
197
191
|
// If we encounter an undefined entry, use null instead if supported by the schema, otherwise throw.
|
|
198
192
|
let childWithFallback = child;
|
|
@@ -204,39 +198,43 @@ function arrayChildToMapTree(child, allowedTypes) {
|
|
|
204
198
|
throw new TypeError(`Received unsupported array entry value: ${child}.`);
|
|
205
199
|
}
|
|
206
200
|
}
|
|
207
|
-
return
|
|
201
|
+
return unhydratedFlexTreeFromInsertableNode(childWithFallback, allowedTypes);
|
|
208
202
|
}
|
|
209
203
|
/**
|
|
210
204
|
* Transforms data under an Array schema.
|
|
211
205
|
* @param data - The tree data to be transformed. Must be an iterable.
|
|
212
206
|
* @param schema - The schema associated with the value.
|
|
213
|
-
* @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema
|
|
214
|
-
* validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will
|
|
215
|
-
* be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.
|
|
216
207
|
*/
|
|
217
|
-
function
|
|
208
|
+
function arrayToFlexContent(data, schema) {
|
|
218
209
|
(0, internal_1.assert)(schema.kind === index_js_4.NodeKind.Array, 0x922 /* Expected an array schema. */);
|
|
219
210
|
if (!(typeof data === "object" && data !== null && Symbol.iterator in data)) {
|
|
220
211
|
throw new internal_2.UsageError(`Input data is incompatible with Array schema: ${data}`);
|
|
221
212
|
}
|
|
222
213
|
const allowedChildTypes = (0, schemaTypes_js_1.normalizeAllowedTypes)(schema.info);
|
|
223
|
-
const mappedData = Array.from(data, (child) =>
|
|
214
|
+
const mappedData = Array.from(data, (child) => arrayChildToFlexTree(child, allowedChildTypes));
|
|
215
|
+
const context = (0, createContext_js_1.getUnhydratedContext)(schema).flexContext;
|
|
224
216
|
// Array nodes have a single `EmptyKey` field:
|
|
225
|
-
const fieldsEntries = mappedData.length === 0
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
217
|
+
const fieldsEntries = mappedData.length === 0
|
|
218
|
+
? []
|
|
219
|
+
: [
|
|
220
|
+
[
|
|
221
|
+
index_js_1.EmptyKey,
|
|
222
|
+
new index_js_4.UnhydratedSequenceField(context, index_js_2.FieldKinds.sequence.identifier, index_js_1.EmptyKey, mappedData),
|
|
223
|
+
],
|
|
224
|
+
];
|
|
225
|
+
return [
|
|
226
|
+
{
|
|
227
|
+
type: (0, index_js_3.brand)(schema.identifier),
|
|
228
|
+
},
|
|
229
|
+
new Map(fieldsEntries),
|
|
230
|
+
];
|
|
230
231
|
}
|
|
231
232
|
/**
|
|
232
233
|
* Transforms data under a Map schema.
|
|
233
234
|
* @param data - The tree data to be transformed. Must be an iterable.
|
|
234
235
|
* @param schema - The schema associated with the value.
|
|
235
|
-
* @param schemaValidationPolicy - The stored schema and policy to be used for validation, if the policy says schema
|
|
236
|
-
* validation should happen. If it does, the input tree will be validated against this schema + policy, and an error will
|
|
237
|
-
* be thrown if the tree does not conform to the schema. If undefined, no validation against the stored schema is done.
|
|
238
236
|
*/
|
|
239
|
-
function
|
|
237
|
+
function mapToFlexContent(data, schema) {
|
|
240
238
|
(0, internal_1.assert)(schema.kind === index_js_4.NodeKind.Map, 0x923 /* Expected a Map schema. */);
|
|
241
239
|
if (!(typeof data === "object" && data !== null)) {
|
|
242
240
|
throw new internal_2.UsageError(`Input data is incompatible with Map schema: ${data}`);
|
|
@@ -247,6 +245,7 @@ function mapToMapTree(data, schema) {
|
|
|
247
245
|
data
|
|
248
246
|
: // Support record objects for JSON style Map data
|
|
249
247
|
Object.entries(data));
|
|
248
|
+
const context = (0, createContext_js_1.getUnhydratedContext)(schema).flexContext;
|
|
250
249
|
const transformedFields = new Map();
|
|
251
250
|
for (const item of fieldsIterator) {
|
|
252
251
|
if (!(0, index_js_3.isReadonlyArray)(item) || item.length !== 2 || typeof item[0] !== "string") {
|
|
@@ -256,21 +255,24 @@ function mapToMapTree(data, schema) {
|
|
|
256
255
|
(0, internal_1.assert)(!transformedFields.has((0, index_js_3.brand)(key)), 0x84c /* Keys should not be duplicated */);
|
|
257
256
|
// Omit undefined values - an entry with an undefined value is equivalent to one that has been removed or omitted
|
|
258
257
|
if (value !== undefined) {
|
|
259
|
-
const
|
|
260
|
-
|
|
258
|
+
const child = unhydratedFlexTreeFromInsertableNode(value, allowedChildTypes);
|
|
259
|
+
const field = (0, unhydratedFlexTree_js_1.createField)(context, index_js_2.FieldKinds.optional.identifier, (0, index_js_3.brand)(key), [child]);
|
|
260
|
+
transformedFields.set((0, index_js_3.brand)(key), field);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
return [
|
|
264
|
+
{
|
|
265
|
+
type: (0, index_js_3.brand)(schema.identifier),
|
|
266
|
+
},
|
|
267
|
+
transformedFields,
|
|
268
|
+
];
|
|
267
269
|
}
|
|
268
270
|
/**
|
|
269
271
|
* Transforms data under an Object schema.
|
|
270
272
|
* @param data - The tree data to be transformed. Must be a Record-like object.
|
|
271
273
|
* @param schema - The schema associated with the value.
|
|
272
274
|
*/
|
|
273
|
-
function
|
|
275
|
+
function objectToFlexContent(data, schema) {
|
|
274
276
|
(0, internal_1.assert)((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema), 0x924 /* Expected an Object schema. */);
|
|
275
277
|
if (typeof data !== "object" ||
|
|
276
278
|
data === null ||
|
|
@@ -279,44 +281,52 @@ function objectToMapTree(data, schema) {
|
|
|
279
281
|
throw new internal_2.UsageError(`Input data is incompatible with Object schema: ${data}`);
|
|
280
282
|
}
|
|
281
283
|
const fields = new Map();
|
|
282
|
-
|
|
283
|
-
// This does NOT apply defaults.
|
|
284
|
+
const context = (0, createContext_js_1.getUnhydratedContext)(schema).flexContext;
|
|
284
285
|
for (const [key, fieldInfo] of schema.flexKeyMap) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
const value = getFieldProperty(data, key);
|
|
287
|
+
let children;
|
|
288
|
+
if (value === undefined) {
|
|
289
|
+
const defaultProvider = fieldInfo.schema.props?.defaultProvider ??
|
|
290
|
+
(0, internal_1.fail)(0xbb1 /* missing field has no default provider */);
|
|
291
|
+
const fieldProvider = (0, schemaTypes_js_1.extractFieldProvider)(defaultProvider);
|
|
292
|
+
children = (0, schemaTypes_js_1.isConstant)(fieldProvider) ? fieldProvider() : fieldProvider;
|
|
288
293
|
}
|
|
294
|
+
else {
|
|
295
|
+
children = [
|
|
296
|
+
unhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
const kind = toStoredSchema_js_1.convertFieldKind.get(fieldInfo.schema.kind) ?? (0, internal_1.fail)(0xbb2 /* Invalid field kind */);
|
|
300
|
+
fields.set(fieldInfo.storedKey, (0, unhydratedFlexTree_js_1.createField)(context, kind.identifier, fieldInfo.storedKey, children));
|
|
289
301
|
}
|
|
290
|
-
return {
|
|
291
|
-
type: (0, index_js_3.brand)(schema.identifier),
|
|
292
|
-
fields,
|
|
293
|
-
};
|
|
302
|
+
return [{ type: (0, index_js_3.brand)(schema.identifier) }, fields];
|
|
294
303
|
}
|
|
295
304
|
/**
|
|
296
305
|
* Check {@link FactoryContentObject} for a property which could be store a field.
|
|
306
|
+
*
|
|
307
|
+
* @returns If the property exists, return its value. Otherwise, returns undefined.
|
|
297
308
|
* @remarks
|
|
298
309
|
* The currently policy is to only consider own properties.
|
|
299
310
|
* See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.
|
|
300
311
|
*
|
|
301
|
-
* Explicit undefined
|
|
312
|
+
* Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.
|
|
313
|
+
*
|
|
314
|
+
* @privateRemarks
|
|
315
|
+
* If we ever want to have an optional field which defaults to something other than undefined, this will need changes.
|
|
316
|
+
* It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.
|
|
302
317
|
*/
|
|
303
|
-
function
|
|
318
|
+
function getFieldProperty(data, key) {
|
|
304
319
|
// This policy only allows own properties.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
function setFieldValue(fields, fieldValue, fieldSchema, flexKey) {
|
|
308
|
-
if (fieldValue !== undefined) {
|
|
309
|
-
const mappedChildTree = nodeDataToMapTree(fieldValue, fieldSchema.allowedTypeSet);
|
|
310
|
-
(0, internal_1.assert)(!fields.has(flexKey), 0x956 /* Keys must not be duplicated */);
|
|
311
|
-
fields.set(flexKey, [mappedChildTree]);
|
|
320
|
+
if (Object.hasOwnProperty.call(data, key)) {
|
|
321
|
+
return data[key];
|
|
312
322
|
}
|
|
323
|
+
return undefined;
|
|
313
324
|
}
|
|
314
325
|
function getType(data, allowedTypes) {
|
|
315
326
|
const possibleTypes = getPossibleTypes(allowedTypes, data);
|
|
316
327
|
if (possibleTypes.length === 0) {
|
|
317
328
|
throw new internal_2.UsageError(`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify([...allowedTypes].map((schema) => schema.identifier))}.`);
|
|
318
329
|
}
|
|
319
|
-
(0, internal_1.assert)((0, index_js_3.hasSome)(possibleTypes), 0x84e /* data is incompatible with all types allowed by the schema */);
|
|
320
330
|
if (!(0, index_js_3.hasSingle)(possibleTypes)) {
|
|
321
331
|
throw new internal_2.UsageError(`The provided data is compatible with more than one type allowed by the schema.
|
|
322
332
|
The set of possible types is ${JSON.stringify([
|
|
@@ -433,12 +443,7 @@ function shallowCompatibilityTest(schema, data) {
|
|
|
433
443
|
// If the schema has a required key which is not present in the input object, reject it.
|
|
434
444
|
for (const [fieldKey, fieldSchema] of schema.fields) {
|
|
435
445
|
if (fieldSchema.requiresValue) {
|
|
436
|
-
if (
|
|
437
|
-
if (data[fieldKey] === undefined) {
|
|
438
|
-
return CompatibilityLevel.None;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
446
|
+
if (getFieldProperty(data, fieldKey) === undefined) {
|
|
442
447
|
return CompatibilityLevel.None;
|
|
443
448
|
}
|
|
444
449
|
}
|
|
@@ -451,91 +456,4 @@ function allowsValue(schema, value) {
|
|
|
451
456
|
}
|
|
452
457
|
return false;
|
|
453
458
|
}
|
|
454
|
-
|
|
455
|
-
* Walk the given {@link ExclusiveMapTree} and deeply provide any field defaults for fields that are missing in the tree but present in the schema.
|
|
456
|
-
* @param mapTree - The tree to populate with defaults. This is borrowed: no references to it are kept by this function.
|
|
457
|
-
* @param allowedTypes - Some {@link TreeNodeSchema}, at least one of which the input tree must conform to
|
|
458
|
-
* @param context - An optional context for generating defaults.
|
|
459
|
-
* If present, all applicable defaults will be provided.
|
|
460
|
-
* If absent, only defaults produced by a {@link ConstantFieldProvider} will be provided, and defaults produced by a {@link ContextualFieldProvider} will be ignored.
|
|
461
|
-
* @remarks This function mutates the input tree by deeply adding new fields to the field maps where applicable.
|
|
462
|
-
*/
|
|
463
|
-
function addDefaultsToMapTree(mapTree, allowedTypes, context) {
|
|
464
|
-
const schema = (0, index_js_3.find)((0, schemaTypes_js_1.normalizeAllowedTypes)(allowedTypes), (s) => s.identifier === mapTree.type) ??
|
|
465
|
-
(0, internal_1.fail)(0xae1 /* MapTree is incompatible with schema */);
|
|
466
|
-
if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema)) {
|
|
467
|
-
for (const [_key, fieldInfo] of schema.flexKeyMap) {
|
|
468
|
-
const field = mapTree.fields.get(fieldInfo.storedKey);
|
|
469
|
-
if (field !== undefined) {
|
|
470
|
-
for (const child of field) {
|
|
471
|
-
addDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
const defaultProvider = fieldInfo.schema.props?.defaultProvider;
|
|
476
|
-
if (defaultProvider !== undefined) {
|
|
477
|
-
const fieldProvider = (0, schemaTypes_js_1.extractFieldProvider)(defaultProvider);
|
|
478
|
-
const data = provideDefault(fieldProvider, context);
|
|
479
|
-
if (data !== undefined) {
|
|
480
|
-
setFieldValue(mapTree.fields, data, fieldInfo.schema, fieldInfo.storedKey);
|
|
481
|
-
// call addDefaultsToMapTree on newly inserted default values
|
|
482
|
-
for (const child of mapTree.fields.get(fieldInfo.storedKey) ??
|
|
483
|
-
(0, internal_1.fail)(0xae2 /* Expected field to be populated */)) {
|
|
484
|
-
addDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
switch (schema.kind) {
|
|
493
|
-
case index_js_4.NodeKind.Array:
|
|
494
|
-
case index_js_4.NodeKind.Map:
|
|
495
|
-
{
|
|
496
|
-
for (const field of mapTree.fields.values()) {
|
|
497
|
-
for (const child of field) {
|
|
498
|
-
addDefaultsToMapTree(child, schema.info, context);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
break;
|
|
503
|
-
default:
|
|
504
|
-
(0, internal_1.assert)(schema.kind === index_js_4.NodeKind.Leaf, 0x989 /* Unrecognized schema kind */);
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
exports.addDefaultsToMapTree = addDefaultsToMapTree;
|
|
509
|
-
/**
|
|
510
|
-
* Provides the default value (which can be undefined, for example with optional fields), or undefined if a context is required but not provided.
|
|
511
|
-
* @privateRemarks
|
|
512
|
-
* It is a bit concerning that there is no way for the caller to know when undefined is returned if that is the default value, or a context was required.
|
|
513
|
-
* TODO: maybe better formalize the two stage defaulting (without then with context), or rework this design we only do one stage.
|
|
514
|
-
*/
|
|
515
|
-
function provideDefault(fieldProvider, context) {
|
|
516
|
-
if (context !== undefined) {
|
|
517
|
-
return fieldProvider(context);
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
if ((0, schemaTypes_js_1.isConstant)(fieldProvider)) {
|
|
521
|
-
return fieldProvider();
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
// Leaving field empty despite it needing a default value since a context was required and none was provided.
|
|
525
|
-
// Caller better handle this case by providing the default at some other point in time when the context becomes known.
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.
|
|
531
|
-
* @remarks
|
|
532
|
-
* If `target` is a unhydrated node, returns its MapTreeNode.
|
|
533
|
-
* If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.
|
|
534
|
-
* If the target is not a node, or a marinated node with no FlexTreeNode for its anchor, returns undefined.
|
|
535
|
-
*/
|
|
536
|
-
function tryGetInnerNode(target) {
|
|
537
|
-
if ((0, index_js_4.isTreeNode)(target)) {
|
|
538
|
-
return (0, index_js_4.getKernel)(target).tryGetInnerNode();
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
//# sourceMappingURL=toMapTree.js.map
|
|
459
|
+
//# sourceMappingURL=unhydratedFlexTreeFromInsertable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AACpF,u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BAA4B,CAAC,CAAC;IAEvE,oFAAoF;IACpF,gFAAgF;IAChF,+FAA+F;IAC/F,8IAA8I;IAE9I,qIAAqI;IAErI,wFAAwF;IACxF,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACrD,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;YAC/B,IAAI,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,SAAS,EAAE,CAAC;gBACpD,OAAO,kBAAkB,CAAC,IAAI,CAAC;YAChC,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,MAAsB,EAAE,KAAgB;IAC5D,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAA,4BAAiB,EAAC,MAAM,CAAC,IAAmB,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tEmptyKey,\n\ttype FieldKey,\n\ttype NodeData,\n\ttype TreeValue,\n\ttype ValueSchema,\n} from \"../core/index.js\";\nimport { FieldKinds, isTreeValue, valueSchemaAllows } from \"../feature-libraries/index.js\";\nimport { brand, isReadonlyArray, hasSingle } from \"../util/index.js\";\n\nimport { nullSchema } from \"./leafNodeSchema.js\";\nimport {\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\tisConstant,\n\ttype ImplicitFieldSchema,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype TreeLeafValue,\n\textractFieldProvider,\n\ttype ContextualFieldProvider,\n} from \"./schemaTypes.js\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\tNodeKind,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n\tUnhydratedSequenceField,\n} from \"./core/index.js\";\n// Required to prevent the introduction of new circular dependencies\n// TODO: Having the schema provide their own policy functions for compatibility which\n// unhydratedFlexTreeFromInsertable invokes instead of manually handling each kind would remove this bad\n// dependency, and reduce coupling.\n// eslint-disable-next-line import/no-internal-modules\nimport { isObjectNodeSchema } from \"./node-kinds/object/objectNodeTypes.js\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n// eslint-disable-next-line import/no-internal-modules\nimport { createField, type UnhydratedFlexTreeField } from \"./core/unhydratedFlexTree.js\";\nimport { convertFieldKind } from \"./toStoredSchema.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Module notes:\n *\n * The flow of the below code is in terms of the structure of the input data. We then verify that the associated\n * schema is appropriate for that kind of data. This is fine while we have a 1:1 mapping of kind of input data to\n * the kind of schema we expect for it (e.g. an input that is an array always need to be associated with a sequence in\n * the schema). If/when we begin accepting kinds of input data that are ambiguous (e.g. accepting an input that is an\n * array of key/value tuples to instantiate a map) we may need to rethink the structure here to be based more on the\n * schema than on the input data.\n */\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nfunction unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\n\tlet result: FlexContent;\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\tresult = leafToFlexContent(data, schema, allowedTypes);\n\t\t\tbreak;\n\t\tcase NodeKind.Array:\n\t\t\tresult = arrayToFlexContent(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Map:\n\t\t\tresult = mapToFlexContent(data, schema);\n\t\t\tbreak;\n\t\tcase NodeKind.Object:\n\t\t\tresult = objectToFlexContent(data, schema);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tunreachableCase(schema.kind);\n\t}\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(schema));\n}\n\ntype FlexContent = [NodeData, Map<FieldKey, UnhydratedFlexTreeField>];\n\n/**\n * Transforms data under a Leaf schema.\n * @param data - The tree data to be transformed. Must be a {@link TreeValue}.\n * @param schema - The schema associated with the value.\n * @param allowedTypes - The allowed types specified by the parent.\n * Used to determine which fallback values may be appropriate.\n */\nfunction leafToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): FlexContent {\n\tassert(schema.kind === NodeKind.Leaf, 0x921 /* Expected a leaf schema. */);\n\tif (!isTreeValue(data)) {\n\t\t// This rule exists to protect against useless `toString` output like `[object Object]`.\n\t\t// In this case, that's actually reasonable behavior, since object input is not compatible with Leaf schemas.\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with leaf schema: ${data}`);\n\t}\n\n\tconst mappedValue = mapValueWithFallbacks(data, allowedTypes);\n\tconst mappedSchema = getType(mappedValue, allowedTypes);\n\n\tassert(\n\t\tallowsValue(mappedSchema, mappedValue),\n\t\t0x84a /* Unsupported schema for provided primitive. */,\n\t);\n\n\treturn [\n\t\t{\n\t\t\tvalue: mappedValue,\n\t\t\ttype: brand(mappedSchema.identifier),\n\t\t},\n\t\tnew Map<FieldKey, UnhydratedFlexTreeField>(),\n\t];\n}\n\n/**\n * Checks an incoming {@link TreeLeafValue} to ensure it is compatible with its requirements.\n * For unsupported values with a schema-compatible replacement, return the replacement value.\n * For unsupported values without a schema-compatible replacement, throw.\n * For supported values, return the input.\n */\nfunction mapValueWithFallbacks(\n\tvalue: TreeLeafValue,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeValue {\n\tswitch (typeof value) {\n\t\tcase \"number\": {\n\t\t\tif (Object.is(value, -0)) {\n\t\t\t\t// Our serialized data format does not support -0.\n\t\t\t\t// Map such input to +0.\n\t\t\t\treturn 0;\n\t\t\t} else if (!Number.isFinite(value)) {\n\t\t\t\t// Our serialized data format does not support NaN nor +/-∞.\n\t\t\t\t// If the schema supports `null`, fall back to that. Otherwise, throw.\n\t\t\t\t// This is intended to match JSON's behavior for such values.\n\t\t\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new UsageError(`Received unsupported numeric value: ${value}.`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tcase \"string\":\n\t\t// TODO:\n\t\t// This should detect invalid strings. Something like @stdlib/regexp-utf16-unpaired-surrogate could be used to do this.\n\t\t// See SchemaFactory.string for details.\n\t\tcase \"boolean\":\n\t\t\treturn value;\n\t\tcase \"object\": {\n\t\t\tif (value === null || isFluidHandle(value)) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new UsageError(`Received unsupported leaf value: ${value}.`);\n\t}\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed.\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n */\nfunction arrayChildToFlexTree(\n\tchild: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\t// We do not support undefined sequence entries.\n\t// If we encounter an undefined entry, use null instead if supported by the schema, otherwise throw.\n\tlet childWithFallback = child;\n\tif (child === undefined) {\n\t\tif (allowedTypes.has(nullSchema)) {\n\t\t\tchildWithFallback = null;\n\t\t} else {\n\t\t\tthrow new TypeError(`Received unsupported array entry value: ${child}.`);\n\t\t}\n\t}\n\treturn unhydratedFlexTreeFromInsertableNode(childWithFallback, allowedTypes);\n}\n\n/**\n * Transforms data under an Array schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n */\nfunction arrayToFlexContent(data: FactoryContent, schema: TreeNodeSchema): FlexContent {\n\tassert(schema.kind === NodeKind.Array, 0x922 /* Expected an array schema. */);\n\tif (!(typeof data === \"object\" && data !== null && Symbol.iterator in data)) {\n\t\tthrow new UsageError(`Input data is incompatible with Array schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst mappedData = Array.from(data, (child) =>\n\t\tarrayChildToFlexTree(child, allowedChildTypes),\n\t);\n\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\t// Array nodes have a single `EmptyKey` field:\n\tconst fieldsEntries =\n\t\tmappedData.length === 0\n\t\t\t? []\n\t\t\t: ([\n\t\t\t\t\t[\n\t\t\t\t\t\tEmptyKey,\n\t\t\t\t\t\tnew UnhydratedSequenceField(\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tFieldKinds.sequence.identifier,\n\t\t\t\t\t\t\tEmptyKey,\n\t\t\t\t\t\t\tmappedData,\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t] as const);\n\n\treturn [\n\t\t{\n\t\t\ttype: brand(schema.identifier),\n\t\t},\n\t\tnew Map(fieldsEntries),\n\t];\n}\n\n/**\n * Transforms data under a Map schema.\n * @param data - The tree data to be transformed. Must be an iterable.\n * @param schema - The schema associated with the value.\n */\nfunction mapToFlexContent(data: FactoryContent, schema: TreeNodeSchema): FlexContent {\n\tassert(schema.kind === NodeKind.Map, 0x923 /* Expected a Map schema. */);\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Map schema: ${data}`);\n\t}\n\n\tconst allowedChildTypes = normalizeAllowedTypes(schema.info as ImplicitAllowedTypes);\n\n\tconst fieldsIterator = (\n\t\tSymbol.iterator in data\n\t\t\t? // Support iterables of key value pairs (including Map objects)\n\t\t\t\tdata\n\t\t\t: // Support record objects for JSON style Map data\n\t\t\t\tObject.entries(data)\n\t) as Iterable<readonly [string, InsertableContent]>;\n\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tconst transformedFields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tfor (const item of fieldsIterator) {\n\t\tif (!isReadonlyArray(item) || item.length !== 2 || typeof item[0] !== \"string\") {\n\t\t\tthrow new UsageError(`Input data is incompatible with map entry: ${item}`);\n\t\t}\n\t\tconst [key, value] = item;\n\t\tassert(!transformedFields.has(brand(key)), 0x84c /* Keys should not be duplicated */);\n\n\t\t// Omit undefined values - an entry with an undefined value is equivalent to one that has been removed or omitted\n\t\tif (value !== undefined) {\n\t\t\tconst child = unhydratedFlexTreeFromInsertableNode(value, allowedChildTypes);\n\t\t\tconst field = createField(context, FieldKinds.optional.identifier, brand(key), [child]);\n\t\t\ttransformedFields.set(brand(key), field);\n\t\t}\n\t}\n\n\treturn [\n\t\t{\n\t\t\ttype: brand(schema.identifier),\n\t\t},\n\t\ttransformedFields,\n\t];\n}\n\n/**\n * Transforms data under an Object schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema associated with the value.\n */\nfunction objectToFlexContent(data: FactoryContent, schema: TreeNodeSchema): FlexContent {\n\tassert(isObjectNodeSchema(schema), 0x924 /* Expected an Object schema. */);\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst level = shallowCompatibilityTest(schema, data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Indicates a compatibility level for inferring a schema to apply to insertable data.\n * @remarks\n * Only the highest compatibility options are used.\n * This approach allows adding new possible matching at a new lower compatibility level as a non breaking change,\n * since that way they can't make a case that was compatible before ambiguous now.\n */\nenum CompatibilityLevel {\n\t/**\n\t * Not compatible. Constructor typing indicates incompatibility.\n\t */\n\tNone = 0,\n\t/**\n\t * Additional compatibility cases added in Fluid Framework 2.2.\n\t */\n\tLow = 1,\n\t/**\n\t * Compatible in Fluid Framework 2.0.\n\t */\n\tNormal = 2,\n}\n\n/**\n * Checks if data might be schema-compatible.\n *\n * @returns false if `data` is incompatible with `type` based on a cheap/shallow check.\n *\n * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.\n */\nfunction shallowCompatibilityTest(\n\tschema: TreeNodeSchema,\n\tdata: FactoryContent,\n): CompatibilityLevel {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tif (isTreeValue(data)) {\n\t\treturn allowsValue(schema, data) ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// Typing (of schema based constructors and thus implicit node construction)\n\t// allows iterables for constructing maps and arrays.\n\t// Some users of this API may have unions of maps and arrays,\n\t// and rely on Arrays ending up as array nodes and maps as Map nodes,\n\t// despite both being iterable and thus compatible with both.\n\t// This uses a priority based system where an array would be parsed as an array when unioned with a map,\n\t// but if in a map only context, could still be used as a map.\n\n\tif (data instanceof Map) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Array:\n\t\t\t\t// Maps are iterable, so type checking does allow constructing an ArrayNode from a map if the array's type is an array that includes the key and value types of the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tif (isReadonlyArray(data)) {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn CompatibilityLevel.Normal;\n\t\t\tcase NodeKind.Map:\n\t\t\t\t// Arrays are iterable, so type checking does allow constructing an array from a MapNode from an if the array's type is key values pairs for the map.\n\t\t\t\treturn CompatibilityLevel.Low;\n\t\t\tdefault:\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\tconst mapOrArray = schema.kind === NodeKind.Array || schema.kind === NodeKind.Map;\n\n\tif (Symbol.iterator in data) {\n\t\treturn mapOrArray ? CompatibilityLevel.Normal : CompatibilityLevel.None;\n\t}\n\n\t// At this point, it is assumed data is a record-like object since all the other cases have been eliminated.\n\n\tif (schema.kind === NodeKind.Array) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (schema.kind === NodeKind.Map) {\n\t\t// When not unioned with an ObjectNode, allow objects to be used to create maps.\n\t\treturn CompatibilityLevel.Low;\n\t}\n\n\tassert(isObjectNodeSchema(schema), 0x9e6 /* unexpected schema kind */);\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue) {\n\t\t\tif (getFieldProperty(data, fieldKey) === undefined) {\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\nfunction allowsValue(schema: TreeNodeSchema, value: TreeValue): boolean {\n\tif (schema.kind === NodeKind.Leaf) {\n\t\treturn valueSchemaAllows(schema.info as ValueSchema, value);\n\t}\n\treturn false;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAGtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAGtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa,EAAE,YAAY;CAAG;AAgDnE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CASpD"}
|
package/dist/treeFactory.js
CHANGED
|
@@ -10,6 +10,7 @@ const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
|
10
10
|
const index_js_1 = require("./shared-tree/index.js");
|
|
11
11
|
const sharedTreeAttributes_js_1 = require("./sharedTreeAttributes.js");
|
|
12
12
|
const index_js_2 = require("./util/index.js");
|
|
13
|
+
const index_js_3 = require("./codec/index.js");
|
|
13
14
|
/**
|
|
14
15
|
* Creates a factory for shared tree kernels with the given options.
|
|
15
16
|
* @remarks
|
|
@@ -21,7 +22,11 @@ function treeKernelFactory(options) {
|
|
|
21
22
|
if (args.idCompressor === undefined) {
|
|
22
23
|
throw new internal_2.UsageError("IdCompressor must be enabled to use SharedTree");
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
const adjustedOptions = { ...options };
|
|
26
|
+
// TODO: get default from runtime once something like runtime.oldestCompatibleClient exists.
|
|
27
|
+
// Using default of 2.0 since that is the oldest version that supports SharedTree.
|
|
28
|
+
adjustedOptions.oldestCompatibleClient ??= index_js_3.FluidClientVersion.v2_0;
|
|
29
|
+
return new index_js_1.SharedTreeKernel(new index_js_2.Breakable("SharedTree"), args.sharedObject, args.serializer, args.submitLocalMessage, args.lastSequenceNumber, args.logger, args.idCompressor, adjustedOptions);
|
|
25
30
|
}
|
|
26
31
|
return {
|
|
27
32
|
create: (args) => {
|
package/dist/treeFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0EAQqD;AACrD,uEAAsE;AAEtE,qDAMgC;AAChC,uEAAwF;AAExF,8CAA4C;
|
|
1
|
+
{"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0EAQqD;AACrD,uEAAsE;AAEtE,qDAMgC;AAChC,uEAAwF;AAExF,8CAA4C;AAC5C,+CAAsD;AAStD;;;;;GAKG;AACH,SAAS,iBAAiB,CACzB,OAAkC;IAElC,SAAS,kBAAkB,CAAC,IAAgB;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,qBAA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AAC;IAEF,OAAO,IAAA,+BAAoB,EAAQ,mBAAmB,CAAC,CAAC;AACzD,CAAC;AAXD,oDAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable } from \"./util/index.js\";\nimport { FluidClientVersion } from \"./codec/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\t\tconst adjustedOptions = { ...options };\n\t\t// TODO: get default from runtime once something like runtime.oldestCompatibleClient exists.\n\t\t// Using default of 2.0 since that is the oldest version that supports SharedTree.\n\t\tadjustedOptions.oldestCompatibleClient ??= FluidClientVersion.v2_0;\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy\n * @alpha\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing to opt into extra validation or see if opting out of some optimizations fixes an issue.\n * @example\n * ```typescript\n * import {\n * \tForestType,\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \ttypeboxValidator,\n * \t// eslint-disable-next-line import/no-internal-modules\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: typeboxValidator,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to limitations of API tagging preventing it from being both alpha and alpha+legacy.\n * TODO:\n * Expose Ajv validator for better error message quality somehow.\n * Maybe as part of a test utils or dev-tool package?\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n"]}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { addToNestedSet, type NestedSet, nestedSetContains } from "./nestedSet.j
|
|
|
10
10
|
export { type OffsetList, OffsetListFactory } from "./offsetList.js";
|
|
11
11
|
export type { areSafelyAssignable, Contravariant, Covariant, eitherIsAny, EnforceTypeCheckTests, Invariant, isAny, isAssignableTo, isStrictSubset, MakeNominal, requireFalse, requireTrue, requireAssignableTo, areOnlyKeys, } from "./typeCheck.js";
|
|
12
12
|
export { StackyIterator } from "./stackyIterator.js";
|
|
13
|
-
export { asMutable, balancedReduce, clone, compareSets, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, type Named, compareNamed, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, getLast, hasSome, hasSingle, defineLazyCachedProperty, copyPropertyIfDefined as copyProperty, getOrAddInMap, } from "./utils.js";
|
|
13
|
+
export { asMutable, balancedReduce, clone, compareSets, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromSet, type Named, compareNamed, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareStrings, find, count, getLast, hasSome, hasSingle, defineLazyCachedProperty, copyPropertyIfDefined as copyProperty, getOrAddInMap, iterableHasSome, } from "./utils.js";
|
|
14
14
|
export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
|
|
15
15
|
export type { _RecursiveTrick, RestrictiveReadonlyRecord, RestrictiveStringRecord, _InlineTrick, FlattenKeys, IsUnion, UnionToIntersection, UnionToTuple, PopUnion, } from "./typeUtils.js";
|
|
16
16
|
export { unsafeArrayToTuple } from "./typeUtils.js";
|
package/dist/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EACX,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACN,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,4BAA4B,EAC5B,SAAS,EACT,WAAW,EACX,cAAc,EACd,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,WAAW,EACX,SAAS,EACT,UAAU,EACV,KAAK,KAAK,EACV,YAAY,EACZ,aAAa,EACb,KAAK,WAAW,EAChB,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,wBAAwB,EACxB,qBAAqB,IAAI,YAAY,EACrC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM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