@timber-js/app 0.2.0-alpha.150 → 0.2.0-alpha.152

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":"route-element-builder.d.ts","sourceRoot":"","sources":["../../src/server/route-element-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA0B9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAyCzD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAM7D;AAID;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAID,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACvC;AAED,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,2CAA2C;IAC3C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,wDAAwD;IACxD,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,qCAAqC;IACrC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM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AAK,CAAC,YAAY,CAAC;IAC5B,2CAA2C;IAC3C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,wDAAwD;IACxD,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,qCAAqC;IACrC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AA8DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,YAAY,CAAC,EAAE,mBAAmB,EAClC,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,kBAAkB,CAAC,CAse7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.150",
3
+ "version": "0.2.0-alpha.152",
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",
@@ -15,7 +15,7 @@
15
15
  import type { Plugin, ViteDevServer, DevEnvironment } from 'vite';
16
16
  import type { IncomingMessage, ServerResponse } from 'node:http';
17
17
  import type { TLSSocket } from 'node:tls';
18
- import { existsSync } from 'node:fs';
18
+ import { existsSync, statSync } from 'node:fs';
19
19
  import { join } from 'node:path';
20
20
  import type { PluginContext } from '../plugin-context.js';
21
21
  import {
@@ -164,6 +164,16 @@ function createTimberMiddleware(server: ViteDevServer, ctx: PluginContext) {
164
164
  return;
165
165
  }
166
166
 
167
+ // Files that exist in public/ are always served by Vite's static
168
+ // middleware, regardless of extension. Without this, extensions like
169
+ // .ico, .txt, .xml, .html either get caught by the metadata route
170
+ // check or aren't in ASSET_EXTENSIONS, so they fall through to the
171
+ // app router where a dynamic segment like [artistSlug] 404s them.
172
+ if (isPublicFile(server, url)) {
173
+ next();
174
+ return;
175
+ }
176
+
167
177
  // Pass through static asset requests — but not metadata routes like
168
178
  // /favicon.ico that match asset extensions but are handled by timber,
169
179
  // and not registered routes like app/feed.json/route.ts whose URL ends
@@ -521,6 +531,25 @@ function isAssetRequest(url: string): boolean {
521
531
  return ASSET_EXTENSIONS.test(url);
522
532
  }
523
533
 
534
+ /**
535
+ * Check if a URL maps to a real file in the project's public/ directory.
536
+ * Vite serves public/ files as static assets — if a file exists there it
537
+ * must be passed through to Vite regardless of extension.
538
+ */
539
+ function isPublicFile(server: ViteDevServer, url: string): boolean {
540
+ const { publicDir } = server.config;
541
+ if (!publicDir) return false;
542
+ const pathname = url.split('?')[0];
543
+ const relativePath = pathname.startsWith('/') ? pathname.slice(1) : pathname;
544
+ if (!relativePath) return false;
545
+ const fullPath = join(publicDir, relativePath);
546
+ try {
547
+ return statSync(fullPath).isFile();
548
+ } catch {
549
+ return false;
550
+ }
551
+ }
552
+
524
553
  /**
525
554
  * Check whether an asset-extension URL belongs to a scanned route rather
526
555
  * than a static file.
@@ -606,7 +606,10 @@ export async function buildRouteElement(
606
606
  );
607
607
  }
608
608
 
609
- const segmentPath = segment.urlPath.split('/');
609
+ // '/'.split('/') → ['', ''] (length 2), but root should be [''] (length 1).
610
+ // The extra empty string makes useSelectedLayoutSegment skip the first URL segment.
611
+ const rawPath = segment.urlPath.split('/');
612
+ const segmentPath = rawPath.length === 2 && rawPath[1] === '' ? [''] : rawPath;
610
613
  const parallelRouteKeys = Object.keys(segment.slots ?? {});
611
614
 
612
615
  // For route groups, urlPath is shared with the parent (both "/"),