File tree Expand file tree Collapse file tree 5 files changed +16
-3
lines changed
Expand file tree Collapse file tree 5 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,21 @@ export interface DevToolsOptions {
99 * @default true
1010 */
1111 builtinDevTools ?: boolean
12+ /**
13+ * Use a fixed auth id for all clients connecting to the devtools.
14+ */
15+ authId ?: string
1216}
1317
1418export async function DevTools ( options : DevToolsOptions = { } ) : Promise < Plugin [ ] > {
1519 const {
1620 builtinDevTools = true ,
21+ authId,
1722 } = options
1823
1924 const plugins = [
2025 DevToolsInjection ( ) ,
21- DevToolsServer ( ) ,
26+ DevToolsServer ( { authId } ) ,
2227 ]
2328
2429 if ( builtinDevTools ) {
Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ export function renderDockImportsMap(docks: Iterable<DevToolsDockEntry>): string
3434 ] . join ( '\n' )
3535}
3636
37- export function DevToolsServer ( ) : Plugin {
37+ export interface DevToolsServerOptions {
38+ authId ?: string
39+ }
40+
41+ export function DevToolsServer ( options : DevToolsServerOptions = { } ) : Plugin {
3842 let context : DevToolsNodeContext
3943 return {
4044 name : 'vite:devtools:server' ,
@@ -51,6 +55,7 @@ export function DevToolsServer(): Plugin {
5155 cwd : viteDevServer . config . root ,
5256 hostWebSocket : host ,
5357 context,
58+ authId : options . authId ,
5459 } )
5560 viteDevServer . middlewares . use ( DEVTOOLS_MOUNT_PATH , middleware )
5661 } ,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface CreateWsServerOptions {
2020 hostWebSocket : string
2121 base ?: string
2222 context : DevToolsNodeContext
23+ authId ?: string
2324}
2425
2526const ANONYMOUS_SCOPE = 'vite:anonymous:'
@@ -117,6 +118,7 @@ export async function createWsServer(options: CreateWsServerOptions) {
117118 return {
118119 backend : 'websocket' ,
119120 websocket : port ,
121+ ...( options . authId ? { authId : options . authId } : { } ) ,
120122 }
121123 }
122124
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ export async function getDevToolsRpcClient(
184184 const context : DevToolsClientContext = {
185185 rpc : undefined ! ,
186186 }
187- const authId = getConnectionAuthIdFromWindows ( options . authId )
187+ const authId = getConnectionAuthIdFromWindows ( options . authId ?? connectionMeta . authId )
188188 const clientRpc : DevToolsClientRpcHost = new RpcFunctionsCollectorBase < DevToolsRpcClientFunctions , DevToolsClientContext > ( context )
189189
190190 async function fetchJsonFromBases ( path : string ) : Promise < any > {
Original file line number Diff line number Diff line change @@ -86,4 +86,5 @@ export interface DevToolsNodeUtils {
8686export interface ConnectionMeta {
8787 backend : 'websocket' | 'static'
8888 websocket ?: number | string
89+ authId ?: string
8990}
You can’t perform that action at this time.
0 commit comments