@fluidframework/tree 2.3.0-288113 → 2.3.1
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/.dependency-cruiser-known-violations.json +28 -40
- package/.vscode/Tree.code-workspace +0 -2
- package/CHANGELOG.md +92 -0
- package/README.md +6 -0
- package/alpha.d.ts +11 -0
- package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
- package/api-extractor/api-extractor.current.json +8 -0
- package/api-extractor/api-extractor.legacy.json +4 -0
- package/api-extractor.json +1 -1
- package/api-report/tree.alpha.api.md +21 -42
- package/api-report/tree.beta.api.md +21 -11
- package/api-report/tree.legacy.alpha.api.md +562 -0
- package/api-report/tree.legacy.public.api.md +559 -0
- package/api-report/tree.public.api.md +8 -13
- package/dist/alpha.d.ts +102 -0
- package/dist/beta.d.ts +6 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
- package/dist/core/revertible.d.ts.map +1 -0
- package/dist/core/revertible.js.map +1 -0
- package/dist/core/schema-stored/format.d.ts +3 -3
- package/dist/core/schema-stored/format.js +1 -1
- package/dist/core/schema-stored/format.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +2 -7
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +4 -6
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +6 -2
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +0 -1
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +1 -0
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts +7 -2
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/events/emitter.d.ts +127 -0
- package/dist/events/emitter.d.ts.map +1 -0
- package/dist/events/{events.js → emitter.js} +48 -30
- package/dist/events/emitter.js.map +1 -0
- package/dist/events/index.d.ts +2 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +4 -5
- package/dist/events/index.js.map +1 -1
- package/dist/events/interop.d.ts +36 -0
- package/dist/events/interop.d.ts.map +1 -0
- package/dist/{core/revertible/index.d.ts → events/interop.js} +3 -2
- package/dist/events/interop.js.map +1 -0
- package/dist/events/listeners.d.ts +65 -0
- package/dist/events/listeners.d.ts.map +1 -0
- package/{lib/core/revertible/index.d.ts → dist/events/listeners.js} +3 -2
- package/dist/events/listeners.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +36 -15
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +12 -5
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +28 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
- package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/index.js +2 -1
- package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +82 -103
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +30 -14
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +10 -7
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +15 -3
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +2 -3
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +2 -10
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +26 -28
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -14
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +23 -74
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/unboxed.d.ts +4 -16
- package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/unboxed.js +7 -41
- package/dist/feature-libraries/flex-tree/unboxed.js.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/utilities.js +3 -6
- package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -5
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +5 -11
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +3 -6
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.js +3 -13
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +12 -5
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
- package/dist/feature-libraries/schema-index/format.d.ts +3 -3
- package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
- package/dist/feature-libraries/storedToViewSchema.js +2 -4
- package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
- package/dist/feature-libraries/typed-schema/flexList.d.ts +3 -3
- package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
- package/dist/feature-libraries/typed-schema/index.d.ts +2 -2
- package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/index.js +2 -2
- package/dist/feature-libraries/typed-schema/index.js.map +1 -1
- package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/schemaCollection.js +8 -10
- package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +5 -37
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/dist/feature-libraries/typed-schema/view.d.ts +4 -6
- package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/view.js +5 -4
- package/dist/feature-libraries/typed-schema/view.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -36
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +83 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +0 -1
- package/dist/shared-tree/checkoutFlexTreeView.d.ts +53 -0
- package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
- package/dist/shared-tree/{treeView.js → checkoutFlexTreeView.js} +28 -6
- package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -0
- package/dist/shared-tree/index.d.ts +3 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -2
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +15 -4
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +7 -8
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +9 -4
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +25 -12
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +6 -2
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +3 -2
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +1 -3
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +6 -4
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -13
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +17 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.js +1 -1
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +1 -1
- package/dist/simple-tree/api/create.js.map +1 -1
- package/{lib/simple-tree → dist/simple-tree/api}/getJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -0
- package/dist/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -0
- package/{lib/simple-tree → dist/simple-tree/api}/getSimpleSchema.d.ts +1 -1
- package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
- package/dist/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
- package/dist/simple-tree/api/getSimpleSchema.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +5 -0
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +7 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/{lib/simple-tree → dist/simple-tree/api}/jsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -0
- package/dist/simple-tree/api/jsonSchema.js.map +1 -0
- package/dist/simple-tree/api/schemaFactory.d.ts +45 -14
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +43 -12
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +4 -4
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -0
- package/dist/simple-tree/api/simpleSchema.js.map +1 -0
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
- package/dist/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +4 -4
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
- package/dist/simple-tree/api/tree.d.ts +1 -21
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +3 -38
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts +79 -0
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -0
- package/dist/simple-tree/api/treeApiBeta.js +26 -0
- package/dist/simple-tree/api/treeApiBeta.js.map +1 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +21 -19
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +2 -2
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
- package/dist/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +4 -4
- package/{lib/simple-tree → dist/simple-tree/api}/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +2 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +30 -21
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +3 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +4 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/schemaCaching.d.ts +5 -0
- package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
- package/dist/simple-tree/core/schemaCaching.js +10 -1
- package/dist/simple-tree/core/schemaCaching.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +61 -3
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +166 -13
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +17 -20
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +3 -2
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +7 -9
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +15 -6
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +7 -9
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +13 -11
- 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 +38 -29
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +9 -7
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +37 -31
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts +1 -14
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +12 -15
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/proxyBinding.d.ts +2 -62
- package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
- package/dist/simple-tree/proxyBinding.js +8 -181
- package/dist/simple-tree/proxyBinding.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +7 -7
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +4 -4
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +11 -1
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +54 -31
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +25 -37
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.js +53 -16
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +7 -10
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/typesUnsafe.d.ts +13 -13
- package/dist/simple-tree/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/walkSchema.d.ts +26 -0
- package/dist/simple-tree/walkSchema.d.ts.map +1 -0
- package/dist/simple-tree/walkSchema.js +49 -0
- package/dist/simple-tree/walkSchema.js.map +1 -0
- package/dist/treeFactory.d.ts +2 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +2 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/typeUtils.d.ts +2 -2
- package/dist/util/typeUtils.js.map +1 -1
- package/legacy.d.ts +11 -0
- package/lib/alpha.d.ts +102 -0
- package/lib/beta.d.ts +6 -2
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
- package/lib/core/revertible.d.ts.map +1 -0
- package/lib/core/revertible.js.map +1 -0
- package/lib/core/schema-stored/format.d.ts +3 -3
- package/lib/core/schema-stored/format.js +1 -1
- package/lib/core/schema-stored/format.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +2 -7
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +4 -6
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +6 -2
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +0 -1
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +1 -0
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts +7 -2
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/events/emitter.d.ts +127 -0
- package/lib/events/emitter.d.ts.map +1 -0
- package/lib/events/{events.js → emitter.js} +48 -29
- package/lib/events/emitter.js.map +1 -0
- package/lib/events/index.d.ts +2 -1
- package/lib/events/index.d.ts.map +1 -1
- package/lib/events/index.js +1 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/interop.d.ts +36 -0
- package/lib/events/interop.d.ts.map +1 -0
- package/{src/core/revertible/index.ts → lib/events/interop.js} +2 -2
- package/lib/events/interop.js.map +1 -0
- package/lib/events/listeners.d.ts +65 -0
- package/lib/events/listeners.d.ts.map +1 -0
- package/lib/{core/revertible/index.js → events/listeners.js} +2 -2
- package/lib/events/listeners.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +37 -16
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +12 -5
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +28 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
- package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/index.js +1 -1
- package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +83 -104
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +30 -14
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +10 -7
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +15 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +2 -3
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +2 -10
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +26 -28
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +23 -72
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/unboxed.d.ts +4 -16
- package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/unboxed.js +5 -37
- package/lib/feature-libraries/flex-tree/unboxed.js.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/utilities.js +3 -6
- package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -5
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +5 -5
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +3 -6
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.js +3 -13
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +12 -5
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
- package/lib/feature-libraries/schema-index/format.d.ts +3 -3
- package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
- package/lib/feature-libraries/storedToViewSchema.js +3 -5
- package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
- package/lib/feature-libraries/typed-schema/flexList.d.ts +3 -3
- package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
- package/lib/feature-libraries/typed-schema/index.d.ts +2 -2
- package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/index.js +2 -2
- package/lib/feature-libraries/typed-schema/index.js.map +1 -1
- package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/schemaCollection.js +9 -11
- package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +5 -36
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/lib/feature-libraries/typed-schema/view.d.ts +4 -6
- package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/view.js +5 -4
- package/lib/feature-libraries/typed-schema/view.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -5
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +83 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +0 -1
- package/lib/shared-tree/checkoutFlexTreeView.d.ts +53 -0
- package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
- package/lib/shared-tree/{treeView.js → checkoutFlexTreeView.js} +26 -5
- package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -0
- package/lib/shared-tree/index.d.ts +3 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +15 -4
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +8 -9
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +9 -4
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +26 -13
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -2
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -2
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +3 -2
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +1 -3
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +7 -5
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -13
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +18 -2
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.js +1 -1
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +2 -2
- package/lib/simple-tree/api/create.js.map +1 -1
- package/{dist/simple-tree → lib/simple-tree/api}/getJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -0
- package/lib/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -0
- package/{dist/simple-tree → lib/simple-tree/api}/getSimpleSchema.d.ts +1 -1
- package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
- package/lib/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
- package/lib/simple-tree/api/getSimpleSchema.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +5 -0
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +3 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/{dist/simple-tree → lib/simple-tree/api}/jsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -0
- package/lib/simple-tree/api/jsonSchema.js.map +1 -0
- package/lib/simple-tree/api/schemaFactory.d.ts +45 -14
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +43 -12
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +4 -4
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -0
- package/lib/simple-tree/api/simpleSchema.js.map +1 -0
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
- package/lib/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +4 -4
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
- package/lib/simple-tree/api/tree.d.ts +1 -21
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +2 -34
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts +79 -0
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -0
- package/lib/simple-tree/api/treeApiBeta.js +23 -0
- package/lib/simple-tree/api/treeApiBeta.js.map +1 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +23 -21
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
- package/lib/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +4 -4
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
- package/lib/simple-tree/arrayNode.d.ts +2 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +33 -24
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +3 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/schemaCaching.d.ts +5 -0
- package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
- package/lib/simple-tree/core/schemaCaching.js +8 -0
- package/lib/simple-tree/core/schemaCaching.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +61 -3
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +156 -5
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +17 -20
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +3 -2
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +7 -9
- 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 +7 -9
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +14 -12
- 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 +38 -29
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +9 -7
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +40 -34
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts +1 -14
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +11 -14
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/proxyBinding.d.ts +2 -62
- package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
- package/lib/simple-tree/proxyBinding.js +6 -174
- package/lib/simple-tree/proxyBinding.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +7 -7
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +4 -4
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +11 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +29 -8
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +25 -37
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.js +54 -17
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +8 -11
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/typesUnsafe.d.ts +13 -13
- package/lib/simple-tree/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/walkSchema.d.ts +26 -0
- package/lib/simple-tree/walkSchema.d.ts.map +1 -0
- package/lib/simple-tree/walkSchema.js +43 -0
- package/lib/simple-tree/walkSchema.js.map +1 -0
- package/lib/treeFactory.d.ts +2 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +2 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/util/typeUtils.d.ts +2 -2
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +57 -25
- package/src/core/index.ts +1 -1
- package/src/core/{revertible/revertible.ts → revertible.ts} +15 -0
- package/src/core/schema-stored/format.ts +1 -1
- package/src/core/schema-stored/schema.ts +6 -13
- package/src/core/tree/anchorSet.ts +18 -3
- package/src/core/tree/detachedFieldIndex.ts +6 -5
- package/src/core/tree/visitDelta.ts +7 -2
- package/src/events/{events.ts → emitter.ts} +52 -139
- package/src/events/index.ts +7 -7
- package/src/events/interop.ts +49 -0
- package/src/events/listeners.ts +68 -0
- package/src/feature-libraries/chunked-forest/chunkTree.ts +63 -18
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +18 -4
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +33 -0
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +5 -3
- package/src/feature-libraries/flex-map-tree/index.ts +1 -0
- package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +135 -210
- package/src/feature-libraries/flex-tree/README.md +4 -75
- package/src/feature-libraries/flex-tree/context.ts +37 -16
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +69 -291
- package/src/feature-libraries/flex-tree/index.ts +7 -13
- package/src/feature-libraries/flex-tree/lazyEntity.ts +2 -11
- package/src/feature-libraries/flex-tree/lazyField.ts +49 -73
- package/src/feature-libraries/flex-tree/lazyNode.ts +25 -154
- package/src/feature-libraries/flex-tree/unboxed.ts +9 -68
- package/src/feature-libraries/flex-tree/utilities.ts +4 -8
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -1
- package/src/feature-libraries/index.ts +2 -27
- package/src/feature-libraries/modular-schema/comparison.ts +4 -6
- package/src/feature-libraries/modular-schema/discrepancies.ts +7 -16
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +14 -4
- package/src/feature-libraries/storedToViewSchema.ts +5 -6
- package/src/feature-libraries/typed-schema/flexList.ts +3 -3
- package/src/feature-libraries/typed-schema/index.ts +1 -3
- package/src/feature-libraries/typed-schema/schemaCollection.ts +15 -17
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +35 -127
- package/src/feature-libraries/typed-schema/view.ts +4 -13
- package/src/index.ts +4 -8
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/checkoutFlexTreeView.ts +89 -0
- package/src/shared-tree/index.ts +2 -7
- package/src/shared-tree/schematizeTree.ts +23 -12
- package/src/shared-tree/schematizingTreeView.ts +34 -24
- package/src/shared-tree/sharedTree.ts +6 -1
- package/src/shared-tree/sharedTreeChangeEnricher.ts +6 -1
- package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
- package/src/shared-tree/sharedTreeEditBuilder.ts +9 -4
- package/src/shared-tree/treeApi.ts +10 -10
- package/src/shared-tree/treeCheckout.ts +26 -15
- package/src/shared-tree-core/branch.ts +1 -1
- package/src/simple-tree/ProxyBinding.md +23 -23
- package/src/simple-tree/api/create.ts +8 -3
- package/src/simple-tree/{getJsonSchema.ts → api/getJsonSchema.ts} +3 -3
- package/src/simple-tree/{getSimpleSchema.ts → api/getSimpleSchema.ts} +3 -3
- package/src/simple-tree/api/index.ts +20 -0
- package/src/simple-tree/{jsonSchema.ts → api/jsonSchema.ts} +1 -1
- package/src/simple-tree/api/schemaFactory.ts +44 -13
- package/src/simple-tree/{simpleSchema.ts → api/simpleSchema.ts} +4 -4
- package/src/simple-tree/{simpleSchemaToJsonSchema.ts → api/simpleSchemaToJsonSchema.ts} +4 -4
- package/src/simple-tree/api/tree.ts +2 -71
- package/src/simple-tree/api/treeApiBeta.ts +101 -0
- package/src/simple-tree/api/treeNodeApi.ts +32 -23
- package/src/simple-tree/api/verboseTree.ts +1 -1
- package/src/simple-tree/{viewSchemaToSimpleSchema.ts → api/viewSchemaToSimpleSchema.ts} +5 -5
- package/src/simple-tree/arrayNode.ts +37 -31
- package/src/simple-tree/core/index.ts +4 -1
- package/src/simple-tree/core/schemaCaching.ts +10 -0
- package/src/simple-tree/core/treeNodeKernel.ts +198 -5
- package/src/simple-tree/core/treeNodeSchema.ts +1 -1
- package/src/simple-tree/core/types.ts +16 -27
- package/src/simple-tree/core/withType.ts +3 -1
- package/src/simple-tree/index.ts +29 -21
- package/src/simple-tree/leafNodeSchema.ts +24 -28
- package/src/simple-tree/mapNode.ts +47 -29
- package/src/simple-tree/objectNode.ts +51 -46
- package/src/simple-tree/proxies.ts +22 -51
- package/src/simple-tree/proxyBinding.ts +3 -254
- package/src/simple-tree/schemaTypes.ts +8 -8
- package/src/simple-tree/toFlexSchema.ts +40 -7
- package/src/simple-tree/toMapTree.ts +113 -79
- package/src/simple-tree/treeNodeValid.ts +10 -13
- package/src/simple-tree/typesUnsafe.ts +13 -13
- package/src/simple-tree/walkSchema.ts +81 -0
- package/src/treeFactory.ts +2 -1
- package/src/util/typeUtils.ts +2 -2
- package/dist/core/revertible/index.d.ts.map +0 -1
- package/dist/core/revertible/index.js +0 -10
- package/dist/core/revertible/index.js.map +0 -1
- package/dist/core/revertible/revertible.d.ts.map +0 -1
- package/dist/core/revertible/revertible.js.map +0 -1
- package/dist/domains/index.d.ts +0 -8
- package/dist/domains/index.d.ts.map +0 -1
- package/dist/domains/index.js +0 -20
- package/dist/domains/index.js.map +0 -1
- package/dist/domains/json/index.d.ts +0 -7
- package/dist/domains/json/index.d.ts.map +0 -1
- package/dist/domains/json/index.js +0 -17
- package/dist/domains/json/index.js.map +0 -1
- package/dist/domains/json/jsonCursor.d.ts +0 -52
- package/dist/domains/json/jsonCursor.d.ts.map +0 -1
- package/dist/domains/json/jsonCursor.js +0 -197
- package/dist/domains/json/jsonCursor.js.map +0 -1
- package/dist/domains/json/jsonDomainSchema.d.ts +0 -24
- package/dist/domains/json/jsonDomainSchema.d.ts.map +0 -1
- package/dist/domains/json/jsonDomainSchema.js +0 -32
- package/dist/domains/json/jsonDomainSchema.js.map +0 -1
- package/dist/domains/leafDomain.d.ts +0 -72
- package/dist/domains/leafDomain.d.ts.map +0 -1
- package/dist/domains/leafDomain.js +0 -88
- package/dist/domains/leafDomain.js.map +0 -1
- package/dist/domains/schemaBuilder.d.ts +0 -103
- package/dist/domains/schemaBuilder.d.ts.map +0 -1
- package/dist/domains/schemaBuilder.js +0 -121
- package/dist/domains/schemaBuilder.js.map +0 -1
- package/dist/domains/testRecursiveDomain.d.ts +0 -17
- package/dist/domains/testRecursiveDomain.d.ts.map +0 -1
- package/dist/domains/testRecursiveDomain.js +0 -35
- package/dist/domains/testRecursiveDomain.js.map +0 -1
- package/dist/events/events.d.ts +0 -207
- package/dist/events/events.d.ts.map +0 -1
- package/dist/events/events.js.map +0 -1
- package/dist/feature-libraries/schemaBuilder.d.ts +0 -31
- package/dist/feature-libraries/schemaBuilder.d.ts.map +0 -1
- package/dist/feature-libraries/schemaBuilder.js +0 -40
- package/dist/feature-libraries/schemaBuilder.js.map +0 -1
- package/dist/feature-libraries/schemaBuilderBase.d.ts +0 -191
- package/dist/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
- package/dist/feature-libraries/schemaBuilderBase.js +0 -201
- package/dist/feature-libraries/schemaBuilderBase.js.map +0 -1
- package/dist/shared-tree/treeView.d.ts +0 -73
- package/dist/shared-tree/treeView.d.ts.map +0 -1
- package/dist/shared-tree/treeView.js.map +0 -1
- package/dist/simple-tree/getJsonSchema.d.ts.map +0 -1
- package/dist/simple-tree/getJsonSchema.js.map +0 -1
- package/dist/simple-tree/getSimpleSchema.d.ts.map +0 -1
- package/dist/simple-tree/getSimpleSchema.js.map +0 -1
- package/dist/simple-tree/jsonSchema.d.ts.map +0 -1
- package/dist/simple-tree/jsonSchema.js.map +0 -1
- package/dist/simple-tree/simpleSchema.d.ts.map +0 -1
- package/dist/simple-tree/simpleSchema.js.map +0 -1
- package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
- package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
- package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
- package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
- package/lib/core/revertible/index.d.ts.map +0 -1
- package/lib/core/revertible/index.js.map +0 -1
- package/lib/core/revertible/revertible.d.ts.map +0 -1
- package/lib/core/revertible/revertible.js.map +0 -1
- package/lib/domains/index.d.ts +0 -8
- package/lib/domains/index.d.ts.map +0 -1
- package/lib/domains/index.js +0 -8
- package/lib/domains/index.js.map +0 -1
- package/lib/domains/json/index.d.ts +0 -7
- package/lib/domains/json/index.d.ts.map +0 -1
- package/lib/domains/json/index.js +0 -7
- package/lib/domains/json/index.js.map +0 -1
- package/lib/domains/json/jsonCursor.d.ts +0 -52
- package/lib/domains/json/jsonCursor.d.ts.map +0 -1
- package/lib/domains/json/jsonCursor.js +0 -192
- package/lib/domains/json/jsonCursor.js.map +0 -1
- package/lib/domains/json/jsonDomainSchema.d.ts +0 -24
- package/lib/domains/json/jsonDomainSchema.d.ts.map +0 -1
- package/lib/domains/json/jsonDomainSchema.js +0 -29
- package/lib/domains/json/jsonDomainSchema.js.map +0 -1
- package/lib/domains/leafDomain.d.ts +0 -72
- package/lib/domains/leafDomain.d.ts.map +0 -1
- package/lib/domains/leafDomain.js +0 -85
- package/lib/domains/leafDomain.js.map +0 -1
- package/lib/domains/schemaBuilder.d.ts +0 -103
- package/lib/domains/schemaBuilder.d.ts.map +0 -1
- package/lib/domains/schemaBuilder.js +0 -117
- package/lib/domains/schemaBuilder.js.map +0 -1
- package/lib/domains/testRecursiveDomain.d.ts +0 -17
- package/lib/domains/testRecursiveDomain.d.ts.map +0 -1
- package/lib/domains/testRecursiveDomain.js +0 -32
- package/lib/domains/testRecursiveDomain.js.map +0 -1
- package/lib/events/events.d.ts +0 -207
- package/lib/events/events.d.ts.map +0 -1
- package/lib/events/events.js.map +0 -1
- package/lib/feature-libraries/schemaBuilder.d.ts +0 -31
- package/lib/feature-libraries/schemaBuilder.d.ts.map +0 -1
- package/lib/feature-libraries/schemaBuilder.js +0 -36
- package/lib/feature-libraries/schemaBuilder.js.map +0 -1
- package/lib/feature-libraries/schemaBuilderBase.d.ts +0 -191
- package/lib/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
- package/lib/feature-libraries/schemaBuilderBase.js +0 -195
- package/lib/feature-libraries/schemaBuilderBase.js.map +0 -1
- package/lib/shared-tree/treeView.d.ts +0 -73
- package/lib/shared-tree/treeView.d.ts.map +0 -1
- package/lib/shared-tree/treeView.js.map +0 -1
- package/lib/simple-tree/getJsonSchema.d.ts.map +0 -1
- package/lib/simple-tree/getJsonSchema.js.map +0 -1
- package/lib/simple-tree/getSimpleSchema.d.ts.map +0 -1
- package/lib/simple-tree/getSimpleSchema.js.map +0 -1
- package/lib/simple-tree/jsonSchema.d.ts.map +0 -1
- package/lib/simple-tree/jsonSchema.js.map +0 -1
- package/lib/simple-tree/simpleSchema.d.ts.map +0 -1
- package/lib/simple-tree/simpleSchema.js.map +0 -1
- package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
- package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
- package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
- package/src/domains/README.md +0 -6
- package/src/domains/fence.json +0 -5
- package/src/domains/index.ts +0 -19
- package/src/domains/json/fence.json +0 -5
- package/src/domains/json/index.ts +0 -13
- package/src/domains/json/jsonCursor.ts +0 -247
- package/src/domains/json/jsonDomainSchema.ts +0 -47
- package/src/domains/leafDomain.ts +0 -97
- package/src/domains/schemaBuilder.ts +0 -153
- package/src/domains/testRecursiveDomain.ts +0 -38
- package/src/events/fence.json +0 -5
- package/src/feature-libraries/schemaBuilder.ts +0 -45
- package/src/feature-libraries/schemaBuilderBase.ts +0 -393
- package/src/shared-tree/treeView.ts +0 -113
- /package/dist/core/{revertible/revertible.js → revertible.js} +0 -0
- /package/dist/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
- /package/dist/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
- /package/dist/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
- /package/lib/core/{revertible/revertible.js → revertible.js} +0 -0
- /package/lib/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
- /package/lib/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
- /package/lib/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
var _a, _b;
|
|
6
6
|
import { assert, oob } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
8
|
import { EmptyKey, } from "../../core/index.js";
|
|
8
|
-
import { brand, fail, getOrCreate, mapIterable } from "../../util/index.js";
|
|
9
|
+
import { brand, fail, getOrCreate, isReadonlyArray, mapIterable } from "../../util/index.js";
|
|
9
10
|
import { FlexTreeEntityKind, flexTreeMarker, indexForAt, } from "../flex-tree/index.js";
|
|
10
|
-
import { FlexFieldSchema,
|
|
11
|
-
import {
|
|
12
|
-
import { FieldKinds } from "../default-schema/index.js";
|
|
13
|
-
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
11
|
+
import { FlexFieldSchema, intoStoredSchemaCollection, isLazy, } from "../typed-schema/index.js";
|
|
12
|
+
import { defaultSchemaPolicy, FieldKinds, } from "../default-schema/index.js";
|
|
14
13
|
/**
|
|
15
14
|
* Checks if the given {@link FlexTreeNode} is a {@link MapTreeNode}.
|
|
16
15
|
*/
|
|
@@ -31,6 +30,9 @@ export function isMapTreeSequenceField(field) {
|
|
|
31
30
|
* when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `MapTreeNode` object.
|
|
32
31
|
*/
|
|
33
32
|
export class EagerMapTreeNode {
|
|
33
|
+
get schema() {
|
|
34
|
+
return this.flexSchema.name;
|
|
35
|
+
}
|
|
34
36
|
/**
|
|
35
37
|
* Create a new MapTreeNode.
|
|
36
38
|
* @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not
|
|
@@ -39,14 +41,14 @@ export class EagerMapTreeNode {
|
|
|
39
41
|
* A `MapTreeNode` may never be constructed more than once for the same {@link MapTree} object.
|
|
40
42
|
* Instead, it should always be acquired via {@link getOrCreateNode}.
|
|
41
43
|
*/
|
|
42
|
-
constructor(
|
|
44
|
+
constructor(context, flexSchema,
|
|
43
45
|
/** The underlying {@link MapTree} that this `MapTreeNode` reads its data from */
|
|
44
46
|
mapTree, location = unparentedLocation) {
|
|
45
|
-
this.
|
|
47
|
+
this.context = context;
|
|
48
|
+
this.flexSchema = flexSchema;
|
|
46
49
|
this.mapTree = mapTree;
|
|
47
50
|
this.location = location;
|
|
48
51
|
this[_a] = FlexTreeEntityKind.Node;
|
|
49
|
-
this.context = undefined;
|
|
50
52
|
assert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);
|
|
51
53
|
nodeCache.set(mapTree, this);
|
|
52
54
|
// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.
|
|
@@ -59,7 +61,7 @@ export class EagerMapTreeNode {
|
|
|
59
61
|
this.walkTree();
|
|
60
62
|
}
|
|
61
63
|
get type() {
|
|
62
|
-
return this.
|
|
64
|
+
return this.flexSchema.name;
|
|
63
65
|
}
|
|
64
66
|
adoptBy(parent, index) {
|
|
65
67
|
if (parent !== undefined) {
|
|
@@ -80,21 +82,25 @@ export class EagerMapTreeNode {
|
|
|
80
82
|
return this.location;
|
|
81
83
|
}
|
|
82
84
|
is(schema) {
|
|
83
|
-
return schema === this.
|
|
85
|
+
return schema === this.flexSchema;
|
|
84
86
|
}
|
|
85
87
|
tryGetField(key) {
|
|
86
88
|
const field = this.mapTree.fields.get(key);
|
|
87
89
|
// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.
|
|
88
90
|
if (field !== undefined && field.length > 0) {
|
|
89
|
-
return getOrCreateField(this, key, this.
|
|
91
|
+
return getOrCreateField(this, key, this.flexSchema.getFieldSchema(key));
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
getBoxed(key) {
|
|
93
95
|
const fieldKey = brand(key);
|
|
94
|
-
return getOrCreateField(this, fieldKey, this.
|
|
96
|
+
return getOrCreateField(this, fieldKey, this.flexSchema.getFieldSchema(fieldKey));
|
|
95
97
|
}
|
|
96
98
|
boxedIterator() {
|
|
97
|
-
return mapIterable(this.mapTree.fields.entries(), ([key]) => getOrCreateField(this, key, this.
|
|
99
|
+
return mapIterable(this.mapTree.fields.entries(), ([key]) => getOrCreateField(this, key, this.flexSchema.getFieldSchema(key)));
|
|
100
|
+
}
|
|
101
|
+
keys() {
|
|
102
|
+
// TODO: how this should handle missing defaults (and empty keys if they end up being allowed) needs to be determined.
|
|
103
|
+
return this.mapTree.fields.keys();
|
|
98
104
|
}
|
|
99
105
|
get value() {
|
|
100
106
|
return this.mapTree.value;
|
|
@@ -106,9 +112,9 @@ export class EagerMapTreeNode {
|
|
|
106
112
|
}
|
|
107
113
|
walkTree() {
|
|
108
114
|
for (const [key, mapTrees] of this.mapTree.fields) {
|
|
109
|
-
const field = getOrCreateField(this, key, this.
|
|
115
|
+
const field = getOrCreateField(this, key, this.flexSchema.getFieldSchema(key));
|
|
110
116
|
for (let index = 0; index < field.length; index++) {
|
|
111
|
-
const child = getOrCreateChild(mapTrees[index] ?? oob(), this.
|
|
117
|
+
const child = getOrCreateChild(this.context, mapTrees[index] ?? oob(), this.flexSchema.getFieldSchema(key).allowedTypes, { parent: field, index });
|
|
112
118
|
// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create
|
|
113
119
|
assert(child.location !== undefined, 0x98d /* Expected node to have parent */);
|
|
114
120
|
assert(child.location.parent.parent === this, 0x98e /* Node may not be multi-parented */);
|
|
@@ -119,34 +125,33 @@ export class EagerMapTreeNode {
|
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
_a = flexTreeMarker;
|
|
128
|
+
// #endregion Nodes
|
|
122
129
|
/**
|
|
123
|
-
*
|
|
130
|
+
* Implementation of `FlexTreeContext`.
|
|
131
|
+
*
|
|
132
|
+
* @remarks An editor is required to edit the FlexTree.
|
|
124
133
|
*/
|
|
125
|
-
export class
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
unboxedField(this.tryGetField(key) ?? fail("Unexpected empty map field"), key, this.mapTree, this),
|
|
136
|
-
]);
|
|
137
|
-
}
|
|
138
|
-
getBoxed(key) {
|
|
139
|
-
return super.getBoxed(key);
|
|
140
|
-
}
|
|
141
|
-
[Symbol.iterator]() {
|
|
142
|
-
return this.entries();
|
|
134
|
+
export class UnhydratedContext {
|
|
135
|
+
/**
|
|
136
|
+
* @param flexSchema - Schema to use when working with the tree.
|
|
137
|
+
*/
|
|
138
|
+
constructor(flexSchema) {
|
|
139
|
+
this.flexSchema = flexSchema;
|
|
140
|
+
this.schema = {
|
|
141
|
+
rootFieldSchema: flexSchema.rootFieldSchema.stored,
|
|
142
|
+
...intoStoredSchemaCollection(flexSchema),
|
|
143
|
+
};
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
get value() {
|
|
147
|
-
return super.value;
|
|
145
|
+
isHydrated() {
|
|
146
|
+
return false;
|
|
148
147
|
}
|
|
149
148
|
}
|
|
149
|
+
const emptyContext = new UnhydratedContext({
|
|
150
|
+
adapters: {},
|
|
151
|
+
nodeSchema: new Map(),
|
|
152
|
+
policy: defaultSchemaPolicy,
|
|
153
|
+
rootFieldSchema: FlexFieldSchema.empty,
|
|
154
|
+
});
|
|
150
155
|
/**
|
|
151
156
|
* A special singleton that is the implicit {@link LocationInField} of all un-parented {@link EagerMapTreeNode}s.
|
|
152
157
|
* @remarks This exists because {@link EagerMapTreeNode.parentField} must return a field.
|
|
@@ -161,8 +166,8 @@ const unparentedLocation = {
|
|
|
161
166
|
length: 0,
|
|
162
167
|
key: EmptyKey,
|
|
163
168
|
parent: undefined,
|
|
164
|
-
is(
|
|
165
|
-
return schema ===
|
|
169
|
+
is(kind) {
|
|
170
|
+
return this.schema.kind === kind.identifier;
|
|
166
171
|
},
|
|
167
172
|
boxedIterator() {
|
|
168
173
|
return [].values();
|
|
@@ -170,15 +175,22 @@ const unparentedLocation = {
|
|
|
170
175
|
boxedAt(index) {
|
|
171
176
|
return undefined;
|
|
172
177
|
},
|
|
173
|
-
schema: FlexFieldSchema.empty,
|
|
174
|
-
context:
|
|
178
|
+
schema: FlexFieldSchema.empty.stored,
|
|
179
|
+
context: emptyContext,
|
|
175
180
|
mapTrees: [],
|
|
181
|
+
getFieldPath() {
|
|
182
|
+
fail("unsupported");
|
|
183
|
+
},
|
|
176
184
|
},
|
|
177
185
|
index: -1,
|
|
178
186
|
};
|
|
179
187
|
class EagerMapTreeField {
|
|
180
|
-
|
|
181
|
-
this.
|
|
188
|
+
get schema() {
|
|
189
|
+
return this.flexSchema.stored;
|
|
190
|
+
}
|
|
191
|
+
constructor(context, flexSchema, key, parent) {
|
|
192
|
+
this.context = context;
|
|
193
|
+
this.flexSchema = flexSchema;
|
|
182
194
|
this.key = key;
|
|
183
195
|
this.parent = parent;
|
|
184
196
|
this[_b] = FlexTreeEntityKind.Field;
|
|
@@ -203,12 +215,12 @@ class EagerMapTreeField {
|
|
|
203
215
|
get length() {
|
|
204
216
|
return this.mapTrees.length;
|
|
205
217
|
}
|
|
206
|
-
is(
|
|
207
|
-
return this.schema.
|
|
218
|
+
is(kind) {
|
|
219
|
+
return this.schema.kind === kind.identifier;
|
|
208
220
|
}
|
|
209
221
|
boxedIterator() {
|
|
210
222
|
return this.mapTrees
|
|
211
|
-
.map((m, index) => getOrCreateChild(m, this.
|
|
223
|
+
.map((m, index) => getOrCreateChild(this.context, m, this.flexSchema.allowedTypes, {
|
|
212
224
|
parent: this,
|
|
213
225
|
index,
|
|
214
226
|
}))
|
|
@@ -221,7 +233,7 @@ class EagerMapTreeField {
|
|
|
221
233
|
}
|
|
222
234
|
const m = this.mapTrees[i];
|
|
223
235
|
if (m !== undefined) {
|
|
224
|
-
return getOrCreateChild(m, this.
|
|
236
|
+
return getOrCreateChild(this.context, m, this.flexSchema.allowedTypes, {
|
|
225
237
|
parent: this,
|
|
226
238
|
index: i,
|
|
227
239
|
});
|
|
@@ -245,6 +257,9 @@ class EagerMapTreeField {
|
|
|
245
257
|
this.parent.mapTree.fields.delete(this.key);
|
|
246
258
|
}
|
|
247
259
|
}
|
|
260
|
+
getFieldPath() {
|
|
261
|
+
throw unsupportedUsageError("Editing an array");
|
|
262
|
+
}
|
|
248
263
|
}
|
|
249
264
|
_b = flexTreeMarker;
|
|
250
265
|
class EagerMapTreeOptionalField extends EagerMapTreeField {
|
|
@@ -275,7 +290,7 @@ class EagerMapTreeOptionalField extends EagerMapTreeField {
|
|
|
275
290
|
get content() {
|
|
276
291
|
const value = this.mapTrees[0];
|
|
277
292
|
if (value !== undefined) {
|
|
278
|
-
return
|
|
293
|
+
return unboxed(this.flexSchema, value, {
|
|
279
294
|
parent: this,
|
|
280
295
|
index: 0,
|
|
281
296
|
});
|
|
@@ -328,19 +343,16 @@ class EagerMapTreeSequenceField extends EagerMapTreeField {
|
|
|
328
343
|
if (i === undefined) {
|
|
329
344
|
return undefined;
|
|
330
345
|
}
|
|
331
|
-
return
|
|
346
|
+
return unboxed(this.flexSchema, this.mapTrees[i] ?? oob(), { parent: this, index: i });
|
|
332
347
|
}
|
|
333
348
|
map(callbackfn) {
|
|
334
349
|
return Array.from(this, callbackfn);
|
|
335
350
|
}
|
|
336
351
|
*[Symbol.iterator]() {
|
|
337
352
|
for (const [i, mapTree] of this.mapTrees.entries()) {
|
|
338
|
-
yield
|
|
353
|
+
yield unboxed(this.flexSchema, mapTree, { parent: this, index: i });
|
|
339
354
|
}
|
|
340
355
|
}
|
|
341
|
-
getFieldPath() {
|
|
342
|
-
throw unsupportedUsageError("Editing an array");
|
|
343
|
-
}
|
|
344
356
|
}
|
|
345
357
|
// #endregion Fields
|
|
346
358
|
// #region Caching and unboxing utilities
|
|
@@ -363,36 +375,26 @@ export function tryGetMapTreeNode(mapTree) {
|
|
|
363
375
|
* @param mapTree - the {@link MapTree} containing the data for this node.
|
|
364
376
|
* @remarks It must conform to the `nodeSchema`.
|
|
365
377
|
*/
|
|
366
|
-
export function getOrCreateMapTreeNode(nodeSchema, mapTree) {
|
|
367
|
-
return nodeCache.get(mapTree) ?? createNode(nodeSchema, mapTree, undefined);
|
|
378
|
+
export function getOrCreateMapTreeNode(context, nodeSchema, mapTree) {
|
|
379
|
+
return nodeCache.get(mapTree) ?? createNode(context, nodeSchema, mapTree, undefined);
|
|
368
380
|
}
|
|
369
381
|
/** Helper for creating a `MapTreeNode` given the parent field (e.g. when "walking down") */
|
|
370
|
-
function getOrCreateChild(mapTree,
|
|
382
|
+
function getOrCreateChild(context, mapTree, allowedTypes, parent) {
|
|
371
383
|
const cached = nodeCache.get(mapTree);
|
|
372
384
|
if (cached !== undefined) {
|
|
373
385
|
return cached;
|
|
374
386
|
}
|
|
375
|
-
|
|
387
|
+
assert(isReadonlyArray(allowedTypes), 0xa25 /* invalid types */);
|
|
376
388
|
const nodeSchema = allowedTypes
|
|
377
389
|
.map((t) => (isLazy(t) ? t() : t))
|
|
378
390
|
.find((t) => {
|
|
379
|
-
assert(t !== "Any", 0x993 /* 'Any' type is not supported */);
|
|
380
391
|
return t.name === mapTree.type;
|
|
381
392
|
}) ?? fail("Unsupported node schema");
|
|
382
|
-
return createNode(nodeSchema, mapTree, parent);
|
|
393
|
+
return createNode(context, nodeSchema, mapTree, parent);
|
|
383
394
|
}
|
|
384
395
|
/** Always constructs a new node, therefore may not be called twice for the same `MapTree`. */
|
|
385
|
-
function createNode(nodeSchema, mapTree, parentField) {
|
|
386
|
-
|
|
387
|
-
return new EagerMapTreeLeafNode(nodeSchema, mapTree, parentField);
|
|
388
|
-
}
|
|
389
|
-
if (schemaIsMap(nodeSchema)) {
|
|
390
|
-
return new EagerMapTreeMapNode(nodeSchema, mapTree, parentField);
|
|
391
|
-
}
|
|
392
|
-
if (schemaIsObjectNode(nodeSchema)) {
|
|
393
|
-
return new EagerMapTreeNode(nodeSchema, mapTree, parentField);
|
|
394
|
-
}
|
|
395
|
-
assert(false, 0x994 /* Unrecognized node kind */);
|
|
396
|
+
function createNode(context, nodeSchema, mapTree, parentField) {
|
|
397
|
+
return new EagerMapTreeNode(context, nodeSchema, mapTree, parentField);
|
|
396
398
|
}
|
|
397
399
|
/** Creates a field with the given attributes, or returns a cached field if there is one */
|
|
398
400
|
function getOrCreateField(parent, key, schema) {
|
|
@@ -402,46 +404,23 @@ function getOrCreateField(parent, key, schema) {
|
|
|
402
404
|
}
|
|
403
405
|
if (schema.kind.identifier === FieldKinds.required.identifier ||
|
|
404
406
|
schema.kind.identifier === FieldKinds.identifier.identifier) {
|
|
405
|
-
return new EagerMapTreeRequiredField(schema, key, parent);
|
|
407
|
+
return new EagerMapTreeRequiredField(parent.context, schema, key, parent);
|
|
406
408
|
}
|
|
407
409
|
if (schema.kind.identifier === FieldKinds.optional.identifier) {
|
|
408
|
-
return new EagerMapTreeOptionalField(schema, key, parent);
|
|
410
|
+
return new EagerMapTreeOptionalField(parent.context, schema, key, parent);
|
|
409
411
|
}
|
|
410
412
|
if (schema.kind.identifier === FieldKinds.sequence.identifier) {
|
|
411
|
-
return new EagerMapTreeSequenceField(schema, key, parent);
|
|
413
|
+
return new EagerMapTreeSequenceField(parent.context, schema, key, parent);
|
|
412
414
|
}
|
|
413
|
-
return new EagerMapTreeField(schema, key, parent);
|
|
415
|
+
return new EagerMapTreeField(parent.context, schema, key, parent);
|
|
414
416
|
}
|
|
415
|
-
/** Unboxes
|
|
416
|
-
function
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
return mapTree.value;
|
|
421
|
-
}
|
|
422
|
-
return getOrCreateChild(mapTree, type, parent);
|
|
423
|
-
}
|
|
424
|
-
return getOrCreateChild(mapTree, schema.allowedTypes, parent);
|
|
425
|
-
}
|
|
426
|
-
/** Unboxes non-polymorphic required and optional fields holding leaf nodes to their values, if applicable */
|
|
427
|
-
function unboxedField(field, key, mapTree, parentNode) {
|
|
428
|
-
const fieldSchema = field.schema;
|
|
429
|
-
const mapTrees = mapTree.fields.get(key) ?? fail("Key does not exist in unhydrated map tree");
|
|
430
|
-
if (fieldSchema.kind === FieldKinds.required) {
|
|
431
|
-
return unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {
|
|
432
|
-
parent: field,
|
|
433
|
-
index: 0,
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
if (fieldSchema.kind === FieldKinds.optional) {
|
|
437
|
-
return (mapTrees.length > 0
|
|
438
|
-
? unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {
|
|
439
|
-
parent: field,
|
|
440
|
-
index: 0,
|
|
441
|
-
})
|
|
442
|
-
: undefined);
|
|
417
|
+
/** Unboxes leaf nodes to their values */
|
|
418
|
+
function unboxed(schema, mapTree, parent) {
|
|
419
|
+
const value = mapTree.value;
|
|
420
|
+
if (value !== undefined) {
|
|
421
|
+
return value;
|
|
443
422
|
}
|
|
444
|
-
return
|
|
423
|
+
return getOrCreateChild(parent.parent.context, mapTree, schema.allowedTypes, parent);
|
|
445
424
|
}
|
|
446
425
|
// #endregion Caching and unboxing utilities
|
|
447
426
|
export function unsupportedUsageError(message) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapTreeNode.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-map-tree/mapTreeNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAEN,QAAQ,GAQR,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EACN,kBAAkB,EAalB,cAAc,EACd,UAAU,GACV,MAAM,uB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AED,6GAA6G;AAC7G,SAAS,YAAY,CACpB,KAA0C,EAC1C,GAAa,EACb,OAAyB,EACzB,UAAgD;IAEhD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,MAAM,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,2CAA2C,CAAC,CAAC;IAE9E,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE;YACtD,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,CAAC;SACR,CAAqC,CAAC;IACxC,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,CACN,QAAQ,CAAC,MAAM,GAAG,CAAC;YAClB,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE;gBAChD,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,CAAC;aACR,CAAC;YACH,CAAC,CAAC,SAAS,CACwB,CAAC;IACvC,CAAC;IAED,OAAO,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,WAAW,CAAqC,CAAC;AAC3F,CAAC;AAED,4CAA4C;AAE5C,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,UAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC","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\";\nimport {\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype MapTree,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, fail, getOrCreate, mapIterable } from \"../../util/index.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeLeafNode,\n\ttype FlexTreeMapNode,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNode,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxField,\n\ttype FlexTreeUnboxNodeUnion,\n\tflexTreeMarker,\n\tindexForAt,\n} from \"../flex-tree/index.js\";\nimport {\n\ttype FlexAllowedTypes,\n\tFlexFieldSchema,\n\ttype FlexMapNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype LeafNodeSchema,\n\tisLazy,\n\tschemaIsLeaf,\n\tschemaIsMap,\n\tschemaIsObjectNode,\n} from \"../typed-schema/index.js\";\nimport { type FlexImplicitAllowedTypes, normalizeAllowedTypes } from \"../schemaBuilderBase.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport { FieldKinds, type SequenceFieldEditBuilder } from \"../default-schema/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n// #region Nodes\n\n/**\n * A readonly {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Reading data from the MapTreeNode will read the corresponding data from the {@link MapTree}.\n * Create a `MapTreeNode` by calling {@link getOrCreateMapTreeNode}.\n */\nexport interface MapTreeNode extends FlexTreeNode {\n\treadonly mapTree: MapTree;\n}\n\n/**\n * Checks if the given {@link FlexTreeNode} is a {@link MapTreeNode}.\n */\nexport function isMapTreeNode(flexNode: FlexTreeNode): flexNode is MapTreeNode {\n\treturn flexNode instanceof EagerMapTreeNode;\n}\n\n/**\n * Checks if the given {@link FlexTreeField} is a {@link MapTreeSequenceField}.\n */\nexport function isMapTreeSequenceField<T extends FlexAllowedTypes>(\n\tfield: FlexTreeSequenceField<T> | FlexTreeField,\n): field is MapTreeSequenceField<T> {\n\treturn field instanceof EagerMapTreeSequenceField;\n}\n\n/**\n * An unhydrated {@link FlexTreeSequenceField}, which has additional editing capabilities.\n * @remarks When doing a removal edit, a {@link MapTreeSequenceField}'s `editor` returns ownership of the removed {@link ExclusiveMapTree}s to the caller.\n */\nexport interface MapTreeSequenceField<T extends FlexAllowedTypes>\n\textends FlexTreeSequenceField<T> {\n\treadonly editor: MapTreeSequenceFieldEditBuilder;\n}\n\ninterface MapTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: MapTreeField;\n\treadonly index: number;\n}\n\n/**\n * A readonly implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Any methods that would mutate the node will fail,\n * as will the querying of data specific to the {@link LazyTreeNode} implementation (e.g. {@link FlexTreeNode.context}).\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `MapTreeNode` object.\n */\nexport class EagerMapTreeNode<TSchema extends FlexTreeNodeSchema> implements MapTreeNode {\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\t/**\n\t * Create a new MapTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a MapTreeNode from a {@link MapTree}.\n\t * A `MapTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schema: TSchema,\n\t\t/** The underlying {@link MapTree} that this `MapTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a MapTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing MapTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor MapTreeNode can be created after any number of its descendant MapTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all MapTreeNodes that are descendants of the ancestor MapTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding MapTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.schema.name;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: MapTreeField, index: number): void;\n\tpublic adoptBy(parent: MapTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.location === unparentedLocation,\n\t\t\t\t0x98c /* Node may not be adopted if it already has a parent */,\n\t\t\t);\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic is<TSchemaInner extends FlexTreeNodeSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedNode<TSchemaInner> {\n\t\treturn (schema as unknown) === this.schema;\n\t}\n\n\tpublic tryGetField(key: FieldKey): EagerMapTreeField<FlexAllowedTypes> | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(this, fieldKey, this.schema.getFieldSchema(fieldKey));\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.schema.getFieldSchema(key)),\n\t\t);\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic context = undefined;\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `MapTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(\"MapTreeNode does not implement anchorNode\");\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(this, key, this.schema.getFieldSchema(key));\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(\n\t\t\t\t\tmapTrees[index] ?? oob(),\n\t\t\t\t\tthis.schema.getFieldSchema(key).allowedTypes,\n\t\t\t\t\t{ parent: field, index },\n\t\t\t\t);\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * The implementation of a map node created by {@link getOrCreateNode}.\n */\nexport class EagerMapTreeMapNode<TSchema extends FlexMapNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeMapNode<TSchema>\n{\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic values(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">> {\n\t\treturn mapIterable(\n\t\t\tthis.mapTree.fields.keys(),\n\t\t\t(key) =>\n\t\t\t\tunboxedField(\n\t\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\t\tkey,\n\t\t\t\t\tthis.mapTree,\n\t\t\t\t\tthis,\n\t\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t);\n\t}\n\n\tpublic entries(): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn mapIterable(this.mapTree.fields.keys(), (key) => [\n\t\t\tkey,\n\t\t\tunboxedField(\n\t\t\t\tthis.tryGetField(key) ?? fail(\"Unexpected empty map field\"),\n\t\t\t\tkey,\n\t\t\t\tthis.mapTree,\n\t\t\t\tthis,\n\t\t\t) as FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t]);\n\t}\n\n\tpublic override getBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]> {\n\t\treturn super.getBoxed(key) as FlexTreeTypedField<TSchema[\"info\"]>;\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t> {\n\t\treturn this.entries();\n\t}\n}\n\nclass EagerMapTreeLeafNode<TSchema extends LeafNodeSchema>\n\textends EagerMapTreeNode<TSchema>\n\timplements FlexTreeLeafNode<TSchema>\n{\n\tpublic override get value(): TreeValue<TSchema[\"info\"]> {\n\t\treturn super.value as TreeValue<TSchema[\"info\"]>;\n\t}\n}\n\n// #endregion Nodes\n\n// #region Fields\n\n/**\n * A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.\n * @remarks Reading data from the MapTreeField will read the corresponding data from the {@link MapTree}s.\n * Create a `MapTreeField` by calling {@link getOrCreateField}.\n */\ninterface MapTreeField extends FlexTreeField {\n\treadonly mapTrees: readonly MapTree[];\n}\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link EagerMapTreeNode}s.\n * @remarks This exists because {@link EagerMapTreeNode.parentField} must return a field.\n * If a {@link EagerMapTreeNode} is created without a parent, its {@link EagerMapTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TSchema extends FlexFieldSchema>(schema: TSchema) {\n\t\t\treturn schema === (FlexFieldSchema.empty as FlexFieldSchema);\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: FlexFieldSchema.empty,\n\t\tcontext: undefined,\n\t\tmapTrees: [],\n\t},\n\tindex: -1,\n};\n\nclass EagerMapTreeField<T extends FlexAllowedTypes> implements MapTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic constructor(\n\t\tpublic readonly schema: FlexFieldSchema<FlexFieldKind, T>,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TSchemaInner extends FlexFieldSchema>(\n\t\tschema: TSchemaInner,\n\t): this is FlexTreeTypedField<TSchemaInner> {\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<T>> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(m, this.schema.allowedTypes, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode as FlexTreeTypedNodeUnion<T>;\n\t\t}\n\t}\n\n\tpublic context: undefined;\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\t}\n}\n\nclass EagerMapTreeOptionalField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeOptionalField<T>\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a MapTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a MapTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn unboxedUnion(this.schema, value, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: 0,\n\t\t\t});\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField<T extends FlexAllowedTypes>\n\textends EagerMapTreeOptionalField<T>\n\timplements FlexTreeRequiredField<T>\n{\n\tpublic override get content(): FlexTreeUnboxNodeUnion<T> {\n\t\treturn super.content ?? fail(\"Expected EagerMapTree required field to have a value\");\n\t}\n}\n\nclass EagerMapTreeSequenceField<T extends FlexAllowedTypes>\n\textends EagerMapTreeField<T>\n\timplements FlexTreeSequenceField<T>\n{\n\tpublic readonly editor: MapTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(\"Expected removed to be set by edit\");\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<T> | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn unboxedUnion(this.schema, this.mapTrees[i] ?? oob(), { parent: this, index: i });\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<T>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<T>> {\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tyield unboxedUnion(this.schema, mapTree, { parent: this, index: i });\n\t\t}\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, EagerMapTreeNode<FlexTreeNodeSchema>>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<\n\tMapTreeNode,\n\tMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>>\n>();\nfunction getFieldKeyCache(\n\tparent: MapTreeNode,\n): WeakMap<FieldKey, EagerMapTreeField<FlexAllowedTypes>> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link EagerMapTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link EagerMapTreeNode | MapTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryGetMapTreeNode(mapTree: MapTree): MapTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/**\n * Create a {@link EagerMapTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n * @param mapTree - the {@link MapTree} containing the data for this node.\n * @remarks It must conform to the `nodeSchema`.\n */\nexport function getOrCreateMapTreeNode(\n\tnodeSchema: FlexTreeNodeSchema,\n\tmapTree: ExclusiveMapTree,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\treturn nodeCache.get(mapTree) ?? createNode(nodeSchema, mapTree, undefined);\n}\n\n/** Helper for creating a `MapTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tmapTree: ExclusiveMapTree,\n\timplicitAllowedTypes: FlexImplicitAllowedTypes,\n\tparent: LocationInField | undefined,\n): EagerMapTreeNode<FlexTreeNodeSchema> {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst allowedTypes = normalizeAllowedTypes(implicitAllowedTypes);\n\tconst nodeSchema =\n\t\tallowedTypes\n\t\t\t.map((t) => (isLazy(t) ? t() : t))\n\t\t\t.find((t): t is FlexTreeNodeSchema => {\n\t\t\t\tassert(t !== \"Any\", 0x993 /* 'Any' type is not supported */);\n\t\t\t\treturn t.name === mapTree.type;\n\t\t\t}) ?? fail(\"Unsupported node schema\");\n\n\treturn createNode(nodeSchema, mapTree, parent);\n}\n\n/** Always constructs a new node, therefore may not be called twice for the same `MapTree`. */\nfunction createNode<TSchema extends FlexTreeNodeSchema>(\n\tnodeSchema: TSchema,\n\tmapTree: ExclusiveMapTree,\n\tparentField: LocationInField | undefined,\n): EagerMapTreeNode<TSchema> {\n\tif (schemaIsLeaf(nodeSchema)) {\n\t\treturn new EagerMapTreeLeafNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsMap(nodeSchema)) {\n\t\treturn new EagerMapTreeMapNode(nodeSchema, mapTree, parentField);\n\t}\n\tif (schemaIsObjectNode(nodeSchema)) {\n\t\treturn new EagerMapTreeNode(nodeSchema, mapTree, parentField);\n\t}\n\tassert(false, 0x994 /* Unrecognized node kind */);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: EagerMapTreeNode<FlexTreeNodeSchema>,\n\tkey: FieldKey,\n\tschema: FlexFieldSchema,\n): EagerMapTreeField<FlexFieldSchema[\"allowedTypes\"]> {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema.kind.identifier === FieldKinds.required.identifier ||\n\t\tschema.kind.identifier === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.sequence.identifier) {\n\t\treturn new EagerMapTreeSequenceField(schema, key, parent);\n\t}\n\n\treturn new EagerMapTreeField(schema, key, parent);\n}\n\n/** Unboxes non-polymorphic leaf nodes to their values, if applicable */\nfunction unboxedUnion<TTypes extends FlexAllowedTypes>(\n\tschema: FlexFieldSchema<FlexFieldKind, TTypes>,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField,\n): FlexTreeUnboxNodeUnion<TTypes> {\n\tconst type = schema.monomorphicChildType;\n\tif (type !== undefined) {\n\t\tif (schemaIsLeaf(type)) {\n\t\t\treturn mapTree.value as FlexTreeUnboxNodeUnion<TTypes>;\n\t\t}\n\t\treturn getOrCreateChild(mapTree, type, parent) as FlexTreeUnboxNodeUnion<TTypes>;\n\t}\n\n\treturn getOrCreateChild(\n\t\tmapTree,\n\t\tschema.allowedTypes,\n\t\tparent,\n\t) as FlexTreeUnboxNodeUnion<TTypes>;\n}\n\n/** Unboxes non-polymorphic required and optional fields holding leaf nodes to their values, if applicable */\nfunction unboxedField<TFieldSchema extends FlexFieldSchema>(\n\tfield: EagerMapTreeField<FlexAllowedTypes>,\n\tkey: FieldKey,\n\tmapTree: ExclusiveMapTree,\n\tparentNode: EagerMapTreeNode<FlexTreeNodeSchema>,\n): FlexTreeUnboxField<TFieldSchema> {\n\tconst fieldSchema = field.schema;\n\tconst mapTrees =\n\t\tmapTree.fields.get(key) ?? fail(\"Key does not exist in unhydrated map tree\");\n\n\tif (fieldSchema.kind === FieldKinds.required) {\n\t\treturn unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\tparent: field,\n\t\t\tindex: 0,\n\t\t}) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\tif (fieldSchema.kind === FieldKinds.optional) {\n\t\treturn (\n\t\t\tmapTrees.length > 0\n\t\t\t\t? unboxedUnion(fieldSchema, mapTrees[0] ?? oob(), {\n\t\t\t\t\t\tparent: field,\n\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t})\n\t\t\t\t: undefined\n\t\t) as FlexTreeUnboxField<TFieldSchema>;\n\t}\n\n\treturn getOrCreateField(parentNode, key, fieldSchema) as FlexTreeUnboxField<TFieldSchema>;\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3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AAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC","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\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype MapTree,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchema,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, fail, getOrCreate, isReadonlyArray, mapIterable } from \"../../util/index.js\";\nimport {\n\ttype FlexTreeContext,\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tindexForAt,\n\ttype FlexTreeHydratedContext,\n} from \"../flex-tree/index.js\";\nimport {\n\ttype FlexAllowedTypes,\n\tFlexFieldSchema,\n\ttype FlexTreeNodeSchema,\n\ttype FlexTreeSchema,\n\tintoStoredSchemaCollection,\n\tisLazy,\n} from \"../typed-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport {\n\tdefaultSchemaPolicy,\n\tFieldKinds,\n\ttype SequenceFieldEditBuilder,\n} from \"../default-schema/index.js\";\n\n// #region Nodes\n\n/**\n * A readonly {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Reading data from the MapTreeNode will read the corresponding data from the {@link MapTree}.\n * Create a `MapTreeNode` by calling {@link getOrCreateMapTreeNode}.\n */\nexport interface MapTreeNode extends FlexTreeNode {\n\treadonly mapTree: MapTree;\n}\n\n/**\n * Checks if the given {@link FlexTreeNode} is a {@link MapTreeNode}.\n */\nexport function isMapTreeNode(flexNode: FlexTreeNode): flexNode is MapTreeNode {\n\treturn flexNode instanceof EagerMapTreeNode;\n}\n\n/**\n * Checks if the given {@link FlexTreeField} is a {@link MapTreeSequenceField}.\n */\nexport function isMapTreeSequenceField(\n\tfield: FlexTreeSequenceField | FlexTreeField,\n): field is MapTreeSequenceField {\n\treturn field instanceof EagerMapTreeSequenceField;\n}\n\n/**\n * An unhydrated {@link FlexTreeSequenceField}, which has additional editing capabilities.\n * @remarks When doing a removal edit, a {@link MapTreeSequenceField}'s `editor` returns ownership of the removed {@link ExclusiveMapTree}s to the caller.\n */\nexport interface MapTreeSequenceField extends FlexTreeSequenceField {\n\treadonly editor: MapTreeSequenceFieldEditBuilder;\n}\n\ninterface MapTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: MapTreeField;\n\treadonly index: number;\n}\n\n/**\n * A readonly implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks Any methods that would mutate the node will fail,\n * as will the querying of data specific to the {@link LazyTreeNode} implementation (e.g. {@link FlexTreeNode.context}).\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `MapTreeNode` object.\n */\nexport class EagerMapTreeNode implements MapTreeNode {\n\tpublic get schema(): TreeNodeSchemaIdentifier {\n\t\treturn this.flexSchema.name;\n\t}\n\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\t/**\n\t * Create a new MapTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a MapTreeNode from a {@link MapTree}.\n\t * A `MapTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly context: UnhydratedContext,\n\t\tpublic readonly flexSchema: FlexTreeNodeSchema,\n\t\t/** The underlying {@link MapTree} that this `MapTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a MapTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing MapTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor MapTreeNode can be created after any number of its descendant MapTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all MapTreeNodes that are descendants of the ancestor MapTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding MapTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.flexSchema.name;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: MapTreeField, index: number): void;\n\tpublic adoptBy(parent: MapTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.location === unparentedLocation,\n\t\t\t\t0x98c /* Node may not be adopted if it already has a parent */,\n\t\t\t);\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic is(schema: FlexTreeNodeSchema): boolean {\n\t\treturn (schema as unknown) === this.flexSchema;\n\t}\n\n\tpublic tryGetField(key: FieldKey): EagerMapTreeField | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.flexSchema.getFieldSchema(key));\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(this, fieldKey, this.flexSchema.getFieldSchema(fieldKey));\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.flexSchema.getFieldSchema(key)),\n\t\t);\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\t// TODO: how this should handle missing defaults (and empty keys if they end up being allowed) needs to be determined.\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `MapTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(\"MapTreeNode does not implement anchorNode\");\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(this, key, this.flexSchema.getFieldSchema(key));\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(\n\t\t\t\t\tthis.context,\n\t\t\t\t\tmapTrees[index] ?? oob(),\n\t\t\t\t\tthis.flexSchema.getFieldSchema(key).allowedTypes,\n\t\t\t\t\t{ parent: field, index },\n\t\t\t\t);\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n}\n\n// #endregion Nodes\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class UnhydratedContext implements FlexTreeContext {\n\tpublic readonly schema: TreeStoredSchema;\n\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t */\n\tpublic constructor(public readonly flexSchema: FlexTreeSchema) {\n\t\tthis.schema = {\n\t\t\trootFieldSchema: flexSchema.rootFieldSchema.stored,\n\t\t\t...intoStoredSchemaCollection(flexSchema),\n\t\t};\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn false;\n\t}\n}\n\n// #region Fields\n\n/**\n * A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.\n * @remarks Reading data from the MapTreeField will read the corresponding data from the {@link MapTree}s.\n * Create a `MapTreeField` by calling {@link getOrCreateField}.\n */\ninterface MapTreeField extends FlexTreeField {\n\treadonly mapTrees: readonly MapTree[];\n}\n\nconst emptyContext = new UnhydratedContext({\n\tadapters: {},\n\tnodeSchema: new Map(),\n\tpolicy: defaultSchemaPolicy,\n\trootFieldSchema: FlexFieldSchema.empty,\n});\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link EagerMapTreeNode}s.\n * @remarks This exists because {@link EagerMapTreeNode.parentField} must return a field.\n * If a {@link EagerMapTreeNode} is created without a parent, its {@link EagerMapTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TKind2 extends FlexFieldKind>(kind: TKind2) {\n\t\t\treturn this.schema.kind === kind.identifier;\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: FlexFieldSchema.empty.stored,\n\t\tcontext: emptyContext,\n\t\tmapTrees: [],\n\t\tgetFieldPath() {\n\t\t\tfail(\"unsupported\");\n\t\t},\n\t},\n\tindex: -1,\n};\n\nclass EagerMapTreeField implements MapTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic get schema(): TreeFieldStoredSchema {\n\t\treturn this.flexSchema.stored;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly context: UnhydratedContext,\n\t\tpublic readonly flexSchema: FlexFieldSchema,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: EagerMapTreeNode,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\treturn this.schema.kind === kind.identifier;\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(this.context, m, this.flexSchema.allowedTypes, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(this.context, m, this.flexSchema.allowedTypes, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode;\n\t\t}\n\t}\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n}\n\nclass EagerMapTreeOptionalField extends EagerMapTreeField implements FlexTreeOptionalField {\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a MapTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a MapTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn unboxed(this.flexSchema, value, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: 0,\n\t\t\t});\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField\n\textends EagerMapTreeOptionalField\n\timplements FlexTreeRequiredField\n{\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\treturn super.content ?? fail(\"Expected EagerMapTree required field to have a value\");\n\t}\n}\n\nclass EagerMapTreeSequenceField extends EagerMapTreeField implements FlexTreeSequenceField {\n\tpublic readonly editor: MapTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(\"Expected removed to be set by edit\");\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn unboxed(this.flexSchema, this.mapTrees[i] ?? oob(), { parent: this, index: i });\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tyield unboxed(this.flexSchema, mapTree, { parent: this, index: i });\n\t\t}\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, EagerMapTreeNode>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<MapTreeNode, Map<FieldKey, EagerMapTreeField>>();\nfunction getFieldKeyCache(parent: MapTreeNode): WeakMap<FieldKey, EagerMapTreeField> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link EagerMapTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link EagerMapTreeNode | MapTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryGetMapTreeNode(mapTree: MapTree): MapTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/**\n * Create a {@link EagerMapTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n * @param mapTree - the {@link MapTree} containing the data for this node.\n * @remarks It must conform to the `nodeSchema`.\n */\nexport function getOrCreateMapTreeNode(\n\tcontext: UnhydratedContext,\n\tnodeSchema: FlexTreeNodeSchema,\n\tmapTree: ExclusiveMapTree,\n): EagerMapTreeNode {\n\treturn nodeCache.get(mapTree) ?? createNode(context, nodeSchema, mapTree, undefined);\n}\n\n/** Helper for creating a `MapTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tcontext: UnhydratedContext,\n\tmapTree: ExclusiveMapTree,\n\tallowedTypes: FlexAllowedTypes,\n\tparent: LocationInField | undefined,\n): EagerMapTreeNode {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tassert(isReadonlyArray(allowedTypes), 0xa25 /* invalid types */);\n\tconst nodeSchema =\n\t\tallowedTypes\n\t\t\t.map((t) => (isLazy(t) ? t() : t))\n\t\t\t.find((t): t is FlexTreeNodeSchema => {\n\t\t\t\treturn t.name === mapTree.type;\n\t\t\t}) ?? fail(\"Unsupported node schema\");\n\n\treturn createNode(context, nodeSchema, mapTree, parent);\n}\n\n/** Always constructs a new node, therefore may not be called twice for the same `MapTree`. */\nfunction createNode(\n\tcontext: UnhydratedContext,\n\tnodeSchema: FlexTreeNodeSchema,\n\tmapTree: ExclusiveMapTree,\n\tparentField: LocationInField | undefined,\n): EagerMapTreeNode {\n\treturn new EagerMapTreeNode(context, nodeSchema, mapTree, parentField);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: EagerMapTreeNode,\n\tkey: FieldKey,\n\tschema: FlexFieldSchema,\n): EagerMapTreeField {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema.kind.identifier === FieldKinds.required.identifier ||\n\t\tschema.kind.identifier === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(parent.context, schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(parent.context, schema, key, parent);\n\t}\n\n\tif (schema.kind.identifier === FieldKinds.sequence.identifier) {\n\t\treturn new EagerMapTreeSequenceField(parent.context, schema, key, parent);\n\t}\n\n\treturn new EagerMapTreeField(parent.context, schema, key, parent);\n}\n\n/** Unboxes leaf nodes to their values */\nfunction unboxed(\n\tschema: FlexFieldSchema,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField,\n): FlexTreeUnknownUnboxed {\n\tconst value = mapTree.value;\n\tif (value !== undefined) {\n\t\treturn value;\n\t}\n\n\treturn getOrCreateChild(parent.parent.context, mapTree, schema.allowedTypes, parent);\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\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 FieldKey, type ForestEvents, type TreeFieldStoredSchema } from "../../core/index.js";
|
|
5
|
+
import { type FieldKey, type ForestEvents, type TreeFieldStoredSchema, type TreeStoredSchema } from "../../core/index.js";
|
|
6
6
|
import type { Listenable } from "../../events/index.js";
|
|
7
7
|
import { type IDisposable, disposeSymbol } from "../../util/index.js";
|
|
8
8
|
import type { FieldGenerator } from "../fieldGenerator.js";
|
|
@@ -12,19 +12,36 @@ import type { FlexTreeField } from "./flexTreeTypes.js";
|
|
|
12
12
|
import { type LazyEntity } from "./lazyEntity.js";
|
|
13
13
|
import type { ITreeCheckout } from "../../shared-tree/index.js";
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* It handles group operations like transforming cursors into anchors for edits.
|
|
15
|
+
* Context for FlexTrees.
|
|
17
16
|
*/
|
|
18
|
-
export interface FlexTreeContext
|
|
17
|
+
export interface FlexTreeContext {
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
19
|
+
* Schema used within this context.
|
|
20
|
+
* All data must conform to these schema.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
readonly flexSchema: FlexTreeSchema;
|
|
23
23
|
/**
|
|
24
24
|
* Schema used within this context.
|
|
25
25
|
* All data must conform to these schema.
|
|
26
26
|
*/
|
|
27
|
-
readonly schema:
|
|
27
|
+
readonly schema: TreeStoredSchema;
|
|
28
|
+
/**
|
|
29
|
+
* If true, this context is the canonical context instance for a given view,
|
|
30
|
+
* and its schema include all schema from the document.
|
|
31
|
+
*
|
|
32
|
+
* If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.
|
|
33
|
+
*/
|
|
34
|
+
isHydrated(): this is FlexTreeHydratedContext;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A common context of a "forest" of FlexTrees.
|
|
38
|
+
* It handles group operations like transforming cursors into anchors for edits.
|
|
39
|
+
*/
|
|
40
|
+
export interface FlexTreeHydratedContext extends FlexTreeContext, Listenable<ForestEvents> {
|
|
41
|
+
/**
|
|
42
|
+
* Gets the root field of the tree.
|
|
43
|
+
*/
|
|
44
|
+
get root(): FlexTreeField;
|
|
28
45
|
readonly nodeKeyManager: NodeKeyManager;
|
|
29
46
|
/**
|
|
30
47
|
* The checkout object associated with this context.
|
|
@@ -34,9 +51,6 @@ export interface FlexTreeContext extends Listenable<ForestEvents> {
|
|
|
34
51
|
/**
|
|
35
52
|
* Creating multiple flex tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.
|
|
36
53
|
* This slot is used to detect if one already exists and error if creating a second.
|
|
37
|
-
*
|
|
38
|
-
* TODO:
|
|
39
|
-
* 1. API docs need to reflect this limitation or the limitation has to be removed.
|
|
40
54
|
*/
|
|
41
55
|
export declare const ContextSlot: import("../../core/index.js").AnchorSlot<Context>;
|
|
42
56
|
/**
|
|
@@ -44,8 +58,8 @@ export declare const ContextSlot: import("../../core/index.js").AnchorSlot<Conte
|
|
|
44
58
|
*
|
|
45
59
|
* @remarks An editor is required to edit the FlexTree.
|
|
46
60
|
*/
|
|
47
|
-
export declare class Context implements
|
|
48
|
-
readonly
|
|
61
|
+
export declare class Context implements FlexTreeHydratedContext, IDisposable {
|
|
62
|
+
readonly flexSchema: FlexTreeSchema;
|
|
49
63
|
readonly checkout: ITreeCheckout;
|
|
50
64
|
readonly nodeKeyManager: NodeKeyManager;
|
|
51
65
|
readonly withCursors: Set<LazyEntity>;
|
|
@@ -53,11 +67,13 @@ export declare class Context implements FlexTreeContext, IDisposable {
|
|
|
53
67
|
private readonly eventUnregister;
|
|
54
68
|
private disposed;
|
|
55
69
|
/**
|
|
56
|
-
* @param
|
|
70
|
+
* @param flexSchema - Schema to use when working with the tree.
|
|
57
71
|
* @param checkout - The checkout.
|
|
58
72
|
* @param nodeKeyManager - An object which handles node key generation and conversion
|
|
59
73
|
*/
|
|
60
|
-
constructor(
|
|
74
|
+
constructor(flexSchema: FlexTreeSchema, checkout: ITreeCheckout, nodeKeyManager: NodeKeyManager);
|
|
75
|
+
isHydrated(): this is FlexTreeHydratedContext;
|
|
76
|
+
get schema(): TreeStoredSchema;
|
|
61
77
|
/**
|
|
62
78
|
* Called before editing.
|
|
63
79
|
* Clears all cursors so editing can proceed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAGrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,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