UNPKG

@scrapeless-ai/sdk

Version:
1,566 lines (1,524 loc) 2.7 MB
/// <reference types="node" /> import { ReadStream } from "fs"; import { ChildProcess } from "node:child_process"; import { PassThrough } from "node:stream"; import * as stream from "stream"; import { Readable } from "stream"; import { LEVEL, MESSAGE, SPLAT } from "triple-beam"; import { ChildProcess as ChildProcess$1 } from "child_process"; //#region src/types/base.d.ts type RequestResponse<T, R extends boolean> = R extends true ? { status: number; data: T; } : T; /** * Response structure for API requests with status */ interface ResponseWithStatus<T> { status: number; data: T; } //#endregion //#region src/types/config.d.ts interface ScrapelessConfig { baseApiUrl?: string; actorApiUrl?: string; storageApiUrl?: string; browserApiUrl?: string; scrapingCrawlApiUrl?: string; apiKey?: string; timeout?: number; } //#endregion //#region node_modules/.pnpm/typed-query-selector@2.12.0/node_modules/typed-query-selector/parser.d.ts type Whitespace = ' ' | '\n' | '\r' | '\f' | '\t'; type Trim<S extends string> = S extends `${infer T}${Whitespace}` ? Trim<T> : S extends `${Whitespace}${infer T}` ? Trim<T> : S; type Combinators = ' ' | '>' | '~' | '+'; type GetLastTag<I> = I extends `${string}${Combinators}${infer Right}` ? Right extends '' // right arm can't be empty ? unknown : GetLastTag<Right> : I; type PseudoPrefix = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'h' | 'i' | 'l' | 'n' | 'o' | 'p' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | ':-'; type Split<S> = S extends `${string},` // invalid selector ? unknown : S extends '' ? '' : SplitRec<S>; type SplitRec<S, Acc = never> = S extends `${infer Left},${infer Right}` ? SplitRec<Right, Acc | Left> : S extends '' ? Acc : SplitRec<'', Acc | S>; type Quotes = '"' | "'"; // DO NOT use union type like `${infer L},${Whitespace}${infer R}` here, // or it may cause OOM when running tsc in downstream projects. type PreprocessGrouping<I> = I extends `${infer L}, ${infer R}` ? PreprocessGrouping<`${L},${R}`> : I extends `${infer L},\n${infer R}` ? PreprocessGrouping<`${L},${R}`> : I extends `${infer L},\r${infer R}` ? PreprocessGrouping<`${L},${R}`> : I extends `${infer L},\f${infer R}` ? PreprocessGrouping<`${L},${R}`> : I extends `${infer L},\t${infer R}` ? PreprocessGrouping<`${L},${R}`> : I; type Preprocess<I> = I extends `${string}[]${string}` // invalid selector ? unknown : PreprocessUnchecked<I>; type PreprocessUnchecked<I> = I extends `${infer L}\\${Quotes}${infer R}` // remove escaped quotes ? PreprocessUnchecked<`${L}${R}`> : I extends `${infer L}"${string}"${infer R}` // remove quoted content in attribute ? PreprocessUnchecked<`${L}${R}`> : I extends `${infer L}'${string}'${infer R}` // remove quoted content in attribute ? PreprocessUnchecked<`${L}${R}`> : I extends `${infer L}[${string}]${infer R}` // process attribute ? PreprocessUnchecked<`${L}#x${R}`> // replace it with a fake ID selector : I extends `${infer L}[${string}${infer R}` // process unclosed attribute ? PreprocessUnchecked<`${L}#x${R}`> // replace it with a fake ID selector : I; /** Parse `:is()` and `:where()` */ type ExpandFunctions<I> = I extends `${infer L}:is(${infer Args})${infer R}` ? Split<Trim<Args>> extends string ? ExpandFunctions<`${L}&${Split<Trim<Args>>}${R}`> : unknown : I extends `${infer L}:where(${infer Args})${infer R}` ? Split<Trim<Args>> extends string ? ExpandFunctions<`${L}&${Split<Trim<Args>>}${R}`> : unknown : I extends `${infer L}:${infer Pseudo}(${string})${infer R}` ? IsIdentifier<Pseudo> extends true ? ExpandFunctions<`${L}${R}`> : I : I; /** Check whether each tag is valid or not. */ type Postprocess<Tags> = PostprocessEach<GetLastTag<Tags>> extends string ? PostprocessEach<GetLastTag<Tags>> : unknown; /** Postprocess each tag with simple validation. */ type PostprocessEach<I> = I extends `${string}.` // invalid class selector ? unknown : I extends `${string}#` // invalid ID selector ? unknown : PostprocessEachUnchecked<I>; type PostprocessEachUnchecked<I> = I extends `${infer Tag}.${string}&${infer Rest}` ? PostprocessEachUnchecked<`${Tag}&${Rest}`> : I extends `${infer Tag}.${string}` ? PostprocessEachUnchecked<Tag> : I extends `${infer Tag}#${string}&${infer Rest}` ? PostprocessEachUnchecked<`${Tag}&${Rest}`> : I extends `${infer Tag}#${string}` ? PostprocessEachUnchecked<Tag> : I extends `${infer Tag}:${PseudoPrefix}${string}&${infer Rest}` ? PostprocessEachUnchecked<`${Tag}&${Rest}`> : I extends `${infer Tag}:${PseudoPrefix}${string}` ? PostprocessEachUnchecked<Tag> : I extends `${string}|${infer Tag}` // namespace prefix ? PostprocessEachUnchecked<Tag> : I; type ParseSelectorToTagNames<I extends string> = Trim<I> extends '' ? unknown : Postprocess<Split<ExpandFunctions<Preprocess<PreprocessGrouping<Trim<I>>>>>>; type ParseSelector<I extends string, Fallback extends Element = Element> = ParseSelectorToTagNames<I> extends string ? ExpandAnd<ParseSelectorToTagNames<I>, Fallback> extends Fallback ? ExpandAnd<ParseSelectorToTagNames<I>, Fallback> : Fallback : Fallback; /** * Wrapper for `...&...` syntax expander. * * `&` is valid, but the expander will return the default result which is `unknown`, * so we must check the result and if it's `unknown` we will turn it into `Fallback`. */ type ExpandAnd<I extends string, Fallback extends Element> = unknown extends ExpandAndInner<I, Fallback> ? Fallback : ExpandAndInner<I, Fallback>; /** * Actually expand the `...&...` syntax. * * The reason why we choose `unknown` as initial type is * that `unknown & T` equals to `T`. */ type ExpandAndInner<I extends string, Fallback extends Element, Result extends Element | unknown = unknown> = I extends `${'' | '*'}&${infer Rest}` ? ExpandAndInner<Rest, Fallback, Result> : I extends `${infer Tag}&${infer Rest}` ? ExpandAndInner<Rest, Fallback, Result & TagNameToElement<Tag, Fallback>> : I extends '' | '*' ? Result : ExpandAndInner<'', Fallback, Result & TagNameToElement<I, Fallback>>; type TagNameToElement<Tag extends string, Fallback extends Element = Element> = Tag extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[Tag] : Tag extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[Tag] : Fallback; // -------------------------------------------------------- // Strict Parser // -------------------------------------------------------- // Specification is here: https://drafts.csswg.org/css-syntax-3/#ident-token-diagram // but we don't plan to comply that fully, // otherwise it will increase type-checking time and the complexity of parser. type LowerCaseLetter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'; type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; type IdentifierFirstChar = LowerCaseLetter | Uppercase<LowerCaseLetter> | '-' | '_'; type IdentifierChar = IdentifierFirstChar | Digit; type IsIdentifier<S> = S extends `${infer FirstChar}${infer Rest}` ? FirstChar extends IdentifierFirstChar ? IsValidRestChars<Rest> : false : false; type IsValidRestChars<S extends string> = S extends `${infer H}${infer Rest}` ? H extends IdentifierChar ? IsValidRestChars<Rest> : false : true; // no characters left, so it's OK //#endregion //#region node_modules/.pnpm/devtools-protocol@0.0.1452169/node_modules/devtools-protocol/types/protocol.d.ts /********************************************************************** * Auto-generated by protocol-dts-generator.ts, do not edit manually. * **********************************************************************/ /** * The Chrome DevTools Protocol. * @public */ declare namespace Protocol$1 { export type integer = number; /** * This domain is deprecated - use Runtime or Log instead. */ export namespace Console { export const enum ConsoleMessageSource { XML = 'xml', Javascript = 'javascript', Network = 'network', ConsoleAPI = 'console-api', Storage = 'storage', Appcache = 'appcache', Rendering = 'rendering', Security = 'security', Other = 'other', Deprecation = 'deprecation', Worker = 'worker', } export const enum ConsoleMessageLevel { Log = 'log', Warning = 'warning', Error = 'error', Debug = 'debug', Info = 'info', } /** * Console message. */ export interface ConsoleMessage { /** * Message source. (ConsoleMessageSource enum) */ source: ('xml' | 'javascript' | 'network' | 'console-api' | 'storage' | 'appcache' | 'rendering' | 'security' | 'other' | 'deprecation' | 'worker'); /** * Message severity. (ConsoleMessageLevel enum) */ level: ('log' | 'warning' | 'error' | 'debug' | 'info'); /** * Message text. */ text: string; /** * URL of the message origin. */ url?: string; /** * Line number in the resource that generated this message (1-based). */ line?: integer; /** * Column number in the resource that generated this message (1-based). */ column?: integer; } /** * Issued when new console message is added. */ export interface MessageAddedEvent { /** * Console message that has been added. */ message: ConsoleMessage; } } /** * Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing * breakpoints, stepping through execution, exploring stack traces, etc. */ export namespace Debugger { /** * Breakpoint identifier. */ export type BreakpointId = string; /** * Call frame identifier. */ export type CallFrameId = string; /** * Location in the source code. */ export interface Location { /** * Script identifier as reported in the `Debugger.scriptParsed`. */ scriptId: Runtime.ScriptId; /** * Line number in the script (0-based). */ lineNumber: integer; /** * Column number in the script (0-based). */ columnNumber?: integer; } /** * Location in the source code. */ export interface ScriptPosition { lineNumber: integer; columnNumber: integer; } /** * Location range within one script. */ export interface LocationRange { scriptId: Runtime.ScriptId; start: ScriptPosition; end: ScriptPosition; } /** * JavaScript call frame. Array of call frames form the call stack. */ export interface CallFrame { /** * Call frame identifier. This identifier is only valid while the virtual machine is paused. */ callFrameId: CallFrameId; /** * Name of the JavaScript function called on this call frame. */ functionName: string; /** * Location in the source code. */ functionLocation?: Location; /** * Location in the source code. */ location: Location; /** * JavaScript script name or url. * Deprecated in favor of using the `location.scriptId` to resolve the URL via a previously * sent `Debugger.scriptParsed` event. */ url: string; /** * Scope chain for this call frame. */ scopeChain: Scope[]; /** * `this` object for this call frame. */ this: Runtime.RemoteObject; /** * The value being returned, if the function is at return point. */ returnValue?: Runtime.RemoteObject; /** * Valid only while the VM is paused and indicates whether this frame * can be restarted or not. Note that a `true` value here does not * guarantee that Debugger#restartFrame with this CallFrameId will be * successful, but it is very likely. */ canBeRestarted?: boolean; } export const enum ScopeType { Global = 'global', Local = 'local', With = 'with', Closure = 'closure', Catch = 'catch', Block = 'block', Script = 'script', Eval = 'eval', Module = 'module', WasmExpressionStack = 'wasm-expression-stack', } /** * Scope description. */ export interface Scope { /** * Scope type. (ScopeType enum) */ type: ('global' | 'local' | 'with' | 'closure' | 'catch' | 'block' | 'script' | 'eval' | 'module' | 'wasm-expression-stack'); /** * Object representing the scope. For `global` and `with` scopes it represents the actual * object; for the rest of the scopes, it is artificial transient object enumerating scope * variables as its properties. */ object: Runtime.RemoteObject; name?: string; /** * Location in the source code where scope starts */ startLocation?: Location; /** * Location in the source code where scope ends */ endLocation?: Location; } /** * Search match for resource. */ export interface SearchMatch { /** * Line number in resource content. */ lineNumber: number; /** * Line with match content. */ lineContent: string; } export const enum BreakLocationType { DebuggerStatement = 'debuggerStatement', Call = 'call', Return = 'return', } export interface BreakLocation { /** * Script identifier as reported in the `Debugger.scriptParsed`. */ scriptId: Runtime.ScriptId; /** * Line number in the script (0-based). */ lineNumber: integer; /** * Column number in the script (0-based). */ columnNumber?: integer; /** * (BreakLocationType enum) */ type?: ('debuggerStatement' | 'call' | 'return'); } export interface WasmDisassemblyChunk { /** * The next chunk of disassembled lines. */ lines: string[]; /** * The bytecode offsets describing the start of each line. */ bytecodeOffsets: integer[]; } /** * Enum of possible script languages. */ export type ScriptLanguage = ('JavaScript' | 'WebAssembly'); export const enum DebugSymbolsType { SourceMap = 'SourceMap', EmbeddedDWARF = 'EmbeddedDWARF', ExternalDWARF = 'ExternalDWARF', } /** * Debug symbols available for a wasm script. */ export interface DebugSymbols { /** * Type of the debug symbols. (DebugSymbolsType enum) */ type: ('SourceMap' | 'EmbeddedDWARF' | 'ExternalDWARF'); /** * URL of the external symbol source. */ externalURL?: string; } export interface ResolvedBreakpoint { /** * Breakpoint unique identifier. */ breakpointId: BreakpointId; /** * Actual breakpoint location. */ location: Location; } export const enum ContinueToLocationRequestTargetCallFrames { Any = 'any', Current = 'current', } export interface ContinueToLocationRequest { /** * Location to continue to. */ location: Location; /** * (ContinueToLocationRequestTargetCallFrames enum) */ targetCallFrames?: ('any' | 'current'); } export interface EnableRequest { /** * The maximum size in bytes of collected scripts (not referenced by other heap objects) * the debugger can hold. Puts no limit if parameter is omitted. */ maxScriptsCacheSize?: number; } export interface EnableResponse { /** * Unique identifier of the debugger. */ debuggerId: Runtime.UniqueDebuggerId; } export interface EvaluateOnCallFrameRequest { /** * Call frame identifier to evaluate on. */ callFrameId: CallFrameId; /** * Expression to evaluate. */ expression: string; /** * String object group name to put result into (allows rapid releasing resulting object handles * using `releaseObjectGroup`). */ objectGroup?: string; /** * Specifies whether command line API should be available to the evaluated expression, defaults * to false. */ includeCommandLineAPI?: boolean; /** * In silent mode exceptions thrown during evaluation are not reported and do not pause * execution. Overrides `setPauseOnException` state. */ silent?: boolean; /** * Whether the result is expected to be a JSON object that should be sent by value. */ returnByValue?: boolean; /** * Whether preview should be generated for the result. */ generatePreview?: boolean; /** * Whether to throw an exception if side effect cannot be ruled out during evaluation. */ throwOnSideEffect?: boolean; /** * Terminate execution after timing out (number of milliseconds). */ timeout?: Runtime.TimeDelta; } export interface EvaluateOnCallFrameResponse { /** * Object wrapper for the evaluation result. */ result: Runtime.RemoteObject; /** * Exception details. */ exceptionDetails?: Runtime.ExceptionDetails; } export interface GetPossibleBreakpointsRequest { /** * Start of range to search possible breakpoint locations in. */ start: Location; /** * End of range to search possible breakpoint locations in (excluding). When not specified, end * of scripts is used as end of range. */ end?: Location; /** * Only consider locations which are in the same (non-nested) function as start. */ restrictToFunction?: boolean; } export interface GetPossibleBreakpointsResponse { /** * List of the possible breakpoint locations. */ locations: BreakLocation[]; } export interface GetScriptSourceRequest { /** * Id of the script to get source for. */ scriptId: Runtime.ScriptId; } export interface GetScriptSourceResponse { /** * Script source (empty in case of Wasm bytecode). */ scriptSource: string; /** * Wasm bytecode. (Encoded as a base64 string when passed over JSON) */ bytecode?: string; } export interface DisassembleWasmModuleRequest { /** * Id of the script to disassemble */ scriptId: Runtime.ScriptId; } export interface DisassembleWasmModuleResponse { /** * For large modules, return a stream from which additional chunks of * disassembly can be read successively. */ streamId?: string; /** * The total number of lines in the disassembly text. */ totalNumberOfLines: integer; /** * The offsets of all function bodies, in the format [start1, end1, * start2, end2, ...] where all ends are exclusive. */ functionBodyOffsets: integer[]; /** * The first chunk of disassembly. */ chunk: WasmDisassemblyChunk; } export interface NextWasmDisassemblyChunkRequest { streamId: string; } export interface NextWasmDisassemblyChunkResponse { /** * The next chunk of disassembly. */ chunk: WasmDisassemblyChunk; } export interface GetWasmBytecodeRequest { /** * Id of the Wasm script to get source for. */ scriptId: Runtime.ScriptId; } export interface GetWasmBytecodeResponse { /** * Script source. (Encoded as a base64 string when passed over JSON) */ bytecode: string; } export interface GetStackTraceRequest { stackTraceId: Runtime.StackTraceId; } export interface GetStackTraceResponse { stackTrace: Runtime.StackTrace; } export interface PauseOnAsyncCallRequest { /** * Debugger will pause when async call with given stack trace is started. */ parentStackTraceId: Runtime.StackTraceId; } export interface RemoveBreakpointRequest { breakpointId: BreakpointId; } export const enum RestartFrameRequestMode { StepInto = 'StepInto', } export interface RestartFrameRequest { /** * Call frame identifier to evaluate on. */ callFrameId: CallFrameId; /** * The `mode` parameter must be present and set to 'StepInto', otherwise * `restartFrame` will error out. (RestartFrameRequestMode enum) */ mode?: ('StepInto'); } export interface RestartFrameResponse { /** * New stack trace. */ callFrames: CallFrame[]; /** * Async stack trace, if any. */ asyncStackTrace?: Runtime.StackTrace; /** * Async stack trace, if any. */ asyncStackTraceId?: Runtime.StackTraceId; } export interface ResumeRequest { /** * Set to true to terminate execution upon resuming execution. In contrast * to Runtime.terminateExecution, this will allows to execute further * JavaScript (i.e. via evaluation) until execution of the paused code * is actually resumed, at which point termination is triggered. * If execution is currently not paused, this parameter has no effect. */ terminateOnResume?: boolean; } export interface SearchInContentRequest { /** * Id of the script to search in. */ scriptId: Runtime.ScriptId; /** * String to search for. */ query: string; /** * If true, search is case sensitive. */ caseSensitive?: boolean; /** * If true, treats string parameter as regex. */ isRegex?: boolean; } export interface SearchInContentResponse { /** * List of search matches. */ result: SearchMatch[]; } export interface SetAsyncCallStackDepthRequest { /** * Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async * call stacks (default). */ maxDepth: integer; } export interface SetBlackboxExecutionContextsRequest { /** * Array of execution context unique ids for the debugger to ignore. */ uniqueIds: string[]; } export interface SetBlackboxPatternsRequest { /** * Array of regexps that will be used to check script url for blackbox state. */ patterns: string[]; /** * If true, also ignore scripts with no source url. */ skipAnonymous?: boolean; } export interface SetBlackboxedRangesRequest { /** * Id of the script. */ scriptId: Runtime.ScriptId; positions: ScriptPosition[]; } export interface SetBreakpointRequest { /** * Location to set breakpoint in. */ location: Location; /** * Expression to use as a breakpoint condition. When specified, debugger will only stop on the * breakpoint if this expression evaluates to true. */ condition?: string; } export interface SetBreakpointResponse { /** * Id of the created breakpoint for further reference. */ breakpointId: BreakpointId; /** * Location this breakpoint resolved into. */ actualLocation: Location; } export const enum SetInstrumentationBreakpointRequestInstrumentation { BeforeScriptExecution = 'beforeScriptExecution', BeforeScriptWithSourceMapExecution = 'beforeScriptWithSourceMapExecution', } export interface SetInstrumentationBreakpointRequest { /** * Instrumentation name. (SetInstrumentationBreakpointRequestInstrumentation enum) */ instrumentation: ('beforeScriptExecution' | 'beforeScriptWithSourceMapExecution'); } export interface SetInstrumentationBreakpointResponse { /** * Id of the created breakpoint for further reference. */ breakpointId: BreakpointId; } export interface SetBreakpointByUrlRequest { /** * Line number to set breakpoint at. */ lineNumber: integer; /** * URL of the resources to set breakpoint on. */ url?: string; /** * Regex pattern for the URLs of the resources to set breakpoints on. Either `url` or * `urlRegex` must be specified. */ urlRegex?: string; /** * Script hash of the resources to set breakpoint on. */ scriptHash?: string; /** * Offset in the line to set breakpoint at. */ columnNumber?: integer; /** * Expression to use as a breakpoint condition. When specified, debugger will only stop on the * breakpoint if this expression evaluates to true. */ condition?: string; } export interface SetBreakpointByUrlResponse { /** * Id of the created breakpoint for further reference. */ breakpointId: BreakpointId; /** * List of the locations this breakpoint resolved into upon addition. */ locations: Location[]; } export interface SetBreakpointOnFunctionCallRequest { /** * Function object id. */ objectId: Runtime.RemoteObjectId; /** * Expression to use as a breakpoint condition. When specified, debugger will * stop on the breakpoint if this expression evaluates to true. */ condition?: string; } export interface SetBreakpointOnFunctionCallResponse { /** * Id of the created breakpoint for further reference. */ breakpointId: BreakpointId; } export interface SetBreakpointsActiveRequest { /** * New value for breakpoints active state. */ active: boolean; } export const enum SetPauseOnExceptionsRequestState { None = 'none', Caught = 'caught', Uncaught = 'uncaught', All = 'all', } export interface SetPauseOnExceptionsRequest { /** * Pause on exceptions mode. (SetPauseOnExceptionsRequestState enum) */ state: ('none' | 'caught' | 'uncaught' | 'all'); } export interface SetReturnValueRequest { /** * New return value. */ newValue: Runtime.CallArgument; } export const enum SetScriptSourceResponseStatus { Ok = 'Ok', CompileError = 'CompileError', BlockedByActiveGenerator = 'BlockedByActiveGenerator', BlockedByActiveFunction = 'BlockedByActiveFunction', BlockedByTopLevelEsModuleChange = 'BlockedByTopLevelEsModuleChange', } export interface SetScriptSourceRequest { /** * Id of the script to edit. */ scriptId: Runtime.ScriptId; /** * New content of the script. */ scriptSource: string; /** * If true the change will not actually be applied. Dry run may be used to get result * description without actually modifying the code. */ dryRun?: boolean; /** * If true, then `scriptSource` is allowed to change the function on top of the stack * as long as the top-most stack frame is the only activation of that function. */ allowTopFrameEditing?: boolean; } export interface SetScriptSourceResponse { /** * New stack trace in case editing has happened while VM was stopped. */ callFrames?: CallFrame[]; /** * Whether current call stack was modified after applying the changes. */ stackChanged?: boolean; /** * Async stack trace, if any. */ asyncStackTrace?: Runtime.StackTrace; /** * Async stack trace, if any. */ asyncStackTraceId?: Runtime.StackTraceId; /** * Whether the operation was successful or not. Only `Ok` denotes a * successful live edit while the other enum variants denote why * the live edit failed. (SetScriptSourceResponseStatus enum) */ status: ('Ok' | 'CompileError' | 'BlockedByActiveGenerator' | 'BlockedByActiveFunction' | 'BlockedByTopLevelEsModuleChange'); /** * Exception details if any. Only present when `status` is `CompileError`. */ exceptionDetails?: Runtime.ExceptionDetails; } export interface SetSkipAllPausesRequest { /** * New value for skip pauses state. */ skip: boolean; } export interface SetVariableValueRequest { /** * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' * scope types are allowed. Other scopes could be manipulated manually. */ scopeNumber: integer; /** * Variable name. */ variableName: string; /** * New variable value. */ newValue: Runtime.CallArgument; /** * Id of callframe that holds variable. */ callFrameId: CallFrameId; } export interface StepIntoRequest { /** * Debugger will pause on the execution of the first async task which was scheduled * before next pause. */ breakOnAsyncCall?: boolean; /** * The skipList specifies location ranges that should be skipped on step into. */ skipList?: LocationRange[]; } export interface StepOverRequest { /** * The skipList specifies location ranges that should be skipped on step over. */ skipList?: LocationRange[]; } /** * Fired when breakpoint is resolved to an actual script and location. * Deprecated in favor of `resolvedBreakpoints` in the `scriptParsed` event. */ export interface BreakpointResolvedEvent { /** * Breakpoint unique identifier. */ breakpointId: BreakpointId; /** * Actual breakpoint location. */ location: Location; } export const enum PausedEventReason { Ambiguous = 'ambiguous', Assert = 'assert', CSPViolation = 'CSPViolation', DebugCommand = 'debugCommand', DOM = 'DOM', EventListener = 'EventListener', Exception = 'exception', Instrumentation = 'instrumentation', OOM = 'OOM', Other = 'other', PromiseRejection = 'promiseRejection', XHR = 'XHR', Step = 'step', } /** * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. */ export interface PausedEvent { /** * Call stack the virtual machine stopped on. */ callFrames: CallFrame[]; /** * Pause reason. (PausedEventReason enum) */ reason: ('ambiguous' | 'assert' | 'CSPViolation' | 'debugCommand' | 'DOM' | 'EventListener' | 'exception' | 'instrumentation' | 'OOM' | 'other' | 'promiseRejection' | 'XHR' | 'step'); /** * Object containing break-specific auxiliary properties. */ data?: any; /** * Hit breakpoints IDs */ hitBreakpoints?: string[]; /** * Async stack trace, if any. */ asyncStackTrace?: Runtime.StackTrace; /** * Async stack trace, if any. */ asyncStackTraceId?: Runtime.StackTraceId; /** * Never present, will be removed. */ asyncCallStackTraceId?: Runtime.StackTraceId; } /** * Fired when virtual machine fails to parse the script. */ export interface ScriptFailedToParseEvent { /** * Identifier of the script parsed. */ scriptId: Runtime.ScriptId; /** * URL or name of the script parsed (if any). */ url: string; /** * Line offset of the script within the resource with given URL (for script tags). */ startLine: integer; /** * Column offset of the script within the resource with given URL. */ startColumn: integer; /** * Last line of the script. */ endLine: integer; /** * Length of the last line of the script. */ endColumn: integer; /** * Specifies script creation context. */ executionContextId: Runtime.ExecutionContextId; /** * Content hash of the script, SHA-256. */ hash: string; /** * For Wasm modules, the content of the `build_id` custom section. For JavaScript the `debugId` magic comment. */ buildId: string; /** * Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string} */ executionContextAuxData?: any; /** * URL of source map associated with script (if any). */ sourceMapURL?: string; /** * True, if this script has sourceURL. */ hasSourceURL?: boolean; /** * True, if this script is ES6 module. */ isModule?: boolean; /** * This script length. */ length?: integer; /** * JavaScript top stack frame of where the script parsed event was triggered if available. */ stackTrace?: Runtime.StackTrace; /** * If the scriptLanguage is WebAssembly, the code section offset in the module. */ codeOffset?: integer; /** * The language of the script. */ scriptLanguage?: Debugger.ScriptLanguage; /** * The name the embedder supplied for this script. */ embedderName?: string; } /** * Fired when virtual machine parses script. This event is also fired for all known and uncollected * scripts upon enabling debugger. */ export interface ScriptParsedEvent { /** * Identifier of the script parsed. */ scriptId: Runtime.ScriptId; /** * URL or name of the script parsed (if any). */ url: string; /** * Line offset of the script within the resource with given URL (for script tags). */ startLine: integer; /** * Column offset of the script within the resource with given URL. */ startColumn: integer; /** * Last line of the script. */ endLine: integer; /** * Length of the last line of the script. */ endColumn: integer; /** * Specifies script creation context. */ executionContextId: Runtime.ExecutionContextId; /** * Content hash of the script, SHA-256. */ hash: string; /** * For Wasm modules, the content of the `build_id` custom section. For JavaScript the `debugId` magic comment. */ buildId: string; /** * Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string} */ executionContextAuxData?: any; /** * True, if this script is generated as a result of the live edit operation. */ isLiveEdit?: boolean; /** * URL of source map associated with script (if any). */ sourceMapURL?: string; /** * True, if this script has sourceURL. */ hasSourceURL?: boolean; /** * True, if this script is ES6 module. */ isModule?: boolean; /** * This script length. */ length?: integer; /** * JavaScript top stack frame of where the script parsed event was triggered if available. */ stackTrace?: Runtime.StackTrace; /** * If the scriptLanguage is WebAssembly, the code section offset in the module. */ codeOffset?: integer; /** * The language of the script. */ scriptLanguage?: Debugger.ScriptLanguage; /** * If the scriptLanguage is WebAssembly, the source of debug symbols for the module. */ debugSymbols?: Debugger.DebugSymbols[]; /** * The name the embedder supplied for this script. */ embedderName?: string; /** * The list of set breakpoints in this script if calls to `setBreakpointByUrl` * matches this script's URL or hash. Clients that use this list can ignore the * `breakpointResolved` event. They are equivalent. */ resolvedBreakpoints?: ResolvedBreakpoint[]; } } export namespace HeapProfiler { /** * Heap snapshot object id. */ export type HeapSnapshotObjectId = string; /** * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. */ export interface SamplingHeapProfileNode { /** * Function location. */ callFrame: Runtime.CallFrame; /** * Allocations size in bytes for the node excluding children. */ selfSize: number; /** * Node id. Ids are unique across all profiles collected between startSampling and stopSampling. */ id: integer; /** * Child nodes. */ children: SamplingHeapProfileNode[]; } /** * A single sample from a sampling profile. */ export interface SamplingHeapProfileSample { /** * Allocation size in bytes attributed to the sample. */ size: number; /** * Id of the corresponding profile tree node. */ nodeId: integer; /** * Time-ordered sample ordinal number. It is unique across all profiles retrieved * between startSampling and stopSampling. */ ordinal: number; } /** * Sampling profile. */ export interface SamplingHeapProfile { head: SamplingHeapProfileNode; samples: SamplingHeapProfileSample[]; } export interface AddInspectedHeapObjectRequest { /** * Heap snapshot object id to be accessible by means of $x command line API. */ heapObjectId: HeapSnapshotObjectId; } export interface GetHeapObjectIdRequest { /** * Identifier of the object to get heap object id for. */ objectId: Runtime.RemoteObjectId; } export interface GetHeapObjectIdResponse { /** * Id of the heap snapshot object corresponding to the passed remote object id. */ heapSnapshotObjectId: HeapSnapshotObjectId; } export interface GetObjectByHeapObjectIdRequest { objectId: HeapSnapshotObjectId; /** * Symbolic group name that can be used to release multiple objects. */ objectGroup?: string; } export interface GetObjectByHeapObjectIdResponse { /** * Evaluation result. */ result: Runtime.RemoteObject; } export interface GetSamplingProfileResponse { /** * Return the sampling profile being collected. */ profile: SamplingHeapProfile; } export interface StartSamplingRequest { /** * Average sample interval in bytes. Poisson distribution is used for the intervals. The * default value is 32768 bytes. */ samplingInterval?: number; /** * By default, the sampling heap profiler reports only objects which are * still alive when the profile is returned via getSamplingProfile or * stopSampling, which is useful for determining what functions contribute * the most to steady-state memory usage. This flag instructs the sampling * heap profiler to also include information about objects discarded by * major GC, which will show which functions cause large temporary memory * usage or long GC pauses. */ includeObjectsCollectedByMajorGC?: boolean; /** * By default, the sampling heap profiler reports only objects which are * still alive when the profile is returned via getSamplingProfile or * stopSampling, which is useful for determining what functions contribute * the most to steady-state memory usage. This flag instructs the sampling * heap profiler to also include information about objects discarded by * minor GC, which is useful when tuning a latency-sensitive application * for minimal GC activity. */ includeObjectsCollectedByMinorGC?: boolean; } export interface StartTrackingHeapObjectsRequest { trackAllocations?: boolean; } export interface StopSamplingResponse { /** * Recorded sampling heap profile. */ profile: SamplingHeapProfile; } export interface StopTrackingHeapObjectsRequest { /** * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken * when the tracking is stopped. */ reportProgress?: boolean; /** * Deprecated in favor of `exposeInternals`. */ treatGlobalObjectsAsRoots?: boolean; /** * If true, numerical values are included in the snapshot */ captureNumericValue?: boolean; /** * If true, exposes internals of the snapshot. */ exposeInternals?: boolean; } export interface TakeHeapSnapshotRequest { /** * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. */ reportProgress?: boolean; /** * If true, a raw snapshot without artificial roots will be generated. * Deprecated in favor of `exposeInternals`. */ treatGlobalObjectsAsRoots?: boolean; /** * If true, numerical values are included in the snapshot */ captureNumericValue?: boolean; /** * If true, exposes internals of the snapshot. */ exposeInternals?: boolean; } export interface AddHeapSnapshotChunkEvent { chunk: string; } /** * If heap objects tracking has been started then backend may send update for one or more fragments */ export interface HeapStatsUpdateEvent { /** * An array of triplets. Each triplet describes a fragment. The first integer is the fragment * index, the second integer is a total count of objects for the fragment, the third integer is * a total size of the objects for the fragment. */ statsUpdate: integer[]; } /** * If heap objects tracking has been started then backend regularly sends a current value for last * seen object id and corresponding timestamp. If the were changes in the heap since last event * then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. */ export interface LastSeenObjectIdEvent { lastSeenObjectId: integer; timestamp: number; } export interface ReportHeapSnapshotProgressEvent { done: integer; total: integer; finished?: boolean; } } export namespace Profiler { /** * Profile node. Holds callsite information, execution statistics and child nodes. */ export interface ProfileNode { /** * Unique id of the node. */ id: integer; /** * Function location. */ callFrame: Runtime.CallFrame; /** * Number of samples where this node was on top of the call stack. */ hitCount?: integer; /** * Child node ids. */ children?: integer[]; /** * The reason of being not optimized. The function may be deoptimized or marked as don't * optimize. */ deoptReason?: string; /** * An array of source position ticks. */ positionTicks?: PositionTickInfo[]; } /** * Profile. */ export interface Profile { /** * The list of profile nodes. First item is the root node. */ nodes: ProfileNode[]; /** * Profiling start timestamp in microseconds. */ startTime: number; /** * Profiling end timestamp in microseconds. */ endTime: number; /** * Ids of samples top nodes. */ samples?: integer[]; /** * Time intervals between adjacent samples in microseconds. The first delta is relative to the * profile startTime. */ timeDeltas?: integer[]; } /** * Specifies a number of samples attributed to a certain source position. */ export interface PositionTickInfo { /** * Source line number (1-based). */ line: integer; /** * Number of samples attributed to the source line. */ ticks: integer; } /** * Coverage data for a source range. */ export interface CoverageRange { /** * JavaScript script source offset for the range start. */ startOffset: integer; /** * JavaScript script source offset for the range end. */ endOffset: integer; /** * Collected execution count of the source range. */ count: integer; } /** * Coverage data for a JavaScript function. */ export interface FunctionCoverage { /** * JavaScript function name. */ functionName: string; /** * Source ranges inside the function with coverage data. */ ranges: CoverageRange[]; /** * Whether coverage data for this function has block granularity. */ isBlockCoverage: boolean; } /** * Coverage data for a JavaScript script. */ export interface ScriptCoverage { /** * JavaScript script id. */ scriptId: Runtime.ScriptId; /** * JavaScript script name or url. */ url: string; /** * Functions contained in the script that has coverage data. */ functions: FunctionCoverage[]; } export interface GetBestEffortCoverageResponse { /** * Coverage data for the current isolate. */ result: ScriptCoverage[]; } export interface SetSamplingIntervalRequest { /** * New sampling interval in microseconds. */ interval: integer; } export interface StartPreciseCoverageRequest { /** * Collect accurate call counts beyond simple 'covered' or 'not covered'. */ callCount?: boolean; /** * Collect block-based coverage. */ detailed?: boolean; /** * Allow the backend to send updates on its own initiative */ allowTriggeredUpdates?: boolean; } export interface StartPreciseCoverageResponse { /** * Monotonically increasing time (in seconds) when the coverage update was taken in the backend. */ timestamp: number; } export interface StopResponse { /** * Recorded profile. */ profile: Profile; } export interface TakePreciseCoverageResponse { /** * Coverage data for the current isolate. */ result: ScriptCoverage[]; /** * Monotonically increasing time (in seconds) when the coverage update was taken in the backend. */ timestamp: number; } export interface ConsoleProfileFinishedEvent { id: string; /** * Location of console.profileEnd(). */ location: Debugger.Location; profile: Profile; /** * Profile title passed as an argument to console.profile(). */ title?: string; } /** * Sent when new profile recording is started using console.profile() call. */ export interface ConsoleProfileStartedEvent { id: string; /** * Location of console.profile(). */ location: Debugger.Location; /** * Profile title passed as an argument to console.profile(). */ title?: string; } /** * Reports coverage delta since the last poll (either from an event like this, or from * `takePreciseCoverage` for the current isolate. May only be sent if precise code * coverage has been started. This event can be trigged by the embedder to, for example, * trigger collection of coverage data immediately at a certain point in time. */ export interface PreciseCoverageDeltaUpdateEvent { /** * Monotonically increasing time (in seconds) when the coverage update was taken in the backend. */ timestamp: number; /** * Identifier for distinguishing coverage events. */ occasion: string; /** * Coverage data for the current isolate. */ result: ScriptCoverage[]; } } /** * Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. * Evaluation results are returned as mirror object that expose object type, string representation * and unique identifier that can be used for further object reference. Original objects are * maintained in memory unless they are either explicitly released or are released along with the * other objects in their object group. */ export namespace Runtime { /** * Unique script identifier. */ export type ScriptId = string; export const enum SerializationOptionsSerialization { Deep = 'deep', Json = 'json', IdOnly = 'idOnly', } /** * Represents options for serialization. Overrides `generatePreview` and `returnByValue`. */ export interface SerializationOptions { /** * (SerializationOptionsSerialization enum) */ serialization: ('deep' | 'json' | 'idOnly'); /** * Deep serialization depth. Default is full depth. Respected only in `deep` serialization mode. */ maxDepth?: integer;