texlite 0.19.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/DESIGN.md +241 -7
  2. package/OPERATIONS.md +7 -4
  3. package/README.md +6 -1
  4. package/README.zh-CN.md +4 -1
  5. package/dist/client/assets/AdminUsers-BghRo_hC.js +1 -0
  6. package/dist/client/assets/AdminUsers-BghRo_hC.js.br +0 -0
  7. package/dist/client/assets/AdminUsers-BghRo_hC.js.gz +0 -0
  8. package/dist/client/assets/AgentIcon-DsoMeMA8.js +1 -0
  9. package/dist/client/assets/AgentIcon-DsoMeMA8.js.br +0 -0
  10. package/dist/client/assets/AgentIcon-DsoMeMA8.js.gz +0 -0
  11. package/dist/client/assets/AgentIcon-dCMgWJG-.css +1 -0
  12. package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
  13. package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
  14. package/dist/client/assets/AgentManagement-rIYtm4Bo.js +1 -0
  15. package/dist/client/assets/AgentManagement-rIYtm4Bo.js.br +0 -0
  16. package/dist/client/assets/AgentManagement-rIYtm4Bo.js.gz +0 -0
  17. package/dist/client/assets/AgentTerminal-BEjiw51y.js +2 -0
  18. package/dist/client/assets/AgentTerminal-BEjiw51y.js.br +0 -0
  19. package/dist/client/assets/AgentTerminal-BEjiw51y.js.gz +0 -0
  20. package/dist/client/assets/{AgentTerminalSurface-C11baRxh.js → AgentTerminalSurface-B2rwONYs.js} +2 -2
  21. package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.br +0 -0
  22. package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.gz +0 -0
  23. package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js +1 -0
  24. package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.br +0 -0
  25. package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.gz +0 -0
  26. package/dist/client/assets/CitationBibtexEditor-BnK6nZPi.js +1 -0
  27. package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js +3 -0
  28. package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.br +0 -0
  29. package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.gz +0 -0
  30. package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js +36 -0
  31. package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.br +0 -0
  32. package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.gz +0 -0
  33. package/dist/client/assets/Dashboard-Dcl0Y_C3.js +5 -0
  34. package/dist/client/assets/Dashboard-Dcl0Y_C3.js.br +0 -0
  35. package/dist/client/assets/Dashboard-Dcl0Y_C3.js.gz +0 -0
  36. package/dist/client/assets/GitDialog-BeYvUCDv.js +3 -0
  37. package/dist/client/assets/GitDialog-BeYvUCDv.js.br +0 -0
  38. package/dist/client/assets/GitDialog-BeYvUCDv.js.gz +0 -0
  39. package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js +1 -0
  40. package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.br +0 -0
  41. package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.gz +0 -0
  42. package/dist/client/assets/GitHubIcon-CExJn0AV.js +1 -0
  43. package/dist/client/assets/HistoryDialog-B-C4Zaef.js +8 -0
  44. package/dist/client/assets/HistoryDialog-B-C4Zaef.js.br +0 -0
  45. package/dist/client/assets/HistoryDialog-B-C4Zaef.js.gz +0 -0
  46. package/dist/client/assets/InfoPopover-Dkz742vJ.js +1 -0
  47. package/dist/client/assets/LatexEditor-CohUJrGD.js +25 -0
  48. package/dist/client/assets/LatexEditor-CohUJrGD.js.br +0 -0
  49. package/dist/client/assets/LatexEditor-CohUJrGD.js.gz +0 -0
  50. package/dist/client/assets/PdfPreview-BvJxduy3.js +1 -0
  51. package/dist/client/assets/PdfPreview-BvJxduy3.js.br +0 -0
  52. package/dist/client/assets/PdfPreview-BvJxduy3.js.gz +0 -0
  53. package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js +1 -0
  54. package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.br +0 -0
  55. package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.gz +0 -0
  56. package/dist/client/assets/ProjectSettings-D8uH3PqQ.js +4 -0
  57. package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.br +0 -0
  58. package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.gz +0 -0
  59. package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js +31 -0
  60. package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.br +0 -0
  61. package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.gz +0 -0
  62. package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js +1 -0
  63. package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.br +0 -0
  64. package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.gz +0 -0
  65. package/dist/client/assets/ReadOnlySource-BZ7WYQO7.js +2 -0
  66. package/dist/client/assets/SaveButton-wiTpGLho.js +1 -0
  67. package/dist/client/assets/{SelectionHistoryDialog-cDxbuXmO.js → SelectionHistoryDialog-DYQb9hXp.js} +2 -2
  68. package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.br +0 -0
  69. package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.gz +0 -0
  70. package/dist/client/assets/SharedProjectPage-BOGGeyBG.css +1 -0
  71. package/dist/client/assets/SharedProjectPage-DJjR-D8d.js +2 -0
  72. package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.br +0 -0
  73. package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.gz +0 -0
  74. package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js +1 -0
  75. package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.br +0 -0
  76. package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.gz +0 -0
  77. package/dist/client/assets/{TagColorSelect-D-zwdawC.js → TagColorSelect-CzPUDAny.js} +1 -1
  78. package/dist/client/assets/TagManagementDialog-BBOpD_62.js +1 -0
  79. package/dist/client/assets/TagManagementDialog-BBOpD_62.js.br +0 -0
  80. package/dist/client/assets/TagManagementDialog-BBOpD_62.js.gz +0 -0
  81. package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js +1 -0
  82. package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.br +0 -0
  83. package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.gz +0 -0
  84. package/dist/client/assets/WordCountDialog-CgDcnPdJ.js +1 -0
  85. package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.br +0 -0
  86. package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.gz +0 -0
  87. package/dist/client/assets/arrow-down-C_4f1E-E.js +1 -0
  88. package/dist/client/assets/check-Dw16EqG-.js +1 -0
  89. package/dist/client/assets/chevron-up-BHaMUEEA.js +1 -0
  90. package/dist/client/assets/{chktex-Dm6IIkcR.js → chktex-BeOSrdut.js} +1 -1
  91. package/dist/client/assets/circle-check-CunlnBPw.js +1 -0
  92. package/dist/client/assets/clipboard-CslquMx4.js +1 -0
  93. package/dist/client/assets/clock-3-DztJubz_.js +1 -0
  94. package/dist/client/assets/createLucideIcon-CDYIzuiB.js +1 -0
  95. package/dist/client/assets/createLucideIcon-CDYIzuiB.js.br +0 -0
  96. package/dist/client/assets/createLucideIcon-CDYIzuiB.js.gz +0 -0
  97. package/dist/client/assets/dist-B_WjsTVV.js +1 -0
  98. package/dist/client/assets/dist-B_WjsTVV.js.br +0 -0
  99. package/dist/client/assets/dist-B_WjsTVV.js.gz +0 -0
  100. package/dist/client/assets/dist-Bcdl4EAC.js +1 -0
  101. package/dist/client/assets/dist-Bcdl4EAC.js.br +0 -0
  102. package/dist/client/assets/dist-Bcdl4EAC.js.gz +0 -0
  103. package/dist/client/assets/dist-DdUqlCPw.js +1 -0
  104. package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
  105. package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
  106. package/dist/client/assets/editor-JqCouYk8.js +14 -0
  107. package/dist/client/assets/editor-JqCouYk8.js.br +0 -0
  108. package/dist/client/assets/editor-JqCouYk8.js.gz +0 -0
  109. package/dist/client/assets/editor-languages-CRI2h3Fj.js +36 -0
  110. package/dist/client/assets/editor-languages-CRI2h3Fj.js.br +0 -0
  111. package/dist/client/assets/editor-languages-CRI2h3Fj.js.gz +0 -0
  112. package/dist/client/assets/editorThemeExtension-BNWs0sHh.js +1 -0
  113. package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.br +0 -0
  114. package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.gz +0 -0
  115. package/dist/client/assets/es2015-D2UDOM09.js +41 -0
  116. package/dist/client/assets/es2015-D2UDOM09.js.br +0 -0
  117. package/dist/client/assets/es2015-D2UDOM09.js.gz +0 -0
  118. package/dist/client/assets/eye-BnslGpqB.js +1 -0
  119. package/dist/client/assets/hard-drive-CXlummIE.js +1 -0
  120. package/dist/client/assets/i18n-Bv4wFb8D.js +13 -0
  121. package/dist/client/assets/i18n-Bv4wFb8D.js.br +0 -0
  122. package/dist/client/assets/i18n-Bv4wFb8D.js.gz +0 -0
  123. package/dist/client/assets/index-Bdb2ITID.js +2 -0
  124. package/dist/client/assets/index-Bdb2ITID.js.br +0 -0
  125. package/dist/client/assets/index-Bdb2ITID.js.gz +0 -0
  126. package/dist/client/assets/index-wqKiaXZr.css +1 -0
  127. package/dist/client/assets/index-wqKiaXZr.css.br +0 -0
  128. package/dist/client/assets/index-wqKiaXZr.css.gz +0 -0
  129. package/dist/client/assets/katex-CBRBI6nR.js +257 -0
  130. package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
  131. package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
  132. package/dist/client/assets/katex-CvRo0776.css +1 -0
  133. package/dist/client/assets/katex-CvRo0776.css.br +0 -0
  134. package/dist/client/assets/{katex-DDK6mlKN.css.gz → katex-CvRo0776.css.gz} +0 -0
  135. package/dist/client/assets/library-big-B8e_Fiql.js +1 -0
  136. package/dist/client/assets/loader-circle-DKGyi5EK.js +1 -0
  137. package/dist/client/assets/lock-keyhole-aC_QjKDi.js +1 -0
  138. package/dist/client/assets/minimize-2-CkBmeGXp.js +1 -0
  139. package/dist/client/assets/minus-DrpwqY8Y.js +1 -0
  140. package/dist/client/assets/refresh-cw-IqExWG6S.js +1 -0
  141. package/dist/client/assets/relativeTime-DlKXhH_h.js +1 -0
  142. package/dist/client/assets/relativeTime-DlKXhH_h.js.br +0 -0
  143. package/dist/client/assets/relativeTime-DlKXhH_h.js.gz +0 -0
  144. package/dist/client/assets/search-DjOWqLig.js +1 -0
  145. package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js +1 -0
  146. package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.br +0 -0
  147. package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.gz +0 -0
  148. package/dist/client/assets/{spellCheck-DiNvmZKv.js → spellCheck-P-fMO4iR.js} +1 -1
  149. package/dist/client/assets/spellCheck-P-fMO4iR.js.br +0 -0
  150. package/dist/client/assets/spellCheck-P-fMO4iR.js.gz +0 -0
  151. package/dist/client/assets/tags-GrE3ZIQN.js +1 -0
  152. package/dist/client/assets/terminal-DD9WJ56e.js +1 -0
  153. package/dist/client/assets/{textLanguageSupport-DIXngcZX.js → textLanguageSupport-BSIE7WPM.js} +1 -1
  154. package/dist/client/assets/textLanguages-DAJ1OXJA.js +78 -0
  155. package/dist/client/assets/textLanguages-DAJ1OXJA.js.br +0 -0
  156. package/dist/client/assets/textLanguages-DAJ1OXJA.js.gz +0 -0
  157. package/dist/client/assets/type-CKe1tHHo.js +1 -0
  158. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +1 -0
  159. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
  160. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
  161. package/dist/client/assets/useTranslation-DwkoADSz.js +1 -0
  162. package/dist/client/assets/useTranslation-DwkoADSz.js.br +0 -0
  163. package/dist/client/assets/useTranslation-DwkoADSz.js.gz +0 -0
  164. package/dist/client/assets/user-plus-NNBQOWDP.js +1 -0
  165. package/dist/client/assets/{vimSupport-RdD-E-Eh.js → vimSupport-BwIAfLU0.js} +6 -6
  166. package/dist/client/assets/vimSupport-BwIAfLU0.js.br +0 -0
  167. package/dist/client/assets/vimSupport-BwIAfLU0.js.gz +0 -0
  168. package/dist/client/index.html +9 -4
  169. package/dist/server/app.js +7 -1
  170. package/dist/server/byteRange.js +19 -0
  171. package/dist/server/citationCollections.js +163 -0
  172. package/dist/server/citationFolderTransfer.js +74 -0
  173. package/dist/server/citationInput.js +34 -0
  174. package/dist/server/collaboration.js +47 -16
  175. package/dist/server/commentMentions.js +6 -1
  176. package/dist/server/commentSuggestions.js +143 -0
  177. package/dist/server/db.js +81 -0
  178. package/dist/server/i18n.js +9 -0
  179. package/dist/server/locales/zh-Hant.js +6 -0
  180. package/dist/server/projectPreview.js +133 -0
  181. package/dist/server/routes/citations.js +84 -55
  182. package/dist/server/routes/commentSuggestions.js +154 -0
  183. package/dist/server/routes/comments.js +17 -1
  184. package/dist/server/routes/compile.js +1 -19
  185. package/dist/server/routes/projectShared.js +3 -0
  186. package/dist/server/routes/projectViewLinks.js +238 -0
  187. package/dist/server/routes/projects.js +12 -3
  188. package/dist/server/viewLinkTokens.js +49 -0
  189. package/dist/server/viewLinks.js +25 -0
  190. package/dist/shared/citationCollections.js +29 -0
  191. package/dist/shared/citationContent.js +4 -0
  192. package/dist/shared/citationTransfer.js +7 -0
  193. package/dist/shared/comments.js +2 -1
  194. package/dist/shared/projectCatalog.js +1 -1
  195. package/dist/shared/projectViewLinks.js +20 -0
  196. package/dist/shared/suggestionMessages.js +41 -0
  197. package/dist/shared/updates.js +1 -1
  198. package/package.json +9 -1
  199. package/dist/client/assets/AdminUsers-D5vhK_Ae.js +0 -1
  200. package/dist/client/assets/AdminUsers-D5vhK_Ae.js.br +0 -0
  201. package/dist/client/assets/AdminUsers-D5vhK_Ae.js.gz +0 -0
  202. package/dist/client/assets/AgentIcon-C97W4Mt-.js +0 -1
  203. package/dist/client/assets/AgentIcon-C97W4Mt-.js.br +0 -0
  204. package/dist/client/assets/AgentIcon-C97W4Mt-.js.gz +0 -0
  205. package/dist/client/assets/AgentIcon-DxrC-zx_.css +0 -1
  206. package/dist/client/assets/AgentIcon-DxrC-zx_.css.br +0 -0
  207. package/dist/client/assets/AgentIcon-DxrC-zx_.css.gz +0 -0
  208. package/dist/client/assets/AgentManagement-D6I_GDL_.js +0 -1
  209. package/dist/client/assets/AgentManagement-D6I_GDL_.js.br +0 -0
  210. package/dist/client/assets/AgentManagement-D6I_GDL_.js.gz +0 -0
  211. package/dist/client/assets/AgentTerminal-fsHpIB_c.js +0 -2
  212. package/dist/client/assets/AgentTerminal-fsHpIB_c.js.br +0 -0
  213. package/dist/client/assets/AgentTerminal-fsHpIB_c.js.gz +0 -0
  214. package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.br +0 -0
  215. package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.gz +0 -0
  216. package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js +0 -1
  217. package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.br +0 -0
  218. package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.gz +0 -0
  219. package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js +0 -1
  220. package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.br +0 -0
  221. package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.gz +0 -0
  222. package/dist/client/assets/Dashboard-DAPwKNNH.js +0 -5
  223. package/dist/client/assets/Dashboard-DAPwKNNH.js.br +0 -0
  224. package/dist/client/assets/Dashboard-DAPwKNNH.js.gz +0 -0
  225. package/dist/client/assets/GitDialog-BzyA_IgU.js +0 -3
  226. package/dist/client/assets/GitDialog-BzyA_IgU.js.br +0 -0
  227. package/dist/client/assets/GitDialog-BzyA_IgU.js.gz +0 -0
  228. package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js +0 -1
  229. package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.br +0 -0
  230. package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.gz +0 -0
  231. package/dist/client/assets/GitHubIcon-BqDow-CN.js +0 -1
  232. package/dist/client/assets/HistoryDialog-407q3Fe6.js +0 -8
  233. package/dist/client/assets/HistoryDialog-407q3Fe6.js.br +0 -0
  234. package/dist/client/assets/HistoryDialog-407q3Fe6.js.gz +0 -0
  235. package/dist/client/assets/LatexEditor-BYiVPD_b.js +0 -101
  236. package/dist/client/assets/LatexEditor-BYiVPD_b.js.br +0 -0
  237. package/dist/client/assets/LatexEditor-BYiVPD_b.js.gz +0 -0
  238. package/dist/client/assets/PdfPreview-Bbzop29j.js +0 -1
  239. package/dist/client/assets/PdfPreview-Bbzop29j.js.br +0 -0
  240. package/dist/client/assets/PdfPreview-Bbzop29j.js.gz +0 -0
  241. package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js +0 -1
  242. package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.br +0 -0
  243. package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.gz +0 -0
  244. package/dist/client/assets/ProjectSettings-BfvAiyC6.js +0 -4
  245. package/dist/client/assets/ProjectSettings-BfvAiyC6.js.br +0 -0
  246. package/dist/client/assets/ProjectSettings-BfvAiyC6.js.gz +0 -0
  247. package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js +0 -30
  248. package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.br +0 -0
  249. package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.gz +0 -0
  250. package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js +0 -1
  251. package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.br +0 -0
  252. package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.gz +0 -0
  253. package/dist/client/assets/SaveButton-C8W1DGzx.js +0 -1
  254. package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.br +0 -0
  255. package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.gz +0 -0
  256. package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js +0 -1
  257. package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.br +0 -0
  258. package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.gz +0 -0
  259. package/dist/client/assets/TagManagementDialog-BN3tlXuW.js +0 -1
  260. package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.br +0 -0
  261. package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.gz +0 -0
  262. package/dist/client/assets/WordCountDialog-C4okQWS3.js +0 -1
  263. package/dist/client/assets/WordCountDialog-C4okQWS3.js.br +0 -0
  264. package/dist/client/assets/WordCountDialog-C4okQWS3.js.gz +0 -0
  265. package/dist/client/assets/arrow-down-BiIGj4-X.js +0 -1
  266. package/dist/client/assets/check-DfWHdQ1s.js +0 -1
  267. package/dist/client/assets/chevron-up-lyMKml7P.js +0 -1
  268. package/dist/client/assets/circle-check-DjXwnxuR.js +0 -1
  269. package/dist/client/assets/clock-3-D-XeFtkK.js +0 -1
  270. package/dist/client/assets/dist-ByqeNQqT.js +0 -1
  271. package/dist/client/assets/dist-ByqeNQqT.js.br +0 -0
  272. package/dist/client/assets/dist-ByqeNQqT.js.gz +0 -0
  273. package/dist/client/assets/dist-Dxkdrap6.js +0 -2
  274. package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
  275. package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
  276. package/dist/client/assets/editor-languages-C6EDWlLD.js +0 -36
  277. package/dist/client/assets/editor-languages-C6EDWlLD.js.br +0 -0
  278. package/dist/client/assets/editor-languages-C6EDWlLD.js.gz +0 -0
  279. package/dist/client/assets/editor-oR9RlWUz.js +0 -14
  280. package/dist/client/assets/editor-oR9RlWUz.js.br +0 -0
  281. package/dist/client/assets/editor-oR9RlWUz.js.gz +0 -0
  282. package/dist/client/assets/eye-BvCLgqrq.js +0 -1
  283. package/dist/client/assets/hard-drive-Crh-l_oh.js +0 -1
  284. package/dist/client/assets/i18n-O9QnEo2t.js +0 -13
  285. package/dist/client/assets/i18n-O9QnEo2t.js.br +0 -0
  286. package/dist/client/assets/i18n-O9QnEo2t.js.gz +0 -0
  287. package/dist/client/assets/index-7d5TfVNx.css +0 -1
  288. package/dist/client/assets/index-7d5TfVNx.css.br +0 -0
  289. package/dist/client/assets/index-7d5TfVNx.css.gz +0 -0
  290. package/dist/client/assets/index-DFEpXxLs.js +0 -42
  291. package/dist/client/assets/index-DFEpXxLs.js.br +0 -0
  292. package/dist/client/assets/index-DFEpXxLs.js.gz +0 -0
  293. package/dist/client/assets/info-g1IBvVg6.js +0 -1
  294. package/dist/client/assets/katex-Bd0sKoun.js +0 -257
  295. package/dist/client/assets/katex-Bd0sKoun.js.br +0 -0
  296. package/dist/client/assets/katex-Bd0sKoun.js.gz +0 -0
  297. package/dist/client/assets/katex-DDK6mlKN.css +0 -1
  298. package/dist/client/assets/katex-DDK6mlKN.css.br +0 -0
  299. package/dist/client/assets/minimize-2-BHKmubQs.js +0 -1
  300. package/dist/client/assets/minus-BmWzkFwz.js +0 -1
  301. package/dist/client/assets/plus-CoYCCEFJ.js +0 -1
  302. package/dist/client/assets/refresh-cw-Di6Huxb4.js +0 -1
  303. package/dist/client/assets/relativeTime-CFNodf1I.js +0 -1
  304. package/dist/client/assets/relativeTime-CFNodf1I.js.br +0 -0
  305. package/dist/client/assets/relativeTime-CFNodf1I.js.gz +0 -0
  306. package/dist/client/assets/search-l36unLLS.js +0 -1
  307. package/dist/client/assets/spellCheck-DiNvmZKv.js.br +0 -0
  308. package/dist/client/assets/spellCheck-DiNvmZKv.js.gz +0 -0
  309. package/dist/client/assets/tags-yjr9KRc8.js +0 -1
  310. package/dist/client/assets/terminal-P09ZGT83.js +0 -1
  311. package/dist/client/assets/type-C7rzXWVU.js +0 -1
  312. package/dist/client/assets/user-plus-CqyV7OV4.js +0 -1
  313. package/dist/client/assets/vimSupport-RdD-E-Eh.js.br +0 -0
  314. package/dist/client/assets/vimSupport-RdD-E-Eh.js.gz +0 -0
@@ -0,0 +1,74 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { CITATION_FOLDER_FORMAT, CITATION_FOLDER_VERSION, MAX_CITATION_FOLDER_BYTES, MAX_CITATION_FOLDER_ENTRIES } from "../shared/citationTransfer.js";
3
+ import { requireUser } from "./auth.js";
4
+ import { citationInput } from "./citationInput.js";
5
+ import { httpError } from "./http.js";
6
+ /** Export only portable content, never tags, owner identifiers or internal folder IDs. */
7
+ export function exportCitationFolder(db, userId, folder) {
8
+ const bundle = { format: CITATION_FOLDER_FORMAT, version: CITATION_FOLDER_VERSION, entries: [] };
9
+ let bytes = Buffer.byteLength(JSON.stringify(bundle), "utf8");
10
+ const rows = db.prepare(`SELECT entry.citation_key AS citationKey, entry.entry_type AS entryType,
11
+ entry.bibtex, entry.title, entry.authors, entry.year, entry.notes
12
+ FROM citation_library_entries entry JOIN citation_library_entry_collections link ON link.entry_id = entry.id
13
+ WHERE entry.user_id = ? AND link.collection_id = ? ORDER BY entry.citation_key COLLATE NOCASE, entry.id`)
14
+ .iterate(userId, folder.id);
15
+ for (const row of rows) {
16
+ bytes += Buffer.byteLength(JSON.stringify(row), "utf8") + (bundle.entries.length ? 1 : 0);
17
+ if (bytes > MAX_CITATION_FOLDER_BYTES || bundle.entries.length >= MAX_CITATION_FOLDER_ENTRIES)
18
+ throw httpError(413, "CITATION_FOLDER_TOO_LARGE");
19
+ bundle.entries.push(row);
20
+ }
21
+ return JSON.stringify(bundle);
22
+ }
23
+ export function registerCitationFolderImport(app, db) {
24
+ app.post("/api/citations/collections/import", { bodyLimit: MAX_CITATION_FOLDER_BYTES }, async (request, reply) => {
25
+ const user = requireUser(request, reply, db);
26
+ if (!user)
27
+ return;
28
+ const body = request.body;
29
+ if (!body || body.format !== CITATION_FOLDER_FORMAT || body.version !== CITATION_FOLDER_VERSION
30
+ || typeof body.name !== "string" || !body.name.trim() || body.name.trim().length > 80
31
+ || !Array.isArray(body.entries))
32
+ throw httpError(400, "CITATION_FOLDER_INVALID");
33
+ if (body.entries.length > MAX_CITATION_FOLDER_ENTRIES)
34
+ throw httpError(413, "CITATION_FOLDER_TOO_LARGE");
35
+ // Validate the entire import before opening a write transaction. Repeated
36
+ // keys in the bundle follow the same last-entry-wins rule as existing keys.
37
+ const entries = new Map();
38
+ for (const value of body.entries) {
39
+ if (!value || typeof value.notes !== "string")
40
+ throw httpError(400, "CITATION_FOLDER_INVALID");
41
+ const entry = citationInput(value);
42
+ entries.set(entry.citationKey.toLowerCase(), entry);
43
+ }
44
+ const timestamp = new Date().toISOString();
45
+ const id = randomUUID();
46
+ const baseName = body.name.trim();
47
+ const name = db.transaction(() => {
48
+ let candidate = baseName, suffix = 0;
49
+ const exists = db.prepare("SELECT 1 FROM citation_library_collections WHERE user_id = ? AND name = ? COLLATE NOCASE");
50
+ while (exists.get(user.id, candidate)) {
51
+ const ending = `-${++suffix}`;
52
+ candidate = `${baseName.slice(0, 80 - ending.length)}${ending}`;
53
+ }
54
+ db.prepare("INSERT INTO citation_library_collections (id, user_id, name, created_at) VALUES (?, ?, ?, ?)").run(id, user.id, candidate, timestamp);
55
+ const upsert = db.prepare(`INSERT INTO citation_library_entries
56
+ (id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
57
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
58
+ ON CONFLICT (user_id, citation_key) DO UPDATE SET citation_key = excluded.citation_key,
59
+ entry_type = excluded.entry_type, bibtex = excluded.bibtex, title = excluded.title,
60
+ authors = excluded.authors, year = excluded.year, notes = excluded.notes,
61
+ revision = citation_library_entries.revision + 1, updated_at = excluded.updated_at
62
+ RETURNING id`);
63
+ const place = db.prepare("INSERT INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)");
64
+ for (const entry of entries.values()) {
65
+ const saved = upsert.get(randomUUID(), user.id, entry.citationKey, entry.entryType, entry.bibtex, entry.title, entry.authors, entry.year, entry.notes, timestamp, timestamp);
66
+ // Existing placements and tags are retained. Imported content replaces
67
+ // the user's shared entry, so all its placements see the updated notes.
68
+ place.run(saved.id, id);
69
+ }
70
+ return candidate;
71
+ })();
72
+ return reply.code(201).send({ collection: { id, name, entryCount: entries.size }, imported: entries.size });
73
+ });
74
+ }
@@ -0,0 +1,34 @@
1
+ import { MAX_CITATION_NOTES_BYTES } from "../shared/citationTransfer.js";
2
+ import { httpError, ValidationError } from "./http.js";
3
+ import { MAX_CITATION_BIBTEX_BYTES } from "./limits.js";
4
+ function nullableText(value, max) {
5
+ if (value === undefined || value === null || value === "")
6
+ return null;
7
+ if (typeof value !== "string" || value.length > max)
8
+ throw new ValidationError();
9
+ return value.trim() || null;
10
+ }
11
+ export function citationInput(value) {
12
+ if (typeof value !== "object" || value === null)
13
+ throw new ValidationError();
14
+ const body = value;
15
+ if (typeof body.bibtex !== "string" || !body.bibtex.trim())
16
+ throw new ValidationError();
17
+ if (Buffer.byteLength(body.bibtex, "utf8") > MAX_CITATION_BIBTEX_BYTES)
18
+ throw httpError(413, "CITATION_TOO_LARGE");
19
+ if (typeof body.citationKey !== "string" || !body.citationKey.trim() || body.citationKey.length > 512)
20
+ throw new ValidationError();
21
+ if (typeof body.entryType !== "string" || !body.entryType.trim() || body.entryType.length > 128)
22
+ throw new ValidationError();
23
+ if (body.notes !== undefined) {
24
+ if (typeof body.notes !== "string")
25
+ throw new ValidationError();
26
+ if (Buffer.byteLength(body.notes, "utf8") > MAX_CITATION_NOTES_BYTES)
27
+ throw httpError(413, "CITATION_NOTES_TOO_LARGE");
28
+ }
29
+ return {
30
+ bibtex: body.bibtex.trim(), citationKey: body.citationKey.trim(), entryType: body.entryType.trim(),
31
+ title: nullableText(body.title, 2048), authors: nullableText(body.authors, 2048), year: nullableText(body.year, 128),
32
+ notes: body.notes
33
+ };
34
+ }
@@ -12,6 +12,8 @@ import { Awareness, applyAwarenessUpdate, encodeAwarenessUpdate, modifyAwareness
12
12
  import { listProjectFilesAsync, outputRoot, resolveSourcePath, safeRelativePath, sourceRoot } from "./files.js";
13
13
  import { collaborationProjectAccessFromStatement, canEdit, prepareCollaborationProjectAccessStatement } from "./projects.js";
14
14
  import { reanchorFileComments } from "./anchors.js";
15
+ import { finishSuggestionApplications, hasPendingSuggestionApplication, prepareSuggestionApplication, recoverSuggestionApplications } from "./commentSuggestions.js";
16
+ import { httpError, SourceFlushError } from "./http.js";
15
17
  import { createEditHistorySpan, hashText } from "./editHistory.js";
16
18
  import { isEditableTextFile, isTextContent, MAX_TEXT_EDITOR_BYTES } from "../shared/fileTypes.js";
17
19
  import { COLLABORATION_PROTOCOL_VERSION, CollaborationMessageType, isCollaborationCleanMode, isCollaborationCompileStatus } from "../shared/collaborationProtocol.js";
@@ -137,13 +139,49 @@ export class CollaborationService {
137
139
  }
138
140
  /** Wait for an in-flight cold-room load before reading or replacing sources. */
139
141
  async waitForReady(projectId) {
140
- const initialization = this.roomInitializations.get(projectId);
142
+ let initialization = this.roomInitializations.get(projectId);
143
+ // After a crash the filesystem alone is not authoritative while an
144
+ // accepted source update is journaled. Recover it before a cold HTTP
145
+ // write/restore can replace the source tree or discard its CRDT base.
146
+ if (!initialization && !this.rooms.has(projectId) && hasPendingSuggestionApplication(this.db, projectId)) {
147
+ initialization = this.initializeRoom(projectId, this.projectGeneration(projectId));
148
+ }
141
149
  if (!initialization)
142
150
  return;
143
151
  try {
144
- await initialization;
152
+ this.scheduleRoomCleanup(await initialization);
153
+ }
154
+ catch (error) {
155
+ if (hasPendingSuggestionApplication(this.db, projectId))
156
+ throw error;
157
+ // Without a pending application, source files remain authoritative.
158
+ }
159
+ }
160
+ async prepareSuggestionRoom(projectId) {
161
+ if (this.closed || this.isMaintaining(projectId))
162
+ throw httpError(409, "PROJECT_BUSY");
163
+ const room = await this.initializeRoom(projectId, this.projectGeneration(projectId));
164
+ // Revalidation may reject the HTTP request after hydration. Such a room
165
+ // still needs idle eviction even if no browser ever connects to it.
166
+ this.scheduleRoomCleanup(room);
167
+ }
168
+ /** A source-range operation, not an HTTP whole-file replacement. Called inside runWrite. */
169
+ applyCommentSuggestion(projectId, filePath, commentId, userId) {
170
+ const room = this.rooms.get(projectId);
171
+ if (!room || room.maintenanceReason || this.activeFormatLease(room, filePath))
172
+ throw httpError(409, "PROJECT_BUSY");
173
+ try {
174
+ // The journal update refers to this durable CRDT base, including a cold room's item IDs.
175
+ this.persistRoomState(room);
176
+ const update = prepareSuggestionApplication(this.db, projectId, commentId, room.doc, userId, maxCollaborativeFileBytes(this.config));
177
+ Y.applyUpdate(room.doc, update, { externalUserId: userId, exact: true });
178
+ const receipt = this.flushRoom(room);
179
+ if (!receipt.ok)
180
+ throw new SourceFlushError(receipt.failedPaths);
181
+ }
182
+ finally {
183
+ this.scheduleRoomCleanup(room);
145
184
  }
146
- catch { /* Source files remain authoritative if recovery fails. */ }
147
185
  }
148
186
  flushProject(projectId) {
149
187
  const room = this.rooms.get(projectId);
@@ -624,16 +662,6 @@ export class CollaborationService {
624
662
  }, META_ORIGIN);
625
663
  return changed;
626
664
  }
627
- closeProject(projectId) {
628
- this.invalidateProject(projectId);
629
- this.snapshotBarriers.delete(projectId);
630
- const room = this.rooms.get(projectId);
631
- if (!room)
632
- return;
633
- for (const connection of room.connections)
634
- connection.socket.close(1008, "Project closed");
635
- this.destroyRoom(room);
636
- }
637
665
  resetProject(projectId) {
638
666
  this.invalidateProject(projectId);
639
667
  this.snapshotBarriers.delete(projectId);
@@ -703,9 +731,10 @@ export class CollaborationService {
703
731
  doc = new Y.Doc();
704
732
  }
705
733
  }
734
+ const suggestionsRecovered = recoverSuggestionApplications(this.db, projectId, doc, recoveredState);
706
735
  const epoch = await collaborationEpochAsync(this.config, projectId, recoveredState);
707
736
  const files = await this.readCollaborativeFiles(projectId);
708
- return { doc, recoveredState, epoch, files };
737
+ return { doc, recoveredState, epoch, files, suggestionsRecovered };
709
738
  }
710
739
  catch (error) {
711
740
  doc.destroy();
@@ -887,7 +916,7 @@ export class CollaborationService {
887
916
  try {
888
917
  // Persist a corrected state even when an oversized recovered document was
889
918
  // reverted to the source file and no source write remains dirty.
890
- if (recoveredDirty || rejectedRecoveredPaths.length > 0)
919
+ if (recoveredDirty || rejectedRecoveredPaths.length > 0 || bootstrap.suggestionsRecovered)
891
920
  this.flushRoom(room);
892
921
  else if (recoveredMetadataChanged)
893
922
  this.scheduleStateSave(room);
@@ -989,7 +1018,7 @@ export class CollaborationService {
989
1018
  }
990
1019
  else if (delta.delete || typeof delta.insert === "string") {
991
1020
  pending ??= { from: offset, to: offset, insert: "", insertLength: 0,
992
- inferred: isExternalOrigin(transaction.origin) };
1021
+ inferred: isExternalOrigin(transaction.origin) && transaction.origin.exact !== true };
993
1022
  if (delta.delete) {
994
1023
  offset += delta.delete;
995
1024
  pending.to = offset;
@@ -1585,6 +1614,8 @@ export class CollaborationService {
1585
1614
  catch { /* Source durability must not depend on optional history bookkeeping. */ }
1586
1615
  }
1587
1616
  const ok = failedPaths.length === 0 && !roomHasPendingChanges(room);
1617
+ if (ok && finishSuggestionApplications(this.db, room.projectId, room.doc))
1618
+ this.signalComments(room.projectId);
1588
1619
  if (changed)
1589
1620
  room.persistedRevision += 1;
1590
1621
  if (ok) {
@@ -57,6 +57,10 @@ export function createCommentMentions(db, input) {
57
57
  ON CONFLICT DO UPDATE SET
58
58
  mentioned_by_user_id = excluded.mentioned_by_user_id,
59
59
  created_at = excluded.created_at,
60
+ kind = CASE WHEN excluded.reply_id IS NULL AND EXISTS (
61
+ SELECT 1 FROM comment_suggestions suggestion WHERE suggestion.comment_id = excluded.comment_id
62
+ AND suggestion.status = 'pending' AND suggestion.reviewer_id = excluded.mentioned_user_id
63
+ ) THEN 'review' ELSE 'mention' END,
60
64
  read_at = NULL,
61
65
  read_reason = NULL`);
62
66
  for (const recipient of recipients) {
@@ -80,6 +84,7 @@ export function unreadMentionCountsForProjects(db, projectIds, userId) {
80
84
  }
81
85
  function mentionFromRow(row) {
82
86
  return {
87
+ kind: row.kind,
83
88
  id: row.id,
84
89
  projectId: row.project_id,
85
90
  commentId: row.comment_id,
@@ -92,7 +97,7 @@ function mentionFromRow(row) {
92
97
  readReason: row.read_reason
93
98
  };
94
99
  }
95
- const mentionSelect = `SELECT mention.id, mention.project_id, mention.comment_id, mention.reply_id,
100
+ const mentionSelect = `SELECT mention.kind, mention.id, mention.project_id, mention.comment_id, mention.reply_id,
96
101
  comment.file_path, comment.content AS comment_content, reply.content AS reply_content,
97
102
  comment.resolved, mention.created_at, mention.read_at, mention.read_reason
98
103
  FROM comment_mentions mention
@@ -0,0 +1,143 @@
1
+ import * as Y from "yjs";
2
+ import { createSourceAnchor, offsetToLine } from "./anchors.js";
3
+ import { httpError } from "./http.js";
4
+ import { MAX_SUGGESTION_LENGTH } from "../shared/comments.js";
5
+ import { randomUUID } from "node:crypto";
6
+ export function attachSuggestion(db, projectId, commentId, authorId, original, input) {
7
+ if (!input || typeof input !== "object")
8
+ throw httpError(400, "SUGGESTION_INVALID");
9
+ const { replacementText, reviewerId } = input;
10
+ validateSuggestionReplacement(original, replacementText);
11
+ if (reviewerId === authorId)
12
+ throw httpError(400, "SUGGESTION_SELF_REVIEW");
13
+ if (typeof reviewerId !== "string" || !suggestionReviewers(db, projectId, authorId).some((user) => user.id === reviewerId))
14
+ throw httpError(400, "SUGGESTION_REVIEWER_INVALID");
15
+ if (suggestionRow(db, projectId, commentId))
16
+ throw httpError(409, "SUGGESTION_EXISTS");
17
+ db.prepare("INSERT INTO comment_suggestions (comment_id, original_text, replacement_text, reviewer_id) VALUES (?, ?, ?, ?)")
18
+ .run(commentId, original, replacementText, reviewerId);
19
+ requestSuggestionReview(db, projectId, commentId, reviewerId, authorId, new Date().toISOString());
20
+ }
21
+ export function validateSuggestionReplacement(original, replacement) {
22
+ if (!original || original.length > MAX_SUGGESTION_LENGTH || typeof replacement !== "string"
23
+ || replacement.length > MAX_SUGGESTION_LENGTH || replacement === original || replacement.includes("\0"))
24
+ throw httpError(400, "SUGGESTION_INVALID");
25
+ }
26
+ export function suggestionReviewers(db, projectId, authorId) {
27
+ return db.prepare(`SELECT u.id, u.username, u.display_name AS displayName FROM users u
28
+ JOIN projects p ON p.id = ? LEFT JOIN project_members m ON m.project_id = p.id AND m.user_id = u.id
29
+ WHERE u.disabled = 0 AND (u.id = p.owner_id OR m.permission = 'edit') AND (? IS NULL OR u.id <> ?)
30
+ ORDER BY u.display_name COLLATE NOCASE, u.username COLLATE NOCASE`).all(projectId, authorId ?? null, authorId ?? null);
31
+ }
32
+ export function requestSuggestionReview(db, projectId, commentId, reviewerId, authorId, at) {
33
+ if (reviewerId === authorId)
34
+ return;
35
+ db.prepare(`INSERT INTO comment_mentions (id, project_id, comment_id, mentioned_user_id, mentioned_by_user_id, created_at, kind)
36
+ VALUES (?, ?, ?, ?, ?, ?, 'review') ON CONFLICT DO UPDATE SET kind = 'review', read_at = NULL,
37
+ read_reason = NULL, created_at = excluded.created_at, mentioned_by_user_id = excluded.mentioned_by_user_id`)
38
+ .run(randomUUID(), projectId, commentId, reviewerId, authorId, at);
39
+ }
40
+ export function clearSuggestionReview(db, commentId, at) {
41
+ db.prepare("UPDATE comment_mentions SET read_at = ?, read_reason = 'manual' WHERE comment_id = ? AND kind = 'review' AND read_at IS NULL").run(at, commentId);
42
+ }
43
+ export function suggestionRow(db, projectId, commentId) {
44
+ return db.prepare(`SELECT s.*, c.author_id, c.file_path, c.start_offset, c.end_offset, c.orphaned FROM comment_suggestions s
45
+ JOIN comments c ON c.id = s.comment_id WHERE c.project_id = ? AND c.id = ?`).get(projectId, commentId);
46
+ }
47
+ export function hasPendingSuggestionApplication(db, projectId) {
48
+ return !!db.prepare(`SELECT 1 FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
49
+ WHERE c.project_id = ? AND s.apply_update IS NOT NULL LIMIT 1`).get(projectId);
50
+ }
51
+ /** One query per discussion list, not one query per thread. */
52
+ export function suggestionsForProject(db, projectId, sources) {
53
+ const reviewers = new Set(suggestionReviewers(db, projectId).map((user) => user.id));
54
+ const rows = db.prepare(`SELECT s.*, c.author_id, c.file_path, c.start_offset, c.end_offset, c.orphaned,
55
+ reviewer.username AS reviewerUsername, reviewer.display_name AS reviewerDisplayName,
56
+ decider.username AS decidedByUsername, decider.display_name AS decidedByDisplayName
57
+ FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
58
+ LEFT JOIN users reviewer ON reviewer.id = s.reviewer_id LEFT JOIN users decider ON decider.id = s.decided_by
59
+ WHERE c.project_id = ?`).all(projectId);
60
+ return new Map(rows.map((row) => [row.comment_id, {
61
+ originalText: row.original_text, replacementText: row.replacement_text, reviewerId: row.reviewer_id,
62
+ reviewerUsername: row.reviewerUsername, reviewerDisplayName: row.reviewerDisplayName,
63
+ reviewerAvailable: row.reviewer_id !== null && row.reviewer_id !== row.author_id && reviewers.has(row.reviewer_id), status: row.status,
64
+ applicable: !row.orphaned && sources.get(row.file_path)?.slice(row.start_offset, row.end_offset) === row.original_text,
65
+ applying: row.apply_update !== null, decidedById: row.decided_by, decidedAt: row.decided_at,
66
+ decidedByUsername: row.decidedByUsername, decidedByDisplayName: row.decidedByDisplayName
67
+ }]));
68
+ }
69
+ /** Journal a CRDT update BEFORE applying it. Its item IDs make every replay idempotent. */
70
+ export function prepareSuggestionApplication(db, projectId, commentId, doc, userId, maxBytes) {
71
+ const row = suggestionRow(db, projectId, commentId);
72
+ if (!row)
73
+ throw httpError(404, "COMMENT_NOT_FOUND");
74
+ if (row.apply_update)
75
+ return row.apply_update;
76
+ if (row.status !== "pending")
77
+ throw httpError(409, "SUGGESTION_DECIDED");
78
+ const name = `source:${row.file_path}`;
79
+ const text = doc.getText(name);
80
+ if (row.orphaned || row.end_offset <= row.start_offset || text.toString().slice(row.start_offset, row.end_offset) !== row.original_text) {
81
+ throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
82
+ }
83
+ const source = text.toString();
84
+ if (Buffer.byteLength(source.slice(0, row.start_offset) + row.replacement_text + source.slice(row.end_offset), "utf8") > maxBytes) {
85
+ throw httpError(413, "FILE_TOO_LARGE", { path: row.file_path, size: Math.floor(maxBytes / 1024 / 1024) });
86
+ }
87
+ const copy = new Y.Doc();
88
+ try {
89
+ Y.applyUpdate(copy, Y.encodeStateAsUpdate(doc));
90
+ const vector = Y.encodeStateVector(copy);
91
+ const target = copy.getText(name);
92
+ copy.transact(() => {
93
+ target.delete(row.start_offset, row.end_offset - row.start_offset);
94
+ target.insert(row.start_offset, row.replacement_text);
95
+ });
96
+ const update = Y.encodeStateAsUpdate(copy, vector);
97
+ const range = JSON.stringify([
98
+ Y.relativePositionToJSON(Y.createRelativePositionFromTypeIndex(target, row.start_offset, 0)),
99
+ Y.relativePositionToJSON(Y.createRelativePositionFromTypeIndex(target, row.start_offset + row.replacement_text.length, -1))
100
+ ]);
101
+ db.prepare("UPDATE comment_suggestions SET apply_update = ?, apply_range = ?, decided_by = ?, decided_at = ? WHERE comment_id = ?")
102
+ .run(Buffer.from(update), range, userId, new Date().toISOString(), commentId);
103
+ return update;
104
+ }
105
+ finally {
106
+ copy.destroy();
107
+ }
108
+ }
109
+ /** Called while hydrating a room, before accepting any client edits. */
110
+ export function recoverSuggestionApplications(db, projectId, doc, recoveredState) {
111
+ const rows = db.prepare(`SELECT s.apply_update FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
112
+ WHERE c.project_id = ? AND s.apply_update IS NOT NULL`).all(projectId);
113
+ if (rows.length && !recoveredState)
114
+ throw httpError(409, "SUGGESTION_RECOVERY_FAILED");
115
+ for (const row of rows)
116
+ Y.applyUpdate(doc, row.apply_update);
117
+ return rows.length > 0;
118
+ }
119
+ /** Source, Yjs state and anchors must be durable before marking an application accepted. */
120
+ export function finishSuggestionApplications(db, projectId, doc) {
121
+ const rows = db.prepare(`SELECT s.*, c.file_path FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
122
+ WHERE c.project_id = ? AND s.apply_update IS NOT NULL`).all(projectId);
123
+ if (!rows.length)
124
+ return false;
125
+ db.transaction(() => {
126
+ for (const row of rows) {
127
+ const positions = JSON.parse(row.apply_range);
128
+ const start = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(positions[0]), doc);
129
+ const end = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(positions[1]), doc);
130
+ const text = doc.getText(`source:${row.file_path}`);
131
+ if (start?.type === text && end?.type === text) {
132
+ const source = text.toString();
133
+ const anchor = createSourceAnchor(source, start.index, end.index);
134
+ db.prepare(`UPDATE comments SET selected_text = ?, start_offset = ?, end_offset = ?, context_before = ?, context_after = ?,
135
+ orphaned = 0, start_line = ?, end_line = ?, updated_at = ? WHERE id = ?`)
136
+ .run(anchor.selectedText, anchor.startOffset, anchor.endOffset, anchor.contextBefore, anchor.contextAfter, offsetToLine(source, anchor.startOffset), offsetToLine(source, anchor.endOffset), row.decided_at, row.comment_id);
137
+ }
138
+ db.prepare("UPDATE comment_suggestions SET status = 'accepted', apply_update = NULL, apply_range = NULL WHERE comment_id = ?").run(row.comment_id);
139
+ clearSuggestionReview(db, row.comment_id, row.decided_at);
140
+ }
141
+ })();
142
+ return true;
143
+ }
package/dist/server/db.js CHANGED
@@ -93,6 +93,87 @@ const databaseMigrations = [
93
93
  if (missingColumn(db, "agent_tasks", "native_cleanup_done")) {
94
94
  db.exec("ALTER TABLE agent_tasks ADD COLUMN native_cleanup_done INTEGER NOT NULL DEFAULT 0 CHECK (native_cleanup_done IN (0, 1))");
95
95
  }
96
+ } },
97
+ { version: 12, name: "add_comment_suggestions", apply: (db) => {
98
+ db.exec(`CREATE TABLE IF NOT EXISTS comment_suggestions (
99
+ comment_id TEXT PRIMARY KEY REFERENCES comments(id) ON DELETE CASCADE,
100
+ original_text TEXT NOT NULL,
101
+ replacement_text TEXT NOT NULL,
102
+ reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL,
103
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'accepted', 'rejected')),
104
+ decided_by TEXT REFERENCES users(id) ON DELETE SET NULL,
105
+ decided_at TEXT,
106
+ apply_update BLOB,
107
+ apply_range TEXT
108
+ );
109
+ `);
110
+ if (missingColumn(db, "comment_mentions", "kind"))
111
+ db.exec("ALTER TABLE comment_mentions ADD COLUMN kind TEXT NOT NULL DEFAULT 'mention' CHECK (kind IN ('mention', 'review'))");
112
+ } },
113
+ { version: 13, name: "move_reviewer_to_comments", apply: (db) => {
114
+ if (missingColumn(db, "comments", "reviewer_id"))
115
+ db.exec("ALTER TABLE comments ADD COLUMN reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL");
116
+ if (!missingColumn(db, "comment_suggestions", "reviewer_id")) {
117
+ db.exec(`UPDATE comments SET reviewer_id = (
118
+ SELECT reviewer_id FROM comment_suggestions WHERE comment_id = comments.id
119
+ ) WHERE id IN (SELECT comment_id FROM comment_suggestions);
120
+ ALTER TABLE comment_suggestions DROP COLUMN reviewer_id;`);
121
+ }
122
+ } },
123
+ { version: 14, name: "keep_reviewers_on_suggestions", apply: (db) => {
124
+ if (missingColumn(db, "comment_suggestions", "reviewer_id"))
125
+ db.exec("ALTER TABLE comment_suggestions ADD COLUMN reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL");
126
+ if (!missingColumn(db, "comments", "reviewer_id")) {
127
+ db.exec(`UPDATE comment_suggestions SET reviewer_id = (
128
+ SELECT reviewer_id FROM comments WHERE id = comment_suggestions.comment_id
129
+ );
130
+ DELETE FROM comment_mentions WHERE kind = 'review' AND comment_id NOT IN (SELECT comment_id FROM comment_suggestions);
131
+ ALTER TABLE comments DROP COLUMN reviewer_id;`);
132
+ }
133
+ } },
134
+ { version: 15, name: "add_project_view_links", apply: (db) => {
135
+ db.exec(`CREATE TABLE IF NOT EXISTS project_view_links (
136
+ id TEXT PRIMARY KEY,
137
+ project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
138
+ token_hash TEXT NOT NULL UNIQUE,
139
+ label TEXT NOT NULL DEFAULT '',
140
+ created_at TEXT NOT NULL,
141
+ expires_at TEXT,
142
+ revoked_at TEXT
143
+ );
144
+ CREATE INDEX IF NOT EXISTS project_view_links_project ON project_view_links(project_id, created_at DESC);`);
145
+ } },
146
+ { version: 16, name: "remove_revoked_project_view_links", apply: (db) => {
147
+ if (missingColumn(db, "project_view_links", "revoked_at"))
148
+ return;
149
+ db.exec(`DELETE FROM project_view_links WHERE revoked_at IS NOT NULL;
150
+ ALTER TABLE project_view_links DROP COLUMN revoked_at;`);
151
+ } },
152
+ { version: 17, name: "store_encrypted_view_link_tokens", apply: (db) => {
153
+ if (missingColumn(db, "project_view_links", "token_ciphertext")) {
154
+ db.exec("ALTER TABLE project_view_links ADD COLUMN token_ciphertext TEXT");
155
+ }
156
+ } },
157
+ { version: 18, name: "add_citation_collections", apply: (db) => {
158
+ db.exec(`CREATE TABLE IF NOT EXISTS citation_library_collections (
159
+ id TEXT PRIMARY KEY,
160
+ user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
161
+ name TEXT NOT NULL COLLATE NOCASE,
162
+ created_at TEXT NOT NULL,
163
+ UNIQUE (user_id, name)
164
+ );
165
+ CREATE TABLE IF NOT EXISTS citation_library_entry_collections (
166
+ entry_id TEXT NOT NULL REFERENCES citation_library_entries(id) ON DELETE CASCADE,
167
+ collection_id TEXT NOT NULL REFERENCES citation_library_collections(id) ON DELETE CASCADE,
168
+ PRIMARY KEY (entry_id, collection_id)
169
+ );
170
+ CREATE INDEX IF NOT EXISTS citation_library_entry_collections_collection
171
+ ON citation_library_entry_collections(collection_id, entry_id);`);
172
+ } },
173
+ { version: 19, name: "add_citation_notes", apply: (db) => {
174
+ if (missingColumn(db, "citation_library_entries", "notes")) {
175
+ db.exec("ALTER TABLE citation_library_entries ADD COLUMN notes TEXT NOT NULL DEFAULT ''");
176
+ }
96
177
  } }
97
178
  ];
98
179
  function migrateGitHubTokensToUsers(db) {
@@ -6,7 +6,13 @@
6
6
  import { supportedLocale } from "../shared/locales.js";
7
7
  import { zhHantMessages } from "./locales/zh-Hant.js";
8
8
  import { agentMessages } from "../shared/agentMessages.js";
9
+ import { suggestionMessages } from "../shared/suggestionMessages.js";
10
+ import { viewLinkMessages } from "../shared/projectViewLinks.js";
11
+ import { citationCollectionMessages } from "../shared/citationCollections.js";
9
12
  const enMessages = {
13
+ ...citationCollectionMessages.en,
14
+ ...viewLinkMessages.en,
15
+ ...suggestionMessages.en,
10
16
  ...agentMessages.en,
11
17
  AVATAR_STYLE_INVALID: "Choose a supported avatar style.",
12
18
  AVATAR_NOT_FOUND: "No custom avatar is configured for this user.",
@@ -150,6 +156,9 @@ const enMessages = {
150
156
  GIT_OPERATION_FAILED: "The Git operation could not be completed."
151
157
  };
152
158
  const zhMessages = {
159
+ ...viewLinkMessages.zh,
160
+ ...citationCollectionMessages.zh,
161
+ ...suggestionMessages.zh,
153
162
  ...agentMessages.zh,
154
163
  AVATAR_STYLE_INVALID: "请选择支持的头像风格。",
155
164
  AVATAR_NOT_FOUND: "该用户尚未设置自定义头像。",
@@ -1,6 +1,12 @@
1
1
  import { agentMessages } from "../../shared/agentMessages.js";
2
+ import { suggestionMessages } from "../../shared/suggestionMessages.js";
3
+ import { viewLinkMessages } from "../../shared/projectViewLinks.js";
4
+ import { citationCollectionMessages } from "../../shared/citationCollections.js";
2
5
  /** Traditional Chinese API messages, using the same stable error codes. */
3
6
  export const zhHantMessages = {
7
+ ...viewLinkMessages["zh-Hant"],
8
+ ...citationCollectionMessages["zh-Hant"],
9
+ ...suggestionMessages["zh-Hant"],
4
10
  ...agentMessages["zh-Hant"],
5
11
  AVATAR_STYLE_INVALID: "請選擇支援的頭像風格。",
6
12
  AVATAR_NOT_FOUND: "該使用者尚未設定自訂頭像。",
@@ -0,0 +1,133 @@
1
+ import fs from "node:fs";
2
+ import { resolveSourcePath } from "./files.js";
3
+ import { maskLatexComments, maskLatexLiteralContent } from "../shared/latexLiterals.js";
4
+ import { forEachLatexCommand, readLatexMandatoryArguments } from "../shared/latexScanner.js";
5
+ export const PROJECT_PREVIEW_BYTES = 64 * 1024;
6
+ const sentences = new Intl.Segmenter(undefined, { granularity: "sentence" });
7
+ const omittedCommands = new Set(["label", "ref", "eqref", "pageref", "cite", "citep", "citet", "citealp", "citeauthor", "citeyear",
8
+ "autocite", "parencite", "textcite", "footcite", "footnote", "thanks", "url", "input", "include", "includegraphics", "bibliography", "bibliographystyle"]);
9
+ /** Display-only text, not TeX expansion or source used by compilation. */
10
+ function previewText(value) {
11
+ const source = maskLatexComments(maskLatexLiteralContent(value));
12
+ const fragments = [];
13
+ let cursor = 0;
14
+ forEachLatexCommand(source, (command) => {
15
+ if (command.from < cursor)
16
+ return;
17
+ fragments.push(source.slice(cursor, command.from));
18
+ const argument = omittedCommands.has(command.name) || command.name === "begin" || command.name === "end"
19
+ ? readLatexMandatoryArguments(source, command.to, 1)[0] : undefined;
20
+ cursor = argument?.to ?? command.to;
21
+ if (command.name === "LaTeX" || command.name === "TeX")
22
+ fragments.push(command.name);
23
+ else if (/^[%&_$#]$/.test(command.name))
24
+ fragments.push(command.name);
25
+ else if (command.name === "\\" || command.name === "par")
26
+ fragments.push(" ");
27
+ });
28
+ fragments.push(source.slice(cursor));
29
+ return fragments.join("").replace(/[{}$]/g, "").replace(/~/g, " ").replace(/\s+/g, " ").replace(/\s+([,.;:!?,。;:!?])/gu, "$1").trim();
30
+ }
31
+ function excerpt(value) {
32
+ const first = sentences.segment(value)[Symbol.iterator]().next().value?.segment.trim() ?? "";
33
+ const characters = Array.from(first);
34
+ return characters.length > 240 ? `${characters.slice(0, 240).join("")}…` : first;
35
+ }
36
+ /** Abstract first sentence, then title. Never guess metadata from document-body commands. */
37
+ export function extractProjectPreview(source) {
38
+ let title = "", abstractStart = -1, abstractEnd = -1, bodyStart = -1, bodyEnd = source.length;
39
+ forEachLatexCommand(source, (command) => {
40
+ if (!["title", "begin", "end"].includes(command.name))
41
+ return;
42
+ const argument = readLatexMandatoryArguments(source, command.to, 1)[0];
43
+ if (!argument)
44
+ return;
45
+ const value = source.slice(argument.contentFrom, argument.contentTo);
46
+ if (command.name === "title" && !title)
47
+ title = previewText(value);
48
+ if (command.name === "begin" && value.trim() === "abstract" && abstractStart < 0)
49
+ abstractStart = argument.to;
50
+ if (command.name === "end" && value.trim() === "abstract" && abstractStart >= 0 && abstractEnd < 0)
51
+ abstractEnd = command.from;
52
+ if (command.name === "begin" && value.trim() === "document" && bodyStart < 0)
53
+ bodyStart = argument.to;
54
+ if (command.name === "end" && value.trim() === "document" && bodyStart >= 0)
55
+ bodyEnd = command.from;
56
+ });
57
+ const abstract = abstractStart >= 0 && abstractEnd >= abstractStart ? excerpt(previewText(source.slice(abstractStart, abstractEnd))) : "";
58
+ if (abstract)
59
+ return abstract;
60
+ if (title)
61
+ return Array.from(title).slice(0, 240).join("");
62
+ if (bodyStart >= 0) {
63
+ const body = source.slice(bodyStart, bodyEnd);
64
+ // Only inspect the body to distinguish genuinely empty documents from
65
+ // unavailable metadata. Formatting arguments and includes are not prose.
66
+ return maskLatexComments(body).trim() ? null : "";
67
+ }
68
+ return maskLatexComments(source).trim() ? null : "";
69
+ }
70
+ /** Bounded main-file reads, coalesced across users and cached by file metadata. */
71
+ export class ProjectPreviewService {
72
+ config;
73
+ cache = new Map();
74
+ pending = new Map();
75
+ constructor(config) {
76
+ this.config = config;
77
+ }
78
+ read(projectId, mainFile) {
79
+ let file;
80
+ try {
81
+ file = resolveSourcePath(this.config, projectId, mainFile);
82
+ }
83
+ catch {
84
+ return Promise.resolve(null);
85
+ }
86
+ const existing = this.pending.get(file);
87
+ if (existing)
88
+ return existing;
89
+ const request = this.readFile(file).finally(() => { if (this.pending.get(file) === request)
90
+ this.pending.delete(file); });
91
+ this.pending.set(file, request);
92
+ return request;
93
+ }
94
+ async readFile(file) {
95
+ try {
96
+ const stat = await fs.promises.stat(file);
97
+ if (!stat.isFile())
98
+ return null;
99
+ const signature = `${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
100
+ const cached = this.cache.get(file);
101
+ if (cached?.signature === signature) {
102
+ this.cache.delete(file);
103
+ this.cache.set(file, cached);
104
+ return cached.preview;
105
+ }
106
+ const handle = await fs.promises.open(file, "r");
107
+ let source;
108
+ try {
109
+ const buffer = Buffer.alloc(Math.min(stat.size, PROJECT_PREVIEW_BYTES));
110
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
111
+ const bytes = buffer.subarray(0, bytesRead);
112
+ if (bytes.includes(0))
113
+ return null;
114
+ source = new TextDecoder("utf-8").decode(bytes, { stream: true });
115
+ }
116
+ finally {
117
+ await handle.close();
118
+ }
119
+ const extracted = extractProjectPreview(source);
120
+ // An empty prefix says nothing about content beyond the bounded read.
121
+ const preview = extracted === "" && stat.size > PROJECT_PREVIEW_BYTES ? null : extracted;
122
+ this.cache.delete(file);
123
+ this.cache.set(file, { signature, preview });
124
+ if (this.cache.size > 128)
125
+ this.cache.delete(this.cache.keys().next().value);
126
+ return preview;
127
+ }
128
+ catch {
129
+ this.cache.delete(file);
130
+ return null;
131
+ }
132
+ }
133
+ }