@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
@@ -20,8 +20,16 @@ class Breakable {
20
20
  * @remarks
21
21
  * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.
22
22
  */
23
- name) {
23
+ name,
24
+ /**
25
+ * Optional logger for telemetry.
26
+ * @remarks
27
+ * When provided, subsystems that have access to a Breakable can use this logger to emit telemetry
28
+ * without requiring additional plumbing.
29
+ */
30
+ logger) {
24
31
  this.name = name;
32
+ this.logger = logger;
25
33
  }
26
34
  /**
27
35
  * Throws if this object is in the broken state.
@@ -1 +1 @@
1
- {"version":3,"file":"breakable.js","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE;;;;;GAKG;AACH,MAAa,SAAS;IAGrB;IACC;;;;OAIG;IACc,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAC3B,CAAC;IAEJ;;;;OAIG;IACI,GAAG,CACT,UAAuC,CAAC,QAAQ,EAAE,EAAE,CACnD,kBAAkB,IAAI,CAAC,IAAI,+EAA+E,QAAQ,EAAE;QAErH,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,IAAI,qBAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErD,+GA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AAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAC3B,CAAC;oBACF,gKAAgK;oBAChK,MAAM,MAAM,GAAG,UAAU,CAAC,KAAwC,CAAC;oBACnE,UAAU,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;oBAC1C,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;gBACtE,CAAC;YACF,CAAC;QACF,CAAC;QACD,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC3B,CAAC;AApCD,sCAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * An object which can enter a \"broken\" state where trying to use it is a UsageError.\n * @remarks\n * Use {@link WithBreakable} to apply this to another object.\n * @sealed\n */\nexport class Breakable {\n\tprivate brokenBy?: Error;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A name for a given breakable scope.\n\t\t * @remarks\n\t\t * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.\n\t\t */\n\t\tprivate readonly name: string,\n\t) {}\n\n\t/**\n\t * Throws if this object is in the broken state.\n\t * @remarks\n\t * Can use {@link throwIfBroken} to apply this to a method.\n\t */\n\tpublic use(\n\t\tmessage: (brokenBy: Error) => string = (brokenBy) =>\n\t\t\t`Invalid use of ${this.name} after it was put into an invalid state by another error.\\nOriginal Error:\\n${brokenBy}`,\n\t): void {\n\t\tif (this.brokenBy !== undefined) {\n\t\t\tconst error = new UsageError(message(this.brokenBy));\n\n\t\t\t// This \"cause\" field is added in ES2022, but using it even without that built in support, it is still helpful.\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause\n\t\t\t// TODO: remove this cast when targeting ES2022 lib or later.\n\t\t\t(error as { cause?: unknown }).cause =\n\t\t\t\t(this.brokenBy as { cause?: unknown }).cause ?? this.brokenBy;\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Puts this object into the broken state, and throws an error.\n\t *\n\t * @throws If already broken by a different error, throws a UsageError, otherwise throws `brokenBy`.\n\t */\n\tpublic break(brokenBy: Error): never {\n\t\t// If already broken by this error, let it bubble up without rethrowing a modified version.\n\t\t// This prevents internal errors like asserts getting rethrown as different errors when wrapped with multiple call to `{@link Breakable.run}` or `{@link breakingMethod}`.\n\t\tif (this.brokenBy !== brokenBy) {\n\t\t\tthis.use();\n\t\t\tthis.brokenBy = brokenBy;\n\t\t}\n\t\tthrow brokenBy;\n\t}\n\n\t/**\n\t * {@link Breakable.break}, except tolerates `unknown` to be more easily used by catch blocks.\n\t * @privateRemarks\n\t * If there is a use-case, this should be made public.\n\t */\n\tprivate rethrowCaught(brokenBy: unknown): never {\n\t\tif (brokenBy instanceof Error) {\n\t\t\tthis.break(brokenBy);\n\t\t}\n\t\tthis.break(\n\t\t\tnew Error(`Non-error thrown breaking ${this.name}. Thrown value: \"${brokenBy}\"`),\n\t\t);\n\t}\n\n\t/**\n\t * Runs code which should break the object if it throws.\n\t * @remarks\n\t * Like {@link Breakable.use}, this also throws if already broken.\n\t * Any exceptions this catches are re-thrown.\n\t * Can use {@link breakingMethod} to apply this to a method.\n\t *\n\t * If `breaker` returns a Promise, the breakable is also broken if that Promise rejects, and the broken state is rechecked when it resolves:\n\t * if the breakable was put into a broken state during the async operation (by some other code path), the resolved value is discarded and the returned Promise rejects with a {@link UsageError}.\n\t *\n\t * This does not serialize concurrent runs: a synchronous run invoked while an async run is in flight will execute immediately, and is only blocked if the breakable is already broken.\n\t * Detection of an async result uses `instanceof Promise`, so custom Promise-like objects and Promises from other realms will be treated as synchronous results.\n\t */\n\tpublic run<TResult>(breaker: () => TResult): TResult {\n\t\tthis.use();\n\t\ttry {\n\t\t\tconst result = breaker();\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\t(value: Awaited<TResult>) => {\n\t\t\t\t\t\t// If broken while process was running: this will throw instead of returning the value.\n\t\t\t\t\t\tthis.use(\n\t\t\t\t\t\t\t(brokenBy) =>\n\t\t\t\t\t\t\t\t`${this.name} was put into a broken state during an async operation.\\nOriginal Error:\\n${brokenBy}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => this.rethrowCaught(error),\n\t\t\t\t) as TResult;\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error: unknown) {\n\t\t\tthis.rethrowCaught(error);\n\t\t}\n\t}\n\n\t/**\n\t * Clears the existing broken state.\n\t * @remarks\n\t * This is rarely safe to to: it is only ok when all objects using this breaker are known to not have been left in an invalid state.\n\t * This is pretty much only safe in tests which just were checking a specific error was thrown, and which know that error closepath is actually exception safe.\n\t */\n\tpublic clearError(): void {\n\t\tassert(this.brokenBy !== undefined, 0x9b6 /* No error to clear */);\n\t\tthis.brokenBy = undefined;\n\t}\n}\n\n/**\n * Marks an object as being able to be in a broken state (unknown/unspecified/broken state due to unhandled exception).\n * @remarks\n * See decorators {@link breakingMethod} and {@link throwIfBroken} for ease of use.\n */\nexport interface WithBreakable {\n\t/**\n\t * The breaker for this object.\n\t * @remarks\n\t * If this `breaker` is in the broken state, the `WithBreakable` should be considered in a broken state.\n\t */\n\treadonly breaker: Breakable;\n}\n\n/**\n * Decorator for methods which should break the object when they throw.\n * @remarks\n * This also throws if already broken like {@link throwIfBroken}.\n * See {@link Breakable.run} for details.\n *\n * This should be used on methods which modify data that could result in an unsupported/broken state if an exception is thrown while modifying.\n * It is ok for breakingMethods to call each-other.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function breakingMethod<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context?: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tif (this.breaker === undefined) {\n\t\t\t// This case is necessary for when wrapping methods which are invoked inside the constructor of the base class before `breaker` is set.\n\t\t\t// Since the constructor throwing does not return an object, failing to put it into a broken state is not too bad.\n\t\t\t// However when more than just the constructed object should be broken, this can result in missing a break.\n\t\t\treturn target.call(this, ...args);\n\t\t}\n\t\treturn this.breaker.run(() => {\n\t\t\treturn target.call(this, ...args);\n\t\t});\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n/**\n * Decorator for methods which should throw if the object is in a broken state.\n * @remarks\n * This should be used on methods which read data that could be invalid when the object is broken.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function throwIfBroken<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tthis.breaker.use();\n\t\treturn target.call(this, ...args);\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype PossiblyNamedFunction = Function & { displayName?: undefined | string };\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction nameFunctionFrom(toName: Function, nameFrom: Function): void {\n\t(toName as PossiblyNamedFunction).displayName =\n\t\t(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;\n}\n\nconst isBreakerSymbol: unique symbol = Symbol(\"isBreaker\");\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction markBreaker(f: Function): void {\n\t(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;\n}\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isBreaker(f: Function): boolean {\n\treturn isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);\n}\n\n/**\n * Decorator for classes which should break when their methods throw.\n * @remarks\n * Applies {@link breakingMethod} to all methods declared directly by class or its base classes.\n * Does not include those on derived classes.\n * Does not include getters or setters, or value properties.\n * Methods already marked as {@link breakingMethod} or {@link throwIfBroken} are unaffected.\n */\nexport function breakingClass<Target extends abstract new (...args: any[]) => WithBreakable>(\n\ttarget: Target,\n\tcontext: ClassDecoratorContext<Target>,\n): Target {\n\t// This could extend target, but doing so adds an extra step in the prototype chain and makes the instances just show up as \"DecoratedBreakable\" in the debugger.\n\tconst DecoratedBreakable = target;\n\n\t// Keep track of what keys we have seen (and already wrapped if needed).\n\t// Used to avoid rewrapping already wrapped properties.\n\t// Preloaded with \"constructor\" to avoid wrapping the constructor as there is no need to set the broken flag when the constructor throws and does not return an object.\n\t// Avoiding wrapping the constructor also avoids messing up the displayed name in the debugger.\n\tconst doNotWrap: Set<string | symbol> = new Set([\"constructor\"]);\n\n\tlet prototype: object | null = target.prototype as object;\n\twhile (prototype !== null) {\n\t\tfor (const key of Reflect.ownKeys(prototype)) {\n\t\t\tif (!doNotWrap.has(key)) {\n\t\t\t\tdoNotWrap.add(key);\n\t\t\t\tconst descriptor = Reflect.getOwnPropertyDescriptor(prototype, key);\n\t\t\t\t// Method\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\ttypeof descriptor.value === \"function\" &&\n\t\t\t\t\t!isBreaker(descriptor.value)\n\t\t\t\t) {\n\t\t\t\t\t// This does not affect the original class, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\n\t\t\t\t\tconst method = descriptor.value as (...args: unknown[]) => unknown;\n\t\t\t\t\tdescriptor.value = breakingMethod(method);\n\t\t\t\t\tObject.defineProperty(DecoratedBreakable.prototype, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprototype = Reflect.getPrototypeOf(prototype);\n\t}\n\n\treturn DecoratedBreakable;\n}\n"]}
1
+ {"version":3,"file":"breakable.js","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAA+F;AAE/F;;;;;GAKG;AACH,MAAa,SAAS;IAGrB;IACC;;;;OAIG;IACc,IAAY;IAC7B;;;;;OAKG;IACa,MAA2B;QAP1B,SAAI,GAAJ,IAAI,CAAQ;QAOb,WAAM,GAAN,MAAM,CAAqB;IACzC,CAAC;IAEJ;;;;OAIG;IACI,GAAG,CACT,UAAuC,CAAC,QAAQ,EAAE,EAAE,CACnD,kBAAkB,IAAI,CAAC,IAAI,+EAA+E,QAAQ,EAAE;QAErH,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,IAAI,qBAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErD,+GAA+G;YAC/G,mGAAmG;YACnG,6DAA6D;YAC5D,KAA6B,CAAC,KAAK;gBAClC,IAAI,CAAC,QAAgC,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC;YAE/D,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,QAAe;QAC3B,2FAA2F;QAC3F,0KAA0K;QAC1K,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,CAAC;QACD,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CAAC;AApCD,sCAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError, type TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * An object which can enter a \"broken\" state where trying to use it is a UsageError.\n * @remarks\n * Use {@link WithBreakable} to apply this to another object.\n * @sealed\n */\nexport class Breakable {\n\tprivate brokenBy?: Error;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A name for a given breakable scope.\n\t\t * @remarks\n\t\t * This is useful for documenting the semantics of a given Breakable and when inspecting things in the debugger, but is currently otherwise unused.\n\t\t */\n\t\tprivate readonly name: string,\n\t\t/**\n\t\t * Optional logger for telemetry.\n\t\t * @remarks\n\t\t * When provided, subsystems that have access to a Breakable can use this logger to emit telemetry\n\t\t * without requiring additional plumbing.\n\t\t */\n\t\tpublic readonly logger?: TelemetryLoggerExt,\n\t) {}\n\n\t/**\n\t * Throws if this object is in the broken state.\n\t * @remarks\n\t * Can use {@link throwIfBroken} to apply this to a method.\n\t */\n\tpublic use(\n\t\tmessage: (brokenBy: Error) => string = (brokenBy) =>\n\t\t\t`Invalid use of ${this.name} after it was put into an invalid state by another error.\\nOriginal Error:\\n${brokenBy}`,\n\t): void {\n\t\tif (this.brokenBy !== undefined) {\n\t\t\tconst error = new UsageError(message(this.brokenBy));\n\n\t\t\t// This \"cause\" field is added in ES2022, but using it even without that built in support, it is still helpful.\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause\n\t\t\t// TODO: remove this cast when targeting ES2022 lib or later.\n\t\t\t(error as { cause?: unknown }).cause =\n\t\t\t\t(this.brokenBy as { cause?: unknown }).cause ?? this.brokenBy;\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Puts this object into the broken state, and throws an error.\n\t *\n\t * @throws If already broken by a different error, throws a UsageError, otherwise throws `brokenBy`.\n\t */\n\tpublic break(brokenBy: Error): never {\n\t\t// If already broken by this error, let it bubble up without rethrowing a modified version.\n\t\t// This prevents internal errors like asserts getting rethrown as different errors when wrapped with multiple call to `{@link Breakable.run}` or `{@link breakingMethod}`.\n\t\tif (this.brokenBy !== brokenBy) {\n\t\t\tthis.use();\n\t\t\tthis.brokenBy = brokenBy;\n\t\t}\n\t\tthrow brokenBy;\n\t}\n\n\t/**\n\t * {@link Breakable.break}, except tolerates `unknown` to be more easily used by catch blocks.\n\t * @privateRemarks\n\t * If there is a use-case, this should be made public.\n\t */\n\tprivate rethrowCaught(brokenBy: unknown): never {\n\t\tif (brokenBy instanceof Error) {\n\t\t\tthis.break(brokenBy);\n\t\t}\n\t\tthis.break(\n\t\t\tnew Error(`Non-error thrown breaking ${this.name}. Thrown value: \"${brokenBy}\"`),\n\t\t);\n\t}\n\n\t/**\n\t * Runs code which should break the object if it throws.\n\t * @remarks\n\t * Like {@link Breakable.use}, this also throws if already broken.\n\t * Any exceptions this catches are re-thrown.\n\t * Can use {@link breakingMethod} to apply this to a method.\n\t *\n\t * If `breaker` returns a Promise, the breakable is also broken if that Promise rejects, and the broken state is rechecked when it resolves:\n\t * if the breakable was put into a broken state during the async operation (by some other code path), the resolved value is discarded and the returned Promise rejects with a {@link UsageError}.\n\t *\n\t * This does not serialize concurrent runs: a synchronous run invoked while an async run is in flight will execute immediately, and is only blocked if the breakable is already broken.\n\t * Detection of an async result uses `instanceof Promise`, so custom Promise-like objects and Promises from other realms will be treated as synchronous results.\n\t */\n\tpublic run<TResult>(breaker: () => TResult): TResult {\n\t\tthis.use();\n\t\ttry {\n\t\t\tconst result = breaker();\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.then(\n\t\t\t\t\t(value: Awaited<TResult>) => {\n\t\t\t\t\t\t// If broken while process was running: this will throw instead of returning the value.\n\t\t\t\t\t\tthis.use(\n\t\t\t\t\t\t\t(brokenBy) =>\n\t\t\t\t\t\t\t\t`${this.name} was put into a broken state during an async operation.\\nOriginal Error:\\n${brokenBy}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => this.rethrowCaught(error),\n\t\t\t\t) as TResult;\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error: unknown) {\n\t\t\tthis.rethrowCaught(error);\n\t\t}\n\t}\n\n\t/**\n\t * Clears the existing broken state.\n\t * @remarks\n\t * This is rarely safe to to: it is only ok when all objects using this breaker are known to not have been left in an invalid state.\n\t * This is pretty much only safe in tests which just were checking a specific error was thrown, and which know that error closepath is actually exception safe.\n\t */\n\tpublic clearError(): void {\n\t\tassert(this.brokenBy !== undefined, 0x9b6 /* No error to clear */);\n\t\tthis.brokenBy = undefined;\n\t}\n}\n\n/**\n * Marks an object as being able to be in a broken state (unknown/unspecified/broken state due to unhandled exception).\n * @remarks\n * See decorators {@link breakingMethod} and {@link throwIfBroken} for ease of use.\n */\nexport interface WithBreakable {\n\t/**\n\t * The breaker for this object.\n\t * @remarks\n\t * If this `breaker` is in the broken state, the `WithBreakable` should be considered in a broken state.\n\t */\n\treadonly breaker: Breakable;\n}\n\n/**\n * Decorator for methods which should break the object when they throw.\n * @remarks\n * This also throws if already broken like {@link throwIfBroken}.\n * See {@link Breakable.run} for details.\n *\n * This should be used on methods which modify data that could result in an unsupported/broken state if an exception is thrown while modifying.\n * It is ok for breakingMethods to call each-other.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function breakingMethod<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context?: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tif (this.breaker === undefined) {\n\t\t\t// This case is necessary for when wrapping methods which are invoked inside the constructor of the base class before `breaker` is set.\n\t\t\t// Since the constructor throwing does not return an object, failing to put it into a broken state is not too bad.\n\t\t\t// However when more than just the constructed object should be broken, this can result in missing a break.\n\t\t\treturn target.call(this, ...args);\n\t\t}\n\t\treturn this.breaker.run(() => {\n\t\t\treturn target.call(this, ...args);\n\t\t});\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n/**\n * Decorator for methods which should throw if the object is in a broken state.\n * @remarks\n * This should be used on methods which read data that could be invalid when the object is broken.\n * @privateRemarks\n * Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.\n */\nexport function throwIfBroken<\n\tTarget extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return),\n\tThis extends WithBreakable,\n\tArgs extends never[],\n\tReturn,\n>(target: Target, context: ClassMethodDecoratorContext<This, Target>): Target {\n\tfunction replacementMethod(this: This, ...args: Args): Return {\n\t\tthis.breaker.use();\n\t\treturn target.call(this, ...args);\n\t}\n\tmarkBreaker(replacementMethod);\n\tnameFunctionFrom(replacementMethod, target);\n\treturn replacementMethod as Target;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype PossiblyNamedFunction = Function & { displayName?: undefined | string };\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction nameFunctionFrom(toName: Function, nameFrom: Function): void {\n\t(toName as PossiblyNamedFunction).displayName =\n\t\t(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;\n}\n\nconst isBreakerSymbol: unique symbol = Symbol(\"isBreaker\");\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction markBreaker(f: Function): void {\n\t(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;\n}\n\n// Accepting any function like value is desired and safe here as this does not call the provided function.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isBreaker(f: Function): boolean {\n\treturn isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);\n}\n\n/**\n * Decorator for classes which should break when their methods throw.\n * @remarks\n * Applies {@link breakingMethod} to all methods declared directly by class or its base classes.\n * Does not include those on derived classes.\n * Does not include getters or setters, or value properties.\n * Methods already marked as {@link breakingMethod} or {@link throwIfBroken} are unaffected.\n */\nexport function breakingClass<Target extends abstract new (...args: any[]) => WithBreakable>(\n\ttarget: Target,\n\tcontext: ClassDecoratorContext<Target>,\n): Target {\n\t// This could extend target, but doing so adds an extra step in the prototype chain and makes the instances just show up as \"DecoratedBreakable\" in the debugger.\n\tconst DecoratedBreakable = target;\n\n\t// Keep track of what keys we have seen (and already wrapped if needed).\n\t// Used to avoid rewrapping already wrapped properties.\n\t// Preloaded with \"constructor\" to avoid wrapping the constructor as there is no need to set the broken flag when the constructor throws and does not return an object.\n\t// Avoiding wrapping the constructor also avoids messing up the displayed name in the debugger.\n\tconst doNotWrap: Set<string | symbol> = new Set([\"constructor\"]);\n\n\tlet prototype: object | null = target.prototype as object;\n\twhile (prototype !== null) {\n\t\tfor (const key of Reflect.ownKeys(prototype)) {\n\t\t\tif (!doNotWrap.has(key)) {\n\t\t\t\tdoNotWrap.add(key);\n\t\t\t\tconst descriptor = Reflect.getOwnPropertyDescriptor(prototype, key);\n\t\t\t\t// Method\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\ttypeof descriptor.value === \"function\" &&\n\t\t\t\t\t!isBreaker(descriptor.value)\n\t\t\t\t) {\n\t\t\t\t\t// This does not affect the original class, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\n\t\t\t\t\tconst method = descriptor.value as (...args: unknown[]) => unknown;\n\t\t\t\t\tdescriptor.value = breakingMethod(method);\n\t\t\t\t\tObject.defineProperty(DecoratedBreakable.prototype, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprototype = Reflect.getPrototypeOf(prototype);\n\t}\n\n\treturn DecoratedBreakable;\n}\n"]}
@@ -82,9 +82,10 @@ export declare function tryDecodeEncodedIdWithoutSession(id: OriginatorDependent
82
82
  * the user-facing {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}
83
83
  * option — see that option for the user-facing rationale and trade-offs.
84
84
  *
85
- * Carried by decode-side contexts (`ChangeEncodingContext.healing`,
85
+ * Carried by decode-side contexts ({@link IdDecoderOptionsOriginatorless},
86
+ * `ChangeEncodingContext.healing`,
86
87
  * `EditManagerEncodingContext.healing`, etc.) when the workaround is enabled.
87
- * Presence enables healing; `undefined` opts out. There is no separate boolean,
88
+ * Presence enables healing; `undefined` means healing is disabled. There is no separate boolean,
88
89
  * which makes it impossible to enable healing without supplying the namespace
89
90
  * input.
90
91
  */
@@ -115,4 +116,70 @@ export declare function forceDecodeEncodedIdWithoutSession(id: OpSpaceCompressed
115
116
  * whether a `StableId` UUID, a heal-synthesized v5 UUID or other arbitrary string identifier.
116
117
  */
117
118
  export declare function decompressIdentifierIfNeeded(id: SessionSpaceCompressedId | string, idCompressor: Pick<IIdCompressor, "decompress">): string;
119
+ /**
120
+ * Options for creating an {@link IdDecodingContext} without an originator.
121
+ * @remarks
122
+ * Decodes {@link OriginatorlessEncodedId} instances, and optionally has a {@link IdentifierHealingConfig} fallback for {@link OriginatorDependentEncodedId} instances.
123
+ */
124
+ export interface IdDecoderOptionsOriginatorless {
125
+ readonly idCompressor: IIdCompressor;
126
+ /**
127
+ * Optional {@link IdentifierHealingConfig} to use for healing unresolvable identifiers.
128
+ * @privateRemarks
129
+ * This is a required field which can be undefined to make it explicit when this is not provided.
130
+ * This explicitness helps ensure we we don't accidentally drop the healing config as that would break
131
+ * an edge case which does not get a lot of testing.
132
+ */
133
+ readonly healing: IdentifierHealingConfig | undefined;
134
+ }
135
+ /**
136
+ * Options for creating an {@link IdDecodingContext} with an originator.
137
+ * @remarks
138
+ * Decodes {@link OriginatorDependentEncodedId} instances.
139
+ */
140
+ export interface IdDecoderOptionsWithOriginator {
141
+ readonly idCompressor: IIdCompressor;
142
+ /**
143
+ * The ID of the session that encoded the ids.
144
+ */
145
+ readonly originatorId: SessionId;
146
+ }
147
+ /**
148
+ * Context for decoding identifiers.
149
+ * @remarks
150
+ * Depended on how this is constructed, it may or may not handle {@link OriginatorDependentEncodedId} instances.
151
+ *
152
+ * 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.
153
+ * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.
154
+ *
155
+ * @privateRemarks
156
+ * We have code (FieldBatchDecodingContext) which sometimes has a session ID and sometimes doesn't, so we need a flexible decoding context.
157
+ * Additionally, since this is about serialized data, having stronger types is often counterproductive, as it just relies more on type casts when parsing.
158
+ * This is why we use this flexible pattern rather than code strongly typed over which kind of encoded ids are expected.
159
+ */
160
+ export declare class IdDecodingContext {
161
+ /**
162
+ * 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).
163
+ */
164
+ protected readonly hasOriginatorSessionId: boolean;
165
+ /**
166
+ * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.
167
+ */
168
+ readonly idCompressor: Pick<IIdCompressor, "decompress">;
169
+ /**
170
+ * Resolves an encoded op-space identifier to either a session-space ID
171
+ * (which {@link idCompressor} can decompress if needed)
172
+ * or a string (which passes through unchanged).
173
+ * @remarks
174
+ * In contexts where non-final identifiers can't be supported (where no originator session is available),
175
+ * if a non-final identifier is encountered, this may throw or perform a data healing workaround.
176
+ * See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.
177
+ */
178
+ readonly resolveEncodedId: (id: OpSpaceCompressedId) => SessionSpaceCompressedId | string;
179
+ /**
180
+ * Creates a new instance of the context.
181
+ * @param options - The options for creating the context.
182
+ */
183
+ constructor(options: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator);
184
+ }
118
185
  //# sourceMappingURL=compressedIds.d.ts.map
@@ -1 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B;IAC9C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;CACjC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAiB;IAC7B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IAEnD;;OAEG;IACH,SAAgB,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAEhE;;;;;;;;OAQG;IACH,SAAgB,gBAAgB,EAAE,CACjC,EAAE,EAAE,mBAAmB,KACnB,wBAAwB,GAAG,MAAM,CAAC;IAEvC;;;OAGG;gBAEF,OAAO,EAAE,8BAA8B,GAAG,8BAA8B;CAazE"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.decompressIdentifierIfNeeded = exports.forceDecodeEncodedIdWithoutSession = exports.tryDecodeEncodedIdWithoutSession = exports.decodeEncodedIdWithOriginator = exports.decodeOriginatorlessEncodedId = exports.encodePossiblyCompressedId = exports.EncodedIdType = void 0;
7
+ exports.IdDecodingContext = exports.decompressIdentifierIfNeeded = exports.forceDecodeEncodedIdWithoutSession = exports.tryDecodeEncodedIdWithoutSession = exports.decodeEncodedIdWithOriginator = exports.decodeOriginatorlessEncodedId = exports.encodePossiblyCompressedId = exports.EncodedIdType = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/id-compressor/internal");
10
10
  const uuid_1 = require("uuid");
@@ -130,4 +130,35 @@ function decompressIdentifierIfNeeded(id, idCompressor) {
130
130
  }
131
131
  }
132
132
  exports.decompressIdentifierIfNeeded = decompressIdentifierIfNeeded;
133
+ /**
134
+ * Context for decoding identifiers.
135
+ * @remarks
136
+ * Depended on how this is constructed, it may or may not handle {@link OriginatorDependentEncodedId} instances.
137
+ *
138
+ * 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.
139
+ * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.
140
+ *
141
+ * @privateRemarks
142
+ * We have code (FieldBatchDecodingContext) which sometimes has a session ID and sometimes doesn't, so we need a flexible decoding context.
143
+ * Additionally, since this is about serialized data, having stronger types is often counterproductive, as it just relies more on type casts when parsing.
144
+ * This is why we use this flexible pattern rather than code strongly typed over which kind of encoded ids are expected.
145
+ */
146
+ class IdDecodingContext {
147
+ /**
148
+ * Creates a new instance of the context.
149
+ * @param options - The options for creating the context.
150
+ */
151
+ constructor(options) {
152
+ this.idCompressor = options.idCompressor;
153
+ if ("originatorId" in options) {
154
+ this.hasOriginatorSessionId = true;
155
+ this.resolveEncodedId = (id) => options.idCompressor.normalizeToSessionSpace(id, options.originatorId);
156
+ }
157
+ else {
158
+ this.hasOriginatorSessionId = false;
159
+ this.resolveEncodedId = (id) => forceDecodeEncodedIdWithoutSession(id, options.idCompressor, options.healing);
160
+ }
161
+ }
162
+ }
163
+ exports.IdDecodingContext = IdDecodingContext;
133
164
  //# sourceMappingURL=compressedIds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compressedIds.js","sourceRoot":"","sources":["../../src/util/compressedIds.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D,qEAA+E;AAC/E,+BAAoC;AAqBpC;;GAEG;AACH,IAAY,aASX;AATD,WAAY,aAAa;IACxB;;OAEG;IACH,qEAAc,CAAA;IACd;;OAEG;IACH,+EAAmB,CAAA;AACpB,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB;AAiBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,0BAA0B,CACzC,EAAU,EACV,YAA2B,EAC3B,aAAgB;IAEhB,IAAI,CAAC,IAAA,qBAAU,EAAC,EAAE,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,wBAAwB,GAAG,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AS,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,8CAA8C;IAC9C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAA,SAAM,EAAC,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,IAAI,KAAK,CACd,qJAAqJ,CACrJ,CAAC;AACH,CAAC;AAhBD,gFAgBC;AAED;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAC3C,EAAqC,EACrC,YAA+C;IAE/C,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACX,CAAC;SAAM,CAAC;QACP,MAAM,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACjD,IAAA,iBAAM,EAAC,OAAO,YAAY,KAAK,QAAQ,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACvF,OAAO,YAAY,CAAC;IACrB,CAAC;AACF,CAAC;AAXD,oEAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n} from \"@fluidframework/id-compressor\";\nimport { isFinalId, isStableId } from \"@fluidframework/id-compressor/internal\";\nimport { v5 as uuidV5 } from \"uuid\";\n\n/**\n * An encoded identifier that can be decoded without an originator session id.\n * A finalized compressed id — the same numeric value in op-space and session-space.\n * @remarks\n * These are safe to use in contexts where the encoding id compressor is available to decode them,\n * even when the session id of the encoding id compressor is not known.\n */\nexport type OriginatorlessEncodedId = SessionSpaceCompressedId & OpSpaceCompressedId;\n\n/**\n * An encoded identifier that may require an originator session id to decode.\n * Any op-space compressed id, either finalized or session-local.\n * @remarks\n * These are only safe to use in contexts where the encoding id compressor is available\n * and the session id of the encoding id compressor is known.\n * Currently the only such case is in ops, excluding attach summary ops.\n */\nexport type OriginatorDependentEncodedId = OpSpaceCompressedId;\n\n/**\n * Selects how identifiers are encoded for transport/persistence.\n */\nexport enum EncodedIdType {\n\t/**\n\t * {@link OriginatorlessEncodedId}.\n\t */\n\tOriginatorless,\n\t/**\n\t * {@link OriginatorDependentEncodedId}.\n\t */\n\tOriginatorDependent,\n}\n\nexport type EncodedId<T extends EncodedIdType> = T extends EncodedIdType.Originatorless\n\t? OriginatorlessEncodedId\n\t: T extends EncodedIdType.OriginatorDependent\n\t\t? OriginatorDependentEncodedId\n\t\t: OriginatorlessEncodedId | OriginatorDependentEncodedId;\n\n/**\n * Context for encoding identifiers.\n * @remarks\n * See {@link FieldBatchDecodingContext} for the decoder.\n */\nexport interface IdEncodingContext {\n\tencodePossiblyCompressedId(id: string): string | EncodedId<EncodedIdType>;\n}\n\n/**\n * Encode a string identifier into a possibly compressed form based on the requested mode.\n *\n * @param id - The string identifier to encode.\n * @param idCompressor - The ID compressor to use for compression.\n * @param encodedIdType - The type of encoding to use. If the context doing the decoding will have the originator {@link SessionId},\n * then {@link EncodedIdType.OriginatorDependent} can be used.\n * Otherwise, {@link EncodedIdType.Originatorless} must be used.\n *\n * @privateRemarks\n * Performance:\n * When trying to optimize to avoid unnecessary identifier decompression, and store identifiers compressed in memory,\n * this will likely need to be updated to allow in SessionSpaceCompressedIds.\n */\nexport function encodePossiblyCompressedId<T extends EncodedIdType>(\n\tid: string,\n\tidCompressor: IIdCompressor,\n\tencodedIdType: T,\n): string | EncodedId<T> {\n\tif (!isStableId(id)) {\n\t\treturn id;\n\t}\n\tconst sessionSpaceCompressedId = idCompressor.tryRecompress(id);\n\tif (sessionSpaceCompressedId === undefined) {\n\t\treturn id;\n\t}\n\tconst opSpaceId = idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\tif (encodedIdType === EncodedIdType.Originatorless) {\n\t\treturn isFinalId(opSpaceId) ? (opSpaceId as unknown as EncodedId<T>) : id;\n\t}\n\treturn opSpaceId as unknown as EncodedId<T>;\n}\n\n/**\n * Namespace used for the deterministic UUIDv5 produced by the heal-on-decode workaround\n * in {@link forceDecodeEncodedIdWithoutSession}.\n *\n * This scheme requires consensus across all clients to function — every client that\n * encounters the same unresolvable id must produce the same v5 UUID.\n */\nconst healingNamespace = \"f8a89df3-6882-400f-b913-4c1f6f0157bd\";\n\n/**\n * Decode an {@link OriginatorlessEncodedId} without needing an originator session id.\n *\n * The id is guaranteed to be final by the type contract; it is normalized via\n * {@link IIdCompressor.tryNormalizeToSessionSpaceWithoutSession}, which handles the\n * cluster-aligned-local case rather than relying on the bare numeric value.\n */\nexport function decodeOriginatorlessEncodedId(\n\tid: OriginatorlessEncodedId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId {\n\tconst sessionSpaceId = idCompressor.tryNormalizeToSessionSpaceWithoutSession(id);\n\tassert(\n\t\tsessionSpaceId !== undefined,\n\t\t0xd0a /* OriginatorlessEncodedId must be a finalized compressed id at runtime */,\n\t);\n\treturn sessionSpaceId;\n}\n\n/**\n * Decode an {@link OriginatorDependentEncodedId} using a known originator session id.\n */\nexport function decodeEncodedIdWithOriginator(\n\tid: OriginatorDependentEncodedId,\n\toriginator: SessionId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId {\n\treturn idCompressor.normalizeToSessionSpace(id, originator);\n}\n\n/**\n * Decode an {@link OriginatorDependentEncodedId} without a session.\n *\n * Returns the session-space id if `id` is finalized (and therefore resolvable\n * without an originator session), or `undefined` if `id` is a non-final op-space\n * id that cannot be resolved without the originator session.\n */\nexport function tryDecodeEncodedIdWithoutSession(\n\tid: OriginatorDependentEncodedId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId | undefined {\n\treturn idCompressor.tryNormalizeToSessionSpaceWithoutSession(id);\n}\n\n/**\n * Configuration for the heal-on-decode workaround. The internal counterpart of\n * the user-facing {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}\n * option — see that option for the user-facing rationale and trade-offs.\n *\n * Carried by decode-side contexts (`ChangeEncodingContext.healing`,\n * `EditManagerEncodingContext.healing`, etc.) when the workaround is enabled.\n * Presence enables healing; `undefined` opts out. There is no separate boolean,\n * which makes it impossible to enable healing without supplying the namespace\n * input.\n */\nexport interface IdentifierHealingConfig {\n\t/**\n\t * The SharedTree's shared-object id, used as the v5 namespace input so\n\t * healed UUIDs are unique across attaches of different documents with the\n\t * same session offsets.\n\t */\n\treadonly sharedObjectId: string;\n}\n\n/**\n * Decode an op-space compressed id without a session.\n *\n * Finalized ids are returned as session-space ids (final ids are invariant\n * across the two spaces). Non-final ids are healed via {@link IdentifierHealingConfig}\n * if provided, or cause the resolver to throw otherwise. A healed result is a\n * deterministic v5 UUID string — *not* a `StableId`, since that brand requires\n * v4, but still a valid identifier value; the `string` arm of the return type\n * covers this case.\n */\nexport function forceDecodeEncodedIdWithoutSession(\n\tid: OpSpaceCompressedId,\n\tidCompressor: IIdCompressor,\n\thealing: IdentifierHealingConfig | undefined,\n): SessionSpaceCompressedId | string {\n\tconst decoded = tryDecodeEncodedIdWithoutSession(id, idCompressor);\n\tif (decoded !== undefined) {\n\t\treturn decoded;\n\t}\n\t// `id` is a non-final op-space compressed id.\n\tif (healing !== undefined) {\n\t\treturn uuidV5(`${healing.sharedObjectId}|${id}`, healingNamespace);\n\t}\n\tthrow new Error(\n\t\t\"Summary could not be loaded due to an incorrectly encoded identifier. See SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode for mitigation.\",\n\t);\n}\n\n/**\n * Convert a decoded, but possibly compressed, identifier to the decompressed string format.\n *\n * Session-space compressed ids are decompressed to their UUID representation via the compressor.\n * String inputs pass through unchanged — they are already in the stored form,\n * whether a `StableId` UUID, a heal-synthesized v5 UUID or other arbitrary string identifier.\n */\nexport function decompressIdentifierIfNeeded(\n\tid: SessionSpaceCompressedId | string,\n\tidCompressor: Pick<IIdCompressor, \"decompress\">,\n): string {\n\tif (typeof id === \"string\") {\n\t\treturn id;\n\t} else {\n\t\tconst decompressed = idCompressor.decompress(id);\n\t\tassert(typeof decompressed === \"string\", 0xd0b /* Decompressed id must be a string */);\n\t\treturn decompressed;\n\t}\n}\n"]}
1
+ {"version":3,"file":"compressedIds.js","sourceRoot":"","sources":["../../src/util/compressedIds.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D,qEAA+E;AAC/E,+BAAoC;AAqBpC;;GAEG;AACH,IAAY,aASX;AATD,WAAY,aAAa;IACxB;;OAEG;IACH,qEAAc,CAAA;IACd;;OAEG;IACH,+EAAmB,CAAA;AACpB,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB;AAiBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,0BAA0B,CACzC,EAAU,EACV,YAA2B,EAC3B,aAAgB;IAEhB,IAAI,CAAC,IAAA,qBAAU,EAAC,EAAE,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,wBAAwB,GAAG,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAChE,IAAI,wBAAwB,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,SAAS,GAAG,YAAY,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;IAC5E,IAAI,aAAa,KAAK,aAAa,CAAC,cAAc,EAAE,CAAC;QACpD,OAAO,IAAA,oBAAS,EAAC,SAAS,CAAC,CAAC,CAAC,CAAE,SAAqC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,CAAC;IACD,OAAO,SAAoC,CAAC;AAC7C,CAAC;AAjBD,gEAiBC;AAED;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAEhE;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAC5C,EAA2B,EAC3B,YAA2B;IAE3B,MAAM,cAAc,GAAG,YAAY,CAAC,wC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EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACvF,OAAO,YAAY,CAAC;IACrB,CAAC;AACF,CAAC;AAXD,oEAWC;AAgCD;;;;;;;;;;;;GAYG;AACH,MAAa,iBAAiB;IAwB7B;;;OAGG;IACH,YACC,OAAwE;QAExE,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC;YAC/B,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,CAAC,EAAE,EAAqC,EAAE,CACjE,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,EAAE,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;YACpC,IAAI,CAAC,gBAAgB,GAAG,CAAC,EAAE,EAAqC,EAAE,CACjE,kCAAkC,CAAC,EAAE,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;CACD;AA1CD,8CA0CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n} from \"@fluidframework/id-compressor\";\nimport { isFinalId, isStableId } from \"@fluidframework/id-compressor/internal\";\nimport { v5 as uuidV5 } from \"uuid\";\n\n/**\n * An encoded identifier that can be decoded without an originator session id.\n * A finalized compressed id — the same numeric value in op-space and session-space.\n * @remarks\n * These are safe to use in contexts where the encoding id compressor is available to decode them,\n * even when the session id of the encoding id compressor is not known.\n */\nexport type OriginatorlessEncodedId = SessionSpaceCompressedId & OpSpaceCompressedId;\n\n/**\n * An encoded identifier that may require an originator session id to decode.\n * Any op-space compressed id, either finalized or session-local.\n * @remarks\n * These are only safe to use in contexts where the encoding id compressor is available\n * and the session id of the encoding id compressor is known.\n * Currently the only such case is in ops, excluding attach summary ops.\n */\nexport type OriginatorDependentEncodedId = OpSpaceCompressedId;\n\n/**\n * Selects how identifiers are encoded for transport/persistence.\n */\nexport enum EncodedIdType {\n\t/**\n\t * {@link OriginatorlessEncodedId}.\n\t */\n\tOriginatorless,\n\t/**\n\t * {@link OriginatorDependentEncodedId}.\n\t */\n\tOriginatorDependent,\n}\n\nexport type EncodedId<T extends EncodedIdType> = T extends EncodedIdType.Originatorless\n\t? OriginatorlessEncodedId\n\t: T extends EncodedIdType.OriginatorDependent\n\t\t? OriginatorDependentEncodedId\n\t\t: OriginatorlessEncodedId | OriginatorDependentEncodedId;\n\n/**\n * Context for encoding identifiers.\n * @remarks\n * See {@link FieldBatchDecodingContext} for the decoder.\n */\nexport interface IdEncodingContext {\n\tencodePossiblyCompressedId(id: string): string | EncodedId<EncodedIdType>;\n}\n\n/**\n * Encode a string identifier into a possibly compressed form based on the requested mode.\n *\n * @param id - The string identifier to encode.\n * @param idCompressor - The ID compressor to use for compression.\n * @param encodedIdType - The type of encoding to use. If the context doing the decoding will have the originator {@link SessionId},\n * then {@link EncodedIdType.OriginatorDependent} can be used.\n * Otherwise, {@link EncodedIdType.Originatorless} must be used.\n *\n * @privateRemarks\n * Performance:\n * When trying to optimize to avoid unnecessary identifier decompression, and store identifiers compressed in memory,\n * this will likely need to be updated to allow in SessionSpaceCompressedIds.\n */\nexport function encodePossiblyCompressedId<T extends EncodedIdType>(\n\tid: string,\n\tidCompressor: IIdCompressor,\n\tencodedIdType: T,\n): string | EncodedId<T> {\n\tif (!isStableId(id)) {\n\t\treturn id;\n\t}\n\tconst sessionSpaceCompressedId = idCompressor.tryRecompress(id);\n\tif (sessionSpaceCompressedId === undefined) {\n\t\treturn id;\n\t}\n\tconst opSpaceId = idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\tif (encodedIdType === EncodedIdType.Originatorless) {\n\t\treturn isFinalId(opSpaceId) ? (opSpaceId as unknown as EncodedId<T>) : id;\n\t}\n\treturn opSpaceId as unknown as EncodedId<T>;\n}\n\n/**\n * Namespace used for the deterministic UUIDv5 produced by the heal-on-decode workaround\n * in {@link forceDecodeEncodedIdWithoutSession}.\n *\n * This scheme requires consensus across all clients to function — every client that\n * encounters the same unresolvable id must produce the same v5 UUID.\n */\nconst healingNamespace = \"f8a89df3-6882-400f-b913-4c1f6f0157bd\";\n\n/**\n * Decode an {@link OriginatorlessEncodedId} without needing an originator session id.\n *\n * The id is guaranteed to be final by the type contract; it is normalized via\n * {@link IIdCompressor.tryNormalizeToSessionSpaceWithoutSession}, which handles the\n * cluster-aligned-local case rather than relying on the bare numeric value.\n */\nexport function decodeOriginatorlessEncodedId(\n\tid: OriginatorlessEncodedId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId {\n\tconst sessionSpaceId = idCompressor.tryNormalizeToSessionSpaceWithoutSession(id);\n\tassert(\n\t\tsessionSpaceId !== undefined,\n\t\t0xd0a /* OriginatorlessEncodedId must be a finalized compressed id at runtime */,\n\t);\n\treturn sessionSpaceId;\n}\n\n/**\n * Decode an {@link OriginatorDependentEncodedId} using a known originator session id.\n */\nexport function decodeEncodedIdWithOriginator(\n\tid: OriginatorDependentEncodedId,\n\toriginator: SessionId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId {\n\treturn idCompressor.normalizeToSessionSpace(id, originator);\n}\n\n/**\n * Decode an {@link OriginatorDependentEncodedId} without a session.\n *\n * Returns the session-space id if `id` is finalized (and therefore resolvable\n * without an originator session), or `undefined` if `id` is a non-final op-space\n * id that cannot be resolved without the originator session.\n */\nexport function tryDecodeEncodedIdWithoutSession(\n\tid: OriginatorDependentEncodedId,\n\tidCompressor: IIdCompressor,\n): SessionSpaceCompressedId | undefined {\n\treturn idCompressor.tryNormalizeToSessionSpaceWithoutSession(id);\n}\n\n/**\n * Configuration for the heal-on-decode workaround. The internal counterpart of\n * the user-facing {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}\n * option — see that option for the user-facing rationale and trade-offs.\n *\n * Carried by decode-side contexts ({@link IdDecoderOptionsOriginatorless},\n * `ChangeEncodingContext.healing`,\n * `EditManagerEncodingContext.healing`, etc.) when the workaround is enabled.\n * Presence enables healing; `undefined` means healing is disabled. There is no separate boolean,\n * which makes it impossible to enable healing without supplying the namespace\n * input.\n */\nexport interface IdentifierHealingConfig {\n\t/**\n\t * The SharedTree's shared-object id, used as the v5 namespace input so\n\t * healed UUIDs are unique across attaches of different documents with the\n\t * same session offsets.\n\t */\n\treadonly sharedObjectId: string;\n}\n\n/**\n * Decode an op-space compressed id without a session.\n *\n * Finalized ids are returned as session-space ids (final ids are invariant\n * across the two spaces). Non-final ids are healed via {@link IdentifierHealingConfig}\n * if provided, or cause the resolver to throw otherwise. A healed result is a\n * deterministic v5 UUID string — *not* a `StableId`, since that brand requires\n * v4, but still a valid identifier value; the `string` arm of the return type\n * covers this case.\n */\nexport function forceDecodeEncodedIdWithoutSession(\n\tid: OpSpaceCompressedId,\n\tidCompressor: IIdCompressor,\n\thealing: IdentifierHealingConfig | undefined,\n): SessionSpaceCompressedId | string {\n\tconst decoded = tryDecodeEncodedIdWithoutSession(id, idCompressor);\n\tif (decoded !== undefined) {\n\t\treturn decoded;\n\t}\n\t// `id` is a non-final op-space compressed id.\n\tif (healing !== undefined) {\n\t\treturn uuidV5(`${healing.sharedObjectId}|${id}`, healingNamespace);\n\t}\n\tthrow new Error(\n\t\t\"Summary could not be loaded due to an incorrectly encoded identifier. See SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode for mitigation.\",\n\t);\n}\n\n/**\n * Convert a decoded, but possibly compressed, identifier to the decompressed string format.\n *\n * Session-space compressed ids are decompressed to their UUID representation via the compressor.\n * String inputs pass through unchanged — they are already in the stored form,\n * whether a `StableId` UUID, a heal-synthesized v5 UUID or other arbitrary string identifier.\n */\nexport function decompressIdentifierIfNeeded(\n\tid: SessionSpaceCompressedId | string,\n\tidCompressor: Pick<IIdCompressor, \"decompress\">,\n): string {\n\tif (typeof id === \"string\") {\n\t\treturn id;\n\t} else {\n\t\tconst decompressed = idCompressor.decompress(id);\n\t\tassert(typeof decompressed === \"string\", 0xd0b /* Decompressed id must be a string */);\n\t\treturn decompressed;\n\t}\n}\n\n/**\n * Options for creating an {@link IdDecodingContext} without an originator.\n * @remarks\n * Decodes {@link OriginatorlessEncodedId} instances, and optionally has a {@link IdentifierHealingConfig} fallback for {@link OriginatorDependentEncodedId} instances.\n */\nexport interface IdDecoderOptionsOriginatorless {\n\treadonly idCompressor: IIdCompressor;\n\t/**\n\t * Optional {@link IdentifierHealingConfig} to use for healing unresolvable identifiers.\n\t * @privateRemarks\n\t * This is a required field which can be undefined to make it explicit when this is not provided.\n\t * This explicitness helps ensure we we don't accidentally drop the healing config as that would break\n\t * an edge case which does not get a lot of testing.\n\t */\n\treadonly healing: IdentifierHealingConfig | undefined;\n}\n\n/**\n * Options for creating an {@link IdDecodingContext} with an originator.\n * @remarks\n * Decodes {@link OriginatorDependentEncodedId} instances.\n */\nexport interface IdDecoderOptionsWithOriginator {\n\treadonly idCompressor: IIdCompressor;\n\t/**\n\t * The ID of the session that encoded the ids.\n\t */\n\treadonly originatorId: SessionId;\n}\n\n/**\n * Context for decoding identifiers.\n * @remarks\n * Depended on how this is constructed, it may or may not handle {@link OriginatorDependentEncodedId} instances.\n *\n * 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.\n * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.\n *\n * @privateRemarks\n * We have code (FieldBatchDecodingContext) which sometimes has a session ID and sometimes doesn't, so we need a flexible decoding context.\n * Additionally, since this is about serialized data, having stronger types is often counterproductive, as it just relies more on type casts when parsing.\n * This is why we use this flexible pattern rather than code strongly typed over which kind of encoded ids are expected.\n */\nexport class IdDecodingContext {\n\t/**\n\t * 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).\n\t */\n\tprotected readonly hasOriginatorSessionId: boolean;\n\n\t/**\n\t * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.\n\t */\n\tpublic readonly idCompressor: Pick<IIdCompressor, \"decompress\">;\n\n\t/**\n\t * Resolves an encoded op-space identifier to either a session-space ID\n\t * (which {@link idCompressor} can decompress if needed)\n\t * or a string (which passes through unchanged).\n\t * @remarks\n\t * In contexts where non-final identifiers can't be supported (where no originator session is available),\n\t * if a non-final identifier is encountered, this may throw or perform a data healing workaround.\n\t * See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.\n\t */\n\tpublic readonly resolveEncodedId: (\n\t\tid: OpSpaceCompressedId,\n\t) => SessionSpaceCompressedId | string;\n\n\t/**\n\t * Creates a new instance of the context.\n\t * @param options - The options for creating the context.\n\t */\n\tpublic constructor(\n\t\toptions: IdDecoderOptionsOriginatorless | IdDecoderOptionsWithOriginator,\n\t) {\n\t\tthis.idCompressor = options.idCompressor;\n\t\tif (\"originatorId\" in options) {\n\t\t\tthis.hasOriginatorSessionId = true;\n\t\t\tthis.resolveEncodedId = (id): SessionSpaceCompressedId | string =>\n\t\t\t\toptions.idCompressor.normalizeToSessionSpace(id, options.originatorId);\n\t\t} else {\n\t\t\tthis.hasOriginatorSessionId = false;\n\t\t\tthis.resolveEncodedId = (id): SessionSpaceCompressedId | string =>\n\t\t\t\tforceDecodeEncodedIdWithoutSession(id, options.idCompressor, options.healing);\n\t\t}\n\t}\n}\n"]}
@@ -11,7 +11,7 @@ export { addToNestedSet, type NestedSet, nestedSetContains } from "./nestedSet.j
11
11
  export { type OffsetList, OffsetListFactory } from "./offsetList.js";
12
12
  export type { areSafelyAssignable, Contravariant, Covariant, eitherIsAny, EnforceTypeCheckTests, Invariant, isAny, isAssignableTo, isStrictSubset, MakeNominal, requireFalse, requireTrue, requireAssignableTo, areOnlyKeys, } from "./typeCheck.js";
13
13
  export { StackyIterator } from "./stackyIterator.js";
14
- export { asMutable, balancedReduce, compareSets, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromIterable, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareNumbers, comparePartialNumbers, compareStrings, comparePartialStrings, find, count, getLast, hasSome, hasSingle, defineLazyCachedProperty, copyPropertyIfDefined as copyProperty, getOrAddInMap, iterableHasSome, } from "./utils.js";
14
+ export { asMutable, balancedReduce, compareSets, getOrAddEmptyToMap, getOrCreate, isJsonObject, isReadonlyArray, type JsonCompatible, type JsonCompatibleObject, type JsonCompatibleReadOnly, type JsonCompatibleReadOnlyObject, JsonCompatibleReadOnlySchema, makeArray, mapIterable, filterIterable, type Mutable, type Populated, type RecursiveReadonly, assertValidIndex, assertValidRange, assertNonNegativeSafeInteger, objectToMap, invertMap, oneFromIterable, disposeSymbol, type IDisposable, capitalize, assertValidRangeIndices, transformObjectMap, compareNumbers, comparePartialNumbers, compareStrings, comparePartialStrings, find, count, getLast, hasSome, hasSingle, defineLazyCachedProperty, copyPropertyIfDefined as copyProperty, iterableHasSome, } from "./utils.js";
15
15
  export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
16
16
  export type { _RecursiveTrick, RestrictiveReadonlyRecord, RestrictiveStringRecord, _InlineTrick, FlattenKeys, IsUnion, UnionToIntersection, UnionToTuple, PopUnion, } from "./typeUtils.js";
17
17
  export { unsafeArrayToTuple } from "./typeUtils.js";
@@ -22,5 +22,5 @@ export { Breakable, type WithBreakable, breakingMethod, throwIfBroken, breakingC
22
22
  export { type TupleBTree, newTupleBTree, mergeTupleBTrees, createTupleComparator, } from "./bTreeUtils.js";
23
23
  export { cloneWithReplacements } from "./cloneWithReplacements.js";
24
24
  export { readAndParseSnapshotBlob } from "./readSnapshotBlob.js";
25
- export { type OriginatorlessEncodedId, type OriginatorDependentEncodedId, type IdentifierHealingConfig, EncodedIdType, encodePossiblyCompressedId, type IdEncodingContext, type EncodedId, decodeOriginatorlessEncodedId, decodeEncodedIdWithOriginator, tryDecodeEncodedIdWithoutSession, forceDecodeEncodedIdWithoutSession, decompressIdentifierIfNeeded, } from "./compressedIds.js";
25
+ export { type OriginatorlessEncodedId, type OriginatorDependentEncodedId, type IdentifierHealingConfig, EncodedIdType, encodePossiblyCompressedId, type IdEncodingContext, type EncodedId, decodeOriginatorlessEncodedId, decodeEncodedIdWithOriginator, tryDecodeEncodedIdWithoutSession, forceDecodeEncodedIdWithoutSession, decompressIdentifierIfNeeded, IdDecodingContext, type IdDecoderOptionsOriginatorless, type IdDecoderOptionsWithOriginator, } from "./compressedIds.js";
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,uBAAuB,EACvB,KAAK,UAAU,EACf,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,EACL,KAAK,KAAK,EACV,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,UAAU,EACV,KAAK,MAAM,EACX,UAAU,EACV,OAAO,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB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AC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,aAAa,EACb,0BAA0B,EAC1B,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,6BAA6B,EAC7B,6BAA6B,EAC7B,gCAAgC,EAChC,kCAAkC,EAClC,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,GACnC,MAAM,oBAAoB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.capitalize = exports.disposeSymbol = exports.oneFromIterable = exports.invertMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.filterIterable = exports.mapIterable = exports.makeArray = exports.JsonCompatibleReadOnlySchema = exports.isReadonlyArray = exports.isJsonObject = exports.getOrCreate = exports.getOrAddEmptyToMap = exports.compareSets = exports.balancedReduce = exports.asMutable = exports.StackyIterator = exports.OffsetListFactory = exports.nestedSetContains = exports.addToNestedSet = exports.getOrCreateInNestedMap = exports.nestedMapFromFlatList = exports.nestedMapToFlatList = exports.mapNestedMap = exports.tryGetFromNestedMap = exports.tryAddToNestedMap = exports.setInNestedMap = exports.populateNestedMap = exports.SizedNestedMap = exports.forEachInNestedMap = exports.getOrDefaultInNestedMap = exports.getOrAddInNestedMap = exports.deleteFromNestedMap = exports.extractFromOpaque = exports.brandOpaque = exports.brandedStringType = exports.brandedNumberType = exports.unbrand = exports.strictEnum = exports.brandConst = exports.BrandedType = exports.brand = exports.validateSafeInteger = exports.validatePositiveIndex = exports.validateIndexRange = exports.validateIndex = exports.collectContiguousRanges = void 0;
8
- exports.decompressIdentifierIfNeeded = exports.forceDecodeEncodedIdWithoutSession = exports.tryDecodeEncodedIdWithoutSession = exports.decodeEncodedIdWithOriginator = exports.decodeOriginatorlessEncodedId = exports.encodePossiblyCompressedId = exports.EncodedIdType = exports.readAndParseSnapshotBlob = exports.cloneWithReplacements = exports.createTupleComparator = exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.iterableHasSome = exports.getOrAddInMap = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = exports.count = exports.find = exports.comparePartialStrings = exports.compareStrings = exports.comparePartialNumbers = exports.compareNumbers = exports.transformObjectMap = exports.assertValidRangeIndices = void 0;
8
+ exports.IdDecodingContext = exports.decompressIdentifierIfNeeded = exports.forceDecodeEncodedIdWithoutSession = exports.tryDecodeEncodedIdWithoutSession = exports.decodeEncodedIdWithOriginator = exports.decodeOriginatorlessEncodedId = exports.encodePossiblyCompressedId = exports.EncodedIdType = exports.readAndParseSnapshotBlob = exports.cloneWithReplacements = exports.createTupleComparator = exports.mergeTupleBTrees = exports.newTupleBTree = exports.breakingClass = exports.throwIfBroken = exports.breakingMethod = exports.Breakable = exports.fakeIdAllocator = exports.idAllocatorFromState = exports.idAllocatorFromMaxId = exports.newIntegerRangeMap = exports.RangeMap = exports.brandedSlot = exports.getOrCreateSlotContent = exports.unsafeArrayToTuple = exports.ReferenceCountedBase = exports.iterableHasSome = exports.copyProperty = exports.defineLazyCachedProperty = exports.hasSingle = exports.hasSome = exports.getLast = exports.count = exports.find = exports.comparePartialStrings = exports.compareStrings = exports.comparePartialNumbers = exports.compareNumbers = exports.transformObjectMap = exports.assertValidRangeIndices = void 0;
9
9
  var arrayUtilities_js_1 = require("./arrayUtilities.js");
10
10
  Object.defineProperty(exports, "collectContiguousRanges", { enumerable: true, get: function () { return arrayUtilities_js_1.collectContiguousRanges; } });
11
11
  Object.defineProperty(exports, "validateIndex", { enumerable: true, get: function () { return arrayUtilities_js_1.validateIndex; } });
@@ -78,7 +78,6 @@ Object.defineProperty(exports, "hasSome", { enumerable: true, get: function () {
78
78
  Object.defineProperty(exports, "hasSingle", { enumerable: true, get: function () { return utils_js_1.hasSingle; } });
79
79
  Object.defineProperty(exports, "defineLazyCachedProperty", { enumerable: true, get: function () { return utils_js_1.defineLazyCachedProperty; } });
80
80
  Object.defineProperty(exports, "copyProperty", { enumerable: true, get: function () { return utils_js_1.copyPropertyIfDefined; } });
81
- Object.defineProperty(exports, "getOrAddInMap", { enumerable: true, get: function () { return utils_js_1.getOrAddInMap; } });
82
81
  Object.defineProperty(exports, "iterableHasSome", { enumerable: true, get: function () { return utils_js_1.iterableHasSome; } });
83
82
  var referenceCounting_js_1 = require("./referenceCounting.js");
84
83
  Object.defineProperty(exports, "ReferenceCountedBase", { enumerable: true, get: function () { return referenceCounting_js_1.ReferenceCountedBase; } });
@@ -115,4 +114,5 @@ Object.defineProperty(exports, "decodeEncodedIdWithOriginator", { enumerable: tr
115
114
  Object.defineProperty(exports, "tryDecodeEncodedIdWithoutSession", { enumerable: true, get: function () { return compressedIds_js_1.tryDecodeEncodedIdWithoutSession; } });
116
115
  Object.defineProperty(exports, "forceDecodeEncodedIdWithoutSession", { enumerable: true, get: function () { return compressedIds_js_1.forceDecodeEncodedIdWithoutSession; } });
117
116
  Object.defineProperty(exports, "decompressIdentifierIfNeeded", { enumerable: true, get: function () { return compressedIds_js_1.decompressIdentifierIfNeeded; } });
117
+ Object.defineProperty(exports, "IdDecodingContext", { enumerable: true, get: function () { return compressedIds_js_1.IdDecodingContext; } });
118
118
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,yDAO6B;AAN5B,4HA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B,iHAAA,aAAa,OAAA;AACb,8HAAA,0BAA0B,OAAA;AAG1B,iIAAA,6BAA6B,OAAA;AAC7B,iIAAA,6BAA6B,OAAA;AAC7B,oIAAA,gCAAgC,OAAA;AAChC,sIAAA,kCAAkC,OAAA;AAClC,gIAAA,4BAA4B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tcollectContiguousRanges,\n\ttype IndexRange,\n\tvalidateIndex,\n\tvalidateIndexRange,\n\tvalidatePositiveIndex,\n\tvalidateSafeInteger,\n} from \"./arrayUtilities.js\";\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n\tbrandConst,\n\ttype Values,\n\tstrictEnum,\n\tunbrand,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tcompareSets,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromIterable,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareNumbers,\n\tcomparePartialNumbers,\n\tcompareStrings,\n\tcomparePartialStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\tgetOrAddInMap,\n\titerableHasSome,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\tnewIntegerRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport {\n\ttype TupleBTree,\n\tnewTupleBTree,\n\tmergeTupleBTrees,\n\tcreateTupleComparator,\n} from \"./bTreeUtils.js\";\n\nexport { cloneWithReplacements } from \"./cloneWithReplacements.js\";\n\nexport { readAndParseSnapshotBlob } from \"./readSnapshotBlob.js\";\n\nexport {\n\ttype OriginatorlessEncodedId,\n\ttype OriginatorDependentEncodedId,\n\ttype IdentifierHealingConfig,\n\tEncodedIdType,\n\tencodePossiblyCompressedId,\n\ttype IdEncodingContext,\n\ttype EncodedId,\n\tdecodeOriginatorlessEncodedId,\n\tdecodeEncodedIdWithOriginator,\n\ttryDecodeEncodedIdWithoutSession,\n\tforceDecodeEncodedIdWithoutSession,\n\tdecompressIdentifierIfNeeded,\n} from \"./compressedIds.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,yDAO6B;AAN5B,4HAAA,uBAAuB,OAAA;AAEvB,kHAAA,aAAa,OAAA;AACb,uHAAA,kBAAkB,OAAA;AAClB,0HAAA,qBAAqB,OAAA;AACrB,wHAAA,mBAAmB,OAAA;AAEpB,uCAUoB;AATnB,iGAAA,KAAK,OAAA;AAEL,uGAAA,WAAW,OAAA;AAGX,sGAAA,UAAU,OAAA;AAEV,sGAAA,UAAU,OAAA;AACV,mGAAA,OAAO,OAAA;AAER,qDAAyE;AAAhE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAC7C,yCAKqB;AAJpB,wGAAA,WAAW,OAAA;AACX,8GAAA,iBAAiB,OAAA;AAIlB,+CAgBwB;AAfvB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAA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OAAA;AACT,oHAAA,wBAAwB,OAAA;AACxB,wGAAA,qBAAqB,OAAgB;AACrC,2GAAA,eAAe,OAAA;AAEhB,+DAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAc7B,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,iDAMyB;AAFxB,uHAAA,sBAAsB,OAAA;AACtB,4GAAA,WAAW,OAAA;AAGZ,6CAIuB;AAHtB,uGAAA,QAAQ,OAAA;AAER,iHAAA,kBAAkB,OAAA;AAGnB,mDAM0B;AAJzB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AAEpB,iHAAA,eAAe,OAAA;AAGhB,+CAMwB;AALvB,yGAAA,SAAS,OAAA;AAET,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AAGd,iDAKyB;AAHxB,8GAAA,aAAa,OAAA;AACb,iHAAA,gBAAgB,OAAA;AAChB,sHAAA,qBAAqB,OAAA;AAGtB,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAE9B,6DAAiE;AAAxD,+HAAA,wBAAwB,OAAA;AAEjC,uDAgB4B;AAZ3B,iHAAA,aAAa,OAAA;AACb,8HAAA,0BAA0B,OAAA;AAG1B,iIAAA,6BAA6B,OAAA;AAC7B,iIAAA,6BAA6B,OAAA;AAC7B,oIAAA,gCAAgC,OAAA;AAChC,sIAAA,kCAAkC,OAAA;AAClC,gIAAA,4BAA4B,OAAA;AAC5B,qHAAA,iBAAiB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tcollectContiguousRanges,\n\ttype IndexRange,\n\tvalidateIndex,\n\tvalidateIndexRange,\n\tvalidatePositiveIndex,\n\tvalidateSafeInteger,\n} from \"./arrayUtilities.js\";\nexport {\n\tbrand,\n\ttype Brand,\n\tBrandedType,\n\ttype NameFromBranded,\n\ttype ValueFromBranded,\n\tbrandConst,\n\ttype Values,\n\tstrictEnum,\n\tunbrand,\n} from \"./brand.js\";\nexport { brandedNumberType, brandedStringType } from \"./typeboxBrand.js\";\nexport {\n\tbrandOpaque,\n\textractFromOpaque,\n\ttype ExtractFromOpaque,\n\ttype Opaque,\n} from \"./opaque.js\";\nexport {\n\tdeleteFromNestedMap,\n\tgetOrAddInNestedMap,\n\tgetOrDefaultInNestedMap,\n\tforEachInNestedMap,\n\ttype NestedMap,\n\ttype ReadonlyNestedMap,\n\tSizedNestedMap,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryAddToNestedMap,\n\ttryGetFromNestedMap,\n\tmapNestedMap,\n\tnestedMapToFlatList,\n\tnestedMapFromFlatList,\n\tgetOrCreateInNestedMap,\n} from \"./nestedMap.js\";\nexport { addToNestedSet, type NestedSet, nestedSetContains } from \"./nestedSet.js\";\nexport { type OffsetList, OffsetListFactory } from \"./offsetList.js\";\nexport type {\n\tareSafelyAssignable,\n\tContravariant,\n\tCovariant,\n\teitherIsAny,\n\tEnforceTypeCheckTests,\n\tInvariant,\n\tisAny,\n\tisAssignableTo,\n\tisStrictSubset,\n\tMakeNominal,\n\trequireFalse,\n\trequireTrue,\n\trequireAssignableTo,\n\tareOnlyKeys,\n} from \"./typeCheck.js\";\nexport { StackyIterator } from \"./stackyIterator.js\";\nexport {\n\tasMutable,\n\tbalancedReduce,\n\tcompareSets,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n\tisJsonObject,\n\tisReadonlyArray,\n\ttype JsonCompatible,\n\ttype JsonCompatibleObject,\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatibleReadOnlyObject,\n\tJsonCompatibleReadOnlySchema,\n\tmakeArray,\n\tmapIterable,\n\tfilterIterable,\n\ttype Mutable,\n\ttype Populated,\n\ttype RecursiveReadonly,\n\tassertValidIndex,\n\tassertValidRange,\n\tassertNonNegativeSafeInteger,\n\tobjectToMap,\n\tinvertMap,\n\toneFromIterable,\n\tdisposeSymbol,\n\ttype IDisposable,\n\tcapitalize,\n\tassertValidRangeIndices,\n\ttransformObjectMap,\n\tcompareNumbers,\n\tcomparePartialNumbers,\n\tcompareStrings,\n\tcomparePartialStrings,\n\tfind,\n\tcount,\n\tgetLast,\n\thasSome,\n\thasSingle,\n\tdefineLazyCachedProperty,\n\tcopyPropertyIfDefined as copyProperty,\n\titerableHasSome,\n} from \"./utils.js\";\nexport { ReferenceCountedBase, type ReferenceCounted } from \"./referenceCounting.js\";\n\nexport type {\n\t_RecursiveTrick,\n\tRestrictiveReadonlyRecord,\n\tRestrictiveStringRecord,\n\t_InlineTrick,\n\tFlattenKeys,\n\tIsUnion,\n\tUnionToIntersection,\n\tUnionToTuple,\n\tPopUnion,\n} from \"./typeUtils.js\";\n\nexport { unsafeArrayToTuple } from \"./typeUtils.js\";\n\nexport {\n\ttype BrandedKey,\n\ttype BrandedKeyContent,\n\ttype BrandedMapSubset,\n\tgetOrCreateSlotContent,\n\tbrandedSlot,\n} from \"./brandedMap.js\";\n\nexport {\n\tRangeMap,\n\ttype RangeQueryResult,\n\tnewIntegerRangeMap,\n} from \"./rangeMap.js\";\n\nexport {\n\ttype IdAllocator,\n\tidAllocatorFromMaxId,\n\tidAllocatorFromState,\n\ttype IdAllocationState,\n\tfakeIdAllocator,\n} from \"./idAllocator.js\";\n\nexport {\n\tBreakable,\n\ttype WithBreakable,\n\tbreakingMethod,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"./breakable.js\";\n\nexport {\n\ttype TupleBTree,\n\tnewTupleBTree,\n\tmergeTupleBTrees,\n\tcreateTupleComparator,\n} from \"./bTreeUtils.js\";\n\nexport { cloneWithReplacements } from \"./cloneWithReplacements.js\";\n\nexport { readAndParseSnapshotBlob } from \"./readSnapshotBlob.js\";\n\nexport {\n\ttype OriginatorlessEncodedId,\n\ttype OriginatorDependentEncodedId,\n\ttype IdentifierHealingConfig,\n\tEncodedIdType,\n\tencodePossiblyCompressedId,\n\ttype IdEncodingContext,\n\ttype EncodedId,\n\tdecodeOriginatorlessEncodedId,\n\tdecodeEncodedIdWithOriginator,\n\ttryDecodeEncodedIdWithoutSession,\n\tforceDecodeEncodedIdWithoutSession,\n\tdecompressIdentifierIfNeeded,\n\tIdDecodingContext,\n\ttype IdDecoderOptionsOriginatorless,\n\ttype IdDecoderOptionsWithOriginator,\n} from \"./compressedIds.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nestedMap.d.ts","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/F;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAClD,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EACjC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACV,KAAK,GAAG,SAAS,CAWnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAClD,MAAM,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAC5C,WAAW,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EACzC,QAAQ,EAAE,OAAO,GACf,IAAI,CAcN;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAC/C,GAAG,EAAE,SAA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CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAI9E;;OAEG;IACI,KAAK,IAAI,IAAI;IAKb,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC;IAIjC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;CAGtE"}
@@ -50,12 +50,25 @@ function populateNestedMap(source, destination, override) {
50
50
  }
51
51
  }
52
52
  exports.populateNestedMap = populateNestedMap;
53
+ /**
54
+ * Sets the value at `key` in map to new Map if not already present.
55
+ * Returns the value at `key` after setting it.
56
+ */
57
+ function getOrAddInMap(map, key1) {
58
+ const currentValue = map.get(key1);
59
+ if (currentValue !== undefined) {
60
+ return currentValue;
61
+ }
62
+ const value = new Map();
63
+ map.set(key1, value);
64
+ return value;
65
+ }
53
66
  /**
54
67
  * Sets the value at (key1, key2) in map to value.
55
68
  * If there already is a value for (key1, key2), it is replaced with the provided one.
56
69
  */
57
70
  function setInNestedMap(map, key1, key2, value) {
58
- const innerMap = (0, utils_js_1.getOrAddInMap)(map, key1, new Map());
71
+ const innerMap = getOrAddInMap(map, key1);
59
72
  innerMap.set(key2, value);
60
73
  }
61
74
  exports.setInNestedMap = setInNestedMap;
@@ -63,7 +76,7 @@ exports.setInNestedMap = setInNestedMap;
63
76
  * {@link getOrCreate} for {@link NestedMap}.
64
77
  */
65
78
  function getOrCreateInNestedMap(map, key1, key2, defaultValue) {
66
- const innerMap = (0, utils_js_1.getOrAddInMap)(map, key1, new Map());
79
+ const innerMap = getOrAddInMap(map, key1);
67
80
  return (0, utils_js_1.getOrCreate)(innerMap, key2, () => defaultValue(key1, key2));
68
81
  }
69
82
  exports.getOrCreateInNestedMap = getOrCreateInNestedMap;
@@ -139,7 +152,7 @@ exports.nestedMapToFlatList = nestedMapToFlatList;
139
152
  function nestedMapFromFlatList(list) {
140
153
  const map = new Map();
141
154
  for (const [key1, key2, val] of list) {
142
- (0, utils_js_1.getOrAddInMap)(map, key1, new Map()).set(key2, val);
155
+ getOrAddInMap(map, key1).set(key2, val);
143
156
  }
144
157
  return map;
145
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,yCAAwD;AAgBxD;;GAEG;AACH,SAAgB,iBAAiB,CAChC,GAAiC,EACjC,IAAU,EACV,IAAU,EACV,KAAY;IAEZ,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QACrB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,OAAO,SAAS,CAAC;AAClB,CAAC;AAhBD,8CAgBC;AAED;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAChC,MAA4C,EAC5C,WAAyC,EACzC,QAAiB;IAEjB,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,EAAE,CAAC;QAC1C,IAAI,gBAAgB,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACpC,gBAAgB,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;YACxC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,gB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EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAU,EAAE,IAAU;QACnC,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,QAAwD;QACtE,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IAC1F,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD;AApFD,wCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrAddInMap, getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tfor (const [key1, innerMap] of map) {\n\t\tfor (const [key2, val] of innerMap) {\n\t\t\tlist.push([key1, key2, val]);\n\t\t}\n\t}\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tfor (const [keyFirst, innerMap] of map) {\n\t\tfor (const [keySecond, val] of innerMap) {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t}\n\t}\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tfor (const [keyFirst, inputInnerMap] of input) {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tfor (const [keySecond, val] of inputInnerMap) {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t}\n\t\toutput.set(keyFirst, outputInnerMap);\n\t}\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? oob();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
1
+ {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA0D;AAE1D,yCAAyC;AAgBzC;;GAEG;AACH,SAAgB,iBAAiB,CAChC,GAAiC,EACjC,IAAU,EACV,IAAU,EACV,KAAY;IAEZ,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QACrB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,C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ACI,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IAC1F,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD;AApFD,wCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at `key` in map to new Map if not already present.\n * Returns the value at `key` after setting it.\n */\nfunction getOrAddInMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n): Map<Key2, Value> {\n\tconst currentValue = map.get(key1);\n\tif (currentValue !== undefined) {\n\t\treturn currentValue;\n\t}\n\tconst value = new Map<Key2, Value>();\n\tmap.set(key1, value);\n\treturn value;\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1);\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1);\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tfor (const [key1, innerMap] of map) {\n\t\tfor (const [key2, val] of innerMap) {\n\t\t\tlist.push([key1, key2, val]);\n\t\t}\n\t}\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tfor (const [keyFirst, innerMap] of map) {\n\t\tfor (const [keySecond, val] of innerMap) {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t}\n\t}\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tfor (const [keyFirst, inputInnerMap] of input) {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tfor (const [keySecond, val] of inputInnerMap) {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t}\n\t\toutput.set(keyFirst, outputInnerMap);\n\t}\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? oob();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type NestedMap } from "./nestedMap.js";
6
- export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, boolean>;
6
+ export type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, true>;
7
7
  export declare function addToNestedSet<Key1, Key2>(set: NestedSet<Key1, Key2>, key1: Key1, key2: Key2): void;
8
8
  export declare function nestedSetContains<Key1, Key2>(set: NestedSet<Key1, Key2>, key1: Key1, key2: Key2): boolean;
9
9
  //# sourceMappingURL=nestedSet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nestedSet.d.ts","sourceRoot":"","sources":["../../src/util/nestedSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,SAAS,EAA2C,MAAM,gBAAgB,CAAC;AAEzF,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAEnE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EACxC,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,GACR,IAAI,CAEN;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAC3C,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,GACR,OAAO,CAET"}
1
+ {"version":3,"file":"nestedSet.d.ts","sourceRoot":"","sources":["../../src/util/nestedSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,SAAS,EAA2C,MAAM,gBAAgB,CAAC;AAEzF,MAAM,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEhE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EACxC,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,GACR,IAAI,CAEN;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAC3C,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,GACR,OAAO,CAET"}
@@ -1 +1 @@
1
- {"version":3,"file":"nestedSet.js","sourceRoot":"","sources":["../../src/util/nestedSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAyF;AAIzF,SAAgB,cAAc,CAC7B,GAA0B,EAC1B,IAAU,EACV,IAAU;IAEV,IAAA,6BAAc,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAND,wCAMC;AAED,SAAgB,iBAAiB,CAChC,GAA0B,EAC1B,IAAU,EACV,IAAU;IAEV,OAAO,IAAA,sCAAuB,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from \"./nestedMap.js\";\n\nexport type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, boolean>;\n\nexport function addToNestedSet<Key1, Key2>(\n\tset: NestedSet<Key1, Key2>,\n\tkey1: Key1,\n\tkey2: Key2,\n): void {\n\tsetInNestedMap(set, key1, key2, true);\n}\n\nexport function nestedSetContains<Key1, Key2>(\n\tset: NestedSet<Key1, Key2>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\treturn getOrDefaultInNestedMap(set, key1, key2, false);\n}\n"]}
1
+ {"version":3,"file":"nestedSet.js","sourceRoot":"","sources":["../../src/util/nestedSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAyF;AAIzF,SAAgB,cAAc,CAC7B,GAA0B,EAC1B,IAAU,EACV,IAAU;IAEV,IAAA,6BAAc,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAND,wCAMC;AAED,SAAgB,iBAAiB,CAChC,GAA0B,EAC1B,IAAU,EACV,IAAU;IAEV,OAAO,IAAA,sCAAuB,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type NestedMap, getOrDefaultInNestedMap, setInNestedMap } from \"./nestedMap.js\";\n\nexport type NestedSet<Key1, Key2> = NestedMap<Key1, Key2, true>;\n\nexport function addToNestedSet<Key1, Key2>(\n\tset: NestedSet<Key1, Key2>,\n\tkey1: Key1,\n\tkey2: Key2,\n): void {\n\tsetInNestedMap(set, key1, key2, true);\n}\n\nexport function nestedSetContains<Key1, Key2>(\n\tset: NestedSet<Key1, Key2>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\treturn getOrDefaultInNestedMap(set, key1, key2, false);\n}\n"]}
@@ -107,12 +107,6 @@ export declare function compareSets<T>({ a, b, aExtra, bExtra, same, }: {
107
107
  bExtra?: (t: T) => boolean;
108
108
  same?: (t: T) => boolean;
109
109
  }): boolean;
110
- /**
111
- * Sets the value at `key` in map to value if not already present.
112
- * Returns the value at `key` after setting it.
113
- * This is equivalent to a get or default that adds the default to the map.
114
- */
115
- export declare function getOrAddInMap<Key, Value>(map: MapGetSet<Key, Value>, key: Key, value: Value): Value;
116
110
  /**
117
111
  * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.
118
112
  * @param map - The map to query/update