texlite 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +273 -6
- package/OPERATIONS.md +7 -4
- package/README.md +6 -1
- package/README.zh-CN.md +4 -1
- package/dist/client/assets/AdminUsers-BghRo_hC.js +1 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.js.br +0 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.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-rIYtm4Bo.js +1 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.br +0 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js +2 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.br +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.gz +0 -0
- package/dist/client/assets/{AgentTerminalSurface-CaYNNZ9A.js → AgentTerminalSurface-B2rwONYs.js} +2 -2
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js +1 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-BnK6nZPi.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.gz +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js +36 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.br +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.gz +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js +5 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.br +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.gz +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js +3 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.br +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-CExJn0AV.js +1 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js +8 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.br +0 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.gz +0 -0
- package/dist/client/assets/InfoPopover-Dkz742vJ.js +1 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js +25 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.br +0 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.gz +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js +1 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.br +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js +4 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.br +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js +31 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js +1 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BZ7WYQO7.js +2 -0
- package/dist/client/assets/SaveButton-wiTpGLho.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-DzlVKtxs.js → SelectionHistoryDialog-DYQb9hXp.js} +2 -2
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BOGGeyBG.css +1 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js +2 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.gz +0 -0
- package/dist/client/assets/{TagColorSelect-xbc2H5ou.js → TagColorSelect-CzPUDAny.js} +1 -1
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js +1 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js +1 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.br +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js +1 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.br +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.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-Bz-LKycq.js → chktex-BeOSrdut.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-Bcdl4EAC.js +1 -0
- package/dist/client/assets/dist-Bcdl4EAC.js.br +0 -0
- package/dist/client/assets/dist-Bcdl4EAC.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-JqCouYk8.js +14 -0
- package/dist/client/assets/editor-JqCouYk8.js.br +0 -0
- package/dist/client/assets/editor-JqCouYk8.js.gz +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js +36 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.br +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js +1 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.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-Bv4wFb8D.js +13 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.br +0 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.gz +0 -0
- package/dist/client/assets/index-Bdb2ITID.js +2 -0
- package/dist/client/assets/index-Bdb2ITID.js.br +0 -0
- package/dist/client/assets/index-Bdb2ITID.js.gz +0 -0
- package/dist/client/assets/index-wqKiaXZr.css +1 -0
- package/dist/client/assets/index-wqKiaXZr.css.br +0 -0
- package/dist/client/assets/index-wqKiaXZr.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/refresh-cw-IqExWG6S.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.br +0 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.gz +0 -0
- package/dist/client/assets/search-DjOWqLig.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.gz +0 -0
- package/dist/client/assets/{spellCheck-xzICTGx1.js → spellCheck-P-fMO4iR.js} +1 -1
- package/dist/client/assets/spellCheck-P-fMO4iR.js.br +0 -0
- package/dist/client/assets/spellCheck-P-fMO4iR.js.gz +0 -0
- package/dist/client/assets/tags-GrE3ZIQN.js +1 -0
- package/dist/client/assets/terminal-DD9WJ56e.js +1 -0
- package/dist/client/assets/{textLanguageSupport-DIXngcZX.js → textLanguageSupport-BSIE7WPM.js} +1 -1
- package/dist/client/assets/textLanguages-DAJ1OXJA.js +78 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.js.br +0 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.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-BwIAfLU0.js} +6 -6
- package/dist/client/assets/vimSupport-BwIAfLU0.js.br +0 -0
- package/dist/client/assets/vimSupport-BwIAfLU0.js.gz +0 -0
- package/dist/client/index.html +9 -4
- package/dist/server/app.js +7 -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 +47 -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 +9 -0
- package/dist/server/locales/zh-Hant.js +6 -0
- package/dist/server/projectPreview.js +133 -0
- package/dist/server/projects.js +2 -1
- 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/projectShared.js +4 -0
- package/dist/server/routes/projectViewLinks.js +238 -0
- package/dist/server/routes/projects.js +27 -12
- package/dist/server/routes/users.js +7 -1
- 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 -0
- package/dist/shared/projectViewLinks.js +20 -0
- package/dist/shared/suggestionMessages.js +41 -0
- package/dist/shared/updates.js +1 -1
- package/dist/shared/userManagement.js +1 -0
- package/package.json +9 -1
- package/dist/client/assets/AdminUsers-CuYfWnEk.js +0 -1
- package/dist/client/assets/AdminUsers-CuYfWnEk.js.br +0 -0
- package/dist/client/assets/AdminUsers-CuYfWnEk.js.gz +0 -0
- package/dist/client/assets/AgentIcon-ClP5dPRL.js +0 -1
- package/dist/client/assets/AgentIcon-ClP5dPRL.js.br +0 -0
- package/dist/client/assets/AgentIcon-ClP5dPRL.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-jY_BF6Qy.js +0 -1
- package/dist/client/assets/AgentManagement-jY_BF6Qy.js.br +0 -0
- package/dist/client/assets/AgentManagement-jY_BF6Qy.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-JKP2SVkZ.js +0 -2
- package/dist/client/assets/AgentTerminal-JKP2SVkZ.js.br +0 -0
- package/dist/client/assets/AgentTerminal-JKP2SVkZ.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-CaYNNZ9A.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-CaYNNZ9A.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C2TACfvP.js +0 -1
- package/dist/client/assets/AvatarSettingsDialog-C2TACfvP.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C2TACfvP.js.gz +0 -0
- package/dist/client/assets/CitationLibraryDialog-BdU9nbgG.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-BdU9nbgG.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-BdU9nbgG.js.gz +0 -0
- package/dist/client/assets/Dashboard-B7mMz5Gj.js +0 -5
- package/dist/client/assets/Dashboard-B7mMz5Gj.js.br +0 -0
- package/dist/client/assets/Dashboard-B7mMz5Gj.js.gz +0 -0
- package/dist/client/assets/GitDialog-C2H-jKVO.js +0 -3
- package/dist/client/assets/GitDialog-C2H-jKVO.js.br +0 -0
- package/dist/client/assets/GitDialog-C2H-jKVO.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-DdKiE3pw.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-DdKiE3pw.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-DdKiE3pw.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-Cjli8pd_.js +0 -1
- package/dist/client/assets/HistoryDialog-CoxJ3EsK.js +0 -8
- package/dist/client/assets/HistoryDialog-CoxJ3EsK.js.br +0 -0
- package/dist/client/assets/HistoryDialog-CoxJ3EsK.js.gz +0 -0
- package/dist/client/assets/LatexEditor-BhAKioho.js +0 -101
- package/dist/client/assets/LatexEditor-BhAKioho.js.br +0 -0
- package/dist/client/assets/LatexEditor-BhAKioho.js.gz +0 -0
- package/dist/client/assets/PdfPreview-CC8KEz1Y.js +0 -1
- package/dist/client/assets/PdfPreview-CC8KEz1Y.js.br +0 -0
- package/dist/client/assets/PdfPreview-CC8KEz1Y.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-vi_HwlCS.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-vi_HwlCS.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-vi_HwlCS.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-Bl1t-Gnh.js +0 -4
- package/dist/client/assets/ProjectSettings-Bl1t-Gnh.js.br +0 -0
- package/dist/client/assets/ProjectSettings-Bl1t-Gnh.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-1UOdyfBq.js +0 -30
- package/dist/client/assets/ProjectWorkspace-1UOdyfBq.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-1UOdyfBq.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-BAzyrB-4.js +0 -1
- package/dist/client/assets/QuickOpenDialog-BAzyrB-4.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-BAzyrB-4.js.gz +0 -0
- package/dist/client/assets/SaveButton-DkyoEu6j.js +0 -1
- package/dist/client/assets/SelectionHistoryDialog-DzlVKtxs.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-DzlVKtxs.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-C6RVZdJZ.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-C6RVZdJZ.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-C6RVZdJZ.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-8pZUVaEI.js +0 -1
- package/dist/client/assets/TagManagementDialog-8pZUVaEI.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-8pZUVaEI.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-BODhL9iz.js +0 -1
- package/dist/client/assets/WordCountDialog-BODhL9iz.js.br +0 -0
- package/dist/client/assets/WordCountDialog-BODhL9iz.js.gz +0 -0
- package/dist/client/assets/arrow-down-B6T7Z6IO.js +0 -1
- package/dist/client/assets/check-BRlv1lrZ.js +0 -1
- package/dist/client/assets/chevron-up-krb7w67X.js +0 -1
- package/dist/client/assets/clock-3-Fb1_e3ec.js +0 -1
- package/dist/client/assets/dist-CMYWzCHL.js +0 -1
- package/dist/client/assets/dist-CMYWzCHL.js.br +0 -0
- package/dist/client/assets/dist-CMYWzCHL.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-B6AX_5uX.js +0 -1
- package/dist/client/assets/hard-drive-CBmnJ2xS.js +0 -1
- package/dist/client/assets/i18n-DF6keNBA.js +0 -13
- package/dist/client/assets/i18n-DF6keNBA.js.br +0 -0
- package/dist/client/assets/i18n-DF6keNBA.js.gz +0 -0
- package/dist/client/assets/index-DCwfhKK9.js +0 -42
- package/dist/client/assets/index-DCwfhKK9.js.br +0 -0
- package/dist/client/assets/index-DCwfhKK9.js.gz +0 -0
- package/dist/client/assets/index-SVNFLCYh.css +0 -1
- package/dist/client/assets/index-SVNFLCYh.css.br +0 -0
- package/dist/client/assets/index-SVNFLCYh.css.gz +0 -0
- package/dist/client/assets/info-DNSAs0_-.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-C8oL6PTV.js +0 -1
- package/dist/client/assets/minus-TCBOakyi.js +0 -1
- package/dist/client/assets/plus-Dfkyfvvy.js +0 -1
- package/dist/client/assets/refresh-cw-DuLtxWBX.js +0 -1
- package/dist/client/assets/relativeTime-BR0CVAvz.js +0 -1
- package/dist/client/assets/relativeTime-BR0CVAvz.js.br +0 -0
- package/dist/client/assets/relativeTime-BR0CVAvz.js.gz +0 -0
- package/dist/client/assets/search-n-2tBATf.js +0 -1
- package/dist/client/assets/spellCheck-xzICTGx1.js.br +0 -0
- package/dist/client/assets/spellCheck-xzICTGx1.js.gz +0 -0
- package/dist/client/assets/tags-Dy96boLq.js +0 -1
- package/dist/client/assets/terminal-C0xh8jVR.js +0 -1
- package/dist/client/assets/type-BjXWxrjH.js +0 -1
- package/dist/client/assets/user-plus-3oJZJXHW.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,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.
|
|
@@ -125,11 +128,12 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
125
128
|
if (!user)
|
|
126
129
|
return;
|
|
127
130
|
const query = request.query;
|
|
131
|
+
const scope = query.scope === "owned" || query.scope === "shared" ? query.scope : "all";
|
|
128
132
|
const archivedOnly = query.archived === "1" || query.archived === "true";
|
|
129
133
|
const requestedPage = Number.parseInt(query.page ?? "1", 10);
|
|
130
134
|
const page = Number.isFinite(requestedPage) && requestedPage > 0 ? requestedPage : 1;
|
|
131
|
-
const requestedPageSize = Number.parseInt(query.pageSize ??
|
|
132
|
-
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));
|
|
133
137
|
const search = typeof query.search === "string" ? query.search.trim() : "";
|
|
134
138
|
const tagId = typeof query.tag === "string" ? query.tag.trim() : "";
|
|
135
139
|
const sortColumn = query.sort === "created" ? "p.created_at" : "p.updated_at";
|
|
@@ -139,10 +143,7 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
139
143
|
const from = `FROM projects p JOIN users owner ON owner.id = p.owner_id
|
|
140
144
|
LEFT JOIN users modifier ON modifier.id = p.last_modified_by
|
|
141
145
|
LEFT JOIN project_members pm ON pm.project_id = p.id AND pm.user_id = :userId`;
|
|
142
|
-
const conditions = [
|
|
143
|
-
"(p.owner_id = :userId OR pm.user_id = :userId)",
|
|
144
|
-
archiveCondition
|
|
145
|
-
];
|
|
146
|
+
const conditions = ["(p.owner_id = :userId OR pm.user_id = :userId)"];
|
|
146
147
|
const params = { userId: user.id };
|
|
147
148
|
if (search) {
|
|
148
149
|
conditions.push("(p.name LIKE :search ESCAPE '\\' OR owner.username LIKE :search ESCAPE '\\' OR owner.display_name LIKE :search ESCAPE '\\')");
|
|
@@ -157,16 +158,23 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
157
158
|
params.tagId = tagId;
|
|
158
159
|
}
|
|
159
160
|
const where = `WHERE ${conditions.join(" AND ")}`;
|
|
160
|
-
const
|
|
161
|
-
|
|
161
|
+
const ownershipCondition = scope === "all" ? "" : ` AND p.owner_id ${scope === "owned" ? "=" : "<>"} :userId`;
|
|
162
|
+
// Tab badges span both archive states; pagination counts only visible rows.
|
|
163
|
+
const { total, ...counts } = db.prepare(`SELECT COUNT(DISTINCT p.id) AS "all",
|
|
164
|
+
COUNT(DISTINCT CASE WHEN p.owner_id = :userId THEN p.id END) AS owned,
|
|
165
|
+
COUNT(DISTINCT CASE WHEN p.owner_id <> :userId THEN p.id END) AS shared,
|
|
166
|
+
COUNT(DISTINCT CASE WHEN ${archiveCondition}${ownershipCondition} THEN p.id END) AS total
|
|
167
|
+
${from} ${where}`).get(params);
|
|
168
|
+
const scopedWhere = `${where} AND ${archiveCondition}${ownershipCondition}`;
|
|
162
169
|
const totalPages = Math.ceil(total / pageSize);
|
|
163
170
|
const currentPage = totalPages === 0 ? 1 : Math.min(page, totalPages);
|
|
164
171
|
const rowsParams = { ...params, limit: pageSize, offset: (currentPage - 1) * pageSize };
|
|
165
172
|
const select = `SELECT DISTINCT p.*,
|
|
166
173
|
CASE WHEN p.owner_id = :userId THEN 'owner' ELSE pm.permission END AS permission,
|
|
167
174
|
owner.username AS owner_username, owner.display_name AS owner_display_name,
|
|
168
|
-
modifier.username AS last_modified_username, modifier.display_name AS last_modified_display_name
|
|
169
|
-
|
|
175
|
+
modifier.username AS last_modified_username, modifier.display_name AS last_modified_display_name,
|
|
176
|
+
(SELECT COUNT(*) FROM project_members members WHERE members.project_id = p.id AND members.user_id <> p.owner_id) AS shared_member_count`;
|
|
177
|
+
const rows = db.prepare(`${select} ${from} ${scopedWhere}
|
|
170
178
|
ORDER BY ${sortColumn} DESC, p.name COLLATE NOCASE ASC
|
|
171
179
|
LIMIT :limit OFFSET :offset`).all(rowsParams);
|
|
172
180
|
const projects = rows;
|
|
@@ -174,9 +182,16 @@ export function registerProjectCatalogRoutes(app, context) {
|
|
|
174
182
|
const projectTags = tagsForProjects(db, projectIds, user.id);
|
|
175
183
|
const commentsSummaries = commentsSummaryForProjects(db, projectIds);
|
|
176
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
|
+
if (!projectTags.get(project.id)?.length)
|
|
189
|
+
previews.set(project.id, await projectPreviews.read(project.id, project.main_file));
|
|
190
|
+
}));
|
|
177
191
|
return {
|
|
178
|
-
projects: projects.map((project) => projectJson({ ...project, archived: archivedOnly }, projectTags.get(project.id) ?? [], commentsSummaries.get(project.id), unreadMentionCounts.get(project.id) ?? 0)),
|
|
179
|
-
pagination: { page: currentPage, pageSize, total, totalPages }
|
|
192
|
+
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) } : {}) })),
|
|
193
|
+
pagination: { page: currentPage, pageSize, total, totalPages },
|
|
194
|
+
counts
|
|
180
195
|
};
|
|
181
196
|
});
|
|
182
197
|
app.post("/api/projects", async (request, reply) => {
|
|
@@ -34,9 +34,15 @@ export function registerUserManagementRoutes(app, context) {
|
|
|
34
34
|
ORDER BY u.created_at, u.username COLLATE NOCASE
|
|
35
35
|
LIMIT ? OFFSET ?
|
|
36
36
|
`).all(...params, pageSize, (page - 1) * pageSize);
|
|
37
|
+
const summary = db.prepare(`SELECT COUNT(*) AS totalUsers,
|
|
38
|
+
COUNT(CASE WHEN role = 'admin' THEN 1 END) AS administrators,
|
|
39
|
+
COUNT(CASE WHEN role = 'admin' OR can_create_projects = 1 THEN 1 END) AS projectCreators,
|
|
40
|
+
(SELECT COUNT(*) FROM projects) AS totalProjects,
|
|
41
|
+
(SELECT COUNT(DISTINCT owner_id) FROM projects) AS projectOwners FROM users`).get();
|
|
37
42
|
return {
|
|
38
43
|
users: users.map((user) => ({ ...publicUser(user), ownedProjects: user.owned_projects })),
|
|
39
|
-
pagination: { page, pageSize, total, totalPages }
|
|
44
|
+
pagination: { page, pageSize, total, totalPages },
|
|
45
|
+
summary
|
|
40
46
|
};
|
|
41
47
|
});
|
|
42
48
|
app.post("/api/admin/users", async (request, reply) => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
4
|
+
import { digestToken } from "./security.js";
|
|
5
|
+
/** Keep this file alongside the database when backing up read-only links. */
|
|
6
|
+
export const VIEW_LINK_KEY_FILE = "view-link-token.key";
|
|
7
|
+
function encryptionKey(config, create) {
|
|
8
|
+
const file = path.join(config.dataDir, VIEW_LINK_KEY_FILE);
|
|
9
|
+
if (create && !fs.existsSync(file)) {
|
|
10
|
+
fs.mkdirSync(config.dataDir, { recursive: true, mode: 0o700 });
|
|
11
|
+
try {
|
|
12
|
+
fs.writeFileSync(file, randomBytes(32), { flag: "wx", mode: 0o600 });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code !== "EEXIST")
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const key = fs.readFileSync(file);
|
|
20
|
+
if (key.length !== 32)
|
|
21
|
+
throw new Error("Invalid read-only link encryption key");
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
const associatedData = (row) => Buffer.from(JSON.stringify(["TexLite view link", row.project_id, row.id]));
|
|
25
|
+
export function encryptViewLinkToken(config, row, token) {
|
|
26
|
+
const iv = randomBytes(12);
|
|
27
|
+
const cipher = createCipheriv("aes-256-gcm", encryptionKey(config, true), iv);
|
|
28
|
+
cipher.setAAD(associatedData(row));
|
|
29
|
+
const encrypted = Buffer.concat([cipher.update(token, "utf8"), cipher.final()]);
|
|
30
|
+
return ["v1", iv.toString("base64url"), cipher.getAuthTag().toString("base64url"), encrypted.toString("base64url")].join(".");
|
|
31
|
+
}
|
|
32
|
+
/** Missing legacy secrets or an unavailable key must not hide revocation controls. */
|
|
33
|
+
export function decryptViewLinkToken(config, row) {
|
|
34
|
+
if (!row.token_ciphertext)
|
|
35
|
+
return null;
|
|
36
|
+
try {
|
|
37
|
+
const [version, iv, tag, ciphertext, extra] = row.token_ciphertext.split(".");
|
|
38
|
+
if (version !== "v1" || !iv || !tag || !ciphertext || extra !== undefined)
|
|
39
|
+
return null;
|
|
40
|
+
const decipher = createDecipheriv("aes-256-gcm", encryptionKey(config, false), Buffer.from(iv, "base64url"));
|
|
41
|
+
decipher.setAAD(associatedData(row));
|
|
42
|
+
decipher.setAuthTag(Buffer.from(tag, "base64url"));
|
|
43
|
+
const token = Buffer.concat([decipher.update(Buffer.from(ciphertext, "base64url")), decipher.final()]).toString("utf8");
|
|
44
|
+
return /^[A-Za-z0-9_-]{43}$/.test(token) && digestToken(token) === row.token_hash ? token : null;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { digestToken } from "./security.js";
|
|
2
|
+
import { httpError } from "./http.js";
|
|
3
|
+
export function viewLinkJson(row, path) {
|
|
4
|
+
return { id: row.id, label: row.label, createdAt: row.created_at, expiresAt: row.expires_at, path };
|
|
5
|
+
}
|
|
6
|
+
export function viewCookieName(id) {
|
|
7
|
+
return `texlite_view_${id.replaceAll("-", "")}`;
|
|
8
|
+
}
|
|
9
|
+
/** Called on EVERY resource request, including Range/HEAD; never grants a UserRow. */
|
|
10
|
+
export function requireViewLink(db, request, token) {
|
|
11
|
+
const { linkId } = request.params;
|
|
12
|
+
if (!/^[a-f0-9-]{36}$/i.test(linkId))
|
|
13
|
+
throw httpError(410, "VIEW_LINK_INVALID");
|
|
14
|
+
const secret = token ?? request.cookies[viewCookieName(linkId)];
|
|
15
|
+
if (typeof secret !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(secret))
|
|
16
|
+
throw httpError(410, "VIEW_LINK_INVALID");
|
|
17
|
+
const row = db.prepare(`SELECT link.* FROM project_view_links link
|
|
18
|
+
JOIN projects p ON p.id = link.project_id
|
|
19
|
+
WHERE link.id = ? AND link.token_hash = ?
|
|
20
|
+
AND (link.expires_at IS NULL OR link.expires_at > ?)`)
|
|
21
|
+
.get(linkId, digestToken(secret), new Date().toISOString());
|
|
22
|
+
if (!row)
|
|
23
|
+
throw httpError(410, "VIEW_LINK_INVALID");
|
|
24
|
+
return row;
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const citationCollectionMessages = {
|
|
2
|
+
en: {
|
|
3
|
+
CITATION_NOTES_TOO_LARGE: "Notes must be 64 KB or smaller.",
|
|
4
|
+
CITATION_FOLDER_INVALID: "Choose a valid TexLite citation folder exported with notes.",
|
|
5
|
+
CITATION_FOLDER_TOO_LARGE: "Folder transfers support up to 16 MB and 500 entries.",
|
|
6
|
+
CITATION_COLLECTION_NOT_FOUND: "The citation folder does not exist.",
|
|
7
|
+
CITATION_COLLECTION_FULL: "This folder has reached its 500-entry limit. Remove a reference before adding another.",
|
|
8
|
+
CITATION_COLLECTION_NAME_EXISTS: "A citation folder with this name already exists.",
|
|
9
|
+
CITATION_COLLECTION_NAME_INVALID: "Use a folder name of 80 characters or fewer."
|
|
10
|
+
},
|
|
11
|
+
zh: {
|
|
12
|
+
CITATION_NOTES_TOO_LARGE: "笔记不能超过 64 KB。",
|
|
13
|
+
CITATION_FOLDER_INVALID: "请选择通过 TexLite 导出的含笔记文献文件夹。",
|
|
14
|
+
CITATION_FOLDER_TOO_LARGE: "文献文件夹传输最多支持 16 MB 和 500 个条目。",
|
|
15
|
+
CITATION_COLLECTION_NOT_FOUND: "此文献文件夹不存在。",
|
|
16
|
+
CITATION_COLLECTION_FULL: "此文件夹已达到 500 条文献上限,请先移出部分文献再添加。",
|
|
17
|
+
CITATION_COLLECTION_NAME_EXISTS: "已存在同名的文献文件夹。",
|
|
18
|
+
CITATION_COLLECTION_NAME_INVALID: "请输入不超过 80 个字符的文件夹名称。"
|
|
19
|
+
},
|
|
20
|
+
"zh-Hant": {
|
|
21
|
+
CITATION_NOTES_TOO_LARGE: "筆記不能超過 64 KB。",
|
|
22
|
+
CITATION_FOLDER_INVALID: "請選擇透過 TexLite 匯出的含筆記文獻資料夾。",
|
|
23
|
+
CITATION_FOLDER_TOO_LARGE: "文獻資料夾傳輸最多支援 16 MB 和 500 個條目。",
|
|
24
|
+
CITATION_COLLECTION_NOT_FOUND: "此文獻資料夾不存在。",
|
|
25
|
+
CITATION_COLLECTION_FULL: "此資料夾已達 500 條文獻上限,請先移出部分文獻再新增。",
|
|
26
|
+
CITATION_COLLECTION_NAME_EXISTS: "已存在同名的文獻資料夾。",
|
|
27
|
+
CITATION_COLLECTION_NAME_INVALID: "請輸入不超過 80 個字元的資料夾名稱。"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A portable folder contains no user IDs, tags or database-specific memberships. */
|
|
2
|
+
export const CITATION_FOLDER_FORMAT = "texlite-citation-folder";
|
|
3
|
+
export const CITATION_FOLDER_VERSION = 1;
|
|
4
|
+
export const MAX_CITATION_NOTES_BYTES = 64 * 1024;
|
|
5
|
+
export const MAX_CITATION_FOLDER_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
/** Shared folder capacity and per-transfer entry limit. */
|
|
7
|
+
export const MAX_CITATION_FOLDER_ENTRIES = 500;
|
package/dist/shared/comments.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** Transport types shared by comment routes and the workspace cache. */
|
|
2
|
+
export const MAX_SUGGESTION_LENGTH = 50_000;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_PROJECT_PAGE_SIZE = 32;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const viewLinkMessages = {
|
|
2
|
+
en: {
|
|
3
|
+
VIEW_LINK_INVALID: "This read-only link is invalid, expired or revoked.",
|
|
4
|
+
VIEW_LINK_EXISTS: "This project already has an active read-only link. Copy it or revoke it before creating another.",
|
|
5
|
+
VIEW_LINK_EXPIRY_INVALID: "Choose a future expiry time.",
|
|
6
|
+
VIEW_LINK_LABEL_INVALID: "Use a link name of 80 characters or fewer."
|
|
7
|
+
},
|
|
8
|
+
zh: {
|
|
9
|
+
VIEW_LINK_INVALID: "此只读链接无效、已过期或已撤销。",
|
|
10
|
+
VIEW_LINK_EXISTS: "此项目已有有效的只读链接,请复制现有链接,或撤销后再创建。",
|
|
11
|
+
VIEW_LINK_EXPIRY_INVALID: "请选择将来的过期时间。",
|
|
12
|
+
VIEW_LINK_LABEL_INVALID: "链接名称不能超过 80 个字符。"
|
|
13
|
+
},
|
|
14
|
+
"zh-Hant": {
|
|
15
|
+
VIEW_LINK_INVALID: "此唯讀連結無效、已過期或已撤銷。",
|
|
16
|
+
VIEW_LINK_EXISTS: "此專案已有有效的唯讀連結,請複製現有連結,或撤銷後再建立。",
|
|
17
|
+
VIEW_LINK_EXPIRY_INVALID: "請選擇未來的到期時間。",
|
|
18
|
+
VIEW_LINK_LABEL_INVALID: "連結名稱不能超過 80 個字元。"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
SUGGESTION_INVALID: "Select a passage and provide different replacement text (up to 50,000 characters).",
|
|
3
|
+
SUGGESTION_REVIEWER_INVALID: "Choose a reviewer with write access to this project.",
|
|
4
|
+
SUGGESTION_SELF_REVIEW: "The comment author cannot review their own suggestion.",
|
|
5
|
+
SUGGESTION_REVIEW_FORBIDDEN: "Only the assigned reviewer with write access can review this suggestion.",
|
|
6
|
+
SUGGESTION_SOURCE_CHANGED: "The original passage has changed or can no longer be located. Create a new suggestion from the current source.",
|
|
7
|
+
SUGGESTION_EXISTS: "This discussion already has a suggestion.",
|
|
8
|
+
SUGGESTION_PENDING: "Review the pending suggestion before resolving this discussion.",
|
|
9
|
+
SUGGESTION_DECIDED: "This suggestion has already been reviewed.",
|
|
10
|
+
SUGGESTION_UPDATED: "This suggestion was updated. Check the latest content and try again.",
|
|
11
|
+
SUGGESTION_APPLYING: "This change is being saved. Retry accepting it to finish; do not apply it again manually.",
|
|
12
|
+
SUGGESTION_RECOVERY_FAILED: "The saved suggestion could not be recovered. Check the server log before changing this project."
|
|
13
|
+
};
|
|
14
|
+
const zh = {
|
|
15
|
+
SUGGESTION_INVALID: "请选择一段源码,并提供不同的替换内容(最多 50,000 个字符)。",
|
|
16
|
+
SUGGESTION_REVIEWER_INVALID: "请选择对本项目有写权限的审核人。",
|
|
17
|
+
SUGGESTION_SELF_REVIEW: "评论作者不能审核自己的修改建议。",
|
|
18
|
+
SUGGESTION_REVIEW_FORBIDDEN: "只有仍有写权限的指定审核人可以审核此建议。",
|
|
19
|
+
SUGGESTION_SOURCE_CHANGED: "原文已修改或无法定位,请基于当前源码重新提出建议。",
|
|
20
|
+
SUGGESTION_EXISTS: "此讨论已有修改建议。",
|
|
21
|
+
SUGGESTION_PENDING: "请先审核待处理的修改建议,再解决此讨论。",
|
|
22
|
+
SUGGESTION_DECIDED: "此建议已完成审核。",
|
|
23
|
+
SUGGESTION_UPDATED: "修改建议已更新,请查看最新内容后重试。",
|
|
24
|
+
SUGGESTION_APPLYING: "修改正在保存,请重试接受以完成操作,不要手动重复应用。",
|
|
25
|
+
SUGGESTION_RECOVERY_FAILED: "无法恢复已保存的修改建议,请先检查服务器日志,再修改此项目。"
|
|
26
|
+
};
|
|
27
|
+
const zhHant = {
|
|
28
|
+
SUGGESTION_INVALID: "請選取一段原始碼,並提供不同的替換內容(最多 50,000 個字元)。",
|
|
29
|
+
SUGGESTION_REVIEWER_INVALID: "請選擇對本專案有寫入權限的審核人。",
|
|
30
|
+
SUGGESTION_SELF_REVIEW: "批註作者不能審核自己的修改建議。",
|
|
31
|
+
SUGGESTION_REVIEW_FORBIDDEN: "只有仍有寫入權限的指定審核人可以審核此建議。",
|
|
32
|
+
SUGGESTION_SOURCE_CHANGED: "原文已修改或無法定位,請根據目前原始碼重新提出建議。",
|
|
33
|
+
SUGGESTION_EXISTS: "此討論已有修改建議。",
|
|
34
|
+
SUGGESTION_PENDING: "請先審核待處理的修改建議,再解決此討論。",
|
|
35
|
+
SUGGESTION_DECIDED: "此建議已完成審核。",
|
|
36
|
+
SUGGESTION_UPDATED: "修改建議已更新,請查看最新內容後再試。",
|
|
37
|
+
SUGGESTION_APPLYING: "修改正在儲存,請重試接受以完成操作,不要手動重複套用。",
|
|
38
|
+
SUGGESTION_RECOVERY_FAILED: "無法復原已儲存的修改建議,請先檢查伺服器日誌,再修改此專案。"
|
|
39
|
+
};
|
|
40
|
+
export const suggestionMessages = { en, zh, "zh-Hant": zhHant };
|
|
41
|
+
export const defaultSuggestionComments = { en: "Suggested change", zh: "修改意见", "zh-Hant": "修改意見" };
|
package/dist/shared/updates.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Commands are displayed for manual execution, never run by the server. */
|
|
2
2
|
export const UPDATE_COMMANDS = {
|
|
3
|
-
npm: "npm
|
|
3
|
+
npm: "npm update --global texlite\ntexlite restart",
|
|
4
4
|
docker: "git pull --ff-only\n./scripts/compose.sh pull\n./scripts/compose.sh up -d"
|
|
5
5
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "texlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "A lightweight local-first collaborative LaTeX workspace",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -125,7 +125,10 @@
|
|
|
125
125
|
"react": "^19.1.1",
|
|
126
126
|
"react-dom": "^19.1.1",
|
|
127
127
|
"react-i18next": "^17.1.0",
|
|
128
|
+
"react-markdown": "^10.1.0",
|
|
128
129
|
"react-resizable-panels": "^4.14.8",
|
|
130
|
+
"remark-gfm": "^4.0.1",
|
|
131
|
+
"remark-math": "^6.0.0",
|
|
129
132
|
"tex-fmt": "0.5.7-npm.1",
|
|
130
133
|
"tsx": "^4.20.3",
|
|
131
134
|
"typescript": "^5.8.3",
|
|
@@ -136,6 +139,11 @@
|
|
|
136
139
|
"y-indexeddb": "^9.0.12",
|
|
137
140
|
"y-websocket": "^3.0.0"
|
|
138
141
|
},
|
|
142
|
+
"overrides": {
|
|
143
|
+
"micromark-extension-math": {
|
|
144
|
+
"katex": "$katex"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
139
147
|
"optionalDependencies": {
|
|
140
148
|
"node-pty": "^1.1.0"
|
|
141
149
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{$ as r,I as i,M as a,N as ee,Z as te,at as ne,et as re}from"./relativeTime-BR0CVAvz.js";import{t as ie}from"./search-n-2tBATf.js";import{t as o}from"./user-plus-3oJZJXHW.js";import{C as s,E as c,b as l,c as u,j as ae,s as oe,y as se}from"./index-DCwfhKK9.js";import{a as ce,l as le,n as ue,r as de,t as fe}from"./dist-CMYWzCHL.js";import{t as pe}from"./SuccessNotice-ubBtzzi_.js";var d={name:`dices`,size:24,node:[[`rect`,{width:`12`,height:`12`,x:`2`,y:`10`,rx:`2`,ry:`2`,key:`6agr2n`}],[`path`,{d:`m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6`,key:`1o487t`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 14h.01`,key:`ssrbsk`}],[`path`,{d:`M15 6h.01`,key:`cblpky`}],[`path`,{d:`M18 9h.01`,key:`2061c0`}]]};d.node;var f=l(d),p={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};p.node;var m=l(p),h={name:`lock-keyhole`,size:24,node:[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]};h.node;var g=l(h),_=e(t(),1),v=n();function y(e=10){let t=crypto.getRandomValues(new Uint8Array(e));return Array.from(t,e=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%`[e%62]).join(``)}function b({currentUser:e,minPasswordLength:t,onBack:n}){let{t:l}=ae(),[d,p]=(0,_.useState)([]),[h,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(1),[C,me]=(0,_.useState)({page:1,pageSize:20,total:0,totalPages:0}),[w,T]=(0,_.useState)(!0),[E,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(0),[D,O]=(0,_.useState)(``),k=pe(),[A,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(``),[ve,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)({username:``,displayName:``,password:``,role:`user`,canCreateProjects:!1}),[L,R]=(0,_.useState)(null),[z,B]=(0,_.useState)(``),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(!1),[G,K]=(0,_.useState)(!1),[ye,q]=(0,_.useState)(``),[J,Y]=(0,_.useState)(null),[X,be]=(0,_.useState)(!1),[xe,Z]=(0,_.useState)(``),Q=h.trim(),$=()=>_e(e=>e+1);(0,_.useEffect)(()=>{let e=new AbortController;T(!0),he(!1),O(``);let t=window.setTimeout(()=>{let t=new URLSearchParams({page:String(x)});Q&&t.set(`q`,Q),c(`/api/admin/users?${t}`,{signal:e.signal}).then(t=>{e.signal.aborted||(p(t.users),me(t.pagination),S(t.pagination.page))}).catch(t=>{e.signal.aborted||(O(s(t)),he(!0))}).finally(()=>{e.signal.aborted||T(!1)})},Q?200:0);return()=>{window.clearTimeout(t),e.abort()}},[Q,x,ge]);let Se=async()=>{if(!A){if(F.password.length<t)return N(l(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await c(`/api/admin/users`,{method:`POST`,body:JSON.stringify({username:F.username,displayName:F.displayName||F.username,password:F.password,role:F.role,canCreateProjects:F.canCreateProjects})}),P(!1),I({username:``,displayName:``,password:``,role:`user`,canCreateProjects:!1}),$(),k.show(`create`)}catch(e){N(s(e))}finally{j(!1)}}},Ce=async e=>{Y({target:e,setting:e.role===`admin`?`demote`:`promote`}),Z(``)},we=async e=>{Y({target:e,setting:e.canCreateProjects?`denyProjectCreation`:`allowProjectCreation`}),Z(``)},Te=async()=>{if(!J||X)return;let{target:e,setting:t}=J,n=t===`demote`?{role:`user`}:t===`promote`?{role:`admin`}:{canCreateProjects:t===`allowProjectCreation`};be(!0),Z(``);try{await c(`/api/admin/users/${e.id}`,{method:`PATCH`,body:JSON.stringify(n)}),$(),Y(null)}catch(e){Z(s(e))}finally{be(!1)}},Ee=async()=>{if(L&&z&&!A){if(z.length<t)return N(l(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await c(`/api/admin/users/${L.id}`,{method:`PATCH`,body:JSON.stringify({password:z})}),k.show(`reset:${L.id}`),R(null),B(``)}catch(e){N(s(e))}finally{j(!1)}}},De=async()=>{if(V&&!G){K(!0),q(``);try{await c(`/api/admin/users/${V.id}`,{method:`DELETE`,body:JSON.stringify({deleteProjects:U})}),H(null),W(!1),$()}catch(e){q(s(e))}finally{K(!1)}}};return(0,v.jsxs)(`section`,{className:`admin-users-page management-page`,children:[(0,v.jsxs)(`div`,{className:`section-title`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`h1`,{children:[(0,v.jsx)(ee,{"aria-hidden":!0,size:25}),l(`users.manage`)]}),(0,v.jsx)(`p`,{className:`muted`,children:l(`users.onlyAdmin`)})]}),(0,v.jsxs)(`button`,{type:`button`,className:`dashboard-back-button`,onClick:n,children:[(0,v.jsx)(ne,{size:14}),l(`navigation.backToProjects`)]})]}),(0,v.jsxs)(`div`,{className:`admin-user-toolbar`,children:[(0,v.jsxs)(`div`,{className:`admin-user-filters`,children:[(0,v.jsxs)(`div`,{className:`admin-user-search`,role:`search`,children:[(0,v.jsx)(ie,{"aria-hidden":!0,size:16}),(0,v.jsx)(`input`,{role:`searchbox`,"aria-label":l(`users.searchPlaceholder`),placeholder:l(`users.searchPlaceholder`),value:h,onChange:e=>{b(e.target.value),S(1)}}),h&&(0,v.jsx)(`button`,{type:`button`,"aria-label":l(`users.clearSearch`),title:l(`users.clearSearch`),onClick:()=>{b(``),S(1)},children:(0,v.jsx)(a,{"aria-hidden":!0,size:14})})]}),!w&&!E&&(0,v.jsx)(`span`,{className:`admin-user-count`,role:`status`,children:l(`users.total`,{count:C.total})})]}),(0,v.jsxs)(`button`,{className:`primary icon-button admin-user-add`,onClick:()=>{k.clear(),N(``),P(!0)},children:[(0,v.jsx)(o,{"aria-hidden":!0,size:15}),(0,v.jsx)(`span`,{role:`status`,children:l(k.message===`create`?`common.done`:`users.add`)})]})]}),D&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:D}),(0,v.jsx)(`div`,{className:`table-card admin-user-table`,"aria-busy":w,children:(0,v.jsxs)(`table`,{children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:l(`common.user`)}),(0,v.jsx)(`th`,{children:l(`users.role`)}),(0,v.jsx)(`th`,{children:l(`users.createProjects`)}),(0,v.jsx)(`th`,{children:l(`users.ownedProjects`)}),(0,v.jsx)(`th`,{children:l(`users.actions`)})]})}),(0,v.jsx)(`tbody`,{children:w?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:5,className:`admin-user-list-state`,children:(0,v.jsxs)(`span`,{role:`status`,children:[(0,v.jsx)(se,{className:`spin`,size:16}),l(`common.loading`)]})})}):E?(0,v.jsx)(`tr`,{children:(0,v.jsxs)(`td`,{colSpan:5,className:`admin-user-list-state`,children:[(0,v.jsx)(`span`,{children:l(`users.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:$,children:l(`common.retry`)})]})}):d.length===0?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:5,className:`admin-user-list-state`,children:l(Q?`users.noMatches`:`users.empty`)})}):d.map(t=>{let n=t.id===e.id,r=A||X;return(0,v.jsxs)(`tr`,{children:[(0,v.jsxs)(`td`,{className:`admin-user-identity`,children:[(0,v.jsx)(`strong`,{children:t.displayName}),(0,v.jsxs)(`small`,{children:[`@`,t.username]})]}),(0,v.jsx)(`td`,{children:n?(0,v.jsxs)(`span`,{className:`admin-user-badge`,title:l(`users.selfProtected`),children:[(0,v.jsx)(g,{size:12,"aria-hidden":!0}),l(`common.admin`)]}):(0,v.jsxs)(`select`,{className:`admin-user-role`,"aria-label":l(`users.roleFor`,{username:t.username}),value:t.role,disabled:r,onChange:()=>void Ce(t),children:[(0,v.jsx)(`option`,{value:`user`,children:l(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:l(`common.admin`)})]})}),(0,v.jsx)(`td`,{children:t.role===`admin`?(0,v.jsxs)(`span`,{className:`admin-user-locked`,title:l(`users.adminCreation`),children:[(0,v.jsx)(g,{size:12,"aria-hidden":!0}),l(`users.allow`)]}):(0,v.jsx)(`button`,{type:`button`,className:`admin-user-switch`,role:`switch`,"aria-checked":t.canCreateProjects,"aria-label":l(`users.creationFor`,{username:t.username}),disabled:r,onClick:()=>void we(t),children:(0,v.jsx)(`span`,{})})}),(0,v.jsx)(`td`,{children:t.ownedProjects??0}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`admin-user-actions`,children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:r,onClick:()=>{k.clear(),R(t),B(``),N(``)},children:[(0,v.jsx)(m,{"aria-hidden":!0,size:13}),(0,v.jsx)(`span`,{role:`status`,children:l(k.message===`reset:${t.id}`?`common.done`:`users.resetPassword`)})]}),!n&&(0,v.jsxs)(fe,{modal:!1,children:[(0,v.jsx)(le,{asChild:!0,children:(0,v.jsx)(`button`,{className:`icon-button`,disabled:r,"aria-label":l(`users.actionsFor`,{username:t.username}),children:(0,v.jsx)(te,{size:17,"aria-hidden":!0})})}),(0,v.jsx)(ce,{children:(0,v.jsx)(ue,{className:`comment-actions-menu-content`,align:`end`,sideOffset:5,children:(0,v.jsxs)(de,{className:`danger-text`,onSelect:()=>{H(t),W(!1),q(``)},children:[(0,v.jsx)(i,{size:14,"aria-hidden":!0}),l(`users.deleteTitle`)]})})})]})]})})]},t.id)})})]})}),C.totalPages>1&&(0,v.jsxs)(`nav`,{className:`project-pagination admin-user-pagination`,"aria-label":l(`users.pagination`),children:[(0,v.jsxs)(`button`,{type:`button`,disabled:w||E||C.page<=1,onClick:()=>S(C.page-1),children:[(0,v.jsx)(re,{size:15}),l(`users.previousPage`)]}),(0,v.jsx)(`span`,{children:l(`users.pageOf`,{page:C.page,totalPages:C.totalPages})}),(0,v.jsxs)(`button`,{type:`button`,disabled:w||E||C.page>=C.totalPages,onClick:()=>S(C.page+1),children:[l(`users.nextPage`),(0,v.jsx)(r,{size:15})]})]}),(0,v.jsxs)(u,{className:`management-dialog`,open:ve,title:l(`users.add`),description:l(`users.addDescription`),onOpenChange:e=>{A||P(e)},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:A,onClick:()=>P(!1),children:[(0,v.jsx)(a,{"aria-hidden":!0,size:14}),l(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`primary icon-button`,disabled:A||!F.username.trim()||F.password.length<t,onClick:()=>void Se(),children:[(0,v.jsx)(o,{"aria-hidden":!0,size:14}),l(`users.createUser`)]})]}),children:[M&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:M}),(0,v.jsxs)(`fieldset`,{className:`admin-user-form form-stack`,disabled:A,children:[(0,v.jsxs)(`label`,{className:`form-field`,children:[l(`auth.username`),(0,v.jsx)(`input`,{value:F.username,onChange:e=>I({...F,username:e.target.value})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[l(`users.displayName`),(0,v.jsx)(`input`,{value:F.displayName,onChange:e=>I({...F,displayName:e.target.value})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[l(`users.initialPassword`),(0,v.jsxs)(`span`,{className:`password-generator`,children:[(0,v.jsx)(`input`,{minLength:t,autoComplete:`new-password`,value:F.password,onChange:e=>I({...F,password:e.target.value})}),(0,v.jsxs)(`button`,{type:`button`,title:l(`users.generatePassword`),onClick:()=>I({...F,password:y()}),children:[(0,v.jsx)(f,{size:15}),l(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:l(`auth.passwordMinimum`,{count:t})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[l(`users.role`),(0,v.jsxs)(`select`,{value:F.role,onChange:e=>I({...F,role:e.target.value}),children:[(0,v.jsx)(`option`,{value:`user`,children:l(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:l(`common.admin`)})]})]}),(0,v.jsxs)(`label`,{className:`checkbox-field`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:F.canCreateProjects||F.role===`admin`,disabled:F.role===`admin`,onChange:e=>I({...F,canCreateProjects:e.target.checked})}),` `,l(`users.allowCreate`)]})]})]}),(0,v.jsxs)(u,{className:`management-dialog`,open:!!L,title:l(`users.resetPassword`),description:l(`users.resetDescription`,{username:L?.username??``}),onOpenChange:e=>{!e&&!A&&R(null)},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:A,onClick:()=>R(null),children:[(0,v.jsx)(a,{"aria-hidden":!0,size:14}),l(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`primary icon-button`,disabled:A||z.length<t,onClick:()=>void Ee(),children:[(0,v.jsx)(m,{"aria-hidden":!0,size:14}),l(`users.reset`)]})]}),children:[M&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:M}),(0,v.jsxs)(`label`,{className:`form-field`,children:[l(`auth.newPassword`),(0,v.jsxs)(`span`,{className:`password-generator`,children:[(0,v.jsx)(`input`,{disabled:A,autoFocus:!0,minLength:t,autoComplete:`new-password`,value:z,onChange:e=>B(e.target.value)}),(0,v.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>B(y()),children:[(0,v.jsx)(f,{size:15}),l(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:l(`auth.passwordMinimum`,{count:t})})]})]}),(0,v.jsx)(u,{className:`management-dialog`,open:!!V,title:l(`users.deleteTitle`),description:l(`users.deleteDescription`,{username:V?.username??``}),onOpenChange:e=>{!e&&!G&&(H(null),q(``))},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:G,onClick:()=>{H(null),q(``)},children:[(0,v.jsx)(a,{"aria-hidden":!0,size:14}),l(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`danger icon-button`,disabled:G,"aria-busy":G,onClick:()=>void De(),children:[G?(0,v.jsx)(se,{className:`spin`,"aria-hidden":!0,size:14}):(0,v.jsx)(i,{"aria-hidden":!0,size:14}),l(G?`common.loading`:`users.deleteTitle`)]})]}),children:(0,v.jsxs)(v.Fragment,{children:[ye&&(0,v.jsx)(`p`,{className:`error dialog-error`,children:ye}),(0,v.jsxs)(`fieldset`,{className:`choice-group`,disabled:G,children:[(0,v.jsx)(`legend`,{children:l(`users.ownedChoice`,{count:V?.ownedProjects??0})}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:!U,onChange:()=>W(!1)}),` `,l(`users.transferProjects`)]}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:U,onChange:()=>W(!0)}),` `,l(`users.deleteProjects`)]})]})]})}),(0,v.jsx)(oe,{open:!!J,title:l(`userConfirmations.${J?.setting??`demote`}Title`),description:l(`userConfirmations.${J?.setting??`demote`}Description`,{username:J?.target.username??``}),confirmLabel:l(`userConfirmations.${J?.setting??`demote`}Confirm`),danger:J?.setting!==`promote`&&J?.setting!==`allowProjectCreation`,busy:X,error:xe,onCancel:()=>{X||(Y(null),Z(``))},onConfirm:()=>void Te()})]})}export{b as AdminUsers};
|
|
Binary file
|
|
Binary file
|