4 lines
84 KiB
JavaScript
4 lines
84 KiB
JavaScript
|
#!/usr/bin/env node
|
|||
|
|
|||
|
"use strict";var e=require("postcss-selector-parser"),t=require("tty"),r=require("path"),n=require("url"),s=require("fs");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e),a=i(t),l=i(r),u=i(n),c=i(s);const h=e=>{e="object"==typeof e&&e||p;const t=Boolean(!("preserve"in e)||e.preserve);return{postcssPlugin:"css-has-pseudo",Rule:(e,{result:r})=>{if(!e.selector.includes(":has("))return;let n;try{const t=o.default((e=>{e.walkPseudos((e=>{if(":has"===e.value&&e.nodes){const t=d(e);e.value=t?":not-has":":has";const r=o.default.attribute({attribute:f(String(e))});t?e.parent.parent.replaceWith(r):e.replaceWith(r)}}))})).processSync(e.selector);n=String(t)}catch(t){return void e.warn(r,`Failed to parse selector : ${e.selector}`)}void 0!==n&&n!==e.selector&&(t?e.cloneBefore({selector:n}):e.selector=n)}}};h.postcss=!0;const p={preserve:!0},f=e=>{let t="",r="";const n=()=>{if(r){const e=encodeURIComponent(r);let n="",s="";const i=()=>{n&&(s+=n,n="")};let o=!1;for(let t=0;t<e.length;t++){const r=e[t];if(o)n+=r,o=!1;else switch(r){case"%":i(),s+="\\"+r;continue;case"\\":n+=r,o=!0;continue;default:n+=r;continue}}i(),t+=s,r=""}};let s=!1;for(let i=0;i<e.length;i++){const o=e[i];if(s)r+=o,s=!1;else switch(o){case":":case"[":case"]":case",":case"(":case")":n(),t+="\\"+o;continue;case"\\":r+=o,s=!0;continue;default:r+=o;continue}}return n(),t},d=e=>{var t,r;return"pseudo"===(null==(t=e.parent)||null==(r=t.parent)?void 0:r.type)&&":not"===e.parent.parent.value};var g;!function(e){e.InvalidArguments="INVALID_ARGUMENTS"}(g||(g={}));var m={exports:{}};let w=a.default,y=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||"win32"===process.platform||w.isatty(1)&&"dumb"!==process.env.TERM||"CI"in process.env),v=(e,t,r=e)=>n=>{let s=""+n,i=s.indexOf(t,e.length);return~i?e+S(s,t,r,i)+t:e+s+t},S=(e,t,r,n)=>{let s=e.substring(0,n)+r,i=e.substring(n+t.length),o=i.indexOf(t);return~o?s+S(i,t,r,o):s+i},C=(e=y)=>({isColorSupported:e,reset:e?e=>`[0m${e}[0m`:String,bold:e?v("[1m","[22m","[22m[1m"):String,dim:e?v("[2m","[22m","[22m[2m"):String,italic:e?v("[3m","[23m"):String,underline:e?v("[4m","[24m"):String,inverse:e?v("[7m","[27m"):String,hidden:e?v("[8m","[28m"):String,strikethrough:e?v("[9m","[29m"):String,black:e?v("[30m","[39m"):String,red:e?v("[31m","[39m"):String,green:e?v("[32m","[39m"):String,yellow:e?v("[33m","[39m"):String,blue:e?v("[34m","[39m"):String,magenta:e?v("[35m","[39m"):String,cyan:e?v("[36m","[39m"):String,white:e?v("[37m","[39m"):String,gray:e?v("[90m","[39m"):String,bgBlack:e?v("[40m","[49m"):String,bgRed:e?v("[41m","[49m"):String,bgGreen:e?v("[42m","[49m"):String,bgYellow:e?v("[43m","[49m"):String,bgBlue:e?v("[44m","[49m"):String,bgMagenta:e?v("[45m","[49m"):String,bgCyan:e?v("[46m","[49m"):String,bgWhite:e?v("[47m","[49m"):String});m.exports=C(),m.exports.createColors=C;const b="'".charCodeAt(0),_='"'.charCodeAt(0),x="\\".charCodeAt(0),O="/".charCodeAt(0),A="\n".charCodeAt(0),M=" ".charCodeAt(0),k="\f".charCodeAt(0),E="\t".charCodeAt(0),L="\r".charCodeAt(0),R="[".charCodeAt(0),P="]".charCodeAt(0),I="(".charCodeAt(0),j=")".charCodeAt(0),N="{".charCodeAt(0),U="}".charCodeAt(0),B=";".charCodeAt(0),D="*".charCodeAt(0),F=":".charCodeAt(0),T="@".charCodeAt(0),$=/[\t\n\f\r "#'()/;[\\\]{}]/g,G=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,z=/.[\n"'(/\\]/,W=/[\da-f]/i;var V=function(e,t={}){let r,n,s,i,o,a,l,u,c,h,p=e.css.valueOf(),f=t.ignoreErrors,d=p.length,g=0,m=[],w=[];function y(t){throw e.error("Unclosed "+t,g)}return{back:function(e){w.push(e)},nextToken:function(e){if(w.length)return w.pop();if(g>=d)return;let t=!!e&&e.ignoreUnclosed;switch(r=p.charCodeAt(g),r){case A:case M:case E:case L:case k:n=g;do{n+=1,r=p.charCodeAt(n)}while(r===M||r===A||r===E||r===L||r===k);h=["space",p.slice(g,n)],g=n-1;break;case R:case P:case N:case U:case F:case B:case j:{let e=String.fromCharCode(r);h=[e,e,g];break}case I:if(u=m.length?m.pop()[1]:"",c=p.charCodeAt(g+1),"url"===u&&c!==b&&c!==_&&
|