@fluidframework/tree 2.113.1 → 2.115.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 +289 -0
- package/api-report/tree.alpha.api.md +127 -39
- package/dist/core/change-family/changeFamily.d.ts +15 -4
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/change-family/editBuilder.d.ts +2 -3
- package/dist/core/change-family/editBuilder.d.ts.map +1 -1
- package/dist/core/change-family/editBuilder.js +1 -2
- package/dist/core/change-family/editBuilder.js.map +1 -1
- package/dist/core/change-family/index.d.ts +1 -1
- package/dist/core/change-family/index.d.ts.map +1 -1
- package/dist/core/change-family/index.js.map +1 -1
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +110 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +47 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/tree/delta.d.ts +62 -16
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +7 -13
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +32 -46
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- 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.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +2 -4
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +2 -2
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/entrypoints/alpha.d.ts +1 -1
- package/dist/entrypoints/alpha.d.ts.map +1 -1
- package/dist/entrypoints/alpha.js +8 -3
- package/dist/entrypoints/alpha.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +16 -13
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +10 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.js +98 -0
- package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
- package/dist/feature-libraries/comparison-forest/index.d.ts +6 -0
- package/dist/feature-libraries/comparison-forest/index.d.ts.map +1 -0
- package/dist/feature-libraries/comparison-forest/index.js +10 -0
- package/dist/feature-libraries/comparison-forest/index.js.map +1 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.js +3 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +18 -6
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -3
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +4 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +77 -72
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +12 -0
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.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.map +1 -1
- package/dist/feature-libraries/modular-schema/invert.d.ts +15 -0
- package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/invert.js +159 -0
- package/dist/feature-libraries/modular-schema/invert.js.map +1 -0
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
- package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
- package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +53 -406
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.js +205 -0
- package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
- package/dist/feature-libraries/modular-schema/prune.d.ts +10 -0
- package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/prune.js +49 -0
- package/dist/feature-libraries/modular-schema/prune.js.map +1 -0
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.d.ts +15 -0
- package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +64 -1
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- 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/serializedChange.d.ts +2 -2
- package/dist/shared-tree/serializedChange.d.ts.map +1 -1
- package/dist/shared-tree/serializedChange.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +11 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +9 -7
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +57 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
- package/dist/shared-tree/transactionMinimize.js +2 -2
- package/dist/shared-tree/transactionMinimize.js.map +1 -1
- package/dist/shared-tree/transactionPostProcessor.d.ts +2 -1
- package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -1
- package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +13 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +59 -13
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +24 -9
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +7 -0
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +4 -4
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +2 -0
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -14
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +4 -4
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +0 -1
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +8 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +5 -5
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +10 -10
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +6 -3
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.js +15 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -3
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +6 -7
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaStatics.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts +20 -24
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +48 -49
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +5 -6
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +2 -4
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +20 -7
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js +4 -7
- package/dist/simple-tree/core/withType.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 +3 -4
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +6 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +0 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +53 -5
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +91 -10
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +90 -0
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +26 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/text/codePointUtils.d.ts +2 -2
- package/dist/text/codePointUtils.js +2 -2
- package/dist/text/codePointUtils.js.map +1 -1
- package/dist/text/index.d.ts +3 -3
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +4 -4
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomain.d.ts +30 -18
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +44 -23
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +180 -82
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +164 -84
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/text/textDomainFormattedDefault.d.ts +48 -25
- package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/dist/text/textDomainFormattedDefault.js +24 -19
- package/dist/text/textDomainFormattedDefault.js.map +1 -1
- package/dist/treeDataStore.d.ts +49 -0
- package/dist/treeDataStore.d.ts.map +1 -0
- package/dist/treeDataStore.js +57 -0
- package/dist/treeDataStore.js.map +1 -0
- package/dist/treeFactory.d.ts +8 -3
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +6 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/compressedIds.d.ts +22 -2
- package/dist/util/compressedIds.d.ts.map +1 -1
- package/dist/util/compressedIds.js +22 -1
- package/dist/util/compressedIds.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +15 -4
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/change-family/editBuilder.d.ts +2 -3
- package/lib/core/change-family/editBuilder.d.ts.map +1 -1
- package/lib/core/change-family/editBuilder.js +1 -2
- package/lib/core/change-family/editBuilder.js.map +1 -1
- package/lib/core/change-family/index.d.ts +1 -1
- package/lib/core/change-family/index.d.ts.map +1 -1
- package/lib/core/change-family/index.js.map +1 -1
- package/lib/core/index.d.ts +4 -3
- 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/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +110 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +46 -0
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/tree/delta.d.ts +62 -16
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +7 -13
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +7 -21
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- 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.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +2 -4
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +2 -2
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/entrypoints/alpha.d.ts +1 -1
- package/lib/entrypoints/alpha.d.ts.map +1 -1
- package/lib/entrypoints/alpha.js +1 -1
- package/lib/entrypoints/alpha.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +16 -13
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +10 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.js +94 -0
- package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
- package/lib/feature-libraries/comparison-forest/index.d.ts +6 -0
- package/lib/feature-libraries/comparison-forest/index.d.ts.map +1 -0
- package/lib/feature-libraries/comparison-forest/index.js +6 -0
- package/lib/feature-libraries/comparison-forest/index.js.map +1 -0
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.js +3 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +16 -4
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +4 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +12 -0
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.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.map +1 -1
- package/lib/feature-libraries/modular-schema/invert.d.ts +15 -0
- package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/invert.js +155 -0
- package/lib/feature-libraries/modular-schema/invert.js.map +1 -0
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
- package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
- package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +16 -367
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.js +192 -0
- package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
- package/lib/feature-libraries/modular-schema/prune.d.ts +10 -0
- package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/prune.js +45 -0
- package/lib/feature-libraries/modular-schema/prune.js.map +1 -0
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.d.ts +15 -0
- package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +62 -1
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -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/serializedChange.d.ts +2 -2
- package/lib/shared-tree/serializedChange.d.ts.map +1 -1
- package/lib/shared-tree/serializedChange.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +11 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +10 -8
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +55 -0
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
- package/lib/shared-tree/transactionMinimize.js +3 -3
- package/lib/shared-tree/transactionMinimize.js.map +1 -1
- package/lib/shared-tree/transactionPostProcessor.d.ts +2 -1
- package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -1
- package/lib/shared-tree/transactionPostProcessor.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +13 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +61 -15
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +24 -9
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +7 -0
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +4 -4
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +2 -0
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -14
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +4 -4
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +0 -1
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +8 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +5 -5
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +10 -10
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +6 -3
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.js +15 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +6 -7
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaStatics.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts +20 -24
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +46 -46
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +5 -6
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +2 -4
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +20 -7
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js +4 -7
- package/lib/simple-tree/core/withType.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 +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +6 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +0 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +53 -5
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +93 -12
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +90 -0
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +27 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/text/codePointUtils.d.ts +2 -2
- package/lib/text/codePointUtils.js +2 -2
- package/lib/text/codePointUtils.js.map +1 -1
- package/lib/text/index.d.ts +3 -3
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +3 -3
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomain.d.ts +30 -18
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +41 -22
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +180 -82
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +165 -86
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/text/textDomainFormattedDefault.d.ts +48 -25
- package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
- package/lib/text/textDomainFormattedDefault.js +25 -20
- package/lib/text/textDomainFormattedDefault.js.map +1 -1
- package/lib/treeDataStore.d.ts +49 -0
- package/lib/treeDataStore.d.ts.map +1 -0
- package/lib/treeDataStore.js +52 -0
- package/lib/treeDataStore.js.map +1 -0
- package/lib/treeFactory.d.ts +8 -3
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +5 -0
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/compressedIds.d.ts +22 -2
- package/lib/util/compressedIds.d.ts.map +1 -1
- package/lib/util/compressedIds.js +22 -1
- package/lib/util/compressedIds.js.map +1 -1
- package/package.json +32 -24
- package/src/core/change-family/changeFamily.ts +32 -4
- package/src/core/change-family/editBuilder.ts +1 -2
- package/src/core/change-family/index.ts +2 -0
- package/src/core/index.ts +11 -6
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +113 -0
- package/src/core/tree/delta.ts +62 -16
- package/src/core/tree/detachedFieldIndex.ts +7 -38
- package/src/core/tree/index.ts +2 -0
- package/src/core/tree/visitorUtils.ts +3 -17
- package/src/entrypoints/alpha.ts +9 -1
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -14
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +11 -1
- package/src/feature-libraries/comparison-forest/comparisonForest.ts +140 -0
- package/src/feature-libraries/comparison-forest/index.ts +6 -0
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +20 -6
- package/src/feature-libraries/default-schema/index.ts +1 -0
- package/src/feature-libraries/default-schema/noChangeCodecs.ts +11 -3
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +33 -5
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -3
- package/src/feature-libraries/index.ts +5 -0
- package/src/feature-libraries/mitigatedChangeFamily.ts +21 -3
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -1
- package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +9 -4
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/modular-schema/invert.ts +338 -0
- package/src/feature-libraries/modular-schema/minimizeModularChange.ts +3 -5
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +16 -13
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +3 -1
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +2 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +45 -644
- package/src/feature-libraries/modular-schema/modularChangeUtils.ts +340 -0
- package/src/feature-libraries/modular-schema/prune.ts +69 -0
- package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +4 -2
- package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +6 -3
- package/src/feature-libraries/treeTextCursor.ts +66 -1
- package/src/index.ts +11 -4
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/serializedChange.ts +2 -2
- package/src/shared-tree/sharedTree.ts +40 -15
- package/src/shared-tree/sharedTreeChangeCodecs.ts +11 -3
- package/src/shared-tree/sharedTreeChangeFamily.ts +77 -2
- package/src/shared-tree/transactionMinimize.ts +7 -3
- package/src/shared-tree/transactionPostProcessor.ts +5 -1
- package/src/shared-tree/treeCheckout.ts +136 -30
- package/src/shared-tree-core/branch.ts +41 -12
- package/src/shared-tree-core/editManager.ts +46 -25
- package/src/shared-tree-core/editManagerCodecs.ts +9 -21
- package/src/shared-tree-core/editManagerCodecsCommons.ts +14 -2
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +18 -21
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +18 -20
- package/src/shared-tree-core/editManagerSummarizer.ts +9 -6
- package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -3
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -2
- package/src/shared-tree-core/messageCodecs.ts +12 -2
- package/src/shared-tree-core/sharedTreeCore.ts +16 -7
- package/src/shared-tree-core/transaction.ts +47 -25
- package/src/simple-tree/api/eraseSchemaDetails.ts +15 -0
- package/src/simple-tree/api/index.ts +0 -1
- package/src/simple-tree/api/schemaStatics.ts +2 -2
- package/src/simple-tree/api/treeNodeApi.ts +64 -48
- package/src/simple-tree/core/treeNode.ts +13 -10
- package/src/simple-tree/core/withType.ts +20 -7
- package/src/simple-tree/index.ts +1 -2
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +130 -16
- package/src/simple-tree/node-kinds/map/mapNode.ts +137 -5
- package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
- package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
- package/src/text/README.md +1 -1
- package/src/text/codePointUtils.ts +2 -2
- package/src/text/index.ts +3 -3
- package/src/text/textDomain.ts +50 -27
- package/src/text/textDomainFormatted.ts +384 -163
- package/src/text/textDomainFormattedDefault.ts +32 -32
- package/src/treeDataStore.ts +125 -0
- package/src/treeFactory.ts +11 -3
- package/src/util/compressedIds.ts +36 -3
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.FormattedText = exports.StringTextAtomNode = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
8
9
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
10
|
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
11
|
const index_js_1 = require("../core/index.js");
|
|
@@ -26,34 +27,106 @@ function createFormattedScopedFactory(inputSchemaFactory) {
|
|
|
26
27
|
*/
|
|
27
28
|
const sfStatic = new index_js_4.SchemaFactoryAlpha("com.fluidframework.text.formatted");
|
|
28
29
|
const formatKey = (0, index_js_5.brand)("format");
|
|
30
|
+
/**
|
|
31
|
+
* Atom in the string containing a single character.
|
|
32
|
+
* @privateRemarks
|
|
33
|
+
* This is outside the namespace so it can be exported for testing, but not package exported.
|
|
34
|
+
*/
|
|
35
|
+
class StringTextAtomNode extends sfStatic.object("StringTextAtom", {
|
|
36
|
+
/**
|
|
37
|
+
* The underlying text content of this atom.
|
|
38
|
+
* @remarks
|
|
39
|
+
* This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.
|
|
40
|
+
* Longer strings are still valid. For example, users might store whole grapheme clusters here, or even longer sections of text.
|
|
41
|
+
* Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.
|
|
42
|
+
* Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.
|
|
43
|
+
* Instead, atoms should always be the smallest unit of text which will be independently selected, moved or formatted.
|
|
44
|
+
* @privateRemarks
|
|
45
|
+
* This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.
|
|
46
|
+
*/
|
|
47
|
+
content: index_js_4.SchemaFactory.required([index_js_4.SchemaFactory.string], { key: index_js_1.EmptyKey }),
|
|
48
|
+
}) {
|
|
49
|
+
static fromCharacter(value) {
|
|
50
|
+
const character = (0, index_js_5.oneFromIterable)((0, textDomain_js_1.charactersFromString)(value));
|
|
51
|
+
if (character === undefined) {
|
|
52
|
+
throw new internal_2.UsageError("value must contain exactly one Unicode character.");
|
|
53
|
+
}
|
|
54
|
+
return new StringTextAtomNode({ content: character });
|
|
55
|
+
}
|
|
56
|
+
static fromString(value) {
|
|
57
|
+
return Array.from((0, textDomain_js_1.charactersFromString)(value), (character) => new StringTextAtomNode({ content: character }));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.StringTextAtomNode = StringTextAtomNode;
|
|
29
61
|
/**
|
|
30
62
|
* A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
|
|
63
|
+
*
|
|
31
64
|
* @remarks
|
|
32
65
|
* This is generic over formatting an embedded object/atom types.
|
|
33
|
-
*
|
|
66
|
+
*
|
|
34
67
|
* @privateRemarks
|
|
68
|
+
* See {@link FormattedTextDefault} for an example parameterization.
|
|
69
|
+
*
|
|
35
70
|
* TODO:
|
|
36
71
|
* - Add more comprehensive tests for generic parameterizations other than default.
|
|
37
72
|
* - Sort out API around overwriting subsets of formatting information.
|
|
38
|
-
* @
|
|
73
|
+
* @alpha
|
|
39
74
|
*/
|
|
40
|
-
var
|
|
41
|
-
(function (
|
|
75
|
+
var FormattedText;
|
|
76
|
+
(function (FormattedText) {
|
|
42
77
|
/**
|
|
43
|
-
*
|
|
78
|
+
* Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.
|
|
79
|
+
*
|
|
80
|
+
* @param inputSchemaFactory - The {@link SchemaFactoryBeta} used to scope the generated schema.
|
|
81
|
+
* The generated types are scoped under `com.fluidframework.text.formatted<TUserScope>`, where `TUserScope` is the scope of this factory.
|
|
82
|
+
* This scope is used to distinguish different usages of `createSchema` from each-other, and must be kept the same between versions for nodes to remain compatible.
|
|
83
|
+
* It must be different to distinguish different formatted text schema within the same document.
|
|
84
|
+
* @param formatSchema - Schema describing the formatting associated with each atom of text.
|
|
85
|
+
* Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.
|
|
86
|
+
* @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.
|
|
87
|
+
* Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
|
|
88
|
+
* @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs
|
|
89
|
+
* (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).
|
|
90
|
+
* @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.
|
|
91
|
+
*
|
|
92
|
+
* @privateRemarks
|
|
93
|
+
* See {@link FormattedTextDefault} for an example parameterization of this factory.
|
|
94
|
+
*
|
|
95
|
+
* TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
|
|
44
96
|
*/
|
|
45
97
|
function createSchema(inputSchemaFactory, formatSchema, extraAtoms, defaultFormatInsertable) {
|
|
46
|
-
|
|
98
|
+
var _TextNode_instances, _TextNode_fullString_reference, _TextNode_charactersCopy_reference, _TextNode_editRange;
|
|
99
|
+
const atoms = [FormattedText.StringTextAtom, ...extraAtoms];
|
|
47
100
|
const sf = createFormattedScopedFactory(inputSchemaFactory);
|
|
101
|
+
const defaultFormat = index_js_4.TreeBeta.create(formatSchema, defaultFormatInsertable);
|
|
102
|
+
/**
|
|
103
|
+
* Gets a format node, which must be cloned before being inserted.
|
|
104
|
+
*/
|
|
105
|
+
function getFormatNode(format) {
|
|
106
|
+
// Note we cannot use the `format ?? defaultFormat` syntax as format is allowed to be `null`.
|
|
107
|
+
return format === undefined
|
|
108
|
+
? defaultFormat
|
|
109
|
+
: index_js_4.TreeBeta.create(formatSchema, format);
|
|
110
|
+
}
|
|
111
|
+
function cloneFormat(format) {
|
|
112
|
+
const clone = index_js_4.TreeBeta.clone(format);
|
|
113
|
+
// TypeScript fails to prove that cloning a node gives a node, and not possible undefined (like cloning a empty field could).
|
|
114
|
+
// This cast helps users of this function get the types they need.
|
|
115
|
+
return clone;
|
|
116
|
+
}
|
|
48
117
|
class TextNode extends sf.object("Text", {
|
|
49
118
|
content: index_js_4.SchemaFactory.required([() => StringArray], { key: index_js_1.EmptyKey }),
|
|
50
119
|
}) {
|
|
51
120
|
constructor() {
|
|
52
121
|
super(...arguments);
|
|
53
|
-
|
|
122
|
+
_TextNode_instances.add(this);
|
|
54
123
|
}
|
|
55
|
-
insertAt(index, additionalCharacters) {
|
|
56
|
-
|
|
124
|
+
insertAt(index, additionalCharacters, format) {
|
|
125
|
+
const newAtoms = typeof additionalCharacters === "string"
|
|
126
|
+
? stringTextAtomsFromString(additionalCharacters)
|
|
127
|
+
: additionalCharacters;
|
|
128
|
+
const formatNode = getFormatNode(format);
|
|
129
|
+
this.content.insertAt(index, index_js_4.TreeArrayNode.spread(stringAtomsFromTextAtoms(newAtoms, formatNode)));
|
|
57
130
|
}
|
|
58
131
|
removeRange(index, end) {
|
|
59
132
|
this.content.removeRange(index, end);
|
|
@@ -63,7 +136,7 @@ var FormattedTextAsTree;
|
|
|
63
136
|
}
|
|
64
137
|
charactersCopy() {
|
|
65
138
|
const result = this.content.charactersCopy();
|
|
66
|
-
(0,
|
|
139
|
+
(0, textDomain_js_1.expensiveInternalValidationAssert)(() => (0, internal_1.compareArrays)(result, tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_charactersCopy_reference).call(this)) ||
|
|
67
140
|
"invalid charactersCopy optimizations");
|
|
68
141
|
return result;
|
|
69
142
|
}
|
|
@@ -72,29 +145,18 @@ var FormattedTextAsTree;
|
|
|
72
145
|
}
|
|
73
146
|
fullString() {
|
|
74
147
|
const result = this.content.fullString();
|
|
75
|
-
(0,
|
|
148
|
+
(0, textDomain_js_1.expensiveInternalValidationAssert)(() => result === tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_fullString_reference).call(this) || "invalid fullString optimizations");
|
|
76
149
|
return result;
|
|
77
150
|
}
|
|
78
|
-
/**
|
|
79
|
-
* A non-optimized reference implementation of fullString.
|
|
80
|
-
*/
|
|
81
|
-
fullString_reference() {
|
|
82
|
-
return [...this.characters()].join("");
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Unoptimized trivially correct implementation of charactersCopy.
|
|
86
|
-
*/
|
|
87
|
-
charactersCopy_reference() {
|
|
88
|
-
return [...this.characters()];
|
|
89
|
-
}
|
|
90
151
|
static fromString(value, format) {
|
|
152
|
+
const formatNode = getFormatNode(format);
|
|
91
153
|
// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.
|
|
92
154
|
return new this({
|
|
93
155
|
content: [
|
|
94
156
|
// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,
|
|
95
157
|
// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.
|
|
96
158
|
// Thus the array construction here is necessary to avoid a runtime error.
|
|
97
|
-
...textAtomsFromString(value,
|
|
159
|
+
...textAtomsFromString(value, formatNode),
|
|
98
160
|
],
|
|
99
161
|
});
|
|
100
162
|
}
|
|
@@ -105,39 +167,39 @@ var FormattedTextAsTree;
|
|
|
105
167
|
this.content.insertAt(index, index_js_4.TreeArrayNode.spread(additionalCharacters));
|
|
106
168
|
}
|
|
107
169
|
formatRange(start, end, format) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Object.entries should only return string keyed enumerable own properties.
|
|
126
|
-
// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
|
|
127
|
-
(0, internal_1.assert)(typeof key === "string", 0xcc8 /* Object.entries returned a non-string key. */);
|
|
128
|
-
const field = atomFormatSchema.fields.get(key);
|
|
129
|
-
if (field === undefined) {
|
|
130
|
-
throw new internal_2.UsageError(`Unknown format key: ${key}`);
|
|
131
|
-
}
|
|
132
|
-
// Ensures that if the input is a node, it is cloned before being inserted into the tree.
|
|
133
|
-
const clonedValue = index_js_4.TreeBeta.clone(index_js_4.TreeBeta.create(field, value));
|
|
134
|
-
formatNode[key] = clonedValue;
|
|
170
|
+
const fieldFormatsRaw = Object.entries(format);
|
|
171
|
+
const fieldFormats = fieldFormatsRaw.map(([key, value]) => {
|
|
172
|
+
// Object.entries should only return string keyed enumerable own properties.
|
|
173
|
+
// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
|
|
174
|
+
(0, internal_1.assert)(typeof key === "string", 0xcc8 /* Object.entries returned a non-string key. */);
|
|
175
|
+
return [key, value];
|
|
176
|
+
});
|
|
177
|
+
tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedText.formatRange", (atom) => {
|
|
178
|
+
const formatNode = atom.format;
|
|
179
|
+
const atomFormatSchema = index_js_3.Tree.schema(formatNode);
|
|
180
|
+
if (!(0, index_js_4.isObjectNodeSchema)(atomFormatSchema)) {
|
|
181
|
+
throw new internal_2.UsageError("formatRange currently only supports object nodes for the format.");
|
|
182
|
+
}
|
|
183
|
+
for (const [key, value] of fieldFormats) {
|
|
184
|
+
const field = atomFormatSchema.fields.get(key);
|
|
185
|
+
if (field === undefined) {
|
|
186
|
+
throw new internal_2.UsageError(`Unknown format key: ${key}`);
|
|
135
187
|
}
|
|
188
|
+
// Ensures that if the input is a node, it is cloned before being inserted into the tree.
|
|
189
|
+
// Note that since this uses field schema, `undefined` can pass through this if allowed by the schema.
|
|
190
|
+
const clonedValue = index_js_4.TreeBeta.clone(index_js_4.TreeBeta.create(field, value));
|
|
191
|
+
formatNode[key] = clonedValue;
|
|
136
192
|
}
|
|
137
193
|
});
|
|
138
194
|
}
|
|
195
|
+
reformat(start, end, format) {
|
|
196
|
+
const node = getFormatNode(format);
|
|
197
|
+
tslib_1.__classPrivateFieldGet(this, _TextNode_instances, "m", _TextNode_editRange).call(this, start, end, "FormattedText.reformat", (atom) => {
|
|
198
|
+
atom.format = cloneFormat(node);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
139
201
|
/**
|
|
140
|
-
* Returns the {@link
|
|
202
|
+
* Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
|
|
141
203
|
*/
|
|
142
204
|
getAtomCharacterAt(index) {
|
|
143
205
|
const atom = this.content[index];
|
|
@@ -158,17 +220,43 @@ var FormattedTextAsTree;
|
|
|
158
220
|
return this.content.getString(startIndex, endIndex);
|
|
159
221
|
}
|
|
160
222
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
223
|
+
_TextNode_instances = new WeakSet(), _TextNode_fullString_reference = function _TextNode_fullString_reference() {
|
|
224
|
+
return [...this.characters()].join("");
|
|
225
|
+
}, _TextNode_charactersCopy_reference = function _TextNode_charactersCopy_reference() {
|
|
226
|
+
return [...this.characters()];
|
|
227
|
+
}, _TextNode_editRange = function _TextNode_editRange(start, end, method, edit) {
|
|
228
|
+
const formatStart = start ?? 0;
|
|
229
|
+
(0, index_js_5.validateIndex)(formatStart, this.content, method, true);
|
|
230
|
+
const formatEnd = Math.min(this.content.length, end ?? this.content.length);
|
|
231
|
+
(0, index_js_5.validateIndexRange)(formatStart, formatEnd, this.content, method);
|
|
232
|
+
index_js_3.TreeAlpha.context(this).runTransaction(() => {
|
|
233
|
+
for (let i = formatStart; i < formatEnd; i++) {
|
|
234
|
+
const atom = this.content[i];
|
|
235
|
+
// Range validated above, so this should never fail.
|
|
236
|
+
(0, internal_1.assert)(atom !== undefined, 0xd08 /* Index out of bounds while formatting text range. */);
|
|
237
|
+
edit(atom);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
function stringTextAtomsFromString(value) {
|
|
242
|
+
// TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.
|
|
243
|
+
// Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.
|
|
244
|
+
return FormattedText.StringTextAtom.fromString(value);
|
|
245
|
+
}
|
|
246
|
+
function stringAtomsFromTextAtoms(value, format) {
|
|
247
|
+
const result = (0, index_js_5.mapIterable)(value, (content) => {
|
|
164
248
|
const data = {
|
|
165
|
-
content
|
|
166
|
-
format:
|
|
249
|
+
content,
|
|
250
|
+
format: cloneFormat(format),
|
|
167
251
|
};
|
|
168
252
|
return new StringAtom(data); // Generic break type safety here. TODO: try and make safer.
|
|
169
253
|
});
|
|
170
254
|
return result;
|
|
171
255
|
}
|
|
256
|
+
function textAtomsFromString(value, format) {
|
|
257
|
+
const textAtoms = stringTextAtomsFromString(value);
|
|
258
|
+
return stringAtomsFromTextAtoms(textAtoms, format);
|
|
259
|
+
}
|
|
172
260
|
class StringArray extends sf.array("StringArray", [() => StringAtom]) {
|
|
173
261
|
withBorrowedSequenceCursor(f) {
|
|
174
262
|
const innerNode = (0, index_js_4.getInnerNode)(this);
|
|
@@ -192,7 +280,7 @@ var FormattedTextAsTree;
|
|
|
192
280
|
cursor.enterNode(0);
|
|
193
281
|
let content;
|
|
194
282
|
switch (cursor.type) {
|
|
195
|
-
case StringTextAtom.identifier: {
|
|
283
|
+
case FormattedText.StringTextAtom.identifier: {
|
|
196
284
|
cursor.enterField(index_js_1.EmptyKey);
|
|
197
285
|
cursor.enterNode(0);
|
|
198
286
|
content = cursor.value;
|
|
@@ -204,7 +292,7 @@ var FormattedTextAsTree;
|
|
|
204
292
|
// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.
|
|
205
293
|
// A less general optimization could just include cases for build in types with constant values
|
|
206
294
|
// (like below commented code: currently this would cause a cyclical dependency but could be refactored).
|
|
207
|
-
// case
|
|
295
|
+
// case FormattedText.StringLineAtom.identifier: {
|
|
208
296
|
// content = "\n";
|
|
209
297
|
// break;
|
|
210
298
|
// }
|
|
@@ -233,11 +321,11 @@ var FormattedTextAsTree;
|
|
|
233
321
|
return this.charactersCopy().join("");
|
|
234
322
|
}
|
|
235
323
|
getString(startIndex, endIndex = this.length) {
|
|
236
|
-
(0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "
|
|
324
|
+
(0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedText.getString");
|
|
237
325
|
return this.getCharactersSubarray(startIndex, endIndex).join("");
|
|
238
326
|
}
|
|
239
327
|
getUniformRun(startIndex, endIndex = this.length) {
|
|
240
|
-
(0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "
|
|
328
|
+
(0, index_js_5.validateIndexRange)(startIndex, endIndex, this, "FormattedText.getUniformRun");
|
|
241
329
|
if (endIndex === startIndex) {
|
|
242
330
|
throw new internal_2.UsageError("endIndex must be greater than startIndex for getUniformRun.");
|
|
243
331
|
}
|
|
@@ -296,32 +384,24 @@ var FormattedTextAsTree;
|
|
|
296
384
|
/**
|
|
297
385
|
* Schema for a text node.
|
|
298
386
|
* @remarks
|
|
299
|
-
* See {@link
|
|
300
|
-
* See {@link
|
|
387
|
+
* See {@link FormattedText.Members} for the API.
|
|
388
|
+
* See {@link FormattedText.Statics} for static APIs on this Schema, including construction.
|
|
389
|
+
* @privateRemarks
|
|
390
|
+
* eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.
|
|
391
|
+
* Ideally we would generate private members for non-public properties, but TypeScript does not support this.
|
|
392
|
+
* It is up to the user of eraseSchemaDetailsSubclassable to manage this risk.
|
|
393
|
+
*
|
|
394
|
+
* TODO: there is at least one collision prone member to worry about here: `content`.
|
|
301
395
|
*/
|
|
302
396
|
const Tree = (0, index_js_4.eraseSchemaDetailsSubclassable)()(TextNode);
|
|
303
397
|
return Tree;
|
|
304
398
|
}
|
|
305
|
-
|
|
399
|
+
FormattedText.createSchema = createSchema;
|
|
306
400
|
/**
|
|
307
|
-
*
|
|
308
|
-
* @
|
|
401
|
+
* Schema for a {@link FormattedText.(StringTextAtom:variable)} node.
|
|
402
|
+
* @sealed
|
|
403
|
+
* @alpha
|
|
309
404
|
*/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* The underlying text content of this atom.
|
|
313
|
-
* @remarks
|
|
314
|
-
* This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.
|
|
315
|
-
* Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.
|
|
316
|
-
* Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.
|
|
317
|
-
* Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.
|
|
318
|
-
* Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.
|
|
319
|
-
* @privateRemarks
|
|
320
|
-
* This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.
|
|
321
|
-
*/
|
|
322
|
-
content: index_js_4.SchemaFactory.required([index_js_4.SchemaFactory.string], { key: index_js_1.EmptyKey }),
|
|
323
|
-
}) {
|
|
324
|
-
}
|
|
325
|
-
FormattedTextAsTree.StringTextAtom = StringTextAtom;
|
|
326
|
-
})(FormattedTextAsTree || (exports.FormattedTextAsTree = FormattedTextAsTree = {}));
|
|
405
|
+
FormattedText.StringTextAtom = (0, index_js_4.eraseSchemaDetails)()(StringTextAtomNode);
|
|
406
|
+
})(FormattedText || (exports.FormattedText = FormattedText = {}));
|
|
327
407
|
//# sourceMappingURL=textDomainFormatted.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA+F;AAC/F,uEAAsE;AAEtE,+CAM0B;AAC1B,4DAAqF;AACrF,sDAAwE;AACxE,sDASiC;AAiBjC,+CAAyF;AAEzF,mDAIyB;AAEzB;;;GAGG;AACH,2HAA2H;AAC3H,SAAS,4BAA4B,CACpC,kBAAiD;IAEjD,OAAO,IAAA,sDAA2C,EAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAC1F,C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gB,mBAAmB,mCAAnB,mBAAmB,QA8nBnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachNodeSubsequence,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha, Tree as TreeStatic } from \"../shared-tree/index.js\";\nimport {\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n\tcreateCustomizedFluidFrameworkScopedFactory,\n\tisObjectNodeSchema,\n\teraseSchemaDetailsSubclassable,\n} from \"../simple-tree/index.js\";\nimport type {\n\tTreeNodeSchema,\n\tLazyItem,\n\tImplicitAllowedTypes,\n\tTreeFieldFromImplicitField,\n\tInsertableTypedNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeFieldFromImplicitField,\n\tNodeKind,\n\tTreeNode,\n\tScopedSchemaName,\n\tErasedSchemaSubclassable,\n\tErasedNode,\n\tSchemaFactoryBeta,\n} from \"../simple-tree/index.js\";\nimport { brand, mapIterable, validateIndex, validateIndexRange } from \"../util/index.js\";\n\nimport {\n\tcharactersFromString,\n\tprocessCharactersChangedDelta,\n\ttype TextAsTree,\n} from \"./textDomain.js\";\n\n/**\n * Sets up scope for formatted text schema built-in types.\n * @remarks User-provided factory scoping will be applied as `com.fluidframework.text.formatted<user-scope>`.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Inferring is the most practical option here\nfunction createFormattedScopedFactory<TUserScope extends string>(\n\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n) {\n\treturn createCustomizedFluidFrameworkScopedFactory(inputSchemaFactory, \"text.formatted\");\n}\n\n/**\n * Schema factory for formatted text types which are not generic.\n */\nconst sfStatic = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nconst formatKey: FieldKey = brand(\"format\");\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n * @remarks\n * This is generic over formatting an embedded object/atom types.\n * See {@link FormattedTextAsTreeDefault} for a default parameterization.\n * @privateRemarks\n * TODO:\n * - Add more comprehensive tests for generic parameterizations other than default.\n * - Sort out API around overwriting subsets of formatting information.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Factory for formatted text schema as a function of the formatting and the embedded object (atom) types.\n\t */\n\texport function createSchema<\n\t\tconst TUserScope extends string,\n\t\tconst FormatSchema extends ImplicitAllowedTypes,\n\t\tconst ExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n\t\tformatSchema: FormatSchema,\n\t\textraAtoms: ExtraAtomsSchema,\n\t\tdefaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> {\n\t\tconst atoms = [StringTextAtom, ...extraAtoms] as const;\n\n\t\tconst sf = createFormattedScopedFactory(inputSchemaFactory);\n\t\tclass TextNode\n\t\t\textends sf.object(\"Text\", {\n\t\t\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t\t\t})\n\t\t\timplements FormattedTextMembers<FormatSchema, ExtraAtomsSchema>\n\t\t{\n\t\t\tpublic defaultFormat: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\t\tTreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable);\n\n\t\t\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\t\t\tthis.content.insertAt(\n\t\t\t\t\tindex,\n\t\t\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\t\t\tthis.content.removeRange(index, end);\n\t\t\t}\n\n\t\t\tpublic characters(): Iterable<string> {\n\t\t\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\tconst result = this.content.charactersCopy();\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcompareArrays(result, this.charactersCopy_reference()) ||\n\t\t\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic characterCount(): number {\n\t\t\t\treturn this.content.length;\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\tconst result = this.content.fullString();\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() => result === this.fullString_reference() || \"invalid fullString optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A non-optimized reference implementation of fullString.\n\t\t\t */\n\t\t\tpublic fullString_reference(): string {\n\t\t\t\treturn [...this.characters()].join(\"\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Unoptimized trivially correct implementation of charactersCopy.\n\t\t\t */\n\t\t\tpublic charactersCopy_reference(): string[] {\n\t\t\t\treturn [...this.characters()];\n\t\t\t}\n\n\t\t\tpublic static fromString(\n\t\t\t\tvalue: string,\n\t\t\t\tformat?: TreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): TextNode {\n\t\t\t\t// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.\n\t\t\t\treturn new this({\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t\t\t\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t\t\t\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\t\t\t\t\t...textAtomsFromString(\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\tformat ?? TreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable),\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic charactersWithFormatting(): readonly StringAtom[] {\n\t\t\t\treturn this.content;\n\t\t\t}\n\t\t\tpublic insertWithFormattingAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t\t): void {\n\t\t\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t\t\t}\n\n\t\t\tpublic formatRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t\t): void {\n\t\t\t\tconst formatStart = start ?? 0;\n\t\t\t\tvalidateIndex(formatStart, this.content, \"FormattedTextAsTree.formatRange\", true);\n\n\t\t\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\t\t\tvalidateIndexRange(\n\t\t\t\t\tformatStart,\n\t\t\t\t\tformatEnd,\n\t\t\t\t\tthis.content,\n\t\t\t\t\t\"FormattedTextAsTree.formatRange\",\n\t\t\t\t);\n\n\t\t\t\tconst fieldFormats = Object.entries(format) as [\n\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tunknown,\n\t\t\t\t][];\n\n\t\t\t\tTreeAlpha.context(this).runTransaction(() => {\n\t\t\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\t\t\tconst atom = this.content[i];\n\t\t\t\t\t\t// Range validated above, so this should never fail.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tatom !== undefined,\n\t\t\t\t\t\t\t0xd08 /* Index out of bounds while formatting text range. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst formatNode: TreeNode | TreeValue = atom.format;\n\t\t\t\t\t\tconst atomFormatSchema = TreeStatic.schema(formatNode);\n\t\t\t\t\t\tif (!isObjectNodeSchema(atomFormatSchema)) {\n\t\t\t\t\t\t\t// TODO: redesign this API to work with all allowed FormatSchema types.\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"formatRange currently only supports object nodes for the format.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const [key, value] of fieldFormats) {\n\t\t\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst field = atomFormatSchema.fields.get(key);\n\t\t\t\t\t\t\tif (field === undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\t\t\tconst clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as\n\t\t\t\t\t\t\t\t| TreeNode\n\t\t\t\t\t\t\t\t| TreeValue;\n\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformatNode as unknown as Record<\n\t\t\t\t\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\t\t\t\t\tTreeNode | TreeValue\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t)[key] = clonedValue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Returns the {@link FormattedTextAsTree.TextAtom.content} at the given atom index, or `undefined` if out of bounds.\n\t\t\t */\n\t\t\tprivate getAtomCharacterAt(index: number): string | undefined {\n\t\t\t\tconst atom = this.content[index];\n\t\t\t\tif (atom === undefined) return undefined;\n\t\t\t\treturn atom.content.content;\n\t\t\t}\n\n\t\t\tpublic onCharactersChanged(\n\t\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"nodeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic onContentChanged(\n\t\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"treeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\t\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\t\t\treturn this.content.getString(startIndex, endIndex);\n\t\t\t}\n\t\t}\n\n\t\tfunction textAtomsFromString(\n\t\t\tvalue: string,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst result = mapIterable(charactersFromString(value), (char) => {\n\t\t\t\tconst textAtom = new StringTextAtom({ content: char });\n\t\t\t\tconst data = {\n\t\t\t\t\tcontent: textAtom,\n\t\t\t\t\tformat: TreeBeta.clone<FormatSchema>(format),\n\t\t\t\t};\n\t\t\t\treturn new StringAtom(data as never); // Generic break type safety here. TODO: try and make safer.\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\n\t\tclass StringArray extends sf.array(\"StringArray\", [() => StringAtom]) {\n\t\t\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\t\t\tconst innerNode = getInnerNode(this);\n\t\t\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t\t\t// treat it as if it observed the whole subtree.\n\t\t\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\t\t\tconst cursor = innerNode.borrowCursor();\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tconst result = f(cursor);\n\t\t\t\tcursor.exitField();\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\t\t\tconst slowPathIndexes: number[] = [];\n\t\t\t\tconst result: string[] = [];\n\t\t\t\tthis.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\t(cursor.type as string) === StringAtom.identifier ||\n\t\t\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tlet content: string;\n\t\t\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\t\t\tcase StringTextAtom.identifier: {\n\t\t\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.\n\t\t\t\t\t\t\t// A less general optimization could just include cases for build in types with constant values\n\t\t\t\t\t\t\t// (like below commented code: currently this would cause a cyclical dependency but could be refactored).\n\t\t\t\t\t\t\t// case FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\t\t// \tcontent = \"\\n\";\n\t\t\t\t\t\t\t// \tbreak;\n\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\tslowPathIndexes.push(result.length);\n\t\t\t\t\t\t\t\tcontent = \"\"; // Placeholder for slow path content\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tresult.push(content);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Fill in slow path cases not optimized above.\n\t\t\t\tfor (const index of slowPathIndexes) {\n\t\t\t\t\tconst node =\n\t\t\t\t\t\tthis[index + startIndex] ??\n\t\t\t\t\t\tfail(\n\t\t\t\t\t\t\t0xd09 /* getCharactersSubarray failed to find index after index range was checked */,\n\t\t\t\t\t\t);\n\t\t\t\t\tresult[index] = node.content.content;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\treturn this.getCharactersSubarray(0, this.length);\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\treturn this.charactersCopy().join(\"\");\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getString\");\n\t\t\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getUniformRun\");\n\t\t\t\tif (endIndex === startIndex) {\n\t\t\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t\t\t}\n\t\t\t\tconst arrayLength = this.length;\n\t\t\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t\t\t// Capture the content type of the first atom\n\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst contentType = cursor.type;\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t\t\t// This compares by field key\n\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\tlet runLength = 1;\n\t\t\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t\t\t// Compare atom type\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tif (!typeMatches) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trunLength++;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\treturn runLength;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * A unit of the text, with formatting.\n\t\t */\n\t\tclass StringAtom\n\t\t\textends sf.object(\"StringAtom\", {\n\t\t\t\tcontent: SchemaFactory.required(atoms, { key: EmptyKey }),\n\t\t\t\tformat: SchemaFactory.required(formatSchema),\n\t\t\t})\n\t\t\timplements\n\t\t\t\tFormattedAtom<\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<typeof atoms>\n\t\t\t\t> {}\n\n\t\t/**\n\t\t * Schema for a text node.\n\t\t * @remarks\n\t\t * See {@link FormattedTextAsTree.Members} for the API.\n\t\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t\t */\n\t\tconst Tree = eraseSchemaDetailsSubclassable<\n\t\t\tFormattedTextMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tStatics<Tree>\n\t\t>()(TextNode);\n\t\ttype Tree = ErasedNode<\n\t\t\tFormattedTextMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n\n\t\treturn Tree;\n\t}\n\n\t/**\n\t * Portion of a string with formatting.\n\t * @sealed\n\t * @internal\n\t */\n\texport interface FormattedAtom<TFormat, TText> {\n\t\treadonly content: TText;\n\t\tformat: TFormat;\n\t}\n\n\t/**\n\t * Portion of a string.\n\t * @internal\n\t */\n\texport interface TextAtom {\n\t\t/**\n\t\t * The content of the text atom, viewed as a string.\n\t\t */\n\t\treadonly content: string;\n\t}\n\n\t/**\n\t * Unit in the string representing a single character.\n\t * @internal\n\t */\n\texport class StringTextAtom\n\t\textends sfStatic.object(\"StringTextAtom\", {\n\t\t\t/**\n\t\t\t * The underlying text content of this atom.\n\t\t\t * @remarks\n\t\t\t * This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.\n\t\t\t * Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.\n\t\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t\t * Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t\t * @privateRemarks\n\t\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t\t */\n\t\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t\t})\n\t\timplements TextAtom {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics<TTree> {\n\t\t/**\n\t\t * Construct a node of `this` schema from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(value: string): TTree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedTextAsTree.Statics.fromString} for construction.\n\t * @see {@link FormattedTextAsTree.createSchema} for creating schemas whose nodes implement this.\n\t * @internal\n\t */\n\texport interface Members<TFormatTree, TPartialFormat, TFormattedAtom, TFormattedInsert>\n\t\textends TextAsTree.Members {\n\t\t/**\n\t\t * Format to use by default for text inserted with non-formatted APIs.\n\t\t * @remarks\n\t\t * This is not persisted in the tree, and observation of it is not tracked by the tree observation tracking.\n\t\t * @privateRemarks\n\t\t * Opt this into observation tracking.\n\t\t */\n\t\tdefaultFormat: TFormatTree;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly TFormattedAtom[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<TFormattedInsert>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: TPartialFormat,\n\t\t): void;\n\n\t\t/**\n\t\t * Returns the length of the run of characters starting at `startIndex` which have the same formatting and atom type, up to `endIndex`.\n\t\t * @param startIndex - The starting index of the run.\n\t\t * @param endIndex - The ending index (exclusive) of the run. Defaults to the end of the text.\n\t\t */\n\t\tgetUniformRun(startIndex: number, endIndex?: number): number;\n\t\t/**\n\t\t * Returns a substring of the text from `startIndex` to `endIndex`\n\t\t * @param startIndex - starting index (inclusive)\n\t\t * @param endIndex - Optional ending index (exclusive). Defaults to the end of the text.\n\t\t */\n\t\tgetString(startIndex: number, endIndex?: number): string;\n\n\t\t/**\n\t\t * Subscribe to all content changes on this text node, including both shallow\n\t\t * changes (inserts/removes) and deep changes (formatting updates on existing characters).\n\t\t * @param callback - Called after each change with a sequence of {@link TextAsTree.TextOp}s describing what changed,\n\t\t * or `undefined` when a delta could not be computed (e.g. during a schema upgrade).\n\t\t * @returns A cleanup function that unsubscribes the callback when called.\n\t\t * @remarks\n\t\t * Unlike {@link TextAsTree.Members.onCharactersChanged} which only fires on\n\t\t * shallow changes (inserts and removes), this method also fires on deep changes —\n\t\t * formatting property updates on existing characters.\n\t\t * The {@link TextAsTree.TextRetainOp.formattingChanged} flag on retain ops\n\t\t * indicates which character ranges had formatting updates.\n\t\t *\n\t\t * All counts in the delivered ops are in Unicode code points, not UTF-16 code units.\n\t\t * For characters outside the Basic Multilingual Plane (e.g. emoji), one code point\n\t\t * corresponds to two UTF-16 code units — convert before using the counts as string indices.\n\t\t */\n\t\tonContentChanged(\n\t\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t\t): () => void;\n\t}\n\n\t/**\n\t * Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.\n\t * @internal\n\t */\n\texport interface FormattedAtomInsertable<TFormat, TContent> {\n\t\treadonly content: TContent;\n\t\treadonly format: TFormat;\n\t}\n\n\t/**\n\t * Schema identifier for the a generic formatted text schema.\n\t * @privateRemarks\n\t * Eventually this should probably be given a better name and/or made a system type in a system namespace.\n\t * @internal\n\t */\n\texport type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<\n\t\t`com.fluidframework.text.formatted<${TUserScope}>`,\n\t\t\"Text\"\n\t>;\n\n\t/**\n\t * Helper for expressing the full set of formatted text atoms for a given schema.\n\t * @privateRemarks\n\t * Eventually this should probably be given a better name and/or made a system type in a system namespace.\n\t * @internal\n\t */\n\texport type FormattedTextAtoms<\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = readonly [typeof StringTextAtom, ...ExtraAtomsSchema];\n\n\t/**\n\t * Helper for configuring {@link FormattedTextAsTree.Members}.\n\t * @privateRemarks\n\t * Eventually this should probably be inlined into `FormattedTextAsTree.Members` or made a system type in a system namespace.\n\t * The approach should be evaluated after settling on a redesign of the `formatRange` API as that will impact what the type parameters are.\n\t * @internal\n\t */\n\texport type FormattedTextMembers<\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = Members<\n\t\tTreeFieldFromImplicitField<FormatSchema>,\n\t\tPartial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\tFormattedAtom<\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormattedTextAtoms<ExtraAtomsSchema>>\n\t\t>,\n\t\tFormattedAtomInsertable<\n\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<FormattedTextAtoms<ExtraAtomsSchema>>\n\t\t>\n\t>;\n\n\t/**\n\t * A generic type for a formatted text schema.\n\t * @internal\n\t */\n\texport type FormattedTextSchema<\n\t\tTUserScope extends string,\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = Statics<\n\t\tErasedNode<\n\t\t\tFormattedTextMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>\n\t> &\n\t\tErasedSchemaSubclassable<\n\t\t\tFormattedTextMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAA+F;AAC/F,uEAAsE;AAEtE,+CAM0B;AAC1B,4DAAqF;AACrF,sDAAwE;AACxE,sDAUiC;AAiBjC,+CAM0B;AAE1B,mDAKyB;AAEzB;;;GAGG;AACH,2HAA2H;AAC3H,SAAS,4BAA4B,CACpC,kBAAiD;IAEjD,OAAO,IAAA,sDAA2C,EAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAI,6BAAkB,CAAC,mCAAmC,CAAC,CAAC;AAE7E,MAAM,SAAS,GAAa,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAa,kBACZ,SAAQ,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE;IACzC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,CAAC,wBAAa,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;CAC1E,CAAC;IAGK,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,I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CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;YACzD,MAAM,EAAE,wBAAa,CAAC,QAAQ,CAAC,YAAY,CAAC;SAC5C,CAAC;SAKG;QAEN;;;;;;;;;;;WAWG;QACH,MAAM,IAAI,GAAG,IAAA,yCAA8B,GAGxC,CAAC,QAAQ,CAAC,CAAC;QAMd,OAAO,IAAI,CAAC;IACb,CAAC;IA7de,0BAAY,eA6d3B,CAAA;IA4DD;;;;OAIG;IACU,4BAAc,GAAG,IAAA,6BAAkB,GAAmC,CAClF,kBAAkB,CAClB,CAAC;AAqPH,CAAC,EA1yBgB,aAAa,6BAAb,aAAa,QA0yB7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachNodeSubsequence,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha, Tree as TreeStatic } from \"../shared-tree/index.js\";\nimport {\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n\tcreateCustomizedFluidFrameworkScopedFactory,\n\teraseSchemaDetails,\n\tisObjectNodeSchema,\n\teraseSchemaDetailsSubclassable,\n} from \"../simple-tree/index.js\";\nimport type {\n\tTreeNodeSchema,\n\tLazyItem,\n\tImplicitAllowedTypes,\n\tTreeFieldFromImplicitField,\n\tInsertableTypedNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tInsertableTreeFieldFromImplicitField,\n\tNodeKind,\n\tTreeNode,\n\tScopedSchemaName,\n\tErasedSchemaSubclassable,\n\tErasedNode,\n\tSchemaFactoryBeta,\n} from \"../simple-tree/index.js\";\nimport {\n\tbrand,\n\tmapIterable,\n\toneFromIterable,\n\tvalidateIndex,\n\tvalidateIndexRange,\n} from \"../util/index.js\";\n\nimport {\n\tcharactersFromString,\n\texpensiveInternalValidationAssert,\n\tprocessCharactersChangedDelta,\n\ttype PlainText,\n} from \"./textDomain.js\";\n\n/**\n * Sets up scope for formatted text schema built-in types.\n * @remarks User-provided factory scoping will be applied as `com.fluidframework.text.formatted<user-scope>`.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Inferring is the most practical option here\nfunction createFormattedScopedFactory<TUserScope extends string>(\n\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n) {\n\treturn createCustomizedFluidFrameworkScopedFactory(inputSchemaFactory, \"text.formatted\");\n}\n\n/**\n * Schema factory for formatted text types which are not generic.\n */\nconst sfStatic = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nconst formatKey: FieldKey = brand(\"format\");\n\n/**\n * Atom in the string containing a single character.\n * @privateRemarks\n * This is outside the namespace so it can be exported for testing, but not package exported.\n */\nexport class StringTextAtomNode\n\textends sfStatic.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single Unicode code point, and thus may contain multiple UTF-16 surrogate pair code units.\n\t\t * Longer strings are still valid. For example, users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead, atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t})\n\timplements FormattedText.TextAtom\n{\n\tpublic static fromCharacter(value: string): StringTextAtomNode {\n\t\tconst character = oneFromIterable(charactersFromString(value));\n\t\tif (character === undefined) {\n\t\t\tthrow new UsageError(\"value must contain exactly one Unicode character.\");\n\t\t}\n\t\treturn new StringTextAtomNode({ content: character });\n\t}\n\n\tpublic static fromString(value: string): StringTextAtomNode[] {\n\t\treturn Array.from(\n\t\t\tcharactersFromString(value),\n\t\t\t(character) => new StringTextAtomNode({ content: character }),\n\t\t);\n\t}\n}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n *\n * @remarks\n * This is generic over formatting an embedded object/atom types.\n *\n * @privateRemarks\n * See {@link FormattedTextDefault} for an example parameterization.\n *\n * TODO:\n * - Add more comprehensive tests for generic parameterizations other than default.\n * - Sort out API around overwriting subsets of formatting information.\n * @alpha\n */\nexport namespace FormattedText {\n\t/**\n\t * Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.\n\t *\n\t * @param inputSchemaFactory - The {@link SchemaFactoryBeta} used to scope the generated schema.\n\t * The generated types are scoped under `com.fluidframework.text.formatted<TUserScope>`, where `TUserScope` is the scope of this factory.\n\t * This scope is used to distinguish different usages of `createSchema` from each-other, and must be kept the same between versions for nodes to remain compatible.\n\t * It must be different to distinguish different formatted text schema within the same document.\n\t * @param formatSchema - Schema describing the formatting associated with each atom of text.\n\t * Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.\n\t * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.\n\t * Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.\n\t * @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs\n\t * (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).\n\t * @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.\n\t *\n\t * @privateRemarks\n\t * See {@link FormattedTextDefault} for an example parameterization of this factory.\n\t *\n\t * TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.\n\t */\n\texport function createSchema<\n\t\tconst TUserScope extends string,\n\t\tconst FormatSchema extends ImplicitAllowedTypes,\n\t\tconst ExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryBeta<TUserScope>,\n\t\tformatSchema: FormatSchema,\n\t\textraAtoms: ExtraAtomsSchema,\n\t\tdefaultFormatInsertable: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t): FormattedTextSchema<TUserScope, FormatSchema, ExtraAtomsSchema> {\n\t\tconst atoms = [StringTextAtom, ...extraAtoms] as const;\n\t\t/**\n\t\t * The type of a text atom node, which goes in a StringAtom.\n\t\t */\n\t\ttype TextAtomNode = TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>;\n\n\t\tconst sf = createFormattedScopedFactory(inputSchemaFactory);\n\n\t\tconst defaultFormat: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\tTreeBeta.create<FormatSchema>(formatSchema, defaultFormatInsertable);\n\n\t\t/**\n\t\t * Gets a format node, which must be cloned before being inserted.\n\t\t */\n\t\tfunction getFormatNode(\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> {\n\t\t\t// Note we cannot use the `format ?? defaultFormat` syntax as format is allowed to be `null`.\n\t\t\treturn format === undefined\n\t\t\t\t? defaultFormat\n\t\t\t\t: TreeBeta.create<FormatSchema>(formatSchema, format);\n\t\t}\n\n\t\tfunction cloneFormat(\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): TreeFieldFromImplicitField<FormatSchema> &\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema> {\n\t\t\tconst clone: TreeFieldFromImplicitField<FormatSchema> =\n\t\t\t\tTreeBeta.clone<FormatSchema>(format);\n\t\t\t// TypeScript fails to prove that cloning a node gives a node, and not possible undefined (like cloning a empty field could).\n\t\t\t// This cast helps users of this function get the types they need.\n\t\t\treturn clone as typeof clone & TreeNodeFromImplicitAllowedTypes<FormatSchema>;\n\t\t}\n\n\t\tclass TextNode\n\t\t\textends sf.object(\"Text\", {\n\t\t\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t\t\t})\n\t\t\timplements Members<FormatSchema, ExtraAtomsSchema>\n\t\t{\n\t\t\tpublic insertAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters:\n\t\t\t\t\t| string\n\t\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst newAtoms: Iterable<TextAtomNode> =\n\t\t\t\t\ttypeof additionalCharacters === \"string\"\n\t\t\t\t\t\t? stringTextAtomsFromString(additionalCharacters)\n\t\t\t\t\t\t: additionalCharacters;\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\tthis.content.insertAt(\n\t\t\t\t\tindex,\n\t\t\t\t\tTreeArrayNode.spread(stringAtomsFromTextAtoms(newAtoms, formatNode)),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\t\t\tthis.content.removeRange(index, end);\n\t\t\t}\n\n\t\t\tpublic characters(): Iterable<string> {\n\t\t\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\tconst result = this.content.charactersCopy();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcompareArrays(result, this.#charactersCopy_reference()) ||\n\t\t\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic characterCount(): number {\n\t\t\t\treturn this.content.length;\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\tconst result = this.content.fullString();\n\t\t\t\texpensiveInternalValidationAssert(\n\t\t\t\t\t() => result === this.#fullString_reference() || \"invalid fullString optimizations\",\n\t\t\t\t);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A non-optimized reference implementation of fullString.\n\t\t\t */\n\t\t\t#fullString_reference(): string {\n\t\t\t\treturn [...this.characters()].join(\"\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Unoptimized trivially correct implementation of charactersCopy.\n\t\t\t */\n\t\t\t#charactersCopy_reference(): string[] {\n\t\t\t\treturn [...this.characters()];\n\t\t\t}\n\n\t\t\tpublic static fromString(\n\t\t\t\tvalue: string,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): TextNode {\n\t\t\t\tconst formatNode = getFormatNode(format);\n\t\t\t\t// Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.\n\t\t\t\treturn new this({\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t\t\t\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t\t\t\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\t\t\t\t\t...textAtomsFromString(value, formatNode),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic charactersWithFormatting(): readonly StringAtom[] {\n\t\t\t\treturn this.content;\n\t\t\t}\n\t\t\tpublic insertWithFormattingAt(\n\t\t\t\tindex: number,\n\t\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t\t): void {\n\t\t\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t\t\t}\n\n\t\t\tpublic formatRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t\t): void {\n\t\t\t\tconst fieldFormatsRaw = Object.entries(format) as [\n\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tunknown,\n\t\t\t\t][];\n\t\t\t\tconst fieldFormats = fieldFormatsRaw.map(([key, value]) => {\n\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\tassert(\n\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t);\n\t\t\t\t\treturn [key, value] as const;\n\t\t\t\t});\n\t\t\t\tthis.#editRange(start, end, \"FormattedText.formatRange\", (atom) => {\n\t\t\t\t\tconst formatNode: TreeNode | TreeValue = atom.format;\n\t\t\t\t\tconst atomFormatSchema = TreeStatic.schema(formatNode);\n\t\t\t\t\tif (!isObjectNodeSchema(atomFormatSchema)) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\"formatRange currently only supports object nodes for the format.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [key, value] of fieldFormats) {\n\t\t\t\t\t\tconst field = atomFormatSchema.fields.get(key);\n\t\t\t\t\t\tif (field === undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\t\t// Note that since this uses field schema, `undefined` can pass through this if allowed by the schema.\n\t\t\t\t\t\tconst clonedValue = TreeBeta.clone(TreeBeta.create(field, value as never)) as\n\t\t\t\t\t\t\t| TreeNode\n\t\t\t\t\t\t\t| TreeValue;\n\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformatNode as unknown as Record<\n\t\t\t\t\t\t\t\tkeyof TreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\t\t\t\tTreeNode | TreeValue\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t)[key] = clonedValue;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic reformat(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t\t): void {\n\t\t\t\tconst node = getFormatNode(format);\n\t\t\t\tthis.#editRange(start, end, \"FormattedText.reformat\", (atom) => {\n\t\t\t\t\tatom.format = cloneFormat(node);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Map an edit over a range of atoms, validating the range and running the edits in a transaction.\n\t\t\t * @remarks\n\t\t\t * This is not exposed in the API since this approach will have to be replaced when formatting is optimized,\n\t\t\t * so we don't want users to directly depend on this un-optimizable layer.\n\t\t\t */\n\t\t\t#editRange(\n\t\t\t\tstart: number | undefined,\n\t\t\t\tend: number | undefined,\n\t\t\t\tmethod: string,\n\t\t\t\tedit: (atom: StringAtom) => void,\n\t\t\t): void {\n\t\t\t\tconst formatStart = start ?? 0;\n\t\t\t\tvalidateIndex(formatStart, this.content, method, true);\n\n\t\t\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\t\t\tvalidateIndexRange(formatStart, formatEnd, this.content, method);\n\n\t\t\t\tTreeAlpha.context(this).runTransaction(() => {\n\t\t\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\t\t\tconst atom = this.content[i];\n\t\t\t\t\t\t// Range validated above, so this should never fail.\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tatom !== undefined,\n\t\t\t\t\t\t\t0xd08 /* Index out of bounds while formatting text range. */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tedit(atom);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.\n\t\t\t */\n\t\t\tprivate getAtomCharacterAt(index: number): string | undefined {\n\t\t\t\tconst atom = this.content[index];\n\t\t\t\tif (atom === undefined) return undefined;\n\t\t\t\treturn atom.content.content;\n\t\t\t}\n\n\t\t\tpublic onCharactersChanged(\n\t\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"nodeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic onContentChanged(\n\t\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t\t): () => void {\n\t\t\t\treturn TreeAlpha.on(this.content, \"treeChanged\", ({ delta }) =>\n\t\t\t\t\tprocessCharactersChangedDelta(\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\t\t\tcallback,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\t\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\t\t\treturn this.content.getString(startIndex, endIndex);\n\t\t\t}\n\t\t}\n\n\t\tfunction stringTextAtomsFromString(\n\t\t\tvalue: string,\n\t\t): Iterable<StringTextAtom & TextAtomNode> {\n\t\t\t// TypeScript can't prove in this Generic context that StringTextAtom is assignable to TextAtomNode, so we have to cast.\n\t\t\t// Since TextAtomSchemas unconditionally includes StringTextAtom, this cast is safe.\n\t\t\treturn StringTextAtom.fromString(value) as (StringTextAtom & TextAtomNode)[];\n\t\t}\n\n\t\tfunction stringAtomsFromTextAtoms(\n\t\t\tvalue: Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst result = mapIterable(value, (content) => {\n\t\t\t\tconst data = {\n\t\t\t\t\tcontent,\n\t\t\t\t\tformat: cloneFormat(format),\n\t\t\t\t};\n\t\t\t\treturn new StringAtom(data as never); // Generic break type safety here. TODO: try and make safer.\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\n\t\tfunction textAtomsFromString(\n\t\t\tvalue: string,\n\t\t\tformat: TreeFieldFromImplicitField<FormatSchema>,\n\t\t): Iterable<StringAtom> {\n\t\t\tconst textAtoms = stringTextAtomsFromString(value);\n\t\t\treturn stringAtomsFromTextAtoms(textAtoms, format);\n\t\t}\n\n\t\tclass StringArray extends sf.array(\"StringArray\", [() => StringAtom]) {\n\t\t\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\t\t\tconst innerNode = getInnerNode(this);\n\t\t\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t\t\t// treat it as if it observed the whole subtree.\n\t\t\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\t\t\tconst cursor = innerNode.borrowCursor();\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tconst result = f(cursor);\n\t\t\t\tcursor.exitField();\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\t\t\tconst slowPathIndexes: number[] = [];\n\t\t\t\tconst result: string[] = [];\n\t\t\t\tthis.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\t(cursor.type as string) === StringAtom.identifier ||\n\t\t\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tlet content: string;\n\t\t\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\t\t\tcase StringTextAtom.identifier: {\n\t\t\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.\n\t\t\t\t\t\t\t// A less general optimization could just include cases for build in types with constant values\n\t\t\t\t\t\t\t// (like below commented code: currently this would cause a cyclical dependency but could be refactored).\n\t\t\t\t\t\t\t// case FormattedText.StringLineAtom.identifier: {\n\t\t\t\t\t\t\t// \tcontent = \"\\n\";\n\t\t\t\t\t\t\t// \tbreak;\n\t\t\t\t\t\t\t// }\n\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\tslowPathIndexes.push(result.length);\n\t\t\t\t\t\t\t\tcontent = \"\"; // Placeholder for slow path content\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tresult.push(content);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Fill in slow path cases not optimized above.\n\t\t\t\tfor (const index of slowPathIndexes) {\n\t\t\t\t\tconst node =\n\t\t\t\t\t\tthis[index + startIndex] ??\n\t\t\t\t\t\tfail(\n\t\t\t\t\t\t\t0xd09 /* getCharactersSubarray failed to find index after index range was checked */,\n\t\t\t\t\t\t);\n\t\t\t\t\tresult[index] = node.content.content;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tpublic charactersCopy(): string[] {\n\t\t\t\treturn this.getCharactersSubarray(0, this.length);\n\t\t\t}\n\n\t\t\tpublic fullString(): string {\n\t\t\t\treturn this.charactersCopy().join(\"\");\n\t\t\t}\n\n\t\t\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedText.getString\");\n\t\t\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t\t\t}\n\n\t\t\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\t\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedText.getUniformRun\");\n\t\t\t\tif (endIndex === startIndex) {\n\t\t\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t\t\t}\n\t\t\t\tconst arrayLength = this.length;\n\t\t\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t\t\t// Capture the content type of the first atom\n\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst contentType = cursor.type;\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t\t\t// This compares by field key\n\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\tlet runLength = 1;\n\t\t\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t\t\t// Compare atom type\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tif (!typeMatches) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\n\t\t\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trunLength++;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\treturn runLength;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * A unit of the text, with formatting.\n\t\t */\n\t\tclass StringAtom\n\t\t\textends sf.object(\"StringAtom\", {\n\t\t\t\tcontent: SchemaFactory.required(atoms, { key: EmptyKey }),\n\t\t\t\tformat: SchemaFactory.required(formatSchema),\n\t\t\t})\n\t\t\timplements\n\t\t\t\tFormattedAtom<\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tTreeNodeFromImplicitAllowedTypes<typeof atoms>\n\t\t\t\t> {}\n\n\t\t/**\n\t\t * Schema for a text node.\n\t\t * @remarks\n\t\t * See {@link FormattedText.Members} for the API.\n\t\t * See {@link FormattedText.Statics} for static APIs on this Schema, including construction.\n\t\t * @privateRemarks\n\t\t * eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.\n\t\t * Ideally we would generate private members for non-public properties, but TypeScript does not support this.\n\t\t * It is up to the user of eraseSchemaDetailsSubclassable to manage this risk.\n\t\t *\n\t\t * TODO: there is at least one collision prone member to worry about here: `content`.\n\t\t */\n\t\tconst Tree = eraseSchemaDetailsSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tStatics<Tree, FormatSchema>\n\t\t>()(TextNode);\n\t\ttype Tree = ErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n\n\t\treturn Tree;\n\t}\n\n\t/**\n\t * Portion of a string with formatting.\n\t * @privateRemarks\n\t * This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to\n\t * preserve more future flexibility.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface FormattedAtom<TFormat, TText> {\n\t\t/**\n\t\t * Content which is formatted.\n\t\t */\n\t\treadonly content: TText;\n\t\t/**\n\t\t * Formatting which is applied to the content.\n\t\t * @remarks\n\t\t * Can be reassigned or deeply mutated to edit the formatting of the content.\n\t\t */\n\t\tformat: TFormat;\n\t}\n\n\t/**\n\t * Portion of a string.\n\t * @remarks\n\t * Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.\n\t * The schema for them can then be provided to {@link FormattedText.createSchema}.\n\t * @alpha\n\t */\n\texport interface TextAtom {\n\t\t/**\n\t\t * The content of the text atom, viewed as a string.\n\t\t */\n\t\treadonly content: string;\n\t}\n\n\t/**\n\t * Static factory functions for {@link FormattedText.(StringTextAtom:variable)}.\n\t * @privateRemarks\n\t * We type-erase `StringTextAtom` and only provide these static factories for construction\n\t * to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.\n\t * Other strings should work, but our intention is to provide no type-safe API which can produce them, so an application can take their lack of existence as an invariant if they want.\n\t * It is still however possible to produce them, like export/import round trips with editing in the middle of the process, or collaboration with an equivalent schema which doesn't enforce this invariant.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface StringTextAtomStatics {\n\t\t/**\n\t\t * Creates an atom from exactly one Unicode code point.\n\t\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if `value` does not contain exactly one Unicode code character.\n\t\t */\n\t\tfromCharacter(value: string): StringTextAtom;\n\n\t\t/**\n\t\t * Creates one atom for each Unicode code point in `value`.\n\t\t */\n\t\tfromString(value: string): StringTextAtom[];\n\t}\n\n\t/**\n\t * Schema for a {@link FormattedText.(StringTextAtom:variable)} node.\n\t * @sealed\n\t * @alpha\n\t */\n\texport const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(\n\t\tStringTextAtomNode,\n\t);\n\n\t/**\n\t * Node for the {@link FormattedText.(StringTextAtom:variable)} schema.\n\t * @sealed\n\t * @alpha\n\t */\n\texport type StringTextAtom = ErasedNode<\n\t\tTextAtom,\n\t\t\"com.fluidframework.text.formatted.StringTextAtom\"\n\t>;\n\n\t/**\n\t * Statics for formatted text nodes.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {\n\t\t/**\n\t\t * Construct a node of `this` schema from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(\n\t\t\tvalue: string,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): TTree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedText.Statics.fromString} for construction.\n\t * @see {@link FormattedText.createSchema} for creating schemas whose nodes implement this.\n\t * @sealed\n\t * @alpha\n\t */\n\texport interface Members<\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> extends PlainText.Members {\n\t\t/**\n\t\t * {@link PlainText.Members.insertAt} with optional formatting to apply to all additional characters,\n\t\t * and allowing an array of atoms instead of a string.\n\t\t * @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedText.createSchema}) will be used.\n\t\t * @remarks\n\t\t * Use {@link FormattedText.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.\n\t\t * @override\n\t\t */\n\t\tinsertAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters:\n\t\t\t\t| string\n\t\t\t\t| Iterable<TreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>>,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t *\n\t\t * For more efficient access, use {@link FormattedText.Members.getUniformRun} and {@link FormattedText.Members.getString} to access ranges of characters\n\t\t * to avoid having to inspect the formatting on every atom.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly FormattedAtom<\n\t\t\tTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\tTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t>[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedText.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<\n\t\t\t\tFormattedAtomInsertable<\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<FormatSchema>,\n\t\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas<ExtraAtomsSchema>>\n\t\t\t\t>\n\t\t\t>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * For each atom, every property of `format` will be cloned and assigned to the atom's format's corresponding subtree, overwriting any existing values for those properties.\n\t\t * All enumerable own properties of `format` will be applied, including those with `undefined` values.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t * This edits existing formatting subtrees on each atom, and only works when those atoms are object nodes.\n\t\t *\n\t\t * This is typically used to set some formatting property, like `bold` on a range of text without impacting other formatting properties.\n\t\t * @privateRemarks\n\t\t * This API is designed such that it can be optimized and improved in the future in a few different ways:\n\t\t * 1. TODO: It can be optimized to use lower level APIs directly, bypassing the overhead of the public API surface.\n\t\t * 2. TODO: A lower level editing API could be introduced and used to more efficiently express the edit (for example a bulk edit based on path, or a way to reuse the inserted content in multiple places instead of having to clone it before making the edit).\n\t\t * 3. TODO: Optimize the encoding of such edits, either with a dedicated format for range edits like this and/or encoding optimizations that can compress such edits over ranges to O(1) space.\n\t\t * 4. TODO: Preserve the range editing semantics through the whole stack to allow for better merge behavior, and make optimizations easier.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: Partial<TreeNodeFromImplicitAllowedTypes<FormatSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Replace formatting of a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to replace the formatting of the indicated range with.\n\t\t * For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.\n\t\t * If not specified the `defaultFormat` from {@link FormattedText.createSchema} will be used.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t *\n\t\t * This is typically used to normalize formatting, like resetting the formatting of a range to default settings.\n\t\t * @privateRemarks\n\t\t * See notes on {@link FormattedText.Members.formatRange} for future optimization opportunities.\n\t\t */\n\t\treformat(\n\t\t\tstartIndex?: number | undefined,\n\t\t\tendIndex?: number | undefined,\n\t\t\tformat?: InsertableTreeFieldFromImplicitField<FormatSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Returns the length of the run of characters starting at `startIndex` which have the same formatting and atom type, up to `endIndex`.\n\t\t * @param startIndex - The starting index of the run.\n\t\t * @param endIndex - The ending index (exclusive) of the run. Defaults to the end of the text.\n\t\t */\n\t\tgetUniformRun(startIndex: number, endIndex?: number): number;\n\t\t/**\n\t\t * Returns a substring of the text from `startIndex` to `endIndex`\n\t\t * @param startIndex - starting index (inclusive)\n\t\t * @param endIndex - Optional ending index (exclusive). Defaults to the end of the text.\n\t\t */\n\t\tgetString(startIndex: number, endIndex?: number): string;\n\n\t\t/**\n\t\t * Subscribe to all content changes on this text node, including both shallow\n\t\t * changes (inserts/removes) and deep changes (formatting updates on existing characters).\n\t\t * @param callback - Called after each change with a sequence of {@link PlainText.TextOp}s describing what changed,\n\t\t * or `undefined` when a delta could not be computed (e.g. during a schema upgrade).\n\t\t * @returns A cleanup function that unsubscribes the callback when called.\n\t\t * @remarks\n\t\t * Unlike {@link PlainText.Members.onCharactersChanged} which only fires on\n\t\t * shallow changes (inserts and removes), this method also fires on deep changes —\n\t\t * formatting property updates on existing characters.\n\t\t * The {@link PlainText.TextRetainOp.formattingChanged} flag on retain ops\n\t\t * indicates which character ranges had formatting updates.\n\t\t *\n\t\t * All counts in the delivered ops are in Unicode code points, not UTF-16 code units.\n\t\t * For characters outside the Basic Multilingual Plane (e.g. emoji), one code point\n\t\t * corresponds to two UTF-16 code units — convert before using the counts as string indices.\n\t\t */\n\t\tonContentChanged(\n\t\t\tcallback: (ops: readonly PlainText.TextOp[] | undefined) => void,\n\t\t): () => void;\n\t}\n\n\t/**\n\t * Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.\n\t * @input\n\t * @alpha\n\t */\n\texport interface FormattedAtomInsertable<TFormat, TContent> {\n\t\treadonly content: TContent;\n\t\treadonly format: TFormat;\n\t}\n\n\t/**\n\t * Schema identifier for the a generic formatted text schema.\n\t * @privateRemarks\n\t * Eventually this should probably be given a better name and/or made a system type in a system namespace.\n\t * @alpha\n\t */\n\texport type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<\n\t\t`com.fluidframework.text.formatted<${TUserScope}>`,\n\t\t\"Text\"\n\t>;\n\n\t/**\n\t * Helper for expressing the full set of text atoms for a given schema.\n\t * @remarks\n\t * This is just schema for the text atom {@link AllowedTypes},\n\t * and does not include the actual formatting (which is higher up in the tree).\n\t * @sealed\n\t * @alpha\n\t */\n\texport type TextAtomSchemas<\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = readonly [typeof StringTextAtom, ...ExtraAtomsSchema];\n\n\t/**\n\t * A generic type for a formatted text schema.\n\t * @sealed\n\t * @alpha\n\t */\n\texport type FormattedTextSchema<\n\t\tTUserScope extends string,\n\t\tFormatSchema extends ImplicitAllowedTypes,\n\t\tExtraAtomsSchema extends readonly LazyItem<\n\t\t\tTreeNodeSchema<string, NodeKind, TextAtom & TreeNode>\n\t\t>[],\n\t> = Statics<\n\t\tErasedNode<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>,\n\t\tFormatSchema\n\t> &\n\t\tErasedSchemaSubclassable<\n\t\t\tMembers<FormatSchema, ExtraAtomsSchema>,\n\t\t\tFormattedTextSchemaIdentifier<TUserScope>\n\t\t>;\n}\n"]}
|