puppeteer-ruby 0.52.0 → 0.52.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70526928098a3ab1bcf1718b6110a6620188a30c77419a04181cb746acf4ed15
|
|
4
|
+
data.tar.gz: 073e09f7dd759b1b2b2d268ec3021cab96c3e56df93353343fd6ded898556d7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a222036f53e7552d12a8340850369aeed45277f44f1914984ff91168131fbc8ad0a93adf0a3ffe07b98e0f5038a14ee2da6239685bdbf297883bb2702d31df86
|
|
7
|
+
data.tar.gz: 57c5a117800a1b814d77abd3ad41d9b25487b08993e1752327dbac49a3e80474c612a52dd3141fd1025dd4fc96e5758c199a82de470abba73e290a5316db0516
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative './browser'
|
|
2
|
+
require_relative './chrome_user_data_dir'
|
|
2
3
|
require_relative './launcher/browser_options'
|
|
3
4
|
|
|
4
5
|
class Puppeteer::BrowserConnector
|
|
@@ -7,6 +8,7 @@ class Puppeteer::BrowserConnector
|
|
|
7
8
|
@browser_ws_endpoint = options[:browser_ws_endpoint]
|
|
8
9
|
@browser_url = options[:browser_url]
|
|
9
10
|
@transport = options[:transport]
|
|
11
|
+
@channel = options[:channel]
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
# @return [Puppeteer::Browser]
|
|
@@ -38,16 +40,24 @@ class Puppeteer::BrowserConnector
|
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
private def connection
|
|
41
|
-
@connection ||=
|
|
42
|
-
|
|
43
|
+
@connection ||= begin
|
|
44
|
+
connection_options = [@browser_ws_endpoint, @browser_url, @transport, @channel]
|
|
45
|
+
unless connection_options.count { |option| !!option } == 1
|
|
46
|
+
raise ArgumentError.new('Exactly one of browserWSEndpoint, browserURL, transport or channel must be passed to puppeteer.connect')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
if @transport
|
|
50
|
+
connect_with_transport(@transport)
|
|
51
|
+
elsif @browser_ws_endpoint
|
|
43
52
|
connect_with_browser_ws_endpoint(@browser_ws_endpoint)
|
|
44
|
-
elsif @
|
|
53
|
+
elsif @browser_url
|
|
45
54
|
connect_with_browser_url(@browser_url)
|
|
46
|
-
elsif @
|
|
47
|
-
|
|
55
|
+
elsif @channel
|
|
56
|
+
connect_with_channel(@channel)
|
|
48
57
|
else
|
|
49
|
-
raise ArgumentError.new(
|
|
58
|
+
raise ArgumentError.new('Invalid connection options')
|
|
50
59
|
end
|
|
60
|
+
end
|
|
51
61
|
end
|
|
52
62
|
|
|
53
63
|
# @return [Puppeteer::Connection]
|
|
@@ -72,6 +82,31 @@ class Puppeteer::BrowserConnector
|
|
|
72
82
|
connect_with_browser_ws_endpoint(connection_url)
|
|
73
83
|
end
|
|
74
84
|
|
|
85
|
+
# @return [Puppeteer::Connection]
|
|
86
|
+
private def connect_with_channel(channel)
|
|
87
|
+
port_path = File.join(
|
|
88
|
+
Puppeteer::ChromeUserDataDir.resolve_default(channel),
|
|
89
|
+
'DevToolsActivePort',
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
begin
|
|
93
|
+
file_content = File.read(port_path, mode: 'r:ASCII')
|
|
94
|
+
raw_port, raw_path = file_content.lines.map(&:strip).reject(&:empty?)
|
|
95
|
+
unless raw_port && raw_path
|
|
96
|
+
raise Puppeteer::Error.new("Invalid DevToolsActivePort '#{file_content}' found")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
port = raw_port.to_i
|
|
100
|
+
if port <= 0 || port > 65_535
|
|
101
|
+
raise Puppeteer::Error.new("Invalid port '#{raw_port}' found")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
connect_with_browser_ws_endpoint("ws://localhost:#{port}#{raw_path}")
|
|
105
|
+
rescue StandardError
|
|
106
|
+
raise Puppeteer::Error.new("Could not find DevToolsActivePort for #{channel} at #{port_path}")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
75
110
|
# @return [Puppeteer::Connection]
|
|
76
111
|
private def connect_with_transport(transport)
|
|
77
112
|
Puppeteer::Connection.new(
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
require_relative './env'
|
|
5
|
+
|
|
6
|
+
module Puppeteer::ChromeUserDataDir
|
|
7
|
+
CHANNELS = %w[chrome chrome-beta chrome-canary chrome-dev].freeze #: Array[String]
|
|
8
|
+
|
|
9
|
+
MAC_DIR_NAMES = {
|
|
10
|
+
'chrome' => 'Chrome',
|
|
11
|
+
'chrome-beta' => 'Chrome Beta',
|
|
12
|
+
'chrome-canary' => 'Chrome Canary',
|
|
13
|
+
'chrome-dev' => 'Chrome Dev',
|
|
14
|
+
}.freeze #: Hash[String, String]
|
|
15
|
+
|
|
16
|
+
LINUX_DIR_NAMES = {
|
|
17
|
+
'chrome' => 'google-chrome',
|
|
18
|
+
'chrome-beta' => 'google-chrome-beta',
|
|
19
|
+
'chrome-canary' => 'google-chrome-canary',
|
|
20
|
+
'chrome-dev' => 'google-chrome-unstable',
|
|
21
|
+
}.freeze #: Hash[String, String]
|
|
22
|
+
|
|
23
|
+
WINDOWS_DIR_NAMES = {
|
|
24
|
+
'chrome' => ['Google', 'Chrome', 'User Data'],
|
|
25
|
+
'chrome-beta' => ['Google', 'Chrome Beta', 'User Data'],
|
|
26
|
+
'chrome-canary' => ['Google', 'Chrome SxS', 'User Data'],
|
|
27
|
+
'chrome-dev' => ['Google', 'Chrome Dev', 'User Data'],
|
|
28
|
+
}.freeze #: Hash[String, Array[String]]
|
|
29
|
+
|
|
30
|
+
# @rbs channel: (String | Symbol) -- Chrome release channel
|
|
31
|
+
# @rbs platform: Symbol? -- Optional platform override
|
|
32
|
+
# @rbs env: Hash[String, String] -- Environment variables
|
|
33
|
+
# @rbs home: String? -- Home directory override
|
|
34
|
+
# @rbs return: String -- Default user data directory
|
|
35
|
+
def self.resolve_default(channel, platform: nil, env: ENV, home: nil)
|
|
36
|
+
channel = normalize_channel(channel)
|
|
37
|
+
platform ||= current_platform
|
|
38
|
+
home ||= Dir.home
|
|
39
|
+
|
|
40
|
+
case platform.to_sym
|
|
41
|
+
when :windows
|
|
42
|
+
base = env['LOCALAPPDATA']
|
|
43
|
+
base = join_path(:windows, home, 'AppData', 'Local') if base.nil? || base.empty?
|
|
44
|
+
join_path(:windows, base, *WINDOWS_DIR_NAMES.fetch(channel))
|
|
45
|
+
when :darwin
|
|
46
|
+
join_path(:darwin, home, 'Library', 'Application Support', 'Google', MAC_DIR_NAMES.fetch(channel))
|
|
47
|
+
when :linux
|
|
48
|
+
base = env['CHROME_CONFIG_HOME']
|
|
49
|
+
base = env['XDG_CONFIG_HOME'] if base.nil? || base.empty?
|
|
50
|
+
base = join_path(:linux, home, '.config') if base.nil? || base.empty?
|
|
51
|
+
join_path(:linux, base, LINUX_DIR_NAMES.fetch(channel))
|
|
52
|
+
else
|
|
53
|
+
raise ArgumentError.new("Unsupported platform: #{platform}")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# @rbs channel: (String | Symbol) -- Chrome release channel
|
|
58
|
+
# @rbs return: String -- Normalized channel
|
|
59
|
+
def self.normalize_channel(channel)
|
|
60
|
+
normalized_channel = channel.to_s
|
|
61
|
+
return normalized_channel if CHANNELS.include?(normalized_channel)
|
|
62
|
+
|
|
63
|
+
raise ArgumentError.new("Invalid channel: '#{channel}'. Allowed channel is #{CHANNELS}")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @rbs return: Symbol -- Current platform
|
|
67
|
+
def self.current_platform
|
|
68
|
+
if Puppeteer.env.windows?
|
|
69
|
+
:windows
|
|
70
|
+
elsif Puppeteer.env.darwin?
|
|
71
|
+
:darwin
|
|
72
|
+
else
|
|
73
|
+
:linux
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
private_class_method :current_platform
|
|
77
|
+
|
|
78
|
+
# @rbs platform: Symbol -- Target platform
|
|
79
|
+
# @rbs parts: String -- Path segments
|
|
80
|
+
# @rbs return: String -- Joined path
|
|
81
|
+
def self.join_path(platform, *parts)
|
|
82
|
+
if platform == :windows
|
|
83
|
+
parts.map(&:to_s).reject(&:empty?).join('\\')
|
|
84
|
+
else
|
|
85
|
+
File.join(*parts)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
private_class_method :join_path
|
|
89
|
+
end
|
data/lib/puppeteer/puppeteer.rb
CHANGED
|
@@ -140,6 +140,7 @@ class Puppeteer::Puppeteer
|
|
|
140
140
|
# @rbs browser_ws_endpoint: String? -- Browser WebSocket endpoint
|
|
141
141
|
# @rbs browser_url: String? -- Browser HTTP URL for WebSocket discovery
|
|
142
142
|
# @rbs transport: Puppeteer::WebSocketTransport? -- Pre-connected transport
|
|
143
|
+
# @rbs channel: (String | Symbol)? -- Browser channel
|
|
143
144
|
# @rbs ignore_https_errors: bool? -- Ignore HTTPS errors
|
|
144
145
|
# @rbs network_enabled: bool? -- Enable network domain
|
|
145
146
|
# @rbs issues_enabled: bool? -- Enable issues domain
|
|
@@ -153,11 +154,12 @@ class Puppeteer::Puppeteer
|
|
|
153
154
|
browser_ws_endpoint: nil,
|
|
154
155
|
browser_url: nil,
|
|
155
156
|
transport: nil,
|
|
157
|
+
channel: nil,
|
|
156
158
|
ignore_https_errors: nil,
|
|
157
159
|
network_enabled: true,
|
|
158
160
|
issues_enabled: true,
|
|
159
161
|
block_list: nil,
|
|
160
|
-
default_viewport:
|
|
162
|
+
default_viewport: NoViewport.new,
|
|
161
163
|
slow_mo: nil,
|
|
162
164
|
protocol_timeout: nil,
|
|
163
165
|
&block
|
|
@@ -166,14 +168,17 @@ class Puppeteer::Puppeteer
|
|
|
166
168
|
browser_ws_endpoint: browser_ws_endpoint,
|
|
167
169
|
browser_url: browser_url,
|
|
168
170
|
transport: transport,
|
|
171
|
+
channel: channel&.to_s,
|
|
169
172
|
ignore_https_errors: ignore_https_errors,
|
|
170
173
|
network_enabled: network_enabled,
|
|
171
174
|
issues_enabled: issues_enabled,
|
|
172
175
|
block_list: block_list,
|
|
173
|
-
default_viewport: default_viewport,
|
|
174
176
|
slow_mo: slow_mo,
|
|
175
177
|
protocol_timeout: protocol_timeout,
|
|
176
178
|
}.compact
|
|
179
|
+
unless default_viewport.is_a?(NoViewport)
|
|
180
|
+
options[:default_viewport] = default_viewport
|
|
181
|
+
end
|
|
177
182
|
if async_context?
|
|
178
183
|
browser = Puppeteer::BrowserConnector.new(options).connect_to_browser
|
|
179
184
|
if block
|
data/lib/puppeteer/version.rb
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated from lib/puppeteer/chrome_user_data_dir.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Puppeteer::ChromeUserDataDir
|
|
4
|
+
CHANNELS: Array[String]
|
|
5
|
+
|
|
6
|
+
MAC_DIR_NAMES: Hash[String, String]
|
|
7
|
+
|
|
8
|
+
LINUX_DIR_NAMES: Hash[String, String]
|
|
9
|
+
|
|
10
|
+
WINDOWS_DIR_NAMES: Hash[String, Array[String]]
|
|
11
|
+
|
|
12
|
+
# @rbs channel: (String | Symbol) -- Chrome release channel
|
|
13
|
+
# @rbs platform: Symbol? -- Optional platform override
|
|
14
|
+
# @rbs env: Hash[String, String] -- Environment variables
|
|
15
|
+
# @rbs home: String? -- Home directory override
|
|
16
|
+
# @rbs return: String -- Default user data directory
|
|
17
|
+
def self.resolve_default: (String | Symbol channel, ?platform: Symbol?, ?env: Hash[String, String], ?home: String?) -> String
|
|
18
|
+
|
|
19
|
+
# @rbs channel: (String | Symbol) -- Chrome release channel
|
|
20
|
+
# @rbs return: String -- Normalized channel
|
|
21
|
+
def self.normalize_channel: (String | Symbol channel) -> String
|
|
22
|
+
|
|
23
|
+
# @rbs return: Symbol -- Current platform
|
|
24
|
+
def self.current_platform: () -> Symbol
|
|
25
|
+
|
|
26
|
+
# @rbs platform: Symbol -- Target platform
|
|
27
|
+
# @rbs parts: String -- Path segments
|
|
28
|
+
# @rbs return: String -- Joined path
|
|
29
|
+
def self.join_path: (Symbol platform, *untyped parts) -> String
|
|
30
|
+
end
|
data/sig/puppeteer/puppeteer.rbs
CHANGED
|
@@ -42,6 +42,7 @@ class Puppeteer::Puppeteer
|
|
|
42
42
|
# @rbs browser_ws_endpoint: String? -- Browser WebSocket endpoint
|
|
43
43
|
# @rbs browser_url: String? -- Browser HTTP URL for WebSocket discovery
|
|
44
44
|
# @rbs transport: Puppeteer::WebSocketTransport? -- Pre-connected transport
|
|
45
|
+
# @rbs channel: (String | Symbol)? -- Browser channel
|
|
45
46
|
# @rbs ignore_https_errors: bool? -- Ignore HTTPS errors
|
|
46
47
|
# @rbs network_enabled: bool? -- Enable network domain
|
|
47
48
|
# @rbs issues_enabled: bool? -- Enable issues domain
|
|
@@ -51,7 +52,7 @@ class Puppeteer::Puppeteer
|
|
|
51
52
|
# @rbs protocol_timeout: Integer? -- CDP protocol timeout in milliseconds
|
|
52
53
|
# @rbs block: Proc? -- Optional block receiving the browser
|
|
53
54
|
# @rbs return: Puppeteer::Browser -- Browser instance
|
|
54
|
-
def connect: (?browser_ws_endpoint: String?, ?browser_url: String?, ?transport: Puppeteer::WebSocketTransport?, ?ignore_https_errors: bool?, ?network_enabled: bool?, ?issues_enabled: bool?, ?block_list: Array[String]?, ?default_viewport: Puppeteer::Viewport?, ?slow_mo: Integer?, ?protocol_timeout: Integer?) ?{ (?) -> untyped } -> Puppeteer::Browser
|
|
55
|
+
def connect: (?browser_ws_endpoint: String?, ?browser_url: String?, ?transport: Puppeteer::WebSocketTransport?, ?channel: (String | Symbol)?, ?ignore_https_errors: bool?, ?network_enabled: bool?, ?issues_enabled: bool?, ?block_list: Array[String]?, ?default_viewport: Puppeteer::Viewport?, ?slow_mo: Integer?, ?protocol_timeout: Integer?) ?{ (?) -> untyped } -> Puppeteer::Browser
|
|
55
56
|
|
|
56
57
|
# @rbs channel: String? -- Browser channel
|
|
57
58
|
# @rbs return: String -- Executable path
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puppeteer-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.52.
|
|
4
|
+
version: 0.52.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- YusukeIwaki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async
|
|
@@ -317,6 +317,7 @@ files:
|
|
|
317
317
|
- lib/puppeteer/browser_runner.rb
|
|
318
318
|
- lib/puppeteer/cdp_session.rb
|
|
319
319
|
- lib/puppeteer/chrome_target_manager.rb
|
|
320
|
+
- lib/puppeteer/chrome_user_data_dir.rb
|
|
320
321
|
- lib/puppeteer/connection.rb
|
|
321
322
|
- lib/puppeteer/console_message.rb
|
|
322
323
|
- lib/puppeteer/console_patch.rb
|
|
@@ -399,6 +400,7 @@ files:
|
|
|
399
400
|
- sig/_supplementary.rbs
|
|
400
401
|
- sig/puppeteer/browser.rbs
|
|
401
402
|
- sig/puppeteer/cdp_session.rbs
|
|
403
|
+
- sig/puppeteer/chrome_user_data_dir.rbs
|
|
402
404
|
- sig/puppeteer/dialog.rbs
|
|
403
405
|
- sig/puppeteer/element_handle.rbs
|
|
404
406
|
- sig/puppeteer/execution_context.rbs
|