Compare commits

..

6 Commits

Author SHA1 Message Date
fa99b7f068 2.0.1 2019-11-19 16:28:14 +00:00
3e865b6c92 fix(ci): update snyk step for faster testing 2019-11-19 16:28:13 +00:00
94dd576d3b 2.0.0 2019-11-19 15:53:14 +00:00
9c19b4a3e4 BREAKING CHANGE(API): now clearly naming PDF Results what they are. 2019-11-19 15:53:14 +00:00
1155656c2b 1.0.29 2019-11-16 00:50:12 +01:00
5cf23c1134 fix(core): update 2019-11-16 00:50:11 +01:00
5 changed files with 37 additions and 23 deletions

View File

@ -25,10 +25,10 @@ mirror:
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:

40
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpdf",
"version": "1.0.28",
"version": "2.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -140,11 +140,21 @@
"version": "2.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^3.0.6"
}
},
"@pushrocks/smartenv": {
"version": "4.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.8.tgz",
"integrity": "sha512-gKEL1/ogJwss2b/xjbOen5s+9geT5XUvNXuD1qUpc1t5P9w0BaXXuLw7vz1pVRxb/NWtmPLRIdVbAxL1OmmwCg==",
"requires": {
"@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^3.0.6",
"@types/node": "^12.12.7",
"is-wsl": "^2.1.1"
}
},
"@pushrocks/smartevent": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",
@ -256,7 +266,6 @@
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartparam/-/smartparam-1.0.4.tgz",
"integrity": "sha512-UAqhnTQGBaJRptTK3qTd47Yt2ZTrAWByteow4auSNZD+k0xrpY9mTPPgKh0IwsURe0cZhj7zYNpGiekhKkL4rA==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"is-promise": "^2.1.0",
@ -266,8 +275,7 @@
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==",
"dev": true
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
}
},
@ -282,10 +290,12 @@
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
},
"@pushrocks/smartpuppeteer": {
"version": "1.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpuppeteer/-/smartpuppeteer-1.0.6.tgz",
"integrity": "sha512-cn/puPrF63HKbFh/zlTrpqLg73rEDgk+q4Ru2bIStDQkwSsZobEdAV5x+Ll2guOYHGLBNMSxIsvqe1joMhdCLA==",
"version": "1.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpuppeteer/-/smartpuppeteer-1.0.11.tgz",
"integrity": "sha512-a38EUpOigY5PYFFgl/N6tkPdv4GYvU5zRAb+adwZts1uNe15UIKpC7upkA2QykuYU0ueMgc0a+JMB1qeJsA7HQ==",
"requires": {
"@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartenv": "^4.0.8",
"@types/puppeteer": "^1.20.2",
"puppeteer": "^2.0.0"
}
@ -508,9 +518,9 @@
"dev": true
},
"@types/node": {
"version": "12.12.7",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
"version": "12.12.8",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.8.tgz",
"integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w=="
},
"@types/portscanner": {
"version": "2.1.0",
@ -1501,8 +1511,7 @@
"is-promise": {
"version": "2.1.0",
"resolved": "https://verdaccio.lossless.one/is-promise/-/is-promise-2.1.0.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
},
"is-regex": {
"version": "1.0.4",
@ -1525,6 +1534,11 @@
"has-symbols": "^1.0.0"
}
},
"is-wsl": {
"version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/is-wsl/-/is-wsl-2.1.1.tgz",
"integrity": "sha512-umZHcSrwlDHo2TGMXv0DZ8dIUGunZ2Iv68YZnrmCiBPkZ4aaOhtv7pXJKeki9k3qJ3RJr0cDyitcl5wEH3AYog=="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/isarray/-/isarray-1.0.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpdf",
"version": "1.0.28",
"version": "2.0.1",
"private": false,
"description": "create pdfs on the fly",
"main": "dist/index.js",
@ -17,7 +17,7 @@
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.12.7",
"@types/node": "^12.12.8",
"tslint": "^6.0.0-beta0",
"tslint-config-prettier": "^1.18.0"
},
@ -25,7 +25,7 @@
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartnetwork": "^1.1.14",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartpuppeteer": "^1.0.6",
"@pushrocks/smartpuppeteer": "^1.0.11",
"@pushrocks/smartunique": "^3.0.1",
"@types/express": "^4.17.2",
"express": "^4.17.1"

View File

@ -13,15 +13,15 @@ tap.test('should start the instance', async () => {
});
tap.test('should create a pdf from html string', async () => {
await testSmartPdf.getPdfForHtmlString('hi');
await testSmartPdf.getPdfResultForHtmlString('hi');
});
tap.test('should create a pdf from website as A4', async () => {
await testSmartPdf.getPdfForWebsite('https://maintainedby.lossless.com');
await testSmartPdf.getPdfResultForWebsite('https://www.wikipedia.org');
});
tap.test('should create a pdf from website as single page PDF', async () => {
await testSmartPdf.getFullWebsiteAsSinglePdf('https://maintainedby.lossless.com');
await testSmartPdf.getFullWebsiteAsSinglePdf('https://www.wikipedia.org');
});
tap.test('should create a valid PDFResult', async () => {

View File

@ -63,7 +63,7 @@ export class SmartPdf {
/**
* returns a pdf for a given html string;
*/
async getPdfForHtmlString(htmlStringArg: string): Promise<interfaces.IPdfResult> {
async getPdfResultForHtmlString(htmlStringArg: string): Promise<interfaces.IPdfResult> {
await this._readyDeferred.promise;
const pdfCandidate = new PdfCandidate(htmlStringArg);
this._candidates[pdfCandidate.pdfId] = pdfCandidate;
@ -96,9 +96,9 @@ export class SmartPdf {
};
}
async getPdfForWebsite(websiteUrl: string): Promise<interfaces.IPdfResult> {
async getPdfResultForWebsite(websiteUrl: string): Promise<interfaces.IPdfResult> {
const page = await this.headlessBrowser.newPage();
page.emulateMedia('screen');
await page.emulateMedia('screen');
const response = await page.goto(websiteUrl, { waitUntil: 'networkidle2' });
const pdfId = plugins.smartunique.shortId();
const { documentHeight, documentWidth } = await page.evaluate(() => {