texlite 0.21.0 → 0.23.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 (316) hide show
  1. package/DESIGN.md +174 -22
  2. package/OPERATIONS.md +23 -3
  3. package/README.md +44 -37
  4. package/README.zh-CN.md +38 -31
  5. package/addon.md +76 -0
  6. package/dist/client/assets/AdminUsers-xuVuiwoh.js +1 -0
  7. package/dist/client/assets/AdminUsers-xuVuiwoh.js.br +0 -0
  8. package/dist/client/assets/AdminUsers-xuVuiwoh.js.gz +0 -0
  9. package/dist/client/assets/{AgentIcon-dCMgWJG-.css → AgentIcon-DJGGRJnV.css} +1 -1
  10. package/dist/client/assets/AgentIcon-DJGGRJnV.css.br +0 -0
  11. package/dist/client/assets/AgentIcon-DJGGRJnV.css.gz +0 -0
  12. package/dist/client/assets/{AgentManagement-0n1UkKZ5.js → AgentManagement-D-0hrv6f.js} +1 -1
  13. package/dist/client/assets/AgentManagement-D-0hrv6f.js.br +0 -0
  14. package/dist/client/assets/AgentManagement-D-0hrv6f.js.gz +0 -0
  15. package/dist/client/assets/AgentTerminal-DZo-22RN.js +2 -0
  16. package/dist/client/assets/AgentTerminal-DZo-22RN.js.br +0 -0
  17. package/dist/client/assets/AgentTerminal-DZo-22RN.js.gz +0 -0
  18. package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js +16 -0
  19. package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.br +0 -0
  20. package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.gz +0 -0
  21. package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js +1 -0
  22. package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.br +0 -0
  23. package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.gz +0 -0
  24. package/dist/client/assets/CitationBibtexEditor-BZIU4Lif.js +1 -0
  25. package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js +3 -0
  26. package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.br +0 -0
  27. package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.gz +0 -0
  28. package/dist/client/assets/CitationNotesPreview-D3CjBD0p.js +1 -0
  29. package/dist/client/assets/Dashboard-BYgqCgBM.js +5 -0
  30. package/dist/client/assets/Dashboard-BYgqCgBM.js.br +0 -0
  31. package/dist/client/assets/Dashboard-BYgqCgBM.js.gz +0 -0
  32. package/dist/client/assets/GitDialog-CA68baSd.js +4 -0
  33. package/dist/client/assets/GitDialog-CA68baSd.js.br +0 -0
  34. package/dist/client/assets/GitDialog-CA68baSd.js.gz +0 -0
  35. package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js +1 -0
  36. package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.br +0 -0
  37. package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.gz +0 -0
  38. package/dist/client/assets/HistoryDialog-c2EEaFsl.js +8 -0
  39. package/dist/client/assets/HistoryDialog-c2EEaFsl.js.br +0 -0
  40. package/dist/client/assets/HistoryDialog-c2EEaFsl.js.gz +0 -0
  41. package/dist/client/assets/InfoPopover-BJYnFn1P.js +1 -0
  42. package/dist/client/assets/LatexEditor-vNOVTIl7.js +25 -0
  43. package/dist/client/assets/LatexEditor-vNOVTIl7.js.br +0 -0
  44. package/dist/client/assets/LatexEditor-vNOVTIl7.js.gz +0 -0
  45. package/dist/client/assets/MarkdownContent-BeKi2gI5.js +36 -0
  46. package/dist/client/assets/MarkdownContent-BeKi2gI5.js.br +0 -0
  47. package/dist/client/assets/MarkdownContent-BeKi2gI5.js.gz +0 -0
  48. package/dist/client/assets/MarkdownPreview-BJPqGTcw.js +1 -0
  49. package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.br +0 -0
  50. package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.gz +0 -0
  51. package/dist/client/assets/{ProjectIconPickerDialog-DAiP7wVe.js → ProjectIconPickerDialog-ChiEUQ0g.js} +1 -1
  52. package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.br +0 -0
  53. package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.gz +0 -0
  54. package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js +1 -0
  55. package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.br +0 -0
  56. package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.gz +0 -0
  57. package/dist/client/assets/ProjectSettings-BwQTbXhh.js +4 -0
  58. package/dist/client/assets/ProjectSettings-BwQTbXhh.js.br +0 -0
  59. package/dist/client/assets/ProjectSettings-BwQTbXhh.js.gz +0 -0
  60. package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js +25 -0
  61. package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.br +0 -0
  62. package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.gz +0 -0
  63. package/dist/client/assets/{QuickOpenDialog-kW-97LBY.js → QuickOpenDialog-B7NTqOpu.js} +1 -1
  64. package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.br +0 -0
  65. package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.gz +0 -0
  66. package/dist/client/assets/{ReadOnlySource-B-ZZIpJq.js → ReadOnlySource-DIalHHvP.js} +2 -2
  67. package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js +3 -0
  68. package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.br +0 -0
  69. package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.gz +0 -0
  70. package/dist/client/assets/SharedProjectPage-s-khOyvB.js +2 -0
  71. package/dist/client/assets/SharedProjectPage-s-khOyvB.js.br +0 -0
  72. package/dist/client/assets/SharedProjectPage-s-khOyvB.js.gz +0 -0
  73. package/dist/client/assets/{SystemMetricsDialog-Dz_zxjfR.js → SystemMetricsDialog-Bycm88U1.js} +1 -1
  74. package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.br +0 -0
  75. package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.gz +0 -0
  76. package/dist/client/assets/TagManagementDialog-DwUAA8uC.js +1 -0
  77. package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.br +0 -0
  78. package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.gz +0 -0
  79. package/dist/client/assets/ThemeSwitcher-RSqZi7kx.js +1 -0
  80. package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css +1 -0
  81. package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.br +0 -0
  82. package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.gz +0 -0
  83. package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js +1 -0
  84. package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.br +0 -0
  85. package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.gz +0 -0
  86. package/dist/client/assets/WordCountDialog-ByxE-RUs.js +1 -0
  87. package/dist/client/assets/WordCountDialog-ByxE-RUs.js.br +0 -0
  88. package/dist/client/assets/WordCountDialog-ByxE-RUs.js.gz +0 -0
  89. package/dist/client/assets/{bibtexFormatterWorker-B_jvobIv.js → bibtexFormatterWorker-Bp8kjjvw.js} +14 -14
  90. package/dist/client/assets/bibtexFormatterWorker-Bp8kjjvw.js.br +0 -0
  91. package/dist/client/assets/bibtexFormatterWorker-Bp8kjjvw.js.gz +0 -0
  92. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js +2 -0
  93. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js.br +0 -0
  94. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js.gz +0 -0
  95. package/dist/client/assets/bibtexNames-CPGbBJxd.js +1 -0
  96. package/dist/client/assets/bibtexReferences-xpSF8IXH.js +1 -0
  97. package/dist/client/assets/bot-ClmnQ29j.js +1 -0
  98. package/dist/client/assets/{chktex-CCcr_9m7.js → chktex-22lKGvKa.js} +2 -2
  99. package/dist/client/assets/citationAuthors-BWHXhKvT.js +1 -0
  100. package/dist/client/assets/citationAuthors-BWHXhKvT.js.br +0 -0
  101. package/dist/client/assets/citationAuthors-BWHXhKvT.js.gz +0 -0
  102. package/dist/client/assets/citationLibrary-DxGdbZEQ.js +1 -0
  103. package/dist/client/assets/citationLibrary-DxGdbZEQ.js.br +0 -0
  104. package/dist/client/assets/citationLibrary-DxGdbZEQ.js.gz +0 -0
  105. package/dist/client/assets/dist-Dxkdrap6.js +2 -0
  106. package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
  107. package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
  108. package/dist/client/assets/editor-CkUEg2La.js +14 -0
  109. package/dist/client/assets/editor-CkUEg2La.js.br +0 -0
  110. package/dist/client/assets/editor-CkUEg2La.js.gz +0 -0
  111. package/dist/client/assets/editor-languages-kcWr1Z3Q.js +36 -0
  112. package/dist/client/assets/editor-languages-kcWr1Z3Q.js.br +0 -0
  113. package/dist/client/assets/editor-languages-kcWr1Z3Q.js.gz +0 -0
  114. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js +1 -0
  115. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.br +0 -0
  116. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.gz +0 -0
  117. package/dist/client/assets/generatedParser-CZa2vsK6.js +1 -0
  118. package/dist/client/assets/generatedParser-CZa2vsK6.js.br +0 -0
  119. package/dist/client/assets/generatedParser-CZa2vsK6.js.gz +0 -0
  120. package/dist/client/assets/git-compare-arrows-158rS_vn.js +1 -0
  121. package/dist/client/assets/i18n-Wn96VbWM.js +13 -0
  122. package/dist/client/assets/i18n-Wn96VbWM.js.br +0 -0
  123. package/dist/client/assets/i18n-Wn96VbWM.js.gz +0 -0
  124. package/dist/client/assets/index-CemLYDYL.js +2 -0
  125. package/dist/client/assets/index-CemLYDYL.js.br +0 -0
  126. package/dist/client/assets/index-CemLYDYL.js.gz +0 -0
  127. package/dist/client/assets/index-DSF5eT29.css +1 -0
  128. package/dist/client/assets/index-DSF5eT29.css.br +0 -0
  129. package/dist/client/assets/index-DSF5eT29.css.gz +0 -0
  130. package/dist/client/assets/katex-Ca9qmXPj.js +257 -0
  131. package/dist/client/assets/katex-Ca9qmXPj.js.br +0 -0
  132. package/dist/client/assets/katex-Ca9qmXPj.js.gz +0 -0
  133. package/dist/client/assets/katex.min-VLoWtPY0.js +1 -0
  134. package/dist/client/assets/{latexFormatterWorker-BIDCSZPd.js → latexFormatterWorker-BWiogBYE.js} +1 -1
  135. package/dist/client/assets/latexFormatterWorker-BWiogBYE.js.br +0 -0
  136. package/dist/client/assets/latexFormatterWorker-BWiogBYE.js.gz +0 -0
  137. package/dist/client/assets/latexScanner-D9bMX44Y.js +6 -0
  138. package/dist/client/assets/latexScanner-D9bMX44Y.js.br +0 -0
  139. package/dist/client/assets/latexScanner-D9bMX44Y.js.gz +0 -0
  140. package/dist/client/assets/palette-8_-Y5XON.js +1 -0
  141. package/dist/client/assets/relativeTime-C-GTw3lA.js +1 -0
  142. package/dist/client/assets/relativeTime-C-GTw3lA.js.br +0 -0
  143. package/dist/client/assets/relativeTime-C-GTw3lA.js.gz +0 -0
  144. package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js +1 -0
  145. package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.br +0 -0
  146. package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.gz +0 -0
  147. package/dist/client/assets/{spellCheck-D-tYd_ac.js → spellCheck-kxvnxrvw.js} +1 -1
  148. package/dist/client/assets/spellCheck-kxvnxrvw.js.br +0 -0
  149. package/dist/client/assets/spellCheck-kxvnxrvw.js.gz +0 -0
  150. package/dist/client/assets/{textLanguageSupport-Kz9ESEVW.js → textLanguageSupport-Ck8lMOWz.js} +1 -1
  151. package/dist/client/assets/{textLanguages-Dac6mieP.js → textLanguages-CwWstpJ5.js} +5 -5
  152. package/dist/client/assets/textLanguages-CwWstpJ5.js.br +0 -0
  153. package/dist/client/assets/textLanguages-CwWstpJ5.js.gz +0 -0
  154. package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js +1 -0
  155. package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.br +0 -0
  156. package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.gz +0 -0
  157. package/dist/client/assets/{vimSupport-DWYaSMuX.js → vimSupport-C-WiMLjc.js} +6 -6
  158. package/dist/client/assets/vimSupport-C-WiMLjc.js.br +0 -0
  159. package/dist/client/assets/{vimSupport-DWYaSMuX.js.gz → vimSupport-C-WiMLjc.js.gz} +0 -0
  160. package/dist/client/index.html +3 -3
  161. package/dist/server/agentChanges.js +149 -0
  162. package/dist/server/agents/sessions.js +1 -1
  163. package/dist/server/agents/workspaces.js +21 -28
  164. package/dist/server/app.js +15 -6
  165. package/dist/server/boundedExpiringCache.js +69 -0
  166. package/dist/server/citationFolderTransfer.js +5 -5
  167. package/dist/server/citationInput.js +1 -0
  168. package/dist/server/cli.js +12 -1
  169. package/dist/server/collaboration.js +8 -4
  170. package/dist/server/config.js +10 -0
  171. package/dist/server/db.js +23 -0
  172. package/dist/server/editHistory.js +71 -12
  173. package/dist/server/git.js +58 -7
  174. package/dist/server/history.js +58 -9
  175. package/dist/server/i18n.js +12 -0
  176. package/dist/server/locales/zh-Hant.js +6 -0
  177. package/dist/server/projectReferences.js +110 -9
  178. package/dist/server/routes/auth.js +3 -0
  179. package/dist/server/routes/citations.js +28 -61
  180. package/dist/server/routes/comments.js +8 -3
  181. package/dist/server/routes/compile.js +56 -4
  182. package/dist/server/routes/projectGit.js +10 -0
  183. package/dist/server/routes/projectHistory.js +42 -0
  184. package/dist/server/routes/system.js +1 -0
  185. package/dist/server/routes/tikzGallery.js +38 -0
  186. package/dist/server/routes/users.js +2 -2
  187. package/dist/server/tikzEditorAddon.js +115 -0
  188. package/dist/server/tikzEditorRelease.js +9 -0
  189. package/dist/server/tikzGallery.js +63 -0
  190. package/dist/shared/bibtexBraces.js +20 -0
  191. package/dist/shared/bibtexNames.js +82 -0
  192. package/dist/shared/bibtexReferences.js +52 -12
  193. package/dist/shared/bibtexText.js +175 -0
  194. package/dist/shared/gitProtocol.js +2 -0
  195. package/dist/shared/historyProtocol.js +5 -0
  196. package/dist/shared/textDiff.js +36 -1
  197. package/dist/shared/tikzStandalone.js +15 -0
  198. package/package.json +2 -1
  199. package/templates/agents/AGENTS.md +12 -0
  200. package/texlite.config.example.json +4 -0
  201. package/dist/client/assets/AdminUsers-Cpj29JD6.js +0 -1
  202. package/dist/client/assets/AdminUsers-Cpj29JD6.js.br +0 -0
  203. package/dist/client/assets/AdminUsers-Cpj29JD6.js.gz +0 -0
  204. package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
  205. package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
  206. package/dist/client/assets/AgentManagement-0n1UkKZ5.js.br +0 -0
  207. package/dist/client/assets/AgentManagement-0n1UkKZ5.js.gz +0 -0
  208. package/dist/client/assets/AgentTerminal-BbGH5iPx.js +0 -2
  209. package/dist/client/assets/AgentTerminal-BbGH5iPx.js.br +0 -0
  210. package/dist/client/assets/AgentTerminal-BbGH5iPx.js.gz +0 -0
  211. package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js +0 -16
  212. package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.br +0 -0
  213. package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.gz +0 -0
  214. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js +0 -1
  215. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.br +0 -0
  216. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.gz +0 -0
  217. package/dist/client/assets/CitationBibtexEditor-B4ITqbxl.js +0 -1
  218. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js +0 -3
  219. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.br +0 -0
  220. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.gz +0 -0
  221. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js +0 -36
  222. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.br +0 -0
  223. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.gz +0 -0
  224. package/dist/client/assets/Dashboard-Dc3ANXhG.js +0 -5
  225. package/dist/client/assets/Dashboard-Dc3ANXhG.js.br +0 -0
  226. package/dist/client/assets/Dashboard-Dc3ANXhG.js.gz +0 -0
  227. package/dist/client/assets/GitDialog-CzLmo9Z_.js +0 -3
  228. package/dist/client/assets/GitDialog-CzLmo9Z_.js.br +0 -0
  229. package/dist/client/assets/GitDialog-CzLmo9Z_.js.gz +0 -0
  230. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js +0 -1
  231. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.br +0 -0
  232. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.gz +0 -0
  233. package/dist/client/assets/HistoryDialog-C4zmnE1s.js +0 -8
  234. package/dist/client/assets/HistoryDialog-C4zmnE1s.js.br +0 -0
  235. package/dist/client/assets/HistoryDialog-C4zmnE1s.js.gz +0 -0
  236. package/dist/client/assets/InfoPopover-Dkz742vJ.js +0 -1
  237. package/dist/client/assets/LatexEditor-BRPiyMbH.js +0 -25
  238. package/dist/client/assets/LatexEditor-BRPiyMbH.js.br +0 -0
  239. package/dist/client/assets/LatexEditor-BRPiyMbH.js.gz +0 -0
  240. package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.br +0 -0
  241. package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.gz +0 -0
  242. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js +0 -1
  243. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.br +0 -0
  244. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.gz +0 -0
  245. package/dist/client/assets/ProjectSettings-CARW1k8M.js +0 -4
  246. package/dist/client/assets/ProjectSettings-CARW1k8M.js.br +0 -0
  247. package/dist/client/assets/ProjectSettings-CARW1k8M.js.gz +0 -0
  248. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js +0 -31
  249. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.br +0 -0
  250. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.gz +0 -0
  251. package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.br +0 -0
  252. package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.gz +0 -0
  253. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js +0 -3
  254. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.br +0 -0
  255. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.gz +0 -0
  256. package/dist/client/assets/SharedProjectPage-BjhT-js7.js +0 -2
  257. package/dist/client/assets/SharedProjectPage-BjhT-js7.js.br +0 -0
  258. package/dist/client/assets/SharedProjectPage-BjhT-js7.js.gz +0 -0
  259. package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.br +0 -0
  260. package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.gz +0 -0
  261. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js +0 -1
  262. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.br +0 -0
  263. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.gz +0 -0
  264. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js +0 -1
  265. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.br +0 -0
  266. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.gz +0 -0
  267. package/dist/client/assets/WordCountDialog-CJb1b8cD.js +0 -1
  268. package/dist/client/assets/WordCountDialog-CJb1b8cD.js.br +0 -0
  269. package/dist/client/assets/WordCountDialog-CJb1b8cD.js.gz +0 -0
  270. package/dist/client/assets/bibtexFormatterWorker-B_jvobIv.js.br +0 -0
  271. package/dist/client/assets/bibtexFormatterWorker-B_jvobIv.js.gz +0 -0
  272. package/dist/client/assets/citationLibrary-BzlqZiFU.js +0 -26
  273. package/dist/client/assets/citationLibrary-BzlqZiFU.js.br +0 -0
  274. package/dist/client/assets/citationLibrary-BzlqZiFU.js.gz +0 -0
  275. package/dist/client/assets/clipboard-CslquMx4.js +0 -1
  276. package/dist/client/assets/editor-fyrvjoqA.js +0 -14
  277. package/dist/client/assets/editor-fyrvjoqA.js.br +0 -0
  278. package/dist/client/assets/editor-fyrvjoqA.js.gz +0 -0
  279. package/dist/client/assets/editor-languages-D1a-K8dK.js +0 -36
  280. package/dist/client/assets/editor-languages-D1a-K8dK.js.br +0 -0
  281. package/dist/client/assets/editor-languages-D1a-K8dK.js.gz +0 -0
  282. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js +0 -1
  283. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.br +0 -0
  284. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.gz +0 -0
  285. package/dist/client/assets/eye-BnslGpqB.js +0 -1
  286. package/dist/client/assets/i18n-DNTfpttY.js +0 -13
  287. package/dist/client/assets/i18n-DNTfpttY.js.br +0 -0
  288. package/dist/client/assets/i18n-DNTfpttY.js.gz +0 -0
  289. package/dist/client/assets/index-CfSDaTd4.js +0 -2
  290. package/dist/client/assets/index-CfSDaTd4.js.br +0 -0
  291. package/dist/client/assets/index-CfSDaTd4.js.gz +0 -0
  292. package/dist/client/assets/index-PNFHDg2W.css +0 -1
  293. package/dist/client/assets/index-PNFHDg2W.css.br +0 -0
  294. package/dist/client/assets/index-PNFHDg2W.css.gz +0 -0
  295. package/dist/client/assets/katex-CBRBI6nR.js +0 -257
  296. package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
  297. package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
  298. package/dist/client/assets/latexFormatterWorker-BIDCSZPd.js.br +0 -0
  299. package/dist/client/assets/latexFormatterWorker-BIDCSZPd.js.gz +0 -0
  300. package/dist/client/assets/relativeTime-DKEihsTa.js +0 -1
  301. package/dist/client/assets/relativeTime-DKEihsTa.js.br +0 -0
  302. package/dist/client/assets/relativeTime-DKEihsTa.js.gz +0 -0
  303. package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js +0 -1
  304. package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.br +0 -0
  305. package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.gz +0 -0
  306. package/dist/client/assets/spellCheck-D-tYd_ac.js.br +0 -0
  307. package/dist/client/assets/spellCheck-D-tYd_ac.js.gz +0 -0
  308. package/dist/client/assets/textLanguages-Dac6mieP.js.br +0 -0
  309. package/dist/client/assets/textLanguages-Dac6mieP.js.gz +0 -0
  310. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +0 -1
  311. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
  312. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
  313. package/dist/client/assets/vimSupport-DWYaSMuX.js.br +0 -0
  314. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js → AgentIcon-qmglBc3M.js} +0 -0
  315. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js.br → AgentIcon-qmglBc3M.js.br} +0 -0
  316. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js.gz → AgentIcon-qmglBc3M.js.gz} +0 -0
@@ -6,7 +6,7 @@ import { resolveSourcePath, safeRelativePath } from "../files.js";
6
6
  import { apiError, httpError } from "../http.js";
7
7
  import { accessibleProject } from "../projects.js";
8
8
  import { isCollaborativeTextFile } from "../collaboration.js";
9
- import { attachSuggestion, suggestionRow } from "../commentSuggestions.js";
9
+ import { attachSuggestion, suggestionReviewers, suggestionRow } from "../commentSuggestions.js";
10
10
  import { registerSuggestionRoutes } from "./commentSuggestions.js";
11
11
  import { defaultSuggestionComments } from "../../shared/suggestionMessages.js";
12
12
  import { serverLocale } from "../i18n.js";
@@ -217,8 +217,13 @@ export function registerCommentRoutes(app, context) {
217
217
  changed = true;
218
218
  }
219
219
  if (typeof body.resolved === "boolean") {
220
- if (body.resolved && suggestionRow(db, id, commentId)?.status === "pending")
221
- return apiError(reply, 409, "SUGGESTION_PENDING");
220
+ if (body.resolved) {
221
+ const suggestion = suggestionRow(db, id, commentId);
222
+ if (suggestion?.status === "pending" && (suggestion.apply_update
223
+ || suggestionReviewers(db, id, suggestion.author_id).some(user => user.id === suggestion.reviewer_id))) {
224
+ return apiError(reply, 409, "SUGGESTION_PENDING");
225
+ }
226
+ }
222
227
  changed = true;
223
228
  }
224
229
  if (!changed)
@@ -5,7 +5,9 @@ import { randomUUID } from "node:crypto";
5
5
  import { performance } from "node:perf_hooks";
6
6
  import { requireUser } from "../auth.js";
7
7
  import { accessibleProject, canEdit } from "../projects.js";
8
- import { resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
8
+ import { outputRoot, resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
9
+ import { isStandaloneTikz } from "../../shared/tikzStandalone.js";
10
+ import { touchProject } from "./projectShared.js";
9
11
  import { captureCompileSnapshot, cleanCompileArtifacts, cleanCompileCache, CompileCancelledError, compileProject, discardCompileSnapshot, hasCompileCache, publishCompileArtifacts, publishedCompileArtifacts } from "../compiler.js";
10
12
  import { parseCompileDiagnostics } from "../compileDiagnostics.js";
11
13
  import { pdfToSource, sourceToPdf } from "../synctex.js";
@@ -293,6 +295,50 @@ export function registerCompileRoutes(app, context) {
293
295
  throw httpError(404, "PROJECT_NOT_FOUND");
294
296
  } });
295
297
  });
298
+ // Copies the latest successful PDF of a standalone TikZ figure beside its
299
+ // source so that other documents can include it. A separate step because
300
+ // concurrent compile requests are coalesced into one run.
301
+ app.post("/api/projects/:id/compile/export-pdf", async (request, reply) => {
302
+ const user = requireUser(request, reply, db);
303
+ if (!user)
304
+ return;
305
+ const { id } = request.params;
306
+ const permitted = () => {
307
+ const project = accessibleProject(db, id, user);
308
+ if (!project || !canEdit(project))
309
+ throw httpError(403, "COMPILE_FORBIDDEN");
310
+ return project;
311
+ };
312
+ const body = (request.body ?? {});
313
+ return projectMutations.runWrite(id, () => {
314
+ const project = permitted();
315
+ const mainFile = compileMainFile(config, id, project.main_file, body.mainFile);
316
+ if (!mainFile)
317
+ throw httpError(400, "MAIN_DOCUMENT_INVALID");
318
+ if (!isStandaloneTikz(fs.readFileSync(resolveSourcePath(config, id, mainFile), "utf8")))
319
+ throw httpError(400, "REQUEST_INVALID");
320
+ const pdf = availablePdf(config, id, mainFile);
321
+ if (!pdf)
322
+ throw httpError(404, "PDF_NOT_FOUND");
323
+ const target = `${mainFile.slice(0, -".tex".length)}.pdf`;
324
+ const destination = resolveSourcePath(config, id, target);
325
+ if (fs.statSync(destination, { throwIfNoEntry: false })?.isDirectory())
326
+ throw httpError(409, "PATH_EXISTS");
327
+ // Staged outside the source tree, on the same filesystem, so collaborators
328
+ // and including documents only ever see a complete file.
329
+ const staged = path.join(outputRoot(config, id), `.export-${randomUUID()}.pdf`);
330
+ try {
331
+ fs.copyFileSync(pdf.path, staged);
332
+ fs.renameSync(staged, destination);
333
+ }
334
+ finally {
335
+ fs.rmSync(staged, { force: true });
336
+ }
337
+ touchProject(db, id, user.id);
338
+ collaboration.invalidateSourceTree(id, target);
339
+ return { path: target };
340
+ }, { preflight: () => { permitted(); } });
341
+ });
296
342
  app.post("/api/projects/:id/compile/cancel", async (request, reply) => {
297
343
  const user = requireUser(request, reply, db);
298
344
  if (!user)
@@ -318,6 +364,12 @@ export function registerCompileRoutes(app, context) {
318
364
  if (!initialProject || !canEdit(initialProject))
319
365
  return apiError(reply, 403, "COMPILE_FORBIDDEN");
320
366
  const body = (request.body ?? {});
367
+ const requestedEngine = config.allowedEngines.find((engine) => engine === body.engine);
368
+ if (body.engine !== undefined && !requestedEngine)
369
+ return apiError(reply, 400, "REQUEST_INVALID");
370
+ // For this run only; part of the compile generation and cache key, so a
371
+ // request for another engine is neither coalesced nor treated as up to date.
372
+ const withRequestedEngine = (row) => requestedEngine ? { ...row, engine: requestedEngine } : row;
321
373
  const requestedMainFile = typeof body.mainFile === "string" && body.mainFile ? body.mainFile : null;
322
374
  const initialMainFile = compileMainFile(config, id, initialProject.main_file, body.mainFile);
323
375
  if (!initialMainFile)
@@ -348,9 +400,9 @@ export function registerCompileRoutes(app, context) {
348
400
  }
349
401
  const generationRevision = receipt?.revision ?? revisionBeforeFlush;
350
402
  const admissionResult = {
351
- project: refreshedProject,
403
+ project: withRequestedEngine(refreshedProject),
352
404
  mainFile: currentMainFile,
353
- generation: compileRequestGeneration(refreshedProject, generationRevision, collaboration.currentGeneration(id), config.extraArgs)
405
+ generation: compileRequestGeneration(withRequestedEngine(refreshedProject), generationRevision, collaboration.currentGeneration(id), config.extraArgs)
354
406
  };
355
407
  // Insert the queued probe while the project lock is still held. A
356
408
  // concurrent clean request must observe this row before the compile
@@ -428,7 +480,7 @@ export function registerCompileRoutes(app, context) {
428
480
  throw new Error("Selected main document is no longer available");
429
481
  if (!requestedMainFile && currentMainFile !== mainFile)
430
482
  throw mainDocumentChangedError();
431
- project = currentProject;
483
+ project = withRequestedEngine(currentProject);
432
484
  mainFile = currentMainFile;
433
485
  // Capture only after all exclusive source-tree operations queued
434
486
  // before this request have completed. A collaboration barrier
@@ -38,6 +38,16 @@ export function registerProjectGitRoutes(app, context) {
38
38
  return apiError(reply, 400, "GIT_TOKEN_INVALID");
39
39
  return { status: await projectGit.configureUserToken(user.id, body.token) };
40
40
  });
41
+ app.put("/api/account/github/identity", async (request, reply) => {
42
+ const user = requireUser(request, reply, db);
43
+ if (!user)
44
+ return;
45
+ const body = request.body;
46
+ if (typeof body.username !== "string" || typeof body.email !== "string") {
47
+ return apiError(reply, 400, "GIT_IDENTITY_INVALID");
48
+ }
49
+ return { status: projectGit.updateGitIdentity(user.id, body.username, body.email) };
50
+ });
41
51
  app.delete("/api/account/github", async (request, reply) => {
42
52
  const user = requireUser(request, reply, db);
43
53
  if (!user)
@@ -7,6 +7,8 @@ import { resolveSourcePath, safeRelativePath } from "../files.js";
7
7
  import { apiError, httpError } from "../http.js";
8
8
  import { MAX_TEXT_PREVIEW_BYTES } from "../limits.js";
9
9
  import { defaultHistoryTracking, historyTextCandidate } from "../../shared/historyTracking.js";
10
+ /** Files with agent changes examined per request; the newest edits matter most. */
11
+ const MAX_AGENT_CHANGE_FILES = 200;
10
12
  import { accessibleProject, canEdit } from "../projects.js";
11
13
  import { commentsSummaryForProject, projectJson, projectTextSnapshot, reanchorProjectSnapshot, requireEditableProject, requireProjectOwnerPermission, tagsForProject, text, touchProject } from "./projectShared.js";
12
14
  /** Register retained project version listing, inspection, restoration, and cleanup routes. */
@@ -80,6 +82,46 @@ export function registerProjectHistoryRoutes(app, context) {
80
82
  throw httpError(404, "PROJECT_NOT_FOUND");
81
83
  } });
82
84
  });
85
+ /**
86
+ * The caller's own coding-agent changes across the project, mapped to the
87
+ * current sources. Other users' agent work is never returned. Read-only:
88
+ * which changes were reviewed is kept by the browser.
89
+ */
90
+ app.get("/api/projects/:id/agent-changes", async (request, reply) => {
91
+ const user = requireUser(request, reply, db);
92
+ if (!user)
93
+ return;
94
+ const { id } = request.params;
95
+ if (!accessibleProject(db, id, user))
96
+ return apiError(reply, 404, "PROJECT_NOT_FOUND");
97
+ return await projectMutations.runConsistentRead(id, () => {
98
+ const paths = db.prepare(`SELECT DISTINCT file_path FROM project_edit_segments
99
+ WHERE project_id = ? AND author_id = ? AND has_agent = 1 ORDER BY file_path LIMIT ?`)
100
+ .all(id, user.id, MAX_AGENT_CHANGE_FILES).map((row) => row.file_path);
101
+ const files = [];
102
+ for (const filePath of paths) {
103
+ if (!isCollaborativeTextFile(filePath))
104
+ continue;
105
+ let source;
106
+ try {
107
+ source = resolveSourcePath(config, id, filePath);
108
+ }
109
+ catch {
110
+ continue;
111
+ }
112
+ if (!fs.existsSync(source) || !fs.statSync(source).isFile() || fs.statSync(source).size > maxCollaborativeFileBytes(config))
113
+ continue;
114
+ const content = fs.readFileSync(source, "utf8");
115
+ const changes = editHistory.agentChanges(id, filePath, content, user.id);
116
+ if (changes.length)
117
+ files.push({ path: filePath, sourceHash: hashText(content), changes });
118
+ }
119
+ return { files };
120
+ }, { preflight: () => {
121
+ if (!accessibleProject(db, id, user))
122
+ throw httpError(404, "PROJECT_NOT_FOUND");
123
+ } });
124
+ });
83
125
  app.get("/api/projects/:id/history", async (request, reply) => {
84
126
  const user = requireUser(request, reply, db);
85
127
  if (!user)
@@ -43,6 +43,7 @@ export function registerSystemRoutes(app, context) {
43
43
  maxUploadSizeMB: Math.floor(config.maxUploadBytes / 1024 / 1024),
44
44
  maxCollaborativeFileSizeMB: Math.floor(maxCollaborativeFileBytes(config) / 1024 / 1024),
45
45
  allowedEngines: config.allowedEngines,
46
+ tikzGalleryEnabled: config.tikzGalleryEnabled,
46
47
  allowProjectLatexmkrc: config.allowProjectLatexmkrc
47
48
  }));
48
49
  app.get("/api/health", async () => ({ ok: true, pid: process.pid, latexmk: config.latexmk }));
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs";
2
+ import { requireUser } from "../auth.js";
3
+ import { apiError } from "../http.js";
4
+ import { TikzGalleryLibrary } from "../tikzGallery.js";
5
+ /** A preview comes from a repository this host only chose, not wrote: opened directly, it must not run as TexLite. */
6
+ const SVG_CSP = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
7
+ export function registerTikzGalleryRoutes(app, { config, db }) {
8
+ const library = new TikzGalleryLibrary(config.tikzGalleryDir);
9
+ app.get("/api/tikz-gallery/catalog", async (request, reply) => {
10
+ if (!requireUser(request, reply, db))
11
+ return;
12
+ if (!config.tikzGalleryEnabled)
13
+ return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
14
+ const result = library.catalog();
15
+ if (result.status === "unavailable")
16
+ return apiError(reply, 503, "TIKZ_GALLERY_UNAVAILABLE");
17
+ if (result.status === "incompatible")
18
+ return apiError(reply, 409, "TIKZ_GALLERY_INCOMPATIBLE");
19
+ reply.header("Cache-Control", "no-store");
20
+ return result.catalog;
21
+ });
22
+ app.get("/api/tikz-gallery/file", async (request, reply) => {
23
+ if (!requireUser(request, reply, db))
24
+ return;
25
+ if (!config.tikzGalleryEnabled)
26
+ return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
27
+ const { path: relative } = request.query;
28
+ const file = typeof relative === "string" ? library.listedFile(relative) : null;
29
+ if (!file)
30
+ return apiError(reply, 404, "FILE_NOT_FOUND");
31
+ reply.header("Cache-Control", "private, max-age=300").header("X-Content-Type-Options", "nosniff");
32
+ if (/\.svg$/i.test(file))
33
+ reply.header("Content-Security-Policy", SVG_CSP).type("image/svg+xml");
34
+ else
35
+ reply.type("text/plain; charset=utf-8");
36
+ return reply.send(fs.readFileSync(file));
37
+ });
38
+ }
@@ -58,11 +58,11 @@ export function registerUserManagementRoutes(app, context) {
58
58
  const user = {
59
59
  id: randomUUID(), username, display_name: displayName,
60
60
  password_hash: await hashPassword(password), role, disabled: 0,
61
- must_change_password: 0, can_create_projects: body?.canCreateProjects === true ? 1 : 0, created_at: now()
61
+ must_change_password: 1, can_create_projects: body?.canCreateProjects === true ? 1 : 0, created_at: now()
62
62
  };
63
63
  db.prepare(`INSERT INTO users
64
64
  (id, username, display_name, password_hash, role, disabled, must_change_password, can_create_projects, created_at)
65
- VALUES (?, ?, ?, ?, ?, 0, 0, ?, ?)`)
65
+ VALUES (?, ?, ?, ?, ?, 0, 1, ?, ?)`)
66
66
  .run(user.id, user.username, user.display_name, user.password_hash, user.role, user.can_create_projects, user.created_at);
67
67
  return reply.code(201).send({ user: publicUser(user) });
68
68
  });
@@ -0,0 +1,115 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { Readable } from "node:stream";
6
+ import { pipeline } from "node:stream/promises";
7
+ import { TIKZ_BRIDGE_PROTOCOL } from "../shared/tikzStandalone.js";
8
+ import { TIKZ_EDITOR_RELEASE } from "./tikzEditorRelease.js";
9
+ const REPOSITORY_URL = "https://github.com/SWUFE-DB-Group/TexLite";
10
+ const DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
11
+ const MANIFEST = "texlite-bridge.json";
12
+ /** Kept with the instance's data so it survives upgrades of the npm package. */
13
+ export function tikzEditorDirectory(dataDir) {
14
+ return path.join(dataDir, "addons", "tikz-editor");
15
+ }
16
+ export function tikzEditorDownloadUrl(release = TIKZ_EDITOR_RELEASE) {
17
+ return `${REPOSITORY_URL}/releases/download/${release.tag}/${release.asset}`;
18
+ }
19
+ function readManifest(directory) {
20
+ try {
21
+ const parsed = JSON.parse(fs.readFileSync(path.join(directory, MANIFEST), "utf8"));
22
+ return typeof parsed.protocol === "number" && typeof parsed.commit === "string" && typeof parsed.version === "string" && typeof parsed.build === "string"
23
+ ? { protocol: parsed.protocol, commit: parsed.commit, version: parsed.version, build: parsed.build }
24
+ : null;
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ export function installedTikzEditor(dataDir) {
31
+ return readManifest(tikzEditorDirectory(dataDir));
32
+ }
33
+ async function download(url, destination, fetcher) {
34
+ let response;
35
+ try {
36
+ response = await fetcher(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
37
+ }
38
+ catch (error) {
39
+ throw new Error(`Could not download ${url}: ${error instanceof Error ? error.message : String(error)}. Without access to GitHub, fetch it elsewhere and use --file.`);
40
+ }
41
+ if (!response.ok || !response.body)
42
+ throw new Error(`Could not download ${url} (HTTP ${response.status}). Without access to GitHub, fetch it elsewhere and use --file.`);
43
+ await pipeline(Readable.fromWeb(response.body), fs.createWriteStream(destination));
44
+ }
45
+ async function sha256(file) {
46
+ const hash = createHash("sha256");
47
+ await pipeline(fs.createReadStream(file), hash);
48
+ return hash.digest("hex");
49
+ }
50
+ function extract(archive, destination) {
51
+ fs.mkdirSync(destination);
52
+ const result = spawnSync("tar", ["-xzf", archive, "--no-same-owner", "-C", destination], { encoding: "utf8" });
53
+ if (result.error)
54
+ throw new Error(`Could not run tar to unpack the editor: ${result.error.message}`);
55
+ if (result.status !== 0)
56
+ throw new Error(`Could not unpack the editor: ${result.stderr.trim()}`);
57
+ }
58
+ /**
59
+ * Verifies the archive against the digest pinned in this TexLite version, then
60
+ * swaps it in whole, so a failure leaves any existing install untouched. A
61
+ * running server picks up the new files without a restart.
62
+ */
63
+ export async function installTikzEditor(dataDir, options = {}) {
64
+ const release = options.release ?? TIKZ_EDITOR_RELEASE;
65
+ if (!options.file && !release.sha256)
66
+ throw new Error("This TexLite build has no TikZ Editor release pinned.");
67
+ const target = tikzEditorDirectory(dataDir);
68
+ fs.mkdirSync(path.dirname(target), { recursive: true });
69
+ const work = fs.mkdtempSync(path.join(path.dirname(target), ".install-"));
70
+ try {
71
+ let archive = options.file ? path.resolve(options.file) : path.join(work, release.asset);
72
+ if (options.file) {
73
+ if (!fs.existsSync(archive))
74
+ throw new Error(`File not found: ${archive}`);
75
+ }
76
+ else {
77
+ const url = tikzEditorDownloadUrl(release);
78
+ options.onDownload?.(url);
79
+ await download(url, archive, options.fetcher ?? fetch);
80
+ }
81
+ const actual = await sha256(archive);
82
+ if (actual !== release.sha256) {
83
+ throw new Error(`The archive is not the TikZ Editor build for this TexLite version (expected ${release.asset}, SHA-256 ${release.sha256}, got ${actual}).`);
84
+ }
85
+ const staged = path.join(work, "editor");
86
+ extract(archive, staged);
87
+ const manifest = readManifest(staged);
88
+ if (!manifest || manifest.protocol !== TIKZ_BRIDGE_PROTOCOL || manifest.build !== release.build || !fs.existsSync(path.join(staged, "index.html"))) {
89
+ throw new Error("The archive does not contain a compatible TikZ Editor build.");
90
+ }
91
+ const previous = path.join(work, "previous");
92
+ const replacing = fs.existsSync(target);
93
+ if (replacing)
94
+ fs.renameSync(target, previous);
95
+ try {
96
+ fs.renameSync(staged, target);
97
+ }
98
+ catch (error) {
99
+ if (replacing)
100
+ fs.renameSync(previous, target);
101
+ throw error;
102
+ }
103
+ return manifest;
104
+ }
105
+ finally {
106
+ fs.rmSync(work, { recursive: true, force: true });
107
+ }
108
+ }
109
+ /** Returns whether an editor was installed. */
110
+ export function removeTikzEditor(dataDir) {
111
+ const target = tikzEditorDirectory(dataDir);
112
+ const installed = readManifest(target) !== null;
113
+ fs.rmSync(target, { recursive: true, force: true });
114
+ return installed;
115
+ }
@@ -0,0 +1,9 @@
1
+ // Written by scripts/build-tikz-editor.mjs. Do not edit by hand.
2
+ export const TIKZ_EDITOR_RELEASE = {
3
+ version: "1.1.0",
4
+ commit: "2056d9649e89312041ab8353845ec7addc2a8304",
5
+ build: "a2398522",
6
+ tag: "tikz-editor-1.1.0-2056d96-a2398522",
7
+ asset: "tikz-editor-1.1.0-2056d96-a2398522.tar.gz",
8
+ sha256: "f3feb955a7fd2d7fa47746271f663642bd956423389ceddfed40d0c30d5197d4"
9
+ };
@@ -0,0 +1,63 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ /** The catalog format this TexLite can read; see the add-on's README. */
4
+ const SUPPORTED_CATALOG_VERSION = 1;
5
+ const MAX_FIGURE_FILE_BYTES = 16 * 1024 * 1024;
6
+ /** A file inside `root` once symbolic links are followed, or null. */
7
+ function containedFile(root, relative) {
8
+ try {
9
+ const realRoot = fs.realpathSync(root);
10
+ const real = fs.realpathSync(path.resolve(realRoot, relative));
11
+ return real.startsWith(`${realRoot}${path.sep}`) && fs.statSync(real).isFile() ? real : null;
12
+ }
13
+ catch {
14
+ return null;
15
+ }
16
+ }
17
+ function isCatalog(value) {
18
+ const catalog = value;
19
+ return typeof catalog === "object" && catalog !== null && catalog.version === SUPPORTED_CATALOG_VERSION && Array.isArray(catalog.items)
20
+ && catalog.items.every((item) => typeof item?.tex === "string" && typeof item.preview === "string");
21
+ }
22
+ /**
23
+ * Reads the add-on an administrator placed on this host. The directory is a
24
+ * whole repository, so only the files its catalog lists are ever exposed. It
25
+ * is read per request (the parse is cached) so `git pull` needs no restart.
26
+ */
27
+ export class TikzGalleryLibrary {
28
+ directory;
29
+ cached = null;
30
+ constructor(directory) {
31
+ this.directory = directory;
32
+ }
33
+ load() {
34
+ const file = containedFile(this.directory, "catalog.json");
35
+ if (!file)
36
+ return { result: { status: "unavailable" }, listed: new Set() };
37
+ const stat = fs.statSync(file);
38
+ const stamp = `${stat.mtimeMs}:${stat.size}`;
39
+ if (this.cached?.stamp === stamp)
40
+ return this.cached;
41
+ let parsed;
42
+ try {
43
+ parsed = JSON.parse(fs.readFileSync(file, "utf8"));
44
+ }
45
+ catch {
46
+ parsed = null;
47
+ }
48
+ const result = isCatalog(parsed) ? { status: "ok", catalog: parsed } : { status: "incompatible" };
49
+ const listed = new Set(result.status === "ok" ? result.catalog.items.flatMap(({ tex, preview }) => [tex, preview]) : []);
50
+ this.cached = { stamp, result, listed };
51
+ return this.cached;
52
+ }
53
+ catalog() {
54
+ return this.load().result;
55
+ }
56
+ /** The path of a figure source or preview the catalog lists, or null. */
57
+ listedFile(relative) {
58
+ if (!this.load().listed.has(relative) || !/\.(?:tex|svg)$/i.test(relative))
59
+ return null;
60
+ const file = containedFile(this.directory, relative);
61
+ return file && fs.statSync(file).size <= MAX_FIGURE_FILE_BYTES ? file : null;
62
+ }
63
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Index just after the brace that closes the BibTeX group opened at `start`,
3
+ * or -1 when the group is not closed. A backslash escapes the next character,
4
+ * so `\{` and `\}` are not counted.
5
+ */
6
+ export function bracedGroupEnd(source, start) {
7
+ let depth = 0;
8
+ for (let index = start; index < source.length; index += 1) {
9
+ const character = source[index];
10
+ if (character === "\\") {
11
+ index += 1;
12
+ continue;
13
+ }
14
+ if (character === "{")
15
+ depth += 1;
16
+ else if (character === "}" && --depth === 0)
17
+ return index + 1;
18
+ }
19
+ return -1;
20
+ }
@@ -0,0 +1,82 @@
1
+ import { bracedGroupEnd } from "./bibtexBraces.js";
2
+ /**
3
+ * Find BibTeX name-list separators: the word `and` (any case) after
4
+ * whitespace, at brace depth 0, so `{Barnes and Noble}` and escaped TeX are
5
+ * never split. A trailing `and` (a list still being typed) counts too, so it
6
+ * never becomes part of a name. Shared by the editor's completion and
7
+ * diagnostics and by author display.
8
+ */
9
+ export function findTopLevelAndSeparators(text) {
10
+ const separators = [];
11
+ let depth = 0;
12
+ for (let index = 0; index < text.length; index++) {
13
+ const character = text[index];
14
+ if (character === "\\") {
15
+ index++;
16
+ continue;
17
+ }
18
+ if (character === "{") {
19
+ depth++;
20
+ continue;
21
+ }
22
+ if (character === "}") {
23
+ depth = Math.max(0, depth - 1);
24
+ continue;
25
+ }
26
+ if (depth !== 0 || text.slice(index, index + 3).toLowerCase() !== "and")
27
+ continue;
28
+ const before = text[index - 1];
29
+ const after = text[index + 3];
30
+ if (!before || !/\s/.test(before) || (after !== undefined && !/\s/.test(after)))
31
+ continue;
32
+ let from = index;
33
+ while (from > 0 && /\s/.test(text[from - 1]))
34
+ from--;
35
+ let to = index + 3;
36
+ while (to < text.length && /\s/.test(text[to]))
37
+ to++;
38
+ separators.push({ from, to });
39
+ index += 2;
40
+ }
41
+ return separators;
42
+ }
43
+ /**
44
+ * Split a BibTeX name list (`author`, `editor`) into names at its top-level
45
+ * `and` separators. A final `others` is BibTeX's marker for an incomplete
46
+ * list, not a name. Names keep their original form: reordering or
47
+ * abbreviating them would need BibTeX's full von/Jr. rules, and the source
48
+ * text is never wrong.
49
+ */
50
+ export function splitBibtexNames(value) {
51
+ const names = [];
52
+ let start = 0;
53
+ for (const separator of findTopLevelAndSeparators(value)) {
54
+ names.push(value.slice(start, separator.from));
55
+ start = separator.to;
56
+ }
57
+ names.push(value.slice(start));
58
+ const cleaned = names.map(displayName).filter(Boolean);
59
+ const others = cleaned.length > 1 && cleaned[cleaned.length - 1].toLowerCase() === "others";
60
+ return { names: others ? cleaned.slice(0, -1) : cleaned, others };
61
+ }
62
+ /** Trim a name and drop braces that only protect the whole name, such as `{World Health Organization}`. */
63
+ function displayName(name) {
64
+ const trimmed = name.trim();
65
+ if (trimmed.startsWith("{") && bracedGroupEnd(trimmed, 0) === trimmed.length)
66
+ return trimmed.slice(1, -1).trim();
67
+ return trimmed;
68
+ }
69
+ /**
70
+ * biblatex's default name-list truncation (`maxnames=3`, `minnames=1`): a list
71
+ * longer than `maxNames` shows only its first `minNames` names followed by
72
+ * "et al.". A list ending in `and others` is already truncated, so it is
73
+ * shortened the same way and always followed by "et al.".
74
+ */
75
+ export function truncateBibtexNames(list, { maxNames = 3, minNames = 1 } = {}) {
76
+ const tooLong = list.names.length > maxNames;
77
+ return {
78
+ shown: tooLong ? list.names.slice(0, minNames) : list.names,
79
+ truncated: tooLong || list.others,
80
+ total: list.others ? null : list.names.length
81
+ };
82
+ }
@@ -23,6 +23,16 @@ function readBibtexBlock(source, start) {
23
23
  continue;
24
24
  }
25
25
  if (opening === "{") {
26
+ // Comments belong to the entry body, not to its brace structure. Skip
27
+ // them before counting braces so an unpaired } or { in a comment cannot
28
+ // close or extend the entry. Quotes at the top level protect literal
29
+ // percent signs inside quoted values.
30
+ if (depth === 1 && !quoted && isLatexCommentStart(source, index)) {
31
+ index = skipLatexComment(source, index);
32
+ continue;
33
+ }
34
+ if (depth === 1 && character === "\"")
35
+ quoted = !quoted;
26
36
  if (character === "{") {
27
37
  depth += 1;
28
38
  continue;
@@ -51,6 +61,10 @@ function readBibtexBlock(source, start) {
51
61
  braceDepth -= 1;
52
62
  continue;
53
63
  }
64
+ if (depth === 1 && isLatexCommentStart(source, index)) {
65
+ index = skipLatexComment(source, index);
66
+ continue;
67
+ }
54
68
  if (character === "{") {
55
69
  braceDepth = 1;
56
70
  continue;
@@ -72,24 +86,25 @@ function readBibtexBlock(source, start) {
72
86
  }
73
87
  return null;
74
88
  }
89
+ /**
90
+ * Characters that end a key, as in the editor grammar's key token. A key must
91
+ * then be followed, after whitespace and comments, by `,` or the end of the
92
+ * entry: `@article{f(1), ...}` and `@article{title = {A}}` have no key.
93
+ */
94
+ const keyTerminator = /[\s,{}()%]/;
75
95
  function bibtexKeyRange(source, entry) {
76
- let from = entry.contentFrom;
77
- while (from < entry.contentTo && /\s/.test(source[from]))
78
- from += 1;
96
+ const from = skipLatexTrivia(source, entry.contentFrom);
79
97
  if (from >= entry.contentTo)
80
98
  return null;
81
99
  let to = from;
82
- while (to < entry.contentTo && source[to] !== "," && !/\s/.test(source[to]))
100
+ while (to < entry.contentTo && !keyTerminator.test(source[to]))
83
101
  to += 1;
84
- let trimmedTo = to;
85
- while (trimmedTo > from && /\s/.test(source[trimmedTo - 1]))
86
- trimmedTo -= 1;
87
- if (trimmedTo <= from)
102
+ if (to <= from)
88
103
  return null;
89
104
  const separator = skipLatexTrivia(source, to);
90
105
  if (separator < entry.contentTo && source[separator] !== ",")
91
106
  return null;
92
- return { key: source.slice(from, trimmedTo), from, to: trimmedTo };
107
+ return { key: source.slice(from, to), from, to };
93
108
  }
94
109
  /**
95
110
  * Find ordinary BibTeX/BibLaTeX entry keys. `@string`, `@preamble`, and
@@ -111,13 +126,15 @@ export function findBibtexEntryKeys(source) {
111
126
  index += 1;
112
127
  continue;
113
128
  }
129
+ // An entry type is a letter followed by letters, digits, `_` or `-`,
130
+ // matching the editor grammar (`@misc1`, `@article-v2`).
114
131
  let typeEnd = index + 1;
115
- while (typeEnd < source.length && /[A-Za-z]/.test(source[typeEnd]))
116
- typeEnd += 1;
117
- if (typeEnd === index + 1) {
132
+ if (!/[A-Za-z]/.test(source[typeEnd] ?? "")) {
118
133
  index += 1;
119
134
  continue;
120
135
  }
136
+ while (typeEnd < source.length && /[A-Za-z0-9_-]/.test(source[typeEnd]))
137
+ typeEnd += 1;
121
138
  let opening = typeEnd;
122
139
  while (opening < source.length && /\s/.test(source[opening]))
123
140
  opening += 1;
@@ -137,3 +154,26 @@ export function findBibtexEntryKeys(source) {
137
154
  }
138
155
  return entries;
139
156
  }
157
+ /**
158
+ * Where an entry was published. biblatex spells a journal `journaltitle`;
159
+ * BibTeX spells it `journal`. Proceedings and collection parts prefer their
160
+ * book title.
161
+ */
162
+ export function bibtexVenue(entryType, fields) {
163
+ const journal = fields.journaltitle ?? fields.journal;
164
+ const venue = /inproceedings|conference|incollection/.test(entryType.toLowerCase())
165
+ ? fields.booktitle ?? journal
166
+ : journal ?? fields.booktitle;
167
+ return venue?.trim() || null;
168
+ }
169
+ /**
170
+ * Publication year: BibTeX's `year`, or the year of biblatex's ISO 8601
171
+ * `date` (`2021-05-03`, `2021/2022`). A `date` without a leading four-digit
172
+ * year gives no year rather than a guess.
173
+ */
174
+ export function bibtexYear(fields) {
175
+ const year = fields.year?.trim();
176
+ if (year)
177
+ return year;
178
+ return /^\s*(-?\d{4})(?!\d)/.exec(fields.date ?? "")?.[1] ?? null;
179
+ }