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,129 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { resolveSourcePath } from "./files.js";
|
|
3
|
+
import { maskLatexComments, maskLatexLiteralContent } from "../shared/latexLiterals.js";
|
|
4
|
+
import { forEachLatexCommand, readLatexMandatoryArguments } from "../shared/latexScanner.js";
|
|
5
|
+
export const PROJECT_PREVIEW_BYTES = 64 * 1024;
|
|
6
|
+
const omittedCommands = new Set(["label", "ref", "eqref", "pageref", "cite", "citep", "citet", "citealp", "citeauthor", "citeyear",
|
|
7
|
+
"autocite", "parencite", "textcite", "footcite", "footnote", "thanks", "url", "input", "include", "includegraphics", "bibliography", "bibliographystyle"]);
|
|
8
|
+
/** Display-only text, not TeX expansion or source used by compilation. */
|
|
9
|
+
function previewText(value) {
|
|
10
|
+
const source = maskLatexComments(maskLatexLiteralContent(value));
|
|
11
|
+
const fragments = [];
|
|
12
|
+
let cursor = 0;
|
|
13
|
+
forEachLatexCommand(source, (command) => {
|
|
14
|
+
if (command.from < cursor)
|
|
15
|
+
return;
|
|
16
|
+
fragments.push(source.slice(cursor, command.from));
|
|
17
|
+
const argument = omittedCommands.has(command.name) || command.name === "begin" || command.name === "end"
|
|
18
|
+
? readLatexMandatoryArguments(source, command.to, 1)[0] : undefined;
|
|
19
|
+
cursor = argument?.to ?? command.to;
|
|
20
|
+
if (command.name === "LaTeX" || command.name === "TeX")
|
|
21
|
+
fragments.push(command.name);
|
|
22
|
+
else if (/^[%&_$#]$/.test(command.name))
|
|
23
|
+
fragments.push(command.name);
|
|
24
|
+
else if (command.name === "\\" || command.name === "par")
|
|
25
|
+
fragments.push(" ");
|
|
26
|
+
});
|
|
27
|
+
fragments.push(source.slice(cursor));
|
|
28
|
+
return fragments.join("").replace(/[{}$]/g, "").replace(/~/g, " ").replace(/\s+/g, " ").replace(/\s+([,.;:!?,。;:!?])/gu, "$1").trim();
|
|
29
|
+
}
|
|
30
|
+
function excerpt(value) {
|
|
31
|
+
const characters = Array.from(value);
|
|
32
|
+
return characters.length > 240 ? `${characters.slice(0, 240).join("")}…` : value;
|
|
33
|
+
}
|
|
34
|
+
/** Keep title and abstract separate. Never guess metadata from document-body commands. */
|
|
35
|
+
export function extractProjectPreview(source) {
|
|
36
|
+
let title = "", abstractStart = -1, abstractEnd = -1, bodyStart = -1, bodyEnd = source.length;
|
|
37
|
+
forEachLatexCommand(source, (command) => {
|
|
38
|
+
if (!["title", "begin", "end"].includes(command.name))
|
|
39
|
+
return;
|
|
40
|
+
const argument = readLatexMandatoryArguments(source, command.to, 1)[0];
|
|
41
|
+
if (!argument)
|
|
42
|
+
return;
|
|
43
|
+
const value = source.slice(argument.contentFrom, argument.contentTo);
|
|
44
|
+
if (command.name === "title" && !title)
|
|
45
|
+
title = previewText(value);
|
|
46
|
+
if (command.name === "begin" && value.trim() === "abstract" && abstractStart < 0)
|
|
47
|
+
abstractStart = argument.to;
|
|
48
|
+
if (command.name === "end" && value.trim() === "abstract" && abstractStart >= 0 && abstractEnd < 0)
|
|
49
|
+
abstractEnd = command.from;
|
|
50
|
+
if (command.name === "begin" && value.trim() === "document" && bodyStart < 0)
|
|
51
|
+
bodyStart = argument.to;
|
|
52
|
+
if (command.name === "end" && value.trim() === "document" && bodyStart >= 0)
|
|
53
|
+
bodyEnd = command.from;
|
|
54
|
+
});
|
|
55
|
+
const abstract = abstractStart >= 0 && abstractEnd >= abstractStart ? excerpt(previewText(source.slice(abstractStart, abstractEnd))) : "";
|
|
56
|
+
if (abstract || title)
|
|
57
|
+
return { title: excerpt(title), abstract };
|
|
58
|
+
if (bodyStart >= 0) {
|
|
59
|
+
const body = source.slice(bodyStart, bodyEnd);
|
|
60
|
+
// Only inspect the body to distinguish genuinely empty documents from
|
|
61
|
+
// unavailable metadata. Formatting arguments and includes are not prose.
|
|
62
|
+
return maskLatexComments(body).trim() ? null : { title: "", abstract: "" };
|
|
63
|
+
}
|
|
64
|
+
return maskLatexComments(source).trim() ? null : { title: "", abstract: "" };
|
|
65
|
+
}
|
|
66
|
+
/** Bounded main-file reads, coalesced across users and cached by file metadata. */
|
|
67
|
+
export class ProjectPreviewService {
|
|
68
|
+
config;
|
|
69
|
+
cache = new Map();
|
|
70
|
+
pending = new Map();
|
|
71
|
+
constructor(config) {
|
|
72
|
+
this.config = config;
|
|
73
|
+
}
|
|
74
|
+
read(projectId, mainFile) {
|
|
75
|
+
let file;
|
|
76
|
+
try {
|
|
77
|
+
file = resolveSourcePath(this.config, projectId, mainFile);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return Promise.resolve(null);
|
|
81
|
+
}
|
|
82
|
+
const existing = this.pending.get(file);
|
|
83
|
+
if (existing)
|
|
84
|
+
return existing;
|
|
85
|
+
const request = this.readFile(file).finally(() => { if (this.pending.get(file) === request)
|
|
86
|
+
this.pending.delete(file); });
|
|
87
|
+
this.pending.set(file, request);
|
|
88
|
+
return request;
|
|
89
|
+
}
|
|
90
|
+
async readFile(file) {
|
|
91
|
+
try {
|
|
92
|
+
const stat = await fs.promises.stat(file);
|
|
93
|
+
if (!stat.isFile())
|
|
94
|
+
return null;
|
|
95
|
+
const signature = `${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
|
|
96
|
+
const cached = this.cache.get(file);
|
|
97
|
+
if (cached?.signature === signature) {
|
|
98
|
+
this.cache.delete(file);
|
|
99
|
+
this.cache.set(file, cached);
|
|
100
|
+
return cached.preview;
|
|
101
|
+
}
|
|
102
|
+
const handle = await fs.promises.open(file, "r");
|
|
103
|
+
let source;
|
|
104
|
+
try {
|
|
105
|
+
const buffer = Buffer.alloc(Math.min(stat.size, PROJECT_PREVIEW_BYTES));
|
|
106
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
107
|
+
const bytes = buffer.subarray(0, bytesRead);
|
|
108
|
+
if (bytes.includes(0))
|
|
109
|
+
return null;
|
|
110
|
+
source = new TextDecoder("utf-8").decode(bytes, { stream: true });
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
await handle.close();
|
|
114
|
+
}
|
|
115
|
+
const extracted = extractProjectPreview(source);
|
|
116
|
+
// An empty prefix says nothing about content beyond the bounded read.
|
|
117
|
+
const preview = extracted && !extracted.title && !extracted.abstract && stat.size > PROJECT_PREVIEW_BYTES ? null : extracted;
|
|
118
|
+
this.cache.delete(file);
|
|
119
|
+
this.cache.set(file, { signature, preview });
|
|
120
|
+
if (this.cache.size > 128)
|
|
121
|
+
this.cache.delete(this.cache.keys().next().value);
|
|
122
|
+
return preview;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
this.cache.delete(file);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { isTextContent, resourceFileKind } from "../shared/fileTypes.js";
|
|
4
|
+
import { PROJECT_SEARCH_MAX_MATCHES } from "../shared/projectSearch.js";
|
|
5
|
+
import { maxCollaborativeFileBytes } from "./collaboration.js";
|
|
6
|
+
import { resolveSourcePath } from "./files.js";
|
|
7
|
+
import { httpError } from "./http.js";
|
|
8
|
+
import { searchPattern } from "./projectSearch.js";
|
|
9
|
+
/** Prepare all files without yielding or writing. Hashes bind edits to the displayed results. */
|
|
10
|
+
export function prepareProjectReplacement(config, projectId, options, replacement, targets) {
|
|
11
|
+
let replaced = 0;
|
|
12
|
+
let totalBytes = 0;
|
|
13
|
+
const files = targets.map((target) => {
|
|
14
|
+
if (resourceFileKind(target.path) !== "text")
|
|
15
|
+
throw httpError(400, "FILE_CONTENT_INVALID");
|
|
16
|
+
const absolute = resolveSourcePath(config, projectId, target.path);
|
|
17
|
+
let bytes;
|
|
18
|
+
try {
|
|
19
|
+
const stat = fs.statSync(absolute);
|
|
20
|
+
if (!stat.isFile())
|
|
21
|
+
throw httpError(409, "SEARCH_SOURCE_CHANGED");
|
|
22
|
+
totalBytes += stat.size;
|
|
23
|
+
if (totalBytes > 32 * 1024 * 1024)
|
|
24
|
+
throw httpError(409, "SEARCH_LIMITED");
|
|
25
|
+
if (stat.size > maxCollaborativeFileBytes(config))
|
|
26
|
+
throw httpError(413, "FILE_TOO_LARGE");
|
|
27
|
+
bytes = fs.readFileSync(absolute);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
|
|
31
|
+
throw httpError(409, "SEARCH_SOURCE_CHANGED");
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
if (!isTextContent(bytes))
|
|
35
|
+
throw httpError(400, "FILE_CONTENT_INVALID");
|
|
36
|
+
if (createHash("sha256").update(bytes).digest("hex") !== target.sourceHash)
|
|
37
|
+
throw httpError(409, "SEARCH_SOURCE_CHANGED");
|
|
38
|
+
const before = bytes.toString("utf8");
|
|
39
|
+
const ranges = new Map(target.ranges.map((range) => [range.from, range.to]));
|
|
40
|
+
const matchedRanges = new Set();
|
|
41
|
+
const edits = [];
|
|
42
|
+
for (const match of before.matchAll(searchPattern(options))) {
|
|
43
|
+
if (ranges.get(match.index) !== match.index + match[0].length)
|
|
44
|
+
continue;
|
|
45
|
+
matchedRanges.add(match.index);
|
|
46
|
+
if (match[0] === replacement)
|
|
47
|
+
continue;
|
|
48
|
+
if (++replaced > PROJECT_SEARCH_MAX_MATCHES)
|
|
49
|
+
throw httpError(409, "SEARCH_LIMITED");
|
|
50
|
+
edits.push({ from: match.index, to: match.index + match[0].length, insert: replacement });
|
|
51
|
+
}
|
|
52
|
+
if (matchedRanges.size !== ranges.size)
|
|
53
|
+
throw httpError(409, "SEARCH_SOURCE_CHANGED");
|
|
54
|
+
const pieces = [];
|
|
55
|
+
let offset = 0;
|
|
56
|
+
for (const edit of edits) {
|
|
57
|
+
pieces.push(before.slice(offset, edit.from), edit.insert);
|
|
58
|
+
offset = edit.to;
|
|
59
|
+
}
|
|
60
|
+
pieces.push(before.slice(offset));
|
|
61
|
+
const content = pieces.join("");
|
|
62
|
+
if (Buffer.byteLength(content, "utf8") > maxCollaborativeFileBytes(config))
|
|
63
|
+
throw httpError(413, "FILE_TOO_LARGE");
|
|
64
|
+
return { path: target.path, before, edits };
|
|
65
|
+
}).filter((file) => file.edits.length > 0);
|
|
66
|
+
return { files, replaced };
|
|
67
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { isTextContent, resourceFileKind } from "../shared/fileTypes.js";
|
|
4
|
+
import { PROJECT_SEARCH_MAX_MATCHES } from "../shared/projectSearch.js";
|
|
5
|
+
import { maxCollaborativeFileBytes } from "./collaboration.js";
|
|
6
|
+
import { listProjectFilesAsync, resolveSourcePath } from "./files.js";
|
|
7
|
+
const maxFiles = 500;
|
|
8
|
+
const maxTotalBytes = 32 * 1024 * 1024;
|
|
9
|
+
/** Literal patterns only: arbitrary user regex must not block the server's event loop. */
|
|
10
|
+
export function searchPattern(options) {
|
|
11
|
+
const literal = options.query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12
|
+
const pattern = options.wholeWord ? `(?<![\\p{L}\\p{N}_])${literal}(?![\\p{L}\\p{N}_])` : literal;
|
|
13
|
+
return new RegExp(pattern, options.caseSensitive ? "gu" : "giu");
|
|
14
|
+
}
|
|
15
|
+
/** The caller holds a consistent-read barrier so collaborative buffers are flushed first. */
|
|
16
|
+
export async function searchProject(config, projectId, options) {
|
|
17
|
+
const candidates = (await listProjectFilesAsync(config, projectId))
|
|
18
|
+
.filter((entry) => entry.type === "file" && resourceFileKind(entry.path) === "text")
|
|
19
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
20
|
+
const result = { matches: [], limited: candidates.length > maxFiles };
|
|
21
|
+
const pattern = searchPattern(options);
|
|
22
|
+
const fileLimit = Math.min(maxCollaborativeFileBytes(config), maxTotalBytes);
|
|
23
|
+
let totalBytes = 0;
|
|
24
|
+
for (const entry of candidates.slice(0, maxFiles)) {
|
|
25
|
+
if ((entry.size ?? 0) > fileLimit || totalBytes + (entry.size ?? 0) > maxTotalBytes) {
|
|
26
|
+
result.limited = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
let bytes;
|
|
30
|
+
try {
|
|
31
|
+
bytes = await fs.readFile(resolveSourcePath(config, projectId, entry.path));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.code !== "ENOENT")
|
|
35
|
+
throw error;
|
|
36
|
+
result.limited = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
totalBytes += bytes.length;
|
|
40
|
+
if (bytes.length > fileLimit || totalBytes > maxTotalBytes) {
|
|
41
|
+
result.limited = true;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!isTextContent(bytes))
|
|
45
|
+
continue;
|
|
46
|
+
const content = bytes.toString("utf8");
|
|
47
|
+
const sourceHash = createHash("sha256").update(content, "utf8").digest("hex");
|
|
48
|
+
let line = 1, lineStart = 0, nextBreak = content.indexOf("\n");
|
|
49
|
+
pattern.lastIndex = 0;
|
|
50
|
+
for (const match of content.matchAll(pattern)) {
|
|
51
|
+
if (result.matches.length >= PROJECT_SEARCH_MAX_MATCHES) {
|
|
52
|
+
result.limited = true;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
const offset = match.index;
|
|
56
|
+
while (nextBreak >= 0 && nextBreak < offset) {
|
|
57
|
+
line++;
|
|
58
|
+
lineStart = nextBreak + 1;
|
|
59
|
+
nextBreak = content.indexOf("\n", lineStart);
|
|
60
|
+
}
|
|
61
|
+
const end = nextBreak;
|
|
62
|
+
const lineEnd = end < 0 ? content.length : content[end - 1] === "\r" ? end - 1 : end;
|
|
63
|
+
const from = Math.max(lineStart, offset - 80), to = Math.min(lineEnd, offset + match[0].length + 100);
|
|
64
|
+
const prefix = from > lineStart ? "…" : "";
|
|
65
|
+
const start = prefix.length + offset - from;
|
|
66
|
+
result.matches.push({ path: entry.path, line, column: offset - lineStart + 1, sourceHash, from: offset, to: offset + match[0].length,
|
|
67
|
+
preview: prefix + content.slice(from, to) + (to < lineEnd ? "…" : ""),
|
|
68
|
+
matchStart: start, matchEnd: start + match[0].length });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
@@ -2,6 +2,9 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { requireUser } from "../auth.js";
|
|
3
3
|
import { apiError, httpError, ValidationError } from "../http.js";
|
|
4
4
|
import { MAX_CITATION_BIBTEX_BYTES } from "../limits.js";
|
|
5
|
+
import { assertCitationCollectionCapacity, citationCollectionIds, citationCollectionsForEntries, filterCitationCollection, registerCitationCollectionRoutes } from "../citationCollections.js";
|
|
6
|
+
import { comparableCitationBibtex } from "../../shared/citationContent.js";
|
|
7
|
+
import { citationInput } from "../citationInput.js";
|
|
5
8
|
const tagColors = ["red", "orange", "yellow", "green", "blue", "purple", "gray"];
|
|
6
9
|
const now = () => new Date().toISOString();
|
|
7
10
|
function escapeLikePattern(value) {
|
|
@@ -13,16 +16,18 @@ function text(value, max = 200) {
|
|
|
13
16
|
}
|
|
14
17
|
return value.trim();
|
|
15
18
|
}
|
|
16
|
-
function citationJson(row, tags = []) {
|
|
19
|
+
function citationJson(row, tags = [], collectionIds = []) {
|
|
17
20
|
return {
|
|
18
21
|
id: row.id,
|
|
19
22
|
citationKey: row.citation_key,
|
|
20
23
|
entryType: row.entry_type,
|
|
21
24
|
bibtex: row.bibtex,
|
|
25
|
+
notes: row.notes,
|
|
22
26
|
title: row.title,
|
|
23
27
|
authors: row.authors,
|
|
24
28
|
year: row.year,
|
|
25
29
|
revision: row.revision,
|
|
30
|
+
collectionIds,
|
|
26
31
|
tags: tags.map((tag) => ({ id: tag.id, name: tag.name, color: tag.color, ownerId: tag.user_id })),
|
|
27
32
|
ownerId: row.user_id,
|
|
28
33
|
ownerUsername: row.owner_username ?? null,
|
|
@@ -31,6 +36,9 @@ function citationJson(row, tags = []) {
|
|
|
31
36
|
updatedAt: row.updated_at
|
|
32
37
|
};
|
|
33
38
|
}
|
|
39
|
+
function citationDetails(db, row) {
|
|
40
|
+
return citationJson(row, citationTagsForEntries(db, [row.id]).get(row.id), citationCollectionsForEntries(db, [row.id]).get(row.id));
|
|
41
|
+
}
|
|
34
42
|
function citationTagsForEntries(db, entryIds) {
|
|
35
43
|
const result = new Map(entryIds.map((entryId) => [entryId, []]));
|
|
36
44
|
if (!entryIds.length)
|
|
@@ -71,42 +79,10 @@ function citationExpectedRevision(value) {
|
|
|
71
79
|
}
|
|
72
80
|
return Number(value);
|
|
73
81
|
}
|
|
74
|
-
function citationNullableText(value, max) {
|
|
75
|
-
if (value === undefined || value === null || value === "")
|
|
76
|
-
return null;
|
|
77
|
-
if (typeof value !== "string" || value.length > max)
|
|
78
|
-
throw new ValidationError();
|
|
79
|
-
const trimmed = value.trim();
|
|
80
|
-
return trimmed || null;
|
|
81
|
-
}
|
|
82
|
-
function citationInput(value) {
|
|
83
|
-
if (typeof value !== "object" || value === null)
|
|
84
|
-
throw new ValidationError();
|
|
85
|
-
const body = value;
|
|
86
|
-
if (typeof body.bibtex !== "string" || !body.bibtex.trim()) {
|
|
87
|
-
throw new ValidationError();
|
|
88
|
-
}
|
|
89
|
-
if (Buffer.byteLength(body.bibtex, "utf8") > MAX_CITATION_BIBTEX_BYTES) {
|
|
90
|
-
throw httpError(413, "CITATION_TOO_LARGE");
|
|
91
|
-
}
|
|
92
|
-
if (typeof body.citationKey !== "string" || !body.citationKey.trim() || body.citationKey.length > 512) {
|
|
93
|
-
throw new ValidationError();
|
|
94
|
-
}
|
|
95
|
-
if (typeof body.entryType !== "string" || !body.entryType.trim() || body.entryType.length > 128) {
|
|
96
|
-
throw new ValidationError();
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
bibtex: body.bibtex.trim(),
|
|
100
|
-
citationKey: body.citationKey.trim(),
|
|
101
|
-
entryType: body.entryType.trim(),
|
|
102
|
-
title: citationNullableText(body.title, 2048),
|
|
103
|
-
authors: citationNullableText(body.authors, 2048),
|
|
104
|
-
year: citationNullableText(body.year, 128)
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
82
|
/** Register the current user's private citation-library routes. */
|
|
108
83
|
export function registerCitationRoutes(app, context) {
|
|
109
84
|
const { db } = context;
|
|
85
|
+
registerCitationCollectionRoutes(app, db);
|
|
110
86
|
app.get("/api/citations", async (request, reply) => {
|
|
111
87
|
const user = requireUser(request, reply, db);
|
|
112
88
|
if (!user)
|
|
@@ -119,6 +95,7 @@ export function registerCitationRoutes(app, context) {
|
|
|
119
95
|
const pageSize = Math.min(200, Math.max(1, Number.isFinite(requestedPageSize) ? requestedPageSize : 60));
|
|
120
96
|
const where = ["entry.user_id = ?"];
|
|
121
97
|
const params = [user.id];
|
|
98
|
+
filterCitationCollection(db, user.id, typeof query.collection === "string" ? query.collection.trim() : "", where, params);
|
|
122
99
|
if (search) {
|
|
123
100
|
where.push(`(
|
|
124
101
|
citation_key LIKE ? ESCAPE '\\' OR entry_type LIKE ? ESCAPE '\\'
|
|
@@ -147,8 +124,9 @@ export function registerCitationRoutes(app, context) {
|
|
|
147
124
|
JOIN users owner ON owner.id = entry.user_id
|
|
148
125
|
WHERE ${where.join(" AND ")} ORDER BY entry.updated_at DESC, entry.citation_key COLLATE NOCASE LIMIT ? OFFSET ?`).all(...params);
|
|
149
126
|
const tags = citationTagsForEntries(db, rows.map((row) => row.id));
|
|
127
|
+
const collections = citationCollectionsForEntries(db, rows.map((row) => row.id));
|
|
150
128
|
return {
|
|
151
|
-
entries: rows.map((row) => citationJson(row, tags.get(row.id)
|
|
129
|
+
entries: rows.map((row) => citationJson(row, tags.get(row.id), collections.get(row.id))),
|
|
152
130
|
pagination: { page, pageSize, total, totalPages }
|
|
153
131
|
};
|
|
154
132
|
});
|
|
@@ -216,25 +194,48 @@ export function registerCitationRoutes(app, context) {
|
|
|
216
194
|
return;
|
|
217
195
|
return apiError(reply, 403, "CITATION_LIBRARY_PRIVATE");
|
|
218
196
|
});
|
|
219
|
-
app.post("/api/citations/lookup", async (request, reply) => {
|
|
197
|
+
app.post("/api/citations/lookup", { bodyLimit: MAX_CITATION_BIBTEX_BYTES * 8 }, async (request, reply) => {
|
|
220
198
|
const user = requireUser(request, reply, db);
|
|
221
199
|
if (!user)
|
|
222
200
|
return;
|
|
223
201
|
const body = request.body;
|
|
224
|
-
|
|
225
|
-
|
|
202
|
+
let contents = null;
|
|
203
|
+
let keyInput = body?.keys;
|
|
204
|
+
if (body?.entries !== undefined) {
|
|
205
|
+
if (body.keys !== undefined || !Array.isArray(body.entries) || body.entries.length > 5000)
|
|
206
|
+
throw new ValidationError();
|
|
207
|
+
contents = new Map();
|
|
208
|
+
let bytes = 0;
|
|
209
|
+
keyInput = body.entries.map((value) => {
|
|
210
|
+
if (typeof value !== "object" || !value)
|
|
211
|
+
throw new ValidationError();
|
|
212
|
+
const item = value;
|
|
213
|
+
if (typeof item.citationKey !== "string" || typeof item.bibtex !== "string" || !item.bibtex.trim())
|
|
214
|
+
throw new ValidationError();
|
|
215
|
+
bytes += Buffer.byteLength(item.bibtex, "utf8");
|
|
216
|
+
if (bytes > MAX_CITATION_BIBTEX_BYTES)
|
|
217
|
+
throw httpError(413, "CITATION_TOO_LARGE");
|
|
218
|
+
contents.set(item.citationKey.trim().toLowerCase(), comparableCitationBibtex(item.bibtex));
|
|
219
|
+
return item.citationKey;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (!Array.isArray(keyInput) || keyInput.length > 5000
|
|
223
|
+
|| keyInput.some((key) => typeof key !== "string" || !key.trim() || key.length > 512)) {
|
|
226
224
|
throw new ValidationError();
|
|
227
225
|
}
|
|
228
|
-
const keys = [...new Map(
|
|
226
|
+
const keys = [...new Map(keyInput.map((key) => [key.trim().toLowerCase(), key.trim()])).values()];
|
|
229
227
|
const matches = [];
|
|
230
228
|
for (let offset = 0; offset < keys.length; offset += 500) {
|
|
231
229
|
const chunk = keys.slice(offset, offset + 500);
|
|
232
230
|
const placeholders = chunk.map(() => "?").join(", ");
|
|
233
|
-
|
|
231
|
+
const rows = db.prepare(`SELECT id, citation_key, revision${contents ? ", bibtex" : ""} FROM citation_library_entries
|
|
234
232
|
WHERE user_id = ? AND citation_key COLLATE NOCASE IN (${placeholders})`)
|
|
235
|
-
.
|
|
233
|
+
.iterate(user.id, ...chunk);
|
|
234
|
+
for (const row of rows)
|
|
235
|
+
matches.push({ id: row.id, citationKey: row.citation_key, revision: row.revision,
|
|
236
|
+
...(contents ? { sameContent: comparableCitationBibtex(row.bibtex) === contents.get(row.citation_key.toLowerCase()) } : {}) });
|
|
236
237
|
}
|
|
237
|
-
return { matches
|
|
238
|
+
return { matches };
|
|
238
239
|
});
|
|
239
240
|
app.post("/api/citations", async (request, reply) => {
|
|
240
241
|
const user = requireUser(request, reply, db);
|
|
@@ -243,6 +244,7 @@ export function registerCitationRoutes(app, context) {
|
|
|
243
244
|
const body = request.body;
|
|
244
245
|
const citation = citationInput(body);
|
|
245
246
|
const tagIds = citationTagIds(db, user.id, body?.tagIds);
|
|
247
|
+
const collectionIds = citationCollectionIds(db, user.id, body?.collectionIds);
|
|
246
248
|
const overwrite = body?.overwrite === true;
|
|
247
249
|
const existing = db.prepare("SELECT id, revision FROM citation_library_entries WHERE user_id = ? AND citation_key = ? COLLATE NOCASE")
|
|
248
250
|
.get(user.id, citation.citationKey);
|
|
@@ -255,30 +257,34 @@ export function registerCitationRoutes(app, context) {
|
|
|
255
257
|
const id = existing?.id ?? randomUUID();
|
|
256
258
|
const timestamp = now();
|
|
257
259
|
db.transaction(() => {
|
|
260
|
+
assertCitationCollectionCapacity(db, user.id, id, collectionIds ?? []);
|
|
258
261
|
if (existing) {
|
|
259
262
|
const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
|
|
260
|
-
title = ?, authors = ?, year = ?, revision = revision + 1, updated_at = ?
|
|
263
|
+
title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
|
|
261
264
|
WHERE id = ? AND user_id = ? AND revision = ?`)
|
|
262
|
-
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, timestamp, id, user.id, expectedRevision);
|
|
265
|
+
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, timestamp, id, user.id, expectedRevision);
|
|
263
266
|
if (!result.changes)
|
|
264
267
|
throw httpError(409, "CITATION_CONFLICT");
|
|
265
268
|
}
|
|
266
269
|
else {
|
|
267
270
|
db.prepare(`INSERT INTO citation_library_entries
|
|
268
|
-
(id, user_id, citation_key, entry_type, bibtex, title, authors, year, revision, created_at, updated_at)
|
|
269
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
|
|
270
|
-
.run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, timestamp, timestamp);
|
|
271
|
+
(id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
|
|
272
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
|
|
273
|
+
.run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? "", timestamp, timestamp);
|
|
271
274
|
}
|
|
272
275
|
if (tagIds !== null) {
|
|
273
276
|
db.prepare("DELETE FROM citation_library_entry_tags WHERE entry_id = ?").run(id);
|
|
274
277
|
for (const tagId of tagIds)
|
|
275
278
|
db.prepare("INSERT INTO citation_library_entry_tags (entry_id, tag_id, created_at) VALUES (?, ?, ?)").run(id, tagId, timestamp);
|
|
276
279
|
}
|
|
280
|
+
// Saving from a project's .bib adds the chosen folder without removing
|
|
281
|
+
// other placements of an already-saved reference.
|
|
282
|
+
for (const collectionId of collectionIds ?? [])
|
|
283
|
+
db.prepare("INSERT OR IGNORE INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)").run(id, collectionId);
|
|
277
284
|
})();
|
|
278
285
|
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
279
286
|
.get(id, user.id);
|
|
280
|
-
|
|
281
|
-
return reply.code(existing ? 200 : 201).send({ entry: citationJson(row, tags.get(id) ?? []), updated: Boolean(existing) });
|
|
287
|
+
return reply.code(existing ? 200 : 201).send({ entry: citationDetails(db, row), updated: Boolean(existing) });
|
|
282
288
|
});
|
|
283
289
|
app.patch("/api/citations/:citationId/tags", async (request, reply) => {
|
|
284
290
|
const user = requireUser(request, reply, db);
|
|
@@ -310,8 +316,32 @@ export function registerCitationRoutes(app, context) {
|
|
|
310
316
|
})();
|
|
311
317
|
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
312
318
|
.get(citationId, user.id);
|
|
313
|
-
|
|
314
|
-
|
|
319
|
+
return { entry: citationDetails(db, row) };
|
|
320
|
+
});
|
|
321
|
+
app.patch("/api/citations/:citationId/collections", async (request, reply) => {
|
|
322
|
+
const user = requireUser(request, reply, db);
|
|
323
|
+
if (!user)
|
|
324
|
+
return;
|
|
325
|
+
const { citationId } = request.params;
|
|
326
|
+
if (!db.prepare("SELECT id FROM citation_library_entries WHERE id = ? AND user_id = ?").get(citationId, user.id))
|
|
327
|
+
throw httpError(404, "CITATION_NOT_FOUND");
|
|
328
|
+
const body = request.body;
|
|
329
|
+
const collectionIds = citationCollectionIds(db, user.id, body?.collectionIds);
|
|
330
|
+
if (collectionIds === null)
|
|
331
|
+
throw new ValidationError();
|
|
332
|
+
const revision = citationExpectedRevision(body?.expectedRevision);
|
|
333
|
+
db.transaction(() => {
|
|
334
|
+
const result = db.prepare("UPDATE citation_library_entries SET revision = revision + 1, updated_at = ? WHERE id = ? AND user_id = ? AND revision = ?").run(now(), citationId, user.id, revision);
|
|
335
|
+
if (!result.changes)
|
|
336
|
+
throw httpError(409, "CITATION_CONFLICT");
|
|
337
|
+
assertCitationCollectionCapacity(db, user.id, citationId, collectionIds);
|
|
338
|
+
db.prepare("DELETE FROM citation_library_entry_collections WHERE entry_id = ?").run(citationId);
|
|
339
|
+
const insert = db.prepare("INSERT INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)");
|
|
340
|
+
for (const id of collectionIds)
|
|
341
|
+
insert.run(citationId, id);
|
|
342
|
+
})();
|
|
343
|
+
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?").get(citationId, user.id);
|
|
344
|
+
return { entry: citationDetails(db, row) };
|
|
315
345
|
});
|
|
316
346
|
app.patch("/api/citations/:citationId", async (request, reply) => {
|
|
317
347
|
const user = requireUser(request, reply, db);
|
|
@@ -330,15 +360,14 @@ export function registerCitationRoutes(app, context) {
|
|
|
330
360
|
if (duplicate)
|
|
331
361
|
return apiError(reply, 409, "CITATION_KEY_EXISTS");
|
|
332
362
|
const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
|
|
333
|
-
title = ?, authors = ?, year = ?, revision = revision + 1, updated_at = ?
|
|
363
|
+
title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
|
|
334
364
|
WHERE id = ? AND user_id = ? AND revision = ?`)
|
|
335
|
-
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, now(), citationId, user.id, expectedRevision);
|
|
365
|
+
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, now(), citationId, user.id, expectedRevision);
|
|
336
366
|
if (!result.changes)
|
|
337
367
|
return apiError(reply, 409, "CITATION_CONFLICT");
|
|
338
368
|
const updated = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
339
369
|
.get(citationId, user.id);
|
|
340
|
-
|
|
341
|
-
return { entry: citationJson(updated, tags.get(citationId) ?? []) };
|
|
370
|
+
return { entry: citationDetails(db, updated) };
|
|
342
371
|
});
|
|
343
372
|
app.delete("/api/citations/:citationId", async (request, reply) => {
|
|
344
373
|
const user = requireUser(request, reply, db);
|