@@ -36,10 +36,10 @@ import { getQuickInfoAtPosition } from '@vue/typescript-plugin/lib/requests/getQ
3636export function createVueServicePlugins (
3737 ts : typeof import ( 'typescript' ) ,
3838 getVueOptions : ( env : ServiceEnvironment ) => VueCompilerOptions ,
39- getTsPluginClient ?: ( context : ServiceContext ) => typeof import ( '@vue/typescript-plugin/lib/client' ) | undefined ,
39+ getTsPluginClient = createDefaultGetTsPluginClient ( ts , getVueOptions ) ,
40+ hybridMode = false ,
4041) : ServicePlugin [ ] {
4142 const plugins : ServicePlugin [ ] = [ ] ;
42- const hybridMode = ! ! getTsPluginClient ;
4343 if ( ! hybridMode ) {
4444 plugins . push ( ...createTypeScriptServicePlugins ( ts ) ) ;
4545 for ( let i = 0 ; i < plugins . length ; i ++ ) {
@@ -61,45 +61,6 @@ export function createVueServicePlugins(
6161 break ;
6262 }
6363 }
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- } ;
10364 }
10465 else {
10566 plugins . push (
@@ -129,3 +90,48 @@ export function createVueServicePlugins(
12990 ) ;
13091 return plugins ;
13192}
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