texlite 0.24.0 → 0.25.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 +85 -2
- package/NPM_TESTING.md +46 -2
- package/OPERATIONS.md +136 -6
- package/README.md +1 -2
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +12 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js +1 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.br +0 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.gz +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js +1 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.br +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js +2 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.br +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.gz +0 -0
- package/dist/client/assets/{AgentTerminalSurface-DliOcop5.js → AgentTerminalSurface-BLroKMGe.js} +1 -1
- package/dist/client/assets/{AgentTerminalSurface-DliOcop5.js.br → AgentTerminalSurface-BLroKMGe.js.br} +0 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-iuEbMO4a.js → AvatarSettingsDialog-BgVGfSzn.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-DLPom-qx.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.gz +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js +5 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.br +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.gz +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js +1 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.br +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.gz +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js +4 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.br +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.gz +0 -0
- package/dist/client/assets/{HistoryDialog-upkR8E0L.js → HistoryDialog-CcPWpTLn.js} +3 -3
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.br +0 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.gz +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js +25 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.br +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-_AXp5G7f.js → MarkdownPreview-Txs5upCY.js} +1 -1
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-BxjEYsau.js → ProjectIconPickerDialog-CUlPlfmL.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js +4 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.br +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js +25 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-HlkWqVR9.js → QuickOpenDialog-D6yjnquG.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.gz +0 -0
- package/dist/client/assets/{ReadOnlySource-BIdN1YP_.js → ReadOnlySource-BOAnB5L0.js} +1 -1
- package/dist/client/assets/{SelectionHistoryDialog-Cb8I-G6m.js → SelectionHistoryDialog-D6ql9E0j.js} +2 -2
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js +2 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js +1 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-5cgNbWiG.js +1 -0
- package/dist/client/assets/{TikzGalleryDialog-cPUDQ5Wj.js → TikzGalleryDialog-CFbLjNTt.js} +1 -1
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.gz +0 -0
- package/dist/client/assets/{WordCountDialog-AiuR3rra.js → WordCountDialog-hXC-cpPs.js} +1 -1
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.gz +0 -0
- package/dist/client/assets/{chktex--32C-Pkl.js → chktex-CLzMD_9a.js} +1 -1
- package/dist/client/assets/file-down-DA4jGFrF.js +1 -0
- package/dist/client/assets/i18n-B8sR-BXw.js +13 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.br +0 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.gz +0 -0
- package/dist/client/assets/index-D6faTuJe.css +1 -0
- package/dist/client/assets/index-D6faTuJe.css.br +0 -0
- package/dist/client/assets/index-D6faTuJe.css.gz +0 -0
- package/dist/client/assets/index-dScQ5LCu.js +2 -0
- package/dist/client/assets/index-dScQ5LCu.js.br +0 -0
- package/dist/client/assets/index-dScQ5LCu.js.gz +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js +1 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.br +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js +2 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.gz +0 -0
- package/dist/client/assets/{spellCheck-DpWPgtM7.js → spellCheck-DpyzDbmq.js} +1 -1
- package/dist/client/assets/spellCheck-DpyzDbmq.js.br +0 -0
- package/dist/client/assets/spellCheck-DpyzDbmq.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js +1 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.gz +0 -0
- package/dist/client/index.html +3 -4
- package/dist/server/agents/adapters/claude.js +5 -2
- package/dist/server/agents/adapters/common.js +18 -5
- package/dist/server/agents/execution.js +25 -4
- package/dist/server/agents/launcher.js +5 -2
- package/dist/server/agents/processIdentity.js +1 -1
- package/dist/server/agents/terminal.js +5 -2
- package/dist/server/agents/windowsJob.js +141 -0
- package/dist/server/app.js +24 -6
- package/dist/server/auth.js +3 -2
- package/dist/server/browserOrigin.js +15 -0
- package/dist/server/chktex.js +23 -11
- package/dist/server/collaboration.js +2 -1
- package/dist/server/compileDiagnostics.js +13 -9
- package/dist/server/compiler.js +70 -25
- package/dist/server/config.js +5 -1
- package/dist/server/db.js +4 -0
- package/dist/server/drawioLocks.js +114 -0
- package/dist/server/drawioOwnedBrowser.js +122 -0
- package/dist/server/drawioPdf.js +182 -0
- package/dist/server/environment.js +17 -8
- package/dist/server/files.js +86 -20
- package/dist/server/git.js +20 -16
- package/dist/server/harper.js +29 -10
- package/dist/server/history.js +62 -15
- package/dist/server/i18n.js +15 -0
- package/dist/server/index.js +15 -8
- package/dist/server/locales/zh-Hant.js +9 -0
- package/dist/server/pdfFonts.js +78 -0
- package/dist/server/pm2.js +2 -1
- package/dist/server/processTree.js +128 -7
- package/dist/server/projectDeletionCleanup.js +62 -0
- package/dist/server/projectMutations.js +3 -0
- package/dist/server/projectReplace.js +2 -2
- package/dist/server/projectSearch.js +2 -1
- package/dist/server/projectTemplateCache.js +94 -0
- package/dist/server/projectTemplateDownload.js +75 -0
- package/dist/server/projectTextSave.js +56 -0
- package/dist/server/routes/agents.js +2 -15
- package/dist/server/routes/compile.js +67 -9
- package/dist/server/routes/drawio.js +192 -0
- package/dist/server/routes/projectFiles.js +106 -20
- package/dist/server/routes/projects.js +81 -20
- package/dist/server/routes/users.js +10 -14
- package/dist/server/synctex.js +20 -3
- package/dist/server/texcount.js +27 -23
- package/dist/server/zip.js +37 -11
- package/dist/shared/drawio.js +79 -0
- package/dist/shared/fileTypes.js +1 -1
- package/dist/shared/pdfFonts.js +14 -0
- package/dist/shared/projectImport.js +21 -0
- package/package.json +3 -1
- package/dist/client/assets/AdminUsers-C-8tXzvj.js +0 -1
- 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/AgentManagement-DXgfP7l_.js +0 -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 +0 -2
- 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.gz +0 -0
- 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 +0 -1
- package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js +0 -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 +0 -5
- 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-DUGAigLx.js +0 -4
- 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-B4eD622i.js +0 -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.br +0 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js.gz +0 -0
- package/dist/client/assets/InfoPopover-CQ3Q10tN.js +0 -1
- package/dist/client/assets/LatexEditor-DvDYTc0r.js +0 -25
- 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-_AXp5G7f.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.gz +0 -0
- 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 +0 -1
- 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 +0 -4
- 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 +0 -25
- 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-HlkWqVR9.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.gz +0 -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 +0 -2
- 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-Dr4pYWG6.js +0 -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-D4fYVboy.js +0 -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-BgzkYTeA.js +0 -1
- 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.br +0 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +0 -1
- package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js +0 -13
- 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 +0 -2
- 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 +0 -1
- 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-CcP1IEvr.js +0 -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 +0 -1
- 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-DpWPgtM7.js.br +0 -0
- package/dist/client/assets/spellCheck-DpWPgtM7.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js +0 -1
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.gz +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { LATEX_ENGINES } from "./config.js";
|
|
3
3
|
import { httpError } from "./http.js";
|
|
4
|
-
import { detachedProcessGroup,
|
|
4
|
+
import { afterProcessStop, detachedProcessGroup, stopProcessTree } from "./processTree.js";
|
|
5
5
|
import { COMPILER_VERSION_TOOLS } from "../shared/compilerVersions.js";
|
|
6
6
|
export const MIN_NODE_MAJOR = 24;
|
|
7
7
|
const commandProbeTimeoutMs = 10_000;
|
|
@@ -91,6 +91,7 @@ function optionalToolDefinitions(gitCommand, gitTimeoutMs) {
|
|
|
91
91
|
return [
|
|
92
92
|
gitToolDefinition(gitCommand, gitTimeoutMs),
|
|
93
93
|
{ id: "texcount", name: "TeXcount", command: "texcount", requirement: "optional", purpose: "Word and character statistics", versionArgs: ["-version"] },
|
|
94
|
+
{ id: "pdffonts", name: "pdffonts", command: "pdffonts", requirement: "optional", purpose: "PDF font diagnostics", versionArgs: ["-v"] },
|
|
94
95
|
{ id: "bibtex", name: "BibTeX", command: "bibtex", requirement: "optional", purpose: "BibTeX bibliography builds" },
|
|
95
96
|
{ id: "biber", name: "Biber", command: "biber", requirement: "optional", purpose: "Biber bibliography builds" },
|
|
96
97
|
{ id: "makeindex", name: "MakeIndex", command: "makeindex", requirement: "optional", purpose: "Index generation", versionArgs: [] },
|
|
@@ -181,14 +182,19 @@ function commandVersion(command, timeoutMs, args) {
|
|
|
181
182
|
clearTimeout(timer);
|
|
182
183
|
resolve({ ...result, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") });
|
|
183
184
|
};
|
|
184
|
-
const
|
|
185
|
+
const terminate = () => {
|
|
186
|
+
void stopProcessTree(child).catch((error) => finish({ status: null, error: error.message, errorCode: null }));
|
|
187
|
+
};
|
|
188
|
+
const timer = setTimeout(() => { timedOut = true; terminate(); }, timeoutMs);
|
|
185
189
|
const collect = (target) => (chunk) => {
|
|
186
190
|
if (settled)
|
|
187
191
|
return;
|
|
188
192
|
outputBytes += chunk.length;
|
|
189
193
|
if (outputBytes > maxCommandOutputBytes) {
|
|
194
|
+
if (outputExceeded)
|
|
195
|
+
return;
|
|
190
196
|
outputExceeded = true;
|
|
191
|
-
|
|
197
|
+
terminate();
|
|
192
198
|
return;
|
|
193
199
|
}
|
|
194
200
|
target.push(chunk);
|
|
@@ -196,10 +202,13 @@ function commandVersion(command, timeoutMs, args) {
|
|
|
196
202
|
child.stdout.on("data", collect(stdout));
|
|
197
203
|
child.stderr.on("data", collect(stderr));
|
|
198
204
|
child.once("error", (error) => finish({ status: null, error: error.message, errorCode: error.code ?? null }));
|
|
199
|
-
child.once("close", (status) =>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
child.once("close", (status) => {
|
|
206
|
+
clearTimeout(timer);
|
|
207
|
+
afterProcessStop(child, () => finish({
|
|
208
|
+
status,
|
|
209
|
+
error: timedOut ? "command timed out" : outputExceeded ? "command produced too much output" : null,
|
|
210
|
+
errorCode: null
|
|
211
|
+
}), (error) => finish({ status: null, error: error.message, errorCode: null }));
|
|
212
|
+
});
|
|
204
213
|
});
|
|
205
214
|
}
|
package/dist/server/files.js
CHANGED
|
@@ -39,7 +39,7 @@ export async function duplicateProjectFiles(config, sourceProjectId, targetProje
|
|
|
39
39
|
for (const entry of entries) {
|
|
40
40
|
if (entry.isSymbolicLink())
|
|
41
41
|
throw symbolicLinkError(entry.name);
|
|
42
|
-
if (entry.name
|
|
42
|
+
if (isGitEntry(entry.name))
|
|
43
43
|
continue;
|
|
44
44
|
await fs.promises.cp(path.join(source, entry.name), path.join(target, entry.name), {
|
|
45
45
|
recursive: true, errorOnExist: true, force: false, verbatimSymlinks: false
|
|
@@ -48,27 +48,38 @@ export async function duplicateProjectFiles(config, sourceProjectId, targetProje
|
|
|
48
48
|
}
|
|
49
49
|
await fs.promises.mkdir(outputRoot(config, targetProjectId), { recursive: true, mode: 0o700 });
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const windowsDeviceName = /^(?:con|prn|aux|nul|conin\$|conout\$|(?:com|lpt)[1-9¹²³])$/i;
|
|
52
|
+
export function safeRelativePath(input, platform = process.platform) {
|
|
53
|
+
const windows = platform === "win32";
|
|
54
|
+
if (!input || input.includes("\0") || (windows ? path.win32 : path.posix).isAbsolute(input)) {
|
|
53
55
|
throw httpError(400, "INVALID_PATH");
|
|
54
56
|
}
|
|
55
57
|
const normalized = path.posix.normalize(input.replaceAll("\\", "/"));
|
|
56
58
|
if (normalized === "." || normalized === ".." || normalized.startsWith("../")) {
|
|
57
59
|
throw httpError(400, "INVALID_PATH");
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
const segments = normalized.split("/");
|
|
62
|
+
if (windows && segments.some((segment) => /^ |[\x00-\x1f<>:"|?*]|[. ]$/.test(segment)
|
|
63
|
+
|| windowsDeviceName.test(segment.split(".", 1)[0].replace(/ +$/, "")))) {
|
|
64
|
+
throw httpError(400, "INVALID_PATH");
|
|
65
|
+
}
|
|
66
|
+
if (segments.some((segment) => (windows ? segment.toLowerCase() : segment.toLocaleLowerCase()) === ".git")) {
|
|
60
67
|
throw httpError(400, "RESERVED_PATH");
|
|
61
68
|
}
|
|
62
69
|
return normalized;
|
|
63
70
|
}
|
|
64
71
|
/** Validate a user-provided file or directory name used within one folder. */
|
|
65
72
|
export function safePathSegment(input) {
|
|
66
|
-
const
|
|
67
|
-
|
|
73
|
+
const trimmed = input.trim();
|
|
74
|
+
const name = process.platform === "win32" ? input : trimmed;
|
|
75
|
+
if (!trimmed || name.includes("\0") || name.includes("/") || name.includes("\\")) {
|
|
68
76
|
throw httpError(400, "INVALID_PATH");
|
|
69
77
|
}
|
|
70
78
|
return safeRelativePath(name);
|
|
71
79
|
}
|
|
80
|
+
function isGitEntry(name) {
|
|
81
|
+
return (process.platform === "win32" ? name.toLowerCase() : name) === ".git";
|
|
82
|
+
}
|
|
72
83
|
export function symbolicLinkError(relativePath) {
|
|
73
84
|
return httpError(409, "SYMLINK_FORBIDDEN", { path: relativePath || "source" });
|
|
74
85
|
}
|
|
@@ -77,7 +88,7 @@ export function symbolicLinkError(relativePath) {
|
|
|
77
88
|
* resolving it. `stat()` and most file APIs follow links, so a lexical
|
|
78
89
|
* `safeRelativePath()` check alone is not sufficient after a Git checkout.
|
|
79
90
|
*/
|
|
80
|
-
function assertSourcePathComponents(config, projectId, relativePath,
|
|
91
|
+
function assertSourcePathComponents(config, projectId, relativePath, options = {}) {
|
|
81
92
|
let current = projectRoot(config, projectId);
|
|
82
93
|
const segments = ["source", ...relativePath.split("/").filter(Boolean)];
|
|
83
94
|
const projectStat = lstatIfPresent(current);
|
|
@@ -89,10 +100,22 @@ function assertSourcePathComponents(config, projectId, relativePath, allowFinalS
|
|
|
89
100
|
if (!stat)
|
|
90
101
|
return;
|
|
91
102
|
const isFinal = index === segments.length - 1;
|
|
92
|
-
if (stat.isSymbolicLink() && !(allowFinalSymlink && isFinal && relativePath.length > 0)) {
|
|
103
|
+
if (stat.isSymbolicLink() && !(options.allowFinalSymlink && isFinal && relativePath.length > 0)) {
|
|
93
104
|
const displayed = relativePath || segments.slice(0, index + 1).join("/");
|
|
94
105
|
throw symbolicLinkError(displayed);
|
|
95
106
|
}
|
|
107
|
+
if (process.platform === "win32" && index > 0 && !stat.isSymbolicLink()) {
|
|
108
|
+
const actualName = path.basename(fs.realpathSync.native(current));
|
|
109
|
+
if (isGitEntry(actualName))
|
|
110
|
+
throw httpError(400, "RESERVED_PATH");
|
|
111
|
+
const requestedName = segments[index];
|
|
112
|
+
if (requestedName !== actualName && !(isFinal && options.allowFinalCaseAlias
|
|
113
|
+
&& requestedName.toLowerCase() === actualName.toLowerCase())) {
|
|
114
|
+
// Do not let differently cased or DOS short aliases open separate
|
|
115
|
+
// Yjs rooms, hold independent locks, or bypass reserved paths.
|
|
116
|
+
throw httpError(400, "INVALID_PATH");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
121
|
function lstatIfPresent(target) {
|
|
@@ -121,7 +144,7 @@ export function assertNoSymbolicLinks(root, ignoreGitDirectory = false) {
|
|
|
121
144
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
122
145
|
if (entry.isSymbolicLink())
|
|
123
146
|
throw symbolicLinkError(relative);
|
|
124
|
-
if (ignoreGitDirectory && entry.name
|
|
147
|
+
if (ignoreGitDirectory && isGitEntry(entry.name))
|
|
125
148
|
continue;
|
|
126
149
|
if (entry.isDirectory())
|
|
127
150
|
visit(path.join(directory, entry.name), relative);
|
|
@@ -140,9 +163,32 @@ export function texFileStem(input) {
|
|
|
140
163
|
}
|
|
141
164
|
export function resolveSourcePath(config, projectId, input, options = {}) {
|
|
142
165
|
const relativePath = safeRelativePath(input);
|
|
143
|
-
assertSourcePathComponents(config, projectId, relativePath, options
|
|
166
|
+
assertSourcePathComponents(config, projectId, relativePath, options);
|
|
144
167
|
return path.join(sourceRoot(config, projectId), relativePath);
|
|
145
168
|
}
|
|
169
|
+
export function resolveProjectMoveDestination(config, projectId, source, destination) {
|
|
170
|
+
const caseOnly = process.platform === "win32" && source !== destination
|
|
171
|
+
&& path.posix.dirname(source) === path.posix.dirname(destination)
|
|
172
|
+
&& source.toLowerCase() === destination.toLowerCase();
|
|
173
|
+
const target = resolveSourcePath(config, projectId, destination, { allowFinalCaseAlias: caseOnly });
|
|
174
|
+
if (lstatIfPresent(target) && (!caseOnly || fs.realpathSync.native(target)
|
|
175
|
+
!== fs.realpathSync.native(resolveSourcePath(config, projectId, source)))) {
|
|
176
|
+
throw httpError(409, "PATH_EXISTS", { path: destination });
|
|
177
|
+
}
|
|
178
|
+
return target;
|
|
179
|
+
}
|
|
180
|
+
/** Surface sharing failures without falling back to non-atomic writes. */
|
|
181
|
+
export function renameProjectPath(source, destination) {
|
|
182
|
+
try {
|
|
183
|
+
fs.renameSync(source, destination);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
if (process.platform === "win32" && ["EBUSY", "EPERM", "EACCES"].includes(error.code ?? "")) {
|
|
187
|
+
throw httpError(409, "PROJECT_PATH_BUSY");
|
|
188
|
+
}
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
146
192
|
export function listProjectFiles(config, projectId) {
|
|
147
193
|
const root = sourceRoot(config, projectId);
|
|
148
194
|
const result = [];
|
|
@@ -155,7 +201,7 @@ export function listProjectFiles(config, projectId) {
|
|
|
155
201
|
const absolute = path.join(directory, entry.name);
|
|
156
202
|
if (entry.isSymbolicLink())
|
|
157
203
|
throw symbolicLinkError(relative);
|
|
158
|
-
if (entry.name
|
|
204
|
+
if (isGitEntry(entry.name))
|
|
159
205
|
continue;
|
|
160
206
|
if (entry.isDirectory()) {
|
|
161
207
|
result.push({ path: relative, type: "directory" });
|
|
@@ -212,7 +258,7 @@ export async function listProjectFilesAsync(config, projectId) {
|
|
|
212
258
|
const absolute = path.join(directory, entry.name);
|
|
213
259
|
if (entry.isSymbolicLink())
|
|
214
260
|
throw symbolicLinkError(relative);
|
|
215
|
-
if (entry.name
|
|
261
|
+
if (isGitEntry(entry.name))
|
|
216
262
|
continue;
|
|
217
263
|
if (entry.isDirectory()) {
|
|
218
264
|
result.push({ path: relative, type: "directory" });
|
|
@@ -245,18 +291,38 @@ export async function listProjectFilesAsync(config, projectId) {
|
|
|
245
291
|
}
|
|
246
292
|
return result.sort((left, right) => left.path.localeCompare(right.path));
|
|
247
293
|
}
|
|
294
|
+
const trashRemovalOptions = {
|
|
295
|
+
recursive: true, force: true,
|
|
296
|
+
...(process.platform === "win32" ? { maxRetries: 3, retryDelay: 100 } : {})
|
|
297
|
+
};
|
|
298
|
+
function trashDestination(config, label) {
|
|
299
|
+
const trash = path.join(config.dataDir, "trash");
|
|
300
|
+
fs.mkdirSync(trash, { recursive: true, mode: 0o700 });
|
|
301
|
+
return path.join(trash, `${label}-${Date.now()}-${randomUUID()}`);
|
|
302
|
+
}
|
|
303
|
+
function retirePath(absolute, target) {
|
|
304
|
+
renameProjectPath(absolute, target);
|
|
305
|
+
// If a handle is still open, the startup trash sweep retries it. The
|
|
306
|
+
// retired path cannot partially disappear from the active source tree.
|
|
307
|
+
void fs.promises.rm(target, trashRemovalOptions).catch(() => undefined);
|
|
308
|
+
}
|
|
309
|
+
export function removeProjectSourcePath(config, absolute) {
|
|
310
|
+
if (process.platform === "win32")
|
|
311
|
+
retirePath(absolute, trashDestination(config, "source"));
|
|
312
|
+
else
|
|
313
|
+
fs.rmSync(absolute, { recursive: true, force: true });
|
|
314
|
+
}
|
|
248
315
|
export function removeProjectDirectory(config, projectId) {
|
|
249
316
|
const root = projectRoot(config, projectId);
|
|
250
|
-
if (!
|
|
317
|
+
if (!lstatIfPresent(root))
|
|
251
318
|
return;
|
|
252
|
-
const
|
|
253
|
-
fs.mkdirSync(trash, { recursive: true, mode: 0o700 });
|
|
254
|
-
const target = path.join(trash, `${projectId}-${Date.now()}-${randomUUID()}`);
|
|
319
|
+
const target = trashDestination(config, projectId);
|
|
255
320
|
try {
|
|
256
|
-
|
|
257
|
-
void fs.promises.rm(target, { recursive: true, force: true }).catch(() => undefined);
|
|
321
|
+
retirePath(root, target);
|
|
258
322
|
}
|
|
259
|
-
catch {
|
|
323
|
+
catch (error) {
|
|
324
|
+
if (process.platform === "win32")
|
|
325
|
+
throw error;
|
|
260
326
|
fs.rmSync(root, { recursive: true, force: true });
|
|
261
327
|
if (fs.existsSync(root)) {
|
|
262
328
|
throw new Error(`Unable to remove project directory: ${root}`);
|
|
@@ -270,7 +336,7 @@ export async function pruneTrashDirectory(config) {
|
|
|
270
336
|
if (!fs.existsSync(dir))
|
|
271
337
|
continue;
|
|
272
338
|
const entries = await fs.promises.readdir(dir);
|
|
273
|
-
await Promise.allSettled(entries.map((entry) => fs.promises.rm(path.join(dir, entry),
|
|
339
|
+
await Promise.allSettled(entries.map((entry) => fs.promises.rm(path.join(dir, entry), trashRemovalOptions)));
|
|
274
340
|
}
|
|
275
341
|
catch {
|
|
276
342
|
// Ignore error
|
package/dist/server/git.js
CHANGED
|
@@ -5,7 +5,7 @@ import { spawn } from "node:child_process";
|
|
|
5
5
|
import { assertGitAvailable } from "./environment.js";
|
|
6
6
|
import { assertNoSourceSymlinks, sourceRoot, symbolicLinkError } from "./files.js";
|
|
7
7
|
import { httpError } from "./http.js";
|
|
8
|
-
import { detachedProcessGroup,
|
|
8
|
+
import { afterProcessStop, detachedProcessGroup, spawnOwnedCommand, stopProcessTree } from "./processTree.js";
|
|
9
9
|
const MAX_COMMAND_OUTPUT = 8 * 1024 * 1024;
|
|
10
10
|
const MAX_DIFF_OUTPUT = 1024 * 1024;
|
|
11
11
|
// Conflict recovery copies are local safety artifacts, never backup content.
|
|
@@ -417,9 +417,10 @@ export class ProjectGitService {
|
|
|
417
417
|
async git(cwd, args, allowedCodes = [], env = process.env) {
|
|
418
418
|
await this.ensureGitAvailable();
|
|
419
419
|
return new Promise((resolve, reject) => {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
})
|
|
420
|
+
// A push can leave SSH, credential helpers and remote helpers behind.
|
|
421
|
+
// Fast local status/history commands avoid the Windows job setup cost.
|
|
422
|
+
const child = args[0] === "push" ? spawnOwnedCommand(this.config.git, args, { cwd, env })
|
|
423
|
+
: spawn(this.config.git, args, { cwd, env, shell: false, detached: detachedProcessGroup(), stdio: ["ignore", "pipe", "pipe"] });
|
|
423
424
|
const stdout = [];
|
|
424
425
|
const stderr = [];
|
|
425
426
|
let size = 0;
|
|
@@ -429,7 +430,7 @@ export class ProjectGitService {
|
|
|
429
430
|
if (terminated)
|
|
430
431
|
return;
|
|
431
432
|
terminated = true;
|
|
432
|
-
|
|
433
|
+
void stopProcessTree(child).catch(fail);
|
|
433
434
|
};
|
|
434
435
|
const timer = setTimeout(() => { timedOut = true; terminate(); }, this.config.gitOperationTimeoutMs);
|
|
435
436
|
const collect = (target) => (chunk) => {
|
|
@@ -441,19 +442,22 @@ export class ProjectGitService {
|
|
|
441
442
|
};
|
|
442
443
|
child.stdout.on("data", collect(stdout));
|
|
443
444
|
child.stderr.on("data", collect(stderr));
|
|
444
|
-
|
|
445
|
+
function fail() { clearTimeout(timer); reject(httpError(500, "GIT_OPERATION_FAILED")); }
|
|
446
|
+
child.once("error", fail);
|
|
445
447
|
child.once("close", (code) => {
|
|
446
448
|
clearTimeout(timer);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
449
|
+
afterProcessStop(child, () => {
|
|
450
|
+
const result = { stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8"), code: code ?? -1 };
|
|
451
|
+
if (timedOut)
|
|
452
|
+
return reject(httpError(504, "GIT_TIMEOUT"));
|
|
453
|
+
if (size > MAX_COMMAND_OUTPUT)
|
|
454
|
+
return reject(httpError(413, "GIT_OUTPUT_TOO_LARGE"));
|
|
455
|
+
if (result.code !== 0 && !allowedCodes.includes(result.code)) {
|
|
456
|
+
const pushAuthError = args[0] === "push" ? classifyGitPushFailure(result.stderr) : null;
|
|
457
|
+
return reject(httpError(400, pushAuthError ?? "GIT_COMMAND_FAILED"));
|
|
458
|
+
}
|
|
459
|
+
resolve(result);
|
|
460
|
+
}, fail);
|
|
457
461
|
});
|
|
458
462
|
});
|
|
459
463
|
}
|
package/dist/server/harper.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { afterProcessStop, stopProcessTree } from "./processTree.js";
|
|
2
3
|
import { createHash } from "node:crypto";
|
|
3
4
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
4
5
|
import { tmpdir } from "node:os";
|
|
@@ -221,7 +222,12 @@ export class HarperService {
|
|
|
221
222
|
}
|
|
222
223
|
this.waitingByLane.clear();
|
|
223
224
|
this.latestSequenceByLane.clear();
|
|
224
|
-
this.activeChild
|
|
225
|
+
if (this.activeChild) {
|
|
226
|
+
if (process.platform === "win32")
|
|
227
|
+
await stopProcessTree(this.activeChild).catch(() => undefined);
|
|
228
|
+
else
|
|
229
|
+
this.activeChild.kill("SIGTERM");
|
|
230
|
+
}
|
|
225
231
|
await this.queueRunner?.catch(() => undefined);
|
|
226
232
|
this.inFlight.clear();
|
|
227
233
|
this.scheduledByKey.clear();
|
|
@@ -408,6 +414,7 @@ export class HarperService {
|
|
|
408
414
|
const stderr = [];
|
|
409
415
|
let outputBytes = 0;
|
|
410
416
|
let settled = false;
|
|
417
|
+
let terminationError;
|
|
411
418
|
let timer;
|
|
412
419
|
const finish = (callback) => {
|
|
413
420
|
if (settled)
|
|
@@ -420,15 +427,24 @@ export class HarperService {
|
|
|
420
427
|
callback();
|
|
421
428
|
};
|
|
422
429
|
const fail = (error) => finish(() => reject(error));
|
|
430
|
+
const terminate = (error) => {
|
|
431
|
+
if (settled || terminationError)
|
|
432
|
+
return;
|
|
433
|
+
if (process.platform !== "win32") {
|
|
434
|
+
child.kill("SIGTERM");
|
|
435
|
+
fail(error);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
terminationError = error;
|
|
439
|
+
void stopProcessTree(child).then(() => fail(error), fail);
|
|
440
|
+
};
|
|
423
441
|
timer = setTimeout(() => {
|
|
424
|
-
|
|
425
|
-
fail(new Error(`${this.command} timed out after ${Math.ceil(timeoutMs / 1000)} seconds.`));
|
|
442
|
+
terminate(new Error(`${this.command} timed out after ${Math.ceil(timeoutMs / 1000)} seconds.`));
|
|
426
443
|
}, timeoutMs);
|
|
427
444
|
const collect = (target) => (chunk) => {
|
|
428
445
|
outputBytes += chunk.length;
|
|
429
446
|
if (outputBytes > outputLimit) {
|
|
430
|
-
|
|
431
|
-
fail(new Error(`${this.command} produced too much output.`));
|
|
447
|
+
terminate(new Error(`${this.command} produced too much output.`));
|
|
432
448
|
return;
|
|
433
449
|
}
|
|
434
450
|
target.push(chunk);
|
|
@@ -436,11 +452,14 @@ export class HarperService {
|
|
|
436
452
|
child.stdout.on("data", collect(stdout));
|
|
437
453
|
child.stderr.on("data", collect(stderr));
|
|
438
454
|
child.once("error", (error) => fail(error));
|
|
439
|
-
child.once("close", (code) =>
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
455
|
+
child.once("close", (code) => {
|
|
456
|
+
clearTimeout(timer);
|
|
457
|
+
afterProcessStop(child, () => finish(() => {
|
|
458
|
+
if (terminationError)
|
|
459
|
+
return reject(terminationError);
|
|
460
|
+
resolve({ code, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") });
|
|
461
|
+
}), fail);
|
|
462
|
+
});
|
|
444
463
|
});
|
|
445
464
|
}
|
|
446
465
|
}
|
package/dist/server/history.js
CHANGED
|
@@ -33,12 +33,15 @@ const METADATA_BYTES_SQL = `(octet_length(id) + octet_length(project_id) + COALE
|
|
|
33
33
|
+ octet_length(changed_paths_json) + octet_length(created_at))`;
|
|
34
34
|
const DEFAULT_HISTORY_PAGE_SIZE = 100;
|
|
35
35
|
const MAX_HISTORY_PAGE_SIZE = 100;
|
|
36
|
+
const restoreCleanupPattern = /^\.history-cleanup-[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;
|
|
36
37
|
export class ProjectHistoryService {
|
|
37
38
|
config;
|
|
38
39
|
db;
|
|
39
|
-
|
|
40
|
+
onRestoreCleanupError;
|
|
41
|
+
constructor(config, db, onRestoreCleanupError = () => undefined) {
|
|
40
42
|
this.config = config;
|
|
41
43
|
this.db = db;
|
|
44
|
+
this.onRestoreCleanupError = onRestoreCleanupError;
|
|
42
45
|
}
|
|
43
46
|
record(projectId, authorId, reason, changedRoots, options = {}) {
|
|
44
47
|
const project = this.project(projectId);
|
|
@@ -402,8 +405,6 @@ export class ProjectHistoryService {
|
|
|
402
405
|
return { restoredPaths: [filePath], manifest };
|
|
403
406
|
}
|
|
404
407
|
this.restoreProjectTree(projectId, manifest);
|
|
405
|
-
this.db.prepare("UPDATE projects SET main_file = ?, engine = ?, latexmkrc = ?, chktex_enabled = ? WHERE id = ?")
|
|
406
|
-
.run(manifest.settings.mainFile, manifest.settings.engine, manifest.settings.latexmkrc, manifest.settings.chktexEnabled ? 1 : 0, projectId);
|
|
407
408
|
return { restoredPaths: Object.keys(manifest.files).sort(), manifest };
|
|
408
409
|
}
|
|
409
410
|
checkpointForRestore(projectId, authorId, versionId, filePathInput) {
|
|
@@ -761,12 +762,42 @@ export class ProjectHistoryService {
|
|
|
761
762
|
fs.rmSync(this.objectPath(projectId, digest), { force: true });
|
|
762
763
|
}
|
|
763
764
|
}
|
|
765
|
+
/** Called at startup, before any restore can run. Unmarked backups may
|
|
766
|
+
* belong to an interrupted restore and must never be deleted here. */
|
|
767
|
+
pruneRestoreBackups(projectId) {
|
|
768
|
+
const root = projectRoot(this.config, projectId);
|
|
769
|
+
let entries;
|
|
770
|
+
try {
|
|
771
|
+
if (!fs.lstatSync(root).isDirectory())
|
|
772
|
+
return;
|
|
773
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
774
|
+
}
|
|
775
|
+
catch (error) {
|
|
776
|
+
if (error.code !== "ENOENT")
|
|
777
|
+
this.onRestoreCleanupError(error, root);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
for (const entry of entries) {
|
|
781
|
+
if (entry.isDirectory() && restoreCleanupPattern.test(entry.name)) {
|
|
782
|
+
this.removeRestoreDirectory(path.join(root, entry.name));
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
removeRestoreDirectory(directory) {
|
|
787
|
+
try {
|
|
788
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
789
|
+
}
|
|
790
|
+
catch (error) {
|
|
791
|
+
this.onRestoreCleanupError(error, directory);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
764
794
|
restoreProjectTree(projectId, manifest) {
|
|
765
795
|
assertNoSourceSymlinks(this.config, projectId);
|
|
766
796
|
const root = projectRoot(this.config, projectId);
|
|
767
797
|
const live = sourceRoot(this.config, projectId);
|
|
768
|
-
const
|
|
769
|
-
const
|
|
798
|
+
const restoreId = randomUUID();
|
|
799
|
+
const temporary = path.join(root, `.history-restore-${restoreId}`);
|
|
800
|
+
const backup = path.join(root, `.history-backup-${restoreId}`);
|
|
770
801
|
fs.mkdirSync(temporary, { recursive: true, mode: 0o700 });
|
|
771
802
|
let liveMoved = false;
|
|
772
803
|
let replacementInstalled = false;
|
|
@@ -810,22 +841,38 @@ export class ProjectHistoryService {
|
|
|
810
841
|
fs.renameSync(git, path.join(live, ".git"));
|
|
811
842
|
gitMoved = true;
|
|
812
843
|
}
|
|
813
|
-
|
|
844
|
+
this.db.prepare("UPDATE projects SET main_file = ?, engine = ?, latexmkrc = ?, chktex_enabled = ? WHERE id = ?")
|
|
845
|
+
.run(manifest.settings.mainFile, manifest.settings.engine, manifest.settings.latexmkrc, manifest.settings.chktexEnabled ? 1 : 0, projectId);
|
|
814
846
|
}
|
|
815
847
|
catch (error) {
|
|
816
|
-
//
|
|
817
|
-
//
|
|
818
|
-
|
|
819
|
-
if (
|
|
820
|
-
|
|
848
|
+
// The backup is still intact. Swap the replacement out before deleting
|
|
849
|
+
// anything, so another cleanup failure cannot strand the live tree.
|
|
850
|
+
try {
|
|
851
|
+
if (replacementInstalled) {
|
|
852
|
+
if (gitMoved)
|
|
853
|
+
fs.renameSync(path.join(live, ".git"), path.join(backup, ".git"));
|
|
854
|
+
fs.renameSync(live, temporary);
|
|
821
855
|
}
|
|
822
|
-
|
|
856
|
+
if (liveMoved)
|
|
857
|
+
fs.renameSync(backup, live);
|
|
858
|
+
}
|
|
859
|
+
catch (rollbackError) {
|
|
860
|
+
throw new AggregateError([error, rollbackError], "Could not roll back project snapshot restore");
|
|
823
861
|
}
|
|
824
|
-
|
|
825
|
-
fs.renameSync(backup, live);
|
|
826
|
-
fs.rmSync(temporary, { recursive: true, force: true });
|
|
862
|
+
this.removeRestoreDirectory(temporary);
|
|
827
863
|
throw error;
|
|
828
864
|
}
|
|
865
|
+
// Both the source swap and the settings update succeeded. Mark this
|
|
866
|
+
// backup as disposable before attempting any non-atomic deletion.
|
|
867
|
+
const cleanup = path.join(root, `.history-cleanup-${restoreId}`);
|
|
868
|
+
try {
|
|
869
|
+
fs.renameSync(backup, cleanup);
|
|
870
|
+
}
|
|
871
|
+
catch (error) {
|
|
872
|
+
this.onRestoreCleanupError(error, backup);
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
this.removeRestoreDirectory(cleanup);
|
|
829
876
|
}
|
|
830
877
|
}
|
|
831
878
|
function settings(project) {
|
package/dist/server/i18n.js
CHANGED
|
@@ -10,7 +10,13 @@ import { suggestionMessages } from "../shared/suggestionMessages.js";
|
|
|
10
10
|
import { viewLinkMessages } from "../shared/projectViewLinks.js";
|
|
11
11
|
import { citationCollectionMessages } from "../shared/citationCollections.js";
|
|
12
12
|
import { projectSearchMessages } from "../shared/projectSearch.js";
|
|
13
|
+
import { projectImportMessages } from "../shared/projectImport.js";
|
|
14
|
+
import { pdfFontMessages } from "../shared/pdfFonts.js";
|
|
15
|
+
import { drawioMessages } from "../shared/drawio.js";
|
|
13
16
|
const enMessages = {
|
|
17
|
+
...drawioMessages.en.errors,
|
|
18
|
+
...pdfFontMessages.en,
|
|
19
|
+
...projectImportMessages.en,
|
|
14
20
|
...projectSearchMessages.en,
|
|
15
21
|
...citationCollectionMessages.en,
|
|
16
22
|
...viewLinkMessages.en,
|
|
@@ -49,6 +55,7 @@ const enMessages = {
|
|
|
49
55
|
COMPILE_ARTIFACTS_NOT_FOUND: "No compiled artifacts are available yet.",
|
|
50
56
|
COMPILE_CLEAN_BUSY: "This root document is compiling. Try recovery again after it finishes.",
|
|
51
57
|
COMPILE_FORBIDDEN: "You do not have permission to compile this project.",
|
|
58
|
+
LATEX_ENGINE_UNAVAILABLE: "{{engine}} is unavailable on this server. Select another engine in LaTeX settings or ask an administrator to enable it.",
|
|
52
59
|
TIKZ_GALLERY_DISABLED: "The TikZ gallery is not enabled on this server.",
|
|
53
60
|
TIKZ_GALLERY_UNAVAILABLE: "The TikZ gallery add-on was not found on this server. Ask an administrator to install it.",
|
|
54
61
|
TIKZ_GALLERY_INCOMPATIBLE: "The installed TikZ gallery is not compatible with this version of TexLite. Ask an administrator to update it.",
|
|
@@ -101,6 +108,7 @@ const enMessages = {
|
|
|
101
108
|
OWNER_MEMBER_FORBIDDEN: "The project owner cannot be added as a member.",
|
|
102
109
|
PASSWORD_TOO_SHORT: "The password must contain at least {{minLength}} characters.",
|
|
103
110
|
PATH_EXISTS: "The destination path is already used by a file or folder.",
|
|
111
|
+
PROJECT_PATH_BUSY: "The file or folder may be in use or access was denied. Close it and try again.",
|
|
104
112
|
PATH_NOT_FOUND: "The file or folder does not exist.",
|
|
105
113
|
PDF_NOT_FOUND: "No PDF has been generated yet.",
|
|
106
114
|
PROJECT_BUSY: "The project is performing a source-file operation. Try again shortly.",
|
|
@@ -142,6 +150,7 @@ const enMessages = {
|
|
|
142
150
|
WORD_COUNT_SOURCE_TOO_LARGE: "The selected source is too large to count.",
|
|
143
151
|
WORD_COUNT_UNAVAILABLE: "The TeX Live texcount package is not installed on this server. Install it and try again.",
|
|
144
152
|
ZIP_DUPLICATE_ENTRY: "The ZIP archive contains a duplicate filename: {{path}}.",
|
|
153
|
+
ZIP_PATH_CONFLICT: "The ZIP archive contains conflicting Windows paths: {{path}}.",
|
|
145
154
|
ZIP_ENTRY_READ_FAILED: "A ZIP archive entry could not be read.",
|
|
146
155
|
ZIP_ENTRY_TOO_LARGE: "The ZIP archive contains a file that exceeds the permitted size.",
|
|
147
156
|
ZIP_INVALID: "The ZIP archive could not be imported.",
|
|
@@ -165,6 +174,9 @@ const enMessages = {
|
|
|
165
174
|
GIT_OPERATION_FAILED: "The Git operation could not be completed."
|
|
166
175
|
};
|
|
167
176
|
const zhMessages = {
|
|
177
|
+
...drawioMessages.zh.errors,
|
|
178
|
+
...pdfFontMessages.zh,
|
|
179
|
+
...projectImportMessages.zh,
|
|
168
180
|
...viewLinkMessages.zh,
|
|
169
181
|
...projectSearchMessages.zh,
|
|
170
182
|
...citationCollectionMessages.zh,
|
|
@@ -203,6 +215,7 @@ const zhMessages = {
|
|
|
203
215
|
COMPILE_ARTIFACTS_NOT_FOUND: "尚无可用的编译产物。",
|
|
204
216
|
COMPILE_CLEAN_BUSY: "当前主文档正在编译,请完成后再执行故障恢复。",
|
|
205
217
|
COMPILE_FORBIDDEN: "你没有编译此项目的权限。",
|
|
218
|
+
LATEX_ENGINE_UNAVAILABLE: "此服务器上的 {{engine}} 不可用。请在 LaTeX 设置中切换引擎,或联系管理员启用。",
|
|
206
219
|
TIKZ_GALLERY_DISABLED: "此服务器未启用 TikZ 图库。",
|
|
207
220
|
TIKZ_GALLERY_UNAVAILABLE: "此服务器上找不到 TikZ 图库插件,请联系管理员安装。",
|
|
208
221
|
TIKZ_GALLERY_INCOMPATIBLE: "已安装的 TikZ 图库与当前 TexLite 版本不兼容,请联系管理员更新。",
|
|
@@ -255,6 +268,7 @@ const zhMessages = {
|
|
|
255
268
|
OWNER_MEMBER_FORBIDDEN: "项目所有者不能作为成员添加。",
|
|
256
269
|
PASSWORD_TOO_SHORT: "密码至少需要 {{minLength}} 个字符。",
|
|
257
270
|
PATH_EXISTS: "目标路径已被文件或文件夹占用。",
|
|
271
|
+
PROJECT_PATH_BUSY: "文件或文件夹可能正在使用,或无法访问。请关闭后重试。",
|
|
258
272
|
PATH_NOT_FOUND: "文件或文件夹不存在。",
|
|
259
273
|
PDF_NOT_FOUND: "尚未生成 PDF。",
|
|
260
274
|
PROJECT_BUSY: "项目正在执行源文件操作,请稍后重试。",
|
|
@@ -296,6 +310,7 @@ const zhMessages = {
|
|
|
296
310
|
WORD_COUNT_SOURCE_TOO_LARGE: "所选源码过大,无法统计。",
|
|
297
311
|
WORD_COUNT_UNAVAILABLE: "服务器未安装 TeX Live 的 texcount 包,请安装后重试。",
|
|
298
312
|
ZIP_DUPLICATE_ENTRY: "ZIP 压缩包包含重复文件名:{{path}}。",
|
|
313
|
+
ZIP_PATH_CONFLICT: "ZIP 压缩包中的路径在 Windows 上发生冲突:{{path}}。",
|
|
299
314
|
ZIP_ENTRY_READ_FAILED: "无法读取 ZIP 压缩包中的文件。",
|
|
300
315
|
ZIP_ENTRY_TOO_LARGE: "ZIP 压缩包中存在超过限制的文件。",
|
|
301
316
|
ZIP_INVALID: "无法导入 ZIP 压缩包。",
|
package/dist/server/index.js
CHANGED
|
@@ -66,17 +66,24 @@ export async function startServer(configPath) {
|
|
|
66
66
|
}
|
|
67
67
|
export async function serve(configPath) {
|
|
68
68
|
const running = await startServer(configPath);
|
|
69
|
+
const windowsIpc = process.platform === "win32" && Boolean(process.send);
|
|
69
70
|
let closed = false;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
await new Promise((resolve, reject) => {
|
|
72
|
+
const complete = () => {
|
|
73
|
+
if (closed)
|
|
74
|
+
return;
|
|
75
|
+
closed = true;
|
|
76
|
+
if (windowsIpc)
|
|
77
|
+
process.off("message", onMessage);
|
|
78
|
+
void running.close().then(resolve, reject);
|
|
79
|
+
};
|
|
80
|
+
const onMessage = (message) => { if (message === "shutdown")
|
|
81
|
+
complete(); };
|
|
78
82
|
process.once("SIGINT", complete);
|
|
79
83
|
process.once("SIGTERM", complete);
|
|
84
|
+
// PM2 cannot deliver a graceful POSIX signal on native Windows.
|
|
85
|
+
if (windowsIpc)
|
|
86
|
+
process.on("message", onMessage);
|
|
80
87
|
});
|
|
81
88
|
}
|
|
82
89
|
export async function main() {
|