@vue/typescript-plugin 2.1.4 → 2.1.6

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 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 setupedProjects = new WeakSet();
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<string[] | null | undefined>;
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>;
@@ -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): string[] | undefined;
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 Set();
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
- result.add(prop.name);
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
- result.add(prop.name);
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 watchNamedPipeReady(namedPipePath) {
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
- watchNamedPipeReady(configuredPipe);
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
- watchNamedPipeReady(inferredPipe);
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/typescript-plugin",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -13,11 +13,11 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@volar/typescript": "~2.4.1",
16
- "@vue/language-core": "2.1.4",
16
+ "@vue/language-core": "2.1.6",
17
17
  "@vue/shared": "^3.4.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "latest"
21
21
  },
22
- "gitHead": "5e197d08eaef57209ff2927c943ba1db3bf4eff6"
22
+ "gitHead": "fd61953ce9eb924eeaf4df0bf8d2237267321194"
23
23
  }