@unocss/runtime 0.51.0 → 0.51.1
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/attributify.global.js +3 -3
- package/core.global.js +2 -2
- package/full.global.js +3 -3
- package/mini.global.js +3 -3
- package/package.json +4 -4
- package/uno.global.js +3 -3
package/core.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
2
|
-
`,c=new Set([N]),h=new Set,x=new Map,S={},w=Array.from(f).map(async p=>{if(h.has(p))return;let C=await this.parseToken(p);if(C!=null){h.add(p);for(let T of C){let
|
|
1
|
+
"use strict";(()=>{function Re(t){let e=t.length,r=-1,n,s="",o=t.charCodeAt(0);for(;++r<e;){if(n=t.charCodeAt(r),n===0){s+="\uFFFD";continue}if(n===44){s+="\\,";continue}if(n>=1&&n<=31||n===127||r===0&&n>=48&&n<=57||r===1&&n>=48&&n<=57&&o===45){s+=`\\${n.toString(16)} `;continue}if(r===0&&e===1&&n===45){s+=`\\${t.charAt(r)}`;continue}if(n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122){s+=t.charAt(r);continue}s+=`\\${t.charAt(r)}`}return s}var H=Re;function b(t=[]){return Array.isArray(t)?t:[t]}function D(t){return Array.from(new Set(t))}function R(t){return typeof t=="string"}function j(t){return R(t)?t:(Array.isArray(t)?t:Object.entries(t)).filter(e=>e[1]!=null)}function ee(t){return Array.isArray(t)?t.find(e=>!Array.isArray(e)||Array.isArray(e[0]))?t.map(e=>j(e)):[t]:[j(t)]}function be(t){return t.filter(([e,r],n)=>{if(e.startsWith("$$"))return!1;for(let s=n-1;s>=0;s--)if(t[s][0]===e&&t[s][1]===r)return!1;return!0})}function F(t){return t==null?"":be(t).map(([e,r])=>r!=null?`${e}:${r};`:void 0).filter(Boolean).join("")}function G(t){return t&&typeof t=="object"&&!Array.isArray(t)}function Y(t,e,r=!1){let n=t,s=e;if(Array.isArray(s))return r&&Array.isArray(s)?[...n,...s]:[...s];let o={...n};return G(n)&&G(s)&&Object.keys(s).forEach(i=>{G(n[i])&&G(s[i])||Array.isArray(n[i])&&Array.isArray(s[i])?o[i]=Y(n[i],s[i],r):Object.assign(o,{[i]:s[i]})}),o}function k(t){let e,r,n;if(Array.isArray(t)){for(r=Array(e=t.length);e--;)r[e]=(n=t[e])&&typeof n=="object"?k(n):n;return r}if(Object.prototype.toString.call(t)==="[object Object]"){r={};for(e in t)e==="__proto__"?Object.defineProperty(r,e,{value:k(t[e]),configurable:!0,enumerable:!0,writable:!0}):r[e]=(n=t[e])&&typeof n=="object"?k(n):n;return r}return t}function te(t){return R(t[0])}function re(t){return R(t[0])}var q="$$shortcut-no-merge";function ne(t){return typeof t=="function"?{match:t}:t}function Z(t){return t.length===3}function se(t){return t!=null}function ie(){}var B=class{_map=new Map;get(e,r){let n=this._map.get(e);if(n)return n.get(r)}getFallback(e,r,n){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.has(r)||s.set(r,n),s.get(r)}set(e,r,n){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.set(r,n),this}has(e,r){return this._map.get(e)?.has(r)}delete(e,r){return this._map.get(e)?.delete(r)||!1}deleteTop(e){return this._map.delete(e)}map(e){return Array.from(this._map.entries()).flatMap(([r,n])=>Array.from(n.entries()).map(([s,o])=>e(o,r,s)))}};var z={};function ve(t=["-",":"]){let e=t.join("|");return z[e]||(z[e]=new RegExp(`((?:[!@\\w+:_/-]|\\[&?>?:?\\S*\\])+?)(${e})\\(((?:[~!<>\\w\\s:/\\\\,%#.$?-]|\\[.*?\\])+?)\\)(?!\\s*?=>)`,"gm")),z[e].lastIndex=0,z[e]}function we(t,e=["-",":"],r=5){let n=ve(e),s=!1,o=t.toString(),i=new Set;do{let a=o;o=o.replace(n,(f,u,c,h)=>e.includes(c)?(i.add(u+c),h.split(/\s/g).filter(Boolean).map(x=>x==="~"?u:x.replace(/^(!?)(.*)/,`$1${u}${c}$2`)).join(" ")):f),s=o!==a,r-=1}while(s&&r);return{prefixes:Array.from(i),expanded:o,hasChanged:s}}function oe(t,e=["-",":"],r=5){let{expanded:n}=we(t.toString(),e,r);return typeof t=="string"?n:t.length()?t.overwrite(0,t.length(),n):t}var ae=new Set;function ce(t){ae.has(t)||(console.warn("[unocss]",t),ae.add(t))}var le=/[\\:]?[\s'"`;{}]+/g;function Ae(t){return[...new Set(t.split(le))]}var I={name:"@unocss/core/extractor-split",order:0,extract({code:t}){return Ae(t)}};function ue(){return{events:{},emit(t,...e){(this.events[t]||[]).forEach(r=>r(...e))},on(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=(this.events[t]||[]).filter(r=>r!==e)}}}var N="default",W="preflights",Ue="shortcuts",fe={[W]:-100,[Ue]:-10,[N]:0};function de(t){return b(t).flatMap(e=>Array.isArray(e)?[e]:Object.entries(e))}var pe="_uno_resolved";function Me(t){if(pe in t)return t;t={...t},Object.defineProperty(t,pe,{value:!0,enumerable:!1});let e=t.shortcuts?de(t.shortcuts):void 0;if(t.shortcuts=e,t.prefix||t.layer){let r=n=>{n[2]||(n[2]={});let s=n[2];s.prefix==null&&t.prefix&&(s.prefix=b(t.prefix)),s.layer==null&&t.layer&&(s.layer=t.layer)};e?.forEach(r),t.rules?.forEach(r)}return t}function he(t){let e=Me(t);if(!e.presets)return[e];let r=(e.presets||[]).flatMap(b).flatMap(he);return[e,...r]}function J(t={},e={}){let r=Object.assign({},e,t),n=D((r.presets||[]).flatMap(b).flatMap(he)),s=[...n.filter(l=>l.enforce==="pre"),...n.filter(l=>!l.enforce),...n.filter(l=>l.enforce==="post")],o=Object.assign({},fe,...n.map(l=>l.layers),r.layers);function i(l){return D([...s.flatMap(p=>b(p[l]||[])),...b(r[l]||[])])}let a=i("extractors"),f=[...s,r].reverse().find(l=>l.extractorDefault!==void 0)?.extractorDefault;f===void 0&&(f=I),f&&!a.includes(f)&&a.unshift(f),a.sort((l,p)=>(l.order||0)-(p.order||0));let u=i("rules"),c={},h=u.length,x=u.map((l,p)=>{if(te(l)){b(l[2]?.prefix||"").forEach(T=>{c[T+l[0]]=[p,l[1],l[2],l]});return}return[p,...l]}).filter(Boolean).reverse(),S=k([...s.map(l=>l.theme||{}),r.theme||{}].reduce((l,p)=>Y(l,p),{})),w=b(i("extendTheme"));for(let l of w)S=l(S)||S;let U={templates:D(s.map(l=>b(l.autocomplete?.templates)).flat()),extractors:s.map(l=>b(l.autocomplete?.extractors)).flat().sort((l,p)=>(l.order||0)-(p.order||0))},y=b(i("separators"));y.length||(y=[":","-"]);let E={mergeSelectors:!0,warn:!0,blocklist:[],sortLayers:l=>l,...r,presets:s,envMode:r.envMode||"build",shortcutsLayer:r.shortcutsLayer||"shortcuts",layers:o,theme:S,rulesSize:h,rulesDynamic:x,rulesStaticMap:c,preprocess:i("preprocess"),postprocess:i("postprocess"),preflights:i("preflights"),autocomplete:U,variants:i("variants").map(ne).sort((l,p)=>(l.order||0)-(p.order||0)),shortcuts:de(i("shortcuts")).reverse(),extractors:a,safelist:i("safelist"),separators:y};for(let l of s)l?.configResolved?.(E);return t?.configResolved?.(E),E}var me="0.51.1";var Q=class{constructor(e={},r={}){this.userConfig=e;this.defaults=r;this.config=J(e,r),this.events.emit("config",this.config)}version=me;_cache=new Map;config;blocked=new Set;parentOrders=new Map;events=ue();setConfig(e,r){e&&(r&&(this.defaults=r),this.userConfig=e,this.blocked.clear(),this.parentOrders.clear(),this._cache.clear(),this.config=J(e,this.defaults),this.events.emit("config",this.config))}async applyExtractors(e,r,n=new Set){let s={original:e,code:e,id:r,extracted:n};for(let o of this.config.extractors){let i=await o.extract?.(s);if(i)for(let a of i)n.add(a)}return n}makeContext(e,r){let n={rawSelector:e,currentSelector:r[1],theme:this.config.theme,generator:this,variantHandlers:r[2],constructCSS:(...s)=>this.constructCustomCSS(n,...s),variantMatch:r};return n}async parseToken(e,r){if(this.blocked.has(e))return;let n=`${e}${r?` ${r}`:""}`;if(this._cache.has(n))return this._cache.get(n);let s=e;for(let u of this.config.preprocess)s=u(e);if(this.isBlocked(s)){this.blocked.add(e),this._cache.set(n,null);return}let o=await this.matchVariants(e,s);if(!o||this.isBlocked(o[1])){this.blocked.add(e),this._cache.set(n,null);return}let i=this.makeContext(e,[r||o[0],o[1],o[2],o[3]]);this.config.details&&(i.variants=[...o[3]]);let a=await this.expandShortcut(i.currentSelector,i),f=a?await this.stringifyShortcuts(i.variantMatch,i,a[0],a[1]):(await this.parseUtil(i.variantMatch,i))?.map(u=>this.stringifyUtil(u,i)).filter(se);if(f?.length)return this._cache.set(n,f),f;this._cache.set(n,null)}async generate(e,r={}){let{id:n,scope:s,preflights:o=!0,safelist:i=!0,minify:a=!1}=r,f=R(e)?await this.applyExtractors(e,n):Array.isArray(e)?new Set(e):e;i&&this.config.safelist.forEach(p=>f.add(p));let u=a?"":`
|
|
2
|
+
`,c=new Set([N]),h=new Set,x=new Map,S={},w=Array.from(f).map(async p=>{if(h.has(p))return;let C=await this.parseToken(p);if(C!=null){h.add(p);for(let T of C){let v=T[3]||"",M=T[4]?.layer;x.has(v)||x.set(v,[]),x.get(v).push(T),M&&c.add(M)}}});await Promise.all(w),await(async()=>{if(!o)return;let p={generator:this,theme:this.config.theme},C=new Set([]);this.config.preflights.forEach(({layer:T=W})=>{c.add(T),C.add(T)}),S=Object.fromEntries(await Promise.all(Array.from(C).map(async T=>{let M=(await Promise.all(this.config.preflights.filter(_=>(_.layer||W)===T).map(async _=>await _.getCSS(p)))).filter(Boolean).join(u);return[T,M]})))})();let U=this.config.sortLayers(Array.from(c).sort((p,C)=>(this.config.layers[p]??0)-(this.config.layers[C]??0)||p.localeCompare(C))),y={},E=p=>{if(y[p])return y[p];let C=Array.from(x).sort((v,M)=>(this.parentOrders.get(v[0])??0)-(this.parentOrders.get(M[0])??0)||v[0]?.localeCompare(M[0]||"")||0).map(([v,M])=>{let _=M.length,L=M.filter(d=>(d[4]?.layer||N)===p).sort((d,g)=>d[0]-g[0]||(d[4]?.sort||0)-(g[4]?.sort||0)||d[5]?.currentSelector?.localeCompare(g[5]?.currentSelector??"")||d[1]?.localeCompare(g[1]||"")||d[2]?.localeCompare(g[2]||"")||0).map(([,d,g,,A,,V])=>[[[(d&&Pe(d,s))??"",A?.sort??0]],g,!!(V??A?.noMerge)]);if(!L.length)return;let K=L.reverse().map(([d,g,A],V)=>{if(!A&&this.config.mergeSelectors)for(let O=V+1;O<_;O++){let $=L[O];if($&&!$[2]&&(d&&$[0]||d==null&&$[0]==null)&&$[1]===g)return d&&$[0]&&$[0].push(...d),null}let P=d?D(d.sort((O,$)=>O[1]-$[1]||O[0]?.localeCompare($[0]||"")||0).map(O=>O[0]).filter(Boolean)):[];return P.length?`${P.join(`,${u}`)}{${g}}`:g}).filter(Boolean).reverse().join(u);if(!v)return K;let m=v.split(" $$ ");return`${m.join("{")}{${u}${K}${u}}${m.map(d=>"").join("}")}`}).filter(Boolean).join(u);o&&(C=[S[p],C].filter(Boolean).join(u));let T=a?"":`/* layer: ${p} */${u}`;return y[p]=C?T+C:""},l=(p=U,C)=>p.filter(T=>!C?.includes(T)).map(T=>E(T)||"").filter(Boolean).join(u);return{get css(){return l()},layers:U,matched:h,getLayers:l,getLayer:E}}async matchVariants(e,r){let n=new Set,s=[],o=r||e,i=!1,a={rawSelector:e,theme:this.config.theme,generator:this};for(;;){i=!1;for(let f of this.config.variants){if(!f.multiPass&&n.has(f))continue;let u=await f.match(o,a);if(u){R(u)&&(u={matcher:u}),o=u.matcher,s.unshift(u),n.add(f),i=!0;break}}if(!i)break;if(s.length>500)throw new Error(`Too many variants applied to "${e}"`)}return[e,o,s,n]}applyVariants(e,r=e[4],n=e[1]){let o=r.slice().sort((u,c)=>(u.order||0)-(c.order||0)).reduceRight((u,c)=>h=>{let x=c.body?.(h.entries)||h.entries,S=Array.isArray(c.parent)?c.parent:[c.parent,void 0];return(c.handle??De)({...h,entries:x,selector:c.selector?.(h.selector,x)||h.selector,parent:S[0]||h.parent,parentOrder:S[1]||h.parentOrder,layer:c.layer||h.layer,sort:c.sort||h.sort},u)},u=>u)({prefix:"",selector:Oe(n),pseudo:"",entries:e[2]}),{parent:i,parentOrder:a}=o;i!=null&&a!=null&&this.parentOrders.set(i,a);let f={selector:[o.prefix,o.selector,o.pseudo].join(""),entries:o.entries,parent:i,layer:o.layer,sort:o.sort,noMerge:o.noMerge};for(let u of this.config.postprocess)u(f);return f}constructCustomCSS(e,r,n){let s=j(r);if(R(s))return s;let{selector:o,entries:i,parent:a}=this.applyVariants([0,n||e.rawSelector,s,void 0,e.variantHandlers]),f=`${o}{${F(i)}}`;return a?`${a}{${f}}`:f}async parseUtil(e,r,n=!1,s){let[o,i,a]=R(e)?await this.matchVariants(e):e;this.config.details&&(r.rules=r.rules??[]);let f=this.config.rulesStaticMap[i];if(f&&f[1]&&(n||!f[2]?.internal)){this.config.details&&r.rules.push(f[3]);let c=f[0],h=j(f[1]),x=f[2];return R(h)?[[c,h,x]]:[[c,o,h,x,a]]}r.variantHandlers=a;let{rulesDynamic:u}=this.config;for(let[c,h,x,S]of u){if(S?.internal&&!n)continue;let w=i;if(S?.prefix){let l=b(S.prefix);if(s){let p=b(s);if(!l.some(C=>p.includes(C)))continue}else{let p=l.find(C=>i.startsWith(C));if(p==null)continue;w=i.slice(p.length)}}let U=w.match(h);if(!U)continue;let y=await x(U,r);if(!y)continue;this.config.details&&r.rules.push([h,x,S]);let E=ee(y).filter(l=>l.length);if(E.length)return E.map(l=>R(l)?[c,l,S]:[c,o,l,S,a])}}stringifyUtil(e,r){if(!e)return;if(Z(e))return[e[0],void 0,e[1],void 0,e[2],this.config.details?r:void 0,void 0];let{selector:n,entries:s,parent:o,layer:i,sort:a,noMerge:f}=this.applyVariants(e),u=F(s);if(!u)return;let{layer:c,sort:h,...x}=e[3]??{},S={...x,layer:i??c,sort:a??h};return[e[0],n,u,o,S,this.config.details?r:void 0,f]}async expandShortcut(e,r,n=5){if(n===0)return;let s=this.config.details?a=>{r.shortcuts=r.shortcuts??[],r.shortcuts.push(a)}:ie,o,i;for(let a of this.config.shortcuts){let f=e;if(a[2]?.prefix){let c=b(a[2].prefix).find(h=>e.startsWith(h));if(c==null)continue;f=e.slice(c.length)}if(re(a)){if(a[0]===f){o=o||a[2],i=a[1],s(a);break}}else{let u=f.match(a[0]);if(u&&(i=a[1](u,r)),i){o=o||a[2],s(a);break}}}if(R(i)&&(i=oe(i.trim()).split(/\s+/g)),!i){let[a,f]=R(e)?await this.matchVariants(e):e;if(a!==f){let u=await this.expandShortcut(f,r,n-1);u&&(i=u[0].map(c=>R(c)?a.replace(f,c):c))}}if(i)return[(await Promise.all(i.map(async a=>(R(a)?(await this.expandShortcut(a,r,n-1))?.[0]:void 0)||[a]))).flat(1).filter(Boolean),o]}async stringifyShortcuts(e,r,n,s={layer:this.config.shortcutsLayer}){let o=new B,i=(await Promise.all(D(n).map(async c=>{let h=R(c)?await this.parseUtil(c,r,!0,s.prefix):[[1/0,"{inline}",j(c),void 0,[]]];return h||ce(`unmatched utility "${c}" in shortcut "${e[1]}"`),h||[]}))).flat(1).filter(Boolean).sort((c,h)=>c[0]-h[0]),[a,,f]=e,u=[];for(let c of i){if(Z(c)){u.push([c[0],void 0,c[1],void 0,c[2],r,void 0]);continue}let{selector:h,entries:x,parent:S,sort:w,noMerge:U}=this.applyVariants(c,[...c[4],...f],a);o.getFallback(h,S,[[],c[0]])[0].push([x,!!(U??c[3]?.noMerge),w??0])}return u.concat(o.map(([c,h],x,S)=>{let w=(y,E,l)=>{let p=Math.max(...l.map(T=>T[1])),C=l.map(T=>T[0]);return(y?[C.flat(1)]:C).map(T=>{let v=F(T);if(v)return[h,x,v,S,{...s,noMerge:E,sort:p},r,void 0]})};return[[c.filter(([,y])=>y).map(([y,,E])=>[y,E]),!0],[c.filter(([,y])=>!y).map(([y,,E])=>[y,E]),!1]].map(([y,E])=>[...w(!1,E,y.filter(([l])=>l.some(p=>p[0]===q))),...w(!0,E,y.filter(([l])=>l.every(p=>p[0]!==q)))])}).flat(2).filter(Boolean))}isBlocked(e){return!e||this.config.blocklist.some(r=>R(r)?r===e:r.test(e))}};function xe(t,e){return new Q(t,e)}var $e=/\s\$\$\s+/g;function _e(t){return t.match(/\s\$\$\s/)}function Pe(t,e){return _e(t)?t.replace($e,e?` ${e} `:" "):e?`${e} ${t}`:t}var ge=/^\[(.+?)(~?=)"(.*)"\]$/;function Oe(t){return ge.test(t)?t.replace(ge,(e,r,n,s)=>`[${H(r)}${n}"${H(s)}"]`):`.${H(t)}`}function De(t,e){return e(t)}function Le(t){return t.replace(/-(\w)/g,(e,r)=>r?r.toUpperCase():"")}function ye(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Se(t){return t.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase()}var Ce=["Webkit","Moz","ms"];function Te(t){let e={};function r(n){let s=e[n];if(s)return s;let o=Le(n);if(o!=="filter"&&o in t)return e[n]=Se(o);o=ye(o);for(let i=0;i<Ce.length;i++){let a=`${Ce[i]}${o}`;if(a in t)return e[n]=Se(ye(a))}return n}return({entries:n})=>n.forEach(s=>{s[0].startsWith("--")||(s[0]=r(s[0]))})}function Ee(t){return t.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")}function X(t={}){if(typeof window>"u"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let e=window,r=window.document,n=()=>r.documentElement,s=e.__unocss||{},o=Object.assign({},t,s.runtime),i=o.defaults||{},a=o.cloakAttribute??"un-cloak";o.autoPrefix&&(i.postprocess=b(i.postprocess)).unshift(Te(r.createElement("div").style)),o.configResolved?.(s,i);let f=xe(s,i),u=new Map,c=!0,h=new Set,x,S,w=[],U=()=>new Promise(m=>{w.push(m),S!=null&&clearTimeout(S),S=setTimeout(()=>l().then(()=>{let d=w;w=[],d.forEach(g=>g())}),0)});function y(m){if(m.nodeType!==1)return;let d=m;d.hasAttribute(a)&&d.removeAttribute(a),d.querySelectorAll(`[${a}]`).forEach(g=>{g.removeAttribute(a)})}function E(m,d){let g=u.get(m);if(!g)if(g=r.createElement("style"),u.set(m,g),d==null)n().prepend(g);else{let A=E(d),V=A.parentNode;V?V.insertBefore(g,A.nextSibling):n().prepend(g)}return g}async function l(){let m=await f.generate(h);return m.layers.reduce((d,g)=>(E(g,d).innerHTML=m.getLayer(g)??"",g),void 0),h=m.matched,{...m,getStyleElement:d=>u.get(d),getStyleElements:()=>u}}async function p(m){let d=h.size;await f.applyExtractors(m,void 0,h),d!==h.size&&await U()}async function C(){let m=r.body,d=m&&m.outerHTML;d&&(await p(`${d} ${Ee(d)}`),y(n()),y(m))}let T=new MutationObserver(m=>{c||m.forEach(async d=>{if(d.target.nodeType!==1)return;let g=d.target;for(let A of u)if(g===A[1])return;if(d.type==="childList")d.addedNodes.forEach(async A=>{if(A.nodeType!==1)return;let V=A;x&&!x(V)||(await p(V.outerHTML),y(V))});else{if(x&&!x(g))return;if(d.attributeName!==a){let A=Array.from(g.attributes).map(P=>P.value?`${P.name}="${P.value}"`:P.name).join(" "),V=`<${g.tagName.toLowerCase()} ${A}>`;await p(V)}g.hasAttribute(a)&&g.removeAttribute(a)}})}),v=!1;function M(){if(v)return;let m=n()||r.body;m&&(T.observe(m,{childList:!0,subtree:!0,attributes:!0}),v=!0)}function _(){C(),M()}function L(){r.readyState==="loading"?e.addEventListener("DOMContentLoaded",_):_()}let K=e.__unocss_runtime=e.__unocss_runtime={version:f.version,uno:f,async extract(m){R(m)||(m.forEach(d=>h.add(d)),m=""),await p(m)},extractAll:C,inspect(m){x=m},toggleObserver(m){m===void 0?c=!c:c=!!m,!v&&!c&&L()},update:l};o.ready?.(K)!==!1&&(c=!1,L())}X();})();
|