@fluidframework/tree 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +12 -1
- package/CHANGELOG.md +371 -0
- package/api-report/tree.alpha.api.md +271 -80
- package/api-report/tree.beta.api.md +100 -51
- package/api-report/tree.legacy.alpha.api.md +99 -50
- package/api-report/tree.legacy.public.api.md +99 -50
- package/api-report/tree.public.api.md +99 -50
- package/dist/alpha.d.ts +32 -2
- package/dist/beta.d.ts +6 -0
- package/dist/codec/codec.d.ts +24 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +26 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +0 -4
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -7
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +1 -0
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +29 -4
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/events/interop.d.ts +1 -7
- package/dist/events/interop.d.ts.map +1 -1
- package/dist/events/interop.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- 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/lazyNode.d.ts +2 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +2 -2
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +1 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/legacy.d.ts +6 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +6 -0
- package/dist/shared-tree/independentView.d.ts +57 -0
- package/dist/shared-tree/independentView.d.ts.map +1 -0
- package/dist/shared-tree/independentView.js +89 -0
- package/dist/shared-tree/independentView.js.map +1 -0
- package/dist/shared-tree/index.d.ts +3 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +28 -0
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +10 -7
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +6 -6
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/dist/shared-tree/treeApiAlpha.js +122 -0
- package/dist/shared-tree/treeApiAlpha.js.map +1 -0
- package/dist/shared-tree/treeCheckout.d.ts +12 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +11 -4
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +13 -6
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +80 -33
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +28 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +2 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +6 -24
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +4 -19
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +1 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +2 -2
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +7 -7
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +10 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +31 -21
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +16 -12
- 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/simpleSchemaToJsonSchema.js +3 -3
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.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/testRecursiveDomain.d.ts +5 -5
- package/dist/simple-tree/api/tree.d.ts +122 -5
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +12 -4
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.js +3 -15
- package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +69 -17
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +3 -0
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +15 -4
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +51 -11
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +2 -1
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/createContext.js +2 -2
- package/dist/simple-tree/createContext.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 +15 -5
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +3 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +6 -0
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +4 -2
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +210 -18
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +66 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +4 -2
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/dist/simple-tree/toStoredSchema.js.map +1 -0
- package/dist/simple-tree/treeNodeValid.d.ts +5 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +7 -1
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/util/index.d.ts +3 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +3 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +9 -0
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/typeUtils.d.ts +61 -0
- package/dist/util/typeUtils.d.ts.map +1 -1
- package/dist/util/typeUtils.js +27 -0
- package/dist/util/typeUtils.js.map +1 -1
- package/dist/util/utils.d.ts +7 -3
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +13 -3
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +32 -2
- package/lib/beta.d.ts +6 -0
- package/lib/codec/codec.d.ts +24 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +25 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +2 -2
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +0 -4
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -5
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +1 -0
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +27 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/events/interop.d.ts +1 -7
- package/lib/events/interop.d.ts.map +1 -1
- package/lib/events/interop.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- 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/lazyNode.d.ts +2 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +2 -2
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +1 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/legacy.d.ts +6 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +6 -0
- package/lib/shared-tree/independentView.d.ts +57 -0
- package/lib/shared-tree/independentView.d.ts.map +1 -0
- package/lib/shared-tree/independentView.js +84 -0
- package/lib/shared-tree/independentView.js.map +1 -0
- package/lib/shared-tree/index.d.ts +3 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +29 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +10 -7
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +6 -6
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/lib/shared-tree/treeApiAlpha.js +119 -0
- package/lib/shared-tree/treeApiAlpha.js.map +1 -0
- package/lib/shared-tree/treeCheckout.d.ts +12 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +11 -4
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +13 -6
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +80 -33
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +29 -4
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +2 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +6 -24
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +2 -16
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +1 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +2 -2
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +7 -7
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +6 -4
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +30 -19
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +16 -12
- 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/simpleSchemaToJsonSchema.js +3 -3
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +1 -1
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/lib/simple-tree/api/tree.d.ts +122 -5
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +9 -2
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.js +4 -16
- package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +69 -17
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +3 -0
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +15 -4
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +51 -11
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +2 -1
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.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 +5 -5
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +3 -0
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +6 -0
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +4 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +210 -18
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +64 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +4 -2
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/lib/simple-tree/toStoredSchema.js.map +1 -0
- package/lib/simple-tree/treeNodeValid.d.ts +5 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +7 -1
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/util/index.d.ts +3 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeCheck.d.ts +9 -0
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/typeUtils.d.ts +61 -0
- package/lib/util/typeUtils.d.ts.map +1 -1
- package/lib/util/typeUtils.js +25 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/lib/util/utils.d.ts +7 -3
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +13 -3
- package/lib/util/utils.js.map +1 -1
- package/package.json +55 -30
- package/src/codec/codec.ts +25 -0
- package/src/codec/index.ts +1 -0
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +0 -12
- package/src/core/rebase/utils.ts +35 -3
- package/src/events/interop.ts +1 -12
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
- package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
- package/src/feature-libraries/object-forest/objectForest.ts +1 -1
- package/src/feature-libraries/treeCursorUtils.ts +2 -2
- package/src/index.ts +36 -6
- package/src/internalTypes.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +176 -0
- package/src/shared-tree/index.ts +9 -1
- package/src/shared-tree/schematizingTreeView.ts +64 -13
- package/src/shared-tree/sharedTree.ts +29 -9
- package/src/shared-tree/treeApi.ts +19 -9
- package/src/shared-tree/treeApiAlpha.ts +401 -0
- package/src/shared-tree/treeCheckout.ts +28 -5
- package/src/shared-tree-core/editManager.ts +126 -59
- package/src/shared-tree-core/sharedTreeCore.ts +37 -8
- package/src/simple-tree/api/conciseTree.ts +2 -1
- package/src/simple-tree/api/create.ts +33 -65
- package/src/simple-tree/api/customTree.ts +3 -2
- package/src/simple-tree/api/index.ts +19 -8
- package/src/simple-tree/api/schemaCreationUtilities.ts +59 -37
- package/src/simple-tree/api/schemaFactory.ts +28 -12
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +3 -3
- package/src/simple-tree/api/storedSchema.ts +1 -1
- package/src/simple-tree/api/tree.ts +152 -7
- package/src/simple-tree/api/treeApiBeta.ts +35 -31
- package/src/simple-tree/api/typesUnsafe.ts +125 -30
- package/src/simple-tree/api/verboseTree.ts +3 -0
- package/src/simple-tree/arrayNode.ts +38 -17
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +107 -34
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
- package/src/simple-tree/core/withType.ts +2 -1
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/index.ts +34 -3
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/mapNode.ts +13 -4
- package/src/simple-tree/objectNode.ts +5 -3
- package/src/simple-tree/schemaTypes.ts +342 -36
- package/src/simple-tree/toMapTree.ts +4 -1
- package/src/simple-tree/treeNodeValid.ts +11 -1
- package/src/util/index.ts +7 -0
- package/src/util/typeCheck.ts +13 -0
- package/src/util/typeUtils.ts +87 -0
- package/src/util/utils.ts +20 -7
- package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/dist/simple-tree/toFlexSchema.js.map +0 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/lib/simple-tree/toFlexSchema.js.map +0 -1
- /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
|
@@ -198,7 +198,7 @@ class BasicChunkCursor extends treeCursorUtils_js_1.SynchronousCursor {
|
|
|
198
198
|
(0, internal_1.assert)(this.mode === 1 /* CursorLocationType.Fields */, 0x525 /* must be in fields mode */);
|
|
199
199
|
return {
|
|
200
200
|
field: this.indexStack.length === 1
|
|
201
|
-
? prefix?.rootFieldOverride ?? this.getFieldKey()
|
|
201
|
+
? (prefix?.rootFieldOverride ?? this.getFieldKey())
|
|
202
202
|
: this.getFieldKey(),
|
|
203
203
|
parent: this.getOffsetPath(1, prefix),
|
|
204
204
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAalE,kDAAiE;AACjE,8DAAsE;AAEtE,yCAAwF;AAExF;;GAEG;AACH,MAAa,UAAW,SAAQ,+BAAoB;IAGnD;;;;;;;OAOG;IACH,YACQ,IAA8B,EAC9B,MAAkC,EAClC,KAAiB;QAExB,KAAK,EAAE,CAAC;QAJD,SAAI,GAAJ,IAAI,CAA0B;QAC9B,WAAM,GAAN,MAAM,CAA4B;QAClC,UAAK,GAAL,KAAK,CAAY;QAbT,mBAAc,GAAW,CAAC,CAAC;IAgB3C,CAAC;IAEM,KAAK;QACX,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;QAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC7B,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACd,CAAC,CAAC,CAAC;YACH,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAEM,MAAM;QACZ,OAAO,IAAI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C;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,WAAW;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD;AA5eD,4CA4eC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\nimport { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from \"./chunk.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param fields - provides exclusive deep ownership of this map to this object (which might mutate it in the future).\n\t * The caller must have already accounted for this reference to the children in this map (via `referenceAdded`),\n\t * and any edits to this must update child reference counts.\n\t * @param value - the value on this node, if any.\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(\"nested cursors should not be root\")\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(\"nested cursors should not be root\");\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? prefix?.rootFieldOverride ?? this.getFieldKey()\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings = this.siblingStack.pop() ?? fail(\"Unexpected siblingStack.length\");\n\t\tthis.index = this.indexStack.pop() ?? fail(\"Unexpected indexStack.length\");\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings = this.siblingStack.pop() ?? fail(\"Unexpected siblingStack.length\");\n\t\tthis.index = this.indexStack.pop() ?? fail(\"Unexpected indexStack.length\");\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(\"Unexpected indexOfChunkStack.length\");\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ?? fail(\"Unexpected indexWithinChunkStack.length\");\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAalE,kDAAiE;AACjE,8DAAsE;AAEtE,yCAAwF;AAExF;;GAEG;AACH,MAAa,UAAW,SAAQ,+BAAoB;IAGnD;;;;;;;OAOG;IACH,YACQ,IAA8B,EAC9B,MAAkC,EAClC,KAAiB;QAExB,KAAK,EAAE,CAAC;QAJ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CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED;;;OAGG;IACK,YAAY;QACnB,IAAA,iBAAM,EAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1F,IAAA,iBAAM,EACL,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC/B,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,YAAY,CAAC,UAAU,EACvD,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAC3C,CAAC;IAED,IAAW,UAAU;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,WAAW;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD;AA5eD,4CA4eC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\nimport { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from \"./chunk.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param fields - provides exclusive deep ownership of this map to this object (which might mutate it in the future).\n\t * The caller must have already accounted for this reference to the children in this map (via `referenceAdded`),\n\t * and any edits to this must update child reference counts.\n\t * @param value - the value on this node, if any.\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(\"nested cursors should not be root\")\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(\"nested cursors should not be root\");\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? (prefix?.rootFieldOverride ?? this.getFieldKey())\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings = this.siblingStack.pop() ?? fail(\"Unexpected siblingStack.length\");\n\t\tthis.index = this.indexStack.pop() ?? fail(\"Unexpected indexStack.length\");\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings = this.siblingStack.pop() ?? fail(\"Unexpected siblingStack.length\");\n\t\tthis.index = this.indexStack.pop() ?? fail(\"Unexpected indexStack.length\");\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(\"Unexpected indexOfChunkStack.length\");\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ?? fail(\"Unexpected indexWithinChunkStack.length\");\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
|
|
@@ -401,7 +401,7 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
|
|
|
401
401
|
this.indexOfField =
|
|
402
402
|
fieldInfo === undefined
|
|
403
403
|
? fieldMap.size
|
|
404
|
-
: fieldInfo.indexOfParentField ?? (0, index_js_1.fail)("children should have parents");
|
|
404
|
+
: (fieldInfo.indexOfParentField ?? (0, index_js_1.fail)("children should have parents"));
|
|
405
405
|
this.fieldKey = key;
|
|
406
406
|
this.mode = 1 /* CursorLocationType.Fields */;
|
|
407
407
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniformChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/uniformChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAiF;AAYjF,kDAAiE;AACjE,8DAAuF;AAEvF,yCAAwF;AAExF,uEAAsE;AAEtE;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAiB,EAAE,MAAmB;IAClE,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,+BAAoB;IAErD;;;;;OAKG;IACH,YACQ,KAAiB,EACjB,MAAmB,EAC1B,YAA4B;QAE5B,KAAK,EAAE,CAAC;QAJD,UAAK,GAAL,KAAK,CAAY;QACjB,WAAM,GAAN,MAAM,C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QAAQ,kCAA0B,CAAC;QACrD,iGAAiG;QACjG,yIAAyI;QACzI,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,+BAA+B,EAAE,CAAC;YACvE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;gBAC7D,OAAO,YAAY,CAAC,UAAU,CAAC,KAAiC,CAAC,CAAC;YACnE,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixFieldPath, prefixPath } from \"../treeCursorUtils.js\";\n\nimport { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from \"./chunk.js\";\nimport type { SessionSpaceCompressedId, IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Create a tree chunk with ref count 1.\n *\n * @param shape - describes the semantics and layout of `values`.\n * @param values - provides exclusive ownership of this array to this object (which might mutate it in the future).\n */\nexport function uniformChunk(shape: ChunkShape, values: TreeValue[]): TreeChunk {\n\treturn new UniformChunk(shape, values);\n}\n\n/**\n * Chunk which handles a sequence of trees with identical \"shape\" (see `TreeShape`).\n *\n * Separates shape from content,\n * allowing deduplication of shape information and storing of content as a flat sequence of values.\n */\nexport class UniformChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic idCompressor: undefined | IIdCompressor;\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param shape - describes the semantics and layout of `values`.\n\t * @param values - provides exclusive ownership of this array to this object (which might mutate it in the future).\n\t */\n\tpublic constructor(\n\t\tpublic shape: ChunkShape,\n\t\tpublic values: TreeValue[],\n\t\tidCompressor?: IIdCompressor,\n\t) {\n\t\tsuper();\n\t\tthis.idCompressor = idCompressor;\n\t\tassert(\n\t\t\tshape.treeShape.valuesPerTopLevelNode * shape.topLevelLength === values.length,\n\t\t\t0x4c3 /* invalid number of values for shape */,\n\t\t);\n\t}\n\n\tpublic get topLevelLength(): number {\n\t\treturn this.shape.topLevelLength;\n\t}\n\n\tpublic clone(): UniformChunk {\n\t\treturn new UniformChunk(this.shape, this.values.slice());\n\t}\n\n\tpublic cursor(): Cursor {\n\t\treturn new Cursor(this);\n\t}\n\n\tprotected onUnreferenced(): void {}\n}\n\n/**\n * The \"shape\" of a field.\n *\n * Requires that all trees in the field have the same shape, which is described by `TreeShape`.\n * Note that this requirement means that not all fields can be described using this type.\n */\nexport type FieldShape = readonly [FieldKey, TreeShape, number];\n\n/**\n * The \"shape\" of a tree.\n * Does not contain the actual values from the tree, but describes everything else,\n * including where the values would be found in a flat values array.\n *\n * Note that since this requires fields to have uniform shapes (see `FieldShape`),\n * not all trees can have their shape described using this type.\n */\nexport class TreeShape {\n\tpublic readonly fields: ReadonlyMap<FieldKey, OffsetShape>;\n\tpublic readonly fieldsOffsetArray: readonly OffsetShape[];\n\tpublic readonly valuesPerTopLevelNode: number;\n\n\t// TODO: this is only needed at chunk roots. Optimize it base on that.\n\tpublic readonly positions: readonly NodePositionInfo[];\n\n\t/**\n\t *\n\t * @param type - {@link TreeNodeSchemaIdentifier} used to compare shapes.\n\t * @param hasValue - whether or not the TreeShape has a value.\n\t * @param fieldsArray - an array of {@link FieldShape} values, which contains a TreeShape for each FieldKey.\n\t *\n\t * @param maybeDecompressedStringAsNumber - used to check whether or not the value could have been compressed by the idCompressor.\n\t * This flag can only be set on string leaf nodes, and will throw a usage error otherwise.\n\t * If set to true, an additional check can be made (example: getting the value of {@link Cursor}) to return the original uncompressed value.\n\t */\n\tpublic constructor(\n\t\tpublic readonly type: TreeNodeSchemaIdentifier,\n\t\tpublic readonly hasValue: boolean,\n\t\tpublic readonly fieldsArray: readonly FieldShape[],\n\t\tpublic readonly maybeDecompressedStringAsNumber: boolean = false,\n\t) {\n\t\tif (\n\t\t\tmaybeDecompressedStringAsNumber &&\n\t\t\t!(hasValue && type === \"com.fluidframework.leaf.string\")\n\t\t) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"maybeDecompressedStringAsNumber flag can only be set to true for string leaf node.\",\n\t\t\t);\n\t\t}\n\t\tconst fields: Map<FieldKey, OffsetShape> = new Map();\n\t\tlet numberOfValues = hasValue ? 1 : 0;\n\t\tconst infos: NodePositionInfo[] = [\n\t\t\tnew NodePositionInfo(undefined, dummyRoot, 0, undefined, undefined, this, 1, 0),\n\t\t];\n\t\tlet fieldIndex = 0;\n\t\tfor (const [k, f, length] of fieldsArray) {\n\t\t\tassert(!fields.has(k), 0x4c5 /* no duplicate keys */);\n\t\t\tconst offset = new OffsetShape(f, length, infos.length, k, fieldIndex);\n\t\t\tfields.set(k, offset);\n\t\t\tclonePositions(0, [k, f, length], fieldIndex, numberOfValues, infos);\n\t\t\tnumberOfValues += f.valuesPerTopLevelNode * length;\n\t\t\tfieldIndex++;\n\t\t}\n\t\tthis.fields = fields;\n\t\tthis.valuesPerTopLevelNode = numberOfValues;\n\t\tthis.positions = infos;\n\n\t\tthis.fieldsOffsetArray = [...fields.values()];\n\t}\n\n\tpublic equals(other: TreeShape): boolean {\n\t\t// TODO: either dedup instances and/or store a collision resistant hash for fast compare.\n\n\t\tif (\n\t\t\t!compareArrays(\n\t\t\t\tthis.fieldsArray,\n\t\t\t\tother.fieldsArray,\n\t\t\t\t([k, f, l], [k2, f2, l2]) => k === k2 && l === l2 && f.equals(f2),\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.type === other.type && this.hasValue === other.hasValue;\n\t}\n\n\tpublic withTopLevelLength(topLevelLength: number): ChunkShape {\n\t\treturn new ChunkShape(this, topLevelLength);\n\t}\n}\n\nfunction clonePositions(\n\tindexOfParentInOutput: number | undefined,\n\t[key, shape, copies]: FieldShape,\n\tindexOfParentField: number,\n\tvalueOffset: number,\n\toutputInto: NodePositionInfo[] | (NodePositionInfo | undefined)[],\n): void {\n\tconst offset = outputInto.length;\n\tfor (let index = 0; index < copies; index++) {\n\t\tfor (const inner of shape.positions) {\n\t\t\tconst wasRoot = inner.indexOfParentPosition === undefined;\n\t\t\tconst parentPositionIndex = wasRoot\n\t\t\t\t? indexOfParentInOutput\n\t\t\t\t: inner.indexOfParentPosition + index * shape.positions.length + offset;\n\t\t\toutputInto.push(\n\t\t\t\tnew NodePositionInfo(\n\t\t\t\t\tparentPositionIndex === undefined ? undefined : outputInto[parentPositionIndex],\n\t\t\t\t\tinner.parentField === dummyRoot ? key : inner.parentField,\n\t\t\t\t\twasRoot ? index : inner.parentIndex,\n\t\t\t\t\tinner.indexOfParentField ?? indexOfParentField,\n\t\t\t\t\tparentPositionIndex,\n\t\t\t\t\tinner.shape,\n\t\t\t\t\twasRoot ? copies : inner.topLevelLength,\n\t\t\t\t\tinner.valueOffset + valueOffset + shape.valuesPerTopLevelNode * index,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * The shape (see `TreeShape`) of a sequence of trees, all with the same shape (like `FieldShape`, but without a field key).\n *\n * This shape is optimized (by caching derived data like the positions array),\n * so that when paired with a value array it can be efficiently traversed like a tree by an {@link ITreeCursorSynchronous}.\n * See {@link uniformChunk} for how to do this.\n *\n * TODO: consider storing shape information in WASM\n */\nexport class ChunkShape {\n\tpublic readonly positions: readonly (NodePositionInfo | undefined)[];\n\n\tpublic constructor(\n\t\tpublic readonly treeShape: TreeShape,\n\t\tpublic readonly topLevelLength: number,\n\t) {\n\t\tassert(topLevelLength > 0, 0x4c6 /* topLevelLength must be greater than 0 */);\n\n\t\t// TODO: avoid duplication from inner loop\n\t\tconst positions: (NodePositionInfo | undefined)[] = [undefined];\n\t\tclonePositions(0, [dummyRoot, treeShape, topLevelLength], 0, 0, positions);\n\t\tthis.positions = positions;\n\t}\n\n\tpublic equals(other: ChunkShape): boolean {\n\t\t// TODO: either dedup instances and/or store a collision resistant hash for fast compare.\n\t\treturn this.topLevelLength === other.topLevelLength && this.treeShape === other.treeShape;\n\t}\n}\n\n/**\n * Shape of a field (like `FieldShape`) but with information about how it would be offset within a chunk because of its parents.\n */\nclass OffsetShape {\n\t/**\n\t * @param shape - the shape of each child in this field\n\t * @param topLevelLength - number of top level nodes in this sequence chunk (either field within a chunk, or top level chunk)\n\t * @param offset - number of nodes before this in the parent's subtree\n\t * @param key - field key\n\t * @param indexOfParentField - index of node with this shape\n\t */\n\tpublic constructor(\n\t\tpublic readonly shape: TreeShape,\n\t\tpublic readonly topLevelLength: number,\n\t\tpublic readonly offset: number,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly indexOfParentField: number | undefined,\n\t) {}\n}\n\n/**\n * Information about a node at a specific position within a uniform chunk.\n */\nclass NodePositionInfo implements UpPath {\n\t/**\n\t * @param parent - TODO\n\t * @param parentField - TODO\n\t * @param parentIndex - indexWithinParentField\n\t * @param indexOfParentField - which field of the parent `parentIndex` is indexing into to locate this.\n\t * @param indexOfParentPosition - Index of parent NodePositionInfo in positions array. TODO: use offsets to avoid copying at top level?\n\t * @param shape - Shape of the top level sequence this node is part of\n\t * @param valueOffset - TODO\n\t */\n\tpublic constructor(\n\t\tpublic readonly parent: NodePositionInfo | undefined, // TODO; general UpPath to allow prefixing here?\n\t\tpublic readonly parentField: FieldKey,\n\t\tpublic readonly parentIndex: number,\n\t\tpublic readonly indexOfParentField: number | undefined,\n\t\tpublic readonly indexOfParentPosition: number | undefined,\n\t\tpublic readonly shape: TreeShape, // Shape of sequence that contains this node (top level is parent of this node)\n\t\tpublic readonly topLevelLength: number,\n\t\tpublic readonly valueOffset: number,\n\t) {}\n}\n\n/**\n * The cursor implementation for `UniformChunk`.\n *\n * Works by tracking its location in the chunk's `positions` array.\n */\nclass Cursor extends SynchronousCursor implements ChunkedCursor {\n\tprivate positionIndex!: number; // When in fields mode, this points to the parent node.\n\t// Undefined when in root field\n\tprivate nodePositionInfo: NodePositionInfo | undefined;\n\n\t// Cached constants for faster access\n\tprivate readonly shape: ChunkShape;\n\tprivate readonly positions: readonly (NodePositionInfo | undefined)[];\n\n\tpublic mode: CursorLocationType = CursorLocationType.Fields;\n\n\t// Undefined when not in fields mode.\n\tprivate fieldKey?: FieldKey;\n\n\t// Valid only in fields mode. Can be past end for empty fields.\n\t// This is redundant with fieldKey above (but might be worth keeping for perf), and could be removed.\n\tprivate indexOfField: number = 0;\n\n\t// TODO: support prefix (path above root, including index offset of chunk in its containing field)\n\tpublic constructor(private readonly chunk: UniformChunk) {\n\t\tsuper();\n\t\tthis.shape = this.chunk.shape;\n\t\tthis.positions = this.shape.positions;\n\t\tthis.fieldKey = dummyRoot;\n\t\tthis.moveToPosition(0);\n\t}\n\n\tpublic get [cursorChunk](): UniformChunk | undefined {\n\t\treturn this.atChunkRoot() ? this.chunk : undefined;\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\tassert(\n\t\t\t(this.fieldKey === undefined) === (this.mode === CursorLocationType.Nodes),\n\t\t\t0x560 /* expect valid field key */,\n\t\t);\n\t\treturn (\n\t\t\tthis.nodePositionInfo === undefined ||\n\t\t\t(this.nodePositionInfo.parent === undefined && this.fieldKey === undefined)\n\t\t);\n\t}\n\n\tpublic fork(): Cursor {\n\t\tconst cursor = new Cursor(this.chunk);\n\t\tcursor.mode = this.mode;\n\t\tcursor.fieldKey = this.fieldKey;\n\t\tcursor.indexOfField = this.indexOfField;\n\t\tcursor.moveToPosition(this.positionIndex);\n\t\treturn cursor;\n\t}\n\n\t/**\n\t * Change the current node within the chunk.\n\t * See `nodeInfo` for getting data about the current node.\n\t *\n\t * @param positionIndex - index of the position of the newly selected node in `positions`.\n\t * This is NOT an index within a field, and is not bounds checked.\n\t */\n\tprivate moveToPosition(positionIndex: number): void {\n\t\tthis.nodePositionInfo = this.positions[positionIndex];\n\t\tthis.positionIndex = positionIndex;\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\tassert(positionIndex === 0, 0x561 /* expected root at start */);\n\t\t\tassert(this.mode === CursorLocationType.Fields, 0x562 /* expected root to be a field */);\n\t\t}\n\t}\n\n\t/**\n\t * Gets information about the current node.\n\t *\n\t * When in Nodes mode, this means the node this cursor is current at.\n\t * When if fields mode, this means the node which is the parent of the current field.\n\t * This cursor is in Nodes mode at the root, so there is no case where a fields mode does not have a parent.\n\t *\n\t * @param requiredMode - asserts that the mode matches this. Since the semantics of this function are somewhat mode dependent,\n\t * providing this ensures that the caller knows what the results will mean.\n\t */\n\tprivate nodeInfo(requiredMode: CursorLocationType): NodePositionInfo {\n\t\tassert(this.mode === requiredMode, 0x4c8 /* tried to access cursor when in wrong mode */);\n\t\tassert(\n\t\t\tthis.nodePositionInfo !== undefined,\n\t\t\t0x53e /* can not access nodeInfo in root field */,\n\t\t);\n\t\treturn this.nodePositionInfo;\n\t}\n\n\tpublic nextField(): boolean {\n\t\tthis.indexOfField++;\n\t\tconst fields = this.nodeInfo(CursorLocationType.Fields).shape.fieldsArray;\n\t\tif (this.indexOfField < fields.length) {\n\t\t\tconst fieldArr = fields[this.indexOfField] ?? oob();\n\t\t\tthis.fieldKey = fieldArr[0];\n\t\t\treturn true;\n\t\t}\n\t\tthis.exitField();\n\t\treturn false;\n\t}\n\n\tpublic exitField(): void {\n\t\tassert(this.mode === CursorLocationType.Fields, 0x4c9 /* exitField when in wrong mode */);\n\t\tassert(this.nodePositionInfo !== undefined, 0x563 /* can not exit root field */);\n\t\tthis.fieldKey = undefined;\n\t\tthis.mode = CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\treturn this.fieldKey ?? fail(\"not in a field\");\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x53f /* tried to access cursor when in wrong mode */,\n\t\t);\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\treturn this.shape.topLevelLength;\n\t\t}\n\t\tconst fieldInfo = this.nodePositionInfo.shape.fieldsArray[this.indexOfField];\n\t\tif (fieldInfo === undefined) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn fieldInfo[2];\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x540 /* tried to access cursor when in wrong mode */,\n\t\t);\n\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\t// Root field is not allowed to be empty, so we can skip handling that case.\n\t\t\tthis.enterRootNodeInner(0);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn this.enterNodeInner(this.nodePositionInfo, 0);\n\t\t}\n\t}\n\n\tpublic enterNode(childIndex: number): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x541 /* tried to access cursor when in wrong mode */,\n\t\t);\n\t\tassert(childIndex >= 0, 0x4ca /* index must be positive */);\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\tassert(\n\t\t\t\tchildIndex < this.shape.topLevelLength,\n\t\t\t\t0x542 /* index must not be past the end of the field */,\n\t\t\t);\n\t\t\tthis.enterRootNodeInner(childIndex);\n\t\t} else {\n\t\t\tconst moved = this.enterNodeInner(this.nodePositionInfo, childIndex);\n\t\t\tassert(moved, 0x4cb /* index must not be past the end of the field */);\n\t\t}\n\t}\n\n\t/**\n\t * Enter the current field, at `childIndex`.\n\t * @param childIndex - index into current field to navigate to. Must be non-negative integer.\n\t */\n\tprivate enterNodeInner(currentPosition: NodePositionInfo, childIndex: number): boolean {\n\t\tconst shape = currentPosition.shape;\n\t\tconst fields = shape.fieldsOffsetArray;\n\t\tif (this.indexOfField >= fields.length) {\n\t\t\treturn false; // Handle empty field (indexed by key into empty field)\n\t\t}\n\t\tconst f = shape.fieldsOffsetArray[this.indexOfField] ?? oob();\n\t\tif (childIndex >= f.topLevelLength) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.mode = CursorLocationType.Nodes;\n\t\tthis.fieldKey = undefined;\n\t\tthis.moveToPosition(this.positionIndex + f.offset + childIndex * f.shape.positions.length);\n\t\tassert(this.fieldIndex === childIndex, 0x4cc /* should be at selected child */);\n\t\treturn true;\n\t}\n\n\tprivate enterRootNodeInner(childIndex: number): void {\n\t\tthis.mode = CursorLocationType.Nodes;\n\t\tthis.fieldKey = undefined;\n\t\t// 1 for the \"undefined\" at the beginning of the positions array, then stride by top level tree shape.\n\t\tthis.moveToPosition(1 + childIndex * this.shape.treeShape.positions.length);\n\t\tassert(this.fieldIndex === childIndex, 0x543 /* should be at selected child */);\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, {\n\t\t\tfield: this.getFieldKey(),\n\t\t\tparent: this.nodePositionInfo,\n\t\t});\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath | undefined {\n\t\treturn prefixPath(prefix, this.nodeInfo(CursorLocationType.Nodes));\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).parentIndex;\n\t}\n\n\tpublic readonly chunkStart: number = 0;\n\n\tpublic get chunkLength(): number {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).topLevelLength;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tconst index = offset + info.parentIndex;\n\t\tif (index >= 0 && index < info.topLevelLength) {\n\t\t\tthis.moveToPosition(this.positionIndex + offset * info.shape.positions.length);\n\t\t\treturn true;\n\t\t}\n\t\tthis.exitNode();\n\t\treturn false;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\t// This is the same as `return this.seekNodes(1);` but slightly faster.\n\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tconst index = info.parentIndex + 1;\n\t\tif (index === info.topLevelLength) {\n\t\t\tthis.exitNode();\n\t\t\treturn false;\n\t\t}\n\t\tthis.moveToPosition(this.positionIndex + info.shape.positions.length);\n\t\treturn true;\n\t}\n\n\tpublic exitNode(): void {\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tthis.indexOfField =\n\t\t\tinfo.indexOfParentField ?? fail(\"navigation up to root field not yet supported\"); // TODO;\n\t\tthis.fieldKey = info.parentField;\n\t\tthis.mode = CursorLocationType.Fields;\n\t\tthis.moveToPosition(\n\t\t\tinfo.indexOfParentPosition ?? fail(\"navigation up to root field not yet supported\"),\n\t\t); // TODO\n\t}\n\n\tpublic firstField(): boolean {\n\t\tconst fieldsArray = this.nodeInfo(CursorLocationType.Nodes).shape.fieldsArray;\n\t\tif (fieldsArray.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.indexOfField = 0;\n\t\tthis.mode = CursorLocationType.Fields;\n\t\tconst fields = fieldsArray[0] ?? oob();\n\t\tthis.fieldKey = fields[0];\n\t\treturn true;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tconst fieldMap = this.nodeInfo(CursorLocationType.Nodes).shape.fields;\n\t\tconst fieldInfo = fieldMap.get(key);\n\t\tthis.indexOfField =\n\t\t\tfieldInfo === undefined\n\t\t\t\t? fieldMap.size\n\t\t\t\t: fieldInfo.indexOfParentField ?? fail(\"children should have parents\");\n\t\tthis.fieldKey = key;\n\t\tthis.mode = CursorLocationType.Fields;\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).shape.type;\n\t}\n\n\tpublic get value(): Value {\n\t\tconst idCompressor = this.chunk.idCompressor;\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\t// If the maybeDecompressedStringAsNumber flag is set to true, we check if the value is a number.\n\t\t// This flag can only ever be set on string leaf nodes, so if the value is a number, we can assume it is a compressible, known stable id.\n\t\tif (info.shape.hasValue && info.shape.maybeDecompressedStringAsNumber) {\n\t\t\tconst value = this.chunk.values[info.valueOffset];\n\t\t\tif (typeof value === \"number\" && idCompressor !== undefined) {\n\t\t\t\treturn idCompressor.decompress(value as SessionSpaceCompressedId);\n\t\t\t}\n\t\t}\n\t\treturn info.shape.hasValue ? this.chunk.values[info.valueOffset] : undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"uniformChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/uniformChunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAiF;AAYjF,kDAAiE;AACjE,8DAAuF;AAEvF,yCAAwF;AAExF,uEAAsE;AAEtE;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAiB,EAAE,MAAmB;IAClE,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,MAAa,YAAa,SAAQ,+BAAoB;IAErD;;;;;OAKG;IACH,YACQ,KAAiB,EACjB,MAAmB,EAC1B,YAA4B;QAE5B,KAAK,EAAE,CAAC;QAJD,UAAK,GAAL,KAAK,CAAY;QACjB,WAAM,GAAN,MAAM,CAAa;QAI1B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAA,iBAAM,EACL,KAAK,CAAC,SAAS,CAAC,qBAAqB,GAAG,KAAK,CAAC,cAAc,KAAK,MAAM,CAAC,MAAM,EAC9E,KAAK,CAAC,wCAAwC,CAC9C,CAAC;IACH,CAAC;I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MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;gBAC7D,OAAO,YAAY,CAAC,UAAU,CAAC,KAAiC,CAAC,CAAC;YACnE,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixFieldPath, prefixPath } from \"../treeCursorUtils.js\";\n\nimport { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from \"./chunk.js\";\nimport type { SessionSpaceCompressedId, IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Create a tree chunk with ref count 1.\n *\n * @param shape - describes the semantics and layout of `values`.\n * @param values - provides exclusive ownership of this array to this object (which might mutate it in the future).\n */\nexport function uniformChunk(shape: ChunkShape, values: TreeValue[]): TreeChunk {\n\treturn new UniformChunk(shape, values);\n}\n\n/**\n * Chunk which handles a sequence of trees with identical \"shape\" (see `TreeShape`).\n *\n * Separates shape from content,\n * allowing deduplication of shape information and storing of content as a flat sequence of values.\n */\nexport class UniformChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic idCompressor: undefined | IIdCompressor;\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * @param shape - describes the semantics and layout of `values`.\n\t * @param values - provides exclusive ownership of this array to this object (which might mutate it in the future).\n\t */\n\tpublic constructor(\n\t\tpublic shape: ChunkShape,\n\t\tpublic values: TreeValue[],\n\t\tidCompressor?: IIdCompressor,\n\t) {\n\t\tsuper();\n\t\tthis.idCompressor = idCompressor;\n\t\tassert(\n\t\t\tshape.treeShape.valuesPerTopLevelNode * shape.topLevelLength === values.length,\n\t\t\t0x4c3 /* invalid number of values for shape */,\n\t\t);\n\t}\n\n\tpublic get topLevelLength(): number {\n\t\treturn this.shape.topLevelLength;\n\t}\n\n\tpublic clone(): UniformChunk {\n\t\treturn new UniformChunk(this.shape, this.values.slice());\n\t}\n\n\tpublic cursor(): Cursor {\n\t\treturn new Cursor(this);\n\t}\n\n\tprotected onUnreferenced(): void {}\n}\n\n/**\n * The \"shape\" of a field.\n *\n * Requires that all trees in the field have the same shape, which is described by `TreeShape`.\n * Note that this requirement means that not all fields can be described using this type.\n */\nexport type FieldShape = readonly [FieldKey, TreeShape, number];\n\n/**\n * The \"shape\" of a tree.\n * Does not contain the actual values from the tree, but describes everything else,\n * including where the values would be found in a flat values array.\n *\n * Note that since this requires fields to have uniform shapes (see `FieldShape`),\n * not all trees can have their shape described using this type.\n */\nexport class TreeShape {\n\tpublic readonly fields: ReadonlyMap<FieldKey, OffsetShape>;\n\tpublic readonly fieldsOffsetArray: readonly OffsetShape[];\n\tpublic readonly valuesPerTopLevelNode: number;\n\n\t// TODO: this is only needed at chunk roots. Optimize it base on that.\n\tpublic readonly positions: readonly NodePositionInfo[];\n\n\t/**\n\t *\n\t * @param type - {@link TreeNodeSchemaIdentifier} used to compare shapes.\n\t * @param hasValue - whether or not the TreeShape has a value.\n\t * @param fieldsArray - an array of {@link FieldShape} values, which contains a TreeShape for each FieldKey.\n\t *\n\t * @param maybeDecompressedStringAsNumber - used to check whether or not the value could have been compressed by the idCompressor.\n\t * This flag can only be set on string leaf nodes, and will throw a usage error otherwise.\n\t * If set to true, an additional check can be made (example: getting the value of {@link Cursor}) to return the original uncompressed value.\n\t */\n\tpublic constructor(\n\t\tpublic readonly type: TreeNodeSchemaIdentifier,\n\t\tpublic readonly hasValue: boolean,\n\t\tpublic readonly fieldsArray: readonly FieldShape[],\n\t\tpublic readonly maybeDecompressedStringAsNumber: boolean = false,\n\t) {\n\t\tif (\n\t\t\tmaybeDecompressedStringAsNumber &&\n\t\t\t!(hasValue && type === \"com.fluidframework.leaf.string\")\n\t\t) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"maybeDecompressedStringAsNumber flag can only be set to true for string leaf node.\",\n\t\t\t);\n\t\t}\n\t\tconst fields: Map<FieldKey, OffsetShape> = new Map();\n\t\tlet numberOfValues = hasValue ? 1 : 0;\n\t\tconst infos: NodePositionInfo[] = [\n\t\t\tnew NodePositionInfo(undefined, dummyRoot, 0, undefined, undefined, this, 1, 0),\n\t\t];\n\t\tlet fieldIndex = 0;\n\t\tfor (const [k, f, length] of fieldsArray) {\n\t\t\tassert(!fields.has(k), 0x4c5 /* no duplicate keys */);\n\t\t\tconst offset = new OffsetShape(f, length, infos.length, k, fieldIndex);\n\t\t\tfields.set(k, offset);\n\t\t\tclonePositions(0, [k, f, length], fieldIndex, numberOfValues, infos);\n\t\t\tnumberOfValues += f.valuesPerTopLevelNode * length;\n\t\t\tfieldIndex++;\n\t\t}\n\t\tthis.fields = fields;\n\t\tthis.valuesPerTopLevelNode = numberOfValues;\n\t\tthis.positions = infos;\n\n\t\tthis.fieldsOffsetArray = [...fields.values()];\n\t}\n\n\tpublic equals(other: TreeShape): boolean {\n\t\t// TODO: either dedup instances and/or store a collision resistant hash for fast compare.\n\n\t\tif (\n\t\t\t!compareArrays(\n\t\t\t\tthis.fieldsArray,\n\t\t\t\tother.fieldsArray,\n\t\t\t\t([k, f, l], [k2, f2, l2]) => k === k2 && l === l2 && f.equals(f2),\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.type === other.type && this.hasValue === other.hasValue;\n\t}\n\n\tpublic withTopLevelLength(topLevelLength: number): ChunkShape {\n\t\treturn new ChunkShape(this, topLevelLength);\n\t}\n}\n\nfunction clonePositions(\n\tindexOfParentInOutput: number | undefined,\n\t[key, shape, copies]: FieldShape,\n\tindexOfParentField: number,\n\tvalueOffset: number,\n\toutputInto: NodePositionInfo[] | (NodePositionInfo | undefined)[],\n): void {\n\tconst offset = outputInto.length;\n\tfor (let index = 0; index < copies; index++) {\n\t\tfor (const inner of shape.positions) {\n\t\t\tconst wasRoot = inner.indexOfParentPosition === undefined;\n\t\t\tconst parentPositionIndex = wasRoot\n\t\t\t\t? indexOfParentInOutput\n\t\t\t\t: inner.indexOfParentPosition + index * shape.positions.length + offset;\n\t\t\toutputInto.push(\n\t\t\t\tnew NodePositionInfo(\n\t\t\t\t\tparentPositionIndex === undefined ? undefined : outputInto[parentPositionIndex],\n\t\t\t\t\tinner.parentField === dummyRoot ? key : inner.parentField,\n\t\t\t\t\twasRoot ? index : inner.parentIndex,\n\t\t\t\t\tinner.indexOfParentField ?? indexOfParentField,\n\t\t\t\t\tparentPositionIndex,\n\t\t\t\t\tinner.shape,\n\t\t\t\t\twasRoot ? copies : inner.topLevelLength,\n\t\t\t\t\tinner.valueOffset + valueOffset + shape.valuesPerTopLevelNode * index,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * The shape (see `TreeShape`) of a sequence of trees, all with the same shape (like `FieldShape`, but without a field key).\n *\n * This shape is optimized (by caching derived data like the positions array),\n * so that when paired with a value array it can be efficiently traversed like a tree by an {@link ITreeCursorSynchronous}.\n * See {@link uniformChunk} for how to do this.\n *\n * TODO: consider storing shape information in WASM\n */\nexport class ChunkShape {\n\tpublic readonly positions: readonly (NodePositionInfo | undefined)[];\n\n\tpublic constructor(\n\t\tpublic readonly treeShape: TreeShape,\n\t\tpublic readonly topLevelLength: number,\n\t) {\n\t\tassert(topLevelLength > 0, 0x4c6 /* topLevelLength must be greater than 0 */);\n\n\t\t// TODO: avoid duplication from inner loop\n\t\tconst positions: (NodePositionInfo | undefined)[] = [undefined];\n\t\tclonePositions(0, [dummyRoot, treeShape, topLevelLength], 0, 0, positions);\n\t\tthis.positions = positions;\n\t}\n\n\tpublic equals(other: ChunkShape): boolean {\n\t\t// TODO: either dedup instances and/or store a collision resistant hash for fast compare.\n\t\treturn this.topLevelLength === other.topLevelLength && this.treeShape === other.treeShape;\n\t}\n}\n\n/**\n * Shape of a field (like `FieldShape`) but with information about how it would be offset within a chunk because of its parents.\n */\nclass OffsetShape {\n\t/**\n\t * @param shape - the shape of each child in this field\n\t * @param topLevelLength - number of top level nodes in this sequence chunk (either field within a chunk, or top level chunk)\n\t * @param offset - number of nodes before this in the parent's subtree\n\t * @param key - field key\n\t * @param indexOfParentField - index of node with this shape\n\t */\n\tpublic constructor(\n\t\tpublic readonly shape: TreeShape,\n\t\tpublic readonly topLevelLength: number,\n\t\tpublic readonly offset: number,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly indexOfParentField: number | undefined,\n\t) {}\n}\n\n/**\n * Information about a node at a specific position within a uniform chunk.\n */\nclass NodePositionInfo implements UpPath {\n\t/**\n\t * @param parent - TODO\n\t * @param parentField - TODO\n\t * @param parentIndex - indexWithinParentField\n\t * @param indexOfParentField - which field of the parent `parentIndex` is indexing into to locate this.\n\t * @param indexOfParentPosition - Index of parent NodePositionInfo in positions array. TODO: use offsets to avoid copying at top level?\n\t * @param shape - Shape of the top level sequence this node is part of\n\t * @param valueOffset - TODO\n\t */\n\tpublic constructor(\n\t\tpublic readonly parent: NodePositionInfo | undefined, // TODO; general UpPath to allow prefixing here?\n\t\tpublic readonly parentField: FieldKey,\n\t\tpublic readonly parentIndex: number,\n\t\tpublic readonly indexOfParentField: number | undefined,\n\t\tpublic readonly indexOfParentPosition: number | undefined,\n\t\tpublic readonly shape: TreeShape, // Shape of sequence that contains this node (top level is parent of this node)\n\t\tpublic readonly topLevelLength: number,\n\t\tpublic readonly valueOffset: number,\n\t) {}\n}\n\n/**\n * The cursor implementation for `UniformChunk`.\n *\n * Works by tracking its location in the chunk's `positions` array.\n */\nclass Cursor extends SynchronousCursor implements ChunkedCursor {\n\tprivate positionIndex!: number; // When in fields mode, this points to the parent node.\n\t// Undefined when in root field\n\tprivate nodePositionInfo: NodePositionInfo | undefined;\n\n\t// Cached constants for faster access\n\tprivate readonly shape: ChunkShape;\n\tprivate readonly positions: readonly (NodePositionInfo | undefined)[];\n\n\tpublic mode: CursorLocationType = CursorLocationType.Fields;\n\n\t// Undefined when not in fields mode.\n\tprivate fieldKey?: FieldKey;\n\n\t// Valid only in fields mode. Can be past end for empty fields.\n\t// This is redundant with fieldKey above (but might be worth keeping for perf), and could be removed.\n\tprivate indexOfField: number = 0;\n\n\t// TODO: support prefix (path above root, including index offset of chunk in its containing field)\n\tpublic constructor(private readonly chunk: UniformChunk) {\n\t\tsuper();\n\t\tthis.shape = this.chunk.shape;\n\t\tthis.positions = this.shape.positions;\n\t\tthis.fieldKey = dummyRoot;\n\t\tthis.moveToPosition(0);\n\t}\n\n\tpublic get [cursorChunk](): UniformChunk | undefined {\n\t\treturn this.atChunkRoot() ? this.chunk : undefined;\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\tassert(\n\t\t\t(this.fieldKey === undefined) === (this.mode === CursorLocationType.Nodes),\n\t\t\t0x560 /* expect valid field key */,\n\t\t);\n\t\treturn (\n\t\t\tthis.nodePositionInfo === undefined ||\n\t\t\t(this.nodePositionInfo.parent === undefined && this.fieldKey === undefined)\n\t\t);\n\t}\n\n\tpublic fork(): Cursor {\n\t\tconst cursor = new Cursor(this.chunk);\n\t\tcursor.mode = this.mode;\n\t\tcursor.fieldKey = this.fieldKey;\n\t\tcursor.indexOfField = this.indexOfField;\n\t\tcursor.moveToPosition(this.positionIndex);\n\t\treturn cursor;\n\t}\n\n\t/**\n\t * Change the current node within the chunk.\n\t * See `nodeInfo` for getting data about the current node.\n\t *\n\t * @param positionIndex - index of the position of the newly selected node in `positions`.\n\t * This is NOT an index within a field, and is not bounds checked.\n\t */\n\tprivate moveToPosition(positionIndex: number): void {\n\t\tthis.nodePositionInfo = this.positions[positionIndex];\n\t\tthis.positionIndex = positionIndex;\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\tassert(positionIndex === 0, 0x561 /* expected root at start */);\n\t\t\tassert(this.mode === CursorLocationType.Fields, 0x562 /* expected root to be a field */);\n\t\t}\n\t}\n\n\t/**\n\t * Gets information about the current node.\n\t *\n\t * When in Nodes mode, this means the node this cursor is current at.\n\t * When if fields mode, this means the node which is the parent of the current field.\n\t * This cursor is in Nodes mode at the root, so there is no case where a fields mode does not have a parent.\n\t *\n\t * @param requiredMode - asserts that the mode matches this. Since the semantics of this function are somewhat mode dependent,\n\t * providing this ensures that the caller knows what the results will mean.\n\t */\n\tprivate nodeInfo(requiredMode: CursorLocationType): NodePositionInfo {\n\t\tassert(this.mode === requiredMode, 0x4c8 /* tried to access cursor when in wrong mode */);\n\t\tassert(\n\t\t\tthis.nodePositionInfo !== undefined,\n\t\t\t0x53e /* can not access nodeInfo in root field */,\n\t\t);\n\t\treturn this.nodePositionInfo;\n\t}\n\n\tpublic nextField(): boolean {\n\t\tthis.indexOfField++;\n\t\tconst fields = this.nodeInfo(CursorLocationType.Fields).shape.fieldsArray;\n\t\tif (this.indexOfField < fields.length) {\n\t\t\tconst fieldArr = fields[this.indexOfField] ?? oob();\n\t\t\tthis.fieldKey = fieldArr[0];\n\t\t\treturn true;\n\t\t}\n\t\tthis.exitField();\n\t\treturn false;\n\t}\n\n\tpublic exitField(): void {\n\t\tassert(this.mode === CursorLocationType.Fields, 0x4c9 /* exitField when in wrong mode */);\n\t\tassert(this.nodePositionInfo !== undefined, 0x563 /* can not exit root field */);\n\t\tthis.fieldKey = undefined;\n\t\tthis.mode = CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\treturn this.fieldKey ?? fail(\"not in a field\");\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x53f /* tried to access cursor when in wrong mode */,\n\t\t);\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\treturn this.shape.topLevelLength;\n\t\t}\n\t\tconst fieldInfo = this.nodePositionInfo.shape.fieldsArray[this.indexOfField];\n\t\tif (fieldInfo === undefined) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn fieldInfo[2];\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x540 /* tried to access cursor when in wrong mode */,\n\t\t);\n\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\t// Root field is not allowed to be empty, so we can skip handling that case.\n\t\t\tthis.enterRootNodeInner(0);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn this.enterNodeInner(this.nodePositionInfo, 0);\n\t\t}\n\t}\n\n\tpublic enterNode(childIndex: number): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x541 /* tried to access cursor when in wrong mode */,\n\t\t);\n\t\tassert(childIndex >= 0, 0x4ca /* index must be positive */);\n\t\tif (this.nodePositionInfo === undefined) {\n\t\t\tassert(\n\t\t\t\tchildIndex < this.shape.topLevelLength,\n\t\t\t\t0x542 /* index must not be past the end of the field */,\n\t\t\t);\n\t\t\tthis.enterRootNodeInner(childIndex);\n\t\t} else {\n\t\t\tconst moved = this.enterNodeInner(this.nodePositionInfo, childIndex);\n\t\t\tassert(moved, 0x4cb /* index must not be past the end of the field */);\n\t\t}\n\t}\n\n\t/**\n\t * Enter the current field, at `childIndex`.\n\t * @param childIndex - index into current field to navigate to. Must be non-negative integer.\n\t */\n\tprivate enterNodeInner(currentPosition: NodePositionInfo, childIndex: number): boolean {\n\t\tconst shape = currentPosition.shape;\n\t\tconst fields = shape.fieldsOffsetArray;\n\t\tif (this.indexOfField >= fields.length) {\n\t\t\treturn false; // Handle empty field (indexed by key into empty field)\n\t\t}\n\t\tconst f = shape.fieldsOffsetArray[this.indexOfField] ?? oob();\n\t\tif (childIndex >= f.topLevelLength) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.mode = CursorLocationType.Nodes;\n\t\tthis.fieldKey = undefined;\n\t\tthis.moveToPosition(this.positionIndex + f.offset + childIndex * f.shape.positions.length);\n\t\tassert(this.fieldIndex === childIndex, 0x4cc /* should be at selected child */);\n\t\treturn true;\n\t}\n\n\tprivate enterRootNodeInner(childIndex: number): void {\n\t\tthis.mode = CursorLocationType.Nodes;\n\t\tthis.fieldKey = undefined;\n\t\t// 1 for the \"undefined\" at the beginning of the positions array, then stride by top level tree shape.\n\t\tthis.moveToPosition(1 + childIndex * this.shape.treeShape.positions.length);\n\t\tassert(this.fieldIndex === childIndex, 0x543 /* should be at selected child */);\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\treturn prefixFieldPath(prefix, {\n\t\t\tfield: this.getFieldKey(),\n\t\t\tparent: this.nodePositionInfo,\n\t\t});\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath | undefined {\n\t\treturn prefixPath(prefix, this.nodeInfo(CursorLocationType.Nodes));\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).parentIndex;\n\t}\n\n\tpublic readonly chunkStart: number = 0;\n\n\tpublic get chunkLength(): number {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).topLevelLength;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tconst index = offset + info.parentIndex;\n\t\tif (index >= 0 && index < info.topLevelLength) {\n\t\t\tthis.moveToPosition(this.positionIndex + offset * info.shape.positions.length);\n\t\t\treturn true;\n\t\t}\n\t\tthis.exitNode();\n\t\treturn false;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\t// This is the same as `return this.seekNodes(1);` but slightly faster.\n\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tconst index = info.parentIndex + 1;\n\t\tif (index === info.topLevelLength) {\n\t\t\tthis.exitNode();\n\t\t\treturn false;\n\t\t}\n\t\tthis.moveToPosition(this.positionIndex + info.shape.positions.length);\n\t\treturn true;\n\t}\n\n\tpublic exitNode(): void {\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\tthis.indexOfField =\n\t\t\tinfo.indexOfParentField ?? fail(\"navigation up to root field not yet supported\"); // TODO;\n\t\tthis.fieldKey = info.parentField;\n\t\tthis.mode = CursorLocationType.Fields;\n\t\tthis.moveToPosition(\n\t\t\tinfo.indexOfParentPosition ?? fail(\"navigation up to root field not yet supported\"),\n\t\t); // TODO\n\t}\n\n\tpublic firstField(): boolean {\n\t\tconst fieldsArray = this.nodeInfo(CursorLocationType.Nodes).shape.fieldsArray;\n\t\tif (fieldsArray.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.indexOfField = 0;\n\t\tthis.mode = CursorLocationType.Fields;\n\t\tconst fields = fieldsArray[0] ?? oob();\n\t\tthis.fieldKey = fields[0];\n\t\treturn true;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tconst fieldMap = this.nodeInfo(CursorLocationType.Nodes).shape.fields;\n\t\tconst fieldInfo = fieldMap.get(key);\n\t\tthis.indexOfField =\n\t\t\tfieldInfo === undefined\n\t\t\t\t? fieldMap.size\n\t\t\t\t: (fieldInfo.indexOfParentField ?? fail(\"children should have parents\"));\n\t\tthis.fieldKey = key;\n\t\tthis.mode = CursorLocationType.Fields;\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.nodeInfo(CursorLocationType.Nodes).shape.type;\n\t}\n\n\tpublic get value(): Value {\n\t\tconst idCompressor = this.chunk.idCompressor;\n\t\tconst info = this.nodeInfo(CursorLocationType.Nodes);\n\t\t// If the maybeDecompressedStringAsNumber flag is set to true, we check if the value is a number.\n\t\t// This flag can only ever be set on string leaf nodes, so if the value is a number, we can assume it is a compressible, known stable id.\n\t\tif (info.shape.hasValue && info.shape.maybeDecompressedStringAsNumber) {\n\t\t\tconst value = this.chunk.values[info.valueOffset];\n\t\t\tif (typeof value === \"number\" && idCompressor !== undefined) {\n\t\t\t\treturn idCompressor.decompress(value as SessionSpaceCompressedId);\n\t\t\t}\n\t\t}\n\t\treturn info.shape.hasValue ? this.chunk.values[info.valueOffset] : undefined;\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type AnchorNode, type ExclusiveMapTree, type FieldKey, type FieldKindIdentifier, type FieldUpPath, type TreeNodeSchemaIdentifier, type TreeValue } from "../../core/index.js";
|
|
5
|
+
import { type AnchorNode, type ExclusiveMapTree, type FieldKey, type FieldKindIdentifier, type FieldUpPath, type ITreeCursorSynchronous, type TreeNodeSchemaIdentifier, type TreeValue } from "../../core/index.js";
|
|
6
6
|
import type { FieldKinds, SequenceFieldEditBuilder, ValueFieldEditBuilder, OptionalFieldEditBuilder } from "../default-schema/index.js";
|
|
7
7
|
import type { FlexFieldKind } from "../modular-schema/index.js";
|
|
8
8
|
import type { FlexTreeContext } from "./context.js";
|
|
@@ -146,6 +146,13 @@ export interface FlexTreeNode extends FlexTreeEntity {
|
|
|
146
146
|
* If well-formed, it must follow this schema.
|
|
147
147
|
*/
|
|
148
148
|
readonly schema: TreeNodeSchemaIdentifier;
|
|
149
|
+
/**
|
|
150
|
+
* Get a cursor for the underlying data.
|
|
151
|
+
* @remarks
|
|
152
|
+
* 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.
|
|
153
|
+
* Must not be held onto across edits or any other tree API use.
|
|
154
|
+
*/
|
|
155
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
149
156
|
}
|
|
150
157
|
/**
|
|
151
158
|
* A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.
|
|
@@ -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,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,YAAY,wDAA6B,CAAC;AAEvD;;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;CAClC;AAED;;;GAGG;AACH,oBAAY,UAAU;IACrB;;OAEG;IACH,UAAU,IAAI;IAEd;;OAEG;IACH,OAAO,IAAI;IAEX;;OAEG;IACH,OAAO,IAAI;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,IAAI;CACP;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAa,SA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AAS,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;AA6BD;;;GAGG;AACH,IAAY,UAkCX;AAlCD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,yCAAO,CAAA;AACR,CAAC,EAlCW,UAAU,0BAAV,UAAU,QAkCrB","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 ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldUpPath,\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 { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext } 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<FlexTreeNode>();\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 */\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 * - `Tree.shortId` (when the identifier was explicitly specified and thus works at all) will just return the full identifier as a string,\n\t * but might return a compressed form as a number once hydrated.\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 * 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\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\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(): FieldUpPath;\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 = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\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,kDAU6B;AAW7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAgB,CAAC;AAEvD;;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;AA6BD;;;GAGG;AACH,IAAY,UAkCX;AAlCD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,yCAAO,CAAA;AACR,CAAC,EAlCW,UAAU,0BAAV,UAAU,QAkCrB","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 ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\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 { FlexFieldKind } from \"../modular-schema/index.js\";\n\nimport type { FlexTreeContext } 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<FlexTreeNode>();\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 */\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 * - `Tree.shortId` (when the identifier was explicitly specified and thus works at all) will just return the full identifier as a string,\n\t * but might return a compressed form as a number once hydrated.\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 * 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\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\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(): FieldUpPath;\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 = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\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"]}
|
|
@@ -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 Anchor, type AnchorNode, type FieldKey, type ITreeSubscriptionCursor, type TreeNavigationResult, type TreeNodeSchemaIdentifier, type Value } from "../../core/index.js";
|
|
5
|
+
import { type Anchor, type AnchorNode, type FieldKey, type ITreeCursorSynchronous, type ITreeSubscriptionCursor, type TreeNavigationResult, type TreeNodeSchemaIdentifier, type Value } from "../../core/index.js";
|
|
6
6
|
import type { Context } from "./context.js";
|
|
7
7
|
import { FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, flexTreeMarker } from "./flexTreeTypes.js";
|
|
8
8
|
import { LazyEntity, forgetAnchorSymbol, tryMoveCursorToAnchorSymbol } from "./lazyEntity.js";
|
|
@@ -20,6 +20,7 @@ export declare class LazyTreeNode extends LazyEntity<Anchor> implements FlexTree
|
|
|
20
20
|
get [flexTreeMarker](): FlexTreeEntityKind.Node;
|
|
21
21
|
private readonly storedSchema;
|
|
22
22
|
constructor(context: Context, schema: TreeNodeSchemaIdentifier, cursor: ITreeSubscriptionCursor, anchorNode: AnchorNode, anchor: Anchor);
|
|
23
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
23
24
|
protected [tryMoveCursorToAnchorSymbol](cursor: ITreeSubscriptionCursor): TreeNavigationResult;
|
|
24
25
|
protected [forgetAnchorSymbol](): void;
|
|
25
26
|
get value(): Value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyNode.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,UAAU,EAEf,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"lazyNode.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,UAAU,EAEf,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAE3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAE7B,KAAK,KAAK,EAIV,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACN,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,cAAc,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,UAAU,EAGV,kBAAkB,EAClB,2BAA2B,EAC3B,MAAM,iBAAiB,CAAC;AAGzB;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,YAAY,CAaxF;AAQD;;GAEG;AACH,qBAAa,YAAa,SAAQ,UAAU,CAAC,MAAM,CAAE,YAAW,YAAY;;aAY1D,MAAM,EAAE,wBAAwB;aAEhC,UAAU,EAAE,UAAU;IAbvC,IAAW,CAAC,cAAc,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAErD;IAKD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;gBAGnD,OAAO,EAAE,OAAO,EACA,MAAM,EAAE,wBAAwB,EAChD,MAAM,EAAE,uBAAuB,EACf,UAAU,EAAE,UAAU,EACtC,MAAM,EAAE,MAAM;IASR,YAAY,IAAI,sBAAsB;cAI1B,CAAC,2BAA2B,CAAC,CAC/C,MAAM,EAAE,uBAAuB,GAC7B,oBAAoB;cAIJ,CAAC,kBAAkB,CAAC,IAAI,IAAI;IAS/C,IAAW,KAAK,IAAI,KAAK,CAExB;IAEM,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS;IAU1D,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa;IAOtC,aAAa,IAAI,gBAAgB,CAAC,aAAa,CAAC;IAUvD,IAAW,WAAW,IAAI;QAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CA8CnF;IAEM,IAAI,IAAI,gBAAgB,CAAC,QAAQ,CAAC;CAGzC"}
|
|
@@ -64,6 +64,9 @@ class LazyTreeNode extends lazyEntity_js_1.LazyEntity {
|
|
|
64
64
|
anchorNode.slots.set(flexTreeTypes_js_1.flexTreeSlot, this);
|
|
65
65
|
__classPrivateFieldSet(this, _LazyTreeNode_removeDeleteCallback, anchorNode.on("afterDestroy", cleanupTree), "f");
|
|
66
66
|
}
|
|
67
|
+
borrowCursor() {
|
|
68
|
+
return this[lazyEntity_js_1.cursorSymbol];
|
|
69
|
+
}
|
|
67
70
|
[lazyEntity_js_1.tryMoveCursorToAnchorSymbol](cursor) {
|
|
68
71
|
return this.context.checkout.forest.tryMoveCursorToNode(this[lazyEntity_js_1.anchorSymbol], cursor);
|
|
69
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyNode.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA6D;AAE7D,kDAc6B;AAC7B,kDAA0D;AAC1D,yDAAwD;AAGxD,yDAM4B;AAC5B,mDAMy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BAAS,EAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAExB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IAEM,IAAI;QACV,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,4BAAY,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACvF,CAAC;CACD;AAzHD,oCAyHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Anchor,\n\ttype AnchorNode,\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype Value,\n\tinCursorField,\n\tmapCursorFields,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail } from \"../../util/index.js\";\nimport { FieldKinds } from \"../default-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\n\n/**\n * @param cursor - This does not take ownership of this cursor: Node will fork it as needed.\n */\nexport function makeTree(context: Context, cursor: ITreeSubscriptionCursor): LazyTreeNode {\n\tconst anchor = cursor.buildAnchor();\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(anchor) ??\n\t\tfail(\"cursor should point to a node that is not the root of the AnchorSet\");\n\tconst cached = anchorNode.slots.get(flexTreeSlot);\n\tif (cached !== undefined) {\n\t\tcontext.checkout.forest.anchors.forget(anchor);\n\t\tassert(cached.context === context, 0x782 /* contexts must match */);\n\t\tassert(cached instanceof LazyTreeNode, 0x92c /* Expected LazyTreeNode */);\n\t\treturn cached;\n\t}\n\treturn new LazyTreeNode(context, cursor.type, cursor, anchorNode, anchor);\n}\n\nfunction cleanupTree(anchor: AnchorNode): void {\n\tconst cached = anchor.slots.get(flexTreeSlot) ?? fail(\"tree should only be cleaned up once\");\n\tassert(cached instanceof LazyTreeNode, 0x92d /* Expected LazyTreeNode */);\n\tcached[disposeSymbol]();\n}\n\n/**\n * Lazy implementation of {@link FlexTreeNode}.\n */\nexport class LazyTreeNode extends LazyEntity<Anchor> implements FlexTreeNode {\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Node {\n\t\treturn FlexTreeEntityKind.Node;\n\t}\n\n\t// Using JS private here prevents it from showing up as a enumerable own property, or conflicting with struct fields.\n\treadonly #removeDeleteCallback: () => void;\n\n\tprivate readonly storedSchema: TreeNodeStoredSchema;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tpublic readonly schema: TreeNodeSchemaIdentifier,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tpublic readonly anchorNode: AnchorNode,\n\t\tanchor: Anchor,\n\t) {\n\t\tsuper(context, cursor, anchor);\n\t\tthis.storedSchema = context.schema.nodeSchema.get(this.schema) ?? fail(\"missing schema\");\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x783 /* must be in nodes mode */);\n\t\tanchorNode.slots.set(flexTreeSlot, this);\n\t\tthis.#removeDeleteCallback = anchorNode.on(\"afterDestroy\", cleanupTree);\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToNode(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\t// This type unconditionally has an anchor, so `forgetAnchor` is always called and cleanup can be done here:\n\t\t// After this point this node will not be usable,\n\t\t// so remove it from the anchor incase a different context (or the same context later) uses this AnchorSet.\n\t\tthis.anchorNode.slots.delete(flexTreeSlot);\n\t\tthis.#removeDeleteCallback();\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol]);\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this[cursorSymbol].value;\n\t}\n\n\tpublic tryGetField(fieldKey: FieldKey): FlexTreeField | undefined {\n\t\tconst schema = this.storedSchema.getFieldSchema(fieldKey);\n\t\treturn inCursorField(this[cursorSymbol], fieldKey, (cursor) => {\n\t\t\tif (cursor.getFieldLength() === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn makeField(this.context, schema.kind, cursor);\n\t\t});\n\t}\n\n\tpublic getBoxed(key: FieldKey): FlexTreeField {\n\t\tconst fieldSchema = this.storedSchema.getFieldSchema(key);\n\t\treturn inCursorField(this[cursorSymbol], key, (cursor) => {\n\t\t\treturn makeField(this.context, fieldSchema.kind, cursor);\n\t\t});\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapCursorFields(this[cursorSymbol], (cursor) =>\n\t\t\tmakeField(\n\t\t\t\tthis.context,\n\t\t\t\tthis.storedSchema.getFieldSchema(cursor.getFieldKey()).kind,\n\t\t\t\tcursor,\n\t\t\t),\n\t\t).values();\n\t}\n\n\tpublic get parentField(): { readonly parent: FlexTreeField; readonly index: number } {\n\t\tconst cursor = this[cursorSymbol];\n\t\tconst index = this.anchorNode.parentIndex;\n\t\tassert(cursor.fieldIndex === index, 0x786 /* mismatched indexes */);\n\t\tconst key = this.anchorNode.parentField;\n\n\t\tcursor.exitNode();\n\t\tassert(key === cursor.getFieldKey(), 0x787 /* mismatched keys */);\n\t\tlet fieldSchema: FieldKindIdentifier;\n\n\t\t// Check if the current node is in a detached sequence.\n\t\tif (this.anchorNode.parent === undefined) {\n\t\t\t// Parent field is a detached sequence, and thus needs special handling for its schema.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (key === rootFieldKey) {\n\t\t\t\tfieldSchema = this.context.schema.rootFieldSchema.kind;\n\t\t\t} else {\n\t\t\t\t// All fields (in the flex tree API) have a schema.\n\t\t\t\t// Since currently there is no known schema for detached field other than the special default root:\n\t\t\t\t// give all other detached fields a schema of sequence of anything.\n\t\t\t\t// That schema is the only one that is safe since its the only field schema that allows any possible field content.\n\t\t\t\t//\n\t\t\t\t// TODO:\n\t\t\t\t// if any of the following are done this schema will need to be more specific:\n\t\t\t\t// 1. Editing APIs start exposing user created detached sequences.\n\t\t\t\t// 2. Remove (and its inverse) start working on subsequences or fields contents (like everything in a sequence or optional field) and not just single nodes.\n\t\t\t\t// 3. Possibly other unknown cases.\n\t\t\t\t// Additionally this approach makes it possible for a user to take a FlexTree node, get its parent, check its schema, down cast based on that, then edit that detached field (ex: removing the node in it).\n\t\t\t\t// This MIGHT work properly with existing merge resolution logic (it must keep client in sync and be unable to violate schema), but this either needs robust testing or to be explicitly banned (error before sending the op).\n\t\t\t\t// Issues like replacing a node in the a removed sequenced then undoing the remove could easily violate schema if not everything works exactly right!\n\t\t\t\tfieldSchema = FieldKinds.sequence.identifier;\n\t\t\t}\n\t\t} else {\n\t\t\tcursor.exitField();\n\t\t\tconst parentType = cursor.type;\n\t\t\tcursor.enterField(key);\n\t\t\tconst nodeSchema =\n\t\t\t\tthis.context.schema.nodeSchema.get(parentType) ??\n\t\t\t\tfail(\"requested schema that does not exist\");\n\t\t\tfieldSchema = nodeSchema.getFieldSchema(key).kind;\n\t\t}\n\n\t\tconst proxifiedField = makeField(this.context, fieldSchema, cursor);\n\t\tcursor.enterNode(index);\n\n\t\treturn { parent: proxifiedField, index };\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn mapCursorFields(this[cursorSymbol], (cursor) => cursor.getFieldKey()).values();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lazyNode.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA6D;AAE7D,kDAe6B;AAC7B,kDAA0D;AAC1D,yDAAwD;AAGxD,yDAM4B;AAC5B,mDAMyB;AACzB,iDAA2C;AAE3C;;GAEG;AACH,SAAgB,QAAQ,CAAC,OAAgB,EAAE,MAA+B;IACzE,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,UAAU,GACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9C,IAAA,eAAI,EAAC,qEAAqE,CAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,+BAAY,CAAC,CAAC;IAClD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAA,iBAAM,EAAC,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACpE,IAAA,iBAAM,EAAC,MAAM,YAAY,YAAY,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAC3E,CAAC;AAbD,4BAaC;AAED,SAAS,WAAW,CAAC,MAAkB;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,+BAAY,CAAC,IAAI,IAAA,eAAI,EAAC,qCAAq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,GAAG,MAAM,CAAC,IAAI,CAAC;YAC/B,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACvB,MAAM,UAAU,GACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC;gBAC9C,IAAA,eAAI,EAAC,sCAAsC,CAAC,CAAC;YAC9C,WAAW,GAAG,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnD,CAAC;QAED,MAAM,cAAc,GAAG,IAAA,wBAAS,EAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAExB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IAEM,IAAI;QACV,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,4BAAY,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACvF,CAAC;CACD;AA7HD,oCA6HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Anchor,\n\ttype AnchorNode,\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype FieldKindIdentifier,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype Value,\n\tinCursorField,\n\tmapCursorFields,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail } from \"../../util/index.js\";\nimport { FieldKinds } from \"../default-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\n\n/**\n * @param cursor - This does not take ownership of this cursor: Node will fork it as needed.\n */\nexport function makeTree(context: Context, cursor: ITreeSubscriptionCursor): LazyTreeNode {\n\tconst anchor = cursor.buildAnchor();\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(anchor) ??\n\t\tfail(\"cursor should point to a node that is not the root of the AnchorSet\");\n\tconst cached = anchorNode.slots.get(flexTreeSlot);\n\tif (cached !== undefined) {\n\t\tcontext.checkout.forest.anchors.forget(anchor);\n\t\tassert(cached.context === context, 0x782 /* contexts must match */);\n\t\tassert(cached instanceof LazyTreeNode, 0x92c /* Expected LazyTreeNode */);\n\t\treturn cached;\n\t}\n\treturn new LazyTreeNode(context, cursor.type, cursor, anchorNode, anchor);\n}\n\nfunction cleanupTree(anchor: AnchorNode): void {\n\tconst cached = anchor.slots.get(flexTreeSlot) ?? fail(\"tree should only be cleaned up once\");\n\tassert(cached instanceof LazyTreeNode, 0x92d /* Expected LazyTreeNode */);\n\tcached[disposeSymbol]();\n}\n\n/**\n * Lazy implementation of {@link FlexTreeNode}.\n */\nexport class LazyTreeNode extends LazyEntity<Anchor> implements FlexTreeNode {\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Node {\n\t\treturn FlexTreeEntityKind.Node;\n\t}\n\n\t// Using JS private here prevents it from showing up as a enumerable own property, or conflicting with struct fields.\n\treadonly #removeDeleteCallback: () => void;\n\n\tprivate readonly storedSchema: TreeNodeStoredSchema;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tpublic readonly schema: TreeNodeSchemaIdentifier,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tpublic readonly anchorNode: AnchorNode,\n\t\tanchor: Anchor,\n\t) {\n\t\tsuper(context, cursor, anchor);\n\t\tthis.storedSchema = context.schema.nodeSchema.get(this.schema) ?? fail(\"missing schema\");\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x783 /* must be in nodes mode */);\n\t\tanchorNode.slots.set(flexTreeSlot, this);\n\t\tthis.#removeDeleteCallback = anchorNode.on(\"afterDestroy\", cleanupTree);\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn this[cursorSymbol] as ITreeCursorSynchronous;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToNode(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\t// This type unconditionally has an anchor, so `forgetAnchor` is always called and cleanup can be done here:\n\t\t// After this point this node will not be usable,\n\t\t// so remove it from the anchor incase a different context (or the same context later) uses this AnchorSet.\n\t\tthis.anchorNode.slots.delete(flexTreeSlot);\n\t\tthis.#removeDeleteCallback();\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol]);\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this[cursorSymbol].value;\n\t}\n\n\tpublic tryGetField(fieldKey: FieldKey): FlexTreeField | undefined {\n\t\tconst schema = this.storedSchema.getFieldSchema(fieldKey);\n\t\treturn inCursorField(this[cursorSymbol], fieldKey, (cursor) => {\n\t\t\tif (cursor.getFieldLength() === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn makeField(this.context, schema.kind, cursor);\n\t\t});\n\t}\n\n\tpublic getBoxed(key: FieldKey): FlexTreeField {\n\t\tconst fieldSchema = this.storedSchema.getFieldSchema(key);\n\t\treturn inCursorField(this[cursorSymbol], key, (cursor) => {\n\t\t\treturn makeField(this.context, fieldSchema.kind, cursor);\n\t\t});\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapCursorFields(this[cursorSymbol], (cursor) =>\n\t\t\tmakeField(\n\t\t\t\tthis.context,\n\t\t\t\tthis.storedSchema.getFieldSchema(cursor.getFieldKey()).kind,\n\t\t\t\tcursor,\n\t\t\t),\n\t\t).values();\n\t}\n\n\tpublic get parentField(): { readonly parent: FlexTreeField; readonly index: number } {\n\t\tconst cursor = this[cursorSymbol];\n\t\tconst index = this.anchorNode.parentIndex;\n\t\tassert(cursor.fieldIndex === index, 0x786 /* mismatched indexes */);\n\t\tconst key = this.anchorNode.parentField;\n\n\t\tcursor.exitNode();\n\t\tassert(key === cursor.getFieldKey(), 0x787 /* mismatched keys */);\n\t\tlet fieldSchema: FieldKindIdentifier;\n\n\t\t// Check if the current node is in a detached sequence.\n\t\tif (this.anchorNode.parent === undefined) {\n\t\t\t// Parent field is a detached sequence, and thus needs special handling for its schema.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (key === rootFieldKey) {\n\t\t\t\tfieldSchema = this.context.schema.rootFieldSchema.kind;\n\t\t\t} else {\n\t\t\t\t// All fields (in the flex tree API) have a schema.\n\t\t\t\t// Since currently there is no known schema for detached field other than the special default root:\n\t\t\t\t// give all other detached fields a schema of sequence of anything.\n\t\t\t\t// That schema is the only one that is safe since its the only field schema that allows any possible field content.\n\t\t\t\t//\n\t\t\t\t// TODO:\n\t\t\t\t// if any of the following are done this schema will need to be more specific:\n\t\t\t\t// 1. Editing APIs start exposing user created detached sequences.\n\t\t\t\t// 2. Remove (and its inverse) start working on subsequences or fields contents (like everything in a sequence or optional field) and not just single nodes.\n\t\t\t\t// 3. Possibly other unknown cases.\n\t\t\t\t// Additionally this approach makes it possible for a user to take a FlexTree node, get its parent, check its schema, down cast based on that, then edit that detached field (ex: removing the node in it).\n\t\t\t\t// This MIGHT work properly with existing merge resolution logic (it must keep client in sync and be unable to violate schema), but this either needs robust testing or to be explicitly banned (error before sending the op).\n\t\t\t\t// Issues like replacing a node in the a removed sequenced then undoing the remove could easily violate schema if not everything works exactly right!\n\t\t\t\tfieldSchema = FieldKinds.sequence.identifier;\n\t\t\t}\n\t\t} else {\n\t\t\tcursor.exitField();\n\t\t\tconst parentType = cursor.type;\n\t\t\tcursor.enterField(key);\n\t\t\tconst nodeSchema =\n\t\t\t\tthis.context.schema.nodeSchema.get(parentType) ??\n\t\t\t\tfail(\"requested schema that does not exist\");\n\t\t\tfieldSchema = nodeSchema.getFieldSchema(key).kind;\n\t\t}\n\n\t\tconst proxifiedField = makeField(this.context, fieldSchema, cursor);\n\t\tcursor.enterNode(index);\n\n\t\treturn { parent: proxifiedField, index };\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn mapCursorFields(this[cursorSymbol], (cursor) => cursor.getFieldKey()).values();\n\t}\n}\n"]}
|
|
@@ -87,7 +87,7 @@ class ObjectForest {
|
|
|
87
87
|
this.events.emit("beforeChange");
|
|
88
88
|
(0, internal_1.assert)(this.currentCursors.has(cursor), 0x995 /* missing visitor cursor while editing */);
|
|
89
89
|
if (this.currentCursors.size > 1) {
|
|
90
|
-
const unexpectedSources = [...this.currentCursors].flatMap((c) => c === cursor ? [] : c.source ?? null);
|
|
90
|
+
const unexpectedSources = [...this.currentCursors].flatMap((c) => c === cursor ? [] : (c.source ?? null));
|
|
91
91
|
throw new Error(`Found unexpected cursors when editing with the following annotations: ${JSON.stringify(unexpectedSources)}`);
|
|
92
92
|
}
|
|
93
93
|
};
|