@unocss/runtime 66.5.12 → 66.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- "use strict";(()=>{var U="default",D="preflights",B="shortcuts",C="imports",Q={[C]:-200,[D]:-100,[B]:-10,[U]:0};function j(t=[]){return Array.isArray(t)?t:[t]}function x(t){return t&&typeof t=="object"&&!Array.isArray(t)}function T(t,n,f=!1){let c=t,e=n;if(Array.isArray(e))return f&&Array.isArray(e)?[...c,...e]:[...e];let o={...c};return x(c)&&x(e)&&Object.keys(e).forEach(s=>{x(c[s])&&x(e[s])||Array.isArray(c[s])&&Array.isArray(e[s])?o[s]=T(c[s],e[s],f):Object.assign(o,{[s]:e[s]})}),o}function Y(t,n){return{name:t,getImportUrl(f){let c=f.map(e=>{let{name:o,weights:s,italic:i}=e,b=o.toLowerCase().replace(/\s/g,"-");if(!s?.length)return`${b}${i?":i":""}`;let u=s.map(g=>g.toString());return!u.some(g=>g.endsWith("i"))&&i&&(u=u.map(g=>g+="i")),`${b}:${u.join(",")}`});return`${n}/css?family=${c.join("|")}&display=swap`}}}var R=Y("bunny","https://fonts.bunny.net");function G(t){if(!t||t.length===0)return"";let n=[[]];for(let{values:f}of t){let c=[];for(let e of n)for(let o of f)c.push([...e,o]);n=c}return n.map(f=>f.join(",")).join(";")}function W(t,n){return{name:t,getImportUrl(f){let c=f.map(e=>{let o=e.name.replace(/\s+/g,"+"),s=[];return e.italic&&s.push({axis:"ital",values:["0","1"]}),e.widths?.length&&s.push({axis:"wdth",values:e.widths.map(i=>i.toString())}),e.weights?.length&&s.push({axis:"wght",values:e.weights.map(i=>i.toString())}),s.length&&(o+=":",o+=s.map(i=>i.axis).join(","),o+="@",o+=G(s)),`family=${o}`}).join("&");return`${n}/css2?${c}&display=swap`}}}var _=W("google","https://fonts.googleapis.com");var E=W("coollabs","https://api.fonts.coollabs.io");var I=H("fontshare","https://api.fontshare.com");function H(t,n){return{name:t,getImportUrl(f){let c=f.map(e=>{let o=e.name.replace(/\s+/g,"-").toLocaleLowerCase();return e.weights?.length?o+=`@${e.weights.flatMap(s=>e.italic?Number(s)+1:s).sort().join()}`:o+=`@${e.italic?2:1}`,`f[]=${o}`}).join("&");return`${n}/v2/css?${c}&display=swap`}}}function q(t,n){let f=new Map,c=new Map;return{name:t,async getPreflight(e,o){return(await Promise.all(e.map(async i=>{let b=[],u=i.name.toLowerCase().replace(/\s+/g,"-"),l=f.get(u);if(!l){let v=`https://api.fontsource.org/v1/fonts/${u}`;try{l=await o(v),f.set(u,l)}catch{throw new Error(`Failed to fetch font: ${i.name}`)}}let{weights:g,unicodeRange:S,variants:h,family:$}=l,F=l.subsets.filter(v=>i.subsets?i.subsets.includes(v):!0),P=i.italic?"italic":"normal";if(l.variable&&!i.preferStatic){let v=c.get(u),r=`https://api.fontsource.org/v1/variable/${u}`;try{v=await o(r),c.set(u,v)}catch{throw new Error(`Failed to fetch font variable: ${i.name}`)}let a=T(v.axes,i.variable??{});for(let p of F)if(S[p]){let m=`${n}/fontsource/fonts/${l.id}:vf@latest/${p}-wght-${P}.woff2`,y={family:$,display:"swap",style:P,weight:400,src:[{url:m,format:"woff2-variations"}],variable:{wght:a.wght??void 0,wdth:a.wdth??void 0,slnt:a.slnt??void 0},unicodeRange:S[p],comment:`${l.id}-${p}-wght-normal`};b.push(O(y))}else Object.entries(S).filter(([m])=>!l.subsets.includes(m)).forEach(([m,y])=>{let d=`${n}/fontsource/fonts/${l.id}:vf@latest/${m.slice(1,-1)}-wght-${P}.woff2`,w={family:$,display:"swap",style:P,weight:400,src:[{url:d,format:"woff2-variations"}],variable:{wght:a.wght??void 0,wdth:a.wdth??void 0,slnt:a.slnt??void 0},unicodeRange:y,comment:`${l.id}-${m}-wght-normal`};b.push(O(w))})}else{let v=i.weights&&i.weights.length>0?i.weights:g;for(let r of F)for(let a of v){let p=h[a][P][r].url,m={family:$,display:"swap",style:P,weight:Number(a),src:[{url:p.woff2,format:"woff2"}],unicodeRange:S[r],comment:`${l.id}-${r}-${a}-${P}`};b.push(O(m))}}return b}))).flat().join(`
1
+ "use strict";(()=>{var U="default",B="preflights",k="shortcuts",M="imports",J={[M]:-200,[B]:-100,[k]:-10,[U]:0};function C(t=[]){return Array.isArray(t)?t:[t]}function A(t){return t&&typeof t=="object"&&!Array.isArray(t)}function j(t,s,l=!1){let c=t,e=s;if(Array.isArray(e))return l&&Array.isArray(e)?[...c,...e]:[...e];let n={...c};return A(c)&&A(e)&&Object.keys(e).forEach(o=>{A(c[o])&&A(e[o])||Array.isArray(c[o])&&Array.isArray(e[o])?n[o]=j(c[o],e[o],l):Object.assign(n,{[o]:e[o]})}),n}function G(t,s){return{name:t,getImportUrl(l){let c=l.map(e=>{let{name:n,weights:o,italic:i}=e,v=n.toLowerCase().replace(/\s/g,"-");if(!o?.length)return`${v}${i?":i":""}`;let f=o.map(d=>d.toString());return!f.some(d=>d.endsWith("i"))&&i&&(f=f.map(d=>d+="i")),`${v}:${f.join(",")}`});return`${s}/css?family=${c.join("|")}&display=swap`}}}var R=G("bunny","https://fonts.bunny.net");function D(t){if(!t||t.length===0)return"";let s=[[]];for(let{values:l}of t){let c=[];for(let e of s)for(let n of l)c.push([...e,n]);s=c}return s.map(l=>l.join(",")).join(";")}function _(t,s){return{name:t,getImportUrl(l){let c=l.map(e=>{let n=e.name.replace(/\s+/g,"+"),o=[];return e.italic&&o.push({axis:"ital",values:["0","1"]}),e.widths?.length&&o.push({axis:"wdth",values:e.widths.map(i=>i.toString())}),e.weights?.length&&o.push({axis:"wght",values:e.weights.map(i=>i.toString())}),o.length&&(n+=":",n+=o.map(i=>i.axis).join(","),n+="@",n+=D(o)),`family=${n}`}).join("&");return`${s}/css2?${c}&display=swap`}}}var E=_("google","https://fonts.googleapis.com");var W=_("coollabs","https://api.fonts.coollabs.io");var L=H("fontshare","https://api.fontshare.com");function H(t,s){return{name:t,getImportUrl(l){let c=l.map(e=>{let n=e.name.replace(/\s+/g,"-").toLocaleLowerCase();return e.weights?.length?n+=`@${e.weights.flatMap(o=>e.italic?Number(o)+1:o).sort().join()}`:n+=`@${e.italic?2:1}`,`f[]=${n}`}).join("&");return`${s}/v2/css?${c}&display=swap`}}}function z(t,s){let l=new Map,c=new Map;return{name:t,async getPreflight(e,n){return(await Promise.all(e.map(async i=>{let v=[],f=i.name.toLowerCase().replace(/\s+/g,"-"),u=l.get(f);if(!u){let $=`https://api.fontsource.org/v1/fonts/${f}`;try{u=await n($),l.set(f,u)}catch{throw new Error(`Failed to fetch font: ${i.name}`)}}let{weights:d,unicodeRange:b,variants:g,family:x}=u,P=u.subsets.filter($=>i.subsets?i.subsets.includes($):!0),S=i.italic?"italic":"normal";if(u.variable&&!i.preferStatic){let $=c.get(f),r=`https://api.fontsource.org/v1/variable/${f}`;try{$=await n(r),c.set(f,$)}catch{throw new Error(`Failed to fetch font variable: ${i.name}`)}let a=j($.axes,i.variable??{});for(let p of P)if(b[p]){let h=`${s}/fontsource/fonts/${u.id}:vf@latest/${p}-wght-${S}.woff2`,y={family:x,display:"swap",style:S,weight:400,src:[{url:h,format:"woff2-variations"}],variable:{wght:a.wght??void 0,wdth:a.wdth??void 0,slnt:a.slnt??void 0},unicodeRange:b[p],comment:`${u.id}-${p}-wght-normal`};v.push(O(y))}else Object.entries(b).filter(([h])=>!u.subsets.includes(h)).forEach(([h,y])=>{let m=`${s}/fontsource/fonts/${u.id}:vf@latest/${h.slice(1,-1)}-wght-${S}.woff2`,w={family:x,display:"swap",style:S,weight:400,src:[{url:m,format:"woff2-variations"}],variable:{wght:a.wght??void 0,wdth:a.wdth??void 0,slnt:a.slnt??void 0},unicodeRange:y,comment:`${u.id}-${h}-wght-normal`};v.push(O(w))})}else{let $=i.weights&&i.weights.length>0?i.weights:d;for(let r of P)for(let a of $){let p=g[a][S][r].url,h={family:x,display:"swap",style:S,weight:Number(a),src:[{url:p.woff2,format:"woff2"}],unicodeRange:b[r],comment:`${u.id}-${r}-${a}-${S}`};v.push(O(h))}}return v}))).flat().join(`
2
2
 
3
- `)}}}var L=q("fontsource","https://cdn.jsdelivr.net");function O(t){let{family:n,style:f,display:c,weight:e,variable:o,src:s,unicodeRange:i,comment:b,spacer:u=`
4
- `}=t,{wght:l,wdth:g,slnt:S}=o??{},h="@font-face {";return h+=`${u}font-family: '${n}';`,h+=`${u}font-style: ${S?`oblique ${Number(S.max)*-1}deg ${Number(S.min)*-1}deg`:f};`,h+=`${u}font-display: ${c};`,h+=`${u}font-weight: ${l?z(l):e};`,g&&(h+=`${u}font-stretch: ${g.min}% ${g.max}%;`),h+=`${u}src: ${s.map(({url:$,format:F})=>`url(${$}) format('${F}')`).join(", ")};`,i&&(h+=`${u}unicode-range: ${i};`),b&&(h=`/* ${b} */
5
- ${h}`),`${h}
6
- }`}function z(t){return t?t.min===t.max?`${t.min}`:`${t.min} ${t.max}`:"400"}var M={name:"none",getPreflight(){return""},getFontName(t){return t.name}};var K={google:_,bunny:R,fontshare:I,fontsource:L,coollabs:E,none:M};function V(t){return typeof t=="string"?K[t]:t}function J(t,n){if(typeof t!="string")return t.provider=V(t.provider||n),t.weights&&(t.weights=[...new Set(t.weights.sort((e,o)=>e.toString().localeCompare(o.toString(),"en",{numeric:!0})))]),t.widths&&(t.widths=[...new Set(t.widths.sort((e,o)=>e.toString().localeCompare(o.toString(),"en",{numeric:!0})))]),t;let[f,c=""]=t.split(":");return{name:f,weights:[...new Set(c.split(/[,;]\s*/).filter(Boolean).sort((e,o)=>e.localeCompare(o,"en",{numeric:!0})))],provider:V(n)}}function N(t){return(n={})=>{let{provider:f="google",extendTheme:c=!0,inlineImports:e=!0,customFetch:o=t,timeouts:s={}}=n,i="fonts",b=e?i:C,u=j(n.processors||[]),l=Object.fromEntries(Object.entries(n.fonts||{}).map(([r,a])=>[r,j(a).map(p=>J(p,f))])),g=Object.values(l).flatMap(r=>r),S={};async function h(r){if(s===!1)return o(r);let{warning:a=1e3,failure:p=2e3}=s,m=!1,y=setTimeout(()=>{console.warn(`[unocss] Fetching web fonts: ${r}`),m=!0},a);return await Promise.race([o(r),new Promise((d,w)=>{setTimeout(()=>w(new Error("[unocss] Fetch web fonts timeout.")),p)})]).then(d=>(m&&console.info("[unocss] Web fonts fetched."),d)).finally(()=>clearTimeout(y))}async function $(r){return e?(S[r]||(S[r]=h(r).catch(a=>{if(console.error(`[unocss] Failed to fetch web fonts: ${r}`),console.error(a),typeof process<"u"&&process.env.CI)throw a})),await S[r]):`@import url('${r}');`}let F=Array.from(new Set(g.map(r=>r.provider)));async function P(r,a){let p=[];for(let y of a){let d=r.filter(w=>w.provider.name===y.name);if(y.getImportUrl){let w=y.getImportUrl(d);w&&p.push(await $(w))}try{p.push(await y.getPreflight?.(d,h))}catch(w){console.warn("[unocss] Web fonts preflight fetch failed.",w)}}return p.filter(Boolean).join(`
7
- `)}let v={name:"@unocss/preset-web-fonts",preflights:[{async getCSS(){let r;for(let a of u){let p=await a.getCSS?.(g,F,P);if(p){r=p;break}}r||(r=await P(g,F));for(let a of u)r=await a.transformCSS?.(r)||r;return r},layer:b}],layers:{[i]:-200}};return c&&(v.extendTheme=(r,a)=>{let p=a.presets.some(d=>d.name==="@unocss/preset-wind4"),m=n.themeKey??(p?"font":"fontFamily");r[m]||(r[m]={});let y=Object.fromEntries(Object.entries(l).map(([d,w])=>[d,w.map(A=>A.provider.getFontName?.(A)??`"${A.name}"`)]));for(let d of Object.keys(y))typeof r[m][d]=="string"?r[m][d]=y[d].map(w=>`${w},`).join("")+r[m][d]:r[m][d]=y[d].join(",")}),v}}window.__unocss_runtime=window.__unocss_runtime??{};window.__unocss_runtime.presets=Object.assign(window.__unocss_runtime?.presets??{},(()=>{let t=N(n=>fetch(n).then(f=>f.json()));return{presetWebFonts:n=>t(n)}})());})();
3
+ `)}}}var N=z("fontsource","https://cdn.jsdelivr.net");function O(t){let{family:s,style:l,display:c,weight:e,variable:n,src:o,unicodeRange:i,comment:v,spacer:f=`
4
+ `}=t,{wght:u,wdth:d,slnt:b}=n??{},g="@font-face {";return g+=`${f}font-family: '${s}';`,g+=`${f}font-style: ${b?`oblique ${Number(b.max)*-1}deg ${Number(b.min)*-1}deg`:l};`,g+=`${f}font-display: ${c};`,g+=`${f}font-weight: ${u?Y(u):e};`,d&&(g+=`${f}font-stretch: ${d.min}% ${d.max}%;`),g+=`${f}src: ${o.map(({url:x,format:P})=>`url(${x}) format('${P}')`).join(", ")};`,i&&(g+=`${f}unicode-range: ${i};`),v&&(g=`/* ${v} */
5
+ ${g}`),`${g}
6
+ }`}function Y(t){return t?t.min===t.max?`${t.min}`:`${t.min} ${t.max}`:"400"}var V={name:"none",getPreflight(){return""},getFontName(t){return t.name}};var K={google:E,bunny:R,fontshare:L,fontsource:N,coollabs:W,none:V};function T(t){return typeof t=="string"?K[t]:t}function q(t,s){if(typeof t!="string")return t.provider=T(t.provider||s),t.weights&&(t.weights=[...new Set(t.weights.sort((e,n)=>e.toString().localeCompare(n.toString(),"en",{numeric:!0})))]),t.widths&&(t.widths=[...new Set(t.widths.sort((e,n)=>e.toString().localeCompare(n.toString(),"en",{numeric:!0})))]),t;let[l,c=""]=t.split(":");return{name:l,weights:[...new Set(c.split(/[,;]\s*/).filter(Boolean).sort((e,n)=>e.localeCompare(n,"en",{numeric:!0})))],provider:T(s)}}function I(t){return(s={})=>{let{provider:l="google",extendTheme:c=!0,inlineImports:e=!0,customFetch:n=t,timeouts:o={}}=s,i="fonts",v=e?i:M,f=C(s.processors||[]),u=Object.fromEntries(Object.entries(s.fonts||{}).map(([r,a])=>[r,C(a).map(p=>q(p,l))])),d=Object.values(u).flatMap(r=>r),b={};async function g(r){if(o===!1)return n(r);let{warning:a=1e3,failure:p=2e3}=o,h=!1,y=setTimeout(()=>{console.warn(`[unocss] Fetching web fonts: ${r}`),h=!0},a);return await Promise.race([n(r),new Promise((m,w)=>{setTimeout(()=>w(new Error("[unocss] Fetch web fonts timeout.")),p)})]).then(m=>(h&&console.info("[unocss] Web fonts fetched."),m)).finally(()=>clearTimeout(y))}async function x(r){return e?(b[r]||(b[r]=g(r).catch(a=>{if(console.error(`[unocss] Failed to fetch web fonts: ${r}`),console.error(a),typeof process<"u"&&process.env.CI)throw a})),await b[r]):`@import url('${r}');`}let P=Array.from(new Set(d.map(r=>r.provider)));async function S(r,a){let p=[];for(let y of a){let m=r.filter(w=>w.provider.name===y.name);if(y.getImportUrl){let w=y.getImportUrl(m);w&&p.push(await x(w))}try{p.push(await y.getPreflight?.(m,g))}catch(w){console.warn("[unocss] Web fonts preflight fetch failed.",w)}}return p.filter(Boolean).join(`
7
+ `)}let $={name:"@unocss/preset-web-fonts",preflights:[{async getCSS(){let r;for(let a of f){let p=await a.getCSS?.(d,P,S);if(p){r=p;break}}r||(r=await S(d,P));for(let a of f)r=await a.transformCSS?.(r)||r;return r},layer:v}],layers:{[i]:-200}};return c&&($.extendTheme=(r,a)=>{let p=a.presets.some(m=>m.name==="@unocss/preset-wind4"),h=s.themeKey??(p?"font":"fontFamily");r[h]||(r[h]={});let y=Object.fromEntries(Object.entries(u).map(([m,w])=>[m,w.map(F=>F.provider.getFontName?.(F)??`"${F.name}"`)]));for(let m of Object.keys(y))typeof r[h][m]=="string"?r[h][m]=y[m].map(w=>`${w},`).join("")+r[h][m]:r[h][m]=y[m].join(",")}),$}}window.__unocss_runtime=window.__unocss_runtime??{};window.__unocss_runtime.presets=Object.assign(window.__unocss_runtime?.presets??{},(()=>{let t=I(s=>fetch(s).then(l=>l.json()));return{presetWebFonts:s=>t(s)}})());})();