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,74 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { CITATION_FOLDER_FORMAT, CITATION_FOLDER_VERSION, MAX_CITATION_FOLDER_BYTES, MAX_CITATION_FOLDER_ENTRIES } from "../shared/citationTransfer.js";
|
|
3
|
+
import { requireUser } from "./auth.js";
|
|
4
|
+
import { citationInput } from "./citationInput.js";
|
|
5
|
+
import { httpError } from "./http.js";
|
|
6
|
+
/** Export only portable content, never tags, owner identifiers or internal folder IDs. */
|
|
7
|
+
export function exportCitationFolder(db, userId, folder) {
|
|
8
|
+
const bundle = { format: CITATION_FOLDER_FORMAT, version: CITATION_FOLDER_VERSION, entries: [] };
|
|
9
|
+
let bytes = Buffer.byteLength(JSON.stringify(bundle), "utf8");
|
|
10
|
+
const rows = db.prepare(`SELECT entry.citation_key AS citationKey, entry.entry_type AS entryType,
|
|
11
|
+
entry.bibtex, entry.title, entry.authors, entry.year, entry.notes
|
|
12
|
+
FROM citation_library_entries entry JOIN citation_library_entry_collections link ON link.entry_id = entry.id
|
|
13
|
+
WHERE entry.user_id = ? AND link.collection_id = ? ORDER BY entry.citation_key COLLATE NOCASE, entry.id`)
|
|
14
|
+
.iterate(userId, folder.id);
|
|
15
|
+
for (const row of rows) {
|
|
16
|
+
bytes += Buffer.byteLength(JSON.stringify(row), "utf8") + (bundle.entries.length ? 1 : 0);
|
|
17
|
+
if (bytes > MAX_CITATION_FOLDER_BYTES || bundle.entries.length >= MAX_CITATION_FOLDER_ENTRIES)
|
|
18
|
+
throw httpError(413, "CITATION_FOLDER_TOO_LARGE");
|
|
19
|
+
bundle.entries.push(row);
|
|
20
|
+
}
|
|
21
|
+
return JSON.stringify(bundle);
|
|
22
|
+
}
|
|
23
|
+
export function registerCitationFolderImport(app, db) {
|
|
24
|
+
app.post("/api/citations/collections/import", { bodyLimit: MAX_CITATION_FOLDER_BYTES }, async (request, reply) => {
|
|
25
|
+
const user = requireUser(request, reply, db);
|
|
26
|
+
if (!user)
|
|
27
|
+
return;
|
|
28
|
+
const body = request.body;
|
|
29
|
+
if (!body || body.format !== CITATION_FOLDER_FORMAT || body.version !== CITATION_FOLDER_VERSION
|
|
30
|
+
|| typeof body.name !== "string" || !body.name.trim() || body.name.trim().length > 80
|
|
31
|
+
|| !Array.isArray(body.entries))
|
|
32
|
+
throw httpError(400, "CITATION_FOLDER_INVALID");
|
|
33
|
+
if (body.entries.length > MAX_CITATION_FOLDER_ENTRIES)
|
|
34
|
+
throw httpError(413, "CITATION_FOLDER_TOO_LARGE");
|
|
35
|
+
// Validate the entire import before opening a write transaction. Repeated
|
|
36
|
+
// keys in the bundle follow the same last-entry-wins rule as existing keys.
|
|
37
|
+
const entries = new Map();
|
|
38
|
+
for (const value of body.entries) {
|
|
39
|
+
if (!value || typeof value.notes !== "string")
|
|
40
|
+
throw httpError(400, "CITATION_FOLDER_INVALID");
|
|
41
|
+
const entry = citationInput(value);
|
|
42
|
+
entries.set(entry.citationKey.toLowerCase(), entry);
|
|
43
|
+
}
|
|
44
|
+
const timestamp = new Date().toISOString();
|
|
45
|
+
const id = randomUUID();
|
|
46
|
+
const baseName = body.name.trim();
|
|
47
|
+
const name = db.transaction(() => {
|
|
48
|
+
let candidate = baseName, suffix = 0;
|
|
49
|
+
const exists = db.prepare("SELECT 1 FROM citation_library_collections WHERE user_id = ? AND name = ? COLLATE NOCASE");
|
|
50
|
+
while (exists.get(user.id, candidate)) {
|
|
51
|
+
const ending = `-${++suffix}`;
|
|
52
|
+
candidate = `${baseName.slice(0, 80 - ending.length)}${ending}`;
|
|
53
|
+
}
|
|
54
|
+
db.prepare("INSERT INTO citation_library_collections (id, user_id, name, created_at) VALUES (?, ?, ?, ?)").run(id, user.id, candidate, timestamp);
|
|
55
|
+
const upsert = db.prepare(`INSERT INTO citation_library_entries
|
|
56
|
+
(id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
|
|
57
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
|
58
|
+
ON CONFLICT (user_id, citation_key) DO UPDATE SET citation_key = excluded.citation_key,
|
|
59
|
+
entry_type = excluded.entry_type, bibtex = excluded.bibtex, title = excluded.title,
|
|
60
|
+
authors = excluded.authors, year = excluded.year, notes = excluded.notes,
|
|
61
|
+
revision = citation_library_entries.revision + 1, updated_at = excluded.updated_at
|
|
62
|
+
RETURNING id`);
|
|
63
|
+
const place = db.prepare("INSERT INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)");
|
|
64
|
+
for (const entry of entries.values()) {
|
|
65
|
+
const saved = upsert.get(randomUUID(), user.id, entry.citationKey, entry.entryType, entry.bibtex, entry.title, entry.authors, entry.year, entry.notes, timestamp, timestamp);
|
|
66
|
+
// Existing placements and tags are retained. Imported content replaces
|
|
67
|
+
// the user's shared entry, so all its placements see the updated notes.
|
|
68
|
+
place.run(saved.id, id);
|
|
69
|
+
}
|
|
70
|
+
return candidate;
|
|
71
|
+
})();
|
|
72
|
+
return reply.code(201).send({ collection: { id, name, entryCount: entries.size }, imported: entries.size });
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MAX_CITATION_NOTES_BYTES } from "../shared/citationTransfer.js";
|
|
2
|
+
import { httpError, ValidationError } from "./http.js";
|
|
3
|
+
import { MAX_CITATION_BIBTEX_BYTES } from "./limits.js";
|
|
4
|
+
function nullableText(value, max) {
|
|
5
|
+
if (value === undefined || value === null || value === "")
|
|
6
|
+
return null;
|
|
7
|
+
if (typeof value !== "string" || value.length > max)
|
|
8
|
+
throw new ValidationError();
|
|
9
|
+
return value.trim() || null;
|
|
10
|
+
}
|
|
11
|
+
export function citationInput(value) {
|
|
12
|
+
if (typeof value !== "object" || value === null)
|
|
13
|
+
throw new ValidationError();
|
|
14
|
+
const body = value;
|
|
15
|
+
if (typeof body.bibtex !== "string" || !body.bibtex.trim())
|
|
16
|
+
throw new ValidationError();
|
|
17
|
+
if (Buffer.byteLength(body.bibtex, "utf8") > MAX_CITATION_BIBTEX_BYTES)
|
|
18
|
+
throw httpError(413, "CITATION_TOO_LARGE");
|
|
19
|
+
if (typeof body.citationKey !== "string" || !body.citationKey.trim() || body.citationKey.length > 512)
|
|
20
|
+
throw new ValidationError();
|
|
21
|
+
if (typeof body.entryType !== "string" || !body.entryType.trim() || body.entryType.length > 128)
|
|
22
|
+
throw new ValidationError();
|
|
23
|
+
if (body.notes !== undefined) {
|
|
24
|
+
if (typeof body.notes !== "string")
|
|
25
|
+
throw new ValidationError();
|
|
26
|
+
if (Buffer.byteLength(body.notes, "utf8") > MAX_CITATION_NOTES_BYTES)
|
|
27
|
+
throw httpError(413, "CITATION_NOTES_TOO_LARGE");
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
bibtex: body.bibtex.trim(), citationKey: body.citationKey.trim(), entryType: body.entryType.trim(),
|
|
31
|
+
title: nullableText(body.title, 2048), authors: nullableText(body.authors, 2048), year: nullableText(body.year, 128),
|
|
32
|
+
notes: body.notes
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -12,6 +12,8 @@ import { Awareness, applyAwarenessUpdate, encodeAwarenessUpdate, modifyAwareness
|
|
|
12
12
|
import { listProjectFilesAsync, outputRoot, resolveSourcePath, safeRelativePath, sourceRoot } from "./files.js";
|
|
13
13
|
import { collaborationProjectAccessFromStatement, canEdit, prepareCollaborationProjectAccessStatement } from "./projects.js";
|
|
14
14
|
import { reanchorFileComments } from "./anchors.js";
|
|
15
|
+
import { finishSuggestionApplications, hasPendingSuggestionApplication, prepareSuggestionApplication, recoverSuggestionApplications } from "./commentSuggestions.js";
|
|
16
|
+
import { httpError, SourceFlushError } from "./http.js";
|
|
15
17
|
import { createEditHistorySpan, hashText } from "./editHistory.js";
|
|
16
18
|
import { isEditableTextFile, isTextContent, MAX_TEXT_EDITOR_BYTES } from "../shared/fileTypes.js";
|
|
17
19
|
import { COLLABORATION_PROTOCOL_VERSION, CollaborationMessageType, isCollaborationCleanMode, isCollaborationCompileStatus } from "../shared/collaborationProtocol.js";
|
|
@@ -137,13 +139,79 @@ export class CollaborationService {
|
|
|
137
139
|
}
|
|
138
140
|
/** Wait for an in-flight cold-room load before reading or replacing sources. */
|
|
139
141
|
async waitForReady(projectId) {
|
|
140
|
-
|
|
142
|
+
let initialization = this.roomInitializations.get(projectId);
|
|
143
|
+
// After a crash the filesystem alone is not authoritative while an
|
|
144
|
+
// accepted source update is journaled. Recover it before a cold HTTP
|
|
145
|
+
// write/restore can replace the source tree or discard its CRDT base.
|
|
146
|
+
if (!initialization && !this.rooms.has(projectId) && hasPendingSuggestionApplication(this.db, projectId)) {
|
|
147
|
+
initialization = this.initializeRoom(projectId, this.projectGeneration(projectId));
|
|
148
|
+
}
|
|
141
149
|
if (!initialization)
|
|
142
150
|
return;
|
|
143
151
|
try {
|
|
144
|
-
await initialization;
|
|
152
|
+
this.scheduleRoomCleanup(await initialization);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (hasPendingSuggestionApplication(this.db, projectId))
|
|
156
|
+
throw error;
|
|
157
|
+
// Without a pending application, source files remain authoritative.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async prepareSourceEditRoom(projectId) {
|
|
161
|
+
if (this.closed || this.isMaintaining(projectId))
|
|
162
|
+
throw httpError(409, "PROJECT_BUSY");
|
|
163
|
+
const room = await this.initializeRoom(projectId, this.projectGeneration(projectId));
|
|
164
|
+
// Revalidation may reject the HTTP request after hydration. Such a room
|
|
165
|
+
// still needs idle eviction even if no browser ever connects to it.
|
|
166
|
+
this.scheduleRoomCleanup(room);
|
|
167
|
+
}
|
|
168
|
+
/** Exact HTTP range edits share the normal Yjs attribution, anchors and history pipeline. */
|
|
169
|
+
applySourceEdits(projectId, files, userId) {
|
|
170
|
+
const room = this.rooms.get(projectId);
|
|
171
|
+
if (!room || room.maintenanceReason)
|
|
172
|
+
throw httpError(409, "PROJECT_BUSY");
|
|
173
|
+
// Check every file before changing any of them. The caller holds runWrite,
|
|
174
|
+
// and this synchronous block cannot interleave incoming WebSocket updates.
|
|
175
|
+
for (const file of files) {
|
|
176
|
+
if (this.activeFormatLease(room, file.path))
|
|
177
|
+
throw httpError(409, "PROJECT_BUSY");
|
|
178
|
+
if (!room.allowedPaths.has(file.path) || this.trackedText(room, file.path).toString() !== file.before) {
|
|
179
|
+
throw httpError(409, "SEARCH_SOURCE_CHANGED");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
room.doc.transact(() => {
|
|
183
|
+
for (const file of files) {
|
|
184
|
+
const text = this.trackedText(room, file.path);
|
|
185
|
+
for (const edit of [...file.edits].reverse()) {
|
|
186
|
+
text.delete(edit.from, edit.to - edit.from);
|
|
187
|
+
if (edit.insert)
|
|
188
|
+
text.insert(edit.from, edit.insert);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, { externalUserId: userId, exact: true });
|
|
192
|
+
const receipt = this.flushRoom(room);
|
|
193
|
+
for (const file of files)
|
|
194
|
+
this.bumpFiles(room, { kind: "update", path: file.path });
|
|
195
|
+
if (!receipt.ok)
|
|
196
|
+
throw new SourceFlushError(receipt.failedPaths);
|
|
197
|
+
}
|
|
198
|
+
/** A source-range operation, not an HTTP whole-file replacement. Called inside runWrite. */
|
|
199
|
+
applyCommentSuggestion(projectId, filePath, commentId, userId) {
|
|
200
|
+
const room = this.rooms.get(projectId);
|
|
201
|
+
if (!room || room.maintenanceReason || this.activeFormatLease(room, filePath))
|
|
202
|
+
throw httpError(409, "PROJECT_BUSY");
|
|
203
|
+
try {
|
|
204
|
+
// The journal update refers to this durable CRDT base, including a cold room's item IDs.
|
|
205
|
+
this.persistRoomState(room);
|
|
206
|
+
const update = prepareSuggestionApplication(this.db, projectId, commentId, room.doc, userId, maxCollaborativeFileBytes(this.config));
|
|
207
|
+
Y.applyUpdate(room.doc, update, { externalUserId: userId, exact: true });
|
|
208
|
+
const receipt = this.flushRoom(room);
|
|
209
|
+
if (!receipt.ok)
|
|
210
|
+
throw new SourceFlushError(receipt.failedPaths);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
this.scheduleRoomCleanup(room);
|
|
145
214
|
}
|
|
146
|
-
catch { /* Source files remain authoritative if recovery fails. */ }
|
|
147
215
|
}
|
|
148
216
|
flushProject(projectId) {
|
|
149
217
|
const room = this.rooms.get(projectId);
|
|
@@ -624,16 +692,6 @@ export class CollaborationService {
|
|
|
624
692
|
}, META_ORIGIN);
|
|
625
693
|
return changed;
|
|
626
694
|
}
|
|
627
|
-
closeProject(projectId) {
|
|
628
|
-
this.invalidateProject(projectId);
|
|
629
|
-
this.snapshotBarriers.delete(projectId);
|
|
630
|
-
const room = this.rooms.get(projectId);
|
|
631
|
-
if (!room)
|
|
632
|
-
return;
|
|
633
|
-
for (const connection of room.connections)
|
|
634
|
-
connection.socket.close(1008, "Project closed");
|
|
635
|
-
this.destroyRoom(room);
|
|
636
|
-
}
|
|
637
695
|
resetProject(projectId) {
|
|
638
696
|
this.invalidateProject(projectId);
|
|
639
697
|
this.snapshotBarriers.delete(projectId);
|
|
@@ -703,9 +761,10 @@ export class CollaborationService {
|
|
|
703
761
|
doc = new Y.Doc();
|
|
704
762
|
}
|
|
705
763
|
}
|
|
764
|
+
const suggestionsRecovered = recoverSuggestionApplications(this.db, projectId, doc, recoveredState);
|
|
706
765
|
const epoch = await collaborationEpochAsync(this.config, projectId, recoveredState);
|
|
707
766
|
const files = await this.readCollaborativeFiles(projectId);
|
|
708
|
-
return { doc, recoveredState, epoch, files };
|
|
767
|
+
return { doc, recoveredState, epoch, files, suggestionsRecovered };
|
|
709
768
|
}
|
|
710
769
|
catch (error) {
|
|
711
770
|
doc.destroy();
|
|
@@ -887,7 +946,7 @@ export class CollaborationService {
|
|
|
887
946
|
try {
|
|
888
947
|
// Persist a corrected state even when an oversized recovered document was
|
|
889
948
|
// reverted to the source file and no source write remains dirty.
|
|
890
|
-
if (recoveredDirty || rejectedRecoveredPaths.length > 0)
|
|
949
|
+
if (recoveredDirty || rejectedRecoveredPaths.length > 0 || bootstrap.suggestionsRecovered)
|
|
891
950
|
this.flushRoom(room);
|
|
892
951
|
else if (recoveredMetadataChanged)
|
|
893
952
|
this.scheduleStateSave(room);
|
|
@@ -989,7 +1048,7 @@ export class CollaborationService {
|
|
|
989
1048
|
}
|
|
990
1049
|
else if (delta.delete || typeof delta.insert === "string") {
|
|
991
1050
|
pending ??= { from: offset, to: offset, insert: "", insertLength: 0,
|
|
992
|
-
inferred: isExternalOrigin(transaction.origin) };
|
|
1051
|
+
inferred: isExternalOrigin(transaction.origin) && transaction.origin.exact !== true };
|
|
993
1052
|
if (delta.delete) {
|
|
994
1053
|
offset += delta.delete;
|
|
995
1054
|
pending.to = offset;
|
|
@@ -1585,6 +1644,8 @@ export class CollaborationService {
|
|
|
1585
1644
|
catch { /* Source durability must not depend on optional history bookkeeping. */ }
|
|
1586
1645
|
}
|
|
1587
1646
|
const ok = failedPaths.length === 0 && !roomHasPendingChanges(room);
|
|
1647
|
+
if (ok && finishSuggestionApplications(this.db, room.projectId, room.doc))
|
|
1648
|
+
this.signalComments(room.projectId);
|
|
1588
1649
|
if (changed)
|
|
1589
1650
|
room.persistedRevision += 1;
|
|
1590
1651
|
if (ok) {
|
|
@@ -57,6 +57,10 @@ export function createCommentMentions(db, input) {
|
|
|
57
57
|
ON CONFLICT DO UPDATE SET
|
|
58
58
|
mentioned_by_user_id = excluded.mentioned_by_user_id,
|
|
59
59
|
created_at = excluded.created_at,
|
|
60
|
+
kind = CASE WHEN excluded.reply_id IS NULL AND EXISTS (
|
|
61
|
+
SELECT 1 FROM comment_suggestions suggestion WHERE suggestion.comment_id = excluded.comment_id
|
|
62
|
+
AND suggestion.status = 'pending' AND suggestion.reviewer_id = excluded.mentioned_user_id
|
|
63
|
+
) THEN 'review' ELSE 'mention' END,
|
|
60
64
|
read_at = NULL,
|
|
61
65
|
read_reason = NULL`);
|
|
62
66
|
for (const recipient of recipients) {
|
|
@@ -80,6 +84,7 @@ export function unreadMentionCountsForProjects(db, projectIds, userId) {
|
|
|
80
84
|
}
|
|
81
85
|
function mentionFromRow(row) {
|
|
82
86
|
return {
|
|
87
|
+
kind: row.kind,
|
|
83
88
|
id: row.id,
|
|
84
89
|
projectId: row.project_id,
|
|
85
90
|
commentId: row.comment_id,
|
|
@@ -92,7 +97,7 @@ function mentionFromRow(row) {
|
|
|
92
97
|
readReason: row.read_reason
|
|
93
98
|
};
|
|
94
99
|
}
|
|
95
|
-
const mentionSelect = `SELECT mention.id, mention.project_id, mention.comment_id, mention.reply_id,
|
|
100
|
+
const mentionSelect = `SELECT mention.kind, mention.id, mention.project_id, mention.comment_id, mention.reply_id,
|
|
96
101
|
comment.file_path, comment.content AS comment_content, reply.content AS reply_content,
|
|
97
102
|
comment.resolved, mention.created_at, mention.read_at, mention.read_reason
|
|
98
103
|
FROM comment_mentions mention
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { createSourceAnchor, offsetToLine } from "./anchors.js";
|
|
3
|
+
import { httpError } from "./http.js";
|
|
4
|
+
import { MAX_SUGGESTION_LENGTH } from "../shared/comments.js";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
export function attachSuggestion(db, projectId, commentId, authorId, original, input) {
|
|
7
|
+
if (!input || typeof input !== "object")
|
|
8
|
+
throw httpError(400, "SUGGESTION_INVALID");
|
|
9
|
+
const { replacementText, reviewerId } = input;
|
|
10
|
+
validateSuggestionReplacement(original, replacementText);
|
|
11
|
+
if (reviewerId === authorId)
|
|
12
|
+
throw httpError(400, "SUGGESTION_SELF_REVIEW");
|
|
13
|
+
if (typeof reviewerId !== "string" || !suggestionReviewers(db, projectId, authorId).some((user) => user.id === reviewerId))
|
|
14
|
+
throw httpError(400, "SUGGESTION_REVIEWER_INVALID");
|
|
15
|
+
if (suggestionRow(db, projectId, commentId))
|
|
16
|
+
throw httpError(409, "SUGGESTION_EXISTS");
|
|
17
|
+
db.prepare("INSERT INTO comment_suggestions (comment_id, original_text, replacement_text, reviewer_id) VALUES (?, ?, ?, ?)")
|
|
18
|
+
.run(commentId, original, replacementText, reviewerId);
|
|
19
|
+
requestSuggestionReview(db, projectId, commentId, reviewerId, authorId, new Date().toISOString());
|
|
20
|
+
}
|
|
21
|
+
export function validateSuggestionReplacement(original, replacement) {
|
|
22
|
+
if (!original || original.length > MAX_SUGGESTION_LENGTH || typeof replacement !== "string"
|
|
23
|
+
|| replacement.length > MAX_SUGGESTION_LENGTH || replacement === original || replacement.includes("\0"))
|
|
24
|
+
throw httpError(400, "SUGGESTION_INVALID");
|
|
25
|
+
}
|
|
26
|
+
export function suggestionReviewers(db, projectId, authorId) {
|
|
27
|
+
return db.prepare(`SELECT u.id, u.username, u.display_name AS displayName FROM users u
|
|
28
|
+
JOIN projects p ON p.id = ? LEFT JOIN project_members m ON m.project_id = p.id AND m.user_id = u.id
|
|
29
|
+
WHERE u.disabled = 0 AND (u.id = p.owner_id OR m.permission = 'edit') AND (? IS NULL OR u.id <> ?)
|
|
30
|
+
ORDER BY u.display_name COLLATE NOCASE, u.username COLLATE NOCASE`).all(projectId, authorId ?? null, authorId ?? null);
|
|
31
|
+
}
|
|
32
|
+
export function requestSuggestionReview(db, projectId, commentId, reviewerId, authorId, at) {
|
|
33
|
+
if (reviewerId === authorId)
|
|
34
|
+
return;
|
|
35
|
+
db.prepare(`INSERT INTO comment_mentions (id, project_id, comment_id, mentioned_user_id, mentioned_by_user_id, created_at, kind)
|
|
36
|
+
VALUES (?, ?, ?, ?, ?, ?, 'review') ON CONFLICT DO UPDATE SET kind = 'review', read_at = NULL,
|
|
37
|
+
read_reason = NULL, created_at = excluded.created_at, mentioned_by_user_id = excluded.mentioned_by_user_id`)
|
|
38
|
+
.run(randomUUID(), projectId, commentId, reviewerId, authorId, at);
|
|
39
|
+
}
|
|
40
|
+
export function clearSuggestionReview(db, commentId, at) {
|
|
41
|
+
db.prepare("UPDATE comment_mentions SET read_at = ?, read_reason = 'manual' WHERE comment_id = ? AND kind = 'review' AND read_at IS NULL").run(at, commentId);
|
|
42
|
+
}
|
|
43
|
+
export function suggestionRow(db, projectId, commentId) {
|
|
44
|
+
return db.prepare(`SELECT s.*, c.author_id, c.file_path, c.start_offset, c.end_offset, c.orphaned FROM comment_suggestions s
|
|
45
|
+
JOIN comments c ON c.id = s.comment_id WHERE c.project_id = ? AND c.id = ?`).get(projectId, commentId);
|
|
46
|
+
}
|
|
47
|
+
export function hasPendingSuggestionApplication(db, projectId) {
|
|
48
|
+
return !!db.prepare(`SELECT 1 FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
|
|
49
|
+
WHERE c.project_id = ? AND s.apply_update IS NOT NULL LIMIT 1`).get(projectId);
|
|
50
|
+
}
|
|
51
|
+
/** One query per discussion list, not one query per thread. */
|
|
52
|
+
export function suggestionsForProject(db, projectId, sources) {
|
|
53
|
+
const reviewers = new Set(suggestionReviewers(db, projectId).map((user) => user.id));
|
|
54
|
+
const rows = db.prepare(`SELECT s.*, c.author_id, c.file_path, c.start_offset, c.end_offset, c.orphaned,
|
|
55
|
+
reviewer.username AS reviewerUsername, reviewer.display_name AS reviewerDisplayName,
|
|
56
|
+
decider.username AS decidedByUsername, decider.display_name AS decidedByDisplayName
|
|
57
|
+
FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
|
|
58
|
+
LEFT JOIN users reviewer ON reviewer.id = s.reviewer_id LEFT JOIN users decider ON decider.id = s.decided_by
|
|
59
|
+
WHERE c.project_id = ?`).all(projectId);
|
|
60
|
+
return new Map(rows.map((row) => [row.comment_id, {
|
|
61
|
+
originalText: row.original_text, replacementText: row.replacement_text, reviewerId: row.reviewer_id,
|
|
62
|
+
reviewerUsername: row.reviewerUsername, reviewerDisplayName: row.reviewerDisplayName,
|
|
63
|
+
reviewerAvailable: row.reviewer_id !== null && row.reviewer_id !== row.author_id && reviewers.has(row.reviewer_id), status: row.status,
|
|
64
|
+
applicable: !row.orphaned && sources.get(row.file_path)?.slice(row.start_offset, row.end_offset) === row.original_text,
|
|
65
|
+
applying: row.apply_update !== null, decidedById: row.decided_by, decidedAt: row.decided_at,
|
|
66
|
+
decidedByUsername: row.decidedByUsername, decidedByDisplayName: row.decidedByDisplayName
|
|
67
|
+
}]));
|
|
68
|
+
}
|
|
69
|
+
/** Journal a CRDT update BEFORE applying it. Its item IDs make every replay idempotent. */
|
|
70
|
+
export function prepareSuggestionApplication(db, projectId, commentId, doc, userId, maxBytes) {
|
|
71
|
+
const row = suggestionRow(db, projectId, commentId);
|
|
72
|
+
if (!row)
|
|
73
|
+
throw httpError(404, "COMMENT_NOT_FOUND");
|
|
74
|
+
if (row.apply_update)
|
|
75
|
+
return row.apply_update;
|
|
76
|
+
if (row.status !== "pending")
|
|
77
|
+
throw httpError(409, "SUGGESTION_DECIDED");
|
|
78
|
+
const name = `source:${row.file_path}`;
|
|
79
|
+
const text = doc.getText(name);
|
|
80
|
+
if (row.orphaned || row.end_offset <= row.start_offset || text.toString().slice(row.start_offset, row.end_offset) !== row.original_text) {
|
|
81
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
82
|
+
}
|
|
83
|
+
const source = text.toString();
|
|
84
|
+
if (Buffer.byteLength(source.slice(0, row.start_offset) + row.replacement_text + source.slice(row.end_offset), "utf8") > maxBytes) {
|
|
85
|
+
throw httpError(413, "FILE_TOO_LARGE", { path: row.file_path, size: Math.floor(maxBytes / 1024 / 1024) });
|
|
86
|
+
}
|
|
87
|
+
const copy = new Y.Doc();
|
|
88
|
+
try {
|
|
89
|
+
Y.applyUpdate(copy, Y.encodeStateAsUpdate(doc));
|
|
90
|
+
const vector = Y.encodeStateVector(copy);
|
|
91
|
+
const target = copy.getText(name);
|
|
92
|
+
copy.transact(() => {
|
|
93
|
+
target.delete(row.start_offset, row.end_offset - row.start_offset);
|
|
94
|
+
target.insert(row.start_offset, row.replacement_text);
|
|
95
|
+
});
|
|
96
|
+
const update = Y.encodeStateAsUpdate(copy, vector);
|
|
97
|
+
const range = JSON.stringify([
|
|
98
|
+
Y.relativePositionToJSON(Y.createRelativePositionFromTypeIndex(target, row.start_offset, 0)),
|
|
99
|
+
Y.relativePositionToJSON(Y.createRelativePositionFromTypeIndex(target, row.start_offset + row.replacement_text.length, -1))
|
|
100
|
+
]);
|
|
101
|
+
db.prepare("UPDATE comment_suggestions SET apply_update = ?, apply_range = ?, decided_by = ?, decided_at = ? WHERE comment_id = ?")
|
|
102
|
+
.run(Buffer.from(update), range, userId, new Date().toISOString(), commentId);
|
|
103
|
+
return update;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
copy.destroy();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Called while hydrating a room, before accepting any client edits. */
|
|
110
|
+
export function recoverSuggestionApplications(db, projectId, doc, recoveredState) {
|
|
111
|
+
const rows = db.prepare(`SELECT s.apply_update FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
|
|
112
|
+
WHERE c.project_id = ? AND s.apply_update IS NOT NULL`).all(projectId);
|
|
113
|
+
if (rows.length && !recoveredState)
|
|
114
|
+
throw httpError(409, "SUGGESTION_RECOVERY_FAILED");
|
|
115
|
+
for (const row of rows)
|
|
116
|
+
Y.applyUpdate(doc, row.apply_update);
|
|
117
|
+
return rows.length > 0;
|
|
118
|
+
}
|
|
119
|
+
/** Source, Yjs state and anchors must be durable before marking an application accepted. */
|
|
120
|
+
export function finishSuggestionApplications(db, projectId, doc) {
|
|
121
|
+
const rows = db.prepare(`SELECT s.*, c.file_path FROM comment_suggestions s JOIN comments c ON c.id = s.comment_id
|
|
122
|
+
WHERE c.project_id = ? AND s.apply_update IS NOT NULL`).all(projectId);
|
|
123
|
+
if (!rows.length)
|
|
124
|
+
return false;
|
|
125
|
+
db.transaction(() => {
|
|
126
|
+
for (const row of rows) {
|
|
127
|
+
const positions = JSON.parse(row.apply_range);
|
|
128
|
+
const start = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(positions[0]), doc);
|
|
129
|
+
const end = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(positions[1]), doc);
|
|
130
|
+
const text = doc.getText(`source:${row.file_path}`);
|
|
131
|
+
if (start?.type === text && end?.type === text) {
|
|
132
|
+
const source = text.toString();
|
|
133
|
+
const anchor = createSourceAnchor(source, start.index, end.index);
|
|
134
|
+
db.prepare(`UPDATE comments SET selected_text = ?, start_offset = ?, end_offset = ?, context_before = ?, context_after = ?,
|
|
135
|
+
orphaned = 0, start_line = ?, end_line = ?, updated_at = ? WHERE id = ?`)
|
|
136
|
+
.run(anchor.selectedText, anchor.startOffset, anchor.endOffset, anchor.contextBefore, anchor.contextAfter, offsetToLine(source, anchor.startOffset), offsetToLine(source, anchor.endOffset), row.decided_at, row.comment_id);
|
|
137
|
+
}
|
|
138
|
+
db.prepare("UPDATE comment_suggestions SET status = 'accepted', apply_update = NULL, apply_range = NULL WHERE comment_id = ?").run(row.comment_id);
|
|
139
|
+
clearSuggestionReview(db, row.comment_id, row.decided_at);
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
return true;
|
|
143
|
+
}
|
package/dist/server/db.js
CHANGED
|
@@ -93,6 +93,87 @@ const databaseMigrations = [
|
|
|
93
93
|
if (missingColumn(db, "agent_tasks", "native_cleanup_done")) {
|
|
94
94
|
db.exec("ALTER TABLE agent_tasks ADD COLUMN native_cleanup_done INTEGER NOT NULL DEFAULT 0 CHECK (native_cleanup_done IN (0, 1))");
|
|
95
95
|
}
|
|
96
|
+
} },
|
|
97
|
+
{ version: 12, name: "add_comment_suggestions", apply: (db) => {
|
|
98
|
+
db.exec(`CREATE TABLE IF NOT EXISTS comment_suggestions (
|
|
99
|
+
comment_id TEXT PRIMARY KEY REFERENCES comments(id) ON DELETE CASCADE,
|
|
100
|
+
original_text TEXT NOT NULL,
|
|
101
|
+
replacement_text TEXT NOT NULL,
|
|
102
|
+
reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL,
|
|
103
|
+
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'accepted', 'rejected')),
|
|
104
|
+
decided_by TEXT REFERENCES users(id) ON DELETE SET NULL,
|
|
105
|
+
decided_at TEXT,
|
|
106
|
+
apply_update BLOB,
|
|
107
|
+
apply_range TEXT
|
|
108
|
+
);
|
|
109
|
+
`);
|
|
110
|
+
if (missingColumn(db, "comment_mentions", "kind"))
|
|
111
|
+
db.exec("ALTER TABLE comment_mentions ADD COLUMN kind TEXT NOT NULL DEFAULT 'mention' CHECK (kind IN ('mention', 'review'))");
|
|
112
|
+
} },
|
|
113
|
+
{ version: 13, name: "move_reviewer_to_comments", apply: (db) => {
|
|
114
|
+
if (missingColumn(db, "comments", "reviewer_id"))
|
|
115
|
+
db.exec("ALTER TABLE comments ADD COLUMN reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL");
|
|
116
|
+
if (!missingColumn(db, "comment_suggestions", "reviewer_id")) {
|
|
117
|
+
db.exec(`UPDATE comments SET reviewer_id = (
|
|
118
|
+
SELECT reviewer_id FROM comment_suggestions WHERE comment_id = comments.id
|
|
119
|
+
) WHERE id IN (SELECT comment_id FROM comment_suggestions);
|
|
120
|
+
ALTER TABLE comment_suggestions DROP COLUMN reviewer_id;`);
|
|
121
|
+
}
|
|
122
|
+
} },
|
|
123
|
+
{ version: 14, name: "keep_reviewers_on_suggestions", apply: (db) => {
|
|
124
|
+
if (missingColumn(db, "comment_suggestions", "reviewer_id"))
|
|
125
|
+
db.exec("ALTER TABLE comment_suggestions ADD COLUMN reviewer_id TEXT REFERENCES users(id) ON DELETE SET NULL");
|
|
126
|
+
if (!missingColumn(db, "comments", "reviewer_id")) {
|
|
127
|
+
db.exec(`UPDATE comment_suggestions SET reviewer_id = (
|
|
128
|
+
SELECT reviewer_id FROM comments WHERE id = comment_suggestions.comment_id
|
|
129
|
+
);
|
|
130
|
+
DELETE FROM comment_mentions WHERE kind = 'review' AND comment_id NOT IN (SELECT comment_id FROM comment_suggestions);
|
|
131
|
+
ALTER TABLE comments DROP COLUMN reviewer_id;`);
|
|
132
|
+
}
|
|
133
|
+
} },
|
|
134
|
+
{ version: 15, name: "add_project_view_links", apply: (db) => {
|
|
135
|
+
db.exec(`CREATE TABLE IF NOT EXISTS project_view_links (
|
|
136
|
+
id TEXT PRIMARY KEY,
|
|
137
|
+
project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
138
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
139
|
+
label TEXT NOT NULL DEFAULT '',
|
|
140
|
+
created_at TEXT NOT NULL,
|
|
141
|
+
expires_at TEXT,
|
|
142
|
+
revoked_at TEXT
|
|
143
|
+
);
|
|
144
|
+
CREATE INDEX IF NOT EXISTS project_view_links_project ON project_view_links(project_id, created_at DESC);`);
|
|
145
|
+
} },
|
|
146
|
+
{ version: 16, name: "remove_revoked_project_view_links", apply: (db) => {
|
|
147
|
+
if (missingColumn(db, "project_view_links", "revoked_at"))
|
|
148
|
+
return;
|
|
149
|
+
db.exec(`DELETE FROM project_view_links WHERE revoked_at IS NOT NULL;
|
|
150
|
+
ALTER TABLE project_view_links DROP COLUMN revoked_at;`);
|
|
151
|
+
} },
|
|
152
|
+
{ version: 17, name: "store_encrypted_view_link_tokens", apply: (db) => {
|
|
153
|
+
if (missingColumn(db, "project_view_links", "token_ciphertext")) {
|
|
154
|
+
db.exec("ALTER TABLE project_view_links ADD COLUMN token_ciphertext TEXT");
|
|
155
|
+
}
|
|
156
|
+
} },
|
|
157
|
+
{ version: 18, name: "add_citation_collections", apply: (db) => {
|
|
158
|
+
db.exec(`CREATE TABLE IF NOT EXISTS citation_library_collections (
|
|
159
|
+
id TEXT PRIMARY KEY,
|
|
160
|
+
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
161
|
+
name TEXT NOT NULL COLLATE NOCASE,
|
|
162
|
+
created_at TEXT NOT NULL,
|
|
163
|
+
UNIQUE (user_id, name)
|
|
164
|
+
);
|
|
165
|
+
CREATE TABLE IF NOT EXISTS citation_library_entry_collections (
|
|
166
|
+
entry_id TEXT NOT NULL REFERENCES citation_library_entries(id) ON DELETE CASCADE,
|
|
167
|
+
collection_id TEXT NOT NULL REFERENCES citation_library_collections(id) ON DELETE CASCADE,
|
|
168
|
+
PRIMARY KEY (entry_id, collection_id)
|
|
169
|
+
);
|
|
170
|
+
CREATE INDEX IF NOT EXISTS citation_library_entry_collections_collection
|
|
171
|
+
ON citation_library_entry_collections(collection_id, entry_id);`);
|
|
172
|
+
} },
|
|
173
|
+
{ version: 19, name: "add_citation_notes", apply: (db) => {
|
|
174
|
+
if (missingColumn(db, "citation_library_entries", "notes")) {
|
|
175
|
+
db.exec("ALTER TABLE citation_library_entries ADD COLUMN notes TEXT NOT NULL DEFAULT ''");
|
|
176
|
+
}
|
|
96
177
|
} }
|
|
97
178
|
];
|
|
98
179
|
function migrateGitHubTokensToUsers(db) {
|
package/dist/server/i18n.js
CHANGED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
import { supportedLocale } from "../shared/locales.js";
|
|
7
7
|
import { zhHantMessages } from "./locales/zh-Hant.js";
|
|
8
8
|
import { agentMessages } from "../shared/agentMessages.js";
|
|
9
|
+
import { suggestionMessages } from "../shared/suggestionMessages.js";
|
|
10
|
+
import { viewLinkMessages } from "../shared/projectViewLinks.js";
|
|
11
|
+
import { citationCollectionMessages } from "../shared/citationCollections.js";
|
|
12
|
+
import { projectSearchMessages } from "../shared/projectSearch.js";
|
|
9
13
|
const enMessages = {
|
|
14
|
+
...projectSearchMessages.en,
|
|
15
|
+
...citationCollectionMessages.en,
|
|
16
|
+
...viewLinkMessages.en,
|
|
17
|
+
...suggestionMessages.en,
|
|
10
18
|
...agentMessages.en,
|
|
11
19
|
AVATAR_STYLE_INVALID: "Choose a supported avatar style.",
|
|
12
20
|
AVATAR_NOT_FOUND: "No custom avatar is configured for this user.",
|
|
@@ -150,6 +158,10 @@ const enMessages = {
|
|
|
150
158
|
GIT_OPERATION_FAILED: "The Git operation could not be completed."
|
|
151
159
|
};
|
|
152
160
|
const zhMessages = {
|
|
161
|
+
...viewLinkMessages.zh,
|
|
162
|
+
...projectSearchMessages.zh,
|
|
163
|
+
...citationCollectionMessages.zh,
|
|
164
|
+
...suggestionMessages.zh,
|
|
153
165
|
...agentMessages.zh,
|
|
154
166
|
AVATAR_STYLE_INVALID: "请选择支持的头像风格。",
|
|
155
167
|
AVATAR_NOT_FOUND: "该用户尚未设置自定义头像。",
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { agentMessages } from "../../shared/agentMessages.js";
|
|
2
|
+
import { suggestionMessages } from "../../shared/suggestionMessages.js";
|
|
3
|
+
import { viewLinkMessages } from "../../shared/projectViewLinks.js";
|
|
4
|
+
import { citationCollectionMessages } from "../../shared/citationCollections.js";
|
|
5
|
+
import { projectSearchMessages } from "../../shared/projectSearch.js";
|
|
2
6
|
/** Traditional Chinese API messages, using the same stable error codes. */
|
|
3
7
|
export const zhHantMessages = {
|
|
8
|
+
...viewLinkMessages["zh-Hant"],
|
|
9
|
+
...citationCollectionMessages["zh-Hant"],
|
|
10
|
+
...projectSearchMessages["zh-Hant"],
|
|
11
|
+
...suggestionMessages["zh-Hant"],
|
|
4
12
|
...agentMessages["zh-Hant"],
|
|
5
13
|
AVATAR_STYLE_INVALID: "請選擇支援的頭像風格。",
|
|
6
14
|
AVATAR_NOT_FOUND: "該使用者尚未設定自訂頭像。",
|