@vue/language-server 1.7.0
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.
- package/LICENSE +21 -0
- package/bin/vue-language-server.js +8 -0
- package/out/index.d.ts +5 -0
- package/out/index.js +24 -0
- package/out/languageServerPlugin.d.ts +2 -0
- package/out/languageServerPlugin.js +113 -0
- package/out/nodeServer.d.ts +1 -0
- package/out/nodeServer.js +8 -0
- package/out/protocol.d.ts +44 -0
- package/out/protocol.js +25 -0
- package/out/types.d.ts +10 -0
- package/out/types.js +3 -0
- package/out/webServer.d.ts +1 -0
- package/out/webServer.js +8 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Johnson Chu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/out/index.d.ts
ADDED
package/out/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./protocol"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
// export protocol and types of parent package
|
|
20
|
+
__exportStar(require("@volar/language-server/out/protocol"), exports);
|
|
21
|
+
__exportStar(require("@volar/language-server/out/types"), exports);
|
|
22
|
+
// only export types of depend packages
|
|
23
|
+
__exportStar(require("@vue/language-service/out/types"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,113 @@
|
|
|
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");
|
|
9
|
+
function createServerPlugin(connection) {
|
|
10
|
+
const plugin = (initOptions, modules) => {
|
|
11
|
+
if (!modules.typescript) {
|
|
12
|
+
console.warn('No typescript found, vue-language-server will not work.');
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const ts = modules.typescript;
|
|
16
|
+
const vueFileExtensions = ['vue'];
|
|
17
|
+
const hostToVueOptions = new WeakMap();
|
|
18
|
+
if (initOptions.additionalExtensions) {
|
|
19
|
+
for (const additionalExtension of initOptions.additionalExtensions) {
|
|
20
|
+
vueFileExtensions.push(additionalExtension);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
extraFileExtensions: vueFileExtensions.map(ext => ({ extension: ext, isMixedContent: true, scriptKind: ts.ScriptKind.Deferred })),
|
|
25
|
+
watchFileExtensions: ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts', 'jsx', 'tsx', 'json', ...vueFileExtensions],
|
|
26
|
+
resolveConfig(config, ctx) {
|
|
27
|
+
const vueOptions = getVueCompilerOptions();
|
|
28
|
+
const vueLanguageServiceSettings = getVueLanguageServiceSettings();
|
|
29
|
+
if (ctx) {
|
|
30
|
+
hostToVueOptions.set(ctx.host, vueOptions);
|
|
31
|
+
}
|
|
32
|
+
return vue.resolveConfig(config, ctx?.host.getCompilationSettings() ?? {}, vueOptions, vueLanguageServiceSettings, ts);
|
|
33
|
+
function getVueCompilerOptions() {
|
|
34
|
+
const ts = modules.typescript;
|
|
35
|
+
let vueOptions;
|
|
36
|
+
if (typeof ctx?.project.tsConfig === 'string' && ts) {
|
|
37
|
+
vueOptions = vue2.createParsedCommandLine(ts, ctx.sys, ctx.project.tsConfig).vueOptions;
|
|
38
|
+
}
|
|
39
|
+
else if (typeof ctx?.project.tsConfig === 'object' && ts) {
|
|
40
|
+
vueOptions = vue2.createParsedCommandLineByJson(ts, ctx.sys, ctx.host.getCurrentDirectory(), ctx.project.tsConfig).vueOptions;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
vueOptions = vue2.resolveVueCompilerOptions({});
|
|
44
|
+
}
|
|
45
|
+
vueOptions.extensions = [
|
|
46
|
+
...vueOptions.extensions,
|
|
47
|
+
...vueFileExtensions.map(ext => '.' + ext),
|
|
48
|
+
];
|
|
49
|
+
vueOptions.extensions = [...new Set(vueOptions.extensions)];
|
|
50
|
+
return vueOptions;
|
|
51
|
+
}
|
|
52
|
+
function getVueLanguageServiceSettings() {
|
|
53
|
+
const settings = {};
|
|
54
|
+
if (initOptions.json && ctx) {
|
|
55
|
+
settings.json = { schemas: [] };
|
|
56
|
+
for (const blockType in initOptions.json.customBlockSchemaUrls) {
|
|
57
|
+
const url = initOptions.json.customBlockSchemaUrls[blockType];
|
|
58
|
+
settings.json.schemas?.push({
|
|
59
|
+
fileMatch: [`*.customBlock_${blockType}_*.json*`],
|
|
60
|
+
uri: new URL(url, ctx.project.rootUri.toString() + '/').toString(),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return settings;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onInitialized(getService, env) {
|
|
68
|
+
connection.onRequest(protocol_1.ParseSFCRequest.type, params => {
|
|
69
|
+
return vue2.parse(params);
|
|
70
|
+
});
|
|
71
|
+
connection.onRequest(protocol_1.DetectNameCasingRequest.type, async (params) => {
|
|
72
|
+
const languageService = await getService(params.textDocument.uri);
|
|
73
|
+
if (languageService?.context.typescript) {
|
|
74
|
+
return nameCasing.detect(ts, languageService.context, params.textDocument.uri);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
connection.onRequest(protocol_1.GetConvertTagCasingEditsRequest.type, async (params) => {
|
|
78
|
+
const languageService = await getService(params.textDocument.uri);
|
|
79
|
+
if (languageService?.context.typescript) {
|
|
80
|
+
return nameCasing.convertTagName(ts, languageService.context, params.textDocument.uri, params.casing);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
connection.onRequest(protocol_1.GetConvertAttrCasingEditsRequest.type, async (params) => {
|
|
84
|
+
const languageService = await getService(params.textDocument.uri);
|
|
85
|
+
if (languageService?.context.typescript) {
|
|
86
|
+
const vueOptions = hostToVueOptions.get(languageService.context.host);
|
|
87
|
+
if (vueOptions) {
|
|
88
|
+
return nameCasing.convertAttrName(ts, languageService.context, params.textDocument.uri, params.casing);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const checkers = new WeakMap();
|
|
93
|
+
connection.onRequest(protocol_1.GetComponentMeta.type, async (params) => {
|
|
94
|
+
const languageService = await getService(params.uri);
|
|
95
|
+
if (!languageService?.context.typescript)
|
|
96
|
+
return;
|
|
97
|
+
let checker = checkers.get(languageService.context.host);
|
|
98
|
+
if (!checker) {
|
|
99
|
+
checker = componentMeta.baseCreate({
|
|
100
|
+
...languageService.context.host,
|
|
101
|
+
getVueCompilationSettings: () => hostToVueOptions.get(languageService.context.host),
|
|
102
|
+
}, {}, languageService.context.host.getCurrentDirectory() + '/tsconfig.json.global.vue', ts);
|
|
103
|
+
checkers.set(languageService.context.host, checker);
|
|
104
|
+
}
|
|
105
|
+
return checker.getComponentMeta(env.uriToFileName(params.uri));
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
return plugin;
|
|
111
|
+
}
|
|
112
|
+
exports.createServerPlugin = createServerPlugin;
|
|
113
|
+
//# sourceMappingURL=languageServerPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
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
|
+
export declare namespace DetectNameCasingRequest {
|
|
11
|
+
type ParamsType = {
|
|
12
|
+
textDocument: vscode.TextDocumentIdentifier;
|
|
13
|
+
};
|
|
14
|
+
type ResponseType = {
|
|
15
|
+
tag: TagNameCasing[];
|
|
16
|
+
attr: AttrNameCasing[];
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
type ErrorType = never;
|
|
19
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace GetConvertTagCasingEditsRequest {
|
|
22
|
+
type ParamsType = {
|
|
23
|
+
textDocument: vscode.TextDocumentIdentifier;
|
|
24
|
+
casing: TagNameCasing;
|
|
25
|
+
};
|
|
26
|
+
type ResponseType = vscode.TextEdit[] | null | undefined;
|
|
27
|
+
type ErrorType = never;
|
|
28
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
29
|
+
}
|
|
30
|
+
export declare namespace GetConvertAttrCasingEditsRequest {
|
|
31
|
+
type ParamsType = {
|
|
32
|
+
textDocument: vscode.TextDocumentIdentifier;
|
|
33
|
+
casing: AttrNameCasing;
|
|
34
|
+
};
|
|
35
|
+
type ResponseType = vscode.TextEdit[] | null | undefined;
|
|
36
|
+
type ErrorType = never;
|
|
37
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
38
|
+
}
|
|
39
|
+
export declare namespace ParseSFCRequest {
|
|
40
|
+
type ParamsType = string;
|
|
41
|
+
type ResponseType = SFCParseResult;
|
|
42
|
+
type ErrorType = never;
|
|
43
|
+
const type: vscode.RequestType<string, SFCParseResult, never>;
|
|
44
|
+
}
|
package/out/protocol.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParseSFCRequest = exports.GetConvertAttrCasingEditsRequest = exports.GetConvertTagCasingEditsRequest = exports.DetectNameCasingRequest = exports.GetComponentMeta = void 0;
|
|
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 || (exports.GetComponentMeta = {}));
|
|
9
|
+
var DetectNameCasingRequest;
|
|
10
|
+
(function (DetectNameCasingRequest) {
|
|
11
|
+
DetectNameCasingRequest.type = new vscode.RequestType('vue/detectTagCasing');
|
|
12
|
+
})(DetectNameCasingRequest = exports.DetectNameCasingRequest || (exports.DetectNameCasingRequest = {}));
|
|
13
|
+
var GetConvertTagCasingEditsRequest;
|
|
14
|
+
(function (GetConvertTagCasingEditsRequest) {
|
|
15
|
+
GetConvertTagCasingEditsRequest.type = new vscode.RequestType('vue/convertTagNameCasing');
|
|
16
|
+
})(GetConvertTagCasingEditsRequest = exports.GetConvertTagCasingEditsRequest || (exports.GetConvertTagCasingEditsRequest = {}));
|
|
17
|
+
var GetConvertAttrCasingEditsRequest;
|
|
18
|
+
(function (GetConvertAttrCasingEditsRequest) {
|
|
19
|
+
GetConvertAttrCasingEditsRequest.type = new vscode.RequestType('vue/convertPropNameCasing');
|
|
20
|
+
})(GetConvertAttrCasingEditsRequest = exports.GetConvertAttrCasingEditsRequest || (exports.GetConvertAttrCasingEditsRequest = {}));
|
|
21
|
+
var ParseSFCRequest;
|
|
22
|
+
(function (ParseSFCRequest) {
|
|
23
|
+
ParseSFCRequest.type = new vscode.RequestType('vue/parseSfc');
|
|
24
|
+
})(ParseSFCRequest = exports.ParseSFCRequest || (exports.ParseSFCRequest = {}));
|
|
25
|
+
//# sourceMappingURL=protocol.js.map
|
package/out/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InitializationOptions } from "@volar/language-server";
|
|
2
|
+
export type VueServerInitializationOptions = InitializationOptions & {
|
|
3
|
+
json?: {
|
|
4
|
+
customBlockSchemaUrls?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @example ['vue1', 'vue2']
|
|
8
|
+
*/
|
|
9
|
+
additionalExtensions?: string[];
|
|
10
|
+
};
|
package/out/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/out/webServer.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vue/language-server",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"main": "out/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"out/**/*.js",
|
|
8
|
+
"out/**/*.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"vue-language-server": "./bin/vue-language-server.js"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/vuejs/language-tools.git",
|
|
16
|
+
"directory": "packages/vue-language-server"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@volar/language-core": "1.5.4",
|
|
20
|
+
"@volar/language-server": "1.5.4",
|
|
21
|
+
"@vue/language-core": "1.7.0",
|
|
22
|
+
"@vue/language-service": "1.7.0",
|
|
23
|
+
"vscode-languageserver-protocol": "^3.17.3",
|
|
24
|
+
"vue-component-meta": "1.7.0"
|
|
25
|
+
}
|
|
26
|
+
}
|