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
@@ -7,6 +7,10 @@ module Puppeteer
7
7
  class Page
8
8
  DEFAULT_TIMEOUT: Integer
9
9
 
10
+ UNIT_TO_PIXELS: untyped
11
+
12
+ PAPER_FORMATS: untyped
13
+
10
14
  attr_reader browsing_context: Core::BrowsingContext
11
15
 
12
16
  attr_reader browser_context: BrowserContext
@@ -42,6 +46,15 @@ module Puppeteer
42
46
  # @rbs return: void
43
47
  def emit: (Symbol | String event, ?untyped data) -> void
44
48
 
49
+ # @rbs return: bool -- Whether any network interception is enabled
50
+ def network_interception_enabled?: () -> bool
51
+
52
+ # @rbs return: Hash[Symbol, String]?
53
+ def credentials: () -> Hash[Symbol, String]?
54
+
55
+ # @rbs return: Async::Semaphore -- Serialize request interception handling
56
+ attr_reader request_interception_semaphore: untyped
57
+
45
58
  # Navigate to a URL
46
59
  # @rbs url: String -- URL to navigate to
47
60
  # @rbs wait_until: String -- When to consider navigation complete ('load', 'domcontentloaded')
@@ -63,6 +76,28 @@ module Puppeteer
63
76
  # @rbs return: String -- Base64-encoded image data
64
77
  def screenshot: (?path: String?, ?type: String, ?full_page: bool, ?clip: Hash[Symbol, Numeric]?, ?capture_beyond_viewport: bool) -> String
65
78
 
79
+ # Generate a PDF of the page.
80
+ # @rbs path: String? -- File path to save PDF
81
+ # @rbs scale: Numeric? -- Scale of the webpage rendering
82
+ # @rbs display_header_footer: bool? -- Display header and footer
83
+ # @rbs header_template: String? -- HTML template for header
84
+ # @rbs footer_template: String? -- HTML template for footer
85
+ # @rbs print_background: bool? -- Print background graphics
86
+ # @rbs landscape: bool? -- Print in landscape orientation
87
+ # @rbs page_ranges: String? -- Paper ranges to print (e.g. "1-5, 8")
88
+ # @rbs format: String? -- Paper format (e.g. "A4")
89
+ # @rbs width: String | Numeric? -- Paper width
90
+ # @rbs height: String | Numeric? -- Paper height
91
+ # @rbs prefer_css_page_size: bool? -- Prefer CSS @page size
92
+ # @rbs margin: Hash[Symbol, String | Numeric]? -- Paper margins
93
+ # @rbs omit_background: bool? -- Omit background
94
+ # @rbs tagged: bool? -- Generate tagged PDF
95
+ # @rbs outline: bool? -- Generate document outline
96
+ # @rbs timeout: Numeric? -- Timeout in ms (0 disables)
97
+ # @rbs wait_for_fonts: bool? -- Wait for document fonts to load
98
+ # @rbs return: String -- PDF data as binary string
99
+ def pdf: (?path: String?, ?scale: Numeric?, ?display_header_footer: bool?, ?header_template: String?, ?footer_template: String?, ?print_background: bool?, ?landscape: bool?, ?page_ranges: String?, ?format: String?, ?width: String | Numeric?, ?height: String | Numeric?, ?prefer_css_page_size: bool?, ?margin: Hash[Symbol, String | Numeric]?, ?omit_background: bool?, ?tagged: bool?, ?outline: bool?, ?timeout: Numeric?, ?wait_for_fonts: bool?) -> String
100
+
66
101
  # Evaluate JavaScript in the page context
67
102
  # @rbs script: String -- JavaScript code to evaluate
68
103
  # @rbs *args: untyped -- Arguments to pass to the script
@@ -85,6 +120,12 @@ module Puppeteer
85
120
  # @rbs return: Array[ElementHandle] -- All matching elements
86
121
  def query_selector_all: (String selector) -> Array[ElementHandle]
87
122
 
123
+ # Create a locator for a selector or function.
124
+ # @rbs selector: String? -- Selector to locate
125
+ # @rbs function: String? -- JavaScript function for function locator
126
+ # @rbs return: Locator -- Locator instance
127
+ def locator: (?String? selector, ?function: String?) -> Locator
128
+
88
129
  # Evaluate a function on the first element matching the selector
89
130
  # @rbs selector: String -- Selector to query
90
131
  # @rbs page_function: String -- JavaScript function to evaluate
@@ -120,6 +161,13 @@ module Puppeteer
120
161
  # @rbs return: void
121
162
  def hover: (String selector) -> void
122
163
 
164
+ # Select options on a <select> element matching the selector
165
+ # Triggers 'change' and 'input' events once all options are selected.
166
+ # @rbs selector: String -- Selector for <select> element
167
+ # @rbs *values: String -- Option values to select
168
+ # @rbs return: Array[String] -- Actually selected option values
169
+ def select: (String selector, *String values) -> Array[String]
170
+
123
171
  # Focus an element matching the selector
124
172
  # @rbs selector: String -- Selector to focus
125
173
  # @rbs return: void
@@ -133,6 +181,10 @@ module Puppeteer
133
181
  # @rbs return: String -- Page URL
134
182
  def url: () -> String
135
183
 
184
+ # Get the full HTML contents of the page, including the DOCTYPE.
185
+ # @rbs return: String -- Full HTML contents
186
+ def content: () -> String
187
+
136
188
  # Close the page
137
189
  # @rbs return: void
138
190
  def close: () -> void
@@ -145,6 +197,33 @@ module Puppeteer
145
197
  # @rbs return: Frame -- Main frame
146
198
  def main_frame: () -> Frame
147
199
 
200
+ # Reloads the page.
201
+ # @rbs timeout: Numeric -- Navigation timeout in ms
202
+ # @rbs wait_until: String | Array[String] -- When to consider navigation complete
203
+ # @rbs ignore_cache: bool -- Whether to ignore the browser cache
204
+ # @rbs return: HTTPResponse? -- Response or nil
205
+ def reload: (?timeout: Numeric, ?wait_until: String | Array[String], ?ignore_cache: bool) -> HTTPResponse?
206
+
207
+ # Enable or disable request interception.
208
+ # @rbs enable: bool -- Whether to enable interception
209
+ # @rbs return: void
210
+ def set_request_interception: (bool enable) -> void
211
+
212
+ # Set extra HTTP headers for the page.
213
+ # @rbs headers: Hash[String, String] -- Extra headers
214
+ # @rbs return: void
215
+ def set_extra_http_headers: (Hash[String, String] headers) -> void
216
+
217
+ # Authenticate to HTTP Basic auth challenges.
218
+ # @rbs credentials: Hash[Symbol, String]? -- Credentials (username/password) or nil to disable
219
+ # @rbs return: void
220
+ def authenticate: (Hash[Symbol, String]? credentials) -> void
221
+
222
+ # Enable or disable cache.
223
+ # @rbs enabled: bool -- Whether to enable cache
224
+ # @rbs return: void
225
+ def set_cache_enabled: (bool enabled) -> void
226
+
148
227
  # Get the focused frame
149
228
  # @rbs return: Frame -- Focused frame
150
229
  def focused_frame: () -> Frame
@@ -195,6 +274,37 @@ module Puppeteer
195
274
  # @rbs return: HTTPResponse? -- Response or nil
196
275
  def wait_for_navigation: (?timeout: Numeric, ?wait_until: String) ?{ (?) -> untyped } -> HTTPResponse?
197
276
 
277
+ # Wait for a request that matches a URL or predicate.
278
+ # @rbs url_or_predicate: String | ^(HTTPRequest) -> boolish -- URL or predicate
279
+ # @rbs timeout: Numeric? -- Timeout in ms (0 for infinite)
280
+ # @rbs &block: (-> void)? -- Optional block to trigger the request
281
+ # @rbs return: HTTPRequest
282
+ def wait_for_request: (String | ^(HTTPRequest) -> boolish url_or_predicate, ?timeout: Numeric?) ?{ (?) -> untyped } -> HTTPRequest
283
+
284
+ # Wait for a response that matches a URL or predicate.
285
+ # @rbs url_or_predicate: String | ^(HTTPResponse) -> boolish -- URL or predicate
286
+ # @rbs timeout: Numeric? -- Timeout in ms (0 for infinite)
287
+ # @rbs &block: (-> void)? -- Optional block to trigger the response
288
+ # @rbs return: HTTPResponse
289
+ def wait_for_response: (String | ^(HTTPResponse) -> boolish url_or_predicate, ?timeout: Numeric?) ?{ (?) -> untyped } -> HTTPResponse
290
+
291
+ # Retrieve cookies for the current page.
292
+ # @rbs *urls: Array[String] -- URLs to filter cookies by
293
+ # @rbs return: Array[Hash[String, untyped]]
294
+ def cookies: (*Array[String] urls) -> Array[Hash[String, untyped]]
295
+
296
+ # Set cookies for the current page.
297
+ # @rbs *cookies: Array[Hash[String, untyped]] -- Cookie data
298
+ # @rbs **cookie: untyped -- Single cookie via keyword arguments
299
+ # @rbs return: void
300
+ def set_cookie: (*Array[Hash[String, untyped]] cookies, **untyped cookie) -> void
301
+
302
+ # Delete cookies from the current page.
303
+ # @rbs *cookies: Array[Hash[String, untyped]] -- Cookie filters
304
+ # @rbs **cookie: untyped -- Single cookie filter via keyword arguments
305
+ # @rbs return: void
306
+ def delete_cookie: (*Array[Hash[String, untyped]] cookies, **untyped cookie) -> void
307
+
198
308
  # Wait for a file chooser to be opened
199
309
  # @rbs timeout: Numeric? -- Wait timeout in ms
200
310
  # @rbs &block: (-> void)? -- Optional block to trigger file chooser
@@ -215,6 +325,19 @@ module Puppeteer
215
325
  # @rbs return: void
216
326
  def set_viewport: (width: Integer, height: Integer) -> void
217
327
 
328
+ # Set geolocation override
329
+ # @rbs longitude: Numeric -- Longitude between -180 and 180
330
+ # @rbs latitude: Numeric -- Latitude between -90 and 90
331
+ # @rbs accuracy: Numeric? -- Non-negative accuracy value
332
+ # @rbs return: void
333
+ def set_geolocation: (longitude: Numeric, latitude: Numeric, ?accuracy: Numeric?) -> void
334
+
335
+ # Set user agent
336
+ # @rbs user_agent: String? -- User agent string or nil to restore original
337
+ # @rbs user_agent_metadata: Hash[Symbol, untyped]? -- Not supported in BiDi-only mode
338
+ # @rbs return: void
339
+ def set_user_agent: (String? user_agent, ?Hash[Symbol, untyped]? user_agent_metadata) -> void
340
+
218
341
  # Get current viewport size
219
342
  # @rbs return: Hash[Symbol, Integer]? -- Viewport dimensions
220
343
  def viewport: () -> Hash[Symbol, Integer]?
@@ -232,16 +355,63 @@ module Puppeteer
232
355
  # @rbs return: bool -- Whether JavaScript is enabled
233
356
  def javascript_enabled?: () -> bool
234
357
 
358
+ # Navigate backward in history
359
+ # @rbs wait_until: String -- When to consider navigation complete
360
+ # @rbs timeout: Numeric -- Navigation timeout in ms
361
+ # @rbs return: HTTPResponse? -- Response or nil
362
+ def go_back: (?wait_until: String, ?timeout: Numeric) -> HTTPResponse?
363
+
364
+ # Navigate forward in history
365
+ # @rbs wait_until: String -- When to consider navigation complete
366
+ # @rbs timeout: Numeric -- Navigation timeout in ms
367
+ # @rbs return: HTTPResponse? -- Response or nil
368
+ def go_forward: (?wait_until: String, ?timeout: Numeric) -> HTTPResponse?
369
+
235
370
  private
236
371
 
372
+ # Navigate history by delta.
373
+ #
374
+ # In Firefox, BFCache restores may emit `browsingContext.navigationStarted`
375
+ # without firing `domContentLoaded` / `load`. We treat such navigations as
376
+ # completed if we don't observe a navigation request shortly after start.
377
+ # @rbs delta: Integer -- Steps to go back (negative) or forward (positive)
378
+ # @rbs wait_until: String -- When to consider navigation complete
379
+ # @rbs timeout: Numeric -- Navigation timeout in ms
380
+ # @rbs return: HTTPResponse? -- Response or nil
381
+ def go: (Integer delta, wait_until: String, timeout: Numeric) -> HTTPResponse?
382
+
237
383
  # Recursively collect all frames starting from the given frame
238
384
  # @rbs frame: Frame -- Starting frame
239
385
  # @rbs return: Array[Frame] -- All frames in subtree
240
386
  def collect_frames: (Frame frame) -> Array[Frame]
241
387
 
388
+ def parse_pdf_options: (untyped options, untyped length_unit) -> untyped
389
+
390
+ def convert_print_parameter_to_length_unit: (untyped parameter, untyped length_unit) -> untyped
391
+
392
+ def parse_print_parameter_value: (untyped text, untyped value_text) -> untyped
393
+
394
+ def js_typeof: (untyped value) -> untyped
395
+
242
396
  # Check if this page is closed and raise error if so
243
397
  # @rbs return: void
244
398
  def assert_not_closed: () -> void
399
+
400
+ # @rbs cookie_url: String -- Cookie URL
401
+ # @rbs return: URI::Generic? -- Parsed URL or nil
402
+ def parse_cookie_url: (String cookie_url) -> URI::Generic?
403
+
404
+ def parse_cookie_url_strict: (untyped cookie_url) -> untyped
405
+
406
+ def toggle_interception: (untyped phases, untyped interception, untyped expected) -> untyped
407
+
408
+ # @rbs clip_x: Numeric -- Clip x coordinate
409
+ # @rbs clip_y: Numeric -- Clip y coordinate
410
+ # @rbs clip_width: Numeric -- Clip width
411
+ # @rbs clip_height: Numeric -- Clip height
412
+ # @rbs return: Array[Integer] -- Processed clip [x, y, width, height]
413
+ # ref: https://github.com/puppeteer/puppeteer/commit/2275c3c0c801d42514d6de127b9b1537d20356a9
414
+ def process_clip: (clip_x: Numeric, clip_y: Numeric, clip_width: Numeric, clip_height: Numeric) -> Array[Integer]
245
415
  end
246
416
  end
247
417
  end
@@ -8,9 +8,10 @@ module Puppeteer
8
8
  # @rbs headless: bool -- Run browser in headless mode
9
9
  # @rbs args: Array[String]? -- Additional browser arguments
10
10
  # @rbs timeout: Numeric? -- Launch timeout in seconds
11
+ # @rbs accept_insecure_certs: bool -- Accept insecure certificates
11
12
  # @rbs &block: (Browser) -> untyped -- Block to execute with the browser instance
12
13
  # @rbs return: untyped
13
- def self.launch: (?executable_path: String?, ?user_data_dir: String?, ?headless: bool, ?args: Array[String]?, ?timeout: Numeric?) { (Browser) -> untyped } -> untyped
14
+ def self.launch: (?executable_path: String?, ?user_data_dir: String?, ?headless: bool, ?args: Array[String]?, ?timeout: Numeric?, ?accept_insecure_certs: bool) { (Browser) -> untyped } -> untyped
14
15
 
15
16
  # Launch a new browser instance
16
17
  # @rbs executable_path: String? -- Path to browser executable
@@ -18,12 +19,23 @@ module Puppeteer
18
19
  # @rbs headless: bool -- Run browser in headless mode
19
20
  # @rbs args: Array[String]? -- Additional browser arguments
20
21
  # @rbs timeout: Numeric? -- Launch timeout in seconds
22
+ # @rbs accept_insecure_certs: bool -- Accept insecure certificates
21
23
  # @rbs return: Browser -- Browser instance (if no block given)
22
- def self.launch_browser_instance: (?executable_path: String?, ?user_data_dir: String?, ?headless: bool, ?args: Array[String]?, ?timeout: Numeric?) -> Browser
24
+ def self.launch_browser_instance: (?executable_path: String?, ?user_data_dir: String?, ?headless: bool, ?args: Array[String]?, ?timeout: Numeric?, ?accept_insecure_certs: bool) -> Browser
23
25
 
24
26
  # Connect to an existing browser instance
25
27
  # @rbs ws_endpoint: String -- WebSocket endpoint URL
28
+ # @rbs timeout: Numeric? -- Connect timeout in seconds
29
+ # @rbs accept_insecure_certs: bool -- Accept insecure certificates
30
+ # @rbs &block: (Browser) -> untyped -- Block to execute with the browser instance
31
+ # @rbs return: untyped
32
+ def self.connect: (String ws_endpoint, ?timeout: Numeric?, ?accept_insecure_certs: bool) { (Browser) -> untyped } -> untyped
33
+
34
+ # Connect to an existing browser instance
35
+ # @rbs ws_endpoint: String -- WebSocket endpoint URL
36
+ # @rbs timeout: Numeric? -- Connect timeout in seconds
37
+ # @rbs accept_insecure_certs: bool -- Accept insecure certificates
26
38
  # @rbs return: Browser -- Browser instance
27
- def self.connect: (String ws_endpoint) -> Browser
39
+ def self.connect_to_browser_instance: (String ws_endpoint, ?timeout: Numeric?, ?accept_insecure_certs: bool) -> Browser
28
40
  end
29
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppeteer-bidi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta10
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
@@ -77,6 +77,8 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".rspec"
79
79
  - ".rubocop.yml"
80
+ - AGENTS.md
81
+ - API_COVERAGE.md
80
82
  - CLAUDE.md
81
83
  - CLAUDE/README.md
82
84
  - CLAUDE/async_programming.md
@@ -98,16 +100,20 @@ files:
98
100
  - CLAUDE/testing_strategy.md
99
101
  - CLAUDE/two_layer_architecture.md
100
102
  - CLAUDE/wrapped_element_click.md
103
+ - DEVELOPMENT.md
101
104
  - LICENSE.txt
102
105
  - README.md
103
106
  - Rakefile
104
107
  - Steepfile
108
+ - development/generate_api_coverage.rb
109
+ - development/puppeteer_revision.txt
105
110
  - lib/puppeteer/bidi.rb
106
111
  - lib/puppeteer/bidi/async_utils.rb
107
112
  - lib/puppeteer/bidi/browser.rb
108
113
  - lib/puppeteer/bidi/browser_context.rb
109
114
  - lib/puppeteer/bidi/browser_launcher.rb
110
115
  - lib/puppeteer/bidi/connection.rb
116
+ - lib/puppeteer/bidi/cookie_utils.rb
111
117
  - lib/puppeteer/bidi/core.rb
112
118
  - lib/puppeteer/bidi/core/README.md
113
119
  - lib/puppeteer/bidi/core/browser.rb
@@ -126,12 +132,14 @@ files:
126
132
  - lib/puppeteer/bidi/errors.rb
127
133
  - lib/puppeteer/bidi/file_chooser.rb
128
134
  - lib/puppeteer/bidi/frame.rb
135
+ - lib/puppeteer/bidi/http_request.rb
129
136
  - lib/puppeteer/bidi/http_response.rb
130
137
  - lib/puppeteer/bidi/injected.js
131
138
  - lib/puppeteer/bidi/injected_source.rb
132
139
  - lib/puppeteer/bidi/js_handle.rb
133
140
  - lib/puppeteer/bidi/keyboard.rb
134
141
  - lib/puppeteer/bidi/lazy_arg.rb
142
+ - lib/puppeteer/bidi/locator.rb
135
143
  - lib/puppeteer/bidi/mouse.rb
136
144
  - lib/puppeteer/bidi/page.rb
137
145
  - lib/puppeteer/bidi/query_handler.rb
@@ -152,6 +160,7 @@ files:
152
160
  - sig/puppeteer/bidi/browser_context.rbs
153
161
  - sig/puppeteer/bidi/browser_launcher.rbs
154
162
  - sig/puppeteer/bidi/connection.rbs
163
+ - sig/puppeteer/bidi/cookie_utils.rbs
155
164
  - sig/puppeteer/bidi/core.rbs
156
165
  - sig/puppeteer/bidi/core/browser.rbs
157
166
  - sig/puppeteer/bidi/core/browsing_context.rbs
@@ -169,11 +178,13 @@ files:
169
178
  - sig/puppeteer/bidi/errors.rbs
170
179
  - sig/puppeteer/bidi/file_chooser.rbs
171
180
  - sig/puppeteer/bidi/frame.rbs
181
+ - sig/puppeteer/bidi/http_request.rbs
172
182
  - sig/puppeteer/bidi/http_response.rbs
173
183
  - sig/puppeteer/bidi/injected_source.rbs
174
184
  - sig/puppeteer/bidi/js_handle.rbs
175
185
  - sig/puppeteer/bidi/keyboard.rbs
176
186
  - sig/puppeteer/bidi/lazy_arg.rbs
187
+ - sig/puppeteer/bidi/locator.rbs
177
188
  - sig/puppeteer/bidi/mouse.rbs
178
189
  - sig/puppeteer/bidi/page.rbs
179
190
  - sig/puppeteer/bidi/query_handler.rbs