/// import { Debugger, InspectorNotification } from 'inspector'; import { Debug } from './apis/Debug'; import Configuration from './models/Configuration'; import Container from './utils/Container'; import { MapInfoOutput } from "./utils/mappings/sourcemapper"; import { ClientConfig } from "./models/ClientConfig"; import { IEventSnapshot } from "./models/Snapshot"; import Events from "./apis/Events"; import Breakpoint from "./models/Breakpoint"; import SourceMapperService from "./apis/SourceMapperService"; export interface IBreakpointService { installedTracepoints(): BreakpointListItem[]; } export interface BreakpointListItem { breakpoint: Breakpoint; breakpointId?: Debugger.BreakpointId; params: Debugger.SetBreakpointByUrlParameterType; locationHash: string; mappingData: MapInfoOutput; firedCount: number; lastFiredTime: number; suppressedCount: number; } export default class BreakpointService implements IBreakpointService { private _debug; private _events; private _config; private _container; private _clientConfig; private _sourceMapper; /** * A record of the currently installed tracepoints * @protected */ protected _installedTracepoints: { [key: string]: BreakpointListItem; }; protected _callbacks: { event: IEventSnapshot; callbacks: number; sent: boolean; }[]; constructor(_debug: Debug, _events: Events, _config: Configuration, _container: Container, _clientConfig: ClientConfig, _sourceMapper: SourceMapperService); /** * Get the current state of tracepoints */ installedTracepoints(): BreakpointListItem[]; /** * Update the set breakpoints with the new list of breakpoints * * Note: due to grpc concurrency this function cannot invoke async/promises * * @param newBreakpoints The list of breakpoints that should be set */ processRequest(newBreakpoints: Breakpoint[]): void; /** * Find the requested breakpoints and filter the ones that cant fire yet * * @param breakpointIds The ids of the breakpoints you want to find * @param timestamp The current timestamp */ protected findNVTracepoints(breakpointIds: Debugger.BreakpointId[], timestamp: number): BreakpointListItem[]; /** * Add the given breakpoint * * @param breakpointIds The breakpoint ids linked to this location hash * @param locationHash the location to install the tracepoint into * @param params for the tracepoint */ addBreakpoint(breakpointIds: BreakpointListItem[], locationHash: string, params: Debugger.SetBreakpointByUrlParameterType): void; /** * Convert NV breakpoint to params for v8 * * @param breakpoint the breakpoint to convert * @private */ private registerV8Tracepoint; /** * Remove a breakpoint * * @param toRemove The breakpoint to remove */ protected removeBreakpoint(toRemove: BreakpointListItem): void; pushCallback(snapshot: IEventSnapshot): void; protected isRateLimitHit(bp: BreakpointListItem, timestamp: number): boolean; /** * Check if a breakpoint can fire * * @param breakpoint The breakpoint to check * @param timestamp The current time (ms) */ protected canFire(breakpoint: BreakpointListItem, timestamp: number): boolean; /** * Map a NV Tracepoint to a actual file location, if no mapping is found and we are not a '.js' file then we use the * tracepoint config. If we find a mapping we use that, we will also try to scan the directory of the incoming tracepoint * if we are not a '.js' file and did not find a mapping the first go. We only scan the directory once. * * @param root_path the root path from the NV config * @param root the root from the NV config * @param breakpoint the incoming tracepoint * @private * * @return the mapping for the location to install the tracepoint */ private mapBreakpoint; /** * This function will scan the for source mappings in the folder where the incoming tracepoint file is located. * * **NOTE:** This function has to use the 'sync' versions of the scanning as we are calling it from inside the GRPC callback. * * @param root_path the root_path from NV config * @param rel_path the rel_path from the tracepoint * @param line_no the line number from the NV tracepoint * @param colNumber the column number from the NV tracepoint * * @return the source map info or null */ protected scanSourceMappings(root_path: string, rel_path: string, line_no: number, colNumber: number): MapInfoOutput | null; hasCallbacks(): boolean; /** * Handle a breakpoint being fired * * @param message The information about the current state of the application */ protected breakpointFired(message: InspectorNotification): Promise; protected processCallbacks(message: InspectorNotification): Promise[]; private findError; private checkCondition; private conditionMatches; }