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.
- checksums.yaml +4 -4
- data/CLAUDE.md +44 -0
- data/README.md +8 -1
- data/Steepfile +36 -0
- data/lib/puppeteer/bidi/async_utils.rb +1 -0
- data/lib/puppeteer/bidi/browser.rb +43 -24
- data/lib/puppeteer/bidi/browser_context.rb +13 -4
- data/lib/puppeteer/bidi/browser_launcher.rb +1 -0
- data/lib/puppeteer/bidi/connection.rb +26 -9
- data/lib/puppeteer/bidi/core/browser.rb +15 -14
- data/lib/puppeteer/bidi/core/browsing_context.rb +64 -46
- data/lib/puppeteer/bidi/core/disposable.rb +10 -3
- data/lib/puppeteer/bidi/core/errors.rb +18 -1
- data/lib/puppeteer/bidi/core/event_emitter.rb +18 -9
- data/lib/puppeteer/bidi/core/navigation.rb +4 -3
- data/lib/puppeteer/bidi/core/realm.rb +29 -26
- data/lib/puppeteer/bidi/core/request.rb +33 -29
- data/lib/puppeteer/bidi/core/session.rb +14 -11
- data/lib/puppeteer/bidi/core/user_context.rb +17 -16
- data/lib/puppeteer/bidi/core/user_prompt.rb +8 -7
- data/lib/puppeteer/bidi/core.rb +1 -0
- data/lib/puppeteer/bidi/deserializer.rb +1 -0
- data/lib/puppeteer/bidi/element_handle.rb +52 -52
- data/lib/puppeteer/bidi/errors.rb +1 -0
- data/lib/puppeteer/bidi/file_chooser.rb +1 -0
- data/lib/puppeteer/bidi/frame.rb +70 -70
- data/lib/puppeteer/bidi/http_response.rb +1 -0
- data/lib/puppeteer/bidi/injected_source.rb +1 -0
- data/lib/puppeteer/bidi/js_handle.rb +23 -23
- data/lib/puppeteer/bidi/keyboard.rb +24 -13
- data/lib/puppeteer/bidi/lazy_arg.rb +1 -0
- data/lib/puppeteer/bidi/mouse.rb +31 -18
- data/lib/puppeteer/bidi/page.rb +87 -87
- data/lib/puppeteer/bidi/query_handler.rb +3 -0
- data/lib/puppeteer/bidi/realm.rb +70 -6
- data/lib/puppeteer/bidi/serializer.rb +1 -0
- data/lib/puppeteer/bidi/target.rb +27 -0
- data/lib/puppeteer/bidi/timeout_settings.rb +1 -0
- data/lib/puppeteer/bidi/transport.rb +1 -0
- data/lib/puppeteer/bidi/version.rb +1 -1
- data/lib/puppeteer/bidi/wait_task.rb +1 -0
- data/lib/puppeteer/bidi.rb +13 -4
- data/sig/_external.rbs +134 -0
- data/sig/_supplementary.rbs +20 -0
- data/sig/puppeteer/bidi/async_utils.rbs +68 -0
- data/sig/puppeteer/bidi/browser.rbs +34 -27
- data/sig/puppeteer/bidi/browser_context.rbs +39 -0
- data/sig/puppeteer/bidi/browser_launcher.rbs +45 -0
- data/sig/puppeteer/bidi/connection.rbs +67 -0
- data/sig/puppeteer/bidi/core/browser.rbs +79 -0
- data/sig/puppeteer/bidi/core/browsing_context.rbs +210 -0
- data/sig/puppeteer/bidi/core/disposable.rbs +42 -0
- data/sig/puppeteer/bidi/core/errors.rbs +65 -0
- data/sig/puppeteer/bidi/core/event_emitter.rbs +50 -0
- data/sig/puppeteer/bidi/core/navigation.rbs +37 -0
- data/sig/puppeteer/bidi/core/realm.rbs +132 -0
- data/sig/puppeteer/bidi/core/request.rbs +120 -0
- data/sig/puppeteer/bidi/core/session.rbs +65 -0
- data/sig/puppeteer/bidi/core/user_context.rbs +72 -0
- data/sig/puppeteer/bidi/core/user_prompt.rbs +52 -0
- data/sig/puppeteer/bidi/core.rbs +9 -0
- data/sig/puppeteer/bidi/deserializer.rbs +28 -0
- data/sig/puppeteer/bidi/element_handle.rbs +52 -52
- data/sig/puppeteer/bidi/errors.rbs +34 -0
- data/sig/puppeteer/bidi/file_chooser.rbs +27 -0
- data/sig/puppeteer/bidi/frame.rbs +70 -70
- data/sig/puppeteer/bidi/http_response.rbs +18 -0
- data/sig/puppeteer/bidi/injected_source.rbs +21 -0
- data/sig/puppeteer/bidi/js_handle.rbs +23 -23
- data/sig/puppeteer/bidi/keyboard.rbs +57 -0
- data/sig/puppeteer/bidi/lazy_arg.rbs +15 -0
- data/sig/puppeteer/bidi/mouse.rbs +73 -0
- data/sig/puppeteer/bidi/page.rbs +87 -87
- data/sig/puppeteer/bidi/query_handler.rbs +113 -0
- data/sig/puppeteer/bidi/realm.rbs +141 -0
- data/sig/puppeteer/bidi/serializer.rbs +31 -0
- data/sig/puppeteer/bidi/target.rbs +68 -0
- data/sig/puppeteer/bidi/timeout_settings.rbs +14 -0
- data/sig/puppeteer/bidi/transport.rbs +43 -0
- data/sig/puppeteer/bidi/wait_task.rbs +62 -0
- data/sig/puppeteer/bidi.rbs +7 -5
- metadata +35 -1
|
@@ -8,8 +8,8 @@ module Puppeteer
|
|
|
8
8
|
class JSHandle
|
|
9
9
|
attr_reader :realm #: Core::Realm
|
|
10
10
|
|
|
11
|
-
# @rbs remote_value: Hash[String, untyped]
|
|
12
|
-
# @rbs realm: Core::Realm
|
|
11
|
+
# @rbs remote_value: Hash[String, untyped] -- BiDi RemoteValue
|
|
12
|
+
# @rbs realm: Core::Realm -- Associated realm
|
|
13
13
|
# @rbs return: void
|
|
14
14
|
def initialize(realm, remote_value)
|
|
15
15
|
@realm = realm
|
|
@@ -18,9 +18,9 @@ module Puppeteer
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Factory method to create JSHandle from remote value
|
|
21
|
-
# @rbs remote_value: Hash[String, untyped]
|
|
22
|
-
# @rbs realm: Core::Realm
|
|
23
|
-
# @rbs return: JSHandle | ElementHandle
|
|
21
|
+
# @rbs remote_value: Hash[String, untyped] -- BiDi RemoteValue
|
|
22
|
+
# @rbs realm: Core::Realm -- Associated realm
|
|
23
|
+
# @rbs return: JSHandle | ElementHandle -- JSHandle or ElementHandle instance
|
|
24
24
|
def self.from(remote_value, realm)
|
|
25
25
|
if remote_value['type'] == 'node'
|
|
26
26
|
ElementHandle.new(realm, remote_value)
|
|
@@ -30,19 +30,19 @@ module Puppeteer
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Get the remote value (BiDi Script.RemoteValue)
|
|
33
|
-
# @rbs return: Hash[String, untyped]
|
|
33
|
+
# @rbs return: Hash[String, untyped] -- BiDi RemoteValue
|
|
34
34
|
def remote_value
|
|
35
35
|
@remote_value
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# Get the remote object (alias for remote_value)
|
|
39
|
-
# @rbs return: Hash[String, untyped]
|
|
39
|
+
# @rbs return: Hash[String, untyped] -- BiDi RemoteValue
|
|
40
40
|
def remote_object
|
|
41
41
|
@remote_value
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Check if handle has been disposed
|
|
45
|
-
# @rbs return: bool
|
|
45
|
+
# @rbs return: bool -- Whether handle is disposed
|
|
46
46
|
def disposed?
|
|
47
47
|
@disposed
|
|
48
48
|
end
|
|
@@ -60,15 +60,15 @@ module Puppeteer
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Get the handle ID (handle or sharedId)
|
|
63
|
-
# @rbs return: String?
|
|
63
|
+
# @rbs return: String? -- Handle ID or nil
|
|
64
64
|
def id
|
|
65
65
|
@remote_value['handle'] || @remote_value['sharedId']
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Evaluate JavaScript function with this handle as the first argument
|
|
69
|
-
# @rbs script: String
|
|
70
|
-
# @rbs *args: untyped
|
|
71
|
-
# @rbs return: untyped
|
|
69
|
+
# @rbs script: String -- JavaScript code to evaluate
|
|
70
|
+
# @rbs *args: untyped -- Arguments to pass to the script
|
|
71
|
+
# @rbs return: untyped -- Evaluation result
|
|
72
72
|
def evaluate(script, *args)
|
|
73
73
|
assert_not_disposed
|
|
74
74
|
|
|
@@ -87,9 +87,9 @@ module Puppeteer
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Evaluate JavaScript function and return a handle to the result
|
|
90
|
-
# @rbs script: String
|
|
91
|
-
# @rbs *args: untyped
|
|
92
|
-
# @rbs return: JSHandle
|
|
90
|
+
# @rbs script: String -- JavaScript code to evaluate
|
|
91
|
+
# @rbs *args: untyped -- Arguments to pass to the script
|
|
92
|
+
# @rbs return: JSHandle -- Handle to the result
|
|
93
93
|
def evaluate_handle(script, *args)
|
|
94
94
|
assert_not_disposed
|
|
95
95
|
|
|
@@ -109,8 +109,8 @@ module Puppeteer
|
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
# Get a property of the object
|
|
112
|
-
# @rbs property_name: String
|
|
113
|
-
# @rbs return: JSHandle
|
|
112
|
+
# @rbs property_name: String -- Property name to get
|
|
113
|
+
# @rbs return: JSHandle -- Handle to the property value
|
|
114
114
|
def get_property(property_name)
|
|
115
115
|
assert_not_disposed
|
|
116
116
|
|
|
@@ -133,7 +133,7 @@ module Puppeteer
|
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
# Get all properties of the object
|
|
136
|
-
# @rbs return: Hash[String, JSHandle]
|
|
136
|
+
# @rbs return: Hash[String, JSHandle] -- Map of property names to handles
|
|
137
137
|
def get_properties
|
|
138
138
|
assert_not_disposed
|
|
139
139
|
|
|
@@ -212,7 +212,7 @@ module Puppeteer
|
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
# Convert this handle to a JSON-serializable value
|
|
215
|
-
# @rbs return: untyped
|
|
215
|
+
# @rbs return: untyped -- JSON-serializable value
|
|
216
216
|
def json_value
|
|
217
217
|
assert_not_disposed
|
|
218
218
|
|
|
@@ -222,7 +222,7 @@ module Puppeteer
|
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
# Convert to ElementHandle if this is an element
|
|
225
|
-
# @rbs return: ElementHandle?
|
|
225
|
+
# @rbs return: ElementHandle? -- ElementHandle or nil if not an element
|
|
226
226
|
def as_element
|
|
227
227
|
return nil unless @remote_value['type'] == 'node'
|
|
228
228
|
|
|
@@ -246,14 +246,14 @@ module Puppeteer
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
# Check if this is a primitive value
|
|
249
|
-
# @rbs return: bool
|
|
249
|
+
# @rbs return: bool -- Whether this is a primitive value
|
|
250
250
|
def primitive_value?
|
|
251
251
|
type = @remote_value['type']
|
|
252
252
|
%w[string number bigint boolean undefined null].include?(type)
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
# String representation of this handle
|
|
256
|
-
# @rbs return: String
|
|
256
|
+
# @rbs return: String -- String representation
|
|
257
257
|
def to_s
|
|
258
258
|
return 'JSHandle@disposed' if @disposed
|
|
259
259
|
|
|
@@ -279,7 +279,7 @@ module Puppeteer
|
|
|
279
279
|
end
|
|
280
280
|
|
|
281
281
|
# Handle evaluation exceptions
|
|
282
|
-
# @rbs result: Hash[String, untyped]
|
|
282
|
+
# @rbs result: Hash[String, untyped] -- Evaluation result containing exception
|
|
283
283
|
# @rbs return: void
|
|
284
284
|
def handle_evaluation_exception(result)
|
|
285
285
|
exception_details = result['exceptionDetails']
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
2
3
|
|
|
3
4
|
module Puppeteer
|
|
4
5
|
module Bidi
|
|
5
6
|
# Keyboard class for keyboard input operations
|
|
6
7
|
# Based on Puppeteer's BidiKeyboard implementation
|
|
7
8
|
class Keyboard
|
|
9
|
+
# @rbs page: Page -- Page instance
|
|
10
|
+
# @rbs browsing_context: Core::BrowsingContext -- Browsing context
|
|
11
|
+
# @rbs return: void
|
|
8
12
|
def initialize(page, browsing_context)
|
|
9
13
|
@page = page
|
|
10
14
|
@browsing_context = browsing_context
|
|
@@ -12,9 +16,10 @@ module Puppeteer
|
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
# Press key down
|
|
15
|
-
# @
|
|
16
|
-
# @
|
|
17
|
-
# @
|
|
19
|
+
# @rbs key: String -- Key name (e.g., 'a', 'Enter', 'ArrowLeft')
|
|
20
|
+
# @rbs text: String? -- Text to insert (for CDP compatibility, not used in BiDi)
|
|
21
|
+
# @rbs commands: Array[String]? -- Commands to trigger (for CDP compatibility, not used in BiDi)
|
|
22
|
+
# @rbs return: void
|
|
18
23
|
def down(key, text: nil, commands: nil)
|
|
19
24
|
# Note: text and commands parameters exist for CDP compatibility but are not used in BiDi
|
|
20
25
|
actions = [{
|
|
@@ -27,7 +32,8 @@ module Puppeteer
|
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
# Release key
|
|
30
|
-
# @
|
|
35
|
+
# @rbs key: String -- Key name
|
|
36
|
+
# @rbs return: void
|
|
31
37
|
def up(key)
|
|
32
38
|
actions = [{
|
|
33
39
|
type: 'keyUp',
|
|
@@ -39,10 +45,11 @@ module Puppeteer
|
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
# Press and release a key
|
|
42
|
-
# @
|
|
43
|
-
# @
|
|
44
|
-
# @
|
|
45
|
-
# @
|
|
48
|
+
# @rbs key: String -- Key name
|
|
49
|
+
# @rbs delay: Numeric? -- Delay between keydown and keyup in milliseconds
|
|
50
|
+
# @rbs text: String? -- Text to insert (for CDP compatibility, not used in BiDi)
|
|
51
|
+
# @rbs commands: Array[String]? -- Commands to trigger (for CDP compatibility, not used in BiDi)
|
|
52
|
+
# @rbs return: void
|
|
46
53
|
def press(key, delay: nil, text: nil, commands: nil)
|
|
47
54
|
# Note: text and commands parameters exist for CDP compatibility but are not used in BiDi
|
|
48
55
|
actions = [{ type: 'keyDown', value: get_bidi_key_value(key) }]
|
|
@@ -60,8 +67,9 @@ module Puppeteer
|
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
# Type text (types each character with keydown/keyup events)
|
|
63
|
-
# @
|
|
64
|
-
# @
|
|
70
|
+
# @rbs text: String -- Text to type
|
|
71
|
+
# @rbs delay: Numeric -- Delay between each character in milliseconds
|
|
72
|
+
# @rbs return: void
|
|
65
73
|
def type(text, delay: 0)
|
|
66
74
|
actions = []
|
|
67
75
|
|
|
@@ -84,7 +92,8 @@ module Puppeteer
|
|
|
84
92
|
end
|
|
85
93
|
|
|
86
94
|
# Send character directly (bypasses keyboard events, uses execCommand)
|
|
87
|
-
# @
|
|
95
|
+
# @rbs char: String -- Character to send
|
|
96
|
+
# @rbs return: void
|
|
88
97
|
def send_character(char)
|
|
89
98
|
# Validate: cannot send more than 1 character
|
|
90
99
|
# Measures the number of code points rather than UTF-16 code units
|
|
@@ -106,8 +115,8 @@ module Puppeteer
|
|
|
106
115
|
private
|
|
107
116
|
|
|
108
117
|
# Convert key name to BiDi protocol value
|
|
109
|
-
# @
|
|
110
|
-
# @return
|
|
118
|
+
# @rbs key: String -- Key name
|
|
119
|
+
# @rbs return: String -- BiDi key value (Unicode character or escape sequence)
|
|
111
120
|
def get_bidi_key_value(key)
|
|
112
121
|
# Normalize line breaks
|
|
113
122
|
normalized_key = case key
|
|
@@ -251,6 +260,8 @@ module Puppeteer
|
|
|
251
260
|
end
|
|
252
261
|
|
|
253
262
|
# Perform input actions via BiDi
|
|
263
|
+
# @rbs action_list: Array[Hash[Symbol, untyped]] -- List of key actions
|
|
264
|
+
# @rbs return: void
|
|
254
265
|
def perform_actions(action_list)
|
|
255
266
|
@browsing_context.perform_actions([
|
|
256
267
|
{
|
data/lib/puppeteer/bidi/mouse.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
2
3
|
|
|
3
4
|
module Puppeteer
|
|
4
5
|
module Bidi
|
|
@@ -6,12 +7,14 @@ module Puppeteer
|
|
|
6
7
|
# Based on Puppeteer's BidiMouse implementation
|
|
7
8
|
class Mouse
|
|
8
9
|
# Mouse button constants
|
|
9
|
-
LEFT = 'left'
|
|
10
|
-
RIGHT = 'right'
|
|
11
|
-
MIDDLE = 'middle'
|
|
12
|
-
BACK = 'back'
|
|
13
|
-
FORWARD = 'forward'
|
|
14
|
-
|
|
10
|
+
LEFT = 'left' #: String
|
|
11
|
+
RIGHT = 'right' #: String
|
|
12
|
+
MIDDLE = 'middle' #: String
|
|
13
|
+
BACK = 'back' #: String
|
|
14
|
+
FORWARD = 'forward' #: String
|
|
15
|
+
|
|
16
|
+
# @rbs browsing_context: Core::BrowsingContext -- Browsing context
|
|
17
|
+
# @rbs return: void
|
|
15
18
|
def initialize(browsing_context)
|
|
16
19
|
@browsing_context = browsing_context
|
|
17
20
|
@x = 0
|
|
@@ -19,9 +22,10 @@ module Puppeteer
|
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
# Move mouse to coordinates
|
|
22
|
-
# @
|
|
23
|
-
# @
|
|
24
|
-
# @
|
|
25
|
+
# @rbs x: Numeric -- X coordinate
|
|
26
|
+
# @rbs y: Numeric -- Y coordinate
|
|
27
|
+
# @rbs steps: Integer -- Number of intermediate steps (for smooth movement)
|
|
28
|
+
# @rbs return: void
|
|
25
29
|
def move(x, y, steps: 1)
|
|
26
30
|
from_x = @x
|
|
27
31
|
from_y = @y
|
|
@@ -46,7 +50,8 @@ module Puppeteer
|
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
# Press mouse button down
|
|
49
|
-
# @
|
|
53
|
+
# @rbs button: String -- Mouse button ('left', 'right', 'middle', 'back', 'forward')
|
|
54
|
+
# @rbs return: void
|
|
50
55
|
def down(button: LEFT)
|
|
51
56
|
actions = [{
|
|
52
57
|
type: 'pointerDown',
|
|
@@ -56,7 +61,8 @@ module Puppeteer
|
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
# Release mouse button
|
|
59
|
-
# @
|
|
64
|
+
# @rbs button: String -- Mouse button
|
|
65
|
+
# @rbs return: void
|
|
60
66
|
def up(button: LEFT)
|
|
61
67
|
actions = [{
|
|
62
68
|
type: 'pointerUp',
|
|
@@ -66,11 +72,12 @@ module Puppeteer
|
|
|
66
72
|
end
|
|
67
73
|
|
|
68
74
|
# Click at coordinates
|
|
69
|
-
# @
|
|
70
|
-
# @
|
|
71
|
-
# @
|
|
72
|
-
# @
|
|
73
|
-
# @
|
|
75
|
+
# @rbs x: Numeric -- X coordinate
|
|
76
|
+
# @rbs y: Numeric -- Y coordinate
|
|
77
|
+
# @rbs button: String -- Mouse button
|
|
78
|
+
# @rbs count: Integer -- Number of clicks (1 for single, 2 for double, 3 for triple)
|
|
79
|
+
# @rbs delay: Numeric? -- Delay between down and up in milliseconds
|
|
80
|
+
# @rbs return: void
|
|
74
81
|
def click(x, y, button: LEFT, count: 1, delay: nil)
|
|
75
82
|
actions = []
|
|
76
83
|
|
|
@@ -113,8 +120,9 @@ module Puppeteer
|
|
|
113
120
|
end
|
|
114
121
|
|
|
115
122
|
# Scroll using mouse wheel
|
|
116
|
-
# @
|
|
117
|
-
# @
|
|
123
|
+
# @rbs delta_x: Numeric -- Horizontal scroll amount
|
|
124
|
+
# @rbs delta_y: Numeric -- Vertical scroll amount
|
|
125
|
+
# @rbs return: void
|
|
118
126
|
def wheel(delta_x: 0, delta_y: 0)
|
|
119
127
|
@browsing_context.perform_actions([
|
|
120
128
|
{
|
|
@@ -135,6 +143,7 @@ module Puppeteer
|
|
|
135
143
|
|
|
136
144
|
# Reset mouse state
|
|
137
145
|
# Resets position to origin and releases all pressed buttons
|
|
146
|
+
# @rbs return: void
|
|
138
147
|
def reset
|
|
139
148
|
@x = 0
|
|
140
149
|
@y = 0
|
|
@@ -144,6 +153,8 @@ module Puppeteer
|
|
|
144
153
|
private
|
|
145
154
|
|
|
146
155
|
# Convert mouse button name to BiDi button number
|
|
156
|
+
# @rbs button: String -- Mouse button name
|
|
157
|
+
# @rbs return: Integer -- BiDi button number
|
|
147
158
|
def button_to_bidi(button)
|
|
148
159
|
case button
|
|
149
160
|
when LEFT then 0
|
|
@@ -156,6 +167,8 @@ module Puppeteer
|
|
|
156
167
|
end
|
|
157
168
|
|
|
158
169
|
# Perform input actions via BiDi
|
|
170
|
+
# @rbs action_list: Array[Hash[Symbol, untyped]] -- List of pointer actions
|
|
171
|
+
# @rbs return: void
|
|
159
172
|
def perform_actions(action_list)
|
|
160
173
|
@browsing_context.perform_actions([
|
|
161
174
|
{
|