bidi2pdf 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +53 -0
- data/.devcontainer/devcontainer.json +51 -0
- data/.devcontainer/docker-compose.yml +33 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +93 -6
- data/README.md +80 -5
- data/docker/Dockerfile +1 -1
- data/docker/Dockerfile.slim +2 -2
- data/docker/chrome-driver/chrome.json +874 -0
- data/lib/bidi2pdf/bidi/browser_tab.rb +97 -4
- data/lib/bidi2pdf/bidi/buffered_web_socket_client.rb +178 -0
- data/lib/bidi2pdf/bidi/client.rb +12 -5
- data/lib/bidi2pdf/bidi/commands/base.rb +2 -0
- data/lib/bidi2pdf/bidi/commands/capture_screenshot.rb +33 -0
- data/lib/bidi2pdf/bidi/commands/set_viewport.rb +32 -0
- data/lib/bidi2pdf/bidi/commands.rb +2 -0
- data/lib/bidi2pdf/bidi/network_event.rb +12 -3
- data/lib/bidi2pdf/bidi/network_events.rb +9 -1
- data/lib/bidi2pdf/bidi/session.rb +1 -1
- data/lib/bidi2pdf/chromedriver_manager.rb +10 -6
- data/lib/bidi2pdf/cli.rb +11 -1
- data/lib/bidi2pdf/launcher.rb +5 -3
- data/lib/bidi2pdf/notifications/logging_subscriber.rb +2 -0
- data/lib/bidi2pdf/session_warmer.rb +377 -0
- data/lib/bidi2pdf/test_helpers/images.rb +8 -0
- data/lib/bidi2pdf/test_helpers/pdf_reader_utils.rb +1 -2
- data/lib/bidi2pdf/test_helpers/pdf_text_sanitizer.rb +1 -2
- data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rb +1 -1
- data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rb +22 -2
- data/lib/bidi2pdf/test_helpers/testcontainers/container_endpoint.rb +30 -0
- data/lib/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rb +33 -0
- data/lib/bidi2pdf/test_helpers/testcontainers.rb +1 -0
- data/lib/bidi2pdf/version.rb +1 -1
- data/lib/bidi2pdf.rb +26 -1
- data/sig/bidi2pdf/bidi/add_headers_interceptor.rbs +16 -9
- data/sig/bidi2pdf/bidi/auth_interceptor.rbs +32 -7
- data/sig/bidi2pdf/bidi/browser.rbs +4 -31
- data/sig/bidi2pdf/bidi/browser_console_logger.rbs +59 -0
- data/sig/bidi2pdf/bidi/browser_tab.rbs +269 -25
- data/sig/bidi2pdf/bidi/buffered_web_socket_client.rbs +81 -0
- data/sig/bidi2pdf/bidi/client.rbs +103 -43
- data/sig/bidi2pdf/bidi/command_manager.rbs +5 -17
- data/sig/bidi2pdf/bidi/commands/add_intercept.rbs +16 -8
- data/sig/bidi2pdf/bidi/commands/base.rbs +49 -9
- data/sig/bidi2pdf/bidi/commands/browser_close.rbs +3 -1
- data/sig/bidi2pdf/bidi/commands/browser_create_user_context.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/browser_remove_user_context.rbs +19 -0
- data/sig/bidi2pdf/bidi/commands/browsing_context_close.rbs +8 -2
- data/sig/bidi2pdf/bidi/commands/browsing_context_navigate.rbs +12 -6
- data/sig/bidi2pdf/bidi/commands/browsing_context_print.rbs +10 -5
- data/sig/bidi2pdf/bidi/commands/cancel_auth.rbs +8 -2
- data/sig/bidi2pdf/bidi/commands/capture_screenshot.rbs +31 -0
- data/sig/bidi2pdf/bidi/commands/cdp_get_session.rbs +17 -0
- data/sig/bidi2pdf/bidi/commands/create_window.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/get_user_contexts.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/network_continue.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/page_print.rbs +28 -0
- data/sig/bidi2pdf/bidi/commands/print_parameters_validator.rbs +3 -0
- data/sig/bidi2pdf/bidi/commands/provide_credentials.rbs +12 -6
- data/sig/bidi2pdf/bidi/commands/script_evaluate.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/session_end.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/session_status.rbs +3 -1
- data/sig/bidi2pdf/bidi/commands/session_subscribe.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/set_tab_cookie.rbs +51 -23
- data/sig/bidi2pdf/bidi/commands/set_usercontext_cookie.rbs +17 -19
- data/sig/bidi2pdf/bidi/commands/set_viewport.rbs +31 -0
- data/sig/bidi2pdf/bidi/connection_manager.rbs +2 -1
- data/sig/bidi2pdf/bidi/event_manager.rbs +14 -19
- data/sig/bidi2pdf/bidi/interceptor.rbs +5 -0
- data/sig/bidi2pdf/bidi/js_logger_helper.rbs +9 -0
- data/sig/bidi2pdf/bidi/logger_events.rbs +21 -0
- data/sig/bidi2pdf/bidi/navigation_failed_events.rbs +17 -0
- data/sig/bidi2pdf/bidi/network_event.rbs +64 -46
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_console_formatter.rbs +63 -0
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_formatter_utils.rbs +15 -0
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_html_formatter.rbs +18 -0
- data/sig/bidi2pdf/bidi/network_event_formatters.rbs +6 -0
- data/sig/bidi2pdf/bidi/network_events.rbs +14 -39
- data/sig/bidi2pdf/bidi/session.rbs +144 -31
- data/sig/bidi2pdf/bidi/user_context.rbs +64 -45
- data/sig/bidi2pdf/bidi/web_socket_dispatcher.rbs +22 -30
- data/sig/bidi2pdf/chromedriver_manager.rbs +61 -22
- data/sig/bidi2pdf/cli.rbs +22 -2
- data/sig/bidi2pdf/dsl.rbs +34 -0
- data/sig/bidi2pdf/launcher.rbs +39 -1
- data/sig/bidi2pdf/notifications/event.rbs +40 -0
- data/sig/bidi2pdf/notifications/instrumenter.rbs +21 -0
- data/sig/bidi2pdf/notifications/logging_subscriber.rbs +41 -0
- data/sig/bidi2pdf/notifications.rbs +24 -0
- data/sig/bidi2pdf/process_tree.rbs +2 -2
- data/sig/bidi2pdf/session_runner.rbs +41 -1
- data/sig/bidi2pdf/session_warmer.rbs +221 -0
- data/sig/bidi2pdf/test_helpers/configuration.rbs +51 -0
- data/sig/bidi2pdf/test_helpers/images/extractor.rbs +43 -0
- data/sig/bidi2pdf/test_helpers/images/image_similarity_checker.rbs +35 -0
- data/sig/bidi2pdf/test_helpers/images/tiff_helper.rbs +70 -0
- data/sig/bidi2pdf/test_helpers/images.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_image.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_text.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/have_pdf_page_count.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/match_pdf_text.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/pdf_file_helper.rbs +23 -0
- data/sig/bidi2pdf/test_helpers/pdf_reader_utils.rbs +49 -0
- data/sig/bidi2pdf/test_helpers/pdf_text_sanitizer.rbs +38 -0
- data/sig/bidi2pdf/test_helpers/spec_paths_helper.rbs +35 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rbs +43 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rbs +45 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/container_endpoint.rbs +25 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/shared_docker_network.rbs +3 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rbs +47 -0
- data/sig/bidi2pdf/test_helpers/testcontainers.rbs +6 -0
- data/sig/bidi2pdf/test_helpers.rbs +0 -0
- data/sig/bidi2pdf/verbose_logger.rbs +37 -0
- data/sig/bidi2pdf/version.rbs +3 -0
- data/sig/bidi2pdf.rbs +130 -2
- data/tasks/generate_rbs.rake +11 -11
- data/tasks/release_credentials_check.rake +97 -0
- metadata +67 -10
- data/sig/bidi2pdf/utils.rbs +0 -5
|
@@ -1,72 +1,132 @@
|
|
|
1
1
|
module Bidi2pdf
|
|
2
2
|
module Bidi
|
|
3
|
+
# Represents a WebSocket client for managing communication with a remote server
|
|
4
|
+
# using the Bidi2pdf library. This class handles the setup, connection, and
|
|
5
|
+
# communication with the WebSocket server, including sending commands and
|
|
6
|
+
# handling responses.
|
|
7
|
+
#
|
|
8
|
+
# @example Creating and starting a client
|
|
9
|
+
# client = Bidi2pdf::Bidi::Client.new("ws://example.com/socket")
|
|
10
|
+
# client.start
|
|
11
|
+
#
|
|
12
|
+
# @example Sending a command
|
|
13
|
+
# command = Bidi2pdf::Bidi::Commands::ScriptEvaluate.new context: browsing_context_id, expression: script
|
|
14
|
+
# client.send_cmd(command)
|
|
15
|
+
#
|
|
16
|
+
# @example Subscribing to events
|
|
17
|
+
# client.on_event("eventName") do |event_data|
|
|
18
|
+
# puts "Received event: #{event_data}"
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# @param [String] ws_url The WebSocket URL to connect to.
|
|
3
22
|
class Client
|
|
4
|
-
@next_id_mutex: Mutex
|
|
5
23
|
@ws_url: untyped
|
|
6
24
|
|
|
7
|
-
@id: untyped
|
|
8
|
-
|
|
9
|
-
@pending_responses: Hash[String, Thread::Queue]
|
|
10
|
-
|
|
11
|
-
@connected: untyped
|
|
12
|
-
|
|
13
|
-
@connection_mutex: Mutex
|
|
14
|
-
|
|
15
|
-
@send_cmd_mutex: Mutex
|
|
16
|
-
|
|
17
|
-
@connection_cv: untyped
|
|
18
|
-
|
|
19
25
|
@started: untyped
|
|
20
26
|
|
|
27
|
+
@connection_manager: untyped
|
|
28
|
+
|
|
21
29
|
@socket: untyped
|
|
22
30
|
|
|
23
31
|
@dispatcher: untyped
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
# @return [String] The WebSocket URL.
|
|
27
34
|
attr_reader ws_url: untyped
|
|
28
35
|
|
|
36
|
+
# Initializes a new WebSocket client.
|
|
37
|
+
#
|
|
38
|
+
# @param [String] ws_url The WebSocket URL to connect to.
|
|
29
39
|
def initialize: (untyped ws_url) -> void
|
|
30
40
|
|
|
41
|
+
# Starts the WebSocket client and establishes a connection.
|
|
42
|
+
#
|
|
43
|
+
# @return [BufferedWebSocketClient] The WebSocket connection object.
|
|
31
44
|
def start: () -> untyped
|
|
32
45
|
|
|
46
|
+
# Checks if the WebSocket client has started. Unlike #open?, this never flips back to false on
|
|
47
|
+
# its own if the connection dies externally - it only reflects whether #start has run.
|
|
48
|
+
#
|
|
49
|
+
# @return [Boolean] True if the client has started, false otherwise.
|
|
33
50
|
def started?: () -> untyped
|
|
34
51
|
|
|
52
|
+
# Checks if the underlying WebSocket connection is actually open right now - false before
|
|
53
|
+
# #start, after #close, or if the reader thread noticed the connection died on its own (a
|
|
54
|
+
# real liveness signal, not just an internal "did we ever start" flag).
|
|
55
|
+
#
|
|
56
|
+
# @return [Boolean] True if the underlying socket reports itself open.
|
|
57
|
+
def open?: () -> untyped
|
|
58
|
+
|
|
59
|
+
# Waits until the WebSocket connection is open.
|
|
60
|
+
#
|
|
61
|
+
# @param [Integer] timeout The timeout duration in seconds.
|
|
62
|
+
# @raise [Bidi2pdf::WebsocketError] If the connection is not established within the timeout.
|
|
35
63
|
def wait_until_open: (?timeout: untyped) -> untyped
|
|
36
64
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def
|
|
65
|
+
# Sends a command to the WebSocket server.
|
|
66
|
+
#
|
|
67
|
+
# @param [Bidi2pdf::Bidi::Commands::Base] cmd The command to send.
|
|
68
|
+
# @raise [Bidi2pdf::ClientError] If the client has not started.
|
|
69
|
+
def send_cmd: (untyped cmd) -> untyped
|
|
70
|
+
|
|
71
|
+
# Sends a command to the WebSocket server and waits for a response.
|
|
72
|
+
#
|
|
73
|
+
# @param [Object] cmd The command to send.
|
|
74
|
+
# @param [Integer] timeout The timeout duration in seconds.
|
|
75
|
+
# @yield [response] A block to handle the response.
|
|
76
|
+
# @raise [Bidi2pdf::ClientError] If the client has not started.
|
|
77
|
+
def send_cmd_and_wait: (untyped cmd, ?timeout: untyped) { (?) -> untyped } -> untyped
|
|
78
|
+
|
|
79
|
+
# Registers a callback for incoming WebSocket messages.
|
|
80
|
+
#
|
|
81
|
+
# @yield [message] A block to handle the incoming message.
|
|
82
|
+
def on_message: () { (?) -> untyped } -> untyped
|
|
83
|
+
|
|
84
|
+
# Registers a callback for when the WebSocket connection is opened.
|
|
85
|
+
#
|
|
86
|
+
# @yield A block to execute when the connection is opened.
|
|
87
|
+
def on_open: () { (?) -> untyped } -> untyped
|
|
88
|
+
|
|
89
|
+
# Registers a callback for when the WebSocket connection is closed.
|
|
90
|
+
#
|
|
91
|
+
# @yield A block to execute when the connection is closed.
|
|
92
|
+
def on_close: () { (?) -> untyped } -> untyped
|
|
93
|
+
|
|
94
|
+
# Registers a callback for WebSocket errors.
|
|
95
|
+
#
|
|
96
|
+
# @yield [error] A block to handle the error.
|
|
97
|
+
def on_error: () { (?) -> untyped } -> untyped
|
|
98
|
+
|
|
99
|
+
# Subscribes to specific WebSocket events.
|
|
100
|
+
#
|
|
101
|
+
# @param [Array<String>] names The names of the events to subscribe to.
|
|
102
|
+
# @yield [event_data] A block to handle the event data.
|
|
103
|
+
def on_event: (*untyped names) { (?) -> untyped } -> untyped
|
|
104
|
+
|
|
105
|
+
# Removes a message listener.
|
|
106
|
+
#
|
|
107
|
+
# @param [Proc] block The listener block to remove.
|
|
108
|
+
def remove_message_listener: (untyped listener) -> untyped
|
|
109
|
+
|
|
110
|
+
# Removes event listeners for specific events.
|
|
111
|
+
#
|
|
112
|
+
# @param [Array<String>] names The names of the events to unsubscribe from.
|
|
113
|
+
# @param [Proc] block The listener block to remove.
|
|
114
|
+
def remove_event_listener: (*untyped names, untyped listener) -> untyped
|
|
115
|
+
|
|
116
|
+
# Closes the WebSocket connection.
|
|
117
|
+
def close: () -> (nil | untyped)
|
|
60
118
|
|
|
61
119
|
private
|
|
62
120
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
121
|
+
# Returns the WebSocket dispatcher for managing events and messages.
|
|
122
|
+
#
|
|
123
|
+
# @return [WebSocketDispatcher] The dispatcher instance.
|
|
124
|
+
def dispatcher: () -> untyped
|
|
66
125
|
|
|
126
|
+
# Handles responses to commands sent to the WebSocket server.
|
|
127
|
+
#
|
|
128
|
+
# @param [Hash] data The response data.
|
|
67
129
|
def handle_response_to_cmd: (untyped data) -> untyped
|
|
68
|
-
|
|
69
|
-
def redact_sensitive_fields: (untyped obj, ?::Array[untyped] sensitive_keys) -> untyped
|
|
70
130
|
end
|
|
71
131
|
end
|
|
72
132
|
end
|
|
@@ -3,39 +3,27 @@ module Bidi2pdf
|
|
|
3
3
|
class CommandManager
|
|
4
4
|
self.@id: untyped
|
|
5
5
|
|
|
6
|
-
self.@id_mutex: untyped
|
|
7
|
-
|
|
8
6
|
@socket: untyped
|
|
9
7
|
|
|
10
|
-
@logger: untyped
|
|
11
|
-
|
|
12
8
|
@pending_responses: untyped
|
|
13
9
|
|
|
14
|
-
@initiated_cmds: untyped
|
|
15
|
-
|
|
16
10
|
def self.initialize_counter: () -> untyped
|
|
17
11
|
|
|
18
12
|
def self.next_id: () -> untyped
|
|
19
13
|
|
|
20
|
-
def initialize: (untyped socket
|
|
14
|
+
def initialize: (untyped socket) -> void
|
|
21
15
|
|
|
22
|
-
def send_cmd: (untyped cmd, ?
|
|
16
|
+
def send_cmd: (untyped cmd, ?result_queue: untyped?) -> untyped
|
|
23
17
|
|
|
24
|
-
def send_cmd_and_wait: (untyped cmd, ?timeout: untyped)
|
|
18
|
+
def send_cmd_and_wait: (untyped cmd, ?timeout: untyped) { (?) -> untyped } -> untyped
|
|
25
19
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
def handle_response: (untyped data) -> (true | untyped | false)
|
|
20
|
+
def handle_response: (untyped data) -> untyped
|
|
29
21
|
|
|
30
22
|
private
|
|
31
23
|
|
|
32
|
-
def init_queue_for: (untyped id) -> untyped
|
|
24
|
+
def init_queue_for: (untyped id, untyped result_queue) -> untyped
|
|
33
25
|
|
|
34
26
|
def next_id: () -> untyped
|
|
35
|
-
|
|
36
|
-
def redact_sensitive_fields: (untyped obj, ?::Array[untyped] sensitive_keys) -> untyped
|
|
37
|
-
|
|
38
|
-
def raise_timeout_error: (untyped id, untyped cmd) -> untyped
|
|
39
27
|
end
|
|
40
28
|
end
|
|
41
29
|
end
|
|
@@ -2,19 +2,27 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class AddIntercept
|
|
5
|
+
@context: untyped
|
|
6
|
+
|
|
7
|
+
@phases: untyped
|
|
8
|
+
|
|
9
|
+
@url_patterns: untyped
|
|
10
|
+
|
|
5
11
|
include Base
|
|
6
12
|
|
|
7
|
-
BEFORE_REQUEST:
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
BEFORE_REQUEST: "beforeRequestSent"
|
|
14
|
+
|
|
15
|
+
RESPONSE_STARTED: "responseStarted"
|
|
16
|
+
|
|
17
|
+
AUTH_REQUIRED: "authRequired"
|
|
18
|
+
|
|
19
|
+
def initialize: (context: untyped, phases: untyped, url_patterns: untyped) -> void
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
@phases: Array[String]
|
|
13
|
-
@url_patterns: Array[String]
|
|
21
|
+
def method_name: () -> "network.addIntercept"
|
|
14
22
|
|
|
15
|
-
def
|
|
23
|
+
def params: () -> untyped
|
|
16
24
|
|
|
17
|
-
def validate_phases!: () ->
|
|
25
|
+
def validate_phases!: () -> untyped
|
|
18
26
|
end
|
|
19
27
|
end
|
|
20
28
|
end
|
|
@@ -1,26 +1,66 @@
|
|
|
1
1
|
module Bidi2pdf
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
|
+
# Base module for defining WebSocket commands in the Bidi2pdf library.
|
|
5
|
+
# This module provides common functionality for creating, comparing, and
|
|
6
|
+
# inspecting WebSocket command payloads.
|
|
4
7
|
module Base
|
|
5
|
-
|
|
8
|
+
# Abstract method that must be implemented in subclasses to define the
|
|
9
|
+
# WebSocket command method name.
|
|
10
|
+
#
|
|
11
|
+
# @raise [NotImplementedError] If the method is not implemented in a subclass.
|
|
12
|
+
def method_name: () -> untyped
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
# Returns the parameters for the WebSocket command.
|
|
15
|
+
#
|
|
16
|
+
# @return [Hash] The parameters for the command. Defaults to an empty hash.
|
|
17
|
+
def params: () -> ::Hash[untyped, untyped]
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
# Constructs the payload for the WebSocket command.
|
|
20
|
+
#
|
|
21
|
+
# @param [Integer] id The unique identifier for the command.
|
|
22
|
+
# @return [Hash] The payload containing the command ID, method name, and parameters.
|
|
23
|
+
def as_payload: (untyped id) -> { id: untyped, method: untyped, params: untyped }
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
# Compares the current command with another command for equality.
|
|
26
|
+
#
|
|
27
|
+
# @param [Object] other The other command to compare.
|
|
28
|
+
# @return [Boolean] True if the commands are equal, false otherwise.
|
|
29
|
+
# rubocop: disable Metrics/AbcSize
|
|
30
|
+
def ==: (untyped other) -> (false | untyped)
|
|
12
31
|
|
|
13
|
-
|
|
32
|
+
# Checks if the current command is hash-equal to another command.
|
|
33
|
+
#
|
|
34
|
+
# @param [Object] other The other command to compare.
|
|
35
|
+
# @return [Boolean] True if the commands are hash-equal, false otherwise.
|
|
36
|
+
def eql?: (untyped other) -> (false | untyped)
|
|
14
37
|
|
|
15
|
-
|
|
38
|
+
# Computes the hash value for the command.
|
|
39
|
+
#
|
|
40
|
+
# @return [Integer] The hash value based on the method name and parameters.
|
|
41
|
+
def hash: () -> untyped
|
|
16
42
|
|
|
17
|
-
|
|
43
|
+
# Returns a string representation of the command, with sensitive fields redacted.
|
|
44
|
+
#
|
|
45
|
+
# @return [String] The string representation of the command.
|
|
46
|
+
def inspect: () -> ::String
|
|
18
47
|
|
|
19
48
|
private
|
|
20
49
|
|
|
21
|
-
|
|
50
|
+
# Redacts sensitive fields in a given object.
|
|
51
|
+
#
|
|
52
|
+
# @param [Object] obj The object to redact.
|
|
53
|
+
# @param [Array<String>] sensitive_keys The list of sensitive keys to redact. Defaults to common sensitive keys.
|
|
54
|
+
# @return [Object] The object with sensitive fields redacted.
|
|
55
|
+
def redact_sensitive_fields: (untyped obj, ?::Array[untyped] sensitive_keys) -> untyped
|
|
22
56
|
|
|
23
|
-
|
|
57
|
+
# Logs and raises a timeout error for a command.
|
|
58
|
+
#
|
|
59
|
+
# @param [Integer] id The unique identifier for the command.
|
|
60
|
+
# @param [String] method The method name of the command.
|
|
61
|
+
# @param [Hash] params The parameters of the command.
|
|
62
|
+
# @raise [CmdTimeoutError] If the command times out.
|
|
63
|
+
def raise_timeout_error: (untyped id, untyped method, untyped params) -> untyped
|
|
24
64
|
end
|
|
25
65
|
end
|
|
26
66
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Bidi2pdf
|
|
2
|
+
module Bidi
|
|
3
|
+
module Commands
|
|
4
|
+
class BrowserRemoveUserContext
|
|
5
|
+
@user_context_id: untyped
|
|
6
|
+
|
|
7
|
+
include Base
|
|
8
|
+
|
|
9
|
+
attr_reader user_context_id: untyped
|
|
10
|
+
|
|
11
|
+
def initialize: (?user_context_id: untyped?) -> void
|
|
12
|
+
|
|
13
|
+
def params: () -> untyped
|
|
14
|
+
|
|
15
|
+
def method_name: () -> "browser.removeUserContext"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -2,9 +2,15 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class BrowsingContextClose
|
|
5
|
-
|
|
5
|
+
@context: untyped
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
include Base
|
|
8
|
+
|
|
9
|
+
def initialize: (context: untyped) -> void
|
|
10
|
+
|
|
11
|
+
def params: () -> { context: untyped }
|
|
12
|
+
|
|
13
|
+
def method_name: () -> "browsingContext.close"
|
|
8
14
|
end
|
|
9
15
|
end
|
|
10
16
|
end
|
|
@@ -2,13 +2,19 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class BrowsingContextNavigate
|
|
5
|
-
|
|
5
|
+
@url: untyped
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
@context: untyped
|
|
8
|
+
|
|
9
|
+
@wait: untyped
|
|
10
|
+
|
|
11
|
+
include Base
|
|
12
|
+
|
|
13
|
+
def initialize: (url: untyped, context: untyped, ?wait: ::String) -> void
|
|
14
|
+
|
|
15
|
+
def params: () -> { url: untyped, context: untyped, wait: untyped }
|
|
16
|
+
|
|
17
|
+
def method_name: () -> "browsingContext.navigate"
|
|
12
18
|
end
|
|
13
19
|
end
|
|
14
20
|
end
|
|
@@ -2,12 +2,17 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class BrowsingContextPrint
|
|
5
|
-
|
|
5
|
+
@context: untyped
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
@print_options: untyped
|
|
8
|
+
|
|
9
|
+
include Base
|
|
10
|
+
|
|
11
|
+
def initialize: (context: untyped, print_options: untyped) -> void
|
|
12
|
+
|
|
13
|
+
def params: () -> untyped
|
|
14
|
+
|
|
15
|
+
def method_name: () -> "browsingContext.print"
|
|
11
16
|
end
|
|
12
17
|
end
|
|
13
18
|
end
|
|
@@ -2,9 +2,15 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class CancelAuth
|
|
5
|
-
|
|
5
|
+
@request: untyped
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
include Base
|
|
8
|
+
|
|
9
|
+
def initialize: (request: untyped) -> void
|
|
10
|
+
|
|
11
|
+
def params: () -> { request: untyped, action: "cancel" }
|
|
12
|
+
|
|
13
|
+
def method_name: () -> "network.continueWithAuth"
|
|
8
14
|
end
|
|
9
15
|
end
|
|
10
16
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Bidi2pdf
|
|
2
|
+
module Bidi
|
|
3
|
+
module Commands
|
|
4
|
+
class CaptureScreenshot
|
|
5
|
+
@context: untyped
|
|
6
|
+
|
|
7
|
+
@origin: untyped
|
|
8
|
+
|
|
9
|
+
@format: untyped
|
|
10
|
+
|
|
11
|
+
@clip: untyped
|
|
12
|
+
|
|
13
|
+
include Base
|
|
14
|
+
|
|
15
|
+
attr_reader context: untyped
|
|
16
|
+
|
|
17
|
+
attr_reader origin: untyped
|
|
18
|
+
|
|
19
|
+
attr_reader format: untyped
|
|
20
|
+
|
|
21
|
+
attr_reader clip: untyped
|
|
22
|
+
|
|
23
|
+
def initialize: (context: untyped, ?origin: ::String, ?format: untyped?, ?clip: untyped?) -> void
|
|
24
|
+
|
|
25
|
+
def method_name: () -> "browsingContext.captureScreenshot"
|
|
26
|
+
|
|
27
|
+
def params: () -> untyped
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Bidi2pdf
|
|
2
|
+
module Bidi
|
|
3
|
+
module Commands
|
|
4
|
+
class CdpGetSession
|
|
5
|
+
@context: untyped
|
|
6
|
+
|
|
7
|
+
include Base
|
|
8
|
+
|
|
9
|
+
def initialize: (context: untyped) -> void
|
|
10
|
+
|
|
11
|
+
def params: () -> { context: untyped }
|
|
12
|
+
|
|
13
|
+
def method_name: () -> "goog:cdp.getSession"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Bidi2pdf
|
|
2
|
+
module Bidi
|
|
3
|
+
module Commands
|
|
4
|
+
class PagePrint
|
|
5
|
+
@cdp_session: untyped
|
|
6
|
+
|
|
7
|
+
@print_options: untyped
|
|
8
|
+
|
|
9
|
+
include Base
|
|
10
|
+
|
|
11
|
+
def initialize: (cdp_session: untyped, print_options: untyped) -> void
|
|
12
|
+
|
|
13
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
14
|
+
def params: () -> { method: "Page.printToPDF", session: untyped, params: untyped }
|
|
15
|
+
|
|
16
|
+
def method_name: () -> "goog:cdp.sendCommand"
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# rubocop:disable Naming/MethodParameterName
|
|
21
|
+
def cm_to_inch: (untyped cm) -> (nil | untyped)
|
|
22
|
+
|
|
23
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
24
|
+
def page_ranges_to_string: (untyped input) -> (nil | untyped)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -15,6 +15,7 @@ module Bidi2pdf
|
|
|
15
15
|
# },
|
|
16
16
|
# orientation: "portrait" or "landscape" (optional, default: "portrait"),
|
|
17
17
|
# page: {
|
|
18
|
+
# format: String (optional, use either format or width/height),
|
|
18
19
|
# width: Float >= 0.0352 (optional, default: 21.59),
|
|
19
20
|
# height: Float >= 0.0352 (optional, default: 27.94)
|
|
20
21
|
# },
|
|
@@ -32,6 +33,7 @@ module Bidi2pdf
|
|
|
32
33
|
|
|
33
34
|
def initialize: (untyped params) -> void
|
|
34
35
|
|
|
36
|
+
# rubocop:disable Naming/PredicateMethod
|
|
35
37
|
def validate!: () -> true
|
|
36
38
|
|
|
37
39
|
private
|
|
@@ -46,6 +48,7 @@ module Bidi2pdf
|
|
|
46
48
|
|
|
47
49
|
def validate_margin: () -> (nil | untyped)
|
|
48
50
|
|
|
51
|
+
# rubocop: disable Metrics/CyclomaticComplexity
|
|
49
52
|
def validate_page_size: () -> (nil | untyped)
|
|
50
53
|
end
|
|
51
54
|
end
|
|
@@ -2,13 +2,19 @@ module Bidi2pdf
|
|
|
2
2
|
module Bidi
|
|
3
3
|
module Commands
|
|
4
4
|
class ProvideCredentials
|
|
5
|
-
|
|
5
|
+
@request: untyped
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
@username: untyped
|
|
8
|
+
|
|
9
|
+
@password: untyped
|
|
10
|
+
|
|
11
|
+
include Base
|
|
12
|
+
|
|
13
|
+
def initialize: (request: untyped, username: untyped, password: untyped) -> void
|
|
14
|
+
|
|
15
|
+
def params: () -> { request: untyped, action: "provideCredentials", credentials: { type: "password", username: untyped, password: untyped } }
|
|
16
|
+
|
|
17
|
+
def method_name: () -> "network.continueWithAuth"
|
|
12
18
|
end
|
|
13
19
|
end
|
|
14
20
|
end
|
|
@@ -11,6 +11,10 @@ module Bidi2pdf
|
|
|
11
11
|
include Base
|
|
12
12
|
|
|
13
13
|
def initialize: (expression: untyped, context: untyped, ?await_promise: bool) -> void
|
|
14
|
+
|
|
15
|
+
def params: () -> { expression: untyped, target: { context: untyped }, awaitPromise: untyped }
|
|
16
|
+
|
|
17
|
+
def method_name: () -> "script.evaluate"
|
|
14
18
|
end
|
|
15
19
|
end
|
|
16
20
|
end
|