@vue/typescript-plugin 2.1.5 → 2.1.8
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/index.js +2 -34
- package/lib/client.d.ts +4 -1
- package/lib/common.d.ts +1 -1
- package/lib/common.js +2 -2
- package/lib/requests/collectExtractProps.js +1 -1
- package/lib/requests/componentInfos.d.ts +4 -1
- package/lib/requests/componentInfos.js +40 -4
- package/lib/utils.js +9 -3
- package/package.json +6 -5
package/index.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const createLanguageServicePlugin_1 = require("@volar/typescript/lib/quickstart/createLanguageServicePlugin");
|
|
3
|
-
const path = require("path");
|
|
4
3
|
const vue = require("@vue/language-core");
|
|
5
4
|
const common_1 = require("./lib/common");
|
|
6
5
|
const server_1 = require("./lib/server");
|
|
7
6
|
const windowsPathReg = /\\/g;
|
|
8
7
|
const vueCompilerOptions = new WeakMap();
|
|
9
|
-
const
|
|
10
|
-
const basePlugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)((ts, info) => {
|
|
8
|
+
const plugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)((ts, info) => {
|
|
11
9
|
const vueOptions = getVueCompilerOptions();
|
|
12
|
-
const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(),
|
|
13
|
-
...vueOptions,
|
|
14
|
-
__setupedGlobalTypes: () => setupedProjects.has(info.project),
|
|
15
|
-
}, id => id);
|
|
10
|
+
const languagePlugin = vue.createVueLanguagePlugin(ts, info.languageServiceHost.getCompilationSettings(), vueOptions, id => id);
|
|
16
11
|
vueCompilerOptions.set(info.project, vueOptions);
|
|
17
12
|
return {
|
|
18
13
|
languagePlugins: [languagePlugin],
|
|
@@ -41,32 +36,5 @@ const basePlugin = (0, createLanguageServicePlugin_1.createLanguageServicePlugin
|
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
});
|
|
44
|
-
const plugin = mods => {
|
|
45
|
-
const pluginModule = basePlugin(mods);
|
|
46
|
-
return {
|
|
47
|
-
...pluginModule,
|
|
48
|
-
getExternalFiles(proj, updateLevel = 0) {
|
|
49
|
-
const options = vueCompilerOptions.get(proj);
|
|
50
|
-
if (updateLevel >= 1 && options) {
|
|
51
|
-
try {
|
|
52
|
-
let dir = proj.getCurrentDirectory();
|
|
53
|
-
while (!proj.directoryExists(path.resolve(dir, 'node_modules'))) {
|
|
54
|
-
const parentDir = path.resolve(dir, '..');
|
|
55
|
-
if (dir === parentDir) {
|
|
56
|
-
throw 0;
|
|
57
|
-
}
|
|
58
|
-
dir = parentDir;
|
|
59
|
-
}
|
|
60
|
-
const globalTypesPath = path.resolve(dir, `node_modules/.vue-global-types/${options.lib}_${options.target}_${options.strictTemplates}.d.ts`);
|
|
61
|
-
const globalTypesContents = vue.generateGlobalTypes('global', options.lib, options.target, options.strictTemplates);
|
|
62
|
-
proj.writeFile(globalTypesPath, globalTypesContents);
|
|
63
|
-
setupedProjects.add(proj);
|
|
64
|
-
}
|
|
65
|
-
catch { }
|
|
66
|
-
}
|
|
67
|
-
return pluginModule.getExternalFiles?.(proj, updateLevel) ?? [];
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
39
|
module.exports = plugin;
|
|
72
40
|
//# sourceMappingURL=index.js.map
|
package/lib/client.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ export declare function collectExtractProps(...args: Parameters<typeof import('.
|
|
|
6
6
|
export declare function getImportPathForFile(...args: Parameters<typeof import('./requests/getImportPathForFile.js')['getImportPathForFile']>): Promise<string | null | undefined>;
|
|
7
7
|
export declare function getPropertiesAtLocation(...args: Parameters<typeof import('./requests/getPropertiesAtLocation.js')['getPropertiesAtLocation']>): Promise<string[] | null | undefined>;
|
|
8
8
|
export declare function getQuickInfoAtPosition(...args: Parameters<typeof import('./requests/getQuickInfoAtPosition.js')['getQuickInfoAtPosition']>): Promise<string | null | undefined>;
|
|
9
|
-
export declare function getComponentProps(...args: Parameters<typeof import('./requests/componentInfos.js')['getComponentProps']>): Promise<
|
|
9
|
+
export declare function getComponentProps(...args: Parameters<typeof import('./requests/componentInfos.js')['getComponentProps']>): Promise<{
|
|
10
|
+
name: string;
|
|
11
|
+
commentMarkdown: string;
|
|
12
|
+
}[] | null | undefined>;
|
|
10
13
|
export declare function getComponentEvents(...args: Parameters<typeof import('./requests/componentInfos.js')['getComponentEvents']>): Promise<string[] | null | undefined>;
|
|
11
14
|
export declare function getTemplateContextProps(...args: Parameters<typeof import('./requests/componentInfos.js')['getTemplateContextProps']>): Promise<string[] | null | undefined>;
|
|
12
15
|
export declare function getComponentNames(...args: Parameters<typeof import('./requests/componentInfos.js')['getComponentNames']>): Promise<string[] | null | undefined>;
|
package/lib/common.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { Language, VueCompilerOptions, VueVirtualCode } from '@vue/language-core
|
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { RequestContext } from './requests/types';
|
|
4
4
|
export declare function proxyLanguageServiceForVue<T>(ts: typeof import('typescript'), language: Language<T>, languageService: ts.LanguageService, vueOptions: VueCompilerOptions, asScriptId: (fileName: string) => T): ts.LanguageService;
|
|
5
|
-
export declare function getComponentSpans(this: Pick<RequestContext, 'typescript' | 'languageService'>, vueCode: VueVirtualCode, template: NonNullable<VueVirtualCode['
|
|
5
|
+
export declare function getComponentSpans(this: Pick<RequestContext, 'typescript' | 'languageService'>, vueCode: VueVirtualCode, template: NonNullable<VueVirtualCode['_sfc']['template']>, spanTemplateRange: ts.TextSpan): ts.TextSpan[];
|
package/lib/common.js
CHANGED
|
@@ -102,7 +102,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
102
102
|
const { fileName } = args[6]?.__isAutoImport;
|
|
103
103
|
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
104
104
|
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
105
|
-
const sfc = sourceScript.generated.root.
|
|
105
|
+
const sfc = sourceScript.generated.root._vueSfc.get();
|
|
106
106
|
if (!sfc?.descriptor.script && !sfc?.descriptor.scriptSetup) {
|
|
107
107
|
for (const codeAction of details?.codeActions ?? []) {
|
|
108
108
|
for (const change of codeAction.changes) {
|
|
@@ -172,7 +172,7 @@ function getEncodedSemanticClassifications(ts, language, languageService, asScri
|
|
|
172
172
|
const result = getEncodedSemanticClassifications(fileName, span, format);
|
|
173
173
|
const file = language.scripts.get(asScriptId(fileName));
|
|
174
174
|
if (file?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
175
|
-
const { template } = file.generated.root.
|
|
175
|
+
const { template } = file.generated.root._sfc;
|
|
176
176
|
if (template) {
|
|
177
177
|
for (const componentSpan of getComponentSpans.call({ typescript: ts, languageService }, file.generated.root, template, {
|
|
178
178
|
start: span.start - template.startTagEnd,
|
|
@@ -14,7 +14,7 @@ function collectExtractProps(fileName, templateCodeRange) {
|
|
|
14
14
|
const checker = program.getTypeChecker();
|
|
15
15
|
const script = volarFile.generated?.languagePlugin.typescript?.getServiceScript(volarFile.generated.root);
|
|
16
16
|
const maps = script ? [...language.maps.forEach(script.code)].map(([_sourceScript, map]) => map) : [];
|
|
17
|
-
const sfc = volarFile.generated.root.
|
|
17
|
+
const sfc = volarFile.generated.root._sfc;
|
|
18
18
|
sourceFile.forEachChild(function visit(node) {
|
|
19
19
|
if (ts.isPropertyAccessExpression(node)
|
|
20
20
|
&& ts.isIdentifier(node.expression)
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as vue from '@vue/language-core';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { RequestContext } from './types';
|
|
4
|
-
export declare function getComponentProps(this: RequestContext, fileName: string, tag: string, requiredOnly?: boolean):
|
|
4
|
+
export declare function getComponentProps(this: RequestContext, fileName: string, tag: string, requiredOnly?: boolean): {
|
|
5
|
+
name: string;
|
|
6
|
+
commentMarkdown: string;
|
|
7
|
+
}[] | undefined;
|
|
5
8
|
export declare function getComponentEvents(this: RequestContext, fileName: string, tag: string): string[] | undefined;
|
|
6
9
|
export declare function getTemplateContextProps(this: RequestContext, fileName: string): string[] | undefined;
|
|
7
10
|
export declare function getComponentNames(this: RequestContext, fileName: string): string[] | undefined;
|
|
@@ -40,7 +40,7 @@ function getComponentProps(fileName, tag, requiredOnly = false) {
|
|
|
40
40
|
return [];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
const result = new
|
|
43
|
+
const result = new Map();
|
|
44
44
|
for (const sig of componentType.getCallSignatures()) {
|
|
45
45
|
const propParam = sig.parameters[0];
|
|
46
46
|
if (propParam) {
|
|
@@ -48,7 +48,9 @@ function getComponentProps(fileName, tag, requiredOnly = false) {
|
|
|
48
48
|
const props = propsType.getProperties();
|
|
49
49
|
for (const prop of props) {
|
|
50
50
|
if (!requiredOnly || !(prop.flags & ts.SymbolFlags.Optional)) {
|
|
51
|
-
|
|
51
|
+
const name = prop.name;
|
|
52
|
+
const commentMarkdown = generateCommentMarkdown(prop.getDocumentationComment(checker), prop.getJsDocTags());
|
|
53
|
+
result.set(name, { name, commentMarkdown });
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -64,12 +66,14 @@ function getComponentProps(fileName, tag, requiredOnly = false) {
|
|
|
64
66
|
continue;
|
|
65
67
|
}
|
|
66
68
|
if (!requiredOnly || !(prop.flags & ts.SymbolFlags.Optional)) {
|
|
67
|
-
|
|
69
|
+
const name = prop.name;
|
|
70
|
+
const commentMarkdown = generateCommentMarkdown(prop.getDocumentationComment(checker), prop.getJsDocTags());
|
|
71
|
+
result.set(name, { name, commentMarkdown });
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
return [...result];
|
|
76
|
+
return [...result.values()];
|
|
73
77
|
}
|
|
74
78
|
function getComponentEvents(fileName, tag) {
|
|
75
79
|
const { typescript: ts, language, languageService, getFileId } = this;
|
|
@@ -214,4 +218,36 @@ function searchVariableDeclarationNode(ts, sourceFile, name) {
|
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
}
|
|
221
|
+
function generateCommentMarkdown(parts, jsDocTags) {
|
|
222
|
+
const parsedComment = _symbolDisplayPartsToMarkdown(parts);
|
|
223
|
+
const parsedJsDoc = _jsDocTagInfoToMarkdown(jsDocTags);
|
|
224
|
+
let result = [parsedComment, parsedJsDoc].filter(str => !!str).join('\n\n');
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
function _symbolDisplayPartsToMarkdown(parts) {
|
|
228
|
+
return parts.map(part => {
|
|
229
|
+
switch (part.kind) {
|
|
230
|
+
case 'keyword':
|
|
231
|
+
return `\`${part.text}\``;
|
|
232
|
+
case 'functionName':
|
|
233
|
+
return `**${part.text}**`;
|
|
234
|
+
default:
|
|
235
|
+
return part.text;
|
|
236
|
+
}
|
|
237
|
+
}).join('');
|
|
238
|
+
}
|
|
239
|
+
function _jsDocTagInfoToMarkdown(jsDocTags) {
|
|
240
|
+
return jsDocTags.map(tag => {
|
|
241
|
+
const tagName = `*@${tag.name}*`;
|
|
242
|
+
const tagText = tag.text?.map(t => {
|
|
243
|
+
if (t.kind === 'parameterName') {
|
|
244
|
+
return `\`${t.text}\``;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return t.text;
|
|
248
|
+
}
|
|
249
|
+
}).join('') || '';
|
|
250
|
+
return `${tagName} ${tagText}`;
|
|
251
|
+
}).join('\n\n');
|
|
252
|
+
}
|
|
217
253
|
//# sourceMappingURL=componentInfos.js.map
|
package/lib/utils.js
CHANGED
|
@@ -27,7 +27,7 @@ const configuredNamedPipePathPrefix = toFullPath(`vue-named-pipe-${version}-conf
|
|
|
27
27
|
const inferredNamedPipePathPrefix = toFullPath(`vue-named-pipe-${version}-inferred-`);
|
|
28
28
|
const pipes = new Map();
|
|
29
29
|
exports.onSomePipeReadyCallbacks = [];
|
|
30
|
-
function
|
|
30
|
+
function waitingForNamedPipeServerReady(namedPipePath) {
|
|
31
31
|
const socket = net.connect(namedPipePath);
|
|
32
32
|
const start = Date.now();
|
|
33
33
|
socket.on('connect', () => {
|
|
@@ -51,6 +51,10 @@ function watchNamedPipeReady(namedPipePath) {
|
|
|
51
51
|
pipes.delete(namedPipePath);
|
|
52
52
|
socket.end();
|
|
53
53
|
});
|
|
54
|
+
socket.on('timeout', () => {
|
|
55
|
+
pipes.delete(namedPipePath);
|
|
56
|
+
socket.end();
|
|
57
|
+
});
|
|
54
58
|
}
|
|
55
59
|
function getNamedPipePath(projectKind, key) {
|
|
56
60
|
return projectKind === 1
|
|
@@ -68,14 +72,14 @@ function getReadyNamedPipePaths() {
|
|
|
68
72
|
}
|
|
69
73
|
else if (!pipes.has(configuredPipe)) {
|
|
70
74
|
pipes.set(configuredPipe, 'unknown');
|
|
71
|
-
|
|
75
|
+
waitingForNamedPipeServerReady(configuredPipe);
|
|
72
76
|
}
|
|
73
77
|
if (pipes.get(inferredPipe) === 'ready') {
|
|
74
78
|
inferredPipes.push(inferredPipe);
|
|
75
79
|
}
|
|
76
80
|
else if (!pipes.has(inferredPipe)) {
|
|
77
81
|
pipes.set(inferredPipe, 'unknown');
|
|
78
|
-
|
|
82
|
+
waitingForNamedPipeServerReady(inferredPipe);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
return {
|
|
@@ -104,10 +108,12 @@ function connect(namedPipePath, timeout) {
|
|
|
104
108
|
pipes.delete(namedPipePath);
|
|
105
109
|
cleanup();
|
|
106
110
|
resolve('error');
|
|
111
|
+
socket.end();
|
|
107
112
|
};
|
|
108
113
|
const onTimeout = () => {
|
|
109
114
|
cleanup();
|
|
110
115
|
resolve('timeout');
|
|
116
|
+
socket.end();
|
|
111
117
|
};
|
|
112
118
|
const cleanup = () => {
|
|
113
119
|
socket.off('connect', onConnect);
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
7
7
|
"**/*.d.ts"
|
|
8
8
|
],
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "https://github.com/vuejs/language-tools.git",
|
|
12
13
|
"directory": "packages/typescript-plugin"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@volar/typescript": "~2.4.
|
|
16
|
-
"@vue/language-core": "2.1.
|
|
17
|
-
"@vue/shared": "^3.
|
|
16
|
+
"@volar/typescript": "~2.4.8",
|
|
17
|
+
"@vue/language-core": "2.1.8",
|
|
18
|
+
"@vue/shared": "^3.5.0"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/node": "latest"
|
|
21
22
|
},
|
|
22
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "25cccedc53e7361ed4e34296d6ecd43d7de2a095"
|
|
23
24
|
}
|