@vue/typescript-plugin
Advanced tools
Comparing version 2.0.29 to 2.1.0
@@ -1,2 +0,3 @@ | ||
declare const plugin: import("typescript").server.PluginModuleFactory; | ||
import type * as ts from 'typescript'; | ||
declare const plugin: ts.server.PluginModuleFactory; | ||
export = plugin; |
28
index.js
@@ -7,7 +7,7 @@ "use strict"; | ||
const windowsPathReg = /\\/g; | ||
const plugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)((ts, info) => { | ||
const vueCompilerOptions = new WeakMap(); | ||
const basePlugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)((ts, info) => { | ||
const vueOptions = getVueCompilerOptions(); | ||
const languagePlugin = vue.createVueLanguagePlugin2(ts, id => id, info.project.projectKind === ts.server.ProjectKind.Inferred | ||
? () => true | ||
: vue.createRootFileChecker(info.languageServiceHost.getProjectVersion ? () => info.languageServiceHost.getProjectVersion() : undefined, () => createLanguageServicePlugin_1.externalFiles.get(info.project) ?? [], info.languageServiceHost.useCaseSensitiveFileNames?.() ?? false), info.languageServiceHost.getCompilationSettings(), vueOptions); | ||
const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(), vueOptions, id => id); | ||
vueCompilerOptions.set(info.project, vueOptions); | ||
return { | ||
@@ -40,3 +40,23 @@ languagePlugins: [languagePlugin], | ||
}); | ||
const plugin = mods => { | ||
const pluginModule = basePlugin(mods); | ||
return { | ||
...pluginModule, | ||
getExternalFiles(proj, updateLevel = 0) { | ||
const options = vueCompilerOptions.get(proj); | ||
if (updateLevel >= 1 && options) { | ||
try { | ||
const libDir = require.resolve(`${options.lib}/package.json`, { paths: [proj.getCurrentDirectory()] }) | ||
.slice(0, -'package.json'.length); | ||
const globalTypesPath = `${libDir}__globalTypes_${options.target}_${options.strictTemplates}.d.ts`; | ||
const globalTypesContents = vue.generateGlobalTypes(options.lib, options.target, options.strictTemplates); | ||
proj.writeFile(globalTypesPath, globalTypesContents); | ||
} | ||
catch { } | ||
} | ||
return pluginModule.getExternalFiles?.(proj, updateLevel) ?? []; | ||
}, | ||
}; | ||
}; | ||
module.exports = plugin; | ||
//# sourceMappingURL=index.js.map |
@@ -12,6 +12,3 @@ "use strict"; | ||
const result = new Map(); | ||
const program = languageService.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
const program = languageService.getProgram(); | ||
const sourceFile = program.getSourceFile(fileName); | ||
@@ -18,0 +15,0 @@ const checker = program.getTypeChecker(); |
@@ -18,6 +18,3 @@ "use strict"; | ||
const vueCode = volarFile.generated.root; | ||
const program = languageService.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
const program = languageService.getProgram(); | ||
const checker = program.getTypeChecker(); | ||
@@ -85,6 +82,3 @@ const components = getVariableType(ts, languageService, vueCode, '__VLS_components'); | ||
const vueCode = volarFile.generated.root; | ||
const program = languageService.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
const program = languageService.getProgram(); | ||
const checker = program.getTypeChecker(); | ||
@@ -179,6 +173,3 @@ const components = getVariableType(ts, languageService, vueCode, '__VLS_components'); | ||
} | ||
const program = languageService.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
const program = languageService.getProgram(); | ||
let tsSourceFile; | ||
@@ -199,7 +190,4 @@ if (tsSourceFile = program.getSourceFile(fileName)) { | ||
} | ||
function getVariableType(ts, tsLs, vueCode, name) { | ||
const program = tsLs.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
function getVariableType(ts, languageService, vueCode, name) { | ||
const program = languageService.getProgram(); | ||
let tsSourceFile; | ||
@@ -206,0 +194,0 @@ if (tsSourceFile = program.getSourceFile(vueCode.fileName)) { |
@@ -34,6 +34,3 @@ "use strict"; | ||
} | ||
const program = languageService.getCurrentProgram(); | ||
if (!program) { | ||
return; | ||
} | ||
const program = languageService.getProgram(); | ||
const sourceFile = program.getSourceFile(fileName); | ||
@@ -40,0 +37,0 @@ if (!sourceFile) { |
@@ -22,6 +22,14 @@ "use strict"; | ||
const fileName = request.args[0]; | ||
const requestContext = { | ||
typescript: ts, | ||
languageService: info.languageService, | ||
languageServiceHost: info.languageServiceHost, | ||
language: language, | ||
isTsPlugin: true, | ||
getFileId: (fileName) => fileName, | ||
}; | ||
if (request.type === 'containsFile') { | ||
sendResponse(info.project.containsFile(ts.server.toNormalizedPath(fileName))); | ||
} | ||
if (request.type === 'projectInfo') { | ||
else if (request.type === 'projectInfo') { | ||
sendResponse({ | ||
@@ -33,11 +41,3 @@ name: info.project.getProjectName(), | ||
} | ||
const requestContext = { | ||
typescript: ts, | ||
languageService: info.languageService, | ||
languageServiceHost: info.languageServiceHost, | ||
language: language, | ||
isTsPlugin: true, | ||
getFileId: (fileName) => fileName, | ||
}; | ||
if (request.type === 'collectExtractProps') { | ||
else if (request.type === 'collectExtractProps') { | ||
const result = collectExtractProps_1.collectExtractProps.apply(requestContext, request.args); | ||
@@ -44,0 +44,0 @@ sendResponse(result); |
{ | ||
"name": "@vue/typescript-plugin", | ||
"version": "2.0.29", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -15,4 +15,4 @@ "files": [ | ||
"dependencies": { | ||
"@volar/typescript": "~2.4.0-alpha.18", | ||
"@vue/language-core": "2.0.29", | ||
"@volar/typescript": "~2.4.1", | ||
"@vue/language-core": "2.1.0", | ||
"@vue/shared": "^3.4.0" | ||
@@ -23,3 +23,3 @@ }, | ||
}, | ||
"gitHead": "49ad9563e6f2677595878a000179dfea83fb910c" | ||
"gitHead": "510063740b90b64caedaee1f0bde70974613a92c" | ||
} |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
53272
1157
3
+ Added@vue/language-core@2.1.0(transitive)
- Removed@vue/language-core@2.0.29(transitive)
Updated@volar/typescript@~2.4.1
Updated@vue/language-core@2.1.0