@vue/typescript-plugin 2.0.11 → 2.0.12
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/lib/server.js +1 -1
- package/lib/utils.js +30 -1
- package/package.json +4 -4
package/lib/server.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -33,12 +33,16 @@ exports.updatePipeTable = updatePipeTable;
|
|
|
33
33
|
function connect(path) {
|
|
34
34
|
return new Promise(resolve => {
|
|
35
35
|
const client = net.connect(path);
|
|
36
|
+
client.setTimeout(1000);
|
|
36
37
|
client.on('connect', () => {
|
|
37
38
|
resolve(client);
|
|
38
39
|
});
|
|
39
40
|
client.on('error', () => {
|
|
40
41
|
return resolve(undefined);
|
|
41
42
|
});
|
|
43
|
+
client.on('timeout', () => {
|
|
44
|
+
return resolve(undefined);
|
|
45
|
+
});
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
exports.connect = connect;
|
|
@@ -49,7 +53,7 @@ async function searchNamedPipeServerForFile(fileName) {
|
|
|
49
53
|
const inferredServers = servers
|
|
50
54
|
.filter(item => item.serverKind === 0)
|
|
51
55
|
.sort((a, b) => b.currentDirectory.length - a.currentDirectory.length);
|
|
52
|
-
for (const server of configuredServers) {
|
|
56
|
+
for (const server of configuredServers.sort((a, b) => sortTSConfigs(fileName, a.currentDirectory, b.currentDirectory))) {
|
|
53
57
|
const client = await connect(server.path);
|
|
54
58
|
if (client) {
|
|
55
59
|
const projectInfo = await sendRequestWorker({ type: 'projectInfoForFile', args: [fileName] }, client);
|
|
@@ -74,9 +78,26 @@ async function searchNamedPipeServerForFile(fileName) {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
exports.searchNamedPipeServerForFile = searchNamedPipeServerForFile;
|
|
81
|
+
function sortTSConfigs(file, a, b) {
|
|
82
|
+
const inA = isFileInDir(file, path.dirname(a));
|
|
83
|
+
const inB = isFileInDir(file, path.dirname(b));
|
|
84
|
+
if (inA !== inB) {
|
|
85
|
+
const aWeight = inA ? 1 : 0;
|
|
86
|
+
const bWeight = inB ? 1 : 0;
|
|
87
|
+
return bWeight - aWeight;
|
|
88
|
+
}
|
|
89
|
+
const aLength = a.split('/').length;
|
|
90
|
+
const bLength = b.split('/').length;
|
|
91
|
+
return bLength - aLength;
|
|
92
|
+
}
|
|
93
|
+
function isFileInDir(fileName, dir) {
|
|
94
|
+
const relative = path.relative(dir, fileName);
|
|
95
|
+
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
96
|
+
}
|
|
77
97
|
function sendRequestWorker(request, client) {
|
|
78
98
|
return new Promise(resolve => {
|
|
79
99
|
let dataChunks = [];
|
|
100
|
+
client.setTimeout(5000);
|
|
80
101
|
client.on('data', chunk => {
|
|
81
102
|
dataChunks.push(chunk);
|
|
82
103
|
});
|
|
@@ -99,6 +120,14 @@ function sendRequestWorker(request, client) {
|
|
|
99
120
|
}
|
|
100
121
|
resolve(json);
|
|
101
122
|
});
|
|
123
|
+
client.on('error', err => {
|
|
124
|
+
console.error('[Vue Named Pipe Client] Error:', err.message);
|
|
125
|
+
resolve(undefined);
|
|
126
|
+
});
|
|
127
|
+
client.on('timeout', () => {
|
|
128
|
+
console.error('[Vue Named Pipe Client] Timeout');
|
|
129
|
+
resolve(undefined);
|
|
130
|
+
});
|
|
102
131
|
client.write(JSON.stringify(request));
|
|
103
132
|
});
|
|
104
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"directory": "packages/typescript-plugin"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/typescript": "
|
|
16
|
-
"@vue/language-core": "2.0.
|
|
15
|
+
"@volar/typescript": "2.2.0-alpha.7",
|
|
16
|
+
"@vue/language-core": "2.0.12",
|
|
17
17
|
"@vue/shared": "^3.4.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "latest"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "c1c4e1a2a6c32da59351641bd41bf7f5db0cac69"
|
|
23
23
|
}
|