@timber-js/app 0.2.0-alpha.63 → 0.2.0-alpha.64
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.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/shims/font-local.d.ts +26 -0
- package/dist/shims/font-local.d.ts.map +1 -0
- package/package.json +9 -1
- package/src/plugins/fonts.ts +10 -6
- package/src/plugins/shims.ts +6 -2
- package/src/shims/font-local.ts +34 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAmCzE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AA4CtD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAE5F;AAUD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB/D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAqB3E;AAwED;;;;;GAKG;AACH,wBAAgB,eA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Q,EAAE,YAAY,GAAG,MAAM,CAMjE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKtE;AAqED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CA4VtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuEjD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA+KvD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback shim for `next/font/local` → `@timber/fonts/local`.
|
|
3
|
+
*
|
|
4
|
+
* At build time, the timber-fonts plugin's transform hook replaces
|
|
5
|
+
* `localFont()` calls with static FontResult objects containing real
|
|
6
|
+
* class names and font stacks. This file serves two purposes:
|
|
7
|
+
*
|
|
8
|
+
* 1. **TypeScript resolution** — provides types for IDEs and `tsc` outside
|
|
9
|
+
* of Vite's module graph (where the virtual module handles it).
|
|
10
|
+
* 2. **Runtime fallback** — returns empty className/fontFamily values when
|
|
11
|
+
* the plugin hasn't processed a call (e.g. in tests or non-Vite environments).
|
|
12
|
+
*
|
|
13
|
+
* Design doc: 24-fonts.md, "Next.js Font Compatibility"
|
|
14
|
+
*/
|
|
15
|
+
import type { LocalFontConfig, FontResult } from '../fonts/types.js';
|
|
16
|
+
export type { LocalFontConfig, FontResult };
|
|
17
|
+
/**
|
|
18
|
+
* Create a local font.
|
|
19
|
+
*
|
|
20
|
+
* The timber-fonts plugin replaces these calls at build time with real
|
|
21
|
+
* class names and font stacks. This stub ensures code that imports
|
|
22
|
+
* `localFont` outside of the build pipeline (tests, type-checking)
|
|
23
|
+
* gets a valid FontResult shape without runtime errors.
|
|
24
|
+
*/
|
|
25
|
+
export default function localFont(config?: LocalFontConfig): FontResult;
|
|
26
|
+
//# sourceMappingURL=font-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-local.d.ts","sourceRoot":"","sources":["../../src/shims/font-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAErE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAMtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.64",
|
|
4
4
|
"description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
|
@@ -75,6 +75,14 @@
|
|
|
75
75
|
"types": "./dist/adapters/nitro.d.ts",
|
|
76
76
|
"import": "./dist/adapters/nitro.js"
|
|
77
77
|
},
|
|
78
|
+
"./fonts/google": {
|
|
79
|
+
"types": "./dist/shims/font-google.d.ts",
|
|
80
|
+
"import": "./dist/shims/font-google.js"
|
|
81
|
+
},
|
|
82
|
+
"./fonts/local": {
|
|
83
|
+
"types": "./dist/shims/font-local.d.ts",
|
|
84
|
+
"import": "./dist/shims/font-local.js"
|
|
85
|
+
},
|
|
78
86
|
"./package.json": "./package.json"
|
|
79
87
|
},
|
|
80
88
|
"publishConfig": {
|
package/src/plugins/fonts.ts
CHANGED
|
@@ -134,7 +134,7 @@ export function detectDynamicFontCall(source: string, importedNames: string[]):
|
|
|
134
134
|
* but the source code still contains the original import specifier.
|
|
135
135
|
*/
|
|
136
136
|
const GOOGLE_FONT_IMPORT_RE =
|
|
137
|
-
/import\s*\{([^}]+)\}\s*from\s*['"](?:@timber\/fonts\/google|next\/font\/google)['"]/g;
|
|
137
|
+
/import\s*\{([^}]+)\}\s*from\s*['"](?:@timber\/fonts\/google|@timber-js\/app\/fonts\/google|next\/font\/google)['"]/g;
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Parse import specifiers from a source file that imports from
|
|
@@ -311,7 +311,7 @@ export function generateAllFontCss(registry: FontRegistry): string {
|
|
|
311
311
|
*/
|
|
312
312
|
export function parseLocalFontImportName(source: string): string | null {
|
|
313
313
|
const match = source.match(
|
|
314
|
-
/import\s+(\w+)\s+from\s*['"](?:@timber\/fonts\/local|next\/font\/local)['"]/
|
|
314
|
+
/import\s+(\w+)\s+from\s*['"](?:@timber\/fonts\/local|@timber-js\/app\/fonts\/local|next\/font\/local)['"]/
|
|
315
315
|
);
|
|
316
316
|
return match ? match[1] : null;
|
|
317
317
|
}
|
|
@@ -376,7 +376,7 @@ function transformLocalFonts(
|
|
|
376
376
|
|
|
377
377
|
// Remove the import statement
|
|
378
378
|
transformedCode = transformedCode.replace(
|
|
379
|
-
/import\s+\w+\s+from\s*['"](?:@timber\/fonts\/local|next\/font\/local)['"];?\s*\n?/g,
|
|
379
|
+
/import\s+\w+\s+from\s*['"](?:@timber\/fonts\/local|@timber-js\/app\/fonts\/local|next\/font\/local)['"];?\s*\n?/g,
|
|
380
380
|
''
|
|
381
381
|
);
|
|
382
382
|
|
|
@@ -532,9 +532,13 @@ export function timberFonts(ctx: PluginContext): Plugin {
|
|
|
532
532
|
if (id.startsWith('\0') || id.includes('node_modules')) return null;
|
|
533
533
|
|
|
534
534
|
const hasGoogleImport =
|
|
535
|
-
code.includes('@timber/fonts/google') ||
|
|
535
|
+
code.includes('@timber/fonts/google') ||
|
|
536
|
+
code.includes('@timber-js/app/fonts/google') ||
|
|
537
|
+
code.includes('next/font/google');
|
|
536
538
|
const hasLocalImport =
|
|
537
|
-
code.includes('@timber/fonts/local') ||
|
|
539
|
+
code.includes('@timber/fonts/local') ||
|
|
540
|
+
code.includes('@timber-js/app/fonts/local') ||
|
|
541
|
+
code.includes('next/font/local');
|
|
538
542
|
if (!hasGoogleImport && !hasLocalImport) return null;
|
|
539
543
|
|
|
540
544
|
let transformedCode = code;
|
|
@@ -606,7 +610,7 @@ export function timberFonts(ctx: PluginContext): Plugin {
|
|
|
606
610
|
}
|
|
607
611
|
|
|
608
612
|
transformedCode = transformedCode.replace(
|
|
609
|
-
/import\s*\{[^}]+\}\s*from\s*['"](?:@timber\/fonts\/google|next\/font\/google)['"];?\s*\n?/g,
|
|
613
|
+
/import\s*\{[^}]+\}\s*from\s*['"](?:@timber\/fonts\/google|@timber-js\/app\/fonts\/google|next\/font\/google)['"];?\s*\n?/g,
|
|
610
614
|
''
|
|
611
615
|
);
|
|
612
616
|
}
|
package/src/plugins/shims.ts
CHANGED
|
@@ -68,10 +68,14 @@ const SHIM_MAP: Record<string, string> = {
|
|
|
68
68
|
'next/image': resolve(SHIMS_DIR, 'image.ts'),
|
|
69
69
|
'next/navigation': resolve(SHIMS_DIR, 'navigation.ts'),
|
|
70
70
|
'next/headers': resolve(SHIMS_DIR, 'headers.ts'),
|
|
71
|
-
// next/font/*
|
|
72
|
-
// The fonts plugin's load hook serves the actual module
|
|
71
|
+
// next/font/* and @timber-js/app/fonts/* redirect to the timber-fonts
|
|
72
|
+
// virtual modules. The fonts plugin's load hook serves the actual module
|
|
73
|
+
// code. The package.json exports point to shim stubs for non-Vite contexts
|
|
74
|
+
// (tsc, tests), but in Vite the virtual module takes priority via this map.
|
|
73
75
|
'next/font/google': '\0@timber/fonts/google',
|
|
74
76
|
'next/font/local': '\0@timber/fonts/local',
|
|
77
|
+
'@timber-js/app/fonts/google': '\0@timber/fonts/google',
|
|
78
|
+
'@timber-js/app/fonts/local': '\0@timber/fonts/local',
|
|
75
79
|
};
|
|
76
80
|
|
|
77
81
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback shim for `next/font/local` → `@timber/fonts/local`.
|
|
3
|
+
*
|
|
4
|
+
* At build time, the timber-fonts plugin's transform hook replaces
|
|
5
|
+
* `localFont()` calls with static FontResult objects containing real
|
|
6
|
+
* class names and font stacks. This file serves two purposes:
|
|
7
|
+
*
|
|
8
|
+
* 1. **TypeScript resolution** — provides types for IDEs and `tsc` outside
|
|
9
|
+
* of Vite's module graph (where the virtual module handles it).
|
|
10
|
+
* 2. **Runtime fallback** — returns empty className/fontFamily values when
|
|
11
|
+
* the plugin hasn't processed a call (e.g. in tests or non-Vite environments).
|
|
12
|
+
*
|
|
13
|
+
* Design doc: 24-fonts.md, "Next.js Font Compatibility"
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { LocalFontConfig, FontResult } from '../fonts/types.js';
|
|
17
|
+
|
|
18
|
+
export type { LocalFontConfig, FontResult };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a local font.
|
|
22
|
+
*
|
|
23
|
+
* The timber-fonts plugin replaces these calls at build time with real
|
|
24
|
+
* class names and font stacks. This stub ensures code that imports
|
|
25
|
+
* `localFont` outside of the build pipeline (tests, type-checking)
|
|
26
|
+
* gets a valid FontResult shape without runtime errors.
|
|
27
|
+
*/
|
|
28
|
+
export default function localFont(config?: LocalFontConfig): FontResult {
|
|
29
|
+
return {
|
|
30
|
+
className: '',
|
|
31
|
+
style: { fontFamily: '' },
|
|
32
|
+
variable: config?.variable,
|
|
33
|
+
};
|
|
34
|
+
}
|