From 35e5ded8089f1bd1545325bd29e3f2a05cb7276e Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 4 Jun 2019 08:29:05 +0200 Subject: [PATCH] fix(core): update --- package-lock.json | 9 +++++++++ package.json | 4 ++-- ts/index.ts | 41 ++++++++++++++++++-------------------- ts/smartbrowser.plugins.ts | 6 ++---- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76979d1..55c352a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -282,6 +282,15 @@ "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz", "integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ==" }, + "@pushrocks/smartpuppeteer": { + "version": "1.0.5", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpuppeteer/-/smartpuppeteer-1.0.5.tgz", + "integrity": "sha512-7iD2mxQHXG5/6PwZY2wU6GQjNXy9dR5cLP/nvfjxXaelX/x3N1yagjPAuMYxuIqiTtVfrHC4Ehq+gnTZ4mSPow==", + "requires": { + "@types/puppeteer": "^1.12.4", + "puppeteer": "^1.17.0" + } + }, "@pushrocks/smartrequest": { "version": "1.1.15", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.15.tgz", diff --git a/package.json b/package.json index 0526dd2..09ac6e1 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "dependencies": { "@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartpdf": "^1.0.17", - "@pushrocks/smartunique": "^3.0.1", - "puppeteer": "^1.17.0" + "@pushrocks/smartpuppeteer": "^1.0.5", + "@pushrocks/smartunique": "^3.0.1" }, "devDependencies": { "@gitzone/tsbuild": "^2.1.11", diff --git a/ts/index.ts b/ts/index.ts index fcd22bb..948d083 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -6,9 +6,26 @@ import * as interfaces from './interfaces'; * SmartBrowser */ export class SmartBrowser { - public headlessBrowser: plugins.puppeteer.Browser; + public headlessBrowser: plugins.smartpuppeteer.puppeteer.Browser; public smartpdf: plugins.smartpdf.SmartPdf; + /** + * start the SmartBrowser instance + */ + public async start() { + this.headlessBrowser = await plugins.smartpuppeteer.getEnvAwareBrowserInstance(); + this.smartpdf = new plugins.smartpdf.SmartPdf(); + await this.smartpdf.start(this.headlessBrowser); + } + + /** + * stop the SmartBrowser instance + */ + public async stop() { + await this.headlessBrowser.close(); + await this.smartpdf.stop(); + } + /** * create a pdf from page * @param urlArg @@ -51,25 +68,5 @@ export class SmartBrowser { }); } - /** - * start a page - */ - public async start() { - this.headlessBrowser = await plugins.puppeteer.launch({ - defaultViewport: { - width: 1600, - height: 1080 - } - }); - this.smartpdf = new plugins.smartpdf.SmartPdf(); - await this.smartpdf.start(this.headlessBrowser); - } - - /** - * stops the smartbrowser instance - */ - public async stop() { - await this.headlessBrowser.close(); - await this.smartpdf.stop(); - } + } diff --git a/ts/smartbrowser.plugins.ts b/ts/smartbrowser.plugins.ts index 6a5a28c..d1367fa 100644 --- a/ts/smartbrowser.plugins.ts +++ b/ts/smartbrowser.plugins.ts @@ -1,10 +1,8 @@ // pushrocks scope import * as smartpdf from '@pushrocks/smartpdf'; +import * as smartpuppeteer from '@pushrocks/smartpuppeteer'; import * as smartunique from '@pushrocks/smartunique'; -export { smartpdf, smartunique }; +export { smartpdf, smartpuppeteer, smartunique }; // third party -import puppeteer from 'puppeteer'; - -export { puppeteer };