puppeteer-bidi 0.0.1.beta1 → 0.0.1.beta3
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 +50 -4
- data/README.md +8 -1
- data/Steepfile +36 -0
- data/lib/puppeteer/bidi/async_utils.rb +1 -0
- data/lib/puppeteer/bidi/browser.rb +38 -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 +24 -0
- data/lib/puppeteer/bidi/task_manager.rb +9 -3
- 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 +8 -4
- data/sig/_external.rbs +128 -0
- data/sig/_supplementary.rbs +20 -0
- data/sig/puppeteer/bidi/async_utils.rbs +68 -0
- data/sig/puppeteer/bidi/browser.rbs +35 -26
- 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/task_manager.rbs +36 -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 +8 -4
- metadata +36 -1
|
@@ -1,78 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
1
4
|
module Puppeteer
|
|
2
5
|
module Bidi
|
|
3
6
|
class BrowserTarget
|
|
7
|
+
# @rbs browser: Browser
|
|
8
|
+
# @rbs return: void
|
|
4
9
|
def initialize(browser)
|
|
5
10
|
@browser = browser
|
|
6
11
|
end
|
|
7
12
|
|
|
13
|
+
# @rbs return: nil
|
|
8
14
|
def page
|
|
9
15
|
nil
|
|
10
16
|
end
|
|
11
17
|
|
|
18
|
+
# @rbs return: String
|
|
12
19
|
def url
|
|
13
20
|
''
|
|
14
21
|
end
|
|
15
22
|
|
|
23
|
+
# @rbs return: String
|
|
16
24
|
def type
|
|
17
25
|
'browser'
|
|
18
26
|
end
|
|
19
27
|
|
|
28
|
+
# @rbs return: Browser
|
|
20
29
|
def browser
|
|
21
30
|
@browser
|
|
22
31
|
end
|
|
23
32
|
|
|
33
|
+
# @rbs return: BrowserContext
|
|
24
34
|
def browser_context
|
|
25
35
|
@browser.default_browser_context
|
|
26
36
|
end
|
|
27
37
|
end
|
|
28
38
|
|
|
29
39
|
class PageTarget
|
|
40
|
+
# @rbs page: Page
|
|
41
|
+
# @rbs return: void
|
|
30
42
|
def initialize(page)
|
|
31
43
|
@page = page
|
|
32
44
|
end
|
|
33
45
|
|
|
46
|
+
# @rbs return: Page
|
|
34
47
|
def page
|
|
35
48
|
@page
|
|
36
49
|
end
|
|
37
50
|
|
|
51
|
+
# @rbs return: String
|
|
38
52
|
def url
|
|
39
53
|
@page.url
|
|
40
54
|
end
|
|
41
55
|
|
|
56
|
+
# @rbs return: String
|
|
42
57
|
def type
|
|
43
58
|
'page'
|
|
44
59
|
end
|
|
45
60
|
|
|
61
|
+
# @rbs return: Browser
|
|
46
62
|
def browser
|
|
47
63
|
@page.browser_context.browser
|
|
48
64
|
end
|
|
49
65
|
|
|
66
|
+
# @rbs return: BrowserContext
|
|
50
67
|
def browser_context
|
|
51
68
|
@page.browser_context
|
|
52
69
|
end
|
|
53
70
|
end
|
|
54
71
|
|
|
55
72
|
class FrameTarget
|
|
73
|
+
# @rbs frame: Frame
|
|
74
|
+
# @rbs return: void
|
|
56
75
|
def initialize(frame)
|
|
57
76
|
@frame = frame
|
|
58
77
|
end
|
|
59
78
|
|
|
79
|
+
# @rbs return: Page
|
|
60
80
|
def page
|
|
61
81
|
@frame.page
|
|
62
82
|
end
|
|
63
83
|
|
|
84
|
+
# @rbs return: String
|
|
64
85
|
def url
|
|
65
86
|
@frame.url
|
|
66
87
|
end
|
|
67
88
|
|
|
89
|
+
# @rbs return: String
|
|
68
90
|
def type
|
|
69
91
|
'frame'
|
|
70
92
|
end
|
|
71
93
|
|
|
94
|
+
# @rbs return: Browser
|
|
72
95
|
def browser
|
|
73
96
|
@frame.browser_context.browser
|
|
74
97
|
end
|
|
75
98
|
|
|
99
|
+
# @rbs return: BrowserContext
|
|
76
100
|
def browser_context
|
|
77
101
|
@frame.browser_context
|
|
78
102
|
end
|
|
@@ -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,27 +7,31 @@ module Puppeteer
|
|
|
6
7
|
# This is a faithful port of Puppeteer's TaskManager implementation:
|
|
7
8
|
# https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/common/WaitTask.ts
|
|
8
9
|
class TaskManager
|
|
10
|
+
# @rbs return: void
|
|
9
11
|
def initialize
|
|
10
12
|
@tasks = Set.new
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
# Add a task to the manager
|
|
14
16
|
# Corresponds to Puppeteer's add(task: WaitTask<any>): void
|
|
15
|
-
# @
|
|
17
|
+
# @rbs task: WaitTask -- Task to add
|
|
18
|
+
# @rbs return: void
|
|
16
19
|
def add(task)
|
|
17
20
|
@tasks.add(task)
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
# Delete a task from the manager
|
|
21
24
|
# Corresponds to Puppeteer's delete(task: WaitTask<any>): void
|
|
22
|
-
# @
|
|
25
|
+
# @rbs task: WaitTask -- Task to delete
|
|
26
|
+
# @rbs return: void
|
|
23
27
|
def delete(task)
|
|
24
28
|
@tasks.delete(task)
|
|
25
29
|
end
|
|
26
30
|
|
|
27
31
|
# Terminate all tasks with an optional error
|
|
28
32
|
# Corresponds to Puppeteer's terminateAll(error?: Error): void
|
|
29
|
-
# @
|
|
33
|
+
# @rbs error: Exception? -- Error to terminate with
|
|
34
|
+
# @rbs return: void
|
|
30
35
|
def terminate_all(error = nil)
|
|
31
36
|
@tasks.each do |task|
|
|
32
37
|
task.terminate(error)
|
|
@@ -36,6 +41,7 @@ module Puppeteer
|
|
|
36
41
|
|
|
37
42
|
# Rerun all tasks in parallel
|
|
38
43
|
# Corresponds to Puppeteer's async rerunAll(): Promise<void>
|
|
44
|
+
# @rbs return: void
|
|
39
45
|
def rerun_all
|
|
40
46
|
@tasks.each(&:rerun)
|
|
41
47
|
end
|
data/lib/puppeteer/bidi.rb
CHANGED
|
@@ -33,15 +33,19 @@ require "puppeteer/bidi/browser"
|
|
|
33
33
|
module Puppeteer
|
|
34
34
|
module Bidi
|
|
35
35
|
# Launch a new browser instance
|
|
36
|
-
# @rbs
|
|
37
|
-
# @rbs
|
|
36
|
+
# @rbs executable_path: String
|
|
37
|
+
# @rbs user_data_dir: String
|
|
38
|
+
# @rbs headless: bool
|
|
39
|
+
# @rbs args: Array[String]
|
|
40
|
+
# @rbs timeout: Numeric
|
|
41
|
+
# @rbs return: Browser -- Browser instance
|
|
38
42
|
def self.launch(**options)
|
|
39
43
|
Browser.launch(**options)
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
# Connect to an existing browser instance
|
|
43
|
-
# @rbs ws_endpoint: String
|
|
44
|
-
# @rbs return: Browser
|
|
47
|
+
# @rbs ws_endpoint: String -- WebSocket endpoint URL
|
|
48
|
+
# @rbs return: Browser -- Browser instance
|
|
45
49
|
def self.connect(ws_endpoint)
|
|
46
50
|
Browser.connect(ws_endpoint)
|
|
47
51
|
end
|
data/sig/_external.rbs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# External dependencies stub definitions
|
|
2
|
+
# These types are from external gems and standard library extensions
|
|
3
|
+
|
|
4
|
+
# Async gem adds these methods to Kernel
|
|
5
|
+
module Kernel
|
|
6
|
+
def Async: [T] () { (Async::Task[T]) -> T } -> Async::Task[T]
|
|
7
|
+
def Sync: [T] () { () -> T } -> T
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Async
|
|
11
|
+
def self.call: [T] () { () -> T } -> Task[T]
|
|
12
|
+
|
|
13
|
+
class Task[T]
|
|
14
|
+
def wait: () -> T
|
|
15
|
+
def sleep: (Numeric) -> void
|
|
16
|
+
def stop: () -> void
|
|
17
|
+
def with_timeout: [U] (Numeric) { () -> U } -> U
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Promise[T]
|
|
21
|
+
def initialize: () -> void
|
|
22
|
+
def wait: () -> T
|
|
23
|
+
def resolve: (T) -> void
|
|
24
|
+
def reject: (Exception) -> void
|
|
25
|
+
def resolved?: () -> bool
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class TimeoutError < StandardError
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class Stop < Exception
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Barrier
|
|
35
|
+
def initialize: () -> void
|
|
36
|
+
def async: () { () -> untyped } -> void
|
|
37
|
+
def wait: () -> void
|
|
38
|
+
def stop: () -> void
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module HTTP
|
|
42
|
+
class Client
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Endpoint
|
|
46
|
+
def self.parse: (String) -> Endpoint
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
module Protocol
|
|
50
|
+
module HTTP1
|
|
51
|
+
class Client
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class WebSocket
|
|
58
|
+
class Client
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class Connection
|
|
62
|
+
def write: (untyped) -> void
|
|
63
|
+
def read: () -> untyped
|
|
64
|
+
def close: () -> void
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class Thread
|
|
70
|
+
class Mutex
|
|
71
|
+
def synchronize: [T] () { () -> T } -> T
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
module Protocol
|
|
76
|
+
module WebSocket
|
|
77
|
+
class TextMessage
|
|
78
|
+
attr_reader buffer: String
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class BinaryMessage
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class CloseFrame
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class PingFrame
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class PongFrame
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Open3 extensions
|
|
96
|
+
module Open3
|
|
97
|
+
def self.popen3: (*String) -> [IO, IO, IO, Thread]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Singleton module
|
|
101
|
+
module Singleton
|
|
102
|
+
def self.included: (Class) -> void
|
|
103
|
+
|
|
104
|
+
module SingletonClassMethods
|
|
105
|
+
def instance: () -> instance
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Dir extensions (tmpdir library)
|
|
110
|
+
class Dir
|
|
111
|
+
def self.mktmpdir: (String) -> String
|
|
112
|
+
| (String) { (String) -> untyped } -> untyped
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Time extensions (time library)
|
|
116
|
+
class Time
|
|
117
|
+
def self.parse: (String) -> Time
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Date/DateTime extensions
|
|
121
|
+
class Date
|
|
122
|
+
def to_time: () -> Time
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class DateTime
|
|
126
|
+
def to_time: () -> Time
|
|
127
|
+
end
|
|
128
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Supplementary type declarations for types that rbs-inline cannot generate
|
|
2
|
+
# This file is NOT auto-generated and should be manually maintained
|
|
3
|
+
|
|
4
|
+
# AsyncUtils uses `extend self` to make instance methods callable as singleton methods
|
|
5
|
+
module Puppeteer
|
|
6
|
+
module Bidi
|
|
7
|
+
module AsyncUtils
|
|
8
|
+
extend AsyncUtils
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# QueryHandler uses Singleton pattern
|
|
14
|
+
module Puppeteer
|
|
15
|
+
module Bidi
|
|
16
|
+
class QueryHandler
|
|
17
|
+
extend Singleton::SingletonClassMethods
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Generated from lib/puppeteer/bidi/async_utils.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Puppeteer
|
|
4
|
+
module Bidi
|
|
5
|
+
# Utility methods for working with Async tasks
|
|
6
|
+
# Provides Promise.all and Promise.race equivalents using Async::Barrier
|
|
7
|
+
module AsyncUtils
|
|
8
|
+
def await: (untyped task) -> untyped
|
|
9
|
+
|
|
10
|
+
# Execute a task with a timeout using Async::Task#with_timeout
|
|
11
|
+
# @param timeout_ms [Numeric] Timeout duration in milliseconds
|
|
12
|
+
# @param task [Proc, Async::Promise, nil] Task to execute; falls back to block
|
|
13
|
+
# @yield [async_task] Execute a task within the timeout, optionally receiving Async::Task
|
|
14
|
+
# @return [Async::Task] Async task that resolves/rejects once the operation completes
|
|
15
|
+
def async_timeout: (untyped timeout_ms, ?untyped task) ?{ (?) -> untyped } -> untyped
|
|
16
|
+
|
|
17
|
+
def promise_all: (*untyped tasks) -> untyped
|
|
18
|
+
|
|
19
|
+
# Wait for all async tasks to complete and return results
|
|
20
|
+
# Similar to Promise.all in JavaScript
|
|
21
|
+
# @param tasks [Array<Proc, Async::Promise>] Array of procs or promises
|
|
22
|
+
# @return [Array] Array of results in the same order as the input tasks
|
|
23
|
+
# @raise If any task raises an exception, it will be propagated
|
|
24
|
+
# @example With procs
|
|
25
|
+
# results = AsyncUtils.await_promise_all(
|
|
26
|
+
# -> { sleep 0.1; "first" },
|
|
27
|
+
# -> { sleep 0.2; "second" },
|
|
28
|
+
# -> { sleep 0.05; "third" }
|
|
29
|
+
# )
|
|
30
|
+
# # => ["first", "second", "third"]
|
|
31
|
+
# @example With promises
|
|
32
|
+
# promise1 = Async::Promise.new
|
|
33
|
+
# promise2 = Async::Promise.new
|
|
34
|
+
# Thread.new { sleep 0.1; promise1.resolve("first") }
|
|
35
|
+
# Thread.new { sleep 0.2; promise2.resolve("second") }
|
|
36
|
+
# results = AsyncUtils.await_promise_all(promise1, promise2)
|
|
37
|
+
# # => ["first", "second"]
|
|
38
|
+
def await_promise_all: (*untyped tasks) -> untyped
|
|
39
|
+
|
|
40
|
+
def promise_race: (*untyped tasks) -> untyped
|
|
41
|
+
|
|
42
|
+
# Race multiple async tasks and return the result of the first one to complete
|
|
43
|
+
# Similar to Promise.race in JavaScript
|
|
44
|
+
# @param tasks [Array<Proc, Async::Promise>] Array of procs or promises
|
|
45
|
+
# @return The result of the first task to complete
|
|
46
|
+
# @example With procs
|
|
47
|
+
# result = AsyncUtils.await_promise_race(
|
|
48
|
+
# -> { sleep 1; "slow" },
|
|
49
|
+
# -> { sleep 0.1; "fast" }
|
|
50
|
+
# )
|
|
51
|
+
# # => "fast"
|
|
52
|
+
# @example With promises
|
|
53
|
+
# promise1 = Async::Promise.new
|
|
54
|
+
# promise2 = Async::Promise.new
|
|
55
|
+
# Thread.new { sleep 0.3; promise1.resolve("slow") }
|
|
56
|
+
# Thread.new { sleep 0.1; promise2.resolve("fast") }
|
|
57
|
+
# result = AsyncUtils.await_promise_race(promise1, promise2)
|
|
58
|
+
# # => "fast"
|
|
59
|
+
def await_promise_race: (*untyped tasks) -> untyped
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def zip: (*untyped tasks) -> untyped
|
|
64
|
+
|
|
65
|
+
def first: (*untyped tasks) -> untyped
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -10,38 +10,47 @@ module Puppeteer
|
|
|
10
10
|
|
|
11
11
|
attr_reader default_browser_context: BrowserContext
|
|
12
12
|
|
|
13
|
-
# @rbs connection: Connection
|
|
14
|
-
# @rbs launcher: BrowserLauncher?
|
|
15
|
-
# @rbs return: Browser
|
|
13
|
+
# @rbs connection: Connection -- BiDi connection
|
|
14
|
+
# @rbs launcher: BrowserLauncher? -- Browser launcher instance
|
|
15
|
+
# @rbs return: Browser -- Browser instance
|
|
16
16
|
def self.create: (connection: Connection, ?launcher: BrowserLauncher?) -> Browser
|
|
17
17
|
|
|
18
|
-
# @rbs connection: Connection
|
|
19
|
-
# @rbs launcher: BrowserLauncher?
|
|
20
|
-
# @rbs core_browser: Core::Browser
|
|
21
|
-
# @rbs session: Core::Session
|
|
18
|
+
# @rbs connection: Connection -- BiDi connection
|
|
19
|
+
# @rbs launcher: BrowserLauncher? -- Browser launcher instance
|
|
20
|
+
# @rbs core_browser: Core::Browser -- Core browser instance
|
|
21
|
+
# @rbs session: Core::Session -- BiDi session
|
|
22
22
|
# @rbs return: void
|
|
23
23
|
def initialize: (connection: Connection, launcher: BrowserLauncher?, core_browser: Core::Browser, session: Core::Session) -> void
|
|
24
24
|
|
|
25
25
|
# Launch a new Firefox browser instance
|
|
26
|
-
# @rbs
|
|
27
|
-
# @rbs
|
|
26
|
+
# @rbs executable_path: String
|
|
27
|
+
# @rbs user_data_dir: String
|
|
28
|
+
# @rbs headless: bool
|
|
29
|
+
# @rbs args: Array[String]
|
|
30
|
+
# @rbs timeout: Numeric
|
|
31
|
+
# @rbs return: Browser -- Browser instance
|
|
28
32
|
def self.launch: (**untyped options) -> Browser
|
|
29
33
|
|
|
34
|
+
# Connect to an existing Firefox browser instance
|
|
35
|
+
# @rbs ws_endpoint: String -- WebSocket endpoint URL
|
|
36
|
+
# @rbs return: Browser -- Browser instance
|
|
37
|
+
def self.connect: (String ws_endpoint) -> Browser
|
|
38
|
+
|
|
30
39
|
# Get BiDi session status
|
|
31
|
-
# @rbs return: untyped
|
|
40
|
+
# @rbs return: untyped -- Session status
|
|
32
41
|
def status: () -> untyped
|
|
33
42
|
|
|
34
43
|
# Create a new page (Puppeteer-like API)
|
|
35
|
-
# @rbs return: Page
|
|
44
|
+
# @rbs return: Page -- New page instance
|
|
36
45
|
def new_page: () -> Page
|
|
37
46
|
|
|
38
47
|
# Get all pages
|
|
39
|
-
# @rbs return: Array[Page]
|
|
48
|
+
# @rbs return: Array[Page] -- All pages
|
|
40
49
|
def pages: () -> Array[Page]
|
|
41
50
|
|
|
42
51
|
# Register event handler
|
|
43
|
-
# @rbs event: String | Symbol
|
|
44
|
-
# @rbs &block: (untyped) -> void
|
|
52
|
+
# @rbs event: String | Symbol -- Event name
|
|
53
|
+
# @rbs &block: (untyped) -> void -- Event handler
|
|
45
54
|
# @rbs return: void
|
|
46
55
|
def on: (String | Symbol event) { (untyped) -> void } -> void
|
|
47
56
|
|
|
@@ -53,10 +62,10 @@ module Puppeteer
|
|
|
53
62
|
def closed?: () -> bool
|
|
54
63
|
|
|
55
64
|
# Wait until a target (top-level browsing context) satisfies the predicate.
|
|
56
|
-
# @rbs timeout: Integer?
|
|
57
|
-
# @rbs &predicate: (
|
|
58
|
-
# @rbs return:
|
|
59
|
-
def wait_for_target: (?timeout: Integer?) { (
|
|
65
|
+
# @rbs timeout: Integer? -- Timeout in milliseconds (default: 30000)
|
|
66
|
+
# @rbs &predicate: (BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate evaluated against each Target
|
|
67
|
+
# @rbs return: BrowserTarget | PageTarget | FrameTarget -- Matching target
|
|
68
|
+
def wait_for_target: (?timeout: Integer?) { (BrowserTarget | PageTarget | FrameTarget) -> boolish } -> (BrowserTarget | PageTarget | FrameTarget)
|
|
60
69
|
|
|
61
70
|
# Wait for browser process to exit
|
|
62
71
|
# @rbs return: void
|
|
@@ -64,16 +73,16 @@ module Puppeteer
|
|
|
64
73
|
|
|
65
74
|
private
|
|
66
75
|
|
|
67
|
-
# @rbs &block: (
|
|
68
|
-
# @rbs return: Enumerator[
|
|
69
|
-
def each_target: () { (
|
|
76
|
+
# @rbs &block: (BrowserTarget | PageTarget | FrameTarget) -> void -- Block to yield each target to
|
|
77
|
+
# @rbs return: Enumerator[BrowserTarget | PageTarget | FrameTarget, void] -- Enumerator of targets
|
|
78
|
+
def each_target: () { (BrowserTarget | PageTarget | FrameTarget) -> void } -> Enumerator[BrowserTarget | PageTarget | FrameTarget, void]
|
|
70
79
|
|
|
71
|
-
# @rbs predicate: (
|
|
72
|
-
# @rbs return:
|
|
73
|
-
def find_target: (
|
|
80
|
+
# @rbs predicate: ^(BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate to match targets
|
|
81
|
+
# @rbs return: (BrowserTarget | PageTarget | FrameTarget)? -- Matching target or nil
|
|
82
|
+
def find_target: (^(BrowserTarget | PageTarget | FrameTarget) -> boolish predicate) -> (BrowserTarget | PageTarget | FrameTarget)?
|
|
74
83
|
|
|
75
|
-
# @rbs user_context: Core::UserContext
|
|
76
|
-
# @rbs return: BrowserContext?
|
|
84
|
+
# @rbs user_context: Core::UserContext -- User context to get browser context for
|
|
85
|
+
# @rbs return: BrowserContext? -- Browser context or nil
|
|
77
86
|
def browser_context_for: (Core::UserContext user_context) -> BrowserContext?
|
|
78
87
|
end
|
|
79
88
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated from lib/puppeteer/bidi/browser_context.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Puppeteer
|
|
4
|
+
module Bidi
|
|
5
|
+
# BrowserContext represents an isolated browsing session
|
|
6
|
+
# This is a high-level wrapper around Core::UserContext
|
|
7
|
+
class BrowserContext
|
|
8
|
+
attr_reader user_context: Core::UserContext
|
|
9
|
+
|
|
10
|
+
attr_reader browser: Browser
|
|
11
|
+
|
|
12
|
+
# @rbs browser: Browser -- Parent browser instance
|
|
13
|
+
# @rbs user_context: Core::UserContext -- Associated user context
|
|
14
|
+
# @rbs return: void
|
|
15
|
+
def initialize: (Browser browser, Core::UserContext user_context) -> void
|
|
16
|
+
|
|
17
|
+
# Create a new page (tab/window)
|
|
18
|
+
# @rbs return: Page -- New page instance
|
|
19
|
+
def new_page: () -> Page
|
|
20
|
+
|
|
21
|
+
# Get all pages in this context
|
|
22
|
+
# @rbs return: Array[Page] -- All pages
|
|
23
|
+
def pages: () -> Array[Page]
|
|
24
|
+
|
|
25
|
+
# Get or create a Page for the given browsing context
|
|
26
|
+
# @rbs browsing_context: Core::BrowsingContext -- Browsing context
|
|
27
|
+
# @rbs return: Page -- Page instance
|
|
28
|
+
def page_for: (Core::BrowsingContext browsing_context) -> Page
|
|
29
|
+
|
|
30
|
+
# Close the browser context
|
|
31
|
+
# @rbs return: void
|
|
32
|
+
def close: () -> void
|
|
33
|
+
|
|
34
|
+
# Check if context is closed
|
|
35
|
+
# @rbs return: bool -- Whether the context is closed
|
|
36
|
+
def closed?: () -> bool
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Generated from lib/puppeteer/bidi/browser_launcher.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Puppeteer
|
|
4
|
+
module Bidi
|
|
5
|
+
# BrowserLauncher handles launching Firefox with BiDi support
|
|
6
|
+
class BrowserLauncher
|
|
7
|
+
class LaunchError < Error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
attr_reader executable_path: untyped
|
|
11
|
+
|
|
12
|
+
attr_reader user_data_dir: untyped
|
|
13
|
+
|
|
14
|
+
def initialize: (?executable_path: untyped, ?user_data_dir: untyped, ?headless: untyped, ?args: untyped) -> untyped
|
|
15
|
+
|
|
16
|
+
# Launch Firefox and return BiDi WebSocket endpoint
|
|
17
|
+
# @return [String] WebSocket endpoint URL
|
|
18
|
+
def launch: () -> untyped
|
|
19
|
+
|
|
20
|
+
# Kill the Firefox process
|
|
21
|
+
def kill: () -> untyped
|
|
22
|
+
|
|
23
|
+
# Wait for process to exit
|
|
24
|
+
def wait: () -> untyped
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def find_firefox: () -> untyped
|
|
29
|
+
|
|
30
|
+
def setup_user_data_dir: () -> untyped
|
|
31
|
+
|
|
32
|
+
def create_prefs_file: () -> untyped
|
|
33
|
+
|
|
34
|
+
def default_prefs: () -> untyped
|
|
35
|
+
|
|
36
|
+
def cleanup_temp_user_data_dir: () -> untyped
|
|
37
|
+
|
|
38
|
+
def find_available_port: () -> untyped
|
|
39
|
+
|
|
40
|
+
def build_launch_args: (untyped port) -> untyped
|
|
41
|
+
|
|
42
|
+
def wait_for_ws_endpoint: (untyped port, untyped stdout, untyped stderr, ?timeout: untyped) -> untyped
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Generated from lib/puppeteer/bidi/connection.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Puppeteer
|
|
4
|
+
module Bidi
|
|
5
|
+
# Connection manages BiDi protocol communication
|
|
6
|
+
# Handles command sending, response waiting, and event dispatching
|
|
7
|
+
class Connection
|
|
8
|
+
class TimeoutError < Error
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class ProtocolError < Error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
DEFAULT_TIMEOUT: Integer
|
|
15
|
+
|
|
16
|
+
# @rbs transport: Transport
|
|
17
|
+
# @rbs return: void
|
|
18
|
+
def initialize: (Transport transport) -> void
|
|
19
|
+
|
|
20
|
+
# Send a BiDi command and wait for response
|
|
21
|
+
# @rbs method: String
|
|
22
|
+
# @rbs params: Hash[String | Symbol, untyped]
|
|
23
|
+
# @rbs timeout: Integer
|
|
24
|
+
# @rbs return: Async::Task[Hash[String, untyped]]
|
|
25
|
+
def async_send_command: (String method, ?Hash[String | Symbol, untyped] params, ?timeout: Integer) -> Async::Task[Hash[String, untyped]]
|
|
26
|
+
|
|
27
|
+
# Subscribe to BiDi events
|
|
28
|
+
# @rbs event: String
|
|
29
|
+
# @rbs &block: (untyped) -> void
|
|
30
|
+
# @rbs return: void
|
|
31
|
+
def on: (String event) { (untyped) -> void } -> void
|
|
32
|
+
|
|
33
|
+
# Unsubscribe from BiDi events
|
|
34
|
+
# @rbs event: String
|
|
35
|
+
# @rbs &block: ((untyped) -> void)?
|
|
36
|
+
# @rbs return: void
|
|
37
|
+
def off: (String event) ?{ (?) -> untyped } -> void
|
|
38
|
+
|
|
39
|
+
# Close the connection
|
|
40
|
+
# @rbs return: void
|
|
41
|
+
def close: () -> void
|
|
42
|
+
|
|
43
|
+
# @rbs return: bool
|
|
44
|
+
def closed?: () -> bool
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
# @rbs return: Integer
|
|
49
|
+
def next_id: () -> Integer
|
|
50
|
+
|
|
51
|
+
# @rbs return: void
|
|
52
|
+
def setup_transport_handlers: () -> void
|
|
53
|
+
|
|
54
|
+
# @rbs message: Hash[String, untyped]
|
|
55
|
+
# @rbs return: void
|
|
56
|
+
def handle_message: (Hash[String, untyped] message) -> void
|
|
57
|
+
|
|
58
|
+
# @rbs message: Hash[String, untyped]
|
|
59
|
+
# @rbs return: void
|
|
60
|
+
def handle_response: (Hash[String, untyped] message) -> void
|
|
61
|
+
|
|
62
|
+
# @rbs message: Hash[String, untyped]
|
|
63
|
+
# @rbs return: void
|
|
64
|
+
def handle_event: (Hash[String, untyped] message) -> void
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|