@astrojs/language-server 2.15.4 → 2.16.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/check.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -40,9 +50,9 @@ const vscode_uri_1 = require("vscode-uri");
40
50
  const index_js_1 = require("./core/index.js");
41
51
  const svelte_js_1 = require("./core/svelte.js");
42
52
  const vue_js_1 = require("./core/vue.js");
43
- const utils_js_1 = require("./utils.js");
44
53
  const astro_js_1 = require("./plugins/astro.js");
45
54
  const index_js_2 = require("./plugins/typescript/index.js");
55
+ const utils_js_1 = require("./utils.js");
46
56
  class AstroCheck {
47
57
  constructor(workspacePath, typescriptPath, tsconfigPath) {
48
58
  this.workspacePath = workspacePath;
@@ -4,7 +4,7 @@ import type ts from 'typescript';
4
4
  import type { HTMLDocument } from 'vscode-html-languageservice';
5
5
  import type { URI } from 'vscode-uri';
6
6
  import type { PackageInfo } from '../importPackage.js';
7
- import type { AstroMetadata } from './parseAstro';
7
+ import type { AstroMetadata } from './parseAstro.js';
8
8
  export declare function addAstroTypes(astroInstall: PackageInfo | undefined, ts: typeof import('typescript'), host: ts.LanguageServiceHost): void;
9
9
  export declare function getAstroLanguagePlugin(): LanguagePlugin<URI, AstroVirtualCode>;
10
10
  export declare class AstroVirtualCode implements VirtualCode {
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.AstroVirtualCode = void 0;
27
37
  exports.addAstroTypes = addAstroTypes;
@@ -29,10 +39,10 @@ exports.getAstroLanguagePlugin = getAstroLanguagePlugin;
29
39
  const path = __importStar(require("node:path"));
30
40
  const language_core_1 = require("@volar/language-core");
31
41
  const utils_js_1 = require("../utils.js");
32
- const astro2tsx_1 = require("./astro2tsx");
33
- const parseAstro_1 = require("./parseAstro");
34
- const parseCSS_1 = require("./parseCSS");
35
- const parseHTML_1 = require("./parseHTML");
42
+ const astro2tsx_js_1 = require("./astro2tsx.js");
43
+ const parseAstro_js_1 = require("./parseAstro.js");
44
+ const parseCSS_js_1 = require("./parseCSS.js");
45
+ const parseHTML_js_1 = require("./parseHTML.js");
36
46
  const parseJS_js_1 = require("./parseJS.js");
37
47
  const decoratedHosts = new WeakSet();
38
48
  function addAstroTypes(astroInstall, ts, host) {
@@ -150,14 +160,14 @@ class AstroVirtualCode {
150
160
  },
151
161
  },
152
162
  ];
153
- const tsx = (0, astro2tsx_1.astro2tsx)(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
154
- const astroMetadata = (0, parseAstro_1.getAstroMetadata)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()));
155
- const { htmlDocument, virtualCode: htmlVirtualCode } = (0, parseHTML_1.parseHTML)(this.snapshot, astroMetadata.frontmatter.status === 'closed'
163
+ const tsx = (0, astro2tsx_js_1.astro2tsx)(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
164
+ const astroMetadata = (0, parseAstro_js_1.getAstroMetadata)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()));
165
+ const { htmlDocument, virtualCode: htmlVirtualCode } = (0, parseHTML_js_1.parseHTML)(this.snapshot, astroMetadata.frontmatter.status === 'closed'
156
166
  ? astroMetadata.frontmatter.position.end.offset
157
167
  : 0);
158
168
  this.htmlDocument = htmlDocument;
159
169
  htmlVirtualCode.embeddedCodes = [
160
- ...(0, parseCSS_1.extractStylesheets)(tsx.ranges.styles),
170
+ ...(0, parseCSS_js_1.extractStylesheets)(tsx.ranges.styles),
161
171
  ...(0, parseJS_js_1.extractScriptTags)(tsx.ranges.scripts),
162
172
  ];
163
173
  this.astroMeta = { ...astroMetadata, tsxRanges: tsx.ranges };
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.parseHTML = parseHTML;
27
37
  exports.preprocessHTML = preprocessHTML;
@@ -35,7 +35,7 @@ function toPascalCase(string) {
35
35
  return `${string}`
36
36
  .replace(new RegExp(/[-_]+/, 'g'), ' ')
37
37
  .replace(new RegExp(/[^\w\s]/, 'g'), '')
38
- .replace(new RegExp(/\s+(.)(\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`)
38
+ .replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`)
39
39
  .replace(new RegExp(/\w/), (s) => s.toUpperCase());
40
40
  }
41
41
  function classNameFromFilename(filename) {
@@ -1,5 +1,5 @@
1
- import { type Connection, type LanguagePlugin } from '@volar/language-server/node';
1
+ import { type Connection, type InitializeParams, type LanguagePlugin } from '@volar/language-server/node';
2
2
  import { URI } from 'vscode-uri';
3
3
  import { type CollectionConfig } from './core/frontmatterHolders.js';
4
4
  export declare function getLanguagePlugins(collectionConfig: CollectionConfig): LanguagePlugin<URI, import("@volar/language-server/node").VirtualCode>[];
5
- export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript'), collectionConfig: CollectionConfig): import("@volar/language-server/node").LanguageServicePlugin<any>[];
5
+ export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript'), collectionConfig: CollectionConfig, initializeParams?: InitializeParams): import("@volar/language-server/node").LanguageServicePlugin<any>[];
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLanguagePlugins = getLanguagePlugins;
4
4
  exports.getLanguageServicePlugins = getLanguageServicePlugins;
5
5
  const node_1 = require("@volar/language-server/node");
6
- const vscode_uri_1 = require("vscode-uri");
7
- const core_1 = require("./core");
8
- const svelte_js_1 = require("./core/svelte.js");
9
- const vue_js_1 = require("./core/vue.js");
10
- const importPackage_js_1 = require("./importPackage.js");
11
6
  // Services
12
7
  const volar_service_css_1 = require("volar-service-css");
13
8
  const volar_service_emmet_1 = require("volar-service-emmet");
14
9
  const volar_service_prettier_1 = require("volar-service-prettier");
15
10
  const volar_service_typescript_twoslash_queries_1 = require("volar-service-typescript-twoslash-queries");
11
+ const vscode_uri_1 = require("vscode-uri");
12
+ const core_1 = require("./core");
16
13
  const frontmatterHolders_js_1 = require("./core/frontmatterHolders.js");
14
+ const svelte_js_1 = require("./core/svelte.js");
15
+ const vue_js_1 = require("./core/vue.js");
16
+ const importPackage_js_1 = require("./importPackage.js");
17
17
  const astro_js_1 = require("./plugins/astro.js");
18
18
  const html_js_1 = require("./plugins/html.js");
19
- const index_js_1 = require("./plugins/typescript-addons/index.js");
20
- const index_js_2 = require("./plugins/typescript/index.js");
19
+ const index_js_1 = require("./plugins/typescript/index.js");
20
+ const index_js_2 = require("./plugins/typescript-addons/index.js");
21
21
  const yaml_js_1 = require("./plugins/yaml.js");
22
22
  function getLanguagePlugins(collectionConfig) {
23
23
  const languagePlugins = [
@@ -28,14 +28,16 @@ function getLanguagePlugins(collectionConfig) {
28
28
  ];
29
29
  return languagePlugins;
30
30
  }
31
- function getLanguageServicePlugins(connection, ts, collectionConfig) {
31
+ function getLanguageServicePlugins(connection, ts, collectionConfig, initializeParams) {
32
32
  const LanguageServicePlugins = [
33
33
  (0, html_js_1.create)(),
34
34
  (0, volar_service_css_1.create)(),
35
35
  (0, volar_service_emmet_1.create)(),
36
- ...(0, index_js_2.create)(ts),
36
+ ...(0, index_js_1.create)(ts, {
37
+ disableAutoImportCache: initializeParams?.initializationOptions?.disableAutoImportCache,
38
+ }),
37
39
  (0, volar_service_typescript_twoslash_queries_1.create)(ts),
38
- (0, index_js_1.create)(),
40
+ (0, index_js_2.create)(),
39
41
  (0, astro_js_1.create)(ts),
40
42
  getPrettierService(),
41
43
  (0, yaml_js_1.create)(collectionConfig),
@@ -24,6 +24,7 @@ connection.onInitialize((params) => {
24
24
  configs: contentIntellisenseEnabled
25
25
  ? loadCollectionConfig(
26
26
  // The vast majority of clients support workspaceFolders, but sometimes some unusual environments like tests don't
27
+ // @ts-expect-error - Just deprecated types, it's fine
27
28
  params.workspaceFolders ?? (params.rootUri ? [{ uri: params.rootUri }] : []) ?? [])
28
29
  : [],
29
30
  };
@@ -69,7 +70,7 @@ connection.onInitialize((params) => {
69
70
  (0, index_js_1.addAstroTypes)(typeof astroInstall === 'string' ? undefined : astroInstall, typescript, languageServiceHost);
70
71
  },
71
72
  };
72
- }), (0, languageServerPlugin_js_1.getLanguageServicePlugins)(connection, typescript, collectionConfig));
73
+ }), (0, languageServerPlugin_js_1.getLanguageServicePlugins)(connection, typescript, collectionConfig, params));
73
74
  });
74
75
  connection.onInitialized(() => {
75
76
  server.initialized();
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.create = void 0;
27
37
  const language_server_1 = require("@volar/language-server");
@@ -9,4 +9,4 @@ export declare enum DiagnosticCodes {
9
9
  JSX_NO_CLOSING_TAG = 17008,// JSX element '{0}' has no corresponding closing tag.
10
10
  JSX_ELEMENT_NO_CALL = 2604
11
11
  }
12
- export declare function enhancedProvideSemanticDiagnostics(originalDiagnostics: Diagnostic[], tsxLineCount?: number | undefined): Diagnostic[];
12
+ export declare function enhancedProvideSemanticDiagnostics(originalDiagnostics: Diagnostic[], tsxLineCount?: number): Diagnostic[];
@@ -1,2 +1,4 @@
1
1
  import type { LanguageServicePlugin } from '@volar/language-server';
2
- export declare const create: (ts: typeof import("typescript")) => LanguageServicePlugin[];
2
+ export declare const create: (ts: typeof import("typescript"), options?: {
3
+ disableAutoImportCache: boolean | undefined;
4
+ }) => LanguageServicePlugin[];
@@ -7,8 +7,10 @@ const index_js_1 = require("../../core/index.js");
7
7
  const codeActions_js_1 = require("./codeActions.js");
8
8
  const completions_js_1 = require("./completions.js");
9
9
  const diagnostics_js_1 = require("./diagnostics.js");
10
- const create = (ts) => {
11
- const tsServicePlugins = (0, volar_service_typescript_1.create)(ts, {});
10
+ const create = (ts, options) => {
11
+ const tsServicePlugins = (0, volar_service_typescript_1.create)(ts, {
12
+ disableAutoImportCache: options?.disableAutoImportCache,
13
+ });
12
14
  return tsServicePlugins.map((plugin) => {
13
15
  if (plugin.name === 'typescript-semantic') {
14
16
  return {
@@ -57,7 +57,7 @@ function getSnippetCompletions(frontmatter) {
57
57
  '[Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#configuring-individual-routes)',
58
58
  ].join('\n'),
59
59
  },
60
- insertText: 'export const prerender = ${1|true,false,import.meta.env.|}',
60
+ insertText: 'export const prerender = ${1|true,false|}',
61
61
  insertTextFormat: 2,
62
62
  },
63
63
  ];
@@ -100,6 +100,7 @@ const create = (collectionConfig) => {
100
100
  // Remove last line that contains the source schema, it's not useful to users since they're generated
101
101
  originalHover.contents.value = originalHover.contents.value
102
102
  .replace(/\nSource:.*$/, '')
103
+ .replace(/\n\nsource$/, '')
103
104
  .trim();
104
105
  }
105
106
  return originalHover;
package/dist/utils.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.getLanguageServerTypesDir = getLanguageServerTypesDir;
27
37
  exports.getAstroInstall = getAstroInstall;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.15.4",
3
+ "version": "2.16.0",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/withastro/language-tools",
9
- "directory": "packages/language-server"
8
+ "url": "https://github.com/withastro/astro.git",
9
+ "directory": "packages/language-tools/language-server"
10
10
  },
11
11
  "type": "commonjs",
12
12
  "main": "dist/index.js",
@@ -23,38 +23,31 @@
23
23
  "@astrojs/compiler": "^2.10.3",
24
24
  "@astrojs/yaml2ts": "^0.2.2",
25
25
  "@jridgewell/sourcemap-codec": "^1.4.15",
26
- "@volar/kit": "~2.4.7",
27
- "@volar/language-core": "~2.4.7",
28
- "@volar/language-server": "~2.4.7",
29
- "@volar/language-service": "~2.4.7",
26
+ "@volar/kit": "~2.4.23",
27
+ "@volar/language-core": "~2.4.23",
28
+ "@volar/language-server": "~2.4.23",
29
+ "@volar/language-service": "~2.4.23",
30
30
  "fast-glob": "^3.2.12",
31
31
  "muggle-string": "^0.4.1",
32
- "volar-service-css": "0.0.62",
33
- "volar-service-emmet": "0.0.62",
34
- "volar-service-html": "0.0.62",
35
- "volar-service-prettier": "0.0.62",
36
- "volar-service-typescript": "0.0.62",
37
- "volar-service-typescript-twoslash-queries": "0.0.62",
38
- "volar-service-yaml": "0.0.62",
39
- "vscode-html-languageservice": "^5.2.0",
40
- "vscode-uri": "^3.0.8"
32
+ "volar-service-css": "0.0.66",
33
+ "volar-service-emmet": "0.0.66",
34
+ "volar-service-html": "0.0.66",
35
+ "volar-service-prettier": "0.0.66",
36
+ "volar-service-typescript": "0.0.66",
37
+ "volar-service-typescript-twoslash-queries": "0.0.66",
38
+ "volar-service-yaml": "0.0.66",
39
+ "vscode-html-languageservice": "^5.5.2",
40
+ "vscode-uri": "^3.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@astrojs/svelte": "^5.0.3",
44
- "@astrojs/vue": "^4.0.8",
45
- "@types/chai": "^4.3.5",
46
- "@types/mocha": "^10.0.1",
47
- "@types/node": "^18.17.8",
48
- "@volar/test-utils": "~2.4.7",
49
- "@volar/typescript": "~2.4.7",
50
- "astro": "^4.14.0",
51
- "chai": "^4.3.7",
52
- "mocha": "^10.2.0",
53
- "svelte": "^4.2.10",
54
- "tsx": "^3.12.7",
55
- "typescript": "^5.5.4",
43
+ "@types/node": "^20.9.0",
44
+ "@volar/test-utils": "~2.4.23",
45
+ "@volar/typescript": "~2.4.23",
46
+ "tsx": "^4.20.6",
47
+ "typescript": "^5.9.3",
56
48
  "vscode-languageserver-protocol": "^3.17.5",
57
- "vscode-languageserver-textdocument": "^1.0.11"
49
+ "vscode-languageserver-textdocument": "^1.0.11",
50
+ "astro-scripts": "0.0.14"
58
51
  },
59
52
  "peerDependencies": {
60
53
  "prettier": "^3.0.0",
@@ -72,7 +65,7 @@
72
65
  "build": "tsc",
73
66
  "dev": "tsc --watch",
74
67
  "sync-fixture": "pnpm --dir ./test/fixture sync",
75
- "test": "pnpm run sync-fixture && mocha --timeout 10000 --require tsx --require test/takedown.ts test/misc/init.test.ts test/**/*.test.ts",
76
- "test:match": "pnpm run test -g"
68
+ "test": "pnpm sync-fixture && astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true",
69
+ "test:match": "pnpm run test --match"
77
70
  }
78
71
  }