Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vue/typescript-plugin

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/typescript-plugin - npm Package Compare versions

Comparing version 2.0.23-alpha.1 to 2.0.24

2

index.js

@@ -22,3 +22,3 @@ "use strict";

server_1.projects.set(info.project, { info, language, vueOptions });
(0, common_1.decorateLanguageServiceForVue)(language, info.languageService, vueOptions, ts, true, fileName => fileName);
info.languageService = (0, common_1.proxyLanguageServiceForVue)(ts, language, info.languageService, vueOptions, fileName => fileName);
(0, server_1.startNamedPipeServer)(ts, info.project.projectKind, info.project.getCurrentDirectory());

@@ -25,0 +25,0 @@ // #3963

@@ -1,5 +0,5 @@

import * as vue from '@vue/language-core';
import { Language, VueCompilerOptions, VueVirtualCode } from '@vue/language-core';
import type * as ts from 'typescript';
import type { RequestContext } from './requests/types';
export declare function decorateLanguageServiceForVue<T>(language: vue.Language<T>, languageService: ts.LanguageService, vueOptions: vue.VueCompilerOptions, ts: typeof import('typescript'), isTsPlugin: boolean, getScriptId: (fileName: string) => T): void;
export declare function getComponentSpans(this: Pick<RequestContext, 'typescript' | 'languageService'>, vueCode: vue.VueVirtualCode, template: NonNullable<vue.VueVirtualCode['sfc']['template']>, spanTemplateRange: ts.TextSpan): ts.TextSpan[];
export declare function proxyLanguageServiceForVue<T>(ts: typeof import('typescript'), language: Language<T>, languageService: ts.LanguageService, vueOptions: VueCompilerOptions, asScriptId: (fileName: string) => T): ts.LanguageService;
export declare function getComponentSpans(this: Pick<RequestContext, 'typescript' | 'languageService'>, vueCode: VueVirtualCode, template: NonNullable<VueVirtualCode['sfc']['template']>, spanTemplateRange: ts.TextSpan): ts.TextSpan[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decorateLanguageServiceForVue = decorateLanguageServiceForVue;
exports.proxyLanguageServiceForVue = proxyLanguageServiceForVue;
exports.getComponentSpans = getComponentSpans;
const vue = require("@vue/language-core");
const language_core_1 = require("@vue/language-core");
const shared_1 = require("@vue/shared");
const componentInfos_1 = require("./requests/componentInfos");
function decorateLanguageServiceForVue(language, languageService, vueOptions, ts, isTsPlugin, getScriptId) {
const { getCompletionsAtPosition, getCompletionEntryDetails, getCodeFixesAtPosition, getEncodedSemanticClassifications, getQuickInfoAtPosition, } = languageService;
languageService.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {
const windowsPathReg = /\\/g;
function proxyLanguageServiceForVue(ts, language, languageService, vueOptions, asScriptId) {
const proxyCache = new Map();
const getProxyMethod = (target, p) => {
switch (p) {
case 'getCompletionsAtPosition': return getCompletionsAtPosition(vueOptions, target[p]);
case 'getCompletionEntryDetails': return getCompletionEntryDetails(language, asScriptId, target[p]);
case 'getCodeFixesAtPosition': return getCodeFixesAtPosition(target[p]);
case 'getQuickInfoAtPosition': return getQuickInfoAtPosition(ts, target, target[p]);
// TS plugin only
case 'getEncodedSemanticClassifications': return getEncodedSemanticClassifications(ts, language, target, asScriptId, target[p]);
}
};
return new Proxy(languageService, {
get(target, p, receiver) {
if (getProxyMethod) {
if (!proxyCache.has(p)) {
proxyCache.set(p, getProxyMethod(target, p));
}
const proxyMethod = proxyCache.get(p);
if (proxyMethod) {
return proxyMethod;
}
}
return Reflect.get(target, p, receiver);
},
set(target, p, value, receiver) {
return Reflect.set(target, p, value, receiver);
},
});
}
function getCompletionsAtPosition(vueOptions, getCompletionsAtPosition) {
return (filePath, position, options, formattingSettings) => {
const fileName = filePath.replace(windowsPathReg, '/');
const result = getCompletionsAtPosition(fileName, position, options, formattingSettings);

@@ -51,3 +82,5 @@ if (result) {

};
languageService.getCompletionEntryDetails = (...args) => {
}
function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetails) {
return (...args) => {
const details = getCompletionEntryDetails(...args);

@@ -71,4 +104,4 @@ // modify import statement

const { fileName } = args[6]?.__isAutoImport;
const sourceScript = language.scripts.get(getScriptId(fileName));
if (sourceScript?.generated?.root instanceof vue.VueVirtualCode) {
const sourceScript = language.scripts.get(asScriptId(fileName));
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
const sfc = sourceScript.generated.root.getVueSfc();

@@ -91,3 +124,5 @@ if (!sfc?.descriptor.script && !sfc?.descriptor.scriptSetup) {

};
languageService.getCodeFixesAtPosition = (...args) => {
}
function getCodeFixesAtPosition(getCodeFixesAtPosition) {
return (...args) => {
let result = getCodeFixesAtPosition(...args);

@@ -98,3 +133,5 @@ // filter __VLS_

};
languageService.getQuickInfoAtPosition = (...args) => {
}
function getQuickInfoAtPosition(ts, languageService, getQuickInfoAtPosition) {
return (...args) => {
const result = getQuickInfoAtPosition(...args);

@@ -135,21 +172,22 @@ if (result && result.documentation?.length === 1 && result.documentation[0].text.startsWith('__VLS_emit,')) {

};
if (isTsPlugin) {
languageService.getEncodedSemanticClassifications = (fileName, span, format) => {
const result = getEncodedSemanticClassifications(fileName, span, format);
const file = language.scripts.get(getScriptId(fileName));
if (file?.generated?.root instanceof vue.VueVirtualCode) {
const { template } = file.generated.root.sfc;
if (template) {
for (const componentSpan of getComponentSpans.call({ typescript: ts, languageService }, file.generated.root, template, {
start: span.start - template.startTagEnd,
length: span.length,
})) {
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256 // class
);
}
}
function getEncodedSemanticClassifications(ts, language, languageService, asScriptId, getEncodedSemanticClassifications) {
return (filePath, span, format) => {
const fileName = filePath.replace(windowsPathReg, '/');
const result = getEncodedSemanticClassifications(fileName, span, format);
const file = language.scripts.get(asScriptId(fileName));
if (file?.generated?.root instanceof language_core_1.VueVirtualCode) {
const { template } = file.generated.root.sfc;
if (template) {
for (const componentSpan of getComponentSpans.call({ typescript: ts, languageService }, file.generated.root, template, {
start: span.start - template.startTagEnd,
length: span.length,
})) {
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256 // class
);
}
}
return result;
};
}
}
return result;
};
}

@@ -162,6 +200,6 @@ function getComponentSpans(vueCode, template, spanTemplateRange) {

...validComponentNames,
...validComponentNames.map(vue.hyphenateTag),
...validComponentNames.map(language_core_1.hyphenateTag),
]);
if (template.ast) {
for (const node of vue.forEachElementNode(template.ast)) {
for (const node of (0, language_core_1.forEachElementNode)(template.ast)) {
if (node.loc.end.offset <= spanTemplateRange.start || node.loc.start.offset >= (spanTemplateRange.start + spanTemplateRange.length)) {

@@ -168,0 +206,0 @@ continue;

{
"name": "@vue/typescript-plugin",
"version": "2.0.23-alpha.1",
"version": "2.0.24",
"license": "MIT",

@@ -15,4 +15,4 @@ "files": [

"dependencies": {
"@volar/typescript": "~2.4.0-alpha.0",
"@vue/language-core": "2.0.23-alpha.1",
"@volar/typescript": "~2.4.0-alpha.2",
"@vue/language-core": "2.0.24",
"@vue/shared": "^3.4.0"

@@ -23,3 +23,3 @@ },

},
"gitHead": "70cb34e9d58afd603d50cb5b870116b189f4662b"
"gitHead": "bca79db09e413ef29c17b910271c123a7a68806f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc