Comparing version 5.0.2 to 5.1.0
@@ -21,3 +21,3 @@ "use strict"; | ||
const array_differ_1 = __importDefault(require("array-differ")); | ||
const easydate_1 = __importDefault(require("easydate")); | ||
const date_fns_1 = __importDefault(require("date-fns")); | ||
const get_res_1 = __importDefault(require("get-res")); | ||
@@ -78,12 +78,12 @@ const log_symbols_1 = __importDefault(require("log-symbols")); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield Promise.all(this.src().map((src) => __awaiter(this, void 0, void 0, function* () { | ||
const options = Object.assign({}, this.options, src.options); | ||
const sizes = array_uniq_1.default(src.sizes.filter(/./.test, /^\d{2,4}x\d{2,4}$/i)); | ||
const keywords = array_differ_1.default(src.sizes, sizes); | ||
this.urls.push(src.url); | ||
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) { | ||
return this.resolution(src.url, options); | ||
yield Promise.all(this.src().map((source) => __awaiter(this, void 0, void 0, function* () { | ||
const options = Object.assign({}, this.options, source.options); | ||
const sizes = array_uniq_1.default(source.sizes.filter(/./.test, /^\d{2,4}x\d{2,4}$/i)); | ||
const keywords = array_differ_1.default(source.sizes, sizes); | ||
this.urls.push(source.url); | ||
if (sizes.length === 0 && keywords.includes('w3counter')) { | ||
return this.resolution(source.url, options); | ||
} | ||
if (keywords.length > 0) { | ||
return this.viewport({ url: src.url, sizes, keywords }, options); | ||
return this.viewport({ url: source.url, sizes, keywords }, options); | ||
} | ||
@@ -93,3 +93,3 @@ for (const size of sizes) { | ||
// TODO: Make this concurrent | ||
this.items.push(yield this.create(src.url, size, options)); | ||
this.items.push(yield this.create(source.url, size, options)); | ||
} | ||
@@ -125,10 +125,10 @@ return undefined; | ||
} | ||
viewport(obj, options) { | ||
viewport(viewport, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (const item of yield viewportListMem(obj.keywords)) { | ||
for (const item of yield viewportListMem(viewport.keywords)) { | ||
this.sizes.push(item.size); | ||
obj.sizes.push(item.size); | ||
viewport.sizes.push(item.size); | ||
} | ||
for (const size of array_uniq_1.default(obj.sizes)) { | ||
this.items.push(yield this.create(obj.url, size, options)); | ||
for (const size of array_uniq_1.default(viewport.sizes)) { | ||
this.items.push(yield this.create(viewport.url, size, options)); | ||
} | ||
@@ -146,6 +146,6 @@ }); | ||
} | ||
create(uri, size, options) { | ||
create(url, size, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const basename = path_1.default.isAbsolute(uri) ? path_1.default.basename(uri) : uri; | ||
let hash = url_1.parse(uri).hash || ''; | ||
const basename = path_1.default.isAbsolute(url) ? path_1.default.basename(url) : url; | ||
let hash = url_1.parse(url).hash || ''; | ||
// Strip empty hash fragments: `#` `#/` `#!/` | ||
@@ -157,6 +157,7 @@ if (/^#!?\/?$/.test(hash)) { | ||
const filenameTemplate = lodash_template_1.default(`${options.filename}.${options.format}`); | ||
const now = Date.now(); | ||
let filename = filenameTemplate({ | ||
crop: options.crop ? '-cropped' : '', | ||
date: easydate_1.default('Y-M-d'), | ||
time: easydate_1.default('h-m-s'), | ||
date: date_fns_1.default.format(now, 'YYYY-MM-DD'), | ||
time: date_fns_1.default.format(now, 'HH-mm-ss'), | ||
size, | ||
@@ -192,3 +193,3 @@ width, | ||
} | ||
const screenshot = yield capture_website_1.default.buffer(uri, finalOptions); | ||
const screenshot = yield capture_website_1.default.buffer(url, finalOptions); | ||
screenshot.filename = filename; | ||
@@ -195,0 +196,0 @@ return screenshot; |
{ | ||
"name": "pageres", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"description": "Capture website screenshots", | ||
@@ -58,5 +58,5 @@ "license": "MIT", | ||
"array-uniq": "^2.0.0", | ||
"capture-website": "^0.1.2", | ||
"easydate": "^2.0.0", | ||
"filenamify": "^2.0.0", | ||
"capture-website": "^0.3.0", | ||
"date-fns": "^1.30.1", | ||
"filenamify": "^3.0.0", | ||
"filenamify-url": "^1.0.0", | ||
@@ -69,9 +69,9 @@ "get-res": "^3.0.0", | ||
"plur": "^3.0.1", | ||
"unused-filename": "^1.0.0", | ||
"unused-filename": "^2.0.0", | ||
"viewport-list": "^5.0.1" | ||
}, | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^0.2.0", | ||
"@sindresorhus/tsconfig": "^0.3.0", | ||
"@types/image-size": "^0.7.0", | ||
"@types/node": "^10.12.23", | ||
"@types/node": "^11.11.4", | ||
"@typescript-eslint/eslint-plugin": "^1.3.0", | ||
@@ -82,3 +82,3 @@ "ava": "^1.2.0", | ||
"del-cli": "^1.1.0", | ||
"eslint-config-xo-typescript": "^0.7.0", | ||
"eslint-config-xo-typescript": "^0.9.0", | ||
"file-type": "^10.7.1", | ||
@@ -96,3 +96,3 @@ "get-port": "^4.1.0", | ||
}, | ||
"typings": "dist", | ||
"types": "dist", | ||
"ava": { | ||
@@ -102,4 +102,3 @@ "babel": false, | ||
"extensions": [ | ||
"ts", | ||
"js" | ||
"ts" | ||
], | ||
@@ -106,0 +105,0 @@ "require": [ |
@@ -103,4 +103,4 @@ # ![pageres](media/promo.png) | ||
- `crop`: Outputs `-cropped` when the crop option is true | ||
- `date`: The current date (Y-M-d), eg. 2015-05-18 | ||
- `time`: The current time (h-m-s), eg. 21-15-11 | ||
- `date`: The current date (YYYY-MM-DD), eg. 2015-05-18 | ||
- `time`: The current time (HH-mm-ss), eg. 21-15-11 | ||
@@ -225,2 +225,7 @@ ##### incrementalName | ||
## Related | ||
- [capture-website](https://github.com/sindresorhus/capture-website) - A different take on screenshotting websites | ||
## Team | ||
@@ -227,0 +232,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26376
255
239
+ Addeddate-fns@^1.30.1
+ Addedcapture-website@0.3.2(transitive)
+ Addeddate-fns@1.30.1(transitive)
+ Addedfilenamify@3.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedunused-filename@2.1.0(transitive)
- Removedeasydate@^2.0.0
- Removedbrowser-stdout@1.3.0(transitive)
- Removedcapture-website@0.1.2(transitive)
- Removedcommander@2.9.0(transitive)
- Removeddebug@2.6.8(transitive)
- Removeddiff@3.2.0(transitive)
- Removedeasydate@2.2.1(transitive)
- Removedfilenamify@2.1.0(transitive)
- Removedglob@7.1.1(transitive)
- Removedgraceful-readlink@1.0.1(transitive)
- Removedgrowl@1.9.2(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedhe@1.1.1(transitive)
- Removedjson3@3.3.2(transitive)
- Removedlodash._baseassign@3.2.0(transitive)
- Removedlodash._basecopy@3.0.1(transitive)
- Removedlodash._basecreate@3.0.3(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash._isiterateecall@3.0.9(transitive)
- Removedlodash.create@3.1.1(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.5.1(transitive)
- Removedmocha@3.5.3(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedsupports-color@3.1.2(transitive)
- Removedunused-filename@1.0.0(transitive)
Updatedcapture-website@^0.3.0
Updatedfilenamify@^3.0.0
Updatedunused-filename@^2.0.0