texlite 0.19.2 → 0.21.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 +276 -9
- package/OPERATIONS.md +7 -4
- package/README.md +9 -6
- package/README.zh-CN.md +8 -5
- package/dist/client/assets/AdminUsers-Cpj29JD6.js +1 -0
- package/dist/client/assets/AdminUsers-Cpj29JD6.js.br +0 -0
- package/dist/client/assets/AdminUsers-Cpj29JD6.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js +1 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.br +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.gz +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css +1 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
- package/dist/client/assets/AgentManagement-0n1UkKZ5.js +1 -0
- package/dist/client/assets/AgentManagement-0n1UkKZ5.js.br +0 -0
- package/dist/client/assets/AgentManagement-0n1UkKZ5.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-BbGH5iPx.js +2 -0
- package/dist/client/assets/AgentTerminal-BbGH5iPx.js.br +0 -0
- package/dist/client/assets/AgentTerminal-BbGH5iPx.js.gz +0 -0
- package/dist/client/assets/{AgentTerminalSurface-C11baRxh.js → AgentTerminalSurface-CIouKd-C.js} +2 -2
- package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js +1 -0
- package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-B4ITqbxl.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.gz +0 -0
- package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js +36 -0
- package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.br +0 -0
- package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.gz +0 -0
- package/dist/client/assets/Dashboard-Dc3ANXhG.js +5 -0
- package/dist/client/assets/Dashboard-Dc3ANXhG.js.br +0 -0
- package/dist/client/assets/Dashboard-Dc3ANXhG.js.gz +0 -0
- package/dist/client/assets/GitDialog-CzLmo9Z_.js +3 -0
- package/dist/client/assets/GitDialog-CzLmo9Z_.js.br +0 -0
- package/dist/client/assets/GitDialog-CzLmo9Z_.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-CExJn0AV.js +1 -0
- package/dist/client/assets/HistoryDialog-C4zmnE1s.js +8 -0
- package/dist/client/assets/HistoryDialog-C4zmnE1s.js.br +0 -0
- package/dist/client/assets/HistoryDialog-C4zmnE1s.js.gz +0 -0
- package/dist/client/assets/InfoPopover-Dkz742vJ.js +1 -0
- package/dist/client/assets/LatexEditor-BRPiyMbH.js +25 -0
- package/dist/client/assets/LatexEditor-BRPiyMbH.js.br +0 -0
- package/dist/client/assets/LatexEditor-BRPiyMbH.js.gz +0 -0
- package/dist/client/assets/PdfPreview-CIOM7sbu.js +1 -0
- package/dist/client/assets/PdfPreview-CIOM7sbu.js.br +0 -0
- package/dist/client/assets/PdfPreview-CIOM7sbu.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-CARW1k8M.js +4 -0
- package/dist/client/assets/ProjectSettings-CARW1k8M.js.br +0 -0
- package/dist/client/assets/ProjectSettings-CARW1k8M.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js +31 -0
- package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-kW-97LBY.js +1 -0
- package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-B-ZZIpJq.js +2 -0
- package/dist/client/assets/SaveButton-wiTpGLho.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-cDxbuXmO.js → SelectionHistoryDialog-CmHcjD4T.js} +2 -2
- package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BOGGeyBG.css +1 -0
- package/dist/client/assets/SharedProjectPage-BjhT-js7.js +2 -0
- package/dist/client/assets/SharedProjectPage-BjhT-js7.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-BjhT-js7.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.gz +0 -0
- package/dist/client/assets/{TagColorSelect-D-zwdawC.js → TagColorSelect-e-Tq5V3H.js} +1 -1
- package/dist/client/assets/TagManagementDialog-BIsAi9rh.js +1 -0
- package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.gz +0 -0
- package/dist/client/assets/TagMarquee-BLmCTTCt.js +1 -0
- package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js +1 -0
- package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.br +0 -0
- package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-CJb1b8cD.js +1 -0
- package/dist/client/assets/WordCountDialog-CJb1b8cD.js.br +0 -0
- package/dist/client/assets/WordCountDialog-CJb1b8cD.js.gz +0 -0
- package/dist/client/assets/arrow-down-C_4f1E-E.js +1 -0
- package/dist/client/assets/check-Dw16EqG-.js +1 -0
- package/dist/client/assets/chevron-up-BHaMUEEA.js +1 -0
- package/dist/client/assets/{chktex-Dm6IIkcR.js → chktex-CCcr_9m7.js} +1 -1
- package/dist/client/assets/circle-check-CunlnBPw.js +1 -0
- package/dist/client/assets/clipboard-CslquMx4.js +1 -0
- package/dist/client/assets/clock-3-DztJubz_.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.br +0 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.gz +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js +1 -0
- package/dist/client/assets/dist-B_WjsTVV.js.br +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js.gz +0 -0
- package/dist/client/assets/dist-C9O-A_C4.js +1 -0
- package/dist/client/assets/dist-C9O-A_C4.js.br +0 -0
- package/dist/client/assets/dist-C9O-A_C4.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +1 -0
- 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-fyrvjoqA.js +14 -0
- package/dist/client/assets/editor-fyrvjoqA.js.br +0 -0
- package/dist/client/assets/editor-fyrvjoqA.js.gz +0 -0
- package/dist/client/assets/editor-languages-D1a-K8dK.js +36 -0
- package/dist/client/assets/editor-languages-D1a-K8dK.js.br +0 -0
- package/dist/client/assets/editor-languages-D1a-K8dK.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BpJbXyCP.js +1 -0
- package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.gz +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js +41 -0
- package/dist/client/assets/es2015-D2UDOM09.js.br +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js.gz +0 -0
- package/dist/client/assets/eye-BnslGpqB.js +1 -0
- package/dist/client/assets/hard-drive-CXlummIE.js +1 -0
- package/dist/client/assets/i18n-DNTfpttY.js +13 -0
- package/dist/client/assets/i18n-DNTfpttY.js.br +0 -0
- package/dist/client/assets/i18n-DNTfpttY.js.gz +0 -0
- package/dist/client/assets/index-CfSDaTd4.js +2 -0
- package/dist/client/assets/index-CfSDaTd4.js.br +0 -0
- package/dist/client/assets/index-CfSDaTd4.js.gz +0 -0
- package/dist/client/assets/index-PNFHDg2W.css +1 -0
- package/dist/client/assets/index-PNFHDg2W.css.br +0 -0
- package/dist/client/assets/index-PNFHDg2W.css.gz +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js +257 -0
- package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
- package/dist/client/assets/katex-CvRo0776.css +1 -0
- package/dist/client/assets/katex-CvRo0776.css.br +0 -0
- package/dist/client/assets/{katex-DDK6mlKN.css.gz → katex-CvRo0776.css.gz} +0 -0
- package/dist/client/assets/library-big-B8e_Fiql.js +1 -0
- package/dist/client/assets/loader-circle-DKGyi5EK.js +1 -0
- package/dist/client/assets/lock-keyhole-aC_QjKDi.js +1 -0
- package/dist/client/assets/minimize-2-CkBmeGXp.js +1 -0
- package/dist/client/assets/minus-DrpwqY8Y.js +1 -0
- package/dist/client/assets/plus-Cei21TlT.js +1 -0
- package/dist/client/assets/refresh-cw-IqExWG6S.js +1 -0
- package/dist/client/assets/relativeTime-DKEihsTa.js +1 -0
- package/dist/client/assets/relativeTime-DKEihsTa.js.br +0 -0
- package/dist/client/assets/relativeTime-DKEihsTa.js.gz +0 -0
- package/dist/client/assets/search-DjOWqLig.js +1 -0
- package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js +1 -0
- package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.gz +0 -0
- package/dist/client/assets/{spellCheck-DiNvmZKv.js → spellCheck-D-tYd_ac.js} +1 -1
- package/dist/client/assets/spellCheck-D-tYd_ac.js.br +0 -0
- package/dist/client/assets/spellCheck-D-tYd_ac.js.gz +0 -0
- package/dist/client/assets/terminal-DD9WJ56e.js +1 -0
- package/dist/client/assets/{textLanguageSupport-DIXngcZX.js → textLanguageSupport-Kz9ESEVW.js} +1 -1
- package/dist/client/assets/textLanguages-Dac6mieP.js +78 -0
- package/dist/client/assets/textLanguages-Dac6mieP.js.br +0 -0
- package/dist/client/assets/textLanguages-Dac6mieP.js.gz +0 -0
- package/dist/client/assets/type-CKe1tHHo.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js +1 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.br +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.gz +0 -0
- package/dist/client/assets/user-plus-NNBQOWDP.js +1 -0
- package/dist/client/assets/{vimSupport-RdD-E-Eh.js → vimSupport-DWYaSMuX.js} +6 -6
- package/dist/client/assets/vimSupport-DWYaSMuX.js.br +0 -0
- package/dist/client/assets/vimSupport-DWYaSMuX.js.gz +0 -0
- package/dist/client/index.html +9 -4
- package/dist/server/app.js +9 -1
- package/dist/server/byteRange.js +19 -0
- package/dist/server/citationCollections.js +163 -0
- package/dist/server/citationFolderTransfer.js +74 -0
- package/dist/server/citationInput.js +34 -0
- package/dist/server/collaboration.js +77 -16
- package/dist/server/commentMentions.js +6 -1
- package/dist/server/commentSuggestions.js +143 -0
- package/dist/server/db.js +81 -0
- package/dist/server/i18n.js +12 -0
- package/dist/server/locales/zh-Hant.js +8 -0
- package/dist/server/projectPreview.js +129 -0
- package/dist/server/projectReplace.js +67 -0
- package/dist/server/projectSearch.js +72 -0
- package/dist/server/routes/citations.js +84 -55
- package/dist/server/routes/commentSuggestions.js +154 -0
- package/dist/server/routes/comments.js +17 -1
- package/dist/server/routes/compile.js +1 -19
- package/dist/server/routes/projectSearch.js +72 -0
- package/dist/server/routes/projectShared.js +3 -0
- package/dist/server/routes/projectViewLinks.js +238 -0
- package/dist/server/routes/projects.js +11 -3
- package/dist/server/viewLinkTokens.js +49 -0
- package/dist/server/viewLinks.js +25 -0
- package/dist/shared/citationCollections.js +29 -0
- package/dist/shared/citationContent.js +4 -0
- package/dist/shared/citationTransfer.js +7 -0
- package/dist/shared/comments.js +2 -1
- package/dist/shared/projectCatalog.js +1 -1
- package/dist/shared/projectSearch.js +17 -0
- package/dist/shared/projectViewLinks.js +20 -0
- package/dist/shared/suggestionMessages.js +41 -0
- package/dist/shared/updates.js +1 -1
- package/package.json +9 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js +0 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.br +0 -0
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.gz +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js +0 -1
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.br +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css +0 -1
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.br +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.gz +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js +0 -1
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.br +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js +0 -2
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.br +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js +0 -1
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.gz +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.gz +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js +0 -5
- package/dist/client/assets/Dashboard-DAPwKNNH.js.br +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js.gz +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js +0 -3
- package/dist/client/assets/GitDialog-BzyA_IgU.js.br +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-BqDow-CN.js +0 -1
- package/dist/client/assets/HistoryDialog-407q3Fe6.js +0 -8
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.br +0 -0
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.gz +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js +0 -101
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.br +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.gz +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js +0 -1
- package/dist/client/assets/PdfPreview-Bbzop29j.js.br +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js +0 -4
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js +0 -30
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js +0 -1
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.gz +0 -0
- package/dist/client/assets/SaveButton-C8W1DGzx.js +0 -1
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js +0 -1
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js +0 -1
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.br +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.gz +0 -0
- package/dist/client/assets/arrow-down-BiIGj4-X.js +0 -1
- package/dist/client/assets/check-DfWHdQ1s.js +0 -1
- package/dist/client/assets/chevron-up-lyMKml7P.js +0 -1
- package/dist/client/assets/circle-check-DjXwnxuR.js +0 -1
- package/dist/client/assets/clock-3-D-XeFtkK.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js.br +0 -0
- package/dist/client/assets/dist-ByqeNQqT.js.gz +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js +0 -2
- package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js +0 -36
- package/dist/client/assets/editor-languages-C6EDWlLD.js.br +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js.gz +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js +0 -14
- package/dist/client/assets/editor-oR9RlWUz.js.br +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js.gz +0 -0
- package/dist/client/assets/eye-BvCLgqrq.js +0 -1
- package/dist/client/assets/hard-drive-Crh-l_oh.js +0 -1
- package/dist/client/assets/i18n-O9QnEo2t.js +0 -13
- package/dist/client/assets/i18n-O9QnEo2t.js.br +0 -0
- package/dist/client/assets/i18n-O9QnEo2t.js.gz +0 -0
- package/dist/client/assets/index-7d5TfVNx.css +0 -1
- package/dist/client/assets/index-7d5TfVNx.css.br +0 -0
- package/dist/client/assets/index-7d5TfVNx.css.gz +0 -0
- package/dist/client/assets/index-DFEpXxLs.js +0 -42
- package/dist/client/assets/index-DFEpXxLs.js.br +0 -0
- package/dist/client/assets/index-DFEpXxLs.js.gz +0 -0
- package/dist/client/assets/info-g1IBvVg6.js +0 -1
- package/dist/client/assets/katex-Bd0sKoun.js +0 -257
- package/dist/client/assets/katex-Bd0sKoun.js.br +0 -0
- package/dist/client/assets/katex-Bd0sKoun.js.gz +0 -0
- package/dist/client/assets/katex-DDK6mlKN.css +0 -1
- package/dist/client/assets/katex-DDK6mlKN.css.br +0 -0
- package/dist/client/assets/minimize-2-BHKmubQs.js +0 -1
- package/dist/client/assets/minus-BmWzkFwz.js +0 -1
- package/dist/client/assets/plus-CoYCCEFJ.js +0 -1
- package/dist/client/assets/refresh-cw-Di6Huxb4.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js.br +0 -0
- package/dist/client/assets/relativeTime-CFNodf1I.js.gz +0 -0
- package/dist/client/assets/search-l36unLLS.js +0 -1
- package/dist/client/assets/spellCheck-DiNvmZKv.js.br +0 -0
- package/dist/client/assets/spellCheck-DiNvmZKv.js.gz +0 -0
- package/dist/client/assets/tags-yjr9KRc8.js +0 -1
- package/dist/client/assets/terminal-P09ZGT83.js +0 -1
- package/dist/client/assets/type-C7rzXWVU.js +0 -1
- package/dist/client/assets/user-plus-CqyV7OV4.js +0 -1
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.br +0 -0
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.gz +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { requireUser } from "../auth.js";
|
|
4
|
+
import { accessibleProject, canEdit } from "../projects.js";
|
|
5
|
+
import { apiError, httpError } from "../http.js";
|
|
6
|
+
import { resolveSourcePath } from "../files.js";
|
|
7
|
+
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
8
|
+
import { attachSuggestion, clearSuggestionReview, requestSuggestionReview, suggestionReviewers, suggestionRow, validateSuggestionReplacement } from "../commentSuggestions.js";
|
|
9
|
+
import { commentsForFile, commentsSummaryForProject, now } from "./projectShared.js";
|
|
10
|
+
export function registerSuggestionRoutes(app, context) {
|
|
11
|
+
const { db, config, collaboration, projectMutations } = context;
|
|
12
|
+
const result = (projectId, commentId, filePath) => {
|
|
13
|
+
const comment = commentsForFile(db, config, projectId, filePath).find((item) => item.id === commentId);
|
|
14
|
+
collaboration.signalComments(projectId);
|
|
15
|
+
return { change: { kind: "suggestion", commentId, filePath, suggestion: comment.suggestion }, summary: commentsSummaryForProject(db, projectId) };
|
|
16
|
+
};
|
|
17
|
+
app.get("/api/projects/:id/suggestion-reviewers", async (request, reply) => {
|
|
18
|
+
const user = requireUser(request, reply, db);
|
|
19
|
+
if (!user)
|
|
20
|
+
return;
|
|
21
|
+
const { id } = request.params;
|
|
22
|
+
const project = accessibleProject(db, id, user);
|
|
23
|
+
if (!project)
|
|
24
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
25
|
+
const { commentId } = request.query;
|
|
26
|
+
let authorId = user.id;
|
|
27
|
+
if (commentId !== undefined) {
|
|
28
|
+
const comment = db.prepare("SELECT author_id FROM comments WHERE id = ? AND project_id = ?").get(commentId, id);
|
|
29
|
+
if (!comment)
|
|
30
|
+
return apiError(reply, 404, "COMMENT_NOT_FOUND");
|
|
31
|
+
authorId = comment.author_id;
|
|
32
|
+
}
|
|
33
|
+
return { users: suggestionReviewers(db, id, authorId), ownerId: project.owner_id };
|
|
34
|
+
});
|
|
35
|
+
app.post("/api/projects/:id/comments/:commentId/suggestion", async (request, reply) => {
|
|
36
|
+
const user = requireUser(request, reply, db);
|
|
37
|
+
if (!user)
|
|
38
|
+
return;
|
|
39
|
+
const { id, commentId } = request.params;
|
|
40
|
+
if (!request.body || typeof request.body !== "object" || Array.isArray(request.body))
|
|
41
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
42
|
+
const body = request.body;
|
|
43
|
+
return projectMutations.runWrite(id, () => {
|
|
44
|
+
const comment = db.prepare("SELECT * FROM comments WHERE id = ? AND project_id = ?").get(commentId, id);
|
|
45
|
+
if (!comment)
|
|
46
|
+
throw httpError(404, "COMMENT_NOT_FOUND");
|
|
47
|
+
if (comment.author_id !== user.id)
|
|
48
|
+
throw httpError(403, "COMMENT_EDIT_FORBIDDEN");
|
|
49
|
+
const absolute = resolveSourcePath(config, id, comment.file_path);
|
|
50
|
+
if (comment.resolved || comment.orphaned || !isCollaborativeTextFile(comment.file_path) || !fs.existsSync(absolute))
|
|
51
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
52
|
+
const source = fs.readFileSync(absolute, "utf8");
|
|
53
|
+
if (comment.orphaned || createHash("sha256").update(source, "utf8").digest("hex") !== body.sourceHash
|
|
54
|
+
|| source.slice(comment.start_offset, comment.end_offset) !== comment.selected_text)
|
|
55
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
56
|
+
db.transaction(() => attachSuggestion(db, id, commentId, user.id, comment.selected_text, body))();
|
|
57
|
+
return result(id, commentId, comment.file_path);
|
|
58
|
+
}, { preflight: () => { if (!accessibleProject(db, id, user))
|
|
59
|
+
throw httpError(404, "PROJECT_NOT_FOUND"); } });
|
|
60
|
+
});
|
|
61
|
+
app.post("/api/projects/:id/comments/:commentId/suggestion/review", async (request, reply) => {
|
|
62
|
+
const user = requireUser(request, reply, db);
|
|
63
|
+
if (!user)
|
|
64
|
+
return;
|
|
65
|
+
const { id, commentId } = request.params;
|
|
66
|
+
const { action, expectedReplacementText } = (request.body ?? {});
|
|
67
|
+
if (action !== "accept" && action !== "reject")
|
|
68
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
69
|
+
const validate = () => {
|
|
70
|
+
const project = accessibleProject(db, id, user);
|
|
71
|
+
const row = suggestionRow(db, id, commentId);
|
|
72
|
+
if (!project || !canEdit(project) || row?.reviewer_id !== user.id || !suggestionReviewers(db, id).some((candidate) => candidate.id === user.id)) {
|
|
73
|
+
throw httpError(403, "SUGGESTION_REVIEW_FORBIDDEN");
|
|
74
|
+
}
|
|
75
|
+
if (row.author_id === user.id)
|
|
76
|
+
throw httpError(403, "SUGGESTION_SELF_REVIEW");
|
|
77
|
+
// Bind the decision to the replacement actually displayed by the reviewer.
|
|
78
|
+
// Repeat inside the project write queue after room preparation and flushing.
|
|
79
|
+
if (typeof expectedReplacementText !== "string" || row.replacement_text !== expectedReplacementText)
|
|
80
|
+
throw httpError(409, "SUGGESTION_UPDATED");
|
|
81
|
+
return row;
|
|
82
|
+
};
|
|
83
|
+
validate();
|
|
84
|
+
if (action === "accept")
|
|
85
|
+
await collaboration.prepareSourceEditRoom(id);
|
|
86
|
+
return projectMutations.runWrite(id, () => {
|
|
87
|
+
const row = validate();
|
|
88
|
+
const expected = action === "accept" ? "accepted" : "rejected";
|
|
89
|
+
if (row.status === expected)
|
|
90
|
+
return result(id, commentId, row.file_path);
|
|
91
|
+
if (row.status !== "pending")
|
|
92
|
+
throw httpError(409, "SUGGESTION_DECIDED");
|
|
93
|
+
if (action === "accept") {
|
|
94
|
+
if (!fs.existsSync(resolveSourcePath(config, id, row.file_path)))
|
|
95
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
96
|
+
collaboration.applyCommentSuggestion(id, row.file_path, commentId, user.id);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
if (row.apply_update)
|
|
100
|
+
throw httpError(409, "SUGGESTION_APPLYING");
|
|
101
|
+
db.transaction(() => {
|
|
102
|
+
const at = now();
|
|
103
|
+
db.prepare("UPDATE comment_suggestions SET status = 'rejected', decided_by = ?, decided_at = ? WHERE comment_id = ?").run(user.id, at, commentId);
|
|
104
|
+
clearSuggestionReview(db, commentId, at);
|
|
105
|
+
})();
|
|
106
|
+
}
|
|
107
|
+
return result(id, commentId, row.file_path);
|
|
108
|
+
}, { preflight: () => { validate(); } });
|
|
109
|
+
});
|
|
110
|
+
app.patch("/api/projects/:id/comments/:commentId/suggestion", async (request, reply) => {
|
|
111
|
+
const user = requireUser(request, reply, db);
|
|
112
|
+
if (!user)
|
|
113
|
+
return;
|
|
114
|
+
const { id, commentId } = request.params;
|
|
115
|
+
if (!request.body || typeof request.body !== "object" || Array.isArray(request.body))
|
|
116
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
117
|
+
const body = request.body;
|
|
118
|
+
// Assignment is fixed when a suggestion is created; this endpoint only edits its text.
|
|
119
|
+
if (body.reviewerId !== undefined || typeof body.expectedReplacementText !== "string")
|
|
120
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
121
|
+
const validate = () => {
|
|
122
|
+
if (!accessibleProject(db, id, user))
|
|
123
|
+
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
124
|
+
const row = suggestionRow(db, id, commentId);
|
|
125
|
+
if (!row)
|
|
126
|
+
throw httpError(404, "COMMENT_NOT_FOUND");
|
|
127
|
+
if (row.author_id !== user.id)
|
|
128
|
+
throw httpError(403, "COMMENT_EDIT_FORBIDDEN");
|
|
129
|
+
if (row.status !== "pending")
|
|
130
|
+
throw httpError(409, "SUGGESTION_DECIDED");
|
|
131
|
+
if (row.apply_update)
|
|
132
|
+
throw httpError(409, "SUGGESTION_APPLYING");
|
|
133
|
+
return row;
|
|
134
|
+
};
|
|
135
|
+
return projectMutations.runWrite(id, () => {
|
|
136
|
+
const row = validate();
|
|
137
|
+
validateSuggestionReplacement(row.original_text, body.replacementText);
|
|
138
|
+
// A retried save with identical text is a no-op, not another review request.
|
|
139
|
+
if (row.replacement_text === body.replacementText)
|
|
140
|
+
return result(id, commentId, row.file_path);
|
|
141
|
+
if (row.replacement_text !== body.expectedReplacementText)
|
|
142
|
+
throw httpError(409, "SUGGESTION_UPDATED");
|
|
143
|
+
db.transaction(() => {
|
|
144
|
+
const at = now();
|
|
145
|
+
db.prepare("UPDATE comment_suggestions SET replacement_text = ? WHERE comment_id = ?").run(body.replacementText, commentId);
|
|
146
|
+
clearSuggestionReview(db, commentId, at);
|
|
147
|
+
if (row.reviewer_id && suggestionReviewers(db, id, row.author_id).some((candidate) => candidate.id === row.reviewer_id)) {
|
|
148
|
+
requestSuggestionReview(db, id, commentId, row.reviewer_id, user.id, at);
|
|
149
|
+
}
|
|
150
|
+
})();
|
|
151
|
+
return result(id, commentId, row.file_path);
|
|
152
|
+
}, { preflight: () => { validate(); } });
|
|
153
|
+
});
|
|
154
|
+
}
|
|
@@ -5,11 +5,17 @@ import { createSourceAnchor, offsetToLine } from "../anchors.js";
|
|
|
5
5
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
6
6
|
import { apiError, httpError } from "../http.js";
|
|
7
7
|
import { accessibleProject } from "../projects.js";
|
|
8
|
+
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
9
|
+
import { attachSuggestion, suggestionRow } from "../commentSuggestions.js";
|
|
10
|
+
import { registerSuggestionRoutes } from "./commentSuggestions.js";
|
|
11
|
+
import { defaultSuggestionComments } from "../../shared/suggestionMessages.js";
|
|
12
|
+
import { serverLocale } from "../i18n.js";
|
|
8
13
|
import { commentMentionForUser, createCommentMentions, listCommentMentions, markAllCommentMentionsRead, markCommentMentionRead, markCommentMentionsResolved, mentionableUsersForProject } from "../commentMentions.js";
|
|
9
14
|
import { commentsForFile, commentsForProject, commentsSummaryForProject, now, repliesForComment, text } from "./projectShared.js";
|
|
10
15
|
/** Register source-anchored comments and reply routes. */
|
|
11
16
|
export function registerCommentRoutes(app, context) {
|
|
12
17
|
const { config, db, collaboration, projectMutations } = context;
|
|
18
|
+
registerSuggestionRoutes(app, context);
|
|
13
19
|
app.get("/api/projects/:id/mention-candidates", async (request, reply) => {
|
|
14
20
|
const user = requireUser(request, reply, db);
|
|
15
21
|
if (!user)
|
|
@@ -132,9 +138,13 @@ export function registerCommentRoutes(app, context) {
|
|
|
132
138
|
return apiError(reply, 409, "COMMENT_SOURCE_CHANGED");
|
|
133
139
|
}
|
|
134
140
|
const anchor = createSourceAnchor(source, Number(body.startOffset), Number(body.endOffset));
|
|
141
|
+
if (body.suggestion !== undefined && (!isCollaborativeTextFile(filePath) || body.sourceHash === undefined
|
|
142
|
+
|| Number(body.startOffset) < 0 || Number(body.endOffset) > source.length || Number(body.endOffset) <= Number(body.startOffset)))
|
|
143
|
+
throw httpError(400, "SUGGESTION_INVALID");
|
|
135
144
|
const comment = {
|
|
136
145
|
id: randomUUID(), filePath,
|
|
137
|
-
content: text(body.content
|
|
146
|
+
content: text(body.suggestion !== undefined && (body.content === undefined || typeof body.content === "string" && !body.content.trim())
|
|
147
|
+
? defaultSuggestionComments[serverLocale(request.headers)] : body.content, 5000)
|
|
138
148
|
};
|
|
139
149
|
db.transaction(() => {
|
|
140
150
|
db.prepare(`INSERT INTO comments
|
|
@@ -146,6 +156,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
146
156
|
projectId: id, commentId: comment.id, authorId: user.id,
|
|
147
157
|
content: comment.content, createdAt
|
|
148
158
|
});
|
|
159
|
+
if (body.suggestion !== undefined)
|
|
160
|
+
attachSuggestion(db, id, comment.id, user.id, anchor.selectedText, body.suggestion);
|
|
149
161
|
})();
|
|
150
162
|
const created = commentsForFile(db, config, id, filePath).find((item) => item.id === comment.id);
|
|
151
163
|
collaboration.signalComments(id);
|
|
@@ -205,6 +217,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
205
217
|
changed = true;
|
|
206
218
|
}
|
|
207
219
|
if (typeof body.resolved === "boolean") {
|
|
220
|
+
if (body.resolved && suggestionRow(db, id, commentId)?.status === "pending")
|
|
221
|
+
return apiError(reply, 409, "SUGGESTION_PENDING");
|
|
208
222
|
changed = true;
|
|
209
223
|
}
|
|
210
224
|
if (!changed)
|
|
@@ -256,6 +270,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
256
270
|
return apiError(reply, 404, "COMMENT_NOT_FOUND");
|
|
257
271
|
if (comment.author_id !== user.id)
|
|
258
272
|
return apiError(reply, 403, "COMMENT_DELETE_FORBIDDEN");
|
|
273
|
+
if (suggestionRow(db, id, commentId)?.apply_update)
|
|
274
|
+
return apiError(reply, 409, "SUGGESTION_APPLYING");
|
|
259
275
|
db.prepare("DELETE FROM comments WHERE id = ?").run(commentId);
|
|
260
276
|
collaboration.signalComments(id);
|
|
261
277
|
const result = { change: { kind: "deleted", commentId, filePath: comment.file_path }, summary: commentsSummaryForProject(db, id) };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { parseByteRange } from "../byteRange.js";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { performance } from "node:perf_hooks";
|
|
@@ -787,22 +788,3 @@ function compileRequestGeneration(project, persistedRevision, sourceGeneration,
|
|
|
787
788
|
function pdfDownloadTimestamp(date = new Date()) {
|
|
788
789
|
return date.toISOString().slice(0, 19).replace("T", "-").replaceAll(":", "");
|
|
789
790
|
}
|
|
790
|
-
function parseByteRange(value, size) {
|
|
791
|
-
if (!value)
|
|
792
|
-
return null;
|
|
793
|
-
const match = /^bytes=(\d*)-(\d*)$/.exec(value.trim());
|
|
794
|
-
if (!match || (!match[1] && !match[2]) || size < 1)
|
|
795
|
-
return "invalid";
|
|
796
|
-
if (!match[1]) {
|
|
797
|
-
const suffixLength = Number(match[2]);
|
|
798
|
-
if (!Number.isSafeInteger(suffixLength) || suffixLength <= 0)
|
|
799
|
-
return "invalid";
|
|
800
|
-
return { start: Math.max(0, size - suffixLength), end: size - 1 };
|
|
801
|
-
}
|
|
802
|
-
const start = Number(match[1]);
|
|
803
|
-
const requestedEnd = match[2] ? Number(match[2]) : size - 1;
|
|
804
|
-
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || start >= size || requestedEnd < start) {
|
|
805
|
-
return "invalid";
|
|
806
|
-
}
|
|
807
|
-
return { start, end: Math.min(requestedEnd, size - 1) };
|
|
808
|
-
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isTextContent } from "../../shared/fileTypes.js";
|
|
2
|
+
import { PROJECT_SEARCH_MAX_QUERY_LENGTH, PROJECT_SEARCH_MAX_MATCHES, PROJECT_SEARCH_MAX_REPLACEMENT_LENGTH } from "../../shared/projectSearch.js";
|
|
3
|
+
import { requireUser } from "../auth.js";
|
|
4
|
+
import { apiError, httpError } from "../http.js";
|
|
5
|
+
import { searchProject } from "../projectSearch.js";
|
|
6
|
+
import { accessibleProject } from "../projects.js";
|
|
7
|
+
import { requireEditableProject } from "./projectShared.js";
|
|
8
|
+
import { prepareProjectReplacement } from "../projectReplace.js";
|
|
9
|
+
import { safeRelativePath } from "../files.js";
|
|
10
|
+
function searchOptions(body) {
|
|
11
|
+
if (!body || typeof body.query !== "string" || body.query.length === 0
|
|
12
|
+
|| body.query.length > PROJECT_SEARCH_MAX_QUERY_LENGTH || /[\r\n\0]/.test(body.query)
|
|
13
|
+
|| (body.caseSensitive !== undefined && typeof body.caseSensitive !== "boolean")
|
|
14
|
+
|| (body.wholeWord !== undefined && typeof body.wholeWord !== "boolean"))
|
|
15
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
16
|
+
return { query: body.query, caseSensitive: body.caseSensitive !== false, wholeWord: body.wholeWord !== false };
|
|
17
|
+
}
|
|
18
|
+
export function registerProjectSearchRoutes(app, { config, db, projectMutations, collaboration }) {
|
|
19
|
+
app.post("/api/projects/:id/search", async (request, reply) => {
|
|
20
|
+
const user = requireUser(request, reply, db);
|
|
21
|
+
if (!user)
|
|
22
|
+
return;
|
|
23
|
+
const { id } = request.params;
|
|
24
|
+
if (!accessibleProject(db, id, user))
|
|
25
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
26
|
+
const options = searchOptions(request.body);
|
|
27
|
+
return await projectMutations.runConsistentRead(id, () => searchProject(config, id, options), {
|
|
28
|
+
preflight: () => { if (!accessibleProject(db, id, user))
|
|
29
|
+
throw httpError(404, "PROJECT_NOT_FOUND"); }
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
app.post("/api/projects/:id/search/replace", async (request, reply) => {
|
|
33
|
+
const user = requireUser(request, reply, db);
|
|
34
|
+
if (!user)
|
|
35
|
+
return;
|
|
36
|
+
const { id } = request.params;
|
|
37
|
+
requireEditableProject(db, id, user);
|
|
38
|
+
const body = request.body;
|
|
39
|
+
const options = searchOptions(body);
|
|
40
|
+
if (typeof body?.replacement !== "string" || body.replacement.length > PROJECT_SEARCH_MAX_REPLACEMENT_LENGTH
|
|
41
|
+
|| !isTextContent(Buffer.from(body.replacement, "utf8")) || !Array.isArray(body.targets)
|
|
42
|
+
|| !body.targets.length || body.targets.length > PROJECT_SEARCH_MAX_MATCHES)
|
|
43
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
44
|
+
const replacement = body.replacement;
|
|
45
|
+
const paths = new Set();
|
|
46
|
+
let totalRanges = 0;
|
|
47
|
+
const targets = body.targets.map((value) => {
|
|
48
|
+
const target = value;
|
|
49
|
+
if (!target || typeof target.path !== "string" || safeRelativePath(target.path) !== target.path || paths.has(target.path)
|
|
50
|
+
|| typeof target.sourceHash !== "string" || !/^[a-f0-9]{64}$/.test(target.sourceHash)
|
|
51
|
+
|| !Array.isArray(target.ranges) || !target.ranges.length
|
|
52
|
+
|| target.ranges.some((range) => !range || !Number.isSafeInteger(range.from) || !Number.isSafeInteger(range.to)
|
|
53
|
+
|| range.from < 0 || range.to <= range.from))
|
|
54
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
55
|
+
const ranges = [...target.ranges].sort((a, b) => a.from - b.from);
|
|
56
|
+
if (ranges.some((range, index) => index > 0 && range.from < ranges[index - 1].to))
|
|
57
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
58
|
+
paths.add(target.path);
|
|
59
|
+
totalRanges += ranges.length;
|
|
60
|
+
return { path: target.path, sourceHash: target.sourceHash, ranges };
|
|
61
|
+
});
|
|
62
|
+
if (totalRanges > PROJECT_SEARCH_MAX_MATCHES)
|
|
63
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
64
|
+
await collaboration.prepareSourceEditRoom(id);
|
|
65
|
+
return projectMutations.runWrite(id, () => {
|
|
66
|
+
const plan = prepareProjectReplacement(config, id, options, replacement, targets);
|
|
67
|
+
if (plan.files.length)
|
|
68
|
+
collaboration.applySourceEdits(id, plan.files, user.id);
|
|
69
|
+
return { replaced: plan.replaced, files: plan.files.length };
|
|
70
|
+
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -7,6 +7,7 @@ import { httpError, ValidationError } from "../http.js";
|
|
|
7
7
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
8
|
import { isTextContent } from "../../shared/fileTypes.js";
|
|
9
9
|
import { sortProjectCommentsBySource } from "../commentSourceOrder.js";
|
|
10
|
+
import { suggestionsForProject } from "../commentSuggestions.js";
|
|
10
11
|
export const now = () => new Date().toISOString();
|
|
11
12
|
export function escapeLikePattern(value) {
|
|
12
13
|
return value.replace(/[\\%_]/g, "\\$&");
|
|
@@ -253,7 +254,9 @@ function commentsForScope(db, config, projectId, filePath) {
|
|
|
253
254
|
});
|
|
254
255
|
replyMap.set(reply.comment_id, list);
|
|
255
256
|
}
|
|
257
|
+
const suggestions = suggestionsForProject(db, projectId, sourceByPath);
|
|
256
258
|
const comments = rows.map((comment) => ({
|
|
259
|
+
suggestion: suggestions.get(comment.id) ?? null,
|
|
257
260
|
id: comment.id,
|
|
258
261
|
filePath: comment.file_path,
|
|
259
262
|
authorId: comment.author_id,
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { requireUser } from "../auth.js";
|
|
5
|
+
import { createSessionToken } from "../security.js";
|
|
6
|
+
import { requireActualProjectOwner } from "./projectShared.js";
|
|
7
|
+
import { httpError, contentDisposition } from "../http.js";
|
|
8
|
+
import { requireViewLink, viewCookieName, viewLinkJson } from "../viewLinks.js";
|
|
9
|
+
import { decryptViewLinkToken, encryptViewLinkToken } from "../viewLinkTokens.js";
|
|
10
|
+
import { listProjectFilesAsync, resolveSourcePath, safeRelativePath } from "../files.js";
|
|
11
|
+
import { isTextContent, MAX_TEXT_EDITOR_BYTES, resourceFileKind } from "../../shared/fileTypes.js";
|
|
12
|
+
import { availablePdf, pdfLoadingMode } from "../compileArtifacts.js";
|
|
13
|
+
import { withBasePath } from "../../shared/basePath.js";
|
|
14
|
+
import { parseByteRange } from "../byteRange.js";
|
|
15
|
+
const defaultLifetimeMs = 7 * 24 * 60 * 60_000;
|
|
16
|
+
const imageTypes = {
|
|
17
|
+
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp",
|
|
18
|
+
".svg": "image/svg+xml", ".bmp": "image/bmp", ".ico": "image/x-icon", ".avif": "image/avif", ".tif": "image/tiff", ".tiff": "image/tiff"
|
|
19
|
+
};
|
|
20
|
+
function privateResponse(reply) {
|
|
21
|
+
reply.header("Cache-Control", "private, no-store");
|
|
22
|
+
reply.header("Referrer-Policy", "no-referrer");
|
|
23
|
+
reply.header("X-Robots-Tag", "noindex, nofollow");
|
|
24
|
+
reply.header("X-Content-Type-Options", "nosniff");
|
|
25
|
+
}
|
|
26
|
+
export function registerProjectViewLinkRoutes(app, { db, config, projectMutations, projectOutlines }) {
|
|
27
|
+
const owner = (request, reply) => {
|
|
28
|
+
privateResponse(reply);
|
|
29
|
+
const user = requireUser(request, reply, db);
|
|
30
|
+
if (!user)
|
|
31
|
+
return null;
|
|
32
|
+
const { id } = request.params;
|
|
33
|
+
requireActualProjectOwner(db, id, user);
|
|
34
|
+
return id;
|
|
35
|
+
};
|
|
36
|
+
const viewPath = (id, token) => `${withBasePath(config.basePath, `/share/${id}`)}#${token}`;
|
|
37
|
+
const createdLink = (row, token) => {
|
|
38
|
+
const path = viewPath(row.id, token);
|
|
39
|
+
return { link: viewLinkJson(row, path), path };
|
|
40
|
+
};
|
|
41
|
+
const createLink = db.transaction((projectId, label, expiresAt) => {
|
|
42
|
+
const now = new Date().toISOString();
|
|
43
|
+
// Check and insert under the same write lock, including requests from other
|
|
44
|
+
// tabs. Copying an existing link must never change its token or lifetime.
|
|
45
|
+
const active = db.prepare(`SELECT id FROM project_view_links
|
|
46
|
+
WHERE project_id = ? AND (expires_at IS NULL OR expires_at > ?) LIMIT 1`).get(projectId, now);
|
|
47
|
+
if (active)
|
|
48
|
+
throw httpError(409, "VIEW_LINK_EXISTS");
|
|
49
|
+
const { token, digest } = createSessionToken();
|
|
50
|
+
const row = { id: randomUUID(), project_id: projectId, token_hash: digest, token_ciphertext: null, label,
|
|
51
|
+
created_at: now, expires_at: expiresAt };
|
|
52
|
+
row.token_ciphertext = encryptViewLinkToken(config, row, token);
|
|
53
|
+
db.prepare(`INSERT INTO project_view_links (id, project_id, token_hash, token_ciphertext, label, created_at, expires_at)
|
|
54
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`).run(row.id, projectId, digest, row.token_ciphertext, row.label, now, expiresAt);
|
|
55
|
+
return createdLink(row, token);
|
|
56
|
+
});
|
|
57
|
+
app.get("/api/projects/:id/view-links", async (request, reply) => {
|
|
58
|
+
const id = owner(request, reply);
|
|
59
|
+
if (!id)
|
|
60
|
+
return;
|
|
61
|
+
const rows = db.prepare("SELECT * FROM project_view_links WHERE project_id = ? ORDER BY created_at DESC, id").all(id);
|
|
62
|
+
return { links: rows.map((row) => {
|
|
63
|
+
const token = decryptViewLinkToken(config, row);
|
|
64
|
+
return viewLinkJson(row, token ? viewPath(row.id, token) : null);
|
|
65
|
+
}) };
|
|
66
|
+
});
|
|
67
|
+
app.post("/api/projects/:id/view-links", { bodyLimit: 4096 }, async (request, reply) => {
|
|
68
|
+
const id = owner(request, reply);
|
|
69
|
+
if (!id)
|
|
70
|
+
return;
|
|
71
|
+
const body = (request.body ?? {});
|
|
72
|
+
if (body.label !== undefined && (typeof body.label !== "string" || body.label.trim().length > 80))
|
|
73
|
+
throw httpError(400, "VIEW_LINK_LABEL_INVALID");
|
|
74
|
+
const expiry = body.expiresAt === undefined ? Date.now() + defaultLifetimeMs
|
|
75
|
+
: body.expiresAt === null ? null : typeof body.expiresAt === "string" ? Date.parse(body.expiresAt) : NaN;
|
|
76
|
+
if (expiry !== null && (!Number.isFinite(expiry) || expiry <= Date.now() || expiry > 8.64e15))
|
|
77
|
+
throw httpError(400, "VIEW_LINK_EXPIRY_INVALID");
|
|
78
|
+
return reply.code(201).send(createLink.immediate(id, body.label?.trim() ?? "", expiry === null ? null : new Date(expiry).toISOString()));
|
|
79
|
+
});
|
|
80
|
+
app.delete("/api/projects/:id/view-links/:linkId", async (request, reply) => {
|
|
81
|
+
const id = owner(request, reply);
|
|
82
|
+
if (!id)
|
|
83
|
+
return;
|
|
84
|
+
const { linkId } = request.params;
|
|
85
|
+
// Idempotent so retrying after a lost response also removes the stale UI row.
|
|
86
|
+
db.prepare("DELETE FROM project_view_links WHERE id = ? AND project_id = ?").run(linkId, id);
|
|
87
|
+
return { ok: true };
|
|
88
|
+
});
|
|
89
|
+
// Encapsulation keeps all guest responses (including errors) private. No guest
|
|
90
|
+
// route delegates to authenticated project endpoints or creates a Yjs room.
|
|
91
|
+
void app.register(async (guest) => {
|
|
92
|
+
guest.addHook("onRequest", async (_request, reply) => { privateResponse(reply); });
|
|
93
|
+
guest.post("/:linkId/access", { bodyLimit: 1024 }, async (request, reply) => {
|
|
94
|
+
const token = request.body?.token;
|
|
95
|
+
if (typeof token !== "string")
|
|
96
|
+
throw httpError(410, "VIEW_LINK_INVALID");
|
|
97
|
+
const row = requireViewLink(db, request, token);
|
|
98
|
+
const isSecure = request.protocol === "https" || request.headers["x-forwarded-proto"] === "https";
|
|
99
|
+
reply.setCookie(viewCookieName(row.id), token, { httpOnly: true, sameSite: "strict", secure: isSecure,
|
|
100
|
+
path: withBasePath(config.basePath, `/api/shared/${row.id}`), ...(row.expires_at ? { expires: new Date(row.expires_at) } : {}) });
|
|
101
|
+
return { ok: true };
|
|
102
|
+
});
|
|
103
|
+
guest.get("/:linkId/access", async (request) => {
|
|
104
|
+
const row = requireViewLink(db, request);
|
|
105
|
+
return { expiresAt: row.expires_at };
|
|
106
|
+
});
|
|
107
|
+
guest.get("/:linkId", async (request) => {
|
|
108
|
+
const row = requireViewLink(db, request);
|
|
109
|
+
return projectMutations.runFilesystemRead(row.project_id, async () => {
|
|
110
|
+
const files = await listProjectFilesAsync(config, row.project_id);
|
|
111
|
+
requireViewLink(db, request);
|
|
112
|
+
const project = db.prepare("SELECT name, main_file, engine FROM projects WHERE id = ?").get(row.project_id);
|
|
113
|
+
const outline = await projectOutlines.build(row.project_id, project.main_file);
|
|
114
|
+
const pdf = availablePdf(config, row.project_id, project.main_file);
|
|
115
|
+
let size = null;
|
|
116
|
+
if (pdf) {
|
|
117
|
+
try {
|
|
118
|
+
size = (await fs.promises.stat(pdf.path)).size;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (!missingFile(error))
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
requireViewLink(db, request);
|
|
126
|
+
const run = pdf ? db.prepare("SELECT finished_at FROM compile_runs WHERE id = ? AND project_id = ? AND status = 'succeeded'")
|
|
127
|
+
.get(pdf.version, row.project_id) : undefined;
|
|
128
|
+
return { siteName: config.siteName, outline, project: { name: project.name, mainFile: project.main_file, engine: project.engine }, expiresAt: row.expires_at,
|
|
129
|
+
files: files.map(({ path, type, size }) => ({ path, type, ...(size !== undefined ? { size } : {}) })),
|
|
130
|
+
pdf: pdf && size !== null ? { size, compiledAt: run?.finished_at ?? null, loadingMode: pdfLoadingMode(config, size),
|
|
131
|
+
url: withBasePath(config.basePath, `/api/shared/${row.id}/pdf?version=${encodeURIComponent(pdf.version)}`) } : null };
|
|
132
|
+
}, { preflight: () => { requireViewLink(db, request); } });
|
|
133
|
+
});
|
|
134
|
+
guest.get("/:linkId/file", async (request) => {
|
|
135
|
+
const row = requireViewLink(db, request);
|
|
136
|
+
const relative = safeRelativePath(request.query.path ?? "");
|
|
137
|
+
return projectMutations.runFilesystemRead(row.project_id, async () => {
|
|
138
|
+
const handle = await openFile(resolveSourcePath(config, row.project_id, relative));
|
|
139
|
+
try {
|
|
140
|
+
const stat = await handle.stat();
|
|
141
|
+
if (!stat.isFile())
|
|
142
|
+
throw httpError(404, "FILE_NOT_FOUND");
|
|
143
|
+
// Sniff a bounded prefix before reporting size, so a huge binary is
|
|
144
|
+
// never decoded or reported as an editable text file.
|
|
145
|
+
const prefix = Buffer.alloc(Math.min(stat.size, 8192));
|
|
146
|
+
const read = await handle.read(prefix, 0, prefix.length, 0);
|
|
147
|
+
if (!isTextContent(prefix.subarray(0, read.bytesRead), read.bytesRead < stat.size))
|
|
148
|
+
throw httpError(400, "FILE_CONTENT_INVALID");
|
|
149
|
+
if (stat.size > MAX_TEXT_EDITOR_BYTES)
|
|
150
|
+
throw httpError(413, "FILE_TOO_LARGE");
|
|
151
|
+
// Bounded read also handles a file growing during the request.
|
|
152
|
+
const chunks = [];
|
|
153
|
+
let length = 0;
|
|
154
|
+
for await (const chunk of handle.createReadStream({ start: 0, end: MAX_TEXT_EDITOR_BYTES, autoClose: false })) {
|
|
155
|
+
const bytes = chunk;
|
|
156
|
+
length += bytes.length;
|
|
157
|
+
if (length > MAX_TEXT_EDITOR_BYTES)
|
|
158
|
+
throw httpError(413, "FILE_TOO_LARGE");
|
|
159
|
+
chunks.push(bytes);
|
|
160
|
+
}
|
|
161
|
+
const content = Buffer.concat(chunks, length);
|
|
162
|
+
if (!isTextContent(content))
|
|
163
|
+
throw httpError(400, "FILE_CONTENT_INVALID");
|
|
164
|
+
requireViewLink(db, request);
|
|
165
|
+
return { path: relative, content: content.toString("utf8") };
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
await handle.close();
|
|
169
|
+
}
|
|
170
|
+
}, { preflight: () => { requireViewLink(db, request); } });
|
|
171
|
+
});
|
|
172
|
+
guest.get("/:linkId/resource", async (request, reply) => {
|
|
173
|
+
const row = requireViewLink(db, request);
|
|
174
|
+
const relative = safeRelativePath(request.query.path ?? "");
|
|
175
|
+
const kind = resourceFileKind(relative);
|
|
176
|
+
if (kind !== "image" && kind !== "pdf")
|
|
177
|
+
throw httpError(400, "FILE_CONTENT_INVALID");
|
|
178
|
+
return projectMutations.runFilesystemRead(row.project_id, async () => {
|
|
179
|
+
const absolute = resolveSourcePath(config, row.project_id, relative);
|
|
180
|
+
// An uploaded SVG is an image, never an executable same-origin document.
|
|
181
|
+
reply.header("Content-Security-Policy", "sandbox; default-src 'none'; style-src 'unsafe-inline'");
|
|
182
|
+
return sendResource(request, reply, absolute, kind === "pdf" ? "application/pdf" : imageTypes[path.extname(relative).toLowerCase()], path.basename(relative), () => { requireViewLink(db, request); });
|
|
183
|
+
}, { preflight: () => { requireViewLink(db, request); } });
|
|
184
|
+
});
|
|
185
|
+
guest.get("/:linkId/pdf", async (request, reply) => {
|
|
186
|
+
const row = requireViewLink(db, request);
|
|
187
|
+
const project = db.prepare("SELECT name, main_file FROM projects WHERE id = ?").get(row.project_id);
|
|
188
|
+
const pdf = availablePdf(config, row.project_id, project.main_file);
|
|
189
|
+
// Do not expose compile history or mix bytes from two versions in Range requests.
|
|
190
|
+
if (!pdf || request.query.version !== pdf.version)
|
|
191
|
+
throw httpError(404, "PDF_NOT_FOUND");
|
|
192
|
+
return sendResource(request, reply, pdf.path, "application/pdf", `${project.name}.pdf`, () => { requireViewLink(db, request); });
|
|
193
|
+
});
|
|
194
|
+
}, { prefix: "/api/shared" });
|
|
195
|
+
}
|
|
196
|
+
function missingFile(error) {
|
|
197
|
+
return ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
|
|
198
|
+
}
|
|
199
|
+
async function openFile(file) {
|
|
200
|
+
try {
|
|
201
|
+
return await fs.promises.open(file, "r");
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (missingFile(error))
|
|
205
|
+
throw httpError(404, "FILE_NOT_FOUND");
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function sendResource(request, reply, file, type, filename, validate) {
|
|
210
|
+
const handle = await openFile(file);
|
|
211
|
+
try {
|
|
212
|
+
const stat = await handle.stat();
|
|
213
|
+
if (!stat.isFile())
|
|
214
|
+
throw httpError(404, "FILE_NOT_FOUND");
|
|
215
|
+
validate();
|
|
216
|
+
reply.header("Content-Type", type);
|
|
217
|
+
reply.header("Content-Disposition", contentDisposition(filename, request.query.download === "1" ? "attachment" : "inline"));
|
|
218
|
+
reply.header("Accept-Ranges", "bytes");
|
|
219
|
+
const range = parseByteRange(request.headers.range, stat.size);
|
|
220
|
+
if (range === "invalid") {
|
|
221
|
+
await handle.close();
|
|
222
|
+
return reply.header("Content-Range", `bytes */${stat.size}`).code(416).send();
|
|
223
|
+
}
|
|
224
|
+
if (range)
|
|
225
|
+
reply.header("Content-Range", `bytes ${range.start}-${range.end}/${stat.size}`);
|
|
226
|
+
reply.header("Content-Length", range ? range.end - range.start + 1 : stat.size);
|
|
227
|
+
if (request.method === "HEAD") {
|
|
228
|
+
await handle.close();
|
|
229
|
+
return reply.code(range ? 206 : 200).send();
|
|
230
|
+
}
|
|
231
|
+
// The open descriptor pins this file even if a source-tree operation replaces it.
|
|
232
|
+
return reply.code(range ? 206 : 200).send(handle.createReadStream(range ?? {}));
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
await handle.close();
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -8,17 +8,20 @@ import { apiError, contentDisposition, httpError } from "../http.js";
|
|
|
8
8
|
import { isMainDocumentCandidate } from "../latexRoot.js";
|
|
9
9
|
import { lucideIconSvg, resolveLucideIconName } from "../lucideIcons.js";
|
|
10
10
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
11
|
+
import { ProjectPreviewService } from "../projectPreview.js";
|
|
11
12
|
import { writeProjectArchive } from "../archive.js";
|
|
12
13
|
import { extractProjectZip, ZipValidationError } from "../zip.js";
|
|
13
14
|
import { HarperLintSupersededError, HarperUnavailableError } from "../harper.js";
|
|
14
15
|
import { ChktexLintSupersededError, ChktexUnavailableError } from "../chktex.js";
|
|
15
16
|
import { supportsChktexChecks, supportsWritingChecks } from "../../shared/writingChecks.js";
|
|
16
17
|
import { unreadMentionCountsForProjects } from "../commentMentions.js";
|
|
18
|
+
import { DEFAULT_PROJECT_PAGE_SIZE } from "../../shared/projectCatalog.js";
|
|
17
19
|
import { commentsSummaryForProject, commentsSummaryForProjects, dictionaryWord, escapeLikePattern, now, projectJson, requireProjectOwnerPermission, tagColors, tagsForProject, tagsForProjects, text } from "./projectShared.js";
|
|
18
20
|
const clientIdPattern = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
19
21
|
/** Register project catalog, metadata, archive, dictionary, tag, export, and deletion routes. */
|
|
20
22
|
export function registerProjectCatalogRoutes(app, context) {
|
|
21
23
|
const { config, db, collaboration, projectMutations, latexCompletions, projectOutlines, harper, chktex, recordHistory } = context;
|
|
24
|
+
const projectPreviews = new ProjectPreviewService(config);
|
|
22
25
|
// Advanced project icons are served as cacheable SVG masks. The browser
|
|
23
26
|
// therefore does not have to bundle Lucide's entire icon catalogue merely
|
|
24
27
|
// because an owner selected an icon outside the curated picker.
|
|
@@ -129,8 +132,8 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
129
132
|
const archivedOnly = query.archived === "1" || query.archived === "true";
|
|
130
133
|
const requestedPage = Number.parseInt(query.page ?? "1", 10);
|
|
131
134
|
const page = Number.isFinite(requestedPage) && requestedPage > 0 ? requestedPage : 1;
|
|
132
|
-
const requestedPageSize = Number.parseInt(query.pageSize ??
|
|
133
|
-
const pageSize = Math.min(100, Math.max(1, Number.isFinite(requestedPageSize) && requestedPageSize > 0 ? requestedPageSize :
|
|
135
|
+
const requestedPageSize = Number.parseInt(query.pageSize ?? String(DEFAULT_PROJECT_PAGE_SIZE), 10);
|
|
136
|
+
const pageSize = Math.min(100, Math.max(1, Number.isFinite(requestedPageSize) && requestedPageSize > 0 ? requestedPageSize : DEFAULT_PROJECT_PAGE_SIZE));
|
|
134
137
|
const search = typeof query.search === "string" ? query.search.trim() : "";
|
|
135
138
|
const tagId = typeof query.tag === "string" ? query.tag.trim() : "";
|
|
136
139
|
const sortColumn = query.sort === "created" ? "p.created_at" : "p.updated_at";
|
|
@@ -179,8 +182,13 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
179
182
|
const projectTags = tagsForProjects(db, projectIds, user.id);
|
|
180
183
|
const commentsSummaries = commentsSummaryForProjects(db, projectIds);
|
|
181
184
|
const unreadMentionCounts = unreadMentionCountsForProjects(db, projectIds, user.id);
|
|
185
|
+
const previews = new Map();
|
|
186
|
+
if (query.previews === "1")
|
|
187
|
+
await Promise.all(projects.map(async (project) => {
|
|
188
|
+
previews.set(project.id, await projectPreviews.read(project.id, project.main_file));
|
|
189
|
+
}));
|
|
182
190
|
return {
|
|
183
|
-
projects: projects.map((project) => projectJson({ ...project, archived: archivedOnly }, projectTags.get(project.id) ?? [], commentsSummaries.get(project.id), unreadMentionCounts.get(project.id) ?? 0)),
|
|
191
|
+
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) } : {}) })),
|
|
184
192
|
pagination: { page: currentPage, pageSize, total, totalPages },
|
|
185
193
|
counts
|
|
186
194
|
};
|