@stacksjs/ts-css 0.1.4 → 0.3.2
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/ENGINE.md +677 -0
- package/PLUGIN.md +217 -0
- package/dist/bin/cli.js +29 -38
- package/dist/bin/cssx.js +405 -0
- package/dist/chunk-0h48763m.js +2 -0
- package/dist/chunk-br9jax0b.js +2 -0
- package/dist/chunk-f9gzb0a5.js +3 -0
- package/dist/chunk-genwkevp.js +3 -0
- package/dist/chunk-jj3s4ctf.js +62 -0
- package/dist/chunk-mz87cw2e.js +2 -0
- package/dist/engine/build.d.ts +26 -0
- package/dist/engine/color-modifier.d.ts +8 -0
- package/dist/engine/config.d.ts +5 -0
- package/dist/engine/format.d.ts +20 -0
- package/dist/engine/generator.d.ts +14 -0
- package/dist/engine/index.d.ts +13 -0
- package/dist/engine/index.js +653 -0
- package/dist/engine/parser.d.ts +68 -0
- package/dist/engine/plugin.d.ts +22 -0
- package/dist/engine/preflight-forms.d.ts +6 -0
- package/dist/engine/preflight.d.ts +3 -0
- package/dist/engine/rules-advanced.d.ts +27 -0
- package/dist/engine/rules-effects.d.ts +35 -0
- package/dist/engine/rules-forms.d.ts +8 -0
- package/dist/engine/rules-grid.d.ts +13 -0
- package/dist/engine/rules-icons.d.ts +2 -0
- package/dist/engine/rules-interactivity.d.ts +41 -0
- package/dist/engine/rules-layout.d.ts +28 -0
- package/dist/engine/rules-transforms.d.ts +35 -0
- package/dist/engine/rules-typography.d.ts +47 -0
- package/dist/engine/rules.d.ts +56 -0
- package/dist/engine/scanner.d.ts +16 -0
- package/dist/engine/style/api.d.ts +95 -0
- package/dist/engine/style/collect.d.ts +10 -0
- package/dist/engine/style/evaluate.d.ts +11 -0
- package/dist/engine/style/hash.d.ts +15 -0
- package/dist/engine/style/index.d.ts +56 -0
- package/dist/engine/style/plugin.d.ts +27 -0
- package/dist/engine/style/priority.d.ts +12 -0
- package/dist/engine/style/registry.d.ts +56 -0
- package/dist/engine/style/types.d.ts +54 -0
- package/dist/engine/style/value.d.ts +15 -0
- package/dist/engine/transformer-compile-class.d.ts +34 -0
- package/dist/engine/types.d.ts +156 -0
- package/dist/index.js +1 -60
- package/dist/optimize/index.js +1 -1
- package/dist/parse/index.js +1 -1
- package/dist/parse/list.d.ts +1 -1
- package/dist/select/index.js +1 -1
- package/dist/what/index.js +1 -1
- package/package.json +35 -19
- package/dist/chunk-1kmkypmr.js +0 -3
- package/dist/chunk-2wsah70r.js +0 -2
- package/dist/chunk-9ep6bwwb.js +0 -2
- package/dist/chunk-edwg811g.js +0 -2
- package/dist/chunk-thy3p95k.js +0 -3
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u}from"./chunk-genwkevp.js";var N={};u(N,{List:()=>t,TokenType:()=>b,Tokenizer:()=>d,clone:()=>y,decodeName:()=>x,generate:()=>e,makeList:()=>T,parse:()=>o,walk:()=>n});function _(r){return{prev:null,next:null,data:r}}class t{head=null;tail=null;cursors=[];allocateCursor(r,s){let i={prev:r,next:s};return this.cursors.push(i),i}releaseCursor(){this.cursors.pop()}updateCursors(r,s,i,a){for(let l of this.cursors){if(l.prev===r)l.prev=s;if(l.next===i)l.next=a}}static createItem(r){return _(r)}createItem(r){return _(r)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let r=this.head;r!=null;r=r.next)yield r.data}fromArray(r){let s=null;this.head=null;for(let i of r){let a=_(i);if(a.prev=s,s)s.next=a;else this.head=a;s=a}return this.tail=s,this}toArray(){let r=[];for(let s=this.head;s!=null;s=s.next)r.push(s.data);return r}toJSON(){return this.toArray()}forEach(r,s){let i=this.allocateCursor(null,this.head);while(i.next!==null){let a=i.next;i.prev=a,i.next=a.next,r.call(s,a.data,a,this)}this.releaseCursor()}forEachRight(r,s){let i=this.allocateCursor(this.tail,null);while(i.prev!==null){let a=i.prev;i.next=a,i.prev=a.prev,r.call(s,a.data,a,this)}this.releaseCursor()}reduce(r,s){let i=s,a=0;for(let l=this.head;l!=null;l=l.next)i=r(i,l.data,a++,this);return i}some(r){let s=0;for(let i=this.head;i!=null;i=i.next)if(r(i.data,s++,this))return!0;return!1}map(r){let s=new t,i=null,a=0;for(let l=this.head;l!=null;l=l.next){let c=_(r(l.data,a++,this));if(c.prev=i,i)i.next=c;else s.head=c;i=c}return s.tail=i,s}filter(r){let s=new t,i=null,a=0;for(let l=this.head;l!=null;l=l.next)if(r(l.data,a++,this)){let c=_(l.data);if(c.prev=i,i)i.next=c;else s.head=c;i=c}return s.tail=i,s}clear(){let r=this.head;while(r){let s=r.next;r.prev=null,r.next=null,r=s}this.head=null,this.tail=null}copy(){let r=new t,s=null;for(let i=this.head;i!=null;i=i.next){let a=_(i.data);if(a.prev=s,s)s.next=a;else r.head=a;s=a}return r.tail=s,r}prepend(r){return this.insert(r,this.head)}prependData(r){return this.insert(_(r),this.head)}append(r){return this.insert(r,null)}appendData(r){return this.insert(_(r),null)}insert(r,s=null){if(s!=null)if(this.updateCursors(s.prev,r,s,r),s.prev===null){if(this.head!==s)throw Error("before doesn't belong to list");this.head=r,s.prev=r,r.next=s,this.updateCursors(null,r,null,null)}else s.prev.next=r,r.prev=s.prev,s.prev=r,r.next=s;else if(this.updateCursors(this.tail,r,null,r),this.tail!==null)this.tail.next=r,r.prev=this.tail,this.tail=r;else this.head=r,this.tail=r;return this}insertData(r,s=null){return this.insert(_(r),s)}remove(r){if(this.updateCursors(r,r.prev,r,r.next),r.prev!==null)r.prev.next=r.next;else if(this.head===r)this.head=r.next;else throw Error("item doesn't belong to list");if(r.next!==null)r.next.prev=r.prev;else if(this.tail===r)this.tail=r.prev;else throw Error("item doesn't belong to list");return r.prev=null,r.next=null,r}push(r){this.insert(_(r),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(r){this.prependData(r)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(r){return this.insertList(r,this.head)}appendList(r){return this.insertList(r,null)}insertList(r,s=null){if(r.head===null)return this;if(s!==null){if(this.updateCursors(s.prev,r.tail,s,r.head),s.prev!==null)s.prev.next=r.head,r.head.prev=s.prev;else this.head=r.head;s.prev=r.tail,r.tail.next=s}else{if(this.updateCursors(this.tail,r.tail,null,r.head),this.tail!==null)this.tail.next=r.head,r.head.prev=this.tail;else this.head=r.head;this.tail=r.tail}return r.head=null,r.tail=null,this}replace(r,s){if(s instanceof t)this.insertList(s,r),this.remove(r);else this.insert(s,r),this.remove(r)}}function T(){return new t}function y(r){return G(r)}function G(r){if(r===null||typeof r!=="object")return r;if(r instanceof t){let i=new t;for(let a of r)i.appendData(G(a));return i}if(Array.isArray(r))return r.map(G);if("type"in r&&typeof r.type==="string"){let i={type:r.type};for(let a of Object.keys(r)){if(a==="type")continue;i[a]=G(r[a])}return i}let s={};for(let i of Object.keys(r))s[i]=G(r[i]);return s}function e(r){switch(r.type){case"StyleSheet":return O(r.children,"");case"Rule":return`${e(r.prelude)}{${e(r.block)}}`;case"Block":return ve(r.children);case"Atrule":{let s=`@${r.name}`;if(r.prelude){let i=e(r.prelude);if(i)s+=` ${i}`}if(r.block)s+=`{${e(r.block)}}`;else s+=";";return s}case"AtrulePrelude":return O(r.children,"");case"SelectorList":return O(r.children,",");case"Selector":return O(r.children,"");case"TypeSelector":return r.name;case"IdSelector":return`#${r.name}`;case"ClassSelector":return`.${r.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let s=`[${r.name.name}`;if(r.matcher&&r.value)if(s+=r.matcher,r.value.type==="String")s+=`"${ne(r.value.value)}"`;else s+=r.value.name;if(r.flags)s+=` ${r.flags}`;return s+="]",s}case"PseudoClassSelector":return r.children?`:${r.name}(${O(r.children,"")})`:`:${r.name}`;case"PseudoElementSelector":return r.children?`::${r.name}(${O(r.children,"")})`:`::${r.name}`;case"Combinator":return r.name===" "?" ":r.name;case"Declaration":return`${r.property}:${e(r.value)}${r.important?"!important":""}`;case"DeclarationList":return O(r.children,";");case"Value":return O(r.children,"");case"Identifier":return r.name;case"Number":return r.value;case"Percentage":return`${r.value}%`;case"Dimension":return r.value+r.unit;case"String":return`"${ne(r.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(r.value)?`url("${ne(r.value)}")`:`url(${r.value})`;case"Hash":return`#${r.name}`;case"Operator":return r.value;case"Function":return`${r.name}(${O(r.children,"")})`;case"Parentheses":return`(${O(r.children,"")})`;case"Brackets":return`[${O(r.children,"")}]`;case"Raw":return r.value;case"Comment":return r.value.startsWith("!")?`/*${r.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let s=r.a??"",i=r.b??"";if(s&&i){let a=Number(i);return`${s==="1"?"":s==="-1"?"-":s}n${a>=0?`+${i}`:i}`}if(s)return`${s==="1"?"":s==="-1"?"-":s}n`;return i}case"Ratio":return`${r.left.value}/${r.right.value}`;case"UnicodeRange":return r.value;case"Nth":return r.selector?`${e(r.nth)} of ${e(r.selector)}`:e(r.nth);case"MediaQueryList":return O(r.children,",");case"MediaQuery":return O(r.children,"");case"MediaFeature":{let s=`(${r.name}`;if(r.value)s+=`:${e(r.value)}`;return s+=")",s}}return""}function O(r,s){let i="",a=!0,l=null,c=r.head;while(c!=null){let p=c.data;if(p.type==="WhiteSpace"){let h=c.next?c.next.data:null;if(fe(l)||fe(h)){c=c.next;continue}}let f=e(p);if(!f){c=c.next;continue}if(!a&&s&&!De(l))i+=s;a=!1,i+=f,l=p,c=c.next}return i}function ve(r){let s="",i=null,a=r.head;while(a!=null){let l=a.data,c=e(l);if(!c){a=a.next;continue}if(i&&Ee(i,l))s+=";";s+=c,i=l,a=a.next}return s}function Ee(r,s){return r.type==="Declaration"&&s.type!=="Comment"}function fe(r){if(!r||r.type!=="Operator")return!1;let s=r.value;return s===":"||s===","||s==="/"}function De(r){if(!r)return!1;return r.type==="Operator"||r.type==="Combinator"}function ne(r){let s="";for(let i=0;i<r.length;i++){let a=r.charCodeAt(i);if(a===92)s+="\\\\";else if(a===34)s+="\\\"";else if(a<32||a===127){let l=a.toString(16),c=i+1<r.length?r.charCodeAt(i+1):-1,p=c===32||c===9||c===10||c===12||c===13||c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102;s+=`\\${l}${p?" ":""}`}else s+=r[i]}return s}var b;((C)=>{C[C.EOF=0]="EOF";C[C.Ident=1]="Ident";C[C.Function=2]="Function";C[C.AtKeyword=3]="AtKeyword";C[C.Hash=4]="Hash";C[C.String=5]="String";C[C.BadString=6]="BadString";C[C.Url=7]="Url";C[C.BadUrl=8]="BadUrl";C[C.Delim=9]="Delim";C[C.Number=10]="Number";C[C.Percentage=11]="Percentage";C[C.Dimension=12]="Dimension";C[C.WhiteSpace=13]="WhiteSpace";C[C.CDO=14]="CDO";C[C.CDC=15]="CDC";C[C.Colon=16]="Colon";C[C.Semicolon=17]="Semicolon";C[C.Comma=18]="Comma";C[C.LeftSquareBracket=19]="LeftSquareBracket";C[C.RightSquareBracket=20]="RightSquareBracket";C[C.LeftParenthesis=21]="LeftParenthesis";C[C.RightParenthesis=22]="RightParenthesis";C[C.LeftCurlyBracket=23]="LeftCurlyBracket";C[C.RightCurlyBracket=24]="RightCurlyBracket";C[C.Comment=25]="Comment"})(b||={});var H=(()=>{let r=new Uint8Array(128);for(let s=0;s<128;s++){let i=0;if(s===32||s===9||s===10||s===12||s===13)i|=1;if(s>=48&&s<=57)i|=2;if(s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102)i|=4;if(s>=65&&s<=90||s>=97&&s<=122||s===95)i|=8;if(s===10||s===12||s===13)i|=16;r[s]=i}return r})();function V(r){return r<128&&(H[r]&2)!==0}function X(r){return r<128&&(H[r]&4)!==0}function me(r){return r>=128||r<128&&(H[r]&8)!==0}function Re(r){return r===45||r>=128||r<128&&(H[r]&10)!==0}function Ie(r){return r>=0&&r<=8||r===11||r>=14&&r<=31||r===127}function oe(r){return r<128&&(H[r]&16)!==0}function M(r){return r<128&&(H[r]&1)!==0}function j(r,s){if(r!==92)return!1;if(oe(s))return!1;return!0}function re(r,s,i){if(r===45)return me(s)||s===45||j(s,i);if(me(r))return!0;if(r===92)return j(r,s);return!1}function Fe(r,s,i){if(r===43||r===45){if(V(s))return!0;if(s===46&&V(i))return!0;return!1}if(r===46)return V(s);return V(r)}class d{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(r){this.source=r;let s=Math.max(64,Math.ceil(r.length/3));this.types=new Uint8Array(s),this.starts=new Uint32Array(s),this.ends=new Uint32Array(s),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=Be(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let r=Array.from({length:this.count});for(let s=0;s<this.count;s++)r[s]={type:this.types[s],start:this.starts[s],end:this.ends[s]};return this._tokens=r,r}addToken(r,s,i){if(this.count>=this.types.length)this.grow();this.types[this.count]=r,this.starts[this.count]=s,this.ends[this.count]=i,this.count++}grow(){let s=this.types.length*2,i=new Uint8Array(s);i.set(this.types),this.types=i;let a=new Uint32Array(s);a.set(this.starts),this.starts=a;let l=new Uint32Array(s);l.set(this.ends),this.ends=l}tokenize(){let r=this.source,s=0,i=r.length;while(s<i){let a=r.charCodeAt(s);if(a===47&&r.charCodeAt(s+1)===42){let p=s;s+=2;while(s<i&&!(r.charCodeAt(s)===42&&r.charCodeAt(s+1)===47))s++;s=s<i?s+2:i,this.addToken(25,p,s);continue}if(M(a)){let p=s;while(s<i&&M(r.charCodeAt(s)))s++;this.addToken(13,p,s);continue}if(a===34||a===39){s=this.consumeString(a,s);continue}if(a===35){if(s+1<i&&(Re(r.charCodeAt(s+1))||j(r.charCodeAt(s+1),r.charCodeAt(s+2)))){let p=s;s++,s=this.consumeName(s),this.addToken(4,p,s);continue}this.addToken(9,s,s+1),s++;continue}switch(a){case 40:this.addToken(21,s,s+1),s++;continue;case 41:this.addToken(22,s,s+1),s++;continue;case 91:this.addToken(19,s,s+1),s++;continue;case 93:this.addToken(20,s,s+1),s++;continue;case 123:this.addToken(23,s,s+1),s++;continue;case 125:this.addToken(24,s,s+1),s++;continue;case 44:this.addToken(18,s,s+1),s++;continue;case 58:this.addToken(16,s,s+1),s++;continue;case 59:this.addToken(17,s,s+1),s++;continue}if(a===60&&r.startsWith("!--",s+1)){this.addToken(14,s,s+4),s+=4;continue}if(a===45&&r.startsWith("->",s+1)){this.addToken(15,s,s+3),s+=3;continue}if(a===64){let p=r.charCodeAt(s+1),f=r.charCodeAt(s+2),h=r.charCodeAt(s+3);if(re(p,f,h)){let S=s;s++,s=this.consumeName(s),this.addToken(3,S,s);continue}this.addToken(9,s,s+1),s++;continue}let l=r.charCodeAt(s+1),c=r.charCodeAt(s+2);if(Fe(a,l,c)){s=this.consumeNumeric(s);continue}if(re(a,l,c)){s=this.consumeIdentLike(s);continue}if(a===92){if(j(a,l)){s=this.consumeIdentLike(s);continue}this.addToken(9,s,s+1),s++;continue}this.addToken(9,s,s+1),s++}this.addToken(0,i,i)}consumeString(r,s){let i=this.source,a=i.length,l=s+1;while(l<a){let c=i.charCodeAt(l);if(c===r)return l++,this.addToken(5,s,l),l;if(oe(c))return this.addToken(6,s,l),l;if(c===92){let p=i.charCodeAt(l+1);if(oe(p)){l+=2;continue}if(l+1<a){l=this.consumeEscapeSkip(l+1);continue}}l++}return this.addToken(5,s,l),l}consumeEscapeSkip(r){let s=this.source;if(r>=s.length)return r;let i=s.charCodeAt(r);if(X(i)){let a=1;r++;while(a<6&&r<s.length&&X(s.charCodeAt(r)))r++,a++;if(r<s.length&&M(s.charCodeAt(r)))r++;return r}return r+1}consumeName(r){let s=this.source,i=s.length,a=r;while(a<i){let l=s.charCodeAt(a);if(l<128&&(H[l]&10)!==0){a++;continue}if(l===45){a++;continue}if(l>=128){a++;continue}if(l===92&&j(l,s.charCodeAt(a+1))){a=this.consumeEscapeSkip(a+1);continue}break}return a}consumeNumber(r){let s=this.source,i=r;if(s.charCodeAt(i)===43||s.charCodeAt(i)===45)i++;while(i<s.length&&V(s.charCodeAt(i)))i++;if(s.charCodeAt(i)===46&&V(s.charCodeAt(i+1))){i+=2;while(i<s.length&&V(s.charCodeAt(i)))i++}let a=s.charCodeAt(i);if(a===69||a===101){let l=s.charCodeAt(i+1),c=s.charCodeAt(i+2);if(V(l)){i+=2;while(i<s.length&&V(s.charCodeAt(i)))i++}else if((l===43||l===45)&&V(c)){i+=3;while(i<s.length&&V(s.charCodeAt(i)))i++}}return i}consumeNumeric(r){let s=this.source,i=this.consumeNumber(r),a=s.charCodeAt(i),l=s.charCodeAt(i+1),c=s.charCodeAt(i+2);if(re(a,l,c)){let p=this.consumeName(i);return this.addToken(12,r,p),p}if(a===37)return this.addToken(11,r,i+1),i+1;return this.addToken(10,r,i),i}consumeIdentLike(r){let s=this.source,i=this.consumeName(r),a=s.charCodeAt(i);if(a===40&&i-r===3){let l=s.charCodeAt(r)|32,c=s.charCodeAt(r+1)|32,p=s.charCodeAt(r+2)|32;if(l===117&&c===114&&p===108){let f=i+1;while(f<s.length&&M(s.charCodeAt(f)))f++;let h=s.charCodeAt(f);if(h===34||h===39)return this.addToken(2,r,i+1),i+1;return this.consumeUrl(r,i)}}if(a===40)return this.addToken(2,r,i+1),i+1;return this.addToken(1,r,i),i}consumeUrl(r,s){let i=this.source,a=i.length,l=s+1;while(l<a&&M(i.charCodeAt(l)))l++;while(l<a){let c=i.charCodeAt(l);if(c===41)return l++,this.addToken(7,r,l),l;if(M(c)){let p=l;while(l<a&&M(i.charCodeAt(l)))l++;if(l>=a)return this.addToken(7,r,l),l;if(i.charCodeAt(l)===41)return l++,this.addToken(7,r,l),l;return this.consumeBadUrl(r,p)}if(c===34||c===39||c===40||Ie(c))return this.consumeBadUrl(r,l);if(c===92){if(j(c,i.charCodeAt(l+1))){l=this.consumeEscapeSkip(l+1);continue}return this.consumeBadUrl(r,l)}l++}return this.addToken(7,r,l),l}consumeBadUrl(r,s){let i=this.source,a=s;while(a<i.length){let l=i.charCodeAt(a);if(l===41){a++;break}if(l===92&&j(l,i.charCodeAt(a+1))){a=this.consumeEscapeSkip(a+1);continue}a++}return this.addToken(8,r,a),a}locate(r){let s=this.lineStarts,i=0,a=s.length-1;while(i<a){let c=i+a+1>>1;if(s[c]<=r)i=c;else a=c-1}let l=s[i];return{line:i+1,column:r-l+1}}}function Be(r){let s=[0],i=r.length;for(let a=0;a<i;a++){let l=r.charCodeAt(a);if(l===10)s.push(a+1);else if(l===13){if(r.charCodeAt(a+1)!==10)s.push(a+1)}}return s}function se(r,s,i){for(let a=s;a<i;a++)if(r.charCodeAt(a)===92)return Oe(r,s,i,a);return r.slice(s,i)}function Oe(r,s,i,a){let l=r.slice(s,a),c=a;while(c<i){if(r.charCodeAt(c)!==92){l+=r[c],c++;continue}if(c+1>=i){c++;continue}let f=r.charCodeAt(c+1);if(f===10){c+=2;continue}if(f===13){c+=r.charCodeAt(c+2)===10?3:2;continue}if(X(f)){let h=c+1,S="";while(S.length<6&&h<i&&X(r.charCodeAt(h)))S+=r[h],h++;let P=Number.parseInt(S,16);if(h<i&&M(r.charCodeAt(h)))h++;l+=P===0||P>=55296&&P<=57343||P>1114111?String.fromCodePoint(65533):String.fromCodePoint(P),c=h;continue}l+=r[c+1],c+=2}return l}function x(r,s,i){for(let a=s;a<i;a++)if(r.charCodeAt(a)===92)return We(r,s,i,a);return r.slice(s,i)}function We(r,s,i,a){let l=r.slice(s,a),c=a;while(c<i){if(r.charCodeAt(c)!==92){l+=r[c],c++;continue}let f=c+1,h="";while(h.length<6&&f<i&&X(r.charCodeAt(f)))h+=r[f],f++;if(h.length>0){let S=Number.parseInt(h,16);if(f<i&&M(r.charCodeAt(f)))f++;l+=S===0||S>=55296&&S<=57343||S>1114111?String.fromCodePoint(65533):String.fromCodePoint(S),c=f;continue}if(f<i){l+=r[f],c=f+1;continue}l+=String.fromCodePoint(65533),c=f}return l}function ge(r,s){let i=new d(r);return{source:r,types:i.types,starts:i.starts,ends:i.ends,count:i.count,end:i.count,pos:0,positions:s.positions??!1,filename:s.filename,parseValue:s.parseValue??!0,parseAtrulePrelude:s.parseAtrulePrelude??!0,parseCustomProperty:s.parseCustomProperty??!1,parseRulePrelude:s.parseRulePrelude??!0,onParseError:s.onParseError,tokenizer:i}}function k(r){return r.pos<r.end?r.types[r.pos]:0}function g(r){let s=r.pos;if(s>=r.end)return{type:0,start:r.starts[s]??r.source.length,end:r.ends[s]??r.source.length};return{type:r.types[s],start:r.starts[s],end:r.ends[s]}}function A(r){let s=r.pos++;if(s>=r.end)return{type:0,start:r.starts[s]??r.source.length,end:r.ends[s]??r.source.length};return{type:r.types[s],start:r.starts[s],end:r.ends[s]}}function q(r,s){return r.source.slice(s.start,s.end)}function z(r){let{types:s,end:i}=r;while(r.pos<i){let a=s[r.pos];if(a===13||a===25)r.pos++;else break}}function ye(r){let{types:s,end:i}=r;while(r.pos<i&&s[r.pos]===13)r.pos++}function L(r,s,i){if(!r.positions)return null;let a=r.tokenizer.locate(s.start),l=r.tokenizer.locate(i.end);return{source:r.filename??"<unknown>",start:{offset:s.start,line:a.line,column:a.column},end:{offset:i.end,line:l.line,column:l.column}}}function Ae(r){if(!r.positions)return null;let s=g(r),i=r.tokenizer.locate(s.start);return{source:r.filename??"<unknown>",start:{offset:s.start,line:i.line,column:i.column},end:{offset:s.start,line:i.line,column:i.column}}}function Y(r,s,i,a){return{type:"Raw",value:r,loc:L(a,s,i)}}function I(){return new t}function ie(r,s,i,a){if(r.onParseError){let{line:l,column:c}=r.tokenizer.locate(i.start),p=SyntaxError(`${r.filename??"<input>"}:${l}:${c}: ${s}`);p.line=l,p.column=c,p.offset=i.start,r.onParseError(p,a)}return a}function o(r,s={}){let i=ge(r,s);switch(s.context??"stylesheet"){case"stylesheet":return ke(i);case"atrule":return ee(i)??Ce(i);case"atrulePrelude":return Ve(i);case"mediaQuery":case"mediaQueryList":return Se(i);case"rule":return le(i);case"selectorList":return de(i);case"selector":return Le(i);case"block":return ce(i);case"declarationList":return qe(i);case"declaration":return ue(i)??Ce(i);case"value":return Me(i);case"raw":return Se(i);default:return ke(i)}}function Ce(r){return{type:"StyleSheet",children:I(),loc:Ae(r)}}function Se(r){let s=g(r),i=s;while(k(r)!==0)i=A(r);return{type:"Raw",value:r.source.slice(s.start,i.end),loc:L(r,s,i)}}function ke(r){let s=g(r),i=I(),{types:a,end:l}=r;while(r.pos<l){let f=a[r.pos];if(f===13){r.pos++;continue}if(f===25){let P={type:25,start:r.starts[r.pos],end:r.ends[r.pos]},m=ae(r,P);r.pos++,i.appendData(m);continue}if(f===0)break;if(f===14||f===15){r.pos++;continue}if(f===3){let P=ee(r);if(P)i.appendData(P);continue}if(f===24){r.pos++;continue}let h=r.pos,S=le(r);if(i.appendData(S),r.pos===h)r.pos++}let c=r.end-1,p=c>=0?{type:r.types[c],start:r.starts[c],end:r.ends[c]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:i,loc:L(r,s,p)}}function ae(r,s){return{type:"Comment",value:r.source.slice(s.start+2,s.end-2),loc:L(r,s,s)}}function ee(r){let s=g(r);if(s.type!==3)return null;r.pos++;let i=Z(r.source,s.start+1,s.end);z(r);let a=r.pos,l=g(r),{types:c,end:p}=r,f=a,h=a;while(f<p){let m=c[f];if(m===0||m===17||m===23)break;if(m!==13&&m!==25)h=f+1;f++}let S=null;if(h>a){let m=r.starts[a],w=r.ends[h-1],v={type:c[h-1],start:r.starts[h-1],end:w},U=r.source.slice(m,w).trim();if(U.length>0)if(r.parseAtrulePrelude)try{let J=r.end;r.end=h,r.pos=a;let W=I();while(k(r)!==0){let Q=K(r);if(Q)W.appendData(Q)}if(Pe(W),r.end=J,r.pos=f,W.isEmpty)S=Y(U,l,v,r);else S={type:"AtrulePrelude",children:W,loc:null}}catch(J){let W=Y(U,l,v,r);ie(r,`Failed to parse @${i} prelude: ${J.message}`,l,W),S=W,r.pos=f}else S=Y(U,l,v,r),r.pos=f;else r.pos=f}else r.pos=f;let P=null;if(k(r)===17)A(r);else if(k(r)===23)P=ce(r,Ue.has(i));return{type:"Atrule",name:i,prelude:S,block:P,loc:L(r,s,g(r))}}var $e=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),Ue=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function Ve(r){let s=g(r),i=I();while(k(r)!==0){if(g(r).type===13){r.pos++;continue}let l=K(r);if(l)i.appendData(l)}return{type:"AtrulePrelude",children:i,loc:L(r,s,g(r))}}function le(r){let s=g(r),i;if(r.parseRulePrelude)i=de(r);else{let l=g(r),c=l;while(k(r)!==0&&k(r)!==23)c=A(r);let p=r.source.slice(l.start,c.end).trim();i=Y(p,l,c,r)}let a=ce(r,!0);return{type:"Rule",prelude:i,block:a,loc:L(r,s,g(r))}}function ce(r,s=!1){let i=g(r);if(k(r)!==23)return{type:"Block",children:I(),loc:Ae(r)};r.pos++;let a=I(),{types:l,end:c}=r;while(r.pos<c){let p=l[r.pos];if(p===24||p===0)break;if(p===13){r.pos++;continue}if(p===25){let h={type:25,start:r.starts[r.pos],end:r.ends[r.pos]};r.pos++,a.appendData(ae(r,h));continue}if(p===3){let h=ee(r);if(h)a.appendData(h);continue}if(s&&ze(r,_e)){let h=le(r);a.appendData(h);continue}let f=ue(r);if(f)a.appendData(f);if(r.pos<c&&l[r.pos]===17)r.pos++}if(k(r)===24)r.pos++;return{type:"Block",children:a,loc:L(r,i,g(r))}}function ze(r,s){let i=r.pos,a=s(r);return r.pos=i,a}function _e(r){let{types:s,end:i}=r;while(r.pos<i){let a=s[r.pos];if(a===23)return!0;if(a===17||a===24||a===0)return!1;r.pos++}return!1}function qe(r){let s=g(r),i=I();while(k(r)!==0&&k(r)!==24){let a=g(r);if(a.type===13){r.pos++;continue}if(a.type===25){i.appendData(ae(r,A(r)));continue}if(a.type===17){r.pos++;continue}if(a.type===3){let c=ee(r);if(c)i.appendData(c);continue}let l=ue(r);if(l)i.appendData(l);if(k(r)===17)A(r)}return{type:"DeclarationList",children:i,loc:L(r,s,g(r))}}function ue(r){z(r);let s=g(r);if(s.type!==1&&s.type!==4&&!(s.type===9&&r.source[s.start]==="*"&&r.source[s.start+1]===" "))if(s.type===9&&r.source[s.start]==="*")r.pos++;else{ie(r,"Expected property name",s,{type:"Raw",value:"",loc:null});let{types:F,end:B}=r;while(r.pos<B){let D=F[r.pos];if(D===0||D===17||D===24)break;r.pos++}return null}let i=r.starts[r.pos],a=r.ends[r.pos];r.pos++;let l=r.source.slice(i,a);if(ye(r),k(r)!==16){ie(r,`Expected ':' after property "${l}"`,g(r),{type:"Raw",value:"",loc:null});let{types:F,end:B}=r;while(r.pos<B){let D=F[r.pos];if(D===0||D===17||D===24)break;r.pos++}return null}r.pos++,ye(r);let{types:c,starts:p,end:f,pos:h}=r,S=h,P=h,m=-1,w=-1;while(S<f){let F=c[S];if(F===0||F===17||F===24)break;if(F===9&&r.source.charCodeAt(p[S])===33){let B=S+1;while(B<f&&c[B]===13)B++;if(B<f&&c[B]===1){let D=p[B];if(r.ends[B]-D===9&&(r.source.charCodeAt(D)|32)===105&&(r.source.charCodeAt(D+1)|32)===109&&(r.source.charCodeAt(D+2)|32)===112&&(r.source.charCodeAt(D+3)|32)===111&&(r.source.charCodeAt(D+4)|32)===114&&(r.source.charCodeAt(D+5)|32)===116&&(r.source.charCodeAt(D+6)|32)===97&&(r.source.charCodeAt(D+7)|32)===110&&(r.source.charCodeAt(D+8)|32)===116){w=S,m=B,S=B+1;continue}}}if(F!==13&&F!==25)P=S+1;S++}let v=P,U=m>=0?{type:1,start:p[m],end:r.ends[m]}:null,J=l.startsWith("--"),W,Q=p[h],pe=v>h?r.ends[v-1]:Q,te={type:c[h],start:Q,end:r.ends[h]},he=v>h?{type:c[v-1],start:p[v-1],end:pe}:te;if(J&&!r.parseCustomProperty||!r.parseValue)W={type:"Raw",value:r.source.slice(Q,pe).trim(),loc:L(r,te,he)};else if(v===h)W={type:"Value",children:I(),loc:L(r,te,he)};else{let F=r.end;r.end=v,r.pos=h,W=Ne(r),r.end=F}return r.pos=S,{type:"Declaration",property:l,important:U?!0:!1,value:W,loc:L(r,s,g(r))}}function Me(r){return Ne(r)}function Ne(r){let s=g(r),i=I();while(k(r)!==0&&k(r)!==17&&k(r)!==24&&k(r)!==22&&k(r)!==20){let a=K(r);if(a)i.appendData(a)}return xe(i),{type:"Value",children:i,loc:L(r,s,g(r))}}function Pe(r){for(let s of r)if("children"in s&&s.children instanceof t)Pe(s.children);xe(r)}function xe(r){let s=r.head;while(s){if(s.data.type==="Number"){let i=s.next;while(i&&i.data.type==="WhiteSpace")i=i.next;if(i&&i.data.type==="Operator"&&i.data.value==="/"){let a=i.next;while(a&&a.data.type==="WhiteSpace")a=a.next;if(a&&a.data.type==="Number"){let l={type:"Ratio",left:s.data,right:a.data,loc:null},c=s.next;while(c&&c!==a.next){let p=c.next;r.remove(c),c=p}r.replace(s,r.createItem(l)),s=r.head;continue}}}s=s.next}}function K(r){let s=r.pos;if(s>=r.end)return null;let i=r.types[s],a=r.starts[s],l=r.ends[s],c=r.source;switch(i){case 13:return r.pos++,r.positions?{type:"WhiteSpace",value:" ",loc:R(r,a,l)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return r.pos++,{type:"Comment",value:c.slice(a+2,l-2),loc:r.positions?R(r,a,l):null};case 10:return r.pos++,{type:"Number",value:c.slice(a,l),loc:r.positions?R(r,a,l):null};case 11:return r.pos++,{type:"Percentage",value:c.slice(a,l-1),loc:r.positions?R(r,a,l):null};case 12:{r.pos++;let p=a,f=c.charCodeAt(p);if(f===43||f===45)p++;let h=!1;while(p<l){let P=c.charCodeAt(p);if(P>=48&&P<=57){p++;continue}if(P===46&&!h){h=!0,p++;continue}break}let S=c.charCodeAt(p);if(S===69||S===101){let P=p+1,m=c.charCodeAt(P);if(m===43||m===45)P++;let w=!1;while(P<l){let v=c.charCodeAt(P);if(v>=48&&v<=57){P++,w=!0;continue}break}if(w)p=P}return{type:"Dimension",value:c.slice(a,p),unit:c.slice(p,l),loc:r.positions?R(r,a,l):null}}case 1:return r.pos++,{type:"Identifier",name:x(c,a,l),loc:r.positions?R(r,a,l):null};case 5:{r.pos++;let p=a+1,h=l-a>=2&&c.charCodeAt(l-1)===c.charCodeAt(a)?l-1:l;return{type:"String",value:se(c,p,h),loc:r.positions?R(r,a,l):null}}case 7:{r.pos++;let p=a+4;while(p<l&&be(c.charCodeAt(p)))p++;let f=l;if(f>p&&c.charCodeAt(f-1)===41)f--;while(f>p&&be(c.charCodeAt(f-1)))f--;let h;if(f-p>=2){let S=c.charCodeAt(p),P=c.charCodeAt(f-1);if((S===34||S===39)&&S===P)h=c.slice(p+1,f-1);else h=c.slice(p,f)}else h=c.slice(p,f);return{type:"Url",value:h,loc:r.positions?R(r,a,l):null}}case 4:return r.pos++,{type:"Hash",name:c.slice(a+1,l),loc:r.positions?R(r,a,l):null};case 2:return He(r);case 21:return Ke(r);case 18:return r.pos++,{type:"Operator",value:",",loc:r.positions?R(r,a,l):null};case 16:return r.pos++,{type:"Operator",value:":",loc:r.positions?R(r,a,l):null};case 9:{r.pos++;let p=c.charCodeAt(a),f=c[a];if(je(p))return{type:"Operator",value:f,loc:r.positions?R(r,a,l):null};return{type:"Identifier",name:f,loc:r.positions?R(r,a,l):null}}case 19:{r.pos++;let p=I();while(k(r)!==0&&k(r)!==20){let h=K(r);if(h)p.appendData(h)}let f=r.pos<r.end?r.ends[r.pos]:l;if(k(r)===20)r.pos++;return{type:"Brackets",children:p,loc:r.positions?R(r,a,f):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return r.pos++,{type:"Raw",value:c.slice(a,l),loc:r.positions?R(r,a,l):null}}return r.pos++,null}function be(r){return r===32||r===9||r===10||r===12||r===13}function je(r){return r===47||r===43||r===45||r===42||r===61||r===62||r===60||r===126||r===124||r===36||r===94||r===33||r===38}function Z(r,s,i){for(let a=s;a<i;a++){let l=r.charCodeAt(a);if(l>=65&&l<=90)return r.slice(s,i).toLowerCase()}return r.slice(s,i)}function R(r,s,i){let a=r.tokenizer.locate(s),l=r.tokenizer.locate(i);return{source:r.filename??"<unknown>",start:{offset:s,line:a.line,column:a.column},end:{offset:i,line:l.line,column:l.column}}}function He(r){let s=A(r),i=Z(r.source,s.start,s.end-1),a=I();while(k(r)!==0&&k(r)!==22){let l=K(r);if(l)a.appendData(l)}if(k(r)===22)A(r);if(i==="url"){for(let l=a.head;l!=null;l=l.next)if(l.data.type==="String")return{type:"Url",value:l.data.value,loc:L(r,s,g(r))}}return{type:"Function",name:i,children:a,loc:L(r,s,g(r))}}function Ke(r){let s=A(r),i=I();while(k(r)!==0&&k(r)!==22){let a=K(r);if(a)i.appendData(a)}if(k(r)===22)A(r);return{type:"Parentheses",children:i,loc:L(r,s,g(r))}}function de(r){let s=g(r),i=I();while(k(r)!==0){if(z(r),k(r)===0||k(r)===23)break;let a=Le(r);if(a.children.head!==null)i.appendData(a);if(z(r),k(r)===18){A(r);continue}break}return{type:"SelectorList",children:i,loc:L(r,s,g(r))}}function Le(r){let s=g(r),i=I(),a=!0;while(k(r)!==0&&k(r)!==18&&k(r)!==23){let l=g(r);if(l.type===13){if(A(r),!a&&k(r)!==0&&k(r)!==18&&k(r)!==23&&!Te(r)&&!Qe(r)){let p={type:"Combinator",name:" ",loc:L(r,l,l)};i.appendData(p),a=!0}continue}if(l.type===9&&r.source.charCodeAt(l.start)===124&&r.types[r.pos+1]===9&&r.source.charCodeAt(r.starts[r.pos+1])===124){let p=g(r);A(r);let f=A(r),h={type:"Combinator",name:"||",loc:L(r,p,f)};i.appendData(h),a=!0,z(r);continue}if(Te(r)){let p=A(r),h={type:"Combinator",name:r.source[p.start],loc:L(r,p,p)};i.appendData(h),a=!0,z(r);continue}let c=Je(r);if(!c)break;i.appendData(c),a=!1}while(i.tail&&i.tail.data.type==="Combinator")i.remove(i.tail);return{type:"Selector",children:i,loc:L(r,s,g(r))}}function Te(r){let s=g(r);if(s.type!==9)return!1;let i=r.source[s.start];return i===">"||i==="+"||i==="~"}function Qe(r){if(r.types[r.pos]!==9)return!1;if(r.source.charCodeAt(r.starts[r.pos])!==124)return!1;if(r.types[r.pos+1]!==9)return!1;return r.source.charCodeAt(r.starts[r.pos+1])===124}function Je(r){let s=g(r);switch(s.type){case 1:{if(A(r),k(r)===9&&r.source[g(r).start]==="|"&&r.source[g(r).start+1]!=="="&&!(r.types[r.pos+1]===9&&r.source.charCodeAt(r.starts[r.pos+1])===124)){if(A(r),k(r)===1){let a=A(r);return{type:"TypeSelector",name:`${q(r,s)}|${q(r,a)}`,loc:L(r,s,a)}}if(k(r)===9&&r.source[g(r).start]==="*"){let a=A(r);return{type:"TypeSelector",name:`${q(r,s)}|*`,loc:L(r,s,a)}}}return{type:"TypeSelector",name:q(r,s),loc:L(r,s,s)}}case 11:return A(r),{type:"TypeSelector",name:q(r,s),loc:L(r,s,s)};case 10:return A(r),{type:"TypeSelector",name:q(r,s),loc:L(r,s,s)};case 9:{let i=r.source[s.start];if(i==="*")return A(r),{type:"TypeSelector",name:"*",loc:L(r,s,s)};if(i==="."){if(A(r),k(r)===1){let a=A(r);return{type:"ClassSelector",name:q(r,a),loc:L(r,s,a)}}return null}if(i==="&")return A(r),{type:"NestingSelector",loc:L(r,s,s)};return A(r),null}case 4:return A(r),{type:"IdSelector",name:r.source.slice(s.start+1,s.end),loc:L(r,s,s)};case 16:{A(r);let i=k(r)===16;if(i)A(r);return Ge(r,i,s)}case 19:return Xe(r)}return null}function Ge(r,s,i){let a=g(r);if(a.type===1){A(r);let l=Z(r.source,a.start,a.end);return s?{type:"PseudoElementSelector",name:l,children:null,loc:L(r,i,a)}:{type:"PseudoClassSelector",name:l,children:null,loc:L(r,i,a)}}if(a.type===2){A(r);let l=Z(r.source,a.start,a.end-1),c=I();if(!s&&$e.has(l)){let h=g(r),S=h,P=1;while(k(r)!==0&&P>0){if(k(r)===21||k(r)===2)P++;else if(k(r)===22){if(P--,P===0)break}S=A(r)}if(k(r)===22)A(r);let m=r.source.slice(h.start,S.end).trim();if(m.length>0){let w=ge(m,{positions:!1}),v=de(w);c.appendData(v)}}else{while(k(r)!==0&&k(r)!==22){let h=K(r);if(h)c.appendData(h)}if(k(r)===22)A(r)}if(s)return{type:"PseudoElementSelector",name:l,children:c,loc:L(r,i,g(r))};return{type:"PseudoClassSelector",name:l,children:c,loc:L(r,i,g(r))}}return null}function Xe(r){let s=A(r);z(r);let i=g(r);if(i.type!==1)return null;A(r);let a={type:"Identifier",name:q(r,i),loc:L(r,i,i)};z(r);let l=null,c=null,p=null,f=g(r);if(f.type===9){let S=r.source[f.start],P=r.source[f.start+1];if(S==="=")l="=",A(r);else if((S==="~"||S==="|"||S==="^"||S==="$"||S==="*")&&P==="="){A(r);let v=g(r);if(v.type===9&&r.source[v.start]==="=")A(r),l=`${S}=`}z(r);let m=g(r);if(m.type===5){A(r);let v=m.end-m.start>=2&&r.source.charCodeAt(m.end-1)===r.source.charCodeAt(m.start);c={type:"String",value:se(r.source,m.start+1,v?m.end-1:m.end),loc:L(r,m,m)}}else if(m.type===1)A(r),c={type:"Identifier",name:q(r,m),loc:L(r,m,m)};z(r);let w=g(r);if(w.type===1)A(r),p=q(r,w)}z(r);let h=g(r);if(k(r)===20)h=A(r);return{type:"AttributeSelector",name:a,matcher:l,value:c,flags:p,loc:L(r,s,h)}}var we=Symbol("walkSkip"),E=Symbol("walkStop");function Ye(r){return{root:r,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function Ze(r,s){let i=Ye(r),a=typeof s==="function"?s:s.enter,l=typeof s==="function"?null:s.leave??null,c=typeof s==="function"?null:s.visit??null,p=typeof s==="function"?!1:s.reverse??!1;function f(h,S,P){let m=null,w;switch(h.type){case"StyleSheet":m="stylesheet",w=i.stylesheet,i.stylesheet=h;break;case"Atrule":m="atrule",w=i.atrule,i.atrule=h;break;case"AtrulePrelude":m="atrulePrelude",w=i.atrulePrelude,i.atrulePrelude=h;break;case"Rule":m="rule",w=i.rule,i.rule=h;break;case"Selector":m="selector",w=i.selector,i.selector=h;break;case"Block":m="block",w=i.block,i.block=h;break;case"Declaration":m="declaration",w=i.declaration,i.declaration=h;break;case"Function":m="function",w=i.function,i.function=h;break}let v;if((c===null||c===h.type)&&a){let U=a.call(i,h,S,P);if(U===we){if(m)i[m]=w;return}if(U===E){if(m)i[m]=w;return E}}if(v=et(h,p,f),v===E){if(m)i[m]=w;return E}if((c===null||c===h.type)&&l){if(l.call(i,h,S,P)===E){if(m)i[m]=w;return E}}if(m)i[m]=w;return}return f(r,null,null)}var n=Object.assign(Ze,{skip:we,stop:E});function et(r,s,i){if("children"in r&&r.children instanceof t)return tt(r.children,s,i);if(r.type==="Rule"){if(i(r.prelude,null,null)===E)return E;if(i(r.block,null,null)===E)return E;return}if(r.type==="Atrule"){if(r.prelude){if(i(r.prelude,null,null)===E)return E}if(r.block){if(i(r.block,null,null)===E)return E}return}if(r.type==="Declaration")return i(r.value,null,null);if(r.type==="AttributeSelector"){if(i(r.name,null,null)===E)return E;if(r.value)return i(r.value,null,null);return}return}function tt(r,s,i){let a;if(s)r.forEachRight((l,c,p)=>{if(a)return;if(i(l,c,p)===E)a=E});else r.forEach((l,c,p)=>{if(a)return;if(i(l,c,p)===E)a=E});return a}export{t,T,y,e,b,d,x,o,n,N};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CssConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Build CSS from content patterns
|
|
4
|
+
*/
|
|
5
|
+
export declare function build(config: CssConfig): Promise<BuildResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Write CSS to output file
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeCSS(css: string, outputPath: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Write transformed files to disk
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeTransformedFiles(transformedFiles: Map<string, string>): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Build and write CSS to output file
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildAndWrite(config: CssConfig): Promise<BuildResult>;
|
|
18
|
+
export declare interface BuildResult {
|
|
19
|
+
css: string
|
|
20
|
+
classes: Set<string>
|
|
21
|
+
duration: number
|
|
22
|
+
compiledClasses?: Map<string, { className: string, utilities: string[] }>
|
|
23
|
+
transformedFiles?: Map<string, string>
|
|
24
|
+
unmatchedPatterns?: string[]
|
|
25
|
+
styleModules?: string[]
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find an opacity modifier slash without mistaking a slash inside a CSS color
|
|
3
|
+
* function for the utility modifier.
|
|
4
|
+
*
|
|
5
|
+
* `bg-red-500/50` and `bg-[rgb(1_2_3)]/[0.5]` have a top-level modifier,
|
|
6
|
+
* while `bg-[rgb(1_2_3_/_0.5)]` carries its alpha inside `rgb(...)`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function colorModifierSlashIndex(value: string): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value formatting helpers shared by the generator and the rule modules.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Render `num / denom` as a CSS percentage.
|
|
6
|
+
*
|
|
7
|
+
* Plain `(1 / 3) * 100` stringifies to `33.33333333333333%` — sixteen
|
|
8
|
+
* significant digits of float noise in every generated stylesheet, well past
|
|
9
|
+
* any renderer's precision. Tailwind emits six decimals, so match that and
|
|
10
|
+
* drop trailing zeros so exact ratios stay clean (`1/2` → `50%`, not
|
|
11
|
+
* `50.000000%`).
|
|
12
|
+
*
|
|
13
|
+
* Returns undefined for a zero or non-numeric denominator rather than
|
|
14
|
+
* emitting `Infinity%` / `NaN%`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fractionToPercent(num: number, denom: number): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Round to at most 6 decimal places and strip trailing zeros.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatNumber(value: number): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CssConfig } from './types';
|
|
2
|
+
// Exported for tests: ranking is pure and selector-driven, and asserting it
|
|
3
|
+
// through generated CSS would need an @iconify-json collection installed —
|
|
4
|
+
// without one an icon emits nothing, `indexOf` returns -1, and an ordering
|
|
5
|
+
// assertion passes for the wrong reason.
|
|
6
|
+
export declare function computeUtilityRank(selector: string): number;
|
|
7
|
+
export declare class CSSGenerator {
|
|
8
|
+
constructor(config: CssConfig);
|
|
9
|
+
generateBatch(classNames: string[]): void;
|
|
10
|
+
generate(className: string): void;
|
|
11
|
+
generateCompiledClass(className: string, utilities: string[]): void;
|
|
12
|
+
toCSS(includePreflight?: boolean, minify?: boolean): string;
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './build';
|
|
2
|
+
export * from './config';
|
|
3
|
+
export * from './generator';
|
|
4
|
+
export * from './parser';
|
|
5
|
+
export * from './plugin';
|
|
6
|
+
export * from './preflight';
|
|
7
|
+
export * from './preflight-forms';
|
|
8
|
+
export * from './rules';
|
|
9
|
+
export * from './scanner';
|
|
10
|
+
export * from './style/index';
|
|
11
|
+
export * from './style/collect';
|
|
12
|
+
export * from './style/plugin';
|
|
13
|
+
export * from './types';
|