@svgrid/mcp 3.0.32 → 3.0.34
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/dist/compile-core.d.ts +24 -0
- package/dist/compile-core.js +27 -0
- package/dist/compile-svelte.js +2 -26
- package/dist/data.js +104 -75
- package/dist/index.js +21 -19
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/stdio-server.d.ts +60 -0
- package/dist/stdio-server.js +95 -0
- package/dist/tool-defs.d.ts +12 -0
- package/dist/tool-defs.js +15 -0
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +37 -0
- package/package.json +5 -7
- package/server.json +2 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte compiler output as `check_svgrid_code` diagnostics.
|
|
3
|
+
*
|
|
4
|
+
* No Node imports here, on purpose: the stdio server loads the compiler from
|
|
5
|
+
* the user's project (compile-svelte.ts) and the Worker bundles its own copy,
|
|
6
|
+
* and both turn what it says into findings through this one function, so the
|
|
7
|
+
* two servers report a broken file the same way.
|
|
8
|
+
*/
|
|
9
|
+
import type { Diagnostic } from './validate.js';
|
|
10
|
+
type SvelteMessage = {
|
|
11
|
+
code?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
start?: {
|
|
14
|
+
line?: number;
|
|
15
|
+
column?: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type CompileApi = {
|
|
19
|
+
compile: (src: string, options: Record<string, unknown>) => {
|
|
20
|
+
warnings: SvelteMessage[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function compileDiagnostics(mod: CompileApi, source: string, filename: string): Diagnostic[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Compiler warnings that repeat per element and drown the real findings. */
|
|
2
|
+
const MAX_WARNINGS = 15;
|
|
3
|
+
export function compileDiagnostics(mod, source, filename) {
|
|
4
|
+
const diagnostics = [];
|
|
5
|
+
try {
|
|
6
|
+
const { warnings } = mod.compile(source, { filename, generate: 'client' });
|
|
7
|
+
for (const w of warnings.slice(0, MAX_WARNINGS)) {
|
|
8
|
+
diagnostics.push({
|
|
9
|
+
rule: `svelte/${w.code ?? 'warning'}`,
|
|
10
|
+
severity: 'warning',
|
|
11
|
+
line: w.start?.line ?? 1,
|
|
12
|
+
message: w.message ?? 'compiler warning',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const e = err;
|
|
18
|
+
diagnostics.push({
|
|
19
|
+
rule: `svelte/${e.code ?? 'compile-error'}`,
|
|
20
|
+
severity: 'error',
|
|
21
|
+
line: e.start?.line ?? 1,
|
|
22
|
+
message: (e.message ?? String(err)).split('\n')[0],
|
|
23
|
+
fix: 'The file does not parse. Fix this first - every other check ran on unparsed text.',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return diagnostics;
|
|
27
|
+
}
|
package/dist/compile-svelte.js
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
import { createRequire } from 'node:module';
|
|
11
11
|
import { pathToFileURL } from 'node:url';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
|
-
|
|
14
|
-
const MAX_WARNINGS = 15;
|
|
13
|
+
import { compileDiagnostics } from './compile-core.js';
|
|
15
14
|
/**
|
|
16
15
|
* Prefer the Svelte the USER's project is on, so the check matches what their
|
|
17
16
|
* build will do; fall back to the copy that ships with this package. Resolved
|
|
@@ -47,28 +46,5 @@ export const compileWithSvelte = async (source, filename) => {
|
|
|
47
46
|
const mod = await loadCompiler();
|
|
48
47
|
if (!mod)
|
|
49
48
|
return { available: false, diagnostics: [] };
|
|
50
|
-
|
|
51
|
-
const diagnostics = [];
|
|
52
|
-
try {
|
|
53
|
-
const { warnings } = compile(source, { filename, generate: 'client' });
|
|
54
|
-
for (const w of warnings.slice(0, MAX_WARNINGS)) {
|
|
55
|
-
diagnostics.push({
|
|
56
|
-
rule: `svelte/${w.code ?? 'warning'}`,
|
|
57
|
-
severity: 'warning',
|
|
58
|
-
line: w.start?.line ?? 1,
|
|
59
|
-
message: w.message ?? 'compiler warning',
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
const e = err;
|
|
65
|
-
diagnostics.push({
|
|
66
|
-
rule: `svelte/${e.code ?? 'compile-error'}`,
|
|
67
|
-
severity: 'error',
|
|
68
|
-
line: e.start?.line ?? 1,
|
|
69
|
-
message: (e.message ?? String(err)).split('\n')[0],
|
|
70
|
-
fix: 'The file does not parse. Fix this first - every other check ran on unparsed text.',
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return { available: true, diagnostics };
|
|
49
|
+
return { available: true, diagnostics: compileDiagnostics(mod, source, filename) };
|
|
74
50
|
};
|