vinext 0.0.15 → 0.0.16

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.
Files changed (44) hide show
  1. package/README.md +6 -0
  2. package/dist/cli.js +21 -11
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config/config-matchers.d.ts +4 -1
  5. package/dist/config/config-matchers.d.ts.map +1 -1
  6. package/dist/config/config-matchers.js +11 -1
  7. package/dist/config/config-matchers.js.map +1 -1
  8. package/dist/config/next-config.d.ts +2 -0
  9. package/dist/config/next-config.d.ts.map +1 -1
  10. package/dist/config/next-config.js.map +1 -1
  11. package/dist/deploy.d.ts.map +1 -1
  12. package/dist/deploy.js +2 -0
  13. package/dist/deploy.js.map +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +68 -57
  16. package/dist/index.js.map +1 -1
  17. package/dist/server/app-dev-server.d.ts.map +1 -1
  18. package/dist/server/app-dev-server.js +25 -9
  19. package/dist/server/app-dev-server.js.map +1 -1
  20. package/dist/server/middleware.d.ts +23 -1
  21. package/dist/server/middleware.d.ts.map +1 -1
  22. package/dist/server/middleware.js +42 -8
  23. package/dist/server/middleware.js.map +1 -1
  24. package/dist/server/prod-server.js +1 -1
  25. package/dist/server/prod-server.js.map +1 -1
  26. package/dist/shims/fetch-cache.d.ts.map +1 -1
  27. package/dist/shims/fetch-cache.js +73 -41
  28. package/dist/shims/fetch-cache.js.map +1 -1
  29. package/dist/shims/font-google-base.d.ts +68 -0
  30. package/dist/shims/font-google-base.d.ts.map +1 -0
  31. package/dist/shims/font-google-base.js +365 -0
  32. package/dist/shims/font-google-base.js.map +1 -0
  33. package/dist/shims/font-google.d.ts +2 -121
  34. package/dist/shims/font-google.d.ts.map +1 -1
  35. package/dist/shims/font-google.generated.d.ts +1925 -0
  36. package/dist/shims/font-google.generated.d.ts.map +1 -0
  37. package/dist/shims/font-google.generated.js +1928 -0
  38. package/dist/shims/font-google.generated.js.map +1 -0
  39. package/dist/shims/font-google.js +2 -386
  40. package/dist/shims/font-google.js.map +1 -1
  41. package/dist/utils/project.d.ts.map +1 -1
  42. package/dist/utils/project.js +4 -0
  43. package/dist/utils/project.js.map +1 -1
  44. package/package.json +2 -1
@@ -0,0 +1,365 @@
1
+ /**
2
+ * next/font/google shim
3
+ *
4
+ * Provides a compatible shim for Next.js Google Fonts.
5
+ *
6
+ * Two modes:
7
+ * 1. **Dev / CDN mode** (default): Loads fonts from Google Fonts CDN via <link> tags.
8
+ * 2. **Self-hosted mode** (production build): The vinext:google-fonts Vite plugin
9
+ * fetches font CSS + .woff2 files at build time, caches them locally, and injects
10
+ * @font-face CSS pointing at local assets. No requests to Google at runtime.
11
+ *
12
+ * Usage:
13
+ * import { Inter } from 'next/font/google';
14
+ * const inter = Inter({ subsets: ['latin'], weight: ['400', '700'] });
15
+ * // inter.className -> unique CSS class
16
+ * // inter.style -> { fontFamily: "'Inter', sans-serif" }
17
+ * // inter.variable -> CSS variable name like '--font-inter'
18
+ */
19
+ /**
20
+ * Escape a string for safe interpolation inside a CSS single-quoted string.
21
+ *
22
+ * Prevents CSS injection by escaping characters that could break out of
23
+ * a `'...'` CSS string context: backslashes, single quotes, and newlines.
24
+ */
25
+ function escapeCSSString(value) {
26
+ return value
27
+ .replace(/\\/g, "\\\\")
28
+ .replace(/'/g, "\\'")
29
+ .replace(/\n/g, "\\a ")
30
+ .replace(/\r/g, "\\d ");
31
+ }
32
+ /**
33
+ * Validate a CSS custom property name (e.g. `--font-inter`).
34
+ *
35
+ * Custom properties must start with `--` and only contain alphanumeric
36
+ * characters, hyphens, and underscores. Anything else could be used to
37
+ * break out of the CSS declaration and inject arbitrary rules.
38
+ *
39
+ * Returns the name if valid, undefined otherwise.
40
+ */
41
+ function sanitizeCSSVarName(name) {
42
+ if (/^--[a-zA-Z0-9_-]+$/.test(name))
43
+ return name;
44
+ return undefined;
45
+ }
46
+ /**
47
+ * Sanitize a CSS font-family fallback name.
48
+ *
49
+ * Generic family names (sans-serif, serif, monospace, etc.) are used as-is.
50
+ * Named families are wrapped in escaped quotes. This prevents injection via
51
+ * crafted fallback values like `); } body { color: red; } .x {`.
52
+ */
53
+ function sanitizeFallback(name) {
54
+ // CSS generic font families — safe to use unquoted
55
+ const generics = new Set([
56
+ "serif", "sans-serif", "monospace", "cursive", "fantasy",
57
+ "system-ui", "ui-serif", "ui-sans-serif", "ui-monospace", "ui-rounded",
58
+ "emoji", "math", "fangsong",
59
+ ]);
60
+ const trimmed = name.trim();
61
+ if (generics.has(trimmed))
62
+ return trimmed;
63
+ // Wrap in single quotes with escaping to prevent CSS injection
64
+ return `'${escapeCSSString(trimmed)}'`;
65
+ }
66
+ // Counter for generating unique class names
67
+ let classCounter = 0;
68
+ // Track which font stylesheets have been injected (SSR + client)
69
+ const injectedFonts = new Set();
70
+ /**
71
+ * Convert a font family name to a CSS variable name.
72
+ * e.g., "Inter" -> "--font-inter", "Roboto Mono" -> "--font-roboto-mono"
73
+ */
74
+ function toVarName(family) {
75
+ return "--font-" + family.toLowerCase().replace(/\s+/g, "-");
76
+ }
77
+ /**
78
+ * Build a Google Fonts CSS URL.
79
+ */
80
+ export function buildGoogleFontsUrl(family, options) {
81
+ const params = new URLSearchParams();
82
+ // Don't pre-replace spaces with "+". URLSearchParams handles encoding:
83
+ // spaces become "+" in application/x-www-form-urlencoded format.
84
+ // Pre-replacing would cause double-encoding: "+" -> "%2B" (400 error).
85
+ let spec = family;
86
+ // Build weight/style specs
87
+ const weights = options.weight
88
+ ? Array.isArray(options.weight)
89
+ ? options.weight
90
+ : [options.weight]
91
+ : [];
92
+ const styles = options.style
93
+ ? Array.isArray(options.style)
94
+ ? options.style
95
+ : [options.style]
96
+ : [];
97
+ if (weights.length > 0 || styles.length > 0) {
98
+ const hasItalic = styles.includes("italic");
99
+ if (weights.length > 0) {
100
+ if (hasItalic) {
101
+ // Use ital axis: ital,wght@0,400;0,700;1,400;1,700
102
+ const pairs = [];
103
+ for (const w of weights) {
104
+ pairs.push(`0,${w}`);
105
+ pairs.push(`1,${w}`);
106
+ }
107
+ spec += `:ital,wght@${pairs.join(";")}`;
108
+ }
109
+ else {
110
+ spec += `:wght@${weights.join(";")}`;
111
+ }
112
+ }
113
+ }
114
+ else {
115
+ // When no weight is specified, request the full variable weight range.
116
+ // Without this, Google Fonts returns only weight 400 (the default).
117
+ // Next.js loads the full variable font by default, so we match that
118
+ // behavior to ensure all font weights render correctly.
119
+ spec += `:wght@100..900`;
120
+ }
121
+ params.set("family", spec);
122
+ params.set("display", options.display ?? "swap");
123
+ return `https://fonts.googleapis.com/css2?${params.toString()}`;
124
+ }
125
+ /**
126
+ * Inject a <link> tag for the font (client-side only).
127
+ * On the server, we track font URLs for SSR head injection.
128
+ */
129
+ function injectFontStylesheet(url) {
130
+ if (injectedFonts.has(url))
131
+ return;
132
+ injectedFonts.add(url);
133
+ if (typeof document !== "undefined") {
134
+ const link = document.createElement("link");
135
+ link.rel = "stylesheet";
136
+ link.href = url;
137
+ document.head.appendChild(link);
138
+ }
139
+ }
140
+ /** Track which className CSS rules have been injected. */
141
+ const injectedClassRules = new Set();
142
+ /**
143
+ * Inject a CSS rule that maps a className to a font-family.
144
+ *
145
+ * This is what makes `<div className={inter.className}>` apply the font.
146
+ * Next.js generates equivalent rules at build time.
147
+ *
148
+ * In Next.js, the .className class ONLY sets font-family — it does NOT
149
+ * set CSS variables. CSS variables are handled separately by the .variable class.
150
+ */
151
+ function injectClassNameRule(className, fontFamily) {
152
+ if (injectedClassRules.has(className))
153
+ return;
154
+ injectedClassRules.add(className);
155
+ const css = `.${className} { font-family: ${fontFamily}; }\n`;
156
+ // On server, store the CSS for SSR injection
157
+ if (typeof document === "undefined") {
158
+ ssrFontStyles.push(css);
159
+ return;
160
+ }
161
+ // On client, inject a <style> tag
162
+ const style = document.createElement("style");
163
+ style.textContent = css;
164
+ style.setAttribute("data-vinext-font-class", className);
165
+ document.head.appendChild(style);
166
+ }
167
+ /** Track which variable class CSS rules have been injected. */
168
+ const injectedVariableRules = new Set();
169
+ /** Track which :root CSS variable rules have been injected. */
170
+ const injectedRootVariables = new Set();
171
+ /**
172
+ * Inject a CSS rule that sets a CSS variable on an element.
173
+ * This is what makes `<html className={inter.variable}>` set the CSS variable
174
+ * that can be referenced by other styles (e.g., Tailwind's font-sans).
175
+ *
176
+ * In Next.js, the .variable class ONLY sets the CSS variable — it does NOT
177
+ * set font-family. This is critical because apps commonly apply multiple
178
+ * .variable classes to <body> (e.g., geistSans.variable + geistMono.variable).
179
+ * If we also set font-family here, the last class wins due to CSS cascade,
180
+ * causing all text to use that font (e.g., everything becomes monospace).
181
+ */
182
+ function injectVariableClassRule(variableClassName, cssVarName, fontFamily) {
183
+ if (injectedVariableRules.has(variableClassName))
184
+ return;
185
+ injectedVariableRules.add(variableClassName);
186
+ // Only set the CSS variable — do NOT set font-family.
187
+ // This matches Next.js behavior where .variable classes only define CSS variables.
188
+ let css = `.${variableClassName} { ${cssVarName}: ${fontFamily}; }\n`;
189
+ // Also inject at :root so CSS variable inheritance works throughout the page.
190
+ // This ensures Tailwind utilities like `font-sans` that reference these
191
+ // variables via var(--font-geist-sans) work correctly.
192
+ if (!injectedRootVariables.has(cssVarName)) {
193
+ injectedRootVariables.add(cssVarName);
194
+ css += `:root { ${cssVarName}: ${fontFamily}; }\n`;
195
+ }
196
+ // On server, store the CSS for SSR injection
197
+ if (typeof document === "undefined") {
198
+ ssrFontStyles.push(css);
199
+ return;
200
+ }
201
+ // On client, inject a <style> tag
202
+ const style = document.createElement("style");
203
+ style.textContent = css;
204
+ style.setAttribute("data-vinext-font-variable", variableClassName);
205
+ document.head.appendChild(style);
206
+ }
207
+ // SSR: collect font class CSS for injection in <head>
208
+ const ssrFontStyles = [];
209
+ /**
210
+ * Get collected SSR font class styles (used by the renderer).
211
+ * Note: We don't clear the arrays because fonts are loaded at module import
212
+ * time and need to persist across all requests in the Workers environment.
213
+ */
214
+ export function getSSRFontStyles() {
215
+ return [...ssrFontStyles];
216
+ }
217
+ // SSR: collect font URLs to inject in <head>
218
+ const ssrFontUrls = [];
219
+ /**
220
+ * Get collected SSR font URLs (used by the renderer).
221
+ * Note: We don't clear the arrays because fonts are loaded at module import
222
+ * time and need to persist across all requests in the Workers environment.
223
+ */
224
+ export function getSSRFontLinks() {
225
+ return [...ssrFontUrls];
226
+ }
227
+ // SSR: collect font file URLs for <link rel="preload"> injection (self-hosted Google fonts)
228
+ const ssrFontPreloads = [];
229
+ const ssrFontPreloadHrefs = new Set();
230
+ /**
231
+ * Get collected SSR font preload data (used by the renderer).
232
+ * Returns an array of { href, type } objects for emitting
233
+ * <link rel="preload" as="font" ...> tags.
234
+ */
235
+ export function getSSRFontPreloads() {
236
+ return [...ssrFontPreloads];
237
+ }
238
+ /**
239
+ * Determine the MIME type for a font file based on its extension.
240
+ */
241
+ function getFontMimeType(pathOrUrl) {
242
+ if (pathOrUrl.endsWith(".woff2"))
243
+ return "font/woff2";
244
+ if (pathOrUrl.endsWith(".woff"))
245
+ return "font/woff";
246
+ if (pathOrUrl.endsWith(".ttf"))
247
+ return "font/ttf";
248
+ if (pathOrUrl.endsWith(".otf"))
249
+ return "font/opentype";
250
+ return "font/woff2";
251
+ }
252
+ /**
253
+ * Extract font file URLs from @font-face CSS rules.
254
+ * Parses url('...') references from the CSS text.
255
+ */
256
+ function extractFontUrlsFromCSS(css) {
257
+ const urls = [];
258
+ const urlRegex = /url\(['"]?([^'")]+)['"]?\)/g;
259
+ let match;
260
+ while ((match = urlRegex.exec(css)) !== null) {
261
+ const url = match[1];
262
+ // Only collect absolute paths (starting with /) — these are self-hosted font files
263
+ if (url && url.startsWith("/")) {
264
+ urls.push(url);
265
+ }
266
+ }
267
+ return urls;
268
+ }
269
+ /**
270
+ * Collect font file URLs from self-hosted CSS for preload link generation.
271
+ * Only collects on the server (SSR). Deduplicates by href using a Set for O(1) lookups.
272
+ */
273
+ function collectFontPreloadsFromCSS(css) {
274
+ if (typeof document !== "undefined")
275
+ return; // client-side, skip
276
+ const urls = extractFontUrlsFromCSS(css);
277
+ for (const href of urls) {
278
+ if (!ssrFontPreloadHrefs.has(href)) {
279
+ ssrFontPreloadHrefs.add(href);
280
+ ssrFontPreloads.push({ href, type: getFontMimeType(href) });
281
+ }
282
+ }
283
+ }
284
+ /** Track injected self-hosted @font-face blocks (deduplicate) */
285
+ const injectedSelfHosted = new Set();
286
+ /**
287
+ * Inject self-hosted @font-face CSS (from the build plugin).
288
+ * This replaces the CDN <link> tag with inline CSS.
289
+ */
290
+ function injectSelfHostedCSS(css) {
291
+ if (injectedSelfHosted.has(css))
292
+ return;
293
+ injectedSelfHosted.add(css);
294
+ // Extract font file URLs for preload hints (SSR only)
295
+ collectFontPreloadsFromCSS(css);
296
+ if (typeof document === "undefined") {
297
+ // SSR: add to collected styles
298
+ ssrFontStyles.push(css);
299
+ return;
300
+ }
301
+ // Client: inject <style> tag
302
+ const style = document.createElement("style");
303
+ style.textContent = css;
304
+ style.setAttribute("data-vinext-font-selfhosted", "true");
305
+ document.head.appendChild(style);
306
+ }
307
+ export function createFontLoader(family) {
308
+ return function fontLoader(options = {}) {
309
+ const id = classCounter++;
310
+ const className = `__font_${family.toLowerCase().replace(/\s+/g, "_")}_${id}`;
311
+ const fallback = options.fallback ?? ["sans-serif"];
312
+ // Sanitize each fallback name to prevent CSS injection via crafted values
313
+ const fontFamily = `'${escapeCSSString(family)}', ${fallback.map(sanitizeFallback).join(", ")}`;
314
+ // Validate CSS variable name — reject anything that could inject CSS.
315
+ // Fall back to auto-generated name if invalid.
316
+ const defaultVarName = toVarName(family);
317
+ const cssVarName = options.variable ? (sanitizeCSSVarName(options.variable) ?? defaultVarName) : defaultVarName;
318
+ // In Next.js, `variable` returns a CLASS NAME that sets the CSS variable.
319
+ // Users apply this class to set the CSS variable on that element.
320
+ const variableClassName = `__variable_${family.toLowerCase().replace(/\s+/g, "_")}_${id}`;
321
+ if (options._selfHostedCSS) {
322
+ // Self-hosted mode: inject local @font-face CSS instead of CDN link
323
+ injectSelfHostedCSS(options._selfHostedCSS);
324
+ }
325
+ else {
326
+ // CDN mode: inject <link> to Google Fonts
327
+ const url = buildGoogleFontsUrl(family, options);
328
+ injectFontStylesheet(url);
329
+ // On SSR, collect the URL for head injection
330
+ if (typeof document === "undefined") {
331
+ if (!ssrFontUrls.includes(url)) {
332
+ ssrFontUrls.push(url);
333
+ }
334
+ }
335
+ }
336
+ // Inject a CSS rule that maps className to font-family.
337
+ // This is what makes `<div className={inter.className}>` work.
338
+ injectClassNameRule(className, fontFamily);
339
+ // Inject a CSS rule for the variable class name.
340
+ // This is what makes `<html className={inter.variable}>` set the CSS variable.
341
+ injectVariableClassRule(variableClassName, cssVarName, fontFamily);
342
+ return {
343
+ className,
344
+ style: { fontFamily },
345
+ variable: variableClassName,
346
+ };
347
+ };
348
+ }
349
+ // Export a Proxy that creates font loaders for any Google Font family.
350
+ // Usage: import { Inter } from 'next/font/google'
351
+ // The proxy intercepts property access and returns a loader for that font.
352
+ const googleFonts = new Proxy({}, {
353
+ get(_target, prop) {
354
+ if (prop === "__esModule")
355
+ return true;
356
+ if (prop === "default")
357
+ return googleFonts;
358
+ // Convert camelCase/PascalCase to proper font family name
359
+ // e.g., "Inter" -> "Inter", "RobotoMono" -> "Roboto Mono"
360
+ const family = prop.replace(/([a-z])([A-Z])/g, "$1 $2");
361
+ return createFontLoader(family);
362
+ },
363
+ });
364
+ export default googleFonts;
365
+ //# sourceMappingURL=font-google-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-google-base.js","sourceRoot":"","sources":["../../src/shims/font-google-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,MAA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AW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,wDAAwD;QACxD,+DAA+D;QAC/D,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAE3C,iDAAiD;QACjD,+EAA+E;QAC/E,uBAAuB,CAAC,iBAAiB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAEnE,OAAO;YACL,SAAS;YACT,KAAK,EAAE,EAAE,UAAU,EAAE;YACrB,QAAQ,EAAE,iBAAiB;SAC5B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,kDAAkD;AAClD,2EAA2E;AAC3E,MAAM,WAAW,GAAG,IAAI,KAAK,CAC3B,EAA2D,EAC3D;IACE,GAAG,CAAC,OAAO,EAAE,IAAY;QACvB,IAAI,IAAI,KAAK,YAAY;YAAE,OAAO,IAAI,CAAC;QACvC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,WAAW,CAAC;QAC3C,0DAA0D;QAC1D,0DAA0D;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/**\n * next/font/google shim\n *\n * Provides a compatible shim for Next.js Google Fonts.\n *\n * Two modes:\n * 1. **Dev / CDN mode** (default): Loads fonts from Google Fonts CDN via <link> tags.\n * 2. **Self-hosted mode** (production build): The vinext:google-fonts Vite plugin\n * fetches font CSS + .woff2 files at build time, caches them locally, and injects\n * @font-face CSS pointing at local assets. No requests to Google at runtime.\n *\n * Usage:\n * import { Inter } from 'next/font/google';\n * const inter = Inter({ subsets: ['latin'], weight: ['400', '700'] });\n * // inter.className -> unique CSS class\n * // inter.style -> { fontFamily: \"'Inter', sans-serif\" }\n * // inter.variable -> CSS variable name like '--font-inter'\n */\n\n/**\n * Escape a string for safe interpolation inside a CSS single-quoted string.\n *\n * Prevents CSS injection by escaping characters that could break out of\n * a `'...'` CSS string context: backslashes, single quotes, and newlines.\n */\nfunction escapeCSSString(value: string): string {\n return value\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, \"\\\\a \")\n .replace(/\\r/g, \"\\\\d \");\n}\n\n/**\n * Validate a CSS custom property name (e.g. `--font-inter`).\n *\n * Custom properties must start with `--` and only contain alphanumeric\n * characters, hyphens, and underscores. Anything else could be used to\n * break out of the CSS declaration and inject arbitrary rules.\n *\n * Returns the name if valid, undefined otherwise.\n */\nfunction sanitizeCSSVarName(name: string): string | undefined {\n if (/^--[a-zA-Z0-9_-]+$/.test(name)) return name;\n return undefined;\n}\n\n/**\n * Sanitize a CSS font-family fallback name.\n *\n * Generic family names (sans-serif, serif, monospace, etc.) are used as-is.\n * Named families are wrapped in escaped quotes. This prevents injection via\n * crafted fallback values like `); } body { color: red; } .x {`.\n */\nfunction sanitizeFallback(name: string): string {\n // CSS generic font families — safe to use unquoted\n const generics = new Set([\n \"serif\", \"sans-serif\", \"monospace\", \"cursive\", \"fantasy\",\n \"system-ui\", \"ui-serif\", \"ui-sans-serif\", \"ui-monospace\", \"ui-rounded\",\n \"emoji\", \"math\", \"fangsong\",\n ]);\n const trimmed = name.trim();\n if (generics.has(trimmed)) return trimmed;\n // Wrap in single quotes with escaping to prevent CSS injection\n return `'${escapeCSSString(trimmed)}'`;\n}\n\n// Counter for generating unique class names\nlet classCounter = 0;\n\n// Track which font stylesheets have been injected (SSR + client)\nconst injectedFonts = new Set<string>();\n\nexport interface FontOptions {\n weight?: string | string[];\n style?: string | string[];\n subsets?: string[];\n display?: string;\n preload?: boolean;\n fallback?: string[];\n adjustFontFallback?: boolean | string;\n variable?: string;\n axes?: string[];\n}\n\nexport interface FontResult {\n className: string;\n style: { fontFamily: string };\n variable?: string;\n}\n\n/**\n * Convert a font family name to a CSS variable name.\n * e.g., \"Inter\" -> \"--font-inter\", \"Roboto Mono\" -> \"--font-roboto-mono\"\n */\nfunction toVarName(family: string): string {\n return \"--font-\" + family.toLowerCase().replace(/\\s+/g, \"-\");\n}\n\n/**\n * Build a Google Fonts CSS URL.\n */\nexport function buildGoogleFontsUrl(family: string, options: FontOptions): string {\n const params = new URLSearchParams();\n // Don't pre-replace spaces with \"+\". URLSearchParams handles encoding:\n // spaces become \"+\" in application/x-www-form-urlencoded format.\n // Pre-replacing would cause double-encoding: \"+\" -> \"%2B\" (400 error).\n let spec = family;\n\n // Build weight/style specs\n const weights = options.weight\n ? Array.isArray(options.weight)\n ? options.weight\n : [options.weight]\n : [];\n const styles = options.style\n ? Array.isArray(options.style)\n ? options.style\n : [options.style]\n : [];\n\n if (weights.length > 0 || styles.length > 0) {\n const hasItalic = styles.includes(\"italic\");\n if (weights.length > 0) {\n if (hasItalic) {\n // Use ital axis: ital,wght@0,400;0,700;1,400;1,700\n const pairs: string[] = [];\n for (const w of weights) {\n pairs.push(`0,${w}`);\n pairs.push(`1,${w}`);\n }\n spec += `:ital,wght@${pairs.join(\";\")}`;\n } else {\n spec += `:wght@${weights.join(\";\")}`;\n }\n }\n } else {\n // When no weight is specified, request the full variable weight range.\n // Without this, Google Fonts returns only weight 400 (the default).\n // Next.js loads the full variable font by default, so we match that\n // behavior to ensure all font weights render correctly.\n spec += `:wght@100..900`;\n }\n\n params.set(\"family\", spec);\n params.set(\"display\", options.display ?? \"swap\");\n\n return `https://fonts.googleapis.com/css2?${params.toString()}`;\n}\n\n/**\n * Inject a <link> tag for the font (client-side only).\n * On the server, we track font URLs for SSR head injection.\n */\nfunction injectFontStylesheet(url: string): void {\n if (injectedFonts.has(url)) return;\n injectedFonts.add(url);\n\n if (typeof document !== \"undefined\") {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = url;\n document.head.appendChild(link);\n }\n}\n\n/** Track which className CSS rules have been injected. */\nconst injectedClassRules = new Set<string>();\n\n/**\n * Inject a CSS rule that maps a className to a font-family.\n *\n * This is what makes `<div className={inter.className}>` apply the font.\n * Next.js generates equivalent rules at build time.\n *\n * In Next.js, the .className class ONLY sets font-family — it does NOT\n * set CSS variables. CSS variables are handled separately by the .variable class.\n */\nfunction injectClassNameRule(\n className: string,\n fontFamily: string,\n): void {\n if (injectedClassRules.has(className)) return;\n injectedClassRules.add(className);\n\n const css = `.${className} { font-family: ${fontFamily}; }\\n`;\n\n // On server, store the CSS for SSR injection\n if (typeof document === \"undefined\") {\n ssrFontStyles.push(css);\n return;\n }\n\n // On client, inject a <style> tag\n const style = document.createElement(\"style\");\n style.textContent = css;\n style.setAttribute(\"data-vinext-font-class\", className);\n document.head.appendChild(style);\n}\n\n/** Track which variable class CSS rules have been injected. */\nconst injectedVariableRules = new Set<string>();\n\n/** Track which :root CSS variable rules have been injected. */\nconst injectedRootVariables = new Set<string>();\n\n/**\n * Inject a CSS rule that sets a CSS variable on an element.\n * This is what makes `<html className={inter.variable}>` set the CSS variable\n * that can be referenced by other styles (e.g., Tailwind's font-sans).\n *\n * In Next.js, the .variable class ONLY sets the CSS variable — it does NOT\n * set font-family. This is critical because apps commonly apply multiple\n * .variable classes to <body> (e.g., geistSans.variable + geistMono.variable).\n * If we also set font-family here, the last class wins due to CSS cascade,\n * causing all text to use that font (e.g., everything becomes monospace).\n */\nfunction injectVariableClassRule(\n variableClassName: string,\n cssVarName: string,\n fontFamily: string,\n): void {\n if (injectedVariableRules.has(variableClassName)) return;\n injectedVariableRules.add(variableClassName);\n\n // Only set the CSS variable — do NOT set font-family.\n // This matches Next.js behavior where .variable classes only define CSS variables.\n let css = `.${variableClassName} { ${cssVarName}: ${fontFamily}; }\\n`;\n \n // Also inject at :root so CSS variable inheritance works throughout the page.\n // This ensures Tailwind utilities like `font-sans` that reference these\n // variables via var(--font-geist-sans) work correctly.\n if (!injectedRootVariables.has(cssVarName)) {\n injectedRootVariables.add(cssVarName);\n css += `:root { ${cssVarName}: ${fontFamily}; }\\n`;\n }\n\n // On server, store the CSS for SSR injection\n if (typeof document === \"undefined\") {\n ssrFontStyles.push(css);\n return;\n }\n\n // On client, inject a <style> tag\n const style = document.createElement(\"style\");\n style.textContent = css;\n style.setAttribute(\"data-vinext-font-variable\", variableClassName);\n document.head.appendChild(style);\n}\n\n// SSR: collect font class CSS for injection in <head>\nconst ssrFontStyles: string[] = [];\n\n/**\n * Get collected SSR font class styles (used by the renderer).\n * Note: We don't clear the arrays because fonts are loaded at module import\n * time and need to persist across all requests in the Workers environment.\n */\nexport function getSSRFontStyles(): string[] {\n return [...ssrFontStyles];\n}\n\n// SSR: collect font URLs to inject in <head>\nconst ssrFontUrls: string[] = [];\n\n/**\n * Get collected SSR font URLs (used by the renderer).\n * Note: We don't clear the arrays because fonts are loaded at module import\n * time and need to persist across all requests in the Workers environment.\n */\nexport function getSSRFontLinks(): string[] {\n return [...ssrFontUrls];\n}\n\n// SSR: collect font file URLs for <link rel=\"preload\"> injection (self-hosted Google fonts)\nconst ssrFontPreloads: Array<{ href: string; type: string }> = [];\nconst ssrFontPreloadHrefs = new Set<string>();\n\n/**\n * Get collected SSR font preload data (used by the renderer).\n * Returns an array of { href, type } objects for emitting\n * <link rel=\"preload\" as=\"font\" ...> tags.\n */\nexport function getSSRFontPreloads(): Array<{ href: string; type: string }> {\n return [...ssrFontPreloads];\n}\n\n/**\n * Determine the MIME type for a font file based on its extension.\n */\nfunction getFontMimeType(pathOrUrl: string): string {\n if (pathOrUrl.endsWith(\".woff2\")) return \"font/woff2\";\n if (pathOrUrl.endsWith(\".woff\")) return \"font/woff\";\n if (pathOrUrl.endsWith(\".ttf\")) return \"font/ttf\";\n if (pathOrUrl.endsWith(\".otf\")) return \"font/opentype\";\n return \"font/woff2\";\n}\n\n/**\n * Extract font file URLs from @font-face CSS rules.\n * Parses url('...') references from the CSS text.\n */\nfunction extractFontUrlsFromCSS(css: string): string[] {\n const urls: string[] = [];\n const urlRegex = /url\\(['\"]?([^'\")]+)['\"]?\\)/g;\n let match: RegExpExecArray | null;\n while ((match = urlRegex.exec(css)) !== null) {\n const url = match[1];\n // Only collect absolute paths (starting with /) — these are self-hosted font files\n if (url && url.startsWith(\"/\")) {\n urls.push(url);\n }\n }\n return urls;\n}\n\n/**\n * Collect font file URLs from self-hosted CSS for preload link generation.\n * Only collects on the server (SSR). Deduplicates by href using a Set for O(1) lookups.\n */\nfunction collectFontPreloadsFromCSS(css: string): void {\n if (typeof document !== \"undefined\") return; // client-side, skip\n\n const urls = extractFontUrlsFromCSS(css);\n for (const href of urls) {\n if (!ssrFontPreloadHrefs.has(href)) {\n ssrFontPreloadHrefs.add(href);\n ssrFontPreloads.push({ href, type: getFontMimeType(href) });\n }\n }\n}\n\n/** Track injected self-hosted @font-face blocks (deduplicate) */\nconst injectedSelfHosted = new Set<string>();\n\n/**\n * Inject self-hosted @font-face CSS (from the build plugin).\n * This replaces the CDN <link> tag with inline CSS.\n */\nfunction injectSelfHostedCSS(css: string): void {\n if (injectedSelfHosted.has(css)) return;\n injectedSelfHosted.add(css);\n\n // Extract font file URLs for preload hints (SSR only)\n collectFontPreloadsFromCSS(css);\n\n if (typeof document === \"undefined\") {\n // SSR: add to collected styles\n ssrFontStyles.push(css);\n return;\n }\n\n // Client: inject <style> tag\n const style = document.createElement(\"style\");\n style.textContent = css;\n style.setAttribute(\"data-vinext-font-selfhosted\", \"true\");\n document.head.appendChild(style);\n}\n\nexport type FontLoader = (options?: FontOptions & { _selfHostedCSS?: string }) => FontResult;\n\nexport function createFontLoader(family: string): FontLoader {\n return function fontLoader(options: FontOptions & { _selfHostedCSS?: string } = {}): FontResult {\n const id = classCounter++;\n const className = `__font_${family.toLowerCase().replace(/\\s+/g, \"_\")}_${id}`;\n const fallback = options.fallback ?? [\"sans-serif\"];\n // Sanitize each fallback name to prevent CSS injection via crafted values\n const fontFamily = `'${escapeCSSString(family)}', ${fallback.map(sanitizeFallback).join(\", \")}`;\n // Validate CSS variable name — reject anything that could inject CSS.\n // Fall back to auto-generated name if invalid.\n const defaultVarName = toVarName(family);\n const cssVarName = options.variable ? (sanitizeCSSVarName(options.variable) ?? defaultVarName) : defaultVarName;\n // In Next.js, `variable` returns a CLASS NAME that sets the CSS variable.\n // Users apply this class to set the CSS variable on that element.\n const variableClassName = `__variable_${family.toLowerCase().replace(/\\s+/g, \"_\")}_${id}`;\n\n if (options._selfHostedCSS) {\n // Self-hosted mode: inject local @font-face CSS instead of CDN link\n injectSelfHostedCSS(options._selfHostedCSS);\n } else {\n // CDN mode: inject <link> to Google Fonts\n const url = buildGoogleFontsUrl(family, options);\n injectFontStylesheet(url);\n\n // On SSR, collect the URL for head injection\n if (typeof document === \"undefined\") {\n if (!ssrFontUrls.includes(url)) {\n ssrFontUrls.push(url);\n }\n }\n }\n\n // Inject a CSS rule that maps className to font-family.\n // This is what makes `<div className={inter.className}>` work.\n injectClassNameRule(className, fontFamily);\n \n // Inject a CSS rule for the variable class name.\n // This is what makes `<html className={inter.variable}>` set the CSS variable.\n injectVariableClassRule(variableClassName, cssVarName, fontFamily);\n\n return {\n className,\n style: { fontFamily },\n variable: variableClassName,\n };\n };\n}\n\n// Export a Proxy that creates font loaders for any Google Font family.\n// Usage: import { Inter } from 'next/font/google'\n// The proxy intercepts property access and returns a loader for that font.\nconst googleFonts = new Proxy(\n {} as Record<string, (options?: FontOptions) => FontResult>,\n {\n get(_target, prop: string) {\n if (prop === \"__esModule\") return true;\n if (prop === \"default\") return googleFonts;\n // Convert camelCase/PascalCase to proper font family name\n // e.g., \"Inter\" -> \"Inter\", \"RobotoMono\" -> \"Roboto Mono\"\n const family = prop.replace(/([a-z])([A-Z])/g, \"$1 $2\");\n return createFontLoader(family);\n },\n },\n);\n\nexport default googleFonts;\n"]}
@@ -1,122 +1,3 @@
1
- /**
2
- * next/font/google shim
3
- *
4
- * Provides a compatible shim for Next.js Google Fonts.
5
- *
6
- * Two modes:
7
- * 1. **Dev / CDN mode** (default): Loads fonts from Google Fonts CDN via <link> tags.
8
- * 2. **Self-hosted mode** (production build): The vinext:google-fonts Vite plugin
9
- * fetches font CSS + .woff2 files at build time, caches them locally, and injects
10
- * @font-face CSS pointing at local assets. No requests to Google at runtime.
11
- *
12
- * Usage:
13
- * import { Inter } from 'next/font/google';
14
- * const inter = Inter({ subsets: ['latin'], weight: ['400', '700'] });
15
- * // inter.className -> unique CSS class
16
- * // inter.style -> { fontFamily: "'Inter', sans-serif" }
17
- * // inter.variable -> CSS variable name like '--font-inter'
18
- */
19
- interface FontOptions {
20
- weight?: string | string[];
21
- style?: string | string[];
22
- subsets?: string[];
23
- display?: string;
24
- preload?: boolean;
25
- fallback?: string[];
26
- adjustFontFallback?: boolean | string;
27
- variable?: string;
28
- axes?: string[];
29
- }
30
- interface FontResult {
31
- className: string;
32
- style: {
33
- fontFamily: string;
34
- };
35
- variable?: string;
36
- }
37
- /**
38
- * Build a Google Fonts CSS URL.
39
- */
40
- declare function buildGoogleFontsUrl(family: string, options: FontOptions): string;
41
- /**
42
- * Get collected SSR font class styles (used by the renderer).
43
- * Note: We don't clear the arrays because fonts are loaded at module import
44
- * time and need to persist across all requests in the Workers environment.
45
- */
46
- export declare function getSSRFontStyles(): string[];
47
- /**
48
- * Get collected SSR font URLs (used by the renderer).
49
- * Note: We don't clear the arrays because fonts are loaded at module import
50
- * time and need to persist across all requests in the Workers environment.
51
- */
52
- export declare function getSSRFontLinks(): string[];
53
- /**
54
- * Get collected SSR font preload data (used by the renderer).
55
- * Returns an array of { href, type } objects for emitting
56
- * <link rel="preload" as="font" ...> tags.
57
- */
58
- export declare function getSSRFontPreloads(): Array<{
59
- href: string;
60
- type: string;
61
- }>;
62
- export { buildGoogleFontsUrl };
63
- declare const googleFonts: Record<string, (options?: FontOptions) => FontResult>;
64
- export default googleFonts;
65
- export declare const Inter: (options?: FontOptions & {
66
- _selfHostedCSS?: string;
67
- }) => FontResult;
68
- export declare const Roboto: (options?: FontOptions & {
69
- _selfHostedCSS?: string;
70
- }) => FontResult;
71
- export declare const Roboto_Mono: (options?: FontOptions & {
72
- _selfHostedCSS?: string;
73
- }) => FontResult;
74
- export declare const Open_Sans: (options?: FontOptions & {
75
- _selfHostedCSS?: string;
76
- }) => FontResult;
77
- export declare const Lato: (options?: FontOptions & {
78
- _selfHostedCSS?: string;
79
- }) => FontResult;
80
- export declare const Poppins: (options?: FontOptions & {
81
- _selfHostedCSS?: string;
82
- }) => FontResult;
83
- export declare const Montserrat: (options?: FontOptions & {
84
- _selfHostedCSS?: string;
85
- }) => FontResult;
86
- export declare const Source_Code_Pro: (options?: FontOptions & {
87
- _selfHostedCSS?: string;
88
- }) => FontResult;
89
- export declare const Noto_Sans: (options?: FontOptions & {
90
- _selfHostedCSS?: string;
91
- }) => FontResult;
92
- export declare const Raleway: (options?: FontOptions & {
93
- _selfHostedCSS?: string;
94
- }) => FontResult;
95
- export declare const Ubuntu: (options?: FontOptions & {
96
- _selfHostedCSS?: string;
97
- }) => FontResult;
98
- export declare const Nunito: (options?: FontOptions & {
99
- _selfHostedCSS?: string;
100
- }) => FontResult;
101
- export declare const Playfair_Display: (options?: FontOptions & {
102
- _selfHostedCSS?: string;
103
- }) => FontResult;
104
- export declare const Merriweather: (options?: FontOptions & {
105
- _selfHostedCSS?: string;
106
- }) => FontResult;
107
- export declare const PT_Sans: (options?: FontOptions & {
108
- _selfHostedCSS?: string;
109
- }) => FontResult;
110
- export declare const Fira_Code: (options?: FontOptions & {
111
- _selfHostedCSS?: string;
112
- }) => FontResult;
113
- export declare const JetBrains_Mono: (options?: FontOptions & {
114
- _selfHostedCSS?: string;
115
- }) => FontResult;
116
- export declare const Geist: (options?: FontOptions & {
117
- _selfHostedCSS?: string;
118
- }) => FontResult;
119
- export declare const Geist_Mono: (options?: FontOptions & {
120
- _selfHostedCSS?: string;
121
- }) => FontResult;
1
+ export { default, buildGoogleFontsUrl, getSSRFontLinks, getSSRFontStyles, getSSRFontPreloads } from "./font-google-base";
2
+ export * from "./font-google.generated";
122
3
  //# sourceMappingURL=font-google.d.ts.map
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