MCPcopy Create free account
hub / github.com/TanStack/devtools / devtools

Function devtools

packages/devtools-vite/src/plugin.ts:111–698  ·  view source on GitHub ↗
(args?: TanStackDevtoolsViteConfig)

Source from the content-addressed store, hash-verified

109 const preferredPort = args?.eventBusConfig?.port ?? 4206
110 const isHttps = !!server.config.server.https
111 const serverHost =
112 typeof server.config.server.host === 'string'
113 ? server.config.server.host
114 : 'localhost'
115
116 devtoolsProtocol = isHttps ? 'https' : 'http'
117 devtoolsHost = serverHost
118
119 const bus = new ServerEventBus({
120 ...args?.eventBusConfig,
121 port: preferredPort,
122 host: serverHost,
123 // When HTTPS is enabled, piggyback on Vite's server
124 // so WebSocket/SSE connections share the same TLS certificate
125 ...(isHttps && server.httpServer
126 ? { httpServer: server.httpServer as HttpServerLike }
127 : {}),
128 })
129 // start() now handles EADDRINUSE and returns the actual port
130 devtoolsPort = await bus.start()
131 if ((server as any).environments) {
132 const teardownBridge = wireRuntimeBridgeChannels(
133 server as unknown as Parameters<
134 typeof wireRuntimeBridgeChannels
135 >[0],
136 () => globalThis.__TANSTACK_EVENT_TARGET__,
137 )
138 server.httpServer?.on('close', teardownBridge)
139 }
140 }
141
142 server.middlewares.use((req, _res, next) => {
143 if (req.socket.localPort && req.socket.localPort !== port) {
144 port = req.socket.localPort
145 }
146 next()
147 })
148 if (server.config.server.port) {
149 port = server.config.server.port
150 }
151
152 server.httpServer?.on('listening', () => {
153 port = server.config.server.port
154 })
155
156 const editor = args?.editor ?? DEFAULT_EDITOR_CONFIG
157 const openInEditor: EditorConfig['open'] = async (
158 path,
159 lineNum,
160 columnNum,
161 ) => {
162 if (!path) {
163 return
164 }
165 await editor.open(path, lineNum, columnNum)
166 }
167
168 const originalConsole = Object.fromEntries(

Callers 15

index.test.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90
vite.config.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected