@unocss/preset-web-fonts 66.2.0 → 66.2.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +13 -6
- package/dist/local.d.mts +1 -1
- package/dist/local.d.ts +1 -1
- package/dist/shared/{preset-web-fonts.Du87QQvO.d.mts → preset-web-fonts.B42lyDww.d.mts} +35 -1
- package/dist/shared/{preset-web-fonts.Du87QQvO.d.ts → preset-web-fonts.B42lyDww.d.ts} +35 -1
- package/package.json +2 -2
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.B42lyDww.mjs';
|
|
3
|
+
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.B42lyDww.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.B42lyDww.js';
|
|
3
|
+
export { A as Axes, c as WebFontProcessor } from './shared/preset-web-fonts.B42lyDww.js';
|
|
4
4
|
|
|
5
5
|
declare function normalizedFontMeta(meta: WebFontMeta | string, defaultProvider: WebFontsProviders): ResolvedWebFontMeta;
|
|
6
6
|
|
package/dist/index.mjs
CHANGED
|
@@ -82,8 +82,9 @@ function createFontSourceProvider(name, host) {
|
|
|
82
82
|
throw new Error(`Failed to fetch font: ${font.name}`);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const {
|
|
86
|
-
|
|
85
|
+
const { weights } = metadata;
|
|
86
|
+
const subsets = metadata.subsets.filter((subset) => font.subsets ? font.subsets.includes(subset) : true);
|
|
87
|
+
if (metadata.variable && !font.preferStatic) {
|
|
87
88
|
let variableData = variablesMap.get(id);
|
|
88
89
|
const url = `https://api.fontsource.org/v1/variable/${id}`;
|
|
89
90
|
try {
|
|
@@ -244,10 +245,11 @@ function createWebFontPreset(fetcher) {
|
|
|
244
245
|
provider: defaultProvider = "google",
|
|
245
246
|
extendTheme = true,
|
|
246
247
|
inlineImports = true,
|
|
247
|
-
themeKey = "fontFamily",
|
|
248
248
|
customFetch = fetcher,
|
|
249
249
|
timeouts = {}
|
|
250
250
|
} = options;
|
|
251
|
+
const fontLayer = "fonts";
|
|
252
|
+
const layerName = inlineImports ? fontLayer : LAYER_IMPORTS;
|
|
251
253
|
const processors = toArray(options.processors || []);
|
|
252
254
|
const fontObject = Object.fromEntries(
|
|
253
255
|
Object.entries(options.fonts || {}).map(([name, meta]) => [name, toArray(meta).map((m) => normalizedFontMeta(m, defaultProvider))])
|
|
@@ -330,12 +332,17 @@ function createWebFontPreset(fetcher) {
|
|
|
330
332
|
css = await processor.transformCSS?.(css) || css;
|
|
331
333
|
return css;
|
|
332
334
|
},
|
|
333
|
-
layer:
|
|
335
|
+
layer: layerName
|
|
334
336
|
}
|
|
335
|
-
]
|
|
337
|
+
],
|
|
338
|
+
layers: {
|
|
339
|
+
[fontLayer]: -200
|
|
340
|
+
}
|
|
336
341
|
};
|
|
337
342
|
if (extendTheme) {
|
|
338
|
-
preset.extendTheme = (theme) => {
|
|
343
|
+
preset.extendTheme = (theme, config) => {
|
|
344
|
+
const hasWind4 = config.presets.some((p) => p.name === "@unocss/preset-wind4");
|
|
345
|
+
const themeKey = options.themeKey ?? (hasWind4 ? "font" : "fontFamily");
|
|
339
346
|
if (!theme[themeKey])
|
|
340
347
|
theme[themeKey] = {};
|
|
341
348
|
const obj = Object.fromEntries(
|
package/dist/local.d.mts
CHANGED
package/dist/local.d.ts
CHANGED
|
@@ -2,10 +2,40 @@ import { Awaitable, Arrayable } from '@unocss/core';
|
|
|
2
2
|
|
|
3
3
|
type WebFontsProviders = 'google' | 'bunny' | 'fontshare' | 'fontsource' | 'coollabs' | 'none' | Provider;
|
|
4
4
|
interface WebFontMeta {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the font family
|
|
7
|
+
* @example 'Fira Code'
|
|
8
|
+
*/
|
|
5
9
|
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Font weight(s) to include, and respect the weight order
|
|
12
|
+
* @example [400, 700]
|
|
13
|
+
*/
|
|
6
14
|
weights?: (string | number)[];
|
|
15
|
+
/**
|
|
16
|
+
* Use italic style
|
|
17
|
+
*/
|
|
7
18
|
italic?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Variable font settings
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* variable: {
|
|
24
|
+
* wght: { default: '400', min: '100', max: '900', step: '100' },
|
|
25
|
+
* wdth: { default: '100', min: '50', max: '200', step: '10' },
|
|
26
|
+
* slnt: { default: '0', min: '-20', max: '20', step: '1' },
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
8
29
|
variable?: Record<string, Partial<Axes>>;
|
|
30
|
+
/**
|
|
31
|
+
* The font subsets to include
|
|
32
|
+
* @example ['latin', 'cyrillic']
|
|
33
|
+
*/
|
|
34
|
+
subsets?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Prefer static font files over variable
|
|
37
|
+
*/
|
|
38
|
+
preferStatic?: boolean;
|
|
9
39
|
/**
|
|
10
40
|
* Override the provider
|
|
11
41
|
* @default <matches root config>
|
|
@@ -37,7 +67,11 @@ interface WebFontsOptions {
|
|
|
37
67
|
/**
|
|
38
68
|
* Key for the theme object
|
|
39
69
|
*
|
|
40
|
-
*
|
|
70
|
+
* Automatically detect the key based on the preset used
|
|
71
|
+
*
|
|
72
|
+
* @default
|
|
73
|
+
* `preset-wind3` -> 'fontFamily'
|
|
74
|
+
* `preset-wind4` -> 'font'
|
|
41
75
|
*/
|
|
42
76
|
themeKey?: string;
|
|
43
77
|
/**
|
|
@@ -2,10 +2,40 @@ import { Awaitable, Arrayable } from '@unocss/core';
|
|
|
2
2
|
|
|
3
3
|
type WebFontsProviders = 'google' | 'bunny' | 'fontshare' | 'fontsource' | 'coollabs' | 'none' | Provider;
|
|
4
4
|
interface WebFontMeta {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the font family
|
|
7
|
+
* @example 'Fira Code'
|
|
8
|
+
*/
|
|
5
9
|
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Font weight(s) to include, and respect the weight order
|
|
12
|
+
* @example [400, 700]
|
|
13
|
+
*/
|
|
6
14
|
weights?: (string | number)[];
|
|
15
|
+
/**
|
|
16
|
+
* Use italic style
|
|
17
|
+
*/
|
|
7
18
|
italic?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Variable font settings
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* variable: {
|
|
24
|
+
* wght: { default: '400', min: '100', max: '900', step: '100' },
|
|
25
|
+
* wdth: { default: '100', min: '50', max: '200', step: '10' },
|
|
26
|
+
* slnt: { default: '0', min: '-20', max: '20', step: '1' },
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
8
29
|
variable?: Record<string, Partial<Axes>>;
|
|
30
|
+
/**
|
|
31
|
+
* The font subsets to include
|
|
32
|
+
* @example ['latin', 'cyrillic']
|
|
33
|
+
*/
|
|
34
|
+
subsets?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Prefer static font files over variable
|
|
37
|
+
*/
|
|
38
|
+
preferStatic?: boolean;
|
|
9
39
|
/**
|
|
10
40
|
* Override the provider
|
|
11
41
|
* @default <matches root config>
|
|
@@ -37,7 +67,11 @@ interface WebFontsOptions {
|
|
|
37
67
|
/**
|
|
38
68
|
* Key for the theme object
|
|
39
69
|
*
|
|
40
|
-
*
|
|
70
|
+
* Automatically detect the key based on the preset used
|
|
71
|
+
*
|
|
72
|
+
* @default
|
|
73
|
+
* `preset-wind3` -> 'fontFamily'
|
|
74
|
+
* `preset-wind4` -> 'font'
|
|
41
75
|
*/
|
|
42
76
|
themeKey?: string;
|
|
43
77
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-web-fonts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.2.
|
|
4
|
+
"version": "66.2.2",
|
|
5
5
|
"description": "Web Fonts support for Uno CSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"ofetch": "^1.4.1",
|
|
53
|
-
"@unocss/core": "66.2.
|
|
53
|
+
"@unocss/core": "66.2.2"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "unbuild",
|