qtex 1.1.17 ā 1.1.18
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/index.js +9 -5
- package/package.json +1 -1
- package/src/compiler.js +4 -3
- package/src/ws-client.js +11 -2
package/index.js
CHANGED
|
@@ -16,10 +16,10 @@ const args = process.argv.slice(2);
|
|
|
16
16
|
const optionsSchema = {
|
|
17
17
|
watch: { type: 'boolean', short: 'w' },
|
|
18
18
|
output: { type: 'string', short: 'o' },
|
|
19
|
+
server: { type: 'string', short: 's' },
|
|
19
20
|
help: { type: 'boolean', short: 'h' },
|
|
20
21
|
update: { type: 'boolean', short: 'u' },
|
|
21
|
-
version: { type: 'boolean', short: 'v' }
|
|
22
|
-
server: { type: 'string', short: 's' }
|
|
22
|
+
version: { type: 'boolean', short: 'v' }
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
async function main() {
|
|
@@ -42,7 +42,7 @@ ${colors.bold}USAGE:${colors.reset}
|
|
|
42
42
|
${colors.bold}OPTIONS:${colors.reset}
|
|
43
43
|
-w, --watch Watch for changes and recompile
|
|
44
44
|
-o, --output <file> Define output filename (default: output.pdf)
|
|
45
|
-
-s, --server <url>
|
|
45
|
+
-s, --server <url> Specify Tachyon-Tex server URL
|
|
46
46
|
-u, --update Update to the latest version
|
|
47
47
|
-v, --version Show version information
|
|
48
48
|
-h, --help Show this help message
|
|
@@ -58,12 +58,16 @@ ${colors.bold}OPTIONS:${colors.reset}
|
|
|
58
58
|
const directory = positionals[0] || '.';
|
|
59
59
|
console.log(`${colors.magenta}${colors.bold}\nš qtex CLI v${packageJson.version} (Vanilla)${colors.reset}\n`);
|
|
60
60
|
|
|
61
|
+
if (values.server) {
|
|
62
|
+
ui.info(`Using compilation server: ${colors.bold}${values.server}${colors.reset}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
// Check for updates in the background
|
|
62
66
|
autoUpdate(packageJson.version);
|
|
63
67
|
|
|
64
68
|
if (values.watch) {
|
|
65
69
|
const { TachyonWS } = await import('./src/ws-client.js');
|
|
66
|
-
const wsClient = new TachyonWS(directory,
|
|
70
|
+
const wsClient = new TachyonWS(directory, values);
|
|
67
71
|
await wsClient.connect();
|
|
68
72
|
|
|
69
73
|
const server = startServer();
|
|
@@ -97,7 +101,7 @@ ${colors.bold}OPTIONS:${colors.reset}
|
|
|
97
101
|
|
|
98
102
|
// Auto-open generated PDF in the system browser
|
|
99
103
|
const outputFileName = values.output || 'output.pdf';
|
|
100
|
-
const outputPath = resolve(process.cwd(), outputFileName);
|
|
104
|
+
const outputPath = resolve(process.cwd(), directory, outputFileName);
|
|
101
105
|
const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start ""' : 'xdg-open';
|
|
102
106
|
exec(`${openCmd} "${outputPath}"`);
|
|
103
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qtex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Ultra-fast cloud LaTeX compiler. Compile .tex documents in milliseconds without installing TeXLive or MikTeX. Zero config, sub-second builds, live watch mode.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/compiler.js
CHANGED
|
@@ -27,6 +27,7 @@ async function getFiles(dir, baseDir = dir) {
|
|
|
27
27
|
|
|
28
28
|
export async function compile(dir, options) {
|
|
29
29
|
const outputFileName = options.output || 'output.pdf';
|
|
30
|
+
const serverUrl = options.server || API_BASE;
|
|
30
31
|
const spinner = new Spinner(`${colors.blue}Preparing compilation...`).start();
|
|
31
32
|
|
|
32
33
|
try {
|
|
@@ -75,7 +76,7 @@ export async function compile(dir, options) {
|
|
|
75
76
|
// Phase 1: Validation
|
|
76
77
|
spinner.update(`${colors.cyan}Validating LaTeX...`);
|
|
77
78
|
try {
|
|
78
|
-
const validateRes = await fetch(`${
|
|
79
|
+
const validateRes = await fetch(`${serverUrl}/validate`, {
|
|
79
80
|
method: 'POST',
|
|
80
81
|
body: validateForm
|
|
81
82
|
});
|
|
@@ -103,7 +104,7 @@ export async function compile(dir, options) {
|
|
|
103
104
|
// Phase 2: Compilation
|
|
104
105
|
spinner.update(`${colors.cyan}Compiling via Tachyon-Tex API...`);
|
|
105
106
|
|
|
106
|
-
const response = await fetch(`${
|
|
107
|
+
const response = await fetch(`${serverUrl}/compile`, {
|
|
107
108
|
method: 'POST',
|
|
108
109
|
body: form
|
|
109
110
|
});
|
|
@@ -113,7 +114,7 @@ export async function compile(dir, options) {
|
|
|
113
114
|
const compileTime = response.headers.get('x-compile-time-ms') || 'unknown';
|
|
114
115
|
const filesReceived = response.headers.get('x-files-received') || sentFilesCount;
|
|
115
116
|
|
|
116
|
-
const outputPath = resolve(process.cwd(), outputFileName);
|
|
117
|
+
const outputPath = resolve(process.cwd(), dir, outputFileName);
|
|
117
118
|
await writeFile(outputPath, Buffer.from(buffer));
|
|
118
119
|
|
|
119
120
|
if (options.watch) {
|
package/src/ws-client.js
CHANGED
|
@@ -20,7 +20,16 @@ export class TachyonWS {
|
|
|
20
20
|
async connect() {
|
|
21
21
|
return new Promise((res, rej) => {
|
|
22
22
|
ui.info(`${colors.cyan}Connecting to Tachyon-Tex Live Engine...${colors.reset}`);
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
let serverUrl = this.options.server || WS_URL;
|
|
25
|
+
if (serverUrl.startsWith('http')) {
|
|
26
|
+
serverUrl = serverUrl.replace(/^http/, 'ws');
|
|
27
|
+
if (!serverUrl.endsWith('/ws')) {
|
|
28
|
+
serverUrl = serverUrl.replace(/\/$/, '') + '/ws';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.socket = new WebSocket(serverUrl);
|
|
24
33
|
|
|
25
34
|
this.socket.onopen = () => {
|
|
26
35
|
this.isConnected = true;
|
|
@@ -44,7 +53,7 @@ export class TachyonWS {
|
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
const outputFileName = this.options.output || 'output.pdf';
|
|
47
|
-
const outputPath = resolve(process.cwd(), outputFileName);
|
|
56
|
+
const outputPath = resolve(process.cwd(), this.directory, outputFileName);
|
|
48
57
|
|
|
49
58
|
// Decode base64 PDF
|
|
50
59
|
const buffer = Buffer.from(data.pdf, 'base64');
|