@self-review/serve 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (553) hide show
  1. package/README.md +128 -0
  2. package/dist/cli.js +839 -0
  3. package/dist/cli.js.map +1 -0
  4. package/dist/client/assets/_basePickBy-DzL66huQ.js +1 -0
  5. package/dist/client/assets/_baseUniq-D_kA9hnK.js +1 -0
  6. package/dist/client/assets/arc-LxCcHggQ.js +1 -0
  7. package/dist/client/assets/architectureDiagram-VXUJARFQ-BmSW2FCh.js +36 -0
  8. package/dist/client/assets/blockDiagram-VD42YOAC-Duz6oS5b.js +122 -0
  9. package/dist/client/assets/c4Diagram-YG6GDRKO-Bv4P72yB.js +10 -0
  10. package/dist/client/assets/channel-ydExFSqY.js +1 -0
  11. package/dist/client/assets/chunk-4BX2VUAB-D2GfUqwd.js +1 -0
  12. package/dist/client/assets/chunk-55IACEB6-C68L7s0h.js +1 -0
  13. package/dist/client/assets/chunk-B4BG7PRW-BtVwfswM.js +165 -0
  14. package/dist/client/assets/chunk-DI55MBZ5-BDdO91wt.js +220 -0
  15. package/dist/client/assets/chunk-FMBD7UC4-tB9OepVI.js +15 -0
  16. package/dist/client/assets/chunk-QN33PNHL-HjKgp1PB.js +1 -0
  17. package/dist/client/assets/chunk-QZHKN3VN-GT04-vw7.js +1 -0
  18. package/dist/client/assets/chunk-TZMSLE5B-DpxXSXMp.js +1 -0
  19. package/dist/client/assets/classDiagram-2ON5EDUG-Dg8dmmRD.js +1 -0
  20. package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dg8dmmRD.js +1 -0
  21. package/dist/client/assets/clone-Bq6xpRgi.js +1 -0
  22. package/dist/client/assets/cose-bilkent-S5V4N54A-Ds41oEbD.js +1 -0
  23. package/dist/client/assets/cytoscape.esm-5J0xJHOV.js +321 -0
  24. package/dist/client/assets/dagre-6UL2VRFP-DZiEousR.js +4 -0
  25. package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  26. package/dist/client/assets/diagram-PSM6KHXK-0_alnUMs.js +24 -0
  27. package/dist/client/assets/diagram-QEK2KX5R-KFaKVdU8.js +43 -0
  28. package/dist/client/assets/diagram-S2PKOQOG-C2Dy10VG.js +24 -0
  29. package/dist/client/assets/erDiagram-Q2GNP2WA-_P7rrcgu.js +60 -0
  30. package/dist/client/assets/flowDiagram-NV44I4VS-BvC6gSn5.js +162 -0
  31. package/dist/client/assets/ganttDiagram-JELNMOA3-DjzuVPeB.js +267 -0
  32. package/dist/client/assets/gitGraphDiagram-V2S2FVAM-B9fPDqqA.js +65 -0
  33. package/dist/client/assets/graph-BqLQdgDA.js +1 -0
  34. package/dist/client/assets/index-CAXQd1OO.js +286 -0
  35. package/dist/client/assets/index-CmSvc3Wo.css +1 -0
  36. package/dist/client/assets/infoDiagram-HS3SLOUP-DiMCwlkY.js +2 -0
  37. package/dist/client/assets/init-Gi6I4Gst.js +1 -0
  38. package/dist/client/assets/journeyDiagram-XKPGCS4Q-Dn5WdzPP.js +139 -0
  39. package/dist/client/assets/kanban-definition-3W4ZIXB7-D-BINTOt.js +89 -0
  40. package/dist/client/assets/katex-DhXJpUyf.js +261 -0
  41. package/dist/client/assets/layout-Bo5pDIcD.js +1 -0
  42. package/dist/client/assets/linear-CNmY37sq.js +1 -0
  43. package/dist/client/assets/mermaid.core-DfADLZQ1.js +250 -0
  44. package/dist/client/assets/mindmap-definition-VGOIOE7T-H5HwEwuX.js +68 -0
  45. package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
  46. package/dist/client/assets/pieDiagram-ADFJNKIX-RiZa5XQN.js +30 -0
  47. package/dist/client/assets/quadrantDiagram-AYHSOK5B-CFFX55h2.js +7 -0
  48. package/dist/client/assets/requirementDiagram-UZGBJVZJ-B6JBcV1I.js +64 -0
  49. package/dist/client/assets/sankeyDiagram-TZEHDZUN-GZT80dnc.js +10 -0
  50. package/dist/client/assets/sequenceDiagram-WL72ISMW-CbUqoUma.js +145 -0
  51. package/dist/client/assets/stateDiagram-FKZM4ZOC-LEb-ZQVV.js +1 -0
  52. package/dist/client/assets/stateDiagram-v2-4FDKWEC3-BYGHA8iw.js +1 -0
  53. package/dist/client/assets/timeline-definition-IT6M3QCI-Cm1Kd50N.js +61 -0
  54. package/dist/client/assets/treemap-GDKQZRPO-CWXk-dEb.js +160 -0
  55. package/dist/client/assets/xychartDiagram-PRI3JC2R-BUllxp6G.js +7 -0
  56. package/dist/client/index.html +29 -0
  57. package/dist/core/src/apply-suggestion.d.ts +76 -0
  58. package/dist/core/src/apply-suggestion.d.ts.map +1 -0
  59. package/dist/core/src/apply-suggestion.js +109 -0
  60. package/dist/core/src/apply-suggestion.js.map +1 -0
  61. package/dist/core/src/config.d.ts +3 -0
  62. package/dist/core/src/config.d.ts.map +1 -0
  63. package/dist/core/src/config.js +196 -0
  64. package/dist/core/src/config.js.map +1 -0
  65. package/dist/core/src/diff-parser.d.ts +3 -0
  66. package/dist/core/src/diff-parser.d.ts.map +1 -0
  67. package/dist/core/src/diff-parser.js +236 -0
  68. package/dist/core/src/diff-parser.js.map +1 -0
  69. package/dist/core/src/directory-scanner.d.ts +18 -0
  70. package/dist/core/src/directory-scanner.d.ts.map +1 -0
  71. package/dist/core/src/directory-scanner.js +99 -0
  72. package/dist/core/src/directory-scanner.js.map +1 -0
  73. package/dist/core/src/fetch-comments.d.ts +69 -0
  74. package/dist/core/src/fetch-comments.d.ts.map +1 -0
  75. package/dist/core/src/fetch-comments.js +180 -0
  76. package/dist/core/src/fetch-comments.js.map +1 -0
  77. package/dist/core/src/file-type-utils.d.ts +16 -0
  78. package/dist/core/src/file-type-utils.d.ts.map +1 -0
  79. package/dist/core/src/file-type-utils.js +106 -0
  80. package/dist/core/src/file-type-utils.js.map +1 -0
  81. package/dist/core/src/forge-provider.d.ts +123 -0
  82. package/dist/core/src/forge-provider.d.ts.map +1 -0
  83. package/dist/core/src/forge-provider.js +68 -0
  84. package/dist/core/src/forge-provider.js.map +1 -0
  85. package/dist/core/src/fs-utils.d.ts +7 -0
  86. package/dist/core/src/fs-utils.d.ts.map +1 -0
  87. package/dist/core/src/fs-utils.js +20 -0
  88. package/dist/core/src/fs-utils.js.map +1 -0
  89. package/dist/core/src/git-diff-args.d.ts +38 -0
  90. package/dist/core/src/git-diff-args.d.ts.map +1 -0
  91. package/dist/core/src/git-diff-args.js +170 -0
  92. package/dist/core/src/git-diff-args.js.map +1 -0
  93. package/dist/core/src/git-diff-loader.d.ts +14 -0
  94. package/dist/core/src/git-diff-loader.d.ts.map +1 -0
  95. package/dist/core/src/git-diff-loader.js +30 -0
  96. package/dist/core/src/git-diff-loader.js.map +1 -0
  97. package/dist/core/src/git.d.ts +52 -0
  98. package/dist/core/src/git.d.ts.map +1 -0
  99. package/dist/core/src/git.js +191 -0
  100. package/dist/core/src/git.js.map +1 -0
  101. package/dist/core/src/github-provider.d.ts +7 -0
  102. package/dist/core/src/github-provider.d.ts.map +1 -0
  103. package/dist/core/src/github-provider.js +151 -0
  104. package/dist/core/src/github-provider.js.map +1 -0
  105. package/dist/core/src/gitlab-provider.d.ts +10 -0
  106. package/dist/core/src/gitlab-provider.d.ts.map +1 -0
  107. package/dist/core/src/gitlab-provider.js +207 -0
  108. package/dist/core/src/gitlab-provider.js.map +1 -0
  109. package/dist/core/src/guide-loader.d.ts +23 -0
  110. package/dist/core/src/guide-loader.d.ts.map +1 -0
  111. package/dist/core/src/guide-loader.js +95 -0
  112. package/dist/core/src/guide-loader.js.map +1 -0
  113. package/dist/core/src/guide-parser.d.ts +34 -0
  114. package/dist/core/src/guide-parser.d.ts.map +1 -0
  115. package/dist/core/src/guide-parser.js +136 -0
  116. package/dist/core/src/guide-parser.js.map +1 -0
  117. package/dist/core/src/guide-schema.d.ts +2 -0
  118. package/dist/core/src/guide-schema.d.ts.map +1 -0
  119. package/dist/core/src/guide-schema.js +202 -0
  120. package/dist/core/src/guide-schema.js.map +1 -0
  121. package/dist/core/src/ignore-filter.d.ts +8 -0
  122. package/dist/core/src/ignore-filter.d.ts.map +1 -0
  123. package/dist/core/src/ignore-filter.js +16 -0
  124. package/dist/core/src/ignore-filter.js.map +1 -0
  125. package/dist/core/src/index.d.ts +38 -0
  126. package/dist/core/src/index.d.ts.map +1 -0
  127. package/dist/core/src/index.js +54 -0
  128. package/dist/core/src/index.js.map +1 -0
  129. package/dist/core/src/materializer.d.ts +60 -0
  130. package/dist/core/src/materializer.d.ts.map +1 -0
  131. package/dist/core/src/materializer.js +255 -0
  132. package/dist/core/src/materializer.js.map +1 -0
  133. package/dist/core/src/payload-sizing.d.ts +20 -0
  134. package/dist/core/src/payload-sizing.d.ts.map +1 -0
  135. package/dist/core/src/payload-sizing.js +74 -0
  136. package/dist/core/src/payload-sizing.js.map +1 -0
  137. package/dist/core/src/remote-mode.d.ts +89 -0
  138. package/dist/core/src/remote-mode.d.ts.map +1 -0
  139. package/dist/core/src/remote-mode.js +193 -0
  140. package/dist/core/src/remote-mode.js.map +1 -0
  141. package/dist/core/src/review-handlers.d.ts +160 -0
  142. package/dist/core/src/review-handlers.d.ts.map +1 -0
  143. package/dist/core/src/review-handlers.js +463 -0
  144. package/dist/core/src/review-handlers.js.map +1 -0
  145. package/dist/core/src/staged-untracked.d.ts +12 -0
  146. package/dist/core/src/staged-untracked.d.ts.map +1 -0
  147. package/dist/core/src/staged-untracked.js +21 -0
  148. package/dist/core/src/staged-untracked.js.map +1 -0
  149. package/dist/core/src/startup-mode.d.ts +6 -0
  150. package/dist/core/src/startup-mode.d.ts.map +1 -0
  151. package/dist/core/src/startup-mode.js +73 -0
  152. package/dist/core/src/startup-mode.js.map +1 -0
  153. package/dist/core/src/synthetic-diff.d.ts +21 -0
  154. package/dist/core/src/synthetic-diff.d.ts.map +1 -0
  155. package/dist/core/src/synthetic-diff.js +104 -0
  156. package/dist/core/src/synthetic-diff.js.map +1 -0
  157. package/dist/core/src/thread-mapper.d.ts +39 -0
  158. package/dist/core/src/thread-mapper.d.ts.map +1 -0
  159. package/dist/core/src/thread-mapper.js +217 -0
  160. package/dist/core/src/thread-mapper.js.map +1 -0
  161. package/dist/core/src/types.d.ts +2 -0
  162. package/dist/core/src/types.d.ts.map +1 -0
  163. package/dist/core/src/types.js +2 -0
  164. package/dist/core/src/types.js.map +1 -0
  165. package/dist/core/src/xml-parser.d.ts +15 -0
  166. package/dist/core/src/xml-parser.d.ts.map +1 -0
  167. package/dist/core/src/xml-parser.js +237 -0
  168. package/dist/core/src/xml-parser.js.map +1 -0
  169. package/dist/core/src/xml-serializer.d.ts +4 -0
  170. package/dist/core/src/xml-serializer.d.ts.map +1 -0
  171. package/dist/core/src/xml-serializer.js +923 -0
  172. package/dist/core/src/xml-serializer.js.map +1 -0
  173. package/dist/react/src/ReviewPanel.d.ts +72 -0
  174. package/dist/react/src/ReviewPanel.d.ts.map +1 -0
  175. package/dist/react/src/ReviewPanel.js +51 -0
  176. package/dist/react/src/ReviewPanel.js.map +1 -0
  177. package/dist/react/src/SingleFileReview.d.ts +49 -0
  178. package/dist/react/src/SingleFileReview.d.ts.map +1 -0
  179. package/dist/react/src/SingleFileReview.js +41 -0
  180. package/dist/react/src/SingleFileReview.js.map +1 -0
  181. package/dist/react/src/adapter.d.ts +72 -0
  182. package/dist/react/src/adapter.d.ts.map +1 -0
  183. package/dist/react/src/adapter.js +2 -0
  184. package/dist/react/src/adapter.js.map +1 -0
  185. package/dist/react/src/components/Comments/AttachmentDropZone.d.ts +10 -0
  186. package/dist/react/src/components/Comments/AttachmentDropZone.d.ts.map +1 -0
  187. package/dist/react/src/components/Comments/AttachmentDropZone.js +52 -0
  188. package/dist/react/src/components/Comments/AttachmentDropZone.js.map +1 -0
  189. package/dist/react/src/components/Comments/AttachmentImage.d.ts +6 -0
  190. package/dist/react/src/components/Comments/AttachmentImage.d.ts.map +1 -0
  191. package/dist/react/src/components/Comments/AttachmentImage.js +50 -0
  192. package/dist/react/src/components/Comments/AttachmentImage.js.map +1 -0
  193. package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts +6 -0
  194. package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts.map +1 -0
  195. package/dist/react/src/components/Comments/AttachmentThumbnail.js +16 -0
  196. package/dist/react/src/components/Comments/AttachmentThumbnail.js.map +1 -0
  197. package/dist/react/src/components/Comments/CategorySelector.d.ts +6 -0
  198. package/dist/react/src/components/Comments/CategorySelector.d.ts.map +1 -0
  199. package/dist/react/src/components/Comments/CategorySelector.js +27 -0
  200. package/dist/react/src/components/Comments/CategorySelector.js.map +1 -0
  201. package/dist/react/src/components/Comments/CommentDisplay.d.ts +7 -0
  202. package/dist/react/src/components/Comments/CommentDisplay.d.ts.map +1 -0
  203. package/dist/react/src/components/Comments/CommentDisplay.js +103 -0
  204. package/dist/react/src/components/Comments/CommentDisplay.js.map +1 -0
  205. package/dist/react/src/components/Comments/CommentInput.d.ts +11 -0
  206. package/dist/react/src/components/Comments/CommentInput.d.ts.map +1 -0
  207. package/dist/react/src/components/Comments/CommentInput.js +81 -0
  208. package/dist/react/src/components/Comments/CommentInput.js.map +1 -0
  209. package/dist/react/src/components/Comments/ComposerCore.d.ts +49 -0
  210. package/dist/react/src/components/Comments/ComposerCore.d.ts.map +1 -0
  211. package/dist/react/src/components/Comments/ComposerCore.js +91 -0
  212. package/dist/react/src/components/Comments/ComposerCore.js.map +1 -0
  213. package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts +14 -0
  214. package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts.map +1 -0
  215. package/dist/react/src/components/Comments/EmojiAutocomplete.js +19 -0
  216. package/dist/react/src/components/Comments/EmojiAutocomplete.js.map +1 -0
  217. package/dist/react/src/components/Comments/ReplyDisplay.d.ts +22 -0
  218. package/dist/react/src/components/Comments/ReplyDisplay.d.ts.map +1 -0
  219. package/dist/react/src/components/Comments/ReplyDisplay.js +38 -0
  220. package/dist/react/src/components/Comments/ReplyDisplay.js.map +1 -0
  221. package/dist/react/src/components/Comments/ReplyInput.d.ts +9 -0
  222. package/dist/react/src/components/Comments/ReplyInput.d.ts.map +1 -0
  223. package/dist/react/src/components/Comments/ReplyInput.js +47 -0
  224. package/dist/react/src/components/Comments/ReplyInput.js.map +1 -0
  225. package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts +27 -0
  226. package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts.map +1 -0
  227. package/dist/react/src/components/Comments/SuggestionApplyControl.js +103 -0
  228. package/dist/react/src/components/Comments/SuggestionApplyControl.js.map +1 -0
  229. package/dist/react/src/components/Comments/SuggestionBlock.d.ts +26 -0
  230. package/dist/react/src/components/Comments/SuggestionBlock.d.ts.map +1 -0
  231. package/dist/react/src/components/Comments/SuggestionBlock.js +33 -0
  232. package/dist/react/src/components/Comments/SuggestionBlock.js.map +1 -0
  233. package/dist/react/src/components/Comments/SuggestionPanel.d.ts +8 -0
  234. package/dist/react/src/components/Comments/SuggestionPanel.d.ts.map +1 -0
  235. package/dist/react/src/components/Comments/SuggestionPanel.js +12 -0
  236. package/dist/react/src/components/Comments/SuggestionPanel.js.map +1 -0
  237. package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts +35 -0
  238. package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts.map +1 -0
  239. package/dist/react/src/components/DiffViewer/DiffContentArea.js +40 -0
  240. package/dist/react/src/components/DiffViewer/DiffContentArea.js.map +1 -0
  241. package/dist/react/src/components/DiffViewer/DiffViewer.d.ts +4 -0
  242. package/dist/react/src/components/DiffViewer/DiffViewer.d.ts.map +1 -0
  243. package/dist/react/src/components/DiffViewer/DiffViewer.js +110 -0
  244. package/dist/react/src/components/DiffViewer/DiffViewer.js.map +1 -0
  245. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts +6 -0
  246. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts.map +1 -0
  247. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js +18 -0
  248. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js.map +1 -0
  249. package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts +2 -0
  250. package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts.map +1 -0
  251. package/dist/react/src/components/DiffViewer/EmptyLinePane.js +5 -0
  252. package/dist/react/src/components/DiffViewer/EmptyLinePane.js.map +1 -0
  253. package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts +10 -0
  254. package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts.map +1 -0
  255. package/dist/react/src/components/DiffViewer/ExpandContextBar.js +16 -0
  256. package/dist/react/src/components/DiffViewer/ExpandContextBar.js.map +1 -0
  257. package/dist/react/src/components/DiffViewer/FileSection.d.ts +9 -0
  258. package/dist/react/src/components/DiffViewer/FileSection.d.ts.map +1 -0
  259. package/dist/react/src/components/DiffViewer/FileSection.js +137 -0
  260. package/dist/react/src/components/DiffViewer/FileSection.js.map +1 -0
  261. package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts +13 -0
  262. package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts.map +1 -0
  263. package/dist/react/src/components/DiffViewer/FileSectionBody.js +8 -0
  264. package/dist/react/src/components/DiffViewer/FileSectionBody.js.map +1 -0
  265. package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts +16 -0
  266. package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts.map +1 -0
  267. package/dist/react/src/components/DiffViewer/FileSectionHeader.js +53 -0
  268. package/dist/react/src/components/DiffViewer/FileSectionHeader.js.map +1 -0
  269. package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts +6 -0
  270. package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts.map +1 -0
  271. package/dist/react/src/components/DiffViewer/FrontMatterTable.js +30 -0
  272. package/dist/react/src/components/DiffViewer/FrontMatterTable.js.map +1 -0
  273. package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts +20 -0
  274. package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts.map +1 -0
  275. package/dist/react/src/components/DiffViewer/GuideChapterDivider.js +27 -0
  276. package/dist/react/src/components/DiffViewer/GuideChapterDivider.js.map +1 -0
  277. package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts +16 -0
  278. package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts.map +1 -0
  279. package/dist/react/src/components/DiffViewer/GuideOverviewContent.js +56 -0
  280. package/dist/react/src/components/DiffViewer/GuideOverviewContent.js.map +1 -0
  281. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts +12 -0
  282. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts.map +1 -0
  283. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js +13 -0
  284. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js.map +1 -0
  285. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts +8 -0
  286. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts.map +1 -0
  287. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js +16 -0
  288. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js.map +1 -0
  289. package/dist/react/src/components/DiffViewer/HunkHeader.d.ts +5 -0
  290. package/dist/react/src/components/DiffViewer/HunkHeader.d.ts.map +1 -0
  291. package/dist/react/src/components/DiffViewer/HunkHeader.js +5 -0
  292. package/dist/react/src/components/DiffViewer/HunkHeader.js.map +1 -0
  293. package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts +18 -0
  294. package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts.map +1 -0
  295. package/dist/react/src/components/DiffViewer/InlineCommentSlot.js +13 -0
  296. package/dist/react/src/components/DiffViewer/InlineCommentSlot.js.map +1 -0
  297. package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts +9 -0
  298. package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts.map +1 -0
  299. package/dist/react/src/components/DiffViewer/MarkdownCode.js +24 -0
  300. package/dist/react/src/components/DiffViewer/MarkdownCode.js.map +1 -0
  301. package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts +4 -0
  302. package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts.map +1 -0
  303. package/dist/react/src/components/DiffViewer/MermaidBlock.js +51 -0
  304. package/dist/react/src/components/DiffViewer/MermaidBlock.js.map +1 -0
  305. package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts +8 -0
  306. package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts.map +1 -0
  307. package/dist/react/src/components/DiffViewer/RenderedImageView.js +46 -0
  308. package/dist/react/src/components/DiffViewer/RenderedImageView.js.map +1 -0
  309. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts +16 -0
  310. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts.map +1 -0
  311. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js +324 -0
  312. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js.map +1 -0
  313. package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts +7 -0
  314. package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts.map +1 -0
  315. package/dist/react/src/components/DiffViewer/RenderedSvgView.js +21 -0
  316. package/dist/react/src/components/DiffViewer/RenderedSvgView.js.map +1 -0
  317. package/dist/react/src/components/DiffViewer/SplitView.d.ts +23 -0
  318. package/dist/react/src/components/DiffViewer/SplitView.d.ts.map +1 -0
  319. package/dist/react/src/components/DiffViewer/SplitView.js +137 -0
  320. package/dist/react/src/components/DiffViewer/SplitView.js.map +1 -0
  321. package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts +49 -0
  322. package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts.map +1 -0
  323. package/dist/react/src/components/DiffViewer/SyntaxLine.js +73 -0
  324. package/dist/react/src/components/DiffViewer/SyntaxLine.js.map +1 -0
  325. package/dist/react/src/components/DiffViewer/UnifiedView.d.ts +23 -0
  326. package/dist/react/src/components/DiffViewer/UnifiedView.d.ts.map +1 -0
  327. package/dist/react/src/components/DiffViewer/UnifiedView.js +96 -0
  328. package/dist/react/src/components/DiffViewer/UnifiedView.js.map +1 -0
  329. package/dist/react/src/components/DiffViewer/diff-utils.d.ts +31 -0
  330. package/dist/react/src/components/DiffViewer/diff-utils.d.ts.map +1 -0
  331. package/dist/react/src/components/DiffViewer/diff-utils.js +134 -0
  332. package/dist/react/src/components/DiffViewer/diff-utils.js.map +1 -0
  333. package/dist/react/src/components/DiffViewer/useDragSelection.d.ts +25 -0
  334. package/dist/react/src/components/DiffViewer/useDragSelection.d.ts.map +1 -0
  335. package/dist/react/src/components/DiffViewer/useDragSelection.js +210 -0
  336. package/dist/react/src/components/DiffViewer/useDragSelection.js.map +1 -0
  337. package/dist/react/src/components/DiffViewer/useExpandContext.d.ts +15 -0
  338. package/dist/react/src/components/DiffViewer/useExpandContext.d.ts.map +1 -0
  339. package/dist/react/src/components/DiffViewer/useExpandContext.js +209 -0
  340. package/dist/react/src/components/DiffViewer/useExpandContext.js.map +1 -0
  341. package/dist/react/src/components/FileTree.d.ts +2 -0
  342. package/dist/react/src/components/FileTree.d.ts.map +1 -0
  343. package/dist/react/src/components/FileTree.js +93 -0
  344. package/dist/react/src/components/FileTree.js.map +1 -0
  345. package/dist/react/src/components/FileTreeEntry.d.ts +13 -0
  346. package/dist/react/src/components/FileTreeEntry.d.ts.map +1 -0
  347. package/dist/react/src/components/FileTreeEntry.js +21 -0
  348. package/dist/react/src/components/FileTreeEntry.js.map +1 -0
  349. package/dist/react/src/components/FileTreeToggle.d.ts +15 -0
  350. package/dist/react/src/components/FileTreeToggle.d.ts.map +1 -0
  351. package/dist/react/src/components/FileTreeToggle.js +16 -0
  352. package/dist/react/src/components/FileTreeToggle.js.map +1 -0
  353. package/dist/react/src/components/GuideRouteHud.d.ts +10 -0
  354. package/dist/react/src/components/GuideRouteHud.d.ts.map +1 -0
  355. package/dist/react/src/components/GuideRouteHud.js +43 -0
  356. package/dist/react/src/components/GuideRouteHud.js.map +1 -0
  357. package/dist/react/src/components/GuideRouteMap.d.ts +20 -0
  358. package/dist/react/src/components/GuideRouteMap.d.ts.map +1 -0
  359. package/dist/react/src/components/GuideRouteMap.js +58 -0
  360. package/dist/react/src/components/GuideRouteMap.js.map +1 -0
  361. package/dist/react/src/components/GuideStation.d.ts +28 -0
  362. package/dist/react/src/components/GuideStation.d.ts.map +1 -0
  363. package/dist/react/src/components/GuideStation.js +24 -0
  364. package/dist/react/src/components/GuideStation.js.map +1 -0
  365. package/dist/react/src/components/HintOverlay.d.ts +13 -0
  366. package/dist/react/src/components/HintOverlay.d.ts.map +1 -0
  367. package/dist/react/src/components/HintOverlay.js +27 -0
  368. package/dist/react/src/components/HintOverlay.js.map +1 -0
  369. package/dist/react/src/components/KeyboardNavigationManager.d.ts +2 -0
  370. package/dist/react/src/components/KeyboardNavigationManager.d.ts.map +1 -0
  371. package/dist/react/src/components/KeyboardNavigationManager.js +8 -0
  372. package/dist/react/src/components/KeyboardNavigationManager.js.map +1 -0
  373. package/dist/react/src/components/Layout.d.ts +2 -0
  374. package/dist/react/src/components/Layout.d.ts.map +1 -0
  375. package/dist/react/src/components/Layout.js +63 -0
  376. package/dist/react/src/components/Layout.js.map +1 -0
  377. package/dist/react/src/components/ReviewProgress.d.ts +2 -0
  378. package/dist/react/src/components/ReviewProgress.d.ts.map +1 -0
  379. package/dist/react/src/components/ReviewProgress.js +25 -0
  380. package/dist/react/src/components/ReviewProgress.js.map +1 -0
  381. package/dist/react/src/components/Toolbar.d.ts +6 -0
  382. package/dist/react/src/components/Toolbar.d.ts.map +1 -0
  383. package/dist/react/src/components/Toolbar.js +61 -0
  384. package/dist/react/src/components/Toolbar.js.map +1 -0
  385. package/dist/react/src/components/TruncatedPath.d.ts +7 -0
  386. package/dist/react/src/components/TruncatedPath.d.ts.map +1 -0
  387. package/dist/react/src/components/TruncatedPath.js +15 -0
  388. package/dist/react/src/components/TruncatedPath.js.map +1 -0
  389. package/dist/react/src/components/ui/badge.d.ts +10 -0
  390. package/dist/react/src/components/ui/badge.d.ts.map +1 -0
  391. package/dist/react/src/components/ui/badge.js +21 -0
  392. package/dist/react/src/components/ui/badge.js.map +1 -0
  393. package/dist/react/src/components/ui/button.d.ts +11 -0
  394. package/dist/react/src/components/ui/button.d.ts.map +1 -0
  395. package/dist/react/src/components/ui/button.js +32 -0
  396. package/dist/react/src/components/ui/button.js.map +1 -0
  397. package/dist/react/src/components/ui/dialog.d.ts +12 -0
  398. package/dist/react/src/components/ui/dialog.d.ts.map +1 -0
  399. package/dist/react/src/components/ui/dialog.js +23 -0
  400. package/dist/react/src/components/ui/dialog.js.map +1 -0
  401. package/dist/react/src/components/ui/input.d.ts +4 -0
  402. package/dist/react/src/components/ui/input.d.ts.map +1 -0
  403. package/dist/react/src/components/ui/input.js +9 -0
  404. package/dist/react/src/components/ui/input.js.map +1 -0
  405. package/dist/react/src/components/ui/separator.d.ts +6 -0
  406. package/dist/react/src/components/ui/separator.d.ts.map +1 -0
  407. package/dist/react/src/components/ui/separator.js +8 -0
  408. package/dist/react/src/components/ui/separator.js.map +1 -0
  409. package/dist/react/src/components/ui/table.d.ts +11 -0
  410. package/dist/react/src/components/ui/table.d.ts.map +1 -0
  411. package/dist/react/src/components/ui/table.js +21 -0
  412. package/dist/react/src/components/ui/table.js.map +1 -0
  413. package/dist/react/src/components/ui/textarea.d.ts +4 -0
  414. package/dist/react/src/components/ui/textarea.d.ts.map +1 -0
  415. package/dist/react/src/components/ui/textarea.js +9 -0
  416. package/dist/react/src/components/ui/textarea.js.map +1 -0
  417. package/dist/react/src/components/ui/toggle-group.d.ts +22 -0
  418. package/dist/react/src/components/ui/toggle-group.d.ts.map +1 -0
  419. package/dist/react/src/components/ui/toggle-group.js +48 -0
  420. package/dist/react/src/components/ui/toggle-group.js.map +1 -0
  421. package/dist/react/src/components/ui/tooltip.d.ts +16 -0
  422. package/dist/react/src/components/ui/tooltip.d.ts.map +1 -0
  423. package/dist/react/src/components/ui/tooltip.js +21 -0
  424. package/dist/react/src/components/ui/tooltip.js.map +1 -0
  425. package/dist/react/src/context/ConfigContext.d.ts +26 -0
  426. package/dist/react/src/context/ConfigContext.d.ts.map +1 -0
  427. package/dist/react/src/context/ConfigContext.js +150 -0
  428. package/dist/react/src/context/ConfigContext.js.map +1 -0
  429. package/dist/react/src/context/DiffNavigationContext.d.ts +16 -0
  430. package/dist/react/src/context/DiffNavigationContext.d.ts.map +1 -0
  431. package/dist/react/src/context/DiffNavigationContext.js +79 -0
  432. package/dist/react/src/context/DiffNavigationContext.js.map +1 -0
  433. package/dist/react/src/context/GuideContext.d.ts +28 -0
  434. package/dist/react/src/context/GuideContext.d.ts.map +1 -0
  435. package/dist/react/src/context/GuideContext.js +64 -0
  436. package/dist/react/src/context/GuideContext.js.map +1 -0
  437. package/dist/react/src/context/ReviewAdapterContext.d.ts +9 -0
  438. package/dist/react/src/context/ReviewAdapterContext.d.ts.map +1 -0
  439. package/dist/react/src/context/ReviewAdapterContext.js +10 -0
  440. package/dist/react/src/context/ReviewAdapterContext.js.map +1 -0
  441. package/dist/react/src/context/ReviewContext.d.ts +60 -0
  442. package/dist/react/src/context/ReviewContext.d.ts.map +1 -0
  443. package/dist/react/src/context/ReviewContext.js +233 -0
  444. package/dist/react/src/context/ReviewContext.js.map +1 -0
  445. package/dist/react/src/hooks/useDiffNavigation.d.ts +4 -0
  446. package/dist/react/src/hooks/useDiffNavigation.d.ts.map +1 -0
  447. package/dist/react/src/hooks/useDiffNavigation.js +5 -0
  448. package/dist/react/src/hooks/useDiffNavigation.js.map +1 -0
  449. package/dist/react/src/hooks/useEmojiAutocomplete.d.ts +24 -0
  450. package/dist/react/src/hooks/useEmojiAutocomplete.d.ts.map +1 -0
  451. package/dist/react/src/hooks/useEmojiAutocomplete.js +175 -0
  452. package/dist/react/src/hooks/useEmojiAutocomplete.js.map +1 -0
  453. package/dist/react/src/hooks/useKeyboardNavigation.d.ts +15 -0
  454. package/dist/react/src/hooks/useKeyboardNavigation.d.ts.map +1 -0
  455. package/dist/react/src/hooks/useKeyboardNavigation.js +227 -0
  456. package/dist/react/src/hooks/useKeyboardNavigation.js.map +1 -0
  457. package/dist/react/src/hooks/useReviewBridge.d.ts +15 -0
  458. package/dist/react/src/hooks/useReviewBridge.d.ts.map +1 -0
  459. package/dist/react/src/hooks/useReviewBridge.js +43 -0
  460. package/dist/react/src/hooks/useReviewBridge.js.map +1 -0
  461. package/dist/react/src/hooks/useReviewState.d.ts +16 -0
  462. package/dist/react/src/hooks/useReviewState.d.ts.map +1 -0
  463. package/dist/react/src/hooks/useReviewState.js +101 -0
  464. package/dist/react/src/hooks/useReviewState.js.map +1 -0
  465. package/dist/react/src/index.d.ts +25 -0
  466. package/dist/react/src/index.d.ts.map +1 -0
  467. package/dist/react/src/index.js +22 -0
  468. package/dist/react/src/index.js.map +1 -0
  469. package/dist/react/src/lib/utils.d.ts +3 -0
  470. package/dist/react/src/lib/utils.d.ts.map +1 -0
  471. package/dist/react/src/lib/utils.js +6 -0
  472. package/dist/react/src/lib/utils.js.map +1 -0
  473. package/dist/react/src/utils/category-utils.d.ts +17 -0
  474. package/dist/react/src/utils/category-utils.d.ts.map +1 -0
  475. package/dist/react/src/utils/category-utils.js +23 -0
  476. package/dist/react/src/utils/category-utils.js.map +1 -0
  477. package/dist/react/src/utils/comment-anchors.d.ts +4 -0
  478. package/dist/react/src/utils/comment-anchors.d.ts.map +1 -0
  479. package/dist/react/src/utils/comment-anchors.js +17 -0
  480. package/dist/react/src/utils/comment-anchors.js.map +1 -0
  481. package/dist/react/src/utils/diff-styles.d.ts +12 -0
  482. package/dist/react/src/utils/diff-styles.d.ts.map +1 -0
  483. package/dist/react/src/utils/diff-styles.js +46 -0
  484. package/dist/react/src/utils/diff-styles.js.map +1 -0
  485. package/dist/react/src/utils/emoji-data.d.ts +8 -0
  486. package/dist/react/src/utils/emoji-data.d.ts.map +1 -0
  487. package/dist/react/src/utils/emoji-data.js +43 -0
  488. package/dist/react/src/utils/emoji-data.js.map +1 -0
  489. package/dist/react/src/utils/file-type-utils.d.ts +20 -0
  490. package/dist/react/src/utils/file-type-utils.d.ts.map +1 -0
  491. package/dist/react/src/utils/file-type-utils.js +110 -0
  492. package/dist/react/src/utils/file-type-utils.js.map +1 -0
  493. package/dist/react/src/utils/front-matter.d.ts +14 -0
  494. package/dist/react/src/utils/front-matter.d.ts.map +1 -0
  495. package/dist/react/src/utils/front-matter.js +40 -0
  496. package/dist/react/src/utils/front-matter.js.map +1 -0
  497. package/dist/react/src/utils/guide-accents.d.ts +46 -0
  498. package/dist/react/src/utils/guide-accents.d.ts.map +1 -0
  499. package/dist/react/src/utils/guide-accents.js +100 -0
  500. package/dist/react/src/utils/guide-accents.js.map +1 -0
  501. package/dist/react/src/utils/guide-display.d.ts +48 -0
  502. package/dist/react/src/utils/guide-display.d.ts.map +1 -0
  503. package/dist/react/src/utils/guide-display.js +75 -0
  504. package/dist/react/src/utils/guide-display.js.map +1 -0
  505. package/dist/react/src/utils/image-utils.d.ts +3 -0
  506. package/dist/react/src/utils/image-utils.d.ts.map +1 -0
  507. package/dist/react/src/utils/image-utils.js +33 -0
  508. package/dist/react/src/utils/image-utils.js.map +1 -0
  509. package/dist/react/src/utils/passive-content.d.ts +9 -0
  510. package/dist/react/src/utils/passive-content.d.ts.map +1 -0
  511. package/dist/react/src/utils/passive-content.js +135 -0
  512. package/dist/react/src/utils/passive-content.js.map +1 -0
  513. package/dist/react/src/utils/remark-emoji.d.ts +3 -0
  514. package/dist/react/src/utils/remark-emoji.d.ts.map +1 -0
  515. package/dist/react/src/utils/remark-emoji.js +38 -0
  516. package/dist/react/src/utils/remark-emoji.js.map +1 -0
  517. package/dist/serve/src/args.d.ts +15 -0
  518. package/dist/serve/src/args.d.ts.map +1 -0
  519. package/dist/serve/src/args.js +65 -0
  520. package/dist/serve/src/args.js.map +1 -0
  521. package/dist/serve/src/cli.d.ts +3 -0
  522. package/dist/serve/src/cli.d.ts.map +1 -0
  523. package/dist/serve/src/cli.js +81 -0
  524. package/dist/serve/src/cli.js.map +1 -0
  525. package/dist/serve/src/client/adapter.d.ts +25 -0
  526. package/dist/serve/src/client/adapter.d.ts.map +1 -0
  527. package/dist/serve/src/client/adapter.js +190 -0
  528. package/dist/serve/src/client/adapter.js.map +1 -0
  529. package/dist/serve/src/client/index.d.ts +2 -0
  530. package/dist/serve/src/client/index.d.ts.map +1 -0
  531. package/dist/serve/src/client/index.js +135 -0
  532. package/dist/serve/src/client/index.js.map +1 -0
  533. package/dist/serve/src/lifecycle.d.ts +27 -0
  534. package/dist/serve/src/lifecycle.d.ts.map +1 -0
  535. package/dist/serve/src/lifecycle.js +73 -0
  536. package/dist/serve/src/lifecycle.js.map +1 -0
  537. package/dist/serve/src/server.d.ts +34 -0
  538. package/dist/serve/src/server.d.ts.map +1 -0
  539. package/dist/serve/src/server.js +430 -0
  540. package/dist/serve/src/server.js.map +1 -0
  541. package/dist/serve/src/startup.d.ts +19 -0
  542. package/dist/serve/src/startup.d.ts.map +1 -0
  543. package/dist/serve/src/startup.js +117 -0
  544. package/dist/serve/src/startup.js.map +1 -0
  545. package/dist/serve/src/validate.d.ts +44 -0
  546. package/dist/serve/src/validate.d.ts.map +1 -0
  547. package/dist/serve/src/validate.js +295 -0
  548. package/dist/serve/src/validate.js.map +1 -0
  549. package/dist/types/src/index.d.ts +417 -0
  550. package/dist/types/src/index.d.ts.map +1 -0
  551. package/dist/types/src/index.js +5 -0
  552. package/dist/types/src/index.js.map +1 -0
  553. package/package.json +38 -0
@@ -0,0 +1,104 @@
1
+ // packages/core/src/synthetic-diff.ts
2
+ // Generates synthetic unified diffs for files that aren't tracked by git.
3
+ // Reusable by both git untracked file handling and directory-based scanning.
4
+ import { readFileSync } from 'fs';
5
+ import { join } from 'path';
6
+ // C-style escapes git emits for the characters that have one.
7
+ const C_STYLE_ESCAPES = {
8
+ 0x07: '\\a',
9
+ 0x08: '\\b',
10
+ 0x09: '\\t',
11
+ 0x0a: '\\n',
12
+ 0x0b: '\\v',
13
+ 0x0c: '\\f',
14
+ 0x0d: '\\r',
15
+ 0x22: '\\"',
16
+ 0x5c: '\\\\',
17
+ };
18
+ function needsQuoting(byte) {
19
+ return byte < 0x20 || byte >= 0x7f || byte === 0x22 || byte === 0x5c;
20
+ }
21
+ /**
22
+ * Encode a path the way git writes it in diff headers. A plain path goes out
23
+ * verbatim. Anything else becomes a double-quoted C-style token with control
24
+ * characters, quotes, backslashes and non-ASCII UTF-8 bytes escaped.
25
+ *
26
+ * This inverts `decodeGitPath` in diff-parser.ts. Without it, a filename
27
+ * containing a newline ends the header line mid-name and the parser recovers
28
+ * a name no file on disk answers to.
29
+ */
30
+ export function quoteGitPath(path) {
31
+ const bytes = Buffer.from(path, 'utf-8');
32
+ if (!bytes.some(needsQuoting))
33
+ return path;
34
+ let quoted = '"';
35
+ for (const byte of bytes) {
36
+ const escape = C_STYLE_ESCAPES[byte];
37
+ if (escape) {
38
+ quoted += escape;
39
+ }
40
+ else if (byte < 0x20 || byte >= 0x7f) {
41
+ quoted += `\\${byte.toString(8).padStart(3, '0')}`;
42
+ }
43
+ else {
44
+ quoted += String.fromCharCode(byte);
45
+ }
46
+ }
47
+ return `${quoted}"`;
48
+ }
49
+ /**
50
+ * Generate synthetic unified diffs for a list of file paths so they can be
51
+ * parsed by the existing diff parser. Each file is treated as a new addition.
52
+ *
53
+ * @param paths - Literal relative file paths (e.g. "src/foo.ts"), resolved
54
+ * against rootDir and never git-quoted on the way in
55
+ * @param rootDir - Absolute path to the root directory the paths are relative to
56
+ * @returns A unified diff string covering all provided files
57
+ */
58
+ export function generateSyntheticDiffs(paths, rootDir) {
59
+ const diffs = [];
60
+ for (const filePath of paths) {
61
+ const fullPath = join(rootDir, filePath);
62
+ let content;
63
+ try {
64
+ content = readFileSync(fullPath);
65
+ }
66
+ catch {
67
+ // File may have been deleted between listing and reading
68
+ continue;
69
+ }
70
+ // Git quotes the prefixed path as a whole ("a/name"), not the name alone.
71
+ const oldHeaderPath = quoteGitPath(`a/${filePath}`);
72
+ const newHeaderPath = quoteGitPath(`b/${filePath}`);
73
+ // Detect binary files by checking for null bytes in the first 8KB
74
+ const sample = content.subarray(0, 8192);
75
+ const isBinary = sample.includes(0);
76
+ if (isBinary) {
77
+ diffs.push(`diff --git ${oldHeaderPath} ${newHeaderPath}\n` +
78
+ `new file mode 100644\n` +
79
+ `Binary files /dev/null and ${newHeaderPath} differ`);
80
+ continue;
81
+ }
82
+ const text = content.toString('utf-8');
83
+ const lines = text.split('\n');
84
+ // Remove trailing empty string from split if file ends with newline
85
+ if (lines.length > 0 && lines[lines.length - 1] === '') {
86
+ lines.pop();
87
+ }
88
+ const lineCount = lines.length;
89
+ const addedLines = lines.map(line => `+${line}`).join('\n');
90
+ let diff = `diff --git ${oldHeaderPath} ${newHeaderPath}\n` +
91
+ `new file mode 100644\n` +
92
+ `--- /dev/null\n` +
93
+ `+++ ${newHeaderPath}\n` +
94
+ `@@ -0,0 +1,${lineCount} @@\n` +
95
+ addedLines;
96
+ // Indicate missing newline at end of file
97
+ if (text.length > 0 && !text.endsWith('\n')) {
98
+ diff += '\n\';
99
+ }
100
+ diffs.push(diff);
101
+ }
102
+ return diffs.join('\n');
103
+ }
104
+ //# sourceMappingURL=synthetic-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synthetic-diff.js","sourceRoot":"","sources":["../../../../core/src/synthetic-diff.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAC1E,6EAA6E;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,8DAA8D;AAC9D,MAAM,eAAe,GAA2B;IAC9C,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,SAAS,YAAY,CAAC,IAAY;IAChC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AAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,gCAAgC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { ForgeThread } from './forge-provider';
2
+ import type { DiffFile, ReviewComment } from './types';
3
+ /**
4
+ * Sentinel `filePath` for review-level threads (threads with no file
5
+ * association at all, e.g. GitLab non-diff discussions).
6
+ *
7
+ * The v3 schema has no review-level comment element — every `<comment>`
8
+ * lives inside a `<file path>` — so the mapper degrades these threads to
9
+ * file-level comments on this sentinel path, the closest legal shape.
10
+ * The empty string can never collide with a repository-relative diff path,
11
+ * so consumers (the fetch-comments orchestrator, the app's remote mode)
12
+ * detect review-level comments by comparing against this constant and
13
+ * decide their placement (e.g. a synthetic review-level file entry).
14
+ */
15
+ export declare const REVIEW_LEVEL_FILE_PATH = "";
16
+ /**
17
+ * Convert normalized forge threads into v3 `ReviewComment` threads.
18
+ *
19
+ * - The root turn becomes the root comment and owns the anchor; subsequent
20
+ * turns become flat replies in document order (nothing sorts them).
21
+ * - Forge usernames land in `author`, forge thread/comment ids in
22
+ * `remoteId`, markdown bodies pass through verbatim.
23
+ * - Outdated or line-less anchors degrade to file-level comments
24
+ * (`lineRange: null`); anchor-less threads degrade to file-level
25
+ * comments on {@link REVIEW_LEVEL_FILE_PATH}. The degradation is
26
+ * structural, never textual.
27
+ * - Mapped comments carry no category, severity or confidence: forge
28
+ * threads have none, and absent means below every threshold. The empty
29
+ * `category` matches how the XML parser represents a missing category.
30
+ * - A root body carrying a single ` ```suggestion ` fence becomes a
31
+ * `Suggestion` anchored to the thread's line range, with `originalCode`
32
+ * read out of `diffFiles` at that anchor. Without the reviewed diff there
33
+ * is nothing to anchor against, so the default leaves every
34
+ * `suggestion: null` exactly as before.
35
+ *
36
+ * Output order is input order. The input is never mutated.
37
+ */
38
+ export declare function mapThreadsToReviewComments(threads: ForgeThread[], diffFiles?: DiffFile[]): ReviewComment[];
39
+ //# sourceMappingURL=thread-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-mapper.d.ts","sourceRoot":"","sources":["../../../../core/src/thread-mapper.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAsC,MAAM,kBAAkB,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAoB,aAAa,EAAc,MAAM,SAAS,CAAC;AAErF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AA+KzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,WAAW,EAAE,EACtB,SAAS,GAAE,QAAQ,EAAO,GACzB,aAAa,EAAE,CAmBjB"}
@@ -0,0 +1,217 @@
1
+ // thread-mapper.ts
2
+ // Deterministic mapper from forge-neutral discussion threads to the v3
3
+ // ReviewComment model. Pure code: no I/O, no randomness, no timestamps —
4
+ // the same input always yields byte-identical output, and it contains no
5
+ // forge-conditional logic (anything forge-specific belongs in the
6
+ // providers). Fetch direction only.
7
+ /**
8
+ * Sentinel `filePath` for review-level threads (threads with no file
9
+ * association at all, e.g. GitLab non-diff discussions).
10
+ *
11
+ * The v3 schema has no review-level comment element — every `<comment>`
12
+ * lives inside a `<file path>` — so the mapper degrades these threads to
13
+ * file-level comments on this sentinel path, the closest legal shape.
14
+ * The empty string can never collide with a repository-relative diff path,
15
+ * so consumers (the fetch-comments orchestrator, the app's remote mode)
16
+ * detect review-level comments by comparing against this constant and
17
+ * decide their placement (e.g. a synthetic review-level file entry).
18
+ */
19
+ export const REVIEW_LEVEL_FILE_PATH = '';
20
+ /**
21
+ * Map an anchor to the model's line range, honoring the exactly-one-pair
22
+ * rule: the single `LineRange.side` selects which pair the serializer
23
+ * emits (`'new'` → `new-line-*`, `'old'` → `old-line-*`), so a comment can
24
+ * never carry both.
25
+ *
26
+ * Returns `null` (file-level) when the anchor is outdated, has no usable
27
+ * line information, or carries non-positive lines (the XSD requires
28
+ * `xs:positiveInteger`, and the serializer must never receive an
29
+ * unserializable range). Reversed bounds are normalized rather than
30
+ * rejected so a defective provider payload still maps deterministically.
31
+ */
32
+ function mapAnchorToLineRange(anchor) {
33
+ if (anchor.outdated) {
34
+ return null;
35
+ }
36
+ const { startLine, endLine } = anchor;
37
+ if (startLine === null || endLine === null) {
38
+ return null;
39
+ }
40
+ if (startLine < 1 || endLine < 1) {
41
+ return null;
42
+ }
43
+ return {
44
+ side: anchor.side,
45
+ start: Math.min(startLine, endLine),
46
+ end: Math.max(startLine, endLine),
47
+ };
48
+ }
49
+ /**
50
+ * Internal ids are in-memory render keys the app normally generates
51
+ * randomly on parse. The mapper must be deterministic, so it derives them
52
+ * from the forge-assigned ids instead.
53
+ */
54
+ function internalId(turn) {
55
+ return `remote-${turn.remoteId}`;
56
+ }
57
+ /**
58
+ * Opening line of a fenced code block: up to three spaces of indent, then
59
+ * three or more backticks or tildes, then the info string. A fence indented
60
+ * four spaces or more is an indented code block, not a fence.
61
+ */
62
+ const FENCE_OPEN = /^( {0,3})(`{3,}|~{3,})(.*)$/;
63
+ /** Drop a single trailing CR so a CRLF body yields LF-terminated lines. */
64
+ function stripCr(line) {
65
+ return line.endsWith('\r') ? line.slice(0, -1) : line;
66
+ }
67
+ /** Remove up to `width` leading spaces, the way CommonMark unindents a fence. */
68
+ function stripIndent(line, width) {
69
+ let i = 0;
70
+ while (i < width && line[i] === ' ')
71
+ i++;
72
+ return line.slice(i);
73
+ }
74
+ /** A closing fence: the same character, at least as long, nothing after it. */
75
+ function isClosingFence(line, marker) {
76
+ const match = FENCE_OPEN.exec(line);
77
+ return (match !== null &&
78
+ match[2][0] === marker[0] &&
79
+ match[2].length >= marker.length &&
80
+ match[3].trim() === '');
81
+ }
82
+ /**
83
+ * Collect the bodies of every top-level ` ```suggestion ` block in a
84
+ * markdown body, in document order.
85
+ *
86
+ * Fences are walked in order so a `suggestion` fence nested inside another
87
+ * code block is never mistaken for a real one. The info string must be the
88
+ * bare word `suggestion`: GitLab's range form (`suggestion:-1+2`) widens the
89
+ * anchor by an amount this mapper cannot verify against the diff, so it is
90
+ * deliberately not recognized and leaves the thread without a suggestion.
91
+ */
92
+ function findSuggestionBlocks(body) {
93
+ const lines = body.split('\n').map(stripCr);
94
+ const blocks = [];
95
+ let i = 0;
96
+ while (i < lines.length) {
97
+ const open = FENCE_OPEN.exec(lines[i]);
98
+ if (!open) {
99
+ i++;
100
+ continue;
101
+ }
102
+ const [, indent, marker, info] = open;
103
+ // A backtick fence's info string may not contain a backtick.
104
+ if (marker[0] === '`' && info.includes('`')) {
105
+ i++;
106
+ continue;
107
+ }
108
+ const content = [];
109
+ let j = i + 1;
110
+ for (; j < lines.length && !isClosingFence(lines[j], marker); j++) {
111
+ content.push(stripIndent(lines[j], indent.length));
112
+ }
113
+ if (info.trim().toLowerCase() === 'suggestion') {
114
+ blocks.push(content.join('\n'));
115
+ }
116
+ // An unclosed fence runs to the end of the body, as GitHub renders it.
117
+ i = j + 1;
118
+ }
119
+ return blocks;
120
+ }
121
+ /**
122
+ * Read the reviewed lines the anchor points at, straight out of the diff.
123
+ *
124
+ * Returns `null` unless the diff covers the whole range: a partially covered
125
+ * anchor would produce an `originalCode` that matches nothing, and the apply
126
+ * engine's byte-for-byte check would refuse it anyway. Taking the text from
127
+ * the diff rather than from the thread body is what makes the extracted
128
+ * suggestion anchored rather than merely quoted.
129
+ */
130
+ function readAnchoredLines(diffFiles, filePath, range) {
131
+ const sidePath = (file) => (range.side === 'old' ? file.oldPath : file.newPath);
132
+ const file = diffFiles.find(f => sidePath(f) === filePath) ??
133
+ diffFiles.find(f => f.oldPath === filePath || f.newPath === filePath);
134
+ if (!file)
135
+ return null;
136
+ const found = [];
137
+ for (const hunk of file.hunks) {
138
+ for (const line of hunk.lines) {
139
+ const number = range.side === 'old' ? line.oldLineNumber : line.newLineNumber;
140
+ if (number !== null && number >= range.start && number <= range.end) {
141
+ found.push(line.content);
142
+ }
143
+ }
144
+ }
145
+ return found.length === range.end - range.start + 1 ? found.join('\n') : null;
146
+ }
147
+ /**
148
+ * Turn a `suggestion` fence in a thread's root body into an anchored
149
+ * {@link Suggestion}, or `null` when there is nothing safe to anchor.
150
+ *
151
+ * `null` covers every uncertain case: no fence, more than one fence (the
152
+ * model holds a single suggestion, and silently keeping the first would drop
153
+ * the rest), a file-level or outdated anchor, and an anchor the reviewed
154
+ * diff does not cover.
155
+ */
156
+ function extractSuggestion(body, filePath, range, diffFiles) {
157
+ if (!range)
158
+ return null;
159
+ const blocks = findSuggestionBlocks(body);
160
+ if (blocks.length !== 1)
161
+ return null;
162
+ const originalCode = readAnchoredLines(diffFiles, filePath, range);
163
+ if (originalCode === null)
164
+ return null;
165
+ return { originalCode, proposedCode: blocks[0] };
166
+ }
167
+ function mapReply(turn) {
168
+ return {
169
+ id: internalId(turn),
170
+ body: turn.body,
171
+ author: turn.author,
172
+ remoteId: turn.remoteId,
173
+ };
174
+ }
175
+ /**
176
+ * Convert normalized forge threads into v3 `ReviewComment` threads.
177
+ *
178
+ * - The root turn becomes the root comment and owns the anchor; subsequent
179
+ * turns become flat replies in document order (nothing sorts them).
180
+ * - Forge usernames land in `author`, forge thread/comment ids in
181
+ * `remoteId`, markdown bodies pass through verbatim.
182
+ * - Outdated or line-less anchors degrade to file-level comments
183
+ * (`lineRange: null`); anchor-less threads degrade to file-level
184
+ * comments on {@link REVIEW_LEVEL_FILE_PATH}. The degradation is
185
+ * structural, never textual.
186
+ * - Mapped comments carry no category, severity or confidence: forge
187
+ * threads have none, and absent means below every threshold. The empty
188
+ * `category` matches how the XML parser represents a missing category.
189
+ * - A root body carrying a single ` ```suggestion ` fence becomes a
190
+ * `Suggestion` anchored to the thread's line range, with `originalCode`
191
+ * read out of `diffFiles` at that anchor. Without the reviewed diff there
192
+ * is nothing to anchor against, so the default leaves every
193
+ * `suggestion: null` exactly as before.
194
+ *
195
+ * Output order is input order. The input is never mutated.
196
+ */
197
+ export function mapThreadsToReviewComments(threads, diffFiles = []) {
198
+ return threads.map(thread => {
199
+ const filePath = thread.anchor?.filePath ?? REVIEW_LEVEL_FILE_PATH;
200
+ const lineRange = thread.anchor ? mapAnchorToLineRange(thread.anchor) : null;
201
+ const comment = {
202
+ id: internalId(thread.root),
203
+ filePath,
204
+ lineRange,
205
+ body: thread.root.body,
206
+ category: '',
207
+ suggestion: extractSuggestion(thread.root.body, filePath, lineRange, diffFiles),
208
+ author: thread.root.author,
209
+ remoteId: thread.root.remoteId,
210
+ };
211
+ if (thread.replies.length > 0) {
212
+ comment.replies = thread.replies.map(mapReply);
213
+ }
214
+ return comment;
215
+ });
216
+ }
217
+ //# sourceMappingURL=thread-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-mapper.js","sourceRoot":"","sources":["../../../../core/src/thread-mapper.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,uEAAuE;AACvE,yEAAyE;AACzE,yEAAyE;AACzE,kEAAkE;AAClE,oCAAoC;AAKpC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAAC,MAAyB;IACrD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACtC,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,SAAS,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAA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EAAE;YACZ,UAAU,EAAE,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YAC/E,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;YAC1B,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ;SAC/B,CAAC;QACF,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type * from '@self-review/types';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../core/src/types.ts"],"names":[],"mappings":"AAEA,mBAAmB,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../core/src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { ReviewComment, DiffSource, RemoteForge } from './types';
2
+ export interface ParsedReview {
3
+ comments: ReviewComment[];
4
+ /** Paths of files the previous review marked as done (`viewed="true"`). */
5
+ viewedFiles: string[];
6
+ gitDiffArgs: string;
7
+ source: DiffSource;
8
+ remoteUrl?: string;
9
+ remoteBaseSha?: string;
10
+ remoteHeadSha?: string;
11
+ remoteForge?: RemoteForge;
12
+ }
13
+ export declare function parseReviewXml(xmlPath: string): ParsedReview;
14
+ export declare function parseReviewXmlString(xmlContent: string): ParsedReview;
15
+ //# sourceMappingURL=xml-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-parser.d.ts","sourceRoot":"","sources":["../../../../core/src/xml-parser.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EAGb,UAAU,EAGV,WAAW,EAGZ,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,2EAA2E;IAC3E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;IAInB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAY5D;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAiFrE"}
@@ -0,0 +1,237 @@
1
+ // src/main/xml-parser.ts
2
+ // Parse XML review file back into ReviewComment[]
3
+ import { readFileSync } from 'fs';
4
+ import { XMLParser } from 'fast-xml-parser';
5
+ const SEVERITY_VALUES = ['critical', 'major', 'minor', 'info'];
6
+ const CONFIDENCE_VALUES = ['high', 'medium', 'low'];
7
+ const REMOTE_FORGE_VALUES = ['github', 'gitlab'];
8
+ export function parseReviewXml(xmlPath) {
9
+ try {
10
+ const xmlContent = readFileSync(xmlPath, 'utf-8');
11
+ return parseReviewXmlString(xmlContent);
12
+ }
13
+ catch (error) {
14
+ if (error instanceof Error) {
15
+ console.error(`Error reading XML file: ${error.message}`);
16
+ }
17
+ else {
18
+ console.error('Error reading XML file: unknown error');
19
+ }
20
+ process.exit(1);
21
+ }
22
+ }
23
+ export function parseReviewXmlString(xmlContent) {
24
+ const parser = new XMLParser({
25
+ ignoreAttributes: false,
26
+ attributeNamePrefix: '@_',
27
+ allowBooleanAttributes: true,
28
+ trimValues: false,
29
+ });
30
+ try {
31
+ const result = parser.parse(xmlContent);
32
+ if (!result.review) {
33
+ throw new Error('Invalid XML: missing <review> root element');
34
+ }
35
+ const review = result.review;
36
+ const gitDiffArgs = review['@_git-diff-args'] || '';
37
+ const source = parseSource(review);
38
+ const comments = [];
39
+ const viewedFiles = [];
40
+ // Handle files array
41
+ const files = toChildArray(review.file);
42
+ for (const file of files) {
43
+ // Skip only when the attribute is genuinely absent: the empty string
44
+ // is the review-level sentinel path (REVIEW_LEVEL_FILE_PATH) used by
45
+ // fetch-comments for threads with no file anchor, and must round-trip.
46
+ const rawPath = file['@_path'];
47
+ if (rawPath === undefined || rawPath === null)
48
+ continue;
49
+ const filePath = String(rawPath);
50
+ if (parseViewed(file['@_viewed'])) {
51
+ viewedFiles.push(filePath);
52
+ }
53
+ // Handle comments array
54
+ const fileComments = toChildArray(file.comment);
55
+ for (const comment of fileComments) {
56
+ const reviewComment = {
57
+ id: generateId(),
58
+ filePath,
59
+ lineRange: parseLineRange(comment),
60
+ body: comment.body !== undefined ? String(comment.body) : '',
61
+ category: comment.category !== undefined ? String(comment.category) : '',
62
+ suggestion: parseSuggestion(comment),
63
+ author: comment['@_author'] ? String(comment['@_author']) : undefined,
64
+ severity: parseEnumAttribute(comment['@_severity'], SEVERITY_VALUES),
65
+ confidence: parseEnumAttribute(comment['@_confidence'], CONFIDENCE_VALUES),
66
+ remoteId: parseStringAttribute(comment['@_remote-id']),
67
+ };
68
+ const attachments = parseAttachments(comment, reviewComment.id);
69
+ if (attachments)
70
+ reviewComment.attachments = attachments;
71
+ const replies = parseReplies(comment);
72
+ if (replies)
73
+ reviewComment.replies = replies;
74
+ comments.push(reviewComment);
75
+ }
76
+ }
77
+ return {
78
+ comments,
79
+ viewedFiles,
80
+ gitDiffArgs,
81
+ source,
82
+ remoteUrl: parseStringAttribute(review['@_remote-url']),
83
+ remoteBaseSha: parseStringAttribute(review['@_remote-base-sha']),
84
+ remoteHeadSha: parseStringAttribute(review['@_remote-head-sha']),
85
+ remoteForge: parseEnumAttribute(review['@_remote-forge'], REMOTE_FORGE_VALUES),
86
+ };
87
+ }
88
+ catch (error) {
89
+ if (error instanceof Error) {
90
+ console.error(`Error parsing XML: ${error.message}`);
91
+ }
92
+ else {
93
+ console.error('Error parsing XML: unknown error');
94
+ }
95
+ process.exit(1);
96
+ }
97
+ }
98
+ /**
99
+ * Read an enumerated attribute, dropping values the schema does not define.
100
+ *
101
+ * An unrecognised value becomes undefined rather than being passed through:
102
+ * undefined is the fail-safe reading (below every threshold floor), and it
103
+ * keeps a resumed review serializable, since the serializer validates its
104
+ * output against the XSD before writing.
105
+ */
106
+ function parseEnumAttribute(raw, allowed) {
107
+ if (raw === undefined || raw === null)
108
+ return undefined;
109
+ const value = String(raw);
110
+ return allowed.includes(value) ? value : undefined;
111
+ }
112
+ /**
113
+ * Read an optional free-form string attribute, leaving absent as undefined.
114
+ * Values are taken as-is: the remote attributes are provenance the app never
115
+ * interprets, so there is nothing to validate on read.
116
+ */
117
+ function parseStringAttribute(raw) {
118
+ return raw === undefined || raw === null ? undefined : String(raw);
119
+ }
120
+ /**
121
+ * Read the `viewed` attribute of a <file> element.
122
+ *
123
+ * Anything other than an explicit true reads as not viewed: the attribute is
124
+ * optional, and treating an unknown value as "already reviewed" would silently
125
+ * hide files from the resumed review.
126
+ */
127
+ function parseViewed(raw) {
128
+ return raw === true || String(raw) === 'true';
129
+ }
130
+ function parseSource(review) {
131
+ const sourcePath = review['@_source-path'];
132
+ if (sourcePath) {
133
+ return { type: 'directory', sourcePath: String(sourcePath) };
134
+ }
135
+ const gitDiffArgs = review['@_git-diff-args'];
136
+ const repository = review['@_repository'];
137
+ if (gitDiffArgs !== undefined || repository !== undefined) {
138
+ return {
139
+ type: 'git',
140
+ gitDiffArgs: String(gitDiffArgs || ''),
141
+ repository: String(repository || ''),
142
+ };
143
+ }
144
+ return { type: 'welcome' };
145
+ }
146
+ function parseLineRange(comment) {
147
+ const hasOld = comment['@_old-line-start'] !== undefined && comment['@_old-line-end'] !== undefined;
148
+ const hasNew = comment['@_new-line-start'] !== undefined && comment['@_new-line-end'] !== undefined;
149
+ if (hasOld) {
150
+ return {
151
+ side: 'old',
152
+ start: parseInt(String(comment['@_old-line-start']), 10),
153
+ end: parseInt(String(comment['@_old-line-end']), 10),
154
+ };
155
+ }
156
+ if (hasNew) {
157
+ return {
158
+ side: 'new',
159
+ start: parseInt(String(comment['@_new-line-start']), 10),
160
+ end: parseInt(String(comment['@_new-line-end']), 10),
161
+ };
162
+ }
163
+ return null; // File-level comment
164
+ }
165
+ function parseSuggestion(comment) {
166
+ if (!comment.suggestion) {
167
+ return null;
168
+ }
169
+ const suggestion = comment.suggestion;
170
+ return {
171
+ originalCode: String(suggestion['original-code'] || ''),
172
+ proposedCode: String(suggestion['proposed-code'] || ''),
173
+ };
174
+ }
175
+ /**
176
+ * Normalize a repeatable child element into an array.
177
+ *
178
+ * fast-xml-parser collapses a single occurrence into a bare object and only
179
+ * produces an array from two or more, so every repeatable child in this file
180
+ * has to be widened before it can be iterated. An absent child yields an empty
181
+ * array.
182
+ */
183
+ function toChildArray(raw) {
184
+ if (Array.isArray(raw))
185
+ return raw;
186
+ if (raw === undefined || raw === null)
187
+ return [];
188
+ return [raw];
189
+ }
190
+ /**
191
+ * Read `<attachment>` children of a comment or a reply.
192
+ *
193
+ * Attachment ids are synthetic: nothing in the document names them, so they are
194
+ * derived from the id of their owner, which is why the prefix is a parameter
195
+ * rather than read off the node. Returns undefined rather than [] when there
196
+ * are none, matching the optional field on the type.
197
+ */
198
+ function parseAttachments(node, idPrefix) {
199
+ const raw = toChildArray(node.attachment);
200
+ if (raw.length === 0)
201
+ return undefined;
202
+ return raw.map((att, i) => ({
203
+ id: `${idPrefix}-att-${i}`,
204
+ fileName: String(att['@_path'] || ''),
205
+ mediaType: String(att['@_media-type'] || 'image/png'),
206
+ }));
207
+ }
208
+ /**
209
+ * Read `<reply>` children in document order.
210
+ *
211
+ * Document order is conversation order: a reply carries no timestamp and no
212
+ * identifier, so the order of this array is the only ordering signal a thread
213
+ * ever has. Returns undefined rather than [] when there are none, so a
214
+ * reply-free comment keeps exactly the shape it had before threads existed.
215
+ */
216
+ function parseReplies(comment) {
217
+ const raw = toChildArray(comment.reply);
218
+ if (raw.length === 0)
219
+ return undefined;
220
+ return raw.map(node => {
221
+ const id = generateId();
222
+ const reply = {
223
+ id,
224
+ body: node.body !== undefined ? String(node.body) : '',
225
+ author: node['@_author'] ? String(node['@_author']) : undefined,
226
+ remoteId: parseStringAttribute(node['@_remote-id']),
227
+ };
228
+ const attachments = parseAttachments(node, id);
229
+ if (attachments)
230
+ reply.attachments = attachments;
231
+ return reply;
232
+ });
233
+ }
234
+ function generateId() {
235
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
236
+ }
237
+ //# sourceMappingURL=xml-parser.js.map