@fluidframework/tree 2.114.0 → 2.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/api-report/tree.alpha.api.md +108 -39
  3. package/dist/core/index.d.ts +1 -1
  4. package/dist/core/index.d.ts.map +1 -1
  5. package/dist/core/index.js +3 -2
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/rebase/index.d.ts +1 -1
  8. package/dist/core/rebase/index.d.ts.map +1 -1
  9. package/dist/core/rebase/index.js +2 -1
  10. package/dist/core/rebase/index.js.map +1 -1
  11. package/dist/core/rebase/types.d.ts +110 -0
  12. package/dist/core/rebase/types.d.ts.map +1 -1
  13. package/dist/core/rebase/types.js +47 -1
  14. package/dist/core/rebase/types.js.map +1 -1
  15. package/dist/entrypoints/alpha.d.ts +1 -1
  16. package/dist/entrypoints/alpha.d.ts.map +1 -1
  17. package/dist/entrypoints/alpha.js +6 -4
  18. package/dist/entrypoints/alpha.js.map +1 -1
  19. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  20. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +6 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/packageVersion.d.ts +1 -1
  28. package/dist/packageVersion.js +1 -1
  29. package/dist/packageVersion.js.map +1 -1
  30. package/dist/shared-tree/sharedTree.d.ts +5 -0
  31. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  32. package/dist/shared-tree/sharedTree.js +1 -1
  33. package/dist/shared-tree/sharedTree.js.map +1 -1
  34. package/dist/shared-tree/treeCheckout.d.ts +5 -0
  35. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  36. package/dist/shared-tree/treeCheckout.js +58 -12
  37. package/dist/shared-tree/treeCheckout.js.map +1 -1
  38. package/dist/shared-tree-core/branch.d.ts +1 -0
  39. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  40. package/dist/shared-tree-core/branch.js.map +1 -1
  41. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  42. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  43. package/dist/simple-tree/api/index.d.ts +1 -1
  44. package/dist/simple-tree/api/index.d.ts.map +1 -1
  45. package/dist/simple-tree/api/index.js +2 -3
  46. package/dist/simple-tree/api/index.js.map +1 -1
  47. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  48. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  49. package/dist/simple-tree/api/schemaStatics.d.ts +6 -7
  50. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  51. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  52. package/dist/simple-tree/api/treeNodeApi.d.ts +20 -24
  53. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  54. package/dist/simple-tree/api/treeNodeApi.js +48 -49
  55. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  56. package/dist/simple-tree/core/treeNode.d.ts +5 -6
  57. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  58. package/dist/simple-tree/core/treeNode.js +2 -4
  59. package/dist/simple-tree/core/treeNode.js.map +1 -1
  60. package/dist/simple-tree/core/withType.d.ts +20 -7
  61. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  62. package/dist/simple-tree/core/withType.js +4 -7
  63. package/dist/simple-tree/core/withType.js.map +1 -1
  64. package/dist/simple-tree/index.d.ts +2 -2
  65. package/dist/simple-tree/index.d.ts.map +1 -1
  66. package/dist/simple-tree/index.js +3 -4
  67. package/dist/simple-tree/index.js.map +1 -1
  68. package/dist/simple-tree/leafNodeSchema.d.ts +6 -1
  69. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  70. package/dist/simple-tree/leafNodeSchema.js +0 -1
  71. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  72. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
  73. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  74. package/dist/simple-tree/node-kinds/array/arrayNode.js +91 -10
  75. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  76. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
  77. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  78. package/dist/simple-tree/node-kinds/map/mapNode.js +17 -1
  79. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  80. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
  81. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  82. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
  83. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  84. package/dist/text/codePointUtils.d.ts +2 -2
  85. package/dist/text/codePointUtils.js +2 -2
  86. package/dist/text/codePointUtils.js.map +1 -1
  87. package/dist/text/index.d.ts +3 -3
  88. package/dist/text/index.d.ts.map +1 -1
  89. package/dist/text/index.js +4 -4
  90. package/dist/text/index.js.map +1 -1
  91. package/dist/text/textDomain.d.ts +18 -18
  92. package/dist/text/textDomain.d.ts.map +1 -1
  93. package/dist/text/textDomain.js +8 -8
  94. package/dist/text/textDomain.js.map +1 -1
  95. package/dist/text/textDomainFormatted.d.ts +46 -42
  96. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  97. package/dist/text/textDomainFormatted.js +32 -28
  98. package/dist/text/textDomainFormatted.js.map +1 -1
  99. package/dist/text/textDomainFormattedDefault.d.ts +18 -18
  100. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
  101. package/dist/text/textDomainFormattedDefault.js +14 -17
  102. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  103. package/dist/util/compressedIds.d.ts +22 -2
  104. package/dist/util/compressedIds.d.ts.map +1 -1
  105. package/dist/util/compressedIds.js +22 -1
  106. package/dist/util/compressedIds.js.map +1 -1
  107. package/lib/core/index.d.ts +1 -1
  108. package/lib/core/index.d.ts.map +1 -1
  109. package/lib/core/index.js +1 -1
  110. package/lib/core/index.js.map +1 -1
  111. package/lib/core/rebase/index.d.ts +1 -1
  112. package/lib/core/rebase/index.d.ts.map +1 -1
  113. package/lib/core/rebase/index.js +1 -1
  114. package/lib/core/rebase/index.js.map +1 -1
  115. package/lib/core/rebase/types.d.ts +110 -0
  116. package/lib/core/rebase/types.d.ts.map +1 -1
  117. package/lib/core/rebase/types.js +46 -0
  118. package/lib/core/rebase/types.js.map +1 -1
  119. package/lib/entrypoints/alpha.d.ts +1 -1
  120. package/lib/entrypoints/alpha.d.ts.map +1 -1
  121. package/lib/entrypoints/alpha.js +1 -1
  122. package/lib/entrypoints/alpha.js.map +1 -1
  123. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +9 -6
  124. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  125. package/lib/feature-libraries/chunked-forest/codec/codecs.js +16 -13
  126. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  127. package/lib/index.d.ts +3 -3
  128. package/lib/index.d.ts.map +1 -1
  129. package/lib/index.js +2 -2
  130. package/lib/index.js.map +1 -1
  131. package/lib/packageVersion.d.ts +1 -1
  132. package/lib/packageVersion.js +1 -1
  133. package/lib/packageVersion.js.map +1 -1
  134. package/lib/shared-tree/sharedTree.d.ts +5 -0
  135. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  136. package/lib/shared-tree/sharedTree.js +1 -1
  137. package/lib/shared-tree/sharedTree.js.map +1 -1
  138. package/lib/shared-tree/treeCheckout.d.ts +5 -0
  139. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  140. package/lib/shared-tree/treeCheckout.js +60 -14
  141. package/lib/shared-tree/treeCheckout.js.map +1 -1
  142. package/lib/shared-tree-core/branch.d.ts +1 -0
  143. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  144. package/lib/shared-tree-core/branch.js.map +1 -1
  145. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  146. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  147. package/lib/simple-tree/api/index.d.ts +1 -1
  148. package/lib/simple-tree/api/index.d.ts.map +1 -1
  149. package/lib/simple-tree/api/index.js +1 -1
  150. package/lib/simple-tree/api/index.js.map +1 -1
  151. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +3 -3
  152. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  153. package/lib/simple-tree/api/schemaStatics.d.ts +6 -7
  154. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  155. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  156. package/lib/simple-tree/api/treeNodeApi.d.ts +20 -24
  157. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  158. package/lib/simple-tree/api/treeNodeApi.js +46 -46
  159. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  160. package/lib/simple-tree/core/treeNode.d.ts +5 -6
  161. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  162. package/lib/simple-tree/core/treeNode.js +2 -4
  163. package/lib/simple-tree/core/treeNode.js.map +1 -1
  164. package/lib/simple-tree/core/withType.d.ts +20 -7
  165. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  166. package/lib/simple-tree/core/withType.js +4 -7
  167. package/lib/simple-tree/core/withType.js.map +1 -1
  168. package/lib/simple-tree/index.d.ts +2 -2
  169. package/lib/simple-tree/index.d.ts.map +1 -1
  170. package/lib/simple-tree/index.js +1 -1
  171. package/lib/simple-tree/index.js.map +1 -1
  172. package/lib/simple-tree/leafNodeSchema.d.ts +6 -1
  173. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  174. package/lib/simple-tree/leafNodeSchema.js +0 -1
  175. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  176. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +32 -3
  177. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  178. package/lib/simple-tree/node-kinds/array/arrayNode.js +93 -12
  179. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  180. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +77 -0
  181. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  182. package/lib/simple-tree/node-kinds/map/mapNode.js +18 -2
  183. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  184. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  185. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  186. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
  187. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  188. package/lib/text/codePointUtils.d.ts +2 -2
  189. package/lib/text/codePointUtils.js +2 -2
  190. package/lib/text/codePointUtils.js.map +1 -1
  191. package/lib/text/index.d.ts +3 -3
  192. package/lib/text/index.d.ts.map +1 -1
  193. package/lib/text/index.js +3 -3
  194. package/lib/text/index.js.map +1 -1
  195. package/lib/text/textDomain.d.ts +18 -18
  196. package/lib/text/textDomain.d.ts.map +1 -1
  197. package/lib/text/textDomain.js +7 -7
  198. package/lib/text/textDomain.js.map +1 -1
  199. package/lib/text/textDomainFormatted.d.ts +46 -42
  200. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  201. package/lib/text/textDomainFormatted.js +31 -27
  202. package/lib/text/textDomainFormatted.js.map +1 -1
  203. package/lib/text/textDomainFormattedDefault.d.ts +18 -18
  204. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
  205. package/lib/text/textDomainFormattedDefault.js +14 -17
  206. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  207. package/lib/util/compressedIds.d.ts +22 -2
  208. package/lib/util/compressedIds.d.ts.map +1 -1
  209. package/lib/util/compressedIds.js +22 -1
  210. package/lib/util/compressedIds.js.map +1 -1
  211. package/package.json +29 -22
  212. package/src/core/index.ts +2 -0
  213. package/src/core/rebase/index.ts +2 -0
  214. package/src/core/rebase/types.ts +113 -0
  215. package/src/entrypoints/alpha.ts +10 -6
  216. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -14
  217. package/src/index.ts +7 -4
  218. package/src/packageVersion.ts +1 -1
  219. package/src/shared-tree/sharedTree.ts +6 -1
  220. package/src/shared-tree/treeCheckout.ts +81 -14
  221. package/src/shared-tree-core/branch.ts +1 -0
  222. package/src/shared-tree-core/sharedTreeCore.ts +1 -1
  223. package/src/simple-tree/api/index.ts +0 -1
  224. package/src/simple-tree/api/schemaStatics.ts +2 -2
  225. package/src/simple-tree/api/treeNodeApi.ts +64 -48
  226. package/src/simple-tree/core/treeNode.ts +13 -10
  227. package/src/simple-tree/core/withType.ts +20 -7
  228. package/src/simple-tree/index.ts +1 -2
  229. package/src/simple-tree/leafNodeSchema.ts +6 -1
  230. package/src/simple-tree/node-kinds/array/arrayNode.ts +109 -14
  231. package/src/simple-tree/node-kinds/map/mapNode.ts +113 -3
  232. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
  233. package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
  234. package/src/text/README.md +1 -1
  235. package/src/text/codePointUtils.ts +2 -2
  236. package/src/text/index.ts +3 -3
  237. package/src/text/textDomain.ts +21 -21
  238. package/src/text/textDomainFormatted.ts +56 -52
  239. package/src/text/textDomainFormattedDefault.ts +14 -23
  240. package/src/util/compressedIds.ts +36 -3
@@ -54,7 +54,7 @@ import {
54
54
  charactersFromString,
55
55
  expensiveInternalValidationAssert,
56
56
  processCharactersChangedDelta,
57
- type TextAsTree,
57
+ type PlainText,
58
58
  } from "./textDomain.js";
59
59
 
60
60
  /**
@@ -95,7 +95,7 @@ export class StringTextAtomNode
95
95
  */
96
96
  content: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),
97
97
  })
98
- implements FormattedTextAsTree.TextAtom
98
+ implements FormattedText.TextAtom
99
99
  {
100
100
  public static fromCharacter(value: string): StringTextAtomNode {
101
101
  const character = oneFromIterable(charactersFromString(value));
@@ -115,16 +115,19 @@ export class StringTextAtomNode
115
115
 
116
116
  /**
117
117
  * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
118
+ *
118
119
  * @remarks
119
120
  * This is generic over formatting an embedded object/atom types.
120
- * See {@link FormattedTextAsTreeDefault} for a default parameterization.
121
+ *
121
122
  * @privateRemarks
123
+ * See {@link FormattedTextDefault} for an example parameterization.
124
+ *
122
125
  * TODO:
123
126
  * - Add more comprehensive tests for generic parameterizations other than default.
124
127
  * - Sort out API around overwriting subsets of formatting information.
125
- * @internal
128
+ * @alpha
126
129
  */
127
- export namespace FormattedTextAsTree {
130
+ export namespace FormattedText {
128
131
  /**
129
132
  * Creates a schema for a formatted text node, parameterized by the formatting and the embedded object (atom) types.
130
133
  *
@@ -133,16 +136,17 @@ export namespace FormattedTextAsTree {
133
136
  * This scope is used to distinguish different usages of `createSchema` from each-other, and must be kept the same between versions for nodes to remain compatible.
134
137
  * It must be different to distinguish different formatted text schema within the same document.
135
138
  * @param formatSchema - Schema describing the formatting associated with each atom of text.
136
- * Use an {@link NodeKind.Object|Object node} to support {@link FormattedTextAsTree.Members.formatRange}.
137
- * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)}.
139
+ * Use an {@link NodeKind.Object|Object node} to support {@link FormattedText.Members.formatRange}.
140
+ * @param extraAtoms - Additional atom schema to allow as text content beyond the built-in {@link FormattedText.(StringTextAtom:variable)}.
138
141
  * Use this to embed richer content (for example line breaks or inline objects) alongside plain characters.
139
142
  * @param defaultFormatInsertable - The formatting applied to text inserted via non-formatted APIs
140
- * (for example {@link FormattedTextAsTree.Members.insertAt} and {@link FormattedTextAsTree.Statics.fromString} when no explicit format is provided).
141
- * @returns The schema for the formatted text node, whose nodes implement {@link FormattedTextAsTree.Members} and whose statics implement {@link FormattedTextAsTree.Statics}.
142
- * @remarks
143
- * See {@link FormattedTextAsTreeDefault} for a default parameterization of this factory.
143
+ * (for example {@link FormattedText.Members.insertAt} and {@link FormattedText.Statics.fromString} when no explicit format is provided).
144
+ * @returns The schema for the formatted text node, whose nodes implement {@link FormattedText.Members} and whose statics implement {@link FormattedText.Statics}.
145
+ *
144
146
  * @privateRemarks
145
- * TODO: The choice to always include the built-in {@link FormattedTextAsTree.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
147
+ * See {@link FormattedTextDefault} for an example parameterization of this factory.
148
+ *
149
+ * TODO: The choice to always include the built-in {@link FormattedText.(StringTextAtom:variable)} is a design decision that should be re-evaluated before stabilizing.
146
150
  */
147
151
  export function createSchema<
148
152
  const TUserScope extends string,
@@ -302,7 +306,7 @@ export namespace FormattedTextAsTree {
302
306
  );
303
307
  return [key, value] as const;
304
308
  });
305
- this.#editRange(start, end, "FormattedTextAsTree.formatRange", (atom) => {
309
+ this.#editRange(start, end, "FormattedText.formatRange", (atom) => {
306
310
  const formatNode: TreeNode | TreeValue = atom.format;
307
311
  const atomFormatSchema = TreeStatic.schema(formatNode);
308
312
  if (!isObjectNodeSchema(atomFormatSchema)) {
@@ -338,7 +342,7 @@ export namespace FormattedTextAsTree {
338
342
  format?: InsertableTreeFieldFromImplicitField<FormatSchema>,
339
343
  ): void {
340
344
  const node = getFormatNode(format);
341
- this.#editRange(start, end, "FormattedTextAsTree.reformat", (atom) => {
345
+ this.#editRange(start, end, "FormattedText.reformat", (atom) => {
342
346
  atom.format = cloneFormat(node);
343
347
  });
344
348
  }
@@ -375,7 +379,7 @@ export namespace FormattedTextAsTree {
375
379
  }
376
380
 
377
381
  /**
378
- * Returns the {@link FormattedTextAsTree.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
382
+ * Returns the {@link FormattedText.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
379
383
  */
380
384
  private getAtomCharacterAt(index: number): string | undefined {
381
385
  const atom = this.content[index];
@@ -384,7 +388,7 @@ export namespace FormattedTextAsTree {
384
388
  }
385
389
 
386
390
  public onCharactersChanged(
387
- callback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,
391
+ callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
388
392
  ): () => void {
389
393
  return TreeAlpha.on(this.content, "nodeChanged", ({ delta }) =>
390
394
  processCharactersChangedDelta(
@@ -396,7 +400,7 @@ export namespace FormattedTextAsTree {
396
400
  }
397
401
 
398
402
  public onContentChanged(
399
- callback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,
403
+ callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
400
404
  ): () => void {
401
405
  return TreeAlpha.on(this.content, "treeChanged", ({ delta }) =>
402
406
  processCharactersChangedDelta(
@@ -487,7 +491,7 @@ export namespace FormattedTextAsTree {
487
491
  // TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.
488
492
  // A less general optimization could just include cases for build in types with constant values
489
493
  // (like below commented code: currently this would cause a cyclical dependency but could be refactored).
490
- // case FormattedTextAsTree.StringLineAtom.identifier: {
494
+ // case FormattedText.StringLineAtom.identifier: {
491
495
  // content = "\n";
492
496
  // break;
493
497
  // }
@@ -524,12 +528,12 @@ export namespace FormattedTextAsTree {
524
528
  }
525
529
 
526
530
  public getString(startIndex: number, endIndex: number = this.length): string {
527
- validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getString");
531
+ validateIndexRange(startIndex, endIndex, this, "FormattedText.getString");
528
532
  return this.getCharactersSubarray(startIndex, endIndex).join("");
529
533
  }
530
534
 
531
535
  public getUniformRun(startIndex: number, endIndex: number = this.length): number {
532
- validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getUniformRun");
536
+ validateIndexRange(startIndex, endIndex, this, "FormattedText.getUniformRun");
533
537
  if (endIndex === startIndex) {
534
538
  throw new UsageError("endIndex must be greater than startIndex for getUniformRun.");
535
539
  }
@@ -602,8 +606,8 @@ export namespace FormattedTextAsTree {
602
606
  /**
603
607
  * Schema for a text node.
604
608
  * @remarks
605
- * See {@link FormattedTextAsTree.Members} for the API.
606
- * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
609
+ * See {@link FormattedText.Members} for the API.
610
+ * See {@link FormattedText.Statics} for static APIs on this Schema, including construction.
607
611
  * @privateRemarks
608
612
  * eraseSchemaDetailsSubclassable risks user's defining subclass members which collide with internals.
609
613
  * Ideally we would generate private members for non-public properties, but TypeScript does not support this.
@@ -629,7 +633,7 @@ export namespace FormattedTextAsTree {
629
633
  * This is implemented {@link StringAtom}, but we avoid leaking the fact this is a TreeNode in the API surface to
630
634
  * preserve more future flexibility.
631
635
  * @sealed
632
- * @internal
636
+ * @alpha
633
637
  */
634
638
  export interface FormattedAtom<TFormat, TText> {
635
639
  /**
@@ -648,8 +652,8 @@ export namespace FormattedTextAsTree {
648
652
  * Portion of a string.
649
653
  * @remarks
650
654
  * Additional kinds of text atoms (also known as embedded objects) which can occur inside a string can implement this.
651
- * The schema for them can then be provided to {@link FormattedTextAsTree.createSchema}.
652
- * @internal
655
+ * The schema for them can then be provided to {@link FormattedText.createSchema}.
656
+ * @alpha
653
657
  */
654
658
  export interface TextAtom {
655
659
  /**
@@ -659,14 +663,14 @@ export namespace FormattedTextAsTree {
659
663
  }
660
664
 
661
665
  /**
662
- * Static factory functions for {@link FormattedTextAsTree.(StringTextAtom:variable)}.
666
+ * Static factory functions for {@link FormattedText.(StringTextAtom:variable)}.
663
667
  * @privateRemarks
664
668
  * We type-erase `StringTextAtom` and only provide these static factories for construction
665
669
  * to reduce the chance of someone accidentally creating a text atom for a string other than a single unicode code point.
666
670
  * Other strings should work, but our intention is to provide no type-safe API which can produce them, so an application can take their lack of existence as an invariant if they want.
667
671
  * It is still however possible to produce them, like export/import round trips with editing in the middle of the process, or collaboration with an equivalent schema which doesn't enforce this invariant.
668
672
  * @sealed
669
- * @internal
673
+ * @alpha
670
674
  */
671
675
  export interface StringTextAtomStatics {
672
676
  /**
@@ -682,18 +686,18 @@ export namespace FormattedTextAsTree {
682
686
  }
683
687
 
684
688
  /**
685
- * Schema for a {@link FormattedTextAsTree.(StringTextAtom:variable)} node.
689
+ * Schema for a {@link FormattedText.(StringTextAtom:variable)} node.
686
690
  * @sealed
687
- * @internal
691
+ * @alpha
688
692
  */
689
693
  export const StringTextAtom = eraseSchemaDetails<TextAtom, StringTextAtomStatics>()(
690
694
  StringTextAtomNode,
691
695
  );
692
696
 
693
697
  /**
694
- * Node for the {@link FormattedTextAsTree.(StringTextAtom:variable)} schema.
698
+ * Node for the {@link FormattedText.(StringTextAtom:variable)} schema.
695
699
  * @sealed
696
- * @internal
700
+ * @alpha
697
701
  */
698
702
  export type StringTextAtom = ErasedNode<
699
703
  TextAtom,
@@ -703,7 +707,7 @@ export namespace FormattedTextAsTree {
703
707
  /**
704
708
  * Statics for formatted text nodes.
705
709
  * @sealed
706
- * @internal
710
+ * @alpha
707
711
  */
708
712
  export interface Statics<TTree, FormatSchema extends ImplicitAllowedTypes> {
709
713
  /**
@@ -729,23 +733,23 @@ export namespace FormattedTextAsTree {
729
733
  * (which often operates on something in between unicode code points and grapheme clusters)
730
734
  * and navigation/selection (which typically uses grapheme clusters).
731
735
  *
732
- * @see {@link FormattedTextAsTree.Statics.fromString} for construction.
733
- * @see {@link FormattedTextAsTree.createSchema} for creating schemas whose nodes implement this.
736
+ * @see {@link FormattedText.Statics.fromString} for construction.
737
+ * @see {@link FormattedText.createSchema} for creating schemas whose nodes implement this.
734
738
  * @sealed
735
- * @internal
739
+ * @alpha
736
740
  */
737
741
  export interface Members<
738
742
  FormatSchema extends ImplicitAllowedTypes,
739
743
  ExtraAtomsSchema extends readonly LazyItem<
740
744
  TreeNodeSchema<string, NodeKind, TextAtom & TreeNode>
741
745
  >[],
742
- > extends TextAsTree.Members {
746
+ > extends PlainText.Members {
743
747
  /**
744
- * {@link TextAsTree.Members.insertAt} with optional formatting to apply to all additional characters,
748
+ * {@link PlainText.Members.insertAt} with optional formatting to apply to all additional characters,
745
749
  * and allowing an array of atoms instead of a string.
746
- * @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedTextAsTree.createSchema}) will be used.
750
+ * @param format - Optional formatting to apply to all additional characters. If not specified, the default formatting (from {@link FormattedText.createSchema}) will be used.
747
751
  * @remarks
748
- * Use {@link FormattedTextAsTree.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.
752
+ * Use {@link FormattedText.Members.insertWithFormattingAt} if you need to specify formatting for atom independently.
749
753
  * @override
750
754
  */
751
755
  insertAt(
@@ -761,7 +765,7 @@ export namespace FormattedTextAsTree {
761
765
  * @remarks
762
766
  * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.
763
767
  *
764
- * For more efficient access, use {@link FormattedTextAsTree.Members.getUniformRun} and {@link FormattedTextAsTree.Members.getString} to access ranges of characters
768
+ * For more efficient access, use {@link FormattedText.Members.getUniformRun} and {@link FormattedText.Members.getString} to access ranges of characters
765
769
  * to avoid having to inspect the formatting on every atom.
766
770
  * @privateRemarks
767
771
  * Currently this is implemented by a node and changes with the text over time.
@@ -777,7 +781,7 @@ export namespace FormattedTextAsTree {
777
781
  * Insert a range of characters into the string based on character index.
778
782
  * @remarks
779
783
  * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.
780
- * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.
784
+ * See {@link FormattedText.Statics.fromString} for how the `additionalCharacters` string is broken into characters.
781
785
  * @privateRemarks
782
786
  * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.
783
787
  * Doing this currently would enable insertion of text with different character boundaries than the existing text,
@@ -827,13 +831,13 @@ export namespace FormattedTextAsTree {
827
831
  * @param endIndex - The ending index (exclusive) of the range to format.
828
832
  * @param format - The formatting to replace the formatting of the indicated range with.
829
833
  * For each atom, `format` will be cloned and assigned to the atom's format, overwriting any existing formatting.
830
- * If not specified the `defaultFormat` from {@link FormattedTextAsTree.createSchema} will be used.
834
+ * If not specified the `defaultFormat` from {@link FormattedText.createSchema} will be used.
831
835
  * @remarks
832
836
  * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.
833
837
  *
834
838
  * This is typically used to normalize formatting, like resetting the formatting of a range to default settings.
835
839
  * @privateRemarks
836
- * See notes on {@link FormattedTextAsTree.Members.formatRange} for future optimization opportunities.
840
+ * See notes on {@link FormattedText.Members.formatRange} for future optimization opportunities.
837
841
  */
838
842
  reformat(
839
843
  startIndex?: number | undefined,
@@ -857,14 +861,14 @@ export namespace FormattedTextAsTree {
857
861
  /**
858
862
  * Subscribe to all content changes on this text node, including both shallow
859
863
  * changes (inserts/removes) and deep changes (formatting updates on existing characters).
860
- * @param callback - Called after each change with a sequence of {@link TextAsTree.TextOp}s describing what changed,
864
+ * @param callback - Called after each change with a sequence of {@link PlainText.TextOp}s describing what changed,
861
865
  * or `undefined` when a delta could not be computed (e.g. during a schema upgrade).
862
866
  * @returns A cleanup function that unsubscribes the callback when called.
863
867
  * @remarks
864
- * Unlike {@link TextAsTree.Members.onCharactersChanged} which only fires on
868
+ * Unlike {@link PlainText.Members.onCharactersChanged} which only fires on
865
869
  * shallow changes (inserts and removes), this method also fires on deep changes —
866
870
  * formatting property updates on existing characters.
867
- * The {@link TextAsTree.TextRetainOp.formattingChanged} flag on retain ops
871
+ * The {@link PlainText.TextRetainOp.formattingChanged} flag on retain ops
868
872
  * indicates which character ranges had formatting updates.
869
873
  *
870
874
  * All counts in the delivered ops are in Unicode code points, not UTF-16 code units.
@@ -872,14 +876,14 @@ export namespace FormattedTextAsTree {
872
876
  * corresponds to two UTF-16 code units — convert before using the counts as string indices.
873
877
  */
874
878
  onContentChanged(
875
- callback: (ops: readonly TextAsTree.TextOp[] | undefined) => void,
879
+ callback: (ops: readonly PlainText.TextOp[] | undefined) => void,
876
880
  ): () => void;
877
881
  }
878
882
 
879
883
  /**
880
- * Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.
884
+ * Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.
881
885
  * @input
882
- * @internal
886
+ * @alpha
883
887
  */
884
888
  export interface FormattedAtomInsertable<TFormat, TContent> {
885
889
  readonly content: TContent;
@@ -890,7 +894,7 @@ export namespace FormattedTextAsTree {
890
894
  * Schema identifier for the a generic formatted text schema.
891
895
  * @privateRemarks
892
896
  * Eventually this should probably be given a better name and/or made a system type in a system namespace.
893
- * @internal
897
+ * @alpha
894
898
  */
895
899
  export type FormattedTextSchemaIdentifier<TUserScope extends string> = ScopedSchemaName<
896
900
  `com.fluidframework.text.formatted<${TUserScope}>`,
@@ -903,7 +907,7 @@ export namespace FormattedTextAsTree {
903
907
  * This is just schema for the text atom {@link AllowedTypes},
904
908
  * and does not include the actual formatting (which is higher up in the tree).
905
909
  * @sealed
906
- * @internal
910
+ * @alpha
907
911
  */
908
912
  export type TextAtomSchemas<
909
913
  ExtraAtomsSchema extends readonly LazyItem<
@@ -914,7 +918,7 @@ export namespace FormattedTextAsTree {
914
918
  /**
915
919
  * A generic type for a formatted text schema.
916
920
  * @sealed
917
- * @internal
921
+ * @alpha
918
922
  */
919
923
  export type FormattedTextSchema<
920
924
  TUserScope extends string,
@@ -9,7 +9,7 @@ import type {
9
9
  InsertableTreeNodeFromImplicitAllowedTypes,
10
10
  } from "../simple-tree/index.js";
11
11
 
12
- import { FormattedTextAsTree } from "./textDomainFormatted.js";
12
+ import { FormattedText } from "./textDomainFormatted.js";
13
13
 
14
14
  /**
15
15
  * Schema factory for default formatted text types which are not generic.
@@ -25,21 +25,18 @@ const defaultFormat = {
25
25
  } as const;
26
26
 
27
27
  /**
28
- * A default parameterization of the generic {@link FormattedTextAsTree} with hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
28
+ * A default parameterization of the generic {@link FormattedText} with hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
29
29
  * @remarks
30
- * It is unlikely this meets the needs of most users, but it can serve as an unstable example of how to use the generic {@link FormattedTextAsTree}.
30
+ * It is unlikely this meets the needs of most users, but it can serve as an unstable example of how to use the generic {@link FormattedText}.
31
31
  * @internal
32
32
  */
33
- export namespace FormattedTextAsTreeDefault {
33
+ export namespace FormattedTextDefault {
34
34
  /**
35
35
  * Portion of a string with formatting.
36
36
  * @sealed
37
37
  * @internal
38
38
  */
39
- export type FormattedAtom = FormattedTextAsTree.FormattedAtom<
40
- CharacterFormat,
41
- StringAtomContent
42
- >;
39
+ export type FormattedAtom = FormattedText.FormattedAtom<CharacterFormat, StringAtomContent>;
43
40
 
44
41
  /**
45
42
  * Formatting options for characters.
@@ -74,7 +71,7 @@ export namespace FormattedTextAsTreeDefault {
74
71
  "codeBlock",
75
72
  ]);
76
73
  /**
77
- * {@inheritdoc FormattedTextAsTreeDefault.(LineTag:variable)}
74
+ * {@inheritdoc FormattedTextDefault.(LineTag:variable)}
78
75
  * @sealed
79
76
  * @internal
80
77
  */
@@ -104,12 +101,9 @@ export namespace FormattedTextAsTreeDefault {
104
101
  * @sealed
105
102
  * @internal
106
103
  */
107
- export const StringAtomContent = [
108
- FormattedTextAsTree.StringTextAtom,
109
- StringLineAtom,
110
- ] as const;
104
+ export const StringAtomContent = [FormattedText.StringTextAtom, StringLineAtom] as const;
111
105
  /**
112
- * {@inheritdoc FormattedTextAsTreeDefault.(StringAtomContent:variable)}
106
+ * {@inheritdoc FormattedTextDefault.(StringAtomContent:variable)}
113
107
  * @sealed
114
108
  * @internal
115
109
  */
@@ -120,17 +114,14 @@ export namespace FormattedTextAsTreeDefault {
120
114
  * @sealed
121
115
  * @internal
122
116
  */
123
- export type Statics<TTree = Tree> = FormattedTextAsTree.Statics<
124
- TTree,
125
- typeof CharacterFormat
126
- >;
117
+ export type Statics<TTree = Tree> = FormattedText.Statics<TTree, typeof CharacterFormat>;
127
118
 
128
119
  /**
129
- * Insertable shape for a formatted text atom used by {@link FormattedTextAsTree.Members.insertWithFormattingAt}.
120
+ * Insertable shape for a formatted text atom used by {@link FormattedText.Members.insertWithFormattingAt}.
130
121
  * @sealed
131
122
  * @internal
132
123
  */
133
- export type FormattedAtomInsertable = FormattedTextAsTree.FormattedAtom<
124
+ export type FormattedAtomInsertable = FormattedText.FormattedAtom<
134
125
  InsertableTreeNodeFromImplicitAllowedTypes<typeof CharacterFormat>,
135
126
  InsertableTreeNodeFromImplicitAllowedTypes<TextAtomSchemas>
136
127
  >;
@@ -142,15 +133,15 @@ export namespace FormattedTextAsTreeDefault {
142
133
  * @sealed
143
134
  * @internal
144
135
  */
145
- export type TextAtomSchemas = FormattedTextAsTree.TextAtomSchemas<[typeof StringLineAtom]>;
136
+ export type TextAtomSchemas = FormattedText.TextAtomSchemas<[typeof StringLineAtom]>;
146
137
 
147
138
  /**
148
- * The schema produced using {@link FormattedTextAsTree.createSchema} with hard-coded assumptions
139
+ * The schema produced using {@link FormattedText.createSchema} with hard-coded assumptions
149
140
  * about what kind of embedded content and what kind of formatting is supported.
150
141
  * @sealed
151
142
  * @internal
152
143
  */
153
- export class Tree extends FormattedTextAsTree.createSchema(
144
+ export class Tree extends FormattedText.createSchema(
154
145
  sf,
155
146
  CharacterFormat,
156
147
  [StringLineAtom],
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { LogLevel, type ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6
7
  import { assert } from "@fluidframework/core-utils/internal";
7
8
  import type {
8
9
  IIdCompressor,
@@ -166,6 +167,12 @@ export interface IdentifierHealingConfig {
166
167
  * same session offsets.
167
168
  */
168
169
  readonly sharedObjectId: string;
170
+
171
+ /**
172
+ * Optional logger used by {@link forceDecodeEncodedIdWithoutSession} to record telemetry
173
+ * when the heal-on-decode recovery path is taken (a non-final identifier is healed).
174
+ */
175
+ readonly logger?: ITelemetryBaseLogger;
169
176
  }
170
177
 
171
178
  /**
@@ -177,6 +184,16 @@ export interface IdentifierHealingConfig {
177
184
  * deterministic v5 UUID string — *not* a `StableId`, since that brand requires
178
185
  * v4, but still a valid identifier value; the `string` arm of the return type
179
186
  * covers this case.
187
+ *
188
+ * The recovery (heal) path only occurs because of a prior bug where non-finalized identifiers were
189
+ * written into summaries. When {@link IdentifierHealingConfig.logger} is supplied, a telemetry event
190
+ * is recorded on that path so heals can be observed in the wild. The error/throw path is intentionally
191
+ * not instrumented here: the thrown exception is expected to surface via the application's own error
192
+ * telemetry, and should never be silently swallowed.
193
+ *
194
+ * @param id - The op-space compressed ID to decode.
195
+ * @param idCompressor - The ID compressor used to normalize the ID.
196
+ * @param healing - Heal-on-decode configuration. Presence enables healing of non-final IDs.
180
197
  */
181
198
  export function forceDecodeEncodedIdWithoutSession(
182
199
  id: OpSpaceCompressedId,
@@ -189,7 +206,19 @@ export function forceDecodeEncodedIdWithoutSession(
189
206
  }
190
207
  // `id` is a non-final op-space compressed id.
191
208
  if (healing !== undefined) {
192
- return uuidV5(`${healing.sharedObjectId}|${id}`, healingNamespace);
209
+ const healed = uuidV5(`${healing.sharedObjectId}|${id}`, healingNamespace);
210
+ healing.logger?.send(
211
+ {
212
+ category: "generic",
213
+ eventName: "HealUnresolvableIdentifierOnDecode",
214
+ },
215
+ // This telemetry should be very low-volume (and possibly never happen at all),
216
+ // as should only occur when loading documents that were corrupted by a now fixed bug and have not been re-summarized since healing was added.
217
+ // It is useful for monitoring and diagnosing for this to be reported in the same cases in which the error case would be reported,
218
+ // which is the essential level.
219
+ LogLevel.essential,
220
+ );
221
+ return healed;
193
222
  }
194
223
  throw new Error(
195
224
  "Summary could not be loaded due to an incorrectly encoded identifier. See SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode for mitigation.",
@@ -261,9 +290,13 @@ export interface IdDecoderOptionsWithOriginator {
261
290
  */
262
291
  export class IdDecodingContext {
263
292
  /**
264
- * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
293
+ * Whether this context resolves identifiers using an originator session ID.
294
+ * @remarks
295
+ * Consulted by {@link FieldBatchDecodingContext} to prevent using an originator-based
296
+ * decoder in incremental chunks (which may come from other sessions, making such a
297
+ * decoder wrong there).
265
298
  */
266
- protected readonly hasOriginatorSessionId: boolean;
299
+ public readonly hasOriginatorSessionId: boolean;
267
300
 
268
301
  /**
269
302
  * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.