Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dropcss

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropcss - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

10

dist/dropcss.cjs.js

@@ -7,3 +7,3 @@ /**

* An exceptionally fast, thorough and tiny unused-CSS cleaner
* https://github.com/leeoniya/dropcss (v1.0.12)
* https://github.com/leeoniya/dropcss (v1.0.13)
*/

@@ -816,3 +816,3 @@

var CUSTOM_PROP_DEF = /(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm;
var CUSTOM_PROP_DEF = /([{};])\s*(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm;
var CUSTOM_PROP_USE = /var\(([\w-]+)\)/gm;

@@ -828,3 +828,3 @@ var COMMA_SPACED = /\s*,\s*/gm;

while (m = CUSTOM_PROP_DEF.exec(css))
{ defs[m[1]] = m[2]; }
{ defs[m[2]] = m[3]; }

@@ -925,3 +925,3 @@ // replace any non-composites

css = css2;
css2 = css.replace(CUSTOM_PROP_DEF, function (m, m1) { return css.indexOf('var(' + m1 + ')') != -1 ? m : ''; });
css2 = css.replace(CUSTOM_PROP_DEF, function (m, m1, m2) { return css.indexOf('var(' + m2 + ')') != -1 ? m : m1; });
} while (css2 != css);

@@ -938,3 +938,3 @@

// so does not need to be regenerated during iterative purging
var flatCss = resolveCustomProps(out).replace(CUSTOM_PROP_DEF, '');
var flatCss = resolveCustomProps(out).replace(CUSTOM_PROP_DEF, function (m, m1) { return m1; });

@@ -941,0 +941,0 @@ out = dropKeyFrames(out, flatCss, shouldDrop);

@@ -7,3 +7,3 @@ /**

* An exceptionally fast, thorough and tiny unused-CSS cleaner
* https://github.com/leeoniya/dropcss (v1.0.12)
* https://github.com/leeoniya/dropcss (v1.0.13)
*/

@@ -820,3 +820,3 @@

var CUSTOM_PROP_DEF = /(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm;
var CUSTOM_PROP_DEF = /([{};])\s*(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm;
var CUSTOM_PROP_USE = /var\(([\w-]+)\)/gm;

@@ -832,3 +832,3 @@ var COMMA_SPACED = /\s*,\s*/gm;

while (m = CUSTOM_PROP_DEF.exec(css))
{ defs[m[1]] = m[2]; }
{ defs[m[2]] = m[3]; }

@@ -929,3 +929,3 @@ // replace any non-composites

css = css2;
css2 = css.replace(CUSTOM_PROP_DEF, function (m, m1) { return css.indexOf('var(' + m1 + ')') != -1 ? m : ''; });
css2 = css.replace(CUSTOM_PROP_DEF, function (m, m1, m2) { return css.indexOf('var(' + m2 + ')') != -1 ? m : m1; });
} while (css2 != css);

@@ -942,3 +942,3 @@

// so does not need to be regenerated during iterative purging
var flatCss = resolveCustomProps(out).replace(CUSTOM_PROP_DEF, '');
var flatCss = resolveCustomProps(out).replace(CUSTOM_PROP_DEF, function (m, m1) { return m1; });

@@ -945,0 +945,0 @@ out = dropKeyFrames(out, flatCss, shouldDrop);

@@ -1,2 +0,2 @@

/*! https://github.com/leeoniya/dropcss (v1.0.12) */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).dropcss=r()}(this,function(){"use strict";function e(e,r,t){throw new Error(e+' parser stopped here: "'+r.substring(t,t+100)+'"')}var r=1,t=2,n=3,a=new Set("area base br col command embed hr img input keygen link meta param source track wbr".split(" ")),s=/<!doctype[^>]*>|<!--[\s\S]*?-->|<script[^>]*>[\s\S]*?<\/script>|<style[^>]*>[\s\S]*?<\/style>|<link[^>]*>|<meta[^>]*>/gim,i=/([\w-]+)(?:="([^"]*)"|='([^']*)'|=(\S+))?/gm,c={TAG_HEAD:/\s*<([\w-]+)(?:\s*([^>]*))?>\s*/imy,TEXT:/\s*[^<]*/my,TAG_CLOSE:/\s*<\/[\w-]+>\s*/imy};var o=new Set;function u(e,r,t){return{tagName:r,attributes:t,classList:null!=t&&t.has("class")?new Set(t.get("class").split(/\s+/g)):o,parentNode:e,childNodes:[]}}var l=[];function f(e,r){if(null!=e){var t=e._ofTypes=e._ofTypes||{};if(!(r in t)){var n=0;t[r]=e.childNodes.filter(function(e){if(e.tagName==r)return e._typeIdx=n++,!0})}return t[r]}return l}var d=function(l){var f=function(s){var o,u=0,l=[];function f(e){for(var r in u=e.lastIndex,c)c[r].lastIndex=u}function d(){if(null!=(o=c.TAG_CLOSE.exec(s)))return f(c.TAG_CLOSE),void l.push(n);if(null==(o=c.TAG_HEAD.exec(s)))null!=(o=c.TEXT.exec(s))&&f(c.TEXT);else{f(c.TAG_HEAD);var e=o[1];l.push(r,e);var u=o[2];if(null!=u){for(var d,h=new Map;d=i.exec(u);)h.set(d[1],(d[2]||d[3]||d[4]||"").trim());l.push(t,h)}(a.has(e)||u&&u.endsWith("/"))&&l.push(n)}}for(var h=u;u<s.length;)d(),h===u&&e("html",s,u),h=u;return f({lastIndex:0}),l}(l=l.replace(s,"")),d={nodes:[],tag:new Set(["*"]),class:new Set,attr:new Set};!function(e,a){for(var s,i=u(null,"root",o),c=0;c<e.length;c++)switch(e[c]){case r:var l=e[++c],f=o;e[c+1]===t&&(f=e[c+=2]),s=i.childNodes.length,i.childNodes.push(i=u(i,l,f)),a(i,s);break;case n:i=i.parentNode}}(f,function(e,r){return function(e,r,t){e.idx=r;var n=e.attributes;t.tag.add(e.tagName),e.classList.forEach(function(e){return t.class.add(e)}),n.has("id")&&t.attr.add("[id="+n.get("id")+"]"),n.has("type")&&t.attr.add("[type="+n.get("type")+"]"),t.nodes.push(e)}(e,r,d)});return d},h=/\s*\/\*[\s\S]*?\*\/\s*/gm,p=/\s*[>~+.#]\s*|\[[^\]]+\]|\s+/gm,v=1,x=2,g=3,m=4,y=5;function b(e){var r=e.split(/\s*,\s*/gm);return r.push(r.map(function(e){return function(e){for(var r=e.length;(e=e.replace(E,"")).length!=r;)r=e.length;return e.replace(/:?:[a-z-]+/gm,"")}(e).trim().replace(p,function(e,r){return e=e.trim(),0==r?e:"."==e||"#"==e?"`"+e:e.length<=1?"`":"`"+e.replace(/['"]/gm,"")}).split(/`+/gm)})),r}var E=/:[a-z-]+\([^()]*\)/;function k(e,r,t,n){for(var a="",s=1;e[r]==t?s++:e[r]==n&&s--,0!=s;)a+=e[r++];return a}function T(r){return function(r){var t,n={RULE_HEAD:/\s*([^{;]+?)\s*[{;]\s*/my,RULE_TAIL:/\s*([^}]*?)\s*\}/my,AT_TAIL:/\s*\}/my,RULE_FULL:/\s*([^{]*?)\{([^}]+?)\}/my},a=0,s=0,i=[];function c(e){for(var r in s=e.lastIndex,n)n[r].lastIndex=s}function o(){if(a>0&&null!=(t=n.AT_TAIL.exec(r)))return a--,i.push(x),void c(n.AT_TAIL);if(null!=(t=n.RULE_HEAD.exec(r))){var e=t[1];if(c(n.RULE_HEAD),"@"==e[0])switch(e.match(/@[a-z-]+/)[0]){case"@media":case"@supports":case"@document":a++,i.push(v,e);break;case"@import":case"@charset":case"@namespace":i.push(y,e+";");break;default:a++;var o=k(r,s,"{","}");c({lastIndex:s+o.length}),i.push(v,e,y,o)}else i.push(g,b(t[1])),t=n.RULE_TAIL.exec(r),i.push(m,t[1]),c(n.RULE_TAIL)}else s=r.length}for(var u=s;s<r.length;)o(),u===s&&e("css",r,s),u=s;return i}(r=r.replace(h,""))}function w(e){return e.replace(/@[a-z-]+[^{]+\{\s*\}/gm,"")}var I=/^([+-]?\d*)?n([+-]\d+)?$/;function A(e,r){return r==e.tagName||"*"==r}function _(e,r,t,n){n=n||"=";var a=e.attributes;if(a.has(r)){var s=a.get(r);switch(n){case"=":return null==t||t==s;case"*=":return-1!=s.indexOf(t);case"^=":return s.startsWith(t);case"$=":return s.endsWith(t);case"~=":return t==s||s.startsWith(t+" ")||s.endsWith(" "+t)||-1!=s.indexOf(" "+t+" ")}}return!1}function N(e,r){return e.classList.has(r)}function S(e,r){var t;if("odd"==r)t=e%2==1;else if("even"==r)t=e%2==0;else if(/^\d+$/.test(r))t=e==+r;else{var n=function(e){var r=I.exec(e);if(null!=r){var t=r[1],n=r[2];return[t=null==t||"+"==t?1:"-"==t?-1:+t,n=null==n?0:+n]}return[0,0]}(r);t=function(e,r,t){if(r<0&&e<=0)return!1;if(-1===e)return t<=r;if(0===e)return t===r;if(1===e)return r<0||t>=r;var n=r%e;return n<0&&(n+=e),e>1?t>=r&&t%e===n:(e*=-1,t<=r&&t%e===n)}(n[0],n[1],e)}return t}function L(e,r){return e.some(function(e){return function e(r,t){for(var n,a,s,i,c,o;t.idx>-1;){switch(r[t.idx]){case"_":n=r[--t.idx],o=A(t.node,n),t.idx--;break;case"#":a=r[--t.idx],o=_(t.node,"id",a,"="),t.idx--;break;case".":n=r[--t.idx],o=N(t.node,n),t.idx--;break;case"[":n=r[--t.idx],s=r[--t.idx],a=r[--t.idx],o=_(t.node,n,a,s),t.idx--;break;case":":n=r[--t.idx],a=r[--t.idx];var u=t.node,l=u.tagName;c=u.idx;var d=(i=u.parentNode)?i.childNodes.length:1,h=void 0;switch(n){case"not":o=!e(a,{node:t.node,idx:a.length-1});break;case"first-child":o=0==c;break;case"last-child":o=c==d-1;break;case"only-child":o=1==d;break;case"nth-child":o=S(c+1,a);break;case"nth-last-child":o=S(d-c,a);break;case"first-of-type":h=f(i,l),o=0==u._typeIdx;break;case"last-of-type":h=f(i,l),o=u._typeIdx==h.length-1;break;case"only-of-type":o=1==(h=f(i,l)).length;break;case"nth-of-type":h=f(i,l),o=S(u._typeIdx+1,a);break;case"nth-last-of-type":o=S((h=f(i,l)).length-u._typeIdx,a)}t.idx--;break;case" ":for(c=--t.idx,o=!1;!o&&null!=(i=t.node.parentNode);)t.idx=c,t.node=i,o=e(r,t);break;case">":t.idx--,null!=(i=t.node.parentNode)?(t.node=i,o=e(r,t)):o=!1;break;case"+":t.idx--,null!=(i=t.node.parentNode)&&t.node.idx>0?(t.node=i.childNodes[t.node.idx-1],o=e(r,t)):o=!1;break;case"~":if(t.idx--,o=!1,c=t.node.idx,null!=(i=t.node.parentNode)&&c>0)for(var p=0;p<c&&!o;p++)t.node=i.childNodes[p],o=e(r,t)}if(!o)break}return o}(r,{idx:r.length-1,node:e})})}var D=function(e,r){return L(e,Array.isArray(r)?r:function e(r){var t,n={IDENT:/([\w*-]+)/iy,ATTR:/([\w-]+)(?:(.?=)["']?([^\]]*?)["']?)?\]/iy,PSEUDO:/([\w-]+)(\()?/iy,MODE:/\s*[:.#\[]\s*/iy,COMB:/\s*[>~+]\s*|\s+/iy},a=0,s=[],i=-1;function c(e){for(var r in a=e.lastIndex,n)n[r].lastIndex=a}function o(){var a=!1;if(t=n.COMB.exec(r)){a=!0;var o=t[0].trim();""==o&&(o=" "),s.push(o),c(n.COMB),i=s.length-1}else if(t=n.MODE.exec(r)){a=!0;var u=t[0].trim();if(c(n.MODE),":"==u){if("("==(t=n.PSEUDO.exec(r))[2]){var l=k(r,n.PSEUDO.lastIndex,"(",")");n.PSEUDO.lastIndex+=l.length+1,t[2]="not"==t[1]?e(l):l}s.splice(i+1,0,t[2],t[1],u),c(n.PSEUDO)}else"["==u?(t=n.ATTR.exec(r),s.splice(i+1,0,t[3],t[2],t[1],u),c(n.ATTR)):(t=n.IDENT.exec(r),s.push(t[1],u),c(n.IDENT))}else(t=n.IDENT.exec(r))&&(a=!0,s.push(t[1],"_"),c(n.IDENT));return a}for(;a<r.length;)o();return s}(r))};function O(e,r,t,n,a){a=a||"";for(var s=r.length-1;s>-1;s--){var i=r[s];t.has(i[2])||!0!==n(a+i[2])||(c=e,o=i[0],u=i[1],l="",e=c.slice(0,o)+l+c.slice(o+u))}var c,o,u,l;return e}var R=/(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm,U=/var\(([\w-]+)\)/gm,M=/\s*,\s*/gm;function W(e){return e.trim().replace(/'|"/gm,"").split(M)}function z(e,r,t,n){var a=function(e){for(var r,t={};U.test(e);){for(;r=R.exec(e);)t[r[1]]=r[2];e=e.replace(U,function(e,r){return U.test(t[r])?e:t[r]})}return e}(e).replace(R,"");return(e=function(e,r){var t=e;do{t=(e=t).replace(R,function(r,t){return-1!=e.indexOf("var("+t+")")?r:""})}while(t!=e);return t}(e=function(e,r,t){for(var n,a="@font-face[^}]+\\}+",s=RegExp(a,"gm"),i=[];n=s.exec(e);)i.push([n.index,n[0].length]);for(var c,o="font-family:([^;!}]+)",u=RegExp(o),l=0;n=s.exec(r);)c=u.exec(n[0]),i[l++].push(W(c[1])[0]);for(var f=new Set,d=RegExp(a+"|"+o,"gm");n=d.exec(r);)"@"!==n[0][0]&&W(n[1]).forEach(function(e){return f.add(e)});for(var h,p=/font:([^;!}]+)/gm,v=/\s*(?:['"][\w- ]+['"]|[\w-]+)\s*(?:,|$)/gm;n=p.exec(r);){for(h="";c=v.exec(n[1]);)h+=c[0];W(h).forEach(function(e){return f.add(e)})}return O(e,i,f,t,"@font-face ")}(e=function(e,r,t){for(var n,a=[],s=/@(?:-\w+-)?keyframes\s+([\w-]+)\s*\{/gm;n=s.exec(e);){var i=k(e,s.lastIndex,"{","}");a.push([n.index,n[0].length+i.length+1,n[1]])}for(var c=new Set,o=/animation(?:-name)?:([^;!}]+)/gm;n=o.exec(r);)n[1].trim().split(M).forEach(function(e){var r=e.match(/^\S+/)[0];/^-?[\d.]+m?s/.test(r)&&(r=e.match(/\S+$/)[0]),c.add(r)});return O(e,a,c,t,"@keyframes ")}(e,a,r),a,r))).replace(/[^{}]+\{\s*\}/gm,"")}var C=/\[([\w-]+)(?:(.?=)"?([^\]]*?)"?)?\]/i,G=/:(?:first|last|nth|only|not)\b/;var H=function(e){return!0};return function(e){for(var r=d(e.html,!e.keepText),t=e.shouldDrop||H,n=T(e.css),a={},s=0;s<n.length;s++)if(n[s]===g){var i=n[s+1],c=i[i.length-1];s++;for(var o=0;o<c.length;o++){var u=c[o];e:for(var l=0;l<u.length;l++){var f=u[l],h=!1,p=void 0;if(""!=f){if(f in a)h=a[f];else switch(f[0]){case"#":p=f.substr(1),a[f]=h=r.attr.has("[id="+p+"]");break;case".":p=f.substr(1),a[f]=h=r.class.has(p);break;case"[":if(f.startsWith("[type="))a[f]=h=r.attr.has(f);else{var b=f.match(C);a[f]=h=r.nodes.some(function(e){return _(e,b[1],b[3],b[2])})}break;default:a[f]=h=r.tag.has(f)}if(!h){!0===t(i[o])?i[o]=null:a[i[o]]=!0;break e}}}}}for(var E=0;E<n.length;E++)n[E]===g&&(n[++E].length,n[E]=n[E].filter(function(e){if("string"==typeof e){if(e in a)return a[e];var n=(s=e).replace(/:?:[a-z-]+/gm,function(e){return s.startsWith("::")||!G.test(e)?"":e}).replace(/:[a-z-]+\(\)/gm,"");return""==n||(n in a?a[n]:a[n]=D(r.nodes,n)||!0!==t(e))}var s;return!1}));var k=new Set,I=function(e,r){for(var t="",n=0,a=0;a<e.length;a++)switch(e[a]){case g:var s=e[++a];(n=s.length)>0&&(s.forEach(function(e){return r.add(e)}),t+=s.join());break;case m:n>0&&(t+="{"+e[++a]+"}");break;case v:t+=e[++a]+"{";break;case x:t+="}";break;case y:t+=e[++a]}return w(t)}(n,k);return{css:w(I=z(I,t)),sels:k}}});
/*! https://github.com/leeoniya/dropcss (v1.0.13) */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).dropcss=r()}(this,function(){"use strict";function e(e,r,t){throw new Error(e+' parser stopped here: "'+r.substring(t,t+100)+'"')}var r=1,t=2,n=3,a=new Set("area base br col command embed hr img input keygen link meta param source track wbr".split(" ")),s=/<!doctype[^>]*>|<!--[\s\S]*?-->|<script[^>]*>[\s\S]*?<\/script>|<style[^>]*>[\s\S]*?<\/style>|<link[^>]*>|<meta[^>]*>/gim,i=/([\w-]+)(?:="([^"]*)"|='([^']*)'|=(\S+))?/gm,c={TAG_HEAD:/\s*<([\w-]+)(?:\s*([^>]*))?>\s*/imy,TEXT:/\s*[^<]*/my,TAG_CLOSE:/\s*<\/[\w-]+>\s*/imy};var o=new Set;function u(e,r,t){return{tagName:r,attributes:t,classList:null!=t&&t.has("class")?new Set(t.get("class").split(/\s+/g)):o,parentNode:e,childNodes:[]}}var l=[];function f(e,r){if(null!=e){var t=e._ofTypes=e._ofTypes||{};if(!(r in t)){var n=0;t[r]=e.childNodes.filter(function(e){if(e.tagName==r)return e._typeIdx=n++,!0})}return t[r]}return l}var d=function(l){var f=function(s){var o,u=0,l=[];function f(e){for(var r in u=e.lastIndex,c)c[r].lastIndex=u}function d(){if(null!=(o=c.TAG_CLOSE.exec(s)))return f(c.TAG_CLOSE),void l.push(n);if(null==(o=c.TAG_HEAD.exec(s)))null!=(o=c.TEXT.exec(s))&&f(c.TEXT);else{f(c.TAG_HEAD);var e=o[1];l.push(r,e);var u=o[2];if(null!=u){for(var d,h=new Map;d=i.exec(u);)h.set(d[1],(d[2]||d[3]||d[4]||"").trim());l.push(t,h)}(a.has(e)||u&&u.endsWith("/"))&&l.push(n)}}for(var h=u;u<s.length;)d(),h===u&&e("html",s,u),h=u;return f({lastIndex:0}),l}(l=l.replace(s,"")),d={nodes:[],tag:new Set(["*"]),class:new Set,attr:new Set};!function(e,a){for(var s,i=u(null,"root",o),c=0;c<e.length;c++)switch(e[c]){case r:var l=e[++c],f=o;e[c+1]===t&&(f=e[c+=2]),s=i.childNodes.length,i.childNodes.push(i=u(i,l,f)),a(i,s);break;case n:i=i.parentNode}}(f,function(e,r){return function(e,r,t){e.idx=r;var n=e.attributes;t.tag.add(e.tagName),e.classList.forEach(function(e){return t.class.add(e)}),n.has("id")&&t.attr.add("[id="+n.get("id")+"]"),n.has("type")&&t.attr.add("[type="+n.get("type")+"]"),t.nodes.push(e)}(e,r,d)});return d},h=/\s*\/\*[\s\S]*?\*\/\s*/gm,p=/\s*[>~+.#]\s*|\[[^\]]+\]|\s+/gm,v=1,x=2,g=3,m=4,y=5;function b(e){var r=e.split(/\s*,\s*/gm);return r.push(r.map(function(e){return function(e){for(var r=e.length;(e=e.replace(E,"")).length!=r;)r=e.length;return e.replace(/:?:[a-z-]+/gm,"")}(e).trim().replace(p,function(e,r){return e=e.trim(),0==r?e:"."==e||"#"==e?"`"+e:e.length<=1?"`":"`"+e.replace(/['"]/gm,"")}).split(/`+/gm)})),r}var E=/:[a-z-]+\([^()]*\)/;function k(e,r,t,n){for(var a="",s=1;e[r]==t?s++:e[r]==n&&s--,0!=s;)a+=e[r++];return a}function T(r){return function(r){var t,n={RULE_HEAD:/\s*([^{;]+?)\s*[{;]\s*/my,RULE_TAIL:/\s*([^}]*?)\s*\}/my,AT_TAIL:/\s*\}/my,RULE_FULL:/\s*([^{]*?)\{([^}]+?)\}/my},a=0,s=0,i=[];function c(e){for(var r in s=e.lastIndex,n)n[r].lastIndex=s}function o(){if(a>0&&null!=(t=n.AT_TAIL.exec(r)))return a--,i.push(x),void c(n.AT_TAIL);if(null!=(t=n.RULE_HEAD.exec(r))){var e=t[1];if(c(n.RULE_HEAD),"@"==e[0])switch(e.match(/@[a-z-]+/)[0]){case"@media":case"@supports":case"@document":a++,i.push(v,e);break;case"@import":case"@charset":case"@namespace":i.push(y,e+";");break;default:a++;var o=k(r,s,"{","}");c({lastIndex:s+o.length}),i.push(v,e,y,o)}else i.push(g,b(t[1])),t=n.RULE_TAIL.exec(r),i.push(m,t[1]),c(n.RULE_TAIL)}else s=r.length}for(var u=s;s<r.length;)o(),u===s&&e("css",r,s),u=s;return i}(r=r.replace(h,""))}function w(e){return e.replace(/@[a-z-]+[^{]+\{\s*\}/gm,"")}var I=/^([+-]?\d*)?n([+-]\d+)?$/;function A(e,r){return r==e.tagName||"*"==r}function _(e,r,t,n){n=n||"=";var a=e.attributes;if(a.has(r)){var s=a.get(r);switch(n){case"=":return null==t||t==s;case"*=":return-1!=s.indexOf(t);case"^=":return s.startsWith(t);case"$=":return s.endsWith(t);case"~=":return t==s||s.startsWith(t+" ")||s.endsWith(" "+t)||-1!=s.indexOf(" "+t+" ")}}return!1}function N(e,r){return e.classList.has(r)}function S(e,r){var t;if("odd"==r)t=e%2==1;else if("even"==r)t=e%2==0;else if(/^\d+$/.test(r))t=e==+r;else{var n=function(e){var r=I.exec(e);if(null!=r){var t=r[1],n=r[2];return[t=null==t||"+"==t?1:"-"==t?-1:+t,n=null==n?0:+n]}return[0,0]}(r);t=function(e,r,t){if(r<0&&e<=0)return!1;if(-1===e)return t<=r;if(0===e)return t===r;if(1===e)return r<0||t>=r;var n=r%e;return n<0&&(n+=e),e>1?t>=r&&t%e===n:(e*=-1,t<=r&&t%e===n)}(n[0],n[1],e)}return t}function L(e,r){return e.some(function(e){return function e(r,t){for(var n,a,s,i,c,o;t.idx>-1;){switch(r[t.idx]){case"_":n=r[--t.idx],o=A(t.node,n),t.idx--;break;case"#":a=r[--t.idx],o=_(t.node,"id",a,"="),t.idx--;break;case".":n=r[--t.idx],o=N(t.node,n),t.idx--;break;case"[":n=r[--t.idx],s=r[--t.idx],a=r[--t.idx],o=_(t.node,n,a,s),t.idx--;break;case":":n=r[--t.idx],a=r[--t.idx];var u=t.node,l=u.tagName;c=u.idx;var d=(i=u.parentNode)?i.childNodes.length:1,h=void 0;switch(n){case"not":o=!e(a,{node:t.node,idx:a.length-1});break;case"first-child":o=0==c;break;case"last-child":o=c==d-1;break;case"only-child":o=1==d;break;case"nth-child":o=S(c+1,a);break;case"nth-last-child":o=S(d-c,a);break;case"first-of-type":h=f(i,l),o=0==u._typeIdx;break;case"last-of-type":h=f(i,l),o=u._typeIdx==h.length-1;break;case"only-of-type":o=1==(h=f(i,l)).length;break;case"nth-of-type":h=f(i,l),o=S(u._typeIdx+1,a);break;case"nth-last-of-type":o=S((h=f(i,l)).length-u._typeIdx,a)}t.idx--;break;case" ":for(c=--t.idx,o=!1;!o&&null!=(i=t.node.parentNode);)t.idx=c,t.node=i,o=e(r,t);break;case">":t.idx--,null!=(i=t.node.parentNode)?(t.node=i,o=e(r,t)):o=!1;break;case"+":t.idx--,null!=(i=t.node.parentNode)&&t.node.idx>0?(t.node=i.childNodes[t.node.idx-1],o=e(r,t)):o=!1;break;case"~":if(t.idx--,o=!1,c=t.node.idx,null!=(i=t.node.parentNode)&&c>0)for(var p=0;p<c&&!o;p++)t.node=i.childNodes[p],o=e(r,t)}if(!o)break}return o}(r,{idx:r.length-1,node:e})})}var D=function(e,r){return L(e,Array.isArray(r)?r:function e(r){var t,n={IDENT:/([\w*-]+)/iy,ATTR:/([\w-]+)(?:(.?=)["']?([^\]]*?)["']?)?\]/iy,PSEUDO:/([\w-]+)(\()?/iy,MODE:/\s*[:.#\[]\s*/iy,COMB:/\s*[>~+]\s*|\s+/iy},a=0,s=[],i=-1;function c(e){for(var r in a=e.lastIndex,n)n[r].lastIndex=a}function o(){var a=!1;if(t=n.COMB.exec(r)){a=!0;var o=t[0].trim();""==o&&(o=" "),s.push(o),c(n.COMB),i=s.length-1}else if(t=n.MODE.exec(r)){a=!0;var u=t[0].trim();if(c(n.MODE),":"==u){if("("==(t=n.PSEUDO.exec(r))[2]){var l=k(r,n.PSEUDO.lastIndex,"(",")");n.PSEUDO.lastIndex+=l.length+1,t[2]="not"==t[1]?e(l):l}s.splice(i+1,0,t[2],t[1],u),c(n.PSEUDO)}else"["==u?(t=n.ATTR.exec(r),s.splice(i+1,0,t[3],t[2],t[1],u),c(n.ATTR)):(t=n.IDENT.exec(r),s.push(t[1],u),c(n.IDENT))}else(t=n.IDENT.exec(r))&&(a=!0,s.push(t[1],"_"),c(n.IDENT));return a}for(;a<r.length;)o();return s}(r))};function O(e,r,t,n,a){a=a||"";for(var s=r.length-1;s>-1;s--){var i=r[s];t.has(i[2])||!0!==n(a+i[2])||(c=e,o=i[0],u=i[1],l="",e=c.slice(0,o)+l+c.slice(o+u))}var c,o,u,l;return e}var R=/([{};])\s*(--[\w-]+)\s*:\s*([^;}]+);?\s*/gm,U=/var\(([\w-]+)\)/gm,M=/\s*,\s*/gm;function W(e){return e.trim().replace(/'|"/gm,"").split(M)}function z(e,r,t,n){var a=function(e){for(var r,t={};U.test(e);){for(;r=R.exec(e);)t[r[2]]=r[3];e=e.replace(U,function(e,r){return U.test(t[r])?e:t[r]})}return e}(e).replace(R,function(e,r){return r});return(e=function(e,r){var t=e;do{t=(e=t).replace(R,function(r,t,n){return-1!=e.indexOf("var("+n+")")?r:t})}while(t!=e);return t}(e=function(e,r,t){for(var n,a="@font-face[^}]+\\}+",s=RegExp(a,"gm"),i=[];n=s.exec(e);)i.push([n.index,n[0].length]);for(var c,o="font-family:([^;!}]+)",u=RegExp(o),l=0;n=s.exec(r);)c=u.exec(n[0]),i[l++].push(W(c[1])[0]);for(var f=new Set,d=RegExp(a+"|"+o,"gm");n=d.exec(r);)"@"!==n[0][0]&&W(n[1]).forEach(function(e){return f.add(e)});for(var h,p=/font:([^;!}]+)/gm,v=/\s*(?:['"][\w- ]+['"]|[\w-]+)\s*(?:,|$)/gm;n=p.exec(r);){for(h="";c=v.exec(n[1]);)h+=c[0];W(h).forEach(function(e){return f.add(e)})}return O(e,i,f,t,"@font-face ")}(e=function(e,r,t){for(var n,a=[],s=/@(?:-\w+-)?keyframes\s+([\w-]+)\s*\{/gm;n=s.exec(e);){var i=k(e,s.lastIndex,"{","}");a.push([n.index,n[0].length+i.length+1,n[1]])}for(var c=new Set,o=/animation(?:-name)?:([^;!}]+)/gm;n=o.exec(r);)n[1].trim().split(M).forEach(function(e){var r=e.match(/^\S+/)[0];/^-?[\d.]+m?s/.test(r)&&(r=e.match(/\S+$/)[0]),c.add(r)});return O(e,a,c,t,"@keyframes ")}(e,a,r),a,r))).replace(/[^{}]+\{\s*\}/gm,"")}var C=/\[([\w-]+)(?:(.?=)"?([^\]]*?)"?)?\]/i,G=/:(?:first|last|nth|only|not)\b/;var H=function(e){return!0};return function(e){for(var r=d(e.html,!e.keepText),t=e.shouldDrop||H,n=T(e.css),a={},s=0;s<n.length;s++)if(n[s]===g){var i=n[s+1],c=i[i.length-1];s++;for(var o=0;o<c.length;o++){var u=c[o];e:for(var l=0;l<u.length;l++){var f=u[l],h=!1,p=void 0;if(""!=f){if(f in a)h=a[f];else switch(f[0]){case"#":p=f.substr(1),a[f]=h=r.attr.has("[id="+p+"]");break;case".":p=f.substr(1),a[f]=h=r.class.has(p);break;case"[":if(f.startsWith("[type="))a[f]=h=r.attr.has(f);else{var b=f.match(C);a[f]=h=r.nodes.some(function(e){return _(e,b[1],b[3],b[2])})}break;default:a[f]=h=r.tag.has(f)}if(!h){!0===t(i[o])?i[o]=null:a[i[o]]=!0;break e}}}}}for(var E=0;E<n.length;E++)n[E]===g&&(n[++E].length,n[E]=n[E].filter(function(e){if("string"==typeof e){if(e in a)return a[e];var n=(s=e).replace(/:?:[a-z-]+/gm,function(e){return s.startsWith("::")||!G.test(e)?"":e}).replace(/:[a-z-]+\(\)/gm,"");return""==n||(n in a?a[n]:a[n]=D(r.nodes,n)||!0!==t(e))}var s;return!1}));var k=new Set,I=function(e,r){for(var t="",n=0,a=0;a<e.length;a++)switch(e[a]){case g:var s=e[++a];(n=s.length)>0&&(s.forEach(function(e){return r.add(e)}),t+=s.join());break;case m:n>0&&(t+="{"+e[++a]+"}");break;case v:t+=e[++a]+"{";break;case x:t+="}";break;case y:t+=e[++a]}return w(t)}(n,k);return{css:w(I=z(I,t)),sels:k}}});
{
"name": "dropcss",
"version": "1.0.12",
"version": "1.0.13",
"description": "An exceptionally fast, thorough and tiny unused-CSS cleaner",

@@ -30,3 +30,3 @@ "main": "./dist/dropcss.cjs.js",

"nyc": "^14.1.1",
"rollup": "^1.13.0",
"rollup": "^1.13.1",
"rollup-plugin-buble": "^0.19.6",

@@ -33,0 +33,0 @@ "rollup-plugin-cjs-es": "^0.7.0",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc