@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.
Files changed (291) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/tree.alpha.api.md +19 -0
  3. package/dist/codec/codec.d.ts +22 -53
  4. package/dist/codec/codec.d.ts.map +1 -1
  5. package/dist/codec/codec.js +7 -44
  6. package/dist/codec/codec.js.map +1 -1
  7. package/dist/codec/index.d.ts +1 -1
  8. package/dist/codec/index.d.ts.map +1 -1
  9. package/dist/codec/index.js +2 -2
  10. package/dist/codec/index.js.map +1 -1
  11. package/dist/codec/versioned/codec.d.ts +56 -28
  12. package/dist/codec/versioned/codec.d.ts.map +1 -1
  13. package/dist/codec/versioned/codec.js +29 -12
  14. package/dist/codec/versioned/codec.js.map +1 -1
  15. package/dist/codec/versioned/index.d.ts +1 -1
  16. package/dist/codec/versioned/index.d.ts.map +1 -1
  17. package/dist/codec/versioned/index.js +2 -2
  18. package/dist/codec/versioned/index.js.map +1 -1
  19. package/dist/core/tree/deltaUtil.d.ts +2 -2
  20. package/dist/core/tree/deltaUtil.js +2 -2
  21. package/dist/core/tree/deltaUtil.js.map +1 -1
  22. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  23. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  24. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  26. package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -2
  27. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
  29. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
  31. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
  33. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/chunkTree.js +62 -4
  35. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/chunkedForest.js +18 -4
  38. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
  40. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +106 -3
  42. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
  44. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  46. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
  48. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
  51. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +9 -3
  53. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
  55. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
  56. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +44 -0
  57. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
  58. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
  59. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/format/index.js +5 -1
  61. package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
  63. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +7 -1
  65. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  67. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +1 -2
  69. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  70. package/dist/feature-libraries/forest-summary/codec.d.ts +5 -4
  71. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  72. package/dist/feature-libraries/forest-summary/codec.js +2 -2
  73. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  74. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
  75. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  76. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  77. package/dist/feature-libraries/schema-index/codec.d.ts +2 -2
  78. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  79. package/dist/feature-libraries/schema-index/codec.js +1 -1
  80. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +3 -1
  84. package/dist/index.js.map +1 -1
  85. package/dist/packageVersion.d.ts +1 -1
  86. package/dist/packageVersion.js +1 -1
  87. package/dist/packageVersion.js.map +1 -1
  88. package/dist/shared-tree/isAuditableFromOutcome.d.ts +20 -0
  89. package/dist/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
  90. package/dist/shared-tree/isAuditableFromOutcome.js +36 -0
  91. package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -0
  92. package/dist/shared-tree/treeCheckout.d.ts +2 -0
  93. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  94. package/dist/shared-tree/treeCheckout.js +37 -8
  95. package/dist/shared-tree/treeCheckout.js.map +1 -1
  96. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -3
  97. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  98. package/dist/shared-tree-core/editManagerCodecs.js +2 -2
  99. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  100. package/dist/shared-tree-core/messageCodecs.d.ts +3 -3
  101. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  102. package/dist/shared-tree-core/messageCodecs.js +2 -2
  103. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  104. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  105. package/dist/simple-tree/core/treeNodeKernel.js +25 -11
  106. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  107. package/dist/text/codePointUtils.d.ts +48 -0
  108. package/dist/text/codePointUtils.d.ts.map +1 -0
  109. package/dist/text/codePointUtils.js +80 -0
  110. package/dist/text/codePointUtils.js.map +1 -0
  111. package/dist/text/index.d.ts +1 -0
  112. package/dist/text/index.d.ts.map +1 -1
  113. package/dist/text/index.js +4 -1
  114. package/dist/text/index.js.map +1 -1
  115. package/dist/text/textDomain.d.ts +93 -1
  116. package/dist/text/textDomain.d.ts.map +1 -1
  117. package/dist/text/textDomain.js +65 -8
  118. package/dist/text/textDomain.js.map +1 -1
  119. package/dist/text/textDomainFormatted.d.ts +24 -6
  120. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  121. package/dist/text/textDomainFormatted.js +29 -1
  122. package/dist/text/textDomainFormatted.js.map +1 -1
  123. package/dist/treeFactory.d.ts.map +1 -1
  124. package/dist/treeFactory.js +9 -7
  125. package/dist/treeFactory.js.map +1 -1
  126. package/dist/util/breakable.d.ts +7 -1
  127. package/dist/util/breakable.d.ts.map +1 -1
  128. package/dist/util/breakable.js +18 -4
  129. package/dist/util/breakable.js.map +1 -1
  130. package/lib/codec/codec.d.ts +22 -53
  131. package/lib/codec/codec.d.ts.map +1 -1
  132. package/lib/codec/codec.js +7 -44
  133. package/lib/codec/codec.js.map +1 -1
  134. package/lib/codec/index.d.ts +1 -1
  135. package/lib/codec/index.d.ts.map +1 -1
  136. package/lib/codec/index.js +1 -1
  137. package/lib/codec/index.js.map +1 -1
  138. package/lib/codec/versioned/codec.d.ts +56 -28
  139. package/lib/codec/versioned/codec.d.ts.map +1 -1
  140. package/lib/codec/versioned/codec.js +27 -10
  141. package/lib/codec/versioned/codec.js.map +1 -1
  142. package/lib/codec/versioned/index.d.ts +1 -1
  143. package/lib/codec/versioned/index.d.ts.map +1 -1
  144. package/lib/codec/versioned/index.js +1 -1
  145. package/lib/codec/versioned/index.js.map +1 -1
  146. package/lib/core/tree/deltaUtil.d.ts +2 -2
  147. package/lib/core/tree/deltaUtil.js +2 -2
  148. package/lib/core/tree/deltaUtil.js.map +1 -1
  149. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  150. package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
  151. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  152. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  153. package/lib/core/tree/detachedFieldIndexCodecV2.js +5 -3
  154. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  155. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
  156. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  157. package/lib/core/tree/detachedFieldIndexCodecs.js +2 -2
  158. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  159. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
  160. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  161. package/lib/feature-libraries/chunked-forest/chunkTree.js +61 -4
  162. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  163. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  164. package/lib/feature-libraries/chunked-forest/chunkedForest.js +20 -6
  165. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  166. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
  167. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  168. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +102 -2
  169. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  170. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
  171. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  172. package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
  173. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  174. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
  175. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  176. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  177. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +25 -5
  178. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
  179. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +8 -2
  180. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
  181. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +105 -0
  182. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
  183. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js +41 -0
  184. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
  185. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
  186. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
  187. package/lib/feature-libraries/chunked-forest/codec/format/index.js +2 -1
  188. package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
  189. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
  190. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
  191. package/lib/feature-libraries/chunked-forest/codec/format/versions.js +6 -0
  192. package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  193. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  194. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  195. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +2 -3
  196. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  197. package/lib/feature-libraries/forest-summary/codec.d.ts +5 -4
  198. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  199. package/lib/feature-libraries/forest-summary/codec.js +3 -3
  200. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  201. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
  202. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  203. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  204. package/lib/feature-libraries/schema-index/codec.d.ts +2 -2
  205. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  206. package/lib/feature-libraries/schema-index/codec.js +2 -2
  207. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  208. package/lib/index.d.ts +1 -1
  209. package/lib/index.d.ts.map +1 -1
  210. package/lib/index.js +1 -1
  211. package/lib/index.js.map +1 -1
  212. package/lib/packageVersion.d.ts +1 -1
  213. package/lib/packageVersion.js +1 -1
  214. package/lib/packageVersion.js.map +1 -1
  215. package/lib/shared-tree/isAuditableFromOutcome.d.ts +20 -0
  216. package/lib/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
  217. package/lib/shared-tree/isAuditableFromOutcome.js +32 -0
  218. package/lib/shared-tree/isAuditableFromOutcome.js.map +1 -0
  219. package/lib/shared-tree/treeCheckout.d.ts +2 -0
  220. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  221. package/lib/shared-tree/treeCheckout.js +37 -8
  222. package/lib/shared-tree/treeCheckout.js.map +1 -1
  223. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -3
  224. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  225. package/lib/shared-tree-core/editManagerCodecs.js +3 -3
  226. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  227. package/lib/shared-tree-core/messageCodecs.d.ts +3 -3
  228. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  229. package/lib/shared-tree-core/messageCodecs.js +3 -3
  230. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  231. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  232. package/lib/simple-tree/core/treeNodeKernel.js +25 -11
  233. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  234. package/lib/text/codePointUtils.d.ts +48 -0
  235. package/lib/text/codePointUtils.d.ts.map +1 -0
  236. package/lib/text/codePointUtils.js +75 -0
  237. package/lib/text/codePointUtils.js.map +1 -0
  238. package/lib/text/index.d.ts +1 -0
  239. package/lib/text/index.d.ts.map +1 -1
  240. package/lib/text/index.js +1 -0
  241. package/lib/text/index.js.map +1 -1
  242. package/lib/text/textDomain.d.ts +93 -1
  243. package/lib/text/textDomain.d.ts.map +1 -1
  244. package/lib/text/textDomain.js +56 -0
  245. package/lib/text/textDomain.js.map +1 -1
  246. package/lib/text/textDomainFormatted.d.ts +24 -6
  247. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  248. package/lib/text/textDomainFormatted.js +30 -2
  249. package/lib/text/textDomainFormatted.js.map +1 -1
  250. package/lib/treeFactory.d.ts.map +1 -1
  251. package/lib/treeFactory.js +2 -0
  252. package/lib/treeFactory.js.map +1 -1
  253. package/lib/util/breakable.d.ts +7 -1
  254. package/lib/util/breakable.d.ts.map +1 -1
  255. package/lib/util/breakable.js +18 -4
  256. package/lib/util/breakable.js.map +1 -1
  257. package/package.json +24 -24
  258. package/src/codec/codec.ts +82 -73
  259. package/src/codec/index.ts +2 -1
  260. package/src/codec/versioned/codec.ts +173 -73
  261. package/src/codec/versioned/index.ts +2 -1
  262. package/src/core/tree/deltaUtil.ts +2 -2
  263. package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -2
  264. package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -3
  265. package/src/core/tree/detachedFieldIndexCodecs.ts +2 -2
  266. package/src/feature-libraries/chunked-forest/chunkTree.ts +85 -1
  267. package/src/feature-libraries/chunked-forest/chunkedForest.ts +27 -7
  268. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +143 -7
  269. package/src/feature-libraries/chunked-forest/codec/codecs.ts +30 -28
  270. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +7 -7
  271. package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +11 -7
  272. package/src/feature-libraries/chunked-forest/codec/format/formatVText.ts +83 -0
  273. package/src/feature-libraries/chunked-forest/codec/format/index.ts +6 -1
  274. package/src/feature-libraries/chunked-forest/codec/format/versions.ts +25 -4
  275. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +14 -18
  276. package/src/feature-libraries/forest-summary/codec.ts +9 -4
  277. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +1 -1
  278. package/src/feature-libraries/schema-index/codec.ts +2 -5
  279. package/src/index.ts +6 -1
  280. package/src/packageVersion.ts +1 -1
  281. package/src/shared-tree/isAuditableFromOutcome.ts +34 -0
  282. package/src/shared-tree/treeCheckout.ts +52 -9
  283. package/src/shared-tree-core/editManagerCodecs.ts +4 -6
  284. package/src/shared-tree-core/messageCodecs.ts +4 -4
  285. package/src/simple-tree/core/treeNodeKernel.ts +27 -13
  286. package/src/text/codePointUtils.ts +81 -0
  287. package/src/text/index.ts +1 -0
  288. package/src/text/textDomain.ts +155 -2
  289. package/src/text/textDomainFormatted.ts +73 -2
  290. package/src/treeFactory.ts +5 -0
  291. package/src/util/breakable.ts +27 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.102.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.101.0
4
8
 
5
9
  ### Minor Changes
@@ -1587,17 +1587,36 @@ export namespace TableSchema {
1587
1587
 
1588
1588
  // @alpha
1589
1589
  export namespace TextAsTree {
1590
+ // @sealed
1590
1591
  export interface Members {
1591
1592
  characterCount(): number;
1592
1593
  characters(): Iterable<string>;
1593
1594
  charactersCopy(): string[];
1594
1595
  fullString(): string;
1595
1596
  insertAt(index: number, additionalCharacters: string): void;
1597
+ onCharactersChanged(callback: (ops: readonly TextOp[] | undefined) => void): () => void;
1596
1598
  removeRange(startIndex: number | undefined, endIndex: number | undefined): void;
1597
1599
  }
1598
1600
  export interface Statics {
1599
1601
  fromString(value: string): Tree;
1600
1602
  }
1603
+ // @sealed
1604
+ export interface TextInsertOp {
1605
+ readonly text: string;
1606
+ readonly type: "insert";
1607
+ }
1608
+ export type TextOp = TextRetainOp | TextInsertOp | TextRemoveOp;
1609
+ // @sealed
1610
+ export interface TextRemoveOp {
1611
+ readonly count: number;
1612
+ readonly type: "remove";
1613
+ }
1614
+ // @sealed
1615
+ export interface TextRetainOp {
1616
+ readonly count: number;
1617
+ readonly formattingChanged?: boolean;
1618
+ readonly type: "retain";
1619
+ }
1601
1620
  const Tree: Statics & TreeNodeSchema<"com.fluidframework.text.Text", NodeKind, Members & TreeNode & WithType<"com.fluidframework.text.Text", NodeKind, unknown>, never, false>;
1602
1621
  export type Tree = Members & TreeNode & WithType<"com.fluidframework.text.Text">;
1603
1622
  }
@@ -144,8 +144,9 @@ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta
144
144
  readonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;
145
145
  }
146
146
  /**
147
- * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.
148
- * This parameter is typically used for:
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, TContext = void> extends IEncoder<TDecoded, TEncoded, TContext>, IDecoder<TDecoded, TValidate, TContext> {
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, TContext = void> extends IEncoder<TDecoded, Static<TEncodedSchema>, TContext>, IDecoder<TDecoded, Static<TEncodedSchema>, TContext> {
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, TContext = void>(codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TValidate, TValidate, TContext>;
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 This interface currently assumes all codecs in a family require the same encode/decode context,
201
- * which isn't necessarily true.
202
- * This may need to be relaxed in the future.
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, TContext = void> {
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, TContext>;
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, TContext>(registry: Iterable<[
264
+ export declare function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(registry: Iterable<[
264
265
  formatVersion: FormatVersion,
265
- codec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>
266
- ]>): ICodecFamily<TDecoded, TContext>;
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 ClientVersionDispatchingCodecBuilder, resulting in that having the only use of this API.
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, TContext>(schema: EncodedSchema, codec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>, validator?: JsonValidator | FormatValidator): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>;
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
- * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.
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
- * The entries in these enums should document the following:
294
- * - The user facing impact of opting into a particular version. This will help customers decide if they want to opt into
295
- * a new version. For example, document if there is an encoding efficiency improvement of oping into that version or newer.
296
- * - Any new data formats that are introduced in that version. This will help developers tell which data formats a given
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
@@ -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,kB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OAQG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;OAQG;;CAEwD,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,uBAA2D,CAAC;AAEzF;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS,CAAC,cAAc,SAAS,aAAa,GAAG,aAAa;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,sBAAsB,CAMzE"}
@@ -98,7 +98,7 @@ exports.unitCodec = {
98
98
  * Wraps a codec with JSON schema validation for its encoded type.
99
99
  * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
100
100
  * @remarks
101
- * Eventually all codecs should use the same pattern implemented by ClientVersionDispatchingCodecBuilder, resulting in that having the only use of this API.
101
+ * Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.
102
102
  */
103
103
  function withSchemaValidation(schema, codec, validator) {
104
104
  if (!validator) {
@@ -124,59 +124,22 @@ function withSchemaValidation(schema, codec, validator) {
124
124
  }
125
125
  exports.withSchemaValidation = withSchemaValidation;
126
126
  /**
127
- * Versions of Fluid Framework client packages.
127
+ * Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.
128
128
  * @remarks
129
- * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.
130
- *
131
- * 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.
132
- * 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,
133
- * but the semantics of keys in this enum will not change.
134
- *
135
- * Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.
136
- *
137
- * Some release may also be omitted if there is currently no need to express that specific version.
138
- * If the need arises, they might be added in the future.
129
+ * Versions with no notable impact may be omitted, and added later if needed.
139
130
  *
140
131
  * @privateRemarks
141
- * The entries in these enums should document the following:
142
- * - The user facing impact of opting into a particular version. This will help customers decide if they want to opt into
143
- * a new version. For example, document if there is an encoding efficiency improvement of oping into that version or newer.
144
- * - Any new data formats that are introduced in that version. This will help developers tell which data formats a given
145
- * version will write. For example, document if a new summary or encoding format is added in a version.
146
- * - Whether the above features or data formats introduced in a version are enabled by default or require the
147
- * {@link minVersionForCollab} option to be set to that particular version.
148
- *
149
- * Versions with no notable impact can be omitted.
150
- *
151
- * This scheme assumes a single version will always be enough to communicate compatibility.
152
- * For this to work, compatibility has to be strictly increasing.
153
- * 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),
154
- * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:
155
- * such a system can be added if/when its needed since it will be opt in and thus non-breaking.
156
- *
157
- * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.
158
- * 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.
159
- * For example, if needed, would adding more leading zeros to the minor version break things.
132
+ * Each entry should document:
133
+ * - The user-facing impact of opting into it (e.g. encoding efficiency improvements).
134
+ * - Any new data formats introduced in that version.
135
+ * - Whether those features/formats are enabled by default or require {@link MinimumVersionForCollab | minVersionForCollab} to be set accordingly.
160
136
  * @alpha
161
137
  */
162
138
  exports.FluidClientVersion = {
163
- /**
164
- * Fluid Framework Client 1.4 and newer.
165
- * @remarks
166
- * This opts into support for the 1.4 LTS branch.
167
- * @privateRemarks
168
- * As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.
169
- */
170
- // v1_4 = 1.004,
171
139
  /**
172
140
  * Fluid Framework Client 2.0 and newer.
173
141
  */
174
142
  v2_0: "2.0.0",
175
- /** Fluid Framework Client 2.1 and newer. */
176
- // If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),
177
- // we could add an entry like this to allow users to indicate that they can be opted in once we are ready,
178
- // then update it to "2.001" once we actually have the opt in working.
179
- // v2_1 = v2_0,
180
143
  /**
181
144
  * Fluid Framework Client 2.43 and newer.
182
145
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAmE;AAEnE,qEAAoH;AA0DpH;;;;GAIG;AACH,MAAM,aAAa,GAAkB;IACpC,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC;AAEF;;;GAGG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEpE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAsB;IACvD,OAAO,OAAqC,CAAC;AAC9C,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAsC;IAC1E,OAAO,KAAiC,CAAC;AAC1C,CAAC;AAFD,oDAEC;AAoID;;GAEG;AACH,SAAgB,gBAAgB,CAM/B,KAA0D;IAE1D,OAAO,KAAwE,CAAC;AACjF,CAAC;AATD,4CASC;AAkED,MAAa,4BAA4B;IAGxC,YAAoC,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IACrD,MAAM,CAAC,OAAsB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAPD,oEAOC;AAED,MAAa,4BAA4B;IAKxC,YAAoC,GAA+C;QAA/C,QAAG,GAAH,GAAG,CAA4C;IAAG,CAAC;IAChF,MAAM,CAAC,MAAsB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,C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;;;;OAQG;IACH,KAAK,EAAE,QAAQ;CAC4C,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACU,QAAA,cAAc,GAA4B,gCAAiC,CAAC;AAgBzF,SAAgB,iBAAiB,CAAC,IAAe;IAChD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;KAC/C,CAAC;AACH,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @input @beta\n */\nexport interface CodecWriteOptionsBeta {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * 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`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * Part of a codec.\n * @remarks\n * Encode and decode logic and schema for some chunk of data.\n * Can be composed into larger codecs, and eventually versioned at the top level using\n * {@link VersionDispatchingCodecBuilder}.\n *\n * This portion of a codec is not responsible for managing versioning or validation of the data against the schema.\n */\nexport interface JsonCodecPart<TDecoded, TEncodedSchema extends TAnySchema, TContext = void>\n\textends IEncoder<TDecoded, Static<TEncodedSchema>, TContext>,\n\t\tIDecoder<TDecoded, Static<TEncodedSchema>, TContext> {\n\t/**\n\t * TypeBox schema which describes the encoded format for this chunk of data.\n\t * @remarks\n\t * The user of this codec can use this to build its own larger schema,\n\t * until eventually it is provided to the {@link VersionDispatchingCodecBuilder}.\n\t */\n\tencodedSchema: TEncodedSchema;\n}\n\n/**\n * Type erase the more detailed encoded type from a codec.\n */\nexport function eraseEncodedType<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TValidate, TValidate, TContext> {\n\treturn codec as unknown as IJsonCodec<TDecoded, TValidate, TValidate, TContext>;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, codec);\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: FormatVersion,\n\t\t): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IJsonCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tencode: () => 0,\n\tdecode: () => 0,\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n * @remarks\n * Eventually all codecs should use the same pattern implemented by ClientVersionDispatchingCodecBuilder, resulting in that having the only use of this API.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat,\n\tTValidate,\n\tTContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded data should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Data being decoded should validate */);\n\t\t\t}\n\t\t\treturn codec.decode(encoded, context);\n\t\t},\n\t\tencodedSchema: schema,\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages.\n * @remarks\n * Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.\n *\n * 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.\n * 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,\n * but the semantics of keys in this enum will not change.\n *\n * Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.\n *\n * Some release may also be omitted if there is currently no need to express that specific version.\n * If the need arises, they might be added in the future.\n *\n * @privateRemarks\n * The entries in these enums should document the following:\n * - The user facing impact of opting into a particular version. This will help customers decide if they want to opt into\n * a new version. For example, document if there is an encoding efficiency improvement of oping into that version or newer.\n * - Any new data formats that are introduced in that version. This will help developers tell which data formats a given\n * version will write. For example, document if a new summary or encoding format is added in a version.\n * - Whether the above features or data formats introduced in a version are enabled by default or require the\n * {@link minVersionForCollab} option to be set to that particular version.\n *\n * Versions with no notable impact can be omitted.\n *\n * This scheme assumes a single version will always be enough to communicate compatibility.\n * For this to work, compatibility has to be strictly increasing.\n * 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),\n * a more complex scheme may be needed to allow safely opting into incompatible features in those cases:\n * such a system can be added if/when its needed since it will be opt in and thus non-breaking.\n *\n * TODO: this should likely be defined higher in the stack and specified when creating the container, possibly as part of its schema.\n * 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.\n * For example, if needed, would adding more leading zeros to the minor version break things.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 1.4 and newer.\n\t * @remarks\n\t * This opts into support for the 1.4 LTS branch.\n\t * @privateRemarks\n\t * As long as this code is in Tree, there is no reason to have this option as SharedTree did not exist in 1.4.\n\t */\n\t// v1_4 = 1.004,\n\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/** Fluid Framework Client 2.1 and newer. */\n\t// If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),\n\t// we could add an entry like this to allow users to indicate that they can be opted in once we are ready,\n\t// then update it to \"2.001\" once we actually have the opt in working.\n\t// v2_1 = v2_0,\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n} as const satisfies Record<string, MinimumVersionForCollab>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid MinimumVersionForCollab\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: MinimumVersionForCollab = runtimeUtilsCleanedPackageVersion;\n\n/**\n * TODO:\n * This needs to be documented.\n * Its documentation should cover at least the following:\n * - Is this used for anything other than testing.\n * - What should be included as children. For example should it include versioned codecs which dispatch base on the min version for collaboration? If so, what version of them should be used?\n * - What risks does having this mitigate?\n */\nexport interface CodecTree<TFormatVersion extends FormatVersion = FormatVersion> {\n\treadonly name: string;\n\treadonly version: TFormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAmE;AAEnE,qEAAoH;AA0DpH;;;;GAIG;AACH,MAAM,aAAa,GAAkB;IACpC,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC;AAEF;;;GAGG;AACU,QAAA,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAEpE;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAsB;IACvD,OAAO,OAAqC,CAAC;AAC9C,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAsC;IAC1E,OAAO,KAAiC,CAAC;AAC1C,CAAC;AAFD,oDAEC;AA0ID;;GAEG;AACH,SAAgB,gBAAgB,CAO/B,KAAgF;IAEhF,OA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AtCD,oDAsCC;AAED;;;;;;;;;;;GAWG;AACU,QAAA,kBAAkB,GAAG;IACjC;;OAEG;IACH,IAAI,EAAE,OAAO;IAEb;;;;;;;;OAQG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;OAKG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;OAKG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;;;;;;;OAWG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;;;;OAQG;IACH,KAAK,EAAE,QAAQ;CAC4C,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACU,QAAA,cAAc,GAA4B,gCAAiC,CAAC;AAgBzF,SAAgB,iBAAiB,CAAC,IAAe;IAChD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,CAAC;KAC/C,CAAC;AACH,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from \"@fluidframework/runtime-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * A kind of validator for SharedTree's internal data formats.\n * @remarks\n * Assuming no data corruption or type confusion, such validation should never fail.\n * Any client version compatibility issues should instead be detected by the data format versioning which Shared Tree does internally independent of data format validation.\n * However, persisted data can sometimes be corrupted, bugs can produce invalid data, or users can mix up which data is compatible with which APIs.\n * In such cases, a format validator can help catch issues.\n *\n * Current options are {@link FormatValidatorNoOp} and {@link FormatValidatorBasic}.\n * @privateRemarks\n * Implement using {@link toFormatValidator}.\n * Consume using {@link extractJsonValidator}.\n *\n * Exposing this as the stable API entry point (instead of {@link JsonValidator}) means that we avoid leaking the reference to TypeBox to the API surface.\n * Additionally, if we adopt non JSON formats, we can just update the validators as needed without breaking the API.\n * This also allows us to avoid stabilizing or documenting how handles interact with JSON validation since that is not exposed through this type.\n * @sealed @alpha\n */\nexport interface FormatValidator extends ErasedType<\"FormatValidator\"> {}\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n */\nconst noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n\n/**\n * A {@link FormatValidator} which does no validation.\n * @alpha\n */\nexport const FormatValidatorNoOp = toFormatValidator(noopValidator);\n\n/**\n * Type erase a {@link JsonValidator} to a {@link FormatValidator}.\n */\nexport function toFormatValidator(factory: JsonValidator): FormatValidator {\n\treturn factory as unknown as FormatValidator;\n}\n\n/**\n * Un-type-erase the {@link FormatValidator}.\n */\nexport function extractJsonValidator(input: FormatValidator | JsonValidator): JsonValidator {\n\treturn input as unknown as JsonValidator;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha @input\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n *\n * @see {@link CodecWriteOptions} for options that are specific to encoding data.\n * @alpha @input\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link FormatValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t * @remarks\n\t * See {@link FormatValidatorNoOp} and {@link FormatValidatorBasic} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `FormatValidatorNoOp`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t * @privateRemarks\n\t * This property should probably be renamed to `validator` before stabilizing the API.\n\t */\n\treadonly jsonValidator: FormatValidator;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @input @beta\n */\nexport interface CodecWriteOptionsBeta {\n\t/**\n\t * The minimum version of the Fluid Framework client output must be encoded to be compatible with.\n\t * @remarks\n\t * This is used to ensure that the the output from this codec can be used with older versions of the Fluid Framework client.\n\t * This includes both concurrent collaboration, and an older version opening the document later.\n\t *\n\t * Note that versions older than this should not result in data corruption if they access the data:\n\t * the data's format should be versioned and if they can't handle the format they should error.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab;\n}\n\n/**\n * Options relating to encoding of persisted data.\n * @remarks\n * Extends {@link ICodecOptions} with options that are specific to encoding data.\n * @alpha @input\n */\nexport interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {\n\t/**\n\t * Overrides the version of the codec to use for encoding.\n\t * @remarks\n\t * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;\n\n\t/**\n\t * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.\n\t */\n\treadonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;\n}\n\n/**\n * `TEncodeContext` and `TDecodeContext` allow passing context to the codec which may configure how data is encoded/decoded.\n * `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).\n * These parameters are typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of {@link https://en.wikipedia.org/wiki/Dictionary_coder | dictionary coding}\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * 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`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, TEncoded, TEncodeContext>,\n\t\tIDecoder<TDecoded, TValidate, TDecodeContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * Part of a codec.\n * @remarks\n * Encode and decode logic and schema for some chunk of data.\n * Can be composed into larger codecs, and eventually versioned at the top level using\n * {@link VersionDispatchingCodecBuilder}.\n *\n * This portion of a codec is not responsible for managing versioning or validation of the data against the schema.\n */\nexport interface JsonCodecPart<\n\tTDecoded,\n\tTEncodedSchema extends TAnySchema,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> extends IEncoder<TDecoded, Static<TEncodedSchema>, TEncodeContext>,\n\t\tIDecoder<TDecoded, Static<TEncodedSchema>, TDecodeContext> {\n\t/**\n\t * TypeBox schema which describes the encoded format for this chunk of data.\n\t * @remarks\n\t * The user of this codec can use this to build its own larger schema,\n\t * until eventually it is provided to the {@link VersionDispatchingCodecBuilder}.\n\t */\n\tencodedSchema: TEncodedSchema;\n}\n\n/**\n * Type erase the more detailed encoded type from a codec.\n */\nexport function eraseEncodedType<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n>(\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TEncodeContext, TDecodeContext>,\n): IJsonCodec<TDecoded, TValidate, TValidate, TEncodeContext, TDecodeContext> {\n\treturn codec as unknown as IJsonCodec<\n\t\tTDecoded,\n\t\tTValidate,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks\n * Encode and decode can be parameterized independently — the encode-side context type need not equal the decode-side context type.\n * `TDecodeContext` defaults to `TEncodeContext` so callers that share a single context shape (the common case) don't need to specify it.\n */\nexport interface ICodecFamily<\n\tTDecoded,\n\tTEncodeContext = void,\n\tTDecodeContext = TEncodeContext,\n> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IJsonCodec<\n\t\tTDecoded,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n * @remarks\n * Strings are used for formats that are not yet officially supported.\n * When such formats become officially supported/stable, they will be switched to using a number.\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n * @alpha\n */\nexport type FormatVersion = number | string | undefined;\n\n/**\n * A unique name given to this codec family.\n * @remarks\n * This is not persisted: it is only used to specify version overrides and in errors.\n * @alpha\n */\nexport type CodecName = string;\n\n/**\n * A format version which is dependent on some parent format version.\n */\nexport interface DependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> {\n\t/**\n\t * Looks up the child format version for a given parent format version.\n\t * @param parent - The parent format version.\n\t * @returns The corresponding child format version.\n\t */\n\tlookup(parent: TParentVersion): TChildVersion;\n}\n\nexport class UniqueDependentFormatVersion<TChildVersion extends FormatVersion>\n\timplements DependentFormatVersion<FormatVersion, TChildVersion>\n{\n\tpublic constructor(private readonly child: TChildVersion) {}\n\tpublic lookup(_parent: FormatVersion): TChildVersion {\n\t\treturn this.child;\n\t}\n}\n\nexport class MappedDependentFormatVersion<\n\tTParentVersion extends FormatVersion = FormatVersion,\n\tTChildVersion extends FormatVersion = FormatVersion,\n> implements DependentFormatVersion<TParentVersion, TChildVersion>\n{\n\tpublic constructor(private readonly map: ReadonlyMap<TParentVersion, TChildVersion>) {}\n\tpublic lookup(parent: TParentVersion): TChildVersion {\n\t\treturn this.map.get(parent) ?? fail(0xc73 /* Unknown parent version */);\n\t}\n}\n\nexport const DependentFormatVersion = {\n\tfromUnique: <TChildVersion extends FormatVersion>(\n\t\tchild: TChildVersion,\n\t): UniqueDependentFormatVersion<TChildVersion> => new UniqueDependentFormatVersion(child),\n\tfromMap: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tmap: ReadonlyMap<TParentVersion, TChildVersion>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(map),\n\tfromPairs: <TParentVersion extends FormatVersion, TChildVersion extends FormatVersion>(\n\t\tpairs: Iterable<[TParentVersion, TChildVersion]>,\n\t): MappedDependentFormatVersion<TParentVersion, TChildVersion> =>\n\t\tnew MappedDependentFormatVersion(new Map(pairs)),\n};\n\n/**\n * Creates a codec family from a registry of codecs.\n */\nexport function makeCodecFamily<TDecoded, TEncodeContext, TDecodeContext = TEncodeContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec: IJsonCodec<\n\t\t\t\tTDecoded,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tJsonCompatibleReadOnly,\n\t\t\t\tTEncodeContext,\n\t\t\t\tTDecodeContext\n\t\t\t>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TEncodeContext, TDecodeContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(0xabf /* Duplicate codecs specified. */);\n\t\t}\n\t\tcodecs.set(formatVersion, codec);\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: FormatVersion,\n\t\t): IJsonCodec<\n\t\t\tTDecoded,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tTEncodeContext,\n\t\t\tTDecodeContext\n\t\t> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IJsonCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tencode: () => 0,\n\tdecode: () => 0,\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n * @remarks\n * Eventually all codecs should use the same pattern implemented by VersionDispatchingCodecBuilder, resulting in that having the only use of this API.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat,\n\tTValidate,\n\tTEncodeContext,\n\tTDecodeContext = TEncodeContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<\n\t\tTInMemoryFormat,\n\t\tTEncodedFormat,\n\t\tTValidate,\n\t\tTEncodeContext,\n\t\tTDecodeContext\n\t>,\n\tvalidator?: JsonValidator | FormatValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TEncodeContext, TDecodeContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = extractJsonValidator(validator).compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TEncodeContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac0 /* Encoded data should validate */);\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TDecodeContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(0xac1 /* Data being decoded should validate */);\n\t\t\t}\n\t\t\treturn codec.decode(encoded, context);\n\t\t},\n\t\tencodedSchema: schema,\n\t};\n}\n\n/**\n * Versions of Fluid Framework client packages, usable as a {@link @fluidframework/runtime-definitions#MinimumVersionForCollab}.\n * @remarks\n * Versions with no notable impact may be omitted, and added later if needed.\n *\n * @privateRemarks\n * Each entry should document:\n * - The user-facing impact of opting into it (e.g. encoding efficiency improvements).\n * - Any new data formats introduced in that version.\n * - Whether those features/formats are enabled by default or require {@link MinimumVersionForCollab | minVersionForCollab} to be set accordingly.\n * @alpha\n */\nexport const FluidClientVersion = {\n\t/**\n\t * Fluid Framework Client 2.0 and newer.\n\t */\n\tv2_0: \"2.0.0\",\n\n\t/**\n\t * Fluid Framework Client 2.43 and newer.\n\t * @remarks\n\t * New formats introduced in 2.43:\n\t * - SchemaFormatVersion.v2 - written when minVersionForCollab \\>= 2.43\n\t * - MessageFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - EditManagerFormatVersion.v4 - written when minVersionForCollab \\>= 2.43\n\t * - sequence-field/formatV3 - written when minVersionForCollab \\>= 2.43\n\t */\n\tv2_43: \"2.43.0\",\n\n\t/**\n\t * Fluid Framework Client 2.52 and newer.\n\t * @remarks\n\t * New formats introduced in 2.52:\n\t * - DetachedFieldIndexFormatVersion.v2 - written when minVersionForCollab \\>= 2.52\n\t */\n\tv2_52: \"2.52.0\",\n\n\t/**\n\t * Fluid Framework Client 2.73 and newer.\n\t * @remarks\n\t * New formats introduced in 2.73:\n\t * - FieldBatchFormatVersion.v2 - written when minVersionForCollab \\>= 2.73\n\t */\n\tv2_73: \"2.73.0\",\n\n\t/**\n\t * Fluid Framework Client 2.74 and newer.\n\t * @remarks\n\t * New formats introduced in 2.74:\n\t * - SharedTreeSummaryFormatVersion.v2 - written by default\n\t * - DetachedFieldIndexSummaryFormatVersion.v2 - written by default\n\t * - SchemaSummaryFormatVersion.v2 - written by default\n\t * - EditManagerSummaryFormatVersion.v2 - written by default\n\t * - ForestSummaryFormatVersion.v2 - written by default\n\t * - ForestFormatVersion.v2 - written when minVersionForCollab \\>= 2.74\n\t * - ForestSummaryFormatVersion.v3 - written when minVersionForCollab \\>= 2.74\n\t */\n\tv2_74: \"2.74.0\",\n\n\t/**\n\t * Fluid Framework Client 2.80 and newer.\n\t * @remarks\n\t * New formats introduced in 2.80:\n\t * - MessageFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - EditManagerFormatVersion.v6 - written when minVersionForCollab \\>= 2.80\n\t * - SharedTreeChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \\>= 2.80\n\t */\n\tv2_80: \"2.80.0\",\n} as const satisfies Record<string, MinimumVersionForCollab>;\n\n/**\n * An up to date version which includes all stable features.\n * @remarks\n * Use for cases when data is not persisted and thus would only ever be read by the the same version of the code which read this value.\n *\n * The pkgVersion from this package (tree) can not be used here as it is not guaranteed to be a valid MinimumVersionForCollab\n * and would also unexpectedly disable features in prereleases and on CI if it didn't fail validation.\n * See {@link @fluidframework/runtime-utils/internal#cleanedPackageVersion} for more details on why cleanedPackageVersion is preferred over pkgVersion.\n *\n * @privateRemarks\n * It is safe to use CleanedPackageVersion from runtime-utils here since features are enabled in minor versions,\n * and this package (tree) depends on runtime-utils with a `~` semver range\n * ensuring that the version of runtime-utils this was imported from will match the version of this (tree) package at least up to the minor version.\n * Reusing this from runtime-utils avoids duplicating the cleanup logic here as well as the cost or recomputing it.\n * If in the future for some reason this becomes not okay, runtime-utils could instead export a function that performs that cleanup logic which could be reused here.\n */\nexport const currentVersion: MinimumVersionForCollab = runtimeUtilsCleanedPackageVersion;\n\n/**\n * TODO:\n * This needs to be documented.\n * Its documentation should cover at least the following:\n * - Is this used for anything other than testing.\n * - What should be included as children. For example should it include versioned codecs which dispatch base on the min version for collaboration? If so, what version of them should be used?\n * - What risks does having this mitigate?\n */\nexport interface CodecTree<TFormatVersion extends FormatVersion = FormatVersion> {\n\treadonly name: string;\n\treadonly version: TFormatVersion;\n\treadonly children?: readonly CodecTree[];\n}\n\nexport function jsonableCodecTree(tree: CodecTree): JsonCompatibleReadOnly {\n\treturn {\n\t\tname: tree.name,\n\t\tversion: tree.version ?? \"null\",\n\t\tchildren: tree.children?.map(jsonableCodecTree),\n\t};\n}\n"]}
@@ -4,5 +4,5 @@
4
4
  */
5
5
  export { type FormatVersion, DependentFormatVersion, type ICodecFamily, type ICodecOptions, type CodecWriteOptions, type CodecWriteOptionsBeta, type IDecoder, type IEncoder, type IJsonCodec, type JsonValidator, makeCodecFamily, type SchemaValidationFunction, unitCodec, withSchemaValidation, FluidClientVersion, currentVersion, toFormatValidator, FormatValidatorNoOp, type FormatValidator, type CodecTree, jsonableCodecTree, extractJsonValidator, type CodecName, eraseEncodedType, type JsonCodecPart, } from "./codec.js";
6
6
  export { DiscriminatedUnionDispatcher, type DiscriminatedUnionLibrary, unionOptions, } from "./discriminatedUnions.js";
7
- export { Versioned, makeDiscontinuedCodecAndSchema, ClientVersionDispatchingCodecBuilder, type CodecVersion, type CodecAndSchema, versionField, } from "./versioned/index.js";
7
+ export { Versioned, makeDiscontinuedCodecAndSchema, VersionDispatchingCodecBuilder, type VersionDispatchingCodec, type CodecVersion, type CodecAndSchema, versionField, } from "./versioned/index.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,wBAAwB,EAC7B,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,SAAS,EACd,gBAAgB,EAChB,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,SAAS,EACT,8BAA8B,EAC9B,oCAAoC,EACpC,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,YAAY,GACZ,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,wBAAwB,EAC7B,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,SAAS,EACd,gBAAgB,EAChB,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,4BAA4B,EAC5B,KAAK,yBAAyB,EAC9B,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,SAAS,EACT,8BAA8B,EAC9B,8BAA8B,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,YAAY,GACZ,MAAM,sBAAsB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.versionField = exports.ClientVersionDispatchingCodecBuilder = exports.makeDiscontinuedCodecAndSchema = exports.Versioned = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.eraseEncodedType = exports.extractJsonValidator = exports.jsonableCodecTree = exports.FormatValidatorNoOp = exports.toFormatValidator = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.makeCodecFamily = exports.DependentFormatVersion = void 0;
7
+ exports.versionField = exports.VersionDispatchingCodecBuilder = exports.makeDiscontinuedCodecAndSchema = exports.Versioned = exports.unionOptions = exports.DiscriminatedUnionDispatcher = exports.eraseEncodedType = exports.extractJsonValidator = exports.jsonableCodecTree = exports.FormatValidatorNoOp = exports.toFormatValidator = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.makeCodecFamily = exports.DependentFormatVersion = void 0;
8
8
  var codec_js_1 = require("./codec.js");
9
9
  Object.defineProperty(exports, "DependentFormatVersion", { enumerable: true, get: function () { return codec_js_1.DependentFormatVersion; } });
10
10
  Object.defineProperty(exports, "makeCodecFamily", { enumerable: true, get: function () { return codec_js_1.makeCodecFamily; } });
@@ -23,6 +23,6 @@ Object.defineProperty(exports, "unionOptions", { enumerable: true, get: function
23
23
  var index_js_1 = require("./versioned/index.js");
24
24
  Object.defineProperty(exports, "Versioned", { enumerable: true, get: function () { return index_js_1.Versioned; } });
25
25
  Object.defineProperty(exports, "makeDiscontinuedCodecAndSchema", { enumerable: true, get: function () { return index_js_1.makeDiscontinuedCodecAndSchema; } });
26
- Object.defineProperty(exports, "ClientVersionDispatchingCodecBuilder", { enumerable: true, get: function () { return index_js_1.ClientVersionDispatchingCodecBuilder; } });
26
+ Object.defineProperty(exports, "VersionDispatchingCodecBuilder", { enumerable: true, get: function () { return index_js_1.VersionDispatchingCodecBuilder; } });
27
27
  Object.defineProperty(exports, "versionField", { enumerable: true, get: function () { return index_js_1.versionField; } });
28
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCA0BoB;AAxBnB,kHAAA,sBAAsB,OAAA;AAStB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AACpB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AAGnB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AAEpB,4GAAA,gBAAgB,OAAA;AAGjB,mEAIkC;AAHjC,sIAAA,4BAA4B,OAAA;AAE5B,sHAAA,YAAY,OAAA;AAEb,iDAO8B;AAN7B,qGAAA,SAAS,OAAA;AACT,0HAAA,8BAA8B,OAAA;AAC9B,gIAAA,oCAAoC,OAAA;AAGpC,wGAAA,YAAY,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FormatVersion,\n\tDependentFormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n\ttype CodecWriteOptionsBeta,\n\ttype IDecoder,\n\ttype IEncoder,\n\ttype IJsonCodec,\n\ttype JsonValidator,\n\tmakeCodecFamily,\n\ttype SchemaValidationFunction,\n\tunitCodec,\n\twithSchemaValidation,\n\tFluidClientVersion,\n\tcurrentVersion,\n\ttoFormatValidator,\n\tFormatValidatorNoOp,\n\ttype FormatValidator,\n\ttype CodecTree,\n\tjsonableCodecTree,\n\textractJsonValidator,\n\ttype CodecName,\n\teraseEncodedType,\n\ttype JsonCodecPart,\n} from \"./codec.js\";\nexport {\n\tDiscriminatedUnionDispatcher,\n\ttype DiscriminatedUnionLibrary,\n\tunionOptions,\n} from \"./discriminatedUnions.js\";\nexport {\n\tVersioned,\n\tmakeDiscontinuedCodecAndSchema,\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecVersion,\n\ttype CodecAndSchema,\n\tversionField,\n} from \"./versioned/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCA0BoB;AAxBnB,kHAAA,sBAAsB,OAAA;AAStB,2GAAA,eAAe,OAAA;AAEf,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AACpB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AAGnB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AAEpB,4GAAA,gBAAgB,OAAA;AAGjB,mEAIkC;AAHjC,sIAAA,4BAA4B,OAAA;AAE5B,sHAAA,YAAY,OAAA;AAEb,iDAQ8B;AAP7B,qGAAA,SAAS,OAAA;AACT,0HAAA,8BAA8B,OAAA;AAC9B,0HAAA,8BAA8B,OAAA;AAI9B,wGAAA,YAAY,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype FormatVersion,\n\tDependentFormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype CodecWriteOptions,\n\ttype CodecWriteOptionsBeta,\n\ttype IDecoder,\n\ttype IEncoder,\n\ttype IJsonCodec,\n\ttype JsonValidator,\n\tmakeCodecFamily,\n\ttype SchemaValidationFunction,\n\tunitCodec,\n\twithSchemaValidation,\n\tFluidClientVersion,\n\tcurrentVersion,\n\ttoFormatValidator,\n\tFormatValidatorNoOp,\n\ttype FormatValidator,\n\ttype CodecTree,\n\tjsonableCodecTree,\n\textractJsonValidator,\n\ttype CodecName,\n\teraseEncodedType,\n\ttype JsonCodecPart,\n} from \"./codec.js\";\nexport {\n\tDiscriminatedUnionDispatcher,\n\ttype DiscriminatedUnionLibrary,\n\tunionOptions,\n} from \"./discriminatedUnions.js\";\nexport {\n\tVersioned,\n\tmakeDiscontinuedCodecAndSchema,\n\tVersionDispatchingCodecBuilder,\n\ttype VersionDispatchingCodec,\n\ttype CodecVersion,\n\ttype CodecAndSchema,\n\tversionField,\n} from \"./versioned/index.js\";\n"]}