@pierre/diffs 1.3.0-beta.1 → 1.3.0-beta.11

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 (705) hide show
  1. package/README.md +15 -15
  2. package/dist/components/CodeView.d.ts +103 -15
  3. package/dist/components/CodeView.d.ts.map +1 -1
  4. package/dist/components/CodeView.js +335 -51
  5. package/dist/components/CodeView.js.map +1 -1
  6. package/dist/components/File.d.ts +12 -8
  7. package/dist/components/File.d.ts.map +1 -1
  8. package/dist/components/File.js +103 -40
  9. package/dist/components/File.js.map +1 -1
  10. package/dist/components/FileDiff.d.ts +82 -36
  11. package/dist/components/FileDiff.d.ts.map +1 -1
  12. package/dist/components/FileDiff.js +382 -96
  13. package/dist/components/FileDiff.js.map +1 -1
  14. package/dist/components/FileStream.d.ts +0 -1
  15. package/dist/components/FileStream.d.ts.map +1 -1
  16. package/dist/components/FileStream.js +10 -7
  17. package/dist/components/FileStream.js.map +1 -1
  18. package/dist/components/UnresolvedFile.d.ts +3 -3
  19. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  20. package/dist/components/UnresolvedFile.js +8 -6
  21. package/dist/components/UnresolvedFile.js.map +1 -1
  22. package/dist/components/VirtualizedFile.d.ts +8 -4
  23. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  24. package/dist/components/VirtualizedFile.js +118 -44
  25. package/dist/components/VirtualizedFile.js.map +1 -1
  26. package/dist/components/VirtualizedFileDiff.d.ts +36 -9
  27. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  28. package/dist/components/VirtualizedFileDiff.js +371 -120
  29. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  30. package/dist/components/Virtualizer.d.ts +4 -1
  31. package/dist/components/Virtualizer.d.ts.map +1 -1
  32. package/dist/components/Virtualizer.js +47 -29
  33. package/dist/components/Virtualizer.js.map +1 -1
  34. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  35. package/dist/components/web-components.d.ts.map +1 -1
  36. package/dist/components/web-components.js +2 -3
  37. package/dist/components/web-components.js.map +1 -1
  38. package/dist/constants.d.ts +5 -2
  39. package/dist/constants.d.ts.map +1 -1
  40. package/dist/constants.js +5 -2
  41. package/dist/constants.js.map +1 -1
  42. package/dist/editor/command.d.ts +3 -2
  43. package/dist/editor/command.d.ts.map +1 -1
  44. package/dist/editor/command.js +29 -6
  45. package/dist/editor/command.js.map +1 -1
  46. package/dist/editor/editStack.d.ts +12 -2
  47. package/dist/editor/editStack.d.ts.map +1 -1
  48. package/dist/editor/editStack.js +57 -16
  49. package/dist/editor/editStack.js.map +1 -1
  50. package/dist/editor/editor.d.ts +91 -8
  51. package/dist/editor/editor.d.ts.map +1 -1
  52. package/dist/editor/editor.js +1951 -709
  53. package/dist/editor/editor.js.map +1 -1
  54. package/dist/editor/editor2.js +6 -0
  55. package/dist/editor/editor2.js.map +1 -0
  56. package/dist/editor/index.d.ts +4 -2
  57. package/dist/editor/index.js +1 -2
  58. package/dist/editor/languages.d.ts +26 -0
  59. package/dist/editor/languages.d.ts.map +1 -0
  60. package/dist/editor/languages.js +363 -0
  61. package/dist/editor/languages.js.map +1 -0
  62. package/dist/editor/lineAnnotations.d.ts +2 -1
  63. package/dist/editor/lineAnnotations.d.ts.map +1 -1
  64. package/dist/editor/lineAnnotations.js +193 -13
  65. package/dist/editor/lineAnnotations.js.map +1 -1
  66. package/dist/editor/marker.d.ts +38 -0
  67. package/dist/editor/marker.d.ts.map +1 -0
  68. package/dist/editor/marker.js +245 -0
  69. package/dist/editor/marker.js.map +1 -0
  70. package/dist/editor/matchBrackets.d.ts +9 -0
  71. package/dist/editor/matchBrackets.d.ts.map +1 -0
  72. package/dist/editor/matchBrackets.js +138 -0
  73. package/dist/editor/matchBrackets.js.map +1 -0
  74. package/dist/editor/pieceTable.d.ts +15 -7
  75. package/dist/editor/pieceTable.d.ts.map +1 -1
  76. package/dist/editor/pieceTable.js +306 -190
  77. package/dist/editor/pieceTable.js.map +1 -1
  78. package/dist/editor/platform.d.ts +8 -1
  79. package/dist/editor/platform.d.ts.map +1 -1
  80. package/dist/editor/platform.js +18 -5
  81. package/dist/editor/platform.js.map +1 -1
  82. package/dist/editor/popover.d.ts +65 -0
  83. package/dist/editor/popover.d.ts.map +1 -0
  84. package/dist/editor/popover.js +191 -0
  85. package/dist/editor/popover.js.map +1 -0
  86. package/dist/editor/searchPanel.d.ts +17 -7
  87. package/dist/editor/searchPanel.d.ts.map +1 -1
  88. package/dist/editor/searchPanel.js +268 -169
  89. package/dist/editor/searchPanel.js.map +1 -1
  90. package/dist/editor/selection.d.ts +101 -16
  91. package/dist/editor/selection.d.ts.map +1 -1
  92. package/dist/editor/selection.js +863 -137
  93. package/dist/editor/selection.js.map +1 -1
  94. package/dist/editor/selectionAction.d.ts +46 -0
  95. package/dist/editor/selectionAction.d.ts.map +1 -0
  96. package/dist/editor/selectionAction.js +64 -0
  97. package/dist/editor/selectionAction.js.map +1 -0
  98. package/dist/editor/sprite.d.ts +8 -0
  99. package/dist/editor/sprite.d.ts.map +1 -0
  100. package/dist/editor/sprite.js +45 -0
  101. package/dist/editor/sprite.js.map +1 -0
  102. package/dist/editor/stateStorage.d.ts +15 -0
  103. package/dist/editor/stateStorage.d.ts.map +1 -0
  104. package/dist/editor/stateStorage.js +65 -0
  105. package/dist/editor/stateStorage.js.map +1 -0
  106. package/dist/editor/textDocument.d.ts +21 -83
  107. package/dist/editor/textDocument.d.ts.map +1 -1
  108. package/dist/editor/textDocument.js +117 -48
  109. package/dist/editor/textDocument.js.map +1 -1
  110. package/dist/editor/textMeasure.d.ts +31 -2
  111. package/dist/editor/textMeasure.d.ts.map +1 -1
  112. package/dist/editor/textMeasure.js +122 -21
  113. package/dist/editor/textMeasure.js.map +1 -1
  114. package/dist/editor/{tokenzier.d.ts → tokenizer.d.ts} +16 -12
  115. package/dist/editor/tokenizer.d.ts.map +1 -0
  116. package/dist/editor/tokenizer.js +518 -0
  117. package/dist/editor/tokenizer.js.map +1 -0
  118. package/dist/editor/utils.d.ts +6 -1
  119. package/dist/editor/utils.d.ts.map +1 -1
  120. package/dist/editor/utils.js +34 -3
  121. package/dist/editor/utils.js.map +1 -1
  122. package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
  123. package/dist/highlighter/languages/areLanguagesAttached.js +1 -2
  124. package/dist/highlighter/languages/areLanguagesAttached.js.map +1 -1
  125. package/dist/highlighter/languages/attachResolvedLanguages.d.ts +0 -2
  126. package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
  127. package/dist/highlighter/languages/attachResolvedLanguages.js +1 -2
  128. package/dist/highlighter/languages/attachResolvedLanguages.js.map +1 -1
  129. package/dist/highlighter/languages/cleanUpResolvedLanguages.d.ts.map +1 -1
  130. package/dist/highlighter/languages/cleanUpResolvedLanguages.js +1 -2
  131. package/dist/highlighter/languages/cleanUpResolvedLanguages.js.map +1 -1
  132. package/dist/highlighter/languages/constants.d.ts +0 -1
  133. package/dist/highlighter/languages/constants.d.ts.map +1 -1
  134. package/dist/highlighter/languages/constants.js +1 -1
  135. package/dist/highlighter/languages/constants.js.map +1 -1
  136. package/dist/highlighter/languages/getResolvedLanguages.d.ts +0 -2
  137. package/dist/highlighter/languages/getResolvedLanguages.d.ts.map +1 -1
  138. package/dist/highlighter/languages/getResolvedLanguages.js +1 -2
  139. package/dist/highlighter/languages/getResolvedLanguages.js.map +1 -1
  140. package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +0 -2
  141. package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts.map +1 -1
  142. package/dist/highlighter/languages/getResolvedOrResolveLanguage.js +1 -2
  143. package/dist/highlighter/languages/getResolvedOrResolveLanguage.js.map +1 -1
  144. package/dist/highlighter/languages/hasResolvedLanguages.d.ts.map +1 -1
  145. package/dist/highlighter/languages/hasResolvedLanguages.js +1 -2
  146. package/dist/highlighter/languages/hasResolvedLanguages.js.map +1 -1
  147. package/dist/highlighter/languages/registerCustomLanguage.d.ts +0 -1
  148. package/dist/highlighter/languages/registerCustomLanguage.d.ts.map +1 -1
  149. package/dist/highlighter/languages/registerCustomLanguage.js +1 -2
  150. package/dist/highlighter/languages/registerCustomLanguage.js.map +1 -1
  151. package/dist/highlighter/languages/resolveLanguage.d.ts +0 -2
  152. package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
  153. package/dist/highlighter/languages/resolveLanguage.js +4 -5
  154. package/dist/highlighter/languages/resolveLanguage.js.map +1 -1
  155. package/dist/highlighter/languages/resolveLanguages.d.ts +0 -2
  156. package/dist/highlighter/languages/resolveLanguages.d.ts.map +1 -1
  157. package/dist/highlighter/languages/resolveLanguages.js +1 -2
  158. package/dist/highlighter/languages/resolveLanguages.js.map +1 -1
  159. package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
  160. package/dist/highlighter/shared_highlighter.js +6 -33
  161. package/dist/highlighter/shared_highlighter.js.map +1 -1
  162. package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
  163. package/dist/highlighter/themes/areThemesAttached.js +1 -2
  164. package/dist/highlighter/themes/areThemesAttached.js.map +1 -1
  165. package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
  166. package/dist/highlighter/themes/attachResolvedThemes.js +5 -5
  167. package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
  168. package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
  169. package/dist/highlighter/themes/cleanUpResolvedThemes.js +4 -4
  170. package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
  171. package/dist/highlighter/themes/constants.d.ts +1 -7
  172. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  173. package/dist/highlighter/themes/constants.js +2 -5
  174. package/dist/highlighter/themes/constants.js.map +1 -1
  175. package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
  176. package/dist/highlighter/themes/getResolvedOrResolveTheme.js +3 -4
  177. package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
  178. package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
  179. package/dist/highlighter/themes/getResolvedThemes.js +3 -10
  180. package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
  181. package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
  182. package/dist/highlighter/themes/hasResolvedThemes.js +3 -5
  183. package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
  184. package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
  185. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +2 -3
  186. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js.map +1 -1
  187. package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
  188. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  189. package/dist/highlighter/themes/registerCustomTheme.js +16 -7
  190. package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
  191. package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
  192. package/dist/highlighter/themes/resolveTheme.js +7 -29
  193. package/dist/highlighter/themes/resolveTheme.js.map +1 -1
  194. package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
  195. package/dist/highlighter/themes/resolveThemes.js +6 -14
  196. package/dist/highlighter/themes/resolveThemes.js.map +1 -1
  197. package/dist/highlighter/themes/themeResolution.d.ts +8 -0
  198. package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
  199. package/dist/highlighter/themes/themeResolution.js +21 -0
  200. package/dist/highlighter/themes/themeResolution.js.map +1 -0
  201. package/dist/highlighter/themes/themeResolver.d.ts +8 -0
  202. package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
  203. package/dist/highlighter/themes/themeResolver.js +7 -0
  204. package/dist/highlighter/themes/themeResolver.js.map +1 -0
  205. package/dist/index.d.ts +16 -14
  206. package/dist/index.js +13 -12
  207. package/dist/managers/InteractionManager.d.ts +20 -2
  208. package/dist/managers/InteractionManager.d.ts.map +1 -1
  209. package/dist/managers/InteractionManager.js +159 -83
  210. package/dist/managers/InteractionManager.js.map +1 -1
  211. package/dist/managers/ResizeManager.d.ts +10 -2
  212. package/dist/managers/ResizeManager.d.ts.map +1 -1
  213. package/dist/managers/ResizeManager.js +35 -15
  214. package/dist/managers/ResizeManager.js.map +1 -1
  215. package/dist/managers/ScrollSyncManager.d.ts.map +1 -1
  216. package/dist/managers/ScrollSyncManager.js +1 -1
  217. package/dist/managers/ScrollSyncManager.js.map +1 -1
  218. package/dist/managers/UniversalRenderingManager.d.ts +2 -1
  219. package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
  220. package/dist/managers/UniversalRenderingManager.js +8 -3
  221. package/dist/managers/UniversalRenderingManager.js.map +1 -1
  222. package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts +228 -0
  223. package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts.map +1 -0
  224. package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +84 -0
  225. package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts.map +1 -0
  226. package/dist/react/CodeView.d.ts +26 -2
  227. package/dist/react/CodeView.d.ts.map +1 -1
  228. package/dist/react/CodeView.js +90 -30
  229. package/dist/react/CodeView.js.map +1 -1
  230. package/dist/react/EditContext.d.ts +15 -0
  231. package/dist/react/EditContext.d.ts.map +1 -0
  232. package/dist/react/EditContext.js +23 -0
  233. package/dist/react/EditContext.js.map +1 -0
  234. package/dist/react/File.d.ts +1 -0
  235. package/dist/react/File.d.ts.map +1 -1
  236. package/dist/react/File.js +4 -6
  237. package/dist/react/File.js.map +1 -1
  238. package/dist/react/FileDiff.d.ts +1 -0
  239. package/dist/react/FileDiff.d.ts.map +1 -1
  240. package/dist/react/FileDiff.js +4 -6
  241. package/dist/react/FileDiff.js.map +1 -1
  242. package/dist/react/MultiFileDiff.d.ts +4 -4
  243. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  244. package/dist/react/MultiFileDiff.js +4 -6
  245. package/dist/react/MultiFileDiff.js.map +1 -1
  246. package/dist/react/PatchDiff.d.ts +1 -0
  247. package/dist/react/PatchDiff.d.ts.map +1 -1
  248. package/dist/react/PatchDiff.js +4 -6
  249. package/dist/react/PatchDiff.js.map +1 -1
  250. package/dist/react/UnresolvedFile.d.ts +2 -1
  251. package/dist/react/UnresolvedFile.d.ts.map +1 -1
  252. package/dist/react/UnresolvedFile.js +4 -6
  253. package/dist/react/UnresolvedFile.js.map +1 -1
  254. package/dist/react/Virtualizer.d.ts.map +1 -1
  255. package/dist/react/Virtualizer.js +2 -5
  256. package/dist/react/Virtualizer.js.map +1 -1
  257. package/dist/react/WorkerPoolContext.d.ts +0 -1
  258. package/dist/react/WorkerPoolContext.d.ts.map +1 -1
  259. package/dist/react/WorkerPoolContext.js +2 -5
  260. package/dist/react/WorkerPoolContext.js.map +1 -1
  261. package/dist/react/constants.d.ts.map +1 -1
  262. package/dist/react/constants.js +1 -1
  263. package/dist/react/constants.js.map +1 -1
  264. package/dist/react/index.d.ts +3 -3
  265. package/dist/react/index.js +2 -3
  266. package/dist/react/jsx.d.ts +0 -1
  267. package/dist/react/jsx.d.ts.map +1 -1
  268. package/dist/react/types.d.ts +2 -0
  269. package/dist/react/types.d.ts.map +1 -1
  270. package/dist/react/types.js +1 -0
  271. package/dist/react/utils/renderDiffChildren.d.ts +2 -0
  272. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  273. package/dist/react/utils/renderDiffChildren.js +18 -11
  274. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  275. package/dist/react/utils/renderFileChildren.d.ts +2 -0
  276. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  277. package/dist/react/utils/renderFileChildren.js +18 -11
  278. package/dist/react/utils/renderFileChildren.js.map +1 -1
  279. package/dist/react/utils/templateRender.d.ts.map +1 -1
  280. package/dist/react/utils/templateRender.js +1 -2
  281. package/dist/react/utils/templateRender.js.map +1 -1
  282. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  283. package/dist/react/utils/useFileDiffInstance.js +10 -18
  284. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  285. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  286. package/dist/react/utils/useFileInstance.js +3 -7
  287. package/dist/react/utils/useFileInstance.js.map +1 -1
  288. package/dist/react/utils/useStableCallback.d.ts.map +1 -1
  289. package/dist/react/utils/useStableCallback.js +1 -2
  290. package/dist/react/utils/useStableCallback.js.map +1 -1
  291. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  292. package/dist/react/utils/useUnresolvedFileInstance.js +10 -11
  293. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  294. package/dist/renderers/DiffHunksRenderer.d.ts +30 -4
  295. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  296. package/dist/renderers/DiffHunksRenderer.js +313 -45
  297. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  298. package/dist/renderers/FileRenderer.d.ts +7 -6
  299. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  300. package/dist/renderers/FileRenderer.js +113 -56
  301. package/dist/renderers/FileRenderer.js.map +1 -1
  302. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +1 -2
  303. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
  304. package/dist/renderers/UnresolvedFileHunksRenderer.js +1 -2
  305. package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
  306. package/dist/shiki-stream/index.js +1 -2
  307. package/dist/shiki-stream/stream.d.ts +0 -1
  308. package/dist/shiki-stream/stream.d.ts.map +1 -1
  309. package/dist/shiki-stream/stream.js +1 -2
  310. package/dist/shiki-stream/stream.js.map +1 -1
  311. package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
  312. package/dist/shiki-stream/tokenizer.js +1 -1
  313. package/dist/shiki-stream/tokenizer.js.map +1 -1
  314. package/dist/shiki-stream/types.d.ts +0 -1
  315. package/dist/shiki-stream/types.d.ts.map +1 -1
  316. package/dist/sprite.d.ts.map +1 -1
  317. package/dist/sprite.js +1 -1
  318. package/dist/ssr/FileDiffReact.d.ts.map +1 -1
  319. package/dist/ssr/FileDiffReact.js +4 -7
  320. package/dist/ssr/FileDiffReact.js.map +1 -1
  321. package/dist/ssr/index.d.ts +2 -2
  322. package/dist/ssr/index.js +1 -2
  323. package/dist/ssr/preloadDiffs.d.ts +12 -11
  324. package/dist/ssr/preloadDiffs.d.ts.map +1 -1
  325. package/dist/ssr/preloadDiffs.js +16 -9
  326. package/dist/ssr/preloadDiffs.js.map +1 -1
  327. package/dist/ssr/preloadFile.d.ts.map +1 -1
  328. package/dist/ssr/preloadFile.js +1 -2
  329. package/dist/ssr/preloadFile.js.map +1 -1
  330. package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
  331. package/dist/ssr/preloadPatchFile.js +2 -3
  332. package/dist/ssr/preloadPatchFile.js.map +1 -1
  333. package/dist/ssr/renderHTML.d.ts +1 -1
  334. package/dist/ssr/renderHTML.d.ts.map +1 -1
  335. package/dist/ssr/renderHTML.js +1 -2
  336. package/dist/ssr/renderHTML.js.map +1 -1
  337. package/dist/string-import.d.ts +4 -0
  338. package/dist/string-import.d.ts.map +1 -1
  339. package/dist/style.js +3 -3
  340. package/dist/style.js.map +1 -1
  341. package/dist/types.d.ts +278 -31
  342. package/dist/types.d.ts.map +1 -1
  343. package/dist/utils/applyLineTextWithNewline.d.ts +5 -0
  344. package/dist/utils/applyLineTextWithNewline.d.ts.map +1 -0
  345. package/dist/utils/applyLineTextWithNewline.js +11 -0
  346. package/dist/utils/applyLineTextWithNewline.js.map +1 -0
  347. package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -1
  348. package/dist/utils/areDiffLineAnnotationsEqual.js +1 -1
  349. package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -1
  350. package/dist/utils/areDiffRenderOptionsEqual.d.ts.map +1 -1
  351. package/dist/utils/areDiffRenderOptionsEqual.js +1 -2
  352. package/dist/utils/areDiffRenderOptionsEqual.js.map +1 -1
  353. package/dist/utils/areDiffTargetsEqual.d.ts.map +1 -1
  354. package/dist/utils/areDiffTargetsEqual.js +1 -1
  355. package/dist/utils/areDiffTargetsEqual.js.map +1 -1
  356. package/dist/utils/areFileRenderOptionsEqual.d.ts.map +1 -1
  357. package/dist/utils/areFileRenderOptionsEqual.js +1 -2
  358. package/dist/utils/areFileRenderOptionsEqual.js.map +1 -1
  359. package/dist/utils/areFilesEqual.d.ts.map +1 -1
  360. package/dist/utils/areFilesEqual.js +1 -1
  361. package/dist/utils/areFilesEqual.js.map +1 -1
  362. package/dist/utils/areHunkDataEqual.d.ts.map +1 -1
  363. package/dist/utils/areHunkDataEqual.js +2 -2
  364. package/dist/utils/areHunkDataEqual.js.map +1 -1
  365. package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -1
  366. package/dist/utils/areLineAnnotationsEqual.js +1 -1
  367. package/dist/utils/areLineAnnotationsEqual.js.map +1 -1
  368. package/dist/utils/areManagedSnapshotsEqual.d.ts +2 -2
  369. package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
  370. package/dist/utils/areManagedSnapshotsEqual.js +6 -1
  371. package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
  372. package/dist/utils/areMergeConflictActionsEqual.d.ts.map +1 -1
  373. package/dist/utils/areMergeConflictActionsEqual.js +1 -1
  374. package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
  375. package/dist/utils/areObjectsEqual.d.ts.map +1 -1
  376. package/dist/utils/areObjectsEqual.js +1 -1
  377. package/dist/utils/areObjectsEqual.js.map +1 -1
  378. package/dist/utils/areOptionsEqual.d.ts +0 -2
  379. package/dist/utils/areOptionsEqual.d.ts.map +1 -1
  380. package/dist/utils/areOptionsEqual.js +1 -2
  381. package/dist/utils/areOptionsEqual.js.map +1 -1
  382. package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -1
  383. package/dist/utils/arePrePropertiesEqual.js +1 -1
  384. package/dist/utils/arePrePropertiesEqual.js.map +1 -1
  385. package/dist/utils/areRenderRangesEqual.d.ts.map +1 -1
  386. package/dist/utils/areRenderRangesEqual.js +1 -1
  387. package/dist/utils/areRenderRangesEqual.js.map +1 -1
  388. package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -1
  389. package/dist/utils/areSelectionPointsEqual.js +1 -1
  390. package/dist/utils/areSelectionPointsEqual.js.map +1 -1
  391. package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
  392. package/dist/utils/areSelectionsEqual.js +1 -1
  393. package/dist/utils/areSelectionsEqual.js.map +1 -1
  394. package/dist/utils/areThemesEqual.d.ts.map +1 -1
  395. package/dist/utils/areThemesEqual.js +1 -1
  396. package/dist/utils/areThemesEqual.js.map +1 -1
  397. package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -1
  398. package/dist/utils/areVirtualWindowSpecsEqual.js +1 -1
  399. package/dist/utils/areVirtualWindowSpecsEqual.js.map +1 -1
  400. package/dist/utils/areWorkerStatsEqual.d.ts +0 -2
  401. package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -1
  402. package/dist/utils/areWorkerStatsEqual.js +1 -1
  403. package/dist/utils/areWorkerStatsEqual.js.map +1 -1
  404. package/dist/utils/awaitWithTimeout.d.ts +5 -0
  405. package/dist/utils/awaitWithTimeout.d.ts.map +1 -0
  406. package/dist/utils/awaitWithTimeout.js +15 -0
  407. package/dist/utils/awaitWithTimeout.js.map +1 -0
  408. package/dist/utils/cleanLastNewline.d.ts.map +1 -1
  409. package/dist/utils/cleanLastNewline.js +1 -1
  410. package/dist/utils/cleanLastNewline.js.map +1 -1
  411. package/dist/utils/cloneFileDiffMetadata.d.ts +7 -0
  412. package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -0
  413. package/dist/utils/cloneFileDiffMetadata.js +16 -0
  414. package/dist/utils/cloneFileDiffMetadata.js.map +1 -0
  415. package/dist/utils/computeEstimatedDiffHeights.d.ts +3 -1
  416. package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
  417. package/dist/utils/computeEstimatedDiffHeights.js +18 -23
  418. package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
  419. package/dist/utils/computeFileOffsets.d.ts +9 -1
  420. package/dist/utils/computeFileOffsets.d.ts.map +1 -1
  421. package/dist/utils/computeFileOffsets.js +51 -4
  422. package/dist/utils/computeFileOffsets.js.map +1 -1
  423. package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -1
  424. package/dist/utils/computeVirtualFileMetrics.js +1 -2
  425. package/dist/utils/computeVirtualFileMetrics.js.map +1 -1
  426. package/dist/utils/createAnnotationElement.d.ts +1 -1
  427. package/dist/utils/createAnnotationElement.d.ts.map +1 -1
  428. package/dist/utils/createAnnotationElement.js +1 -2
  429. package/dist/utils/createAnnotationElement.js.map +1 -1
  430. package/dist/utils/createAnnotationWrapperNode.d.ts.map +1 -1
  431. package/dist/utils/createAnnotationWrapperNode.js +1 -1
  432. package/dist/utils/createAnnotationWrapperNode.js.map +1 -1
  433. package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts +5 -0
  434. package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts.map +1 -0
  435. package/dist/utils/createCodeViewHeaderFooterHostElement.js +19 -0
  436. package/dist/utils/createCodeViewHeaderFooterHostElement.js.map +1 -0
  437. package/dist/utils/createContentColumn.d.ts +1 -1
  438. package/dist/utils/createContentColumn.d.ts.map +1 -1
  439. package/dist/utils/createContentColumn.js +1 -2
  440. package/dist/utils/createContentColumn.js.map +1 -1
  441. package/dist/utils/createEmptyRowBuffer.d.ts +1 -1
  442. package/dist/utils/createEmptyRowBuffer.d.ts.map +1 -1
  443. package/dist/utils/createEmptyRowBuffer.js +1 -2
  444. package/dist/utils/createEmptyRowBuffer.js.map +1 -1
  445. package/dist/utils/createFileHeaderElement.d.ts +1 -1
  446. package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
  447. package/dist/utils/createFileHeaderElement.js +6 -3
  448. package/dist/utils/createFileHeaderElement.js.map +1 -1
  449. package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -1
  450. package/dist/utils/createGutterUtilityContentNode.js +1 -1
  451. package/dist/utils/createGutterUtilityContentNode.js.map +1 -1
  452. package/dist/utils/createGutterUtilityElement.d.ts +1 -1
  453. package/dist/utils/createGutterUtilityElement.d.ts.map +1 -1
  454. package/dist/utils/createGutterUtilityElement.js +1 -2
  455. package/dist/utils/createGutterUtilityElement.js.map +1 -1
  456. package/dist/utils/createNoNewlineElement.d.ts +1 -1
  457. package/dist/utils/createNoNewlineElement.d.ts.map +1 -1
  458. package/dist/utils/createNoNewlineElement.js +1 -2
  459. package/dist/utils/createNoNewlineElement.js.map +1 -1
  460. package/dist/utils/createPreElement.d.ts +1 -1
  461. package/dist/utils/createPreElement.d.ts.map +1 -1
  462. package/dist/utils/createPreElement.js +1 -3
  463. package/dist/utils/createPreElement.js.map +1 -1
  464. package/dist/utils/createRowNodes.d.ts.map +1 -1
  465. package/dist/utils/createRowNodes.js +1 -1
  466. package/dist/utils/createRowNodes.js.map +1 -1
  467. package/dist/utils/createSeparator.d.ts +1 -1
  468. package/dist/utils/createSeparator.d.ts.map +1 -1
  469. package/dist/utils/createSeparator.js +1 -2
  470. package/dist/utils/createSeparator.js.map +1 -1
  471. package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
  472. package/dist/utils/createSpanNodeFromToken.js +1 -2
  473. package/dist/utils/createSpanNodeFromToken.js.map +1 -1
  474. package/dist/utils/createStyleElement.d.ts +1 -1
  475. package/dist/utils/createStyleElement.d.ts.map +1 -1
  476. package/dist/utils/createStyleElement.js +1 -2
  477. package/dist/utils/createStyleElement.js.map +1 -1
  478. package/dist/utils/createTransformerWithState.d.ts.map +1 -1
  479. package/dist/utils/createTransformerWithState.js +1 -2
  480. package/dist/utils/createTransformerWithState.js.map +1 -1
  481. package/dist/utils/createUnsafeCSSStyleNode.d.ts.map +1 -1
  482. package/dist/utils/createUnsafeCSSStyleNode.js +1 -2
  483. package/dist/utils/createUnsafeCSSStyleNode.js.map +1 -1
  484. package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
  485. package/dist/utils/createWindowFromScrollPosition.js +5 -5
  486. package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
  487. package/dist/utils/cssWrappers.d.ts.map +1 -1
  488. package/dist/utils/cssWrappers.js +2 -3
  489. package/dist/utils/cssWrappers.js.map +1 -1
  490. package/dist/utils/detachString.d.ts.map +1 -1
  491. package/dist/utils/detachString.js +1 -1
  492. package/dist/utils/detachString.js.map +1 -1
  493. package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
  494. package/dist/utils/diffAcceptRejectHunk.js +1 -2
  495. package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
  496. package/dist/utils/editSessionHunks.d.ts +84 -0
  497. package/dist/utils/editSessionHunks.d.ts.map +1 -0
  498. package/dist/utils/editSessionHunks.js +366 -0
  499. package/dist/utils/editSessionHunks.js.map +1 -0
  500. package/dist/utils/formatCSSVariablePrefix.d.ts.map +1 -1
  501. package/dist/utils/formatCSSVariablePrefix.js +1 -1
  502. package/dist/utils/formatCSSVariablePrefix.js.map +1 -1
  503. package/dist/utils/getDiffFileInput.d.ts +14 -0
  504. package/dist/utils/getDiffFileInput.d.ts.map +1 -0
  505. package/dist/utils/getDiffFileInput.js +24 -0
  506. package/dist/utils/getDiffFileInput.js.map +1 -0
  507. package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
  508. package/dist/utils/getDiffHunksRendererOptions.js +2 -1
  509. package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
  510. package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
  511. package/dist/utils/getFileRendererOptions.js +1 -1
  512. package/dist/utils/getFileRendererOptions.js.map +1 -1
  513. package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
  514. package/dist/utils/getFiletypeFromFileName.js +3 -1
  515. package/dist/utils/getFiletypeFromFileName.js.map +1 -1
  516. package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
  517. package/dist/utils/getHighlighterOptions.js +1 -2
  518. package/dist/utils/getHighlighterOptions.js.map +1 -1
  519. package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
  520. package/dist/utils/getHighlighterThemeStyles.js +17 -14
  521. package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
  522. package/dist/utils/getHunkSeparatorSlotName.d.ts.map +1 -1
  523. package/dist/utils/getHunkSeparatorSlotName.js +1 -1
  524. package/dist/utils/getHunkSeparatorSlotName.js.map +1 -1
  525. package/dist/utils/getIconForType.d.ts.map +1 -1
  526. package/dist/utils/getIconForType.js +1 -1
  527. package/dist/utils/getIconForType.js.map +1 -1
  528. package/dist/utils/getLineAnnotationName.d.ts.map +1 -1
  529. package/dist/utils/getLineAnnotationName.js +1 -1
  530. package/dist/utils/getLineAnnotationName.js.map +1 -1
  531. package/dist/utils/getLineEndingType.d.ts.map +1 -1
  532. package/dist/utils/getLineEndingType.js +1 -1
  533. package/dist/utils/getLineEndingType.js.map +1 -1
  534. package/dist/utils/getLineNodes.d.ts +1 -1
  535. package/dist/utils/getLineNodes.d.ts.map +1 -1
  536. package/dist/utils/getLineNodes.js +1 -1
  537. package/dist/utils/getLineNodes.js.map +1 -1
  538. package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
  539. package/dist/utils/getMergeConflictActionSlotName.js +1 -1
  540. package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
  541. package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
  542. package/dist/utils/getMergeConflictLineTypes.js +1 -2
  543. package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
  544. package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
  545. package/dist/utils/getOrCreateCodeNode.js +1 -1
  546. package/dist/utils/getOrCreateCodeNode.js.map +1 -1
  547. package/dist/utils/getSingularPatch.d.ts.map +1 -1
  548. package/dist/utils/getSingularPatch.js +1 -2
  549. package/dist/utils/getSingularPatch.js.map +1 -1
  550. package/dist/utils/getThemes.d.ts.map +1 -1
  551. package/dist/utils/getThemes.js +1 -2
  552. package/dist/utils/getThemes.js.map +1 -1
  553. package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
  554. package/dist/utils/getTotalLineCountFromHunks.js +1 -1
  555. package/dist/utils/getTotalLineCountFromHunks.js.map +1 -1
  556. package/dist/utils/hast_utils.d.ts +1 -1
  557. package/dist/utils/hast_utils.d.ts.map +1 -1
  558. package/dist/utils/hast_utils.js +1 -1
  559. package/dist/utils/hast_utils.js.map +1 -1
  560. package/dist/utils/hostTheme.d.ts.map +1 -1
  561. package/dist/utils/hostTheme.js +1 -2
  562. package/dist/utils/hostTheme.js.map +1 -1
  563. package/dist/utils/hydratePartialDiff.d.ts +10 -0
  564. package/dist/utils/hydratePartialDiff.d.ts.map +1 -0
  565. package/dist/utils/hydratePartialDiff.js +140 -0
  566. package/dist/utils/hydratePartialDiff.js.map +1 -0
  567. package/dist/utils/includesFileAnnotations.d.ts +17 -0
  568. package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
  569. package/dist/utils/includesFileAnnotations.js +19 -0
  570. package/dist/utils/includesFileAnnotations.js.map +1 -0
  571. package/dist/utils/isDefaultRenderRange.d.ts.map +1 -1
  572. package/dist/utils/isDefaultRenderRange.js +1 -1
  573. package/dist/utils/isDefaultRenderRange.js.map +1 -1
  574. package/dist/utils/isDiffPlainText.d.ts.map +1 -1
  575. package/dist/utils/isDiffPlainText.js +1 -2
  576. package/dist/utils/isDiffPlainText.js.map +1 -1
  577. package/dist/utils/isFilePlainText.d.ts.map +1 -1
  578. package/dist/utils/isFilePlainText.js +1 -2
  579. package/dist/utils/isFilePlainText.js.map +1 -1
  580. package/dist/utils/isGutterUtilityPath.d.ts +5 -0
  581. package/dist/utils/isGutterUtilityPath.d.ts.map +1 -0
  582. package/dist/utils/isGutterUtilityPath.js +12 -0
  583. package/dist/utils/isGutterUtilityPath.js.map +1 -0
  584. package/dist/utils/isStyleNode.d.ts.map +1 -1
  585. package/dist/utils/isStyleNode.js +1 -1
  586. package/dist/utils/isStyleNode.js.map +1 -1
  587. package/dist/utils/isWorkerContext.d.ts.map +1 -1
  588. package/dist/utils/isWorkerContext.js +1 -1
  589. package/dist/utils/isWorkerContext.js.map +1 -1
  590. package/dist/utils/iterateOverDiff.d.ts.map +1 -1
  591. package/dist/utils/iterateOverDiff.js +178 -214
  592. package/dist/utils/iterateOverDiff.js.map +1 -1
  593. package/dist/utils/normalizeDiffResolution.d.ts.map +1 -1
  594. package/dist/utils/normalizeDiffResolution.js +1 -1
  595. package/dist/utils/normalizeDiffResolution.js.map +1 -1
  596. package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
  597. package/dist/utils/parseDiffDecorations.js +1 -2
  598. package/dist/utils/parseDiffDecorations.js.map +1 -1
  599. package/dist/utils/parseDiffFromFile.d.ts +1 -2
  600. package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
  601. package/dist/utils/parseDiffFromFile.js +27 -7
  602. package/dist/utils/parseDiffFromFile.js.map +1 -1
  603. package/dist/utils/parseLineType.d.ts.map +1 -1
  604. package/dist/utils/parseLineType.js +1 -1
  605. package/dist/utils/parseLineType.js.map +1 -1
  606. package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
  607. package/dist/utils/parseMergeConflictDiffFromFile.js +5 -5
  608. package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
  609. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  610. package/dist/utils/parsePatchFiles.js +101 -11
  611. package/dist/utils/parsePatchFiles.js.map +1 -1
  612. package/dist/utils/prefersReducedMotion.d.ts.map +1 -1
  613. package/dist/utils/prefersReducedMotion.js +1 -1
  614. package/dist/utils/prefersReducedMotion.js.map +1 -1
  615. package/dist/utils/prerenderHTMLIfNecessary.d.ts.map +1 -1
  616. package/dist/utils/prerenderHTMLIfNecessary.js +1 -1
  617. package/dist/utils/prerenderHTMLIfNecessary.js.map +1 -1
  618. package/dist/utils/processLine.d.ts +1 -1
  619. package/dist/utils/processLine.d.ts.map +1 -1
  620. package/dist/utils/processLine.js +1 -2
  621. package/dist/utils/processLine.js.map +1 -1
  622. package/dist/utils/realignChangeContent.d.ts +28 -0
  623. package/dist/utils/realignChangeContent.d.ts.map +1 -0
  624. package/dist/utils/realignChangeContent.js +142 -0
  625. package/dist/utils/realignChangeContent.js.map +1 -0
  626. package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
  627. package/dist/utils/renderDiffWithHighlighter.js +9 -8
  628. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  629. package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
  630. package/dist/utils/renderFileWithHighlighter.js +5 -4
  631. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  632. package/dist/utils/resolveConflict.d.ts.map +1 -1
  633. package/dist/utils/resolveConflict.js +1 -2
  634. package/dist/utils/resolveConflict.js.map +1 -1
  635. package/dist/utils/resolveRegion.d.ts.map +1 -1
  636. package/dist/utils/resolveRegion.js +1 -1
  637. package/dist/utils/resolveRegion.js.map +1 -1
  638. package/dist/utils/roundToDevicePixel.d.ts.map +1 -1
  639. package/dist/utils/roundToDevicePixel.js +1 -1
  640. package/dist/utils/roundToDevicePixel.js.map +1 -1
  641. package/dist/utils/scrollbarGutter.d.ts.map +1 -1
  642. package/dist/utils/scrollbarGutter.js +1 -2
  643. package/dist/utils/scrollbarGutter.js.map +1 -1
  644. package/dist/utils/setLanguageOverride.d.ts.map +1 -1
  645. package/dist/utils/setLanguageOverride.js +1 -1
  646. package/dist/utils/setLanguageOverride.js.map +1 -1
  647. package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
  648. package/dist/utils/setWrapperNodeProps.js +1 -2
  649. package/dist/utils/setWrapperNodeProps.js.map +1 -1
  650. package/dist/utils/shouldUseTokenTransformer.d.ts.map +1 -1
  651. package/dist/utils/shouldUseTokenTransformer.js +1 -1
  652. package/dist/utils/shouldUseTokenTransformer.js.map +1 -1
  653. package/dist/utils/splitFileContents.d.ts.map +1 -1
  654. package/dist/utils/splitFileContents.js +1 -2
  655. package/dist/utils/splitFileContents.js.map +1 -1
  656. package/dist/utils/trimPatchContext.d.ts.map +1 -1
  657. package/dist/utils/trimPatchContext.js +1 -2
  658. package/dist/utils/trimPatchContext.js.map +1 -1
  659. package/dist/utils/updateDiffHunks.d.ts +24 -0
  660. package/dist/utils/updateDiffHunks.d.ts.map +1 -0
  661. package/dist/utils/updateDiffHunks.js +235 -0
  662. package/dist/utils/updateDiffHunks.js.map +1 -0
  663. package/dist/utils/virtualDiffLayout.d.ts +62 -2
  664. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  665. package/dist/utils/virtualDiffLayout.js +137 -3
  666. package/dist/utils/virtualDiffLayout.js.map +1 -1
  667. package/dist/utils/wrapTokenFragments.d.ts +1 -1
  668. package/dist/utils/wrapTokenFragments.d.ts.map +1 -1
  669. package/dist/utils/wrapTokenFragments.js +1 -2
  670. package/dist/utils/wrapTokenFragments.js.map +1 -1
  671. package/dist/worker/WorkerPoolManager.d.ts +7 -2
  672. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  673. package/dist/worker/WorkerPoolManager.js +88 -23
  674. package/dist/worker/WorkerPoolManager.js.map +1 -1
  675. package/dist/worker/getOrCreateWorkerPoolSingleton.d.ts.map +1 -1
  676. package/dist/worker/getOrCreateWorkerPoolSingleton.js +1 -2
  677. package/dist/worker/getOrCreateWorkerPoolSingleton.js.map +1 -1
  678. package/dist/worker/index.d.ts +2 -2
  679. package/dist/worker/index.js +1 -2
  680. package/dist/worker/types.d.ts +11 -1
  681. package/dist/worker/types.d.ts.map +1 -1
  682. package/dist/worker/wasm-B9ZqxnKj.js +8 -0
  683. package/dist/worker/wasm-B9ZqxnKj.js.map +1 -0
  684. package/dist/worker/worker-portable.js +3361 -6211
  685. package/dist/worker/worker-portable.js.map +1 -1
  686. package/dist/worker/worker.js +321 -314
  687. package/dist/worker/worker.js.map +1 -1
  688. package/package.json +29 -32
  689. package/dist/editor/css.d.ts +0 -6
  690. package/dist/editor/css.d.ts.map +0 -1
  691. package/dist/editor/css.js +0 -218
  692. package/dist/editor/css.js.map +0 -1
  693. package/dist/editor/quickEdit.d.ts +0 -29
  694. package/dist/editor/quickEdit.d.ts.map +0 -1
  695. package/dist/editor/quickEdit.js +0 -81
  696. package/dist/editor/quickEdit.js.map +0 -1
  697. package/dist/editor/tokenzier.d.ts.map +0 -1
  698. package/dist/editor/tokenzier.js +0 -348
  699. package/dist/editor/tokenzier.js.map +0 -1
  700. package/dist/react/EditorContext.d.ts +0 -16
  701. package/dist/react/EditorContext.d.ts.map +0 -1
  702. package/dist/react/EditorContext.js +0 -26
  703. package/dist/react/EditorContext.js.map +0 -1
  704. package/dist/worker/wasm-D4DU5jgR.js +0 -10
  705. package/dist/worker/wasm-D4DU5jgR.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { DEFAULT_VIRTUAL_FILE_METRICS } from "../constants.js";
2
2
  import { areObjectsEqual } from "../utils/areObjectsEqual.js";
3
3
  import { areOptionsEqual } from "../utils/areOptionsEqual.js";
4
- import { areFilesEqual } from "../utils/areFilesEqual.js";
5
4
  import { getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "../utils/computeVirtualFileMetrics.js";
5
+ import { areFilesEqual } from "../utils/areFilesEqual.js";
6
+ import { FILE_ANNOTATION_DOM_KEY, includesFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
6
7
  import { File } from "./File.js";
7
-
8
8
  //#region src/components/VirtualizedFile.ts
9
9
  const LAYOUT_CHECKPOINT_INTERVAL = 5e3;
10
10
  let instanceId = -1;
@@ -12,12 +12,15 @@ function hasFileLayoutOptionChanged(previousOptions, nextOptions) {
12
12
  return (previousOptions.overflow ?? "scroll") !== (nextOptions.overflow ?? "scroll") || (previousOptions.collapsed ?? false) !== (nextOptions.collapsed ?? false) || (previousOptions.disableLineNumbers ?? false) !== (nextOptions.disableLineNumbers ?? false) || (previousOptions.disableFileHeader ?? false) !== (nextOptions.disableFileHeader ?? false) || previousOptions.unsafeCSS !== nextOptions.unsafeCSS;
13
13
  }
14
14
  var VirtualizedFile = class extends File {
15
+ virtualizer;
16
+ metrics;
15
17
  __id = `virtualized-file:${++instanceId}`;
16
18
  top;
17
19
  height = 0;
18
20
  cache = {
19
21
  heights: /* @__PURE__ */ new Map(),
20
- checkpoints: []
22
+ checkpoints: [],
23
+ fileAnnotationHeight: 0
21
24
  };
22
25
  isVisible = false;
23
26
  isSetup = false;
@@ -34,6 +37,18 @@ var VirtualizedFile = class extends File {
34
37
  this.metrics = metrics;
35
38
  this.resetLayoutCache();
36
39
  }
40
+ setLineAnnotations(lineAnnotations) {
41
+ if (this.syncLineAnnotations(lineAnnotations)) this.resetLayoutCache();
42
+ }
43
+ syncLineAnnotations(lineAnnotations) {
44
+ if (lineAnnotations == null || lineAnnotations === this.lineAnnotations) return false;
45
+ if (lineAnnotations.length === 0 && this.lineAnnotations.length === 0) return false;
46
+ super.setLineAnnotations(lineAnnotations);
47
+ return true;
48
+ }
49
+ hasLineAnnotations() {
50
+ return this.lineAnnotations.some((annotation) => annotation.lineNumber > 0);
51
+ }
37
52
  getLineHeight(lineIndex, hasMetadataLine = false) {
38
53
  const cached = this.cache.heights.get(lineIndex);
39
54
  if (cached != null) return cached;
@@ -55,11 +70,12 @@ var VirtualizedFile = class extends File {
55
70
  if (this.isAdvancedMode()) throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");
56
71
  super.setThemeType(themeType);
57
72
  }
58
- resetLayoutCache(recompute = false) {
73
+ resetLayoutCache(recompute = false, resetRenderRange = true) {
59
74
  this.layoutDirty = true;
75
+ this.cache.fileAnnotationHeight = 0;
60
76
  if (this.cache.heights.size > 0) this.cache.heights.clear();
61
77
  if (this.cache.checkpoints.length > 0) this.cache.checkpoints.length = 0;
62
- if (this.renderRange != null) this.renderRange = void 0;
78
+ if (this.renderRange != null && resetRenderRange) this.renderRange = void 0;
63
79
  if (recompute && this.isSimpleMode()) this.computeApproximateSize();
64
80
  }
65
81
  reconcileHeights() {
@@ -75,6 +91,17 @@ var VirtualizedFile = class extends File {
75
91
  if (this.code == null) return hasHeightChange;
76
92
  const content = this.code.children[1];
77
93
  if (!(content instanceof HTMLElement)) return hasHeightChange;
94
+ const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);
95
+ if (this.renderRange != null && hasFileAnnotations && shouldRenderFileAnnotations(this.renderRange)) {
96
+ const nextFileAnnotationHeight = measureFileAnnotationHeight(content) ?? 0;
97
+ if (nextFileAnnotationHeight !== this.cache.fileAnnotationHeight) {
98
+ this.cache.fileAnnotationHeight = nextFileAnnotationHeight;
99
+ hasHeightChange = true;
100
+ }
101
+ } else if (!hasFileAnnotations && this.cache.fileAnnotationHeight !== 0) {
102
+ this.cache.fileAnnotationHeight = 0;
103
+ hasHeightChange = true;
104
+ }
78
105
  for (const line of content.children) {
79
106
  if (!(line instanceof HTMLElement)) continue;
80
107
  const lineIndexAttr = line.dataset.lineIndex;
@@ -100,8 +127,10 @@ var VirtualizedFile = class extends File {
100
127
  if (dirty) this.top = this.getVirtualizedTop();
101
128
  return this.render({ file: this.file });
102
129
  };
103
- prepareCodeViewItem(file, top, reset) {
104
- let shouldResetLayoutCache = reset?.resetFileLayoutCache === true;
130
+ prepareCodeViewItem(file, top, reset, lineAnnotations) {
131
+ const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
132
+ const unkeyedContentsChanged = this.fileRenderer.hasUnkeyedFileContentsChanged(file);
133
+ let shouldResetLayoutCache = reset?.resetFileLayoutCache === true || annotationsChanged || unkeyedContentsChanged;
105
134
  if (reset?.metrics != null) {
106
135
  this.metrics = reset.metrics;
107
136
  shouldResetLayoutCache = true;
@@ -119,7 +148,7 @@ var VirtualizedFile = class extends File {
119
148
  return this.height;
120
149
  }
121
150
  getLinePosition(lineNumber) {
122
- if (this.file == null) return;
151
+ if (this.file == null || lineNumber < 1) return;
123
152
  const { disableFileHeader = false, collapsed = false } = this.options;
124
153
  const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;
125
154
  let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
@@ -130,7 +159,8 @@ var VirtualizedFile = class extends File {
130
159
  const clampedLineIndex = Math.min(Math.max(lineNumber - 1, 0), lastLineIndex);
131
160
  const { overflow = "scroll" } = this.options;
132
161
  const { lineHeight } = this.metrics;
133
- if (overflow === "scroll" && this.lineAnnotations.length === 0) return {
162
+ top += this.cache.fileAnnotationHeight;
163
+ if (overflow === "scroll" && !this.hasLineAnnotations()) return {
134
164
  top: top + clampedLineIndex * lineHeight,
135
165
  height: lineHeight
136
166
  };
@@ -142,6 +172,10 @@ var VirtualizedFile = class extends File {
142
172
  height: this.getLineHeight(clampedLineIndex, false)
143
173
  };
144
174
  }
175
+ getScrollContainer() {
176
+ const root = this.getSimpleVirtualizer()?.getRoot();
177
+ return root instanceof HTMLElement ? root : root?.documentElement;
178
+ }
145
179
  getNumericScrollAnchor(localViewportTop) {
146
180
  if (this.file == null || this.renderRange == null) return;
147
181
  const { disableFileHeader = false, collapsed = false, overflow = "scroll" } = this.options;
@@ -152,17 +186,18 @@ var VirtualizedFile = class extends File {
152
186
  const firstRenderedLineIndex = Math.min(this.renderRange.startingLine, lastLineIndex);
153
187
  const lastRenderedLineIndex = Math.min(firstRenderedLineIndex + this.renderRange.totalLines - 1, lastLineIndex);
154
188
  if (lastRenderedLineIndex < firstRenderedLineIndex) return;
155
- if (overflow === "scroll" && this.lineAnnotations.length === 0) {
189
+ const { fileAnnotationHeight } = this.cache;
190
+ if (overflow === "scroll" && !this.hasLineAnnotations()) {
156
191
  const { lineHeight } = this.metrics;
157
- const firstRenderedLineTop = headerRegion + this.renderRange.bufferBefore;
192
+ const firstRenderedLineTop = headerRegion + (firstRenderedLineIndex === 0 ? fileAnnotationHeight : this.renderRange.bufferBefore);
158
193
  const lineIndex = firstRenderedLineIndex + Math.max(Math.ceil((localViewportTop - firstRenderedLineTop) / lineHeight), 0);
159
194
  if (lineIndex > lastRenderedLineIndex) return;
160
195
  return {
161
196
  lineNumber: lineIndex + 1,
162
- top: headerRegion + lineIndex * lineHeight
197
+ top: headerRegion + fileAnnotationHeight + lineIndex * lineHeight
163
198
  };
164
199
  }
165
- let top = headerRegion + this.renderRange.bufferBefore;
200
+ let top = headerRegion + (firstRenderedLineIndex === 0 ? fileAnnotationHeight : this.renderRange.bufferBefore);
166
201
  for (let lineIndex = firstRenderedLineIndex; lineIndex <= lastRenderedLineIndex; lineIndex++) {
167
202
  if (top >= localViewportTop) return {
168
203
  lineNumber: lineIndex + 1,
@@ -183,14 +218,19 @@ var VirtualizedFile = class extends File {
183
218
  const renderRange = windowSpecs != null ? this.computeRenderRangeFromWindow(this.file, this.top, windowSpecs) : this.renderRange;
184
219
  if (renderRange == null) return;
185
220
  const { bufferBefore, bufferAfter, totalLines } = renderRange;
221
+ let headerOnlyOffset = 0;
222
+ if (totalLines === 0) {
223
+ const activeWindow = windowSpecs ?? this.virtualizer.getWindowSpecs();
224
+ if (this.top < activeWindow.top) headerOnlyOffset = bufferAfter;
225
+ }
186
226
  return {
187
- topOffset: this.top + bufferBefore + (totalLines === 0 ? bufferAfter : 0),
227
+ topOffset: this.top + bufferBefore + headerOnlyOffset,
188
228
  height: this.height - (bufferBefore + bufferAfter)
189
229
  };
190
230
  }
191
231
  cleanUp(recycle = false) {
192
232
  if (this.fileContainer != null && this.isSimpleMode()) this.getSimpleVirtualizer()?.disconnect(this.fileContainer);
193
- if (!recycle) this.layoutDirty = true;
233
+ if (!recycle) this.resetLayoutCache();
194
234
  this.isSetup = false;
195
235
  super.cleanUp(recycle);
196
236
  }
@@ -214,7 +254,8 @@ var VirtualizedFile = class extends File {
214
254
  this.layoutDirty = false;
215
255
  return;
216
256
  }
217
- if (overflow === "scroll" && this.lineAnnotations.length === 0) this.height += lineCount * lineHeight;
257
+ this.height += this.cache.fileAnnotationHeight;
258
+ if (overflow === "scroll" && !this.hasLineAnnotations()) this.height += lineCount * lineHeight;
218
259
  else for (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {
219
260
  this.addLayoutCheckpoint(lineIndex, this.height);
220
261
  this.height += this.getLineHeight(lineIndex, false);
@@ -246,21 +287,23 @@ var VirtualizedFile = class extends File {
246
287
  this.forceRenderOverride = true;
247
288
  this.virtualizer.instanceChanged(this, false);
248
289
  }
249
- applyLayoutChange(textDocument, newLineAnnotations, shouldUpdateBuffer = false) {
290
+ applyDocumentChange(textDocument, newLineAnnotations, shouldUpdateBuffer = false) {
250
291
  const previousRenderRange = this.renderRange;
251
- super.applyLayoutChange(textDocument, newLineAnnotations);
292
+ super.applyDocumentChange(textDocument, newLineAnnotations);
252
293
  this.getSimpleVirtualizer()?.markDOMDirty();
253
- this.resetLayoutCache(true);
294
+ this.resetLayoutCache(this.isSimpleMode(), false);
254
295
  if (shouldUpdateBuffer && previousRenderRange !== void 0 && this.file !== void 0) {
255
296
  const windowSpecs = this.virtualizer.getWindowSpecs();
256
297
  const renderRange = this.computeRenderRangeFromWindow(this.file, this.top ?? 0, windowSpecs);
257
298
  if (renderRange.bufferAfter !== previousRenderRange.bufferAfter) this.updateBuffers(renderRange);
258
299
  }
259
300
  }
260
- render({ fileContainer, file, forceRender = false,...props }) {
261
- const didFileChange = this.file == null || !areFilesEqual(this.file, file);
301
+ renderPreparedFile({ fileContainer, file, forceRender = false, lineAnnotations, ...props }) {
302
+ const didFileChange = this.file == null || !areFilesEqual(this.file, file) || this.fileRenderer.hasUnkeyedFileContentsChanged(file);
262
303
  const { forceRenderOverride, isSetup } = this;
263
304
  this.forceRenderOverride = void 0;
305
+ const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
306
+ if (annotationsChanged) this.resetLayoutCache();
264
307
  this.file = file;
265
308
  fileContainer = this.getOrCreateFileContainerNode(fileContainer);
266
309
  if (this.file == null) {
@@ -289,13 +332,16 @@ var VirtualizedFile = class extends File {
289
332
  const windowSpecs = this.virtualizer.getWindowSpecs();
290
333
  const fileTop = this.top ?? 0;
291
334
  const renderRange = this.computeRenderRangeFromWindow(this.file, fileTop, windowSpecs);
292
- return super.render({
335
+ const rendered = super.renderPreparedFile({
293
336
  file: this.file,
294
337
  fileContainer,
295
338
  renderRange,
296
- forceRender: forceRenderOverride ?? forceRender,
339
+ lineAnnotations,
340
+ forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged,
297
341
  ...props
298
342
  });
343
+ if (this.isSimpleMode() && rendered) this.getSimpleVirtualizer()?.requestHeightReconcile(this);
344
+ return rendered;
299
345
  }
300
346
  syncVirtualizedTop() {
301
347
  this.top = this.getVirtualizedTop();
@@ -369,6 +415,12 @@ var VirtualizedFile = class extends File {
369
415
  const fileHeight = this.height;
370
416
  const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
371
417
  const paddingBottom = lineCount > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;
418
+ const { fileAnnotationHeight } = this.cache;
419
+ const codeRegionTop = headerRegion + fileAnnotationHeight;
420
+ const codeRowsHeight = Math.max(0, fileHeight - headerRegion - fileAnnotationHeight - paddingBottom);
421
+ const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);
422
+ const fileAnnotationTop = fileTop + headerRegion;
423
+ const measuredFileAnnotationVisible = fileAnnotationHeight > 0 && hasFileAnnotations && fileAnnotationTop < bottom && fileAnnotationTop + fileAnnotationHeight > top;
372
424
  if (fileTop < top - fileHeight || fileTop > bottom) return {
373
425
  startingLine: 0,
374
426
  totalLines: 0,
@@ -385,25 +437,33 @@ var VirtualizedFile = class extends File {
385
437
  const totalLines = Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount + hunkLineCount * 2;
386
438
  const totalHunks = totalLines / hunkLineCount;
387
439
  const viewportCenter = (top + bottom) / 2;
388
- if (overflow === "scroll" && this.lineAnnotations.length === 0) {
389
- const centerLine = Math.floor((viewportCenter - (fileTop + headerRegion)) / lineHeight);
390
- const idealStartHunk$1 = Math.floor(centerLine / hunkLineCount) - Math.floor(totalHunks / 2);
440
+ if (overflow === "scroll" && !this.hasLineAnnotations()) {
441
+ const sourceRowsTop = fileTop + codeRegionTop;
442
+ const sourceRowsBottom = sourceRowsTop + codeRowsHeight;
443
+ if (!measuredFileAnnotationVisible && !(sourceRowsTop < bottom && sourceRowsBottom > top)) return {
444
+ startingLine: 0,
445
+ totalLines: 0,
446
+ bufferBefore: 0,
447
+ bufferAfter: fileHeight - headerRegion - paddingBottom
448
+ };
449
+ const centerLine = Math.floor(measuredFileAnnotationVisible && viewportCenter < fileTop + codeRegionTop ? 0 : (viewportCenter - (fileTop + codeRegionTop)) / lineHeight);
450
+ const idealStartHunk = Math.floor(centerLine / hunkLineCount) - Math.floor(totalHunks / 2);
391
451
  const totalHunksInFile = Math.ceil(lineCount / hunkLineCount);
392
- const startingLine$1 = Math.max(0, Math.min(idealStartHunk$1, totalHunksInFile)) * hunkLineCount;
393
- const clampedTotalLines$1 = idealStartHunk$1 < 0 ? totalLines + idealStartHunk$1 * hunkLineCount : totalLines;
394
- const bufferBefore$1 = startingLine$1 * lineHeight;
395
- const renderedLines = Math.min(clampedTotalLines$1, lineCount - startingLine$1);
452
+ const startingLine = Math.max(0, Math.min(idealStartHunk, totalHunksInFile)) * hunkLineCount;
453
+ const clampedTotalLines = idealStartHunk < 0 ? totalLines + idealStartHunk * hunkLineCount : totalLines;
454
+ const bufferBefore = startingLine === 0 ? 0 : fileAnnotationHeight + startingLine * lineHeight;
455
+ const renderedLines = Math.min(clampedTotalLines, lineCount - startingLine);
396
456
  return {
397
- startingLine: startingLine$1,
398
- totalLines: clampedTotalLines$1,
399
- bufferBefore: bufferBefore$1,
400
- bufferAfter: Math.max(0, (lineCount - startingLine$1 - renderedLines) * lineHeight)
457
+ startingLine,
458
+ totalLines: clampedTotalLines,
459
+ bufferBefore,
460
+ bufferAfter: Math.max(0, (lineCount - startingLine - renderedLines) * lineHeight)
401
461
  };
402
462
  }
403
463
  const overflowHunks = totalHunks;
404
464
  const hunkOffsets = [];
405
465
  const checkpoint = this.getLayoutCheckpointBeforeTop(Math.max(0, top - fileTop - totalLines * lineHeight * 2), hunkLineCount);
406
- let absoluteLineTop = fileTop + (checkpoint?.top ?? headerRegion);
466
+ let absoluteLineTop = fileTop + (checkpoint?.top ?? codeRegionTop);
407
467
  let currentLine = checkpoint?.lineIndex ?? 0;
408
468
  let firstVisibleHunk;
409
469
  let centerHunk;
@@ -413,20 +473,23 @@ var VirtualizedFile = class extends File {
413
473
  const isAtHunkBoundary = currentLine % hunkLineCount === 0;
414
474
  const currentHunk = Math.floor(currentLine / hunkLineCount);
415
475
  if (isAtHunkBoundary) {
416
- hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + headerRegion);
476
+ hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + codeRegionTop);
417
477
  if (overflowCounter != null) {
418
478
  if (overflowCounter <= 0) break;
419
479
  overflowCounter--;
420
480
  }
421
481
  }
422
- const lineHeight$1 = this.getLineHeight(lineIndex, false);
423
- if (absoluteLineTop > top - lineHeight$1 && absoluteLineTop < bottom) firstVisibleHunk ??= currentHunk;
424
- if (absoluteLineTop + lineHeight$1 > viewportCenter) centerHunk ??= currentHunk;
482
+ const lineHeight = this.getLineHeight(lineIndex, false);
483
+ if (absoluteLineTop > top - lineHeight && absoluteLineTop < bottom) firstVisibleHunk ??= currentHunk;
484
+ if (absoluteLineTop + lineHeight > viewportCenter) centerHunk ??= currentHunk;
425
485
  if (overflowCounter == null && absoluteLineTop >= bottom && isAtHunkBoundary) overflowCounter = overflowHunks;
426
486
  currentLine++;
427
- absoluteLineTop += lineHeight$1;
487
+ absoluteLineTop += lineHeight;
428
488
  }
429
- if (firstVisibleHunk == null) return {
489
+ if (firstVisibleHunk == null) if (measuredFileAnnotationVisible) {
490
+ firstVisibleHunk = 0;
491
+ centerHunk = 0;
492
+ } else return {
430
493
  startingLine: 0,
431
494
  totalLines: 0,
432
495
  bufferBefore: 0,
@@ -438,17 +501,28 @@ var VirtualizedFile = class extends File {
438
501
  const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));
439
502
  const startingLine = startHunk * hunkLineCount;
440
503
  const clampedTotalLines = idealStartHunk < 0 ? totalLines + idealStartHunk * hunkLineCount : totalLines;
441
- const bufferBefore = hunkOffsets[startHunk] ?? 0;
504
+ const codeBufferBefore = hunkOffsets[startHunk] ?? 0;
505
+ const bufferBefore = startingLine === 0 ? 0 : fileAnnotationHeight + codeBufferBefore;
442
506
  const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;
507
+ const bufferAfter = finalHunkIndex < hunkOffsets.length ? codeRowsHeight - hunkOffsets[finalHunkIndex] : codeRowsHeight - (absoluteLineTop - fileTop - codeRegionTop);
443
508
  return {
444
509
  startingLine,
445
510
  totalLines: clampedTotalLines,
446
511
  bufferBefore,
447
- bufferAfter: finalHunkIndex < hunkOffsets.length ? fileHeight - headerRegion - hunkOffsets[finalHunkIndex] - paddingBottom : fileHeight - (absoluteLineTop - fileTop) - paddingBottom
512
+ bufferAfter: Math.max(0, bufferAfter)
448
513
  };
449
514
  }
450
515
  };
451
-
516
+ function measureFileAnnotationHeight(content) {
517
+ let height;
518
+ for (const child of content.children) {
519
+ if (!(child instanceof HTMLElement)) continue;
520
+ if (child.dataset.lineAnnotation !== FILE_ANNOTATION_DOM_KEY) continue;
521
+ height = Math.max(height ?? 0, child.getBoundingClientRect().height);
522
+ }
523
+ return height;
524
+ }
452
525
  //#endregion
453
526
  export { VirtualizedFile };
527
+
454
528
  //# sourceMappingURL=VirtualizedFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedFile.js","names":["virtualizer: Virtualizer | CodeView<LAnnotation>","metrics: VirtualFileMetrics","result: FileLayoutCheckpoint | undefined","idealStartHunk","startingLine","clampedTotalLines","bufferBefore","hunkOffsets: number[]","firstVisibleHunk: number | undefined","centerHunk: number | undefined","overflowCounter: number | undefined","lineHeight"],"sources":["../../src/components/VirtualizedFile.ts"],"sourcesContent":["import { DEFAULT_VIRTUAL_FILE_METRICS } from '../constants';\nimport type {\n DiffsTextDocument,\n FileContents,\n LineAnnotation,\n NumericScrollLineAnchor,\n PendingCodeViewLayoutReset,\n RenderRange,\n RenderWindow,\n StickySpecs,\n ThemeTypes,\n VirtualFileMetrics,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areObjectsEqual } from '../utils/areObjectsEqual';\nimport { areOptionsEqual } from '../utils/areOptionsEqual';\nimport {\n getVirtualFileHeaderRegion,\n getVirtualFilePaddingBottom,\n} from '../utils/computeVirtualFileMetrics';\nimport type { WorkerPoolManager } from '../worker';\nimport type { CodeView } from './CodeView';\nimport { File, type FileOptions, type FileRenderProps } from './File';\nimport type { Virtualizer } from './Virtualizer';\n\ninterface FileLayoutCheckpoint {\n lineIndex: number;\n top: number;\n}\n\ninterface FileLayoutCache {\n // Sparse map: line index -> measured height. Only stores lines that differ\n // from what is returned by `getLineHeight`.\n heights: Map<number, number>;\n // Sparse measured positions used to resume deep geometry scans near a target\n // line or scroll offset instead of replaying layout from the start.\n checkpoints: FileLayoutCheckpoint[];\n}\n\nconst LAYOUT_CHECKPOINT_INTERVAL = 5_000;\n\nlet instanceId = -1;\n\nfunction hasFileLayoutOptionChanged<LAnnotation>(\n previousOptions: FileOptions<LAnnotation>,\n nextOptions: FileOptions<LAnnotation>\n): boolean {\n return (\n (previousOptions.overflow ?? 'scroll') !==\n (nextOptions.overflow ?? 'scroll') ||\n (previousOptions.collapsed ?? false) !== (nextOptions.collapsed ?? false) ||\n (previousOptions.disableLineNumbers ?? false) !==\n (nextOptions.disableLineNumbers ?? false) ||\n (previousOptions.disableFileHeader ?? false) !==\n (nextOptions.disableFileHeader ?? false) ||\n previousOptions.unsafeCSS !== nextOptions.unsafeCSS\n );\n}\n\nexport class VirtualizedFile<\n LAnnotation = undefined,\n> extends File<LAnnotation> {\n override readonly __id: string = `virtualized-file:${++instanceId}`;\n\n public top: number | undefined;\n public height: number = 0;\n private cache: FileLayoutCache = { heights: new Map(), checkpoints: [] };\n private isVisible: boolean = false;\n private isSetup: boolean = false;\n private layoutDirty = true;\n private forceRenderOverride: true | undefined;\n private currentCollapsed: boolean | undefined;\n\n constructor(\n options: FileOptions<LAnnotation> | undefined,\n private virtualizer: Virtualizer | CodeView<LAnnotation>,\n private metrics: VirtualFileMetrics = DEFAULT_VIRTUAL_FILE_METRICS,\n workerManager?: WorkerPoolManager,\n isContainerManaged = false\n ) {\n super(options, workerManager, isContainerManaged);\n }\n\n public setMetrics(metrics: VirtualFileMetrics, force = false): void {\n if (!force && areObjectsEqual(this.metrics, metrics)) {\n return;\n }\n\n this.metrics = metrics;\n this.resetLayoutCache();\n }\n\n // Get the height for a line, using cached value if available.\n // If not cached and hasMetadataLine is true, adds lineHeight for the\n // metadata.\n public getLineHeight(lineIndex: number, hasMetadataLine = false): number {\n const cached = this.cache.heights.get(lineIndex);\n if (cached != null) {\n return cached;\n }\n const multiplier = hasMetadataLine ? 2 : 1;\n return this.metrics.lineHeight * multiplier;\n }\n\n override setOptions(options: FileOptions<LAnnotation> | undefined): void {\n if (this.isAdvancedMode()) {\n throw new Error(\n 'VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.'\n );\n }\n\n if (options == null) return;\n const { options: previousOptions } = this;\n const optionsChanged = !areOptionsEqual(previousOptions, options);\n const layoutChanged = hasFileLayoutOptionChanged(previousOptions, options);\n\n super.setOptions(options);\n\n if (layoutChanged) {\n this.resetLayoutCache(true);\n }\n // Any option can affect rendered DOM; only layout-affecting options clear\n // the measured height cache above.\n if (optionsChanged) {\n this.forceRenderOverride = true;\n }\n if (optionsChanged) {\n this.virtualizer.instanceChanged(this, layoutChanged);\n }\n }\n\n override setThemeType(themeType: ThemeTypes): void {\n if (this.isAdvancedMode()) {\n throw new Error(\n 'VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.'\n );\n }\n\n super.setThemeType(themeType);\n }\n\n private resetLayoutCache(recompute = false): void {\n this.layoutDirty = true;\n if (this.cache.heights.size > 0) {\n this.cache.heights.clear();\n }\n if (this.cache.checkpoints.length > 0) {\n this.cache.checkpoints.length = 0;\n }\n if (this.renderRange != null) {\n this.renderRange = undefined;\n }\n // NOTE(amadeus): In CodeView we intentionally batch computes to all happen\n // at the same time, so we shouldn't trigger this there.\n if (recompute && this.isSimpleMode()) {\n this.computeApproximateSize();\n }\n }\n\n // Measure rendered lines and update height cache.\n // Called after render to reconcile estimated vs actual heights.\n public reconcileHeights(): boolean {\n let hasHeightChange = false;\n if (this.fileContainer == null || this.file == null) {\n if (this.height !== 0) {\n hasHeightChange = true;\n }\n this.height = 0;\n return hasHeightChange;\n }\n const { overflow = 'scroll' } = this.options;\n this.top = this.getVirtualizedTop();\n\n // If the file has no annotations and we are using the scroll variant, then\n // we can probably skip everything\n if (\n overflow === 'scroll' &&\n this.lineAnnotations.length === 0 &&\n !this.isResizeDebuggingEnabled()\n ) {\n return hasHeightChange;\n }\n\n // Single code element (no split mode)\n if (this.code == null) {\n return hasHeightChange;\n }\n const content = this.code.children[1]; // Content column (gutter is [0])\n if (!(content instanceof HTMLElement)) {\n return hasHeightChange;\n }\n\n for (const line of content.children) {\n if (!(line instanceof HTMLElement)) continue;\n\n const lineIndexAttr = line.dataset.lineIndex;\n if (lineIndexAttr == null) continue;\n\n const lineIndex = Number(lineIndexAttr);\n let measuredHeight = line.getBoundingClientRect().height;\n let hasMetadata = false;\n\n // Annotations or noNewline metadata increase the size of their attached line\n if (\n line.nextElementSibling instanceof HTMLElement &&\n ('lineAnnotation' in line.nextElementSibling.dataset ||\n 'noNewline' in line.nextElementSibling.dataset)\n ) {\n if ('noNewline' in line.nextElementSibling.dataset) {\n hasMetadata = true;\n }\n measuredHeight +=\n line.nextElementSibling.getBoundingClientRect().height;\n }\n\n const expectedHeight = this.getLineHeight(lineIndex, hasMetadata);\n\n if (measuredHeight === expectedHeight) {\n continue;\n }\n\n hasHeightChange = true;\n // Line is back to standard height (e.g., after window resize)\n // Remove from cache\n if (measuredHeight === this.metrics.lineHeight * (hasMetadata ? 2 : 1)) {\n this.cache.heights.delete(lineIndex);\n }\n // Non-standard height, cache it\n else {\n this.cache.heights.set(lineIndex, measuredHeight);\n }\n }\n\n if (hasHeightChange || this.isResizeDebuggingEnabled()) {\n this.computeApproximateSize(true);\n }\n return hasHeightChange;\n }\n\n public onRender = (dirty: boolean): boolean => {\n if (this.fileContainer == null || this.file == null) {\n return false;\n }\n if (dirty) {\n this.top = this.getVirtualizedTop();\n }\n return this.render({ file: this.file });\n };\n\n // Prepares this item for CodeView layout by binding the latest file, syncing\n // its virtualized top, and returning an approximate height. This method is\n // called while downstream items are being re-positioned, so later changes\n // should keep clean instances on a cached-height fast path.\n public prepareCodeViewItem(\n file: FileContents,\n top: number,\n reset?: PendingCodeViewLayoutReset\n ): number {\n let shouldResetLayoutCache = reset?.resetFileLayoutCache === true;\n if (reset?.metrics != null) {\n this.metrics = reset.metrics;\n shouldResetLayoutCache = true;\n }\n\n const { collapsed = false } = this.options;\n if (this.currentCollapsed !== collapsed) {\n this.currentCollapsed = collapsed;\n shouldResetLayoutCache = true;\n }\n\n if (shouldResetLayoutCache) {\n this.resetLayoutCache();\n }\n\n if (this.file !== file) {\n this.layoutDirty = true;\n }\n this.file = file;\n this.top = top;\n this.computeApproximateSize();\n return this.height;\n }\n\n public getLinePosition(\n lineNumber: number\n ): { top: number; height: number } | undefined {\n if (this.file == null) {\n return undefined;\n }\n\n const { disableFileHeader = false, collapsed = false } = this.options;\n const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;\n let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);\n\n if (collapsed || lastLineIndex < 0) {\n return { top, height: 0 };\n }\n\n const clampedLineIndex = Math.min(\n Math.max(lineNumber - 1, 0),\n lastLineIndex\n );\n const { overflow = 'scroll' } = this.options;\n const { lineHeight } = this.metrics;\n\n if (overflow === 'scroll' && this.lineAnnotations.length === 0) {\n return {\n top: top + clampedLineIndex * lineHeight,\n height: lineHeight,\n };\n }\n\n const checkpoint =\n this.getLayoutCheckpointBeforeLineIndex(clampedLineIndex);\n top = checkpoint?.top ?? top;\n for (\n let lineIndex = checkpoint?.lineIndex ?? 0;\n lineIndex < clampedLineIndex;\n lineIndex++\n ) {\n top += this.getLineHeight(lineIndex, false);\n }\n\n return {\n top,\n height: this.getLineHeight(clampedLineIndex, false),\n };\n }\n\n public getNumericScrollAnchor(\n localViewportTop: number\n ): NumericScrollLineAnchor | undefined {\n if (this.file == null || this.renderRange == null) {\n return undefined;\n }\n\n const {\n disableFileHeader = false,\n collapsed = false,\n overflow = 'scroll',\n } = this.options;\n if (collapsed || this.renderRange.totalLines <= 0) {\n return undefined;\n }\n\n const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;\n if (lastLineIndex < 0) {\n return undefined;\n }\n\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const firstRenderedLineIndex = Math.min(\n this.renderRange.startingLine,\n lastLineIndex\n );\n const lastRenderedLineIndex = Math.min(\n firstRenderedLineIndex + this.renderRange.totalLines - 1,\n lastLineIndex\n );\n if (lastRenderedLineIndex < firstRenderedLineIndex) {\n return undefined;\n }\n\n // If we don't allow line wrapping and have no annotations, we can just\n // multiply our way to the the correct value\n if (overflow === 'scroll' && this.lineAnnotations.length === 0) {\n const { lineHeight } = this.metrics;\n const firstRenderedLineTop = headerRegion + this.renderRange.bufferBefore;\n const deltaLineCount = Math.max(\n Math.ceil((localViewportTop - firstRenderedLineTop) / lineHeight),\n 0\n );\n const lineIndex = firstRenderedLineIndex + deltaLineCount;\n if (lineIndex > lastRenderedLineIndex) {\n return undefined;\n }\n\n return {\n lineNumber: lineIndex + 1,\n top: headerRegion + lineIndex * lineHeight,\n };\n }\n\n // Otherwise we gotta iterate through the range\n let top = headerRegion + this.renderRange.bufferBefore;\n for (\n let lineIndex = firstRenderedLineIndex;\n lineIndex <= lastRenderedLineIndex;\n lineIndex++\n ) {\n if (top >= localViewportTop) {\n return {\n lineNumber: lineIndex + 1,\n top,\n };\n }\n top += this.getLineHeight(lineIndex);\n }\n\n return undefined;\n }\n\n public getVirtualizedHeight(): number {\n return this.height;\n }\n\n public getAdvancedStickySpecs(\n windowSpecs?: RenderWindow\n ): StickySpecs | undefined {\n if (this.top == null || this.file == null) {\n return undefined;\n }\n if (this.options.collapsed === true) {\n return { topOffset: this.top, height: this.height };\n }\n const renderRange =\n windowSpecs != null\n ? this.computeRenderRangeFromWindow(this.file, this.top, windowSpecs)\n : this.renderRange;\n if (renderRange == null) {\n return undefined;\n }\n const { bufferBefore, bufferAfter, totalLines } = renderRange;\n return {\n topOffset: this.top + bufferBefore + (totalLines === 0 ? bufferAfter : 0),\n height: this.height - (bufferBefore + bufferAfter),\n };\n }\n\n override cleanUp(recycle = false): void {\n if (this.fileContainer != null && this.isSimpleMode()) {\n this.getSimpleVirtualizer()?.disconnect(this.fileContainer);\n }\n if (!recycle) {\n this.layoutDirty = true;\n }\n this.isSetup = false;\n super.cleanUp(recycle);\n }\n\n // Compute the approximate size of the file using cached line heights.\n // Uses lineHeight for lines without cached measurements.\n private computeApproximateSize(force = false): void {\n const shouldValidateSize = this.isResizeDebuggingEnabled();\n if (!force && !this.layoutDirty && !shouldValidateSize) {\n return;\n }\n\n const isFirstCompute = this.height === 0;\n this.height = 0;\n this.cache.checkpoints = [];\n if (this.file == null) {\n this.layoutDirty = false;\n return;\n }\n\n const {\n disableFileHeader = false,\n collapsed = false,\n overflow = 'scroll',\n } = this.options;\n const { lineHeight } = this.metrics;\n const lineCount = this.fileRenderer.getLineCount(this.file);\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const paddingBottom = getVirtualFilePaddingBottom(this.metrics);\n\n this.height += headerRegion;\n if (collapsed) {\n this.layoutDirty = false;\n return;\n }\n\n if (overflow === 'scroll' && this.lineAnnotations.length === 0) {\n this.height += lineCount * lineHeight;\n } else {\n for (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {\n this.addLayoutCheckpoint(lineIndex, this.height);\n this.height += this.getLineHeight(lineIndex, false);\n }\n }\n\n if (lineCount > 0) {\n this.height += paddingBottom;\n }\n\n if (this.fileContainer != null && shouldValidateSize && !isFirstCompute) {\n const rect = this.fileContainer.getBoundingClientRect();\n if (rect.height !== this.height) {\n console.log(\n 'VirtualizedFile.computeApproximateSize: computed height doesnt match',\n {\n name: this.file.name,\n elementHeight: rect.height,\n computedHeight: this.height,\n }\n );\n } else {\n console.log(\n 'VirtualizedFile.computeApproximateSize: computed height IS CORRECT'\n );\n }\n }\n this.layoutDirty = false;\n }\n\n public setVisibility(visible: boolean): void {\n if (this.isAdvancedMode() || this.fileContainer == null) {\n return;\n }\n if (visible && !this.isVisible) {\n this.top = this.getVirtualizedTop();\n this.isVisible = true;\n } else if (!visible && this.isVisible) {\n this.isVisible = false;\n this.rerender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.file == null) {\n return;\n }\n this.forceRenderOverride = true;\n this.virtualizer.instanceChanged(this, false);\n }\n\n override applyLayoutChange(\n textDocument: DiffsTextDocument,\n newLineAnnotations?: LineAnnotation<LAnnotation>[],\n shouldUpdateBuffer = false\n ): void {\n const previousRenderRange = this.renderRange;\n super.applyLayoutChange(textDocument, newLineAnnotations);\n this.getSimpleVirtualizer()?.markDOMDirty();\n this.resetLayoutCache(true);\n // Update the buffers caused by the line-count change to ensure the editor\n // scrolls to the correct position before re-rendering\n if (\n shouldUpdateBuffer &&\n previousRenderRange !== undefined &&\n this.file !== undefined\n ) {\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const renderRange = this.computeRenderRangeFromWindow(\n this.file,\n this.top ?? 0,\n windowSpecs\n );\n if (renderRange.bufferAfter !== previousRenderRange.bufferAfter) {\n this.updateBuffers(renderRange);\n }\n }\n }\n\n override render({\n fileContainer,\n file,\n forceRender = false,\n ...props\n }: FileRenderProps<LAnnotation>): boolean {\n const didFileChange = this.file == null || !areFilesEqual(this.file, file);\n const { forceRenderOverride, isSetup } = this;\n this.forceRenderOverride = undefined;\n\n this.file = file;\n\n fileContainer = this.getOrCreateFileContainerNode(fileContainer);\n\n if (this.file == null) {\n console.error(\n 'VirtualizedFile.render: attempting to virtually render when we dont have file'\n );\n return false;\n }\n\n if (!isSetup) {\n this.computeApproximateSize();\n const virtualizer = this.getSimpleVirtualizer();\n this.top ??= this.getVirtualizedTop();\n if (this.isAdvancedMode()) {\n this.isVisible = true;\n } else {\n if (virtualizer == null) {\n throw new Error(\n 'VirtualizedFile.render: simple virtualizer is not available'\n );\n }\n virtualizer.connect(fileContainer, this);\n this.isVisible = virtualizer.isInstanceVisible(\n this.top ?? 0,\n this.height\n );\n }\n this.isSetup = true;\n } else {\n this.top ??= this.getVirtualizedTop();\n if (didFileChange && this.isSimpleMode()) {\n this.getSimpleVirtualizer()?.markDOMDirty();\n this.resetLayoutCache(true);\n }\n }\n\n if (!this.isVisible && this.isSimpleMode()) {\n return this.renderPlaceholder(this.height);\n }\n\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const fileTop = this.top ?? 0;\n const renderRange = this.computeRenderRangeFromWindow(\n this.file,\n fileTop,\n windowSpecs\n );\n return super.render({\n file: this.file,\n fileContainer,\n renderRange,\n forceRender: forceRenderOverride ?? forceRender,\n ...props,\n });\n }\n\n public syncVirtualizedTop(): void {\n this.top = this.getVirtualizedTop();\n }\n\n protected override shouldDisableVirtualizationBuffers(): boolean {\n return this.isAdvancedMode() || super.shouldDisableVirtualizationBuffers();\n }\n\n private isSimpleMode(): boolean {\n return this.virtualizer.type === 'simple';\n }\n\n private isAdvancedMode(): boolean {\n return this.virtualizer.type === 'advanced';\n }\n\n private addLayoutCheckpoint(lineIndex: number, top: number): void {\n if (lineIndex % LAYOUT_CHECKPOINT_INTERVAL !== 0) {\n return;\n }\n this.cache.checkpoints.push({ lineIndex, top });\n }\n\n // Find the nearest sparse layout checkpoint at or before a raw file line.\n // Checkpoints store measured `top` offsets every few thousand lines, so a\n // binary search lets deep line-position lookups resume from that checkpoint\n // instead of replaying layout from the start of the file.\n private getLayoutCheckpointBeforeLineIndex(\n lineIndex: number\n ): FileLayoutCheckpoint | undefined {\n if (lineIndex <= 0 || this.cache.checkpoints.length === 0) {\n return undefined;\n }\n\n let low = 0;\n let high = this.cache.checkpoints.length - 1;\n let result: FileLayoutCheckpoint | undefined;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const checkpoint = this.cache.checkpoints[mid];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.lineIndex <= lineIndex) {\n result = checkpoint;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n return result;\n }\n\n // Find the nearest sparse layout checkpoint at or before a scroll offset.\n // Render-range scans start from this checkpoint so variable-height files\n // only replay the nearby measured rows. When `hunkLineCount` is provided,\n // step backward to a hunk boundary so hooks that depend on grouped lines\n // still see a complete hunk.\n private getLayoutCheckpointBeforeTop(\n top: number,\n hunkLineCount?: number\n ): FileLayoutCheckpoint | undefined {\n let low = 0;\n let high = this.cache.checkpoints.length - 1;\n let resultIndex = -1;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const checkpoint = this.cache.checkpoints[mid];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.top <= top) {\n resultIndex = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n if (hunkLineCount == null) {\n return resultIndex >= 0 ? this.cache.checkpoints[resultIndex] : undefined;\n }\n\n for (let index = resultIndex; index >= 0; index--) {\n const checkpoint = this.cache.checkpoints[index];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.lineIndex % hunkLineCount === 0) {\n return checkpoint;\n }\n }\n\n return undefined;\n }\n\n private getVirtualizedTop(): number {\n if (this.virtualizer.type === 'advanced') {\n return this.virtualizer.getLocalTopForInstance(this);\n }\n return this.fileContainer != null\n ? this.virtualizer.getOffsetInScrollContainer(this.fileContainer)\n : 0;\n }\n\n private getSimpleVirtualizer(): Virtualizer | undefined {\n return this.virtualizer.type === 'simple' ? this.virtualizer : undefined;\n }\n\n private isResizeDebuggingEnabled(): boolean {\n return this.getSimpleVirtualizer()?.config.resizeDebugging ?? false;\n }\n\n private computeRenderRangeFromWindow(\n file: FileContents,\n fileTop: number,\n { top, bottom }: RenderWindow\n ): RenderRange {\n const { disableFileHeader = false, overflow = 'scroll' } = this.options;\n const { hunkLineCount, lineHeight } = this.metrics;\n const lineCount = this.fileRenderer.getLineCount(file);\n const fileHeight = this.height;\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const paddingBottom =\n lineCount > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;\n\n // File is outside render window\n if (fileTop < top - fileHeight || fileTop > bottom) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: fileHeight - headerRegion - paddingBottom,\n };\n }\n\n // Small file, just render it all\n if (lineCount <= hunkLineCount) {\n return {\n startingLine: 0,\n totalLines: hunkLineCount,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n\n // Calculate totalLines based on viewport size\n const estimatedTargetLines = Math.ceil(\n Math.max(bottom - top, 0) / lineHeight\n );\n const totalLines =\n Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount +\n hunkLineCount * 2;\n const totalHunks = totalLines / hunkLineCount;\n const viewportCenter = (top + bottom) / 2;\n\n // Simple case: overflow scroll with no annotations - pure math!\n if (overflow === 'scroll' && this.lineAnnotations.length === 0) {\n // Find which line is at viewport center\n const centerLine = Math.floor(\n (viewportCenter - (fileTop + headerRegion)) / lineHeight\n );\n const centerHunk = Math.floor(centerLine / hunkLineCount);\n\n // Calculate ideal start centered around viewport\n const idealStartHunk = centerHunk - Math.floor(totalHunks / 2);\n const totalHunksInFile = Math.ceil(lineCount / hunkLineCount);\n const startingLine =\n Math.max(0, Math.min(idealStartHunk, totalHunksInFile)) * hunkLineCount;\n\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n const bufferBefore = startingLine * lineHeight;\n const renderedLines = Math.min(\n clampedTotalLines,\n lineCount - startingLine\n );\n const bufferAfter = Math.max(\n 0,\n (lineCount - startingLine - renderedLines) * lineHeight\n );\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter,\n };\n }\n\n // Complex case: need to account for line annotations or wrap overflow\n const overflowHunks = totalHunks;\n const hunkOffsets: number[] = [];\n // Start the scan before the viewport so we collect hunk offsets that may be\n // needed for bufferBefore. This only chooses the scan origin; the returned\n // render range is still computed from the visible window below.\n const checkpoint = this.getLayoutCheckpointBeforeTop(\n Math.max(0, top - fileTop - totalLines * lineHeight * 2),\n hunkLineCount\n );\n\n let absoluteLineTop = fileTop + (checkpoint?.top ?? headerRegion);\n let currentLine = checkpoint?.lineIndex ?? 0;\n let firstVisibleHunk: number | undefined;\n let centerHunk: number | undefined;\n let overflowCounter: number | undefined;\n\n const startingLineIndex = checkpoint?.lineIndex ?? 0;\n for (\n let lineIndex = startingLineIndex;\n lineIndex < lineCount;\n lineIndex++\n ) {\n const isAtHunkBoundary = currentLine % hunkLineCount === 0;\n const currentHunk = Math.floor(currentLine / hunkLineCount);\n\n if (isAtHunkBoundary) {\n hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + headerRegion);\n\n if (overflowCounter != null) {\n if (overflowCounter <= 0) {\n break;\n }\n overflowCounter--;\n }\n }\n\n const lineHeight = this.getLineHeight(lineIndex, false);\n\n // Track visible region\n if (absoluteLineTop > top - lineHeight && absoluteLineTop < bottom) {\n firstVisibleHunk ??= currentHunk;\n }\n\n // Track which hunk contains the viewport center\n if (absoluteLineTop + lineHeight > viewportCenter) {\n centerHunk ??= currentHunk;\n }\n\n // Start overflow when we are out of the viewport at a hunk boundary\n if (\n overflowCounter == null &&\n absoluteLineTop >= bottom &&\n isAtHunkBoundary\n ) {\n overflowCounter = overflowHunks;\n }\n\n currentLine++;\n absoluteLineTop += lineHeight;\n }\n\n // No visible lines found\n if (firstVisibleHunk == null) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: fileHeight - headerRegion - paddingBottom,\n };\n }\n\n // Calculate balanced startingLine centered around the viewport center\n centerHunk ??= firstVisibleHunk;\n const idealStartHunk = Math.round(centerHunk - totalHunks / 2);\n\n // Clamp startHunk: at the beginning, reduce totalLines; at the end, shift\n // startHunk back\n const maxStartHunk = Math.max(\n 0,\n Math.ceil(lineCount / hunkLineCount) - totalHunks\n );\n const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));\n const startingLine = startHunk * hunkLineCount;\n\n // If we wanted to start before 0, reduce totalLines by the clamped amount\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n // Use hunkOffsets array for efficient buffer calculations\n const bufferBefore = hunkOffsets[startHunk] ?? 0;\n\n // Calculate bufferAfter\n const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;\n const bufferAfter =\n finalHunkIndex < hunkOffsets.length\n ? fileHeight -\n headerRegion -\n hunkOffsets[finalHunkIndex] -\n paddingBottom\n : fileHeight - (absoluteLineTop - fileTop) - paddingBottom;\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter,\n };\n }\n}\n"],"mappings":";;;;;;;;AAuCA,MAAM,6BAA6B;AAEnC,IAAI,aAAa;AAEjB,SAAS,2BACP,iBACA,aACS;AACT,SACG,gBAAgB,YAAY,eAC1B,YAAY,YAAY,cAC1B,gBAAgB,aAAa,YAAY,YAAY,aAAa,WAClE,gBAAgB,sBAAsB,YACpC,YAAY,sBAAsB,WACpC,gBAAgB,qBAAqB,YACnC,YAAY,qBAAqB,UACpC,gBAAgB,cAAc,YAAY;;AAI9C,IAAa,kBAAb,cAEU,KAAkB;CAC1B,AA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B;EAGN,MAAM,eAAe,YAAY,cAAc;EAG/C,MAAM,iBAAiB,YAAY,oBAAoB;AASvD,SAAO;GACL;GACA,YAAY;GACZ;GACA,aAXA,iBAAiB,YAAY,SACzB,aACA,eACA,YAAY,kBACZ,gBACA,cAAc,kBAAkB,WAAW;GAOhD"}
1
+ {"version":3,"file":"VirtualizedFile.js","names":[],"sources":["../../src/components/VirtualizedFile.ts"],"sourcesContent":["import { DEFAULT_VIRTUAL_FILE_METRICS } from '../constants';\nimport type {\n DiffsTextDocument,\n FileContents,\n LineAnnotation,\n NumericScrollLineAnchor,\n PendingCodeViewLayoutReset,\n RenderRange,\n RenderWindow,\n StickySpecs,\n ThemeTypes,\n VirtualFileMetrics,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areObjectsEqual } from '../utils/areObjectsEqual';\nimport { areOptionsEqual } from '../utils/areOptionsEqual';\nimport {\n getVirtualFileHeaderRegion,\n getVirtualFilePaddingBottom,\n} from '../utils/computeVirtualFileMetrics';\nimport {\n FILE_ANNOTATION_DOM_KEY,\n FILE_ANNOTATION_LINE_NUMBER,\n includesFileAnnotations,\n shouldRenderFileAnnotations,\n} from '../utils/includesFileAnnotations';\nimport type { WorkerPoolManager } from '../worker';\nimport type { CodeView } from './CodeView';\nimport { File, type FileOptions, type FileRenderProps } from './File';\nimport type { Virtualizer } from './Virtualizer';\n\ninterface FileLayoutCheckpoint {\n lineIndex: number;\n top: number;\n}\n\ninterface FileLayoutCache {\n // Sparse map: line index -> measured height. Only stores lines that differ\n // from what is returned by `getLineHeight`.\n heights: Map<number, number>;\n // Sparse measured positions used to resume deep geometry scans near a target\n // line or scroll offset instead of replaying layout from the start.\n checkpoints: FileLayoutCheckpoint[];\n // Measured height for the file-level annotation row. Starts at 0 so\n // unmeasured annotations behave like all other unmeasured annotations.\n fileAnnotationHeight: number;\n}\n\nconst LAYOUT_CHECKPOINT_INTERVAL = 5_000;\n\nlet instanceId = -1;\n\nfunction hasFileLayoutOptionChanged<LAnnotation>(\n previousOptions: FileOptions<LAnnotation>,\n nextOptions: FileOptions<LAnnotation>\n): boolean {\n return (\n (previousOptions.overflow ?? 'scroll') !==\n (nextOptions.overflow ?? 'scroll') ||\n (previousOptions.collapsed ?? false) !== (nextOptions.collapsed ?? false) ||\n (previousOptions.disableLineNumbers ?? false) !==\n (nextOptions.disableLineNumbers ?? false) ||\n (previousOptions.disableFileHeader ?? false) !==\n (nextOptions.disableFileHeader ?? false) ||\n previousOptions.unsafeCSS !== nextOptions.unsafeCSS\n );\n}\n\nexport class VirtualizedFile<\n LAnnotation = undefined,\n> extends File<LAnnotation> {\n override readonly __id: string = `virtualized-file:${++instanceId}`;\n\n public top: number | undefined;\n public height: number = 0;\n private cache: FileLayoutCache = {\n heights: new Map(),\n checkpoints: [],\n fileAnnotationHeight: 0,\n };\n private isVisible: boolean = false;\n private isSetup: boolean = false;\n private layoutDirty = true;\n private forceRenderOverride: true | undefined;\n private currentCollapsed: boolean | undefined;\n\n constructor(\n options: FileOptions<LAnnotation> | undefined,\n private virtualizer: Virtualizer | CodeView<LAnnotation>,\n private metrics: VirtualFileMetrics = DEFAULT_VIRTUAL_FILE_METRICS,\n workerManager?: WorkerPoolManager,\n isContainerManaged = false\n ) {\n super(options, workerManager, isContainerManaged);\n }\n\n public setMetrics(metrics: VirtualFileMetrics, force = false): void {\n if (!force && areObjectsEqual(this.metrics, metrics)) {\n return;\n }\n\n this.metrics = metrics;\n this.resetLayoutCache();\n }\n\n override setLineAnnotations(\n lineAnnotations: LineAnnotation<LAnnotation>[]\n ): void {\n if (this.syncLineAnnotations(lineAnnotations)) {\n this.resetLayoutCache();\n }\n }\n\n private syncLineAnnotations(\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined\n ): boolean {\n if (lineAnnotations == null || lineAnnotations === this.lineAnnotations) {\n return false;\n }\n if (lineAnnotations.length === 0 && this.lineAnnotations.length === 0) {\n return false;\n }\n\n super.setLineAnnotations(lineAnnotations);\n return true;\n }\n\n private hasLineAnnotations(): boolean {\n return this.lineAnnotations.some(\n (annotation) => annotation.lineNumber > FILE_ANNOTATION_LINE_NUMBER\n );\n }\n\n // Get the height for a line, using cached value if available.\n // If not cached and hasMetadataLine is true, adds lineHeight for the\n // metadata.\n public getLineHeight(lineIndex: number, hasMetadataLine = false): number {\n const cached = this.cache.heights.get(lineIndex);\n if (cached != null) {\n return cached;\n }\n const multiplier = hasMetadataLine ? 2 : 1;\n return this.metrics.lineHeight * multiplier;\n }\n\n override setOptions(options: FileOptions<LAnnotation> | undefined): void {\n if (this.isAdvancedMode()) {\n throw new Error(\n 'VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.'\n );\n }\n\n if (options == null) return;\n const { options: previousOptions } = this;\n const optionsChanged = !areOptionsEqual(previousOptions, options);\n const layoutChanged = hasFileLayoutOptionChanged(previousOptions, options);\n\n super.setOptions(options);\n\n if (layoutChanged) {\n this.resetLayoutCache(true);\n }\n // Any option can affect rendered DOM; only layout-affecting options clear\n // the measured height cache above.\n if (optionsChanged) {\n this.forceRenderOverride = true;\n }\n if (optionsChanged) {\n this.virtualizer.instanceChanged(this, layoutChanged);\n }\n }\n\n override setThemeType(themeType: ThemeTypes): void {\n if (this.isAdvancedMode()) {\n throw new Error(\n 'VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.'\n );\n }\n\n super.setThemeType(themeType);\n }\n\n private resetLayoutCache(recompute = false, resetRenderRange = true): void {\n this.layoutDirty = true;\n this.cache.fileAnnotationHeight = 0;\n if (this.cache.heights.size > 0) {\n this.cache.heights.clear();\n }\n if (this.cache.checkpoints.length > 0) {\n this.cache.checkpoints.length = 0;\n }\n if (this.renderRange != null && resetRenderRange) {\n this.renderRange = undefined;\n }\n // NOTE(amadeus): In CodeView we intentionally batch computes to all happen\n // at the same time, so we shouldn't trigger this there.\n if (recompute && this.isSimpleMode()) {\n this.computeApproximateSize();\n }\n }\n\n // Measure rendered lines and update height cache.\n // Called after render to reconcile estimated vs actual heights.\n public reconcileHeights(): boolean {\n let hasHeightChange = false;\n if (this.fileContainer == null || this.file == null) {\n if (this.height !== 0) {\n hasHeightChange = true;\n }\n this.height = 0;\n return hasHeightChange;\n }\n const { overflow = 'scroll' } = this.options;\n this.top = this.getVirtualizedTop();\n\n // If the file has no annotations and we are using the scroll variant, then\n // we can probably skip everything\n if (\n overflow === 'scroll' &&\n this.lineAnnotations.length === 0 &&\n !this.isResizeDebuggingEnabled()\n ) {\n return hasHeightChange;\n }\n\n // Single code element (no split mode)\n if (this.code == null) {\n return hasHeightChange;\n }\n const content = this.code.children[1]; // Content column (gutter is [0])\n if (!(content instanceof HTMLElement)) {\n return hasHeightChange;\n }\n\n const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);\n if (\n this.renderRange != null &&\n hasFileAnnotations &&\n shouldRenderFileAnnotations(this.renderRange)\n ) {\n const fileAnnotationHeight = measureFileAnnotationHeight(content);\n const nextFileAnnotationHeight = fileAnnotationHeight ?? 0;\n if (nextFileAnnotationHeight !== this.cache.fileAnnotationHeight) {\n this.cache.fileAnnotationHeight = nextFileAnnotationHeight;\n hasHeightChange = true;\n }\n } else if (!hasFileAnnotations && this.cache.fileAnnotationHeight !== 0) {\n this.cache.fileAnnotationHeight = 0;\n hasHeightChange = true;\n }\n\n for (const line of content.children) {\n if (!(line instanceof HTMLElement)) continue;\n\n const lineIndexAttr = line.dataset.lineIndex;\n if (lineIndexAttr == null) continue;\n\n const lineIndex = Number(lineIndexAttr);\n let measuredHeight = line.getBoundingClientRect().height;\n let hasMetadata = false;\n\n // Annotations or noNewline metadata increase the size of their attached line\n if (\n line.nextElementSibling instanceof HTMLElement &&\n ('lineAnnotation' in line.nextElementSibling.dataset ||\n 'noNewline' in line.nextElementSibling.dataset)\n ) {\n if ('noNewline' in line.nextElementSibling.dataset) {\n hasMetadata = true;\n }\n measuredHeight +=\n line.nextElementSibling.getBoundingClientRect().height;\n }\n\n const expectedHeight = this.getLineHeight(lineIndex, hasMetadata);\n\n if (measuredHeight === expectedHeight) {\n continue;\n }\n\n hasHeightChange = true;\n // Line is back to standard height (e.g., after window resize)\n // Remove from cache\n if (measuredHeight === this.metrics.lineHeight * (hasMetadata ? 2 : 1)) {\n this.cache.heights.delete(lineIndex);\n }\n // Non-standard height, cache it\n else {\n this.cache.heights.set(lineIndex, measuredHeight);\n }\n }\n\n if (hasHeightChange || this.isResizeDebuggingEnabled()) {\n this.computeApproximateSize(true);\n }\n return hasHeightChange;\n }\n\n public onRender = (dirty: boolean): boolean => {\n if (this.fileContainer == null || this.file == null) {\n return false;\n }\n if (dirty) {\n this.top = this.getVirtualizedTop();\n }\n return this.render({ file: this.file });\n };\n\n // Prepares this item for CodeView layout by binding the latest file, syncing\n // its virtualized top, and returning an approximate height. This method is\n // called while downstream items are being re-positioned, so later changes\n // should keep clean instances on a cached-height fast path.\n public prepareCodeViewItem(\n file: FileContents,\n top: number,\n reset?: PendingCodeViewLayoutReset,\n lineAnnotations?: LineAnnotation<LAnnotation>[]\n ): number {\n const annotationsChanged = this.syncLineAnnotations(lineAnnotations);\n const unkeyedContentsChanged =\n this.fileRenderer.hasUnkeyedFileContentsChanged(file);\n let shouldResetLayoutCache =\n reset?.resetFileLayoutCache === true ||\n annotationsChanged ||\n unkeyedContentsChanged;\n if (reset?.metrics != null) {\n this.metrics = reset.metrics;\n shouldResetLayoutCache = true;\n }\n\n const { collapsed = false } = this.options;\n if (this.currentCollapsed !== collapsed) {\n this.currentCollapsed = collapsed;\n shouldResetLayoutCache = true;\n }\n\n if (shouldResetLayoutCache) {\n this.resetLayoutCache();\n }\n\n if (this.file !== file) {\n this.layoutDirty = true;\n }\n this.file = file;\n this.top = top;\n this.computeApproximateSize();\n return this.height;\n }\n\n public getLinePosition(\n lineNumber: number\n ): { top: number; height: number } | undefined {\n if (this.file == null || lineNumber < 1) {\n return undefined;\n }\n\n const { disableFileHeader = false, collapsed = false } = this.options;\n const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;\n let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);\n\n if (collapsed || lastLineIndex < 0) {\n return { top, height: 0 };\n }\n\n const clampedLineIndex = Math.min(\n Math.max(lineNumber - 1, 0),\n lastLineIndex\n );\n const { overflow = 'scroll' } = this.options;\n const { lineHeight } = this.metrics;\n top += this.cache.fileAnnotationHeight;\n\n if (overflow === 'scroll' && !this.hasLineAnnotations()) {\n return {\n top: top + clampedLineIndex * lineHeight,\n height: lineHeight,\n };\n }\n\n const checkpoint =\n this.getLayoutCheckpointBeforeLineIndex(clampedLineIndex);\n top = checkpoint?.top ?? top;\n for (\n let lineIndex = checkpoint?.lineIndex ?? 0;\n lineIndex < clampedLineIndex;\n lineIndex++\n ) {\n top += this.getLineHeight(lineIndex, false);\n }\n\n return {\n top,\n height: this.getLineHeight(clampedLineIndex, false),\n };\n }\n\n public getScrollContainer(): HTMLElement | undefined {\n const root = this.getSimpleVirtualizer()?.getRoot();\n return root instanceof HTMLElement ? root : root?.documentElement;\n }\n\n public getNumericScrollAnchor(\n localViewportTop: number\n ): NumericScrollLineAnchor | undefined {\n if (this.file == null || this.renderRange == null) {\n return undefined;\n }\n\n const {\n disableFileHeader = false,\n collapsed = false,\n overflow = 'scroll',\n } = this.options;\n if (collapsed || this.renderRange.totalLines <= 0) {\n return undefined;\n }\n\n const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;\n if (lastLineIndex < 0) {\n return undefined;\n }\n\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const firstRenderedLineIndex = Math.min(\n this.renderRange.startingLine,\n lastLineIndex\n );\n const lastRenderedLineIndex = Math.min(\n firstRenderedLineIndex + this.renderRange.totalLines - 1,\n lastLineIndex\n );\n if (lastRenderedLineIndex < firstRenderedLineIndex) {\n return undefined;\n }\n const { fileAnnotationHeight } = this.cache;\n\n // If we don't allow line wrapping and have no annotations, we can just\n // multiply our way to the the correct value\n if (overflow === 'scroll' && !this.hasLineAnnotations()) {\n const { lineHeight } = this.metrics;\n const firstRenderedLineTop =\n headerRegion +\n (firstRenderedLineIndex === 0\n ? fileAnnotationHeight\n : this.renderRange.bufferBefore);\n const deltaLineCount = Math.max(\n Math.ceil((localViewportTop - firstRenderedLineTop) / lineHeight),\n 0\n );\n const lineIndex = firstRenderedLineIndex + deltaLineCount;\n if (lineIndex > lastRenderedLineIndex) {\n return undefined;\n }\n\n return {\n lineNumber: lineIndex + 1,\n top: headerRegion + fileAnnotationHeight + lineIndex * lineHeight,\n };\n }\n\n // Otherwise we gotta iterate through the range\n let top =\n headerRegion +\n (firstRenderedLineIndex === 0\n ? fileAnnotationHeight\n : this.renderRange.bufferBefore);\n for (\n let lineIndex = firstRenderedLineIndex;\n lineIndex <= lastRenderedLineIndex;\n lineIndex++\n ) {\n if (top >= localViewportTop) {\n return {\n lineNumber: lineIndex + 1,\n top,\n };\n }\n top += this.getLineHeight(lineIndex);\n }\n\n return undefined;\n }\n\n public getVirtualizedHeight(): number {\n return this.height;\n }\n\n public getAdvancedStickySpecs(\n windowSpecs?: RenderWindow\n ): StickySpecs | undefined {\n if (this.top == null || this.file == null) {\n return undefined;\n }\n if (this.options.collapsed === true) {\n return { topOffset: this.top, height: this.height };\n }\n const renderRange =\n windowSpecs != null\n ? this.computeRenderRangeFromWindow(this.file, this.top, windowSpecs)\n : this.renderRange;\n if (renderRange == null) {\n return undefined;\n }\n const { bufferBefore, bufferAfter, totalLines } = renderRange;\n // Rendered items flow contiguously in the sticky container with no buffer\n // spacers, so a header-only item (totalLines === 0, none of its rows fall\n // inside the window) must report where its header actually sits in that\n // flow, which depends on which side of the window its content is on:\n // - content ABOVE the window (item starts above window.top): the header\n // sits at the item's bottom so the following item connects, so offset by\n // bufferAfter.\n // - content BELOW the window (item starts at/after window.top, e.g. a\n // trailing header peeking in at the bottom): the header renders at the\n // item's top with nothing after it, so no offset. Always adding\n // bufferAfter here made getStickyBounds over-measure the sticky\n // container for that trailing case.\n let headerOnlyOffset = 0;\n if (totalLines === 0) {\n const activeWindow = windowSpecs ?? this.virtualizer.getWindowSpecs();\n if (this.top < activeWindow.top) {\n headerOnlyOffset = bufferAfter;\n }\n }\n return {\n topOffset: this.top + bufferBefore + headerOnlyOffset,\n height: this.height - (bufferBefore + bufferAfter),\n };\n }\n\n override cleanUp(recycle = false): void {\n if (this.fileContainer != null && this.isSimpleMode()) {\n this.getSimpleVirtualizer()?.disconnect(this.fileContainer);\n }\n if (!recycle) {\n this.resetLayoutCache();\n }\n this.isSetup = false;\n super.cleanUp(recycle);\n }\n\n // Compute the approximate size of the file using cached line heights.\n // Uses lineHeight for lines without cached measurements.\n private computeApproximateSize(force = false): void {\n const shouldValidateSize = this.isResizeDebuggingEnabled();\n if (!force && !this.layoutDirty && !shouldValidateSize) {\n return;\n }\n\n const isFirstCompute = this.height === 0;\n this.height = 0;\n this.cache.checkpoints = [];\n if (this.file == null) {\n this.layoutDirty = false;\n return;\n }\n\n const {\n disableFileHeader = false,\n collapsed = false,\n overflow = 'scroll',\n } = this.options;\n const { lineHeight } = this.metrics;\n const lineCount = this.fileRenderer.getLineCount(this.file);\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const paddingBottom = getVirtualFilePaddingBottom(this.metrics);\n\n this.height += headerRegion;\n if (collapsed) {\n this.layoutDirty = false;\n return;\n }\n\n this.height += this.cache.fileAnnotationHeight;\n\n if (overflow === 'scroll' && !this.hasLineAnnotations()) {\n this.height += lineCount * lineHeight;\n } else {\n for (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {\n this.addLayoutCheckpoint(lineIndex, this.height);\n this.height += this.getLineHeight(lineIndex, false);\n }\n }\n\n if (lineCount > 0) {\n this.height += paddingBottom;\n }\n\n if (this.fileContainer != null && shouldValidateSize && !isFirstCompute) {\n const rect = this.fileContainer.getBoundingClientRect();\n if (rect.height !== this.height) {\n console.log(\n 'VirtualizedFile.computeApproximateSize: computed height doesnt match',\n {\n name: this.file.name,\n elementHeight: rect.height,\n computedHeight: this.height,\n }\n );\n } else {\n console.log(\n 'VirtualizedFile.computeApproximateSize: computed height IS CORRECT'\n );\n }\n }\n this.layoutDirty = false;\n }\n\n public setVisibility(visible: boolean): void {\n if (this.isAdvancedMode() || this.fileContainer == null) {\n return;\n }\n if (visible && !this.isVisible) {\n this.top = this.getVirtualizedTop();\n this.isVisible = true;\n } else if (!visible && this.isVisible) {\n this.isVisible = false;\n this.rerender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.file == null) {\n return;\n }\n this.forceRenderOverride = true;\n this.virtualizer.instanceChanged(this, false);\n }\n\n // normally triggered by the host when the document line count changes\n override applyDocumentChange(\n textDocument: DiffsTextDocument,\n newLineAnnotations?: LineAnnotation<LAnnotation>[],\n shouldUpdateBuffer = false\n ): void {\n const previousRenderRange = this.renderRange;\n\n super.applyDocumentChange(textDocument, newLineAnnotations);\n\n // reset the layout cache\n this.getSimpleVirtualizer()?.markDOMDirty();\n this.resetLayoutCache(this.isSimpleMode(), false);\n\n // Update the buffers caused by the line-count change to ensure the host\n // scrolls to the correct position before re-rendering\n if (\n shouldUpdateBuffer &&\n previousRenderRange !== undefined &&\n this.file !== undefined\n ) {\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const renderRange = this.computeRenderRangeFromWindow(\n this.file,\n this.top ?? 0,\n windowSpecs\n );\n if (renderRange.bufferAfter !== previousRenderRange.bufferAfter) {\n this.updateBuffers(renderRange);\n }\n }\n }\n\n protected override renderPreparedFile({\n fileContainer,\n file,\n forceRender = false,\n lineAnnotations,\n ...props\n }: FileRenderProps<LAnnotation>): boolean {\n const didFileChange =\n this.file == null ||\n !areFilesEqual(this.file, file) ||\n this.fileRenderer.hasUnkeyedFileContentsChanged(file);\n const { forceRenderOverride, isSetup } = this;\n this.forceRenderOverride = undefined;\n const annotationsChanged = this.syncLineAnnotations(lineAnnotations);\n if (annotationsChanged) {\n this.resetLayoutCache();\n }\n\n this.file = file;\n\n fileContainer = this.getOrCreateFileContainerNode(fileContainer);\n\n if (this.file == null) {\n console.error(\n 'VirtualizedFile.render: attempting to virtually render when we dont have file'\n );\n return false;\n }\n\n if (!isSetup) {\n this.computeApproximateSize();\n const virtualizer = this.getSimpleVirtualizer();\n this.top ??= this.getVirtualizedTop();\n if (this.isAdvancedMode()) {\n this.isVisible = true;\n } else {\n if (virtualizer == null) {\n throw new Error(\n 'VirtualizedFile.render: simple virtualizer is not available'\n );\n }\n virtualizer.connect(fileContainer, this);\n this.isVisible = virtualizer.isInstanceVisible(\n this.top ?? 0,\n this.height\n );\n }\n this.isSetup = true;\n } else {\n this.top ??= this.getVirtualizedTop();\n if (didFileChange && this.isSimpleMode()) {\n this.getSimpleVirtualizer()?.markDOMDirty();\n this.resetLayoutCache(true);\n }\n }\n\n if (!this.isVisible && this.isSimpleMode()) {\n return this.renderPlaceholder(this.height);\n }\n\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const fileTop = this.top ?? 0;\n const renderRange = this.computeRenderRangeFromWindow(\n this.file,\n fileTop,\n windowSpecs\n );\n const rendered = super.renderPreparedFile({\n file: this.file,\n fileContainer,\n renderRange,\n lineAnnotations,\n forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged,\n ...props,\n });\n // Renders can be driven from outside the virtualizer (host/React render\n // calls, async highlight completions), and the virtualizer only\n // auto-reconciles renders it initiated. Queue a measured-height\n // reconciliation for every applied content render so line deltas\n // (wrapped lines, annotation heights) survive layout resets.\n if (this.isSimpleMode() && rendered) {\n this.getSimpleVirtualizer()?.requestHeightReconcile(this);\n }\n return rendered;\n }\n\n public syncVirtualizedTop(): void {\n this.top = this.getVirtualizedTop();\n }\n\n protected override shouldDisableVirtualizationBuffers(): boolean {\n return this.isAdvancedMode() || super.shouldDisableVirtualizationBuffers();\n }\n\n private isSimpleMode(): boolean {\n return this.virtualizer.type === 'simple';\n }\n\n private isAdvancedMode(): boolean {\n return this.virtualizer.type === 'advanced';\n }\n\n private addLayoutCheckpoint(lineIndex: number, top: number): void {\n if (lineIndex % LAYOUT_CHECKPOINT_INTERVAL !== 0) {\n return;\n }\n this.cache.checkpoints.push({ lineIndex, top });\n }\n\n // Find the nearest sparse layout checkpoint at or before a raw file line.\n // Checkpoints store measured `top` offsets every few thousand lines, so a\n // binary search lets deep line-position lookups resume from that checkpoint\n // instead of replaying layout from the start of the file.\n private getLayoutCheckpointBeforeLineIndex(\n lineIndex: number\n ): FileLayoutCheckpoint | undefined {\n if (lineIndex <= 0 || this.cache.checkpoints.length === 0) {\n return undefined;\n }\n\n let low = 0;\n let high = this.cache.checkpoints.length - 1;\n let result: FileLayoutCheckpoint | undefined;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const checkpoint = this.cache.checkpoints[mid];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.lineIndex <= lineIndex) {\n result = checkpoint;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n return result;\n }\n\n // Find the nearest sparse layout checkpoint at or before a scroll offset.\n // Render-range scans start from this checkpoint so variable-height files\n // only replay the nearby measured rows. When `hunkLineCount` is provided,\n // step backward to a hunk boundary so hooks that depend on grouped lines\n // still see a complete hunk.\n private getLayoutCheckpointBeforeTop(\n top: number,\n hunkLineCount?: number\n ): FileLayoutCheckpoint | undefined {\n let low = 0;\n let high = this.cache.checkpoints.length - 1;\n let resultIndex = -1;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const checkpoint = this.cache.checkpoints[mid];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.top <= top) {\n resultIndex = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n if (hunkLineCount == null) {\n return resultIndex >= 0 ? this.cache.checkpoints[resultIndex] : undefined;\n }\n\n for (let index = resultIndex; index >= 0; index--) {\n const checkpoint = this.cache.checkpoints[index];\n if (checkpoint == null) {\n throw new Error('VirtualizedFile: invalid checkpoint index');\n }\n if (checkpoint.lineIndex % hunkLineCount === 0) {\n return checkpoint;\n }\n }\n\n return undefined;\n }\n\n private getVirtualizedTop(): number {\n if (this.virtualizer.type === 'advanced') {\n return this.virtualizer.getLocalTopForInstance(this);\n }\n return this.fileContainer != null\n ? this.virtualizer.getOffsetInScrollContainer(this.fileContainer)\n : 0;\n }\n\n private getSimpleVirtualizer(): Virtualizer | undefined {\n return this.virtualizer.type === 'simple' ? this.virtualizer : undefined;\n }\n\n private isResizeDebuggingEnabled(): boolean {\n return this.getSimpleVirtualizer()?.config.resizeDebugging ?? false;\n }\n\n private computeRenderRangeFromWindow(\n file: FileContents,\n fileTop: number,\n { top, bottom }: RenderWindow\n ): RenderRange {\n const { disableFileHeader = false, overflow = 'scroll' } = this.options;\n const { hunkLineCount, lineHeight } = this.metrics;\n const lineCount = this.fileRenderer.getLineCount(file);\n const fileHeight = this.height;\n const headerRegion = getVirtualFileHeaderRegion(\n this.metrics,\n disableFileHeader\n );\n const paddingBottom =\n lineCount > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;\n const { fileAnnotationHeight } = this.cache;\n const codeRegionTop = headerRegion + fileAnnotationHeight;\n const codeRowsHeight = Math.max(\n 0,\n fileHeight - headerRegion - fileAnnotationHeight - paddingBottom\n );\n const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);\n const fileAnnotationTop = fileTop + headerRegion;\n const measuredFileAnnotationVisible =\n fileAnnotationHeight > 0 &&\n hasFileAnnotations &&\n fileAnnotationTop < bottom &&\n fileAnnotationTop + fileAnnotationHeight > top;\n\n // File is outside render window\n if (fileTop < top - fileHeight || fileTop > bottom) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: fileHeight - headerRegion - paddingBottom,\n };\n }\n\n // Small file, just render it all\n if (lineCount <= hunkLineCount) {\n return {\n startingLine: 0,\n totalLines: hunkLineCount,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n\n // Calculate totalLines based on viewport size\n const estimatedTargetLines = Math.ceil(\n Math.max(bottom - top, 0) / lineHeight\n );\n const totalLines =\n Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount +\n hunkLineCount * 2;\n const totalHunks = totalLines / hunkLineCount;\n const viewportCenter = (top + bottom) / 2;\n // Simple case: overflow scroll with no annotations - pure math!\n if (overflow === 'scroll' && !this.hasLineAnnotations()) {\n const sourceRowsTop = fileTop + codeRegionTop;\n const sourceRowsBottom = sourceRowsTop + codeRowsHeight;\n const sourceRowsVisible =\n sourceRowsTop < bottom && sourceRowsBottom > top;\n if (!measuredFileAnnotationVisible && !sourceRowsVisible) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: fileHeight - headerRegion - paddingBottom,\n };\n }\n\n // Find which line is at viewport center\n const centerLine = Math.floor(\n measuredFileAnnotationVisible &&\n viewportCenter < fileTop + codeRegionTop\n ? 0\n : (viewportCenter - (fileTop + codeRegionTop)) / lineHeight\n );\n const centerHunk = Math.floor(centerLine / hunkLineCount);\n\n // Calculate ideal start centered around viewport\n const idealStartHunk = centerHunk - Math.floor(totalHunks / 2);\n const totalHunksInFile = Math.ceil(lineCount / hunkLineCount);\n const startingLine =\n Math.max(0, Math.min(idealStartHunk, totalHunksInFile)) * hunkLineCount;\n\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n const bufferBefore =\n startingLine === 0\n ? 0\n : fileAnnotationHeight + startingLine * lineHeight;\n const renderedLines = Math.min(\n clampedTotalLines,\n lineCount - startingLine\n );\n const bufferAfter = Math.max(\n 0,\n (lineCount - startingLine - renderedLines) * lineHeight\n );\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter,\n };\n }\n\n // Complex case: need to account for line annotations or wrap overflow\n const overflowHunks = totalHunks;\n const hunkOffsets: number[] = [];\n // Start the scan before the viewport so we collect hunk offsets that may be\n // needed for bufferBefore. This only chooses the scan origin; the returned\n // render range is still computed from the visible window below.\n const checkpoint = this.getLayoutCheckpointBeforeTop(\n Math.max(0, top - fileTop - totalLines * lineHeight * 2),\n hunkLineCount\n );\n\n let absoluteLineTop = fileTop + (checkpoint?.top ?? codeRegionTop);\n let currentLine = checkpoint?.lineIndex ?? 0;\n let firstVisibleHunk: number | undefined;\n let centerHunk: number | undefined;\n let overflowCounter: number | undefined;\n\n const startingLineIndex = checkpoint?.lineIndex ?? 0;\n for (\n let lineIndex = startingLineIndex;\n lineIndex < lineCount;\n lineIndex++\n ) {\n const isAtHunkBoundary = currentLine % hunkLineCount === 0;\n const currentHunk = Math.floor(currentLine / hunkLineCount);\n\n if (isAtHunkBoundary) {\n hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + codeRegionTop);\n\n if (overflowCounter != null) {\n if (overflowCounter <= 0) {\n break;\n }\n overflowCounter--;\n }\n }\n\n const lineHeight = this.getLineHeight(lineIndex, false);\n\n // Track visible region\n if (absoluteLineTop > top - lineHeight && absoluteLineTop < bottom) {\n firstVisibleHunk ??= currentHunk;\n }\n\n // Track which hunk contains the viewport center\n if (absoluteLineTop + lineHeight > viewportCenter) {\n centerHunk ??= currentHunk;\n }\n\n // Start overflow when we are out of the viewport at a hunk boundary\n if (\n overflowCounter == null &&\n absoluteLineTop >= bottom &&\n isAtHunkBoundary\n ) {\n overflowCounter = overflowHunks;\n }\n\n currentLine++;\n absoluteLineTop += lineHeight;\n }\n\n // No visible lines found\n if (firstVisibleHunk == null) {\n if (measuredFileAnnotationVisible) {\n firstVisibleHunk = 0;\n centerHunk = 0;\n } else {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: fileHeight - headerRegion - paddingBottom,\n };\n }\n }\n\n // Calculate balanced startingLine centered around the viewport center\n centerHunk ??= firstVisibleHunk;\n const idealStartHunk = Math.round(centerHunk - totalHunks / 2);\n\n // Clamp startHunk: at the beginning, reduce totalLines; at the end, shift\n // startHunk back\n const maxStartHunk = Math.max(\n 0,\n Math.ceil(lineCount / hunkLineCount) - totalHunks\n );\n const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));\n const startingLine = startHunk * hunkLineCount;\n\n // If we wanted to start before 0, reduce totalLines by the clamped amount\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n // Use hunkOffsets array for efficient buffer calculations\n const codeBufferBefore = hunkOffsets[startHunk] ?? 0;\n const bufferBefore =\n startingLine === 0 ? 0 : fileAnnotationHeight + codeBufferBefore;\n\n // Calculate bufferAfter\n const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;\n const bufferAfter =\n finalHunkIndex < hunkOffsets.length\n ? codeRowsHeight - hunkOffsets[finalHunkIndex]\n : codeRowsHeight - (absoluteLineTop - fileTop - codeRegionTop);\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter: Math.max(0, bufferAfter),\n };\n }\n}\n\nfunction measureFileAnnotationHeight(content: HTMLElement): number | undefined {\n let height: number | undefined;\n for (const child of content.children) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n if (child.dataset.lineAnnotation !== FILE_ANNOTATION_DOM_KEY) {\n continue;\n }\n height = Math.max(height ?? 0, child.getBoundingClientRect().height);\n }\n return height;\n}\n"],"mappings":";;;;;;;;AAgDA,MAAM,6BAA6B;AAEnC,IAAI,aAAa;AAEjB,SAAS,2BACP,iBACA,aACS;CACT,QACG,gBAAgB,YAAY,eAC1B,YAAY,YAAY,cAC1B,gBAAgB,aAAa,YAAY,YAAY,aAAa,WAClE,gBAAgB,sBAAsB,YACpC,YAAY,sBAAsB,WACpC,gBAAgB,qBAAqB,YACnC,YAAY,qBAAqB,UACpC,gBAAgB,cAAc,YAAY;AAE9C;AAEA,IAAa,kBAAb,cAEU,KAAkB;CAkBhB;CACA;CAlBV,OAAiC,oBAAoB,EAAE;CAEvD;CACA,SAAwB;CACxB,QAAiC;EAC/B,yBAAS,IAAI,IAAI;EACjB,aAAa,CAAC;EACd,sBAAsB;CACxB;CACA,YAA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