@fluidframework/tree 2.82.0 → 2.83.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 (281) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +33 -5
  3. package/api-report/tree.alpha.api.md +25 -21
  4. package/api-report/tree.beta.api.md +14 -2
  5. package/api-report/tree.legacy.beta.api.md +14 -2
  6. package/api-report/tree.legacy.public.api.md +1 -1
  7. package/api-report/tree.public.api.md +1 -1
  8. package/dist/alpha.d.ts +3 -3
  9. package/dist/beta.d.ts +1 -0
  10. package/dist/codec/codec.d.ts +3 -39
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +5 -50
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +1 -2
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/codec/versioned/codec.d.ts +20 -7
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +56 -30
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  23. package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
  24. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  25. package/dist/extensibleUnionNode.d.ts +97 -0
  26. package/dist/extensibleUnionNode.d.ts.map +1 -0
  27. package/dist/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  28. package/dist/extensibleUnionNode.js.map +1 -0
  29. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
  32. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  33. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  34. package/dist/feature-libraries/forest-summary/codec.js +7 -1
  35. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  36. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  37. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  38. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  39. package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  40. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  41. package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
  42. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  43. package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  44. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  45. package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
  46. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  47. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +2 -2
  48. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  49. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -4
  50. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  51. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  52. package/dist/feature-libraries/schema-index/codec.js +6 -4
  53. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  54. package/dist/index.d.ts +2 -2
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +4 -4
  57. package/dist/index.js.map +1 -1
  58. package/dist/legacy.d.ts +1 -0
  59. package/dist/packageVersion.d.ts +1 -1
  60. package/dist/packageVersion.js +1 -1
  61. package/dist/packageVersion.js.map +1 -1
  62. package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -1
  63. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  64. package/dist/shared-tree/tree.d.ts +1 -1
  65. package/dist/shared-tree/tree.js.map +1 -1
  66. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  67. package/dist/shared-tree/treeAlpha.js.map +1 -1
  68. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  69. package/dist/shared-tree/treeCheckout.js +2 -4
  70. package/dist/shared-tree/treeCheckout.js.map +1 -1
  71. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  72. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  73. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
  74. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  75. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  76. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  77. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  78. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  79. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  80. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  81. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  82. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  83. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  84. package/dist/shared-tree-core/messageCodecs.js +2 -2
  85. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  86. package/dist/simple-tree/api/index.d.ts +1 -1
  87. package/dist/simple-tree/api/index.d.ts.map +1 -1
  88. package/dist/simple-tree/api/index.js +2 -2
  89. package/dist/simple-tree/api/index.js.map +1 -1
  90. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  91. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  92. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
  93. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  94. package/dist/simple-tree/api/tree.d.ts +1 -1
  95. package/dist/simple-tree/api/tree.js.map +1 -1
  96. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  97. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  98. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  99. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  100. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  101. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  102. package/dist/simple-tree/core/unhydratedFlexTree.js +29 -0
  103. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  104. package/dist/simple-tree/index.d.ts +1 -1
  105. package/dist/simple-tree/index.d.ts.map +1 -1
  106. package/dist/simple-tree/index.js +2 -2
  107. package/dist/simple-tree/index.js.map +1 -1
  108. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  109. package/dist/simple-tree/node-kinds/array/arrayNode.js +4 -13
  110. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  111. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  112. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +33 -7
  113. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  114. package/dist/text/textDomainFormatted.d.ts +3 -3
  115. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  116. package/dist/text/textDomainFormatted.js +48 -32
  117. package/dist/text/textDomainFormatted.js.map +1 -1
  118. package/dist/util/bTreeUtils.d.ts.map +1 -1
  119. package/dist/util/bTreeUtils.js +6 -6
  120. package/dist/util/bTreeUtils.js.map +1 -1
  121. package/dist/util/rangeMap.d.ts.map +1 -1
  122. package/dist/util/rangeMap.js +5 -6
  123. package/dist/util/rangeMap.js.map +1 -1
  124. package/lib/alpha.d.ts +3 -3
  125. package/lib/beta.d.ts +1 -0
  126. package/lib/codec/codec.d.ts +3 -39
  127. package/lib/codec/codec.d.ts.map +1 -1
  128. package/lib/codec/codec.js +4 -47
  129. package/lib/codec/codec.js.map +1 -1
  130. package/lib/codec/index.d.ts +1 -1
  131. package/lib/codec/index.d.ts.map +1 -1
  132. package/lib/codec/index.js +1 -1
  133. package/lib/codec/index.js.map +1 -1
  134. package/lib/codec/versioned/codec.d.ts +20 -7
  135. package/lib/codec/versioned/codec.d.ts.map +1 -1
  136. package/lib/codec/versioned/codec.js +59 -33
  137. package/lib/codec/versioned/codec.js.map +1 -1
  138. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  139. package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
  140. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  141. package/lib/extensibleUnionNode.d.ts +97 -0
  142. package/lib/extensibleUnionNode.d.ts.map +1 -0
  143. package/lib/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  144. package/lib/extensibleUnionNode.js.map +1 -0
  145. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  146. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  147. package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
  148. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  149. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  150. package/lib/feature-libraries/forest-summary/codec.js +8 -2
  151. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  152. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  153. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  154. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  155. package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  156. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  157. package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
  158. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  159. package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  160. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  161. package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
  162. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  163. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +2 -2
  164. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  165. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -4
  166. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  167. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  168. package/lib/feature-libraries/schema-index/codec.js +6 -4
  169. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  170. package/lib/index.d.ts +2 -2
  171. package/lib/index.d.ts.map +1 -1
  172. package/lib/index.js +2 -2
  173. package/lib/index.js.map +1 -1
  174. package/lib/legacy.d.ts +1 -0
  175. package/lib/packageVersion.d.ts +1 -1
  176. package/lib/packageVersion.js +1 -1
  177. package/lib/packageVersion.js.map +1 -1
  178. package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -1
  179. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  180. package/lib/shared-tree/tree.d.ts +1 -1
  181. package/lib/shared-tree/tree.js.map +1 -1
  182. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  183. package/lib/shared-tree/treeAlpha.js.map +1 -1
  184. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  185. package/lib/shared-tree/treeCheckout.js +2 -4
  186. package/lib/shared-tree/treeCheckout.js.map +1 -1
  187. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  188. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  189. package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
  190. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  191. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  192. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  193. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
  194. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  195. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  196. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  197. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  198. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  199. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  200. package/lib/shared-tree-core/messageCodecs.js +2 -2
  201. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  202. package/lib/simple-tree/api/index.d.ts +1 -1
  203. package/lib/simple-tree/api/index.d.ts.map +1 -1
  204. package/lib/simple-tree/api/index.js +1 -1
  205. package/lib/simple-tree/api/index.js.map +1 -1
  206. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  207. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  208. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
  209. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  210. package/lib/simple-tree/api/tree.d.ts +1 -1
  211. package/lib/simple-tree/api/tree.js.map +1 -1
  212. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  213. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  214. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  215. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  216. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  217. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  218. package/lib/simple-tree/core/unhydratedFlexTree.js +29 -0
  219. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  220. package/lib/simple-tree/index.d.ts +1 -1
  221. package/lib/simple-tree/index.d.ts.map +1 -1
  222. package/lib/simple-tree/index.js +1 -1
  223. package/lib/simple-tree/index.js.map +1 -1
  224. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  225. package/lib/simple-tree/node-kinds/array/arrayNode.js +5 -14
  226. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  227. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  228. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +34 -8
  229. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  230. package/lib/text/textDomainFormatted.d.ts +3 -3
  231. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  232. package/lib/text/textDomainFormatted.js +30 -14
  233. package/lib/text/textDomainFormatted.js.map +1 -1
  234. package/lib/util/bTreeUtils.d.ts.map +1 -1
  235. package/lib/util/bTreeUtils.js +6 -6
  236. package/lib/util/bTreeUtils.js.map +1 -1
  237. package/lib/util/rangeMap.d.ts.map +1 -1
  238. package/lib/util/rangeMap.js +5 -6
  239. package/lib/util/rangeMap.js.map +1 -1
  240. package/package.json +23 -23
  241. package/src/codec/codec.ts +10 -112
  242. package/src/codec/index.ts +0 -3
  243. package/src/codec/versioned/codec.ts +119 -83
  244. package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
  245. package/src/{extensibleSchemaUnion.ts → extensibleUnionNode.ts} +61 -19
  246. package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
  247. package/src/feature-libraries/forest-summary/codec.ts +8 -7
  248. package/src/feature-libraries/forest-summary/formatCommon.ts +5 -3
  249. package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
  250. package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
  251. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +5 -6
  252. package/src/feature-libraries/schema-index/codec.ts +6 -4
  253. package/src/index.ts +3 -3
  254. package/src/packageVersion.ts +1 -1
  255. package/src/shared-tree/sharedTreeChangeCodecs.ts +2 -2
  256. package/src/shared-tree/tree.ts +1 -1
  257. package/src/shared-tree/treeAlpha.ts +1 -1
  258. package/src/shared-tree/treeCheckout.ts +2 -4
  259. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
  260. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
  261. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
  262. package/src/shared-tree-core/messageCodecs.ts +2 -6
  263. package/src/simple-tree/api/index.ts +2 -2
  264. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
  265. package/src/simple-tree/api/tree.ts +1 -1
  266. package/src/simple-tree/api/treeBeta.ts +1 -1
  267. package/src/simple-tree/core/allowedTypes.ts +1 -1
  268. package/src/simple-tree/core/unhydratedFlexTree.ts +43 -1
  269. package/src/simple-tree/index.ts +2 -2
  270. package/src/simple-tree/node-kinds/array/arrayNode.ts +13 -19
  271. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +51 -10
  272. package/src/text/textDomainFormatted.ts +37 -17
  273. package/src/util/bTreeUtils.ts +10 -6
  274. package/src/util/rangeMap.ts +9 -6
  275. package/api-extractor-lint.json +0 -4
  276. package/dist/extensibleSchemaUnion.d.ts +0 -72
  277. package/dist/extensibleSchemaUnion.d.ts.map +0 -1
  278. package/dist/extensibleSchemaUnion.js.map +0 -1
  279. package/lib/extensibleSchemaUnion.d.ts +0 -72
  280. package/lib/extensibleSchemaUnion.d.ts.map +0 -1
  281. package/lib/extensibleSchemaUnion.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.83.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Fix false positive error from FormatValidator ([#26372](https://github.com/microsoft/FluidFramework/pull/26372)) [adad917d30](https://github.com/microsoft/FluidFramework/commit/adad917d30e251f4bfd510e7a1ebc4a73bd1f7ee)
8
+
9
+ Users of the alpha API [FormatValidatorBasic](https://fluidframework.com/docs/api/fluid-framework/#formatvalidatorbasic-variable)
10
+ could hit an "Invalid JSON." error when parsing data.
11
+ This would occur where the result of evaluating "[MinimumVersionForCollab](https://fluidframework.com/docs/api/runtime-definitions/minimumversionforcollab-typealias) \< 2.74.0"
12
+ differed between the client encoding the data and the client decoding it.
13
+ For example opening an old document with a new client that sets `MinimumVersionForCollab = 2.74.0` would throw this error.
14
+ This has been fixed: this case will no longer throw.
15
+
16
+ - New beta ExtensibleUnionNode API ([#26438](https://github.com/microsoft/FluidFramework/pull/26438)) [05f716ffb5](https://github.com/microsoft/FluidFramework/commit/05f716ffb56e280624e65853dd9291411ee752ff)
17
+
18
+ The new `ExtensibleUnionNode` API allows for creation of unions which can tolerate future additions not yet known to the current code.
19
+
20
+ ```typescript
21
+ const sf = new SchemaFactoryBeta("extensibleUnionNodeExample.items");
22
+ class ItemA extends sf.object("A", { x: sf.string }) {}
23
+ class ItemB extends sf.object("B", { x: sf.number }) {}
24
+
25
+ class AnyItem extends ExtensibleUnionNode.createSchema(
26
+ [ItemA, ItemB], // Future versions may add more members here
27
+ sf,
28
+ "ExtensibleUnion",
29
+ ) {}
30
+ // Instances of the union are created using `create`.
31
+ const anyItem = AnyItem.create(new ItemA({ x: "hello" }));
32
+ // Reading the content from the union is done via the `union` property,
33
+ // which can be `undefined` to handle the case where a future version of this schema allows a type unknown to the current version.
34
+ const childNode: ItemA | ItemB | undefined = anyItem.union;
35
+ // To determine which member of the union was present, its schema can be inspected:
36
+ const aSchema = Tree.schema(childNode ?? assert.fail("No child"));
37
+ assert.equal(aSchema, ItemA);
38
+ ```
39
+
40
+ - Improve error messages when failing to construct nodes ([#26433](https://github.com/microsoft/FluidFramework/pull/26433)) [8c612c6f2b](https://github.com/microsoft/FluidFramework/commit/8c612c6f2bc04a1fc1cdc54e620c2180eb73b107)
41
+
42
+ The error messages when constructing tree nodes have been improved.
43
+ Several cases now list not only the schema identifiers, but also schema names which can help when there are identifier collisions and make it easier to find the implementations.
44
+ Additionally some cases which did not include what schema were encountered and which were allowed now include both.
45
+
3
46
  ## 2.82.0
4
47
 
5
48
  ### Minor Changes
package/README.md CHANGED
@@ -53,12 +53,10 @@ API documentation for **@fluidframework/tree** is available at <https://fluidfra
53
53
 
54
54
  ## Status
55
55
 
56
- Notable consideration that early adopters should be wary of:
56
+ Notable considerations that users should be wary of:
57
57
 
58
- - The persisted format is stable such that documents created with released versions 2.0.0 or greater of this package are fully supported long term.
59
- - In versions prior to 2.1.0, SharedTree had unbounded memory growth:
60
- - Removed content was retained in memory and persisted in the document at rest ([fix](https://github.com/microsoft/FluidFramework/pull/21372)). This was fixed in version 2.1.0.
61
- - All range changes are atomized.
58
+ - The persisted format is stable: documents created with released versions 2.0.0 or greater of this package are fully supported long term.
59
+ - All range changes are currently atomized.
62
60
  This means that, when inserting/removing/moving multiple contiguous nodes the edit is split up into separate single node edits.
63
61
  This can impact the merge behavior of these edits, as well as the performance of large array edits.
64
62
  - Some documentation (such as this readme and [the roadmap](docs/roadmap.md)) are out of date.
@@ -165,6 +163,36 @@ Insertable content can still be used in other places, like when nested in other
165
163
  const node = new Test({ data: {} });
166
164
  ```
167
165
 
166
+ See the documentation for [TreeNode](https://fluidframework.com/docs/api/fluid-framework/treenode-class#treenode-remarks) for some notes about explicit vs implicit node construction.
167
+
168
+ ### Why is the only type TypeScript will let me provide as content for my field `undefined`?
169
+
170
+ An optional field allows `undefined` or whatever types the [`AllowedTypes`](https://fluidframework.com/docs/api/fluid-framework/allowedtypes-typealias) for the field permit.
171
+ If the allowed types are getting reduced to `never` only `undefined` will remain.
172
+ See below for why this might happen.
173
+
174
+ ### Why is my insertable content getting typed as `never`?
175
+
176
+ This is a common problem when working with [Input](https://fluidframework.com/docs/api/fluid-framework/input-typealias) types due to the contravariance (see the linked documentation for details).
177
+
178
+ This is most commonly a symptom of the schema having insufficiently specific types for the schema.
179
+ This most commonly happens when declaring a constant for part of a schema which is then used later when building the full schema.
180
+ For example it fails if you do:
181
+
182
+ ```typescript
183
+ const itemTypes = [ItemA, ItemB]; // BAD: use `as const` to fix.
184
+ class Holder extends schemaFactory.object("Holder", { item: itemTypes }) {}
185
+ const holder = new Holder({ item: new ItemA({ a: 42 }) }); // Type 'ItemA' is not assignable to type 'never'.ts(2322)
186
+ ```
187
+
188
+ This can be fixed by capturing a more specific type for the schema:
189
+
190
+ ```typescript
191
+ const itemTypes = [ItemA, ItemB] as const; // Fixed
192
+ class Holder extends schemaFactory.object("Holder", { item: itemTypes }) {}
193
+ const holder = new Holder({ item: new ItemA({ a: 42 }) });
194
+ ```
195
+
168
196
  ## Architecture
169
197
 
170
198
  This section covers the internal structure of the Tree DDS.
@@ -145,9 +145,6 @@ export type ChangeMetadata = LocalChangeMetadata | RemoteChangeMetadata;
145
145
  // @alpha
146
146
  export function checkCompatibility(viewWhichCreatedStoredSchema: TreeViewConfiguration, view: TreeViewConfiguration): Omit<SchemaCompatibilityStatus, "canInitialize">;
147
147
 
148
- // @alpha
149
- export function checkSchemaCompatibilitySnapshots(options: SchemaCompatibilitySnapshotsOptions): void;
150
-
151
148
  // @alpha
152
149
  export function cloneWithReplacements(root: unknown, rootKey: string, replacer: (key: string, value: unknown) => {
153
150
  clone: boolean;
@@ -274,11 +271,12 @@ export function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>)
274
271
  // @alpha
275
272
  export function exportCompatibilitySchemaSnapshot(config: Pick<TreeViewConfiguration, "schema">): JsonCompatibleReadOnly;
276
273
 
277
- // @alpha
278
- export namespace ExtensibleSchemaUnion {
279
- export function extensibleSchemaUnion<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & TreeNodeSchemaCore_2<ScopedSchemaName_2<`com.fluidframework.extensibleSchemaUnion<${TScope}>`, TName>, NodeKind_2, false, unknown, never, unknown> & (new (data: InternalTreeNode_2) => Members<TreeNodeFromImplicitAllowedTypes<T>> & TreeNode_2 & WithType_2<ScopedSchemaName_2<`com.fluidframework.extensibleSchemaUnion<${TScope}>`, TName>, NodeKind_2, unknown>);
274
+ // @beta
275
+ export namespace ExtensibleUnionNode {
276
+ export function createSchema<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & TreeNodeSchemaCore_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, false, unknown, never, unknown> & (new (data: InternalTreeNode_2) => Members<TreeNodeFromImplicitAllowedTypes<T>> & TreeNode_2 & WithType_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, unknown>);
280
277
  export interface Members<T> {
281
- readonly child: T | undefined;
278
+ isValid(): boolean;
279
+ readonly union: T | undefined;
282
280
  }
283
281
  export interface Statics<T extends readonly TreeNodeSchema[]> {
284
282
  create<TThis extends TreeNodeSchema>(this: TThis, child: TreeNodeFromImplicitAllowedTypes<T>): TreeFieldFromImplicitField<TThis>;
@@ -976,17 +974,6 @@ export interface RunTransactionParams {
976
974
  readonly preconditions?: readonly TransactionConstraintAlpha[];
977
975
  }
978
976
 
979
- // @alpha @input
980
- export interface SchemaCompatibilitySnapshotsOptions {
981
- readonly fileSystem: SnapshotFileSystem;
982
- readonly minVersionForCollaboration: string;
983
- readonly mode: "test" | "update";
984
- readonly schema: TreeViewConfiguration;
985
- readonly snapshotDirectory: string;
986
- readonly snapshotUnchangedVersions?: true;
987
- readonly version: string;
988
- }
989
-
990
977
  // @public @sealed
991
978
  export interface SchemaCompatibilityStatus {
992
979
  readonly canInitialize: boolean;
@@ -1223,6 +1210,23 @@ export interface SnapshotFileSystem {
1223
1210
  }): void;
1224
1211
  }
1225
1212
 
1213
+ // @alpha
1214
+ export function snapshotSchemaCompatibility(options: SnapshotSchemaCompatibilityOptions): void;
1215
+
1216
+ // @alpha @input
1217
+ export interface SnapshotSchemaCompatibilityOptions {
1218
+ readonly fileSystem: SnapshotFileSystem;
1219
+ readonly minVersionForCollaboration: string;
1220
+ readonly mode: "assert" | "update";
1221
+ readonly rejectSchemaChangesWithNoVersionChange?: true;
1222
+ readonly rejectVersionsWithNoSchemaChange?: true;
1223
+ readonly schema: TreeViewConfiguration;
1224
+ readonly snapshotDirectory: string;
1225
+ readonly snapshotUnchangedVersions?: true;
1226
+ readonly version: string;
1227
+ readonly versionComparer?: (a: string, b: string) => number;
1228
+ }
1229
+
1226
1230
  // @beta @system
1227
1231
  export namespace System_TableSchema {
1228
1232
  // @sealed @system
@@ -1487,7 +1491,7 @@ export interface TransactionResultSuccess<TSuccessValue> {
1487
1491
  value: TSuccessValue;
1488
1492
  }
1489
1493
 
1490
- // @public @sealed @system
1494
+ // @public @sealed
1491
1495
  export interface Tree extends TreeNodeApi {
1492
1496
  contains(node: TreeNode, other: TreeNode): boolean;
1493
1497
  readonly runTransaction: RunTransaction;
@@ -1496,7 +1500,7 @@ export interface Tree extends TreeNodeApi {
1496
1500
  // @public
1497
1501
  export const Tree: Tree;
1498
1502
 
1499
- // @alpha @sealed @system
1503
+ // @alpha @sealed
1500
1504
  export interface TreeAlpha {
1501
1505
  branch(node: TreeNode): TreeBranchAlpha | undefined;
1502
1506
  child(node: TreeNode, key: string | number): TreeNode | TreeLeafValue | undefined;
@@ -1551,7 +1555,7 @@ export const TreeArrayNode: {
1551
1555
  readonly spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>;
1552
1556
  };
1553
1557
 
1554
- // @beta @sealed @system
1558
+ // @beta @sealed
1555
1559
  export interface TreeBeta {
1556
1560
  clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
1557
1561
  create<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: InsertableTreeFieldFromImplicitField<TSchema>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
@@ -133,6 +133,18 @@ export function enumFromStrings<TScope extends string, const Members extends rea
133
133
  }, Record<string, never>, true, Record<string, never>, undefined>; }[Members[number]] : never>;
134
134
  };
135
135
 
136
+ // @beta
137
+ export namespace ExtensibleUnionNode {
138
+ export function createSchema<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & TreeNodeSchemaCore_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, false, unknown, never, unknown> & (new (data: InternalTreeNode_2) => Members<TreeNodeFromImplicitAllowedTypes<T>> & TreeNode_2 & WithType_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, unknown>);
139
+ export interface Members<T> {
140
+ isValid(): boolean;
141
+ readonly union: T | undefined;
142
+ }
143
+ export interface Statics<T extends readonly TreeNodeSchema[]> {
144
+ create<TThis extends TreeNodeSchema>(this: TThis, child: TreeNodeFromImplicitAllowedTypes<T>): TreeFieldFromImplicitField<TThis>;
145
+ }
146
+ }
147
+
136
148
  // @public @system
137
149
  type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ? Result : Item;
138
150
 
@@ -809,7 +821,7 @@ export namespace TableSchema {
809
821
  // @public
810
822
  export type TransactionConstraint = NodeInDocumentConstraint;
811
823
 
812
- // @public @sealed @system
824
+ // @public @sealed
813
825
  export interface Tree extends TreeNodeApi {
814
826
  contains(node: TreeNode, other: TreeNode): boolean;
815
827
  readonly runTransaction: RunTransaction;
@@ -846,7 +858,7 @@ export const TreeArrayNode: {
846
858
  readonly spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>;
847
859
  };
848
860
 
849
- // @beta @sealed @system
861
+ // @beta @sealed
850
862
  export interface TreeBeta {
851
863
  clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
852
864
  create<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: InsertableTreeFieldFromImplicitField<TSchema>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
@@ -136,6 +136,18 @@ export function enumFromStrings<TScope extends string, const Members extends rea
136
136
  }, Record<string, never>, true, Record<string, never>, undefined>; }[Members[number]] : never>;
137
137
  };
138
138
 
139
+ // @beta
140
+ export namespace ExtensibleUnionNode {
141
+ export function createSchema<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & TreeNodeSchemaCore_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, false, unknown, never, unknown> & (new (data: InternalTreeNode_2) => Members<TreeNodeFromImplicitAllowedTypes<T>> & TreeNode_2 & WithType_2<ScopedSchemaName_2<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, NodeKind_2, unknown>);
142
+ export interface Members<T> {
143
+ isValid(): boolean;
144
+ readonly union: T | undefined;
145
+ }
146
+ export interface Statics<T extends readonly TreeNodeSchema[]> {
147
+ create<TThis extends TreeNodeSchema>(this: TThis, child: TreeNodeFromImplicitAllowedTypes<T>): TreeFieldFromImplicitField<TThis>;
148
+ }
149
+ }
150
+
139
151
  // @public @system
140
152
  type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ? Result : Item;
141
153
 
@@ -821,7 +833,7 @@ export namespace TableSchema {
821
833
  // @public
822
834
  export type TransactionConstraint = NodeInDocumentConstraint;
823
835
 
824
- // @public @sealed @system
836
+ // @public @sealed
825
837
  export interface Tree extends TreeNodeApi {
826
838
  contains(node: TreeNode, other: TreeNode): boolean;
827
839
  readonly runTransaction: RunTransaction;
@@ -858,7 +870,7 @@ export const TreeArrayNode: {
858
870
  readonly spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>;
859
871
  };
860
872
 
861
- // @beta @sealed @system
873
+ // @beta @sealed
862
874
  export interface TreeBeta {
863
875
  clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
864
876
  create<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: InsertableTreeFieldFromImplicitField<TSchema>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
@@ -450,7 +450,7 @@ export namespace System_Unsafe {
450
450
  // @public
451
451
  export type TransactionConstraint = NodeInDocumentConstraint;
452
452
 
453
- // @public @sealed @system
453
+ // @public @sealed
454
454
  export interface Tree extends TreeNodeApi {
455
455
  contains(node: TreeNode, other: TreeNode): boolean;
456
456
  readonly runTransaction: RunTransaction;
@@ -450,7 +450,7 @@ export namespace System_Unsafe {
450
450
  // @public
451
451
  export type TransactionConstraint = NodeInDocumentConstraint;
452
452
 
453
- // @public @sealed @system
453
+ // @public @sealed
454
454
  export interface Tree extends TreeNodeApi {
455
455
  contains(node: TreeNode, other: TreeNode): boolean;
456
456
  readonly runTransaction: RunTransaction;
package/dist/alpha.d.ts CHANGED
@@ -107,6 +107,7 @@ export {
107
107
  AnnotatedAllowedTypesUnsafe,
108
108
  CodecWriteOptionsBeta,
109
109
  ConciseTree,
110
+ ExtensibleUnionNode,
110
111
  FixRecursiveArraySchema,
111
112
  FluidSerializableAsTree,
112
113
  ForestOptions,
@@ -160,7 +161,6 @@ export {
160
161
  CreateIndependentTreeAlphaOptions,
161
162
  DirtyTreeMap,
162
163
  DirtyTreeStatus,
163
- ExtensibleSchemaUnion,
164
164
  FactoryContent,
165
165
  FactoryContentObject,
166
166
  FieldPropsAlpha,
@@ -217,7 +217,6 @@ export {
217
217
  RevertibleAlpha,
218
218
  RevertibleAlphaFactory,
219
219
  RunTransactionParams,
220
- SchemaCompatibilitySnapshotsOptions,
221
220
  SchemaFactoryAlpha,
222
221
  SchemaType,
223
222
  SharedTreeFormatOptions,
@@ -235,6 +234,7 @@ export {
235
234
  SimpleTreeIndex,
236
235
  SimpleTreeSchema,
237
236
  SnapshotFileSystem,
237
+ SnapshotSchemaCompatibilityOptions,
238
238
  TransactionCallbackStatus,
239
239
  TransactionConstraintAlpha,
240
240
  TransactionResult,
@@ -265,7 +265,6 @@ export {
265
265
  asAlpha,
266
266
  asTreeViewAlpha,
267
267
  checkCompatibility,
268
- checkSchemaCompatibilitySnapshots,
269
268
  cloneWithReplacements,
270
269
  comparePersistedSchema,
271
270
  configuredSharedTreeAlpha,
@@ -295,6 +294,7 @@ export {
295
294
  replaceConciseTreeHandles,
296
295
  replaceHandles,
297
296
  replaceVerboseTreeHandles,
297
+ snapshotSchemaCompatibility,
298
298
  trackDirtyNodes
299
299
  // #endregion
300
300
  } from "./index.js";
package/dist/beta.d.ts CHANGED
@@ -107,6 +107,7 @@ export {
107
107
  AnnotatedAllowedTypesUnsafe,
108
108
  CodecWriteOptionsBeta,
109
109
  ConciseTree,
110
+ ExtensibleUnionNode,
110
111
  FixRecursiveArraySchema,
111
112
  FluidSerializableAsTree,
112
113
  ForestOptions,
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IsoBuffer } from "@fluid-internal/client-utils";
6
5
  import type { ErasedType } from "@fluidframework/core-interfaces/internal";
7
6
  import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
7
  import type { Static, TAnySchema, TSchema } from "@sinclair/typebox";
@@ -171,30 +170,6 @@ export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValida
171
170
  * Type erase the more detailed encoded type from a codec.
172
171
  */
173
172
  export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TContext = void>(codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TValidate, TValidate, TContext>;
174
- /**
175
- * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.
176
- */
177
- export interface IBinaryCodec<TDecoded, TContext = void> extends IEncoder<TDecoded, IsoBuffer, TContext>, IDecoder<TDecoded, IsoBuffer, TContext> {
178
- }
179
- /**
180
- * Contains knowledge of how to encode some in-memory type into JSON and binary formats,
181
- * as well as how to decode those representations.
182
- *
183
- * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.
184
- * For this common use case, any format for encoding that was ever actually used needs to
185
- * be supported for decoding in all future code versions.
186
- *
187
- * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in
188
- * mind evolution of encodings over time.
189
- */
190
- export interface IMultiFormatCodec<TDecoded, TJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly, TJsonValidate = TJsonEncoded, TContext = void> {
191
- json: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;
192
- binary: IBinaryCodec<TDecoded, TContext>;
193
- /** Ensures multi-format codecs cannot also be single-format codecs. */
194
- encode?: never;
195
- /** Ensures multi-format codecs cannot also be single-format codecs. */
196
- decode?: never;
197
- }
198
173
  /**
199
174
  * Represents a family of codecs that can be used to encode and decode data in different formats.
200
175
  * The family is identified by a format version, which is typically used to select the codec to use.
@@ -216,7 +191,7 @@ export interface ICodecFamily<TDecoded, TContext = void> {
216
191
  * logged properties or directly using some logger) when a format version is requested that is not supported.
217
192
  * This ensures that applications can diagnose compatibility issues.
218
193
  */
219
- resolve(formatVersion: FormatVersion): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;
194
+ resolve(formatVersion: FormatVersion): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;
220
195
  /**
221
196
  * @returns an iterable of all format versions supported by this family.
222
197
  */
@@ -266,26 +241,15 @@ export declare const DependentFormatVersion: {
266
241
  };
267
242
  /**
268
243
  * Creates a codec family from a registry of codecs.
269
- * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.
270
244
  */
271
245
  export declare function makeCodecFamily<TDecoded, TContext>(registry: Iterable<[
272
246
  formatVersion: FormatVersion,
273
- codec: IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> | IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>
247
+ codec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>
274
248
  ]>): ICodecFamily<TDecoded, TContext>;
275
- /**
276
- * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes
277
- * the json representation of the object to a buffer.
278
- */
279
- export declare function withDefaultBinaryEncoding<TDecoded, TContext, TEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly>(jsonCodec: IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>;
280
- /**
281
- * Ensures that the provided single or multi-format codec has a binary encoding.
282
- * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.
283
- */
284
- export declare function ensureBinaryEncoding<TDecoded, TContext, TEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly>(codec: IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext> | IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>;
285
249
  /**
286
250
  * Codec for objects which carry no information.
287
251
  */
288
- export declare const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, unknown>;
252
+ export declare const unitCodec: IJsonCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, unknown>;
289
253
  /**
290
254
  * Wraps a codec with JSON schema validation for its encoded type.
291
255
  * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;A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,CAAC,CAwBlC;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UAAU,CACjC,CAAC,EACD,sBAAsB,EACtB,sBAAsB,EACtB,OAAO,CAIP,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,eAAe,EACf,aAAa,SAAS,OAAO,EAC7B,cAAc,EACd,SAAS,EACT,QAAQ,EAER,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,CAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,EACvE,SAAS,CAAC,EAAE,aAAa,GAAG,eAAe,GACzC,UAAU,CAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAqBlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,kBAAkB;IAC9B;;;;;;OAMG;IAGH;;OAEG;;IAGH,4CAA4C;IAM5C;;;;;;;;OAQG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;;;;;;OAWG;;IAGH;;;;;;;;OAQG;;CAEwD,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,uBAA2D,CAAC;AAEzF,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,sBAAsB,CAMzE"}
@@ -4,8 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.jsonableCodecTree = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.ensureBinaryEncoding = exports.withDefaultBinaryEncoding = exports.makeCodecFamily = exports.DependentFormatVersion = exports.MappedDependentFormatVersion = exports.UniqueDependentFormatVersion = exports.eraseEncodedType = exports.extractJsonValidator = exports.toFormatValidator = exports.FormatValidatorNoOp = void 0;
8
- const client_utils_1 = require("@fluid-internal/client-utils");
7
+ exports.jsonableCodecTree = exports.currentVersion = exports.FluidClientVersion = exports.withSchemaValidation = exports.unitCodec = exports.makeCodecFamily = exports.DependentFormatVersion = exports.MappedDependentFormatVersion = exports.UniqueDependentFormatVersion = exports.eraseEncodedType = exports.extractJsonValidator = exports.toFormatValidator = exports.FormatValidatorNoOp = void 0;
9
8
  const internal_1 = require("@fluidframework/core-utils/internal");
10
9
  const internal_2 = require("@fluidframework/runtime-utils/internal");
11
10
  /**
@@ -67,7 +66,6 @@ exports.DependentFormatVersion = {
67
66
  };
68
67
  /**
69
68
  * Creates a codec family from a registry of codecs.
70
- * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.
71
69
  */
72
70
  function makeCodecFamily(registry) {
73
71
  const codecs = new Map();
@@ -75,12 +73,12 @@ function makeCodecFamily(registry) {
75
73
  if (codecs.has(formatVersion)) {
76
74
  (0, internal_1.fail)(0xabf /* Duplicate codecs specified. */);
77
75
  }
78
- codecs.set(formatVersion, ensureBinaryEncoding(codec));
76
+ codecs.set(formatVersion, codec);
79
77
  }
80
78
  return {
81
79
  resolve(formatVersion) {
82
80
  const codec = codecs.get(formatVersion);
83
- (0, internal_1.assert)(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);
81
+ (0, internal_1.assert)(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);
84
82
  return codec;
85
83
  },
86
84
  getSupportedFormats() {
@@ -89,55 +87,12 @@ function makeCodecFamily(registry) {
89
87
  };
90
88
  }
91
89
  exports.makeCodecFamily = makeCodecFamily;
92
- class DefaultBinaryCodec {
93
- constructor(jsonCodec) {
94
- this.jsonCodec = jsonCodec;
95
- }
96
- encode(change, context) {
97
- const jsonable = this.jsonCodec.encode(change, context);
98
- const json = JSON.stringify(jsonable);
99
- return client_utils_1.IsoBuffer.from(json);
100
- }
101
- decode(change, context) {
102
- const json = (0, client_utils_1.bufferToString)(change, "utf8");
103
- const jsonable = JSON.parse(json);
104
- return this.jsonCodec.decode(jsonable, context);
105
- }
106
- }
107
- function isJsonCodec(codec) {
108
- return typeof codec.encode === "function" && typeof codec.decode === "function";
109
- }
110
- /**
111
- * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes
112
- * the json representation of the object to a buffer.
113
- */
114
- function withDefaultBinaryEncoding(jsonCodec) {
115
- return {
116
- json: jsonCodec,
117
- binary: new DefaultBinaryCodec(jsonCodec),
118
- };
119
- }
120
- exports.withDefaultBinaryEncoding = withDefaultBinaryEncoding;
121
- /**
122
- * Ensures that the provided single or multi-format codec has a binary encoding.
123
- * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.
124
- */
125
- function ensureBinaryEncoding(codec) {
126
- return isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;
127
- }
128
- exports.ensureBinaryEncoding = ensureBinaryEncoding;
129
90
  /**
130
91
  * Codec for objects which carry no information.
131
92
  */
132
93
  exports.unitCodec = {
133
- json: {
134
- encode: () => 0,
135
- decode: () => 0,
136
- },
137
- binary: {
138
- encode: () => client_utils_1.IsoBuffer.from(""),
139
- decode: () => 0,
140
- },
94
+ encode: () => 0,
95
+ decode: () => 0,
141
96
  };
142
97
  /**
143
98
  * Wraps a codec with JSON schema validation for its encoded type.