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
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin's single subprocess entry point. Every typst invocation and the
|
|
3
|
+
* login-shell lookup go through the harness `ctx.subprocess` seam, which
|
|
4
|
+
* supplies the scrubbed environment, managed process range, abort propagation
|
|
5
|
+
* and host-exit teardown.
|
|
6
|
+
*
|
|
7
|
+
* Two shapes are exposed: {@link ProcessRunner.run} collects a short command's
|
|
8
|
+
* output for toolchain probes and one-shot compiles; {@link ProcessRunner.spawnPiped}
|
|
9
|
+
* streams a long-running child (the watch) with incremental UTF-8 decoding.
|
|
10
|
+
* @module dsh-typst/typst/process
|
|
11
|
+
*/
|
|
12
|
+
import { StringDecoder } from "node:string_decoder";
|
|
13
|
+
import { deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
14
|
+
import { LIMITS } from "../constants.js";
|
|
15
|
+
import { TYPST_TIMEOUT } from "../errors.js";
|
|
16
|
+
/**
|
|
17
|
+
* Wrap the host subprocess capability. One instance is owned by the workbench
|
|
18
|
+
* service and shared by every workspace session.
|
|
19
|
+
*/
|
|
20
|
+
export class ProcessRunner {
|
|
21
|
+
runtime;
|
|
22
|
+
constructor(runtime) {
|
|
23
|
+
this.runtime = runtime;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Spawn a long-running child with raw pipes. Both streams are decoded with
|
|
27
|
+
* a streaming decoder, so a multi-byte character split across chunks is
|
|
28
|
+
* never replaced with U+FFFD.
|
|
29
|
+
* @param argv - executable and arguments; never shell-interpreted.
|
|
30
|
+
* @param options - cwd, explicit env, cancellation and grace.
|
|
31
|
+
* @returns the live handle plus text-output helpers.
|
|
32
|
+
*/
|
|
33
|
+
spawnPiped(argv, options) {
|
|
34
|
+
const handle = this.runtime.spawn({
|
|
35
|
+
argv,
|
|
36
|
+
cwd: options.cwd,
|
|
37
|
+
stdio: { stdin: "ignore", stdout: "pipe", stderr: "pipe" },
|
|
38
|
+
graceMs: options.graceMs ?? LIMITS.stopGraceMs,
|
|
39
|
+
...(options.env === undefined ? {} : { env: options.env }),
|
|
40
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
handle,
|
|
44
|
+
done: handle.done,
|
|
45
|
+
onOutput: (listener) => {
|
|
46
|
+
const stdout = new StringDecoder("utf8");
|
|
47
|
+
const stderr = new StringDecoder("utf8");
|
|
48
|
+
const flush = () => {
|
|
49
|
+
for (const decoder of [stdout, stderr]) {
|
|
50
|
+
const tail = decoder.end();
|
|
51
|
+
if (tail.length > 0)
|
|
52
|
+
listener(tail);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
handle.stdout?.on("data", (chunk) => {
|
|
56
|
+
const text = stdout.write(chunk);
|
|
57
|
+
if (text.length > 0)
|
|
58
|
+
listener(text);
|
|
59
|
+
});
|
|
60
|
+
handle.stderr?.on("data", (chunk) => {
|
|
61
|
+
const text = stderr.write(chunk);
|
|
62
|
+
if (text.length > 0)
|
|
63
|
+
listener(text);
|
|
64
|
+
});
|
|
65
|
+
// Flush before the owner's own `done` continuation runs: listeners are
|
|
66
|
+
// registered in call order, and the owner registers after this call.
|
|
67
|
+
void handle.done.then(flush, flush);
|
|
68
|
+
},
|
|
69
|
+
terminate: () => handle.terminate(),
|
|
70
|
+
waitForExit: (signal) => handle.waitForExit(signal),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Run a short command to completion with bounded collected output.
|
|
75
|
+
* A nonzero exit resolves; only a spawn/provider failure or the deadline
|
|
76
|
+
* produces the failure shape.
|
|
77
|
+
* @param argv - executable and arguments.
|
|
78
|
+
* @param options - cwd, explicit env, cancellation, deadline and output cap.
|
|
79
|
+
* @returns exit facts plus decoded stdout/stderr.
|
|
80
|
+
*/
|
|
81
|
+
async run(argv, options) {
|
|
82
|
+
const timeoutMs = options.timeoutMs ?? LIMITS.oneshotTimeoutMs;
|
|
83
|
+
const fuse = deadline(options.signal, timeoutMs, TYPST_TIMEOUT);
|
|
84
|
+
const collect = {
|
|
85
|
+
maxBytes: options.collectBytes ?? LIMITS.processOutputBytes,
|
|
86
|
+
};
|
|
87
|
+
try {
|
|
88
|
+
let handle;
|
|
89
|
+
try {
|
|
90
|
+
handle = this.runtime.spawn({
|
|
91
|
+
argv,
|
|
92
|
+
cwd: options.cwd,
|
|
93
|
+
stdio: { stdin: "ignore", stdout: collect, stderr: collect },
|
|
94
|
+
graceMs: options.graceMs ?? LIMITS.stopGraceMs,
|
|
95
|
+
signal: fuse.signal,
|
|
96
|
+
...(options.env === undefined ? {} : { env: options.env }),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
code: null,
|
|
102
|
+
signal: null,
|
|
103
|
+
stdout: "",
|
|
104
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
105
|
+
timedOut: timeoutOf(fuse.signal, TYPST_TIMEOUT) !== undefined,
|
|
106
|
+
aborted: options.signal?.aborted === true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
let outcome = null;
|
|
110
|
+
let providerFailure = null;
|
|
111
|
+
try {
|
|
112
|
+
outcome = await handle.done;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
providerFailure =
|
|
116
|
+
error instanceof Error ? error.message : String(error);
|
|
117
|
+
}
|
|
118
|
+
const stdout = handle.collected.stdout?.readFrom(0).text ?? "";
|
|
119
|
+
const stderr = handle.collected.stderr?.readFrom(0).text ?? "";
|
|
120
|
+
const timedOut = timeoutOf(fuse.signal, TYPST_TIMEOUT) !== undefined;
|
|
121
|
+
if (providerFailure !== null) {
|
|
122
|
+
return {
|
|
123
|
+
code: null,
|
|
124
|
+
signal: null,
|
|
125
|
+
stdout,
|
|
126
|
+
stderr: stderr.length > 0
|
|
127
|
+
? `${stderr}\n${providerFailure}`
|
|
128
|
+
: providerFailure,
|
|
129
|
+
timedOut,
|
|
130
|
+
aborted: options.signal?.aborted === true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
code: outcome === null ? null : outcome.exitCode,
|
|
135
|
+
signal: outcome === null ? null : outcome.signal,
|
|
136
|
+
stdout,
|
|
137
|
+
stderr,
|
|
138
|
+
timedOut,
|
|
139
|
+
aborted: options.signal?.aborted === true,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
fuse[Symbol.dispose]();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/typst/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC/D,O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|
|
18
|
-
label: string;
|
|
19
|
-
width: number;
|
|
20
|
-
height: number;
|
|
21
|
-
originX: number;
|
|
22
|
-
originY: number;
|
|
23
18
|
}
|
|
24
19
|
export interface TextSpan {
|
|
25
20
|
start: number;
|
|
@@ -45,9 +40,11 @@ interface PageHit {
|
|
|
45
40
|
}
|
|
46
41
|
/**
|
|
47
42
|
* Find a quote in the extracted pages: exact (folded) match first, then
|
|
48
|
-
* across adjacent pages, preferring the preferred page when given.
|
|
43
|
+
* across adjacent pages, preferring the preferred page when given. `from`
|
|
44
|
+
* is a UTF-16 offset hint on the preferred page and `occurrence` names the
|
|
45
|
+
* match ordinal (from that offset) to keep when the text repeats.
|
|
49
46
|
*/
|
|
50
|
-
export declare function findQuote(pages: PageText[], quote: string, preferredPage?: number): PageHit | null;
|
|
47
|
+
export declare function findQuote(pages: PageText[], quote: string, preferredPage?: number, from?: number, occurrence?: number): PageHit | null;
|
|
51
48
|
/**
|
|
52
49
|
* PDF user-space rectangles covering `page.text[start, end)`, merged across
|
|
53
50
|
* adjacent spans on the same line. The panel maps them through the page
|
package/lib/typst/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/typst/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/typst/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qEAAqE;AACrE,MAAM,WAAW,WAA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