always use urls

This commit is contained in:
Tommy D. Rossi
2025-12-25 21:37:38 +01:00
parent 91c30bbd3e
commit eb58952578
2 changed files with 11 additions and 8 deletions
+7 -7
View File
@@ -42,7 +42,7 @@ export interface ScriptInfo {
* const cdp = await getCDPSessionForPage({ page, wsUrl }) * const cdp = await getCDPSessionForPage({ page, wsUrl })
* const dbg = new Debugger({ cdp }) * const dbg = new Debugger({ cdp })
* *
* await dbg.setBreakpoint({ file: '/path/to/file.js', line: 42 }) * await dbg.setBreakpoint({ file: 'https://example.com/app.js', line: 42 })
* // trigger the code path, then: * // trigger the code path, then:
* const location = await dbg.getLocation() * const location = await dbg.getLocation()
* const vars = await dbg.inspectVariables() * const vars = await dbg.inspectVariables()
@@ -115,17 +115,17 @@ export class Debugger {
} }
/** /**
* Sets a breakpoint at a specified file and line number. * Sets a breakpoint at a specified URL and line number.
* The file path is automatically converted to a file:// URL if needed. * Use the URL from listScripts() to find available scripts.
* *
* @param options - Breakpoint options * @param options - Breakpoint options
* @param options.file - Absolute file path or URL * @param options.file - Script URL (e.g. https://example.com/app.js)
* @param options.line - Line number (1-based) * @param options.line - Line number (1-based)
* @returns The breakpoint ID for later removal * @returns The breakpoint ID for later removal
* *
* @example * @example
* ```ts * ```ts
* const id = await dbg.setBreakpoint({ file: '/app/src/index.js', line: 42 }) * const id = await dbg.setBreakpoint({ file: 'https://example.com/app.js', line: 42 })
* // later: * // later:
* await dbg.deleteBreakpoint({ breakpointId: id }) * await dbg.deleteBreakpoint({ breakpointId: id })
* ``` * ```
@@ -173,7 +173,7 @@ export class Debugger {
* @example * @example
* ```ts * ```ts
* const breakpoints = dbg.listBreakpoints() * const breakpoints = dbg.listBreakpoints()
* // [{ id: 'bp-123', file: '/app/index.js', line: 42 }] * // [{ id: 'bp-123', file: 'https://example.com/index.js', line: 42 }]
* ``` * ```
*/ */
listBreakpoints(): BreakpointInfo[] { listBreakpoints(): BreakpointInfo[] {
@@ -322,7 +322,7 @@ export class Debugger {
* @example * @example
* ```ts * ```ts
* const location = await dbg.getLocation() * const location = await dbg.getLocation()
* console.log(location.url) // '/app/src/index.js' * console.log(location.url) // 'https://example.com/src/index.js'
* console.log(location.lineNumber) // 42 * console.log(location.lineNumber) // 42
* console.log(location.callstack) // [{ functionName: 'handleRequest', ... }] * console.log(location.callstack) // [{ functionName: 'handleRequest', ... }]
* console.log(location.sourceContext) * console.log(location.sourceContext)
+4 -1
View File
@@ -395,7 +395,10 @@ server.resource('debugger-api', 'playwriter://debugger-api', { mimeType: 'text/p
const packageJsonPath = require.resolve('playwriter/package.json') const packageJsonPath = require.resolve('playwriter/package.json')
const distDir = path.join(path.dirname(packageJsonPath), 'dist') const distDir = path.join(path.dirname(packageJsonPath), 'dist')
const debuggerTypes = fs.readFileSync(path.join(distDir, 'debugger.d.ts'), 'utf-8') const debuggerTypes = fs
.readFileSync(path.join(distDir, 'debugger.d.ts'), 'utf-8')
.replace(/\/\/# sourceMappingURL=.*$/gm, '')
.trim()
const debuggerExamples = fs.readFileSync(path.join(distDir, 'debugger-examples.ts'), 'utf-8') const debuggerExamples = fs.readFileSync(path.join(distDir, 'debugger-examples.ts'), 'utf-8')
return { return {