phantomas 2.6.0 → 2.8.0
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.
- package/README.md +1 -1
- package/extensions/viewport/viewport.js +1 -1
- package/lib/browser.js +13 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ module.exports = function (phantomas) {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
phantomas.on("init", async (page) => {
|
|
32
|
-
// @see https://github.com/puppeteer/puppeteer/blob/
|
|
32
|
+
// @see https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.page.setviewport.md
|
|
33
33
|
await page.setViewport(options);
|
|
34
34
|
phantomas.log("page.setViewport() called with options %j", options);
|
|
35
35
|
});
|
package/lib/browser.js
CHANGED
|
@@ -26,7 +26,13 @@ Browser.prototype.init = async (phantomasOptions) => {
|
|
|
26
26
|
// page.evaluate throw "Protocol error (Runtime.callFunctionOn): Target closed." without the following
|
|
27
27
|
// https://github.com/GoogleChrome/puppeteer/issues/1175#issuecomment-369728215
|
|
28
28
|
"--disable-dev-shm-usage",
|
|
29
|
+
|
|
30
|
+
// make sure to default the viewport to a specific size
|
|
31
|
+
"--window-size=800,600",
|
|
29
32
|
],
|
|
33
|
+
// use the new Headless mode for Chrome
|
|
34
|
+
// https://developer.chrome.com/articles/new-headless/
|
|
35
|
+
headless: "new",
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
// handle Phantomas options
|
|
@@ -70,7 +76,7 @@ Browser.prototype.init = async (phantomasOptions) => {
|
|
|
70
76
|
debug("Launching Puppeteer: %j", options);
|
|
71
77
|
|
|
72
78
|
try {
|
|
73
|
-
// https://github.com/puppeteer/puppeteer/blob/main/docs/api.md
|
|
79
|
+
// https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.browserlaunchargumentoptions.md
|
|
74
80
|
this.browser = await puppeteer.launch(options);
|
|
75
81
|
this.page = await this.browser.newPage();
|
|
76
82
|
} catch (ex) /* istanbul ignore next */ {
|
|
@@ -328,11 +334,16 @@ Browser.prototype.close = async () => {
|
|
|
328
334
|
// https://github.com/puppeteer/puppeteer/blob/v1.11.0/docs/api.md#pagecloseoptions
|
|
329
335
|
if (this.page && !this.page.isClosed())
|
|
330
336
|
await this.page.close({ runBeforeUnload: true });
|
|
337
|
+
} catch (ex) /* istanbul ignore next */ {
|
|
338
|
+
debug("An exception was raised while closing the page: " + ex);
|
|
339
|
+
debug(ex);
|
|
340
|
+
}
|
|
331
341
|
|
|
342
|
+
try {
|
|
332
343
|
// The page is closed, let's close the browser
|
|
333
344
|
if (this.browser && this.browser.isConnected()) await this.browser.close();
|
|
334
345
|
} catch (ex) /* istanbul ignore next */ {
|
|
335
|
-
debug("An exception was raised
|
|
346
|
+
debug("An exception was raised while closing the browser: " + ex);
|
|
336
347
|
debug(ex);
|
|
337
348
|
}
|
|
338
349
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phantomas",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"author": "macbre <maciej.brencz@gmail.com> (http://macbre.net)",
|
|
5
5
|
"description": "Headless Chromium-based web performance metrics collector and monitoring tool",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "BSD-2-Clause",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=16.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"analyze-css": "^2.0.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"decamelize": "^5.0.0",
|
|
34
34
|
"fast-stats": "0.0.6",
|
|
35
35
|
"js-yaml": "^4.0.0",
|
|
36
|
-
"puppeteer": "^20.
|
|
36
|
+
"puppeteer": "^20.8.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@jest/globals": "^28.0.0",
|