@flint.fyi/vue-language 0.1.1 → 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/dist/index.d.mts +17 -0
- package/{lib/language.js → dist/index.mjs} +54 -4
- package/package.json +10 -10
- package/lib/extractTemplateDirectives.d.ts +0 -4
- package/lib/extractTemplateDirectives.js +0 -38
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/language.d.ts +0 -20
- package/lib/vueParsingErrorsToLanguageReports.d.ts +0 -4
- package/lib/vueParsingErrorsToLanguageReports.js +0 -24
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RootNode } from "@vue/compiler-dom";
|
|
2
|
+
import { VueVirtualCode, tsCodegen } from "@vue/language-core";
|
|
3
|
+
import { Mapper } from "@volar/language-core";
|
|
4
|
+
|
|
5
|
+
//#region src/language.d.ts
|
|
6
|
+
interface VueServices {
|
|
7
|
+
vue: {
|
|
8
|
+
codegen: VueCodegen;
|
|
9
|
+
map: Mapper;
|
|
10
|
+
sfc: RootNode;
|
|
11
|
+
virtualCode: VueVirtualCode;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
type VueCodegen = typeof tsCodegen extends WeakMap<WeakKey, infer V> ? V : never;
|
|
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
|
+
//#endregion
|
|
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) => {
|
|
@@ -46,5 +98,3 @@ const vueLanguage = createVolarBasedLanguage((ts, options) => {
|
|
|
46
98
|
});
|
|
47
99
|
//#endregion
|
|
48
100
|
export { vueLanguage };
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=language.js.map
|
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,26 +16,26 @@
|
|
|
16
16
|
"sideEffects": true,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./
|
|
19
|
+
".": "./dist/index.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"!lib/**/*.map"
|
|
22
|
+
"dist/"
|
|
24
23
|
],
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@volar/language-core": "2.4.28",
|
|
27
26
|
"@vue/compiler-dom": "^3.5.0",
|
|
28
27
|
"@vue/language-core": "3.2.1",
|
|
29
28
|
"typescript": "^5.9.0 || ^6.0.0",
|
|
30
|
-
"@flint.fyi/ts-patch": "^0.
|
|
31
|
-
"@flint.fyi/utils": "^0.
|
|
32
|
-
"@flint.fyi/volar-language": "^0.
|
|
33
|
-
"@flint.fyi/typescript-language": "^0.
|
|
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"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"tsdown": "0.
|
|
35
|
+
"tsdown": "0.22.3",
|
|
37
36
|
"vitest": "4.1.0",
|
|
38
|
-
"@flint.fyi/core": "^0.
|
|
37
|
+
"@flint.fyi/core": "^0.24.0",
|
|
38
|
+
"@flint.fyi/build": "^0.1.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=24.0.0"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type RootNode } from "@vue/compiler-dom";
|
|
2
|
-
import type { ExtractedDirective } from "@flint.fyi/typescript-language";
|
|
3
|
-
export declare function extractTemplateDirectives(ast: RootNode): ExtractedDirective[];
|
|
4
|
-
//# sourceMappingURL=extractTemplateDirectives.d.ts.map
|
|
@@ -1,38 +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 };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=extractTemplateDirectives.js.map
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
package/lib/language.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RootNode } from "@vue/compiler-dom";
|
|
2
|
-
import { VueVirtualCode, tsCodegen } from "@vue/language-core";
|
|
3
|
-
import * as _flint_fyi_volar_language0 from "@flint.fyi/volar-language";
|
|
4
|
-
import * as _flint_fyi_typescript_language0 from "@flint.fyi/typescript-language";
|
|
5
|
-
import { Mapper } from "@volar/language-core";
|
|
6
|
-
|
|
7
|
-
//#region src/language.d.ts
|
|
8
|
-
interface VueServices {
|
|
9
|
-
vue: {
|
|
10
|
-
codegen: VueCodegen;
|
|
11
|
-
map: Mapper;
|
|
12
|
-
sfc: RootNode;
|
|
13
|
-
virtualCode: VueVirtualCode;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
type VueCodegen = typeof tsCodegen extends WeakMap<WeakKey, infer V> ? V : never;
|
|
17
|
-
declare const vueLanguage: _flint_fyi_volar_language0.Language<_flint_fyi_typescript_language0.TypeScriptNodesByName, Partial<VueServices> & _flint_fyi_typescript_language0.TypeScriptFileServices>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { vueLanguage };
|
|
20
|
-
//# sourceMappingURL=language.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CompilerError } from "@vue/compiler-dom";
|
|
2
|
-
import type { LanguageReports } from "@flint.fyi/core";
|
|
3
|
-
export declare function vueParsingErrorsToLanguageReports(fileName: string, errors: (CompilerError | SyntaxError)[]): LanguageReports;
|
|
4
|
-
//# sourceMappingURL=vueParsingErrorsToLanguageReports.d.ts.map
|
|
@@ -1,24 +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 };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=vueParsingErrorsToLanguageReports.js.map
|