puppeteer-ruby 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +62 -0
- data/lib/puppeteer/browser.rb +0 -2
- data/lib/puppeteer/concurrent_ruby_utils.rb +6 -3
- data/lib/puppeteer/page.rb +25 -13
- data/lib/puppeteer/page/screenshot_options.rb +2 -2
- data/lib/puppeteer/page/screenshot_task_queue.rb +13 -0
- data/lib/puppeteer/target.rb +2 -4
- data/lib/puppeteer/version.rb +1 -1
- data/puppeteer-ruby.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f76be710be28b32694ef8d21bcaa305f00b8ac0ada333d2992137f166614bd94
|
4
|
+
data.tar.gz: 29d4c83aaa00705db67dd1a33b62b304b125fc59bd5f826099a9f864202f3e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5dbf6ee744fdb70d7645bdfaf3840088d756b31a0dfcf05109058299d07ea338967c019ee4a55f834bc388b39cfc19b147ac7f08d80762d5eb44ed8517d0f1a
|
7
|
+
data.tar.gz: 05a88198b74788638619bbdef3faaede3503c61a5b6574a562180265f5f927a236a564b3f0d73dfefcaa442b492227b934f7233ad72183924b98d66e242e4850
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.25...master)]
|
2
|
+
|
3
|
+
* xxx
|
4
|
+
|
5
|
+
### 0.0.25 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.23...0.0.25)]
|
6
|
+
|
7
|
+
New feature:
|
8
|
+
|
9
|
+
* **Cookie** feature: `Page#set_cookie`, `Page#cookies`
|
10
|
+
|
11
|
+
### 0.0.23 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.22...0.0.23)]
|
12
|
+
|
13
|
+
New feature:
|
14
|
+
|
15
|
+
* **GeoLocation** feature
|
16
|
+
* grant/clear permission
|
17
|
+
|
18
|
+
Bugfix/Improvement:
|
19
|
+
|
20
|
+
* Refactoring for events ([#31](https://github.com/YusukeIwaki/puppeteer-ruby/pull/31))
|
21
|
+
* Improve SEND/RECV handling in CDPSession ([#34](https://github.com/YusukeIwaki/puppeteer-ruby/pull/34))
|
22
|
+
|
23
|
+
### 0.0.22 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.21...0.0.22)]
|
24
|
+
|
25
|
+
Bugfix
|
26
|
+
|
27
|
+
* Make `Puppeteer#default_args` to work
|
28
|
+
* Respect Firefox launch options
|
29
|
+
* Respect `default_viewport: nil`
|
30
|
+
|
31
|
+
### 0.0.21 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.20...0.0.21)]
|
32
|
+
|
33
|
+
Bugfix/Improvement:
|
34
|
+
|
35
|
+
* Update DeviceDescriptors (list of emulatable devices)
|
36
|
+
* Fix bug on inputing "(" ([#25](https://github.com/YusukeIwaki/puppeteer-ruby/pull/25))
|
37
|
+
|
38
|
+
### 0.0.20 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.19...0.0.20)]
|
39
|
+
|
40
|
+
New feature
|
41
|
+
|
42
|
+
* Dialog-handling feature
|
43
|
+
|
44
|
+
### 0.0.19 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.18...0.0.19)]
|
45
|
+
|
46
|
+
New feature
|
47
|
+
|
48
|
+
* **Firefox support**
|
49
|
+
|
50
|
+
Bugfix/Improvement
|
51
|
+
|
52
|
+
* Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
|
53
|
+
|
54
|
+
### 0.0.18 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.17...0.0.18)]
|
55
|
+
|
56
|
+
New feature
|
57
|
+
|
58
|
+
* **Firefox support**
|
59
|
+
|
60
|
+
Bugfix/Improvement
|
61
|
+
|
62
|
+
* Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
|
data/lib/puppeteer/browser.rb
CHANGED
@@ -36,7 +36,6 @@ class Puppeteer::Browser
|
|
36
36
|
@ignore_https_errors = ignore_https_errors
|
37
37
|
@default_viewport = default_viewport
|
38
38
|
@process = process
|
39
|
-
# @screenshot_task_queue = TaskQueue.new
|
40
39
|
@connection = connection
|
41
40
|
@close_callback = close_callback
|
42
41
|
|
@@ -125,7 +124,6 @@ class Puppeteer::Browser
|
|
125
124
|
session_factory: -> { @connection.create_session(target_info) },
|
126
125
|
ignore_https_errors: @ignore_https_errors,
|
127
126
|
default_viewport: @default_viewport,
|
128
|
-
screenshot_task_queue: @screenshot_task_queue,
|
129
127
|
)
|
130
128
|
# assert(!this._targets.has(event.targetInfo.targetId), 'Target should not exist before targetCreated');
|
131
129
|
@targets[target_info.target_id] = target
|
@@ -39,9 +39,12 @@ module Puppeteer::ConcurrentRubyUtils
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def future(&block)
|
43
|
-
Concurrent::Promises.future do
|
44
|
-
block.call
|
42
|
+
def future(*args, &block)
|
43
|
+
Concurrent::Promises.future(*args) do |*block_args|
|
44
|
+
block.call(*block_args)
|
45
|
+
rescue Puppeteer::TimeoutError
|
46
|
+
# suppress error logging
|
47
|
+
raise
|
45
48
|
rescue => err
|
46
49
|
Logger.new($stderr).warn(err)
|
47
50
|
raise err
|
data/lib/puppeteer/page.rb
CHANGED
@@ -3,6 +3,7 @@ require "stringio"
|
|
3
3
|
|
4
4
|
require_relative './page/pdf_options'
|
5
5
|
require_relative './page/screenshot_options'
|
6
|
+
require_relative './page/screenshot_task_queue'
|
6
7
|
|
7
8
|
class Puppeteer::Page
|
8
9
|
include Puppeteer::EventCallbackable
|
@@ -13,10 +14,9 @@ class Puppeteer::Page
|
|
13
14
|
# @param {!Puppeteer.Target} target
|
14
15
|
# @param {boolean} ignoreHTTPSErrors
|
15
16
|
# @param {?Puppeteer.Viewport} defaultViewport
|
16
|
-
# @param {!Puppeteer.TaskQueue} screenshotTaskQueue
|
17
17
|
# @return {!Promise<!Page>}
|
18
|
-
def self.create(client, target, ignore_https_errors, default_viewport
|
19
|
-
page = Puppeteer::Page.new(client, target, ignore_https_errors
|
18
|
+
def self.create(client, target, ignore_https_errors, default_viewport)
|
19
|
+
page = Puppeteer::Page.new(client, target, ignore_https_errors)
|
20
20
|
page.init
|
21
21
|
if default_viewport
|
22
22
|
page.viewport = default_viewport
|
@@ -27,8 +27,7 @@ class Puppeteer::Page
|
|
27
27
|
# @param {!Puppeteer.CDPSession} client
|
28
28
|
# @param {!Puppeteer.Target} target
|
29
29
|
# @param {boolean} ignoreHTTPSErrors
|
30
|
-
|
31
|
-
def initialize(client, target, ignore_https_errors, screenshot_task_queue)
|
30
|
+
def initialize(client, target, ignore_https_errors)
|
32
31
|
@closed = false
|
33
32
|
@client = client
|
34
33
|
@target = target
|
@@ -43,7 +42,7 @@ class Puppeteer::Page
|
|
43
42
|
@page_bindings = {}
|
44
43
|
# @coverage = Coverage.new(client)
|
45
44
|
@javascript_enabled = true
|
46
|
-
@screenshot_task_queue =
|
45
|
+
@screenshot_task_queue = ScreenshotTaskQueue.new
|
47
46
|
|
48
47
|
@workers = {}
|
49
48
|
@client.on_event('Target.attachedToTarget') do |event|
|
@@ -867,15 +866,28 @@ class Puppeteer::Page
|
|
867
866
|
main_frame.title
|
868
867
|
end
|
869
868
|
|
870
|
-
#
|
871
|
-
#
|
872
|
-
#
|
873
|
-
#
|
874
|
-
|
869
|
+
# @param type [String] "png"|"jpeg"
|
870
|
+
# @param path [String]
|
871
|
+
# @param full_page [Boolean]
|
872
|
+
# @param clip [Hash]
|
873
|
+
# @param quality [Integer]
|
874
|
+
# @param omit_background [Boolean]
|
875
|
+
# @param encoding [String]
|
876
|
+
def screenshot(type: nil, path: nil, full_page: nil, clip: nil, quality: nil, omit_background: nil, encoding: nil)
|
877
|
+
options = {
|
878
|
+
type: type,
|
879
|
+
path: path,
|
880
|
+
full_page: full_page,
|
881
|
+
clip: clip,
|
882
|
+
quality: quality,
|
883
|
+
omit_background: omit_background,
|
884
|
+
encoding: encoding,
|
885
|
+
}.compact
|
875
886
|
screenshot_options = ScreenshotOptions.new(options)
|
876
887
|
|
877
|
-
|
878
|
-
|
888
|
+
@screenshot_task_queue.post_task do
|
889
|
+
screenshot_task(screenshot_options.type, screenshot_options)
|
890
|
+
end
|
879
891
|
end
|
880
892
|
|
881
893
|
# @param {"png"|"jpeg"} format
|
@@ -32,14 +32,14 @@ class Puppeteer::Page
|
|
32
32
|
@type ||= 'png'
|
33
33
|
|
34
34
|
if options[:quality]
|
35
|
-
unless @type == '
|
35
|
+
unless @type == 'jpeg'
|
36
36
|
raise ArgumentError.new("options.quality is unsupported for the #{@type} screenshots")
|
37
37
|
end
|
38
38
|
unless options[:quality].is_a?(Numeric)
|
39
39
|
raise ArgumentError.new("Expected options.quality to be a number but found #{options[:quality].class}")
|
40
40
|
end
|
41
41
|
quality = options[:quality].to_i
|
42
|
-
unless (0..100).include?(
|
42
|
+
unless (0..100).include?(quality)
|
43
43
|
raise ArgumentError.new("Expected options.quality to be between 0 and 100 (inclusive), got #{quality}")
|
44
44
|
end
|
45
45
|
@quality = quality
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Puppeteer::Page
|
2
|
+
class ScreenshotTaskQueue
|
3
|
+
def initialize
|
4
|
+
@chain = Concurrent::Promises.fulfilled_future(nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
def post_task(&block)
|
8
|
+
result = @chain.then { block.call }
|
9
|
+
@chain = result.rescue { nil }
|
10
|
+
result.value!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/puppeteer/target.rb
CHANGED
@@ -18,15 +18,13 @@ class Puppeteer::Target
|
|
18
18
|
# @param {!function():!Promise<!Puppeteer.CDPSession>} sessionFactory
|
19
19
|
# @param {boolean} ignoreHTTPSErrors
|
20
20
|
# @param {?Puppeteer.Viewport} defaultViewport
|
21
|
-
|
22
|
-
def initialize(target_info:, browser_context:, session_factory:, ignore_https_errors:, default_viewport:, screenshot_task_queue:)
|
21
|
+
def initialize(target_info:, browser_context:, session_factory:, ignore_https_errors:, default_viewport:)
|
23
22
|
@target_info = target_info
|
24
23
|
@browser_context = browser_context
|
25
24
|
@target_id = target_info.target_id
|
26
25
|
@session_factory = session_factory
|
27
26
|
@ignore_https_errors = ignore_https_errors
|
28
27
|
@default_viewport = default_viewport
|
29
|
-
@screenshot_task_queue = screenshot_task_queue
|
30
28
|
|
31
29
|
|
32
30
|
# /** @type {?Promise<!Puppeteer.Page>} */
|
@@ -87,7 +85,7 @@ class Puppeteer::Target
|
|
87
85
|
def page
|
88
86
|
if ['page', 'background_page', 'webview'].include?(@target_info.type) && @page.nil?
|
89
87
|
client = @session_factory.call
|
90
|
-
@page = Puppeteer::Page.create(client, self, @ignore_https_errors, @default_viewport
|
88
|
+
@page = Puppeteer::Page.create(client, self, @ignore_https_errors, @default_viewport)
|
91
89
|
end
|
92
90
|
@page
|
93
91
|
end
|
data/lib/puppeteer/version.rb
CHANGED
data/puppeteer-ruby.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'websocket-driver', '>= 0.6.0'
|
23
23
|
spec.add_dependency 'mime-types', '>= 3.0'
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
25
|
+
spec.add_development_dependency 'chunky_png'
|
25
26
|
spec.add_development_dependency 'pry-byebug'
|
26
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
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.0.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: chunky_png
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry-byebug
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +207,7 @@ files:
|
|
193
207
|
- ".rspec"
|
194
208
|
- ".rubocop.yml"
|
195
209
|
- ".travis.yml"
|
210
|
+
- CHANGELOG.md
|
196
211
|
- Dockerfile
|
197
212
|
- Gemfile
|
198
213
|
- README.md
|
@@ -248,6 +263,7 @@ files:
|
|
248
263
|
- lib/puppeteer/page.rb
|
249
264
|
- lib/puppeteer/page/pdf_options.rb
|
250
265
|
- lib/puppeteer/page/screenshot_options.rb
|
266
|
+
- lib/puppeteer/page/screenshot_task_queue.rb
|
251
267
|
- lib/puppeteer/remote_object.rb
|
252
268
|
- lib/puppeteer/request.rb
|
253
269
|
- lib/puppeteer/response.rb
|