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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { browserOriginAllowed } from "../browserOrigin.js";
|
|
1
2
|
import { currentUser, requireAdmin, requireUser } from "../auth.js";
|
|
2
3
|
import { apiError, httpError } from "../http.js";
|
|
3
4
|
import { isAgentId } from "../../shared/agentProtocol.js";
|
|
@@ -9,20 +10,6 @@ function title(value, optional = false) {
|
|
|
9
10
|
throw httpError(400, "REQUEST_INVALID");
|
|
10
11
|
return value.trim();
|
|
11
12
|
}
|
|
12
|
-
function terminalOriginAllowed(request) {
|
|
13
|
-
const origin = request.headers.origin;
|
|
14
|
-
if (!origin)
|
|
15
|
-
return false;
|
|
16
|
-
try {
|
|
17
|
-
const parsed = new URL(origin);
|
|
18
|
-
const forwarded = request.headers["x-forwarded-proto"];
|
|
19
|
-
const protocol = forwarded === "https" || forwarded === "http" ? forwarded : request.protocol;
|
|
20
|
-
return parsed.host === request.headers.host && parsed.protocol === `${protocol}:` && parsed.origin === origin;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
13
|
/** Task owners get terminal access; administrators get separate metadata/cleanup routes. */
|
|
27
14
|
export function registerAgentRoutes(app, { db, agents }) {
|
|
28
15
|
app.get("/api/agents/access", async (request, reply) => {
|
|
@@ -114,7 +101,7 @@ export function registerAgentRoutes(app, { db, agents }) {
|
|
|
114
101
|
});
|
|
115
102
|
app.get("/api/agent-tasks/:taskId/terminal", { websocket: true }, (socket, request) => {
|
|
116
103
|
const user = currentUser(request, db);
|
|
117
|
-
if (!user || !
|
|
104
|
+
if (!user || !browserOriginAllowed(request)) {
|
|
118
105
|
socket.close(1008, "Access denied");
|
|
119
106
|
return;
|
|
120
107
|
}
|
|
@@ -4,7 +4,7 @@ import { requireUser } from "../auth.js";
|
|
|
4
4
|
import { createSourceAnchor, offsetToLine } from "../anchors.js";
|
|
5
5
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
6
6
|
import { apiError, httpError } from "../http.js";
|
|
7
|
-
import { accessibleProject } from "../projects.js";
|
|
7
|
+
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
8
|
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
9
9
|
import { attachSuggestion, suggestionReviewers, suggestionRow } from "../commentSuggestions.js";
|
|
10
10
|
import { registerSuggestionRoutes } from "./commentSuggestions.js";
|
|
@@ -201,7 +201,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
201
201
|
if (!user)
|
|
202
202
|
return;
|
|
203
203
|
const { id, commentId } = request.params;
|
|
204
|
-
|
|
204
|
+
const project = accessibleProject(db, id, user);
|
|
205
|
+
if (!project)
|
|
205
206
|
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
206
207
|
const comment = db.prepare("SELECT author_id, resolved, content FROM comments WHERE id = ? AND project_id = ?")
|
|
207
208
|
.get(commentId, id);
|
|
@@ -217,6 +218,10 @@ export function registerCommentRoutes(app, context) {
|
|
|
217
218
|
changed = true;
|
|
218
219
|
}
|
|
219
220
|
if (typeof body.resolved === "boolean") {
|
|
221
|
+
// Read-only members may discuss, but closing or reopening a thread is a
|
|
222
|
+
// review decision for people who can change the project.
|
|
223
|
+
if (!canEdit(project))
|
|
224
|
+
return apiError(reply, 403, "COMMENT_RESOLVE_FORBIDDEN");
|
|
220
225
|
if (body.resolved) {
|
|
221
226
|
const suggestion = suggestionRow(db, id, commentId);
|
|
222
227
|
if (suggestion?.status === "pending" && (suggestion.apply_update
|
|
@@ -3,17 +3,19 @@ import { parseByteRange } from "../byteRange.js";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
|
+
import { isEngine } from "../config.js";
|
|
6
7
|
import { requireUser } from "../auth.js";
|
|
7
8
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
|
-
import { outputRoot, resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
|
|
9
|
+
import { outputRoot, renameProjectPath, resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
|
|
9
10
|
import { isStandaloneTikz } from "../../shared/tikzStandalone.js";
|
|
10
11
|
import { touchProject } from "./projectShared.js";
|
|
11
12
|
import { captureCompileSnapshot, cleanCompileArtifacts, cleanCompileCache, CompileCancelledError, compileProject, discardCompileSnapshot, hasCompileCache, publishCompileArtifacts, publishedCompileArtifacts } from "../compiler.js";
|
|
12
13
|
import { parseCompileDiagnostics } from "../compileDiagnostics.js";
|
|
13
14
|
import { pdfToSource, sourceToPdf } from "../synctex.js";
|
|
15
|
+
import { inspectPdfFonts } from "../pdfFonts.js";
|
|
14
16
|
import { availablePdf, compileRunPdf, compileMainFile, compilePdfUrl, isTextCompileArtifact, listCompileArtifacts, pdfLoadingMode, syncArtifacts } from "../compileArtifacts.js";
|
|
15
17
|
import { MAX_TEXT_PREVIEW_BYTES } from "../limits.js";
|
|
16
|
-
import { apiError, contentDisposition, httpError } from "../http.js";
|
|
18
|
+
import { apiError, contentDisposition, httpError, HttpError } from "../http.js";
|
|
17
19
|
const now = () => new Date().toISOString();
|
|
18
20
|
const timingDuration = (milliseconds) => Math.round(milliseconds * 10) / 10;
|
|
19
21
|
const MAX_SNAPSHOT_ATTEMPTS = 3;
|
|
@@ -89,6 +91,55 @@ export function registerCompileRoutes(app, context) {
|
|
|
89
91
|
...pdfMetadata
|
|
90
92
|
};
|
|
91
93
|
});
|
|
94
|
+
app.get("/api/projects/:id/compile/fonts", async (request, reply) => {
|
|
95
|
+
const user = requireUser(request, reply, db);
|
|
96
|
+
if (!user)
|
|
97
|
+
return;
|
|
98
|
+
const { id } = request.params;
|
|
99
|
+
const project = accessibleProject(db, id, user);
|
|
100
|
+
if (!project)
|
|
101
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
102
|
+
const query = request.query;
|
|
103
|
+
const mainFile = compileMainFile(config, id, project.main_file, query.mainFile);
|
|
104
|
+
if (!mainFile)
|
|
105
|
+
return apiError(reply, 400, "MAIN_DOCUMENT_INVALID");
|
|
106
|
+
// Require the displayed PDF's immutable run identity, never the latest log's run.
|
|
107
|
+
if (!query.run || !/^[a-f0-9-]{36}$/i.test(query.run))
|
|
108
|
+
return apiError(reply, 404, "PDF_NOT_FOUND");
|
|
109
|
+
const run = db.prepare(`SELECT id FROM compile_runs
|
|
110
|
+
WHERE id = ? AND project_id = ? AND main_file = ? AND status = 'succeeded'`).get(query.run, id, mainFile);
|
|
111
|
+
const pdf = run ? compileRunPdf(config, id, mainFile, query.run) : null;
|
|
112
|
+
if (!pdf)
|
|
113
|
+
return apiError(reply, 404, "PDF_NOT_FOUND");
|
|
114
|
+
const controller = new AbortController();
|
|
115
|
+
const cancel = () => { if (!reply.raw.writableEnded)
|
|
116
|
+
controller.abort(); };
|
|
117
|
+
reply.raw.once("close", cancel);
|
|
118
|
+
reply.header("Cache-Control", "private, no-store");
|
|
119
|
+
try {
|
|
120
|
+
const result = await inspectPdfFonts(pdf.path, controller.signal);
|
|
121
|
+
if (controller.signal.aborted)
|
|
122
|
+
return;
|
|
123
|
+
// Project membership can change while a host tool is running.
|
|
124
|
+
if (!accessibleProject(db, id, user))
|
|
125
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
126
|
+
return { mainFile, runId: query.run, ...result };
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (controller.signal.aborted)
|
|
130
|
+
return;
|
|
131
|
+
if (!accessibleProject(db, id, user))
|
|
132
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
133
|
+
if (!regularFileStat(pdf.path))
|
|
134
|
+
return apiError(reply, 404, "PDF_NOT_FOUND");
|
|
135
|
+
if (error instanceof HttpError)
|
|
136
|
+
return apiError(reply, error.statusCode, error.code);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
reply.raw.removeListener("close", cancel);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
92
143
|
app.get("/api/projects/:id/compile/artifacts", async (request, reply) => {
|
|
93
144
|
const user = requireUser(request, reply, db);
|
|
94
145
|
if (!user)
|
|
@@ -329,7 +380,7 @@ export function registerCompileRoutes(app, context) {
|
|
|
329
380
|
const staged = path.join(outputRoot(config, id), `.export-${randomUUID()}.pdf`);
|
|
330
381
|
try {
|
|
331
382
|
fs.copyFileSync(pdf.path, staged);
|
|
332
|
-
|
|
383
|
+
renameProjectPath(staged, destination);
|
|
333
384
|
}
|
|
334
385
|
finally {
|
|
335
386
|
fs.rmSync(staged, { force: true });
|
|
@@ -364,12 +415,18 @@ export function registerCompileRoutes(app, context) {
|
|
|
364
415
|
if (!initialProject || !canEdit(initialProject))
|
|
365
416
|
return apiError(reply, 403, "COMPILE_FORBIDDEN");
|
|
366
417
|
const body = (request.body ?? {});
|
|
367
|
-
const requestedEngine =
|
|
368
|
-
if (
|
|
418
|
+
const requestedEngine = body.engine;
|
|
419
|
+
if (requestedEngine !== undefined && !isEngine(requestedEngine))
|
|
369
420
|
return apiError(reply, 400, "REQUEST_INVALID");
|
|
370
421
|
// For this run only; part of the compile generation and cache key, so a
|
|
371
422
|
// request for another engine is neither coalesced nor treated as up to date.
|
|
372
|
-
const withRequestedEngine = (row) =>
|
|
423
|
+
const withRequestedEngine = (row) => {
|
|
424
|
+
const engine = requestedEngine ?? row.engine;
|
|
425
|
+
if (!config.allowedEngines.includes(engine))
|
|
426
|
+
throw httpError(422, "LATEX_ENGINE_UNAVAILABLE", { engine });
|
|
427
|
+
return engine === row.engine ? row : { ...row, engine };
|
|
428
|
+
};
|
|
429
|
+
withRequestedEngine(initialProject);
|
|
373
430
|
const requestedMainFile = typeof body.mainFile === "string" && body.mainFile ? body.mainFile : null;
|
|
374
431
|
const initialMainFile = compileMainFile(config, id, initialProject.main_file, body.mainFile);
|
|
375
432
|
if (!initialMainFile)
|
|
@@ -399,10 +456,11 @@ export function registerCompileRoutes(app, context) {
|
|
|
399
456
|
throw new Error("Project access changed while preparing a compile request");
|
|
400
457
|
}
|
|
401
458
|
const generationRevision = receipt?.revision ?? revisionBeforeFlush;
|
|
459
|
+
const project = withRequestedEngine(refreshedProject);
|
|
402
460
|
const admissionResult = {
|
|
403
|
-
project
|
|
461
|
+
project,
|
|
404
462
|
mainFile: currentMainFile,
|
|
405
|
-
generation: compileRequestGeneration(
|
|
463
|
+
generation: compileRequestGeneration(project, generationRevision, collaboration.currentGeneration(id), config.extraArgs)
|
|
406
464
|
};
|
|
407
465
|
// Insert the queued probe while the project lock is still held. A
|
|
408
466
|
// concurrent clean request must observe this row before the compile
|
|
@@ -598,7 +656,7 @@ export function registerCompileRoutes(app, context) {
|
|
|
598
656
|
if (!db.prepare("SELECT 1 FROM projects WHERE id = ?").get(id)) {
|
|
599
657
|
throw new Error("Project was deleted before compile artifacts could be published.");
|
|
600
658
|
}
|
|
601
|
-
publishCompileArtifacts(config, id, snapshot, compiled);
|
|
659
|
+
publishCompileArtifacts(config, id, snapshot, compiled, (err, directory) => app.log.warn({ err, directory }, "Could not remove a retired compile run"));
|
|
602
660
|
}, { flush: false });
|
|
603
661
|
refreshSnapshotStale();
|
|
604
662
|
if (compiled.timings) {
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
+
import { currentUser, requireUser } from "../auth.js";
|
|
5
|
+
import { browserOriginAllowed } from "../browserOrigin.js";
|
|
6
|
+
import { outputRoot, renameProjectPath, resolveSourcePath, safeRelativePath } from "../files.js";
|
|
7
|
+
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
|
+
import { apiError, HttpError, httpError } from "../http.js";
|
|
9
|
+
import { requireEditableProject, touchProject } from "./projectShared.js";
|
|
10
|
+
import { reanchorFileComments } from "../anchors.js";
|
|
11
|
+
import { DrawioPdfRenderer } from "../drawioPdf.js";
|
|
12
|
+
import { saveProjectText } from "../projectTextSave.js";
|
|
13
|
+
import { drawioPdfPath, isDrawioFile } from "../../shared/drawio.js";
|
|
14
|
+
import { isTextContent } from "../../shared/fileTypes.js";
|
|
15
|
+
const maxDiagramBytes = 5 * 1024 * 1024;
|
|
16
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
17
|
+
function diagramPath(value) {
|
|
18
|
+
const relative = safeRelativePath(typeof value === "string" ? value : "");
|
|
19
|
+
if (!isDrawioFile(relative))
|
|
20
|
+
throw httpError(400, "DRAWIO_INVALID");
|
|
21
|
+
return relative;
|
|
22
|
+
}
|
|
23
|
+
function readDiagram(absolute) {
|
|
24
|
+
if (!fs.existsSync(absolute) || !fs.statSync(absolute).isFile())
|
|
25
|
+
throw httpError(404, "FILE_NOT_FOUND");
|
|
26
|
+
if (fs.statSync(absolute).size > maxDiagramBytes)
|
|
27
|
+
throw httpError(413, "DRAWIO_INVALID");
|
|
28
|
+
const bytes = fs.readFileSync(absolute);
|
|
29
|
+
if (!isTextContent(bytes))
|
|
30
|
+
throw httpError(400, "DRAWIO_INVALID");
|
|
31
|
+
return bytes.toString("utf8");
|
|
32
|
+
}
|
|
33
|
+
function validateXml(content, limit) {
|
|
34
|
+
if (typeof content !== "string" || Buffer.byteLength(content) > limit || !isTextContent(Buffer.from(content))
|
|
35
|
+
|| !/^\s*(?:<\?xml[^>]*>\s*)?<(?:mxfile|mxGraphModel)(?:\s|>)/.test(content)
|
|
36
|
+
|| /<!DOCTYPE/i.test(content))
|
|
37
|
+
throw httpError(400, "DRAWIO_INVALID");
|
|
38
|
+
}
|
|
39
|
+
function pdfRevision(absolute) {
|
|
40
|
+
if (!fs.existsSync(absolute))
|
|
41
|
+
return null;
|
|
42
|
+
if (!fs.statSync(absolute).isFile())
|
|
43
|
+
throw httpError(409, "PATH_EXISTS");
|
|
44
|
+
// Only detect replacement conflicts; do not read an existing large PDF.
|
|
45
|
+
const stat = fs.statSync(absolute, { bigint: true });
|
|
46
|
+
return hash(`${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`);
|
|
47
|
+
}
|
|
48
|
+
function writeAtomic(absolute, bytes) {
|
|
49
|
+
const temporary = path.join(path.dirname(absolute), `.texlite-drawio-${randomUUID()}.tmp`);
|
|
50
|
+
try {
|
|
51
|
+
fs.writeFileSync(temporary, bytes, { mode: 0o600, flag: "wx" });
|
|
52
|
+
renameProjectPath(temporary, absolute);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
fs.rmSync(temporary, { force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function registerDrawioRoutes(app, { config, db, collaboration, projectMutations, recordHistory }) {
|
|
59
|
+
const renderer = new DrawioPdfRenderer((err) => app.log.warn({ err }, "draw.io browser export failed"));
|
|
60
|
+
const locks = projectMutations.drawioLocks;
|
|
61
|
+
// Cancel Windows browser jobs before Fastify waits for in-flight exports.
|
|
62
|
+
app.addHook(process.platform === "win32" ? "preClose" : "onClose", async () => { await renderer.close(); });
|
|
63
|
+
app.get("/api/projects/:id/drawio/lock", { websocket: true }, (socket, request) => {
|
|
64
|
+
const user = currentUser(request, db);
|
|
65
|
+
if (!user || user.must_change_password || !browserOriginAllowed(request)) {
|
|
66
|
+
socket.close(1008, "Access denied");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const { id } = request.params;
|
|
70
|
+
const valid = () => {
|
|
71
|
+
const current = currentUser(request, db, true);
|
|
72
|
+
const project = current && !current.must_change_password ? accessibleProject(db, id, current) : null;
|
|
73
|
+
return Boolean(project && canEdit(project));
|
|
74
|
+
};
|
|
75
|
+
socket.on("error", () => { });
|
|
76
|
+
let relative;
|
|
77
|
+
try {
|
|
78
|
+
relative = diagramPath(request.query.path);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
socket.close(1008, "Invalid diagram");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
void projectMutations.runFilesystemRead(id, () => {
|
|
85
|
+
if (socket.readyState !== 1)
|
|
86
|
+
return;
|
|
87
|
+
const content = readDiagram(resolveSourcePath(config, id, relative));
|
|
88
|
+
validateXml(content, maxDiagramBytes);
|
|
89
|
+
locks.acquire(id, relative, user.id, user.display_name, socket, valid, hash(content));
|
|
90
|
+
}, { preflight: () => { if (!valid())
|
|
91
|
+
throw httpError(403, "PROJECT_EDIT_FORBIDDEN"); } })
|
|
92
|
+
.catch(() => { socket.close(1008, "Diagram unavailable"); });
|
|
93
|
+
});
|
|
94
|
+
app.get("/api/projects/:id/drawio", async (request, reply) => {
|
|
95
|
+
const user = requireUser(request, reply, db);
|
|
96
|
+
if (!user)
|
|
97
|
+
return;
|
|
98
|
+
const { id } = request.params;
|
|
99
|
+
if (!accessibleProject(db, id, user))
|
|
100
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
101
|
+
const relative = diagramPath(request.query.path);
|
|
102
|
+
reply.header("Cache-Control", "private, no-store");
|
|
103
|
+
// Diagrams are not Yjs documents. Keep the filesystem mutation barrier,
|
|
104
|
+
// without making the editor wait for unrelated room hydration.
|
|
105
|
+
return projectMutations.runFilesystemRead(id, () => {
|
|
106
|
+
const content = readDiagram(resolveSourcePath(config, id, relative));
|
|
107
|
+
validateXml(content, maxDiagramBytes);
|
|
108
|
+
return { content, revision: hash(content), pdfRevision: pdfRevision(resolveSourcePath(config, id, drawioPdfPath(relative))) };
|
|
109
|
+
}, { preflight: () => { if (!accessibleProject(db, id, user))
|
|
110
|
+
throw httpError(404, "PROJECT_NOT_FOUND"); } });
|
|
111
|
+
});
|
|
112
|
+
app.put("/api/projects/:id/drawio", { bodyLimit: 6 * 1024 * 1024 }, async (request, reply) => {
|
|
113
|
+
const user = requireUser(request, reply, db);
|
|
114
|
+
if (!user)
|
|
115
|
+
return;
|
|
116
|
+
const { id } = request.params;
|
|
117
|
+
requireEditableProject(db, id, user);
|
|
118
|
+
const body = request.body;
|
|
119
|
+
const relative = diagramPath(body.path);
|
|
120
|
+
validateXml(body.content, Math.min(maxDiagramBytes, config.maxUploadBytes));
|
|
121
|
+
const content = body.content;
|
|
122
|
+
return projectMutations.runWrite(id, () => {
|
|
123
|
+
locks.assertOwned(id, relative, body.lockToken, user.id);
|
|
124
|
+
const absolute = resolveSourcePath(config, id, relative);
|
|
125
|
+
const previous = readDiagram(absolute);
|
|
126
|
+
// A lost response can leave the browser retrying the same save with its
|
|
127
|
+
// old revision. Acknowledge identical bytes without another write.
|
|
128
|
+
if (previous === content)
|
|
129
|
+
return { revision: hash(previous) };
|
|
130
|
+
if (hash(previous) !== body.revision)
|
|
131
|
+
throw httpError(409, "DRAWIO_CONFLICT");
|
|
132
|
+
saveProjectText(db, outputRoot(config, id), absolute, Buffer.from(content, "utf8"), fs.statSync(absolute), () => {
|
|
133
|
+
reanchorFileComments(db, id, relative, previous, content);
|
|
134
|
+
touchProject(db, id, user.id);
|
|
135
|
+
}, (err, directory) => app.log.warn({ err, directory }, "Could not clean up diagram save staging"));
|
|
136
|
+
collaboration.invalidateSourceTree(id, relative);
|
|
137
|
+
recordHistory(id, user.id, "autosave", [relative]);
|
|
138
|
+
return { revision: hash(content) };
|
|
139
|
+
}, { preflight: () => { requireEditableProject(db, id, user); locks.assertOwned(id, relative, body.lockToken, user.id); } });
|
|
140
|
+
});
|
|
141
|
+
app.post("/api/projects/:id/drawio/pdf", { bodyLimit: 12 * 1024 * 1024 }, async (request, reply) => {
|
|
142
|
+
const user = requireUser(request, reply, db);
|
|
143
|
+
if (!user)
|
|
144
|
+
return;
|
|
145
|
+
const { id } = request.params;
|
|
146
|
+
requireEditableProject(db, id, user);
|
|
147
|
+
const body = request.body;
|
|
148
|
+
const relative = diagramPath(body.path), output = drawioPdfPath(relative);
|
|
149
|
+
if (typeof body.svg !== "string" || Buffer.byteLength(body.svg) > 10 * 1024 * 1024
|
|
150
|
+
|| !/^\s*(?:<\?xml[^>]*>\s*)?(?:<!DOCTYPE[^>]*>\s*)?<svg[\s>]/i.test(body.svg))
|
|
151
|
+
return apiError(reply, 400, "DRAWIO_INVALID");
|
|
152
|
+
const validate = () => {
|
|
153
|
+
requireEditableProject(db, id, user);
|
|
154
|
+
locks.assertOwned(id, relative, body.lockToken, user.id);
|
|
155
|
+
if (hash(readDiagram(resolveSourcePath(config, id, relative))) !== body.revision
|
|
156
|
+
|| pdfRevision(resolveSourcePath(config, id, output)) !== body.pdfRevision)
|
|
157
|
+
throw httpError(409, "DRAWIO_CONFLICT");
|
|
158
|
+
};
|
|
159
|
+
// Validate before spawning, but never hold the project write queue while
|
|
160
|
+
// rendering. Recheck source, output, and permissions at the actual write.
|
|
161
|
+
await projectMutations.runConsistentRead(id, validate, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
162
|
+
const controller = new AbortController();
|
|
163
|
+
const cancel = () => { if (!reply.raw.writableEnded)
|
|
164
|
+
controller.abort(); };
|
|
165
|
+
reply.raw.on("close", cancel);
|
|
166
|
+
try {
|
|
167
|
+
const pdf = await renderer.render(body.svg, config.drawioBrowserPath, controller.signal);
|
|
168
|
+
controller.signal.throwIfAborted();
|
|
169
|
+
return await projectMutations.runWrite(id, () => {
|
|
170
|
+
controller.signal.throwIfAborted();
|
|
171
|
+
validate();
|
|
172
|
+
const absolute = resolveSourcePath(config, id, output);
|
|
173
|
+
writeAtomic(absolute, pdf);
|
|
174
|
+
touchProject(db, id, user.id);
|
|
175
|
+
collaboration.invalidateSourceTree(id, output);
|
|
176
|
+
recordHistory(id, user.id, "file", [output]);
|
|
177
|
+
return { path: output, pdfRevision: pdfRevision(absolute) };
|
|
178
|
+
}, { preflight: validate });
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (controller.signal.aborted)
|
|
182
|
+
return;
|
|
183
|
+
requireEditableProject(db, id, user);
|
|
184
|
+
if (error instanceof HttpError)
|
|
185
|
+
return apiError(reply, error.statusCode, error.code, error.details);
|
|
186
|
+
return apiError(reply, 422, "DRAWIO_EXPORT_FAILED");
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
reply.raw.off("close", cancel);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|