grover 1.1.3 → 1.1.5

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: f7082a7b6e05f0898404a1df133ed2f2cf3d0bb71ab0098b6707b9a29aa76e65
4
- data.tar.gz: 2e458d1604e99fb8b0529982986cbffd45513fa4bf632e046ada76ae5bc30a51
3
+ metadata.gz: 9685b557f5d1cdc200fe5806aadc59106ccb9d6572e4d57c1660964286b3f4c7
4
+ data.tar.gz: b0584418598e6ca66b097b8e9ffc87ad5bbd6ae64becf74966ceef4b4d894730
5
5
  SHA512:
6
- metadata.gz: 438cd6b10944fc008017fa4fd48d6e5e7919916a8d61a34cf1d7fbbaf5471215ab40b13c3a446665fa2d6bea1788532a1e0a198c776256ee9ddb444501934948
7
- data.tar.gz: 76c38b2c307f7cdd41a2b8e67b854539e1ef2e34a6fda814cab64cfee911331dab7e8bfe3b468e165a2510ee679e244cf9ac8457a9fdaaef7886c3ab6ddc7256
6
+ metadata.gz: cfad1954989183edd8f9cd238085c6031ec9cfca25b61dbe6e83fd33bd733c4d60b97b64da59d9b6301b538aa26979e8e9813b40765fa34fd03a17f47f46897c
7
+ data.tar.gz: e06271f0ede0792519f7a6d1156b04e5d5465921b8b75d36438fffdf62a491c54029c73f070de6241cb4cb1654e548024115634fe27c80fa1ee1b056375d20c9
@@ -10,34 +10,52 @@ try {
10
10
  }
11
11
  process.stdout.write("[\"ok\"]\n");
12
12
 
13
+ const fs = require('fs');
14
+ const os = require('os');
15
+ const path = require('path');
16
+
13
17
  const _processPage = (async (convertAction, urlOrHtml, options) => {
14
- let browser, errors = [];
15
- try {
16
- const launchParams = {
17
- args: process.env.GROVER_NO_SANDBOX === 'true' ? ['--no-sandbox', '--disable-setuid-sandbox'] : []
18
- };
18
+ let browser, errors = [], tmpDir;
19
19
 
20
+ try {
20
21
  // Configure puppeteer debugging options
21
22
  const debug = options.debug; delete options.debug;
22
- if (typeof debug === 'object' && !!debug) {
23
- if (debug.headless !== undefined) { launchParams.headless = debug.headless; }
24
- if (debug.devtools !== undefined) { launchParams.devtools = debug.devtools; }
25
- }
26
-
27
- // Configure additional launch arguments
28
- const args = options.launchArgs; delete options.launchArgs;
29
- if (Array.isArray(args)) {
30
- launchParams.args = launchParams.args.concat(args);
31
- }
23
+ const browserWsEndpoint = options.browserWsEndpoint; delete options.browserWsEndpoint;
24
+ if (typeof browserWsEndpoint === "string") {
25
+ const connectParams = {
26
+ browserWSEndpoint: browserWsEndpoint,
27
+ };
32
28
 
33
- // Set executable path if given
34
- const executablePath = options.executablePath; delete options.executablePath;
35
- if (executablePath) {
36
- launchParams.executablePath = executablePath;
29
+ browser = await puppeteer.connect(connectParams);
30
+ } else {
31
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'grover-'));
32
+
33
+ const launchParams = {
34
+ args: process.env.GROVER_NO_SANDBOX === 'true' ? ['--no-sandbox', '--disable-setuid-sandbox'] : [],
35
+ userDataDir: tmpDir
36
+ };
37
+
38
+ if (typeof debug === 'object' && !!debug) {
39
+ if (debug.headless !== undefined) { launchParams.headless = debug.headless; }
40
+ if (debug.devtools !== undefined) { launchParams.devtools = debug.devtools; }
41
+ }
42
+
43
+ // Configure additional launch arguments
44
+ const args = options.launchArgs; delete options.launchArgs;
45
+ if (Array.isArray(args)) {
46
+ launchParams.args = launchParams.args.concat(args);
47
+ }
48
+
49
+ // Set executable path if given
50
+ const executablePath = options.executablePath; delete options.executablePath;
51
+ if (executablePath) {
52
+ launchParams.executablePath = executablePath;
53
+ }
54
+
55
+ // Launch the browser and create a page
56
+ browser = await puppeteer.launch(launchParams);
37
57
  }
38
58
 
39
- // Launch the browser and create a page
40
- browser = await puppeteer.launch(launchParams);
41
59
  const page = await browser.newPage();
42
60
 
43
61
  // Basic auth
@@ -245,6 +263,10 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
245
263
  if (browser) {
246
264
  await browser.close();
247
265
  }
266
+
267
+ try {
268
+ if (tmpDir) fs.rmSync(tmpDir, { recursive: true });
269
+ } catch { }
248
270
  }
249
271
  });
250
272
 
@@ -8,7 +8,7 @@ class Grover
8
8
  # Build options from Grover.configuration, meta_options, and passed-in options
9
9
  #
10
10
  class OptionsBuilder < Hash
11
- def initialize(options, url) # rubocop:disable Lint/MissingSuper
11
+ def initialize(options, url)
12
12
  @url = url
13
13
  combined = grover_configuration
14
14
  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.3'
4
+ VERSION = '1.1.5'
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.3
4
+ version: 1.1.5
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-01-20 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  - !ruby/object:Gem::Version
216
216
  version: '0'
217
217
  requirements: []
218
- rubygems_version: 3.4.1
218
+ rubygems_version: 3.2.3
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: A Ruby gem to transform HTML into PDF, PNG or JPEG by wrapping the NodeJS