@azerothjs/language-server 0.4.0-beta.1 → 0.4.0-beta.3
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.md +47 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsc-cli.d.ts +3 -0
- package/dist/tsc-cli.d.ts.map +1 -0
- package/dist/tsc-cli.js +17 -0
- package/dist/tsc-cli.js.map +1 -0
- package/dist/tsc.d.ts +56 -0
- package/dist/tsc.d.ts.map +1 -0
- package/dist/tsc.js +185 -0
- package/dist/tsc.js.map +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -35,7 +35,53 @@ back any other host without this package.
|
|
|
35
35
|
| --- | --- |
|
|
36
36
|
| `server.ts` | LSP wiring: connection, capabilities, document sync, settings, and one handler per request. |
|
|
37
37
|
| `cli.ts` | Executable entry point (`azeroth-language-server`); starts the server over stdio. |
|
|
38
|
-
| `
|
|
38
|
+
| `tsc.ts` | `runTsc`: the batch type-checker behind the `azeroth-tsc` binary. |
|
|
39
|
+
| `tsc-cli.ts` | Executable entry point (`azeroth-tsc`); runs one check and sets the exit code. |
|
|
40
|
+
| `index.ts` | Library entry point; exports `startServer` and `runTsc`. |
|
|
41
|
+
|
|
42
|
+
### `azeroth-tsc` (command-line type checking)
|
|
43
|
+
|
|
44
|
+
`tsc` cannot parse `.azeroth`, so this package ships `azeroth-tsc`, the `vue-tsc`
|
|
45
|
+
equivalent. It reuses the language service to compile each `.azeroth` file to its
|
|
46
|
+
virtual TypeScript module, type-check it against the project's tsconfig, and print
|
|
47
|
+
`tsc`-style diagnostics mapped back to the original `.azeroth` positions, exiting
|
|
48
|
+
non-zero on the first error. It is a `--noEmit` gate (the Vite plugin / compiler
|
|
49
|
+
owns code emit), meant to run in CI and pre-commit beside `tsc`:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npx azeroth-tsc # check every .azeroth file under the cwd
|
|
53
|
+
npx azeroth-tsc -p tsconfig.json
|
|
54
|
+
npx azeroth-tsc --watch # re-check on every .azeroth change (alias: -w)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Build wiring
|
|
58
|
+
|
|
59
|
+
`azeroth-tsc` checks `.azeroth`; `tsc` checks the surrounding `.ts`. Run both
|
|
60
|
+
before bundling - the canonical consumer build is:
|
|
61
|
+
|
|
62
|
+
```jsonc
|
|
63
|
+
// package.json
|
|
64
|
+
{
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsc --noEmit && azeroth-tsc && vite build",
|
|
67
|
+
"typecheck": "tsc --noEmit && azeroth-tsc",
|
|
68
|
+
"dev:check": "azeroth-tsc --watch"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
With `@azerothjs/typescript-plugin` in the editor, `.ts` files importing
|
|
74
|
+
`.azeroth` already get real types live; `azeroth-tsc` provides the matching gate
|
|
75
|
+
on the command line and in CI.
|
|
76
|
+
|
|
77
|
+
#### Follow-up: a single combined checker
|
|
78
|
+
|
|
79
|
+
Today `tsc` and `azeroth-tsc` are two passes. A single `vue-tsc`-style binary
|
|
80
|
+
that builds one program over `.ts` + `.azeroth` together (so a `.ts` barrel
|
|
81
|
+
importing `.azeroth` is checked in the same run, without the editor plugin) is a
|
|
82
|
+
tracked follow-up; the building block - presenting each `.azeroth` as its virtual
|
|
83
|
+
TypeScript twin - is already shared by the language service and the
|
|
84
|
+
typescript-plugin.
|
|
39
85
|
|
|
40
86
|
### Settings
|
|
41
87
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
// re-exports it so the server can also be embedded (e.g. in a web worker host
|
|
6
6
|
// or an integration test that drives it through an in-memory connection).
|
|
7
7
|
export { startServer } from "./server.js";
|
|
8
|
+
export { runTsc, watchTsc, parseArgs } from "./tsc.js";
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAoD,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc-cli.d.ts","sourceRoot":"","sources":["../src/tsc-cli.ts"],"names":[],"mappings":""}
|
package/dist/tsc-cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Binary entry point for `azeroth-tsc`. Runs one batch type-check and exits
|
|
3
|
+
// non-zero when any `.azeroth` file has an error, so it drops into CI and
|
|
4
|
+
// pre-commit the same way `tsc --noEmit` does. All behaviour lives in the
|
|
5
|
+
// testable `runTsc`.
|
|
6
|
+
import { runTsc, watchTsc, parseArgs } from "./tsc.js";
|
|
7
|
+
const options = parseArgs(process.argv.slice(2));
|
|
8
|
+
if (options.watch) {
|
|
9
|
+
// The fs watcher keeps the event loop alive; the process stays up until the
|
|
10
|
+
// user interrupts it. Errors are reported each pass but don't exit the loop.
|
|
11
|
+
watchTsc(options);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const { errorCount } = runTsc(options);
|
|
15
|
+
process.exit(errorCount > 0 ? 1 : 0);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=tsc-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc-cli.js","sourceRoot":"","sources":["../src/tsc-cli.ts"],"names":[],"mappings":";AACA,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,qBAAqB;AAErB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjD,IAAI,OAAO,CAAC,KAAK,EACjB,CAAC;IACG,4EAA4E;IAC5E,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtB,CAAC;KAED,CAAC;IACG,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/tsc.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Options controlling a single check run. */
|
|
2
|
+
export interface TscOptions {
|
|
3
|
+
/** Directory to search for `.azeroth` files (default: cwd). */
|
|
4
|
+
cwd?: string;
|
|
5
|
+
/** Explicit tsconfig path; otherwise the nearest one is used. */
|
|
6
|
+
project?: string;
|
|
7
|
+
/** Re-check on every `.azeroth` change instead of running once. */
|
|
8
|
+
watch?: boolean;
|
|
9
|
+
/** Sink for formatted output (default: stdout). */
|
|
10
|
+
write?: (text: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/** A running watch session. */
|
|
13
|
+
export interface TscWatcher {
|
|
14
|
+
/** Runs one full check pass now (re-reading files from disk). */
|
|
15
|
+
recheck: () => TscResult;
|
|
16
|
+
/** Stops watching and releases the file-system watcher. */
|
|
17
|
+
close: () => void;
|
|
18
|
+
}
|
|
19
|
+
/** Outcome of a check run. */
|
|
20
|
+
export interface TscResult {
|
|
21
|
+
/** Number of `.azeroth` files checked. */
|
|
22
|
+
fileCount: number;
|
|
23
|
+
/** Number of error-severity diagnostics found. */
|
|
24
|
+
errorCount: number;
|
|
25
|
+
}
|
|
26
|
+
/** Parses the argv subset this CLI understands into {@link TscOptions}. */
|
|
27
|
+
export declare function parseArgs(argv: string[]): TscOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Type-checks every `.azeroth` file under `cwd` against the project's tsconfig,
|
|
30
|
+
* printing `tsc`-style diagnostics. Returns the file/error counts; the caller
|
|
31
|
+
* decides the process exit code.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const { errorCount } = runTsc({ cwd: 'app' });
|
|
36
|
+
* process.exit(errorCount > 0 ? 1 : 0);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function runTsc(options?: TscOptions): TscResult;
|
|
40
|
+
/**
|
|
41
|
+
* Runs an initial check, then re-checks whenever a `.azeroth` file under `cwd`
|
|
42
|
+
* changes. A single language service is reused across passes (each pass re-reads
|
|
43
|
+
* changed files from disk and bumps their version), so unchanged files and the
|
|
44
|
+
* lib/node_modules program are not re-parsed every time. Returns a handle:
|
|
45
|
+
* `recheck()` forces a pass (used by tests and the file watcher); `close()`
|
|
46
|
+
* stops watching. The returned watcher keeps the process alive via the
|
|
47
|
+
* underlying fs watcher.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const w = watchTsc({ cwd: 'app' }); // checks now, then on every change
|
|
52
|
+
* // ... later: w.close();
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function watchTsc(options?: TscOptions): TscWatcher;
|
|
56
|
+
//# sourceMappingURL=tsc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.d.ts","sourceRoot":"","sources":["../src/tsc.ts"],"names":[],"mappings":"AAeA,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IAEvB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,mDAAmD;IACnD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,+BAA+B;AAC/B,MAAM,WAAW,UAAU;IAEvB,iEAAiE;IACjE,OAAO,EAAE,MAAM,SAAS,CAAC;IAEzB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IAEtB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAwBpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,UAAe,GAAG,SAAS,CAU1D;AAoFD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,UAAe,GAAG,UAAU,CAuE7D"}
|
package/dist/tsc.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// azeroth-tsc: a batch type-checker for `.azeroth` files, the vue-tsc
|
|
2
|
+
// equivalent for this framework. `tsc` itself cannot parse `.azeroth` markup,
|
|
3
|
+
// so this driver reuses the language service (which compiles each file to a
|
|
4
|
+
// virtual TypeScript module and maps diagnostics back to original positions)
|
|
5
|
+
// and prints them in the familiar `tsc` format. It is meant to run in CI and
|
|
6
|
+
// pre-commit, alongside `tsc` for the surrounding `.ts`.
|
|
7
|
+
//
|
|
8
|
+
// Scope: this reports type errors in `.azeroth` files. It does not emit `.js`
|
|
9
|
+
// (the Vite plugin / compiler does that) - like `tsc --noEmit`, it is a gate.
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { watch as fsWatch } from 'node:fs';
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
import { AzerothLanguageService, pathToUri, DiagnosticSeverity } from '@azerothjs/language-service';
|
|
14
|
+
/** Parses the argv subset this CLI understands into {@link TscOptions}. */
|
|
15
|
+
export function parseArgs(argv) {
|
|
16
|
+
const options = {};
|
|
17
|
+
for (let i = 0; i < argv.length; i++) {
|
|
18
|
+
const arg = argv[i];
|
|
19
|
+
if (arg === '--project' || arg === '-p') {
|
|
20
|
+
options.project = argv[++i];
|
|
21
|
+
}
|
|
22
|
+
else if (arg.startsWith('--project=')) {
|
|
23
|
+
options.project = arg.slice('--project='.length);
|
|
24
|
+
}
|
|
25
|
+
else if (arg === '--watch' || arg === '-w') {
|
|
26
|
+
options.watch = true;
|
|
27
|
+
}
|
|
28
|
+
else if (!arg.startsWith('-')) {
|
|
29
|
+
options.cwd = arg;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return options;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type-checks every `.azeroth` file under `cwd` against the project's tsconfig,
|
|
36
|
+
* printing `tsc`-style diagnostics. Returns the file/error counts; the caller
|
|
37
|
+
* decides the process exit code.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const { errorCount } = runTsc({ cwd: 'app' });
|
|
42
|
+
* process.exit(errorCount > 0 ? 1 : 0);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function runTsc(options = {}) {
|
|
46
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
47
|
+
const write = options.write ?? ((text) => {
|
|
48
|
+
process.stdout.write(text);
|
|
49
|
+
});
|
|
50
|
+
const service = new AzerothLanguageService(cwd, options.project);
|
|
51
|
+
return checkPass(service, cwd, write, new Set());
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Runs one diagnostic pass over every `.azeroth` file under `cwd` using the
|
|
55
|
+
* given (possibly long-lived) service. `open` tracks which document URIs were
|
|
56
|
+
* open after the previous pass so files deleted since then are closed - this is
|
|
57
|
+
* what lets a single service be reused across watch passes without leaking
|
|
58
|
+
* stale documents. On return, `open` holds exactly the URIs seen this pass.
|
|
59
|
+
*/
|
|
60
|
+
function checkPass(service, cwd, write, open) {
|
|
61
|
+
const files = ts.sys.readDirectory(cwd, ['.azeroth'], ['**/node_modules/**', '**/dist/**', '**/.git/**'], ['**/*.azeroth']);
|
|
62
|
+
// On a reused service (watch), a file created or deleted since the last pass
|
|
63
|
+
// changes the program's root set; refresh discovery so cross-file resolution
|
|
64
|
+
// stays correct. Skipped on the first pass - the constructor just discovered.
|
|
65
|
+
if (open.size > 0 && files.length !== open.size) {
|
|
66
|
+
service.refreshWorkspace();
|
|
67
|
+
}
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
let errorCount = 0;
|
|
70
|
+
for (const file of files) {
|
|
71
|
+
const source = ts.sys.readFile(file);
|
|
72
|
+
if (source === undefined) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const uri = pathToUri(file);
|
|
76
|
+
seen.add(uri);
|
|
77
|
+
// didChange opens-or-updates: it bumps the version and invalidates just
|
|
78
|
+
// this file's virtual cache, so the reused service always reflects disk.
|
|
79
|
+
service.didChange(uri, source);
|
|
80
|
+
for (const diag of service.getDiagnostics(uri)) {
|
|
81
|
+
const isError = diag.severity === DiagnosticSeverity.Error;
|
|
82
|
+
if (isError) {
|
|
83
|
+
errorCount++;
|
|
84
|
+
}
|
|
85
|
+
write(formatDiagnostic(cwd, file, diag, isError) + '\n');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Drop documents whose files vanished since the previous pass.
|
|
89
|
+
for (const uri of open) {
|
|
90
|
+
if (!seen.has(uri)) {
|
|
91
|
+
service.didClose(uri);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
open.clear();
|
|
95
|
+
for (const uri of seen) {
|
|
96
|
+
open.add(uri);
|
|
97
|
+
}
|
|
98
|
+
if (errorCount === 0) {
|
|
99
|
+
write(`Checked ${files.length} .azeroth file(s); no type errors.\n`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
write(`\nFound ${errorCount} error(s) in ${files.length} .azeroth file(s).\n`);
|
|
103
|
+
}
|
|
104
|
+
return { fileCount: files.length, errorCount };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Runs an initial check, then re-checks whenever a `.azeroth` file under `cwd`
|
|
108
|
+
* changes. A single language service is reused across passes (each pass re-reads
|
|
109
|
+
* changed files from disk and bumps their version), so unchanged files and the
|
|
110
|
+
* lib/node_modules program are not re-parsed every time. Returns a handle:
|
|
111
|
+
* `recheck()` forces a pass (used by tests and the file watcher); `close()`
|
|
112
|
+
* stops watching. The returned watcher keeps the process alive via the
|
|
113
|
+
* underlying fs watcher.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const w = watchTsc({ cwd: 'app' }); // checks now, then on every change
|
|
118
|
+
* // ... later: w.close();
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export function watchTsc(options = {}) {
|
|
122
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
123
|
+
const write = options.write ?? ((text) => {
|
|
124
|
+
process.stdout.write(text);
|
|
125
|
+
});
|
|
126
|
+
// One service for the whole session: lib.d.ts, node_modules and unchanged
|
|
127
|
+
// `.azeroth` files are parsed once and reused across passes via the document
|
|
128
|
+
// registry, instead of building a fresh program on every change. `open`
|
|
129
|
+
// tracks the open document set so deleted files are closed between passes.
|
|
130
|
+
const service = new AzerothLanguageService(cwd, options.project);
|
|
131
|
+
const open = new Set();
|
|
132
|
+
const recheck = () => {
|
|
133
|
+
write('\n[azeroth-tsc] checking .azeroth files...\n');
|
|
134
|
+
try {
|
|
135
|
+
return checkPass(service, cwd, write, open);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
// A bad tsconfig or an unreadable file must not kill the watch loop;
|
|
139
|
+
// report it and keep watching.
|
|
140
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
141
|
+
write(`[azeroth-tsc] check failed: ${message}\n`);
|
|
142
|
+
return { fileCount: 0, errorCount: 0 };
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
recheck();
|
|
146
|
+
let debounce = null;
|
|
147
|
+
let watcher;
|
|
148
|
+
try {
|
|
149
|
+
watcher = fsWatch(cwd, { recursive: true }, (_event, fileName) => {
|
|
150
|
+
// Recursive watch reports every file; only react to `.azeroth`.
|
|
151
|
+
if (fileName && !String(fileName).endsWith('.azeroth')) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (debounce) {
|
|
155
|
+
clearTimeout(debounce);
|
|
156
|
+
}
|
|
157
|
+
debounce = setTimeout(recheck, 120);
|
|
158
|
+
});
|
|
159
|
+
write(`[azeroth-tsc] watching ${cwd} for .azeroth changes (Ctrl+C to exit)\n`);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Recursive watch isn't supported on every platform; fall back to a
|
|
163
|
+
// one-shot check rather than crashing.
|
|
164
|
+
write('[azeroth-tsc] file watching unavailable on this platform; ran a single check\n');
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
recheck,
|
|
168
|
+
close: () => {
|
|
169
|
+
if (debounce) {
|
|
170
|
+
clearTimeout(debounce);
|
|
171
|
+
}
|
|
172
|
+
watcher?.close();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Formats one diagnostic in `tsc`'s `file(line,col): error TSxxxx: msg` shape. */
|
|
177
|
+
function formatDiagnostic(cwd, file, diag, isError) {
|
|
178
|
+
const rel = path.relative(cwd, file).replace(/\\/g, '/');
|
|
179
|
+
const line = diag.range.start.line + 1;
|
|
180
|
+
const column = diag.range.start.character + 1;
|
|
181
|
+
const severity = isError ? 'error' : 'warning';
|
|
182
|
+
const code = typeof diag.code === 'number' ? ` TS${diag.code}` : '';
|
|
183
|
+
return `${rel}(${line},${column}): ${severity}${code}: ${diag.message}`;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=tsc.js.map
|
package/dist/tsc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.js","sourceRoot":"","sources":["../src/tsc.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,yDAAyD;AACzD,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAE9E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,OAAO,EAAkB,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAsCpG,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAc;IAEpC,MAAM,OAAO,GAAe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AC5F,CAAC;IAED,OAAO;QACH,OAAO;QACP,KAAK,EAAE,GAAS,EAAE;YAEd,IAAI,QAAQ,EACZ,CAAC;gBACG,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,CAAC;QACrB,CAAC;KACJ,CAAC;AACN,CAAC;AAED,mFAAmF;AACnF,SAAS,gBAAgB,CACrB,GAAW,EACX,IAAY,EACZ,IAAwG,EACxG,OAAgB;IAGhB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAO,IAAI,CAAC,IAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO,GAAI,GAAI,IAAK,IAAK,IAAK,MAAO,MAAO,QAAS,GAAI,IAAK,KAAM,IAAI,CAAC,OAAQ,EAAE,CAAC;AACxF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azerothjs/language-server",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.3",
|
|
4
4
|
"description": "AzerothJS language server — a Language Server Protocol front-end for .azeroth files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin":
|
|
10
10
|
{
|
|
11
|
-
"azeroth-language-server": "./dist/cli.js"
|
|
11
|
+
"azeroth-language-server": "./dist/cli.js",
|
|
12
|
+
"azeroth-tsc": "./dist/tsc-cli.js"
|
|
12
13
|
},
|
|
13
14
|
"exports":
|
|
14
15
|
{
|
|
@@ -18,7 +19,8 @@
|
|
|
18
19
|
"import": "./dist/index.js",
|
|
19
20
|
"default": "./dist/index.js"
|
|
20
21
|
},
|
|
21
|
-
"./cli": "./dist/cli.js"
|
|
22
|
+
"./cli": "./dist/cli.js",
|
|
23
|
+
"./tsc": "./dist/tsc.js"
|
|
22
24
|
},
|
|
23
25
|
"files":
|
|
24
26
|
[
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
],
|
|
27
29
|
"dependencies":
|
|
28
30
|
{
|
|
29
|
-
"@azerothjs/language-service": "0.4.0-beta.
|
|
31
|
+
"@azerothjs/language-service": "0.4.0-beta.3",
|
|
30
32
|
"typescript": ">=5",
|
|
31
33
|
"vscode-languageserver": "^9",
|
|
32
34
|
"vscode-languageserver-textdocument": "^1"
|