dsh-typst-plugin 0.1.0-alpha.0 → 0.1.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/README.en.md +86 -52
- package/README.md +93 -59
- package/cordis.patch.yml +1 -1
- package/docs/images/icon.png +0 -0
- package/lib/client.js +2088 -1136
- package/lib/client.js.map +4 -4
- package/lib/config.d.ts +66 -9
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +161 -25
- package/lib/config.js.map +1 -7
- package/lib/constants.d.ts +21 -2
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +83 -60
- package/lib/constants.js.map +1 -7
- package/lib/contract.d.ts +90 -6
- package/lib/contract.d.ts.map +1 -1
- package/lib/contract.js +9 -1
- package/lib/contract.js.map +1 -7
- package/lib/diagnostic-text.d.ts +13 -0
- package/lib/diagnostic-text.d.ts.map +1 -0
- package/lib/diagnostic-text.js +28 -0
- package/lib/diagnostic-text.js.map +1 -0
- package/lib/errors.d.ts +57 -15
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +154 -79
- package/lib/errors.js.map +1 -7
- package/lib/host/facts.d.ts.map +1 -1
- package/lib/host/facts.js +133 -139
- package/lib/host/facts.js.map +1 -7
- package/lib/host/which.d.ts +20 -0
- package/lib/host/which.d.ts.map +1 -0
- package/lib/host/which.js +50 -0
- package/lib/host/which.js.map +1 -0
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -7
- package/lib/remote.d.ts +5 -4
- package/lib/remote.d.ts.map +1 -1
- package/lib/remote.js +153 -143
- package/lib/remote.js.map +1 -7
- package/lib/service.d.ts +28 -4
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +202 -99
- package/lib/service.js.map +1 -7
- package/lib/skills/typst.js +74 -68
- package/lib/skills/typst.js.map +1 -7
- package/lib/status-codec.js +10 -5
- package/lib/status-codec.js.map +1 -7
- package/lib/tools/registration.d.ts +4 -3
- package/lib/tools/registration.d.ts.map +1 -1
- package/lib/tools/registration.js +726 -493
- package/lib/tools/registration.js.map +1 -7
- package/lib/tools/shared.d.ts +4 -5
- package/lib/tools/shared.d.ts.map +1 -1
- package/lib/tools/shared.js +73 -64
- package/lib/tools/shared.js.map +1 -7
- package/lib/typert.d.ts +5 -3
- package/lib/typert.d.ts.map +1 -1
- package/lib/typert.js +113 -64
- package/lib/typert.js.map +1 -7
- package/lib/typst/diagnostics.d.ts.map +1 -1
- package/lib/typst/diagnostics.js +218 -152
- package/lib/typst/diagnostics.js.map +1 -7
- package/lib/typst/flags.d.ts +8 -0
- package/lib/typst/flags.d.ts.map +1 -0
- package/lib/typst/flags.js +8 -0
- package/lib/typst/flags.js.map +1 -0
- package/lib/typst/locate.d.ts +6 -13
- package/lib/typst/locate.d.ts.map +1 -1
- package/lib/typst/locate.js +138 -180
- package/lib/typst/locate.js.map +1 -7
- package/lib/typst/mainfile.d.ts +23 -4
- package/lib/typst/mainfile.d.ts.map +1 -1
- package/lib/typst/mainfile.js +131 -59
- package/lib/typst/mainfile.js.map +1 -7
- package/lib/typst/match.d.ts +9 -1
- package/lib/typst/match.d.ts.map +1 -1
- package/lib/typst/match.js +213 -157
- package/lib/typst/match.js.map +1 -7
- package/lib/typst/oneshot.d.ts +8 -5
- package/lib/typst/oneshot.d.ts.map +1 -1
- package/lib/typst/oneshot.js +76 -66
- package/lib/typst/oneshot.js.map +1 -7
- package/lib/typst/owners.d.ts +28 -0
- package/lib/typst/owners.d.ts.map +1 -0
- package/lib/typst/owners.js +98 -0
- package/lib/typst/owners.js.map +1 -0
- package/lib/typst/pdf-extract.d.ts +1 -2
- package/lib/typst/pdf-extract.d.ts.map +1 -1
- package/lib/typst/pdf-extract.js +98 -74
- package/lib/typst/pdf-extract.js.map +1 -7
- package/lib/typst/process.d.ts +73 -0
- package/lib/typst/process.d.ts.map +1 -0
- package/lib/typst/process.js +147 -0
- package/lib/typst/process.js.map +1 -0
- package/lib/typst/text.d.ts +4 -7
- package/lib/typst/text.d.ts.map +1 -1
- package/lib/typst/text.js +258 -290
- package/lib/typst/text.js.map +1 -7
- package/lib/typst/watcher.d.ts +16 -17
- package/lib/typst/watcher.d.ts.map +1 -1
- package/lib/typst/watcher.js +199 -208
- package/lib/typst/watcher.js.map +1 -7
- package/lib/wire-schemas.d.ts +8 -153
- package/lib/wire-schemas.d.ts.map +1 -1
- package/lib/wire-schemas.js +405 -361
- package/lib/wire-schemas.js.map +1 -7
- package/lib/workspace/containment.d.ts +25 -0
- package/lib/workspace/containment.d.ts.map +1 -0
- package/lib/workspace/containment.js +54 -0
- package/lib/workspace/containment.js.map +1 -0
- package/lib/workspace/session.d.ts +73 -14
- package/lib/workspace/session.d.ts.map +1 -1
- package/lib/workspace/session.js +1516 -1172
- package/lib/workspace/session.js.map +1 -7
- package/locale/en.json +8 -2
- package/locale/zh.json +8 -2
- package/package.json +36 -179
- package/release-provenance.json +137 -0
- package/lib/typst/pdfjs-worker.d.js +0 -1
- package/lib/typst/pdfjs-worker.d.js.map +0 -7
package/lib/host/facts.js
CHANGED
|
@@ -1,151 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Host facts for the setup page: OS name, architecture, and the package
|
|
3
|
+
* managers that could install Typst. Probed once per session (and refreshed
|
|
4
|
+
* when the setup page re-checks with the shell). Ported from the ZCode
|
|
5
|
+
* typst-workbench server (0.2.0) `src/host/facts.ts`. Host half only.
|
|
6
|
+
* @module dsh-typst/host/facts
|
|
7
|
+
*/
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
3
9
|
import { homedir, release } from "node:os";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
} catch {
|
|
15
|
-
resolve(null);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async function isExecutable(path, platform) {
|
|
20
|
-
try {
|
|
21
|
-
if (!(await stat(path)).isFile()) return false;
|
|
22
|
-
await access(path, platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
23
|
-
return true;
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function findExecutable(bin, dirs, options = {}) {
|
|
29
|
-
const env = options.env ?? process.env;
|
|
30
|
-
const platform = options.platform ?? process.platform;
|
|
31
|
-
const names = platform === "win32" ? [`${bin}.exe`, `${bin}.cmd`, bin] : [bin];
|
|
32
|
-
const path = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean);
|
|
33
|
-
for (const dir of [...path, ...dirs]) {
|
|
34
|
-
for (const name of names) {
|
|
35
|
-
const candidate = join(dir, name);
|
|
36
|
-
if (await isExecutable(candidate, platform)) return candidate;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
10
|
+
import { join, sep } from "node:path";
|
|
11
|
+
import { deadline } from "@deepseek-ai/dsh-timeout";
|
|
12
|
+
import { runNativeCommand } from "@deepseek-ai/dsh-native-command";
|
|
13
|
+
import { findExecutable } from "./which.js";
|
|
14
|
+
function output(command, args) {
|
|
15
|
+
const fuse = deadline(undefined, 5_000, "TYPST_HOST_PROBE_TIMEOUT");
|
|
16
|
+
return runNativeCommand(command, args, fuse.signal, "hidden")
|
|
17
|
+
.then(({ stdout }) => stdout)
|
|
18
|
+
.catch(() => null)
|
|
19
|
+
.finally(() => fuse[Symbol.dispose]());
|
|
40
20
|
}
|
|
41
21
|
function tilde(path, home) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
if (!home)
|
|
23
|
+
return path;
|
|
24
|
+
if (path === home)
|
|
25
|
+
return "~";
|
|
26
|
+
return path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path;
|
|
45
27
|
}
|
|
46
|
-
async function osName(platform
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
28
|
+
async function osName(platform) {
|
|
29
|
+
if (platform === "darwin") {
|
|
30
|
+
const version = (await output("/usr/bin/sw_vers", ["-productVersion"]))?.trim();
|
|
31
|
+
return version ? `macOS ${version}` : "macOS";
|
|
32
|
+
}
|
|
33
|
+
if (platform === "win32") {
|
|
34
|
+
const [major, , build] = release().split(".").map(Number);
|
|
35
|
+
return major === 10
|
|
36
|
+
? build >= 22_000
|
|
37
|
+
? "Windows 11"
|
|
38
|
+
: "Windows 10"
|
|
39
|
+
: `Windows ${release()}`;
|
|
40
|
+
}
|
|
41
|
+
if (platform === "linux") {
|
|
42
|
+
const text = await readFile("/etc/os-release", "utf8").catch(() => "");
|
|
43
|
+
const pretty = /^PRETTY_NAME="?([^"\n]+)"?/m.exec(text)?.[1];
|
|
44
|
+
return pretty ?? "Linux";
|
|
45
|
+
}
|
|
46
|
+
return platform;
|
|
61
47
|
}
|
|
62
|
-
async function archName(platform, arch
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
async function archName(platform, arch) {
|
|
49
|
+
if (platform === "darwin") {
|
|
50
|
+
if (arch === "arm64")
|
|
51
|
+
return "Apple silicon";
|
|
52
|
+
const arm = (await output("/usr/sbin/sysctl", ["-n", "hw.optional.arm64"]))?.trim();
|
|
53
|
+
return arm === "1" ? "Apple silicon" : "Intel";
|
|
54
|
+
}
|
|
55
|
+
return arch;
|
|
69
56
|
}
|
|
70
57
|
function packageManagers(platform, env, home) {
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
if (platform === "win32") {
|
|
59
|
+
const local = env.LOCALAPPDATA ?? join(home, "AppData", "Local");
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
name: "winget",
|
|
63
|
+
bin: "winget",
|
|
64
|
+
dirs: [join(local, "Microsoft", "WindowsApps")],
|
|
65
|
+
},
|
|
66
|
+
{ name: "Scoop", bin: "scoop", dirs: [join(home, "scoop", "shims")] },
|
|
67
|
+
{
|
|
68
|
+
name: "Chocolatey",
|
|
69
|
+
bin: "choco",
|
|
70
|
+
dirs: [join(env.ProgramData ?? "C:\\ProgramData", "chocolatey", "bin")],
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
const brew = {
|
|
75
|
+
name: "Homebrew",
|
|
76
|
+
bin: "brew",
|
|
77
|
+
dirs: [
|
|
78
|
+
"/opt/homebrew/bin",
|
|
79
|
+
"/usr/local/bin",
|
|
80
|
+
"/home/linuxbrew/.linuxbrew/bin",
|
|
81
|
+
join(home, ".linuxbrew", "bin"),
|
|
82
|
+
],
|
|
83
|
+
version: { args: ["--version"], pattern: /Homebrew\s+(\d+\.\d+\.\d+)/ },
|
|
84
|
+
};
|
|
85
|
+
if (platform !== "linux")
|
|
86
|
+
return [brew];
|
|
73
87
|
return [
|
|
74
|
-
|
|
75
|
-
name: "
|
|
76
|
-
bin: "
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
name: "Chocolatey",
|
|
82
|
-
bin: "choco",
|
|
83
|
-
dirs: [join(env.ProgramData ?? "C:\\ProgramData", "chocolatey", "bin")]
|
|
84
|
-
}
|
|
88
|
+
brew,
|
|
89
|
+
{ name: "apt", bin: "apt-get", dirs: ["/usr/bin"] },
|
|
90
|
+
{ name: "dnf", bin: "dnf", dirs: ["/usr/bin"] },
|
|
91
|
+
{ name: "pacman", bin: "pacman", dirs: ["/usr/bin"] },
|
|
92
|
+
{ name: "zypper", bin: "zypper", dirs: ["/usr/bin"] },
|
|
93
|
+
{ name: "snap", bin: "snap", dirs: ["/usr/bin", "/snap/bin"] },
|
|
94
|
+
{ name: "Flatpak", bin: "flatpak", dirs: ["/usr/bin"] },
|
|
85
95
|
];
|
|
86
|
-
}
|
|
87
|
-
const brew = {
|
|
88
|
-
name: "Homebrew",
|
|
89
|
-
bin: "brew",
|
|
90
|
-
dirs: [
|
|
91
|
-
"/opt/homebrew/bin",
|
|
92
|
-
"/usr/local/bin",
|
|
93
|
-
"/home/linuxbrew/.linuxbrew/bin",
|
|
94
|
-
join(home, ".linuxbrew", "bin")
|
|
95
|
-
],
|
|
96
|
-
version: { args: ["--version"], pattern: /Homebrew\s+(\d+\.\d+\.\d+)/ }
|
|
97
|
-
};
|
|
98
|
-
if (platform !== "linux") return [brew];
|
|
99
|
-
return [
|
|
100
|
-
brew,
|
|
101
|
-
{ name: "apt", bin: "apt-get", dirs: ["/usr/bin"] },
|
|
102
|
-
{ name: "dnf", bin: "dnf", dirs: ["/usr/bin"] },
|
|
103
|
-
{ name: "pacman", bin: "pacman", dirs: ["/usr/bin"] },
|
|
104
|
-
{ name: "zypper", bin: "zypper", dirs: ["/usr/bin"] },
|
|
105
|
-
{ name: "snap", bin: "snap", dirs: ["/usr/bin", "/snap/bin"] },
|
|
106
|
-
{ name: "Flatpak", bin: "flatpak", dirs: ["/usr/bin"] }
|
|
107
|
-
];
|
|
108
96
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
/** Extra specs to probe alongside the platform defaults (cargo, for typst). */
|
|
98
|
+
export function cargoSpec(env) {
|
|
99
|
+
const home = env.HOME ?? env.USERPROFILE ?? "";
|
|
100
|
+
return { name: "cargo", bin: "cargo", dirs: [join(home, ".cargo", "bin")] };
|
|
112
101
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Detect the host facts the setup page shows: OS, architecture, and every
|
|
104
|
+
* package manager that could install Typst.
|
|
105
|
+
*/
|
|
106
|
+
export async function detectFacts(extra = [], options = {}) {
|
|
107
|
+
const env = options.env ?? process.env;
|
|
108
|
+
const platform = options.platform ?? process.platform;
|
|
109
|
+
const home = options.home ?? env.HOME ?? env.USERPROFILE ?? homedir();
|
|
110
|
+
const specs = [...packageManagers(platform, env, home), ...extra];
|
|
111
|
+
const [name, arch, tools] = await Promise.all([
|
|
112
|
+
osName(platform),
|
|
113
|
+
archName(platform, options.arch ?? process.arch),
|
|
114
|
+
Promise.all(specs.map(async (spec) => {
|
|
115
|
+
const path = await findExecutable(spec.bin, spec.dirs, {
|
|
116
|
+
env,
|
|
117
|
+
platform,
|
|
118
|
+
});
|
|
119
|
+
if (!path)
|
|
120
|
+
return null;
|
|
121
|
+
const probe = spec.version;
|
|
122
|
+
const text = probe ? await output(path, probe.args) : null;
|
|
123
|
+
const version = text ? probe?.pattern.exec(text)?.[1] : undefined;
|
|
124
|
+
return {
|
|
125
|
+
name: spec.name,
|
|
126
|
+
...(version ? { version } : {}),
|
|
127
|
+
path: tilde(path, home),
|
|
128
|
+
};
|
|
129
|
+
})),
|
|
130
|
+
]);
|
|
131
|
+
const os = platform === "darwin"
|
|
132
|
+
? "macos"
|
|
133
|
+
: platform === "win32"
|
|
134
|
+
? "windows"
|
|
135
|
+
: platform === "linux"
|
|
136
|
+
? "linux"
|
|
137
|
+
: "other";
|
|
138
|
+
return {
|
|
139
|
+
os,
|
|
140
|
+
osName: name,
|
|
141
|
+
arch,
|
|
142
|
+
tools: tools.filter((tool) => tool !== null),
|
|
143
|
+
};
|
|
146
144
|
}
|
|
147
|
-
|
|
148
|
-
cargoSpec,
|
|
149
|
-
detectFacts
|
|
150
|
-
};
|
|
151
|
-
//# sourceMappingURL=facts.js.map
|
|
145
|
+
//# sourceMappingURL=facts.js.map
|
package/lib/host/facts.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/host/facts.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Host facts for the setup page: OS name, architecture, and the package\n * managers that could install Typst. Probed once per session (and refreshed\n * when the setup page re-checks with the shell). Ported from the ZCode\n * typst-workbench server (0.2.0) `src/host/facts.ts`. Host half only.\n * @module dsh-typst/host/facts\n */\n\nimport { execFile } from \"node:child_process\";\nimport { access, constants, readFile, stat } from \"node:fs/promises\";\nimport { homedir, release } from \"node:os\";\nimport { delimiter, join, sep } from \"node:path\";\nimport type { HostFactsView, PackageManagerView } from \"../contract.js\";\n\nfunction output(\n command: string,\n args: string[],\n env: NodeJS.ProcessEnv,\n timeout = 5_000,\n): Promise<string | null> {\n return new Promise((resolve) => {\n try {\n execFile(\n command,\n args,\n { env, timeout, windowsHide: true },\n (error, stdout) => resolve(error ? null : String(stdout)),\n );\n } catch {\n resolve(null);\n }\n });\n}\n\nasync function isExecutable(path: string, platform: string): Promise<boolean> {\n try {\n if (!(await stat(path)).isFile()) return false;\n await access(path, platform === \"win32\" ? constants.F_OK : constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function findExecutable(\n bin: string,\n dirs: string[],\n options: { env?: NodeJS.ProcessEnv; platform?: string } = {},\n): Promise<string | null> {\n const env = options.env ?? process.env;\n const platform = options.platform ?? process.platform;\n const names =\n platform === \"win32\" ? [`${bin}.exe`, `${bin}.cmd`, bin] : [bin];\n const path = (env.PATH ?? env.Path ?? \"\").split(delimiter).filter(Boolean);\n for (const dir of [...path, ...dirs]) {\n for (const name of names) {\n const candidate = join(dir, name);\n if (await isExecutable(candidate, platform)) return candidate;\n }\n }\n return null;\n}\n\nfunction tilde(path: string, home: string): string {\n if (!home) return path;\n if (path === home) return \"~\";\n return path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path;\n}\n\nasync function osName(\n platform: string,\n env: NodeJS.ProcessEnv,\n): Promise<string> {\n if (platform === \"darwin\") {\n const version = (\n await output(\"/usr/bin/sw_vers\", [\"-productVersion\"], env)\n )?.trim();\n return version ? `macOS ${version}` : \"macOS\";\n }\n if (platform === \"win32\") {\n const [major, , build] = release().split(\".\").map(Number);\n return major === 10\n ? build >= 22_000\n ? \"Windows 11\"\n : \"Windows 10\"\n : `Windows ${release()}`;\n }\n if (platform === \"linux\") {\n const text = await readFile(\"/etc/os-release\", \"utf8\").catch(() => \"\");\n const pretty = /^PRETTY_NAME=\"?([^\"\\n]+)\"?/m.exec(text)?.[1];\n return pretty ?? \"Linux\";\n }\n return platform;\n}\n\nasync function archName(\n platform: string,\n arch: string,\n env: NodeJS.ProcessEnv,\n): Promise<string> {\n if (platform === \"darwin\") {\n if (arch === \"arm64\") return \"Apple silicon\";\n const arm = (\n await output(\"/usr/sbin/sysctl\", [\"-n\", \"hw.optional.arm64\"], env)\n )?.trim();\n return arm === \"1\" ? \"Apple silicon\" : \"Intel\";\n }\n return arch;\n}\n\ninterface PmSpec {\n name: string;\n bin: string;\n dirs: string[];\n version?: { args: string[]; pattern: RegExp };\n}\n\nfunction packageManagers(\n platform: string,\n env: NodeJS.ProcessEnv,\n home: string,\n): PmSpec[] {\n if (platform === \"win32\") {\n const local = env.LOCALAPPDATA ?? join(home, \"AppData\", \"Local\");\n return [\n {\n name: \"winget\",\n bin: \"winget\",\n dirs: [join(local, \"Microsoft\", \"WindowsApps\")],\n },\n { name: \"Scoop\", bin: \"scoop\", dirs: [join(home, \"scoop\", \"shims\")] },\n {\n name: \"Chocolatey\",\n bin: \"choco\",\n dirs: [join(env.ProgramData ?? \"C:\\\\ProgramData\", \"chocolatey\", \"bin\")],\n },\n ];\n }\n const brew: PmSpec = {\n name: \"Homebrew\",\n bin: \"brew\",\n dirs: [\n \"/opt/homebrew/bin\",\n \"/usr/local/bin\",\n \"/home/linuxbrew/.linuxbrew/bin\",\n join(home, \".linuxbrew\", \"bin\"),\n ],\n version: { args: [\"--version\"], pattern: /Homebrew\\s+(\\d+\\.\\d+\\.\\d+)/ },\n };\n if (platform !== \"linux\") return [brew];\n return [\n brew,\n { name: \"apt\", bin: \"apt-get\", dirs: [\"/usr/bin\"] },\n { name: \"dnf\", bin: \"dnf\", dirs: [\"/usr/bin\"] },\n { name: \"pacman\", bin: \"pacman\", dirs: [\"/usr/bin\"] },\n { name: \"zypper\", bin: \"zypper\", dirs: [\"/usr/bin\"] },\n { name: \"snap\", bin: \"snap\", dirs: [\"/usr/bin\", \"/snap/bin\"] },\n { name: \"Flatpak\", bin: \"flatpak\", dirs: [\"/usr/bin\"] },\n ];\n}\n\n/** Extra specs to probe alongside the platform defaults (cargo, for typst). */\nexport function cargoSpec(env: NodeJS.ProcessEnv): PmSpec {\n const home = env.HOME ?? env.USERPROFILE ?? \"\";\n return { name: \"cargo\", bin: \"cargo\", dirs: [join(home, \".cargo\", \"bin\")] };\n}\n\n/**\n * Detect the host facts the setup page shows: OS, architecture, and every\n * package manager that could install Typst.\n */\nexport async function detectFacts(\n extra: PmSpec[] = [],\n options: {\n env?: NodeJS.ProcessEnv;\n platform?: string;\n home?: string;\n arch?: string;\n } = {},\n): Promise<HostFactsView> {\n const env = options.env ?? process.env;\n const platform = options.platform ?? process.platform;\n const home = options.home ?? env.HOME ?? env.USERPROFILE ?? homedir();\n const specs: PmSpec[] = [...packageManagers(platform, env, home), ...extra];\n const [name, arch, tools] = await Promise.all([\n osName(platform, env),\n archName(platform, options.arch ?? process.arch, env),\n Promise.all(\n specs.map(async (spec): Promise<PackageManagerView | null> => {\n const path = await findExecutable(spec.bin, spec.dirs, {\n env,\n platform,\n });\n if (!path) return null;\n const probe = spec.version;\n const text = probe ? await output(path, probe.args, env) : null;\n const version = text ? probe?.pattern.exec(text)?.[1] : undefined;\n return {\n name: spec.name,\n ...(version ? { version } : {}),\n path: tilde(path, home),\n };\n }),\n ),\n ]);\n const os =\n platform === \"darwin\"\n ? \"macos\"\n : platform === \"win32\"\n ? \"windows\"\n : platform === \"linux\"\n ? \"linux\"\n : \"other\";\n return {\n os,\n osName: name,\n arch,\n tools: tools.filter((tool) => tool !== null),\n };\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,gBAAgB;AACzB,SAAS,QAAQ,WAAW,UAAU,YAAY;AAClD,SAAS,SAAS,eAAe;AACjC,SAAS,WAAW,MAAM,WAAW;AAGrC,SAAS,OACP,SACA,MACA,KACA,UAAU,KACc;AACxB,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI;AACF;AAAA,QACE;AAAA,QACA;AAAA,QACA,EAAE,KAAK,SAAS,aAAa,KAAK;AAAA,QAClC,CAAC,OAAO,WAAW,QAAQ,QAAQ,OAAO,OAAO,MAAM,CAAC;AAAA,MAC1D;AAAA,IACF,QAAQ;AACN,cAAQ,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACH;AAEA,eAAe,aAAa,MAAc,UAAoC;AAC5E,MAAI;AACF,QAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,EAAG,QAAO;AACzC,UAAM,OAAO,MAAM,aAAa,UAAU,UAAU,OAAO,UAAU,IAAI;AACzE,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAe,eACb,KACA,MACA,UAA0D,CAAC,GACnC;AACxB,QAAM,MAAM,QAAQ,OAAO,QAAQ;AACnC,QAAM,WAAW,QAAQ,YAAY,QAAQ;AAC7C,QAAM,QACJ,aAAa,UAAU,CAAC,GAAG,GAAG,QAAQ,GAAG,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG;AACjE,QAAM,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,MAAM,SAAS,EAAE,OAAO,OAAO;AACzE,aAAW,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACpC,eAAW,QAAQ,OAA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;gBACpB,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,OAAO,CAAC;IAClB,OAAO;QACL,EAAE;QACF,MAAM,EAAE,IAAI;QACZ,IAAI;QACJ,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a path is an executable regular file on this host.
|
|
3
|
+
* @param path - candidate path.
|
|
4
|
+
* @param platform - platform spelling, defaulting to the running host.
|
|
5
|
+
* @returns true when the file exists and is executable (or F_OK on Windows).
|
|
6
|
+
*/
|
|
7
|
+
export declare function isExecutable(path: string, platform?: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Find one executable by name, searching PATH before explicit directories.
|
|
10
|
+
* @param bin - base name without a platform suffix.
|
|
11
|
+
* @param dirs - extra directories after PATH.
|
|
12
|
+
* @param options - environment, platform and optional name override.
|
|
13
|
+
* @returns the first executable path, or null.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findExecutable(bin: string, dirs: readonly string[], options?: {
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
platform?: string;
|
|
18
|
+
names?: readonly string[];
|
|
19
|
+
}): Promise<string | null>;
|
|
20
|
+
//# sourceMappingURL=which.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.d.ts","sourceRoot":"","sources":["../../src/host/which.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtB,GACL,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host executable lookup shared by toolchain detection and host facts.
|
|
3
|
+
* One PATH + common-directory search keeps the two discovery paths from
|
|
4
|
+
* disagreeing about the same binary.
|
|
5
|
+
* @module dsh-typst/host/which
|
|
6
|
+
*/
|
|
7
|
+
import { access, constants, stat } from "node:fs/promises";
|
|
8
|
+
import { delimiter, join } from "node:path";
|
|
9
|
+
/**
|
|
10
|
+
* Whether a path is an executable regular file on this host.
|
|
11
|
+
* @param path - candidate path.
|
|
12
|
+
* @param platform - platform spelling, defaulting to the running host.
|
|
13
|
+
* @returns true when the file exists and is executable (or F_OK on Windows).
|
|
14
|
+
*/
|
|
15
|
+
export async function isExecutable(path, platform = process.platform) {
|
|
16
|
+
try {
|
|
17
|
+
if (!(await stat(path)).isFile())
|
|
18
|
+
return false;
|
|
19
|
+
await access(path, platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Find one executable by name, searching PATH before explicit directories.
|
|
28
|
+
* @param bin - base name without a platform suffix.
|
|
29
|
+
* @param dirs - extra directories after PATH.
|
|
30
|
+
* @param options - environment, platform and optional name override.
|
|
31
|
+
* @returns the first executable path, or null.
|
|
32
|
+
*/
|
|
33
|
+
export async function findExecutable(bin, dirs, options = {}) {
|
|
34
|
+
const env = options.env ?? process.env;
|
|
35
|
+
const platform = options.platform ?? process.platform;
|
|
36
|
+
const names = options.names ??
|
|
37
|
+
(platform === "win32" ? [`${bin}.exe`, `${bin}.cmd`, bin] : [bin]);
|
|
38
|
+
const path = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean);
|
|
39
|
+
for (const dir of [...path, ...dirs]) {
|
|
40
|
+
if (!dir)
|
|
41
|
+
continue;
|
|
42
|
+
for (const name of names) {
|
|
43
|
+
const candidate = join(dir, name);
|
|
44
|
+
if (await isExecutable(candidate, platform))
|
|
45
|
+
return candidate;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=which.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.js","sourceRoot":"","sources":["../../src/host/which.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,WAAmB,OAAO,CAAC,QAAQ;IAEnC,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;YAAE,OAAO,KAAK,CAAC;QAC/C,MAAM,MAAM,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,IAAuB,EACvB,UAII,EAAE;IAEN,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IACtD,MAAM,KAAK,GACT,OAAO,CAAC,KAAK;QACb,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3E,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClC,IAAI,MAAM,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC;gBAAE,OAAO,SAAS,CAAC;QAChE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { TypstWorkbenchService as default } from \"./service.js\";\n"],
|
|
5
|
-
"mappings": "AAAA,SAAkC,6BAAe;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/lib/remote.d.ts
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* The host Typert Remote runtime for the `typst` namespace: state frames,
|
|
3
3
|
* the live watch stream, preview bytes, file discovery, and source
|
|
4
4
|
* matching, all scoped to the calling Session's workspace through the
|
|
5
|
-
* `typstScope` lookup
|
|
6
|
-
* `@deepseek-ai/dsh-api-workspace-files`
|
|
5
|
+
* `typstScope` lookup, adapted from the `workspaceFileScope` lookup shape in
|
|
6
|
+
* `@deepseek-ai/dsh-api-workspace-files` (that package is a reference, not a
|
|
7
|
+
* dependency of this plugin). Host half only.
|
|
7
8
|
* @module dsh-typst/remote
|
|
8
9
|
*/
|
|
9
10
|
import type { Context } from "@deepseek-ai/cordis";
|
|
10
11
|
import type { SessionId } from "@deepseek-ai/dsh-session/types";
|
|
11
12
|
import { TypertRemoteService, type TypertLookup } from "@deepseek-ai/dsh-typert-protocol";
|
|
12
|
-
import type { PreviewIdentity, PreviewBytes, TypstStateFrame } from "./contract.js";
|
|
13
|
+
import type { DiscoveryView, PreviewIdentity, PreviewBytes, TypstStateFrame } from "./contract.js";
|
|
13
14
|
import type { SourceMatch } from "./typst/match.js";
|
|
14
15
|
/**
|
|
15
16
|
* The session identity every endpoint is scoped by: received on the wire as
|
|
@@ -64,6 +65,6 @@ export declare class TypstRuntime extends TypertRemoteService {
|
|
|
64
65
|
/** Stop the watch, relocate typst, rescan, restart; answers with the new frame. */
|
|
65
66
|
restart(typstScope: TypstScope, signal: AbortSignal): Promise<TypstStateFrame>;
|
|
66
67
|
/** Refresh the cancellable workspace index, optionally including excluded directories. */
|
|
67
|
-
discover(typstScope: TypstScope, includeExcluded: boolean, signal: AbortSignal): Promise<
|
|
68
|
+
discover(typstScope: TypstScope, includeExcluded: boolean, signal: AbortSignal): Promise<DiscoveryView>;
|
|
68
69
|
}
|
|
69
70
|
//# sourceMappingURL=remote.d.ts.map
|
package/lib/remote.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA
|
|
1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