@unocss/preset-web-fonts 66.6.6-beta.1 → 66.6.7

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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as WebFontProcessor, i as WebFontMeta, n as Provider, o as WebFontsOptions, r as ResolvedWebFontMeta, s as WebFontsProviders, t as Axes } from "./types-CAg9LcCB.mjs";
1
+ import { a as WebFontProcessor, i as WebFontMeta, n as Provider, o as WebFontsOptions, r as ResolvedWebFontMeta, s as WebFontsProviders, t as Axes } from "./types-o6CvBLpT.mjs";
2
2
  import * as _unocss_core0 from "@unocss/core";
3
3
 
4
4
  //#region src/preset.d.ts
package/dist/index.mjs CHANGED
@@ -1,13 +1,12 @@
1
1
  import { LAYER_IMPORTS, definePreset, mergeDeep, toArray } from "@unocss/core";
2
-
3
2
  //#region src/providers/bunny.ts
4
3
  function createBunnyFontsProvider(name, host) {
5
4
  return {
6
5
  name,
7
6
  getImportUrl(fonts) {
8
7
  return `${host}/css?family=${fonts.map((font) => {
9
- const { name: name$1, weights, italic } = font;
10
- const formattedName = name$1.toLowerCase().replace(/\s/g, "-");
8
+ const { name, weights, italic } = font;
9
+ const formattedName = name.toLowerCase().replace(/\s/g, "-");
11
10
  if (!weights?.length) return `${formattedName}${italic ? ":i" : ""}`;
12
11
  let weightsAsString = weights.map((weight) => weight.toString());
13
12
  if (!weightsAsString.some((weight) => weight.endsWith("i")) && italic) weightsAsString = weightsAsString.map((weight) => weight += "i");
@@ -17,7 +16,6 @@ function createBunnyFontsProvider(name, host) {
17
16
  };
18
17
  }
19
18
  const BunnyFontsProvider = createBunnyFontsProvider("bunny", "https://fonts.bunny.net");
20
-
21
19
  //#endregion
22
20
  //#region src/providers/google.ts
23
21
  function generateFontAxes(axes) {
@@ -35,7 +33,7 @@ function createGoogleCompatibleProvider(name, host) {
35
33
  name,
36
34
  getImportUrl(fonts) {
37
35
  return `${host}/css2?${fonts.map((i) => {
38
- let name$1 = i.name.replace(/\s+/g, "+");
36
+ let name = i.name.replace(/\s+/g, "+");
39
37
  /**
40
38
  * When using the Google Fonts API, be sure to list them alphabetically.
41
39
  * @see https://fonts.google.com/knowledge/using_type/styling_type_on_the_web_with_variable_fonts
@@ -55,22 +53,20 @@ function createGoogleCompatibleProvider(name, host) {
55
53
  values: i.weights.map((w) => w.toString())
56
54
  });
57
55
  if (axisValues.length) {
58
- name$1 += ":";
59
- name$1 += axisValues.map((a) => a.axis).join(",");
60
- name$1 += "@";
61
- name$1 += generateFontAxes(axisValues);
56
+ name += ":";
57
+ name += axisValues.map((a) => a.axis).join(",");
58
+ name += "@";
59
+ name += generateFontAxes(axisValues);
62
60
  }
63
- return `family=${name$1}`;
61
+ return `family=${name}`;
64
62
  }).join("&")}&display=swap`;
65
63
  }
66
64
  };
67
65
  }
68
66
  const GoogleFontsProvider = createGoogleCompatibleProvider("google", "https://fonts.googleapis.com");
69
-
70
67
  //#endregion
71
68
  //#region src/providers/coollabs.ts
72
69
  const CoolLabsFontsProvider = createGoogleCompatibleProvider("coollabs", "https://api.fonts.coollabs.io");
73
-
74
70
  //#endregion
75
71
  //#region src/providers/fontshare.ts
76
72
  const FontshareProvider = createFontshareProvider("fontshare", "https://api.fontshare.com");
@@ -79,15 +75,14 @@ function createFontshareProvider(name, host) {
79
75
  name,
80
76
  getImportUrl(fonts) {
81
77
  return `${host}/v2/css?${fonts.map((f) => {
82
- let name$1 = f.name.replace(/\s+/g, "-").toLocaleLowerCase();
83
- if (f.weights?.length) name$1 += `@${f.weights.flatMap((w) => f.italic ? Number(w) + 1 : w).sort().join()}`;
84
- else name$1 += `@${f.italic ? 2 : 1}`;
85
- return `f[]=${name$1}`;
78
+ let name = f.name.replace(/\s+/g, "-").toLocaleLowerCase();
79
+ if (f.weights?.length) name += `@${f.weights.flatMap((w) => f.italic ? Number(w) + 1 : w).sort().join()}`;
80
+ else name += `@${f.italic ? 2 : 1}`;
81
+ return `f[]=${name}`;
86
82
  }).join("&")}&display=swap`;
87
83
  }
88
84
  };
89
85
  }
90
-
91
86
  //#endregion
92
87
  //#region src/providers/fontsource/index.ts
93
88
  function createFontSourceProvider(name, host) {
@@ -205,19 +200,6 @@ function getVariableWght(axes) {
205
200
  if (axes.min === axes.max) return `${axes.min}`;
206
201
  return `${axes.min} ${axes.max}`;
207
202
  }
208
-
209
- //#endregion
210
- //#region src/providers/none.ts
211
- const NoneProvider = {
212
- name: "none",
213
- getPreflight() {
214
- return "";
215
- },
216
- getFontName(font) {
217
- return font.name;
218
- }
219
- };
220
-
221
203
  //#endregion
222
204
  //#region src/preset.ts
223
205
  const builtinProviders = {
@@ -226,7 +208,15 @@ const builtinProviders = {
226
208
  fontshare: FontshareProvider,
227
209
  fontsource: FontSourceProvider,
228
210
  coollabs: CoolLabsFontsProvider,
229
- none: NoneProvider
211
+ none: {
212
+ name: "none",
213
+ getPreflight() {
214
+ return "";
215
+ },
216
+ getFontName(font) {
217
+ return font.name;
218
+ }
219
+ }
230
220
  };
231
221
  function resolveProvider(provider) {
232
222
  if (typeof provider === "string") return builtinProviders[provider];
@@ -281,10 +271,10 @@ function createWebFontPreset(fetcher) {
281
271
  } else return `@import url('${url}');`;
282
272
  }
283
273
  const enabledProviders = Array.from(new Set(fonts.map((i) => i.provider)));
284
- async function getCSSDefault(fonts$1, providers) {
274
+ async function getCSSDefault(fonts, providers) {
285
275
  const preflights = [];
286
276
  for (const provider of providers) {
287
- const fontsForProvider = fonts$1.filter((i) => i.provider.name === provider.name);
277
+ const fontsForProvider = fonts.filter((i) => i.provider.name === provider.name);
288
278
  if (provider.getImportUrl) {
289
279
  const url = provider.getImportUrl(fontsForProvider);
290
280
  if (url) preflights.push(await importUrl(url));
@@ -321,14 +311,13 @@ function createWebFontPreset(fetcher) {
321
311
  const hasWind4 = config.presets.some((p) => p.name === "@unocss/preset-wind4");
322
312
  const themeKey = options.themeKey ?? (hasWind4 ? "font" : "fontFamily");
323
313
  if (!theme[themeKey]) theme[themeKey] = {};
324
- const obj = Object.fromEntries(Object.entries(fontObject).map(([name, fonts$1]) => [name, fonts$1.map((f) => f.provider.getFontName?.(f) ?? `"${f.name}"`)]));
314
+ const obj = Object.fromEntries(Object.entries(fontObject).map(([name, fonts]) => [name, fonts.map((f) => f.provider.getFontName?.(f) ?? `"${f.name}"`)]));
325
315
  for (const key of Object.keys(obj)) if (typeof theme[themeKey][key] === "string") theme[themeKey][key] = obj[key].map((i) => `${i},`).join("") + theme[themeKey][key];
326
316
  else theme[themeKey][key] = obj[key].join(",");
327
317
  };
328
318
  return preset;
329
319
  };
330
320
  }
331
-
332
321
  //#endregion
333
322
  //#region src/index.ts
334
323
  const userAgentWoff2 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36";
@@ -342,7 +331,5 @@ const defaultFetch = async (url) => (await import("ofetch")).$fetch(url, {
342
331
  * @see https://unocss.dev/presets/web-fonts
343
332
  */
344
333
  const presetWebFonts = definePreset(createWebFontPreset(defaultFetch));
345
- var src_default = presetWebFonts;
346
-
347
334
  //#endregion
348
- export { createGoogleCompatibleProvider as createGoogleProvider, src_default as default, normalizedFontMeta, presetWebFonts };
335
+ export { createGoogleCompatibleProvider as createGoogleProvider, presetWebFonts as default, presetWebFonts, normalizedFontMeta };
package/dist/local.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as WebFontProcessor } from "./types-CAg9LcCB.mjs";
1
+ import { a as WebFontProcessor } from "./types-o6CvBLpT.mjs";
2
2
  import { fetch } from "ofetch";
3
3
 
4
4
  //#region src/local.d.ts
package/dist/local.mjs CHANGED
@@ -6,7 +6,6 @@ import fsp from "node:fs/promises";
6
6
  import { join, resolve } from "node:path";
7
7
  import process from "node:process";
8
8
  import { fetch } from "ofetch";
9
-
10
9
  //#region ../../virtual-shared/integration/src/utils.ts
11
10
  function replaceAsync(string, searchValue, replacer) {
12
11
  try {
@@ -26,7 +25,6 @@ function replaceAsync(string, searchValue, replacer) {
26
25
  return Promise.reject(error);
27
26
  }
28
27
  }
29
-
30
28
  //#endregion
31
29
  //#region src/local.ts
32
30
  const fontUrlRegex = /[-\w@:%+.~#?&/=]+\.(?:woff2?|eot|ttf|otf|svg)/gi;
@@ -81,6 +79,5 @@ function withProtocol(input, protocol = "https://") {
81
79
  if (!match) return protocol + input;
82
80
  return protocol + input.slice(match[0].length);
83
81
  }
84
-
85
82
  //#endregion
86
- export { createLocalFontProcessor };
83
+ export { createLocalFontProcessor };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-web-fonts",
3
3
  "type": "module",
4
- "version": "66.6.6-beta.1",
4
+ "version": "66.6.7",
5
5
  "description": "Web Fonts support for Uno CSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "ofetch": "^1.5.1",
45
- "@unocss/core": "66.6.6-beta.1"
45
+ "@unocss/core": "66.6.7"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsdown --config-loader unrun",