puppeteer-bidi 0.0.1.beta1 → 0.0.1.beta2

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CLAUDE.md +44 -0
  3. data/README.md +8 -1
  4. data/Steepfile +36 -0
  5. data/lib/puppeteer/bidi/async_utils.rb +1 -0
  6. data/lib/puppeteer/bidi/browser.rb +43 -24
  7. data/lib/puppeteer/bidi/browser_context.rb +13 -4
  8. data/lib/puppeteer/bidi/browser_launcher.rb +1 -0
  9. data/lib/puppeteer/bidi/connection.rb +26 -9
  10. data/lib/puppeteer/bidi/core/browser.rb +15 -14
  11. data/lib/puppeteer/bidi/core/browsing_context.rb +64 -46
  12. data/lib/puppeteer/bidi/core/disposable.rb +10 -3
  13. data/lib/puppeteer/bidi/core/errors.rb +18 -1
  14. data/lib/puppeteer/bidi/core/event_emitter.rb +18 -9
  15. data/lib/puppeteer/bidi/core/navigation.rb +4 -3
  16. data/lib/puppeteer/bidi/core/realm.rb +29 -26
  17. data/lib/puppeteer/bidi/core/request.rb +33 -29
  18. data/lib/puppeteer/bidi/core/session.rb +14 -11
  19. data/lib/puppeteer/bidi/core/user_context.rb +17 -16
  20. data/lib/puppeteer/bidi/core/user_prompt.rb +8 -7
  21. data/lib/puppeteer/bidi/core.rb +1 -0
  22. data/lib/puppeteer/bidi/deserializer.rb +1 -0
  23. data/lib/puppeteer/bidi/element_handle.rb +52 -52
  24. data/lib/puppeteer/bidi/errors.rb +1 -0
  25. data/lib/puppeteer/bidi/file_chooser.rb +1 -0
  26. data/lib/puppeteer/bidi/frame.rb +70 -70
  27. data/lib/puppeteer/bidi/http_response.rb +1 -0
  28. data/lib/puppeteer/bidi/injected_source.rb +1 -0
  29. data/lib/puppeteer/bidi/js_handle.rb +23 -23
  30. data/lib/puppeteer/bidi/keyboard.rb +24 -13
  31. data/lib/puppeteer/bidi/lazy_arg.rb +1 -0
  32. data/lib/puppeteer/bidi/mouse.rb +31 -18
  33. data/lib/puppeteer/bidi/page.rb +87 -87
  34. data/lib/puppeteer/bidi/query_handler.rb +3 -0
  35. data/lib/puppeteer/bidi/realm.rb +70 -6
  36. data/lib/puppeteer/bidi/serializer.rb +1 -0
  37. data/lib/puppeteer/bidi/target.rb +27 -0
  38. data/lib/puppeteer/bidi/timeout_settings.rb +1 -0
  39. data/lib/puppeteer/bidi/transport.rb +1 -0
  40. data/lib/puppeteer/bidi/version.rb +1 -1
  41. data/lib/puppeteer/bidi/wait_task.rb +1 -0
  42. data/lib/puppeteer/bidi.rb +13 -4
  43. data/sig/_external.rbs +134 -0
  44. data/sig/_supplementary.rbs +20 -0
  45. data/sig/puppeteer/bidi/async_utils.rbs +68 -0
  46. data/sig/puppeteer/bidi/browser.rbs +34 -27
  47. data/sig/puppeteer/bidi/browser_context.rbs +39 -0
  48. data/sig/puppeteer/bidi/browser_launcher.rbs +45 -0
  49. data/sig/puppeteer/bidi/connection.rbs +67 -0
  50. data/sig/puppeteer/bidi/core/browser.rbs +79 -0
  51. data/sig/puppeteer/bidi/core/browsing_context.rbs +210 -0
  52. data/sig/puppeteer/bidi/core/disposable.rbs +42 -0
  53. data/sig/puppeteer/bidi/core/errors.rbs +65 -0
  54. data/sig/puppeteer/bidi/core/event_emitter.rbs +50 -0
  55. data/sig/puppeteer/bidi/core/navigation.rbs +37 -0
  56. data/sig/puppeteer/bidi/core/realm.rbs +132 -0
  57. data/sig/puppeteer/bidi/core/request.rbs +120 -0
  58. data/sig/puppeteer/bidi/core/session.rbs +65 -0
  59. data/sig/puppeteer/bidi/core/user_context.rbs +72 -0
  60. data/sig/puppeteer/bidi/core/user_prompt.rbs +52 -0
  61. data/sig/puppeteer/bidi/core.rbs +9 -0
  62. data/sig/puppeteer/bidi/deserializer.rbs +28 -0
  63. data/sig/puppeteer/bidi/element_handle.rbs +52 -52
  64. data/sig/puppeteer/bidi/errors.rbs +34 -0
  65. data/sig/puppeteer/bidi/file_chooser.rbs +27 -0
  66. data/sig/puppeteer/bidi/frame.rbs +70 -70
  67. data/sig/puppeteer/bidi/http_response.rbs +18 -0
  68. data/sig/puppeteer/bidi/injected_source.rbs +21 -0
  69. data/sig/puppeteer/bidi/js_handle.rbs +23 -23
  70. data/sig/puppeteer/bidi/keyboard.rbs +57 -0
  71. data/sig/puppeteer/bidi/lazy_arg.rbs +15 -0
  72. data/sig/puppeteer/bidi/mouse.rbs +73 -0
  73. data/sig/puppeteer/bidi/page.rbs +87 -87
  74. data/sig/puppeteer/bidi/query_handler.rbs +113 -0
  75. data/sig/puppeteer/bidi/realm.rbs +141 -0
  76. data/sig/puppeteer/bidi/serializer.rbs +31 -0
  77. data/sig/puppeteer/bidi/target.rbs +68 -0
  78. data/sig/puppeteer/bidi/timeout_settings.rbs +14 -0
  79. data/sig/puppeteer/bidi/transport.rbs +43 -0
  80. data/sig/puppeteer/bidi/wait_task.rbs +62 -0
  81. data/sig/puppeteer/bidi.rbs +7 -5
  82. metadata +35 -1
@@ -19,17 +19,17 @@ module Puppeteer
19
19
  BoxModel = Data.define(:content, :padding, :border, :margin, :width, :height)
20
20
 
21
21
  # Factory method to create ElementHandle from remote value
22
- # @rbs remote_value: Hash[String, untyped]
23
- # @rbs realm: Core::Realm
24
- # @rbs return: ElementHandle
22
+ # @rbs remote_value: Hash[String, untyped] -- BiDi RemoteValue
23
+ # @rbs realm: Core::Realm -- Associated realm
24
+ # @rbs return: ElementHandle -- ElementHandle instance
25
25
  def self.from(remote_value, realm)
26
26
  new(realm, remote_value)
27
27
  end
28
28
 
29
29
  # Query for a descendant element matching the selector
30
30
  # Supports CSS selectors and prefixed selectors (xpath/, text/, aria/, pierce/)
31
- # @rbs selector: String
32
- # @rbs return: ElementHandle?
31
+ # @rbs selector: String -- Selector to query
32
+ # @rbs return: ElementHandle? -- Matching element or nil
33
33
  def query_selector(selector)
34
34
  assert_not_disposed
35
35
 
@@ -39,8 +39,8 @@ module Puppeteer
39
39
 
40
40
  # Query for all descendant elements matching the selector
41
41
  # Supports CSS selectors and prefixed selectors (xpath/, text/, aria/, pierce/)
42
- # @rbs selector: String
43
- # @rbs return: Array[ElementHandle]
42
+ # @rbs selector: String -- Selector to query
43
+ # @rbs return: Array[ElementHandle] -- All matching elements
44
44
  def query_selector_all(selector)
45
45
  assert_not_disposed
46
46
 
@@ -49,10 +49,10 @@ module Puppeteer
49
49
  end
50
50
 
51
51
  # Evaluate a function on the first element matching the selector
52
- # @rbs selector: String
53
- # @rbs page_function: String
54
- # @rbs *args: untyped
55
- # @rbs return: untyped
52
+ # @rbs selector: String -- Selector to query
53
+ # @rbs page_function: String -- JavaScript function to evaluate
54
+ # @rbs *args: untyped -- Arguments to pass to the function
55
+ # @rbs return: untyped -- Evaluation result
56
56
  def eval_on_selector(selector, page_function, *args)
57
57
  assert_not_disposed
58
58
 
@@ -67,10 +67,10 @@ module Puppeteer
67
67
  end
68
68
 
69
69
  # Evaluate a function on all elements matching the selector
70
- # @rbs selector: String
71
- # @rbs page_function: String
72
- # @rbs *args: untyped
73
- # @rbs return: untyped
70
+ # @rbs selector: String -- Selector to query
71
+ # @rbs page_function: String -- JavaScript function to evaluate
72
+ # @rbs *args: untyped -- Arguments to pass to the function
73
+ # @rbs return: untyped -- Evaluation result
74
74
  def eval_on_selector_all(selector, page_function, *args)
75
75
  assert_not_disposed
76
76
 
@@ -102,22 +102,22 @@ module Puppeteer
102
102
  end
103
103
 
104
104
  # Wait for an element matching the selector to appear as a descendant of this element
105
- # @rbs selector: String
106
- # @rbs visible: bool?
107
- # @rbs hidden: bool?
108
- # @rbs timeout: Numeric?
109
- # @rbs &block: ((ElementHandle?) -> void)?
110
- # @rbs return: ElementHandle?
105
+ # @rbs selector: String -- Selector to wait for
106
+ # @rbs visible: bool? -- Wait for element to be visible
107
+ # @rbs hidden: bool? -- Wait for element to be hidden
108
+ # @rbs timeout: Numeric? -- Wait timeout in ms
109
+ # @rbs &block: ((ElementHandle?) -> void)? -- Optional block called with element
110
+ # @rbs return: ElementHandle? -- Element or nil if hidden
111
111
  def wait_for_selector(selector, visible: nil, hidden: nil, timeout: nil, &block)
112
112
  result = QueryHandler.instance.get_query_handler_and_selector(selector)
113
113
  result.query_handler.new.wait_for(self, result.updated_selector, visible: visible, hidden: hidden, polling: result.polling, timeout: timeout, &block)
114
114
  end
115
115
 
116
116
  # Click the element
117
- # @rbs button: String
118
- # @rbs count: Integer
119
- # @rbs delay: Numeric?
120
- # @rbs offset: Hash[Symbol, Numeric]?
117
+ # @rbs button: String -- Mouse button ('left', 'right', 'middle')
118
+ # @rbs count: Integer -- Number of clicks
119
+ # @rbs delay: Numeric? -- Delay between clicks in ms
120
+ # @rbs offset: Hash[Symbol, Numeric]? -- Click offset from element center
121
121
  # @rbs return: void
122
122
  def click(button: 'left', count: 1, delay: nil, offset: nil)
123
123
  assert_not_disposed
@@ -129,8 +129,8 @@ module Puppeteer
129
129
  end
130
130
 
131
131
  # Type text into the element
132
- # @rbs text: String
133
- # @rbs delay: Numeric
132
+ # @rbs text: String -- Text to type
133
+ # @rbs delay: Numeric -- Delay between key presses in ms
134
134
  # @rbs return: void
135
135
  def type(text, delay: 0)
136
136
  assert_not_disposed
@@ -145,9 +145,9 @@ module Puppeteer
145
145
  end
146
146
 
147
147
  # Press a key on the element
148
- # @rbs key: String
149
- # @rbs delay: Numeric?
150
- # @rbs text: String?
148
+ # @rbs key: String -- Key to press
149
+ # @rbs delay: Numeric? -- Delay between keydown and keyup in ms
150
+ # @rbs text: String? -- Text to send with key press
151
151
  # @rbs return: void
152
152
  def press(key, delay: nil, text: nil)
153
153
  assert_not_disposed
@@ -163,14 +163,14 @@ module Puppeteer
163
163
 
164
164
  # Get the frame this element belongs to
165
165
  # Following Puppeteer's pattern: realm.environment
166
- # @rbs return: Frame
166
+ # @rbs return: Frame -- Owning frame
167
167
  def frame
168
168
  @realm.environment
169
169
  end
170
170
 
171
171
  # Get the content frame for iframe/frame elements
172
172
  # Returns the frame that the iframe/frame element refers to
173
- # @rbs return: Frame?
173
+ # @rbs return: Frame? -- Content frame or nil
174
174
  def content_frame
175
175
  assert_not_disposed
176
176
 
@@ -204,7 +204,7 @@ module Puppeteer
204
204
  # - It has computed styles
205
205
  # - Its visibility is not 'hidden' or 'collapse'
206
206
  # - Its bounding box is not empty (width > 0 AND height > 0)
207
- # @rbs return: bool
207
+ # @rbs return: bool -- Whether element is visible
208
208
  def visible?
209
209
  check_visibility(true)
210
210
  end
@@ -214,15 +214,15 @@ module Puppeteer
214
214
  # - It has no computed styles
215
215
  # - Its visibility is 'hidden' or 'collapse'
216
216
  # - Its bounding box is empty (width == 0 OR height == 0)
217
- # @rbs return: bool
217
+ # @rbs return: bool -- Whether element is hidden
218
218
  def hidden?
219
219
  check_visibility(false)
220
220
  end
221
221
 
222
222
  # Convert the current handle to the given element type
223
223
  # Validates that the element matches the expected tag name
224
- # @rbs tag_name: String
225
- # @rbs return: ElementHandle
224
+ # @rbs tag_name: String -- Expected tag name
225
+ # @rbs return: ElementHandle -- This element if matching
226
226
  def to_element(tag_name)
227
227
  assert_not_disposed
228
228
 
@@ -253,7 +253,7 @@ module Puppeteer
253
253
 
254
254
  # Upload files to this element (for <input type="file">)
255
255
  # Following Puppeteer's implementation: ElementHandle.uploadFile -> Frame.setFiles
256
- # @rbs *files: String
256
+ # @rbs *files: String -- File paths to upload
257
257
  # @rbs return: void
258
258
  def upload_file(*files)
259
259
  assert_not_disposed
@@ -271,7 +271,7 @@ module Puppeteer
271
271
  end
272
272
 
273
273
  # Get the remote value as a SharedReference for BiDi commands
274
- # @rbs return: Hash[Symbol, String]
274
+ # @rbs return: Hash[Symbol, String] -- SharedReference for BiDi
275
275
  def remote_value_as_shared_reference
276
276
  if @remote_value['sharedId']
277
277
  { sharedId: @remote_value['sharedId'] }
@@ -300,8 +300,8 @@ module Puppeteer
300
300
  end
301
301
 
302
302
  # Check if element is intersecting the viewport
303
- # @rbs threshold: Numeric
304
- # @rbs return: bool
303
+ # @rbs threshold: Numeric -- Intersection ratio threshold
304
+ # @rbs return: bool -- Whether element intersects viewport
305
305
  def intersecting_viewport?(threshold: 0)
306
306
  assert_not_disposed
307
307
 
@@ -321,8 +321,8 @@ module Puppeteer
321
321
  end
322
322
 
323
323
  # Get clickable point for the element
324
- # @rbs offset: Hash[Symbol, Numeric]?
325
- # @rbs return: Point
324
+ # @rbs offset: Hash[Symbol, Numeric]? -- Offset from element center
325
+ # @rbs return: Point -- Clickable point coordinates
326
326
  def clickable_point(offset: nil)
327
327
  assert_not_disposed
328
328
 
@@ -344,7 +344,7 @@ module Puppeteer
344
344
 
345
345
  # Get the bounding box of the element
346
346
  # Uses getBoundingClientRect() to get the element's position and size
347
- # @rbs return: BoundingBox?
347
+ # @rbs return: BoundingBox? -- Bounding box or nil if not visible
348
348
  def bounding_box
349
349
  assert_not_disposed
350
350
 
@@ -372,7 +372,7 @@ module Puppeteer
372
372
  end
373
373
 
374
374
  # Get the box model of the element (content, padding, border, margin)
375
- # @rbs return: BoxModel?
375
+ # @rbs return: BoxModel? -- Box model or nil if not visible
376
376
  def box_model
377
377
  assert_not_disposed
378
378
 
@@ -465,7 +465,7 @@ module Puppeteer
465
465
  # Uses getClientRects() to handle wrapped/multi-line elements correctly
466
466
  # Following Puppeteer's implementation:
467
467
  # https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/api/ElementHandle.ts#clickableBox
468
- # @rbs return: Hash[Symbol, Numeric]?
468
+ # @rbs return: Hash[Symbol, Numeric]? -- Clickable box or nil
469
469
  def clickable_box
470
470
  assert_not_disposed
471
471
 
@@ -508,7 +508,7 @@ module Puppeteer
508
508
 
509
509
  # Intersect bounding boxes with frame viewport boundaries
510
510
  # Modifies boxes in-place to clip them to visible area
511
- # @rbs boxes: Array[Hash[String, Numeric]]
511
+ # @rbs boxes: Array[Hash[String, Numeric]] -- Bounding boxes to clip
512
512
  # @rbs return: void
513
513
  def intersect_bounding_boxes_with_frame(boxes)
514
514
  # Get document dimensions using element's evaluate (which handles deserialization)
@@ -532,9 +532,9 @@ module Puppeteer
532
532
 
533
533
  # Intersect a single bounding box with given width/height boundaries
534
534
  # Modifies box in-place
535
- # @rbs box: Hash[String, Numeric]
536
- # @rbs width: Numeric
537
- # @rbs height: Numeric
535
+ # @rbs box: Hash[String, Numeric] -- Box to clip
536
+ # @rbs width: Numeric -- Viewport width
537
+ # @rbs height: Numeric -- Viewport height
538
538
  # @rbs return: void
539
539
  def intersect_bounding_box(box, width, height)
540
540
  # Clip width
@@ -559,8 +559,8 @@ module Puppeteer
559
559
  end
560
560
 
561
561
  # Check element visibility
562
- # @rbs visible: bool
563
- # @rbs return: bool
562
+ # @rbs visible: bool -- Expected visibility state
563
+ # @rbs return: bool -- Whether element matches visibility state
564
564
  def check_visibility(visible)
565
565
  assert_not_disposed
566
566
 
@@ -592,7 +592,7 @@ module Puppeteer
592
592
  end
593
593
 
594
594
  # String representation includes element type
595
- # @rbs return: String
595
+ # @rbs return: String -- String representation
596
596
  def to_s
597
597
  return 'ElementHandle@disposed' if disposed?
598
598
  'ElementHandle@node'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rbs_inline: enabled
2
3
 
3
4
  module Puppeteer
4
5
  module Bidi
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rbs_inline: enabled
2
3
 
3
4
  module Puppeteer
4
5
  module Bidi
@@ -10,17 +10,17 @@ module Puppeteer
10
10
  attr_reader :browsing_context #: Core::BrowsingContext
11
11
 
12
12
  # Factory method following Puppeteer's BidiFrame.from pattern
13
- # @rbs parent: Page | Frame
14
- # @rbs browsing_context: Core::BrowsingContext
15
- # @rbs return: Frame
13
+ # @rbs parent: Page | Frame -- Parent page or frame
14
+ # @rbs browsing_context: Core::BrowsingContext -- Associated browsing context
15
+ # @rbs return: Frame -- New frame instance
16
16
  def self.from(parent, browsing_context)
17
17
  frame = new(parent, browsing_context)
18
18
  frame.send(:initialize_frame)
19
19
  frame
20
20
  end
21
21
 
22
- # @rbs parent: Page | Frame
23
- # @rbs browsing_context: Core::BrowsingContext
22
+ # @rbs parent: Page | Frame -- Parent page or frame
23
+ # @rbs browsing_context: Core::BrowsingContext -- Associated browsing context
24
24
  # @rbs return: void
25
25
  def initialize(parent, browsing_context)
26
26
  @parent = parent
@@ -34,55 +34,55 @@ module Puppeteer
34
34
  @isolated_realm = FrameRealm.new(self, internal_core_realm)
35
35
  end
36
36
 
37
- # @rbs return: FrameRealm
37
+ # @rbs return: FrameRealm -- Main execution realm
38
38
  def main_realm
39
39
  @main_realm
40
40
  end
41
41
 
42
- # @rbs return: FrameRealm
42
+ # @rbs return: FrameRealm -- Isolated execution realm
43
43
  def isolated_realm
44
44
  @isolated_realm
45
45
  end
46
46
 
47
47
  # Backwards compatibility for call sites that previously accessed Frame#realm.
48
- # @rbs return: FrameRealm
48
+ # @rbs return: FrameRealm -- Main execution realm
49
49
  def realm
50
50
  main_realm
51
51
  end
52
52
 
53
53
  # Get the page that owns this frame
54
54
  # Traverses up the parent chain until reaching a Page
55
- # @rbs return: Page
55
+ # @rbs return: Page -- Owning page
56
56
  def page
57
57
  @parent.is_a?(Page) ? @parent : @parent.page
58
58
  end
59
59
 
60
60
  # Get the parent frame
61
- # @rbs return: Frame?
61
+ # @rbs return: Frame? -- Parent frame or nil for main frame
62
62
  def parent_frame
63
63
  @parent.is_a?(Frame) ? @parent : nil
64
64
  end
65
65
 
66
66
  # Evaluate JavaScript in the frame context
67
- # @rbs script: String
68
- # @rbs *args: untyped
69
- # @rbs return: untyped
67
+ # @rbs script: String -- JavaScript code to evaluate
68
+ # @rbs *args: untyped -- Arguments to pass to the script
69
+ # @rbs return: untyped -- Evaluation result
70
70
  def evaluate(script, *args)
71
71
  assert_not_detached
72
72
  main_realm.evaluate(script, *args)
73
73
  end
74
74
 
75
75
  # Evaluate JavaScript and return a handle to the result
76
- # @rbs script: String
77
- # @rbs *args: untyped
78
- # @rbs return: JSHandle
76
+ # @rbs script: String -- JavaScript code to evaluate
77
+ # @rbs *args: untyped -- Arguments to pass to the script
78
+ # @rbs return: JSHandle -- Handle to the result
79
79
  def evaluate_handle(script, *args)
80
80
  assert_not_detached
81
81
  main_realm.evaluate_handle(script, *args)
82
82
  end
83
83
 
84
84
  # Get the document element handle
85
- # @rbs return: ElementHandle
85
+ # @rbs return: ElementHandle -- Document element handle
86
86
  def document
87
87
  assert_not_detached
88
88
  handle = main_realm.evaluate_handle('document')
@@ -94,8 +94,8 @@ module Puppeteer
94
94
  end
95
95
 
96
96
  # Query for an element matching the selector
97
- # @rbs selector: String
98
- # @rbs return: ElementHandle?
97
+ # @rbs selector: String -- Selector to query
98
+ # @rbs return: ElementHandle? -- Matching element or nil
99
99
  def query_selector(selector)
100
100
  doc = document
101
101
  begin
@@ -106,8 +106,8 @@ module Puppeteer
106
106
  end
107
107
 
108
108
  # Query for all elements matching the selector
109
- # @rbs selector: String
110
- # @rbs return: Array[ElementHandle]
109
+ # @rbs selector: String -- Selector to query
110
+ # @rbs return: Array[ElementHandle] -- All matching elements
111
111
  def query_selector_all(selector)
112
112
  doc = document
113
113
  begin
@@ -118,10 +118,10 @@ module Puppeteer
118
118
  end
119
119
 
120
120
  # Evaluate a function on the first element matching the selector
121
- # @rbs selector: String
122
- # @rbs page_function: String
123
- # @rbs *args: untyped
124
- # @rbs return: untyped
121
+ # @rbs selector: String -- Selector to query
122
+ # @rbs page_function: String -- JavaScript function to evaluate
123
+ # @rbs *args: untyped -- Arguments to pass to the function
124
+ # @rbs return: untyped -- Evaluation result
125
125
  def eval_on_selector(selector, page_function, *args)
126
126
  doc = document
127
127
  begin
@@ -132,10 +132,10 @@ module Puppeteer
132
132
  end
133
133
 
134
134
  # Evaluate a function on all elements matching the selector
135
- # @rbs selector: String
136
- # @rbs page_function: String
137
- # @rbs *args: untyped
138
- # @rbs return: untyped
135
+ # @rbs selector: String -- Selector to query
136
+ # @rbs page_function: String -- JavaScript function to evaluate
137
+ # @rbs *args: untyped -- Arguments to pass to the function
138
+ # @rbs return: untyped -- Evaluation result
139
139
  def eval_on_selector_all(selector, page_function, *args)
140
140
  doc = document
141
141
  begin
@@ -146,11 +146,11 @@ module Puppeteer
146
146
  end
147
147
 
148
148
  # Click an element matching the selector
149
- # @rbs selector: String
150
- # @rbs button: String
151
- # @rbs count: Integer
152
- # @rbs delay: Numeric?
153
- # @rbs offset: Hash[Symbol, Numeric]?
149
+ # @rbs selector: String -- Selector to click
150
+ # @rbs button: String -- Mouse button ('left', 'right', 'middle')
151
+ # @rbs count: Integer -- Number of clicks
152
+ # @rbs delay: Numeric? -- Delay between clicks in ms
153
+ # @rbs offset: Hash[Symbol, Numeric]? -- Click offset from element center
154
154
  # @rbs return: void
155
155
  def click(selector, button: 'left', count: 1, delay: nil, offset: nil)
156
156
  assert_not_detached
@@ -166,9 +166,9 @@ module Puppeteer
166
166
  end
167
167
 
168
168
  # Type text into an element matching the selector
169
- # @rbs selector: String
170
- # @rbs text: String
171
- # @rbs delay: Numeric
169
+ # @rbs selector: String -- Selector to type into
170
+ # @rbs text: String -- Text to type
171
+ # @rbs delay: Numeric -- Delay between key presses in ms
172
172
  # @rbs return: void
173
173
  def type(selector, text, delay: 0)
174
174
  assert_not_detached
@@ -184,7 +184,7 @@ module Puppeteer
184
184
  end
185
185
 
186
186
  # Hover over an element matching the selector
187
- # @rbs selector: String
187
+ # @rbs selector: String -- Selector to hover
188
188
  # @rbs return: void
189
189
  def hover(selector)
190
190
  assert_not_detached
@@ -200,16 +200,16 @@ module Puppeteer
200
200
  end
201
201
 
202
202
  # Get the frame URL
203
- # @rbs return: String
203
+ # @rbs return: String -- Current URL
204
204
  def url
205
205
  @browsing_context.url
206
206
  end
207
207
 
208
208
  # Navigate to a URL
209
- # @rbs url: String
210
- # @rbs wait_until: String
211
- # @rbs timeout: Numeric
212
- # @rbs return: HTTPResponse?
209
+ # @rbs url: String -- URL to navigate to
210
+ # @rbs wait_until: String -- When to consider navigation complete ('load', 'domcontentloaded')
211
+ # @rbs timeout: Numeric -- Navigation timeout in ms
212
+ # @rbs return: HTTPResponse? -- Response or nil
213
213
  def goto(url, wait_until: 'load', timeout: 30000)
214
214
  response = wait_for_navigation(timeout: timeout, wait_until: wait_until) do
215
215
  @browsing_context.navigate(url, wait: 'interactive').wait
@@ -221,8 +221,8 @@ module Puppeteer
221
221
  end
222
222
 
223
223
  # Set frame content
224
- # @rbs html: String
225
- # @rbs wait_until: String
224
+ # @rbs html: String -- HTML content to set
225
+ # @rbs wait_until: String -- When to consider content set ('load', 'domcontentloaded')
226
226
  # @rbs return: void
227
227
  def set_content(html, wait_until: 'load')
228
228
  assert_not_detached
@@ -259,7 +259,7 @@ module Puppeteer
259
259
 
260
260
  # Set frame content using document.open/write/close
261
261
  # This is a low-level method that doesn't wait for load events
262
- # @rbs content: String
262
+ # @rbs content: String -- HTML content to set
263
263
  # @rbs return: void
264
264
  def set_frame_content(content)
265
265
  assert_not_detached
@@ -274,20 +274,20 @@ module Puppeteer
274
274
  end
275
275
 
276
276
  # Get the frame name
277
- # @rbs return: String
277
+ # @rbs return: String -- Frame name
278
278
  def name
279
279
  @_name || ''
280
280
  end
281
281
 
282
282
  # Check if frame is detached
283
- # @rbs return: bool
283
+ # @rbs return: bool -- Whether frame is detached
284
284
  def detached?
285
285
  @browsing_context.closed?
286
286
  end
287
287
 
288
288
  # Get child frames
289
289
  # Returns cached frame instances following Puppeteer's pattern
290
- # @rbs return: Array[Frame]
290
+ # @rbs return: Array[Frame] -- Child frames
291
291
  def child_frames
292
292
  @browsing_context.children.map do |child_context|
293
293
  @frames[child_context.id]
@@ -297,7 +297,7 @@ module Puppeteer
297
297
  # Get the frame element (iframe/frame DOM element) for this frame
298
298
  # Returns nil for the main frame
299
299
  # Following Puppeteer's Frame.frameElement() implementation exactly
300
- # @rbs return: ElementHandle?
300
+ # @rbs return: ElementHandle? -- Frame element or nil for main frame
301
301
  def frame_element
302
302
  assert_not_detached
303
303
 
@@ -333,10 +333,10 @@ module Puppeteer
333
333
  end
334
334
 
335
335
  # Wait for navigation to complete
336
- # @rbs timeout: Numeric
337
- # @rbs wait_until: String | Array[String]
338
- # @rbs &block: (-> void)?
339
- # @rbs return: HTTPResponse?
336
+ # @rbs timeout: Numeric -- Navigation timeout in ms
337
+ # @rbs wait_until: String | Array[String] -- When to consider navigation complete
338
+ # @rbs &block: (-> void)? -- Optional block to trigger navigation
339
+ # @rbs return: HTTPResponse? -- Response or nil
340
340
  def wait_for_navigation(timeout: 30000, wait_until: 'load', &block)
341
341
  assert_not_detached
342
342
 
@@ -478,30 +478,30 @@ module Puppeteer
478
478
  end
479
479
 
480
480
  # Wait for a function to return a truthy value
481
- # @rbs page_function: String
482
- # @rbs options: Hash[Symbol, untyped]
483
- # @rbs *args: untyped
484
- # @rbs &block: ((JSHandle) -> void)?
485
- # @rbs return: JSHandle
481
+ # @rbs page_function: String -- JavaScript function to evaluate
482
+ # @rbs options: Hash[Symbol, untyped] -- Wait options (timeout, polling)
483
+ # @rbs *args: untyped -- Arguments to pass to the function
484
+ # @rbs &block: ((JSHandle) -> void)? -- Optional block called with result
485
+ # @rbs return: JSHandle -- Handle to the truthy result
486
486
  def wait_for_function(page_function, options = {}, *args, &block)
487
487
  main_realm.wait_for_function(page_function, options, *args, &block)
488
488
  end
489
489
 
490
490
  # Wait for an element matching the selector to appear in the frame
491
- # @rbs selector: String
492
- # @rbs visible: bool?
493
- # @rbs hidden: bool?
494
- # @rbs timeout: Numeric?
495
- # @rbs &block: ((ElementHandle?) -> void)?
496
- # @rbs return: ElementHandle?
491
+ # @rbs selector: String -- Selector to wait for
492
+ # @rbs visible: bool? -- Wait for element to be visible
493
+ # @rbs hidden: bool? -- Wait for element to be hidden
494
+ # @rbs timeout: Numeric? -- Wait timeout in ms
495
+ # @rbs &block: ((ElementHandle?) -> void)? -- Optional block called with element
496
+ # @rbs return: ElementHandle? -- Element or nil if hidden
497
497
  def wait_for_selector(selector, visible: nil, hidden: nil, timeout: nil, &block)
498
498
  result = QueryHandler.instance.get_query_handler_and_selector(selector)
499
499
  result.query_handler.new.wait_for(self, result.updated_selector, visible: visible, hidden: hidden, polling: result.polling, timeout: timeout, &block)
500
500
  end
501
501
 
502
502
  # Set files on an input element
503
- # @rbs element: ElementHandle
504
- # @rbs files: Array[String]
503
+ # @rbs element: ElementHandle -- Input element
504
+ # @rbs files: Array[String] -- File paths to set
505
505
  # @rbs return: void
506
506
  def set_files(element, files)
507
507
  assert_not_detached
@@ -514,7 +514,7 @@ module Puppeteer
514
514
 
515
515
  # Get the frame ID (browsing context ID)
516
516
  # Following Puppeteer's _id pattern
517
- # @rbs return: String
517
+ # @rbs return: String -- Frame ID
518
518
  def _id
519
519
  @browsing_context.id
520
520
  end
@@ -568,8 +568,8 @@ module Puppeteer
568
568
  # });
569
569
  # Note: FrameDetached is NOT emitted here - it's emitted in #initialize
570
570
  # when the frame's own browsing context closes
571
- # @rbs browsing_context: Core::BrowsingContext
572
- # @rbs return: Frame
571
+ # @rbs browsing_context: Core::BrowsingContext -- Child browsing context
572
+ # @rbs return: Frame -- New child frame
573
573
  def create_frame_target(browsing_context)
574
574
  frame = Frame.from(self, browsing_context)
575
575
  @frames[browsing_context.id] = frame
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rbs_inline: enabled
2
3
 
3
4
  module Puppeteer
4
5
  module Bidi
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rbs_inline: enabled
2
3
 
3
4
  module Puppeteer
4
5
  module Bidi