@projectwallace/css-analyzer 5.7.3 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer.cjs +1 -1
- package/dist/analyzer.cjs.map +1 -1
- package/dist/analyzer.modern.js +1 -1
- package/dist/analyzer.modern.js.map +1 -1
- package/dist/analyzer.module.js +1 -1
- package/dist/analyzer.module.js.map +1 -1
- package/dist/analyzer.umd.js +1 -1
- package/dist/analyzer.umd.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/package.json +1 -1
package/dist/analyzer.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("css-tree/parser"),t=require("css-tree/walker"),r=require("@bramus/specificity/core");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e),a=/*#__PURE__*/n(t);function o(e,t){return t>=65&&t<=90&&(t|=32),e===t}function s(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!1===o(e.charCodeAt(r),t.charCodeAt(r)))return!1;return!0}function u(e,t){var r=t.length-e.length;if(r<0)return!1;for(var n=t.length-1;n>=r;n--)if(!1===o(e.charCodeAt(n-r),t.charCodeAt(n)))return!1;return!0}function l(e,t){if(t.length<e.length)return!1;for(var r=0;r<e.length;r++)if(!1===o(e.charCodeAt(r),t.charCodeAt(r)))return!1;return!0}function c(e,t,r){return s(t,e.property)&&"Identifier"===e.value.children.first.type&&s(r,e.value.children.first.name)}function f(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function d(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function m(e,t){var r=[];return a.default(e,{visit:"Selector",enter:function(e){r.push(t(e))}}),r}function h(e){return s(e,"not")||s(e,"nth-child")||s(e,"nth-last-child")||s(e,"where")||s(e,"is")||s(e,"has")||s(e,"matches")||s(e,"-webkit-any")||s(e,"-moz-any")}function w(e){var t=!1;return a.default(e,function(e){if("AttributeSelector"==e.type){if(s("role",e.name.name)||l("aria-",e.name.name))return t=!0,this.break}else if("PseudoClassSelector"==e.type&&h(e.name))return m(e,w).some(function(e){return 1==e})?(t=!0,this.skip):this.skip}),t}function b(e){var t=0;return a.default(e,function(e){if("Selector"!=e.type&&"Nth"!=e.type){if(t++,"IdSelector"!=e.type&&"ClassSelector"!=e.type&&"PseudoElementSelector"!=e.type&&"TypeSelector"!=e.type&&"PseudoClassSelector"!=e.type||f(e.name)&&t++,"AttributeSelector"==e.type)return Boolean(e.value)&&t++,f(e.name.name)&&t++,this.skip;if("PseudoClassSelector"==e.type&&h(e.name)){var r=m(e,b);if(0===r.length)return;return r.forEach(function(e){return t+=e}),this.skip}}}),t}var v=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),g=new Set(["canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext"]),p=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color"]),k=new Set(["currentcolor","transparent"]),y=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]),x=new Set(["normal","xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller","bold","bolder","lighter","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","italic","oblique"]);function q(e){var t=e.children.first;return"Identifier"===t.type&&y.has(t.name)}var S=new Set(["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]),z=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]);function I(e){var t=e.children.first;return"Identifier"===t.type&&z.has(t.name)}var O=new Set(["auto","inherit","initial","unset","revert","none"]);function C(e){if(!e.children)return!1;var t=e.children.first;return!!t&&!(e.children.size>1)&&"Identifier"===t.type&&O.has(t.name)}var U=new Set(["linear","ease","ease-in","ease-out","ease-in-out","step-start","step-end"]);function j(e){if(!e.children)return!1;for(var t=e.children.toArray(),r=0;r<t.length;r++){var n=t[r],i=n.type,a=n.name;if("Identifier"===i&&f(a))return!0;if("Function"===i){if(f(a))return!0;if(j(n))return!0}}return!1}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var R=/*#__PURE__*/function(){function e(e){if(this.t=new Map,this.i=0,e)for(var t=0;t<e.length;t++)this.push(e[t])}var t=e.prototype;return t.push=function(e){this.i++,this.t.has(e)?this.t.set(e,this.t.get(e)+1):this.t.set(e,1)},t.size=function(){return this.i},t.count=function(){return{total:this.i,totalUnique:this.t.size,unique:Object.fromEntries(this.t),uniquenessRatio:0===this.i?0:this.t.size/this.i}},e}(),M=/*#__PURE__*/function(){function e(){this.o=new R,this.u=new Map}var t=e.prototype;return t.push=function(e,t){this.o.push(e),this.u.has(t)||this.u.set(t,new R),this.u.get(t).push(e)},t.count=function(){for(var e,t=new Map,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return D(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?D(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.u.entries());!(e=r()).done;){var n=e.value;t.set(n[0],n[1].count())}return Object.assign(this.o.count(),{itemsPerContext:Object.fromEntries(t)})},e}(),A=/*#__PURE__*/function(){function e(){this.t=[],this.l=0}var t=e.prototype;return t.push=function(e){this.t.push(e),this.l+=e},t.size=function(){return this.t.length},t.aggregate=function(){if(0===this.t.length)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};var e,t,r,n=this.t.slice().sort(function(e,t){return e-t}),i=n[0],a=n[n.length-1],o=function(e){for(var t=new Map,r=-1,n=0,i=0,a=0;a<e.length;a++){var o=e[a],s=(t.get(o)||0)+1;t.set(o,s),s>r&&(r=s,n=0,i=0),s>=r&&(n++,i+=o)}return i/n}(n),s=(t=(e=n).length/2)!==(r=Math.floor(t))?e[r]:(e[r]+e[r-1])/2;return{min:i,max:a,mean:this.l/n.length,mode:o,median:s,range:a-i,sum:this.l}},t.toArray=function(){return this.t},e}();function F(e){return!(e.length<3)&&45===e.charCodeAt(0)&&45===e.charCodeAt(1)}function P(e,t){return!F(t)&&u(e,t)}function T(e,t){return 0===t?0:e/t}exports.analyze=function(e){var t=Date.now(),n=e.split(/\r?\n/g);function o(t){return e.substring(t.loc.start.offset,t.loc.end.offset)}var m,h,y=0,z=0,O=new R,D=0,_={total:0,unique:new Map},E=Date.now(),N=i.default(e,{parseCustomProperty:!0,positions:!0,onComment:function(e){y++,z+=e.length}}),B=Date.now(),H=0,K=[],L=new R,Q=new R,V=new R,$=new R,G=new R,J=new R,W=new R,X=new R,Y=new R,Z=new R,ee=0,te=0,re=new A,ne=new A,ie=new A,ae=new R,oe=new Set,se=new A,ue=new A,le=new A,ce=new R,fe=new A,de=[],me=new R,he=new R,we=new Set,be=0,ve=0,ge=0,pe=new R,ke=new R,ye=new R,xe=new R,qe=new R,Se=new A,ze=new R,Ie=new R,Oe=new R,Ce=new R,Ue=new R,je=new R,De=new R,Re=new R,Me=new R,Ae=new M,Fe=new R,Pe=new M;a.default(N,function(e){switch(e.type){case"Atrule":H++;var t=e.name;if("font-face"===t){var n={};e.block.children.forEach(function(e){return n[e.property]=o(e.value)}),K.push(n);break}if("media"===t){var i=o(e.prelude).trim();V.push(i),function(e){var t=!1;return a.default(e,function(e){if("MediaQuery"===e.type&&1===e.children.size&&"Identifier"===e.children.first.type&&(l("\\0",(e=e.children.first).name)||u("\\9 ",e.name)))return t=!0,this.break;if("MediaFeature"===e.type){if(null!==e.value&&"\\0"===e.value.unit)return t=!0,this.break;if(s("-moz-images-in-menus",e.name)||s("min--moz-device-pixel-ratio",e.name)||s("-ms-high-contrast",e.name))return t=!0,this.break;if(s("min-resolution",e.name)&&s(".001",e.value.value)&&s("dpcm",e.value.unit))return t=!0,this.break;if(s("-webkit-min-device-pixel-ratio",e.name)&&(s("0",e.value.value)||s("10000",e.value.value)))return t=!0,this.break}}),t}(e.prelude)&&$.push(i);break}if("supports"===t){var y=o(e.prelude);J.push(y),function(e){var t=!1;return a.default(e,function(e){if("Declaration"===e.type&&(c(e,"-webkit-appearance","none")||c(e,"-moz-appearance","meterbar")))return t=!0,this.break}),t}(e.prelude)&&W.push(y);break}if(u("keyframes",t)){var z="@"+t+" "+o(e.prelude);f(t)&&Y.push(z),X.push(z);break}if("import"===t){Q.push(o(e.prelude));break}if("charset"===t){G.push(o(e.prelude));break}if("container"===t){Z.push(o(e.prelude));break}"layer"===t&&o(e.prelude).trim().split(",").forEach(function(e){return L.push(e.trim())});break;case"Rule":var R=e.prelude.children?e.prelude.children.size:0,M=e.block.children?e.block.children.size:0;re.push(R+M),ne.push(R),ie.push(M),ee++,0===M&&te++;break;case"Selector":var A=o(e);if(this.atrule&&u("keyframes",this.atrule.name))return ae.push(A),this.skip;var T=r.calculate(e)[0].value,E=[T.a,T.b,T.c];return E[0]>0&&me.push(A),w(e)&&he.push(A),oe.add(A),fe.push(b(e)),ce.push(E[0]+","+E[1]+","+E[2]),void 0===m&&(m=E),void 0===h&&(h=E),se.push(E[0]),ue.push(E[1]),le.push(E[2]),void 0!==h&&d(h,E)<0&&(h=E),void 0!==m&&d(m,E)>0&&(m=E),de.push(E),this.skip;case"Dimension":if(!this.declaration)break;return u("\\9",e.unit)?Pe.push(e.unit.substring(0,e.unit.length-2),this.declaration.property):Pe.push(e.unit,this.declaration.property),this.skip;case"Url":if(l("data:",e.value)){var N=e.value,B=N.length,Te=function(e){var t=e.indexOf(";"),r=e.indexOf(",");return e.substring(5,-1===t||-1!==r&&r<t?r:t)}(N);if(_.total++,D+=B,_.unique.has(Te)){var _e=_.unique.get(Te);_e.count++,_e.size+=B,_.unique.set(Te,_e)}else _.unique.set(Te,{count:1,size:B});O.push(N)}break;case"Value":if(C(e))break;var Ee=this.declaration,Ne=Ee.property,Be=Ee.important;if(j(e)&&ze.push(o(e)),"string"==typeof Be&&Ie.push(o(e)+"!"+Be),function(e){return e.children&&e.children.last&&"Identifier"===e.children.last.type&&u("\\9",e.children.last.name)}(e)&&Ie.push(o(e)),P("z-index",Ne))return C(e)||Oe.push(o(e)),this.skip;if(P("font",Ne)){if(q(e)||je.push(function(e,t){var r="";return a.default(e,{reverse:!0,enter:function(e){if("String"===e.type){var n=e.loc.start.offset,i=t({loc:{start:{offset:n},end:{offset:n+1}}});return r=i+e.value+i+r}return"Operator"===e.type&&44===e.value.charCodeAt(0)?r=e.value+r:"Identifier"===e.type?x.has(e.name)?this.skip:r=e.name+r:void 0}}),r}(e,o)),!I(e)){var He=function(e){var t,r=!1;return a.default(e,function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return t="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(r=!0);break;case"Dimension":if(!r)return t=e.value+e.unit,this.break;case"Identifier":if(S.has(e.name))return t=e.name,this.break}}),t}(e);He&&De.push(He)}break}if(P("font-size",Ne)){I(e)||De.push(o(e));break}if(P("font-family",Ne)){q(e)||je.push(o(e));break}if(P("transition",Ne)||P("animation",Ne)){for(var Ke=function(e,t){var r=!1,n=[],i=[];return e.forEach(function(e){return"Operator"===e.type?r=!1:"Dimension"===e.type&&!1===r?(r=!0,n.push(t(e))):"Identifier"===e.type&&U.has(e.name)?i.push(t(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:i.push(t(e))}),[n,i]}(e.children,o),Le=Ke[0],Qe=Ke[1],Ve=0;Ve<Le.length;Ve++)Me.push(Le[Ve]);for(var $e=0;$e<Qe.length;$e++)Re.push(Qe[$e]);break}if(P("animation-duration",Ne)||P("transition-duration",Ne)){Me.push(o(e));break}if(P("transition-timing-function",Ne)||P("animation-timing-function",Ne)){Re.push(o(e));break}P("text-shadow",Ne)?C(e)||Ce.push(o(e)):P("box-shadow",Ne)&&(C(e)||Ue.push(o(e))),a.default(e,function(e){switch(e.type){case"Hash":var t=e.value.length;return u("\\9",e.value)&&(t-=2),Ae.push("#"+e.value,Ne),Fe.push("hex"+t),this.skip;case"Identifier":var r=e.name;if(r.length>20||r.length<3)return this.skip;var n=o(e),i=r.toLowerCase();return v.has(i)?(Ae.push(n,Ne),Fe.push("named")):k.has(i)?(Ae.push(n,Ne),Fe.push(i)):g.has(i)&&(Ae.push(n,Ne),Fe.push("system")),this.skip;case"Function":if(s("var",e.name))return this.skip;var a=e.name.toLowerCase(),l=o(e);p.has(a)&&(Ae.push(l,Ne),Fe.push(a))}});break;case"Declaration":if(null!==this.atrulePrelude)return this.skip;be++,we.add(o(e)),!0===e.important&&(ve++,this.atrule&&u("keyframes",this.atrule.name)&&ge++);var Ge=e.property;ke.push(Ge),f(Ge)?(xe.push(Ge),Se.push(2)):function(e){if(F(e)||f(e))return!1;var t=e.charCodeAt(0);return 47===t||95===t||43===t||42===t||38===t||36===t||35===t}(Ge)?(ye.push(Ge),Se.push(2)):F(Ge)?(qe.push(Ge),Se.push(2),!0===e.important&&pe.push(Ge)):Se.push(1)}});var Te=O.count(),_e=we.size,Ee=fe.size(),Ne=se.aggregate(),Be=ue.aggregate(),He=le.aggregate(),Ke=ce.count(),Le=new R(fe.toArray()).count(),Qe=oe.size,Ve=new R(re.toArray()).count(),$e=new R(ne.toArray()).count(),Ge=new R(ie.toArray()).count(),Je=Object.assign;return{stylesheet:{sourceLinesOfCode:H+Ee+be+ae.size(),linesOfCode:n.length,size:e.length,comments:{total:y,size:z},embeddedContent:Je(Te,{size:{total:D,ratio:T(D,e.length)},types:{total:_.total,totalUnique:_.unique.size,uniquenessRatio:T(_.unique.size,_.total),unique:Object.fromEntries(_.unique)}})},atrules:{fontface:{total:K.length,totalUnique:K.length,unique:K,uniquenessRatio:0===K.length?0:1},import:Q.count(),media:Je(V.count(),{browserhacks:$.count()}),charset:G.count(),supports:Je(J.count(),{browserhacks:W.count()}),keyframes:Je(X.count(),{prefixed:Je(Y.count(),{ratio:T(Y.size(),X.size())})}),container:Z.count(),layer:L.count()},rules:{total:ee,empty:{total:te,ratio:T(te,ee)},sizes:Je(re.aggregate(),{items:re.toArray(),unique:Ve.unique,totalUnique:Ve.totalUnique,uniquenessRatio:Ve.uniquenessRatio}),selectors:Je(ne.aggregate(),{items:ne.toArray(),unique:$e.unique,totalUnique:$e.totalUnique,uniquenessRatio:$e.uniquenessRatio}),declarations:Je(ie.aggregate(),{items:ie.toArray(),unique:Ge.unique,totalUnique:Ge.totalUnique,uniquenessRatio:Ge.uniquenessRatio})},selectors:{total:Ee,totalUnique:Qe,uniquenessRatio:T(Qe,Ee),specificity:{min:void 0===h?[0,0,0]:h,max:void 0===m?[0,0,0]:m,sum:[Ne.sum,Be.sum,He.sum],mean:[Ne.mean,Be.mean,He.mean],mode:[Ne.mode,Be.mode,He.mode],median:[Ne.median,Be.median,He.median],items:de,unique:Ke.unique,totalUnique:Ke.totalUnique,uniquenessRatio:Ke.uniquenessRatio},complexity:Je(fe.aggregate(),Le,{items:fe.toArray()}),id:Je(me.count(),{ratio:T(me.size(),Ee)}),accessibility:Je(he.count(),{ratio:T(he.size(),Ee)}),keyframes:ae.count()},declarations:{total:be,totalUnique:_e,uniquenessRatio:T(_e,be),unique:{total:_e,ratio:T(_e,be)},importants:{total:ve,ratio:T(ve,be),inKeyframes:{total:ge,ratio:T(ge,ve)}}},properties:Je(ke.count(),{prefixed:Je(xe.count(),{ratio:T(xe.size(),ke.size())}),custom:Je(qe.count(),{ratio:T(qe.size(),ke.size()),importants:Je(pe.count(),{ratio:T(pe.size(),qe.size())})}),browserhacks:Je(ye.count(),{ratio:T(ye.size(),ke.size())}),complexity:Se.aggregate()}),values:{colors:Je(Ae.count(),{formats:Fe.count()}),fontFamilies:je.count(),fontSizes:De.count(),zindexes:Oe.count(),textShadows:Ce.count(),boxShadows:Ue.count(),animations:{durations:Me.count(),timingFunctions:Re.count()},prefixes:ze.count(),browserhacks:Ie.count(),units:Pe.count()},__meta__:{parseTime:B-E,analyzeTime:Date.now()-B,total:Date.now()-t}}},exports.compareSpecificity=d;
|
|
1
|
+
var e=require("css-tree/parser"),t=require("css-tree/walker"),r=require("@bramus/specificity/core");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e),a=/*#__PURE__*/n(t);function o(e,t){return t>=65&&t<=90&&(t|=32),e===t}function s(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!1===o(e.charCodeAt(r),t.charCodeAt(r)))return!1;return!0}function u(e,t){var r=t.length-e.length;if(r<0)return!1;for(var n=t.length-1;n>=r;n--)if(!1===o(e.charCodeAt(n-r),t.charCodeAt(n)))return!1;return!0}function l(e,t){if(t.length<e.length)return!1;for(var r=0;r<e.length;r++)if(!1===o(e.charCodeAt(r),t.charCodeAt(r)))return!1;return!0}function c(e,t,r){return s(t,e.property)&&"Identifier"===e.value.children.first.type&&s(r,e.value.children.first.name)}function f(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function d(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function h(e,t){var r=[];return a.default(e,{visit:"Selector",enter:function(e){r.push(t(e))}}),r}function m(e){return s(e,"not")||s(e,"nth-child")||s(e,"nth-last-child")||s(e,"where")||s(e,"is")||s(e,"has")||s(e,"matches")||s(e,"-webkit-any")||s(e,"-moz-any")}function w(e){var t=!1;return a.default(e,function(e){if("AttributeSelector"==e.type){if(s("role",e.name.name)||l("aria-",e.name.name))return t=!0,this.break}else if("PseudoClassSelector"==e.type&&m(e.name))return h(e,w).some(function(e){return 1==e})?(t=!0,this.skip):this.skip}),t}function b(e){var t=0;return a.default(e,function(e){if("Selector"!=e.type&&"Nth"!=e.type){if(t++,"IdSelector"!=e.type&&"ClassSelector"!=e.type&&"PseudoElementSelector"!=e.type&&"TypeSelector"!=e.type&&"PseudoClassSelector"!=e.type||f(e.name)&&t++,"AttributeSelector"==e.type)return Boolean(e.value)&&t++,f(e.name.name)&&t++,this.skip;if("PseudoClassSelector"==e.type&&m(e.name)){var r=h(e,b);if(0===r.length)return;return r.forEach(function(e){return t+=e}),this.skip}}}),t}var v=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),g=new Set(["canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext"]),p=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color"]),k=new Set(["currentcolor","transparent"]),y=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]),x=new Set(["normal","xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller","bold","bolder","lighter","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","italic","oblique"]);function q(e){var t=e.children.first;return"Identifier"===t.type&&y.has(t.name)}var S=new Set(["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]),z=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]);function I(e){var t=e.children.first;return"Identifier"===t.type&&z.has(t.name)}var O=new Set(["auto","inherit","initial","unset","revert","none"]);function C(e){if(!e.children)return!1;var t=e.children.first;return!!t&&!(e.children.size>1)&&"Identifier"===t.type&&O.has(t.name)}var U=new Set(["linear","ease","ease-in","ease-out","ease-in-out","step-start","step-end"]);function j(e){if(!e.children)return!1;for(var t=e.children.toArray(),r=0;r<t.length;r++){var n=t[r],i=n.type,a=n.name;if("Identifier"===i&&f(a))return!0;if("Function"===i){if(f(a))return!0;if(j(n))return!0}}return!1}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var R=/*#__PURE__*/function(){function e(e){if(this.t=new Map,this.i=0,e)for(var t=0;t<e.length;t++)this.push(e[t])}var t=e.prototype;return t.push=function(e){this.i++,this.t.has(e)?this.t.set(e,this.t.get(e)+1):this.t.set(e,1)},t.size=function(){return this.i},t.count=function(){return{total:this.i,totalUnique:this.t.size,unique:Object.fromEntries(this.t),uniquenessRatio:0===this.i?0:this.t.size/this.i}},e}(),M=/*#__PURE__*/function(){function e(){this.o=new R,this.u=new Map}var t=e.prototype;return t.push=function(e,t){this.o.push(e),this.u.has(t)||this.u.set(t,new R),this.u.get(t).push(e)},t.count=function(){for(var e,t=new Map,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return D(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?D(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.u.entries());!(e=r()).done;){var n=e.value;t.set(n[0],n[1].count())}return Object.assign(this.o.count(),{itemsPerContext:Object.fromEntries(t)})},e}(),A=/*#__PURE__*/function(){function e(){this.t=[],this.l=0}var t=e.prototype;return t.push=function(e){this.t.push(e),this.l+=e},t.size=function(){return this.t.length},t.aggregate=function(){if(0===this.t.length)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};var e,t,r,n=this.t.slice().sort(function(e,t){return e-t}),i=n[0],a=n[n.length-1],o=function(e){for(var t=new Map,r=-1,n=0,i=0,a=0;a<e.length;a++){var o=e[a],s=(t.get(o)||0)+1;t.set(o,s),s>r&&(r=s,n=0,i=0),s>=r&&(n++,i+=o)}return i/n}(n),s=(t=(e=n).length/2)!==(r=Math.floor(t))?e[r]:(e[r]+e[r-1])/2;return{min:i,max:a,mean:this.l/n.length,mode:o,median:s,range:a-i,sum:this.l}},t.toArray=function(){return this.t},e}();function F(e){return!(e.length<3)&&45===e.charCodeAt(0)&&45===e.charCodeAt(1)}function P(e,t){return!F(t)&&u(e,t)}function T(e,t){return 0===t?0:e/t}exports.analyze=function(e){var t=Date.now(),n=e.split(/\r?\n/g);function o(e){return h(e).trim()}function h(t){return e.substring(t.loc.start.offset,t.loc.end.offset)}var m,y,z=0,O=0,D=new R,_=0,E={total:0,unique:new Map},H=Date.now(),N=i.default(e,{parseCustomProperty:!0,positions:!0,onComment:function(e){z++,O+=e.length}}),B=Date.now(),K=0,L=[],Q=new R,V=new R,$=new R,G=new R,J=new R,W=new R,X=new R,Y=new R,Z=new R,ee=new R,te=0,re=0,ne=new A,ie=new A,ae=new A,oe=new R,se=new Set,ue=new A,le=new A,ce=new A,fe=new R,de=new A,he=[],me=new R,we=new R,be=new Set,ve=0,ge=0,pe=0,ke=new R,ye=new R,xe=new R,qe=new R,Se=new R,ze=new A,Ie=new R,Oe=new R,Ce=new R,Ue=new R,je=new R,De=new R,Re=new R,Me=new R,Ae=new R,Fe=new R,Pe=new M,Te=new R,_e=new M;a.default(N,function(e){switch(e.type){case"Atrule":K++;var t=e.name;if("font-face"===t){var n={};e.block.children.forEach(function(e){return n[e.property]=o(e.value)}),L.push(n);break}if("media"===t){var i=o(e.prelude);$.push(i),function(e){var t=!1;return a.default(e,function(e){if("MediaQuery"===e.type&&1===e.children.size&&"Identifier"===e.children.first.type&&(l("\\0",(e=e.children.first).name)||u("\\9 ",e.name)))return t=!0,this.break;if("MediaFeature"===e.type){if(null!==e.value&&"\\0"===e.value.unit)return t=!0,this.break;if(s("-moz-images-in-menus",e.name)||s("min--moz-device-pixel-ratio",e.name)||s("-ms-high-contrast",e.name))return t=!0,this.break;if(s("min-resolution",e.name)&&s(".001",e.value.value)&&s("dpcm",e.value.unit))return t=!0,this.break;if(s("-webkit-min-device-pixel-ratio",e.name)&&(s("0",e.value.value)||s("10000",e.value.value)))return t=!0,this.break}}),t}(e.prelude)&&G.push(i);break}if("supports"===t){var z=o(e.prelude);W.push(z),function(e){var t=!1;return a.default(e,function(e){if("Declaration"===e.type&&(c(e,"-webkit-appearance","none")||c(e,"-moz-appearance","meterbar")))return t=!0,this.break}),t}(e.prelude)&&X.push(z);break}if(u("keyframes",t)){var O="@"+t+" "+o(e.prelude);f(t)&&Z.push(O),Y.push(O);break}if("import"===t){V.push(o(e.prelude));break}if("charset"===t){J.push(o(e.prelude));break}if("container"===t){ee.push(o(e.prelude));break}"layer"===t&&o(e.prelude).split(",").forEach(function(e){return Q.push(e.trim())});break;case"Rule":var R=e.prelude.children?e.prelude.children.size:0,M=e.block.children?e.block.children.size:0;ne.push(R+M),ie.push(R),ae.push(M),te++,0===M&&re++;break;case"Selector":var A=o(e);if(this.atrule&&u("keyframes",this.atrule.name))return oe.push(A),this.skip;var T=r.calculate(e)[0].value,H=[T.a,T.b,T.c];return H[0]>0&&me.push(A),w(e)&&we.push(A),se.add(A),de.push(b(e)),fe.push(H[0]+","+H[1]+","+H[2]),void 0===m&&(m=H),void 0===y&&(y=H),ue.push(H[0]),le.push(H[1]),ce.push(H[2]),void 0!==y&&d(y,H)<0&&(y=H),void 0!==m&&d(m,H)>0&&(m=H),he.push(H),this.skip;case"Dimension":if(!this.declaration)break;return u("\\9",e.unit)?_e.push(e.unit.substring(0,e.unit.length-2),this.declaration.property):_e.push(e.unit,this.declaration.property),this.skip;case"Url":if(l("data:",e.value)){var N=e.value,B=N.length,Ee=function(e){var t=e.indexOf(";"),r=e.indexOf(",");return e.substring(5,-1===t||-1!==r&&r<t?r:t)}(N);if(E.total++,_+=B,E.unique.has(Ee)){var He=E.unique.get(Ee);He.count++,He.size+=B,E.unique.set(Ee,He)}else E.unique.set(Ee,{count:1,size:B});D.push(N)}break;case"Value":if(C(e))break;var Ne=this.declaration,Be=Ne.property,Ke=Ne.important;if(j(e)&&Ie.push(o(e)),"string"==typeof Ke&&Oe.push(h(e)+"!"+Ke),function(e){return e.children&&e.children.last&&"Identifier"===e.children.last.type&&u("\\9",e.children.last.name)}(e)&&Oe.push(o(e)),P("z-index",Be))return C(e)||Ce.push(o(e)),this.skip;if(P("font",Be)){if(q(e)||De.push(function(e,t){var r="";return a.default(e,{reverse:!0,enter:function(e){if("String"===e.type){var n=e.loc.start.offset,i=t({loc:{start:{offset:n},end:{offset:n+1}}});return r=i+e.value+i+r}return"Operator"===e.type&&44===e.value.charCodeAt(0)?r=e.value+r:"Identifier"===e.type?x.has(e.name)?this.skip:r=e.name+r:void 0}}),r}(e,o)),!I(e)){var Le=function(e){var t,r=!1;return a.default(e,function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return t="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(r=!0);break;case"Dimension":if(!r)return t=e.value+e.unit,this.break;case"Identifier":if(S.has(e.name))return t=e.name,this.break}}),t}(e);Le&&Re.push(Le)}break}if(P("font-size",Be)){I(e)||Re.push(o(e));break}if(P("font-family",Be)){q(e)||De.push(o(e));break}if(P("line-height",Be))Me.push(o(e));else{if(P("transition",Be)||P("animation",Be)){for(var Qe=function(e,t){var r=!1,n=[],i=[];return e.forEach(function(e){return"Operator"===e.type?r=!1:"Dimension"===e.type&&!1===r?(r=!0,n.push(t(e))):"Identifier"===e.type&&U.has(e.name)?i.push(t(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:i.push(t(e))}),[n,i]}(e.children,o),Ve=Qe[0],$e=Qe[1],Ge=0;Ge<Ve.length;Ge++)Fe.push(Ve[Ge]);for(var Je=0;Je<$e.length;Je++)Ae.push($e[Je]);break}if(P("animation-duration",Be)||P("transition-duration",Be)){Fe.push(o(e));break}if(P("transition-timing-function",Be)||P("animation-timing-function",Be)){Ae.push(o(e));break}P("text-shadow",Be)?C(e)||Ue.push(o(e)):P("box-shadow",Be)&&(C(e)||je.push(o(e)))}a.default(e,function(e){switch(e.type){case"Hash":var t=e.value.length;return u("\\9",e.value)&&(t-=2),Pe.push("#"+e.value,Be),Te.push("hex"+t),this.skip;case"Identifier":var r=e.name;if(r.length>20||r.length<3)return this.skip;var n=o(e),i=r.toLowerCase();return v.has(i)?(Pe.push(n,Be),Te.push("named")):k.has(i)?(Pe.push(n,Be),Te.push(i)):g.has(i)&&(Pe.push(n,Be),Te.push("system")),this.skip;case"Function":if(s("var",e.name))return this.skip;var a=e.name.toLowerCase(),l=o(e);p.has(a)&&(Pe.push(l,Be),Te.push(a))}});break;case"Declaration":if(null!==this.atrulePrelude)return this.skip;ve++,be.add(o(e)),!0===e.important&&(ge++,this.atrule&&u("keyframes",this.atrule.name)&&pe++);var We=e.property;ye.push(We),f(We)?(qe.push(We),ze.push(2)):function(e){if(F(e)||f(e))return!1;var t=e.charCodeAt(0);return 47===t||95===t||43===t||42===t||38===t||36===t||35===t}(We)?(xe.push(We),ze.push(2)):F(We)?(Se.push(We),ze.push(2),!0===e.important&&ke.push(We)):ze.push(1)}});var Ee=D.count(),He=be.size,Ne=de.size(),Be=ue.aggregate(),Ke=le.aggregate(),Le=ce.aggregate(),Qe=fe.count(),Ve=new R(de.toArray()).count(),$e=se.size,Ge=new R(ne.toArray()).count(),Je=new R(ie.toArray()).count(),We=new R(ae.toArray()).count(),Xe=Object.assign;return{stylesheet:{sourceLinesOfCode:K+Ne+ve+oe.size(),linesOfCode:n.length,size:e.length,comments:{total:z,size:O},embeddedContent:Xe(Ee,{size:{total:_,ratio:T(_,e.length)},types:{total:E.total,totalUnique:E.unique.size,uniquenessRatio:T(E.unique.size,E.total),unique:Object.fromEntries(E.unique)}})},atrules:{fontface:{total:L.length,totalUnique:L.length,unique:L,uniquenessRatio:0===L.length?0:1},import:V.count(),media:Xe($.count(),{browserhacks:G.count()}),charset:J.count(),supports:Xe(W.count(),{browserhacks:X.count()}),keyframes:Xe(Y.count(),{prefixed:Xe(Z.count(),{ratio:T(Z.size(),Y.size())})}),container:ee.count(),layer:Q.count()},rules:{total:te,empty:{total:re,ratio:T(re,te)},sizes:Xe(ne.aggregate(),{items:ne.toArray(),unique:Ge.unique,totalUnique:Ge.totalUnique,uniquenessRatio:Ge.uniquenessRatio}),selectors:Xe(ie.aggregate(),{items:ie.toArray(),unique:Je.unique,totalUnique:Je.totalUnique,uniquenessRatio:Je.uniquenessRatio}),declarations:Xe(ae.aggregate(),{items:ae.toArray(),unique:We.unique,totalUnique:We.totalUnique,uniquenessRatio:We.uniquenessRatio})},selectors:{total:Ne,totalUnique:$e,uniquenessRatio:T($e,Ne),specificity:{min:void 0===y?[0,0,0]:y,max:void 0===m?[0,0,0]:m,sum:[Be.sum,Ke.sum,Le.sum],mean:[Be.mean,Ke.mean,Le.mean],mode:[Be.mode,Ke.mode,Le.mode],median:[Be.median,Ke.median,Le.median],items:he,unique:Qe.unique,totalUnique:Qe.totalUnique,uniquenessRatio:Qe.uniquenessRatio},complexity:Xe(de.aggregate(),Ve,{items:de.toArray()}),id:Xe(me.count(),{ratio:T(me.size(),Ne)}),accessibility:Xe(we.count(),{ratio:T(we.size(),Ne)}),keyframes:oe.count()},declarations:{total:ve,totalUnique:He,uniquenessRatio:T(He,ve),unique:{total:He,ratio:T(He,ve)},importants:{total:ge,ratio:T(ge,ve),inKeyframes:{total:pe,ratio:T(pe,ge)}}},properties:Xe(ye.count(),{prefixed:Xe(qe.count(),{ratio:T(qe.size(),ye.size())}),custom:Xe(Se.count(),{ratio:T(Se.size(),ye.size()),importants:Xe(ke.count(),{ratio:T(ke.size(),Se.size())})}),browserhacks:Xe(xe.count(),{ratio:T(xe.size(),ye.size())}),complexity:ze.aggregate()}),values:{colors:Xe(Pe.count(),{formats:Te.count()}),fontFamilies:De.count(),fontSizes:Re.count(),lineHeights:Me.count(),zindexes:Ce.count(),textShadows:Ue.count(),boxShadows:je.count(),animations:{durations:Fe.count(),timingFunctions:Ae.count()},prefixes:Ie.count(),browserhacks:Oe.count(),units:_e.count()},__meta__:{parseTime:B-H,analyzeTime:Date.now()-B,total:Date.now()-t}}},exports.compareSpecificity=d;
|
|
2
2
|
//# sourceMappingURL=analyzer.cjs.map
|
package/dist/analyzer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.cjs","sources":["../src/string-utils.js","../src/atrules/atrules.js","../src/vendor-prefix.js","../src/selectors/utils.js","../src/values/colors.js","../src/values/font-families.js","../src/values/font-sizes.js","../src/values/values.js","../src/values/animations.js","../src/values/vendor-prefix.js","../src/countable-collection.js","../src/context-collection.js","../src/aggregate-collection.js","../src/properties/property-utils.js","../src/index.js","../src/stylesheet/stylesheet.js","../src/values/browserhacks.js"],"sourcesContent":["/**\n * Case-insensitive compare two character codes\n * @param {string} charA\n * @param {string} charB\n * @see https://github.com/csstree/csstree/blob/41f276e8862d8223eeaa01a3d113ab70bb13d2d9/lib/tokenizer/utils.js#L22\n */\nfunction compareChar(referenceCode, testCode) {\n // if uppercase\n if (testCode >= 0x0041 && testCode <= 0x005A) {\n // shifting the 6th bit makes a letter lowercase\n testCode = testCode | 32\n }\n return referenceCode === testCode\n}\n\n/**\n * Case-insensitive string-comparison\n * @param {string} base\n * @param {string} test\n * @returns {boolean} true if the two strings are the same, false otherwise\n */\nexport function strEquals(base, test) {\n if (base.length !== test.length) return false\n\n for (let i = 0; i < base.length; i++) {\n if (compareChar(base.charCodeAt(i), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Case-insensitive testing whether a string ends with a given substring\n * @param {string} base e.g. '-webkit-transform'\n * @param {string} cmp e.g. 'transform'\n * @returns {boolean} true if `test` ends with `base`, false otherwise\n */\nexport function endsWith(base, test) {\n const offset = test.length - base.length\n\n if (offset < 0) {\n return false\n }\n\n for (let i = test.length - 1; i >= offset; i--) {\n if (compareChar(base.charCodeAt(i - offset), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Case-insensitive testing whether a string starts with a given substring\n * @param {string} base\n * @param {test} test\n * @returns {boolean} true if `test` starts with `base`, false otherwise\n */\nexport function startsWith(base, test) {\n if (test.length < base.length) return false\n\n for (let i = 0; i < base.length; i++) {\n if (compareChar(base.charCodeAt(i), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n","import { strEquals, startsWith, endsWith } from '../string-utils.js'\nimport walk from 'css-tree/walker'\n\n/**\n * Check whether node.property === property and node.value === value,\n * but case-insensitive and fast.\n * @param {import('css-tree').Declaration} node\n * @param {string} property - The CSS property to compare with (case-insensitive)\n * @param {string} value - The identifier/keyword value to compare with\n * @returns true if declaratioNode is the given property: value, false otherwise\n */\nfunction isPropertyValue(node, property, value) {\n return strEquals(property, node.property)\n && node.value.children.first.type === 'Identifier'\n && strEquals(value, node.value.children.first.name)\n}\n\n/**\n * Check if an @supports atRule is a browserhack\n * @param {import('css-tree').AtrulePrelude} prelude\n * @returns true if the atrule is a browserhack\n */\nexport function isSupportsBrowserhack(prelude) {\n let returnValue = false\n\n walk(prelude, function (node) {\n if (node.type === 'Declaration') {\n if (\n isPropertyValue(node, '-webkit-appearance', 'none')\n || isPropertyValue(node, '-moz-appearance', 'meterbar')\n ) {\n returnValue = true\n return this.break\n }\n }\n })\n\n return returnValue\n}\n\n/**\n * Check if a @media atRule is a browserhack\n * @param {import('css-tree').AtrulePrelude} prelude\n * @returns true if the atrule is a browserhack\n */\nexport function isMediaBrowserhack(prelude) {\n let returnValue = false\n\n walk(prelude, function (node) {\n if (node.type === 'MediaQuery'\n && node.children.size === 1\n && node.children.first.type === 'Identifier'\n ) {\n node = node.children.first\n // Note: CSSTree adds a trailing space to \\\\9\n if (startsWith('\\\\0', node.name) || endsWith('\\\\9 ', node.name)) {\n returnValue = true\n return this.break\n }\n }\n if (node.type === 'MediaFeature') {\n if (node.value !== null && node.value.unit === '\\\\0') {\n returnValue = true\n return this.break\n }\n if (strEquals('-moz-images-in-menus', node.name)\n || strEquals('min--moz-device-pixel-ratio', node.name)\n || strEquals('-ms-high-contrast', node.name)\n ) {\n returnValue = true\n return this.break\n }\n if (strEquals('min-resolution', node.name)\n && strEquals('.001', node.value.value)\n && strEquals('dpcm', node.value.unit)\n ) {\n returnValue = true\n return this.break\n }\n if (strEquals('-webkit-min-device-pixel-ratio', node.name)) {\n if ((strEquals('0', node.value.value) || strEquals('10000', node.value.value))) {\n returnValue = true\n return this.break\n }\n }\n }\n })\n\n return returnValue\n}","const HYPHENMINUS = 45; // '-'.charCodeAt()\n\n/**\n * @param {string} keyword\n * @returns {boolean}\n */\nfunction hasVendorPrefix(keyword) {\n if (keyword.charCodeAt(0) === HYPHENMINUS && keyword.charCodeAt(1) !== HYPHENMINUS) {\n // String must have a 2nd occurrence of '-', at least at position 3 (offset=2)\n if (keyword.indexOf('-', 2) !== -1) {\n return true\n }\n }\n\n return false\n}\n\nexport {\n hasVendorPrefix\n}","import walk from 'css-tree/walker'\nimport { startsWith, strEquals } from '../string-utils.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\n/**\n * Compare specificity A to Specificity B\n * @param {[number,number,number]} a - Specificity A\n * @param {[number,number,number]} b - Specificity B\n * @returns {number} sortIndex - 0 when a==b, 1 when a<b, -1 when a>b\n */\nexport function compareSpecificity(a, b) {\n if (a[0] === b[0]) {\n if (a[1] === b[1]) {\n return b[2] - a[2]\n }\n\n return b[1] - a[1]\n }\n\n return b[0] - a[0]\n}\n\n/**\n *\n * @param {import('css-tree').SelectorList} selectorListAst\n * @returns {Selector[]} Analyzed selectors in the selectorList\n */\nfunction analyzeList(selectorListAst, cb) {\n const childSelectors = []\n walk(selectorListAst, {\n visit: 'Selector',\n enter: function (node) {\n childSelectors.push(cb(node))\n }\n })\n\n return childSelectors\n}\n\nfunction isPseudoFunction(name) {\n return (\n strEquals(name, 'not')\n || strEquals(name, 'nth-child')\n || strEquals(name, 'nth-last-child')\n || strEquals(name, 'where')\n || strEquals(name, 'is')\n || strEquals(name, 'has')\n || strEquals(name, 'matches')\n || strEquals(name, '-webkit-any')\n || strEquals(name, '-moz-any')\n )\n}\n\nexport function isAccessibility(selector) {\n let isA11y = false\n\n walk(selector, function (node) {\n if (node.type == 'AttributeSelector') {\n if (strEquals('role', node.name.name) || startsWith('aria-', node.name.name)) {\n isA11y = true\n return this.break\n }\n }\n // Test for [aria-] or [role] inside :is()/:where() and friends\n else if (node.type == 'PseudoClassSelector') {\n if (isPseudoFunction(node.name)) {\n const list = analyzeList(node, isAccessibility)\n\n if (list.some(b => b == true)) {\n isA11y = true\n return this.skip\n }\n\n return this.skip\n }\n }\n })\n\n return isA11y;\n}\n\n/**\n * Get the Complexity for the AST of a Selector Node\n * @param {import('css-tree').Selector} ast - AST Node for a Selector\n * @return {number} - The numeric complexity of the Selector\n */\nexport function getComplexity(selector) {\n let complexity = 0\n\n walk(selector, function (node) {\n if (node.type == 'Selector' || node.type == 'Nth') return\n\n complexity++\n\n if (node.type == 'IdSelector'\n || node.type == 'ClassSelector'\n || node.type == 'PseudoElementSelector'\n || node.type == 'TypeSelector'\n || node.type == 'PseudoClassSelector'\n ) {\n if (hasVendorPrefix(node.name)) {\n complexity++\n }\n }\n\n if (node.type == 'AttributeSelector') {\n if (Boolean(node.value)) {\n complexity++\n }\n if (hasVendorPrefix(node.name.name)) {\n complexity++\n }\n return this.skip\n }\n\n if (node.type == 'PseudoClassSelector') {\n if (isPseudoFunction(node.name)) {\n const list = analyzeList(node, getComplexity)\n\n // Bail out for empty/non-existent :nth-child() params\n if (list.length === 0) return\n\n list.forEach(c => complexity += c)\n return this.skip\n }\n }\n })\n\n return complexity\n}\n","export const namedColors = new Set([\n // CSS Named Colors\n // Spec: https://drafts.csswg.org/css-color/#named-colors\n 'aliceblue',\n 'antiquewhite',\n 'aqua',\n 'aquamarine',\n 'azure',\n 'beige',\n 'bisque',\n 'black',\n 'blanchedalmond',\n 'blue',\n 'blueviolet',\n 'brown',\n 'burlywood',\n 'cadetblue',\n 'chartreuse',\n 'chocolate',\n 'coral',\n 'cornflowerblue',\n 'cornsilk',\n 'crimson',\n 'cyan',\n 'darkblue',\n 'darkcyan',\n 'darkgoldenrod',\n 'darkgray',\n 'darkgreen',\n 'darkgrey',\n 'darkkhaki',\n 'darkmagenta',\n 'darkolivegreen',\n 'darkorange',\n 'darkorchid',\n 'darkred',\n 'darksalmon',\n 'darkseagreen',\n 'darkslateblue',\n 'darkslategray',\n 'darkslategrey',\n 'darkturquoise',\n 'darkviolet',\n 'deeppink',\n 'deepskyblue',\n 'dimgray',\n 'dimgrey',\n 'dodgerblue',\n 'firebrick',\n 'floralwhite',\n 'forestgreen',\n 'fuchsia',\n 'gainsboro',\n 'ghostwhite',\n 'gold',\n 'goldenrod',\n 'gray',\n 'green',\n 'greenyellow',\n 'grey',\n 'honeydew',\n 'hotpink',\n 'indianred',\n 'indigo',\n 'ivory',\n 'khaki',\n 'lavender',\n 'lavenderblush',\n 'lawngreen',\n 'lemonchiffon',\n 'lightblue',\n 'lightcoral',\n 'lightcyan',\n 'lightgoldenrodyellow',\n 'lightgray',\n 'lightgreen',\n 'lightgrey',\n 'lightpink',\n 'lightsalmon',\n 'lightseagreen',\n 'lightskyblue',\n 'lightslategray',\n 'lightslategrey',\n 'lightsteelblue',\n 'lightyellow',\n 'lime',\n 'limegreen',\n 'linen',\n 'magenta',\n 'maroon',\n 'mediumaquamarine',\n 'mediumblue',\n 'mediumorchid',\n 'mediumpurple',\n 'mediumseagreen',\n 'mediumslateblue',\n 'mediumspringgreen',\n 'mediumturquoise',\n 'mediumvioletred',\n 'midnightblue',\n 'mintcream',\n 'mistyrose',\n 'moccasin',\n 'navajowhite',\n 'navy',\n 'oldlace',\n 'olive',\n 'olivedrab',\n 'orange',\n 'orangered',\n 'orchid',\n 'palegoldenrod',\n 'palegreen',\n 'paleturquoise',\n 'palevioletred',\n 'papayawhip',\n 'peachpuff',\n 'peru',\n 'pink',\n 'plum',\n 'powderblue',\n 'purple',\n 'rebeccapurple',\n 'red',\n 'rosybrown',\n 'royalblue',\n 'saddlebrown',\n 'salmon',\n 'sandybrown',\n 'seagreen',\n 'seashell',\n 'sienna',\n 'silver',\n 'skyblue',\n 'slateblue',\n 'slategray',\n 'slategrey',\n 'snow',\n 'springgreen',\n 'steelblue',\n 'tan',\n 'teal',\n 'thistle',\n 'tomato',\n 'turquoise',\n 'violet',\n 'wheat',\n 'white',\n 'whitesmoke',\n 'yellow',\n 'yellowgreen',\n])\n\nexport const systemColors = new Set([\n // CSS System Colors\n // Spec: https://drafts.csswg.org/css-color/#css-system-colors\n 'canvas',\n 'canvastext',\n 'linktext',\n 'visitedtext',\n 'activetext',\n 'buttonface',\n 'buttontext',\n 'buttonborder',\n 'field',\n 'fieldtext',\n 'highlight',\n 'highlighttext',\n 'selecteditem',\n 'selecteditemtext',\n 'mark',\n 'marktext',\n 'graytext',\n\n // TODO: Deprecated CSS System colors\n // Spec: https://drafts.csswg.org/css-color/#deprecated-system-colors\n])\n\nexport const colorFunctions = new Set([\n 'rgb',\n 'rgba',\n 'hsl',\n 'hsla',\n 'hwb',\n 'lab',\n 'lch',\n 'oklab',\n 'oklch',\n 'color',\n])\n\nexport const colorKeywords = new Set([\n 'currentcolor',\n 'transparent',\n])\n","import walk from 'css-tree/walker'\n\nconst systemKeywords = new Set([\n // Global CSS keywords\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n\n // System font keywords\n 'caption',\n 'icon',\n 'menu',\n 'message-box',\n 'small-caption',\n 'status-bar',\n])\n\nconst keywordDisallowList = new Set([\n // font-weight, font-stretch, font-style\n 'normal',\n\n // font-size keywords\n 'xx-small',\n 'x-small',\n 'small',\n 'medium',\n 'large',\n 'x-large',\n 'xx-large',\n 'larger',\n 'smaller',\n\n // font-weight keywords\n 'bold',\n 'bolder',\n 'lighter',\n\n // font-stretch keywords\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n\n // font-style keywords\n 'italic',\n 'oblique',\n])\n\nconst COMMA = 44 // ','.charCodeAt(0) === 44\n\nexport function isFontFamilyKeyword(node) {\n const firstChild = node.children.first\n return firstChild.type === 'Identifier' && systemKeywords.has(firstChild.name)\n}\n\nexport function getFamilyFromFont(node, stringifyNode) {\n let parts = ''\n\n walk(node, {\n reverse: true,\n enter: function (fontNode) {\n if (fontNode.type === 'String') {\n const offset = fontNode.loc.start.offset\n // Stringify the first character to get the correct quote character\n const quote = stringifyNode({\n loc: {\n start: { offset },\n end: { offset: offset + 1 }\n }\n })\n return parts = quote + fontNode.value + quote + parts\n }\n if (fontNode.type === 'Operator' && fontNode.value.charCodeAt(0) === COMMA) {\n return parts = fontNode.value + parts\n }\n if (fontNode.type === 'Identifier') {\n if (keywordDisallowList.has(fontNode.name)) {\n return this.skip\n }\n return parts = fontNode.name + parts\n }\n }\n })\n\n return parts\n}\n","import walk from 'css-tree/walker'\n\nconst sizeKeywords = new Set([\n 'xx-small',\n 'x-small',\n 'small',\n 'medium',\n 'large',\n 'x-large',\n 'xx-large',\n 'larger',\n 'smaller',\n])\n\nconst keywords = new Set([\n // Global CSS keywords\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n\n // System font keywords\n 'caption',\n 'icon',\n 'menu',\n 'message-box',\n 'small-caption',\n 'status-bar',\n])\n\nconst ZERO = 48 // '0'.charCodeAt(0) === 48\nconst SLASH = 47 // '/'.charCodeAt(0) === 47\n\nexport function isFontSizeKeyword(node) {\n const firstChild = node.children.first\n return firstChild.type === 'Identifier' && keywords.has(firstChild.name)\n}\n\nexport function getSizeFromFont(node) {\n let operator = false\n let size\n\n walk(node, function (fontNode) {\n switch (fontNode.type) {\n case 'Number': {\n // Special case for `font: 0/0 a`\n if (fontNode.value.charCodeAt(0) === ZERO) {\n size = '0'\n return this.break\n }\n }\n case 'Operator': {\n if (fontNode.value.charCodeAt(0) === SLASH) {\n operator = true\n }\n break\n }\n case 'Dimension': {\n if (!operator) {\n size = fontNode.value + fontNode.unit\n return this.break\n }\n }\n case 'Identifier': {\n if (sizeKeywords.has(fontNode.name)) {\n size = fontNode.name\n return this.break\n }\n }\n }\n })\n\n return size\n}\n","const keywords = new Set([\n 'auto',\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n 'none', // for `text-shadow`, `box-shadow` and `background`\n])\n\nexport function isValueKeyword(node) {\n if (!node.children) return false\n const firstChild = node.children.first\n if (!firstChild) return false\n\n if (node.children.size > 1) return false\n return firstChild.type === 'Identifier' && keywords.has(firstChild.name)\n}\n","const timingKeywords = new Set([\n 'linear',\n 'ease',\n 'ease-in',\n 'ease-out',\n 'ease-in-out',\n 'step-start',\n 'step-end',\n])\n\nexport function analyzeAnimation(children, stringifyNode) {\n let durationFound = false\n const durations = []\n const timingFunctions = []\n\n children.forEach(child => {\n // Right after a ',' we start over again\n if (child.type === 'Operator') {\n return durationFound = false\n }\n if (child.type === 'Dimension' && durationFound === false) {\n durationFound = true\n return durations.push(stringifyNode(child))\n }\n if (child.type === 'Identifier' && timingKeywords.has(child.name)) {\n return timingFunctions.push(stringifyNode(child))\n }\n if (child.type === 'Function'\n && (\n child.name === 'cubic-bezier' || child.name === 'steps'\n )\n ) {\n return timingFunctions.push(stringifyNode(child))\n }\n })\n\n return [durations, timingFunctions]\n}\n","import { hasVendorPrefix } from '../vendor-prefix.js'\n\nexport function isAstVendorPrefixed(node) {\n if (!node.children) {\n return false\n }\n\n const children = node.children.toArray()\n\n for (let index = 0; index < children.length; index++) {\n const node = children[index]\n const { type, name } = node;\n\n if (type === 'Identifier' && hasVendorPrefix(name)) {\n return true\n }\n\n if (type === 'Function') {\n if (hasVendorPrefix(name)) {\n return true\n }\n\n if (isAstVendorPrefixed(node)) {\n return true\n }\n }\n }\n\n return false\n}\n","class CountableCollection {\n /**\n * @param {string[]} initial\n */\n constructor(initial) {\n /** @type [index: string]: string */\n this._items = new Map()\n /** @type number */\n this._total = 0\n\n if (initial) {\n for (let i = 0; i < initial.length; i++) {\n this.push(initial[i])\n }\n }\n }\n\n /**\n * Push an item to the end of this collection\n * @param {string} item\n * @returns {void}\n */\n push(item) {\n this._total++\n\n if (this._items.has(item)) {\n this._items.set(item, this._items.get(item) + 1)\n return\n }\n\n this._items.set(item, 1)\n }\n\n /**\n * Get the size of this collection\n * @returns {number} the size of this collection\n */\n size() {\n return this._total\n }\n\n /**\n * Get the counts of this collection, like total, uniques, etc.\n */\n count() {\n return {\n total: this._total,\n totalUnique: this._items.size,\n unique: Object.fromEntries(this._items),\n uniquenessRatio: this._total === 0 ? 0 : this._items.size / this._total,\n }\n }\n}\n\nexport {\n CountableCollection\n}","import { CountableCollection } from './countable-collection.js'\n\nclass ContextCollection {\n constructor() {\n this._list = new CountableCollection()\n /** @type {[index; string]: CountableCollection} */\n this._contexts = new Map()\n }\n\n /**\n * Add an item to this _list's context\n * @param {string} item Item to push\n * @param {string} context Context to push Item to\n */\n push(item, context) {\n this._list.push(item)\n\n if (!this._contexts.has(context)) {\n this._contexts.set(context, new CountableCollection())\n }\n\n this._contexts.get(context).push(item)\n }\n\n count() {\n const itemsPerContext = new Map()\n\n for (let [context, value] of this._contexts.entries()) {\n itemsPerContext.set(context, value.count())\n }\n\n return Object.assign(this._list.count(), {\n itemsPerContext: Object.fromEntries(itemsPerContext)\n })\n }\n}\n\nexport {\n ContextCollection\n}","/**\n * Find the mode (most occurring value) in an array of Numbers\n * Takes the mean/average of multiple values if multiple values occur the same amount of times.\n *\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-mode/index.js\n * @param {Array} arr - Array to find the mode value for\n * @returns {Number} mode - The `mode` value of `arr`\n */\nfunction Mode(arr) {\n const frequencies = new Map()\n let maxOccurrences = -1\n let maxOccurenceCount = 0\n let sum = 0\n\n for (let i = 0; i < arr.length; i++) {\n const element = arr[i]\n const updatedCount = (frequencies.get(element) || 0) + 1\n frequencies.set(element, updatedCount)\n\n if (updatedCount > maxOccurrences) {\n maxOccurrences = updatedCount\n maxOccurenceCount = 0\n sum = 0\n }\n\n if (updatedCount >= maxOccurrences) {\n maxOccurenceCount++\n sum += element\n }\n }\n\n return sum / maxOccurenceCount\n}\n\n/**\n * Find the middle number in an Array of Numbers\n * Returns the average of 2 numbers if the Array length is an even number\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-median/index.js\n * @param {Array} arr - A sorted Array\n * @returns {Number} - The array's Median\n */\nfunction Median(arr) {\n const middle = arr.length / 2\n const lowerMiddleRank = Math.floor(middle)\n\n if (middle !== lowerMiddleRank) {\n return arr[lowerMiddleRank]\n }\n return (arr[lowerMiddleRank] + arr[lowerMiddleRank - 1]) / 2\n}\n\nclass AggregateCollection {\n constructor() {\n /** @type number[] */\n this._items = []\n this._sum = 0\n }\n\n /**\n * Add a new Integer at the end of this AggregateCollection\n * @param {number} item - The item to add\n */\n push(item) {\n this._items.push(item)\n this._sum += item\n }\n\n size() {\n return this._items.length\n }\n\n aggregate() {\n if (this._items.length === 0) {\n return {\n min: 0,\n max: 0,\n mean: 0,\n mode: 0,\n median: 0,\n range: 0,\n sum: 0,\n }\n }\n\n // TODO: can we avoid this sort()? It's slow\n /** @type Number[] */\n const sorted = this._items.slice().sort((a, b) => a - b)\n const min = sorted[0]\n const max = sorted[sorted.length - 1]\n\n const mode = Mode(sorted)\n const median = Median(sorted)\n\n return {\n min,\n max,\n mean: this._sum / sorted.length,\n mode,\n median,\n range: max - min,\n sum: this._sum,\n }\n }\n\n /**\n * @returns {number[]} All _items in this collection\n */\n toArray() {\n return this._items\n }\n}\n\nexport {\n AggregateCollection\n}","import { hasVendorPrefix } from '../vendor-prefix.js'\nimport { endsWith } from '../string-utils.js'\n\n/**\n * @param {string} property\n * @see https://github.com/csstree/csstree/blob/master/lib/utils/names.js#L69\n */\nexport function isHack(property) {\n if (isCustom(property) || hasVendorPrefix(property)) return false\n\n let code = property.charCodeAt(0)\n\n return code === 47 // /\n || code === 95 // _\n || code === 43 // +\n || code === 42 // *\n || code === 38 // &\n || code === 36 // $\n || code === 35 // #\n}\n\nexport function isCustom(property) {\n if (property.length < 3) return false\n // 45 === '-'.charCodeAt(0)\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45\n}\n\nexport function isProperty(basename, property) {\n if (isCustom(property)) return false\n return endsWith(basename, property)\n}","import parse from 'css-tree/parser'\nimport walk from 'css-tree/walker'\nimport { calculate } from '@bramus/specificity/core'\nimport { isSupportsBrowserhack, isMediaBrowserhack } from './atrules/atrules.js'\nimport { getComplexity, isAccessibility, compareSpecificity } from './selectors/utils.js'\nimport { colorFunctions, colorKeywords, namedColors, systemColors } from './values/colors.js'\nimport { isFontFamilyKeyword, getFamilyFromFont } from './values/font-families.js'\nimport { isFontSizeKeyword, getSizeFromFont } from './values/font-sizes.js'\nimport { isValueKeyword } from './values/values.js'\nimport { analyzeAnimation } from './values/animations.js'\nimport { isAstVendorPrefixed } from './values/vendor-prefix.js'\nimport { ContextCollection } from './context-collection.js'\nimport { CountableCollection } from './countable-collection.js'\nimport { AggregateCollection } from './aggregate-collection.js'\nimport { strEquals, startsWith, endsWith } from './string-utils.js'\nimport { hasVendorPrefix } from './vendor-prefix.js'\nimport { isCustom, isHack, isProperty } from './properties/property-utils.js'\nimport { getEmbedType } from './stylesheet/stylesheet.js'\nimport { isIe9Hack } from './values/browserhacks.js'\n\nfunction ratio(part, total) {\n if (total === 0) return 0\n return part / total\n}\n\n/**\n * Analyze CSS\n * @param {string} css\n */\nconst analyze = (css) => {\n const start = Date.now()\n let lines = css.split(/\\r?\\n/g)\n\n /**\n * Recreate the authored CSS from a CSSTree node\n * @param {import('css-tree').CssNode} node - Node from CSSTree AST to stringify\n * @returns {string} str - The stringified node\n */\n function stringifyNode(node) {\n return css.substring(node.loc.start.offset, node.loc.end.offset)\n }\n\n // Stylesheet\n let totalComments = 0\n let commentsSize = 0\n const embeds = new CountableCollection()\n let embedSize = 0\n const embedTypes = {\n total: 0,\n unique: new Map()\n }\n\n const startParse = Date.now()\n\n const ast = parse(css, {\n parseCustomProperty: true, // To find font-families, colors, etc.\n positions: true, // So we can use stringifyNode()\n onComment: function (comment) {\n totalComments++\n commentsSize += comment.length\n },\n })\n\n const startAnalysis = Date.now()\n\n // Atrules\n let totalAtRules = 0\n /** @type {string}[]} */\n const fontfaces = []\n const layers = new CountableCollection()\n const imports = new CountableCollection()\n const medias = new CountableCollection()\n const mediaBrowserhacks = new CountableCollection()\n const charsets = new CountableCollection()\n const supports = new CountableCollection()\n const supportsBrowserhacks = new CountableCollection()\n const keyframes = new CountableCollection()\n const prefixedKeyframes = new CountableCollection()\n const containers = new CountableCollection()\n\n // Rules\n let totalRules = 0\n let emptyRules = 0\n const ruleSizes = new AggregateCollection()\n const selectorsPerRule = new AggregateCollection()\n const declarationsPerRule = new AggregateCollection()\n\n // Selectors\n const keyframeSelectors = new CountableCollection()\n const uniqueSelectors = new Set()\n /** @type [number,number,number] */\n let maxSpecificity\n /** @type [number,number,number] */\n let minSpecificity\n const specificityA = new AggregateCollection()\n const specificityB = new AggregateCollection()\n const specificityC = new AggregateCollection()\n const uniqueSpecificities = new CountableCollection()\n const selectorComplexities = new AggregateCollection()\n /** @type [number,number,number][] */\n const specificities = []\n const ids = new CountableCollection()\n const a11y = new CountableCollection()\n\n // Declarations\n const uniqueDeclarations = new Set()\n let totalDeclarations = 0\n let importantDeclarations = 0\n let importantsInKeyframes = 0\n let importantCustomProperties = new CountableCollection()\n\n // Properties\n const properties = new CountableCollection()\n const propertyHacks = new CountableCollection()\n const propertyVendorPrefixes = new CountableCollection()\n const customProperties = new CountableCollection()\n const propertyComplexities = new AggregateCollection()\n\n // Values\n const vendorPrefixedValues = new CountableCollection()\n const valueBrowserhacks = new CountableCollection()\n const zindex = new CountableCollection()\n const textShadows = new CountableCollection()\n const boxShadows = new CountableCollection()\n const fontFamilies = new CountableCollection()\n const fontSizes = new CountableCollection()\n const timingFunctions = new CountableCollection()\n const durations = new CountableCollection()\n const colors = new ContextCollection()\n const colorFormats = new CountableCollection()\n const units = new ContextCollection()\n\n walk(ast, function (node) {\n switch (node.type) {\n case 'Atrule': {\n totalAtRules++\n const atRuleName = node.name\n\n if (atRuleName === 'font-face') {\n /** @type {[index: string]: string} */\n const descriptors = {}\n\n node.block.children.forEach(\n /** @param {import('css-tree').Declaration} descriptor */\n descriptor => (descriptors[descriptor.property] = stringifyNode(descriptor.value))\n )\n\n fontfaces.push(descriptors)\n break\n }\n\n if (atRuleName === 'media') {\n const prelude = stringifyNode(node.prelude).trim()\n medias.push(prelude)\n if (isMediaBrowserhack(node.prelude)) {\n mediaBrowserhacks.push(prelude)\n }\n break\n }\n if (atRuleName === 'supports') {\n const prelude = stringifyNode(node.prelude)\n supports.push(prelude)\n if (isSupportsBrowserhack(node.prelude)) {\n supportsBrowserhacks.push(prelude)\n }\n break\n }\n if (endsWith('keyframes', atRuleName)) {\n const name = '@' + atRuleName + ' ' + stringifyNode(node.prelude)\n if (hasVendorPrefix(atRuleName)) {\n prefixedKeyframes.push(name)\n }\n keyframes.push(name)\n break\n }\n if (atRuleName === 'import') {\n imports.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'charset') {\n charsets.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'container') {\n containers.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'layer') {\n const prelude = stringifyNode(node.prelude)\n prelude.trim()\n .split(',')\n .forEach(name => layers.push(name.trim()))\n }\n break\n }\n case 'Rule': {\n const numSelectors = node.prelude.children ? node.prelude.children.size : 0\n const numDeclarations = node.block.children ? node.block.children.size : 0\n\n ruleSizes.push(numSelectors + numDeclarations)\n selectorsPerRule.push(numSelectors)\n declarationsPerRule.push(numDeclarations)\n\n totalRules++\n\n if (numDeclarations === 0) {\n emptyRules++\n }\n break\n }\n case 'Selector': {\n const selector = stringifyNode(node)\n\n if (this.atrule && endsWith('keyframes', this.atrule.name)) {\n keyframeSelectors.push(selector)\n return this.skip\n }\n\n const [{ value: specificityObj }] = calculate(node)\n const specificity = [specificityObj.a, specificityObj.b, specificityObj.c]\n\n if (specificity[0] > 0) {\n ids.push(selector)\n }\n\n if (isAccessibility(node)) {\n a11y.push(selector)\n }\n\n uniqueSelectors.add(selector)\n selectorComplexities.push(getComplexity(node))\n uniqueSpecificities.push(specificity[0] + ',' + specificity[1] + ',' + specificity[2])\n\n if (maxSpecificity === undefined) {\n maxSpecificity = specificity\n }\n\n if (minSpecificity === undefined) {\n minSpecificity = specificity\n }\n\n specificityA.push(specificity[0])\n specificityB.push(specificity[1])\n specificityC.push(specificity[2])\n\n if (minSpecificity !== undefined && compareSpecificity(minSpecificity, specificity) < 0) {\n minSpecificity = specificity\n }\n\n if (maxSpecificity !== undefined && compareSpecificity(maxSpecificity, specificity) > 0) {\n maxSpecificity = specificity\n }\n\n specificities.push(specificity)\n\n // Avoid deeper walking of selectors to not mess with\n // our specificity calculations in case of a selector\n // with :where() or :is() that contain SelectorLists\n // as children\n return this.skip\n }\n case 'Dimension': {\n if (!this.declaration) {\n break\n }\n\n if (endsWith('\\\\9', node.unit)) {\n units.push(node.unit.substring(0, node.unit.length - 2), this.declaration.property)\n } else {\n units.push(node.unit, this.declaration.property)\n }\n\n return this.skip\n }\n case 'Url': {\n if (startsWith('data:', node.value)) {\n var embed = node.value\n var size = embed.length\n var type = getEmbedType(embed)\n\n embedTypes.total++\n embedSize += size\n\n if (embedTypes.unique.has(type)) {\n let item = embedTypes.unique.get(type)\n item.count++\n item.size += size\n embedTypes.unique.set(type, item)\n } else {\n embedTypes.unique.set(type, {\n count: 1,\n size\n })\n }\n\n // @deprecated\n embeds.push(embed)\n }\n break\n }\n case 'Value': {\n if (isValueKeyword(node)) {\n break\n }\n\n const declaration = this.declaration\n const { property, important } = declaration\n\n if (isAstVendorPrefixed(node)) {\n vendorPrefixedValues.push(stringifyNode(node))\n }\n\n // i.e. `property: value !ie`\n if (typeof important === 'string') {\n valueBrowserhacks.push(stringifyNode(node) + '!' + important)\n }\n\n // i.e. `property: value\\9`\n if (isIe9Hack(node)) {\n valueBrowserhacks.push(stringifyNode(node))\n }\n\n // Process properties first that don't have colors,\n // so we can avoid further walking them;\n if (isProperty('z-index', property)) {\n if (!isValueKeyword(node)) {\n zindex.push(stringifyNode(node))\n }\n return this.skip\n } else if (isProperty('font', property)) {\n if (!isFontFamilyKeyword(node)) {\n fontFamilies.push(getFamilyFromFont(node, stringifyNode))\n }\n if (!isFontSizeKeyword(node)) {\n const size = getSizeFromFont(node)\n if (size) {\n fontSizes.push(size)\n }\n }\n break\n } else if (isProperty('font-size', property)) {\n if (!isFontSizeKeyword(node)) {\n fontSizes.push(stringifyNode(node))\n }\n break\n } else if (isProperty('font-family', property)) {\n if (!isFontFamilyKeyword(node)) {\n fontFamilies.push(stringifyNode(node))\n }\n break\n } else if (isProperty('transition', property) || isProperty('animation', property)) {\n const [times, fns] = analyzeAnimation(node.children, stringifyNode)\n for (let i = 0; i < times.length; i++) {\n durations.push(times[i])\n }\n for (let i = 0; i < fns.length; i++) {\n timingFunctions.push(fns[i])\n }\n break\n } else if (isProperty('animation-duration', property) || isProperty('transition-duration', property)) {\n durations.push(stringifyNode(node))\n break\n } else if (isProperty('transition-timing-function', property) || isProperty('animation-timing-function', property)) {\n timingFunctions.push(stringifyNode(node))\n break\n } else if (isProperty('text-shadow', property)) {\n if (!isValueKeyword(node)) {\n textShadows.push(stringifyNode(node))\n }\n // no break here: potentially contains colors\n } else if (isProperty('box-shadow', property)) {\n if (!isValueKeyword(node)) {\n boxShadows.push(stringifyNode(node))\n }\n // no break here: potentially contains colors\n }\n\n walk(node, function (valueNode) {\n switch (valueNode.type) {\n case 'Hash': {\n let hexLength = valueNode.value.length\n if (endsWith('\\\\9', valueNode.value)) {\n hexLength = hexLength - 2\n }\n colors.push('#' + valueNode.value, property)\n colorFormats.push(`hex` + hexLength)\n\n return this.skip\n }\n case 'Identifier': {\n const { name } = valueNode\n // Bail out if it can't be a color name\n // 20 === 'lightgoldenrodyellow'.length\n // 3 === 'red'.length\n if (name.length > 20 || name.length < 3) {\n return this.skip\n }\n const stringified = stringifyNode(valueNode)\n const lowerCased = name.toLowerCase()\n\n if (namedColors.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push('named')\n } else if (colorKeywords.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push(lowerCased)\n } else if (systemColors.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push('system')\n }\n return this.skip\n }\n case 'Function': {\n // Don't walk var() multiple times\n if (strEquals('var', valueNode.name)) {\n return this.skip\n }\n const fnName = valueNode.name.toLowerCase()\n const stringified = stringifyNode(valueNode)\n if (colorFunctions.has(fnName)) {\n colors.push(stringified, property)\n colorFormats.push(fnName)\n }\n // No this.skip here intentionally,\n // otherwise we'll miss colors in linear-gradient() etc.\n }\n }\n })\n break\n }\n case 'Declaration': {\n // Do not process Declarations in atRule preludes\n // because we will handle them manually\n if (this.atrulePrelude !== null) {\n return this.skip\n }\n\n totalDeclarations++\n\n uniqueDeclarations.add(stringifyNode(node))\n\n if (node.important === true) {\n importantDeclarations++\n\n if (this.atrule && endsWith('keyframes', this.atrule.name)) {\n importantsInKeyframes++\n }\n }\n\n const { property } = node\n\n properties.push(property)\n\n if (hasVendorPrefix(property)) {\n propertyVendorPrefixes.push(property)\n propertyComplexities.push(2)\n } else if (isHack(property)) {\n propertyHacks.push(property)\n propertyComplexities.push(2)\n } else if (isCustom(property)) {\n customProperties.push(property)\n propertyComplexities.push(2)\n if (node.important === true) {\n importantCustomProperties.push(property)\n }\n } else {\n propertyComplexities.push(1)\n }\n break\n }\n }\n })\n\n const embeddedContent = embeds.count()\n\n const totalUniqueDeclarations = uniqueDeclarations.size\n\n const totalSelectors = selectorComplexities.size()\n const specificitiesA = specificityA.aggregate()\n const specificitiesB = specificityB.aggregate()\n const specificitiesC = specificityC.aggregate()\n const uniqueSpecificitiesCount = uniqueSpecificities.count()\n const complexityCount = new CountableCollection(selectorComplexities.toArray()).count()\n const totalUniqueSelectors = uniqueSelectors.size\n const uniqueRuleSize = new CountableCollection(ruleSizes.toArray()).count()\n const uniqueSelectorsPerRule = new CountableCollection(selectorsPerRule.toArray()).count()\n const uniqueDeclarationsPerRule = new CountableCollection(declarationsPerRule.toArray()).count()\n const assign = Object.assign\n\n return {\n stylesheet: {\n sourceLinesOfCode: totalAtRules + totalSelectors + totalDeclarations + keyframeSelectors.size(),\n linesOfCode: lines.length,\n size: css.length,\n comments: {\n total: totalComments,\n size: commentsSize,\n },\n embeddedContent: assign(embeddedContent, {\n size: {\n total: embedSize,\n ratio: ratio(embedSize, css.length),\n },\n types: {\n total: embedTypes.total,\n totalUnique: embedTypes.unique.size,\n uniquenessRatio: ratio(embedTypes.unique.size, embedTypes.total),\n unique: Object.fromEntries(embedTypes.unique),\n },\n }),\n },\n atrules: {\n fontface: {\n total: fontfaces.length,\n totalUnique: fontfaces.length,\n unique: fontfaces,\n uniquenessRatio: fontfaces.length === 0 ? 0 : 1\n },\n import: imports.count(),\n media: assign(\n medias.count(),\n {\n browserhacks: mediaBrowserhacks.count(),\n }\n ),\n charset: charsets.count(),\n supports: assign(\n supports.count(),\n {\n browserhacks: supportsBrowserhacks.count(),\n },\n ),\n keyframes: assign(\n keyframes.count(), {\n prefixed: assign(\n prefixedKeyframes.count(), {\n ratio: ratio(prefixedKeyframes.size(), keyframes.size())\n }),\n }),\n container: containers.count(),\n layer: layers.count(),\n },\n rules: {\n total: totalRules,\n empty: {\n total: emptyRules,\n ratio: ratio(emptyRules, totalRules)\n },\n sizes: assign(\n ruleSizes.aggregate(),\n {\n items: ruleSizes.toArray(),\n unique: uniqueRuleSize.unique,\n totalUnique: uniqueRuleSize.totalUnique,\n uniquenessRatio: uniqueRuleSize.uniquenessRatio\n },\n ),\n selectors: assign(\n selectorsPerRule.aggregate(),\n {\n items: selectorsPerRule.toArray(),\n unique: uniqueSelectorsPerRule.unique,\n totalUnique: uniqueSelectorsPerRule.totalUnique,\n uniquenessRatio: uniqueSelectorsPerRule.uniquenessRatio\n },\n ),\n declarations: assign(\n declarationsPerRule.aggregate(),\n {\n items: declarationsPerRule.toArray(),\n unique: uniqueDeclarationsPerRule.unique,\n totalUnique: uniqueDeclarationsPerRule.totalUnique,\n uniquenessRatio: uniqueDeclarationsPerRule.uniquenessRatio,\n },\n ),\n },\n selectors: {\n total: totalSelectors,\n totalUnique: totalUniqueSelectors,\n uniquenessRatio: ratio(totalUniqueSelectors, totalSelectors),\n specificity: {\n /** @type [number, number, number] */\n min: minSpecificity === undefined ? [0, 0, 0] : minSpecificity,\n /** @type [number, number, number] */\n max: maxSpecificity === undefined ? [0, 0, 0] : maxSpecificity,\n /** @type [number, number, number] */\n sum: [specificitiesA.sum, specificitiesB.sum, specificitiesC.sum],\n /** @type [number, number, number] */\n mean: [specificitiesA.mean, specificitiesB.mean, specificitiesC.mean],\n /** @type [number, number, number] */\n mode: [specificitiesA.mode, specificitiesB.mode, specificitiesC.mode],\n /** @type [number, number, number] */\n median: [specificitiesA.median, specificitiesB.median, specificitiesC.median],\n items: specificities,\n unique: uniqueSpecificitiesCount.unique,\n totalUnique: uniqueSpecificitiesCount.totalUnique,\n uniquenessRatio: uniqueSpecificitiesCount.uniquenessRatio,\n },\n complexity: assign(\n selectorComplexities.aggregate(),\n complexityCount, {\n items: selectorComplexities.toArray(),\n }),\n id: assign(\n ids.count(), {\n ratio: ratio(ids.size(), totalSelectors),\n }),\n accessibility: assign(\n a11y.count(), {\n ratio: ratio(a11y.size(), totalSelectors),\n }),\n keyframes: keyframeSelectors.count(),\n },\n declarations: {\n total: totalDeclarations,\n totalUnique: totalUniqueDeclarations,\n uniquenessRatio: ratio(totalUniqueDeclarations, totalDeclarations),\n // @TODO: deprecated, remove in next major version\n unique: {\n total: totalUniqueDeclarations,\n ratio: ratio(totalUniqueDeclarations, totalDeclarations),\n },\n importants: {\n total: importantDeclarations,\n ratio: ratio(importantDeclarations, totalDeclarations),\n inKeyframes: {\n total: importantsInKeyframes,\n ratio: ratio(importantsInKeyframes, importantDeclarations),\n },\n },\n },\n properties: assign(\n properties.count(),\n {\n prefixed: assign(\n propertyVendorPrefixes.count(),\n {\n ratio: ratio(propertyVendorPrefixes.size(), properties.size()),\n },\n ),\n custom: assign(\n customProperties.count(),\n {\n ratio: ratio(customProperties.size(), properties.size()),\n importants: assign(\n importantCustomProperties.count(),\n {\n ratio: ratio(importantCustomProperties.size(), customProperties.size()),\n }\n ),\n },\n ),\n browserhacks: assign(\n propertyHacks.count(), {\n ratio: ratio(propertyHacks.size(), properties.size()),\n }),\n complexity: propertyComplexities.aggregate(),\n }),\n values: {\n colors: assign(\n colors.count(),\n {\n formats: colorFormats.count(),\n },\n ),\n fontFamilies: fontFamilies.count(),\n fontSizes: fontSizes.count(),\n zindexes: zindex.count(),\n textShadows: textShadows.count(),\n boxShadows: boxShadows.count(),\n animations: {\n durations: durations.count(),\n timingFunctions: timingFunctions.count(),\n },\n prefixes: vendorPrefixedValues.count(),\n browserhacks: valueBrowserhacks.count(),\n units: units.count(),\n },\n __meta__: {\n parseTime: startAnalysis - startParse,\n analyzeTime: Date.now() - startAnalysis,\n total: Date.now() - start\n }\n }\n}\n\nexport {\n analyze,\n compareSpecificity,\n}\n","export function getEmbedType(/** @type string */embed) {\n\t// data:image/gif;base64,R0lG\n\tlet start = 5 // `data:`.length\n\tlet semicolon = embed.indexOf(';')\n\tlet comma = embed.indexOf(',')\n\n\tif (semicolon === -1) {\n\t\treturn embed.substring(start, comma)\n\t}\n\n\tif (comma !== -1 && comma < semicolon) {\n\t\treturn embed.substring(start, comma);\n\t}\n\n\treturn embed.substring(start, semicolon)\n}","import { endsWith } from \"../string-utils.js\"\n\nexport function isIe9Hack(node) {\n\treturn node.children\n\t\t&& node.children.last\n\t\t&& node.children.last.type === 'Identifier'\n\t\t&& endsWith('\\\\9', node.children.last.name)\n}"],"names":["compareChar","referenceCode","testCode","strEquals","base","test","length","i","charCodeAt","endsWith","offset","startsWith","isPropertyValue","node","property","value","children","first","type","name","hasVendorPrefix","keyword","indexOf","compareSpecificity","a","b","analyzeList","selectorListAst","cb","childSelectors","walk","visit","enter","push","isPseudoFunction","isAccessibility","selector","isA11y","some","skip","getComplexity","complexity","Boolean","list","forEach","c","namedColors","Set","systemColors","colorFunctions","colorKeywords","systemKeywords","keywordDisallowList","isFontFamilyKeyword","firstChild","has","sizeKeywords","keywords","isFontSizeKeyword","isValueKeyword","size","timingKeywords","isAstVendorPrefixed","toArray","index","CountableCollection","initial","this","_items","Map","_total","item","set","get","count","total","totalUnique","unique","Object","fromEntries","uniquenessRatio","ContextCollection","_list","_contexts","context","itemsPerContext","entries","assign","AggregateCollection","_sum","aggregate","min","max","mean","mode","median","range","sum","arr","middle","lowerMiddleRank","sorted","slice","sort","frequencies","maxOccurrences","maxOccurenceCount","element","updatedCount","Mode","Math","floor","isCustom","isProperty","basename","ratio","part","css","start","Date","now","lines","split","stringifyNode","substring","loc","end","maxSpecificity","minSpecificity","totalComments","commentsSize","embeds","embedSize","embedTypes","startParse","ast","parse","parseCustomProperty","positions","onComment","comment","startAnalysis","totalAtRules","fontfaces","layers","imports","medias","mediaBrowserhacks","charsets","supports","supportsBrowserhacks","keyframes","prefixedKeyframes","containers","totalRules","emptyRules","ruleSizes","selectorsPerRule","declarationsPerRule","keyframeSelectors","uniqueSelectors","specificityA","specificityB","specificityC","uniqueSpecificities","selectorComplexities","specificities","ids","a11y","uniqueDeclarations","totalDeclarations","importantDeclarations","importantsInKeyframes","importantCustomProperties","properties","propertyHacks","propertyVendorPrefixes","customProperties","propertyComplexities","vendorPrefixedValues","valueBrowserhacks","zindex","textShadows","boxShadows","fontFamilies","fontSizes","timingFunctions","durations","colors","colorFormats","units","atRuleName","descriptors","block","descriptor","prelude","trim","returnValue","unit","isMediaBrowserhack","isSupportsBrowserhack","numSelectors","numDeclarations","atrule","specificityObj","calculate","specificity","add","undefined","declaration","embed","semicolon","comma","getEmbedType","important","last","isIe9Hack","parts","reverse","fontNode","quote","getFamilyFromFont","operator","getSizeFromFont","durationFound","child","analyzeAnimation","times","fns","valueNode","hexLength","stringified","lowerCased","toLowerCase","fnName","atrulePrelude","code","isHack","embeddedContent","totalUniqueDeclarations","totalSelectors","specificitiesA","specificitiesB","specificitiesC","uniqueSpecificitiesCount","complexityCount","totalUniqueSelectors","uniqueRuleSize","uniqueSelectorsPerRule","uniqueDeclarationsPerRule","stylesheet","sourceLinesOfCode","linesOfCode","comments","types","atrules","fontface","import","media","browserhacks","charset","prefixed","container","layer","rules","empty","sizes","items","selectors","declarations","id","accessibility","importants","inKeyframes","custom","values","formats","zindexes","animations","prefixes","__meta__","parseTime","analyzeTime"],"mappings":"wNAMA,SAASA,EAAYC,EAAeC,GAMlC,OAJIA,GAAY,IAAUA,GAAY,KAEpCA,GAAsB,IAEjBD,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FN,IACb,EAEJ,GAEME,CACR,KCjIYK,EAAc,IAAIC,IAAI,CAGjC,YACA,eACA,OACA,aACA,QACA,QACA,SACA,QACA,iBACA,OACA,aACA,QACA,YACA,YACA,aACA,YACA,QACA,iBACA,WACA,UACA,OACA,WACA,WACA,gBACA,WACA,YACA,WACA,YACA,cACA,iBACA,aACA,aACA,UACA,aACA,eACA,gBACA,gBACA,gBACA,gBACA,aACA,WACA,cACA,UACA,UACA,aACA,YACA,cACA,cACA,UACA,YACA,aACA,OACA,YACA,OACA,QACA,cACA,OACA,WACA,UACA,YACA,SACA,QACA,QACA,WACA,gBACA,YACA,eACA,YACA,aACA,YACA,uBACA,YACA,aACA,YACA,YACA,cACA,gBACA,eACA,iBACA,iBACA,iBACA,cACA,OACA,YACA,QACA,UACA,SACA,mBACA,aACA,eACA,eACA,iBACA,kBACA,oBACA,kBACA,kBACA,eACA,YACA,YACA,WACA,cACA,OACA,UACA,QACA,YACA,SACA,YACA,SACA,gBACA,YACA,gBACA,gBACA,aACA,YACA,OACA,OACA,OACA,aACA,SACA,gBACA,MACA,YACA,YACA,cACA,SACA,aACA,WACA,WACA,SACA,SACA,UACA,YACA,YACA,YACA,OACA,cACA,YACA,MACA,OACA,UACA,SACA,YACA,SACA,QACA,QACA,aACA,SACA,gBAGWC,EAAe,IAAID,IAAI,CAGlC,SACA,aACA,WACA,cACA,aACA,aACA,aACA,eACA,QACA,YACA,YACA,gBACA,eACA,mBACA,OACA,WACA,aAMWE,EAAiB,IAAIF,IAAI,CACpC,MACA,OACA,MACA,OACA,MACA,MACA,MACA,QACA,QACA,UAGWG,EAAgB,IAAIH,IAAI,CACnC,eACA,gBC/LII,EAAiB,IAAIJ,IAAI,CAE7B,UACA,UACA,QACA,SAGA,UACA,OACA,OACA,cACA,gBACA,eAGIK,EAAsB,IAAIL,IAAI,CAElC,SAGA,WACA,UACA,QACA,SACA,QACA,UACA,WACA,SACA,UAGA,OACA,SACA,UAGA,kBACA,kBACA,YACA,iBACA,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AAS,CACvByC,MAAOA,EAAM4D,GAAcnH,OAAQkH,GAAWlH,UAEhDnB,WAAYyI,GAAqBxF,cAErCyL,OAAQ,CACNvF,OAAQrG,GACNqG,GAAOlH,QACP,CACE0M,QAASvF,GAAanH,UAG1B8G,aAAcA,GAAa9G,QAC3B+G,UAAWA,GAAU/G,QACrB2M,SAAUhG,GAAO3G,QACjB4G,YAAaA,GAAY5G,QACzB6G,WAAYA,GAAW7G,QACvB4M,WAAY,CACV3F,UAAWA,GAAUjH,QACrBgH,gBAAiBA,GAAgBhH,SAEnC6M,SAAUpG,GAAqBzG,QAC/ByL,aAAc/E,GAAkB1G,QAChCoH,MAAOA,GAAMpH,SAEf8M,SAAU,CACRC,UAAW5I,EAAgBP,EAC3BoJ,YAAanK,KAAKC,MAAQqB,EAC1BlE,MAAO4C,KAAKC,MAAQF,GAGzB"}
|
|
1
|
+
{"version":3,"file":"analyzer.cjs","sources":["../src/string-utils.js","../src/atrules/atrules.js","../src/vendor-prefix.js","../src/selectors/utils.js","../src/values/colors.js","../src/values/font-families.js","../src/values/font-sizes.js","../src/values/values.js","../src/values/animations.js","../src/values/vendor-prefix.js","../src/countable-collection.js","../src/context-collection.js","../src/aggregate-collection.js","../src/properties/property-utils.js","../src/index.js","../src/stylesheet/stylesheet.js","../src/values/browserhacks.js"],"sourcesContent":["/**\n * Case-insensitive compare two character codes\n * @param {string} charA\n * @param {string} charB\n * @see https://github.com/csstree/csstree/blob/41f276e8862d8223eeaa01a3d113ab70bb13d2d9/lib/tokenizer/utils.js#L22\n */\nfunction compareChar(referenceCode, testCode) {\n // if uppercase\n if (testCode >= 0x0041 && testCode <= 0x005A) {\n // shifting the 6th bit makes a letter lowercase\n testCode = testCode | 32\n }\n return referenceCode === testCode\n}\n\n/**\n * Case-insensitive string-comparison\n * @param {string} base\n * @param {string} test\n * @returns {boolean} true if the two strings are the same, false otherwise\n */\nexport function strEquals(base, test) {\n if (base.length !== test.length) return false\n\n for (let i = 0; i < base.length; i++) {\n if (compareChar(base.charCodeAt(i), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Case-insensitive testing whether a string ends with a given substring\n * @param {string} base e.g. '-webkit-transform'\n * @param {string} cmp e.g. 'transform'\n * @returns {boolean} true if `test` ends with `base`, false otherwise\n */\nexport function endsWith(base, test) {\n const offset = test.length - base.length\n\n if (offset < 0) {\n return false\n }\n\n for (let i = test.length - 1; i >= offset; i--) {\n if (compareChar(base.charCodeAt(i - offset), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Case-insensitive testing whether a string starts with a given substring\n * @param {string} base\n * @param {test} test\n * @returns {boolean} true if `test` starts with `base`, false otherwise\n */\nexport function startsWith(base, test) {\n if (test.length < base.length) return false\n\n for (let i = 0; i < base.length; i++) {\n if (compareChar(base.charCodeAt(i), test.charCodeAt(i)) === false) {\n return false\n }\n }\n\n return true\n}\n","import { strEquals, startsWith, endsWith } from '../string-utils.js'\nimport walk from 'css-tree/walker'\n\n/**\n * Check whether node.property === property and node.value === value,\n * but case-insensitive and fast.\n * @param {import('css-tree').Declaration} node\n * @param {string} property - The CSS property to compare with (case-insensitive)\n * @param {string} value - The identifier/keyword value to compare with\n * @returns true if declaratioNode is the given property: value, false otherwise\n */\nfunction isPropertyValue(node, property, value) {\n return strEquals(property, node.property)\n && node.value.children.first.type === 'Identifier'\n && strEquals(value, node.value.children.first.name)\n}\n\n/**\n * Check if an @supports atRule is a browserhack\n * @param {import('css-tree').AtrulePrelude} prelude\n * @returns true if the atrule is a browserhack\n */\nexport function isSupportsBrowserhack(prelude) {\n let returnValue = false\n\n walk(prelude, function (node) {\n if (node.type === 'Declaration') {\n if (\n isPropertyValue(node, '-webkit-appearance', 'none')\n || isPropertyValue(node, '-moz-appearance', 'meterbar')\n ) {\n returnValue = true\n return this.break\n }\n }\n })\n\n return returnValue\n}\n\n/**\n * Check if a @media atRule is a browserhack\n * @param {import('css-tree').AtrulePrelude} prelude\n * @returns true if the atrule is a browserhack\n */\nexport function isMediaBrowserhack(prelude) {\n let returnValue = false\n\n walk(prelude, function (node) {\n if (node.type === 'MediaQuery'\n && node.children.size === 1\n && node.children.first.type === 'Identifier'\n ) {\n node = node.children.first\n // Note: CSSTree adds a trailing space to \\\\9\n if (startsWith('\\\\0', node.name) || endsWith('\\\\9 ', node.name)) {\n returnValue = true\n return this.break\n }\n }\n if (node.type === 'MediaFeature') {\n if (node.value !== null && node.value.unit === '\\\\0') {\n returnValue = true\n return this.break\n }\n if (strEquals('-moz-images-in-menus', node.name)\n || strEquals('min--moz-device-pixel-ratio', node.name)\n || strEquals('-ms-high-contrast', node.name)\n ) {\n returnValue = true\n return this.break\n }\n if (strEquals('min-resolution', node.name)\n && strEquals('.001', node.value.value)\n && strEquals('dpcm', node.value.unit)\n ) {\n returnValue = true\n return this.break\n }\n if (strEquals('-webkit-min-device-pixel-ratio', node.name)) {\n if ((strEquals('0', node.value.value) || strEquals('10000', node.value.value))) {\n returnValue = true\n return this.break\n }\n }\n }\n })\n\n return returnValue\n}","const HYPHENMINUS = 45; // '-'.charCodeAt()\n\n/**\n * @param {string} keyword\n * @returns {boolean}\n */\nfunction hasVendorPrefix(keyword) {\n if (keyword.charCodeAt(0) === HYPHENMINUS && keyword.charCodeAt(1) !== HYPHENMINUS) {\n // String must have a 2nd occurrence of '-', at least at position 3 (offset=2)\n if (keyword.indexOf('-', 2) !== -1) {\n return true\n }\n }\n\n return false\n}\n\nexport {\n hasVendorPrefix\n}","import walk from 'css-tree/walker'\nimport { startsWith, strEquals } from '../string-utils.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\n/**\n * Compare specificity A to Specificity B\n * @param {[number,number,number]} a - Specificity A\n * @param {[number,number,number]} b - Specificity B\n * @returns {number} sortIndex - 0 when a==b, 1 when a<b, -1 when a>b\n */\nexport function compareSpecificity(a, b) {\n if (a[0] === b[0]) {\n if (a[1] === b[1]) {\n return b[2] - a[2]\n }\n\n return b[1] - a[1]\n }\n\n return b[0] - a[0]\n}\n\n/**\n *\n * @param {import('css-tree').SelectorList} selectorListAst\n * @returns {Selector[]} Analyzed selectors in the selectorList\n */\nfunction analyzeList(selectorListAst, cb) {\n const childSelectors = []\n walk(selectorListAst, {\n visit: 'Selector',\n enter: function (node) {\n childSelectors.push(cb(node))\n }\n })\n\n return childSelectors\n}\n\nfunction isPseudoFunction(name) {\n return (\n strEquals(name, 'not')\n || strEquals(name, 'nth-child')\n || strEquals(name, 'nth-last-child')\n || strEquals(name, 'where')\n || strEquals(name, 'is')\n || strEquals(name, 'has')\n || strEquals(name, 'matches')\n || strEquals(name, '-webkit-any')\n || strEquals(name, '-moz-any')\n )\n}\n\nexport function isAccessibility(selector) {\n let isA11y = false\n\n walk(selector, function (node) {\n if (node.type == 'AttributeSelector') {\n if (strEquals('role', node.name.name) || startsWith('aria-', node.name.name)) {\n isA11y = true\n return this.break\n }\n }\n // Test for [aria-] or [role] inside :is()/:where() and friends\n else if (node.type == 'PseudoClassSelector') {\n if (isPseudoFunction(node.name)) {\n const list = analyzeList(node, isAccessibility)\n\n if (list.some(b => b == true)) {\n isA11y = true\n return this.skip\n }\n\n return this.skip\n }\n }\n })\n\n return isA11y;\n}\n\n/**\n * Get the Complexity for the AST of a Selector Node\n * @param {import('css-tree').Selector} ast - AST Node for a Selector\n * @return {number} - The numeric complexity of the Selector\n */\nexport function getComplexity(selector) {\n let complexity = 0\n\n walk(selector, function (node) {\n if (node.type == 'Selector' || node.type == 'Nth') return\n\n complexity++\n\n if (node.type == 'IdSelector'\n || node.type == 'ClassSelector'\n || node.type == 'PseudoElementSelector'\n || node.type == 'TypeSelector'\n || node.type == 'PseudoClassSelector'\n ) {\n if (hasVendorPrefix(node.name)) {\n complexity++\n }\n }\n\n if (node.type == 'AttributeSelector') {\n if (Boolean(node.value)) {\n complexity++\n }\n if (hasVendorPrefix(node.name.name)) {\n complexity++\n }\n return this.skip\n }\n\n if (node.type == 'PseudoClassSelector') {\n if (isPseudoFunction(node.name)) {\n const list = analyzeList(node, getComplexity)\n\n // Bail out for empty/non-existent :nth-child() params\n if (list.length === 0) return\n\n list.forEach(c => complexity += c)\n return this.skip\n }\n }\n })\n\n return complexity\n}\n","export const namedColors = new Set([\n // CSS Named Colors\n // Spec: https://drafts.csswg.org/css-color/#named-colors\n 'aliceblue',\n 'antiquewhite',\n 'aqua',\n 'aquamarine',\n 'azure',\n 'beige',\n 'bisque',\n 'black',\n 'blanchedalmond',\n 'blue',\n 'blueviolet',\n 'brown',\n 'burlywood',\n 'cadetblue',\n 'chartreuse',\n 'chocolate',\n 'coral',\n 'cornflowerblue',\n 'cornsilk',\n 'crimson',\n 'cyan',\n 'darkblue',\n 'darkcyan',\n 'darkgoldenrod',\n 'darkgray',\n 'darkgreen',\n 'darkgrey',\n 'darkkhaki',\n 'darkmagenta',\n 'darkolivegreen',\n 'darkorange',\n 'darkorchid',\n 'darkred',\n 'darksalmon',\n 'darkseagreen',\n 'darkslateblue',\n 'darkslategray',\n 'darkslategrey',\n 'darkturquoise',\n 'darkviolet',\n 'deeppink',\n 'deepskyblue',\n 'dimgray',\n 'dimgrey',\n 'dodgerblue',\n 'firebrick',\n 'floralwhite',\n 'forestgreen',\n 'fuchsia',\n 'gainsboro',\n 'ghostwhite',\n 'gold',\n 'goldenrod',\n 'gray',\n 'green',\n 'greenyellow',\n 'grey',\n 'honeydew',\n 'hotpink',\n 'indianred',\n 'indigo',\n 'ivory',\n 'khaki',\n 'lavender',\n 'lavenderblush',\n 'lawngreen',\n 'lemonchiffon',\n 'lightblue',\n 'lightcoral',\n 'lightcyan',\n 'lightgoldenrodyellow',\n 'lightgray',\n 'lightgreen',\n 'lightgrey',\n 'lightpink',\n 'lightsalmon',\n 'lightseagreen',\n 'lightskyblue',\n 'lightslategray',\n 'lightslategrey',\n 'lightsteelblue',\n 'lightyellow',\n 'lime',\n 'limegreen',\n 'linen',\n 'magenta',\n 'maroon',\n 'mediumaquamarine',\n 'mediumblue',\n 'mediumorchid',\n 'mediumpurple',\n 'mediumseagreen',\n 'mediumslateblue',\n 'mediumspringgreen',\n 'mediumturquoise',\n 'mediumvioletred',\n 'midnightblue',\n 'mintcream',\n 'mistyrose',\n 'moccasin',\n 'navajowhite',\n 'navy',\n 'oldlace',\n 'olive',\n 'olivedrab',\n 'orange',\n 'orangered',\n 'orchid',\n 'palegoldenrod',\n 'palegreen',\n 'paleturquoise',\n 'palevioletred',\n 'papayawhip',\n 'peachpuff',\n 'peru',\n 'pink',\n 'plum',\n 'powderblue',\n 'purple',\n 'rebeccapurple',\n 'red',\n 'rosybrown',\n 'royalblue',\n 'saddlebrown',\n 'salmon',\n 'sandybrown',\n 'seagreen',\n 'seashell',\n 'sienna',\n 'silver',\n 'skyblue',\n 'slateblue',\n 'slategray',\n 'slategrey',\n 'snow',\n 'springgreen',\n 'steelblue',\n 'tan',\n 'teal',\n 'thistle',\n 'tomato',\n 'turquoise',\n 'violet',\n 'wheat',\n 'white',\n 'whitesmoke',\n 'yellow',\n 'yellowgreen',\n])\n\nexport const systemColors = new Set([\n // CSS System Colors\n // Spec: https://drafts.csswg.org/css-color/#css-system-colors\n 'canvas',\n 'canvastext',\n 'linktext',\n 'visitedtext',\n 'activetext',\n 'buttonface',\n 'buttontext',\n 'buttonborder',\n 'field',\n 'fieldtext',\n 'highlight',\n 'highlighttext',\n 'selecteditem',\n 'selecteditemtext',\n 'mark',\n 'marktext',\n 'graytext',\n\n // TODO: Deprecated CSS System colors\n // Spec: https://drafts.csswg.org/css-color/#deprecated-system-colors\n])\n\nexport const colorFunctions = new Set([\n 'rgb',\n 'rgba',\n 'hsl',\n 'hsla',\n 'hwb',\n 'lab',\n 'lch',\n 'oklab',\n 'oklch',\n 'color',\n])\n\nexport const colorKeywords = new Set([\n 'currentcolor',\n 'transparent',\n])\n","import walk from 'css-tree/walker'\n\nconst systemKeywords = new Set([\n // Global CSS keywords\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n\n // System font keywords\n 'caption',\n 'icon',\n 'menu',\n 'message-box',\n 'small-caption',\n 'status-bar',\n])\n\nconst keywordDisallowList = new Set([\n // font-weight, font-stretch, font-style\n 'normal',\n\n // font-size keywords\n 'xx-small',\n 'x-small',\n 'small',\n 'medium',\n 'large',\n 'x-large',\n 'xx-large',\n 'larger',\n 'smaller',\n\n // font-weight keywords\n 'bold',\n 'bolder',\n 'lighter',\n\n // font-stretch keywords\n 'ultra-condensed',\n 'extra-condensed',\n 'condensed',\n 'semi-condensed',\n 'semi-expanded',\n 'expanded',\n 'extra-expanded',\n 'ultra-expanded',\n\n // font-style keywords\n 'italic',\n 'oblique',\n])\n\nconst COMMA = 44 // ','.charCodeAt(0) === 44\n\nexport function isFontFamilyKeyword(node) {\n const firstChild = node.children.first\n return firstChild.type === 'Identifier' && systemKeywords.has(firstChild.name)\n}\n\nexport function getFamilyFromFont(node, stringifyNode) {\n let parts = ''\n\n walk(node, {\n reverse: true,\n enter: function (fontNode) {\n if (fontNode.type === 'String') {\n const offset = fontNode.loc.start.offset\n // Stringify the first character to get the correct quote character\n const quote = stringifyNode({\n loc: {\n start: { offset },\n end: { offset: offset + 1 }\n }\n })\n return parts = quote + fontNode.value + quote + parts\n }\n if (fontNode.type === 'Operator' && fontNode.value.charCodeAt(0) === COMMA) {\n return parts = fontNode.value + parts\n }\n if (fontNode.type === 'Identifier') {\n if (keywordDisallowList.has(fontNode.name)) {\n return this.skip\n }\n return parts = fontNode.name + parts\n }\n }\n })\n\n return parts\n}\n","import walk from 'css-tree/walker'\n\nconst sizeKeywords = new Set([\n 'xx-small',\n 'x-small',\n 'small',\n 'medium',\n 'large',\n 'x-large',\n 'xx-large',\n 'larger',\n 'smaller',\n])\n\nconst keywords = new Set([\n // Global CSS keywords\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n\n // System font keywords\n 'caption',\n 'icon',\n 'menu',\n 'message-box',\n 'small-caption',\n 'status-bar',\n])\n\nconst ZERO = 48 // '0'.charCodeAt(0) === 48\nconst SLASH = 47 // '/'.charCodeAt(0) === 47\n\nexport function isFontSizeKeyword(node) {\n const firstChild = node.children.first\n return firstChild.type === 'Identifier' && keywords.has(firstChild.name)\n}\n\nexport function getSizeFromFont(node) {\n let operator = false\n let size\n\n walk(node, function (fontNode) {\n switch (fontNode.type) {\n case 'Number': {\n // Special case for `font: 0/0 a`\n if (fontNode.value.charCodeAt(0) === ZERO) {\n size = '0'\n return this.break\n }\n }\n case 'Operator': {\n if (fontNode.value.charCodeAt(0) === SLASH) {\n operator = true\n }\n break\n }\n case 'Dimension': {\n if (!operator) {\n size = fontNode.value + fontNode.unit\n return this.break\n }\n }\n case 'Identifier': {\n if (sizeKeywords.has(fontNode.name)) {\n size = fontNode.name\n return this.break\n }\n }\n }\n })\n\n return size\n}\n","const keywords = new Set([\n 'auto',\n 'inherit',\n 'initial',\n 'unset',\n 'revert',\n 'none', // for `text-shadow`, `box-shadow` and `background`\n])\n\nexport function isValueKeyword(node) {\n if (!node.children) return false\n const firstChild = node.children.first\n if (!firstChild) return false\n\n if (node.children.size > 1) return false\n return firstChild.type === 'Identifier' && keywords.has(firstChild.name)\n}\n","const timingKeywords = new Set([\n 'linear',\n 'ease',\n 'ease-in',\n 'ease-out',\n 'ease-in-out',\n 'step-start',\n 'step-end',\n])\n\nexport function analyzeAnimation(children, stringifyNode) {\n let durationFound = false\n const durations = []\n const timingFunctions = []\n\n children.forEach(child => {\n // Right after a ',' we start over again\n if (child.type === 'Operator') {\n return durationFound = false\n }\n if (child.type === 'Dimension' && durationFound === false) {\n durationFound = true\n return durations.push(stringifyNode(child))\n }\n if (child.type === 'Identifier' && timingKeywords.has(child.name)) {\n return timingFunctions.push(stringifyNode(child))\n }\n if (child.type === 'Function'\n && (\n child.name === 'cubic-bezier' || child.name === 'steps'\n )\n ) {\n return timingFunctions.push(stringifyNode(child))\n }\n })\n\n return [durations, timingFunctions]\n}\n","import { hasVendorPrefix } from '../vendor-prefix.js'\n\nexport function isAstVendorPrefixed(node) {\n if (!node.children) {\n return false\n }\n\n const children = node.children.toArray()\n\n for (let index = 0; index < children.length; index++) {\n const node = children[index]\n const { type, name } = node;\n\n if (type === 'Identifier' && hasVendorPrefix(name)) {\n return true\n }\n\n if (type === 'Function') {\n if (hasVendorPrefix(name)) {\n return true\n }\n\n if (isAstVendorPrefixed(node)) {\n return true\n }\n }\n }\n\n return false\n}\n","class CountableCollection {\n /**\n * @param {string[]} initial\n */\n constructor(initial) {\n /** @type [index: string]: string */\n this._items = new Map()\n /** @type number */\n this._total = 0\n\n if (initial) {\n for (let i = 0; i < initial.length; i++) {\n this.push(initial[i])\n }\n }\n }\n\n /**\n * Push an item to the end of this collection\n * @param {string} item\n * @returns {void}\n */\n push(item) {\n this._total++\n\n if (this._items.has(item)) {\n this._items.set(item, this._items.get(item) + 1)\n return\n }\n\n this._items.set(item, 1)\n }\n\n /**\n * Get the size of this collection\n * @returns {number} the size of this collection\n */\n size() {\n return this._total\n }\n\n /**\n * Get the counts of this collection, like total, uniques, etc.\n */\n count() {\n return {\n total: this._total,\n totalUnique: this._items.size,\n unique: Object.fromEntries(this._items),\n uniquenessRatio: this._total === 0 ? 0 : this._items.size / this._total,\n }\n }\n}\n\nexport {\n CountableCollection\n}","import { CountableCollection } from './countable-collection.js'\n\nclass ContextCollection {\n constructor() {\n this._list = new CountableCollection()\n /** @type {[index; string]: CountableCollection} */\n this._contexts = new Map()\n }\n\n /**\n * Add an item to this _list's context\n * @param {string} item Item to push\n * @param {string} context Context to push Item to\n */\n push(item, context) {\n this._list.push(item)\n\n if (!this._contexts.has(context)) {\n this._contexts.set(context, new CountableCollection())\n }\n\n this._contexts.get(context).push(item)\n }\n\n count() {\n const itemsPerContext = new Map()\n\n for (let [context, value] of this._contexts.entries()) {\n itemsPerContext.set(context, value.count())\n }\n\n return Object.assign(this._list.count(), {\n itemsPerContext: Object.fromEntries(itemsPerContext)\n })\n }\n}\n\nexport {\n ContextCollection\n}","/**\n * Find the mode (most occurring value) in an array of Numbers\n * Takes the mean/average of multiple values if multiple values occur the same amount of times.\n *\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-mode/index.js\n * @param {Array} arr - Array to find the mode value for\n * @returns {Number} mode - The `mode` value of `arr`\n */\nfunction Mode(arr) {\n const frequencies = new Map()\n let maxOccurrences = -1\n let maxOccurenceCount = 0\n let sum = 0\n\n for (let i = 0; i < arr.length; i++) {\n const element = arr[i]\n const updatedCount = (frequencies.get(element) || 0) + 1\n frequencies.set(element, updatedCount)\n\n if (updatedCount > maxOccurrences) {\n maxOccurrences = updatedCount\n maxOccurenceCount = 0\n sum = 0\n }\n\n if (updatedCount >= maxOccurrences) {\n maxOccurenceCount++\n sum += element\n }\n }\n\n return sum / maxOccurenceCount\n}\n\n/**\n * Find the middle number in an Array of Numbers\n * Returns the average of 2 numbers if the Array length is an even number\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-median/index.js\n * @param {Array} arr - A sorted Array\n * @returns {Number} - The array's Median\n */\nfunction Median(arr) {\n const middle = arr.length / 2\n const lowerMiddleRank = Math.floor(middle)\n\n if (middle !== lowerMiddleRank) {\n return arr[lowerMiddleRank]\n }\n return (arr[lowerMiddleRank] + arr[lowerMiddleRank - 1]) / 2\n}\n\nclass AggregateCollection {\n constructor() {\n /** @type number[] */\n this._items = []\n this._sum = 0\n }\n\n /**\n * Add a new Integer at the end of this AggregateCollection\n * @param {number} item - The item to add\n */\n push(item) {\n this._items.push(item)\n this._sum += item\n }\n\n size() {\n return this._items.length\n }\n\n aggregate() {\n if (this._items.length === 0) {\n return {\n min: 0,\n max: 0,\n mean: 0,\n mode: 0,\n median: 0,\n range: 0,\n sum: 0,\n }\n }\n\n // TODO: can we avoid this sort()? It's slow\n /** @type Number[] */\n const sorted = this._items.slice().sort((a, b) => a - b)\n const min = sorted[0]\n const max = sorted[sorted.length - 1]\n\n const mode = Mode(sorted)\n const median = Median(sorted)\n\n return {\n min,\n max,\n mean: this._sum / sorted.length,\n mode,\n median,\n range: max - min,\n sum: this._sum,\n }\n }\n\n /**\n * @returns {number[]} All _items in this collection\n */\n toArray() {\n return this._items\n }\n}\n\nexport {\n AggregateCollection\n}","import { hasVendorPrefix } from '../vendor-prefix.js'\nimport { endsWith } from '../string-utils.js'\n\n/**\n * @param {string} property\n * @see https://github.com/csstree/csstree/blob/master/lib/utils/names.js#L69\n */\nexport function isHack(property) {\n if (isCustom(property) || hasVendorPrefix(property)) return false\n\n let code = property.charCodeAt(0)\n\n return code === 47 // /\n || code === 95 // _\n || code === 43 // +\n || code === 42 // *\n || code === 38 // &\n || code === 36 // $\n || code === 35 // #\n}\n\nexport function isCustom(property) {\n if (property.length < 3) return false\n // 45 === '-'.charCodeAt(0)\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45\n}\n\nexport function isProperty(basename, property) {\n if (isCustom(property)) return false\n return endsWith(basename, property)\n}","import parse from 'css-tree/parser'\nimport walk from 'css-tree/walker'\nimport { calculate } from '@bramus/specificity/core'\nimport { isSupportsBrowserhack, isMediaBrowserhack } from './atrules/atrules.js'\nimport { getComplexity, isAccessibility, compareSpecificity } from './selectors/utils.js'\nimport { colorFunctions, colorKeywords, namedColors, systemColors } from './values/colors.js'\nimport { isFontFamilyKeyword, getFamilyFromFont } from './values/font-families.js'\nimport { isFontSizeKeyword, getSizeFromFont } from './values/font-sizes.js'\nimport { isValueKeyword } from './values/values.js'\nimport { analyzeAnimation } from './values/animations.js'\nimport { isAstVendorPrefixed } from './values/vendor-prefix.js'\nimport { ContextCollection } from './context-collection.js'\nimport { CountableCollection } from './countable-collection.js'\nimport { AggregateCollection } from './aggregate-collection.js'\nimport { strEquals, startsWith, endsWith } from './string-utils.js'\nimport { hasVendorPrefix } from './vendor-prefix.js'\nimport { isCustom, isHack, isProperty } from './properties/property-utils.js'\nimport { getEmbedType } from './stylesheet/stylesheet.js'\nimport { isIe9Hack } from './values/browserhacks.js'\n\nfunction ratio(part, total) {\n if (total === 0) return 0\n return part / total\n}\n\n/**\n * Analyze CSS\n * @param {string} css\n */\nconst analyze = (css) => {\n const start = Date.now()\n let lines = css.split(/\\r?\\n/g)\n\n /**\n * Recreate the authored CSS from a CSSTree node\n * @param {import('css-tree').CssNode} node - Node from CSSTree AST to stringify\n * @returns {string} str - The stringified node\n */\n function stringifyNode(node) {\n return stringifyNodePlain(node).trim()\n }\n\n function stringifyNodePlain(node) {\n return css.substring(node.loc.start.offset, node.loc.end.offset)\n }\n\n // Stylesheet\n let totalComments = 0\n let commentsSize = 0\n const embeds = new CountableCollection()\n let embedSize = 0\n const embedTypes = {\n total: 0,\n unique: new Map()\n }\n\n const startParse = Date.now()\n\n const ast = parse(css, {\n parseCustomProperty: true, // To find font-families, colors, etc.\n positions: true, // So we can use stringifyNode()\n onComment: function (comment) {\n totalComments++\n commentsSize += comment.length\n },\n })\n\n const startAnalysis = Date.now()\n\n // Atrules\n let totalAtRules = 0\n /** @type {string}[]} */\n const fontfaces = []\n const layers = new CountableCollection()\n const imports = new CountableCollection()\n const medias = new CountableCollection()\n const mediaBrowserhacks = new CountableCollection()\n const charsets = new CountableCollection()\n const supports = new CountableCollection()\n const supportsBrowserhacks = new CountableCollection()\n const keyframes = new CountableCollection()\n const prefixedKeyframes = new CountableCollection()\n const containers = new CountableCollection()\n\n // Rules\n let totalRules = 0\n let emptyRules = 0\n const ruleSizes = new AggregateCollection()\n const selectorsPerRule = new AggregateCollection()\n const declarationsPerRule = new AggregateCollection()\n\n // Selectors\n const keyframeSelectors = new CountableCollection()\n const uniqueSelectors = new Set()\n /** @type [number,number,number] */\n let maxSpecificity\n /** @type [number,number,number] */\n let minSpecificity\n const specificityA = new AggregateCollection()\n const specificityB = new AggregateCollection()\n const specificityC = new AggregateCollection()\n const uniqueSpecificities = new CountableCollection()\n const selectorComplexities = new AggregateCollection()\n /** @type [number,number,number][] */\n const specificities = []\n const ids = new CountableCollection()\n const a11y = new CountableCollection()\n\n // Declarations\n const uniqueDeclarations = new Set()\n let totalDeclarations = 0\n let importantDeclarations = 0\n let importantsInKeyframes = 0\n let importantCustomProperties = new CountableCollection()\n\n // Properties\n const properties = new CountableCollection()\n const propertyHacks = new CountableCollection()\n const propertyVendorPrefixes = new CountableCollection()\n const customProperties = new CountableCollection()\n const propertyComplexities = new AggregateCollection()\n\n // Values\n const vendorPrefixedValues = new CountableCollection()\n const valueBrowserhacks = new CountableCollection()\n const zindex = new CountableCollection()\n const textShadows = new CountableCollection()\n const boxShadows = new CountableCollection()\n const fontFamilies = new CountableCollection()\n const fontSizes = new CountableCollection()\n const lineHeights = new CountableCollection()\n const timingFunctions = new CountableCollection()\n const durations = new CountableCollection()\n const colors = new ContextCollection()\n const colorFormats = new CountableCollection()\n const units = new ContextCollection()\n\n walk(ast, function (node) {\n switch (node.type) {\n case 'Atrule': {\n totalAtRules++\n const atRuleName = node.name\n\n if (atRuleName === 'font-face') {\n /** @type {[index: string]: string} */\n const descriptors = {}\n\n node.block.children.forEach(\n /** @param {import('css-tree').Declaration} descriptor */\n descriptor => (descriptors[descriptor.property] = stringifyNode(descriptor.value))\n )\n\n fontfaces.push(descriptors)\n break\n }\n\n if (atRuleName === 'media') {\n const prelude = stringifyNode(node.prelude)\n medias.push(prelude)\n if (isMediaBrowserhack(node.prelude)) {\n mediaBrowserhacks.push(prelude)\n }\n break\n }\n if (atRuleName === 'supports') {\n const prelude = stringifyNode(node.prelude)\n supports.push(prelude)\n if (isSupportsBrowserhack(node.prelude)) {\n supportsBrowserhacks.push(prelude)\n }\n break\n }\n if (endsWith('keyframes', atRuleName)) {\n const name = '@' + atRuleName + ' ' + stringifyNode(node.prelude)\n if (hasVendorPrefix(atRuleName)) {\n prefixedKeyframes.push(name)\n }\n keyframes.push(name)\n break\n }\n if (atRuleName === 'import') {\n imports.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'charset') {\n charsets.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'container') {\n containers.push(stringifyNode(node.prelude))\n break\n }\n if (atRuleName === 'layer') {\n const prelude = stringifyNode(node.prelude)\n prelude\n .split(',')\n .forEach(name => layers.push(name.trim()))\n }\n break\n }\n case 'Rule': {\n const numSelectors = node.prelude.children ? node.prelude.children.size : 0\n const numDeclarations = node.block.children ? node.block.children.size : 0\n\n ruleSizes.push(numSelectors + numDeclarations)\n selectorsPerRule.push(numSelectors)\n declarationsPerRule.push(numDeclarations)\n\n totalRules++\n\n if (numDeclarations === 0) {\n emptyRules++\n }\n break\n }\n case 'Selector': {\n const selector = stringifyNode(node)\n\n if (this.atrule && endsWith('keyframes', this.atrule.name)) {\n keyframeSelectors.push(selector)\n return this.skip\n }\n\n const [{ value: specificityObj }] = calculate(node)\n const specificity = [specificityObj.a, specificityObj.b, specificityObj.c]\n\n if (specificity[0] > 0) {\n ids.push(selector)\n }\n\n if (isAccessibility(node)) {\n a11y.push(selector)\n }\n\n uniqueSelectors.add(selector)\n selectorComplexities.push(getComplexity(node))\n uniqueSpecificities.push(specificity[0] + ',' + specificity[1] + ',' + specificity[2])\n\n if (maxSpecificity === undefined) {\n maxSpecificity = specificity\n }\n\n if (minSpecificity === undefined) {\n minSpecificity = specificity\n }\n\n specificityA.push(specificity[0])\n specificityB.push(specificity[1])\n specificityC.push(specificity[2])\n\n if (minSpecificity !== undefined && compareSpecificity(minSpecificity, specificity) < 0) {\n minSpecificity = specificity\n }\n\n if (maxSpecificity !== undefined && compareSpecificity(maxSpecificity, specificity) > 0) {\n maxSpecificity = specificity\n }\n\n specificities.push(specificity)\n\n // Avoid deeper walking of selectors to not mess with\n // our specificity calculations in case of a selector\n // with :where() or :is() that contain SelectorLists\n // as children\n return this.skip\n }\n case 'Dimension': {\n if (!this.declaration) {\n break\n }\n\n if (endsWith('\\\\9', node.unit)) {\n units.push(node.unit.substring(0, node.unit.length - 2), this.declaration.property)\n } else {\n units.push(node.unit, this.declaration.property)\n }\n\n return this.skip\n }\n case 'Url': {\n if (startsWith('data:', node.value)) {\n var embed = node.value\n var size = embed.length\n var type = getEmbedType(embed)\n\n embedTypes.total++\n embedSize += size\n\n if (embedTypes.unique.has(type)) {\n let item = embedTypes.unique.get(type)\n item.count++\n item.size += size\n embedTypes.unique.set(type, item)\n } else {\n embedTypes.unique.set(type, {\n count: 1,\n size\n })\n }\n\n // @deprecated\n embeds.push(embed)\n }\n break\n }\n case 'Value': {\n if (isValueKeyword(node)) {\n break\n }\n\n const declaration = this.declaration\n const { property, important } = declaration\n\n if (isAstVendorPrefixed(node)) {\n vendorPrefixedValues.push(stringifyNode(node))\n }\n\n // i.e. `property: value !ie`\n if (typeof important === 'string') {\n valueBrowserhacks.push(stringifyNodePlain(node) + '!' + important)\n }\n\n // i.e. `property: value\\9`\n if (isIe9Hack(node)) {\n valueBrowserhacks.push(stringifyNode(node))\n }\n\n // Process properties first that don't have colors,\n // so we can avoid further walking them;\n if (isProperty('z-index', property)) {\n if (!isValueKeyword(node)) {\n zindex.push(stringifyNode(node))\n }\n return this.skip\n } else if (isProperty('font', property)) {\n if (!isFontFamilyKeyword(node)) {\n fontFamilies.push(getFamilyFromFont(node, stringifyNode))\n }\n if (!isFontSizeKeyword(node)) {\n const size = getSizeFromFont(node)\n if (size) {\n fontSizes.push(size)\n }\n }\n break\n } else if (isProperty('font-size', property)) {\n if (!isFontSizeKeyword(node)) {\n fontSizes.push(stringifyNode(node))\n }\n break\n } else if (isProperty('font-family', property)) {\n if (!isFontFamilyKeyword(node)) {\n fontFamilies.push(stringifyNode(node))\n }\n break\n } else if (isProperty('line-height', property)) {\n lineHeights.push((stringifyNode(node)))\n } else if (isProperty('transition', property) || isProperty('animation', property)) {\n const [times, fns] = analyzeAnimation(node.children, stringifyNode)\n for (let i = 0; i < times.length; i++) {\n durations.push(times[i])\n }\n for (let i = 0; i < fns.length; i++) {\n timingFunctions.push(fns[i])\n }\n break\n } else if (isProperty('animation-duration', property) || isProperty('transition-duration', property)) {\n durations.push(stringifyNode(node))\n break\n } else if (isProperty('transition-timing-function', property) || isProperty('animation-timing-function', property)) {\n timingFunctions.push(stringifyNode(node))\n break\n } else if (isProperty('text-shadow', property)) {\n if (!isValueKeyword(node)) {\n textShadows.push(stringifyNode(node))\n }\n // no break here: potentially contains colors\n } else if (isProperty('box-shadow', property)) {\n if (!isValueKeyword(node)) {\n boxShadows.push(stringifyNode(node))\n }\n // no break here: potentially contains colors\n }\n\n walk(node, function (valueNode) {\n switch (valueNode.type) {\n case 'Hash': {\n let hexLength = valueNode.value.length\n if (endsWith('\\\\9', valueNode.value)) {\n hexLength = hexLength - 2\n }\n colors.push('#' + valueNode.value, property)\n colorFormats.push(`hex` + hexLength)\n\n return this.skip\n }\n case 'Identifier': {\n const { name } = valueNode\n // Bail out if it can't be a color name\n // 20 === 'lightgoldenrodyellow'.length\n // 3 === 'red'.length\n if (name.length > 20 || name.length < 3) {\n return this.skip\n }\n const stringified = stringifyNode(valueNode)\n const lowerCased = name.toLowerCase()\n\n if (namedColors.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push('named')\n } else if (colorKeywords.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push(lowerCased)\n } else if (systemColors.has(lowerCased)) {\n colors.push(stringified, property)\n colorFormats.push('system')\n }\n return this.skip\n }\n case 'Function': {\n // Don't walk var() multiple times\n if (strEquals('var', valueNode.name)) {\n return this.skip\n }\n const fnName = valueNode.name.toLowerCase()\n const stringified = stringifyNode(valueNode)\n if (colorFunctions.has(fnName)) {\n colors.push(stringified, property)\n colorFormats.push(fnName)\n }\n // No this.skip here intentionally,\n // otherwise we'll miss colors in linear-gradient() etc.\n }\n }\n })\n break\n }\n case 'Declaration': {\n // Do not process Declarations in atRule preludes\n // because we will handle them manually\n if (this.atrulePrelude !== null) {\n return this.skip\n }\n\n totalDeclarations++\n\n uniqueDeclarations.add(stringifyNode(node))\n\n if (node.important === true) {\n importantDeclarations++\n\n if (this.atrule && endsWith('keyframes', this.atrule.name)) {\n importantsInKeyframes++\n }\n }\n\n const { property } = node\n\n properties.push(property)\n\n if (hasVendorPrefix(property)) {\n propertyVendorPrefixes.push(property)\n propertyComplexities.push(2)\n } else if (isHack(property)) {\n propertyHacks.push(property)\n propertyComplexities.push(2)\n } else if (isCustom(property)) {\n customProperties.push(property)\n propertyComplexities.push(2)\n if (node.important === true) {\n importantCustomProperties.push(property)\n }\n } else {\n propertyComplexities.push(1)\n }\n break\n }\n }\n })\n\n const embeddedContent = embeds.count()\n\n const totalUniqueDeclarations = uniqueDeclarations.size\n\n const totalSelectors = selectorComplexities.size()\n const specificitiesA = specificityA.aggregate()\n const specificitiesB = specificityB.aggregate()\n const specificitiesC = specificityC.aggregate()\n const uniqueSpecificitiesCount = uniqueSpecificities.count()\n const complexityCount = new CountableCollection(selectorComplexities.toArray()).count()\n const totalUniqueSelectors = uniqueSelectors.size\n const uniqueRuleSize = new CountableCollection(ruleSizes.toArray()).count()\n const uniqueSelectorsPerRule = new CountableCollection(selectorsPerRule.toArray()).count()\n const uniqueDeclarationsPerRule = new CountableCollection(declarationsPerRule.toArray()).count()\n const assign = Object.assign\n\n return {\n stylesheet: {\n sourceLinesOfCode: totalAtRules + totalSelectors + totalDeclarations + keyframeSelectors.size(),\n linesOfCode: lines.length,\n size: css.length,\n comments: {\n total: totalComments,\n size: commentsSize,\n },\n embeddedContent: assign(embeddedContent, {\n size: {\n total: embedSize,\n ratio: ratio(embedSize, css.length),\n },\n types: {\n total: embedTypes.total,\n totalUnique: embedTypes.unique.size,\n uniquenessRatio: ratio(embedTypes.unique.size, embedTypes.total),\n unique: Object.fromEntries(embedTypes.unique),\n },\n }),\n },\n atrules: {\n fontface: {\n total: fontfaces.length,\n totalUnique: fontfaces.length,\n unique: fontfaces,\n uniquenessRatio: fontfaces.length === 0 ? 0 : 1\n },\n import: imports.count(),\n media: assign(\n medias.count(),\n {\n browserhacks: mediaBrowserhacks.count(),\n }\n ),\n charset: charsets.count(),\n supports: assign(\n supports.count(),\n {\n browserhacks: supportsBrowserhacks.count(),\n },\n ),\n keyframes: assign(\n keyframes.count(), {\n prefixed: assign(\n prefixedKeyframes.count(), {\n ratio: ratio(prefixedKeyframes.size(), keyframes.size())\n }),\n }),\n container: containers.count(),\n layer: layers.count(),\n },\n rules: {\n total: totalRules,\n empty: {\n total: emptyRules,\n ratio: ratio(emptyRules, totalRules)\n },\n sizes: assign(\n ruleSizes.aggregate(),\n {\n items: ruleSizes.toArray(),\n unique: uniqueRuleSize.unique,\n totalUnique: uniqueRuleSize.totalUnique,\n uniquenessRatio: uniqueRuleSize.uniquenessRatio\n },\n ),\n selectors: assign(\n selectorsPerRule.aggregate(),\n {\n items: selectorsPerRule.toArray(),\n unique: uniqueSelectorsPerRule.unique,\n totalUnique: uniqueSelectorsPerRule.totalUnique,\n uniquenessRatio: uniqueSelectorsPerRule.uniquenessRatio\n },\n ),\n declarations: assign(\n declarationsPerRule.aggregate(),\n {\n items: declarationsPerRule.toArray(),\n unique: uniqueDeclarationsPerRule.unique,\n totalUnique: uniqueDeclarationsPerRule.totalUnique,\n uniquenessRatio: uniqueDeclarationsPerRule.uniquenessRatio,\n },\n ),\n },\n selectors: {\n total: totalSelectors,\n totalUnique: totalUniqueSelectors,\n uniquenessRatio: ratio(totalUniqueSelectors, totalSelectors),\n specificity: {\n /** @type [number, number, number] */\n min: minSpecificity === undefined ? [0, 0, 0] : minSpecificity,\n /** @type [number, number, number] */\n max: maxSpecificity === undefined ? [0, 0, 0] : maxSpecificity,\n /** @type [number, number, number] */\n sum: [specificitiesA.sum, specificitiesB.sum, specificitiesC.sum],\n /** @type [number, number, number] */\n mean: [specificitiesA.mean, specificitiesB.mean, specificitiesC.mean],\n /** @type [number, number, number] */\n mode: [specificitiesA.mode, specificitiesB.mode, specificitiesC.mode],\n /** @type [number, number, number] */\n median: [specificitiesA.median, specificitiesB.median, specificitiesC.median],\n items: specificities,\n unique: uniqueSpecificitiesCount.unique,\n totalUnique: uniqueSpecificitiesCount.totalUnique,\n uniquenessRatio: uniqueSpecificitiesCount.uniquenessRatio,\n },\n complexity: assign(\n selectorComplexities.aggregate(),\n complexityCount, {\n items: selectorComplexities.toArray(),\n }),\n id: assign(\n ids.count(), {\n ratio: ratio(ids.size(), totalSelectors),\n }),\n accessibility: assign(\n a11y.count(), {\n ratio: ratio(a11y.size(), totalSelectors),\n }),\n keyframes: keyframeSelectors.count(),\n },\n declarations: {\n total: totalDeclarations,\n totalUnique: totalUniqueDeclarations,\n uniquenessRatio: ratio(totalUniqueDeclarations, totalDeclarations),\n // @TODO: deprecated, remove in next major version\n unique: {\n total: totalUniqueDeclarations,\n ratio: ratio(totalUniqueDeclarations, totalDeclarations),\n },\n importants: {\n total: importantDeclarations,\n ratio: ratio(importantDeclarations, totalDeclarations),\n inKeyframes: {\n total: importantsInKeyframes,\n ratio: ratio(importantsInKeyframes, importantDeclarations),\n },\n },\n },\n properties: assign(\n properties.count(),\n {\n prefixed: assign(\n propertyVendorPrefixes.count(),\n {\n ratio: ratio(propertyVendorPrefixes.size(), properties.size()),\n },\n ),\n custom: assign(\n customProperties.count(),\n {\n ratio: ratio(customProperties.size(), properties.size()),\n importants: assign(\n importantCustomProperties.count(),\n {\n ratio: ratio(importantCustomProperties.size(), customProperties.size()),\n }\n ),\n },\n ),\n browserhacks: assign(\n propertyHacks.count(), {\n ratio: ratio(propertyHacks.size(), properties.size()),\n }),\n complexity: propertyComplexities.aggregate(),\n }),\n values: {\n colors: assign(\n colors.count(),\n {\n formats: colorFormats.count(),\n },\n ),\n fontFamilies: fontFamilies.count(),\n fontSizes: fontSizes.count(),\n lineHeights: lineHeights.count(),\n zindexes: zindex.count(),\n textShadows: textShadows.count(),\n boxShadows: boxShadows.count(),\n animations: {\n durations: durations.count(),\n timingFunctions: timingFunctions.count(),\n },\n prefixes: vendorPrefixedValues.count(),\n browserhacks: valueBrowserhacks.count(),\n units: units.count(),\n },\n __meta__: {\n parseTime: startAnalysis - startParse,\n analyzeTime: Date.now() - startAnalysis,\n total: Date.now() - start\n }\n }\n}\n\nexport {\n analyze,\n compareSpecificity,\n}\n","export function getEmbedType(/** @type string */embed) {\n\t// data:image/gif;base64,R0lG\n\tlet start = 5 // `data:`.length\n\tlet semicolon = embed.indexOf(';')\n\tlet comma = embed.indexOf(',')\n\n\tif (semicolon === -1) {\n\t\treturn embed.substring(start, comma)\n\t}\n\n\tif (comma !== -1 && comma < semicolon) {\n\t\treturn embed.substring(start, comma);\n\t}\n\n\treturn embed.substring(start, semicolon)\n}","import { endsWith } from \"../string-utils.js\"\n\nexport function isIe9Hack(node) {\n\treturn node.children\n\t\t&& node.children.last\n\t\t&& node.children.last.type === 'Identifier'\n\t\t&& endsWith('\\\\9', node.children.last.name)\n}"],"names":["compareChar","referenceCode","testCode","strEquals","base","test","length","i","charCodeAt","endsWith","offset","startsWith","isPropertyValue","node","property","value","children","first","type","name","hasVendorPrefix","keyword","indexOf","compareSpecificity","a","b","analyzeList","selectorListAst","cb","childSelectors","walk","visit","enter","push","isPseudoFunction","isAccessibility","selector","isA11y","some","skip","getComplexity","complexity","Boolean","list","forEach","c","namedColors","Set","systemColors","colorFunctions","colorKeywords","systemKeywords","keywordDisallowList","isFontFamilyKeyword","firstChild","has","sizeKeywords","keywords","isFontSizeKeyword","isValueKeyword","size","timingKeywords","isAstVendorPrefixed","toArray","index","CountableCollection","initial","this","_items","Map","_total","item","set","get","count","total","totalUnique","unique","Object","fromEntries","uniquenessRatio","ContextCollection","_list","_contexts","context","itemsPerContext","entries","assign","AggregateCollection","_sum","aggregate","min","max","mean","mode","median","range","sum","arr","middle","lowerMiddleRank","sorted","slice","sort","frequencies","maxOccurrences","maxOccurenceCount","element","updatedCount","Mode","Math","floor","isCustom","isProperty","basename","ratio","part","css","start","Date","now","lines","split","stringifyNode","stringifyNodePlain","trim","substring","loc","end","maxSpecificity","minSpecificity","totalComments","commentsSize","embeds","embedSize","embedTypes","startParse","ast","parse","parseCustomProperty","positions","onComment","comment","startAnalysis","totalAtRules","fontfaces","layers","imports","medias","mediaBrowserhacks","charsets","supports","supportsBrowserhacks","keyframes","prefixedKeyframes","containers","totalRules","emptyRules","ruleSizes","selectorsPerRule","declarationsPerRule","keyframeSelectors","uniqueSelectors","specificityA","specificityB","specificityC","uniqueSpecificities","selectorComplexities","specificities","ids","a11y","uniqueDeclarations","totalDeclarations","importantDeclarations","importantsInKeyframes","importantCustomProperties","properties","propertyHacks","propertyVendorPrefixes","customProperties","propertyComplexities","vendorPrefixedValues","valueBrowserhacks","zindex","textShadows","boxShadows","fontFamilies","fontSizes","lineHeights","timingFunctions","durations","colors","colorFormats","units","atRuleName","descriptors","block","descriptor","prelude","returnValue","unit","isMediaBrowserhack","isSupportsBrowserhack","numSelectors","numDeclarations","atrule","specificityObj","calculate","specificity","add","undefined","declaration","embed","semicolon","comma","getEmbedType","important","last","isIe9Hack","parts","reverse","fontNode","quote","getFamilyFromFont","operator","getSizeFromFont","durationFound","child","analyzeAnimation","times","fns","valueNode","hexLength","stringified","lowerCased","toLowerCase","fnName","atrulePrelude","code","isHack","embeddedContent","totalUniqueDeclarations","totalSelectors","specificitiesA","specificitiesB","specificitiesC","uniqueSpecificitiesCount","complexityCount","totalUniqueSelectors","uniqueRuleSize","uniqueSelectorsPerRule","uniqueDeclarationsPerRule","stylesheet","sourceLinesOfCode","linesOfCode","comments","types","atrules","fontface","import","media","browserhacks","charset","prefixed","container","layer","rules","empty","sizes","items","selectors","declarations","id","accessibility","importants","inKeyframes","custom","values","formats","zindexes","animations","prefixes","__meta__","parseTime","analyzeTime"],"mappings":"wNAMA,SAASA,EAAYC,EAAeC,GAMlC,OAJIA,GAAY,IAAUA,GAAY,KAEpCA,GAAsB,IAEjBD,IAAkBC,CAC1B,UAQeC,EAAUC,EAAMC,GAC9B,GAAID,EAAKE,SAAWD,EAAKC,OAAQ,SAEjC,IAAK,IAAIC,EAAI,EAAGA,EAAIH,EAAKE,OAAQC,IAC/B,IAA4D,IAAxDP,EAAYI,EAAKI,WAAWD,GAAIF,EAAKG,WAAWD,IAClD,SAIJ,QACD,UAQeE,EAASL,EAAMC,GAC7B,IAAMK,EAASL,EAAKC,OAASF,E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ACA,UACA,aACA,YACA,cACA,cACA,UACA,YACA,aACA,OACA,YACA,OACA,QACA,cACA,OACA,WACA,UACA,YACA,SACA,QACA,QACA,WACA,gBACA,YACA,eACA,YACA,aACA,YACA,uBACA,YACA,aACA,YACA,YACA,cACA,gBACA,eACA,iBACA,iBACA,iBACA,cACA,OACA,YACA,QACA,UACA,SACA,mBACA,aACA,eACA,eACA,iBACA,kBACA,oBACA,kBACA,kBACA,eACA,YACA,YACA,WACA,cACA,OACA,UACA,QACA,YACA,SACA,YACA,SACA,gBACA,YACA,gBACA,gBACA,aACA,YACA,OACA,OACA,OACA,aACA,SACA,gBACA,MACA,YACA,YACA,cACA,SACA,aACA,WACA,WACA,SACA,SACA,UACA,YACA,YACA,YACA,OACA,cACA,YACA,MACA,OACA,UACA,SACA,YACA,SACA,QACA,QACA,aACA,SACA,gBAGWC,EAAe,IAAID,IAAI,CAGlC,SACA,aACA,WACA,cACA,aACA,aACA,aACA,eACA,QACA,YACA,YACA,gBACA,eACA,mBACA,OACA,WACA,aAMWE,EAAiB,IAAIF,IAAI,CACpC,MACA,OACA,MACA,OACA,MACA,MACA,MACA,QACA,QACA,UAGWG,EAAgB,IAAIH,IAAI,CACnC,eACA,gBC/LII,EAAiB,IAAIJ,IAAI,CAE7B,UACA,UACA,QACA,SAGA,UACA,OACA,OACA,cACA,gBACA,eAGIK,EAAsB,IAAIL,IAAI,CAElC,SAGA,WACA,UACA,QACA,SACA,QACA,UACA,WACA,SACA,UAGA,OACA,SACA,UAGA,kBACA,kBACA,YACA,iBACA,gBACA,WACA,iBACA,iBAGA,SACA,qBAKcM,EAAoBxC,GAClC,IAAMyC,EAAazC,EAAKG,SAASC,MACjC,MAA2B,eAApBqC,EAAWpC,MAAyBiC,EAAeI,IAAID,EAAWnC,KAC1E,CCxDD,IAAMqC,EAAe,IAAIT,IAAI,CAC3B,WACA,UACA,QACA,SACA,QACA,UACA,WACA,SACA,YAGIU,EAAW,IAAIV,IAAI,CAEvB,UACA,UACA,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AAOrH,QACP,CACE4M,QAAStF,GAAatH,UAG1BgH,aAAcA,GAAahH,QAC3BiH,UAAWA,GAAUjH,QACrBkH,YAAaA,GAAYlH,QACzB6M,SAAUhG,GAAO7G,QACjB8G,YAAaA,GAAY9G,QACzB+G,WAAYA,GAAW/G,QACvB8M,WAAY,CACV1F,UAAWA,GAAUpH,QACrBmH,gBAAiBA,GAAgBnH,SAEnC+M,SAAUpG,GAAqB3G,QAC/B2L,aAAc/E,GAAkB5G,QAChCuH,MAAOA,GAAMvH,SAEfgN,SAAU,CACRC,UAAW5I,EAAgBP,EAC3BoJ,YAAarK,KAAKC,MAAQuB,EAC1BpE,MAAO4C,KAAKC,MAAQF,GAGzB"}
|
package/dist/analyzer.modern.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"css-tree/parser";import t from"css-tree/walker";import{calculate as n}from"@bramus/specificity/core";function i(e,t){return t>=65&&t<=90&&(t|=32),e===t}function r(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!1===i(e.charCodeAt(n),t.charCodeAt(n)))return!1;return!0}function a(e,t){const n=t.length-e.length;if(n<0)return!1;for(let r=t.length-1;r>=n;r--)if(!1===i(e.charCodeAt(r-n),t.charCodeAt(r)))return!1;return!0}function o(e,t){if(t.length<e.length)return!1;for(let n=0;n<e.length;n++)if(!1===i(e.charCodeAt(n),t.charCodeAt(n)))return!1;return!0}function s(e,t,n){return r(t,e.property)&&"Identifier"===e.value.children.first.type&&r(n,e.value.children.first.name)}function u(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function l(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function c(e,n){const i=[];return t(e,{visit:"Selector",enter:function(e){i.push(n(e))}}),i}function f(e){return r(e,"not")||r(e,"nth-child")||r(e,"nth-last-child")||r(e,"where")||r(e,"is")||r(e,"has")||r(e,"matches")||r(e,"-webkit-any")||r(e,"-moz-any")}function d(e){let n=!1;return t(e,function(e){if("AttributeSelector"==e.type){if(r("role",e.name.name)||o("aria-",e.name.name))return n=!0,this.break}else if("PseudoClassSelector"==e.type&&f(e.name))return c(e,d).some(e=>1==e)?(n=!0,this.skip):this.skip}),n}function m(e){let n=0;return t(e,function(e){if("Selector"!=e.type&&"Nth"!=e.type){if(n++,"IdSelector"!=e.type&&"ClassSelector"!=e.type&&"PseudoElementSelector"!=e.type&&"TypeSelector"!=e.type&&"PseudoClassSelector"!=e.type||u(e.name)&&n++,"AttributeSelector"==e.type)return Boolean(e.value)&&n++,u(e.name.name)&&n++,this.skip;if("PseudoClassSelector"==e.type&&f(e.name)){const t=c(e,m);if(0===t.length)return;return t.forEach(e=>n+=e),this.skip}}}),n}const h=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),w=new Set(["canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext"]),b=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color"]),g=new Set(["currentcolor","transparent"]),p=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]),k=new Set(["normal","xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller","bold","bolder","lighter","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","italic","oblique"]);function y(e){const t=e.children.first;return"Identifier"===t.type&&p.has(t.name)}const x=new Set(["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]),q=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]);function v(e){const t=e.children.first;return"Identifier"===t.type&&q.has(t.name)}const S=new Set(["auto","inherit","initial","unset","revert","none"]);function z(e){if(!e.children)return!1;const t=e.children.first;return!!t&&!(e.children.size>1)&&"Identifier"===t.type&&S.has(t.name)}const I=new Set(["linear","ease","ease-in","ease-out","ease-in-out","step-start","step-end"]);function C(e){if(!e.children)return!1;const t=e.children.toArray();for(let e=0;e<t.length;e++){const n=t[e],{type:i,name:r}=n;if("Identifier"===i&&u(r))return!0;if("Function"===i){if(u(r))return!0;if(C(n))return!0}}return!1}class D{constructor(e){if(this.t=new Map,this.i=0,e)for(let t=0;t<e.length;t++)this.push(e[t])}push(e){this.i++,this.t.has(e)?this.t.set(e,this.t.get(e)+1):this.t.set(e,1)}size(){return this.i}count(){return{total:this.i,totalUnique:this.t.size,unique:Object.fromEntries(this.t),uniquenessRatio:0===this.i?0:this.t.size/this.i}}}class O{constructor(){this.o=new D,this.u=new Map}push(e,t){this.o.push(e),this.u.has(t)||this.u.set(t,new D),this.u.get(t).push(e)}count(){const e=new Map;for(let[t,n]of this.u.entries())e.set(t,n.count());return Object.assign(this.o.count(),{itemsPerContext:Object.fromEntries(e)})}}class R{constructor(){this.t=[],this.l=0}push(e){this.t.push(e),this.l+=e}size(){return this.t.length}aggregate(){if(0===this.t.length)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};const e=this.t.slice().sort((e,t)=>e-t),t=e[0],n=e[e.length-1],i=function(e){const t=new Map;let n=-1,i=0,r=0;for(let a=0;a<e.length;a++){const o=e[a],s=(t.get(o)||0)+1;t.set(o,s),s>n&&(n=s,i=0,r=0),s>=n&&(i++,r+=o)}return r/i}(e),r=function(e){const t=e.length/2,n=Math.floor(t);return t!==n?e[n]:(e[n]+e[n-1])/2}(e);return{min:t,max:n,mean:this.l/e.length,mode:i,median:r,range:n-t,sum:this.l}}toArray(){return this.t}}function U(e){return!(e.length<3)&&45===e.charCodeAt(0)&&45===e.charCodeAt(1)}function M(e,t){return!U(t)&&a(e,t)}function j(e,t){return 0===t?0:e/t}const F=i=>{const c=Date.now();let f=i.split(/\r?\n/g);function p(e){return i.substring(e.loc.start.offset,e.loc.end.offset)}let q=0,S=0;const F=new D;let P=0;const A={total:0,unique:new Map},_=Date.now(),T=e(i,{parseCustomProperty:!0,positions:!0,onComment:function(e){q++,S+=e.length}}),N=Date.now();let B=0;const E=[],H=new D,K=new D,L=new D,Q=new D,V=new D,G=new D,J=new D,W=new D,X=new D,Y=new D;let Z=0,$=0;const ee=new R,te=new R,ne=new R,ie=new D,re=new Set;let ae,oe;const se=new R,ue=new R,le=new R,ce=new D,fe=new R,de=[],me=new D,he=new D,we=new Set;let be=0,ge=0,pe=0,ke=new D;const ye=new D,xe=new D,qe=new D,ve=new D,Se=new R,ze=new D,Ie=new D,Ce=new D,De=new D,Oe=new D,Re=new D,Ue=new D,Me=new D,je=new D,Fe=new O,Pe=new D,Ae=new O;t(T,function(e){switch(e.type){case"Atrule":{B++;const n=e.name;if("font-face"===n){const t={};e.block.children.forEach(e=>t[e.property]=p(e.value)),E.push(t);break}if("media"===n){const n=p(e.prelude).trim();L.push(n),function(e){let n=!1;return t(e,function(e){if("MediaQuery"===e.type&&1===e.children.size&&"Identifier"===e.children.first.type&&(o("\\0",(e=e.children.first).name)||a("\\9 ",e.name)))return n=!0,this.break;if("MediaFeature"===e.type){if(null!==e.value&&"\\0"===e.value.unit)return n=!0,this.break;if(r("-moz-images-in-menus",e.name)||r("min--moz-device-pixel-ratio",e.name)||r("-ms-high-contrast",e.name))return n=!0,this.break;if(r("min-resolution",e.name)&&r(".001",e.value.value)&&r("dpcm",e.value.unit))return n=!0,this.break;if(r("-webkit-min-device-pixel-ratio",e.name)&&(r("0",e.value.value)||r("10000",e.value.value)))return n=!0,this.break}}),n}(e.prelude)&&Q.push(n);break}if("supports"===n){const n=p(e.prelude);G.push(n),function(e){let n=!1;return t(e,function(e){if("Declaration"===e.type&&(s(e,"-webkit-appearance","none")||s(e,"-moz-appearance","meterbar")))return n=!0,this.break}),n}(e.prelude)&&J.push(n);break}if(a("keyframes",n)){const t="@"+n+" "+p(e.prelude);u(n)&&X.push(t),W.push(t);break}if("import"===n){K.push(p(e.prelude));break}if("charset"===n){V.push(p(e.prelude));break}if("container"===n){Y.push(p(e.prelude));break}"layer"===n&&p(e.prelude).trim().split(",").forEach(e=>H.push(e.trim()));break}case"Rule":{const t=e.prelude.children?e.prelude.children.size:0,n=e.block.children?e.block.children.size:0;ee.push(t+n),te.push(t),ne.push(n),Z++,0===n&&$++;break}case"Selector":{const t=p(e);if(this.atrule&&a("keyframes",this.atrule.name))return ie.push(t),this.skip;const[{value:i}]=n(e),r=[i.a,i.b,i.c];return r[0]>0&&me.push(t),d(e)&&he.push(t),re.add(t),fe.push(m(e)),ce.push(r[0]+","+r[1]+","+r[2]),void 0===ae&&(ae=r),void 0===oe&&(oe=r),se.push(r[0]),ue.push(r[1]),le.push(r[2]),void 0!==oe&&l(oe,r)<0&&(oe=r),void 0!==ae&&l(ae,r)>0&&(ae=r),de.push(r),this.skip}case"Dimension":if(!this.declaration)break;return a("\\9",e.unit)?Ae.push(e.unit.substring(0,e.unit.length-2),this.declaration.property):Ae.push(e.unit,this.declaration.property),this.skip;case"Url":if(o("data:",e.value)){var i=e.value,c=i.length,f=function(e){let t=e.indexOf(";"),n=e.indexOf(",");return e.substring(5,-1===t||-1!==n&&n<t?n:t)}(i);if(A.total++,P+=c,A.unique.has(f)){let e=A.unique.get(f);e.count++,e.size+=c,A.unique.set(f,e)}else A.unique.set(f,{count:1,size:c});F.push(i)}break;case"Value":{if(z(e))break;const n=this.declaration,{property:i,important:o}=n;if(C(e)&&ze.push(p(e)),"string"==typeof o&&Ie.push(p(e)+"!"+o),function(e){return e.children&&e.children.last&&"Identifier"===e.children.last.type&&a("\\9",e.children.last.name)}(e)&&Ie.push(p(e)),M("z-index",i))return z(e)||Ce.push(p(e)),this.skip;if(M("font",i)){if(y(e)||Re.push(function(e,n){let i="";return t(e,{reverse:!0,enter:function(e){if("String"===e.type){const t=e.loc.start.offset,r=n({loc:{start:{offset:t},end:{offset:t+1}}});return i=r+e.value+r+i}return"Operator"===e.type&&44===e.value.charCodeAt(0)?i=e.value+i:"Identifier"===e.type?k.has(e.name)?this.skip:i=e.name+i:void 0}}),i}(e,p)),!v(e)){const n=function(e){let n,i=!1;return t(e,function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return n="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(i=!0);break;case"Dimension":if(!i)return n=e.value+e.unit,this.break;case"Identifier":if(x.has(e.name))return n=e.name,this.break}}),n}(e);n&&Ue.push(n)}break}if(M("font-size",i)){v(e)||Ue.push(p(e));break}if(M("font-family",i)){y(e)||Re.push(p(e));break}if(M("transition",i)||M("animation",i)){const[t,n]=function(e,t){let n=!1;const i=[],r=[];return e.forEach(e=>"Operator"===e.type?n=!1:"Dimension"===e.type&&!1===n?(n=!0,i.push(t(e))):"Identifier"===e.type&&I.has(e.name)?r.push(t(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:r.push(t(e))),[i,r]}(e.children,p);for(let e=0;e<t.length;e++)je.push(t[e]);for(let e=0;e<n.length;e++)Me.push(n[e]);break}if(M("animation-duration",i)||M("transition-duration",i)){je.push(p(e));break}if(M("transition-timing-function",i)||M("animation-timing-function",i)){Me.push(p(e));break}M("text-shadow",i)?z(e)||De.push(p(e)):M("box-shadow",i)&&(z(e)||Oe.push(p(e))),t(e,function(e){switch(e.type){case"Hash":{let t=e.value.length;return a("\\9",e.value)&&(t-=2),Fe.push("#"+e.value,i),Pe.push("hex"+t),this.skip}case"Identifier":{const{name:t}=e;if(t.length>20||t.length<3)return this.skip;const n=p(e),r=t.toLowerCase();return h.has(r)?(Fe.push(n,i),Pe.push("named")):g.has(r)?(Fe.push(n,i),Pe.push(r)):w.has(r)&&(Fe.push(n,i),Pe.push("system")),this.skip}case"Function":{if(r("var",e.name))return this.skip;const t=e.name.toLowerCase(),n=p(e);b.has(t)&&(Fe.push(n,i),Pe.push(t))}}});break}case"Declaration":{if(null!==this.atrulePrelude)return this.skip;be++,we.add(p(e)),!0===e.important&&(ge++,this.atrule&&a("keyframes",this.atrule.name)&&pe++);const{property:t}=e;ye.push(t),u(t)?(qe.push(t),Se.push(2)):function(e){if(U(e)||u(e))return!1;let t=e.charCodeAt(0);return 47===t||95===t||43===t||42===t||38===t||36===t||35===t}(t)?(xe.push(t),Se.push(2)):U(t)?(ve.push(t),Se.push(2),!0===e.important&&ke.push(t)):Se.push(1);break}}});const _e=F.count(),Te=we.size,Ne=fe.size(),Be=se.aggregate(),Ee=ue.aggregate(),He=le.aggregate(),Ke=ce.count(),Le=new D(fe.toArray()).count(),Qe=re.size,Ve=new D(ee.toArray()).count(),Ge=new D(te.toArray()).count(),Je=new D(ne.toArray()).count(),We=Object.assign;return{stylesheet:{sourceLinesOfCode:B+Ne+be+ie.size(),linesOfCode:f.length,size:i.length,comments:{total:q,size:S},embeddedContent:We(_e,{size:{total:P,ratio:j(P,i.length)},types:{total:A.total,totalUnique:A.unique.size,uniquenessRatio:j(A.unique.size,A.total),unique:Object.fromEntries(A.unique)}})},atrules:{fontface:{total:E.length,totalUnique:E.length,unique:E,uniquenessRatio:0===E.length?0:1},import:K.count(),media:We(L.count(),{browserhacks:Q.count()}),charset:V.count(),supports:We(G.count(),{browserhacks:J.count()}),keyframes:We(W.count(),{prefixed:We(X.count(),{ratio:j(X.size(),W.size())})}),container:Y.count(),layer:H.count()},rules:{total:Z,empty:{total:$,ratio:j($,Z)},sizes:We(ee.aggregate(),{items:ee.toArray(),unique:Ve.unique,totalUnique:Ve.totalUnique,uniquenessRatio:Ve.uniquenessRatio}),selectors:We(te.aggregate(),{items:te.toArray(),unique:Ge.unique,totalUnique:Ge.totalUnique,uniquenessRatio:Ge.uniquenessRatio}),declarations:We(ne.aggregate(),{items:ne.toArray(),unique:Je.unique,totalUnique:Je.totalUnique,uniquenessRatio:Je.uniquenessRatio})},selectors:{total:Ne,totalUnique:Qe,uniquenessRatio:j(Qe,Ne),specificity:{min:void 0===oe?[0,0,0]:oe,max:void 0===ae?[0,0,0]:ae,sum:[Be.sum,Ee.sum,He.sum],mean:[Be.mean,Ee.mean,He.mean],mode:[Be.mode,Ee.mode,He.mode],median:[Be.median,Ee.median,He.median],items:de,unique:Ke.unique,totalUnique:Ke.totalUnique,uniquenessRatio:Ke.uniquenessRatio},complexity:We(fe.aggregate(),Le,{items:fe.toArray()}),id:We(me.count(),{ratio:j(me.size(),Ne)}),accessibility:We(he.count(),{ratio:j(he.size(),Ne)}),keyframes:ie.count()},declarations:{total:be,totalUnique:Te,uniquenessRatio:j(Te,be),unique:{total:Te,ratio:j(Te,be)},importants:{total:ge,ratio:j(ge,be),inKeyframes:{total:pe,ratio:j(pe,ge)}}},properties:We(ye.count(),{prefixed:We(qe.count(),{ratio:j(qe.size(),ye.size())}),custom:We(ve.count(),{ratio:j(ve.size(),ye.size()),importants:We(ke.count(),{ratio:j(ke.size(),ve.size())})}),browserhacks:We(xe.count(),{ratio:j(xe.size(),ye.size())}),complexity:Se.aggregate()}),values:{colors:We(Fe.count(),{formats:Pe.count()}),fontFamilies:Re.count(),fontSizes:Ue.count(),zindexes:Ce.count(),textShadows:De.count(),boxShadows:Oe.count(),animations:{durations:je.count(),timingFunctions:Me.count()},prefixes:ze.count(),browserhacks:Ie.count(),units:Ae.count()},__meta__:{parseTime:N-_,analyzeTime:Date.now()-N,total:Date.now()-c}}};export{F as analyze,l as compareSpecificity};
|
|
1
|
+
import e from"css-tree/parser";import t from"css-tree/walker";import{calculate as n}from"@bramus/specificity/core";function i(e,t){return t>=65&&t<=90&&(t|=32),e===t}function r(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!1===i(e.charCodeAt(n),t.charCodeAt(n)))return!1;return!0}function o(e,t){const n=t.length-e.length;if(n<0)return!1;for(let r=t.length-1;r>=n;r--)if(!1===i(e.charCodeAt(r-n),t.charCodeAt(r)))return!1;return!0}function a(e,t){if(t.length<e.length)return!1;for(let n=0;n<e.length;n++)if(!1===i(e.charCodeAt(n),t.charCodeAt(n)))return!1;return!0}function s(e,t,n){return r(t,e.property)&&"Identifier"===e.value.children.first.type&&r(n,e.value.children.first.name)}function u(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function l(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function c(e,n){const i=[];return t(e,{visit:"Selector",enter:function(e){i.push(n(e))}}),i}function f(e){return r(e,"not")||r(e,"nth-child")||r(e,"nth-last-child")||r(e,"where")||r(e,"is")||r(e,"has")||r(e,"matches")||r(e,"-webkit-any")||r(e,"-moz-any")}function d(e){let n=!1;return t(e,function(e){if("AttributeSelector"==e.type){if(r("role",e.name.name)||a("aria-",e.name.name))return n=!0,this.break}else if("PseudoClassSelector"==e.type&&f(e.name))return c(e,d).some(e=>1==e)?(n=!0,this.skip):this.skip}),n}function h(e){let n=0;return t(e,function(e){if("Selector"!=e.type&&"Nth"!=e.type){if(n++,"IdSelector"!=e.type&&"ClassSelector"!=e.type&&"PseudoElementSelector"!=e.type&&"TypeSelector"!=e.type&&"PseudoClassSelector"!=e.type||u(e.name)&&n++,"AttributeSelector"==e.type)return Boolean(e.value)&&n++,u(e.name.name)&&n++,this.skip;if("PseudoClassSelector"==e.type&&f(e.name)){const t=c(e,h);if(0===t.length)return;return t.forEach(e=>n+=e),this.skip}}}),n}const m=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),w=new Set(["canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext"]),g=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color"]),b=new Set(["currentcolor","transparent"]),p=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]),k=new Set(["normal","xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller","bold","bolder","lighter","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","italic","oblique"]);function y(e){const t=e.children.first;return"Identifier"===t.type&&p.has(t.name)}const x=new Set(["xx-small","x-small","small","medium","large","x-large","xx-large","larger","smaller"]),q=new Set(["inherit","initial","unset","revert","caption","icon","menu","message-box","small-caption","status-bar"]);function v(e){const t=e.children.first;return"Identifier"===t.type&&q.has(t.name)}const S=new Set(["auto","inherit","initial","unset","revert","none"]);function z(e){if(!e.children)return!1;const t=e.children.first;return!!t&&!(e.children.size>1)&&"Identifier"===t.type&&S.has(t.name)}const I=new Set(["linear","ease","ease-in","ease-out","ease-in-out","step-start","step-end"]);function C(e){if(!e.children)return!1;const t=e.children.toArray();for(let e=0;e<t.length;e++){const n=t[e],{type:i,name:r}=n;if("Identifier"===i&&u(r))return!0;if("Function"===i){if(u(r))return!0;if(C(n))return!0}}return!1}class D{constructor(e){if(this.t=new Map,this.i=0,e)for(let t=0;t<e.length;t++)this.push(e[t])}push(e){this.i++,this.t.has(e)?this.t.set(e,this.t.get(e)+1):this.t.set(e,1)}size(){return this.i}count(){return{total:this.i,totalUnique:this.t.size,unique:Object.fromEntries(this.t),uniquenessRatio:0===this.i?0:this.t.size/this.i}}}class O{constructor(){this.o=new D,this.u=new Map}push(e,t){this.o.push(e),this.u.has(t)||this.u.set(t,new D),this.u.get(t).push(e)}count(){const e=new Map;for(let[t,n]of this.u.entries())e.set(t,n.count());return Object.assign(this.o.count(),{itemsPerContext:Object.fromEntries(e)})}}class R{constructor(){this.t=[],this.l=0}push(e){this.t.push(e),this.l+=e}size(){return this.t.length}aggregate(){if(0===this.t.length)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};const e=this.t.slice().sort((e,t)=>e-t),t=e[0],n=e[e.length-1],i=function(e){const t=new Map;let n=-1,i=0,r=0;for(let o=0;o<e.length;o++){const a=e[o],s=(t.get(a)||0)+1;t.set(a,s),s>n&&(n=s,i=0,r=0),s>=n&&(i++,r+=a)}return r/i}(e),r=function(e){const t=e.length/2,n=Math.floor(t);return t!==n?e[n]:(e[n]+e[n-1])/2}(e);return{min:t,max:n,mean:this.l/e.length,mode:i,median:r,range:n-t,sum:this.l}}toArray(){return this.t}}function U(e){return!(e.length<3)&&45===e.charCodeAt(0)&&45===e.charCodeAt(1)}function M(e,t){return!U(t)&&o(e,t)}function j(e,t){return 0===t?0:e/t}const F=i=>{const c=Date.now();let f=i.split(/\r?\n/g);function p(e){return q(e).trim()}function q(e){return i.substring(e.loc.start.offset,e.loc.end.offset)}let S=0,F=0;const P=new D;let A=0;const _={total:0,unique:new Map},T=Date.now(),H=e(i,{parseCustomProperty:!0,positions:!0,onComment:function(e){S++,F+=e.length}}),N=Date.now();let B=0;const E=[],K=new D,L=new D,Q=new D,V=new D,G=new D,J=new D,W=new D,X=new D,Y=new D,Z=new D;let $=0,ee=0;const te=new R,ne=new R,ie=new R,re=new D,oe=new Set;let ae,se;const ue=new R,le=new R,ce=new R,fe=new D,de=new R,he=[],me=new D,we=new D,ge=new Set;let be=0,pe=0,ke=0,ye=new D;const xe=new D,qe=new D,ve=new D,Se=new D,ze=new R,Ie=new D,Ce=new D,De=new D,Oe=new D,Re=new D,Ue=new D,Me=new D,je=new D,Fe=new D,Pe=new D,Ae=new O,_e=new D,Te=new O;t(H,function(e){switch(e.type){case"Atrule":{B++;const n=e.name;if("font-face"===n){const t={};e.block.children.forEach(e=>t[e.property]=p(e.value)),E.push(t);break}if("media"===n){const n=p(e.prelude);Q.push(n),function(e){let n=!1;return t(e,function(e){if("MediaQuery"===e.type&&1===e.children.size&&"Identifier"===e.children.first.type&&(a("\\0",(e=e.children.first).name)||o("\\9 ",e.name)))return n=!0,this.break;if("MediaFeature"===e.type){if(null!==e.value&&"\\0"===e.value.unit)return n=!0,this.break;if(r("-moz-images-in-menus",e.name)||r("min--moz-device-pixel-ratio",e.name)||r("-ms-high-contrast",e.name))return n=!0,this.break;if(r("min-resolution",e.name)&&r(".001",e.value.value)&&r("dpcm",e.value.unit))return n=!0,this.break;if(r("-webkit-min-device-pixel-ratio",e.name)&&(r("0",e.value.value)||r("10000",e.value.value)))return n=!0,this.break}}),n}(e.prelude)&&V.push(n);break}if("supports"===n){const n=p(e.prelude);J.push(n),function(e){let n=!1;return t(e,function(e){if("Declaration"===e.type&&(s(e,"-webkit-appearance","none")||s(e,"-moz-appearance","meterbar")))return n=!0,this.break}),n}(e.prelude)&&W.push(n);break}if(o("keyframes",n)){const t="@"+n+" "+p(e.prelude);u(n)&&Y.push(t),X.push(t);break}if("import"===n){L.push(p(e.prelude));break}if("charset"===n){G.push(p(e.prelude));break}if("container"===n){Z.push(p(e.prelude));break}"layer"===n&&p(e.prelude).split(",").forEach(e=>K.push(e.trim()));break}case"Rule":{const t=e.prelude.children?e.prelude.children.size:0,n=e.block.children?e.block.children.size:0;te.push(t+n),ne.push(t),ie.push(n),$++,0===n&&ee++;break}case"Selector":{const t=p(e);if(this.atrule&&o("keyframes",this.atrule.name))return re.push(t),this.skip;const[{value:i}]=n(e),r=[i.a,i.b,i.c];return r[0]>0&&me.push(t),d(e)&&we.push(t),oe.add(t),de.push(h(e)),fe.push(r[0]+","+r[1]+","+r[2]),void 0===ae&&(ae=r),void 0===se&&(se=r),ue.push(r[0]),le.push(r[1]),ce.push(r[2]),void 0!==se&&l(se,r)<0&&(se=r),void 0!==ae&&l(ae,r)>0&&(ae=r),he.push(r),this.skip}case"Dimension":if(!this.declaration)break;return o("\\9",e.unit)?Te.push(e.unit.substring(0,e.unit.length-2),this.declaration.property):Te.push(e.unit,this.declaration.property),this.skip;case"Url":if(a("data:",e.value)){var i=e.value,c=i.length,f=function(e){let t=e.indexOf(";"),n=e.indexOf(",");return e.substring(5,-1===t||-1!==n&&n<t?n:t)}(i);if(_.total++,A+=c,_.unique.has(f)){let e=_.unique.get(f);e.count++,e.size+=c,_.unique.set(f,e)}else _.unique.set(f,{count:1,size:c});P.push(i)}break;case"Value":{if(z(e))break;const n=this.declaration,{property:i,important:a}=n;if(C(e)&&Ie.push(p(e)),"string"==typeof a&&Ce.push(q(e)+"!"+a),function(e){return e.children&&e.children.last&&"Identifier"===e.children.last.type&&o("\\9",e.children.last.name)}(e)&&Ce.push(p(e)),M("z-index",i))return z(e)||De.push(p(e)),this.skip;if(M("font",i)){if(y(e)||Ue.push(function(e,n){let i="";return t(e,{reverse:!0,enter:function(e){if("String"===e.type){const t=e.loc.start.offset,r=n({loc:{start:{offset:t},end:{offset:t+1}}});return i=r+e.value+r+i}return"Operator"===e.type&&44===e.value.charCodeAt(0)?i=e.value+i:"Identifier"===e.type?k.has(e.name)?this.skip:i=e.name+i:void 0}}),i}(e,p)),!v(e)){const n=function(e){let n,i=!1;return t(e,function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return n="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(i=!0);break;case"Dimension":if(!i)return n=e.value+e.unit,this.break;case"Identifier":if(x.has(e.name))return n=e.name,this.break}}),n}(e);n&&Me.push(n)}break}if(M("font-size",i)){v(e)||Me.push(p(e));break}if(M("font-family",i)){y(e)||Ue.push(p(e));break}if(M("line-height",i))je.push(p(e));else{if(M("transition",i)||M("animation",i)){const[t,n]=function(e,t){let n=!1;const i=[],r=[];return e.forEach(e=>"Operator"===e.type?n=!1:"Dimension"===e.type&&!1===n?(n=!0,i.push(t(e))):"Identifier"===e.type&&I.has(e.name)?r.push(t(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:r.push(t(e))),[i,r]}(e.children,p);for(let e=0;e<t.length;e++)Pe.push(t[e]);for(let e=0;e<n.length;e++)Fe.push(n[e]);break}if(M("animation-duration",i)||M("transition-duration",i)){Pe.push(p(e));break}if(M("transition-timing-function",i)||M("animation-timing-function",i)){Fe.push(p(e));break}M("text-shadow",i)?z(e)||Oe.push(p(e)):M("box-shadow",i)&&(z(e)||Re.push(p(e)))}t(e,function(e){switch(e.type){case"Hash":{let t=e.value.length;return o("\\9",e.value)&&(t-=2),Ae.push("#"+e.value,i),_e.push("hex"+t),this.skip}case"Identifier":{const{name:t}=e;if(t.length>20||t.length<3)return this.skip;const n=p(e),r=t.toLowerCase();return m.has(r)?(Ae.push(n,i),_e.push("named")):b.has(r)?(Ae.push(n,i),_e.push(r)):w.has(r)&&(Ae.push(n,i),_e.push("system")),this.skip}case"Function":{if(r("var",e.name))return this.skip;const t=e.name.toLowerCase(),n=p(e);g.has(t)&&(Ae.push(n,i),_e.push(t))}}});break}case"Declaration":{if(null!==this.atrulePrelude)return this.skip;be++,ge.add(p(e)),!0===e.important&&(pe++,this.atrule&&o("keyframes",this.atrule.name)&&ke++);const{property:t}=e;xe.push(t),u(t)?(ve.push(t),ze.push(2)):function(e){if(U(e)||u(e))return!1;let t=e.charCodeAt(0);return 47===t||95===t||43===t||42===t||38===t||36===t||35===t}(t)?(qe.push(t),ze.push(2)):U(t)?(Se.push(t),ze.push(2),!0===e.important&&ye.push(t)):ze.push(1);break}}});const He=P.count(),Ne=ge.size,Be=de.size(),Ee=ue.aggregate(),Ke=le.aggregate(),Le=ce.aggregate(),Qe=fe.count(),Ve=new D(de.toArray()).count(),Ge=oe.size,Je=new D(te.toArray()).count(),We=new D(ne.toArray()).count(),Xe=new D(ie.toArray()).count(),Ye=Object.assign;return{stylesheet:{sourceLinesOfCode:B+Be+be+re.size(),linesOfCode:f.length,size:i.length,comments:{total:S,size:F},embeddedContent:Ye(He,{size:{total:A,ratio:j(A,i.length)},types:{total:_.total,totalUnique:_.unique.size,uniquenessRatio:j(_.unique.size,_.total),unique:Object.fromEntries(_.unique)}})},atrules:{fontface:{total:E.length,totalUnique:E.length,unique:E,uniquenessRatio:0===E.length?0:1},import:L.count(),media:Ye(Q.count(),{browserhacks:V.count()}),charset:G.count(),supports:Ye(J.count(),{browserhacks:W.count()}),keyframes:Ye(X.count(),{prefixed:Ye(Y.count(),{ratio:j(Y.size(),X.size())})}),container:Z.count(),layer:K.count()},rules:{total:$,empty:{total:ee,ratio:j(ee,$)},sizes:Ye(te.aggregate(),{items:te.toArray(),unique:Je.unique,totalUnique:Je.totalUnique,uniquenessRatio:Je.uniquenessRatio}),selectors:Ye(ne.aggregate(),{items:ne.toArray(),unique:We.unique,totalUnique:We.totalUnique,uniquenessRatio:We.uniquenessRatio}),declarations:Ye(ie.aggregate(),{items:ie.toArray(),unique:Xe.unique,totalUnique:Xe.totalUnique,uniquenessRatio:Xe.uniquenessRatio})},selectors:{total:Be,totalUnique:Ge,uniquenessRatio:j(Ge,Be),specificity:{min:void 0===se?[0,0,0]:se,max:void 0===ae?[0,0,0]:ae,sum:[Ee.sum,Ke.sum,Le.sum],mean:[Ee.mean,Ke.mean,Le.mean],mode:[Ee.mode,Ke.mode,Le.mode],median:[Ee.median,Ke.median,Le.median],items:he,unique:Qe.unique,totalUnique:Qe.totalUnique,uniquenessRatio:Qe.uniquenessRatio},complexity:Ye(de.aggregate(),Ve,{items:de.toArray()}),id:Ye(me.count(),{ratio:j(me.size(),Be)}),accessibility:Ye(we.count(),{ratio:j(we.size(),Be)}),keyframes:re.count()},declarations:{total:be,totalUnique:Ne,uniquenessRatio:j(Ne,be),unique:{total:Ne,ratio:j(Ne,be)},importants:{total:pe,ratio:j(pe,be),inKeyframes:{total:ke,ratio:j(ke,pe)}}},properties:Ye(xe.count(),{prefixed:Ye(ve.count(),{ratio:j(ve.size(),xe.size())}),custom:Ye(Se.count(),{ratio:j(Se.size(),xe.size()),importants:Ye(ye.count(),{ratio:j(ye.size(),Se.size())})}),browserhacks:Ye(qe.count(),{ratio:j(qe.size(),xe.size())}),complexity:ze.aggregate()}),values:{colors:Ye(Ae.count(),{formats:_e.count()}),fontFamilies:Ue.count(),fontSizes:Me.count(),lineHeights:je.count(),zindexes:De.count(),textShadows:Oe.count(),boxShadows:Re.count(),animations:{durations:Pe.count(),timingFunctions:Fe.count()},prefixes:Ie.count(),browserhacks:Ce.count(),units:Te.count()},__meta__:{parseTime:N-T,analyzeTime:Date.now()-N,total:Date.now()-c}}};export{F as analyze,l as compareSpecificity};
|
|
2
2
|
//# sourceMappingURL=analyzer.modern.js.map
|