@flint.fyi/vue-language 0.1.2 → 0.2.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/{lib/language.d.ts → dist/index.d.mts} +1 -1
- package/{lib/language.js → dist/index.mjs} +54 -2
- package/package.json +9 -8
- package/lib/extractTemplateDirectives.d.ts +0 -3
- package/lib/extractTemplateDirectives.js +0 -36
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/vueParsingErrorsToLanguageReports.d.ts +0 -3
- package/lib/vueParsingErrorsToLanguageReports.js +0 -22
|
@@ -14,4 +14,4 @@ interface VueServices {
|
|
|
14
14
|
type VueCodegen = typeof tsCodegen extends WeakMap<WeakKey, infer V> ? V : never;
|
|
15
15
|
declare const vueLanguage: import("@flint.fyi/volar-language").Language<import("@flint.fyi/typescript-language").TypeScriptNodesByName, Partial<VueServices> & import("@flint.fyi/typescript-language").TypeScriptFileServices>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { vueLanguage };
|
|
@@ -1,10 +1,62 @@
|
|
|
1
|
-
import { extractTemplateDirectives } from "./extractTemplateDirectives.js";
|
|
2
|
-
import { vueParsingErrorsToLanguageReports } from "./vueParsingErrorsToLanguageReports.js";
|
|
3
1
|
import { NodeTypes, parse } from "@vue/compiler-dom";
|
|
4
2
|
import { VueVirtualCode, createParsedCommandLine, createParsedCommandLineByJson, createVueLanguagePlugin, tsCodegen } from "@vue/language-core";
|
|
5
3
|
import { setTSExtraSupportedExtensions } from "@flint.fyi/ts-patch";
|
|
6
4
|
import { assert, nullThrows } from "@flint.fyi/utils";
|
|
7
5
|
import { createVolarBasedLanguage } from "@flint.fyi/volar-language";
|
|
6
|
+
//#region src/extractTemplateDirectives.ts
|
|
7
|
+
function extractTemplateDirectives(ast) {
|
|
8
|
+
const directives = [];
|
|
9
|
+
function visitTemplate(elem) {
|
|
10
|
+
if (elem.type === NodeTypes.ELEMENT) {
|
|
11
|
+
for (const child of elem.children) visitTemplate(child);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (elem.type !== NodeTypes.COMMENT) return;
|
|
15
|
+
const match = /\s*flint-(\S+)(?:\s+(.+))?/.exec(elem.content);
|
|
16
|
+
if (match == null) return;
|
|
17
|
+
const [, type, selection] = match;
|
|
18
|
+
directives.push({
|
|
19
|
+
range: {
|
|
20
|
+
begin: {
|
|
21
|
+
column: elem.loc.start.column - 1,
|
|
22
|
+
line: elem.loc.start.line - 1,
|
|
23
|
+
raw: elem.loc.start.offset
|
|
24
|
+
},
|
|
25
|
+
end: {
|
|
26
|
+
column: elem.loc.end.column - 1,
|
|
27
|
+
line: elem.loc.end.line - 1,
|
|
28
|
+
raw: elem.loc.end.offset
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
selection: nullThrows(selection, "Expected RegExp to provide second capturing group"),
|
|
32
|
+
type: nullThrows(type, "Expected RegExp to provide first capturing group")
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
for (const child of ast.children) visitTemplate(child);
|
|
36
|
+
return directives;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/vueParsingErrorsToLanguageReports.ts
|
|
40
|
+
function vueParsingErrorsToLanguageReports(fileName, errors) {
|
|
41
|
+
return errors.map((error) => {
|
|
42
|
+
let code = "VUE";
|
|
43
|
+
let loc = "";
|
|
44
|
+
if ("code" in error) {
|
|
45
|
+
code += error.code.toString();
|
|
46
|
+
loc = error.loc != null ? `:${error.loc.start.line}:${error.loc.start.column}` : "";
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
code,
|
|
50
|
+
source: "vue",
|
|
51
|
+
text: `${fileName}${loc} - ${code}: ${error.name} - ${error.message}`,
|
|
52
|
+
..."code" in error && error.loc != null && { range: {
|
|
53
|
+
begin: error.loc.start.offset,
|
|
54
|
+
end: error.loc.end.offset
|
|
55
|
+
} }
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
8
60
|
//#region src/language.ts
|
|
9
61
|
setTSExtraSupportedExtensions([".vue"]);
|
|
10
62
|
const vueLanguage = createVolarBasedLanguage((ts, options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/vue-language",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "[Experimental] Vue.js language for Flint.",
|
|
5
5
|
"homepage": "https://flint.fyi",
|
|
6
6
|
"repository": {
|
|
@@ -16,25 +16,26 @@
|
|
|
16
16
|
"sideEffects": true,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./
|
|
19
|
+
".": "./dist/index.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"
|
|
22
|
+
"dist/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@volar/language-core": "2.4.28",
|
|
26
26
|
"@vue/compiler-dom": "^3.5.0",
|
|
27
27
|
"@vue/language-core": "3.2.1",
|
|
28
28
|
"typescript": "^5.9.0 || ^6.0.0",
|
|
29
|
-
"@flint.fyi/ts-patch": "^0.
|
|
30
|
-
"@flint.fyi/
|
|
31
|
-
"@flint.fyi/
|
|
32
|
-
"@flint.fyi/
|
|
29
|
+
"@flint.fyi/ts-patch": "^0.15.0",
|
|
30
|
+
"@flint.fyi/utils": "^0.15.0",
|
|
31
|
+
"@flint.fyi/volar-language": "^0.2.0",
|
|
32
|
+
"@flint.fyi/typescript-language": "^0.19.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"tsdown": "0.22.3",
|
|
36
36
|
"vitest": "4.1.0",
|
|
37
|
-
"@flint.fyi/core": "^0.
|
|
37
|
+
"@flint.fyi/core": "^0.24.0",
|
|
38
|
+
"@flint.fyi/build": "^0.1.0"
|
|
38
39
|
},
|
|
39
40
|
"engines": {
|
|
40
41
|
"node": ">=24.0.0"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { NodeTypes } from "@vue/compiler-dom";
|
|
2
|
-
import { nullThrows } from "@flint.fyi/utils";
|
|
3
|
-
//#region src/extractTemplateDirectives.ts
|
|
4
|
-
function extractTemplateDirectives(ast) {
|
|
5
|
-
const directives = [];
|
|
6
|
-
function visitTemplate(elem) {
|
|
7
|
-
if (elem.type === NodeTypes.ELEMENT) {
|
|
8
|
-
for (const child of elem.children) visitTemplate(child);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (elem.type !== NodeTypes.COMMENT) return;
|
|
12
|
-
const match = /\s*flint-(\S+)(?:\s+(.+))?/.exec(elem.content);
|
|
13
|
-
if (match == null) return;
|
|
14
|
-
const [, type, selection] = match;
|
|
15
|
-
directives.push({
|
|
16
|
-
range: {
|
|
17
|
-
begin: {
|
|
18
|
-
column: elem.loc.start.column - 1,
|
|
19
|
-
line: elem.loc.start.line - 1,
|
|
20
|
-
raw: elem.loc.start.offset
|
|
21
|
-
},
|
|
22
|
-
end: {
|
|
23
|
-
column: elem.loc.end.column - 1,
|
|
24
|
-
line: elem.loc.end.line - 1,
|
|
25
|
-
raw: elem.loc.end.offset
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
selection: nullThrows(selection, "Expected RegExp to provide second capturing group"),
|
|
29
|
-
type: nullThrows(type, "Expected RegExp to provide first capturing group")
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
for (const child of ast.children) visitTemplate(child);
|
|
33
|
-
return directives;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { extractTemplateDirectives };
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/vueParsingErrorsToLanguageReports.ts
|
|
2
|
-
function vueParsingErrorsToLanguageReports(fileName, errors) {
|
|
3
|
-
return errors.map((error) => {
|
|
4
|
-
let code = "VUE";
|
|
5
|
-
let loc = "";
|
|
6
|
-
if ("code" in error) {
|
|
7
|
-
code += error.code.toString();
|
|
8
|
-
loc = error.loc != null ? `:${error.loc.start.line}:${error.loc.start.column}` : "";
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
code,
|
|
12
|
-
source: "vue",
|
|
13
|
-
text: `${fileName}${loc} - ${code}: ${error.name} - ${error.message}`,
|
|
14
|
-
..."code" in error && error.loc != null && { range: {
|
|
15
|
-
begin: error.loc.start.offset,
|
|
16
|
-
end: error.loc.end.offset
|
|
17
|
-
} }
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { vueParsingErrorsToLanguageReports };
|