@vue/typescript-plugin 3.0.0-beta.1 → 3.0.0-beta.3
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 +19 -10
- package/lib/common.js +29 -6
- package/lib/requests/getComponentProps.js +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ module.exports = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)(
|
|
|
29
29
|
info.project['program'].__vue__ = { language };
|
|
30
30
|
}
|
|
31
31
|
}, 50);
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
function getVueCompilerOptions() {
|
|
35
35
|
if (info.project.projectKind === ts.server.ProjectKind.Configured) {
|
|
@@ -58,47 +58,56 @@ module.exports = (0, createLanguageServicePlugin_1.createLanguageServicePlugin)(
|
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
session.vueCommandsAdded = true;
|
|
61
|
-
session.addProtocolHandler('
|
|
61
|
+
session.addProtocolHandler('_vue:projectInfo', ({ arguments: args }) => {
|
|
62
|
+
return session.handlers.get('projectInfo')?.({ arguments: args });
|
|
63
|
+
});
|
|
64
|
+
session.addProtocolHandler('_vue:documentHighlights-full', ({ arguments: args }) => {
|
|
65
|
+
return session.handlers.get('documentHighlights-full')?.({ arguments: args });
|
|
66
|
+
});
|
|
67
|
+
session.addProtocolHandler('_vue:quickinfo', ({ arguments: args }) => {
|
|
68
|
+
return session.handlers.get('quickinfo')?.({ arguments: args });
|
|
69
|
+
});
|
|
70
|
+
session.addProtocolHandler('_vue:collectExtractProps', ({ arguments: args }) => {
|
|
62
71
|
return {
|
|
63
72
|
response: collectExtractProps_1.collectExtractProps.apply(getRequestContext(args[0]), args),
|
|
64
73
|
};
|
|
65
74
|
});
|
|
66
|
-
session.addProtocolHandler('
|
|
75
|
+
session.addProtocolHandler('_vue:getImportPathForFile', ({ arguments: args }) => {
|
|
67
76
|
return {
|
|
68
77
|
response: getImportPathForFile_1.getImportPathForFile.apply(getRequestContext(args[0]), args),
|
|
69
78
|
};
|
|
70
79
|
});
|
|
71
|
-
session.addProtocolHandler('
|
|
80
|
+
session.addProtocolHandler('_vue:getPropertiesAtLocation', ({ arguments: args }) => {
|
|
72
81
|
return {
|
|
73
82
|
response: getPropertiesAtLocation_1.getPropertiesAtLocation.apply(getRequestContext(args[0]), args),
|
|
74
83
|
};
|
|
75
84
|
});
|
|
76
|
-
session.addProtocolHandler('
|
|
85
|
+
session.addProtocolHandler('_vue:getComponentNames', ({ arguments: args }) => {
|
|
77
86
|
return {
|
|
78
87
|
response: getComponentNames_1.getComponentNames.apply(getRequestContext(args[0]), args) ?? [],
|
|
79
88
|
};
|
|
80
89
|
});
|
|
81
|
-
session.addProtocolHandler('
|
|
90
|
+
session.addProtocolHandler('_vue:getComponentProps', ({ arguments: args }) => {
|
|
82
91
|
return {
|
|
83
92
|
response: getComponentProps_1.getComponentProps.apply(getRequestContext(args[0]), args),
|
|
84
93
|
};
|
|
85
94
|
});
|
|
86
|
-
session.addProtocolHandler('
|
|
95
|
+
session.addProtocolHandler('_vue:getComponentEvents', ({ arguments: args }) => {
|
|
87
96
|
return {
|
|
88
97
|
response: getComponentEvents_1.getComponentEvents.apply(getRequestContext(args[0]), args),
|
|
89
98
|
};
|
|
90
99
|
});
|
|
91
|
-
session.addProtocolHandler('
|
|
100
|
+
session.addProtocolHandler('_vue:getComponentDirectives', ({ arguments: args }) => {
|
|
92
101
|
return {
|
|
93
102
|
response: getComponentDirectives_1.getComponentDirectives.apply(getRequestContext(args[0]), args),
|
|
94
103
|
};
|
|
95
104
|
});
|
|
96
|
-
session.addProtocolHandler('
|
|
105
|
+
session.addProtocolHandler('_vue:getElementAttrs', ({ arguments: args }) => {
|
|
97
106
|
return {
|
|
98
107
|
response: getElementAttrs_1.getElementAttrs.apply(getRequestContext(args[0]), args),
|
|
99
108
|
};
|
|
100
109
|
});
|
|
101
|
-
session.addProtocolHandler('
|
|
110
|
+
session.addProtocolHandler('_vue:getElementNames', ({ arguments: args }) => {
|
|
102
111
|
return {
|
|
103
112
|
response: getElementNames_1.getElementNames.apply(getRequestContext(args[0]), args),
|
|
104
113
|
};
|
package/lib/common.js
CHANGED
|
@@ -10,7 +10,7 @@ function createVueLanguageServiceProxy(ts, language, languageService, vueOptions
|
|
|
10
10
|
const proxyCache = new Map();
|
|
11
11
|
const getProxyMethod = (target, p) => {
|
|
12
12
|
switch (p) {
|
|
13
|
-
case 'getCompletionsAtPosition': return getCompletionsAtPosition(vueOptions, target[p]);
|
|
13
|
+
case 'getCompletionsAtPosition': return getCompletionsAtPosition(ts, language, vueOptions, asScriptId, target[p]);
|
|
14
14
|
case 'getCompletionEntryDetails': return getCompletionEntryDetails(language, asScriptId, target[p]);
|
|
15
15
|
case 'getCodeFixesAtPosition': return getCodeFixesAtPosition(target[p]);
|
|
16
16
|
case 'getDefinitionAndBoundSpan': return getDefinitionAndBoundSpan(ts, language, languageService, vueOptions, asScriptId, target[p]);
|
|
@@ -37,7 +37,7 @@ function createVueLanguageServiceProxy(ts, language, languageService, vueOptions
|
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function getCompletionsAtPosition(vueOptions, getCompletionsAtPosition) {
|
|
40
|
+
function getCompletionsAtPosition(ts, language, vueOptions, asScriptId, getCompletionsAtPosition) {
|
|
41
41
|
return (filePath, position, options, formattingSettings) => {
|
|
42
42
|
const fileName = filePath.replace(windowsPathReg, '/');
|
|
43
43
|
const result = getCompletionsAtPosition(fileName, position, options, formattingSettings);
|
|
@@ -45,6 +45,30 @@ function getCompletionsAtPosition(vueOptions, getCompletionsAtPosition) {
|
|
|
45
45
|
// filter __VLS_
|
|
46
46
|
result.entries = result.entries.filter(entry => !entry.name.includes('__VLS_')
|
|
47
47
|
&& !entry.labelDetails?.description?.includes('__VLS_'));
|
|
48
|
+
// filter global variables in template and styles
|
|
49
|
+
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
50
|
+
const root = sourceScript?.generated?.root;
|
|
51
|
+
if (root instanceof language_core_1.VueVirtualCode) {
|
|
52
|
+
const blocks = [
|
|
53
|
+
root.sfc.template,
|
|
54
|
+
...root.sfc.styles,
|
|
55
|
+
];
|
|
56
|
+
const ranges = blocks.filter(Boolean).map(block => [
|
|
57
|
+
block.startTagEnd,
|
|
58
|
+
block.endTagStart,
|
|
59
|
+
]);
|
|
60
|
+
if (ranges.some(([start, end]) => position >= start && position <= end)) {
|
|
61
|
+
const globalsOrKeywords = ts.Completions.SortText.GlobalsOrKeywords;
|
|
62
|
+
const sortTexts = new Set([
|
|
63
|
+
globalsOrKeywords,
|
|
64
|
+
'z' + globalsOrKeywords,
|
|
65
|
+
globalsOrKeywords + '1',
|
|
66
|
+
]);
|
|
67
|
+
result.entries = result.entries.filter(entry => !(entry.kind === 'const' && entry.name in vueOptions.macros) && (entry.kind !== 'var' && entry.kind !== 'function'
|
|
68
|
+
|| !sortTexts.has(entry.sortText)
|
|
69
|
+
|| (0, shared_1.isGloballyAllowed)(entry.name)));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
48
72
|
// modify label
|
|
49
73
|
for (const item of result.entries) {
|
|
50
74
|
if (item.source) {
|
|
@@ -88,7 +112,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
88
112
|
// @ts-expect-error
|
|
89
113
|
if (args[6]?.__isComponentAutoImport) {
|
|
90
114
|
// @ts-expect-error
|
|
91
|
-
const {
|
|
115
|
+
const { originalName, newName } = args[6].__isComponentAutoImport;
|
|
92
116
|
for (const codeAction of details?.codeActions ?? []) {
|
|
93
117
|
for (const change of codeAction.changes) {
|
|
94
118
|
for (const textChange of change.textChanges) {
|
|
@@ -100,7 +124,7 @@ function getCompletionEntryDetails(language, asScriptId, getCompletionEntryDetai
|
|
|
100
124
|
// @ts-expect-error
|
|
101
125
|
if (args[6]?.__isAutoImport) {
|
|
102
126
|
// @ts-expect-error
|
|
103
|
-
const { fileName } = args[6]
|
|
127
|
+
const { fileName } = args[6].__isAutoImport;
|
|
104
128
|
const sourceScript = language.scripts.get(asScriptId(fileName));
|
|
105
129
|
if (sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode) {
|
|
106
130
|
const sfc = sourceScript.generated.root.vueSfc;
|
|
@@ -260,8 +284,7 @@ function getEncodedSemanticClassifications(ts, language, languageService, asScri
|
|
|
260
284
|
start: span.start - template.startTagEnd,
|
|
261
285
|
length: span.length,
|
|
262
286
|
})) {
|
|
263
|
-
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256
|
|
264
|
-
);
|
|
287
|
+
result.spans.push(componentSpan.start + template.startTagEnd, componentSpan.length, 256);
|
|
265
288
|
}
|
|
266
289
|
}
|
|
267
290
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@volar/typescript": "2.4.14",
|
|
17
|
-
"@vue/language-core": "3.0.0-beta.
|
|
17
|
+
"@vue/language-core": "3.0.0-beta.3",
|
|
18
18
|
"@vue/shared": "^3.5.0",
|
|
19
19
|
"path-browserify": "^1.0.1"
|
|
20
20
|
},
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@types/node": "^22.10.4",
|
|
23
23
|
"@types/path-browserify": "^1.0.1"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "17e3beabc13e9eb59a82fb1a9f0252fd6685e444"
|
|
26
26
|
}
|