dsh-typst-plugin 0.0.0-stage → 0.1.0-alpha.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.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +87 -0
  3. package/README.md +86 -2
  4. package/cordis.patch.yml +6 -0
  5. package/docs/images/icon.png +0 -0
  6. package/docs/plugin-detail.en.md +2 -0
  7. package/docs/plugin-detail.md +2 -0
  8. package/lib/client.js +41044 -0
  9. package/lib/client.js.map +7 -0
  10. package/lib/config.d.ts +50 -0
  11. package/lib/config.d.ts.map +1 -0
  12. package/lib/config.js +31 -0
  13. package/lib/config.js.map +7 -0
  14. package/lib/constants.d.ts +58 -0
  15. package/lib/constants.d.ts.map +1 -0
  16. package/lib/constants.js +62 -0
  17. package/lib/constants.js.map +7 -0
  18. package/lib/contract.d.ts +179 -0
  19. package/lib/contract.d.ts.map +1 -0
  20. package/lib/contract.js +1 -0
  21. package/lib/contract.js.map +7 -0
  22. package/lib/errors.d.ts +77 -0
  23. package/lib/errors.d.ts.map +1 -0
  24. package/lib/errors.js +86 -0
  25. package/lib/errors.js.map +7 -0
  26. package/lib/host/facts.d.ts +31 -0
  27. package/lib/host/facts.d.ts.map +1 -0
  28. package/lib/host/facts.js +151 -0
  29. package/lib/host/facts.js.map +7 -0
  30. package/lib/index.d.ts +2 -0
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +5 -0
  33. package/lib/index.js.map +7 -0
  34. package/lib/remote.d.ts +69 -0
  35. package/lib/remote.d.ts.map +1 -0
  36. package/lib/remote.js +146 -0
  37. package/lib/remote.js.map +7 -0
  38. package/lib/service.d.ts +47 -0
  39. package/lib/service.d.ts.map +1 -0
  40. package/lib/service.js +110 -0
  41. package/lib/service.js.map +7 -0
  42. package/lib/skills/typst.d.ts +13 -0
  43. package/lib/skills/typst.d.ts.map +1 -0
  44. package/lib/skills/typst.js +72 -0
  45. package/lib/skills/typst.js.map +7 -0
  46. package/lib/status-codec.d.ts +11 -0
  47. package/lib/status-codec.d.ts.map +1 -0
  48. package/lib/status-codec.js +6 -0
  49. package/lib/status-codec.js.map +7 -0
  50. package/lib/tools/registration.d.ts +22 -0
  51. package/lib/tools/registration.d.ts.map +1 -0
  52. package/lib/tools/registration.js +525 -0
  53. package/lib/tools/registration.js.map +7 -0
  54. package/lib/tools/shared.d.ts +31 -0
  55. package/lib/tools/shared.d.ts.map +1 -0
  56. package/lib/tools/shared.js +70 -0
  57. package/lib/tools/shared.js.map +7 -0
  58. package/lib/typert.d.ts +23 -0
  59. package/lib/typert.d.ts.map +1 -0
  60. package/lib/typert.js +67 -0
  61. package/lib/typert.js.map +7 -0
  62. package/lib/typst/diagnostics.d.ts +58 -0
  63. package/lib/typst/diagnostics.d.ts.map +1 -0
  64. package/lib/typst/diagnostics.js +171 -0
  65. package/lib/typst/diagnostics.js.map +7 -0
  66. package/lib/typst/locate.d.ts +68 -0
  67. package/lib/typst/locate.d.ts.map +1 -0
  68. package/lib/typst/locate.js +194 -0
  69. package/lib/typst/locate.js.map +7 -0
  70. package/lib/typst/mainfile.d.ts +21 -0
  71. package/lib/typst/mainfile.d.ts.map +1 -0
  72. package/lib/typst/mainfile.js +64 -0
  73. package/lib/typst/mainfile.js.map +7 -0
  74. package/lib/typst/match.d.ts +59 -0
  75. package/lib/typst/match.d.ts.map +1 -0
  76. package/lib/typst/match.js +171 -0
  77. package/lib/typst/match.js.map +7 -0
  78. package/lib/typst/oneshot.d.ts +45 -0
  79. package/lib/typst/oneshot.d.ts.map +1 -0
  80. package/lib/typst/oneshot.js +76 -0
  81. package/lib/typst/oneshot.js.map +7 -0
  82. package/lib/typst/pdf-extract.d.ts +29 -0
  83. package/lib/typst/pdf-extract.d.ts.map +1 -0
  84. package/lib/typst/pdf-extract.js +87 -0
  85. package/lib/typst/pdf-extract.js.map +7 -0
  86. package/lib/typst/pdfjs-worker.d.js +1 -0
  87. package/lib/typst/pdfjs-worker.d.js.map +7 -0
  88. package/lib/typst/text.d.ts +65 -0
  89. package/lib/typst/text.d.ts.map +1 -0
  90. package/lib/typst/text.js +314 -0
  91. package/lib/typst/text.js.map +7 -0
  92. package/lib/typst/watcher.d.ts +77 -0
  93. package/lib/typst/watcher.d.ts.map +1 -0
  94. package/lib/typst/watcher.js +219 -0
  95. package/lib/typst/watcher.js.map +7 -0
  96. package/lib/wire-schemas.d.ts +578 -0
  97. package/lib/wire-schemas.d.ts.map +1 -0
  98. package/lib/wire-schemas.js +384 -0
  99. package/lib/wire-schemas.js.map +7 -0
  100. package/lib/workspace/session.d.ts +209 -0
  101. package/lib/workspace/session.d.ts.map +1 -0
  102. package/lib/workspace/session.js +1232 -0
  103. package/lib/workspace/session.js.map +7 -0
  104. package/locale/en.json +9 -0
  105. package/locale/zh.json +9 -0
  106. package/package.json +256 -4
@@ -0,0 +1,70 @@
1
+ import { LIMITS } from "../constants.js";
2
+ async function sessionOfExec(ctx, exec, service) {
3
+ const workingDirectory = ctx.get("workingDirectory");
4
+ if (workingDirectory === void 0) {
5
+ throw new Error(
6
+ "The working-directory service is not composed; cannot resolve the workspace."
7
+ );
8
+ }
9
+ const cwd = exec.agent ? await workingDirectory.ensure(exec.agent, exec.signal) : workingDirectory.defaultDirectory;
10
+ return service.sessionFor(cwd);
11
+ }
12
+ function diagnosticText(diagnostic) {
13
+ const lines = [
14
+ `${diagnostic.severity}: ${diagnostic.message}`,
15
+ ` at ${formatLocation(diagnostic.location)}`
16
+ ];
17
+ if (diagnostic.excerpt !== void 0)
18
+ lines.push(` | ${diagnostic.excerpt.trim()}`);
19
+ for (const hint of diagnostic.hints) lines.push(` hint: ${hint}`);
20
+ for (const point of diagnostic.trace) {
21
+ lines.push(` from ${formatLocation(point.location)}: ${point.message}`);
22
+ }
23
+ return lines.join("\n");
24
+ }
25
+ function formatLocation(location) {
26
+ return location ? `${location.file}:${location.line}:${location.column}` : "(no location)";
27
+ }
28
+ function diagnosticsText(diagnostics, limit = LIMITS.diagnostics) {
29
+ const shown = diagnostics.slice(0, limit);
30
+ const more = diagnostics.length - shown.length;
31
+ const body = shown.map(diagnosticText).join("\n\n");
32
+ return body + (more > 0 ? `
33
+
34
+ \u2026 and ${more} more.` : "");
35
+ }
36
+ function countOf(diagnostics) {
37
+ const errors = diagnostics.filter(
38
+ (entry) => entry.severity === "error"
39
+ ).length;
40
+ return { errors, warnings: diagnostics.length - errors };
41
+ }
42
+ const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
43
+ function compileSummary(status, main, diagnostics, pages) {
44
+ const { errors, warnings } = countOf(diagnostics);
45
+ const time = status.durationMs !== void 0 ? ` in ${status.durationMs < 10 ? status.durationMs.toFixed(1) : Math.round(status.durationMs)} ms` : "";
46
+ const pagesText = pages !== void 0 ? ` \u2014 ${plural(pages, "page")}` : "";
47
+ switch (status.phase) {
48
+ case "ok":
49
+ return `${main} compiled successfully${time}${pagesText}. No errors or warnings.`;
50
+ case "warnings":
51
+ return `${main} compiled with ${plural(warnings, "warning")}${time}${pagesText}.`;
52
+ case "error":
53
+ return `${main} failed to compile: ${plural(errors, "error")}${warnings ? ` and ${plural(warnings, "warning")}` : ""}.${pages !== void 0 ? ` The preview still shows the last successful version (${plural(pages, "page")}).` : " There is no preview yet."}`;
54
+ case "compiling":
55
+ case "starting":
56
+ return `${main} is compiling\u2026`;
57
+ case "crashed":
58
+ return `typst watch stopped: ${status.error ?? "unknown error"}`;
59
+ case "idle":
60
+ return "Not compiling.";
61
+ }
62
+ }
63
+ export {
64
+ compileSummary,
65
+ countOf,
66
+ diagnosticText,
67
+ diagnosticsText,
68
+ sessionOfExec
69
+ };
70
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/shared.ts"],
4
+ "sourcesContent": ["/**\n * Shared tool plumbing: session resolution from a tool execution, and the\n * diagnostics/status text the tools return (ported from the ZCode\n * typst-workbench server 0.2.0 `src/domain/format.ts` and\n * `src/adapters/server.ts`). Host half only.\n * @module dsh-typst/tools/shared\n */\n\nimport type { Context } from \"@deepseek-ai/cordis\";\nimport type { ToolRunContext } from \"@deepseek-ai/dsh-tools\";\nimport { LIMITS } from \"../constants.js\";\nimport type { DiagnosticView, StatusView } from \"../contract.js\";\nimport type { TypstWorkbenchService } from \"../service.js\";\nimport { WorkspaceSession } from \"../workspace/session.js\";\n\n/**\n * Resolve the executing session's workspace and return its workbench\n * session (creating it on first use).\n * @param ctx - the plugin context (services resolve through it).\n * @param exec - the tool execution context.\n * @param service - the workbench service.\n */\nexport async function sessionOfExec(\n ctx: Context,\n exec: ToolRunContext,\n service: TypstWorkbenchService,\n): Promise<WorkspaceSession> {\n const workingDirectory = ctx.get(\"workingDirectory\");\n if (workingDirectory === undefined) {\n throw new Error(\n \"The working-directory service is not composed; cannot resolve the workspace.\",\n );\n }\n const cwd = exec.agent\n ? await workingDirectory.ensure(exec.agent, exec.signal)\n : workingDirectory.defaultDirectory;\n return service.sessionFor(cwd);\n}\n\n/** Model-facing rendering of one diagnostic: location, excerpt, hints, trace. */\nexport function diagnosticText(diagnostic: DiagnosticView): string {\n const lines: string[] = [\n `${diagnostic.severity}: ${diagnostic.message}`,\n ` at ${formatLocation(diagnostic.location)}`,\n ];\n if (diagnostic.excerpt !== undefined)\n lines.push(` | ${diagnostic.excerpt.trim()}`);\n for (const hint of diagnostic.hints) lines.push(` hint: ${hint}`);\n for (const point of diagnostic.trace) {\n lines.push(` from ${formatLocation(point.location)}: ${point.message}`);\n }\n return lines.join(\"\\n\");\n}\n\nfunction formatLocation(\n location: { file: string; line: number; column: number } | null,\n): string {\n return location\n ? `${location.file}:${location.line}:${location.column}`\n : \"(no location)\";\n}\n\n/** The diagnostics block, capped at LIMITS.diagnostics entries. */\nexport function diagnosticsText(\n diagnostics: DiagnosticView[],\n limit = LIMITS.diagnostics,\n): string {\n const shown = diagnostics.slice(0, limit);\n const more = diagnostics.length - shown.length;\n const body = shown.map(diagnosticText).join(\"\\n\\n\");\n return body + (more > 0 ? `\\n\\n\u2026 and ${more} more.` : \"\");\n}\n\nexport function countOf(diagnostics: DiagnosticView[]): {\n errors: number;\n warnings: number;\n} {\n const errors = diagnostics.filter(\n (entry) => entry.severity === \"error\",\n ).length;\n return { errors, warnings: diagnostics.length - errors };\n}\n\nconst plural = (count: number, word: string): string =>\n `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** One-line compile summary the status/check/set_main answers lead with. */\nexport function compileSummary(\n status: StatusView,\n main: string | null,\n diagnostics: DiagnosticView[],\n pages: number | undefined,\n): string {\n const { errors, warnings } = countOf(diagnostics);\n const time =\n status.durationMs !== undefined\n ? ` in ${status.durationMs < 10 ? status.durationMs.toFixed(1) : Math.round(status.durationMs)} ms`\n : \"\";\n const pagesText = pages !== undefined ? ` \u2014 ${plural(pages, \"page\")}` : \"\";\n switch (status.phase) {\n case \"ok\":\n return `${main} compiled successfully${time}${pagesText}. No errors or warnings.`;\n case \"warnings\":\n return `${main} compiled with ${plural(warnings, \"warning\")}${time}${pagesText}.`;\n case \"error\":\n return `${main} failed to compile: ${plural(errors, \"error\")}${warnings ? ` and ${plural(warnings, \"warning\")}` : \"\"}.${pages !== undefined ? ` The preview still shows the last successful version (${plural(pages, \"page\")}).` : \" There is no preview yet.\"}`;\n case \"compiling\":\n case \"starting\":\n return `${main} is compiling\u2026`;\n case \"crashed\":\n return `typst watch stopped: ${status.error ?? \"unknown error\"}`;\n case \"idle\":\n return \"Not compiling.\";\n }\n}\n"],
5
+ "mappings": "AAUA,SAAS,cAAc;AAYvB,eAAsB,cACpB,KACA,MACA,SAC2B;AAC3B,QAAM,mBAAmB,IAAI,IAAI,kBAAkB;AACnD,MAAI,qBAAqB,QAAW;AAClC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,MAAM,KAAK,QACb,MAAM,iBAAiB,OAAO,KAAK,OAAO,KAAK,MAAM,IACrD,iBAAiB;AACrB,SAAO,QAAQ,WAAW,G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K,MAAM,OAAO,UAAU,CAAC,QAC5F;AACN,QAAM,YAAY,UAAU,SAAY,WAAM,OAAO,OAAO,MAAM,CAAC,KAAK;AACxE,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,aAAO,GAAG,IAAI,yBAAyB,IAAI,GAAG,SAAS;AAAA,IACzD,KAAK;AACH,aAAO,GAAG,IAAI,kBAAkB,OAAO,UAAU,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS;AAAA,IAChF,KAAK;AACH,aAAO,GAAG,IAAI,uBAAuB,OAAO,QAAQ,OAAO,CAAC,GAAG,WAAW,QAAQ,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,IAAI,UAAU,SAAY,yDAAyD,OAAO,OAAO,MAAM,CAAC,OAAO,2BAA2B;AAAA,IAChQ,KAAK;AAAA,IACL,KAAK;AACH,aAAO,GAAG,IAAI;AAAA,IAChB,KAAK;AACH,aAAO,wBAAwB,OAAO,SAAS,eAAe;AAAA,IAChE,KAAK;AACH,aAAO;AAAA,EACX;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The hand-written host Typert manifest for the typst Remote. Registered
3
+ * through `ctx.typert.register` in the service body, not as a generated
4
+ * `./typert` artifact: Typert's generator runs only inside a workspace root
5
+ * that contains both `tsconfig.host.json` and `packages/`, and this
6
+ * repository is a standalone checkout with neither. The registry documents
7
+ * `ctx.typert.register()` as the path for hand-written wire schemas. No
8
+ * `./typert` export is declared on purpose: the production Loader row is the
9
+ * bare package name `dsh-typst`, and registering the same `package#face`
10
+ * twice fails with "already registered". The strict registry is the Host
11
+ * Gateway's preferred resolution path and needs no `@Remote` markers.
12
+ *
13
+ * Invocations come from `status-codec.ts` (host zod factories); the client
14
+ * half mounts its own codecs in `client/status-codec.ts`. Both arms
15
+ * materialize the same strict schemas from the client-safe
16
+ * `wire-schemas.ts`. Structural endpoint identity is shared through
17
+ * `contract.ts`.
18
+ * @module dsh-typst/typert
19
+ */
20
+ import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry/types";
21
+ /** The typst namespace's host manifest (strict codecs owned by this half). */
22
+ export declare const TYPERT_MANIFEST: TypertContribution;
23
+ //# sourceMappingURL=typert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typert.d.ts","sourceRoot":"","sources":["../src/typert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAIjF,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,kBAqE7B,CAAC"}
package/lib/typert.js ADDED
@@ -0,0 +1,67 @@
1
+ import { TYPST_STATUS_SERVICE_KEY } from "./constants.js";
2
+ import { TYPST_INVOCATIONS_HOST } from "./status-codec.js";
3
+ const TYPERT_MANIFEST = {
4
+ package: "typst",
5
+ face: "host",
6
+ schemas: [],
7
+ model: {
8
+ services: [
9
+ {
10
+ key: TYPST_STATUS_SERVICE_KEY,
11
+ exportName: "TypstRuntime",
12
+ description: "Serves the Typst workbench to the panel: state frames, the live watch stream, the preview bytes, file discovery, and source matching.",
13
+ tags: [],
14
+ members: [
15
+ {
16
+ kind: "method",
17
+ name: "status",
18
+ signature: "status(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>"
19
+ },
20
+ {
21
+ kind: "method",
22
+ name: "setMain",
23
+ signature: "setMain(typstScope: TypstScope, path: string, signal: AbortSignal): Promise<{ main: string }>"
24
+ },
25
+ {
26
+ kind: "method",
27
+ name: "watch",
28
+ signature: "@Remote({ mode: 'stream' }) watch(typstScope: TypstScope, signal: AbortSignal): AsyncIterable<TypstStateFrame>"
29
+ },
30
+ {
31
+ kind: "method",
32
+ name: "readPreview",
33
+ signature: "readPreview(typstScope: TypstScope, identity: PreviewIdentity, signal: AbortSignal): Promise<PreviewBytes>"
34
+ },
35
+ {
36
+ kind: "method",
37
+ name: "locateSource",
38
+ signature: "locateSource(typstScope: TypstScope, text: string, focus: string | null, signal: AbortSignal): Promise<{ matches: SourceMatch[] }>"
39
+ },
40
+ {
41
+ kind: "method",
42
+ name: "recheck",
43
+ signature: "recheck(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>"
44
+ },
45
+ {
46
+ kind: "method",
47
+ name: "restart",
48
+ signature: "restart(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>"
49
+ },
50
+ {
51
+ kind: "method",
52
+ name: "discover",
53
+ signature: "discover(typstScope: TypstScope, includeExcluded: boolean, signal: AbortSignal): Promise<object>"
54
+ }
55
+ ],
56
+ types: []
57
+ }
58
+ ],
59
+ events: [],
60
+ objects: []
61
+ },
62
+ invocations: TYPST_INVOCATIONS_HOST
63
+ };
64
+ export {
65
+ TYPERT_MANIFEST
66
+ };
67
+ //# sourceMappingURL=typert.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/typert.ts"],
4
+ "sourcesContent": ["/**\n * The hand-written host Typert manifest for the typst Remote. Registered\n * through `ctx.typert.register` in the service body, not as a generated\n * `./typert` artifact: Typert's generator runs only inside a workspace root\n * that contains both `tsconfig.host.json` and `packages/`, and this\n * repository is a standalone checkout with neither. The registry documents\n * `ctx.typert.register()` as the path for hand-written wire schemas. No\n * `./typert` export is declared on purpose: the production Loader row is the\n * bare package name `dsh-typst`, and registering the same `package#face`\n * twice fails with \"already registered\". The strict registry is the Host\n * Gateway's preferred resolution path and needs no `@Remote` markers.\n *\n * Invocations come from `status-codec.ts` (host zod factories); the client\n * half mounts its own codecs in `client/status-codec.ts`. Both arms\n * materialize the same strict schemas from the client-safe\n * `wire-schemas.ts`. Structural endpoint identity is shared through\n * `contract.ts`.\n * @module dsh-typst/typert\n */\n\nimport type { TypertContribution } from \"@deepseek-ai/dsh-typert-registry/types\";\nimport { TYPST_STATUS_SERVICE_KEY } from \"./constants.js\";\nimport { TYPST_INVOCATIONS_HOST } from \"./status-codec.js\";\n\n/** The typst namespace's host manifest (strict codecs owned by this half). */\nexport const TYPERT_MANIFEST: TypertContribution = {\n package: \"typst\",\n face: \"host\",\n schemas: [],\n model: {\n services: [\n {\n key: TYPST_STATUS_SERVICE_KEY,\n exportName: \"TypstRuntime\",\n description:\n \"Serves the Typst workbench to the panel: state frames, the live watch stream, the preview bytes, file discovery, and source matching.\",\n tags: [],\n members: [\n {\n kind: \"method\",\n name: \"status\",\n signature:\n \"status(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>\",\n },\n {\n kind: \"method\",\n name: \"setMain\",\n signature:\n \"setMain(typstScope: TypstScope, path: string, signal: AbortSignal): Promise<{ main: string }>\",\n },\n {\n kind: \"method\",\n name: \"watch\",\n signature:\n \"@Remote({ mode: 'stream' }) watch(typstScope: TypstScope, signal: AbortSignal): AsyncIterable<TypstStateFrame>\",\n },\n {\n kind: \"method\",\n name: \"readPreview\",\n signature:\n \"readPreview(typstScope: TypstScope, identity: PreviewIdentity, signal: AbortSignal): Promise<PreviewBytes>\",\n },\n {\n kind: \"method\",\n name: \"locateSource\",\n signature:\n \"locateSource(typstScope: TypstScope, text: string, focus: string | null, signal: AbortSignal): Promise<{ matches: SourceMatch[] }>\",\n },\n {\n kind: \"method\",\n name: \"recheck\",\n signature:\n \"recheck(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>\",\n },\n {\n kind: \"method\",\n name: \"restart\",\n signature:\n \"restart(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>\",\n },\n {\n kind: \"method\",\n name: \"discover\",\n signature:\n \"discover(typstScope: TypstScope, includeExcluded: boolean, signal: AbortSignal): Promise<object>\",\n },\n ],\n types: [],\n },\n ],\n events: [],\n objects: [],\n },\n invocations: TYPST_INVOCATIONS_HOST,\n};\n"],
5
+ "mappings": "AAqBA,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAGhC,MAAM,kBAAsC;AAAA,EACjD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS,CAAC;AAAA,EACV,OAAO;AAAA,IACL,UAAU;AAAA,MACR;AAAA,QACE,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,aACE;AAAA,QACF,MAAM,CAAC;AAAA,QACP,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,WACE;AAAA,UACJ;AAAA,QACF;AAAA,QACA,OAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,aAAa;AACf;",
6
+ "names": []
7
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Typst output parsing: one-shot diagnostics, the `typst watch` log stream,
3
+ * and make-deps files. Ported from the ZCode typst-workbench server
4
+ * (0.2.0) `src/typst/diagnostics.ts` and adjusted to this repository's
5
+ * domain error type. Host half only.
6
+ * @module dsh-typst/typst/diagnostics
7
+ */
8
+ import type { DiagnosticView } from "../contract.js";
9
+ /**
10
+ * Parse the diagnostics block of one compile round (stderr of a one-shot
11
+ * compile, or the lines a `typst watch` round accumulated).
12
+ * @param text - raw output text.
13
+ * @param toFile - maps a path as typst printed it onto a display path.
14
+ * @returns the parsed diagnostics in order of appearance.
15
+ */
16
+ export declare function parseDiagnostics(text: string, toFile?: (path: string) => string): DiagnosticView[];
17
+ /** One event the watch log emits; the watcher serializes their handling. */
18
+ export type WatchEvent = {
19
+ kind: "compiling";
20
+ } | {
21
+ kind: "finished";
22
+ outcome: "ok" | "warnings" | "error";
23
+ durationMs?: number;
24
+ diagnostics: DiagnosticView[];
25
+ } | {
26
+ kind: "fatal";
27
+ message: string;
28
+ };
29
+ /**
30
+ * Incremental parser for `typst watch` stdout/stderr. Typst prints an
31
+ * ANSI-stamped `compiling` line per round, then `compiled …` plus any
32
+ * diagnostics. Rounds are finalized on the next marker or when the caller
33
+ * decides the output went quiet (`finalize`); a round with errors keeps
34
+ * accumulating help/hint lines until then.
35
+ */
36
+ export declare class WatchLog {
37
+ private readonly emit;
38
+ private readonly toFile;
39
+ private buffer;
40
+ private pending;
41
+ constructor(emit: (event: WatchEvent) => void, toFile?: (path: string) => string);
42
+ /**
43
+ * Feed one output chunk.
44
+ * @returns whether a round is awaiting `finalize`.
45
+ */
46
+ feed(chunk: string): boolean;
47
+ private line;
48
+ /** End the current round (next round started, or output went quiet). */
49
+ finalize(): void;
50
+ }
51
+ /**
52
+ * Parse a deps file: typst ≥0.14 JSON (`{ inputs: [...] }`) or the classic
53
+ * make-deps grammar of `--make-deps`.
54
+ * @param text - the deps file content.
55
+ * @returns dependency paths in the order printed.
56
+ */
57
+ export declare function parseDeps(text: string): string[];
58
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/typst/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,gBAAgB,CAAC;AASxB;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuB,GAChD,cAAc,EAAE,CAgDlB;AAkBD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC;;;;;;GAMG;AACH,qBAAa,QAAQ;IASjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,OAAO,CAIC;gBAGG,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACjC,MAAM,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuB;IAGpE;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAW5B,OAAO,CAAC,IAAI;IAoCZ,wEAAwE;IACxE,QAAQ,IAAI,IAAI;CAWjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA2ChD"}
@@ -0,0 +1,171 @@
1
+ const ANSI = /\u001b\[[0-9;?]*[A-Za-z]/g;
2
+ const HEADER = /^(error|warning|help)(?:\[[^\]]*\])?: (.*)$/;
3
+ const LOCATION = /^\s*[┌╭]─+\s*(.+):(\d+):(\d+)\s*$/;
4
+ const NOTE = /^\s*= (?:(hint|note|help): )?(.*)$/;
5
+ const stripAnsi = (text) => text.replace(ANSI, "");
6
+ function parseDiagnostics(text, toFile = (path) => path) {
7
+ const diagnostics = [];
8
+ let target = null;
9
+ let current = null;
10
+ for (const raw of stripAnsi(text).split(/\r?\n/)) {
11
+ const line = raw.trimEnd();
12
+ const header = HEADER.exec(line);
13
+ if (header) {
14
+ const [, kind, message] = header;
15
+ if (kind === "help") {
16
+ if (current) {
17
+ const point = { message, location: null };
18
+ current.trace.push(point);
19
+ target = point;
20
+ } else {
21
+ target = null;
22
+ }
23
+ } else {
24
+ current = {
25
+ severity: kind,
26
+ message,
27
+ location: null,
28
+ hints: [],
29
+ trace: []
30
+ };
31
+ diagnostics.push(current);
32
+ target = current;
33
+ }
34
+ continue;
35
+ }
36
+ const location = LOCATION.exec(line);
37
+ if (location && target && !target.location) {
38
+ target.location = {
39
+ file: toFile(location[1]),
40
+ line: Number(location[2]),
41
+ column: Number(location[3])
42
+ };
43
+ continue;
44
+ }
45
+ const note = NOTE.exec(line);
46
+ if (note && current && /^\s*=/.test(line))
47
+ current.hints.push(note[2].trim());
48
+ }
49
+ return diagnostics;
50
+ }
51
+ const STAMP = String.raw`^(?:\[[^\]]*\]\s*)?`;
52
+ const COMPILING = new RegExp(`${STAMP}compiling\\b`);
53
+ const FINISHED = new RegExp(
54
+ `${STAMP}compiled (successfully|with warnings|with errors)(?: in ([\\d.]+)\\s*(\xB5s|us|ms|s))?`
55
+ );
56
+ function duration(value, unit) {
57
+ if (!value) return void 0;
58
+ const number = Number(value);
59
+ if (!Number.isFinite(number)) return void 0;
60
+ return unit === "s" ? number * 1e3 : unit === "ms" ? number : number / 1e3;
61
+ }
62
+ class WatchLog {
63
+ constructor(emit, toFile = (path) => path) {
64
+ this.emit = emit;
65
+ this.toFile = toFile;
66
+ }
67
+ emit;
68
+ toFile;
69
+ buffer = "";
70
+ pending = null;
71
+ /**
72
+ * Feed one output chunk.
73
+ * @returns whether a round is awaiting `finalize`.
74
+ */
75
+ feed(chunk) {
76
+ this.buffer += chunk;
77
+ let newline;
78
+ while ((newline = this.buffer.indexOf("\n")) >= 0) {
79
+ const line = stripAnsi(this.buffer.slice(0, newline)).replace(/\r$/, "");
80
+ this.buffer = this.buffer.slice(newline + 1);
81
+ this.line(line);
82
+ }
83
+ return this.pending !== null;
84
+ }
85
+ line(line) {
86
+ const trimmed = line.trim();
87
+ if (COMPILING.test(trimmed)) {
88
+ this.finalize();
89
+ this.emit({ kind: "compiling" });
90
+ return;
91
+ }
92
+ const finished = FINISHED.exec(trimmed);
93
+ if (finished) {
94
+ this.finalize();
95
+ const outcome = finished[1] === "successfully" ? "ok" : finished[1] === "with warnings" ? "warnings" : "error";
96
+ this.pending = {
97
+ outcome,
98
+ durationMs: duration(finished[2], finished[3]),
99
+ lines: []
100
+ };
101
+ if (outcome === "ok") this.finalize();
102
+ return;
103
+ }
104
+ if (/^watching\s/.test(trimmed) || /^writing to\s/.test(trimmed)) {
105
+ this.finalize();
106
+ return;
107
+ }
108
+ if (this.pending) {
109
+ this.pending.lines.push(line);
110
+ return;
111
+ }
112
+ if (trimmed.startsWith("error: "))
113
+ this.emit({ kind: "fatal", message: trimmed.slice(7) });
114
+ }
115
+ /** End the current round (next round started, or output went quiet). */
116
+ finalize() {
117
+ const pending = this.pending;
118
+ if (!pending) return;
119
+ this.pending = null;
120
+ this.emit({
121
+ kind: "finished",
122
+ outcome: pending.outcome,
123
+ durationMs: pending.durationMs,
124
+ diagnostics: parseDiagnostics(pending.lines.join("\n"), this.toFile)
125
+ });
126
+ }
127
+ }
128
+ function parseDeps(text) {
129
+ const trimmed = text.trim();
130
+ if (!trimmed) return [];
131
+ if (trimmed.startsWith("{")) {
132
+ try {
133
+ const value = JSON.parse(trimmed);
134
+ if (typeof value === "object" && value !== null && "inputs" in value) {
135
+ const inputs = value.inputs;
136
+ return Array.isArray(inputs) ? inputs.filter((entry) => typeof entry === "string") : [];
137
+ }
138
+ return [];
139
+ } catch {
140
+ return [];
141
+ }
142
+ }
143
+ const body = trimmed.replace(/\\\r?\n/g, " ");
144
+ const colon = body.search(/(?<!\\):(?=\s|$)/);
145
+ if (colon < 0) return [];
146
+ const deps = [];
147
+ let currentDep = "";
148
+ const rest = body.slice(colon + 1);
149
+ for (let index = 0; index < rest.length; index++) {
150
+ const char = rest[index];
151
+ if (char === "\\" && index + 1 < rest.length && /[\s#\\:]/.test(rest[index + 1])) {
152
+ currentDep += rest[++index];
153
+ } else if (char === "$" && rest[index + 1] === "$") {
154
+ currentDep += "$";
155
+ index++;
156
+ } else if (/\s/.test(char)) {
157
+ if (currentDep) deps.push(currentDep);
158
+ currentDep = "";
159
+ } else {
160
+ currentDep += char;
161
+ }
162
+ }
163
+ if (currentDep) deps.push(currentDep);
164
+ return deps;
165
+ }
166
+ export {
167
+ WatchLog,
168
+ parseDeps,
169
+ parseDiagnostics
170
+ };
171
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/typst/diagnostics.ts"],
4
+ "sourcesContent": ["/**\n * Typst output parsing: one-shot diagnostics, the `typst watch` log stream,\n * and make-deps files. Ported from the ZCode typst-workbench server\n * (0.2.0) `src/typst/diagnostics.ts` and adjusted to this repository's\n * domain error type. Host half only.\n * @module dsh-typst/typst/diagnostics\n */\n\nimport type {\n DiagnosticLocationView,\n DiagnosticPointView,\n DiagnosticView,\n} from \"../contract.js\";\n\nconst ANSI = /\\u001b\\[[0-9;?]*[A-Za-z]/g;\nconst HEADER = /^(error|warning|help)(?:\\[[^\\]]*\\])?: (.*)$/;\nconst LOCATION = /^\\s*[\u250C\u256D]\u2500+\\s*(.+):(\\d+):(\\d+)\\s*$/;\nconst NOTE = /^\\s*= (?:(hint|note|help): )?(.*)$/;\n\nconst stripAnsi = (text: string): string => text.replace(ANSI, \"\");\n\n/**\n * Parse the diagnostics block of one compile round (stderr of a one-shot\n * compile, or the lines a `typst watch` round accumulated).\n * @param text - raw output text.\n * @param toFile - maps a path as typst printed it onto a display path.\n * @returns the parsed diagnostics in order of appearance.\n */\nexport function parseDiagnostics(\n text: string,\n toFile: (path: string) => string = (path) => path,\n): DiagnosticView[] {\n const diagnostics: DiagnosticView[] = [];\n let target:\n { location: DiagnosticLocationView | null } | DiagnosticPointView | null =\n null;\n let current: DiagnosticView | null = null;\n for (const raw of stripAnsi(text).split(/\\r?\\n/)) {\n const line = raw.trimEnd();\n const header = HEADER.exec(line);\n if (header) {\n const [, kind, message] = header;\n if (kind === \"help\") {\n if (current) {\n const point: DiagnosticPointView = { message, location: null };\n current.trace.push(point);\n target = point;\n } else {\n target = null;\n }\n } else {\n // The header grammar only admits error|warning|help, and help took\n // the trace branch above, so the remaining kinds are exact.\n current = {\n severity: kind as DiagnosticView[\"severity\"],\n message,\n location: null,\n hints: [],\n trace: [],\n };\n diagnostics.push(current);\n target = current;\n }\n continue;\n }\n const location = LOCATION.exec(line);\n if (location && target && !target.location) {\n target.location = {\n file: toFile(location[1]),\n line: Number(location[2]),\n column: Number(location[3]),\n };\n continue;\n }\n const note = NOTE.exec(line);\n if (note && current && /^\\s*=/.test(line))\n current.hints.push(note[2].trim());\n }\n return diagnostics;\n}\n\nconst STAMP = String.raw`^(?:\\[[^\\]]*\\]\\s*)?`;\nconst COMPILING = new RegExp(`${STAMP}compiling\\\\b`);\nconst FINISHED = new RegExp(\n `${STAMP}compiled (successfully|with warnings|with errors)(?: in ([\\\\d.]+)\\\\s*(\\u00b5s|us|ms|s))?`,\n);\n\nfunction duration(\n value: string | undefined,\n unit: string | undefined,\n): number | undefined {\n if (!value) return undefined;\n const number = Number(value);\n if (!Number.isFinite(number)) return undefined;\n return unit === \"s\" ? number * 1e3 : unit === \"ms\" ? number : number / 1e3;\n}\n\n/** One event the watch log emits; the watcher serializes their handling. */\nexport type WatchEvent =\n | { kind: \"compiling\" }\n | {\n kind: \"finished\";\n outcome: \"ok\" | \"warnings\" | \"error\";\n durationMs?: number;\n diagnostics: DiagnosticView[];\n }\n | { kind: \"fatal\"; message: string };\n\n/**\n * Incremental parser for `typst watch` stdout/stderr. Typst prints an\n * ANSI-stamped `compiling` line per round, then `compiled \u2026` plus any\n * diagnostics. Rounds are finalized on the next marker or when the caller\n * decides the output went quiet (`finalize`); a round with errors keeps\n * accumulating help/hint lines until then.\n */\nexport class WatchLog {\n private buffer = \"\";\n private pending: {\n outcome: \"ok\" | \"warnings\" | \"error\";\n durationMs?: number;\n lines: string[];\n } | null = null;\n\n constructor(\n private readonly emit: (event: WatchEvent) => void,\n private readonly toFile: (path: string) => string = (path) => path,\n ) {}\n\n /**\n * Feed one output chunk.\n * @returns whether a round is awaiting `finalize`.\n */\n feed(chunk: string): boolean {\n this.buffer += chunk;\n let newline: number;\n while ((newline = this.buffer.indexOf(\"\\n\")) >= 0) {\n const line = stripAnsi(this.buffer.slice(0, newline)).replace(/\\r$/, \"\");\n this.buffer = this.buffer.slice(newline + 1);\n this.line(line);\n }\n return this.pending !== null;\n }\n\n private line(line: string): void {\n const trimmed = line.trim();\n if (COMPILING.test(trimmed)) {\n this.finalize();\n this.emit({ kind: \"compiling\" });\n return;\n }\n const finished = FINISHED.exec(trimmed);\n if (finished) {\n this.finalize();\n const outcome =\n finished[1] === \"successfully\"\n ? \"ok\"\n : finished[1] === \"with warnings\"\n ? \"warnings\"\n : \"error\";\n this.pending = {\n outcome,\n durationMs: duration(finished[2], finished[3]),\n lines: [],\n };\n if (outcome === \"ok\") this.finalize();\n return;\n }\n if (/^watching\\s/.test(trimmed) || /^writing to\\s/.test(trimmed)) {\n this.finalize();\n return;\n }\n if (this.pending) {\n this.pending.lines.push(line);\n return;\n }\n if (trimmed.startsWith(\"error: \"))\n this.emit({ kind: \"fatal\", message: trimmed.slice(7) });\n }\n\n /** End the current round (next round started, or output went quiet). */\n finalize(): void {\n const pending = this.pending;\n if (!pending) return;\n this.pending = null;\n this.emit({\n kind: \"finished\",\n outcome: pending.outcome,\n durationMs: pending.durationMs,\n diagnostics: parseDiagnostics(pending.lines.join(\"\\n\"), this.toFile),\n });\n }\n}\n\n/**\n * Parse a deps file: typst \u22650.14 JSON (`{ inputs: [...] }`) or the classic\n * make-deps grammar of `--make-deps`.\n * @param text - the deps file content.\n * @returns dependency paths in the order printed.\n */\nexport function parseDeps(text: string): string[] {\n const trimmed = text.trim();\n if (!trimmed) return [];\n if (trimmed.startsWith(\"{\")) {\n try {\n const value: unknown = JSON.parse(trimmed);\n if (typeof value === \"object\" && value !== null && \"inputs\" in value) {\n const inputs = (value as { inputs: unknown }).inputs;\n return Array.isArray(inputs)\n ? inputs.filter((entry): entry is string => typeof entry === \"string\")\n : [];\n }\n return [];\n } catch {\n return [];\n }\n }\n const body = trimmed.replace(/\\\\\\r?\\n/g, \" \");\n const colon = body.search(/(?<!\\\\):(?=\\s|$)/);\n if (colon < 0) return [];\n const deps: string[] = [];\n let currentDep = \"\";\n const rest = body.slice(colon + 1);\n for (let index = 0; index < rest.length; index++) {\n const char = rest[index];\n if (\n char === \"\\\\\" &&\n index + 1 < rest.length &&\n /[\\s#\\\\:]/.test(rest[index + 1])\n ) {\n currentDep += rest[++index];\n } else if (char === \"$\" && rest[index + 1] === \"$\") {\n currentDep += \"$\";\n index++;\n } else if (/\\s/.test(char)) {\n if (currentDep) deps.push(currentDep);\n currentDep = \"\";\n } else {\n currentDep += char;\n }\n }\n if (currentDep) deps.push(currentDep);\n return deps;\n}\n"],
5
+ "mappings": "AAcA,MAAM,OAAO;AACb,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,OAAO;AAEb,MAAM,YAAY,CAAC,SAAyB,KAAK,QAAQ,MAAM,EAAE;AAS1D,SAAS,iBACd,MACA,SAAmC,CAAC,SAAS,MAC3B;AAClB,QAAM,cAAgC,CAAC;AACvC,MAAI,SAEF;AACF,MAAI,UAAiC;AACrC,aAAW,OAAO,UAAU,IAAI,EAAE,MAAM,OAAO,GAAG;AAChD,UAAM,OAAO,IAAI,QAAQ;AACzB,UAAM,SAAS,OAAO,KAAK,IAAI;AAC/B,QAAI,QAAQ;AACV,YAAM,CAAC,EAAE,MAAM,OAAO,IAAI;AAC1B,UAAI,SAAS,QAAQ;AACnB,YAAI,SAAS;AACX,gBAAM,QAA6B,EAAE,SAAS,UAAU,KAAK;AAC7D,kBAAQ,MAAM,KAAK,KAAK;AACx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 -0,0 +1,68 @@
1
+ /**
2
+ * Locating and version-checking the typst binary: the configured path, then
3
+ * PATH, then common install locations, then the login shell (version
4
+ * managers). Ported from the ZCode typst-workbench server (0.2.0)
5
+ * `src/typst/locate.ts`. Host half only.
6
+ * @module dsh-typst/typst/locate
7
+ */
8
+ import type { TypstSource } from "../contract.js";
9
+ /** Parse `typst 0.13.1`-style version output. */
10
+ export declare function parseVersion(text: string): [number, number, number] | null;
11
+ export declare function compareVersion(a: readonly number[], b: readonly number[]): number;
12
+ export declare const versionText: (version: readonly number[]) => string;
13
+ export declare function atLeast(version: string, required: readonly number[]): boolean;
14
+ /** Common typst install directories per platform. */
15
+ export declare function commonDirs(platform: string, env: NodeJS.ProcessEnv, home: string): string[];
16
+ /**
17
+ * The directories the lookup covers, in report order (for the setup page's
18
+ * "where we looked" list), `~`-abbreviated.
19
+ */
20
+ export declare function searchedDirs(platform: string, env: NodeJS.ProcessEnv, home: string, arch?: string): string[];
21
+ export interface RunResult {
22
+ code: number | null;
23
+ stdout: string;
24
+ stderr: string;
25
+ timedOut: boolean;
26
+ }
27
+ /** Run a short-lived command to completion, capturing both streams. */
28
+ export declare function run(command: string, args: string[], options?: {
29
+ cwd?: string;
30
+ env?: NodeJS.ProcessEnv;
31
+ timeoutMs?: number;
32
+ }): Promise<RunResult>;
33
+ export type Toolchain = {
34
+ state: "ready";
35
+ path: string;
36
+ source: TypstSource;
37
+ version: string;
38
+ } | {
39
+ state: "missing";
40
+ } | {
41
+ state: "too_old";
42
+ path: string;
43
+ source: TypstSource;
44
+ version: string;
45
+ error: string;
46
+ } | {
47
+ state: "error";
48
+ path?: string;
49
+ source?: TypstSource;
50
+ error: string;
51
+ };
52
+ export interface LocateOptions {
53
+ /** The configured "Typst path" setting; wins when executable. */
54
+ setting?: string;
55
+ env?: NodeJS.ProcessEnv;
56
+ platform?: string;
57
+ home?: string;
58
+ /** Directory list overriding the common defaults (tests). */
59
+ common?: string[];
60
+ /** Skip the login-shell probe (the panel's periodic recheck does). */
61
+ shell?: boolean;
62
+ }
63
+ /**
64
+ * Locate a usable typst and check its version.
65
+ * @returns the toolchain state; `ready` carries path/source/version.
66
+ */
67
+ export declare function locateTypst(options?: LocateOptions): Promise<Toolchain>;
68
+ //# sourceMappingURL=locate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate.d.ts","sourceRoot":"","sources":["../../src/typst/locate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAK1E;AAED,wBAAgB,cAAc,CAC5B,CAAC,EAAE,SAAS,MAAM,EAAE,EACpB,CAAC,EAAE,SAAS,MAAM,EAAE,GACnB,MAAM,CAKR;AAED,eAAO,MAAM,WAAW,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MACtC,CAAC;AAEpB,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAG7E;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,CAuBV;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAqB,GAC1B,MAAM,EAAE,CAeV;AAgBD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,u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