puppeteer-bidi 0.0.1.beta10 → 0.0.1

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +44 -0
  3. data/API_COVERAGE.md +345 -0
  4. data/CLAUDE/porting_puppeteer.md +20 -0
  5. data/CLAUDE.md +2 -1
  6. data/DEVELOPMENT.md +14 -0
  7. data/README.md +47 -415
  8. data/development/generate_api_coverage.rb +411 -0
  9. data/development/puppeteer_revision.txt +1 -0
  10. data/lib/puppeteer/bidi/browser.rb +118 -22
  11. data/lib/puppeteer/bidi/browser_context.rb +185 -2
  12. data/lib/puppeteer/bidi/connection.rb +16 -5
  13. data/lib/puppeteer/bidi/cookie_utils.rb +192 -0
  14. data/lib/puppeteer/bidi/core/browsing_context.rb +83 -40
  15. data/lib/puppeteer/bidi/core/realm.rb +6 -0
  16. data/lib/puppeteer/bidi/core/request.rb +79 -35
  17. data/lib/puppeteer/bidi/core/user_context.rb +5 -3
  18. data/lib/puppeteer/bidi/element_handle.rb +200 -8
  19. data/lib/puppeteer/bidi/errors.rb +4 -0
  20. data/lib/puppeteer/bidi/frame.rb +115 -11
  21. data/lib/puppeteer/bidi/http_request.rb +577 -0
  22. data/lib/puppeteer/bidi/http_response.rb +161 -10
  23. data/lib/puppeteer/bidi/locator.rb +792 -0
  24. data/lib/puppeteer/bidi/page.rb +859 -7
  25. data/lib/puppeteer/bidi/query_handler.rb +1 -1
  26. data/lib/puppeteer/bidi/version.rb +1 -1
  27. data/lib/puppeteer/bidi.rb +39 -6
  28. data/sig/puppeteer/bidi/browser.rbs +53 -6
  29. data/sig/puppeteer/bidi/browser_context.rbs +36 -0
  30. data/sig/puppeteer/bidi/cookie_utils.rbs +64 -0
  31. data/sig/puppeteer/bidi/core/browsing_context.rbs +16 -6
  32. data/sig/puppeteer/bidi/core/request.rbs +14 -11
  33. data/sig/puppeteer/bidi/core/user_context.rbs +2 -2
  34. data/sig/puppeteer/bidi/element_handle.rbs +28 -0
  35. data/sig/puppeteer/bidi/errors.rbs +4 -0
  36. data/sig/puppeteer/bidi/frame.rbs +17 -0
  37. data/sig/puppeteer/bidi/http_request.rbs +162 -0
  38. data/sig/puppeteer/bidi/http_response.rbs +67 -8
  39. data/sig/puppeteer/bidi/locator.rbs +267 -0
  40. data/sig/puppeteer/bidi/page.rbs +170 -0
  41. data/sig/puppeteer/bidi.rbs +15 -3
  42. metadata +12 -1
@@ -0,0 +1,162 @@
1
+ # Generated from lib/puppeteer/bidi/http_request.rb with RBS::Inline
2
+
3
+ module Puppeteer
4
+ module Bidi
5
+ # HTTPRequest represents a request initiated by a page.
6
+ class HTTPRequest
7
+ module InterceptResolutionAction
8
+ ABORT: ::String
9
+
10
+ RESPOND: ::String
11
+
12
+ CONTINUE: ::String
13
+
14
+ DISABLED: ::String
15
+
16
+ NONE: ::String
17
+
18
+ ALREADY_HANDLED: ::String
19
+ end
20
+
21
+ DEFAULT_INTERCEPT_RESOLUTION_PRIORITY: ::Integer
22
+
23
+ STATUS_TEXTS: untyped
24
+
25
+ ERROR_REASONS: untyped
26
+
27
+ REQUESTS: untyped
28
+
29
+ # @rbs core_request: Core::Request -- Underlying BiDi request
30
+ # @rbs frame: Frame -- Owning frame
31
+ # @rbs interception_enabled: bool -- Whether interception is enabled
32
+ # @rbs redirect: HTTPRequest? -- Redirected request
33
+ # @rbs return: HTTPRequest
34
+ def self.from: (Core::Request core_request, Frame frame, bool interception_enabled, ?redirect: HTTPRequest?) -> HTTPRequest
35
+
36
+ # @rbs core_request: Core::Request -- Underlying core request
37
+ # @rbs return: HTTPRequest? -- Mapped request
38
+ def self.for_core_request: (Core::Request core_request) -> HTTPRequest?
39
+
40
+ attr_reader id: untyped
41
+
42
+ # @rbs core_request: Core::Request -- Underlying BiDi request
43
+ # @rbs frame: Frame -- Owning frame
44
+ # @rbs interception_enabled: bool -- Whether interception is enabled
45
+ # @rbs redirect: HTTPRequest? -- Redirected request
46
+ # @rbs return: void
47
+ def initialize: (Core::Request core_request, Frame frame, bool interception_enabled, HTTPRequest? redirect) -> void
48
+
49
+ # @rbs return: String -- Request URL
50
+ def url: () -> String
51
+
52
+ # @rbs return: String -- HTTP method
53
+ def method: () -> String
54
+
55
+ # @rbs return: Hash[String, String] -- Lowercased headers
56
+ def headers: () -> Hash[String, String]
57
+
58
+ # @rbs return: String? -- POST body (if available)
59
+ def post_data: () -> String?
60
+
61
+ # @rbs return: bool -- Whether request has POST data
62
+ def has_post_data?: () -> bool
63
+
64
+ # @rbs return: String? -- POST body fetched from browser
65
+ def fetch_post_data: () -> String?
66
+
67
+ # @rbs return: String -- Resource type
68
+ def resource_type: () -> String
69
+
70
+ # @rbs return: Frame -- Request initiator frame
71
+ def frame: () -> Frame
72
+
73
+ # @rbs return: bool -- Whether this is a navigation request
74
+ def navigation_request?: () -> bool
75
+
76
+ # @rbs return: Array[HTTPRequest] -- Redirect chain
77
+ def redirect_chain: () -> Array[HTTPRequest]
78
+
79
+ # @rbs return: HTTPResponse? -- Response if available
80
+ def response: () -> HTTPResponse?
81
+
82
+ # @rbs return: Hash[String, String]? -- Failure info
83
+ def failure: () -> Hash[String, String]?
84
+
85
+ # @rbs return: Hash[String, untyped]? -- Initiator metadata
86
+ def initiator: () -> Hash[String, untyped]?
87
+
88
+ # @rbs return: Hash[String, untyped] -- Timing info
89
+ def timing: () -> Hash[String, untyped]
90
+
91
+ # @rbs return: Hash[Symbol, untyped] -- Interception resolution state
92
+ def intercept_resolution_state: () -> Hash[Symbol, untyped]
93
+
94
+ # @rbs return: bool -- Whether intercept is already handled
95
+ def intercept_resolution_handled?: () -> bool
96
+
97
+ # @rbs return: Hash[Symbol | String, untyped] -- Continue overrides
98
+ def continue_request_overrides: () -> Hash[Symbol | String, untyped]
99
+
100
+ # @rbs return: Hash[Symbol | String, untyped]? -- Response overrides
101
+ def response_for_request: () -> Hash[Symbol | String, untyped]?
102
+
103
+ # @rbs return: String? -- Abort error reason
104
+ def abort_error_reason: () -> String?
105
+
106
+ # @rbs &block: (-> untyped) -- Intercept handler
107
+ # @rbs return: void
108
+ def enqueue_intercept_action: () ?{ (?) -> untyped } -> void
109
+
110
+ # @rbs return: void
111
+ def finalize_interceptions: () -> void
112
+
113
+ # @rbs overrides: Hash[Symbol | String, untyped] -- Continue overrides
114
+ # @rbs priority: Integer? -- Cooperative intercept priority
115
+ # @rbs return: void
116
+ def continue: (?Hash[Symbol | String, untyped] overrides, ?Integer? priority) -> void
117
+
118
+ # @rbs response: Hash[Symbol | String, untyped] -- Response overrides
119
+ # @rbs priority: Integer? -- Cooperative intercept priority
120
+ # @rbs return: void
121
+ def respond: (?Hash[Symbol | String, untyped] response, ?Integer? priority) -> void
122
+
123
+ # @rbs error_code: String -- Abort error code
124
+ # @rbs priority: Integer? -- Cooperative intercept priority
125
+ # @rbs return: void
126
+ def abort: (?String error_code, ?Integer? priority) -> void
127
+
128
+ # @rbs return: String -- Response body (binary string)
129
+ def get_response_content: () -> String
130
+
131
+ # @rbs body: String -- Response body
132
+ # @rbs return: Hash[Symbol, untyped]
133
+ def self.get_response: (String body) -> Hash[Symbol, untyped]
134
+
135
+ private
136
+
137
+ def initialize_request: () -> untyped
138
+
139
+ def redirect_chain_internal: () -> untyped
140
+
141
+ def verify_interception: () -> untyped
142
+
143
+ def can_be_intercepted?: () -> untyped
144
+
145
+ def _continue: (untyped overrides) -> untyped
146
+
147
+ def _abort: (untyped _error_reason) -> untyped
148
+
149
+ def _respond: (untyped response) -> untyped
150
+
151
+ def handle_authentication: () -> untyped
152
+
153
+ def body_override: (untyped post_data) -> untyped
154
+
155
+ def value_for_key: (untyped hash, untyped symbol_key, untyped string_key) -> untyped
156
+
157
+ def self.bidi_headers_from_hash: (untyped raw_headers) -> untyped
158
+
159
+ def self.handle_interception_error: (untyped error) -> untyped
160
+ end
161
+ end
162
+ end
@@ -2,17 +2,76 @@
2
2
 
3
3
  module Puppeteer
4
4
  module Bidi
5
- # HTTPResponse represents a response to an HTTP request
5
+ # HTTPResponse represents a response to an HTTP request.
6
6
  class HTTPResponse
7
- attr_reader url: untyped
7
+ # @rbs data: Hash[String, untyped] -- BiDi response data
8
+ # @rbs request: HTTPRequest -- Associated request
9
+ # @rbs return: HTTPResponse
10
+ def self.from: (Hash[String, untyped] data, HTTPRequest request) -> HTTPResponse
8
11
 
9
- # @param url [String] Response URL
10
- # @param status [Integer] HTTP status code
11
- def initialize: (url: untyped, ?status: untyped) -> untyped
12
+ # Create a synthetic response for BFCache restoration
13
+ # @rbs url: String -- Response URL
14
+ # @rbs status: Integer -- HTTP status code
15
+ # @rbs return: HTTPResponse
16
+ def self.for_bfcache: (url: String, ?status: Integer) -> HTTPResponse
12
17
 
13
- # Check if the response was successful (status code 200-299)
14
- # @return [Boolean] True if status code is in 2xx range
15
- def ok?: () -> untyped
18
+ attr_reader request: untyped
19
+
20
+ # @rbs data: Hash[String, untyped] -- BiDi response data
21
+ # @rbs request: HTTPRequest? -- Associated request (nil for BFCache)
22
+ # @rbs return: void
23
+ def initialize: (data: Hash[String, untyped], request: HTTPRequest?) -> void
24
+
25
+ # @rbs return: Hash[Symbol, untyped]
26
+ def remote_address: () -> Hash[Symbol, untyped]
27
+
28
+ # @rbs return: String
29
+ def url: () -> String
30
+
31
+ # @rbs return: Integer
32
+ def status: () -> Integer
33
+
34
+ # @rbs return: String
35
+ def status_text: () -> String
36
+
37
+ # @rbs return: Hash[String, String]
38
+ def headers: () -> Hash[String, String]
39
+
40
+ # @rbs return: bool
41
+ def ok?: () -> bool
42
+
43
+ # @rbs return: Hash[String, untyped]?
44
+ def security_details: () -> Hash[String, untyped]?
45
+
46
+ # @rbs return: Hash[String, Numeric]?
47
+ def timing: () -> Hash[String, Numeric]?
48
+
49
+ # @rbs return: String
50
+ def content: () -> String
51
+
52
+ # @rbs return: String
53
+ def buffer: () -> String
54
+
55
+ # @rbs return: String
56
+ def text: () -> String
57
+
58
+ # @rbs return: untyped
59
+ def json: () -> untyped
60
+
61
+ # @rbs return: bool
62
+ def from_cache?: () -> bool
63
+
64
+ # @rbs return: bool
65
+ def from_service_worker?: () -> bool
66
+
67
+ # @rbs return: Frame?
68
+ def frame: () -> Frame?
69
+
70
+ private
71
+
72
+ def initialize_response: () -> untyped
73
+
74
+ def update_data: (untyped data) -> untyped
16
75
  end
17
76
  end
18
77
  end
@@ -0,0 +1,267 @@
1
+ # Generated from lib/puppeteer/bidi/locator.rb with RBS::Inline
2
+
3
+ module Puppeteer
4
+ module Bidi
5
+ # Visibility options for locators.
6
+ module VisibilityOption
7
+ HIDDEN: ::String
8
+
9
+ VISIBLE: ::String
10
+ end
11
+
12
+ # Events emitted by locators.
13
+ module LocatorEvent
14
+ ACTION: ::Symbol
15
+ end
16
+
17
+ class RetryableError < StandardError
18
+ end
19
+
20
+ # Locators describe a strategy of locating objects and performing an action on them.
21
+ # Actions are retried when the element is not ready.
22
+ class Locator
23
+ RETRY_DELAY: ::Float
24
+
25
+ attr_reader timeout: Numeric
26
+
27
+ def initialize: () -> untyped
28
+
29
+ # Create a race between multiple locators.
30
+ # @rbs *locators: Array[Locator] -- Locators to race
31
+ # @rbs return: Locator -- Locator that resolves to the first match
32
+ def self.race: (*Array[Locator] locators) -> Locator
33
+
34
+ # Register an event listener.
35
+ # @rbs event: Symbol | String -- Event name
36
+ # @rbs &block: (untyped) -> void -- Event handler
37
+ # @rbs return: Locator -- This locator
38
+ def on: (Symbol | String event) { (untyped) -> void } -> Locator
39
+
40
+ # Register a one-time event listener.
41
+ # @rbs event: Symbol | String -- Event name
42
+ # @rbs &block: (untyped) -> void -- Event handler
43
+ # @rbs return: Locator -- This locator
44
+ def once: (Symbol | String event) { (untyped) -> void } -> Locator
45
+
46
+ # Remove an event listener.
47
+ # @rbs event: Symbol | String -- Event name
48
+ # @rbs &block: ((untyped) -> void)? -- Handler to remove
49
+ # @rbs return: Locator -- This locator
50
+ def off: (Symbol | String event) ?{ (?) -> untyped } -> Locator
51
+
52
+ # Clone the locator.
53
+ # @rbs return: Locator -- Cloned locator
54
+ def clone: () -> Locator
55
+
56
+ # Set the total timeout for locator actions.
57
+ # Pass 0 to disable timeout.
58
+ # @rbs timeout: Numeric -- Timeout in ms
59
+ # @rbs return: Locator -- Cloned locator with timeout
60
+ def set_timeout: (Numeric timeout) -> Locator
61
+
62
+ # Set visibility checks for the locator.
63
+ # @rbs visibility: String? -- Visibility option ("hidden", "visible", or nil)
64
+ # @rbs return: Locator -- Cloned locator with visibility option
65
+ def set_visibility: (String? visibility) -> Locator
66
+
67
+ # Set whether to wait for elements to become enabled.
68
+ # @rbs value: bool -- Whether to wait for enabled state
69
+ # @rbs return: Locator -- Cloned locator with enabled check
70
+ def set_wait_for_enabled: (bool value) -> Locator
71
+
72
+ # Set whether to ensure elements are in the viewport.
73
+ # @rbs value: bool -- Whether to ensure viewport visibility
74
+ # @rbs return: Locator -- Cloned locator with viewport check
75
+ def set_ensure_element_is_in_the_viewport: (bool value) -> Locator
76
+
77
+ # Set whether to wait for a stable bounding box.
78
+ # @rbs value: bool -- Whether to wait for stable bounding box
79
+ # @rbs return: Locator -- Cloned locator with stable bounding box check
80
+ def set_wait_for_stable_bounding_box: (bool value) -> Locator
81
+
82
+ # Wait for the locator to produce a handle.
83
+ # @rbs return: JSHandle -- Handle to located value
84
+ def wait_handle: () -> JSHandle
85
+
86
+ # Wait for the locator to produce a JSON-serializable value.
87
+ # @rbs return: untyped -- JSON-serializable value
88
+ def wait: () -> untyped
89
+
90
+ # Map the locator using a JavaScript mapper.
91
+ # @rbs mapper: String -- JavaScript mapper function
92
+ # @rbs &block: () -> String -- Optional block returning mapper string
93
+ # @rbs return: Locator -- Mapped locator
94
+ def map: (?String mapper) { () -> String } -> Locator
95
+
96
+ # Filter the locator using a JavaScript predicate.
97
+ # @rbs predicate: String -- JavaScript predicate function
98
+ # @rbs &block: () -> String -- Optional block returning predicate string
99
+ # @rbs return: Locator -- Filtered locator
100
+ def filter: (?String predicate) { () -> String } -> Locator
101
+
102
+ # Click the located element.
103
+ # @rbs button: String -- Mouse button ('left', 'right', 'middle')
104
+ # @rbs count: Integer -- Number of clicks
105
+ # @rbs delay: Numeric? -- Delay between clicks in ms
106
+ # @rbs offset: Hash[Symbol, Numeric]? -- Click offset from element center
107
+ # @rbs return: void
108
+ def click: (?button: String, ?count: Integer, ?delay: Numeric?, ?offset: Hash[Symbol, Numeric]?) -> void
109
+
110
+ # Fill the located element with the provided value.
111
+ # @rbs value: String -- Value to fill
112
+ # @rbs return: void
113
+ def fill: (String value) -> void
114
+
115
+ # Hover over the located element.
116
+ # @rbs return: void
117
+ def hover: () -> void
118
+
119
+ # Scroll the located element.
120
+ # @rbs scroll_top: Numeric? -- Scroll top offset
121
+ # @rbs scroll_left: Numeric? -- Scroll left offset
122
+ # @rbs return: void
123
+ def scroll: (?scroll_top: Numeric?, ?scroll_left: Numeric?) -> void
124
+
125
+ def copy_options: (untyped locator) -> untyped
126
+
127
+ def visibility: () -> untyped
128
+
129
+ def wait_for_enabled?: () -> untyped
130
+
131
+ def ensure_element_is_in_viewport?: () -> untyped
132
+
133
+ def wait_for_stable_bounding_box?: () -> untyped
134
+
135
+ def map_handle: (untyped mapper) -> untyped
136
+
137
+ def _clone: () -> untyped
138
+
139
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
140
+
141
+ private
142
+
143
+ attr_writer timeout: untyped
144
+
145
+ attr_writer visibility: untyped
146
+
147
+ attr_writer wait_for_enabled: untyped
148
+
149
+ attr_writer ensure_element_is_in_viewport: untyped
150
+
151
+ attr_writer wait_for_stable_bounding_box: untyped
152
+
153
+ # @rbs cause: String -- Action name
154
+ # @rbs wait_for_enabled: bool -- Whether to wait for enabled
155
+ # @rbs &block: (ElementHandle) -> void -- Action to perform
156
+ # @rbs return: void
157
+ def perform_action: (String cause, ?wait_for_enabled: bool) { (ElementHandle) -> void } -> void
158
+
159
+ # @rbs cause: String -- Action name
160
+ # @rbs &block: (Numeric?, Numeric?) -> untyped -- Retry block
161
+ # @rbs return: untyped
162
+ def with_retry: (String cause) { (Numeric?, Numeric?) -> untyped } -> untyped
163
+
164
+ def build_deadline: () -> untyped
165
+
166
+ def remaining_time_ms: (untyped deadline) -> untyped
167
+
168
+ def raise_timeout: () -> untyped
169
+
170
+ # @rbs deadline: Numeric? -- Deadline timestamp
171
+ # @rbs &block: () -> boolish -- Condition block
172
+ # @rbs return: void
173
+ def wait_until: (Numeric? deadline) { () -> boolish } -> void
174
+
175
+ def ensure_element_is_in_viewport_if_needed: (untyped handle, untyped deadline) -> untyped
176
+
177
+ def wait_for_stable_bounding_box_if_needed: (untyped handle, untyped deadline) -> untyped
178
+
179
+ def wait_for_enabled_if_needed: (untyped handle, untyped deadline) -> untyped
180
+ end
181
+
182
+ # Locator implementation based on JavaScript functions.
183
+ class FunctionLocator < Locator
184
+ # @rbs page_or_frame: Page | Frame -- Page or frame to evaluate in
185
+ # @rbs function: String -- JavaScript function to evaluate
186
+ # @rbs return: Locator -- Function locator
187
+ def self.create: (Page | Frame page_or_frame, String function) -> Locator
188
+
189
+ def initialize: (untyped page_or_frame, untyped function) -> untyped
190
+
191
+ def _clone: () -> untyped
192
+
193
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
194
+ end
195
+
196
+ # Abstract locator that delegates to another locator.
197
+ class DelegatedLocator < Locator
198
+ def initialize: (untyped delegate) -> untyped
199
+
200
+ def set_timeout: (untyped timeout) -> untyped
201
+
202
+ def set_visibility: (untyped visibility) -> untyped
203
+
204
+ def set_wait_for_enabled: (untyped value) -> untyped
205
+
206
+ def set_ensure_element_is_in_the_viewport: (untyped value) -> untyped
207
+
208
+ def set_wait_for_stable_bounding_box: (untyped value) -> untyped
209
+
210
+ attr_accessor delegate: untyped
211
+ end
212
+
213
+ # Locator that filters results using a predicate.
214
+ class FilteredLocator < DelegatedLocator
215
+ def initialize: (untyped delegate, untyped predicate) -> untyped
216
+
217
+ def _clone: () -> untyped
218
+
219
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
220
+ end
221
+
222
+ # Locator that maps results using a mapper.
223
+ class MappedLocator < DelegatedLocator
224
+ def initialize: (untyped delegate, untyped mapper) -> untyped
225
+
226
+ def _clone: () -> untyped
227
+
228
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
229
+ end
230
+
231
+ # Locator that queries nodes by selector or handle.
232
+ class NodeLocator < Locator
233
+ # @rbs page_or_frame: Page | Frame -- Page or frame to query
234
+ # @rbs selector: String -- Selector to query
235
+ # @rbs return: Locator -- Node locator
236
+ def self.create: (Page | Frame page_or_frame, String selector) -> Locator
237
+
238
+ # @rbs page_or_frame: Page | Frame -- Page or frame to query
239
+ # @rbs handle: ElementHandle -- Element handle to wrap
240
+ # @rbs return: Locator -- Node locator
241
+ def self.create_from_handle: (Page | Frame page_or_frame, ElementHandle handle) -> Locator
242
+
243
+ def initialize: (untyped page_or_frame, untyped selector_or_handle) -> untyped
244
+
245
+ def _clone: () -> untyped
246
+
247
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
248
+
249
+ def query_selector_with_pseudo_selectors: (untyped selector) -> untyped
250
+
251
+ def p_selector_candidates: (untyped selector) -> untyped
252
+
253
+ def split_selector_list: (untyped selector) -> untyped
254
+
255
+ def unquote_selector_value: (untyped value) -> untyped
256
+ end
257
+
258
+ # Locator that races multiple locators.
259
+ class RaceLocator < Locator
260
+ def initialize: (untyped locators) -> untyped
261
+
262
+ def _clone: () -> untyped
263
+
264
+ def _wait: (timeout_ms: untyped, deadline: untyped) -> untyped
265
+ end
266
+ end
267
+ end