@fluidframework/tree 2.40.0-336023 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/api-report/tree.alpha.api.md +4 -1
- package/dist/alpha.d.ts +1 -0
- package/dist/codec/codec.d.ts +5 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +6 -2
- 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 +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
- package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/dist/core/schema-stored/formatV1.js.map +1 -0
- package/dist/core/schema-stored/index.d.ts +3 -3
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +3 -3
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +3 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +8 -6
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/dist/core/schema-view/index.d.ts +1 -1
- package/dist/core/schema-view/index.d.ts.map +1 -1
- package/dist/core/schema-view/index.js +1 -2
- package/dist/core/schema-view/index.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -27
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js +1 -35
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js +1 -1
- package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/format.js +1 -1
- package/dist/feature-libraries/forest-summary/format.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- 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 +3 -3
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +2 -2
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +63 -9
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
- package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +6 -3
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +8 -9
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +9 -33
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -4
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +28 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +29 -3
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/tree.d.ts +24 -0
- package/dist/shared-tree/tree.d.ts.map +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +2 -0
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +3 -2
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +4 -1
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +9 -0
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +7 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +8 -7
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +13 -9
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +25 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +4 -1
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/dist/simple-tree/api/treeChangeEvents.js +7 -0
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +28 -0
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +5 -5
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +94 -0
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
- package/dist/simple-tree/core/treeNode.js +123 -0
- package/dist/simple-tree/core/treeNode.js.map +1 -0
- package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +0 -165
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js +1 -113
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +1 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +1 -0
- 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 +8 -8
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +27 -32
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +302 -83
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +299 -57
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +30 -75
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +1 -0
- package/lib/codec/codec.d.ts +5 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +5 -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 +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
- package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
- package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
- package/lib/core/schema-stored/formatV1.js.map +1 -0
- package/lib/core/schema-stored/index.d.ts +3 -3
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +2 -2
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +3 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
- package/lib/core/schema-view/index.d.ts +1 -1
- package/lib/core/schema-view/index.d.ts.map +1 -1
- package/lib/core/schema-view/index.js +1 -1
- package/lib/core/schema-view/index.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -27
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js +0 -34
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
- package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/persistedTreeTextFormat.js +2 -2
- package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
- package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/format.js +2 -2
- package/lib/feature-libraries/forest-summary/format.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- 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 +3 -3
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +2 -2
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +61 -9
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
- package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
- package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
- package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -2
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +8 -9
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +10 -34
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +2 -5
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +28 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +29 -4
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/tree.d.ts +24 -0
- package/lib/shared-tree/tree.d.ts.map +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +2 -0
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +4 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +4 -1
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -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 +9 -0
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +7 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +8 -7
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +17 -11
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +25 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +4 -1
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
- package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
- package/lib/simple-tree/api/treeChangeEvents.js +6 -0
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +28 -0
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +94 -0
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
- package/lib/simple-tree/core/treeNode.js +118 -0
- package/lib/simple-tree/core/treeNode.js.map +1 -0
- package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +0 -165
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js +0 -110
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +1 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +1 -0
- 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 +8 -8
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +26 -31
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +302 -83
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +299 -57
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +30 -75
- package/lib/treeFactory.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +6 -1
- package/src/codec/index.ts +1 -0
- package/src/core/index.ts +1 -2
- package/src/core/schema-stored/index.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -1
- package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -31
- package/src/core/tree/persistedTreeTextFormat.ts +2 -2
- package/src/feature-libraries/forest-summary/format.ts +2 -2
- package/src/feature-libraries/index.ts +7 -1
- package/src/feature-libraries/mapTreeCursor.ts +3 -3
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
- package/src/feature-libraries/schema-index/codec.ts +80 -12
- package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
- package/src/feature-libraries/schema-index/index.ts +7 -2
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +3 -2
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/schematizeTree.ts +5 -35
- package/src/shared-tree/schematizingTreeView.ts +2 -10
- package/src/shared-tree/sharedTree.ts +67 -6
- package/src/shared-tree/tree.ts +24 -0
- package/src/shared-tree/treeAlpha.ts +6 -3
- package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
- package/src/shared-tree-core/transactionEnricher.ts +4 -1
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +9 -0
- package/src/simple-tree/api/storedSchema.ts +24 -13
- package/src/simple-tree/api/tree.ts +25 -0
- package/src/simple-tree/api/treeBeta.ts +3 -1
- package/src/simple-tree/api/treeChangeEvents.ts +84 -0
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/arrayNode.ts +28 -0
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/index.ts +5 -4
- package/src/simple-tree/core/treeNode.ts +163 -0
- package/src/simple-tree/core/treeNodeKernel.ts +2 -1
- package/src/simple-tree/core/treeNodeSchema.ts +3 -1
- package/src/simple-tree/core/types.ts +0 -234
- package/src/simple-tree/core/withType.ts +1 -1
- package/src/simple-tree/index.ts +2 -1
- package/src/simple-tree/schemaTypes.ts +1 -0
- package/src/simple-tree/toStoredSchema.ts +42 -41
- package/src/tableSchema.ts +665 -197
- package/src/treeFactory.ts +56 -173
- package/dist/core/schema-stored/format.d.ts.map +0 -1
- package/dist/core/schema-stored/format.js.map +0 -1
- package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/dist/feature-libraries/schema-index/format.js.map +0 -1
- package/lib/core/schema-stored/format.d.ts.map +0 -1
- package/lib/core/schema-stored/format.js.map +0 -1
- package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
- package/lib/feature-libraries/schema-index/format.js.map +0 -1
- /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A collection of events that can be emitted by a {@link TreeNode}.
|
|
8
|
+
*
|
|
9
|
+
* @privateRemarks
|
|
10
|
+
* TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
|
|
11
|
+
* Probably have object node and map node specific APIs for this.
|
|
12
|
+
*
|
|
13
|
+
* TODO: ensure that subscription API for fields aligns with API for subscribing to the root.
|
|
14
|
+
*
|
|
15
|
+
* TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.
|
|
16
|
+
* Some ideas:
|
|
17
|
+
*
|
|
18
|
+
* - treeChanged, but with some subtrees/fields/paths excluded
|
|
19
|
+
* - helper to batch several nodeChanged calls to a treeChanged scope
|
|
20
|
+
* - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)
|
|
21
|
+
* - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.
|
|
22
|
+
* Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)
|
|
23
|
+
* to allow efficiently searching for new content (and initial content) of a given type.
|
|
24
|
+
*
|
|
25
|
+
* @sealed @public
|
|
26
|
+
*/
|
|
27
|
+
export interface TreeChangeEvents {
|
|
28
|
+
/**
|
|
29
|
+
* Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.
|
|
30
|
+
*
|
|
31
|
+
* - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).
|
|
32
|
+
*
|
|
33
|
+
* - Array nodes define a change as when an element is added, removed, moved or replaced.
|
|
34
|
+
*
|
|
35
|
+
* - Map nodes define a change as when an entry is added, updated, or removed.
|
|
36
|
+
*
|
|
37
|
+
* @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.
|
|
38
|
+
* users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.
|
|
39
|
+
* This parameter exists to capture this fact in the type system.
|
|
40
|
+
* Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* This event is not emitted when:
|
|
44
|
+
*
|
|
45
|
+
* - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing
|
|
46
|
+
* elements/entries) will emit this event on the array/map node itself, but not on the node that contains the
|
|
47
|
+
* array/map node as one of its properties.
|
|
48
|
+
*
|
|
49
|
+
* - The node is moved to a different location in the tree or removed from the tree.
|
|
50
|
+
* In this case the event is emitted on the _parent_ node, not the node itself.
|
|
51
|
+
*
|
|
52
|
+
* For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
|
|
53
|
+
* the client that made the original edit.
|
|
54
|
+
*
|
|
55
|
+
* When the event is emitted, the tree is guaranteed to be in-schema.
|
|
56
|
+
*
|
|
57
|
+
* @privateRemarks
|
|
58
|
+
* This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.
|
|
59
|
+
* For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the
|
|
60
|
+
* node, or when the node has to be updated due to resolution of a merge conflict
|
|
61
|
+
* (for example a previously applied local change might be undone, then reapplied differently or not at all).
|
|
62
|
+
*
|
|
63
|
+
* TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).
|
|
64
|
+
*/
|
|
65
|
+
nodeChanged(unstable?: unknown): void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the
|
|
69
|
+
* subtree rooted at it.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.
|
|
73
|
+
* In that case it is emitted on the _parent_ node, not the node itself.
|
|
74
|
+
*
|
|
75
|
+
* The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties
|
|
76
|
+
* of the node itself.
|
|
77
|
+
*
|
|
78
|
+
* For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
|
|
79
|
+
* the client that made the original edit.
|
|
80
|
+
*
|
|
81
|
+
* When it is emitted, the tree is guaranteed to be in-schema.
|
|
82
|
+
*/
|
|
83
|
+
treeChanged(): void;
|
|
84
|
+
}
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
type TreeNodeSchema,
|
|
33
33
|
NodeKind,
|
|
34
34
|
type TreeNode,
|
|
35
|
-
type TreeChangeEvents,
|
|
36
35
|
tryGetTreeNodeSchema,
|
|
37
36
|
getOrCreateNodeFromInnerNode,
|
|
38
37
|
UnhydratedFlexTreeNode,
|
|
@@ -40,6 +39,7 @@ import {
|
|
|
40
39
|
getOrCreateInnerNode,
|
|
41
40
|
} from "../core/index.js";
|
|
42
41
|
import { isObjectNodeSchema } from "../objectNodeTypes.js";
|
|
42
|
+
import type { TreeChangeEvents } from "./treeChangeEvents.js";
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Provides various functions for analyzing {@link TreeNode}s.
|
|
@@ -173,8 +173,11 @@ export interface TreeArrayNode<
|
|
|
173
173
|
* For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
|
|
174
174
|
*
|
|
175
175
|
* - `0` (between the start of the array and `A`'s original position)
|
|
176
|
+
*
|
|
176
177
|
* - `1` (between `A`'s original position and `B`'s original position)
|
|
178
|
+
*
|
|
177
179
|
* - `2` (between `B`'s original position and `C`'s original position)
|
|
180
|
+
*
|
|
178
181
|
* - `3` (between `C`'s original position and the end of the array)
|
|
179
182
|
*
|
|
180
183
|
* So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
|
|
@@ -183,13 +186,17 @@ export interface TreeArrayNode<
|
|
|
183
186
|
* or relative to the start or end of the array:
|
|
184
187
|
*
|
|
185
188
|
* - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
|
|
189
|
+
*
|
|
186
190
|
* - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
|
|
191
|
+
*
|
|
187
192
|
* - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
|
|
193
|
+
*
|
|
188
194
|
* - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
|
|
189
195
|
*
|
|
190
196
|
* This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
|
|
191
197
|
*
|
|
192
198
|
* - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
|
|
199
|
+
*
|
|
193
200
|
* - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
|
|
194
201
|
*
|
|
195
202
|
* Notice the asymmetry between `-1` and `+2` in the above examples.
|
|
@@ -215,8 +222,11 @@ export interface TreeArrayNode<
|
|
|
215
222
|
* For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
|
|
216
223
|
*
|
|
217
224
|
* - `0` (between the start of the array and `A`'s original position)
|
|
225
|
+
*
|
|
218
226
|
* - `1` (between `A`'s original position and `B`'s original position)
|
|
227
|
+
*
|
|
219
228
|
* - `2` (between `B`'s original position and `C`'s original position)
|
|
229
|
+
*
|
|
220
230
|
* - `3` (between `C`'s original position and the end of the array)
|
|
221
231
|
*
|
|
222
232
|
* So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
|
|
@@ -225,13 +235,17 @@ export interface TreeArrayNode<
|
|
|
225
235
|
* or relative to the start or end of the array:
|
|
226
236
|
*
|
|
227
237
|
* - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
|
|
238
|
+
*
|
|
228
239
|
* - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
|
|
240
|
+
*
|
|
229
241
|
* - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
|
|
242
|
+
*
|
|
230
243
|
* - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
|
|
231
244
|
*
|
|
232
245
|
* This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
|
|
233
246
|
*
|
|
234
247
|
* - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
|
|
248
|
+
*
|
|
235
249
|
* - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
|
|
236
250
|
*
|
|
237
251
|
* Notice the asymmetry between `-1` and `+2` in the above examples.
|
|
@@ -299,8 +313,11 @@ export interface TreeArrayNode<
|
|
|
299
313
|
* For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
|
|
300
314
|
*
|
|
301
315
|
* - `0` (between the start of the array and `A`'s original position)
|
|
316
|
+
*
|
|
302
317
|
* - `1` (between `A`'s original position and `B`'s original position)
|
|
318
|
+
*
|
|
303
319
|
* - `2` (between `B`'s original position and `C`'s original position)
|
|
320
|
+
*
|
|
304
321
|
* - `3` (between `C`'s original position and the end of the array)
|
|
305
322
|
*
|
|
306
323
|
* So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
|
|
@@ -309,13 +326,17 @@ export interface TreeArrayNode<
|
|
|
309
326
|
* or relative to the start or end of the array:
|
|
310
327
|
*
|
|
311
328
|
* - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
|
|
329
|
+
*
|
|
312
330
|
* - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
|
|
331
|
+
*
|
|
313
332
|
* - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
|
|
333
|
+
*
|
|
314
334
|
* - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
|
|
315
335
|
*
|
|
316
336
|
* This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
|
|
317
337
|
*
|
|
318
338
|
* - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
|
|
339
|
+
*
|
|
319
340
|
* - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
|
|
320
341
|
*
|
|
321
342
|
* Notice the asymmetry between `-1` and `+2` in the above examples.
|
|
@@ -343,8 +364,11 @@ export interface TreeArrayNode<
|
|
|
343
364
|
* For example, if the array contains items `[A, B, C]` before the move, the `destinationGap` must be one of the following:
|
|
344
365
|
*
|
|
345
366
|
* - `0` (between the start of the array and `A`'s original position)
|
|
367
|
+
*
|
|
346
368
|
* - `1` (between `A`'s original position and `B`'s original position)
|
|
369
|
+
*
|
|
347
370
|
* - `2` (between `B`'s original position and `C`'s original position)
|
|
371
|
+
*
|
|
348
372
|
* - `3` (between `C`'s original position and the end of the array)
|
|
349
373
|
*
|
|
350
374
|
* So moving `A` between `B` and `C` would require `destinationGap` to be `2`.
|
|
@@ -353,13 +377,17 @@ export interface TreeArrayNode<
|
|
|
353
377
|
* or relative to the start or end of the array:
|
|
354
378
|
*
|
|
355
379
|
* - Move to the start of the array: `array.moveToIndex(0, ...)` (see also `moveToStart`)
|
|
380
|
+
*
|
|
356
381
|
* - Move to before some item X: `array.moveToIndex(indexOfX, ...)`
|
|
382
|
+
*
|
|
357
383
|
* - Move to after some item X: `array.moveToIndex(indexOfX + 1`, ...)
|
|
384
|
+
*
|
|
358
385
|
* - Move to the end of the array: `array.moveToIndex(array.length, ...)` (see also `moveToEnd`)
|
|
359
386
|
*
|
|
360
387
|
* This interpretation of `destinationGap` does however make it less obvious how to move an item relative to its current position:
|
|
361
388
|
*
|
|
362
389
|
* - Move item B before its predecessor: `array.moveToIndex(indexOfB - 1, ...)`
|
|
390
|
+
*
|
|
363
391
|
* - Move item B after its successor: `array.moveToIndex(indexOfB + 2, ...)`
|
|
364
392
|
*
|
|
365
393
|
* Notice the asymmetry between `-1` and `+2` in the above examples.
|
|
@@ -17,13 +17,14 @@ export {
|
|
|
17
17
|
} from "./treeNodeKernel.js";
|
|
18
18
|
export { type WithType, typeNameSymbol, typeSchemaSymbol } from "./withType.js";
|
|
19
19
|
export {
|
|
20
|
-
type TreeChangeEvents,
|
|
21
|
-
TreeNode,
|
|
22
20
|
type Unhydrated,
|
|
23
|
-
inPrototypeChain,
|
|
24
21
|
type InternalTreeNode,
|
|
25
|
-
privateToken,
|
|
26
22
|
} from "./types.js";
|
|
23
|
+
export {
|
|
24
|
+
TreeNode,
|
|
25
|
+
privateToken,
|
|
26
|
+
inPrototypeChain,
|
|
27
|
+
} from "./treeNode.js";
|
|
27
28
|
export {
|
|
28
29
|
type TreeNodeSchema,
|
|
29
30
|
NodeKind,
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
|
|
9
|
+
import { NodeKind, type TreeNodeSchemaClass } from "./treeNodeSchema.js";
|
|
10
|
+
// eslint-disable-next-line import/no-deprecated
|
|
11
|
+
import { type WithType, typeNameSymbol, type typeSchemaSymbol } from "./withType.js";
|
|
12
|
+
import { tryGetTreeNodeSchema } from "./treeNodeKernel.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Base type which all nodes extend.
|
|
19
|
+
*
|
|
20
|
+
* This type can be used as a type to indicate/document values which should be tree nodes.
|
|
21
|
+
* Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.
|
|
22
|
+
*
|
|
23
|
+
* There are three ways to get instances of TreeNode:
|
|
24
|
+
*
|
|
25
|
+
* 1. From a {@link TreeView} loading nodes from an existing document, or creating local copies of nodes inserted by a remote collaborator.
|
|
26
|
+
* This case provides an {@link InternalTreeNode} to the constructor: subclasses must not modify how the constructor handles this case.
|
|
27
|
+
*
|
|
28
|
+
* 2. Explicit construction of {@link Unhydrated} nodes using either {@link TreeNodeSchemaClass} as a constructor or {@link TreeNodeSchemaNonClass|TreeNodeSchemaNonClass.create}.
|
|
29
|
+
* Either way the {@link TreeNodeSchema} produced must be produced using a {@link SchemaFactory}.
|
|
30
|
+
*
|
|
31
|
+
* 3. Implicit construction: Several APIs which logically require an unhydrated TreeNode also allow passing in a value which could be used to explicitly construct the node instead.
|
|
32
|
+
* These APIs internally call the constructor with the provided value, so it's really just a special case of the above option.
|
|
33
|
+
* Note that when constructing nodes, sometimes implicit construction is not allowed
|
|
34
|
+
* (either at runtime due to ambiguous types or at compile time due to TypeScript limitations):
|
|
35
|
+
* in such cases, explicit construction must be used.
|
|
36
|
+
*
|
|
37
|
+
* @privateRemarks
|
|
38
|
+
* This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})
|
|
39
|
+
* and some runtime enforcement of schema class policy (see the the validation in the constructor).
|
|
40
|
+
* This class is however only `type` exported not value exported, preventing the class object from being used,
|
|
41
|
+
* similar to how interfaces work.
|
|
42
|
+
*
|
|
43
|
+
* Not all node implementations include this in their prototype chain (some hide it with a proxy),
|
|
44
|
+
* and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.
|
|
45
|
+
* This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.
|
|
46
|
+
* For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).
|
|
47
|
+
* @sealed @public
|
|
48
|
+
*/
|
|
49
|
+
export abstract class TreeNode implements WithType {
|
|
50
|
+
/**
|
|
51
|
+
* This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.
|
|
52
|
+
* @remarks
|
|
53
|
+
* This field forces TypeScript to use nominal instead of structural typing,
|
|
54
|
+
* preventing compiler error messages and tools like "add missing properties"
|
|
55
|
+
* from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.
|
|
56
|
+
* Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.
|
|
57
|
+
*
|
|
58
|
+
* @privateRemarks
|
|
59
|
+
* This is a JavaScript private field, so is not accessible from outside this class.
|
|
60
|
+
* This prevents it from having name collisions with object fields.
|
|
61
|
+
* Since this is private, the type of this field is stripped in the d.ts file.
|
|
62
|
+
* To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.
|
|
63
|
+
* To avoid this having any runtime impact, the field is uninitialized.
|
|
64
|
+
*
|
|
65
|
+
* Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.
|
|
66
|
+
* This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.
|
|
67
|
+
* To avoid all this mess, this field is required, not optional.
|
|
68
|
+
*
|
|
69
|
+
* Another option would be to use a symbol (possibly as a private field).
|
|
70
|
+
* That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.
|
|
71
|
+
*
|
|
72
|
+
* The [type] symbol provides a lot of the value this private brand does, but is not all of it:
|
|
73
|
+
* someone could manually (or via Intellisense auto-implement completion, or in response to a type error)
|
|
74
|
+
* make an object literal with the [type] field and pass it off as a node: this private brand prevents that.
|
|
75
|
+
*/
|
|
76
|
+
readonly #brand!: unknown;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Adds a type symbol for stronger typing.
|
|
80
|
+
* @privateRemarks
|
|
81
|
+
* Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
|
|
82
|
+
* @deprecated Use {@link typeSchemaSymbol} instead.
|
|
83
|
+
*/
|
|
84
|
+
// eslint-disable-next-line import/no-deprecated
|
|
85
|
+
public abstract get [typeNameSymbol](): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Adds a type symbol for stronger typing.
|
|
89
|
+
* @privateRemarks
|
|
90
|
+
* Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.
|
|
91
|
+
*/
|
|
92
|
+
public abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Provides `instanceof` support for testing if a value is a `TreeNode`.
|
|
96
|
+
* @remarks
|
|
97
|
+
* For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.
|
|
98
|
+
* @privateRemarks
|
|
99
|
+
* Due to type-only export, this functionality is not available outside the package.
|
|
100
|
+
*/
|
|
101
|
+
public static [Symbol.hasInstance](value: unknown): value is TreeNode;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Provides `instanceof` support for all schema classes with public constructors.
|
|
105
|
+
* @remarks
|
|
106
|
+
* For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.
|
|
107
|
+
* @privateRemarks
|
|
108
|
+
* Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.
|
|
109
|
+
*/
|
|
110
|
+
public static [Symbol.hasInstance]<
|
|
111
|
+
TSchema extends abstract new (
|
|
112
|
+
...args: any[]
|
|
113
|
+
) => TreeNode,
|
|
114
|
+
>(this: TSchema, value: unknown): value is InstanceType<TSchema>;
|
|
115
|
+
|
|
116
|
+
public static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {
|
|
117
|
+
const schema = tryGetTreeNodeSchema(value);
|
|
118
|
+
|
|
119
|
+
if (schema === undefined || schema.kind === NodeKind.Leaf) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
assert("prototype" in schema, 0x98a /* expected class based schema */);
|
|
124
|
+
return inPrototypeChain(schema.prototype, this.prototype);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.
|
|
129
|
+
* @privateRemarks
|
|
130
|
+
* `token` must be the {@link privateToken} value, which is not package exported.
|
|
131
|
+
* This is used to detect invalid subclasses.
|
|
132
|
+
*
|
|
133
|
+
* All valid subclass should use {@link TreeNodeValid}, but this code doesn't directly reference it to avoid cyclic dependencies.
|
|
134
|
+
*/
|
|
135
|
+
protected constructor(token: unknown) {
|
|
136
|
+
if (token !== privateToken) {
|
|
137
|
+
throw new UsageError("TreeNodes must extend schema classes created by SchemaFactory");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* `token` to pass to {@link TreeNode}'s constructor used to detect invalid subclasses.
|
|
144
|
+
*/
|
|
145
|
+
export const privateToken = {};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Check if the prototype derived's prototype chain contains `base`.
|
|
149
|
+
* @param derived - prototype to check
|
|
150
|
+
* @param base - prototype to search for
|
|
151
|
+
* @returns true iff `base` is in the prototype chain starting at `derived`.
|
|
152
|
+
*/
|
|
153
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
154
|
+
export function inPrototypeChain(derived: object | null, base: object): boolean {
|
|
155
|
+
let checking = derived;
|
|
156
|
+
while (checking !== null) {
|
|
157
|
+
if (base === checking) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
checking = Reflect.getPrototypeOf(checking);
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
@@ -7,7 +7,7 @@ import { assert, Lazy, fail, debugAssert } from "@fluidframework/core-utils/inte
|
|
|
7
7
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
import { createEmitter } from "@fluid-internal/client-utils";
|
|
9
9
|
import type { Listenable, Off } from "@fluidframework/core-interfaces";
|
|
10
|
-
import type { InternalTreeNode,
|
|
10
|
+
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
11
11
|
import {
|
|
12
12
|
anchorSlot,
|
|
13
13
|
type AnchorEvents,
|
|
@@ -31,6 +31,7 @@ import type { TreeNodeSchema } from "./treeNodeSchema.js";
|
|
|
31
31
|
import { makeTree } from "../../feature-libraries/flex-tree/lazyNode.js";
|
|
32
32
|
import { SimpleContextSlot, type Context, type HydratedContext } from "./context.js";
|
|
33
33
|
import { UnhydratedFlexTreeNode } from "./unhydratedFlexTree.js";
|
|
34
|
+
import type { TreeNode } from "./treeNode.js";
|
|
34
35
|
|
|
35
36
|
const treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();
|
|
36
37
|
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import type { TreeLeafValue } from "../schemaTypes.js";
|
|
7
7
|
import type { SimpleNodeSchemaBase } from "../simpleSchema.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { TreeNode } from "./treeNode.js";
|
|
9
|
+
import type { InternalTreeNode, Unhydrated } from "./types.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Schema for a {@link TreeNode} or {@link TreeLeafValue}.
|
|
@@ -136,6 +137,7 @@ export type TreeNodeSchemaNonClass<
|
|
|
136
137
|
* // If both get used, its an error!
|
|
137
138
|
* class Invalid extends base {}
|
|
138
139
|
* ```
|
|
140
|
+
*
|
|
139
141
|
* - Do not modify the constructor input parameter types or values:
|
|
140
142
|
* ```typescript
|
|
141
143
|
* class Invalid extends schemaFactory.object("A", {
|