@unocss/runtime 66.6.8 → 66.7.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,8 @@
1
- "use strict";(()=>{var I="default",U="preflights",B="shortcuts",M="imports",J={[M]:-200,[U]:-100,[B]:-10,[I]:0};function C(t=[]){return Array.isArray(t)?t:[t]}function A(t){return t&&typeof t=="object"&&!Array.isArray(t)}function _(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]=_(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 j(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=j("google","https://fonts.googleapis.com");var W=j("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=_($.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(`
1
+ "use strict";(()=>{var B="default",G="preflights",D="shortcuts",M="imports",Q={[M]:-200,[G]:-100,[D]:-10,[B]:0};function C(e=[]){return Array.isArray(e)?e:[e]}function F(e){return e&&typeof e=="object"&&!Array.isArray(e)}function _(e,n,c=!1){let a=e,t=n;if(Array.isArray(t))return c&&Array.isArray(t)?[...a,...t]:[...t];let s={...a};return F(a)&&F(t)&&Object.keys(t).forEach(o=>{F(a[o])&&F(t[o])||Array.isArray(a[o])&&Array.isArray(t[o])?s[o]=_(a[o],t[o],c):Object.assign(s,{[o]:t[o]})}),s}function z(e,n){return{name:e,getImportUrl(c){let a=c.map(t=>{let{name:s,weights:o,italic:i}=t,y=s.toLowerCase().replace(/\s/g,"-");if(!o?.length)return`${y}${i?":i":""}`;let f=o.map(d=>d.toString());return!f.some(d=>d.endsWith("i"))&&i&&(f=f.map(d=>d+="i")),`${y}:${f.join(",")}`});return`${n}/css?family=${a.join("|")}&display=swap`}}}var R=z("bunny","https://fonts.bunny.net");function H(e){if(!e||e.length===0)return"";let n=[[]];for(let{values:c}of e){let a=[];for(let t of n)for(let s of c)a.push([...t,s]);n=a}return n.map(c=>c.join(",")).join(";")}function j(e,n){return{name:e,getImportUrl(c){let a=c.map(t=>{let s=t.name.replace(/\s+/g,"+"),o=[];return t.italic&&o.push({axis:"ital",values:["0","1"]}),t.widths?.length&&o.push({axis:"wdth",values:t.widths.map(i=>i.toString())}),t.weights?.length&&o.push({axis:"wght",values:t.weights.map(i=>i.toString())}),o.length&&(s+=":",s+=o.map(i=>i.axis).join(","),s+="@",s+=H(o)),`family=${s}`}).join("&");return`${n}/css2?${a}&display=swap`}}}var E=j("google","https://fonts.googleapis.com");var W=j("coollabs","https://api.fonts.coollabs.io");var L=Y("fontshare","https://api.fontshare.com");function Y(e,n){return{name:e,getImportUrl(c){let a=c.map(t=>{let s=t.name.replace(/\s+/g,"-").toLocaleLowerCase();return t.weights?.length?s+=`@${t.weights.flatMap(o=>t.italic?Number(o)+1:o).sort().join()}`:s+=`@${t.italic?2:1}`,`f[]=${s}`}).join("&");return`${n}/v2/css?${a}&display=swap`}}}function K(e,n){let c=new Map,a=new Map;return{name:e,async getPreflight(t,s){return(await Promise.all(t.map(async i=>{let y=[],f=i.name.toLowerCase().replace(/\s+/g,"-"),u=c.get(f);if(!u){let $=`https://api.fontsource.org/v1/fonts/${f}`;try{u=await s($),c.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 $=a.get(f),r=`https://api.fontsource.org/v1/variable/${f}`;try{$=await s(r),a.set(f,$)}catch{throw new Error(`Failed to fetch font variable: ${i.name}`)}let l=_($.axes,i.variable??{});for(let p of P)if(b[p]){let h=`${n}/fontsource/fonts/${u.id}:vf@latest/${p}-wght-${S}.woff2`,v={family:x,display:"swap",style:S,weight:400,src:[{url:h,format:"woff2-variations"}],variable:{wght:l.wght??void 0,wdth:l.wdth??void 0,slnt:l.slnt??void 0},unicodeRange:b[p],comment:`${u.id}-${p}-wght-normal`};y.push(O(v))}else Object.entries(b).filter(([h])=>!u.subsets.includes(h)).forEach(([h,v])=>{let m=`${n}/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:l.wght??void 0,wdth:l.wdth??void 0,slnt:l.slnt??void 0},unicodeRange:v,comment:`${u.id}-${h}-wght-normal`};y.push(O(w))})}else{let $=i.weights&&i.weights.length>0?i.weights:d;for(let r of P)for(let l of $){let p=g[l][S][r].url,h={family:x,display:"swap",style:S,weight:Number(l),src:[{url:p.woff2,format:"woff2"}],unicodeRange:b[r],comment:`${u.id}-${r}-${l}-${S}`};y.push(O(h))}}return y}))).flat().join(`
2
2
 
3
- `)}}}var k=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} */
3
+ `)}}}var N=K("fontsource","https://cdn.jsdelivr.net");function O(e){let{family:n,style:c,display:a,weight:t,variable:s,src:o,unicodeRange:i,comment:y,spacer:f=`
4
+ `}=e,{wght:u,wdth:d,slnt:b}=s??{},g="@font-face {";return g+=`${f}font-family: '${n}';`,g+=`${f}font-style: ${b?`oblique ${Number(b.max)*-1}deg ${Number(b.min)*-1}deg`:c};`,g+=`${f}font-display: ${a};`,g+=`${f}font-weight: ${u?Z(u):t};`,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};`),y&&(g=`/* ${y} */
5
5
  ${g}`),`${g}
6
- }`}function Y(t){return t?t.min===t.max?`${t.min}`:`${t.min} ${t.max}`:"400"}var N={name:"none",getPreflight(){return""},getFontName(t){return t.name}};var K={google:E,bunny:R,fontshare:L,fontsource:k,coollabs:W,none:N};function V(t){return typeof t=="string"?K[t]:t}function q(t,s){if(typeof t!="string")return t.provider=V(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:V(s)}}function T(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=T(s=>fetch(s).then(l=>l.json()));return{presetWebFonts:s=>t(s)}})());})();
6
+ }`}function Z(e){return e?e.min===e.max?`${e.min}`:`${e.min} ${e.max}`:"400"}var k={name:"none",getPreflight(){return""},getFontName(e){return e.name}};function I(e){let n=e.lastIndexOf("@");if(n===-1)throw new Error(`[unocss] ZeoSeven provider requires font ID in format "FontFamily@id", e.g. "LXGW WenKai@292". Got: "${e}"`);return{family:e.slice(0,n).trim(),id:e.slice(n+1).trim()}}function q(e,n){return{name:e,getFontName(c){let{family:a}=I(c.name);return`"${a}"`},async getPreflight(c,a){let t=[];for(let s of c){let{id:o}=I(s.name),i=`${n}/${o}/main/`,y=`${i}result.css`;try{let u=(await a(y)).replace(/url\("\.\/([^"]+)"\)/g,`url("${i}$1")`);t.push(u)}catch{throw new Error(`[unocss] Failed to fetch ZeoSeven font CSS for ID "${o}"`)}}return t.join(`
7
+ `)}}}var V=q("zeoseven","https://fontsapi.zeoseven.com");var X={google:E,bunny:R,fontshare:L,fontsource:N,coollabs:W,none:k,zeoseven:V};function T(e){return typeof e=="string"?X[e]:e}function J(e,n){if(typeof e!="string")return e.provider=T(e.provider||n),e.weights&&(e.weights=[...new Set(e.weights.sort((t,s)=>t.toString().localeCompare(s.toString(),"en",{numeric:!0})))]),e.widths&&(e.widths=[...new Set(e.widths.sort((t,s)=>t.toString().localeCompare(s.toString(),"en",{numeric:!0})))]),e;let[c,a=""]=e.split(":");return{name:c,weights:[...new Set(a.split(/[,;]\s*/).filter(Boolean).sort((t,s)=>t.localeCompare(s,"en",{numeric:!0})))],provider:T(n)}}function U(e){return(n={})=>{let{provider:c="google",extendTheme:a=!0,inlineImports:t=!0,customFetch:s=e,timeouts:o={}}=n,i="fonts",y=t?i:M,f=C(n.processors||[]),u=Object.fromEntries(Object.entries(n.fonts||{}).map(([r,l])=>[r,C(l).map(p=>J(p,c))])),d=Object.values(u).flatMap(r=>r),b={};async function g(r){if(o===!1)return s(r);let{warning:l=1e3,failure:p=2e3}=o,h=!1,v=setTimeout(()=>{console.warn(`[unocss] Fetching web fonts: ${r}`),h=!0},l);return await Promise.race([s(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(v))}async function x(r){return t?(b[r]||(b[r]=g(r).catch(l=>{if(console.error(`[unocss] Failed to fetch web fonts: ${r}`),console.error(l),typeof process<"u"&&process.env.CI)throw l})),await b[r]):`@import url('${r}');`}let P=Array.from(new Set(d.map(r=>r.provider)));async function S(r,l){let p=[];for(let v of l){let m=r.filter(w=>w.provider.name===v.name);if(v.getImportUrl){let w=v.getImportUrl(m);w&&p.push(await x(w))}try{p.push(await v.getPreflight?.(m,g))}catch(w){console.warn("[unocss] Web fonts preflight fetch failed.",w)}}return p.filter(Boolean).join(`
8
+ `)}let $={name:"@unocss/preset-web-fonts",preflights:[{async getCSS(){let r;for(let l of f){let p=await l.getCSS?.(d,P,S);if(p){r=p;break}}r||(r=await S(d,P));for(let l of f)r=await l.transformCSS?.(r)||r;return r},layer:y}],layers:{[i]:-200}};return a&&($.extendTheme=(r,l)=>{let p=l.presets.some(m=>m.name==="@unocss/preset-wind4"),h=n.themeKey??(p?"font":"fontFamily");r[h]||(r[h]={});let v=Object.fromEntries(Object.entries(u).map(([m,w])=>[m,w.map(A=>A.provider.getFontName?.(A)??`"${A.name}"`)]));for(let m of Object.keys(v))typeof r[h][m]=="string"?r[h][m]=v[m].map(w=>`${w},`).join("")+r[h][m]:r[h][m]=v[m].join(",")}),$}}window.__unocss_runtime=window.__unocss_runtime??{};window.__unocss_runtime.presets=Object.assign(window.__unocss_runtime?.presets??{},(()=>{let e=U(n=>fetch(n).then(c=>c.json()));return{presetWebFonts:n=>e(n)}})());})();