texlite 0.22.0 → 0.23.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 +5 -0
- 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-DepqkT6m.js → AdminUsers-xuVuiwoh.js} +1 -1
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.br +0 -0
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.gz +0 -0
- package/dist/client/assets/{AgentIcon-DeoZDwgh.css → AgentIcon-DJGGRJnV.css} +1 -1
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.br +0 -0
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.gz +0 -0
- package/dist/client/assets/{AgentManagement-DlV6tHez.js → AgentManagement-D-0hrv6f.js} +1 -1
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.br +0 -0
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js +2 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.br +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js +16 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-C8WQhZBK.js → AvatarSettingsDialog-ChKrdDqp.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.gz +0 -0
- package/dist/client/assets/{CitationBibtexEditor-SpudGDwi.js → CitationBibtexEditor-BZIU4Lif.js} +1 -1
- package/dist/client/assets/{CitationLibraryDialog-DgOIkLwK.js → CitationLibraryDialog-DqO9e0GV.js} +3 -3
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.gz +0 -0
- package/dist/client/assets/{Dashboard-CD1w42mA.js → Dashboard-BYgqCgBM.js} +3 -3
- package/dist/client/assets/Dashboard-BYgqCgBM.js.br +0 -0
- package/dist/client/assets/Dashboard-BYgqCgBM.js.gz +0 -0
- package/dist/client/assets/{GitDialog-DGzZ3GRj.js → GitDialog-CA68baSd.js} +1 -1
- package/dist/client/assets/GitDialog-CA68baSd.js.br +0 -0
- package/dist/client/assets/GitDialog-CA68baSd.js.gz +0 -0
- package/dist/client/assets/{GitHubAccountDialog-CGZl3mcY.js → GitHubAccountDialog-CnxfR0JD.js} +1 -1
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.gz +0 -0
- package/dist/client/assets/{HistoryDialog-DTZxCgyT.js → HistoryDialog-c2EEaFsl.js} +1 -1
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.br +0 -0
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.gz +0 -0
- package/dist/client/assets/{InfoPopover-Ba7GvcuW.js → InfoPopover-BJYnFn1P.js} +1 -1
- package/dist/client/assets/{LatexEditor-Boc-45KL.js → LatexEditor-vNOVTIl7.js} +1 -1
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.br +0 -0
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-BH2iwvle.js → MarkdownPreview-BJPqGTcw.js} +1 -1
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-Bfkaxcnh.js → ProjectIconPickerDialog-ChiEUQ0g.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.gz +0 -0
- package/dist/client/assets/{ProjectSearchDialog-DPIzxVYj.js → ProjectSearchDialog-DxgjbnmY.js} +1 -1
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.gz +0 -0
- package/dist/client/assets/{ProjectSettings-ChXx_cmP.js → ProjectSettings-BwQTbXhh.js} +1 -1
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js +25 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-CHjPlBu2.js → QuickOpenDialog-B7NTqOpu.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.gz +0 -0
- package/dist/client/assets/{ReadOnlySource-DKcmDg0e.js → ReadOnlySource-DIalHHvP.js} +1 -1
- package/dist/client/assets/{SelectionHistoryDialog-Dnj22E8N.js → SelectionHistoryDialog-BhOyneNx.js} +1 -1
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.gz +0 -0
- package/dist/client/assets/{SharedProjectPage-l8GSYTm-.js → SharedProjectPage-s-khOyvB.js} +2 -2
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.gz +0 -0
- package/dist/client/assets/{SystemMetricsDialog-DkmBA4o4.js → SystemMetricsDialog-Bycm88U1.js} +1 -1
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.gz +0 -0
- package/dist/client/assets/{TagManagementDialog-BM1MRuwh.js → TagManagementDialog-DwUAA8uC.js} +1 -1
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.gz +0 -0
- package/dist/client/assets/{ThemeSwitcher-dcvtWVCO.js → ThemeSwitcher-RSqZi7kx.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-CLAmKmS6.js +1 -0
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js +1 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.gz +0 -0
- package/dist/client/assets/{chktex-BrzPYHey.js → chktex-22lKGvKa.js} +1 -1
- package/dist/client/assets/{i18n-Dtn6w-qA.js → i18n-Wn96VbWM.js} +4 -4
- package/dist/client/assets/i18n-Wn96VbWM.js.br +0 -0
- package/dist/client/assets/i18n-Wn96VbWM.js.gz +0 -0
- package/dist/client/assets/{index-CPR6YZEf.js → index-CemLYDYL.js} +2 -2
- package/dist/client/assets/index-CemLYDYL.js.br +0 -0
- package/dist/client/assets/index-CemLYDYL.js.gz +0 -0
- package/dist/client/assets/index-DSF5eT29.css +1 -0
- package/dist/client/assets/index-DSF5eT29.css.br +0 -0
- package/dist/client/assets/index-DSF5eT29.css.gz +0 -0
- package/dist/client/assets/{relativeTime-mmWGtWRR.js → relativeTime-C-GTw3lA.js} +1 -1
- package/dist/client/assets/relativeTime-C-GTw3lA.js.br +0 -0
- package/dist/client/assets/relativeTime-C-GTw3lA.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js +1 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.gz +0 -0
- package/dist/client/assets/{spellCheck-BTyLQAFH.js → spellCheck-kxvnxrvw.js} +1 -1
- package/dist/client/assets/spellCheck-kxvnxrvw.js.br +0 -0
- package/dist/client/assets/spellCheck-kxvnxrvw.js.gz +0 -0
- package/dist/client/assets/{useDeletionTransitions-Ba_yhkrl.js → useDeletionTransitions-Xlq7HabP.js} +1 -1
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.gz +0 -0
- package/dist/client/index.html +3 -3
- 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/config.js +10 -0
- package/dist/server/i18n.js +6 -0
- package/dist/server/locales/zh-Hant.js +3 -0
- package/dist/server/routes/compile.js +56 -4
- 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/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.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/CitationLibraryDialog-DgOIkLwK.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.gz +0 -0
- 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.br +0 -0
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js.gz +0 -0
- 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.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.gz +0 -0
- 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/SelectionHistoryDialog-Dnj22E8N.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.gz +0 -0
- 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/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.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/useDeletionTransitions-Ba_yhkrl.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.gz +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js → AgentIcon-qmglBc3M.js} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.br → AgentIcon-qmglBc3M.js.br} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.gz → AgentIcon-qmglBc3M.js.gz} +0 -0
package/dist/server/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import { serve } from "./index.js";
|
|
|
13
13
|
import { processStatus, restartManaged, startManaged, stopManaged, streamLogs, waitForOnline } from "./pm2.js";
|
|
14
14
|
import { resolveConfigPath } from "./runtimePaths.js";
|
|
15
15
|
import { basePathHref } from "../shared/basePath.js";
|
|
16
|
+
import { TikzGalleryLibrary } from "./tikzGallery.js";
|
|
16
17
|
const HELP = `TexLite ${packageVersion()}
|
|
17
18
|
|
|
18
19
|
Usage:
|
|
@@ -211,7 +212,8 @@ async function requirements(options) {
|
|
|
211
212
|
function inspectDoctorApplication(config, configPath) {
|
|
212
213
|
const checks = [
|
|
213
214
|
{ name: "Configuration", status: "passed", detail: `Valid: ${configPath}` },
|
|
214
|
-
inspectClientAssets(config)
|
|
215
|
+
inspectClientAssets(config),
|
|
216
|
+
...(config.tikzGalleryEnabled ? [inspectTikzGallery(config)] : [])
|
|
215
217
|
];
|
|
216
218
|
let db = null;
|
|
217
219
|
try {
|
|
@@ -242,6 +244,14 @@ function inspectClientAssets(config) {
|
|
|
242
244
|
catch { /* Report a concise diagnostic below. */ }
|
|
243
245
|
return { name: "Client assets", status: "failed", detail: `Missing ${entry}; run \`npm run build\` or reinstall TexLite.` };
|
|
244
246
|
}
|
|
247
|
+
function inspectTikzGallery(config) {
|
|
248
|
+
const result = new TikzGalleryLibrary(config.tikzGalleryDir).catalog();
|
|
249
|
+
if (result.status === "ok")
|
|
250
|
+
return { name: "TikZ gallery", status: "passed", detail: `${result.catalog.items.length} figures: ${config.tikzGalleryDir}` };
|
|
251
|
+
return { name: "TikZ gallery", status: "failed", detail: result.status === "incompatible"
|
|
252
|
+
? `${config.tikzGalleryDir} has a catalog this TexLite cannot read; update TexLite or the add-on.`
|
|
253
|
+
: `No catalog in ${config.tikzGalleryDir}; clone the add-on there or set tikzGallery.enabled to false.` };
|
|
254
|
+
}
|
|
245
255
|
function errorMessage(error) {
|
|
246
256
|
return error instanceof Error ? error.message.replace(/\s+/g, " ").slice(0, 240) : String(error).slice(0, 240);
|
|
247
257
|
}
|
|
@@ -256,6 +266,7 @@ async function printConfig(options) {
|
|
|
256
266
|
dataDir: config.dataDir,
|
|
257
267
|
databasePath: config.databasePath,
|
|
258
268
|
projectsDir: config.projectsDir,
|
|
269
|
+
tikzGallery: { enabled: config.tikzGalleryEnabled, path: config.tikzGalleryDir },
|
|
259
270
|
clientDir: config.clientDir,
|
|
260
271
|
sessionDays: config.sessionDays,
|
|
261
272
|
compileTimeoutSeconds: config.compileTimeoutMs / 1000,
|
package/dist/server/config.js
CHANGED
|
@@ -14,6 +14,9 @@ export const CONFIG_DEFAULTS = {
|
|
|
14
14
|
basePath: ROOT_BASE_PATH,
|
|
15
15
|
dataDir: defaultDataDirectory(),
|
|
16
16
|
clientDir: packageClientDirectory(),
|
|
17
|
+
tikzGalleryEnabled: false,
|
|
18
|
+
/** Relative to the configuration file, like a relative storage.dataDir. */
|
|
19
|
+
tikzGalleryPath: path.join("addon", "texlite-tikz"),
|
|
17
20
|
sessionDays: 14,
|
|
18
21
|
compileTimeoutSeconds: 600,
|
|
19
22
|
maxCompileJobs: 10,
|
|
@@ -93,6 +96,8 @@ export function loadConfig(configPathOverride) {
|
|
|
93
96
|
databasePath: path.join(dataDir, "texlite.db"),
|
|
94
97
|
projectsDir: path.join(dataDir, "projects"),
|
|
95
98
|
clientDir,
|
|
99
|
+
tikzGalleryEnabled: fileConfig.tikzGallery?.enabled ?? CONFIG_DEFAULTS.tikzGalleryEnabled,
|
|
100
|
+
tikzGalleryDir: resolveConfiguredPath("tikzGallery.path", fileConfig.tikzGallery?.path ?? CONFIG_DEFAULTS.tikzGalleryPath, configDirectory),
|
|
96
101
|
sessionDays: integerSetting("sessionDays", process.env.TEXLITE_SESSION_DAYS, fileConfig.sessionDays, CONFIG_DEFAULTS.sessionDays, CONFIG_LIMITS.sessionDays),
|
|
97
102
|
compileTimeoutMs: compileTimeoutSeconds * 1000,
|
|
98
103
|
maxCompileJobs,
|
|
@@ -210,6 +215,11 @@ function validateFileConfig(config) {
|
|
|
210
215
|
optionalString(server?.basePath, "server.basePath", { min: 1, max: 1_024 });
|
|
211
216
|
const storage = optionalSection(config.storage, "storage");
|
|
212
217
|
optionalString(storage?.dataDir, "storage.dataDir", { min: 1, max: 4_096 });
|
|
218
|
+
const tikzGallery = optionalSection(config.tikzGallery, "tikzGallery");
|
|
219
|
+
if (tikzGallery && Object.prototype.hasOwnProperty.call(tikzGallery, "enabled") && typeof tikzGallery.enabled !== "boolean") {
|
|
220
|
+
throw configurationError("tikzGallery.enabled", "must be true or false");
|
|
221
|
+
}
|
|
222
|
+
optionalString(tikzGallery?.path, "tikzGallery.path", { min: 1, max: 4_096 });
|
|
213
223
|
const uploads = optionalSection(config.uploads, "uploads");
|
|
214
224
|
optionalInteger(uploads?.maxFileSizeMB, "uploads.maxFileSizeMB", CONFIG_LIMITS.maxFileSizeMB);
|
|
215
225
|
const pdf = optionalSection(config.pdf, "pdf");
|
package/dist/server/i18n.js
CHANGED
|
@@ -48,6 +48,9 @@ const enMessages = {
|
|
|
48
48
|
COMPILE_ARTIFACTS_NOT_FOUND: "No compiled artifacts are available yet.",
|
|
49
49
|
COMPILE_CLEAN_BUSY: "This root document is compiling. Try recovery again after it finishes.",
|
|
50
50
|
COMPILE_FORBIDDEN: "You do not have permission to compile this project.",
|
|
51
|
+
TIKZ_GALLERY_DISABLED: "The TikZ gallery is not enabled on this server.",
|
|
52
|
+
TIKZ_GALLERY_UNAVAILABLE: "The TikZ gallery add-on was not found on this server. Ask an administrator to install it.",
|
|
53
|
+
TIKZ_GALLERY_INCOMPATIBLE: "The installed TikZ gallery is not compatible with this version of TexLite. Ask an administrator to update it.",
|
|
51
54
|
COMPILE_SNAPSHOT_BUSY: "The project source is still being saved. Try compiling again shortly.",
|
|
52
55
|
CURRENT_PASSWORD_INVALID: "The current password is incorrect.",
|
|
53
56
|
PASSWORD_CHANGE_REQUIRED: "Change your temporary password before continuing.",
|
|
@@ -198,6 +201,9 @@ const zhMessages = {
|
|
|
198
201
|
COMPILE_ARTIFACTS_NOT_FOUND: "尚无可用的编译产物。",
|
|
199
202
|
COMPILE_CLEAN_BUSY: "当前主文档正在编译,请完成后再执行故障恢复。",
|
|
200
203
|
COMPILE_FORBIDDEN: "你没有编译此项目的权限。",
|
|
204
|
+
TIKZ_GALLERY_DISABLED: "此服务器未启用 TikZ 图库。",
|
|
205
|
+
TIKZ_GALLERY_UNAVAILABLE: "此服务器上找不到 TikZ 图库插件,请联系管理员安装。",
|
|
206
|
+
TIKZ_GALLERY_INCOMPATIBLE: "已安装的 TikZ 图库与当前 TexLite 版本不兼容,请联系管理员更新。",
|
|
201
207
|
COMPILE_SNAPSHOT_BUSY: "项目源码仍在保存,请稍后重新编译。",
|
|
202
208
|
CURRENT_PASSWORD_INVALID: "当前密码错误。",
|
|
203
209
|
PASSWORD_CHANGE_REQUIRED: "请先修改初始密码再继续。",
|
|
@@ -42,6 +42,9 @@ export const zhHantMessages = {
|
|
|
42
42
|
COMPILE_ARTIFACTS_NOT_FOUND: "尚無可用的編譯產出。",
|
|
43
43
|
COMPILE_CLEAN_BUSY: "目前主文件正在編譯,請完成後再執行故障排除。",
|
|
44
44
|
COMPILE_FORBIDDEN: "你沒有編譯此專案的權限。",
|
|
45
|
+
TIKZ_GALLERY_DISABLED: "此伺服器未啟用 TikZ 圖庫。",
|
|
46
|
+
TIKZ_GALLERY_UNAVAILABLE: "此伺服器上找不到 TikZ 圖庫外掛,請聯絡管理員安裝。",
|
|
47
|
+
TIKZ_GALLERY_INCOMPATIBLE: "已安裝的 TikZ 圖庫與目前 TexLite 版本不相容,請聯絡管理員更新。",
|
|
45
48
|
COMPILE_SNAPSHOT_BUSY: "專案原始碼仍在儲存,請稍後重新編譯。",
|
|
46
49
|
CURRENT_PASSWORD_INVALID: "目前密碼錯誤。",
|
|
47
50
|
PASSWORD_CHANGE_REQUIRED: "請先變更初始密碼再繼續。",
|
|
@@ -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
|
|
@@ -43,6 +43,7 @@ export function registerSystemRoutes(app, context) {
|
|
|
43
43
|
maxUploadSizeMB: Math.floor(config.maxUploadBytes / 1024 / 1024),
|
|
44
44
|
maxCollaborativeFileSizeMB: Math.floor(maxCollaborativeFileBytes(config) / 1024 / 1024),
|
|
45
45
|
allowedEngines: config.allowedEngines,
|
|
46
|
+
tikzGalleryEnabled: config.tikzGalleryEnabled,
|
|
46
47
|
allowProjectLatexmkrc: config.allowProjectLatexmkrc
|
|
47
48
|
}));
|
|
48
49
|
app.get("/api/health", async () => ({ ok: true, pid: process.pid, latexmk: config.latexmk }));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { requireUser } from "../auth.js";
|
|
3
|
+
import { apiError } from "../http.js";
|
|
4
|
+
import { TikzGalleryLibrary } from "../tikzGallery.js";
|
|
5
|
+
/** A preview comes from a repository this host only chose, not wrote: opened directly, it must not run as TexLite. */
|
|
6
|
+
const SVG_CSP = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
|
7
|
+
export function registerTikzGalleryRoutes(app, { config, db }) {
|
|
8
|
+
const library = new TikzGalleryLibrary(config.tikzGalleryDir);
|
|
9
|
+
app.get("/api/tikz-gallery/catalog", async (request, reply) => {
|
|
10
|
+
if (!requireUser(request, reply, db))
|
|
11
|
+
return;
|
|
12
|
+
if (!config.tikzGalleryEnabled)
|
|
13
|
+
return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
|
|
14
|
+
const result = library.catalog();
|
|
15
|
+
if (result.status === "unavailable")
|
|
16
|
+
return apiError(reply, 503, "TIKZ_GALLERY_UNAVAILABLE");
|
|
17
|
+
if (result.status === "incompatible")
|
|
18
|
+
return apiError(reply, 409, "TIKZ_GALLERY_INCOMPATIBLE");
|
|
19
|
+
reply.header("Cache-Control", "no-store");
|
|
20
|
+
return result.catalog;
|
|
21
|
+
});
|
|
22
|
+
app.get("/api/tikz-gallery/file", async (request, reply) => {
|
|
23
|
+
if (!requireUser(request, reply, db))
|
|
24
|
+
return;
|
|
25
|
+
if (!config.tikzGalleryEnabled)
|
|
26
|
+
return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
|
|
27
|
+
const { path: relative } = request.query;
|
|
28
|
+
const file = typeof relative === "string" ? library.listedFile(relative) : null;
|
|
29
|
+
if (!file)
|
|
30
|
+
return apiError(reply, 404, "FILE_NOT_FOUND");
|
|
31
|
+
reply.header("Cache-Control", "private, max-age=300").header("X-Content-Type-Options", "nosniff");
|
|
32
|
+
if (/\.svg$/i.test(file))
|
|
33
|
+
reply.header("Content-Security-Policy", SVG_CSP).type("image/svg+xml");
|
|
34
|
+
else
|
|
35
|
+
reply.type("text/plain; charset=utf-8");
|
|
36
|
+
return reply.send(fs.readFileSync(file));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Readable } from "node:stream";
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import { TIKZ_BRIDGE_PROTOCOL } from "../shared/tikzStandalone.js";
|
|
8
|
+
import { TIKZ_EDITOR_RELEASE } from "./tikzEditorRelease.js";
|
|
9
|
+
const REPOSITORY_URL = "https://github.com/SWUFE-DB-Group/TexLite";
|
|
10
|
+
const DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
|
|
11
|
+
const MANIFEST = "texlite-bridge.json";
|
|
12
|
+
/** Kept with the instance's data so it survives upgrades of the npm package. */
|
|
13
|
+
export function tikzEditorDirectory(dataDir) {
|
|
14
|
+
return path.join(dataDir, "addons", "tikz-editor");
|
|
15
|
+
}
|
|
16
|
+
export function tikzEditorDownloadUrl(release = TIKZ_EDITOR_RELEASE) {
|
|
17
|
+
return `${REPOSITORY_URL}/releases/download/${release.tag}/${release.asset}`;
|
|
18
|
+
}
|
|
19
|
+
function readManifest(directory) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(directory, MANIFEST), "utf8"));
|
|
22
|
+
return typeof parsed.protocol === "number" && typeof parsed.commit === "string" && typeof parsed.version === "string" && typeof parsed.build === "string"
|
|
23
|
+
? { protocol: parsed.protocol, commit: parsed.commit, version: parsed.version, build: parsed.build }
|
|
24
|
+
: null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function installedTikzEditor(dataDir) {
|
|
31
|
+
return readManifest(tikzEditorDirectory(dataDir));
|
|
32
|
+
}
|
|
33
|
+
async function download(url, destination, fetcher) {
|
|
34
|
+
let response;
|
|
35
|
+
try {
|
|
36
|
+
response = await fetcher(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new Error(`Could not download ${url}: ${error instanceof Error ? error.message : String(error)}. Without access to GitHub, fetch it elsewhere and use --file.`);
|
|
40
|
+
}
|
|
41
|
+
if (!response.ok || !response.body)
|
|
42
|
+
throw new Error(`Could not download ${url} (HTTP ${response.status}). Without access to GitHub, fetch it elsewhere and use --file.`);
|
|
43
|
+
await pipeline(Readable.fromWeb(response.body), fs.createWriteStream(destination));
|
|
44
|
+
}
|
|
45
|
+
async function sha256(file) {
|
|
46
|
+
const hash = createHash("sha256");
|
|
47
|
+
await pipeline(fs.createReadStream(file), hash);
|
|
48
|
+
return hash.digest("hex");
|
|
49
|
+
}
|
|
50
|
+
function extract(archive, destination) {
|
|
51
|
+
fs.mkdirSync(destination);
|
|
52
|
+
const result = spawnSync("tar", ["-xzf", archive, "--no-same-owner", "-C", destination], { encoding: "utf8" });
|
|
53
|
+
if (result.error)
|
|
54
|
+
throw new Error(`Could not run tar to unpack the editor: ${result.error.message}`);
|
|
55
|
+
if (result.status !== 0)
|
|
56
|
+
throw new Error(`Could not unpack the editor: ${result.stderr.trim()}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Verifies the archive against the digest pinned in this TexLite version, then
|
|
60
|
+
* swaps it in whole, so a failure leaves any existing install untouched. A
|
|
61
|
+
* running server picks up the new files without a restart.
|
|
62
|
+
*/
|
|
63
|
+
export async function installTikzEditor(dataDir, options = {}) {
|
|
64
|
+
const release = options.release ?? TIKZ_EDITOR_RELEASE;
|
|
65
|
+
if (!options.file && !release.sha256)
|
|
66
|
+
throw new Error("This TexLite build has no TikZ Editor release pinned.");
|
|
67
|
+
const target = tikzEditorDirectory(dataDir);
|
|
68
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
69
|
+
const work = fs.mkdtempSync(path.join(path.dirname(target), ".install-"));
|
|
70
|
+
try {
|
|
71
|
+
let archive = options.file ? path.resolve(options.file) : path.join(work, release.asset);
|
|
72
|
+
if (options.file) {
|
|
73
|
+
if (!fs.existsSync(archive))
|
|
74
|
+
throw new Error(`File not found: ${archive}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const url = tikzEditorDownloadUrl(release);
|
|
78
|
+
options.onDownload?.(url);
|
|
79
|
+
await download(url, archive, options.fetcher ?? fetch);
|
|
80
|
+
}
|
|
81
|
+
const actual = await sha256(archive);
|
|
82
|
+
if (actual !== release.sha256) {
|
|
83
|
+
throw new Error(`The archive is not the TikZ Editor build for this TexLite version (expected ${release.asset}, SHA-256 ${release.sha256}, got ${actual}).`);
|
|
84
|
+
}
|
|
85
|
+
const staged = path.join(work, "editor");
|
|
86
|
+
extract(archive, staged);
|
|
87
|
+
const manifest = readManifest(staged);
|
|
88
|
+
if (!manifest || manifest.protocol !== TIKZ_BRIDGE_PROTOCOL || manifest.build !== release.build || !fs.existsSync(path.join(staged, "index.html"))) {
|
|
89
|
+
throw new Error("The archive does not contain a compatible TikZ Editor build.");
|
|
90
|
+
}
|
|
91
|
+
const previous = path.join(work, "previous");
|
|
92
|
+
const replacing = fs.existsSync(target);
|
|
93
|
+
if (replacing)
|
|
94
|
+
fs.renameSync(target, previous);
|
|
95
|
+
try {
|
|
96
|
+
fs.renameSync(staged, target);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (replacing)
|
|
100
|
+
fs.renameSync(previous, target);
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
return manifest;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
fs.rmSync(work, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Returns whether an editor was installed. */
|
|
110
|
+
export function removeTikzEditor(dataDir) {
|
|
111
|
+
const target = tikzEditorDirectory(dataDir);
|
|
112
|
+
const installed = readManifest(target) !== null;
|
|
113
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
114
|
+
return installed;
|
|
115
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Written by scripts/build-tikz-editor.mjs. Do not edit by hand.
|
|
2
|
+
export const TIKZ_EDITOR_RELEASE = {
|
|
3
|
+
version: "1.1.0",
|
|
4
|
+
commit: "2056d9649e89312041ab8353845ec7addc2a8304",
|
|
5
|
+
build: "a2398522",
|
|
6
|
+
tag: "tikz-editor-1.1.0-2056d96-a2398522",
|
|
7
|
+
asset: "tikz-editor-1.1.0-2056d96-a2398522.tar.gz",
|
|
8
|
+
sha256: "f3feb955a7fd2d7fa47746271f663642bd956423389ceddfed40d0c30d5197d4"
|
|
9
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/** The catalog format this TexLite can read; see the add-on's README. */
|
|
4
|
+
const SUPPORTED_CATALOG_VERSION = 1;
|
|
5
|
+
const MAX_FIGURE_FILE_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
/** A file inside `root` once symbolic links are followed, or null. */
|
|
7
|
+
function containedFile(root, relative) {
|
|
8
|
+
try {
|
|
9
|
+
const realRoot = fs.realpathSync(root);
|
|
10
|
+
const real = fs.realpathSync(path.resolve(realRoot, relative));
|
|
11
|
+
return real.startsWith(`${realRoot}${path.sep}`) && fs.statSync(real).isFile() ? real : null;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isCatalog(value) {
|
|
18
|
+
const catalog = value;
|
|
19
|
+
return typeof catalog === "object" && catalog !== null && catalog.version === SUPPORTED_CATALOG_VERSION && Array.isArray(catalog.items)
|
|
20
|
+
&& catalog.items.every((item) => typeof item?.tex === "string" && typeof item.preview === "string");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reads the add-on an administrator placed on this host. The directory is a
|
|
24
|
+
* whole repository, so only the files its catalog lists are ever exposed. It
|
|
25
|
+
* is read per request (the parse is cached) so `git pull` needs no restart.
|
|
26
|
+
*/
|
|
27
|
+
export class TikzGalleryLibrary {
|
|
28
|
+
directory;
|
|
29
|
+
cached = null;
|
|
30
|
+
constructor(directory) {
|
|
31
|
+
this.directory = directory;
|
|
32
|
+
}
|
|
33
|
+
load() {
|
|
34
|
+
const file = containedFile(this.directory, "catalog.json");
|
|
35
|
+
if (!file)
|
|
36
|
+
return { result: { status: "unavailable" }, listed: new Set() };
|
|
37
|
+
const stat = fs.statSync(file);
|
|
38
|
+
const stamp = `${stat.mtimeMs}:${stat.size}`;
|
|
39
|
+
if (this.cached?.stamp === stamp)
|
|
40
|
+
return this.cached;
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
parsed = null;
|
|
47
|
+
}
|
|
48
|
+
const result = isCatalog(parsed) ? { status: "ok", catalog: parsed } : { status: "incompatible" };
|
|
49
|
+
const listed = new Set(result.status === "ok" ? result.catalog.items.flatMap(({ tex, preview }) => [tex, preview]) : []);
|
|
50
|
+
this.cached = { stamp, result, listed };
|
|
51
|
+
return this.cached;
|
|
52
|
+
}
|
|
53
|
+
catalog() {
|
|
54
|
+
return this.load().result;
|
|
55
|
+
}
|
|
56
|
+
/** The path of a figure source or preview the catalog lists, or null. */
|
|
57
|
+
listedFile(relative) {
|
|
58
|
+
if (!this.load().listed.has(relative) || !/\.(?:tex|svg)$/i.test(relative))
|
|
59
|
+
return null;
|
|
60
|
+
const file = containedFile(this.directory, relative);
|
|
61
|
+
return file && fs.statSync(file).size <= MAX_FIGURE_FILE_BYTES ? file : null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { maskLatexComments, maskLatexLiteralContent } from "./latexLiterals.js";
|
|
2
|
+
/**
|
|
3
|
+
* A complete `standalone` document that draws with TikZ, as opposed to a main
|
|
4
|
+
* document. Comments and verbatim examples do not count.
|
|
5
|
+
*/
|
|
6
|
+
export function isStandaloneTikz(source) {
|
|
7
|
+
if (!source.includes("standalone"))
|
|
8
|
+
return false;
|
|
9
|
+
const visible = maskLatexComments(maskLatexLiteralContent(source));
|
|
10
|
+
const declaration = /\\documentclass(?![A-Za-z@])\s*(?:\[([^\]]*)\]\s*)?\{\s*standalone\s*\}/.exec(visible);
|
|
11
|
+
if (!declaration)
|
|
12
|
+
return false;
|
|
13
|
+
return (declaration[1] ?? "").split(",").some((option) => option.trim() === "tikz")
|
|
14
|
+
|| /\\begin\s*\{tikzpicture\}/.test(visible);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "texlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "A lightweight local-first collaborative LaTeX workspace",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"OPERATIONS.md",
|
|
29
29
|
"DESIGN.md",
|
|
30
30
|
"NPM_TESTING.md",
|
|
31
|
+
"addon.md",
|
|
31
32
|
"LICENSE",
|
|
32
33
|
"THIRD_PARTY_NOTICES.md",
|
|
33
34
|
"texlite.config.example.json"
|
|
@@ -130,6 +130,18 @@ file modification times or treating an older retained PDF as the latest result.
|
|
|
130
130
|
- Summarize the files changed and checks performed. If you did not recompile,
|
|
131
131
|
or could not verify a fix, state that explicitly.
|
|
132
132
|
|
|
133
|
+
## TikZ and pgfplots figures
|
|
134
|
+
|
|
135
|
+
Before creating or substantially editing a TikZ or pgfplots figure, read
|
|
136
|
+
`tikzGuide` from the JSON file named by `TEXLITE_PROJECT_CONTEXT`. If it is a
|
|
137
|
+
path, TexLite's figure library is installed: read that file and follow it for the
|
|
138
|
+
figure work. If it is `null` or missing, continue without it.
|
|
139
|
+
|
|
140
|
+
That file and the library directory containing it are a read-only exception to
|
|
141
|
+
working in this project's source tree. Copy what you need into the project and
|
|
142
|
+
never change anything in the library. The guide applies only to figure work and
|
|
143
|
+
does not change the rest of these instructions.
|
|
144
|
+
|
|
133
145
|
This file was copied from TexLite's default template because the project had
|
|
134
146
|
no root `AGENTS.md`. Project maintainers can edit it; TexLite does not overwrite
|
|
135
147
|
an existing file.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AgentTerminalSurface-COqg_GdK.js","./rolldown-runtime-XKyaHtl9.js","./react-DUEFWlB7.js","./relativeTime-mmWGtWRR.js","./i18nInstance-CIMFwH0l.js","./useTranslation-DwkoADSz.js","./basePath-B5-c90eh.js","./createLucideIcon-CDYIzuiB.js","./useDeletionTransitions-Ba_yhkrl.js","./dist-B_WjsTVV.js","./es2015-D2UDOM09.js","./index-CPR6YZEf.js","./i18n-Dtn6w-qA.js","./vite-runtime-CRzLMJPS.js","./loader-circle-DKGyi5EK.js","./dist-DdUqlCPw.js","./index-BbU2fbRw.css","./AgentIcon-CA-PfOka.js","./AgentIcon-DeoZDwgh.css","./AgentTerminalSurface-B5LH8GIb.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{_ as r,d as i,m as a,r as o,u as s}from"./relativeTime-mmWGtWRR.js";import{t as c}from"./useTranslation-DwkoADSz.js";import{t as l}from"./vite-runtime-CRzLMJPS.js";import{t as u}from"./createLucideIcon-CDYIzuiB.js";import{E as d,H as f,P as p,T as m,c as h,w as g,x as _}from"./useDeletionTransitions-Ba_yhkrl.js";import{t as v}from"./check-Dw16EqG-.js";import{o as y}from"./dist-B_WjsTVV.js";import{t as b}from"./chevron-up-BHaMUEEA.js";import{i as x,n as S,t as C}from"./AgentIcon-CA-PfOka.js";import{S as ee}from"./sourceCursorStore-BVDvDKeP.js";import{t as w}from"./git-compare-arrows-158rS_vn.js";import{t as T}from"./InfoPopover-Ba7GvcuW.js";import{t as E}from"./loader-circle-DKGyi5EK.js";import{t as te}from"./plus-Cei21TlT.js";import{t as D}from"./refresh-cw-IqExWG6S.js";import{t as ne}from"./SaveButton-wiTpGLho.js";import{g as re,w as O,y as k}from"./index-CPR6YZEf.js";import{a as A,i as j,l as M,n as N,o as P,s as F,t as I}from"./dist-C9O-A_C4.js";import{n as L}from"./ProjectWorkspace-B-w2ix8N.js";var R={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};R.node;var z=u(R),B=e(t(),1);function V(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)({tasks:[],page:1,pageSize:50,total:0}),[a,s]=(0,B.useState)(1),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(!1),m=(0,B.useRef)(!1),h=(0,B.useRef)(0),g=(0,B.useRef)(!1),[_,v]=(0,B.useState)(0);(0,B.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,B.useEffect)(()=>{let e=new AbortController;return O(`/api/agents`,{signal:e.signal}).then(n).catch(t=>{e.signal.aborted||d(k(t))}),()=>e.abort()},[e,_]),(0,B.useEffect)(()=>{let t,n=!1,r=()=>{if(document.visibilityState===`hidden`||m.current)return;t?.abort(),t=new AbortController;let r=t,o=h.current,s=new URLSearchParams({project:e,page:String(a)});O(`/api/agent-tasks?${s}`,{signal:r.signal}).then(e=>{n||r.signal.aborted||o!==h.current||(i(e),l(t=>e.tasks.some(e=>e.id===t)?t:e.tasks[0]?.id??``))}).catch(e=>{!n&&!r.signal.aborted&&o===h.current&&d(k(e))})};r();let o=window.setInterval(r,5e3);return window.addEventListener(`focus`,r),()=>{n=!0,t?.abort(),window.clearInterval(o),window.removeEventListener(`focus`,r)}},[e,a,_]);let y=(0,B.useCallback)(()=>v(e=>e+1),[]),b=(0,B.useCallback)(e=>{h.current++,i(t=>({...t,activeTaskId:[`starting`,`running`,`stopping`].includes(e.state)?e.id:t.activeTaskId===e.id?null:t.activeTaskId,tasks:t.tasks.some(t=>t.id===e.id)?t.tasks.map(t=>t.id===e.id?e:t):[e,...t.tasks],total:t.tasks.some(t=>t.id===e.id)?t.total:t.total+1})),m.current||o()},[]);return{catalog:t,result:r,page:a,setPage:s,selectedId:c,setSelectedId:l,selected:r.tasks.find(e=>e.id===c)??null,error:u,setError:d,busy:f,mutate:async e=>{if(!m.current){m.current=!0,h.current++,p(!0),d(``);try{return await e()}catch(e){g.current&&d(k(e))}finally{m.current=!1,o(),g.current&&(p(!1),y())}}},acceptTask:b}}var H=n();function ie({agents:e,value:t,onChange:n,disabled:r=!1}){let{t:i}=c(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),l=e.find(e=>e.id===t),u=r||e.length===0;return(0,B.useEffect)(()=>{u&&o(!1)},[u]),(0,H.jsxs)(I,{modal:!1,open:a,onOpenChange:o,children:[(0,H.jsx)(M,{asChild:!0,children:(0,H.jsxs)(`button`,{ref:s,type:`button`,className:`agent-select-trigger`,disabled:u,"aria-label":l?`${i(`agents.agent`)}: ${l.label}`:i(`agents.agent`),children:[l&&(0,H.jsx)(C,{agent:l.id,size:16}),(0,H.jsx)(`span`,{children:l?.label??i(`agents.agent`)}),(0,H.jsx)(y,{size:13,"aria-hidden":`true`})]})}),(0,H.jsx)(A,{container:s.current?.closest(`[role="dialog"]`),children:(0,H.jsx)(N,{className:`agent-select-options`,side:`top`,align:`start`,sideOffset:5,collisionPadding:8,children:(0,H.jsx)(P,{value:t,"aria-label":i(`agents.agent`),onValueChange:t=>{let r=e.find(e=>e.id===t);!u&&r?.installed&&r.enabled&&n(r.id)},children:e.map(e=>(0,H.jsxs)(F,{value:e.id,textValue:e.label,className:`agent-select-option`,disabled:u||!e.installed||!e.enabled,children:[(0,H.jsx)(C,{agent:e.id,size:16}),(0,H.jsxs)(`span`,{className:`agent-select-label`,children:[e.label,(!e.installed||!e.enabled)&&(0,H.jsx)(`small`,{children:i(e.installed?`agents.disabled`:`agents.notInstalled`)})]}),(0,H.jsx)(j,{className:`agent-select-check`,children:(0,H.jsx)(v,{size:14,"aria-hidden":`true`})})]},e.id))})})})]})}function U({change:e}){let t=e.after??``,n=[],r=0;for(let i of[...e.pieces].sort((e,t)=>e.from-t.from)){let a=Math.max(r,i.from-e.afterFrom),o=Math.min(t.length,i.to-e.afterFrom);o<=a||(a>r&&n.push({text:t.slice(r,a),agent:!1}),n.push({text:t.slice(a,o),agent:!0}),r=o)}return r<t.length&&n.push({text:t.slice(r),agent:!1}),(0,H.jsx)(`pre`,{className:`agent-review-content`,children:n.map((e,t)=>e.agent?(0,H.jsx)(`mark`,{children:e.text},t):(0,H.jsx)(`span`,{children:e.text},t))})}function W({review:e,activeId:t,onShow:n,focus:i=null}){let{t:a,i18n:o}=c(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(i?.id??t),[m,g]=(0,B.useState)(`diff`),{pending:_}=e,x=(0,B.useMemo)(()=>{let e=_.findIndex(e=>e.id===u);return e>=0?e:_.length?0:-1},[_,u]),S=x>=0?_[x]:null;(0,B.useEffect)(()=>{i&&(d(i.id),l(!0))},[i?.nonce]),(0,B.useEffect)(()=>{S&&S.id!==u&&d(S.id)},[S,u]);let C=e=>{let t=_[(e+_.length)%_.length];t&&(d(t.id),l(!0),n(t,!1))};return!_.length&&!e.loading&&!e.error?null:(0,H.jsxs)(`section`,{className:`agent-review`,"aria-label":a(`agents.reviewTitle`),children:[(0,H.jsxs)(`div`,{className:`agent-review-bar`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`agent-review-toggle`,"aria-expanded":s,onClick:()=>l(e=>!e),children:[(0,H.jsx)(w,{size:13,"aria-hidden":!0}),a(`agents.reviewTitle`),(0,H.jsx)(`span`,{className:`agent-review-count`,children:_.length}),s?(0,H.jsx)(b,{size:13,"aria-hidden":!0}):(0,H.jsx)(y,{size:13,"aria-hidden":!0})]}),_.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.previousChange`),title:a(`agents.previousChange`),onClick:()=>C(x-1),children:(0,H.jsx)(r,{size:13})}),(0,H.jsxs)(`small`,{className:`agent-review-position`,children:[x+1,` / `,_.length]}),(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.nextChange`),title:a(`agents.nextChange`),onClick:()=>C(x+1),children:(0,H.jsx)(f,{size:13})})]}),(0,H.jsx)(`span`,{className:`agent-toolbar-spacer`}),_.length>0&&(0,H.jsxs)(`button`,{type:`button`,onClick:e.markAllReviewed,children:[(0,H.jsx)(z,{size:12,"aria-hidden":!0}),a(`agents.markAllReviewed`)]}),(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.refreshChanges`),title:a(`agents.refreshChanges`),disabled:e.loading,onClick:e.refresh,children:e.loading?(0,H.jsx)(E,{className:`spin`,size:13}):(0,H.jsx)(D,{size:13})})]}),e.error&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:e.error}),s&&S&&(0,H.jsxs)(`div`,{className:`agent-review-detail`,children:[(0,H.jsxs)(`div`,{className:`agent-review-location`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`agent-review-file`,onClick:()=>n(S,!0),title:a(`agents.openChange`),children:[(0,H.jsx)(p,{size:12,"aria-hidden":!0}),(0,H.jsxs)(`span`,{children:[S.path,`:`,S.line]})]}),(0,H.jsx)(`time`,{dateTime:S.at,children:h(S.at,o.resolvedLanguage,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),(0,H.jsxs)(`div`,{className:`agent-review-tabs`,role:`tablist`,"aria-label":a(`agents.reviewTitle`),children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-content-${S.id}`,"aria-selected":m===`content`,"aria-controls":`agent-review-panel`,className:m===`content`?`active`:``,onClick:()=>g(`content`),children:a(`agents.contentTab`)}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-diff-${S.id}`,"aria-selected":m===`diff`,"aria-controls":`agent-review-panel`,className:m===`diff`?`active`:``,onClick:()=>g(`diff`),children:a(`agents.diffTab`)})]}),(0,H.jsx)(`div`,{id:`agent-review-panel`,role:`tabpanel`,"aria-labelledby":`agent-review-tab-${m}-${S.id}`,children:m===`content`?S.after===null?(0,H.jsx)(`p`,{className:`agent-review-unavailable`,children:a(`agents.contentUnavailable`)}):(0,H.jsx)(U,{change:S}):S.before!==null&&S.after!==null?(0,H.jsx)(L,{original:S.before,replacement:S.after}):(0,H.jsx)(`p`,{className:`agent-review-unavailable`,children:a(`agents.changePreviewUnavailable`)})}),(0,H.jsxs)(`div`,{className:`agent-review-actions`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(S,!0),children:[(0,H.jsx)(p,{size:12,"aria-hidden":!0}),a(`agents.openChange`)]}),(0,H.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>{if(!S)return;let t=_[x+1]??_[x-1]??null;e.markReviewed(S),d(t?.id??null),t&&n(t,!1)},children:[(0,H.jsx)(v,{size:12,"aria-hidden":!0}),a(`agents.markReviewed`)]})]})]})]})}var ae=(0,B.lazy)(()=>l(()=>import(`./AgentTerminalSurface-COqg_GdK.js`).then(e=>({default:e.AgentTerminalSurface})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),import.meta.url));function G({projectId:e,readOnly:t,onHide:n,maximized:o=!1,onToggleMaximized:l,review:u,activeChangeId:p=null,onShowChange:h,reviewFocus:v=null}){let{t:w}=c(),D=V(e),k=s(),A=D.selected,[j,M]=(0,B.useState)(!1),[N,P]=(0,B.useState)(``),[F,I]=(0,B.useState)(``),[L,R]=(0,B.useState)(!1),[z,U]=(0,B.useState)(``),[G,K]=(0,B.useState)(!1),q=A&&[`starting`,`running`,`stopping`].includes(A.state),oe=A&&(A.canResume||A.startedAt!==null||[`stopped`,`exited`,`interrupted`].includes(A.state)),J=D.catalog?.agents.find(e=>e.id===A?.agentId),Y=D.catalog?.agents.filter(e=>e.installed&&e.enabled)??[],X=F?D.catalog?.agents.find(e=>e.id===F):Y[0],Z=!!(D.result.activeTaskId&&D.result.activeTaskId!==A?.id),Q=t||D.busy||!!D.result.activeTaskId||!D.catalog?.ptyAvailable||!X?.installed||!X.enabled,se=!Z&&!t&&J?.installed&&J.enabled&&D.catalog?.ptyAvailable&&A?.cleanupState===`none`,ce=e=>{D.setSelectedId(e),R(!1)},$=e=>D.mutate(async()=>{if(!A)return;let t=await O(`/api/agent-tasks/${A.id}${e}`,{method:`POST`});D.acceptTask(t.task)});return(0,H.jsxs)(`section`,{className:`agent-terminal-panel`,"data-agent-terminal":`true`,"aria-label":w(`agents.terminal`),children:[(0,H.jsxs)(`div`,{className:`agent-terminal-heading`,children:[(0,H.jsxs)(`strong`,{children:[(0,H.jsx)(d,{size:14}),w(`agents.terminal`)]}),(0,H.jsx)(T,{className:`agent-session-help`,content:w(`agents.sessionManagementHint`),size:13}),(0,H.jsx)(`div`,{className:`agent-task-tabs`,role:`tablist`,"aria-label":w(`agents.tasks`),children:D.result.tasks.map(e=>(0,H.jsxs)(`button`,{role:`tab`,type:`button`,"aria-selected":e.id===A?.id,title:e.title,className:e.id===A?.id?`active`:``,onClick:()=>ce(e.id),children:[(0,H.jsx)(`span`,{className:`agent-state-dot ${e.state}`}),(0,H.jsx)(C,{agent:e.agentId,size:13}),(0,H.jsx)(`span`,{children:e.title}),(0,H.jsx)(`small`,{children:S[e.agentId]})]},e.id))}),(0,H.jsx)(`button`,{className:`agent-icon-button`,disabled:t||D.busy||!Y.length,title:w(`agents.newTask`),"aria-label":w(`agents.newTask`),onClick:()=>M(e=>!e),children:(0,H.jsx)(te,{size:15})}),l&&(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,title:w(o?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-label":w(o?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-pressed":o,onClick:l,children:o?(0,H.jsx)(y,{size:15}):(0,H.jsx)(b,{size:15})}),(0,H.jsx)(`button`,{className:`agent-icon-button`,title:w(`agents.hide`),"aria-label":w(`agents.hide`),onClick:n,children:(0,H.jsx)(_,{size:15})})]}),(A||D.result.total>D.result.pageSize)&&(0,H.jsxs)(`div`,{className:`agent-task-toolbar`,children:[D.result.total>D.result.pageSize&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{disabled:D.result.page<=1,"aria-label":w(`agents.previous`),onClick:()=>D.setPage(D.result.page-1),children:(0,H.jsx)(r,{size:13})}),(0,H.jsxs)(`small`,{children:[D.result.page,` / `,Math.ceil(D.result.total/D.result.pageSize)]}),(0,H.jsx)(`button`,{disabled:D.result.page*D.result.pageSize>=D.result.total,"aria-label":w(`agents.next`),onClick:()=>D.setPage(D.result.page+1),children:(0,H.jsx)(f,{size:13})})]}),A&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`agent-task-state`,children:w(`agents.state_${A.state}`)}),(0,H.jsx)(`span`,{className:`agent-toolbar-spacer`}),q?(0,H.jsxs)(`button`,{disabled:D.busy,onClick:()=>void $(`/stop`),children:[(0,H.jsx)(x,{size:12}),w(`agents.end`)]}):(0,H.jsxs)(`button`,{disabled:!se||D.busy,onClick:()=>void $(`/start`),children:[(0,H.jsx)(ee,{size:13}),w(oe?`agents.resume`:`agents.start`)]}),(0,H.jsx)(`button`,{className:`agent-icon-button`,title:w(`agents.rename`),"aria-label":w(`agents.rename`),disabled:D.busy,onClick:()=>{U(A.title),R(e=>!e)},children:(0,H.jsx)(a,{size:13})}),(0,H.jsx)(`button`,{className:`agent-icon-button agent-danger`,title:w(`agents.delete`),"aria-label":w(`agents.delete`),disabled:D.busy,onClick:()=>{D.setError(``),K(!0)},children:(0,H.jsx)(m,{size:13})})]})]}),(j||!A)&&(0,H.jsxs)(`form`,{className:`agent-task-create`,onSubmit:t=>{t.preventDefault(),!Q&&D.mutate(async()=>{let t=X?.id,n=await O(`/api/projects/${e}/agent-tasks`,{method:`POST`,body:JSON.stringify({agentId:t,title:N})});D.acceptTask(n.task),D.setPage(1),D.setSelectedId(n.task.id),M(!1),P(``);let r=await O(`/api/agent-tasks/${n.task.id}/start`,{method:`POST`});D.acceptTask(r.task)})},children:[(0,H.jsx)(`input`,{"aria-label":w(`agents.task`),placeholder:w(`agents.titlePlaceholder`),maxLength:160,value:N,onChange:e=>P(e.target.value),disabled:D.busy||t}),(0,H.jsx)(ie,{agents:D.catalog?.agents??[],value:X?.id??``,onChange:I,disabled:t||D.busy}),(0,H.jsxs)(`button`,{type:`submit`,disabled:Q,children:[D.busy&&(0,H.jsx)(E,{className:`spin`,size:13}),w(`agents.create`)]})]}),L&&A&&(0,H.jsxs)(`form`,{className:`agent-task-create`,onSubmit:e=>{e.preventDefault(),D.mutate(async()=>{let e=await O(`/api/agent-tasks/${A.id}`,{method:`PATCH`,body:JSON.stringify({title:z})});D.acceptTask(e.task),R(!1)})},children:[(0,H.jsx)(`input`,{value:z,onChange:e=>U(e.target.value),required:!0,maxLength:160,"aria-label":w(`agents.task`)}),(0,H.jsx)(ne,{type:`submit`,saving:D.busy,children:w(`common.save`)})]}),D.error&&!G&&(0,H.jsxs)(`p`,{className:`error agent-inline-error`,role:`alert`,children:[D.error,(0,H.jsx)(`button`,{onClick:()=>D.setError(``),"aria-label":w(`common.close`),children:(0,H.jsx)(_,{size:13})})]}),A?.errorCode&&!D.error&&!G&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:w(`errors.codes.${A.errorCode}`,{defaultValue:w(`agents.taskUnavailable`)})}),(Z||j&&D.result.activeTaskId)&&(0,H.jsxs)(`p`,{className:`agent-inline-warning`,role:`status`,children:[(0,H.jsx)(g,{size:14,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:w(`errors.codes.AGENT_PROJECT_BUSY`)})]}),D.catalog&&!D.catalog.ptyAvailable&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,children:w(`agents.ptyUnavailable`)}),u&&h&&(0,H.jsx)(W,{review:u,activeId:p,onShow:h,focus:v}),(0,H.jsx)(`div`,{className:`agent-terminal-body`,style:i(k.theme),children:(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(`div`,{className:`agent-task-empty`,children:(0,H.jsx)(E,{className:`spin`,size:18})}),children:A&&q&&!t?(0,H.jsx)(ae,{task:A,onTask:D.acceptTask},A.id):(0,H.jsxs)(`div`,{className:`agent-task-empty`,children:[(0,H.jsx)(d,{size:24}),(0,H.jsx)(`strong`,{children:A?.title||w(`agents.noTasks`)}),(0,H.jsx)(`p`,{children:w(t?`agents.permissionLost`:`agents.readyHint`)}),A?.exitCode!==null&&A?.exitCode!==void 0&&A.exitCode!==0&&(0,H.jsx)(`small`,{children:w(`agents.exitCode`,{code:A.exitCode})})]})})}),k.showExecutionReminder&&q&&A.state!==`stopping`&&(0,H.jsxs)(`p`,{className:`agent-execution-reminder`,children:[(0,H.jsx)(g,{size:12,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:w(`agents.endReminder`)})]}),A&&(0,H.jsx)(re,{open:G,title:w(`agents.delete`),description:w(`agents.deleteDescription`),onOpenChange:e=>{D.busy||K(e)},footer:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{disabled:D.busy,onClick:()=>K(!1),children:w(`common.cancel`)}),(0,H.jsxs)(`button`,{className:`danger`,disabled:D.busy,onClick:()=>void D.mutate(async()=>{await O(`/api/agent-tasks/${A.id}`,{method:`DELETE`}),K(!1)}),children:[D.busy&&(0,H.jsx)(E,{className:`spin`,size:13}),w(`agents.delete`)]})]}),children:D.error&&(0,H.jsx)(`p`,{className:`error`,role:`alert`,children:D.error})})]})}export{G as AgentTerminal};
|
|
Binary file
|
|
Binary file
|