import type { CodeWithSourceMap } from 'source-map'; import type { DebugProtocol } from '@vscode/debugprotocol'; import type { Project } from './ProjectManager'; import type { SourceMapManager } from './SourceMapManager'; import type { LocationManager } from './LocationManager'; export declare class BreakpointManager { private sourceMapManager; private locationManager; /** * @deprecated temporary flag. AST-based breakpoint validation is disabled in production because Roku * silently relocates a breakpoint on a non-runnable line to the next runnable line, so rejecting it * would take away behavior the user has. Enabled in tests. Remove once we can relocate breakpoints * ourselves instead of dropping them. */ private enableAstBreakpointValidation; constructor(sourceMapManager: SourceMapManager, locationManager: LocationManager, /** * @deprecated temporary flag. AST-based breakpoint validation is disabled in production because Roku * silently relocates a breakpoint on a non-runnable line to the next runnable line, so rejecting it * would take away behavior the user has. Enabled in tests. Remove once we can relocate breakpoints * ourselves instead of dropping them. */ enableAstBreakpointValidation?: boolean); private logger; launchConfiguration: { sourceDirs: string[]; rootDir: string; enableSourceMaps?: boolean; /** * When true the session uses the DebugProtocol (on-device) debugger, which sets breakpoints by * line number. When false/undefined it's a telnet session, where breakpoints are only possible by * writing literal `STOP` statements into the staged files. */ enableDebugProtocol?: boolean; }; private emitter; private emit; /** * Subscribe to an event */ on(eventName: 'breakpoints-verified', handler: (data: { breakpoints: AugmentedSourceBreakpoint[]; }) => any): any; /** * Get a promise that resolves the next time the specified event occurs */ once(eventName: 'breakpoints-verified'): Promise<{ breakpoints: AugmentedSourceBreakpoint[]; }>; /** * A map of breakpoints by what file they were set in. * This does not handle any source-to-dest mapping...these breakpoints are stored in the file they were set in. * These breakpoints are all set before launch, and then this list is not changed again after that. * (this concept may need to be modified once we get live breakpoint support) */ private breakpointsByFilePath; /** * A list of breakpoints that failed to delete and will be deleted as soon as possible */ failedDeletions: BreakpointWorkItem[]; /** * A sequence used to generate unique client breakpoint IDs */ private breakpointIdSequence; /** * breakpoint lines are 1-based, and columns are zero-based */ setBreakpoint(srcPath: string, breakpoint: AugmentedSourceBreakpoint | DebugProtocol.SourceBreakpoint): AugmentedSourceBreakpoint; /** * Delete a breakpoint */ deleteBreakpoint(hash: string): any; deleteBreakpoint(breakpoint: AugmentedSourceBreakpoint): any; deleteBreakpoint(srcPath: string, breakpoint: Breakpoint): any; /** * Delete a set of breakpoints */ deleteBreakpoints(args: BreakpointRef[]): void; /** * Get a breakpoint by providing the data you have available */ getBreakpoint(hash: BreakpointRef): AugmentedSourceBreakpoint; getBreakpoint(srcPath: string, breakpoint: Breakpoint): AugmentedSourceBreakpoint; /** * Given a breakpoint ref, turn it into a hash */ private refToHash; /** * Get breakpoints by providing a list of breakpoint refs * @param refs a list of breakpoint refs for breakpoints to get * @param includeHistoric if true, will also look through historic breakpoints for a match. */ getBreakpoints(refs: BreakpointRef[]): AugmentedSourceBreakpoint[]; private deviceIdByDestHash; /** * Find a breakpoint by its deviceId * @returns the breakpoint, or undefined if not found */ private getBreakpointByDeviceId; /** * Set the deviceId of a breakpoint */ setBreakpointDeviceId(srcHash: string, destHast: string, deviceId: number): void; /** * Mark this breakpoint as verified */ verifyBreakpoint(deviceId: number, isVerified?: boolean): boolean; private queueEventStates; /** * Queue future events to be fired when data settles. Typically this is data that needs synced back to vscode. * This queues up a future function that will emit a batch of all the specified breakpoints. * @param hash the breakpoint hash that identifies this specific breakpoint based on its features */ private queueEvent; /** * Generate a hash based on the features of the breakpoint. Every breakpoint that exists at the same location * and has the same features should have the same hash. */ private getBreakpointSrcHash; /** * Generate a hash based on the features of the breakpoint. Every breakpoint that exists at the same location * and has the same features should have the same hash. */ private getBreakpointDestHash; /** * Set/replace/delete the list of breakpoints for this file. * @param srcPath * @param allBreakpointsForFile */ replaceBreakpoints(srcPath: string, allBreakpointsForFile: DebugProtocol.SourceBreakpoint[]): AugmentedSourceBreakpoint[]; /** * Get a list of all breakpoint tasks that should be performed. * This will also exclude files with breakpoints that are not in scope. * @param willInjectStop true for telnet (a literal `STOP` is baked in at each breakpoint). Only used by * the AST line check (see {@link isValidBreakpointLine}), which is gated behind enableAstBreakpointValidation * and off by default; when on, it lets telnet exclude lines where injecting a `STOP` would be invalid. */ private getBreakpointWork; sortAndRemoveDuplicateBreakpoints(breakpoints: Array): T[]; /** * Reconcile every breakpoint against the project's staged files, marking any that can't be placed * (unsupported file type, or a file not in the project) as failed. Returns the placeable breakpoints * keyed by staging file path. * * For telnet there is no on-device breakpoint API, so this also bakes a literal `STOP` into the staged * files for each breakpoint and registers them as permanent/verified. DebugProtocol writes nothing * (the device breaks by line number). The choice is made here from `launchConfiguration.enableDebugProtocol`. */ validateAndWriteBreakpointsForProject(project: Project): Promise>; /** * Write STOP statements into the project's staging files for each breakpoint location and update the * sourcemaps to match. Marks the written breakpoints as verified and registers them as permanent. * Telnet only — `validateAndWriteBreakpointsForProject` calls this when no on-device breakpoint API * is available. */ private writeBreakpointsForProject; private registerPermanentBreakpoint; /** * The list of breakpoints that were permanently written to a file at the start of a debug session. Used for line offset calculations. */ private permanentBreakpointsBySrcPath; /** * Cache of parsed ASTs keyed by staging file path. * Populated lazily in isValidBreakpointLine. Clear on new debug session. */ private stagingFileAstCache; /** * Clear the staging file AST cache. Should be called at the start of each debug session * so stale parsed ASTs don't carry over after files are re-staged. */ clearStagingFileAstCache(): void; /** * Reset all per-session state so a relaunch/restart starts clean. A restart re-stages the project, * so cached parsed ASTs from the previous run are stale, and the diff baseline must be cleared so the * next client sees every breakpoint as a fresh add. (The `