@fluidframework/tree 2.111.0 → 2.112.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 (375) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/api-report/tree.alpha.api.md +48 -5
  3. package/api-report/tree.beta.api.md +1 -1
  4. package/api-report/tree.legacy.beta.api.md +1 -1
  5. package/api-report/tree.legacy.public.api.md +1 -1
  6. package/api-report/tree.public.api.md +1 -1
  7. package/dist/componentApi.d.ts +198 -0
  8. package/dist/componentApi.d.ts.map +1 -0
  9. package/dist/componentApi.js +138 -0
  10. package/dist/componentApi.js.map +1 -0
  11. package/dist/entrypoints/alpha.d.ts +1 -1
  12. package/dist/entrypoints/alpha.d.ts.map +1 -1
  13. package/dist/entrypoints/alpha.js +4 -2
  14. package/dist/entrypoints/alpha.js.map +1 -1
  15. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  16. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  17. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  18. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  19. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  20. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  21. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  22. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  23. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -16
  24. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  25. package/dist/feature-libraries/index.d.ts +2 -2
  26. package/dist/feature-libraries/index.d.ts.map +1 -1
  27. package/dist/feature-libraries/index.js +3 -2
  28. package/dist/feature-libraries/index.js.map +1 -1
  29. package/dist/feature-libraries/modular-schema/index.d.ts +1 -0
  30. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  31. package/dist/feature-libraries/modular-schema/index.js +3 -1
  32. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  33. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  34. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  35. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +29 -0
  36. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  37. package/dist/feature-libraries/schemaChecker.d.ts +22 -3
  38. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  39. package/dist/feature-libraries/schemaChecker.js +48 -5
  40. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  41. package/dist/index.d.ts +2 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +5 -2
  44. package/dist/index.js.map +1 -1
  45. package/dist/packageVersion.d.ts +1 -1
  46. package/dist/packageVersion.js +1 -1
  47. package/dist/packageVersion.js.map +1 -1
  48. package/dist/shared-tree/independentView.d.ts +17 -4
  49. package/dist/shared-tree/independentView.d.ts.map +1 -1
  50. package/dist/shared-tree/independentView.js +11 -5
  51. package/dist/shared-tree/independentView.js.map +1 -1
  52. package/dist/shared-tree/index.d.ts +2 -1
  53. package/dist/shared-tree/index.d.ts.map +1 -1
  54. package/dist/shared-tree/index.js +3 -1
  55. package/dist/shared-tree/index.js.map +1 -1
  56. package/dist/shared-tree/schematizingTreeView.d.ts +1 -0
  57. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  58. package/dist/shared-tree/schematizingTreeView.js +6 -3
  59. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  60. package/dist/shared-tree/serializedChange.d.ts +41 -0
  61. package/dist/shared-tree/serializedChange.d.ts.map +1 -0
  62. package/dist/shared-tree/serializedChange.js +87 -0
  63. package/dist/shared-tree/serializedChange.js.map +1 -0
  64. package/dist/shared-tree/sharedTree.d.ts +13 -0
  65. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  66. package/dist/shared-tree/sharedTree.js +2 -0
  67. package/dist/shared-tree/sharedTree.js.map +1 -1
  68. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  69. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  70. package/dist/shared-tree/sharedTreeChangeFamily.js +8 -1
  71. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  72. package/dist/shared-tree/transactionMinimize.d.ts +35 -0
  73. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -0
  74. package/dist/shared-tree/transactionMinimize.js +65 -0
  75. package/dist/shared-tree/transactionMinimize.js.map +1 -0
  76. package/dist/shared-tree/treeCheckout.d.ts +3 -1
  77. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  78. package/dist/shared-tree/treeCheckout.js +36 -62
  79. package/dist/shared-tree/treeCheckout.js.map +1 -1
  80. package/dist/shared-tree-core/editManager.d.ts +6 -3
  81. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  82. package/dist/shared-tree-core/editManager.js +35 -14
  83. package/dist/shared-tree-core/editManager.js.map +1 -1
  84. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  85. package/dist/shared-tree-core/editManagerFormatCommons.js +1 -1
  86. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  87. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  88. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  89. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  90. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  91. package/dist/shared-tree-core/messageFormat.d.ts +1 -1
  92. package/dist/shared-tree-core/messageFormat.js +1 -1
  93. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  94. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  95. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  96. package/dist/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  97. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  98. package/dist/shared-tree-core/messageTypes.d.ts +1 -0
  99. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  100. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  101. package/dist/shared-tree-core/sharedTreeCore.d.ts +9 -3
  102. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  103. package/dist/shared-tree-core/sharedTreeCore.js +24 -11
  104. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  105. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  106. package/dist/shared-tree-core/transaction.js +16 -2
  107. package/dist/shared-tree-core/transaction.js.map +1 -1
  108. package/dist/simple-tree/api/index.d.ts +1 -1
  109. package/dist/simple-tree/api/index.d.ts.map +1 -1
  110. package/dist/simple-tree/api/index.js +2 -2
  111. package/dist/simple-tree/api/index.js.map +1 -1
  112. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
  113. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  114. package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -44
  115. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  116. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  117. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  118. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  119. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  120. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  121. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  122. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  123. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +1 -2
  124. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  125. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  126. package/dist/simple-tree/api/storedSchema.js +1 -2
  127. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  128. package/dist/simple-tree/api/tree.d.ts +22 -2
  129. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  130. package/dist/simple-tree/api/tree.js.map +1 -1
  131. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -2
  132. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  133. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  134. package/dist/simple-tree/index.d.ts +1 -1
  135. package/dist/simple-tree/index.d.ts.map +1 -1
  136. package/dist/simple-tree/index.js +2 -2
  137. package/dist/simple-tree/index.js.map +1 -1
  138. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  139. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  140. package/dist/simple-tree/node-kinds/array/arrayNode.js +39 -0
  141. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  142. package/dist/simple-tree/simpleSchemaFormatV1.js +1 -1
  143. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  144. package/dist/treeFactory.js +1 -1
  145. package/dist/treeFactory.js.map +1 -1
  146. package/dist/util/breakable.d.ts +16 -1
  147. package/dist/util/breakable.d.ts.map +1 -1
  148. package/dist/util/breakable.js +9 -1
  149. package/dist/util/breakable.js.map +1 -1
  150. package/dist/util/compressedIds.d.ts +69 -2
  151. package/dist/util/compressedIds.d.ts.map +1 -1
  152. package/dist/util/compressedIds.js +32 -1
  153. package/dist/util/compressedIds.js.map +1 -1
  154. package/dist/util/index.d.ts +2 -2
  155. package/dist/util/index.d.ts.map +1 -1
  156. package/dist/util/index.js +2 -2
  157. package/dist/util/index.js.map +1 -1
  158. package/dist/util/nestedMap.d.ts.map +1 -1
  159. package/dist/util/nestedMap.js +16 -3
  160. package/dist/util/nestedMap.js.map +1 -1
  161. package/dist/util/nestedSet.d.ts +1 -1
  162. package/dist/util/nestedSet.d.ts.map +1 -1
  163. package/dist/util/nestedSet.js.map +1 -1
  164. package/dist/util/utils.d.ts +0 -6
  165. package/dist/util/utils.d.ts.map +1 -1
  166. package/dist/util/utils.js +1 -15
  167. package/dist/util/utils.js.map +1 -1
  168. package/lib/componentApi.d.ts +198 -0
  169. package/lib/componentApi.d.ts.map +1 -0
  170. package/lib/componentApi.js +135 -0
  171. package/lib/componentApi.js.map +1 -0
  172. package/lib/entrypoints/alpha.d.ts +1 -1
  173. package/lib/entrypoints/alpha.d.ts.map +1 -1
  174. package/lib/entrypoints/alpha.js +1 -1
  175. package/lib/entrypoints/alpha.js.map +1 -1
  176. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -25
  177. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  178. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -1
  179. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  180. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -2
  181. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  182. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  183. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +6 -18
  184. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  185. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -17
  186. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  187. package/lib/feature-libraries/index.d.ts +2 -2
  188. package/lib/feature-libraries/index.d.ts.map +1 -1
  189. package/lib/feature-libraries/index.js +1 -1
  190. package/lib/feature-libraries/index.js.map +1 -1
  191. package/lib/feature-libraries/modular-schema/index.d.ts +1 -0
  192. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  193. package/lib/feature-libraries/modular-schema/index.js +1 -0
  194. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  195. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +25 -0
  196. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -0
  197. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +25 -0
  198. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -0
  199. package/lib/feature-libraries/schemaChecker.d.ts +22 -3
  200. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  201. package/lib/feature-libraries/schemaChecker.js +48 -5
  202. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  203. package/lib/index.d.ts +2 -1
  204. package/lib/index.d.ts.map +1 -1
  205. package/lib/index.js +2 -1
  206. package/lib/index.js.map +1 -1
  207. package/lib/packageVersion.d.ts +1 -1
  208. package/lib/packageVersion.js +1 -1
  209. package/lib/packageVersion.js.map +1 -1
  210. package/lib/shared-tree/independentView.d.ts +17 -4
  211. package/lib/shared-tree/independentView.d.ts.map +1 -1
  212. package/lib/shared-tree/independentView.js +9 -3
  213. package/lib/shared-tree/independentView.js.map +1 -1
  214. package/lib/shared-tree/index.d.ts +2 -1
  215. package/lib/shared-tree/index.d.ts.map +1 -1
  216. package/lib/shared-tree/index.js +1 -0
  217. package/lib/shared-tree/index.js.map +1 -1
  218. package/lib/shared-tree/schematizingTreeView.d.ts +1 -0
  219. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  220. package/lib/shared-tree/schematizingTreeView.js +7 -4
  221. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  222. package/lib/shared-tree/serializedChange.d.ts +41 -0
  223. package/lib/shared-tree/serializedChange.d.ts.map +1 -0
  224. package/lib/shared-tree/serializedChange.js +84 -0
  225. package/lib/shared-tree/serializedChange.js.map +1 -0
  226. package/lib/shared-tree/sharedTree.d.ts +13 -0
  227. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  228. package/lib/shared-tree/sharedTree.js +2 -0
  229. package/lib/shared-tree/sharedTree.js.map +1 -1
  230. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -0
  231. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  232. package/lib/shared-tree/sharedTreeChangeFamily.js +7 -1
  233. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  234. package/lib/shared-tree/transactionMinimize.d.ts +35 -0
  235. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -0
  236. package/lib/shared-tree/transactionMinimize.js +62 -0
  237. package/lib/shared-tree/transactionMinimize.js.map +1 -0
  238. package/lib/shared-tree/treeCheckout.d.ts +3 -1
  239. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  240. package/lib/shared-tree/treeCheckout.js +18 -44
  241. package/lib/shared-tree/treeCheckout.js.map +1 -1
  242. package/lib/shared-tree-core/editManager.d.ts +6 -3
  243. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  244. package/lib/shared-tree-core/editManager.js +36 -15
  245. package/lib/shared-tree-core/editManager.js.map +1 -1
  246. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -1
  247. package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
  248. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  249. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  250. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  251. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  252. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  253. package/lib/shared-tree-core/messageFormat.d.ts +1 -1
  254. package/lib/shared-tree-core/messageFormat.js +1 -1
  255. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  256. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +10 -1
  257. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  258. package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -0
  259. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  260. package/lib/shared-tree-core/messageTypes.d.ts +1 -0
  261. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  262. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  263. package/lib/shared-tree-core/sharedTreeCore.d.ts +9 -3
  264. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  265. package/lib/shared-tree-core/sharedTreeCore.js +25 -12
  266. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  267. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  268. package/lib/shared-tree-core/transaction.js +16 -2
  269. package/lib/shared-tree-core/transaction.js.map +1 -1
  270. package/lib/simple-tree/api/index.d.ts +1 -1
  271. package/lib/simple-tree/api/index.d.ts.map +1 -1
  272. package/lib/simple-tree/api/index.js +1 -1
  273. package/lib/simple-tree/api/index.js.map +1 -1
  274. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -24
  275. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  276. package/lib/simple-tree/api/schemaCompatibilityTester.js +29 -42
  277. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  278. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +56 -15
  279. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  280. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  281. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +0 -3
  282. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  283. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  284. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  285. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -3
  286. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  287. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  288. package/lib/simple-tree/api/storedSchema.js +2 -3
  289. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  290. package/lib/simple-tree/api/tree.d.ts +22 -2
  291. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  292. package/lib/simple-tree/api/tree.js.map +1 -1
  293. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -2
  294. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  295. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  296. package/lib/simple-tree/index.d.ts +1 -1
  297. package/lib/simple-tree/index.d.ts.map +1 -1
  298. package/lib/simple-tree/index.js +1 -1
  299. package/lib/simple-tree/index.js.map +1 -1
  300. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +83 -4
  301. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  302. package/lib/simple-tree/node-kinds/array/arrayNode.js +39 -0
  303. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  304. package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
  305. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  306. package/lib/treeFactory.js +1 -1
  307. package/lib/treeFactory.js.map +1 -1
  308. package/lib/util/breakable.d.ts +16 -1
  309. package/lib/util/breakable.d.ts.map +1 -1
  310. package/lib/util/breakable.js +9 -1
  311. package/lib/util/breakable.js.map +1 -1
  312. package/lib/util/compressedIds.d.ts +69 -2
  313. package/lib/util/compressedIds.d.ts.map +1 -1
  314. package/lib/util/compressedIds.js +30 -0
  315. package/lib/util/compressedIds.js.map +1 -1
  316. package/lib/util/index.d.ts +2 -2
  317. package/lib/util/index.d.ts.map +1 -1
  318. package/lib/util/index.js +2 -2
  319. package/lib/util/index.js.map +1 -1
  320. package/lib/util/nestedMap.d.ts.map +1 -1
  321. package/lib/util/nestedMap.js +17 -4
  322. package/lib/util/nestedMap.js.map +1 -1
  323. package/lib/util/nestedSet.d.ts +1 -1
  324. package/lib/util/nestedSet.d.ts.map +1 -1
  325. package/lib/util/nestedSet.js.map +1 -1
  326. package/lib/util/utils.d.ts +0 -6
  327. package/lib/util/utils.d.ts.map +1 -1
  328. package/lib/util/utils.js +0 -13
  329. package/lib/util/utils.js.map +1 -1
  330. package/package.json +22 -22
  331. package/src/componentApi.ts +354 -0
  332. package/src/entrypoints/alpha.ts +3 -0
  333. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -27
  334. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -2
  335. package/src/feature-libraries/chunked-forest/codec/codecs.ts +17 -44
  336. package/src/feature-libraries/index.ts +2 -0
  337. package/src/feature-libraries/modular-schema/index.ts +1 -0
  338. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +33 -0
  339. package/src/feature-libraries/schemaChecker.ts +86 -9
  340. package/src/index.ts +3 -0
  341. package/src/packageVersion.ts +1 -1
  342. package/src/shared-tree/independentView.ts +35 -5
  343. package/src/shared-tree/index.ts +3 -0
  344. package/src/shared-tree/schematizingTreeView.ts +15 -5
  345. package/src/shared-tree/serializedChange.ts +127 -0
  346. package/src/shared-tree/sharedTree.ts +16 -0
  347. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  348. package/src/shared-tree/transactionMinimize.ts +74 -0
  349. package/src/shared-tree/treeCheckout.ts +42 -57
  350. package/src/shared-tree-core/editManager.ts +42 -6
  351. package/src/shared-tree-core/editManagerFormatCommons.ts +1 -1
  352. package/src/shared-tree-core/messageCodecVSharedBranches.ts +8 -1
  353. package/src/shared-tree-core/messageFormat.ts +1 -1
  354. package/src/shared-tree-core/messageFormatVSharedBranches.ts +10 -0
  355. package/src/shared-tree-core/messageTypes.ts +1 -0
  356. package/src/shared-tree-core/sharedTreeCore.ts +33 -10
  357. package/src/shared-tree-core/transaction.ts +19 -2
  358. package/src/simple-tree/api/index.ts +1 -1
  359. package/src/simple-tree/api/schemaCompatibilityTester.ts +36 -48
  360. package/src/simple-tree/api/schemaFactoryAlpha.ts +56 -15
  361. package/src/simple-tree/api/schemaFactoryBeta.ts +0 -3
  362. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +2 -3
  363. package/src/simple-tree/api/storedSchema.ts +2 -3
  364. package/src/simple-tree/api/tree.ts +24 -2
  365. package/src/simple-tree/api/typesUnsafe.ts +2 -1
  366. package/src/simple-tree/index.ts +1 -1
  367. package/src/simple-tree/node-kinds/array/arrayNode.ts +168 -4
  368. package/src/simple-tree/simpleSchemaFormatV1.ts +1 -1
  369. package/src/treeFactory.ts +1 -1
  370. package/src/util/breakable.ts +8 -1
  371. package/src/util/compressedIds.ts +90 -2
  372. package/src/util/index.ts +3 -1
  373. package/src/util/nestedMap.ts +21 -4
  374. package/src/util/nestedSet.ts +1 -1
  375. package/src/util/utils.ts +0 -18
@@ -109,6 +109,14 @@ export interface TreeArrayNode<
109
109
  > extends ReadonlyArrayNode<T> {
110
110
  /**
111
111
  * Inserts new item(s) at a specified location.
112
+ *
113
+ * @remarks
114
+ * All items inserted by a single call to this method are inserted consecutively.
115
+ * The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified:
116
+ * Concurrently inserting `[A, B]` and `[X, Y]` at the same location may yield
117
+ * either `[A, B, X, Y]` or `[X, Y, A, B]`, regardless of the order in which those edits are sequenced.
118
+ * No other interleavings are possible. (e.g. `[A, X, B, Y]` is not possible.)
119
+ *
112
120
  * @param index - The index at which to insert `value`.
113
121
  * @param value - The content to insert.
114
122
  * @throws Throws if `index` is not in the range [0, `array.length`).
@@ -117,12 +125,18 @@ export interface TreeArrayNode<
117
125
 
118
126
  /**
119
127
  * Inserts new item(s) at the start of the array.
128
+ * @remarks
129
+ * Equivalent to `insertAt(0, ...value)`:
130
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
120
131
  * @param value - The content to insert.
121
132
  */
122
133
  insertAtStart(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
123
134
 
124
135
  /**
125
136
  * Inserts new item(s) at the end of the array.
137
+ * @remarks
138
+ * Equivalent to `insertAt(array.length, ...value)`:
139
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
126
140
  * @param value - The content to insert.
127
141
  */
128
142
  insertAtEnd(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
@@ -131,10 +145,10 @@ export interface TreeArrayNode<
131
145
  * Inserts new item(s) at the end of the array.
132
146
  *
133
147
  * @remarks
134
- * The order of the inserted items relative to other concurrently inserted items at the same location is only partially specified:
135
- * Concurrently inserting `[A, B]` and `[X, Y]` at the same location may yield
136
- * either `[A, B, X, Y]` or `[X, Y, A, B]`, regardless of the order in which those edits are sequenced.
137
- * No other interleavings are possible. (e.g. `[A, X, B, Y]` is not possible.)
148
+ * Unlike `Array.prototype.push`, this method does not return the new length of the array.
149
+ *
150
+ * Equivalent to `insertAt(array.length, ...value)`:
151
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
138
152
  *
139
153
  * @param value - The content to insert.
140
154
  */
@@ -460,6 +474,87 @@ export interface TreeArrayNodeAlpha<
460
474
  ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
461
475
  : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>,
462
476
  > extends TreeArrayNode<TAllowedTypes, T, TNew> {
477
+ /**
478
+ * Returns the item located at the specified index.
479
+ * @param index - The zero-based index of the item to retrieve.
480
+ * Negative indices count back from the last item in the array: for `index < 0`, `index + array.length` is used.
481
+ * @returns The item at the specified index, or `undefined` if the index is out of bounds.
482
+ */
483
+ at(index: number): T | undefined;
484
+
485
+ /**
486
+ * Returns the last item in the array for which the given type guard returns `true`,
487
+ * searching from the last item to the first.
488
+ * @remarks
489
+ * The array's length is captured when the search begins; items are read live as the search progresses.
490
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
491
+ * @typeParam S - The subtype of `T` asserted by the `predicate` type guard.
492
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns `true`.
493
+ * Receives the item, its index, and the array being searched.
494
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
495
+ * @returns The last item for which `predicate` returns `true` (narrowed to the guarded type), or `undefined` if there is no such item.
496
+ */
497
+ findLast<S extends T>(
498
+ predicate: (value: T, index: number, array: readonly T[]) => value is S,
499
+ thisArg?: unknown,
500
+ ): S | undefined;
501
+
502
+ /**
503
+ * Returns the last item in the array for which the given predicate returns a truthy value,
504
+ * searching from the last item to the first.
505
+ * @remarks
506
+ * The array's length is captured when the search begins; items are read live as the search progresses.
507
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.prototype.findLast}.
508
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
509
+ * Receives the item, its index, and the array being searched.
510
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
511
+ * @returns The last item for which `predicate` returns a truthy value, or `undefined` if there is no such item.
512
+ */
513
+ findLast(
514
+ predicate: (value: T, index: number, array: readonly T[]) => unknown,
515
+ thisArg?: unknown,
516
+ ): T | undefined;
517
+
518
+ /**
519
+ * Returns the index of the last item in the array for which the given predicate returns a truthy value,
520
+ * searching from the last item to the first.
521
+ * @remarks
522
+ * The array's length is captured when the search begins; items are read live as the search progresses.
523
+ * If `predicate` edits the array, behavior matches {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.prototype.findLastIndex}.
524
+ * @param predicate - Evaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value.
525
+ * Receives the item, its index, and the array being searched.
526
+ * @param thisArg - If provided, used as `this` when invoking `predicate`.
527
+ * @returns The index of the last item for which `predicate` returns a truthy value, or `-1` if there is no such item.
528
+ */
529
+ findLastIndex(
530
+ predicate: (value: T, index: number, array: readonly T[]) => unknown,
531
+ thisArg?: unknown,
532
+ ): number;
533
+
534
+ /**
535
+ * Removes the last item from the array and returns it.
536
+ * @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
537
+ */
538
+ pop(): T | undefined;
539
+
540
+ /**
541
+ * Removes the first item from the array and returns it.
542
+ * @returns The removed item, or `undefined` if the array is empty (in which case the array is not modified).
543
+ */
544
+ shift(): T | undefined;
545
+
546
+ /**
547
+ * Inserts new item(s) at the start of the array.
548
+ *
549
+ * @param value - The content to insert.
550
+ * @remarks
551
+ * Unlike `Array.prototype.unshift`, this method does not return the new length of the array.
552
+ *
553
+ * Equivalent to `insertAt(0, ...value)`:
554
+ * see {@link (TreeArrayNode:interface).insertAt} for details, including merge semantics with concurrent edits.
555
+ */
556
+ unshift(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;
557
+
463
558
  /**
464
559
  * Removes existing item(s) and/or adds new item(s).
465
560
  * @param start - The index at which to start changing the array. If negative, it is treated as `array.length + start`.
@@ -995,6 +1090,58 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
995
1090
 
996
1091
  return getOrCreateNodeFromInnerNode(val) as TreeNodeFromImplicitAllowedTypes<T>;
997
1092
  }
1093
+ public findLast<S extends TreeNodeFromImplicitAllowedTypes<T>>(
1094
+ predicate: (
1095
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1096
+ index: number,
1097
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1098
+ ) => value is S,
1099
+ thisArg?: unknown,
1100
+ ): S | undefined;
1101
+ public findLast(
1102
+ predicate: (
1103
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1104
+ index: number,
1105
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1106
+ ) => unknown,
1107
+ thisArg?: unknown,
1108
+ ): TreeNodeFromImplicitAllowedTypes<T> | undefined;
1109
+ public findLast(
1110
+ predicate: (
1111
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1112
+ index: number,
1113
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1114
+ ) => unknown,
1115
+ thisArg?: unknown,
1116
+ ): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1117
+ const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
1118
+ for (let index = this.length - 1; index >= 0; index--) {
1119
+ const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
1120
+ const matched = Boolean(predicate.call(thisArg, value, index, array));
1121
+ if (matched) {
1122
+ return value;
1123
+ }
1124
+ }
1125
+ return undefined;
1126
+ }
1127
+ public findLastIndex(
1128
+ predicate: (
1129
+ value: TreeNodeFromImplicitAllowedTypes<T>,
1130
+ index: number,
1131
+ array: readonly TreeNodeFromImplicitAllowedTypes<T>[],
1132
+ ) => unknown,
1133
+ thisArg?: unknown,
1134
+ ): number {
1135
+ const array = this as readonly TreeNodeFromImplicitAllowedTypes<T>[];
1136
+ for (let index = this.length - 1; index >= 0; index--) {
1137
+ const value = this.at(index) as TreeNodeFromImplicitAllowedTypes<T>;
1138
+ const matched = Boolean(predicate.call(thisArg, value, index, array));
1139
+ if (matched) {
1140
+ return index;
1141
+ }
1142
+ }
1143
+ return -1;
1144
+ }
998
1145
  public insertAt(index: number, ...value: Insertable<T>): void {
999
1146
  const field = getSequenceField(this);
1000
1147
  validateIndex(index, field, "TreeArrayNode.insertAt", true);
@@ -1010,6 +1157,23 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
1010
1157
  public push(...value: Insertable<T>): void {
1011
1158
  this.insertAt(this.length, ...value);
1012
1159
  }
1160
+ public unshift(...value: Insertable<T>): void {
1161
+ this.insertAt(0, ...value);
1162
+ }
1163
+ public pop(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1164
+ const value = this.at(-1);
1165
+ if (value !== undefined) {
1166
+ this.removeAt(this.length - 1);
1167
+ }
1168
+ return value;
1169
+ }
1170
+ public shift(): TreeNodeFromImplicitAllowedTypes<T> | undefined {
1171
+ const value = this.at(0);
1172
+ if (value !== undefined) {
1173
+ this.removeAt(0);
1174
+ }
1175
+ return value;
1176
+ }
1013
1177
  public removeAt(index: number): void {
1014
1178
  const field = getSequenceField(this);
1015
1179
  validateIndex(index, field, "TreeArrayNode.removeAt");
@@ -7,7 +7,7 @@
7
7
  * This file contains a format for serializing the compatibility impacting subset of simple schema.
8
8
 
9
9
  * This format can be used for both view and stored simple schema.
10
- * This only includes all parts of the schema that impact compatibility according to SchemaCompatibilityTester.
10
+ * This only includes all parts of the schema that impact compatibility according to {@link checkSchemaCompatibility}.
11
11
  * It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).
12
12
  */
13
13
 
@@ -77,7 +77,7 @@ function treeKernelFactory(
77
77
  };
78
78
 
79
79
  return new SharedTreeKernel(
80
- new Breakable("SharedTree"),
80
+ new Breakable("SharedTree", args.logger),
81
81
  args.sharedObject,
82
82
  args.serializer,
83
83
  args.submitLocalMessage,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
+ import { UsageError, type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
8
8
 
9
9
  /**
10
10
  * An object which can enter a "broken" state where trying to use it is a UsageError.
@@ -22,6 +22,13 @@ export class Breakable {
22
22
  * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.
23
23
  */
24
24
  private readonly name: string,
25
+ /**
26
+ * Optional logger for telemetry.
27
+ * @remarks
28
+ * When provided, subsystems that have access to a Breakable can use this logger to emit telemetry
29
+ * without requiring additional plumbing.
30
+ */
31
+ public readonly logger?: TelemetryLoggerExt,
25
32
  ) {}
26
33
 
27
34
  /**
@@ -152,9 +152,10 @@ export function tryDecodeEncodedIdWithoutSession(
152
152
  * the user-facing {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}
153
153
  * option — see that option for the user-facing rationale and trade-offs.
154
154
  *
155
- * Carried by decode-side contexts (`ChangeEncodingContext.healing`,
155
+ * Carried by decode-side contexts ({@link IdDecoderOptionsOriginatorless},
156
+ * `ChangeEncodingContext.healing`,
156
157
  * `EditManagerEncodingContext.healing`, etc.) when the workaround is enabled.
157
- * Presence enables healing; `undefined` opts out. There is no separate boolean,
158
+ * Presence enables healing; `undefined` means healing is disabled. There is no separate boolean,
158
159
  * which makes it impossible to enable healing without supplying the namespace
159
160
  * input.
160
161
  */
@@ -214,3 +215,90 @@ export function decompressIdentifierIfNeeded(
214
215
  return decompressed;
215
216
  }
216
217
  }
218
+
219
+ /**
220
+ * Options for creating an {@link IdDecodingContext} without an originator.
221
+ * @remarks
222
+ * Decodes {@link OriginatorlessEncodedId} instances, and optionally has a {@link IdentifierHealingConfig} fallback for {@link OriginatorDependentEncodedId} instances.
223
+ */
224
+ export interface IdDecoderOptionsOriginatorless {
225
+ readonly idCompressor: IIdCompressor;
226
+ /**
227
+ * Optional {@link IdentifierHealingConfig} to use for healing unresolvable identifiers.
228
+ * @privateRemarks
229
+ * This is a required field which can be undefined to make it explicit when this is not provided.
230
+ * This explicitness helps ensure we we don't accidentally drop the healing config as that would break
231
+ * an edge case which does not get a lot of testing.
232
+ */
233
+ readonly healing: IdentifierHealingConfig | undefined;
234
+ }
235
+
236
+ /**
237
+ * Options for creating an {@link IdDecodingContext} with an originator.
238
+ * @remarks
239
+ * Decodes {@link OriginatorDependentEncodedId} instances.
240
+ */
241
+ export interface IdDecoderOptionsWithOriginator {
242
+ readonly idCompressor: IIdCompressor;
243
+ /**
244
+ * The ID of the session that encoded the ids.
245
+ */
246
+ readonly originatorId: SessionId;
247
+ }
248
+
249
+ /**
250
+ * Context for decoding identifiers.
251
+ * @remarks
252
+ * Depended on how this is constructed, it may or may not handle {@link OriginatorDependentEncodedId} instances.
253
+ *
254
+ * This intentionally avoids exposing anything which depends on the underlying id-compressor's session ID to avoid confusion with the session ID of the compressor which encoded the data.
255
+ * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.
256
+ *
257
+ * @privateRemarks
258
+ * We have code (FieldBatchDecodingContext) which sometimes has a session ID and sometimes doesn't, so we need a flexible decoding context.
259
+ * Additionally, since this is about serialized data, having stronger types is often counterproductive, as it just relies more on type casts when parsing.
260
+ * This is why we use this flexible pattern rather than code strongly typed over which kind of encoded ids are expected.
261
+ */
262
+ export class IdDecodingContext {
263
+ /**
264
+ * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
265
+ */
266
+ protected readonly hasOriginatorSessionId: boolean;
267
+
268
+ /**
269
+ * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.
270
+ */
271
+ public readonly idCompressor: Pick<IIdCompressor, "decompress">;
272
+
273
+ /**
274
+ * Resolves an encoded op-space identifier to either a session-space ID
275
+ * (which {@link idCompressor} can decompress if needed)
276
+ * or a string (which passes through unchanged).
277
+ * @remarks
278
+ * In contexts where non-final identifiers can't be supported (where no originator session is available),
279
+ * if a non-final identifier is encountered, this may throw or perform a data healing workaround.
280
+ * See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.
281
+ */
282
+ public readonly resolveEncodedId: (
283
+ id: OpSpaceCompressedId,
284
+ ) => SessionSpaceCompressedId | string;
285
+
286
+ /**
287
+ * Creates a new instance of the context.
288
+ * @param options - The options for creating the context.
289
+ */
290
+ public constructor(
291
+ options: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator,
292
+ ) {
293
+ this.idCompressor = options.idCompressor;
294
+ if ("originatorId" in options) {
295
+ this.hasOriginatorSessionId = true;
296
+ this.resolveEncodedId = (id): SessionSpaceCompressedId | string =>
297
+ options.idCompressor.normalizeToSessionSpace(id, options.originatorId);
298
+ } else {
299
+ this.hasOriginatorSessionId = false;
300
+ this.resolveEncodedId = (id): SessionSpaceCompressedId | string =>
301
+ forceDecodeEncodedIdWithoutSession(id, options.idCompressor, options.healing);
302
+ }
303
+ }
304
+ }
package/src/util/index.ts CHANGED
@@ -106,7 +106,6 @@ export {
106
106
  hasSingle,
107
107
  defineLazyCachedProperty,
108
108
  copyPropertyIfDefined as copyProperty,
109
- getOrAddInMap,
110
109
  iterableHasSome,
111
110
  } from "./utils.js";
112
111
  export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
@@ -179,4 +178,7 @@ export {
179
178
  tryDecodeEncodedIdWithoutSession,
180
179
  forceDecodeEncodedIdWithoutSession,
181
180
  decompressIdentifierIfNeeded,
181
+ IdDecodingContext,
182
+ type IdDecoderOptionsOriginatorless,
183
+ type IdDecoderOptionsWithOriginator,
182
184
  } from "./compressedIds.js";
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { oob } from "@fluidframework/core-utils/internal";
7
7
 
8
- import { getOrAddInMap, getOrCreate } from "./utils.js";
8
+ import { getOrCreate } from "./utils.js";
9
9
 
10
10
  /**
11
11
  * A dictionary whose values are keyed off of two objects (key1, key2).
@@ -72,6 +72,23 @@ export function populateNestedMap<Key1, Key2, Value>(
72
72
  }
73
73
  }
74
74
 
75
+ /**
76
+ * Sets the value at `key` in map to new Map if not already present.
77
+ * Returns the value at `key` after setting it.
78
+ */
79
+ function getOrAddInMap<Key1, Key2, Value>(
80
+ map: NestedMap<Key1, Key2, Value>,
81
+ key1: Key1,
82
+ ): Map<Key2, Value> {
83
+ const currentValue = map.get(key1);
84
+ if (currentValue !== undefined) {
85
+ return currentValue;
86
+ }
87
+ const value = new Map<Key2, Value>();
88
+ map.set(key1, value);
89
+ return value;
90
+ }
91
+
75
92
  /**
76
93
  * Sets the value at (key1, key2) in map to value.
77
94
  * If there already is a value for (key1, key2), it is replaced with the provided one.
@@ -82,7 +99,7 @@ export function setInNestedMap<Key1, Key2, Value>(
82
99
  key2: Key2,
83
100
  value: Value,
84
101
  ): void {
85
- const innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());
102
+ const innerMap = getOrAddInMap(map, key1);
86
103
  innerMap.set(key2, value);
87
104
  }
88
105
 
@@ -95,7 +112,7 @@ export function getOrCreateInNestedMap<Key1, Key2, Value>(
95
112
  key2: Key2,
96
113
  defaultValue: (key1: Key1, key2: Key2) => Value,
97
114
  ): Value {
98
- const innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());
115
+ const innerMap = getOrAddInMap(map, key1);
99
116
  return getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));
100
117
  }
101
118
 
@@ -193,7 +210,7 @@ export function nestedMapFromFlatList<Key1, Key2, Value>(
193
210
  ): NestedMap<Key1, Key2, Value> {
194
211
  const map = new Map<Key1, Map<Key2, Value>>();
195
212
  for (const [key1, key2, val] of list) {
196
- getOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);
213
+ getOrAddInMap(map, key1).set(key2, val);
197
214
  }
198
215
  return map;
199
216
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from "./nestedMap.js";
7
7
 
8
- export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, boolean>;
8
+ export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, true>;
9
9
 
10
10
  export function addToNestedSet<Key1, Key2>(
11
11
  set: NestedSet<Key1, Key2>,
package/src/util/utils.ts CHANGED
@@ -192,24 +192,6 @@ export function compareSets<T>({
192
192
  return true;
193
193
  }
194
194
 
195
- /**
196
- * Sets the value at `key` in map to value if not already present.
197
- * Returns the value at `key` after setting it.
198
- * This is equivalent to a get or default that adds the default to the map.
199
- */
200
- export function getOrAddInMap<Key, Value>(
201
- map: MapGetSet<Key, Value>,
202
- key: Key,
203
- value: Value,
204
- ): Value {
205
- const currentValue = map.get(key);
206
- if (currentValue !== undefined) {
207
- return currentValue;
208
- }
209
- map.set(key, value);
210
- return value;
211
- }
212
-
213
195
  /**
214
196
  * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
215
197
  * @param map - The map to query/update