@astrojs/ts-plugin
Advanced tools
Comparing version 1.3.0 to 1.3.1
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
const language_core_1 = require("@volar/language-core"); | ||
const typescript_1 = require("@volar/typescript"); | ||
const semver = __importStar(require("semver")); | ||
const language_js_1 = require("./language.js"); | ||
@@ -13,18 +37,29 @@ const externalFiles = new WeakMap(); | ||
(0, typescript_1.decorateLanguageServiceHost)(virtualFiles, info.languageServiceHost, ts, ['.astro']); | ||
// HACK: AutoImportProviderProject's script kind does not match the one of the language service host here | ||
// this causes TypeScript to throw and crash. So, we'll fake being a TS file here for now until they fix it | ||
const getScriptKind = info.languageServiceHost.getScriptKind?.bind(info.languageServiceHost.getScriptKind); | ||
if (getScriptKind) { | ||
info.languageServiceHost.getScriptKind = (fileName) => { | ||
if (fileName.endsWith('.astro')) { | ||
return ts.ScriptKind.TS; | ||
} | ||
return getScriptKind(fileName); | ||
}; | ||
if (semver.lt(ts.version, '5.3.0')) { | ||
// HACK: AutoImportProviderProject's script kind does not match the one of the language service host here | ||
// this causes TypeScript to throw and crash. So, we'll fake being a TS file here for now until they fix it | ||
// Fixed by https://github.com/microsoft/TypeScript/pull/55716 | ||
const getScriptKind = info.languageServiceHost.getScriptKind?.bind(info.languageServiceHost.getScriptKind); | ||
if (getScriptKind) { | ||
info.languageServiceHost.getScriptKind = (fileName) => { | ||
if (fileName.endsWith('.astro')) { | ||
return ts.ScriptKind.TS; | ||
} | ||
return getScriptKind(fileName); | ||
}; | ||
} | ||
} | ||
return info.languageService; | ||
}, | ||
getExternalFiles(project) { | ||
if (!externalFiles.has(project)) { | ||
externalFiles.set(project, (0, typescript_1.getExternalFiles)(ts, project, ['.astro'])); | ||
getExternalFiles(project, updateLevel = 0) { | ||
if ( | ||
// @ts-expect-error wait for TS 5.3 | ||
updateLevel >= (1) || | ||
!externalFiles.has(project)) { | ||
const oldFiles = externalFiles.get(project); | ||
const newFiles = (0, typescript_1.searchExternalFiles)(ts, project, ['.astro']); | ||
externalFiles.set(project, newFiles); | ||
if (oldFiles && !arrayItemsEqual(oldFiles, newFiles)) { | ||
project.refreshDiagnostics(); | ||
} | ||
} | ||
@@ -36,2 +71,14 @@ return externalFiles.get(project); | ||
}; | ||
function arrayItemsEqual(a, b) { | ||
if (a.length !== b.length) { | ||
return false; | ||
} | ||
const set = new Set(a); | ||
for (const file of b) { | ||
if (!set.has(file)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
module.exports = init; |
{ | ||
"name": "@astrojs/ts-plugin", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A TypeScript Plugin providing Astro intellisense", | ||
@@ -25,6 +25,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@volar/language-core": "~1.10.3", | ||
"@volar/typescript": "~1.10.3", | ||
"@astrojs/compiler": "^2.2.1", | ||
"@volar/language-core": "~1.10.9", | ||
"@volar/typescript": "~1.10.9", | ||
"@astrojs/compiler": "^2.2.2", | ||
"@jridgewell/sourcemap-codec": "^1.4.15", | ||
"semver": "^7.3.8", | ||
"vscode-languageserver-textdocument": "^1.0.11" | ||
@@ -35,7 +36,7 @@ }, | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^16.18.26", | ||
"@types/node": "^18.17.8", | ||
"@types/semver": "^7.3.13", | ||
"chai": "^4.3.7", | ||
"glob": "^8.0.3", | ||
"mocha": "^10.2.0", | ||
"typescript": "~5.1.3" | ||
"mocha": "^10.2.0" | ||
}, | ||
@@ -42,0 +43,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16961
306
6
+ Addedsemver@^7.3.8
+ Addedsemver@7.6.3(transitive)
Updated@astrojs/compiler@^2.2.2
Updated@volar/language-core@~1.10.9
Updated@volar/typescript@~1.10.9