astro 5.16.4 → 5.16.6
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/assets/endpoint/dev.js +7 -6
- package/dist/assets/fonts/config.d.ts +26 -197
- package/dist/assets/fonts/config.js +36 -135
- package/dist/assets/fonts/providers/index.d.ts +6 -24
- package/dist/assets/fonts/types.d.ts +136 -6
- package/dist/assets/services/noop.js +10 -5
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +55 -51
- package/dist/assets/types.d.ts +2 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/loaders/glob.js +5 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +4 -14
- package/dist/core/config/schemas/base.d.ts +95 -103
- package/dist/core/config/schemas/base.js +3 -1
- package/dist/core/config/schemas/relative.d.ts +134 -142
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/env/schema.d.ts +10 -10
- package/dist/types/public/extendables.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { root } from "astro:config/server";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { isParentDirectory } from "@astrojs/internal-helpers/path";
|
|
6
5
|
import { handleImageRequest, loadRemoteImage } from "./shared.js";
|
|
7
|
-
function replaceFileSystemReferences(src) {
|
|
8
|
-
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
9
|
-
}
|
|
10
6
|
async function loadLocalImage(src, url) {
|
|
11
7
|
if (src.startsWith("/@fs/")) {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(new URL(src, url));
|
|
10
|
+
if (!res.ok) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
return Buffer.from(await res.arrayBuffer());
|
|
14
|
+
} catch {
|
|
14
15
|
return void 0;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,99 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const weightSchema: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
2
3
|
export declare const styleSchema: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
3
|
-
export declare const
|
|
4
|
-
/**
|
|
5
|
-
* URL, path relative to the root or package import.
|
|
6
|
-
*/
|
|
7
|
-
entrypoint: z.ZodUnion<[z.ZodString, z.ZodType<URL, z.ZodTypeDef, URL>]>;
|
|
8
|
-
/**
|
|
9
|
-
* Optional serializable object passed to the unifont provider.
|
|
10
|
-
*/
|
|
11
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
12
|
-
}, "strict", z.ZodTypeAny, {
|
|
13
|
-
entrypoint: string | URL;
|
|
14
|
-
config?: Record<string, any> | undefined;
|
|
15
|
-
}, {
|
|
16
|
-
entrypoint: string | URL;
|
|
17
|
-
config?: Record<string, any> | undefined;
|
|
18
|
-
}>;
|
|
4
|
+
export declare const displaySchema: z.ZodEnum<["auto", "block", "swap", "fallback", "optional"]>;
|
|
19
5
|
export declare const localFontFamilySchema: z.ZodObject<{
|
|
20
|
-
/**
|
|
21
|
-
* The font family name, as identified by your font provider.
|
|
22
|
-
*/
|
|
23
|
-
name: z.ZodString;
|
|
24
|
-
/**
|
|
25
|
-
* A valid [ident](https://developer.mozilla.org/en-US/docs/Web/CSS/ident) in the form of a CSS variable (i.e. starting with `--`).
|
|
26
|
-
*/
|
|
27
|
-
cssVariable: z.ZodString;
|
|
28
|
-
} & {
|
|
29
|
-
/**
|
|
30
|
-
* @default `["sans-serif"]`
|
|
31
|
-
*
|
|
32
|
-
* An array of fonts to use when your chosen font is unavailable, or loading. Fallback fonts will be chosen in the order listed. The first available font will be used:
|
|
33
|
-
*
|
|
34
|
-
* ```js
|
|
35
|
-
* fallbacks: ["CustomFont", "serif"]
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* To disable fallback fonts completely, configure an empty array:
|
|
39
|
-
*
|
|
40
|
-
* ```js
|
|
41
|
-
* fallbacks: []
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
* If the last font in the `fallbacks` array is a [generic family name](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name), Astro will attempt to generate [optimized fallbacks](https://developer.chrome.com/blog/font-fallbacks) using font metrics will be generated. To disable this optimization, set `optimizedFallbacks` to false.
|
|
46
|
-
*/
|
|
47
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
48
|
-
/**
|
|
49
|
-
* @default `true`
|
|
50
|
-
*
|
|
51
|
-
* Whether or not to enable optimized fallback generation. You may disable this default optimization to have full control over `fallbacks`.
|
|
52
|
-
*/
|
|
53
|
-
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
} & {
|
|
55
|
-
/**
|
|
56
|
-
* The source of your font files. Set to `"local"` to use local font files.
|
|
57
|
-
*/
|
|
58
6
|
provider: z.ZodLiteral<"local">;
|
|
59
|
-
/**
|
|
60
|
-
* Each variant represents a [`@font-face` declaration](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/).
|
|
61
|
-
*/
|
|
62
7
|
variants: z.ZodArray<z.ZodObject<{
|
|
63
|
-
/**
|
|
64
|
-
* A [font weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight). If the associated font is a [variable font](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide), you can specify a range of weights:
|
|
65
|
-
*
|
|
66
|
-
* ```js
|
|
67
|
-
* weight: "100 900"
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
weight: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
71
|
-
/**
|
|
72
|
-
* A [font style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style).
|
|
73
|
-
*/
|
|
74
|
-
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
75
|
-
/**
|
|
76
|
-
* @default `"swap"`
|
|
77
|
-
*
|
|
78
|
-
* A [font display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display).
|
|
79
|
-
*/
|
|
80
|
-
display: z.ZodOptional<z.ZodEnum<["auto", "block", "swap", "fallback", "optional"]>>;
|
|
81
|
-
/**
|
|
82
|
-
* A [font stretch](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch).
|
|
83
|
-
*/
|
|
84
|
-
stretch: z.ZodOptional<z.ZodString>;
|
|
85
|
-
/**
|
|
86
|
-
* Font [feature settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings).
|
|
87
|
-
*/
|
|
88
|
-
featureSettings: z.ZodOptional<z.ZodString>;
|
|
89
|
-
/**
|
|
90
|
-
* Font [variation settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-variation-settings).
|
|
91
|
-
*/
|
|
92
|
-
variationSettings: z.ZodOptional<z.ZodString>;
|
|
93
|
-
} & {
|
|
94
|
-
/**
|
|
95
|
-
* Font [sources](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src). It can be a path relative to the root, a package import or a URL. URLs are particularly useful if you inject local fonts through an integration.
|
|
96
|
-
*/
|
|
97
8
|
src: z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<URL, z.ZodTypeDef, URL>]>, z.ZodObject<{
|
|
98
9
|
url: z.ZodUnion<[z.ZodString, z.ZodType<URL, z.ZodTypeDef, URL>]>;
|
|
99
10
|
tech: z.ZodOptional<z.ZodString>;
|
|
@@ -104,9 +15,12 @@ export declare const localFontFamilySchema: z.ZodObject<{
|
|
|
104
15
|
url: string | URL;
|
|
105
16
|
tech?: string | undefined;
|
|
106
17
|
}>]>, "atleastone">;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
18
|
+
weight: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
19
|
+
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
20
|
+
display: z.ZodOptional<z.ZodEnum<["auto", "block", "swap", "fallback", "optional"]>>;
|
|
21
|
+
stretch: z.ZodOptional<z.ZodString>;
|
|
22
|
+
featureSettings: z.ZodOptional<z.ZodString>;
|
|
23
|
+
variationSettings: z.ZodOptional<z.ZodString>;
|
|
110
24
|
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
111
25
|
}, "strict", z.ZodTypeAny, {
|
|
112
26
|
src: [string | URL | {
|
|
@@ -139,10 +53,14 @@ export declare const localFontFamilySchema: z.ZodObject<{
|
|
|
139
53
|
variationSettings?: string | undefined;
|
|
140
54
|
unicodeRange?: [string, ...string[]] | undefined;
|
|
141
55
|
}>, "atleastone">;
|
|
56
|
+
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
57
|
+
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
cssVariable: z.ZodString;
|
|
142
60
|
}, "strict", z.ZodTypeAny, {
|
|
61
|
+
provider: "local";
|
|
143
62
|
name: string;
|
|
144
63
|
cssVariable: string;
|
|
145
|
-
provider: "local";
|
|
146
64
|
variants: [{
|
|
147
65
|
src: [string | URL | {
|
|
148
66
|
url: string | URL;
|
|
@@ -177,9 +95,9 @@ export declare const localFontFamilySchema: z.ZodObject<{
|
|
|
177
95
|
fallbacks?: string[] | undefined;
|
|
178
96
|
optimizedFallbacks?: boolean | undefined;
|
|
179
97
|
}, {
|
|
98
|
+
provider: "local";
|
|
180
99
|
name: string;
|
|
181
100
|
cssVariable: string;
|
|
182
|
-
provider: "local";
|
|
183
101
|
variants: [{
|
|
184
102
|
src: [string | URL | {
|
|
185
103
|
url: string | URL;
|
|
@@ -215,83 +133,8 @@ export declare const localFontFamilySchema: z.ZodObject<{
|
|
|
215
133
|
optimizedFallbacks?: boolean | undefined;
|
|
216
134
|
}>;
|
|
217
135
|
export declare const remoteFontFamilySchema: z.ZodObject<{
|
|
218
|
-
/**
|
|
219
|
-
* The font family name, as identified by your font provider.
|
|
220
|
-
*/
|
|
221
|
-
name: z.ZodString;
|
|
222
|
-
/**
|
|
223
|
-
* A valid [ident](https://developer.mozilla.org/en-US/docs/Web/CSS/ident) in the form of a CSS variable (i.e. starting with `--`).
|
|
224
|
-
*/
|
|
225
|
-
cssVariable: z.ZodString;
|
|
226
|
-
} & Omit<{
|
|
227
|
-
/**
|
|
228
|
-
* A [font weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight). If the associated font is a [variable font](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide), you can specify a range of weights:
|
|
229
|
-
*
|
|
230
|
-
* ```js
|
|
231
|
-
* weight: "100 900"
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
weight: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
235
|
-
/**
|
|
236
|
-
* A [font style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style).
|
|
237
|
-
*/
|
|
238
|
-
style: z.ZodOptional<z.ZodEnum<["normal", "italic", "oblique"]>>;
|
|
239
|
-
/**
|
|
240
|
-
* @default `"swap"`
|
|
241
|
-
*
|
|
242
|
-
* A [font display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display).
|
|
243
|
-
*/
|
|
244
|
-
display: z.ZodOptional<z.ZodEnum<["auto", "block", "swap", "fallback", "optional"]>>;
|
|
245
|
-
/**
|
|
246
|
-
* A [font stretch](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch).
|
|
247
|
-
*/
|
|
248
|
-
stretch: z.ZodOptional<z.ZodString>;
|
|
249
|
-
/**
|
|
250
|
-
* Font [feature settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings).
|
|
251
|
-
*/
|
|
252
|
-
featureSettings: z.ZodOptional<z.ZodString>;
|
|
253
|
-
/**
|
|
254
|
-
* Font [variation settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-variation-settings).
|
|
255
|
-
*/
|
|
256
|
-
variationSettings: z.ZodOptional<z.ZodString>;
|
|
257
|
-
}, "weight" | "style"> & {
|
|
258
|
-
/**
|
|
259
|
-
* @default `["sans-serif"]`
|
|
260
|
-
*
|
|
261
|
-
* An array of fonts to use when your chosen font is unavailable, or loading. Fallback fonts will be chosen in the order listed. The first available font will be used:
|
|
262
|
-
*
|
|
263
|
-
* ```js
|
|
264
|
-
* fallbacks: ["CustomFont", "serif"]
|
|
265
|
-
* ```
|
|
266
|
-
*
|
|
267
|
-
* To disable fallback fonts completely, configure an empty array:
|
|
268
|
-
*
|
|
269
|
-
* ```js
|
|
270
|
-
* fallbacks: []
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
|
|
274
|
-
* If the last font in the `fallbacks` array is a [generic family name](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name), Astro will attempt to generate [optimized fallbacks](https://developer.chrome.com/blog/font-fallbacks) using font metrics will be generated. To disable this optimization, set `optimizedFallbacks` to false.
|
|
275
|
-
*/
|
|
276
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
277
|
-
/**
|
|
278
|
-
* @default `true`
|
|
279
|
-
*
|
|
280
|
-
* Whether or not to enable optimized fallback generation. You may disable this default optimization to have full control over `fallbacks`.
|
|
281
|
-
*/
|
|
282
|
-
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
283
|
-
} & {
|
|
284
|
-
/**
|
|
285
|
-
* The source of your font files. You can use a built-in provider or write your own custom provider.
|
|
286
|
-
*/
|
|
287
136
|
provider: z.ZodObject<{
|
|
288
|
-
/**
|
|
289
|
-
* URL, path relative to the root or package import.
|
|
290
|
-
*/
|
|
291
137
|
entrypoint: z.ZodUnion<[z.ZodString, z.ZodType<URL, z.ZodTypeDef, URL>]>;
|
|
292
|
-
/**
|
|
293
|
-
* Optional serializable object passed to the unifont provider.
|
|
294
|
-
*/
|
|
295
138
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
296
139
|
}, "strict", z.ZodTypeAny, {
|
|
297
140
|
entrypoint: string | URL;
|
|
@@ -300,39 +143,25 @@ export declare const remoteFontFamilySchema: z.ZodObject<{
|
|
|
300
143
|
entrypoint: string | URL;
|
|
301
144
|
config?: Record<string, any> | undefined;
|
|
302
145
|
}>;
|
|
303
|
-
/**
|
|
304
|
-
* @default `[400]`
|
|
305
|
-
*
|
|
306
|
-
* An array of [font weights](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight). If the associated font is a [variable font](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide), you can specify a range of weights:
|
|
307
|
-
*
|
|
308
|
-
* ```js
|
|
309
|
-
* weight: "100 900"
|
|
310
|
-
* ```
|
|
311
|
-
*/
|
|
312
146
|
weights: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "atleastone">>;
|
|
313
|
-
/**
|
|
314
|
-
* @default `["normal", "italic"]`
|
|
315
|
-
*
|
|
316
|
-
* An array of [font styles](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style).
|
|
317
|
-
*/
|
|
318
147
|
styles: z.ZodOptional<z.ZodArray<z.ZodEnum<["normal", "italic", "oblique"]>, "atleastone">>;
|
|
319
|
-
/**
|
|
320
|
-
* @default `["latin"]`
|
|
321
|
-
*
|
|
322
|
-
* An array of [font subsets](https://knaap.dev/posts/font-subsetting/):
|
|
323
|
-
*/
|
|
324
148
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
149
|
+
display: z.ZodOptional<z.ZodEnum<["auto", "block", "swap", "fallback", "optional"]>>;
|
|
150
|
+
stretch: z.ZodOptional<z.ZodString>;
|
|
151
|
+
featureSettings: z.ZodOptional<z.ZodString>;
|
|
152
|
+
variationSettings: z.ZodOptional<z.ZodString>;
|
|
328
153
|
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
154
|
+
fallbacks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
155
|
+
optimizedFallbacks: z.ZodOptional<z.ZodBoolean>;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
cssVariable: z.ZodString;
|
|
329
158
|
}, "strict", z.ZodTypeAny, {
|
|
330
|
-
name: string;
|
|
331
|
-
cssVariable: string;
|
|
332
159
|
provider: {
|
|
333
160
|
entrypoint: string | URL;
|
|
334
161
|
config?: Record<string, any> | undefined;
|
|
335
162
|
};
|
|
163
|
+
name: string;
|
|
164
|
+
cssVariable: string;
|
|
336
165
|
weights?: [string | number, ...(string | number)[]] | undefined;
|
|
337
166
|
styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
|
|
338
167
|
subsets?: [string, ...string[]] | undefined;
|
|
@@ -344,12 +173,12 @@ export declare const remoteFontFamilySchema: z.ZodObject<{
|
|
|
344
173
|
variationSettings?: string | undefined;
|
|
345
174
|
unicodeRange?: [string, ...string[]] | undefined;
|
|
346
175
|
}, {
|
|
347
|
-
name: string;
|
|
348
|
-
cssVariable: string;
|
|
349
176
|
provider: {
|
|
350
177
|
entrypoint: string | URL;
|
|
351
178
|
config?: Record<string, any> | undefined;
|
|
352
179
|
};
|
|
180
|
+
name: string;
|
|
181
|
+
cssVariable: string;
|
|
353
182
|
weights?: [string | number, ...(string | number)[]] | undefined;
|
|
354
183
|
styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
|
|
355
184
|
subsets?: [string, ...string[]] | undefined;
|
|
@@ -2,160 +2,61 @@ import { z } from "zod";
|
|
|
2
2
|
import { LOCAL_PROVIDER_NAME } from "./constants.js";
|
|
3
3
|
const weightSchema = z.union([z.string(), z.number()]);
|
|
4
4
|
const styleSchema = z.enum(["normal", "italic", "oblique"]);
|
|
5
|
-
const
|
|
5
|
+
const displaySchema = z.enum(["auto", "block", "swap", "fallback", "optional"]);
|
|
6
6
|
const familyPropertiesSchema = z.object({
|
|
7
|
-
/**
|
|
8
|
-
* A [font weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight). If the associated font is a [variable font](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide), you can specify a range of weights:
|
|
9
|
-
*
|
|
10
|
-
* ```js
|
|
11
|
-
* weight: "100 900"
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
7
|
weight: weightSchema.optional(),
|
|
15
|
-
/**
|
|
16
|
-
* A [font style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style).
|
|
17
|
-
*/
|
|
18
8
|
style: styleSchema.optional(),
|
|
19
|
-
|
|
20
|
-
* @default `"swap"`
|
|
21
|
-
*
|
|
22
|
-
* A [font display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display).
|
|
23
|
-
*/
|
|
24
|
-
display: z.enum(["auto", "block", "swap", "fallback", "optional"]).optional(),
|
|
25
|
-
/**
|
|
26
|
-
* A [font stretch](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch).
|
|
27
|
-
*/
|
|
9
|
+
display: displaySchema.optional(),
|
|
28
10
|
stretch: z.string().optional(),
|
|
29
|
-
/**
|
|
30
|
-
* Font [feature settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings).
|
|
31
|
-
*/
|
|
32
11
|
featureSettings: z.string().optional(),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
variationSettings: z.string().optional()
|
|
12
|
+
variationSettings: z.string().optional(),
|
|
13
|
+
unicodeRange: z.array(z.string()).nonempty().optional()
|
|
37
14
|
});
|
|
38
15
|
const fallbacksSchema = z.object({
|
|
39
|
-
/**
|
|
40
|
-
* @default `["sans-serif"]`
|
|
41
|
-
*
|
|
42
|
-
* An array of fonts to use when your chosen font is unavailable, or loading. Fallback fonts will be chosen in the order listed. The first available font will be used:
|
|
43
|
-
*
|
|
44
|
-
* ```js
|
|
45
|
-
* fallbacks: ["CustomFont", "serif"]
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* To disable fallback fonts completely, configure an empty array:
|
|
49
|
-
*
|
|
50
|
-
* ```js
|
|
51
|
-
* fallbacks: []
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
* If the last font in the `fallbacks` array is a [generic family name](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name), Astro will attempt to generate [optimized fallbacks](https://developer.chrome.com/blog/font-fallbacks) using font metrics will be generated. To disable this optimization, set `optimizedFallbacks` to false.
|
|
56
|
-
*/
|
|
57
16
|
fallbacks: z.array(z.string()).optional(),
|
|
58
|
-
/**
|
|
59
|
-
* @default `true`
|
|
60
|
-
*
|
|
61
|
-
* Whether or not to enable optimized fallback generation. You may disable this default optimization to have full control over `fallbacks`.
|
|
62
|
-
*/
|
|
63
17
|
optimizedFallbacks: z.boolean().optional()
|
|
64
18
|
});
|
|
65
19
|
const requiredFamilyAttributesSchema = z.object({
|
|
66
|
-
/**
|
|
67
|
-
* The font family name, as identified by your font provider.
|
|
68
|
-
*/
|
|
69
20
|
name: z.string(),
|
|
70
|
-
/**
|
|
71
|
-
* A valid [ident](https://developer.mozilla.org/en-US/docs/Web/CSS/ident) in the form of a CSS variable (i.e. starting with `--`).
|
|
72
|
-
*/
|
|
73
21
|
cssVariable: z.string()
|
|
74
22
|
});
|
|
75
23
|
const entrypointSchema = z.union([z.string(), z.instanceof(URL)]);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
24
|
+
const localFontFamilySchema = z.object({
|
|
25
|
+
...requiredFamilyAttributesSchema.shape,
|
|
26
|
+
...fallbacksSchema.shape,
|
|
27
|
+
provider: z.literal(LOCAL_PROVIDER_NAME),
|
|
28
|
+
variants: z.array(
|
|
29
|
+
z.object({
|
|
30
|
+
...familyPropertiesSchema.shape,
|
|
31
|
+
src: z.array(
|
|
32
|
+
z.union([
|
|
33
|
+
entrypointSchema,
|
|
34
|
+
z.object({ url: entrypointSchema, tech: z.string().optional() }).strict()
|
|
35
|
+
])
|
|
36
|
+
).nonempty()
|
|
37
|
+
// TODO: find a way to support subsets (through fontkit?)
|
|
38
|
+
}).strict()
|
|
39
|
+
).nonempty()
|
|
85
40
|
}).strict();
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
provider: z.literal(LOCAL_PROVIDER_NAME),
|
|
92
|
-
/**
|
|
93
|
-
* Each variant represents a [`@font-face` declaration](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/).
|
|
94
|
-
*/
|
|
95
|
-
variants: z.array(
|
|
96
|
-
familyPropertiesSchema.merge(
|
|
97
|
-
z.object({
|
|
98
|
-
/**
|
|
99
|
-
* Font [sources](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src). It can be a path relative to the root, a package import or a URL. URLs are particularly useful if you inject local fonts through an integration.
|
|
100
|
-
*/
|
|
101
|
-
src: z.array(
|
|
102
|
-
z.union([
|
|
103
|
-
entrypointSchema,
|
|
104
|
-
z.object({ url: entrypointSchema, tech: z.string().optional() }).strict()
|
|
105
|
-
])
|
|
106
|
-
).nonempty(),
|
|
107
|
-
/**
|
|
108
|
-
* A [unicode range](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range).
|
|
109
|
-
*/
|
|
110
|
-
unicodeRange: unicodeRangeSchema.optional()
|
|
111
|
-
// TODO: find a way to support subsets (through fontkit?)
|
|
112
|
-
}).strict()
|
|
113
|
-
)
|
|
114
|
-
).nonempty()
|
|
115
|
-
})
|
|
116
|
-
).strict();
|
|
117
|
-
const remoteFontFamilySchema = requiredFamilyAttributesSchema.merge(
|
|
118
|
-
familyPropertiesSchema.omit({
|
|
41
|
+
const remoteFontFamilySchema = z.object({
|
|
42
|
+
...requiredFamilyAttributesSchema.shape,
|
|
43
|
+
...fallbacksSchema.shape,
|
|
44
|
+
...familyPropertiesSchema.omit({
|
|
119
45
|
weight: true,
|
|
120
46
|
style: true
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
*
|
|
131
|
-
* An array of [font weights](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight). If the associated font is a [variable font](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide), you can specify a range of weights:
|
|
132
|
-
*
|
|
133
|
-
* ```js
|
|
134
|
-
* weight: "100 900"
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
weights: z.array(weightSchema).nonempty().optional(),
|
|
138
|
-
/**
|
|
139
|
-
* @default `["normal", "italic"]`
|
|
140
|
-
*
|
|
141
|
-
* An array of [font styles](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style).
|
|
142
|
-
*/
|
|
143
|
-
styles: z.array(styleSchema).nonempty().optional(),
|
|
144
|
-
/**
|
|
145
|
-
* @default `["latin"]`
|
|
146
|
-
*
|
|
147
|
-
* An array of [font subsets](https://knaap.dev/posts/font-subsetting/):
|
|
148
|
-
*/
|
|
149
|
-
subsets: z.array(z.string()).nonempty().optional(),
|
|
150
|
-
/**
|
|
151
|
-
* A [unicode range](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range).
|
|
152
|
-
*/
|
|
153
|
-
unicodeRange: unicodeRangeSchema.optional()
|
|
154
|
-
})
|
|
155
|
-
).strict();
|
|
47
|
+
}).shape,
|
|
48
|
+
provider: z.object({
|
|
49
|
+
entrypoint: entrypointSchema,
|
|
50
|
+
config: z.record(z.string(), z.any()).optional()
|
|
51
|
+
}).strict(),
|
|
52
|
+
weights: z.array(weightSchema).nonempty().optional(),
|
|
53
|
+
styles: z.array(styleSchema).nonempty().optional(),
|
|
54
|
+
subsets: z.array(z.string()).nonempty().optional()
|
|
55
|
+
}).strict();
|
|
156
56
|
export {
|
|
157
|
-
|
|
57
|
+
displaySchema,
|
|
158
58
|
localFontFamilySchema,
|
|
159
59
|
remoteFontFamilySchema,
|
|
160
|
-
styleSchema
|
|
60
|
+
styleSchema,
|
|
61
|
+
weightSchema
|
|
161
62
|
};
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import type { providers } from 'unifont';
|
|
2
2
|
import type { AstroFontProvider } from '../types.js';
|
|
3
3
|
/** [Adobe](https://fonts.adobe.com/) */
|
|
4
|
-
declare function adobe(config: Parameters<typeof providers.adobe>[0]):
|
|
5
|
-
entrypoint: string | URL;
|
|
6
|
-
config?: Record<string, any> | undefined;
|
|
7
|
-
};
|
|
4
|
+
declare function adobe(config: Parameters<typeof providers.adobe>[0]): AstroFontProvider;
|
|
8
5
|
/** [Bunny](https://fonts.bunny.net/) */
|
|
9
|
-
declare function bunny():
|
|
10
|
-
entrypoint: string | URL;
|
|
11
|
-
config?: Record<string, any> | undefined;
|
|
12
|
-
};
|
|
6
|
+
declare function bunny(): AstroFontProvider;
|
|
13
7
|
/** [Fontshare](https://www.fontshare.com/) */
|
|
14
|
-
declare function fontshare():
|
|
15
|
-
entrypoint: string | URL;
|
|
16
|
-
config?: Record<string, any> | undefined;
|
|
17
|
-
};
|
|
8
|
+
declare function fontshare(): AstroFontProvider;
|
|
18
9
|
/** [Fontsource](https://fontsource.org/) */
|
|
19
|
-
declare function fontsource():
|
|
20
|
-
entrypoint: string | URL;
|
|
21
|
-
config?: Record<string, any> | undefined;
|
|
22
|
-
};
|
|
10
|
+
declare function fontsource(): AstroFontProvider;
|
|
23
11
|
/** [Google](https://fonts.google.com/) */
|
|
24
|
-
declare function google(config?: Parameters<typeof providers.google>[0]):
|
|
25
|
-
entrypoint: string | URL;
|
|
26
|
-
config?: Record<string, any> | undefined;
|
|
27
|
-
};
|
|
12
|
+
declare function google(config?: Parameters<typeof providers.google>[0]): AstroFontProvider;
|
|
28
13
|
/**
|
|
29
14
|
* Astro re-exports most [unifont](https://github.com/unjs/unifont/) providers:
|
|
30
15
|
* - [Adobe](https://fonts.adobe.com/)
|
|
@@ -41,8 +26,5 @@ export declare const fontProviders: {
|
|
|
41
26
|
google: typeof google;
|
|
42
27
|
};
|
|
43
28
|
/** A type helper for defining Astro font providers config objects */
|
|
44
|
-
export declare function defineAstroFontProvider(provider: AstroFontProvider):
|
|
45
|
-
entrypoint: string | URL;
|
|
46
|
-
config?: Record<string, any> | undefined;
|
|
47
|
-
};
|
|
29
|
+
export declare function defineAstroFontProvider(provider: AstroFontProvider): AstroFontProvider;
|
|
48
30
|
export {};
|