@flanksource/clicky-ui 0.3.65 → 0.3.67

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 (592) hide show
  1. package/NOTICE.md +4 -2
  2. package/dist/comments/CommentAuthor.cjs +6 -1
  3. package/dist/comments/CommentAuthor.cjs.map +1 -1
  4. package/dist/comments/CommentAuthor.d.ts.map +1 -1
  5. package/dist/comments/CommentAuthor.js +8 -3
  6. package/dist/comments/CommentAuthor.js.map +1 -1
  7. package/dist/comments/CommentComposer.cjs +4 -1
  8. package/dist/comments/CommentComposer.cjs.map +1 -1
  9. package/dist/comments/CommentComposer.d.ts.map +1 -1
  10. package/dist/comments/CommentComposer.js +4 -1
  11. package/dist/comments/CommentComposer.js.map +1 -1
  12. package/dist/comments/CommentEditor.cjs +3 -6
  13. package/dist/comments/CommentEditor.cjs.map +1 -1
  14. package/dist/comments/CommentEditor.d.ts.map +1 -1
  15. package/dist/comments/CommentEditor.js +3 -6
  16. package/dist/comments/CommentEditor.js.map +1 -1
  17. package/dist/comments/CommentProvider.cjs +3 -1
  18. package/dist/comments/CommentProvider.cjs.map +1 -1
  19. package/dist/comments/CommentProvider.d.ts +2 -0
  20. package/dist/comments/CommentProvider.d.ts.map +1 -1
  21. package/dist/comments/CommentProvider.js +3 -1
  22. package/dist/comments/CommentProvider.js.map +1 -1
  23. package/dist/comments/CommentRail.cjs +31 -18
  24. package/dist/comments/CommentRail.cjs.map +1 -1
  25. package/dist/comments/CommentRail.d.ts.map +1 -1
  26. package/dist/comments/CommentRail.js +31 -18
  27. package/dist/comments/CommentRail.js.map +1 -1
  28. package/dist/comments/agent-delivery.cjs +1 -2
  29. package/dist/comments/agent-delivery.cjs.map +1 -1
  30. package/dist/comments/agent-delivery.d.ts +1 -1
  31. package/dist/comments/agent-delivery.d.ts.map +1 -1
  32. package/dist/comments/agent-delivery.js +1 -2
  33. package/dist/comments/agent-delivery.js.map +1 -1
  34. package/dist/comments/annotation-types.d.ts +16 -0
  35. package/dist/comments/annotation-types.d.ts.map +1 -1
  36. package/dist/comments/comment-context.cjs.map +1 -1
  37. package/dist/comments/comment-context.d.ts +2 -1
  38. package/dist/comments/comment-context.d.ts.map +1 -1
  39. package/dist/comments/comment-context.js.map +1 -1
  40. package/dist/comments/comment-types.cjs.map +1 -1
  41. package/dist/comments/comment-types.d.ts +10 -1
  42. package/dist/comments/comment-types.d.ts.map +1 -1
  43. package/dist/comments/comment-types.js.map +1 -1
  44. package/dist/comments/gavel/CommentAgentSessions.cjs +55 -44
  45. package/dist/comments/gavel/CommentAgentSessions.cjs.map +1 -1
  46. package/dist/comments/gavel/CommentAgentSessions.d.ts +5 -2
  47. package/dist/comments/gavel/CommentAgentSessions.d.ts.map +1 -1
  48. package/dist/comments/gavel/CommentAgentSessions.js +55 -44
  49. package/dist/comments/gavel/CommentAgentSessions.js.map +1 -1
  50. package/dist/comments/gavel/client.cjs +3 -1
  51. package/dist/comments/gavel/client.cjs.map +1 -1
  52. package/dist/comments/gavel/client.d.ts.map +1 -1
  53. package/dist/comments/gavel/client.js +3 -1
  54. package/dist/comments/gavel/client.js.map +1 -1
  55. package/dist/comments/gavel/comment-agent-model.cjs +1 -1
  56. package/dist/comments/gavel/comment-agent-model.cjs.map +1 -1
  57. package/dist/comments/gavel/comment-agent-model.js +1 -1
  58. package/dist/comments/gavel/comment-agent-model.js.map +1 -1
  59. package/dist/comments/gavel/inbox-prompt.cjs +3 -1
  60. package/dist/comments/gavel/inbox-prompt.cjs.map +1 -1
  61. package/dist/comments/gavel/inbox-prompt.d.ts.map +1 -1
  62. package/dist/comments/gavel/inbox-prompt.js +3 -1
  63. package/dist/comments/gavel/inbox-prompt.js.map +1 -1
  64. package/dist/comments/gavel/index.d.ts +2 -1
  65. package/dist/comments/gavel/index.d.ts.map +1 -1
  66. package/dist/comments/gavel/useGavelComments.cjs +17 -9
  67. package/dist/comments/gavel/useGavelComments.cjs.map +1 -1
  68. package/dist/comments/gavel/useGavelComments.d.ts.map +1 -1
  69. package/dist/comments/gavel/useGavelComments.js +18 -10
  70. package/dist/comments/gavel/useGavelComments.js.map +1 -1
  71. package/dist/comments-gavel.cjs +4 -0
  72. package/dist/comments-gavel.js +3 -1
  73. package/dist/comments.d.ts +1 -1
  74. package/dist/comments.d.ts.map +1 -1
  75. package/dist/components/FilterBar.cjs +12 -5
  76. package/dist/components/FilterBar.cjs.map +1 -1
  77. package/dist/components/FilterBar.d.ts.map +1 -1
  78. package/dist/components/FilterBar.js +12 -5
  79. package/dist/components/FilterBar.js.map +1 -1
  80. package/dist/components/JsonSchemaForm.cjs +4 -1
  81. package/dist/components/JsonSchemaForm.cjs.map +1 -1
  82. package/dist/components/JsonSchemaForm.d.ts.map +1 -1
  83. package/dist/components/JsonSchemaForm.js +4 -1
  84. package/dist/components/JsonSchemaForm.js.map +1 -1
  85. package/dist/components/SecretFormField.cjs +3 -0
  86. package/dist/components/SecretFormField.cjs.map +1 -1
  87. package/dist/components/SecretFormField.d.ts.map +1 -1
  88. package/dist/components/SecretFormField.js +3 -0
  89. package/dist/components/SecretFormField.js.map +1 -1
  90. package/dist/components/SecretKeySelector.cjs +28 -2
  91. package/dist/components/SecretKeySelector.cjs.map +1 -1
  92. package/dist/components/SecretKeySelector.d.ts +7 -1
  93. package/dist/components/SecretKeySelector.d.ts.map +1 -1
  94. package/dist/components/SecretKeySelector.js +28 -2
  95. package/dist/components/SecretKeySelector.js.map +1 -1
  96. package/dist/components/SegmentedControl.cjs +4 -1
  97. package/dist/components/SegmentedControl.cjs.map +1 -1
  98. package/dist/components/SegmentedControl.d.ts +3 -3
  99. package/dist/components/SegmentedControl.d.ts.map +1 -1
  100. package/dist/components/SegmentedControl.js +5 -2
  101. package/dist/components/SegmentedControl.js.map +1 -1
  102. package/dist/components/WorkspaceAccessDialog.cjs +273 -99
  103. package/dist/components/WorkspaceAccessDialog.cjs.map +1 -1
  104. package/dist/components/WorkspaceAccessDialog.d.ts +4 -2
  105. package/dist/components/WorkspaceAccessDialog.d.ts.map +1 -1
  106. package/dist/components/WorkspaceAccessDialog.js +275 -101
  107. package/dist/components/WorkspaceAccessDialog.js.map +1 -1
  108. package/dist/components/json-schema-form-accordion-array.cjs +5 -3
  109. package/dist/components/json-schema-form-accordion-array.cjs.map +1 -1
  110. package/dist/components/json-schema-form-accordion-array.d.ts.map +1 -1
  111. package/dist/components/json-schema-form-accordion-array.js +7 -5
  112. package/dist/components/json-schema-form-accordion-array.js.map +1 -1
  113. package/dist/components/json-schema-form-cards-array.cjs +1 -0
  114. package/dist/components/json-schema-form-cards-array.cjs.map +1 -1
  115. package/dist/components/json-schema-form-cards-array.d.ts.map +1 -1
  116. package/dist/components/json-schema-form-cards-array.js +2 -1
  117. package/dist/components/json-schema-form-cards-array.js.map +1 -1
  118. package/dist/components/json-schema-form-conditionals.cjs +1 -4
  119. package/dist/components/json-schema-form-conditionals.cjs.map +1 -1
  120. package/dist/components/json-schema-form-conditionals.d.ts.map +1 -1
  121. package/dist/components/json-schema-form-conditionals.js +1 -4
  122. package/dist/components/json-schema-form-conditionals.js.map +1 -1
  123. package/dist/components/json-schema-form-enum-choice.cjs +4 -3
  124. package/dist/components/json-schema-form-enum-choice.cjs.map +1 -1
  125. package/dist/components/json-schema-form-enum-choice.d.ts.map +1 -1
  126. package/dist/components/json-schema-form-enum-choice.js +4 -3
  127. package/dist/components/json-schema-form-enum-choice.js.map +1 -1
  128. package/dist/components/json-schema-form-item-row.cjs +4 -0
  129. package/dist/components/json-schema-form-item-row.cjs.map +1 -1
  130. package/dist/components/json-schema-form-item-row.d.ts +3 -0
  131. package/dist/components/json-schema-form-item-row.d.ts.map +1 -1
  132. package/dist/components/json-schema-form-item-row.js +5 -2
  133. package/dist/components/json-schema-form-item-row.js.map +1 -1
  134. package/dist/components/json-schema-form-item-summary.cjs +10 -0
  135. package/dist/components/json-schema-form-item-summary.cjs.map +1 -1
  136. package/dist/components/json-schema-form-item-summary.d.ts +1 -0
  137. package/dist/components/json-schema-form-item-summary.d.ts.map +1 -1
  138. package/dist/components/json-schema-form-item-summary.js +10 -1
  139. package/dist/components/json-schema-form-item-summary.js.map +1 -1
  140. package/dist/components/json-schema-form-listeners.cjs +1 -5
  141. package/dist/components/json-schema-form-listeners.cjs.map +1 -1
  142. package/dist/components/json-schema-form-listeners.js +1 -5
  143. package/dist/components/json-schema-form-listeners.js.map +1 -1
  144. package/dist/components/json-schema-form-refs.cjs +29 -4
  145. package/dist/components/json-schema-form-refs.cjs.map +1 -1
  146. package/dist/components/json-schema-form-refs.js +29 -4
  147. package/dist/components/json-schema-form-refs.js.map +1 -1
  148. package/dist/components/json-schema-form-render.cjs +35 -13
  149. package/dist/components/json-schema-form-render.cjs.map +1 -1
  150. package/dist/components/json-schema-form-render.d.ts.map +1 -1
  151. package/dist/components/json-schema-form-render.js +36 -14
  152. package/dist/components/json-schema-form-render.js.map +1 -1
  153. package/dist/components/json-schema-form-resolve.cjs +3 -1
  154. package/dist/components/json-schema-form-resolve.cjs.map +1 -1
  155. package/dist/components/json-schema-form-resolve.d.ts.map +1 -1
  156. package/dist/components/json-schema-form-resolve.js +3 -1
  157. package/dist/components/json-schema-form-resolve.js.map +1 -1
  158. package/dist/components/json-schema-form-runtime-types.d.ts +8 -0
  159. package/dist/components/json-schema-form-runtime-types.d.ts.map +1 -1
  160. package/dist/components/json-schema-form-table-array.cjs +1 -1
  161. package/dist/components/json-schema-form-table-array.cjs.map +1 -1
  162. package/dist/components/json-schema-form-table-array.js +2 -2
  163. package/dist/components/json-schema-form-table-array.js.map +1 -1
  164. package/dist/components/json-schema-form-types.d.ts +6 -0
  165. package/dist/components/json-schema-form-types.d.ts.map +1 -1
  166. package/dist/components/json-schema-form-utils.cjs +12 -3
  167. package/dist/components/json-schema-form-utils.cjs.map +1 -1
  168. package/dist/components/json-schema-form-utils.d.ts +4 -1
  169. package/dist/components/json-schema-form-utils.d.ts.map +1 -1
  170. package/dist/components/json-schema-form-utils.js +12 -3
  171. package/dist/components/json-schema-form-utils.js.map +1 -1
  172. package/dist/components/secret-form-extension.cjs.map +1 -1
  173. package/dist/components/secret-form-extension.d.ts +2 -0
  174. package/dist/components/secret-form-extension.d.ts.map +1 -1
  175. package/dist/components/secret-form-extension.js.map +1 -1
  176. package/dist/components/useSingleRowTagCount.cjs +16 -13
  177. package/dist/components/useSingleRowTagCount.cjs.map +1 -1
  178. package/dist/components/useSingleRowTagCount.d.ts +0 -5
  179. package/dist/components/useSingleRowTagCount.d.ts.map +1 -1
  180. package/dist/components/useSingleRowTagCount.js +16 -13
  181. package/dist/components/useSingleRowTagCount.js.map +1 -1
  182. package/dist/components.cjs +4 -0
  183. package/dist/components.d.ts +2 -0
  184. package/dist/components.d.ts.map +1 -1
  185. package/dist/components.js +3 -1
  186. package/dist/connections/connectionSchemaFormExtensions.cjs +13 -2
  187. package/dist/connections/connectionSchemaFormExtensions.cjs.map +1 -1
  188. package/dist/connections/connectionSchemaFormExtensions.d.ts.map +1 -1
  189. package/dist/connections/connectionSchemaFormExtensions.js +13 -2
  190. package/dist/connections/connectionSchemaFormExtensions.js.map +1 -1
  191. package/dist/data/DataTable.cjs +128 -82
  192. package/dist/data/DataTable.cjs.map +1 -1
  193. package/dist/data/DataTable.d.ts +29 -0
  194. package/dist/data/DataTable.d.ts.map +1 -1
  195. package/dist/data/DataTable.js +129 -83
  196. package/dist/data/DataTable.js.map +1 -1
  197. package/dist/data/DataTableList.cjs +43 -0
  198. package/dist/data/DataTableList.cjs.map +1 -0
  199. package/dist/data/DataTableList.d.ts +13 -0
  200. package/dist/data/DataTableList.d.ts.map +1 -0
  201. package/dist/data/DataTableList.js +43 -0
  202. package/dist/data/DataTableList.js.map +1 -0
  203. package/dist/data/DataTableOverflowCue.cjs +18 -8
  204. package/dist/data/DataTableOverflowCue.cjs.map +1 -1
  205. package/dist/data/DataTableOverflowCue.d.ts.map +1 -1
  206. package/dist/data/DataTableOverflowCue.js +18 -8
  207. package/dist/data/DataTableOverflowCue.js.map +1 -1
  208. package/dist/data/Markdown.cjs +11 -1
  209. package/dist/data/Markdown.cjs.map +1 -1
  210. package/dist/data/Markdown.d.ts.map +1 -1
  211. package/dist/data/Markdown.js +11 -1
  212. package/dist/data/Markdown.js.map +1 -1
  213. package/dist/data/PromptBanner.cjs +13 -4
  214. package/dist/data/PromptBanner.cjs.map +1 -1
  215. package/dist/data/PromptBanner.d.ts.map +1 -1
  216. package/dist/data/PromptBanner.js +13 -4
  217. package/dist/data/PromptBanner.js.map +1 -1
  218. package/dist/data/SelectionActionBar.cjs +20 -5
  219. package/dist/data/SelectionActionBar.cjs.map +1 -1
  220. package/dist/data/SelectionActionBar.d.ts +6 -1
  221. package/dist/data/SelectionActionBar.d.ts.map +1 -1
  222. package/dist/data/SelectionActionBar.js +20 -5
  223. package/dist/data/SelectionActionBar.js.map +1 -1
  224. package/dist/data/StatStrip.cjs +12 -4
  225. package/dist/data/StatStrip.cjs.map +1 -1
  226. package/dist/data/StatStrip.d.ts +0 -8
  227. package/dist/data/StatStrip.d.ts.map +1 -1
  228. package/dist/data/StatStrip.js +12 -4
  229. package/dist/data/StatStrip.js.map +1 -1
  230. package/dist/data/TaskManager.cjs +173 -53
  231. package/dist/data/TaskManager.cjs.map +1 -1
  232. package/dist/data/TaskManager.d.ts +9 -1
  233. package/dist/data/TaskManager.d.ts.map +1 -1
  234. package/dist/data/TaskManager.js +175 -55
  235. package/dist/data/TaskManager.js.map +1 -1
  236. package/dist/data/TaskPoolUsage.cjs +65 -1
  237. package/dist/data/TaskPoolUsage.cjs.map +1 -1
  238. package/dist/data/TaskPoolUsage.d.ts +19 -1
  239. package/dist/data/TaskPoolUsage.d.ts.map +1 -1
  240. package/dist/data/TaskPoolUsage.js +65 -2
  241. package/dist/data/TaskPoolUsage.js.map +1 -1
  242. package/dist/data/ai/SessionInspector.cjs +24 -14
  243. package/dist/data/ai/SessionInspector.cjs.map +1 -1
  244. package/dist/data/ai/SessionInspector.collection.cjs +9 -7
  245. package/dist/data/ai/SessionInspector.collection.cjs.map +1 -1
  246. package/dist/data/ai/SessionInspector.collection.d.ts +1 -1
  247. package/dist/data/ai/SessionInspector.collection.d.ts.map +1 -1
  248. package/dist/data/ai/SessionInspector.collection.js +9 -7
  249. package/dist/data/ai/SessionInspector.collection.js.map +1 -1
  250. package/dist/data/ai/SessionInspector.d.ts +8 -3
  251. package/dist/data/ai/SessionInspector.d.ts.map +1 -1
  252. package/dist/data/ai/SessionInspector.hierarchy-state.cjs +5 -4
  253. package/dist/data/ai/SessionInspector.hierarchy-state.cjs.map +1 -1
  254. package/dist/data/ai/SessionInspector.hierarchy-state.js +6 -5
  255. package/dist/data/ai/SessionInspector.hierarchy-state.js.map +1 -1
  256. package/dist/data/ai/SessionInspector.host-tabs.cjs +28 -0
  257. package/dist/data/ai/SessionInspector.host-tabs.cjs.map +1 -0
  258. package/dist/data/ai/SessionInspector.host-tabs.d.ts +17 -0
  259. package/dist/data/ai/SessionInspector.host-tabs.d.ts.map +1 -0
  260. package/dist/data/ai/SessionInspector.host-tabs.js +28 -0
  261. package/dist/data/ai/SessionInspector.host-tabs.js.map +1 -0
  262. package/dist/data/ai/SessionInspector.js +24 -14
  263. package/dist/data/ai/SessionInspector.js.map +1 -1
  264. package/dist/data/ai/SessionInspector.legacy.cjs +13 -6
  265. package/dist/data/ai/SessionInspector.legacy.cjs.map +1 -1
  266. package/dist/data/ai/SessionInspector.legacy.d.ts +3 -1
  267. package/dist/data/ai/SessionInspector.legacy.d.ts.map +1 -1
  268. package/dist/data/ai/SessionInspector.legacy.js +13 -6
  269. package/dist/data/ai/SessionInspector.legacy.js.map +1 -1
  270. package/dist/data/ai/SessionInspector.remote.cjs +7 -3
  271. package/dist/data/ai/SessionInspector.remote.cjs.map +1 -1
  272. package/dist/data/ai/SessionInspector.remote.d.ts +1 -1
  273. package/dist/data/ai/SessionInspector.remote.d.ts.map +1 -1
  274. package/dist/data/ai/SessionInspector.remote.js +8 -4
  275. package/dist/data/ai/SessionInspector.remote.js.map +1 -1
  276. package/dist/data/ai/SessionViewer.input.cjs +78 -1
  277. package/dist/data/ai/SessionViewer.input.cjs.map +1 -1
  278. package/dist/data/ai/SessionViewer.input.d.ts +9 -0
  279. package/dist/data/ai/SessionViewer.input.d.ts.map +1 -1
  280. package/dist/data/ai/SessionViewer.input.js +77 -2
  281. package/dist/data/ai/SessionViewer.input.js.map +1 -1
  282. package/dist/data/ai/SessionViewer.tool-details.cjs +44 -13
  283. package/dist/data/ai/SessionViewer.tool-details.cjs.map +1 -1
  284. package/dist/data/ai/SessionViewer.tool-details.d.ts +7 -1
  285. package/dist/data/ai/SessionViewer.tool-details.d.ts.map +1 -1
  286. package/dist/data/ai/SessionViewer.tool-details.js +44 -13
  287. package/dist/data/ai/SessionViewer.tool-details.js.map +1 -1
  288. package/dist/data/ai/SessionViewer.tool-row.cjs +7 -3
  289. package/dist/data/ai/SessionViewer.tool-row.cjs.map +1 -1
  290. package/dist/data/ai/SessionViewer.tool-row.d.ts.map +1 -1
  291. package/dist/data/ai/SessionViewer.tool-row.js +8 -4
  292. package/dist/data/ai/SessionViewer.tool-row.js.map +1 -1
  293. package/dist/data/ai/index.d.ts +1 -1
  294. package/dist/data/ai/index.d.ts.map +1 -1
  295. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs +5 -2
  296. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs.map +1 -1
  297. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.d.ts.map +1 -1
  298. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js +6 -3
  299. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js.map +1 -1
  300. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs +2 -1
  301. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs.map +1 -1
  302. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts.map +1 -1
  303. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js +2 -1
  304. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js.map +1 -1
  305. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs +2 -1
  306. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs.map +1 -1
  307. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts.map +1 -1
  308. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js +2 -1
  309. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js.map +1 -1
  310. package/dist/data/ai/use-session-scroll.cjs +120 -41
  311. package/dist/data/ai/use-session-scroll.cjs.map +1 -1
  312. package/dist/data/ai/use-session-scroll.d.ts +3 -3
  313. package/dist/data/ai/use-session-scroll.d.ts.map +1 -1
  314. package/dist/data/ai/use-session-scroll.js +120 -41
  315. package/dist/data/ai/use-session-scroll.js.map +1 -1
  316. package/dist/data/cells/timestamp-format.cjs +57 -2
  317. package/dist/data/cells/timestamp-format.cjs.map +1 -1
  318. package/dist/data/cells/timestamp-format.d.ts +9 -1
  319. package/dist/data/cells/timestamp-format.d.ts.map +1 -1
  320. package/dist/data/cells/timestamp-format.js +56 -3
  321. package/dist/data/cells/timestamp-format.js.map +1 -1
  322. package/dist/data/chat/AgentIdentity.cjs +10 -3
  323. package/dist/data/chat/AgentIdentity.cjs.map +1 -1
  324. package/dist/data/chat/AgentIdentity.d.ts +2 -1
  325. package/dist/data/chat/AgentIdentity.d.ts.map +1 -1
  326. package/dist/data/chat/AgentIdentity.js +10 -3
  327. package/dist/data/chat/AgentIdentity.js.map +1 -1
  328. package/dist/data/chat/Conversation.cjs +14 -5
  329. package/dist/data/chat/Conversation.cjs.map +1 -1
  330. package/dist/data/chat/Conversation.d.ts.map +1 -1
  331. package/dist/data/chat/Conversation.js +14 -5
  332. package/dist/data/chat/Conversation.js.map +1 -1
  333. package/dist/data/data-table-list.cjs +24 -0
  334. package/dist/data/data-table-list.cjs.map +1 -0
  335. package/dist/data/data-table-list.d.ts +31 -0
  336. package/dist/data/data-table-list.d.ts.map +1 -0
  337. package/dist/data/data-table-list.js +24 -0
  338. package/dist/data/data-table-list.js.map +1 -0
  339. package/dist/data/delimited.cjs +48 -0
  340. package/dist/data/delimited.cjs.map +1 -0
  341. package/dist/data/delimited.d.ts +10 -0
  342. package/dist/data/delimited.d.ts.map +1 -0
  343. package/dist/data/delimited.js +47 -0
  344. package/dist/data/delimited.js.map +1 -0
  345. package/dist/data/git/index.d.ts +1 -0
  346. package/dist/data/git/index.d.ts.map +1 -1
  347. package/dist/data/git/pickers/GitPickers.cjs +2 -0
  348. package/dist/data/git/pickers/GitPickers.cjs.map +1 -1
  349. package/dist/data/git/pickers/GitPickers.d.ts.map +1 -1
  350. package/dist/data/git/pickers/GitPickers.js +2 -0
  351. package/dist/data/git/pickers/GitPickers.js.map +1 -1
  352. package/dist/data/git/pickers/GitSourcePicker.cjs +9 -2
  353. package/dist/data/git/pickers/GitSourcePicker.cjs.map +1 -1
  354. package/dist/data/git/pickers/GitSourcePicker.d.ts.map +1 -1
  355. package/dist/data/git/pickers/GitSourcePicker.js +9 -2
  356. package/dist/data/git/pickers/GitSourcePicker.js.map +1 -1
  357. package/dist/data/git/pickers/ReferencePicker.cjs +60 -6
  358. package/dist/data/git/pickers/ReferencePicker.cjs.map +1 -1
  359. package/dist/data/git/pickers/ReferencePicker.d.ts +9 -1
  360. package/dist/data/git/pickers/ReferencePicker.d.ts.map +1 -1
  361. package/dist/data/git/pickers/ReferencePicker.js +61 -7
  362. package/dist/data/git/pickers/ReferencePicker.js.map +1 -1
  363. package/dist/data/git/pickers/git-ref-group-limits.cjs +14 -0
  364. package/dist/data/git/pickers/git-ref-group-limits.cjs.map +1 -0
  365. package/dist/data/git/pickers/git-ref-group-limits.d.ts +11 -0
  366. package/dist/data/git/pickers/git-ref-group-limits.d.ts.map +1 -0
  367. package/dist/data/git/pickers/git-ref-group-limits.js +14 -0
  368. package/dist/data/git/pickers/git-ref-group-limits.js.map +1 -0
  369. package/dist/data/git/pickers/types.d.ts +2 -0
  370. package/dist/data/git/pickers/types.d.ts.map +1 -1
  371. package/dist/data/lint/LintList.cjs +154 -0
  372. package/dist/data/lint/LintList.cjs.map +1 -0
  373. package/dist/data/lint/LintList.d.ts +14 -0
  374. package/dist/data/lint/LintList.d.ts.map +1 -0
  375. package/dist/data/lint/LintList.js +154 -0
  376. package/dist/data/lint/LintList.js.map +1 -0
  377. package/dist/data/lint/LintResults.cjs +31 -10
  378. package/dist/data/lint/LintResults.cjs.map +1 -1
  379. package/dist/data/lint/LintResults.d.ts +5 -3
  380. package/dist/data/lint/LintResults.d.ts.map +1 -1
  381. package/dist/data/lint/LintResults.js +31 -10
  382. package/dist/data/lint/LintResults.js.map +1 -1
  383. package/dist/data/lint/actions.cjs +3 -1
  384. package/dist/data/lint/actions.cjs.map +1 -1
  385. package/dist/data/lint/actions.d.ts.map +1 -1
  386. package/dist/data/lint/actions.js +3 -1
  387. package/dist/data/lint/actions.js.map +1 -1
  388. package/dist/data/lint/index.d.ts +2 -0
  389. package/dist/data/lint/index.d.ts.map +1 -1
  390. package/dist/data/lint/list-grouping.cjs +39 -0
  391. package/dist/data/lint/list-grouping.cjs.map +1 -0
  392. package/dist/data/lint/list-grouping.d.ts +20 -0
  393. package/dist/data/lint/list-grouping.d.ts.map +1 -0
  394. package/dist/data/lint/list-grouping.js +39 -0
  395. package/dist/data/lint/list-grouping.js.map +1 -0
  396. package/dist/data/task-run-format.cjs +20 -0
  397. package/dist/data/task-run-format.cjs.map +1 -0
  398. package/dist/data/task-run-format.d.ts +6 -0
  399. package/dist/data/task-run-format.d.ts.map +1 -0
  400. package/dist/data/task-run-format.js +20 -0
  401. package/dist/data/task-run-format.js.map +1 -0
  402. package/dist/data/test-runner/TestDetailPanel.cjs +15 -4
  403. package/dist/data/test-runner/TestDetailPanel.cjs.map +1 -1
  404. package/dist/data/test-runner/TestDetailPanel.d.ts.map +1 -1
  405. package/dist/data/test-runner/TestDetailPanel.js +16 -5
  406. package/dist/data/test-runner/TestDetailPanel.js.map +1 -1
  407. package/dist/data/test-runner/TestList.cjs +87 -0
  408. package/dist/data/test-runner/TestList.cjs.map +1 -0
  409. package/dist/data/test-runner/TestList.d.ts +9 -0
  410. package/dist/data/test-runner/TestList.d.ts.map +1 -0
  411. package/dist/data/test-runner/TestList.js +87 -0
  412. package/dist/data/test-runner/TestList.js.map +1 -0
  413. package/dist/data/test-runner/TestRunner.cjs +21 -2
  414. package/dist/data/test-runner/TestRunner.cjs.map +1 -1
  415. package/dist/data/test-runner/TestRunner.d.ts +9 -1
  416. package/dist/data/test-runner/TestRunner.d.ts.map +1 -1
  417. package/dist/data/test-runner/TestRunner.js +21 -2
  418. package/dist/data/test-runner/TestRunner.js.map +1 -1
  419. package/dist/data/test-runner/TestTreeNode.cjs +1 -1
  420. package/dist/data/test-runner/TestTreeNode.cjs.map +1 -1
  421. package/dist/data/test-runner/TestTreeNode.js +1 -1
  422. package/dist/data/test-runner/TestTreeNode.js.map +1 -1
  423. package/dist/data/test-runner/TestViewToggle.cjs +32 -0
  424. package/dist/data/test-runner/TestViewToggle.cjs.map +1 -0
  425. package/dist/data/test-runner/TestViewToggle.d.ts +5 -0
  426. package/dist/data/test-runner/TestViewToggle.d.ts.map +1 -0
  427. package/dist/data/test-runner/TestViewToggle.js +32 -0
  428. package/dist/data/test-runner/TestViewToggle.js.map +1 -0
  429. package/dist/data/test-runner/adapter.cjs +14 -0
  430. package/dist/data/test-runner/adapter.cjs.map +1 -1
  431. package/dist/data/test-runner/adapter.d.ts +15 -0
  432. package/dist/data/test-runner/adapter.d.ts.map +1 -1
  433. package/dist/data/test-runner/adapter.js +14 -0
  434. package/dist/data/test-runner/adapter.js.map +1 -1
  435. package/dist/data/test-runner/context.cjs.map +1 -1
  436. package/dist/data/test-runner/context.d.ts +5 -0
  437. package/dist/data/test-runner/context.d.ts.map +1 -1
  438. package/dist/data/test-runner/context.js.map +1 -1
  439. package/dist/data/test-runner/index.d.ts +3 -0
  440. package/dist/data/test-runner/index.d.ts.map +1 -1
  441. package/dist/data/test-runner/status.cjs +5 -0
  442. package/dist/data/test-runner/status.cjs.map +1 -1
  443. package/dist/data/test-runner/status.d.ts +2 -0
  444. package/dist/data/test-runner/status.d.ts.map +1 -1
  445. package/dist/data/test-runner/status.js +5 -1
  446. package/dist/data/test-runner/status.js.map +1 -1
  447. package/dist/data/traces/index.d.ts +2 -1
  448. package/dist/data/traces/index.d.ts.map +1 -1
  449. package/dist/data/traces/otel/OtelTraceBrowser.cjs +173 -0
  450. package/dist/data/traces/otel/OtelTraceBrowser.cjs.map +1 -0
  451. package/dist/data/traces/otel/OtelTraceBrowser.d.ts +31 -0
  452. package/dist/data/traces/otel/OtelTraceBrowser.d.ts.map +1 -0
  453. package/dist/data/traces/otel/OtelTraceBrowser.js +173 -0
  454. package/dist/data/traces/otel/OtelTraceBrowser.js.map +1 -0
  455. package/dist/data/traces/otel/OtelTraceDetail.cjs +6 -4
  456. package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
  457. package/dist/data/traces/otel/OtelTraceDetail.d.ts +5 -1
  458. package/dist/data/traces/otel/OtelTraceDetail.d.ts.map +1 -1
  459. package/dist/data/traces/otel/OtelTraceDetail.js +6 -4
  460. package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
  461. package/dist/data/traces/otel/OtelTraceSearch.cjs +2 -1
  462. package/dist/data/traces/otel/OtelTraceSearch.cjs.map +1 -1
  463. package/dist/data/traces/otel/OtelTraceSearch.d.ts +3 -1
  464. package/dist/data/traces/otel/OtelTraceSearch.d.ts.map +1 -1
  465. package/dist/data/traces/otel/OtelTraceSearch.js +2 -1
  466. package/dist/data/traces/otel/OtelTraceSearch.js.map +1 -1
  467. package/dist/data/traces/otel/OtelTraceTable.cjs +62 -6
  468. package/dist/data/traces/otel/OtelTraceTable.cjs.map +1 -1
  469. package/dist/data/traces/otel/OtelTraceTable.d.ts +22 -1
  470. package/dist/data/traces/otel/OtelTraceTable.d.ts.map +1 -1
  471. package/dist/data/traces/otel/OtelTraceTable.js +62 -6
  472. package/dist/data/traces/otel/OtelTraceTable.js.map +1 -1
  473. package/dist/data/traces/otel/QueryBar.cjs +23 -10
  474. package/dist/data/traces/otel/QueryBar.cjs.map +1 -1
  475. package/dist/data/traces/otel/QueryBar.d.ts +3 -1
  476. package/dist/data/traces/otel/QueryBar.d.ts.map +1 -1
  477. package/dist/data/traces/otel/QueryBar.js +23 -10
  478. package/dist/data/traces/otel/QueryBar.js.map +1 -1
  479. package/dist/data/traces/otel/browser-state.cjs +86 -0
  480. package/dist/data/traces/otel/browser-state.cjs.map +1 -0
  481. package/dist/data/traces/otel/browser-state.d.ts +22 -0
  482. package/dist/data/traces/otel/browser-state.d.ts.map +1 -0
  483. package/dist/data/traces/otel/browser-state.js +83 -0
  484. package/dist/data/traces/otel/browser-state.js.map +1 -0
  485. package/dist/data/version-info.cjs +3 -3
  486. package/dist/data/version-info.js +3 -3
  487. package/dist/data.cjs +17 -0
  488. package/dist/data.d.ts +3 -3
  489. package/dist/data.d.ts.map +1 -1
  490. package/dist/data.js +10 -3
  491. package/dist/file-findings/file-review/FileReview.cjs +38 -11
  492. package/dist/file-findings/file-review/FileReview.cjs.map +1 -1
  493. package/dist/file-findings/file-review/FileReview.d.ts.map +1 -1
  494. package/dist/file-findings/file-review/FileReview.js +39 -12
  495. package/dist/file-findings/file-review/FileReview.js.map +1 -1
  496. package/dist/file-findings/file-review/geometry.cjs +20 -15
  497. package/dist/file-findings/file-review/geometry.cjs.map +1 -1
  498. package/dist/file-findings/file-review/geometry.d.ts +5 -3
  499. package/dist/file-findings/file-review/geometry.d.ts.map +1 -1
  500. package/dist/file-findings/file-review/geometry.js +21 -16
  501. package/dist/file-findings/file-review/geometry.js.map +1 -1
  502. package/dist/file-findings/file-review/patch-comments.cjs +23 -16
  503. package/dist/file-findings/file-review/patch-comments.cjs.map +1 -1
  504. package/dist/file-findings/file-review/patch-comments.d.ts +22 -12
  505. package/dist/file-findings/file-review/patch-comments.d.ts.map +1 -1
  506. package/dist/file-findings/file-review/patch-comments.js +23 -17
  507. package/dist/file-findings/file-review/patch-comments.js.map +1 -1
  508. package/dist/file-findings/file-review/quote-anchor.cjs +23 -9
  509. package/dist/file-findings/file-review/quote-anchor.cjs.map +1 -1
  510. package/dist/file-findings/file-review/quote-anchor.d.ts +12 -2
  511. package/dist/file-findings/file-review/quote-anchor.d.ts.map +1 -1
  512. package/dist/file-findings/file-review/quote-anchor.js +22 -9
  513. package/dist/file-findings/file-review/quote-anchor.js.map +1 -1
  514. package/dist/file-findings/file-review/selection-lines.cjs +17 -8
  515. package/dist/file-findings/file-review/selection-lines.cjs.map +1 -1
  516. package/dist/file-findings/file-review/selection-lines.d.ts +3 -2
  517. package/dist/file-findings/file-review/selection-lines.d.ts.map +1 -1
  518. package/dist/file-findings/file-review/selection-lines.js +17 -8
  519. package/dist/file-findings/file-review/selection-lines.js.map +1 -1
  520. package/dist/file-findings/file-review/table-cell.cjs +95 -0
  521. package/dist/file-findings/file-review/table-cell.cjs.map +1 -0
  522. package/dist/file-findings/file-review/table-cell.d.ts +31 -0
  523. package/dist/file-findings/file-review/table-cell.d.ts.map +1 -0
  524. package/dist/file-findings/file-review/table-cell.js +92 -0
  525. package/dist/file-findings/file-review/table-cell.js.map +1 -0
  526. package/dist/file-findings.cjs +2 -0
  527. package/dist/file-findings.d.ts +1 -0
  528. package/dist/file-findings.d.ts.map +1 -1
  529. package/dist/file-findings.js +2 -1
  530. package/dist/icons/components/UiFolderGit.cjs +8 -8
  531. package/dist/icons/components/UiFolderGit.cjs.map +1 -1
  532. package/dist/icons/components/UiFolderGit.js +8 -8
  533. package/dist/icons/components/UiFolderGit.js.map +1 -1
  534. package/dist/icons/components/UiUserSwitch.cjs +51 -0
  535. package/dist/icons/components/UiUserSwitch.cjs.map +1 -0
  536. package/dist/icons/components/UiUserSwitch.d.ts +15 -0
  537. package/dist/icons/components/UiUserSwitch.d.ts.map +1 -0
  538. package/dist/icons/components/UiUserSwitch.js +48 -0
  539. package/dist/icons/components/UiUserSwitch.js.map +1 -0
  540. package/dist/icons/index.d.ts +2 -0
  541. package/dist/icons/index.d.ts.map +1 -1
  542. package/dist/icons/registry.cjs +2 -0
  543. package/dist/icons/registry.cjs.map +1 -1
  544. package/dist/icons/registry.d.ts.map +1 -1
  545. package/dist/icons/registry.js +2 -0
  546. package/dist/icons/registry.js.map +1 -1
  547. package/dist/icons.cjs +3 -0
  548. package/dist/icons.js +2 -1
  549. package/dist/index.cjs +23 -0
  550. package/dist/index.js +13 -3
  551. package/dist/jvm/model/threads.cjs +1 -1
  552. package/dist/jvm/model/threads.cjs.map +1 -1
  553. package/dist/jvm/model/threads.js +1 -1
  554. package/dist/jvm/model/threads.js.map +1 -1
  555. package/dist/lib/random-uuid.cjs +12 -0
  556. package/dist/lib/random-uuid.cjs.map +1 -0
  557. package/dist/lib/random-uuid.d.ts +2 -0
  558. package/dist/lib/random-uuid.d.ts.map +1 -0
  559. package/dist/lib/random-uuid.js +12 -0
  560. package/dist/lib/random-uuid.js.map +1 -0
  561. package/dist/overlay/Modal.cjs +22 -11
  562. package/dist/overlay/Modal.cjs.map +1 -1
  563. package/dist/overlay/Modal.d.ts +5 -1
  564. package/dist/overlay/Modal.d.ts.map +1 -1
  565. package/dist/overlay/Modal.js +22 -11
  566. package/dist/overlay/Modal.js.map +1 -1
  567. package/dist/overlay/ModalProvider.cjs +238 -0
  568. package/dist/overlay/ModalProvider.cjs.map +1 -0
  569. package/dist/overlay/ModalProvider.d.ts +10 -0
  570. package/dist/overlay/ModalProvider.d.ts.map +1 -0
  571. package/dist/overlay/ModalProvider.js +238 -0
  572. package/dist/overlay/ModalProvider.js.map +1 -0
  573. package/dist/overlay/modal-context.cjs +12 -0
  574. package/dist/overlay/modal-context.cjs.map +1 -0
  575. package/dist/overlay/modal-context.d.ts +46 -0
  576. package/dist/overlay/modal-context.d.ts.map +1 -0
  577. package/dist/overlay/modal-context.js +11 -0
  578. package/dist/overlay/modal-context.js.map +1 -0
  579. package/dist/overlay/modal-draft-storage.cjs +51 -0
  580. package/dist/overlay/modal-draft-storage.cjs.map +1 -0
  581. package/dist/overlay/modal-draft-storage.d.ts +19 -0
  582. package/dist/overlay/modal-draft-storage.d.ts.map +1 -0
  583. package/dist/overlay/modal-draft-storage.js +47 -0
  584. package/dist/overlay/modal-draft-storage.js.map +1 -0
  585. package/dist/runtime/barrels.json +8696 -8652
  586. package/dist/runtime/importmap.json +2116 -2103
  587. package/dist/styles.css +1 -1
  588. package/dist/utils.cjs +2 -0
  589. package/dist/utils.d.ts +1 -0
  590. package/dist/utils.d.ts.map +1 -1
  591. package/dist/utils.js +2 -1
  592. package/package.json +2 -2
@@ -2,18 +2,29 @@ const require_dom_anchor = require("../../comments/anchoring/dom-anchor.cjs");
2
2
  const require_patch_anchor = require("../../comments/anchoring/patch-anchor.cjs");
3
3
  const require_findings_comments = require("../findings-comments.cjs");
4
4
  const require_quote_anchor = require("./quote-anchor.cjs");
5
+ const require_table_cell = require("./table-cell.cjs");
5
6
  // src/file-findings/file-review/geometry.ts
6
7
  var SOURCE_BLOCK = "[data-source-start]";
7
8
  /** The rendered source block holding `node`, if any. */
8
9
  function sourceBlockOf(node) {
9
10
  return (node instanceof Element ? node : node?.parentElement ?? null)?.closest(SOURCE_BLOCK) ?? null;
10
11
  }
12
+ /** The table cell `cell` names in a table covering `lines`, while it still sits on them. */
13
+ function cellInLines(markdown, lines, cell) {
14
+ for (const block of markdown.querySelectorAll(SOURCE_BLOCK)) {
15
+ if (Number(block.dataset.sourceStart) > lines.end || Number(block.dataset.sourceEnd) < lines.start) continue;
16
+ const found = require_table_cell.resolveTableCell(block, cell);
17
+ if (found && found.line >= lines.start && found.line <= lines.end) return found.cell;
18
+ }
19
+ return null;
20
+ }
11
21
  /**
12
22
  * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in
13
23
  * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's
14
24
  * does. An anchor in `patchRanges` (an `r:` thread already placed in the
15
- * source) covers every block that overlaps its lines, or in text mode just its
16
- * quoted words while the quote still lies in them; an `e:` anchor finds its
25
+ * source) covers every block that overlaps its lines (in a table, just the rows
26
+ * on them); in text mode, just its table cell and quoted words while they still
27
+ * lie in those lines. An `e:` anchor finds its
17
28
  * element by its locators and takes that element's box. An anchor that no
18
29
  * longer finds its target is left out. Entries come in document order.
19
30
  */
@@ -65,21 +76,15 @@ function measureAnchors({ origin, markdown, anchors, mode, patchRanges }) {
65
76
  if (require_patch_anchor.isPatchAnchor(anchor)) {
66
77
  const lines = patchRanges?.get(anchor);
67
78
  if (!lines) continue;
68
- const range = mode === "text" && lines.quote ? require_quote_anchor.resolveQuoteInLines(markdown, lines, lines.quote) : null;
79
+ const within = mode === "text" && lines.cell ? cellInLines(markdown, lines, lines.cell) : null;
80
+ const covering = within ? [within] : require_quote_anchor.elementsInLines(markdown, lines);
81
+ const range = mode === "text" && lines.quote ? require_quote_anchor.resolveQuoteWithin(covering, lines.quote) : null;
69
82
  const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];
70
- if (words.length > 0) {
71
- found.push({
72
- anchor,
73
- boxes: words,
74
- at: words[0].top
75
- });
76
- continue;
77
- }
78
- const covered = [...markdown.querySelectorAll(SOURCE_BLOCK)].filter((el) => Number(el.dataset.sourceStart) <= lines.end && Number(el.dataset.sourceEnd) >= lines.start).flatMap(blockBoxes);
79
- if (covered.length > 0) found.push({
83
+ const boxes = words.length > 0 ? words : covering.flatMap(blockBoxes);
84
+ if (boxes.length > 0) found.push({
80
85
  anchor,
81
- boxes: covered,
82
- at: covered[0].top
86
+ boxes,
87
+ at: boxes[0].top
83
88
  });
84
89
  continue;
85
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.cjs","names":["blockAnchor","resolveQuote","parseQuoteAnchor","resolveElementAnchor","isPatchAnchor","resolveQuoteInLines","lineRangeAnchorResolver"],"sources":["../../../src/file-findings/file-review/geometry.ts"],"sourcesContent":["import { ELEMENT_PREFIX, resolveElementAnchor } from \"../../comments/anchoring/dom-anchor\";\nimport { isPatchAnchor } from \"../../comments/anchoring/patch-anchor\";\nimport { blockAnchor, lineRangeAnchorResolver } from \"../findings-comments\";\n\nimport type { TextQuote } from \"../../comments/annotation-types\";\nimport { QUOTE_PREFIX, parseQuoteAnchor, resolveQuote, resolveQuoteInLines } from \"./quote-anchor\";\n\n/** A rectangle relative to the annotated document's top-left corner. */\nexport type Box = { top: number; left: number; width: number; height: number };\n\n/** How a quote anchor is drawn: its exact text, or the whole block holding it. */\nexport type AnchorMode = \"text\" | \"block\";\n\nconst SOURCE_BLOCK = \"[data-source-start]\";\n\n/** The rendered source block holding `node`, if any. */\nexport function sourceBlockOf(node: Node | null): Element | null {\n const element = node instanceof Element ? node : (node?.parentElement ?? null);\n return element?.closest(SOURCE_BLOCK) ?? null;\n}\n\n/**\n * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in\n * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's\n * does. An anchor in `patchRanges` (an `r:` thread already placed in the\n * source) covers every block that overlaps its lines, or in text mode just its\n * quoted words while the quote still lies in them; an `e:` anchor finds its\n * element by its locators and takes that element's box. An anchor that no\n * longer finds its target is left out. Entries come in document order.\n */\nexport function measureAnchors({\n origin,\n markdown,\n anchors,\n mode,\n patchRanges,\n}: {\n origin: Element;\n markdown: Element;\n anchors: readonly string[];\n mode: AnchorMode;\n patchRanges?: ReadonlyMap<string, { start: number; end: number; quote?: TextQuote }>;\n}): Map<string, Box[]> {\n const base = origin.getBoundingClientRect();\n const rel = (rect: DOMRect): Box => ({\n top: rect.top - base.top,\n left: rect.left - base.left,\n width: rect.width,\n height: rect.height,\n });\n const blocks = new Map<string, Element>();\n for (const el of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n const key = blockAnchor(Number(el.dataset.sourceStart), Number(el.dataset.sourceEnd));\n if (!blocks.has(key)) blocks.set(key, el);\n }\n\n /** One box per rendered line of `block`'s text, or the block itself when it has none. */\n const blockBoxes = (block: Element): Box[] => {\n const range = document.createRange();\n range.selectNodeContents(block);\n const lines = textLines([...range.getClientRects()].filter((rect) => rect.width > 0).map(rel));\n return lines.length > 0 ? lines : [rel(block.getBoundingClientRect())];\n };\n\n // `at` is where the anchored text itself starts, so anchors sharing a block keep document order.\n const found: { anchor: string; boxes: Box[]; at: number }[] = [];\n for (const anchor of anchors) {\n if (anchor.startsWith(QUOTE_PREFIX)) {\n const range = resolveQuote(markdown, parseQuoteAnchor(anchor));\n if (!range) continue;\n const text = [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel);\n const block = sourceBlockOf(range.startContainer);\n const boxes = mode === \"text\" ? text : block ? [rel(block.getBoundingClientRect())] : [];\n if (boxes.length > 0) found.push({ anchor, boxes, at: text[0]?.top ?? boxes[0]!.top });\n continue;\n }\n if (anchor.startsWith(ELEMENT_PREFIX)) {\n const element = resolveElementAnchor(markdown, anchor)?.element;\n const box = element && rel(element.getBoundingClientRect());\n if (box) found.push({ anchor, boxes: [box], at: box.top });\n continue;\n }\n if (isPatchAnchor(anchor)) {\n const lines = patchRanges?.get(anchor);\n if (!lines) continue;\n // The patch is authoritative; its quote only sharpens the highlight while it still lies in the matched lines.\n const range = mode === \"text\" && lines.quote ? resolveQuoteInLines(markdown, lines, lines.quote) : null;\n const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];\n if (words.length > 0) {\n found.push({ anchor, boxes: words, at: words[0]!.top });\n continue;\n }\n const covered = [...markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)]\n .filter((el) => Number(el.dataset.sourceStart) <= lines.end && Number(el.dataset.sourceEnd) >= lines.start)\n .flatMap(blockBoxes);\n if (covered.length > 0) found.push({ anchor, boxes: covered, at: covered[0]!.top });\n continue;\n }\n const key = lineRangeAnchorResolver(anchor, [...blocks.keys()]);\n const block = key ? blocks.get(key) : undefined;\n if (block) {\n const boxes = blockBoxes(block);\n found.push({ anchor, boxes, at: boxes[0]!.top });\n }\n }\n return new Map(found.sort((a, b) => a.at - b.at).map(({ anchor, boxes }) => [anchor, boxes]));\n}\n\n/**\n * One box per visual line: text rects that overlap vertically merge into their\n * horizontal union, so a finding's squiggle runs under each rendered line.\n */\nexport function textLines(rects: readonly Box[]): Box[] {\n const lines: Box[] = [];\n for (const rect of [...rects].sort((a, b) => a.top - b.top || a.left - b.left)) {\n const line = lines.find((l) => rect.top < l.top + l.height && rect.top + rect.height > l.top);\n if (!line) {\n lines.push({ ...rect });\n continue;\n }\n const right = Math.max(line.left + line.width, rect.left + rect.width);\n const bottom = Math.max(line.top + line.height, rect.top + rect.height);\n line.left = Math.min(line.left, rect.left);\n line.top = Math.min(line.top, rect.top);\n line.width = right - line.left;\n line.height = bottom - line.top;\n }\n return lines;\n}\n\n/**\n * Margin layout in the style of Google Docs: each card wants the top of its\n * anchor; the focused card gets exactly that, cards above it are pushed up and\n * cards below it pushed down so none overlap.\n */\nexport function layoutCards({\n cards,\n focused,\n gap = 8,\n}: {\n /** `order` breaks ties between cards that want the same top, e.g. two quotes in one block. */\n cards: readonly { anchor: string; desired: number; order: number; height: number }[];\n focused: string | null;\n gap?: number;\n}): Map<string, number> {\n const sorted = [...cards].sort((a, b) => a.desired - b.desired || a.order - b.order);\n const tops = sorted.map((card) => card.desired);\n const pivot = sorted.findIndex((card) => card.anchor === focused);\n if (pivot >= 0) {\n for (let i = pivot - 1; i >= 0; i--) {\n tops[i] = Math.min(tops[i]!, tops[i + 1]! - gap - sorted[i]!.height);\n }\n }\n // Cards pushed above the top, and everything below the pivot, flow downward.\n for (let i = 0; i < sorted.length; i++) {\n const floor = i === 0 ? 0 : tops[i - 1]! + sorted[i - 1]!.height + gap;\n tops[i] = Math.max(tops[i]!, floor);\n }\n return new Map(sorted.map((card, i) => [card.anchor, tops[i]!]));\n}\n"],"mappings":";;;;;AAaA,IAAM,eAAe;;AAGrB,SAAgB,cAAc,MAAmC;CAE/D,QADgB,gBAAgB,UAAU,OAAQ,MAAM,iBAA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,EAAE,KAAK;CACnF,MAAM,OAAO,OAAO,KAAK,SAAS,KAAK,OAAO;CAC9C,MAAM,QAAQ,OAAO,WAAW,SAAS,KAAK,WAAW,OAAO;CAChE,IAAI,SAAS,GACX,KAAK,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK,IAAI,KAAM,MAAM,OAAO,EAAE,CAAE,MAAM;CAIvE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,IAAI,KAAM,OAAO,IAAI,EAAE,CAAE,SAAS;EACnE,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK;CACpC;CACA,OAAO,IAAI,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC,KAAK,QAAQ,KAAK,EAAG,CAAC,CAAC;AACjE"}
1
+ {"version":3,"file":"geometry.cjs","names":["resolveTableCell","blockAnchor","resolveQuote","parseQuoteAnchor","resolveElementAnchor","isPatchAnchor","elementsInLines","resolveQuoteWithin","lineRangeAnchorResolver"],"sources":["../../../src/file-findings/file-review/geometry.ts"],"sourcesContent":["import { ELEMENT_PREFIX, resolveElementAnchor } from \"../../comments/anchoring/dom-anchor\";\nimport { isPatchAnchor } from \"../../comments/anchoring/patch-anchor\";\nimport { blockAnchor, lineRangeAnchorResolver } from \"../findings-comments\";\n\nimport type { TableCell, TextQuote } from \"../../comments/annotation-types\";\nimport { QUOTE_PREFIX, elementsInLines, parseQuoteAnchor, resolveQuote, resolveQuoteWithin } from \"./quote-anchor\";\nimport { resolveTableCell } from \"./table-cell\";\n\n/** A rectangle relative to the annotated document's top-left corner. */\nexport type Box = { top: number; left: number; width: number; height: number };\n\n/** How a quote anchor is drawn: its exact text, or the whole block holding it. */\nexport type AnchorMode = \"text\" | \"block\";\n\nconst SOURCE_BLOCK = \"[data-source-start]\";\n\n/** The rendered source block holding `node`, if any. */\nexport function sourceBlockOf(node: Node | null): Element | null {\n const element = node instanceof Element ? node : (node?.parentElement ?? null);\n return element?.closest(SOURCE_BLOCK) ?? null;\n}\n\n/** The table cell `cell` names in a table covering `lines`, while it still sits on them. */\nfunction cellInLines(markdown: Element, lines: { start: number; end: number }, cell: TableCell): Element | null {\n for (const block of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n if (Number(block.dataset.sourceStart) > lines.end || Number(block.dataset.sourceEnd) < lines.start) continue;\n const found = resolveTableCell(block, cell);\n if (found && found.line >= lines.start && found.line <= lines.end) return found.cell;\n }\n return null;\n}\n\n/**\n * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in\n * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's\n * does. An anchor in `patchRanges` (an `r:` thread already placed in the\n * source) covers every block that overlaps its lines (in a table, just the rows\n * on them); in text mode, just its table cell and quoted words while they still\n * lie in those lines. An `e:` anchor finds its\n * element by its locators and takes that element's box. An anchor that no\n * longer finds its target is left out. Entries come in document order.\n */\nexport function measureAnchors({\n origin,\n markdown,\n anchors,\n mode,\n patchRanges,\n}: {\n origin: Element;\n markdown: Element;\n anchors: readonly string[];\n mode: AnchorMode;\n patchRanges?: ReadonlyMap<string, { start: number; end: number; quote?: TextQuote; cell?: TableCell }>;\n}): Map<string, Box[]> {\n const base = origin.getBoundingClientRect();\n const rel = (rect: DOMRect): Box => ({\n top: rect.top - base.top,\n left: rect.left - base.left,\n width: rect.width,\n height: rect.height,\n });\n const blocks = new Map<string, Element>();\n for (const el of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n const key = blockAnchor(Number(el.dataset.sourceStart), Number(el.dataset.sourceEnd));\n if (!blocks.has(key)) blocks.set(key, el);\n }\n\n /** One box per rendered line of `block`'s text, or the block itself when it has none. */\n const blockBoxes = (block: Element): Box[] => {\n const range = document.createRange();\n range.selectNodeContents(block);\n const lines = textLines([...range.getClientRects()].filter((rect) => rect.width > 0).map(rel));\n return lines.length > 0 ? lines : [rel(block.getBoundingClientRect())];\n };\n\n // `at` is where the anchored text itself starts, so anchors sharing a block keep document order.\n const found: { anchor: string; boxes: Box[]; at: number }[] = [];\n for (const anchor of anchors) {\n if (anchor.startsWith(QUOTE_PREFIX)) {\n const range = resolveQuote(markdown, parseQuoteAnchor(anchor));\n if (!range) continue;\n const text = [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel);\n const block = sourceBlockOf(range.startContainer);\n const boxes = mode === \"text\" ? text : block ? [rel(block.getBoundingClientRect())] : [];\n if (boxes.length > 0) found.push({ anchor, boxes, at: text[0]?.top ?? boxes[0]!.top });\n continue;\n }\n if (anchor.startsWith(ELEMENT_PREFIX)) {\n const element = resolveElementAnchor(markdown, anchor)?.element;\n const box = element && rel(element.getBoundingClientRect());\n if (box) found.push({ anchor, boxes: [box], at: box.top });\n continue;\n }\n if (isPatchAnchor(anchor)) {\n const lines = patchRanges?.get(anchor);\n if (!lines) continue;\n // The patch is authoritative; its cell and quote only sharpen the highlight while they still lie in the matched lines.\n const within = mode === \"text\" && lines.cell ? cellInLines(markdown, lines, lines.cell) : null;\n const covering = within ? [within] : elementsInLines(markdown, lines);\n const range = mode === \"text\" && lines.quote ? resolveQuoteWithin(covering, lines.quote) : null;\n const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];\n const boxes = words.length > 0 ? words : covering.flatMap(blockBoxes);\n if (boxes.length > 0) found.push({ anchor, boxes, at: boxes[0]!.top });\n continue;\n }\n const key = lineRangeAnchorResolver(anchor, [...blocks.keys()]);\n const block = key ? blocks.get(key) : undefined;\n if (block) {\n const boxes = blockBoxes(block);\n found.push({ anchor, boxes, at: boxes[0]!.top });\n }\n }\n return new Map(found.sort((a, b) => a.at - b.at).map(({ anchor, boxes }) => [anchor, boxes]));\n}\n\n/**\n * One box per visual line: text rects that overlap vertically merge into their\n * horizontal union, so a finding's squiggle runs under each rendered line.\n */\nexport function textLines(rects: readonly Box[]): Box[] {\n const lines: Box[] = [];\n for (const rect of [...rects].sort((a, b) => a.top - b.top || a.left - b.left)) {\n const line = lines.find((l) => rect.top < l.top + l.height && rect.top + rect.height > l.top);\n if (!line) {\n lines.push({ ...rect });\n continue;\n }\n const right = Math.max(line.left + line.width, rect.left + rect.width);\n const bottom = Math.max(line.top + line.height, rect.top + rect.height);\n line.left = Math.min(line.left, rect.left);\n line.top = Math.min(line.top, rect.top);\n line.width = right - line.left;\n line.height = bottom - line.top;\n }\n return lines;\n}\n\n/**\n * Margin layout in the style of Google Docs: each card wants the top of its\n * anchor; the focused card gets exactly that, cards above it are pushed up and\n * cards below it pushed down so none overlap.\n */\nexport function layoutCards({\n cards,\n focused,\n gap = 8,\n}: {\n /** `order` breaks ties between cards that want the same top, e.g. two quotes in one block. */\n cards: readonly { anchor: string; desired: number; order: number; height: number }[];\n focused: string | null;\n gap?: number;\n}): Map<string, number> {\n const sorted = [...cards].sort((a, b) => a.desired - b.desired || a.order - b.order);\n const tops = sorted.map((card) => card.desired);\n const pivot = sorted.findIndex((card) => card.anchor === focused);\n if (pivot >= 0) {\n for (let i = pivot - 1; i >= 0; i--) {\n tops[i] = Math.min(tops[i]!, tops[i + 1]! - gap - sorted[i]!.height);\n }\n }\n // Cards pushed above the top, and everything below the pivot, flow downward.\n for (let i = 0; i < sorted.length; i++) {\n const floor = i === 0 ? 0 : tops[i - 1]! + sorted[i - 1]!.height + gap;\n tops[i] = Math.max(tops[i]!, floor);\n }\n return new Map(sorted.map((card, i) => [card.anchor, tops[i]!]));\n}\n"],"mappings":";;;;;;AAcA,IAAM,eAAe;;AAGrB,SAAgB,cAAc,MAAmC;CAE/D,QADgB,gBAAgB,UAAU,OAAQ,MAAM,iBAAiB,KAAA,EACzD,QAAQ,YAAY,KAAK;AAC3C;;AAGA,SAAS,YAAY,UAAmB,OAAuC,MAAiC;CAC9G,KAAK,MAAM,SAAS,SAAS,iBAA8B,YAAY,GAAG;EACxE,IAAI,OAAO,MAAM,QAAQ,WAAW,IAAI,MAAM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M,GAAG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK;CACnF,MAAM,OAAO,OAAO,KAAK,SAAS,KAAK,OAAO;CAC9C,MAAM,QAAQ,OAAO,WAAW,SAAS,KAAK,WAAW,OAAO;CAChE,IAAI,SAAS,GACX,KAAK,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK,IAAI,KAAM,MAAM,OAAO,EAAE,CAAE,MAAM;CAIvE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,IAAI,KAAM,OAAO,IAAI,EAAE,CAAE,SAAS;EACnE,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK;CACpC;CACA,OAAO,IAAI,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC,KAAK,QAAQ,KAAK,EAAG,CAAC,CAAC;AACjE"}
@@ -1,4 +1,4 @@
1
- import { TextQuote } from '../../comments/annotation-types.js';
1
+ import { TableCell, TextQuote } from '../../comments/annotation-types.js';
2
2
  /** A rectangle relative to the annotated document's top-left corner. */
3
3
  export type Box = {
4
4
  top: number;
@@ -14,8 +14,9 @@ export declare function sourceBlockOf(node: Node | null): Element | null;
14
14
  * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in
15
15
  * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's
16
16
  * does. An anchor in `patchRanges` (an `r:` thread already placed in the
17
- * source) covers every block that overlaps its lines, or in text mode just its
18
- * quoted words while the quote still lies in them; an `e:` anchor finds its
17
+ * source) covers every block that overlaps its lines (in a table, just the rows
18
+ * on them); in text mode, just its table cell and quoted words while they still
19
+ * lie in those lines. An `e:` anchor finds its
19
20
  * element by its locators and takes that element's box. An anchor that no
20
21
  * longer finds its target is left out. Entries come in document order.
21
22
  */
@@ -28,6 +29,7 @@ export declare function measureAnchors({ origin, markdown, anchors, mode, patchR
28
29
  start: number;
29
30
  end: number;
30
31
  quote?: TextQuote;
32
+ cell?: TableCell;
31
33
  }>;
32
34
  }): Map<string, Box[]>;
33
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/file-findings/file-review/geometry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,wEAAwE;AACxE,MAAM,MAAM,GAAG,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAI1C,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAG/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtF,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAgErB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,CAgBtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC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AAC,EAAE,SAAS,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACxG,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CA4DrB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,CAgBtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,GAAO,GACR,EAAE;IACD,8FAA8F;IAC9F,KAAK,EAAE,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAetB"}
@@ -1,19 +1,30 @@
1
1
  import { resolveElementAnchor } from "../../comments/anchoring/dom-anchor.js";
2
2
  import { isPatchAnchor } from "../../comments/anchoring/patch-anchor.js";
3
3
  import { blockAnchor, lineRangeAnchorResolver } from "../findings-comments.js";
4
- import { parseQuoteAnchor, resolveQuote, resolveQuoteInLines } from "./quote-anchor.js";
4
+ import { elementsInLines, parseQuoteAnchor, resolveQuote, resolveQuoteWithin } from "./quote-anchor.js";
5
+ import { resolveTableCell } from "./table-cell.js";
5
6
  // src/file-findings/file-review/geometry.ts
6
7
  var SOURCE_BLOCK = "[data-source-start]";
7
8
  /** The rendered source block holding `node`, if any. */
8
9
  function sourceBlockOf(node) {
9
10
  return (node instanceof Element ? node : node?.parentElement ?? null)?.closest(SOURCE_BLOCK) ?? null;
10
11
  }
12
+ /** The table cell `cell` names in a table covering `lines`, while it still sits on them. */
13
+ function cellInLines(markdown, lines, cell) {
14
+ for (const block of markdown.querySelectorAll(SOURCE_BLOCK)) {
15
+ if (Number(block.dataset.sourceStart) > lines.end || Number(block.dataset.sourceEnd) < lines.start) continue;
16
+ const found = resolveTableCell(block, cell);
17
+ if (found && found.line >= lines.start && found.line <= lines.end) return found.cell;
18
+ }
19
+ return null;
20
+ }
11
21
  /**
12
22
  * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in
13
23
  * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's
14
24
  * does. An anchor in `patchRanges` (an `r:` thread already placed in the
15
- * source) covers every block that overlaps its lines, or in text mode just its
16
- * quoted words while the quote still lies in them; an `e:` anchor finds its
25
+ * source) covers every block that overlaps its lines (in a table, just the rows
26
+ * on them); in text mode, just its table cell and quoted words while they still
27
+ * lie in those lines. An `e:` anchor finds its
17
28
  * element by its locators and takes that element's box. An anchor that no
18
29
  * longer finds its target is left out. Entries come in document order.
19
30
  */
@@ -65,21 +76,15 @@ function measureAnchors({ origin, markdown, anchors, mode, patchRanges }) {
65
76
  if (isPatchAnchor(anchor)) {
66
77
  const lines = patchRanges?.get(anchor);
67
78
  if (!lines) continue;
68
- const range = mode === "text" && lines.quote ? resolveQuoteInLines(markdown, lines, lines.quote) : null;
79
+ const within = mode === "text" && lines.cell ? cellInLines(markdown, lines, lines.cell) : null;
80
+ const covering = within ? [within] : elementsInLines(markdown, lines);
81
+ const range = mode === "text" && lines.quote ? resolveQuoteWithin(covering, lines.quote) : null;
69
82
  const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];
70
- if (words.length > 0) {
71
- found.push({
72
- anchor,
73
- boxes: words,
74
- at: words[0].top
75
- });
76
- continue;
77
- }
78
- const covered = [...markdown.querySelectorAll(SOURCE_BLOCK)].filter((el) => Number(el.dataset.sourceStart) <= lines.end && Number(el.dataset.sourceEnd) >= lines.start).flatMap(blockBoxes);
79
- if (covered.length > 0) found.push({
83
+ const boxes = words.length > 0 ? words : covering.flatMap(blockBoxes);
84
+ if (boxes.length > 0) found.push({
80
85
  anchor,
81
- boxes: covered,
82
- at: covered[0].top
86
+ boxes,
87
+ at: boxes[0].top
83
88
  });
84
89
  continue;
85
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.js","names":[],"sources":["../../../src/file-findings/file-review/geometry.ts"],"sourcesContent":["import { ELEMENT_PREFIX, resolveElementAnchor } from \"../../comments/anchoring/dom-anchor\";\nimport { isPatchAnchor } from \"../../comments/anchoring/patch-anchor\";\nimport { blockAnchor, lineRangeAnchorResolver } from \"../findings-comments\";\n\nimport type { TextQuote } from \"../../comments/annotation-types\";\nimport { QUOTE_PREFIX, parseQuoteAnchor, resolveQuote, resolveQuoteInLines } from \"./quote-anchor\";\n\n/** A rectangle relative to the annotated document's top-left corner. */\nexport type Box = { top: number; left: number; width: number; height: number };\n\n/** How a quote anchor is drawn: its exact text, or the whole block holding it. */\nexport type AnchorMode = \"text\" | \"block\";\n\nconst SOURCE_BLOCK = \"[data-source-start]\";\n\n/** The rendered source block holding `node`, if any. */\nexport function sourceBlockOf(node: Node | null): Element | null {\n const element = node instanceof Element ? node : (node?.parentElement ?? null);\n return element?.closest(SOURCE_BLOCK) ?? null;\n}\n\n/**\n * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in\n * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's\n * does. An anchor in `patchRanges` (an `r:` thread already placed in the\n * source) covers every block that overlaps its lines, or in text mode just its\n * quoted words while the quote still lies in them; an `e:` anchor finds its\n * element by its locators and takes that element's box. An anchor that no\n * longer finds its target is left out. Entries come in document order.\n */\nexport function measureAnchors({\n origin,\n markdown,\n anchors,\n mode,\n patchRanges,\n}: {\n origin: Element;\n markdown: Element;\n anchors: readonly string[];\n mode: AnchorMode;\n patchRanges?: ReadonlyMap<string, { start: number; end: number; quote?: TextQuote }>;\n}): Map<string, Box[]> {\n const base = origin.getBoundingClientRect();\n const rel = (rect: DOMRect): Box => ({\n top: rect.top - base.top,\n left: rect.left - base.left,\n width: rect.width,\n height: rect.height,\n });\n const blocks = new Map<string, Element>();\n for (const el of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n const key = blockAnchor(Number(el.dataset.sourceStart), Number(el.dataset.sourceEnd));\n if (!blocks.has(key)) blocks.set(key, el);\n }\n\n /** One box per rendered line of `block`'s text, or the block itself when it has none. */\n const blockBoxes = (block: Element): Box[] => {\n const range = document.createRange();\n range.selectNodeContents(block);\n const lines = textLines([...range.getClientRects()].filter((rect) => rect.width > 0).map(rel));\n return lines.length > 0 ? lines : [rel(block.getBoundingClientRect())];\n };\n\n // `at` is where the anchored text itself starts, so anchors sharing a block keep document order.\n const found: { anchor: string; boxes: Box[]; at: number }[] = [];\n for (const anchor of anchors) {\n if (anchor.startsWith(QUOTE_PREFIX)) {\n const range = resolveQuote(markdown, parseQuoteAnchor(anchor));\n if (!range) continue;\n const text = [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel);\n const block = sourceBlockOf(range.startContainer);\n const boxes = mode === \"text\" ? text : block ? [rel(block.getBoundingClientRect())] : [];\n if (boxes.length > 0) found.push({ anchor, boxes, at: text[0]?.top ?? boxes[0]!.top });\n continue;\n }\n if (anchor.startsWith(ELEMENT_PREFIX)) {\n const element = resolveElementAnchor(markdown, anchor)?.element;\n const box = element && rel(element.getBoundingClientRect());\n if (box) found.push({ anchor, boxes: [box], at: box.top });\n continue;\n }\n if (isPatchAnchor(anchor)) {\n const lines = patchRanges?.get(anchor);\n if (!lines) continue;\n // The patch is authoritative; its quote only sharpens the highlight while it still lies in the matched lines.\n const range = mode === \"text\" && lines.quote ? resolveQuoteInLines(markdown, lines, lines.quote) : null;\n const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];\n if (words.length > 0) {\n found.push({ anchor, boxes: words, at: words[0]!.top });\n continue;\n }\n const covered = [...markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)]\n .filter((el) => Number(el.dataset.sourceStart) <= lines.end && Number(el.dataset.sourceEnd) >= lines.start)\n .flatMap(blockBoxes);\n if (covered.length > 0) found.push({ anchor, boxes: covered, at: covered[0]!.top });\n continue;\n }\n const key = lineRangeAnchorResolver(anchor, [...blocks.keys()]);\n const block = key ? blocks.get(key) : undefined;\n if (block) {\n const boxes = blockBoxes(block);\n found.push({ anchor, boxes, at: boxes[0]!.top });\n }\n }\n return new Map(found.sort((a, b) => a.at - b.at).map(({ anchor, boxes }) => [anchor, boxes]));\n}\n\n/**\n * One box per visual line: text rects that overlap vertically merge into their\n * horizontal union, so a finding's squiggle runs under each rendered line.\n */\nexport function textLines(rects: readonly Box[]): Box[] {\n const lines: Box[] = [];\n for (const rect of [...rects].sort((a, b) => a.top - b.top || a.left - b.left)) {\n const line = lines.find((l) => rect.top < l.top + l.height && rect.top + rect.height > l.top);\n if (!line) {\n lines.push({ ...rect });\n continue;\n }\n const right = Math.max(line.left + line.width, rect.left + rect.width);\n const bottom = Math.max(line.top + line.height, rect.top + rect.height);\n line.left = Math.min(line.left, rect.left);\n line.top = Math.min(line.top, rect.top);\n line.width = right - line.left;\n line.height = bottom - line.top;\n }\n return lines;\n}\n\n/**\n * Margin layout in the style of Google Docs: each card wants the top of its\n * anchor; the focused card gets exactly that, cards above it are pushed up and\n * cards below it pushed down so none overlap.\n */\nexport function layoutCards({\n cards,\n focused,\n gap = 8,\n}: {\n /** `order` breaks ties between cards that want the same top, e.g. two quotes in one block. */\n cards: readonly { anchor: string; desired: number; order: number; height: number }[];\n focused: string | null;\n gap?: number;\n}): Map<string, number> {\n const sorted = [...cards].sort((a, b) => a.desired - b.desired || a.order - b.order);\n const tops = sorted.map((card) => card.desired);\n const pivot = sorted.findIndex((card) => card.anchor === focused);\n if (pivot >= 0) {\n for (let i = pivot - 1; i >= 0; i--) {\n tops[i] = Math.min(tops[i]!, tops[i + 1]! - gap - sorted[i]!.height);\n }\n }\n // Cards pushed above the top, and everything below the pivot, flow downward.\n for (let i = 0; i < sorted.length; i++) {\n const floor = i === 0 ? 0 : tops[i - 1]! + sorted[i - 1]!.height +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ACA,SACA,MAAM,KAMgB;CACtB,MAAM,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK;CACnF,MAAM,OAAO,OAAO,KAAK,SAAS,KAAK,OAAO;CAC9C,MAAM,QAAQ,OAAO,WAAW,SAAS,KAAK,WAAW,OAAO;CAChE,IAAI,SAAS,GACX,KAAK,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK,IAAI,KAAM,MAAM,OAAO,EAAE,CAAE,MAAM;CAIvE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,IAAI,KAAM,OAAO,IAAI,EAAE,CAAE,SAAS;EACnE,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK;CACpC;CACA,OAAO,IAAI,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC,KAAK,QAAQ,KAAK,EAAG,CAAC,CAAC;AACjE"}
1
+ {"version":3,"file":"geometry.js","names":[],"sources":["../../../src/file-findings/file-review/geometry.ts"],"sourcesContent":["import { ELEMENT_PREFIX, resolveElementAnchor } from \"../../comments/anchoring/dom-anchor\";\nimport { isPatchAnchor } from \"../../comments/anchoring/patch-anchor\";\nimport { blockAnchor, lineRangeAnchorResolver } from \"../findings-comments\";\n\nimport type { TableCell, TextQuote } from \"../../comments/annotation-types\";\nimport { QUOTE_PREFIX, elementsInLines, parseQuoteAnchor, resolveQuote, resolveQuoteWithin } from \"./quote-anchor\";\nimport { resolveTableCell } from \"./table-cell\";\n\n/** A rectangle relative to the annotated document's top-left corner. */\nexport type Box = { top: number; left: number; width: number; height: number };\n\n/** How a quote anchor is drawn: its exact text, or the whole block holding it. */\nexport type AnchorMode = \"text\" | \"block\";\n\nconst SOURCE_BLOCK = \"[data-source-start]\";\n\n/** The rendered source block holding `node`, if any. */\nexport function sourceBlockOf(node: Node | null): Element | null {\n const element = node instanceof Element ? node : (node?.parentElement ?? null);\n return element?.closest(SOURCE_BLOCK) ?? null;\n}\n\n/** The table cell `cell` names in a table covering `lines`, while it still sits on them. */\nfunction cellInLines(markdown: Element, lines: { start: number; end: number }, cell: TableCell): Element | null {\n for (const block of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n if (Number(block.dataset.sourceStart) > lines.end || Number(block.dataset.sourceEnd) < lines.start) continue;\n const found = resolveTableCell(block, cell);\n if (found && found.line >= lines.start && found.line <= lines.end) return found.cell;\n }\n return null;\n}\n\n/**\n * Boxes for each anchor, relative to `origin`. A `q:` anchor finds its quote in\n * `markdown` through its section and context words; a `line:N` anchor resolves to its block like a line finding's\n * does. An anchor in `patchRanges` (an `r:` thread already placed in the\n * source) covers every block that overlaps its lines (in a table, just the rows\n * on them); in text mode, just its table cell and quoted words while they still\n * lie in those lines. An `e:` anchor finds its\n * element by its locators and takes that element's box. An anchor that no\n * longer finds its target is left out. Entries come in document order.\n */\nexport function measureAnchors({\n origin,\n markdown,\n anchors,\n mode,\n patchRanges,\n}: {\n origin: Element;\n markdown: Element;\n anchors: readonly string[];\n mode: AnchorMode;\n patchRanges?: ReadonlyMap<string, { start: number; end: number; quote?: TextQuote; cell?: TableCell }>;\n}): Map<string, Box[]> {\n const base = origin.getBoundingClientRect();\n const rel = (rect: DOMRect): Box => ({\n top: rect.top - base.top,\n left: rect.left - base.left,\n width: rect.width,\n height: rect.height,\n });\n const blocks = new Map<string, Element>();\n for (const el of markdown.querySelectorAll<HTMLElement>(SOURCE_BLOCK)) {\n const key = blockAnchor(Number(el.dataset.sourceStart), Number(el.dataset.sourceEnd));\n if (!blocks.has(key)) blocks.set(key, el);\n }\n\n /** One box per rendered line of `block`'s text, or the block itself when it has none. */\n const blockBoxes = (block: Element): Box[] => {\n const range = document.createRange();\n range.selectNodeContents(block);\n const lines = textLines([...range.getClientRects()].filter((rect) => rect.width > 0).map(rel));\n return lines.length > 0 ? lines : [rel(block.getBoundingClientRect())];\n };\n\n // `at` is where the anchored text itself starts, so anchors sharing a block keep document order.\n const found: { anchor: string; boxes: Box[]; at: number }[] = [];\n for (const anchor of anchors) {\n if (anchor.startsWith(QUOTE_PREFIX)) {\n const range = resolveQuote(markdown, parseQuoteAnchor(anchor));\n if (!range) continue;\n const text = [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel);\n const block = sourceBlockOf(range.startContainer);\n const boxes = mode === \"text\" ? text : block ? [rel(block.getBoundingClientRect())] : [];\n if (boxes.length > 0) found.push({ anchor, boxes, at: text[0]?.top ?? boxes[0]!.top });\n continue;\n }\n if (anchor.startsWith(ELEMENT_PREFIX)) {\n const element = resolveElementAnchor(markdown, anchor)?.element;\n const box = element && rel(element.getBoundingClientRect());\n if (box) found.push({ anchor, boxes: [box], at: box.top });\n continue;\n }\n if (isPatchAnchor(anchor)) {\n const lines = patchRanges?.get(anchor);\n if (!lines) continue;\n // The patch is authoritative; its cell and quote only sharpen the highlight while they still lie in the matched lines.\n const within = mode === \"text\" && lines.cell ? cellInLines(markdown, lines, lines.cell) : null;\n const covering = within ? [within] : elementsInLines(markdown, lines);\n const range = mode === \"text\" && lines.quote ? resolveQuoteWithin(covering, lines.quote) : null;\n const words = range ? [...range.getClientRects()].filter((rect) => rect.width > 0).map(rel) : [];\n const boxes = words.length > 0 ? words : covering.flatMap(blockBoxes);\n if (boxes.length > 0) found.push({ anchor, boxes, at: boxes[0]!.top });\n continue;\n }\n const key = lineRangeAnchorResolver(anchor, [...blocks.keys()]);\n const block = key ? blocks.get(key) : undefined;\n if (block) {\n const boxes = blockBoxes(block);\n found.push({ anchor, boxes, at: boxes[0]!.top });\n }\n }\n return new Map(found.sort((a, b) => a.at - b.at).map(({ anchor, boxes }) => [anchor, boxes]));\n}\n\n/**\n * One box per visual line: text rects that overlap vertically merge into their\n * horizontal union, so a finding's squiggle runs under each rendered line.\n */\nexport function textLines(rects: readonly Box[]): Box[] {\n const lines: Box[] = [];\n for (const rect of [...rects].sort((a, b) => a.top - b.top || a.left - b.left)) {\n const line = lines.find((l) => rect.top < l.top + l.height && rect.top + rect.height > l.top);\n if (!line) {\n lines.push({ ...rect });\n continue;\n }\n const right = Math.max(line.left + line.width, rect.left + rect.width);\n const bottom = Math.max(line.top + line.height, rect.top + rect.height);\n line.left = Math.min(line.left, rect.left);\n line.top = Math.min(line.top, rect.top);\n line.width = right - line.left;\n line.height = bottom - line.top;\n }\n return lines;\n}\n\n/**\n * Margin layout in the style of Google Docs: each card wants the top of its\n * anchor; the focused card gets exactly that, cards above it are pushed up and\n * cards below it pushed down so none overlap.\n */\nexport function layoutCards({\n cards,\n focused,\n gap = 8,\n}: {\n /** `order` breaks ties between cards that want the same top, e.g. two quotes in one block. */\n cards: readonly { anchor: string; desired: number; order: number; height: number }[];\n focused: string | null;\n gap?: number;\n}): Map<string, number> {\n const sorted = [...cards].sort((a, b) => a.desired - b.desired || a.order - b.order);\n const tops = sorted.map((card) => card.desired);\n const pivot = sorted.findIndex((card) => card.anchor === focused);\n if (pivot >= 0) {\n for (let i = pivot - 1; i >= 0; i--) {\n tops[i] = Math.min(tops[i]!, tops[i + 1]! - gap - sorted[i]!.height);\n }\n }\n // Cards pushed above the top, and everything below the pivot, flow downward.\n for (let i = 0; i < sorted.length; i++) {\n const floor = i === 0 ? 0 : tops[i - 1]! + sorted[i - 1]!.height + gap;\n tops[i] = Math.max(tops[i]!, floor);\n }\n return new Map(sorted.map((card, i) => [card.anchor, tops[i]!]));\n}\n"],"mappings":";;;;;;AAcA,IAAM,eAAe;;AAGrB,SAAgB,cAAc,MAAmC;CAE/D,QADgB,gBAAgB,UAAU,OAAQ,MAAM,iBAAiB,KAAA,EACzD,QAAQ,YAAY,KAAK;AAC3C;;AAGA,SAAS,YAAY,UAAmB,OAAuC,MAAiC;CAC9G,KAAK,MAAM,SAAS,SAAS,iBAA8B,YAAY,GAAG;EACxE,IAAI,OAAO,MAAM,QAA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;CACnF,MAAM,OAAO,OAAO,KAAK,SAAS,KAAK,OAAO;CAC9C,MAAM,QAAQ,OAAO,WAAW,SAAS,KAAK,WAAW,OAAO;CAChE,IAAI,SAAS,GACX,KAAK,IAAI,IAAI,QAAQ,GAAG,KAAK,GAAG,KAC9B,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK,IAAI,KAAM,MAAM,OAAO,EAAE,CAAE,MAAM;CAIvE,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,IAAI,KAAM,OAAO,IAAI,EAAE,CAAE,SAAS;EACnE,KAAK,KAAK,KAAK,IAAI,KAAK,IAAK,KAAK;CACpC;CACA,OAAO,IAAI,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC,KAAK,QAAQ,KAAK,EAAG,CAAC,CAAC;AACjE"}
@@ -1,5 +1,6 @@
1
1
  const require_patch_anchor = require("../../comments/anchoring/patch-anchor.cjs");
2
2
  const require_quote_anchor = require("./quote-anchor.cjs");
3
+ const require_table_cell = require("./table-cell.cjs");
3
4
  // src/file-findings/file-review/patch-comments.ts
4
5
  /** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */
5
6
  function placePatches(raw, anchors) {
@@ -12,21 +13,22 @@ function placePatches(raw, anchors) {
12
13
  }];
13
14
  }));
14
15
  }
16
+ /** Only the extras that are set, so none is spread as an undefined key. */
17
+ var patchExtras = ({ quote, cell }) => ({
18
+ ...quote ? { quote } : {},
19
+ ...cell ? { cell } : {}
20
+ });
15
21
  /**
16
- * The current lines of every placement the file still contains exactly once.
17
- * `quotes` are the selected words each thread was written on, kept by the host
18
- * beside the patch (never in the anchor), keyed by anchor.
22
+ * The current lines of every placement the file still contains exactly once,
23
+ * with the `extras` each thread was written on, keyed by anchor.
19
24
  */
20
- function patchLineRanges(placements, quotes = /* @__PURE__ */ new Map()) {
25
+ function patchLineRanges(placements, extras = /* @__PURE__ */ new Map()) {
21
26
  const ranges = /* @__PURE__ */ new Map();
22
- for (const { anchor, match } of placements.values()) {
23
- const quote = quotes.get(anchor);
24
- if (match.state === "matched") ranges.set(anchor, {
25
- start: match.startLine,
26
- end: match.endLine,
27
- ...quote ? { quote } : {}
28
- });
29
- }
27
+ for (const { anchor, match } of placements.values()) if (match.state === "matched") ranges.set(anchor, {
28
+ start: match.startLine,
29
+ end: match.endLine,
30
+ ...patchExtras(extras.get(anchor) ?? {})
31
+ });
30
32
  return ranges;
31
33
  }
32
34
  /** Source highlights for the placed patches: one whole-line span per covered line. */
@@ -54,17 +56,22 @@ function patchLabel({ patch, match }) {
54
56
  * The anchor and label for a selection of `raw`'s lines. A `quote` of the
55
57
  * selected words is returned beside the anchor (the host stores it next to the
56
58
  * patch, never inside it) only when it lies inside those lines, which the
57
- * server requires; otherwise the patch alone anchors the thread.
59
+ * server requires; otherwise the patch alone anchors the thread. A `cell` (the
60
+ * table cell the selection lies in) needs `lines` to be its row's one line, and
61
+ * names the thread.
58
62
  */
59
- function patchDraft({ raw, lines, quote }) {
63
+ function patchDraft({ raw, lines, quote, cell }) {
64
+ if (cell && lines.startLine !== lines.endLine) throw new Error(`a table cell lies on one line, not lines ${lines.startLine}-${lines.endLine}`);
60
65
  const patch = require_patch_anchor.capturePatch(raw, lines.startLine, lines.endLine);
61
66
  return {
62
67
  anchor: require_patch_anchor.patchAnchor(patch),
63
- label: require_patch_anchor.describePatch(patch),
64
- ...quote && require_quote_anchor.quoteLiesInLines(quote, patch.lines) ? { quote } : {}
68
+ label: cell ? require_table_cell.describeCell(cell) : require_patch_anchor.describePatch(patch),
69
+ ...quote && require_quote_anchor.quoteLiesInLines(quote, patch.lines) ? { quote } : {},
70
+ ...cell ? { cell } : {}
65
71
  };
66
72
  }
67
73
  exports.patchDraft = patchDraft;
74
+ exports.patchExtras = patchExtras;
68
75
  exports.patchLabel = patchLabel;
69
76
  exports.patchLineRanges = patchLineRanges;
70
77
  exports.patchSourceMarks = patchSourceMarks;
@@ -1 +1 @@
1
- {"version":3,"file":"patch-comments.cjs","names":["isPatchAnchor","parsePatchAnchor","matchPatch","describePatch","capturePatch","patchAnchor","quoteLiesInLines"],"sources":["../../../src/file-findings/file-review/patch-comments.ts"],"sourcesContent":["import {\n capturePatch,\n describePatch,\n isPatchAnchor,\n matchPatch,\n parsePatchAnchor,\n patchAnchor,\n type PatchMatch,\n} from \"../../comments/anchoring/patch-anchor\";\nimport type { PatchAnchor, TextQuote } from \"../../comments/annotation-types\";\nimport { quoteLiesInLines } from \"./quote-anchor\";\nimport type { LineRange } from \"./selection-lines\";\nimport type { SourceMark } from \"./source-marks\";\n\n/** An `r:` thread's patch and where it sits in the file's current text. */\nexport type PatchPlacement = { anchor: string; patch: PatchAnchor; match: PatchMatch };\n\n/** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */\nexport function placePatches(raw: string, anchors: readonly string[]): Map<string, PatchPlacement> {\n return new Map(\n anchors.filter(isPatchAnchor).map((anchor) => {\n const patch = parsePatchAnchor(anchor);\n return [anchor, { anchor, patch, match: matchPatch(raw, patch) }];\n }),\n );\n}\n\n/** The current lines of a placed patch, with the quote it was made on, if any. */\nexport type PatchLineRange = { start: number; end: number; quote?: TextQuote };\n\n/**\n * The current lines of every placement the file still contains exactly once.\n * `quotes` are the selected words each thread was written on, kept by the host\n * beside the patch (never in the anchor), keyed by anchor.\n */\nexport function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, quotes: ReadonlyMap<string, TextQuote> = new Map()): Map<string, PatchLineRange> {\n const ranges = new Map<string, PatchLineRange>();\n for (const { anchor, match } of placements.values()) {\n const quote = quotes.get(anchor);\n if (match.state === \"matched\") ranges.set(anchor, { start: match.startLine, end: match.endLine, ...(quote ? { quote } : {}) });\n }\n return ranges;\n}\n\n/** Source highlights for the placed patches: one whole-line span per covered line. */\nexport function patchSourceMarks(raw: string, placements: ReadonlyMap<string, PatchPlacement>): SourceMark[] {\n const lines = raw.split(\"\\n\");\n return [...patchLineRanges(placements)].map(([anchor, { start, end }]) => ({\n anchor,\n spans: Array.from({ length: end - start + 1 }, (_, i) => ({ line: start + i, start: 0, end: lines[start + i - 1]?.length ?? 0 })),\n }));\n}\n\n/** The lines a placed thread covers now; for one that cannot be placed, why, and the lines it was captured on. */\nexport function patchLabel({ patch, match }: PatchPlacement): string {\n if (match.state === \"matched\") return describePatch({ ...patch, startLine: match.startLine, endLine: match.endLine });\n return `${match.state === \"outdated\" ? \"Outdated\" : \"Ambiguous\"} · ${describePatch(patch)}`;\n}\n\n/**\n * The anchor and label for a selection of `raw`'s lines. A `quote` of the\n * selected words is returned beside the anchor (the host stores it next to the\n * patch, never inside it) only when it lies inside those lines, which the\n * server requires; otherwise the patch alone anchors the thread.\n */\nexport function patchDraft({ raw, lines, quote }: { raw: string; lines: LineRange; quote?: TextQuote | null | undefined }): { anchor: string; label: string; quote?: TextQuote } {\n const patch = capturePatch(raw, lines.startLine, lines.endLine);\n return { anchor: patchAnchor(patch), label: describePatch(patch), ...(quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {}) };\n}\n"],"mappings":";;;;AAkBA,SAAgB,aAAa,KAAa,SAAyD;CACjG,OAAO,IAAI,IACT,QAAQ,OAAOA,qBAAAA,aAAa,CAAC,CAAC,KAAK,WAAW;EAC5C,MAAM,QAAQC,qBAAAA,iBAAiB,MAAM;EACrC,OAAO,CAAC,QAAQ;GAAE;GAAQ;GAAO,OAAOC,qBAAAA,WAAW,KAAK,KAAK;EAAE,CAAC;CAClE,CAAC,CACH;AACF;;;;;;AAUA,SAAgB,gBAAgB,YAAiD,yBAAyC,IAAI,IAAI,GAAgC;CAChK,MAAM,yBAAS,IAAI,IAA4B;CAC/C,KAAK,MAAM,EAAE,QAAQ,WAAW,WAAW,OAAO,GAAG;EACnD,MAAM,QAAQ,OAAO,IAAI,MAAM;EAC/B,IAAI,MAAM,UAAU,WAAW,OAAO,IAAI,QAAQ;GAAE,OAAO,MAAM;GAAW,KAAK,MAAM;GAAS,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EAAG,CAAC;CAC/H;CACA,OAAO;AACT;;AAGA,SAAgB,iBAAiB,KAAa,YAA+D;CAC3G,MAAM,QAAQ,IAAI,MAAM,IAAI;CAC5B,OAAO,CAAC,GAAG,gBAAgB,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,YAAY;EACzE;EACA,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,QAAQ,EAAE,IAAI,GAAG,OAAO;GAAE,MAAM,QAAQ;GAAG,OAAO;GAAG,KAAK,MAAM,QAAQ,IAAI,EAAE,EAAE,UAAU;EAAE,EAAE;CAClI,EAAE;AACJ;;AAGA,SAAgB,WAAW,EAAE,OAAO,SAAiC;CACnE,IAAI,MAAM,UAAU,WAAW,OAAOC,qBAAAA,cAAc;EAAE,GAAG;EAAO,WAAW,MAAM;EAAW,SAAS,MAAM;CAAQ,CAAC;CACpH,OAAO,GAAG,MAAM,UAAU,aAAa,aAAa,YAAY,KAAKA,qBAAAA,cAAc,KAAK;AAC1F;;;;;;;AAQA,SAAgB,WAAW,EAAE,KAAK,OAAO,SAAwI;CAC/K,MAAM,QAAQC,qBAAAA,aAAa,KAAK,MAAM,WAAW,MAAM,OAAO;CAC9D,OAAO;EAAE,QAAQC,qBAAAA,YAAY,KAAK;EAAG,OAAOF,qBAAAA,cAAc,KAAK;EAAG,GAAI,SAASG,qBAAAA,iBAAiB,OAAO,MAAM,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;CAAG;AACxI"}
1
+ {"version":3,"file":"patch-comments.cjs","names":["isPatchAnchor","parsePatchAnchor","matchPatch","describePatch","capturePatch","patchAnchor","describeCell","quoteLiesInLines"],"sources":["../../../src/file-findings/file-review/patch-comments.ts"],"sourcesContent":["import {\n capturePatch,\n describePatch,\n isPatchAnchor,\n matchPatch,\n parsePatchAnchor,\n patchAnchor,\n type PatchMatch,\n} from \"../../comments/anchoring/patch-anchor\";\nimport type { PatchAnchor, TableCell, TextQuote } from \"../../comments/annotation-types\";\nimport { quoteLiesInLines } from \"./quote-anchor\";\nimport { describeCell } from \"./table-cell\";\nimport type { LineRange } from \"./selection-lines\";\nimport type { SourceMark } from \"./source-marks\";\n\n/** An `r:` thread's patch and where it sits in the file's current text. */\nexport type PatchPlacement = { anchor: string; patch: PatchAnchor; match: PatchMatch };\n\n/** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */\nexport function placePatches(raw: string, anchors: readonly string[]): Map<string, PatchPlacement> {\n return new Map(\n anchors.filter(isPatchAnchor).map((anchor) => {\n const patch = parsePatchAnchor(anchor);\n return [anchor, { anchor, patch, match: matchPatch(raw, patch) }];\n }),\n );\n}\n\n/** What a host keeps beside a patch (never inside it) to sharpen its highlight: the selected words, and the table cell they lie in. */\nexport type PatchExtras = { quote?: TextQuote; cell?: TableCell };\n\n/** The current lines of a placed patch, with the quote and cell it was made on, if any. */\nexport type PatchLineRange = { start: number; end: number } & PatchExtras;\n\n/** Only the extras that are set, so none is spread as an undefined key. */\nexport const patchExtras = ({ quote, cell }: { quote?: TextQuote | undefined; cell?: TableCell | undefined }): PatchExtras => ({ ...(quote ? { quote } : {}), ...(cell ? { cell } : {}) });\n\n/**\n * The current lines of every placement the file still contains exactly once,\n * with the `extras` each thread was written on, keyed by anchor.\n */\nexport function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, extras: ReadonlyMap<string, PatchExtras> = new Map()): Map<string, PatchLineRange> {\n const ranges = new Map<string, PatchLineRange>();\n for (const { anchor, match } of placements.values()) {\n if (match.state === \"matched\") ranges.set(anchor, { start: match.startLine, end: match.endLine, ...patchExtras(extras.get(anchor) ?? {}) });\n }\n return ranges;\n}\n\n/** Source highlights for the placed patches: one whole-line span per covered line. */\nexport function patchSourceMarks(raw: string, placements: ReadonlyMap<string, PatchPlacement>): SourceMark[] {\n const lines = raw.split(\"\\n\");\n return [...patchLineRanges(placements)].map(([anchor, { start, end }]) => ({\n anchor,\n spans: Array.from({ length: end - start + 1 }, (_, i) => ({ line: start + i, start: 0, end: lines[start + i - 1]?.length ?? 0 })),\n }));\n}\n\n/** The lines a placed thread covers now; for one that cannot be placed, why, and the lines it was captured on. */\nexport function patchLabel({ patch, match }: PatchPlacement): string {\n if (match.state === \"matched\") return describePatch({ ...patch, startLine: match.startLine, endLine: match.endLine });\n return `${match.state === \"outdated\" ? \"Outdated\" : \"Ambiguous\"} · ${describePatch(patch)}`;\n}\n\n/**\n * The anchor and label for a selection of `raw`'s lines. A `quote` of the\n * selected words is returned beside the anchor (the host stores it next to the\n * patch, never inside it) only when it lies inside those lines, which the\n * server requires; otherwise the patch alone anchors the thread. A `cell` (the\n * table cell the selection lies in) needs `lines` to be its row's one line, and\n * names the thread.\n */\nexport function patchDraft({\n raw,\n lines,\n quote,\n cell,\n}: {\n raw: string;\n lines: LineRange;\n quote?: TextQuote | null | undefined;\n cell?: TableCell | null | undefined;\n}): { anchor: string; label: string } & PatchExtras {\n if (cell && lines.startLine !== lines.endLine) throw new Error(`a table cell lies on one line, not lines ${lines.startLine}-${lines.endLine}`);\n const patch = capturePatch(raw, lines.startLine, lines.endLine);\n return {\n anchor: patchAnchor(patch),\n label: cell ? describeCell(cell) : describePatch(patch),\n ...(quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {}),\n ...(cell ? { cell } : {}),\n };\n}\n"],"mappings":";;;;;AAmBA,SAAgB,aAAa,KAAa,SAAyD;CACjG,OAAO,IAAI,IACT,QAAQ,OAAOA,qBAAAA,aAAa,CAAC,CAAC,KAAK,WAAW;EAC5C,MAAM,QAAQC,qBAAAA,iBAAiB,MAAM;EACrC,OAAO,CAAC,QAAQ;GAAE;GAAQ;GAAO,OAAOC,qBAAAA,WAAW,KAAK,KAAK;EAAE,CAAC;CAClE,CAAC,CACH;AACF;;AASA,IAAa,eAAe,EAAE,OAAO,YAA0F;CAAE,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAAI,GAAI,OAAO,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AA,aAAa,IAAI,IAAIH,qBAAAA,cAAc,KAAK;EACtD,GAAI,SAASI,qBAAAA,iBAAiB,OAAO,MAAM,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;EACjE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;CACzB;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { PatchMatch } from '../../comments/anchoring/patch-anchor.js';
2
- import { PatchAnchor, TextQuote } from '../../comments/annotation-types.js';
2
+ import { PatchAnchor, TableCell, TextQuote } from '../../comments/annotation-types.js';
3
3
  import { LineRange } from './selection-lines.js';
4
4
  import { SourceMark } from './source-marks.js';
5
5
  /** An `r:` thread's patch and where it sits in the file's current text. */
@@ -10,18 +10,26 @@ export type PatchPlacement = {
10
10
  };
11
11
  /** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */
12
12
  export declare function placePatches(raw: string, anchors: readonly string[]): Map<string, PatchPlacement>;
13
- /** The current lines of a placed patch, with the quote it was made on, if any. */
13
+ /** What a host keeps beside a patch (never inside it) to sharpen its highlight: the selected words, and the table cell they lie in. */
14
+ export type PatchExtras = {
15
+ quote?: TextQuote;
16
+ cell?: TableCell;
17
+ };
18
+ /** The current lines of a placed patch, with the quote and cell it was made on, if any. */
14
19
  export type PatchLineRange = {
15
20
  start: number;
16
21
  end: number;
17
- quote?: TextQuote;
18
- };
22
+ } & PatchExtras;
23
+ /** Only the extras that are set, so none is spread as an undefined key. */
24
+ export declare const patchExtras: ({ quote, cell }: {
25
+ quote?: TextQuote | undefined;
26
+ cell?: TableCell | undefined;
27
+ }) => PatchExtras;
19
28
  /**
20
- * The current lines of every placement the file still contains exactly once.
21
- * `quotes` are the selected words each thread was written on, kept by the host
22
- * beside the patch (never in the anchor), keyed by anchor.
29
+ * The current lines of every placement the file still contains exactly once,
30
+ * with the `extras` each thread was written on, keyed by anchor.
23
31
  */
24
- export declare function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, quotes?: ReadonlyMap<string, TextQuote>): Map<string, PatchLineRange>;
32
+ export declare function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, extras?: ReadonlyMap<string, PatchExtras>): Map<string, PatchLineRange>;
25
33
  /** Source highlights for the placed patches: one whole-line span per covered line. */
26
34
  export declare function patchSourceMarks(raw: string, placements: ReadonlyMap<string, PatchPlacement>): SourceMark[];
27
35
  /** The lines a placed thread covers now; for one that cannot be placed, why, and the lines it was captured on. */
@@ -30,15 +38,17 @@ export declare function patchLabel({ patch, match }: PatchPlacement): string;
30
38
  * The anchor and label for a selection of `raw`'s lines. A `quote` of the
31
39
  * selected words is returned beside the anchor (the host stores it next to the
32
40
  * patch, never inside it) only when it lies inside those lines, which the
33
- * server requires; otherwise the patch alone anchors the thread.
41
+ * server requires; otherwise the patch alone anchors the thread. A `cell` (the
42
+ * table cell the selection lies in) needs `lines` to be its row's one line, and
43
+ * names the thread.
34
44
  */
35
- export declare function patchDraft({ raw, lines, quote }: {
45
+ export declare function patchDraft({ raw, lines, quote, cell, }: {
36
46
  raw: string;
37
47
  lines: LineRange;
38
48
  quote?: TextQuote | null | undefined;
49
+ cell?: TableCell | null | undefined;
39
50
  }): {
40
51
  anchor: string;
41
52
  label: string;
42
- quote?: TextQuote;
43
- };
53
+ } & PatchExtras;
44
54
  //# sourceMappingURL=patch-comments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"patch-comments.d.ts","sourceRoot":"","sources":["../../../src/file-findings/file-review/patch-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,MAAM,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,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,UAAU,EAAE,CAM3G;AAED,kHAAkH;AAClH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,cAAc,GAAG,MAAM,CAGnE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,KAAK,EACL,KAAK,EACL,IAAI,GACL,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACrC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CASlD"}
@@ -1,5 +1,6 @@
1
1
  import { capturePatch, describePatch, isPatchAnchor, matchPatch, parsePatchAnchor, patchAnchor } from "../../comments/anchoring/patch-anchor.js";
2
2
  import { quoteLiesInLines } from "./quote-anchor.js";
3
+ import { describeCell } from "./table-cell.js";
3
4
  // src/file-findings/file-review/patch-comments.ts
4
5
  /** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */
5
6
  function placePatches(raw, anchors) {
@@ -12,21 +13,22 @@ function placePatches(raw, anchors) {
12
13
  }];
13
14
  }));
14
15
  }
16
+ /** Only the extras that are set, so none is spread as an undefined key. */
17
+ var patchExtras = ({ quote, cell }) => ({
18
+ ...quote ? { quote } : {},
19
+ ...cell ? { cell } : {}
20
+ });
15
21
  /**
16
- * The current lines of every placement the file still contains exactly once.
17
- * `quotes` are the selected words each thread was written on, kept by the host
18
- * beside the patch (never in the anchor), keyed by anchor.
22
+ * The current lines of every placement the file still contains exactly once,
23
+ * with the `extras` each thread was written on, keyed by anchor.
19
24
  */
20
- function patchLineRanges(placements, quotes = /* @__PURE__ */ new Map()) {
25
+ function patchLineRanges(placements, extras = /* @__PURE__ */ new Map()) {
21
26
  const ranges = /* @__PURE__ */ new Map();
22
- for (const { anchor, match } of placements.values()) {
23
- const quote = quotes.get(anchor);
24
- if (match.state === "matched") ranges.set(anchor, {
25
- start: match.startLine,
26
- end: match.endLine,
27
- ...quote ? { quote } : {}
28
- });
29
- }
27
+ for (const { anchor, match } of placements.values()) if (match.state === "matched") ranges.set(anchor, {
28
+ start: match.startLine,
29
+ end: match.endLine,
30
+ ...patchExtras(extras.get(anchor) ?? {})
31
+ });
30
32
  return ranges;
31
33
  }
32
34
  /** Source highlights for the placed patches: one whole-line span per covered line. */
@@ -54,16 +56,20 @@ function patchLabel({ patch, match }) {
54
56
  * The anchor and label for a selection of `raw`'s lines. A `quote` of the
55
57
  * selected words is returned beside the anchor (the host stores it next to the
56
58
  * patch, never inside it) only when it lies inside those lines, which the
57
- * server requires; otherwise the patch alone anchors the thread.
59
+ * server requires; otherwise the patch alone anchors the thread. A `cell` (the
60
+ * table cell the selection lies in) needs `lines` to be its row's one line, and
61
+ * names the thread.
58
62
  */
59
- function patchDraft({ raw, lines, quote }) {
63
+ function patchDraft({ raw, lines, quote, cell }) {
64
+ if (cell && lines.startLine !== lines.endLine) throw new Error(`a table cell lies on one line, not lines ${lines.startLine}-${lines.endLine}`);
60
65
  const patch = capturePatch(raw, lines.startLine, lines.endLine);
61
66
  return {
62
67
  anchor: patchAnchor(patch),
63
- label: describePatch(patch),
64
- ...quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {}
68
+ label: cell ? describeCell(cell) : describePatch(patch),
69
+ ...quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {},
70
+ ...cell ? { cell } : {}
65
71
  };
66
72
  }
67
- export { patchDraft, patchLabel, patchLineRanges, patchSourceMarks, placePatches };
73
+ export { patchDraft, patchExtras, patchLabel, patchLineRanges, patchSourceMarks, placePatches };
68
74
 
69
75
  //# sourceMappingURL=patch-comments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"patch-comments.js","names":[],"sources":["../../../src/file-findings/file-review/patch-comments.ts"],"sourcesContent":["import {\n capturePatch,\n describePatch,\n isPatchAnchor,\n matchPatch,\n parsePatchAnchor,\n patchAnchor,\n type PatchMatch,\n} from \"../../comments/anchoring/patch-anchor\";\nimport type { PatchAnchor, TextQuote } from \"../../comments/annotation-types\";\nimport { quoteLiesInLines } from \"./quote-anchor\";\nimport type { LineRange } from \"./selection-lines\";\nimport type { SourceMark } from \"./source-marks\";\n\n/** An `r:` thread's patch and where it sits in the file's current text. */\nexport type PatchPlacement = { anchor: string; patch: PatchAnchor; match: PatchMatch };\n\n/** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */\nexport function placePatches(raw: string, anchors: readonly string[]): Map<string, PatchPlacement> {\n return new Map(\n anchors.filter(isPatchAnchor).map((anchor) => {\n const patch = parsePatchAnchor(anchor);\n return [anchor, { anchor, patch, match: matchPatch(raw, patch) }];\n }),\n );\n}\n\n/** The current lines of a placed patch, with the quote it was made on, if any. */\nexport type PatchLineRange = { start: number; end: number; quote?: TextQuote };\n\n/**\n * The current lines of every placement the file still contains exactly once.\n * `quotes` are the selected words each thread was written on, kept by the host\n * beside the patch (never in the anchor), keyed by anchor.\n */\nexport function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, quotes: ReadonlyMap<string, TextQuote> = new Map()): Map<string, PatchLineRange> {\n const ranges = new Map<string, PatchLineRange>();\n for (const { anchor, match } of placements.values()) {\n const quote = quotes.get(anchor);\n if (match.state === \"matched\") ranges.set(anchor, { start: match.startLine, end: match.endLine, ...(quote ? { quote } : {}) });\n }\n return ranges;\n}\n\n/** Source highlights for the placed patches: one whole-line span per covered line. */\nexport function patchSourceMarks(raw: string, placements: ReadonlyMap<string, PatchPlacement>): SourceMark[] {\n const lines = raw.split(\"\\n\");\n return [...patchLineRanges(placements)].map(([anchor, { start, end }]) => ({\n anchor,\n spans: Array.from({ length: end - start + 1 }, (_, i) => ({ line: start + i, start: 0, end: lines[start + i - 1]?.length ?? 0 })),\n }));\n}\n\n/** The lines a placed thread covers now; for one that cannot be placed, why, and the lines it was captured on. */\nexport function patchLabel({ patch, match }: PatchPlacement): string {\n if (match.state === \"matched\") return describePatch({ ...patch, startLine: match.startLine, endLine: match.endLine });\n return `${match.state === \"outdated\" ? \"Outdated\" : \"Ambiguous\"} · ${describePatch(patch)}`;\n}\n\n/**\n * The anchor and label for a selection of `raw`'s lines. A `quote` of the\n * selected words is returned beside the anchor (the host stores it next to the\n * patch, never inside it) only when it lies inside those lines, which the\n * server requires; otherwise the patch alone anchors the thread.\n */\nexport function patchDraft({ raw, lines, quote }: { raw: string; lines: LineRange; quote?: TextQuote | null | undefined }): { anchor: string; label: string; quote?: TextQuote } {\n const patch = capturePatch(raw, lines.startLine, lines.endLine);\n return { anchor: patchAnchor(patch), label: describePatch(patch), ...(quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {}) };\n}\n"],"mappings":";;;;AAkBA,SAAgB,aAAa,KAAa,SAAyD;CACjG,OAAO,IAAI,IACT,QAAQ,OAAO,aAAa,CAAC,CAAC,KAAK,WAAW;EAC5C,MAAM,QAAQ,iBAAiB,MAAM;EACrC,OAAO,CAAC,QAAQ;GAAE;GAAQ;GAAO,OAAO,WAAW,KAAK,KAAK;EAAE,CAAC;CAClE,CAAC,CACH;AACF;;;;;;AAUA,SAAgB,gBAAgB,YAAiD,yBAAyC,IAAI,IAAI,GAAgC;CAChK,MAAM,yBAAS,IAAI,IAA4B;CAC/C,KAAK,MAAM,EAAE,QAAQ,WAAW,WAAW,OAAO,GAAG;EACnD,MAAM,QAAQ,OAAO,IAAI,MAAM;EAC/B,IAAI,MAAM,UAAU,WAAW,OAAO,IAAI,QAAQ;GAAE,OAAO,MAAM;GAAW,KAAK,MAAM;GAAS,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EAAG,CAAC;CAC/H;CACA,OAAO;AACT;;AAGA,SAAgB,iBAAiB,KAAa,YAA+D;CAC3G,MAAM,QAAQ,IAAI,MAAM,IAAI;CAC5B,OAAO,CAAC,GAAG,gBAAgB,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,YAAY;EACzE;EACA,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,QAAQ,EAAE,IAAI,GAAG,OAAO;GAAE,MAAM,QAAQ;GAAG,OAAO;GAAG,KAAK,MAAM,QAAQ,IAAI,EAAE,EAAE,UAAU;EAAE,EAAE;CAClI,EAAE;AACJ;;AAGA,SAAgB,WAAW,EAAE,OAAO,SAAiC;CACnE,IAAI,MAAM,UAAU,WAAW,OAAO,cAAc;EAAE,GAAG;EAAO,WAAW,MAAM;EAAW,SAAS,MAAM;CAAQ,CAAC;CACpH,OAAO,GAAG,MAAM,UAAU,aAAa,aAAa,YAAY,KAAK,cAAc,KAAK;AAC1F;;;;;;;AAQA,SAAgB,WAAW,EAAE,KAAK,OAAO,SAAwI;CAC/K,MAAM,QAAQ,aAAa,KAAK,MAAM,WAAW,MAAM,OAAO;CAC9D,OAAO;EAAE,QAAQ,YAAY,KAAK;EAAG,OAAO,cAAc,KAAK;EAAG,GAAI,SAAS,iBAAiB,OAAO,MAAM,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;CAAG;AACxI"}
1
+ {"version":3,"file":"patch-comments.js","names":[],"sources":["../../../src/file-findings/file-review/patch-comments.ts"],"sourcesContent":["import {\n capturePatch,\n describePatch,\n isPatchAnchor,\n matchPatch,\n parsePatchAnchor,\n patchAnchor,\n type PatchMatch,\n} from \"../../comments/anchoring/patch-anchor\";\nimport type { PatchAnchor, TableCell, TextQuote } from \"../../comments/annotation-types\";\nimport { quoteLiesInLines } from \"./quote-anchor\";\nimport { describeCell } from \"./table-cell\";\nimport type { LineRange } from \"./selection-lines\";\nimport type { SourceMark } from \"./source-marks\";\n\n/** An `r:` thread's patch and where it sits in the file's current text. */\nexport type PatchPlacement = { anchor: string; patch: PatchAnchor; match: PatchMatch };\n\n/** Where each `r:` anchor in `anchors` sits in `raw` now; other kinds of anchor are left out. */\nexport function placePatches(raw: string, anchors: readonly string[]): Map<string, PatchPlacement> {\n return new Map(\n anchors.filter(isPatchAnchor).map((anchor) => {\n const patch = parsePatchAnchor(anchor);\n return [anchor, { anchor, patch, match: matchPatch(raw, patch) }];\n }),\n );\n}\n\n/** What a host keeps beside a patch (never inside it) to sharpen its highlight: the selected words, and the table cell they lie in. */\nexport type PatchExtras = { quote?: TextQuote; cell?: TableCell };\n\n/** The current lines of a placed patch, with the quote and cell it was made on, if any. */\nexport type PatchLineRange = { start: number; end: number } & PatchExtras;\n\n/** Only the extras that are set, so none is spread as an undefined key. */\nexport const patchExtras = ({ quote, cell }: { quote?: TextQuote | undefined; cell?: TableCell | undefined }): PatchExtras => ({ ...(quote ? { quote } : {}), ...(cell ? { cell } : {}) });\n\n/**\n * The current lines of every placement the file still contains exactly once,\n * with the `extras` each thread was written on, keyed by anchor.\n */\nexport function patchLineRanges(placements: ReadonlyMap<string, PatchPlacement>, extras: ReadonlyMap<string, PatchExtras> = new Map()): Map<string, PatchLineRange> {\n const ranges = new Map<string, PatchLineRange>();\n for (const { anchor, match } of placements.values()) {\n if (match.state === \"matched\") ranges.set(anchor, { start: match.startLine, end: match.endLine, ...patchExtras(extras.get(anchor) ?? {}) });\n }\n return ranges;\n}\n\n/** Source highlights for the placed patches: one whole-line span per covered line. */\nexport function patchSourceMarks(raw: string, placements: ReadonlyMap<string, PatchPlacement>): SourceMark[] {\n const lines = raw.split(\"\\n\");\n return [...patchLineRanges(placements)].map(([anchor, { start, end }]) => ({\n anchor,\n spans: Array.from({ length: end - start + 1 }, (_, i) => ({ line: start + i, start: 0, end: lines[start + i - 1]?.length ?? 0 })),\n }));\n}\n\n/** The lines a placed thread covers now; for one that cannot be placed, why, and the lines it was captured on. */\nexport function patchLabel({ patch, match }: PatchPlacement): string {\n if (match.state === \"matched\") return describePatch({ ...patch, startLine: match.startLine, endLine: match.endLine });\n return `${match.state === \"outdated\" ? \"Outdated\" : \"Ambiguous\"} · ${describePatch(patch)}`;\n}\n\n/**\n * The anchor and label for a selection of `raw`'s lines. A `quote` of the\n * selected words is returned beside the anchor (the host stores it next to the\n * patch, never inside it) only when it lies inside those lines, which the\n * server requires; otherwise the patch alone anchors the thread. A `cell` (the\n * table cell the selection lies in) needs `lines` to be its row's one line, and\n * names the thread.\n */\nexport function patchDraft({\n raw,\n lines,\n quote,\n cell,\n}: {\n raw: string;\n lines: LineRange;\n quote?: TextQuote | null | undefined;\n cell?: TableCell | null | undefined;\n}): { anchor: string; label: string } & PatchExtras {\n if (cell && lines.startLine !== lines.endLine) throw new Error(`a table cell lies on one line, not lines ${lines.startLine}-${lines.endLine}`);\n const patch = capturePatch(raw, lines.startLine, lines.endLine);\n return {\n anchor: patchAnchor(patch),\n label: cell ? describeCell(cell) : describePatch(patch),\n ...(quote && quoteLiesInLines(quote, patch.lines) ? { quote } : {}),\n ...(cell ? { cell } : {}),\n };\n}\n"],"mappings":";;;;;AAmBA,SAAgB,aAAa,KAAa,SAAyD;CACjG,OAAO,IAAI,IACT,QAAQ,OAAO,aAAa,CAAC,CAAC,KAAK,WAAW;EAC5C,MAAM,QAAQ,iBAAiB,MAAM;EACrC,OAAO,CAAC,QAAQ;GAAE;GAAQ;GAAO,OAAO,WAAW,KAAK,KAAK;EAAE,CAAC;CAClE,CAAC,CACH;AACF;;AASA,IAAa,eAAe,EAAE,OAAO,YAA0F;CAAE,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAAI,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;AAAG;;;;;AAMxL,SAAgB,gBAAgB,YAAiD,yBAA2C,IAAI,IAAI,GAAgC;CAClK,MAAM,yBAAS,IAAI,IAA4B;CAC/C,KAAK,MAAM,EAAE,QAAQ,WAAW,WAAW,OAAO,GAChD,IAAI,MAAM,UAAU,WAAW,OAAO,IAAI,QAAQ;EAAE,OAAO,MAAM;EAAW,KAAK,MAAM;EAAS,GAAG,YAAY,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