@unocss/runtime 66.5.0 → 66.5.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 +2 -2
- package/core.global.js +1 -1
- package/full.global.js +2 -2
- package/mini.global.js +2 -2
- package/package.json +4 -4
- package/preset-mini.global.js +1 -1
- package/preset-uno.global.js +1 -1
- package/preset-web-fonts.global.js +5 -5
- package/preset-wind.global.js +1 -1
- package/uno.global.js +2 -2
|
@@ -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,
|
|
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(`
|
|
2
2
|
|
|
3
|
-
`)}}}var L=q("fontsource","https://cdn.jsdelivr.net");function
|
|
4
|
-
`}=t,{wght:
|
|
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
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[
|
|
7
|
-
`)}let
|
|
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)}})());})();
|