texlite 0.15.0 → 0.17.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 +98 -5
- package/OPERATIONS.md +27 -0
- package/README.md +6 -0
- package/README.zh-CN.md +6 -0
- package/dist/client/assets/AdminUsers-5cAOkdRO.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-G2kKkA2f.js +1 -0
- package/dist/client/assets/Dashboard-BJDFbzQa.js +5 -0
- package/dist/client/assets/GitDialog-BEtLh2S_.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-D2kdCzOs.js +1 -0
- package/dist/client/assets/{HistoryDialog-IurkSJuU.js → HistoryDialog-BwxDdj-j.js} +3 -3
- package/dist/client/assets/LatexEditor-sMjmvA6V.js +141 -0
- package/dist/client/assets/{PdfPreview-BTmvQDCV.js → PdfPreview-z5KnowpL.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-DNV7M7vH.js +1 -0
- package/dist/client/assets/ProjectSettings-Mf8zDGRu.js +1 -0
- package/dist/client/assets/ProjectWorkspace-BJFxjMCn.js +32 -0
- package/dist/client/assets/QuickOpenDialog-C758pouQ.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-DiRKiMEt.js → SelectionHistoryDialog-p8L2n4RS.js} +2 -2
- package/dist/client/assets/SystemMetricsDialog-DDiSuglF.js +1 -0
- package/dist/client/assets/TagManagementDialog-BTVERmQS.js +1 -0
- package/dist/client/assets/WordCountDialog-B6RvAI6V.js +1 -0
- package/dist/client/assets/check-Hlb-tLSh.js +1 -0
- package/dist/client/assets/chevron-up-D0psXvTv.js +1 -0
- package/dist/client/assets/{chktex-CZIYuMLb.js → chktex-ZnIx425m.js} +1 -1
- package/dist/client/assets/{citationLibrary-ZeQPCv5O.js → citationLibrary-C9WnXB-1.js} +2 -2
- package/dist/client/assets/clock-3-C71NmJZI.js +1 -0
- package/dist/client/assets/{editor-CLY5CgkY.js → editor-_i6aPXT4.js} +1 -1
- package/dist/client/assets/eye-swovgNYS.js +1 -0
- package/dist/client/assets/github-y6i0qxSV.js +1 -0
- package/dist/client/assets/{hard-drive-B9h-a7KY.js → hard-drive-BqcHPdoY.js} +1 -1
- package/dist/client/assets/index-7WrjzKvC.js +5 -0
- package/dist/client/assets/index-C5T8_lAl.js +1 -0
- package/dist/client/assets/index-DF5cor0N.js +10 -0
- package/dist/client/assets/index-Do5FsFqg.js +1 -0
- package/dist/client/assets/index-Y-wXUwwe.css +1 -0
- package/dist/client/assets/{minimize-2-Crq_SyYM.js → minimize-2-CK7jUy7-.js} +1 -1
- package/dist/client/assets/{minus-Dn3USloe.js → minus-B2sswwWT.js} +1 -1
- package/dist/client/assets/{plus-BwKRQJHI.js → plus-Co7iyp5m.js} +1 -1
- package/dist/client/assets/{refresh-cw-C5yVKb1r.js → refresh-cw-BHVcjInn.js} +1 -1
- package/dist/client/assets/{search-CDyQWr9H.js → search-Tpi6WAga.js} +1 -1
- package/dist/client/assets/{sigma-9fiQHdlo.js → sigma-DoHJQYf7.js} +1 -1
- package/dist/client/assets/spellCheck-BSbFJY9f.js +1 -0
- package/dist/client/assets/{tags-C_3BvsxV.js → tags-BHDlIcSb.js} +1 -1
- package/dist/client/assets/{type-CnT0mBxu.js → type-C-6Jq_0r.js} +1 -1
- package/dist/client/index.html +16 -4
- package/dist/client/texlite-icon.svg +8 -0
- package/dist/server/app.js +6 -1
- package/dist/server/auth.js +0 -3
- package/dist/server/cgroups.js +35 -0
- package/dist/server/chktex.js +3 -4
- package/dist/server/compilerVersions.js +46 -0
- package/dist/server/config.js +8 -0
- package/dist/server/cpuMetrics.js +122 -0
- package/dist/server/db.js +13 -0
- package/dist/server/environment.js +11 -0
- package/dist/server/i18n.js +4 -2
- package/dist/server/latexCompletion.js +11 -88
- package/dist/server/projectOutline.js +4 -39
- package/dist/server/resourceMetrics.js +214 -0
- package/dist/server/routes/citations.js +22 -0
- package/dist/server/routes/projectFiles.js +1 -59
- package/dist/server/routes/system.js +32 -1
- package/dist/server/routes/users.js +21 -3
- package/dist/server/systemMemory.js +51 -0
- package/dist/server/updates.js +116 -0
- package/dist/shared/bibtexReferences.js +5 -1
- package/dist/shared/compilerVersions.js +11 -0
- package/dist/shared/latexCompletion.js +1 -0
- package/dist/shared/latexReferences.js +13 -3
- package/dist/shared/latexSymbols.js +77 -0
- package/dist/shared/resourceMetrics.js +1 -0
- package/dist/shared/updates.js +5 -0
- package/package.json +3 -1
- package/texlite.config.example.json +3 -0
- package/dist/client/assets/AdminUsers-Cau9nlv9.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-Cf_bbSq3.js +0 -1
- package/dist/client/assets/Dashboard-JQ8pJe2d.js +0 -2
- package/dist/client/assets/GitDialog-BcqqWKr-.js +0 -3
- package/dist/client/assets/GitHubAccountDialog-Cqcezf6G.js +0 -1
- package/dist/client/assets/LatexEditor-msdbtTyG.js +0 -141
- package/dist/client/assets/ProjectIconPickerDialog-Cbm-0YQW.js +0 -1
- package/dist/client/assets/ProjectNavigationDialogs-CozcEa2v.js +0 -1
- package/dist/client/assets/ProjectSettings-BlthcpdA.js +0 -1
- package/dist/client/assets/ProjectWorkspace-DUPLJCQ3.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-DJJZueSr.js +0 -1
- package/dist/client/assets/TagManagementDialog-3c-WAWQd.js +0 -1
- package/dist/client/assets/WordCountDialog-BqlX2s36.js +0 -1
- package/dist/client/assets/check-EZ2H-iDj.js +0 -1
- package/dist/client/assets/external-link-DGfNJFKy.js +0 -1
- package/dist/client/assets/github-DJezB5ef.js +0 -1
- package/dist/client/assets/index-BgeOKYIx.js +0 -10
- package/dist/client/assets/index-CMBalIBd.css +0 -1
- package/dist/client/assets/index-DmBKxZf9.js +0 -5
- package/dist/client/assets/spellCheck-BCpcq-VN.js +0 -1
- package/dist/client/assets/user-plus-pxz36w4w.js +0 -1
- package/dist/client/assets/x-DN0Ol4Ya.js +0 -1
- package/dist/server/projectSearch.js +0 -117
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w,A as L}from"./index-DF5cor0N.js";import{s as y,c as S}from"./ProjectWorkspace-BJFxjMCn.js";import"./react-CltQJflK.js";import"./index-C5T8_lAl.js";import"./check-Hlb-tLSh.js";import"./index-Do5FsFqg.js";import"./chevron-up-D0psXvTv.js";import"./refresh-cw-BHVcjInn.js";const k=5,f=new Map,C=12,x=S();let E=0;class p extends Error{constructor(){super("A newer writing check replaced this request."),this.name="HarperLintSupersededError"}}function I(e){return e instanceof p}function $(e){const t=[0];let r=0;for(const n of e)r+=n.length,t.push(r);return t}function d(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort((t,r)=>t.localeCompare(r)).join("\0")}async function v(e,t,r,n){try{return(await w(`/api/projects/${e}/spellcheck`,{method:"POST",body:JSON.stringify({path:t,source:r,clientId:x,sequence:n})})).lints}catch(o){throw o instanceof L&&o.code==="SPELLCHECK_SUPERSEDED"?new p:o}}function A(e,t,r){if(!t.problem)return null;const n={from:t.start,to:t.end},o={from:r[t.start]??-1,to:r[t.end]??-1},i=c=>c.from>=0&&c.to>c.from&&c.to<=e.length,a=c=>i(c)&&e.slice(c.from,c.to)===t.problem;return a(o)?o:a(n)?n:null}function H(e,t,r){const n=A(e,t,r);if(!n)return null;const{from:o,to:i}=n,a=e.slice(o,i);if(!a.trim()||!/[A-Za-z]/.test(a)||t.kind==="Formatting")return null;const c=t.kind==="Spelling"||t.kind==="Typo"?"spelling":"grammar",u=t.suggestions.filter((m,s,l)=>s<k&&l.indexOf(m)===s);return{from:o,to:i,word:a,kind:c,message:t.message,suggestions:u}}function h(e,t){let r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return`${e}\0${t.length}:${r>>>0}`}function g(e,t,r){const n=h(e,t),o=f.get(n);return!o||o.path!==e||o.source!==t||o.dictionary!==r?null:(f.delete(n),f.set(n,o),o.issues)}function R(e,t,r,n){const o=h(e,t);for(f.set(o,{path:e,source:t,dictionary:r,issues:n});f.size>C;){const i=f.keys().next().value;if(i===void 0)break;f.delete(i)}}async function b(e,t,r,n="main.tex"){const o=d(t),i=g(n,e,o);if(i)return i;const a=$(e),c=new Set(t.map(s=>s.trim().toLocaleLowerCase("en-US")).filter(Boolean)),u=new Set,m=r.map(s=>H(e,s,a)).filter(s=>!!s).filter(s=>s.kind!=="spelling"||!c.has(s.word.trim().toLocaleLowerCase("en-US"))).filter(s=>{const l=`${s.from}:${s.to}:${s.kind}`;return u.has(l)?!1:(u.add(l),!0)}).sort((s,l)=>s.from-l.from||s.to-l.to);return R(n,e,o,m),m}async function P(e,t,r,n){const o=d(n),i=g(t,r,o);if(i)return i;const a=await v(e,t,r,++E);return b(r,n,a,t)}function N(e,t,r,n=[]){return y(t)?P(e,t,r,n):Promise.resolve([])}export{p as HarperLintSupersededError,I as isHarperLintSupersededError,N as lintLatex,b as mapLatexLints};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./index-
|
|
1
|
+
import{c as a}from"./index-DF5cor0N.js";const e=a("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);export{e as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-DF5cor0N.js";const n=e("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);export{n as T};
|
package/dist/client/index.html
CHANGED
|
@@ -3,19 +3,31 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<meta name="color-scheme" content="light" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<base href="/" />
|
|
8
8
|
<meta name="texlite-base-path" content="/" />
|
|
9
|
+
<script>
|
|
10
|
+
// Apply the browser preference before styles paint; keep this key in
|
|
11
|
+
// sync with scopedStorageKey("texlite-theme") in theme.ts.
|
|
12
|
+
try {
|
|
13
|
+
const base = document.querySelector('meta[name="texlite-base-path"]').content;
|
|
14
|
+
const key = base === "/" ? "texlite-theme" : `texlite-theme:base=${encodeURIComponent(base)}`;
|
|
15
|
+
const preference = localStorage.getItem(key);
|
|
16
|
+
const dark = preference === "dark" || (preference === "system" && typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: dark)").matches);
|
|
17
|
+
document.documentElement.dataset.theme = dark ? "dark" : "light";
|
|
18
|
+
} catch { document.documentElement.dataset.theme = "light"; }
|
|
19
|
+
document.documentElement.style.colorScheme = document.documentElement.dataset.theme;
|
|
20
|
+
</script>
|
|
9
21
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
10
22
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
11
23
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&family=Source+Code+Pro:wght@400;500;600&display=swap" />
|
|
12
24
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/iosevka@5.2.5/400.css" />
|
|
13
25
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/iosevka@5.2.5/600.css" />
|
|
14
|
-
<link rel="icon" type="image/svg+xml" href="
|
|
26
|
+
<link rel="icon" type="image/svg+xml" href="texlite-icon.svg" />
|
|
15
27
|
<title>TexLite</title>
|
|
16
|
-
<script type="module" crossorigin src="./assets/index-
|
|
28
|
+
<script type="module" crossorigin src="./assets/index-DF5cor0N.js"></script>
|
|
17
29
|
<link rel="modulepreload" crossorigin href="./assets/react-CltQJflK.js">
|
|
18
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
30
|
+
<link rel="stylesheet" crossorigin href="./assets/index-Y-wXUwwe.css">
|
|
19
31
|
</head>
|
|
20
32
|
<body>
|
|
21
33
|
<div id="root"></div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-labelledby="t" xmlns:c2pa="http://c2pa.org/manifest"><metadata><c2pa:manifest>AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTplZjg5YjM5My1lNjAwLTQ0NTItYWU5OC0yYzM2YmY2ZTJlODYAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaLUd1FJdJGH5jIwitE5HqGwAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDo0MzRjMDg5NS05NmQwLTQ5OTItYjRiYS0yMzUwNGRhMzJlMTVscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNo4FUWXkgHx+vY7+/ya6DnlAAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQLuFaZnwpJUNQtLeprsklaEPiRtBapLZUytS9YAKH2lHCK7eAsGaJRtGmX28d/viiGF8E9ZSo73SqTcZ5X3qxSA=</c2pa:manifest></metadata>
|
|
2
|
+
<title id="t">TexLite</title>
|
|
3
|
+
<rect width="64" height="64" rx="15" fill="#E9F5EE"/>
|
|
4
|
+
<g fill="none" stroke-width="6" stroke-linecap="round" stroke-linejoin="round">
|
|
5
|
+
<path stroke="#133D2B" d="M13.5 16.5H31.5M22.5 16.5V41.5"/>
|
|
6
|
+
<path stroke="#1B8A57" d="M42.5 23.5V48.5M42.5 23.5H50.5M42.5 36H48.5M42.5 48.5H50.5"/>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
package/dist/server/app.js
CHANGED
|
@@ -21,6 +21,7 @@ import { HistoryRetentionScheduler } from "./historyRetention.js";
|
|
|
21
21
|
import { EditHistoryRetry } from "./editHistoryRetry.js";
|
|
22
22
|
import { ProjectOutlineService } from "./projectOutline.js";
|
|
23
23
|
import { MetricRegistry } from "./metrics.js";
|
|
24
|
+
import { UpdateChecker } from "./updates.js";
|
|
24
25
|
import { apiError, HttpError } from "./http.js";
|
|
25
26
|
import { registerCompileRoutes } from "./routes/compile.js";
|
|
26
27
|
import { registerAuthRoutes } from "./routes/auth.js";
|
|
@@ -74,6 +75,9 @@ export async function buildApp(config, db, options = {}) {
|
|
|
74
75
|
logger: options.logger ?? true,
|
|
75
76
|
bodyLimit: Math.max(12 * 1024 * 1024, config.maxUploadBytes + 1024 * 1024)
|
|
76
77
|
});
|
|
78
|
+
const updates = new UpdateChecker(db, { enabled: config.updatesEnabled, fetch: options.updateFetch });
|
|
79
|
+
app.addHook("onListen", async () => { updates.start(); });
|
|
80
|
+
app.addHook("onClose", async () => { await updates.dispose(); });
|
|
77
81
|
const queue = new CompileQueue(config.maxCompileJobs);
|
|
78
82
|
const compileCoordinator = new ProjectCompileCoordinator(queue);
|
|
79
83
|
const metrics = new MetricRegistry(200);
|
|
@@ -257,7 +261,8 @@ export async function buildApp(config, db, options = {}) {
|
|
|
257
261
|
latexCompletions,
|
|
258
262
|
projectOutlines,
|
|
259
263
|
metrics,
|
|
260
|
-
eventLoopDelay
|
|
264
|
+
eventLoopDelay,
|
|
265
|
+
updates
|
|
261
266
|
});
|
|
262
267
|
registerCollaborationRoutes(routes, { db, collaboration, metrics });
|
|
263
268
|
registerAuthRoutes(routes, { config, db, loginLimiter });
|
package/dist/server/auth.js
CHANGED
|
@@ -13,9 +13,6 @@ export function publicUser(user) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
const requestUserCache = new WeakMap();
|
|
16
|
-
export function clearCurrentUserCache(request) {
|
|
17
|
-
requestUserCache.delete(request);
|
|
18
|
-
}
|
|
19
16
|
export function currentUser(request, db) {
|
|
20
17
|
if (requestUserCache.has(request)) {
|
|
21
18
|
return requestUserCache.get(request) ?? null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
/** Resolve the current process's controller in both private and host cgroup namespaces. */
|
|
3
|
+
export function cgroupPaths(groups, mounts, controller) {
|
|
4
|
+
const memberships = groups.split("\n").flatMap((line) => {
|
|
5
|
+
const match = line.match(/^\d+:([^:]*):(\/.*)$/);
|
|
6
|
+
return match && (!match[1] || match[1].split(",").includes(controller))
|
|
7
|
+
? [{ group: path.posix.normalize(match[2]), v2: !match[1] }] : [];
|
|
8
|
+
});
|
|
9
|
+
const paths = [];
|
|
10
|
+
const unescape = (value) => value.replace(/\\([0-7]{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
|
|
11
|
+
for (const line of mounts.split("\n")) {
|
|
12
|
+
const [left, right] = line.split(" - ");
|
|
13
|
+
if (!right)
|
|
14
|
+
continue;
|
|
15
|
+
const fields = left.split(" ");
|
|
16
|
+
const [kind, , options = ""] = right.split(" ");
|
|
17
|
+
if (kind !== "cgroup2" && !(kind === "cgroup" && options.split(",").includes(controller)))
|
|
18
|
+
continue;
|
|
19
|
+
if (!fields[3] || !fields[4])
|
|
20
|
+
continue;
|
|
21
|
+
const root = unescape(fields[3]);
|
|
22
|
+
const mountPoint = unescape(fields[4]);
|
|
23
|
+
for (const membership of memberships.filter((entry) => entry.v2 === (kind === "cgroup2"))) {
|
|
24
|
+
const relative = path.posix.relative(root, membership.group);
|
|
25
|
+
if (relative === ".." || relative.startsWith("../"))
|
|
26
|
+
continue;
|
|
27
|
+
paths.push({ directory: path.posix.join(mountPoint, relative), mountPoint, v2: membership.v2 });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return paths.length ? paths : [
|
|
31
|
+
{ directory: "/sys/fs/cgroup", mountPoint: "/sys/fs/cgroup", v2: true },
|
|
32
|
+
{ directory: `/sys/fs/cgroup/${controller}`, mountPoint: `/sys/fs/cgroup/${controller}`, v2: false },
|
|
33
|
+
...(controller === "memory" ? [] : [{ directory: "/sys/fs/cgroup/cpu,cpuacct", mountPoint: "/sys/fs/cgroup/cpu,cpuacct", v2: false }])
|
|
34
|
+
];
|
|
35
|
+
}
|
package/dist/server/chktex.js
CHANGED
|
@@ -120,7 +120,7 @@ export class ChktexService {
|
|
|
120
120
|
reject = rejectOperation;
|
|
121
121
|
});
|
|
122
122
|
const scheduled = {
|
|
123
|
-
key, source,
|
|
123
|
+
key, source, started: false, cancelled: false,
|
|
124
124
|
lanes: laneKey ? new Set([laneKey]) : new Set(), hasUnscopedWaiter: laneKey === null,
|
|
125
125
|
promise: operation, resolve, reject
|
|
126
126
|
};
|
|
@@ -191,7 +191,6 @@ export class ChktexService {
|
|
|
191
191
|
discardQueued(scheduled) {
|
|
192
192
|
this.queued.delete(scheduled);
|
|
193
193
|
scheduled.source = "";
|
|
194
|
-
scheduled.filePath = "";
|
|
195
194
|
}
|
|
196
195
|
acceptLaneSequence(lane, sequence, key) {
|
|
197
196
|
if (!Number.isSafeInteger(sequence) || sequence <= 0)
|
|
@@ -239,7 +238,7 @@ export class ChktexService {
|
|
|
239
238
|
}
|
|
240
239
|
async runScheduled(scheduled) {
|
|
241
240
|
try {
|
|
242
|
-
scheduled.resolve(await this.lintOnce(scheduled.source
|
|
241
|
+
scheduled.resolve(await this.lintOnce(scheduled.source));
|
|
243
242
|
}
|
|
244
243
|
catch (error) {
|
|
245
244
|
scheduled.reject(error);
|
|
@@ -270,7 +269,7 @@ export class ChktexService {
|
|
|
270
269
|
.finally(() => { this.probePromise = null; });
|
|
271
270
|
return this.probePromise;
|
|
272
271
|
}
|
|
273
|
-
async lintOnce(source
|
|
272
|
+
async lintOnce(source) {
|
|
274
273
|
await this.ensureAvailable();
|
|
275
274
|
// With no filename ChkTeX reads stdin. Passing `-` is interpreted as a
|
|
276
275
|
// literal filename by ChkTeX 1.7.x and silently produces no diagnostics.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { COMPILER_VERSION_TOOLS } from "../shared/compilerVersions.js";
|
|
2
|
+
const cacheDurationMs = 60_000;
|
|
3
|
+
/** Shared across users, refreshed on demand only. Never expose probe errors or paths. */
|
|
4
|
+
export class CompilerVersionService {
|
|
5
|
+
probe;
|
|
6
|
+
now;
|
|
7
|
+
cached = null;
|
|
8
|
+
expiresAt = 0;
|
|
9
|
+
pending = null;
|
|
10
|
+
constructor(probe, now = Date.now) {
|
|
11
|
+
this.probe = probe;
|
|
12
|
+
this.now = now;
|
|
13
|
+
}
|
|
14
|
+
getVersions() {
|
|
15
|
+
if (this.cached && this.now() < this.expiresAt)
|
|
16
|
+
return Promise.resolve(this.cached);
|
|
17
|
+
if (this.pending)
|
|
18
|
+
return this.pending;
|
|
19
|
+
this.pending = this.load().then((result) => {
|
|
20
|
+
this.cached = result;
|
|
21
|
+
this.expiresAt = this.now() + cacheDurationMs;
|
|
22
|
+
return result;
|
|
23
|
+
}).finally(() => { this.pending = null; });
|
|
24
|
+
return this.pending;
|
|
25
|
+
}
|
|
26
|
+
async load() {
|
|
27
|
+
const tools = await this.probe().catch(() => []);
|
|
28
|
+
const banners = new Map(tools.map((tool) => [tool.id, tool.status === "installed" ? tool.version : null]));
|
|
29
|
+
// Some distribution packages omit tlmgr. Engine banners still identify TeX Live.
|
|
30
|
+
const texlive = ["texlive", "pdflatex", "xelatex", "lualatex"]
|
|
31
|
+
.map((id) => banners.get(id)?.match(/\bTeX Live\b.*?\b(20\d{2})\b/i)?.[1])
|
|
32
|
+
.find(Boolean) ?? null;
|
|
33
|
+
return { tools: COMPILER_VERSION_TOOLS.map(({ id }) => ({
|
|
34
|
+
id, version: id === "texlive" ? texlive : softwareVersion(banners.get(id))
|
|
35
|
+
})) };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function softwareVersion(banner) {
|
|
39
|
+
if (!banner)
|
|
40
|
+
return null;
|
|
41
|
+
// Keep meaningful suffixes (BibTeX 0.99d, LuaHBTeX 1.21.0, pdfTeX 3.1415-2.6-1.40).
|
|
42
|
+
const numericVersion = "v?(\\d+(?:\\.\\d+)+(?:-\\d+(?:\\.\\d+)*)*[a-z]?)";
|
|
43
|
+
return banner.match(new RegExp(`\\bversion\\s*:?\\s*${numericVersion}`, "i"))?.[1]
|
|
44
|
+
?? banner.match(new RegExp(`\\b${numericVersion}`, "i"))?.[1]
|
|
45
|
+
?? null;
|
|
46
|
+
}
|
package/dist/server/config.js
CHANGED
|
@@ -7,6 +7,7 @@ export const PDF_LOADING_STRATEGIES = ["auto", "full", "range"];
|
|
|
7
7
|
/** Effective values used when the corresponding file/env setting is omitted. */
|
|
8
8
|
export const CONFIG_DEFAULTS = {
|
|
9
9
|
siteName: "TexLite",
|
|
10
|
+
updatesEnabled: true,
|
|
10
11
|
adminEmail: "",
|
|
11
12
|
host: "127.0.0.1",
|
|
12
13
|
port: 3000,
|
|
@@ -80,6 +81,7 @@ export function loadConfig(configPathOverride) {
|
|
|
80
81
|
const config = {
|
|
81
82
|
configPath,
|
|
82
83
|
siteName: stringSetting("siteName", process.env.TEXLITE_SITE_NAME, fileConfig.siteName, CONFIG_DEFAULTS.siteName, { min: 1, max: 120 }),
|
|
84
|
+
updatesEnabled: fileConfig.updates?.enabled ?? CONFIG_DEFAULTS.updatesEnabled,
|
|
83
85
|
adminEmail: stringSetting("adminEmail", process.env.TEXLITE_ADMIN_EMAIL, fileConfig.adminEmail, CONFIG_DEFAULTS.adminEmail, { min: 0, max: 320 }),
|
|
84
86
|
host: stringSetting("server.host", process.env.TEXLITE_HOST, fileConfig.server?.host, CONFIG_DEFAULTS.host, { min: 1, max: 255 }),
|
|
85
87
|
port: integerSetting("server.port", process.env.TEXLITE_PORT, fileConfig.server?.port, CONFIG_DEFAULTS.port, CONFIG_LIMITS.port),
|
|
@@ -122,6 +124,8 @@ export function loadBasePath(configPathOverride) {
|
|
|
122
124
|
}
|
|
123
125
|
/** Validate an already materialized configuration (useful for startup/tests). */
|
|
124
126
|
export function validateConfig(config) {
|
|
127
|
+
if (typeof config.updatesEnabled !== "boolean")
|
|
128
|
+
throw configurationError("updates.enabled", "must be true or false");
|
|
125
129
|
if (!config.dataDir || path.parse(config.dataDir).root === config.dataDir) {
|
|
126
130
|
throw configurationError("storage.dataDir", "must be a non-root directory where TexLite can store data");
|
|
127
131
|
}
|
|
@@ -188,6 +192,10 @@ function readConfigFile(configPath) {
|
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
function validateFileConfig(config) {
|
|
195
|
+
const updates = optionalSection(config.updates, "updates");
|
|
196
|
+
if (updates && Object.prototype.hasOwnProperty.call(updates, "enabled") && typeof updates.enabled !== "boolean") {
|
|
197
|
+
throw configurationError("updates.enabled", "must be true or false");
|
|
198
|
+
}
|
|
191
199
|
optionalString(config.siteName, "siteName", { min: 1, max: 120 });
|
|
192
200
|
optionalString(config.adminEmail, "adminEmail", { min: 0, max: 320 });
|
|
193
201
|
optionalInteger(config.sessionDays, "sessionDays", CONFIG_LIMITS.sessionDays);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { performance } from "node:perf_hooks";
|
|
5
|
+
import { cgroupPaths } from "./cgroups.js";
|
|
6
|
+
/** Counters, not load averages or lifetime-average ps percentages. */
|
|
7
|
+
export async function collectCpuSnapshot(scope, tex, platform = process.platform, read = (file) => readFile(file, "utf8")) {
|
|
8
|
+
try {
|
|
9
|
+
const cpus = os.cpus();
|
|
10
|
+
if (!cpus.length)
|
|
11
|
+
return null;
|
|
12
|
+
const optional = (file) => read(file).catch(() => null);
|
|
13
|
+
let hostTotal = cpus.reduce((sum, cpu) => sum + Object.values(cpu.times).reduce((sum, time) => sum + time, 0), 0);
|
|
14
|
+
let hostIdle = cpus.reduce((sum, cpu) => sum + cpu.times.idle, 0);
|
|
15
|
+
let linuxTicks = null;
|
|
16
|
+
let capacityCores = cpus.length;
|
|
17
|
+
let containerUsageUs = null;
|
|
18
|
+
if (platform === "linux") {
|
|
19
|
+
const stat = await read("/proc/stat");
|
|
20
|
+
const values = stat.match(/^cpu[ \t]+([\d \t]+)$/m)?.[1].trim().split(/\s+/).map(Number);
|
|
21
|
+
if (!values || values.length < 4)
|
|
22
|
+
return null;
|
|
23
|
+
// guest/guest_nice are already included in user/nice; don't add them twice.
|
|
24
|
+
hostTotal = values.slice(0, 8).reduce((sum, value) => sum + value, 0);
|
|
25
|
+
hostIdle = values[3] + (values[4] ?? 0); // Idle and I/O wait are not executing work.
|
|
26
|
+
linuxTicks = hostTotal;
|
|
27
|
+
if (scope === "container") {
|
|
28
|
+
const [groups, mounts] = await Promise.all([optional("/proc/self/cgroup"), optional("/proc/self/mountinfo")]);
|
|
29
|
+
capacityCores = Math.min(cpus.length, os.availableParallelism());
|
|
30
|
+
for (const entry of cgroupPaths(groups ?? "", mounts ?? "", "cpuacct")) {
|
|
31
|
+
const usage = await optional(`${entry.directory}/${entry.v2 ? "cpu.stat" : "cpuacct.usage"}`);
|
|
32
|
+
const value = entry.v2 ? usage?.match(/^usage_usec\s+(\d+)$/m)?.[1] : usage?.trim();
|
|
33
|
+
if (value && /^\d+$/.test(value)) {
|
|
34
|
+
containerUsageUs = Number(value) / (entry.v2 ? 1 : 1_000);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (containerUsageUs === null)
|
|
39
|
+
return null;
|
|
40
|
+
for (const entry of cgroupPaths(groups ?? "", mounts ?? "", "cpu")) {
|
|
41
|
+
for (let current = entry.directory;; current = path.posix.dirname(current)) {
|
|
42
|
+
let quota;
|
|
43
|
+
let period;
|
|
44
|
+
if (entry.v2) {
|
|
45
|
+
const fields = (await optional(`${current}/cpu.max`))?.trim().split(/\s+/);
|
|
46
|
+
quota = Number(fields?.[0]);
|
|
47
|
+
period = Number(fields?.[1]);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const fields = await Promise.all([optional(`${current}/cpu.cfs_quota_us`), optional(`${current}/cpu.cfs_period_us`)]);
|
|
51
|
+
quota = Number(fields[0]);
|
|
52
|
+
period = Number(fields[1]);
|
|
53
|
+
}
|
|
54
|
+
if (Number.isFinite(quota) && quota > 0 && period > 0)
|
|
55
|
+
capacityCores = Math.min(capacityCores, quota / period);
|
|
56
|
+
if (current === entry.mountPoint || current === "/")
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (scope === "container")
|
|
63
|
+
return null;
|
|
64
|
+
const service = process.cpuUsage();
|
|
65
|
+
return { scope, at: performance.now(), hostCores: cpus.length, capacityCores, hostTotal, hostIdle, linuxTicks,
|
|
66
|
+
containerUsageUs, serviceUs: service.user + service.system, tex };
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** One baseline per server, shared by administrators; idle gaps start a fresh window. */
|
|
73
|
+
export class CpuMetrics {
|
|
74
|
+
previous = null;
|
|
75
|
+
update(current, scope) {
|
|
76
|
+
const empty = (status) => ({ scope, status, texlitePercent: null, otherPercent: null, idlePercent: null });
|
|
77
|
+
const previous = this.previous;
|
|
78
|
+
this.previous = current;
|
|
79
|
+
if (!current || current.tex === null)
|
|
80
|
+
return empty("unavailable");
|
|
81
|
+
const elapsed = previous ? current.at - previous.at : 0;
|
|
82
|
+
if (!previous || previous.tex === null || elapsed < 500 || elapsed > 15_000 || current.scope !== previous.scope
|
|
83
|
+
|| current.capacityCores !== previous.capacityCores || current.hostCores !== previous.hostCores)
|
|
84
|
+
return empty("warming");
|
|
85
|
+
const hostDelta = current.hostTotal - previous.hostTotal;
|
|
86
|
+
const idleDelta = current.hostIdle - previous.hostIdle;
|
|
87
|
+
const serviceDelta = current.serviceUs - previous.serviceUs;
|
|
88
|
+
if (hostDelta <= 0 || idleDelta < 0 || serviceDelta < 0 || current.capacityCores <= 0)
|
|
89
|
+
return empty("unavailable");
|
|
90
|
+
const oldProcesses = new Map(previous.tex.map((process) => [`${process.pid}:${process.started}`, process.time]));
|
|
91
|
+
let texDelta = 0;
|
|
92
|
+
for (const process of current.tex) {
|
|
93
|
+
const delta = process.time - (oldProcesses.get(`${process.pid}:${process.started}`) ?? 0);
|
|
94
|
+
if (delta < 0 || !Number.isFinite(delta))
|
|
95
|
+
return empty("unavailable");
|
|
96
|
+
texDelta += delta;
|
|
97
|
+
}
|
|
98
|
+
const capacityUs = elapsed * 1_000 * current.capacityCores;
|
|
99
|
+
let texPercent;
|
|
100
|
+
if (current.linuxTicks !== null && previous.linuxTicks !== null) {
|
|
101
|
+
const ticks = current.linuxTicks - previous.linuxTicks;
|
|
102
|
+
if (ticks <= 0)
|
|
103
|
+
return empty("unavailable");
|
|
104
|
+
texPercent = texDelta / ticks * current.hostCores / current.capacityCores * 100;
|
|
105
|
+
}
|
|
106
|
+
else
|
|
107
|
+
texPercent = texDelta / capacityUs * 100;
|
|
108
|
+
let busy = (hostDelta - idleDelta) / hostDelta * 100;
|
|
109
|
+
if (scope === "container") {
|
|
110
|
+
if (current.containerUsageUs === null || previous.containerUsageUs === null || current.containerUsageUs < previous.containerUsageUs)
|
|
111
|
+
return empty("unavailable");
|
|
112
|
+
busy = (current.containerUsageUs - previous.containerUsageUs) / capacityUs * 100;
|
|
113
|
+
}
|
|
114
|
+
busy = Math.max(0, Math.min(100, busy));
|
|
115
|
+
// Partition integer tenths before formatting; independently rounded shares
|
|
116
|
+
// can otherwise add up to 100.1% at half-way boundaries.
|
|
117
|
+
const busyTenths = Math.round(busy * 10);
|
|
118
|
+
const texliteTenths = Math.min(busyTenths, Math.round(Math.min(busy, texPercent + serviceDelta / capacityUs * 100) * 10));
|
|
119
|
+
return { scope, status: "ready", texlitePercent: texliteTenths / 10,
|
|
120
|
+
idlePercent: (1_000 - busyTenths) / 10, otherPercent: (busyTenths - texliteTenths) / 10 };
|
|
121
|
+
}
|
|
122
|
+
}
|
package/dist/server/db.js
CHANGED
|
@@ -27,6 +27,19 @@ const databaseMigrations = [
|
|
|
27
27
|
if (missingColumn(db, "comments", "resolved_at")) {
|
|
28
28
|
db.exec("ALTER TABLE comments ADD COLUMN resolved_at TEXT");
|
|
29
29
|
}
|
|
30
|
+
} },
|
|
31
|
+
{ version: 5, name: "add_update_notifications", apply: (db) => {
|
|
32
|
+
db.exec(`
|
|
33
|
+
CREATE TABLE IF NOT EXISTS update_check_cache (
|
|
34
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
35
|
+
latest_version TEXT,
|
|
36
|
+
next_check_at INTEGER NOT NULL
|
|
37
|
+
);
|
|
38
|
+
CREATE TABLE IF NOT EXISTS dismissed_updates (
|
|
39
|
+
user_id TEXT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
|
40
|
+
version TEXT NOT NULL
|
|
41
|
+
);
|
|
42
|
+
`);
|
|
30
43
|
} }
|
|
31
44
|
];
|
|
32
45
|
function migrateGitHubTokensToUsers(db) {
|
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { LATEX_ENGINES } from "./config.js";
|
|
3
3
|
import { httpError } from "./http.js";
|
|
4
4
|
import { detachedProcessGroup, killProcessGroup } from "./processTree.js";
|
|
5
|
+
import { COMPILER_VERSION_TOOLS } from "../shared/compilerVersions.js";
|
|
5
6
|
export const MIN_NODE_MAJOR = 24;
|
|
6
7
|
const commandProbeTimeoutMs = 10_000;
|
|
7
8
|
const maxCommandOutputBytes = 64 * 1024;
|
|
@@ -13,6 +14,16 @@ const maxCommandOutputBytes = 64 * 1024;
|
|
|
13
14
|
export async function inspectHostEnvironment(config) {
|
|
14
15
|
return Promise.all(hostToolDefinitions(config).map((tool) => inspectTool(tool)));
|
|
15
16
|
}
|
|
17
|
+
/** Read-only, bounded version checks; missing tools never become requirements. */
|
|
18
|
+
export async function inspectCompilerEnvironment(config) {
|
|
19
|
+
return Promise.all(COMPILER_VERSION_TOOLS.map(({ id, name }) => inspectTool({
|
|
20
|
+
id, name,
|
|
21
|
+
command: id === "texlive" ? "tlmgr" : id === "latexmk" ? config.latexmk : id,
|
|
22
|
+
requirement: "optional", purpose: "Compiler environment version",
|
|
23
|
+
versionArgs: id === "texcount" ? ["-version"] : ["--version"],
|
|
24
|
+
timeoutMs: 3_000
|
|
25
|
+
})));
|
|
26
|
+
}
|
|
16
27
|
/**
|
|
17
28
|
* Probe the default commands on PATH without loading a TexLite configuration.
|
|
18
29
|
* This supports pre-installation checks through `texlite requirements`.
|
package/dist/server/i18n.js
CHANGED
|
@@ -10,6 +10,7 @@ const enMessages = {
|
|
|
10
10
|
CITATION_LIBRARY_PRIVATE: "Citation libraries are private to their owner.",
|
|
11
11
|
CITATION_NOT_FOUND: "The citation does not exist.",
|
|
12
12
|
CITATION_TAG_NOT_FOUND: "The citation tag does not exist.",
|
|
13
|
+
CITATION_TAG_NAME_EXISTS: "A citation tag with this name already exists.",
|
|
13
14
|
CITATION_TOO_LARGE: "The BibTeX entry is too large.",
|
|
14
15
|
CHK_TEX_SOURCE_INVALID: "The source to check is invalid.",
|
|
15
16
|
CHK_TEX_SOURCE_TOO_LARGE: "The source to check is too large.",
|
|
@@ -90,8 +91,8 @@ const enMessages = {
|
|
|
90
91
|
REPLY_NOT_FOUND: "The reply does not exist.",
|
|
91
92
|
REQUEST_INVALID: "The request is invalid.",
|
|
92
93
|
RESERVED_PATH: "This path is reserved by TexLite.",
|
|
93
|
-
SEARCH_QUERY_INVALID: "The search or replacement text is invalid.",
|
|
94
94
|
SELF_DELETE_FORBIDDEN: "You cannot delete the currently signed-in administrator.",
|
|
95
|
+
SELF_RESTRICT_FORBIDDEN: "You cannot disable or demote the currently signed-in administrator.",
|
|
95
96
|
SERVER_ERROR: "The server could not complete the request.",
|
|
96
97
|
SOURCE_FILE_NOT_FOUND: "The source file does not exist.",
|
|
97
98
|
SOURCE_FLUSH_FAILED: "Some source files could not be saved. The project operation was cancelled.",
|
|
@@ -147,6 +148,7 @@ const zhMessages = {
|
|
|
147
148
|
CITATION_LIBRARY_PRIVATE: "引用库仅对其所有者可见。",
|
|
148
149
|
CITATION_NOT_FOUND: "引用条目不存在。",
|
|
149
150
|
CITATION_TAG_NOT_FOUND: "引用标签不存在。",
|
|
151
|
+
CITATION_TAG_NAME_EXISTS: "已存在同名的引用标签。",
|
|
150
152
|
CITATION_TOO_LARGE: "BibTeX 条目过大。",
|
|
151
153
|
CHK_TEX_SOURCE_INVALID: "待检查源码格式不正确。",
|
|
152
154
|
CHK_TEX_SOURCE_TOO_LARGE: "待检查源码过大。",
|
|
@@ -227,8 +229,8 @@ const zhMessages = {
|
|
|
227
229
|
REPLY_NOT_FOUND: "回复不存在。",
|
|
228
230
|
REQUEST_INVALID: "请求格式无效。",
|
|
229
231
|
RESERVED_PATH: "此路径由 TexLite 保留。",
|
|
230
|
-
SEARCH_QUERY_INVALID: "搜索或替换内容格式不正确。",
|
|
231
232
|
SELF_DELETE_FORBIDDEN: "不能删除当前登录的管理员。",
|
|
233
|
+
SELF_RESTRICT_FORBIDDEN: "不能禁用当前登录的管理员或降低其角色权限。",
|
|
232
234
|
SERVER_ERROR: "服务器内部错误",
|
|
233
235
|
SOURCE_FILE_NOT_FOUND: "源码文件不存在。",
|
|
234
236
|
SOURCE_FLUSH_FAILED: "部分源码未能保存至磁盘,项目操作已取消。",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { maskLatexComments, maskLatexLiteralContent } from "../shared/latexLiterals.js";
|
|
2
|
+
import { listProjectFilesAsync, resolveSourcePath } from "./files.js";
|
|
3
|
+
import { extractLatexSymbols } from "../shared/latexSymbols.js";
|
|
5
4
|
import { findLatexReferenceDefinitions } from "../shared/latexReferences.js";
|
|
6
5
|
import { declaredBibliographyPaths, latexDocumentDirectives } from "./latexDocumentGraph.js";
|
|
7
6
|
const textExtensions = /\.(?:tex|sty|cls|def|cfg|bib|bst|fd|dtx|ins)$/i;
|
|
@@ -111,9 +110,6 @@ function createIndex() {
|
|
|
111
110
|
commands: new Map(), environments: new Map(), labels: new Map(), citations: new Map(), packages: new Map(), classes: new Map(), files: new Map()
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
|
-
function withoutComments(content) {
|
|
115
|
-
return maskLatexComments(maskLatexLiteralContent(content));
|
|
116
|
-
}
|
|
117
113
|
function commandItem(index, name, detail, source, apply) {
|
|
118
114
|
if (!name.startsWith("\\"))
|
|
119
115
|
name = `\\${name}`;
|
|
@@ -126,60 +122,15 @@ function commandItem(index, name, detail, source, apply) {
|
|
|
126
122
|
index.commands.set(name, item(name, detail, "function", source, apply));
|
|
127
123
|
}
|
|
128
124
|
function extractSymbols(index, filePath, original) {
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const arguments_ = newCommandArguments(Number.parseInt(match[2] ?? "0", 10), Boolean(match[3]));
|
|
133
|
-
commandItem(index, `\\${match[1]}`, `Project command (${arguments_.length} argument${arguments_.length === 1 ? "" : "s"})`, source, commandSnippet(`\\${match[1]}`, arguments_));
|
|
134
|
-
}
|
|
135
|
-
for (const definition of xparseCommandDefinitions(content)) {
|
|
136
|
-
const arguments_ = xparseCommandArguments(definition.specification);
|
|
137
|
-
const detail = arguments_
|
|
138
|
-
? `Project command (${arguments_.length} argument${arguments_.length === 1 ? "" : "s"})`
|
|
139
|
-
: "Project command";
|
|
140
|
-
commandItem(index, `\\${definition.name}`, detail, source, arguments_ ? commandSnippet(`\\${definition.name}`, arguments_) : undefined);
|
|
141
|
-
}
|
|
142
|
-
for (const match of content.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)) {
|
|
143
|
-
const args = [...(match[2] ?? "").matchAll(/#\d+/g)].length;
|
|
144
|
-
commandItem(index, `\\${match[1]}`, "Project macro", source, commandSnippet(`\\${match[1]}`, newCommandArguments(args, false)));
|
|
145
|
-
}
|
|
146
|
-
for (const match of content.matchAll(/\\DeclareMathOperator\s*\*?\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))
|
|
147
|
-
commandItem(index, `\\${match[1]}`, "Project math operator", source);
|
|
148
|
-
for (const match of content.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))
|
|
149
|
-
commandItem(index, `\\${match[1]}`, "Project math delimiter", source);
|
|
150
|
-
for (const match of content.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))
|
|
151
|
-
commandItem(index, `\\${match[1]}`, "Expl3 project command", source);
|
|
152
|
-
for (const match of content.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g)) {
|
|
153
|
-
const name = match[1].trim();
|
|
154
|
-
const existing = index.environments.get(name);
|
|
155
|
-
if (/^[A-Za-z][A-Za-z0-9*_-]*$/.test(name) && (!existing || (existing.source === "LaTeX" && source !== "LaTeX"))) {
|
|
156
|
-
index.environments.set(name, item(name, "Project environment", "keyword", source));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
for (const match of content.matchAll(/\\(?:newtheorem|declaretheorem)\s*\*?\s*\{([^}]+)\}/g)) {
|
|
160
|
-
const name = match[1].trim();
|
|
161
|
-
const existing = index.environments.get(name);
|
|
162
|
-
if (/^[A-Za-z][A-Za-z0-9*_-]*$/.test(name) && (!existing || (existing.source === "LaTeX" && source !== "LaTeX"))) {
|
|
163
|
-
index.environments.set(name, item(name, "Theorem environment", "keyword", source));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
for (const definition of findLatexReferenceDefinitions(content, "label")) {
|
|
167
|
-
if (definition.source !== "label")
|
|
168
|
-
continue;
|
|
169
|
-
const label = definition.key;
|
|
170
|
-
if (label && !index.labels.has(label))
|
|
171
|
-
index.labels.set(label, item(label, "Label", "constant", source));
|
|
172
|
-
}
|
|
173
|
-
for (const match of content.matchAll(/\\(?:input|include|subfile|import)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g)) {
|
|
174
|
-
const file = (match[1] ?? match[2] ?? "").trim();
|
|
175
|
-
if (file)
|
|
176
|
-
index.files.set(file, item(file, "Project file", "text", source));
|
|
125
|
+
const symbols = extractLatexSymbols(original);
|
|
126
|
+
for (const symbol of symbols.commands) {
|
|
127
|
+
commandItem(index, symbol.label, symbol.detail, filePath, symbol.apply);
|
|
177
128
|
}
|
|
178
|
-
for (const
|
|
179
|
-
for (const
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
|
|
129
|
+
for (const group of ["environments", "labels", "packages", "classes", "files"]) {
|
|
130
|
+
for (const symbol of symbols[group]) {
|
|
131
|
+
const existing = index[group].get(symbol.label);
|
|
132
|
+
if (!existing || existing.source === "LaTeX")
|
|
133
|
+
index[group].set(symbol.label, { ...symbol, source: filePath });
|
|
183
134
|
}
|
|
184
135
|
}
|
|
185
136
|
// `\\bibitem` suggestions are scoped by the client to the file currently
|
|
@@ -190,7 +141,7 @@ function extractSymbols(index, filePath, original) {
|
|
|
190
141
|
for (const definition of findLatexReferenceDefinitions(original, "citation", true)) {
|
|
191
142
|
const key = definition.key;
|
|
192
143
|
if (key && !index.citations.has(key))
|
|
193
|
-
index.citations.set(key, item(key, "BibTeX key", "constant",
|
|
144
|
+
index.citations.set(key, item(key, "BibTeX key", "constant", filePath));
|
|
194
145
|
}
|
|
195
146
|
}
|
|
196
147
|
}
|
|
@@ -216,34 +167,6 @@ function addProjectFile(index, filePath) {
|
|
|
216
167
|
index.classes.set(name, item(name, "Document class", "class", filePath));
|
|
217
168
|
}
|
|
218
169
|
}
|
|
219
|
-
export function buildLatexCompletionIndex(config, projectId) {
|
|
220
|
-
const index = standardIndex();
|
|
221
|
-
const allEntries = listProjectFiles(config, projectId).filter((entry) => entry.type === "file").slice(0, maxIndexedFiles);
|
|
222
|
-
for (const entry of allEntries)
|
|
223
|
-
addProjectFile(index, entry.path);
|
|
224
|
-
const entries = allEntries.filter((entry) => textExtensions.test(entry.path));
|
|
225
|
-
let indexedBytes = 0;
|
|
226
|
-
for (const entry of entries) {
|
|
227
|
-
const absolute = resolveSourcePath(config, projectId, entry.path);
|
|
228
|
-
let content;
|
|
229
|
-
try {
|
|
230
|
-
const size = fs.statSync(absolute).size;
|
|
231
|
-
if (size > maxIndexedFileBytes || indexedBytes + size > maxIndexedBytes)
|
|
232
|
-
continue;
|
|
233
|
-
indexedBytes += size;
|
|
234
|
-
content = fs.readFileSync(absolute, "utf8");
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (definitionExtensions.test(entry.path) || /\.bib$/i.test(entry.path))
|
|
240
|
-
extractSymbols(index, entry.path, content);
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
commands: sorted(index.commands), environments: sorted(index.environments), labels: sorted(index.labels),
|
|
244
|
-
citations: sorted(index.citations), packages: sorted(index.packages), classes: sorted(index.classes), files: sorted(index.files)
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
170
|
/** Reuses extracted symbols for files whose mtime and size did not change. */
|
|
248
171
|
export class LatexCompletionService {
|
|
249
172
|
config;
|