@flint.fyi/svelte-language 0.0.2 → 0.0.4

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.
@@ -1,5 +1,5 @@
1
+ import type { AST } from "svelte/compiler";
1
2
  import { type SourceFileWithLineMap } from "@flint.fyi/core";
2
3
  import type { ExtractedDirective } from "@flint.fyi/typescript-language";
3
- import type { AST } from "svelte/compiler";
4
4
  export declare function extractDirectives(ast: AST.Root, source: SourceFileWithLineMap): ExtractedDirective[];
5
5
  //# sourceMappingURL=extractDirectives.d.ts.map
package/lib/language.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { extractDirectives } from "./extractDirectives.js";
2
2
  import { errorToLanguageReport, virtualCodeReports, volarLanguagePlugin } from "./volarLanguagePlugin.js";
3
+ import { parse } from "svelte/compiler";
3
4
  import { setTSExtraSupportedExtensions } from "@flint.fyi/ts-patch";
4
5
  import { createVolarBasedLanguage } from "@flint.fyi/volar-language";
5
- import { parse } from "svelte/compiler";
6
6
  //#region src/language.ts
7
7
  setTSExtraSupportedExtensions([".svelte"]);
8
8
  const svelteLanguage = createVolarBasedLanguage((ts, options) => {
@@ -1,6 +1,6 @@
1
- import { type LanguageReport } from "@flint.fyi/core";
2
1
  import { type LanguagePlugin, type VirtualCode } from "@volar/language-core";
3
2
  import type * as ts from "typescript";
3
+ import { type LanguageReport } from "@flint.fyi/core";
4
4
  export declare function volarLanguagePlugin(ts: typeof import("typescript"), options: ts.CreateProgramOptions): LanguagePlugin<string>;
5
5
  export declare const virtualCodeReports: WeakMap<VirtualCode, LanguageReport>;
6
6
  export declare function errorToLanguageReport(fileName: string, error: unknown): LanguageReport;
@@ -1,8 +1,8 @@
1
1
  import { getPositionOfColumnAndLine } from "@flint.fyi/core";
2
- import { decode } from "@jridgewell/sourcemap-codec";
3
- import { forEachEmbeddedCode } from "@volar/language-core";
4
2
  import path from "node:path";
5
3
  import url from "node:url";
4
+ import { decode } from "@jridgewell/sourcemap-codec";
5
+ import { forEachEmbeddedCode } from "@volar/language-core";
6
6
  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")));
@@ -47,11 +47,25 @@ function volarLanguagePlugin(ts, options) {
47
47
  }
48
48
  const virtualCodeReports = /* @__PURE__ */ new WeakMap();
49
49
  function errorToLanguageReport(fileName, error) {
50
- if (typeof error !== "object" || error == null) return { text: `${fileName} - Unknown error` };
51
- const res = { text: `${fileName}${"position" in error && Array.isArray(error.position) ? `:${error.position[0]}:${error.position[1]}` : ""} - ${"message" in error && typeof error.message === "string" ? error.message : "Codegen error"}` };
50
+ if (typeof error !== "object" || error == null) return {
51
+ source: "svelte",
52
+ text: `${fileName} - Unknown error`
53
+ };
54
+ const svelteError = isSvelteCompileError(error) ? error : null;
55
+ const res = {
56
+ source: "svelte",
57
+ text: `${fileName}${svelteError?.start != null ? `:${svelteError.start.line}:${svelteError.start.column}` : ""} - ${"message" in error && typeof error.message === "string" ? error.message : "Codegen error"}`
58
+ };
59
+ if (svelteError?.start != null) res.range = {
60
+ begin: svelteError.start.character,
61
+ end: svelteError.end?.character ?? svelteError.start.character
62
+ };
52
63
  if ("code" in error && typeof error.code === "string") res.code = error.code;
53
64
  return res;
54
65
  }
66
+ function isSvelteCompileError(error) {
67
+ return "start" in error && typeof error.start === "object" && error.start !== null && "character" in error.start && typeof error.start.character === "number";
68
+ }
55
69
  function getEmbeddedTsCode(ts, cwd, fileName, text) {
56
70
  const svelteTsxFiles = internalHelpers.get_global_types(ts.sys, false, sveltePath, svelte2tsxPath, cwd);
57
71
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flint.fyi/svelte-language",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "[Experimental] Svelte language for Flint.",
5
5
  "homepage": "https://flint.fyi",
6
6
  "repository": {
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "author": {
13
- "name": "JoshuaKGoldberg",
14
- "email": "npm@joshuakgoldberg.com"
13
+ "name": "Flint Team",
14
+ "url": "https://flint.fyi/team"
15
15
  },
16
16
  "sideEffects": true,
17
17
  "type": "module",
@@ -28,11 +28,11 @@
28
28
  "svelte": "^5.0.0",
29
29
  "svelte2tsx": "^0.7.52",
30
30
  "typescript": "^5.9.0 || ^6.0.0",
31
- "@flint.fyi/core": "^0.21.0",
31
+ "@flint.fyi/typescript-language": "^0.18.3",
32
32
  "@flint.fyi/ts-patch": "^0.13.5",
33
- "@flint.fyi/typescript-language": "^0.18.0",
34
- "@flint.fyi/volar-language": "^0.1.0",
35
- "@flint.fyi/utils": "^0.14.1"
33
+ "@flint.fyi/core": "^0.23.0",
34
+ "@flint.fyi/utils": "^0.14.1",
35
+ "@flint.fyi/volar-language": "^0.1.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "tsdown": "0.21.0",