claude-dev-server 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -198,7 +198,7 @@ var CLIENT_STYLES = `
198
198
  <style id="claude-dev-server-styles">
199
199
  .claude-dev-server-toggle {
200
200
  position: fixed;
201
- bottom: 20px;
201
+ bottom: 120px;
202
202
  right: 20px;
203
203
  width: 44px;
204
204
  height: 44px;
@@ -207,7 +207,7 @@ var CLIENT_STYLES = `
207
207
  border-radius: 50%;
208
208
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
209
209
  cursor: pointer;
210
- z-index: 999999;
210
+ z-index: 2147483647;
211
211
  display: flex;
212
212
  align-items: center;
213
213
  justify-content: center;
@@ -224,16 +224,16 @@ var CLIENT_STYLES = `
224
224
  }
225
225
  .claude-dev-server-inspect-btn {
226
226
  position: fixed;
227
- bottom: 74px;
227
+ bottom: 174px;
228
228
  right: 20px;
229
229
  width: 44px;
230
230
  height: 44px;
231
- background: #1e1e1e;
231
+ background: #d97757;
232
232
  border: none;
233
233
  border-radius: 50%;
234
234
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
235
235
  cursor: pointer;
236
- z-index: 999999;
236
+ z-index: 2147483647;
237
237
  display: flex;
238
238
  align-items: center;
239
239
  justify-content: center;
@@ -242,10 +242,10 @@ var CLIENT_STYLES = `
242
242
  }
243
243
  .claude-dev-server-inspect-btn:hover {
244
244
  transform: scale(1.1);
245
- background: #2d2d2d;
245
+ background: #c96a4a;
246
246
  }
247
247
  .claude-dev-server-inspect-btn.active {
248
- background: #007acc;
248
+ background: #b85d3f;
249
249
  }
250
250
  .claude-dev-server-inspect-btn.hidden {
251
251
  display: none;
@@ -269,7 +269,7 @@ var CLIENT_STYLES = `
269
269
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
270
270
  transform: translateX(100%);
271
271
  transition: transform 0.2s ease;
272
- z-index: 999999;
272
+ z-index: 2147483647;
273
273
  display: flex;
274
274
  flex-direction: column;
275
275
  }
@@ -293,18 +293,19 @@ var CLIENT_STYLES = `
293
293
  gap: 8px;
294
294
  font-size: 13px;
295
295
  }
296
- .claude-dev-server-title::before {
297
- content: '\u{1F916}';
298
- font-size: 14px;
296
+ .claude-dev-server-title svg {
297
+ width: 14px;
298
+ height: 14px;
299
+ flex-shrink: 0;
299
300
  }
300
301
  .claude-dev-server-actions {
301
302
  display: flex;
302
303
  gap: 6px;
303
304
  }
304
305
  .claude-dev-server-btn {
305
- background: #3e3e3e;
306
+ background: #d97757;
306
307
  border: none;
307
- color: #d4d4d4;
308
+ color: #fff;
308
309
  cursor: pointer;
309
310
  font-family: inherit;
310
311
  font-size: 11px;
@@ -316,10 +317,10 @@ var CLIENT_STYLES = `
316
317
  gap: 4px;
317
318
  }
318
319
  .claude-dev-server-btn:hover {
319
- background: #4e4e4e;
320
+ background: #c96a4a;
320
321
  }
321
322
  .claude-dev-server-btn.active {
322
- background: #007acc;
323
+ background: #b85d3f;
323
324
  color: #fff;
324
325
  }
325
326
  .claude-dev-server-close {
@@ -359,7 +360,7 @@ var CLIENT_STYLES = `
359
360
  right: 0;
360
361
  bottom: 0;
361
362
  pointer-events: none;
362
- z-index: 999998;
363
+ z-index: 2147483646;
363
364
  display: none;
364
365
  }
365
366
  .claude-dev-server-inspect-overlay.active {
@@ -389,14 +390,14 @@ var CLIENT_STYLES = `
389
390
  @media (orientation: portrait) {
390
391
  .claude-dev-server-toggle {
391
392
  top: auto;
392
- bottom: 20px;
393
+ bottom: 120px;
393
394
  right: 10px;
394
395
  width: 36px;
395
396
  height: 36px;
396
397
  }
397
398
  .claude-dev-server-inspect-btn {
398
399
  top: auto;
399
- bottom: 66px;
400
+ bottom: 166px;
400
401
  right: 10px;
401
402
  width: 36px;
402
403
  height: 36px;
@@ -1104,11 +1105,18 @@ var CLIENT_SCRIPT = `
1104
1105
  panel.className = 'claude-dev-server-panel'
1105
1106
  panel.innerHTML = \`
1106
1107
  <div class="claude-dev-server-header">
1107
- <span class="claude-dev-server-title">Claude Code</span>
1108
+ <span class="claude-dev-server-title">
1109
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none">
1110
+ <path d="M11.376 24L10.776 23.544L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336L11.904 15.288L11.784 15.312L10.344 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.784 20.616L8.16 17.568L9.6 15.672L10.536 14.592L10.512 14.448H10.464L4.128 18.576L3 18.72L2.496 18.264L2.568 17.52L2.808 17.28L4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.384 12.744L1.104 12.624L0.528 12.504L0 11.784L0.048 11.424L0.528 11.112L1.224 11.16L2.736 11.28L5.016 11.424L6.672 11.52L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.672L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.384 6.768L8.88 8.616L9.24 8.904L9.408 8.808V8.736L9.24 8.472L7.896 6.024L6.456 3.528L5.808 2.496L5.64 1.872C5.576 1.656 5.544 1.416 5.544 1.152L6.288 0.144001L6.696 0L7.704 0.144001L8.112 0.504001L8.736 1.92L9.72 4.152L11.28 7.176L11.736 8.088L11.976 8.904L12.072 9.168H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.840001L14.04 0.360001L14.616 0.624001L15.096 1.32L15.024 1.752L14.76 3.6L14.184 6.504L13.824 8.472H14.04L14.28 8.208L15.264 6.912L16.92 4.848L17.64 4.032L18.504 3.12L19.056 2.688H20.088L20.832 3.816L20.496 4.992L19.44 6.336L18.552 7.464L17.28 9.168L16.512 10.536L16.584 10.632H16.752L19.608 10.008L21.168 9.744L22.992 9.432L23.832 9.816L23.928 10.2L23.592 11.016L21.624 11.496L19.32 11.952L15.888 12.768L15.84 12.792L15.888 12.864L17.424 13.008L18.096 13.056H19.728L22.752 13.272L23.544 13.8L24 14.424L23.928 14.928L22.704 15.528L21.072 15.144L17.232 14.232L15.936 13.92H15.744V14.016L16.848 15.096L18.84 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.808L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.176L17.184 22.056L15.792 20.136L14.376 17.952L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24Z" fill="#d97757"/>
1111
+ </svg>
1112
+ Claude Code
1113
+ </span>
1108
1114
  <div class="claude-dev-server-actions">
1109
1115
  <button class="claude-dev-server-btn claude-dev-server-btn-inspect" title="Inspect Element">
1110
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1111
- <path d="M2 12h20M12 2v20M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"/>
1116
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1117
+ <path d="M19 11V4a2 2 0 00-2-2H4a2 2 0 00-2 2v13a2 2 0 002 2h7"/>
1118
+ <path d="M12 12l4.166 10 1.48-4.355L22 16.166 12 12z"/>
1119
+ <path d="M18 18l3 3"/>
1112
1120
  </svg>
1113
1121
  Inspect
1114
1122
  </button>
@@ -1674,5 +1682,5 @@ ${projectRootScript}
1674
1682
  }
1675
1683
 
1676
1684
  export { startUniversalServer };
1677
- //# sourceMappingURL=chunk-F6IKDNXJ.js.map
1678
- //# sourceMappingURL=chunk-F6IKDNXJ.js.map
1685
+ //# sourceMappingURL=chunk-RFPIOREI.js.map
1686
+ //# sourceMappingURL=chunk-RFPIOREI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/pty.ts","../src/server/source-map.ts","../src/server/websocket.ts","../src/client/injection.js","../src/universal/index.ts"],"names":["resol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CAAA;AAAA,OAAA;AAAA,GAC5G,CAAE,OAAA;AAAA,IACA,eAAA;AAAA,IACA,WAAW,MAAM,CAAA;AAAA,GACnB;AACF","file":"chunk-RFPIOREI.js","sourcesContent":["import { spawn } from 'child_process'\nimport { randomBytes } from 'crypto'\n\nexport interface PtyOptions {\n cwd: string\n claudePath: string\n args: string[]\n env?: Record<string, string>\n}\n\nexport function spawnClaudeCode(options: PtyOptions) {\n // Generate a random port for ttyd\n const port = 50000 + Math.floor(Math.random() * 10000)\n\n // Start ttyd with claude command\n const ttydProc = spawn('ttyd', [\n '--port', String(port),\n '--interface', '127.0.0.1',\n '--writable',\n options.claudePath,\n ...options.args,\n ], {\n cwd: options.cwd,\n env: {\n ...process.env,\n ...options.env,\n TERM: 'xterm-256color',\n FORCE_COLOR: '1',\n },\n })\n\n ttydProc.on('exit', (code) => {\n console.log(`[claude-dev-server] ttyd exited - code: ${code}`)\n })\n\n ttydProc.on('error', (err) => {\n console.error(`[claude-dev-server] ttyd error: ${err.message}`)\n })\n\n // Wait a bit for ttyd to start, then return the WebSocket URL\n return new Promise<{ wsUrl: string; process: typeof ttydProc; port: number }>((resolve, reject) => {\n ttydProc.stdout?.on('data', (data: Buffer) => {\n const msg = data.toString()\n console.log(`[ttyd] ${msg}`)\n })\n\n ttydProc.stderr?.on('data', (data: Buffer) => {\n const msg = data.toString()\n console.error(`[ttyd stderr] ${msg}`)\n })\n\n // Give ttyd a moment to start\n setTimeout(() => {\n resolve({\n wsUrl: `ws://127.0.0.1:${port}`,\n process: ttydProc,\n port,\n })\n }, 500)\n\n ttydProc.on('error', reject)\n })\n}\n","import { SourceMapConsumer } from 'source-map'\n\nexport interface SourcePosition {\n source: string\n line: number\n column: number\n name?: string\n}\n\nexport interface CodeLocation {\n file: string\n line: number\n column: number\n content?: string\n}\n\n// Store source maps by generated file path\nconst sourceMapCache = new Map<string, SourceMapConsumer>()\n\nexport async function parseSourceMap(sourceMapUrl: string, content: string): Promise<void> {\n try {\n const consumer = await new SourceMapConsumer(content)\n sourceMapCache.set(sourceMapUrl, consumer)\n } catch (err) {\n console.error('Failed to parse source map:', err)\n }\n}\n\nexport async function findOriginalPosition(\n generatedFile: string,\n line: number,\n column: number\n): Promise<SourcePosition | null> {\n const consumer = sourceMapCache.get(generatedFile)\n if (!consumer) {\n return null\n }\n\n try {\n const position = consumer.originalPositionFor({ line, column })\n if (position.source) {\n return {\n source: position.source,\n line: position.line || 1,\n column: position.column || 0,\n name: position.name,\n }\n }\n } catch (err) {\n console.error('Failed to find original position:', err)\n }\n\n return null\n}\n\nexport function generateVSCodeURI(location: CodeLocation): string {\n // Generate VS Code URI scheme for opening files\n // vscode://file/{path}:{line}:{col}\n const filePath = location.file.replace(/\\\\/g, '/')\n return `vscode://file/${filePath}:${location.line}:${location.column}`\n}\n\nexport function formatCodeContext(location: CodeLocation): string {\n return `\n📍 Code Location:\n File: ${location.file}\n Line: ${location.line}\n Column: ${location.column}\n`\n}\n\nexport function clearCache() {\n sourceMapCache.clear()\n}\n","import { WebSocketServer, WebSocket } from 'ws'\nimport { spawnClaudeCode } from './pty.js'\nimport { findOriginalPosition, parseSourceMap, CodeLocation, formatCodeContext } from './source-map.js'\nimport { readFile } from 'fs/promises'\nimport { resolve } from 'path'\n\nexport interface WebSocketServerOptions {\n port?: number\n projectRoot: string\n claudePath: string\n claudeArgs: string[]\n}\n\nexport function createWebSocketServer(options: WebSocketServerOptions) {\n let wss: WebSocketServer | null = null\n let port = options.port || 0\n let ttydInfo: { wsUrl: string; process: any; port: number } | null = null\n\n const start = async (): Promise<{ wsPort: number; ttydPort: number }> => {\n // Start ttyd first\n console.log('[claude-dev-server] Starting ttyd...')\n ttydInfo = await spawnClaudeCode({\n cwd: options.projectRoot,\n claudePath: options.claudePath,\n args: options.claudeArgs,\n })\n console.log(`[claude-dev-server] ttyd running at ${ttydInfo.wsUrl}`)\n\n // Also start a simple WebSocket server for inspect functionality\n return new Promise((resolve, reject) => {\n wss = new WebSocketServer({ port, host: '127.0.0.1' })\n\n wss.on('listening', () => {\n const address = wss!.address()\n if (address && typeof address === 'object') {\n port = address.port\n resolve({ wsPort: port, ttydPort: ttydInfo!.port })\n }\n })\n\n wss.on('error', (err) => {\n reject(err)\n })\n\n wss.on('connection', (ws: WebSocket) => {\n ws.on('message', async (message: Buffer) => {\n try {\n const msg = JSON.parse(message.toString())\n\n if (msg.type === 'inspect') {\n await handleInspect(msg, ws, options.projectRoot)\n } else if (msg.type === 'loadSourceMap') {\n await handleLoadSourceMap(msg, ws, options.projectRoot)\n }\n } catch (err) {\n // Ignore\n }\n })\n\n // Send ready message with ttyd URL\n ws.send(JSON.stringify({\n type: 'ready',\n ttydUrl: ttydInfo!.wsUrl\n }))\n })\n })\n }\n\n const stop = () => {\n ttydInfo?.process.kill()\n wss?.close()\n }\n\n return { start, stop }\n}\n\nasync function handleLoadSourceMap(\n msg: any,\n ws: WebSocket,\n projectRoot: string\n) {\n const { sourceMapUrl } = msg\n try {\n const mapPath = resolve(projectRoot, sourceMapUrl.replace(/^\\//, ''))\n const content = await readFile(mapPath, 'utf-8')\n await parseSourceMap(sourceMapUrl, content)\n ws.send(JSON.stringify({\n type: 'sourceMapLoaded',\n sourceMapUrl,\n success: true\n }))\n } catch (err) {\n ws.send(JSON.stringify({\n type: 'sourceMapLoaded',\n sourceMapUrl,\n success: false,\n error: (err as Error).message\n }))\n }\n}\n\nasync function handleInspect(\n msg: any,\n ws: WebSocket,\n projectRoot: string\n) {\n const { url, line, column, sourceMapUrl } = msg\n\n let location: CodeLocation | null = null\n\n if (sourceMapUrl) {\n const original = await findOriginalPosition(sourceMapUrl, line, column)\n if (original) {\n location = {\n file: resolve(projectRoot, original.source),\n line: original.line,\n column: original.column,\n }\n }\n }\n\n if (!location) {\n const match = url.match(/\\/@fs\\/(.+?)(?:\\?|$)|\\/@vite\\/(.+?)(?:\\?|$)/)\n if (match) {\n location = {\n file: decodeURIComponent(match[1] || match[2]),\n line,\n column,\n }\n }\n }\n\n ws.send(JSON.stringify({\n type: 'inspectResult',\n location: location ? {\n file: location.file,\n line: location.line,\n column: location.column,\n context: formatCodeContext(location)\n } : null\n }))\n}\n","// Client-side script - pure JavaScript (no TypeScript)\n// This file will be injected into the browser\n\nexport const CLIENT_STYLES = `\n<style id=\"claude-dev-server-styles\">\n.claude-dev-server-toggle {\n position: fixed;\n bottom: 120px;\n right: 20px;\n width: 44px;\n height: 44px;\n background: #1e1e1e;\n border: none;\n border-radius: 50%;\n box-shadow: 0 2px 12px rgba(0,0,0,0.3);\n cursor: pointer;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 20px;\n transition: transform 0.2s, background 0.2s;\n padding: 0;\n}\n.claude-dev-server-toggle:hover {\n transform: scale(1.1);\n background: #2d2d2d;\n}\n.claude-dev-server-toggle.hidden {\n display: none;\n}\n.claude-dev-server-inspect-btn {\n position: fixed;\n bottom: 174px;\n right: 20px;\n width: 44px;\n height: 44px;\n background: #d97757;\n border: none;\n border-radius: 50%;\n box-shadow: 0 2px 12px rgba(0,0,0,0.3);\n cursor: pointer;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n transition: transform 0.2s, background 0.2s;\n}\n.claude-dev-server-inspect-btn:hover {\n transform: scale(1.1);\n background: #c96a4a;\n}\n.claude-dev-server-inspect-btn.active {\n background: #b85d3f;\n}\n.claude-dev-server-inspect-btn.hidden {\n display: none;\n}\n.claude-dev-server-toggle svg,\n.claude-dev-server-inspect-btn svg {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n}\n.claude-dev-server-panel {\n position: fixed;\n top: 0;\n right: 0;\n width: 650px;\n height: 100vh;\n background: #1e1e1e;\n color: #d4d4d4;\n font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;\n font-size: 13px;\n box-shadow: -4px 0 20px rgba(0,0,0,0.3);\n transform: translateX(100%);\n transition: transform 0.2s ease;\n z-index: 2147483647;\n display: flex;\n flex-direction: column;\n}\n.claude-dev-server-panel.open {\n transform: translateX(0);\n}\n.claude-dev-server-header {\n padding: 8px 12px;\n background: #2d2d2d;\n border-bottom: 1px solid #3e3e3e;\n display: flex;\n justify-content: space-between;\n align-items: center;\n user-select: none;\n}\n.claude-dev-server-title {\n font-weight: 600;\n color: #fff;\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n}\n.claude-dev-server-title svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n}\n.claude-dev-server-actions {\n display: flex;\n gap: 6px;\n}\n.claude-dev-server-btn {\n background: #d97757;\n border: none;\n color: #fff;\n cursor: pointer;\n font-family: inherit;\n font-size: 11px;\n padding: 4px 10px;\n border-radius: 3px;\n transition: background 0.15s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.claude-dev-server-btn:hover {\n background: #c96a4a;\n}\n.claude-dev-server-btn.active {\n background: #b85d3f;\n color: #fff;\n}\n.claude-dev-server-close {\n background: none;\n border: none;\n color: #858585;\n cursor: pointer;\n font-size: 18px;\n padding: 0;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 3px;\n transition: background 0.15s, color 0.15s;\n}\n.claude-dev-server-close:hover {\n background: #3e3e3e;\n color: #fff;\n}\n.claude-dev-server-terminal {\n flex: 1;\n overflow: hidden;\n position: relative;\n background: #000;\n}\n.claude-dev-server-terminal iframe {\n width: 100%;\n height: 100%;\n border: none;\n}\n.claude-dev-server-inspect-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 2147483646;\n display: none;\n}\n.claude-dev-server-inspect-overlay.active {\n display: block;\n}\n.claude-dev-server-highlight {\n position: absolute;\n border: 2px solid #007acc;\n background: rgba(0, 122, 204, 0.1);\n pointer-events: none;\n transition: all 0.1s ease;\n}\n.claude-dev-server-highlight::after {\n content: attr(data-element);\n position: absolute;\n top: -20px;\n left: 0;\n background: #007acc;\n color: #fff;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 2px 2px 0 0;\n font-family: monospace;\n white-space: nowrap;\n}\n/* Responsive layout for portrait mode */\n@media (orientation: portrait) {\n .claude-dev-server-toggle {\n top: auto;\n bottom: 120px;\n right: 10px;\n width: 36px;\n height: 36px;\n }\n .claude-dev-server-inspect-btn {\n top: auto;\n bottom: 166px;\n right: 10px;\n width: 36px;\n height: 36px;\n }\n .claude-dev-server-panel {\n top: auto;\n bottom: 0;\n right: 0;\n left: 0;\n width: 100%;\n height: 80vh;\n transform: translateY(100%);\n box-shadow: 0 -4px 20px rgba(0,0,0,0.3);\n }\n .claude-dev-server-panel.open {\n transform: translateY(0);\n }\n .claude-dev-server-toggle svg,\n .claude-dev-server-inspect-btn svg {\n width: 16px;\n height: 16px;\n }\n}\n</style>\n`\n\nexport const CLIENT_SCRIPT = `\n(() => {\n let ws = null\n let panel = null\n let toggleBtn = null\n let inspectBtn = null // 悬浮 inspect 按钮\n let terminalContainer = null\n let terminalIframe = null\n let overlay = null\n let isOpen = false\n let isInspectMode = false\n let ttydWsUrl = null\n\n // Fetch the WebSocket port from the server\n async function getWsPort() {\n const res = await fetch('/@claude-port')\n const data = await res.json()\n return data.port\n }\n\n async function initWhenReady() {\n try {\n const port = await getWsPort()\n connect(port)\n } catch (err) {\n console.error('[Claude Dev Server] Failed to get port:', err)\n // Retry after 1 second\n setTimeout(initWhenReady, 1000)\n return\n }\n createToggleBtn()\n createInspectBtn()\n createOverlay()\n createPanel()\n }\n\n function createToggleBtn() {\n if (toggleBtn) return\n toggleBtn = document.createElement('button')\n toggleBtn.className = 'claude-dev-server-toggle'\n toggleBtn.innerHTML = '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M11.376 24L10.776 23.544L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336L11.904 15.288L11.784 15.312L10.344 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.784 20.616L8.16 17.568L9.6 15.672L10.536 14.592L10.512 14.448H10.464L4.128 18.576L3 18.72L2.496 18.264L2.568 17.52L2.808 17.28L4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.384 12.744L1.104 12.624L0.528 12.504L0 11.784L0.048 11.424L0.528 11.112L1.224 11.16L2.736 11.28L5.016 11.424L6.672 11.52L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.672L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.384 6.768L8.88 8.616L9.24 8.904L9.408 8.808V8.736L9.24 8.472L7.896 6.024L6.456 3.528L5.808 2.496L5.64 1.872C5.576 1.656 5.544 1.416 5.544 1.152L6.288 0.144001L6.696 0L7.704 0.144001L8.112 0.504001L8.736 1.92L9.72 4.152L11.28 7.176L11.736 8.088L11.976 8.904L12.072 9.168H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.840001L14.04 0.360001L14.616 0.624001L15.096 1.32L15.024 1.752L14.76 3.6L14.184 6.504L13.824 8.472H14.04L14.28 8.208L15.264 6.912L16.92 4.848L17.64 4.032L18.504 3.12L19.056 2.688H20.088L20.832 3.816L20.496 4.992L19.44 6.336L18.552 7.464L17.28 9.168L16.512 10.536L16.584 10.632H16.752L19.608 10.008L21.168 9.744L22.992 9.432L23.832 9.816L23.928 10.2L23.592 11.016L21.624 11.496L19.32 11.952L15.888 12.768L15.84 12.792L15.888 12.864L17.424 13.008L18.096 13.056H19.728L22.752 13.272L23.544 13.8L24 14.424L23.928 14.928L22.704 15.528L21.072 15.144L17.232 14.232L15.936 13.92H15.744V14.016L16.848 15.096L18.84 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.808L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.176L17.184 22.056L15.792 20.136L14.376 17.952L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24Z\" fill=\"#d97757\"/></svg>'\n toggleBtn.title = 'Open Claude Code (Cmd/Ctrl + \\`)'\n toggleBtn.setAttribute('data-dev-tool', 'true')\n toggleBtn.addEventListener('click', () => togglePanel(true))\n document.body.appendChild(toggleBtn)\n }\n\n function createInspectBtn() {\n if (inspectBtn) return\n inspectBtn = document.createElement('button')\n inspectBtn.className = 'claude-dev-server-inspect-btn'\n inspectBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 11V4a2 2 0 00-2-2H4a2 2 0 00-2 2v13a2 2 0 002 2h7\"/><path d=\"M12 12l4.166 10 1.48-4.355L22 16.166 12 12z\"/><path d=\"M18 18l3 3\"/></svg>'\n inspectBtn.title = 'Inspect Element (Cmd/Ctrl + Shift + I)'\n inspectBtn.setAttribute('data-dev-tool', 'true')\n inspectBtn.addEventListener('click', () => {\n if (isInspectMode) {\n disableInspectMode()\n } else {\n // 点击 Inspect 时先收起面板\n if (isOpen) {\n togglePanel(false)\n }\n enableInspectMode()\n }\n })\n document.body.appendChild(inspectBtn)\n }\n\n function createOverlay() {\n if (overlay) return\n overlay = document.createElement('div')\n overlay.className = 'claude-dev-server-inspect-overlay'\n document.body.appendChild(overlay)\n }\n\n function highlightElement(el) {\n if (!overlay) return\n overlay.innerHTML = ''\n const rect = el.getBoundingClientRect()\n const highlight = document.createElement('div')\n highlight.className = 'claude-dev-server-highlight'\n highlight.style.top = rect.top + 'px'\n highlight.style.left = rect.left + 'px'\n highlight.style.width = rect.width + 'px'\n highlight.style.height = rect.height + 'px'\n const className = el.className ? String(el.className) : ''\n highlight.dataset.element = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (className ? '.' + className.split(' ').join('.') : '')\n overlay.appendChild(highlight)\n }\n\n async function getSourceLocation(el) {\n // Early check: detect Next.js by checking for _next/static chunks\n const hasNextJsChunks = Array.from(document.querySelectorAll('script[src]'))\n .some(script => script.getAttribute('src')?.includes('/_next/static/chunks/'))\n\n if (hasNextJsChunks) {\n console.log('[Claude Dev Server] Next.js Turbopack detected, using specialized lookup')\n\n const pagePath = window.location.pathname\n console.log('[Claude Dev Server] Looking up source for page:', pagePath)\n\n try {\n const params = new URLSearchParams({\n page: pagePath,\n framework: 'nextjs'\n })\n const lookupUrl = '/@sourcemap-lookup?' + params.toString()\n console.log('[Claude Dev Server] Fetching:', lookupUrl)\n\n const response = await fetch(lookupUrl)\n console.log('[Claude Dev Server] Response status:', response.status)\n\n if (response.ok) {\n const result = await response.json()\n console.log('[Claude Dev Server] Lookup result:', result)\n if (result.file) {\n const elClassName = el.className ? String(el.className) : ''\n const selector = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (elClassName ? '.' + elClassName.split(' ').filter(c => c).join('.') : '')\n\n return {\n url: result.file,\n line: result.line || undefined,\n column: result.column || undefined,\n selector: selector,\n hint: 'File: ' + result.file\n }\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Next.js lookup failed:', e)\n }\n // If Next.js lookup failed, continue with normal flow\n }\n\n let sourceFile = null\n let sourceLine = 1\n let sourceColumn = 1\n\n // Try to get original line number using source map\n // Use server-side source map resolution with source-map library\n async function resolveSourceMap(filePath, line, column) {\n try {\n console.log('[Claude Dev Server] Calling server source map resolution for:', filePath, line, column)\n\n // Convert absolute file path to URL path for Vite\n let urlPath = filePath\n if (filePath.startsWith('/Users/')) {\n // Convert /Users/.../src/App.jsx to /src/App.jsx\n const parts = filePath.split('/')\n const srcIndex = parts.indexOf('src')\n if (srcIndex >= 0) {\n urlPath = '/' + parts.slice(srcIndex).join('/')\n }\n }\n\n console.log('[Claude Dev Server] Converted path to URL path:', urlPath)\n\n // Use the server-side source map resolution with URL path\n const params = new URLSearchParams({\n file: urlPath,\n line: String(line),\n col: String(column)\n })\n\n const response = await fetch('/@sourcemap?' + params.toString())\n if (!response.ok) {\n console.log('[Claude Dev Server] Source map request failed:', response.status)\n return null\n }\n\n const result = await response.json()\n console.log('[Claude Dev Server] Source map result:', result)\n\n if (result.error) {\n console.log('[Claude Dev Server] Source map error:', result.error)\n return null\n }\n\n if (result.file) {\n return {\n file: result.file,\n line: result.line,\n column: result.column\n }\n }\n\n return null\n } catch (e) {\n console.log('[Claude Dev Server] Source map lookup failed:', e.message)\n return null\n }\n }\n\n // Try to extract jsxDEV source location from React Fiber\n function extractJsxDevLocation(fiber) {\n try {\n // The jsxDEV location is stored in the element type's _debugInfo or _source\n // React 18 stores it differently - let's check multiple locations\n const elementType = fiber.elementType || fiber.type\n\n // Check if this is a jsxDEV call by looking at the string representation\n if (elementType && typeof elementType === 'function') {\n const fnStr = elementType.toString()\n // jsxDEV functions have a specific pattern\n if (fnStr.includes('jsxDEV') || fnStr.includes('jsx')) {\n console.log('[Claude Dev Server] Found jsxDEV element type')\n }\n }\n\n // Try to get _debugSource which might have jsxDEV metadata\n const debugSource = fiber._debugSource || fiber._debugInfo\n if (debugSource) {\n // For jsxDEV, check if there's a _source object with fileName/lineNumber\n const source = debugSource._source || debugSource.source || debugSource\n if (source && source.fileName && source.lineNumber !== undefined) {\n console.log('[Claude Dev Server] Found _debugSource with source location:', source)\n // NOTE: Don't use this directly! The lineNumber might be from transpiled code\n // We'll let the source map resolver handle it\n return null\n }\n }\n\n // Check the memoizedState or other properties for source location\n if (fiber.memoizedState) {\n // React might store jsxDEV location in memoizedState\n console.log('[Claude Dev Server] Checking memoizedState:', fiber.memoizedState)\n }\n\n // Check the memoizedProps or other properties for source location\n if (fiber.memoizedProps && fiber.memoizedProps.__source) {\n const source = fiber.memoizedProps.__source\n console.log('[Claude Dev Server] Found __source in memoizedProps:', source)\n return {\n file: source.fileName,\n line: source.lineNumber,\n column: source.columnNumber || 1\n }\n }\n\n // Check pendingProps for __source\n if (fiber.pendingProps && fiber.pendingProps.__source) {\n const source = fiber.pendingProps.__source\n console.log('[Claude Dev Server] Found __source in pendingProps:', source)\n return {\n file: source.fileName,\n line: source.lineNumber,\n column: source.columnNumber || 1\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Error extracting jsxDEV location:', e)\n }\n return null\n }\n\n // Try React DevTools - handle React 18's randomized suffix\n const elKeys = Object.keys(el)\n let fiberKey = elKeys.find(k => k === '__reactFiber__' || k === '__reactInternalInstance' || k.indexOf('__reactFiber') === 0)\n let propsKey = elKeys.find(k => k === '__reactProps__' || k.indexOf('__reactProps') === 0)\n\n if (fiberKey) {\n const fiber = el[fiberKey]\n console.log('[Claude Dev Server] Found fiber at key:', fiberKey)\n\n // Log fiber structure for debugging\n console.log('[Claude Dev Server] Fiber structure:', {\n _debugSource: fiber._debugSource,\n elementType: fiber.elementType,\n type: fiber.type,\n memoizedProps: fiber.memoizedProps,\n pendingProps: fiber.pendingProps\n })\n\n // Log _debugSource details\n if (fiber._debugSource) {\n console.log('[Claude Dev Server] _debugSource details:', JSON.stringify(fiber._debugSource, null, 2))\n }\n\n // For Next.js, try to get component name from elementType\n if (!fiber._debugSource && fiber.elementType) {\n const elementType = fiber.elementType\n console.log('[Claude Dev Server] elementType:', elementType)\n console.log('[Claude Dev Server] elementType.name:', elementType.name)\n console.log('[Claude Dev Server] elementType.displayName:', elementType.displayName)\n\n // Try to get the function string to find component name\n if (typeof elementType === 'function') {\n const fnStr = elementType.toString()\n console.log('[Claude Dev Server] elementType function:', fnStr.substring(0, 200))\n }\n }\n\n // First, try to extract jsxDEV source location\n const jsxDevLocation = extractJsxDevLocation(fiber)\n if (jsxDevLocation) {\n sourceFile = jsxDevLocation.file\n sourceLine = jsxDevLocation.line\n sourceColumn = jsxDevLocation.column\n\n // Convert absolute path to relative path\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n console.log('[Claude Dev Server] Using jsxDEV location:', sourceFile, sourceLine)\n } else {\n // Fall back to _debugSource\n const debugSource = fiber._debugSource || fiber.elementType?._debugSource || fiber.type?._debugSource || fiber.alternate?._debugSource\n if (debugSource && debugSource.fileName) {\n sourceFile = debugSource.fileName\n sourceLine = debugSource.lineNumber || 1\n sourceColumn = debugSource.columnNumber || 1\n\n // Convert relative path to absolute path for source map resolution\n let absolutePath = sourceFile\n if (!sourceFile.startsWith('/')) {\n // Relative path - resolve relative to project root\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n absolutePath = projectRoot + '/' + sourceFile\n }\n\n console.log('[Claude Dev Server] Resolving source map for:', absolutePath, 'at line:', sourceLine)\n\n // Use server-side source map resolution\n const original = await resolveSourceMap(absolutePath, sourceLine, sourceColumn)\n if (original) {\n sourceFile = original.file\n sourceLine = original.line\n sourceColumn = original.column\n console.log('[Claude Dev Server] Original location from source map:', sourceFile, sourceLine)\n } else {\n // Source map resolution failed, use the original file\n // Convert absolute path back to relative\n if (absolutePath.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && absolutePath.startsWith(projectRoot)) {\n sourceFile = absolutePath.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n }\n console.log('[Claude Dev Server] Final React source:', sourceFile, sourceLine)\n } else {\n // Try going up the fiber tree\n let currentFiber = fiber\n let depth = 0\n while (currentFiber && depth < 20) {\n const jsxDevLoc = extractJsxDevLocation(currentFiber)\n if (jsxDevLoc) {\n sourceFile = jsxDevLoc.file\n sourceLine = jsxDevLoc.line\n sourceColumn = jsxDevLoc.column\n\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n console.log('[Claude Dev Server] Found jsxDEV location at depth', depth, ':', sourceFile, sourceLine)\n break\n }\n\n const ds = currentFiber._debugSource || currentFiber.elementType?._debugSource || currentFiber.type?._debugSource\n if (ds && ds.fileName) {\n sourceFile = ds.fileName\n sourceLine = ds.lineNumber || 1\n sourceColumn = ds.columnNumber || 1\n\n // Use server-side source map resolution\n const original = await resolveSourceMap(sourceFile, sourceLine, sourceColumn)\n if (original) {\n sourceFile = original.file\n sourceLine = original.line\n sourceColumn = original.column\n } else {\n // Convert absolute path to relative path using project root\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n }\n console.log('[Claude Dev Server] Found React source at depth', depth, ':', sourceFile, sourceLine)\n break\n }\n currentFiber = currentFiber.return || currentFiber.alternate\n depth++\n }\n }\n }\n }\n\n // Try Vue component\n if (!sourceFile) {\n const vueComponent = el.__vueParentComponent || el.__vnode\n if (vueComponent) {\n const type = vueComponent.type || vueComponent.component\n if (type && type.__file) {\n sourceFile = type.__file\n console.log('[Claude Dev Server] Found Vue source:', sourceFile)\n }\n }\n }\n\n // Try Vite's HMR source map\n if (!sourceFile) {\n // Look for data-vite-dev-id or similar attributes\n const viteId = el.getAttribute('data-vite-dev-id')\n if (viteId) {\n // Extract file path from viteId (remove query params if any)\n const queryIndex = viteId.indexOf('?')\n sourceFile = '/' + (queryIndex >= 0 ? viteId.substring(0, queryIndex) : viteId)\n console.log('[Claude Dev Server] Found Vite ID:', viteId)\n }\n }\n\n // Check for inline script\n if (!sourceFile) {\n const inlineScripts = document.querySelectorAll('script:not([src])')\n if (inlineScripts.length > 0) {\n const pathParts = window.location.pathname.split('/')\n const fileName = pathParts[pathParts.length - 1] || 'index.html'\n sourceFile = '/' + fileName\n\n const html = document.documentElement.outerHTML\n const elId = el.id ? el.id : ''\n const elClass = el.className ? el.className : ''\n let elPattern\n if (elId) {\n elPattern = 'id=\"' + elId + '\"'\n } else if (elClass) {\n elPattern = 'class=\"' + elClass.split(' ')[0] + '\"'\n } else {\n elPattern = el.tagName.toLowerCase()\n }\n\n const matchIndex = html.indexOf(elPattern)\n if (matchIndex !== -1) {\n const beforeElement = html.substring(0, matchIndex)\n sourceLine = beforeElement.split('\\\\n').length\n }\n }\n }\n\n // Find main script\n if (!sourceFile) {\n const scripts = document.querySelectorAll('script[src]')\n for (const script of scripts) {\n const src = script.getAttribute('src')\n if (src && !src.includes('cdn') && !src.includes('node_modules') &&\n (src.includes('/src/') || src.includes('/app.') || src.includes('/main.'))) {\n sourceFile = src\n break\n }\n }\n }\n\n // Fallback\n if (!sourceFile) {\n const pathParts = window.location.pathname.split('/')\n const fileName = pathParts[pathParts.length - 1] || 'index.html'\n sourceFile = '/' + fileName\n }\n\n const elClassName = el.className ? String(el.className) : ''\n const selector = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (elClassName ? '.' + elClassName.split(' ').filter(c => c).join('.') : '')\n\n return {\n url: sourceFile,\n line: sourceLine,\n column: sourceColumn,\n selector: selector,\n hint: sourceFile ? 'File: ' + sourceFile : 'Element: ' + selector\n }\n }\n\n function enableInspectMode() {\n isInspectMode = true\n overlay && overlay.classList.add('active')\n document.body.style.cursor = 'crosshair'\n\n // 更新悬浮 inspect 按钮状态\n if (inspectBtn) inspectBtn.classList.add('active')\n\n // 检查元素是否属于 dev tools\n function isDevToolElement(el) {\n if (!el) return false\n // 检查元素本身\n if (el.dataset && el.dataset.devTool === 'true') return true\n // 检查父元素\n let parent = el.parentElement\n while (parent) {\n if (parent.dataset && parent.dataset.devTool === 'true') return true\n parent = parent.parentElement\n }\n return false\n }\n\n const onMouseMove = async (e) => {\n if (!isInspectMode) return\n const el = document.elementFromPoint(e.clientX, e.clientY)\n // 忽略 dev tools 元素和 overlay\n if (el && el !== overlay && !isDevToolElement(el) && (!overlay || !overlay.contains(el))) {\n highlightElement(el)\n }\n }\n\n const onClick = async (e) => {\n if (!isInspectMode) return\n e.preventDefault()\n e.stopPropagation()\n\n const el = document.elementFromPoint(e.clientX, e.clientY)\n // 忽略 dev tools 元素和 overlay\n if (el && el !== overlay && !isDevToolElement(el) && (!overlay || !overlay.contains(el))) {\n const location = await getSourceLocation(el)\n if (location) {\n await inspectElement(location, el)\n }\n disableInspectMode()\n }\n }\n\n document.addEventListener('mousemove', onMouseMove, true)\n document.addEventListener('click', onClick, true)\n\n if (overlay) overlay._inspectHandlers = { onMouseMove, onClick }\n }\n\n function disableInspectMode() {\n isInspectMode = false\n if (overlay) overlay.classList.remove('active')\n document.body.style.cursor = ''\n if (overlay) overlay.innerHTML = ''\n\n // 更新悬浮 inspect 按钮状态\n if (inspectBtn) inspectBtn.classList.remove('active')\n\n const btn = panel && panel.querySelector('.claude-dev-server-btn-inspect')\n if (btn) btn.classList.remove('active')\n\n const handlers = overlay && overlay._inspectHandlers\n if (handlers) {\n document.removeEventListener('mousemove', handlers.onMouseMove, true)\n document.removeEventListener('click', handlers.onClick, true)\n }\n }\n\n async function inspectElement(location, el) {\n // 构建格式化的 prompt\n const filePath = location.url || location.file || 'unknown'\n const tagName = el.tagName ? el.tagName.toLowerCase() : ''\n const id = el.id ? '#' + el.id : ''\n\n // 对于 Tailwind CSS 等大量 class 的情况,只取前 2-3 个 class\n let className = ''\n if (el.className) {\n const classes = String(el.className).split(' ').filter(c => c)\n // 如果 class 太多(可能是 Tailwind),只取前 2 个\n if (classes.length > 5) {\n className = '.' + classes.slice(0, 2).join('.')\n } else {\n className = '.' + classes.join('.')\n }\n }\n\n const selector = tagName + id + className\n\n // 获取元素的文本内容(如果是文本节点或短文本元素)\n let textContent = ''\n if (el.nodeType === Node.TEXT_NODE) {\n textContent = el.textContent ? el.textContent.trim().substring(0, 50) : ''\n } else if (el.childNodes.length === 1 && el.childNodes[0].nodeType === Node.TEXT_NODE) {\n textContent = el.childNodes[0].textContent ? el.childNodes[0].textContent.trim().substring(0, 50) : ''\n }\n\n // Check if file is in node_modules - if so, skip the @filename part\n const isNodeModules = filePath.includes('node_modules')\n\n // 格式: @filename:line <selector> \"text content\" 或 @filename <selector> \"text content\"\n // 如果是 node_modules 文件,只保留 <selector> \"text content\"\n let prompt = ''\n if (isNodeModules) {\n // Skip @filename for node_modules, just show element and text\n prompt = \\`<\\${selector}>\\`\n if (textContent) {\n prompt += \\` \"\\${textContent}\"\\`\n }\n console.log('[Claude Dev Server] Skipping node_modules path:', filePath)\n } else {\n const linePart = location.line ? \\`:\\${location.line}\\` : ''\n prompt = \\`@\\${filePath}\\${linePart} <\\${selector}>\\`\n if (textContent) {\n prompt += \\` \"\\${textContent}\"\\`\n }\n }\n\n // 发送成功后展开面板\n const sendToTerminal = () => {\n if (!terminalIframe || !terminalIframe.contentWindow) {\n return false\n }\n\n const win = terminalIframe.contentWindow\n\n // Check if sendToTerminal function is available\n if (win.sendToTerminal) {\n win.sendToTerminal(prompt)\n console.log('[Claude Dev Server] Sent via sendToTerminal:', prompt)\n // 发送成功后展开面板\n setTimeout(() => togglePanel(true), 100)\n return true\n }\n\n return false\n }\n\n // Try immediately\n if (sendToTerminal()) {\n return\n }\n\n // If not ready, wait and retry\n let attempts = 0\n const maxAttempts = 50\n const retryInterval = setInterval(() => {\n attempts++\n if (sendToTerminal() || attempts >= maxAttempts) {\n clearInterval(retryInterval)\n if (attempts >= maxAttempts) {\n console.warn('[Claude Dev Server] Could not send to terminal after retries')\n }\n }\n }, 100)\n }\n\n function loadTerminalIframe(ttydUrl) {\n if (!terminalContainer || terminalIframe) return\n ttydWsUrl = ttydUrl\n\n // Create iframe pointing to ttyd/index.html with ttyd WebSocket URL\n terminalIframe = document.createElement('iframe')\n // Pass the ttyd WebSocket URL as query param\n terminalIframe.src = '/ttyd/index.html?ws=' + encodeURIComponent(ttydUrl)\n terminalIframe.allow = 'clipboard-read; clipboard-write'\n\n // Load event - iframe is ready\n terminalIframe.onload = () => {\n console.log('[Claude Dev Server] Terminal iframe loaded')\n }\n\n terminalContainer.appendChild(terminalIframe)\n }\n\n function createPanel() {\n if (panel) return\n\n panel = document.createElement('div')\n panel.className = 'claude-dev-server-panel'\n panel.innerHTML = \\`\n <div class=\"claude-dev-server-header\">\n <span class=\"claude-dev-server-title\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path d=\"M11.376 24L10.776 23.544L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336L11.904 15.288L11.784 15.312L10.344 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.784 20.616L8.16 17.568L9.6 15.672L10.536 14.592L10.512 14.448H10.464L4.128 18.576L3 18.72L2.496 18.264L2.568 17.52L2.808 17.28L4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.384 12.744L1.104 12.624L0.528 12.504L0 11.784L0.048 11.424L0.528 11.112L1.224 11.16L2.736 11.28L5.016 11.424L6.672 11.52L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.672L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.384 6.768L8.88 8.616L9.24 8.904L9.408 8.808V8.736L9.24 8.472L7.896 6.024L6.456 3.528L5.808 2.496L5.64 1.872C5.576 1.656 5.544 1.416 5.544 1.152L6.288 0.144001L6.696 0L7.704 0.144001L8.112 0.504001L8.736 1.92L9.72 4.152L11.28 7.176L11.736 8.088L11.976 8.904L12.072 9.168H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.840001L14.04 0.360001L14.616 0.624001L15.096 1.32L15.024 1.752L14.76 3.6L14.184 6.504L13.824 8.472H14.04L14.28 8.208L15.264 6.912L16.92 4.848L17.64 4.032L18.504 3.12L19.056 2.688H20.088L20.832 3.816L20.496 4.992L19.44 6.336L18.552 7.464L17.28 9.168L16.512 10.536L16.584 10.632H16.752L19.608 10.008L21.168 9.744L22.992 9.432L23.832 9.816L23.928 10.2L23.592 11.016L21.624 11.496L19.32 11.952L15.888 12.768L15.84 12.792L15.888 12.864L17.424 13.008L18.096 13.056H19.728L22.752 13.272L23.544 13.8L24 14.424L23.928 14.928L22.704 15.528L21.072 15.144L17.232 14.232L15.936 13.92H15.744V14.016L16.848 15.096L18.84 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.808L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.176L17.184 22.056L15.792 20.136L14.376 17.952L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24Z\" fill=\"#d97757\"/>\n </svg>\n Claude Code\n </span>\n <div class=\"claude-dev-server-actions\">\n <button class=\"claude-dev-server-btn claude-dev-server-btn-inspect\" title=\"Inspect Element\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M19 11V4a2 2 0 00-2-2H4a2 2 0 00-2 2v13a2 2 0 002 2h7\"/>\n <path d=\"M12 12l4.166 10 1.48-4.355L22 16.166 12 12z\"/>\n <path d=\"M18 18l3 3\"/>\n </svg>\n Inspect\n </button>\n </div>\n <button class=\"claude-dev-server-close\" aria-label=\"Close\" title=\"Minimize to icon\">&times;</button>\n </div>\n <div class=\"claude-dev-server-terminal\"></div>\n \\`\n\n document.body.appendChild(panel)\n\n terminalContainer = panel.querySelector('.claude-dev-server-terminal')\n const closeBtn = panel.querySelector('.claude-dev-server-close')\n const inspectBtn = panel.querySelector('.claude-dev-server-btn-inspect')\n\n closeBtn && closeBtn.addEventListener('click', () => togglePanel(false))\n\n inspectBtn && inspectBtn.addEventListener('click', () => {\n if (isInspectMode) {\n disableInspectMode()\n } else {\n // 点击 Inspect 时先收起面板\n if (isOpen) {\n togglePanel(false)\n }\n enableInspectMode()\n }\n })\n }\n\n function togglePanel(force) {\n createPanel()\n if (typeof force === 'boolean') {\n isOpen = force\n } else {\n isOpen = !isOpen\n }\n\n if (panel) panel.classList.toggle('open', isOpen)\n if (toggleBtn) toggleBtn.classList.toggle('hidden', isOpen)\n\n if (isOpen) {\n // Focus iframe when panel opens\n if (terminalIframe && terminalIframe.contentWindow) {\n setTimeout(() => {\n if (terminalIframe.contentWindow.terminalInstance) {\n terminalIframe.contentWindow.terminalInstance.focus()\n }\n }, 100)\n }\n }\n }\n\n function connect(port) {\n const WS_URL = 'ws://localhost:' + port\n ws = new WebSocket(WS_URL)\n\n ws.onopen = () => {\n console.log('[Claude Dev Server] Connected to control server')\n }\n\n ws.onmessage = (e) => {\n try {\n const msg = JSON.parse(e.data)\n console.log('[Claude Dev Server] Received message:', msg.type, msg)\n if (msg.type === 'ready' && msg.ttydUrl) {\n loadTerminalIframe(msg.ttydUrl)\n } else if (msg.type === 'inspectResult') {\n if (msg.location) {\n showContextPanel(msg.location, null, false)\n }\n }\n } catch (err) {\n console.error('[Claude Dev Server] Message parse error:', err)\n }\n }\n\n ws.onclose = () => {\n console.log('[Claude Dev Server] Control WebSocket disconnected, reconnecting...')\n setTimeout(() => connect(port), 2000)\n }\n\n ws.onerror = (err) => {\n console.error('[Claude Dev Server] Control WebSocket error:', err)\n }\n }\n\n initWhenReady()\n\n document.addEventListener('keydown', (e) => {\n if ((e.metaKey || e.ctrlKey) && e.code === 'Backquote') {\n e.preventDefault()\n togglePanel()\n }\n if (e.key === 'Escape' && isOpen) {\n togglePanel(false)\n }\n if (e.key === 'Escape' && isInspectMode) {\n disableInspectMode()\n }\n })\n})()\n`\n","import { spawn } from 'child_process'\nimport { existsSync, readFileSync } from 'fs'\nimport { createHash } from 'crypto'\nimport { join, dirname, relative, sep } from 'path'\nimport http from 'http'\nimport { fileURLToPath } from 'url'\nimport { createProxyMiddleware } from 'http-proxy-middleware'\nimport { WebSocketServer } from 'ws'\nimport { createConnection } from 'net'\nimport { SourceMapConsumer } from 'source-map'\nimport { createWebSocketServer } from '../server/websocket.js'\nimport { CLIENT_SCRIPT, CLIENT_STYLES } from '../client/injection.js'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nexport interface UniversalServerOptions {\n port?: number\n claudePath?: string\n claudeArgs?: string[]\n cwd?: string\n server?: {\n type?: 'vite' | 'next' | 'webpack' | 'custom'\n command?: string\n port?: number\n }\n}\n\nexport async function startUniversalServer(options: UniversalServerOptions = {}) {\n const cwd = options.cwd || process.cwd()\n const port = options.port || 3000\n\n // 1. 检测项目类型\n const projectType = options.server?.type || detectProjectType(cwd)\n const targetCommand = options.server?.command || getDefaultCommand(projectType)\n\n console.log(`[Claude Dev Server] Detected project type: ${projectType}`)\n console.log(`[Claude Dev Server] Starting target server...`)\n\n // 2. 启动目标 dev server(不预设端口)\n const targetServer = spawnTargetServer(targetCommand, cwd)\n\n // 3. 等待并检测目标服务器实际监听的端口\n console.log(`[Claude Dev Server] Waiting for target server to start (PID: ${targetServer.pid})...`)\n const targetPort = await detectServerPort(targetServer, 30000)\n\n if (!targetPort) {\n throw new Error('Failed to detect target server port. Please check if the dev server started successfully.')\n }\n\n console.log(`[Claude Dev Server] Target server is running on port ${targetPort}`)\n\n // 4. 启动控制 WebSocket 服务器(ttyd + Claude)\n const wsServer = createWebSocketServer({\n port: 0, // 自动分配端口\n projectRoot: cwd,\n claudePath: options.claudePath || 'claude',\n claudeArgs: options.claudeArgs || [],\n })\n\n const { wsPort, ttydPort } = await wsServer.start()\n console.log(`[Claude Dev Server] Control server running on ws://localhost:${wsPort}`)\n console.log(`[Claude Dev Server] ttyd running on ws://localhost:${ttydPort}`)\n\n // 5. 启动 HTTP 代理服务器\n const proxyServer = createProxyServer(targetPort, wsPort, cwd)\n proxyServer.listen(port)\n console.log(`[Claude Dev Server] Proxy server running on http://localhost:${port}`)\n console.log(`\\n🚀 Ready! Open http://localhost:${port} in your browser`)\n\n // 清理处理\n const cleanup = () => {\n console.log('[Claude Dev Server] Shutting down...')\n targetServer.kill()\n wsServer.stop()\n proxyServer.close()\n process.exit(0)\n }\n\n process.on('SIGINT', cleanup)\n process.on('SIGTERM', cleanup)\n\n return { proxyServer, targetServer, wsServer }\n}\n\nfunction detectProjectType(cwd: string): 'vite' | 'next' | 'webpack' | 'custom' {\n if (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {\n return 'vite'\n }\n if (existsSync(join(cwd, 'next.config.js')) || existsSync(join(cwd, 'next.config.mjs'))) {\n return 'next'\n }\n if (existsSync(join(cwd, 'webpack.config.js')) || existsSync(join(cwd, 'webpack.config.ts'))) {\n return 'webpack'\n }\n return 'custom'\n}\n\nfunction getDefaultCommand(projectType: string): string {\n switch (projectType) {\n case 'vite': return 'npm run dev'\n case 'next': return 'npm run dev'\n case 'webpack': return 'npm run dev'\n default: return 'npm run dev'\n }\n}\n\nfunction spawnTargetServer(command: string, cwd: string) {\n const [cmd, ...args] = command.split(' ')\n const child = spawn(cmd, args, {\n cwd,\n stdio: 'pipe',\n env: process.env,\n })\n\n // Forward child's stdout/stderr to parent so user can see dev server output\n child.stdout?.pipe(process.stdout)\n child.stderr?.pipe(process.stderr)\n\n return child\n}\n\n/**\n * Detect the port that the dev server is listening on by parsing stdout.\n * Most dev servers announce their port on startup like: \"Local: http://localhost:5173\"\n */\nasync function detectServerPort(childProcess: any, timeout: number): Promise<number | null> {\n return new Promise((resolve) => {\n const timeoutId = setTimeout(() => {\n cleanup()\n resolve(null)\n }, timeout)\n\n let stdout = ''\n\n const onData = (chunk: Buffer) => {\n stdout += chunk.toString()\n\n // Match common port announcement patterns:\n // Vite: \"Local: http://localhost:5173/\"\n // Next.js: \"Local: http://localhost:3000\"\n // Webpack: \"http://localhost:8080/\"\n const patterns = [\n /localhost:(\\d{4,5})/,\n /127\\.0\\.0\\.1:(\\d{4,5})/,\n /0\\.0\\.0\\.0:(\\d{4,5})/,\n ]\n\n for (const pattern of patterns) {\n const match = stdout.match(pattern)\n if (match) {\n const port = parseInt(match[1], 10)\n console.log(`[Claude Dev Server] Detected port from stdout: ${port}`)\n cleanup()\n resolve(port)\n return\n }\n }\n }\n\n const cleanup = () => {\n clearTimeout(timeoutId)\n childProcess.stdout?.off('data', onData)\n }\n\n childProcess.stdout?.on('data', onData)\n })\n}\n\n/**\n * Handle source map resolution request.\n * Given a compiled file path and line/column, find the original source position.\n */\nasync function handleSourceMapRequest(\n projectRoot: string,\n filePath: string,\n line: number,\n column: number,\n targetPort?: number\n): Promise<{ file?: string; line?: number; column?: number; original?: any; error?: string }> {\n try {\n let content: string\n let fullPath = filePath\n\n // If filePath starts with / and looks like a URL path, fetch from Vite\n if (filePath.startsWith('/') && targetPort) {\n // console.log('[Claude Dev Server] Fetching from Vite:', filePath)\n try {\n const response = await fetch(`http://localhost:${targetPort}${filePath}`)\n if (!response.ok) {\n console.log('[Claude Dev Server] Failed to fetch from Dev Server:', response.status)\n return { error: 'Failed to fetch from Dev Server' }\n }\n content = await response.text()\n console.log('[Claude Dev Server] Fetched', content.length, 'chars from Dev Server')\n } catch (e) {\n console.log('[Claude Dev Server] Fetch error:', e)\n return { error: 'Fetch error: ' + (e as Error).message }\n }\n } else {\n // If filePath is absolute, check if it's within projectRoot\n if (!filePath.startsWith('/')) {\n fullPath = join(projectRoot, filePath)\n }\n\n // Check if the file exists\n if (!existsSync(fullPath)) {\n console.log('[Claude Dev Server] File not found:', fullPath)\n return { error: 'File not found' }\n }\n\n // Read the file content\n content = readFileSync(fullPath, 'utf-8')\n\n console.log('[Claude Dev Server] Resolving source map for:', fullPath, 'at line:', line)\n }\n\n // Look for sourceMappingURL comment\n // Format: //# sourceMappingURL=filename.js.map or /*# sourceMappingURL=filename.js.map */\n // Or inline: //# sourceMappingURL=data:application/json;base64,...\n let sourceMapUrl: string | null = null\n const patterns = [\n /\\/\\/[@#]\\s*sourceMappingURL=([^\\s]+)/,\n /\\/\\*[@#]\\s*sourceMappingURL=([^\\s]+)\\s*\\*\\//\n ]\n\n for (const pattern of patterns) {\n const match = content.match(pattern)\n if (match) {\n sourceMapUrl = match[1]\n console.log('[Claude Dev Server] Found sourceMappingURL:', sourceMapUrl.substring(0, 100) + '...')\n break\n }\n }\n\n if (!sourceMapUrl) {\n console.log('[Claude Dev Server] No source map found in:', fullPath)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n\n let sourceMapContent: string\n let sourceMap: any\n\n // Check if it's an inline source map (data URL)\n if (sourceMapUrl.startsWith('data:application/json;base64,') ||\n sourceMapUrl.startsWith('data:application/json;charset=utf-8;base64,')) {\n console.log('[Claude Dev Server] Found inline source map')\n // Extract base64 content\n const base64Data = sourceMapUrl.split(',', 2)[1]\n sourceMapContent = Buffer.from(base64Data, 'base64').toString('utf-8')\n try {\n sourceMap = JSON.parse(sourceMapContent)\n } catch (e) {\n console.log('[Claude Dev Server] Failed to parse inline source map:', e)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n } else if (sourceMapUrl.startsWith('http://') || sourceMapUrl.startsWith('https://')) {\n // Remote source map - try to fetch via proxy\n console.log('[Claude Dev Server] Remote source map not supported:', sourceMapUrl)\n return { file: relative(projectRoot, fullPath), line, column }\n } else {\n // External source map file\n let sourceMapPath: string\n if (sourceMapUrl.startsWith('/')) {\n // Absolute path\n sourceMapPath = sourceMapUrl\n } else {\n // Relative path - resolve relative to the file\n sourceMapPath = join(dirname(fullPath), sourceMapUrl)\n }\n\n console.log('[Claude Dev Server] Reading external source map:', sourceMapPath)\n\n // Read the source map\n if (!existsSync(sourceMapPath)) {\n console.log('[Claude Dev Server] Source map file not found:', sourceMapPath)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n\n sourceMapContent = readFileSync(sourceMapPath, 'utf-8')\n sourceMap = JSON.parse(sourceMapContent)\n }\n\n // console.log('[Claude Dev Server] Source map loaded, sources:', sourceMap.sources?.length, 'mappings:', sourceMap.mappings?.substring(0, 50) + '...')\n // console.log('[Claude Dev Server] Source map sources:', sourceMap.sources)\n\n // Use source-map library to find original position\n const consumer = await new SourceMapConsumer(sourceMap)\n const original = consumer.originalPositionFor({\n line: line,\n column: column\n })\n consumer.destroy()\n\n // console.log('[Claude Dev Server] Source map result:', {\n // generated: { line, column },\n // original: original\n // })\n\n if (original.source && original.line !== null) {\n // Convert source path to be relative to project root\n let originalFile = original.source\n if (originalFile.startsWith('webpack://')) {\n // Remove webpack:// prefix\n originalFile = originalFile.replace(/^webpack:\\/\\/[\\/\\\\]?/, '')\n }\n // For Vite and other bundlers, source might be just a filename\n if (!originalFile.startsWith('/')) {\n // Try to resolve relative to project root to verify the file exists\n const possiblePath = join(projectRoot, originalFile)\n if (existsSync(possiblePath)) {\n // Keep the original source path as-is (preserves directory structure)\n // originalFile is already correct (e.g., 'src/App.jsx')\n } else {\n // File doesn't exist at the given path\n // Check if it's just a filename (no directory separators)\n const fileName = originalFile.split('/').pop() || originalFile.split('\\\\').pop() || originalFile\n if (fileName === originalFile) {\n // Source is just a filename (common with Vite inline source maps)\n // If filePath is already a relative path like '/src/App.jsx', use it directly\n if (filePath.startsWith('/')) {\n originalFile = filePath.substring(1) // Remove leading slash\n console.log('[Claude Dev Server] Source is just a filename, using filePath:', originalFile)\n } else {\n // Fall back to relative path from fullPath\n originalFile = relative(projectRoot, fullPath)\n }\n } else {\n // Has directory but file doesn't exist, use relative\n originalFile = relative(projectRoot, possiblePath)\n }\n }\n }\n\n // console.log('[Claude Dev Server] Source map resolved:', {\n // original: { file: originalFile, line: original.line, column: original.column },\n // generated: { file: filePath, line, column }\n // })\n\n return {\n file: originalFile,\n line: original.line,\n column: original.column || 1,\n original: {\n source: original.source,\n line: original.line,\n column: original.column,\n name: original.name\n }\n }\n }\n\n // No original position found, return generated\n return { file: relative(projectRoot, fullPath), line, column }\n } catch (err) {\n console.error('[Claude Dev Server] Source map resolution error:', err)\n return { error: String(err) }\n }\n}\n\n/**\n * Handle Next.js Turbopack source file lookup.\n * Given a page path, find the corresponding source file by parsing Turbopack chunks.\n */\nasync function handleTurbopackLookup(\n projectRoot: string,\n pagePath: string,\n targetPort: number\n): Promise<{ file?: string; line?: number; error?: string }> {\n try {\n console.log('[Claude Dev Server] Turbopack lookup for page:', pagePath)\n\n // Get the HTML page to find loaded chunk URLs\n const pageRes = await fetch(`http://localhost:${targetPort}${pagePath}`)\n if (!pageRes.ok) {\n return { error: 'Failed to fetch page' }\n }\n\n const html = await pageRes.text()\n const chunkUrls: string[] = []\n\n // Extract chunk URLs from HTML\n const scriptMatches = html.matchAll(/<script[^>]*src=\"([^\"]*\\/_next\\/static\\/chunks\\/[^\"]*)\"/g)\n for (const match of scriptMatches) {\n if (match[1]) {\n chunkUrls.push(match[1])\n }\n }\n\n console.log('[Claude Dev Server] Found', chunkUrls.length, 'chunk URLs')\n\n // Parse each chunk to find module paths\n for (const chunkUrl of chunkUrls) {\n try {\n const fullUrl = chunkUrl.startsWith('http') ? chunkUrl : `http://localhost:${targetPort}${chunkUrl}`\n const chunkRes = await fetch(fullUrl)\n if (!chunkRes.ok) continue\n\n const chunkContent = await chunkRes.text()\n\n // Extract module paths from Turbopack format\n // Format: \"[project]/path/to/file.tsx\" or \"[project]/path/to/file.tsx (ecmascript)\"\n const modulePathRegex = /\\[project\\]([^\\s\"]+\\.(tsx?|jsx?))/g\n const matches = [...chunkContent.matchAll(modulePathRegex)]\n\n for (const match of matches) {\n if (match[1]) {\n const sourcePath = match[1]\n // Remove [project] prefix and convert to relative path\n let relativePath = sourcePath.replace(/^\\[project\\]/, '')\n\n // Check if this path matches the current page\n // Normalize page path: /zh/login -> /login or /app/[lng]/(auth)/login/page.tsx\n const normalizedPagePath = pagePath.replace(/^\\/[^/]+/, '') // Remove language prefix\n\n if (relativePath.toLowerCase().includes(normalizedPagePath.toLowerCase()) ||\n relativePath.toLowerCase().includes('login')) {\n // Found matching source file\n console.log('[Claude Dev Server] Found source file:', relativePath)\n\n return {\n file: relativePath,\n line: undefined // Turbopack doesn't provide line numbers\n }\n }\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Error fetching chunk:', chunkUrl, e)\n }\n }\n\n return { error: 'Source file not found for page: ' + pagePath }\n } catch (err) {\n console.error('[Claude Dev Server] Turbopack lookup error:', err)\n return { error: String(err) }\n }\n}\n\nfunction createProxyServer(targetPort: number, wsPort: number, projectRoot: string) {\n // 读取 ttyd 资源文件\n // 从当前模块路径计算 assets 目录\n // moduleDir 是 /Users/lloyd/moox/claude-dev-server/dist\n // 所以需要 assets 是 /Users/lloyd/moox/claude-dev-server/dist/assets\n const moduleDir = dirname(fileURLToPath(import.meta.url))\n const assetsPath = join(moduleDir, 'assets')\n\n let ttydHtml: string\n let ttydBridgeJs: string\n\n try {\n ttydHtml = readFileSync(join(assetsPath, 'ttyd-terminal.html'), 'utf-8')\n ttydBridgeJs = readFileSync(join(assetsPath, 'ttyd-bridge.js'), 'utf-8')\n } catch (e: any) {\n console.error('[Claude Dev Server] Failed to read ttyd assets from', assetsPath)\n console.error('[Claude Dev Server] moduleDir:', moduleDir)\n console.error('[Claude Dev Server] Error:', e.message)\n throw new Error('ttyd assets not found. Please run `npm run build` first.')\n }\n\n const server = http.createServer((req, res) => {\n // 处理 @claude-port 端点\n if (req.url === '/@claude-port') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ port: wsPort }))\n return\n }\n\n // 处理 sourcemap 解析端点\n if (req.url?.startsWith('/@sourcemap?')) {\n const url = new URL(req.url, `http://localhost:${wsPort}`)\n const file = url.searchParams.get('file')\n const line = url.searchParams.get('line')\n const column = url.searchParams.get('col')\n\n if (file && line && column) {\n handleSourceMapRequest(projectRoot, file, parseInt(line), parseInt(column || '1'), targetPort)\n .then(result => {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n })\n .catch(err => {\n console.error('[Claude Dev Server] Source map error:', err)\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ error: err.message }))\n })\n return\n }\n }\n\n // 处理 Next.js/Turbopack 源文件查找端点\n if (req.url?.startsWith('/@sourcemap-lookup?')) {\n const url = new URL(req.url, `http://localhost:${wsPort}`)\n const page = url.searchParams.get('page')\n const framework = url.searchParams.get('framework')\n\n if (page && framework === 'nextjs') {\n handleTurbopackLookup(projectRoot, page, targetPort)\n .then(result => {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n })\n .catch(err => {\n console.error('[Claude Dev Server] Turbopack lookup error:', err)\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ error: err.message }))\n })\n return\n }\n }\n\n // 处理 /ttyd/* 路由\n if (req.url?.startsWith('/ttyd/')) {\n const urlPath = req.url.split('?')[0] // 移除查询参数\n\n if (urlPath === '/ttyd/index.html' || urlPath === '/ttyd/') {\n res.setHeader('Content-Type', 'text/html')\n res.end(ttydHtml)\n return\n }\n\n if (urlPath === '/ttyd/ttyd-bridge.js') {\n res.setHeader('Content-Type', 'application/javascript')\n res.end(ttydBridgeJs)\n return\n }\n\n // Handle ttyd token endpoint\n if (urlPath === '/ttyd/token' || urlPath === '/ttyd/index.html/token') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ token: '' }))\n return\n }\n\n // 其他 /ttyd/* 路由返回 404\n res.statusCode = 404\n res.end('Not found')\n return\n }\n\n // 代理到目标服务器并注入脚本\n // Remove accept-encoding to get uncompressed content (needed for script injection)\n const proxyHeaders = { ...req.headers }\n delete proxyHeaders['accept-encoding']\n\n const options = {\n hostname: 'localhost',\n port: targetPort,\n path: req.url,\n method: req.method,\n headers: proxyHeaders,\n }\n\n const proxyReq = http.request(options, (proxyRes) => {\n // 注入脚本到 HTML\n if (proxyRes.headers['content-type']?.includes('text/html')) {\n const body: Buffer[] = []\n proxyRes.on('data', (chunk) => body.push(chunk))\n proxyRes.on('end', () => {\n const html = Buffer.concat(body).toString('utf8')\n const injected = injectScripts(html, wsPort, projectRoot)\n const statusCode = proxyRes.statusCode || 200\n res.writeHead(statusCode, {\n ...proxyRes.headers,\n 'content-length': Buffer.byteLength(injected),\n })\n res.end(injected)\n })\n } else {\n const statusCode = proxyRes.statusCode || 200\n res.writeHead(statusCode, proxyRes.headers)\n proxyRes.pipe(res)\n }\n })\n\n proxyReq.on('error', (err) => {\n console.error('[Claude Dev Server] Proxy error:', err)\n res.statusCode = 502\n res.end('Bad Gateway')\n })\n\n req.pipe(proxyReq)\n })\n\n // Handle WebSocket upgrade requests (e.g., Next.js webpack-hmr, Vite HMR)\n server.on('upgrade', (req: any, socket: any, head: Buffer) => {\n // Check if this is a WebSocket upgrade request\n if (req.headers['upgrade']?.toLowerCase() !== 'websocket') {\n return\n }\n\n console.log('[Claude Dev Server] WebSocket upgrade request:', req.url)\n\n // Create raw TCP connection to target server\n const targetSocket = createConnection(targetPort, 'localhost', () => {\n console.log('[Claude Dev Server] Connected to target WebSocket server')\n\n // Forward the upgrade request to target\n const upgradeRequest = [\n `${req.method} ${req.url} HTTP/1.1`,\n `Host: localhost:${targetPort}`,\n 'Upgrade: websocket',\n 'Connection: Upgrade',\n `Sec-WebSocket-Key: ${req.headers['sec-websocket-key']}`,\n `Sec-WebSocket-Version: ${req.headers['sec-websocket-version'] || '13'}`,\n ]\n\n if (req.headers['sec-websocket-protocol']) {\n upgradeRequest.push(`Sec-WebSocket-Protocol: ${req.headers['sec-websocket-protocol']}`)\n }\n if (req.headers['sec-websocket-extensions']) {\n upgradeRequest.push(`Sec-WebSocket-Extensions: ${req.headers['sec-websocket-extensions']}`)\n }\n\n targetSocket.write(upgradeRequest.join('\\r\\n') + '\\r\\n\\r\\n')\n\n // Forward the head (remaining data from the upgrade request)\n if (head && head.length > 0) {\n targetSocket.write(head)\n }\n })\n\n // Handle response from target server\n targetSocket.on('data', (data: Buffer) => {\n if (socket.writable) {\n socket.write(data)\n }\n })\n\n // Handle data from client\n socket.on('data', (data: Buffer) => {\n if (targetSocket.writable) {\n targetSocket.write(data)\n }\n })\n\n // Handle connection close\n socket.on('close', () => {\n console.log('[Claude Dev Server] Client WebSocket closed')\n targetSocket.destroy()\n })\n\n targetSocket.on('close', () => {\n console.log('[Claude Dev Server] Target WebSocket closed')\n socket.end()\n })\n\n // Handle errors\n socket.on('error', (err: Error) => {\n console.error('[Claude Dev Server] Client socket error:', err.message)\n targetSocket.destroy()\n })\n\n targetSocket.on('error', (err: Error) => {\n console.error('[Claude Dev Server] Target socket error:', err.message)\n socket.end()\n })\n })\n\n return server\n}\n\nfunction injectScripts(html: string, wsPort: number, projectRoot: string): string {\n const projectRootScript = `<script>window.__CLAUDE_PROJECT_ROOT__ = ${JSON.stringify(projectRoot)}</script>`\n\n return html.replace(\n '</head>',\n `<!-- Claude Dev Server -->\\n${CLIENT_STYLES}\\n${projectRootScript}\\n<script type=\"module\">${CLIENT_SCRIPT}</script>\\n</head>`\n ).replace(\n /wsPort:\\s*\\d+/,\n `wsPort: ${wsPort}`\n )\n}\n\n/**\n * Generate Sec-WebSocket-Accept header value for WebSocket handshake.\n * RFC 6455: base64(sha1(clientKey + GUID))\n */\nfunction generateWebSocketAccept(clientKey: string): string {\n const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'\n const hash = createHash('sha1')\n .update(clientKey + GUID)\n .digest('base64')\n return hash\n}\n"]}
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { startUniversalServer } from './chunk-F6IKDNXJ.js';
2
+ import { startUniversalServer } from './chunk-RFPIOREI.js';
3
3
  import { execSync } from 'child_process';
4
4
 
5
5
  async function checkTtyd() {
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { startUniversalServer } from './chunk-F6IKDNXJ.js';
1
+ export { startUniversalServer } from './chunk-RFPIOREI.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-dev-server",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Universal dev server wrapper with Claude Code AI assistant - works with Vite, Next.js, Webpack and more",
5
5
  "author": "lloydzhou",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/server/pty.ts","../src/server/source-map.ts","../src/server/websocket.ts","../src/client/injection.js","../src/universal/index.ts"],"names":["resolve","__filename","spawn","SourceMapConsumer"],"mappings":";;;;;;;;;;;AAUO,SAAS,gBAAgB,OAAA,EAAqB;AAEnD,EAAA,MAAM,OAAO,GAAA,GAAQ,IAAA,CAAK,MAAM,IAAA,CAAK,MAAA,KAAW,GAAK,CAAA;AAGrD,EAAA,MAAM,QAAA,GAAW,MAAM,MAAA,EAAQ;AAAA,IAC7B,QAAA;AAAA,IAAU,OAAO,IAAI,CAAA;AAAA,IACrB,aAAA;AAAA,IAAe,WAAA;AAAA,IACf,YAAA;AAAA,IACA,OAAA,CAAQ,UAAA;AAAA,IACR,GAAG,OAAA,CAAQ;AAAA,GACb,EAAG;AAAA,IACD,KAAK,OAAA,CAAQ,GAAA;AAAA,IACb,GAAA,EAAK;AAAA,MACH,GAAG,OAAA,CAAQ,GAAA;AAAA,MACX,GAAG,OAAA,CAAQ,GAAA;AAAA,MACX,IAAA,EAAM,gBAAA;AAAA,MACN,WAAA,EAAa;AAAA;AACf,GACD,CAAA;AAED,EAAA,QAAA,CAAS,EAAA,CAAG,MAAA,EAAQ,CAAC,IAAA,KAAS;AAC5B,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,wCAAA,EAA2C,IAAI,CAAA,CAAE,CAAA;AAAA,EAC/D,CAAC,CAAA;AAED,EAAA,QAAA,CAAS,EAAA,CAAG,OAAA,EAAS,CAAC,GAAA,KAAQ;AAC5B,IAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,gCAAA,EAAmC,GAAA,CAAI,OAAO,CAAA,CA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EAA6B;AAChF,EAAA,MAAM,iBAAA,GAAoB,CAAA,yCAAA,EAA4C,IAAA,CAAK,SAAA,CAAU,WAAW,CAAC,CAAA,SAAA,CAAA;AAEjG,EAAA,OAAO,IAAA,CAAK,OAAA;AAAA,IACV,SAAA;AAAA,IACA,CAAA;AAAA,EAA+B,aAAa;AAAA,EAAK,iBAAiB;AAAA,sBAAA,EAA2B,aAAa,CAAA;AAAA,OAAA;AAAA,GAC5G,CAAE,OAAA;AAAA,IACA,eAAA;AAAA,IACA,WAAW,MAAM,CAAA;AAAA,GACnB;AACF","file":"chunk-F6IKDNXJ.js","sourcesContent":["import { spawn } from 'child_process'\nimport { randomBytes } from 'crypto'\n\nexport interface PtyOptions {\n cwd: string\n claudePath: string\n args: string[]\n env?: Record<string, string>\n}\n\nexport function spawnClaudeCode(options: PtyOptions) {\n // Generate a random port for ttyd\n const port = 50000 + Math.floor(Math.random() * 10000)\n\n // Start ttyd with claude command\n const ttydProc = spawn('ttyd', [\n '--port', String(port),\n '--interface', '127.0.0.1',\n '--writable',\n options.claudePath,\n ...options.args,\n ], {\n cwd: options.cwd,\n env: {\n ...process.env,\n ...options.env,\n TERM: 'xterm-256color',\n FORCE_COLOR: '1',\n },\n })\n\n ttydProc.on('exit', (code) => {\n console.log(`[claude-dev-server] ttyd exited - code: ${code}`)\n })\n\n ttydProc.on('error', (err) => {\n console.error(`[claude-dev-server] ttyd error: ${err.message}`)\n })\n\n // Wait a bit for ttyd to start, then return the WebSocket URL\n return new Promise<{ wsUrl: string; process: typeof ttydProc; port: number }>((resolve, reject) => {\n ttydProc.stdout?.on('data', (data: Buffer) => {\n const msg = data.toString()\n console.log(`[ttyd] ${msg}`)\n })\n\n ttydProc.stderr?.on('data', (data: Buffer) => {\n const msg = data.toString()\n console.error(`[ttyd stderr] ${msg}`)\n })\n\n // Give ttyd a moment to start\n setTimeout(() => {\n resolve({\n wsUrl: `ws://127.0.0.1:${port}`,\n process: ttydProc,\n port,\n })\n }, 500)\n\n ttydProc.on('error', reject)\n })\n}\n","import { SourceMapConsumer } from 'source-map'\n\nexport interface SourcePosition {\n source: string\n line: number\n column: number\n name?: string\n}\n\nexport interface CodeLocation {\n file: string\n line: number\n column: number\n content?: string\n}\n\n// Store source maps by generated file path\nconst sourceMapCache = new Map<string, SourceMapConsumer>()\n\nexport async function parseSourceMap(sourceMapUrl: string, content: string): Promise<void> {\n try {\n const consumer = await new SourceMapConsumer(content)\n sourceMapCache.set(sourceMapUrl, consumer)\n } catch (err) {\n console.error('Failed to parse source map:', err)\n }\n}\n\nexport async function findOriginalPosition(\n generatedFile: string,\n line: number,\n column: number\n): Promise<SourcePosition | null> {\n const consumer = sourceMapCache.get(generatedFile)\n if (!consumer) {\n return null\n }\n\n try {\n const position = consumer.originalPositionFor({ line, column })\n if (position.source) {\n return {\n source: position.source,\n line: position.line || 1,\n column: position.column || 0,\n name: position.name,\n }\n }\n } catch (err) {\n console.error('Failed to find original position:', err)\n }\n\n return null\n}\n\nexport function generateVSCodeURI(location: CodeLocation): string {\n // Generate VS Code URI scheme for opening files\n // vscode://file/{path}:{line}:{col}\n const filePath = location.file.replace(/\\\\/g, '/')\n return `vscode://file/${filePath}:${location.line}:${location.column}`\n}\n\nexport function formatCodeContext(location: CodeLocation): string {\n return `\n📍 Code Location:\n File: ${location.file}\n Line: ${location.line}\n Column: ${location.column}\n`\n}\n\nexport function clearCache() {\n sourceMapCache.clear()\n}\n","import { WebSocketServer, WebSocket } from 'ws'\nimport { spawnClaudeCode } from './pty.js'\nimport { findOriginalPosition, parseSourceMap, CodeLocation, formatCodeContext } from './source-map.js'\nimport { readFile } from 'fs/promises'\nimport { resolve } from 'path'\n\nexport interface WebSocketServerOptions {\n port?: number\n projectRoot: string\n claudePath: string\n claudeArgs: string[]\n}\n\nexport function createWebSocketServer(options: WebSocketServerOptions) {\n let wss: WebSocketServer | null = null\n let port = options.port || 0\n let ttydInfo: { wsUrl: string; process: any; port: number } | null = null\n\n const start = async (): Promise<{ wsPort: number; ttydPort: number }> => {\n // Start ttyd first\n console.log('[claude-dev-server] Starting ttyd...')\n ttydInfo = await spawnClaudeCode({\n cwd: options.projectRoot,\n claudePath: options.claudePath,\n args: options.claudeArgs,\n })\n console.log(`[claude-dev-server] ttyd running at ${ttydInfo.wsUrl}`)\n\n // Also start a simple WebSocket server for inspect functionality\n return new Promise((resolve, reject) => {\n wss = new WebSocketServer({ port, host: '127.0.0.1' })\n\n wss.on('listening', () => {\n const address = wss!.address()\n if (address && typeof address === 'object') {\n port = address.port\n resolve({ wsPort: port, ttydPort: ttydInfo!.port })\n }\n })\n\n wss.on('error', (err) => {\n reject(err)\n })\n\n wss.on('connection', (ws: WebSocket) => {\n ws.on('message', async (message: Buffer) => {\n try {\n const msg = JSON.parse(message.toString())\n\n if (msg.type === 'inspect') {\n await handleInspect(msg, ws, options.projectRoot)\n } else if (msg.type === 'loadSourceMap') {\n await handleLoadSourceMap(msg, ws, options.projectRoot)\n }\n } catch (err) {\n // Ignore\n }\n })\n\n // Send ready message with ttyd URL\n ws.send(JSON.stringify({\n type: 'ready',\n ttydUrl: ttydInfo!.wsUrl\n }))\n })\n })\n }\n\n const stop = () => {\n ttydInfo?.process.kill()\n wss?.close()\n }\n\n return { start, stop }\n}\n\nasync function handleLoadSourceMap(\n msg: any,\n ws: WebSocket,\n projectRoot: string\n) {\n const { sourceMapUrl } = msg\n try {\n const mapPath = resolve(projectRoot, sourceMapUrl.replace(/^\\//, ''))\n const content = await readFile(mapPath, 'utf-8')\n await parseSourceMap(sourceMapUrl, content)\n ws.send(JSON.stringify({\n type: 'sourceMapLoaded',\n sourceMapUrl,\n success: true\n }))\n } catch (err) {\n ws.send(JSON.stringify({\n type: 'sourceMapLoaded',\n sourceMapUrl,\n success: false,\n error: (err as Error).message\n }))\n }\n}\n\nasync function handleInspect(\n msg: any,\n ws: WebSocket,\n projectRoot: string\n) {\n const { url, line, column, sourceMapUrl } = msg\n\n let location: CodeLocation | null = null\n\n if (sourceMapUrl) {\n const original = await findOriginalPosition(sourceMapUrl, line, column)\n if (original) {\n location = {\n file: resolve(projectRoot, original.source),\n line: original.line,\n column: original.column,\n }\n }\n }\n\n if (!location) {\n const match = url.match(/\\/@fs\\/(.+?)(?:\\?|$)|\\/@vite\\/(.+?)(?:\\?|$)/)\n if (match) {\n location = {\n file: decodeURIComponent(match[1] || match[2]),\n line,\n column,\n }\n }\n }\n\n ws.send(JSON.stringify({\n type: 'inspectResult',\n location: location ? {\n file: location.file,\n line: location.line,\n column: location.column,\n context: formatCodeContext(location)\n } : null\n }))\n}\n","// Client-side script - pure JavaScript (no TypeScript)\n// This file will be injected into the browser\n\nexport const CLIENT_STYLES = `\n<style id=\"claude-dev-server-styles\">\n.claude-dev-server-toggle {\n position: fixed;\n bottom: 20px;\n right: 20px;\n width: 44px;\n height: 44px;\n background: #1e1e1e;\n border: none;\n border-radius: 50%;\n box-shadow: 0 2px 12px rgba(0,0,0,0.3);\n cursor: pointer;\n z-index: 999999;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 20px;\n transition: transform 0.2s, background 0.2s;\n padding: 0;\n}\n.claude-dev-server-toggle:hover {\n transform: scale(1.1);\n background: #2d2d2d;\n}\n.claude-dev-server-toggle.hidden {\n display: none;\n}\n.claude-dev-server-inspect-btn {\n position: fixed;\n bottom: 74px;\n right: 20px;\n width: 44px;\n height: 44px;\n background: #1e1e1e;\n border: none;\n border-radius: 50%;\n box-shadow: 0 2px 12px rgba(0,0,0,0.3);\n cursor: pointer;\n z-index: 999999;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n transition: transform 0.2s, background 0.2s;\n}\n.claude-dev-server-inspect-btn:hover {\n transform: scale(1.1);\n background: #2d2d2d;\n}\n.claude-dev-server-inspect-btn.active {\n background: #007acc;\n}\n.claude-dev-server-inspect-btn.hidden {\n display: none;\n}\n.claude-dev-server-toggle svg,\n.claude-dev-server-inspect-btn svg {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n}\n.claude-dev-server-panel {\n position: fixed;\n top: 0;\n right: 0;\n width: 650px;\n height: 100vh;\n background: #1e1e1e;\n color: #d4d4d4;\n font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;\n font-size: 13px;\n box-shadow: -4px 0 20px rgba(0,0,0,0.3);\n transform: translateX(100%);\n transition: transform 0.2s ease;\n z-index: 999999;\n display: flex;\n flex-direction: column;\n}\n.claude-dev-server-panel.open {\n transform: translateX(0);\n}\n.claude-dev-server-header {\n padding: 8px 12px;\n background: #2d2d2d;\n border-bottom: 1px solid #3e3e3e;\n display: flex;\n justify-content: space-between;\n align-items: center;\n user-select: none;\n}\n.claude-dev-server-title {\n font-weight: 600;\n color: #fff;\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n}\n.claude-dev-server-title::before {\n content: '🤖';\n font-size: 14px;\n}\n.claude-dev-server-actions {\n display: flex;\n gap: 6px;\n}\n.claude-dev-server-btn {\n background: #3e3e3e;\n border: none;\n color: #d4d4d4;\n cursor: pointer;\n font-family: inherit;\n font-size: 11px;\n padding: 4px 10px;\n border-radius: 3px;\n transition: background 0.15s;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.claude-dev-server-btn:hover {\n background: #4e4e4e;\n}\n.claude-dev-server-btn.active {\n background: #007acc;\n color: #fff;\n}\n.claude-dev-server-close {\n background: none;\n border: none;\n color: #858585;\n cursor: pointer;\n font-size: 18px;\n padding: 0;\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 3px;\n transition: background 0.15s, color 0.15s;\n}\n.claude-dev-server-close:hover {\n background: #3e3e3e;\n color: #fff;\n}\n.claude-dev-server-terminal {\n flex: 1;\n overflow: hidden;\n position: relative;\n background: #000;\n}\n.claude-dev-server-terminal iframe {\n width: 100%;\n height: 100%;\n border: none;\n}\n.claude-dev-server-inspect-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 999998;\n display: none;\n}\n.claude-dev-server-inspect-overlay.active {\n display: block;\n}\n.claude-dev-server-highlight {\n position: absolute;\n border: 2px solid #007acc;\n background: rgba(0, 122, 204, 0.1);\n pointer-events: none;\n transition: all 0.1s ease;\n}\n.claude-dev-server-highlight::after {\n content: attr(data-element);\n position: absolute;\n top: -20px;\n left: 0;\n background: #007acc;\n color: #fff;\n font-size: 10px;\n padding: 2px 4px;\n border-radius: 2px 2px 0 0;\n font-family: monospace;\n white-space: nowrap;\n}\n/* Responsive layout for portrait mode */\n@media (orientation: portrait) {\n .claude-dev-server-toggle {\n top: auto;\n bottom: 20px;\n right: 10px;\n width: 36px;\n height: 36px;\n }\n .claude-dev-server-inspect-btn {\n top: auto;\n bottom: 66px;\n right: 10px;\n width: 36px;\n height: 36px;\n }\n .claude-dev-server-panel {\n top: auto;\n bottom: 0;\n right: 0;\n left: 0;\n width: 100%;\n height: 80vh;\n transform: translateY(100%);\n box-shadow: 0 -4px 20px rgba(0,0,0,0.3);\n }\n .claude-dev-server-panel.open {\n transform: translateY(0);\n }\n .claude-dev-server-toggle svg,\n .claude-dev-server-inspect-btn svg {\n width: 16px;\n height: 16px;\n }\n}\n</style>\n`\n\nexport const CLIENT_SCRIPT = `\n(() => {\n let ws = null\n let panel = null\n let toggleBtn = null\n let inspectBtn = null // 悬浮 inspect 按钮\n let terminalContainer = null\n let terminalIframe = null\n let overlay = null\n let isOpen = false\n let isInspectMode = false\n let ttydWsUrl = null\n\n // Fetch the WebSocket port from the server\n async function getWsPort() {\n const res = await fetch('/@claude-port')\n const data = await res.json()\n return data.port\n }\n\n async function initWhenReady() {\n try {\n const port = await getWsPort()\n connect(port)\n } catch (err) {\n console.error('[Claude Dev Server] Failed to get port:', err)\n // Retry after 1 second\n setTimeout(initWhenReady, 1000)\n return\n }\n createToggleBtn()\n createInspectBtn()\n createOverlay()\n createPanel()\n }\n\n function createToggleBtn() {\n if (toggleBtn) return\n toggleBtn = document.createElement('button')\n toggleBtn.className = 'claude-dev-server-toggle'\n toggleBtn.innerHTML = '<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M11.376 24L10.776 23.544L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336L11.904 15.288L11.784 15.312L10.344 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.784 20.616L8.16 17.568L9.6 15.672L10.536 14.592L10.512 14.448H10.464L4.128 18.576L3 18.72L2.496 18.264L2.568 17.52L2.808 17.28L4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.384 12.744L1.104 12.624L0.528 12.504L0 11.784L0.048 11.424L0.528 11.112L1.224 11.16L2.736 11.28L5.016 11.424L6.672 11.52L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.672L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.384 6.768L8.88 8.616L9.24 8.904L9.408 8.808V8.736L9.24 8.472L7.896 6.024L6.456 3.528L5.808 2.496L5.64 1.872C5.576 1.656 5.544 1.416 5.544 1.152L6.288 0.144001L6.696 0L7.704 0.144001L8.112 0.504001L8.736 1.92L9.72 4.152L11.28 7.176L11.736 8.088L11.976 8.904L12.072 9.168H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.840001L14.04 0.360001L14.616 0.624001L15.096 1.32L15.024 1.752L14.76 3.6L14.184 6.504L13.824 8.472H14.04L14.28 8.208L15.264 6.912L16.92 4.848L17.64 4.032L18.504 3.12L19.056 2.688H20.088L20.832 3.816L20.496 4.992L19.44 6.336L18.552 7.464L17.28 9.168L16.512 10.536L16.584 10.632H16.752L19.608 10.008L21.168 9.744L22.992 9.432L23.832 9.816L23.928 10.2L23.592 11.016L21.624 11.496L19.32 11.952L15.888 12.768L15.84 12.792L15.888 12.864L17.424 13.008L18.096 13.056H19.728L22.752 13.272L23.544 13.8L24 14.424L23.928 14.928L22.704 15.528L21.072 15.144L17.232 14.232L15.936 13.92H15.744V14.016L16.848 15.096L18.84 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.808L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.176L17.184 22.056L15.792 20.136L14.376 17.952L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24Z\" fill=\"#d97757\"/></svg>'\n toggleBtn.title = 'Open Claude Code (Cmd/Ctrl + \\`)'\n toggleBtn.setAttribute('data-dev-tool', 'true')\n toggleBtn.addEventListener('click', () => togglePanel(true))\n document.body.appendChild(toggleBtn)\n }\n\n function createInspectBtn() {\n if (inspectBtn) return\n inspectBtn = document.createElement('button')\n inspectBtn.className = 'claude-dev-server-inspect-btn'\n inspectBtn.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 11V4a2 2 0 00-2-2H4a2 2 0 00-2 2v13a2 2 0 002 2h7\"/><path d=\"M12 12l4.166 10 1.48-4.355L22 16.166 12 12z\"/><path d=\"M18 18l3 3\"/></svg>'\n inspectBtn.title = 'Inspect Element (Cmd/Ctrl + Shift + I)'\n inspectBtn.setAttribute('data-dev-tool', 'true')\n inspectBtn.addEventListener('click', () => {\n if (isInspectMode) {\n disableInspectMode()\n } else {\n // 点击 Inspect 时先收起面板\n if (isOpen) {\n togglePanel(false)\n }\n enableInspectMode()\n }\n })\n document.body.appendChild(inspectBtn)\n }\n\n function createOverlay() {\n if (overlay) return\n overlay = document.createElement('div')\n overlay.className = 'claude-dev-server-inspect-overlay'\n document.body.appendChild(overlay)\n }\n\n function highlightElement(el) {\n if (!overlay) return\n overlay.innerHTML = ''\n const rect = el.getBoundingClientRect()\n const highlight = document.createElement('div')\n highlight.className = 'claude-dev-server-highlight'\n highlight.style.top = rect.top + 'px'\n highlight.style.left = rect.left + 'px'\n highlight.style.width = rect.width + 'px'\n highlight.style.height = rect.height + 'px'\n const className = el.className ? String(el.className) : ''\n highlight.dataset.element = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (className ? '.' + className.split(' ').join('.') : '')\n overlay.appendChild(highlight)\n }\n\n async function getSourceLocation(el) {\n // Early check: detect Next.js by checking for _next/static chunks\n const hasNextJsChunks = Array.from(document.querySelectorAll('script[src]'))\n .some(script => script.getAttribute('src')?.includes('/_next/static/chunks/'))\n\n if (hasNextJsChunks) {\n console.log('[Claude Dev Server] Next.js Turbopack detected, using specialized lookup')\n\n const pagePath = window.location.pathname\n console.log('[Claude Dev Server] Looking up source for page:', pagePath)\n\n try {\n const params = new URLSearchParams({\n page: pagePath,\n framework: 'nextjs'\n })\n const lookupUrl = '/@sourcemap-lookup?' + params.toString()\n console.log('[Claude Dev Server] Fetching:', lookupUrl)\n\n const response = await fetch(lookupUrl)\n console.log('[Claude Dev Server] Response status:', response.status)\n\n if (response.ok) {\n const result = await response.json()\n console.log('[Claude Dev Server] Lookup result:', result)\n if (result.file) {\n const elClassName = el.className ? String(el.className) : ''\n const selector = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (elClassName ? '.' + elClassName.split(' ').filter(c => c).join('.') : '')\n\n return {\n url: result.file,\n line: result.line || undefined,\n column: result.column || undefined,\n selector: selector,\n hint: 'File: ' + result.file\n }\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Next.js lookup failed:', e)\n }\n // If Next.js lookup failed, continue with normal flow\n }\n\n let sourceFile = null\n let sourceLine = 1\n let sourceColumn = 1\n\n // Try to get original line number using source map\n // Use server-side source map resolution with source-map library\n async function resolveSourceMap(filePath, line, column) {\n try {\n console.log('[Claude Dev Server] Calling server source map resolution for:', filePath, line, column)\n\n // Convert absolute file path to URL path for Vite\n let urlPath = filePath\n if (filePath.startsWith('/Users/')) {\n // Convert /Users/.../src/App.jsx to /src/App.jsx\n const parts = filePath.split('/')\n const srcIndex = parts.indexOf('src')\n if (srcIndex >= 0) {\n urlPath = '/' + parts.slice(srcIndex).join('/')\n }\n }\n\n console.log('[Claude Dev Server] Converted path to URL path:', urlPath)\n\n // Use the server-side source map resolution with URL path\n const params = new URLSearchParams({\n file: urlPath,\n line: String(line),\n col: String(column)\n })\n\n const response = await fetch('/@sourcemap?' + params.toString())\n if (!response.ok) {\n console.log('[Claude Dev Server] Source map request failed:', response.status)\n return null\n }\n\n const result = await response.json()\n console.log('[Claude Dev Server] Source map result:', result)\n\n if (result.error) {\n console.log('[Claude Dev Server] Source map error:', result.error)\n return null\n }\n\n if (result.file) {\n return {\n file: result.file,\n line: result.line,\n column: result.column\n }\n }\n\n return null\n } catch (e) {\n console.log('[Claude Dev Server] Source map lookup failed:', e.message)\n return null\n }\n }\n\n // Try to extract jsxDEV source location from React Fiber\n function extractJsxDevLocation(fiber) {\n try {\n // The jsxDEV location is stored in the element type's _debugInfo or _source\n // React 18 stores it differently - let's check multiple locations\n const elementType = fiber.elementType || fiber.type\n\n // Check if this is a jsxDEV call by looking at the string representation\n if (elementType && typeof elementType === 'function') {\n const fnStr = elementType.toString()\n // jsxDEV functions have a specific pattern\n if (fnStr.includes('jsxDEV') || fnStr.includes('jsx')) {\n console.log('[Claude Dev Server] Found jsxDEV element type')\n }\n }\n\n // Try to get _debugSource which might have jsxDEV metadata\n const debugSource = fiber._debugSource || fiber._debugInfo\n if (debugSource) {\n // For jsxDEV, check if there's a _source object with fileName/lineNumber\n const source = debugSource._source || debugSource.source || debugSource\n if (source && source.fileName && source.lineNumber !== undefined) {\n console.log('[Claude Dev Server] Found _debugSource with source location:', source)\n // NOTE: Don't use this directly! The lineNumber might be from transpiled code\n // We'll let the source map resolver handle it\n return null\n }\n }\n\n // Check the memoizedState or other properties for source location\n if (fiber.memoizedState) {\n // React might store jsxDEV location in memoizedState\n console.log('[Claude Dev Server] Checking memoizedState:', fiber.memoizedState)\n }\n\n // Check the memoizedProps or other properties for source location\n if (fiber.memoizedProps && fiber.memoizedProps.__source) {\n const source = fiber.memoizedProps.__source\n console.log('[Claude Dev Server] Found __source in memoizedProps:', source)\n return {\n file: source.fileName,\n line: source.lineNumber,\n column: source.columnNumber || 1\n }\n }\n\n // Check pendingProps for __source\n if (fiber.pendingProps && fiber.pendingProps.__source) {\n const source = fiber.pendingProps.__source\n console.log('[Claude Dev Server] Found __source in pendingProps:', source)\n return {\n file: source.fileName,\n line: source.lineNumber,\n column: source.columnNumber || 1\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Error extracting jsxDEV location:', e)\n }\n return null\n }\n\n // Try React DevTools - handle React 18's randomized suffix\n const elKeys = Object.keys(el)\n let fiberKey = elKeys.find(k => k === '__reactFiber__' || k === '__reactInternalInstance' || k.indexOf('__reactFiber') === 0)\n let propsKey = elKeys.find(k => k === '__reactProps__' || k.indexOf('__reactProps') === 0)\n\n if (fiberKey) {\n const fiber = el[fiberKey]\n console.log('[Claude Dev Server] Found fiber at key:', fiberKey)\n\n // Log fiber structure for debugging\n console.log('[Claude Dev Server] Fiber structure:', {\n _debugSource: fiber._debugSource,\n elementType: fiber.elementType,\n type: fiber.type,\n memoizedProps: fiber.memoizedProps,\n pendingProps: fiber.pendingProps\n })\n\n // Log _debugSource details\n if (fiber._debugSource) {\n console.log('[Claude Dev Server] _debugSource details:', JSON.stringify(fiber._debugSource, null, 2))\n }\n\n // For Next.js, try to get component name from elementType\n if (!fiber._debugSource && fiber.elementType) {\n const elementType = fiber.elementType\n console.log('[Claude Dev Server] elementType:', elementType)\n console.log('[Claude Dev Server] elementType.name:', elementType.name)\n console.log('[Claude Dev Server] elementType.displayName:', elementType.displayName)\n\n // Try to get the function string to find component name\n if (typeof elementType === 'function') {\n const fnStr = elementType.toString()\n console.log('[Claude Dev Server] elementType function:', fnStr.substring(0, 200))\n }\n }\n\n // First, try to extract jsxDEV source location\n const jsxDevLocation = extractJsxDevLocation(fiber)\n if (jsxDevLocation) {\n sourceFile = jsxDevLocation.file\n sourceLine = jsxDevLocation.line\n sourceColumn = jsxDevLocation.column\n\n // Convert absolute path to relative path\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n console.log('[Claude Dev Server] Using jsxDEV location:', sourceFile, sourceLine)\n } else {\n // Fall back to _debugSource\n const debugSource = fiber._debugSource || fiber.elementType?._debugSource || fiber.type?._debugSource || fiber.alternate?._debugSource\n if (debugSource && debugSource.fileName) {\n sourceFile = debugSource.fileName\n sourceLine = debugSource.lineNumber || 1\n sourceColumn = debugSource.columnNumber || 1\n\n // Convert relative path to absolute path for source map resolution\n let absolutePath = sourceFile\n if (!sourceFile.startsWith('/')) {\n // Relative path - resolve relative to project root\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n absolutePath = projectRoot + '/' + sourceFile\n }\n\n console.log('[Claude Dev Server] Resolving source map for:', absolutePath, 'at line:', sourceLine)\n\n // Use server-side source map resolution\n const original = await resolveSourceMap(absolutePath, sourceLine, sourceColumn)\n if (original) {\n sourceFile = original.file\n sourceLine = original.line\n sourceColumn = original.column\n console.log('[Claude Dev Server] Original location from source map:', sourceFile, sourceLine)\n } else {\n // Source map resolution failed, use the original file\n // Convert absolute path back to relative\n if (absolutePath.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && absolutePath.startsWith(projectRoot)) {\n sourceFile = absolutePath.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n }\n console.log('[Claude Dev Server] Final React source:', sourceFile, sourceLine)\n } else {\n // Try going up the fiber tree\n let currentFiber = fiber\n let depth = 0\n while (currentFiber && depth < 20) {\n const jsxDevLoc = extractJsxDevLocation(currentFiber)\n if (jsxDevLoc) {\n sourceFile = jsxDevLoc.file\n sourceLine = jsxDevLoc.line\n sourceColumn = jsxDevLoc.column\n\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n console.log('[Claude Dev Server] Found jsxDEV location at depth', depth, ':', sourceFile, sourceLine)\n break\n }\n\n const ds = currentFiber._debugSource || currentFiber.elementType?._debugSource || currentFiber.type?._debugSource\n if (ds && ds.fileName) {\n sourceFile = ds.fileName\n sourceLine = ds.lineNumber || 1\n sourceColumn = ds.columnNumber || 1\n\n // Use server-side source map resolution\n const original = await resolveSourceMap(sourceFile, sourceLine, sourceColumn)\n if (original) {\n sourceFile = original.file\n sourceLine = original.line\n sourceColumn = original.column\n } else {\n // Convert absolute path to relative path using project root\n if (sourceFile.startsWith('/')) {\n const projectRoot = window.__CLAUDE_PROJECT_ROOT__\n if (projectRoot && sourceFile.startsWith(projectRoot)) {\n sourceFile = sourceFile.substring(projectRoot.length + 1)\n if (sourceFile.startsWith('/')) {\n sourceFile = sourceFile.substring(1)\n }\n }\n }\n }\n console.log('[Claude Dev Server] Found React source at depth', depth, ':', sourceFile, sourceLine)\n break\n }\n currentFiber = currentFiber.return || currentFiber.alternate\n depth++\n }\n }\n }\n }\n\n // Try Vue component\n if (!sourceFile) {\n const vueComponent = el.__vueParentComponent || el.__vnode\n if (vueComponent) {\n const type = vueComponent.type || vueComponent.component\n if (type && type.__file) {\n sourceFile = type.__file\n console.log('[Claude Dev Server] Found Vue source:', sourceFile)\n }\n }\n }\n\n // Try Vite's HMR source map\n if (!sourceFile) {\n // Look for data-vite-dev-id or similar attributes\n const viteId = el.getAttribute('data-vite-dev-id')\n if (viteId) {\n // Extract file path from viteId (remove query params if any)\n const queryIndex = viteId.indexOf('?')\n sourceFile = '/' + (queryIndex >= 0 ? viteId.substring(0, queryIndex) : viteId)\n console.log('[Claude Dev Server] Found Vite ID:', viteId)\n }\n }\n\n // Check for inline script\n if (!sourceFile) {\n const inlineScripts = document.querySelectorAll('script:not([src])')\n if (inlineScripts.length > 0) {\n const pathParts = window.location.pathname.split('/')\n const fileName = pathParts[pathParts.length - 1] || 'index.html'\n sourceFile = '/' + fileName\n\n const html = document.documentElement.outerHTML\n const elId = el.id ? el.id : ''\n const elClass = el.className ? el.className : ''\n let elPattern\n if (elId) {\n elPattern = 'id=\"' + elId + '\"'\n } else if (elClass) {\n elPattern = 'class=\"' + elClass.split(' ')[0] + '\"'\n } else {\n elPattern = el.tagName.toLowerCase()\n }\n\n const matchIndex = html.indexOf(elPattern)\n if (matchIndex !== -1) {\n const beforeElement = html.substring(0, matchIndex)\n sourceLine = beforeElement.split('\\\\n').length\n }\n }\n }\n\n // Find main script\n if (!sourceFile) {\n const scripts = document.querySelectorAll('script[src]')\n for (const script of scripts) {\n const src = script.getAttribute('src')\n if (src && !src.includes('cdn') && !src.includes('node_modules') &&\n (src.includes('/src/') || src.includes('/app.') || src.includes('/main.'))) {\n sourceFile = src\n break\n }\n }\n }\n\n // Fallback\n if (!sourceFile) {\n const pathParts = window.location.pathname.split('/')\n const fileName = pathParts[pathParts.length - 1] || 'index.html'\n sourceFile = '/' + fileName\n }\n\n const elClassName = el.className ? String(el.className) : ''\n const selector = el.tagName.toLowerCase() +\n (el.id ? '#' + el.id : '') +\n (elClassName ? '.' + elClassName.split(' ').filter(c => c).join('.') : '')\n\n return {\n url: sourceFile,\n line: sourceLine,\n column: sourceColumn,\n selector: selector,\n hint: sourceFile ? 'File: ' + sourceFile : 'Element: ' + selector\n }\n }\n\n function enableInspectMode() {\n isInspectMode = true\n overlay && overlay.classList.add('active')\n document.body.style.cursor = 'crosshair'\n\n // 更新悬浮 inspect 按钮状态\n if (inspectBtn) inspectBtn.classList.add('active')\n\n // 检查元素是否属于 dev tools\n function isDevToolElement(el) {\n if (!el) return false\n // 检查元素本身\n if (el.dataset && el.dataset.devTool === 'true') return true\n // 检查父元素\n let parent = el.parentElement\n while (parent) {\n if (parent.dataset && parent.dataset.devTool === 'true') return true\n parent = parent.parentElement\n }\n return false\n }\n\n const onMouseMove = async (e) => {\n if (!isInspectMode) return\n const el = document.elementFromPoint(e.clientX, e.clientY)\n // 忽略 dev tools 元素和 overlay\n if (el && el !== overlay && !isDevToolElement(el) && (!overlay || !overlay.contains(el))) {\n highlightElement(el)\n }\n }\n\n const onClick = async (e) => {\n if (!isInspectMode) return\n e.preventDefault()\n e.stopPropagation()\n\n const el = document.elementFromPoint(e.clientX, e.clientY)\n // 忽略 dev tools 元素和 overlay\n if (el && el !== overlay && !isDevToolElement(el) && (!overlay || !overlay.contains(el))) {\n const location = await getSourceLocation(el)\n if (location) {\n await inspectElement(location, el)\n }\n disableInspectMode()\n }\n }\n\n document.addEventListener('mousemove', onMouseMove, true)\n document.addEventListener('click', onClick, true)\n\n if (overlay) overlay._inspectHandlers = { onMouseMove, onClick }\n }\n\n function disableInspectMode() {\n isInspectMode = false\n if (overlay) overlay.classList.remove('active')\n document.body.style.cursor = ''\n if (overlay) overlay.innerHTML = ''\n\n // 更新悬浮 inspect 按钮状态\n if (inspectBtn) inspectBtn.classList.remove('active')\n\n const btn = panel && panel.querySelector('.claude-dev-server-btn-inspect')\n if (btn) btn.classList.remove('active')\n\n const handlers = overlay && overlay._inspectHandlers\n if (handlers) {\n document.removeEventListener('mousemove', handlers.onMouseMove, true)\n document.removeEventListener('click', handlers.onClick, true)\n }\n }\n\n async function inspectElement(location, el) {\n // 构建格式化的 prompt\n const filePath = location.url || location.file || 'unknown'\n const tagName = el.tagName ? el.tagName.toLowerCase() : ''\n const id = el.id ? '#' + el.id : ''\n\n // 对于 Tailwind CSS 等大量 class 的情况,只取前 2-3 个 class\n let className = ''\n if (el.className) {\n const classes = String(el.className).split(' ').filter(c => c)\n // 如果 class 太多(可能是 Tailwind),只取前 2 个\n if (classes.length > 5) {\n className = '.' + classes.slice(0, 2).join('.')\n } else {\n className = '.' + classes.join('.')\n }\n }\n\n const selector = tagName + id + className\n\n // 获取元素的文本内容(如果是文本节点或短文本元素)\n let textContent = ''\n if (el.nodeType === Node.TEXT_NODE) {\n textContent = el.textContent ? el.textContent.trim().substring(0, 50) : ''\n } else if (el.childNodes.length === 1 && el.childNodes[0].nodeType === Node.TEXT_NODE) {\n textContent = el.childNodes[0].textContent ? el.childNodes[0].textContent.trim().substring(0, 50) : ''\n }\n\n // Check if file is in node_modules - if so, skip the @filename part\n const isNodeModules = filePath.includes('node_modules')\n\n // 格式: @filename:line <selector> \"text content\" 或 @filename <selector> \"text content\"\n // 如果是 node_modules 文件,只保留 <selector> \"text content\"\n let prompt = ''\n if (isNodeModules) {\n // Skip @filename for node_modules, just show element and text\n prompt = \\`<\\${selector}>\\`\n if (textContent) {\n prompt += \\` \"\\${textContent}\"\\`\n }\n console.log('[Claude Dev Server] Skipping node_modules path:', filePath)\n } else {\n const linePart = location.line ? \\`:\\${location.line}\\` : ''\n prompt = \\`@\\${filePath}\\${linePart} <\\${selector}>\\`\n if (textContent) {\n prompt += \\` \"\\${textContent}\"\\`\n }\n }\n\n // 发送成功后展开面板\n const sendToTerminal = () => {\n if (!terminalIframe || !terminalIframe.contentWindow) {\n return false\n }\n\n const win = terminalIframe.contentWindow\n\n // Check if sendToTerminal function is available\n if (win.sendToTerminal) {\n win.sendToTerminal(prompt)\n console.log('[Claude Dev Server] Sent via sendToTerminal:', prompt)\n // 发送成功后展开面板\n setTimeout(() => togglePanel(true), 100)\n return true\n }\n\n return false\n }\n\n // Try immediately\n if (sendToTerminal()) {\n return\n }\n\n // If not ready, wait and retry\n let attempts = 0\n const maxAttempts = 50\n const retryInterval = setInterval(() => {\n attempts++\n if (sendToTerminal() || attempts >= maxAttempts) {\n clearInterval(retryInterval)\n if (attempts >= maxAttempts) {\n console.warn('[Claude Dev Server] Could not send to terminal after retries')\n }\n }\n }, 100)\n }\n\n function loadTerminalIframe(ttydUrl) {\n if (!terminalContainer || terminalIframe) return\n ttydWsUrl = ttydUrl\n\n // Create iframe pointing to ttyd/index.html with ttyd WebSocket URL\n terminalIframe = document.createElement('iframe')\n // Pass the ttyd WebSocket URL as query param\n terminalIframe.src = '/ttyd/index.html?ws=' + encodeURIComponent(ttydUrl)\n terminalIframe.allow = 'clipboard-read; clipboard-write'\n\n // Load event - iframe is ready\n terminalIframe.onload = () => {\n console.log('[Claude Dev Server] Terminal iframe loaded')\n }\n\n terminalContainer.appendChild(terminalIframe)\n }\n\n function createPanel() {\n if (panel) return\n\n panel = document.createElement('div')\n panel.className = 'claude-dev-server-panel'\n panel.innerHTML = \\`\n <div class=\"claude-dev-server-header\">\n <span class=\"claude-dev-server-title\">Claude Code</span>\n <div class=\"claude-dev-server-actions\">\n <button class=\"claude-dev-server-btn claude-dev-server-btn-inspect\" title=\"Inspect Element\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M2 12h20M12 2v20M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07\"/>\n </svg>\n Inspect\n </button>\n </div>\n <button class=\"claude-dev-server-close\" aria-label=\"Close\" title=\"Minimize to icon\">&times;</button>\n </div>\n <div class=\"claude-dev-server-terminal\"></div>\n \\`\n\n document.body.appendChild(panel)\n\n terminalContainer = panel.querySelector('.claude-dev-server-terminal')\n const closeBtn = panel.querySelector('.claude-dev-server-close')\n const inspectBtn = panel.querySelector('.claude-dev-server-btn-inspect')\n\n closeBtn && closeBtn.addEventListener('click', () => togglePanel(false))\n\n inspectBtn && inspectBtn.addEventListener('click', () => {\n if (isInspectMode) {\n disableInspectMode()\n } else {\n // 点击 Inspect 时先收起面板\n if (isOpen) {\n togglePanel(false)\n }\n enableInspectMode()\n }\n })\n }\n\n function togglePanel(force) {\n createPanel()\n if (typeof force === 'boolean') {\n isOpen = force\n } else {\n isOpen = !isOpen\n }\n\n if (panel) panel.classList.toggle('open', isOpen)\n if (toggleBtn) toggleBtn.classList.toggle('hidden', isOpen)\n\n if (isOpen) {\n // Focus iframe when panel opens\n if (terminalIframe && terminalIframe.contentWindow) {\n setTimeout(() => {\n if (terminalIframe.contentWindow.terminalInstance) {\n terminalIframe.contentWindow.terminalInstance.focus()\n }\n }, 100)\n }\n }\n }\n\n function connect(port) {\n const WS_URL = 'ws://localhost:' + port\n ws = new WebSocket(WS_URL)\n\n ws.onopen = () => {\n console.log('[Claude Dev Server] Connected to control server')\n }\n\n ws.onmessage = (e) => {\n try {\n const msg = JSON.parse(e.data)\n console.log('[Claude Dev Server] Received message:', msg.type, msg)\n if (msg.type === 'ready' && msg.ttydUrl) {\n loadTerminalIframe(msg.ttydUrl)\n } else if (msg.type === 'inspectResult') {\n if (msg.location) {\n showContextPanel(msg.location, null, false)\n }\n }\n } catch (err) {\n console.error('[Claude Dev Server] Message parse error:', err)\n }\n }\n\n ws.onclose = () => {\n console.log('[Claude Dev Server] Control WebSocket disconnected, reconnecting...')\n setTimeout(() => connect(port), 2000)\n }\n\n ws.onerror = (err) => {\n console.error('[Claude Dev Server] Control WebSocket error:', err)\n }\n }\n\n initWhenReady()\n\n document.addEventListener('keydown', (e) => {\n if ((e.metaKey || e.ctrlKey) && e.code === 'Backquote') {\n e.preventDefault()\n togglePanel()\n }\n if (e.key === 'Escape' && isOpen) {\n togglePanel(false)\n }\n if (e.key === 'Escape' && isInspectMode) {\n disableInspectMode()\n }\n })\n})()\n`\n","import { spawn } from 'child_process'\nimport { existsSync, readFileSync } from 'fs'\nimport { createHash } from 'crypto'\nimport { join, dirname, relative, sep } from 'path'\nimport http from 'http'\nimport { fileURLToPath } from 'url'\nimport { createProxyMiddleware } from 'http-proxy-middleware'\nimport { WebSocketServer } from 'ws'\nimport { createConnection } from 'net'\nimport { SourceMapConsumer } from 'source-map'\nimport { createWebSocketServer } from '../server/websocket.js'\nimport { CLIENT_SCRIPT, CLIENT_STYLES } from '../client/injection.js'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nexport interface UniversalServerOptions {\n port?: number\n claudePath?: string\n claudeArgs?: string[]\n cwd?: string\n server?: {\n type?: 'vite' | 'next' | 'webpack' | 'custom'\n command?: string\n port?: number\n }\n}\n\nexport async function startUniversalServer(options: UniversalServerOptions = {}) {\n const cwd = options.cwd || process.cwd()\n const port = options.port || 3000\n\n // 1. 检测项目类型\n const projectType = options.server?.type || detectProjectType(cwd)\n const targetCommand = options.server?.command || getDefaultCommand(projectType)\n\n console.log(`[Claude Dev Server] Detected project type: ${projectType}`)\n console.log(`[Claude Dev Server] Starting target server...`)\n\n // 2. 启动目标 dev server(不预设端口)\n const targetServer = spawnTargetServer(targetCommand, cwd)\n\n // 3. 等待并检测目标服务器实际监听的端口\n console.log(`[Claude Dev Server] Waiting for target server to start (PID: ${targetServer.pid})...`)\n const targetPort = await detectServerPort(targetServer, 30000)\n\n if (!targetPort) {\n throw new Error('Failed to detect target server port. Please check if the dev server started successfully.')\n }\n\n console.log(`[Claude Dev Server] Target server is running on port ${targetPort}`)\n\n // 4. 启动控制 WebSocket 服务器(ttyd + Claude)\n const wsServer = createWebSocketServer({\n port: 0, // 自动分配端口\n projectRoot: cwd,\n claudePath: options.claudePath || 'claude',\n claudeArgs: options.claudeArgs || [],\n })\n\n const { wsPort, ttydPort } = await wsServer.start()\n console.log(`[Claude Dev Server] Control server running on ws://localhost:${wsPort}`)\n console.log(`[Claude Dev Server] ttyd running on ws://localhost:${ttydPort}`)\n\n // 5. 启动 HTTP 代理服务器\n const proxyServer = createProxyServer(targetPort, wsPort, cwd)\n proxyServer.listen(port)\n console.log(`[Claude Dev Server] Proxy server running on http://localhost:${port}`)\n console.log(`\\n🚀 Ready! Open http://localhost:${port} in your browser`)\n\n // 清理处理\n const cleanup = () => {\n console.log('[Claude Dev Server] Shutting down...')\n targetServer.kill()\n wsServer.stop()\n proxyServer.close()\n process.exit(0)\n }\n\n process.on('SIGINT', cleanup)\n process.on('SIGTERM', cleanup)\n\n return { proxyServer, targetServer, wsServer }\n}\n\nfunction detectProjectType(cwd: string): 'vite' | 'next' | 'webpack' | 'custom' {\n if (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {\n return 'vite'\n }\n if (existsSync(join(cwd, 'next.config.js')) || existsSync(join(cwd, 'next.config.mjs'))) {\n return 'next'\n }\n if (existsSync(join(cwd, 'webpack.config.js')) || existsSync(join(cwd, 'webpack.config.ts'))) {\n return 'webpack'\n }\n return 'custom'\n}\n\nfunction getDefaultCommand(projectType: string): string {\n switch (projectType) {\n case 'vite': return 'npm run dev'\n case 'next': return 'npm run dev'\n case 'webpack': return 'npm run dev'\n default: return 'npm run dev'\n }\n}\n\nfunction spawnTargetServer(command: string, cwd: string) {\n const [cmd, ...args] = command.split(' ')\n const child = spawn(cmd, args, {\n cwd,\n stdio: 'pipe',\n env: process.env,\n })\n\n // Forward child's stdout/stderr to parent so user can see dev server output\n child.stdout?.pipe(process.stdout)\n child.stderr?.pipe(process.stderr)\n\n return child\n}\n\n/**\n * Detect the port that the dev server is listening on by parsing stdout.\n * Most dev servers announce their port on startup like: \"Local: http://localhost:5173\"\n */\nasync function detectServerPort(childProcess: any, timeout: number): Promise<number | null> {\n return new Promise((resolve) => {\n const timeoutId = setTimeout(() => {\n cleanup()\n resolve(null)\n }, timeout)\n\n let stdout = ''\n\n const onData = (chunk: Buffer) => {\n stdout += chunk.toString()\n\n // Match common port announcement patterns:\n // Vite: \"Local: http://localhost:5173/\"\n // Next.js: \"Local: http://localhost:3000\"\n // Webpack: \"http://localhost:8080/\"\n const patterns = [\n /localhost:(\\d{4,5})/,\n /127\\.0\\.0\\.1:(\\d{4,5})/,\n /0\\.0\\.0\\.0:(\\d{4,5})/,\n ]\n\n for (const pattern of patterns) {\n const match = stdout.match(pattern)\n if (match) {\n const port = parseInt(match[1], 10)\n console.log(`[Claude Dev Server] Detected port from stdout: ${port}`)\n cleanup()\n resolve(port)\n return\n }\n }\n }\n\n const cleanup = () => {\n clearTimeout(timeoutId)\n childProcess.stdout?.off('data', onData)\n }\n\n childProcess.stdout?.on('data', onData)\n })\n}\n\n/**\n * Handle source map resolution request.\n * Given a compiled file path and line/column, find the original source position.\n */\nasync function handleSourceMapRequest(\n projectRoot: string,\n filePath: string,\n line: number,\n column: number,\n targetPort?: number\n): Promise<{ file?: string; line?: number; column?: number; original?: any; error?: string }> {\n try {\n let content: string\n let fullPath = filePath\n\n // If filePath starts with / and looks like a URL path, fetch from Vite\n if (filePath.startsWith('/') && targetPort) {\n // console.log('[Claude Dev Server] Fetching from Vite:', filePath)\n try {\n const response = await fetch(`http://localhost:${targetPort}${filePath}`)\n if (!response.ok) {\n console.log('[Claude Dev Server] Failed to fetch from Dev Server:', response.status)\n return { error: 'Failed to fetch from Dev Server' }\n }\n content = await response.text()\n console.log('[Claude Dev Server] Fetched', content.length, 'chars from Dev Server')\n } catch (e) {\n console.log('[Claude Dev Server] Fetch error:', e)\n return { error: 'Fetch error: ' + (e as Error).message }\n }\n } else {\n // If filePath is absolute, check if it's within projectRoot\n if (!filePath.startsWith('/')) {\n fullPath = join(projectRoot, filePath)\n }\n\n // Check if the file exists\n if (!existsSync(fullPath)) {\n console.log('[Claude Dev Server] File not found:', fullPath)\n return { error: 'File not found' }\n }\n\n // Read the file content\n content = readFileSync(fullPath, 'utf-8')\n\n console.log('[Claude Dev Server] Resolving source map for:', fullPath, 'at line:', line)\n }\n\n // Look for sourceMappingURL comment\n // Format: //# sourceMappingURL=filename.js.map or /*# sourceMappingURL=filename.js.map */\n // Or inline: //# sourceMappingURL=data:application/json;base64,...\n let sourceMapUrl: string | null = null\n const patterns = [\n /\\/\\/[@#]\\s*sourceMappingURL=([^\\s]+)/,\n /\\/\\*[@#]\\s*sourceMappingURL=([^\\s]+)\\s*\\*\\//\n ]\n\n for (const pattern of patterns) {\n const match = content.match(pattern)\n if (match) {\n sourceMapUrl = match[1]\n console.log('[Claude Dev Server] Found sourceMappingURL:', sourceMapUrl.substring(0, 100) + '...')\n break\n }\n }\n\n if (!sourceMapUrl) {\n console.log('[Claude Dev Server] No source map found in:', fullPath)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n\n let sourceMapContent: string\n let sourceMap: any\n\n // Check if it's an inline source map (data URL)\n if (sourceMapUrl.startsWith('data:application/json;base64,') ||\n sourceMapUrl.startsWith('data:application/json;charset=utf-8;base64,')) {\n console.log('[Claude Dev Server] Found inline source map')\n // Extract base64 content\n const base64Data = sourceMapUrl.split(',', 2)[1]\n sourceMapContent = Buffer.from(base64Data, 'base64').toString('utf-8')\n try {\n sourceMap = JSON.parse(sourceMapContent)\n } catch (e) {\n console.log('[Claude Dev Server] Failed to parse inline source map:', e)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n } else if (sourceMapUrl.startsWith('http://') || sourceMapUrl.startsWith('https://')) {\n // Remote source map - try to fetch via proxy\n console.log('[Claude Dev Server] Remote source map not supported:', sourceMapUrl)\n return { file: relative(projectRoot, fullPath), line, column }\n } else {\n // External source map file\n let sourceMapPath: string\n if (sourceMapUrl.startsWith('/')) {\n // Absolute path\n sourceMapPath = sourceMapUrl\n } else {\n // Relative path - resolve relative to the file\n sourceMapPath = join(dirname(fullPath), sourceMapUrl)\n }\n\n console.log('[Claude Dev Server] Reading external source map:', sourceMapPath)\n\n // Read the source map\n if (!existsSync(sourceMapPath)) {\n console.log('[Claude Dev Server] Source map file not found:', sourceMapPath)\n return { file: relative(projectRoot, fullPath), line, column }\n }\n\n sourceMapContent = readFileSync(sourceMapPath, 'utf-8')\n sourceMap = JSON.parse(sourceMapContent)\n }\n\n // console.log('[Claude Dev Server] Source map loaded, sources:', sourceMap.sources?.length, 'mappings:', sourceMap.mappings?.substring(0, 50) + '...')\n // console.log('[Claude Dev Server] Source map sources:', sourceMap.sources)\n\n // Use source-map library to find original position\n const consumer = await new SourceMapConsumer(sourceMap)\n const original = consumer.originalPositionFor({\n line: line,\n column: column\n })\n consumer.destroy()\n\n // console.log('[Claude Dev Server] Source map result:', {\n // generated: { line, column },\n // original: original\n // })\n\n if (original.source && original.line !== null) {\n // Convert source path to be relative to project root\n let originalFile = original.source\n if (originalFile.startsWith('webpack://')) {\n // Remove webpack:// prefix\n originalFile = originalFile.replace(/^webpack:\\/\\/[\\/\\\\]?/, '')\n }\n // For Vite and other bundlers, source might be just a filename\n if (!originalFile.startsWith('/')) {\n // Try to resolve relative to project root to verify the file exists\n const possiblePath = join(projectRoot, originalFile)\n if (existsSync(possiblePath)) {\n // Keep the original source path as-is (preserves directory structure)\n // originalFile is already correct (e.g., 'src/App.jsx')\n } else {\n // File doesn't exist at the given path\n // Check if it's just a filename (no directory separators)\n const fileName = originalFile.split('/').pop() || originalFile.split('\\\\').pop() || originalFile\n if (fileName === originalFile) {\n // Source is just a filename (common with Vite inline source maps)\n // If filePath is already a relative path like '/src/App.jsx', use it directly\n if (filePath.startsWith('/')) {\n originalFile = filePath.substring(1) // Remove leading slash\n console.log('[Claude Dev Server] Source is just a filename, using filePath:', originalFile)\n } else {\n // Fall back to relative path from fullPath\n originalFile = relative(projectRoot, fullPath)\n }\n } else {\n // Has directory but file doesn't exist, use relative\n originalFile = relative(projectRoot, possiblePath)\n }\n }\n }\n\n // console.log('[Claude Dev Server] Source map resolved:', {\n // original: { file: originalFile, line: original.line, column: original.column },\n // generated: { file: filePath, line, column }\n // })\n\n return {\n file: originalFile,\n line: original.line,\n column: original.column || 1,\n original: {\n source: original.source,\n line: original.line,\n column: original.column,\n name: original.name\n }\n }\n }\n\n // No original position found, return generated\n return { file: relative(projectRoot, fullPath), line, column }\n } catch (err) {\n console.error('[Claude Dev Server] Source map resolution error:', err)\n return { error: String(err) }\n }\n}\n\n/**\n * Handle Next.js Turbopack source file lookup.\n * Given a page path, find the corresponding source file by parsing Turbopack chunks.\n */\nasync function handleTurbopackLookup(\n projectRoot: string,\n pagePath: string,\n targetPort: number\n): Promise<{ file?: string; line?: number; error?: string }> {\n try {\n console.log('[Claude Dev Server] Turbopack lookup for page:', pagePath)\n\n // Get the HTML page to find loaded chunk URLs\n const pageRes = await fetch(`http://localhost:${targetPort}${pagePath}`)\n if (!pageRes.ok) {\n return { error: 'Failed to fetch page' }\n }\n\n const html = await pageRes.text()\n const chunkUrls: string[] = []\n\n // Extract chunk URLs from HTML\n const scriptMatches = html.matchAll(/<script[^>]*src=\"([^\"]*\\/_next\\/static\\/chunks\\/[^\"]*)\"/g)\n for (const match of scriptMatches) {\n if (match[1]) {\n chunkUrls.push(match[1])\n }\n }\n\n console.log('[Claude Dev Server] Found', chunkUrls.length, 'chunk URLs')\n\n // Parse each chunk to find module paths\n for (const chunkUrl of chunkUrls) {\n try {\n const fullUrl = chunkUrl.startsWith('http') ? chunkUrl : `http://localhost:${targetPort}${chunkUrl}`\n const chunkRes = await fetch(fullUrl)\n if (!chunkRes.ok) continue\n\n const chunkContent = await chunkRes.text()\n\n // Extract module paths from Turbopack format\n // Format: \"[project]/path/to/file.tsx\" or \"[project]/path/to/file.tsx (ecmascript)\"\n const modulePathRegex = /\\[project\\]([^\\s\"]+\\.(tsx?|jsx?))/g\n const matches = [...chunkContent.matchAll(modulePathRegex)]\n\n for (const match of matches) {\n if (match[1]) {\n const sourcePath = match[1]\n // Remove [project] prefix and convert to relative path\n let relativePath = sourcePath.replace(/^\\[project\\]/, '')\n\n // Check if this path matches the current page\n // Normalize page path: /zh/login -> /login or /app/[lng]/(auth)/login/page.tsx\n const normalizedPagePath = pagePath.replace(/^\\/[^/]+/, '') // Remove language prefix\n\n if (relativePath.toLowerCase().includes(normalizedPagePath.toLowerCase()) ||\n relativePath.toLowerCase().includes('login')) {\n // Found matching source file\n console.log('[Claude Dev Server] Found source file:', relativePath)\n\n return {\n file: relativePath,\n line: undefined // Turbopack doesn't provide line numbers\n }\n }\n }\n }\n } catch (e) {\n console.log('[Claude Dev Server] Error fetching chunk:', chunkUrl, e)\n }\n }\n\n return { error: 'Source file not found for page: ' + pagePath }\n } catch (err) {\n console.error('[Claude Dev Server] Turbopack lookup error:', err)\n return { error: String(err) }\n }\n}\n\nfunction createProxyServer(targetPort: number, wsPort: number, projectRoot: string) {\n // 读取 ttyd 资源文件\n // 从当前模块路径计算 assets 目录\n // moduleDir 是 /Users/lloyd/moox/claude-dev-server/dist\n // 所以需要 assets 是 /Users/lloyd/moox/claude-dev-server/dist/assets\n const moduleDir = dirname(fileURLToPath(import.meta.url))\n const assetsPath = join(moduleDir, 'assets')\n\n let ttydHtml: string\n let ttydBridgeJs: string\n\n try {\n ttydHtml = readFileSync(join(assetsPath, 'ttyd-terminal.html'), 'utf-8')\n ttydBridgeJs = readFileSync(join(assetsPath, 'ttyd-bridge.js'), 'utf-8')\n } catch (e: any) {\n console.error('[Claude Dev Server] Failed to read ttyd assets from', assetsPath)\n console.error('[Claude Dev Server] moduleDir:', moduleDir)\n console.error('[Claude Dev Server] Error:', e.message)\n throw new Error('ttyd assets not found. Please run `npm run build` first.')\n }\n\n const server = http.createServer((req, res) => {\n // 处理 @claude-port 端点\n if (req.url === '/@claude-port') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ port: wsPort }))\n return\n }\n\n // 处理 sourcemap 解析端点\n if (req.url?.startsWith('/@sourcemap?')) {\n const url = new URL(req.url, `http://localhost:${wsPort}`)\n const file = url.searchParams.get('file')\n const line = url.searchParams.get('line')\n const column = url.searchParams.get('col')\n\n if (file && line && column) {\n handleSourceMapRequest(projectRoot, file, parseInt(line), parseInt(column || '1'), targetPort)\n .then(result => {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n })\n .catch(err => {\n console.error('[Claude Dev Server] Source map error:', err)\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ error: err.message }))\n })\n return\n }\n }\n\n // 处理 Next.js/Turbopack 源文件查找端点\n if (req.url?.startsWith('/@sourcemap-lookup?')) {\n const url = new URL(req.url, `http://localhost:${wsPort}`)\n const page = url.searchParams.get('page')\n const framework = url.searchParams.get('framework')\n\n if (page && framework === 'nextjs') {\n handleTurbopackLookup(projectRoot, page, targetPort)\n .then(result => {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n })\n .catch(err => {\n console.error('[Claude Dev Server] Turbopack lookup error:', err)\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ error: err.message }))\n })\n return\n }\n }\n\n // 处理 /ttyd/* 路由\n if (req.url?.startsWith('/ttyd/')) {\n const urlPath = req.url.split('?')[0] // 移除查询参数\n\n if (urlPath === '/ttyd/index.html' || urlPath === '/ttyd/') {\n res.setHeader('Content-Type', 'text/html')\n res.end(ttydHtml)\n return\n }\n\n if (urlPath === '/ttyd/ttyd-bridge.js') {\n res.setHeader('Content-Type', 'application/javascript')\n res.end(ttydBridgeJs)\n return\n }\n\n // Handle ttyd token endpoint\n if (urlPath === '/ttyd/token' || urlPath === '/ttyd/index.html/token') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({ token: '' }))\n return\n }\n\n // 其他 /ttyd/* 路由返回 404\n res.statusCode = 404\n res.end('Not found')\n return\n }\n\n // 代理到目标服务器并注入脚本\n // Remove accept-encoding to get uncompressed content (needed for script injection)\n const proxyHeaders = { ...req.headers }\n delete proxyHeaders['accept-encoding']\n\n const options = {\n hostname: 'localhost',\n port: targetPort,\n path: req.url,\n method: req.method,\n headers: proxyHeaders,\n }\n\n const proxyReq = http.request(options, (proxyRes) => {\n // 注入脚本到 HTML\n if (proxyRes.headers['content-type']?.includes('text/html')) {\n const body: Buffer[] = []\n proxyRes.on('data', (chunk) => body.push(chunk))\n proxyRes.on('end', () => {\n const html = Buffer.concat(body).toString('utf8')\n const injected = injectScripts(html, wsPort, projectRoot)\n const statusCode = proxyRes.statusCode || 200\n res.writeHead(statusCode, {\n ...proxyRes.headers,\n 'content-length': Buffer.byteLength(injected),\n })\n res.end(injected)\n })\n } else {\n const statusCode = proxyRes.statusCode || 200\n res.writeHead(statusCode, proxyRes.headers)\n proxyRes.pipe(res)\n }\n })\n\n proxyReq.on('error', (err) => {\n console.error('[Claude Dev Server] Proxy error:', err)\n res.statusCode = 502\n res.end('Bad Gateway')\n })\n\n req.pipe(proxyReq)\n })\n\n // Handle WebSocket upgrade requests (e.g., Next.js webpack-hmr, Vite HMR)\n server.on('upgrade', (req: any, socket: any, head: Buffer) => {\n // Check if this is a WebSocket upgrade request\n if (req.headers['upgrade']?.toLowerCase() !== 'websocket') {\n return\n }\n\n console.log('[Claude Dev Server] WebSocket upgrade request:', req.url)\n\n // Create raw TCP connection to target server\n const targetSocket = createConnection(targetPort, 'localhost', () => {\n console.log('[Claude Dev Server] Connected to target WebSocket server')\n\n // Forward the upgrade request to target\n const upgradeRequest = [\n `${req.method} ${req.url} HTTP/1.1`,\n `Host: localhost:${targetPort}`,\n 'Upgrade: websocket',\n 'Connection: Upgrade',\n `Sec-WebSocket-Key: ${req.headers['sec-websocket-key']}`,\n `Sec-WebSocket-Version: ${req.headers['sec-websocket-version'] || '13'}`,\n ]\n\n if (req.headers['sec-websocket-protocol']) {\n upgradeRequest.push(`Sec-WebSocket-Protocol: ${req.headers['sec-websocket-protocol']}`)\n }\n if (req.headers['sec-websocket-extensions']) {\n upgradeRequest.push(`Sec-WebSocket-Extensions: ${req.headers['sec-websocket-extensions']}`)\n }\n\n targetSocket.write(upgradeRequest.join('\\r\\n') + '\\r\\n\\r\\n')\n\n // Forward the head (remaining data from the upgrade request)\n if (head && head.length > 0) {\n targetSocket.write(head)\n }\n })\n\n // Handle response from target server\n targetSocket.on('data', (data: Buffer) => {\n if (socket.writable) {\n socket.write(data)\n }\n })\n\n // Handle data from client\n socket.on('data', (data: Buffer) => {\n if (targetSocket.writable) {\n targetSocket.write(data)\n }\n })\n\n // Handle connection close\n socket.on('close', () => {\n console.log('[Claude Dev Server] Client WebSocket closed')\n targetSocket.destroy()\n })\n\n targetSocket.on('close', () => {\n console.log('[Claude Dev Server] Target WebSocket closed')\n socket.end()\n })\n\n // Handle errors\n socket.on('error', (err: Error) => {\n console.error('[Claude Dev Server] Client socket error:', err.message)\n targetSocket.destroy()\n })\n\n targetSocket.on('error', (err: Error) => {\n console.error('[Claude Dev Server] Target socket error:', err.message)\n socket.end()\n })\n })\n\n return server\n}\n\nfunction injectScripts(html: string, wsPort: number, projectRoot: string): string {\n const projectRootScript = `<script>window.__CLAUDE_PROJECT_ROOT__ = ${JSON.stringify(projectRoot)}</script>`\n\n return html.replace(\n '</head>',\n `<!-- Claude Dev Server -->\\n${CLIENT_STYLES}\\n${projectRootScript}\\n<script type=\"module\">${CLIENT_SCRIPT}</script>\\n</head>`\n ).replace(\n /wsPort:\\s*\\d+/,\n `wsPort: ${wsPort}`\n )\n}\n\n/**\n * Generate Sec-WebSocket-Accept header value for WebSocket handshake.\n * RFC 6455: base64(sha1(clientKey + GUID))\n */\nfunction generateWebSocketAccept(clientKey: string): string {\n const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'\n const hash = createHash('sha1')\n .update(clientKey + GUID)\n .digest('base64')\n return hash\n}\n"]}