@fluidframework/tree 2.101.1 → 2.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/api-report/tree.alpha.api.md +19 -0
- package/dist/codec/codec.d.ts +22 -53
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +7 -44
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +56 -28
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +29 -12
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -2
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/tree/deltaUtil.d.ts +2 -2
- package/dist/core/tree/deltaUtil.js +2 -2
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -2
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +62 -4
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +18 -4
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +106 -3
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +9 -3
- package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +44 -0
- package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js +5 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js +7 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +1 -2
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +5 -4
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +2 -2
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +2 -2
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +1 -1
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- 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/isAuditableFromOutcome.d.ts +20 -0
- package/dist/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
- package/dist/shared-tree/isAuditableFromOutcome.js +36 -0
- package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -0
- package/dist/shared-tree/treeCheckout.d.ts +2 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +37 -8
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +2 -2
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +3 -3
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +2 -2
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +25 -11
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/text/codePointUtils.d.ts +48 -0
- package/dist/text/codePointUtils.d.ts.map +1 -0
- package/dist/text/codePointUtils.js +80 -0
- package/dist/text/codePointUtils.js.map +1 -0
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +4 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/textDomain.d.ts +93 -1
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +65 -8
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +24 -6
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +29 -1
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +9 -7
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +7 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +18 -4
- package/dist/util/breakable.js.map +1 -1
- package/lib/codec/codec.d.ts +22 -53
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +7 -44
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +56 -28
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +27 -10
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/tree/deltaUtil.d.ts +2 -2
- package/lib/core/tree/deltaUtil.js +2 -2
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +5 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +2 -2
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +61 -4
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +20 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +102 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +8 -2
- package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js +41 -0
- package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js +2 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js +6 -0
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +2 -3
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +5 -4
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +3 -3
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +2 -2
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +2 -2
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- 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/isAuditableFromOutcome.d.ts +20 -0
- package/lib/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
- package/lib/shared-tree/isAuditableFromOutcome.js +32 -0
- package/lib/shared-tree/isAuditableFromOutcome.js.map +1 -0
- package/lib/shared-tree/treeCheckout.d.ts +2 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +37 -8
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +3 -3
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +3 -3
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +3 -3
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +25 -11
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/text/codePointUtils.d.ts +48 -0
- package/lib/text/codePointUtils.d.ts.map +1 -0
- package/lib/text/codePointUtils.js +75 -0
- package/lib/text/codePointUtils.js.map +1 -0
- package/lib/text/index.d.ts +1 -0
- package/lib/text/index.d.ts.map +1 -1
- package/lib/text/index.js +1 -0
- package/lib/text/index.js.map +1 -1
- package/lib/text/textDomain.d.ts +93 -1
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +56 -0
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +24 -6
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +30 -2
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +2 -0
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +7 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +18 -4
- package/lib/util/breakable.js.map +1 -1
- package/package.json +24 -24
- package/src/codec/codec.ts +82 -73
- package/src/codec/index.ts +2 -1
- package/src/codec/versioned/codec.ts +173 -73
- package/src/codec/versioned/index.ts +2 -1
- package/src/core/tree/deltaUtil.ts +2 -2
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -2
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -3
- package/src/core/tree/detachedFieldIndexCodecs.ts +2 -2
- package/src/feature-libraries/chunked-forest/chunkTree.ts +85 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +27 -7
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +143 -7
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +30 -28
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +7 -7
- package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +11 -7
- package/src/feature-libraries/chunked-forest/codec/format/formatVText.ts +83 -0
- package/src/feature-libraries/chunked-forest/codec/format/index.ts +6 -1
- package/src/feature-libraries/chunked-forest/codec/format/versions.ts +25 -4
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +14 -18
- package/src/feature-libraries/forest-summary/codec.ts +9 -4
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +1 -1
- package/src/feature-libraries/schema-index/codec.ts +2 -5
- package/src/index.ts +6 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/isAuditableFromOutcome.ts +34 -0
- package/src/shared-tree/treeCheckout.ts +52 -9
- package/src/shared-tree-core/editManagerCodecs.ts +4 -6
- package/src/shared-tree-core/messageCodecs.ts +4 -4
- package/src/simple-tree/core/treeNodeKernel.ts +27 -13
- package/src/text/codePointUtils.ts +81 -0
- package/src/text/index.ts +1 -0
- package/src/text/textDomain.ts +155 -2
- package/src/text/textDomainFormatted.ts +73 -2
- package/src/treeFactory.ts +5 -0
- package/src/util/breakable.ts +27 -6
|
@@ -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,+CAK0B;AAC1B,4DAAqF;AACrF,sDAAoD;AACpD,sDAQiC;AAOjC,+CAAyF;AAEzF,mDAAwE;AAExE,MAAM,EAAE,GAAG,IAAI,6BAAkB,CAAC,mCAAmC,CAAC,CAAC;AAEvE,MAAM,QACL,SAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;IACzB,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EA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IAED;;;OAGG;IACU,qCAAiB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAU,CAAC;IAO3E;;;OAGG;IACH,MAAa,UAAW,SAAQ,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE;QACvD,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,oBAAA,iBAAiB,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;QACrE,MAAM,EAAE,eAAe;KACvB,CAAC;KAAG;IAHQ,8BAAU,aAGlB,CAAA;IAkGL;;;;;;OAMG;IACU,wBAAI,GAAG,IAAA,6BAAkB,GAAoB,CAAC,QAAQ,CAAC,CAAC;AAEtE,CAAC,EAtMgB,mBAAmB,mCAAnB,mBAAmB,QAsMnC","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} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha } from \"../shared-tree/index.js\";\nimport {\n\tenumFromStrings,\n\teraseSchemaDetails,\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n} from \"../simple-tree/index.js\";\nimport type {\n\tInsertableTypedNode,\n\tTreeNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tWithType,\n} from \"../simple-tree/index.js\";\nimport { brand, mapIterable, validateIndex, validateIndexRange } from \"../util/index.js\";\n\nimport { charactersFromString, type TextAsTree } from \"./textDomain.js\";\n\nconst sf = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nclass TextNode\n\textends sf.object(\"Text\", {\n\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.Members\n{\n\tpublic defaultFormat: FormattedTextAsTree.CharacterFormat =\n\t\tnew FormattedTextAsTree.CharacterFormat(defaultFormat);\n\n\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\tthis.content.insertAt(\n\t\t\tindex,\n\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t);\n\t}\n\n\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\tthis.content.removeRange(index, end);\n\t}\n\n\tpublic characters(): Iterable<string> {\n\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\tconst result = this.content.charactersCopy();\n\t\tdebugAssert(\n\t\t\t() =>\n\t\t\t\tcompareArrays(result, this.charactersCopy_reference()) ||\n\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\tpublic characterCount(): number {\n\t\treturn this.content.length;\n\t}\n\n\tpublic fullString(): string {\n\t\tconst result = this.content.fullString();\n\t\tdebugAssert(\n\t\t\t() => result === this.fullString_reference() || \"invalid fullString optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * A non-optimized reference implementation of fullString.\n\t */\n\tpublic fullString_reference(): string {\n\t\treturn [...this.characters()].join(\"\");\n\t}\n\n\t/**\n\t * Unoptimized trivially correct implementation of charactersCopy.\n\t */\n\tpublic charactersCopy_reference(): string[] {\n\t\treturn [...this.characters()];\n\t}\n\n\tpublic static fromString(\n\t\tvalue: string,\n\t\tformat?: FormattedTextAsTree.CharacterFormat,\n\t): TextNode {\n\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// 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// Thus the array construction here is necessary to avoid a runtime error.\n\t\treturn new TextNode({\n\t\t\tcontent: [\n\t\t\t\t...textAtomsFromString(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformat ?? new FormattedTextAsTree.CharacterFormat(defaultFormat),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic charactersWithFormatting(): readonly FormattedTextAsTree.StringAtom[] {\n\t\treturn this.content;\n\t}\n\tpublic insertWithFormattingAt(\n\t\tindex: number,\n\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof FormattedTextAsTree.StringAtom>>,\n\t): void {\n\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t}\n\tpublic formatRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tformat: Partial<FormattedTextAsTree.CharacterFormat>,\n\t): void {\n\t\tconst formatStart = start ?? 0;\n\t\tvalidateIndex(formatStart, this.content, \"FormattedTextAsTree.formatRange\", true);\n\n\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\tvalidateIndexRange(\n\t\t\tformatStart,\n\t\t\tformatEnd,\n\t\t\tthis.content,\n\t\t\t\"FormattedTextAsTree.formatRange\",\n\t\t);\n\n\t\tconst branch = TreeAlpha.branch(this);\n\n\t\tconst applyFormatting = (): void => {\n\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\tconst atom = this.content[i];\n\t\t\t\tif (atom === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Index out of bounds while formatting text range.\");\n\t\t\t\t}\n\t\t\t\tfor (const [key, value] of Object.entries(format) as [\n\t\t\t\t\tkeyof FormattedTextAsTree.CharacterFormat,\n\t\t\t\t\tunknown,\n\t\t\t\t][]) {\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\tconst f = FormattedTextAsTree.CharacterFormat.fields.get(key);\n\t\t\t\t\tif (f === undefined) {\n\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t}\n\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\tatom.format[key] = TreeBeta.clone(TreeBeta.create(f, value as never)) as never;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (branch === undefined) {\n\t\t\t// If this node does not have a corresponding branch, then it is unhydrated.\n\t\t\t// I.e., it is not part of a collaborative session yet.\n\t\t\t// Therefore, we don't need to run the edits as a transaction.\n\t\t\tapplyFormatting();\n\t\t} else {\n\t\t\t// Wrap all formatting operations in a single transaction for atomicity.\n\t\t\tbranch.runTransaction(() => {\n\t\t\t\tapplyFormatting();\n\t\t\t});\n\t\t}\n\t}\n\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t}\n\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\treturn this.content.getString(startIndex, endIndex);\n\t}\n}\n\nconst defaultFormat = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tsize: 12,\n\tfont: \"Arial\",\n} as const;\n\nconst formatKey: FieldKey = brand(\"format\");\n\nfunction textAtomsFromString(\n\tvalue: string,\n\tformat: FormattedTextAsTree.CharacterFormat,\n): Iterable<FormattedTextAsTree.StringAtom> {\n\tconst result = mapIterable(\n\t\tcharactersFromString(value),\n\t\t(char) =>\n\t\t\tnew FormattedTextAsTree.StringAtom({\n\t\t\t\tcontent: { content: char },\n\t\t\t\tformat: TreeBeta.clone<typeof FormattedTextAsTree.CharacterFormat>(format),\n\t\t\t}),\n\t);\n\treturn result;\n}\n\nclass StringArray extends sf.array(\"StringArray\", [() => FormattedTextAsTree.StringAtom]) {\n\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\tconst innerNode = getInnerNode(this);\n\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t// treat it as if it observed the whole subtree.\n\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\tconst cursor = innerNode.borrowCursor();\n\t\tcursor.enterField(EmptyKey);\n\t\tconst result = f(cursor);\n\t\tcursor.exitField();\n\t\treturn result;\n\t}\n\n\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tconst result: string[] = [];\n\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcursor.type === FormattedTextAsTree.StringAtom.identifier ||\n\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t);\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tlet content: string;\n\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\tcase FormattedTextAsTree.StringTextAtom.identifier: {\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\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\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\tcontent = \"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tfail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tresult.push(content);\n\t\t\t});\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\treturn this.getCharactersSubarray(0, this.length);\n\t}\n\n\tpublic fullString(): string {\n\t\treturn this.charactersCopy().join(\"\");\n\t}\n\n\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getString\");\n\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t}\n\n\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getUniformRun\");\n\t\tif (endIndex === startIndex) {\n\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t}\n\t\tconst arrayLength = this.length;\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t// Capture the content type of the first atom\n\t\t\tcursor.enterField(EmptyKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst contentType = cursor.type;\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t// This compares by field key\n\t\t\tcursor.enterField(formatKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\tlet runLength = 1;\n\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t// Compare atom type\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tif (!typeMatches) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\n\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\trunLength++;\n\t\t\t}\n\t\t\tcursor.exitNode();\n\t\t\treturn runLength;\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 * @privateRemarks\n * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.\n * We will want to generalize this with a more generic schema factory function like with table.\n * Then either that and/or the output from it can be package exported.\n * This version is just an initial prototype.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Formatting options for characters.\n\t * @internal\n\t */\n\texport class CharacterFormat extends sf.objectAlpha(\"CharacterFormat\", {\n\t\tbold: SchemaFactory.boolean,\n\t\titalic: SchemaFactory.boolean,\n\t\tunderline: SchemaFactory.boolean,\n\t\tsize: SchemaFactory.number,\n\t\tfont: SchemaFactory.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 extends sf.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 codepoint, and thus may contain multiple utf-16 surrogate pair code units.\n\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 * 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\n\t/**\n\t * Tag with which a line in text can be formatted from HTML.\n\t * @internal\n\t */\n\texport const LineTag = enumFromStrings(sf.scopedFactory(\"lineTag\"), [\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"li\",\n\t\t\"ol\",\n\t\t\"checked\",\n\t\t\"unchecked\",\n\t\t\"blockquote\",\n\t\t\"codeBlock\",\n\t]);\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(LineTag:variable)}\n\t * @internal\n\t */\n\texport type LineTag = TreeNodeFromImplicitAllowedTypes<typeof LineTag.schema>;\n\n\t/**\n\t * Unit in the string representing a new line character with line formatting.\n\t * @remarks\n\t * This aligns with how Quill represents line formatting.\n\t * Quill formats line attributes (headers, list, blockquote, etc... ) on the newline character\n\t * and only lines using this atom can have line-specific formatting.\n\t * The optional indent level mirrors Quill's indent attribute,\n\t * which is applies to the line before the line break.\n\t * Any tagged line can be indented independently.\n\t * @internal\n\t */\n\texport class StringLineAtom extends sf.object(\"StringLineAtom\", {\n\t\ttag: LineTag.schema,\n\t\tindent: SchemaFactory.number,\n\t}) {\n\t\tpublic readonly content = \"\\n\";\n\t}\n\n\t/**\n\t * Types of \"atoms\" that make up the text.\n\t * @internal\n\t */\n\texport const StringAtomContent = [StringTextAtom, StringLineAtom] as const;\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(StringAtomContent:variable)}\n\t * @internal\n\t */\n\texport type StringAtomContent = TreeNodeFromImplicitAllowedTypes<typeof StringAtomContent>;\n\n\t/**\n\t * A unit of the text, with formatting.\n\t * @internal\n\t */\n\texport class StringAtom extends sf.object(\"StringAtom\", {\n\t\tcontent: SchemaFactory.required(StringAtomContent, { key: EmptyKey }),\n\t\tformat: CharacterFormat,\n\t}) {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics {\n\t\t/**\n\t\t * Construct a {@link FormattedTextAsTree.(Tree:type)} 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): Tree;\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.(Tree:type)} for schema.\n\t * @internal\n\t */\n\texport interface Members extends 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: CharacterFormat;\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 StringAtom[];\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<InsertableTypedNode<typeof StringAtom>>,\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: Partial<CharacterFormat>,\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\t}\n\n\t/**\n\t * Schema for a text node.\n\t * @remarks\n\t * See {@link FormattedTextAsTree.Members} for the API.\n\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t * @internal\n\t */\n\texport const Tree = eraseSchemaDetails<Members, Statics>()(TextNode);\n\texport type Tree = Members & TreeNode & WithType<\"com.fluidframework.text.formatted.Text\">;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,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Aa,CAAC,MAAM;KAC5B,CAAC;QAHF;;YAIiB,YAAO,GAAG,IAAI,CAAC;QAChC,CAAC;KAAA;IALY,kCAAc,iBAK1B,CAAA;IAED;;;OAGG;IACU,qCAAiB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAU,CAAC;IAO3E;;;OAGG;IACH,MAAa,UAAW,SAAQ,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE;QACvD,OAAO,EAAE,wBAAa,CAAC,QAAQ,CAAC,oBAAA,iBAAiB,EAAE,EAAE,GAAG,EAAE,mBAAQ,EAAE,CAAC;QACrE,MAAM,EAAE,eAAe;KACvB,CAAC;KAAG;IAHQ,8BAAU,aAGlB,CAAA;IAuHL;;;;;;OAMG;IACU,wBAAI,GAAG,IAAA,6BAAkB,GAAoB,CAAC,QAAQ,CAAC,CAAC;AAEtE,CAAC,EA3NgB,mBAAmB,mCAAnB,mBAAmB,QA2NnC","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} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha } from \"../shared-tree/index.js\";\nimport {\n\tenumFromStrings,\n\teraseSchemaDetails,\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n} from \"../simple-tree/index.js\";\nimport type {\n\tInsertableTypedNode,\n\tTreeNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tWithType,\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\nconst sf = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nclass TextNode\n\textends sf.object(\"Text\", {\n\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.Members\n{\n\tpublic defaultFormat: FormattedTextAsTree.CharacterFormat =\n\t\tnew FormattedTextAsTree.CharacterFormat(defaultFormat);\n\n\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\tthis.content.insertAt(\n\t\t\tindex,\n\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t);\n\t}\n\n\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\tthis.content.removeRange(index, end);\n\t}\n\n\tpublic characters(): Iterable<string> {\n\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\tconst result = this.content.charactersCopy();\n\t\tdebugAssert(\n\t\t\t() =>\n\t\t\t\tcompareArrays(result, this.charactersCopy_reference()) ||\n\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\tpublic characterCount(): number {\n\t\treturn this.content.length;\n\t}\n\n\tpublic fullString(): string {\n\t\tconst result = this.content.fullString();\n\t\tdebugAssert(\n\t\t\t() => result === this.fullString_reference() || \"invalid fullString optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * A non-optimized reference implementation of fullString.\n\t */\n\tpublic fullString_reference(): string {\n\t\treturn [...this.characters()].join(\"\");\n\t}\n\n\t/**\n\t * Unoptimized trivially correct implementation of charactersCopy.\n\t */\n\tpublic charactersCopy_reference(): string[] {\n\t\treturn [...this.characters()];\n\t}\n\n\tpublic static fromString(\n\t\tvalue: string,\n\t\tformat?: FormattedTextAsTree.CharacterFormat,\n\t): TextNode {\n\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// 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// Thus the array construction here is necessary to avoid a runtime error.\n\t\treturn new TextNode({\n\t\t\tcontent: [\n\t\t\t\t...textAtomsFromString(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformat ?? new FormattedTextAsTree.CharacterFormat(defaultFormat),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic charactersWithFormatting(): readonly FormattedTextAsTree.StringAtom[] {\n\t\treturn this.content;\n\t}\n\tpublic insertWithFormattingAt(\n\t\tindex: number,\n\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof FormattedTextAsTree.StringAtom>>,\n\t): void {\n\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t}\n\tpublic formatRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tformat: Partial<FormattedTextAsTree.CharacterFormat>,\n\t): void {\n\t\tconst formatStart = start ?? 0;\n\t\tvalidateIndex(formatStart, this.content, \"FormattedTextAsTree.formatRange\", true);\n\n\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\tvalidateIndexRange(\n\t\t\tformatStart,\n\t\t\tformatEnd,\n\t\t\tthis.content,\n\t\t\t\"FormattedTextAsTree.formatRange\",\n\t\t);\n\n\t\tconst branch = TreeAlpha.branch(this);\n\n\t\tconst applyFormatting = (): void => {\n\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\tconst atom = this.content[i];\n\t\t\t\tif (atom === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Index out of bounds while formatting text range.\");\n\t\t\t\t}\n\t\t\t\tfor (const [key, value] of Object.entries(format) as [\n\t\t\t\t\tkeyof FormattedTextAsTree.CharacterFormat,\n\t\t\t\t\tunknown,\n\t\t\t\t][]) {\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\tconst f = FormattedTextAsTree.CharacterFormat.fields.get(key);\n\t\t\t\t\tif (f === undefined) {\n\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t}\n\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\tatom.format[key] = TreeBeta.clone(TreeBeta.create(f, value as never)) as never;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (branch === undefined) {\n\t\t\t// If this node does not have a corresponding branch, then it is unhydrated.\n\t\t\t// I.e., it is not part of a collaborative session yet.\n\t\t\t// Therefore, we don't need to run the edits as a transaction.\n\t\t\t// Note: for unhydrated nodes each atom edit fires a separate `treeChanged` event,\n\t\t\t// so formatting N atoms will produce N callbacks on `onContentChanged` subscribers\n\t\t\t// instead of the single callback that hydrated (transacted) edits produce.\n\t\t\t// `withBufferedTreeEvents` is not a viable mitigation here: when more than one atom's\n\t\t\t// `format` field changes within the same buffered scope, the kernel's per-field\n\t\t\t// dedup logic discards the delta (see `treeNodeKernel.ts` `#fieldMarksBuffer`),\n\t\t\t// which is worse for incremental consumers than N well-formed callbacks.\n\t\t\t// Use `runTransaction` on a hydrated node (i.e. after inserting into the document)\n\t\t\t// if batched events matter.\n\t\t\tapplyFormatting();\n\t\t} else {\n\t\t\t// Wrap all formatting operations in a single transaction for atomicity.\n\t\t\tbranch.runTransaction(() => {\n\t\t\t\tapplyFormatting();\n\t\t\t});\n\t\t}\n\t}\n\t/**\n\t * Returns the character string at the given atom index, or `undefined` if out of bounds.\n\t * @remarks\n\t * Line atoms expand to `\"\\n\"`; text atoms return their underlying code point(s).\n\t */\n\tprivate getAtomCharacterAt(index: number): string | undefined {\n\t\tconst atom = this.content[index];\n\t\tif (atom === undefined) return undefined;\n\t\treturn atom.content instanceof FormattedTextAsTree.StringLineAtom\n\t\t\t? \"\\n\"\n\t\t\t: atom.content.content;\n\t}\n\n\tpublic onCharactersChanged(\n\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t): () => void {\n\t\treturn TreeAlpha.on(this.content, \"nodeChanged\", ({ delta }) =>\n\t\t\tprocessCharactersChangedDelta(\n\t\t\t\tdelta,\n\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\tcallback,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic onContentChanged(\n\t\tcallback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,\n\t): () => void {\n\t\treturn TreeAlpha.on(this.content, \"treeChanged\", ({ delta }) =>\n\t\t\tprocessCharactersChangedDelta(\n\t\t\t\tdelta,\n\t\t\t\t(index) => this.getAtomCharacterAt(index),\n\t\t\t\tcallback,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t}\n\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\treturn this.content.getString(startIndex, endIndex);\n\t}\n}\n\nconst defaultFormat = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tsize: 12,\n\tfont: \"Arial\",\n} as const;\n\nconst formatKey: FieldKey = brand(\"format\");\n\nfunction textAtomsFromString(\n\tvalue: string,\n\tformat: FormattedTextAsTree.CharacterFormat,\n): Iterable<FormattedTextAsTree.StringAtom> {\n\tconst result = mapIterable(\n\t\tcharactersFromString(value),\n\t\t(char) =>\n\t\t\tnew FormattedTextAsTree.StringAtom({\n\t\t\t\tcontent: { content: char },\n\t\t\t\tformat: TreeBeta.clone<typeof FormattedTextAsTree.CharacterFormat>(format),\n\t\t\t}),\n\t);\n\treturn result;\n}\n\nclass StringArray extends sf.array(\"StringArray\", [() => FormattedTextAsTree.StringAtom]) {\n\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\tconst innerNode = getInnerNode(this);\n\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t// treat it as if it observed the whole subtree.\n\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\tconst cursor = innerNode.borrowCursor();\n\t\tcursor.enterField(EmptyKey);\n\t\tconst result = f(cursor);\n\t\tcursor.exitField();\n\t\treturn result;\n\t}\n\n\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tconst result: string[] = [];\n\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcursor.type === FormattedTextAsTree.StringAtom.identifier ||\n\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t);\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tlet content: string;\n\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\tcase FormattedTextAsTree.StringTextAtom.identifier: {\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\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\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\tcontent = \"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tfail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tresult.push(content);\n\t\t\t});\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\treturn this.getCharactersSubarray(0, this.length);\n\t}\n\n\tpublic fullString(): string {\n\t\treturn this.charactersCopy().join(\"\");\n\t}\n\n\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getString\");\n\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t}\n\n\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getUniformRun\");\n\t\tif (endIndex === startIndex) {\n\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t}\n\t\tconst arrayLength = this.length;\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t// Capture the content type of the first atom\n\t\t\tcursor.enterField(EmptyKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst contentType = cursor.type;\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t// This compares by field key\n\t\t\tcursor.enterField(formatKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\tlet runLength = 1;\n\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t// Compare atom type\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tif (!typeMatches) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\n\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\trunLength++;\n\t\t\t}\n\t\t\tcursor.exitNode();\n\t\t\treturn runLength;\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 * @privateRemarks\n * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.\n * We will want to generalize this with a more generic schema factory function like with table.\n * Then either that and/or the output from it can be package exported.\n * This version is just an initial prototype.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Formatting options for characters.\n\t * @internal\n\t */\n\texport class CharacterFormat extends sf.objectAlpha(\"CharacterFormat\", {\n\t\tbold: SchemaFactory.boolean,\n\t\titalic: SchemaFactory.boolean,\n\t\tunderline: SchemaFactory.boolean,\n\t\tsize: SchemaFactory.number,\n\t\tfont: SchemaFactory.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 extends sf.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 * 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 * 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\n\t/**\n\t * Tag with which a line in text can be formatted from HTML.\n\t * @internal\n\t */\n\texport const LineTag = enumFromStrings(sf.scopedFactory(\"lineTag\"), [\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"li\",\n\t\t\"ol\",\n\t\t\"checked\",\n\t\t\"unchecked\",\n\t\t\"blockquote\",\n\t\t\"codeBlock\",\n\t]);\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(LineTag:variable)}\n\t * @internal\n\t */\n\texport type LineTag = TreeNodeFromImplicitAllowedTypes<typeof LineTag.schema>;\n\n\t/**\n\t * Unit in the string representing a new line character with line formatting.\n\t * @remarks\n\t * This aligns with how Quill represents line formatting.\n\t * Quill formats line attributes (headers, list, blockquote, etc... ) on the newline character\n\t * and only lines using this atom can have line-specific formatting.\n\t * The optional indent level mirrors Quill's indent attribute,\n\t * which is applies to the line before the line break.\n\t * Any tagged line can be indented independently.\n\t * @internal\n\t */\n\texport class StringLineAtom extends sf.object(\"StringLineAtom\", {\n\t\ttag: LineTag.schema,\n\t\tindent: SchemaFactory.number,\n\t}) {\n\t\tpublic readonly content = \"\\n\";\n\t}\n\n\t/**\n\t * Types of \"atoms\" that make up the text.\n\t * @internal\n\t */\n\texport const StringAtomContent = [StringTextAtom, StringLineAtom] as const;\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(StringAtomContent:variable)}\n\t * @internal\n\t */\n\texport type StringAtomContent = TreeNodeFromImplicitAllowedTypes<typeof StringAtomContent>;\n\n\t/**\n\t * A unit of the text, with formatting.\n\t * @internal\n\t */\n\texport class StringAtom extends sf.object(\"StringAtom\", {\n\t\tcontent: SchemaFactory.required(StringAtomContent, { key: EmptyKey }),\n\t\tformat: CharacterFormat,\n\t}) {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics {\n\t\t/**\n\t\t * Construct a {@link FormattedTextAsTree.(Tree:type)} 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): Tree;\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.(Tree:type)} for schema.\n\t * @internal\n\t */\n\texport interface Members extends 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: CharacterFormat;\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 StringAtom[];\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<InsertableTypedNode<typeof StringAtom>>,\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: Partial<CharacterFormat>,\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 * Schema for a text node.\n\t * @remarks\n\t * See {@link FormattedTextAsTree.Members} for the API.\n\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t * @internal\n\t */\n\texport const Tree = eraseSchemaDetails<Members, Statics>()(TextNode);\n\texport type Tree = Members & TreeNode & WithType<\"com.fluidframework.text.formatted.Text\">;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;AAQrD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE9B,MAAM,wBAAwB,CAAC;AAQhC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa,EAAE,YAAY;CAAG;AA8DnE;;;;GAIG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,qBAAqB,GAC5B,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,qBAAqB,GAC5B,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAEpD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAGpD;AAED,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,yBAAyB,GAChC,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CASpD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,yBAAyB,CAQpF"}
|
package/dist/treeFactory.js
CHANGED
|
@@ -8,10 +8,11 @@ exports.resolveOptions = exports.configuredSharedTreeInternal = exports.configur
|
|
|
8
8
|
const internal_1 = require("@fluidframework/shared-object-base/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
10
|
const index_js_1 = require("./codec/index.js");
|
|
11
|
-
const index_js_2 = require("./
|
|
12
|
-
const index_js_3 = require("./shared-tree
|
|
11
|
+
const index_js_2 = require("./core/index.js");
|
|
12
|
+
const index_js_3 = require("./shared-tree/index.js");
|
|
13
|
+
const index_js_4 = require("./shared-tree-core/index.js");
|
|
13
14
|
const sharedTreeAttributes_js_1 = require("./sharedTreeAttributes.js");
|
|
14
|
-
const
|
|
15
|
+
const index_js_5 = require("./util/index.js");
|
|
15
16
|
/**
|
|
16
17
|
* Creates a factory for shared tree kernels with the given options.
|
|
17
18
|
* @remarks
|
|
@@ -36,7 +37,7 @@ function treeKernelFactory(options) {
|
|
|
36
37
|
// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.
|
|
37
38
|
minVersionForCollab: minVersionForCollab ?? args.minVersionForCollab ?? index_js_1.FluidClientVersion.v2_0,
|
|
38
39
|
};
|
|
39
|
-
return new
|
|
40
|
+
return new index_js_3.SharedTreeKernel(new index_js_5.Breakable("SharedTree"), args.sharedObject, args.serializer, args.submitLocalMessage, args.lastSequenceNumber, args.initialSequenceNumber, args.logger, args.idCompressor, adjustedOptions);
|
|
40
41
|
}
|
|
41
42
|
return {
|
|
42
43
|
create: (args) => {
|
|
@@ -144,7 +145,7 @@ function resolveOptions(options) {
|
|
|
144
145
|
...resolveFormatOptions(options),
|
|
145
146
|
};
|
|
146
147
|
for (const optionName of Object.keys(options)) {
|
|
147
|
-
(0,
|
|
148
|
+
(0, index_js_5.copyProperty)(options, optionName, internal);
|
|
148
149
|
}
|
|
149
150
|
return internal;
|
|
150
151
|
}
|
|
@@ -158,8 +159,9 @@ function resolveFormatOptions(options) {
|
|
|
158
159
|
}
|
|
159
160
|
const sharedBranchesOptions = {
|
|
160
161
|
writeVersionOverrides: new Map([
|
|
161
|
-
[
|
|
162
|
-
[
|
|
162
|
+
[index_js_4.editManagerCodecName, index_js_4.EditManagerFormatVersion.vSharedBranches],
|
|
163
|
+
[index_js_4.messageCodecName, index_js_4.MessageFormatVersion.vSharedBranches],
|
|
164
|
+
[index_js_2.detachedFieldIndexCodecBuilder.name, index_js_2.DetachedFieldIndexFormatVersion.v2],
|
|
163
165
|
]),
|
|
164
166
|
allowPossiblyIncompatibleWriteVersionOverrides: true,
|
|
165
167
|
};
|
package/dist/treeFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0EAQqD;AACrD,uEAAsE;AAEtE,+CAA0E;AAC1E,qDAOgC;AAChC,0DAKqC;AACrC,uEAAwF;AAExF,8CAA0D;AAS1D;;;;;GAKG;AACH,SAAS,iBAAiB,CACzB,OAAkC;IAElC,SAAS,kBAAkB,CAAC,IAAgB;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,qBAAU,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,EAAE,mBAAmB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;QAEzD,MAAM,eAAe,GAAG;YACvB,GAAG,YAAY;YACf,SAAS;YACT,kGAAkG;YAClG,0BAA0B;YAC1B,oGAAoG;YACpG,sGAAsG;YACtG,oFAAoF;YACpF,gGAAgG;YAChG,wIAAwI;YACxI,mBAAmB,EAClB,mBAAmB,IAAI,IAAI,CAAC,mBAAmB,IAAI,6BAAkB,CAAC,IAAI;SAC3E,CAAC;QAEF,OAAO,IAAI,2BAAgB,CAC1B,IAAI,oBAAS,CAAC,YAAY,CAAC,EAC3B,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,YAAY,EACjB,eAAe,CACf,CAAC;IACH,CAAC;IAED,OAAO;QACN,MAAM,EAAE,CAAC,IAAgB,EAAoC,EAAE;YAC9D,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,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AWC;AAED,SAAgB,cAAc,CAAC,OAA0B;IACxD,MAAM,QAAQ,GAA8B;QAC3C,GAAG,oBAAoB,CAAC,OAAO,CAAC;KAChC,CAAC;IACF,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,IAAA,uBAAY,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AARD,wCAQC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACvD,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;IAEnE,IAAI,oBAAoB,EAAE,CAAC;QAC1B,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC;AAED,MAAM,qBAAqB,GAA8B;IACxD,qBAAqB,EAAE,IAAI,GAAG,CAAwB;QACrD,CAAC,+BAAoB,EAAE,mCAAwB,CAAC,eAAe,CAAC;QAChE,CAAC,2BAAgB,EAAE,+BAAoB,CAAC,eAAe,CAAC;KACxD,CAAC;IACF,8CAA8C,EAAE,IAAI;CACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { FluidClientVersion, type FormatVersion } from \"./codec/index.js\";\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport {\n\teditManagerCodecName,\n\tEditManagerFormatVersion,\n\tmessageCodecName,\n\tMessageFormatVersion,\n} from \"./shared-tree-core/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\twriteVersionOverrides: new Map<string, FormatVersion>([\n\t\t[editManagerCodecName, EditManagerFormatVersion.vSharedBranches],\n\t\t[messageCodecName, MessageFormatVersion.vSharedBranches],\n\t]),\n\tallowPossiblyIncompatibleWriteVersionOverrides: true,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0EAQqD;AACrD,uEAAsE;AAEtE,+CAA0E;AAC1E,8CAGyB;AACzB,qDAOgC;AAChC,0DAKqC;AACrC,uEAAwF;AAExF,8CAA0D;AAS1D;;;;;GAKG;AACH,SAAS,iBAAiB,CACzB,OAAkC;IAElC,SAAS,kBAAkB,CAAC,IAAgB;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,qBAAU,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,EAAE,mBAAmB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;QAEzD,MAAM,eAAe,GAAG;YACvB,GAAG,YAAY;YACf,SAAS;YACT,kGAAkG;YAClG,0BAA0B;YAC1B,oGAAoG;YACpG,sGAAsG;YACtG,oFAAoF;YACpF,gGAAgG;YAChG,wIAAwI;YACxI,mBAAmB,EAClB,mBAAmB,IAAI,IAAI,CAAC,mBAAmB,IAAI,6BAAkB,CAAC,IAAI;SAC3E,CAAC;QAEF,OAAO,IAAI,2BAAgB,CAC1B,IAAI,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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { FluidClientVersion, type FormatVersion } from \"./codec/index.js\";\nimport {\n\tdetachedFieldIndexCodecBuilder,\n\tDetachedFieldIndexFormatVersion,\n} from \"./core/index.js\";\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport {\n\teditManagerCodecName,\n\tEditManagerFormatVersion,\n\tmessageCodecName,\n\tMessageFormatVersion,\n} from \"./shared-tree-core/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\twriteVersionOverrides: new Map<string, FormatVersion>([\n\t\t[editManagerCodecName, EditManagerFormatVersion.vSharedBranches],\n\t\t[messageCodecName, MessageFormatVersion.vSharedBranches],\n\t\t[detachedFieldIndexCodecBuilder.name, DetachedFieldIndexFormatVersion.v2],\n\t]),\n\tallowPossiblyIncompatibleWriteVersionOverrides: true,\n};\n"]}
|
package/dist/util/breakable.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class Breakable {
|
|
|
28
28
|
* @remarks
|
|
29
29
|
* Can use {@link throwIfBroken} to apply this to a method.
|
|
30
30
|
*/
|
|
31
|
-
use(): void;
|
|
31
|
+
use(message?: (brokenBy: Error) => string): void;
|
|
32
32
|
/**
|
|
33
33
|
* Puts this object into the broken state, and throws an error.
|
|
34
34
|
*
|
|
@@ -47,6 +47,12 @@ export declare class Breakable {
|
|
|
47
47
|
* Like {@link Breakable.use}, this also throws if already broken.
|
|
48
48
|
* Any exceptions this catches are re-thrown.
|
|
49
49
|
* Can use {@link breakingMethod} to apply this to a method.
|
|
50
|
+
*
|
|
51
|
+
* If `breaker` returns a Promise, the breakable is also broken if that Promise rejects, and the broken state is rechecked when it resolves:
|
|
52
|
+
* if the breakable was put into a broken state during the async operation (by some other code path), the resolved value is discarded and the returned Promise rejects with a {@link UsageError}.
|
|
53
|
+
*
|
|
54
|
+
* This does not serialize concurrent runs: a synchronous run invoked while an async run is in flight will execute immediately, and is only blocked if the breakable is already broken.
|
|
55
|
+
* Detection of an async result uses `instanceof Promise`, so custom Promise-like objects and Promises from other realms will be treated as synchronous results.
|
|
50
56
|
*/
|
|
51
57
|
run<TResult>(breaker: () => TResult): TResult;
|
|
52
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breakable.d.ts","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;GAKG;AACH,qBAAa,SAAS;IAIpB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI;IARtB,OAAO,CAAC,QAAQ,CAAC,CAAQ;;IAGxB;;;;OAIG;IACc,IAAI,EAAE,MAAM;IAG9B;;;;OAIG;IACI,GAAG,
|
|
1
|
+
{"version":3,"file":"breakable.d.ts","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;GAKG;AACH,qBAAa,SAAS;IAIpB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI;IARtB,OAAO,CAAC,QAAQ,CAAC,CAAQ;;IAGxB;;;;OAIG;IACc,IAAI,EAAE,MAAM;IAG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SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EAC1F,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,GACpC,MAAM,CAiCR"}
|
package/dist/util/breakable.js
CHANGED
|
@@ -28,10 +28,10 @@ class Breakable {
|
|
|
28
28
|
* @remarks
|
|
29
29
|
* Can use {@link throwIfBroken} to apply this to a method.
|
|
30
30
|
*/
|
|
31
|
-
use() {
|
|
31
|
+
use(message = (brokenBy) => `Invalid use of ${this.name} after it was put into an invalid state by another error.\nOriginal Error:\n${brokenBy}`) {
|
|
32
32
|
if (this.brokenBy !== undefined) {
|
|
33
|
-
const error = new internal_2.UsageError(
|
|
34
|
-
// This "cause" field is added in ES2022, but using
|
|
33
|
+
const error = new internal_2.UsageError(message(this.brokenBy));
|
|
34
|
+
// This "cause" field is added in ES2022, but using it even without that built in support, it is still helpful.
|
|
35
35
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
|
|
36
36
|
// TODO: remove this cast when targeting ES2022 lib or later.
|
|
37
37
|
error.cause =
|
|
@@ -70,11 +70,25 @@ class Breakable {
|
|
|
70
70
|
* Like {@link Breakable.use}, this also throws if already broken.
|
|
71
71
|
* Any exceptions this catches are re-thrown.
|
|
72
72
|
* Can use {@link breakingMethod} to apply this to a method.
|
|
73
|
+
*
|
|
74
|
+
* If `breaker` returns a Promise, the breakable is also broken if that Promise rejects, and the broken state is rechecked when it resolves:
|
|
75
|
+
* if the breakable was put into a broken state during the async operation (by some other code path), the resolved value is discarded and the returned Promise rejects with a {@link UsageError}.
|
|
76
|
+
*
|
|
77
|
+
* This does not serialize concurrent runs: a synchronous run invoked while an async run is in flight will execute immediately, and is only blocked if the breakable is already broken.
|
|
78
|
+
* Detection of an async result uses `instanceof Promise`, so custom Promise-like objects and Promises from other realms will be treated as synchronous results.
|
|
73
79
|
*/
|
|
74
80
|
run(breaker) {
|
|
75
81
|
this.use();
|
|
76
82
|
try {
|
|
77
|
-
|
|
83
|
+
const result = breaker();
|
|
84
|
+
if (result instanceof Promise) {
|
|
85
|
+
return result.then((value) => {
|
|
86
|
+
// If broken while process was running: this will throw instead of returning the value.
|
|
87
|
+
this.use((brokenBy) => `${this.name} was put into a broken state during an async operation.\nOriginal Error:\n${brokenBy}`);
|
|
88
|
+
return value;
|
|
89
|
+
}, (error) => this.rethrowCaught(error));
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
78
92
|
}
|
|
79
93
|
catch (error) {
|
|
80
94
|
this.rethrowCaught(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breakable.js","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE;;;;;GAKG;AACH,MAAa,SAAS;IAGrB;IACC;;;;OAIG;IACc,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAC3B,CAAC;IAEJ;;;;OAIG;IACI,GAAG;QACT,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,IAAI,qBAAU,CAC3B,kBAAkB,IAAI,CAAC,IAAI,+EAA+E,IAAI,CAAC,QAAQ,EAAE,CACzH,CAAC;YAEF,+GAA+G;YAC/G,mGAAmG;YACnG,6DAA6D;YAC5D,KAA6B,CAAC,KAAK;gBAClC,IAAI,CAAC,QAAgC,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC;YAE/D,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,QAAe;QAC3B,2FAA2F;QAC3F,0KAA0K;QAC1K,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,CAAC;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;IAC1D,OAAO,SAAS,KAAK,IAAI,EAAE,CAAC;QAC3B,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACnB,MAAM,UAAU,GAAG,OAAO,CAAC,wBAAwB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBACpE,SAAS;gBACT,IACC,UAAU,KAAK,SAAS;oBACxB,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU;oBACtC,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAC3B,CAAC;oBACF,gKAAgK;oBAChK,MAAM,MAAM,GAAG,UAAU,CAAC,KAAwC,CAAC;oBACnE,UAAU,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;oBAC1C,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;gBACtE,CAAC;YACF,CAAC;QACF,CAAC;QACD,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC3B,CAAC;AApCD,sCAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * An object which can enter a \"broken\" state where trying to use it is a UsageError.\n * @remarks\n * Use {@link WithBreakable} to apply this to another object.\n * @sealed\n */\nexport class Breakable {\n\tprivate brokenBy?: Error;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A name for a given breakable scope.\n\t\t * @remarks\n\t\t * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.\n\t\t */\n\t\tprivate readonly name: string,\n\t) {}\n\n\t/**\n\t * Throws if this object is in the broken state.\n\t * @remarks\n\t * Can use {@link throwIfBroken} to apply this to a method.\n\t */\n\tpublic use(): void {\n\t\tif (this.brokenBy !== undefined) {\n\t\t\tconst error = new UsageError(\n\t\t\t\t`Invalid use of ${this.name} after it was put into an invalid state by another error.\\nOriginal Error:\\n${this.brokenBy}`,\n\t\t\t);\n\n\t\t\t// This \"cause\" field is added in ES2022, but using if even without that built in support, it is still helpful.\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause\n\t\t\t// TODO: remove this cast when targeting ES2022 lib or later.\n\t\t\t(error as { cause?: unknown }).cause =\n\t\t\t\t(this.brokenBy as { cause?: unknown }).cause ?? this.brokenBy;\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Puts this object into the broken state, and throws an error.\n\t *\n\t * @throws If already broken by a different error, throws a UsageError, otherwise throws `brokenBy`.\n\t */\n\tpublic break(brokenBy: Error): never {\n\t\t// If already broken by this error, let it bubble up without rethrowing a modified version.\n\t\t// This prevents internal errors like asserts getting rethrown as different errors when wrapped with multiple call to `{@link Breakable.run}` or `{@link breakingMethod}`.\n\t\tif (this.brokenBy !== brokenBy) {\n\t\t\tthis.use();\n\t\t\tthis.brokenBy = brokenBy;\n\t\t}\n\t\tthrow brokenBy;\n\t}\n\n\t/**\n\t * {@link Breakable.break}, except tolerates `unknown` to be more easily used by catch blocks.\n\t * @privateRemarks\n\t * If there is a use-case, this should be made public.\n\t */\n\tprivate rethrowCaught(brokenBy: unknown): never {\n\t\tif (brokenBy instanceof Error) {\n\t\t\tthis.break(brokenBy);\n\t\t}\n\t\tthis.break(\n\t\t\tnew Error(`Non-error thrown breaking ${this.name}. Thrown value: \"${brokenBy}\"`),\n\t\t);\n\t}\n\n\t/**\n\t * Runs code which should break the object if it throws.\n\t * @remarks\n\t * Like {@link Breakable.use}, this also throws if already broken.\n\t * Any exceptions this catches are re-thrown.\n\t * Can use {@link breakingMethod} to apply this to a method.\n\t */\n\tpublic run<TResult>(breaker: () => TResult): TResult {\n\t\tthis.use();\n\t\ttry {\n\t\t\treturn breaker();\n\t\t} catch (error: unknown) {\n\t\t\tthis.rethrowCaught(error);\n\t\t}\n\t}\n\n\t/**\n\t * Clears the existing broken state.\n\t * @remarks\n\t * This is rarely safe to to: it is only ok when all objects using this breaker are known to not have been left in an invalid state.\n\t * This is pretty much only safe in tests which just were checking a specific error was thrown, and which know that error closepath is actually exception safe.\n\t */\n\tpublic clearError(): void {\n\t\tassert(this.brokenBy !== undefined, 0x9b6 /* No error to clear */);\n\t\tthis.brokenBy = undefined;\n\t}\n}\n\n/**\n * Marks an object as being able to be in a broken state (unknown/unspecified/broken state due to unhandled exception).\n * @remarks\n * See decorators {@link breakingMethod} and {@link throwIfBroken} for ease of use.\n */\nexport interface WithBreakable {\n\t/**\n\t * The breaker for this object.\n\t * @remarks\n\t * If this `breaker` is in the broken state, the `WithBreakable` should be considered in a broken state.\n\t */\n\treadonly breaker: Breakable;\n}\n\n/**\n * Decorator for methods which should break the object when they throw.\n * @remarks\n * This also throws if already broken like {@link throwIfBroken}.\n * See {@link Breakable.run} for details.\n *\n * This should be used on methods which modify data that could result in an unsupported/broken state if an exception is thrown while modifying.\n * It is ok for breakingMethods to call each-other.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function breakingMethod<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context?: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tif (this.breaker === undefined) {\n\t\t\t// This case is necessary for when wrapping methods which are invoked inside the constructor of the base class before `breaker` is set.\n\t\t\t// Since the constructor throwing does not return an object, failing to put it into a broken state is not too bad.\n\t\t\t// However when more than just the constructed object should be broken, this can result in missing a break.\n\t\t\treturn target.call(this, ...args);\n\t\t}\n\t\treturn this.breaker.run(() => {\n\t\t\treturn target.call(this, ...args);\n\t\t});\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n/**\n * Decorator for methods which should throw if the object is in a broken state.\n * @remarks\n * This should be used on methods which read data that could be invalid when the object is broken.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function throwIfBroken<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tthis.breaker.use();\n\t\treturn target.call(this, ...args);\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype PossiblyNamedFunction = Function & { displayName?: undefined | string };\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction nameFunctionFrom(toName: Function, nameFrom: Function): void {\n\t(toName as PossiblyNamedFunction).displayName =\n\t\t(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;\n}\n\nconst isBreakerSymbol: unique symbol = Symbol(\"isBreaker\");\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction markBreaker(f: Function): void {\n\t(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;\n}\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isBreaker(f: Function): boolean {\n\treturn isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);\n}\n\n/**\n * Decorator for classes which should break when their methods throw.\n * @remarks\n * Applies {@link breakingMethod} to all methods declared directly by class or its base classes.\n * Does not include those on derived classes.\n * Does not include getters or setters, or value properties.\n * Methods already marked as {@link breakingMethod} or {@link throwIfBroken} are unaffected.\n */\nexport function breakingClass<Target extends abstract new (...args: any[]) => WithBreakable>(\n\ttarget: Target,\n\tcontext: ClassDecoratorContext<Target>,\n): Target {\n\t// This could extend target, but doing so adds an extra step in the prototype chain and makes the instances just show up as \"DecoratedBreakable\" in the debugger.\n\tconst DecoratedBreakable = target;\n\n\t// Keep track of what keys we have seen (and already wrapped if needed).\n\t// Used to avoid rewrapping already wrapped properties.\n\t// Preloaded with \"constructor\" to avoid wrapping the constructor as there is no need to set the broken flag when the constructor throws and does not return an object.\n\t// Avoiding wrapping the constructor also avoids messing up the displayed name in the debugger.\n\tconst doNotWrap: Set<string | symbol> = new Set([\"constructor\"]);\n\n\tlet prototype: object | null = target.prototype as object;\n\twhile (prototype !== null) {\n\t\tfor (const key of Reflect.ownKeys(prototype)) {\n\t\t\tif (!doNotWrap.has(key)) {\n\t\t\t\tdoNotWrap.add(key);\n\t\t\t\tconst descriptor = Reflect.getOwnPropertyDescriptor(prototype, key);\n\t\t\t\t// Method\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\ttypeof descriptor.value === \"function\" &&\n\t\t\t\t\t!isBreaker(descriptor.value)\n\t\t\t\t) {\n\t\t\t\t\t// This does not affect the original class, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\n\t\t\t\t\tconst method = descriptor.value as (...args: unknown[]) => unknown;\n\t\t\t\t\tdescriptor.value = breakingMethod(method);\n\t\t\t\t\tObject.defineProperty(DecoratedBreakable.prototype, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprototype = Reflect.getPrototypeOf(prototype);\n\t}\n\n\treturn DecoratedBreakable;\n}\n"]}
|
|
1
|
+
{"version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C,aAAa,CAAC,CAAC,CAAC;IAEjE,IAAI,SAAS,GAAkB,MAAM,CAAC,SAAmB,CAAC;IAC1D,OAAO,SAAS,KAAK,IAAI,EAAE,CAAC;QAC3B,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACnB,MAAM,UAAU,GAAG,OAAO,CAAC,wBAAwB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBACpE,SAAS;gBACT,IACC,UAAU,KAAK,SAAS;oBACxB,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU;oBACtC,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAC3B,CAAC;oBACF,gKAAgK;oBAChK,MAAM,MAAM,GAAG,UAAU,CAAC,KAAwC,CAAC;oBACnE,UAAU,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;oBAC1C,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;gBACtE,CAAC;YACF,CAAC;QACF,CAAC;QACD,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC3B,CAAC;AApCD,sCAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * An object which can enter a \"broken\" state where trying to use it is a UsageError.\n * @remarks\n * Use {@link WithBreakable} to apply this to another object.\n * @sealed\n */\nexport class Breakable {\n\tprivate brokenBy?: Error;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A name for a given breakable scope.\n\t\t * @remarks\n\t\t * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.\n\t\t */\n\t\tprivate readonly name: string,\n\t) {}\n\n\t/**\n\t * Throws if this object is in the broken state.\n\t * @remarks\n\t * Can use {@link throwIfBroken} to apply this to a method.\n\t */\n\tpublic use(\n\t\tmessage: (brokenBy: Error) => string = (brokenBy) =>\n\t\t\t`Invalid use of ${this.name} after it was put into an invalid state by another error.\\nOriginal Error:\\n${brokenBy}`,\n\t): void {\n\t\tif (this.brokenBy !== undefined) {\n\t\t\tconst error = new UsageError(message(this.brokenBy));\n\n\t\t\t// This \"cause\" field is added in ES2022, but using it even without that built in support, it is still helpful.\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause\n\t\t\t// TODO: remove this cast when targeting ES2022 lib or later.\n\t\t\t(error as { cause?: unknown }).cause =\n\t\t\t\t(this.brokenBy as { cause?: unknown }).cause ?? this.brokenBy;\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Puts this object into the broken state, and throws an error.\n\t *\n\t * @throws If already broken by a different error, throws a UsageError, otherwise throws `brokenBy`.\n\t */\n\tpublic break(brokenBy: Error): never {\n\t\t// If already broken by this error, let it bubble up without rethrowing a modified version.\n\t\t// This prevents internal errors like asserts getting rethrown as different errors when wrapped with multiple call to `{@link Breakable.run}` or `{@link breakingMethod}`.\n\t\tif (this.brokenBy !== brokenBy) {\n\t\t\tthis.use();\n\t\t\tthis.brokenBy = brokenBy;\n\t\t}\n\t\tthrow brokenBy;\n\t}\n\n\t/**\n\t * {@link Breakable.break}, except tolerates `unknown` to be more easily used by catch blocks.\n\t * @privateRemarks\n\t * If there is a use-case, this should be made public.\n\t */\n\tprivate rethrowCaught(brokenBy: unknown): never {\n\t\tif (brokenBy instanceof Error) {\n\t\t\tthis.break(brokenBy);\n\t\t}\n\t\tthis.break(\n\t\t\tnew Error(`Non-error thrown breaking ${this.name}. Thrown value: \"${brokenBy}\"`),\n\t\t);\n\t}\n\n\t/**\n\t * Runs code which should break the object if it throws.\n\t * @remarks\n\t * Like {@link Breakable.use}, this also throws if already broken.\n\t * Any exceptions this catches are re-thrown.\n\t * Can use {@link breakingMethod} to apply this to a method.\n\t *\n\t * If `breaker` returns a Promise, the breakable is also broken if that Promise rejects, and the broken state is rechecked when it resolves:\n\t * if the breakable was put into a broken state during the async operation (by some other code path), the resolved value is discarded and the returned Promise rejects with a {@link UsageError}.\n\t *\n\t * This does not serialize concurrent runs: a synchronous run invoked while an async run is in flight will execute immediately, and is only blocked if the breakable is already broken.\n\t * Detection of an async result uses `instanceof Promise`, so custom Promise-like objects and Promises from other realms will be treated as synchronous results.\n\t */\n\tpublic run<TResult>(breaker: () => TResult): TResult {\n\t\tthis.use();\n\t\ttry {\n\t\t\tconst result = breaker();\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\t(value: Awaited<TResult>) => {\n\t\t\t\t\t\t// If broken while process was running: this will throw instead of returning the value.\n\t\t\t\t\t\tthis.use(\n\t\t\t\t\t\t\t(brokenBy) =>\n\t\t\t\t\t\t\t\t`${this.name} was put into a broken state during an async operation.\\nOriginal Error:\\n${brokenBy}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => this.rethrowCaught(error),\n\t\t\t\t) as TResult;\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error: unknown) {\n\t\t\tthis.rethrowCaught(error);\n\t\t}\n\t}\n\n\t/**\n\t * Clears the existing broken state.\n\t * @remarks\n\t * This is rarely safe to to: it is only ok when all objects using this breaker are known to not have been left in an invalid state.\n\t * This is pretty much only safe in tests which just were checking a specific error was thrown, and which know that error closepath is actually exception safe.\n\t */\n\tpublic clearError(): void {\n\t\tassert(this.brokenBy !== undefined, 0x9b6 /* No error to clear */);\n\t\tthis.brokenBy = undefined;\n\t}\n}\n\n/**\n * Marks an object as being able to be in a broken state (unknown/unspecified/broken state due to unhandled exception).\n * @remarks\n * See decorators {@link breakingMethod} and {@link throwIfBroken} for ease of use.\n */\nexport interface WithBreakable {\n\t/**\n\t * The breaker for this object.\n\t * @remarks\n\t * If this `breaker` is in the broken state, the `WithBreakable` should be considered in a broken state.\n\t */\n\treadonly breaker: Breakable;\n}\n\n/**\n * Decorator for methods which should break the object when they throw.\n * @remarks\n * This also throws if already broken like {@link throwIfBroken}.\n * See {@link Breakable.run} for details.\n *\n * This should be used on methods which modify data that could result in an unsupported/broken state if an exception is thrown while modifying.\n * It is ok for breakingMethods to call each-other.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function breakingMethod<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context?: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tif (this.breaker === undefined) {\n\t\t\t// This case is necessary for when wrapping methods which are invoked inside the constructor of the base class before `breaker` is set.\n\t\t\t// Since the constructor throwing does not return an object, failing to put it into a broken state is not too bad.\n\t\t\t// However when more than just the constructed object should be broken, this can result in missing a break.\n\t\t\treturn target.call(this, ...args);\n\t\t}\n\t\treturn this.breaker.run(() => {\n\t\t\treturn target.call(this, ...args);\n\t\t});\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n/**\n * Decorator for methods which should throw if the object is in a broken state.\n * @remarks\n * This should be used on methods which read data that could be invalid when the object is broken.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function throwIfBroken<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tthis.breaker.use();\n\t\treturn target.call(this, ...args);\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype PossiblyNamedFunction = Function & { displayName?: undefined | string };\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction nameFunctionFrom(toName: Function, nameFrom: Function): void {\n\t(toName as PossiblyNamedFunction).displayName =\n\t\t(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;\n}\n\nconst isBreakerSymbol: unique symbol = Symbol(\"isBreaker\");\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction markBreaker(f: Function): void {\n\t(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;\n}\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isBreaker(f: Function): boolean {\n\treturn isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);\n}\n\n/**\n * Decorator for classes which should break when their methods throw.\n * @remarks\n * Applies {@link breakingMethod} to all methods declared directly by class or its base classes.\n * Does not include those on derived classes.\n * Does not include getters or setters, or value properties.\n * Methods already marked as {@link breakingMethod} or {@link throwIfBroken} are unaffected.\n */\nexport function breakingClass<Target extends abstract new (...args: any[]) => WithBreakable>(\n\ttarget: Target,\n\tcontext: ClassDecoratorContext<Target>,\n): Target {\n\t// This could extend target, but doing so adds an extra step in the prototype chain and makes the instances just show up as \"DecoratedBreakable\" in the debugger.\n\tconst DecoratedBreakable = target;\n\n\t// Keep track of what keys we have seen (and already wrapped if needed).\n\t// Used to avoid rewrapping already wrapped properties.\n\t// Preloaded with \"constructor\" to avoid wrapping the constructor as there is no need to set the broken flag when the constructor throws and does not return an object.\n\t// Avoiding wrapping the constructor also avoids messing up the displayed name in the debugger.\n\tconst doNotWrap: Set<string | symbol> = new Set([\"constructor\"]);\n\n\tlet prototype: object | null = target.prototype as object;\n\twhile (prototype !== null) {\n\t\tfor (const key of Reflect.ownKeys(prototype)) {\n\t\t\tif (!doNotWrap.has(key)) {\n\t\t\t\tdoNotWrap.add(key);\n\t\t\t\tconst descriptor = Reflect.getOwnPropertyDescriptor(prototype, key);\n\t\t\t\t// Method\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\ttypeof descriptor.value === \"function\" &&\n\t\t\t\t\t!isBreaker(descriptor.value)\n\t\t\t\t) {\n\t\t\t\t\t// This does not affect the original class, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\n\t\t\t\t\tconst method = descriptor.value as (...args: unknown[]) => unknown;\n\t\t\t\t\tdescriptor.value = breakingMethod(method);\n\t\t\t\t\tObject.defineProperty(DecoratedBreakable.prototype, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprototype = Reflect.getPrototypeOf(prototype);\n\t}\n\n\treturn DecoratedBreakable;\n}\n"]}
|
package/lib/codec/codec.d.ts
CHANGED
|
@@ -144,8 +144,9 @@ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta
|
|
|
144
144
|
readonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* `
|
|
148
|
-
*
|
|
147
|
+
* `TEncodeContext` and `TDecodeContext` allow passing context to the codec which may configure how data is encoded/decoded.
|
|
148
|
+
* `TDecodeContext` defaults to `TEncodeContext`; specify them separately when encode and decode need different context (for example, when encoding uses heuristics that are unneeded when decoding).
|
|
149
|
+
* These parameters are typically used for:
|
|
149
150
|
* - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.
|
|
150
151
|
* The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating
|
|
151
152
|
* additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the
|
|
@@ -163,7 +164,7 @@ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta
|
|
|
163
164
|
* If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.
|
|
164
165
|
* This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.
|
|
165
166
|
*/
|
|
166
|
-
export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded,
|
|
167
|
+
export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TEncodeContext = void, TDecodeContext = TEncodeContext> extends IEncoder<TDecoded, TEncoded, TEncodeContext>, IDecoder<TDecoded, TValidate, TDecodeContext> {
|
|
167
168
|
encodedSchema?: TAnySchema;
|
|
168
169
|
}
|
|
169
170
|
/**
|
|
@@ -175,7 +176,7 @@ export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValida
|
|
|
175
176
|
*
|
|
176
177
|
* This portion of a codec is not responsible for managing versioning or validation of the data against the schema.
|
|
177
178
|
*/
|
|
178
|
-
export interface JsonCodecPart<TDecoded, TEncodedSchema extends TAnySchema,
|
|
179
|
+
export interface JsonCodecPart<TDecoded, TEncodedSchema extends TAnySchema, TEncodeContext = void, TDecodeContext = TEncodeContext> extends IEncoder<TDecoded, Static<TEncodedSchema>, TEncodeContext>, IDecoder<TDecoded, Static<TEncodedSchema>, TDecodeContext> {
|
|
179
180
|
/**
|
|
180
181
|
* TypeBox schema which describes the encoded format for this chunk of data.
|
|
181
182
|
* @remarks
|
|
@@ -187,7 +188,7 @@ export interface JsonCodecPart<TDecoded, TEncodedSchema extends TAnySchema, TCon
|
|
|
187
188
|
/**
|
|
188
189
|
* Type erase the more detailed encoded type from a codec.
|
|
189
190
|
*/
|
|
190
|
-
export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded,
|
|
191
|
+
export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TEncodeContext = void, TDecodeContext = TEncodeContext>(codec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>): IJsonCodec<TDecoded, TValidate, TValidate, TEncodeContext, TDecodeContext>;
|
|
191
192
|
/**
|
|
192
193
|
* Represents a family of codecs that can be used to encode and decode data in different formats.
|
|
193
194
|
* The family is identified by a format version, which is typically used to select the codec to use.
|
|
@@ -197,11 +198,11 @@ export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleRead
|
|
|
197
198
|
* allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not
|
|
198
199
|
* involve mixed format versions.
|
|
199
200
|
*
|
|
200
|
-
* @privateRemarks
|
|
201
|
-
*
|
|
202
|
-
*
|
|
201
|
+
* @privateRemarks
|
|
202
|
+
* Encode and decode can be parameterized independently — the encode-side context type need not equal the decode-side context type.
|
|
203
|
+
* `TDecodeContext` defaults to `TEncodeContext` so callers that share a single context shape (the common case) don't need to specify it.
|
|
203
204
|
*/
|
|
204
|
-
export interface ICodecFamily<TDecoded,
|
|
205
|
+
export interface ICodecFamily<TDecoded, TEncodeContext = void, TDecodeContext = TEncodeContext> {
|
|
205
206
|
/**
|
|
206
207
|
* @returns a codec that can be used to encode and decode data in the specified format.
|
|
207
208
|
* @throws if the format version is not supported by this family.
|
|
@@ -209,7 +210,7 @@ export interface ICodecFamily<TDecoded, TContext = void> {
|
|
|
209
210
|
* logged properties or directly using some logger) when a format version is requested that is not supported.
|
|
210
211
|
* This ensures that applications can diagnose compatibility issues.
|
|
211
212
|
*/
|
|
212
|
-
resolve(formatVersion: FormatVersion): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly,
|
|
213
|
+
resolve(formatVersion: FormatVersion): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TEncodeContext, TDecodeContext>;
|
|
213
214
|
/**
|
|
214
215
|
* @returns an iterable of all format versions supported by this family.
|
|
215
216
|
*/
|
|
@@ -260,10 +261,10 @@ export declare const DependentFormatVersion: {
|
|
|
260
261
|
/**
|
|
261
262
|
* Creates a codec family from a registry of codecs.
|
|
262
263
|
*/
|
|
263
|
-
export declare function makeCodecFamily<TDecoded,
|
|
264
|
+
export declare function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(registry: Iterable<[
|
|
264
265
|
formatVersion: FormatVersion,
|
|
265
|
-
codec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly,
|
|
266
|
-
]>): ICodecFamily<TDecoded,
|
|
266
|
+
codec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TEncodeContext, TDecodeContext>
|
|
267
|
+
]>): ICodecFamily<TDecoded, TEncodeContext, TDecodeContext>;
|
|
267
268
|
/**
|
|
268
269
|
* Codec for objects which carry no information.
|
|
269
270
|
*/
|
|
@@ -272,58 +273,26 @@ export declare const unitCodec: IJsonCodec<0, JsonCompatibleReadOnly, JsonCompat
|
|
|
272
273
|
* Wraps a codec with JSON schema validation for its encoded type.
|
|
273
274
|
* @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
|
|
274
275
|
* @remarks
|
|
275
|
-
* Eventually all codecs should use the same pattern implemented by
|
|
276
|
+
* Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.
|
|
276
277
|
*/
|
|
277
|
-
export declare function withSchemaValidation<TInMemoryFormat, EncodedSchema extends TSchema, TEncodedFormat, TValidate,
|
|
278
|
+
export declare function withSchemaValidation<TInMemoryFormat, EncodedSchema extends TSchema, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext = TEncodeContext>(schema: EncodedSchema, codec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext>, validator?: JsonValidator | FormatValidator): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext>;
|
|
278
279
|
/**
|
|
279
|
-
* Versions of Fluid Framework client packages.
|
|
280
|
+
* Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.
|
|
280
281
|
* @remarks
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* When no compatibility-impacting change is made in a given version, the value associated with its enum entry may point to the older version which it's fully compatible with.
|
|
284
|
-
* Note that this can change if a future version of the framework introduces an option to use something which is only supported at a particular version. In which case, the values of the enum may shift,
|
|
285
|
-
* but the semantics of keys in this enum will not change.
|
|
286
|
-
*
|
|
287
|
-
* Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.
|
|
288
|
-
*
|
|
289
|
-
* Some release may also be omitted if there is currently no need to express that specific version.
|
|
290
|
-
* If the need arises, they might be added in the future.
|
|
282
|
+
* Versions with no notable impact may be omitted, and added later if needed.
|
|
291
283
|
*
|
|
292
284
|
* @privateRemarks
|
|
293
|
-
*
|
|
294
|
-
* - The user
|
|
295
|
-
*
|
|
296
|
-
* -
|
|
297
|
-
* version will write. For example, document if a new summary or encoding format is added in a version.
|
|
298
|
-
* - Whether the above features or data formats introduced in a version are enabled by default or require the
|
|
299
|
-
* {@link minVersionForCollab} option to be set to that particular version.
|
|
300
|
-
*
|
|
301
|
-
* Versions with no notable impact can be omitted.
|
|
302
|
-
*
|
|
303
|
-
* This scheme assumes a single version will always be enough to communicate compatibility.
|
|
304
|
-
* For this to work, compatibility has to be strictly increasing.
|
|
305
|
-
* If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),
|
|
306
|
-
* a more complex scheme may be needed to allow safely opting into incompatible features in those cases:
|
|
307
|
-
* such a system can be added if/when its needed since it will be opt in and thus non-breaking.
|
|
308
|
-
*
|
|
309
|
-
* TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.
|
|
310
|
-
* TODO: compatibility requirements for how this enum can and cannot be changed should be clarified when/if it's used across multiple layers in the stack.
|
|
311
|
-
* For example, if needed, would adding more leading zeros to the minor version break things.
|
|
285
|
+
* Each entry should document:
|
|
286
|
+
* - The user-facing impact of opting into it (e.g. encoding efficiency improvements).
|
|
287
|
+
* - Any new data formats introduced in that version.
|
|
288
|
+
* - Whether those features/formats are enabled by default or require {@link MinimumVersionForCollab | minVersionForCollab} to be set accordingly.
|
|
312
289
|
* @alpha
|
|
313
290
|
*/
|
|
314
291
|
export declare const FluidClientVersion: {
|
|
315
|
-
/**
|
|
316
|
-
* Fluid Framework Client 1.4 and newer.
|
|
317
|
-
* @remarks
|
|
318
|
-
* This opts into support for the 1.4 LTS branch.
|
|
319
|
-
* @privateRemarks
|
|
320
|
-
* As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.
|
|
321
|
-
*/
|
|
322
292
|
/**
|
|
323
293
|
* Fluid Framework Client 2.0 and newer.
|
|
324
294
|
*/
|
|
325
295
|
readonly v2_0: "2.0.0";
|
|
326
|
-
/** Fluid Framework Client 2.1 and newer. */
|
|
327
296
|
/**
|
|
328
297
|
* Fluid Framework Client 2.43 and newer.
|
|
329
298
|
* @remarks
|
package/lib/codec/codec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,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