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