@flint.fyi/svelte-language 0.0.4 → 0.0.5
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.
|
@@ -2,4 +2,3 @@ import type { AST } from "svelte/compiler";
|
|
|
2
2
|
import { type SourceFileWithLineMap } from "@flint.fyi/core";
|
|
3
3
|
import type { ExtractedDirective } from "@flint.fyi/typescript-language";
|
|
4
4
|
export declare function extractDirectives(ast: AST.Root, source: SourceFileWithLineMap): ExtractedDirective[];
|
|
5
|
-
//# sourceMappingURL=extractDirectives.d.ts.map
|
package/lib/extractDirectives.js
CHANGED
package/lib/language.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { AST } from "svelte/compiler";
|
|
2
|
-
import * as _flint_fyi_core0 from "@flint.fyi/core";
|
|
3
|
-
import * as _flint_fyi_typescript_language0 from "@flint.fyi/typescript-language";
|
|
4
2
|
|
|
5
3
|
//#region src/language.d.ts
|
|
6
4
|
interface SvelteServices {
|
|
@@ -9,7 +7,6 @@ interface SvelteServices {
|
|
|
9
7
|
sourceText: string;
|
|
10
8
|
};
|
|
11
9
|
}
|
|
12
|
-
declare const svelteLanguage:
|
|
10
|
+
declare const svelteLanguage: import("@flint.fyi/core").Language<import("@flint.fyi/typescript-language").TypeScriptNodesByName, Partial<SvelteServices> & import("@flint.fyi/typescript-language").TypeScriptFileServices>;
|
|
13
11
|
//#endregion
|
|
14
|
-
export { svelteLanguage };
|
|
15
|
-
//# sourceMappingURL=language.d.ts.map
|
|
12
|
+
export { SvelteServices, svelteLanguage };
|
package/lib/language.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type LanguagePlugin, type VirtualCode } from "@volar/language-core";
|
|
2
|
-
import type
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
import type { CreateProgramOptions } from "typescript";
|
|
3
4
|
import { type LanguageReport } from "@flint.fyi/core";
|
|
4
|
-
export declare function volarLanguagePlugin(
|
|
5
|
+
export declare function volarLanguagePlugin(typescript: typeof ts, options: CreateProgramOptions): LanguagePlugin<string>;
|
|
5
6
|
export declare const virtualCodeReports: WeakMap<VirtualCode, LanguageReport>;
|
|
6
7
|
export declare function errorToLanguageReport(fileName: string, error: unknown): LanguageReport;
|
|
7
|
-
//# sourceMappingURL=volarLanguagePlugin.d.ts.map
|
|
@@ -7,14 +7,14 @@ import { internalHelpers, svelte2tsx } from "svelte2tsx";
|
|
|
7
7
|
//#region src/volarLanguagePlugin.ts
|
|
8
8
|
const sveltePath = path.dirname(url.fileURLToPath(import.meta.resolve("svelte/package.json")));
|
|
9
9
|
const svelte2tsxPath = path.dirname(url.fileURLToPath(import.meta.resolve("svelte2tsx/package.json")));
|
|
10
|
-
function volarLanguagePlugin(
|
|
11
|
-
const cwd = typeof options.options.configFilePath === "string" ? path.dirname(options.options.configFilePath) : (options.host ??
|
|
10
|
+
function volarLanguagePlugin(typescript, options) {
|
|
11
|
+
const cwd = typeof options.options.configFilePath === "string" ? path.dirname(options.options.configFilePath) : (options.host ?? typescript.sys).getCurrentDirectory();
|
|
12
12
|
return {
|
|
13
13
|
createVirtualCode(fileName, languageId, snapshot) {
|
|
14
14
|
if (languageId !== "svelte") return;
|
|
15
15
|
return {
|
|
16
16
|
codegenStacks: [],
|
|
17
|
-
embeddedCodes: [getEmbeddedTsCode(
|
|
17
|
+
embeddedCodes: [getEmbeddedTsCode(typescript, cwd, fileName, snapshot.getText(0, snapshot.getLength()))],
|
|
18
18
|
id: "root",
|
|
19
19
|
languageId,
|
|
20
20
|
mappings: [],
|
|
@@ -40,7 +40,7 @@ function volarLanguagePlugin(ts, options) {
|
|
|
40
40
|
},
|
|
41
41
|
updateVirtualCode(fileName, virtualCode, snapshot) {
|
|
42
42
|
virtualCode.snapshot = snapshot;
|
|
43
|
-
virtualCode.embeddedCodes = [getEmbeddedTsCode(
|
|
43
|
+
virtualCode.embeddedCodes = [getEmbeddedTsCode(typescript, cwd, fileName, snapshot.getText(0, snapshot.getLength()))];
|
|
44
44
|
return virtualCode;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -66,8 +66,8 @@ function errorToLanguageReport(fileName, error) {
|
|
|
66
66
|
function isSvelteCompileError(error) {
|
|
67
67
|
return "start" in error && typeof error.start === "object" && error.start !== null && "character" in error.start && typeof error.start.character === "number";
|
|
68
68
|
}
|
|
69
|
-
function getEmbeddedTsCode(
|
|
70
|
-
const svelteTsxFiles = internalHelpers.get_global_types(
|
|
69
|
+
function getEmbeddedTsCode(typescript, cwd, fileName, text) {
|
|
70
|
+
const svelteTsxFiles = internalHelpers.get_global_types(typescript.sys, false, sveltePath, svelte2tsxPath, cwd);
|
|
71
71
|
try {
|
|
72
72
|
const tsx = svelte2tsx(text, {
|
|
73
73
|
isTsFile: true,
|
|
@@ -159,5 +159,3 @@ function getEmbeddedTsCode(ts, cwd, fileName, text) {
|
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
export { errorToLanguageReport, virtualCodeReports, volarLanguagePlugin };
|
|
162
|
-
|
|
163
|
-
//# sourceMappingURL=volarLanguagePlugin.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/svelte-language",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "[Experimental] Svelte language for Flint.",
|
|
5
5
|
"homepage": "https://flint.fyi",
|
|
6
6
|
"repository": {
|
|
@@ -19,23 +19,22 @@
|
|
|
19
19
|
".": "./lib/index.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"lib/"
|
|
23
|
-
"!lib/**/*.map"
|
|
22
|
+
"lib/"
|
|
24
23
|
],
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@jridgewell/sourcemap-codec": "^1.5.5",
|
|
27
26
|
"@volar/language-core": "2.4.28",
|
|
28
27
|
"svelte": "^5.0.0",
|
|
29
|
-
"svelte2tsx": "^0.7.
|
|
28
|
+
"svelte2tsx": "^0.7.55",
|
|
30
29
|
"typescript": "^5.9.0 || ^6.0.0",
|
|
31
|
-
"@flint.fyi/
|
|
32
|
-
"@flint.fyi/ts-patch": "^0.
|
|
33
|
-
"@flint.fyi/core": "^0.23.0",
|
|
30
|
+
"@flint.fyi/core": "^0.23.3",
|
|
31
|
+
"@flint.fyi/ts-patch": "^0.14.0",
|
|
34
32
|
"@flint.fyi/utils": "^0.14.1",
|
|
35
|
-
"@flint.fyi/volar-language": "^0.1.
|
|
33
|
+
"@flint.fyi/volar-language": "^0.1.4",
|
|
34
|
+
"@flint.fyi/typescript-language": "^0.18.4"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"tsdown": "0.
|
|
37
|
+
"tsdown": "0.22.3",
|
|
39
38
|
"vitest": "4.1.0"
|
|
40
39
|
},
|
|
41
40
|
"engines": {
|