@fluidframework/tree 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 -6
- package/api-report/tree.beta.api.md +21 -6
- 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 +6 -6
- package/dist/alpha.d.ts +102 -0
- package/dist/beta.d.ts +6 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +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 +4 -6
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +15 -1
- 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} +49 -28
- 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 -35
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +82 -115
- 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 -281
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +15 -32
- 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 +1 -3
- 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 -29
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -17
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +6 -34
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +23 -159
- 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 -13
- 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 +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +83 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -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.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +51 -21
- 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 +33 -38
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +2 -2
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +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 +78 -7
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +219 -30
- 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 +23 -8
- 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 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/{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 +4 -6
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +15 -1
- 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} +49 -27
- 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 -35
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +83 -116
- 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 -281
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +15 -31
- 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 +2 -2
- 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 -29
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -16
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +6 -34
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +24 -156
- 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 +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +83 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -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.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +53 -23
- 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 +36 -41
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +2 -2
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +2 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/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 +78 -7
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +211 -24
- 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 +23 -8
- 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 +58 -36
- 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 +35 -9
- package/src/core/tree/detachedFieldIndex.ts +6 -5
- package/src/core/tree/visitDelta.ts +7 -2
- package/src/events/{events.ts → emitter.ts} +55 -134
- 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 -231
- 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 -458
- package/src/feature-libraries/flex-tree/index.ts +7 -29
- package/src/feature-libraries/flex-tree/lazyEntity.ts +2 -11
- package/src/feature-libraries/flex-tree/lazyField.ts +49 -79
- package/src/feature-libraries/flex-tree/lazyNode.ts +26 -306
- 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 -41
- 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 +5 -1
- 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 +63 -22
- 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 +38 -41
- package/src/simple-tree/core/index.ts +4 -0
- package/src/simple-tree/core/schemaCaching.ts +10 -0
- package/src/simple-tree/core/treeNodeKernel.ts +279 -27
- package/src/simple-tree/core/treeNodeSchema.ts +1 -1
- package/src/simple-tree/core/types.ts +23 -8
- package/src/simple-tree/core/withType.ts +3 -1
- package/src/simple-tree/index.ts +29 -20
- 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 -201
- 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 -201
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAMN,UAAU,GACV,MAAM,qBAAqB,CAAC;AAyB7B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAgB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,CAAU;IAC1C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,cAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED;GACG;AACH,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AA4CD;;;GAGG;AACH,MAAM,CAAN,IAAY,UAoBX;AApBD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,yCAAO,CAAA;AACR,CAAC,EApBW,UAAU,KAAV,UAAU,QAoBrB;AAmUD;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG;IACnD,YAAY;IACZ,aAAa;IACb,SAAS;IACT,IAAI;IACJ,aAAa;IACb,QAAQ;IACR,aAAa;IACb,MAAM;IACN,OAAO;IACP,eAAe;IACf,UAAU;IACV,UAAU;CACD,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG;IAC1D,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;CACE,CAAC;AAqSX,aAAa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type { Assume, FlattenKeys } from \"../../util/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type {\n\tAny,\n\tFlexAllowedTypes,\n\tFlexFieldSchema,\n\tFlexList,\n\tFlexListToUnion,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeFields,\n\tFlexObjectNodeSchema,\n\tFlexTreeNodeSchema,\n\tLazyItem,\n\tLeafNodeSchema,\n} from \"../typed-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nexport function isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity<out TSchema = unknown> {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TSchema;\n\n\t/**\n\t * A common context of a \"forest\" of FlexTrees.\n\t * @remarks This is `undefined` for unhydrated nodes or fields that have not yet been inserted into the tree.\n\t */\n\treadonly context?: FlexTreeContext;\n\n\t/**\n\t * Iterate through all nodes/fields in this field/node.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeEntity>;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n *\n * @remarks\n * Down-casting (via {@link FlexTreeNode#is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity<FlexTreeNodeSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexTreeNodeSchema>(schema: TSchema): this is FlexTreeTypedNode<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity<FlexFieldSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexFieldSchema>(schema: TSchema): this is FlexTreeTypedField<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n}\n\n// #region Node Kinds\n\n/**\n * A {@link FlexTreeNode} that behaves like a `Map<string, Field>` for a specific `Field` type.\n *\n * @remarks\n * Unlike TypeScript Map type, {@link FlexTreeMapNode.get} always provides a reference to any field looked up, even if it has never been set.\n *\n * This means that, for example, a `MapNode` of {@link FlexTreeSequenceField} fields will return an empty sequence when a previously unused key is looked up,\n * and that sequence can be used to insert new items into the field.\n * Additionally empty fields (those containing no nodes) are not distinguished from fields which do not exist.\n * This differs from JavaScript Maps which have a subtle distinction between storing undefined as a value in the map and deleting an entry from the map.\n */\nexport interface FlexTreeMapNode<in out TSchema extends FlexMapNodeSchema>\n\textends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which map entry to look up.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, so `get` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content into the map.\n\t */\n\tgetBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `values` will yield only the fields containing one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the values returned.\n\t */\n\tvalues(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `entries` will yield only the entries whose fields contain one or more nodes.\n\t *\n\t * This iteration provided by `entries()` is equivalent to that provided by direct iteration of the {@link FlexTreeMapNode} (a.k.a. `[Symbol.Iterator]()`).\n\t *\n\t * No guarantees are made regarding the order of the entries returned.\n\t */\n\tentries(): IterableIterator<[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]>;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the map.\n\t * @param callbackFn - The function to run for each map entry\n\t * @param thisArg - If present, `callbackFn` will be bound to `thisArg`\n\t *\n\t * @privateRemarks\n\t * TODO: This should run over fields in insertion order if we want to match the javascript foreach spec.\n\t */\n\tforEach(\n\t\tcallbackFn: (\n\t\t\tvalue: FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t\tkey: FieldKey,\n\t\t\tmap: FlexTreeMapNode<TSchema>,\n\t\t) => void,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthisArg?: any,\n\t): void;\n\n\t/**\n\t * Iterate through all fields in the map.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t * To iterate over the unboxed values of the map, use `Symbol.Iterator()`.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeTypedField<TSchema[\"info\"]>>;\n\n\t[Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t>;\n}\n\n/**\n * A {@link FlexTreeNode} that behaves like an \"object\" or \"struct\", providing properties to access its fields.\n *\n * ObjectNodes consist of a finite collection of fields, each with their own (distinct) key and {@link FlexFieldSchema}.\n *\n * @remarks\n * ObjectNodes require complex typing, and have been split into two parts for implementation purposes.\n * See {@link FlexTreeObjectNodeTyped} for the schema aware extensions to this that provide access to the fields.\n *\n * These \"Objects\" resemble \"Structs\" from a wide variety of programming languages\n * (Including Algol 68, C, Go, Rust, C# etc.).\n * ObjectNodes also somewhat resemble JavaScript objects: this analogy is less precise (objects don't have a fixed schema for example),\n * but for consistency with other systems in the JavaScript ecosystem (like JSON) is \"ObjectNodes\" nodes are named \"Objects\".\n *\n * Another common name for this abstraction is [record](https://en.wikipedia.org/wiki/Record_(computer_science)).\n * The name \"Record\" is avoided (in favor of Object) here because it has less precise connotations for most TypeScript developers.\n * For example, TypeScript has a built in `Record` type, but it requires all of the fields to have the same type,\n * putting its semantics half way between this library's \"Object\" schema and {@link FlexTreeMapNode}.\n */\nexport interface FlexTreeObjectNode extends FlexTreeNode {\n\treadonly schema: FlexObjectNodeSchema;\n}\n\n/**\n * Leaf holding a value.\n *\n * @remarks\n * Leaves are immutable and have no children.\n * Leaf unboxes its content, so in schema aware APIs which do unboxing, the Leaf itself will be skipped over and its value will be returned directly.\n */\nexport interface FlexTreeLeafNode<in out TSchema extends LeafNodeSchema> extends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value: TreeValue<TSchema[\"info\"]>;\n}\n\n/**\n * An {@link FlexTreeObjectNode} with schema aware accessors for its fields.\n *\n * @privateRemarks\n *\n * The corresponding implementation logic for this lives in `LazyTree.ts` under `buildStructClass`.\n * If you change the signature here, you will need to update that logic to match.\n */\nexport type FlexTreeObjectNodeTyped<TSchema extends FlexObjectNodeSchema> =\n\tFlexObjectNodeSchema extends TSchema\n\t\t? FlexTreeObjectNode\n\t\t: FlexTreeObjectNode & FlexTreeObjectNodeFields<TSchema[\"info\"]>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Support custom field keys.\n */\nexport type FlexTreeObjectNodeFields<TFields extends FlexObjectNodeFields> =\n\tFlexTreeObjectNodeFieldsInner<\n\t\tFlattenKeys<\n\t\t\t{\n\t\t\t\t// When the key does not need to be escaped, map it from the input TFields in a way that doesn't break navigate to declaration\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? key\n\t\t\t\t\t: never]: TFields[key];\n\t\t\t} & {\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? never\n\t\t\t\t\t: PropertyNameFromFieldKey<key & string>]: TFields[key];\n\t\t\t}\n\t\t>\n\t>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Do we keep assignment operator + \"setFoo\" methods, or just use methods?\n * Inconsistency in the API experience could confusing for consumers.\n */\nexport type FlexTreeObjectNodeFieldsInner<TFields extends FlexObjectNodeFields> = FlattenKeys<\n\t{\n\t\t// boxed fields (TODO: maybe remove these when same as non-boxed version?)\n\t\treadonly [key in keyof TFields as `boxed${Capitalize<key & string>}`]: FlexTreeTypedField<\n\t\t\tTFields[key]\n\t\t>;\n\t} & {\n\t\t// Add getter only (make property readonly) when the field is **not** of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? never\n\t\t\t: key]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Add setter (make property writable) when the field is of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\t-readonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? key\n\t\t\t: never]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Setter method (when the field is of a kind that has a logical set operation).\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? `set${Capitalize<key & string>}`\n\t\t\t: never]: (content: FlexibleNodeContent) => void;\n\t}\n>;\n\n/**\n * Reserved object node field property names to avoid collisions with the rest of the object node API.\n */\nexport const reservedObjectNodeFieldPropertyNames = [\n\t\"anchorNode\",\n\t\"constructor\",\n\t\"context\",\n\t\"is\",\n\t\"parentField\",\n\t\"schema\",\n\t\"tryGetField\",\n\t\"type\",\n\t\"value\",\n\t\"boxedIterator\",\n\t\"iterator\",\n\t\"getBoxed\",\n] as const;\n\n/**\n * Reserved object node field property names prefixes.\n * These are reserved to avoid collisions with properties derived from field other field names.\n *\n * Field names starting with these must be followed by a lowercase letter, or be escaped.\n */\nexport const reservedObjectNodeFieldPropertyNamePrefixes = [\n\t\"set\",\n\t\"boxed\",\n\t\"field\",\n\t\"Field\",\n] as const;\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n */\nexport type ReservedObjectNodeFieldPropertyNames =\n\t(typeof reservedObjectNodeFieldPropertyNames)[number];\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n */\nexport type ReservedObjectNodeFieldPropertyNamePrefixes =\n\t(typeof reservedObjectNodeFieldPropertyNamePrefixes)[number];\n\n/**\n * Convert an object node's field key into an escaped string usable as a property name.\n *\n * @privateRemarks\n * TODO:\n * Collisions are still possible.\n * For example fields named \"foo\" and \"Foo\" would both produce a setter \"setFoo\".\n * Consider naming schemes to avoid this, ensure that there is a good workaround for these cases.\n * Another approach would be to support custom field names (separate from keys),\n * and do the escaping (if needed) when creating the flex tree schema (both when manually creating them and when doing so automatically):\n * this would enable better intellisense for escaped fields, as well as allow the feature of custom field property names.\n */\nexport type PropertyNameFromFieldKey<T extends string> =\n\tT extends ReservedObjectNodeFieldPropertyNames\n\t\t? `field${Capitalize<T>}`\n\t\t: T extends `${ReservedObjectNodeFieldPropertyNamePrefixes}${Capitalize<string>}`\n\t\t\t? `field${Capitalize<T>}`\n\t\t\t: T;\n\n/**\n * Field kinds that allow value assignment.\n */\nexport type AssignableFieldKinds = typeof FieldKinds.optional | typeof FieldKinds.required;\n\n// #endregion\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\n\n/**\n * Tree for inserting a subsequence of nodes.\n *\n * Used to insert a batch of 0 or more nodes into some location in a {@link FlexTreeSequenceField}.\n */\nexport type FlexibleNodeSubSequence = ExclusiveMapTree[];\n\n/**\n * Type to ensures two types overlap in at least one way.\n * It evaluates to the input type if this is true, and never otherwise.\n * Examples:\n * CheckTypesOverlap\\<number | boolean, number | object\\> = number | boolean\n * CheckTypesOverlap\\<number | boolean, string | object\\> = never\n */\nexport type CheckTypesOverlap<T, TCheck> = [Extract<T, TCheck> extends never ? never : T][0];\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[];\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U): U[];\n\n\treadonly length: number;\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n\n\tboxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>>;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): FieldUpPath;\n\n\t[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes>;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<\n\tTSchema[\"kind\"],\n\tTSchema[\"allowedTypes\"]\n>;\n\n/**\n * Helper for implementing {@link FlexTreeTypedField}.\n */\nexport type FlexTreeTypedFieldInner<\n\tKind extends FlexFieldKind,\n\tTypes extends FlexAllowedTypes,\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<Types>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeRequiredField<Types>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeOptionalField<Types>\n\t\t\t: FlexTreeField;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexAllowedTypes}.\n */\nexport type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> =\n\tT extends FlexList<FlexTreeNodeSchema>\n\t\t? FlexTreeTypedNode<Assume<FlexListToUnion<T>, FlexTreeNodeSchema>>\n\t\t: FlexTreeNode;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexTreeNodeSchema}.\n */\nexport type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? FlexTreeLeafNode<TSchema>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t: FlexTreeNode;\n\n// #endregion\n\n// #region Unbox\n\n/**\n * Schema aware unboxed field.\n * @remarks\n * Unboxes fields to their content if appropriate for the kind.\n * Recursively unboxes that content (then its content etc.) as well if the node union does unboxing.\n */\nexport type FlexTreeUnboxField<\n\tTSchema extends FlexFieldSchema,\n\t// If \"notEmpty\", then optional fields will unbox to their content (not their content | undefined)\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\" = \"maybeEmpty\",\n> = FlexTreeUnboxFieldInner<TSchema[\"kind\"], TSchema[\"allowedTypes\"], Emptiness>;\n\n/**\n * Helper for implementing FlexTreeUnboxField.\n */\nexport type FlexTreeUnboxFieldInner<\n\tKind extends FlexFieldKind,\n\tTTypes extends FlexAllowedTypes,\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\",\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<TTypes>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeUnboxNodeUnion<TTypes>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends \"notEmpty\" ? never : undefined)\n\t\t\t: // TODO: forbidden\n\t\t\t\tunknown;\n\n/**\n * Schema aware unboxed union of tree types.\n * @remarks\n * Unboxes when not polymorphic.\n * Recursively unboxes that content as well if the node kind does unboxing.\n */\nexport type FlexTreeUnboxNodeUnion<TTypes extends FlexAllowedTypes> = TTypes extends readonly [\n\tLazyItem<infer InnerType>,\n]\n\t? InnerType extends FlexTreeNodeSchema\n\t\t? FlexTreeUnboxNode<InnerType>\n\t\t: InnerType extends Any\n\t\t\t? FlexTreeNode\n\t\t\t: // This case should not occur. If the result ever ends up unknown, look at places like this to debug.\n\t\t\t\tunknown\n\t: boolean extends IsArrayOfOne<TTypes>\n\t\t? FlexTreeUnknownUnboxed // Unknown if this will unbox. This should mainly happen when TTypes is AllowedTypes.\n\t\t: FlexTreeTypedNodeUnion<TTypes>; // Known to not be a single type, so known not to unbox.\n\n/**\n * `true` if T is known to be an array of one item.\n * `false` if T is known not to be an array of one item.\n * `boolean` if it is unknown if T is an array of one item or not.\n */\nexport type IsArrayOfOne<T extends readonly unknown[]> = T[\"length\"] extends 1\n\t? true\n\t: 1 extends T[\"length\"]\n\t\t? boolean\n\t\t: false;\n\n/**\n * Schema aware unboxed tree type.\n * @remarks\n * Unboxes if the node kind does unboxing.\n * Recursively unboxes that content as well if it does unboxing.\n */\nexport type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? TreeValue<TSchema[\"info\"]>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t: FlexTreeUnknownUnboxed;\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n\n// #endregion\n"]}
|
|
1
|
+
{"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAQN,UAAU,GACV,MAAM,qBAAqB,CAAC;AAY7B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAgB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAS,gBAAgB,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,cAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED;GACG;AACH,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AA6BD;;;GAGG;AACH,MAAM,CAAN,IAAY,UAkCX;AAlCD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;;;;;;;;;;;;;;;OAgBG;IACH,yCAAO,CAAA;AACR,CAAC,EAlCW,UAAU,KAAV,UAAU,QAkCrB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type {\n\tFieldKinds,\n\tSequenceFieldEditBuilder,\n\tValueFieldEditBuilder,\n\tOptionalFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexTreeNodeSchema } from \"../typed-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nfunction isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n */\nexport interface FlexTreeEntity {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * A common context of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t * @remarks\n\t * See also {@link Unhydrated}.\n\t *\n\t * Nodes in the new state have some limitations:\n\t *\n\t * - Events are not currently triggered for changes. Fixes for this are planned.\n\t *\n\t * - Reading identifiers from nodes which were left unspecified (defaulted) when creating the tree will error.\n\t * This is because allocating unique identifiers in a compressible manner requires knowing which tree the nodes will be inserted into.\n\t *\n\t * - Transactions do not work: transactions apply to a single {@link TreeView}, and `New` nodes are not part of one.\n\t *\n\t * - `Tree.shortId` (when the identifier was explicitly specified and thus works at all) will just return the full identifier as a string,\n\t * but might return a compressed form as a number once hydrated.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n *\n * @remarks\n * Down-casting (via {@link FlexTreeNode#is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n */\nexport interface FlexTreeNode extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis(schema: FlexTreeNodeSchema): boolean;\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n\n\t/**\n\t * Returns an iterable of keys for non-empty fields.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TreeNodeSchemaIdentifier;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly flexSchema: FlexTreeNodeSchema;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n */\nexport interface FlexTreeField extends FlexTreeEntity {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TKind extends FlexFieldKind>(kind: TKind): this is FlexTreeTypedField<TKind>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): FieldUpPath;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TreeFieldStoredSchema;\n}\n\n// #region Field Kinds\n\n/**\n * Typed tree for inserting as the content of a field.\n */\nexport type FlexibleFieldContent = ExclusiveMapTree[];\n\n/**\n * Tree for inserting as a node.\n */\nexport type FlexibleNodeContent = ExclusiveMapTree;\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n */\nexport interface FlexTreeSequenceField extends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnknownUnboxed | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\treadonly editor: SequenceFieldEditBuilder<FlexibleFieldContent>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n */\nexport interface FlexTreeRequiredField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed;\n\n\treadonly editor: ValueFieldEditBuilder<FlexibleNodeContent>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n */\nexport interface FlexTreeOptionalField extends FlexTreeField {\n\tget content(): FlexTreeUnknownUnboxed | undefined;\n\n\treadonly editor: OptionalFieldEditBuilder<FlexibleNodeContent>;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n */\nexport type FlexTreeTypedField<Kind extends FlexFieldKind> =\n\tKind extends typeof FieldKinds.sequence\n\t\t? FlexTreeSequenceField\n\t\t: Kind extends typeof FieldKinds.required\n\t\t\t? FlexTreeRequiredField\n\t\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t\t? FlexTreeOptionalField\n\t\t\t\t: FlexTreeField;\n\n// #endregion\n\n/**\n * Unboxed tree type for unknown schema cases.\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n"]}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { type FlexTreeField, type FlexTreeNode, type FlexTreeEntity, type FlexTreeTypedField, type
|
|
5
|
+
export { type FlexTreeField, type FlexTreeNode, type FlexTreeEntity, type FlexTreeTypedField, type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, TreeStatus, type FlexTreeUnknownUnboxed, flexTreeMarker, FlexTreeEntityKind, isFlexTreeNode, flexTreeSlot, } from "./flexTreeTypes.js";
|
|
6
6
|
export { visitBipartiteIterableTree, Skip, visitBipartiteIterableTreeWithState, visitIterableTree, visitIterableTreeWithState, } from "./navigation.js";
|
|
7
|
-
export { getTreeContext, type FlexTreeContext, Context, ContextSlot } from "./context.js";
|
|
7
|
+
export { getTreeContext, type FlexTreeContext, type FlexTreeHydratedContext, Context, ContextSlot, } from "./context.js";
|
|
8
8
|
export { type FlexTreeNodeEvents } from "./treeEvents.js";
|
|
9
|
-
export type { FlexTreeTypedFieldInner, FlexTreeUnboxFieldInner, FlexTreeObjectNodeFields, FlexTreeUnboxNode, FlexTreeUnboxNodeUnion, IsArrayOfOne, FlexibleNodeSubSequence, } from "./flexTreeTypes.js";
|
|
10
9
|
export { assertFlexTreeEntityNotFreed, isFreedSymbol, LazyEntity, } from "./lazyEntity.js";
|
|
11
10
|
export { getSchemaAndPolicy, indexForAt } from "./utilities.js";
|
|
12
11
|
export { treeStatusFromAnchorCache } from "./utilities.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,UAAU,EACV,KAAK,sBAAsB,EAC3B,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,0BAA0B,EAC1B,IAAI,EACJ,mCAAmC,EACnC,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,OAAO,EACP,WAAW,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EACN,4BAA4B,EAC5B,aAAa,EACb,UAAU,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { TreeStatus, flexTreeMarker, FlexTreeEntityKind, isFlexTreeNode,
|
|
5
|
+
export { TreeStatus, flexTreeMarker, FlexTreeEntityKind, isFlexTreeNode, flexTreeSlot, } from "./flexTreeTypes.js";
|
|
6
6
|
export { visitBipartiteIterableTree, Skip, visitBipartiteIterableTreeWithState, visitIterableTree, visitIterableTreeWithState, } from "./navigation.js";
|
|
7
|
-
export { getTreeContext, Context, ContextSlot } from "./context.js";
|
|
7
|
+
export { getTreeContext, Context, ContextSlot, } from "./context.js";
|
|
8
8
|
export { assertFlexTreeEntityNotFreed, isFreedSymbol, LazyEntity, } from "./lazyEntity.js";
|
|
9
9
|
export { getSchemaAndPolicy, indexForAt } from "./utilities.js";
|
|
10
10
|
export { treeStatusFromAnchorCache } from "./utilities.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAQN,UAAU,EAEV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,0BAA0B,EAC1B,IAAI,EACJ,mCAAmC,EACnC,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,cAAc,EAGd,OAAO,EACP,WAAW,GACX,MAAM,cAAc,CAAC;AAItB,OAAO,EACN,4BAA4B,EAC5B,aAAa,EACb,UAAU,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeEntity,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tTreeStatus,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tFlexTreeEntityKind,\n\tisFlexTreeNode,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\n\nexport {\n\tvisitBipartiteIterableTree,\n\tSkip,\n\tvisitBipartiteIterableTreeWithState,\n\tvisitIterableTree,\n\tvisitIterableTreeWithState,\n} from \"./navigation.js\";\n\nexport {\n\tgetTreeContext,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\tContext,\n\tContextSlot,\n} from \"./context.js\";\n\nexport { type FlexTreeNodeEvents } from \"./treeEvents.js\";\n\nexport {\n\tassertFlexTreeEntityNotFreed,\n\tisFreedSymbol,\n\tLazyEntity,\n} from \"./lazyEntity.js\";\n\nexport { getSchemaAndPolicy, indexForAt } from \"./utilities.js\";\n\nexport { treeStatusFromAnchorCache } from \"./utilities.js\";\n"]}
|
|
@@ -25,12 +25,12 @@ export declare function assertFlexTreeEntityNotFreed(entity: FlexTreeEntity): vo
|
|
|
25
25
|
/**
|
|
26
26
|
* This is a base class for lazy (cursor based) UntypedEntity implementations, which uniformly handles cursors and anchors.
|
|
27
27
|
*/
|
|
28
|
-
export declare abstract class LazyEntity<TSchema = unknown, TAnchor = unknown> implements FlexTreeEntity
|
|
28
|
+
export declare abstract class LazyEntity<TSchema = unknown, TAnchor = unknown> implements FlexTreeEntity, IDisposable {
|
|
29
29
|
#private;
|
|
30
30
|
readonly context: Context;
|
|
31
|
-
readonly
|
|
31
|
+
readonly flexSchema: TSchema;
|
|
32
32
|
readonly [anchorSymbol]: TAnchor;
|
|
33
|
-
protected constructor(context: Context,
|
|
33
|
+
protected constructor(context: Context, flexSchema: TSchema, cursor: ITreeSubscriptionCursor, anchor: TAnchor);
|
|
34
34
|
abstract boxedIterator(): IterableIterator<FlexTreeEntity>;
|
|
35
35
|
abstract get [flexTreeMarker](): FlexTreeEntityKind;
|
|
36
36
|
[disposeSymbol](): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyEntity.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyEntity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,uBAAuB,EAE5B,oBAAoB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,cAAc,EACd,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,oBAAoB,eAA2B,CAAC;AAC7D,eAAO,MAAM,aAAa,eAAoB,CAAC;AAC/C,eAAO,MAAM,2BAA2B,eAAkC,CAAC;AAC3E,eAAO,MAAM,kBAAkB,eAAyB,CAAC;AACzD,eAAO,MAAM,YAAY,eAAmB,CAAC;AAC7C;;GAEG;AACH,eAAO,MAAM,YAAY,eAAmB,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,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,CAAC,IAAI,kBAAkB,CAAC;IAEpD,CAAC,aAAa,CAAC,IAAI,IAAI;IAOvB,CAAC,oBAAoB,CAAC,IAAI,IAAI;IAK9B,CAAC,aAAa,CAAC,IAAI,OAAO;IAIjC,IAAW,CAAC,YAAY,CAAC,IAAI,uBAAuB,CAkBnD;IAED,SAAS,CAAC,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CAC/C,MAAM,EAAE,uBAAuB,GAC7B,oBAAoB;IAEvB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,IAAI,IAAI;CAC/C"}
|
|
@@ -41,9 +41,9 @@ export function assertFlexTreeEntityNotFreed(entity) {
|
|
|
41
41
|
* This is a base class for lazy (cursor based) UntypedEntity implementations, which uniformly handles cursors and anchors.
|
|
42
42
|
*/
|
|
43
43
|
export class LazyEntity {
|
|
44
|
-
constructor(context,
|
|
44
|
+
constructor(context, flexSchema, cursor, anchor) {
|
|
45
45
|
this.context = context;
|
|
46
|
-
this.
|
|
46
|
+
this.flexSchema = flexSchema;
|
|
47
47
|
_LazyEntity_lazyCursor.set(this, void 0);
|
|
48
48
|
this[anchorSymbol] = anchor;
|
|
49
49
|
__classPrivateFieldSet(this, _LazyEntity_lazyCursor, cursor.fork("LazyEntity Fork"), "f");
|
|
@@ -74,12 +74,4 @@ export class LazyEntity {
|
|
|
74
74
|
return __classPrivateFieldGet(this, _LazyEntity_lazyCursor, "f");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Prevent Entities from inheriting members from Object.prototype including:
|
|
79
|
-
* '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__',
|
|
80
|
-
* 'hasOwnProperty', 'isPrototypeOf', 'valueOf', 'propertyIsEnumerable', 'toLocaleString' and 'toString'.
|
|
81
|
-
*
|
|
82
|
-
* This opens up more options for field names on struct nodes.
|
|
83
|
-
*/
|
|
84
|
-
Object.setPrototypeOf(LazyEntity.prototype, null);
|
|
85
77
|
//# sourceMappingURL=lazyEntity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyEntity.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyEntity.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAEN,4BAA4B,GAE5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAoB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAGN,cAAc,GACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAsB;IAClE,MAAM,CAAC,MAAM,YAAY,UAAU,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC5E,MAAM,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,OAAgB,UAAU;IAM/B,YACiB,OAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"lazyEntity.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyEntity.ts"],"names":[],"m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AAC;QACD,OAAO,uBAAA,IAAI,8BAAY,CAAC;IACzB,CAAC;CAUD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ITreeSubscriptionCursor,\n\tITreeSubscriptionCursorState,\n\tTreeNavigationResult,\n} from \"../../core/index.js\";\nimport { type IDisposable, disposeSymbol } from \"../../util/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\ttype FlexTreeEntity,\n\ttype FlexTreeEntityKind,\n\tflexTreeMarker,\n} from \"./flexTreeTypes.js\";\n\nexport const prepareForEditSymbol = Symbol(\"prepareForEdit\");\nexport const isFreedSymbol = Symbol(\"isFreed\");\nexport const tryMoveCursorToAnchorSymbol = Symbol(\"tryMoveCursorToAnchor\");\nexport const forgetAnchorSymbol = Symbol(\"forgetAnchor\");\nexport const cursorSymbol = Symbol(\"cursor\");\n/**\n * Symbol used to access the (generic) anchor of a {@link LazyEntity}.\n */\nexport const anchorSymbol = Symbol(\"anchor\");\n\n/**\n * Assert `entity` is not deleted.\n * @privateRemarks\n * This can be faster than getting the tree status and checking that since that can require computing removed vs deleted.\n * TODO: provide a non implementation dependent way to leverage this optimization.\n */\nexport function assertFlexTreeEntityNotFreed(entity: FlexTreeEntity): void {\n\tassert(entity instanceof LazyEntity, 0x8c9 /* unexpected implementation */);\n\tassert(!entity[isFreedSymbol](), 0x8ca /* Use after free */);\n}\n\n/**\n * This is a base class for lazy (cursor based) UntypedEntity implementations, which uniformly handles cursors and anchors.\n */\nexport abstract class LazyEntity<TSchema = unknown, TAnchor = unknown>\n\timplements FlexTreeEntity, IDisposable\n{\n\treadonly #lazyCursor: ITreeSubscriptionCursor;\n\tpublic readonly [anchorSymbol]: TAnchor;\n\n\tprotected constructor(\n\t\tpublic readonly context: Context,\n\t\tpublic readonly flexSchema: TSchema,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tanchor: TAnchor,\n\t) {\n\t\tthis[anchorSymbol] = anchor;\n\t\tthis.#lazyCursor = cursor.fork(\"LazyEntity Fork\");\n\t\tcontext.withCursors.add(this);\n\t\tthis.context.withAnchors.add(this);\n\t}\n\n\tpublic abstract boxedIterator(): IterableIterator<FlexTreeEntity>;\n\tpublic abstract get [flexTreeMarker](): FlexTreeEntityKind;\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.#lazyCursor.free();\n\t\tthis.context.withCursors.delete(this);\n\t\tthis[forgetAnchorSymbol]();\n\t\tthis.context.withAnchors.delete(this);\n\t}\n\n\tpublic [prepareForEditSymbol](): void {\n\t\tthis.#lazyCursor.clear();\n\t\tthis.context.withCursors.delete(this);\n\t}\n\n\tpublic [isFreedSymbol](): boolean {\n\t\treturn this.#lazyCursor.state === ITreeSubscriptionCursorState.Freed;\n\t}\n\n\tpublic get [cursorSymbol](): ITreeSubscriptionCursor {\n\t\tif (this.#lazyCursor.state !== ITreeSubscriptionCursorState.Current) {\n\t\t\tassert(\n\t\t\t\tthis.#lazyCursor.state === ITreeSubscriptionCursorState.Cleared,\n\t\t\t\t0x778 /* Unset cursor should be in cleared state */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis[anchorSymbol] !== undefined,\n\t\t\t\t0x779 /* FlexTree should have an anchor if it does not have a cursor */,\n\t\t\t);\n\t\t\tconst result = this[tryMoveCursorToAnchorSymbol](this.#lazyCursor);\n\t\t\tassert(\n\t\t\t\tresult === TreeNavigationResult.Ok,\n\t\t\t\t0x77a /* It is invalid to access a FlexTree node which no longer exists */,\n\t\t\t);\n\t\t\tthis.context.withCursors.add(this);\n\t\t}\n\t\treturn this.#lazyCursor;\n\t}\n\n\tprotected abstract [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult;\n\n\t/**\n\t * Called when disposing of this target, iff it has an anchor.\n\t */\n\tprotected abstract [forgetAnchorSymbol](): void;\n}\n"]}
|
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type ExclusiveMapTree, type FieldAnchor, type FieldKey, type FieldUpPath, type ITreeSubscriptionCursor, type TreeNavigationResult } from "../../core/index.js";
|
|
5
|
+
import { type ExclusiveMapTree, type FieldAnchor, type FieldKey, type FieldUpPath, type ITreeSubscriptionCursor, type TreeFieldStoredSchema, type TreeNavigationResult } from "../../core/index.js";
|
|
6
6
|
import { FieldKinds, type OptionalFieldEditBuilder, type SequenceFieldEditBuilder, type ValueFieldEditBuilder } from "../default-schema/index.js";
|
|
7
7
|
import type { FlexFieldKind } from "../modular-schema/index.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { FlexFieldSchema } from "../typed-schema/index.js";
|
|
9
9
|
import type { Context } from "./context.js";
|
|
10
|
-
import { FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, type FlexTreeTypedField, type
|
|
10
|
+
import { FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, type FlexTreeTypedField, type FlexTreeUnknownUnboxed, flexTreeMarker } from "./flexTreeTypes.js";
|
|
11
11
|
import { LazyEntity, forgetAnchorSymbol, tryMoveCursorToAnchorSymbol } from "./lazyEntity.js";
|
|
12
12
|
export declare function makeField(context: Context, schema: FlexFieldSchema, cursor: ITreeSubscriptionCursor): FlexTreeField;
|
|
13
13
|
/**
|
|
14
14
|
* Base type for fields implementing {@link FlexTreeField} using cursors.
|
|
15
15
|
*/
|
|
16
|
-
export declare abstract class LazyField<out TKind extends FlexFieldKind
|
|
16
|
+
export declare abstract class LazyField<out TKind extends FlexFieldKind> extends LazyEntity<FlexFieldSchema<TKind>, FieldAnchor> implements FlexTreeField {
|
|
17
17
|
get [flexTreeMarker](): FlexTreeEntityKind.Field;
|
|
18
18
|
readonly key: FieldKey;
|
|
19
|
+
get schema(): TreeFieldStoredSchema;
|
|
19
20
|
/**
|
|
20
21
|
* If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free
|
|
21
22
|
* if/when the Anchor is destroyed.
|
|
22
23
|
*/
|
|
23
24
|
private readonly offAfterDestroy?;
|
|
24
|
-
constructor(context: Context, schema: FlexFieldSchema<TKind
|
|
25
|
-
is<
|
|
25
|
+
constructor(context: Context, schema: FlexFieldSchema<TKind>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
26
|
+
is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2>;
|
|
26
27
|
get parent(): FlexTreeNode | undefined;
|
|
27
28
|
protected [tryMoveCursorToAnchorSymbol](cursor: ITreeSubscriptionCursor): TreeNavigationResult;
|
|
28
29
|
protected [forgetAnchorSymbol](): void;
|
|
29
30
|
get length(): number;
|
|
30
|
-
atIndex(index: number):
|
|
31
|
-
boxedAt(index: number):
|
|
32
|
-
map<U>(callbackfn: (value:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>>;
|
|
31
|
+
atIndex(index: number): FlexTreeUnknownUnboxed;
|
|
32
|
+
boxedAt(index: number): FlexTreeNode | undefined;
|
|
33
|
+
map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];
|
|
34
|
+
boxedIterator(): IterableIterator<FlexTreeNode>;
|
|
35
|
+
[Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed>;
|
|
36
36
|
getFieldPath(): FieldUpPath;
|
|
37
37
|
/**
|
|
38
38
|
* Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.
|
|
@@ -40,33 +40,30 @@ export declare abstract class LazyField<out TKind extends FlexFieldKind, TTypes
|
|
|
40
40
|
*/
|
|
41
41
|
getFieldPathForEditing(): FieldUpPath;
|
|
42
42
|
}
|
|
43
|
-
export declare class LazySequence
|
|
44
|
-
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.sequence
|
|
45
|
-
at(index: number):
|
|
46
|
-
get asArray(): readonly
|
|
43
|
+
export declare class LazySequence extends LazyField<typeof FieldKinds.sequence> implements FlexTreeSequenceField {
|
|
44
|
+
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.sequence>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
45
|
+
at(index: number): FlexTreeUnknownUnboxed | undefined;
|
|
46
|
+
get asArray(): readonly FlexTreeUnknownUnboxed[];
|
|
47
47
|
editor: SequenceFieldEditBuilder<ExclusiveMapTree[]>;
|
|
48
48
|
private sequenceEditor;
|
|
49
49
|
}
|
|
50
|
-
export declare class ReadonlyLazyValueField
|
|
51
|
-
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.required
|
|
50
|
+
export declare class ReadonlyLazyValueField extends LazyField<typeof FieldKinds.required> implements FlexTreeRequiredField {
|
|
51
|
+
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.required>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
52
52
|
editor: ValueFieldEditBuilder<ExclusiveMapTree>;
|
|
53
|
-
get content():
|
|
53
|
+
get content(): FlexTreeUnknownUnboxed;
|
|
54
54
|
}
|
|
55
|
-
export declare class LazyValueField
|
|
56
|
-
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.required
|
|
55
|
+
export declare class LazyValueField extends ReadonlyLazyValueField implements FlexTreeRequiredField {
|
|
56
|
+
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.required>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
57
57
|
editor: ValueFieldEditBuilder<ExclusiveMapTree>;
|
|
58
58
|
private valueFieldEditor;
|
|
59
|
-
get content():
|
|
59
|
+
get content(): FlexTreeUnknownUnboxed;
|
|
60
60
|
}
|
|
61
|
-
export declare class
|
|
62
|
-
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.
|
|
63
|
-
}
|
|
64
|
-
export declare class LazyOptionalField<TTypes extends FlexAllowedTypes> extends LazyField<typeof FieldKinds.optional, TTypes> implements FlexTreeOptionalField<TTypes> {
|
|
65
|
-
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
61
|
+
export declare class LazyOptionalField extends LazyField<typeof FieldKinds.optional> implements FlexTreeOptionalField {
|
|
62
|
+
constructor(context: Context, schema: FlexFieldSchema<typeof FieldKinds.optional>, cursor: ITreeSubscriptionCursor, fieldAnchor: FieldAnchor);
|
|
66
63
|
editor: OptionalFieldEditBuilder<ExclusiveMapTree>;
|
|
67
64
|
private optionalEditor;
|
|
68
|
-
get content():
|
|
65
|
+
get content(): FlexTreeUnknownUnboxed | undefined;
|
|
69
66
|
}
|
|
70
|
-
export declare class LazyForbiddenField
|
|
67
|
+
export declare class LazyForbiddenField extends LazyField<typeof FieldKinds.forbidden> {
|
|
71
68
|
}
|
|
72
69
|
//# sourceMappingURL=lazyField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyField.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAEhB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAIzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,
|
|
1
|
+
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-9,7 +9,7 @@ import { FieldKinds, } from "../default-schema/index.js";
|
|
|
9
9
|
import { FlexTreeEntityKind, TreeStatus, flexTreeMarker, flexTreeSlot, } from "./flexTreeTypes.js";
|
|
10
10
|
import { LazyEntity, anchorSymbol, cursorSymbol, forgetAnchorSymbol, isFreedSymbol, tryMoveCursorToAnchorSymbol, } from "./lazyEntity.js";
|
|
11
11
|
import { makeTree } from "./lazyNode.js";
|
|
12
|
-
import {
|
|
12
|
+
import { unboxedFlexNode } from "./unboxed.js";
|
|
13
13
|
import { indexForAt, treeStatusFromAnchorCache } from "./utilities.js";
|
|
14
14
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
15
15
|
import { cursorForMapTreeField, cursorForMapTreeNode } from "../mapTreeCursor.js";
|
|
@@ -63,6 +63,9 @@ export class LazyField extends LazyEntity {
|
|
|
63
63
|
get [flexTreeMarker]() {
|
|
64
64
|
return FlexTreeEntityKind.Field;
|
|
65
65
|
}
|
|
66
|
+
get schema() {
|
|
67
|
+
return this.flexSchema.stored;
|
|
68
|
+
}
|
|
66
69
|
constructor(context, schema, cursor, fieldAnchor) {
|
|
67
70
|
super(context, schema, cursor, fieldAnchor);
|
|
68
71
|
assert(cursor.mode === 1 /* CursorLocationType.Fields */, 0x77b /* must be in fields mode */);
|
|
@@ -77,9 +80,9 @@ export class LazyField extends LazyEntity {
|
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
is(
|
|
81
|
-
assert(this.context.
|
|
82
|
-
return this.
|
|
83
|
+
is(kind) {
|
|
84
|
+
assert(this.context.flexSchema.policy.fieldKinds.get(kind.identifier) === kind, 0xa26 /* Narrowing must be done to a kind that exists in this context */);
|
|
85
|
+
return this.flexSchema.kind === kind;
|
|
83
86
|
}
|
|
84
87
|
get parent() {
|
|
85
88
|
if (this[anchorSymbol].parent === undefined) {
|
|
@@ -104,7 +107,7 @@ export class LazyField extends LazyEntity {
|
|
|
104
107
|
return this[cursorSymbol].getFieldLength();
|
|
105
108
|
}
|
|
106
109
|
atIndex(index) {
|
|
107
|
-
return inCursorNode(this[cursorSymbol], index, (cursor) =>
|
|
110
|
+
return inCursorNode(this[cursorSymbol], index, (cursor) => unboxedFlexNode(this.context, cursor));
|
|
108
111
|
}
|
|
109
112
|
boxedAt(index) {
|
|
110
113
|
const finalIndex = indexForAt(index, this.length);
|
|
@@ -116,14 +119,11 @@ export class LazyField extends LazyEntity {
|
|
|
116
119
|
map(callbackfn) {
|
|
117
120
|
return Array.from(this, callbackfn);
|
|
118
121
|
}
|
|
119
|
-
mapBoxed(callbackfn) {
|
|
120
|
-
return Array.from(this.boxedIterator(), callbackfn);
|
|
121
|
-
}
|
|
122
122
|
boxedIterator() {
|
|
123
123
|
return iterateCursorField(this[cursorSymbol], (cursor) => makeTree(this.context, cursor));
|
|
124
124
|
}
|
|
125
125
|
[Symbol.iterator]() {
|
|
126
|
-
return iterateCursorField(this[cursorSymbol], (cursor) =>
|
|
126
|
+
return iterateCursorField(this[cursorSymbol], (cursor) => unboxedFlexNode(this.context, cursor));
|
|
127
127
|
}
|
|
128
128
|
getFieldPath() {
|
|
129
129
|
return this[cursorSymbol].getFieldPath();
|
|
@@ -163,7 +163,7 @@ export class LazySequence extends LazyField {
|
|
|
163
163
|
if (finalIndex === undefined) {
|
|
164
164
|
return undefined;
|
|
165
165
|
}
|
|
166
|
-
return inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>
|
|
166
|
+
return inCursorNode(this[cursorSymbol], finalIndex, (cursor) => unboxedFlexNode(this.context, cursor));
|
|
167
167
|
}
|
|
168
168
|
get asArray() {
|
|
169
169
|
return this.map((x) => x);
|
|
@@ -204,11 +204,6 @@ export class LazyValueField extends ReadonlyLazyValueField {
|
|
|
204
204
|
return this.atIndex(0);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
export class LazyIdentifierField extends ReadonlyLazyValueField {
|
|
208
|
-
constructor(context, schema, cursor, fieldAnchor) {
|
|
209
|
-
super(context, schema, cursor, fieldAnchor);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
207
|
export class LazyOptionalField extends LazyField {
|
|
213
208
|
constructor(context, schema, cursor, fieldAnchor) {
|
|
214
209
|
super(context, schema, cursor, fieldAnchor);
|
|
@@ -234,7 +229,7 @@ const builderList = [
|
|
|
234
229
|
[FieldKinds.optional, LazyOptionalField],
|
|
235
230
|
[FieldKinds.sequence, LazySequence],
|
|
236
231
|
[FieldKinds.required, LazyValueField],
|
|
237
|
-
[FieldKinds.identifier,
|
|
232
|
+
[FieldKinds.identifier, LazyValueField],
|
|
238
233
|
];
|
|
239
234
|
const kindToClass = new Map(builderList);
|
|
240
235
|
//# sourceMappingURL=lazyField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyField.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EASN,YAAY,EACZ,kBAAkB,EAClB,YAAY,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACN,UAAU,GAIV,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACN,kBAAkB,EASlB,UAAU,EACV,cAAc,EACd,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,2BAA2B,GAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0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xE;CAAG;AAaJ,MAAM,WAAW,GAA+B;IAC/C,CAAC,UAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC1C,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACxC,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC;IACnC,CAAC,UAAU,CAAC,QAAQ,EAAE,cAAc,CAAC;IACrC,CAAC,UAAU,CAAC,UAAU,EAAE,mBAAmB,CAAC;CAC5C,CAAC;AAEF,MAAM,WAAW,GAAwC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype ExclusiveMapTree,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\titerateCursorField,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexAllowedTypes, FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxNodeUnion,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { unboxedUnion } from \"./unboxed.js\";\nimport { indexForAt, treeStatusFromAnchorCache } from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { cursorForMapTreeField, cursorForMapTreeNode } from \"../mapTreeCursor.js\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * Base type for fields implementing {@link FlexTreeField} using cursors.\n */\nexport abstract class LazyField<\n\t\tout TKind extends FlexFieldKind,\n\t\tTTypes extends FlexAllowedTypes,\n\t>\n\textends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TSchema extends FlexFieldSchema>(\n\t\tschema: TSchema,\n\t): this is FlexTreeTypedField<TSchema> {\n\t\tassert(\n\t\t\tthis.context.schema.policy.fieldKinds.get(schema.kind.identifier) === schema.kind,\n\t\t\t0x77c /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t) as unknown as FlexTreeTypedNodeUnion<TTypes>;\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic mapBoxed<U>(\n\t\tcallbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U,\n\t): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(\n\t\t\tthis[cursorSymbol],\n\t\t\t(cursor) => makeTree(this.context, cursor) as unknown as FlexTreeTypedNodeUnion<TTypes>,\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (!this[isFreedSymbol]()) {\n\t\t\tif (\n\t\t\t\t// Only allow editing if we are the root document field...\n\t\t\t\t(this.parent === undefined && this[anchorSymbol].fieldKey === rootFieldKey) ||\n\t\t\t\t// ...or are under a node in the document\n\t\t\t\t(this.parent !== undefined &&\n\t\t\t\t\ttreeStatusFromAnchorCache(this.parent.anchorNode) === TreeStatus.InDocument)\n\t\t\t) {\n\t\t\t\treturn this.getFieldPath();\n\t\t\t}\n\t\t}\n\n\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t}\n}\n\nexport class LazySequence<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.sequence, TTypes>\n\timplements FlexTreeSequenceField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnboxNodeUnion<TTypes>[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic editor: SequenceFieldEditBuilder<ExclusiveMapTree[]> = {\n\t\tinsert: (index, newContent) => {\n\t\t\tthis.sequenceEditor().insert(index, cursorForMapTreeField(newContent));\n\t\t},\n\t\tremove: (index, count) => {\n\t\t\tthis.sequenceEditor().remove(index, count);\n\t\t},\n\t};\n\n\tprivate sequenceEditor(): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\treturn this.context.checkout.editor.sequenceField(fieldPath);\n\t}\n}\n\nexport class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.required, TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tassert(false, 0xa0c /* Unexpected set of readonly field */);\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyValueField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic override editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tthis.valueFieldEditor().set(cursorForMapTreeNode(newContent));\n\t\t},\n\t};\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyIdentifierField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n}\n\nexport class LazyOptionalField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.optional, TTypes>\n\timplements FlexTreeOptionalField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic editor: OptionalFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent, wasEmpty) => {\n\t\t\tthis.optionalEditor().set(\n\t\t\t\tnewContent !== undefined ? cursorForMapTreeNode(newContent) : newContent,\n\t\t\t\twasEmpty,\n\t\t\t);\n\t\t},\n\t};\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n}\n\nexport class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<\n\ttypeof FieldKinds.forbidden,\n\tTTypes\n> {}\n\ntype Builder = new <TTypes extends FlexAllowedTypes>(\n\tcontext: Context,\n\t// Correct use of these builders requires the builder of the matching type to be used.\n\t// Since this has to be done at runtime anyway, trying to use safer typing than `any` here (such as `never`, which is only slightly safer)\n\t// does not seem worth it (ends up requiring type casts that are just as unsafe).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any, TTypes>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n) => LazyField<FlexFieldKind, TTypes>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyIdentifierField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n"]}
|
|
1
|
+
{"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ATF,CAAC;IAWO,cAAc;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC1E,OAAO,WAAW,CAAC;IACpB,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACD;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAsC;CAAG;AAajF,MAAM,WAAW,GAA+B;IAC/C,CAAC,UAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC1C,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACxC,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC;IACnC,CAAC,UAAU,CAAC,QAAQ,EAAE,cAAc,CAAC;IACrC,CAAC,UAAU,CAAC,UAAU,EAAE,cAAc,CAAC;CACvC,CAAC;AAEF,MAAM,WAAW,GAAwC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype ExclusiveMapTree,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\titerateCursorField,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { unboxedFlexNode } from \"./unboxed.js\";\nimport { indexForAt, treeStatusFromAnchorCache } from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { cursorForMapTreeField, cursorForMapTreeNode } from \"../mapTreeCursor.js\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * Base type for fields implementing {@link FlexTreeField} using cursors.\n */\nexport abstract class LazyField<out TKind extends FlexFieldKind>\n\textends LazyEntity<FlexFieldSchema<TKind>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\tpublic get schema(): TreeFieldStoredSchema {\n\t\treturn this.flexSchema.stored;\n\t}\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\tassert(\n\t\t\tthis.context.flexSchema.policy.fieldKinds.get(kind.identifier) === kind,\n\t\t\t0xa26 /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.flexSchema.kind === (kind as unknown);\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnknownUnboxed {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t);\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) => makeTree(this.context, cursor));\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor),\n\t\t);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (!this[isFreedSymbol]()) {\n\t\t\tif (\n\t\t\t\t// Only allow editing if we are the root document field...\n\t\t\t\t(this.parent === undefined && this[anchorSymbol].fieldKey === rootFieldKey) ||\n\t\t\t\t// ...or are under a node in the document\n\t\t\t\t(this.parent !== undefined &&\n\t\t\t\t\ttreeStatusFromAnchorCache(this.parent.anchorNode) === TreeStatus.InDocument)\n\t\t\t) {\n\t\t\t\treturn this.getFieldPath();\n\t\t\t}\n\t\t}\n\n\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t}\n}\n\nexport class LazySequence\n\textends LazyField<typeof FieldKinds.sequence>\n\timplements FlexTreeSequenceField\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedFlexNode(this.context, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnknownUnboxed[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic editor: SequenceFieldEditBuilder<ExclusiveMapTree[]> = {\n\t\tinsert: (index, newContent) => {\n\t\t\tthis.sequenceEditor().insert(index, cursorForMapTreeField(newContent));\n\t\t},\n\t\tremove: (index, count) => {\n\t\t\tthis.sequenceEditor().remove(index, count);\n\t\t},\n\t};\n\n\tprivate sequenceEditor(): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\treturn this.context.checkout.editor.sequenceField(fieldPath);\n\t}\n}\n\nexport class ReadonlyLazyValueField\n\textends LazyField<typeof FieldKinds.required>\n\timplements FlexTreeRequiredField\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tassert(false, 0xa0c /* Unexpected set of readonly field */);\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyValueField extends ReadonlyLazyValueField implements FlexTreeRequiredField {\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic override editor: ValueFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent) => {\n\t\t\tthis.valueFieldEditor().set(cursorForMapTreeNode(newContent));\n\t\t},\n\t};\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\treturn this.atIndex(0);\n\t}\n}\n\nexport class LazyOptionalField\n\textends LazyField<typeof FieldKinds.optional>\n\timplements FlexTreeOptionalField\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic editor: OptionalFieldEditBuilder<ExclusiveMapTree> = {\n\t\tset: (newContent, wasEmpty) => {\n\t\t\tthis.optionalEditor().set(\n\t\t\t\tnewContent !== undefined ? cursorForMapTreeNode(newContent) : newContent,\n\t\t\t\twasEmpty,\n\t\t\t);\n\t\t},\n\t};\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n}\n\nexport class LazyForbiddenField extends LazyField<typeof FieldKinds.forbidden> {}\n\ntype Builder = new (\n\tcontext: Context,\n\t// Correct use of these builders requires the builder of the matching type to be used.\n\t// Since this has to be done at runtime anyway, trying to use safer typing than `any` here (such as `never`, which is only slightly safer)\n\t// does not seem worth it (ends up requiring type casts that are just as unsafe).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n) => LazyField<FlexFieldKind>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyValueField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n"]}
|