@timber-js/app 0.2.0-alpha.184 → 0.2.0-alpha.185

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 (61) hide show
  1. package/dist/_chunks/{cli-schema-sync-D3naS3eH.js → cli-schema-sync-BTWEKJXo.js} +1 -21
  2. package/dist/_chunks/cli-schema-sync-BTWEKJXo.js.map +1 -0
  3. package/dist/_chunks/logger-AWfuX-KJ.js.map +1 -1
  4. package/dist/_chunks/plugin-context---kTF5v8.js.map +1 -1
  5. package/dist/_chunks/segment-classify-Byy425ng.js.map +1 -1
  6. package/dist/_chunks/{walkers-BtTlKviE.js → walkers-_6zKFlch.js} +2 -2
  7. package/dist/_chunks/{walkers-BtTlKviE.js.map → walkers-_6zKFlch.js.map} +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/client/internal.js +36 -28
  10. package/dist/client/internal.js.map +1 -1
  11. package/dist/client/router.d.ts.map +1 -1
  12. package/dist/client/rsc-fetch.d.ts +11 -1
  13. package/dist/client/rsc-fetch.d.ts.map +1 -1
  14. package/dist/index.js +25 -15
  15. package/dist/index.js.map +1 -1
  16. package/dist/plugin-context.d.ts +2 -1
  17. package/dist/plugin-context.d.ts.map +1 -1
  18. package/dist/plugins/static-build.d.ts +19 -6
  19. package/dist/plugins/static-build.d.ts.map +1 -1
  20. package/dist/routing/index.js +2 -2
  21. package/dist/routing/manifest-codegen.d.ts.map +1 -1
  22. package/dist/routing/scanner.d.ts.map +1 -1
  23. package/dist/routing/types.d.ts +1 -3
  24. package/dist/routing/types.d.ts.map +1 -1
  25. package/dist/server/deny-boundary.d.ts +4 -7
  26. package/dist/server/deny-boundary.d.ts.map +1 -1
  27. package/dist/server/internal.js +135 -161
  28. package/dist/server/internal.js.map +1 -1
  29. package/dist/server/prebuilt-builder.d.ts.map +1 -1
  30. package/dist/server/primitives.d.ts +0 -12
  31. package/dist/server/primitives.d.ts.map +1 -1
  32. package/dist/server/sitemap-generator.d.ts.map +1 -1
  33. package/dist/server/static-generator.d.ts.map +1 -1
  34. package/dist/server/status-code-resolver.d.ts +3 -10
  35. package/dist/server/status-code-resolver.d.ts.map +1 -1
  36. package/dist/shims/navigation-client.d.ts +8 -19
  37. package/dist/shims/navigation-client.d.ts.map +1 -1
  38. package/dist/shims/navigation.d.ts +0 -1
  39. package/dist/shims/navigation.d.ts.map +1 -1
  40. package/docs/learn/11-error-handling.mdx +2 -3
  41. package/package.json +1 -1
  42. package/src/client/router.ts +24 -7
  43. package/src/client/rsc-fetch.ts +37 -46
  44. package/src/plugin-context.ts +2 -1
  45. package/src/plugins/routing.ts +1 -1
  46. package/src/plugins/static-build.ts +47 -19
  47. package/src/routing/manifest-codegen.ts +1 -6
  48. package/src/routing/scanner.ts +0 -24
  49. package/src/routing/types.ts +1 -3
  50. package/src/server/deny-boundary.ts +5 -31
  51. package/src/server/deny-renderer.ts +2 -2
  52. package/src/server/pipeline-outcome.ts +1 -1
  53. package/src/server/prebuilt-builder.ts +1 -7
  54. package/src/server/primitives.ts +0 -18
  55. package/src/server/rsc-entry/render-route.ts +3 -3
  56. package/src/server/sitemap-generator.ts +1 -7
  57. package/src/server/static-generator.ts +2 -18
  58. package/src/server/status-code-resolver.ts +4 -47
  59. package/src/shims/navigation-client.ts +8 -26
  60. package/src/shims/navigation.ts +0 -4
  61. package/dist/_chunks/cli-schema-sync-D3naS3eH.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as __esmMin, o as __exportAll, s as __toCommonJS } from "./_chunks/dist-BA3u1z3W.js";
2
2
  import { c as isDynamicMetadataExtension, l as isMetadataRouteServePath, r as canonicalize } from "./_chunks/canonicalize-DQHyFClh.js";
3
3
  import { h as swallow } from "./_chunks/logger-AWfuX-KJ.js";
4
- import { i as scanRoutes } from "./_chunks/cli-schema-sync-D3naS3eH.js";
5
- import { a as generateRouteMap, c as fileHasDirective, d as getPrerenderExport, i as validateSchemaAgainstRoutes, l as fileHasExport, n as collectInterceptionRewrites, o as fileHasAnyExport, s as fileHasDefaultExport, t as collectLeafRoutes, u as fileHasStarExport } from "./_chunks/walkers-BtTlKviE.js";
4
+ import { i as scanRoutes } from "./_chunks/cli-schema-sync-BTWEKJXo.js";
5
+ import { a as generateRouteMap, c as fileHasDirective, d as getPrerenderExport, i as validateSchemaAgainstRoutes, l as fileHasExport, n as collectInterceptionRewrites, o as fileHasAnyExport, s as fileHasDefaultExport, t as collectLeafRoutes, u as fileHasStarExport } from "./_chunks/walkers-_6zKFlch.js";
6
6
  import { a as resolveAppDir, c as createNoopTimer, n as loadTimberConfigFile, o as resolveBuildDir, r as mergeFileConfig, s as resolveClientJavascript, t as createPluginContext } from "./_chunks/plugin-context---kTF5v8.js";
7
7
  import { t as fnv1aHash } from "./_chunks/fast-hash-D6hIVt1Y.js";
8
8
  import { t as formatSize } from "./_chunks/format-CfwjgPz9.js";
@@ -2401,7 +2401,6 @@ var SINGLE_FILE_KEYS = [
2401
2401
  var RECORD_FILE_KEYS = [
2402
2402
  "statusFiles",
2403
2403
  "jsonStatusFiles",
2404
- "legacyStatusFiles",
2405
2404
  "metadataRoutes"
2406
2405
  ];
2407
2406
  var SCHEMA_EXTENSIONS = [
@@ -2829,7 +2828,7 @@ var SEGMENT_PREFIX = "\0$segment:";
2829
2828
  /**
2830
2829
  * File convention names we track for changes that require manifest regeneration.
2831
2830
  */
2832
- var ROUTE_FILE_PATTERNS = /\/(page|layout|middleware|access|route|error|global-error|default|denied|params|schema|\d{3}|[45]xx|not-found|forbidden|unauthorized|sitemap|robots|manifest|favicon|icon|opengraph-image|apple-icon)\./;
2831
+ var ROUTE_FILE_PATTERNS = /\/(page|layout|middleware|access|route|error|global-error|default|denied|params|schema|\d{3}|[45]xx|sitemap|robots|manifest|favicon|icon|opengraph-image|apple-icon)\./;
2833
2832
  /**
2834
2833
  * Create the timber-routing Vite plugin.
2835
2834
  *
@@ -6716,6 +6715,7 @@ async function runStaticGeneration(ctx) {
6716
6715
  const sitemapConfig = ctx.config.sitemap;
6717
6716
  const autoSitemapEnabled = Boolean(sitemapConfig?.enabled && sitemapConfig?.baseUrl);
6718
6717
  const contentTypes = {};
6718
+ const routeParams = {};
6719
6719
  const summary = await generate({
6720
6720
  autoSitemapEnabled,
6721
6721
  renderTimeoutMs: ctx.config.renderTimeoutMs,
@@ -6726,7 +6726,12 @@ async function runStaticGeneration(ctx) {
6726
6726
  if (rel.startsWith("..") || resolve(staticDir, rel) !== fullPath) throw new Error(`[timber] Static generation: output path "${relPath}" escapes the static output directory — check generateStaticSegmentParams for path traversal characters in ${entry.urlPath}`);
6727
6727
  await mkdir(dirname(fullPath), { recursive: true });
6728
6728
  await writeFileAtomic$1(fullPath, entry.body);
6729
- if (entry.kind === "rsc" && entry.headers["x-timber-params"]) await writeFileAtomic$1(fullPath.replace(/\.rsc$/, ".params.json"), entry.headers["x-timber-params"]);
6729
+ if (entry.kind === "rsc" && entry.headers["x-timber-params"]) {
6730
+ const rscUrlKey = entry.urlPath === "/" ? "/_rsc/index.rsc" : `/_rsc${entry.urlPath}.rsc`;
6731
+ try {
6732
+ routeParams[rscUrlKey] = JSON.parse(entry.headers["x-timber-params"]);
6733
+ } catch {}
6734
+ }
6730
6735
  if (entry.kind === "api" && !extname(relPath) && entry.contentType) contentTypes[entry.urlPath] = entry.contentType;
6731
6736
  }
6732
6737
  });
@@ -6738,7 +6743,7 @@ async function runStaticGeneration(ctx) {
6738
6743
  }
6739
6744
  if (Object.keys(contentTypes).length > 0) ctx.staticContentTypes = contentTypes;
6740
6745
  if (!ctx.clientJavascript.disabled) {
6741
- const rscManifest = await hashRscPayloads(staticDir);
6746
+ const rscManifest = await hashRscPayloads(staticDir, routeParams);
6742
6747
  if (Object.keys(rscManifest).length > 0) {
6743
6748
  await injectRscManifestIntoHtml(staticDir, rscManifest);
6744
6749
  ctx.rscManifest = rscManifest;
@@ -6785,32 +6790,37 @@ async function walkDir(dir) {
6785
6790
  return results;
6786
6791
  }
6787
6792
  /**
6788
- * Hash all RSC flight payloads and params sidecars in `_rsc/`, rename
6789
- * them with content hashes, and inject a manifest into each HTML file.
6793
+ * Hash all RSC flight payloads in `_rsc/`, rename them with content
6794
+ * hashes, and build a manifest with optional inlined route params.
6790
6795
  *
6791
6796
  * Before: `_rsc/index.rsc`, `_rsc/about.rsc`
6792
6797
  * After: `_rsc/index-B7YxEKdN.rsc`, `_rsc/about-C8ZzFLfO.rsc`
6793
6798
  *
6794
- * The manifest maps the original `_rsc/` URL to the hashed filename:
6795
- * `{"/_rsc/index.rsc":"/_rsc/index-B7YxEKdN.rsc", ...}`
6799
+ * The manifest maps the original `_rsc/` URL to an entry object:
6800
+ * `{"/_rsc/index.rsc":{"url":"/_rsc/index-B7YxEKdN.rsc"}, ...}`
6801
+ *
6802
+ * Route params (from `routeParams`) are inlined into the manifest
6803
+ * entry, eliminating the need for .params.json sidecar files. TIM-1255.
6796
6804
  *
6797
6805
  * Injected into HTML as:
6798
6806
  * `<script>window.__TIMBER_RSC_MANIFEST__={...}<\/script>`
6799
6807
  *
6800
6808
  * @internal Exported for testing.
6801
6809
  */
6802
- async function hashRscPayloads(staticDir) {
6810
+ async function hashRscPayloads(staticDir, routeParams) {
6803
6811
  const files = await walkDir(join(staticDir, "_rsc"));
6804
6812
  const manifest = {};
6805
6813
  for (const filePath of files) {
6806
- if (!filePath.endsWith(".rsc") && !filePath.endsWith(".params.json")) continue;
6814
+ if (!filePath.endsWith(".rsc")) continue;
6807
6815
  const hash = contentHash(await readFile(filePath));
6808
6816
  const rel = relative(staticDir, filePath).replace(/\\/g, "/");
6809
- const ext = filePath.endsWith(".params.json") ? ".params.json" : ".rsc";
6810
- const hashedPath = `${filePath.slice(0, -ext.length)}-${hash}${ext}`;
6817
+ const hashedPath = `${filePath.slice(0, -4)}-${hash}.rsc`;
6811
6818
  await rename(filePath, hashedPath);
6812
6819
  const hashedRel = relative(staticDir, hashedPath).replace(/\\/g, "/");
6813
- manifest[`/${rel}`] = `/${hashedRel}`;
6820
+ const key = `/${rel}`;
6821
+ const entry = { url: `/${hashedRel}` };
6822
+ if (routeParams?.[key]) entry.params = routeParams[key];
6823
+ manifest[key] = entry;
6814
6824
  }
6815
6825
  return manifest;
6816
6826
  }