@vue/language-server 1.9.0-alpha.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- if (process.argv.includes("--version")) {
3
- const pkgJSON = require("../package.json");
4
- console.log(`${pkgJSON["version"]}`);
2
+ // @ts-check
3
+ if (process.argv.includes('--version')) {
4
+ console.log(require('../package.json').version);
5
5
  }
6
6
  else {
7
- require("../out/nodeServer.js");
7
+ require('../node.js');
8
8
  }
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './lib/protocol';
2
+ export * from './lib/types';
3
+ export * from '@volar/language-server/protocol';
4
+ export * from '@volar/language-server/lib/types';
5
+ export * from '@vue/language-service/lib/types';
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./protocol"), exports);
18
- __exportStar(require("./types"), exports);
17
+ __exportStar(require("./lib/protocol"), exports);
18
+ __exportStar(require("./lib/types"), exports);
19
19
  // export protocol and types of parent package
20
20
  __exportStar(require("@volar/language-server/protocol"), exports);
21
21
  __exportStar(require("@volar/language-server/lib/types"), exports);
22
22
  // only export types of depend packages
23
- __exportStar(require("@vue/language-service/out/types"), exports);
23
+ __exportStar(require("@vue/language-service/lib/types"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,5 @@
1
+ import type { AttrNameCasing, SFCParseResult, TagNameCasing } from '@vue/language-service';
1
2
  import * as vscode from 'vscode-languageserver-protocol';
2
- import { TagNameCasing, AttrNameCasing, SFCParseResult } from '@vue/language-service';
3
- import { ComponentMeta } from 'vue-component-meta';
4
- export declare namespace GetComponentMeta {
5
- type ParamsType = vscode.TextDocumentIdentifier;
6
- type ResponseType = ComponentMeta | null | undefined;
7
- type ErrorType = never;
8
- const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
9
- }
10
3
  export declare namespace DetectNameCasingRequest {
11
4
  type ParamsType = {
12
5
  textDocument: vscode.TextDocumentIdentifier;
@@ -27,20 +20,6 @@ export declare namespace GetConvertTagCasingEditsRequest {
27
20
  type ErrorType = never;
28
21
  const type: vscode.RequestType<ParamsType, ResponseType, never>;
29
22
  }
30
- export declare namespace GetDragAndDragImportEditsRequest {
31
- type ParamsType = {
32
- uri: string;
33
- importUri: string;
34
- casing: TagNameCasing;
35
- };
36
- type ResponseType = {
37
- insertText: string;
38
- insertTextFormat: vscode.InsertTextFormat;
39
- additionalEdits: vscode.TextEdit[];
40
- } | null | undefined;
41
- type ErrorType = never;
42
- const type: vscode.RequestType<ParamsType, ResponseType, never>;
43
- }
44
23
  export declare namespace GetConvertAttrCasingEditsRequest {
45
24
  type ParamsType = {
46
25
  textDocument: vscode.TextDocumentIdentifier;
@@ -56,4 +35,3 @@ export declare namespace ParseSFCRequest {
56
35
  type ErrorType = never;
57
36
  const type: vscode.RequestType<string, SFCParseResult, never>;
58
37
  }
59
- //# sourceMappingURL=protocol.d.ts.map
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseSFCRequest = exports.GetConvertAttrCasingEditsRequest = exports.GetDragAndDragImportEditsRequest = exports.GetConvertTagCasingEditsRequest = exports.DetectNameCasingRequest = exports.GetComponentMeta = void 0;
3
+ exports.ParseSFCRequest = exports.GetConvertAttrCasingEditsRequest = exports.GetConvertTagCasingEditsRequest = exports.DetectNameCasingRequest = void 0;
4
4
  const vscode = require("vscode-languageserver-protocol");
5
- var GetComponentMeta;
6
- (function (GetComponentMeta) {
7
- GetComponentMeta.type = new vscode.RequestType('vue/componentMeta');
8
- })(GetComponentMeta || (exports.GetComponentMeta = GetComponentMeta = {}));
9
5
  var DetectNameCasingRequest;
10
6
  (function (DetectNameCasingRequest) {
11
7
  DetectNameCasingRequest.type = new vscode.RequestType('vue/detectTagCasing');
@@ -14,10 +10,6 @@ var GetConvertTagCasingEditsRequest;
14
10
  (function (GetConvertTagCasingEditsRequest) {
15
11
  GetConvertTagCasingEditsRequest.type = new vscode.RequestType('vue/convertTagNameCasing');
16
12
  })(GetConvertTagCasingEditsRequest || (exports.GetConvertTagCasingEditsRequest = GetConvertTagCasingEditsRequest = {}));
17
- var GetDragAndDragImportEditsRequest;
18
- (function (GetDragAndDragImportEditsRequest) {
19
- GetDragAndDragImportEditsRequest.type = new vscode.RequestType('vue/dragImportEdits');
20
- })(GetDragAndDragImportEditsRequest || (exports.GetDragAndDragImportEditsRequest = GetDragAndDragImportEditsRequest = {}));
21
13
  var GetConvertAttrCasingEditsRequest;
22
14
  (function (GetConvertAttrCasingEditsRequest) {
23
15
  GetConvertAttrCasingEditsRequest.type = new vscode.RequestType('vue/convertPropNameCasing');
package/lib/types.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { InitializationOptions } from "@volar/language-server";
2
+ export type VueInitializationOptions = InitializationOptions & {
3
+ typescript: {
4
+ tsdk: string;
5
+ };
6
+ vue?: {
7
+ /**
8
+ * @example ['vue1', 'vue2']
9
+ */
10
+ additionalExtensions?: string[];
11
+ };
12
+ };
package/node.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { Connection } from '@volar/language-server';
2
+ export declare const connection: Connection;
3
+ export declare const server: {
4
+ initialize: (params: Omit<import("@volar/language-server").InitializeParams, "initializationOptions"> & {
5
+ initializationOptions?: import("@volar/language-server").InitializationOptions | undefined;
6
+ }, projectProviderFactory: import("@volar/language-server").ServerProjectProviderFactory, _serverOptions: import("@volar/language-server/lib/server").ServerOptions) => Promise<import("@volar/language-server").InitializeResult<any>>;
7
+ initialized: () => void;
8
+ shutdown: () => void;
9
+ readonly projects: import("@volar/language-server").ServerProjectProvider;
10
+ readonly env: import("@volar/language-server").ServerRuntimeEnvironment;
11
+ };
package/node.js ADDED
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.server = exports.connection = void 0;
4
+ const node_1 = require("@volar/language-server/node");
5
+ const language_core_1 = require("@vue/language-core");
6
+ const language_service_1 = require("@vue/language-service");
7
+ const protocol_1 = require("./lib/protocol");
8
+ exports.connection = (0, node_1.createConnection)();
9
+ exports.server = (0, node_1.createServer)(exports.connection);
10
+ const envToVueOptions = new WeakMap();
11
+ let tsdk;
12
+ exports.connection.listen();
13
+ exports.connection.onInitialize(async (params) => {
14
+ const options = params.initializationOptions;
15
+ tsdk = (0, node_1.loadTsdkByPath)(options.typescript.tsdk, params.locale);
16
+ const vueFileExtensions = ['vue'];
17
+ if (options.vue?.additionalExtensions) {
18
+ for (const additionalExtension of options.vue.additionalExtensions) {
19
+ vueFileExtensions.push(additionalExtension);
20
+ }
21
+ }
22
+ const result = await exports.server.initialize(params, (0, node_1.createSimpleProjectProviderFactory)(), {
23
+ watchFileExtensions: ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts', 'jsx', 'tsx', 'json', ...vueFileExtensions],
24
+ getServicePlugins() {
25
+ return (0, language_service_1.createVueServicePlugins)(tsdk.typescript, env => envToVueOptions.get(env));
26
+ },
27
+ async getLanguagePlugins(serviceEnv, projectContext) {
28
+ const [commandLine, vueOptions] = await parseCommandLine();
29
+ const resolvedVueOptions = (0, language_core_1.resolveVueCompilerOptions)(vueOptions);
30
+ const vueLanguagePlugin = (0, language_core_1.createVueLanguagePlugin)(tsdk.typescript, serviceEnv.typescript.uriToFileName, commandLine?.options ?? {}, resolvedVueOptions, options.codegenStack);
31
+ envToVueOptions.set(serviceEnv, resolvedVueOptions);
32
+ return [vueLanguagePlugin];
33
+ async function parseCommandLine() {
34
+ let commandLine;
35
+ let vueOptions = {};
36
+ if (projectContext.typescript) {
37
+ const { sys } = projectContext.typescript;
38
+ let sysVersion;
39
+ let newSysVersion = await sys.sync();
40
+ while (sysVersion !== newSysVersion) {
41
+ sysVersion = newSysVersion;
42
+ if (projectContext.typescript.configFileName) {
43
+ commandLine = (0, language_core_1.createParsedCommandLine)(tsdk.typescript, sys, projectContext.typescript.configFileName);
44
+ }
45
+ newSysVersion = await sys.sync();
46
+ }
47
+ }
48
+ if (commandLine) {
49
+ vueOptions = commandLine.vueOptions;
50
+ }
51
+ vueOptions.extensions = [
52
+ ...vueOptions.extensions ?? ['.vue'],
53
+ ...vueFileExtensions.map(ext => '.' + ext),
54
+ ];
55
+ vueOptions.extensions = [...new Set(vueOptions.extensions)];
56
+ return [commandLine, vueOptions];
57
+ }
58
+ },
59
+ });
60
+ // handle by tsserver + @vue/typescript-plugin
61
+ result.capabilities.semanticTokensProvider = undefined;
62
+ return result;
63
+ });
64
+ exports.connection.onInitialized(() => {
65
+ exports.server.initialized();
66
+ });
67
+ exports.connection.onShutdown(() => {
68
+ exports.server.shutdown();
69
+ });
70
+ exports.connection.onRequest(protocol_1.ParseSFCRequest.type, params => {
71
+ return (0, language_core_1.parse)(params);
72
+ });
73
+ exports.connection.onRequest(protocol_1.DetectNameCasingRequest.type, async (params) => {
74
+ const languageService = await getService(params.textDocument.uri);
75
+ if (languageService) {
76
+ return await (0, language_service_1.detect)(languageService.context, params.textDocument.uri);
77
+ }
78
+ });
79
+ exports.connection.onRequest(protocol_1.GetConvertTagCasingEditsRequest.type, async (params) => {
80
+ const languageService = await getService(params.textDocument.uri);
81
+ if (languageService) {
82
+ return await (0, language_service_1.convertTagName)(languageService.context, params.textDocument.uri, params.casing);
83
+ }
84
+ });
85
+ exports.connection.onRequest(protocol_1.GetConvertAttrCasingEditsRequest.type, async (params) => {
86
+ const languageService = await getService(params.textDocument.uri);
87
+ if (languageService) {
88
+ return await (0, language_service_1.convertAttrName)(languageService.context, params.textDocument.uri, params.casing);
89
+ }
90
+ });
91
+ async function getService(uri) {
92
+ return (await exports.server.projects.getProject(uri)).getLanguageService();
93
+ }
94
+ //# sourceMappingURL=node.js.map
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@vue/language-server",
3
- "version": "1.9.0-alpha.3",
4
- "main": "out/index.js",
3
+ "version": "2.0.1",
5
4
  "license": "MIT",
6
5
  "files": [
7
- "out/**/*.js",
8
- "out/**/*.d.ts"
6
+ "**/*.js",
7
+ "**/*.d.ts"
9
8
  ],
10
9
  "bin": {
11
10
  "vue-language-server": "./bin/vue-language-server.js"
@@ -16,13 +15,11 @@
16
15
  "directory": "packages/language-server"
17
16
  },
18
17
  "dependencies": {
19
- "@volar/language-core": "~1.11.0",
20
- "@volar/language-server": "~1.11.0",
21
- "@volar/typescript": "~1.11.0",
22
- "@vue/language-core": "1.9.0-alpha.3",
23
- "@vue/language-service": "1.9.0-alpha.3",
24
- "vscode-languageserver-protocol": "^3.17.5",
25
- "vue-component-meta": "1.9.0-alpha.3"
18
+ "@volar/language-core": "~2.1.0",
19
+ "@volar/language-server": "~2.1.0",
20
+ "@vue/language-core": "2.0.1",
21
+ "@vue/language-service": "2.0.1",
22
+ "vscode-languageserver-protocol": "^3.17.5"
26
23
  },
27
- "gitHead": "cf6564bc8c649151c2e72a93d0aa482d4a59a773"
24
+ "gitHead": "adedfd0983c910370d080e955702cca7d2275420"
28
25
  }
package/out/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './protocol';
2
- export * from './types';
3
- export * from '@volar/language-server/protocol';
4
- export * from '@volar/language-server/lib/types';
5
- export * from '@vue/language-service/out/types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +0,0 @@
1
- import { LanguageServerPlugin, Connection } from '@volar/language-server';
2
- export declare function createServerPlugin(connection: Connection): LanguageServerPlugin;
3
- //# sourceMappingURL=languageServerPlugin.d.ts.map
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createServerPlugin = void 0;
4
- const vue = require("@vue/language-service");
5
- const vue2 = require("@vue/language-core");
6
- const nameCasing = require("@vue/language-service");
7
- const protocol_1 = require("./protocol");
8
- const componentMeta = require("vue-component-meta/out/base");
9
- const typescript_1 = require("@volar/typescript");
10
- function createServerPlugin(connection) {
11
- const plugin = (initOptions, modules) => {
12
- if (!modules.typescript) {
13
- console.warn('No typescript found, vue-language-server will not work.');
14
- return {};
15
- }
16
- const ts = modules.typescript;
17
- const vueFileExtensions = ['vue'];
18
- const hostToVueOptions = new WeakMap();
19
- if (initOptions.additionalExtensions) {
20
- for (const additionalExtension of initOptions.additionalExtensions) {
21
- vueFileExtensions.push(additionalExtension);
22
- }
23
- }
24
- return {
25
- extraFileExtensions: vueFileExtensions.map(ext => ({ extension: ext, isMixedContent: true, scriptKind: ts.ScriptKind.Deferred })),
26
- watchFileExtensions: ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts', 'jsx', 'tsx', 'json', ...vueFileExtensions],
27
- async resolveConfig(config, ctx) {
28
- const vueOptions = await getVueCompilerOptions();
29
- if (ctx) {
30
- hostToVueOptions.set(ctx.host, vue.resolveVueCompilerOptions(vueOptions));
31
- }
32
- return vue.resolveConfig(ts, config, ctx?.host.getCompilationSettings() ?? {}, vueOptions, initOptions.codegenStack);
33
- async function getVueCompilerOptions() {
34
- const ts = modules.typescript;
35
- let vueOptions = {};
36
- if (ts && ctx) {
37
- const sys = (0, typescript_1.createSys)(ts, ctx.env);
38
- let sysVersion;
39
- let newSysVersion = await sys.sync();
40
- while (sysVersion !== newSysVersion) {
41
- sysVersion = newSysVersion;
42
- if (typeof ctx?.project.tsConfig === 'string' && ts) {
43
- vueOptions = vue2.createParsedCommandLine(ts, sys, ctx.project.tsConfig).vueOptions;
44
- }
45
- else if (typeof ctx?.project.tsConfig === 'object' && ts) {
46
- vueOptions = vue2.createParsedCommandLineByJson(ts, sys, ctx.host.rootPath, ctx.project.tsConfig).vueOptions;
47
- }
48
- newSysVersion = await sys.sync();
49
- }
50
- }
51
- vueOptions.extensions = [
52
- ...vueOptions.extensions ?? ['.vue'],
53
- ...vueFileExtensions.map(ext => '.' + ext),
54
- ];
55
- vueOptions.extensions = [...new Set(vueOptions.extensions)];
56
- return vueOptions;
57
- }
58
- },
59
- onInitialized(getService, env) {
60
- connection.onRequest(protocol_1.ParseSFCRequest.type, params => {
61
- return vue2.parse(params);
62
- });
63
- connection.onRequest(protocol_1.DetectNameCasingRequest.type, async (params) => {
64
- const languageService = await getService(params.textDocument.uri);
65
- if (languageService) {
66
- return nameCasing.detect(ts, languageService.context, params.textDocument.uri, hostToVueOptions.get(languageService.context.rawHost));
67
- }
68
- });
69
- connection.onRequest(protocol_1.GetConvertTagCasingEditsRequest.type, async (params) => {
70
- const languageService = await getService(params.textDocument.uri);
71
- if (languageService) {
72
- return nameCasing.convertTagName(ts, languageService.context, params.textDocument.uri, params.casing, hostToVueOptions.get(languageService.context.rawHost));
73
- }
74
- });
75
- connection.onRequest(protocol_1.GetDragAndDragImportEditsRequest.type, async (params) => {
76
- const languageService = await getService(params.uri);
77
- if (languageService) {
78
- return nameCasing.getDragImportEdits(ts, languageService.context, params.uri, params.importUri, params.casing);
79
- }
80
- });
81
- connection.onRequest(protocol_1.GetConvertAttrCasingEditsRequest.type, async (params) => {
82
- const languageService = await getService(params.textDocument.uri);
83
- if (languageService) {
84
- const vueOptions = hostToVueOptions.get(languageService.context.host);
85
- if (vueOptions) {
86
- return nameCasing.convertAttrName(ts, languageService.context, params.textDocument.uri, params.casing, hostToVueOptions.get(languageService.context.rawHost));
87
- }
88
- }
89
- });
90
- const checkers = new WeakMap();
91
- connection.onRequest(protocol_1.GetComponentMeta.type, async (params) => {
92
- const languageService = await getService(params.uri);
93
- if (!languageService)
94
- return;
95
- const host = languageService.context.rawHost;
96
- let checker = checkers.get(host);
97
- if (!checker) {
98
- checker = componentMeta.baseCreate(ts, host, hostToVueOptions.get(host), {}, host.rootPath + '/tsconfig.json.global.vue');
99
- checkers.set(host, checker);
100
- }
101
- return checker.getComponentMeta(env.uriToFileName(params.uri));
102
- });
103
- },
104
- };
105
- };
106
- return plugin;
107
- }
108
- exports.createServerPlugin = createServerPlugin;
109
- //# sourceMappingURL=languageServerPlugin.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=nodeServer.d.ts.map
package/out/nodeServer.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const node_1 = require("@volar/language-server/node");
4
- const languageServerPlugin_1 = require("./languageServerPlugin");
5
- const connection = (0, node_1.createConnection)();
6
- const plugin = (0, languageServerPlugin_1.createServerPlugin)(connection);
7
- (0, node_1.startLanguageServer)(connection, plugin);
8
- //# sourceMappingURL=nodeServer.js.map
package/out/types.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { InitializationOptions } from "@volar/language-server";
2
- export type VueServerInitializationOptions = InitializationOptions & {
3
- /**
4
- * @example ['vue1', 'vue2']
5
- */
6
- additionalExtensions?: string[];
7
- };
8
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=webServer.d.ts.map
package/out/webServer.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const browser_1 = require("@volar/language-server/browser");
4
- const languageServerPlugin_1 = require("./languageServerPlugin");
5
- const connection = (0, browser_1.createConnection)();
6
- const plugin = (0, languageServerPlugin_1.createServerPlugin)(connection);
7
- (0, browser_1.startLanguageServer)(connection, plugin);
8
- //# sourceMappingURL=webServer.js.map
File without changes