texlite 0.23.0 → 0.25.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.
- package/DESIGN.md +155 -17
- package/NPM_TESTING.md +46 -2
- package/OPERATIONS.md +136 -6
- package/README.md +1 -2
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +12 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js +1 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.br +0 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.gz +0 -0
- package/dist/client/assets/{AgentIcon-DJGGRJnV.css → AgentIcon-_B7xXJpJ.css} +1 -1
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.br +0 -0
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.gz +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js +1 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.br +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js +2 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.br +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js +16 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-ChKrdDqp.js → AvatarSettingsDialog-BgVGfSzn.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-DLPom-qx.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.gz +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js +5 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.br +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.gz +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js +1 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.br +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.gz +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js +4 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.br +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js +8 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.br +0 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.gz +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js +25 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.br +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-BJPqGTcw.js → MarkdownPreview-Txs5upCY.js} +1 -1
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-ChiEUQ0g.js → ProjectIconPickerDialog-CUlPlfmL.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js +4 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.br +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js +25 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-B7NTqOpu.js → QuickOpenDialog-D6yjnquG.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BOAnB5L0.js +2 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js +3 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js +2 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js +1 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-5cgNbWiG.js +1 -0
- package/dist/client/assets/{TikzGalleryDialog-CLAmKmS6.js → TikzGalleryDialog-CFbLjNTt.js} +1 -1
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.gz +0 -0
- package/dist/client/assets/{WordCountDialog-ByxE-RUs.js → WordCountDialog-hXC-cpPs.js} +1 -1
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.gz +0 -0
- package/dist/client/assets/{chktex-22lKGvKa.js → chktex-CLzMD_9a.js} +1 -1
- package/dist/client/assets/{citationLibrary-DxGdbZEQ.js → citationLibrary-BJRzAgaV.js} +1 -1
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.br +0 -0
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.gz +0 -0
- package/dist/client/assets/editor-CSq7NymY.js +14 -0
- package/dist/client/assets/editor-CSq7NymY.js.br +0 -0
- package/dist/client/assets/editor-CSq7NymY.js.gz +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js +36 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.br +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js +1 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.gz +0 -0
- package/dist/client/assets/file-cog-D_mhAnBe.js +1 -0
- package/dist/client/assets/file-down-DA4jGFrF.js +1 -0
- package/dist/client/assets/{generatedParser-CZa2vsK6.js → generatedParser-2izSCuvk.js} +1 -1
- package/dist/client/assets/generatedParser-2izSCuvk.js.br +0 -0
- package/dist/client/assets/generatedParser-2izSCuvk.js.gz +0 -0
- package/dist/client/assets/i18n-B8sR-BXw.js +13 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.br +0 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.gz +0 -0
- package/dist/client/assets/index-D6faTuJe.css +1 -0
- package/dist/client/assets/index-D6faTuJe.css.br +0 -0
- package/dist/client/assets/index-D6faTuJe.css.gz +0 -0
- package/dist/client/assets/index-dScQ5LCu.js +2 -0
- package/dist/client/assets/index-dScQ5LCu.js.br +0 -0
- package/dist/client/assets/index-dScQ5LCu.js.gz +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js +1 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.br +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js +2 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.gz +0 -0
- package/dist/client/assets/{spellCheck-kxvnxrvw.js → spellCheck-DpyzDbmq.js} +1 -1
- package/dist/client/assets/spellCheck-DpyzDbmq.js.br +0 -0
- package/dist/client/assets/spellCheck-DpyzDbmq.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-tGXUsMU9.js +1 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js +78 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.br +0 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js +1 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.gz +0 -0
- package/dist/client/assets/{vimSupport-C-WiMLjc.js → vimSupport-DMVGjr9R.js} +6 -6
- package/dist/client/assets/vimSupport-DMVGjr9R.js.br +0 -0
- package/dist/client/assets/vimSupport-DMVGjr9R.js.gz +0 -0
- package/dist/client/index.html +3 -4
- package/dist/server/agentChanges.js +95 -7
- package/dist/server/agents/adapters/claude.js +5 -2
- package/dist/server/agents/adapters/common.js +18 -5
- package/dist/server/agents/execution.js +25 -4
- package/dist/server/agents/launcher.js +5 -2
- package/dist/server/agents/outputBuffer.js +105 -0
- package/dist/server/agents/processIdentity.js +1 -1
- package/dist/server/agents/sessions.js +33 -16
- package/dist/server/agents/terminal.js +5 -2
- package/dist/server/agents/windowsJob.js +141 -0
- package/dist/server/app.js +24 -6
- package/dist/server/auth.js +3 -2
- package/dist/server/browserOrigin.js +15 -0
- package/dist/server/chktex.js +23 -11
- package/dist/server/collaboration.js +11 -1
- package/dist/server/compileDiagnostics.js +13 -9
- package/dist/server/compiler.js +70 -25
- package/dist/server/config.js +5 -1
- package/dist/server/db.js +68 -0
- package/dist/server/drawioLocks.js +114 -0
- package/dist/server/drawioOwnedBrowser.js +122 -0
- package/dist/server/drawioPdf.js +182 -0
- package/dist/server/editHistory.js +68 -20
- package/dist/server/environment.js +17 -8
- package/dist/server/files.js +86 -20
- package/dist/server/git.js +29 -23
- package/dist/server/harper.js +29 -10
- package/dist/server/history.js +220 -82
- package/dist/server/i18n.js +17 -0
- package/dist/server/index.js +15 -8
- package/dist/server/locales/zh-Hant.js +10 -0
- package/dist/server/pdfFonts.js +78 -0
- package/dist/server/pm2.js +2 -1
- package/dist/server/processTree.js +128 -7
- package/dist/server/projectDeletionCleanup.js +62 -0
- package/dist/server/projectMutations.js +7 -0
- package/dist/server/projectReplace.js +2 -2
- package/dist/server/projectSearch.js +2 -1
- package/dist/server/projectTemplateCache.js +94 -0
- package/dist/server/projectTemplateDownload.js +75 -0
- package/dist/server/projectTextSave.js +56 -0
- package/dist/server/routes/agents.js +2 -15
- package/dist/server/routes/comments.js +7 -2
- package/dist/server/routes/compile.js +67 -9
- package/dist/server/routes/drawio.js +192 -0
- package/dist/server/routes/projectFiles.js +160 -20
- package/dist/server/routes/projectGit.js +1 -1
- package/dist/server/routes/projectHistory.js +19 -5
- package/dist/server/routes/projects.js +81 -20
- package/dist/server/routes/users.js +10 -14
- package/dist/server/synctex.js +20 -3
- package/dist/server/texcount.js +27 -23
- package/dist/server/zip.js +37 -11
- package/dist/shared/agentMessages.js +3 -0
- package/dist/shared/drawio.js +79 -0
- package/dist/shared/fileTypes.js +1 -1
- package/dist/shared/pdfFonts.js +14 -0
- package/dist/shared/projectImport.js +21 -0
- package/package.json +3 -1
- package/dist/client/assets/AdminUsers-xuVuiwoh.js +0 -1
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.br +0 -0
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.br +0 -0
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.gz +0 -0
- package/dist/client/assets/AgentManagement-D-0hrv6f.js +0 -1
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.br +0 -0
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js +0 -2
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.br +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js +0 -16
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-BZIU4Lif.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js +0 -3
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.gz +0 -0
- package/dist/client/assets/Dashboard-BYgqCgBM.js +0 -5
- package/dist/client/assets/Dashboard-BYgqCgBM.js.br +0 -0
- package/dist/client/assets/Dashboard-BYgqCgBM.js.gz +0 -0
- package/dist/client/assets/GitDialog-CA68baSd.js +0 -4
- package/dist/client/assets/GitDialog-CA68baSd.js.br +0 -0
- package/dist/client/assets/GitDialog-CA68baSd.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js +0 -8
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.br +0 -0
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.gz +0 -0
- package/dist/client/assets/InfoPopover-BJYnFn1P.js +0 -1
- package/dist/client/assets/LatexEditor-vNOVTIl7.js +0 -25
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.br +0 -0
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js +0 -1
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js +0 -4
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js +0 -25
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-DIalHHvP.js +0 -2
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js +0 -3
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js +0 -2
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js +0 -1
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-RSqZi7kx.js +0 -1
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.gz +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.br +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +0 -1
- package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
- package/dist/client/assets/editor-CkUEg2La.js +0 -14
- package/dist/client/assets/editor-CkUEg2La.js.br +0 -0
- package/dist/client/assets/editor-CkUEg2La.js.gz +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js +0 -36
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.br +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js +0 -1
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.gz +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.br +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.gz +0 -0
- package/dist/client/assets/i18n-Wn96VbWM.js +0 -13
- package/dist/client/assets/i18n-Wn96VbWM.js.br +0 -0
- package/dist/client/assets/i18n-Wn96VbWM.js.gz +0 -0
- package/dist/client/assets/index-CemLYDYL.js +0 -2
- package/dist/client/assets/index-CemLYDYL.js.br +0 -0
- package/dist/client/assets/index-CemLYDYL.js.gz +0 -0
- package/dist/client/assets/index-DSF5eT29.css +0 -1
- package/dist/client/assets/index-DSF5eT29.css.br +0 -0
- package/dist/client/assets/index-DSF5eT29.css.gz +0 -0
- package/dist/client/assets/relativeTime-C-GTw3lA.js +0 -1
- package/dist/client/assets/relativeTime-C-GTw3lA.js.br +0 -0
- package/dist/client/assets/relativeTime-C-GTw3lA.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js +0 -1
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.gz +0 -0
- package/dist/client/assets/spellCheck-kxvnxrvw.js.br +0 -0
- package/dist/client/assets/spellCheck-kxvnxrvw.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-Ck8lMOWz.js +0 -1
- package/dist/client/assets/textLanguages-CwWstpJ5.js +0 -78
- package/dist/client/assets/textLanguages-CwWstpJ5.js.br +0 -0
- package/dist/client/assets/textLanguages-CwWstpJ5.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js +0 -1
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.gz +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.br +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.gz +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js → AgentIcon-CjaO3WzI.js} +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js.br → AgentIcon-CjaO3WzI.js.br} +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js.gz → AgentIcon-CjaO3WzI.js.gz} +0 -0
|
@@ -8,10 +8,14 @@ import { requireUser } from "../auth.js";
|
|
|
8
8
|
import { reanchorFileComments } from "../anchors.js";
|
|
9
9
|
import { isCollaborativeTextFile, maxCollaborativeFileBytes } from "../collaboration.js";
|
|
10
10
|
import { compileMainFile } from "../compileArtifacts.js";
|
|
11
|
-
import { assertNoSourceSymlinks, listProjectFilesAsync, resolveSourcePath, safePathSegment, safeRelativePath, sourceRoot } from "../files.js";
|
|
12
|
-
import { apiError, contentDisposition, httpError } from "../http.js";
|
|
11
|
+
import { assertNoSourceSymlinks, listProjectFilesAsync, outputRoot, removeProjectSourcePath, renameProjectPath, resolveProjectMoveDestination, resolveSourcePath, safePathSegment, safeRelativePath, sourceRoot } from "../files.js";
|
|
12
|
+
import { apiError, contentDisposition, HttpError, httpError } from "../http.js";
|
|
13
|
+
import { saveProjectText } from "../projectTextSave.js";
|
|
14
|
+
import { moveEditHistoryPaths } from "../editHistory.js";
|
|
13
15
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
14
16
|
import { mainDocumentCandidates } from "../latexRoot.js";
|
|
17
|
+
import { inspectPdfFonts } from "../pdfFonts.js";
|
|
18
|
+
import { DRAWIO_LOCK_HEADER } from "../../shared/drawio.js";
|
|
15
19
|
import { isTextContent } from "../../shared/fileTypes.js";
|
|
16
20
|
import { commentsForFile, escapeGlobPattern, movedProjectPath, now, requireEditableProject, touchProject } from "./projectShared.js";
|
|
17
21
|
/** Register project file-tree, editor content, and upload routes. */
|
|
@@ -132,6 +136,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
132
136
|
const absolute = resolveSourcePath(config, id, folderPath);
|
|
133
137
|
if (fs.existsSync(absolute))
|
|
134
138
|
return apiError(reply, 409, "PATH_EXISTS", { path: folderPath });
|
|
139
|
+
projectMutations.drawioLocks.assertUnlocked(id, [folderPath]);
|
|
135
140
|
fs.mkdirSync(absolute, { recursive: true, mode: 0o700 });
|
|
136
141
|
touchProject(db, id, user.id);
|
|
137
142
|
// Empty folders have no file entry to trigger a refresh on their own.
|
|
@@ -182,12 +187,11 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
182
187
|
if (!fs.existsSync(destinationRoot) || !fs.statSync(destinationRoot).isDirectory()) {
|
|
183
188
|
return apiError(reply, 404, "DIRECTORY_NOT_FOUND", { path: destinationDirectory });
|
|
184
189
|
}
|
|
185
|
-
const destinationAbsolute =
|
|
186
|
-
if (fs.existsSync(destinationAbsolute))
|
|
187
|
-
return apiError(reply, 409, "PATH_EXISTS", { path: destination });
|
|
190
|
+
const destinationAbsolute = resolveProjectMoveDestination(config, id, source, destination);
|
|
188
191
|
let currentProject = project;
|
|
189
192
|
const validateMove = () => {
|
|
190
193
|
currentProject = requireEditableProject(db, id, user);
|
|
194
|
+
projectMutations.drawioLocks.assertUnlocked(id, [source, destination]);
|
|
191
195
|
assertNoSourceSymlinks(config, id);
|
|
192
196
|
if (source === currentProject.main_file && !/\.tex$/i.test(destination)) {
|
|
193
197
|
throw httpError(400, "MAIN_DOCUMENT_INVALID");
|
|
@@ -202,9 +206,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
202
206
|
if (!fs.existsSync(destinationRoot) || !fs.statSync(destinationRoot).isDirectory()) {
|
|
203
207
|
throw httpError(404, "DIRECTORY_NOT_FOUND", { path: destinationDirectory });
|
|
204
208
|
}
|
|
205
|
-
|
|
206
|
-
throw httpError(409, "PATH_EXISTS", { path: destination });
|
|
207
|
-
}
|
|
209
|
+
resolveProjectMoveDestination(config, id, source, destination);
|
|
208
210
|
};
|
|
209
211
|
// Moving/renaming is collaboration-aware: movePath() remaps the live Yjs
|
|
210
212
|
// texts and publishes a files event. It therefore needs the ordinary
|
|
@@ -212,7 +214,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
212
214
|
// epoch and makes every connected browser reload after an otherwise safe
|
|
213
215
|
// drag-and-drop move.
|
|
214
216
|
return await projectMutations.runWrite(id, () => {
|
|
215
|
-
|
|
217
|
+
renameProjectPath(sourceAbsolute, destinationAbsolute);
|
|
216
218
|
let hasCommentUpdates = false;
|
|
217
219
|
db.exec("BEGIN IMMEDIATE");
|
|
218
220
|
try {
|
|
@@ -230,6 +232,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
230
232
|
hasCommentUpdates = true;
|
|
231
233
|
}
|
|
232
234
|
}
|
|
235
|
+
moveEditHistoryPaths(db, id, (filePath) => movedProjectPath(filePath, source, destination));
|
|
233
236
|
db.exec("COMMIT");
|
|
234
237
|
}
|
|
235
238
|
catch (error) {
|
|
@@ -244,6 +247,68 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
244
247
|
return { ok: true, path: destination };
|
|
245
248
|
}, { preflight: validateMove });
|
|
246
249
|
});
|
|
250
|
+
app.get("/api/projects/:id/file/fonts", async (request, reply) => {
|
|
251
|
+
const user = requireUser(request, reply, db);
|
|
252
|
+
if (!user)
|
|
253
|
+
return;
|
|
254
|
+
const { id } = request.params;
|
|
255
|
+
if (!accessibleProject(db, id, user))
|
|
256
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
257
|
+
const query = request.query;
|
|
258
|
+
const filePath = safeRelativePath(typeof query.path === "string" ? query.path : "");
|
|
259
|
+
if (!/\.pdf$/i.test(filePath))
|
|
260
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
261
|
+
const controller = new AbortController();
|
|
262
|
+
const cancel = () => { if (!reply.raw.writableEnded)
|
|
263
|
+
controller.abort(); };
|
|
264
|
+
reply.raw.once("close", cancel);
|
|
265
|
+
reply.header("Cache-Control", "private, no-store");
|
|
266
|
+
let temporaryDirectory;
|
|
267
|
+
try {
|
|
268
|
+
const temporaryRoot = path.join(config.dataDir, "tmp");
|
|
269
|
+
await fs.promises.mkdir(temporaryRoot, { recursive: true, mode: 0o700 });
|
|
270
|
+
temporaryDirectory = await fs.promises.mkdtemp(path.join(temporaryRoot, "pdf-fonts-"));
|
|
271
|
+
const snapshot = path.join(temporaryDirectory, "document.pdf");
|
|
272
|
+
// Inspect stable bytes without holding the source-tree queue while a
|
|
273
|
+
// host process runs. Moving/replacing the original cannot change this copy.
|
|
274
|
+
await projectMutations.runFilesystemRead(id, async () => {
|
|
275
|
+
const absolute = resolveSourcePath(config, id, filePath);
|
|
276
|
+
const stat = await fs.promises.stat(absolute).catch((error) => {
|
|
277
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
278
|
+
return null;
|
|
279
|
+
throw error;
|
|
280
|
+
});
|
|
281
|
+
if (!stat?.isFile())
|
|
282
|
+
throw httpError(404, "FILE_NOT_FOUND", { path: filePath });
|
|
283
|
+
await fs.promises.copyFile(absolute, snapshot);
|
|
284
|
+
}, { preflight: () => {
|
|
285
|
+
if (controller.signal.aborted)
|
|
286
|
+
throw new DOMException("Aborted", "AbortError");
|
|
287
|
+
if (!accessibleProject(db, id, user))
|
|
288
|
+
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
289
|
+
} });
|
|
290
|
+
const result = await inspectPdfFonts(snapshot, controller.signal);
|
|
291
|
+
if (controller.signal.aborted)
|
|
292
|
+
return;
|
|
293
|
+
if (!accessibleProject(db, id, user))
|
|
294
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
295
|
+
return { path: filePath, ...result };
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
if (controller.signal.aborted)
|
|
299
|
+
return;
|
|
300
|
+
if (!accessibleProject(db, id, user))
|
|
301
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
302
|
+
if (error instanceof HttpError)
|
|
303
|
+
return apiError(reply, error.statusCode, error.code, error.details);
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
finally {
|
|
307
|
+
reply.raw.removeListener("close", cancel);
|
|
308
|
+
if (temporaryDirectory)
|
|
309
|
+
await fs.promises.rm(temporaryDirectory, { recursive: true, force: true }).catch(() => undefined);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
247
312
|
app.get("/api/projects/:id/file/raw", async (request, reply) => {
|
|
248
313
|
const user = requireUser(request, reply, db);
|
|
249
314
|
if (!user)
|
|
@@ -346,6 +411,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
346
411
|
}
|
|
347
412
|
return await projectMutations.runWrite(id, () => {
|
|
348
413
|
const absolute = resolveSourcePath(config, id, filePath);
|
|
414
|
+
projectMutations.drawioLocks.assertUnlocked(id, [filePath]);
|
|
349
415
|
try {
|
|
350
416
|
fs.mkdirSync(path.dirname(absolute), { recursive: true, mode: 0o700 });
|
|
351
417
|
}
|
|
@@ -365,11 +431,50 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
365
431
|
throw error;
|
|
366
432
|
}
|
|
367
433
|
touchProject(db, id, user.id);
|
|
368
|
-
|
|
434
|
+
if (isCollaborativeTextFile(filePath))
|
|
435
|
+
collaboration.updateFile(id, filePath, content, user.id);
|
|
436
|
+
else
|
|
437
|
+
collaboration.invalidateSourceTree(id, filePath);
|
|
369
438
|
recordHistory(id, user.id, "file", [filePath]);
|
|
370
439
|
return reply.code(201).send({ ok: true, path: filePath, comments: commentsForFile(db, config, id, filePath) });
|
|
371
440
|
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
372
441
|
});
|
|
442
|
+
// Duplicate a file next to itself. The server chooses the name under the
|
|
443
|
+
// write lock, so two quick copies cannot race for the same "(copy)" name.
|
|
444
|
+
app.post("/api/projects/:id/file/copy", async (request, reply) => {
|
|
445
|
+
const user = requireUser(request, reply, db);
|
|
446
|
+
if (!user)
|
|
447
|
+
return;
|
|
448
|
+
const { id } = request.params;
|
|
449
|
+
if (collaboration.isMaintaining(id))
|
|
450
|
+
return apiError(reply, 409, "PROJECT_BUSY");
|
|
451
|
+
const project = accessibleProject(db, id, user);
|
|
452
|
+
if (!project || !canEdit(project))
|
|
453
|
+
return apiError(reply, 403, "PROJECT_EDIT_FORBIDDEN");
|
|
454
|
+
const body = request.body;
|
|
455
|
+
const source = safeRelativePath(typeof body.path === "string" ? body.path : "");
|
|
456
|
+
return await projectMutations.runWrite(id, () => {
|
|
457
|
+
assertNoSourceSymlinks(config, id);
|
|
458
|
+
// runWrite() has flushed live Yjs edits, so the copy has the text
|
|
459
|
+
// collaborators currently see rather than an older file on disk.
|
|
460
|
+
const sourceAbsolute = resolveSourcePath(config, id, source);
|
|
461
|
+
if (!fs.existsSync(sourceAbsolute) || !fs.statSync(sourceAbsolute).isFile()) {
|
|
462
|
+
return apiError(reply, 404, "FILE_NOT_FOUND", { path: source });
|
|
463
|
+
}
|
|
464
|
+
const destination = copiedFilePath(source, (candidate) => fs.existsSync(resolveSourcePath(config, id, candidate)));
|
|
465
|
+
const destinationAbsolute = resolveSourcePath(config, id, destination);
|
|
466
|
+
fs.copyFileSync(sourceAbsolute, destinationAbsolute, fs.constants.COPYFILE_EXCL);
|
|
467
|
+
touchProject(db, id, user.id);
|
|
468
|
+
const bytes = isCollaborativeTextFile(destination) && fs.statSync(destinationAbsolute).size <= maxCollaborativeFileBytes(config)
|
|
469
|
+
? fs.readFileSync(destinationAbsolute) : null;
|
|
470
|
+
if (bytes !== null && isTextContent(bytes))
|
|
471
|
+
collaboration.updateFile(id, destination, bytes.toString("utf8"), user.id);
|
|
472
|
+
else
|
|
473
|
+
collaboration.invalidateSourceTree(id, destination);
|
|
474
|
+
recordHistory(id, user.id, "file", [destination]);
|
|
475
|
+
return reply.code(201).send({ ok: true, path: destination });
|
|
476
|
+
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
477
|
+
});
|
|
373
478
|
app.put("/api/projects/:id/file", async (request, reply) => {
|
|
374
479
|
const user = requireUser(request, reply, db);
|
|
375
480
|
if (!user)
|
|
@@ -396,18 +501,24 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
396
501
|
const absolute = resolveSourcePath(config, id, filePath);
|
|
397
502
|
if (!isCollaborativeTextFile(filePath))
|
|
398
503
|
return apiError(reply, 400, "FILE_CONTENT_INVALID");
|
|
399
|
-
|
|
504
|
+
const previous = fs.statSync(absolute, { throwIfNoEntry: false });
|
|
505
|
+
if (previous && !previous.isFile())
|
|
506
|
+
return apiError(reply, 409, "PATH_EXISTS", { path: filePath });
|
|
507
|
+
if (previous && previous.size > maxCollaborativeFileBytes(config)) {
|
|
400
508
|
return apiError(reply, 413, "FILE_TOO_LARGE", { path: filePath });
|
|
401
509
|
}
|
|
402
510
|
fs.mkdirSync(path.dirname(absolute), { recursive: true, mode: 0o700 });
|
|
403
|
-
const previousBytes =
|
|
511
|
+
const previousBytes = previous ? fs.readFileSync(absolute) : Buffer.alloc(0);
|
|
404
512
|
if (!isTextContent(previousBytes))
|
|
405
513
|
return apiError(reply, 400, "FILE_CONTENT_INVALID");
|
|
406
514
|
const previousContent = previousBytes.toString("utf8");
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
515
|
+
saveProjectText(db, outputRoot(config, id), absolute, Buffer.from(content, "utf8"), previous, () => {
|
|
516
|
+
reanchorFileComments(db, id, filePath, previousContent, content);
|
|
517
|
+
touchProject(db, id, user.id);
|
|
518
|
+
}, (err, directory) => app.log.warn({ err, directory }, "Could not clean up source save staging"));
|
|
410
519
|
collaboration.updateFile(id, filePath, content, user.id);
|
|
520
|
+
if (previousContent !== content)
|
|
521
|
+
collaboration.signalComments(id);
|
|
411
522
|
recordHistory(id, user.id, "file", [filePath]);
|
|
412
523
|
return { ok: true, comments: commentsForFile(db, config, id, filePath) };
|
|
413
524
|
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
@@ -426,6 +537,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
426
537
|
return apiError(reply, 403, "PROJECT_EDIT_FORBIDDEN");
|
|
427
538
|
return await projectMutations.runWrite(id, () => {
|
|
428
539
|
const currentProject = requireEditableProject(db, id, user);
|
|
540
|
+
const releaseDrawio = projectMutations.drawioLocks.prepareDelete(id, relative, user.id, request.headers[DRAWIO_LOCK_HEADER]);
|
|
429
541
|
if (relative === currentProject.main_file || currentProject.main_file.startsWith(`${relative}/`)) {
|
|
430
542
|
return apiError(reply, 400, "MAIN_FILE_DELETE_FORBIDDEN", { path: relative });
|
|
431
543
|
}
|
|
@@ -438,7 +550,8 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
438
550
|
return apiError(reply, 404, "PATH_NOT_FOUND", { path: relative });
|
|
439
551
|
throw error;
|
|
440
552
|
}
|
|
441
|
-
|
|
553
|
+
removeProjectSourcePath(config, absolute);
|
|
554
|
+
releaseDrawio();
|
|
442
555
|
if (currentProject.latexmkrc === relative || currentProject.latexmkrc?.startsWith(`${relative}/`)) {
|
|
443
556
|
db.prepare("UPDATE projects SET latexmkrc = NULL WHERE id = ?").run(id);
|
|
444
557
|
}
|
|
@@ -501,6 +614,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
501
614
|
}
|
|
502
615
|
try {
|
|
503
616
|
return await projectMutations.runWrite(id, () => {
|
|
617
|
+
projectMutations.drawioLocks.assertUnlocked(id, [relative]);
|
|
504
618
|
const absolute = resolveSourcePath(config, id, relative);
|
|
505
619
|
try {
|
|
506
620
|
fs.mkdirSync(path.dirname(absolute), { recursive: true, mode: 0o700 });
|
|
@@ -535,11 +649,21 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
535
649
|
}
|
|
536
650
|
}
|
|
537
651
|
try {
|
|
538
|
-
|
|
652
|
+
renameProjectPath(tmpPath, absolute);
|
|
539
653
|
}
|
|
540
|
-
catch {
|
|
541
|
-
|
|
542
|
-
|
|
654
|
+
catch (error) {
|
|
655
|
+
if (error.code !== "EXDEV")
|
|
656
|
+
throw error;
|
|
657
|
+
// A separately mounted project needs a same-directory staged copy.
|
|
658
|
+
// Never copy directly over the live file, especially on a sharing violation.
|
|
659
|
+
const staged = path.join(path.dirname(absolute), `.texlite-upload-${randomUUID()}.tmp`);
|
|
660
|
+
try {
|
|
661
|
+
fs.copyFileSync(tmpPath, staged, fs.constants.COPYFILE_EXCL);
|
|
662
|
+
renameProjectPath(staged, absolute);
|
|
663
|
+
}
|
|
664
|
+
finally {
|
|
665
|
+
fs.rmSync(staged, { force: true });
|
|
666
|
+
}
|
|
543
667
|
}
|
|
544
668
|
touchProject(db, id, user.id);
|
|
545
669
|
if (collaborativeText) {
|
|
@@ -569,3 +693,19 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
569
693
|
}
|
|
570
694
|
});
|
|
571
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
* Name a copy beside its source: `main.tex` becomes `main (copy).tex`, then
|
|
698
|
+
* `main (copy 2).tex`. A leading dot is part of the name, not an extension.
|
|
699
|
+
*/
|
|
700
|
+
export function copiedFilePath(source, exists) {
|
|
701
|
+
const slash = source.lastIndexOf("/");
|
|
702
|
+
const directory = slash < 0 ? "" : source.slice(0, slash + 1);
|
|
703
|
+
const name = source.slice(slash + 1);
|
|
704
|
+
const dot = name.lastIndexOf(".");
|
|
705
|
+
const [stem, extension] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, ""];
|
|
706
|
+
for (let attempt = 1;; attempt += 1) {
|
|
707
|
+
const candidate = `${directory}${stem} (copy${attempt === 1 ? "" : ` ${attempt}`})${extension}`;
|
|
708
|
+
if (!exists(candidate))
|
|
709
|
+
return candidate;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
@@ -75,7 +75,7 @@ export function registerProjectGitRoutes(app, context) {
|
|
|
75
75
|
if (collaboration.isMaintaining(id))
|
|
76
76
|
return apiError(reply, 409, "PROJECT_BUSY");
|
|
77
77
|
const body = request.body;
|
|
78
|
-
return await projectMutations.
|
|
78
|
+
return await projectMutations.runConsistentRead(id, async () => {
|
|
79
79
|
const project = requireGitOwner(id, user);
|
|
80
80
|
const commit = await projectGit.commit(project, user, typeof body.message === "string" ? body.message : "");
|
|
81
81
|
return reply.code(201).send({ commit, status: await projectGit.status(project) });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { requireUser } from "../auth.js";
|
|
3
3
|
import { isCollaborativeTextFile, maxCollaborativeFileBytes } from "../collaboration.js";
|
|
4
|
-
import {
|
|
4
|
+
import { normalizeAgentChangeLineEndings } from "../agentChanges.js";
|
|
5
|
+
import { hashText, MAX_SELECTION_HISTORY_OFFSET } from "../editHistory.js";
|
|
5
6
|
import { HISTORY_RETENTION_DELAY_MS } from "../historyRetention.js";
|
|
6
7
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
7
8
|
import { apiError, httpError } from "../http.js";
|
|
@@ -65,6 +66,9 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
65
66
|
if (start === null || end === null || start === end)
|
|
66
67
|
return apiError(reply, 400, "REQUEST_INVALID");
|
|
67
68
|
const requestedLimit = parseOffset(query.limit);
|
|
69
|
+
const offset = query.offset === undefined ? 0 : parseOffset(query.offset);
|
|
70
|
+
if (offset === null || offset > MAX_SELECTION_HISTORY_OFFSET)
|
|
71
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
68
72
|
return await projectMutations.runConsistentRead(id, () => {
|
|
69
73
|
const source = resolveSourcePath(config, id, filePath);
|
|
70
74
|
if (!fs.existsSync(source) || !fs.statSync(source).isFile())
|
|
@@ -76,7 +80,7 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
76
80
|
return apiError(reply, 409, "SELECTION_HISTORY_SOURCE_CHANGED");
|
|
77
81
|
if (start > end || end > content.length)
|
|
78
82
|
return apiError(reply, 400, "REQUEST_INVALID");
|
|
79
|
-
return editHistory.selectionHistory(id, filePath, content, start, end, requestedLimit ?? undefined);
|
|
83
|
+
return editHistory.selectionHistory(id, filePath, content, start, end, requestedLimit ?? undefined, offset);
|
|
80
84
|
}, { preflight: () => {
|
|
81
85
|
if (!accessibleProject(db, id, user))
|
|
82
86
|
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
@@ -94,10 +98,18 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
94
98
|
const { id } = request.params;
|
|
95
99
|
if (!accessibleProject(db, id, user))
|
|
96
100
|
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
97
|
-
|
|
101
|
+
// Everything below is synchronous, so no autosave can interleave with it.
|
|
102
|
+
return await projectMutations.runSnapshot(id, () => {
|
|
98
103
|
const paths = db.prepare(`SELECT DISTINCT file_path FROM project_edit_segments
|
|
99
104
|
WHERE project_id = ? AND author_id = ? AND has_agent = 1 ORDER BY file_path LIMIT ?`)
|
|
100
105
|
.all(id, user.id, MAX_AGENT_CHANGE_FILES).map((row) => row.file_path);
|
|
106
|
+
// A running agent's newest write may not have reached the edit chain yet.
|
|
107
|
+
// Its file would not match the chain's end and look as if it had no changes.
|
|
108
|
+
try {
|
|
109
|
+
projectMutations.reconcileExternalSources(id, paths);
|
|
110
|
+
}
|
|
111
|
+
catch { /* The writer's next scan reports this and stops the task. */ }
|
|
112
|
+
projectMutations.flushProject(id);
|
|
101
113
|
const files = [];
|
|
102
114
|
for (const filePath of paths) {
|
|
103
115
|
if (!isCollaborativeTextFile(filePath))
|
|
@@ -113,8 +125,10 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
113
125
|
continue;
|
|
114
126
|
const content = fs.readFileSync(source, "utf8");
|
|
115
127
|
const changes = editHistory.agentChanges(id, filePath, content, user.id);
|
|
116
|
-
if (changes.length)
|
|
117
|
-
|
|
128
|
+
if (changes.length) {
|
|
129
|
+
const normalized = normalizeAgentChangeLineEndings(changes, content);
|
|
130
|
+
files.push({ path: filePath, sourceHash: hashText(normalized.source), changes: [...normalized.changes] });
|
|
131
|
+
}
|
|
118
132
|
}
|
|
119
133
|
return { files };
|
|
120
134
|
}, { preflight: () => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { requireUser } from "../auth.js";
|
|
4
|
+
import { currentUser, requireUser } from "../auth.js";
|
|
5
5
|
import { maxCollaborativeFileBytes } from "../collaboration.js";
|
|
6
|
+
import { isEngine } from "../config.js";
|
|
6
7
|
import { createProjectFiles, duplicateProjectFiles, outputRoot, removeProjectDirectory, resolveSourcePath, safeRelativePath, sourceRoot } from "../files.js";
|
|
7
8
|
import { apiError, contentDisposition, httpError } from "../http.js";
|
|
8
9
|
import { isMainDocumentCandidate } from "../latexRoot.js";
|
|
@@ -11,6 +12,7 @@ import { accessibleProject, canEdit } from "../projects.js";
|
|
|
11
12
|
import { ProjectPreviewService } from "../projectPreview.js";
|
|
12
13
|
import { writeProjectArchive } from "../archive.js";
|
|
13
14
|
import { extractProjectZip, ZipValidationError } from "../zip.js";
|
|
15
|
+
import { ProjectTemplateCache } from "../projectTemplateCache.js";
|
|
14
16
|
import { HarperLintSupersededError, HarperUnavailableError } from "../harper.js";
|
|
15
17
|
import { ChktexLintSupersededError, ChktexUnavailableError } from "../chktex.js";
|
|
16
18
|
import { supportsChktexChecks, supportsWritingChecks } from "../../shared/writingChecks.js";
|
|
@@ -22,6 +24,29 @@ const clientIdPattern = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
|
22
24
|
export function registerProjectCatalogRoutes(app, context) {
|
|
23
25
|
const { config, db, collaboration, projectMutations, latexCompletions, projectOutlines, harper, chktex, recordHistory } = context;
|
|
24
26
|
const projectPreviews = new ProjectPreviewService(config);
|
|
27
|
+
const templateCache = new ProjectTemplateCache(path.join(config.dataDir, "tmp", "template-cache"), config.maxUploadBytes);
|
|
28
|
+
/** Both uploaded archives and template URLs use the same project import. */
|
|
29
|
+
const importArchive = async (user, name, archive) => {
|
|
30
|
+
const project = {
|
|
31
|
+
id: randomUUID(), owner_id: user.id, last_modified_by: user.id, name: text(name, 120),
|
|
32
|
+
main_file: "", latexmkrc: null, engine: config.defaultEngine, icon: null, chktex_enabled: 0, created_at: now(), updated_at: now()
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
fs.mkdirSync(sourceRoot(config, project.id), { recursive: true, mode: 0o700 });
|
|
36
|
+
fs.mkdirSync(outputRoot(config, project.id), { recursive: true, mode: 0o700 });
|
|
37
|
+
const extracted = await extractProjectZip(archive, sourceRoot(config, project.id), config.maxUploadBytes);
|
|
38
|
+
project.main_file = extracted.mainFile;
|
|
39
|
+
db.prepare(`INSERT INTO projects (id, owner_id, last_modified_by, name, main_file, latexmkrc, engine, chktex_enabled, created_at, updated_at)
|
|
40
|
+
VALUES (?, ?, ?, ?, ?, NULL, ?, ?, ?, ?)`)
|
|
41
|
+
.run(project.id, project.owner_id, project.last_modified_by, project.name, project.main_file, project.engine, project.chktex_enabled, project.created_at, project.updated_at);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
removeProjectDirectory(config, project.id);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
recordHistory(project.id, user.id, "initial");
|
|
48
|
+
return project;
|
|
49
|
+
};
|
|
25
50
|
// Advanced project icons are served as cacheable SVG masks. The browser
|
|
26
51
|
// therefore does not have to bundle Lucide's entire icon catalogue merely
|
|
27
52
|
// because an owner selected an icon outside the curated picker.
|
|
@@ -137,13 +162,17 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
137
162
|
const search = typeof query.search === "string" ? query.search.trim() : "";
|
|
138
163
|
const tagId = typeof query.tag === "string" ? query.tag.trim() : "";
|
|
139
164
|
const sortColumn = query.sort === "created" ? "p.created_at" : "p.updated_at";
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
: "NOT EXISTS (SELECT 1 FROM user_project_archives archive WHERE archive.project_id = p.id AND archive.user_id = :userId)";
|
|
165
|
+
const isArchived = "EXISTS (SELECT 1 FROM user_project_archives archive WHERE archive.project_id = p.id AND archive.user_id = :userId)";
|
|
166
|
+
const archiveCondition = archivedOnly ? isArchived : `NOT ${isArchived}`;
|
|
143
167
|
const from = `FROM projects p JOIN users owner ON owner.id = p.owner_id
|
|
144
168
|
LEFT JOIN users modifier ON modifier.id = p.last_modified_by
|
|
145
169
|
LEFT JOIN project_members pm ON pm.project_id = p.id AND pm.user_id = :userId`;
|
|
146
170
|
const conditions = ["(p.owner_id = :userId OR pm.user_id = :userId)"];
|
|
171
|
+
// Archive badges describe the whole category, not the filtered result set.
|
|
172
|
+
const archivedCounts = db.prepare(`SELECT COUNT(DISTINCT p.id) AS "all",
|
|
173
|
+
COUNT(DISTINCT CASE WHEN p.owner_id = :userId THEN p.id END) AS owned,
|
|
174
|
+
COUNT(DISTINCT CASE WHEN p.owner_id <> :userId THEN p.id END) AS shared
|
|
175
|
+
${from} WHERE ${conditions[0]} AND ${isArchived}`).get({ userId: user.id });
|
|
147
176
|
const params = { userId: user.id };
|
|
148
177
|
if (search) {
|
|
149
178
|
conditions.push("(p.name LIKE :search ESCAPE '\\' OR owner.username LIKE :search ESCAPE '\\' OR owner.display_name LIKE :search ESCAPE '\\')");
|
|
@@ -190,7 +219,8 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
190
219
|
return {
|
|
191
220
|
projects: projects.map((project) => ({ ...projectJson({ ...project, archived: archivedOnly }, projectTags.get(project.id) ?? [], commentsSummaries.get(project.id), unreadMentionCounts.get(project.id) ?? 0), ...(previews.has(project.id) ? { preview: previews.get(project.id) } : {}) })),
|
|
192
221
|
pagination: { page: currentPage, pageSize, total, totalPages },
|
|
193
|
-
counts
|
|
222
|
+
counts,
|
|
223
|
+
archivedCounts
|
|
194
224
|
};
|
|
195
225
|
});
|
|
196
226
|
app.post("/api/projects", async (request, reply) => {
|
|
@@ -201,6 +231,41 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
201
231
|
return apiError(reply, 403, "PROJECT_CREATE_FORBIDDEN");
|
|
202
232
|
}
|
|
203
233
|
const body = request.body;
|
|
234
|
+
if (body?.templateUrl !== undefined) {
|
|
235
|
+
// Validate the name before starting a potentially slow download.
|
|
236
|
+
const name = text(body.name, 120);
|
|
237
|
+
const controller = new AbortController();
|
|
238
|
+
const disconnect = () => { if (!reply.raw.writableEnded)
|
|
239
|
+
controller.abort(); };
|
|
240
|
+
reply.raw.on("close", disconnect);
|
|
241
|
+
const template = await templateCache.download(body.templateUrl, controller.signal)
|
|
242
|
+
.finally(() => reply.raw.off("close", disconnect));
|
|
243
|
+
if (controller.signal.aborted)
|
|
244
|
+
return;
|
|
245
|
+
// Downloading may take time; do not create after access was revoked.
|
|
246
|
+
const creator = currentUser(request, db, true);
|
|
247
|
+
if (!creator)
|
|
248
|
+
return apiError(reply, 401, "AUTH_REQUIRED");
|
|
249
|
+
if (creator.must_change_password)
|
|
250
|
+
return apiError(reply, 403, "PASSWORD_CHANGE_REQUIRED");
|
|
251
|
+
if (creator.role !== "admin" && !creator.can_create_projects)
|
|
252
|
+
return apiError(reply, 403, "PROJECT_CREATE_FORBIDDEN");
|
|
253
|
+
let project;
|
|
254
|
+
try {
|
|
255
|
+
project = await importArchive(creator, name, template.archive);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
if (error instanceof ZipValidationError)
|
|
259
|
+
return apiError(reply, 400, error.code, error.details);
|
|
260
|
+
return apiError(reply, 400, "ZIP_INVALID");
|
|
261
|
+
}
|
|
262
|
+
if (!template.cached)
|
|
263
|
+
await templateCache.store(body.templateUrl, template.archive);
|
|
264
|
+
return reply.code(201).send({ project: projectJson({
|
|
265
|
+
...project, permission: "owner", owner_username: creator.username, owner_display_name: creator.display_name,
|
|
266
|
+
last_modified_username: creator.username, last_modified_display_name: creator.display_name
|
|
267
|
+
}) });
|
|
268
|
+
}
|
|
204
269
|
const project = {
|
|
205
270
|
id: randomUUID(), owner_id: user.id, last_modified_by: user.id, name: text(body?.name, 120),
|
|
206
271
|
main_file: "main.tex", latexmkrc: null, engine: config.defaultEngine, icon: null, chktex_enabled: 0, created_at: now(), updated_at: now()
|
|
@@ -233,26 +298,16 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
233
298
|
}
|
|
234
299
|
const query = request.query;
|
|
235
300
|
const fallbackName = path.basename(part.filename, path.extname(part.filename));
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
main_file: "", latexmkrc: null, engine: config.defaultEngine, icon: null, chktex_enabled: 0, created_at: now(), updated_at: now()
|
|
239
|
-
};
|
|
240
|
-
fs.mkdirSync(sourceRoot(config, project.id), { recursive: true, mode: 0o700 });
|
|
241
|
-
fs.mkdirSync(outputRoot(config, project.id), { recursive: true, mode: 0o700 });
|
|
301
|
+
const name = text(query.name || fallbackName, 120);
|
|
302
|
+
let project;
|
|
242
303
|
try {
|
|
243
|
-
|
|
244
|
-
project.main_file = extracted.mainFile;
|
|
245
|
-
db.prepare(`INSERT INTO projects (id, owner_id, last_modified_by, name, main_file, latexmkrc, engine, chktex_enabled, created_at, updated_at)
|
|
246
|
-
VALUES (?, ?, ?, ?, ?, NULL, ?, ?, ?, ?)`)
|
|
247
|
-
.run(project.id, project.owner_id, project.last_modified_by, project.name, project.main_file, project.engine, project.chktex_enabled, project.created_at, project.updated_at);
|
|
304
|
+
project = await importArchive(user, name, await part.toBuffer());
|
|
248
305
|
}
|
|
249
306
|
catch (error) {
|
|
250
|
-
removeProjectDirectory(config, project.id);
|
|
251
307
|
if (error instanceof ZipValidationError)
|
|
252
308
|
return apiError(reply, 400, error.code, error.details);
|
|
253
309
|
return apiError(reply, 400, "ZIP_INVALID");
|
|
254
310
|
}
|
|
255
|
-
recordHistory(project.id, user.id, "initial");
|
|
256
311
|
return reply.code(201).send({ project: projectJson({
|
|
257
312
|
...project, permission: "owner", owner_username: user.username, owner_display_name: user.display_name,
|
|
258
313
|
last_modified_username: user.username, last_modified_display_name: user.display_name
|
|
@@ -558,8 +613,14 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
558
613
|
}
|
|
559
614
|
mainFile = safeRelativePath(body.mainFile);
|
|
560
615
|
}
|
|
561
|
-
|
|
562
|
-
|
|
616
|
+
let engine = currentProject.engine;
|
|
617
|
+
if (body.engine !== undefined && body.engine !== engine) {
|
|
618
|
+
if (!isEngine(body.engine))
|
|
619
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
620
|
+
if (!config.allowedEngines.includes(body.engine))
|
|
621
|
+
return apiError(reply, 422, "LATEX_ENGINE_UNAVAILABLE", { engine: body.engine });
|
|
622
|
+
engine = body.engine;
|
|
623
|
+
}
|
|
563
624
|
const chktexEnabled = typeof body.chktexEnabled === "boolean" ? body.chktexEnabled : Boolean(currentProject.chktex_enabled);
|
|
564
625
|
const latexmkrc = body.latexmkrc === null || body.latexmkrc === ""
|
|
565
626
|
? null
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { publicUser, requireAdmin, requireUser } from "../auth.js";
|
|
3
3
|
import { activeAdminCount } from "../db.js";
|
|
4
|
-
import { removeProjectDirectory } from "../files.js";
|
|
5
4
|
import { apiError, httpError, ValidationError } from "../http.js";
|
|
6
5
|
import { hashPassword } from "../security.js";
|
|
7
6
|
const now = () => new Date().toISOString();
|
|
@@ -13,7 +12,7 @@ function text(value, max = 200) {
|
|
|
13
12
|
}
|
|
14
13
|
/** Register administrator-facing user management and the active-user directory. */
|
|
15
14
|
export function registerUserManagementRoutes(app, context) {
|
|
16
|
-
const {
|
|
15
|
+
const { db, collaboration, projectMutations, projectDeletionCleanup } = context;
|
|
17
16
|
app.get("/api/admin/users", async (request, reply) => {
|
|
18
17
|
if (!requireAdmin(request, reply, db))
|
|
19
18
|
return;
|
|
@@ -133,7 +132,7 @@ export function registerUserManagementRoutes(app, context) {
|
|
|
133
132
|
if (currentTarget.role === "admin" && activeAdminCount(db) <= 1) {
|
|
134
133
|
throw httpError(400, "LAST_ADMIN");
|
|
135
134
|
}
|
|
136
|
-
owned = db.prepare("SELECT id FROM projects WHERE owner_id = ?").all(id);
|
|
135
|
+
owned = db.prepare("SELECT id FROM projects WHERE owner_id = ? ORDER BY created_at, rowid").all(id);
|
|
137
136
|
if (!body.deleteProjects) {
|
|
138
137
|
// Persist any active drafts while the old owner row still exists. This
|
|
139
138
|
// is synchronous, so no edit can arrive between this flush and the
|
|
@@ -142,6 +141,8 @@ export function registerUserManagementRoutes(app, context) {
|
|
|
142
141
|
projectMutations.flushProject(project.id);
|
|
143
142
|
}
|
|
144
143
|
if (body.deleteProjects) {
|
|
144
|
+
for (const project of owned)
|
|
145
|
+
projectDeletionCleanup.enqueue(project.id);
|
|
145
146
|
db.prepare("DELETE FROM projects WHERE owner_id = ?").run(id);
|
|
146
147
|
}
|
|
147
148
|
else {
|
|
@@ -160,20 +161,15 @@ export function registerUserManagementRoutes(app, context) {
|
|
|
160
161
|
// Requests already queued for the removed user fail their lock-time
|
|
161
162
|
// preflight. Cleanup is then serialized after them and invalidates any
|
|
162
163
|
// room initialization that started before the transaction committed.
|
|
164
|
+
collaboration.disconnectUser(id, "user-deleted");
|
|
163
165
|
for (const project of owned) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
if (body.deleteProjects)
|
|
167
|
+
await projectDeletionCleanup.clean(project.id);
|
|
168
|
+
else
|
|
169
|
+
await projectMutations.runExclusive(project.id, "admin ownership transfer", () => {
|
|
166
170
|
collaboration.resetProject(project.id);
|
|
167
|
-
|
|
168
|
-
latexCompletions.invalidate(project.id);
|
|
169
|
-
projectOutlines.invalidate(project.id);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
collaboration.resetProject(project.id);
|
|
173
|
-
}
|
|
174
|
-
}, { flush: false });
|
|
171
|
+
}, { flush: false });
|
|
175
172
|
}
|
|
176
|
-
collaboration.disconnectUser(id, "user-deleted");
|
|
177
173
|
return { ok: true, deletedProjects: body.deleteProjects ? owned.length : 0 };
|
|
178
174
|
});
|
|
179
175
|
app.get("/api/users", async (request, reply) => {
|
package/dist/server/synctex.js
CHANGED
|
@@ -11,6 +11,19 @@ export class SyncTeXError extends Error {
|
|
|
11
11
|
this.name = "SyncTeXError";
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
/** Rebase only absolute project inputs; relative inputs already use the snapshot cwd. */
|
|
15
|
+
export function relocateSyncTeXInputs(content, cacheSource, snapshotSource, platform = process.platform) {
|
|
16
|
+
const paths = platform === "win32" ? path.win32 : path.posix;
|
|
17
|
+
const cacheRoot = paths.resolve(cacheSource);
|
|
18
|
+
return content.replace(/^(Input:\d+:)([^\r\n]+)$/gm, (record, prefix, input) => {
|
|
19
|
+
if (!paths.isAbsolute(input))
|
|
20
|
+
return record;
|
|
21
|
+
const relative = paths.relative(cacheRoot, input);
|
|
22
|
+
if (!relative || relative === ".." || relative.startsWith(`..${paths.sep}`) || paths.isAbsolute(relative))
|
|
23
|
+
return record;
|
|
24
|
+
return prefix + paths.join(snapshotSource, relative);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
14
27
|
async function runSynctex(args, cwd) {
|
|
15
28
|
try {
|
|
16
29
|
const { stdout } = await runFile("synctex", args, {
|
|
@@ -28,9 +41,13 @@ async function runSynctex(args, cwd) {
|
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
43
|
export async function sourceToPdf(sourceDirectory, pdfPath, sourcePath, line, column) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
const view = (input) => runSynctex(["view", "-i", `${line}:${column}:${input}`, "-o", pdfPath], sourceDirectory);
|
|
45
|
+
// TeX Live can record absolute names even for relative \input paths. The
|
|
46
|
+
// SyncTeX CLI may not match a relative query against those records.
|
|
47
|
+
const absoluteInput = path.resolve(sourceDirectory, sourcePath);
|
|
48
|
+
let output = await view(absoluteInput);
|
|
49
|
+
if (absoluteInput !== sourcePath && numericField(output, "Page") === null)
|
|
50
|
+
output = await view(sourcePath);
|
|
34
51
|
const page = numericField(output, "Page");
|
|
35
52
|
const x = numericField(output, "x");
|
|
36
53
|
const y = numericField(output, "y");
|