@fluidframework/tree 2.81.1 → 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 (695) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/README.md +33 -5
  3. package/api-report/tree.alpha.api.md +75 -39
  4. package/api-report/tree.beta.api.md +164 -3
  5. package/api-report/tree.legacy.beta.api.md +164 -3
  6. package/api-report/tree.legacy.public.api.md +2 -1
  7. package/api-report/tree.public.api.md +2 -1
  8. package/dist/alpha.d.ts +10 -4
  9. package/dist/beta.d.ts +4 -0
  10. package/dist/codec/codec.d.ts +18 -45
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +12 -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 +2 -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/index.d.ts +1 -1
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/index.js +4 -2
  25. package/dist/core/index.js.map +1 -1
  26. package/dist/core/rebase/changeRebaser.d.ts +3 -2
  27. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  28. package/dist/core/rebase/changeRebaser.js.map +1 -1
  29. package/dist/core/rebase/index.d.ts +1 -1
  30. package/dist/core/rebase/index.d.ts.map +1 -1
  31. package/dist/core/rebase/index.js +4 -2
  32. package/dist/core/rebase/index.js.map +1 -1
  33. package/dist/core/rebase/types.d.ts +23 -3
  34. package/dist/core/rebase/types.d.ts.map +1 -1
  35. package/dist/core/rebase/types.js +30 -16
  36. package/dist/core/rebase/types.js.map +1 -1
  37. package/dist/core/schema-stored/formatV1.d.ts +2 -2
  38. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  39. package/dist/core/schema-stored/formatV1.js +0 -5
  40. package/dist/core/schema-stored/formatV1.js.map +1 -1
  41. package/dist/core/schema-stored/formatV2.d.ts +11 -10
  42. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  43. package/dist/core/schema-stored/formatV2.js +1 -6
  44. package/dist/core/schema-stored/formatV2.js.map +1 -1
  45. package/dist/core/schema-stored/index.d.ts.map +1 -1
  46. package/dist/core/schema-stored/index.js.map +1 -1
  47. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  48. package/dist/core/schema-stored/schema.js.map +1 -1
  49. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  50. package/dist/core/tree/anchorSet.js.map +1 -1
  51. package/dist/core/tree/delta.d.ts +9 -7
  52. package/dist/core/tree/delta.d.ts.map +1 -1
  53. package/dist/core/tree/delta.js.map +1 -1
  54. package/dist/core/tree/deltaUtil.js +1 -1
  55. package/dist/core/tree/deltaUtil.js.map +1 -1
  56. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
  58. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  59. package/dist/core/tree/visitDelta.js +2 -2
  60. package/dist/core/tree/visitDelta.js.map +1 -1
  61. package/dist/extensibleUnionNode.d.ts +97 -0
  62. package/dist/extensibleUnionNode.d.ts.map +1 -0
  63. package/dist/extensibleUnionNode.js +89 -0
  64. package/dist/extensibleUnionNode.js.map +1 -0
  65. package/dist/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  66. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  67. package/dist/feature-libraries/changeAtomIdBTree.js +9 -1
  68. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
  72. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  74. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  75. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +20 -21
  76. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  78. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  79. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  80. package/dist/feature-libraries/forest-summary/codec.d.ts +2 -1
  81. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  82. package/dist/feature-libraries/forest-summary/codec.js +7 -1
  83. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  84. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  85. package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -2
  86. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  87. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
  88. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  89. package/dist/feature-libraries/forest-summary/formatCommon.js +1 -2
  90. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  91. package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -41
  92. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  93. package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
  94. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -41
  96. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  97. package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
  98. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  99. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  100. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  101. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  102. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  103. package/dist/feature-libraries/index.d.ts +3 -3
  104. package/dist/feature-libraries/index.d.ts.map +1 -1
  105. package/dist/feature-libraries/index.js +4 -3
  106. package/dist/feature-libraries/index.js.map +1 -1
  107. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  108. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +42 -22
  110. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  112. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  113. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  114. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  115. package/dist/feature-libraries/modular-schema/index.js +2 -1
  116. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  117. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
  118. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  119. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +13 -9
  120. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  121. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  122. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  123. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +30 -7
  124. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  125. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  126. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +38 -27
  127. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  128. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  129. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  130. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  131. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  133. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  134. package/dist/feature-libraries/optional-field/optionalField.js +1 -1
  135. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  136. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  137. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  138. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  139. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  140. package/dist/feature-libraries/schema-index/codec.js +6 -4
  141. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  142. package/dist/feature-libraries/schema-index/formatV2.d.ts +4 -4
  143. package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  144. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  145. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  146. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  147. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  148. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  149. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  150. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  151. package/dist/index.d.ts +5 -5
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +5 -2
  154. package/dist/index.js.map +1 -1
  155. package/dist/legacy.d.ts +4 -0
  156. package/dist/packageVersion.d.ts +1 -1
  157. package/dist/packageVersion.js +1 -1
  158. package/dist/packageVersion.js.map +1 -1
  159. package/dist/shared-tree/independentView.d.ts +36 -13
  160. package/dist/shared-tree/independentView.d.ts.map +1 -1
  161. package/dist/shared-tree/independentView.js +1 -0
  162. package/dist/shared-tree/independentView.js.map +1 -1
  163. package/dist/shared-tree/index.d.ts +1 -1
  164. package/dist/shared-tree/index.d.ts.map +1 -1
  165. package/dist/shared-tree/index.js.map +1 -1
  166. package/dist/shared-tree/schematizingTreeView.d.ts +10 -0
  167. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  168. package/dist/shared-tree/schematizingTreeView.js +25 -9
  169. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  170. package/dist/shared-tree/sharedTree.d.ts +3 -3
  171. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  172. package/dist/shared-tree/sharedTree.js +8 -32
  173. package/dist/shared-tree/sharedTree.js.map +1 -1
  174. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  175. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  176. package/dist/shared-tree/sharedTreeChangeCodecs.js +39 -5
  177. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  178. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  179. package/dist/shared-tree/tree.d.ts +1 -1
  180. package/dist/shared-tree/tree.js +1 -1
  181. package/dist/shared-tree/tree.js.map +1 -1
  182. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  183. package/dist/shared-tree/treeAlpha.js.map +1 -1
  184. package/dist/shared-tree/treeCheckout.d.ts +20 -0
  185. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  186. package/dist/shared-tree/treeCheckout.js +41 -7
  187. package/dist/shared-tree/treeCheckout.js.map +1 -1
  188. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  189. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  190. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
  191. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  192. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  193. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  194. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  195. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  196. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  197. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  198. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  199. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  200. package/dist/shared-tree-core/editManagerSummarizer.js +1 -1
  201. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  202. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  203. package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
  204. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  205. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  206. package/dist/shared-tree-core/messageCodecs.js +2 -2
  207. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  208. package/dist/shared-tree-core/transaction.d.ts +14 -3
  209. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  210. package/dist/shared-tree-core/transaction.js +59 -16
  211. package/dist/shared-tree-core/transaction.js.map +1 -1
  212. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  213. package/dist/shared-tree-core/versionedSummarizer.js +1 -1
  214. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  215. package/dist/simple-tree/api/index.d.ts +2 -2
  216. package/dist/simple-tree/api/index.d.ts.map +1 -1
  217. package/dist/simple-tree/api/index.js +4 -3
  218. package/dist/simple-tree/api/index.js.map +1 -1
  219. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  220. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  221. package/dist/simple-tree/api/schemaCreationUtilities.js +16 -1
  222. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  223. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  224. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  225. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  226. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
  227. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  228. package/dist/simple-tree/api/transactionTypes.d.ts +10 -0
  229. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  230. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  231. package/dist/simple-tree/api/tree.d.ts +82 -7
  232. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  233. package/dist/simple-tree/api/tree.js.map +1 -1
  234. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  235. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  236. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  237. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  238. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  239. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  240. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  241. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  242. package/dist/simple-tree/core/unhydratedFlexTree.js +29 -0
  243. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  244. package/dist/simple-tree/index.d.ts +2 -2
  245. package/dist/simple-tree/index.d.ts.map +1 -1
  246. package/dist/simple-tree/index.js +5 -3
  247. package/dist/simple-tree/index.js.map +1 -1
  248. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  249. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  250. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  251. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  252. package/dist/simple-tree/node-kinds/array/arrayNode.js +47 -14
  253. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  254. package/dist/simple-tree/node-kinds/array/index.d.ts +1 -1
  255. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  256. package/dist/simple-tree/node-kinds/array/index.js +2 -1
  257. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  258. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  259. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  260. package/dist/simple-tree/node-kinds/index.js +2 -1
  261. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  262. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  263. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  264. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  265. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +33 -7
  266. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  267. package/dist/tableSchema.d.ts +71 -48
  268. package/dist/tableSchema.d.ts.map +1 -1
  269. package/dist/tableSchema.js +200 -98
  270. package/dist/tableSchema.js.map +1 -1
  271. package/dist/text/textDomainFormatted.d.ts +3 -3
  272. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  273. package/dist/text/textDomainFormatted.js +48 -32
  274. package/dist/text/textDomainFormatted.js.map +1 -1
  275. package/dist/util/bTreeUtils.d.ts +30 -4
  276. package/dist/util/bTreeUtils.d.ts.map +1 -1
  277. package/dist/util/bTreeUtils.js +35 -23
  278. package/dist/util/bTreeUtils.js.map +1 -1
  279. package/dist/util/brand.d.ts.map +1 -1
  280. package/dist/util/brand.js.map +1 -1
  281. package/dist/util/brandedMap.d.ts.map +1 -1
  282. package/dist/util/brandedMap.js.map +1 -1
  283. package/dist/util/breakable.d.ts.map +1 -1
  284. package/dist/util/breakable.js +2 -1
  285. package/dist/util/breakable.js.map +1 -1
  286. package/dist/util/index.d.ts +2 -2
  287. package/dist/util/index.d.ts.map +1 -1
  288. package/dist/util/index.js +6 -3
  289. package/dist/util/index.js.map +1 -1
  290. package/dist/util/opaque.d.ts.map +1 -1
  291. package/dist/util/opaque.js.map +1 -1
  292. package/dist/util/rangeMap.d.ts +3 -2
  293. package/dist/util/rangeMap.d.ts.map +1 -1
  294. package/dist/util/rangeMap.js +12 -7
  295. package/dist/util/rangeMap.js.map +1 -1
  296. package/dist/util/readSnapshotBlob.d.ts +1 -1
  297. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  298. package/dist/util/readSnapshotBlob.js.map +1 -1
  299. package/dist/util/typeCheck.d.ts.map +1 -1
  300. package/dist/util/typeCheck.js.map +1 -1
  301. package/dist/util/utils.d.ts +20 -16
  302. package/dist/util/utils.d.ts.map +1 -1
  303. package/dist/util/utils.js +49 -17
  304. package/dist/util/utils.js.map +1 -1
  305. package/eslint.config.mts +0 -9
  306. package/lib/alpha.d.ts +10 -4
  307. package/lib/beta.d.ts +4 -0
  308. package/lib/codec/codec.d.ts +18 -45
  309. package/lib/codec/codec.d.ts.map +1 -1
  310. package/lib/codec/codec.js +10 -47
  311. package/lib/codec/codec.js.map +1 -1
  312. package/lib/codec/index.d.ts +1 -1
  313. package/lib/codec/index.d.ts.map +1 -1
  314. package/lib/codec/index.js +1 -1
  315. package/lib/codec/index.js.map +1 -1
  316. package/lib/codec/versioned/codec.d.ts +20 -7
  317. package/lib/codec/versioned/codec.d.ts.map +1 -1
  318. package/lib/codec/versioned/codec.js +59 -33
  319. package/lib/codec/versioned/codec.js.map +1 -1
  320. package/lib/core/index.d.ts +1 -1
  321. package/lib/core/index.d.ts.map +1 -1
  322. package/lib/core/index.js +1 -1
  323. package/lib/core/index.js.map +1 -1
  324. package/lib/core/rebase/changeRebaser.d.ts +3 -2
  325. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  326. package/lib/core/rebase/changeRebaser.js.map +1 -1
  327. package/lib/core/rebase/index.d.ts +1 -1
  328. package/lib/core/rebase/index.d.ts.map +1 -1
  329. package/lib/core/rebase/index.js +1 -1
  330. package/lib/core/rebase/index.js.map +1 -1
  331. package/lib/core/rebase/types.d.ts +23 -3
  332. package/lib/core/rebase/types.d.ts.map +1 -1
  333. package/lib/core/rebase/types.js +27 -15
  334. package/lib/core/rebase/types.js.map +1 -1
  335. package/lib/core/schema-stored/formatV1.d.ts +2 -2
  336. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  337. package/lib/core/schema-stored/formatV1.js +0 -5
  338. package/lib/core/schema-stored/formatV1.js.map +1 -1
  339. package/lib/core/schema-stored/formatV2.d.ts +11 -10
  340. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  341. package/lib/core/schema-stored/formatV2.js +1 -6
  342. package/lib/core/schema-stored/formatV2.js.map +1 -1
  343. package/lib/core/schema-stored/index.d.ts.map +1 -1
  344. package/lib/core/schema-stored/index.js +2 -0
  345. package/lib/core/schema-stored/index.js.map +1 -1
  346. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  347. package/lib/core/schema-stored/schema.js.map +1 -1
  348. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  349. package/lib/core/tree/anchorSet.js.map +1 -1
  350. package/lib/core/tree/delta.d.ts +9 -7
  351. package/lib/core/tree/delta.d.ts.map +1 -1
  352. package/lib/core/tree/delta.js.map +1 -1
  353. package/lib/core/tree/deltaUtil.js +1 -1
  354. package/lib/core/tree/deltaUtil.js.map +1 -1
  355. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  356. package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
  357. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  358. package/lib/core/tree/visitDelta.js +2 -2
  359. package/lib/core/tree/visitDelta.js.map +1 -1
  360. package/lib/extensibleUnionNode.d.ts +97 -0
  361. package/lib/extensibleUnionNode.d.ts.map +1 -0
  362. package/lib/extensibleUnionNode.js +86 -0
  363. package/lib/extensibleUnionNode.js.map +1 -0
  364. package/lib/feature-libraries/changeAtomIdBTree.d.ts +4 -2
  365. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  366. package/lib/feature-libraries/changeAtomIdBTree.js +7 -0
  367. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  369. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
  371. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  372. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
  373. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  374. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -5
  375. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  376. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  377. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  378. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  379. package/lib/feature-libraries/forest-summary/codec.d.ts +2 -1
  380. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  381. package/lib/feature-libraries/forest-summary/codec.js +8 -2
  382. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  383. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  384. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -3
  385. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  386. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
  387. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  388. package/lib/feature-libraries/forest-summary/formatCommon.js +2 -3
  389. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  390. package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -41
  391. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  392. package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
  393. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  394. package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -41
  395. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  396. package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
  397. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  398. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
  399. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  400. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
  401. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  402. package/lib/feature-libraries/index.d.ts +3 -3
  403. package/lib/feature-libraries/index.d.ts.map +1 -1
  404. package/lib/feature-libraries/index.js +3 -3
  405. package/lib/feature-libraries/index.js.map +1 -1
  406. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
  407. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  408. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +41 -21
  409. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  410. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
  411. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  412. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  413. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/index.js +1 -1
  415. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
  417. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -10
  419. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
  421. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  422. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +29 -6
  423. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  424. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  425. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +41 -30
  426. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  427. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
  428. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  429. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
  430. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  431. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
  432. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  433. package/lib/feature-libraries/optional-field/optionalField.js +1 -1
  434. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  435. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  436. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  437. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  438. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  439. package/lib/feature-libraries/schema-index/codec.js +6 -4
  440. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  441. package/lib/feature-libraries/schema-index/formatV2.d.ts +4 -4
  442. package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
  443. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  444. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  445. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  446. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -16
  447. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  448. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
  449. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  450. package/lib/index.d.ts +5 -5
  451. package/lib/index.d.ts.map +1 -1
  452. package/lib/index.js +4 -3
  453. package/lib/index.js.map +1 -1
  454. package/lib/legacy.d.ts +4 -0
  455. package/lib/packageVersion.d.ts +1 -1
  456. package/lib/packageVersion.js +1 -1
  457. package/lib/packageVersion.js.map +1 -1
  458. package/lib/shared-tree/independentView.d.ts +36 -13
  459. package/lib/shared-tree/independentView.d.ts.map +1 -1
  460. package/lib/shared-tree/independentView.js +1 -0
  461. package/lib/shared-tree/independentView.js.map +1 -1
  462. package/lib/shared-tree/index.d.ts +1 -1
  463. package/lib/shared-tree/index.d.ts.map +1 -1
  464. package/lib/shared-tree/index.js.map +1 -1
  465. package/lib/shared-tree/schematizingTreeView.d.ts +10 -0
  466. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  467. package/lib/shared-tree/schematizingTreeView.js +25 -9
  468. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  469. package/lib/shared-tree/sharedTree.d.ts +3 -3
  470. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  471. package/lib/shared-tree/sharedTree.js +10 -34
  472. package/lib/shared-tree/sharedTree.js.map +1 -1
  473. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
  474. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  475. package/lib/shared-tree/sharedTreeChangeCodecs.js +40 -6
  476. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  477. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
  478. package/lib/shared-tree/tree.d.ts +1 -1
  479. package/lib/shared-tree/tree.js +1 -1
  480. package/lib/shared-tree/tree.js.map +1 -1
  481. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  482. package/lib/shared-tree/treeAlpha.js.map +1 -1
  483. package/lib/shared-tree/treeCheckout.d.ts +20 -0
  484. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  485. package/lib/shared-tree/treeCheckout.js +41 -7
  486. package/lib/shared-tree/treeCheckout.js.map +1 -1
  487. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  488. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  489. package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
  490. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  491. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  492. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  493. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
  494. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  495. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  496. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  497. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  498. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  499. package/lib/shared-tree-core/editManagerSummarizer.js +1 -1
  500. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  501. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  502. package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
  503. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  504. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  505. package/lib/shared-tree-core/messageCodecs.js +2 -2
  506. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  507. package/lib/shared-tree-core/transaction.d.ts +14 -3
  508. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  509. package/lib/shared-tree-core/transaction.js +61 -18
  510. package/lib/shared-tree-core/transaction.js.map +1 -1
  511. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  512. package/lib/shared-tree-core/versionedSummarizer.js +1 -1
  513. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  514. package/lib/simple-tree/api/index.d.ts +2 -2
  515. package/lib/simple-tree/api/index.d.ts.map +1 -1
  516. package/lib/simple-tree/api/index.js +2 -2
  517. package/lib/simple-tree/api/index.js.map +1 -1
  518. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
  519. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  520. package/lib/simple-tree/api/schemaCreationUtilities.js +14 -0
  521. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  522. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  523. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  524. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  525. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
  526. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  527. package/lib/simple-tree/api/transactionTypes.d.ts +10 -0
  528. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  529. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  530. package/lib/simple-tree/api/tree.d.ts +82 -7
  531. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  532. package/lib/simple-tree/api/tree.js.map +1 -1
  533. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  534. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  535. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  536. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  537. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  538. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  539. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
  540. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  541. package/lib/simple-tree/core/unhydratedFlexTree.js +29 -0
  542. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  543. package/lib/simple-tree/index.d.ts +2 -2
  544. package/lib/simple-tree/index.d.ts.map +1 -1
  545. package/lib/simple-tree/index.js +2 -2
  546. package/lib/simple-tree/index.js.map +1 -1
  547. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  548. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  549. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
  550. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  551. package/lib/simple-tree/node-kinds/array/arrayNode.js +46 -14
  552. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  553. package/lib/simple-tree/node-kinds/array/index.d.ts +1 -1
  554. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  555. package/lib/simple-tree/node-kinds/array/index.js +1 -1
  556. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  557. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  558. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  559. package/lib/simple-tree/node-kinds/index.js +1 -1
  560. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  561. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  562. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  563. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  564. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +34 -8
  565. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  566. package/lib/tableSchema.d.ts +71 -48
  567. package/lib/tableSchema.d.ts.map +1 -1
  568. package/lib/tableSchema.js +201 -99
  569. package/lib/tableSchema.js.map +1 -1
  570. package/lib/text/textDomainFormatted.d.ts +3 -3
  571. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  572. package/lib/text/textDomainFormatted.js +30 -14
  573. package/lib/text/textDomainFormatted.js.map +1 -1
  574. package/lib/util/bTreeUtils.d.ts +30 -4
  575. package/lib/util/bTreeUtils.d.ts.map +1 -1
  576. package/lib/util/bTreeUtils.js +33 -22
  577. package/lib/util/bTreeUtils.js.map +1 -1
  578. package/lib/util/brand.d.ts.map +1 -1
  579. package/lib/util/brand.js.map +1 -1
  580. package/lib/util/brandedMap.d.ts.map +1 -1
  581. package/lib/util/brandedMap.js.map +1 -1
  582. package/lib/util/breakable.d.ts.map +1 -1
  583. package/lib/util/breakable.js +2 -1
  584. package/lib/util/breakable.js.map +1 -1
  585. package/lib/util/index.d.ts +2 -2
  586. package/lib/util/index.d.ts.map +1 -1
  587. package/lib/util/index.js +2 -2
  588. package/lib/util/index.js.map +1 -1
  589. package/lib/util/opaque.d.ts.map +1 -1
  590. package/lib/util/opaque.js.map +1 -1
  591. package/lib/util/rangeMap.d.ts +3 -2
  592. package/lib/util/rangeMap.d.ts.map +1 -1
  593. package/lib/util/rangeMap.js +12 -7
  594. package/lib/util/rangeMap.js.map +1 -1
  595. package/lib/util/readSnapshotBlob.d.ts +1 -1
  596. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  597. package/lib/util/readSnapshotBlob.js.map +1 -1
  598. package/lib/util/typeCheck.d.ts.map +1 -1
  599. package/lib/util/typeCheck.js.map +1 -1
  600. package/lib/util/utils.d.ts +20 -16
  601. package/lib/util/utils.d.ts.map +1 -1
  602. package/lib/util/utils.js +44 -15
  603. package/lib/util/utils.js.map +1 -1
  604. package/package.json +24 -24
  605. package/src/codec/codec.ts +33 -116
  606. package/src/codec/index.ts +2 -3
  607. package/src/codec/versioned/codec.ts +127 -95
  608. package/src/core/index.ts +3 -1
  609. package/src/core/rebase/changeRebaser.ts +3 -2
  610. package/src/core/rebase/index.ts +3 -1
  611. package/src/core/rebase/types.ts +51 -13
  612. package/src/core/schema-stored/formatV1.ts +2 -4
  613. package/src/core/schema-stored/formatV2.ts +9 -7
  614. package/src/core/schema-stored/index.ts +2 -0
  615. package/src/core/schema-stored/schema.ts +4 -1
  616. package/src/core/tree/anchorSet.ts +1 -3
  617. package/src/core/tree/delta.ts +9 -7
  618. package/src/core/tree/deltaUtil.ts +1 -1
  619. package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
  620. package/src/core/tree/visitDelta.ts +2 -2
  621. package/src/extensibleUnionNode.ts +177 -0
  622. package/src/feature-libraries/changeAtomIdBTree.ts +17 -2
  623. package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
  624. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +5 -6
  625. package/src/feature-libraries/default-schema/index.ts +0 -1
  626. package/src/feature-libraries/forest-summary/codec.ts +15 -9
  627. package/src/feature-libraries/forest-summary/forestSummarizer.ts +15 -3
  628. package/src/feature-libraries/forest-summary/formatCommon.ts +7 -6
  629. package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
  630. package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
  631. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +4 -5
  632. package/src/feature-libraries/index.ts +3 -2
  633. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +57 -31
  634. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
  635. package/src/feature-libraries/modular-schema/index.ts +4 -1
  636. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +12 -12
  637. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +32 -7
  638. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +54 -33
  639. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -4
  640. package/src/feature-libraries/optional-field/optionalField.ts +1 -1
  641. package/src/feature-libraries/optional-field/requiredField.ts +2 -4
  642. package/src/feature-libraries/schema-index/codec.ts +7 -5
  643. package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
  644. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  645. package/src/feature-libraries/sequence-field/replaceRevisions.ts +17 -10
  646. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
  647. package/src/index.ts +14 -9
  648. package/src/packageVersion.ts +1 -1
  649. package/src/shared-tree/independentView.ts +42 -6
  650. package/src/shared-tree/index.ts +2 -0
  651. package/src/shared-tree/schematizingTreeView.ts +63 -18
  652. package/src/shared-tree/sharedTree.ts +19 -37
  653. package/src/shared-tree/sharedTreeChangeCodecs.ts +45 -11
  654. package/src/shared-tree/tree.ts +2 -2
  655. package/src/shared-tree/treeAlpha.ts +1 -1
  656. package/src/shared-tree/treeCheckout.ts +52 -7
  657. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
  658. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
  659. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
  660. package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
  661. package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -3
  662. package/src/shared-tree-core/messageCodecs.ts +2 -6
  663. package/src/shared-tree-core/transaction.ts +125 -23
  664. package/src/shared-tree-core/versionedSummarizer.ts +3 -2
  665. package/src/simple-tree/api/index.ts +3 -2
  666. package/src/simple-tree/api/schemaCreationUtilities.ts +35 -5
  667. package/src/simple-tree/api/simpleTreeIndex.ts +1 -1
  668. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
  669. package/src/simple-tree/api/transactionTypes.ts +10 -0
  670. package/src/simple-tree/api/tree.ts +89 -7
  671. package/src/simple-tree/api/treeBeta.ts +1 -1
  672. package/src/simple-tree/core/allowedTypes.ts +1 -1
  673. package/src/simple-tree/core/treeNodeSchema.ts +5 -8
  674. package/src/simple-tree/core/unhydratedFlexTree.ts +43 -1
  675. package/src/simple-tree/index.ts +5 -2
  676. package/src/simple-tree/leafNodeSchema.ts +3 -2
  677. package/src/simple-tree/node-kinds/array/arrayNode.ts +99 -19
  678. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  679. package/src/simple-tree/node-kinds/index.ts +2 -0
  680. package/src/simple-tree/node-kinds/object/objectNode.ts +19 -18
  681. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +51 -10
  682. package/src/tableSchema.ts +280 -140
  683. package/src/text/textDomainFormatted.ts +37 -17
  684. package/src/util/bTreeUtils.ts +55 -32
  685. package/src/util/brand.ts +4 -12
  686. package/src/util/brandedMap.ts +2 -6
  687. package/src/util/breakable.ts +3 -2
  688. package/src/util/index.ts +9 -3
  689. package/src/util/opaque.ts +2 -6
  690. package/src/util/rangeMap.ts +20 -11
  691. package/src/util/readSnapshotBlob.ts +3 -3
  692. package/src/util/typeCheck.ts +11 -9
  693. package/src/util/utils.ts +57 -28
  694. package/api-extractor-lint.json +0 -4
  695. package/biome.jsonc +0 -4
@@ -7,10 +7,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.balancedReduce = exports.copyPropertyIfDefined = exports.defineLazyCachedProperty = exports.compareStrings = exports.capitalize = exports.disposeSymbol = exports.compareNamed = exports.invertMap = exports.transformObjectMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.assertValidRangeIndices = exports.isJsonObject = exports.JsonCompatibleReadOnlySchema = exports.count = exports.find = exports.filterIterable = exports.mapIterable = exports.getOrAddEmptyToMap = exports.getOrCreate = exports.getOrAddInMap = exports.compareSets = exports.hasSingle = exports.oneFromIterable = exports.iterableHasSome = exports.hasSome = exports.getLast = exports.makeArray = exports.isReadonlyArray = exports.clone = exports.asMutable = void 0;
10
+ exports.balancedReduce = exports.copyPropertyIfDefined = exports.defineLazyCachedProperty = exports.comparePartialStrings = exports.compareStrings = exports.comparePartialNumbers = exports.compareNumbers = exports.capitalize = exports.disposeSymbol = exports.invertMap = exports.transformObjectMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.assertValidRangeIndices = exports.isJsonObject = exports.JsonCompatibleReadOnlySchema = exports.count = exports.find = exports.filterIterable = exports.mapIterable = exports.getOrAddEmptyToMap = exports.getOrCreate = exports.getOrAddInMap = exports.compareSets = exports.hasSingle = exports.oneFromIterable = exports.iterableHasSome = exports.hasSome = exports.getLast = exports.makeArray = exports.isReadonlyArray = exports.clone = exports.asMutable = void 0;
11
11
  const internal_1 = require("@fluidframework/core-utils/internal");
12
12
  const typebox_1 = require("@sinclair/typebox");
13
- const structured_clone_1 = __importDefault(require("@ungap/structured-clone"));
14
13
  /**
15
14
  * Casts a readonly object to a mutable one.
16
15
  * Better than casting to `Mutable<Foo>` because it doesn't risk casting a non-`Foo` to a `Mutable<Foo>`.
@@ -21,7 +20,8 @@ function asMutable(readonly) {
21
20
  return readonly;
22
21
  }
23
22
  exports.asMutable = asMutable;
24
- exports.clone = structured_clone_1.default;
23
+ var structured_clone_1 = require("@ungap/structured-clone");
24
+ Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return __importDefault(structured_clone_1).default; } });
25
25
  /**
26
26
  * Checks whether or not the given object is a `readonly` array.
27
27
  *
@@ -337,19 +337,6 @@ function invertMap(input) {
337
337
  return result;
338
338
  }
339
339
  exports.invertMap = invertMap;
340
- /**
341
- * Order {@link Named} objects by their name.
342
- */
343
- function compareNamed(a, b) {
344
- if (a.name < b.name) {
345
- return -1;
346
- }
347
- if (a.name > b.name) {
348
- return 1;
349
- }
350
- return 0;
351
- }
352
- exports.compareNamed = compareNamed;
353
340
  /**
354
341
  * Placeholder for `Symbol.dispose`.
355
342
  * @privateRemarks
@@ -371,12 +358,57 @@ function capitalize(s) {
371
358
  }
372
359
  exports.capitalize = capitalize;
373
360
  /**
374
- * Compares strings lexically to form a strict partial ordering.
361
+ * Compares two numbers to form a strict total ordering.
362
+ * @remarks NaN is treated as less than all other numbers and equal to itself.
363
+ * Infinity is considered equal to itself.
375
364
  */
365
+ function compareNumbers(a, b) {
366
+ if (Number.isNaN(a)) {
367
+ return Number.isNaN(b) ? 0 : -1;
368
+ }
369
+ else if (Number.isNaN(b)) {
370
+ return 1;
371
+ }
372
+ else if (a === b) {
373
+ return 0; // Infinity - Infinity = NaN (not 0), so use explicit comparison
374
+ }
375
+ return a - b;
376
+ }
377
+ exports.compareNumbers = compareNumbers;
378
+ /**
379
+ * Compares two numbers to form a strict total ordering while allowing for `undefined` values.
380
+ * @remarks `undefined` is considered less than any number and equal to itself.
381
+ * NaN is treated as less than all other numbers (but greater than undefined) and equal to itself.
382
+ */
383
+ function comparePartialNumbers(a, b) {
384
+ if (a === undefined) {
385
+ return b === undefined ? 0 : -1;
386
+ }
387
+ else if (b === undefined) {
388
+ return 1;
389
+ }
390
+ return compareNumbers(a, b);
391
+ }
392
+ exports.comparePartialNumbers = comparePartialNumbers;
393
+ /** Compares two strings lexically to form a strict total ordering. */
376
394
  function compareStrings(a, b) {
377
395
  return a > b ? 1 : a === b ? 0 : -1;
378
396
  }
379
397
  exports.compareStrings = compareStrings;
398
+ /**
399
+ * Compares two strings lexically to form a strict total ordering while allowing for `undefined` values.
400
+ * @remarks `undefined` is considered less than any string and equal to itself.
401
+ */
402
+ function comparePartialStrings(a, b) {
403
+ if (a === undefined) {
404
+ return b === undefined ? 0 : -1;
405
+ }
406
+ else if (b === undefined) {
407
+ return 1;
408
+ }
409
+ return compareStrings(a, b);
410
+ }
411
+ exports.comparePartialStrings = comparePartialStrings;
380
412
  /**
381
413
  * Defines a property on an object that is lazily initialized and cached.
382
414
  * @remarks This is useful for properties that are expensive to compute and it is not guaranteed that they will be accessed.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kEAA6D;AAC7D,+CAAyC;AACzC,+EAAsD;AA8BtD;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,QAAW;IACvC,OAAO,QAA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C5C,OAAO,KAAK,CAAC;QACd,CAAC;QACD,YAAY,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,OAAO,GAAmC,CAAC;AAC5C,CAAC;AAdD,4DAcC;AA+BD,SAAgB,qBAAqB,CAKpC,MAAqB,EACrB,QAAW,EACX,WAAc;IAEd,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAI,MAAiC,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,WAAqC,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAC1D,CAAC;IACF,CAAC;AACF,CAAC;AAfD,sDAeC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,cAAc,CAC7B,KAAmB,EACnB,UAAoC,EACpC,SAAkB;IAElB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,EAAE,CAAC;IACpB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC;AAfD,wCAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { Type } from \"@sinclair/typebox\";\nimport structuredClone from \"@ungap/structured-clone\";\n\n/**\n * Subset of Map interface.\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * Make all transitive properties in `T` readonly\n */\nexport type RecursiveReadonly<T> = {\n\treadonly [P in keyof T]: RecursiveReadonly<T[P]>;\n};\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Make all field required and omits fields whose ony valid value would be `undefined`.\n * This is analogous to `Required<T>` except it tolerates 'optional undefined'.\n */\nexport type Populated<T> = {\n\t[P in keyof T as Exclude<P, T[P] extends undefined ? P : never>]-?: T[P];\n};\n\n/**\n * Casts a readonly object to a mutable one.\n * Better than casting to `Mutable<Foo>` because it doesn't risk casting a non-`Foo` to a `Mutable<Foo>`.\n * @param readonly - The object with readonly fields.\n * @returns The same object but with a type that makes all fields mutable.\n */\nexport function asMutable<T>(readonly: T): Mutable<T> {\n\treturn readonly as Mutable<T>;\n}\n\nexport const clone = structuredClone;\n\n/**\n * Checks whether or not the given object is a `readonly` array.\n *\n * Note that this does NOT indicate if a given array should be treated as readonly.\n * This instead indicates if an object is an Array, and is typed to tolerate the readonly case.\n */\nexport function isReadonlyArray<T>(x: readonly T[] | unknown): x is readonly T[] {\n\t// `Array.isArray()` does not properly narrow `readonly` array types by itself,\n\t// so we wrap it in this type guard. This may become unnecessary if/when\n\t// https://github.com/microsoft/TypeScript/issues/17002 is resolved.\n\treturn Array.isArray(x);\n}\n\n/**\n * Creates and populates a new array.\n * @param size - The size of the array to be created.\n * @param filler - Callback for populating the array with a value for a given index\n */\nexport function makeArray<T>(size: number, filler: (index: number) => T): T[] {\n\tconst array = [];\n\tfor (let i = 0; i < size; ++i) {\n\t\tarray.push(filler(i));\n\t}\n\treturn array;\n}\n\n/**\n * Returns the last element of an array, or `undefined` if the array has no elements.\n * @param array - The array to get the last element from.\n * @remarks\n * If the type of the array has been narrowed by e.g. {@link hasSome | hasSome(array)} or {@link hasSingle | hasOne(array)} then the return type will be `T` rather than `T | undefined`.\n */\nexport function getLast<T>(array: readonly [T, ...T[]]): T;\nexport function getLast<T>(array: { [index: number]: T; length: number }): T | undefined;\nexport function getLast<T>(array: { [index: number]: T; length: number }): T | undefined {\n\treturn array[array.length - 1];\n}\n\n/**\n * Returns true if and only if the given array has at least one element.\n * @param array - The array to check.\n * @remarks\n * If `array` contains at least one element, its type will be narrowed and can benefit from improved typing from e.g. `array[0]` and {@link getLast | getLast(array)}.\n * This is especially useful when \"noUncheckedIndexedAccess\" is enabled in the TypeScript compiler options, since the return type of `array[0]` will be `T` rather than `T | undefined`.\n */\nexport function hasSome<T>(array: T[]): array is [T, ...T[]];\nexport function hasSome<T>(array: readonly T[]): array is readonly [T, ...T[]];\nexport function hasSome<T>(array: readonly T[]): array is [T, ...T[]] {\n\treturn array.length > 0;\n}\n\n/**\n * Returns true if and only if the given iterable has at least one element.\n */\nexport function iterableHasSome<T>(iterable: Iterable<T>): boolean {\n\treturn iterable[Symbol.iterator]().next().done === false;\n}\n\n/**\n * Returns the value from the given iterable if it contains exactly one item, otherwise `undefined`.\n * @remarks\n * Note that if the iterable itself may contain `undefined` values,\n * it is not possible to use this to distinguish between an iterable that contains exactly one `undefined` value and an iterable that contains zero or multiple values.\n */\nexport function oneFromIterable<T>(items: Iterable<T>): T | undefined {\n\tconst iterator = items[Symbol.iterator]();\n\tconst first = iterator.next();\n\tif (first.done === true) {\n\t\t// Empty iterable case.\n\t\treturn undefined;\n\t}\n\tconst second = iterator.next();\n\tif (second.done === true) {\n\t\t// Single item iterable case.\n\t\treturn first.value;\n\t}\n\t// Multiple item iterable case.\n\treturn undefined;\n}\n\n/**\n * Returns true if and only if the given array has exactly one element.\n * @param array - The array to check.\n * @remarks\n * If `array` contains exactly one element, its type will be narrowed and can benefit from improved typing from e.g. `array[0]` and {@link getLast | getLast(array)}.\n * This is especially useful when \"noUncheckedIndexedAccess\" is enabled in the TypeScript compiler options, since the return type of `array[0]` will be `T` rather than `T | undefined`.\n */\nexport function hasSingle<T>(array: T[]): array is [T];\nexport function hasSingle<T>(array: readonly T[]): array is readonly [T];\nexport function hasSingle<T>(array: readonly T[]): array is [T] {\n\treturn array.length === 1;\n}\n\n/**\n * Compares two sets using callbacks.\n * Early returns on first false comparison.\n *\n * @param a - One Set.\n * @param b - The other Set.\n * @param aExtra - Called for items in `a` but not `b`.\n * @param bExtra - Called for items in `b` but not `a`.\n * @param same - Called for items in `a` and `b`.\n * @returns false iff any of the call backs returned false.\n */\nexport function compareSets<T>({\n\ta,\n\tb,\n\taExtra,\n\tbExtra,\n\tsame,\n}: {\n\ta: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\tb: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\taExtra?: (t: T) => boolean;\n\tbExtra?: (t: T) => boolean;\n\tsame?: (t: T) => boolean;\n}): boolean {\n\tfor (const item of a.keys()) {\n\t\tif (b.has(item)) {\n\t\t\tif (same !== undefined && !same(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tif (aExtra === undefined) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tif (!aExtra(item)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (const item of b.keys()) {\n\t\tif (a.has(item)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (bExtra === undefined) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tif (!bExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Sets the value at `key` in map to value if not already present.\n * Returns the value at `key` after setting it.\n * This is equivalent to a get or default that adds the default to the map.\n */\nexport function getOrAddInMap<Key, Value>(\n\tmap: MapGetSet<Key, Value>,\n\tkey: Key,\n\tvalue: Value,\n): Value {\n\tconst currentValue = map.get(key);\n\tif (currentValue !== undefined) {\n\t\treturn currentValue;\n\t}\n\tmap.set(key, value);\n\treturn value;\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Utility for dictionaries whose values are lists.\n * Gets the list associated with the provided key, if it exists.\n * Otherwise, creates an entry with an empty list, and returns that list.\n */\nexport function getOrAddEmptyToMap<K, V>(map: MapGetSet<K, V[]>, key: K): V[] {\n\tlet collection = map.get(key);\n\tif (collection === undefined) {\n\t\tcollection = [];\n\t\tmap.set(key, collection);\n\t}\n\treturn collection;\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Filter one iterable into another\n * @param iterable - the iterable to filter\n * @param filter - the predicate function to run on each element of the iterable\n * @returns a new iterable including only the elements that passed the filter predicate\n */\nexport function* filterIterable<T>(\n\titerable: Iterable<T>,\n\tfilter: (t: T) => boolean,\n): IterableIterator<T> {\n\tfor (const t of iterable) {\n\t\tif (filter(t)) {\n\t\t\tyield t;\n\t\t}\n\t}\n}\n\n/**\n * Finds the first element in the given iterable that satisfies a predicate.\n * @param iterable - The iterable to search for an eligible element\n * @param predicate - The predicate to run against each element\n * @returns The first element in the iterable that satisfies the predicate, or undefined if the iterable contains no such element\n */\nexport function find<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): T | undefined {\n\tfor (const t of iterable) {\n\t\tif (predicate(t)) {\n\t\t\treturn t;\n\t\t}\n\t}\n}\n\n/**\n * Counts the number of elements in the given iterable.\n * @param iterable - the iterable to enumerate\n * @returns the number of elements that were iterated after exhausting the iterable\n */\nexport function count(iterable: Iterable<unknown>): number {\n\tlet n = 0;\n\tfor (const _ of iterable) {\n\t\tn += 1;\n\t}\n\treturn n;\n}\n\n/**\n * Use for Json compatible data.\n *\n * @typeparam TExtra - Type permitted in addition to the normal JSON types.\n * Commonly used for to allow {@link @fluidframework/core-interfaces#IFluidHandle} within the otherwise JSON compatible content.\n *\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n *\n * @privateRemarks\n * TODO (before promoting to public): consider moving this to a more general location - this isn't SharedTree-specific.\n *\n * @beta\n */\nexport type JsonCompatible<TExtra = never> =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| JsonCompatible<TExtra>[]\n\t| JsonCompatibleObject<TExtra>\n\t| TExtra;\n\n/**\n * Use for Json object compatible data.\n *\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n *\n * @privateRemarks\n * TODO (before promoting to public): consider moving this to a more general location - this isn't SharedTree-specific.\n *\n * @beta\n */\nexport type JsonCompatibleObject<TExtra = never> = { [P in string]?: JsonCompatible<TExtra> };\n\n/**\n * Use for readonly view of Json compatible data.\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\n */\nexport type JsonCompatibleReadOnly =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| readonly JsonCompatibleReadOnly[]\n\t| JsonCompatibleReadOnlyObject;\n\n/**\n * Use for readonly view of Json compatible data.\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\n */\nexport type JsonCompatibleReadOnlyObject = { readonly [P in string]?: JsonCompatibleReadOnly };\n\n/**\n * @remarks TODO: Audit usage of this type in schemas, evaluating whether it is necessary and performance\n * of alternatives.\n *\n * True \"arbitrary serializable data\" is probably fine, but some persisted types declarations might be better\n * expressed using composition of schemas for runtime validation, even if we don't think making the types\n * generic is worth the maintenance cost.\n */\nexport const JsonCompatibleReadOnlySchema = Type.Any();\n\n/**\n * Returns if a particular json compatible value is an object.\n * Does not include `null` or arrays.\n */\nexport function isJsonObject(\n\tvalue: JsonCompatibleReadOnly,\n): value is { readonly [P in string]?: JsonCompatibleReadOnly } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Verifies that the supplied indices are valid within the supplied array.\n * @param startIndex - The starting index in the range. Must be in [0, length).\n * @param endIndex - The ending index in the range. Must be within (start, length].\n * @param array - The array the indices refer to\n */\nexport function assertValidRangeIndices(\n\tstartIndex: number,\n\tendIndex: number,\n\tarray: { readonly length: number },\n): void {\n\tassert(endIndex >= startIndex, 0x79c /* Range indices are malformed. */);\n\tassertValidIndex(startIndex, array, false);\n\tassertValidIndex(endIndex, array, true);\n}\n\nexport function assertValidIndex(\n\tindex: number,\n\tarray: { readonly length: number },\n\tallowOnePastEnd: boolean = false,\n): void {\n\tassertNonNegativeSafeInteger(index);\n\tif (allowOnePastEnd) {\n\t\tassert(index <= array.length, 0x378 /* index must be less than or equal to length */);\n\t} else {\n\t\tassert(index < array.length, 0x379 /* index must be less than length */);\n\t}\n}\n\nexport function assertValidRange(\n\t{ start, end }: { start: number; end: number },\n\tarray: { readonly length: number },\n): void {\n\tassertNonNegativeSafeInteger(start);\n\tassertNonNegativeSafeInteger(end);\n\tassert(end <= array.length, 0x79d /* Range end must be less than or equal to length */);\n\tassert(start <= end, 0x79e /* Range start must be less than or equal to range start */);\n}\n\nexport function assertNonNegativeSafeInteger(index: number): void {\n\tassert(Number.isSafeInteger(index), 0x376 /* index must be an integer */);\n\tassert(index >= 0, 0x377 /* index must be non-negative */);\n}\n\n/**\n * Convert an object into a Map.\n *\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * This function helps these few cases get into using an actual map in as safe of was as is practical.\n */\nexport function objectToMap<MapKey extends string | number | symbol, MapValue>(\n\tobjectMap: Record<MapKey, MapValue>,\n): Map<MapKey, MapValue> {\n\tconst map = new Map<MapKey, MapValue>();\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tmap.set(key as MapKey, element);\n\t}\n\treturn map;\n}\n\n/**\n * Convert an object used as a map into a new object used like a map.\n *\n * @remarks\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * {@link objectToMap} helps these few cases get into using an actual map in as safe of a way as is practical.\n */\nexport function transformObjectMap<\n\tMapKey extends string | number | symbol,\n\tMapValue,\n\tNewMapValue,\n>(\n\tobjectMap: Record<MapKey, MapValue>,\n\ttransformer: (value: MapValue, key: MapKey) => NewMapValue,\n): Record<MapKey, MapValue> {\n\tconst output: Record<MapKey, MapValue> = Object.create(null);\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tObject.defineProperty(output, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: transformer(element, key as MapKey),\n\t\t});\n\t}\n\treturn output;\n}\n\n/**\n * Make an inverted copy of a map.\n *\n * @returns a map which can look up the keys from the values of the original map.\n */\nexport function invertMap<Key, Value>(input: Map<Key, Value>): Map<Value, Key> {\n\tconst result = new Map<Value, Key>(mapIterable(input, ([key, value]) => [value, key]));\n\tassert(\n\t\tresult.size === input.size,\n\t\t0x88a /* all values in a map must be unique to invert it */,\n\t);\n\treturn result;\n}\n\n/**\n * Type with a name describing what it is.\n * Typically used with values (like schema) that can be stored in a map, but in some representations have their name/key as a field.\n */\nexport interface Named<TName> {\n\treadonly name: TName;\n}\n\n/**\n * Order {@link Named} objects by their name.\n */\nexport function compareNamed(a: Named<string>, b: Named<string>): -1 | 0 | 1 {\n\tif (a.name < b.name) {\n\t\treturn -1;\n\t}\n\tif (a.name > b.name) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/**\n * Placeholder for `Symbol.dispose`.\n * @privateRemarks\n * TODO: replace this with `Symbol.dispose` when it is available or make it a valid polyfill.\n */\nexport const disposeSymbol: unique symbol = Symbol(\"Symbol.dispose placeholder\");\n\n/**\n * An object with an explicit lifetime that can be ended.\n * @privateRemarks\n * Simpler alternative to core-utils/IDisposable for internal use in this package.\n * This avoids adding a named \"dispose\" method, and will eventually be replaced with\n * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management| TypeScript's Disposable}.\n *\n * Once this is replaced with TypeScript's Disposable, core-utils/IDisposable can extend it, bringing the APIs into a reasonable alignment.\n */\nexport interface IDisposable {\n\t/**\n\t * Call to end the lifetime of this object.\n\t *\n\t * It is invalid to use this object after this,\n\t * except for operations which explicitly document they are valid after disposal.\n\t *\n\t * @remarks\n\t * May cleanup resources retained by this object.\n\t * Often includes un-registering from events and thus preventing other objects from retaining a reference to this indefinably.\n\t *\n\t * Usually the only operations allowed after disposal are querying if an object is already disposed,\n\t * but this can vary between implementations.\n\t */\n\t[disposeSymbol](): void;\n}\n\n/**\n * Capitalize a string.\n */\nexport function capitalize<S extends string>(s: S): Capitalize<S> {\n\t// To avoid splitting characters which are made of multiple UTF-16 code units,\n\t// use iteration instead of indexing to separate the first character.\n\tconst iterated = s[Symbol.iterator]().next();\n\tif (iterated.done === true) {\n\t\t// Empty string case.\n\t\treturn \"\" as Capitalize<S>;\n\t}\n\n\treturn (iterated.value.toUpperCase() + s.slice(iterated.value.length)) as Capitalize<S>;\n}\n\n/**\n * Compares strings lexically to form a strict partial ordering.\n */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Defines a property on an object that is lazily initialized and cached.\n * @remarks This is useful for properties that are expensive to compute and it is not guaranteed that they will be accessed.\n * This function initially defines a getter on the object, but after first read it replaces the getter with a value property.\n * @param obj - The object on which to define the property.\n * @param key - The key of the property to define.\n * @param get - The function (called either once or not at all) to compute the value of the property.\n * @returns `obj`, typed such that it has the new property.\n * This allows for the new property to be read off of `obj` in a type-safe manner after calling this function.\n */\nexport function defineLazyCachedProperty<\n\tT extends object,\n\tK extends string | number | symbol,\n\tV,\n>(obj: T, key: K, get: () => V): typeof obj & { [P in K]: V } {\n\tReflect.defineProperty(obj, key, {\n\t\tget() {\n\t\t\tconst value = get();\n\t\t\tReflect.defineProperty(obj, key, { value });\n\t\t\treturn value;\n\t\t},\n\t\tconfigurable: true,\n\t});\n\treturn obj as typeof obj & { [P in K]: V };\n}\n\n/**\n * Copies a given property from one object to another if and only if the property is defined.\n * @param source - The object to copy the property from.\n * If `source` is undefined or does not have the property defined, then this function will do nothing.\n * @param property - The property to copy.\n * @param destination - The object to copy the property to.\n * @remarks This function is useful for copying properties from one object to another while minimizing the presence of `undefined` values.\n * If `property` is not present on `source` - or if `property` is present, but has a value of `undefined` - then this function will not modify `destination`.\n * This is different from doing `destination.foo = source.foo`, which would define a `\"foo\"` property on `destination` with the value `undefined`.\n *\n * If the type of `source` is known to have `property`, then this function asserts that the type of `destination` has `property` as well after the call.\n *\n * This function first reads the property value (if present) from `source` and then sets it on `destination`, as opposed to e.g. directly copying the property descriptor.\n * @privateRemarks The first overload of this function allows auto-complete to suggest property names from `source`, but by having the second overload we still allow for arbitrary property names.\n */\nexport function copyPropertyIfDefined<S extends object, K extends keyof S, D extends object>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;\nexport function copyPropertyIfDefined<\n\tS extends object,\n\tK extends string | number | symbol,\n\tD extends object,\n>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;\nexport function copyPropertyIfDefined<\n\tS extends object,\n\tK extends string | number | symbol,\n\tD extends object,\n>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D {\n\tif (source !== undefined) {\n\t\tconst value = (source as { [P in K]?: unknown })[property];\n\t\tif (value !== undefined) {\n\t\t\t(destination as { [P in K]: unknown })[property] = value;\n\t\t}\n\t}\n}\n\n/**\n * Reduces an array of values into a single value.\n * This is similar to `Array.prototype.reduce`,\n * except that it recursively reduces the left and right halves of the input before reducing their respective reductions.\n *\n * When compared with an approach like reducing all the values left-to-right,\n * this balanced approach is beneficial when the cost of invoking `callbackFn` is proportional to the number reduced values that its parameters collectively represent.\n * For example, if `T` is an array, and `callbackFn` concatenates its inputs,\n * then `balancedReduce` will have O(N*log(N)) time complexity instead of `Array.prototype.reduce`'s O(N²).\n * However, if `callbackFn` is O(1) then both `balancedReduce` and `Array.prototype.reduce` will have O(N) complexity.\n *\n * @param array - The array to reduce.\n * @param callbackFn - The function to execute for each pairwise reduction.\n * @param emptyCase - A factory function that provides the value to return if the input array is empty.\n */\nexport function balancedReduce<T>(\n\tarray: readonly T[],\n\tcallbackFn: (left: T, right: T) => T,\n\temptyCase: () => T,\n): T {\n\tif (hasSingle(array)) {\n\t\treturn array[0];\n\t}\n\tif (!hasSome(array)) {\n\t\treturn emptyCase();\n\t}\n\tconst mid = Math.floor(array.length / 2);\n\tconst left = balancedReduce(array.slice(0, mid), callbackFn, emptyCase);\n\tconst right = balancedReduce(array.slice(mid), callbackFn, emptyCase);\n\treturn callbackFn(left, right);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kEAA6D;AAC7D,+CAAuD;AA8BvD;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,QAAW;IACvC,OAAO,QAAsB,CAAC;AAC/B,CAAC;AAFD,8BAEC;AAED,4DAA2D;AAAlD,0HAAA,OAAO,OAAS;AAEzB;;;;;GAKG;AACH,SAAgB,eAAe,CAAI,CAAyB;IAC3D,+EAA+E;IAC/E,wEAAwE;IACxE,oEAAoE;IACpE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AALD,0CAKC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAI,IAAY,EAAE,MAA4B;IACtE,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAND,8BAMC;AAUD,SAAgB,OAAO,CAAI,KAA6C;IACvE,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAChC,CAAC;AAFD,0BAEC;AAWD,SAAgB,OAAO,CAAI,KAAmB;IAC7C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC;AAFD,0BAEC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAI,QAAqB;IACvD,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC;AAC1D,CAAC;AAFD,0CAEC;AAED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AClB,CAAC,CAAC;IACH,OAAO,GAAmC,CAAC;AAC5C,CAAC;AAdD,4DAcC;AA+BD,SAAgB,qBAAqB,CAKpC,MAAqB,EACrB,QAAW,EACX,WAAc;IAEd,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAI,MAAiC,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,WAAqC,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAC1D,CAAC;IACF,CAAC;AACF,CAAC;AAfD,sDAeC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,cAAc,CAC7B,KAAmB,EACnB,UAAoC,EACpC,SAAkB;IAElB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,EAAE,CAAC;IACpB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC;AAfD,wCAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { Type, type TUnsafe } from \"@sinclair/typebox\";\n\n/**\n * Subset of Map interface.\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * Make all transitive properties in `T` readonly\n */\nexport type RecursiveReadonly<T> = {\n\treadonly [P in keyof T]: RecursiveReadonly<T[P]>;\n};\n\n/**\n * Remove `readonly` from all fields.\n */\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Make all field required and omits fields whose ony valid value would be `undefined`.\n * This is analogous to `Required<T>` except it tolerates 'optional undefined'.\n */\nexport type Populated<T> = {\n\t[P in keyof T as Exclude<P, T[P] extends undefined ? P : never>]-?: T[P];\n};\n\n/**\n * Casts a readonly object to a mutable one.\n * Better than casting to `Mutable<Foo>` because it doesn't risk casting a non-`Foo` to a `Mutable<Foo>`.\n * @param readonly - The object with readonly fields.\n * @returns The same object but with a type that makes all fields mutable.\n */\nexport function asMutable<T>(readonly: T): Mutable<T> {\n\treturn readonly as Mutable<T>;\n}\n\nexport { default as clone } from \"@ungap/structured-clone\";\n\n/**\n * Checks whether or not the given object is a `readonly` array.\n *\n * Note that this does NOT indicate if a given array should be treated as readonly.\n * This instead indicates if an object is an Array, and is typed to tolerate the readonly case.\n */\nexport function isReadonlyArray<T>(x: readonly T[] | unknown): x is readonly T[] {\n\t// `Array.isArray()` does not properly narrow `readonly` array types by itself,\n\t// so we wrap it in this type guard. This may become unnecessary if/when\n\t// https://github.com/microsoft/TypeScript/issues/17002 is resolved.\n\treturn Array.isArray(x);\n}\n\n/**\n * Creates and populates a new array.\n * @param size - The size of the array to be created.\n * @param filler - Callback for populating the array with a value for a given index\n */\nexport function makeArray<T>(size: number, filler: (index: number) => T): T[] {\n\tconst array = [];\n\tfor (let i = 0; i < size; ++i) {\n\t\tarray.push(filler(i));\n\t}\n\treturn array;\n}\n\n/**\n * Returns the last element of an array, or `undefined` if the array has no elements.\n * @param array - The array to get the last element from.\n * @remarks\n * If the type of the array has been narrowed by e.g. {@link hasSome | hasSome(array)} or {@link hasSingle | hasOne(array)} then the return type will be `T` rather than `T | undefined`.\n */\nexport function getLast<T>(array: readonly [T, ...T[]]): T;\nexport function getLast<T>(array: { [index: number]: T; length: number }): T | undefined;\nexport function getLast<T>(array: { [index: number]: T; length: number }): T | undefined {\n\treturn array[array.length - 1];\n}\n\n/**\n * Returns true if and only if the given array has at least one element.\n * @param array - The array to check.\n * @remarks\n * If `array` contains at least one element, its type will be narrowed and can benefit from improved typing from e.g. `array[0]` and {@link getLast | getLast(array)}.\n * This is especially useful when \"noUncheckedIndexedAccess\" is enabled in the TypeScript compiler options, since the return type of `array[0]` will be `T` rather than `T | undefined`.\n */\nexport function hasSome<T>(array: T[]): array is [T, ...T[]];\nexport function hasSome<T>(array: readonly T[]): array is readonly [T, ...T[]];\nexport function hasSome<T>(array: readonly T[]): array is [T, ...T[]] {\n\treturn array.length > 0;\n}\n\n/**\n * Returns true if and only if the given iterable has at least one element.\n */\nexport function iterableHasSome<T>(iterable: Iterable<T>): boolean {\n\treturn iterable[Symbol.iterator]().next().done === false;\n}\n\n/**\n * Returns the value from the given iterable if it contains exactly one item, otherwise `undefined`.\n * @remarks\n * Note that if the iterable itself may contain `undefined` values,\n * it is not possible to use this to distinguish between an iterable that contains exactly one `undefined` value and an iterable that contains zero or multiple values.\n */\nexport function oneFromIterable<T>(items: Iterable<T>): T | undefined {\n\tconst iterator = items[Symbol.iterator]();\n\tconst first = iterator.next();\n\tif (first.done === true) {\n\t\t// Empty iterable case.\n\t\treturn undefined;\n\t}\n\tconst second = iterator.next();\n\tif (second.done === true) {\n\t\t// Single item iterable case.\n\t\treturn first.value;\n\t}\n\t// Multiple item iterable case.\n\treturn undefined;\n}\n\n/**\n * Returns true if and only if the given array has exactly one element.\n * @param array - The array to check.\n * @remarks\n * If `array` contains exactly one element, its type will be narrowed and can benefit from improved typing from e.g. `array[0]` and {@link getLast | getLast(array)}.\n * This is especially useful when \"noUncheckedIndexedAccess\" is enabled in the TypeScript compiler options, since the return type of `array[0]` will be `T` rather than `T | undefined`.\n */\nexport function hasSingle<T>(array: T[]): array is [T];\nexport function hasSingle<T>(array: readonly T[]): array is readonly [T];\nexport function hasSingle<T>(array: readonly T[]): array is [T] {\n\treturn array.length === 1;\n}\n\n/**\n * Compares two sets using callbacks.\n * Early returns on first false comparison.\n *\n * @param a - One Set.\n * @param b - The other Set.\n * @param aExtra - Called for items in `a` but not `b`.\n * @param bExtra - Called for items in `b` but not `a`.\n * @param same - Called for items in `a` and `b`.\n * @returns false iff any of the call backs returned false.\n */\nexport function compareSets<T>({\n\ta,\n\tb,\n\taExtra,\n\tbExtra,\n\tsame,\n}: {\n\ta: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\tb: ReadonlySet<T> | ReadonlyMap<T, unknown>;\n\taExtra?: (t: T) => boolean;\n\tbExtra?: (t: T) => boolean;\n\tsame?: (t: T) => boolean;\n}): boolean {\n\tfor (const item of a.keys()) {\n\t\tif (b.has(item)) {\n\t\t\tif (same !== undefined && !same(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tif (aExtra === undefined) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tif (!aExtra(item)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (const item of b.keys()) {\n\t\tif (a.has(item)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (bExtra === undefined) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tif (!bExtra(item)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Sets the value at `key` in map to value if not already present.\n * Returns the value at `key` after setting it.\n * This is equivalent to a get or default that adds the default to the map.\n */\nexport function getOrAddInMap<Key, Value>(\n\tmap: MapGetSet<Key, Value>,\n\tkey: Key,\n\tvalue: Value,\n): Value {\n\tconst currentValue = map.get(key);\n\tif (currentValue !== undefined) {\n\t\treturn currentValue;\n\t}\n\tmap.set(key, value);\n\treturn value;\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * Utility for dictionaries whose values are lists.\n * Gets the list associated with the provided key, if it exists.\n * Otherwise, creates an entry with an empty list, and returns that list.\n */\nexport function getOrAddEmptyToMap<K, V>(map: MapGetSet<K, V[]>, key: K): V[] {\n\tlet collection = map.get(key);\n\tif (collection === undefined) {\n\t\tcollection = [];\n\t\tmap.set(key, collection);\n\t}\n\treturn collection;\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Filter one iterable into another\n * @param iterable - the iterable to filter\n * @param filter - the predicate function to run on each element of the iterable\n * @returns a new iterable including only the elements that passed the filter predicate\n */\nexport function* filterIterable<T>(\n\titerable: Iterable<T>,\n\tfilter: (t: T) => boolean,\n): IterableIterator<T> {\n\tfor (const t of iterable) {\n\t\tif (filter(t)) {\n\t\t\tyield t;\n\t\t}\n\t}\n}\n\n/**\n * Finds the first element in the given iterable that satisfies a predicate.\n * @param iterable - The iterable to search for an eligible element\n * @param predicate - The predicate to run against each element\n * @returns The first element in the iterable that satisfies the predicate, or undefined if the iterable contains no such element\n */\nexport function find<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): T | undefined {\n\tfor (const t of iterable) {\n\t\tif (predicate(t)) {\n\t\t\treturn t;\n\t\t}\n\t}\n}\n\n/**\n * Counts the number of elements in the given iterable.\n * @param iterable - the iterable to enumerate\n * @returns the number of elements that were iterated after exhausting the iterable\n */\nexport function count(iterable: Iterable<unknown>): number {\n\tlet n = 0;\n\tfor (const _ of iterable) {\n\t\tn += 1;\n\t}\n\treturn n;\n}\n\n/**\n * Use for Json compatible data.\n *\n * @typeparam TExtra - Type permitted in addition to the normal JSON types.\n * Commonly used for to allow {@link @fluidframework/core-interfaces#IFluidHandle} within the otherwise JSON compatible content.\n *\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n *\n * @privateRemarks\n * TODO (before promoting to public): consider moving this to a more general location - this isn't SharedTree-specific.\n *\n * @beta\n */\nexport type JsonCompatible<TExtra = never> =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| JsonCompatible<TExtra>[]\n\t| JsonCompatibleObject<TExtra>\n\t| TExtra;\n\n/**\n * Use for Json object compatible data.\n *\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n *\n * @privateRemarks\n * TODO (before promoting to public): consider moving this to a more general location - this isn't SharedTree-specific.\n *\n * @beta\n */\nexport type JsonCompatibleObject<TExtra = never> = { [P in string]?: JsonCompatible<TExtra> };\n\n/**\n * Use for readonly view of Json compatible data.\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\n */\nexport type JsonCompatibleReadOnly =\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| readonly JsonCompatibleReadOnly[]\n\t| JsonCompatibleReadOnlyObject;\n\n/**\n * Use for readonly view of Json compatible data.\n * @remarks\n * This does not robustly forbid non json comparable data via type checking,\n * but instead mostly restricts access to it.\n * @alpha\n */\nexport type JsonCompatibleReadOnlyObject = { readonly [P in string]?: JsonCompatibleReadOnly };\n\n/**\n * @remarks TODO: Audit usage of this type in schemas, evaluating whether it is necessary and performance\n * of alternatives.\n *\n * True \"arbitrary serializable data\" is probably fine, but some persisted types declarations might be better\n * expressed using composition of schemas for runtime validation, even if we don't think making the types\n * generic is worth the maintenance cost.\n */\nexport const JsonCompatibleReadOnlySchema =\n\tType.Any() as unknown as TUnsafe<JsonCompatibleReadOnly>;\n\n/**\n * Returns if a particular json compatible value is an object.\n * Does not include `null` or arrays.\n */\nexport function isJsonObject(\n\tvalue: JsonCompatibleReadOnly,\n): value is { readonly [P in string]?: JsonCompatibleReadOnly } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Verifies that the supplied indices are valid within the supplied array.\n * @param startIndex - The starting index in the range. Must be in [0, length).\n * @param endIndex - The ending index in the range. Must be within (start, length].\n * @param array - The array the indices refer to\n */\nexport function assertValidRangeIndices(\n\tstartIndex: number,\n\tendIndex: number,\n\tarray: { readonly length: number },\n): void {\n\tassert(endIndex >= startIndex, 0x79c /* Range indices are malformed. */);\n\tassertValidIndex(startIndex, array, false);\n\tassertValidIndex(endIndex, array, true);\n}\n\nexport function assertValidIndex(\n\tindex: number,\n\tarray: { readonly length: number },\n\tallowOnePastEnd: boolean = false,\n): void {\n\tassertNonNegativeSafeInteger(index);\n\tif (allowOnePastEnd) {\n\t\tassert(index <= array.length, 0x378 /* index must be less than or equal to length */);\n\t} else {\n\t\tassert(index < array.length, 0x379 /* index must be less than length */);\n\t}\n}\n\nexport function assertValidRange(\n\t{ start, end }: { start: number; end: number },\n\tarray: { readonly length: number },\n): void {\n\tassertNonNegativeSafeInteger(start);\n\tassertNonNegativeSafeInteger(end);\n\tassert(end <= array.length, 0x79d /* Range end must be less than or equal to length */);\n\tassert(start <= end, 0x79e /* Range start must be less than or equal to range start */);\n}\n\nexport function assertNonNegativeSafeInteger(index: number): void {\n\tassert(Number.isSafeInteger(index), 0x376 /* index must be an integer */);\n\tassert(index >= 0, 0x377 /* index must be non-negative */);\n}\n\n/**\n * Convert an object into a Map.\n *\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * This function helps these few cases get into using an actual map in as safe of was as is practical.\n */\nexport function objectToMap<MapKey extends string | number | symbol, MapValue>(\n\tobjectMap: Record<MapKey, MapValue>,\n): Map<MapKey, MapValue> {\n\tconst map = new Map<MapKey, MapValue>();\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tmap.set(key as MapKey, element);\n\t}\n\treturn map;\n}\n\n/**\n * Convert an object used as a map into a new object used like a map.\n *\n * @remarks\n * This function must only be used with objects specifically intended to encode map like information.\n * The only time such objects should be used is for encoding maps as object literals to allow for developer ergonomics or JSON compatibility.\n * Even those two use-cases need to be carefully considered as using objects as maps can have a lot of issues\n * (including but not limited to unintended access to __proto__ and other non-owned keys).\n * {@link objectToMap} helps these few cases get into using an actual map in as safe of a way as is practical.\n */\nexport function transformObjectMap<\n\tMapKey extends string | number | symbol,\n\tMapValue,\n\tNewMapValue,\n>(\n\tobjectMap: Record<MapKey, MapValue>,\n\ttransformer: (value: MapValue, key: MapKey) => NewMapValue,\n): Record<MapKey, NewMapValue> {\n\tconst output: Record<MapKey, NewMapValue> = Object.create(null) as Record<\n\t\tMapKey,\n\t\tNewMapValue\n\t>;\n\t// This function must only be used with objects specifically intended to encode map like information.\n\tfor (const key of Object.keys(objectMap)) {\n\t\tconst element = objectMap[key as MapKey];\n\t\tObject.defineProperty(output, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: transformer(element, key as MapKey),\n\t\t});\n\t}\n\treturn output;\n}\n\n/**\n * Make an inverted copy of a map.\n *\n * @returns a map which can look up the keys from the values of the original map.\n */\nexport function invertMap<Key, Value>(input: Map<Key, Value>): Map<Value, Key> {\n\tconst result = new Map<Value, Key>(mapIterable(input, ([key, value]) => [value, key]));\n\tassert(\n\t\tresult.size === input.size,\n\t\t0x88a /* all values in a map must be unique to invert it */,\n\t);\n\treturn result;\n}\n\n/**\n * Placeholder for `Symbol.dispose`.\n * @privateRemarks\n * TODO: replace this with `Symbol.dispose` when it is available or make it a valid polyfill.\n */\nexport const disposeSymbol: unique symbol = Symbol(\"Symbol.dispose placeholder\");\n\n/**\n * An object with an explicit lifetime that can be ended.\n * @privateRemarks\n * Simpler alternative to core-utils/IDisposable for internal use in this package.\n * This avoids adding a named \"dispose\" method, and will eventually be replaced with\n * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management| TypeScript's Disposable}.\n *\n * Once this is replaced with TypeScript's Disposable, core-utils/IDisposable can extend it, bringing the APIs into a reasonable alignment.\n */\nexport interface IDisposable {\n\t/**\n\t * Call to end the lifetime of this object.\n\t *\n\t * It is invalid to use this object after this,\n\t * except for operations which explicitly document they are valid after disposal.\n\t *\n\t * @remarks\n\t * May cleanup resources retained by this object.\n\t * Often includes un-registering from events and thus preventing other objects from retaining a reference to this indefinably.\n\t *\n\t * Usually the only operations allowed after disposal are querying if an object is already disposed,\n\t * but this can vary between implementations.\n\t */\n\t[disposeSymbol](): void;\n}\n\n/**\n * Capitalize a string.\n */\nexport function capitalize<S extends string>(s: S): Capitalize<S> {\n\t// To avoid splitting characters which are made of multiple UTF-16 code units,\n\t// use iteration instead of indexing to separate the first character.\n\tconst iterated = s[Symbol.iterator]().next();\n\tif (iterated.done === true) {\n\t\t// Empty string case.\n\t\treturn \"\" as Capitalize<S>;\n\t}\n\n\treturn (iterated.value.toUpperCase() + s.slice(iterated.value.length)) as Capitalize<S>;\n}\n\n/**\n * Compares two numbers to form a strict total ordering.\n * @remarks NaN is treated as less than all other numbers and equal to itself.\n * Infinity is considered equal to itself.\n */\nexport function compareNumbers<T extends number>(a: T, b: T): number {\n\tif (Number.isNaN(a)) {\n\t\treturn Number.isNaN(b) ? 0 : -1;\n\t} else if (Number.isNaN(b)) {\n\t\treturn 1;\n\t} else if (a === b) {\n\t\treturn 0; // Infinity - Infinity = NaN (not 0), so use explicit comparison\n\t}\n\treturn a - b;\n}\n\n/**\n * Compares two numbers to form a strict total ordering while allowing for `undefined` values.\n * @remarks `undefined` is considered less than any number and equal to itself.\n * NaN is treated as less than all other numbers (but greater than undefined) and equal to itself.\n */\nexport function comparePartialNumbers<T extends number>(\n\ta: T | undefined,\n\tb: T | undefined,\n): number {\n\tif (a === undefined) {\n\t\treturn b === undefined ? 0 : -1;\n\t} else if (b === undefined) {\n\t\treturn 1;\n\t}\n\treturn compareNumbers(a, b);\n}\n\n/** Compares two strings lexically to form a strict total ordering. */\nexport function compareStrings<T extends string>(a: T, b: T): number {\n\treturn a > b ? 1 : a === b ? 0 : -1;\n}\n\n/**\n * Compares two strings lexically to form a strict total ordering while allowing for `undefined` values.\n * @remarks `undefined` is considered less than any string and equal to itself.\n */\nexport function comparePartialStrings<T extends string>(\n\ta: T | undefined,\n\tb: T | undefined,\n): number {\n\tif (a === undefined) {\n\t\treturn b === undefined ? 0 : -1;\n\t} else if (b === undefined) {\n\t\treturn 1;\n\t}\n\treturn compareStrings(a, b);\n}\n\n/**\n * Defines a property on an object that is lazily initialized and cached.\n * @remarks This is useful for properties that are expensive to compute and it is not guaranteed that they will be accessed.\n * This function initially defines a getter on the object, but after first read it replaces the getter with a value property.\n * @param obj - The object on which to define the property.\n * @param key - The key of the property to define.\n * @param get - The function (called either once or not at all) to compute the value of the property.\n * @returns `obj`, typed such that it has the new property.\n * This allows for the new property to be read off of `obj` in a type-safe manner after calling this function.\n */\nexport function defineLazyCachedProperty<\n\tT extends object,\n\tK extends string | number | symbol,\n\tV,\n>(obj: T, key: K, get: () => V): typeof obj & { [P in K]: V } {\n\tReflect.defineProperty(obj, key, {\n\t\tget() {\n\t\t\tconst value = get();\n\t\t\tReflect.defineProperty(obj, key, { value });\n\t\t\treturn value;\n\t\t},\n\t\tconfigurable: true,\n\t});\n\treturn obj as typeof obj & { [P in K]: V };\n}\n\n/**\n * Copies a given property from one object to another if and only if the property is defined.\n * @param source - The object to copy the property from.\n * If `source` is undefined or does not have the property defined, then this function will do nothing.\n * @param property - The property to copy.\n * @param destination - The object to copy the property to.\n * @remarks This function is useful for copying properties from one object to another while minimizing the presence of `undefined` values.\n * If `property` is not present on `source` - or if `property` is present, but has a value of `undefined` - then this function will not modify `destination`.\n * This is different from doing `destination.foo = source.foo`, which would define a `\"foo\"` property on `destination` with the value `undefined`.\n *\n * If the type of `source` is known to have `property`, then this function asserts that the type of `destination` has `property` as well after the call.\n *\n * This function first reads the property value (if present) from `source` and then sets it on `destination`, as opposed to e.g. directly copying the property descriptor.\n * @privateRemarks The first overload of this function allows auto-complete to suggest property names from `source`, but by having the second overload we still allow for arbitrary property names.\n */\nexport function copyPropertyIfDefined<S extends object, K extends keyof S, D extends object>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;\nexport function copyPropertyIfDefined<\n\tS extends object,\n\tK extends string | number | symbol,\n\tD extends object,\n>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;\nexport function copyPropertyIfDefined<\n\tS extends object,\n\tK extends string | number | symbol,\n\tD extends object,\n>(\n\tsource: S | undefined,\n\tproperty: K,\n\tdestination: D,\n): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D {\n\tif (source !== undefined) {\n\t\tconst value = (source as { [P in K]?: unknown })[property];\n\t\tif (value !== undefined) {\n\t\t\t(destination as { [P in K]: unknown })[property] = value;\n\t\t}\n\t}\n}\n\n/**\n * Reduces an array of values into a single value.\n * This is similar to `Array.prototype.reduce`,\n * except that it recursively reduces the left and right halves of the input before reducing their respective reductions.\n *\n * When compared with an approach like reducing all the values left-to-right,\n * this balanced approach is beneficial when the cost of invoking `callbackFn` is proportional to the number reduced values that its parameters collectively represent.\n * For example, if `T` is an array, and `callbackFn` concatenates its inputs,\n * then `balancedReduce` will have O(N*log(N)) time complexity instead of `Array.prototype.reduce`'s O(N²).\n * However, if `callbackFn` is O(1) then both `balancedReduce` and `Array.prototype.reduce` will have O(N) complexity.\n *\n * @param array - The array to reduce.\n * @param callbackFn - The function to execute for each pairwise reduction.\n * @param emptyCase - A factory function that provides the value to return if the input array is empty.\n */\nexport function balancedReduce<T>(\n\tarray: readonly T[],\n\tcallbackFn: (left: T, right: T) => T,\n\temptyCase: () => T,\n): T {\n\tif (hasSingle(array)) {\n\t\treturn array[0];\n\t}\n\tif (!hasSome(array)) {\n\t\treturn emptyCase();\n\t}\n\tconst mid = Math.floor(array.length / 2);\n\tconst left = balancedReduce(array.slice(0, mid), callbackFn, emptyCase);\n\tconst right = balancedReduce(array.slice(mid), callbackFn, emptyCase);\n\treturn callbackFn(left, right);\n}\n"]}
package/eslint.config.mts CHANGED
@@ -27,20 +27,11 @@ const config: Linter.Config[] = [
27
27
  "@typescript-eslint/no-unsafe-argument": "off",
28
28
  "@typescript-eslint/no-unsafe-assignment": "off",
29
29
  "jsdoc/require-description": "warn",
30
- "unicorn/no-await-expression-member": "off",
31
30
  "unicorn/no-null": "off",
32
- "unicorn/prefer-export-from": "off",
33
- "unicorn/text-encoding-identifier-case": "off",
34
31
  },
35
32
  },
36
33
  {
37
34
  files: ["src/test/**/*"],
38
- languageOptions: {
39
- parserOptions: {
40
- projectService: false,
41
- project: ["./src/test/tsconfig.json"],
42
- },
43
- },
44
35
  rules: {
45
36
  "@typescript-eslint/no-unused-vars": ["off"],
46
37
  "@typescript-eslint/explicit-function-return-type": "off",
package/lib/alpha.d.ts CHANGED
@@ -105,7 +105,9 @@ export {
105
105
  AnnotatedAllowedTypeUnsafe,
106
106
  AnnotatedAllowedTypes,
107
107
  AnnotatedAllowedTypesUnsafe,
108
+ CodecWriteOptionsBeta,
108
109
  ConciseTree,
110
+ ExtensibleUnionNode,
109
111
  FixRecursiveArraySchema,
110
112
  FluidSerializableAsTree,
111
113
  ForestOptions,
@@ -124,6 +126,8 @@ export {
124
126
  SchemaStaticsBeta,
125
127
  SchemaUpgrade,
126
128
  SharedTreeOptionsBeta,
129
+ System_TableSchema,
130
+ TableSchema,
127
131
  TreeBeta,
128
132
  TreeBranch,
129
133
  TreeChangeEventsBeta,
@@ -149,10 +153,12 @@ export {
149
153
  ArrayNodeCustomizableSchemaUnsafe,
150
154
  ArrayNodePojoEmulationSchema,
151
155
  ArrayNodeSchema,
156
+ ArrayPlaceAnchor,
152
157
  BranchableTree,
153
158
  ChangeMetadata,
154
159
  CodecName,
155
160
  CodecWriteOptions,
161
+ CreateIndependentTreeAlphaOptions,
156
162
  DirtyTreeMap,
157
163
  DirtyTreeStatus,
158
164
  FactoryContent,
@@ -170,6 +176,7 @@ export {
170
176
  ITreeAlpha,
171
177
  IdentifierIndex,
172
178
  IncrementalEncodingPolicy,
179
+ IndependentViewOptions,
173
180
  Insertable,
174
181
  InsertableContent,
175
182
  InsertableField,
@@ -210,7 +217,6 @@ export {
210
217
  RevertibleAlpha,
211
218
  RevertibleAlphaFactory,
212
219
  RunTransactionParams,
213
- SchemaCompatibilitySnapshotsOptions,
214
220
  SchemaFactoryAlpha,
215
221
  SchemaType,
216
222
  SharedTreeFormatOptions,
@@ -228,8 +234,7 @@ export {
228
234
  SimpleTreeIndex,
229
235
  SimpleTreeSchema,
230
236
  SnapshotFileSystem,
231
- System_TableSchema,
232
- TableSchema,
237
+ SnapshotSchemaCompatibilityOptions,
233
238
  TransactionCallbackStatus,
234
239
  TransactionConstraintAlpha,
235
240
  TransactionResult,
@@ -260,11 +265,11 @@ export {
260
265
  asAlpha,
261
266
  asTreeViewAlpha,
262
267
  checkCompatibility,
263
- checkSchemaCompatibilitySnapshots,
264
268
  cloneWithReplacements,
265
269
  comparePersistedSchema,
266
270
  configuredSharedTreeAlpha,
267
271
  contentSchemaSymbol,
272
+ createArrayInsertionAnchor,
268
273
  createIdentifierIndex,
269
274
  createIndependentTreeAlpha,
270
275
  createSimpleTreeIndex,
@@ -289,6 +294,7 @@ export {
289
294
  replaceConciseTreeHandles,
290
295
  replaceHandles,
291
296
  replaceVerboseTreeHandles,
297
+ snapshotSchemaCompatibility,
292
298
  trackDirtyNodes
293
299
  // #endregion
294
300
  } from "./index.js";
package/lib/beta.d.ts CHANGED
@@ -105,7 +105,9 @@ export {
105
105
  AnnotatedAllowedTypeUnsafe,
106
106
  AnnotatedAllowedTypes,
107
107
  AnnotatedAllowedTypesUnsafe,
108
+ CodecWriteOptionsBeta,
108
109
  ConciseTree,
110
+ ExtensibleUnionNode,
109
111
  FixRecursiveArraySchema,
110
112
  FluidSerializableAsTree,
111
113
  ForestOptions,
@@ -124,6 +126,8 @@ export {
124
126
  SchemaStaticsBeta,
125
127
  SchemaUpgrade,
126
128
  SharedTreeOptionsBeta,
129
+ System_TableSchema,
130
+ TableSchema,
127
131
  TreeBeta,
128
132
  TreeBranch,
129
133
  TreeChangeEventsBeta,
@@ -2,11 +2,9 @@
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";
9
- import type { ChangeEncodingContext } from "../core/index.js";
10
8
  import type { JsonCompatibleReadOnly } from "../util/index.js";
11
9
  /**
12
10
  * Translates decoded data to encoded data.
@@ -113,11 +111,9 @@ export interface ICodecOptions {
113
111
  }
114
112
  /**
115
113
  * Options relating to encoding of persisted data.
116
- * @remarks
117
- * Extends {@link ICodecOptions} with options that are specific to encoding data.
118
- * @alpha @input
114
+ * @input @beta
119
115
  */
120
- export interface CodecWriteOptions extends ICodecOptions {
116
+ export interface CodecWriteOptionsBeta {
121
117
  /**
122
118
  * The minimum version of the Fluid Framework client output must be encoded to be compatible with.
123
119
  * @remarks
@@ -128,14 +124,22 @@ export interface CodecWriteOptions extends ICodecOptions {
128
124
  * the data's format should be versioned and if they can't handle the format they should error.
129
125
  */
130
126
  readonly minVersionForCollab: MinimumVersionForCollab;
127
+ }
128
+ /**
129
+ * Options relating to encoding of persisted data.
130
+ * @remarks
131
+ * Extends {@link ICodecOptions} with options that are specific to encoding data.
132
+ * @alpha @input
133
+ */
134
+ export interface CodecWriteOptions extends ICodecOptions, CodecWriteOptionsBeta {
131
135
  /**
132
136
  * Overrides the version of the codec to use for encoding.
133
137
  * @remarks
134
- * Without an override, the selected version will be based on {@link CodecWriteOptions.minVersionForCollab}.
138
+ * Without an override, the selected version will be based on {@link CodecWriteOptionsBeta.minVersionForCollab}.
135
139
  */
136
140
  readonly writeVersionOverrides?: ReadonlyMap<CodecName, FormatVersion>;
137
141
  /**
138
- * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptions.minVersionForCollab}.
142
+ * If true, suppress errors when `writeVersionOverrides` selects a version which may not be compatible with the {@link CodecWriteOptionsBeta.minVersionForCollab}.
139
143
  */
140
144
  readonly allowPossiblyIncompatibleWriteVersionOverrides?: boolean;
141
145
  }
@@ -163,29 +167,9 @@ export interface IJsonCodec<TDecoded, TEncoded = JsonCompatibleReadOnly, TValida
163
167
  encodedSchema?: TAnySchema;
164
168
  }
165
169
  /**
166
- * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.
170
+ * Type erase the more detailed encoded type from a codec.
167
171
  */
168
- export interface IBinaryCodec<TDecoded, TContext = void> extends IEncoder<TDecoded, IsoBuffer, TContext>, IDecoder<TDecoded, IsoBuffer, TContext> {
169
- }
170
- /**
171
- * Contains knowledge of how to encode some in-memory type into JSON and binary formats,
172
- * as well as how to decode those representations.
173
- *
174
- * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.
175
- * For this common use case, any format for encoding that was ever actually used needs to
176
- * be supported for decoding in all future code versions.
177
- *
178
- * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in
179
- * mind evolution of encodings over time.
180
- */
181
- export interface IMultiFormatCodec<TDecoded, TJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly, TJsonValidate = TJsonEncoded, TContext = void> {
182
- json: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;
183
- binary: IBinaryCodec<TDecoded, TContext>;
184
- /** Ensures multi-format codecs cannot also be single-format codecs. */
185
- encode?: never;
186
- /** Ensures multi-format codecs cannot also be single-format codecs. */
187
- decode?: never;
188
- }
172
+ export declare function eraseEncodedType<TDecoded, TEncoded = JsonCompatibleReadOnly, TValidate = TEncoded, TContext = void>(codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TValidate, TValidate, TContext>;
189
173
  /**
190
174
  * Represents a family of codecs that can be used to encode and decode data in different formats.
191
175
  * The family is identified by a format version, which is typically used to select the codec to use.
@@ -207,7 +191,7 @@ export interface ICodecFamily<TDecoded, TContext = void> {
207
191
  * logged properties or directly using some logger) when a format version is requested that is not supported.
208
192
  * This ensures that applications can diagnose compatibility issues.
209
193
  */
210
- resolve(formatVersion: FormatVersion): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;
194
+ resolve(formatVersion: FormatVersion): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;
211
195
  /**
212
196
  * @returns an iterable of all format versions supported by this family.
213
197
  */
@@ -257,31 +241,20 @@ export declare const DependentFormatVersion: {
257
241
  };
258
242
  /**
259
243
  * Creates a codec family from a registry of codecs.
260
- * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.
261
244
  */
262
245
  export declare function makeCodecFamily<TDecoded, TContext>(registry: Iterable<[
263
246
  formatVersion: FormatVersion,
264
- codec: IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> | IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>
247
+ codec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>
265
248
  ]>): ICodecFamily<TDecoded, TContext>;
266
- /**
267
- * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes
268
- * the json representation of the object to a buffer.
269
- */
270
- export declare function withDefaultBinaryEncoding<TDecoded, TContext, TEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly>(jsonCodec: IJsonCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>): IMultiFormatCodec<TDecoded, TEncoded, JsonCompatibleReadOnly, TContext>;
271
- /**
272
- * Ensures that the provided single or multi-format codec has a binary encoding.
273
- * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.
274
- */
275
- 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>;
276
249
  /**
277
250
  * Codec for objects which carry no information.
278
251
  */
279
- export declare const unitCodec: IMultiFormatCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, unknown>;
252
+ export declare const unitCodec: IJsonCodec<0, JsonCompatibleReadOnly, JsonCompatibleReadOnly, unknown>;
280
253
  /**
281
254
  * Wraps a codec with JSON schema validation for its encoded type.
282
255
  * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.
283
256
  */
284
- export declare function withSchemaValidation<TInMemoryFormat, EncodedSchema extends TSchema, TEncodedFormat = JsonCompatibleReadOnly, TValidate = TEncodedFormat, TContext = ChangeEncodingContext>(schema: EncodedSchema, codec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>, validator?: JsonValidator | FormatValidator): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>;
257
+ 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>;
285
258
  /**
286
259
  * Versions of Fluid Framework client packages.
287
260
  * @remarks
@@ -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;AAE5F,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACrD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,wB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,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"}
@@ -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, bufferToString } from "@fluid-internal/client-utils";
6
5
  import { assert, fail } from "@fluidframework/core-utils/internal";
7
6
  import { cleanedPackageVersion as runtimeUtilsCleanedPackageVersion } from "@fluidframework/runtime-utils/internal";
8
7
  /**
@@ -30,6 +29,12 @@ export function toFormatValidator(factory) {
30
29
  export function extractJsonValidator(input) {
31
30
  return input;
32
31
  }
32
+ /**
33
+ * Type erase the more detailed encoded type from a codec.
34
+ */
35
+ export function eraseEncodedType(codec) {
36
+ return codec;
37
+ }
33
38
  export class UniqueDependentFormatVersion {
34
39
  constructor(child) {
35
40
  this.child = child;
@@ -53,7 +58,6 @@ export const DependentFormatVersion = {
53
58
  };
54
59
  /**
55
60
  * Creates a codec family from a registry of codecs.
56
- * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.
57
61
  */
58
62
  export function makeCodecFamily(registry) {
59
63
  const codecs = new Map();
@@ -61,12 +65,12 @@ export function makeCodecFamily(registry) {
61
65
  if (codecs.has(formatVersion)) {
62
66
  fail(0xabf /* Duplicate codecs specified. */);
63
67
  }
64
- codecs.set(formatVersion, ensureBinaryEncoding(codec));
68
+ codecs.set(formatVersion, codec);
65
69
  }
66
70
  return {
67
71
  resolve(formatVersion) {
68
72
  const codec = codecs.get(formatVersion);
69
- assert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);
73
+ assert(codec !== undefined, 0x5e6 /* Requested codec for unsupported format. */);
70
74
  return codec;
71
75
  },
72
76
  getSupportedFormats() {
@@ -74,53 +78,12 @@ export function makeCodecFamily(registry) {
74
78
  },
75
79
  };
76
80
  }
77
- class DefaultBinaryCodec {
78
- constructor(jsonCodec) {
79
- this.jsonCodec = jsonCodec;
80
- }
81
- encode(change, context) {
82
- const jsonable = this.jsonCodec.encode(change, context);
83
- const json = JSON.stringify(jsonable);
84
- return IsoBuffer.from(json);
85
- }
86
- decode(change, context) {
87
- const json = bufferToString(change, "utf8");
88
- const jsonable = JSON.parse(json);
89
- return this.jsonCodec.decode(jsonable, context);
90
- }
91
- }
92
- function isJsonCodec(codec) {
93
- return typeof codec.encode === "function" && typeof codec.decode === "function";
94
- }
95
- /**
96
- * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes
97
- * the json representation of the object to a buffer.
98
- */
99
- export function withDefaultBinaryEncoding(jsonCodec) {
100
- return {
101
- json: jsonCodec,
102
- binary: new DefaultBinaryCodec(jsonCodec),
103
- };
104
- }
105
- /**
106
- * Ensures that the provided single or multi-format codec has a binary encoding.
107
- * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.
108
- */
109
- export function ensureBinaryEncoding(codec) {
110
- return isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;
111
- }
112
81
  /**
113
82
  * Codec for objects which carry no information.
114
83
  */
115
84
  export const unitCodec = {
116
- json: {
117
- encode: () => 0,
118
- decode: () => 0,
119
- },
120
- binary: {
121
- encode: () => IsoBuffer.from(""),
122
- decode: () => 0,
123
- },
85
+ encode: () => 0,
86
+ decode: () => 0,
124
87
  };
125
88
  /**
126
89
  * Wraps a codec with JSON schema validation for its encoded type.