@unocss/preset-web-fonts 0.53.0 → 0.53.3
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.cjs +9 -2
- package/dist/index.mjs +9 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -8,10 +8,15 @@ function createGoogleCompatibleProvider(name, host) {
|
|
|
8
8
|
return {
|
|
9
9
|
name,
|
|
10
10
|
getImportUrl(fonts) {
|
|
11
|
+
const sort = (weights) => {
|
|
12
|
+
const firstW = weights.map((w) => w[0]);
|
|
13
|
+
const lastW = weights.map((w) => w[1]);
|
|
14
|
+
return `${firstW.join(";")};${lastW.join(";")}`;
|
|
15
|
+
};
|
|
11
16
|
const strings = fonts.map((i) => {
|
|
12
17
|
let name2 = i.name.replace(/\s+/g, "+");
|
|
13
18
|
if (i.weights?.length) {
|
|
14
|
-
name2 += i.italic ? `:ital,wght@${i.weights.
|
|
19
|
+
name2 += i.italic ? `:ital,wght@${sort(i.weights.map((w) => [`0,${w}`, `1,${w}`]))}` : `:wght@${i.weights.join(";")}`;
|
|
15
20
|
}
|
|
16
21
|
return `family=${name2}`;
|
|
17
22
|
}).join("&");
|
|
@@ -65,12 +70,14 @@ function resolveProvider(provider) {
|
|
|
65
70
|
function normalizedFontMeta(meta, defaultProvider) {
|
|
66
71
|
if (typeof meta !== "string") {
|
|
67
72
|
meta.provider = resolveProvider(meta.provider || defaultProvider);
|
|
73
|
+
if (meta.weights)
|
|
74
|
+
meta.weights = [...new Set(meta.weights.map(Number).sort((a, b) => a - b))];
|
|
68
75
|
return meta;
|
|
69
76
|
}
|
|
70
77
|
const [name, weights = ""] = meta.split(":");
|
|
71
78
|
return {
|
|
72
79
|
name,
|
|
73
|
-
weights: weights.split(/[,;]\s*/).filter(Boolean),
|
|
80
|
+
weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).map(Number).sort((a, b) => a - b))],
|
|
74
81
|
provider: resolveProvider(defaultProvider)
|
|
75
82
|
};
|
|
76
83
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,15 @@ function createGoogleCompatibleProvider(name, host) {
|
|
|
4
4
|
return {
|
|
5
5
|
name,
|
|
6
6
|
getImportUrl(fonts) {
|
|
7
|
+
const sort = (weights) => {
|
|
8
|
+
const firstW = weights.map((w) => w[0]);
|
|
9
|
+
const lastW = weights.map((w) => w[1]);
|
|
10
|
+
return `${firstW.join(";")};${lastW.join(";")}`;
|
|
11
|
+
};
|
|
7
12
|
const strings = fonts.map((i) => {
|
|
8
13
|
let name2 = i.name.replace(/\s+/g, "+");
|
|
9
14
|
if (i.weights?.length) {
|
|
10
|
-
name2 += i.italic ? `:ital,wght@${i.weights.
|
|
15
|
+
name2 += i.italic ? `:ital,wght@${sort(i.weights.map((w) => [`0,${w}`, `1,${w}`]))}` : `:wght@${i.weights.join(";")}`;
|
|
11
16
|
}
|
|
12
17
|
return `family=${name2}`;
|
|
13
18
|
}).join("&");
|
|
@@ -61,12 +66,14 @@ function resolveProvider(provider) {
|
|
|
61
66
|
function normalizedFontMeta(meta, defaultProvider) {
|
|
62
67
|
if (typeof meta !== "string") {
|
|
63
68
|
meta.provider = resolveProvider(meta.provider || defaultProvider);
|
|
69
|
+
if (meta.weights)
|
|
70
|
+
meta.weights = [...new Set(meta.weights.map(Number).sort((a, b) => a - b))];
|
|
64
71
|
return meta;
|
|
65
72
|
}
|
|
66
73
|
const [name, weights = ""] = meta.split(":");
|
|
67
74
|
return {
|
|
68
75
|
name,
|
|
69
|
-
weights: weights.split(/[,;]\s*/).filter(Boolean),
|
|
76
|
+
weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).map(Number).sort((a, b) => a - b))],
|
|
70
77
|
provider: resolveProvider(defaultProvider)
|
|
71
78
|
};
|
|
72
79
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-web-fonts",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.3",
|
|
4
4
|
"description": "Web Fonts support for Uno CSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"*.css"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"ofetch": "^1.
|
|
41
|
-
"@unocss/core": "0.53.
|
|
40
|
+
"ofetch": "^1.1.1",
|
|
41
|
+
"@unocss/core": "0.53.3"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild",
|