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

@vue/language-service

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/language-service - npm Package Compare versions

Comparing version 2.0.14 to 2.0.15

2

data/language-blocks/zh-cn.json

@@ -691,3 +691,3 @@ {

"kind": "markdown",
"value": "\n一个 `<style module>` 标签会被编译为 [CSS Modules](https://github.com/css-modules/css-modules) 并且将生成的 CSS class 作为 `$style` 对象暴露给组件:\n\n```vue\n<template>\n <p :class=\"$style.red\">This should be red</p>\n</template>\n\n<style module>\n.red {\n color: red;\n}\n</style>\n```\n\n得出的 class 将被哈希化以避免冲突,实现了同样的将 CSS 仅作用于当前组件的效果。\n\n参考 [CSS Modules spec](https://github.com/css-modules/css-modules) 以查看更多详情,例如 [global exceptions](https://github.com/css-modules/css-modules#exceptions) 和 [composition](https://github.com/css-modules/css-modules#composition)。\n\n### 自定义注入名称 \n\n你可以通过给 `module` attribute 一个值来自定义注入 class 对象的属性名:\n\n```vue\n<template>\n <p :class=\"classes.red\">red</p>\n</template>\n\n<style module=\"classes\">\n.red {\n color: red;\n}\n</style>\n```\n\n### 与组合式 API 一同使用 \n\n可以通过 `useCssModule` API 在 `setup()` 和 `<script setup>` 中访问注入的 class。对于使用了自定义注入名称的 `<style module>` 块,`useCssModule` 接收一个匹配的 `module` attribute 值作为第一个参数:\n\n```js\nimport { useCssModule } from 'vue'\n\n// 在 setup() 作用域中...\n// 默认情况下, 返回 <style module> 的 class\nuseCssModule()\n\n// 具名情况下, 返回 <style module=\"classes\"> 的 class\nuseCssModule('classes')\n```\n"
"value": "\n一个 `<style module>` 标签会被编译为 [CSS Modules](https://github.com/css-modules/css-modules) 并且将生成的 CSS class 作为 `$style` 对象暴露给组件:\n\n```vue\n<template>\n <p :class=\"$style.red\">This should be red</p>\n</template>\n\n<style module>\n.red {\n color: red;\n}\n</style>\n```\n\n得出的 class 将被哈希化以避免冲突,实现了同样的将 CSS 仅作用于当前组件的效果。\n\n参考 [CSS Modules spec](https://github.com/css-modules/css-modules) 以查看更多详情,例如 [global exceptions](https://github.com/css-modules/css-modules/blob/master/docs/composition.md#exceptions) 和 [composition](https://github.com/css-modules/css-modules/blob/master/docs/composition.md#composition)。\n\n### 自定义注入名称 \n\n你可以通过给 `module` attribute 一个值来自定义注入 class 对象的属性名:\n\n```vue\n<template>\n <p :class=\"classes.red\">red</p>\n</template>\n\n<style module=\"classes\">\n.red {\n color: red;\n}\n</style>\n```\n\n### 与组合式 API 一同使用 \n\n可以通过 `useCssModule` API 在 `setup()` 和 `<script setup>` 中访问注入的 class。对于使用了自定义注入名称的 `<style module>` 块,`useCssModule` 接收一个匹配的 `module` attribute 值作为第一个参数:\n\n```js\nimport { useCssModule } from 'vue'\n\n// 在 setup() 作用域中...\n// 默认情况下, 返回 <style module> 的 class\nuseCssModule()\n\n// 具名情况下, 返回 <style module=\"classes\"> 的 class\nuseCssModule('classes')\n```\n"
},

@@ -694,0 +694,0 @@ "references": [

@@ -7,3 +7,3 @@ export * from '@volar/language-service';

import type { VueCompilerOptions } from './lib/types';
export declare function createVueServicePlugins(ts: typeof import('typescript'), getVueOptions: (env: ServiceEnvironment) => VueCompilerOptions, getTsPluginClient?: (context: ServiceContext) => typeof import("@vue/typescript-plugin/lib/client") | undefined, hybridMode?: boolean): LanguageServicePlugin[];
export declare function getVueLanguageServicePlugins(ts: typeof import('typescript'), getVueOptions: (env: ServiceEnvironment) => VueCompilerOptions, getTsPluginClient?: (context: ServiceContext) => typeof import("@vue/typescript-plugin/lib/client") | undefined, hybridMode?: boolean): LanguageServicePlugin[];
export declare function createDefaultGetTsPluginClient(ts: typeof import('typescript'), getVueOptions: (env: ServiceEnvironment) => VueCompilerOptions): (context: ServiceContext) => typeof import('@vue/typescript-plugin/lib/client') | undefined;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.createDefaultGetTsPluginClient = exports.createVueServicePlugins = void 0;
exports.createDefaultGetTsPluginClient = exports.getVueLanguageServicePlugins = void 0;
__exportStar(require("@volar/language-service"), exports);

@@ -49,3 +49,3 @@ __exportStar(require("@vue/language-core"), exports);

const getQuickInfoAtPosition_1 = require("@vue/typescript-plugin/lib/requests/getQuickInfoAtPosition");
function createVueServicePlugins(ts, getVueOptions, getTsPluginClient = createDefaultGetTsPluginClient(ts, getVueOptions), hybridMode = false) {
function getVueLanguageServicePlugins(ts, getVueOptions, getTsPluginClient = createDefaultGetTsPluginClient(ts, getVueOptions), hybridMode = false) {
const plugins = [];

@@ -80,3 +80,3 @@ if (!hybridMode) {

}
exports.createVueServicePlugins = createVueServicePlugins;
exports.getVueLanguageServicePlugins = getVueLanguageServicePlugins;
function createDefaultGetTsPluginClient(ts, getVueOptions) {

@@ -83,0 +83,0 @@ return context => {

@@ -6,9 +6,9 @@ import type { ServiceContext } from '@volar/language-service';

export declare function convertAttrName(context: ServiceContext, uri: string, casing: AttrNameCasing, tsPluginClient?: typeof import('@vue/typescript-plugin/lib/client')): Promise<vscode.TextEdit[] | undefined>;
export declare function getNameCasing(context: ServiceContext, uri: string, tsPluginClient?: typeof import('@vue/typescript-plugin/lib/client')): Promise<{
export declare function getNameCasing(context: ServiceContext, uri: string): Promise<{
tag: TagNameCasing;
attr: AttrNameCasing;
}>;
export declare function detect(context: ServiceContext, uri: string, tsPluginClient?: typeof import('@vue/typescript-plugin/lib/client')): Promise<{
export declare function detect(context: ServiceContext, uri: string): Promise<{
tag: TagNameCasing[];
attr: AttrNameCasing[];
}>;

@@ -88,4 +88,4 @@ "use strict";

exports.convertAttrName = convertAttrName;
async function getNameCasing(context, uri, tsPluginClient) {
const detected = await detect(context, uri, tsPluginClient);
async function getNameCasing(context, uri) {
const detected = await detect(context, uri);
const [attr, tag] = await Promise.all([

@@ -103,3 +103,3 @@ context.env.getConfiguration?.('vue.complete.casing.props', uri),

exports.getNameCasing = getNameCasing;
async function detect(context, uri, tsPluginClient) {
async function detect(context, uri) {
const rootFile = context.language.scripts.get(uri)?.generated?.root;

@@ -138,31 +138,19 @@ if (!(rootFile instanceof language_core_1.VueVirtualCode)) {

async function getTagNameCase(file) {
const components = await tsPluginClient?.getComponentNames(file.fileName) ?? [];
const tagNames = getTemplateTagsAndAttrs(file);
const result = [];
let anyComponentUsed = false;
for (const component of components) {
if (tagNames.has(component) || tagNames.has((0, language_core_1.hyphenateTag)(component))) {
anyComponentUsed = true;
break;
const result = new Set();
if (file.sfc.template?.ast) {
for (const element of vue.forEachElementNode(file.sfc.template.ast)) {
if (element.tagType === 1) {
if (element.tag !== (0, language_core_1.hyphenateTag)(element.tag)) {
// TagName
result.add(types_1.TagNameCasing.Pascal);
}
else {
// Tagname -> tagname
// TagName -> tag-name
result.add(types_1.TagNameCasing.Kebab);
}
}
}
}
if (!anyComponentUsed) {
return []; // not sure component style, because do not have any component using in <template> for check
}
for (const [tagName] of tagNames) {
// TagName
if (tagName !== (0, language_core_1.hyphenateTag)(tagName)) {
result.push(types_1.TagNameCasing.Pascal);
break;
}
}
for (const component of components) {
// Tagname -> tagname
// TagName -> tag-name
if (component !== (0, language_core_1.hyphenateTag)(component) && tagNames.has((0, language_core_1.hyphenateTag)(component))) {
result.push(types_1.TagNameCasing.Kebab);
break;
}
}
return result;
return [...result];
}

@@ -169,0 +157,0 @@ }

@@ -19,2 +19,3 @@ "use strict";

let extraCustomData = [];
let lastCompletionComponentNames = new Set();
const onDidChangeCustomDataListeners = new Set();

@@ -96,2 +97,4 @@ const onDidChangeCustomData = (listener) => {

if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
// #4298: Precompute HTMLDocument before provideHtmlData to avoid parseHTMLDocument requesting component names from tsserver
baseServiceInstance.provideCompletionItems?.(document, position, completionContext, token);
sync = (await provideHtmlData(sourceScript.id, sourceScript.generated.root)).sync;

@@ -108,3 +111,3 @@ currentVersion = await sync();

if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
await afterHtmlCompletion(htmlComplete, context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot), sourceScript.generated.root);
await afterHtmlCompletion(htmlComplete, context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot));
}

@@ -133,3 +136,3 @@ return htmlComplete;

// visualize missing required props
const casing = await (0, nameCasing_1.getNameCasing)(context, map.sourceDocument.uri, tsPluginClient);
const casing = await (0, nameCasing_1.getNameCasing)(context, map.sourceDocument.uri);
const components = await tsPluginClient?.getComponentNames(code.fileName) ?? [];

@@ -142,6 +145,5 @@ const componentProps = {};

const tagName = scanner.getTokenText();
const component = tagName.indexOf('.') >= 0
? components.find(component => component === tagName.split('.')[0])
const checkTag = tagName.indexOf('.') >= 0
? tagName
: components.find(component => component === tagName || (0, language_core_1.hyphenateTag)(component) === tagName);
const checkTag = tagName.indexOf('.') >= 0 ? tagName : component;
if (checkTag) {

@@ -318,3 +320,3 @@ componentProps[checkTag] ??= await tsPluginClient?.getComponentProps(code.fileName, checkTag, true) ?? [];

await (initializing ??= initialize());
const casing = await (0, nameCasing_1.getNameCasing)(context, sourceDocumentUri, tsPluginClient);
const casing = await (0, nameCasing_1.getNameCasing)(context, sourceDocumentUri);
if (builtInData.tags) {

@@ -358,2 +360,3 @@ for (const tag of builtInData.tags) {

&& name !== 'Teleport');
lastCompletionComponentNames = new Set(components);
version++;

@@ -513,6 +516,4 @@ })());

}
async function afterHtmlCompletion(completionList, sourceDocument, code) {
async function afterHtmlCompletion(completionList, sourceDocument) {
const replacement = getReplacement(completionList, sourceDocument);
const componentNames = new Set((await tsPluginClient?.getComponentNames(code.fileName) ?? [])
.map(language_core_1.hyphenateTag));
if (replacement) {

@@ -581,3 +582,3 @@ const isEvent = replacement.text.startsWith('v-on:') || replacement.text.startsWith('@');

}
if (item.kind === 10 && componentNames.has((0, language_core_1.hyphenateTag)(item.label))) {
if (item.kind === 10 && lastCompletionComponentNames.has((0, language_core_1.hyphenateTag)(item.label))) {
item.kind = 6;

@@ -584,0 +585,0 @@ item.sortText = '\u0000' + (item.sortText ?? item.label);

{
"name": "@vue/language-service",
"version": "2.0.14",
"version": "2.0.15",
"license": "MIT",

@@ -19,20 +19,20 @@ "files": [

"dependencies": {
"@volar/language-core": "2.2.0-alpha.10",
"@volar/language-service": "2.2.0-alpha.10",
"@volar/typescript": "2.2.0-alpha.10",
"@volar/language-core": "2.2.0-alpha.12",
"@volar/language-service": "2.2.0-alpha.12",
"@volar/typescript": "2.2.0-alpha.12",
"@vue/compiler-dom": "^3.4.0",
"@vue/language-core": "2.0.14",
"@vue/language-core": "2.0.15",
"@vue/shared": "^3.4.0",
"@vue/typescript-plugin": "2.0.14",
"@vue/typescript-plugin": "2.0.15",
"computeds": "^0.0.1",
"path-browserify": "^1.0.1",
"volar-service-css": "0.0.38",
"volar-service-emmet": "0.0.38",
"volar-service-html": "0.0.38",
"volar-service-json": "0.0.38",
"volar-service-pug": "0.0.38",
"volar-service-pug-beautify": "0.0.38",
"volar-service-typescript": "0.0.38",
"volar-service-typescript-twoslash-queries": "0.0.38",
"vscode-html-languageservice": "^5.1.0",
"volar-service-css": "0.0.40",
"volar-service-emmet": "0.0.40",
"volar-service-html": "0.0.40",
"volar-service-json": "0.0.40",
"volar-service-pug": "0.0.40",
"volar-service-pug-beautify": "0.0.40",
"volar-service-typescript": "0.0.40",
"volar-service-typescript-twoslash-queries": "0.0.40",
"vscode-html-languageservice": "npm:@johnsoncodehk/vscode-html-languageservice@5.2.0-34a5462",
"vscode-languageserver-textdocument": "^1.0.11",

@@ -44,6 +44,6 @@ "vscode-uri": "^3.0.8"

"@types/path-browserify": "latest",
"@volar/kit": "2.2.0-alpha.10",
"@volar/kit": "2.2.0-alpha.12",
"vscode-languageserver-protocol": "^3.17.5"
},
"gitHead": "ce1412067f88b7f9af03a2d3e04c220b4921c363"
"gitHead": "095f44449d71cd5a4730306c9c8c40df4d44dce3"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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