@@ -36,10 +36,10 @@ import { getQuickInfoAtPosition } from '@vue/typescript-plugin/lib/requests/getQ
36
36
export function createVueServicePlugins (
37
37
ts : typeof import ( 'typescript' ) ,
38
38
getVueOptions : ( env : ServiceEnvironment ) => VueCompilerOptions ,
39
- getTsPluginClient ?: ( context : ServiceContext ) => typeof import ( '@vue/typescript-plugin/lib/client' ) | undefined ,
39
+ getTsPluginClient = createDefaultGetTsPluginClient ( ts , getVueOptions ) ,
40
+ hybridMode = false ,
40
41
) : ServicePlugin [ ] {
41
42
const plugins : ServicePlugin [ ] = [ ] ;
42
- const hybridMode = ! ! getTsPluginClient ;
43
43
if ( ! hybridMode ) {
44
44
plugins . push ( ...createTypeScriptServicePlugins ( ts ) ) ;
45
45
for ( let i = 0 ; i < plugins . length ; i ++ ) {
@@ -61,45 +61,6 @@ export function createVueServicePlugins(
61
61
break ;
62
62
}
63
63
}
64
- getTsPluginClient = context => {
65
- if ( ! context . language . typescript ) {
66
- return ;
67
- }
68
- const requestContext = {
69
- typescript : ts ,
70
- files : context . language . files ,
71
- languageService : context . inject < ( import ( 'volar-service-typescript' ) . Provide ) , 'typescript/languageService' > ( 'typescript/languageService' ) ,
72
- vueOptions : getVueOptions ( context . env ) ,
73
- isTsPlugin : false ,
74
- getFileId : context . env . typescript ! . fileNameToUri ,
75
- } ;
76
- return {
77
- async collectExtractProps ( ...args ) {
78
- return await collectExtractProps . apply ( requestContext , args ) ;
79
- } ,
80
- async getPropertiesAtLocation ( ...args ) {
81
- return await getPropertiesAtLocation . apply ( requestContext , args ) ;
82
- } ,
83
- async getComponentEvents ( ...args ) {
84
- return await getComponentEvents . apply ( requestContext , args ) ;
85
- } ,
86
- async getComponentNames ( ...args ) {
87
- return await getComponentNames . apply ( requestContext , args ) ;
88
- } ,
89
- async getComponentProps ( ...args ) {
90
- return await getComponentProps . apply ( requestContext , args ) ;
91
- } ,
92
- async getElementAttrs ( ...args ) {
93
- return await getElementAttrs . apply ( requestContext , args ) ;
94
- } ,
95
- async getTemplateContextProps ( ...args ) {
96
- return await getTemplateContextProps . apply ( requestContext , args ) ;
97
- } ,
98
- async getQuickInfoAtPosition ( ...args ) {
99
- return await getQuickInfoAtPosition . apply ( requestContext , args ) ;
100
- } ,
101
- } ;
102
- } ;
103
64
}
104
65
else {
105
66
plugins . push (
@@ -129,3 +90,48 @@ export function createVueServicePlugins(
129
90
) ;
130
91
return plugins ;
131
92
}
93
+
94
+ export function createDefaultGetTsPluginClient (
95
+ ts : typeof import ( 'typescript' ) ,
96
+ getVueOptions : ( env : ServiceEnvironment ) => VueCompilerOptions ,
97
+ ) : ( context : ServiceContext ) => typeof import ( '@vue/typescript-plugin/lib/client' ) | undefined {
98
+ return context => {
99
+ if ( ! context . language . typescript ) {
100
+ return ;
101
+ }
102
+ const requestContext = {
103
+ typescript : ts ,
104
+ files : context . language . files ,
105
+ languageService : context . inject < ( import ( 'volar-service-typescript' ) . Provide ) , 'typescript/languageService' > ( 'typescript/languageService' ) ,
106
+ vueOptions : getVueOptions ( context . env ) ,
107
+ isTsPlugin : false ,
108
+ getFileId : context . env . typescript ! . fileNameToUri ,
109
+ } ;
110
+ return {
111
+ async collectExtractProps ( ...args ) {
112
+ return await collectExtractProps . apply ( requestContext , args ) ;
113
+ } ,
114
+ async getPropertiesAtLocation ( ...args ) {
115
+ return await getPropertiesAtLocation . apply ( requestContext , args ) ;
116
+ } ,
117
+ async getComponentEvents ( ...args ) {
118
+ return await getComponentEvents . apply ( requestContext , args ) ;
119
+ } ,
120
+ async getComponentNames ( ...args ) {
121
+ return await getComponentNames . apply ( requestContext , args ) ;
122
+ } ,
123
+ async getComponentProps ( ...args ) {
124
+ return await getComponentProps . apply ( requestContext , args ) ;
125
+ } ,
126
+ async getElementAttrs ( ...args ) {
127
+ return await getElementAttrs . apply ( requestContext , args ) ;
128
+ } ,
129
+ async getTemplateContextProps ( ...args ) {
130
+ return await getTemplateContextProps . apply ( requestContext , args ) ;
131
+ } ,
132
+ async getQuickInfoAtPosition ( ...args ) {
133
+ return await getQuickInfoAtPosition . apply ( requestContext , args ) ;
134
+ } ,
135
+ } ;
136
+ } ; ;
137
+ }
0 commit comments