@fluidframework/tree 2.42.0 → 2.43.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 +189 -0
- package/api-report/tree.alpha.api.md +72 -25
- package/api-report/tree.beta.api.md +34 -0
- package/api-report/tree.legacy.alpha.api.md +1 -0
- package/api-report/tree.legacy.public.api.md +1 -0
- package/api-report/tree.public.api.md +1 -0
- package/dist/alpha.d.ts +12 -6
- package/dist/beta.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/formatV2.d.ts +80 -0
- package/dist/core/schema-stored/formatV2.d.ts.map +1 -0
- package/dist/core/schema-stored/formatV2.js +55 -0
- package/dist/core/schema-stored/formatV2.js.map +1 -0
- package/dist/core/schema-stored/index.d.ts +3 -1
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js +5 -2
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +49 -17
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +65 -22
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +13 -9
- package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -6
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +1 -7
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -2
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +2 -5
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +15 -7
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -5
- 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 +1 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts +16 -2
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
- package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +2 -0
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +59 -9
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +42 -0
- package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
- package/dist/feature-libraries/schema-index/formatV2.js +26 -0
- package/dist/feature-libraries/schema-index/formatV2.js.map +1 -0
- package/dist/feature-libraries/schema-index/index.d.ts +2 -1
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +4 -2
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +6 -6
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +2 -2
- 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/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -0
- 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 +3 -3
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +5 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +34 -5
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +39 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +117 -11
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +8 -3
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +2 -5
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -7
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +15 -2
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +15 -3
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +40 -22
- package/dist/simple-tree/api/configuration.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 +4 -4
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +15 -11
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +31 -4
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.d.ts +8 -3
- package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
- package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +3 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/context.d.ts +3 -3
- package/dist/simple-tree/core/context.d.ts.map +1 -1
- package/dist/simple-tree/core/context.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts +9 -0
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +12 -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 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +2 -2
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +68 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js +24 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +12 -31
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +3 -3
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +9 -5
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +3 -3
- package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
- package/dist/simple-tree/index.d.ts +6 -6
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +8 -5
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +4 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +1 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +21 -16
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +11 -5
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +12 -7
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +5 -1
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +63 -30
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +73 -40
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +22 -4
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +4 -0
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +15 -4
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +1 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/walkFieldSchema.js +1 -1
- package/dist/simple-tree/walkFieldSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +1 -1
- package/dist/util/typeUtils.d.ts +2 -2
- package/dist/util/typeUtils.js.map +1 -1
- package/dist/util/utils.d.ts +2 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +12 -6
- package/lib/beta.d.ts +6 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/formatV2.d.ts +80 -0
- package/lib/core/schema-stored/formatV2.d.ts.map +1 -0
- package/lib/core/schema-stored/formatV2.js +52 -0
- package/lib/core/schema-stored/formatV2.js.map +1 -0
- package/lib/core/schema-stored/index.d.ts +3 -1
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +3 -1
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +49 -17
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +63 -21
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +11 -7
- package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -7
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +0 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -2
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +3 -6
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +15 -7
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -5
- 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 +16 -2
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
- package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +2 -0
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
- 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.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +60 -10
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +42 -0
- package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
- package/lib/feature-libraries/schema-index/formatV2.js +23 -0
- package/lib/feature-libraries/schema-index/formatV2.js.map +1 -0
- package/lib/feature-libraries/schema-index/index.d.ts +2 -1
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -1
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +6 -6
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +2 -2
- 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/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +1 -0
- 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 +4 -4
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +5 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +34 -5
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +39 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +111 -5
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +8 -3
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +2 -5
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -7
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +15 -2
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +15 -3
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +42 -24
- package/lib/simple-tree/api/configuration.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/schemaCompatibilityTester.js +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +15 -11
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +4 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +31 -4
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +2 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.d.ts +8 -3
- package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
- package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +3 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +2 -2
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/context.d.ts +3 -3
- package/lib/simple-tree/core/context.d.ts.map +1 -1
- package/lib/simple-tree/core/context.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts +9 -0
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +10 -0
- 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.js +2 -2
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +68 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js +21 -0
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +15 -34
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +3 -3
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +9 -5
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +1 -1
- package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
- package/lib/simple-tree/index.d.ts +6 -6
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +4 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +2 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +13 -8
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +14 -8
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +14 -9
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +5 -1
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +63 -30
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +70 -36
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +22 -4
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +4 -0
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +15 -4
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +1 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/walkFieldSchema.js +1 -1
- package/lib/simple-tree/walkFieldSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +1 -1
- package/lib/util/typeUtils.d.ts +2 -2
- package/lib/util/typeUtils.js.map +1 -1
- package/lib/util/utils.d.ts +2 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/core/index.ts +3 -1
- package/src/core/schema-stored/formatV2.ts +78 -0
- package/src/core/schema-stored/index.ts +4 -1
- package/src/core/schema-stored/schema.ts +123 -33
- package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +16 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -7
- package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +4 -4
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +9 -16
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +33 -30
- package/src/feature-libraries/flex-tree/index.ts +0 -8
- package/src/feature-libraries/flex-tree/lazyEntity.ts +5 -1
- package/src/feature-libraries/flex-tree/lazyField.ts +5 -8
- package/src/feature-libraries/flex-tree/lazyNode.ts +17 -8
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +9 -16
- package/src/feature-libraries/index.ts +1 -1
- package/src/feature-libraries/mapTreeCursor.ts +17 -8
- package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +2 -0
- package/src/feature-libraries/object-forest/objectForest.ts +3 -0
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +11 -6
- package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -3
- package/src/feature-libraries/schema-index/codec.ts +73 -14
- package/src/feature-libraries/schema-index/formatV2.ts +30 -0
- package/src/feature-libraries/schema-index/index.ts +2 -1
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +11 -18
- package/src/index.ts +6 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizeTree.ts +1 -0
- package/src/shared-tree/schematizingTreeView.ts +8 -5
- package/src/shared-tree/sharedTree.ts +42 -12
- package/src/shared-tree/treeAlpha.ts +196 -6
- package/src/shared-tree-core/editManagerSummarizer.ts +9 -16
- package/src/shared-tree-core/sharedTreeCore.ts +33 -24
- package/src/simple-tree/api/configuration.ts +59 -27
- package/src/simple-tree/api/index.ts +3 -3
- package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
- package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
- package/src/simple-tree/api/schemaFactory.ts +16 -11
- package/src/simple-tree/api/schemaFactoryAlpha.ts +53 -8
- package/src/simple-tree/api/storedSchema.ts +4 -4
- package/src/simple-tree/api/treeChangeEvents.ts +8 -3
- package/src/simple-tree/api/treeNodeApi.ts +5 -2
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +5 -0
- package/src/simple-tree/core/context.ts +3 -3
- package/src/simple-tree/core/getOrCreateNode.ts +14 -0
- package/src/simple-tree/core/index.ts +7 -1
- package/src/simple-tree/core/treeNodeKernel.ts +2 -2
- package/src/simple-tree/core/treeNodeSchema.ts +113 -1
- package/src/simple-tree/core/unhydratedFlexTree.ts +22 -44
- package/src/simple-tree/core/walkSchema.ts +16 -7
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/getTreeNodeForField.ts +3 -1
- package/src/simple-tree/index.ts +12 -5
- package/src/simple-tree/leafNodeSchema.ts +9 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +20 -9
- package/src/simple-tree/node-kinds/map/mapNode.ts +21 -6
- package/src/simple-tree/node-kinds/object/objectNode.ts +29 -12
- package/src/simple-tree/prepareForInsertion.ts +5 -1
- package/src/simple-tree/schemaTypes.ts +151 -71
- package/src/simple-tree/simpleSchema.ts +27 -5
- package/src/simple-tree/toStoredSchema.ts +17 -4
- package/src/simple-tree/treeNodeValid.ts +1 -1
- package/src/simple-tree/walkFieldSchema.ts +5 -1
- package/src/util/typeUtils.ts +2 -2
- package/src/util/utils.ts +2 -0
- package/dist/feature-libraries/flex-tree/navigation.d.ts +0 -46
- package/dist/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
- package/dist/feature-libraries/flex-tree/navigation.js +0 -104
- package/dist/feature-libraries/flex-tree/navigation.js.map +0 -1
- package/lib/feature-libraries/flex-tree/navigation.d.ts +0 -46
- package/lib/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
- package/lib/feature-libraries/flex-tree/navigation.js +0 -97
- package/lib/feature-libraries/flex-tree/navigation.js.map +0 -1
- package/src/feature-libraries/flex-tree/navigation.ts +0 -121
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAGpF,qDASgC;AAChC,qDAAqD;AAIrD,uEAImC;AAEnC,2CAQqB;AAErB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,uBAAe,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAA,oDAA0B,EAAC,mBAAO,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAbD,4CAaC;AAoED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAoB;IAClD,OAAO;QACN,WAAW,CACV,MAA8B,EAC9B,MAAoB,EACpB,YAA0B;YAE1B,IAAA,sBAAW,EAAC,MAAM,EAAE,GAAG,EAAE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;IACjF,CAAC;IAEM,cAAc,CAAC,KAA4B;QACjD,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7D,CAAC;CACD;AAvBD,oCAuBC;AAoBD,MAAM,gBAAgB;IAGrB,YACiB,KAAiB,EACjB,KAA4B,EAC3B,YAA8B;QAF/B,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAuB;QAC3B,iBAAY,GAAZ,YAAY,CAAkB;IAC7C,CAAC;IACG,WAAW,CACjB,MAA8B,EAC9B,KAAmB,EACnB,YAA0B;QAE1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,OAAO;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\thandleShapesAndIdentifiers,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn handleShapesAndIdentifiers(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly encoder: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAGpF,qDASgC;AAChC,qDAAqD;AAIrD,uEAImC;AAEnC,2CAQqB;AAErB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,uBAAe,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAA,4DAAkC,EAAC,mBAAO,EAAE,WAAW,CAAC,CAAC;AACjE,CAAC;AAbD,4CAaC;AAoED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAoB;IAClD,OAAO;QACN,WAAW,CACV,MAA8B,EAC9B,MAAoB,EACpB,YAA0B;YAE1B,IAAA,sBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,EAAE,OAAO,CAAC,KAAK;KACpB,CAAC;AACH,CAAC;AAXD,wCAWC;AAED;;GAE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D,MAAM,gBAAgB;IAGrB,YACiB,KAAiB,EACjB,KAA4B,EAC3B,YAA8B;QAF/B,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAuB;QAC3B,iBAAY,GAAZ,YAAY,CAAkB;IAC7C,CAAC;IACG,WAAW,CACjB,MAA8B,EAC9B,KAAmB,EACnB,YAA0B;QAE1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,OAAO;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\tupdateShapesAndIdentifiersEncoding,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn updateShapesAndIdentifiersEncoding(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly encoder: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape) => void,\n\t): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape) => void,\n\t): void {\n\t\tshapeDiscovered(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape) => void,\n\t): void {\n\t\tshapeDiscovered(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
|
|
@@ -53,7 +53,7 @@ export declare class NodeShape extends Shape<EncodedChunkShape> implements NodeE
|
|
|
53
53
|
private getValueToEncode;
|
|
54
54
|
encodeNode(cursor: ITreeCursorSynchronous, cache: EncoderCache, outputBuffer: BufferFormat<EncodedChunkShape>): void;
|
|
55
55
|
encodeShape(identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedChunkShape;
|
|
56
|
-
|
|
56
|
+
countReferencedShapesAndIdentifiers(identifiers: Counter<string>, shapeDiscovered: (shape: Shape<EncodedChunkShape>) => void): void;
|
|
57
57
|
get shape(): NodeShape;
|
|
58
58
|
}
|
|
59
59
|
export declare function encodeFieldShapes(fieldEncoders: readonly KeyedFieldEncoder[], identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedFieldShape[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeShape.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAG7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,KAAK,YAAY,EAAmB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KA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B,CAChC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB,EAAE,GAAG,SAAS,CAUjC"}
|
|
@@ -85,16 +85,16 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
countReferencedShapesAndIdentifiers(identifiers, shapeDiscovered) {
|
|
89
89
|
if (this.type !== undefined) {
|
|
90
90
|
identifiers.add(this.type);
|
|
91
91
|
}
|
|
92
92
|
for (const fieldEncoder of this.specializedFieldEncoders) {
|
|
93
93
|
identifiers.add(fieldEncoder.key);
|
|
94
|
-
|
|
94
|
+
shapeDiscovered(fieldEncoder.encoder.shape);
|
|
95
95
|
}
|
|
96
96
|
if (this.otherFieldsEncoder !== undefined) {
|
|
97
|
-
|
|
97
|
+
shapeDiscovered(this.otherFieldsEncoder.shape);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
get shape() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,qEAAoE;AAEpE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAG/B,MAAa,SAAU,SAAQ,+BAAwB;IAOtD,YACiB,IAA0C,EAC1C,KAAwB;IACxC;;;;;;;;;;OAUG;IACa,wBAAsD;IACtE;;;OAGG;IACa,kBAA4C;QAE5D,KAAK,EAAE,CAAC;QApBQ,SAAI,GAAJ,IAAI,CAAsC;QAC1C,UAAK,GAAL,KAAK,CAAmB;QAYxB,6BAAwB,GAAxB,wBAAwB,CAA8B;QAKtD,uBAAkB,GAAl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S,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShape.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.\n\t\t * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, cache, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapes(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapes(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA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M;QACN,gBAAgB,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC;QAC/C,QAAQ;QACR,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC;KACtF,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAS,gBAAgB,CACxB,UAAkB,EAClB,WAAuC;IAEvC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShape.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.\n\t\t * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, cache, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapeDiscovered(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapeDiscovered(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import type { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
|
|
6
|
+
import type { IExperimentalIncrementalSummaryContext, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
|
|
7
7
|
import type { DetachedFieldIndex } from "../core/index.js";
|
|
8
8
|
import type { Summarizable, SummaryElementParser, SummaryElementStringifier } from "../shared-tree-core/index.js";
|
|
9
9
|
/**
|
|
@@ -13,8 +13,13 @@ export declare class DetachedFieldIndexSummarizer implements Summarizable {
|
|
|
13
13
|
private readonly detachedFieldIndex;
|
|
14
14
|
readonly key = "DetachedFieldIndex";
|
|
15
15
|
constructor(detachedFieldIndex: DetachedFieldIndex);
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
summarize(props: {
|
|
17
|
+
stringify: SummaryElementStringifier;
|
|
18
|
+
fullTree?: boolean;
|
|
19
|
+
trackState?: boolean;
|
|
20
|
+
telemetryContext?: ITelemetryContext;
|
|
21
|
+
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext;
|
|
22
|
+
}): ISummaryTreeWithStats;
|
|
18
23
|
load(services: IChannelStorageService, parse: SummaryElementParser): Promise<void>;
|
|
19
24
|
}
|
|
20
25
|
//# sourceMappingURL=detachedFieldIndexSummarizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachedFieldIndexSummarizer.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/detachedFieldIndexSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EACX,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,8BAA8B,CAAC;AAQtC;;GAEG;AACH,qBAAa,4BAA6B,YAAW,YAAY;IAG7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAFtD,SAAgB,GAAG,wBAAwB;gBAEP,kBAAkB,EAAE,kBAAkB;IAEnE,
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexSummarizer.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/detachedFieldIndexSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EACX,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EACX,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,8BAA8B,CAAC;AAQtC;;GAEG;AACH,qBAAa,4BAA6B,YAAW,YAAY;IAG7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAFtD,SAAgB,GAAG,wBAAwB;gBAEP,kBAAkB,EAAE,kBAAkB;IAEnE,SAAS,CAAC,KAAK,EAAE;QACvB,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB;IAKZ,IAAI,CAChB,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAQhB"}
|
|
@@ -19,12 +19,9 @@ class DetachedFieldIndexSummarizer {
|
|
|
19
19
|
this.detachedFieldIndex = detachedFieldIndex;
|
|
20
20
|
this.key = "DetachedFieldIndex";
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
summarize(props) {
|
|
23
23
|
const data = this.detachedFieldIndex.encode();
|
|
24
|
-
return (0, internal_1.createSingleBlobSummary)(detachedFieldIndexBlobKey, stringify(data));
|
|
25
|
-
}
|
|
26
|
-
async summarize(stringify, fullTree, trackState, telemetryContext) {
|
|
27
|
-
return this.getAttachSummary(stringify, fullTree, trackState, telemetryContext);
|
|
24
|
+
return (0, internal_1.createSingleBlobSummary)(detachedFieldIndexBlobKey, props.stringify(data));
|
|
28
25
|
}
|
|
29
26
|
async load(services, parse) {
|
|
30
27
|
if (await services.contains(detachedFieldIndexBlobKey)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachedFieldIndexSummarizer.js","sourceRoot":"","sources":["../../src/feature-libraries/detachedFieldIndexSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;
|
|
1
|
+
{"version":3,"file":"detachedFieldIndexSummarizer.js","sourceRoot":"","sources":["../../src/feature-libraries/detachedFieldIndexSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAO9D,0EAAsF;AAUtF;;GAEG;AACH,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAE3D;;GAEG;AACH,MAAa,4BAA4B;IAGxC,YAAoC,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QAF1D,QAAG,GAAG,oBAAoB,CAAC;IAEkC,CAAC;IAEvE,SAAS,CAAC,KAMhB;QACA,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO,IAAA,kCAAuB,EAAC,yBAAyB,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,QAAgC,EAChC,KAA2B;QAE3B,IAAI,MAAM,QAAQ,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC;YACxD,MAAM,wBAAwB,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;YACpF,MAAM,gBAAgB,GAAG,IAAA,6BAAc,EAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;YAC1E,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAA2B,CAAC;YACjE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;IACF,CAAC;CACD;AA3BD,oEA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { createSingleBlobSummary } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { DetachedFieldIndex } from \"../core/index.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"../shared-tree-core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * The storage key for the blob in the summary containing schema data\n */\nconst detachedFieldIndexBlobKey = \"DetachedFieldIndexBlob\";\n\n/**\n * Provides methods for summarizing and loading a tree index.\n */\nexport class DetachedFieldIndexSummarizer implements Summarizable {\n\tpublic readonly key = \"DetachedFieldIndex\";\n\n\tpublic constructor(private readonly detachedFieldIndex: DetachedFieldIndex) {}\n\n\tpublic summarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats {\n\t\tconst data = this.detachedFieldIndex.encode();\n\t\treturn createSingleBlobSummary(detachedFieldIndexBlobKey, props.stringify(data));\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tif (await services.contains(detachedFieldIndexBlobKey)) {\n\t\t\tconst detachedFieldIndexBuffer = await services.readBlob(detachedFieldIndexBlobKey);\n\t\t\tconst treeBufferString = bufferToString(detachedFieldIndexBuffer, \"utf8\");\n\t\t\tconst parsed = parse(treeBufferString) as JsonCompatibleReadOnly;\n\t\t\tthis.detachedFieldIndex.loadData(parsed);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type AnchorNode, type FieldKey, type FieldKindIdentifier, type ITreeCursorSynchronous, type NormalizedFieldUpPath, type
|
|
5
|
+
import { type AnchorNode, type FieldKey, type FieldKindIdentifier, type ITreeCursorSynchronous, type NormalizedFieldUpPath, type TreeValue } from "../../core/index.js";
|
|
6
6
|
import type { FieldKinds, SequenceFieldEditBuilder, ValueFieldEditBuilder, OptionalFieldEditBuilder } from "../default-schema/index.js";
|
|
7
|
-
import type { MinimalMapTreeNodeView } from "../mapTreeCursor.js";
|
|
7
|
+
import type { MapTreeFieldViewGeneric, MapTreeNodeViewGeneric, MinimalFieldMap, MinimalMapTreeNodeView } from "../mapTreeCursor.js";
|
|
8
8
|
import type { FlexFieldKind } from "../modular-schema/index.js";
|
|
9
9
|
import type { FlexTreeContext, FlexTreeHydratedContext } from "./context.js";
|
|
10
10
|
/**
|
|
@@ -47,6 +47,13 @@ export interface FlexTreeEntity {
|
|
|
47
47
|
* A common context of FlexTrees.
|
|
48
48
|
*/
|
|
49
49
|
readonly context: FlexTreeContext;
|
|
50
|
+
/**
|
|
51
|
+
* Get a cursor for the underlying data.
|
|
52
|
+
* @remarks
|
|
53
|
+
* This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.
|
|
54
|
+
* Must not be held onto across edits or any other tree API use.
|
|
55
|
+
*/
|
|
56
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* Status of the tree that a particular node belongs to.
|
|
@@ -109,12 +116,8 @@ export declare enum TreeStatus {
|
|
|
109
116
|
* @remarks
|
|
110
117
|
* All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.
|
|
111
118
|
*/
|
|
112
|
-
export interface FlexTreeNode extends FlexTreeEntity {
|
|
119
|
+
export interface FlexTreeNode extends FlexTreeEntity, MapTreeNodeViewGeneric<FlexTreeNode> {
|
|
113
120
|
readonly [flexTreeMarker]: FlexTreeEntityKind.Node;
|
|
114
|
-
/**
|
|
115
|
-
* Value stored on this node.
|
|
116
|
-
*/
|
|
117
|
-
readonly value?: TreeValue;
|
|
118
121
|
/**
|
|
119
122
|
* Gets a field of this node, if it is not empty.
|
|
120
123
|
*/
|
|
@@ -126,17 +129,27 @@ export interface FlexTreeNode extends FlexTreeEntity {
|
|
|
126
129
|
* @remarks
|
|
127
130
|
* All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.
|
|
128
131
|
* Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.
|
|
129
|
-
* See {@link FlexTreeNode.tryGetField} for a variant that does not allocate
|
|
132
|
+
* See {@link FlexTreeNode.tryGetField} for a variant that does not allocate a field in the empty case.
|
|
130
133
|
*/
|
|
131
134
|
getBoxed(key: FieldKey): FlexTreeField;
|
|
132
135
|
/**
|
|
133
136
|
* The field this tree is in, and the index within that field.
|
|
137
|
+
* @remarks
|
|
138
|
+
* The behavior of this at the root (especially removed and unhydrated roots) is currently not very consistent.
|
|
139
|
+
* Since very little relies on this, limit what it exposes to reduce the potential impact of inconsistent root handling.
|
|
134
140
|
*/
|
|
135
141
|
readonly parentField: {
|
|
136
|
-
readonly parent: FlexTreeField
|
|
142
|
+
readonly parent: Pick<FlexTreeField, "parent" | "schema" | "key">;
|
|
137
143
|
readonly index: number;
|
|
138
144
|
};
|
|
139
|
-
|
|
145
|
+
/**
|
|
146
|
+
* The non-empty fields on this node.
|
|
147
|
+
*/
|
|
148
|
+
readonly fields: MinimalFieldMap<FlexTreeField>;
|
|
149
|
+
/**
|
|
150
|
+
* The non-empty fields on this node.
|
|
151
|
+
*/
|
|
152
|
+
[Symbol.iterator](): IterableIterator<FlexTreeField>;
|
|
140
153
|
/**
|
|
141
154
|
* Returns an iterable of keys for non-empty fields.
|
|
142
155
|
*
|
|
@@ -146,18 +159,6 @@ export interface FlexTreeNode extends FlexTreeEntity {
|
|
|
146
159
|
* No guarantees are made regarding the order of the keys returned.
|
|
147
160
|
*/
|
|
148
161
|
keys(): IterableIterator<FieldKey>;
|
|
149
|
-
/**
|
|
150
|
-
* Schema for this entity.
|
|
151
|
-
* If well-formed, it must follow this schema.
|
|
152
|
-
*/
|
|
153
|
-
readonly schema: TreeNodeSchemaIdentifier;
|
|
154
|
-
/**
|
|
155
|
-
* Get a cursor for the underlying data.
|
|
156
|
-
* @remarks
|
|
157
|
-
* This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.
|
|
158
|
-
* Must not be held onto across edits or any other tree API use.
|
|
159
|
-
*/
|
|
160
|
-
borrowCursor(): ITreeCursorSynchronous;
|
|
161
162
|
/**
|
|
162
163
|
* If true, this node is a {@link HydratedFlexTreeNode}.
|
|
163
164
|
*
|
|
@@ -201,7 +202,7 @@ export interface HydratedFlexTreeNode extends FlexTreeNode {
|
|
|
201
202
|
* All content in the tree is accessible without down-casting, but if the schema is known,
|
|
202
203
|
* the schema aware API may be more ergonomic.
|
|
203
204
|
*/
|
|
204
|
-
export interface FlexTreeField extends FlexTreeEntity {
|
|
205
|
+
export interface FlexTreeField extends FlexTreeEntity, MapTreeFieldViewGeneric<FlexTreeNode> {
|
|
205
206
|
readonly [flexTreeMarker]: FlexTreeEntityKind.Field;
|
|
206
207
|
/**
|
|
207
208
|
* The number of nodes in this field
|
|
@@ -221,7 +222,6 @@ export interface FlexTreeField extends FlexTreeEntity {
|
|
|
221
222
|
* Type guard for narrowing / down-casting to a specific schema.
|
|
222
223
|
*/
|
|
223
224
|
is<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;
|
|
224
|
-
boxedIterator(): IterableIterator<FlexTreeNode>;
|
|
225
225
|
/**
|
|
226
226
|
* Gets a node of this field by its index without unboxing.
|
|
227
227
|
* @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.
|
|
@@ -292,7 +292,6 @@ export interface FlexTreeSequenceField extends FlexTreeField {
|
|
|
292
292
|
* Get an editor for this sequence.
|
|
293
293
|
*/
|
|
294
294
|
readonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;
|
|
295
|
-
boxedIterator(): IterableIterator<FlexTreeNode>;
|
|
296
295
|
}
|
|
297
296
|
/**
|
|
298
297
|
* Field that stores exactly one child.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flexTreeTypes.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,
|
|
1
|
+
{"version":3,"file":"flexTreeTypes.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACX,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,YAAY,gEAAqC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,cAAc,eAA2B,CAAC;AAMvD,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,YAAY,CAE5D;AAED;GACG;AACH,oBAAY,kBAAkB;IAC7B,IAAI,IAAA;IACJ,KAAK,IAAA;CACL;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC9B;;;OAGG;IACH,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;;;;OAKG;IACH,YAAY,IAAI,sBAAsB,CAAC;CACvC;AAED;;;GAGG;AACH,oBAAY,UAAU;IACrB;;OAEG;IACH,UAAU,IAAI;IAEd;;OAEG;IACH,OAAO,IA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AI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AA6BD;;;GAGG;AACH,IAAY,UA+CX;AA/CD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;OAcG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;;OAiBG;IACH,yCAAO,CAAA;AACR,CAAC,EA/CW,UAAU,0BAAV,UAAU,QA+CrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NormalizedFieldUpPath,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { MinimalMapTreeNodeView } from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext, FlexTreeHydratedContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<HydratedFlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nfunction isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * A common context of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t * @remarks\n\t * Nodes can enter this state for multiple reasons:\n\t * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.\n\t * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.\n\t *\n\t * Deleted nodes' contents should not be observed or edited. This includes functionality exposed via {@link (Tree:variable)},\n\t * with the exception of {@link TreeNodeApi.status}.\n\t *\n\t * @privateRemarks\n\t * There was planned work (AB#17948) to make the first reason a node could become \"Deleted\" impossible,\n\t * at least as an opt in feature,\n\t * by lifetime extending all nodes which are still possible to reach automatically.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t * @remarks\n\t * See also {@link Unhydrated}.\n\t *\n\t * Nodes in the new state have some limitations:\n\t *\n\t * - Events are not currently triggered for changes. Fixes for this are planned.\n\t *\n\t * - Reading identifiers from nodes which were left unspecified (defaulted) when creating the tree will error.\n\t * This is because allocating unique identifiers in a compressible manner requires knowing which tree the nodes will be inserted into.\n\t *\n\t * - Transactions do not work: transactions apply to a single {@link TreeView}, and `New` nodes are not part of one.\n\t *\n\t * - Automatically generated {@link SchemaFactory.identifier | identifiers} will be less compressible if read.\n\t *\n\t * - {@link TreeIdentifierUtils.getShort} and {@link TreeNodeApi.shortId | Tree.shortId} cannot return their short identifiers.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n * @remarks\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * Returns an iterable of keys for non-empty fields.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TreeNodeSchemaIdentifier;\n\n\t/**\n\t * Get a cursor for the underlying data.\n\t * @remarks\n\t * This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.\n\t * Must not be held onto across edits or any other tree API use.\n\t */\n\tborrowCursor(): ITreeCursorSynchronous;\n\n\t/**\n\t * If true, this node is a {@link HydratedFlexTreeNode}.\n\t *\n\t * If false, this node is unhydrated.\n\t */\n\tisHydrated(): this is HydratedFlexTreeNode;\n}\n\n/**\n * A FlexTreeNode that is hydrated, meaning it is associated with a {@link FlexTreeHydratedContext}.\n */\nexport interface HydratedFlexTreeNode extends FlexTreeNode {\n\t/**\n\t * {@inheritDoc FlexTreeNode.context}\n\t */\n\treadonly context: FlexTreeHydratedContext;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): NormalizedFieldUpPath;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: FieldKindIdentifier;\n}\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = readonly FlexibleNodeContent[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = MinimalMapTreeNodeView;\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField extends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnknownUnboxed | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<Kind extends FlexFieldKind> =\n\tKind extends typeof FieldKinds.sequence\n\t\t? FlexTreeSequenceField\n\t\t: Kind extends typeof FieldKinds.required\n\t\t\t? FlexTreeRequiredField\n\t\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t\t? FlexTreeOptionalField\n\t\t\t\t: FlexTreeField;\n\n// #endregion\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n"]}
|
|
1
|
+
{"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAQ6B;AAiB7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAwB,CAAC;AAE/D;;GAEG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAS,gBAAgB,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,sBAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAgB,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAFD,wCAEC;AAED;GACG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAqCD;;;GAGG;AACH,IAAY,UA+CX;AA/CD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;OAcG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;;OAiBG;IACH,yCAAO,CAAA;AACR,CAAC,EA/CW,UAAU,0BAAV,UAAU,QA+CrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NormalizedFieldUpPath,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type {\n\tMapTreeFieldViewGeneric,\n\tMapTreeNodeViewGeneric,\n\tMinimalFieldMap,\n\tMinimalMapTreeNodeView,\n} from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext, FlexTreeHydratedContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<HydratedFlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nfunction isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * A common context of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n\n\t/**\n\t * Get a cursor for the underlying data.\n\t * @remarks\n\t * This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.\n\t * Must not be held onto across edits or any other tree API use.\n\t */\n\tborrowCursor(): ITreeCursorSynchronous;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t * @remarks\n\t * Nodes can enter this state for multiple reasons:\n\t * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.\n\t * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.\n\t *\n\t * Deleted nodes' contents should not be observed or edited. This includes functionality exposed via {@link (Tree:variable)},\n\t * with the exception of {@link TreeNodeApi.status}.\n\t *\n\t * @privateRemarks\n\t * There was planned work (AB#17948) to make the first reason a node could become \"Deleted\" impossible,\n\t * at least as an opt in feature,\n\t * by lifetime extending all nodes which are still possible to reach automatically.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t * @remarks\n\t * See also {@link Unhydrated}.\n\t *\n\t * Nodes in the new state have some limitations:\n\t *\n\t * - Events are not currently triggered for changes. Fixes for this are planned.\n\t *\n\t * - Reading identifiers from nodes which were left unspecified (defaulted) when creating the tree will error.\n\t * This is because allocating unique identifiers in a compressible manner requires knowing which tree the nodes will be inserted into.\n\t *\n\t * - Transactions do not work: transactions apply to a single {@link TreeView}, and `New` nodes are not part of one.\n\t *\n\t * - Automatically generated {@link SchemaFactory.identifier | identifiers} will be less compressible if read.\n\t *\n\t * - {@link TreeIdentifierUtils.getShort} and {@link TreeNodeApi.shortId | Tree.shortId} cannot return their short identifiers.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n * @remarks\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity, MapTreeNodeViewGeneric<FlexTreeNode> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate a field in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks\n\t * The behavior of this at the root (especially removed and unhydrated roots) is currently not very consistent.\n\t * Since very little relies on this, limit what it exposes to reduce the potential impact of inconsistent root handling.\n\t */\n\treadonly parentField: {\n\t\treadonly parent: Pick<FlexTreeField, \"parent\" | \"schema\" | \"key\">;\n\t\treadonly index: number;\n\t};\n\n\t/**\n\t * The non-empty fields on this node.\n\t */\n\treadonly fields: MinimalFieldMap<FlexTreeField>;\n\n\t/**\n\t * The non-empty fields on this node.\n\t */\n\t[Symbol.iterator](): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * Returns an iterable of keys for non-empty fields.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * If true, this node is a {@link HydratedFlexTreeNode}.\n\t *\n\t * If false, this node is unhydrated.\n\t */\n\tisHydrated(): this is HydratedFlexTreeNode;\n}\n\n/**\n * A FlexTreeNode that is hydrated, meaning it is associated with a {@link FlexTreeHydratedContext}.\n */\nexport interface HydratedFlexTreeNode extends FlexTreeNode {\n\t/**\n\t * {@inheritDoc FlexTreeNode.context}\n\t */\n\treadonly context: FlexTreeHydratedContext;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity, MapTreeFieldViewGeneric<FlexTreeNode> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): NormalizedFieldUpPath;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: FieldKindIdentifier;\n}\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = readonly FlexibleNodeContent[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = MinimalMapTreeNodeView;\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField extends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnknownUnboxed | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<Kind extends FlexFieldKind> =\n\tKind extends typeof FieldKinds.sequence\n\t\t? FlexTreeSequenceField\n\t\t: Kind extends typeof FieldKinds.required\n\t\t\t? FlexTreeRequiredField\n\t\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t\t? FlexTreeOptionalField\n\t\t\t\t: FlexTreeField;\n\n// #endregion\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export { type FlexTreeField, type FlexTreeNode, type FlexTreeEntity, type FlexTreeTypedField, type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, TreeStatus, type FlexTreeUnknownUnboxed, flexTreeMarker, FlexTreeEntityKind, isFlexTreeNode, flexTreeSlot, type FlexibleNodeContent, type FlexibleFieldContent, type HydratedFlexTreeNode, } from "./flexTreeTypes.js";
|
|
6
|
-
export { visitBipartiteIterableTree, Skip, visitBipartiteIterableTreeWithState, visitIterableTree, visitIterableTreeWithState, } from "./navigation.js";
|
|
7
6
|
export { type FlexTreeContext, type FlexTreeHydratedContext, Context, ContextSlot, type FlexTreeHydratedContextMinimal, } from "./context.js";
|
|
8
7
|
export { type FlexTreeNodeEvents } from "./treeEvents.js";
|
|
9
8
|
export { assertFlexTreeEntityNotFreed, LazyEntity, } from "./lazyEntity.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,UAAU,EACV,KAAK,sBAAsB,EAC3B,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,UAAU,EACV,KAAK,sBAAsB,EAC3B,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,OAAO,EACP,WAAW,EACX,KAAK,8BAA8B,GACnC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EACN,4BAA4B,EAC5B,UAAU,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -4,19 +4,13 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.treeStatusFromAnchorCache = exports.indexForAt = exports.getSchemaAndPolicy = exports.LazyEntity = exports.assertFlexTreeEntityNotFreed = exports.ContextSlot = exports.Context = exports.
|
|
7
|
+
exports.treeStatusFromAnchorCache = exports.indexForAt = exports.getSchemaAndPolicy = exports.LazyEntity = exports.assertFlexTreeEntityNotFreed = exports.ContextSlot = exports.Context = exports.flexTreeSlot = exports.isFlexTreeNode = exports.FlexTreeEntityKind = exports.flexTreeMarker = exports.TreeStatus = void 0;
|
|
8
8
|
var flexTreeTypes_js_1 = require("./flexTreeTypes.js");
|
|
9
9
|
Object.defineProperty(exports, "TreeStatus", { enumerable: true, get: function () { return flexTreeTypes_js_1.TreeStatus; } });
|
|
10
10
|
Object.defineProperty(exports, "flexTreeMarker", { enumerable: true, get: function () { return flexTreeTypes_js_1.flexTreeMarker; } });
|
|
11
11
|
Object.defineProperty(exports, "FlexTreeEntityKind", { enumerable: true, get: function () { return flexTreeTypes_js_1.FlexTreeEntityKind; } });
|
|
12
12
|
Object.defineProperty(exports, "isFlexTreeNode", { enumerable: true, get: function () { return flexTreeTypes_js_1.isFlexTreeNode; } });
|
|
13
13
|
Object.defineProperty(exports, "flexTreeSlot", { enumerable: true, get: function () { return flexTreeTypes_js_1.flexTreeSlot; } });
|
|
14
|
-
var navigation_js_1 = require("./navigation.js");
|
|
15
|
-
Object.defineProperty(exports, "visitBipartiteIterableTree", { enumerable: true, get: function () { return navigation_js_1.visitBipartiteIterableTree; } });
|
|
16
|
-
Object.defineProperty(exports, "Skip", { enumerable: true, get: function () { return navigation_js_1.Skip; } });
|
|
17
|
-
Object.defineProperty(exports, "visitBipartiteIterableTreeWithState", { enumerable: true, get: function () { return navigation_js_1.visitBipartiteIterableTreeWithState; } });
|
|
18
|
-
Object.defineProperty(exports, "visitIterableTree", { enumerable: true, get: function () { return navigation_js_1.visitIterableTree; } });
|
|
19
|
-
Object.defineProperty(exports, "visitIterableTreeWithState", { enumerable: true, get: function () { return navigation_js_1.visitIterableTreeWithState; } });
|
|
20
14
|
var context_js_1 = require("./context.js");
|
|
21
15
|
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_js_1.Context; } });
|
|
22
16
|
Object.defineProperty(exports, "ContextSlot", { enumerable: true, get: function () { return context_js_1.ContextSlot; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAiB4B;AAT3B,8GAAA,UAAU,OAAA;AAEV,kHAAA,cAAc,OAAA;AACd,sHAAA,kBAAkB,OAAA;AAClB,kHAAA,cAAc,OAAA;AACd,gHAAA,YAAY,OAAA;AAMb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAiB4B;AAT3B,8GAAA,UAAU,OAAA;AAEV,kHAAA,cAAc,OAAA;AACd,sHAAA,kBAAkB,OAAA;AAClB,kHAAA,cAAc,OAAA;AACd,gHAAA,YAAY,OAAA;AAMb,2CAMsB;AAHrB,qGAAA,OAAO,OAAA;AACP,yGAAA,WAAW,OAAA;AAMZ,iDAGyB;AAFxB,6HAAA,4BAA4B,OAAA;AAC5B,2GAAA,UAAU,OAAA;AAGX,+CAAgE;AAAvD,kHAAA,kBAAkB,OAAA;AAAE,0GAAA,UAAU,OAAA;AAEvC,+CAA2D;AAAlD,yHAAA,yBAAyB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeEntity,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tTreeStatus,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tFlexTreeEntityKind,\n\tisFlexTreeNode,\n\tflexTreeSlot,\n\ttype FlexibleNodeContent,\n\ttype FlexibleFieldContent,\n\ttype HydratedFlexTreeNode,\n} from \"./flexTreeTypes.js\";\n\nexport {\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\tContext,\n\tContextSlot,\n\ttype FlexTreeHydratedContextMinimal,\n} from \"./context.js\";\n\nexport { type FlexTreeNodeEvents } from \"./treeEvents.js\";\n\nexport {\n\tassertFlexTreeEntityNotFreed,\n\tLazyEntity,\n} from \"./lazyEntity.js\";\n\nexport { getSchemaAndPolicy, indexForAt } from \"./utilities.js\";\n\nexport { treeStatusFromAnchorCache } from \"./utilities.js\";\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type ITreeSubscriptionCursor, TreeNavigationResult } from "../../core/index.js";
|
|
5
|
+
import { type ITreeCursorSynchronous, type ITreeSubscriptionCursor, TreeNavigationResult } from "../../core/index.js";
|
|
6
6
|
import { type IDisposable, disposeSymbol } from "../../util/index.js";
|
|
7
7
|
import type { Context } from "./context.js";
|
|
8
8
|
import { type FlexTreeEntity, type FlexTreeEntityKind, flexTreeMarker } from "./flexTreeTypes.js";
|
|
@@ -21,7 +21,7 @@ export declare abstract class LazyEntity<TAnchor = unknown> implements FlexTreeE
|
|
|
21
21
|
readonly context: Context;
|
|
22
22
|
readonly anchor: TAnchor;
|
|
23
23
|
protected constructor(context: Context, cursor: ITreeSubscriptionCursor, anchor: TAnchor);
|
|
24
|
-
|
|
24
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
25
25
|
abstract get [flexTreeMarker](): FlexTreeEntityKind;
|
|
26
26
|
[disposeSymbol](): void;
|
|
27
27
|
prepareForEdit(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyEntity.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyEntity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,uBAAuB,EAE5B,oBAAoB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,cAAc,EACd,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAGzE;AAED;;GAEG;AACH,8BAAsB,UAAU,CAAC,OAAO,GAAG,OAAO,CAAE,YAAW,cAAc,EAAE,WAAW;;aAKxE,OAAO,EAAE,OAAO;IAHjC,SAAgB,MAAM,EAAE,OAAO,CAAC;IAEhC,SAAS,aACQ,OAAO,EAAE,OAAO,EAChC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"lazyEntity.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyEntity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAE5B,oBAAoB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,cAAc,EACd,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAGzE;AAED;;GAEG;AACH,8BAAsB,UAAU,CAAC,OAAO,GAAG,OAAO,CAAE,YAAW,cAAc,EAAE,WAAW;;aAKxE,OAAO,EAAE,OAAO;IAHjC,SAAgB,MAAM,EAAE,OAAO,CAAC;IAEhC,SAAS,aACQ,OAAO,EAAE,OAAO,EAChC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,OAAO;IAQT,YAAY,IAAI,sBAAsB;IAI7C,aAAoB,CAAC,cAAc,CAAC,IAAI,kBAAkB,CAAC;IAEpD,CAAC,aAAa,CAAC,IAAI,IAAI;IAOvB,cAAc,IAAI,IAAI;IAKtB,OAAO,IAAI,OAAO;IAIzB,IAAW,MAAM,IAAI,uBAAuB,CAkB3C;IAED,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CACvC,MAAM,EAAE,uBAAuB,GAC7B,oBAAoB;IAEvB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;CACvC"}
|
|
@@ -44,6 +44,9 @@ class LazyEntity {
|
|
|
44
44
|
context.withCursors.add(this);
|
|
45
45
|
this.context.withAnchors.add(this);
|
|
46
46
|
}
|
|
47
|
+
borrowCursor() {
|
|
48
|
+
return this.cursor;
|
|
49
|
+
}
|
|
47
50
|
[(_LazyEntity_lazyCursor = new WeakMap(), index_js_2.disposeSymbol)]() {
|
|
48
51
|
__classPrivateFieldGet(this, _LazyEntity_lazyCursor, "f").free();
|
|
49
52
|
this.context.withCursors.delete(this);
|