@fluidframework/tree 2.11.0 → 2.12.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 +4 -0
- package/api-report/tree.alpha.api.md +2 -2
- package/api-report/tree.beta.api.md +1 -1
- package/api-report/tree.legacy.alpha.api.md +1 -1
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- 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/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 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +6 -2
- 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/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/index.d.ts +1 -1
- 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/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/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -14
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -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.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +8 -12
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +25 -7
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +104 -15
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +35 -12
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +159 -127
- 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 +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +48 -0
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +5 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/simpleSchema.d.ts +3 -1
- 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/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/tree.d.ts +1 -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/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +0 -15
- 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/objectNode.d.ts +8 -3
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +18 -2
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +4 -0
- 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 +4 -2
- 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 +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -1
- package/dist/util/index.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 +13 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +23 -1
- package/dist/util/utils.js.map +1 -1
- 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/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 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/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/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/index.d.ts +1 -1
- 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/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/index.d.ts +4 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -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.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +10 -14
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +25 -7
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +105 -16
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +35 -12
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +161 -129
- 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 +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +48 -0
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +4 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/simpleSchema.d.ts +3 -1
- 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/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/tree.d.ts +1 -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/index.d.ts +2 -2
- 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 +0 -15
- 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/objectNode.d.ts +8 -3
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +16 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +4 -0
- 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 +4 -2
- 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 +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.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 +13 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +21 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +22 -22
- 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/defaultSchema.ts +1 -0
- package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
- package/src/feature-libraries/index.ts +13 -0
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +34 -5
- package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
- package/src/feature-libraries/modular-schema/index.ts +13 -0
- package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
- package/src/feature-libraries/sequence-field/types.ts +0 -1
- package/src/index.ts +1 -29
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +1 -0
- package/src/shared-tree/schematizeTree.ts +6 -10
- package/src/shared-tree/schematizingTreeView.ts +11 -21
- package/src/shared-tree/sharedTree.ts +173 -41
- package/src/shared-tree/treeCheckout.ts +224 -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 +12 -2
- package/src/simple-tree/api/schemaFactory.ts +62 -1
- package/src/simple-tree/api/simpleSchema.ts +3 -1
- 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 +6 -0
- package/src/simple-tree/api/verboseTree.ts +2 -2
- package/src/simple-tree/api/view.ts +197 -51
- package/src/simple-tree/index.ts +6 -0
- package/src/simple-tree/leafNodeSchema.ts +0 -19
- package/src/simple-tree/objectNode.ts +26 -2
- package/src/simple-tree/objectNodeTypes.ts +5 -0
- package/src/simple-tree/schemaTypes.ts +7 -2
- package/src/simple-tree/toStoredSchema.ts +25 -19
- package/src/util/brand.ts +0 -2
- package/src/util/index.ts +1 -0
- package/src/util/typeCheck.ts +0 -2
- package/src/util/utils.ts +26 -0
- package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/chunk.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
|
@@ -9,7 +9,9 @@ const index_js_1 = require("../../codec/index.js");
|
|
|
9
9
|
const index_js_2 = require("../../util/index.js");
|
|
10
10
|
const format_js_1 = require("./format.js");
|
|
11
11
|
/**
|
|
12
|
-
* Schema for what {@link
|
|
12
|
+
* Schema for what {@link TreeLeafValue} is allowed on a Leaf node.
|
|
13
|
+
* @privateRemarks
|
|
14
|
+
* See also {@link TreeValue}.
|
|
13
15
|
* @internal
|
|
14
16
|
*/
|
|
15
17
|
var ValueSchema;
|
|
@@ -51,13 +53,11 @@ function toTreeNodeSchemaDataFormat(data) {
|
|
|
51
53
|
}
|
|
52
54
|
exports.toTreeNodeSchemaDataFormat = toTreeNodeSchemaDataFormat;
|
|
53
55
|
/**
|
|
54
|
-
* @internal
|
|
55
56
|
*/
|
|
56
57
|
class TreeNodeStoredSchema {
|
|
57
58
|
}
|
|
58
59
|
exports.TreeNodeStoredSchema = TreeNodeStoredSchema;
|
|
59
60
|
/**
|
|
60
|
-
* @internal
|
|
61
61
|
*/
|
|
62
62
|
class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
|
|
63
63
|
/**
|
|
@@ -94,7 +94,6 @@ class ObjectNodeStoredSchema extends TreeNodeStoredSchema {
|
|
|
94
94
|
}
|
|
95
95
|
exports.ObjectNodeStoredSchema = ObjectNodeStoredSchema;
|
|
96
96
|
/**
|
|
97
|
-
* @internal
|
|
98
97
|
*/
|
|
99
98
|
class MapNodeStoredSchema extends TreeNodeStoredSchema {
|
|
100
99
|
/**
|
|
@@ -120,7 +119,6 @@ class MapNodeStoredSchema extends TreeNodeStoredSchema {
|
|
|
120
119
|
}
|
|
121
120
|
exports.MapNodeStoredSchema = MapNodeStoredSchema;
|
|
122
121
|
/**
|
|
123
|
-
* @internal
|
|
124
122
|
*/
|
|
125
123
|
class LeafNodeStoredSchema extends TreeNodeStoredSchema {
|
|
126
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mDAAoE;AACpE,kDAA+E;AAC/E,2CAOqB;AAGrB;;;GAGG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,6CAAI,CAAA;AACL,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AAkFD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,WAAW,CAAC;AAExD;;;GAGG;AACU,QAAA,sBAAsB,GAA0B;IAC5D,4CAA4C;IAC5C,IAAI,EAAE,IAAA,gBAAK,EAAC,oCAA4B,CAAC;IACzC,qFAAqF;IACrF,KAAK,EAAE,IAAI,GAAG,EAAE;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,6BAA6B,GAAG,YAAY,CAAC;AAS1D,SAAS,gCAAgC,CACxC,IAA8B;IAE9B,OAAO,IAAiD,CAAC;AAC1D,CAAC;AAED,SAAgB,0BAA0B,CACzC,IAAoC;IAEpC,OAAO,IAA2C,CAAC;AACpD,CAAC;AAJD,gEAIC;AAED;;GAEG;AACH,MAAsB,oBAAoB;CAezC;AAfD,oDAeC;AAED;;GAEG;AACH,MAAa,sBA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C;IACnD,CAAC,WAAW,CAAC,WAAW,EAAE,gCAAoB,CAAC,WAAW,CAAC;IAC3D,CAAC,WAAW,CAAC,IAAI,EAAE,gCAAoB,CAAC,IAAI,CAAC;CAC7C,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,IAAA,oBAAS,EAAC,iBAAiB,CAAC,CAAC;AAEvD,SAAS,iBAAiB,CAAC,QAAqB;IAC/C,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,8BAA8B,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA8B;IACxD,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,qBAAqB,CAAC,CAAC;AACvE,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAA6B;IAC9D,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iHAAiH;QACjH,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC;AAND,8CAMC;AAED,SAAgB,iBAAiB,CAAC,MAAyB;IAC1D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5B,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAPD,8CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport { type MakeNominal, brand, fail, invertMap } from \"../../util/index.js\";\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./format.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * Schema for what {@link TreeValue} is allowed on a Leaf node.\n * @internal\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n * @internal\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a Field Kind.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n */\nexport interface FieldKindData {\n\treadonly identifier: FieldKindIdentifier;\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n\n\t/**\n\t * If true, new content inserted into the tree should be validated against the stored schema.\n\t */\n\treadonly validateSchema: boolean;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n * @internal\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n * 1. The root default field for documents.\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = \"Forbidden\";\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: brand(forbiddenFieldKindIdentifier),\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\n/**\n * Opaque type erased handle to the encoded representation of the contents of a stored schema.\n * @internal\n */\nexport interface ErasedTreeNodeSchemaDataFormat\n\textends ErasedType<\"TreeNodeSchemaDataFormat\"> {}\n\nfunction toErasedTreeNodeSchemaDataFormat(\n\tdata: TreeNodeSchemaDataFormat,\n): ErasedTreeNodeSchemaDataFormat {\n\treturn data as unknown as ErasedTreeNodeSchemaDataFormat;\n}\n\nexport function toTreeNodeSchemaDataFormat(\n\tdata: ErasedTreeNodeSchemaDataFormat,\n): TreeNodeSchemaDataFormat {\n\treturn data as unknown as TreeNodeSchemaDataFormat;\n}\n\n/**\n * @internal\n */\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * @privateRemarks\n\t * Returns TreeNodeSchemaDataFormat.\n\t * This is uses an opaque type to avoid leaking these types out of the package,\n\t * and is runtime validated by the codec.\n\t */\n\tpublic abstract encode(): ErasedTreeNodeSchemaDataFormat;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\n/**\n * @internal\n */\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields -\n\t * Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(this.objectNodeFields.get(key) ?? fail(\"missing field\")),\n\t\t\t});\n\t\t}\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tobject: fieldsObject,\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n}\n\n/**\n * @internal\n */\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields -\n\t * Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(public readonly mapFields: TreeFieldStoredSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tmap: encodeFieldSchema(this.mapFields),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\n/**\n * @internal\n */\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue -\n\t * There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaDataFormat,\n\t[],\n\tTreeNodeStoredSchema\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => new LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (\n\t\tdata: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>,\n\t): TreeNodeStoredSchema => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map);\n\t},\n\tmap: (data: FieldSchemaFormat) => new MapNodeStoredSchema(decodeFieldSchema(data)),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(\"missing PersistedValueSchema\");\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(\"missing ValueSchema\");\n}\n\nexport function encodeFieldSchema(schema: TreeFieldStoredSchema): FieldSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormat): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n * @internal\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n * @internal\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mDAAoE;AACpE,kDAA+E;AAC/E,2CAOqB;AAGrB;;;;;GAKG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,6CAAI,CAAA;AACL,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA0FD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,WAAW,CAAC;AAExD;;;GAGG;AACU,QAAA,sBAAsB,GAA0B;IAC5D,4CAA4C;IAC5C,IAAI,EAAE,IAAA,gBAAK,EAAC,oCAA4B,CAAC;IACzC,qFAAqF;IACrF,KAAK,EAAE,IAAI,GAAG,EAAE;CAChB,CAAC;AAEF;;GAEG;AACU,QAAA,6BAA6B,GAAG,YAAY,CAAC;AAQ1D,SAAS,gCAAgC,CACxC,IAA8B;IAE9B,OAAO,IAAiD,CAAC;AAC1D,CAAC;AAED,SAAgB,0BAA0B,CACzC,IAAoC;IAEpC,OAAO,IAA2C,CAAC;AACpD,CAAC;AAJD,gEAIC;AAED;GACG;AACH,MAAsB,oBAAoB;CAezC;AAfD,oDAeC;AAED;GACG;AACH,MAAa,sBAAuB,SAAQ,oBAAoB;IAC/D;;;;;;;OAOG;IACH,YACiB,gBAA8D;QAE9E,KAAK,EAAE,CAAC;QAFQ,qBAAgB,GAAhB,gBAAgB,CAA8C;IAG/E,CAAC;IAEe,MAAM;QACrB,M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BAAiB,GAAG,IAAA,oBAAS,EAAC,iBAAiB,CAAC,CAAC;AAEvD,SAAS,iBAAiB,CAAC,QAAqB;IAC/C,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,8BAA8B,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA8B;IACxD,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,qBAAqB,CAAC,CAAC;AACvE,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAA6B;IAC9D,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iHAAiH;QACjH,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC;AAND,8CAMC;AAED,SAAgB,iBAAiB,CAAC,MAAyB;IAC1D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5B,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAPD,8CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport { type MakeNominal, brand, fail, invertMap } from \"../../util/index.js\";\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./format.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.\n * @privateRemarks\n * See also {@link TreeValue}.\n * @internal\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a Field Kind.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n */\nexport interface FieldKindData {\n\treadonly identifier: FieldKindIdentifier;\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n\n\t/**\n\t * If true, new content inserted into the tree should be validated against the stored schema.\n\t */\n\treadonly validateSchema: boolean;\n\n\t/**\n\t * Whether to allow a document to be opened when a particular stored schema (identified by `identifier`)\n\t * contains optional fields that are not known to the view schema.\n\t *\n\t * @privateRemarks\n\t * Plumbing this in via `SchemaPolicy` avoids needing to walk the view schema representation repeatedly in places\n\t * that need it (schema validation, view vs stored compatibility checks).\n\t */\n\tallowUnknownOptionalFields(identifier: TreeNodeSchemaIdentifier): boolean;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n * 1. The root default field for documents.\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = \"Forbidden\";\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: brand(forbiddenFieldKindIdentifier),\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\n/**\n * Opaque type erased handle to the encoded representation of the contents of a stored schema.\n */\nexport interface ErasedTreeNodeSchemaDataFormat\n\textends ErasedType<\"TreeNodeSchemaDataFormat\"> {}\n\nfunction toErasedTreeNodeSchemaDataFormat(\n\tdata: TreeNodeSchemaDataFormat,\n): ErasedTreeNodeSchemaDataFormat {\n\treturn data as unknown as ErasedTreeNodeSchemaDataFormat;\n}\n\nexport function toTreeNodeSchemaDataFormat(\n\tdata: ErasedTreeNodeSchemaDataFormat,\n): TreeNodeSchemaDataFormat {\n\treturn data as unknown as TreeNodeSchemaDataFormat;\n}\n\n/**\n */\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * @privateRemarks\n\t * Returns TreeNodeSchemaDataFormat.\n\t * This is uses an opaque type to avoid leaking these types out of the package,\n\t * and is runtime validated by the codec.\n\t */\n\tpublic abstract encode(): ErasedTreeNodeSchemaDataFormat;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\n/**\n */\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields -\n\t * Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(this.objectNodeFields.get(key) ?? fail(\"missing field\")),\n\t\t\t});\n\t\t}\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tobject: fieldsObject,\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n}\n\n/**\n */\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields -\n\t * Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(public readonly mapFields: TreeFieldStoredSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tmap: encodeFieldSchema(this.mapFields),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\n/**\n */\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue -\n\t * There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\tsuper();\n\t}\n\n\tpublic override encode(): ErasedTreeNodeSchemaDataFormat {\n\t\treturn toErasedTreeNodeSchemaDataFormat({\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t});\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaDataFormat,\n\t[],\n\tTreeNodeStoredSchema\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => new LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (\n\t\tdata: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>,\n\t): TreeNodeStoredSchema => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map);\n\t},\n\tmap: (data: FieldSchemaFormat) => new MapNodeStoredSchema(decodeFieldSchema(data)),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(\"missing PersistedValueSchema\");\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(\"missing ValueSchema\");\n}\n\nexport function encodeFieldSchema(schema: TreeFieldStoredSchema): FieldSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormat): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { type Adapters,
|
|
5
|
+
export { type Adapters, type TreeAdapter, AdaptedViewSchema, AllowedUpdateType, } from "./view.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schema-view/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,QAAQ,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schema-view/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,WAAW,CAAC"}
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.AllowedUpdateType = exports.AdaptedViewSchema =
|
|
7
|
+
exports.AllowedUpdateType = exports.AdaptedViewSchema = void 0;
|
|
8
8
|
var view_js_1 = require("./view.js");
|
|
9
|
-
Object.defineProperty(exports, "Compatibility", { enumerable: true, get: function () { return view_js_1.Compatibility; } });
|
|
10
9
|
Object.defineProperty(exports, "AdaptedViewSchema", { enumerable: true, get: function () { return view_js_1.AdaptedViewSchema; } });
|
|
11
10
|
Object.defineProperty(exports, "AllowedUpdateType", { enumerable: true, get: function () { return view_js_1.AllowedUpdateType; } });
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/schema-view/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/schema-view/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAKmB;AAFlB,4GAAA,iBAAiB,OAAA;AACjB,4GAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype Adapters,\n\ttype TreeAdapter,\n\tAdaptedViewSchema,\n\tAllowedUpdateType,\n} from \"./view.js\";\n"]}
|
|
@@ -6,13 +6,6 @@ import type { TreeNodeSchemaIdentifier, TreeStoredSchema } from "../schema-store
|
|
|
6
6
|
/**
|
|
7
7
|
* APIs for applying `view schema` to documents.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* How compatible a particular view schema is for some operation on some specific document.
|
|
11
|
-
*/
|
|
12
|
-
export declare enum Compatibility {
|
|
13
|
-
Incompatible = 0,
|
|
14
|
-
Compatible = 1
|
|
15
|
-
}
|
|
16
9
|
/**
|
|
17
10
|
* What kinds of updates to stored schema to permit.
|
|
18
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/core/schema-view/view.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE5F;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/core/schema-view/view.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE5F;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,iBAAiB;IAC5B;;OAEG;IACH,IAAI,IAAI;IACR;;;;OAIG;IAEH,UAAU,IAAS;IACnB;;;OAGG;IAEH;;;;OAIG;IAEH,gBAAgB,IAAS;CACzB;AAED;GACG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;CAGzC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CACvC;AAED;;GAEG;AACH,qBAAa,iBAAiB;aAEZ,QAAQ,EAAE,QAAQ;aAClB,oBAAoB,EAAE,gBAAgB;gBADtC,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,gBAAgB;CAEvD"}
|
|
@@ -4,21 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.AdaptedViewSchema = exports.AllowedUpdateType =
|
|
7
|
+
exports.AdaptedViewSchema = exports.AllowedUpdateType = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* APIs for applying `view schema` to documents.
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* How compatible a particular view schema is for some operation on some specific document.
|
|
13
|
-
*/
|
|
14
|
-
var Compatibility;
|
|
15
|
-
(function (Compatibility) {
|
|
16
|
-
Compatibility[Compatibility["Incompatible"] = 0] = "Incompatible";
|
|
17
|
-
// For write compatibility this can include compatible schema updates to stored schema.
|
|
18
|
-
// TODO: separate schema updates from adapters.
|
|
19
|
-
// RequiresAdapters,
|
|
20
|
-
Compatibility[Compatibility["Compatible"] = 1] = "Compatible";
|
|
21
|
-
})(Compatibility || (exports.Compatibility = Compatibility = {}));
|
|
22
11
|
/**
|
|
23
12
|
* What kinds of updates to stored schema to permit.
|
|
24
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/schema-view/view.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/schema-view/view.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AAEH;;;;GAIG;AACH,IAAY,iBAwBX;AAxBD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,yDAAQ,CAAA;IACR;;;;OAIG;IACH,sCAAsC;IACtC,qEAAmB,CAAA;IACnB;;;OAGG;IACH,kBAAkB;IAClB;;;;OAIG;IACH,sCAAsC;IACtC,iFAAyB,CAAA;AAC1B,CAAC,EAxBW,iBAAiB,iCAAjB,iBAAiB,QAwB5B;AAsBD;;GAEG;AACH,MAAa,iBAAiB;IAC7B,YACiB,QAAkB,EAClB,oBAAsC;QADtC,aAAQ,GAAR,QAAQ,CAAU;QAClB,yBAAoB,GAApB,oBAAoB,CAAkB;IACpD,CAAC;CACJ;AALD,8CAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNodeSchemaIdentifier, TreeStoredSchema } from \"../schema-stored/index.js\";\n\n/**\n * APIs for applying `view schema` to documents.\n */\n\n/**\n * What kinds of updates to stored schema to permit.\n *\n * Bit flags enum.\n */\nexport enum AllowedUpdateType {\n\t/**\n\t * Do not update the stored schema to match view schema.\n\t */\n\tNone = 0,\n\t/**\n\t * Update the stored schema as part of initializing an empty document.\n\t *\n\t * Includes \"Initialize\".\n\t */\n\t// eslint-disable-next-line no-bitwise\n\tInitialize = 1 << 0,\n\t/**\n\t * Update the stored schema to match the view schema if the current document contents are compatible with the view schema.\n\t * TODO: support this option.\n\t */\n\t// DataCompatible,\n\t/**\n\t * Update the stored schema to match view schema if all possible documents based on the current stored schema would be compatible with the view schema.\n\t *\n\t * Includes \"Initialize\".\n\t */\n\t// eslint-disable-next-line no-bitwise\n\tSchemaCompatible = 1 << 1,\n}\n\n/**\n */\nexport interface TreeAdapter {\n\treadonly output: TreeNodeSchemaIdentifier;\n\treadonly input: TreeNodeSchemaIdentifier;\n\n\t// TODO: include actual adapter functionality, not just what types it converts\n}\n\n/**\n * Minimal selection of adapters (nothing for general out of schema, field level adjustments etc.).\n * Would be used with schematize and have actual conversion/update functionality.\n *\n * TODO: Support more kinds of adapters\n * TODO: support efficient lookup of adapters\n */\nexport interface Adapters {\n\treadonly tree?: readonly TreeAdapter[];\n}\n\n/**\n * A collection of View information for schema, including policy.\n */\nexport class AdaptedViewSchema {\n\tpublic constructor(\n\t\tpublic readonly adapters: Adapters,\n\t\tpublic readonly adaptedForViewSchema: TreeStoredSchema,\n\t) {}\n}\n"]}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type FieldKey, type ITreeCursor, type ITreeCursorSynchronous } from "../../core/index.js";
|
|
6
5
|
import type { ReferenceCounted } from "../../util/index.js";
|
|
6
|
+
import type { FieldKey } from "../schema-stored/index.js";
|
|
7
|
+
import { type ITreeCursor, type ITreeCursorSynchronous } from "./cursor.js";
|
|
7
8
|
/**
|
|
8
9
|
* Contiguous part of the tree which get stored together in some data format.
|
|
9
10
|
* Copy-on-write, but optimized to be mutated in place when a chunk only has a single user (detected using reference counting).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/core/tree/chunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAClD;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,MAAM,IAAI,aAAa,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,QAAuB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,MAA8B,CAAC;AAEhE;;GAEG;AACH,UAAU,SAAS;IAClB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAMtE;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,sBAAsB,EAAE,SAAS;IACvE;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,aAAa,CAAC;CACtB"}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.tryGetChunk = exports.cursorChunk = exports.dummyRoot = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const
|
|
9
|
+
const types_js_1 = require("./types.js");
|
|
10
10
|
/**
|
|
11
11
|
* The key used for the field that contains the root of chunks when not parented anywhere.
|
|
12
12
|
*
|
|
13
13
|
* For now this is using the document root key to ease testing/compatibility, but this may change.
|
|
14
14
|
*/
|
|
15
|
-
exports.dummyRoot =
|
|
15
|
+
exports.dummyRoot = types_js_1.rootFieldKey;
|
|
16
16
|
/**
|
|
17
17
|
* A symbol for extracting a TreeChunk from {@link ITreeCursor}.
|
|
18
18
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/core/tree/chunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,yCAA0C;AAkC1C;;;;GAIG;AACU,QAAA,SAAS,GAAa,uBAAY,CAAC;AAEhD;;GAEG;AACU,QAAA,WAAW,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC;AA2BhE;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAmB;IAC9C,IAAA,iBAAM,EACL,MAAM,CAAC,IAAI,qCAA6B,EACxC,KAAK,CAAC,+CAA+C,CACrD,CAAC;IACF,OAAQ,MAAoB,CAAC,mBAAW,CAAC,CAAC;AAC3C,CAAC;AAND,kCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ReferenceCounted } from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\nimport { rootFieldKey } from \"./types.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n} from \"./cursor.js\";\n\n/**\n * Contiguous part of the tree which get stored together in some data format.\n * Copy-on-write, but optimized to be mutated in place when a chunk only has a single user (detected using reference counting).\n * This allows for efficient cloning without major performance overheads for non-cloning scenarios.\n */\nexport interface TreeChunk extends ReferenceCounted {\n\t/**\n\t * The number of nodes at the top level of this chunk.\n\t *\n\t * If this chunk is included in a field, this is the amount this chunk contributes to the length of the field.\n\t */\n\treadonly topLevelLength: number;\n\n\t/**\n\t * Creates a cursor for navigating the content of this chunk.\n\t *\n\t * Starts in \"fields\" mode in a `dummyRoot` field containing the top level nodes.\n\t *\n\t * This cursor does not own a reference to the data:\n\t * it is up to the caller of this function to ensure the cursor is not used after they release their owning ref to this chunk.\n\t *\n\t * TODO: consider starting this in \"fields\" mode above the top level\n\t * which would compose better with utilities for processing sequences of nodes.\n\t */\n\tcursor(): ChunkedCursor;\n}\n\n/**\n * The key used for the field that contains the root of chunks when not parented anywhere.\n *\n * For now this is using the document root key to ease testing/compatibility, but this may change.\n */\nexport const dummyRoot: FieldKey = rootFieldKey;\n\n/**\n * A symbol for extracting a TreeChunk from {@link ITreeCursor}.\n */\nexport const cursorChunk: unique symbol = Symbol(\"cursorChunk\");\n\n/**\n * Cursors can optionally implement this interface, allowing querying them for the chunk they are traversing.\n */\ninterface WithChunk {\n\t/**\n\t * When in nodes mode, if a value is returned, it is a TreeChunk who's top level nodes are the\n\t * chunkLength nodes starting from chunkStart.\n\t *\n\t *\n\t * @remarks\n\t * Note that there may be other tree representations with different chunk APIs and thus different ways to query them.\n\t * The chunkStart and chunkLength values thus to not uniquely apply to the chunks accessed through this field.\n\t *\n\t * TODO:\n\t * This API (including the chunk start and end on ITreeCUrsor) have some issues:\n\t * 1. There are cases where multiple possible chunks could be considered.\n\t * For example, when in a SequenceChunk, it could be returned, or the chunk within it could be.\n\t * 2. When in a location other than the root of a chunk,\n\t * it can't provide information about the containing chunk other than by allocating a new chunk that just represents that field.\n\t *\n\t * As more optimizations get implemented, this API may need to change to better address these issues.\n\t */\n\treadonly [cursorChunk]?: TreeChunk | undefined;\n}\n\n/**\n * See {@link WithChunk}.\n */\nexport function tryGetChunk(cursor: ITreeCursor): undefined | TreeChunk {\n\tassert(\n\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t0x57b /* cursorChunk only accessible in nodes mode */,\n\t);\n\treturn (cursor as WithChunk)[cursorChunk];\n}\n\n/**\n * Cursor for a chunk which can be wrapped by another cursor.\n *\n * @remarks See `BasicChunkCursor` which uses this.\n */\nexport interface ChunkedCursor extends ITreeCursorSynchronous, WithChunk {\n\t/**\n\t * Checks if the cursor is in the top level nodes of the chunk.\n\t *\n\t * @returns true iff cursor is within the root field, including at a node within that field.\n\t */\n\tatChunkRoot(): boolean;\n\n\t/**\n\t * Clones the cursor to produce a new independent cursor.\n\t * Does not add any counted references to any chunks.\n\t */\n\tfork(): ChunkedCursor;\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export { type AnnouncedVisitor, announceDelta, applyDelta, createAnnouncedVisito
|
|
|
15
15
|
export type { PathVisitor } from "./visitPath.js";
|
|
16
16
|
export { SparseNode, getDescendant } from "./sparseTree.js";
|
|
17
17
|
export { deltaForRootInitialization, emptyFieldChanges, isEmptyFieldChanges, makeDetachedNodeId, offsetDetachId, emptyDelta, } from "./deltaUtil.js";
|
|
18
|
+
export { type TreeChunk, dummyRoot, cursorChunk, tryGetChunk, type ChunkedCursor, } from "./chunk.js";
|
|
18
19
|
export { DetachedFieldIndex } from "./detachedFieldIndex.js";
|
|
19
20
|
export { type ForestRootId } from "./detachedFieldIndexTypes.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,SAAS,EACT,KAAK,UAAU,EACf,KAAK,UAAU,EACf,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,GACR,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,UAAU,EACV,IAAI,IAAI,SAAS,EACjB,SAAS,IAAI,cAAc,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,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/core/tree/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DetachedFieldIndex = exports.emptyDelta = exports.offsetDetachId = exports.makeDetachedNodeId = exports.isEmptyFieldChanges = exports.emptyFieldChanges = exports.deltaForRootInitialization = exports.getDescendant = exports.SparseNode = exports.makeDetachedFieldIndex = exports.combineVisitors = exports.createAnnouncedVisitor = exports.applyDelta = exports.announceDelta = exports.visitDelta = exports.aboveRootPlaceholder = exports.rootField = exports.rootFieldKey = exports.keyAsDetachedField = exports.detachedFieldAsKey = exports.EmptyKey = exports.EncodedJsonableTree = exports.setGenericTreeField = exports.getGenericTreeField = exports.genericTreeKeys = exports.genericTreeDeleteIfEmpty = exports.getDetachedFieldContainingPath = exports.compareFieldUpPaths = exports.compareUpPaths = exports.getDepth = exports.topDownPath = exports.clonePath = exports.deepCopyMapTree = exports.isCursor = exports.CursorMarker = exports.inCursorNode = exports.inCursorField = exports.iterateCursorField = exports.forEachField = exports.forEachNodeInSubtree = exports.forEachNode = exports.mapCursorFields = exports.mapCursorField = exports.castCursorToSynchronous = exports.CursorLocationType = exports.anchorSlot = exports.AnchorSet = void 0;
|
|
7
|
+
exports.DetachedFieldIndex = exports.tryGetChunk = exports.cursorChunk = exports.dummyRoot = exports.emptyDelta = exports.offsetDetachId = exports.makeDetachedNodeId = exports.isEmptyFieldChanges = exports.emptyFieldChanges = exports.deltaForRootInitialization = exports.getDescendant = exports.SparseNode = exports.makeDetachedFieldIndex = exports.combineVisitors = exports.createAnnouncedVisitor = exports.applyDelta = exports.announceDelta = exports.visitDelta = exports.aboveRootPlaceholder = exports.rootField = exports.rootFieldKey = exports.keyAsDetachedField = exports.detachedFieldAsKey = exports.EmptyKey = exports.EncodedJsonableTree = exports.setGenericTreeField = exports.getGenericTreeField = exports.genericTreeKeys = exports.genericTreeDeleteIfEmpty = exports.getDetachedFieldContainingPath = exports.compareFieldUpPaths = exports.compareUpPaths = exports.getDepth = exports.topDownPath = exports.clonePath = exports.deepCopyMapTree = exports.isCursor = exports.CursorMarker = exports.inCursorNode = exports.inCursorField = exports.iterateCursorField = exports.forEachField = exports.forEachNodeInSubtree = exports.forEachNode = exports.mapCursorFields = exports.mapCursorField = exports.castCursorToSynchronous = exports.CursorLocationType = exports.anchorSlot = exports.AnchorSet = void 0;
|
|
8
8
|
var anchorSet_js_1 = require("./anchorSet.js");
|
|
9
9
|
Object.defineProperty(exports, "AnchorSet", { enumerable: true, get: function () { return anchorSet_js_1.AnchorSet; } });
|
|
10
10
|
Object.defineProperty(exports, "anchorSlot", { enumerable: true, get: function () { return anchorSet_js_1.anchorSlot; } });
|
|
@@ -62,6 +62,10 @@ Object.defineProperty(exports, "isEmptyFieldChanges", { enumerable: true, get: f
|
|
|
62
62
|
Object.defineProperty(exports, "makeDetachedNodeId", { enumerable: true, get: function () { return deltaUtil_js_1.makeDetachedNodeId; } });
|
|
63
63
|
Object.defineProperty(exports, "offsetDetachId", { enumerable: true, get: function () { return deltaUtil_js_1.offsetDetachId; } });
|
|
64
64
|
Object.defineProperty(exports, "emptyDelta", { enumerable: true, get: function () { return deltaUtil_js_1.emptyDelta; } });
|
|
65
|
+
var chunk_js_1 = require("./chunk.js");
|
|
66
|
+
Object.defineProperty(exports, "dummyRoot", { enumerable: true, get: function () { return chunk_js_1.dummyRoot; } });
|
|
67
|
+
Object.defineProperty(exports, "cursorChunk", { enumerable: true, get: function () { return chunk_js_1.cursorChunk; } });
|
|
68
|
+
Object.defineProperty(exports, "tryGetChunk", { enumerable: true, get: function () { return chunk_js_1.tryGetChunk; } });
|
|
65
69
|
var detachedFieldIndex_js_1 = require("./detachedFieldIndex.js");
|
|
66
70
|
Object.defineProperty(exports, "DetachedFieldIndex", { enumerable: true, get: function () { return detachedFieldIndex_js_1.DetachedFieldIndex; } });
|
|
67
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CASwB;AANvB,yGAAA,SAAS,OAAA;AAGT,0GAAA,UAAU,OAAA;AAIX,yCAgBqB;AAdpB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AACvB,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,wGAAA,WAAW,OAAA;AACX,iHAAA,oBAAoB,OAAA;AACpB,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAGlB,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AAeT,2CAAoF;AAAtC,6GAAA,eAAe,OAAA;AAC7D,6CAiBuB;AAhBtB,wGAAA,SAAS,OAAA;AACT,0GAAA,WAAW,OAAA;AACX,uGAAA,QAAQ,OAAA;AAUR,6GAAA,cAAc,OAAA;AACd,kHAAA,mBAAmB,OAAA;AACnB,6HAAA,8BAA8B,OAAA;AAG/B,yDAS6B;AAN5B,6HAAA,wBAAwB,OAAA;AACxB,oHAAA,eAAe,OAAA;AAEf,wHAAA,mBAAmB,OAAA;AAEnB,wHAAA,mBAAmB,OAAA;AAEpB,2EAAmE;AAA1D,iIAAA,mBAAmB,OAAA;AAC5B,uCAeoB;AAdnB,oGAAA,QAAQ,OAAA;AAQR,8GAAA,kBAAkB,OAAA;AAClB,8GAAA,kBAAkB,OAAA;AAClB,wGAAA,YAAY,OAAA;AAEZ,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AAErB,iDAAgE;AAApC,2GAAA,UAAU,OAAA;AACtC,qDAO2B;AAL1B,gHAAA,aAAa,OAAA;AACb,6GAAA,UAAU,OAAA;AACV,yHAAA,sBAAsB,OAAA;AACtB,kHAAA,eAAe,OAAA;AACf,yHAAA,sBAAsB,OAAA;AAIvB,iDAA4D;AAAnD,2GAAA,UAAU,OAAA;AAAE,8GAAA,aAAa,OAAA;AAElC,+CAOwB;AANvB,0HAAA,0BAA0B,OAAA;AAC1B,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AACnB,kHAAA,kBAAkB,OAAA;AAClB,8GAAA,cAAc,OAAA;AACd,0GAAA,UAAU,OAAA;AAGX,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\tAnchorSet,\n\ttype AnchorSlot,\n\ttype AnchorNode,\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorSetRootEvents,\n} from \"./anchorSet.js\";\nexport {\n\ttype ITreeCursor,\n\tCursorLocationType,\n\tcastCursorToSynchronous,\n\tmapCursorField,\n\tmapCursorFields,\n\tforEachNode,\n\tforEachNodeInSubtree,\n\tforEachField,\n\titerateCursorField,\n\ttype ITreeCursorSynchronous,\n\ttype PathRootPrefix,\n\tinCursorField,\n\tinCursorNode,\n\tCursorMarker,\n\tisCursor,\n} from \"./cursor.js\";\nexport type {\n\tProtoNodes,\n\tRoot as DeltaRoot,\n\tProtoNode as DeltaProtoNode,\n\tMark as DeltaMark,\n\tDetachedNodeId as DeltaDetachedNodeId,\n\tFieldMap as DeltaFieldMap,\n\tDetachedNodeChanges as DeltaDetachedNodeChanges,\n\tDetachedNodeBuild as DeltaDetachedNodeBuild,\n\tDetachedNodeDestruction as DeltaDetachedNodeDestruction,\n\tDetachedNodeRename as DeltaDetachedNodeRename,\n\tFieldChanges as DeltaFieldChanges,\n} from \"./delta.js\";\nexport { type MapTree, type ExclusiveMapTree, deepCopyMapTree } from \"./mapTree.js\";\nexport {\n\tclonePath,\n\ttopDownPath,\n\tgetDepth,\n\ttype UpPath,\n\ttype FieldUpPath,\n\ttype Range,\n\ttype RangeUpPath,\n\ttype PlaceUpPath,\n\ttype PlaceIndex,\n\ttype NodeIndex,\n\ttype DetachedPlaceUpPath,\n\ttype DetachedRangeUpPath,\n\tcompareUpPaths,\n\tcompareFieldUpPaths,\n\tgetDetachedFieldContainingPath,\n\ttype UpPathDefault,\n} from \"./pathTree.js\";\nexport {\n\ttype FieldMapObject,\n\ttype GenericFieldsNode,\n\tgenericTreeDeleteIfEmpty,\n\tgenericTreeKeys,\n\ttype GenericTreeNode,\n\tgetGenericTreeField,\n\ttype JsonableTree,\n\tsetGenericTreeField,\n} from \"./treeTextFormat.js\";\nexport { EncodedJsonableTree } from \"./persistedTreeTextFormat.js\";\nexport {\n\tEmptyKey,\n\ttype TreeType,\n\ttype ChildLocation,\n\ttype DetachedField,\n\ttype ChildCollection,\n\ttype RootField,\n\ttype Value,\n\ttype TreeValue,\n\tdetachedFieldAsKey,\n\tkeyAsDetachedField,\n\trootFieldKey,\n\ttype NodeData,\n\trootField,\n\taboveRootPlaceholder,\n} from \"./types.js\";\nexport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nexport {\n\ttype AnnouncedVisitor,\n\tannounceDelta,\n\tapplyDelta,\n\tcreateAnnouncedVisitor,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n} from \"./visitorUtils.js\";\nexport type { PathVisitor } from \"./visitPath.js\";\n\nexport { SparseNode, getDescendant } from \"./sparseTree.js\";\n\nexport {\n\tdeltaForRootInitialization,\n\temptyFieldChanges,\n\tisEmptyFieldChanges,\n\tmakeDetachedNodeId,\n\toffsetDetachId,\n\temptyDelta,\n} from \"./deltaUtil.js\";\n\nexport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nexport { type ForestRootId } from \"./detachedFieldIndexTypes.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CASwB;AANvB,yGAAA,SAAS,OAAA;AAGT,0GAAA,UAAU,OAAA;AAIX,yCAgBqB;AAdpB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AACvB,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,wGAAA,WAAW,OAAA;AACX,iHAAA,oBAAoB,OAAA;AACpB,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAGlB,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AAeT,2CAAoF;AAAtC,6GAAA,eAAe,OAAA;AAC7D,6CAiBuB;AAhBtB,wGAAA,SAAS,OAAA;AACT,0GAAA,WAAW,OAAA;AACX,uGAAA,QAAQ,OAAA;AAUR,6GAAA,cAAc,OAAA;AACd,kHAAA,mBAAmB,OAAA;AACnB,6HAAA,8BAA8B,OAAA;AAG/B,yDAS6B;AAN5B,6HAAA,wBAAwB,OAAA;AACxB,oHAAA,eAAe,OAAA;AAEf,wHAAA,mBAAmB,OAAA;AAEnB,wHAAA,mBAAmB,OAAA;AAEpB,2EAAmE;AAA1D,iIAAA,mBAAmB,OAAA;AAC5B,uCAeoB;AAdnB,oGAAA,QAAQ,OAAA;AAQR,8GAAA,kBAAkB,OAAA;AAClB,8GAAA,kBAAkB,OAAA;AAClB,wGAAA,YAAY,OAAA;AAEZ,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AAErB,iDAAgE;AAApC,2GAAA,UAAU,OAAA;AACtC,qDAO2B;AAL1B,gHAAA,aAAa,OAAA;AACb,6GAAA,UAAU,OAAA;AACV,yHAAA,sBAAsB,OAAA;AACtB,kHAAA,eAAe,OAAA;AACf,yHAAA,sBAAsB,OAAA;AAIvB,iDAA4D;AAAnD,2GAAA,UAAU,OAAA;AAAE,8GAAA,aAAa,OAAA;AAElC,+CAOwB;AANvB,0HAAA,0BAA0B,OAAA;AAC1B,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AACnB,kHAAA,kBAAkB,OAAA;AAClB,8GAAA,cAAc,OAAA;AACd,0GAAA,UAAU,OAAA;AAGX,uCAMoB;AAJnB,qGAAA,SAAS,OAAA;AACT,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AAIZ,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\tAnchorSet,\n\ttype AnchorSlot,\n\ttype AnchorNode,\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorSetRootEvents,\n} from \"./anchorSet.js\";\nexport {\n\ttype ITreeCursor,\n\tCursorLocationType,\n\tcastCursorToSynchronous,\n\tmapCursorField,\n\tmapCursorFields,\n\tforEachNode,\n\tforEachNodeInSubtree,\n\tforEachField,\n\titerateCursorField,\n\ttype ITreeCursorSynchronous,\n\ttype PathRootPrefix,\n\tinCursorField,\n\tinCursorNode,\n\tCursorMarker,\n\tisCursor,\n} from \"./cursor.js\";\nexport type {\n\tProtoNodes,\n\tRoot as DeltaRoot,\n\tProtoNode as DeltaProtoNode,\n\tMark as DeltaMark,\n\tDetachedNodeId as DeltaDetachedNodeId,\n\tFieldMap as DeltaFieldMap,\n\tDetachedNodeChanges as DeltaDetachedNodeChanges,\n\tDetachedNodeBuild as DeltaDetachedNodeBuild,\n\tDetachedNodeDestruction as DeltaDetachedNodeDestruction,\n\tDetachedNodeRename as DeltaDetachedNodeRename,\n\tFieldChanges as DeltaFieldChanges,\n} from \"./delta.js\";\nexport { type MapTree, type ExclusiveMapTree, deepCopyMapTree } from \"./mapTree.js\";\nexport {\n\tclonePath,\n\ttopDownPath,\n\tgetDepth,\n\ttype UpPath,\n\ttype FieldUpPath,\n\ttype Range,\n\ttype RangeUpPath,\n\ttype PlaceUpPath,\n\ttype PlaceIndex,\n\ttype NodeIndex,\n\ttype DetachedPlaceUpPath,\n\ttype DetachedRangeUpPath,\n\tcompareUpPaths,\n\tcompareFieldUpPaths,\n\tgetDetachedFieldContainingPath,\n\ttype UpPathDefault,\n} from \"./pathTree.js\";\nexport {\n\ttype FieldMapObject,\n\ttype GenericFieldsNode,\n\tgenericTreeDeleteIfEmpty,\n\tgenericTreeKeys,\n\ttype GenericTreeNode,\n\tgetGenericTreeField,\n\ttype JsonableTree,\n\tsetGenericTreeField,\n} from \"./treeTextFormat.js\";\nexport { EncodedJsonableTree } from \"./persistedTreeTextFormat.js\";\nexport {\n\tEmptyKey,\n\ttype TreeType,\n\ttype ChildLocation,\n\ttype DetachedField,\n\ttype ChildCollection,\n\ttype RootField,\n\ttype Value,\n\ttype TreeValue,\n\tdetachedFieldAsKey,\n\tkeyAsDetachedField,\n\trootFieldKey,\n\ttype NodeData,\n\trootField,\n\taboveRootPlaceholder,\n} from \"./types.js\";\nexport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nexport {\n\ttype AnnouncedVisitor,\n\tannounceDelta,\n\tapplyDelta,\n\tcreateAnnouncedVisitor,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n} from \"./visitorUtils.js\";\nexport type { PathVisitor } from \"./visitPath.js\";\n\nexport { SparseNode, getDescendant } from \"./sparseTree.js\";\n\nexport {\n\tdeltaForRootInitialization,\n\temptyFieldChanges,\n\tisEmptyFieldChanges,\n\tmakeDetachedNodeId,\n\toffsetDetachId,\n\temptyDelta,\n} from \"./deltaUtil.js\";\n\nexport {\n\ttype TreeChunk,\n\tdummyRoot,\n\tcursorChunk,\n\ttryGetChunk,\n\ttype ChunkedCursor,\n} from \"./chunk.js\";\n\nexport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nexport { type ForestRootId } from \"./detachedFieldIndexTypes.js\";\n"]}
|
|
@@ -44,8 +44,6 @@ import type { NodeData } from "./types.js";
|
|
|
44
44
|
* Only use this type when needed for json compatible maps,
|
|
45
45
|
* but even in those cases consider lists of key value pairs for serialization and using `Map`
|
|
46
46
|
* for runtime.
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
47
|
*/
|
|
50
48
|
export interface FieldMapObject<TChild> {
|
|
51
49
|
[key: string]: TChild[];
|
|
@@ -53,14 +51,12 @@ export interface FieldMapObject<TChild> {
|
|
|
53
51
|
/**
|
|
54
52
|
* Json comparable tree node, generic over child type.
|
|
55
53
|
* Json compatibility assumes `TChild` is also json compatible.
|
|
56
|
-
* @internal
|
|
57
54
|
*/
|
|
58
55
|
export interface GenericTreeNode<TChild> extends GenericFieldsNode<TChild>, NodeData {
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
* Json comparable field collection, generic over child type.
|
|
62
59
|
* Json compatibility assumes `TChild` is also json compatible.
|
|
63
|
-
* @internal
|
|
64
60
|
*/
|
|
65
61
|
export interface GenericFieldsNode<TChild> {
|
|
66
62
|
fields?: FieldMapObject<TChild>;
|
|
@@ -72,7 +68,6 @@ export interface GenericFieldsNode<TChild> {
|
|
|
72
68
|
* {@link @fluidframework/shared-object-base#IFluidSerializer.stringify} must be used instead of `JSON.stringify`.
|
|
73
69
|
*
|
|
74
70
|
* JsonableTrees should not store empty fields.
|
|
75
|
-
* @internal
|
|
76
71
|
*/
|
|
77
72
|
export interface JsonableTree extends GenericTreeNode<JsonableTree> {
|
|
78
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeTextFormat.d.ts","sourceRoot":"","sources":["../../../src/core/tree/treeTextFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAG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EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,QAAQ,EAAE,CAWlF;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACzC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,QAAQ,EACb,eAAe,EAAE,OAAO,GACtB,IAAI,CAaN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeTextFormat.js","sourceRoot":"","sources":["../../../src/core/tree/treeTextFormat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAA2C;
|
|
1
|
+
{"version":3,"file":"treeTextFormat.js","sourceRoot":"","sources":["../../../src/core/tree/treeTextFormat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAA2C;AA2E3C;;GAEG;AACH,SAAgB,mBAAmB,CAClC,IAA0B,EAC1B,GAAa,EACb,eAAwB;IAExB,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAE/D,iFAAiF;IACjF,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QACzD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,eAAI,EAAC,+CAA+C,CAAC,CAAC;IAC/E,CAAC;IACD,wBAAwB;IACxB,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACzB,OAAO,QAAQ,CAAC;AACjB,CAAC;AAlBD,kDAkBC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAC9B,IAA0B,EAC1B,eAAwB;IAExB,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC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E,CAAC;gBACrB,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACxC,OAAO,IAAI,CAAC,MAAM,CAAC;gBACpB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAjBD,4DAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { NodeData } from \"./types.js\";\n\n/**\n * This modules provides a simple human readable (and editable) tree format.\n *\n * This implementation can handle all trees (so it does not need a fallback for any special cases),\n * and is not optimized.\n *\n * It's suitable for testing and debugging,\n * though it could also reasonably be used as a fallback for edge cases or for small trees.\n *\n * The serialized format is valid utf-8, and also includes a json compatible intermediate in memory format.\n *\n * This format is currently not stable: its internal contents are not considered public APIs and may change.\n * There is currently no guarantee that data serialized with this library will\n * be loadable with a different version of this library.\n *\n * TODO: stabilize this format (probably after schema are more stable).\n *\n * This format does not include schema: typically schema would be stored alongside data in this format.\n *\n * @privateRemarks A forked version of these types is available at `persistedTreeTextFormat.ts`.\n * Changes to them might necessitate changes to the analogous forked types, or codecs which transcode between\n * them.\n * See persistedTreeTextFormat's module documentation for more details.\n */\n\n/**\n * Json compatible map as object.\n * Keys are FieldKey strings.\n * Values are the content of the field specified by the key.\n *\n * WARNING:\n * Be very careful when using objects as maps:\n * Use `Object.prototype.hasOwnProperty.call(fieldMap, key)` to safely check for keys.\n * Do NOT simply read the field and check for undefined as this will return values for `__proto__`\n * and various methods on Object.prototype, like `hasOwnProperty` and `toString`.\n * This exposes numerous bug possibilities, including prototype pollution.\n *\n * Due to the above issue, try to avoid this type (and the whole object as map pattern).\n * Only use this type when needed for json compatible maps,\n * but even in those cases consider lists of key value pairs for serialization and using `Map`\n * for runtime.\n */\nexport interface FieldMapObject<TChild> {\n\t[key: string]: TChild[];\n}\n\n/**\n * Json comparable tree node, generic over child type.\n * Json compatibility assumes `TChild` is also json compatible.\n */\nexport interface GenericTreeNode<TChild> extends GenericFieldsNode<TChild>, NodeData {}\n\n/**\n * Json comparable field collection, generic over child type.\n * Json compatibility assumes `TChild` is also json compatible.\n */\nexport interface GenericFieldsNode<TChild> {\n\tfields?: FieldMapObject<TChild>;\n}\n\n/**\n * A tree represented using plain JavaScript objects.\n * Can be passed to `JSON.stringify()` to produce a human-readable/editable JSON tree.\n * If the tree may contain an {@link @fluidframework/core-interfaces#IFluidHandle},\n * {@link @fluidframework/shared-object-base#IFluidSerializer.stringify} must be used instead of `JSON.stringify`.\n *\n * JsonableTrees should not store empty fields.\n */\nexport interface JsonableTree extends GenericTreeNode<JsonableTree> {}\n\n/**\n * Get a field from `node`, optionally modifying the tree to create it if missing.\n */\nexport function getGenericTreeField<T>(\n\tnode: GenericFieldsNode<T>,\n\tkey: FieldKey,\n\tcreateIfMissing: boolean,\n): T[] {\n\tconst children = getGenericTreeFieldMap(node, createIfMissing);\n\n\t// Do not just read field and check for undefined: see warning on FieldMapObject.\n\tif (Object.prototype.hasOwnProperty.call(children, key)) {\n\t\treturn children[key] ?? fail(\"This wont be undefined due to the check above\");\n\t}\n\t// Handle missing field:\n\tif (createIfMissing === false) {\n\t\treturn [];\n\t}\n\tconst newField: T[] = [];\n\tchildren[key] = newField;\n\treturn newField;\n}\n\n/**\n * Get a FieldMap from `node`, optionally modifying the tree to create it if missing.\n */\nfunction getGenericTreeFieldMap<T>(\n\tnode: GenericFieldsNode<T>,\n\tcreateIfMissing: boolean,\n): FieldMapObject<T> {\n\tlet children = node.fields;\n\tif (children === undefined) {\n\t\tchildren = {};\n\t\t// Handle missing fields:\n\t\tif (createIfMissing) {\n\t\t\tnode.fields = children;\n\t\t}\n\t}\n\n\treturn children;\n}\n\n/**\n * Sets a field on `node`.\n */\nexport function setGenericTreeField<T>(\n\tnode: GenericFieldsNode<T>,\n\tkey: FieldKey,\n\tcontent: T[],\n): void {\n\tconst children = getGenericTreeFieldMap(node, true);\n\t// like `children[keyString] = content;` except safe when keyString == \"__proto__\".\n\tObject.defineProperty(children, key, {\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t\tvalue: content,\n\t});\n}\n\n/**\n * @returns keys for fields of `tree`.\n */\nexport function genericTreeKeys<T>(tree: GenericFieldsNode<T>): readonly FieldKey[] {\n\tconst fields = tree.fields;\n\t// This function is used when iterating through a tree.\n\t// This means that this is often called on nodes with no keys\n\t// (most trees are a large portion leaf nodes).\n\t// Therefore this function special cases empty fields objects as an optimization.\n\tif (fields === undefined) {\n\t\treturn [];\n\t}\n\n\treturn Object.keys(fields) as FieldKey[];\n}\n\n/**\n * Delete a field if empty.\n * Optionally delete FieldMapObject if empty as well.\n */\nexport function genericTreeDeleteIfEmpty<T>(\n\tnode: GenericFieldsNode<T>,\n\tkey: FieldKey,\n\tremoveMapObject: boolean,\n): void {\n\tconst children = getGenericTreeFieldMap(node, false);\n\tif (Object.prototype.hasOwnProperty.call(children, key)) {\n\t\tif (children[key]?.length === 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete children[key];\n\t\t\tif (removeMapObject) {\n\t\t\t\tif (Object.keys(children).length === 0) {\n\t\t\t\t\tdelete node.fields;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -19,7 +19,6 @@ export type TreeType = TreeNodeSchemaIdentifier;
|
|
|
19
19
|
* This has to be a FieldKey since different nodes will have different TreeFieldStoredSchema for it.
|
|
20
20
|
* This makes it prone to collisions and suggests
|
|
21
21
|
* that this intention may be better conveyed by metadata on the ITreeSchema.
|
|
22
|
-
* @internal
|
|
23
22
|
*/
|
|
24
23
|
export declare const EmptyKey: FieldKey;
|
|
25
24
|
/**
|
|
@@ -86,7 +85,6 @@ export interface FieldKind {
|
|
|
86
85
|
}
|
|
87
86
|
/**
|
|
88
87
|
* Value that may be stored on a leaf node.
|
|
89
|
-
* @internal
|
|
90
88
|
*/
|
|
91
89
|
export type TreeValue<TSchema extends ValueSchema = ValueSchema> = [
|
|
92
90
|
{
|
|
@@ -99,7 +97,6 @@ export type TreeValue<TSchema extends ValueSchema = ValueSchema> = [
|
|
|
99
97
|
][_InlineTrick];
|
|
100
98
|
/**
|
|
101
99
|
* Value stored on a node.
|
|
102
|
-
* @internal
|
|
103
100
|
*/
|
|
104
101
|
export type Value = undefined | TreeValue;
|
|
105
102
|
/**
|
|
@@ -108,8 +105,6 @@ export type Value = undefined | TreeValue;
|
|
|
108
105
|
* @privateRemarks A forked version of this type is used in `persistedTreeTextFormat.ts`.
|
|
109
106
|
* Changes to this type might necessitate changes to `EncodedNodeData` or codecs.
|
|
110
107
|
* See persistedTreeTextFormat's module documentation for more details.
|
|
111
|
-
*
|
|
112
|
-
* @internal
|
|
113
108
|
*/
|
|
114
109
|
export interface NodeData {
|
|
115
110
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EACN,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,YAAY,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,QAAQ,EACR,wBAAwB,EACxB,WAAW,EACX,MAAM,2BAA2B,CAAC;AAEnC;GACG;AACH,MAAM,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EACN,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,YAAY,EACjB,MAAM,qBAAqB,CAAC;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7B,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAC7B,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAC/B,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;QAExC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;KACzB,CAAC,OAAO,CAAC;CACV,CAAC,YAAY,CAAC,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,wBAElC,CAAC"}
|
package/dist/core/tree/types.js
CHANGED
|
@@ -17,7 +17,6 @@ const index_js_1 = require("../../util/index.js");
|
|
|
17
17
|
* This has to be a FieldKey since different nodes will have different TreeFieldStoredSchema for it.
|
|
18
18
|
* This makes it prone to collisions and suggests
|
|
19
19
|
* that this intention may be better conveyed by metadata on the ITreeSchema.
|
|
20
|
-
* @internal
|
|
21
20
|
*/
|
|
22
21
|
exports.EmptyKey = (0, index_js_1.brand)("");
|
|
23
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/tree/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kDAM6B;AAW7B
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/tree/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kDAM6B;AAW7B;;;;;;;;;;;GAWG;AACU,QAAA,QAAQ,GAAa,IAAA,gBAAK,EAAC,EAAE,CAAC,CAAC;AAE5C;;;;GAIG;AACU,QAAA,YAAY,GAAa,IAAA,gBAAK,EAAC,cAAc,CAAC,CAAC;AAE5D;GACG;AACU,QAAA,SAAS,GAAG,kBAAkB,CAAC,oBAAY,CAAC,CAAC;AAqC1D;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAoB;IACtD,OAAO,IAAA,gBAAK,EAAC,IAAA,4BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,GAAa;IAC/C,OAAO,IAAA,gBAAK,EAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAFD,gDAEC;AAsDD;;GAEG;AACU,QAAA,oBAAoB,GAA6B,IAAA,gBAAK,EAClE,0CAA0C,CAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport {\n\ttype Brand,\n\ttype Opaque,\n\tbrand,\n\textractFromOpaque,\n\ttype _InlineTrick,\n} from \"../../util/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValueSchema,\n} from \"../schema-stored/index.js\";\n\n/**\n */\nexport type TreeType = TreeNodeSchemaIdentifier;\n\n/**\n * The empty key (\"\") is used for unnamed relationships, such as the indexer\n * of an explicit array node.\n *\n * This key is a hint that this field is the primary function of the node,\n * and in some abstractions the APIs for this field should be inlined onto the node.\n *\n * TODO:\n * This has to be a FieldKey since different nodes will have different TreeFieldStoredSchema for it.\n * This makes it prone to collisions and suggests\n * that this intention may be better conveyed by metadata on the ITreeSchema.\n */\nexport const EmptyKey: FieldKey = brand(\"\");\n\n/**\n * FieldKey to use for the root of documents in places that need to refer to detached sequences or the root.\n * TODO: if we do want to standardize on a single value for this,\n * it likely should be namespaced or a UUID to avoid risk of collisions.\n */\nexport const rootFieldKey: FieldKey = brand(\"rootFieldKey\");\n\n/**\n */\nexport const rootField = keyAsDetachedField(rootFieldKey);\n\n/**\n * Location of a tree relative to is parent container (which can be a tree or forest).\n */\nexport interface ChildLocation {\n\treadonly container: ChildCollection;\n\treadonly index: number;\n}\n\n/**\n * Wrapper around DetachedField that can be detected at runtime.\n */\nexport interface RootField {\n\treadonly key: DetachedField;\n}\n\n/**\n * Identifier for a child collection, either on a node/tree or at the root of a forest.\n */\nexport type ChildCollection = FieldKey | RootField;\n\n// TODO: its not clear how much DetachedField belongs here in tree,\n// but for now as its needed in Rebase and Forest,\n// it makes sense to have it here for reasoning about the roots of trees.\n/**\n * A root in the forest.\n *\n * The range is a \"container\" like a field:\n * any additional content inserted before or after contents of this range will be included in the range.\n * This also means that moving the content from this range elsewhere will leave this range valid, but empty.\n *\n * In some APIs DetachedFields are used as FieldKeys on a special implicit root node\n * to simplify the APIs and implementation.\n */\nexport interface DetachedField extends Opaque<Brand<string, \"tree.DetachedField\">> {}\n\n/**\n * Some code abstracts the root as a node with detached fields as its fields.\n * This maps detached field to field keys for thus use.\n *\n * @returns `field` as a {@link FieldKey} usable on a special root node serving as a parent of detached fields.\n */\nexport function detachedFieldAsKey(field: DetachedField): FieldKey {\n\treturn brand(extractFromOpaque(field));\n}\n\n/**\n * The inverse of {@link detachedFieldAsKey}.\n * Thus must only be used on {@link FieldKey}s which were produced via {@link detachedFieldAsKey},\n * and with the same scope (ex: forest) as the detachedFieldAsKey was originally from.\n */\nexport function keyAsDetachedField(key: FieldKey): DetachedField {\n\treturn brand(key);\n}\n\n/**\n * TODO: integrate this into Schema. Decide how to persist them (need stable Id?). Maybe allow updating field kinds?.\n * TODO: make families of changes per field kind. Build editing APIs from that.\n * TODO: factor ChangeRebaser implementations to support adding new field kinds.\n */\nexport interface FieldKind {\n\treadonly name: string;\n\treadonly description: string;\n\treadonly minimumChildren: number;\n\treadonly maximumChildren: number;\n}\n\n/**\n * Value that may be stored on a leaf node.\n */\nexport type TreeValue<TSchema extends ValueSchema = ValueSchema> = [\n\t{\n\t\t[ValueSchema.Number]: number;\n\t\t[ValueSchema.String]: string;\n\t\t[ValueSchema.Boolean]: boolean;\n\t\t[ValueSchema.FluidHandle]: IFluidHandle;\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\t[ValueSchema.Null]: null;\n\t}[TSchema],\n][_InlineTrick];\n\n/**\n * Value stored on a node.\n */\nexport type Value = undefined | TreeValue;\n\n/**\n * The fields required by a node in a tree.\n *\n * @privateRemarks A forked version of this type is used in `persistedTreeTextFormat.ts`.\n * Changes to this type might necessitate changes to `EncodedNodeData` or codecs.\n * See persistedTreeTextFormat's module documentation for more details.\n */\nexport interface NodeData {\n\t/**\n\t * A payload of arbitrary serializable data.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * The meaning of this node.\n\t * Provides contexts/semantics for this node and its content.\n\t * Typically used to associate a node with metadata (including a schema) and source code (types, behaviors, etc).\n\t */\n\treadonly type: TreeNodeSchemaIdentifier;\n}\n\n/**\n * Use this type to indicate that a node sits above the detached fields, and thus is not a real node and who's type should not matter.\n */\nexport const aboveRootPlaceholder: TreeNodeSchemaIdentifier = brand(\n\t\"com.fluidframework.placeholder.aboveRoot\",\n);\n"]}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { CursorLocationType, type FieldKey, type FieldUpPath, type PathRootPrefix, type TreeNodeSchemaIdentifier, type TreeType, type TreeValue, type UpPath, type Value } from "../../core/index.js";
|
|
5
|
+
import { CursorLocationType, type FieldKey, type FieldUpPath, type PathRootPrefix, type TreeNodeSchemaIdentifier, type TreeType, type TreeValue, type UpPath, type Value, type ChunkedCursor, type TreeChunk, cursorChunk } from "../../core/index.js";
|
|
6
6
|
import { ReferenceCountedBase } from "../../util/index.js";
|
|
7
7
|
import { SynchronousCursor } from "../treeCursorUtils.js";
|
|
8
|
-
import { type ChunkedCursor, type TreeChunk, cursorChunk } from "./chunk.js";
|
|
9
8
|
/**
|
|
10
9
|
* General purpose one node chunk.
|
|
11
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,KAAK,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAQ,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"basicChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,WAAW,EAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAQ,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAc,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,qBAAa,UAAW,SAAQ,oBAAqB,YAAW,SAAS;IAShE,IAAI,EAAE,wBAAwB;IACrC;;;;;;;OAOG;IACI,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;IACzC;;OAEG;IACI,KAAK,CAAC;IArBd,SAAgB,cAAc,EAAE,MAAM,CAAK;IAE3C;;;;OAIG;gBAE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