@unocss/preset-web-fonts 66.3.2 → 66.4.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.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/local.d.mts +3 -2
- package/dist/local.d.ts +3 -2
- package/dist/shared/{preset-web-fonts.B42lyDww.d.mts → preset-web-fonts.CZc_IGwW.d.mts} +1 -1
- package/dist/shared/{preset-web-fonts.B42lyDww.d.ts → preset-web-fonts.CZc_IGwW.d.ts} +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _unocss_core from '@unocss/core';
|
|
2
|
-
import { W as WebFontMeta, a as WebFontsProviders, R as ResolvedWebFontMeta, P as Provider, b as WebFontsOptions } from './shared/preset-web-fonts.
|
|
3
|
-
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.
|
|
2
|
+
import { W as WebFontMeta, a as WebFontsProviders, R as ResolvedWebFontMeta, P as Provider, b as WebFontsOptions } from './shared/preset-web-fonts.CZc_IGwW.mjs';
|
|
3
|
+
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.CZc_IGwW.mjs';
|
|
4
4
|
|
|
5
5
|
declare function normalizedFontMeta(meta: WebFontMeta | string, defaultProvider: WebFontsProviders): ResolvedWebFontMeta;
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _unocss_core from '@unocss/core';
|
|
2
|
-
import { W as WebFontMeta, a as WebFontsProviders, R as ResolvedWebFontMeta, P as Provider, b as WebFontsOptions } from './shared/preset-web-fonts.
|
|
3
|
-
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.
|
|
2
|
+
import { W as WebFontMeta, a as WebFontsProviders, R as ResolvedWebFontMeta, P as Provider, b as WebFontsOptions } from './shared/preset-web-fonts.CZc_IGwW.js';
|
|
3
|
+
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.CZc_IGwW.js';
|
|
4
4
|
|
|
5
5
|
declare function normalizedFontMeta(meta: WebFontMeta | string, defaultProvider: WebFontsProviders): ResolvedWebFontMeta;
|
|
6
6
|
|
package/dist/index.mjs
CHANGED
|
@@ -68,7 +68,7 @@ function createFontSourceProvider(name, host) {
|
|
|
68
68
|
const variablesMap = /* @__PURE__ */ new Map();
|
|
69
69
|
return {
|
|
70
70
|
name,
|
|
71
|
-
async getPreflight(fonts) {
|
|
71
|
+
async getPreflight(fonts, fetcher) {
|
|
72
72
|
const list = await Promise.all(fonts.map(async (font) => {
|
|
73
73
|
const css = [];
|
|
74
74
|
const id = font.name.toLowerCase().replace(/\s+/g, "-");
|
|
@@ -76,7 +76,7 @@ function createFontSourceProvider(name, host) {
|
|
|
76
76
|
if (!metadata) {
|
|
77
77
|
const url = `https://api.fontsource.org/v1/fonts/${id}`;
|
|
78
78
|
try {
|
|
79
|
-
metadata = await (
|
|
79
|
+
metadata = await fetcher(url);
|
|
80
80
|
fontsMap.set(id, metadata);
|
|
81
81
|
} catch {
|
|
82
82
|
throw new Error(`Failed to fetch font: ${font.name}`);
|
|
@@ -89,7 +89,7 @@ function createFontSourceProvider(name, host) {
|
|
|
89
89
|
let variableData = variablesMap.get(id);
|
|
90
90
|
const url = `https://api.fontsource.org/v1/variable/${id}`;
|
|
91
91
|
try {
|
|
92
|
-
variableData = await (
|
|
92
|
+
variableData = await fetcher(url);
|
|
93
93
|
variablesMap.set(id, variableData);
|
|
94
94
|
} catch {
|
|
95
95
|
throw new Error(`Failed to fetch font variable: ${font.name}`);
|
|
@@ -329,7 +329,7 @@ function createWebFontPreset(fetcher) {
|
|
|
329
329
|
if (url)
|
|
330
330
|
preflights.push(await importUrl(url));
|
|
331
331
|
}
|
|
332
|
-
preflights.push(await provider.getPreflight?.(fontsForProvider));
|
|
332
|
+
preflights.push(await provider.getPreflight?.(fontsForProvider, fetchWithTimeout));
|
|
333
333
|
}
|
|
334
334
|
const css = preflights.filter(Boolean).join("\n");
|
|
335
335
|
return css;
|
package/dist/local.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WebFontProcessor } from './shared/preset-web-fonts.
|
|
1
|
+
import { c as WebFontProcessor } from './shared/preset-web-fonts.CZc_IGwW.mjs';
|
|
2
2
|
import '@unocss/core';
|
|
3
3
|
|
|
4
4
|
interface LocalFontProcessorOptions {
|
|
@@ -29,4 +29,5 @@ interface LocalFontProcessorOptions {
|
|
|
29
29
|
}
|
|
30
30
|
declare function createLocalFontProcessor(options?: LocalFontProcessorOptions): WebFontProcessor;
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { createLocalFontProcessor };
|
|
33
|
+
export type { LocalFontProcessorOptions };
|
package/dist/local.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WebFontProcessor } from './shared/preset-web-fonts.
|
|
1
|
+
import { c as WebFontProcessor } from './shared/preset-web-fonts.CZc_IGwW.js';
|
|
2
2
|
import '@unocss/core';
|
|
3
3
|
|
|
4
4
|
interface LocalFontProcessorOptions {
|
|
@@ -29,4 +29,5 @@ interface LocalFontProcessorOptions {
|
|
|
29
29
|
}
|
|
30
30
|
declare function createLocalFontProcessor(options?: LocalFontProcessorOptions): WebFontProcessor;
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { createLocalFontProcessor };
|
|
33
|
+
export type { LocalFontProcessorOptions };
|
|
@@ -110,7 +110,7 @@ interface WebFontsOptions {
|
|
|
110
110
|
}
|
|
111
111
|
interface Provider {
|
|
112
112
|
name: WebFontsProviders;
|
|
113
|
-
getPreflight?: (fonts: WebFontMeta[]) => Awaitable<string | undefined>;
|
|
113
|
+
getPreflight?: (fonts: WebFontMeta[], fetcher: (url: string) => Promise<any>) => Awaitable<string | undefined>;
|
|
114
114
|
getImportUrl?: (fonts: WebFontMeta[]) => string | undefined;
|
|
115
115
|
getFontName?: (font: WebFontMeta) => string;
|
|
116
116
|
}
|
|
@@ -110,7 +110,7 @@ interface WebFontsOptions {
|
|
|
110
110
|
}
|
|
111
111
|
interface Provider {
|
|
112
112
|
name: WebFontsProviders;
|
|
113
|
-
getPreflight?: (fonts: WebFontMeta[]) => Awaitable<string | undefined>;
|
|
113
|
+
getPreflight?: (fonts: WebFontMeta[], fetcher: (url: string) => Promise<any>) => Awaitable<string | undefined>;
|
|
114
114
|
getImportUrl?: (fonts: WebFontMeta[]) => string | undefined;
|
|
115
115
|
getFontName?: (font: WebFontMeta) => string;
|
|
116
116
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-web-fonts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.
|
|
4
|
+
"version": "66.4.0",
|
|
5
5
|
"description": "Web Fonts support for Uno CSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"homepage": "https://unocss.dev",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/unocss/unocss",
|
|
12
|
+
"url": "git+https://github.com/unocss/unocss.git",
|
|
13
13
|
"directory": "packages-presets/preset-web-fonts"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"ofetch": "^1.4.1",
|
|
53
|
-
"@unocss/core": "66.
|
|
53
|
+
"@unocss/core": "66.4.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "unbuild",
|