1
1
import { ReactElement , useEffect , useRef , useState } from 'react'
2
- import { createLanguageClientManager , LanguageClientId , StatusChangeEvent as WrapperStatusChangeEvent , LanguageClientManager , WillShutdownParams } from '@codingame/monaco-languageclient-wrapper'
2
+ import { createLanguageClientManager , LanguageClientId , StatusChangeEvent as WrapperStatusChangeEvent , LanguageClientManager , WillShutdownParams , Infrastructure } from '@codingame/monaco-languageclient-wrapper'
3
3
import useIsUserActive from './hooks/useIsUserActive'
4
4
import useShouldShutdownLanguageClient from './hooks/useShouldShutdownLanguageClient'
5
5
import { useLastVersion } from './hooks/useLastVersion'
@@ -10,11 +10,7 @@ export interface StatusChangeEvent {
10
10
11
11
export interface LanguageClientProps {
12
12
id : LanguageClientId
13
- sessionId ?: string
14
- languageServerUrl : string
15
- useMutualizedProxy ?: boolean
16
- getSecurityToken : ( ) => Promise < string >
17
- libraryUrls ?: string [ ]
13
+ infrastructure : Infrastructure
18
14
onError ?: ( error : Error ) => void
19
15
onDidChangeStatus ?: ( status : StatusChangeEvent ) => void
20
16
/** The language client will be shutdown by the server */
@@ -25,24 +21,17 @@ export interface LanguageClientProps {
25
21
userInactivityShutdownDelay ?: number
26
22
}
27
23
28
- const defaultLibraryUrls : string [ ] = [ ]
29
-
30
24
const noop = ( ) => null
31
25
32
26
function LanguageClient ( {
33
27
id,
34
- sessionId,
35
- languageServerUrl,
36
- useMutualizedProxy,
37
- getSecurityToken : _getSecurityToken ,
38
- libraryUrls = defaultLibraryUrls ,
28
+ infrastructure,
39
29
onError : _onError ,
40
30
onDidChangeStatus : _onDidChangeStatus ,
41
31
onWillShutdown : _onWillShutdown ,
42
32
userInactivityDelay = 30 * 1000 ,
43
33
userInactivityShutdownDelay = 60 * 1000
44
34
} : LanguageClientProps ) : ReactElement | null {
45
- const getSecurityToken = useLastVersion ( _getSecurityToken )
46
35
const onError = useLastVersion ( _onError ?? noop )
47
36
const onDidChangeStatus = useLastVersion ( _onDidChangeStatus ?? noop )
48
37
const onWillShutdown = useLastVersion ( _onWillShutdown ?? noop )
@@ -75,7 +64,7 @@ function LanguageClient ({
75
64
}
76
65
77
66
console . info ( `Starting language server for language ${ id } ` )
78
- const languageClient = createLanguageClientManager ( id , sessionId , languageServerUrl , getSecurityToken , libraryUrls , useMutualizedProxy )
67
+ const languageClient = createLanguageClientManager ( id , infrastructure )
79
68
languageClientRef . current = languageClient
80
69
const errorDisposable = languageClient . onError ( onError )
81
70
const statusChangeDisposable = languageClient . onDidChangeStatus ( onDidChangeStatus )
@@ -97,7 +86,7 @@ function LanguageClient ({
97
86
console . error ( 'Unable to dispose language client' , err )
98
87
} )
99
88
}
100
- } , [ getSecurityToken , id , languageServerUrl , libraryUrls , sessionId , counter , useMutualizedProxy , shouldShutdownLanguageClientForInactivity , onError , onDidChangeStatus , onWillShutdown ] )
89
+ } , [ id , counter , shouldShutdownLanguageClientForInactivity , onError , onDidChangeStatus , onWillShutdown , infrastructure ] )
101
90
102
91
return null
103
92
}
0 commit comments