@master/css-compiler 2.0.0-beta.111 → 2.0.0-beta.113
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/compiler.d.ts +4 -1
- package/dist/index.cjs +9 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.default.d.ts +2 -0
- package/dist/index.default.js +1 -0
- package/dist/index.default.mjs +1 -0
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
package/dist/compiler.d.ts
CHANGED
|
@@ -3,11 +3,14 @@ import MasterCSS, { Rule } from '@master/css';
|
|
|
3
3
|
import type { Config } from '@master/css';
|
|
4
4
|
import Techor from 'techor';
|
|
5
5
|
export default class MasterCSSCompiler extends Techor<Options, Config> {
|
|
6
|
+
protected customOptions?: Options;
|
|
6
7
|
css: MasterCSS;
|
|
7
8
|
extractions: Set<string>;
|
|
9
|
+
validExtractions: Set<string>;
|
|
10
|
+
invalidExtractions: Set<string>;
|
|
8
11
|
get resolvedModuleId(): string;
|
|
9
12
|
get moduleHMREvent(): string;
|
|
10
|
-
constructor(
|
|
13
|
+
constructor(customOptions?: Options);
|
|
11
14
|
refresh(): Promise<this>;
|
|
12
15
|
compile(): Promise<this>;
|
|
13
16
|
extract(name: string, content: string): string[];
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
3
|
-
`)),
|
|
4
|
-
`)}typeof
|
|
5
|
-
`):
|
|
1
|
+
var we=Object.create;var S=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Se=(e,t)=>{for(var r in t)S(e,r,{get:t[r],enumerable:!0})},K=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ce(t))!Te.call(e,i)&&i!==r&&S(e,i,{get:()=>t[i],enumerable:!(o=Ee(t,i))||o.enumerable});return e};var m=(e,t,r)=>(r=e!=null?we(Re(e)):{},K(t||!e||!e.__esModule?S(r,"default",{value:e,enumerable:!0}):r,e)),ke=e=>K(S({},"__esModule",{value:!0}),e);var mt={};Se(mt,{MasterCSSCompiler:()=>E,default:()=>E,options:()=>C});module.exports=ke(mt);var W=m(require("upath"));var Ne={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},C=Ne;var V=m(require("@master/css")),U=require("perf_hooks");var q=require("@master/css");function I({content:e},{config:t,classes:r}){e=je(e);let o=[...new Set(Object.keys(t.semantics??q.semantics).concat(Object.keys(r)))],i=e.match(/\S+/g)??[],s=new Set;for(let l of i){s.add(M(l,o));let p=Q(l);if(p.size)for(let c of p)s.add(M(c,o))}return[...s].filter(l=>l&&!Be(l,o))}var M=(e,t)=>{let r=e,o=e.match(/(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)/g);return(o?.length?t.concat(o):t).find(i=>r.startsWith(i))?e=P(e,i=>i.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):e=P(e,i=>i.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),r===e||!e?e:M(e,t)},H=e=>e.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),X=(e,t)=>(t?.forEach((r,o)=>{e=e.replace(r,`COMPLETE-STRING--${o}--`)}),e),P=(e,t)=>{let r=H(e);return e=X(e,r),e=t(e),r?.forEach((o,i)=>{e=e.replace(`COMPLETE-STRING--${i}--`,o)}),e},Q=e=>{let t=new Set,r=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,o;for(;(o=r.exec(e))!==null;){o.index===r.lastIndex&&r.lastIndex++,t.add(o[2]);let i=Q(o[2]);if(i.size)for(let s of i)t.add(s)}return t},je=e=>P(e,t=>t.replace(/\/\*(?:(?!\*\/)[\S\s])*\*\//g,"").replace(/<!--(?:(?!-->)[\S\s])*-->/g,"").replace(/<style[^>]*>(?:(?!<\/style>)[\S\s])*<\/style>/g,"").replace(/import.*from\s*COMPLETE-STRING--\d+--/g,"").replace(/import\s*(?:COMPLETE-STRING--\d+--|\([^;\s]*\))/g,"").replace(/require\([^;\s]*\)/g,"")),Be=(e,t)=>{let r=H(e),o=X(e,r),i=/{(.*)}/,s;for(;(s=i.exec(o))!==null;)return s[1].split(";").find(p=>Z(p,t))!==void 0;return Z(o,t)||Ae(e)},Z=(e,t)=>!e||!e.match(/(?:\S*\{\S*\})|(?:^[\w\-()]+:\S+)|(?:^[\w-]+\(\S+\))|(?:^[@~]\S+$)/)&&!e.match(/^(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)$/)&&!t.find(r=>e.startsWith(r))||e.match(/\*\*/)||e.match(/:\[/)||e.match(/\$\{/)||e.match(/\{\{/)||e.match(/\(\{[^}]*\}/)||e.match(/<\w+>|<\/\w+>/)||e.match(/;$/)||e.match(/^\w+:\/\//)||e.match(/^@(?:ts-[^\s]+|charset|import|namespace|media|supports|document|page|font-face|keyframes|counter-style|font-feature-values|property|layer)$/)||e.match(/^~\/.+.\w+$/)||e.match(/function\(|\(.*\)=>/),Ae=e=>{let t=[],r;for(let o=0;o<e.length;o++)switch(e[o]){case"(":case"[":case"{":t.push(e[o]);break;case")":case"]":case"}":if(r=t.pop(),e[o]===")"&&r!=="("||e[o]==="]"&&r!=="["||e[o]==="}"&&r!=="{")return!0;break}return t.length>0};var ye=m(require("fs")),z=m(require("fast-glob")),B=m(require("minimatch")),xe=m(require("techor"));var j=m(require("node:process"),1),fe=m(require("node:os"),1),G=m(require("node:tty"),1),Me=Object.create,de=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Ie=Object.getOwnPropertyNames,Fe=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty,Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Le=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ie(t))!_e.call(e,i)&&i!==r&&de(e,i,{get:()=>t[i],enumerable:!(o=Pe(t,i))||o.enumerable});return e},Ye=(e,t,r)=>(r=e!=null?Me(Fe(e)):{},Le(t||!e||!e.__esModule?de(r,"default",{value:e,enumerable:!0}):r,e)),De=Ge((e,t)=>{"use strict";function r(o){var i=void 0;typeof o=="string"?i=[o]:i=o.raw;for(var s="",l=0;l<i.length;l++)s+=i[l].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),l<(arguments.length<=1?0:arguments.length-1)&&(s+=arguments.length<=l+1?void 0:arguments[l+1]);var p=s.split(`
|
|
2
|
+
`),c=null;return p.forEach(function(a){var h=a.match(/^(\s+)\S+/);if(h){var x=h[1].length;c?c=Math.min(c,x):c=x}}),c!==null&&(s=p.map(function(a){return a[0]===" "?a.slice(c):a}).join(`
|
|
3
|
+
`)),s=s.trim(),s.replace(/\\n/g,`
|
|
4
|
+
`)}typeof t<"u"&&(t.exports=r)}),b=(e,t)=>{if(!e)throw new Error(t)},We=e=>{let t={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:r=>["boolean","string","number"].includes(typeof r)?r:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...e};return b(Object.keys(t).length===9,"Unexpected Option(s) provided"),b(typeof t.joined=="boolean",'Option "joined" has invalid format'),b(typeof t.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),b(typeof t.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),b(typeof t.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),b(typeof t.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),b(typeof t.separator=="string",'Option "separator" has invalid format'),b(typeof t.renderFn=="function",'Option "renderFn" has invalid format'),b(typeof t.sortFn=="function"||t.sortFn===null,'Option "sortFn" has invalid format'),b(typeof t.breakCircularWith=="string"||t.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),t},he=(e,t={})=>{let r=We(t),o=[],i=r.renderFn(e);i!==void 0&&o.push(String(i));let s=a=>r.sortFn===null?a.reverse():a.sort((h,x)=>r.sortFn(x,h)),l=[],p=s(Object.keys(e)).map(a=>[a]),c=[e];for(;p.length!==0;){let a=p.pop(),h=c[a.length-1][a[a.length-1]],x=r.breakCircularWith!==null&&c.includes(h);l[a.length-1]=p.length!==0&&p[p.length-1].length===a.length;let $e=r.renderFn(h);o.push([l.slice(0,a.length-1).map(A=>A?r.spacerNeighbour:r.spacerNoNeighbour).join(""),l[a.length-1]?r.keyNeighbour:r.keyNoNeighbour,a[a.length-1],$e===void 0?"":`${r.separator}${h}`,x?r.breakCircularWith:""].join("")),h instanceof Object&&!Array.isArray(h)&&!x&&(p.push(...s(Object.keys(h)).map(A=>a.concat(A))),c[a.length]=h)}return r.joined===!0?o.join(`
|
|
5
|
+
`):o},ee=(e=0)=>t=>`\x1B[${t+e}m`,te=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,re=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`,u={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Ot=Object.keys(u.modifier),Ve=Object.keys(u.color),Ue=Object.keys(u.bgColor),$t=[...Ve,...Ue];function ze(){let e=new Map;for(let[t,r]of Object.entries(u)){for(let[o,i]of Object.entries(r))u[o]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[o]=u[o],e.set(i[0],i[1]);Object.defineProperty(u,t,{value:r,enumerable:!1})}return Object.defineProperty(u,"codes",{value:e,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=ee(),u.color.ansi256=te(),u.color.ansi16m=re(),u.bgColor.ansi=ee(10),u.bgColor.ansi256=te(10),u.bgColor.ansi16m=re(10),Object.defineProperties(u,{rgbToAnsi256:{value(t,r,o){return t===r&&r===o?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(s=>s+s).join(""));let i=Number.parseInt(o,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:t=>u.rgbToAnsi256(...u.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,o,i;if(t>=232)r=((t-232)*10+8)/255,o=r,i=r;else{t-=16;let p=t%36;r=Math.floor(t/36)/5,o=Math.floor(p/6)/5,i=p%6/5}let s=Math.max(r,o,i)*2;if(s===0)return 30;let l=30+(Math.round(i)<<2|Math.round(o)<<1|Math.round(r));return s===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(t,r,o)=>u.ansi256ToAnsi(u.rgbToAnsi256(t,r,o)),enumerable:!1},hexToAnsi:{value:t=>u.ansi256ToAnsi(u.hexToAnsi256(t)),enumerable:!1}}),u}var Je=ze(),v=Je;function f(e,t=globalThis.Deno?globalThis.Deno.args:j.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),i=t.indexOf("--");return o!==-1&&(i===-1||o<i)}var{env:g}=j.default,k;f("no-color")||f("no-colors")||f("color=false")||f("color=never")?k=0:(f("color")||f("colors")||f("color=true")||f("color=always"))&&(k=1);function Ke(){if("FORCE_COLOR"in g)return g.FORCE_COLOR==="true"?1:g.FORCE_COLOR==="false"?0:g.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(g.FORCE_COLOR,10),3)}function Ze(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function qe(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let o=Ke();o!==void 0&&(k=o);let i=r?k:o;if(i===0)return 0;if(r){if(f("color=16m")||f("color=full")||f("color=truecolor"))return 3;if(f("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(e&&!t&&i===void 0)return 0;let s=i||0;if(g.TERM==="dumb")return s;if(j.default.platform==="win32"){let l=fe.default.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in g)||g.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in g)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(g.TEAMCITY_VERSION)?1:0;if(g.COLORTERM==="truecolor"||g.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in g){let l=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(g.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(g.TERM)||"COLORTERM"in g?1:s}function oe(e,t={}){let r=qe(e,{streamIsTTY:e&&e.isTTY,...t});return Ze(r)}var He={stdout:oe({isTTY:G.default.isatty(1)}),stderr:oe({isTTY:G.default.isatty(2)})},Xe=He;function Qe(e,t,r){let o=e.indexOf(t);if(o===-1)return e;let i=t.length,s=0,l="";do l+=e.slice(s,o)+t+r,s=o+i,o=e.indexOf(t,s);while(o!==-1);return l+=e.slice(s),l}function et(e,t,r,o){let i=0,s="";do{let l=e[o-1]==="\r";s+=e.slice(i,l?o-1:o)+t+(l?`\r
|
|
6
6
|
`:`
|
|
7
|
-
`)+
|
|
8
|
-
`,
|
|
9
|
-
`);return
|
|
10
|
-
`).forEach(
|
|
7
|
+
`)+r,i=o+1,o=e.indexOf(`
|
|
8
|
+
`,i)}while(o!==-1);return s+=e.slice(i),s}var{stdout:ie,stderr:se}=Xe,L=Symbol("GENERATOR"),O=Symbol("STYLER"),R=Symbol("IS_EMPTY"),ne=["ansi","ansi","ansi256","ansi16m"],$=Object.create(null),tt=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=ie?ie.level:0;e.level=t.level===void 0?r:t.level},rt=e=>{let t=(...r)=>r.join(" ");return tt(t,e),Object.setPrototypeOf(t,T.prototype),t};function T(e){return rt(e)}Object.setPrototypeOf(T.prototype,Function.prototype);for(let[e,t]of Object.entries(v))$[e]={get(){let r=N(this,D(t.open,t.close,this[O]),this[R]);return Object.defineProperty(this,e,{value:r}),r}};$.visible={get(){let e=N(this,this[O],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Y=(e,t,r,...o)=>e==="rgb"?t==="ansi16m"?v[r].ansi16m(...o):t==="ansi256"?v[r].ansi256(v.rgbToAnsi256(...o)):v[r].ansi(v.rgbToAnsi(...o)):e==="hex"?Y("rgb",t,r,...v.hexToRgb(...o)):v[r][e](...o),ot=["rgb","hex","ansi256"];for(let e of ot){$[e]={get(){let{level:r}=this;return function(...o){let i=D(Y(e,ne[r],"color",...o),v.color.close,this[O]);return N(this,i,this[R])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);$[t]={get(){let{level:r}=this;return function(...o){let i=D(Y(e,ne[r],"bgColor",...o),v.bgColor.close,this[O]);return N(this,i,this[R])}}}}var it=Object.defineProperties(()=>{},{...$,level:{enumerable:!0,get(){return this[L].level},set(e){this[L].level=e}}}),D=(e,t,r)=>{let o,i;return r===void 0?(o=e,i=t):(o=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:o,closeAll:i,parent:r}},N=(e,t,r)=>{let o=(...i)=>st(o,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(o,it),o[L]=e,o[O]=t,o[R]=r,o},st=(e,t)=>{if(e.level<=0||!t)return e[R]?"":t;let r=e[O];if(r===void 0)return t;let{openAll:o,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=Qe(t,r.close,r.open),r=r.parent;let s=t.indexOf(`
|
|
9
|
+
`);return s!==-1&&(t=et(t,i,o,s)),o+t+i};Object.defineProperties(T.prototype,$);var nt=T(),wt=T({level:se?se.level:0}),n=nt;function y(e){return e.split(" ").map(t=>t.replace(/^(\d*\.?\d*)$/g,`${n.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|kB|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${n.cyan("$1")}${n.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${n.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${n.dim("[")}${n.magenta("$1")}${n.dim("]")}`).replace(/^`(.*?)`$/g,`${n.dim("`")}$1${n.dim("`")}`).replace(/^\((.*?)\)$/g,`${n.dim("(")}$1${n.dim(")")}`).replace(/^<(.*?)>$/g,`${n.dim("<")}${n.gray("$1")}${n.dim(">")}`).replace(/->/g,n.dim("\u2192")).replace(/<-/g,n.dim("\u2190")).replace(/^\$t$/g,`${n.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${n.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${n.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${n.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${n.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${n.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${n.italic("$1")}`).replace(/^_(.*?)_$/g,`${n.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${n.green("$1")}`).replace(/^-(.*?)-$/g,`${n.red("$1")}`)).join(" ")}function d(e,t){let r="";if(Array.isArray(e))for(let o=0;o<e.length;o++)r+=F(e[o])+F(t[o]);else r=[e,...t].map(o=>F(o)).join(" ");return y(r)}var F=e=>e?Array.isArray(e)?e.map(t=>{switch(typeof t){case"string":return`'${n.yellow(t)}'`;case"number":case"boolean":return n.blue(t);default:return t}}).join(n.gray(", ")):e:"",le=(e,...t)=>{let r=n.green("+")+" "+d(e,t);return console.log(r),r},ae=(e,...t)=>{let r=n.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+d(e,t);return console.log(r),r},lt=(e,...t)=>{let r=n.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+n.yellow(d(e,t));return console.log(r),r},at=(e,...t)=>{let r=n.green("\u2713 ")+d(e,t);return console.log(r),r},_=(e,...t)=>{let r=n.red("-")+" "+d(e,t);return console.log(r),r},ce=(e,...t)=>{let r=n.green("\u25CB ")+d(e,t);return console.log(r),r},ue=(e,...t)=>{let r=n.red("\u2717 ")+d(e,t);return console.log(r),r},ge=(e,...t)=>{let r=n.cyan("\u{1D4F2}")+" "+d(e,t);return console.log(r),r},ct=(e,...t)=>{let r=n.green("\u23FA Success ")+d(e,t);return console.log(r),r},ut=(e,...t)=>{let r=n.yellow("\u23FA Warn ")+d(e,t);return console.log(r),r},gt=(e,...t)=>{let r=n.bgGreen.bold.white(" \u2713 PASS ")+" "+d(e,t);return console.log(r),r},pt=e=>{let t=he(be(me(JSON.parse(JSON.stringify(e)))),{spacerNeighbour:y("..\u2502..")+" ",keyNoNeighbour:y("..\u2514\u2500..")+" ",keyNeighbour:y("..\u251C\u2500..")+" ",separator:y("..:..")+" "});return console.log(t),t};function me(e){for(let t in e){let r=e[t];typeof r=="object"?r!==null&&!Object.keys(r).length?delete e[t]:e[t]=me(r):r===void 0&&delete e[t]}return e}function be(e){for(let t in e){let r=e[t];Array.isArray(r)?e[t]=r.map(o=>y(`**${o}**`)).join(y("..,..")):typeof r=="object"?be(r):e[t]=y(`**${r}**`)}return e}var dt=(e,...t)=>{let r=n.red("\u23FA Fail ")+d(e,t);return console.log(r),r},pe=(e,...t)=>{let r=y("$t ")+d(e,t);return console.log(r),r},ht=Ye(De());function ft(e){let{message:t,stack:r}=typeof e=="string"?new Error(e):e,o={};return(0,ht.default)(r.replace(t,"").replace(/^Error: /,"")).split(`
|
|
10
|
+
`).forEach(i=>{o[i.split(" ").map(s=>s.replace(/^\((.+)\)$/,`${n.cyan("$1")}`).replace(/\./g,`${n.dim(".")}`).replace(/^at$/,l=>n.dim(l))).join(" ")]=null}),{message:t.trim().replace(/Error: /g,""),stackTree:o}}var ve=(e,...t)=>{if(e instanceof Error){let{message:r,stackTree:o}=ft(e);return console.log(""),console.log(n.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+n.bold.red(r)),console.log(he(o,{spacerNeighbour:n.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:n.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:n.redBright.dim("\u251C\u2500 "),separator:n.redBright.dim(":\u2000")})),console.log(""),r}else{let r=d(e,t);return console.log(r),r}};Object.assign(ve,{a:le,add:le,d:_,del:_,delete:_,o:ce,valid:ce,x:ue,invalid:ue,i:ge,info:ge,e:ae,error:ae,t:pe,timestamp:pe,success:ct,fail:dt,warn:ut,pass:gt,conflict:lt,ok:at,tree:pt,paint:y});var w=ve;var Oe=m(require("stylelint")),J=m(require("to-extend")),E=class extends xe.default{constructor(r){super(C,r);this.customOptions=r;let o=this.readConfig(null);this.options=(0,J.default)(this.options,o?.compilerOptions,r),this.css=o?.css??new V.default(o?.config)}css;extractions=new Set;validExtractions=new Set;invalidExtractions=new Set;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async refresh(){this.extractions.clear(),this.validExtractions.clear(),this.invalidExtractions.clear(),console.log("");let r=this.readConfig(null);return this.css=new V.default(r?.config),this.options=(0,J.default)({cwd:this.options.cwd},C,r?.compilerOptions,this.customOptions),await this.compile(),this}async compile(){if(this.options.classes?.fixed?.length)for(let r of this.options.classes.fixed)this.css.insert(r);return await Promise.all(this.sources.map(async r=>{let o=ye.default.readFileSync(W.default.resolve(this.options.cwd,r),{encoding:"utf-8"}).toString();await this.insert(r,o)})),this}extract(r,o){if(!r||!o||!this.checkSourcePath(r))return[];let i=[];for(let s of I({content:o,name:r},this.css))this.extractions.has(s)||(this.extractions.add(s),i.push(s));return i}async insert(r,o){let i=this.extract(r,o);if(!i.length)return!1;this.invalidExtractions.size&&(i=i.filter(c=>!this.invalidExtractions.has(c))),this.validExtractions.size&&(i=i.filter(c=>!this.validExtractions.has(c))),this.options.classes?.ignored?.length&&(i=i.filter(c=>{for(let a of this.options.classes.ignored)if(typeof a=="string"){if(a===c)return!1}else if(a.test(c))return!1;return!0}));let s=U.performance.now(),l=[];await Promise.all(i.map(async c=>{let a=await this.createRules(c);a.length?(this.css.insertRules(a),l.push(c),this.validExtractions.add(c)):this.invalidExtractions.add(c)}));let p=Math.round((U.performance.now()-s)*100)/100;if(i.length&&(console.log(""),w`**${W.default.relative(this.options.cwd,r)}**`,w`[extract] ${i.length} potential`),this.css.rules.length){let c=l.filter(a=>!i.includes(a));c.length&&w`[exclude] ${c.length} unknown ${c}`,w`[compile] +${l.length}+ valid inserted ${n.gray("in")} ${p}ms ${l}`,w`[virtual] ${this.css.rules.length} total ${n.gray("in")} ${this.options.module}`}return!0}async createRules(r){return(await Promise.all(this.css.create(r).map(async i=>(await Oe.default.lint({code:i.text,cache:!1,config:{rules:{"color-no-invalid-hex":!0,"named-grid-areas-no-invalid":!0,"at-rule-no-unknown":!0,"function-no-unknown":!0,"media-feature-name-no-unknown":!0,"property-no-unknown":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":!0,"unit-no-unknown":!0}}})).errored?null:i))).filter(i=>i)}get sources(){let{include:r,exclude:o,sources:i}=this.options,s=z.default.sync(r,{cwd:this.options.cwd,ignore:o});return i?.length&&s.push(...z.default.sync(i,{cwd:this.options.cwd})),s}checkSourcePath(r){let{include:o,exclude:i,sources:s}=this.options;for(let l of s)if((0,B.default)(r,l))return!0;for(let l of o)if(!(0,B.default)(r,l))return!1;for(let l of i)if((0,B.default)(r,l))return!1;return!0}get config(){return this.css.config}};0&&(module.exports={MasterCSSCompiler,options});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from './compiler';
|
|
2
|
-
export { default as
|
|
3
|
-
export
|
|
2
|
+
export { default as MasterCSSCompiler } from './compiler';
|
|
3
|
+
export * from './index.default';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(s,t)=>{for(var o in t)r(s,o,{get:t[o],enumerable:!0})},l=(s,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of a(t))!c.call(s,e)&&e!==o&&r(s,e,{get:()=>t[e],enumerable:!(n=p(t,e))||n.enumerable});return s};var m=s=>l(r({},"__esModule",{value:!0}),s);var f={};d(f,{options:()=>i});module.exports=m(f);var u={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},i=u;0&&(module.exports={options});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},s=t;export{s as options};
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
`),
|
|
3
|
-
`)),
|
|
4
|
-
`)}typeof
|
|
5
|
-
`):
|
|
1
|
+
import ce from"upath";var fe={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},R=fe;import ue from"@master/css";import{performance as ge}from"perf_hooks";import{semantics as me}from"@master/css";function B({content:e},{config:r,classes:t}){e=be(e);let o=[...new Set(Object.keys(r.semantics??me).concat(Object.keys(t)))],i=e.match(/\S+/g)??[],s=new Set;for(let l of i){s.add(N(l,o));let p=W(l);if(p.size)for(let c of p)s.add(N(c,o))}return[...s].filter(l=>l&&!ve(l,o))}var N=(e,r)=>{let t=e,o=e.match(/(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)/g);return(o?.length?r.concat(o):r).find(i=>t.startsWith(i))?e=j(e,i=>i.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):e=j(e,i=>i.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===e||!e?e:N(e,r)},Y=e=>e.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),D=(e,r)=>(r?.forEach((t,o)=>{e=e.replace(t,`COMPLETE-STRING--${o}--`)}),e),j=(e,r)=>{let t=Y(e);return e=D(e,t),e=r(e),t?.forEach((o,i)=>{e=e.replace(`COMPLETE-STRING--${i}--`,o)}),e},W=e=>{let r=new Set,t=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,o;for(;(o=t.exec(e))!==null;){o.index===t.lastIndex&&t.lastIndex++,r.add(o[2]);let i=W(o[2]);if(i.size)for(let s of i)r.add(s)}return r},be=e=>j(e,r=>r.replace(/\/\*(?:(?!\*\/)[\S\s])*\*\//g,"").replace(/<!--(?:(?!-->)[\S\s])*-->/g,"").replace(/<style[^>]*>(?:(?!<\/style>)[\S\s])*<\/style>/g,"").replace(/import.*from\s*COMPLETE-STRING--\d+--/g,"").replace(/import\s*(?:COMPLETE-STRING--\d+--|\([^;\s]*\))/g,"").replace(/require\([^;\s]*\)/g,"")),ve=(e,r)=>{let t=Y(e),o=D(e,t),i=/{(.*)}/,s;for(;(s=i.exec(o))!==null;)return s[1].split(";").find(p=>L(p,r))!==void 0;return L(o,r)||ye(e)},L=(e,r)=>!e||!e.match(/(?:\S*\{\S*\})|(?:^[\w\-()]+:\S+)|(?:^[\w-]+\(\S+\))|(?:^[@~]\S+$)/)&&!e.match(/^(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)$/)&&!r.find(t=>e.startsWith(t))||e.match(/\*\*/)||e.match(/:\[/)||e.match(/\$\{/)||e.match(/\{\{/)||e.match(/\(\{[^}]*\}/)||e.match(/<\w+>|<\/\w+>/)||e.match(/;$/)||e.match(/^\w+:\/\//)||e.match(/^@(?:ts-[^\s]+|charset|import|namespace|media|supports|document|page|font-face|keyframes|counter-style|font-feature-values|property|layer)$/)||e.match(/^~\/.+.\w+$/)||e.match(/function\(|\(.*\)=>/),ye=e=>{let r=[],t;for(let o=0;o<e.length;o++)switch(e[o]){case"(":case"[":case"{":r.push(e[o]);break;case")":case"]":case"}":if(t=r.pop(),e[o]===")"&&t!=="("||e[o]==="]"&&t!=="["||e[o]==="}"&&t!=="{")return!0;break}return r.length>0};import ot from"fs";import pe from"fast-glob";import G from"minimatch";import it from"techor";import _ from"node:process";import Me from"node:os";import J from"node:tty";var xe=Object.create,ie=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,$e=Object.getOwnPropertyNames,we=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty,Ce=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Re=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of $e(r))!Ee.call(e,i)&&i!==t&&ie(e,i,{get:()=>r[i],enumerable:!(o=Oe(r,i))||o.enumerable});return e},Te=(e,r,t)=>(t=e!=null?xe(we(e)):{},Re(r||!e||!e.__esModule?ie(t,"default",{value:e,enumerable:!0}):t,e)),Se=Ce((e,r)=>{"use strict";function t(o){var i=void 0;typeof o=="string"?i=[o]:i=o.raw;for(var s="",l=0;l<i.length;l++)s+=i[l].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),l<(arguments.length<=1?0:arguments.length-1)&&(s+=arguments.length<=l+1?void 0:arguments[l+1]);var p=s.split(`
|
|
2
|
+
`),c=null;return p.forEach(function(a){var h=a.match(/^(\s+)\S+/);if(h){var y=h[1].length;c?c=Math.min(c,y):c=y}}),c!==null&&(s=p.map(function(a){return a[0]===" "?a.slice(c):a}).join(`
|
|
3
|
+
`)),s=s.trim(),s.replace(/\\n/g,`
|
|
4
|
+
`)}typeof r<"u"&&(r.exports=t)}),m=(e,r)=>{if(!e)throw new Error(r)},ke=e=>{let r={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:t=>["boolean","string","number"].includes(typeof t)?t:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...e};return m(Object.keys(r).length===9,"Unexpected Option(s) provided"),m(typeof r.joined=="boolean",'Option "joined" has invalid format'),m(typeof r.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),m(typeof r.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),m(typeof r.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),m(typeof r.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),m(typeof r.separator=="string",'Option "separator" has invalid format'),m(typeof r.renderFn=="function",'Option "renderFn" has invalid format'),m(typeof r.sortFn=="function"||r.sortFn===null,'Option "sortFn" has invalid format'),m(typeof r.breakCircularWith=="string"||r.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),r},se=(e,r={})=>{let t=ke(r),o=[],i=t.renderFn(e);i!==void 0&&o.push(String(i));let s=a=>t.sortFn===null?a.reverse():a.sort((h,y)=>t.sortFn(y,h)),l=[],p=s(Object.keys(e)).map(a=>[a]),c=[e];for(;p.length!==0;){let a=p.pop(),h=c[a.length-1][a[a.length-1]],y=t.breakCircularWith!==null&&c.includes(h);l[a.length-1]=p.length!==0&&p[p.length-1].length===a.length;let he=t.renderFn(h);o.push([l.slice(0,a.length-1).map(k=>k?t.spacerNeighbour:t.spacerNoNeighbour).join(""),l[a.length-1]?t.keyNeighbour:t.keyNoNeighbour,a[a.length-1],he===void 0?"":`${t.separator}${h}`,y?t.breakCircularWith:""].join("")),h instanceof Object&&!Array.isArray(h)&&!y&&(p.push(...s(Object.keys(h)).map(k=>a.concat(k))),c[a.length]=h)}return t.joined===!0?o.join(`
|
|
5
|
+
`):o},V=(e=0)=>r=>`\x1B[${r+e}m`,U=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,z=(e=0)=>(r,t,o)=>`\x1B[${38+e};2;${r};${t};${o}m`,u={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ut=Object.keys(u.modifier),Ne=Object.keys(u.color),je=Object.keys(u.bgColor),gt=[...Ne,...je];function Be(){let e=new Map;for(let[r,t]of Object.entries(u)){for(let[o,i]of Object.entries(t))u[o]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[o]=u[o],e.set(i[0],i[1]);Object.defineProperty(u,r,{value:t,enumerable:!1})}return Object.defineProperty(u,"codes",{value:e,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=V(),u.color.ansi256=U(),u.color.ansi16m=z(),u.bgColor.ansi=V(10),u.bgColor.ansi256=U(10),u.bgColor.ansi16m=z(10),Object.defineProperties(u,{rgbToAnsi256:{value(r,t,o){return r===t&&t===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(r){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(s=>s+s).join(""));let i=Number.parseInt(o,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:r=>u.rgbToAnsi256(...u.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let t,o,i;if(r>=232)t=((r-232)*10+8)/255,o=t,i=t;else{r-=16;let p=r%36;t=Math.floor(r/36)/5,o=Math.floor(p/6)/5,i=p%6/5}let s=Math.max(t,o,i)*2;if(s===0)return 30;let l=30+(Math.round(i)<<2|Math.round(o)<<1|Math.round(t));return s===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(r,t,o)=>u.ansi256ToAnsi(u.rgbToAnsi256(r,t,o)),enumerable:!1},hexToAnsi:{value:r=>u.ansi256ToAnsi(u.hexToAnsi256(r)),enumerable:!1}}),u}var Ae=Be(),b=Ae;function f(e,r=globalThis.Deno?globalThis.Deno.args:_.argv){let t=e.startsWith("-")?"":e.length===1?"-":"--",o=r.indexOf(t+e),i=r.indexOf("--");return o!==-1&&(i===-1||o<i)}var{env:g}=_,T;f("no-color")||f("no-colors")||f("color=false")||f("color=never")?T=0:(f("color")||f("colors")||f("color=true")||f("color=always"))&&(T=1);function Pe(){if("FORCE_COLOR"in g)return g.FORCE_COLOR==="true"?1:g.FORCE_COLOR==="false"?0:g.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(g.FORCE_COLOR,10),3)}function Ie(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Fe(e,{streamIsTTY:r,sniffFlags:t=!0}={}){let o=Pe();o!==void 0&&(T=o);let i=t?T:o;if(i===0)return 0;if(t){if(f("color=16m")||f("color=full")||f("color=truecolor"))return 3;if(f("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(e&&!r&&i===void 0)return 0;let s=i||0;if(g.TERM==="dumb")return s;if(_.platform==="win32"){let l=Me.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in g)||g.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in g)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(g.TEAMCITY_VERSION)?1:0;if(g.COLORTERM==="truecolor"||g.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in g){let l=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(g.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(g.TERM)||"COLORTERM"in g?1:s}function K(e,r={}){let t=Fe(e,{streamIsTTY:e&&e.isTTY,...r});return Ie(t)}var _e={stdout:K({isTTY:J.isatty(1)}),stderr:K({isTTY:J.isatty(2)})},Ge=_e;function Le(e,r,t){let o=e.indexOf(r);if(o===-1)return e;let i=r.length,s=0,l="";do l+=e.slice(s,o)+r+t,s=o+i,o=e.indexOf(r,s);while(o!==-1);return l+=e.slice(s),l}function Ye(e,r,t,o){let i=0,s="";do{let l=e[o-1]==="\r";s+=e.slice(i,l?o-1:o)+r+(l?`\r
|
|
6
6
|
`:`
|
|
7
|
-
`)+t,
|
|
8
|
-
`,
|
|
9
|
-
`);return
|
|
10
|
-
`).forEach(
|
|
7
|
+
`)+t,i=o+1,o=e.indexOf(`
|
|
8
|
+
`,i)}while(o!==-1);return s+=e.slice(i),s}var{stdout:Z,stderr:q}=Ge,P=Symbol("GENERATOR"),x=Symbol("STYLER"),w=Symbol("IS_EMPTY"),H=["ansi","ansi","ansi256","ansi16m"],O=Object.create(null),De=(e,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Z?Z.level:0;e.level=r.level===void 0?t:r.level},We=e=>{let r=(...t)=>t.join(" ");return De(r,e),Object.setPrototypeOf(r,E.prototype),r};function E(e){return We(e)}Object.setPrototypeOf(E.prototype,Function.prototype);for(let[e,r]of Object.entries(b))O[e]={get(){let t=S(this,F(r.open,r.close,this[x]),this[w]);return Object.defineProperty(this,e,{value:t}),t}};O.visible={get(){let e=S(this,this[x],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var I=(e,r,t,...o)=>e==="rgb"?r==="ansi16m"?b[t].ansi16m(...o):r==="ansi256"?b[t].ansi256(b.rgbToAnsi256(...o)):b[t].ansi(b.rgbToAnsi(...o)):e==="hex"?I("rgb",r,t,...b.hexToRgb(...o)):b[t][e](...o),Ve=["rgb","hex","ansi256"];for(let e of Ve){O[e]={get(){let{level:t}=this;return function(...o){let i=F(I(e,H[t],"color",...o),b.color.close,this[x]);return S(this,i,this[w])}}};let r="bg"+e[0].toUpperCase()+e.slice(1);O[r]={get(){let{level:t}=this;return function(...o){let i=F(I(e,H[t],"bgColor",...o),b.bgColor.close,this[x]);return S(this,i,this[w])}}}}var Ue=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[P].level},set(e){this[P].level=e}}}),F=(e,r,t)=>{let o,i;return t===void 0?(o=e,i=r):(o=t.openAll+e,i=r+t.closeAll),{open:e,close:r,openAll:o,closeAll:i,parent:t}},S=(e,r,t)=>{let o=(...i)=>ze(o,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(o,Ue),o[P]=e,o[x]=r,o[w]=t,o},ze=(e,r)=>{if(e.level<=0||!r)return e[w]?"":r;let t=e[x];if(t===void 0)return r;let{openAll:o,closeAll:i}=t;if(r.includes("\x1B"))for(;t!==void 0;)r=Le(r,t.close,t.open),t=t.parent;let s=r.indexOf(`
|
|
9
|
+
`);return s!==-1&&(r=Ye(r,i,o,s)),o+r+i};Object.defineProperties(E.prototype,O);var Je=E(),ft=E({level:q?q.level:0}),n=Je;function v(e){return e.split(" ").map(r=>r.replace(/^(\d*\.?\d*)$/g,`${n.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|kB|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${n.cyan("$1")}${n.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${n.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${n.dim("[")}${n.magenta("$1")}${n.dim("]")}`).replace(/^`(.*?)`$/g,`${n.dim("`")}$1${n.dim("`")}`).replace(/^\((.*?)\)$/g,`${n.dim("(")}$1${n.dim(")")}`).replace(/^<(.*?)>$/g,`${n.dim("<")}${n.gray("$1")}${n.dim(">")}`).replace(/->/g,n.dim("\u2192")).replace(/<-/g,n.dim("\u2190")).replace(/^\$t$/g,`${n.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${n.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${n.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${n.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${n.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${n.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${n.italic("$1")}`).replace(/^_(.*?)_$/g,`${n.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${n.green("$1")}`).replace(/^-(.*?)-$/g,`${n.red("$1")}`)).join(" ")}function d(e,r){let t="";if(Array.isArray(e))for(let o=0;o<e.length;o++)t+=A(e[o])+A(r[o]);else t=[e,...r].map(o=>A(o)).join(" ");return v(t)}var A=e=>e?Array.isArray(e)?e.map(r=>{switch(typeof r){case"string":return`'${n.yellow(r)}'`;case"number":case"boolean":return n.blue(r);default:return r}}).join(n.gray(", ")):e:"",X=(e,...r)=>{let t=n.green("+")+" "+d(e,r);return console.log(t),t},Q=(e,...r)=>{let t=n.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+d(e,r);return console.log(t),t},Ke=(e,...r)=>{let t=n.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+n.yellow(d(e,r));return console.log(t),t},Ze=(e,...r)=>{let t=n.green("\u2713 ")+d(e,r);return console.log(t),t},M=(e,...r)=>{let t=n.red("-")+" "+d(e,r);return console.log(t),t},ee=(e,...r)=>{let t=n.green("\u25CB ")+d(e,r);return console.log(t),t},te=(e,...r)=>{let t=n.red("\u2717 ")+d(e,r);return console.log(t),t},re=(e,...r)=>{let t=n.cyan("\u{1D4F2}")+" "+d(e,r);return console.log(t),t},qe=(e,...r)=>{let t=n.green("\u23FA Success ")+d(e,r);return console.log(t),t},He=(e,...r)=>{let t=n.yellow("\u23FA Warn ")+d(e,r);return console.log(t),t},Xe=(e,...r)=>{let t=n.bgGreen.bold.white(" \u2713 PASS ")+" "+d(e,r);return console.log(t),t},Qe=e=>{let r=se(le(ne(JSON.parse(JSON.stringify(e)))),{spacerNeighbour:v("..\u2502..")+" ",keyNoNeighbour:v("..\u2514\u2500..")+" ",keyNeighbour:v("..\u251C\u2500..")+" ",separator:v("..:..")+" "});return console.log(r),r};function ne(e){for(let r in e){let t=e[r];typeof t=="object"?t!==null&&!Object.keys(t).length?delete e[r]:e[r]=ne(t):t===void 0&&delete e[r]}return e}function le(e){for(let r in e){let t=e[r];Array.isArray(t)?e[r]=t.map(o=>v(`**${o}**`)).join(v("..,..")):typeof t=="object"?le(t):e[r]=v(`**${t}**`)}return e}var et=(e,...r)=>{let t=n.red("\u23FA Fail ")+d(e,r);return console.log(t),t},oe=(e,...r)=>{let t=v("$t ")+d(e,r);return console.log(t),t},tt=Te(Se());function rt(e){let{message:r,stack:t}=typeof e=="string"?new Error(e):e,o={};return(0,tt.default)(t.replace(r,"").replace(/^Error: /,"")).split(`
|
|
10
|
+
`).forEach(i=>{o[i.split(" ").map(s=>s.replace(/^\((.+)\)$/,`${n.cyan("$1")}`).replace(/\./g,`${n.dim(".")}`).replace(/^at$/,l=>n.dim(l))).join(" ")]=null}),{message:r.trim().replace(/Error: /g,""),stackTree:o}}var ae=(e,...r)=>{if(e instanceof Error){let{message:t,stackTree:o}=rt(e);return console.log(""),console.log(n.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+n.bold.red(t)),console.log(se(o,{spacerNeighbour:n.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:n.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:n.redBright.dim("\u251C\u2500 "),separator:n.redBright.dim(":\u2000")})),console.log(""),t}else{let t=d(e,r);return console.log(t),t}};Object.assign(ae,{a:X,add:X,d:M,del:M,delete:M,o:ee,valid:ee,x:te,invalid:te,i:re,info:re,e:Q,error:Q,t:oe,timestamp:oe,success:qe,fail:et,warn:He,pass:Xe,conflict:Ke,ok:Ze,tree:Qe,paint:v});var $=ae;import st from"stylelint";import de from"to-extend";var C=class extends it{constructor(t){super(R,t);this.customOptions=t;let o=this.readConfig(null);this.options=de(this.options,o?.compilerOptions,t),this.css=o?.css??new ue(o?.config)}css;extractions=new Set;validExtractions=new Set;invalidExtractions=new Set;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async refresh(){this.extractions.clear(),this.validExtractions.clear(),this.invalidExtractions.clear(),console.log("");let t=this.readConfig(null);return this.css=new ue(t?.config),this.options=de({cwd:this.options.cwd},R,t?.compilerOptions,this.customOptions),await this.compile(),this}async compile(){if(this.options.classes?.fixed?.length)for(let t of this.options.classes.fixed)this.css.insert(t);return await Promise.all(this.sources.map(async t=>{let o=ot.readFileSync(ce.resolve(this.options.cwd,t),{encoding:"utf-8"}).toString();await this.insert(t,o)})),this}extract(t,o){if(!t||!o||!this.checkSourcePath(t))return[];let i=[];for(let s of B({content:o,name:t},this.css))this.extractions.has(s)||(this.extractions.add(s),i.push(s));return i}async insert(t,o){let i=this.extract(t,o);if(!i.length)return!1;this.invalidExtractions.size&&(i=i.filter(c=>!this.invalidExtractions.has(c))),this.validExtractions.size&&(i=i.filter(c=>!this.validExtractions.has(c))),this.options.classes?.ignored?.length&&(i=i.filter(c=>{for(let a of this.options.classes.ignored)if(typeof a=="string"){if(a===c)return!1}else if(a.test(c))return!1;return!0}));let s=ge.now(),l=[];await Promise.all(i.map(async c=>{let a=await this.createRules(c);a.length?(this.css.insertRules(a),l.push(c),this.validExtractions.add(c)):this.invalidExtractions.add(c)}));let p=Math.round((ge.now()-s)*100)/100;if(i.length&&(console.log(""),$`**${ce.relative(this.options.cwd,t)}**`,$`[extract] ${i.length} potential`),this.css.rules.length){let c=l.filter(a=>!i.includes(a));c.length&&$`[exclude] ${c.length} unknown ${c}`,$`[compile] +${l.length}+ valid inserted ${n.gray("in")} ${p}ms ${l}`,$`[virtual] ${this.css.rules.length} total ${n.gray("in")} ${this.options.module}`}return!0}async createRules(t){return(await Promise.all(this.css.create(t).map(async i=>(await st.lint({code:i.text,cache:!1,config:{rules:{"color-no-invalid-hex":!0,"named-grid-areas-no-invalid":!0,"at-rule-no-unknown":!0,"function-no-unknown":!0,"media-feature-name-no-unknown":!0,"property-no-unknown":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":!0,"unit-no-unknown":!0}}})).errored?null:i))).filter(i=>i)}get sources(){let{include:t,exclude:o,sources:i}=this.options,s=pe.sync(t,{cwd:this.options.cwd,ignore:o});return i?.length&&s.push(...pe.sync(i,{cwd:this.options.cwd})),s}checkSourcePath(t){let{include:o,exclude:i,sources:s}=this.options;for(let l of s)if(G(t,l))return!0;for(let l of o)if(!G(t,l))return!1;for(let l of i)if(G(t,l))return!1;return!0}get config(){return this.css.config}};export{C as MasterCSSCompiler,C as default,R as options};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css-compiler","scripts":{"build":"aron pack
|
|
1
|
+
{"name":"@master/css-compiler","scripts":{"build":"aron pack","dev":"npm run build -- --watch","lint":"eslint ./src","test":"jest"},"license":"MIT","description":"The ahead-of-time compiler of Master CSS","author":"Aoyue Design LLC.","funding":"https://docs.master.co/css/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/compiler"},"keywords":["webpack","plugin","integration","vite","parcel","build tools","css","mastercss","vite-plugin"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"node":{"require":"./dist/index.cjs","import":"./dist/index.mjs"},"default":{"require":"./dist/index.default.js","import":"./dist/index.default.mjs"},"types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.113","fast-glob":"^3.2.12","minimatch":"^5.1.1","stylelint":"^15.2.0","techor":"^1.1.0","to-extend":"^1.5.0","upath":"^2.0.1"},"version":"2.0.0-beta.113"}
|