@stacksjs/ts-css 0.3.23 → 0.3.25
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/bin/cli.js +1 -1
- package/dist/bin/cssx.js +100 -75
- package/dist/{chunk-aj9hxvcm.js → chunk-k6ta54hd.js} +2 -2
- package/dist/{chunk-pmshwcfp.js → chunk-zn8gy7w7.js} +1 -1
- package/dist/engine/generator.d.ts +3 -1
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.js +49 -24
- package/dist/engine/safelist.d.ts +42 -0
- package/dist/engine/stylesheet.d.ts +44 -0
- package/dist/engine/types.d.ts +13 -1
- package/dist/index.js +1 -1
- package/dist/optimize/index.js +1 -1
- package/dist/select/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e,o,n}from"./chunk-8h5zg4ad.js";import{r}from"./chunk-dbj97h19.js";import{c}from"./chunk-vbjv9wf0.js";var A={};c(A,{compressTree:()=>p,dedupeDeclarations:()=>u,minify:()=>h,minifyBlock:()=>a,removeComments:()=>s,specificity:()=>l,specificityToString:()=>S,syntax:()=>
|
|
3
|
-
export{s,u,p,h,a,l,S,
|
|
2
|
+
import{e,o,n}from"./chunk-8h5zg4ad.js";import{r}from"./chunk-dbj97h19.js";import{c}from"./chunk-vbjv9wf0.js";var A={};c(A,{compressTree:()=>p,dedupeDeclarations:()=>u,minify:()=>h,minifyBlock:()=>a,removeComments:()=>s,specificity:()=>l,specificityToString:()=>S,syntax:()=>w});function s(i,t={}){let f=t.exclamation??!1,y=!1;n(i,(m,b,g)=>{if(m.type!=="Comment")return;let d=m.value.startsWith("!");if(f===!0&&d)return;if(f==="first-exclamation"&&d&&!y){y=!0;return}if(b&&g)g.remove(b)})}function u(i){n(i,(t)=>{if(t.type!=="Block"&&t.type!=="DeclarationList")return;if(!("children"in t)||!t.children)return;let f=t.children,y=f.head;if(y==null||y.next==null)return;let m=0;for(let d=y;d!=null;d=d.next)if(d.data.type==="Declaration"){if(m++,m>=2)break}if(m<2)return;let b=new Map,g=[];for(let d=y;d!=null;d=d.next){let x=d.data;if(x.type!=="Declaration")continue;let v=x.property,N=b.get(v);if(N){let z=!!N.decl.important,W=!!x.important;if(W||z===W)g.push(N.item),b.set(v,{item:d,decl:x});else g.push(d)}else b.set(v,{item:d,decl:x})}for(let d of g)f.remove(d)})}var G={black:"#000",fuchsia:"#f0f",white:"#fff",red:"#f00",cyan:"#0ff",blue:"#00f",yellow:"#ff0",magenta:"#f0f",lime:"#0f0",silver:"#c0c0c0",gray:"#808080",maroon:"#800000",olive:"#808000",green:"#008000",purple:"#800080",teal:"#008080",navy:"#000080"},U={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function O(i){if(!i.startsWith("#"))return i;let t=i.slice(1);if(t.length===6){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5])return`#${t[0]}${t[2]}${t[4]}`}if(t.length===8){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&t[6]===t[7])return`#${t[0]}${t[2]}${t[4]}${t[6]}`}return i}function R(i){let t=i.toLowerCase();return G[t]??null}function P(i){let t=i.toLowerCase();return U[t]??null}function X(i,t,f){let y=(i<<16|t<<8|f).toString(16).padStart(6,"0");return O(`#${y}`)}var j=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function T(i){let t=j.exec(i.trim());if(!t)return i;let f=k(t[1]),y=k(t[2]),m=k(t[3]);if(t[4]!==void 0&&!V(t[4]))return i;return X(f,y,m)}function V(i){if(i.endsWith("%"))return Number.parseFloat(i)>=100;return Number.parseFloat(i)>=1}function k(i){if(i.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(i)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(i))))}var Z=new Set(["px","pt","pc","in","cm","mm","q","em","rem","ex","ch","cap","ic","lh","rlh","vw","vh","vi","vb","vmin","vmax","svw","svh","svi","svb","svmin","svmax","lvw","lvh","lvi","lvb","lvmin","lvmax","dvw","dvh","dvi","dvb","dvmin","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"]);function C(i){if(i.charCodeAt(0)===43)i=i.slice(1);if(i.includes(".")){let t=i.replace(/(\.\d*?)0+($|[eE])/,"$1$2");t=t.replace(/\.($|[eE])/,"$1"),i=t}if(i.startsWith("0.")&&i.length>2)i=i.slice(1);else if(i.startsWith("-0.")&&i.length>3)i=`-${i.slice(2)}`;if(i==="-0"||i==="-.0"||i==="-0.0")i="0";return i}function I(i,t){let f=C(i);if((f==="0"||f==="-0")&&Z.has(t.toLowerCase()))return{value:"0",unit:""};return{value:f,unit:t}}function H(i){return C(i)}function _(i,t){let f=Number.parseFloat(i);if(!Number.isFinite(f))return i;let y=t<0?0:t;return f.toFixed(y)}var D=new Set(["color","background","background-color","border","border-color","border-top","border-top-color","border-right","border-right-color","border-bottom","border-bottom-color","border-left","border-left-color","border-block","border-block-color","border-block-start-color","border-block-end-color","border-inline","border-inline-color","border-inline-start-color","border-inline-end-color","outline","outline-color","caret-color","fill","stroke","flood-color","lighting-color","stop-color","column-rule","column-rule-color","text-decoration","text-decoration-color","text-emphasis","text-emphasis-color","text-shadow","box-shadow","accent-color","scrollbar-color"]);function L(i){if(!i||i.type!=="Operator")return!1;let t=i.value;return t===":"||t===","||t==="/"}function J(i){let t=i.children;if(!t)return;while(t.head&&t.head.data.type==="WhiteSpace")t.remove(t.head);while(t.tail&&t.tail.data.type==="WhiteSpace")t.remove(t.tail);let f=t.head;while(f){let y=f.next;if(f.data.type==="WhiteSpace"){let m=f.prev&&L(f.prev.data),b=y&&L(y.data);if(m||b)t.remove(f)}f=y}}function p(i,t={}){let f=t.floatPrecision??null,y=f===null?null:(m)=>_(m,f);n(i,{enter(m,b,g){switch(m.type){case"Number":{let d=y?y(m.value):m.value;m.value=C(d);return}case"Percentage":{let d=y?y(m.value):m.value;m.value=H(d);return}case"Dimension":{let d=y?y(m.value):m.value,x=I(d,m.unit);m.value=x.value,m.unit=x.unit;return}case"Hash":{let d=O(`#${m.name}`).slice(1);if(m.name=d,b&&g&&this.declaration&&D.has(this.declaration.property.toLowerCase())){let x=P(`#${d}`);if(x&&x.length<d.length+1){let v={type:"Identifier",name:x,loc:m.loc};g.replace(b,g.createItem(v))}}return}case"Identifier":{if(!b||!g||!this.declaration)return;if(!D.has(this.declaration.property.toLowerCase()))return;let d=R(m.name);if(d&&d.length<m.name.length){let x={type:"Hash",name:d.slice(1),loc:m.loc};g.replace(b,g.createItem(x))}return}case"Url":return;case"Function":{let d=m.name.toLowerCase();if((d==="rgb"||d==="rgba")&&b&&g)m.__rgbReplaceCandidate=!0}}},leave(m,b,g){if(m.type==="Parentheses"||m.type==="Function"||m.type==="Value")J(m);if(m.type==="Function"&&m.__rgbReplaceCandidate&&b&&g){let d=e(m),x=T(d);if(x!==d&&x.startsWith("#")){let v={type:"Hash",name:x.slice(1),loc:m.loc};g.replace(b,g.createItem(v))}}}})}function h(i,t={}){let f=o(i,{context:"stylesheet"});return E(f,t)}function a(i,t={}){let f=o(i,{context:"declarationList"});return E(f,t)}function E(i,t){if(t.comments===!1)s(i,{exclamation:!1});else if(t.comments==="first-exclamation")s(i,{exclamation:"first-exclamation"});else s(i,{exclamation:!0});return p(i,{floatPrecision:t.floatPrecision??null}),u(i),{css:e(i),ast:i}}function l(i){let t=[0,0,0];if(typeof i==="string"){let f=r(i);return F(f,t),t}if(Array.isArray(i)){if(i.length===0)return t;if(Array.isArray(i[0]))F(i,t);else M(i,t);return t}return q(i,t),t}function q(i,t){switch(i.type){case"IdSelector":t[0]++;return;case"ClassSelector":case"AttributeSelector":t[1]++;return;case"TypeSelector":if(i.name!=="*")t[2]++;return;case"PseudoClassSelector":{let f=i.name.toLowerCase();if(f==="is"||f==="matches"||f==="-moz-any"||f==="-webkit-any"||f==="not"||f==="has"){if(i.children){let y=[];for(let b of i.children)if(b.type==="SelectorList"&&"children"in b&&b.children)for(let g of b.children)y.push(g);else if(b.type==="Selector")y.push(b);let m=[0,0,0];for(let b of y){let g=l(b);if(B(g,m)>0)m=g}t[0]+=m[0],t[1]+=m[1],t[2]+=m[2]}return}if(f==="where")return;t[1]++;return}case"PseudoElementSelector":t[2]++;return;case"Selector":case"SelectorList":case"AtrulePrelude":if("children"in i&&i.children)for(let f of i.children)q(f,t);return;case"NestingSelector":return}}function F(i,t){for(let f of i)M(f,t)}function M(i,t){for(let f of i)switch(f.type){case"tag":if(f.name!=="*")t[2]++;break;case"attribute":if(f.name==="id"&&f.action==="equals")t[0]++;else t[1]++;break;case"pseudo":{let y=f.name.toLowerCase();if(y==="is"||y==="matches"||y==="not"||y==="has"||y==="-moz-any"||y==="-webkit-any"){if(Array.isArray(f.data)){let m=[0,0,0];for(let b of f.data){let g=[0,0,0];if(M(b,g),B(g,m)>0)m=g}t[0]+=m[0],t[1]+=m[1],t[2]+=m[2]}break}if(y==="where")break;t[1]++;break}case"pseudo-element":t[2]++;break}}function B(i,t){for(let f=0;f<3;f++)if(i[f]!==t[f])return i[f]-t[f];return 0}function S(i){return i.join(",")}var w={specificity:l};
|
|
3
|
+
export{s,u,p,h,a,l,S,w,A};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./chunk-dbj97h19.js";import{c}from"./chunk-vbjv9wf0.js";var C={};c(C,{clearSelectorCache:()=>P,compile:()=>g,is:()=>w,parseAndCompile:()=>i,selectAll:()=>v,selectOne:()=>R});function Q(u,o,t,l){let a=[],d=[o],n=[0];for(;;){if(n[0]>=d[0].length){if(d.length===1)return a;d.shift(),n.shift();continue}let e=d[0][n[0]++];if(!t.isTag(e))continue;if(u(e))a.push(e);if(l||t.getName(e)!=="template"){let s=t.getChildren(e);if(s.length>0)d.unshift(s),n.unshift(0)}}}function x(u,o,t,l){let a=[o],d=[0];for(;;){if(d[0]>=a[0].length){if(a.length===1)return null;a.shift(),d.shift();continue}let n=a[0][d[0]++];if(!t.isTag(n))continue;if(u(n))return n;if(l||t.getName(n)!=="template"){let e=t.getChildren(n);if(e.length>0)a.unshift(e),d.unshift(0)}}}function O(u,o){if(Array.isArray(u))return o.removeSubsets(u);return o.getChildren(u)}var y=(u)=>!0;function L(u){return u===32||u===9||u===10||u===12||u===13}function h(u,o){let t=o.length,l=u.length;if(t===0||t>l)return!1;let a=u.indexOf(o);while(a>=0){let d=a===0||L(u.charCodeAt(a-1)),n=a+t,e=n===l||L(u.charCodeAt(n));if(d&&e)return!0;a=u.indexOf(o,a+1)}return!1}function q(u,o,t){if(o.ignoreCase===!0)return!0;if(o.ignoreCase===!1)return!1;if(o.ignoreCase==="quirks")return!t.xmlMode;return!1}function V(u,o,t){let l=o.adapter,{action:a,name:d,value:n}=u,e=q(n,u,o);if(e)n=n.toLowerCase();return D(a,d,n,e,l,t)}function D(u,o,t,l,a,d){let n=d===y;switch(u){case"exists":if(n)return(e)=>a.hasAttrib(e,o);return(e)=>a.hasAttrib(e,o)&&d(e);case"equals":if(!l){if(n)return(e)=>a.getAttributeValue(e,o)===t;return(e)=>a.getAttributeValue(e,o)===t&&d(e)}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase()===t};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase()===t&&d(e)};case"not":return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return d(e);return(l?s.toLowerCase():s)!==t&&d(e)};case"start":if(t==="")return()=>!1;if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).startsWith(t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).startsWith(t)&&d(e)};case"end":if(t==="")return()=>!1;if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).endsWith(t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).endsWith(t)&&d(e)};case"any":{if(t==="")return()=>!1;if(l){if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase().indexOf(t)>=0};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase().indexOf(t)>=0&&d(e)}}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.indexOf(t)>=0};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.indexOf(t)>=0&&d(e)}}case"element":{if(t===""||/\s/.test(t))return()=>!1;if(l){if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s.toLowerCase(),t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s.toLowerCase(),t)&&d(e)}}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s,t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s,t)&&d(e)}}case"hyphen":if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;let f=l?s.toLowerCase():s;if(f===t)return!0;if(f.startsWith(t)&&f.charAt(t.length)==="-")return!0;return!1};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;let f=l?s.toLowerCase():s;if(f===t)return d(e);if(f.startsWith(t)&&f.charAt(t.length)==="-")return d(e);return!1}}return(e)=>!1}var k=new Set(["link","any-link","visited","hover","active","focus","focus-visible","focus-within","target","target-within","enabled","disabled","checked","required","optional","valid","invalid","selected","placeholder-shown","read-only","read-write","in-range","out-of-range","default","indeterminate"]),G=new Set(["is","where","matches","-moz-any","-webkit-any"]),I=new Set(["nth-child","nth-last-child","nth-of-type","nth-last-of-type"]);function W(u,o,t){let l=o.adapter,{name:a,data:d}=u;if(u.type==="pseudo"&&G.has(a)){if(!Array.isArray(d))return t;let n=d.map((e)=>i(e,o));if(n.length===1){let e=n[0];return(s)=>e(s)&&t(s)}return(e)=>{for(let s of n)if(s(e))return t(e);return!1}}if(u.type==="pseudo"&&a==="not"){if(!Array.isArray(d))return t;let n=d.map((e)=>i(e,o));if(n.length===1){let e=n[0];return(s)=>!e(s)&&t(s)}return(e)=>{for(let s of n)if(s(e))return!1;return t(e)}}if(u.type==="pseudo"&&a==="has"){if(!Array.isArray(d))return t;let n=d.map((s)=>i(s,o)),e=n.length===1?n[0]:(s)=>{for(let f of n)if(f(s))return!0;return!1};return(s)=>{let f=l.getChildren(s).slice();while(f.length>0){let m=f.pop();if(!l.isTag(m))continue;if(e(m))return t(s);let p=l.getChildren(m);for(let N=0;N<p.length;N++)f.push(p[N])}return!1}}if(u.type==="pseudo"&&I.has(a)){let n=F(typeof d==="string"?d:"",a,o);return(e)=>n(e)&&t(e)}if(u.type==="pseudo"&&a==="first-child")return(n)=>{let e=l.getSiblings(n);for(let s of e){if(!l.isTag(s))continue;return s===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="last-child")return(n)=>{let e=l.getSiblings(n);for(let s=e.length-1;s>=0;s--){let f=e[s];if(!l.isTag(f))continue;return f===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="first-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n);for(let f of s){if(!l.isTag(f)||l.getName(f)!==e)continue;return f===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="last-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n);for(let f=s.length-1;f>=0;f--){let m=s[f];if(!l.isTag(m)||l.getName(m)!==e)continue;return m===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="only-child")return(n)=>{let e=l.getSiblings(n),s=0,f=!1;for(let m of e){if(!l.isTag(m))continue;if(s++,s>1)return!1;if(m===n)f=!0}return s===1&&f&&t(n)};if(u.type==="pseudo"&&a==="only-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n),f=0,m=!1;for(let p of s){if(!l.isTag(p)||l.getName(p)!==e)continue;if(f++,f>1)return!1;if(p===n)m=!0}return f===1&&m&&t(n)};if(u.type==="pseudo"&&a==="empty")return(n)=>l.getChildren(n).length===0&&t(n);if(u.type==="pseudo"&&a==="root")return(n)=>{let e=l.getParent(n);return(e==null||!l.isTag(e))&&t(n)};if(u.type==="pseudo"&&a==="scope"){if(o.context&&Array.isArray(o.context)){let n=new Set(o.context);return(e)=>n.has(e)&&t(e)}if(o.context){let n=o.context;return(e)=>e===n&&t(e)}return(n)=>{let e=l.getParent(n);return(e==null||!l.isTag(e))&&t(n)}}if(u.type==="pseudo"&&k.has(a)){if(o.pseudos&&o.pseudos[a]){let n=o.pseudos[a];if(typeof n==="function")return(e)=>n(e,void 0)&&t(e)}return(n)=>!1}if(u.type==="pseudo-element")return t;if(o.pseudos&&o.pseudos[a]){let n=o.pseudos[a];if(typeof n==="function")return(e)=>n(e,typeof d==="string"?d:void 0)&&t(e);if(typeof n==="string"){let e=r(n),s=b(e,o);return(f)=>s(f)&&t(f)}}return(n)=>!1}function Y(u){let o=u.trim();if(o==="odd")return{a:2,b:1};if(o==="even")return{a:2,b:0};let t=/^([+-]?\d*)n([+-]\d+)?$/.exec(o.replace(/\s+/g,""));if(t){let a=t[1]===""||t[1]==="+"?1:t[1]==="-"?-1:Number(t[1]),d=t[2]?Number(t[2]):0;return{a,b:d}}let l=Number(o);if(!Number.isNaN(l))return{a:0,b:l};return null}function F(u,o,t){let l=Y(u);if(!l)return()=>!1;let{a,b:d}=l,n=t.adapter,e=o==="nth-of-type"||o==="nth-last-of-type",s=o==="nth-last-child"||o==="nth-last-of-type";return(f)=>{let m=n.getSiblings(f),p=e?n.getName(f):"",N=0,A=0;for(let T of m){if(!n.isTag(T))continue;if(e&&n.getName(T)!==p)continue;if(A++,T===f)N=A}if(N===0)return!1;let S=s?A-N+1:N;if(a===0)return S===d;return(S-d)/a>=0&&(S-d)%a===0}}function M(u,o,t){let l=o.adapter,a=t===y;switch(u.type){case"tag":{let d=o.lowerCaseTags!==!1&&!o.xmlMode?u.name.toLowerCase():u.name;if(a)return(n)=>l.getName(n)===d;return(n)=>l.getName(n)===d&&t(n)}case"universal":return t;case"attribute":return V(u,o,t);case"pseudo":case"pseudo-element":return W(u,o,t);case"descendant":case"child":case"parent":case"sibling":case"adjacent":case"column-combinator":return t}return(d)=>!1}var B={universal:50,tag:30,attribute:1,pseudo:0,"pseudo-element":0},z={exists:10,equals:8,not:7,start:6,end:6,hyphen:5,any:4,element:3};function U(u){let o=B[u.type]??0;if(u.type==="attribute")return o+(z[u.action]??0);return o}function b(u,o){if(u.length===1)return i(u[0],o);let t=u.map((l)=>i(l,o));return(l)=>t.some((a)=>a(l))}function i(u,o){let t=o.adapter,l=[[]],a=[];for(let n of u)if(n.type==="descendant"||n.type==="child"||n.type==="sibling"||n.type==="adjacent"||n.type==="parent"||n.type==="column-combinator")a.push(n),l.push([]);else l[l.length-1].push(n);let d=y;for(let n=0;n<l.length;n++){let e=l[n].slice().sort((s,f)=>U(s)-U(f));for(let s of e)d=M(s,o,d);if(n<a.length)d=H(a[n],d,t)}return d}function H(u,o,t){switch(u.type){case"descendant":case"column-combinator":return(l)=>{let a=t.getParent(l);while(a){if(t.isTag(a)&&o(a))return!0;a=t.getParent(a)}return!1};case"child":return(l)=>{let a=t.getParent(l);return a!=null&&t.isTag(a)&&o(a)};case"sibling":return(l)=>{let a=t.getSiblings(l);for(let d of a){if(d===l)return!1;if(t.isTag(d)&&o(d))return!0}return!1};case"adjacent":return(l)=>{let a=t.getSiblings(l),d=null;for(let n of a){if(n===l)return d!=null&&t.isTag(d)&&o(d);d=n}return!1};case"parent":return(l)=>t.existsOne(o,t.getChildren(l))}return(l)=>!1}function j(u){if(!u||!u.adapter)throw Error("css-select: adapter is required");return u.adapter}var E=new WeakMap;function J(u){return(u.xmlMode?1:0)<<0|(u.lowerCaseAttributeNames===!1?1:0)<<1|(u.lowerCaseTags===!1?1:0)<<2}function K(u,o){let t=E.get(u);if(!t)t=[],E.set(u,t);let l=t[o];if(!l)l=new Map,t[o]=l;return l}function _(u,o){let t=r(u,{xmlMode:o.xmlMode,lowerCaseAttributeNames:o.lowerCaseAttributeNames,lowerCaseTags:o.lowerCaseTags});return b(t,o)}function g(u,o){if(typeof u!=="string")return b(u,o);if(o.cacheResults===!1||!o.adapter)return _(u,o);let t=K(o.adapter,J(o)),l=t.get(u);if(l!==void 0)return l;return l=_(u,o),t.set(u,l),l}function P(u,o){if(o===void 0){E.delete(u);return}let t=E.get(u);if(!t)return;for(let l of t)if(l)l.delete(o)}function v(u,o,t){let l=j(t),a=typeof u==="function"?u:g(u,t),d=O(o,l);return Q(a,d,l,t.xmlMode===!0)}function R(u,o,t){let l=j(t),a=typeof u==="function"?u:g(u,t),d=O(o,l);return x(a,d,l,t.xmlMode===!0)}function w(u,o,t){return(typeof o==="function"?o:g(o,t))(u)}export{i,g,P,v,R,w,C};
|
|
2
|
+
import{r}from"./chunk-dbj97h19.js";import{c}from"./chunk-vbjv9wf0.js";var C={};c(C,{clearSelectorCache:()=>P,compile:()=>g,is:()=>k,parseAndCompile:()=>i,selectAll:()=>v,selectOne:()=>R});function O(u,o,t,l){let a=[],d=[o],n=[0];for(;;){if(n[0]>=d[0].length){if(d.length===1)return a;d.shift(),n.shift();continue}let e=d[0][n[0]++];if(!t.isTag(e))continue;if(u(e))a.push(e);if(l||t.getName(e)!=="template"){let s=t.getChildren(e);if(s.length>0)d.unshift(s),n.unshift(0)}}}function Q(u,o,t,l){let a=[o],d=[0];for(;;){if(d[0]>=a[0].length){if(a.length===1)return null;a.shift(),d.shift();continue}let n=a[0][d[0]++];if(!t.isTag(n))continue;if(u(n))return n;if(l||t.getName(n)!=="template"){let e=t.getChildren(n);if(e.length>0)a.unshift(e),d.unshift(0)}}}function T(u,o){if(Array.isArray(u))return o.removeSubsets(u);return o.getChildren(u)}var y=(u)=>!0;function x(u){return u===32||u===9||u===10||u===12||u===13}function h(u,o){let t=o.length,l=u.length;if(t===0||t>l)return!1;let a=u.indexOf(o);while(a>=0){let d=a===0||x(u.charCodeAt(a-1)),n=a+t,e=n===l||x(u.charCodeAt(n));if(d&&e)return!0;a=u.indexOf(o,a+1)}return!1}function j(u,o,t){if(o.ignoreCase===!0)return!0;if(o.ignoreCase===!1)return!1;if(o.ignoreCase==="quirks")return!t.xmlMode;return!1}function L(u,o,t){let l=o.adapter,{action:a,name:d,value:n}=u,e=j(n,u,o);if(e)n=n.toLowerCase();return q(a,d,n,e,l,t)}function q(u,o,t,l,a,d){let n=d===y;switch(u){case"exists":if(n)return(e)=>a.hasAttrib(e,o);return(e)=>a.hasAttrib(e,o)&&d(e);case"equals":if(!l){if(n)return(e)=>a.getAttributeValue(e,o)===t;return(e)=>a.getAttributeValue(e,o)===t&&d(e)}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase()===t};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase()===t&&d(e)};case"not":return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return d(e);return(l?s.toLowerCase():s)!==t&&d(e)};case"start":if(t==="")return()=>!1;if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).startsWith(t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).startsWith(t)&&d(e)};case"end":if(t==="")return()=>!1;if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).endsWith(t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return(l?s.toLowerCase():s).endsWith(t)&&d(e)};case"any":{if(t==="")return()=>!1;if(l){if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase().indexOf(t)>=0};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.toLowerCase().indexOf(t)>=0&&d(e)}}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.indexOf(t)>=0};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return s.indexOf(t)>=0&&d(e)}}case"element":{if(t===""||/\s/.test(t))return()=>!1;if(l){if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s.toLowerCase(),t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s.toLowerCase(),t)&&d(e)}}if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s,t)};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;return h(s,t)&&d(e)}}case"hyphen":if(n)return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;let f=l?s.toLowerCase():s;if(f===t)return!0;if(f.startsWith(t)&&f.charAt(t.length)==="-")return!0;return!1};return(e)=>{let s=a.getAttributeValue(e,o);if(s==null)return!1;let f=l?s.toLowerCase():s;if(f===t)return d(e);if(f.startsWith(t)&&f.charAt(t.length)==="-")return d(e);return!1}}return(e)=>!1}var D=new Set(["link","any-link","visited","hover","active","focus","focus-visible","focus-within","target","target-within","enabled","disabled","checked","required","optional","valid","invalid","selected","placeholder-shown","read-only","read-write","in-range","out-of-range","default","indeterminate"]),G=new Set(["is","where","matches","-moz-any","-webkit-any"]),I=new Set(["nth-child","nth-last-child","nth-of-type","nth-last-of-type"]);function V(u,o,t){let l=o.adapter,{name:a,data:d}=u;if(u.type==="pseudo"&&G.has(a)){if(!Array.isArray(d))return t;let n=d.map((e)=>i(e,o));if(n.length===1){let e=n[0];return(s)=>e(s)&&t(s)}return(e)=>{for(let s of n)if(s(e))return t(e);return!1}}if(u.type==="pseudo"&&a==="not"){if(!Array.isArray(d))return t;let n=d.map((e)=>i(e,o));if(n.length===1){let e=n[0];return(s)=>!e(s)&&t(s)}return(e)=>{for(let s of n)if(s(e))return!1;return t(e)}}if(u.type==="pseudo"&&a==="has"){if(!Array.isArray(d))return t;let n=d.map((s)=>i(s,o)),e=n.length===1?n[0]:(s)=>{for(let f of n)if(f(s))return!0;return!1};return(s)=>{let f=l.getChildren(s).slice();while(f.length>0){let m=f.pop();if(!l.isTag(m))continue;if(e(m))return t(s);let p=l.getChildren(m);for(let N=0;N<p.length;N++)f.push(p[N])}return!1}}if(u.type==="pseudo"&&I.has(a)){let n=F(typeof d==="string"?d:"",a,o);return(e)=>n(e)&&t(e)}if(u.type==="pseudo"&&a==="first-child")return(n)=>{let e=l.getSiblings(n);for(let s of e){if(!l.isTag(s))continue;return s===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="last-child")return(n)=>{let e=l.getSiblings(n);for(let s=e.length-1;s>=0;s--){let f=e[s];if(!l.isTag(f))continue;return f===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="first-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n);for(let f of s){if(!l.isTag(f)||l.getName(f)!==e)continue;return f===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="last-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n);for(let f=s.length-1;f>=0;f--){let m=s[f];if(!l.isTag(m)||l.getName(m)!==e)continue;return m===n&&t(n)}return!1};if(u.type==="pseudo"&&a==="only-child")return(n)=>{let e=l.getSiblings(n),s=0,f=!1;for(let m of e){if(!l.isTag(m))continue;if(s++,s>1)return!1;if(m===n)f=!0}return s===1&&f&&t(n)};if(u.type==="pseudo"&&a==="only-of-type")return(n)=>{let e=l.getName(n),s=l.getSiblings(n),f=0,m=!1;for(let p of s){if(!l.isTag(p)||l.getName(p)!==e)continue;if(f++,f>1)return!1;if(p===n)m=!0}return f===1&&m&&t(n)};if(u.type==="pseudo"&&a==="empty")return(n)=>l.getChildren(n).length===0&&t(n);if(u.type==="pseudo"&&a==="root")return(n)=>{let e=l.getParent(n);return(e==null||!l.isTag(e))&&t(n)};if(u.type==="pseudo"&&a==="scope"){if(o.context&&Array.isArray(o.context)){let n=new Set(o.context);return(e)=>n.has(e)&&t(e)}if(o.context){let n=o.context;return(e)=>e===n&&t(e)}return(n)=>{let e=l.getParent(n);return(e==null||!l.isTag(e))&&t(n)}}if(u.type==="pseudo"&&D.has(a)){if(o.pseudos&&o.pseudos[a]){let n=o.pseudos[a];if(typeof n==="function")return(e)=>n(e,void 0)&&t(e)}return(n)=>!1}if(u.type==="pseudo-element")return t;if(o.pseudos&&o.pseudos[a]){let n=o.pseudos[a];if(typeof n==="function")return(e)=>n(e,typeof d==="string"?d:void 0)&&t(e);if(typeof n==="string"){let e=r(n),s=b(e,o);return(f)=>s(f)&&t(f)}}return(n)=>!1}function Y(u){let o=u.trim();if(o==="odd")return{a:2,b:1};if(o==="even")return{a:2,b:0};let t=/^([+-]?\d*)n([+-]\d+)?$/.exec(o.replace(/\s+/g,""));if(t){let a=t[1]===""||t[1]==="+"?1:t[1]==="-"?-1:Number(t[1]),d=t[2]?Number(t[2]):0;return{a,b:d}}let l=Number(o);if(!Number.isNaN(l))return{a:0,b:l};return null}function F(u,o,t){let l=Y(u);if(!l)return()=>!1;let{a,b:d}=l,n=t.adapter,e=o==="nth-of-type"||o==="nth-last-of-type",s=o==="nth-last-child"||o==="nth-last-of-type";return(f)=>{let m=n.getSiblings(f),p=e?n.getName(f):"",N=0,A=0;for(let w of m){if(!n.isTag(w))continue;if(e&&n.getName(w)!==p)continue;if(A++,w===f)N=A}if(N===0)return!1;let S=s?A-N+1:N;if(a===0)return S===d;return(S-d)/a>=0&&(S-d)%a===0}}function W(u,o,t){let l=o.adapter,a=t===y;switch(u.type){case"tag":{let d=o.lowerCaseTags!==!1&&!o.xmlMode?u.name.toLowerCase():u.name;if(a)return(n)=>l.getName(n)===d;return(n)=>l.getName(n)===d&&t(n)}case"universal":return t;case"attribute":return L(u,o,t);case"pseudo":case"pseudo-element":return V(u,o,t);case"descendant":case"child":case"parent":case"sibling":case"adjacent":case"column-combinator":return t}return(d)=>!1}var B={universal:50,tag:30,attribute:1,pseudo:0,"pseudo-element":0},z={exists:10,equals:8,not:7,start:6,end:6,hyphen:5,any:4,element:3};function M(u){let o=B[u.type]??0;if(u.type==="attribute")return o+(z[u.action]??0);return o}function b(u,o){if(u.length===1)return i(u[0],o);let t=u.map((l)=>i(l,o));return(l)=>t.some((a)=>a(l))}function i(u,o){let t=o.adapter,l=[[]],a=[];for(let n of u)if(n.type==="descendant"||n.type==="child"||n.type==="sibling"||n.type==="adjacent"||n.type==="parent"||n.type==="column-combinator")a.push(n),l.push([]);else l[l.length-1].push(n);let d=y;for(let n=0;n<l.length;n++){let e=l[n].slice().sort((s,f)=>M(s)-M(f));for(let s of e)d=W(s,o,d);if(n<a.length)d=H(a[n],d,t)}return d}function H(u,o,t){switch(u.type){case"descendant":case"column-combinator":return(l)=>{let a=t.getParent(l);while(a){if(t.isTag(a)&&o(a))return!0;a=t.getParent(a)}return!1};case"child":return(l)=>{let a=t.getParent(l);return a!=null&&t.isTag(a)&&o(a)};case"sibling":return(l)=>{let a=t.getSiblings(l);for(let d of a){if(d===l)return!1;if(t.isTag(d)&&o(d))return!0}return!1};case"adjacent":return(l)=>{let a=t.getSiblings(l),d=null;for(let n of a){if(n===l)return d!=null&&t.isTag(d)&&o(d);d=n}return!1};case"parent":return(l)=>t.existsOne(o,t.getChildren(l))}return(l)=>!1}function _(u){if(!u||!u.adapter)throw Error("css-select: adapter is required");return u.adapter}var E=new WeakMap;function J(u){return(u.xmlMode?1:0)<<0|(u.lowerCaseAttributeNames===!1?1:0)<<1|(u.lowerCaseTags===!1?1:0)<<2}function K(u,o){let t=E.get(u);if(!t)t=[],E.set(u,t);let l=t[o];if(!l)l=new Map,t[o]=l;return l}function U(u,o){let t=r(u,{xmlMode:o.xmlMode,lowerCaseAttributeNames:o.lowerCaseAttributeNames,lowerCaseTags:o.lowerCaseTags});return b(t,o)}function g(u,o){if(typeof u!=="string")return b(u,o);if(o.cacheResults===!1||!o.adapter)return U(u,o);let t=K(o.adapter,J(o)),l=t.get(u);if(l!==void 0)return l;return l=U(u,o),t.set(u,l),l}function P(u,o){if(o===void 0){E.delete(u);return}let t=E.get(u);if(!t)return;for(let l of t)if(l)l.delete(o)}function v(u,o,t){let l=_(t),a=typeof u==="function"?u:g(u,t),d=T(o,l);return O(a,d,l,t.xmlMode===!0)}function R(u,o,t){let l=_(t),a=typeof u==="function"?u:g(u,t),d=T(o,l);return Q(a,d,l,t.xmlMode===!0)}function k(u,o,t){return(typeof o==="function"?o:g(o,t))(u)}export{i,g,P,v,R,k,C};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CssConfig } from './types';
|
|
1
|
+
import type { CSSRule, CssConfig } from './types';
|
|
2
2
|
// Exported for tests: ranking is pure and selector-driven, and asserting it
|
|
3
3
|
// through generated CSS would need an @iconify-json collection installed —
|
|
4
4
|
// without one an icon emits nothing, `indexOf` returns -1, and an ordering
|
|
@@ -9,6 +9,8 @@ export declare class CSSGenerator {
|
|
|
9
9
|
generateBatch(classNames: string[]): void;
|
|
10
10
|
generate(className: string): void;
|
|
11
11
|
generateCompiledClass(className: string, utilities: string[]): void;
|
|
12
|
+
escapeSelector(className: string): string;
|
|
12
13
|
toCSS(includePreflight?: boolean, minify?: boolean): string;
|
|
14
|
+
rulesFor(className: string): CSSRule[];
|
|
13
15
|
reset(): void;
|
|
14
16
|
}
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './plugin';
|
|
|
6
6
|
export * from './preflight';
|
|
7
7
|
export * from './preflight-forms';
|
|
8
8
|
export * from './rules';
|
|
9
|
+
export * from './safelist';
|
|
10
|
+
export * from './stylesheet';
|
|
9
11
|
export * from './rules-mask';
|
|
10
12
|
export * from './rules-shadow';
|
|
11
13
|
export * from './scanner';
|