@fluidframework/tree 2.11.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/api-report/tree.alpha.api.md +88 -12
- package/api-report/tree.beta.api.md +23 -11
- package/api-report/tree.legacy.alpha.api.md +23 -11
- package/api-report/tree.legacy.public.api.md +23 -11
- package/api-report/tree.public.api.md +23 -11
- package/dist/alpha.d.ts +11 -0
- package/dist/beta.d.ts +2 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +2 -9
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/format.d.ts +0 -3
- package/dist/core/schema-stored/format.d.ts.map +1 -1
- package/dist/core/schema-stored/format.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +12 -10
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -5
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-view/index.d.ts +1 -1
- package/dist/core/schema-view/index.d.ts.map +1 -1
- package/dist/core/schema-view/index.js +1 -2
- package/dist/core/schema-view/index.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -7
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js +1 -12
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
- package/dist/core/tree/chunk.d.ts.map +1 -0
- package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
- package/dist/core/tree/chunk.js.map +1 -0
- package/dist/core/tree/index.d.ts +1 -0
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +5 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts +0 -5
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/core/tree/types.d.ts +0 -5
- package/dist/core/tree/types.d.ts.map +1 -1
- package/dist/core/tree/types.js +0 -1
- package/dist/core/tree/types.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
- package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +5 -5
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
- package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +13 -13
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
- package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +6 -4
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +31 -5
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -2
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +5 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +24 -4
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
- package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
- package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
- package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
- package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
- package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/types.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +14 -5
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -14
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +2 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +6 -6
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +51 -12
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +31 -10
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +106 -15
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/transactionTypes.d.ts +105 -0
- package/dist/shared-tree/transactionTypes.d.ts.map +1 -0
- package/dist/shared-tree/transactionTypes.js +13 -0
- package/dist/shared-tree/transactionTypes.js.map +1 -0
- package/dist/shared-tree/treeApi.d.ts +1 -25
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +4 -8
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +39 -13
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +275 -128
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +13 -35
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +12 -77
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +7 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +16 -18
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +2 -2
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +3 -3
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +2 -2
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -9
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +4 -16
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +38 -0
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +118 -6
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +5 -1
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +14 -2
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +53 -3
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +6 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/jsonSchema.d.ts +6 -0
- package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/jsonSchema.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +65 -8
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +10 -4
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js +90 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
- package/dist/simple-tree/api/simpleSchema.d.ts +8 -2
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +13 -10
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +3 -1
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +4 -4
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +8 -21
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/dist/simple-tree/api/tree.d.ts +61 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/api/view.d.ts +14 -9
- package/dist/simple-tree/api/view.d.ts.map +1 -1
- package/dist/simple-tree/api/view.js +129 -40
- package/dist/simple-tree/api/view.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -11
- package/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 +2 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +10 -6
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +6 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +5 -20
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +0 -15
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +2 -2
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +2 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +9 -4
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +19 -2
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +6 -2
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +51 -3
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +18 -13
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/util/brand.d.ts +0 -2
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js +0 -1
- package/dist/util/brand.js.map +1 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +4 -5
- package/dist/util/index.js.map +1 -1
- package/dist/util/rangeMap.d.ts +72 -42
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +161 -151
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/typeCheck.d.ts +0 -2
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/utils.d.ts +35 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +32 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +11 -0
- package/lib/beta.d.ts +2 -0
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +3 -10
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/format.d.ts +0 -3
- package/lib/core/schema-stored/format.d.ts.map +1 -1
- package/lib/core/schema-stored/format.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +12 -10
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -5
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-view/index.d.ts +1 -1
- package/lib/core/schema-view/index.d.ts.map +1 -1
- package/lib/core/schema-view/index.js +1 -1
- package/lib/core/schema-view/index.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -7
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js +0 -11
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
- package/lib/core/tree/chunk.d.ts.map +1 -0
- package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
- package/lib/core/tree/chunk.js.map +1 -0
- package/lib/core/tree/index.d.ts +1 -0
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -0
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts +0 -5
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/core/tree/types.d.ts +0 -5
- package/lib/core/tree/types.d.ts.map +1 -1
- package/lib/core/tree/types.js +0 -1
- package/lib/core/tree/types.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
- package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
- package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +31 -5
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js +9 -3
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +24 -4
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
- package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
- package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
- package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
- package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
- package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/types.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +14 -5
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -0
- package/lib/shared-tree/index.d.ts +3 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +7 -7
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +56 -17
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +31 -10
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +107 -16
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/transactionTypes.d.ts +105 -0
- package/lib/shared-tree/transactionTypes.d.ts.map +1 -0
- package/lib/shared-tree/transactionTypes.js +10 -0
- package/lib/shared-tree/transactionTypes.js.map +1 -0
- package/lib/shared-tree/treeApi.d.ts +1 -25
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +1 -5
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +39 -13
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +277 -130
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +13 -35
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +12 -76
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +7 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +16 -18
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +3 -3
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +3 -3
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +2 -2
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -9
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +4 -16
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +38 -0
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +112 -1
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js +2 -2
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +5 -1
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +14 -2
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +50 -2
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +3 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/jsonSchema.d.ts +6 -0
- package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/jsonSchema.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +65 -8
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +9 -3
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js +86 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
- package/lib/simple-tree/api/simpleSchema.d.ts +8 -2
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +14 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +3 -1
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +4 -4
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +5 -18
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/lib/simple-tree/api/tree.d.ts +61 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +2 -2
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/api/view.d.ts +14 -9
- package/lib/simple-tree/api/view.d.ts.map +1 -1
- package/lib/simple-tree/api/view.js +131 -42
- package/lib/simple-tree/api/view.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +12 -12
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- 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 +2 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +10 -6
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +5 -20
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +0 -15
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +2 -2
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +2 -1
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +9 -4
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +17 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +6 -2
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +51 -3
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +19 -14
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/util/brand.d.ts +0 -2
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js +0 -1
- package/lib/util/brand.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/rangeMap.d.ts +72 -42
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +159 -146
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/typeCheck.d.ts +0 -2
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/utils.d.ts +35 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +29 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/core/index.ts +5 -1
- package/src/core/rebase/utils.ts +17 -20
- package/src/core/schema-stored/format.ts +0 -3
- package/src/core/schema-stored/schema.ts +13 -10
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -11
- package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
- package/src/core/tree/index.ts +8 -0
- package/src/core/tree/treeTextFormat.ts +0 -5
- package/src/core/tree/types.ts +0 -5
- package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
- package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
- package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
- package/src/feature-libraries/chunked-forest/index.ts +1 -1
- package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +4 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +14 -1
- package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
- package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
- package/src/feature-libraries/index.ts +13 -1
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +34 -5
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +9 -9
- package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +13 -9
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -2
- package/src/feature-libraries/modular-schema/index.ts +14 -0
- package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +124 -31
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +12 -0
- package/src/feature-libraries/optional-field/optionalField.ts +34 -5
- package/src/feature-libraries/sequence-field/types.ts +0 -1
- package/src/feature-libraries/sequence-field/utils.ts +18 -7
- package/src/index.ts +12 -29
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +13 -2
- package/src/shared-tree/schematizeTree.ts +6 -10
- package/src/shared-tree/schematizingTreeView.ts +102 -23
- package/src/shared-tree/sharedTree.ts +181 -44
- package/src/shared-tree/transactionTypes.ts +125 -0
- package/src/shared-tree/treeApi.ts +1 -28
- package/src/shared-tree/treeCheckout.ts +358 -175
- package/src/shared-tree-core/branch.ts +29 -122
- package/src/shared-tree-core/branchCommitEnricher.ts +19 -20
- package/src/shared-tree-core/editManager.ts +3 -8
- package/src/shared-tree-core/index.ts +2 -1
- package/src/shared-tree-core/sharedTreeCore.ts +8 -19
- package/src/shared-tree-core/transaction.ts +145 -0
- package/src/simple-tree/api/conciseTree.ts +2 -2
- package/src/simple-tree/api/create.ts +5 -1
- package/src/simple-tree/api/customTree.ts +69 -1
- package/src/simple-tree/api/index.ts +13 -2
- package/src/simple-tree/api/jsonSchema.ts +7 -0
- package/src/simple-tree/api/schemaFactory.ts +91 -3
- package/src/simple-tree/api/schemaFactoryAlpha.ts +253 -0
- package/src/simple-tree/api/simpleSchema.ts +9 -2
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +22 -12
- package/src/simple-tree/api/simpleTreeIndex.ts +2 -0
- package/src/simple-tree/api/storedSchema.ts +7 -22
- package/src/simple-tree/api/tree.ts +78 -0
- package/src/simple-tree/api/verboseTree.ts +2 -2
- package/src/simple-tree/api/view.ts +197 -51
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +19 -13
- package/src/simple-tree/arrayNode.ts +7 -1
- package/src/simple-tree/core/treeNodeSchema.ts +51 -7
- package/src/simple-tree/index.ts +9 -0
- package/src/simple-tree/leafNodeSchema.ts +0 -19
- package/src/simple-tree/mapNode.ts +7 -1
- package/src/simple-tree/objectNode.ts +33 -3
- package/src/simple-tree/objectNodeTypes.ts +9 -1
- package/src/simple-tree/schemaTypes.ts +57 -3
- package/src/simple-tree/toStoredSchema.ts +25 -19
- package/src/util/brand.ts +0 -2
- package/src/util/index.ts +3 -6
- package/src/util/rangeMap.ts +199 -189
- package/src/util/typeCheck.ts +0 -2
- package/src/util/utils.ts +73 -1
- package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
- package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
- package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
- package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -74
- package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
- package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
- package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
- package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
- package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -71
- package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
- package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultEditBuilder.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAElB,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EAGX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAKN,KAAK,gBAAgB,EAIrB,MAAM,4BAA4B,CAAC;AASpC,OAAO,KAAK,EA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AAE,MAAM,GACtB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultEditBuilder.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAElB,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EAGX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAKN,KAAK,gBAAgB,EAIrB,MAAM,4BAA4B,CAAC;AASpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,mBACZ,YAAW,YAAY,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;IAE7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsB;gBAEjC,MAAM,EAAE,YAAY,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;IAIhF,IAAW,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAEpD;IAED,IAAW,MAAM,IAAI,YAAY,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAEzE;IAEM,WAAW,CACjB,eAAe,EAAE,MAAM,WAAW,EAClC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,IAAI,GAC9D,kBAAkB;CAGrB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAEjF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,M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AE,MAAM,GAAG,IAAI;IAInD,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,qBAAqB,CAAC,sBAAsB,CAAC;IA+B7E,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,wBAAwB,CAAC,sBAAsB,CAAC;IAwCnF,IAAI,CACV,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,WAAW,EAC7B,SAAS,EAAE,MAAM,GACf,IAAI;IAoGA,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,wBAAwB,CAAC,sBAAsB,CAAC;CA4C1F;AAED;GACG;AACH,MAAM,WAAW,qBAAqB,CAAC,QAAQ;IAC9C;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC;AAED;GACG;AACH,MAAM,WAAW,wBAAwB,CAAC,QAAQ;IACjD;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,QAAQ,GAAG,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/D;AAED;GACG;AACH,MAAM,WAAW,wBAAwB,CAAC,QAAQ;IACjD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;IAElD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C"}
|
|
@@ -69,6 +69,9 @@ export class DefaultEditBuilder {
|
|
|
69
69
|
addNodeExistsConstraint(path) {
|
|
70
70
|
this.modularBuilder.addNodeExistsConstraint(path, this.mintRevisionTag());
|
|
71
71
|
}
|
|
72
|
+
addNodeExistsConstraintOnRevert(path) {
|
|
73
|
+
this.modularBuilder.addNodeExistsConstraintOnRevert(path, this.mintRevisionTag());
|
|
74
|
+
}
|
|
72
75
|
valueField(field) {
|
|
73
76
|
return {
|
|
74
77
|
set: (newContent) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultEditBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAGtE,OAAO,EAcN,mBAAmB,EACnB,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAIN,mBAAmB,EAEnB,kBAAkB,EAClB,SAAS,IAAI,gBAAgB,EAC7B,oBAAoB,IAAI,2BAA2B,GACnD,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,IAAI,cAAc,GAC1B,MAAM,wBAAwB,CAAC;AAMhC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAK/B,YAAmB,MAA6D;QAC/E,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAEM,WAAW,CACjB,eAAkC,EAClC,cAAgE;QAEhE,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IACtE,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,YAA4C;IACrE,OAAO,gBAAgB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAwB;IAC5D,OAAO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M,EAAE,QAAQ,CAAC,CAAC;YAChF,CAAC;SACD,CAAC;IACH,CAAC;CACD;AA2CD;;GAEG;AACH,SAAS,qBAAqB,CAAC,KAAwB,EAAE,KAAwB;IAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,WAAW,GAAG,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;QAC/C,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC/B,IACC,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW;gBACjD,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,EAChD,CAAC;gBACF,MAAM;YACP,CAAC;QACF,CAAC;QACD,WAAW,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ICodecFamily } from \"../../codec/index.js\";\nimport {\n\ttype ChangeAtomId,\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype ChangeRebaser,\n\tCursorLocationType,\n\ttype DeltaDetachedNodeId,\n\ttype DeltaRoot,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\ttype UpPath,\n\tcompareFieldUpPaths,\n\ttopDownPath,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\ttype EditDescription,\n\ttype FieldChangeset,\n\ttype FieldEditDescription,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\tModularEditBuilder,\n\tintoDelta as intoModularDelta,\n\trelevantRemovedRoots as relevantModularRemovedRoots,\n} from \"../modular-schema/index.js\";\nimport type { OptionalChangeset } from \"../optional-field/index.js\";\n\nimport {\n\tfieldKinds,\n\toptional,\n\tsequence,\n\trequired as valueFieldKind,\n} from \"./defaultFieldKinds.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { CellId } from \"../sequence-field/index.js\";\n\nexport type DefaultChangeset = ModularChangeset;\n\n/**\n * Implementation of {@link ChangeFamily} based on the default set of supported field kinds.\n *\n * @sealed\n */\nexport class DefaultChangeFamily\n\timplements ChangeFamily<DefaultEditBuilder, DefaultChangeset>\n{\n\tprivate readonly modularFamily: ModularChangeFamily;\n\n\tpublic constructor(codecs: ICodecFamily<ModularChangeset, ChangeEncodingContext>) {\n\t\tthis.modularFamily = new ModularChangeFamily(fieldKinds, codecs);\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<DefaultChangeset> {\n\t\treturn this.modularFamily.rebaser;\n\t}\n\n\tpublic get codecs(): ICodecFamily<DefaultChangeset, ChangeEncodingContext> {\n\t\treturn this.modularFamily.codecs;\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<DefaultChangeset>) => void,\n\t): DefaultEditBuilder {\n\t\treturn new DefaultEditBuilder(this, mintRevisionTag, changeReceiver);\n\t}\n}\n\n/**\n * @param change - The change to convert into a delta.\n */\nexport function intoDelta(taggedChange: TaggedChange<ModularChangeset>): DeltaRoot {\n\treturn intoModularDelta(taggedChange, fieldKinds);\n}\n\n/**\n * Returns the set of removed roots that should be in memory for the given change to be applied.\n * A removed root is relevant if any of the following is true:\n * - It is being inserted\n * - It is being restored\n * - It is being edited\n * - The ID it is associated with is being changed\n *\n * May be conservative by returning more removed roots than strictly necessary.\n *\n * Will never return IDs for non-root trees, even if they are removed.\n *\n * @param change - The change to be applied.\n */\nexport function relevantRemovedRoots(change: ModularChangeset): Iterable<DeltaDetachedNodeId> {\n\treturn relevantModularRemovedRoots(change, fieldKinds);\n}\n\n/**\n * Default editor for transactional tree data changes.\n * @privateRemarks\n * When taking into account not just the content of the tree,\n * but also how the merge identities (and thus anchors, flex-tree and simple-tree nodes) of nodes before and after the edits correspond,\n * some edits are currently impossible to express.\n * Examples of these non-expressible edits include:\n *\n * - Changing the type of a node while keeping its merge identity.\n * - Changing the value of a leaf while keeping its merge identity.\n * - Swapping subtrees between two value fields.\n * - Replacing a node in the middle of a tree while reusing some of the old nodes decedents that were under value fields.\n *\n * At some point it will likely be worth supporting at least some of these, possibly using a mechanism that could support all of them if desired.\n * If/when such a mechanism becomes available, an evaluation should be done to determine if any existing editing operations should be changed to leverage it\n * (Possibly by adding opt ins at the view schema layer).\n */\nexport interface IDefaultEditBuilder {\n\t/**\n\t * @param field - the value field which is being edited under the parent node\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\tvalueField(field: FieldUpPath): ValueFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * @param field - the optional field which is being edited under the parent node\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\toptionalField(field: FieldUpPath): OptionalFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * @param field - the sequence field which is being edited under the parent node\n\t *\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\tsequenceField(field: FieldUpPath): SequenceFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * Moves a subsequence from one sequence field to another sequence field.\n\t *\n\t * Note that the `destinationIndex` is interpreted based on the state of the sequence *before* the move operation.\n\t * For example, `move(field, 0, 1, field, 2)` changes `[A, B, C]` to `[B, A, C]`.\n\t */\n\tmove(\n\t\tsourceField: FieldUpPath,\n\t\tsourceIndex: number,\n\t\tcount: number,\n\t\tdestinationField: FieldUpPath,\n\t\tdestinationIndex: number,\n\t): void;\n\n\t// TODO: document\n\taddNodeExistsConstraint(path: UpPath): void;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuilder {\n\tprivate readonly modularBuilder: ModularEditBuilder;\n\n\tpublic constructor(\n\t\tfamily: ChangeFamily<ChangeFamilyEditor, DefaultChangeset>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<DefaultChangeset>) => void,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tthis.modularBuilder = new ModularEditBuilder(family, fieldKinds, changeReceiver);\n\t}\n\n\tpublic enterTransaction(): void {\n\t\tthis.modularBuilder.enterTransaction();\n\t}\n\tpublic exitTransaction(): void {\n\t\tthis.modularBuilder.exitTransaction();\n\t}\n\n\tpublic addNodeExistsConstraint(path: UpPath): void {\n\t\tthis.modularBuilder.addNodeExistsConstraint(path, this.mintRevisionTag());\n\t}\n\n\tpublic valueField(field: FieldUpPath): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tset: (newContent: ITreeCursorSynchronous): void => {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tconst detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\tfill.localId,\n\t\t\t\t\tnewContent,\n\t\t\t\t\trevision,\n\t\t\t\t\tthis.idCompressor,\n\t\t\t\t);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tvalueFieldKind.changeHandler.editor.set({\n\t\t\t\t\t\tfill,\n\t\t\t\t\t\tdetach,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst edit: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: valueFieldKind.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tthis.modularBuilder.submitChanges([build, edit], revision);\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic optionalField(field: FieldUpPath): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tset: (newContent: ITreeCursorSynchronous | undefined, wasEmpty: boolean): void => {\n\t\t\t\tconst edits: EditDescription[] = [];\n\t\t\t\tlet optionalChange: OptionalChangeset;\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tconst fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\t\tfill.localId,\n\t\t\t\t\t\tnewContent,\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tthis.idCompressor,\n\t\t\t\t\t);\n\t\t\t\t\tedits.push(build);\n\n\t\t\t\t\toptionalChange = optional.changeHandler.editor.set(wasEmpty, {\n\t\t\t\t\t\tfill,\n\t\t\t\t\t\tdetach,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\toptionalChange = optional.changeHandler.editor.clear(wasEmpty, detach);\n\t\t\t\t}\n\n\t\t\t\tconst change: FieldChangeset = brand(optionalChange);\n\t\t\t\tconst edit: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: optional.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tedits.push(edit);\n\n\t\t\t\tthis.modularBuilder.submitChanges(edits, revision);\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic move(\n\t\tsourceField: FieldUpPath,\n\t\tsourceIndex: number,\n\t\tcount: number,\n\t\tdestinationField: FieldUpPath,\n\t\tdestIndex: number,\n\t): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t} else if (count < 0 || !Number.isSafeInteger(count)) {\n\t\t\tthrow new UsageError(`Expected non-negative integer count, got ${count}.`);\n\t\t}\n\t\tconst revision = this.mintRevisionTag();\n\t\tconst detachCellId = this.modularBuilder.generateId(count);\n\t\tconst attachCellId: CellId = { localId: this.modularBuilder.generateId(count), revision };\n\t\tif (compareFieldUpPaths(sourceField, destinationField)) {\n\t\t\tconst change = sequence.changeHandler.editor.move(\n\t\t\t\tsourceIndex,\n\t\t\t\tcount,\n\t\t\t\tdestIndex,\n\t\t\t\tdetachCellId,\n\t\t\t\tattachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tthis.modularBuilder.submitChange(\n\t\t\t\tsourceField,\n\t\t\t\tsequence.identifier,\n\t\t\t\tbrand(change),\n\t\t\t\trevision,\n\t\t\t);\n\t\t} else {\n\t\t\tconst detachPath = topDownPath(sourceField.parent);\n\t\t\tconst attachPath = topDownPath(destinationField.parent);\n\t\t\tconst sharedDepth = getSharedPrefixLength(detachPath, attachPath);\n\t\t\tlet adjustedAttachField = destinationField;\n\t\t\t// After the above loop, `sharedDepth` is the number of elements, starting from the root,\n\t\t\t// that both paths have in common.\n\t\t\tif (sharedDepth === detachPath.length) {\n\t\t\t\tconst attachField = attachPath[sharedDepth]?.parentField ?? destinationField.field;\n\t\t\t\tif (attachField === sourceField.field) {\n\t\t\t\t\t// The detach occurs in an ancestor field of the field where the attach occurs.\n\t\t\t\t\tlet attachAncestorIndex = attachPath[sharedDepth]?.parentIndex ?? sourceIndex;\n\t\t\t\t\tif (attachAncestorIndex < sourceIndex) {\n\t\t\t\t\t\t// The attach path runs through a node located before the detached nodes.\n\t\t\t\t\t\t// No need to adjust the attach path.\n\t\t\t\t\t} else if (sourceIndex + count <= attachAncestorIndex) {\n\t\t\t\t\t\t// The attach path runs through a node located after the detached nodes.\n\t\t\t\t\t\t// adjust the index for the node at that depth of the path, so that it is interpreted correctly\n\t\t\t\t\t\t// in the composition performed by `submitChanges`.\n\t\t\t\t\t\tattachAncestorIndex -= count;\n\t\t\t\t\t\tlet parent: UpPath | undefined = attachPath[sharedDepth - 1];\n\t\t\t\t\t\tconst parentField = attachPath[sharedDepth] ?? oob();\n\t\t\t\t\t\tparent = {\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tparentIndex: attachAncestorIndex,\n\t\t\t\t\t\t\tparentField: parentField.parentField,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tfor (let i = sharedDepth + 1; i < attachPath.length; i += 1) {\n\t\t\t\t\t\t\tparent = {\n\t\t\t\t\t\t\t\t...(attachPath[i] ?? oob()),\n\t\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tadjustedAttachField = { parent, field: destinationField.field };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"Invalid move operation: the destination is located under one of the moved elements. Consider using the Tree.contains API to detect this.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst moveOut = sequence.changeHandler.editor.moveOut(\n\t\t\t\tsourceIndex,\n\t\t\t\tcount,\n\t\t\t\tdetachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tconst moveIn = sequence.changeHandler.editor.moveIn(\n\t\t\t\tdestIndex,\n\t\t\t\tcount,\n\t\t\t\tdetachCellId,\n\t\t\t\tattachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tthis.modularBuilder.submitChanges(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"field\",\n\t\t\t\t\t\tfield: sourceField,\n\t\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\t\tchange: brand(moveOut),\n\t\t\t\t\t\trevision,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"field\",\n\t\t\t\t\t\tfield: adjustedAttachField,\n\t\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\t\tchange: brand(moveIn),\n\t\t\t\t\t\trevision,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\trevision,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic sequenceField(field: FieldUpPath): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tinsert: (index: number, content: ITreeCursorSynchronous): void => {\n\t\t\t\tconst length =\n\t\t\t\t\tcontent.mode === CursorLocationType.Fields ? content.getFieldLength() : 1;\n\t\t\t\tif (length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst firstId: CellId = { localId: this.modularBuilder.generateId(length), revision };\n\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\tfirstId.localId,\n\t\t\t\t\tcontent,\n\t\t\t\t\trevision,\n\t\t\t\t\tthis.idCompressor,\n\t\t\t\t);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tsequence.changeHandler.editor.insert(index, length, firstId, revision),\n\t\t\t\t);\n\t\t\t\tconst attach: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\t// The changes have to be submitted together, otherwise they will be assigned different revisions,\n\t\t\t\t// which will prevent the build ID and the insert ID from matching.\n\t\t\t\tthis.modularBuilder.submitChanges([build, attach], revision);\n\t\t\t},\n\t\t\tremove: (index: number, count: number): void => {\n\t\t\t\tif (count === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst id = this.modularBuilder.generateId(count);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tsequence.changeHandler.editor.remove(index, count, id, revision),\n\t\t\t\t);\n\t\t\t\tthis.modularBuilder.submitChange(field, sequence.identifier, change, revision);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n */\nexport interface ValueFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which replaces the current newContent of the field with `newContent`.\n\t * @param newContent - the new content for the field.\n\t * The cursor can be in either Field or Node mode and must represent exactly one node.\n\t */\n\tset(newContent: TContent): void;\n}\n\n/**\n */\nexport interface OptionalFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which replaces the current newContent of the field with `newContent`\n\t * @param newContent - the new content for the field.\n\t * If provided, the cursor can be in either Field or Node mode and must represent exactly one node.\n\t * @param wasEmpty - whether the field is empty when creating this change\n\t */\n\tset(newContent: TContent | undefined, wasEmpty: boolean): void;\n}\n\n/**\n */\nexport interface SequenceFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which inserts the `newContent` at the given `index`.\n\t * @param index - the index at which to insert the `newContent`.\n\t * @param newContent - the new content to be inserted in the field. Cursor can be in either Field or Node mode.\n\t */\n\tinsert(index: number, newContent: TContent): void;\n\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t */\n\tremove(index: number, count: number): void;\n}\n\n/**\n * @returns The number of path elements that both paths share, starting at index 0.\n */\nfunction getSharedPrefixLength(pathA: readonly UpPath[], pathB: readonly UpPath[]): number {\n\tconst minDepth = Math.min(pathA.length, pathB.length);\n\tlet sharedDepth = 0;\n\twhile (sharedDepth < minDepth) {\n\t\tconst detachStep = pathA[sharedDepth] ?? oob();\n\t\tconst attachStep = pathB[sharedDepth] ?? oob();\n\t\tif (detachStep !== attachStep) {\n\t\t\tif (\n\t\t\t\tdetachStep.parentField !== attachStep.parentField ||\n\t\t\t\tdetachStep.parentIndex !== attachStep.parentIndex\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tsharedDepth += 1;\n\t}\n\treturn sharedDepth;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"defaultEditBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultEditBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAGtE,OAAO,EAcN,mBAAmB,EACnB,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAIN,mBAAmB,EAEnB,kBAAkB,EAClB,SAAS,IAAI,gBAAgB,EAC7B,oBAAoB,IAAI,2BAA2B,GACnD,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,IAAI,cAAc,GAC1B,MAAM,wBAAwB,CAAC;AAMhC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAK/B,YAAmB,MAA6D;QAC/E,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAEM,WAAW,CACjB,eAAkC,EAClC,cAAgE;QAEhE,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,cAAc,CAAC,CA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,IAAI,CAAC,eAAe,EAAE,CAAC;gBACxC,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACjD,MAAM,MAAM,GAAmB,KAAK,CACnC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,CAAC,CAChE,CAAC;gBACF,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;YAChF,CAAC;SACD,CAAC;IACH,CAAC;CACD;AA2CD;;GAEG;AACH,SAAS,qBAAqB,CAAC,KAAwB,EAAE,KAAwB;IAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,WAAW,GAAG,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;QAC/C,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC/B,IACC,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW;gBACjD,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,EAChD,CAAC;gBACF,MAAM;YACP,CAAC;QACF,CAAC;QACD,WAAW,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ICodecFamily } from \"../../codec/index.js\";\nimport {\n\ttype ChangeAtomId,\n\ttype ChangeEncodingContext,\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype ChangeRebaser,\n\tCursorLocationType,\n\ttype DeltaDetachedNodeId,\n\ttype DeltaRoot,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\ttype UpPath,\n\tcompareFieldUpPaths,\n\ttopDownPath,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport {\n\ttype EditDescription,\n\ttype FieldChangeset,\n\ttype FieldEditDescription,\n\tModularChangeFamily,\n\ttype ModularChangeset,\n\tModularEditBuilder,\n\tintoDelta as intoModularDelta,\n\trelevantRemovedRoots as relevantModularRemovedRoots,\n} from \"../modular-schema/index.js\";\nimport type { OptionalChangeset } from \"../optional-field/index.js\";\n\nimport {\n\tfieldKinds,\n\toptional,\n\tsequence,\n\trequired as valueFieldKind,\n} from \"./defaultFieldKinds.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { CellId } from \"../sequence-field/index.js\";\n\nexport type DefaultChangeset = ModularChangeset;\n\n/**\n * Implementation of {@link ChangeFamily} based on the default set of supported field kinds.\n *\n * @sealed\n */\nexport class DefaultChangeFamily\n\timplements ChangeFamily<DefaultEditBuilder, DefaultChangeset>\n{\n\tprivate readonly modularFamily: ModularChangeFamily;\n\n\tpublic constructor(codecs: ICodecFamily<ModularChangeset, ChangeEncodingContext>) {\n\t\tthis.modularFamily = new ModularChangeFamily(fieldKinds, codecs);\n\t}\n\n\tpublic get rebaser(): ChangeRebaser<DefaultChangeset> {\n\t\treturn this.modularFamily.rebaser;\n\t}\n\n\tpublic get codecs(): ICodecFamily<DefaultChangeset, ChangeEncodingContext> {\n\t\treturn this.modularFamily.codecs;\n\t}\n\n\tpublic buildEditor(\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<DefaultChangeset>) => void,\n\t): DefaultEditBuilder {\n\t\treturn new DefaultEditBuilder(this, mintRevisionTag, changeReceiver);\n\t}\n}\n\n/**\n * @param change - The change to convert into a delta.\n */\nexport function intoDelta(taggedChange: TaggedChange<ModularChangeset>): DeltaRoot {\n\treturn intoModularDelta(taggedChange, fieldKinds);\n}\n\n/**\n * Returns the set of removed roots that should be in memory for the given change to be applied.\n * A removed root is relevant if any of the following is true:\n * - It is being inserted\n * - It is being restored\n * - It is being edited\n * - The ID it is associated with is being changed\n *\n * May be conservative by returning more removed roots than strictly necessary.\n *\n * Will never return IDs for non-root trees, even if they are removed.\n *\n * @param change - The change to be applied.\n */\nexport function relevantRemovedRoots(change: ModularChangeset): Iterable<DeltaDetachedNodeId> {\n\treturn relevantModularRemovedRoots(change, fieldKinds);\n}\n\n/**\n * Default editor for transactional tree data changes.\n * @privateRemarks\n * When taking into account not just the content of the tree,\n * but also how the merge identities (and thus anchors, flex-tree and simple-tree nodes) of nodes before and after the edits correspond,\n * some edits are currently impossible to express.\n * Examples of these non-expressible edits include:\n *\n * - Changing the type of a node while keeping its merge identity.\n * - Changing the value of a leaf while keeping its merge identity.\n * - Swapping subtrees between two value fields.\n * - Replacing a node in the middle of a tree while reusing some of the old nodes decedents that were under value fields.\n *\n * At some point it will likely be worth supporting at least some of these, possibly using a mechanism that could support all of them if desired.\n * If/when such a mechanism becomes available, an evaluation should be done to determine if any existing editing operations should be changed to leverage it\n * (Possibly by adding opt ins at the view schema layer).\n */\nexport interface IDefaultEditBuilder {\n\t/**\n\t * @param field - the value field which is being edited under the parent node\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\tvalueField(field: FieldUpPath): ValueFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * @param field - the optional field which is being edited under the parent node\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\toptionalField(field: FieldUpPath): OptionalFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * @param field - the sequence field which is being edited under the parent node\n\t *\n\t * @returns An object with methods to edit the given field of the given parent.\n\t * The returned object can be used (i.e., have its methods called) multiple times but its lifetime\n\t * is bounded by the lifetime of this edit builder.\n\t */\n\tsequenceField(field: FieldUpPath): SequenceFieldEditBuilder<ITreeCursorSynchronous>;\n\n\t/**\n\t * Moves a subsequence from one sequence field to another sequence field.\n\t *\n\t * Note that the `destinationIndex` is interpreted based on the state of the sequence *before* the move operation.\n\t * For example, `move(field, 0, 1, field, 2)` changes `[A, B, C]` to `[B, A, C]`.\n\t */\n\tmove(\n\t\tsourceField: FieldUpPath,\n\t\tsourceIndex: number,\n\t\tcount: number,\n\t\tdestinationField: FieldUpPath,\n\t\tdestinationIndex: number,\n\t): void;\n\n\t/**\n\t * Add a constraint that the node at the given path must exist.\n\t * @param path - The path to the node that must exist.\n\t */\n\taddNodeExistsConstraint(path: UpPath): void;\n\n\t/**\n\t * Add a constraint that the node at the given path must exist when reverting a change.\n\t * @param path - The path to the node that must exist when reverting a change.\n\t */\n\taddNodeExistsConstraintOnRevert(path: UpPath): void;\n}\n\n/**\n * Implementation of {@link IDefaultEditBuilder} based on the default set of supported field kinds.\n * @sealed\n */\nexport class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuilder {\n\tprivate readonly modularBuilder: ModularEditBuilder;\n\n\tpublic constructor(\n\t\tfamily: ChangeFamily<ChangeFamilyEditor, DefaultChangeset>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tchangeReceiver: (change: TaggedChange<DefaultChangeset>) => void,\n\t\tprivate readonly idCompressor?: IIdCompressor,\n\t) {\n\t\tthis.modularBuilder = new ModularEditBuilder(family, fieldKinds, changeReceiver);\n\t}\n\n\tpublic enterTransaction(): void {\n\t\tthis.modularBuilder.enterTransaction();\n\t}\n\tpublic exitTransaction(): void {\n\t\tthis.modularBuilder.exitTransaction();\n\t}\n\n\tpublic addNodeExistsConstraint(path: UpPath): void {\n\t\tthis.modularBuilder.addNodeExistsConstraint(path, this.mintRevisionTag());\n\t}\n\n\tpublic addNodeExistsConstraintOnRevert(path: UpPath): void {\n\t\tthis.modularBuilder.addNodeExistsConstraintOnRevert(path, this.mintRevisionTag());\n\t}\n\n\tpublic valueField(field: FieldUpPath): ValueFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tset: (newContent: ITreeCursorSynchronous): void => {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tconst detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\tfill.localId,\n\t\t\t\t\tnewContent,\n\t\t\t\t\trevision,\n\t\t\t\t\tthis.idCompressor,\n\t\t\t\t);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tvalueFieldKind.changeHandler.editor.set({\n\t\t\t\t\t\tfill,\n\t\t\t\t\t\tdetach,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst edit: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: valueFieldKind.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tthis.modularBuilder.submitChanges([build, edit], revision);\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic optionalField(field: FieldUpPath): OptionalFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tset: (newContent: ITreeCursorSynchronous | undefined, wasEmpty: boolean): void => {\n\t\t\t\tconst edits: EditDescription[] = [];\n\t\t\t\tlet optionalChange: OptionalChangeset;\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst detach: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tconst fill: ChangeAtomId = { localId: this.modularBuilder.generateId(), revision };\n\t\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\t\tfill.localId,\n\t\t\t\t\t\tnewContent,\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tthis.idCompressor,\n\t\t\t\t\t);\n\t\t\t\t\tedits.push(build);\n\n\t\t\t\t\toptionalChange = optional.changeHandler.editor.set(wasEmpty, {\n\t\t\t\t\t\tfill,\n\t\t\t\t\t\tdetach,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\toptionalChange = optional.changeHandler.editor.clear(wasEmpty, detach);\n\t\t\t\t}\n\n\t\t\t\tconst change: FieldChangeset = brand(optionalChange);\n\t\t\t\tconst edit: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: optional.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\tedits.push(edit);\n\n\t\t\t\tthis.modularBuilder.submitChanges(edits, revision);\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic move(\n\t\tsourceField: FieldUpPath,\n\t\tsourceIndex: number,\n\t\tcount: number,\n\t\tdestinationField: FieldUpPath,\n\t\tdestIndex: number,\n\t): void {\n\t\tif (count === 0) {\n\t\t\treturn;\n\t\t} else if (count < 0 || !Number.isSafeInteger(count)) {\n\t\t\tthrow new UsageError(`Expected non-negative integer count, got ${count}.`);\n\t\t}\n\t\tconst revision = this.mintRevisionTag();\n\t\tconst detachCellId = this.modularBuilder.generateId(count);\n\t\tconst attachCellId: CellId = { localId: this.modularBuilder.generateId(count), revision };\n\t\tif (compareFieldUpPaths(sourceField, destinationField)) {\n\t\t\tconst change = sequence.changeHandler.editor.move(\n\t\t\t\tsourceIndex,\n\t\t\t\tcount,\n\t\t\t\tdestIndex,\n\t\t\t\tdetachCellId,\n\t\t\t\tattachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tthis.modularBuilder.submitChange(\n\t\t\t\tsourceField,\n\t\t\t\tsequence.identifier,\n\t\t\t\tbrand(change),\n\t\t\t\trevision,\n\t\t\t);\n\t\t} else {\n\t\t\tconst detachPath = topDownPath(sourceField.parent);\n\t\t\tconst attachPath = topDownPath(destinationField.parent);\n\t\t\tconst sharedDepth = getSharedPrefixLength(detachPath, attachPath);\n\t\t\tlet adjustedAttachField = destinationField;\n\t\t\t// After the above loop, `sharedDepth` is the number of elements, starting from the root,\n\t\t\t// that both paths have in common.\n\t\t\tif (sharedDepth === detachPath.length) {\n\t\t\t\tconst attachField = attachPath[sharedDepth]?.parentField ?? destinationField.field;\n\t\t\t\tif (attachField === sourceField.field) {\n\t\t\t\t\t// The detach occurs in an ancestor field of the field where the attach occurs.\n\t\t\t\t\tlet attachAncestorIndex = attachPath[sharedDepth]?.parentIndex ?? sourceIndex;\n\t\t\t\t\tif (attachAncestorIndex < sourceIndex) {\n\t\t\t\t\t\t// The attach path runs through a node located before the detached nodes.\n\t\t\t\t\t\t// No need to adjust the attach path.\n\t\t\t\t\t} else if (sourceIndex + count <= attachAncestorIndex) {\n\t\t\t\t\t\t// The attach path runs through a node located after the detached nodes.\n\t\t\t\t\t\t// adjust the index for the node at that depth of the path, so that it is interpreted correctly\n\t\t\t\t\t\t// in the composition performed by `submitChanges`.\n\t\t\t\t\t\tattachAncestorIndex -= count;\n\t\t\t\t\t\tlet parent: UpPath | undefined = attachPath[sharedDepth - 1];\n\t\t\t\t\t\tconst parentField = attachPath[sharedDepth] ?? oob();\n\t\t\t\t\t\tparent = {\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tparentIndex: attachAncestorIndex,\n\t\t\t\t\t\t\tparentField: parentField.parentField,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tfor (let i = sharedDepth + 1; i < attachPath.length; i += 1) {\n\t\t\t\t\t\t\tparent = {\n\t\t\t\t\t\t\t\t...(attachPath[i] ?? oob()),\n\t\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tadjustedAttachField = { parent, field: destinationField.field };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"Invalid move operation: the destination is located under one of the moved elements. Consider using the Tree.contains API to detect this.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst moveOut = sequence.changeHandler.editor.moveOut(\n\t\t\t\tsourceIndex,\n\t\t\t\tcount,\n\t\t\t\tdetachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tconst moveIn = sequence.changeHandler.editor.moveIn(\n\t\t\t\tdestIndex,\n\t\t\t\tcount,\n\t\t\t\tdetachCellId,\n\t\t\t\tattachCellId,\n\t\t\t\trevision,\n\t\t\t);\n\t\t\tthis.modularBuilder.submitChanges(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"field\",\n\t\t\t\t\t\tfield: sourceField,\n\t\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\t\tchange: brand(moveOut),\n\t\t\t\t\t\trevision,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"field\",\n\t\t\t\t\t\tfield: adjustedAttachField,\n\t\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\t\tchange: brand(moveIn),\n\t\t\t\t\t\trevision,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\trevision,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic sequenceField(field: FieldUpPath): SequenceFieldEditBuilder<ITreeCursorSynchronous> {\n\t\treturn {\n\t\t\tinsert: (index: number, content: ITreeCursorSynchronous): void => {\n\t\t\t\tconst length =\n\t\t\t\t\tcontent.mode === CursorLocationType.Fields ? content.getFieldLength() : 1;\n\t\t\t\tif (length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst firstId: CellId = { localId: this.modularBuilder.generateId(length), revision };\n\t\t\t\tconst build = this.modularBuilder.buildTrees(\n\t\t\t\t\tfirstId.localId,\n\t\t\t\t\tcontent,\n\t\t\t\t\trevision,\n\t\t\t\t\tthis.idCompressor,\n\t\t\t\t);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tsequence.changeHandler.editor.insert(index, length, firstId, revision),\n\t\t\t\t);\n\t\t\t\tconst attach: FieldEditDescription = {\n\t\t\t\t\ttype: \"field\",\n\t\t\t\t\tfield,\n\t\t\t\t\tfieldKind: sequence.identifier,\n\t\t\t\t\tchange,\n\t\t\t\t\trevision,\n\t\t\t\t};\n\t\t\t\t// The changes have to be submitted together, otherwise they will be assigned different revisions,\n\t\t\t\t// which will prevent the build ID and the insert ID from matching.\n\t\t\t\tthis.modularBuilder.submitChanges([build, attach], revision);\n\t\t\t},\n\t\t\tremove: (index: number, count: number): void => {\n\t\t\t\tif (count === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst id = this.modularBuilder.generateId(count);\n\t\t\t\tconst change: FieldChangeset = brand(\n\t\t\t\t\tsequence.changeHandler.editor.remove(index, count, id, revision),\n\t\t\t\t);\n\t\t\t\tthis.modularBuilder.submitChange(field, sequence.identifier, change, revision);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n */\nexport interface ValueFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which replaces the current newContent of the field with `newContent`.\n\t * @param newContent - the new content for the field.\n\t * The cursor can be in either Field or Node mode and must represent exactly one node.\n\t */\n\tset(newContent: TContent): void;\n}\n\n/**\n */\nexport interface OptionalFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which replaces the current newContent of the field with `newContent`\n\t * @param newContent - the new content for the field.\n\t * If provided, the cursor can be in either Field or Node mode and must represent exactly one node.\n\t * @param wasEmpty - whether the field is empty when creating this change\n\t */\n\tset(newContent: TContent | undefined, wasEmpty: boolean): void;\n}\n\n/**\n */\nexport interface SequenceFieldEditBuilder<TContent> {\n\t/**\n\t * Issues a change which inserts the `newContent` at the given `index`.\n\t * @param index - the index at which to insert the `newContent`.\n\t * @param newContent - the new content to be inserted in the field. Cursor can be in either Field or Node mode.\n\t */\n\tinsert(index: number, newContent: TContent): void;\n\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t */\n\tremove(index: number, count: number): void;\n}\n\n/**\n * @returns The number of path elements that both paths share, starting at index 0.\n */\nfunction getSharedPrefixLength(pathA: readonly UpPath[], pathB: readonly UpPath[]): number {\n\tconst minDepth = Math.min(pathA.length, pathB.length);\n\tlet sharedDepth = 0;\n\twhile (sharedDepth < minDepth) {\n\t\tconst detachStep = pathA[sharedDepth] ?? oob();\n\t\tconst attachStep = pathB[sharedDepth] ?? oob();\n\t\tif (detachStep !== attachStep) {\n\t\t\tif (\n\t\t\t\tdetachStep.parentField !== attachStep.parentField ||\n\t\t\t\tdetachStep.parentIndex !== attachStep.parentIndex\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tsharedDepth += 1;\n\t}\n\treturn sharedDepth;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSchema.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"defaultSchema.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAIjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSchema.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACpD,UAAU;IACV,cAAc,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"defaultSchema.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/defaultSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACpD,UAAU;IACV,cAAc,EAAE,KAAK;IACrB,0BAA0B,EAAE,GAAG,EAAE,CAAC,KAAK;CACvC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\n\nimport { fieldKinds } from \"./defaultFieldKinds.js\";\n\n/**\n * FullSchemaPolicy with the default field kinds.\n */\nexport const defaultSchemaPolicy: FullSchemaPolicy = {\n\tfieldKinds,\n\tvalidateSchema: false,\n\tallowUnknownOptionalFields: () => false,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAI1B,YAAY,EACZ,KAAK,eAAe,EACpB,MAAM,qBAAqB,CAAC;AAI7B,0BAAkB,sBAAsB;IACvC,OAAO,IAAA;IACP,2BAA2B,IAAA;IAC3B,2BAA2B,IAAA;IAC3B,wBAAwB,IAAA;IACxB,qBAAqB,IAAA;IACrB,yBAAyB,IAAA;IACzB,2BAA2B,IAAA;IAC3B,2BAA2B,IAAA;IAC3B,kBAAkB,IAAA;IAClB,YAAY,IAAA;CACZ;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,OAAO,EACb,eAAe,EAAE,eAAe,GAC9B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"schemaChecker.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAI1B,YAAY,EACZ,KAAK,eAAe,EACpB,MAAM,qBAAqB,CAAC;AAI7B,0BAAkB,sBAAsB;IACvC,OAAO,IAAA;IACP,2BAA2B,IAAA;IAC3B,2BAA2B,IAAA;IAC3B,wBAAwB,IAAA;IACxB,qBAAqB,IAAA;IACrB,yBAAyB,IAAA;IACzB,2BAA2B,IAAA;IAC3B,2BAA2B,IAAA;IAC3B,kBAAkB,IAAA;IAClB,YAAY,IAAA;CACZ;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,OAAO,EACb,eAAe,EAAE,eAAe,GAC9B,sBAAsB,CA2DxB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,SAAS,OAAO,EAAE,EAC9B,MAAM,EAAE,qBAAqB,EAC7B,eAAe,EAAE,eAAe,GAC9B,sBAAsB,CA0BxB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,YAAY,GACxB,OAAO,CAaT"}
|
|
@@ -58,7 +58,8 @@ export function isNodeInSchema(node, schemaAndPolicy) {
|
|
|
58
58
|
uncheckedFieldsFromNode.delete(fieldKey);
|
|
59
59
|
}
|
|
60
60
|
// The node has fields that we did not check as part of looking at every field defined in the node's schema
|
|
61
|
-
if (uncheckedFieldsFromNode.size !== 0
|
|
61
|
+
if (uncheckedFieldsFromNode.size !== 0 &&
|
|
62
|
+
!schemaAndPolicy.policy.allowUnknownOptionalFields(node.type)) {
|
|
62
63
|
return 6 /* SchemaValidationErrors.ObjectNode_FieldNotInSchema */;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaChecker.js","sourceRoot":"","sources":["../../../src/feature-libraries/default-schema/schemaChecker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAGN,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GAEZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,MAAM,CAAN,IAAkB,sBAWjB;AAXD,WAAkB,sBAAsB;IACvC,yEAAO,CAAA;IACP,iHAA2B,CAAA;IAC3B,iHAA2B,CAAA;IAC3B,2GAAwB,CAAA;IACxB,qGAAqB,CAAA;IACrB,6GAAyB,CAAA;IACzB,iHAA2B,CAAA;IAC3B,iHAA2B,CAAA;IAC3B,+FAAkB,CAAA;IAClB,mFAAY,CAAA;AACb,CAAC,EAXiB,sBAAsB,KAAtB,sBAAsB,QAWvC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAa,EACb,eAAgC;IAEhC,mHAAmH;IACnH,+BAA+B;IAC/B,gBAAgB;IAChB,4GAA4G;IAC5G,IAAI,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAClD,8CAAsC;IACvC,CAAC;IAED,kDAAkD;IAClD,MAAM,MAAM,GAAG,eAAe,CAA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AAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype MapTree,\n\ttype TreeFieldStoredSchema,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tMultiplicity,\n\ttype SchemaAndPolicy,\n} from \"../../core/index.js\";\nimport { allowsValue } from \"../valueUtilities.js\";\nimport { fail } from \"../../util/index.js\";\n\nexport const enum SchemaValidationErrors {\n\tNoError,\n\tField_KindNotInSchemaPolicy,\n\tField_IncorrectMultiplicity,\n\tField_NodeTypeNotAllowed,\n\tLeafNode_InvalidValue,\n\tLeafNode_FieldsNotAllowed,\n\tObjectNode_FieldNotInSchema,\n\tNonLeafNode_ValueNotAllowed,\n\tNode_MissingSchema,\n\tUnknownError,\n}\n\n/**\n * Deeply checks that the provided node complies with the schema based on its identifier.\n */\nexport function isNodeInSchema(\n\tnode: MapTree,\n\tschemaAndPolicy: SchemaAndPolicy,\n): SchemaValidationErrors {\n\t// If the stored schema is completely empty it _probably_ (in almost all cases?) means the tree is brand new and we\n\t// shouldn't validate the data.\n\t// TODO: AB#8197\n\t// See https://github.com/microsoft/FluidFramework/pull/21305#discussion_r1626595991 for further discussion.\n\tif (schemaAndPolicy.schema.nodeSchema.size === 0) {\n\t\treturn SchemaValidationErrors.NoError;\n\t}\n\n\t// Validate the schema declared by the node exists\n\tconst schema = schemaAndPolicy.schema.nodeSchema.get(node.type);\n\tif (schema === undefined) {\n\t\treturn SchemaValidationErrors.Node_MissingSchema;\n\t}\n\n\t// Validate the node is well formed according to its schema\n\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tif (node.fields.size !== 0) {\n\t\t\treturn SchemaValidationErrors.LeafNode_FieldsNotAllowed;\n\t\t}\n\t\tif (!allowsValue(schema.leafValue, node.value)) {\n\t\t\treturn SchemaValidationErrors.LeafNode_InvalidValue;\n\t\t}\n\t} else if (schema instanceof ObjectNodeStoredSchema) {\n\t\tif (node.value !== undefined) {\n\t\t\treturn SchemaValidationErrors.NonLeafNode_ValueNotAllowed;\n\t\t}\n\t\tconst uncheckedFieldsFromNode = new Set(node.fields.keys());\n\t\tfor (const [fieldKey, fieldSchema] of schema.objectNodeFields) {\n\t\t\tconst nodeField = node.fields.get(fieldKey) ?? [];\n\t\t\tconst fieldInSchemaResult = isFieldInSchema(nodeField, fieldSchema, schemaAndPolicy);\n\t\t\tif (fieldInSchemaResult !== SchemaValidationErrors.NoError) {\n\t\t\t\treturn fieldInSchemaResult;\n\t\t\t}\n\t\t\tuncheckedFieldsFromNode.delete(fieldKey);\n\t\t}\n\t\t// The node has fields that we did not check as part of looking at every field defined in the node's schema\n\t\tif (\n\t\t\tuncheckedFieldsFromNode.size !== 0 &&\n\t\t\t!schemaAndPolicy.policy.allowUnknownOptionalFields(node.type)\n\t\t) {\n\t\t\treturn SchemaValidationErrors.ObjectNode_FieldNotInSchema;\n\t\t}\n\t} else if (schema instanceof MapNodeStoredSchema) {\n\t\tif (node.value !== undefined) {\n\t\t\treturn SchemaValidationErrors.NonLeafNode_ValueNotAllowed;\n\t\t}\n\t\tfor (const field of node.fields.values()) {\n\t\t\tconst fieldInSchemaResult = isFieldInSchema(field, schema.mapFields, schemaAndPolicy);\n\t\t\tif (fieldInSchemaResult !== SchemaValidationErrors.NoError) {\n\t\t\t\treturn fieldInSchemaResult;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfail(\"Unknown TreeNodeStoredSchema type\");\n\t}\n\n\treturn SchemaValidationErrors.NoError;\n}\n\n/**\n * Deeply checks that the nodes comply with the field schema and included schema.\n */\nexport function isFieldInSchema(\n\tchildNodes: readonly MapTree[],\n\tschema: TreeFieldStoredSchema,\n\tschemaAndPolicy: SchemaAndPolicy,\n): SchemaValidationErrors {\n\t// Validate that the field kind is handled by the schema policy\n\tconst kind = schemaAndPolicy.policy.fieldKinds.get(schema.kind);\n\tif (kind === undefined) {\n\t\treturn SchemaValidationErrors.Field_KindNotInSchemaPolicy;\n\t}\n\n\t// Validate that the field doesn't contain more nodes than its type supports\n\tif (!compliesWithMultiplicity(childNodes.length, kind.multiplicity)) {\n\t\treturn SchemaValidationErrors.Field_IncorrectMultiplicity;\n\t}\n\n\tfor (const node of childNodes) {\n\t\t// Validate the type declared by the node is allowed in this field\n\t\tif (schema.types !== undefined && !schema.types.has(node.type)) {\n\t\t\treturn SchemaValidationErrors.Field_NodeTypeNotAllowed;\n\t\t}\n\n\t\t// Validate the node complies with the type it declares to be.\n\t\tconst nodeInSchemaResult = isNodeInSchema(node, schemaAndPolicy);\n\t\tif (nodeInSchemaResult !== SchemaValidationErrors.NoError) {\n\t\t\treturn nodeInSchemaResult;\n\t\t}\n\t}\n\n\treturn SchemaValidationErrors.NoError;\n}\n\n/**\n * Validates that a given number of items complies with the specified {@link Multiplicity | multiplicity}.\n * @param numberOfItems - Number of items.\n * @param multiplicity - Kind of multiplicity to validate against.\n * @returns `true` if the specified number of items complies with the specified multiplicity; otherwise, `false`.\n */\nexport function compliesWithMultiplicity(\n\tnumberOfItems: number,\n\tmultiplicity: Multiplicity,\n): boolean {\n\tswitch (multiplicity) {\n\t\tcase Multiplicity.Single:\n\t\t\treturn numberOfItems === 1;\n\t\tcase Multiplicity.Optional:\n\t\t\treturn numberOfItems <= 1;\n\t\tcase Multiplicity.Sequence:\n\t\t\treturn true;\n\t\tcase Multiplicity.Forbidden:\n\t\t\treturn numberOfItems === 0;\n\t\tdefault:\n\t\t\tunreachableCase(multiplicity);\n\t}\n}\n"]}
|
|
@@ -6,14 +6,13 @@ export { type DownPath, toDownPath, } from "./editableTreeBinder.js";
|
|
|
6
6
|
export { allowsValue, assertAllowedValue, isTreeValue } from "./valueUtilities.js";
|
|
7
7
|
export { ForestSummarizer } from "./forest-summary/index.js";
|
|
8
8
|
export { cursorForMapTreeField, cursorForMapTreeNode, mapTreeFromCursor, mapTreeFieldFromCursor, } from "./mapTreeCursor.js";
|
|
9
|
-
export { MemoizedIdRangeAllocator, type IdRange } from "./memoizedIdRangeAllocator.js";
|
|
10
9
|
export { buildForest } from "./object-forest/index.js";
|
|
11
10
|
export { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from "./schema-index/index.js";
|
|
12
11
|
export { stackTreeNodeCursor, type CursorAdapter, prefixPath, prefixFieldPath, type CursorWithNode, stackTreeFieldCursor, } from "./treeCursorUtils.js";
|
|
13
12
|
export { cursorForJsonableTreeNode, cursorForJsonableTreeField, jsonableTreeFromCursor, jsonableTreeFromFieldCursor, jsonableTreeFromForest, } from "./treeTextCursor.js";
|
|
14
13
|
import * as SequenceField from "./sequence-field/index.js";
|
|
15
14
|
export { SequenceField };
|
|
16
|
-
export { isNeverField, ModularEditBuilder, type FieldEditDescription as EditDescription, type FieldChangeHandler, type FieldChangeRebaser, type FieldEditor, type FieldChangeMap, type FieldChange, type FieldChangeset, type ToDelta, type ModularChangeset, makeModularChangeCodecFamily, type NodeChangeComposer, type NodeChangeInverter, type NodeChangeRebaser, type NodeChangePruner, type CrossFieldManager, CrossFieldTarget, FlexFieldKind, type FullSchemaPolicy, allowsRepoSuperset, type GenericChangeset, genericFieldKind, type HasFieldChanges, type NodeExistsConstraint, FieldKindWithEditor, ModularChangeFamily, type RelevantRemovedRootsFromChild, EncodedModularChangeset, updateRefreshers, type NodeId, type FieldChangeEncodingContext, type FieldKindConfiguration, type FieldKindConfigurationEntry, getAllowedContentDiscrepancies, isRepoSuperset, isNeverTree, } from "./modular-schema/index.js";
|
|
15
|
+
export { isNeverField, ModularEditBuilder, type FieldEditDescription as EditDescription, type FieldChangeHandler, type FieldChangeRebaser, type FieldEditor, type FieldChangeMap, type FieldChange, type FieldChangeset, type ToDelta, type ModularChangeset, makeModularChangeCodecFamily, type NodeChangeComposer, type NodeChangeInverter, type NodeChangeRebaser, type NodeChangePruner, type CrossFieldManager, CrossFieldTarget, FlexFieldKind, type FullSchemaPolicy, allowsRepoSuperset, type GenericChangeset, genericFieldKind, type HasFieldChanges, type NodeExistsConstraint, FieldKindWithEditor, ModularChangeFamily, type RelevantRemovedRootsFromChild, EncodedModularChangeset, updateRefreshers, type NodeId, type FieldChangeEncodingContext, type FieldKindConfiguration, type FieldKindConfigurationEntry, getAllowedContentDiscrepancies, isRepoSuperset, type AllowedTypeDiscrepancy, type FieldKindDiscrepancy, type ValueSchemaDiscrepancy, type FieldDiscrepancy, type NodeDiscrepancy, type NodeKindDiscrepancy, type NodeFieldsDiscrepancy, isNeverTree, type LinearExtension, type Realizer, fieldRealizer, PosetComparisonResult, comparePosetElements, posetLte, } from "./modular-schema/index.js";
|
|
17
16
|
export { mapRootChanges } from "./deltaUtils.js";
|
|
18
17
|
export { type TreeChunk, chunkTree, chunkFieldSingle, buildChunkedForest, defaultChunkPolicy, type FieldBatch, type FieldBatchCodec, makeTreeChunker, makeFieldBatchCodec, type FieldBatchEncodingContext, } from "./chunked-forest/index.js";
|
|
19
18
|
export { compareLocalNodeKeys, createNodeKeyManager, isStableNodeKey, type LocalNodeKey, MockNodeKeyManager, type NodeKeyManager, nodeKeyTreeIdentifier, type StableNodeKey, } from "./node-key/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,QAAQ,EACb,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","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cAAc,EACd,eAAe,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,IAAI,EACJ,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,cAAc,EACd,UAAU,EACV,OAAO,EACP,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,cAAc,EACd,WAAW,EAEX,cAAc,EACd,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EACN,KAAK,YAAY,EACjB,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EACN,KAAK,SAAS,EACd,eAAe,EACf,UAAU,EACV,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC"}
|
|
@@ -6,7 +6,6 @@ export { toDownPath, } from "./editableTreeBinder.js";
|
|
|
6
6
|
export { allowsValue, assertAllowedValue, isTreeValue } from "./valueUtilities.js";
|
|
7
7
|
export { ForestSummarizer } from "./forest-summary/index.js";
|
|
8
8
|
export { cursorForMapTreeField, cursorForMapTreeNode, mapTreeFromCursor, mapTreeFieldFromCursor, } from "./mapTreeCursor.js";
|
|
9
|
-
export { MemoizedIdRangeAllocator } from "./memoizedIdRangeAllocator.js";
|
|
10
9
|
export { buildForest } from "./object-forest/index.js";
|
|
11
10
|
export { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from "./schema-index/index.js";
|
|
12
11
|
export { stackTreeNodeCursor, prefixPath, prefixFieldPath, stackTreeFieldCursor, } from "./treeCursorUtils.js";
|
|
@@ -14,7 +13,7 @@ export { cursorForJsonableTreeNode, cursorForJsonableTreeField, jsonableTreeFrom
|
|
|
14
13
|
// Split this up into separate import and export for compatibility with API-Extractor.
|
|
15
14
|
import * as SequenceField from "./sequence-field/index.js";
|
|
16
15
|
export { SequenceField };
|
|
17
|
-
export { isNeverField, ModularEditBuilder, makeModularChangeCodecFamily, CrossFieldTarget, FlexFieldKind, allowsRepoSuperset, genericFieldKind, FieldKindWithEditor, ModularChangeFamily, EncodedModularChangeset, updateRefreshers, getAllowedContentDiscrepancies, isRepoSuperset, isNeverTree, } from "./modular-schema/index.js";
|
|
16
|
+
export { isNeverField, ModularEditBuilder, makeModularChangeCodecFamily, CrossFieldTarget, FlexFieldKind, allowsRepoSuperset, genericFieldKind, FieldKindWithEditor, ModularChangeFamily, EncodedModularChangeset, updateRefreshers, getAllowedContentDiscrepancies, isRepoSuperset, isNeverTree, fieldRealizer, PosetComparisonResult, comparePosetElements, posetLte, } from "./modular-schema/index.js";
|
|
18
17
|
export { mapRootChanges } from "./deltaUtils.js";
|
|
19
18
|
export { chunkTree, chunkFieldSingle, buildChunkedForest, defaultChunkPolicy, makeTreeChunker, makeFieldBatchCodec, } from "./chunked-forest/index.js";
|
|
20
19
|
export { compareLocalNodeKeys, createNodeKeyManager, isStableNodeKey, MockNodeKeyManager, nodeKeyTreeIdentifier, } from "./node-key/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE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ACb,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,GACR,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAEN,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAGlB,eAAe,EACf,mBAAmB,GAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAEf,kBAAkB,EAElB,qBAAqB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,UAAU,EAOV,mBAAmB,EACnB,kBAAkB,EAKlB,mBAAmB,EACnB,UAAU,EACV,uBAAuB,EACvB,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,eAAe,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIN,IAAI,EAOJ,cAAc,EACd,UAAU,EACV,OAAO,EAGP,cAAc,EACd,WAAW;AACX,WAAW;AACX,cAAc,EACd,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAEN,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAEN,eAAe,EACf,UAAU,GAIV,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec } from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\ttype AllowedTypeDiscrepancy,\n\ttype FieldKindDiscrepancy,\n\ttype ValueSchemaDiscrepancy,\n\ttype FieldDiscrepancy,\n\ttype NodeDiscrepancy,\n\ttype NodeKindDiscrepancy,\n\ttype NodeFieldsDiscrepancy,\n\tisNeverTree,\n\ttype LinearExtension,\n\ttype Realizer,\n\tfieldRealizer,\n\tPosetComparisonResult,\n\tcomparePosetElements,\n\tposetLte,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeKeys,\n\tcreateNodeKeyManager,\n\tisStableNodeKey,\n\ttype LocalNodeKey,\n\tMockNodeKeyManager,\n\ttype NodeKeyManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeKey,\n} from \"./node-key/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationErrors,\n\tisNodeInSchema,\n\tisFieldInSchema,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tgetTreeContext,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tisFreedSymbol,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n\nexport {\n\ttype KeyFinder,\n\tAnchorTreeIndex,\n\thasElement,\n\ttype TreeIndex,\n\ttype TreeIndexKey,\n\ttype TreeIndexNodes,\n} from \"./indexing/index.js\";\n"]}
|
|
@@ -31,6 +31,7 @@ export declare class AnchorTreeIndex<TKey extends TreeIndexKey, TValue> implemen
|
|
|
31
31
|
private readonly indexer;
|
|
32
32
|
private readonly getValue;
|
|
33
33
|
private readonly checkTreeStatus;
|
|
34
|
+
private readonly isShallowIndex;
|
|
34
35
|
disposed: boolean;
|
|
35
36
|
/**
|
|
36
37
|
* Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not
|
|
@@ -61,8 +62,10 @@ export declare class AnchorTreeIndex<TKey extends TreeIndexKey, TValue> implemen
|
|
|
61
62
|
* @param getValue - a pure and functional function that returns the associated value of one or more anchor nodes, can be used to map and filter the indexed anchor nodes
|
|
62
63
|
* so that the values returned from the index are more usable
|
|
63
64
|
* @param checkTreeStatus - a function that gets the tree status from an anchor node, used for filtering out detached nodes
|
|
65
|
+
* @param isShallowIndex - indicates if this index is shallow, meaning that it only allows nodes to be keyed off of fields directly under them rather than anywhere in their subtree.
|
|
66
|
+
* As a performance optimization, re-indexing up the spine can be turned off for shallow indexes.
|
|
64
67
|
*/
|
|
65
|
-
constructor(forest: IForestSubscription, indexer: (schemaId: TreeNodeSchemaIdentifier) => KeyFinder<TKey> | undefined, getValue: (anchorNodes: TreeIndexNodes<AnchorNode>) => TValue | undefined, checkTreeStatus: (node: AnchorNode) => TreeStatus | undefined);
|
|
68
|
+
constructor(forest: IForestSubscription, indexer: (schemaId: TreeNodeSchemaIdentifier) => KeyFinder<TKey> | undefined, getValue: (anchorNodes: TreeIndexNodes<AnchorNode>) => TValue | undefined, checkTreeStatus: (node: AnchorNode) => TreeStatus | undefined, isShallowIndex?: boolean);
|
|
66
69
|
/**
|
|
67
70
|
* Creates an announced visitor that responds to edits to the forest and updates the index accordingly.
|
|
68
71
|
*/
|
|
@@ -106,6 +109,10 @@ export declare class AnchorTreeIndex<TKey extends TreeIndexKey, TValue> implemen
|
|
|
106
109
|
* Disposes this index and all the anchors it holds onto.
|
|
107
110
|
*/
|
|
108
111
|
[disposeSymbol](): void;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if the spine needs to be re-indexed and if so, re-indexes it starting from the given path.
|
|
114
|
+
*/
|
|
115
|
+
private reIndexSpine;
|
|
109
116
|
private checkNotDisposed;
|
|
110
117
|
/**
|
|
111
118
|
* Given a cursor in node mode, indexes it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorTreeIndex.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/anchorTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAEN,KAAK,UAAU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;IAK5D;;OAEG;IACI,OAAO,CACb,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,EAClF,OAAO,CAAC,EAAE,OAAO,GACf,IAAI;IAUP;;;OAGG;IACK,UAAU,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAU/C,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,CAAC,aAAa,CAAC,IAAI,IAAI;IAa9B;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,SAAS;IA6CjB;;OAEG;IACH,OAAO,CAAC,UAAU;IAUlB;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,YAAY;IAqBpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAUxB;AAgBD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,CAE7E"}
|
|
@@ -21,12 +21,15 @@ export class AnchorTreeIndex {
|
|
|
21
21
|
* @param getValue - a pure and functional function that returns the associated value of one or more anchor nodes, can be used to map and filter the indexed anchor nodes
|
|
22
22
|
* so that the values returned from the index are more usable
|
|
23
23
|
* @param checkTreeStatus - a function that gets the tree status from an anchor node, used for filtering out detached nodes
|
|
24
|
+
* @param isShallowIndex - indicates if this index is shallow, meaning that it only allows nodes to be keyed off of fields directly under them rather than anywhere in their subtree.
|
|
25
|
+
* As a performance optimization, re-indexing up the spine can be turned off for shallow indexes.
|
|
24
26
|
*/
|
|
25
|
-
constructor(forest, indexer, getValue, checkTreeStatus) {
|
|
27
|
+
constructor(forest, indexer, getValue, checkTreeStatus, isShallowIndex = false) {
|
|
26
28
|
this.forest = forest;
|
|
27
29
|
this.indexer = indexer;
|
|
28
30
|
this.getValue = getValue;
|
|
29
31
|
this.checkTreeStatus = checkTreeStatus;
|
|
32
|
+
this.isShallowIndex = isShallowIndex;
|
|
30
33
|
this.disposed = false;
|
|
31
34
|
/**
|
|
32
35
|
* Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not
|
|
@@ -80,6 +83,14 @@ export class AnchorTreeIndex {
|
|
|
80
83
|
this.indexField(detachedCursor);
|
|
81
84
|
detachedCursor.free();
|
|
82
85
|
},
|
|
86
|
+
afterAttach: () => {
|
|
87
|
+
assert(parent !== undefined, 0xa99 /* must have a parent */);
|
|
88
|
+
this.reIndexSpine(parent);
|
|
89
|
+
},
|
|
90
|
+
afterDetach: () => {
|
|
91
|
+
assert(parent !== undefined, 0xa9a /* must have a parent */);
|
|
92
|
+
this.reIndexSpine(parent);
|
|
93
|
+
},
|
|
83
94
|
// when a replace happens, the keys of previously indexed nodes could be changed so we must re-index them
|
|
84
95
|
afterReplace: () => {
|
|
85
96
|
assert(parent !== undefined, 0xa8b /* must have a parent */);
|
|
@@ -87,9 +98,12 @@ export class AnchorTreeIndex {
|
|
|
87
98
|
this.forest.moveCursorToPath(parent, cursor);
|
|
88
99
|
assert(cursor.mode === 0 /* CursorLocationType.Nodes */, 0xa8c /* replace should happen in a node */);
|
|
89
100
|
cursor.exitNode();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
this.indexField(cursor);
|
|
102
|
+
if (!this.isShallowIndex) {
|
|
103
|
+
// we must also re-index the spine if the key finders allow for any value under a subtree to be the key
|
|
104
|
+
// this means that a replace can cause the key for any node up its spine to be changed
|
|
105
|
+
this.indexSpine(cursor);
|
|
106
|
+
}
|
|
93
107
|
cursor.clear();
|
|
94
108
|
},
|
|
95
109
|
// the methods below are used to keep track of the path that has been traversed by the visitor
|
|
@@ -226,6 +240,19 @@ export class AnchorTreeIndex {
|
|
|
226
240
|
this.forest.deregisterAnnouncedVisitor(this.keyFinder);
|
|
227
241
|
this.disposed = true;
|
|
228
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Checks if the spine needs to be re-indexed and if so, re-indexes it starting from the given path.
|
|
245
|
+
*/
|
|
246
|
+
reIndexSpine(path) {
|
|
247
|
+
if (!this.isShallowIndex) {
|
|
248
|
+
const cursor = this.forest.allocateCursor();
|
|
249
|
+
this.forest.moveCursorToPath(path, cursor);
|
|
250
|
+
assert(cursor.mode === 0 /* CursorLocationType.Nodes */, 0xa9b /* attach should happen in a node */);
|
|
251
|
+
cursor.exitNode();
|
|
252
|
+
this.indexSpine(cursor);
|
|
253
|
+
cursor.clear();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
229
256
|
checkNotDisposed(errorMessage) {
|
|
230
257
|
if (this.disposed) {
|
|
231
258
|
if (errorMessage !== undefined) {
|
|
@@ -291,7 +318,6 @@ export class AnchorTreeIndex {
|
|
|
291
318
|
* Given a cursor in field mode, indexes all nodes under the field and then indexes all nodes up the spine.
|
|
292
319
|
*/
|
|
293
320
|
indexSpine(cursor) {
|
|
294
|
-
this.indexField(cursor);
|
|
295
321
|
if (keyAsDetachedField(cursor.getFieldKey()) !== rootField) {
|
|
296
322
|
cursor.exitField();
|
|
297
323
|
cursor.exitNode();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorTreeIndex.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/anchorTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAKN,YAAY,EACZ,WAAW,EAEX,sBAAsB,EAItB,SAAS,EAGT,kBAAkB,EAClB,cAAc,GAEd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAenD;;;;;;;GAOG;AACH,MAAM,OAAO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,EAC/B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,WAAqC;QAC7D,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;YAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACpD,OAAO,UAAU,KAAK,UAAU,CAAC,UAAU,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,KAAK,SAAS,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,SAAS,WAAW,CACnB,WAA8C,EAC9C,MAAqC;IAErC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAI,KAAmB;IAChD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;AAC1B,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\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\tforEachNode,\n\ttype ITreeSubscriptionCursor,\n\tcreateAnnouncedVisitor,\n\ttype IForestSubscription,\n\ttype AnnouncedVisitor,\n\tCursorLocationType,\n\trootField,\n\ttype UpPath,\n\ttype ProtoNodes,\n\tkeyAsDetachedField,\n\tcompareUpPaths,\n\tTreeNavigationResult,\n} from \"../../core/index.js\";\nimport type { TreeIndex, TreeIndexKey, TreeIndexNodes } from \"./types.js\";\nimport { TreeStatus } from \"../flex-tree/index.js\";\n\n/**\n * A function that gets the value to index a node on, must be pure and functional.\n * The given cursor should point to the node that will be indexed.\n *\n * @returns a value the index will use as the key for the given node\n *\n * @remarks\n * This function does not own the cursor in any way, it walks the cursor to find the key the node is indexed on\n * but returns the cursor to the state it was in before being passed to the function. It should also not be disposed by this function\n * and must be disposed elsewhere.\n */\nexport type KeyFinder<TKey extends TreeIndexKey> = (tree: ITreeSubscriptionCursor) => TKey;\n\n/**\n * An index from some arbitrary keys to anchor nodes. Keys can be anything that is a {@link TreeValue}.\n * A key can map to multiple nodes but each collection of nodes only results in a single value.\n *\n * @remarks\n * Detached nodes are stored in the index but filtered out when any public facing apis are called. This means that\n * calling {@link keys} will not include any keys that are stored in the index but only map to detached nodes.\n */\nexport class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>\n\timplements TreeIndex<TKey, TValue>\n{\n\tpublic disposed = false;\n\t/**\n\t * Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not\n\t * need to be considered at all for this index. This allows us to skip subtrees that aren't relevant\n\t * as a performance optimization.\n\t */\n\tprivate readonly keyFinders = new Map<TreeNodeSchemaIdentifier, KeyFinder<TKey> | null>();\n\t/**\n\t * The actual index from keys to anchor nodes.\n\t */\n\tprivate readonly keyToNodes = new Map<TKey, AnchorNode[]>();\n\t/**\n\t * Maintained for efficient removal of anchor nodes from the index when updating their keys\n\t */\n\tprivate readonly nodeToKey = new Map<AnchorNode, TKey>();\n\t/**\n\t * Keeps track of anchors for disposal.\n\t */\n\tprivate readonly anchors = new Map<AnchorNode, Anchor[]>();\n\t/**\n\t * The key finder that is registered on the forest to keep this index updated, maintained\n\t * here for deregistration on disposal\n\t */\n\tprivate readonly keyFinder = this.acquireVisitor.bind(this);\n\n\t/**\n\t * @param forest - the forest that is being indexed\n\t * @param indexer - a function that retrieves the key finder based on a given schema or undefined if the schema does not have an associated key finder\n\t * @param getValue - a pure and functional function that returns the associated value of one or more anchor nodes, can be used to map and filter the indexed anchor nodes\n\t * so that the values returned from the index are more usable\n\t * @param checkTreeStatus - a function that gets the tree status from an anchor node, used for filtering out detached nodes\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IForestSubscription,\n\t\tprivate readonly indexer: (\n\t\t\tschemaId: TreeNodeSchemaIdentifier,\n\t\t) => KeyFinder<TKey> | undefined,\n\t\tprivate readonly getValue: (anchorNodes: TreeIndexNodes<AnchorNode>) => TValue | undefined,\n\t\tprivate readonly checkTreeStatus: (node: AnchorNode) => TreeStatus | undefined,\n\t) {\n\t\tthis.forest.registerAnnouncedVisitor(this.keyFinder);\n\n\t\tconst detachedFieldKeys: FieldKey[] = [];\n\t\tconst detachedFieldsCursor = forest.getCursorAboveDetachedFields();\n\t\tforEachField(detachedFieldsCursor, (field) => {\n\t\t\tdetachedFieldKeys.push(field.getFieldKey());\n\t\t});\n\n\t\t// index all existing trees (this includes the primary document tree and all other detached/removed trees)\n\t\tfor (const fieldKey of detachedFieldKeys) {\n\t\t\tconst cursor = forest.allocateCursor();\n\t\t\tforest.tryMoveCursorToField({ fieldKey, parent: undefined }, cursor);\n\t\t\tthis.indexField(cursor);\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\t/**\n\t * Creates an announced visitor that responds to edits to the forest and updates the index accordingly.\n\t */\n\tprivate acquireVisitor(): AnnouncedVisitor {\n\t\tthis.checkNotDisposed(\n\t\t\t\"visitor getter should be deregistered from the forest when index is disposed\",\n\t\t);\n\t\tlet parentField: FieldKey | undefined;\n\t\tlet parent: UpPath | undefined;\n\n\t\treturn createAnnouncedVisitor({\n\t\t\t// nodes (and their entire subtrees) are added to the index as soon as they are created\n\t\t\tafterCreate: (content: ProtoNodes, destination: FieldKey) => {\n\t\t\t\tconst detachedCursor = this.forest.allocateCursor();\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.tryMoveCursorToField(\n\t\t\t\t\t\t{ fieldKey: destination, parent: undefined },\n\t\t\t\t\t\tdetachedCursor,\n\t\t\t\t\t) === TreeNavigationResult.Ok,\n\t\t\t\t\t0xa8a /* destination of created nodes must be a valid detached field */,\n\t\t\t\t);\n\t\t\t\tthis.indexField(detachedCursor);\n\t\t\t\tdetachedCursor.free();\n\t\t\t},\n\t\t\t// when a replace happens, the keys of previously indexed nodes could be changed so we must re-index them\n\t\t\tafterReplace: () => {\n\t\t\t\tassert(parent !== undefined, 0xa8b /* must have a parent */);\n\t\t\t\tconst cursor = this.forest.allocateCursor();\n\t\t\t\tthis.forest.moveCursorToPath(parent, cursor);\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t\t\t\t0xa8c /* replace should happen in a node */,\n\t\t\t\t);\n\t\t\t\tcursor.exitNode();\n\t\t\t\t// we must re-index the spine because the key finders allow for any value under a subtree to be the key\n\t\t\t\t// this means that a replace can cause the key for any node up its spine to be changed\n\t\t\t\tthis.indexSpine(cursor);\n\t\t\t\tcursor.clear();\n\t\t\t},\n\t\t\t// the methods below are used to keep track of the path that has been traversed by the visitor\n\t\t\t// this is required so that cursors can be moved to the correct location when index updates are required\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(parentField !== undefined, 0xa8d /* must be in a field to enter node */);\n\n\t\t\t\tparent = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(parent !== undefined, 0xa8e /* must have parent node */);\n\t\t\t\tconst temp = parent;\n\t\t\t\tparentField = temp.parentField;\n\t\t\t\tparent = temp.parent;\n\t\t\t},\n\t\t\tenterField: (key: FieldKey) => {\n\t\t\t\tparentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Returns the value associated with the given key if it has been indexed\n\t */\n\tpublic get(key: TKey): TValue | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.getFilteredValue(this.keyToNodes.get(key));\n\t}\n\n\t/**\n\t * Returns true iff the key exists in the index\n\t */\n\tpublic has(key: TKey): boolean {\n\t\tthis.checkNotDisposed();\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Returns the number of values that are indexed\n\t */\n\tpublic get size(): number {\n\t\tthis.checkNotDisposed();\n\t\tlet s = 0;\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\ts += 1;\n\t\t\t}\n\t\t}\n\t\treturn s;\n\t}\n\n\t/**\n\t * Returns all keys in the index\n\t */\n\tpublic *keys(): IterableIterator<TKey> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\tyield key;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of values in the index\n\t */\n\tpublic *values(): IterableIterator<TValue> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield filtered;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index\n\t */\n\tpublic *entries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield [key, filtered];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Applies the provided callback to each entry in the index.\n\t */\n\tpublic forEach(\n\t\tcallbackfn: (value: TValue, key: TKey, map: AnchorTreeIndex<TKey, TValue>) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tcallbackfn.call(thisArg, filtered, key, this);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index, including ones that are detached.\n\t * This function should only be used for testing purposes, it is not exposed as part of the public {@link TreeIndex} API.\n\t */\n\tpublic *allEntries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst value = this.getValue(nodes as unknown as TreeIndexNodes<AnchorNode>);\n\t\t\tif (value !== undefined) {\n\t\t\t\tyield [key, value];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\t/**\n\t * Disposes this index and all the anchors it holds onto.\n\t */\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\"index is already disposed\");\n\t\tfor (const anchors of this.anchors.values()) {\n\t\t\tfor (const anchor of anchors) {\n\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t}\n\t\t}\n\t\tthis.keyToNodes.clear();\n\t\tthis.anchors.clear();\n\t\tthis.forest.deregisterAnnouncedVisitor(this.keyFinder);\n\t\tthis.disposed = true;\n\t}\n\n\tprivate checkNotDisposed(errorMessage?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (errorMessage !== undefined) {\n\t\t\t\tthrow new Error(errorMessage);\n\t\t\t}\n\t\t\tassert(false, 0xa8f /* invalid operation on a disposed index */);\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in node mode, indexes it.\n\t */\n\tprivate indexNode(nodeCursor: ITreeSubscriptionCursor): void {\n\t\tconst keyFinder = getOrCreate(\n\t\t\tthis.keyFinders,\n\t\t\t// the node schema type to look up\n\t\t\tnodeCursor.type,\n\t\t\t// if the indexer does not return a key finder for this schema, we cache a null value to indicate the indexer\n\t\t\t// does not need to be called if this schema is encountered in the future\n\t\t\t(schema) => this.indexer(schema) ?? null,\n\t\t);\n\n\t\tif (keyFinder !== null) {\n\t\t\tconst expectedPath = nodeCursor.getPath();\n\t\t\tconst key = keyFinder(nodeCursor);\n\t\t\t// TODO: determine perf impact of this check, alternative is not doing it in which case (if the key finder is not pure and functional),\n\t\t\t// an error may be thrown further down the line if the structure of the nodes aren't expected or the contents of the index could be inaccurate\n\t\t\tif (!compareUpPaths(nodeCursor.getPath(), expectedPath)) {\n\t\t\t\tthrow new Error(\"key finder should be pure and functional\");\n\t\t\t}\n\t\t\tconst anchor = nodeCursor.buildAnchor();\n\t\t\tconst anchorNode = this.forest.anchors.locate(anchor) ?? fail(\"expected anchor node\");\n\n\t\t\t// check if this anchor node already exists in the index\n\t\t\tconst existingKey = this.nodeToKey.get(anchorNode);\n\t\t\tif (existingKey !== undefined) {\n\t\t\t\t// if the node already exists but has the same key, we return early\n\t\t\t\tif (existingKey === key) {\n\t\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\t// if the node has a different key, we remove the existing one first because it means the key had been detached\n\t\t\t\t\tthis.removeAnchor(anchorNode, existingKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgetOrCreate(this.keyToNodes, key, () => []).push(anchorNode);\n\t\t\tthis.nodeToKey.set(anchorNode, key);\n\n\t\t\tgetOrCreate(this.anchors, anchorNode, () => []).push(anchor);\n\t\t\t// when the anchor node is destroyed, delete it from the index\n\t\t\tanchorNode.events.on(\"afterDestroy\", () => {\n\t\t\t\tthis.removeAnchor(anchorNode, key);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in field mode, recursively indexes all nodes under the field.\n\t */\n\tprivate indexField(fieldCursor: ITreeSubscriptionCursor): void {\n\t\tforEachNode(fieldCursor, (nodeCursor) => {\n\t\t\tthis.indexNode(nodeCursor);\n\n\t\t\tforEachField(nodeCursor, (f) => {\n\t\t\t\tthis.indexField(f);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Given a cursor in field mode, indexes all nodes under the field and then indexes all nodes up the spine.\n\t */\n\tprivate indexSpine(cursor: ITreeSubscriptionCursor): void {\n\t\tthis.indexField(cursor);\n\n\t\tif (keyAsDetachedField(cursor.getFieldKey()) !== rootField) {\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// return early if we're already at the root field\n\t\t\treturn;\n\t\t}\n\n\t\t// walk up the spine and index nodes until we reach the root\n\t\twhile (\n\t\t\tcursor.mode === CursorLocationType.Fields &&\n\t\t\tkeyAsDetachedField(cursor.getFieldKey()) !== rootField\n\t\t) {\n\t\t\tforEachNode(cursor, (nodeCursor) => {\n\t\t\t\tthis.indexNode(nodeCursor);\n\t\t\t});\n\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t}\n\t}\n\n\tprivate removeAnchor(anchorNode: AnchorNode, key: TKey): void {\n\t\tconst indexedNodes = this.keyToNodes.get(key);\n\t\tassert(\n\t\t\tindexedNodes !== undefined,\n\t\t\t0xa90 /* destroyed anchor node should be tracked by index */,\n\t\t);\n\t\tconst index = indexedNodes.indexOf(anchorNode);\n\t\tassert(index !== -1, 0xa91 /* destroyed anchor node should be tracked by index */);\n\t\tconst newNodes = filterNodes(indexedNodes, (n) => n !== anchorNode);\n\t\tif (newNodes !== undefined && newNodes.length > 0) {\n\t\t\tthis.keyToNodes.set(key, newNodes);\n\t\t} else {\n\t\t\tthis.keyToNodes.delete(key);\n\t\t}\n\t\tthis.nodeToKey.delete(anchorNode);\n\t\tassert(\n\t\t\tthis.anchors.delete(anchorNode),\n\t\t\t0xa92 /* destroyed anchor should be tracked by index */,\n\t\t);\n\t}\n\n\t/**\n\t * Filters out any anchor nodes that are detached and returns the value for the remaining nodes.\n\t */\n\tprivate getFilteredValue(anchorNodes: AnchorNode[] | undefined): TValue | undefined {\n\t\tconst attachedNodes = filterNodes(anchorNodes, (anchorNode) => {\n\t\t\tconst nodeStatus = this.checkTreeStatus(anchorNode);\n\t\t\treturn nodeStatus === TreeStatus.InDocument;\n\t\t});\n\n\t\tif (attachedNodes !== undefined && hasElement(attachedNodes)) {\n\t\t\treturn this.getValue(attachedNodes);\n\t\t}\n\t}\n}\n\n/**\n * Filters the given anchor nodes based on the given filter function.\n */\nfunction filterNodes(\n\tanchorNodes: readonly AnchorNode[] | undefined,\n\tfilter: (node: AnchorNode) => boolean,\n): AnchorNode[] | undefined {\n\tif (anchorNodes !== undefined) {\n\t\treturn anchorNodes.filter(filter);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks that an array is of the type {@link TreeIndexNodes} and has at least one element.\n */\nexport function hasElement<T>(array: readonly T[]): array is TreeIndexNodes<T> {\n\treturn array.length >= 1;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"anchorTreeIndex.js","sourceRoot":"","sources":["../../../src/feature-libraries/indexing/anchorTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAKN,YAAY,EACZ,WAAW,EAEX,sBAAsB,EAItB,SAAS,EAGT,kBAAkB,EAClB,cAAc,GAEd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAenD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IA4B3B;;;;;;;;OAQG;IACH,YACkB,MAA2B,EAC3B,OAEe,EACf,QAAyE,EACzE,eAA6D,EAC7D,iBAAiB,KAAK;QANtB,WAAM,GAAN,MAAM,CAAqB;QAC3B,YAAO,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ACH,SAAS,WAAW,CACnB,WAA8C,EAC9C,MAAqC;IAErC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAI,KAAmB;IAChD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;AAC1B,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\";\nimport { disposeSymbol, fail, getOrCreate } from \"../../util/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\tforEachNode,\n\ttype ITreeSubscriptionCursor,\n\tcreateAnnouncedVisitor,\n\ttype IForestSubscription,\n\ttype AnnouncedVisitor,\n\tCursorLocationType,\n\trootField,\n\ttype UpPath,\n\ttype ProtoNodes,\n\tkeyAsDetachedField,\n\tcompareUpPaths,\n\tTreeNavigationResult,\n} from \"../../core/index.js\";\nimport type { TreeIndex, TreeIndexKey, TreeIndexNodes } from \"./types.js\";\nimport { TreeStatus } from \"../flex-tree/index.js\";\n\n/**\n * A function that gets the value to index a node on, must be pure and functional.\n * The given cursor should point to the node that will be indexed.\n *\n * @returns a value the index will use as the key for the given node\n *\n * @remarks\n * This function does not own the cursor in any way, it walks the cursor to find the key the node is indexed on\n * but returns the cursor to the state it was in before being passed to the function. It should also not be disposed by this function\n * and must be disposed elsewhere.\n */\nexport type KeyFinder<TKey extends TreeIndexKey> = (tree: ITreeSubscriptionCursor) => TKey;\n\n/**\n * An index from some arbitrary keys to anchor nodes. Keys can be anything that is a {@link TreeValue}.\n * A key can map to multiple nodes but each collection of nodes only results in a single value.\n *\n * @remarks\n * Detached nodes are stored in the index but filtered out when any public facing apis are called. This means that\n * calling {@link keys} will not include any keys that are stored in the index but only map to detached nodes.\n */\nexport class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>\n\timplements TreeIndex<TKey, TValue>\n{\n\tpublic disposed = false;\n\t/**\n\t * Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not\n\t * need to be considered at all for this index. This allows us to skip subtrees that aren't relevant\n\t * as a performance optimization.\n\t */\n\tprivate readonly keyFinders = new Map<TreeNodeSchemaIdentifier, KeyFinder<TKey> | null>();\n\t/**\n\t * The actual index from keys to anchor nodes.\n\t */\n\tprivate readonly keyToNodes = new Map<TKey, AnchorNode[]>();\n\t/**\n\t * Maintained for efficient removal of anchor nodes from the index when updating their keys\n\t */\n\tprivate readonly nodeToKey = new Map<AnchorNode, TKey>();\n\t/**\n\t * Keeps track of anchors for disposal.\n\t */\n\tprivate readonly anchors = new Map<AnchorNode, Anchor[]>();\n\t/**\n\t * The key finder that is registered on the forest to keep this index updated, maintained\n\t * here for deregistration on disposal\n\t */\n\tprivate readonly keyFinder = this.acquireVisitor.bind(this);\n\n\t/**\n\t * @param forest - the forest that is being indexed\n\t * @param indexer - a function that retrieves the key finder based on a given schema or undefined if the schema does not have an associated key finder\n\t * @param getValue - a pure and functional function that returns the associated value of one or more anchor nodes, can be used to map and filter the indexed anchor nodes\n\t * so that the values returned from the index are more usable\n\t * @param checkTreeStatus - a function that gets the tree status from an anchor node, used for filtering out detached nodes\n\t * @param isShallowIndex - indicates if this index is shallow, meaning that it only allows nodes to be keyed off of fields directly under them rather than anywhere in their subtree.\n\t * As a performance optimization, re-indexing up the spine can be turned off for shallow indexes.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IForestSubscription,\n\t\tprivate readonly indexer: (\n\t\t\tschemaId: TreeNodeSchemaIdentifier,\n\t\t) => KeyFinder<TKey> | undefined,\n\t\tprivate readonly getValue: (anchorNodes: TreeIndexNodes<AnchorNode>) => TValue | undefined,\n\t\tprivate readonly checkTreeStatus: (node: AnchorNode) => TreeStatus | undefined,\n\t\tprivate readonly isShallowIndex = false,\n\t) {\n\t\tthis.forest.registerAnnouncedVisitor(this.keyFinder);\n\n\t\tconst detachedFieldKeys: FieldKey[] = [];\n\t\tconst detachedFieldsCursor = forest.getCursorAboveDetachedFields();\n\t\tforEachField(detachedFieldsCursor, (field) => {\n\t\t\tdetachedFieldKeys.push(field.getFieldKey());\n\t\t});\n\n\t\t// index all existing trees (this includes the primary document tree and all other detached/removed trees)\n\t\tfor (const fieldKey of detachedFieldKeys) {\n\t\t\tconst cursor = forest.allocateCursor();\n\t\t\tforest.tryMoveCursorToField({ fieldKey, parent: undefined }, cursor);\n\t\t\tthis.indexField(cursor);\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\t/**\n\t * Creates an announced visitor that responds to edits to the forest and updates the index accordingly.\n\t */\n\tprivate acquireVisitor(): AnnouncedVisitor {\n\t\tthis.checkNotDisposed(\n\t\t\t\"visitor getter should be deregistered from the forest when index is disposed\",\n\t\t);\n\t\tlet parentField: FieldKey | undefined;\n\t\tlet parent: UpPath | undefined;\n\n\t\treturn createAnnouncedVisitor({\n\t\t\t// nodes (and their entire subtrees) are added to the index as soon as they are created\n\t\t\tafterCreate: (content: ProtoNodes, destination: FieldKey) => {\n\t\t\t\tconst detachedCursor = this.forest.allocateCursor();\n\t\t\t\tassert(\n\t\t\t\t\tthis.forest.tryMoveCursorToField(\n\t\t\t\t\t\t{ fieldKey: destination, parent: undefined },\n\t\t\t\t\t\tdetachedCursor,\n\t\t\t\t\t) === TreeNavigationResult.Ok,\n\t\t\t\t\t0xa8a /* destination of created nodes must be a valid detached field */,\n\t\t\t\t);\n\t\t\t\tthis.indexField(detachedCursor);\n\t\t\t\tdetachedCursor.free();\n\t\t\t},\n\t\t\tafterAttach: () => {\n\t\t\t\tassert(parent !== undefined, 0xa99 /* must have a parent */);\n\t\t\t\tthis.reIndexSpine(parent);\n\t\t\t},\n\t\t\tafterDetach: () => {\n\t\t\t\tassert(parent !== undefined, 0xa9a /* must have a parent */);\n\t\t\t\tthis.reIndexSpine(parent);\n\t\t\t},\n\t\t\t// when a replace happens, the keys of previously indexed nodes could be changed so we must re-index them\n\t\t\tafterReplace: () => {\n\t\t\t\tassert(parent !== undefined, 0xa8b /* must have a parent */);\n\t\t\t\tconst cursor = this.forest.allocateCursor();\n\t\t\t\tthis.forest.moveCursorToPath(parent, cursor);\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t\t\t\t0xa8c /* replace should happen in a node */,\n\t\t\t\t);\n\t\t\t\tcursor.exitNode();\n\t\t\t\tthis.indexField(cursor);\n\t\t\t\tif (!this.isShallowIndex) {\n\t\t\t\t\t// we must also re-index the spine if the key finders allow for any value under a subtree to be the key\n\t\t\t\t\t// this means that a replace can cause the key for any node up its spine to be changed\n\t\t\t\t\tthis.indexSpine(cursor);\n\t\t\t\t}\n\t\t\t\tcursor.clear();\n\t\t\t},\n\t\t\t// the methods below are used to keep track of the path that has been traversed by the visitor\n\t\t\t// this is required so that cursors can be moved to the correct location when index updates are required\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(parentField !== undefined, 0xa8d /* must be in a field to enter node */);\n\n\t\t\t\tparent = {\n\t\t\t\t\tparent,\n\t\t\t\t\tparentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(parent !== undefined, 0xa8e /* must have parent node */);\n\t\t\t\tconst temp = parent;\n\t\t\t\tparentField = temp.parentField;\n\t\t\t\tparent = temp.parent;\n\t\t\t},\n\t\t\tenterField: (key: FieldKey) => {\n\t\t\t\tparentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tparentField = undefined;\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Returns the value associated with the given key if it has been indexed\n\t */\n\tpublic get(key: TKey): TValue | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.getFilteredValue(this.keyToNodes.get(key));\n\t}\n\n\t/**\n\t * Returns true iff the key exists in the index\n\t */\n\tpublic has(key: TKey): boolean {\n\t\tthis.checkNotDisposed();\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Returns the number of values that are indexed\n\t */\n\tpublic get size(): number {\n\t\tthis.checkNotDisposed();\n\t\tlet s = 0;\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\ts += 1;\n\t\t\t}\n\t\t}\n\t\treturn s;\n\t}\n\n\t/**\n\t * Returns all keys in the index\n\t */\n\tpublic *keys(): IterableIterator<TKey> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tif (this.getFilteredValue(nodes) !== undefined) {\n\t\t\t\tyield key;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of values in the index\n\t */\n\tpublic *values(): IterableIterator<TValue> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const nodes of this.keyToNodes.values()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield filtered;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index\n\t */\n\tpublic *entries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tyield [key, filtered];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Applies the provided callback to each entry in the index.\n\t */\n\tpublic forEach(\n\t\tcallbackfn: (value: TValue, key: TKey, map: AnchorTreeIndex<TKey, TValue>) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst filtered = this.getFilteredValue(nodes);\n\t\t\tif (filtered !== undefined) {\n\t\t\t\tcallbackfn.call(thisArg, filtered, key, this);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the index, including ones that are detached.\n\t * This function should only be used for testing purposes, it is not exposed as part of the public {@link TreeIndex} API.\n\t */\n\tpublic *allEntries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.checkNotDisposed();\n\t\tfor (const [key, nodes] of this.keyToNodes.entries()) {\n\t\t\tconst value = this.getValue(nodes as unknown as TreeIndexNodes<AnchorNode>);\n\t\t\tif (value !== undefined) {\n\t\t\t\tyield [key, value];\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\t/**\n\t * Disposes this index and all the anchors it holds onto.\n\t */\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\"index is already disposed\");\n\t\tfor (const anchors of this.anchors.values()) {\n\t\t\tfor (const anchor of anchors) {\n\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t}\n\t\t}\n\t\tthis.keyToNodes.clear();\n\t\tthis.anchors.clear();\n\t\tthis.forest.deregisterAnnouncedVisitor(this.keyFinder);\n\t\tthis.disposed = true;\n\t}\n\n\t/**\n\t * Checks if the spine needs to be re-indexed and if so, re-indexes it starting from the given path.\n\t */\n\tprivate reIndexSpine(path: UpPath): void {\n\t\tif (!this.isShallowIndex) {\n\t\t\tconst cursor = this.forest.allocateCursor();\n\t\t\tthis.forest.moveCursorToPath(path, cursor);\n\t\t\tassert(\n\t\t\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t\t\t0xa9b /* attach should happen in a node */,\n\t\t\t);\n\t\t\tcursor.exitNode();\n\t\t\tthis.indexSpine(cursor);\n\t\t\tcursor.clear();\n\t\t}\n\t}\n\n\tprivate checkNotDisposed(errorMessage?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (errorMessage !== undefined) {\n\t\t\t\tthrow new Error(errorMessage);\n\t\t\t}\n\t\t\tassert(false, 0xa8f /* invalid operation on a disposed index */);\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in node mode, indexes it.\n\t */\n\tprivate indexNode(nodeCursor: ITreeSubscriptionCursor): void {\n\t\tconst keyFinder = getOrCreate(\n\t\t\tthis.keyFinders,\n\t\t\t// the node schema type to look up\n\t\t\tnodeCursor.type,\n\t\t\t// if the indexer does not return a key finder for this schema, we cache a null value to indicate the indexer\n\t\t\t// does not need to be called if this schema is encountered in the future\n\t\t\t(schema) => this.indexer(schema) ?? null,\n\t\t);\n\n\t\tif (keyFinder !== null) {\n\t\t\tconst expectedPath = nodeCursor.getPath();\n\t\t\tconst key = keyFinder(nodeCursor);\n\t\t\t// TODO: determine perf impact of this check, alternative is not doing it in which case (if the key finder is not pure and functional),\n\t\t\t// an error may be thrown further down the line if the structure of the nodes aren't expected or the contents of the index could be inaccurate\n\t\t\tif (!compareUpPaths(nodeCursor.getPath(), expectedPath)) {\n\t\t\t\tthrow new Error(\"key finder should be pure and functional\");\n\t\t\t}\n\t\t\tconst anchor = nodeCursor.buildAnchor();\n\t\t\tconst anchorNode = this.forest.anchors.locate(anchor) ?? fail(\"expected anchor node\");\n\n\t\t\t// check if this anchor node already exists in the index\n\t\t\tconst existingKey = this.nodeToKey.get(anchorNode);\n\t\t\tif (existingKey !== undefined) {\n\t\t\t\t// if the node already exists but has the same key, we return early\n\t\t\t\tif (existingKey === key) {\n\t\t\t\t\tthis.forest.forgetAnchor(anchor);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\t// if the node has a different key, we remove the existing one first because it means the key had been detached\n\t\t\t\t\tthis.removeAnchor(anchorNode, existingKey);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgetOrCreate(this.keyToNodes, key, () => []).push(anchorNode);\n\t\t\tthis.nodeToKey.set(anchorNode, key);\n\n\t\t\tgetOrCreate(this.anchors, anchorNode, () => []).push(anchor);\n\t\t\t// when the anchor node is destroyed, delete it from the index\n\t\t\tanchorNode.events.on(\"afterDestroy\", () => {\n\t\t\t\tthis.removeAnchor(anchorNode, key);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Given a cursor in field mode, recursively indexes all nodes under the field.\n\t */\n\tprivate indexField(fieldCursor: ITreeSubscriptionCursor): void {\n\t\tforEachNode(fieldCursor, (nodeCursor) => {\n\t\t\tthis.indexNode(nodeCursor);\n\n\t\t\tforEachField(nodeCursor, (f) => {\n\t\t\t\tthis.indexField(f);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Given a cursor in field mode, indexes all nodes under the field and then indexes all nodes up the spine.\n\t */\n\tprivate indexSpine(cursor: ITreeSubscriptionCursor): void {\n\t\tif (keyAsDetachedField(cursor.getFieldKey()) !== rootField) {\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// return early if we're already at the root field\n\t\t\treturn;\n\t\t}\n\n\t\t// walk up the spine and index nodes until we reach the root\n\t\twhile (\n\t\t\tcursor.mode === CursorLocationType.Fields &&\n\t\t\tkeyAsDetachedField(cursor.getFieldKey()) !== rootField\n\t\t) {\n\t\t\tforEachNode(cursor, (nodeCursor) => {\n\t\t\t\tthis.indexNode(nodeCursor);\n\t\t\t});\n\n\t\t\tcursor.exitField();\n\t\t\tcursor.exitNode();\n\t\t}\n\t}\n\n\tprivate removeAnchor(anchorNode: AnchorNode, key: TKey): void {\n\t\tconst indexedNodes = this.keyToNodes.get(key);\n\t\tassert(\n\t\t\tindexedNodes !== undefined,\n\t\t\t0xa90 /* destroyed anchor node should be tracked by index */,\n\t\t);\n\t\tconst index = indexedNodes.indexOf(anchorNode);\n\t\tassert(index !== -1, 0xa91 /* destroyed anchor node should be tracked by index */);\n\t\tconst newNodes = filterNodes(indexedNodes, (n) => n !== anchorNode);\n\t\tif (newNodes !== undefined && newNodes.length > 0) {\n\t\t\tthis.keyToNodes.set(key, newNodes);\n\t\t} else {\n\t\t\tthis.keyToNodes.delete(key);\n\t\t}\n\t\tthis.nodeToKey.delete(anchorNode);\n\t\tassert(\n\t\t\tthis.anchors.delete(anchorNode),\n\t\t\t0xa92 /* destroyed anchor should be tracked by index */,\n\t\t);\n\t}\n\n\t/**\n\t * Filters out any anchor nodes that are detached and returns the value for the remaining nodes.\n\t */\n\tprivate getFilteredValue(anchorNodes: AnchorNode[] | undefined): TValue | undefined {\n\t\tconst attachedNodes = filterNodes(anchorNodes, (anchorNode) => {\n\t\t\tconst nodeStatus = this.checkTreeStatus(anchorNode);\n\t\t\treturn nodeStatus === TreeStatus.InDocument;\n\t\t});\n\n\t\tif (attachedNodes !== undefined && hasElement(attachedNodes)) {\n\t\t\treturn this.getValue(attachedNodes);\n\t\t}\n\t}\n}\n\n/**\n * Filters the given anchor nodes based on the given filter function.\n */\nfunction filterNodes(\n\tanchorNodes: readonly AnchorNode[] | undefined,\n\tfilter: (node: AnchorNode) => boolean,\n): AnchorNode[] | undefined {\n\tif (anchorNodes !== undefined) {\n\t\treturn anchorNodes.filter(filter);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks that an array is of the type {@link TreeIndexNodes} and has at least one element.\n */\nexport function hasElement<T>(array: readonly T[]): array is TreeIndexNodes<T> {\n\treturn array.length >= 1;\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { ChangesetLocalId, RevisionTag } from "../../core/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { RangeMap, type RangeQueryResult } from "../../util/index.js";
|
|
7
7
|
import type { NodeId } from "./modularChangeTypes.js";
|
|
8
8
|
export type CrossFieldMap<T> = Map<RevisionTag | undefined, RangeMap<T>>;
|
|
9
9
|
export type CrossFieldQuerySet = CrossFieldMap<boolean>;
|