//// > ⚙️ This module was generated from the Chrome DevTools Protocol version **1.3** //// ## Debugger Domain //// //// Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing //// breakpoints, stepping through execution, exploring stack traces, etc. //// //// [📖 View this domain on the DevTools Protocol API Docs](https://chromedevtools.github.io/devtools-protocol/1-3/Debugger/) // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | // | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| // --------------------------------------------------------------------------- import chrobot/internal/utils import chrome import gleam/dynamic import gleam/json import gleam/option import gleam/result import protocol/runtime /// Breakpoint identifier. pub type BreakpointId { BreakpointId(String) } @internal pub fn encode__breakpoint_id(value__: BreakpointId) { case value__ { BreakpointId(inner_value__) -> json.string(inner_value__) } } @internal pub fn decode__breakpoint_id(value__: dynamic.Dynamic) { value__ |> dynamic.decode1(BreakpointId, dynamic.string) } /// Call frame identifier. pub type CallFrameId { CallFrameId(String) } @internal pub fn encode__call_frame_id(value__: CallFrameId) { case value__ { CallFrameId(inner_value__) -> json.string(inner_value__) } } @internal pub fn decode__call_frame_id(value__: dynamic.Dynamic) { value__ |> dynamic.decode1(CallFrameId, dynamic.string) } /// Location in the source code. pub type Location { Location( /// Script identifier as reported in the `Debugger.scriptParsed`. script_id: runtime.ScriptId, /// Line number in the script (0-based). line_number: Int, /// Column number in the script (0-based). column_number: option.Option(Int), ) } @internal pub fn encode__location(value__: Location) { json.object( [ #("scriptId", runtime.encode__script_id(value__.script_id)), #("lineNumber", json.int(value__.line_number)), ] |> utils.add_optional(value__.column_number, fn(inner_value__) { #("columnNumber", json.int(inner_value__)) }), ) } @internal pub fn decode__location(value__: dynamic.Dynamic) { use script_id <- result.try(dynamic.field( "scriptId", runtime.decode__script_id, )(value__)) use line_number <- result.try(dynamic.field("lineNumber", dynamic.int)( value__, )) use column_number <- result.try(dynamic.optional_field( "columnNumber", dynamic.int, )(value__)) Ok(Location( script_id: script_id, line_number: line_number, column_number: column_number, )) } /// JavaScript call frame. Array of call frames form the call stack. pub type CallFrame { CallFrame( /// Call frame identifier. This identifier is only valid while the virtual machine is paused. call_frame_id: CallFrameId, /// Name of the JavaScript function called on this call frame. function_name: String, /// Location in the source code. function_location: option.Option(Location), /// Location in the source code. location: Location, /// Scope chain for this call frame. scope_chain: List(Scope), /// `this` object for this call frame. this: runtime.RemoteObject, /// The value being returned, if the function is at return point. return_value: option.Option(runtime.RemoteObject), ) } @internal pub fn encode__call_frame(value__: CallFrame) { json.object( [ #("callFrameId", encode__call_frame_id(value__.call_frame_id)), #("functionName", json.string(value__.function_name)), #("location", encode__location(value__.location)), #("scopeChain", json.array(value__.scope_chain, of: encode__scope)), #("this", runtime.encode__remote_object(value__.this)), ] |> utils.add_optional(value__.function_location, fn(inner_value__) { #("functionLocation", encode__location(inner_value__)) }) |> utils.add_optional(value__.return_value, fn(inner_value__) { #("returnValue", runtime.encode__remote_object(inner_value__)) }), ) } @internal pub fn decode__call_frame(value__: dynamic.Dynamic) { use call_frame_id <- result.try(dynamic.field( "callFrameId", decode__call_frame_id, )(value__)) use function_name <- result.try(dynamic.field("functionName", dynamic.string)( value__, )) use function_location <- result.try(dynamic.optional_field( "functionLocation", decode__location, )(value__)) use location <- result.try(dynamic.field("location", decode__location)( value__, )) use scope_chain <- result.try(dynamic.field( "scopeChain", dynamic.list(decode__scope), )(value__)) use this <- result.try(dynamic.field("this", runtime.decode__remote_object)( value__, )) use return_value <- result.try(dynamic.optional_field( "returnValue", runtime.decode__remote_object, )(value__)) Ok(CallFrame( call_frame_id: call_frame_id, function_name: function_name, function_location: function_location, location: location, scope_chain: scope_chain, this: this, return_value: return_value, )) } /// Scope description. pub type Scope { Scope( /// Scope type. type_: ScopeType, /// 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: option.Option(String), /// Location in the source code where scope starts start_location: option.Option(Location), /// Location in the source code where scope ends end_location: option.Option(Location), ) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `type` of `Scope` pub type ScopeType { ScopeTypeGlobal ScopeTypeLocal ScopeTypeWith ScopeTypeClosure ScopeTypeCatch ScopeTypeBlock ScopeTypeScript ScopeTypeEval ScopeTypeModule ScopeTypeWasmExpressionStack } @internal pub fn encode__scope_type(value__: ScopeType) { case value__ { ScopeTypeGlobal -> "global" ScopeTypeLocal -> "local" ScopeTypeWith -> "with" ScopeTypeClosure -> "closure" ScopeTypeCatch -> "catch" ScopeTypeBlock -> "block" ScopeTypeScript -> "script" ScopeTypeEval -> "eval" ScopeTypeModule -> "module" ScopeTypeWasmExpressionStack -> "wasm-expression-stack" } |> json.string() } @internal pub fn decode__scope_type(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("global") -> Ok(ScopeTypeGlobal) Ok("local") -> Ok(ScopeTypeLocal) Ok("with") -> Ok(ScopeTypeWith) Ok("closure") -> Ok(ScopeTypeClosure) Ok("catch") -> Ok(ScopeTypeCatch) Ok("block") -> Ok(ScopeTypeBlock) Ok("script") -> Ok(ScopeTypeScript) Ok("eval") -> Ok(ScopeTypeEval) Ok("module") -> Ok(ScopeTypeModule) Ok("wasm-expression-stack") -> Ok(ScopeTypeWasmExpressionStack) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } @internal pub fn encode__scope(value__: Scope) { json.object( [ #("type", encode__scope_type(value__.type_)), #("object", runtime.encode__remote_object(value__.object)), ] |> utils.add_optional(value__.name, fn(inner_value__) { #("name", json.string(inner_value__)) }) |> utils.add_optional(value__.start_location, fn(inner_value__) { #("startLocation", encode__location(inner_value__)) }) |> utils.add_optional(value__.end_location, fn(inner_value__) { #("endLocation", encode__location(inner_value__)) }), ) } @internal pub fn decode__scope(value__: dynamic.Dynamic) { use type_ <- result.try(dynamic.field("type", decode__scope_type)(value__)) use object <- result.try(dynamic.field( "object", runtime.decode__remote_object, )(value__)) use name <- result.try(dynamic.optional_field("name", dynamic.string)(value__)) use start_location <- result.try(dynamic.optional_field( "startLocation", decode__location, )(value__)) use end_location <- result.try(dynamic.optional_field( "endLocation", decode__location, )(value__)) Ok(Scope( type_: type_, object: object, name: name, start_location: start_location, end_location: end_location, )) } /// Search match for resource. pub type SearchMatch { SearchMatch( /// Line number in resource content. line_number: Float, /// Line with match content. line_content: String, ) } @internal pub fn encode__search_match(value__: SearchMatch) { json.object([ #("lineNumber", json.float(value__.line_number)), #("lineContent", json.string(value__.line_content)), ]) } @internal pub fn decode__search_match(value__: dynamic.Dynamic) { use line_number <- result.try(dynamic.field("lineNumber", dynamic.float)( value__, )) use line_content <- result.try(dynamic.field("lineContent", dynamic.string)( value__, )) Ok(SearchMatch(line_number: line_number, line_content: line_content)) } pub type BreakLocation { BreakLocation( /// Script identifier as reported in the `Debugger.scriptParsed`. script_id: runtime.ScriptId, /// Line number in the script (0-based). line_number: Int, /// Column number in the script (0-based). column_number: option.Option(Int), type_: option.Option(BreakLocationType), ) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `type` of `BreakLocation` pub type BreakLocationType { BreakLocationTypeDebuggerStatement BreakLocationTypeCall BreakLocationTypeReturn } @internal pub fn encode__break_location_type(value__: BreakLocationType) { case value__ { BreakLocationTypeDebuggerStatement -> "debuggerStatement" BreakLocationTypeCall -> "call" BreakLocationTypeReturn -> "return" } |> json.string() } @internal pub fn decode__break_location_type(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("debuggerStatement") -> Ok(BreakLocationTypeDebuggerStatement) Ok("call") -> Ok(BreakLocationTypeCall) Ok("return") -> Ok(BreakLocationTypeReturn) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } @internal pub fn encode__break_location(value__: BreakLocation) { json.object( [ #("scriptId", runtime.encode__script_id(value__.script_id)), #("lineNumber", json.int(value__.line_number)), ] |> utils.add_optional(value__.column_number, fn(inner_value__) { #("columnNumber", json.int(inner_value__)) }) |> utils.add_optional(value__.type_, fn(inner_value__) { #("type", encode__break_location_type(inner_value__)) }), ) } @internal pub fn decode__break_location(value__: dynamic.Dynamic) { use script_id <- result.try(dynamic.field( "scriptId", runtime.decode__script_id, )(value__)) use line_number <- result.try(dynamic.field("lineNumber", dynamic.int)( value__, )) use column_number <- result.try(dynamic.optional_field( "columnNumber", dynamic.int, )(value__)) use type_ <- result.try(dynamic.optional_field( "type", decode__break_location_type, )(value__)) Ok(BreakLocation( script_id: script_id, line_number: line_number, column_number: column_number, type_: type_, )) } /// Enum of possible script languages. pub type ScriptLanguage { ScriptLanguageJavaScript ScriptLanguageWebAssembly } @internal pub fn encode__script_language(value__: ScriptLanguage) { case value__ { ScriptLanguageJavaScript -> "JavaScript" ScriptLanguageWebAssembly -> "WebAssembly" } |> json.string() } @internal pub fn decode__script_language(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("JavaScript") -> Ok(ScriptLanguageJavaScript) Ok("WebAssembly") -> Ok(ScriptLanguageWebAssembly) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } /// Debug symbols available for a wasm script. pub type DebugSymbols { DebugSymbols( /// Type of the debug symbols. type_: DebugSymbolsType, /// URL of the external symbol source. external_url: option.Option(String), ) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `type` of `DebugSymbols` pub type DebugSymbolsType { DebugSymbolsTypeNone DebugSymbolsTypeSourceMap DebugSymbolsTypeEmbeddedDwarf DebugSymbolsTypeExternalDwarf } @internal pub fn encode__debug_symbols_type(value__: DebugSymbolsType) { case value__ { DebugSymbolsTypeNone -> "None" DebugSymbolsTypeSourceMap -> "SourceMap" DebugSymbolsTypeEmbeddedDwarf -> "EmbeddedDWARF" DebugSymbolsTypeExternalDwarf -> "ExternalDWARF" } |> json.string() } @internal pub fn decode__debug_symbols_type(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("None") -> Ok(DebugSymbolsTypeNone) Ok("SourceMap") -> Ok(DebugSymbolsTypeSourceMap) Ok("EmbeddedDWARF") -> Ok(DebugSymbolsTypeEmbeddedDwarf) Ok("ExternalDWARF") -> Ok(DebugSymbolsTypeExternalDwarf) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } @internal pub fn encode__debug_symbols(value__: DebugSymbols) { json.object( [#("type", encode__debug_symbols_type(value__.type_))] |> utils.add_optional(value__.external_url, fn(inner_value__) { #("externalURL", json.string(inner_value__)) }), ) } @internal pub fn decode__debug_symbols(value__: dynamic.Dynamic) { use type_ <- result.try(dynamic.field("type", decode__debug_symbols_type)( value__, )) use external_url <- result.try(dynamic.optional_field( "externalURL", dynamic.string, )(value__)) Ok(DebugSymbols(type_: type_, external_url: external_url)) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `evaluate_on_call_frame` pub type EvaluateOnCallFrameResponse { EvaluateOnCallFrameResponse( /// Object wrapper for the evaluation result. result: runtime.RemoteObject, /// Exception details. exception_details: option.Option(runtime.ExceptionDetails), ) } @internal pub fn decode__evaluate_on_call_frame_response(value__: dynamic.Dynamic) { use result <- result.try(dynamic.field( "result", runtime.decode__remote_object, )(value__)) use exception_details <- result.try(dynamic.optional_field( "exceptionDetails", runtime.decode__exception_details, )(value__)) Ok(EvaluateOnCallFrameResponse( result: result, exception_details: exception_details, )) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `get_possible_breakpoints` pub type GetPossibleBreakpointsResponse { GetPossibleBreakpointsResponse( /// List of the possible breakpoint locations. locations: List(BreakLocation), ) } @internal pub fn decode__get_possible_breakpoints_response(value__: dynamic.Dynamic) { use locations <- result.try(dynamic.field( "locations", dynamic.list(decode__break_location), )(value__)) Ok(GetPossibleBreakpointsResponse(locations: locations)) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `get_script_source` pub type GetScriptSourceResponse { GetScriptSourceResponse( /// Script source (empty in case of Wasm bytecode). script_source: String, /// Wasm bytecode. (Encoded as a base64 string when passed over JSON) bytecode: option.Option(String), ) } @internal pub fn decode__get_script_source_response(value__: dynamic.Dynamic) { use script_source <- result.try(dynamic.field("scriptSource", dynamic.string)( value__, )) use bytecode <- result.try(dynamic.optional_field("bytecode", dynamic.string)( value__, )) Ok(GetScriptSourceResponse(script_source: script_source, bytecode: bytecode)) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `search_in_content` pub type SearchInContentResponse { SearchInContentResponse( /// List of search matches. result: List(SearchMatch), ) } @internal pub fn decode__search_in_content_response(value__: dynamic.Dynamic) { use result <- result.try(dynamic.field( "result", dynamic.list(decode__search_match), )(value__)) Ok(SearchInContentResponse(result: result)) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `set_breakpoint` pub type SetBreakpointResponse { SetBreakpointResponse( /// Id of the created breakpoint for further reference. breakpoint_id: BreakpointId, /// Location this breakpoint resolved into. actual_location: Location, ) } @internal pub fn decode__set_breakpoint_response(value__: dynamic.Dynamic) { use breakpoint_id <- result.try(dynamic.field( "breakpointId", decode__breakpoint_id, )(value__)) use actual_location <- result.try(dynamic.field( "actualLocation", decode__location, )(value__)) Ok(SetBreakpointResponse( breakpoint_id: breakpoint_id, actual_location: actual_location, )) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `set_instrumentation_breakpoint` pub type SetInstrumentationBreakpointResponse { SetInstrumentationBreakpointResponse( /// Id of the created breakpoint for further reference. breakpoint_id: BreakpointId, ) } @internal pub fn decode__set_instrumentation_breakpoint_response(value__: dynamic.Dynamic) { use breakpoint_id <- result.try(dynamic.field( "breakpointId", decode__breakpoint_id, )(value__)) Ok(SetInstrumentationBreakpointResponse(breakpoint_id: breakpoint_id)) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `set_breakpoint_by_url` pub type SetBreakpointByUrlResponse { SetBreakpointByUrlResponse( /// Id of the created breakpoint for further reference. breakpoint_id: BreakpointId, /// List of the locations this breakpoint resolved into upon addition. locations: List(Location), ) } @internal pub fn decode__set_breakpoint_by_url_response(value__: dynamic.Dynamic) { use breakpoint_id <- result.try(dynamic.field( "breakpointId", decode__breakpoint_id, )(value__)) use locations <- result.try(dynamic.field( "locations", dynamic.list(decode__location), )(value__)) Ok(SetBreakpointByUrlResponse( breakpoint_id: breakpoint_id, locations: locations, )) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the response to the command `set_script_source` pub type SetScriptSourceResponse { SetScriptSourceResponse( /// Exception details if any. Only present when `status` is `CompileError`. exception_details: option.Option(runtime.ExceptionDetails), ) } @internal pub fn decode__set_script_source_response(value__: dynamic.Dynamic) { use exception_details <- result.try(dynamic.optional_field( "exceptionDetails", runtime.decode__exception_details, )(value__)) Ok(SetScriptSourceResponse(exception_details: exception_details)) } /// Continues execution until specific location is reached. /// /// Parameters: /// - `location` : Location to continue to. /// - `target_call_frames` /// /// Returns: /// pub fn continue_to_location( callback__, location location: Location, target_call_frames target_call_frames: option.Option( ContinueToLocationTargetCallFrames, ), ) { callback__( "Debugger.continueToLocation", option.Some(json.object( [#("location", encode__location(location))] |> utils.add_optional(target_call_frames, fn(inner_value__) { #( "targetCallFrames", encode__continue_to_location_target_call_frames(inner_value__), ) }), )), ) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `targetCallFrames` of `continueToLocation` pub type ContinueToLocationTargetCallFrames { ContinueToLocationTargetCallFramesAny ContinueToLocationTargetCallFramesCurrent } @internal pub fn encode__continue_to_location_target_call_frames(value__: ContinueToLocationTargetCallFrames) { case value__ { ContinueToLocationTargetCallFramesAny -> "any" ContinueToLocationTargetCallFramesCurrent -> "current" } |> json.string() } @internal pub fn decode__continue_to_location_target_call_frames(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("any") -> Ok(ContinueToLocationTargetCallFramesAny) Ok("current") -> Ok(ContinueToLocationTargetCallFramesCurrent) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } /// Disables debugger for given page. /// pub fn disable(callback__) { callback__("Debugger.disable", option.None) } /// Enables debugger for the given page. Clients should not assume that the debugging has been /// enabled until the result for this command is received. /// /// Parameters: /// /// Returns: /// pub fn enable(callback__) { callback__("Debugger.enable", option.None) } /// Evaluates expression on a given call frame. /// /// Parameters: /// - `call_frame_id` : Call frame identifier to evaluate on. /// - `expression` : Expression to evaluate. /// - `object_group` : String object group name to put result into (allows rapid releasing resulting object handles /// using `releaseObjectGroup`). /// - `include_command_line_api` : Specifies whether command line API should be available to the evaluated expression, defaults /// to false. /// - `silent` : In silent mode exceptions thrown during evaluation are not reported and do not pause /// execution. Overrides `setPauseOnException` state. /// - `return_by_value` : Whether the result is expected to be a JSON object that should be sent by value. /// - `throw_on_side_effect` : Whether to throw an exception if side effect cannot be ruled out during evaluation. /// /// Returns: /// - `result` : Object wrapper for the evaluation result. /// - `exception_details` : Exception details. /// pub fn evaluate_on_call_frame( callback__, call_frame_id call_frame_id: CallFrameId, expression expression: String, object_group object_group: option.Option(String), include_command_line_api include_command_line_api: option.Option(Bool), silent silent: option.Option(Bool), return_by_value return_by_value: option.Option(Bool), throw_on_side_effect throw_on_side_effect: option.Option(Bool), ) { use result__ <- result.try(callback__( "Debugger.evaluateOnCallFrame", option.Some(json.object( [ #("callFrameId", encode__call_frame_id(call_frame_id)), #("expression", json.string(expression)), ] |> utils.add_optional(object_group, fn(inner_value__) { #("objectGroup", json.string(inner_value__)) }) |> utils.add_optional(include_command_line_api, fn(inner_value__) { #("includeCommandLineAPI", json.bool(inner_value__)) }) |> utils.add_optional(silent, fn(inner_value__) { #("silent", json.bool(inner_value__)) }) |> utils.add_optional(return_by_value, fn(inner_value__) { #("returnByValue", json.bool(inner_value__)) }) |> utils.add_optional(throw_on_side_effect, fn(inner_value__) { #("throwOnSideEffect", json.bool(inner_value__)) }), )), )) decode__evaluate_on_call_frame_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Returns possible locations for breakpoint. scriptId in start and end range locations should be /// the same. /// /// Parameters: /// - `start` : Start of range to search possible breakpoint locations in. /// - `end` : End of range to search possible breakpoint locations in (excluding). When not specified, end /// of scripts is used as end of range. /// - `restrict_to_function` : Only consider locations which are in the same (non-nested) function as start. /// /// Returns: /// - `locations` : List of the possible breakpoint locations. /// pub fn get_possible_breakpoints( callback__, start start: Location, end end: option.Option(Location), restrict_to_function restrict_to_function: option.Option(Bool), ) { use result__ <- result.try(callback__( "Debugger.getPossibleBreakpoints", option.Some(json.object( [#("start", encode__location(start))] |> utils.add_optional(end, fn(inner_value__) { #("end", encode__location(inner_value__)) }) |> utils.add_optional(restrict_to_function, fn(inner_value__) { #("restrictToFunction", json.bool(inner_value__)) }), )), )) decode__get_possible_breakpoints_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Returns source for the script with given id. /// /// Parameters: /// - `script_id` : Id of the script to get source for. /// /// Returns: /// - `script_source` : Script source (empty in case of Wasm bytecode). /// - `bytecode` : Wasm bytecode. (Encoded as a base64 string when passed over JSON) /// pub fn get_script_source(callback__, script_id script_id: runtime.ScriptId) { use result__ <- result.try(callback__( "Debugger.getScriptSource", option.Some( json.object([#("scriptId", runtime.encode__script_id(script_id))]), ), )) decode__get_script_source_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Stops on the next JavaScript statement. /// pub fn pause(callback__) { callback__("Debugger.pause", option.None) } /// Removes JavaScript breakpoint. /// /// Parameters: /// - `breakpoint_id` /// /// Returns: /// pub fn remove_breakpoint(callback__, breakpoint_id breakpoint_id: BreakpointId) { callback__( "Debugger.removeBreakpoint", option.Some( json.object([#("breakpointId", encode__breakpoint_id(breakpoint_id))]), ), ) } /// Restarts particular call frame from the beginning. The old, deprecated /// behavior of `restartFrame` is to stay paused and allow further CDP commands /// after a restart was scheduled. This can cause problems with restarting, so /// we now continue execution immediatly after it has been scheduled until we /// reach the beginning of the restarted frame. /// /// To stay back-wards compatible, `restartFrame` now expects a `mode` /// parameter to be present. If the `mode` parameter is missing, `restartFrame` /// errors out. /// /// The various return values are deprecated and `callFrames` is always empty. /// Use the call frames from the `Debugger#paused` events instead, that fires /// once V8 pauses at the beginning of the restarted function. /// /// Parameters: /// - `call_frame_id` : Call frame identifier to evaluate on. /// /// Returns: /// pub fn restart_frame(callback__, call_frame_id call_frame_id: CallFrameId) { callback__( "Debugger.restartFrame", option.Some( json.object([#("callFrameId", encode__call_frame_id(call_frame_id))]), ), ) } /// Resumes JavaScript execution. /// /// Parameters: /// - `terminate_on_resume` : 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. /// /// Returns: /// pub fn resume( callback__, terminate_on_resume terminate_on_resume: option.Option(Bool), ) { callback__( "Debugger.resume", option.Some(json.object( [] |> utils.add_optional(terminate_on_resume, fn(inner_value__) { #("terminateOnResume", json.bool(inner_value__)) }), )), ) } /// Searches for given string in script content. /// /// Parameters: /// - `script_id` : Id of the script to search in. /// - `query` : String to search for. /// - `case_sensitive` : If true, search is case sensitive. /// - `is_regex` : If true, treats string parameter as regex. /// /// Returns: /// - `result` : List of search matches. /// pub fn search_in_content( callback__, script_id script_id: runtime.ScriptId, query query: String, case_sensitive case_sensitive: option.Option(Bool), is_regex is_regex: option.Option(Bool), ) { use result__ <- result.try(callback__( "Debugger.searchInContent", option.Some(json.object( [ #("scriptId", runtime.encode__script_id(script_id)), #("query", json.string(query)), ] |> utils.add_optional(case_sensitive, fn(inner_value__) { #("caseSensitive", json.bool(inner_value__)) }) |> utils.add_optional(is_regex, fn(inner_value__) { #("isRegex", json.bool(inner_value__)) }), )), )) decode__search_in_content_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Enables or disables async call stacks tracking. /// /// Parameters: /// - `max_depth` : Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async /// call stacks (default). /// /// Returns: /// pub fn set_async_call_stack_depth(callback__, max_depth max_depth: Int) { callback__( "Debugger.setAsyncCallStackDepth", option.Some(json.object([#("maxDepth", json.int(max_depth))])), ) } /// Sets JavaScript breakpoint at a given location. /// /// Parameters: /// - `location` : Location to set breakpoint in. /// - `condition` : Expression to use as a breakpoint condition. When specified, debugger will only stop on the /// breakpoint if this expression evaluates to true. /// /// Returns: /// - `breakpoint_id` : Id of the created breakpoint for further reference. /// - `actual_location` : Location this breakpoint resolved into. /// pub fn set_breakpoint( callback__, location location: Location, condition condition: option.Option(String), ) { use result__ <- result.try(callback__( "Debugger.setBreakpoint", option.Some(json.object( [#("location", encode__location(location))] |> utils.add_optional(condition, fn(inner_value__) { #("condition", json.string(inner_value__)) }), )), )) decode__set_breakpoint_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Sets instrumentation breakpoint. /// /// Parameters: /// - `instrumentation` : Instrumentation name. /// /// Returns: /// - `breakpoint_id` : Id of the created breakpoint for further reference. /// pub fn set_instrumentation_breakpoint( callback__, instrumentation instrumentation: SetInstrumentationBreakpointInstrumentation, ) { use result__ <- result.try(callback__( "Debugger.setInstrumentationBreakpoint", option.Some( json.object([ #( "instrumentation", encode__set_instrumentation_breakpoint_instrumentation( instrumentation, ), ), ]), ), )) decode__set_instrumentation_breakpoint_response(result__) |> result.replace_error(chrome.ProtocolError) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `instrumentation` of `setInstrumentationBreakpoint` pub type SetInstrumentationBreakpointInstrumentation { SetInstrumentationBreakpointInstrumentationBeforeScriptExecution SetInstrumentationBreakpointInstrumentationBeforeScriptWithSourceMapExecution } @internal pub fn encode__set_instrumentation_breakpoint_instrumentation(value__: SetInstrumentationBreakpointInstrumentation) { case value__ { SetInstrumentationBreakpointInstrumentationBeforeScriptExecution -> "beforeScriptExecution" SetInstrumentationBreakpointInstrumentationBeforeScriptWithSourceMapExecution -> "beforeScriptWithSourceMapExecution" } |> json.string() } @internal pub fn decode__set_instrumentation_breakpoint_instrumentation(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("beforeScriptExecution") -> Ok(SetInstrumentationBreakpointInstrumentationBeforeScriptExecution) Ok("beforeScriptWithSourceMapExecution") -> Ok( SetInstrumentationBreakpointInstrumentationBeforeScriptWithSourceMapExecution, ) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } /// Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this /// command is issued, all existing parsed scripts will have breakpoints resolved and returned in /// `locations` property. Further matching script parsing will result in subsequent /// `breakpointResolved` events issued. This logical breakpoint will survive page reloads. /// /// Parameters: /// - `line_number` : Line number to set breakpoint at. /// - `url` : URL of the resources to set breakpoint on. /// - `url_regex` : Regex pattern for the URLs of the resources to set breakpoints on. Either `url` or /// `urlRegex` must be specified. /// - `script_hash` : Script hash of the resources to set breakpoint on. /// - `column_number` : Offset in the line to set breakpoint at. /// - `condition` : Expression to use as a breakpoint condition. When specified, debugger will only stop on the /// breakpoint if this expression evaluates to true. /// /// Returns: /// - `breakpoint_id` : Id of the created breakpoint for further reference. /// - `locations` : List of the locations this breakpoint resolved into upon addition. /// pub fn set_breakpoint_by_url( callback__, line_number line_number: Int, url url: option.Option(String), url_regex url_regex: option.Option(String), script_hash script_hash: option.Option(String), column_number column_number: option.Option(Int), condition condition: option.Option(String), ) { use result__ <- result.try(callback__( "Debugger.setBreakpointByUrl", option.Some(json.object( [#("lineNumber", json.int(line_number))] |> utils.add_optional(url, fn(inner_value__) { #("url", json.string(inner_value__)) }) |> utils.add_optional(url_regex, fn(inner_value__) { #("urlRegex", json.string(inner_value__)) }) |> utils.add_optional(script_hash, fn(inner_value__) { #("scriptHash", json.string(inner_value__)) }) |> utils.add_optional(column_number, fn(inner_value__) { #("columnNumber", json.int(inner_value__)) }) |> utils.add_optional(condition, fn(inner_value__) { #("condition", json.string(inner_value__)) }), )), )) decode__set_breakpoint_by_url_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Activates / deactivates all breakpoints on the page. /// /// Parameters: /// - `active` : New value for breakpoints active state. /// /// Returns: /// pub fn set_breakpoints_active(callback__, active active: Bool) { callback__( "Debugger.setBreakpointsActive", option.Some(json.object([#("active", json.bool(active))])), ) } /// Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions, /// or caught exceptions, no exceptions. Initial pause on exceptions state is `none`. /// /// Parameters: /// - `state` : Pause on exceptions mode. /// /// Returns: /// pub fn set_pause_on_exceptions( callback__, state state: SetPauseOnExceptionsState, ) { callback__( "Debugger.setPauseOnExceptions", option.Some( json.object([#("state", encode__set_pause_on_exceptions_state(state))]), ), ) } /// This type is not part of the protocol spec, it has been generated dynamically /// to represent the possible values of the enum property `state` of `setPauseOnExceptions` pub type SetPauseOnExceptionsState { SetPauseOnExceptionsStateNone SetPauseOnExceptionsStateCaught SetPauseOnExceptionsStateUncaught SetPauseOnExceptionsStateAll } @internal pub fn encode__set_pause_on_exceptions_state(value__: SetPauseOnExceptionsState) { case value__ { SetPauseOnExceptionsStateNone -> "none" SetPauseOnExceptionsStateCaught -> "caught" SetPauseOnExceptionsStateUncaught -> "uncaught" SetPauseOnExceptionsStateAll -> "all" } |> json.string() } @internal pub fn decode__set_pause_on_exceptions_state(value__: dynamic.Dynamic) { case dynamic.string(value__) { Ok("none") -> Ok(SetPauseOnExceptionsStateNone) Ok("caught") -> Ok(SetPauseOnExceptionsStateCaught) Ok("uncaught") -> Ok(SetPauseOnExceptionsStateUncaught) Ok("all") -> Ok(SetPauseOnExceptionsStateAll) Error(error) -> Error(error) Ok(other) -> Error([ dynamic.DecodeError( expected: "valid enum property", found: other, path: ["enum decoder"], ), ]) } } /// Edits JavaScript source live. /// /// In general, functions that are currently on the stack can not be edited with /// a single exception: If the edited function is the top-most stack frame and /// that is the only activation of that function on the stack. In this case /// the live edit will be successful and a `Debugger.restartFrame` for the /// top-most function is automatically triggered. /// /// Parameters: /// - `script_id` : Id of the script to edit. /// - `script_source` : New content of the script. /// - `dry_run` : If true the change will not actually be applied. Dry run may be used to get result /// description without actually modifying the code. /// /// Returns: /// - `exception_details` : Exception details if any. Only present when `status` is `CompileError`. /// pub fn set_script_source( callback__, script_id script_id: runtime.ScriptId, script_source script_source: String, dry_run dry_run: option.Option(Bool), ) { use result__ <- result.try(callback__( "Debugger.setScriptSource", option.Some(json.object( [ #("scriptId", runtime.encode__script_id(script_id)), #("scriptSource", json.string(script_source)), ] |> utils.add_optional(dry_run, fn(inner_value__) { #("dryRun", json.bool(inner_value__)) }), )), )) decode__set_script_source_response(result__) |> result.replace_error(chrome.ProtocolError) } /// Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). /// /// Parameters: /// - `skip` : New value for skip pauses state. /// /// Returns: /// pub fn set_skip_all_pauses(callback__, skip skip: Bool) { callback__( "Debugger.setSkipAllPauses", option.Some(json.object([#("skip", json.bool(skip))])), ) } /// Changes value of variable in a callframe. Object-based scopes are not supported and must be /// mutated manually. /// /// Parameters: /// - `scope_number` : 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. /// - `variable_name` : Variable name. /// - `new_value` : New variable value. /// - `call_frame_id` : Id of callframe that holds variable. /// /// Returns: /// pub fn set_variable_value( callback__, scope_number scope_number: Int, variable_name variable_name: String, new_value new_value: runtime.CallArgument, call_frame_id call_frame_id: CallFrameId, ) { callback__( "Debugger.setVariableValue", option.Some( json.object([ #("scopeNumber", json.int(scope_number)), #("variableName", json.string(variable_name)), #("newValue", runtime.encode__call_argument(new_value)), #("callFrameId", encode__call_frame_id(call_frame_id)), ]), ), ) } /// Steps into the function call. /// /// Parameters: /// /// Returns: /// pub fn step_into(callback__) { callback__("Debugger.stepInto", option.None) } /// Steps out of the function call. /// pub fn step_out(callback__) { callback__("Debugger.stepOut", option.None) } /// Steps over the statement. /// /// Parameters: /// /// Returns: /// pub fn step_over(callback__) { callback__("Debugger.stepOver", option.None) }