@astrojs/language-server 2.6.0 → 2.6.2

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,7 +2,7 @@ import type { DiagnosticMessage } from '@astrojs/compiler/types';
2
2
  import { FileCapabilities, FileKind, type Language, type VirtualFile } from '@volar/language-core';
3
3
  import type ts from 'typescript/lib/tsserverlibrary';
4
4
  import type { HTMLDocument } from 'vscode-html-languageservice';
5
- import type { AstroInstall } from '../utils.js';
5
+ import { type AstroInstall } from '../utils.js';
6
6
  import { AstroMetadata } from './parseAstro';
7
7
  export declare function getLanguageModule(astroInstall: AstroInstall | undefined, ts: typeof import('typescript/lib/tsserverlibrary.js')): Language<AstroFile>;
8
8
  export declare class AstroFile implements VirtualFile {
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.AstroFile = exports.getLanguageModule = void 0;
27
27
  const language_core_1 = require("@volar/language-core");
28
28
  const path = __importStar(require("node:path"));
29
+ const utils_js_1 = require("../utils.js");
29
30
  const astro2tsx_1 = require("./astro2tsx");
30
31
  const parseAstro_1 = require("./parseAstro");
31
32
  const parseCSS_1 = require("./parseCSS");
@@ -54,32 +55,25 @@ function getLanguageModule(astroInstall, ts) {
54
55
  return host.resolveModuleName?.(moduleName, impliedNodeFormat) ?? moduleName;
55
56
  },
56
57
  getScriptFileNames() {
57
- let languageServerDirectory;
58
- try {
59
- languageServerDirectory = path.dirname(require.resolve('@astrojs/language-server'));
60
- }
61
- catch (e) {
62
- languageServerDirectory = __dirname;
63
- }
58
+ const languageServerTypesDirectory = (0, utils_js_1.getLanguageServerTypesDir)(ts);
64
59
  const fileNames = host.getScriptFileNames();
65
60
  const addedFileNames = [];
66
61
  if (astroInstall) {
67
62
  addedFileNames.push(...['./env.d.ts', './astro-jsx.d.ts'].map((filePath) => ts.sys.resolvePath(path.resolve(astroInstall.path, filePath))));
68
63
  // If Astro version is < 4.0.8, add jsx-runtime-augment.d.ts to the files to fake `JSX` being available from "astro/jsx-runtime".
69
64
  // TODO: Remove this once a majority of users are on Astro 4.0.8+, erika - 2023-12-28
70
- if (astroInstall.version.major >= 4 &&
71
- (astroInstall.version.minor > 0 || astroInstall.version.patch >= 8)) {
72
- addedFileNames.push(...['../jsx-runtime-augment.d.ts'].map((filePath) => ts.sys.resolvePath(path.resolve(languageServerDirectory, filePath))));
65
+ if (astroInstall.version.major < 4 ||
66
+ (astroInstall.version.major === 4 &&
67
+ astroInstall.version.minor === 0 &&
68
+ astroInstall.version.patch < 8)) {
69
+ addedFileNames.push(...['./jsx-runtime-augment.d.ts'].map((filePath) => ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, filePath))));
70
+ console.log(addedFileNames);
73
71
  }
74
72
  }
75
73
  else {
76
74
  // If we don't have an Astro installation, add the fallback types from the language server.
77
75
  // See the README in packages/language-server/types for more information.
78
- addedFileNames.push(...[
79
- '../types/env.d.ts',
80
- '../types/astro-jsx.d.ts',
81
- '../types/jsx-runtime-fallback.d.ts',
82
- ].map((f) => ts.sys.resolvePath(path.resolve(languageServerDirectory, f))));
76
+ addedFileNames.push(...['./env.d.ts', './astro-jsx.d.ts', './jsx-runtime-fallback.d.ts'].map((f) => ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, f))));
83
77
  }
84
78
  return [...fileNames, ...addedFileNames];
85
79
  },
package/dist/utils.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface AstroInstall {
7
7
  patch: number;
8
8
  };
9
9
  }
10
+ export declare function getLanguageServerTypesDir(ts: typeof import('typescript')): string;
10
11
  export declare function getAstroInstall(basePaths: string[], checkForAstro?: {
11
12
  nearestPackageJson: string | undefined;
12
13
  readDirectory: typeof import('typescript/lib/tsserverlibrary.js').sys.readDirectory;
package/dist/utils.js CHANGED
@@ -23,9 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getAstroInstall = void 0;
26
+ exports.getAstroInstall = exports.getLanguageServerTypesDir = void 0;
27
27
  const path = __importStar(require("node:path"));
28
28
  const importPackage_js_1 = require("./importPackage.js");
29
+ function getLanguageServerTypesDir(ts) {
30
+ return ts.sys.resolvePath(path.resolve(__dirname, '../types'));
31
+ }
32
+ exports.getLanguageServerTypesDir = getLanguageServerTypesDir;
29
33
  function getAstroInstall(basePaths, checkForAstro) {
30
34
  let astroPath;
31
35
  let version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {