@nubisco/ui 5.27.1 → 5.27.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/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/fonts.js +1 -1
- package/dist/plugins/vite/glyphs.d.ts +2 -1
- package/dist/plugins/vite/glyphs.d.ts.map +1 -1
- package/dist/plugins/vite/glyphs.js +7 -2
- package/dist/plugins/vite/imports.d.ts +2 -1
- package/dist/plugins/vite/imports.d.ts.map +1 -1
- package/dist/plugins/vite/imports.js +7 -2
- package/dist/plugins/vite/index.js +1 -1
- package/dist/plugins/vite/vendor-capsize-font-metrics.js +168350 -0
- package/dist/plugins/vite/vendor-fonts.d.ts +311 -0
- package/dist/plugins/vite/vendor.d.ts +6 -0
- package/dist/plugins/vite/vendor.js +38642 -0
- package/package.json +5 -12
- package/src/plugins/fonts.ts +1 -1
- package/src/plugins/vite/glyphs.ts +8 -2
- package/src/plugins/vite/imports.ts +8 -2
- package/src/plugins/vite/index.ts +1 -1
- package/src/plugins/vite/vendor.ts +21 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/** Copied from unplugin-fonts at build time. Internal to @nubisco/ui/plugins/fonts. */
|
|
2
|
+
import type { HtmlTagDescriptor } from 'vite';
|
|
3
|
+
export interface FontFallbackConfig {
|
|
4
|
+
/**
|
|
5
|
+
* System fonts to use as fallback bases.
|
|
6
|
+
* When not provided, fontaine auto-selects by category.
|
|
7
|
+
* @example ['Arial', 'Helvetica Neue']
|
|
8
|
+
*/
|
|
9
|
+
fallbacks?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Generic font category. Used to auto-select system fallbacks
|
|
12
|
+
* when `fallbacks` is not provided.
|
|
13
|
+
* @default 'sans-serif'
|
|
14
|
+
*/
|
|
15
|
+
category?: 'sans-serif' | 'serif' | 'monospace';
|
|
16
|
+
/**
|
|
17
|
+
* Override the generated fallback font-face name.
|
|
18
|
+
* @default '{familyName} fallback'
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Options {
|
|
23
|
+
/** Custom font families loaded from local files. */
|
|
24
|
+
custom?: CustomFonts;
|
|
25
|
+
/** Font families loaded from Fontsource packages. */
|
|
26
|
+
fontsource?: FontsourceFonts;
|
|
27
|
+
/** Font families loaded from Google Fonts. */
|
|
28
|
+
google?: GoogleFonts;
|
|
29
|
+
/** Font families loaded from Adobe Typekit. */
|
|
30
|
+
typekit?: TypeKitFonts;
|
|
31
|
+
/** Enable sourcemap generation for virtual CSS modules. */
|
|
32
|
+
sourcemap?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Inline `@font-face` rules into the HTML as a `<style>` tag
|
|
35
|
+
* instead of keeping them in the external CSS bundle.
|
|
36
|
+
* Reduces render-blocking requests and can improve LCP.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
inlineFontFace?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CustomFontFace {
|
|
42
|
+
/** Original glob source pattern that matched this font face. */
|
|
43
|
+
source: string;
|
|
44
|
+
/** Font family name. */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Base filename without extension. */
|
|
47
|
+
basename: string;
|
|
48
|
+
/** Font weight value or range inferred from the filename. */
|
|
49
|
+
weight: number | `${number} ${number}`;
|
|
50
|
+
/** Font style inferred from the filename (e.g. 'normal', 'italic'). */
|
|
51
|
+
style: string;
|
|
52
|
+
/** Value for the `font-display` descriptor. */
|
|
53
|
+
display: string;
|
|
54
|
+
/** Local font name(s) for `src: local()` in the `@font-face` rule. */
|
|
55
|
+
local?: string | string[];
|
|
56
|
+
/** Resolved font files matching the source pattern. */
|
|
57
|
+
files: {
|
|
58
|
+
/** Absolute path to the font file on disk. */
|
|
59
|
+
src: string;
|
|
60
|
+
/** File extension (e.g. '.woff2'). */
|
|
61
|
+
ext: string;
|
|
62
|
+
/** Public-facing URL path for the font file. */
|
|
63
|
+
path: string;
|
|
64
|
+
/** CSS font format string (e.g. 'woff2', 'truetype'). */
|
|
65
|
+
format: string;
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
export interface CustomFontFamily {
|
|
69
|
+
/**
|
|
70
|
+
* Name of the font family.
|
|
71
|
+
* @example 'Comic Sans MS'
|
|
72
|
+
*/
|
|
73
|
+
name: string;
|
|
74
|
+
/**
|
|
75
|
+
* Regex(es) of font files to import. The names of the files will
|
|
76
|
+
* predicate the `font-style` and `font-weight` values of the `@font-rule`'s.
|
|
77
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* A value of `./RobotoBoldItalic.*` will create this `@font-rule`:
|
|
81
|
+
*
|
|
82
|
+
* ```css
|
|
83
|
+
* font-face {
|
|
84
|
+
* font-family: 'Roboto';
|
|
85
|
+
* src: url(./RobotoBoldItalic.ttf) format('truetype')
|
|
86
|
+
* url(./RobotoBoldItalic.woff) format('woff')
|
|
87
|
+
* url(./RobotoBoldItalic.woff2) format('woff2');
|
|
88
|
+
* font-weight: bold;
|
|
89
|
+
* font-style: italic;
|
|
90
|
+
* font-display: auto;
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
src: string | string[];
|
|
95
|
+
/**
|
|
96
|
+
* Local name of the font. Used to add `src: local()` to `@font-rule`.
|
|
97
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face#description
|
|
98
|
+
*/
|
|
99
|
+
local?: string | string[];
|
|
100
|
+
/**
|
|
101
|
+
* Allows to transform the generated config for any font face.
|
|
102
|
+
*
|
|
103
|
+
* @param font
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
transform?: (font: CustomFontFace) => CustomFontFace | null;
|
|
107
|
+
/**
|
|
108
|
+
* Generate a fallback @font-face with adjusted metrics to reduce CLS.
|
|
109
|
+
* Uses fontaine to compute size-adjust, ascent-override, descent-override,
|
|
110
|
+
* and line-gap-override from the font file.
|
|
111
|
+
*/
|
|
112
|
+
fallback?: FontFallbackConfig;
|
|
113
|
+
}
|
|
114
|
+
export interface CustomFonts {
|
|
115
|
+
/**
|
|
116
|
+
* Font families.
|
|
117
|
+
*/
|
|
118
|
+
families: CustomFontFamily[] | Record<string, string | string[] | Omit<CustomFontFamily, 'name'>>;
|
|
119
|
+
/**
|
|
120
|
+
* Defines the default `font-display` value used for the generated
|
|
121
|
+
* `@font-rule` classes.
|
|
122
|
+
* @see https://developer.mozilla.org/fr/docs/Web/CSS/@font-face/font-display
|
|
123
|
+
* @default 'auto'
|
|
124
|
+
*/
|
|
125
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
126
|
+
/**
|
|
127
|
+
* Using `<link rel="preload">` will trigger a request for the WebFont
|
|
128
|
+
* early in the critical rendering path, without having to wait for the
|
|
129
|
+
* CSSOM to be created.
|
|
130
|
+
* @see https://web.dev/optimize-webfont-loading/#preload-your-webfont-resources
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
preload?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Using `<link rel="prefetch">` is intended for prefetching resources
|
|
136
|
+
* that will be used in the next navigation/page load
|
|
137
|
+
* (e.g. when you go to the next page)
|
|
138
|
+
*
|
|
139
|
+
* Note: this can not be used with `preload`
|
|
140
|
+
* @default false
|
|
141
|
+
*/
|
|
142
|
+
prefetch?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* URL prefix prepended to font paths when using prefetch.
|
|
145
|
+
*/
|
|
146
|
+
prefetchPrefix?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Provides a hook for filtering which `<link>` tags should be actually
|
|
149
|
+
* generated.
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
linkFilter?: (tags: HtmlTagDescriptor[]) => HtmlTagDescriptor[] | boolean;
|
|
153
|
+
/**
|
|
154
|
+
* @default: 'head-prepend'
|
|
155
|
+
*/
|
|
156
|
+
injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
|
|
157
|
+
/**
|
|
158
|
+
* Remove the prefix from the front path
|
|
159
|
+
* @default: 'public/'
|
|
160
|
+
*/
|
|
161
|
+
stripPrefix?: string;
|
|
162
|
+
}
|
|
163
|
+
interface BaseFontsourceFontFamily {
|
|
164
|
+
/**
|
|
165
|
+
* Name of the font family.
|
|
166
|
+
* @example 'Roboto'
|
|
167
|
+
*/
|
|
168
|
+
name: string;
|
|
169
|
+
/**
|
|
170
|
+
* Font styles to load.
|
|
171
|
+
* @default ['normal']
|
|
172
|
+
*/
|
|
173
|
+
styles?: ('italic' | 'normal')[];
|
|
174
|
+
/**
|
|
175
|
+
* Font subset to load (e.g. 'latin', 'latin-ext').
|
|
176
|
+
*/
|
|
177
|
+
subset?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Generate a fallback @font-face with adjusted metrics to reduce CLS.
|
|
180
|
+
* Uses fontaine to look up font metrics by family name.
|
|
181
|
+
*/
|
|
182
|
+
fallback?: FontFallbackConfig;
|
|
183
|
+
}
|
|
184
|
+
interface WeightsFontsourceFontFamily extends BaseFontsourceFontFamily {
|
|
185
|
+
/**
|
|
186
|
+
* Font weights to load.
|
|
187
|
+
* @example [400, 700]
|
|
188
|
+
*/
|
|
189
|
+
weights: (100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900)[];
|
|
190
|
+
}
|
|
191
|
+
interface VariableFontsourceFontFamily extends BaseFontsourceFontFamily {
|
|
192
|
+
/**
|
|
193
|
+
* Enable variable font axes. Set to `true` to load the default
|
|
194
|
+
* variable font, or specify individual axes to load.
|
|
195
|
+
*/
|
|
196
|
+
variable: true | {
|
|
197
|
+
/** Weight axis. */
|
|
198
|
+
wght?: boolean;
|
|
199
|
+
/** Width axis. */
|
|
200
|
+
wdth?: boolean;
|
|
201
|
+
/** Slant axis. */
|
|
202
|
+
slnt?: boolean;
|
|
203
|
+
/** Optical size axis. */
|
|
204
|
+
opsz?: boolean;
|
|
205
|
+
/** Italic axis. */
|
|
206
|
+
ital?: boolean;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export type FontsourceFontFamily = WeightsFontsourceFontFamily | VariableFontsourceFontFamily;
|
|
210
|
+
export interface FontsourceFonts {
|
|
211
|
+
/**
|
|
212
|
+
* Font families to load from Fontsource.
|
|
213
|
+
* Can be strings (load default set) or objects for fine-grained control.
|
|
214
|
+
*/
|
|
215
|
+
families: (string | FontsourceFontFamily)[];
|
|
216
|
+
}
|
|
217
|
+
export interface GoogleFontFamily {
|
|
218
|
+
/**
|
|
219
|
+
* Font family name.
|
|
220
|
+
* @example 'Roboto'
|
|
221
|
+
*/
|
|
222
|
+
name: string;
|
|
223
|
+
/**
|
|
224
|
+
* Font styles/weights to load using the Google Fonts CSS2 API format.
|
|
225
|
+
* @example 'ital,wght@0,400;1,200'
|
|
226
|
+
*/
|
|
227
|
+
styles?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Enable non-blocking renderer using `<link rel="preload">`.
|
|
230
|
+
* @default true
|
|
231
|
+
*/
|
|
232
|
+
defer?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Generate a fallback @font-face with adjusted metrics to reduce CLS.
|
|
235
|
+
* Uses fontaine to look up font metrics by family name.
|
|
236
|
+
*/
|
|
237
|
+
fallback?: FontFallbackConfig;
|
|
238
|
+
}
|
|
239
|
+
export interface GoogleFonts {
|
|
240
|
+
/**
|
|
241
|
+
* Font families to load from Google Fonts.
|
|
242
|
+
* Can be strings (only regular 400 will be loaded) or objects for fine-grained control.
|
|
243
|
+
*/
|
|
244
|
+
families: (string | GoogleFontFamily)[];
|
|
245
|
+
/**
|
|
246
|
+
* Subset the font to only include glyphs needed for the given text.
|
|
247
|
+
* @see https://developers.google.com/fonts/docs/css2#optimizing_your_font_requests
|
|
248
|
+
*/
|
|
249
|
+
text?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Font display strategy.
|
|
252
|
+
* @default 'swap'
|
|
253
|
+
*/
|
|
254
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
255
|
+
/**
|
|
256
|
+
* Enable preconnect link injection to warm up the fonts origin.
|
|
257
|
+
* @default true
|
|
258
|
+
*/
|
|
259
|
+
preconnect?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* @default: 'head-prepend'
|
|
262
|
+
*/
|
|
263
|
+
injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
|
|
264
|
+
/**
|
|
265
|
+
* @default: 'https://fonts.googleapis.com/css2'
|
|
266
|
+
*/
|
|
267
|
+
fontBaseUrl?: string;
|
|
268
|
+
/**
|
|
269
|
+
* @default: 'https://fonts.gstatic.com/'
|
|
270
|
+
*/
|
|
271
|
+
preconnectUrl?: string;
|
|
272
|
+
}
|
|
273
|
+
export interface TypeKitFontFamily {
|
|
274
|
+
/**
|
|
275
|
+
* Font family name as it appears in the Typekit project.
|
|
276
|
+
* @example 'Futura PT'
|
|
277
|
+
*/
|
|
278
|
+
name: string;
|
|
279
|
+
/**
|
|
280
|
+
* Generate a fallback @font-face with adjusted metrics to reduce CLS.
|
|
281
|
+
* Uses fontaine to look up font metrics by family name.
|
|
282
|
+
*/
|
|
283
|
+
fallback?: FontFallbackConfig;
|
|
284
|
+
}
|
|
285
|
+
export interface TypeKitFonts {
|
|
286
|
+
/**
|
|
287
|
+
* Typekit project ID.
|
|
288
|
+
* @example 'abc1def'
|
|
289
|
+
*/
|
|
290
|
+
id: string;
|
|
291
|
+
/**
|
|
292
|
+
* Enable non-blocking renderer using `<link rel="preload">`.
|
|
293
|
+
* @default true
|
|
294
|
+
*/
|
|
295
|
+
defer?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* default: 'head-prepend'
|
|
298
|
+
*/
|
|
299
|
+
injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
|
|
300
|
+
/**
|
|
301
|
+
* @default: 'https://use.typekit.net/'
|
|
302
|
+
*/
|
|
303
|
+
fontBaseUrl?: string;
|
|
304
|
+
/**
|
|
305
|
+
* Font families in this Typekit project.
|
|
306
|
+
* Needed to generate fallback @font-face declarations since Typekit
|
|
307
|
+
* only provides a project ID, not individual family metadata.
|
|
308
|
+
*/
|
|
309
|
+
families?: (string | TypeKitFontFamily)[];
|
|
310
|
+
}
|
|
311
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Internal to @nubisco/ui/vite and @nubisco/ui/plugins/fonts, bundled at build time. Not a public API. */
|
|
2
|
+
export declare const Components: (options?: object) => import('vite').Plugin;
|
|
3
|
+
export declare const MagicString: new (code: string) => object;
|
|
4
|
+
export declare const Unfonts: (
|
|
5
|
+
options?: import('./vendor-fonts').Options,
|
|
6
|
+
) => import('vite').Plugin | import('vite').Plugin[];
|