@timber-js/app 0.2.0-alpha.63 → 0.2.0-alpha.65

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.
@@ -1 +1 @@
1
- {"version":3,"file":"dev-browser-logs.d.ts","sourceRoot":"","sources":["../../src/plugins/dev-browser-logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,kEAAkE;AAClE,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,eAAe,CAAC;IACvB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gDAAgD;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AA6BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAsBnE;AAID;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,eAAe,GAAG,MAAM,GAClC,OAAO,CAGT;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMzE;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,GAAG,MAAM,CAgEhF;AAID;;;;;;;G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A6D/D"}
@@ -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,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAmB3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,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,CAwVtD"}
1
+ {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"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CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAmEjD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA+KvD"}
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,42 @@
1
+ //#region src/shims/font-google.ts
2
+ /**
3
+ * Create a stub FontResult with empty values.
4
+ *
5
+ * The timber-fonts plugin replaces these calls at build time with real
6
+ * class names and font stacks. This stub ensures code that imports
7
+ * font functions outside of the build pipeline (tests, type-checking)
8
+ * gets a valid FontResult shape without runtime errors.
9
+ */
10
+ function createStubFontResult(config) {
11
+ return {
12
+ className: "",
13
+ style: { fontFamily: "" },
14
+ variable: config?.variable
15
+ };
16
+ }
17
+ /**
18
+ * Generic font loader — accepts any font name, returns a stub FontResult.
19
+ *
20
+ * Named exports like `Inter`, `Roboto`, etc. are generated dynamically
21
+ * by the virtual module at build time. This function provides a catch-all
22
+ * for non-Vite contexts.
23
+ */
24
+ function createFont(_family, config) {
25
+ return createStubFontResult(config);
26
+ }
27
+ var Inter = (config) => createStubFontResult(config);
28
+ var Roboto = (config) => createStubFontResult(config);
29
+ var Open_Sans = (config) => createStubFontResult(config);
30
+ var Lato = (config) => createStubFontResult(config);
31
+ var Montserrat = (config) => createStubFontResult(config);
32
+ var Poppins = (config) => createStubFontResult(config);
33
+ var Geist = (config) => createStubFontResult(config);
34
+ var Geist_Mono = (config) => createStubFontResult(config);
35
+ var JetBrains_Mono = (config) => createStubFontResult(config);
36
+ var Source_Code_Pro = (config) => createStubFontResult(config);
37
+ var Playfair_Display = (config) => createStubFontResult(config);
38
+ var Merriweather = (config) => createStubFontResult(config);
39
+ //#endregion
40
+ export { Geist, Geist_Mono, Inter, JetBrains_Mono, Lato, Merriweather, Montserrat, Open_Sans, Playfair_Display, Poppins, Roboto, Source_Code_Pro, createFont };
41
+
42
+ //# sourceMappingURL=font-google.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-google.js","names":[],"sources":["../../src/shims/font-google.ts"],"sourcesContent":["/**\n * Fallback shim for `next/font/google` → `@timber/fonts/google`.\n *\n * At build time, the timber-fonts plugin's transform hook replaces font\n * function calls with static FontResult objects containing real class names\n * and font stacks. This file serves two purposes:\n *\n * 1. **TypeScript resolution** — provides types for IDEs and `tsc` outside\n * of Vite's module graph (where the virtual module handles it).\n * 2. **Runtime fallback** — returns empty className/fontFamily values when\n * the plugin hasn't processed a call (e.g. in tests or non-Vite environments).\n *\n * The shim resolution path (`next/font/google` → `\\0@timber/fonts/google`)\n * is unchanged — this file is NOT on that resolution path. It exists as a\n * physical module for direct imports and type re-exports.\n *\n * Design doc: 24-fonts.md, \"Next.js Font Compatibility\"\n */\n\nimport type { GoogleFontConfig, FontResult } from '../fonts/types.js';\n\nexport type { GoogleFontConfig, FontResult };\n\n/**\n * Create a stub FontResult with empty values.\n *\n * The timber-fonts plugin replaces these calls at build time with real\n * class names and font stacks. This stub ensures code that imports\n * font functions outside of the build pipeline (tests, type-checking)\n * gets a valid FontResult shape without runtime errors.\n */\nfunction createStubFontResult(config?: GoogleFontConfig): FontResult {\n return {\n className: '',\n style: { fontFamily: '' },\n variable: config?.variable,\n };\n}\n\n/**\n * Generic font loader — accepts any font name, returns a stub FontResult.\n *\n * Named exports like `Inter`, `Roboto`, etc. are generated dynamically\n * by the virtual module at build time. This function provides a catch-all\n * for non-Vite contexts.\n */\nexport function createFont(_family: string, config?: GoogleFontConfig): FontResult {\n return createStubFontResult(config);\n}\n\n// Common Google Font exports for TypeScript autocomplete.\n// These are stubs — the virtual module and transform hook provide real values.\nexport const Inter = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Roboto = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Open_Sans = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Lato = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Montserrat = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Poppins = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Geist = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const Geist_Mono = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\nexport const JetBrains_Mono = (config?: GoogleFontConfig): FontResult =>\n createStubFontResult(config);\nexport const Source_Code_Pro = (config?: GoogleFontConfig): FontResult =>\n createStubFontResult(config);\nexport const Playfair_Display = (config?: GoogleFontConfig): FontResult =>\n createStubFontResult(config);\nexport const Merriweather = (config?: GoogleFontConfig): FontResult => createStubFontResult(config);\n"],"mappings":";;;;;;;;;AA+BA,SAAS,qBAAqB,QAAuC;AACnE,QAAO;EACL,WAAW;EACX,OAAO,EAAE,YAAY,IAAI;EACzB,UAAU,QAAQ;EACnB;;;;;;;;;AAUH,SAAgB,WAAW,SAAiB,QAAuC;AACjF,QAAO,qBAAqB,OAAO;;AAKrC,IAAa,SAAS,WAA0C,qBAAqB,OAAO;AAC5F,IAAa,UAAU,WAA0C,qBAAqB,OAAO;AAC7F,IAAa,aAAa,WAA0C,qBAAqB,OAAO;AAChG,IAAa,QAAQ,WAA0C,qBAAqB,OAAO;AAC3F,IAAa,cAAc,WAA0C,qBAAqB,OAAO;AACjG,IAAa,WAAW,WAA0C,qBAAqB,OAAO;AAC9F,IAAa,SAAS,WAA0C,qBAAqB,OAAO;AAC5F,IAAa,cAAc,WAA0C,qBAAqB,OAAO;AACjG,IAAa,kBAAkB,WAC7B,qBAAqB,OAAO;AAC9B,IAAa,mBAAmB,WAC9B,qBAAqB,OAAO;AAC9B,IAAa,oBAAoB,WAC/B,qBAAqB,OAAO;AAC9B,IAAa,gBAAgB,WAA0C,qBAAqB,OAAO"}
@@ -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"}
@@ -0,0 +1,20 @@
1
+ //#region src/shims/font-local.ts
2
+ /**
3
+ * Create a local font.
4
+ *
5
+ * The timber-fonts plugin replaces these calls at build time with real
6
+ * class names and font stacks. This stub ensures code that imports
7
+ * `localFont` outside of the build pipeline (tests, type-checking)
8
+ * gets a valid FontResult shape without runtime errors.
9
+ */
10
+ function localFont(config) {
11
+ return {
12
+ className: "",
13
+ style: { fontFamily: "" },
14
+ variable: config?.variable
15
+ };
16
+ }
17
+ //#endregion
18
+ export { localFont as default };
19
+
20
+ //# sourceMappingURL=font-local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-local.js","names":[],"sources":["../../src/shims/font-local.ts"],"sourcesContent":["/**\n * Fallback shim for `next/font/local` → `@timber/fonts/local`.\n *\n * At build time, the timber-fonts plugin's transform hook replaces\n * `localFont()` calls with static FontResult objects containing real\n * class names and font stacks. This file serves two purposes:\n *\n * 1. **TypeScript resolution** — provides types for IDEs and `tsc` outside\n * of Vite's module graph (where the virtual module handles it).\n * 2. **Runtime fallback** — returns empty className/fontFamily values when\n * the plugin hasn't processed a call (e.g. in tests or non-Vite environments).\n *\n * Design doc: 24-fonts.md, \"Next.js Font Compatibility\"\n */\n\nimport type { LocalFontConfig, FontResult } from '../fonts/types.js';\n\nexport type { LocalFontConfig, FontResult };\n\n/**\n * Create a local font.\n *\n * The timber-fonts plugin replaces these calls at build time with real\n * class names and font stacks. This stub ensures code that imports\n * `localFont` outside of the build pipeline (tests, type-checking)\n * gets a valid FontResult shape without runtime errors.\n */\nexport default function localFont(config?: LocalFontConfig): FontResult {\n return {\n className: '',\n style: { fontFamily: '' },\n variable: config?.variable,\n };\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAwB,UAAU,QAAsC;AACtE,QAAO;EACL,WAAW;EACX,OAAO,EAAE,YAAY,IAAI;EACzB,UAAU,QAAQ;EACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.63",
3
+ "version": "0.2.0-alpha.65",
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": {
@@ -231,7 +231,11 @@ export function timberDevBrowserLogs(ctx: PluginContext): Plugin {
231
231
 
232
232
  configureServer(server: ViteDevServer) {
233
233
  const threshold = ctx.config.devBrowserLogs ?? 'warn';
234
- if (threshold === 'none') return;
234
+ if (threshold === 'none') {
235
+ // Clear any stale script from a prior server instance (e.g. HMR reconfigure)
236
+ delete (globalThis as Record<string, unknown>).__timber_dev_browser_log_script;
237
+ return;
238
+ }
235
239
 
236
240
  // Register the client injection script on globalThis so the RSC entry
237
241
  // can include it in headHtml for all Timber route responses.
@@ -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') || code.includes('next/font/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') || code.includes('next/font/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
  }
@@ -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/* redirects to the timber-fonts virtual modules.
72
- // The fonts plugin's load hook serves the actual module code.
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
+ }