@unocss/runtime 0.64.1 → 0.65.0-beta.2
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 +7 -7
- package/core.global.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/full.global.js +9 -9
- package/mini.global.js +10 -10
- package/package.json +4 -4
- package/preset-attributify.global.js +1 -1
- package/preset-icons.global.js +3 -3
- package/preset-mini.global.js +6 -6
- package/preset-typography.global.js +1 -1
- package/preset-uno.global.js +10 -10
- package/preset-wind.global.js +10 -10
- package/uno.global.js +7 -7
package/core.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var G="default",N="preflights",Pe="shortcuts",Oe="imports",ce={[Oe]:-200,[N]:-100,[Pe]:-10,[G]:0};var le=/[\\:]?[\s'"`;{}]+/g;function je(n){return n.split(le)}var z={name:"@unocss/core/extractor-split",order:0,extract({code:n}){return je(n)}};function V(n=[]){return Array.isArray(n)?n:[n]}function j(n){return Array.from(new Set(n))}function te(n,e){return n.reduce((t,r)=>(t.findIndex(i=>e(r,i))===-1&&t.push(r),t),[])}function w(n){return typeof n=="string"}var H=class extends Set{_map;constructor(e){super(e),this._map??=new Map}add(e){return this._map??=new Map,this._map.set(e,(this._map.get(e)??0)+1),super.add(e)}delete(e){return this._map.delete(e),super.delete(e)}clear(){this._map.clear(),super.clear()}getCount(e){return this._map.get(e)??0}setCount(e,t){return this._map.set(e,t),super.add(e)}};function W(n){return n instanceof H}function _e(n){let e=n.length,t=-1,r,s="",i=n.charCodeAt(0);for(;++t<e;){if(r=n.charCodeAt(t),r===0){s+="\uFFFD";continue}if(r===37){s+="\\%";continue}if(r===44){s+="\\,";continue}if(r>=1&&r<=31||r===127||t===0&&r>=48&&r<=57||t===1&&r>=48&&r<=57&&i===45){s+=`\\${r.toString(16)} `;continue}if(t===0&&e===1&&r===45){s+=`\\${n.charAt(t)}`;continue}if(r>=128||r===45||r===95||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122){s+=n.charAt(t);continue}s+=`\\${n.charAt(t)}`}return s}var Y=_e;function ue(n){return typeof n=="function"?{match:n}:n}function ne(n){return n.length===3}function re(n){return n!=null}function fe(){}var q=class{_map=new Map;get(e,t){let r=this._map.get(e);if(r)return r.get(t)}getFallback(e,t,r){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.has(t)||s.set(t,r),s.get(t)}set(e,t,r){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.set(t,r),this}has(e,t){return this._map.get(e)?.has(t)}delete(e,t){return this._map.get(e)?.delete(t)||!1}deleteTop(e){return this._map.delete(e)}map(e){return Array.from(this._map.entries()).flatMap(([t,r])=>Array.from(r.entries()).map(([s,i])=>e(i,t,s)))}},Z=class extends Map{getFallback(e,t){let r=this.get(e);return r===void 0?(this.set(e,t),t):r}map(e){let t=[];return this.forEach((r,s)=>{t.push(e(r,s))}),t}flatMap(e){let t=[];return this.forEach((r,s)=>{t.push(...e(r,s))}),t}};function K(n){return w(n)?n:(Array.isArray(n)?n:Object.entries(n)).filter(e=>e[1]!=null)}function pe(n){return Array.isArray(n)?n.find(e=>!Array.isArray(e)||Array.isArray(e[0]))?n.map(e=>K(e)):[n]:[K(n)]}function ke(n){return n.filter(([e,t],r)=>{if(e.startsWith("$$"))return!1;for(let s=r-1;s>=0;s--)if(n[s][0]===e&&n[s][1]===t)return!1;return!0})}function Q(n){return n==null?"":ke(n).map(([e,t])=>t!=null&&typeof t!="function"?`${e}:${t};`:void 0).filter(Boolean).join("")}function J(n){return n&&typeof n=="object"&&!Array.isArray(n)}function se(n,e,t=!1){let r=n,s=e;if(Array.isArray(s))return t&&Array.isArray(s)?[...r,...s]:[...s];let i={...r};return J(r)&&J(s)&&Object.keys(s).forEach(l=>{J(r[l])&&J(s[l])||Array.isArray(r[l])&&Array.isArray(s[l])?i[l]=se(r[l],s[l],t):Object.assign(i,{[l]:s[l]})}),i}function B(n){let e,t,r;if(Array.isArray(n)){for(t=Array.from({length:e=n.length});e--;)t[e]=(r=n[e])&&typeof r=="object"?B(r):r;return t}if(Object.prototype.toString.call(n)==="[object Object]"){t={};for(e in n)e==="__proto__"?Object.defineProperty(t,e,{value:B(n[e]),configurable:!0,enumerable:!0,writable:!0}):t[e]=(r=n[e])&&typeof r=="object"?B(r):r;return t}return n}function de(n){return w(n[0])}function me(n){return w(n[0])}var X={};function Le(n=["-",":"]){let e=n.join("|");return X[e]||(X[e]=new RegExp(`((?:[!@<~\\w+:_-]|\\[&?>?:?\\S*\\])+?)(${e})\\(((?:[~!<>\\w\\s:/\\\\,%#.$?-]|\\[.*?\\])+?)\\)(?!\\s*?=>)`,"gm")),X[e].lastIndex=0,X[e]}function De(n,e=["-",":"],t=5){let r=Le(e),s,i=n.toString(),l=new Set,a=new Map;do s=!1,i=i.replace(r,(p,u,f,x,S)=>{if(!e.includes(f))return p;s=!0,l.add(u+f);let v=S+u.length+f.length+1,M={length:p.length,items:[]};a.set(S,M);for(let T of[...x.matchAll(/\S+/g)]){let $=v+T.index,m=a.get($)?.items;m?a.delete($):m=[{offset:$,length:T[0].length,className:T[0]}];for(let g of m)g.className=g.className==="~"?u:g.className.replace(/^(!?)(.*)/,`$1${u}${f}$2`),M.items.push(g)}return"$".repeat(p.length)}),t-=1;while(s&&t);let o;if(typeof n=="string"){o="";let p=0;for(let[u,f]of a)o+=n.slice(p,u),o+=f.items.map(x=>x.className).join(" "),p=u+f.length;o+=n.slice(p)}else{o=n;for(let[p,u]of a)o.overwrite(p,p+u.length,u.items.map(f=>f.className).join(" "))}return{prefixes:Array.from(l),hasChanged:s,groupsByOffset:a,get expanded(){return o.toString()}}}function ge(n,e=["-",":"],t=5){let r=De(n,e,t);return typeof n=="string"?r.expanded:n}var he=new Set;function ye(n){he.has(n)||(console.warn("[unocss]",n),he.add(n))}function be(n){return V(n).flatMap(e=>Array.isArray(e)?[e]:Object.entries(e))}var xe="_uno_resolved";function Fe(n){let e=typeof n=="function"?n():n;if(xe in e)return e;e={...e},Object.defineProperty(e,xe,{value:!0,enumerable:!1});let t=e.shortcuts?be(e.shortcuts):void 0;if(e.shortcuts=t,e.prefix||e.layer){let r=s=>{s[2]||(s[2]={});let i=s[2];i.prefix==null&&e.prefix&&(i.prefix=V(e.prefix)),i.layer==null&&e.layer&&(i.layer=e.layer)};t?.forEach(r),e.rules?.forEach(r)}return e}function Ce(n){let e=Fe(n);if(!e.presets)return[e];let t=(e.presets||[]).flatMap(V).flatMap(Ce);return[e,...t]}function Ke(n){if(n.length===0)return{};let e=[],t=[],r=!1,s=[],i=[],l=[];for(let o of n){if(o.pipeline===!1){r=!0;break}else o.pipeline?.include&&e.push(o.pipeline.include),o.pipeline?.exclude&&t.push(o.pipeline.exclude);o.filesystem&&s.push(o.filesystem),o.inline&&i.push(o.inline),o.plain&&l.push(o.plain)}let a={pipeline:r?!1:{include:j(Se(...e)),exclude:j(Se(...t))}};return s.length&&(a.filesystem=j(s.flat())),i.length&&(a.inline=j(i.flat())),l.length&&(a.plain=j(l.flat())),a}function ie(n={},e={}){let t=Object.assign({},e,n),r=te((t.presets||[]).flatMap(V).flatMap(Ce),(c,d)=>c.name===d.name),s=[...r.filter(c=>c.enforce==="pre"),...r.filter(c=>!c.enforce),...r.filter(c=>c.enforce==="post")],i=[...s,t],l=[...i].reverse(),a=Object.assign({},ce,...i.map(c=>c.layers));function o(c){return j(i.flatMap(d=>V(d[c]||[])))}let p=o("extractors"),u=l.find(c=>c.extractorDefault!==void 0)?.extractorDefault;u===void 0&&(u=z),u&&!p.includes(u)&&p.unshift(u),p.sort((c,d)=>(c.order||0)-(d.order||0));let f=o("rules"),x={},S=f.length,v=f.map((c,d)=>{if(de(c)){V(c[2]?.prefix||"").forEach(A=>{x[A+c[0]]=[d,c[1],c[2],c]});return}return[d,...c]}).filter(Boolean).reverse(),M=Ie(i.map(c=>c.theme)),T=o("extendTheme");for(let c of T)M=c(M)||M;let $={templates:j(i.flatMap(c=>V(c.autocomplete?.templates))),extractors:i.flatMap(c=>V(c.autocomplete?.extractors)).sort((c,d)=>(c.order||0)-(d.order||0)),shorthands:Ge(i.map(c=>c.autocomplete?.shorthands||{}))},m=o("separators");m.length||(m=[":","-"]);let g=o("content"),E=Ke(g),P={mergeSelectors:!0,warn:!0,sortLayers:c=>c,...t,blocklist:o("blocklist"),presets:s,envMode:t.envMode||"build",shortcutsLayer:t.shortcutsLayer||"shortcuts",layers:a,theme:M,rulesSize:S,rulesDynamic:v,rulesStaticMap:x,preprocess:o("preprocess"),postprocess:o("postprocess"),preflights:o("preflights"),autocomplete:$,variants:o("variants").map(ue).sort((c,d)=>(c.order||0)-(d.order||0)),shortcuts:be(o("shortcuts")).reverse(),extractors:p,safelist:o("safelist"),separators:m,details:t.details??t.envMode==="dev",content:E,transformers:te(o("transformers"),(c,d)=>c.name===d.name)};for(let c of i)c?.configResolved?.(P);return P}function Ie(n){return n.map(e=>e?B(e):{}).reduce((e,t)=>se(e,t),{})}function Ge(n){return n.reduce((e,t)=>{let r={};for(let s in t){let i=t[s];Array.isArray(i)?r[s]=`(${i.join("|")})`:r[s]=i}return{...e,...r}},{})}function Se(...n){return n.flatMap(He)}function He(n){return Array.isArray(n)?n:n?[n]:[]}var Te="0.64.1";function Ee(){return{events:{},emit(n,...e){(this.events[n]||[]).forEach(t=>t(...e))},on(n,e){return(this.events[n]=this.events[n]||[]).push(e),()=>this.events[n]=(this.events[n]||[]).filter(t=>t!==e)}}}var F={shortcutsNoMerge:"$$symbol-shortcut-no-merge",variants:"$$symbol-variants",parent:"$$symbol-parent",selector:"$$symbol-selector",layer:"$$symbol-layer"},oe=class{constructor(e={},t={}){this.userConfig=e;this.defaults=t;this.config=ie(e,t),this.events.emit("config",this.config)}version=Te;_cache=new Map;config;blocked=new Set;parentOrders=new Map;events=Ee();setConfig(e,t){e&&(t&&(this.defaults=t),this.userConfig=e,this.blocked.clear(),this.parentOrders.clear(),this._cache.clear(),this.config=ie(e,this.defaults),this.events.emit("config",this.config))}async applyExtractors(e,t,r=new Set){let s={original:e,code:e,id:t,extracted:r,envMode:this.config.envMode};for(let i of this.config.extractors){let l=await i.extract?.(s);if(l)if(W(l)&&W(r))for(let a of l)r.setCount(a,r.getCount(a)+l.getCount(a));else for(let a of l)r.add(a)}return r}makeContext(e,t){let r={rawSelector:e,currentSelector:t[1],theme:this.config.theme,generator:this,symbols:F,variantHandlers:t[2],constructCSS:(...s)=>this.constructCustomCSS(r,...s),variantMatch:t};return r}async parseToken(e,t){if(this.blocked.has(e))return;let r=`${e}${t?` ${t}`:""}`;if(this._cache.has(r))return this._cache.get(r);let s=e;for(let p of this.config.preprocess)s=p(e);if(this.isBlocked(s)){this.blocked.add(e),this._cache.set(r,null);return}let i=await this.matchVariants(e,s);if(!i||this.isBlocked(i[1])){this.blocked.add(e),this._cache.set(r,null);return}let l=this.makeContext(e,[t||i[0],i[1],i[2],i[3]]);this.config.details&&(l.variants=[...i[3]]);let a=await this.expandShortcut(l.currentSelector,l),o=a?await this.stringifyShortcuts(l.variantMatch,l,a[0],a[1]):(await this.parseUtil(l.variantMatch,l))?.map(p=>this.stringifyUtil(p,l)).filter(re);if(o?.length)return this._cache.set(r,o),o;this._cache.set(r,null)}async generate(e,t={}){let{id:r,scope:s,preflights:i=!0,safelist:l=!0,minify:a=!1,extendedInfo:o=!1}=t,p=this.config.outputToCssLayers,u=w(e)?await this.applyExtractors(e,r,o?new H:new Set):Array.isArray(e)?new Set(e):e;if(l){let c={generator:this,theme:this.config.theme};this.config.safelist.flatMap(d=>typeof d=="function"?d(c):d).forEach(d=>{u.has(d)||u.add(d)})}let f=a?"":`
|
|
2
|
-
`,x=new Set([G]),S=o?new Map:new Set,v=new Map,M={},T=Array.from(u).map(async c=>{if(S.has(c))return;let d=await this.parseToken(c);if(d!=null){S instanceof Map?S.set(c,{data:d,count:W(u)?u.getCount(c):-1}):S.add(c);for(let R of d){let A=R[3]||"",O=R[4]?.layer;v.has(A)||v.set(A,[]),v.get(A).push(R),O&&x.add(O)}}});await Promise.all(T),await(async()=>{if(!i)return;let c={generator:this,theme:this.config.theme},d=new Set([]);this.config.preflights.forEach(({layer:R=N})=>{x.add(R),d.add(R)}),M=Object.fromEntries(await Promise.all(Array.from(d).map(async R=>{let O=(await Promise.all(this.config.preflights.filter(k=>(k.layer||N)===R).map(async k=>await k.getCSS(c)))).filter(Boolean).join(f);return[R,O]})))})();let $=this.config.sortLayers(Array.from(x).sort((c,d)=>(this.config.layers[c]??0)-(this.config.layers[d]??0)||c.localeCompare(d))),m={},g=(c=G)=>{if(m[c])return m[c];let d=Array.from(v).sort((A,O)=>(this.parentOrders.get(A[0])??0)-(this.parentOrders.get(O[0])??0)||A[0]?.localeCompare(O[0]||"")||0).map(([A,O])=>{let k=O.length,I=O.filter(h=>(h[4]?.layer||G)===c).sort((h,b)=>h[0]-b[0]||(h[4]?.sort||0)-(b[4]?.sort||0)||h[5]?.currentSelector?.localeCompare(b[5]?.currentSelector??"")||h[1]?.localeCompare(b[1]||"")||h[2]?.localeCompare(b[2]||"")||0).map(([,h,b,,U,,L])=>[[[(h&&ze(h,s))??"",U?.sort??0]],b,!!(L??U?.noMerge)]);if(!I.length)return;let y=I.reverse().map(([h,b,U],L)=>{if(!U&&this.config.mergeSelectors)for(let D=L+1;D<k;D++){let _=I[D];if(_&&!_[2]&&(h&&_[0]||h==null&&_[0]==null)&&_[1]===b)return h&&_[0]&&_[0].push(...h),null}let ee=h?j(h.sort((D,_)=>D[1]-_[1]||D[0]?.localeCompare(_[0]||"")||0).map(D=>D[0]).filter(Boolean)):[];return ee.length?`${ee.join(`,${f}`)}{${b}}`:b}).filter(Boolean).reverse().join(f);if(!A)return y;let C=A.split(" $$ ");return`${C.join("{")}{${f}${y}${f}${"}".repeat(C.length)}`}).filter(Boolean).join(f);if(i&&(d=[M[c],d].filter(Boolean).join(f)),p&&d){let A=typeof p=="object"?p.cssLayerName?.(c):void 0;A!==null&&(A||(A=c),d=`@layer ${A}{${f}${d}${f}}`)}let R=a?"":`/* layer: ${c} */${f}`;return m[c]=d?R+d:""},E=(c=$,d)=>c.filter(R=>!d?.includes(R)).map(R=>g(R)||"").filter(Boolean).join(f);return{get css(){return E()},layers:$,matched:S,getLayers:E,getLayer:g,setLayer:async(c,d)=>{let R=await d(g(c));return m[c]=R,R}}}async matchVariants(e,t){let r=new Set,s=[],i=t||e,l=!0,a={rawSelector:e,theme:this.config.theme,generator:this};for(;l;){l=!1;for(let o of this.config.variants){if(!o.multiPass&&r.has(o))continue;let p=await o.match(i,a);if(p){if(w(p)){if(p===i)continue;p={matcher:p}}i=p.matcher??i,s.unshift(p),r.add(o),l=!0;break}}if(!l)break;if(s.length>500)throw new Error(`Too many variants applied to "${e}"`)}return[e,i,s,r]}applyVariants(e,t=e[4],r=e[1]){let i=t.slice().sort((p,u)=>(p.order||0)-(u.order||0)).reduceRight((p,u)=>f=>{let x=u.body?.(f.entries)||f.entries,S=Array.isArray(u.parent)?u.parent:[u.parent,void 0];return(u.handle??Ye)({...f,entries:x,selector:u.selector?.(f.selector,x)||f.selector,parent:S[0]||f.parent,parentOrder:S[1]||f.parentOrder,layer:u.layer||f.layer,sort:u.sort||f.sort},p)},p=>p)({prefix:"",selector:We(r),pseudo:"",entries:e[2]}),{parent:l,parentOrder:a}=i;l!=null&&a!=null&&this.parentOrders.set(l,a);let o={selector:[i.prefix,i.selector,i.pseudo].join(""),entries:i.entries,parent:l,layer:i.layer,sort:i.sort,noMerge:i.noMerge};for(let p of this.config.postprocess)p(o);return o}constructCustomCSS(e,t,r){let s=K(t);if(w(s))return s;let{selector:i,entries:l,parent:a}=this.applyVariants([0,r||e.rawSelector,s,void 0,e.variantHandlers]),o=`${i}{${Q(l)}}`;return a?`${a}{${o}}`:o}async parseUtil(e,t,r=!1,s){let[i,l,a]=w(e)?await this.matchVariants(e):e;this.config.details&&(t.rules=t.rules??[]);let o=this.config.rulesStaticMap[l];if(o&&o[1]&&(r||!o[2]?.internal)){this.config.details&&t.rules.push(o[3]);let u=o[0],f=K(o[1]),x=o[2];return w(f)?[[u,f,x]]:[[u,i,f,x,a]]}t.variantHandlers=a;let{rulesDynamic:p}=this.config;for(let[u,f,x,S]of p){if(S?.internal&&!r)continue;let v=l;if(S?.prefix){let m=V(S.prefix);if(s){let g=V(s);if(!m.some(E=>g.includes(E)))continue}else{let g=m.find(E=>l.startsWith(E));if(g==null)continue;v=l.slice(g.length)}}let M=v.match(f);if(!M)continue;let T=await x(M,t);if(!T)continue;if(this.config.details&&t.rules.push([f,x,S]),typeof T!="string")if(Symbol.asyncIterator in T){let m=[];for await(let g of T)g&&m.push(g);T=m}else Symbol.iterator in T&&!Array.isArray(T)&&(T=Array.from(T).filter(re));let $=pe(T).filter(m=>m.length);if($.length)return $.map(m=>{if(w(m))return[u,m,S];let g=a;for(let E of m)E[0]===F.variants?g=[...V(E[1]),...g]:E[0]===F.parent?g=[{parent:E[1]},...g]:E[0]===F.selector?g=[{selector:E[1]},...g]:E[0]===F.layer&&(g=[{layer:E[1]},...g]);return[u,i,m,S,g]})}}stringifyUtil(e,t){if(!e)return;if(ne(e))return[e[0],void 0,e[1],void 0,e[2],this.config.details?t:void 0,void 0];let{selector:r,entries:s,parent:i,layer:l,sort:a,noMerge:o}=this.applyVariants(e),p=Q(s);if(!p)return;let{layer:u,sort:f,...x}=e[3]??{},S={...x,layer:l??u,sort:a??f};return[e[0],r,p,i,S,this.config.details?t:void 0,o]}async expandShortcut(e,t,r=5){if(r===0)return;let s=this.config.details?a=>{t.shortcuts=t.shortcuts??[],t.shortcuts.push(a)}:fe,i,l;for(let a of this.config.shortcuts){let o=e;if(a[2]?.prefix){let u=V(a[2].prefix).find(f=>e.startsWith(f));if(u==null)continue;o=e.slice(u.length)}if(me(a)){if(a[0]===o){i=i||a[2],l=a[1],s(a);break}}else{let p=o.match(a[0]);if(p&&(l=a[1](p,t)),l){i=i||a[2],s(a);break}}}if(l&&(l=V(l).map(a=>w(a)?ge(a.trim()).split(/\s+/g):a).flat()),!l){let[a,o]=w(e)?await this.matchVariants(e):e;if(a!==o){let p=await this.expandShortcut(o,t,r-1);p&&(l=p[0].map(u=>w(u)?a.replace(o,u):u))}}if(l)return[(await Promise.all(l.map(async a=>(w(a)?(await this.expandShortcut(a,t,r-1))?.[0]:void 0)||[a]))).flat(1).filter(Boolean),i]}async stringifyShortcuts(e,t,r,s={layer:this.config.shortcutsLayer}){let i=new Z,l=(await Promise.all(j(r).map(async u=>{let f=w(u)?await this.parseUtil(u,t,!0,s.prefix):[[Number.POSITIVE_INFINITY,"{inline}",K(u),void 0,[]]];return!f&&this.config.warn&&ye(`unmatched utility "${u}" in shortcut "${e[1]}"`),f||[]}))).flat(1).filter(Boolean).sort((u,f)=>u[0]-f[0]),[a,,o]=e,p=[];for(let u of l){if(ne(u)){p.push([u[0],void 0,u[1],void 0,u[2],t,void 0]);continue}let{selector:f,entries:x,parent:S,sort:v,noMerge:M,layer:T}=this.applyVariants(u,[...u[4],...o],a);i.getFallback(T??s.layer,new q).getFallback(f,S,[[],u[0]])[0].push([x,!!(M??u[3]?.noMerge),v??0])}return p.concat(i.flatMap((u,f)=>u.map(([x,S],v,M)=>{let T=(m,g,E)=>{let P=Math.max(...E.map(d=>d[1])),c=E.map(d=>d[0]);return(m?[c.flat(1)]:c).map(d=>{let R=Q(d);if(R)return[S,v,R,M,{...s,noMerge:g,sort:P,layer:f},t,void 0]})};return[[x.filter(([,m])=>m).map(([m,,g])=>[m,g]),!0],[x.filter(([,m])=>!m).map(([m,,g])=>[m,g]),!1]].map(([m,g])=>[...T(!1,g,m.filter(([E])=>E.some(P=>P[0]===F.shortcutsNoMerge))),...T(!0,g,m.filter(([E])=>E.every(P=>P[0]!==F.shortcutsNoMerge)))])}).flat(2).filter(Boolean)))}isBlocked(e){return!e||this.config.blocklist.map(t=>Array.isArray(t)?t[0]:t).some(t=>typeof t=="function"?t(e):w(t)?t===e:t.test(e))}getBlocked(e){let t=this.config.blocklist.find(r=>{let s=Array.isArray(r)?r[0]:r;return typeof s=="function"?s(e):w(s)?s===e:s.test(e)});return t?Array.isArray(t)?t:[t,void 0]:void 0}};function ve(n,e){return new oe(n,e)}var Me=/\s\$\$\s+/g;function Ne(n){return Me.test(n)}function ze(n,e){return Ne(n)?n.replace(Me,e?` ${e} `:" "):e?`${e} ${n}`:n}var Re=/^\[(.+?)(~?=)"(.*)"\]$/;function We(n){return Re.test(n)?n.replace(Re,(e,t,r,s)=>`[${Y(t)}${r}"${Y(s)}"]`):`.${Y(n)}`}function Ye(n,e){return e(n)}function qe(n){return n.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"")}function we(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ae(n){return n.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase()}var Ue=["Webkit","Moz","ms"];function Ve(n){let e={};function t(r){let s=e[r];if(s)return s;let i=qe(r);if(i!=="filter"&&i in n)return e[r]=Ae(i);i=we(i);for(let l=0;l<Ue.length;l++){let a=`${Ue[l]}${i}`;if(a in n)return e[r]=Ae(we(a))}return r}return({entries:r})=>r.forEach(s=>{s[0].startsWith("--")||(s[0]=t(s[0]))})}function $e(n){return n.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")}function ae(n={}){if(typeof window>"u"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let e=window,t=window.document,r=()=>t.documentElement,s=e.__unocss||{},i=Object.assign({},n,s.runtime),l=i.defaults||{},a=i.cloakAttribute??"un-cloak";i.autoPrefix&&(l.postprocess=V(l.postprocess)).unshift(Ve(t.createElement("div").style)),i.configResolved?.(s,l);let o=ve(s,l),p=y=>i.inject?i.inject(y):r().prepend(y),u=()=>i.rootElement?i.rootElement():t.body,f=new Map,x=!0,S=new Set,v,M,T=[],$=()=>new Promise(y=>{T.push(y),M!=null&&clearTimeout(M),M=setTimeout(()=>E().then(()=>{let C=T;T=[],C.forEach(h=>h())}),0)});function m(y,C=!1){if(y.nodeType!==1)return;let h=y;h.hasAttribute(a)&&h.removeAttribute(a),C&&h.querySelectorAll(`[${a}]`).forEach(b=>{b.removeAttribute(a)})}function g(y,C){let h=f.get(y);if(!h)if(h=t.createElement("style"),h.setAttribute("data-unocss-runtime-layer",y),f.set(y,h),C==null)p(h);else{let b=g(C),U=b.parentNode;U?U.insertBefore(h,b.nextSibling):p(h)}return h}async function E(){let y=[...S],C=await o.generate(y);return C.layers.reduce((b,U)=>(g(U,b).innerHTML=C.getLayer(U)??"",U),void 0),y.filter(b=>!C.matched.has(b)).forEach(b=>S.delete(b)),{...C,getStyleElement:b=>f.get(b),getStyleElements:()=>f}}async function P(y){let C=S.size;await o.applyExtractors(y,void 0,S),C!==S.size&&await $()}async function c(y=u()){let C=y&&y.outerHTML;C&&(await P(`${C} ${$e(C)}`),m(r()),m(y,!0))}let d=new MutationObserver(y=>{x||y.forEach(async C=>{if(C.target.nodeType!==1)return;let h=C.target;for(let b of f)if(h===b[1])return;if(C.type==="childList")C.addedNodes.forEach(async b=>{if(b.nodeType!==1)return;let U=b;v&&!v(U)||(await P(U.outerHTML),m(U))});else{if(v&&!v(h))return;if(C.attributeName!==a){let b=Array.from(h.attributes).map(L=>L.value?`${L.name}="${L.value}"`:L.name).join(" "),U=`<${h.tagName.toLowerCase()} ${b}>`;await P(U)}m(h)}})}),R=!1;function A(){if(R)return;let y=i.observer?.target?i.observer.target():u();y&&(d.observe(y,{childList:!0,subtree:!0,attributes:!0,attributeFilter:i.observer?.attributeFilter}),R=!0)}function O(){i.bypassDefined&&Ze(o.blocked),c(),A()}function k(){t.readyState==="loading"?e.addEventListener("DOMContentLoaded",O):O()}let I=e.__unocss_runtime=e.__unocss_runtime={version:o.version,uno:o,async extract(y){w(y)||(y.forEach(C=>S.add(C)),y=""),await P(y)},extractAll:c,inspect(y){v=y},toggleObserver(y){y===void 0?x=!x:x=!!y,!R&&!x&&k()},update:E,presets:e.__unocss_runtime?.presets??{}};i.ready?.(I)!==!1&&(x=!1,k())}function Ze(n=new Set){for(let e=0;e<document.styleSheets.length;e++){let t=document.styleSheets[e],r;try{if(r=t.cssRules||t.rules,!r)continue;Array.from(r).flatMap(s=>s.selectorText?.split(/,/g)||[]).forEach(s=>{s&&(s=s.trim(),s.startsWith(".")&&(s=s.slice(1)),n.add(s))})}catch{continue}}return n}ae();})();
|
|
1
|
+
"use strict";(()=>{var G="default",N="preflights",$e="shortcuts",Oe="imports",ce={[Oe]:-200,[N]:-100,[$e]:-10,[G]:0};var le=/[\\:]?[\s'"`;{}]+/g;function je(n){return n.split(le)}var z={name:"@unocss/core/extractor-split",order:0,extract({code:n}){return je(n)}};function V(n=[]){return Array.isArray(n)?n:[n]}function j(n){return Array.from(new Set(n))}function te(n,e){return n.reduce((t,r)=>(t.findIndex(o=>e(r,o))===-1&&t.push(r),t),[])}function M(n){return typeof n=="string"}var H=class extends Set{_map;constructor(e){super(e),this._map??=new Map}add(e){return this._map??=new Map,this._map.set(e,(this._map.get(e)??0)+1),super.add(e)}delete(e){return this._map.delete(e),super.delete(e)}clear(){this._map.clear(),super.clear()}getCount(e){return this._map.get(e)??0}setCount(e,t){return this._map.set(e,t),super.add(e)}};function W(n){return n instanceof H}function _e(n){let e=n.length,t=-1,r,s="",o=n.charCodeAt(0);for(;++t<e;){if(r=n.charCodeAt(t),r===0){s+="\uFFFD";continue}if(r===37){s+="\\%";continue}if(r===44){s+="\\,";continue}if(r>=1&&r<=31||r===127||t===0&&r>=48&&r<=57||t===1&&r>=48&&r<=57&&o===45){s+=`\\${r.toString(16)} `;continue}if(t===0&&e===1&&r===45){s+=`\\${n.charAt(t)}`;continue}if(r>=128||r===45||r===95||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122){s+=n.charAt(t);continue}s+=`\\${n.charAt(t)}`}return s}var Y=_e;function ue(n){return typeof n=="function"?{match:n}:n}function ne(n){return n.length===3}function re(n){return n!=null}function fe(){}var q=class{_map=new Map;get(e,t){let r=this._map.get(e);if(r)return r.get(t)}getFallback(e,t,r){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.has(t)||s.set(t,r),s.get(t)}set(e,t,r){let s=this._map.get(e);return s||(s=new Map,this._map.set(e,s)),s.set(t,r),this}has(e,t){return this._map.get(e)?.has(t)}delete(e,t){return this._map.get(e)?.delete(t)||!1}deleteTop(e){return this._map.delete(e)}map(e){return Array.from(this._map.entries()).flatMap(([t,r])=>Array.from(r.entries()).map(([s,o])=>e(o,t,s)))}},Z=class extends Map{getFallback(e,t){let r=this.get(e);return r===void 0?(this.set(e,t),t):r}map(e){let t=[];return this.forEach((r,s)=>{t.push(e(r,s))}),t}flatMap(e){let t=[];return this.forEach((r,s)=>{t.push(...e(r,s))}),t}};function K(n){return M(n)?n:(Array.isArray(n)?n:Object.entries(n)).filter(e=>e[1]!=null)}function pe(n){return Array.isArray(n)?n.find(e=>!Array.isArray(e)||Array.isArray(e[0]))?n.map(e=>K(e)):[n]:[K(n)]}function ke(n){return n.filter(([e,t],r)=>{if(e.startsWith("$$"))return!1;for(let s=r-1;s>=0;s--)if(n[s][0]===e&&n[s][1]===t)return!1;return!0})}function Q(n){return n==null?"":ke(n).map(([e,t])=>t!=null&&typeof t!="function"?`${e}:${t};`:void 0).filter(Boolean).join("")}function J(n){return n&&typeof n=="object"&&!Array.isArray(n)}function se(n,e,t=!1){let r=n,s=e;if(Array.isArray(s))return t&&Array.isArray(s)?[...r,...s]:[...s];let o={...r};return J(r)&&J(s)&&Object.keys(s).forEach(f=>{J(r[f])&&J(s[f])||Array.isArray(r[f])&&Array.isArray(s[f])?o[f]=se(r[f],s[f],t):Object.assign(o,{[f]:s[f]})}),o}function B(n){let e,t,r;if(Array.isArray(n)){for(t=Array.from({length:e=n.length});e--;)t[e]=(r=n[e])&&typeof r=="object"?B(r):r;return t}if(Object.prototype.toString.call(n)==="[object Object]"){t={};for(e in n)e==="__proto__"?Object.defineProperty(t,e,{value:B(n[e]),configurable:!0,enumerable:!0,writable:!0}):t[e]=(r=n[e])&&typeof r=="object"?B(r):r;return t}return n}function de(n){return M(n[0])}function me(n){return M(n[0])}var X={};function Le(n=["-",":"]){let e=n.join("|");return X[e]||(X[e]=new RegExp(`((?:[!@<~\\w+:_-]|\\[&?>?:?\\S*\\])+?)(${e})\\(((?:[~!<>\\w\\s:/\\\\,%#.$?-]|\\[.*?\\])+?)\\)(?!\\s*?=>)`,"gm")),X[e].lastIndex=0,X[e]}function De(n,e=["-",":"],t=5){let r=Le(e),s,o=n.toString(),f=new Set,l=new Map;do s=!1,o=o.replace(r,(d,u,c,g,y)=>{if(!e.includes(c))return d;s=!0,f.add(u+c);let T=y+u.length+c.length+1,R={length:d.length,items:[]};l.set(y,R);for(let v of[...g.matchAll(/\S+/g)]){let $=T+v.index,x=l.get($)?.items;x?l.delete($):x=[{offset:$,length:v[0].length,className:v[0]}];for(let S of x)S.className=S.className==="~"?u:S.className.replace(/^(!?)(.*)/,`$1${u}${c}$2`),R.items.push(S)}return"$".repeat(d.length)}),t-=1;while(s&&t);let a;if(typeof n=="string"){a="";let d=0;for(let[u,c]of l)a+=n.slice(d,u),a+=c.items.map(g=>g.className).join(" "),d=u+c.length;a+=n.slice(d)}else{a=n;for(let[d,u]of l)a.overwrite(d,d+u.length,u.items.map(c=>c.className).join(" "))}return{prefixes:Array.from(f),hasChanged:s,groupsByOffset:l,get expanded(){return a.toString()}}}function he(n,e=["-",":"],t=5){let r=De(n,e,t);return typeof n=="string"?r.expanded:n}var ge=new Set;function ye(n){ge.has(n)||(console.warn("[unocss]",n),ge.add(n))}function be(n){return V(n).flatMap(e=>Array.isArray(e)?[e]:Object.entries(e))}var xe="_uno_resolved";async function Fe(n){let e=typeof n=="function"?await n():await n;if(xe in e)return e;e={...e},Object.defineProperty(e,xe,{value:!0,enumerable:!1});let t=e.shortcuts?be(e.shortcuts):void 0;if(e.shortcuts=t,e.prefix||e.layer){let r=s=>{s[2]||(s[2]={});let o=s[2];o.prefix==null&&e.prefix&&(o.prefix=V(e.prefix)),o.layer==null&&e.layer&&(o.layer=e.layer)};t?.forEach(r),e.rules?.forEach(r)}return e}async function Ce(n){let e=await Fe(n);if(!e.presets)return[e];let t=(await Promise.all((e.presets||[]).flatMap(V).flatMap(Ce))).flat();return[e,...t]}function Ke(n){if(n.length===0)return{};let e=[],t=[],r=!1,s=[],o=[],f=[];for(let a of n){if(a.pipeline===!1){r=!0;break}else a.pipeline?.include&&e.push(a.pipeline.include),a.pipeline?.exclude&&t.push(a.pipeline.exclude);a.filesystem&&s.push(a.filesystem),a.inline&&o.push(a.inline),a.plain&&f.push(a.plain)}let l={pipeline:r?!1:{include:j(Se(...e)),exclude:j(Se(...t))}};return s.length&&(l.filesystem=j(s.flat())),o.length&&(l.inline=j(o.flat())),f.length&&(l.plain=j(f.flat())),l}async function ie(n={},e={}){let t=Object.assign({},e,n),r=te((await Promise.all((t.presets||[]).flatMap(V).flatMap(Ce))).flat(),(i,p)=>i.name===p.name),s=[...r.filter(i=>i.enforce==="pre"),...r.filter(i=>!i.enforce),...r.filter(i=>i.enforce==="post")],o=[...s,t],f=[...o].reverse(),l=Object.assign({},ce,...o.map(i=>i.layers));function a(i){return j(o.flatMap(p=>V(p[i]||[])))}let d=a("extractors"),u=f.find(i=>i.extractorDefault!==void 0)?.extractorDefault;u===void 0&&(u=z),u&&!d.includes(u)&&d.unshift(u),d.sort((i,p)=>(i.order||0)-(p.order||0));let c=a("rules"),g={},y=c.length,T=c.map((i,p)=>{if(de(i)){V(i[2]?.prefix||"").forEach(A=>{g[A+i[0]]=[p,i[1],i[2],i]});return}return[p,...i]}).filter(Boolean).reverse(),R=Ie(o.map(i=>i.theme)),v=a("extendTheme");for(let i of v)R=i(R)||R;let $={templates:j(o.flatMap(i=>V(i.autocomplete?.templates))),extractors:o.flatMap(i=>V(i.autocomplete?.extractors)).sort((i,p)=>(i.order||0)-(p.order||0)),shorthands:Ge(o.map(i=>i.autocomplete?.shorthands||{}))},x=a("separators");x.length||(x=[":","-"]);let S=a("content"),P=Ke(S),E={mergeSelectors:!0,warn:!0,sortLayers:i=>i,...t,blocklist:a("blocklist"),presets:s,envMode:t.envMode||"build",shortcutsLayer:t.shortcutsLayer||"shortcuts",layers:l,theme:R,rulesSize:y,rulesDynamic:T,rulesStaticMap:g,preprocess:a("preprocess"),postprocess:a("postprocess"),preflights:a("preflights"),autocomplete:$,variants:a("variants").map(ue).sort((i,p)=>(i.order||0)-(p.order||0)),shortcuts:be(a("shortcuts")).reverse(),extractors:d,safelist:a("safelist"),separators:x,details:t.details??t.envMode==="dev",content:P,transformers:te(a("transformers"),(i,p)=>i.name===p.name)};for(let i of o)i?.configResolved?.(E);return E}function Ie(n){return n.map(e=>e?B(e):{}).reduce((e,t)=>se(e,t),{})}function Ge(n){return n.reduce((e,t)=>{let r={};for(let s in t){let o=t[s];Array.isArray(o)?r[s]=`(${o.join("|")})`:r[s]=o}return{...e,...r}},{})}function Se(...n){return n.flatMap(He)}function He(n){return Array.isArray(n)?n:n?[n]:[]}var Te="0.65.0-beta.2";function Ee(){return{events:{},emit(n,...e){(this.events[n]||[]).forEach(t=>t(...e))},on(n,e){return(this.events[n]=this.events[n]||[]).push(e),()=>this.events[n]=(this.events[n]||[]).filter(t=>t!==e)}}}var F={shortcutsNoMerge:"$$symbol-shortcut-no-merge",variants:"$$symbol-variants",parent:"$$symbol-parent",selector:"$$symbol-selector",layer:"$$symbol-layer"},oe=class n{constructor(e={},t={}){this.userConfig=e;this.defaults=t}version=Te;_cache=new Map;config=void 0;blocked=new Set;parentOrders=new Map;events=Ee();static async create(e={},t={}){let r=new n(e,t);return r.config=await ie(r.userConfig,r.defaults),r.events.emit("config",r.config),r}async setConfig(e,t){e&&(t&&(this.defaults=t),this.userConfig=e,this.blocked.clear(),this.parentOrders.clear(),this._cache.clear(),this.config=await ie(e,this.defaults),this.events.emit("config",this.config))}async applyExtractors(e,t,r=new Set){let s={original:e,code:e,id:t,extracted:r,envMode:this.config.envMode};for(let o of this.config.extractors){let f=await o.extract?.(s);if(f)if(W(f)&&W(r))for(let l of f)r.setCount(l,r.getCount(l)+f.getCount(l));else for(let l of f)r.add(l)}return r}makeContext(e,t){let r={rawSelector:e,currentSelector:t[1],theme:this.config.theme,generator:this,symbols:F,variantHandlers:t[2],constructCSS:(...s)=>this.constructCustomCSS(r,...s),variantMatch:t};return r}async parseToken(e,t){if(this.blocked.has(e))return;let r=`${e}${t?` ${t}`:""}`;if(this._cache.has(r))return this._cache.get(r);let s=e;for(let a of this.config.preprocess)s=a(e);if(this.isBlocked(s)){this.blocked.add(e),this._cache.set(r,null);return}let o=await this.matchVariants(e,s);if(o.every(a=>!a||this.isBlocked(a[1]))){this.blocked.add(e),this._cache.set(r,null);return}let f=async a=>{let d=this.makeContext(e,[t||a[0],a[1],a[2],a[3]]);this.config.details&&(d.variants=[...a[3]]);let u=await this.expandShortcut(d.currentSelector,d);return u?await this.stringifyShortcuts(d.variantMatch,d,u[0],u[1]):(await this.parseUtil(d.variantMatch,d))?.map(g=>this.stringifyUtil(g,d)).filter(re)},l=(await Promise.all(o.map(a=>f(a)))).flat().filter(a=>!!a);if(l?.length)return this._cache.set(r,l),l;this._cache.set(r,null)}async generate(e,t={}){let{id:r,scope:s,preflights:o=!0,safelist:f=!0,minify:l=!1,extendedInfo:a=!1}=t,d=this.config.outputToCssLayers,u=M(e)?await this.applyExtractors(e,r,a?new H:new Set):Array.isArray(e)?new Set(e):e;if(f){let i={generator:this,theme:this.config.theme};this.config.safelist.flatMap(p=>typeof p=="function"?p(i):p).forEach(p=>{u.has(p)||u.add(p)})}let c=l?"":`
|
|
2
|
+
`,g=new Set([G]),y=a?new Map:new Set,T=new Map,R={},v=Array.from(u).map(async i=>{if(y.has(i))return;let p=await this.parseToken(i);if(p!=null){y instanceof Map?y.set(i,{data:p,count:W(u)?u.getCount(i):-1}):y.add(i);for(let w of p){let A=w[3]||"",O=w[4]?.layer;T.has(A)||T.set(A,[]),T.get(A).push(w),O&&g.add(O)}}});await Promise.all(v),await(async()=>{if(!o)return;let i={generator:this,theme:this.config.theme},p=new Set([]);this.config.preflights.forEach(({layer:w=N})=>{g.add(w),p.add(w)}),R=Object.fromEntries(await Promise.all(Array.from(p).map(async w=>{let O=(await Promise.all(this.config.preflights.filter(k=>(k.layer||N)===w).map(async k=>await k.getCSS(i)))).filter(Boolean).join(c);return[w,O]})))})();let $=this.config.sortLayers(Array.from(g).sort((i,p)=>(this.config.layers[i]??0)-(this.config.layers[p]??0)||i.localeCompare(p))),x={},S=(i=G)=>{if(x[i])return x[i];let p=Array.from(T).sort((A,O)=>(this.parentOrders.get(A[0])??0)-(this.parentOrders.get(O[0])??0)||A[0]?.localeCompare(O[0]||"")||0).map(([A,O])=>{let k=O.length,I=O.filter(m=>(m[4]?.layer||G)===i).sort((m,b)=>m[0]-b[0]||(m[4]?.sort||0)-(b[4]?.sort||0)||m[5]?.currentSelector?.localeCompare(b[5]?.currentSelector??"")||m[1]?.localeCompare(b[1]||"")||m[2]?.localeCompare(b[2]||"")||0).map(([,m,b,,U,,L])=>[[[(m&&ze(m,s))??"",U?.sort??0]],b,!!(L??U?.noMerge)]);if(!I.length)return;let h=I.reverse().map(([m,b,U],L)=>{if(!U&&this.config.mergeSelectors)for(let D=L+1;D<k;D++){let _=I[D];if(_&&!_[2]&&(m&&_[0]||m==null&&_[0]==null)&&_[1]===b)return m&&_[0]&&_[0].push(...m),null}let ee=m?j(m.sort((D,_)=>D[1]-_[1]||D[0]?.localeCompare(_[0]||"")||0).map(D=>D[0]).filter(Boolean)):[];return ee.length?`${ee.join(`,${c}`)}{${b}}`:b}).filter(Boolean).reverse().join(c);if(!A)return h;let C=A.split(" $$ ");return`${C.join("{")}{${c}${h}${c}${"}".repeat(C.length)}`}).filter(Boolean).join(c);if(o&&(p=[R[i],p].filter(Boolean).join(c)),d&&p){let A=typeof d=="object"?d.cssLayerName?.(i):void 0;A!==null&&(A||(A=i),p=`@layer ${A}{${c}${p}${c}}`)}let w=l?"":`/* layer: ${i} */${c}`;return x[i]=p?w+p:""},P=(i=$,p)=>i.filter(w=>!p?.includes(w)).map(w=>S(w)||"").filter(Boolean).join(c);return{get css(){return P()},layers:$,matched:y,getLayers:P,getLayer:S,setLayer:async(i,p)=>{let w=await p(S(i));return x[i]=w,w}}}async matchVariants(e,t){let r={rawSelector:e,theme:this.config.theme,generator:this},s=async o=>{let f=!0,[,,l,a]=o;for(;f;){f=!1;let d=o[1];for(let u of this.config.variants){if(!u.multiPass&&a.has(u))continue;let c=await u.match(d,r);if(c){if(M(c)){if(c===d)continue;c={matcher:c}}if(Array.isArray(c)){if(!c.length)continue;if(c.length===1)c=c[0];else{if(u.multiPass)throw new Error("multiPass can not be used together with array return variants");let g=c.map(y=>{let T=y.matcher??d,R=[y,...l],v=new Set(a);return v.add(u),[o[0],T,R,v]});return(await Promise.all(g.map(y=>s(y)))).flat()}}o[1]=c.matcher??d,l.unshift(c),a.add(u),f=!0;break}}if(!f)break;if(l.length>500)throw new Error(`Too many variants applied to "${e}"`)}return[o]};return await s([e,t||e,[],new Set])}applyVariants(e,t=e[4],r=e[1]){let o=t.slice().sort((d,u)=>(d.order||0)-(u.order||0)).reduceRight((d,u)=>c=>{let g=u.body?.(c.entries)||c.entries,y=Array.isArray(u.parent)?u.parent:[u.parent,void 0];return(u.handle??Ye)({...c,entries:g,selector:u.selector?.(c.selector,g)||c.selector,parent:y[0]||c.parent,parentOrder:y[1]||c.parentOrder,layer:u.layer||c.layer,sort:u.sort||c.sort},d)},d=>d)({prefix:"",selector:We(r),pseudo:"",entries:e[2]}),{parent:f,parentOrder:l}=o;f!=null&&l!=null&&this.parentOrders.set(f,l);let a={selector:[o.prefix,o.selector,o.pseudo].join(""),entries:o.entries,parent:f,layer:o.layer,sort:o.sort,noMerge:o.noMerge};for(let d of this.config.postprocess)d(a);return a}constructCustomCSS(e,t,r){let s=K(t);if(M(s))return s;let{selector:o,entries:f,parent:l}=this.applyVariants([0,r||e.rawSelector,s,void 0,e.variantHandlers]),a=`${o}{${Q(f)}}`;return l?`${l}{${a}}`:a}async parseUtil(e,t,r=!1,s){let o=M(e)?await this.matchVariants(e):[e],f=async([a,d,u])=>{this.config.details&&(t.rules=t.rules??[]);let c=this.config.rulesStaticMap[d];if(c&&c[1]&&(r||!c[2]?.internal)){this.config.details&&t.rules.push(c[3]);let y=c[0],T=K(c[1]),R=c[2];return M(T)?[[y,T,R]]:[[y,a,T,R,u]]}t.variantHandlers=u;let{rulesDynamic:g}=this.config;for(let[y,T,R,v]of g){if(v?.internal&&!r)continue;let $=d;if(v?.prefix){let E=V(v.prefix);if(s){let i=V(s);if(!E.some(p=>i.includes(p)))continue}else{let i=E.find(p=>d.startsWith(p));if(i==null)continue;$=d.slice(i.length)}}let x=$.match(T);if(!x)continue;let S=await R(x,t);if(!S)continue;if(this.config.details&&t.rules.push([T,R,v]),typeof S!="string")if(Symbol.asyncIterator in S){let E=[];for await(let i of S)i&&E.push(i);S=E}else Symbol.iterator in S&&!Array.isArray(S)&&(S=Array.from(S).filter(re));let P=pe(S).filter(E=>E.length);if(P.length)return P.map(E=>{if(M(E))return[y,E,v];let i=u;for(let p of E)p[0]===F.variants?i=[...V(p[1]),...i]:p[0]===F.parent?i=[{parent:p[1]},...i]:p[0]===F.selector?i=[{selector:p[1]},...i]:p[0]===F.layer&&(i=[{layer:p[1]},...i]);return[y,a,E,v,i]})}},l=(await Promise.all(o.map(a=>f(a)))).flat().filter(a=>!!a);if(l.length)return l}stringifyUtil(e,t){if(!e)return;if(ne(e))return[e[0],void 0,e[1],void 0,e[2],this.config.details?t:void 0,void 0];let{selector:r,entries:s,parent:o,layer:f,sort:l,noMerge:a}=this.applyVariants(e),d=Q(s);if(!d)return;let{layer:u,sort:c,...g}=e[3]??{},y={...g,layer:f??u,sort:l??c};return[e[0],r,d,o,y,this.config.details?t:void 0,a]}async expandShortcut(e,t,r=5){if(r===0)return;let s=this.config.details?l=>{t.shortcuts=t.shortcuts??[],t.shortcuts.push(l)}:fe,o,f;for(let l of this.config.shortcuts){let a=e;if(l[2]?.prefix){let u=V(l[2].prefix).find(c=>e.startsWith(c));if(u==null)continue;a=e.slice(u.length)}if(me(l)){if(l[0]===a){o=o||l[2],f=l[1],s(l);break}}else{let d=a.match(l[0]);if(d&&(f=l[1](d,t)),f){o=o||l[2],s(l);break}}}if(f&&(f=V(f).map(l=>M(l)?he(l.trim()).split(/\s+/g):l).flat()),!f){let l=M(e)?await this.matchVariants(e):[e];for(let a of l){let[d,u]=a;if(d!==u){let c=await this.expandShortcut(u,t,r-1);c&&(f=c[0].map(g=>M(g)?d.replace(u,g):g))}}}if(f)return[(await Promise.all(f.map(async l=>(M(l)?(await this.expandShortcut(l,t,r-1))?.[0]:void 0)||[l]))).flat(1).filter(l=>!!l),o]}async stringifyShortcuts(e,t,r,s={layer:this.config.shortcutsLayer}){let o=new Z,f=(await Promise.all(j(r).map(async u=>{let c=M(u)?await this.parseUtil(u,t,!0,s.prefix):[[Number.POSITIVE_INFINITY,"{inline}",K(u),void 0,[]]];return!c&&this.config.warn&&ye(`unmatched utility "${u}" in shortcut "${e[1]}"`),c||[]}))).flat(1).filter(Boolean).sort((u,c)=>u[0]-c[0]),[l,,a]=e,d=[];for(let u of f){if(ne(u)){d.push([u[0],void 0,u[1],void 0,u[2],t,void 0]);continue}let{selector:c,entries:g,parent:y,sort:T,noMerge:R,layer:v}=this.applyVariants(u,[...u[4],...a],l);o.getFallback(v??s.layer,new q).getFallback(c,y,[[],u[0]])[0].push([g,!!(R??u[3]?.noMerge),T??0])}return d.concat(o.flatMap((u,c)=>u.map(([g,y],T,R)=>{let v=(x,S,P)=>{let E=Math.max(...P.map(p=>p[1])),i=P.map(p=>p[0]);return(x?[i.flat(1)]:i).map(p=>{let w=Q(p);if(w)return[y,T,w,R,{...s,noMerge:S,sort:E,layer:c},t,void 0]})};return[[g.filter(([,x])=>x).map(([x,,S])=>[x,S]),!0],[g.filter(([,x])=>!x).map(([x,,S])=>[x,S]),!1]].map(([x,S])=>[...v(!1,S,x.filter(([P])=>P.some(E=>E[0]===F.shortcutsNoMerge))),...v(!0,S,x.filter(([P])=>P.every(E=>E[0]!==F.shortcutsNoMerge)))])}).flat(2).filter(Boolean)))}isBlocked(e){return!e||this.config.blocklist.map(t=>Array.isArray(t)?t[0]:t).some(t=>typeof t=="function"?t(e):M(t)?t===e:t.test(e))}getBlocked(e){let t=this.config.blocklist.find(r=>{let s=Array.isArray(r)?r[0]:r;return typeof s=="function"?s(e):M(s)?s===e:s.test(e)});return t?Array.isArray(t)?t:[t,void 0]:void 0}};async function ve(n,e){return await oe.create(n,e)}var we=/\s\$\$\s+/g;function Ne(n){return we.test(n)}function ze(n,e){return Ne(n)?n.replace(we,e?` ${e} `:" "):e?`${e} ${n}`:n}var Re=/^\[(.+?)(~?=)"(.*)"\]$/;function We(n){return Re.test(n)?n.replace(Re,(e,t,r,s)=>`[${Y(t)}${r}"${Y(s)}"]`):`.${Y(n)}`}function Ye(n,e){return e(n)}function qe(n){return n.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"")}function Me(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ae(n){return n.replace(/(?:^|\B)([A-Z])/g,"-$1").toLowerCase()}var Pe=["Webkit","Moz","ms"];function Ue(n){let e={};function t(r){let s=e[r];if(s)return s;let o=qe(r);if(o!=="filter"&&o in n)return e[r]=Ae(o);o=Me(o);for(let f=0;f<Pe.length;f++){let l=`${Pe[f]}${o}`;if(l in n)return e[r]=Ae(Me(l))}return r}return({entries:r})=>r.forEach(s=>{s[0].startsWith("--")||(s[0]=t(s[0]))})}function Ve(n){return n.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")}async function ae(n={}){if(typeof window>"u"){console.warn("@unocss/runtime been used in non-browser environment, skipped.");return}let e=window,t=window.document,r=()=>t.documentElement,s=e.__unocss||{},o=Object.assign({},n,s.runtime),f=o.defaults||{},l=o.cloakAttribute??"un-cloak";o.autoPrefix&&(f.postprocess=V(f.postprocess)).unshift(Ue(t.createElement("div").style)),o.configResolved?.(s,f);let a=await ve(s,f),d=h=>o.inject?o.inject(h):r().prepend(h),u=()=>o.rootElement?o.rootElement():t.body,c=new Map,g=!0,y=new Set,T,R,v=[],$=()=>new Promise(h=>{v.push(h),R!=null&&clearTimeout(R),R=setTimeout(()=>P().then(()=>{let C=v;v=[],C.forEach(m=>m())}),0)});function x(h,C=!1){if(h.nodeType!==1)return;let m=h;m.hasAttribute(l)&&m.removeAttribute(l),C&&m.querySelectorAll(`[${l}]`).forEach(b=>{b.removeAttribute(l)})}function S(h,C){let m=c.get(h);if(!m)if(m=t.createElement("style"),m.setAttribute("data-unocss-runtime-layer",h),c.set(h,m),C==null)d(m);else{let b=S(C),U=b.parentNode;U?U.insertBefore(m,b.nextSibling):d(m)}return m}async function P(){let h=[...y],C=await a.generate(h);return C.layers.reduce((b,U)=>(S(U,b).innerHTML=C.getLayer(U)??"",U),void 0),h.filter(b=>!C.matched.has(b)).forEach(b=>y.delete(b)),{...C,getStyleElement:b=>c.get(b),getStyleElements:()=>c}}async function E(h){let C=y.size;await a.applyExtractors(h,void 0,y),C!==y.size&&await $()}async function i(h=u()){let C=h&&h.outerHTML;C&&(await E(`${C} ${Ve(C)}`),x(r()),x(h,!0))}let p=new MutationObserver(h=>{g||h.forEach(async C=>{if(C.target.nodeType!==1)return;let m=C.target;for(let b of c)if(m===b[1])return;if(C.type==="childList")C.addedNodes.forEach(async b=>{if(b.nodeType!==1)return;let U=b;T&&!T(U)||(await E(U.outerHTML),x(U))});else{if(T&&!T(m))return;if(C.attributeName!==l){let b=Array.from(m.attributes).map(L=>L.value?`${L.name}="${L.value}"`:L.name).join(" "),U=`<${m.tagName.toLowerCase()} ${b}>`;await E(U)}x(m)}})}),w=!1;function A(){if(w)return;let h=o.observer?.target?o.observer.target():u();h&&(p.observe(h,{childList:!0,subtree:!0,attributes:!0,attributeFilter:o.observer?.attributeFilter}),w=!0)}function O(){o.bypassDefined&&Ze(a.blocked),i(),A()}function k(){t.readyState==="loading"?e.addEventListener("DOMContentLoaded",O):O()}let I=e.__unocss_runtime=e.__unocss_runtime={version:a.version,uno:a,async extract(h){M(h)||(h.forEach(C=>y.add(C)),h=""),await E(h)},extractAll:i,inspect(h){T=h},toggleObserver(h){h===void 0?g=!g:g=!!h,!w&&!g&&k()},update:P,presets:e.__unocss_runtime?.presets??{}};o.ready?.(I)!==!1&&(g=!1,k())}function Ze(n=new Set){for(let e=0;e<document.styleSheets.length;e++){let t=document.styleSheets[e],r;try{if(r=t.cssRules||t.rules,!r)continue;Array.from(r).flatMap(s=>s.selectorText?.split(/,/g)||[]).forEach(s=>{s&&(s=s.trim(),s.startsWith(".")&&(s=s.slice(1)),n.add(s))})}catch{continue}}return n}ae();})();
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,6 @@ declare global {
|
|
|
126
126
|
__unocss_runtime?: RuntimeContext;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
declare function init(inlineConfig?: RuntimeOptions): void
|
|
129
|
+
declare function init(inlineConfig?: RuntimeOptions): Promise<void>;
|
|
130
130
|
|
|
131
131
|
export { type RuntimeContext, type RuntimeGenerateResult, type RuntimeInspectorCallback, type RuntimeObserverConfig, type RuntimeOptions, init as default, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ function decodeHtml(html) {
|
|
|
42
42
|
function defineConfig(config) {
|
|
43
43
|
return config;
|
|
44
44
|
}
|
|
45
|
-
function init(inlineConfig = {}) {
|
|
45
|
+
async function init(inlineConfig = {}) {
|
|
46
46
|
if (typeof window == "undefined") {
|
|
47
47
|
console.warn("@unocss/runtime been used in non-browser environment, skipped.");
|
|
48
48
|
return;
|
|
@@ -59,7 +59,7 @@ function init(inlineConfig = {}) {
|
|
|
59
59
|
postprocessors.unshift(autoPrefixer(defaultDocument.createElement("div").style));
|
|
60
60
|
}
|
|
61
61
|
runtimeOptions.configResolved?.(userConfig, userConfigDefaults);
|
|
62
|
-
const uno = createGenerator(userConfig, userConfigDefaults);
|
|
62
|
+
const uno = await createGenerator(userConfig, userConfigDefaults);
|
|
63
63
|
const inject = (styleElement) => runtimeOptions.inject ? runtimeOptions.inject(styleElement) : html().prepend(styleElement);
|
|
64
64
|
const rootElement = () => runtimeOptions.rootElement ? runtimeOptions.rootElement() : defaultDocument.body;
|
|
65
65
|
const styleElements = /* @__PURE__ */ new Map();
|