texlite 0.22.0 → 0.24.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 +75 -15
- package/OPERATIONS.md +21 -1
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/addon.md +76 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js +1 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js.br +0 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js.gz +0 -0
- package/dist/client/assets/{AgentIcon-DeoZDwgh.css → AgentIcon-_B7xXJpJ.css} +1 -1
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.br +0 -0
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.gz +0 -0
- package/dist/client/assets/{AgentManagement-DlV6tHez.js → AgentManagement-DXgfP7l_.js} +1 -1
- package/dist/client/assets/AgentManagement-DXgfP7l_.js.br +0 -0
- package/dist/client/assets/AgentManagement-DXgfP7l_.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js +2 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js.br +0 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js +16 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-C8WQhZBK.js → AvatarSettingsDialog-iuEbMO4a.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-CDiYDj3M.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-DgOIkLwK.js → CitationLibraryDialog-CJlL-Ytx.js} +3 -3
- package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.gz +0 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js +5 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js.br +0 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js.gz +0 -0
- package/dist/client/assets/{GitDialog-DGzZ3GRj.js → GitDialog-DUGAigLx.js} +1 -1
- package/dist/client/assets/GitDialog-DUGAigLx.js.br +0 -0
- package/dist/client/assets/GitDialog-DUGAigLx.js.gz +0 -0
- package/dist/client/assets/{GitHubAccountDialog-CGZl3mcY.js → GitHubAccountDialog-B4eD622i.js} +1 -1
- package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js +8 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js.br +0 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js.gz +0 -0
- package/dist/client/assets/{InfoPopover-Ba7GvcuW.js → InfoPopover-CQ3Q10tN.js} +1 -1
- package/dist/client/assets/LatexEditor-DvDYTc0r.js +25 -0
- package/dist/client/assets/LatexEditor-DvDYTc0r.js.br +0 -0
- package/dist/client/assets/LatexEditor-DvDYTc0r.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-BH2iwvle.js → MarkdownPreview-_AXp5G7f.js} +1 -1
- package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-Bfkaxcnh.js → ProjectIconPickerDialog-BxjEYsau.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js +4 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js.br +0 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js +25 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-CHjPlBu2.js → QuickOpenDialog-HlkWqVR9.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BIdN1YP_.js +2 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js +3 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js +2 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.gz +0 -0
- package/dist/client/assets/{SystemMetricsDialog-DkmBA4o4.js → SystemMetricsDialog-Dr4pYWG6.js} +1 -1
- package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.gz +0 -0
- package/dist/client/assets/{TagManagementDialog-BM1MRuwh.js → TagManagementDialog-D4fYVboy.js} +1 -1
- package/dist/client/assets/TagManagementDialog-D4fYVboy.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-D4fYVboy.js.gz +0 -0
- package/dist/client/assets/{ThemeSwitcher-dcvtWVCO.js → ThemeSwitcher-BgzkYTeA.js} +1 -1
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css +1 -0
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.gz +0 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js +1 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js +1 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js.br +0 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js.gz +0 -0
- package/dist/client/assets/{chktex-BrzPYHey.js → chktex--32C-Pkl.js} +1 -1
- package/dist/client/assets/{citationLibrary-DxGdbZEQ.js → citationLibrary-BJRzAgaV.js} +1 -1
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.br +0 -0
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.gz +0 -0
- package/dist/client/assets/editor-CSq7NymY.js +14 -0
- package/dist/client/assets/editor-CSq7NymY.js.br +0 -0
- package/dist/client/assets/editor-CSq7NymY.js.gz +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js +36 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.br +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js +1 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.gz +0 -0
- package/dist/client/assets/file-cog-D_mhAnBe.js +1 -0
- package/dist/client/assets/{generatedParser-CZa2vsK6.js → generatedParser-2izSCuvk.js} +1 -1
- package/dist/client/assets/generatedParser-2izSCuvk.js.br +0 -0
- package/dist/client/assets/generatedParser-2izSCuvk.js.gz +0 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js +13 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js.br +0 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js.gz +0 -0
- package/dist/client/assets/index-B1vejuOw.js +2 -0
- package/dist/client/assets/index-B1vejuOw.js.br +0 -0
- package/dist/client/assets/index-B1vejuOw.js.gz +0 -0
- package/dist/client/assets/index-Blr4J_Pq.css +1 -0
- package/dist/client/assets/index-Blr4J_Pq.css.br +0 -0
- package/dist/client/assets/index-Blr4J_Pq.css.gz +0 -0
- package/dist/client/assets/{relativeTime-mmWGtWRR.js → relativeTime-CcP1IEvr.js} +1 -1
- package/dist/client/assets/relativeTime-CcP1IEvr.js.br +0 -0
- package/dist/client/assets/relativeTime-CcP1IEvr.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js +1 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js.gz +0 -0
- package/dist/client/assets/{spellCheck-BTyLQAFH.js → spellCheck-DpWPgtM7.js} +1 -1
- package/dist/client/assets/spellCheck-DpWPgtM7.js.br +0 -0
- package/dist/client/assets/spellCheck-DpWPgtM7.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-tGXUsMU9.js +1 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js +78 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.br +0 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js +1 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.gz +0 -0
- package/dist/client/assets/{vimSupport-C-WiMLjc.js → vimSupport-DMVGjr9R.js} +6 -6
- package/dist/client/assets/vimSupport-DMVGjr9R.js.br +0 -0
- package/dist/client/assets/vimSupport-DMVGjr9R.js.gz +0 -0
- package/dist/client/index.html +3 -3
- package/dist/server/agentChanges.js +95 -7
- package/dist/server/agents/outputBuffer.js +105 -0
- package/dist/server/agents/sessions.js +33 -16
- package/dist/server/agents/workspaces.js +14 -1
- package/dist/server/app.js +2 -0
- package/dist/server/cli.js +12 -1
- package/dist/server/collaboration.js +9 -0
- package/dist/server/config.js +10 -0
- package/dist/server/db.js +64 -0
- package/dist/server/editHistory.js +68 -20
- package/dist/server/git.js +9 -7
- package/dist/server/history.js +160 -69
- package/dist/server/i18n.js +8 -0
- package/dist/server/locales/zh-Hant.js +4 -0
- package/dist/server/projectMutations.js +4 -0
- package/dist/server/routes/comments.js +7 -2
- package/dist/server/routes/compile.js +56 -4
- package/dist/server/routes/projectFiles.js +54 -0
- package/dist/server/routes/projectGit.js +1 -1
- package/dist/server/routes/projectHistory.js +19 -5
- package/dist/server/routes/system.js +1 -0
- package/dist/server/routes/tikzGallery.js +38 -0
- package/dist/server/tikzEditorAddon.js +115 -0
- package/dist/server/tikzEditorRelease.js +9 -0
- package/dist/server/tikzGallery.js +63 -0
- package/dist/shared/agentMessages.js +3 -0
- package/dist/shared/tikzStandalone.js +15 -0
- package/package.json +2 -1
- package/templates/agents/AGENTS.md +12 -0
- package/texlite.config.example.json +4 -0
- package/dist/client/assets/AdminUsers-DepqkT6m.js +0 -1
- package/dist/client/assets/AdminUsers-DepqkT6m.js.br +0 -0
- package/dist/client/assets/AdminUsers-DepqkT6m.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DeoZDwgh.css.br +0 -0
- package/dist/client/assets/AgentIcon-DeoZDwgh.css.gz +0 -0
- package/dist/client/assets/AgentManagement-DlV6tHez.js.br +0 -0
- package/dist/client/assets/AgentManagement-DlV6tHez.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js +0 -2
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js.br +0 -0
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js +0 -16
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-SpudGDwi.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.gz +0 -0
- package/dist/client/assets/Dashboard-CD1w42mA.js +0 -5
- package/dist/client/assets/Dashboard-CD1w42mA.js.br +0 -0
- package/dist/client/assets/Dashboard-CD1w42mA.js.gz +0 -0
- package/dist/client/assets/GitDialog-DGzZ3GRj.js.br +0 -0
- package/dist/client/assets/GitDialog-DGzZ3GRj.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js +0 -8
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js.br +0 -0
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js.gz +0 -0
- package/dist/client/assets/LatexEditor-Boc-45KL.js +0 -25
- package/dist/client/assets/LatexEditor-Boc-45KL.js.br +0 -0
- package/dist/client/assets/LatexEditor-Boc-45KL.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-BH2iwvle.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-BH2iwvle.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js +0 -1
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js +0 -4
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js.br +0 -0
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js +0 -25
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-DKcmDg0e.js +0 -2
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js +0 -3
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js +0 -2
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.js +0 -1
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.js.br +0 -0
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.js.gz +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.br +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.gz +0 -0
- package/dist/client/assets/editor-CkUEg2La.js +0 -14
- package/dist/client/assets/editor-CkUEg2La.js.br +0 -0
- package/dist/client/assets/editor-CkUEg2La.js.gz +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js +0 -36
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.br +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js +0 -1
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.gz +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.br +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.gz +0 -0
- package/dist/client/assets/i18n-Dtn6w-qA.js +0 -13
- package/dist/client/assets/i18n-Dtn6w-qA.js.br +0 -0
- package/dist/client/assets/i18n-Dtn6w-qA.js.gz +0 -0
- package/dist/client/assets/index-BbU2fbRw.css +0 -1
- package/dist/client/assets/index-BbU2fbRw.css.br +0 -0
- package/dist/client/assets/index-BbU2fbRw.css.gz +0 -0
- package/dist/client/assets/index-CPR6YZEf.js +0 -2
- package/dist/client/assets/index-CPR6YZEf.js.br +0 -0
- package/dist/client/assets/index-CPR6YZEf.js.gz +0 -0
- package/dist/client/assets/relativeTime-mmWGtWRR.js.br +0 -0
- package/dist/client/assets/relativeTime-mmWGtWRR.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js +0 -1
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.gz +0 -0
- package/dist/client/assets/spellCheck-BTyLQAFH.js.br +0 -0
- package/dist/client/assets/spellCheck-BTyLQAFH.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-Ck8lMOWz.js +0 -1
- package/dist/client/assets/textLanguages-CwWstpJ5.js +0 -78
- package/dist/client/assets/textLanguages-CwWstpJ5.js.br +0 -0
- package/dist/client/assets/textLanguages-CwWstpJ5.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js +0 -1
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.gz +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.br +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.gz +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js → AgentIcon-CjaO3WzI.js} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.br → AgentIcon-CjaO3WzI.js.br} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.gz → AgentIcon-CjaO3WzI.js.gz} +0 -0
package/dist/server/history.js
CHANGED
|
@@ -5,6 +5,12 @@ import { assertNoSourceSymlinks, listProjectFiles, outputRoot, projectRoot, reso
|
|
|
5
5
|
import { httpError } from "./http.js";
|
|
6
6
|
import { MAX_TEXT_PREVIEW_BYTES } from "./limits.js";
|
|
7
7
|
import { defaultHistoryTracking, historyTextCandidate, historyTrackingOverride } from "../shared/historyTracking.js";
|
|
8
|
+
/**
|
|
9
|
+
* Versions shown in the timeline and used as "previous" comparisons. Older
|
|
10
|
+
* settings-only rows are hidden; a settings-only safety checkpoint is shown.
|
|
11
|
+
*/
|
|
12
|
+
const VISIBLE_VERSION_SQL = "(json_array_length(%.changed_paths_json) > 0 OR %.reason = 'checkpoint')";
|
|
13
|
+
const visibleVersion = (alias) => VISIBLE_VERSION_SQL.replaceAll("%", alias);
|
|
8
14
|
const HOUR_MS = 60 * 60_000;
|
|
9
15
|
const DAY_MS = 24 * HOUR_MS;
|
|
10
16
|
/** Server-local hour or day, matching the local days the timeline is grouped by. */
|
|
@@ -19,10 +25,12 @@ const HISTORY_KEEP_ALL_MS = DAY_MS;
|
|
|
19
25
|
const HISTORY_KEEP_HOURLY_MS = 7 * DAY_MS;
|
|
20
26
|
/** Fixed window, from a run's first save, in which autosaves (or one user's agent writes) share a snapshot. */
|
|
21
27
|
const AUTOSAVE_COALESCE_MS = 2 * 60_000;
|
|
22
|
-
// Logical stored payload
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
// Logical stored payload: the UTF-8 bytes of a version row's text columns.
|
|
29
|
+
// SQLite pages, indexes and WAL are shared database overhead. octet_length()
|
|
30
|
+
// reads only the stored value sizes, never the manifests themselves.
|
|
31
|
+
const METADATA_BYTES_SQL = `(octet_length(id) + octet_length(project_id) + COALESCE(octet_length(author_id), 0)
|
|
32
|
+
+ octet_length(reason) + COALESCE(octet_length(label), 0) + octet_length(manifest_json)
|
|
33
|
+
+ octet_length(changed_paths_json) + octet_length(created_at))`;
|
|
26
34
|
const DEFAULT_HISTORY_PAGE_SIZE = 100;
|
|
27
35
|
const MAX_HISTORY_PAGE_SIZE = 100;
|
|
28
36
|
export class ProjectHistoryService {
|
|
@@ -46,6 +54,17 @@ export class ProjectHistoryService {
|
|
|
46
54
|
const manifest = comparable ? cloneManifest(comparable) : this.emptyManifest(project);
|
|
47
55
|
manifest.tracking = tracking;
|
|
48
56
|
manifest.settings = settings(project);
|
|
57
|
+
// The baseline assembles the new manifest, because files outside the
|
|
58
|
+
// changed roots are copied from it. Changes are reported against the
|
|
59
|
+
// newest stored version instead: the two differ after that version was
|
|
60
|
+
// deleted, and the timeline must show what changed since the snapshot a
|
|
61
|
+
// user can still see and restore.
|
|
62
|
+
const latestManifest = previous ? parseManifest(previous.manifest_json) : null;
|
|
63
|
+
const reference = latestManifest
|
|
64
|
+
? JSON.stringify(latestManifest.tracking) === JSON.stringify(tracking)
|
|
65
|
+
? latestManifest
|
|
66
|
+
: { ...latestManifest, files: this.filterTrackedObjects(projectId, latestManifest.files, tracking) }
|
|
67
|
+
: comparable;
|
|
49
68
|
if (!previousManifest || policyChanged || changedRoots === undefined) {
|
|
50
69
|
manifest.files = this.snapshotAllFiles(projectId, tracking);
|
|
51
70
|
}
|
|
@@ -60,10 +79,11 @@ export class ProjectHistoryService {
|
|
|
60
79
|
manifest.files[filePath] = file;
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
|
-
const changedPaths =
|
|
82
|
+
const changedPaths = reference ? changedManifestPaths(reference, manifest) : Object.keys(manifest.files).sort();
|
|
83
|
+
const keepSettings = Boolean(options.keepSettingsChange && reference && !sameSettings(reference.settings, manifest.settings));
|
|
64
84
|
// Settings alone do not create a file-history entry. Keep the baseline
|
|
65
85
|
// current so the next real file change captures the effective settings.
|
|
66
|
-
if (changedPaths.length === 0) {
|
|
86
|
+
if (changedPaths.length === 0 && !keepSettings) {
|
|
67
87
|
this.saveBaseline(projectId, manifest);
|
|
68
88
|
return null;
|
|
69
89
|
}
|
|
@@ -80,7 +100,22 @@ export class ProjectHistoryService {
|
|
|
80
100
|
if (!policyChanged && sameRun && previous && !previous.label
|
|
81
101
|
&& JSON.stringify(parseManifest(previous.manifest_json).tracking) === JSON.stringify(tracking)
|
|
82
102
|
&& Date.parse(createdAt) - Date.parse(previous.created_at) < AUTOSAVE_COALESCE_MS) {
|
|
83
|
-
|
|
103
|
+
// Report the run's net change against the version before it, so a file
|
|
104
|
+
// edited and then changed back is not listed as changed.
|
|
105
|
+
const beforeRun = this.previousVersion(projectId, previous.id);
|
|
106
|
+
const beforeRunFiles = beforeRun ? this.manifest(projectId, beforeRun.id)?.files ?? {} : {};
|
|
107
|
+
const merged = [...new Set([...parseStringArray(previous.changed_paths_json), ...changedPaths])]
|
|
108
|
+
.filter((filePath) => beforeRunFiles[filePath]?.digest !== manifest.files[filePath]?.digest).sort();
|
|
109
|
+
const runDigests = new Set(Object.values(parseManifest(previous.manifest_json).files).map((file) => file.digest));
|
|
110
|
+
if (merged.length === 0) {
|
|
111
|
+
// The run left every file as the previous version had it, so it is
|
|
112
|
+
// not a restore point of its own.
|
|
113
|
+
this.db.prepare("DELETE FROM project_history_versions WHERE id = ? AND project_id = ?").run(previous.id, projectId);
|
|
114
|
+
this.saveBaseline(projectId, manifest);
|
|
115
|
+
if (!options.deferRetention)
|
|
116
|
+
this.removeUnreferencedObjects(projectId, runDigests);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
84
119
|
this.db.prepare(`UPDATE project_history_versions
|
|
85
120
|
SET manifest_json = ?, changed_paths_json = ?, author_id = ? WHERE id = ?`)
|
|
86
121
|
.run(JSON.stringify(manifest), JSON.stringify(merged), previous.author_id === authorId ? authorId : null, previous.id);
|
|
@@ -106,7 +141,7 @@ export class ProjectHistoryService {
|
|
|
106
141
|
list(projectId, limit = 100) {
|
|
107
142
|
const rows = this.db.prepare(`SELECT history.*, user.username AS author_username, user.display_name AS author_name
|
|
108
143
|
FROM project_history_versions history LEFT JOIN users user ON user.id = history.author_id
|
|
109
|
-
WHERE history.project_id = ? AND
|
|
144
|
+
WHERE history.project_id = ? AND ${visibleVersion("history")}
|
|
110
145
|
ORDER BY history.created_at DESC, history.rowid DESC LIMIT ?`)
|
|
111
146
|
.all(projectId, Math.min(200, Math.max(1, limit)));
|
|
112
147
|
return rows.map((row) => versionJson(row));
|
|
@@ -161,7 +196,7 @@ export class ProjectHistoryService {
|
|
|
161
196
|
const rows = this.db.prepare(`SELECT history.*, history.rowid AS history_rowid,
|
|
162
197
|
user.username AS author_username, user.display_name AS author_name
|
|
163
198
|
FROM project_history_versions history LEFT JOIN users user ON user.id = history.author_id
|
|
164
|
-
WHERE history.project_id = ? AND
|
|
199
|
+
WHERE history.project_id = ? AND ${visibleVersion("history")} ${cursorFilter}
|
|
165
200
|
ORDER BY history.created_at DESC, history.rowid DESC LIMIT ?`)
|
|
166
201
|
.all(...values);
|
|
167
202
|
const pageRows = rows.slice(0, limitValue);
|
|
@@ -171,29 +206,32 @@ export class ProjectHistoryService {
|
|
|
171
206
|
};
|
|
172
207
|
}
|
|
173
208
|
stats(projectId) {
|
|
174
|
-
const rows = this.db.prepare(`SELECT
|
|
175
|
-
WHERE project_id = ? ORDER BY created_at DESC, rowid DESC`)
|
|
176
|
-
|
|
177
|
-
const protectedObjects = new Map();
|
|
209
|
+
const rows = this.db.prepare(`SELECT id, reason, label, ${METADATA_BYTES_SQL} AS metadata_bytes
|
|
210
|
+
FROM project_history_versions WHERE project_id = ? ORDER BY created_at DESC, rowid DESC`)
|
|
211
|
+
.all(projectId);
|
|
178
212
|
let metadataBytes = 0;
|
|
179
213
|
let protectedMetadataBytes = 0;
|
|
180
214
|
let ordinaryVersionCount = 0;
|
|
181
215
|
let labeledVersionCount = 0;
|
|
216
|
+
const protectedIds = [];
|
|
182
217
|
for (const row of rows) {
|
|
183
218
|
const protectedVersion = row === rows[0] || row.reason === "initial" || Boolean(row.label);
|
|
184
|
-
metadataBytes +=
|
|
185
|
-
if (protectedVersion)
|
|
186
|
-
protectedMetadataBytes +=
|
|
219
|
+
metadataBytes += row.metadata_bytes;
|
|
220
|
+
if (protectedVersion) {
|
|
221
|
+
protectedMetadataBytes += row.metadata_bytes;
|
|
222
|
+
protectedIds.push(row.id);
|
|
223
|
+
}
|
|
187
224
|
if (row.label)
|
|
188
225
|
labeledVersionCount += 1;
|
|
189
226
|
else if (row.reason !== "initial")
|
|
190
227
|
ordinaryVersionCount += 1;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
228
|
+
}
|
|
229
|
+
const objects = this.objectSizes(projectId);
|
|
230
|
+
const protectedObjects = new Map();
|
|
231
|
+
const versionObjects = this.db.prepare("SELECT digest, size FROM project_history_version_objects WHERE version_id = ?");
|
|
232
|
+
for (const id of protectedIds) {
|
|
233
|
+
for (const object of versionObjects.all(id))
|
|
234
|
+
protectedObjects.set(object.digest, object.size);
|
|
197
235
|
}
|
|
198
236
|
const baseline = this.baseline(projectId);
|
|
199
237
|
if (baseline) {
|
|
@@ -221,6 +259,12 @@ export class ProjectHistoryService {
|
|
|
221
259
|
storageLimitExceeded: objectBytes + metadataBytes > this.config.historyMaxStorageBytes
|
|
222
260
|
};
|
|
223
261
|
}
|
|
262
|
+
/** Each stored content object any version refers to, with its size. */
|
|
263
|
+
objectSizes(projectId) {
|
|
264
|
+
const rows = this.db.prepare("SELECT digest, size FROM project_history_objects WHERE project_id = ?")
|
|
265
|
+
.all(projectId);
|
|
266
|
+
return new Map(rows.map((row) => [row.digest, row.size]));
|
|
267
|
+
}
|
|
224
268
|
enforceRetention(projectId) {
|
|
225
269
|
this.pruneVersions(projectId);
|
|
226
270
|
// Deferred autosave maintenance can leave an object from a coalesced
|
|
@@ -230,7 +274,8 @@ export class ProjectHistoryService {
|
|
|
230
274
|
this.removeUnreferencedObjects(projectId, this.storedObjectDigests(projectId));
|
|
231
275
|
}
|
|
232
276
|
deleteVersion(projectId, versionId) {
|
|
233
|
-
const row = this.db.prepare(
|
|
277
|
+
const row = this.db.prepare(`SELECT id, manifest_json, changed_paths_json, created_at, rowid AS history_rowid
|
|
278
|
+
FROM project_history_versions WHERE id = ? AND project_id = ?`)
|
|
234
279
|
.get(versionId, projectId);
|
|
235
280
|
if (!row)
|
|
236
281
|
return false;
|
|
@@ -295,7 +340,7 @@ export class ProjectHistoryService {
|
|
|
295
340
|
previousVersion(projectId, versionId) {
|
|
296
341
|
const row = this.db.prepare(`SELECT older.id FROM project_history_versions older
|
|
297
342
|
JOIN project_history_versions selected ON selected.id = ? AND selected.project_id = older.project_id
|
|
298
|
-
WHERE older.project_id = ? AND
|
|
343
|
+
WHERE older.project_id = ? AND ${visibleVersion("older")}
|
|
299
344
|
AND (older.created_at < selected.created_at
|
|
300
345
|
OR (older.created_at = selected.created_at AND older.rowid < selected.rowid))
|
|
301
346
|
ORDER BY older.created_at DESC, older.rowid DESC LIMIT 1`).get(versionId, projectId);
|
|
@@ -378,7 +423,7 @@ export class ProjectHistoryService {
|
|
|
378
423
|
}
|
|
379
424
|
// This policy belongs only to the safety checkpoint, not project settings.
|
|
380
425
|
// Even a legacy restore or a single excluded file must remain reversible.
|
|
381
|
-
return this.record(projectId, authorId, "checkpoint", undefined, { tracking });
|
|
426
|
+
return this.record(projectId, authorId, "checkpoint", undefined, { tracking, keepSettingsChange: selected === null });
|
|
382
427
|
}
|
|
383
428
|
assertRestoreTargetIsFile(projectId, filePath) {
|
|
384
429
|
const target = resolveSourcePath(this.config, projectId, filePath);
|
|
@@ -536,23 +581,21 @@ export class ProjectHistoryService {
|
|
|
536
581
|
return digests;
|
|
537
582
|
}
|
|
538
583
|
pruneVersions(projectId) {
|
|
539
|
-
const rows = this.db.prepare(`SELECT
|
|
584
|
+
const rows = this.db.prepare(`SELECT id, reason, label, created_at, changed_paths_json, rowid AS history_rowid,
|
|
585
|
+
${METADATA_BYTES_SQL} AS metadata_bytes
|
|
540
586
|
FROM project_history_versions WHERE project_id = ?
|
|
541
587
|
ORDER BY created_at DESC, rowid DESC`).all(projectId);
|
|
542
588
|
if (!rows.length)
|
|
543
589
|
return;
|
|
544
|
-
//
|
|
545
|
-
|
|
590
|
+
// Reference counts are kept by the database for each stored content, so
|
|
591
|
+
// retention never parses manifests; a version's objects are read only if
|
|
592
|
+
// that version is removed.
|
|
546
593
|
const refCounts = new Map();
|
|
547
594
|
const sizeMap = new Map();
|
|
548
|
-
for (const row of
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
refCounts.set(file.digest, (refCounts.get(file.digest) ?? 0) + 1);
|
|
553
|
-
if (!sizeMap.has(file.digest))
|
|
554
|
-
sizeMap.set(file.digest, file.size);
|
|
555
|
-
}
|
|
595
|
+
for (const row of this.db.prepare("SELECT digest, refs, size FROM project_history_objects WHERE project_id = ?")
|
|
596
|
+
.all(projectId)) {
|
|
597
|
+
refCounts.set(row.digest, row.refs);
|
|
598
|
+
sizeMap.set(row.digest, row.size);
|
|
556
599
|
}
|
|
557
600
|
const baseline = this.baseline(projectId);
|
|
558
601
|
if (baseline) {
|
|
@@ -562,7 +605,7 @@ export class ProjectHistoryService {
|
|
|
562
605
|
sizeMap.set(file.digest, file.size);
|
|
563
606
|
}
|
|
564
607
|
}
|
|
565
|
-
let retainedBytes = rows.reduce((sum, row) => sum +
|
|
608
|
+
let retainedBytes = rows.reduce((sum, row) => sum + row.metadata_bytes, 0)
|
|
566
609
|
+ (baseline ? Buffer.byteLength(JSON.stringify(baseline), "utf8") : 0);
|
|
567
610
|
for (const [digest, count] of refCounts.entries()) {
|
|
568
611
|
if (count > 0)
|
|
@@ -571,32 +614,31 @@ export class ProjectHistoryService {
|
|
|
571
614
|
const latestId = rows[0]?.id;
|
|
572
615
|
// Ordinary versions eligible for version count capping (ordered newest to oldest)
|
|
573
616
|
const ordinaryDesc = rows.filter((row) => row.label === null && row.reason !== "initial");
|
|
617
|
+
const overVersionLimit = this.config.historyMaxVersions > 0 && ordinaryDesc.length > this.config.historyMaxVersions;
|
|
618
|
+
if (!overVersionLimit && retainedBytes <= this.config.historyMaxStorageBytes)
|
|
619
|
+
return;
|
|
574
620
|
const toDeleteIds = new Set();
|
|
575
621
|
const rowsById = new Map(rows.map((row) => [row.id, row]));
|
|
622
|
+
const versionObjects = this.db.prepare("SELECT digest FROM project_history_version_objects WHERE version_id = ?");
|
|
576
623
|
const removeVersionRefs = (versionId) => {
|
|
577
624
|
if (toDeleteIds.has(versionId))
|
|
578
625
|
return;
|
|
579
626
|
toDeleteIds.add(versionId);
|
|
580
|
-
retainedBytes -=
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
retainedBytes -= sizeMap.get(file.digest) ?? 0;
|
|
590
|
-
}
|
|
591
|
-
else if (count > 1) {
|
|
592
|
-
refCounts.set(file.digest, count - 1);
|
|
593
|
-
}
|
|
627
|
+
retainedBytes -= rowsById.get(versionId).metadata_bytes;
|
|
628
|
+
for (const { digest } of versionObjects.all(versionId)) {
|
|
629
|
+
const count = refCounts.get(digest);
|
|
630
|
+
if (count === 1) {
|
|
631
|
+
refCounts.set(digest, 0);
|
|
632
|
+
retainedBytes -= sizeMap.get(digest) ?? 0;
|
|
633
|
+
}
|
|
634
|
+
else if (count !== undefined && count > 1) {
|
|
635
|
+
refCounts.set(digest, count - 1);
|
|
594
636
|
}
|
|
595
637
|
}
|
|
596
638
|
};
|
|
597
639
|
// 1. Cap by historyMaxVersions (prune excess ordinary versions when configured; 0 = unlimited)
|
|
598
640
|
const remainingOrdinary = () => ordinaryDesc.filter((row) => !toDeleteIds.has(row.id));
|
|
599
|
-
if (
|
|
641
|
+
if (overVersionLimit) {
|
|
600
642
|
const obsolete = ordinaryDesc.slice(this.config.historyMaxVersions);
|
|
601
643
|
for (const row of obsolete)
|
|
602
644
|
removeVersionRefs(row.id);
|
|
@@ -644,6 +686,7 @@ export class ProjectHistoryService {
|
|
|
644
686
|
this.db.transaction(() => {
|
|
645
687
|
for (const id of toDeleteIds)
|
|
646
688
|
remove.run(id, projectId);
|
|
689
|
+
this.carryChangedPaths(projectId, rows.filter((row) => toDeleteIds.has(row.id)));
|
|
647
690
|
})();
|
|
648
691
|
// 5. Remove unreferenced CAS objects on disk
|
|
649
692
|
for (const [digest, count] of refCounts.entries()) {
|
|
@@ -660,28 +703,63 @@ export class ProjectHistoryService {
|
|
|
660
703
|
candidates.add(file.digest);
|
|
661
704
|
}
|
|
662
705
|
const remove = this.db.prepare("DELETE FROM project_history_versions WHERE id = ? AND project_id = ?");
|
|
663
|
-
this.db.transaction(() => {
|
|
664
|
-
|
|
706
|
+
this.db.transaction(() => {
|
|
707
|
+
for (const row of rows)
|
|
708
|
+
remove.run(row.id, projectId);
|
|
709
|
+
this.carryChangedPaths(projectId, rows);
|
|
710
|
+
})();
|
|
665
711
|
this.removeUnreferencedObjects(projectId, candidates);
|
|
666
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Each version lists the files changed since the version before it. When
|
|
715
|
+
* versions are removed, the next remaining version is now compared with an
|
|
716
|
+
* older one, so it takes over the removed versions' changes. Only files that
|
|
717
|
+
* still differ from the new predecessor are kept.
|
|
718
|
+
*/
|
|
719
|
+
carryChangedPaths(projectId, removed) {
|
|
720
|
+
if (!removed.length)
|
|
721
|
+
return;
|
|
722
|
+
const order = (left, right) => left.created_at < right.created_at ? -1 : left.created_at > right.created_at ? 1 : left.history_rowid - right.history_rowid;
|
|
723
|
+
const pending = [...removed].sort(order);
|
|
724
|
+
const survivors = this.db.prepare(`SELECT id, rowid AS history_rowid, created_at, changed_paths_json
|
|
725
|
+
FROM project_history_versions history WHERE project_id = ? AND ${visibleVersion("history")}
|
|
726
|
+
ORDER BY created_at ASC, rowid ASC`).all(projectId);
|
|
727
|
+
const update = this.db.prepare("UPDATE project_history_versions SET changed_paths_json = ? WHERE id = ? AND project_id = ?");
|
|
728
|
+
let next = 0;
|
|
729
|
+
let previousId = null;
|
|
730
|
+
for (const survivor of survivors) {
|
|
731
|
+
const carried = new Set();
|
|
732
|
+
while (next < pending.length && order(pending[next], survivor) < 0) {
|
|
733
|
+
for (const filePath of parseStringArray(pending[next].changed_paths_json))
|
|
734
|
+
carried.add(filePath);
|
|
735
|
+
next += 1;
|
|
736
|
+
}
|
|
737
|
+
if (carried.size) {
|
|
738
|
+
const own = parseStringArray(survivor.changed_paths_json);
|
|
739
|
+
const files = this.manifest(projectId, survivor.id).files;
|
|
740
|
+
const before = previousId ? this.manifest(projectId, previousId).files : {};
|
|
741
|
+
const differing = [...new Set([...own, ...carried])].filter((filePath) => before[filePath]?.digest !== files[filePath]?.digest).sort();
|
|
742
|
+
// An identical version keeps its old list rather than vanishing from
|
|
743
|
+
// the timeline, which hides versions without changed files.
|
|
744
|
+
const combined = differing.length ? differing : [...own].sort();
|
|
745
|
+
if (JSON.stringify(combined) !== survivor.changed_paths_json)
|
|
746
|
+
update.run(JSON.stringify(combined), survivor.id, projectId);
|
|
747
|
+
}
|
|
748
|
+
previousId = survivor.id;
|
|
749
|
+
if (next >= pending.length)
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
667
753
|
removeUnreferencedObjects(projectId, candidates) {
|
|
668
754
|
if (!candidates.size)
|
|
669
755
|
return;
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
for (const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (!candidates.size)
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
const baseline = this.baseline(projectId);
|
|
679
|
-
if (baseline) {
|
|
680
|
-
for (const file of Object.values(baseline.files))
|
|
681
|
-
candidates.delete(file.digest);
|
|
682
|
-
}
|
|
683
|
-
for (const digest of candidates)
|
|
756
|
+
const referenced = this.db.prepare("SELECT 1 FROM project_history_objects WHERE project_id = ? AND digest = ?");
|
|
757
|
+
const baselineDigests = new Set(Object.values(this.baseline(projectId)?.files ?? {}).map((file) => file.digest));
|
|
758
|
+
for (const digest of candidates) {
|
|
759
|
+
if (baselineDigests.has(digest) || referenced.get(projectId, digest))
|
|
760
|
+
continue;
|
|
684
761
|
fs.rmSync(this.objectPath(projectId, digest), { force: true });
|
|
762
|
+
}
|
|
685
763
|
}
|
|
686
764
|
restoreProjectTree(projectId, manifest) {
|
|
687
765
|
assertNoSourceSymlinks(this.config, projectId);
|
|
@@ -695,9 +773,18 @@ export class ProjectHistoryService {
|
|
|
695
773
|
let gitMoved = false;
|
|
696
774
|
try {
|
|
697
775
|
if (manifest.tracking) {
|
|
776
|
+
const entries = listProjectFiles(this.config, projectId);
|
|
777
|
+
// An empty folder holds nothing a snapshot records, so like other
|
|
778
|
+
// content outside the snapshot's scope it survives the restore.
|
|
779
|
+
const files = entries.filter((entry) => entry.type === "file").map((entry) => entry.path);
|
|
780
|
+
for (const folder of entries) {
|
|
781
|
+
if (folder.type !== "directory" || files.some((filePath) => filePath.startsWith(`${folder.path}/`)))
|
|
782
|
+
continue;
|
|
783
|
+
fs.mkdirSync(path.join(temporary, safeRelativePath(folder.path)), { recursive: true, mode: 0o700 });
|
|
784
|
+
}
|
|
698
785
|
// Files outside this snapshot's scope survive a project restore. Stage
|
|
699
786
|
// them before swapping trees so a copy/conflict failure is harmless.
|
|
700
|
-
for (const file of
|
|
787
|
+
for (const file of entries) {
|
|
701
788
|
if (file.type !== "file" || manifest.files[file.path])
|
|
702
789
|
continue;
|
|
703
790
|
const source = resolveSourcePath(this.config, projectId, file.path);
|
|
@@ -744,6 +831,10 @@ export class ProjectHistoryService {
|
|
|
744
831
|
function settings(project) {
|
|
745
832
|
return { mainFile: project.main_file, engine: project.engine, latexmkrc: project.latexmkrc, chktexEnabled: Boolean(project.chktex_enabled) };
|
|
746
833
|
}
|
|
834
|
+
function sameSettings(left, right) {
|
|
835
|
+
return left.mainFile === right.mainFile && left.engine === right.engine && left.latexmkrc === right.latexmkrc
|
|
836
|
+
&& Boolean(left.chktexEnabled) === Boolean(right.chktexEnabled);
|
|
837
|
+
}
|
|
747
838
|
function cloneManifest(manifest) {
|
|
748
839
|
return { ...manifest, files: { ...manifest.files }, settings: { ...manifest.settings } };
|
|
749
840
|
}
|
package/dist/server/i18n.js
CHANGED
|
@@ -39,6 +39,7 @@ const enMessages = {
|
|
|
39
39
|
CLIENT_UPDATE_REQUIRED: "This page is out of date. Save your changes and reload it to continue writing checks.",
|
|
40
40
|
COMMENT_DELETE_FORBIDDEN: "You can only delete your own comments.",
|
|
41
41
|
COMMENT_EDIT_FORBIDDEN: "You can only edit your own comments.",
|
|
42
|
+
COMMENT_RESOLVE_FORBIDDEN: "Only members who can edit this project can resolve or reopen comments.",
|
|
42
43
|
COMMENT_FILE_NOT_FOUND: "The file for this comment does not exist.",
|
|
43
44
|
COMMENT_NOT_FOUND: "The comment does not exist.",
|
|
44
45
|
COMMENT_RANGE_INVALID: "The comment source range is invalid.",
|
|
@@ -48,6 +49,9 @@ const enMessages = {
|
|
|
48
49
|
COMPILE_ARTIFACTS_NOT_FOUND: "No compiled artifacts are available yet.",
|
|
49
50
|
COMPILE_CLEAN_BUSY: "This root document is compiling. Try recovery again after it finishes.",
|
|
50
51
|
COMPILE_FORBIDDEN: "You do not have permission to compile this project.",
|
|
52
|
+
TIKZ_GALLERY_DISABLED: "The TikZ gallery is not enabled on this server.",
|
|
53
|
+
TIKZ_GALLERY_UNAVAILABLE: "The TikZ gallery add-on was not found on this server. Ask an administrator to install it.",
|
|
54
|
+
TIKZ_GALLERY_INCOMPATIBLE: "The installed TikZ gallery is not compatible with this version of TexLite. Ask an administrator to update it.",
|
|
51
55
|
COMPILE_SNAPSHOT_BUSY: "The project source is still being saved. Try compiling again shortly.",
|
|
52
56
|
CURRENT_PASSWORD_INVALID: "The current password is incorrect.",
|
|
53
57
|
PASSWORD_CHANGE_REQUIRED: "Change your temporary password before continuing.",
|
|
@@ -189,6 +193,7 @@ const zhMessages = {
|
|
|
189
193
|
CLIENT_UPDATE_REQUIRED: "当前页面版本过旧。请先保存修改,再刷新页面以继续写作检查。",
|
|
190
194
|
COMMENT_DELETE_FORBIDDEN: "只能删除自己的批注。",
|
|
191
195
|
COMMENT_EDIT_FORBIDDEN: "只能编辑自己的批注。",
|
|
196
|
+
COMMENT_RESOLVE_FORBIDDEN: "只有可以编辑此项目的成员才能解决或重新打开批注。",
|
|
192
197
|
COMMENT_FILE_NOT_FOUND: "批注对应的文件不存在。",
|
|
193
198
|
COMMENT_NOT_FOUND: "批注不存在。",
|
|
194
199
|
COMMENT_RANGE_INVALID: "批注的源码区间无效。",
|
|
@@ -198,6 +203,9 @@ const zhMessages = {
|
|
|
198
203
|
COMPILE_ARTIFACTS_NOT_FOUND: "尚无可用的编译产物。",
|
|
199
204
|
COMPILE_CLEAN_BUSY: "当前主文档正在编译,请完成后再执行故障恢复。",
|
|
200
205
|
COMPILE_FORBIDDEN: "你没有编译此项目的权限。",
|
|
206
|
+
TIKZ_GALLERY_DISABLED: "此服务器未启用 TikZ 图库。",
|
|
207
|
+
TIKZ_GALLERY_UNAVAILABLE: "此服务器上找不到 TikZ 图库插件,请联系管理员安装。",
|
|
208
|
+
TIKZ_GALLERY_INCOMPATIBLE: "已安装的 TikZ 图库与当前 TexLite 版本不兼容,请联系管理员更新。",
|
|
201
209
|
COMPILE_SNAPSHOT_BUSY: "项目源码仍在保存,请稍后重新编译。",
|
|
202
210
|
CURRENT_PASSWORD_INVALID: "当前密码错误。",
|
|
203
211
|
PASSWORD_CHANGE_REQUIRED: "请先修改初始密码再继续。",
|
|
@@ -33,6 +33,7 @@ export const zhHantMessages = {
|
|
|
33
33
|
CLIENT_UPDATE_REQUIRED: "目前頁面版本過舊。請先儲存修改,再重新整理頁面,以繼續寫作檢查。",
|
|
34
34
|
COMMENT_DELETE_FORBIDDEN: "只能刪除自己的批註。",
|
|
35
35
|
COMMENT_EDIT_FORBIDDEN: "只能編輯自己的批註。",
|
|
36
|
+
COMMENT_RESOLVE_FORBIDDEN: "只有可以編輯此專案的成員才能解決或重新開啟批註。",
|
|
36
37
|
COMMENT_FILE_NOT_FOUND: "批註對應的檔案不存在。",
|
|
37
38
|
COMMENT_NOT_FOUND: "批註不存在。",
|
|
38
39
|
COMMENT_RANGE_INVALID: "批註的原始碼範圍無效。",
|
|
@@ -42,6 +43,9 @@ export const zhHantMessages = {
|
|
|
42
43
|
COMPILE_ARTIFACTS_NOT_FOUND: "尚無可用的編譯產出。",
|
|
43
44
|
COMPILE_CLEAN_BUSY: "目前主文件正在編譯,請完成後再執行故障排除。",
|
|
44
45
|
COMPILE_FORBIDDEN: "你沒有編譯此專案的權限。",
|
|
46
|
+
TIKZ_GALLERY_DISABLED: "此伺服器未啟用 TikZ 圖庫。",
|
|
47
|
+
TIKZ_GALLERY_UNAVAILABLE: "此伺服器上找不到 TikZ 圖庫外掛,請聯絡管理員安裝。",
|
|
48
|
+
TIKZ_GALLERY_INCOMPATIBLE: "已安裝的 TikZ 圖庫與目前 TexLite 版本不相容,請聯絡管理員更新。",
|
|
45
49
|
COMPILE_SNAPSHOT_BUSY: "專案原始碼仍在儲存,請稍後重新編譯。",
|
|
46
50
|
CURRENT_PASSWORD_INVALID: "目前密碼錯誤。",
|
|
47
51
|
PASSWORD_CHANGE_REQUIRED: "請先變更初始密碼再繼續。",
|
|
@@ -38,6 +38,10 @@ export class ProjectMutationCoordinator {
|
|
|
38
38
|
flushProject(projectId) {
|
|
39
39
|
return this.requireSuccessfulFlush(this.collaboration.flushProject(projectId));
|
|
40
40
|
}
|
|
41
|
+
/** See `CollaborationService.reconcileExternalSources`; call it inside a project operation. */
|
|
42
|
+
reconcileExternalSources(projectId, paths) {
|
|
43
|
+
this.collaboration.reconcileExternalSources(projectId, paths);
|
|
44
|
+
}
|
|
41
45
|
async runExclusive(projectId, reason, operation, options = {}) {
|
|
42
46
|
this.exclusivePending.set(projectId, (this.exclusivePending.get(projectId) ?? 0) + 1);
|
|
43
47
|
const exclusion = this.beginCompileExclusion(projectId);
|
|
@@ -4,7 +4,7 @@ import { requireUser } from "../auth.js";
|
|
|
4
4
|
import { createSourceAnchor, offsetToLine } from "../anchors.js";
|
|
5
5
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
6
6
|
import { apiError, httpError } from "../http.js";
|
|
7
|
-
import { accessibleProject } from "../projects.js";
|
|
7
|
+
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
8
|
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
9
9
|
import { attachSuggestion, suggestionReviewers, suggestionRow } from "../commentSuggestions.js";
|
|
10
10
|
import { registerSuggestionRoutes } from "./commentSuggestions.js";
|
|
@@ -201,7 +201,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
201
201
|
if (!user)
|
|
202
202
|
return;
|
|
203
203
|
const { id, commentId } = request.params;
|
|
204
|
-
|
|
204
|
+
const project = accessibleProject(db, id, user);
|
|
205
|
+
if (!project)
|
|
205
206
|
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
206
207
|
const comment = db.prepare("SELECT author_id, resolved, content FROM comments WHERE id = ? AND project_id = ?")
|
|
207
208
|
.get(commentId, id);
|
|
@@ -217,6 +218,10 @@ export function registerCommentRoutes(app, context) {
|
|
|
217
218
|
changed = true;
|
|
218
219
|
}
|
|
219
220
|
if (typeof body.resolved === "boolean") {
|
|
221
|
+
// Read-only members may discuss, but closing or reopening a thread is a
|
|
222
|
+
// review decision for people who can change the project.
|
|
223
|
+
if (!canEdit(project))
|
|
224
|
+
return apiError(reply, 403, "COMMENT_RESOLVE_FORBIDDEN");
|
|
220
225
|
if (body.resolved) {
|
|
221
226
|
const suggestion = suggestionRow(db, id, commentId);
|
|
222
227
|
if (suggestion?.status === "pending" && (suggestion.apply_update
|
|
@@ -5,7 +5,9 @@ import { randomUUID } from "node:crypto";
|
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
6
|
import { requireUser } from "../auth.js";
|
|
7
7
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
|
-
import { resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
|
|
8
|
+
import { outputRoot, resolveSourcePath, safeRelativePath, texFileStem } from "../files.js";
|
|
9
|
+
import { isStandaloneTikz } from "../../shared/tikzStandalone.js";
|
|
10
|
+
import { touchProject } from "./projectShared.js";
|
|
9
11
|
import { captureCompileSnapshot, cleanCompileArtifacts, cleanCompileCache, CompileCancelledError, compileProject, discardCompileSnapshot, hasCompileCache, publishCompileArtifacts, publishedCompileArtifacts } from "../compiler.js";
|
|
10
12
|
import { parseCompileDiagnostics } from "../compileDiagnostics.js";
|
|
11
13
|
import { pdfToSource, sourceToPdf } from "../synctex.js";
|
|
@@ -293,6 +295,50 @@ export function registerCompileRoutes(app, context) {
|
|
|
293
295
|
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
294
296
|
} });
|
|
295
297
|
});
|
|
298
|
+
// Copies the latest successful PDF of a standalone TikZ figure beside its
|
|
299
|
+
// source so that other documents can include it. A separate step because
|
|
300
|
+
// concurrent compile requests are coalesced into one run.
|
|
301
|
+
app.post("/api/projects/:id/compile/export-pdf", async (request, reply) => {
|
|
302
|
+
const user = requireUser(request, reply, db);
|
|
303
|
+
if (!user)
|
|
304
|
+
return;
|
|
305
|
+
const { id } = request.params;
|
|
306
|
+
const permitted = () => {
|
|
307
|
+
const project = accessibleProject(db, id, user);
|
|
308
|
+
if (!project || !canEdit(project))
|
|
309
|
+
throw httpError(403, "COMPILE_FORBIDDEN");
|
|
310
|
+
return project;
|
|
311
|
+
};
|
|
312
|
+
const body = (request.body ?? {});
|
|
313
|
+
return projectMutations.runWrite(id, () => {
|
|
314
|
+
const project = permitted();
|
|
315
|
+
const mainFile = compileMainFile(config, id, project.main_file, body.mainFile);
|
|
316
|
+
if (!mainFile)
|
|
317
|
+
throw httpError(400, "MAIN_DOCUMENT_INVALID");
|
|
318
|
+
if (!isStandaloneTikz(fs.readFileSync(resolveSourcePath(config, id, mainFile), "utf8")))
|
|
319
|
+
throw httpError(400, "REQUEST_INVALID");
|
|
320
|
+
const pdf = availablePdf(config, id, mainFile);
|
|
321
|
+
if (!pdf)
|
|
322
|
+
throw httpError(404, "PDF_NOT_FOUND");
|
|
323
|
+
const target = `${mainFile.slice(0, -".tex".length)}.pdf`;
|
|
324
|
+
const destination = resolveSourcePath(config, id, target);
|
|
325
|
+
if (fs.statSync(destination, { throwIfNoEntry: false })?.isDirectory())
|
|
326
|
+
throw httpError(409, "PATH_EXISTS");
|
|
327
|
+
// Staged outside the source tree, on the same filesystem, so collaborators
|
|
328
|
+
// and including documents only ever see a complete file.
|
|
329
|
+
const staged = path.join(outputRoot(config, id), `.export-${randomUUID()}.pdf`);
|
|
330
|
+
try {
|
|
331
|
+
fs.copyFileSync(pdf.path, staged);
|
|
332
|
+
fs.renameSync(staged, destination);
|
|
333
|
+
}
|
|
334
|
+
finally {
|
|
335
|
+
fs.rmSync(staged, { force: true });
|
|
336
|
+
}
|
|
337
|
+
touchProject(db, id, user.id);
|
|
338
|
+
collaboration.invalidateSourceTree(id, target);
|
|
339
|
+
return { path: target };
|
|
340
|
+
}, { preflight: () => { permitted(); } });
|
|
341
|
+
});
|
|
296
342
|
app.post("/api/projects/:id/compile/cancel", async (request, reply) => {
|
|
297
343
|
const user = requireUser(request, reply, db);
|
|
298
344
|
if (!user)
|
|
@@ -318,6 +364,12 @@ export function registerCompileRoutes(app, context) {
|
|
|
318
364
|
if (!initialProject || !canEdit(initialProject))
|
|
319
365
|
return apiError(reply, 403, "COMPILE_FORBIDDEN");
|
|
320
366
|
const body = (request.body ?? {});
|
|
367
|
+
const requestedEngine = config.allowedEngines.find((engine) => engine === body.engine);
|
|
368
|
+
if (body.engine !== undefined && !requestedEngine)
|
|
369
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
370
|
+
// For this run only; part of the compile generation and cache key, so a
|
|
371
|
+
// request for another engine is neither coalesced nor treated as up to date.
|
|
372
|
+
const withRequestedEngine = (row) => requestedEngine ? { ...row, engine: requestedEngine } : row;
|
|
321
373
|
const requestedMainFile = typeof body.mainFile === "string" && body.mainFile ? body.mainFile : null;
|
|
322
374
|
const initialMainFile = compileMainFile(config, id, initialProject.main_file, body.mainFile);
|
|
323
375
|
if (!initialMainFile)
|
|
@@ -348,9 +400,9 @@ export function registerCompileRoutes(app, context) {
|
|
|
348
400
|
}
|
|
349
401
|
const generationRevision = receipt?.revision ?? revisionBeforeFlush;
|
|
350
402
|
const admissionResult = {
|
|
351
|
-
project: refreshedProject,
|
|
403
|
+
project: withRequestedEngine(refreshedProject),
|
|
352
404
|
mainFile: currentMainFile,
|
|
353
|
-
generation: compileRequestGeneration(refreshedProject, generationRevision, collaboration.currentGeneration(id), config.extraArgs)
|
|
405
|
+
generation: compileRequestGeneration(withRequestedEngine(refreshedProject), generationRevision, collaboration.currentGeneration(id), config.extraArgs)
|
|
354
406
|
};
|
|
355
407
|
// Insert the queued probe while the project lock is still held. A
|
|
356
408
|
// concurrent clean request must observe this row before the compile
|
|
@@ -428,7 +480,7 @@ export function registerCompileRoutes(app, context) {
|
|
|
428
480
|
throw new Error("Selected main document is no longer available");
|
|
429
481
|
if (!requestedMainFile && currentMainFile !== mainFile)
|
|
430
482
|
throw mainDocumentChangedError();
|
|
431
|
-
project = currentProject;
|
|
483
|
+
project = withRequestedEngine(currentProject);
|
|
432
484
|
mainFile = currentMainFile;
|
|
433
485
|
// Capture only after all exclusive source-tree operations queued
|
|
434
486
|
// before this request have completed. A collaboration barrier
|