Skip to content

Commit

Permalink
Merge branch 'master' into feat/v-bind-shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve authored Mar 4, 2024
2 parents d1c90cc + 3793058 commit b92edb0
Show file tree
Hide file tree
Showing 41 changed files with 657 additions and 488 deletions.
92 changes: 92 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
# Changelog

## 2.0.4 (2024/3/4)

### Features

- **vscode:** report requires TSDK version in doctor

### Fixes

- **typescript-plugin:** JSON parsing error when server data length > 8192 (#3961)

## 2.0.3 (2024/3/3)

### Features

- **vscode:** identify #3942 in doctor

### Fixes

- **vscode:** compatible with VSCode 1.87.0
- **vscode:** search "TypeScript and JavaScript Language Features" with id (#3932)
- **typescript-plugin:** more reliable connection to named pipe server (#3941)

### Refactors

- **language-service:** dependency injection typescript plugin (#3994)

## 2.0.2 (2024/3/2)

### Fixes

- **vscode:** fix random `Cannot access 'i' before initialization` errors
- **typescript-plugin:** `vue-tsp-table.json` path is invalid in windows

## 2.0.1 (2024/3/2)

### Fixes

- npm release does not include files (#3919)

## 2.0.0 (2024/3/2)

### Features

- Hybrid Mode
- Takeover Mode has been deprecated. The extension now has the same performance as Takeover Mode by default.
- TypeScript language support has been moved from Vue language server to TypeScript plugin (#3788)
- Integrated all TypeScript editor features
- Warn when internal TypeScript extension is disabled or "TypeScript Vue Plugin" extension is installed
- Migrated to named pipe server using TypeScript LanguageService (#3908, #3916)
- `typescript.tsdk` duplicate registration errors are no longer reported
- **language-service:** reimplemented component tag semantic tokens in TypeScript plugin (#3915)
- **language-service:** reimplemented auto-import patching in TypeScript plugin (#3917)
- **language-service:** ensured tsserver readiness when requesting auto insert `.value` (#3914)
- Upgraded to Volar 2.0 and 2.1 (#3736, #3906)
- **vscode:** extension now compatible with [Volar Labs](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volarjs-labs) v2
- **vscode:** removed `volar.format.initialIndent` option, replaced with 3 new options:
- `vue.format.template.initialIndent`
- `vue.format.script.initialIndent`
- `vue.format.style.initialIndent`
- **language-server:** `ignoreTriggerCharacters`, `reverseConfigFilePriority` and `fullCompletionList` options are no longer supported
- Supported Component Drag and Drop Import (#3692)
- **tsc:** supported `vueCompilerOptions.extensions` option (#3800)
- **language-core:** achieved compatibility with Vue 3.4 type changes (#3860)

### Fixes

- **vscode:** prevented reading undefined properties in non-VS Code editors (#3836)
- **vscode:** prevented extension activation with TS files
- **vscode:** corrected trace server ID
- **language-core:** implemented emit codegen for defineModel (#3895)
- **language-core:** addressed transition type incompatibility with Vue 2.7.16 (#3882)
- **language-core:** excluded vue directive syntax injection in Angular bindings (#3891)
- **component-type-helpers:** resolved inference issue for Vue 3.4.20 functional component

### Refactors

- Renamed "Volar Language Features (Volar)" extension to "Vue - Official"
- "TypeScript Vue Plugin" extension has been deprecated
- Relocated source scripts from `src` to `lib` (#3913)
- Replaced `typescript/lib/tsserverlibrary` imports with `typescript`
- **language-core:** implemented codegen based on Generator (#3778)
- **language-core:** generated global types in a single virtual file (#3803)
- **language-core:** implemented plugin API v2 (#3918)
- **language-core:** ignored nested codeblocks in markdown file (#3839)
- **language-core:** removed `experimentalAdditionalLanguageModules` and deprecated APIs (#3907)
- **language-service:** made service plugins independent of project context
- **language-server:** `volar.config.js` is no longer supported
- **component-meta:** renamed APIs
- **typescript-plugin:** renamed package to `@vue/typescript-plugin` (#3910)
- **tsc:** rewritten based on first-party TS API and no longer relies on TypeScript module (#3795)
- **tsc:** deprecated hooks API (#3793)

## 1.8.27 (2023/12/26)

- fix(language-core): remove misuse of `JSX.Element` for compatible with vue 3.4 (https://github.com/vuejs/core/issues/9923)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*Component props, events, slots types information extract tool*
- [vite-plugin-vue-component-preview](https://github.com/johnsoncodehk/vite-plugin-vue-component-preview) \
*Vite plugin for support Vue component preview view with `Vue Language Features`*
- [`@vue/language-server`](/packages/language-server/) \
*The language server itself*.
- [`@vue/typescript-plugin`](/packages/typescript-plugin/) \
*Typescript plugin for the language server*.

## Community Integration

Expand Down
43 changes: 6 additions & 37 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "volar",
"version": "1.8.27",
"version": "2.0.4",
"repository": {
"type": "git",
"url": "https://github.com/vuejs/language-tools.git",
Expand All @@ -14,7 +14,7 @@
"url": "https://github.com/sponsors/johnsoncodehk"
},
"icon": "images/icon.png",
"displayName": "Vue Language Support - Official",
"displayName": "Vue - Official",
"description": "Language Support for Vue",
"author": "johnsoncodehk",
"publisher": "Vue",
Expand Down Expand Up @@ -85,32 +85,6 @@
"url": "./dist/schemas/vue-tsconfig.deprecated.schema.json"
}
],
"semanticTokenScopes": [
{
"language": "vue",
"scopes": {
"component": [
"support.class.component.vue"
]
}
},
{
"language": "markdown",
"scopes": {
"component": [
"support.class.component.vue"
]
}
},
{
"language": "html",
"scopes": {
"component": [
"support.class.component.vue"
]
}
}
],
"languages": [
{
"id": "vue",
Expand Down Expand Up @@ -341,7 +315,7 @@
"items": {
"type": "string"
},
"default": [ ],
"default": [],
"description": "List any additional file extensions that should be processed as Vue files (requires restart)."
},
"vue.doctor.status": {
Expand Down Expand Up @@ -423,11 +397,6 @@
"default": true,
"description": "Show name casing in status bar."
},
"vue.complete.normalizeComponentImportName": {
"type": "boolean",
"default": true,
"description": "Normalize import name for auto import. (\"myCompVue\" -> \"MyComp\")"
},
"vue.autoInsert.parentheses": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -576,9 +545,9 @@
"@types/semver": "^7.5.3",
"@types/vscode": "^1.82.0",
"@volar/vscode": "~2.1.0",
"@vue/language-core": "1.8.27",
"@vue/language-server": "1.8.27",
"@vue/typescript-plugin": "1.8.27",
"@vue/language-core": "2.0.4",
"@vue/language-server": "2.0.4",
"@vue/typescript-plugin": "2.0.4",
"esbuild": "latest",
"esbuild-plugin-copy": "latest",
"esbuild-visualizer": "latest",
Expand Down
25 changes: 19 additions & 6 deletions extensions/vscode/src/features/doctor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getTsdk } from '@volar/vscode';
import { ParseSFCRequest } from '@vue/language-server';
import { GetConnectedNamedPipeServerRequest, ParseSFCRequest } from '@vue/language-server';
import * as semver from 'semver';
import * as vscode from 'vscode';
import type { BaseLanguageClient } from 'vscode-languageclient';
Expand Down Expand Up @@ -244,15 +244,28 @@ export async function register(context: vscode.ExtensionContext, client: BaseLan
}
*/

// check tsdk version should not be 4.9
// check tsdk version should be higher than 5.0.0
const tsdk = await getTsdk(context);
if (tsdk?.version?.startsWith('4.9')) {
if (tsdk.version && !semver.gte(tsdk.version, '5.0.0')) {
problems.push({
title: 'Bad TypeScript version',
title: 'Requires TSDK 5.0 or higher',
message: [
'TS 4.9 has a bug that will cause auto import to fail. Please downgrade to TS 4.8 or upgrade to TS 5.0+.',
`Extension >= 2.0 requires TSDK 5.0+. You are currently using TSDK ${tsdk.version}, please upgrade to TSDK.`,
'If you need to use TSDK 4.x, please downgrade the extension to v1.',
].join('\n'),
});
}

// #3942
const namedPipe = await client.sendRequest(GetConnectedNamedPipeServerRequest.type, fileUri.fsPath.replace(/\\/g, '/'));
if (namedPipe?.serverKind === 0) {
problems.push({
title: 'Missing jsconfig/tsconfig',
message: [
'The current file does not have a matching tsconfig/jsconfig, and extension version 2.0 will not work properly for this at the moment.',
'To avoid this problem, you can create a jsconfig in the project root, or downgrade to 1.8.27.',
'',
'Issue: https://github.com/vuejs/language-tools/issues/2190',
'Issue: https://github.com/vuejs/language-tools/issues/3942',
].join('\n'),
});
}
Expand Down
46 changes: 11 additions & 35 deletions extensions/vscode/src/nodeClientMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export async function activate(context: vscode.ExtensionContext) {

let serverPathStatusItem: vscode.StatusBarItem | undefined;

const volarLabs = createLabsInfo(serverLib);
volarLabs.extensionExports.volarLabs.codegenStackSupport = true;

await commonActivate(context, (
id,
name,
Expand Down Expand Up @@ -106,31 +109,7 @@ export async function activate(context: vscode.ExtensionContext) {
serverOptions,
clientOptions,
);
client.start().then(() => {
const legend = client.initializeResult?.capabilities.semanticTokensProvider?.legend;
if (!legend) {
console.error('Server does not support semantic tokens');
return;
}
// When tsserver has provided semantic tokens for the .vue file, VSCode will no longer request semantic tokens from the Vue language server, so it needs to be provided here again.
vscode.languages.registerDocumentSemanticTokensProvider(documentSelector, {
async provideDocumentSemanticTokens(document) {
const tokens = await client.sendRequest(lsp.SemanticTokensRequest.type, {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
} satisfies lsp.SemanticTokensParams);
return client.protocol2CodeConverter.asSemanticTokens(tokens);
},
}, legend);
vscode.languages.registerDocumentRangeSemanticTokensProvider(documentSelector, {
async provideDocumentRangeSemanticTokens(document, range) {
const tokens = await client.sendRequest(lsp.SemanticTokensRangeRequest.type, {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
range: client.code2ProtocolConverter.asRange(range),
} satisfies lsp.SemanticTokensRangeParams);
return client.protocol2CodeConverter.asSemanticTokens(tokens);
},
}, legend);
});
client.start();

volarLabs.addLanguageClient(client);

Expand All @@ -151,7 +130,7 @@ export async function activate(context: vscode.ExtensionContext) {
'Show Extension'
).then((selected) => {
if (selected) {
vscode.commands.executeCommand('workbench.extensions.search', '@builtin TypeScript and JavaScript Language Features');
vscode.commands.executeCommand('workbench.extensions.search', '@builtin typescript-language-features');
}
});
}
Expand All @@ -167,8 +146,6 @@ export async function activate(context: vscode.ExtensionContext) {
});
}

const volarLabs = createLabsInfo(serverLib);
volarLabs.extensionExports.volarLabs.codegenStackSupport = true;
return volarLabs.extensionExports;
}

Expand All @@ -193,9 +170,6 @@ function updateProviders(client: lsp.LanguageClient) {
capabilities.workspace.fileOperations.willRename = undefined;
}

// TODO: disalbe for now because this break ts plugin semantic tokens
capabilities.semanticTokensProvider = undefined;

return initializeFeatures.call(client, ...args);
};
}
Expand All @@ -211,11 +185,13 @@ try {
// @ts-expect-error
let text = readFileSync(...args) as string;

// patch jsTsLanguageModes
text = text.replace('t.$u=[t.$r,t.$s,t.$p,t.$q]', s => s + '.concat("vue")');
// VSCode < 1.87.0
text = text.replace('t.$u=[t.$r,t.$s,t.$p,t.$q]', s => s + '.concat("vue")'); // patch jsTsLanguageModes
text = text.replace('.languages.match([t.$p,t.$q,t.$r,t.$s]', s => s + '.concat("vue")'); // patch isSupportedLanguageMode

// patch isSupportedLanguageMode
text = text.replace('.languages.match([t.$p,t.$q,t.$r,t.$s]', s => s + '.concat("vue")');
// VSCode >= 1.87.0
text = text.replace('t.jsTsLanguageModes=[t.javascript,t.javascriptreact,t.typescript,t.typescriptreact]', s => s + '.concat("vue")'); // patch jsTsLanguageModes
text = text.replace('.languages.match([t.typescript,t.typescriptreact,t.javascript,t.javascriptreact]', s => s + '.concat("vue")'); // patch isSupportedLanguageMode

return text;
}
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"packages/*",
"test-workspace"
],
"version": "1.8.27"
"version": "2.0.4"
}
10 changes: 5 additions & 5 deletions packages/component-meta/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "vue-component-meta",
"version": "1.8.27",
"version": "2.0.4",
"license": "MIT",
"files": [
"out/**/*.js",
"out/**/*.d.ts"
"**/*.js",
"**/*.d.ts"
],
"repository": {
"type": "git",
Expand All @@ -13,9 +13,9 @@
},
"dependencies": {
"@volar/typescript": "~2.1.0",
"@vue/language-core": "1.8.27",
"@vue/language-core": "2.0.4",
"path-browserify": "^1.0.1",
"vue-component-type-helpers": "1.8.27"
"vue-component-type-helpers": "2.0.4"
},
"peerDependencies": {
"typescript": "*"
Expand Down
6 changes: 3 additions & 3 deletions packages/component-type-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "vue-component-type-helpers",
"version": "1.8.27",
"version": "2.0.4",
"license": "MIT",
"files": [
"*.js",
"*.d.ts"
"**/*.js",
"**/*.d.ts"
],
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/language-core/lib/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useVueSfcStyles from './plugins/vue-sfc-styles';
import useVueSfcTemplate from './plugins/vue-sfc-template';
import useHtmlTemplatePlugin from './plugins/vue-template-html';
import useVueTsx from './plugins/vue-tsx';
import type { VueCompilerOptions, VueLanguagePlugin } from './types';
import { pluginVersion, type VueCompilerOptions, type VueLanguagePlugin } from './types';
import * as CompilerVue2 from './utils/vue2TemplateCompiler';

export function createPluginContext(
Expand Down Expand Up @@ -61,9 +61,9 @@ export function getDefaultVueLanguagePlugins(pluginContext: Parameters<VueLangua
});

return pluginInstances.filter((plugin) => {
const valid = plugin.version >= 2 && plugin.version < 3;
const valid = plugin.version === pluginVersion;
if (!valid) {
console.warn(`Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected 2.x but got ${JSON.stringify(plugin.version)}`);
console.warn(`Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected ${JSON.stringify(pluginVersion)} but got ${JSON.stringify(plugin.version)}`);
}
return valid;
});
Expand Down
Loading

0 comments on commit b92edb0

Please sign in to comment.