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.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +53 -0
  3. data/.devcontainer/devcontainer.json +51 -0
  4. data/.devcontainer/docker-compose.yml +33 -0
  5. data/.ruby-gemset +1 -1
  6. data/.ruby-version +1 -1
  7. data/CHANGELOG.md +93 -6
  8. data/README.md +80 -5
  9. data/docker/Dockerfile +1 -1
  10. data/docker/Dockerfile.slim +2 -2
  11. data/docker/chrome-driver/chrome.json +874 -0
  12. data/lib/bidi2pdf/bidi/browser_tab.rb +97 -4
  13. data/lib/bidi2pdf/bidi/buffered_web_socket_client.rb +178 -0
  14. data/lib/bidi2pdf/bidi/client.rb +12 -5
  15. data/lib/bidi2pdf/bidi/commands/base.rb +2 -0
  16. data/lib/bidi2pdf/bidi/commands/capture_screenshot.rb +33 -0
  17. data/lib/bidi2pdf/bidi/commands/set_viewport.rb +32 -0
  18. data/lib/bidi2pdf/bidi/commands.rb +2 -0
  19. data/lib/bidi2pdf/bidi/network_event.rb +12 -3
  20. data/lib/bidi2pdf/bidi/network_events.rb +9 -1
  21. data/lib/bidi2pdf/bidi/session.rb +1 -1
  22. data/lib/bidi2pdf/chromedriver_manager.rb +10 -6
  23. data/lib/bidi2pdf/cli.rb +11 -1
  24. data/lib/bidi2pdf/launcher.rb +5 -3
  25. data/lib/bidi2pdf/notifications/logging_subscriber.rb +2 -0
  26. data/lib/bidi2pdf/session_warmer.rb +377 -0
  27. data/lib/bidi2pdf/test_helpers/images.rb +8 -0
  28. data/lib/bidi2pdf/test_helpers/pdf_reader_utils.rb +1 -2
  29. data/lib/bidi2pdf/test_helpers/pdf_text_sanitizer.rb +1 -2
  30. data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rb +1 -1
  31. data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rb +22 -2
  32. data/lib/bidi2pdf/test_helpers/testcontainers/container_endpoint.rb +30 -0
  33. data/lib/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rb +33 -0
  34. data/lib/bidi2pdf/test_helpers/testcontainers.rb +1 -0
  35. data/lib/bidi2pdf/version.rb +1 -1
  36. data/lib/bidi2pdf.rb +26 -1
  37. data/sig/bidi2pdf/bidi/add_headers_interceptor.rbs +16 -9
  38. data/sig/bidi2pdf/bidi/auth_interceptor.rbs +32 -7
  39. data/sig/bidi2pdf/bidi/browser.rbs +4 -31
  40. data/sig/bidi2pdf/bidi/browser_console_logger.rbs +59 -0
  41. data/sig/bidi2pdf/bidi/browser_tab.rbs +269 -25
  42. data/sig/bidi2pdf/bidi/buffered_web_socket_client.rbs +81 -0
  43. data/sig/bidi2pdf/bidi/client.rbs +103 -43
  44. data/sig/bidi2pdf/bidi/command_manager.rbs +5 -17
  45. data/sig/bidi2pdf/bidi/commands/add_intercept.rbs +16 -8
  46. data/sig/bidi2pdf/bidi/commands/base.rbs +49 -9
  47. data/sig/bidi2pdf/bidi/commands/browser_close.rbs +3 -1
  48. data/sig/bidi2pdf/bidi/commands/browser_create_user_context.rbs +2 -0
  49. data/sig/bidi2pdf/bidi/commands/browser_remove_user_context.rbs +19 -0
  50. data/sig/bidi2pdf/bidi/commands/browsing_context_close.rbs +8 -2
  51. data/sig/bidi2pdf/bidi/commands/browsing_context_navigate.rbs +12 -6
  52. data/sig/bidi2pdf/bidi/commands/browsing_context_print.rbs +10 -5
  53. data/sig/bidi2pdf/bidi/commands/cancel_auth.rbs +8 -2
  54. data/sig/bidi2pdf/bidi/commands/capture_screenshot.rbs +31 -0
  55. data/sig/bidi2pdf/bidi/commands/cdp_get_session.rbs +17 -0
  56. data/sig/bidi2pdf/bidi/commands/create_window.rbs +4 -0
  57. data/sig/bidi2pdf/bidi/commands/get_user_contexts.rbs +2 -0
  58. data/sig/bidi2pdf/bidi/commands/network_continue.rbs +4 -0
  59. data/sig/bidi2pdf/bidi/commands/page_print.rbs +28 -0
  60. data/sig/bidi2pdf/bidi/commands/print_parameters_validator.rbs +3 -0
  61. data/sig/bidi2pdf/bidi/commands/provide_credentials.rbs +12 -6
  62. data/sig/bidi2pdf/bidi/commands/script_evaluate.rbs +4 -0
  63. data/sig/bidi2pdf/bidi/commands/session_end.rbs +2 -0
  64. data/sig/bidi2pdf/bidi/commands/session_status.rbs +3 -1
  65. data/sig/bidi2pdf/bidi/commands/session_subscribe.rbs +4 -0
  66. data/sig/bidi2pdf/bidi/commands/set_tab_cookie.rbs +51 -23
  67. data/sig/bidi2pdf/bidi/commands/set_usercontext_cookie.rbs +17 -19
  68. data/sig/bidi2pdf/bidi/commands/set_viewport.rbs +31 -0
  69. data/sig/bidi2pdf/bidi/connection_manager.rbs +2 -1
  70. data/sig/bidi2pdf/bidi/event_manager.rbs +14 -19
  71. data/sig/bidi2pdf/bidi/interceptor.rbs +5 -0
  72. data/sig/bidi2pdf/bidi/js_logger_helper.rbs +9 -0
  73. data/sig/bidi2pdf/bidi/logger_events.rbs +21 -0
  74. data/sig/bidi2pdf/bidi/navigation_failed_events.rbs +17 -0
  75. data/sig/bidi2pdf/bidi/network_event.rbs +64 -46
  76. data/sig/bidi2pdf/bidi/network_event_formatters/network_event_console_formatter.rbs +63 -0
  77. data/sig/bidi2pdf/bidi/network_event_formatters/network_event_formatter_utils.rbs +15 -0
  78. data/sig/bidi2pdf/bidi/network_event_formatters/network_event_html_formatter.rbs +18 -0
  79. data/sig/bidi2pdf/bidi/network_event_formatters.rbs +6 -0
  80. data/sig/bidi2pdf/bidi/network_events.rbs +14 -39
  81. data/sig/bidi2pdf/bidi/session.rbs +144 -31
  82. data/sig/bidi2pdf/bidi/user_context.rbs +64 -45
  83. data/sig/bidi2pdf/bidi/web_socket_dispatcher.rbs +22 -30
  84. data/sig/bidi2pdf/chromedriver_manager.rbs +61 -22
  85. data/sig/bidi2pdf/cli.rbs +22 -2
  86. data/sig/bidi2pdf/dsl.rbs +34 -0
  87. data/sig/bidi2pdf/launcher.rbs +39 -1
  88. data/sig/bidi2pdf/notifications/event.rbs +40 -0
  89. data/sig/bidi2pdf/notifications/instrumenter.rbs +21 -0
  90. data/sig/bidi2pdf/notifications/logging_subscriber.rbs +41 -0
  91. data/sig/bidi2pdf/notifications.rbs +24 -0
  92. data/sig/bidi2pdf/process_tree.rbs +2 -2
  93. data/sig/bidi2pdf/session_runner.rbs +41 -1
  94. data/sig/bidi2pdf/session_warmer.rbs +221 -0
  95. data/sig/bidi2pdf/test_helpers/configuration.rbs +51 -0
  96. data/sig/bidi2pdf/test_helpers/images/extractor.rbs +43 -0
  97. data/sig/bidi2pdf/test_helpers/images/image_similarity_checker.rbs +35 -0
  98. data/sig/bidi2pdf/test_helpers/images/tiff_helper.rbs +70 -0
  99. data/sig/bidi2pdf/test_helpers/images.rbs +0 -0
  100. data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_image.rbs +0 -0
  101. data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_text.rbs +0 -0
  102. data/sig/bidi2pdf/test_helpers/matchers/have_pdf_page_count.rbs +0 -0
  103. data/sig/bidi2pdf/test_helpers/matchers/match_pdf_text.rbs +0 -0
  104. data/sig/bidi2pdf/test_helpers/pdf_file_helper.rbs +23 -0
  105. data/sig/bidi2pdf/test_helpers/pdf_reader_utils.rbs +49 -0
  106. data/sig/bidi2pdf/test_helpers/pdf_text_sanitizer.rbs +38 -0
  107. data/sig/bidi2pdf/test_helpers/spec_paths_helper.rbs +35 -0
  108. data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rbs +43 -0
  109. data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rbs +45 -0
  110. data/sig/bidi2pdf/test_helpers/testcontainers/container_endpoint.rbs +25 -0
  111. data/sig/bidi2pdf/test_helpers/testcontainers/shared_docker_network.rbs +3 -0
  112. data/sig/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rbs +47 -0
  113. data/sig/bidi2pdf/test_helpers/testcontainers.rbs +6 -0
  114. data/sig/bidi2pdf/test_helpers.rbs +0 -0
  115. data/sig/bidi2pdf/verbose_logger.rbs +37 -0
  116. data/sig/bidi2pdf/version.rbs +3 -0
  117. data/sig/bidi2pdf.rbs +130 -2
  118. data/tasks/generate_rbs.rake +11 -11
  119. data/tasks/release_credentials_check.rake +97 -0
  120. metadata +67 -10
  121. 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
- include Bidi2pdf::Utils
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
- def send_cmd: (Bidi2pdf::Bidi::Commands::Base cmd) -> untyped
38
-
39
- # rubocop:disable Metrics/AbcSize
40
- def send_cmd_and_wait: (untyped method, ?::Hash[untyped, untyped] params, ?timeout: untyped) ?{ (untyped) -> untyped } -> untyped
41
-
42
- # Event API for external consumers
43
- def on_message: () { () -> untyped } -> untyped
44
-
45
- def on_open: () { () -> untyped } -> untyped
46
-
47
- def on_close: () { () -> untyped } -> untyped
48
-
49
- def on_error: () { () -> untyped } -> untyped
50
-
51
- def on_event: (*untyped names) { () -> untyped } -> untyped
52
-
53
- def remove_message_listener: (untyped block) -> untyped
54
-
55
- def remove_event_listener: (*untyped names) { () -> untyped } -> untyped
56
-
57
- def add_headers_interceptor: (context: untyped, url_patterns: untyped, headers: untyped) -> untyped
58
-
59
- def add_auth_interceptor: (context: untyped, url_patterns: untyped, username: untyped, password: untyped) -> untyped
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
- def next_id: () -> untyped
64
-
65
- def handle_open: () -> untyped
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, logger: untyped) -> void
14
+ def initialize: (untyped socket) -> void
21
15
 
22
- def send_cmd: (untyped cmd, ?store_response: bool) -> untyped
16
+ def send_cmd: (untyped cmd, ?result_queue: untyped?) -> untyped
23
17
 
24
- def send_cmd_and_wait: (untyped cmd, ?timeout: untyped) ?{ (untyped) -> untyped } -> untyped
18
+ def send_cmd_and_wait: (untyped cmd, ?timeout: untyped) { (?) -> untyped } -> untyped
25
19
 
26
- def pop_response: (untyped id, timeout: untyped) -> untyped
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: String
8
- RESPONSE_STARTED: String
9
- AUTH_REQUIRED: String
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
- @context: String
12
- @phases: Array[String]
13
- @url_patterns: Array[String]
21
+ def method_name: () -> "network.addIntercept"
14
22
 
15
- def initialize: (context: String, phases: Array[String], url_patterns: Array[String]) -> void
23
+ def params: () -> untyped
16
24
 
17
- def validate_phases!: () -> void
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
- def method_name: () -> String
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
- def params: () -> Hash[Symbol, untyped]
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
- def as_payload: (untyped id) -> Hash[Symbol, untyped]
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
- def ==: (untyped other) -> bool
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
- def eql?: (untyped other) -> bool
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
- def hash: () -> Integer
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
- def inspect: () -> String
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
- def redact_sensitive_fields: (untyped obj, Array[String] sensitive_keys) -> untyped
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
- def raise_timeout_error: (untyped id, String method, Hash[Symbol, untyped] params) -> void
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
@@ -2,7 +2,9 @@ module Bidi2pdf
2
2
  module Bidi
3
3
  module Commands
4
4
  class BrowserClose
5
- include Commands::Base
5
+ include Base
6
+
7
+ def method_name: () -> "browser.close"
6
8
  end
7
9
  end
8
10
  end
@@ -3,6 +3,8 @@ module Bidi2pdf
3
3
  module Commands
4
4
  class BrowserCreateUserContext
5
5
  include Base
6
+
7
+ def method_name: () -> "browser.createUserContext"
6
8
  end
7
9
  end
8
10
  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
- include Commands::Base
5
+ @context: untyped
6
6
 
7
- def initialize: (context: String) -> void
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
- include Commands::Base
5
+ @url: untyped
6
6
 
7
- def initialize: (
8
- url: String,
9
- context: String,
10
- ?wait: String
11
- ) -> void
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
- include Commands::Base
5
+ @context: untyped
6
6
 
7
- def initialize: (
8
- context: String,
9
- print_options: Hash[Symbol, untyped]?
10
- ) -> void
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
- include Commands::Base
5
+ @request: untyped
6
6
 
7
- def initialize: (request: String) -> void
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
@@ -12,6 +12,10 @@ module Bidi2pdf
12
12
 
13
13
  def initialize: (?user_context_id: untyped?, ?reference_context: untyped?, ?background: bool) -> void
14
14
 
15
+ def method_name: () -> "browsingContext.create"
16
+
17
+ def params: () -> untyped
18
+
15
19
  def type: () -> "window"
16
20
  end
17
21
  end
@@ -3,6 +3,8 @@ module Bidi2pdf
3
3
  module Commands
4
4
  class GetUserContexts
5
5
  include Base
6
+
7
+ def method_name: () -> "browser.getUserContexts"
6
8
  end
7
9
  end
8
10
  end
@@ -13,6 +13,10 @@ module Bidi2pdf
13
13
  attr_reader headers: untyped
14
14
 
15
15
  def initialize: (request: untyped, headers: untyped) -> void
16
+
17
+ def method_name: () -> "network.continueRequest"
18
+
19
+ def params: () -> untyped
16
20
  end
17
21
  end
18
22
  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
- include Commands::Base
5
+ @request: untyped
6
6
 
7
- def initialize: (
8
- request: String,
9
- username: String,
10
- password: String
11
- ) -> void
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
@@ -3,6 +3,8 @@ module Bidi2pdf
3
3
  module Commands
4
4
  class SessionEnd
5
5
  include Base
6
+
7
+ def method_name: () -> "session.end"
6
8
  end
7
9
  end
8
10
  end
@@ -2,7 +2,9 @@ module Bidi2pdf
2
2
  module Bidi
3
3
  module Commands
4
4
  class SessionStatus
5
- include Commands::Base
5
+ include Base
6
+
7
+ def method_name: () -> "session.status"
6
8
  end
7
9
  end
8
10
  end