grover 1.1.5 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9685b557f5d1cdc200fe5806aadc59106ccb9d6572e4d57c1660964286b3f4c7
4
- data.tar.gz: b0584418598e6ca66b097b8e9ffc87ad5bbd6ae64becf74966ceef4b4d894730
3
+ metadata.gz: e791010e46d99d4347edc987fc2a7b90b08d038a1449cf927b57b828e58f1d59
4
+ data.tar.gz: 62837cb867ec1728c000c91b33352f01a1c4beb5b0823647dff74946d09c0cbd
5
5
  SHA512:
6
- metadata.gz: cfad1954989183edd8f9cd238085c6031ec9cfca25b61dbe6e83fd33bd733c4d60b97b64da59d9b6301b538aa26979e8e9813b40765fa34fd03a17f47f46897c
7
- data.tar.gz: e06271f0ede0792519f7a6d1156b04e5d5465921b8b75d36438fffdf62a491c54029c73f070de6241cb4cb1654e548024115634fe27c80fa1ee1b056375d20c9
6
+ metadata.gz: 1471dda6f9817f921ae1f7ef88cbdf0ffab143448b1057ef1e3f71f5d91a9fce95b77fbece05f10c0823b51fbc181a4138ae5a6c6db437074c2d95143e90fa4d
7
+ data.tar.gz: fad1c63de120fb414aa23ffcf0b2adec6e419550ec2add1c5008ce3e1d855343934bbae4de1e9a14f8c74e974699ad7a74aad2a22bc2d6ef7ba1cd8850a73b36
@@ -1,13 +1,25 @@
1
1
  // Setup imports
2
2
  try {
3
3
  const Module = require('module');
4
- // resolve puppeteer from the CWD instead of where this script is located
5
- var puppeteer = require(require.resolve('puppeteer', { paths: Module._nodeModulePaths(process.cwd()) }));
4
+
5
+ try {
6
+ // resolve puppeteer from the CWD instead of where this script is located
7
+ var puppeteer = require(require.resolve('puppeteer', { paths: Module._nodeModulePaths(process.cwd()) }));
8
+ } catch (puppeteerError) {
9
+ try {
10
+ // try resolve `puppeteer-core` library instead
11
+ var puppeteer = require(require.resolve('puppeteer-core', { paths: Module._nodeModulePaths(process.cwd()) }));
12
+ } catch (coreError) {
13
+ // raise the original puppeteer load issue so we don't send people don't the wrong rabbit hole by default.
14
+ throw puppeteerError;
15
+ }
16
+ }
6
17
  } catch (e) {
7
18
  process.stdout.write(JSON.stringify(['err', e.toString()]));
8
19
  process.stdout.write("\n");
9
20
  process.exit(1);
10
21
  }
22
+
11
23
  process.stdout.write("[\"ok\"]\n");
12
24
 
13
25
  const fs = require('fs');
@@ -15,7 +27,7 @@ const os = require('os');
15
27
  const path = require('path');
16
28
 
17
29
  const _processPage = (async (convertAction, urlOrHtml, options) => {
18
- let browser, errors = [], tmpDir;
30
+ let browser, page, errors = [], tmpDir, wsConnection = false;
19
31
 
20
32
  try {
21
33
  // Configure puppeteer debugging options
@@ -25,8 +37,18 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
25
37
  const connectParams = {
26
38
  browserWSEndpoint: browserWsEndpoint,
27
39
  };
28
-
29
- browser = await puppeteer.connect(connectParams);
40
+ wsConnection = true;
41
+
42
+ try {
43
+ browser = await puppeteer.connect(connectParams);
44
+ } catch {
45
+ function WsConnectFailedError() {
46
+ this.name = "WsConnectFailedError";
47
+ this.message = `Failed to connect to browser WS endpoint: ${browserWsEndpoint}`;
48
+ }
49
+ WsConnectFailedError.prototype = Error.prototype;
50
+ throw new WsConnectFailedError();
51
+ }
30
52
  } else {
31
53
  tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'grover-'));
32
54
 
@@ -34,29 +56,29 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
34
56
  args: process.env.GROVER_NO_SANDBOX === 'true' ? ['--no-sandbox', '--disable-setuid-sandbox'] : [],
35
57
  userDataDir: tmpDir
36
58
  };
37
-
59
+
38
60
  if (typeof debug === 'object' && !!debug) {
39
61
  if (debug.headless !== undefined) { launchParams.headless = debug.headless; }
40
62
  if (debug.devtools !== undefined) { launchParams.devtools = debug.devtools; }
41
63
  }
42
-
64
+
43
65
  // Configure additional launch arguments
44
66
  const args = options.launchArgs; delete options.launchArgs;
45
67
  if (Array.isArray(args)) {
46
68
  launchParams.args = launchParams.args.concat(args);
47
69
  }
48
-
70
+
49
71
  // Set executable path if given
50
72
  const executablePath = options.executablePath; delete options.executablePath;
51
73
  if (executablePath) {
52
74
  launchParams.executablePath = executablePath;
53
75
  }
54
-
76
+
55
77
  // Launch the browser and create a page
56
78
  browser = await puppeteer.launch(launchParams);
57
79
  }
58
80
 
59
- const page = await browser.newPage();
81
+ page = await browser.newPage();
60
82
 
61
83
  // Basic auth
62
84
  const username = options.username; delete options.username
@@ -261,7 +283,12 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
261
283
  }
262
284
  } finally {
263
285
  if (browser) {
264
- await browser.close();
286
+ if (wsConnection) {
287
+ if (page) await page.close();
288
+ await browser.disconnect();
289
+ } else {
290
+ await browser.close();
291
+ }
265
292
  }
266
293
 
267
294
  try {
@@ -70,7 +70,7 @@ class Grover
70
70
 
71
71
  def ignore_request?
72
72
  ignore_request = Grover.configuration.ignore_request
73
- return unless ignore_request.is_a?(Proc)
73
+ return false unless ignore_request.is_a?(Proc)
74
74
 
75
75
  ignore_request.call @request
76
76
  end
@@ -9,6 +9,7 @@ class Grover
9
9
  #
10
10
  class OptionsBuilder < Hash
11
11
  def initialize(options, url)
12
+ super()
12
13
  @url = url
13
14
  combined = grover_configuration
14
15
  Utils.deep_merge! combined, Utils.deep_stringify_keys(options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Grover
4
- VERSION = '1.1.5'
4
+ VERSION = '1.1.7'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2024-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: childprocess
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: mini_magick
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '2.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: puma
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '6.4'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rack-test
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +178,20 @@ dependencies:
150
178
  - - "~>"
151
179
  - !ruby/object:Gem::Version
152
180
  version: '2.18'
181
+ - !ruby/object:Gem::Dependency
182
+ name: sinatra
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '3.2'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '3.2'
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: simplecov
155
197
  requirement: !ruby/object:Gem::Requirement
@@ -208,14 +250,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
250
  version: 2.7.0
209
251
  - - "<"
210
252
  - !ruby/object:Gem::Version
211
- version: 3.3.0
253
+ version: 3.4.0
212
254
  required_rubygems_version: !ruby/object:Gem::Requirement
213
255
  requirements:
214
256
  - - ">="
215
257
  - !ruby/object:Gem::Version
216
258
  version: '0'
217
259
  requirements: []
218
- rubygems_version: 3.2.3
260
+ rubygems_version: 3.3.7
219
261
  signing_key:
220
262
  specification_version: 4
221
263
  summary: A Ruby gem to transform HTML into PDF, PNG or JPEG by wrapping the NodeJS