@unocss/runtime 0.39.2 → 0.41.0
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/dist/index.js +1 -0
- package/dist/index.mjs +2 -0
- 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
|
-
|
|
2
|
-
`,
|
|
1
|
+
"use strict";(()=>{function mt(r){let t=r.length,e=-1,n,s="",i=r.charCodeAt(0);for(;++e<t;){if(n=r.charCodeAt(e),n===0){s+="\uFFFD";continue}if(n===44){s+="\\,";continue}if(n>=1&&n<=31||n===127||e===0&&n>=48&&n<=57||e===1&&n>=48&&n<=57&&i===45){s+=`\\${n.toString(16)} `;continue}if(e===0&&t===1&&n===45){s+=`\\${r.charAt(e)}`;continue}if(n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122){s+=r.charAt(e);continue}s+=`\\${r.charAt(e)}`}return s}var D=mt;function k(r){return typeof r=="string"?r:(Array.isArray(r)?r:Object.entries(r)).filter(t=>t[1]!=null)}function Q(r){return Array.isArray(r)?r.find(t=>!Array.isArray(t)||Array.isArray(t[0]))?r.map(t=>k(t)):[r]:[k(r)]}function yt(r){return r.filter(([t,e],n)=>{if(t.startsWith("$$"))return!1;for(let s=n-1;s>=0;s--)if(r[s][0]===t&&r[s][1]===e)return!1;return!0})}function H(r){return r==null?"":yt(r).map(([t,e])=>e!=null?`${t}:${e};`:void 0).filter(Boolean).join("")}function L(r){return r&&typeof r=="object"&&!Array.isArray(r)}function F(r,t){let e=r,n=t;if(Array.isArray(e)&&Array.isArray(n))return[...e,...n];if(Array.isArray(e))return[...e];let s={...e};return L(e)&&L(n)&&Object.keys(n).forEach(i=>{L(e[i])&&L(n[i])||Array.isArray(e[i])&&Array.isArray(n[i])?s[i]=F(e[i],n[i]):Object.assign(s,{[i]:n[i]})}),s}function j(r){let t,e,n;if(Array.isArray(r)){for(e=Array(t=r.length);t--;)e[t]=(n=r[t])&&typeof n=="object"?j(n):n;return e}if(Object.prototype.toString.call(r)==="[object Object]"){e={};for(t in r)t==="__proto__"?Object.defineProperty(e,t,{value:j(r[t]),configurable:!0,enumerable:!0,writable:!0}):e[t]=(n=r[t])&&typeof n=="object"?j(n):n;return e}return r}function X(r){return typeof r[0]=="string"}function Y(r){return typeof r[0]=="string"}function _(r=[]){return Array.isArray(r)?r:[r]}function K(r){return Array.from(new Set(r))}var St=/(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/,B="$$shortcut-no-merge";function tt(r=""){return St.test(r)}function et(r){return typeof r=="function"?{match:r}:r}function G(r){return r.length===3}function rt(r){return r!=null}function I(){}var z=class{_map=new Map;get(t,e){let n=this._map.get(t);if(n)return n.get(e)}getFallback(t,e,n){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.has(e)||s.set(e,n),s.get(e)}set(t,e,n){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.set(e,n),this}has(t,e){var n;return(n=this._map.get(t))==null?void 0:n.has(e)}delete(t,e){var n;return((n=this._map.get(t))==null?void 0:n.delete(e))||!1}deleteTop(t){return this._map.delete(t)}map(t){return Array.from(this._map.entries()).flatMap(([e,n])=>Array.from(n.entries()).map(([s,i])=>t(i,e,s)))}};var nt=/([!\w+:_/-]+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;function st(r){nt.lastIndex=0;let t=!1;do{let e=r.toString();r=r.replace(nt,(n,s,i,o)=>o.split(/\s/g).map(a=>a==="~"?s:a.replace(/^(!?)(.*)/,`$1${s}${i}$2`)).join(" ")),t=r.toString()!==e}while(t);return r}var it=new Set;function ot(r){it.has(r)||(console.warn("[unocss]",r),it.add(r))}var xt=r=>r.split(/[\s'"`;=]+/g).filter(tt),N={name:"split",order:0,extract({code:r}){return new Set(xt(r))}};function at(){return{events:{},emit(r,...t){(this.events[r]||[]).forEach(e=>e(...t))},on(r,t){return(this.events[r]=this.events[r]||[]).push(t),()=>this.events[r]=(this.events[r]||[]).filter(e=>e!==t)}}}function Ct(r){return _(r).flatMap(t=>Array.isArray(t)?[t]:Object.entries(t))}var bt={preflights:-100,shortcuts:-10,default:0};function q(r={},t={}){let e=Object.assign({},t,r),n=(e.presets||[]).flatMap(_),s=[...n.filter(l=>l.enforce==="pre"),...n.filter(l=>!l.enforce),...n.filter(l=>l.enforce==="post")],i=Object.assign(bt,...n.map(l=>l.layers),r.layers);function o(l){return K([...s.flatMap(d=>_(d[l]||[])),..._(e[l]||[])])}let a=o("extractors");a.length||a.push(N),a.sort((l,d)=>(l.order||0)-(d.order||0));let c=o("rules"),u={},g=c.length;c.forEach((l,d)=>{X(l)&&(u[l[0]]=[d,l[1],l[2],l],delete c[d])});let p=j([...s.map(l=>l.theme||{}),e.theme||{}].reduce((l,d)=>F(l,d),{}));o("extendTheme").forEach(l=>l(p));let S={templates:K(s.map(l=>{var d;return _((d=l.autocomplete)==null?void 0:d.templates)}).flat()),extractors:s.map(l=>{var d;return _((d=l.autocomplete)==null?void 0:d.extractors)}).flat().sort((l,d)=>(l.order||0)-(d.order||0))};return{mergeSelectors:!0,warn:!0,blocklist:[],sortLayers:l=>l,...e,presets:s,envMode:e.envMode||"build",shortcutsLayer:e.shortcutsLayer||"shortcuts",layers:i,theme:p,rulesSize:g,rulesDynamic:c,rulesStaticMap:u,preprocess:o("preprocess"),postprocess:o("postprocess"),preflights:o("preflights"),autocomplete:S,variants:o("variants").map(et),shortcuts:Ct(o("shortcuts")),extractors:a,safelist:o("safelist")}}var ct="0.41.0";var W=class{constructor(t={},e={}){this.userConfig=t;this.defaults=e;this.config=q(t,e),this.events.emit("config",this.config)}version=ct;_cache=new Map;config;blocked=new Set;parentOrders=new Map;events=at();setConfig(t,e){!t||(e&&(this.defaults=e),this.userConfig=t,this.blocked.clear(),this.parentOrders.clear(),this._cache.clear(),this.config=q(t,this.defaults),this.events.emit("config",this.config))}async applyExtractors(t,e,n=new Set){let s={get original(){return t},code:t,id:e};for(let i of this.config.extractors){let o=await i.extract(s);o==null||o.forEach(a=>n.add(a))}return n}makeContext(t,e){let n={rawSelector:t,currentSelector:e[1],theme:this.config.theme,generator:this,variantHandlers:e[2],constructCSS:(...s)=>this.constructCustomCSS(n,...s),variantMatch:e};return n}async parseToken(t,e){var c;if(this.blocked.has(t))return;let n=`${t}${e?` ${e}`:""}`;if(this._cache.has(n))return this._cache.get(n);let s=t;for(let u of this.config.preprocess)s=u(t);if(this.isBlocked(s)){this.blocked.add(t),this._cache.set(n,null);return}let i=this.matchVariants(t,s);if(!i||this.isBlocked(i[1])){this.blocked.add(t),this._cache.set(n,null);return}let o=this.makeContext(t,[e||i[0],i[1],i[2],i[3]]);this.config.details&&(o.variants=[...i[3]]);let a=this.expandShortcut(o.currentSelector,o);if(a){let u=await this.stringifyShortcuts(o.variantMatch,o,a[0],a[1]);if(u!=null&&u.length)return this._cache.set(n,u),u}else{let u=(c=await this.parseUtil(o.variantMatch,o))==null?void 0:c.map(g=>this.stringifyUtil(g,o)).filter(rt);if(u!=null&&u.length)return this._cache.set(n,u),u}this._cache.set(n,null)}async generate(t="",{id:e,scope:n,preflights:s=!0,safelist:i=!0,minify:o=!1}={}){let a=typeof t=="string"?await this.applyExtractors(t,e):t;i&&this.config.safelist.forEach(h=>a.add(h));let c=o?"":`
|
|
2
|
+
`,u=new Set(["default"]),g=new Set,p=new Map,S={},l=Array.from(a).map(async h=>{var y;if(g.has(h))return;let m=await this.parseToken(h);if(m!=null){g.add(h);for(let b of m){let U=b[3]||"",f=(y=b[4])==null?void 0:y.layer;p.has(U)||p.set(U,[]),p.get(U).push(b),f&&u.add(f)}}}),d=(async()=>{if(!s)return;let h={generator:this,theme:this.config.theme},m=new Set(["default"]);this.config.preflights.forEach(({layer:y})=>{y&&(u.add(y),m.add(y))}),S=Object.fromEntries(await Promise.all(Array.from(m).map(async y=>{let U=(await Promise.all(this.config.preflights.filter(f=>(f.layer||"default")===y).map(async f=>await f.getCSS(h)))).filter(Boolean).join(c);return[y,U]})))})();await Promise.all([...l,d]);let v=this.config.sortLayers(Array.from(u).sort((h,m)=>(this.config.layers[h]??0)-(this.config.layers[m]??0)||h.localeCompare(m))),T={},C=h=>{if(T[h])return T[h];let m=Array.from(p).sort((y,b)=>{var U;return(this.parentOrders.get(y[0])??0)-(this.parentOrders.get(b[0])??0)||((U=y[0])==null?void 0:U.localeCompare(b[0]||""))||0}).map(([y,b])=>{let U=b.length,f=b.filter(x=>{var E;return(((E=x[4])==null?void 0:E.layer)||"default")===h}).sort((x,E)=>{var A,O,P,V;return x[0]-E[0]||(((A=x[4])==null?void 0:A.sort)||0)-(((O=E[4])==null?void 0:O.sort)||0)||((P=x[1])==null?void 0:P.localeCompare(E[1]||""))||((V=x[2])==null?void 0:V.localeCompare(E[2]||""))||0}).map(([,x,E,,A])=>[[[(x&&Rt(x,n))??"",(A==null?void 0:A.sort)??0]],E,!!(A!=null&&A.noMerge)]);if(!f.length)return;let R=f.reverse().map(([x,E,A],O)=>{if(!A&&this.config.mergeSelectors)for(let V=O+1;V<U;V++){let M=f[V];if(M&&!M[2]&&(x&&M[0]||x==null&&M[0]==null)&&M[1]===E)return x&&M[0]&&M[0].push(...x),null}let P=x?[...new Set(x.sort((V,M)=>{var J;return V[1]-M[1]||((J=V[0])==null?void 0:J.localeCompare(M[0]||""))||0}).map(V=>V[0]).filter(Boolean))]:[];return P.length?`${P.join(`,${c}`)}{${E}}`:E}).filter(Boolean).reverse().join(c);if(!y)return R;let $=y.split(" $$ ");return`${$.join("{")}{${c}${R}${c}}${$.map(x=>"").join("}")}`}).filter(Boolean).join(c);return s&&(m=[S[h],m].filter(Boolean).join(c)),T[h]=!o&&m?`/* layer: ${h} */${c}${m}`:m},w=(h=v,m)=>h.filter(y=>!(m!=null&&m.includes(y))).map(y=>C(y)||"").filter(Boolean).join(c);return{get css(){return w()},layers:v,getLayers:w,getLayer:C,matched:g}}matchVariants(t,e){let n=new Set,s=[],i=e||t,o=!1,a={rawSelector:t,theme:this.config.theme,generator:this};for(;;){o=!1;for(let c of this.config.variants){if(!c.multiPass&&n.has(c))continue;let u=c.match(i,a);if(!!u){typeof u=="string"&&(u={matcher:u}),i=u.matcher,s.unshift(u),n.add(c),o=!0;break}}if(!o)break;if(s.length>500)throw new Error(`Too many variants applied to "${t}"`)}return[t,i,s,n]}applyVariants(t,e=t[4],n=t[1]){let i=[...e].sort((u,g)=>(u.order||0)-(g.order||0)).reverse().reduce((u,g)=>p=>{var d,v;let S=((d=g.body)==null?void 0:d.call(g,p.entries))||p.entries,l=Array.isArray(g.parent)?g.parent:[g.parent,void 0];return(g.handle??At)({...p,entries:S,selector:((v=g.selector)==null?void 0:v.call(g,p.selector,S))||p.selector,parent:l[0]||p.parent,parentOrder:l[1]||p.parentOrder,layer:g.layer||p.layer,sort:g.sort||p.sort},u)},u=>u)({prefix:"",selector:Ut(n),pseudo:"",entries:t[2]}),{parent:o,parentOrder:a}=i;o!=null&&a!=null&&this.parentOrders.set(o,a);let c={selector:wt([i.prefix,i.selector,i.pseudo].join("")),entries:i.entries,parent:o,layer:i.layer,sort:i.sort};for(let u of this.config.postprocess)u(c);return c}constructCustomCSS(t,e,n){let s=k(e);if(typeof s=="string")return s;let{selector:i,entries:o,parent:a}=this.applyVariants([0,n||t.rawSelector,s,void 0,t.variantHandlers]),c=`${i}{${H(o)}}`;return a?`${a}{${c}}`:c}async parseUtil(t,e,n=!1){var p,S;let[s,i,o]=typeof t=="string"?this.matchVariants(t):t,a=this.config.details?l=>{e.rules=e.rules??[],e.rules.push(l)}:I,c=this.config.rulesStaticMap[i];if(c&&c[1]&&(n||!((p=c[2])!=null&&p.internal))){a(c[3]);let l=c[0],d=k(c[1]),v=c[2];return typeof d=="string"?[[l,d,v]]:[[l,s,d,v,o]]}e.variantHandlers=o;let{rulesDynamic:u,rulesSize:g}=this.config;for(let l=g-1;l>=0;l--){let d=u[l];if(!d||((S=d[2])==null?void 0:S.internal)&&!n)continue;let[v,T,C]=d,w=i.match(v);if(!w)continue;let h=await T(w,e);if(!h)continue;a(d);let m=Q(h).filter(y=>y.length);if(m.length)return m.map(y=>typeof y=="string"?[l,y,C]:[l,s,y,C,o])}}stringifyUtil(t,e){if(!t)return;if(G(t))return[t[0],void 0,t[1],void 0,t[2],this.config.details?e:void 0];let{selector:n,entries:s,parent:i,layer:o,sort:a}=this.applyVariants(t),c=H(s);if(!c)return;let{layer:u,sort:g,...p}=t[3]??{},S={...p,layer:o??u,sort:a??g};return[t[0],n,c,i,S,this.config.details?e:void 0]}expandShortcut(t,e,n=3){if(n===0)return;let s=this.config.details?a=>{e.shortcuts=e.shortcuts??[],e.shortcuts.push(a)}:I,i,o;for(let a of this.config.shortcuts)if(Y(a)){if(a[0]===t){i=i||a[2],o=a[1],s(a);break}}else{let c=t.match(a[0]);if(c&&(o=a[1](c,e)),o){i=i||a[2],s(a);break}}if(typeof o=="string"&&(o=st(o).split(/\s+/g)),!!o)return[o.flatMap(a=>{var c;return((c=this.expandShortcut(a,e,n-1))==null?void 0:c[0])||[a]}).filter(a=>a!==""),i]}async stringifyShortcuts(t,e,n,s={layer:this.config.shortcutsLayer}){var g;let i=new z,o=(await Promise.all(K(n).map(async p=>{let S=await this.parseUtil(p,e,!0);return S||ot(`unmatched utility "${p}" in shortcut "${t[1]}"`),S||[]}))).flat(1).filter(Boolean).sort((p,S)=>p[0]-S[0]),[a,,c]=t,u=[];for(let p of o){if(G(p)){u.push([p[0],void 0,p[1],void 0,p[2],e]);continue}let{selector:S,entries:l,parent:d,sort:v}=this.applyVariants(p,[...p[4],...c],a);i.getFallback(S,d,[[],p[0]])[0].push([l,!!((g=p[3])!=null&&g.noMerge),v??0])}return u.concat(i.map(([p,S],l,d)=>{let v=(C,w,h)=>{let m=Math.max(...h.map(b=>b[1])),y=h.map(b=>b[0]);return(C?[y.flat(1)]:y).map(b=>{let U=H(b);if(U)return[S,l,U,d,{...s,noMerge:w,sort:m},e]})};return[[p.filter(([,C])=>C).map(([C,,w])=>[C,w]),!0],[p.filter(([,C])=>!C).map(([C,,w])=>[C,w]),!1]].map(([C,w])=>[...v(!1,w,C.filter(([h])=>h.some(m=>m[0]===B))),...v(!0,w,C.filter(([h])=>h.every(m=>m[0]!==B)))])}).flat(2).filter(Boolean))}isBlocked(t){return!t||this.config.blocklist.some(e=>typeof e=="string"?e===t:e.test(t))}};function ut(r,t){return new W(r,t)}var ft=/ \$\$ /,vt=r=>r.match(ft);function Rt(r,t){return vt(r)?r.replace(ft,t?` ${t} `:" "):t?`${t} ${r}`:r}function wt(r){let t=r.match(/::[\w-]+/g);return t&&(t.forEach(e=>r=r.replace(e,"")),r+=t.join("")),r}var lt=/^\[(.+?)(~?=)"(.*)"\]$/;function Ut(r){return lt.test(r)?r.replace(lt,(t,e,n,s)=>`[${D(e)}${n}"${D(s)}"]`):`.${D(r)}`}function At(r,t){return t(r)}var $t=r=>r.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""),pt=r=>r.charAt(0).toUpperCase()+r.slice(1),dt=r=>r.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase(),gt=["Webkit","Moz","ms"];function ht(r){let t={};function e(n){let s=t[n];if(s)return s;let i=$t(n);if(i!=="filter"&&i in r)return t[n]=dt(i);i=pt(i);for(let o=0;o<gt.length;o++){let a=`${gt[o]}${i}`;if(a in r)return t[n]=dt(pt(a))}return n}return({entries:n})=>n.forEach(s=>{s[0].startsWith("--")||(s[0]=e(s[0]))})}function Z(r={}){var b,U;if(typeof window>"u"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let t=window.__unocss||{},e=t==null?void 0:t.runtime,n=Object.assign(r.defaults||{},e);if(e!=null&&e.autoPrefix){let f=n.postprocess;f||(f=[]),Array.isArray(f)||(f=[f]),f.unshift(ht(document.createElement("div").style)),n.postprocess=f}(b=e==null?void 0:e.configResolved)==null||b.call(e,t,n);let s,i=!0,o,a=ut(t,n),c=new Set,u,g=[],p=()=>new Promise(f=>{g.push(f),u!=null&&clearTimeout(u),u=setTimeout(()=>l().then(()=>{let R=g;g=[],R.forEach($=>$())}),0)});function S(f=document.body){if(f.nodeType!==1)return;let R=f;R.hasAttribute("un-cloak")&&R.removeAttribute("un-cloak"),R.querySelectorAll("[un-cloak]").forEach($=>{$.removeAttribute("un-cloak")})}async function l(){let f=await a.generate(c);s||(s=document.createElement("style"),document.documentElement.prepend(s)),s.innerHTML=f.css,c=f.matched}async function d(f){let R=c.size;await a.applyExtractors(f,void 0,c),R!==c.size&&await p()}async function v(){let f=document.body&&document.body.outerHTML;f&&(await d(f),S())}let T=new MutationObserver(f=>{i||f.forEach(async R=>{if(R.target.nodeType!==1)return;let $=R.target;if($!==s)if(R.type==="childList")R.addedNodes.forEach(async x=>{if(x.nodeType!==1)return;let E=x;o&&!o(E)||(await d(E.outerHTML),S(E))});else{if(o&&!o($))return;if(R.attributeName!=="un-cloak"){let x=Array.from($.attributes).map(A=>A.value?`${A.name}="${A.value}"`:A.name).join(" "),E=`<${$.tagName.toLowerCase()} ${x}>`;await d(E)}$.hasAttribute("un-cloak")&&$.removeAttribute("un-cloak")}})}),C=!1;function w(){if(C)return;let f=document.documentElement||document.body;!f||(T.observe(f,{childList:!0,subtree:!0,attributes:!0}),C=!0)}function h(){v(),w()}function m(){document.readyState==="loading"?window.addEventListener("DOMContentLoaded",h):h()}let y=window.__unocss_runtime=window.__unocss_runtime={version:a.version,uno:a,async extract(f){typeof f!="string"&&(f.forEach(R=>c.add(R)),f=""),await d(f)},extractAll:v,inspect(f){o=f},toggleObserver(f){f===void 0?i=!i:i=!!f,!C&&!i&&m()}};((U=e==null?void 0:e.ready)==null?void 0:U.call(e,y))!==!1&&(i=!1,m())}Z();})();
|
package/dist/index.js
CHANGED