Socket
Socket
Sign inDemoInstall

critical

Package Overview
Dependencies
421
Maintainers
3
Versions
109
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.6 to 3.0.0

2

cli.js

@@ -170,3 +170,3 @@ #!/usr/bin/env node

// Cleanup camelized group keys
if (groupKeys.find((k) => key.includes(k)) && !validate(key, val)) {
if (groupKeys.some((k) => key.includes(k)) && !validate(key, val)) {
return res;

@@ -173,0 +173,0 @@ }

{
"name": "critical",
"version": "2.0.6",
"version": "3.0.0",
"description": "Extract & Inline Critical-path CSS from HTML",

@@ -26,31 +26,31 @@ "author": "Addy Osmani",

"engines": {
"node": ">=10"
"node": "^10 || ^12 || >=14"
},
"dependencies": {
"chalk": "^4.1.0",
"clean-css": "^4.2.3",
"clean-css": "^5.1.0",
"common-tags": "^1.8.0",
"css-url-parser": "^1.1.3",
"debug": "^4.2.0",
"debug": "^4.3.1",
"find-up": "^5.0.0",
"get-stdin": "^8.0.0",
"globby": "^11.0.1",
"got": "^11.8.0",
"globby": "^11.0.2",
"got": "^11.8.1",
"group-args": "^0.1.0",
"indent-string": "^4.0.0",
"inline-critical": "^6.0.1",
"inline-critical": "^6.0.3",
"is-glob": "^4.0.1",
"joi": "^17.3.0",
"lodash": "^4.17.20",
"joi": "^17.4.0",
"lodash": "^4.17.21",
"make-dir": "^3.1.0",
"meow": "^8.0.0",
"oust": "^1.0.2",
"meow": "^9.0.0",
"oust": "^1.0.4",
"p-all": "^3.0.0",
"penthouse": "^2.3.2",
"plugin-error": "^1.0.1",
"postcss": "^7.0.35",
"postcss": "^8.2.6",
"postcss-discard": "^1.0.1",
"postcss-image-inliner": "^4.0.3",
"postcss-url": "^8.0.0",
"prettier": "^2.1.2",
"postcss-image-inliner": "^4.0.4",
"postcss-url": "^10.1.1",
"prettier": "^2.2.1",
"replace-ext": "^2.0.0",

@@ -66,4 +66,4 @@ "slash": "^3.0.0",

"get-port": "^5.1.1",
"jest": "^26.6.1",
"nock": "^13.0.4",
"jest": "^26.6.3",
"nock": "^13.0.8",
"normalize-newline": "^3.0.0",

@@ -74,3 +74,3 @@ "serve-static": "^1.14.1",

"vinyl-source-stream": "^2.0.0",
"xo": "^0.34.1"
"xo": "^0.38.1"
},

@@ -85,2 +85,4 @@ "xo": {

"unicorn/no-reduce": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-fn-reference-in-iterator": "off"

@@ -87,0 +89,0 @@ },

@@ -17,3 +17,3 @@ 'use strict';

inlineImages: false,
concurrency: Infinity,
concurrency: Number.POSITIVE_INFINITY,
include: [],

@@ -20,0 +20,0 @@ };

@@ -77,3 +77,8 @@ 'use strict';

const result = penthouse({...config, width, height});
debug('Call penthouse with:', {...config, width, height});
debug('Call penthouse with:', {
...config,
width,
height,
cssString: `${(cssString || '').slice(0, 10)} ... ${(cssString || '').slice(-10)}`,
});

@@ -107,3 +112,3 @@ return result;

strict,
concurrency = Infinity,
concurrency = Number.POSITIVE_INFINITY,
assetPaths = [],

@@ -207,6 +212,4 @@ } = options;

// If replaceStylesheets is not set via option and and uncritical is empty
if (extract && replaceStylesheets === undefined) {
if (result.uncritical.trim() === '') {
inline.replaceStylesheets = [];
}
if (extract && replaceStylesheets === undefined && result.uncritical.trim() === '') {
inline.replaceStylesheets = [];
}

@@ -213,0 +216,0 @@

@@ -253,3 +253,3 @@ 'use strict';

*/
function rebaseAssets(css, from, to, method = 'rebase') {
async function rebaseAssets(css, from, to, method = 'rebase') {
let rebased = css.toString();

@@ -283,9 +283,11 @@

rebased = postcss()
const result = await postcss()
.use(postcssUrl({url: transform}))
.process(css, {from, to}).css;
.process(css, {from, to});
rebased = result.css;
} else if (from && to) {
rebased = postcss()
const result = await postcss()
.use(postcssUrl({url: method}))
.process(css, {from, to}).css;
.process(css, {from, to});
rebased = result.css;
}

@@ -601,3 +603,3 @@

base && from && path.join(base, path.dirname(from)),
base && isRelative(file) && hops ? path.join(base, ...new Array(hops).fill('tmpdir'), file) : '',
base && isRelative(file) && hops ? path.join(base, ...Array.from({length: hops}).fill('tmpdir'), file) : '',
process.cwd(),

@@ -734,5 +736,5 @@ ]),

if (rebase.from && rebase.to) {
file.contents = rebaseAssets(file.contents, rebase.from, rebase.to);
file.contents = await rebaseAssets(file.contents, rebase.from, rebase.to);
} else if (typeof rebase === 'function') {
file.contents = rebaseAssets(file.contents, stylepath, document.virtualPath, rebase);
file.contents = await rebaseAssets(file.contents, stylepath, document.virtualPath, rebase);
// Next rebase to the stylesheet url

@@ -743,14 +745,14 @@ } else if (isRemote(rebase.to || stylepath)) {

const method = (asset) => (isRemote(asset.originUrl) ? asset.originUrl : urlResolve(to, asset.originUrl));
file.contents = rebaseAssets(file.contents, from, to, method);
file.contents = await rebaseAssets(file.contents, from, to, method);
// Use relative path to document (local)
} else if (document.virtualPath) {
file.contents = rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || document.virtualPath);
file.contents = await rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || document.virtualPath);
} else if (document.remote) {
const {pathname} = document.urlObj;
file.contents = rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || pathname);
file.contents = await rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || pathname);
// Make images absolute if we have an absolute positioned stylesheet
} else if (path.isAbsolute(stylepath)) {
file.contents = rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || '/index.html', (asset) =>
file.contents = await rebaseAssets(file.contents, rebase.from || stylepath, rebase.to || '/index.html', (asset) =>
normalizePath(asset.absolutePath)

@@ -757,0 +759,0 @@ );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc