Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/class-vue-2
Browse files Browse the repository at this point in the history
* origin/master: (25 commits)
  chore: fix typo (vuejs#3399)
  chore: bump volar
  Deprecate language server `json.customBlockSchemaUrls` option (vuejs#3398)
  Use faster method after config change (vuejs#3393)
  test: change defineComponent to support JSX (vuejs#3384)
  fix(class references): non scoped classes resolution regression (vuejs#3381)
  perf: hoist regexp if possible (vuejs#3378)
  fix: camel case components is not recognized as used (vuejs#3377)
  fix: allow slots to have no arguments (vuejs#3376)
  fix: don't remove comments when comment is in the first line (vuejs#3365)
  chore: add test for vuejs#3353
  chore: check project kind
  feat(typescript): implement `getExternalFiles`
  chore: update lock
  chore: remove resolve tsconfig warn
  ci(language-service): update html data
  chore: remove serverStats command from package.json of VSCode extension (vuejs#3366)
  v1.8.4
  chore: changelog
  chore: unpin volar
  ...
  • Loading branch information
rchl committed Jul 13, 2023
2 parents aa38535 + 378b853 commit bb3ea45
Show file tree
Hide file tree
Showing 65 changed files with 927 additions and 768 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
@@ -1,9 +1,11 @@
# Changelog

## 1.8.3 (2023/6/28)
## 1.8.4 (2023/7/5)

- fix(ts-plugin): tsserver crashes when import > 4MB .vue file ([#3332](https://github.com/vuejs/language-tools/issues/3332))
- fix(language-server): in specific os `fileExists()` throws ([#3336](https://github.com/vuejs/language-tools/issues/3336))
- feat(monaco): support for custom file system provider (https://github.com/volarjs/volar.js/pull/50)
- feat: support auto-complete for template directive comments
- fix: local component type should override a global component ([#1886](https://github.com/vuejs/language-tools/issues/1886)) ([#3333](https://github.com/vuejs/language-tools/issues/3333)) - thanks @so1ve
- fix: support type narrowing for components define in script setup ([#3138](https://github.com/vuejs/language-tools/issues/3138)) ([#3350](https://github.com/vuejs/language-tools/issues/3350)) - thanks @so1ve

---

Expand Down Expand Up @@ -41,6 +43,11 @@
</h5>
</p>

## 1.8.3 (2023/6/28)

- fix(ts-plugin): tsserver crashes when import > 4MB .vue file ([#3332](https://github.com/vuejs/language-tools/issues/3332))
- fix(language-server): in specific os `fileExists()` throws ([#3336](https://github.com/vuejs/language-tools/issues/3336))

## 1.8.2 (2023/6/27)

- fix: should not auto closing `<img>` tag ([#3217](https://github.com/vuejs/language-tools/issues/3217))
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -4,5 +4,5 @@
"packages": [
"packages/*"
],
"version": "1.8.3"
"version": "1.8.4"
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@types/node": "latest",
"@volar/language-service": "1.7.10",
"@volar/language-service": "~1.8.3",
"typescript": "latest",
"vite": "latest",
"vitest": "latest"
Expand Down
6 changes: 3 additions & 3 deletions packages/typescript-vue-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "typescript-vue-plugin",
"version": "1.8.3",
"version": "1.8.4",
"main": "out/index.js",
"license": "MIT",
"files": [
Expand All @@ -13,8 +13,8 @@
"directory": "packages/typescript-vue-plugin"
},
"dependencies": {
"@vue/language-core": "1.8.3",
"@vue/typescript": "1.8.3",
"@vue/language-core": "1.8.4",
"@vue/typescript": "1.8.4",
"vscode-uri": "^3.0.7"
}
}
16 changes: 12 additions & 4 deletions packages/typescript-vue-plugin/src/index.ts
@@ -1,7 +1,9 @@
import * as vue from '@vue/language-core';
import { decorateLanguageService, decorateLanguageServiceHost } from '@vue/typescript';
import { decorateLanguageService, decorateLanguageServiceHost, getExternalFiles } from '@vue/typescript';
import type * as ts from 'typescript/lib/tsserverlibrary';

const externalFiles = new WeakMap<ts.server.Project, string[]>();

const init: ts.server.PluginModuleFactory = (modules) => {
const { typescript: ts } = modules;
const pluginModule: ts.server.PluginModule = {
Expand All @@ -21,15 +23,21 @@ const init: ts.server.PluginModuleFactory = (modules) => {
return info.languageService;

function getVueCompilerOptions() {
const projectName = info.project.getProjectName();
if (info.project.fileExists(projectName)) {
return vue.createParsedCommandLine(ts, ts.sys, projectName).vueOptions;
if (info.project.projectKind === ts.server.ProjectKind.Configured) {
const tsconfig = info.project.getProjectName();
return vue.createParsedCommandLine(ts, ts.sys, tsconfig).vueOptions;
}
else {
return vue.createParsedCommandLineByJson(ts, ts.sys, info.languageServiceHost.getCurrentDirectory(), {}).vueOptions;
}
}
},
getExternalFiles(project) {
if (!externalFiles.has(project)) {
externalFiles.set(project, getExternalFiles(ts, project, ['.vue']));
}
return externalFiles.get(project)!;
},
};
return pluginModule;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-typescript-vue-plugin/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "vscode-typescript-vue-plugin",
"version": "1.8.3",
"version": "1.8.4",
"repository": {
"type": "git",
"url": "https://github.com/vuejs/language-tools.git",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"devDependencies": {
"esbuild": "0.15.18",
"typescript-vue-plugin": "1.8.3",
"typescript-vue-plugin": "1.8.4",
"vsce": "latest"
}
}
16 changes: 4 additions & 12 deletions packages/vscode-vue/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "volar",
"version": "1.8.3",
"version": "1.8.4",
"repository": {
"type": "git",
"url": "https://github.com/vuejs/language-tools.git",
Expand Down Expand Up @@ -426,9 +426,6 @@
"type": "boolean",
"default": false
},
"vue.server.json.customBlockSchemaUrls": {
"type": "object"
},
"vue.server.diagnosticModel": {
"type": "string",
"default": "push",
Expand Down Expand Up @@ -610,11 +607,6 @@
"title": "Write Virtual Files",
"category": "Volar (Debug)"
},
{
"command": "volar.action.serverStats",
"title": "Server Stats",
"category": "Volar (Debug)"
},
{
"command": "volar.action.showComponentMeta",
"title": "Show Component Meta",
Expand Down Expand Up @@ -733,9 +725,9 @@
"devDependencies": {
"@types/semver": "^7.3.13",
"@types/vscode": "1.67.0",
"@volar/vscode": "1.7.10",
"@vue/language-core": "1.8.3",
"@vue/language-server": "1.8.3",
"@volar/vscode": "~1.8.3",
"@vue/language-core": "1.8.4",
"@vue/language-server": "1.8.4",
"esbuild": "0.15.18",
"esbuild-plugin-copy": "latest",
"esbuild-visualizer": "latest",
Expand Down
60 changes: 26 additions & 34 deletions packages/vscode-vue/src/common.ts
Expand Up @@ -137,31 +137,28 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
activateServerSys(client);
}

async function requestReloadVscode() {
const reload = await vscode.window.showInformationMessage(
'Please reload VSCode to restart language servers.',
'Reload Window'
);
if (reload === undefined) return; // cancel
vscode.commands.executeCommand('workbench.action.reloadWindow');
}
function activateServerMaxOldSpaceSizeChange() {
vscode.workspace.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration('vue.server')) {
requestReloadVscode();
}
else if (e.affectsConfiguration('vue')) {
if (e.affectsConfiguration('vue')) {
vscode.commands.executeCommand('volar.action.restartServer');
}
});
}

async function activateRestartRequest() {
context.subscriptions.push(vscode.commands.registerCommand('volar.action.restartServer', async () => {

await Promise.all(clients.map(client => client.stop()));

semanticClient.clientOptions.initializationOptions = await getInitializationOptions(ServerMode.PartialSemantic, context, semanticClient.clientOptions.initializationOptions);
syntacticClient.clientOptions.initializationOptions = await getInitializationOptions(ServerMode.Syntactic, context, syntacticClient.clientOptions.initializationOptions);

await Promise.all(clients.map(client => client.start()));

activateClientRequests();
}));
}

function activateClientRequests() {
nameCasing.activate(context, semanticClient);
}
Expand Down Expand Up @@ -204,29 +201,24 @@ export function getDocumentSelector(context: vscode.ExtensionContext, serverMode
async function getInitializationOptions(
serverMode: ServerMode,
context: vscode.ExtensionContext,
options: VueServerInitializationOptions = {},
) {
const initializationOptions: VueServerInitializationOptions = {
// volar
configFilePath: config.server.configFilePath,
serverMode,
diagnosticModel: config.server.diagnosticModel === 'pull' ? DiagnosticModel.Pull : DiagnosticModel.Push,
typescript: { tsdk: (await getTsdk(context)).tsdk },
reverseConfigFilePriority: config.server.reverseConfigFilePriority,
maxFileSize: config.server.maxFileSize,
semanticTokensLegend: {
// volar
options.configFilePath = config.server.configFilePath;
options.serverMode = serverMode,
options.diagnosticModel = config.server.diagnosticModel === 'pull' ? DiagnosticModel.Pull : DiagnosticModel.Push,
options.typescript = { tsdk: (await getTsdk(context)).tsdk },
options.reverseConfigFilePriority = config.server.reverseConfigFilePriority,
options.maxFileSize = config.server.maxFileSize,
options.semanticTokensLegend = {
tokenTypes: ['component'],
tokenModifiers: [],
},
fullCompletionList: config.server.fullCompletionList,
// vue
json: {
customBlockSchemaUrls: config.server.json.customBlockSchemaUrls,
},
additionalExtensions: [
...config.server.additionalExtensions,
...!config.server.petiteVue.supportHtmlFile ? [] : ['html'],
...!config.server.vitePress.supportMdFile ? [] : ['md'],
],
};
return initializationOptions;
};
options.fullCompletionList = config.server.fullCompletionList;
options.additionalExtensions = [
...config.server.additionalExtensions,
...!config.server.petiteVue.supportHtmlFile ? [] : ['html'],
...!config.server.vitePress.supportMdFile ? [] : ['md'],
];
return options;
}
3 changes: 0 additions & 3 deletions packages/vscode-vue/src/config.ts
Expand Up @@ -29,9 +29,6 @@ export const config = {
petiteVue: {
supportHtmlFile: boolean;
};
json: {
customBlockSchemaUrls: Record<string, string>;
};
}> {
return _config().get('server')!;
},
Expand Down
8 changes: 4 additions & 4 deletions packages/vue-component-meta/package.json
@@ -1,6 +1,6 @@
{
"name": "vue-component-meta",
"version": "1.8.3",
"version": "1.8.4",
"main": "out/index.js",
"license": "MIT",
"files": [
Expand All @@ -13,10 +13,10 @@
"directory": "packages/vue-component-meta"
},
"dependencies": {
"@volar/typescript": "1.7.10",
"@vue/language-core": "1.8.3",
"@volar/typescript": "~1.8.3",
"@vue/language-core": "1.8.4",
"typesafe-path": "^0.2.2",
"vue-component-type-helpers": "1.8.3"
"vue-component-type-helpers": "1.8.4"
},
"peerDependencies": {
"typescript": "*"
Expand Down
16 changes: 9 additions & 7 deletions packages/vue-component-meta/src/index.ts
Expand Up @@ -19,13 +19,15 @@ export * from './types';

export type ComponentMetaChecker = ReturnType<typeof baseCreate>;

const windowsPathReg = /\\/g;

export function createComponentMetaCheckerByJsonConfig(
root: string,
json: any,
checkerOptions: MetaCheckerOptions = {},
ts: typeof import('typescript/lib/tsserverlibrary') = require('typescript'),
) {
const rootPath = (root as path.OsPath).replace(/\\/g, '/') as path.PosixPath;
const rootPath = (root as path.OsPath).replace(windowsPathReg, '/') as path.PosixPath;
return createComponentMetaCheckerWorker(
() => vue.createParsedCommandLineByJson(ts, ts.sys, root, json),
checkerOptions,
Expand All @@ -40,7 +42,7 @@ export function createComponentMetaChecker(
checkerOptions: MetaCheckerOptions = {},
ts: typeof import('typescript/lib/tsserverlibrary') = require('typescript'),
) {
const tsconfig = (tsconfigPath as path.OsPath).replace(/\\/g, '/') as path.PosixPath;
const tsconfig = (tsconfigPath as path.OsPath).replace(windowsPathReg, '/') as path.PosixPath;
return createComponentMetaCheckerWorker(
() => vue.createParsedCommandLine(ts, ts.sys, tsconfigPath),
checkerOptions,
Expand All @@ -63,13 +65,13 @@ function createComponentMetaCheckerWorker(
*/

let parsedCommandLine = loadParsedCommandLine();
let fileNames = (parsedCommandLine.fileNames as path.OsPath[]).map<path.PosixPath>(path => path.replace(/\\/g, '/') as path.PosixPath);
let fileNames = (parsedCommandLine.fileNames as path.OsPath[]).map<path.PosixPath>(path => path.replace(windowsPathReg, '/') as path.PosixPath);
let projectVersion = 0;

const scriptSnapshots = new Map<string, ts.IScriptSnapshot>();
const _host: vue.TypeScriptLanguageHost = {
getCurrentDirectory: () => rootPath,
getProjectVersion: () => projectVersion,
getProjectVersion: () => projectVersion.toString(),
getCompilationSettings: () => parsedCommandLine.options,
getScriptFileNames: () => fileNames,
getProjectReferences: () => parsedCommandLine.projectReferences,
Expand All @@ -87,18 +89,18 @@ function createComponentMetaCheckerWorker(
return {
...baseCreate(_host, vue.resolveVueCompilerOptions(parsedCommandLine.vueOptions), checkerOptions, globalComponentName, ts),
updateFile(fileName: string, text: string) {
fileName = (fileName as path.OsPath).replace(/\\/g, '/') as path.PosixPath;
fileName = (fileName as path.OsPath).replace(windowsPathReg, '/') as path.PosixPath;
scriptSnapshots.set(fileName, ts.ScriptSnapshot.fromString(text));
projectVersion++;
},
deleteFile(fileName: string) {
fileName = (fileName as path.OsPath).replace(/\\/g, '/') as path.PosixPath;
fileName = (fileName as path.OsPath).replace(windowsPathReg, '/') as path.PosixPath;
fileNames = fileNames.filter(f => f !== fileName);
projectVersion++;
},
reload() {
parsedCommandLine = loadParsedCommandLine();
fileNames = (parsedCommandLine.fileNames as path.OsPath[]).map<path.PosixPath>(path => path.replace(/\\/g, '/') as path.PosixPath);
fileNames = (parsedCommandLine.fileNames as path.OsPath[]).map<path.PosixPath>(path => path.replace(windowsPathReg, '/') as path.PosixPath);
this.clearCache();
},
clearCache() {
Expand Down
21 changes: 21 additions & 0 deletions packages/vue-component-meta/tests/index.spec.ts
Expand Up @@ -732,6 +732,27 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ

expect(meta.type).toEqual(TypeMeta.Unknown);
});

test('ts-component.tsx', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/ts-component/component.tsx');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Function);

const a = meta.props.find(prop =>
prop.name === 'foo'
&& prop.required === true
&& prop.type === 'string'
);
const b = meta.props.find(prop =>
prop.name === 'bar'
&& prop.required === false
&& prop.type === 'number | undefined'
);

expect(a).toBeDefined();
expect(b).toBeDefined();
});
});

const checkerOptions: MetaCheckerOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-component-type-helpers/package.json
@@ -1,6 +1,6 @@
{
"name": "vue-component-type-helpers",
"version": "1.8.3",
"version": "1.8.4",
"license": "MIT",
"files": [
"*.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/vue-language-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/language-core",
"version": "1.8.3",
"version": "1.8.4",
"main": "out/index.js",
"license": "MIT",
"files": [
Expand All @@ -13,8 +13,8 @@
"directory": "packages/vue-language-core"
},
"dependencies": {
"@volar/language-core": "1.7.10",
"@volar/source-map": "1.7.10",
"@volar/language-core": "~1.8.3",
"@volar/source-map": "~1.8.3",
"@vue/compiler-dom": "^3.3.0",
"@vue/reactivity": "^3.3.0",
"@vue/shared": "^3.3.0",
Expand Down

0 comments on commit bb3ea45

Please sign in to comment.