@fluidframework/tree 2.4.0-297385 → 2.4.0-299707

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 (349) hide show
  1. package/.dependency-cruiser-known-violations.json +0 -14
  2. package/api-report/tree.alpha.api.md +100 -0
  3. package/dist/alpha.d.ts +20 -1
  4. package/dist/codec/codec.d.ts +4 -4
  5. package/dist/codec/codec.js.map +1 -1
  6. package/dist/codec/noopValidator.d.ts +1 -1
  7. package/dist/codec/noopValidator.js +1 -1
  8. package/dist/codec/noopValidator.js.map +1 -1
  9. package/dist/core/tree/anchorSet.d.ts +159 -2
  10. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  11. package/dist/core/tree/anchorSet.js +54 -12
  12. package/dist/core/tree/anchorSet.js.map +1 -1
  13. package/dist/external-utilities/typeboxValidator.d.ts +1 -1
  14. package/dist/external-utilities/typeboxValidator.js +1 -1
  15. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  16. package/dist/feature-libraries/flex-tree/lazyField.d.ts +4 -0
  17. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyField.js +38 -6
  19. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  20. package/dist/feature-libraries/index.d.ts +0 -1
  21. package/dist/feature-libraries/index.d.ts.map +1 -1
  22. package/dist/feature-libraries/index.js +46 -49
  23. package/dist/feature-libraries/index.js.map +1 -1
  24. package/dist/feature-libraries/treeCompressionUtils.d.ts +1 -1
  25. package/dist/feature-libraries/treeCompressionUtils.js +1 -1
  26. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  27. package/dist/index.d.ts +6 -5
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +4 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/internalTypes.d.ts +1 -1
  32. package/dist/internalTypes.d.ts.map +1 -1
  33. package/dist/internalTypes.js.map +1 -1
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/shared-tree/index.d.ts +2 -1
  38. package/dist/shared-tree/index.d.ts.map +1 -1
  39. package/dist/shared-tree/index.js +5 -1
  40. package/dist/shared-tree/index.js.map +1 -1
  41. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  42. package/dist/shared-tree/schematizingTreeView.js +1 -14
  43. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  44. package/dist/shared-tree/sharedTree.d.ts +24 -9
  45. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  46. package/dist/shared-tree/sharedTree.js +20 -8
  47. package/dist/shared-tree/sharedTree.js.map +1 -1
  48. package/dist/simple-tree/api/conciseTree.d.ts +29 -0
  49. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -0
  50. package/dist/simple-tree/api/conciseTree.js +25 -0
  51. package/dist/simple-tree/api/conciseTree.js.map +1 -0
  52. package/dist/simple-tree/api/customTree.d.ts +44 -0
  53. package/dist/simple-tree/api/customTree.d.ts.map +1 -0
  54. package/dist/simple-tree/api/customTree.js +63 -0
  55. package/dist/simple-tree/api/customTree.js.map +1 -0
  56. package/dist/simple-tree/api/index.d.ts +6 -1
  57. package/dist/simple-tree/api/index.d.ts.map +1 -1
  58. package/dist/simple-tree/api/index.js +5 -1
  59. package/dist/simple-tree/api/index.js.map +1 -1
  60. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
  61. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  62. package/dist/simple-tree/api/schemaCreationUtilities.js +43 -15
  63. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  64. package/dist/simple-tree/api/schemaFactory.d.ts +1 -2
  65. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  66. package/dist/simple-tree/api/schemaFactory.js +8 -8
  67. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  68. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
  69. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  70. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  71. package/dist/simple-tree/api/storedSchema.d.ts +78 -0
  72. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -0
  73. package/dist/simple-tree/api/storedSchema.js +107 -0
  74. package/dist/simple-tree/api/storedSchema.js.map +1 -0
  75. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  76. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  77. package/dist/simple-tree/api/treeNodeApi.js +5 -5
  78. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  79. package/dist/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +14 -5
  80. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -0
  81. package/dist/simple-tree/api/typesUnsafe.js.map +1 -0
  82. package/dist/simple-tree/api/verboseTree.d.ts +6 -20
  83. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  84. package/dist/simple-tree/api/verboseTree.js +10 -48
  85. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  86. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  87. package/dist/simple-tree/arrayNode.js +1 -2
  88. package/dist/simple-tree/arrayNode.js.map +1 -1
  89. package/dist/simple-tree/core/index.d.ts +1 -1
  90. package/dist/simple-tree/core/index.d.ts.map +1 -1
  91. package/dist/simple-tree/core/index.js +2 -1
  92. package/dist/simple-tree/core/index.js.map +1 -1
  93. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -0
  94. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  95. package/dist/simple-tree/core/treeNodeKernel.js +14 -1
  96. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  97. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  98. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -1
  99. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  100. package/dist/simple-tree/flexList.d.ts.map +1 -0
  101. package/dist/simple-tree/flexList.js.map +1 -0
  102. package/dist/simple-tree/index.d.ts +3 -4
  103. package/dist/simple-tree/index.d.ts.map +1 -1
  104. package/dist/simple-tree/index.js +5 -3
  105. package/dist/simple-tree/index.js.map +1 -1
  106. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  107. package/dist/simple-tree/mapNode.js +2 -3
  108. package/dist/simple-tree/mapNode.js.map +1 -1
  109. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  110. package/dist/simple-tree/objectNode.js +3 -4
  111. package/dist/simple-tree/objectNode.js.map +1 -1
  112. package/dist/simple-tree/schemaTypes.d.ts +2 -1
  113. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  114. package/dist/simple-tree/schemaTypes.js +5 -5
  115. package/dist/simple-tree/schemaTypes.js.map +1 -1
  116. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  117. package/dist/simple-tree/toFlexSchema.js +13 -15
  118. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  119. package/dist/simple-tree/toMapTree.js +3 -3
  120. package/dist/simple-tree/toMapTree.js.map +1 -1
  121. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  122. package/dist/simple-tree/treeNodeValid.js +2 -1
  123. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  124. package/dist/treeFactory.d.ts +1 -0
  125. package/dist/treeFactory.d.ts.map +1 -1
  126. package/dist/treeFactory.js +1 -0
  127. package/dist/treeFactory.js.map +1 -1
  128. package/dist/util/utils.d.ts +10 -8
  129. package/dist/util/utils.d.ts.map +1 -1
  130. package/dist/util/utils.js.map +1 -1
  131. package/docs/main/detached-trees.md +8 -8
  132. package/lib/alpha.d.ts +20 -1
  133. package/lib/codec/codec.d.ts +4 -4
  134. package/lib/codec/codec.js.map +1 -1
  135. package/lib/codec/noopValidator.d.ts +1 -1
  136. package/lib/codec/noopValidator.js +1 -1
  137. package/lib/codec/noopValidator.js.map +1 -1
  138. package/lib/core/tree/anchorSet.d.ts +159 -2
  139. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  140. package/lib/core/tree/anchorSet.js +54 -12
  141. package/lib/core/tree/anchorSet.js.map +1 -1
  142. package/lib/external-utilities/typeboxValidator.d.ts +1 -1
  143. package/lib/external-utilities/typeboxValidator.js +1 -1
  144. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  145. package/lib/feature-libraries/flex-tree/lazyField.d.ts +4 -0
  146. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  147. package/lib/feature-libraries/flex-tree/lazyField.js +36 -5
  148. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  149. package/lib/feature-libraries/index.d.ts +0 -1
  150. package/lib/feature-libraries/index.d.ts.map +1 -1
  151. package/lib/feature-libraries/index.js +0 -1
  152. package/lib/feature-libraries/index.js.map +1 -1
  153. package/lib/feature-libraries/treeCompressionUtils.d.ts +1 -1
  154. package/lib/feature-libraries/treeCompressionUtils.js +1 -1
  155. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  156. package/lib/index.d.ts +6 -5
  157. package/lib/index.d.ts.map +1 -1
  158. package/lib/index.js +3 -3
  159. package/lib/index.js.map +1 -1
  160. package/lib/internalTypes.d.ts +1 -1
  161. package/lib/internalTypes.d.ts.map +1 -1
  162. package/lib/internalTypes.js.map +1 -1
  163. package/lib/packageVersion.d.ts +1 -1
  164. package/lib/packageVersion.js +1 -1
  165. package/lib/packageVersion.js.map +1 -1
  166. package/lib/shared-tree/index.d.ts +2 -1
  167. package/lib/shared-tree/index.d.ts.map +1 -1
  168. package/lib/shared-tree/index.js +2 -1
  169. package/lib/shared-tree/index.js.map +1 -1
  170. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  171. package/lib/shared-tree/schematizingTreeView.js +2 -15
  172. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  173. package/lib/shared-tree/sharedTree.d.ts +24 -9
  174. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  175. package/lib/shared-tree/sharedTree.js +19 -8
  176. package/lib/shared-tree/sharedTree.js.map +1 -1
  177. package/lib/simple-tree/api/conciseTree.d.ts +29 -0
  178. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -0
  179. package/lib/simple-tree/api/conciseTree.js +21 -0
  180. package/lib/simple-tree/api/conciseTree.js.map +1 -0
  181. package/lib/simple-tree/api/customTree.d.ts +44 -0
  182. package/lib/simple-tree/api/customTree.d.ts.map +1 -0
  183. package/lib/simple-tree/api/customTree.js +59 -0
  184. package/lib/simple-tree/api/customTree.js.map +1 -0
  185. package/lib/simple-tree/api/index.d.ts +6 -1
  186. package/lib/simple-tree/api/index.d.ts.map +1 -1
  187. package/lib/simple-tree/api/index.js +1 -0
  188. package/lib/simple-tree/api/index.js.map +1 -1
  189. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +41 -26
  190. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  191. package/lib/simple-tree/api/schemaCreationUtilities.js +43 -15
  192. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  193. package/lib/simple-tree/api/schemaFactory.d.ts +1 -2
  194. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  195. package/lib/simple-tree/api/schemaFactory.js +1 -1
  196. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  197. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -2
  198. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  199. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  200. package/lib/simple-tree/api/storedSchema.d.ts +78 -0
  201. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -0
  202. package/lib/simple-tree/api/storedSchema.js +101 -0
  203. package/lib/simple-tree/api/storedSchema.js.map +1 -0
  204. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  205. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  206. package/lib/simple-tree/api/treeNodeApi.js +3 -3
  207. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  208. package/lib/simple-tree/{typesUnsafe.d.ts → api/typesUnsafe.d.ts} +14 -5
  209. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -0
  210. package/lib/simple-tree/api/typesUnsafe.js.map +1 -0
  211. package/lib/simple-tree/api/verboseTree.d.ts +6 -20
  212. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  213. package/lib/simple-tree/api/verboseTree.js +11 -49
  214. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  215. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  216. package/lib/simple-tree/arrayNode.js +1 -2
  217. package/lib/simple-tree/arrayNode.js.map +1 -1
  218. package/lib/simple-tree/core/index.d.ts +1 -1
  219. package/lib/simple-tree/core/index.d.ts.map +1 -1
  220. package/lib/simple-tree/core/index.js +1 -1
  221. package/lib/simple-tree/core/index.js.map +1 -1
  222. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -0
  223. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  224. package/lib/simple-tree/core/treeNodeKernel.js +12 -0
  225. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  226. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  227. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -1
  228. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  229. package/lib/simple-tree/flexList.d.ts.map +1 -0
  230. package/lib/simple-tree/flexList.js.map +1 -0
  231. package/lib/simple-tree/index.d.ts +3 -4
  232. package/lib/simple-tree/index.d.ts.map +1 -1
  233. package/lib/simple-tree/index.js +2 -3
  234. package/lib/simple-tree/index.js.map +1 -1
  235. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  236. package/lib/simple-tree/mapNode.js +1 -2
  237. package/lib/simple-tree/mapNode.js.map +1 -1
  238. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  239. package/lib/simple-tree/objectNode.js +1 -2
  240. package/lib/simple-tree/objectNode.js.map +1 -1
  241. package/lib/simple-tree/schemaTypes.d.ts +2 -1
  242. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  243. package/lib/simple-tree/schemaTypes.js +1 -1
  244. package/lib/simple-tree/schemaTypes.js.map +1 -1
  245. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  246. package/lib/simple-tree/toFlexSchema.js +1 -3
  247. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  248. package/lib/simple-tree/toMapTree.js +3 -3
  249. package/lib/simple-tree/toMapTree.js.map +1 -1
  250. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  251. package/lib/simple-tree/treeNodeValid.js +2 -1
  252. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  253. package/lib/treeFactory.d.ts +1 -0
  254. package/lib/treeFactory.d.ts.map +1 -1
  255. package/lib/treeFactory.js +1 -0
  256. package/lib/treeFactory.js.map +1 -1
  257. package/lib/util/utils.d.ts +10 -8
  258. package/lib/util/utils.d.ts.map +1 -1
  259. package/lib/util/utils.js.map +1 -1
  260. package/package.json +26 -25
  261. package/src/codec/codec.ts +4 -4
  262. package/src/codec/noopValidator.ts +1 -1
  263. package/src/core/tree/anchorSet.ts +63 -13
  264. package/src/external-utilities/typeboxValidator.ts +1 -1
  265. package/src/feature-libraries/flex-tree/lazyField.ts +44 -7
  266. package/src/feature-libraries/index.ts +0 -10
  267. package/src/feature-libraries/treeCompressionUtils.ts +1 -1
  268. package/src/index.ts +17 -6
  269. package/src/internalTypes.ts +1 -1
  270. package/src/packageVersion.ts +1 -1
  271. package/src/shared-tree/index.ts +5 -0
  272. package/src/shared-tree/schematizingTreeView.ts +7 -16
  273. package/src/shared-tree/sharedTree.ts +52 -22
  274. package/src/simple-tree/api/conciseTree.ts +58 -0
  275. package/src/simple-tree/api/customTree.ts +119 -0
  276. package/src/simple-tree/api/index.ts +34 -1
  277. package/src/simple-tree/api/schemaCreationUtilities.ts +55 -36
  278. package/src/simple-tree/api/schemaFactory.ts +4 -6
  279. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -2
  280. package/src/simple-tree/api/storedSchema.ts +126 -0
  281. package/src/simple-tree/api/treeNodeApi.ts +3 -8
  282. package/src/simple-tree/{typesUnsafe.ts → api/typesUnsafe.ts} +15 -5
  283. package/src/simple-tree/api/verboseTree.ts +21 -76
  284. package/src/simple-tree/arrayNode.ts +1 -1
  285. package/src/simple-tree/core/index.ts +1 -0
  286. package/src/simple-tree/core/treeNodeKernel.ts +13 -0
  287. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -1
  288. package/src/simple-tree/index.ts +26 -20
  289. package/src/simple-tree/mapNode.ts +1 -1
  290. package/src/simple-tree/objectNode.ts +1 -1
  291. package/src/simple-tree/schemaTypes.ts +2 -6
  292. package/src/simple-tree/toFlexSchema.ts +1 -3
  293. package/src/simple-tree/toMapTree.ts +3 -3
  294. package/src/simple-tree/treeNodeValid.ts +2 -1
  295. package/src/treeFactory.ts +1 -0
  296. package/src/util/utils.ts +10 -8
  297. package/dist/feature-libraries/flex-tree/unboxed.d.ts +0 -12
  298. package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
  299. package/dist/feature-libraries/flex-tree/unboxed.js +0 -20
  300. package/dist/feature-libraries/flex-tree/unboxed.js.map +0 -1
  301. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
  302. package/dist/feature-libraries/typed-schema/flexList.js.map +0 -1
  303. package/dist/feature-libraries/typed-schema/index.d.ts +0 -7
  304. package/dist/feature-libraries/typed-schema/index.d.ts.map +0 -1
  305. package/dist/feature-libraries/typed-schema/index.js +0 -12
  306. package/dist/feature-libraries/typed-schema/index.js.map +0 -1
  307. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
  308. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
  309. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -7
  310. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
  311. package/dist/simple-tree/proxyBinding.d.ts +0 -15
  312. package/dist/simple-tree/proxyBinding.d.ts.map +0 -1
  313. package/dist/simple-tree/proxyBinding.js +0 -22
  314. package/dist/simple-tree/proxyBinding.js.map +0 -1
  315. package/dist/simple-tree/typesUnsafe.d.ts.map +0 -1
  316. package/dist/simple-tree/typesUnsafe.js.map +0 -1
  317. package/lib/feature-libraries/flex-tree/unboxed.d.ts +0 -12
  318. package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +0 -1
  319. package/lib/feature-libraries/flex-tree/unboxed.js +0 -16
  320. package/lib/feature-libraries/flex-tree/unboxed.js.map +0 -1
  321. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +0 -1
  322. package/lib/feature-libraries/typed-schema/flexList.js.map +0 -1
  323. package/lib/feature-libraries/typed-schema/index.d.ts +0 -7
  324. package/lib/feature-libraries/typed-schema/index.d.ts.map +0 -1
  325. package/lib/feature-libraries/typed-schema/index.js +0 -6
  326. package/lib/feature-libraries/typed-schema/index.js.map +0 -1
  327. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -14
  328. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +0 -1
  329. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +0 -6
  330. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +0 -1
  331. package/lib/simple-tree/proxyBinding.d.ts +0 -15
  332. package/lib/simple-tree/proxyBinding.d.ts.map +0 -1
  333. package/lib/simple-tree/proxyBinding.js +0 -18
  334. package/lib/simple-tree/proxyBinding.js.map +0 -1
  335. package/lib/simple-tree/typesUnsafe.d.ts.map +0 -1
  336. package/lib/simple-tree/typesUnsafe.js.map +0 -1
  337. package/src/feature-libraries/flex-tree/unboxed.ts +0 -24
  338. package/src/feature-libraries/typed-schema/README.md +0 -6
  339. package/src/feature-libraries/typed-schema/index.ts +0 -16
  340. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -14
  341. package/src/simple-tree/proxyBinding.ts +0 -20
  342. /package/dist/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
  343. /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
  344. /package/dist/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
  345. /package/lib/simple-tree/{typesUnsafe.js → api/typesUnsafe.js} +0 -0
  346. /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.d.ts +0 -0
  347. /package/lib/{feature-libraries/typed-schema → simple-tree}/flexList.js +0 -0
  348. /package/src/simple-tree/{ProxyBinding.md → core/TreeNodeBinding.md} +0 -0
  349. /package/src/{feature-libraries/typed-schema → simple-tree}/flexList.ts +0 -0
@@ -11,19 +11,5 @@
11
11
  "src/feature-libraries/flex-tree/lazyNode.ts",
12
12
  "src/feature-libraries/flex-tree/lazyField.ts"
13
13
  ]
14
- },
15
- {
16
- "type": "cycle",
17
- "from": "src/feature-libraries/flex-tree/lazyField.ts",
18
- "to": "src/feature-libraries/flex-tree/unboxed.ts",
19
- "rule": {
20
- "severity": "error",
21
- "name": "no-circular"
22
- },
23
- "cycle": [
24
- "src/feature-libraries/flex-tree/unboxed.ts",
25
- "src/feature-libraries/flex-tree/lazyNode.ts",
26
- "src/feature-libraries/flex-tree/lazyField.ts"
27
- ]
28
14
  }
29
15
  ]
@@ -4,6 +4,15 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ // @alpha
8
+ export function adaptEnum<TScope extends string, const TEnum extends Record<string, string | number>>(factory: SchemaFactory<TScope>, members: TEnum): (<TValue extends TEnum[keyof TEnum]>(value: TValue) => TreeNode & {
9
+ readonly value: TValue;
10
+ }) & { readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & {
11
+ readonly value: TEnum[Property];
12
+ }, never, true, unknown> & (new () => TreeNode & {
13
+ readonly value: TEnum[Property];
14
+ }); };
15
+
7
16
  // @public
8
17
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
9
18
 
@@ -27,13 +36,28 @@ export interface CommitMetadata {
27
36
  readonly kind: CommitKind;
28
37
  }
29
38
 
39
+ // @alpha
40
+ export function comparePersistedSchema(persisted: JsonCompatible, view: JsonCompatible, options: ICodecOptions, canInitialize: boolean): SchemaCompatibilityStatus;
41
+
30
42
  // @public @sealed
31
43
  interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {
32
44
  }
33
45
 
46
+ // @alpha
47
+ export function enumFromStrings<TScope extends string, const Members extends string>(factory: SchemaFactory<TScope>, members: readonly Members[]): (<TValue extends Members>(value: TValue) => TreeNode & {
48
+ readonly value: TValue;
49
+ }) & Record<Members, TreeNodeSchemaClass<ScopedSchemaName<TScope, Members>, NodeKind.Object, TreeNode & {
50
+ readonly value: Members;
51
+ }, never, true, unknown> & (new () => TreeNode & {
52
+ readonly value: Members;
53
+ })>;
54
+
34
55
  // @public
35
56
  type ExtractItemType<Item extends LazyItem> = Item extends () => infer Result ? Result : Item;
36
57
 
58
+ // @alpha
59
+ export function extractPersistedSchema(schema: ImplicitFieldSchema): JsonCompatible;
60
+
37
61
  // @public
38
62
  type FieldHasDefault<T extends ImplicitFieldSchema> = T extends FieldSchema<FieldKind.Optional | FieldKind.Identifier> ? true : false;
39
63
 
@@ -92,6 +116,18 @@ type FlexList<Item = unknown> = readonly LazyItem<Item>[];
92
116
  // @public
93
117
  type FlexListToUnion<TList extends FlexList> = ExtractItemType<TList[number]>;
94
118
 
119
+ // @alpha
120
+ export interface ForestOptions {
121
+ readonly forest?: ForestType;
122
+ }
123
+
124
+ // @alpha
125
+ export enum ForestType {
126
+ Expensive = 2,
127
+ Optimized = 1,
128
+ Reference = 0
129
+ }
130
+
95
131
  // @alpha
96
132
  export function getBranch(tree: ITree): TreeBranch;
97
133
 
@@ -101,6 +137,11 @@ export function getBranch(view: TreeView<ImplicitFieldSchema>): TreeBranch;
101
137
  // @alpha
102
138
  export function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
103
139
 
140
+ // @alpha
141
+ export interface ICodecOptions {
142
+ readonly jsonValidator: JsonValidator;
143
+ }
144
+
104
145
  // @public
105
146
  export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
106
147
 
@@ -215,6 +256,14 @@ export interface JsonArrayNodeSchema extends JsonNodeSchemaBase<NodeKind.Array,
215
256
  readonly items: JsonFieldSchema;
216
257
  }
217
258
 
259
+ // @alpha
260
+ export type JsonCompatible = string | number | boolean | null | JsonCompatible[] | JsonCompatibleObject;
261
+
262
+ // @alpha
263
+ export type JsonCompatibleObject = {
264
+ [P in string]?: JsonCompatible;
265
+ };
266
+
218
267
  // @alpha @sealed
219
268
  export type JsonFieldSchema = {
220
269
  readonly description?: string | undefined;
@@ -272,6 +321,11 @@ export type JsonTreeSchema = JsonFieldSchema & {
272
321
  readonly $defs: Record<JsonSchemaId, JsonNodeSchema>;
273
322
  };
274
323
 
324
+ // @alpha
325
+ export interface JsonValidator {
326
+ compile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;
327
+ }
328
+
275
329
  // @public
276
330
  export type LazyItem<Item = unknown> = Item | (() => Item);
277
331
 
@@ -325,6 +379,9 @@ export enum NodeKind {
325
379
  Object = 2
326
380
  }
327
381
 
382
+ // @alpha
383
+ export const noopValidator: JsonValidator;
384
+
328
385
  // @public
329
386
  type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> = {
330
387
  -readonly [Property in keyof T]: Property extends string ? TreeFieldFromImplicitField<T[Property]> : unknown;
@@ -443,9 +500,40 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
443
500
  readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
444
501
  }
445
502
 
503
+ // @alpha
504
+ export interface SchemaValidationFunction<Schema extends TSchema> {
505
+ check(data: unknown): data is Static<Schema>;
506
+ }
507
+
446
508
  // @public
447
509
  type ScopedSchemaName<TScope extends string | undefined, TName extends number | string> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
448
510
 
511
+ // @alpha
512
+ export interface SharedTreeFormatOptions {
513
+ formatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];
514
+ treeEncodeType: TreeCompressionStrategy;
515
+ }
516
+
517
+ // @alpha
518
+ export const SharedTreeFormatVersion: {
519
+ readonly v1: 1;
520
+ readonly v2: 2;
521
+ readonly v3: 3;
522
+ };
523
+
524
+ // @alpha
525
+ export type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;
526
+
527
+ // @alpha
528
+ export type SharedTreeOptions = Partial<ICodecOptions> & Partial<SharedTreeFormatOptions> & ForestOptions;
529
+
530
+ // @alpha
531
+ export function singletonSchema<TScope extends string, TName extends string | number>(factory: SchemaFactory<TScope, TName>, name: TName): TreeNodeSchemaClass<ScopedSchemaName<TScope, TName>, NodeKind.Object, TreeNode & {
532
+ readonly value: TName;
533
+ }, never, true, unknown> & (new () => TreeNode & {
534
+ readonly value: TName;
535
+ });
536
+
449
537
  // @public
450
538
  export type TransactionConstraint = NodeInDocumentConstraint;
451
539
 
@@ -522,6 +610,12 @@ export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode> extends
522
610
  nodeChanged: (data: NodeChangedData<TNode> & (TNode extends WithType<string, NodeKind.Map | NodeKind.Object> ? Required<Pick<NodeChangedData<TNode>, "changedProperties">> : unknown)) => void;
523
611
  }
524
612
 
613
+ // @alpha
614
+ export enum TreeCompressionStrategy {
615
+ Compressed = 0,
616
+ Uncompressed = 1
617
+ }
618
+
525
619
  // @public
526
620
  export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> = TSchema extends FieldSchema<infer Kind, infer Types> ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind, false> : TSchema extends ImplicitAllowedTypes ? TreeNodeFromImplicitAllowedTypes<TSchema> : unknown;
527
621
 
@@ -641,6 +735,12 @@ export interface TreeViewEvents {
641
735
  schemaChanged(): void;
642
736
  }
643
737
 
738
+ // @alpha
739
+ export const typeboxValidator: JsonValidator;
740
+
741
+ // @alpha
742
+ export function typedObjectValues<TKey extends string, TValues>(object: Record<TKey, TValues>): TValues[];
743
+
644
744
  // @public @deprecated
645
745
  const typeNameSymbol: unique symbol;
646
746
 
package/dist/alpha.d.ts CHANGED
@@ -89,7 +89,12 @@ export {
89
89
 
90
90
  // @alpha APIs
91
91
  FixRecursiveArraySchema,
92
+ ForestOptions,
93
+ ForestType,
94
+ ICodecOptions,
92
95
  JsonArrayNodeSchema,
96
+ JsonCompatible,
97
+ JsonCompatibleObject,
93
98
  JsonFieldSchema,
94
99
  JsonLeafNodeSchema,
95
100
  JsonLeafSchemaType,
@@ -102,8 +107,22 @@ export {
102
107
  JsonSchemaRef,
103
108
  JsonSchemaType,
104
109
  JsonTreeSchema,
110
+ JsonValidator,
111
+ SchemaValidationFunction,
112
+ SharedTreeFormatOptions,
113
+ SharedTreeFormatVersion,
114
+ SharedTreeOptions,
105
115
  TreeBranch,
106
116
  TreeBranchFork,
117
+ TreeCompressionStrategy,
118
+ adaptEnum,
119
+ comparePersistedSchema,
120
+ enumFromStrings,
121
+ extractPersistedSchema,
107
122
  getBranch,
108
- getJsonSchema
123
+ getJsonSchema,
124
+ noopValidator,
125
+ singletonSchema,
126
+ typeboxValidator,
127
+ typedObjectValues
109
128
  } from "./index.js";
@@ -29,17 +29,17 @@ export interface IDecoder<TDecoded, TEncoded, TContext> {
29
29
  /**
30
30
  * Validates data complies with some particular schema.
31
31
  * Implementations are typically created by a {@link JsonValidator}.
32
- * @internal
32
+ * @alpha
33
33
  */
34
34
  export interface SchemaValidationFunction<Schema extends TSchema> {
35
35
  /**
36
- * @returns Whether the data matches a schema.
36
+ * Returns whether the data matches a schema.
37
37
  */
38
38
  check(data: unknown): data is Static<Schema>;
39
39
  }
40
40
  /**
41
41
  * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.
42
- * @internal
42
+ * @alpha
43
43
  */
44
44
  export interface JsonValidator {
45
45
  /**
@@ -55,7 +55,7 @@ export interface JsonValidator {
55
55
  }
56
56
  /**
57
57
  * Options relating to handling of persisted data.
58
- * @internal
58
+ * @alpha
59
59
  */
60
60
  export interface ICodecOptions {
61
61
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAA6D;AAI7D,+CAAqE;AA+KrE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAOC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,IAAA,eAAI,EAAC,6BAA6B,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO;QACN,OAAO,CACN,aAAqB;YAErB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACxC,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,mBAAmB;YAClB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;KACD,CAAC;AACH,CAAC;AAjCD,0CAiCC;AAED,MAAM,kBAAkB;IACvB,YACkB,SAA2D;QAA3D,cAAS,GAAT,SAAS,CAAkD;IAC1E,CAAC;IAEG,MAAM,CAAC,MAAgB,EAAE,OAAiB;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAA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ACH,SAAgB,oBAAoB,CAOnC,MAAqB,EACrB,KAAuE,EACvE,SAAyB;IAEzB,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACN,MAAM,EAAE,CAAC,GAAoB,EAAE,OAAiB,EAAkB,EAAE;YACnE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,OAAkB,EAAE,OAAiB,EAAmB,EAAE;YAClE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpC,IAAA,eAAI,EAAC,gCAAgC,CAAC,CAAC;YACxC,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { ChangeEncodingContext } from \"../core/index.js\";\nimport { type JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @internal\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * @returns Whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @internal\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @internal\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/codec/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AACzE,kEAA6D;AAI7D,+CAAqE;AA+KrE;;;GAGG;AACH,SAAgB,eAAe,CAC9B,QAOC;IAED,MAAM,MAAM,GAGR,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,IAAA,eAAI,EAAC,6BAA6B,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,aAAa,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CAAC;YACxC,CAAC;YACD,2GAA2G;YAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAA+B,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AA/BD,oDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer, bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { Static, TAnySchema, TSchema } from \"@sinclair/typebox\";\n\nimport type { ChangeEncodingContext } from \"../core/index.js\";\nimport { type JsonCompatibleReadOnly, fail } from \"../util/index.js\";\n\n/**\n * Translates decoded data to encoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IEncoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Encodes `obj` into some encoded format.\n\t */\n\tencode(obj: TDecoded, context: TContext): TEncoded;\n}\n\n/**\n * Translates encoded data to decoded data.\n * @remarks Typically paired with an {@link IEncoder}.\n */\nexport interface IDecoder<TDecoded, TEncoded, TContext> {\n\t/**\n\t * Decodes `obj` from some encoded format.\n\t */\n\tdecode(obj: TEncoded, context: TContext): TDecoded;\n}\n\n/**\n * Validates data complies with some particular schema.\n * Implementations are typically created by a {@link JsonValidator}.\n * @alpha\n */\nexport interface SchemaValidationFunction<Schema extends TSchema> {\n\t/**\n\t * Returns whether the data matches a schema.\n\t */\n\tcheck(data: unknown): data is Static<Schema>;\n}\n\n/**\n * JSON schema validator compliant with draft 6 schema. See https://json-schema.org.\n * @alpha\n */\nexport interface JsonValidator {\n\t/**\n\t * Compiles the provided JSON schema into a validator for that schema.\n\t * @param schema - A valid draft 6 JSON schema\n\t * @remarks IFluidHandles--which have circular property references--are used in various places in SharedTree's persisted\n\t * format. Handles should only be contained in sections of data which are validated against the empty schema `{}`\n\t * (see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01#section-4.4).\n\t *\n\t * Implementations of `JsonValidator` must therefore tolerate these values, despite the input not being valid JSON.\n\t */\n\tcompile<Schema extends TSchema>(schema: Schema): SchemaValidationFunction<Schema>;\n}\n\n/**\n * Options relating to handling of persisted data.\n * @alpha\n */\nexport interface ICodecOptions {\n\t/**\n\t * {@link JsonValidator} which SharedTree uses to validate persisted data it reads & writes\n\t * matches the expected encoded format (i.e. the wire format for ops and summaries).\n\t *\n\t * See {@link noopValidator} and {@link typeboxValidator} for out-of-the-box implementations.\n\t *\n\t * This option is not \"on-by-default\" because JSON schema validation comes with a small but noticeable\n\t * runtime performance cost, and popular schema validation libraries have relatively large bundle size.\n\t *\n\t * SharedTree users are still encouraged to use a non-trivial validator (i.e. not `noopValidator`)\n\t * whenever reasonable: it gives better fail-fast behavior when unexpected encoded data is found,\n\t * which reduces the risk of unrecoverable data corruption.\n\t */\n\treadonly jsonValidator: JsonValidator;\n}\n\n/**\n * `TContext` allows passing context to the codec which may configure how data is encoded/decoded.\n * This parameter is typically used for:\n * - Codecs which can pick from multiple encoding options, and imbue the encoded data with information about which option was used.\n * The caller of such a codec can provide context about which encoding choice to make as part of the `encode` call without creating\n * additional codecs. Note that this pattern can always be implemented by having the caller create multiple codecs and selecting the\n * appropriate one, but depending on API layering this might be less ergonomic.\n * - Context for the object currently being encoded, which might enable more efficient encoding. When used in this fashion, the codec author\n * should be careful to include the context somewhere in the encoded data such that decoding can correctly round-trip.\n * For example, a composed set of codecs could implement a form of [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder)\n * using a context map which was created by the top-level codec and passed to the inner codecs.\n * This pattern is used:\n * - To avoid repeatedly encoding session ids on commits (only recording it once at the top level)\n * @remarks `TEncoded` should always be valid Json (i.e. not contain functions), but due to TypeScript's handling\n * of index signatures and `JsonCompatibleReadOnly`'s index signature in the Json object case, specifying this as a\n * type-system level constraint makes code that uses this interface more difficult to write.\n *\n * If provided, `TValidate` allows the input type passed to `decode` to be different than `TEncoded`.\n * This is useful when, for example, the type being decoded is `unknown` and must be validated to be a `TEncoded` before being decoded to a `TDecoded`.\n */\nexport interface IJsonCodec<\n\tTDecoded,\n\tTEncoded = JsonCompatibleReadOnly,\n\tTValidate = TEncoded,\n\tTContext = void,\n> extends IEncoder<TDecoded, TEncoded, TContext>,\n\t\tIDecoder<TDecoded, TValidate, TContext> {\n\tencodedSchema?: TAnySchema;\n}\n\n/**\n * @remarks TODO: We might consider using DataView or some kind of writer instead of IsoBuffer.\n */\nexport interface IBinaryCodec<TDecoded, TContext = void>\n\textends IEncoder<TDecoded, IsoBuffer, TContext>,\n\t\tIDecoder<TDecoded, IsoBuffer, TContext> {}\n\n/**\n * Contains knowledge of how to encode some in-memory type into JSON and binary formats,\n * as well as how to decode those representations.\n *\n * @remarks Codecs are typically used in shared-tree to convert data into some persisted format.\n * For this common use case, any format for encoding that was ever actually used needs to\n * be supported for decoding in all future code versions.\n *\n * Using an {@link ICodecFamily} is the recommended strategy for managing this support, keeping in\n * mind evolution of encodings over time.\n */\nexport interface IMultiFormatCodec<\n\tTDecoded,\n\tTJsonEncoded extends JsonCompatibleReadOnly = JsonCompatibleReadOnly,\n\tTJsonValidate = TJsonEncoded,\n\tTContext = void,\n> {\n\tjson: IJsonCodec<TDecoded, TJsonEncoded, TJsonValidate, TContext>;\n\tbinary: IBinaryCodec<TDecoded, TContext>;\n\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tencode?: never;\n\t/** Ensures multi-format codecs cannot also be single-format codecs. */\n\tdecode?: never;\n}\n\n/**\n * Represents a family of codecs that can be used to encode and decode data in different formats.\n * The family is identified by a format version, which is typically used to select the codec to use.\n *\n * Separating codecs into families rather than having a single codec support multiple versions (i.e. currying\n * the `formatVersion` parameter)\n * allows avoiding some duplicate work at encode/decode time, since the vast majority of document usage will not\n * involve mixed format versions.\n *\n * @privateRemarks - This interface currently assumes all codecs in a family require the same encode/decode context,\n * which isn't necessarily true.\n * This may need to be relaxed in the future.\n */\nexport interface ICodecFamily<TDecoded, TContext = void> {\n\t/**\n\t * @returns a codec that can be used to encode and decode data in the specified format.\n\t * @throws - if the format version is not supported by this family.\n\t * @remarks Implementations should typically emit telemetry (either indirectly by throwing a well-known error with\n\t * logged properties or directly using some logger) when a format version is requested that is not supported.\n\t * This ensures that applications can diagnose compatibility issues.\n\t */\n\tresolve(\n\t\tformatVersion: FormatVersion,\n\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>;\n\n\t/**\n\t * @returns an iterable of all format versions supported by this family.\n\t */\n\tgetSupportedFormats(): Iterable<FormatVersion>;\n}\n\n/**\n * A version stamp for encoded data.\n *\n * Undefined is tolerated to enable the scenario where data was not initially versioned.\n */\nexport type FormatVersion = number | undefined;\n\n/**\n * Creates a codec family from a registry of codecs.\n * Any codec that is not a {@link IMultiFormatCodec} will be wrapped with a default binary encoding.\n */\nexport function makeCodecFamily<TDecoded, TContext>(\n\tregistry: Iterable<\n\t\t[\n\t\t\tformatVersion: FormatVersion,\n\t\t\tcodec:\n\t\t\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n\t\t]\n\t>,\n): ICodecFamily<TDecoded, TContext> {\n\tconst codecs: Map<\n\t\tFormatVersion,\n\t\tIMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t> = new Map();\n\tfor (const [formatVersion, codec] of registry) {\n\t\tif (codecs.has(formatVersion)) {\n\t\t\tfail(\"Duplicate codecs specified.\");\n\t\t}\n\t\tcodecs.set(formatVersion, ensureBinaryEncoding(codec));\n\t}\n\n\treturn {\n\t\tresolve(\n\t\t\tformatVersion: number,\n\t\t): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\t\tconst codec = codecs.get(formatVersion);\n\t\t\tassert(codec !== undefined, 0x5e6 /* Requested coded for unsupported format. */);\n\t\t\treturn codec;\n\t\t},\n\t\tgetSupportedFormats(): Iterable<FormatVersion> {\n\t\t\treturn codecs.keys();\n\t\t},\n\t};\n}\n\nclass DefaultBinaryCodec<TDecoded, TContext> implements IBinaryCodec<TDecoded, TContext> {\n\tpublic constructor(\n\t\tprivate readonly jsonCodec: IJsonCodec<TDecoded, unknown, unknown, TContext>,\n\t) {}\n\n\tpublic encode(change: TDecoded, context: TContext): IsoBuffer {\n\t\tconst jsonable = this.jsonCodec.encode(change, context);\n\t\tconst json = JSON.stringify(jsonable);\n\t\treturn IsoBuffer.from(json);\n\t}\n\n\tpublic decode(change: IsoBuffer, context: TContext): TDecoded {\n\t\tconst json = bufferToString(change, \"utf8\");\n\t\tconst jsonable = JSON.parse(json);\n\t\treturn this.jsonCodec.decode(jsonable, context);\n\t}\n}\n\nfunction isJsonCodec<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): codec is IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn typeof codec.encode === \"function\" && typeof codec.decode === \"function\";\n}\n\n/**\n * Constructs a {@link IMultiFormatCodec} from a `IJsonCodec` using a generic binary encoding that simply writes\n * the json representation of the object to a buffer.\n */\nexport function withDefaultBinaryEncoding<TDecoded, TContext>(\n\tjsonCodec: IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn {\n\t\tjson: jsonCodec,\n\t\tbinary: new DefaultBinaryCodec(jsonCodec),\n\t};\n}\n\n/**\n * Ensures that the provided single or multi-format codec has a binary encoding.\n * Adapts the json encoding using {@link withDefaultBinaryEncoding} if necessary.\n */\nexport function ensureBinaryEncoding<TDecoded, TContext>(\n\tcodec:\n\t\t| IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>\n\t\t| IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext>,\n): IMultiFormatCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\treturn isJsonCodec(codec) ? withDefaultBinaryEncoding(codec) : codec;\n}\n\n/**\n * Codec for objects which carry no information.\n */\nexport const unitCodec: IMultiFormatCodec<\n\t0,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tunknown\n> = {\n\tjson: {\n\t\tencode: () => 0,\n\t\tdecode: () => 0,\n\t},\n\tbinary: {\n\t\tencode: () => IsoBuffer.from(\"\"),\n\t\tdecode: () => 0,\n\t},\n};\n\n/**\n * Wraps a codec with JSON schema validation for its encoded type.\n * @returns An {@link IJsonCodec} which validates the data it encodes and decodes matches the provided schema.\n */\nexport function withSchemaValidation<\n\tTInMemoryFormat,\n\tEncodedSchema extends TSchema,\n\tTEncodedFormat = JsonCompatibleReadOnly,\n\tTValidate = TEncodedFormat,\n\tTContext = ChangeEncodingContext,\n>(\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext>,\n\tvalidator?: JsonValidator,\n): IJsonCodec<TInMemoryFormat, TEncodedFormat, TValidate, TContext> {\n\tif (!validator) {\n\t\treturn codec;\n\t}\n\tconst compiledFormat = validator.compile(schema);\n\treturn {\n\t\tencode: (obj: TInMemoryFormat, context: TContext): TEncodedFormat => {\n\t\t\tconst encoded = codec.encode(obj, context);\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (encoded: TValidate, context: TContext): TInMemoryFormat => {\n\t\t\tif (!compiledFormat.check(encoded)) {\n\t\t\t\tfail(\"Encoded schema should validate\");\n\t\t\t}\n\t\t\t// TODO: would be nice to provide a more specific validate type to the inner codec than the outer one gets.\n\t\t\treturn codec.decode(encoded, context) as unknown as TInMemoryFormat;\n\t\t},\n\t};\n}\n"]}
@@ -7,7 +7,7 @@ import type { JsonValidator } from "./codec.js";
7
7
  * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.
8
8
  * @privateRemarks Having this as an option unifies opting out of validation with selection of
9
9
  * validators, simplifying code performing validation.
10
- * @internal
10
+ * @alpha
11
11
  */
12
12
  export declare const noopValidator: JsonValidator;
13
13
  //# sourceMappingURL=noopValidator.d.ts.map
@@ -9,7 +9,7 @@ exports.noopValidator = void 0;
9
9
  * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.
10
10
  * @privateRemarks Having this as an option unifies opting out of validation with selection of
11
11
  * validators, simplifying code performing validation.
12
- * @internal
12
+ * @alpha
13
13
  */
14
14
  exports.noopValidator = {
15
15
  compile: () => ({ check: (data) => true }),
@@ -1 +1 @@
1
- {"version":3,"file":"noopValidator.js","sourceRoot":"","sources":["../../src/codec/noopValidator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;;;GAKG;AACU,QAAA,aAAa,GAAkB;IAC3C,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonValidator } from \"./codec.js\";\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n * @internal\n */\nexport const noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n"]}
1
+ {"version":3,"file":"noopValidator.js","sourceRoot":"","sources":["../../src/codec/noopValidator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;;;GAKG;AACU,QAAA,aAAa,GAAkB;IAC3C,OAAO,EAAE,GAA2B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,EAAE,CAAC;CAC1F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Static, TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonValidator } from \"./codec.js\";\n\n/**\n * A {@link JsonValidator} implementation which performs no validation and accepts all data as valid.\n * @privateRemarks Having this as an option unifies opting out of validation with selection of\n * validators, simplifying code performing validation.\n * @alpha\n */\nexport const noopValidator: JsonValidator = {\n\tcompile: <Schema extends TSchema>() => ({ check: (data): data is Static<Schema> => true }),\n};\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type Listenable } from "../../events/index.js";
6
- import { type Brand, type BrandedKey, type BrandedMapSubset, type Opaque } from "../../util/index.js";
6
+ import { type Brand, type BrandedKey, type BrandedMapSubset, type Opaque, ReferenceCountedBase } from "../../util/index.js";
7
7
  import type { FieldKey } from "../schema-stored/index.js";
8
8
  import type { UpPath } from "./pathTree.js";
9
9
  import type { DeltaVisitor } from "./visitDelta.js";
@@ -185,6 +185,12 @@ export interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents>
185
185
  *
186
186
  */
187
187
  child(key: FieldKey, index: number): UpPath<AnchorNode>;
188
+ /**
189
+ * Gets the child AnchorNode if already exists.
190
+ *
191
+ * Does NOT add a ref, so the returned AnchorNode must be used with care.
192
+ */
193
+ childIfAnchored(key: FieldKey, index: number): AnchorNode | undefined;
188
194
  /**
189
195
  * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.
190
196
  * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.
@@ -276,8 +282,10 @@ export declare class AnchorSet implements Listenable<AnchorSetRootEvents>, Ancho
276
282
  private trackInner;
277
283
  /**
278
284
  * Finds a path node if it already exists.
285
+ *
286
+ * Does not add a ref!
279
287
  */
280
- private find;
288
+ find(path: UpPath): PathNode | undefined;
281
289
  /**
282
290
  * Returns an equivalent path making as much of it with PathNodes as possible.
283
291
  * This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.
@@ -364,4 +372,153 @@ export declare class AnchorSet implements Listenable<AnchorSetRootEvents>, Ancho
364
372
  */
365
373
  acquireVisitor(): AnnouncedVisitor & DeltaVisitor;
366
374
  }
375
+ /**
376
+ * Indicates the status of a `NodePath`.
377
+ */
378
+ declare enum Status {
379
+ /**
380
+ * Indicates the `NodePath` is being maintained and corresponds to a valid
381
+ * (i.e., not removed) node in the document.
382
+ */
383
+ Alive = 0,
384
+ /**
385
+ * Indicates the `NodePath` is not being maintained by the `AnchorSet`.
386
+ * The `NodePath` may or may not correspond to a valid node in the document.
387
+ *
388
+ * Accessing such a node is invalid.
389
+ * Nodes in this state are retained to detect use-after-free bugs.
390
+ */
391
+ Disposed = 1,
392
+ /**
393
+ * Indicates the `NodePath` corresponds to a removed node in the document.
394
+ * Such `NodePath`s are not maintained by the `AnchorSet` (other than updating
395
+ * their status to `Disposed` when appropriate).
396
+ *
397
+ * Accessing such a node is invalid.
398
+ * Nodes in this state are retained to detect use-after-free bugs.
399
+ */
400
+ Dangling = 2
401
+ }
402
+ /**
403
+ * Tree of anchors.
404
+ *
405
+ * Contains both child and parent pointers, which are kept in sync.
406
+ *
407
+ * Each anchor is equivalent to a path through the tree.
408
+ * This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree
409
+ * prefix-tree style.
410
+ *
411
+ * These anchors are used instead of just holding onto the node objects in forests for several reasons:
412
+ *
413
+ * - Update policy might be more complex than just tracking a node object in the forest.
414
+ *
415
+ * - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.
416
+ *
417
+ * - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the
418
+ * forest.
419
+ *
420
+ * - Forest in general do not need to support up pointers, but they are needed for anchors.
421
+ *
422
+ * Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,
423
+ * plus the parent paths for them.
424
+ *
425
+ * ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).
426
+ * Kept alive as if any of the follow are true:
427
+ * 1. there are children.
428
+ * 2. refcount is non-zero.
429
+ * 3. events are registered.
430
+ */
431
+ declare class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorNode {
432
+ readonly anchorSet: AnchorSet;
433
+ parentField: FieldKey;
434
+ parentIndex: number;
435
+ /**
436
+ * The parent of this `PathNode` (an up pointer in the `PathNode` tree).
437
+ * If the status of this node is `Alive`, then there must be a corresponding down pointer from the
438
+ * `parentPath` node to this node.
439
+ * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.
440
+ *
441
+ * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent
442
+ * (updating down pointers first), but must ensure they are consistent before the editing operation returns
443
+ * to non-`AnchorSet` code.
444
+ * This consistency guarantee only applies to nodes that are `Alive`.
445
+ */
446
+ parentPath: PathNode | undefined;
447
+ status: Status;
448
+ /**
449
+ * Event emitter for this anchor.
450
+ */
451
+ readonly events: Listenable<AnchorEvents> & import("../../events/emitter.js").IEmitter<AnchorEvents> & import("../../events/emitter.js").HasListeners<AnchorEvents>;
452
+ /**
453
+ * PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.
454
+ * Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)
455
+ *
456
+ * Performance Note:
457
+ * Large child lists could be updated more efficiently here using a data-structure optimized
458
+ * for efficient prefix sum updates, such as a Fenwick tree or Finger tree.
459
+ * This would be complicated by the need for parent pointers (including indexes),
460
+ * but is possible to do.
461
+ */
462
+ readonly children: Map<FieldKey, PathNode[]>;
463
+ readonly slots: BrandedMapSubset<AnchorSlot<any>>;
464
+ /**
465
+ * Construct a PathNode with refcount 1.
466
+ * @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet
467
+ * to early out UpPath walking.
468
+ */
469
+ constructor(anchorSet: AnchorSet, parentField: FieldKey, parentIndex: number,
470
+ /**
471
+ * The parent of this `PathNode` (an up pointer in the `PathNode` tree).
472
+ * If the status of this node is `Alive`, then there must be a corresponding down pointer from the
473
+ * `parentPath` node to this node.
474
+ * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.
475
+ *
476
+ * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent
477
+ * (updating down pointers first), but must ensure they are consistent before the editing operation returns
478
+ * to non-`AnchorSet` code.
479
+ * This consistency guarantee only applies to nodes that are `Alive`.
480
+ */
481
+ parentPath: PathNode | undefined);
482
+ on<K extends keyof AnchorEvents>(eventName: K, listener: AnchorEvents[K]): () => void;
483
+ child(key: FieldKey, index: number): UpPath<AnchorNode>;
484
+ getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];
485
+ /**
486
+ * @returns true iff this PathNode is the special root node that sits above all the detached fields.
487
+ * In this case, the fields are detached sequences.
488
+ * Note that the special root node should never appear in an UpPath
489
+ * since UpPaths represent this root as `undefined`.
490
+ */
491
+ private isRoot;
492
+ get parent(): PathNode | undefined;
493
+ addRef(count?: number): void;
494
+ removeRef(count?: number): void;
495
+ protected onUnreferenced(): void;
496
+ /**
497
+ * Gets a child, adding a ref to it.
498
+ * Creates child (with 1 ref) if needed.
499
+ */
500
+ getOrCreateChild(key: FieldKey, index: number): PathNode;
501
+ childIfAnchored(key: FieldKey, index: number): PathNode | undefined;
502
+ /**
503
+ * Removes reference from this to `child`.
504
+ * Since PathNodes are doubly linked,
505
+ * the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).
506
+ */
507
+ removeChild(child: PathNode): void;
508
+ /**
509
+ * Call this after directly editing the child array for a field to be empty.
510
+ * Handles cleaning up unneeded data
511
+ * (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)
512
+ */
513
+ afterEmptyField(key: FieldKey): void;
514
+ /**
515
+ * If node is no longer needed (has no references, no children and no events):
516
+ * removes this from parent if alive, and sets this to disposed.
517
+ * Must only be called when .
518
+ *
519
+ * Allowed when dangling (but not when disposed).
520
+ */
521
+ private considerDispose;
522
+ }
523
+ export {};
367
524
  //# sourceMappingURL=anchorSet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anchorSet.d.ts","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,MAAM,EAKX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,KAAK,EAOX,MAAM,EACN,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAOrD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;CAC/C;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAE7F;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;OAYG;I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