@unocss/runtime 0.22.6 → 0.24.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/core.global.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{var gt=Object.defineProperty,ht=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var N=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&N(e,r,t[r]);if(W)for(var r of W(t))St.call(t,r)&&N(e,r,t[r]);return e},j=(e,t)=>ht(e,mt(t));function xt(e){let t=e.length,r=-1,n,i="",s=e.charCodeAt(0);for(;++r<t;){if(n=e.charCodeAt(r),n===0){i+="\uFFFD";continue}if(n===44){i+="\\2c ";continue}if(n>=1&&n<=31||n===127||r===0&&n>=48&&n<=57||r===1&&n>=48&&n<=57&&s===45){i+=`\\${n.toString(16)} `;continue}if(r===0&&t===1&&n===45){i+=`\\${e.charAt(r)}`;continue}if(n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122){i+=e.charAt(r);continue}i+=`\\${e.charAt(r)}`}return i}var v=xt;function _(e){return(Array.isArray(e)?e:Object.entries(e)).filter(t=>t[1]!=null)}function Z(e){return Array.isArray(e)?e.find(t=>!Array.isArray(t)||Array.isArray(t[0]))?e.map(t=>_(t)):[e]:[_(e)]}function Ct(e){return e.filter(([t,r],n)=>{if(t.startsWith("$$"))return!1;for(let i=n-1;i>=0;i--)if(e[i][0]===t&&e[i][1]===r)return!1;return!0})}function D(e){return e==null?"":Ct(e).map(([t,r])=>r!=null?`${t}:${r};`:void 0).filter(Boolean).join("")}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)}function F(e,t){let r=e,n=t;if(Array.isArray(r)&&Array.isArray(n))return[...r,...n];if(Array.isArray(r))return[...r];let i=O({},r);return k(r)&&k(n)&&Object.keys(n).forEach(s=>{k(n[s])?s in r?i[s]=F(r[s],n[s]):Object.assign(i,{[s]:n[s]}):Object.assign(i,{[s]:n[s]})}),i}function V(e){let t,r,n;if(Array.isArray(e)){for(r=Array(t=e.length);t--;)r[t]=(n=e[t])&&typeof n=="object"?V(n):n;return r}if(Object.prototype.toString.call(e)==="[object Object]"){r={};for(t in e)t==="__proto__"?Object.defineProperty(r,t,{value:V(e[t]),configurable:!0,enumerable:!0,writable:!0}):r[t]=(n=e[t])&&typeof n=="object"?V(n):n;return r}return e}function J(e){return typeof e[0]=="string"}function Q(e){return typeof e[0]=="string"}function M(e=[]){return Array.isArray(e)?e:[e]}function K(e){return Array.from(new Set(e))}var bt=/(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/,z="$$shortcut-no-merge";function X(e=""){return bt.test(e)}function Y(e){return typeof e=="function"?{match:e}:e}function B(e){return e.length===3}function tt(e){return e!=null}var G=class{_map=new Map;get(t,r){let n=this._map.get(t);if(n)return n.get(r)}getFallback(t,r,n){let i=this._map.get(t);return i||(i=new Map,this._map.set(t,i)),i.has(r)||i.set(r,n),i.get(r)}set(t,r,n){let i=this._map.get(t);return i||(i=new Map,this._map.set(t,i)),i.set(r,n),this}has(t,r){var n;return(n=this._map.get(t))==null?void 0:n.has(r)}delete(t,r){var n;return((n=this._map.get(t))==null?void 0:n.delete(r))||!1}deleteTop(t){return this._map.delete(t)}map(t){return Array.from(this._map.entries()).flatMap(([r,n])=>Array.from(n.entries()).map(([i,s])=>t(s,r,i)))}};var wt=/([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;function et(e){let t=[],r;for(;r=wt.exec(e);){let i=r.index,s=i+r[0].length,[,o,a,l]=r,p=l.split(/\s/g).map(h=>h.replace(/^(!?)(.*)/,`$1${o}${a}$2`)).join(" ");t.unshift([i,s,p])}let n=e;return t.forEach(([i,s,o])=>{n=n.slice(0,i)+o+n.slice(s)}),n}var rt=new Set;function nt(e){rt.has(e)||(console.warn("[unocss]",e),rt.add(e))}var Rt=e=>e.split(/[\s'"`;>=]+/g).filter(X),H={name:"split",order:0,extract({code:e}){return new Set(Rt(e))}};function Ut(e){return M(e).flatMap(t=>Array.isArray(t)?[t]:Object.entries(t))}var Et={shortcuts:-1,default:0};function I(e={},t={}){let r=Object.assign({},t,e),n=(r.presets||[]).flatMap(M),i=[...n.filter(u=>u.enforce==="pre"),...n.filter(u=>!u.enforce),...n.filter(u=>u.enforce==="post")],s=Object.assign(Et,...n.map(u=>u.layers),e.layers);function o(u){return K([...i.flatMap(x=>M(x[u]||[])),...M(r[u]||[])])}let a=o("extractors");a.length||a.push(H),a.sort((u,x)=>(u.order||0)-(x.order||0));let l=o("rules"),p={},h=l.length;l.forEach((u,x)=>{J(u)&&(p[u[0]]=[x,u[1],u[2]],delete l[x])});let S=V([...i.map(u=>u.theme||{}),r.theme||{}].reduce((u,x)=>F(u,x),{}));return o("extendTheme").forEach(u=>u(S)),j(O({mergeSelectors:!0,warn:!0,blocklist:[],safelist:[],sortLayers:u=>u},r),{presets:i,envMode:r.envMode||"build",shortcutsLayer:r.shortcutsLayer||"shortcuts",layers:s,theme:S,rulesSize:h,rulesDynamic:l,rulesStaticMap:p,preprocess:o("preprocess"),postprocess:o("postprocess"),preflights:o("preflights"),variants:o("variants").map(Y),shortcuts:Ut(o("shortcuts")),extractors:a})}var it="0.22.6";var st=class{constructor(t={},r={}){this.userConfig=t;this.defaults=r;this.config=I(t,r)}version=it;_cache=new Map;config;blocked=new Set;parentOrders=new Map;setConfig(t,r){!t||(r&&(this.defaults=r),this.userConfig=t,this.config=I(t,this.defaults),this.blocked.clear(),this.parentOrders.clear(),this._cache.clear())}async applyExtractors(t,r,n=new Set){let i={get original(){return t},code:t,id:r};for(let s of this.config.extractors){let o=await s.extract(i);o==null||o.forEach(a=>n.add(a))}return n}async generate(t,{id:r,scope:n,preflights:i=!0,safelist:s=!0,minify:o=!1}={}){let a=typeof t=="string"?await this.applyExtractors(t,r):t;s&&this.config.safelist.forEach(c=>a.add(c));let l=o?"":`
2
- `,p=new Set(["default"]),h=new Set,S=new Map,u=(c,d)=>{var g;this._cache.set(c,d),h.add(c);for(let m of d){let R=m[3]||"";S.has(R)||S.set(R,[]),S.get(R).push(m),((g=m[4])==null?void 0:g.layer)&&p.add(m[4].layer)}},x=c=>{this.blocked.add(c),this._cache.set(c,null)};await Promise.all(Array.from(a).map(async c=>{var $;if(h.has(c)||this.blocked.has(c))return;if(this._cache.has(c)){let C=this._cache.get(c);C&&u(c,C);return}let d=c;for(let C of this.config.preprocess)d=C(c);if(this.isBlocked(d))return x(d);let g=this.matchVariants(c,d);if(!g||this.isBlocked(g[1]))return x(c);let m={rawSelector:c,currentSelector:g[1],theme:this.config.theme,generator:this,variantHandlers:g[2],constructCSS:(...C)=>this.constructCustomCSS(m,...C)},R=this.expandShortcut(g[1],m);if(R){let C=await this.stringifyShortcuts(g,m,R[0],R[1]);if(C==null?void 0:C.length)return u(c,C)}else{let C=($=await this.parseUtil(g,m))==null?void 0:$.map(y=>this.stringifyUtil(y)).filter(tt);if(C==null?void 0:C.length)return u(c,C)}this._cache.set(c,null)})),i&&this.config.preflights.forEach(c=>{c.layer&&p.add(c.layer)});let E={},A=this.config.sortLayers(Array.from(p).sort((c,d)=>{var g,m;return((g=this.config.layers[c])!=null?g:0)-((m=this.config.layers[d])!=null?m:0)||c.localeCompare(d)})),b={};i&&(b=Object.fromEntries(await Promise.all(A.map(async c=>{let g=(await Promise.all(this.config.preflights.filter(m=>(m.layer||"default")===c).map(async m=>await m.getCSS()))).filter(Boolean).join(l);return[c,g]}))));let f=c=>{if(E[c])return E[c];let d=Array.from(S).sort((g,m)=>{var R,$,C;return((R=this.parentOrders.get(g[0]))!=null?R:0)-(($=this.parentOrders.get(m[0]))!=null?$:0)||((C=g[0])==null?void 0:C.localeCompare(m[0]||""))||0}).map(([g,m])=>{let R=m.length,$=m.filter(y=>{var U;return(((U=y[4])==null?void 0:U.layer)||"default")===c}).sort((y,U)=>{var P;return y[0]-U[0]||((P=y[1])==null?void 0:P.localeCompare(U[1]||""))||0}).map(y=>{var U;return[y[1]?Ot(y[1],n):y[1],y[2],!!((U=y[4])==null?void 0:U.noMerge)]}).map(y=>[y[0]==null?y[0]:[y[0]],y[1],y[2]]);if(!$.length)return;let C=$.reverse().map(([y,U,P],dt)=>{if(!P&&y&&this.config.mergeSelectors)for(let L=dt+1;L<R;L++){let T=$[L];if(T&&!T[2]&&T[0]&&T[1]===U)return T[0].push(...y),null}return y?`${[...new Set(y)].join(`,${l}`)}{${U}}`:U}).filter(Boolean).reverse().join(l);return g?`${g}{${l}${C}${l}}`:C}).filter(Boolean).join(l);return i&&(d=[b[c],d].filter(Boolean).join(l)),E[c]=!o&&d?`/* layer: ${c} */${l}${d}`:d},w=(c=A,d)=>c.filter(g=>!(d==null?void 0:d.includes(g))).map(g=>f(g)||"").filter(Boolean).join(l);return{get css(){return w()},layers:A,getLayers:w,getLayer:f,matched:h}}matchVariants(t,r){let n=new Set,i=[],s=r||t,o=!1,a={rawSelector:t,theme:this.config.theme,generator:this};for(;;){o=!1;for(let l of this.config.variants){if(!l.multiPass&&n.has(l))continue;let p=l.match(s,a);if(!!p&&(typeof p=="string"&&(p={matcher:p}),p)){s=p.matcher,Array.isArray(p.parent)&&this.parentOrders.set(p.parent[0],p.parent[1]),i.push(p),n.add(l),o=!0;break}}if(!o)break;if(i.length>500)throw new Error(`Too many variants applied to "${t}"`)}return[t,s,i]}applyVariants(t,r=t[4],n=t[1]){let i=[...r].sort((a,l)=>(a.order||0)-(l.order||0)),s=i.reduce((a,l)=>{var p;return((p=l.body)==null?void 0:p.call(l,a))||a},t[2]),o={selector:i.reduce((a,l)=>{var p;return((p=l.selector)==null?void 0:p.call(l,a,s))||a},Tt(n)),entries:s,parent:i.reduce((a,l)=>Array.isArray(l.parent)?l.parent[0]:l.parent||a,void 0)};for(let a of this.config.postprocess)a(o);return o}constructCustomCSS(t,r,n){r=_(r);let{selector:i,entries:s,parent:o}=this.applyVariants([0,n||t.rawSelector,r,void 0,t.variantHandlers]),a=`${i}{${D(s)}}`;return o?`${o}{${a}}`:a}async parseUtil(t,r,n=!1){var h,S;let[i,s,o]=typeof t=="string"?this.matchVariants(t):t,a=this.config.rulesStaticMap[s];if(a&&a[1]&&(n||!((h=a[2])==null?void 0:h.internal)))return[[a[0],i,_(a[1]),a[2],o]];r.variantHandlers=o;let{rulesDynamic:l,rulesSize:p}=this.config;for(let u=p;u>=0;u--){let x=l[u];if(!x||((S=x[2])==null?void 0:S.internal)&&!n)continue;let[E,A,b]=x,f=s.match(E);if(!f)continue;let w=await A(f,r);if(!w)continue;if(typeof w=="string")return[[u,w,b]];let c=Z(w).filter(d=>d.length);if(c.length)return c.map(d=>[u,i,d,b,o])}}stringifyUtil(t){if(!t)return;if(B(t))return[t[0],void 0,t[1],void 0,t[2]];let{selector:r,entries:n,parent:i}=this.applyVariants(t),s=D(n);if(!!s)return[t[0],r,s,i,t[3]]}expandShortcut(t,r,n=3){if(n===0)return;let i,s;for(let o of this.config.shortcuts)if(Q(o)){if(o[0]===t){i=i||o[2],s=o[1];break}}else{let a=t.match(o[0]);if(a&&(s=o[1](a,r)),s){i=i||o[2];break}}if(typeof s=="string"&&(s=et(s).split(/\s+/g)),!!s)return[s.flatMap(o=>{var a;return((a=this.expandShortcut(o,r,n-1))==null?void 0:a[0])||[o]}).filter(o=>o!==""),i]}async stringifyShortcuts(t,r,n,i={layer:this.config.shortcutsLayer}){var p;let s=new G,o=(await Promise.all(K(n).map(async h=>{let S=await this.parseUtil(h,r,!0);return S||nt(`unmatched utility "${h}" in shortcut "${t[1]}"`),S||[]}))).flat(1).filter(Boolean).sort((h,S)=>h[0]-S[0]),[a,,l]=t;for(let h of o){if(B(h))continue;let{selector:S,entries:u,parent:x}=this.applyVariants(h,[...h[4],...l],a);s.getFallback(S,x,[[],h[0]])[0].push([u,!!((p=h[3])==null?void 0:p.noMerge)])}return s.map(([h,S],u,x)=>{let E=b=>f=>{let w=D(f);if(w)return[S,u,w,x,j(O({},i),{noMerge:b})]};return[[h.filter(([,b])=>b).map(([b])=>b),!0],[h.filter(([,b])=>!b).map(([b])=>b),!1]].map(([b,f])=>{let w=b.filter(d=>d.some(g=>g[0]===z)),c=b.filter(d=>d.every(g=>g[0]!==z));return[...w.map(E(f)),...[c.flat(1)].map(E(f))]})}).flat(2).filter(Boolean)}isBlocked(t){return!t||this.config.blocklist.some(r=>typeof r=="string"?r===t:r.test(t))}};function ot(e,t){return new st(e,t)}var at=/ \$\$ /,$t=e=>e.match(at);function Ot(e,t){return $t(e)?e.replace(at,t?` ${t} `:" "):t?`${t} ${e}`:e}var ct=/^\[(.+?)(~?=)"(.*)"\]$/;function Tt(e){return ct.test(e)?e.replace(ct,(t,r,n,i)=>`[${v(r)}${n}"${v(i)}"]`):`.${v(e)}`}var _t=e=>e.replace(/-(\w)/g,(t,r)=>r?r.toUpperCase():""),lt=e=>e.charAt(0).toUpperCase()+e.slice(1),ut=e=>e.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase(),ft=["Webkit","Moz","ms"];function pt(e){let t={};function r(n){let i=t[n];if(i)return i;let s=_t(n);if(s!=="filter"&&s in e)return t[n]=ut(s);s=lt(s);for(let o=0;o<ft.length;o++){let a=`${ft[o]}${s}`;if(a in e)return t[n]=ut(lt(a))}return n}return({entries:n})=>n.forEach(i=>{i[0].startsWith("--")||(i[0]=r(i[0]))})}function q(e={}){var b;if(typeof window=="undefined"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let t=e.defaults||{};if(e.autoPrefix){let f=t.postprocess;f||(f=[]),Array.isArray(f)||(f=[f]),f.unshift(pt(document.createElement("div").style)),t.postprocess=f}Object.assign(e,(b=window.__unocss)==null?void 0:b.runtime);let r,n=!1,i,s=ot(window.__unocss||{},t),o=new Set,a,l=()=>new Promise(f=>{a!=null&&clearTimeout(a),a=setTimeout(()=>p().then(f),0)});async function p(){let f=await s.generate(o);r||(r=document.createElement("style"),document.documentElement.prepend(r)),r.innerHTML=f.css}async function h(f){await s.applyExtractors(f,void 0,o),await l()}async function S(){let f=document.body&&document.body.outerHTML;f&&await h(f)}let u=new MutationObserver(f=>{n||f.forEach(w=>{let c=w.target;if(c===r||i&&!i(c))return;let d=Array.from(c.attributes).map(m=>m.value?`${m.name}="${m.value}"`:m.name).join(" "),g=`<${c.tagName.toLowerCase()} ${d}>`;h(g)})}),x=!1;function E(){if(!x)return;let f=document.documentElement||document.body;!f||(u.observe(f,{childList:!0,subtree:!0,attributes:!0}),x=!0)}function A(){S(),E()}window.__unocss_runtime=window.__unocss_runtime={version:s.version,uno:s,async extract(f){if(typeof f=="string")return await h(f);f.forEach(w=>o.add(w)),await p()},extractAll:S,inspect(f){i=f},toggleObserver(f){f===void 0?n=!n:n=!!f}},A(),window.addEventListener("load",A),window.addEventListener("DOMContentLoaded",A)}q();})();
1
+ (()=>{var gt=Object.defineProperty,mt=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var W=(n,t,e)=>t in n?gt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$=(n,t)=>{for(var e in t||(t={}))N.call(t,e)&&W(n,e,t[e]);if(j)for(var e of j(t))Z.call(t,e)&&W(n,e,t[e]);return n},V=(n,t)=>mt(n,yt(t));var J=(n,t)=>{var e={};for(var r in n)N.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&j)for(var r of j(n))t.indexOf(r)<0&&Z.call(n,r)&&(e[r]=n[r]);return e};function St(n){let t=n.length,e=-1,r,s="",o=n.charCodeAt(0);for(;++e<t;){if(r=n.charCodeAt(e),r===0){s+="\uFFFD";continue}if(r===44){s+="\\2c ";continue}if(r>=1&&r<=31||r===127||e===0&&r>=48&&r<=57||e===1&&r>=48&&r<=57&&o===45){s+=`\\${r.toString(16)} `;continue}if(e===0&&t===1&&r===45){s+=`\\${n.charAt(e)}`;continue}if(r>=128||r===45||r===95||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122){s+=n.charAt(e);continue}s+=`\\${n.charAt(e)}`}return s}var D=St;function P(n){return(Array.isArray(n)?n:Object.entries(n)).filter(t=>t[1]!=null)}function Q(n){return Array.isArray(n)?n.find(t=>!Array.isArray(t)||Array.isArray(t[0]))?n.map(t=>P(t)):[n]:[P(n)]}function xt(n){return n.filter(([t,e],r)=>{if(t.startsWith("$$"))return!1;for(let s=r-1;s>=0;s--)if(n[s][0]===t&&n[s][1]===e)return!1;return!0})}function K(n){return n==null?"":xt(n).map(([t,e])=>e!=null?`${t}:${e};`:void 0).filter(Boolean).join("")}function L(n){return n&&typeof n=="object"&&!Array.isArray(n)}function F(n,t){let e=n,r=t;if(Array.isArray(e)&&Array.isArray(r))return[...e,...r];if(Array.isArray(e))return[...e];let s=$({},e);return L(e)&&L(r)&&Object.keys(r).forEach(o=>{L(r[o])?o in e?s[o]=F(e[o],r[o]):Object.assign(s,{[o]:r[o]}):Object.assign(s,{[o]:r[o]})}),s}function M(n){let t,e,r;if(Array.isArray(n)){for(e=Array(t=n.length);t--;)e[t]=(r=n[t])&&typeof r=="object"?M(r):r;return e}if(Object.prototype.toString.call(n)==="[object Object]"){e={};for(t in n)t==="__proto__"?Object.defineProperty(e,t,{value:M(n[t]),configurable:!0,enumerable:!0,writable:!0}):e[t]=(r=n[t])&&typeof r=="object"?M(r):r;return e}return n}function X(n){return typeof n[0]=="string"}function Y(n){return typeof n[0]=="string"}function v(n=[]){return Array.isArray(n)?n:[n]}function k(n){return Array.from(new Set(n))}var Ct=/(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/,z="$$shortcut-no-merge";function tt(n=""){return Ct.test(n)}function et(n){return typeof n=="function"?{match:n}:n}function B(n){return n.length===3}function rt(n){return n!=null}var G=class{_map=new Map;get(t,e){let r=this._map.get(t);if(r)return r.get(e)}getFallback(t,e,r){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.has(e)||s.set(e,r),s.get(e)}set(t,e,r){let s=this._map.get(t);return s||(s=new Map,this._map.set(t,s)),s.set(e,r),this}has(t,e){var r;return(r=this._map.get(t))==null?void 0:r.has(e)}delete(t,e){var r;return((r=this._map.get(t))==null?void 0:r.delete(e))||!1}deleteTop(t){return this._map.delete(t)}map(t){return Array.from(this._map.entries()).flatMap(([e,r])=>Array.from(r.entries()).map(([s,o])=>t(o,e,s)))}};var bt=/([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;function nt(n){let t=[],e;for(;e=bt.exec(n);){let s=e.index,o=s+e[0].length,[,a,i,c]=e,u=c.split(/\s/g).map(d=>d.replace(/^(!?)(.*)/,`$1${a}${i}$2`)).join(" ");t.unshift([s,o,u])}let r=n;return t.forEach(([s,o,a])=>{r=r.slice(0,s)+a+r.slice(o)}),r}var st=new Set;function it(n){st.has(n)||(console.warn("[unocss]",n),st.add(n))}var Rt=n=>n.split(/[\s'"`;>=]+/g).filter(tt),H={name:"split",order:0,extract({code:n}){return new Set(Rt(n))}};function Ut(n){return v(n).flatMap(t=>Array.isArray(t)?[t]:Object.entries(t))}var wt={shortcuts:-1,default:0};function I(n={},t={}){let e=Object.assign({},t,n),r=(e.presets||[]).flatMap(v),s=[...r.filter(l=>l.enforce==="pre"),...r.filter(l=>!l.enforce),...r.filter(l=>l.enforce==="post")],o=Object.assign(wt,...r.map(l=>l.layers),n.layers);function a(l){return k([...s.flatMap(m=>v(m[l]||[])),...v(e[l]||[])])}let i=a("extractors");i.length||i.push(H),i.sort((l,m)=>(l.order||0)-(m.order||0));let c=a("rules"),u={},d=c.length;c.forEach((l,m)=>{X(l)&&(u[l[0]]=[m,l[1],l[2]],delete c[m])});let x=M([...s.map(l=>l.theme||{}),e.theme||{}].reduce((l,m)=>F(l,m),{}));return a("extendTheme").forEach(l=>l(x)),V($({mergeSelectors:!0,warn:!0,blocklist:[],safelist:[],sortLayers:l=>l},e),{presets:s,envMode:e.envMode||"build",shortcutsLayer:e.shortcutsLayer||"shortcuts",layers:o,theme:x,rulesSize:d,rulesDynamic:c,rulesStaticMap:u,preprocess:a("preprocess"),postprocess:a("postprocess"),preflights:a("preflights"),variants:a("variants").map(et),shortcuts:Ut(a("shortcuts")),extractors:i})}var ot="0.24.1";var ct=class{constructor(t={},e={}){this.userConfig=t;this.defaults=e;this.config=I(t,e)}version=ot;_cache=new Map;config;blocked=new Set;parentOrders=new Map;setConfig(t,e){!t||(e&&(this.defaults=e),this.userConfig=t,this.config=I(t,this.defaults),this.blocked.clear(),this.parentOrders.clear(),this._cache.clear())}async applyExtractors(t,e,r=new Set){let s={get original(){return t},code:t,id:e};for(let o of this.config.extractors){let a=await o.extract(s);a==null||a.forEach(i=>r.add(i))}return r}async parseToken(t){var a;if(this.blocked.has(t))return;if(this._cache.has(t))return this._cache.get(t);let e=t;for(let i of this.config.preprocess)e=i(t);if(this.isBlocked(e)){this.blocked.add(t),this._cache.set(t,null);return}let r=this.matchVariants(t,e);if(!r||this.isBlocked(r[1])){this.blocked.add(t),this._cache.set(t,null);return}let s={rawSelector:t,currentSelector:r[1],theme:this.config.theme,generator:this,variantHandlers:r[2],constructCSS:(...i)=>this.constructCustomCSS(s,...i)},o=this.expandShortcut(r[1],s);if(o){let i=await this.stringifyShortcuts(r,s,o[0],o[1]);if(i==null?void 0:i.length)return this._cache.set(t,i),i}else{let i=(a=await this.parseUtil(r,s))==null?void 0:a.map(c=>this.stringifyUtil(c)).filter(rt);if(i==null?void 0:i.length)return this._cache.set(t,i),i}this._cache.set(t,null)}async generate(t,{id:e,scope:r,preflights:s=!0,safelist:o=!0,minify:a=!1}={}){let i=typeof t=="string"?await this.applyExtractors(t,e):t;o&&this.config.safelist.forEach(p=>i.add(p));let c=a?"":`
2
+ `,u=new Set(["default"]),d=new Set,x=new Map;await Promise.all(Array.from(i).map(async p=>{var S;if(d.has(p))return;let h=await this.parseToken(p);if(h!=null){d.add(p);for(let y of h){let R=y[3]||"";x.has(R)||x.set(R,[]),x.get(R).push(y),((S=y[4])==null?void 0:S.layer)&&u.add(y[4].layer)}}})),s&&this.config.preflights.forEach(p=>{p.layer&&u.add(p.layer)});let l={},m=this.config.sortLayers(Array.from(u).sort((p,h)=>{var S,y;return((S=this.config.layers[p])!=null?S:0)-((y=this.config.layers[h])!=null?y:0)||p.localeCompare(h)})),U={};s&&(U=Object.fromEntries(await Promise.all(m.map(async p=>{let S=(await Promise.all(this.config.preflights.filter(y=>(y.layer||"default")===p).map(async y=>await y.getCSS()))).filter(Boolean).join(c);return[p,S]}))));let A=p=>{if(l[p])return l[p];let h=Array.from(x).sort((S,y)=>{var R,E,f;return((R=this.parentOrders.get(S[0]))!=null?R:0)-((E=this.parentOrders.get(y[0]))!=null?E:0)||((f=S[0])==null?void 0:f.localeCompare(y[0]||""))||0}).map(([S,y])=>{let R=y.length,E=y.filter(g=>{var b;return(((b=g[4])==null?void 0:b.layer)||"default")===p}).sort((g,b)=>{var T,_,w;return g[0]-b[0]||(((T=g[4])==null?void 0:T.sort)||0)-(((_=b[4])==null?void 0:_.sort)||0)||((w=g[1])==null?void 0:w.localeCompare(b[1]||""))||0}).map(g=>{var b;return[g[1]?$t(g[1],r):g[1],g[2],!!((b=g[4])==null?void 0:b.noMerge)]}).map(g=>[g[0]==null?g[0]:[g[0]],g[1],g[2]]);if(!E.length)return;let f=E.reverse().map(([g,b,T],_)=>{if(!T&&g&&this.config.mergeSelectors)for(let w=_+1;w<R;w++){let O=E[w];if(O&&!O[2]&&O[0]&&O[1]===b)return O[0].push(...g),null}return g?`${[...new Set(g)].join(`,${c}`)}{${b}}`:b}).filter(Boolean).reverse().join(c);return S?`${S}{${c}${f}${c}}`:f}).filter(Boolean).join(c);return s&&(h=[U[p],h].filter(Boolean).join(c)),l[p]=!a&&h?`/* layer: ${p} */${c}${h}`:h},C=(p=m,h)=>p.filter(S=>!(h==null?void 0:h.includes(S))).map(S=>A(S)||"").filter(Boolean).join(c);return{get css(){return C()},layers:m,getLayers:C,getLayer:A,matched:d}}matchVariants(t,e){let r=new Set,s=[],o=e||t,a=!1,i={rawSelector:t,theme:this.config.theme,generator:this};for(;;){a=!1;for(let c of this.config.variants){if(!c.multiPass&&r.has(c))continue;let u=c.match(o,i);if(!!u&&(typeof u=="string"&&(u={matcher:u}),u)){o=u.matcher,Array.isArray(u.parent)&&this.parentOrders.set(u.parent[0],u.parent[1]),s.push(u),r.add(c),a=!0;break}}if(!a)break;if(s.length>500)throw new Error(`Too many variants applied to "${t}"`)}return[t,o,s]}applyVariants(t,e=t[4],r=t[1]){let s=[...e].sort((i,c)=>(i.order||0)-(c.order||0)),o=s.reduce((i,c)=>{var u;return((u=c.body)==null?void 0:u.call(c,i))||i},t[2]),a={selector:s.reduce((i,c)=>{var u;return((u=c.selector)==null?void 0:u.call(c,i,o))||i},Tt(r)),entries:o,parent:s.reduce((i,c)=>Array.isArray(c.parent)?c.parent[0]:c.parent||i,void 0),layer:s.reduce((i,c)=>c.layer||i,void 0),sort:s.reduce((i,c)=>c.sort||i,void 0)};for(let i of this.config.postprocess)i(a);return a}constructCustomCSS(t,e,r){e=P(e);let{selector:s,entries:o,parent:a}=this.applyVariants([0,r||t.rawSelector,e,void 0,t.variantHandlers]),i=`${s}{${K(o)}}`;return a?`${a}{${i}}`:i}async parseUtil(t,e,r=!1){var d,x;let[s,o,a]=typeof t=="string"?this.matchVariants(t):t,i=this.config.rulesStaticMap[o];if(i&&i[1]&&(r||!((d=i[2])==null?void 0:d.internal)))return[[i[0],s,P(i[1]),i[2],a]];e.variantHandlers=a;let{rulesDynamic:c,rulesSize:u}=this.config;for(let l=u;l>=0;l--){let m=c[l];if(!m||((x=m[2])==null?void 0:x.internal)&&!r)continue;let[U,A,C]=m,p=o.match(U);if(!p)continue;let h=await A(p,e);if(!h)continue;if(typeof h=="string")return[[l,h,C]];let S=Q(h).filter(y=>y.length);if(S.length)return S.map(y=>[l,s,y,C,a])}}stringifyUtil(t){var l;if(!t)return;if(B(t))return[t[0],void 0,t[1],void 0,t[2]];let{selector:e,entries:r,parent:s,layer:o,sort:a}=this.applyVariants(t),i=K(r);if(!i)return;let m=(l=t[3])!=null?l:{},{layer:c,sort:u}=m,d=J(m,["layer","sort"]),x=V($({},d),{layer:o!=null?o:c,sort:a!=null?a:u});return[t[0],e,i,s,x]}expandShortcut(t,e,r=3){if(r===0)return;let s,o;for(let a of this.config.shortcuts)if(Y(a)){if(a[0]===t){s=s||a[2],o=a[1];break}}else{let i=t.match(a[0]);if(i&&(o=a[1](i,e)),o){s=s||a[2];break}}if(typeof o=="string"&&(o=nt(o).split(/\s+/g)),!!o)return[o.flatMap(a=>{var i;return((i=this.expandShortcut(a,e,r-1))==null?void 0:i[0])||[a]}).filter(a=>a!==""),s]}async stringifyShortcuts(t,e,r,s={layer:this.config.shortcutsLayer}){var u;let o=new G,a=(await Promise.all(k(r).map(async d=>{let x=await this.parseUtil(d,e,!0);return x||it(`unmatched utility "${d}" in shortcut "${t[1]}"`),x||[]}))).flat(1).filter(Boolean).sort((d,x)=>d[0]-x[0]),[i,,c]=t;for(let d of a){if(B(d))continue;let{selector:x,entries:l,parent:m}=this.applyVariants(d,[...d[4],...c],i);o.getFallback(x,m,[[],d[0]])[0].push([l,!!((u=d[3])==null?void 0:u.noMerge)])}return o.map(([d,x],l,m)=>{let U=C=>p=>{let h=K(p);if(h)return[x,l,h,m,V($({},s),{noMerge:C})]};return[[d.filter(([,C])=>C).map(([C])=>C),!0],[d.filter(([,C])=>!C).map(([C])=>C),!1]].map(([C,p])=>{let h=C.filter(y=>y.some(R=>R[0]===z)),S=C.filter(y=>y.every(R=>R[0]!==z));return[...h.map(U(p)),...[S.flat(1)].map(U(p))]})}).flat(2).filter(Boolean)}isBlocked(t){return!t||this.config.blocklist.some(e=>typeof e=="string"?e===t:e.test(t))}};function lt(n,t){return new ct(n,t)}var ut=/ \$\$ /,At=n=>n.match(ut);function $t(n,t){return At(n)?n.replace(ut,t?` ${t} `:" "):t?`${t} ${n}`:n}var at=/^\[(.+?)(~?=)"(.*)"\]$/;function Tt(n){return at.test(n)?n.replace(at,(t,e,r,s)=>`[${D(e)}${r}"${D(s)}"]`):`.${D(n)}`}var _t=n=>n.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""),ft=n=>n.charAt(0).toUpperCase()+n.slice(1),pt=n=>n.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase(),dt=["Webkit","Moz","ms"];function ht(n){let t={};function e(r){let s=t[r];if(s)return s;let o=_t(r);if(o!=="filter"&&o in n)return t[r]=pt(o);o=ft(o);for(let a=0;a<dt.length;a++){let i=`${dt[a]}${o}`;if(i in n)return t[r]=pt(ft(i))}return r}return({entries:r})=>r.forEach(s=>{s[0].startsWith("--")||(s[0]=e(s[0]))})}function q(n={}){var R,E;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,r=Object.assign(n.defaults||{},e);if(e==null?void 0:e.autoPrefix){let f=r.postprocess;f||(f=[]),Array.isArray(f)||(f=[f]),f.unshift(ht(document.createElement("div").style)),r.postprocess=f}(R=e==null?void 0:e.configResolved)==null||R.call(e,t,r);let s,o=!0,a,i=lt(t,r),c=new Set,u,d=[],x=()=>new Promise(f=>{d.push(f),u!=null&&clearTimeout(u),u=setTimeout(()=>l().then(()=>{let g=d;d=[],g.forEach(b=>b())}),0)});async function l(){let f=await i.generate(c);s||(s=document.createElement("style"),document.documentElement.prepend(s)),s.innerHTML=f.css}async function m(f){await i.applyExtractors(f,void 0,c),await x()}async function U(){let f=document.body&&document.body.outerHTML;f&&await m(f)}let A=new MutationObserver(f=>{o||f.forEach(g=>{let b=g.target;if(b===s||a&&!a(b))return;let T=Array.from(b.attributes).map(w=>w.value?`${w.name}="${w.value}"`:w.name).join(" "),_=`<${b.tagName.toLowerCase()} ${T}>`;m(_)})}),C=!1;function p(){if(!C)return;let f=document.documentElement||document.body;!f||(A.observe(f,{childList:!0,subtree:!0,attributes:!0}),C=!0)}function h(){U(),p()}function S(){h(),window.addEventListener("load",h),window.addEventListener("DOMContentLoaded",h)}let y=window.__unocss_runtime=window.__unocss_runtime={version:i.version,uno:i,async extract(f){if(typeof f=="string")return await m(f);f.forEach(g=>c.add(g)),await l()},extractAll:U,inspect(f){a=f},toggleObserver(f){f===void 0?o=!o:o=!!f,!C&&!o&&S()}};((E=e==null?void 0:e.ready)==null?void 0:E.call(e,y))!==!1&&(o=!1,S())}q();})();
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UserConfig, UnoGenerator, UserConfigDefaults } from '@unocss/core';
1
+ import { UserConfig, UserConfigDefaults, UnoGenerator } from '@unocss/core';
2
2
 
3
3
  interface RuntimeOptions {
4
4
  /**
@@ -10,57 +10,66 @@ interface RuntimeOptions {
10
10
  * @default false
11
11
  */
12
12
  autoPrefix?: boolean;
13
+ /**
14
+ * Callback to modify config
15
+ */
16
+ configResolved?: (config: UserConfig, defaults: UserConfigDefaults) => void;
17
+ /**
18
+ * Callback when the runtime is ready. Returning false will prevent default extraction
19
+ */
20
+ ready?: (runtime: RuntimeContext) => false | any;
13
21
  }
14
22
  declare type RuntimeInspectorCallback = (element: Element) => boolean;
23
+ interface RuntimeContext {
24
+ /**
25
+ * The UnoCSS instance.
26
+ *
27
+ * @type {UnoGenerator}
28
+ */
29
+ uno: UnoGenerator;
30
+ /**
31
+ * Run extractor on specified tokens
32
+ *
33
+ * @returns {Promise<void>}
34
+ */
35
+ extract: (tokens: string | string[]) => Promise<void>;
36
+ /**
37
+ * Rerun extractor on the whole <body>, regardless of paused status or inspection limitation.
38
+ *
39
+ * @returns {Promise<void>}
40
+ */
41
+ extractAll: () => Promise<void>;
42
+ /**
43
+ * Set/unset inspection callback to allow/ignore element to be extracted.
44
+ *
45
+ * @param {RuntimeInspectorCallback} [callback] - Callback to determine whether the element will be extracted.
46
+ *
47
+ * @returns {void}
48
+ */
49
+ inspect: (callback?: RuntimeInspectorCallback) => void;
50
+ /**
51
+ * Pause/resume/toggle the runtime.
52
+ *
53
+ * @param {boolean} [state] - False or True respectively pause or resume the runtime. Undefined parameter toggles the pause/resume state.
54
+ *
55
+ * @returns {void}
56
+ */
57
+ toggleObserver: (state?: boolean) => void;
58
+ /**
59
+ * The UnoCSS version.
60
+ *
61
+ * @type {string}
62
+ */
63
+ version: string;
64
+ }
15
65
  declare global {
16
66
  interface Window {
17
67
  __unocss?: UserConfig & {
18
68
  runtime?: RuntimeOptions;
19
69
  };
20
- __unocss_runtime?: {
21
- /**
22
- * The UnoCSS instance.
23
- *
24
- * @type {UnoGenerator}
25
- */
26
- uno: UnoGenerator;
27
- /**
28
- * Run extractor on specified tokens
29
- *
30
- * @returns {Promise<void>}
31
- */
32
- extract: (tokens: string | string[]) => Promise<void>;
33
- /**
34
- * Rerun extractor on the whole <body>, regardless of paused status or inspection limitation.
35
- *
36
- * @returns {Promise<void>}
37
- */
38
- extractAll: () => Promise<void>;
39
- /**
40
- * Set/unset inspection callback to allow/ignore element to be extracted.
41
- *
42
- * @param {RuntimeInspectorCallback} [callback] - Callback to determine whether the element will be extracted.
43
- *
44
- * @returns {void}
45
- */
46
- inspect: (callback?: RuntimeInspectorCallback) => void;
47
- /**
48
- * Pause/resume/toggle the runtime.
49
- *
50
- * @param {boolean} [state] - False or True respectively pause or resume the runtime. Undefined parameter toggles the pause/resume state.
51
- *
52
- * @returns {void}
53
- */
54
- toggleObserver: (state?: boolean) => void;
55
- /**
56
- * The UnoCSS version.
57
- *
58
- * @type {string}
59
- */
60
- version: string;
61
- };
70
+ __unocss_runtime?: RuntimeContext;
62
71
  }
63
72
  }
64
- declare function init(options?: RuntimeOptions): void;
73
+ declare function init(inlineConfig?: RuntimeOptions): void;
65
74
 
66
- export { RuntimeInspectorCallback, RuntimeOptions, init as default };
75
+ export { RuntimeContext, RuntimeInspectorCallback, RuntimeOptions, init as default };
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
6
  var __export = (target, all) => {
@@ -17,9 +15,6 @@ var __reExport = (target, module2, copyDefault, desc) => {
17
15
  }
18
16
  return target;
19
17
  };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
18
  var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
19
  return (module2, temp) => {
25
20
  return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
@@ -31,7 +26,7 @@ var src_exports = {};
31
26
  __export(src_exports, {
32
27
  default: () => init
33
28
  });
34
- var import_core = __toESM(require("@unocss/core"));
29
+ var import_core = require("@unocss/core");
35
30
 
36
31
  // src/utils.ts
37
32
  var camelize = (str) => str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : "");
@@ -62,33 +57,41 @@ function autoPrefixer(style) {
62
57
  }
63
58
 
64
59
  // src/index.ts
65
- function init(options = {}) {
66
- var _a;
60
+ function init(inlineConfig = {}) {
61
+ var _a, _b;
67
62
  if (typeof window == "undefined") {
68
63
  console.warn("@unocss/runtime been used in non-browser environment, skipped.");
69
64
  return;
70
65
  }
71
- const defaultOptions = options.defaults || {};
72
- if (options.autoPrefix) {
73
- let postprocess = defaultOptions.postprocess;
66
+ const config = window.__unocss || {};
67
+ const runtime = config == null ? void 0 : config.runtime;
68
+ const defaultConfig = Object.assign(inlineConfig.defaults || {}, runtime);
69
+ if (runtime == null ? void 0 : runtime.autoPrefix) {
70
+ let postprocess = defaultConfig.postprocess;
74
71
  if (!postprocess)
75
72
  postprocess = [];
76
73
  if (!Array.isArray(postprocess))
77
74
  postprocess = [postprocess];
78
75
  postprocess.unshift(autoPrefixer(document.createElement("div").style));
79
- defaultOptions.postprocess = postprocess;
76
+ defaultConfig.postprocess = postprocess;
80
77
  }
81
- Object.assign(options, (_a = window.__unocss) == null ? void 0 : _a.runtime);
78
+ (_a = runtime == null ? void 0 : runtime.configResolved) == null ? void 0 : _a.call(runtime, config, defaultConfig);
82
79
  let styleElement;
83
- let paused = false;
80
+ let paused = true;
84
81
  let inspector;
85
- const uno = (0, import_core.createGenerator)(window.__unocss || {}, defaultOptions);
82
+ const uno = (0, import_core.createGenerator)(config, defaultConfig);
86
83
  const tokens = /* @__PURE__ */ new Set();
87
84
  let _timer;
85
+ let _resolvers = [];
88
86
  const scheduleUpdate = () => new Promise((resolve) => {
87
+ _resolvers.push(resolve);
89
88
  if (_timer != null)
90
89
  clearTimeout(_timer);
91
- _timer = setTimeout(() => updateStyle().then(resolve), 0);
90
+ _timer = setTimeout(() => updateStyle().then(() => {
91
+ const resolvers = _resolvers;
92
+ _resolvers = [];
93
+ resolvers.forEach((r) => r());
94
+ }), 0);
92
95
  });
93
96
  async function updateStyle() {
94
97
  const result = await uno.generate(tokens);
@@ -139,7 +142,12 @@ function init(options = {}) {
139
142
  extractAll();
140
143
  observe();
141
144
  }
142
- window.__unocss_runtime = window.__unocss_runtime = {
145
+ function ready() {
146
+ execute();
147
+ window.addEventListener("load", execute);
148
+ window.addEventListener("DOMContentLoaded", execute);
149
+ }
150
+ const unoCssRuntime = window.__unocss_runtime = window.__unocss_runtime = {
143
151
  version: uno.version,
144
152
  uno,
145
153
  async extract(userTokens) {
@@ -157,11 +165,14 @@ function init(options = {}) {
157
165
  paused = !paused;
158
166
  else
159
167
  paused = !!set;
168
+ if (!observing && !paused)
169
+ ready();
160
170
  }
161
171
  };
162
- execute();
163
- window.addEventListener("load", execute);
164
- window.addEventListener("DOMContentLoaded", execute);
172
+ if (((_b = runtime == null ? void 0 : runtime.ready) == null ? void 0 : _b.call(runtime, unoCssRuntime)) !== false) {
173
+ paused = false;
174
+ ready();
175
+ }
165
176
  }
166
177
  module.exports = __toCommonJS(src_exports);
167
178
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -30,33 +30,41 @@ function autoPrefixer(style) {
30
30
  }
31
31
 
32
32
  // src/index.ts
33
- function init(options = {}) {
34
- var _a;
33
+ function init(inlineConfig = {}) {
34
+ var _a, _b;
35
35
  if (typeof window == "undefined") {
36
36
  console.warn("@unocss/runtime been used in non-browser environment, skipped.");
37
37
  return;
38
38
  }
39
- const defaultOptions = options.defaults || {};
40
- if (options.autoPrefix) {
41
- let postprocess = defaultOptions.postprocess;
39
+ const config = window.__unocss || {};
40
+ const runtime = config == null ? void 0 : config.runtime;
41
+ const defaultConfig = Object.assign(inlineConfig.defaults || {}, runtime);
42
+ if (runtime == null ? void 0 : runtime.autoPrefix) {
43
+ let postprocess = defaultConfig.postprocess;
42
44
  if (!postprocess)
43
45
  postprocess = [];
44
46
  if (!Array.isArray(postprocess))
45
47
  postprocess = [postprocess];
46
48
  postprocess.unshift(autoPrefixer(document.createElement("div").style));
47
- defaultOptions.postprocess = postprocess;
49
+ defaultConfig.postprocess = postprocess;
48
50
  }
49
- Object.assign(options, (_a = window.__unocss) == null ? void 0 : _a.runtime);
51
+ (_a = runtime == null ? void 0 : runtime.configResolved) == null ? void 0 : _a.call(runtime, config, defaultConfig);
50
52
  let styleElement;
51
- let paused = false;
53
+ let paused = true;
52
54
  let inspector;
53
- const uno = createGenerator(window.__unocss || {}, defaultOptions);
55
+ const uno = createGenerator(config, defaultConfig);
54
56
  const tokens = /* @__PURE__ */ new Set();
55
57
  let _timer;
58
+ let _resolvers = [];
56
59
  const scheduleUpdate = () => new Promise((resolve) => {
60
+ _resolvers.push(resolve);
57
61
  if (_timer != null)
58
62
  clearTimeout(_timer);
59
- _timer = setTimeout(() => updateStyle().then(resolve), 0);
63
+ _timer = setTimeout(() => updateStyle().then(() => {
64
+ const resolvers = _resolvers;
65
+ _resolvers = [];
66
+ resolvers.forEach((r) => r());
67
+ }), 0);
60
68
  });
61
69
  async function updateStyle() {
62
70
  const result = await uno.generate(tokens);
@@ -107,7 +115,12 @@ function init(options = {}) {
107
115
  extractAll();
108
116
  observe();
109
117
  }
110
- window.__unocss_runtime = window.__unocss_runtime = {
118
+ function ready() {
119
+ execute();
120
+ window.addEventListener("load", execute);
121
+ window.addEventListener("DOMContentLoaded", execute);
122
+ }
123
+ const unoCssRuntime = window.__unocss_runtime = window.__unocss_runtime = {
111
124
  version: uno.version,
112
125
  uno,
113
126
  async extract(userTokens) {
@@ -125,11 +138,14 @@ function init(options = {}) {
125
138
  paused = !paused;
126
139
  else
127
140
  paused = !!set;
141
+ if (!observing && !paused)
142
+ ready();
128
143
  }
129
144
  };
130
- execute();
131
- window.addEventListener("load", execute);
132
- window.addEventListener("DOMContentLoaded", execute);
145
+ if (((_b = runtime == null ? void 0 : runtime.ready) == null ? void 0 : _b.call(runtime, unoCssRuntime)) !== false) {
146
+ paused = false;
147
+ ready();
148
+ }
133
149
  }
134
150
  export {
135
151
  init as default