@timber-js/app 0.2.0-alpha.242 → 0.2.0-alpha.243
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/_chunks/{actions-BkwgRwCl.js → actions-DoTj0Jd3.js} +55 -37
- package/dist/_chunks/actions-DoTj0Jd3.js.map +1 -0
- package/dist/_chunks/als-registry-C-iwbtvI.js.map +1 -1
- package/dist/_chunks/{cache-api-BGA7c5qJ.js → cache-api-D3HmgsFh.js} +4 -4
- package/dist/_chunks/{cache-api-BGA7c5qJ.js.map → cache-api-D3HmgsFh.js.map} +1 -1
- package/dist/_chunks/{chains-Cuwwjv6T.js → chains-BpvDwp08.js} +2 -2
- package/dist/_chunks/{chains-Cuwwjv6T.js.map → chains-BpvDwp08.js.map} +1 -1
- package/dist/_chunks/chains-CjlZZ5ad.js +1 -0
- package/dist/_chunks/{classify-Y8S9C0Na.js → classify-Bbb_lKjH.js} +2 -2
- package/dist/_chunks/{classify-Y8S9C0Na.js.map → classify-Bbb_lKjH.js.map} +1 -1
- package/dist/_chunks/{cli-check-KeE1QaIx.js → cli-check-DlQBSKIN.js} +3 -3
- package/dist/_chunks/{cli-check-KeE1QaIx.js.map → cli-check-DlQBSKIN.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-DZEF31wd.js → cli-schema-sync-CWkGFlYu.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-DZEF31wd.js.map → cli-schema-sync-CWkGFlYu.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-_y5O6MIg.js → cli-schema-sync-Dyvdkv_I.js} +1 -1
- package/dist/_chunks/{client-dep-entries-DpiwvoDi.js → client-dep-entries-Dka67elj.js} +2 -2
- package/dist/_chunks/{client-dep-entries-DpiwvoDi.js.map → client-dep-entries-Dka67elj.js.map} +1 -1
- package/dist/_chunks/{convention-lint-0AEsPK2T.js → convention-lint-CGGcseNn.js} +3 -3
- package/dist/_chunks/{convention-lint-0AEsPK2T.js.map → convention-lint-CGGcseNn.js.map} +1 -1
- package/dist/_chunks/dev-server-DrjLscqT.js +1 -0
- package/dist/_chunks/{dev-server-DYDr8KIc.js → dev-server-LO4McfQi.js} +3 -3
- package/dist/_chunks/{dev-server-DYDr8KIc.js.map → dev-server-LO4McfQi.js.map} +1 -1
- package/dist/_chunks/error-boundary-wuNvAJ4n.js.map +1 -1
- package/dist/_chunks/{flight-source-node-KQsX_OhS.js → flight-source-node-BeF00Wo_.js} +2 -2
- package/dist/_chunks/{flight-source-node-KQsX_OhS.js.map → flight-source-node-BeF00Wo_.js.map} +1 -1
- package/dist/_chunks/{interception-CtNt9jPt.js → interception-D1dCGNmQ.js} +6 -6
- package/dist/_chunks/{interception-CtNt9jPt.js.map → interception-D1dCGNmQ.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-BVDALqMf.js → json-lossy-check-DpXneTBm.js} +2 -2
- package/dist/_chunks/{json-lossy-check-BVDALqMf.js.map → json-lossy-check-DpXneTBm.js.map} +1 -1
- package/dist/_chunks/{live-graph-VhzO7Ol9.js → live-graph-DXhz6A_X.js} +4 -4
- package/dist/_chunks/{live-graph-VhzO7Ol9.js.map → live-graph-DXhz6A_X.js.map} +1 -1
- package/dist/_chunks/{logger-C4m8rfMy.js → logger-D1sWX2I0.js} +17 -2
- package/dist/_chunks/logger-D1sWX2I0.js.map +1 -0
- package/dist/_chunks/{node-response-8Vz29cGS.js → node-response-Cp62CtH1.js} +2 -2
- package/dist/_chunks/{node-response-8Vz29cGS.js.map → node-response-Cp62CtH1.js.map} +1 -1
- package/dist/_chunks/{poison-scan-Dpl3ibG-.js → poison-scan-DdkJoHvP.js} +2 -2
- package/dist/_chunks/{poison-scan-Dpl3ibG-.js.map → poison-scan-DdkJoHvP.js.map} +1 -1
- package/dist/_chunks/{scanner-CCEHN9Jg.js → scanner-B6V2RqqF.js} +20 -3
- package/dist/_chunks/scanner-B6V2RqqF.js.map +1 -0
- package/dist/_chunks/{sizeof-CIF7fwSJ.js → sizeof-BKA6qOZq.js} +2 -2
- package/dist/_chunks/{sizeof-CIF7fwSJ.js.map → sizeof-BKA6qOZq.js.map} +1 -1
- package/dist/_chunks/{walkers-BbotBhNG.js → walkers-BAZoAlfI.js} +3 -3
- package/dist/_chunks/{walkers-BbotBhNG.js.map → walkers-BAZoAlfI.js.map} +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/analyze/crawl-entry.js +3 -3
- package/dist/analyze/graph-command.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/cache/stores/memory.js +1 -1
- package/dist/cli.js +3 -3
- package/dist/client/document-withdrawal.d.ts +2 -0
- package/dist/client/document-withdrawal.d.ts.map +1 -0
- package/dist/client/outlet-content-cache.d.ts +13 -1
- package/dist/client/outlet-content-cache.d.ts.map +1 -1
- package/dist/client/outlet-scope-context.d.ts +5 -0
- package/dist/client/outlet-scope-context.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts.map +1 -1
- package/dist/config-types.d.ts +2 -1
- package/dist/config-types.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/native/rsc/manifest.json +1 -0
- package/dist/native/rsc/server/als-registry.js.map +1 -1
- package/dist/native/rsc/server/cookie-context.js +7 -7
- package/dist/native/rsc/server/cookie-context.js.map +1 -1
- package/dist/native/rsc/server/deny-boundary.js +2 -1
- package/dist/native/rsc/server/deny-boundary.js.map +1 -1
- package/dist/native/rsc/server/dev-overlay-report.js +13 -0
- package/dist/native/rsc/server/dev-overlay-report.js.map +1 -0
- package/dist/native/rsc/server/logger.js +6 -1
- package/dist/native/rsc/server/logger.js.map +1 -1
- package/dist/native/rsc/server/pipeline-interception.js +4 -1
- package/dist/native/rsc/server/pipeline-interception.js.map +1 -1
- package/dist/native/rsc/server/pipeline.js.map +1 -1
- package/dist/native/rsc/server/request-context.js +4 -4
- package/dist/native/rsc/server/request-context.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/read-rule.js +30 -19
- package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/read-scope.js +48 -7
- package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -1
- package/dist/native/rsc/server/slot-resolver.js +5 -4
- package/dist/native/rsc/server/slot-resolver.js.map +1 -1
- package/dist/native/rsc/server/slot-subtree-contain.js +2 -1
- package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
- package/dist/native/rsc/server/subtree-walk.js +14 -5
- package/dist/native/rsc/server/subtree-walk.js.map +1 -1
- package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/ssr/client/document-withdrawal.js +17 -0
- package/dist/native/ssr/client/document-withdrawal.js.map +1 -0
- package/dist/native/ssr/client/outlet-content-cache.js +6 -1
- package/dist/native/ssr/client/outlet-content-cache.js.map +1 -1
- package/dist/native/ssr/client/outlet-scope-context.js.map +1 -1
- package/dist/native/ssr/client/segment-outlet.js +11 -2
- package/dist/native/ssr/client/segment-outlet.js.map +1 -1
- package/dist/native/ssr/manifest.json +5 -0
- package/dist/native/ssr/server/als-registry.js.map +1 -1
- package/dist/native/ssr/server/cookie-context.js +7 -7
- package/dist/native/ssr/server/cookie-context.js.map +1 -1
- package/dist/native/ssr/server/deny-boundary.js +2 -1
- package/dist/native/ssr/server/deny-boundary.js.map +1 -1
- package/dist/native/ssr/server/dev-overlay-report.js +6 -0
- package/dist/native/ssr/server/dev-overlay-report.js.map +1 -0
- package/dist/native/ssr/server/logger.js +6 -1
- package/dist/native/ssr/server/logger.js.map +1 -1
- package/dist/native/ssr/server/pipeline-interception.js +4 -1
- package/dist/native/ssr/server/pipeline-interception.js.map +1 -1
- package/dist/native/ssr/server/pipeline.js.map +1 -1
- package/dist/native/ssr/server/request-context.js +4 -4
- package/dist/native/ssr/server/request-context.js.map +1 -1
- package/dist/native/ssr/server/segment-lifetime/outlet-gate.js +11 -0
- package/dist/native/ssr/server/segment-lifetime/outlet-gate.js.map +1 -0
- package/dist/native/ssr/server/segment-lifetime/read-rule.js +30 -19
- package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -1
- package/dist/native/ssr/server/segment-lifetime/read-scope.js +16 -0
- package/dist/native/ssr/server/segment-lifetime/read-scope.js.map +1 -0
- package/dist/native/ssr/server/subtree-walk.js +149 -0
- package/dist/native/ssr/server/subtree-walk.js.map +1 -0
- package/dist/native/ssr/server/utils/element-type.js +21 -9
- package/dist/native/ssr/server/utils/element-type.js.map +1 -1
- package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
- package/dist/routing/index.js +3 -3
- package/dist/routing/slot-placement.d.ts +23 -4
- package/dist/routing/slot-placement.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +18 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/dev-overlay-report.d.ts +13 -0
- package/dist/server/dev-overlay-report.d.ts.map +1 -0
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +97 -8
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +10 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +13 -1
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/segment-lifetime/read-rule.d.ts +14 -18
- package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -1
- package/dist/server/segment-lifetime/read-scope.d.ts +47 -6
- package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -1
- package/dist/server/segment-lifetime/slot-outlets.d.ts +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/slot-subtree-contain.d.ts.map +1 -1
- package/dist/server/subtree-walk.d.ts +17 -3
- package/dist/server/subtree-walk.d.ts.map +1 -1
- package/dist/server/vite-handoff-rsc.d.ts +2 -0
- package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
- package/docs/api/34-api-config.mdx +1 -1
- package/package.json +1 -1
- package/src/client/document-withdrawal.tsx +41 -0
- package/src/client/outlet-content-cache.ts +18 -2
- package/src/client/outlet-scope-context.ts +5 -0
- package/src/client/segment-outlet.tsx +9 -3
- package/src/config-types.ts +2 -1
- package/src/routing/interception.ts +5 -5
- package/src/routing/slot-placement.ts +41 -4
- package/src/server/als-registry.ts +14 -0
- package/src/server/cookie-context.ts +7 -7
- package/src/server/deny-boundary.ts +4 -1
- package/src/server/dev-overlay-report.ts +22 -0
- package/src/server/logger.ts +13 -0
- package/src/server/pipeline-interception.ts +11 -2
- package/src/server/pipeline.ts +13 -1
- package/src/server/request-context.ts +6 -6
- package/src/server/route-element-builder.ts +2 -2
- package/src/server/rsc-entry/index.ts +7 -0
- package/src/server/segment-lifetime/read-rule.ts +62 -31
- package/src/server/segment-lifetime/read-scope.ts +128 -14
- package/src/server/segment-lifetime/slot-outlets.ts +1 -1
- package/src/server/slot-resolver.ts +22 -10
- package/src/server/slot-subtree-contain.ts +2 -1
- package/src/server/subtree-walk.ts +34 -9
- package/src/server/vite-handoff-rsc.ts +2 -0
- package/dist/_chunks/actions-BkwgRwCl.js.map +0 -1
- package/dist/_chunks/chains-LGjBHfSN.js +0 -1
- package/dist/_chunks/dev-server-CboXr8zX.js +0 -1
- package/dist/_chunks/logger-C4m8rfMy.js.map +0 -1
- package/dist/_chunks/scanner-CCEHN9Jg.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convention-lint-0AEsPK2T.js","names":[],"sources":["../../src/routing/segment-codegen.ts","../../src/routing/codegen-write.ts","../../src/shared/route-options-export.ts","../../src/routing/route-options.ts","../../src/routing/route-options-lint.ts","../../src/routing/convention-lint.ts"],"sourcesContent":["/**\n * $segment type generation and directory-to-route mapping.\n *\n * Generates per-route $segment.d.ts files in .timber/types/ that mirror\n * the app/ directory structure. TypeScript's rootDirs feature makes these\n * importable as './$segment' from route files.\n *\n * Design doc: design/41-global-params.md §The $segment Module\n */\n\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { writeFileAtomic } from '../utils/write-file-atomic.ts';\nimport type { RouteTree, SegmentNode } from './types.ts';\n\n/** Info carried per directory for type generation. */\nexport interface SegmentInfo {\n /** The URL route pattern (groups and slots stripped). e.g. '/[artistSlug]/[year]' */\n route: string;\n /** The full tree path including groups and slots — uniquely identifies a segment.\n * e.g. '/(browse)/[artistSlug]/@shows/[year]' */\n segmentPath: string;\n}\n\n/**\n * Build a map of absolute filesystem directory → segment info.\n * Used by resolveId to map a $segment import's importer to the correct route,\n * and by writeSegmentTypes to generate per-route $segment.d.ts files.\n *\n * Walks every segment (not just leaves) so layouts and middleware\n * at any depth can import $segment.\n */\nexport function buildDirToRouteMap(tree: RouteTree, appDir: string): Map<string, SegmentInfo> {\n const map = new Map<string, SegmentInfo>();\n\n function walk(node: SegmentNode, fsPath: string, treePath: string): void {\n map.set(fsPath, {\n route: node.urlPath || '/',\n segmentPath: treePath || '/',\n });\n\n for (const child of node.children) {\n const childDir = join(fsPath, child.segmentName);\n const childTreePath = `${treePath}/${child.segmentName}`;\n walk(child, childDir, childTreePath);\n }\n for (const [slotName, slotNode] of Object.entries(node.slots)) {\n const slotDir = join(fsPath, `@${slotName}`);\n const slotTreePath = `${treePath}/@${slotName}`;\n walk(slotNode, slotDir, slotTreePath);\n }\n }\n\n walk(tree.root, appDir, '');\n return map;\n}\n\n/**\n * Generate the full $segment.d.ts content for a segment.\n */\nexport function generateSegmentDts(info: SegmentInfo): string {\n return [\n `export const ROUTE: '${info.route}';`,\n `export const SEGMENT_PATH: '${info.segmentPath}';`,\n '',\n ].join('\\n');\n}\n\n/**\n * Generate per-route $segment.d.ts files in .timber/types/ mirroring\n * the app/ directory structure. These files are importable via TypeScript's\n * rootDirs feature.\n */\nexport async function writeSegmentTypes(\n routeTree: RouteTree,\n appDir: string,\n root: string\n): Promise<void> {\n // Compute the relative prefix from project root to appDir.\n // e.g. if appDir is /project/src/app, relative is 'src/app'\n const relative = appDir.slice(root.length + 1);\n const typesBase = join(root, '.timber', 'types', relative);\n const map = buildDirToRouteMap(routeTree, appDir);\n\n const writes: Promise<void>[] = [];\n for (const [fsDir, info] of map) {\n // Mirror the app/ structure under .timber/types/\n const relDir = fsDir.slice(appDir.length); // e.g. '/[artistSlug]/[year]'\n const segmentDir = join(typesBase, relDir);\n const segmentFile = join(segmentDir, '$segment.d.ts');\n const content = generateSegmentDts(info);\n\n writes.push(\n mkdir(segmentDir, { recursive: true }).then(() => writeFileAtomic(segmentFile, content))\n );\n }\n\n await Promise.all(writes);\n}\n","/**\n * Route-map codegen writer.\n *\n * Materializes the generated route types on disk: `.timber/timber-routes.d.ts`,\n * `.timber/segment-types.d.ts` (via `writeSegmentTypes`), and the root\n * `timber-env.d.ts` that references them.\n *\n * Lives outside `plugins/routing.ts` because it has two callers with two\n * different failure policies: the dev/build plugin starts the write off the hot\n * path and logs failures, while `timber check` awaits it and treats a failure as\n * fatal — a type check run against absent or stale route types reports errors\n * about code that is fine. One implementation, two policies, so the bytes on\n * disk cannot drift between the two commands.\n *\n * Design docs: 09-typescript.md §\"Typed Routes\", 18-build-system.md\n */\n\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateRouteMap } from './codegen.ts';\nimport { writeSegmentTypes } from './segment-codegen.ts';\nimport { writeFileAtomic } from '../utils/write-file-atomic.ts';\nimport type { RouteTree } from './types.ts';\n\n/**\n * Path (relative to the project root) of the generated route map declaration\n * file, and the name of the root file that `/// <reference>`s it.\n *\n * Exported because `timber check` has to answer whether the user's tsconfig\n * pulls these into the program — a question about these exact paths. It derives\n * them from here rather than restating them, so a rename cannot leave the check\n * looking for a file nothing writes.\n */\nexport const CODEGEN_OUTPUT = '.timber/timber-routes.d.ts';\n\n/** Root-level file that references the generated declarations. */\nexport const ENV_DTS_FILENAME = 'timber-env.d.ts';\n\n/**\n * Content of the timber-env.d.ts file written to the project root.\n *\n * Uses a triple-slash reference so TypeScript auto-discovers the generated\n * route map without the user needing to edit tsconfig.json — same pattern\n * as Next.js's next-env.d.ts.\n *\n * Also references `vite/client` so side-effect imports like\n * `import './globals.css'` type-check without ts(2882), and so\n * `import.meta.env`, `import.meta.hot`, `import.meta.glob`, asset\n * imports (`*.png`, `*.svg`, …), CSS modules, and `?url`/`?raw`/\n * `?inline` query variants all resolve without the user editing\n * tsconfig.json themselves. Next.js's next-env.d.ts plays the same\n * role via `next/types/global`.\n *\n * `vite` is a peer dep of `@timber-js/app`, so the reference always\n * resolves in a correctly-installed project.\n */\nconst TIMBER_ENV_DTS = [\n '// This file is auto-generated by timber.js. Do not edit.',\n '// It ensures TypeScript picks up the generated route types and',\n '// Vite-provided ambient types (CSS, assets, import.meta.env, HMR).',\n '/* eslint-disable @typescript-eslint/triple-slash-reference */',\n '/// <reference path=\".timber/timber-routes.d.ts\" />',\n '/// <reference types=\"vite/client\" />',\n '/// <reference types=\"react/canary\" />',\n '/// <reference types=\"react-dom/canary\" />',\n '',\n].join('\\n');\n\n/**\n * Codegen writes that have been started but have not yet landed on disk.\n *\n * `writeRouteCodegen` is deliberately unawaited on the dev/build hot path,\n * which leaves that caller no way to know the files exist yet. Anything that\n * tears down the project root — a build process exiting, a test removing its\n * temp root — then races the writes: `rmSync` empties a directory that a\n * pending `mkdir` immediately recreates, and the removal fails with ENOTEMPTY.\n *\n * Every started write registers here and deregisters when it settles, so\n * `flushCodegenWrites()` can await them instead of guessing at a delay.\n */\nconst pendingCodegenWrites = new Set<Promise<void>>();\n\n/**\n * Resolve once every codegen write started so far has landed on disk.\n *\n * Safe to call at any time and from anywhere — writes are tracked per process,\n * not per plugin instance, so a caller does not need a handle on the plugin\n * that started them. Never rejects: the tracked copy of each write has its\n * rejection swallowed, so a failing write cannot turn a teardown barrier into\n * an unhandled rejection. Callers that care about failure await the promise\n * `writeRouteCodegen` returned instead.\n */\nexport async function flushCodegenWrites(): Promise<void> {\n // Loop rather than a single Promise.all: a write started while we were\n // awaiting would otherwise be missed, and the set would still be non-empty\n // on return.\n //\n // Each round drops what it awaited rather than trusting the per-write\n // `finally` to have run, so the two removal paths are independent — a\n // deregistration that stopped firing would leak memory in dev, but it can\n // never turn this into a spin.\n while (pendingCodegenWrites.size > 0) {\n const inFlight = [...pendingCodegenWrites];\n await Promise.all(inFlight);\n for (const write of inFlight) pendingCodegenWrites.delete(write);\n }\n}\n\n/**\n * Write the generated route map, segment types, and the timber-env.d.ts\n * reference file for `tree`.\n *\n * Returns a promise that **rejects** if any write fails. The dev/build plugin\n * does not await it (types are a developer convenience there, not a runtime\n * dependency) and logs instead; `timber check` awaits it and fails the command.\n * Either way the write is registered with `flushCodegenWrites()`.\n */\n/**\n * Write `timber-env.d.ts` only when its content differs.\n *\n * Its content is constant per timber version, so almost every call is a no-op\n * — and a file that is not rewritten cannot be read half-written. It is not\n * replaced atomically because it lives in the user's project root, often\n * committed: a rename would turn a symlink into a regular file, reset its\n * permissions, and a process killed mid-write would leave a temp file next to\n * their source. The in-place write happens only on first run or a timber\n * upgrade.\n */\nasync function writeEnvDts(envPath: string): Promise<void> {\n const existing = await readFile(envPath, 'utf-8').catch(() => null);\n if (existing !== TIMBER_ENV_DTS) await writeFile(envPath, TIMBER_ENV_DTS, 'utf-8');\n}\n\nexport function writeRouteCodegen(tree: RouteTree, appDir: string, root: string): Promise<void> {\n const timberDir = join(root, '.timber');\n const content = generateRouteMap(tree, { appDir, outputDir: timberDir });\n const routesPath = join(root, CODEGEN_OUTPUT);\n const envPath = join(root, ENV_DTS_FILENAME);\n\n const done = mkdir(timberDir, { recursive: true })\n .then(() =>\n // The type checker can read these while they are being rewritten — an\n // editor's TS server during `timber dev`, a `tsgo` run during `vite\n // build`. A truncating write shows it an empty route map for the length\n // of the write, and every typed route degrades to `any` (TIM-1562).\n // The generated files under `.timber/` are replaced atomically.\n Promise.all([\n writeFileAtomic(routesPath, content),\n writeEnvDts(envPath),\n writeSegmentTypes(tree, appDir, root),\n ])\n )\n .then(() => undefined);\n\n // The tracked copy swallows rejection so `flushCodegenWrites` — a teardown\n // barrier — never rejects and never leaves an unhandled rejection behind.\n // The returned promise keeps its rejection for callers that want it.\n const tracked = done.catch(() => undefined);\n pendingCodegenWrites.add(tracked);\n void tracked.finally(() => pendingCodegenWrites.delete(tracked));\n\n return done;\n}\n","/**\n * The export a layout or page declares its options under (design/53\n * §\"Route-module options\"). One table for both readers: the build-time source\n * reader (`routing/route-options.ts`) and the runtime module loader\n * (`server/route-module-loader.ts`), which cannot import the source reader\n * because it pulls in `node:fs` and Vite's parser.\n */\n\nexport type RouteOptionsKind = 'layout' | 'page';\n\nexport const ROUTE_OPTIONS_EXPORT = {\n layout: 'layoutOptions',\n page: 'pageOptions',\n} as const satisfies Record<RouteOptionsKind, string>;\n","/**\n * Route-module options: `export const layoutOptions = { … }` in a layout and\n * `export const pageOptions = { … }` in a page, read from source.\n *\n * Design doc: design/53-segment-lifetime.md §\"Route-module options\".\n *\n * `prerender` is read here at build time, before any route module loads:\n * `plugins/prerender-sugar.ts` decides from it which pages to wrap in\n * `cache.component(...)`. Every other option is validated here and read at\n * runtime from the loaded module (`deferSuspenseFor`, in\n * `server/route-module-loader.ts`; `lifetime` and `key`, in\n * `server/segment-lifetime/segment-key.ts`). A key's `searchParams` and\n * `cookies` name definitions, so they are the one place a non-literal value is\n * accepted; `segmentParams` is checked against the segment's path by\n * `routing/route-options-lint.ts`. The whole object follows one rule so that\n * every key is checkable: this reader accepts one spelling —\n * `export const xOptions = { … }` of literal values, optionally behind\n * `satisfies` / `as` — and reports the others it can see as problems.\n * `routing/convention-lint.ts` turns problems into build errors:\n *\n * - a spread, a computed key, a getter or method, or a non-literal value\n * - an unknown key (a misspelled `prerendr`)\n * - `pageOptions` in a layout or `layoutOptions` in a page\n * - options in a `'use client'` file, whose exports the server never sees\n * - the removed floating exports, `export const prerender` and\n * `export const deferSuspenseFor`\n * - `let`, a destructured binding, a specifier or a named re-export\n * (`export { pageOptions } from`, `export * as pageOptions from`)\n *\n * What it cannot see is not reported: `export * from` is not followed, a\n * file that does not parse reads as having no options (the compiler reports\n * it), and MDX pages are not read at all, so `prerender` in an MDX page does\n * nothing and its `deferSuspenseFor` is unvalidated.\n */\n\nimport { headerKeyProblem } from '../shared/key-headers.ts';\nimport { existsSync } from 'node:fs';\nimport type {\n LayoutOptions,\n PageOptions,\n RoutePrerender,\n SegmentKey,\n SegmentLifetime,\n} from '../server/types.ts';\nimport { patternBinds, TRANSPARENT_WRAPPERS, tryParse } from './export-detect.ts';\nimport { readFileCached } from './file-cache.ts';\nimport { ROUTE_OPTIONS_EXPORT, type RouteOptionsKind } from '../shared/route-options-export.ts';\n\nconst OPTIONS_TYPE = { layout: 'LayoutOptions', page: 'PageOptions' } as const;\n\n/** Floating exports the options objects replaced (design/53). */\nconst REMOVED_EXPORTS = ['prerender', 'deferSuspenseFor'] as const;\n\nexport interface RouteOptionsRead {\n /**\n * The declared options. Undefined when the file declares none or when any\n * problem was found — a half-read object is never acted on.\n */\n options: LayoutOptions | PageOptions | undefined;\n /** One line per problem, each naming what to write instead. */\n problems: string[];\n}\n\n// ─── AST access ────────────────────────────────────────────────────────────\n\n/** An ESTree node as oxc's `parseAst` produces it, read field by field. */\ntype Node = { readonly type: string; readonly [field: string]: unknown };\n\nfunction isNode(value: unknown): value is Node {\n return (\n typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string'\n );\n}\n\nfunction child(node: Node, field: string): Node | undefined {\n const value = node[field];\n return isNode(value) ? value : undefined;\n}\n\nfunction list(node: Node, field: string): unknown[] {\n const value = node[field];\n return Array.isArray(value) ? value : [];\n}\n\n/** Strip `satisfies T`, `as T`, `(x)` and friends, which compile away. */\nfunction unwrap(node: Node): Node {\n let current = node;\n while (TRANSPARENT_WRAPPERS.has(current.type)) {\n const inner = child(current, 'expression');\n if (!inner) break;\n current = inner;\n }\n return current;\n}\n\n/** An identifier's name or a string literal's value (`export { x as \"y\" }`). */\nfunction nameOf(node: Node | undefined): string | undefined {\n if (!node) return undefined;\n if (typeof node.value === 'string') return node.value;\n return typeof node.name === 'string' ? node.name : undefined;\n}\n\n/** A literal's value; a template literal with no `${}` counts as a string. */\nfunction literal(node: Node): unknown {\n const n = unwrap(node);\n if (n.type === 'Literal') return n.value;\n if (n.type !== 'TemplateLiteral' || list(n, 'expressions').length > 0) return undefined;\n const [quasi] = list(n, 'quasis');\n // A TemplateElement's `value` is `{ raw, cooked }`, not a node.\n const parts = isNode(quasi) ? quasi.value : undefined;\n const value =\n typeof parts === 'object' && parts !== null && 'cooked' in parts ? parts.cooked : undefined;\n return typeof value === 'string' ? value : undefined;\n}\n\n/** `key: undefined` — the same as leaving the key out, as the types allow. */\nfunction isUndefined(node: Node): boolean {\n const n = unwrap(node);\n return n.type === 'Identifier' && n.name === 'undefined';\n}\n\n// ─── Value readers, one per option ────────────────────────────────────────\n\ntype Read<T> = { value: T } | { problem: string };\n\n/** A numeric literal is never negative (`-1` is a unary expression), so finite is enough. */\nfunction readNonNegativeNumber(node: Node, label: string): Read<number> {\n const value = literal(node);\n if (typeof value === 'number' && Number.isFinite(value)) return { value };\n return { problem: `${label} must be a non-negative number literal.` };\n}\n\nfunction readPrerender(node: Node): Read<RoutePrerender> {\n const value = literal(node);\n if (typeof value === 'boolean') return { value };\n const n = unwrap(node);\n if (n.type !== 'ObjectExpression') {\n return {\n problem: 'prerender must be `true`, `false`, or an object literal `{ ttl?, tags? }`.',\n };\n }\n const result: { ttl?: number; tags?: string[] } = {};\n for (const entry of readProperties(n, 'prerender')) {\n if ('problem' in entry) return entry;\n if (entry.key === 'ttl') {\n const ttl = readNonNegativeNumber(entry.value, 'prerender.ttl');\n if ('problem' in ttl) return ttl;\n result.ttl = ttl.value;\n } else if (entry.key === 'tags') {\n const tags = readStringArray(entry.value);\n if (!tags) return { problem: 'prerender.tags must be an array of string literals.' };\n result.tags = tags;\n } else {\n return { problem: `Unknown key \"${entry.key}\" in prerender. Allowed: ttl, tags.` };\n }\n }\n return { value: result };\n}\n\nfunction readStringArray(node: Node): string[] | undefined {\n const n = unwrap(node);\n if (n.type !== 'ArrayExpression') return undefined;\n const result: string[] = [];\n for (const element of list(n, 'elements')) {\n const value = isNode(element) ? literal(element) : undefined;\n if (typeof value !== 'string') return undefined;\n result.push(value);\n }\n return result;\n}\n\n/**\n * One reader per option key. Typed against the public option types, so an\n * option added to `PageOptions` / `LayoutOptions` without a reader here (or a\n * reader without the option) fails typecheck — the two lists cannot drift.\n */\ntype Readers<T> = {\n [K in keyof Required<T>]: (\n node: Node\n ) => Read<NonNullable<T[K]> extends SegmentKey ? BuildTimeKey : NonNullable<T[K]>>;\n};\n\nconst deferSuspenseFor = (node: Node) => readNonNegativeNumber(node, 'deferSuspenseFor');\n\nconst LIFETIMES: readonly SegmentLifetime[] = ['request', 'document'];\n\nfunction readLifetime(node: Node): Read<SegmentLifetime> {\n const value = literal(node);\n const lifetime = LIFETIMES.find((l) => l === value);\n if (lifetime) return { value: lifetime };\n return { problem: \"lifetime must be 'request' or 'document'.\" };\n}\n\n/**\n * What the build can read of a segment key: the param and header names. `searchParams`\n * and `cookies` name definitions — code the build cannot evaluate — so only\n * their shape is checked here; their values take effect from the loaded\n * module (`server/segment-lifetime/`). The route-options lint checks the\n * param names against the segment's path.\n */\ntype BuildTimeKey = Pick<SegmentKey, 'segmentParams' | 'headers'>;\n\nfunction readHeaderNames(node: Node): Read<string[]> {\n const names = readStringArray(node);\n if (!names) return { problem: 'key.headers must be an array of header-name string literals.' };\n for (const name of names) {\n const problem = headerKeyProblem(name);\n if (problem) return { problem };\n }\n return { value: names };\n}\n\n/** A value written in place, which cannot be a definition imported or declared elsewhere. */\nfunction isInlineValue(node: Node): boolean {\n const type = unwrap(node).type;\n return (\n literal(node) !== undefined ||\n type === 'ObjectExpression' ||\n type === 'ArrayExpression' ||\n type === 'Literal' ||\n type === 'TemplateLiteral'\n );\n}\n\nfunction readKey(node: Node): Read<BuildTimeKey> {\n const n = unwrap(node);\n if (n.type !== 'ObjectExpression') {\n return {\n problem:\n 'key must be an object literal `{ segmentParams?, searchParams?, cookies?, headers? }`.',\n };\n }\n const result: BuildTimeKey = {};\n for (const entry of readProperties(n, 'key')) {\n if ('problem' in entry) return entry;\n if (entry.key === 'segmentParams') {\n const names = readStringArray(entry.value);\n if (!names) return { problem: 'key.segmentParams must be an array of string literals.' };\n result.segmentParams = names;\n } else if (entry.key === 'searchParams') {\n if (isInlineValue(entry.value)) {\n return {\n problem:\n 'key.searchParams must name a search-params definition (`defineSearchParams`, or a `.pick()` of one).',\n };\n }\n } else if (entry.key === 'cookies') {\n const array = unwrap(entry.value);\n const elements = list(array, 'elements');\n const definitions = elements.every(\n (e) => isNode(e) && e.type !== 'SpreadElement' && !isInlineValue(e)\n );\n if (array.type !== 'ArrayExpression' || !definitions) {\n return {\n problem: 'key.cookies must be an array literal of cookie definitions (`defineCookie`).',\n };\n }\n } else if (entry.key === 'headers') {\n const headers = readHeaderNames(entry.value);\n if ('problem' in headers) return headers;\n result.headers = headers.value;\n } else {\n return {\n problem: `Unknown key \"${entry.key}\" in key. Allowed: segmentParams, searchParams, cookies, headers.`,\n };\n }\n }\n return { value: result };\n}\n\nconst READERS = {\n layout: {\n lifetime: readLifetime,\n key: readKey,\n prerender: readPrerender,\n deferSuspenseFor,\n } satisfies Readers<LayoutOptions>,\n page: {\n lifetime: readLifetime,\n key: readKey,\n prerender: readPrerender,\n deferSuspenseFor,\n } satisfies Readers<PageOptions>,\n};\n\n// ─── Object literal ───────────────────────────────────────────────────────\n\ntype Entry = { key: string; value: Node } | { problem: string };\n\n/**\n * The `key: value` entries of an object literal, or a problem per entry that\n * has none. `key: undefined` entries are dropped: they mean \"not set\".\n */\nfunction readProperties(object: Node, label: string): Entry[] {\n return list(object, 'properties').flatMap((prop): Entry[] => {\n if (!isNode(prop) || prop.type === 'SpreadElement') {\n return [{ problem: `${label} cannot use a spread; write every key in the literal.` }];\n }\n if (prop.computed === true) {\n return [{ problem: `${label} cannot use a computed key; write the key name.` }];\n }\n const value = child(prop, 'value');\n const key = nameOf(child(prop, 'key'));\n if (prop.kind !== 'init' || prop.method === true || !value || key === undefined) {\n return [{ problem: `${label} entries must be plain \\`key: value\\` pairs.` }];\n }\n return isUndefined(value) ? [] : [{ key, value }];\n });\n}\n\nfunction readOptionsObject(init: Node, kind: RouteOptionsKind, problems: string[]) {\n const name = ROUTE_OPTIONS_EXPORT[kind];\n const object = unwrap(init);\n if (object.type !== 'ObjectExpression') {\n problems.push(`${name} must be an object literal: \\`export const ${name} = { … }\\`.`);\n return undefined;\n }\n const readers: Record<string, (node: Node) => Read<unknown>> = READERS[kind];\n const options: Record<string, unknown> = {};\n for (const entry of readProperties(object, name)) {\n if ('problem' in entry) {\n problems.push(entry.problem);\n continue;\n }\n const reader = Object.hasOwn(readers, entry.key) ? readers[entry.key] : undefined;\n if (!reader) {\n problems.push(\n `Unknown key \"${entry.key}\" in ${name}. Allowed: ${Object.keys(readers).join(', ')}.`\n );\n continue;\n }\n const read = reader(entry.value);\n if ('problem' in read) problems.push(read.problem);\n else options[entry.key] = read.value;\n }\n return options;\n}\n\n// ─── File ─────────────────────────────────────────────────────────────────\n\nconst NONE: RouteOptionsRead = Object.freeze({ options: undefined, problems: [] });\n\n/** Every name the reader reacts to; a file containing none of them is not parsed. */\nconst MENTIONS = /Options|prerender|deferSuspenseFor/;\n\n/**\n * Read a layout's `layoutOptions` or a page's `pageOptions` from source.\n *\n * A missing or unparseable file reads as no options and no problems: the\n * compiler reports syntax errors, and guessing at a half-written file would\n * misreport it. `.ts` files are parsed as TypeScript, not TSX, so an\n * angle-bracket cast does not hide a file from this check.\n */\nexport function readRouteOptions(filePath: string, kind: RouteOptionsKind): RouteOptionsRead {\n if (!existsSync(filePath)) return NONE;\n const source = readFileCached(filePath);\n // Runs on every page and layout on each rescan; most declare nothing.\n if (!MENTIONS.test(source)) return NONE;\n const program = tryParse(source, /\\.[mc]?ts$/.test(filePath) ? 'ts' : 'tsx');\n if (!program) return NONE;\n\n const own = ROUTE_OPTIONS_EXPORT[kind];\n const otherKind: RouteOptionsKind = kind === 'page' ? 'layout' : 'page';\n const other = ROUTE_OPTIONS_EXPORT[otherKind];\n const problems: string[] = [];\n let init: Node | undefined;\n\n /** An export of a watched name in a form the build cannot read. */\n const report = (name: string | undefined) => {\n if (name === own) {\n problems.push(\n `${own} must be declared in this file as \\`export const ${own} = { … } satisfies ${OPTIONS_TYPE[kind]}\\`. ` +\n '`let`, destructuring, `export { … }` and re-exports cannot be read at build time.'\n );\n } else if (name === other) {\n problems.push(\n `${other} configures a ${otherKind}; this file is a ${kind}. Use \\`export const ${own}\\`.`\n );\n } else if (name && (REMOVED_EXPORTS as readonly string[]).includes(name)) {\n problems.push(\n `\\`export const ${name}\\` was removed. Move it into the options object: ` +\n `\\`export const ${own} = { ${name}: … } satisfies ${OPTIONS_TYPE[kind]}\\`.`\n );\n }\n };\n const watched = [own, other, ...REMOVED_EXPORTS];\n\n for (const stmt of program.body) {\n if (!isNode(stmt) || stmt.exportKind === 'type') continue;\n // `export * as pageOptions from` names an export; bare `export * from` does not.\n if (stmt.type === 'ExportAllDeclaration') report(nameOf(child(stmt, 'exported')));\n if (stmt.type !== 'ExportNamedDeclaration') continue;\n for (const spec of list(stmt, 'specifiers')) {\n if (isNode(spec) && spec.exportKind !== 'type') report(nameOf(child(spec, 'exported')));\n }\n const decl = child(stmt, 'declaration');\n if (!decl) continue;\n if (decl.type !== 'VariableDeclaration') {\n report(nameOf(child(decl, 'id'))); // function or class\n continue;\n }\n for (const declarator of list(decl, 'declarations')) {\n if (!isNode(declarator)) continue;\n const id = child(declarator, 'id');\n const value = child(declarator, 'init');\n if (id?.type !== 'Identifier') {\n for (const name of watched) if (patternBinds(id, name)) report(name);\n } else if (id.name === own && decl.kind === 'const' && value) {\n init = value;\n } else {\n report(nameOf(id));\n }\n }\n }\n\n if (init && isClientModule(program.body)) {\n problems.push(\n `A 'use client' ${kind} cannot declare ${own}: the server sees a client reference, ` +\n `not the object. Move ${own} to a server ${kind} that renders the client component.`\n );\n }\n const options = init ? readOptionsObject(init, kind, problems) : undefined;\n return { options: problems.length === 0 ? options : undefined, problems };\n}\n\n/** Whether the module starts with a 'use client' directive. */\nfunction isClientModule(body: readonly unknown[]): boolean {\n for (const stmt of body) {\n if (\n !isNode(stmt) ||\n stmt.type !== 'ExpressionStatement' ||\n typeof stmt.directive !== 'string'\n ) {\n return false;\n }\n if (stmt.directive === 'use client') return true;\n }\n return false;\n}\n","/**\n * Convention-lint check for route-module options (design/53 §\"Route-module\n * options\"): `layoutOptions` / `pageOptions` the build cannot read, and\n * options declared where nothing reads them. Called from\n * `lintConventions` in `convention-lint.ts`.\n */\n\nimport type { ConventionWarning } from './convention-lint.ts';\nimport { fileHasAnyExport, isScriptExtension } from './export-detect.ts';\nimport { readRouteOptions } from './route-options.ts';\nimport type { RouteFile, SegmentNode } from './types.ts';\nimport type { LayoutOptions, PageOptions, SegmentLifetime } from '../server/types.ts';\nimport { ROUTE_OPTIONS_EXPORT, type RouteOptionsKind } from '../shared/route-options-export.ts';\n\n/**\n * Fail the build on a `layoutOptions` / `pageOptions` the build cannot read.\n *\n * Proven from source and fatal in the sense the error level requires: the\n * developer declared an option that would otherwise silently do nothing — a\n * misspelled key, a value the build cannot read, an options object in the\n * wrong file kind, or a floating `export const prerender` that no longer\n * prerenders. See `routing/route-options.ts` for what is accepted.\n */\nexport function checkRouteOptions(\n node: SegmentNode,\n warnings: ConventionWarning[],\n position: RoutePosition,\n /** The app's `defaultLayoutLifetime` (design/53 §\"App-wide default\"). */\n defaultLayoutLifetime: SegmentLifetime,\n /** The params named on the path above this segment. */\n ancestorParams: readonly string[] = []\n): void {\n const here: RoutePosition = node.segmentType === 'intercepting' ? 'intercepting' : position;\n const pathParams = node.paramName ? [...ancestorParams, node.paramName] : ancestorParams;\n const files: Array<[RouteOptionsKind, RouteFile | undefined]> = [\n ['layout', node.layout],\n ['page', node.page],\n ];\n for (const [kind, file] of files) {\n if (!file || !isScriptExtension(file.extension)) continue;\n const { options, problems } = readRouteOptions(file.filePath, kind);\n problems.push(\n ...inertOptions(options, here),\n ...paramsOffPath(options, pathParams),\n ...keyWithoutDocument(options, kind === 'layout' ? defaultLayoutLifetime : 'request')\n );\n if (problems.length === 0) continue;\n warnings.push({\n id: `ROUTE_OPTIONS_INVALID:${file.filePath}`,\n summary: `${kind}.${file.extension} has invalid ${ROUTE_OPTIONS_EXPORT[kind]}: ${file.filePath}`,\n details:\n ` File: ${file.filePath}\\n\\n` +\n problems.map((problem) => ` - ${problem}\\n`).join('') +\n '\\n Options are read from source at build time, so they must be one object\\n' +\n ' literal of literal values.\\n',\n level: 'error',\n });\n }\n if (node.default && isScriptExtension(node.default.extension)) {\n const declared = fileHasAnyExport(node.default.filePath, OPTION_EXPORT_NAMES);\n if (declared.size > 0) {\n warnings.push({\n id: `ROUTE_OPTIONS_INVALID:${node.default.filePath}`,\n summary: `default.${node.default.extension} takes no route options: ${node.default.filePath}`,\n details:\n ` File: ${node.default.filePath}\\n\\n` +\n ` default.tsx exports ${[...declared].join(', ')}, which nothing reads.\\n` +\n ' To fix: remove the export; declare options on the slot page or layout.\\n',\n level: 'error',\n });\n }\n }\n for (const child of node.children) {\n checkRouteOptions(child, warnings, here, defaultLayoutLifetime, pathParams);\n }\n for (const slot of Object.values(node.slots)) {\n const slotPosition = here === 'intercepting' ? here : 'slot';\n checkRouteOptions(slot, warnings, slotPosition, defaultLayoutLifetime, pathParams);\n }\n}\n\n/**\n * A `key` applies only to a `'document'` segment; on any other it would\n * silently do nothing. A layout that declares no lifetime takes the app's\n * `defaultLayoutLifetime`, so under a `'document'` default it may declare a\n * key alone. A page always defaults to `'request'`.\n */\nfunction keyWithoutDocument(\n options: LayoutOptions | PageOptions | undefined,\n defaultLifetime: SegmentLifetime\n): string[] {\n if (options?.key === undefined || (options.lifetime ?? defaultLifetime) === 'document') return [];\n return [\n \"key applies only to lifetime: 'document'. Declare `lifetime: 'document'` or remove key.\",\n ];\n}\n\n/**\n * A key's `segmentParams` must name params on the segment's path — the\n * segment's own and every ancestor's, slots included. Anything else could\n * never change, so the key would silently ignore what the author meant\n * (design/53 §\"Segment keys\").\n */\nfunction paramsOffPath(\n options: LayoutOptions | PageOptions | undefined,\n pathParams: readonly string[]\n): string[] {\n const declared = options?.key?.segmentParams ?? [];\n return declared\n .filter((name) => !pathParams.includes(name))\n .map(\n (name) =>\n `key.segmentParams names \"${name}\", which is not a param on this segment's path. ` +\n (pathParams.length > 0\n ? `Params on the path: ${pathParams.join(', ')}.`\n : 'This path has no params.')\n );\n}\n\n/**\n * Where a segment sits decides which options take effect there.\n * - `main`: the matched route chain. Every option applies.\n * - `slot`: a parallel slot. `prerender` applies to slot pages (the sugar\n * walks slots); `deferSuspenseFor` does not — the hold is read from the\n * main chain's modules only (`server/route-module-loader.ts`).\n * - `intercepting`: an intercepting route and everything under it. It renders\n * only on a soft navigation, through the slot resolver, and the sugar skips\n * it, so no option applies.\n */\ntype RoutePosition = 'main' | 'slot' | 'intercepting';\n\nconst OPTION_EXPORT_NAMES = [\n ...Object.values(ROUTE_OPTIONS_EXPORT),\n 'prerender',\n 'deferSuspenseFor',\n] as const;\n\nfunction inertOptions(\n options: LayoutOptions | PageOptions | undefined,\n position: RoutePosition\n): string[] {\n if (!options || position === 'main') return [];\n const inert = Object.keys(options).filter(\n (key) => position === 'intercepting' || key === 'deferSuspenseFor'\n );\n return inert.map((key) =>\n position === 'intercepting'\n ? `${key} has no effect on an intercepting route: it renders only on a soft navigation, ` +\n 'through the slot that intercepts it. Declare it on the route being intercepted.'\n : `${key} has no effect in a parallel slot: the hold is read from the main route's ` +\n 'layouts and page. Declare it there.'\n );\n}\n","/**\n * Convention linter — validates common misconfigurations in the route tree.\n *\n * Runs at scan time (build and dev startup). Each check produces a warning\n * with the file path, what's wrong, and what to do about it.\n *\n * Most checks are warnings — they don't block the build. The goal is to catch\n * issues that would otherwise produce cryptic runtime behavior (silent 404s,\n * empty pages, confusing React errors).\n *\n * A check emits `level: 'error'` only when the misconfiguration is *proven*\n * (never inferred from an absence the analysis cannot see through) and either\n * fatal to rendering or a declaration that provably does nothing — a CSRF\n * exemption the gate never reads, a route option the build cannot read, a\n * middleware.ts in a slot. The developer believes the declaration is in\n * effect, so silence would ship the wrong behavior. `plugins/routing.ts` turns those into a thrown build error,\n * so a false positive there refuses a working app — see\n * `classifyClientBoundaryFile` for how that bar is met.\n *\n * Design doc: 07-routing.md, 10-error-handling.md\n */\n\nimport { existsSync } from 'node:fs';\nimport type { RouteFile, RouteTree, SegmentNode } from './types.ts';\nimport { swallow } from '../server/logger.ts';\nimport { HTTP_METHODS } from '../server/route-methods.ts';\nimport {\n fileDefaultExportIsLocalValue,\n fileHasAnyExport,\n fileHasDefaultExport,\n fileHasDirective,\n fileHasStarExport,\n getCsrfExport,\n isScriptExtension,\n} from './export-detect.ts';\nimport { checkRouteOptions } from './route-options-lint.ts';\nimport type { SegmentLifetime } from '../server/types.ts';\n\n// ─── Types ──────────────────────────────────────────────────────────────────\n\nexport interface ConventionWarning {\n /** Warning ID for deduplication and filtering. */\n id: string;\n /** Human-readable single-line summary. */\n summary: string;\n /** Multi-line details with file path and fix suggestion. */\n details: string;\n /** Severity: 'warn' for potential issues, 'error' for definite misconfigurations. */\n level: 'warn' | 'error';\n}\n\n// ─── Lint Rules ─────────────────────────────────────────────────────────────\n\n/**\n * Run all convention lint checks on a route tree.\n *\n * Returns an array of warnings. Empty array means everything looks good.\n */\nexport function lintConventions(\n tree: RouteTree,\n appDir: string,\n /** The config the checks depend on, as the build resolved it. */\n config: { defaultLayoutLifetime: SegmentLifetime | undefined }\n): ConventionWarning[] {\n const warnings: ConventionWarning[] = [];\n\n // Check 1: app/ directory exists (caller should check before scanning,\n // but we validate the root has at least one routable file)\n checkEmptyApp(tree.root, appDir, warnings);\n\n // Check 2: route.ts without recognized HTTP method exports\n checkRouteExports(tree.root, warnings);\n\n // Check 3: Segments with layout but no page/route anywhere in subtree\n // (not a misconfiguration per se — layouts without pages are valid for\n // route groups. Skip this check.)\n\n // Check 4: Root segment has no layout.tsx (no HTML shell)\n checkRootLayout(tree.root, warnings);\n\n // Check 5: page.tsx / layout.tsx without default export\n checkDefaultExports(tree.root, warnings);\n\n // Check 6: Client layouts cannot suppress server children before Flight\n // serializes them. They remain valid UI boundaries, but not authorization\n // or data-hiding boundaries.\n checkClientLayouts(tree.root, warnings);\n\n // Check 7: error.tsx / 404.tsx / 4xx.tsx / … without 'use client' directive\n checkClientBoundaryFiles(tree.root, warnings);\n if (tree.globalError) {\n checkFileUseClientDirective(tree.globalError, 'global-error', warnings);\n }\n\n // Check 8: middleware.ts inside a parallel slot subtree (silently dead)\n checkSlotMiddleware(tree.root, warnings);\n\n // Check 9: `export const csrf` anywhere but route.ts, or in a form the\n // scanner cannot read (TIM-1543)\n checkCsrfExports(tree.root, warnings);\n if (tree.proxy) checkCsrfExport(tree.proxy, 'proxy.ts', warnings);\n if (tree.globalError) checkCsrfExport(tree.globalError, 'global-error', warnings);\n\n // Check 10: layoutOptions / pageOptions the build cannot read, unknown\n // keys, and the removed floating exports (design/53)\n checkRouteOptions(tree.root, warnings, 'main', config.defaultLayoutLifetime ?? 'request');\n\n return warnings;\n}\n\nfunction checkClientLayouts(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.layout && isScriptExtension(node.layout.extension)) {\n try {\n const isClient = fileHasDirective(node.layout.filePath, 'use client');\n const isProvablyServer = fileDefaultExportIsLocalValue(node.layout.filePath);\n if (isClient || !isProvablyServer) {\n const certainty = isClient\n ? `This layout is a client component.`\n : `Timber cannot prove this layout is a server component because its default export comes from another module or an opaque expression.`;\n warnings.push({\n id: `CLIENT_LAYOUT_NOT_AUTH_BOUNDARY:${node.layout.filePath}`,\n summary: isClient\n ? `Client layout cannot securely suppress server children: ${node.layout.filePath}`\n : `Layout may resolve to a client component and cannot be trusted as an auth boundary: ${node.layout.filePath}`,\n details:\n ` File: ${node.layout.filePath}\\n\\n` +\n ` ${certainty}\\n` +\n ` React Flight resolves server content passed to a client layout before the layout runs in the browser.\\n` +\n ` Conditionally omitting children here does not prevent descendant server components from executing or being serialized.\\n\\n` +\n ` To fix: Put authorization in access.ts or a provably server layout with a locally defined default component, and keep client components inside that boundary.\\n`,\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable layout file ${node.layout.filePath}`);\n }\n }\n for (const child of node.children) checkClientLayouts(child, warnings);\n for (const slot of Object.values(node.slots)) checkClientLayouts(slot, warnings);\n}\n\n// ─── Check: CSRF Exemption Export ──────────────────────────────────────────\n\n/** Single-file segment conventions other than route.ts. */\nconst NON_ROUTE_FILE_KEYS = [\n 'page',\n 'layout',\n 'middleware',\n 'access',\n 'error',\n 'default',\n 'denied',\n] as const satisfies readonly (keyof SegmentNode)[];\n\n/**\n * Fail the build on a `csrf` export the CSRF gate would not honor.\n *\n * Both findings are proven from source, and both are fatal in the sense\n * the error level requires: the developer wrote an exemption that silently\n * does nothing, so a legitimate cross-site POST they meant to accept gets\n * a 403 in production, or they believe a page or action is exempt when\n * the gate still protects it. The exemption exists only on route.ts —\n * server actions always get the check (design/08 §\"Per-route exemption\").\n * A `'use server'` module cannot export it at all: plugin-rsc rejects every\n * non-async-function export there.\n */\nfunction checkCsrfExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.route) checkCsrfExport(node.route, 'route.ts', warnings);\n for (const key of NON_ROUTE_FILE_KEYS) {\n const file = node[key];\n if (file) checkCsrfExport(file, key, warnings);\n }\n // Status files and metadata routes (sitemap.ts, opengraph-image.tsx, …).\n // JSON status files are skipped by the script-extension check.\n for (const [name, file] of Object.entries(node.statusFiles ?? {})) {\n checkCsrfExport(file, name, warnings);\n }\n for (const [name, file] of Object.entries(node.metadataRoutes ?? {})) {\n checkCsrfExport(file, name, warnings);\n }\n for (const child of node.children) checkCsrfExports(child, warnings);\n for (const slot of Object.values(node.slots)) checkCsrfExports(slot, warnings);\n}\n\nfunction checkCsrfExport(file: RouteFile, convention: string, warnings: ConventionWarning[]): void {\n if (!isScriptExtension(file.extension)) return;\n const found = getCsrfExport(file.filePath);\n if (found === 'absent') return;\n const isRoute = convention === 'route.ts';\n if (isRoute && found === 'exempt') return;\n warnings.push({\n id: `CSRF_EXPORT_INVALID:${file.filePath}`,\n summary: isRoute\n ? `route.ts csrf export must be exactly \\`export const csrf = false\\`: ${file.filePath}`\n : `\\`csrf\\` can only be exported from route.ts, not ${convention}: ${file.filePath}`,\n details:\n ` File: ${file.filePath}\\n\\n` +\n (isRoute\n ? ' The CSRF gate reads this export from source before any module loads, so only\\n' +\n ' the literal form counts. Other values, `let`, and re-exports are not read.\\n\\n' +\n ' To fix: write `export const csrf = false;` in this file, or remove the export.\\n'\n : ' The per-route CSRF exemption applies only to route.ts handlers. Pages, layouts\\n' +\n ' and server actions always get the CSRF check.\\n\\n' +\n ' To fix: remove the export. To accept a cross-site POST, handle it in a route.ts\\n' +\n ' that exports `const csrf = false`.\\n'),\n level: 'error',\n });\n}\n\n// ─── Check: Empty App ───────────────────────────────────────────────────────\n\n/**\n * Warn when the app/ directory has no routable files at all.\n *\n * This catches the \"I created app/ but didn't add any pages\" case where\n * every request silently 404s with no guidance.\n */\nfunction checkEmptyApp(root: SegmentNode, appDir: string, warnings: ConventionWarning[]): void {\n if (hasAnyRoutable(root)) return;\n\n warnings.push({\n id: 'EMPTY_APP',\n summary: 'No pages or route handlers found in app/',\n details:\n ` Directory: ${appDir}\\n\\n` +\n ' Your app/ directory has no page.tsx or route.ts files.\\n' +\n ' Every request will return 404.\\n\\n' +\n ' To fix: Create app/page.tsx with a default export:\\n\\n' +\n ' export default function Home() {\\n return <h1>Hello</h1>;\\n }\\n',\n level: 'warn',\n });\n}\n\n/**\n * Check if a segment tree has any routable files (page or route) anywhere.\n */\nfunction hasAnyRoutable(node: SegmentNode): boolean {\n if (node.page || node.route) return true;\n for (const child of node.children) {\n if (hasAnyRoutable(child)) return true;\n }\n for (const slot of Object.values(node.slots)) {\n if (hasAnyRoutable(slot)) return true;\n }\n return false;\n}\n\n/**\n * Check if a segment tree has any page files (not just route handlers).\n * Used by checkRootLayout to avoid false positives for API-only apps (TIM-794).\n * API-only apps (just route.ts handlers) don't need a root layout.\n */\nfunction hasAnyPage(node: SegmentNode): boolean {\n if (node.page) return true;\n for (const child of node.children) {\n if (hasAnyPage(child)) return true;\n }\n for (const slot of Object.values(node.slots)) {\n if (hasAnyPage(slot)) return true;\n }\n return false;\n}\n\n// ─── Check: Route Exports ───────────────────────────────────────────────────\n\n/**\n * Warn when a route.ts file doesn't appear to export any recognized HTTP methods.\n *\n * Uses AST-based detection via parseAst for precise matching.\n * Falls back silently when the file can't be parsed (syntax errors produce\n * no spurious warning — the TS compiler will catch those).\n */\nfunction checkRouteExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.route) {\n const filePath = node.route.filePath;\n try {\n const methods = fileHasAnyExport(filePath, HTTP_METHODS);\n if (methods.size === 0 && !fileHasStarExport(filePath)) {\n const hasDefault = fileHasDefaultExport(filePath);\n const hint = hasDefault\n ? ' It looks like you have a default export. route.ts uses named exports\\n' +\n ' for HTTP methods (GET, POST, etc.), not a default export.\\n'\n : '';\n\n warnings.push({\n id: 'ROUTE_NO_METHODS',\n summary: `route.ts has no HTTP method exports: ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ' route.ts files must export named HTTP method handlers.\\n' +\n ' Without them, the route matches but returns 405 Method Not Allowed.\\n\\n' +\n hint +\n ' Example:\\n\\n' +\n ' export function GET(ctx: RouteContext) {\\n' +\n \" return Response.json({ hello: 'world' });\\n\" +\n ' }\\n',\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable route.ts ${filePath}`);\n }\n }\n\n // Recurse\n for (const child of node.children) {\n checkRouteExports(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkRouteExports(slot, warnings);\n }\n}\n\n// ─── Check: Root Layout ─────────────────────────────────────────────────────\n\n/**\n * Warn when the root segment has no layout.tsx.\n *\n * Without a root layout, there's no HTML shell (<html>, <body>).\n * The page will render but may have hydration issues or no proper document structure.\n */\nfunction checkRootLayout(root: SegmentNode, warnings: ConventionWarning[]): void {\n if (root.layout) return;\n\n // Only warn if there are pages — API-only apps (just route.ts handlers)\n // don't need a root layout (TIM-794).\n if (!hasAnyPage(root)) return;\n\n warnings.push({\n id: 'NO_ROOT_LAYOUT',\n summary: 'No root layout.tsx found',\n details:\n ' Your app has pages but no root layout.\\n' +\n ' Without app/layout.tsx, pages have no <html> or <body> wrapper.\\n\\n' +\n ' To fix: Create app/layout.tsx:\\n\\n' +\n ' export default function RootLayout({ children }: { children: React.ReactNode }) {\\n' +\n ' return (\\n' +\n ' <html lang=\"en\">\\n' +\n ' <body>{children}</body>\\n' +\n ' </html>\\n' +\n ' );\\n' +\n ' }\\n',\n level: 'warn',\n });\n}\n\n// ─── Check: Default Exports ───────────────────────────────────────────\n\n/**\n * Warn when page.tsx or layout.tsx files don't have a default export.\n *\n * Without a default export:\n * - page.tsx: the page renders nothing (empty content)\n * - layout.tsx: the layout module loads but has no component to render\n *\n * Uses AST-based detection via parseAst for precise matching. Falls back\n * silently when the file can't be parsed (no spurious warning on syntax errors).\n */\nfunction checkDefaultExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n // Check page files (tsx/ts/jsx/js only — not mdx, which is default-exported by the mdx compiler)\n if (node.page && isScriptExtension(node.page.extension)) {\n checkFileDefaultExport(node.page.filePath, 'page', warnings);\n }\n\n // Check layout files\n if (node.layout && isScriptExtension(node.layout.extension)) {\n checkFileDefaultExport(node.layout.filePath, 'layout', warnings);\n }\n\n // Recurse\n for (const child of node.children) {\n checkDefaultExports(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkDefaultExports(slot, warnings);\n }\n}\n\nfunction checkFileDefaultExport(\n filePath: string,\n fileType: string,\n warnings: ConventionWarning[]\n): void {\n try {\n if (!fileHasDefaultExport(filePath)) {\n warnings.push({\n id: `NO_DEFAULT_EXPORT:${filePath}`,\n summary: `${fileType}.tsx has no default export: ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ` ${fileType}.tsx files must export a default React component.\\n` +\n ` Without a default export, the ${fileType === 'page' ? 'page renders nothing' : 'layout has no component to wrap children'}.\\n\\n` +\n ` To fix: Add a default export:\\n\\n` +\n ` export default function My${fileType === 'page' ? 'Page' : 'Layout'}(${fileType === 'layout' ? '{ children }' : ''}) {\\n` +\n ` return ${fileType === 'layout' ? '<div>{children}</div>' : '<h1>Hello</h1>'};\\n` +\n ` }\\n`,\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable ${fileType} file ${filePath}`);\n }\n}\n\n// ─── Check: Client Boundary Directive ───────────────────────────────────────\n\n/**\n * Check every file the renderer hands to `TimberErrorBoundary` as a component\n * prop: `error.tsx`, `global-error.tsx`, and the status-code family\n * (`404.tsx`, `4xx.tsx`, `503.tsx`, …).\n *\n * `TimberErrorBoundary` is a client component, so a server component passed as\n * `fallbackComponent` is a function crossing the RSC → client boundary. React\n * Flight refuses to serialize it, and because the boundary wraps the segment's\n * *children*, the failure hits every page under that segment — not just the\n * error path. The raw message (\"Functions cannot be passed directly to Client\n * Components\") names neither the file nor the fix (TIM-1329).\n *\n * `.json` status files never reach React at all, and are not in `statusFiles`.\n */\nfunction checkClientBoundaryFiles(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.error) {\n checkFileUseClientDirective(node.error, 'error', warnings);\n }\n\n for (const [key, file] of Object.entries(node.statusFiles ?? {})) {\n checkFileUseClientDirective(file, key, warnings);\n }\n\n for (const child of node.children) {\n checkClientBoundaryFiles(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkClientBoundaryFiles(slot, warnings);\n }\n}\n\n/**\n * `'client'` — carries the directive.\n * `'server'` — proven server component: no directive, and the default export is\n * a function or class built by this very module, so no other file's directive\n * can be governing it.\n * `'unknown'` — no directive, but the exported value may come from elsewhere\n * (`export { default } from './client-thing'`), or the file could not be\n * read or parsed. Never escalated to a build error.\n */\ntype ClientBoundaryVerdict = 'client' | 'server' | 'unknown';\n\nfunction classifyClientBoundaryFile(filePath: string): ClientBoundaryVerdict {\n if (fileHasDirective(filePath, 'use client')) return 'client';\n if (fileDefaultExportIsLocalValue(filePath)) return 'server';\n return 'unknown';\n}\n\n/** Example component name for the fix snippet, keyed by convention name. */\nfunction exampleComponentName(convention: string): string {\n if (convention === 'global-error') return 'GlobalError';\n if (convention === 'error') return 'ErrorBoundary';\n if (convention === '404') return 'NotFound';\n return 'StatusPage';\n}\n\n/**\n * @param file the route file (its extension decides whether the check applies)\n * @param convention the convention name — `error`, `global-error`, `404`, `4xx`, …\n */\nfunction checkFileUseClientDirective(\n file: RouteFile,\n convention: string,\n warnings: ConventionWarning[]\n): void {\n // Only script extensions need the 'use client' check — .json status files\n // never reach React at all, and are not in `statusFiles`.\n if (!isScriptExtension(file.extension)) return;\n\n const filePath = file.filePath;\n const label = `${convention}.${file.extension}`;\n let verdict: ClientBoundaryVerdict;\n try {\n verdict = classifyClientBoundaryFile(filePath);\n } catch (err) {\n swallow(err, `convention-lint: unreadable ${label} file ${filePath}`);\n return;\n }\n if (verdict === 'client') return;\n\n const isError = verdict === 'server';\n const name = exampleComponentName(convention);\n const props =\n convention === 'error' || convention === 'global-error' ? '{ error, reset }' : '{ status }';\n\n warnings.push({\n id: `NEEDS_USE_CLIENT:${filePath}`,\n summary: isError\n ? `${label} is a server component and must be a client component: ${filePath}`\n : `${label} may be missing 'use client': ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ` ${label} is handed to timber's error boundary — a client\\n` +\n ' component — as a prop. A server component cannot cross that boundary:\\n' +\n ' React fails with \"Functions cannot be passed directly to Client\\n' +\n ' Components\", and every page under this segment fails to render.\\n\\n' +\n (isError\n ? \" To fix: Add 'use client' as the first line of the file:\\n\\n\" +\n \" 'use client';\\n\\n\" +\n ` export default function ${name}(${props}) {\\n` +\n ' return <h1>…</h1>;\\n' +\n ' }\\n'\n : // The default export comes from somewhere this analysis cannot follow\n // — a re-export, an imported binding, a wrapper call. It may well\n // already be a client component, so say what was checked rather than\n // assert a break.\n \" This file has no 'use client' directive, and its default export\\n\" +\n ' comes from elsewhere, so timber cannot tell which it is. If the\\n' +\n \" module it re-exports starts with 'use client', nothing is wrong\\n\" +\n ' and you can ignore this. Otherwise add the directive there.\\n'),\n level: isError ? 'error' : 'warn',\n });\n}\n\n// ─── Check: Slot Middleware ─────────────────────────────────────────────────\n\n/**\n * Error when middleware.ts appears inside a parallel slot subtree.\n *\n * Middleware is collected from the main matched segment chain only\n * (route-matcher.ts `collectMiddlewareChain`). The slot resolver never\n * walks `middleware` on its matched chain, so a middleware.ts under any\n * `@slot/` directory silently never executes. `access.ts` in slot chains\n * DOES run (via SlotAccessGate), making the asymmetry invisible unless\n * you know to look.\n *\n * This is a build error rather than a warning: the file provably cannot\n * run and its presence misleads the author into thinking the slot is\n * middleware-protected.\n *\n * See design/07-routing.md §\"Parallel Routes\"\n */\nfunction checkSlotMiddleware(node: SegmentNode, warnings: ConventionWarning[]): void {\n for (const [slotName, slotRoot] of Object.entries(node.slots)) {\n collectSlotMiddleware(slotRoot, slotName, warnings);\n }\n for (const child of node.children) {\n checkSlotMiddleware(child, warnings);\n }\n}\n\n/**\n * Walk a slot subtree and report every middleware.ts found.\n */\nfunction collectSlotMiddleware(\n node: SegmentNode,\n slotName: string,\n warnings: ConventionWarning[]\n): void {\n if (node.middleware) {\n warnings.push({\n id: `SLOT_MIDDLEWARE:${node.middleware.filePath}`,\n summary: `middleware.ts inside slot @${slotName} never executes: ${node.middleware.filePath}`,\n details:\n ` File: ${node.middleware.filePath}\\n\\n` +\n ` Middleware is collected from the main route chain only.\\n` +\n ` The slot resolver does not run middleware — this file is silently dead.\\n` +\n ` (access.ts in slots does run via SlotAccessGate; middleware.ts does not.)\\n\\n` +\n ` To fix: Move the middleware logic into access.ts for slot-scoped auth,\\n` +\n ` or into a middleware.ts on the main route chain outside the slot.\\n`,\n level: 'error',\n });\n }\n for (const child of node.children) {\n collectSlotMiddleware(child, slotName, warnings);\n }\n for (const [nestedSlotName, nestedSlot] of Object.entries(node.slots)) {\n collectSlotMiddleware(nestedSlot, nestedSlotName, warnings);\n }\n}\n\n// ─── Check: App Directory Exists ────────────────────────────────────────────\n\n/**\n * Check if the app/ directory exists. Called before scanning.\n * Returns a warning if missing, or null if the directory exists.\n */\nexport function checkAppDirExists(appDir: string): ConventionWarning | null {\n if (existsSync(appDir)) return null;\n\n return {\n id: 'NO_APP_DIR',\n summary: 'No app/ directory found',\n details:\n ` Expected: ${appDir}\\n\\n` +\n ' timber.js requires an app/ directory for file-system routing.\\n' +\n ' Every request will return 404 until you create it.\\n\\n' +\n ' To fix: Create the app/ directory with a page:\\n\\n' +\n ' mkdir -p app\\n' +\n ' # Create app/layout.tsx and app/page.tsx\\n',\n level: 'error',\n };\n}\n\n// ─── Formatting ─────────────────────────────────────────────────────────────\n\nimport type { InspectColor } from 'node:util';\nimport { styleText } from 'node:util';\n\ntype Format = InspectColor | readonly InspectColor[];\nconst noValidate = { validateStream: false } as const;\n\nexport interface FormatOptions {\n /**\n * Emit ANSI escapes. Off when the text becomes an `Error` message —\n * whoever prints it decides its formatting, and colored escapes inside\n * an exception leak into logs and stack traces.\n */\n color?: boolean;\n}\n\n/**\n * Format warnings for terminal output.\n *\n * Groups by severity, uses colors, and includes fix suggestions.\n */\nexport function formatConventionWarnings(\n warnings: ConventionWarning[],\n options: FormatOptions = {}\n): string {\n const { color = true } = options;\n const style = (fmt: Format, text: string) => (color ? styleText(fmt, text, noValidate) : text);\n if (warnings.length === 0) return '';\n\n const errors = warnings.filter((w) => w.level === 'error');\n const warns = warnings.filter((w) => w.level === 'warn');\n\n const lines: string[] = [];\n\n if (errors.length > 0) {\n lines.push(\n `${style(['red', 'bold'], '[timber]')} ${style('red', `${errors.length} configuration error${errors.length !== 1 ? 's' : ''}:`)}`\n );\n for (const e of errors) {\n lines.push('');\n lines.push(` ${style('red', '✗')} ${e.summary}`);\n lines.push(style('dim', e.details));\n }\n }\n\n if (warns.length > 0) {\n if (errors.length > 0) lines.push('');\n lines.push(\n `${style(['yellow', 'bold'], '[timber]')} ${style('yellow', `${warns.length} configuration warning${warns.length !== 1 ? 's' : ''}:`)}`\n );\n for (const w of warns) {\n lines.push('');\n lines.push(` ${style('yellow', '⚠')} ${w.summary}`);\n lines.push(style('dim', w.details));\n }\n }\n\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,mBAAmB,MAAiB,QAA0C;CAC5F,MAAM,sBAAM,IAAI,IAAyB;CAEzC,SAAS,KAAK,MAAmB,QAAgB,UAAwB;EACvE,IAAI,IAAI,QAAQ;GACd,OAAO,KAAK,WAAW;GACvB,aAAa,YAAY;EAC3B,CAAC;EAED,KAAK,MAAM,SAAS,KAAK,UAGvB,KAAK,OAFY,KAAK,QAAQ,MAAM,WAExB,GAAU,GADG,SAAS,GAAG,MAAM,aACR;EAErC,KAAK,MAAM,CAAC,UAAU,aAAa,OAAO,QAAQ,KAAK,KAAK,GAG1D,KAAK,UAFW,KAAK,QAAQ,IAAI,UAElB,GAAS,GADA,SAAS,IAAI,UACD;CAExC;CAEA,KAAK,KAAK,MAAM,QAAQ,EAAE;CAC1B,OAAO;AACT;;;;AAKA,SAAgB,mBAAmB,MAA2B;CAC5D,OAAO;EACL,wBAAwB,KAAK,MAAM;EACnC,+BAA+B,KAAK,YAAY;EAChD;CACF,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;AAOA,eAAsB,kBACpB,WACA,QACA,MACe;CAGf,MAAM,WAAW,OAAO,MAAM,KAAK,SAAS,CAAC;CAC7C,MAAM,YAAY,KAAK,MAAM,WAAW,SAAS,QAAQ;CACzD,MAAM,MAAM,mBAAmB,WAAW,MAAM;CAEhD,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,OAAO,SAAS,KAAK;EAE/B,MAAM,SAAS,MAAM,MAAM,OAAO,MAAM;EACxC,MAAM,aAAa,KAAK,WAAW,MAAM;EAC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G,EAAE,GAChI;EACA,KAAK,MAAM,KAAK,QAAQ;GACtB,MAAM,KAAK,EAAE;GACb,MAAM,KAAK,KAAK,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,SAAS;GAChD,MAAM,KAAK,MAAM,OAAO,EAAE,OAAO,CAAC;EACpC;CACF;CAEA,IAAI,MAAM,SAAS,GAAG;EACpB,IAAI,OAAO,SAAS,GAAG,MAAM,KAAK,EAAE;EACpC,MAAM,KACJ,GAAG,MAAM,CAAC,UAAU,MAAM,GAAG,UAAU,EAAE,GAAG,MAAM,UAAU,GAAG,MAAM,OAAO,wBAAwB,MAAM,WAAW,IAAI,MAAM,GAAG,EAAE,GACtI;EACA,KAAK,MAAM,KAAK,OAAO;GACrB,MAAM,KAAK,EAAE;GACb,MAAM,KAAK,KAAK,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,SAAS;GACnD,MAAM,KAAK,MAAM,OAAO,EAAE,OAAO,CAAC;EACpC;CACF;CAEA,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
|
1
|
+
{"version":3,"file":"convention-lint-CGGcseNn.js","names":[],"sources":["../../src/routing/segment-codegen.ts","../../src/routing/codegen-write.ts","../../src/shared/route-options-export.ts","../../src/routing/route-options.ts","../../src/routing/route-options-lint.ts","../../src/routing/convention-lint.ts"],"sourcesContent":["/**\n * $segment type generation and directory-to-route mapping.\n *\n * Generates per-route $segment.d.ts files in .timber/types/ that mirror\n * the app/ directory structure. TypeScript's rootDirs feature makes these\n * importable as './$segment' from route files.\n *\n * Design doc: design/41-global-params.md §The $segment Module\n */\n\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { writeFileAtomic } from '../utils/write-file-atomic.ts';\nimport type { RouteTree, SegmentNode } from './types.ts';\n\n/** Info carried per directory for type generation. */\nexport interface SegmentInfo {\n /** The URL route pattern (groups and slots stripped). e.g. '/[artistSlug]/[year]' */\n route: string;\n /** The full tree path including groups and slots — uniquely identifies a segment.\n * e.g. '/(browse)/[artistSlug]/@shows/[year]' */\n segmentPath: string;\n}\n\n/**\n * Build a map of absolute filesystem directory → segment info.\n * Used by resolveId to map a $segment import's importer to the correct route,\n * and by writeSegmentTypes to generate per-route $segment.d.ts files.\n *\n * Walks every segment (not just leaves) so layouts and middleware\n * at any depth can import $segment.\n */\nexport function buildDirToRouteMap(tree: RouteTree, appDir: string): Map<string, SegmentInfo> {\n const map = new Map<string, SegmentInfo>();\n\n function walk(node: SegmentNode, fsPath: string, treePath: string): void {\n map.set(fsPath, {\n route: node.urlPath || '/',\n segmentPath: treePath || '/',\n });\n\n for (const child of node.children) {\n const childDir = join(fsPath, child.segmentName);\n const childTreePath = `${treePath}/${child.segmentName}`;\n walk(child, childDir, childTreePath);\n }\n for (const [slotName, slotNode] of Object.entries(node.slots)) {\n const slotDir = join(fsPath, `@${slotName}`);\n const slotTreePath = `${treePath}/@${slotName}`;\n walk(slotNode, slotDir, slotTreePath);\n }\n }\n\n walk(tree.root, appDir, '');\n return map;\n}\n\n/**\n * Generate the full $segment.d.ts content for a segment.\n */\nexport function generateSegmentDts(info: SegmentInfo): string {\n return [\n `export const ROUTE: '${info.route}';`,\n `export const SEGMENT_PATH: '${info.segmentPath}';`,\n '',\n ].join('\\n');\n}\n\n/**\n * Generate per-route $segment.d.ts files in .timber/types/ mirroring\n * the app/ directory structure. These files are importable via TypeScript's\n * rootDirs feature.\n */\nexport async function writeSegmentTypes(\n routeTree: RouteTree,\n appDir: string,\n root: string\n): Promise<void> {\n // Compute the relative prefix from project root to appDir.\n // e.g. if appDir is /project/src/app, relative is 'src/app'\n const relative = appDir.slice(root.length + 1);\n const typesBase = join(root, '.timber', 'types', relative);\n const map = buildDirToRouteMap(routeTree, appDir);\n\n const writes: Promise<void>[] = [];\n for (const [fsDir, info] of map) {\n // Mirror the app/ structure under .timber/types/\n const relDir = fsDir.slice(appDir.length); // e.g. '/[artistSlug]/[year]'\n const segmentDir = join(typesBase, relDir);\n const segmentFile = join(segmentDir, '$segment.d.ts');\n const content = generateSegmentDts(info);\n\n writes.push(\n mkdir(segmentDir, { recursive: true }).then(() => writeFileAtomic(segmentFile, content))\n );\n }\n\n await Promise.all(writes);\n}\n","/**\n * Route-map codegen writer.\n *\n * Materializes the generated route types on disk: `.timber/timber-routes.d.ts`,\n * `.timber/segment-types.d.ts` (via `writeSegmentTypes`), and the root\n * `timber-env.d.ts` that references them.\n *\n * Lives outside `plugins/routing.ts` because it has two callers with two\n * different failure policies: the dev/build plugin starts the write off the hot\n * path and logs failures, while `timber check` awaits it and treats a failure as\n * fatal — a type check run against absent or stale route types reports errors\n * about code that is fine. One implementation, two policies, so the bytes on\n * disk cannot drift between the two commands.\n *\n * Design docs: 09-typescript.md §\"Typed Routes\", 18-build-system.md\n */\n\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateRouteMap } from './codegen.ts';\nimport { writeSegmentTypes } from './segment-codegen.ts';\nimport { writeFileAtomic } from '../utils/write-file-atomic.ts';\nimport type { RouteTree } from './types.ts';\n\n/**\n * Path (relative to the project root) of the generated route map declaration\n * file, and the name of the root file that `/// <reference>`s it.\n *\n * Exported because `timber check` has to answer whether the user's tsconfig\n * pulls these into the program — a question about these exact paths. It derives\n * them from here rather than restating them, so a rename cannot leave the check\n * looking for a file nothing writes.\n */\nexport const CODEGEN_OUTPUT = '.timber/timber-routes.d.ts';\n\n/** Root-level file that references the generated declarations. */\nexport const ENV_DTS_FILENAME = 'timber-env.d.ts';\n\n/**\n * Content of the timber-env.d.ts file written to the project root.\n *\n * Uses a triple-slash reference so TypeScript auto-discovers the generated\n * route map without the user needing to edit tsconfig.json — same pattern\n * as Next.js's next-env.d.ts.\n *\n * Also references `vite/client` so side-effect imports like\n * `import './globals.css'` type-check without ts(2882), and so\n * `import.meta.env`, `import.meta.hot`, `import.meta.glob`, asset\n * imports (`*.png`, `*.svg`, …), CSS modules, and `?url`/`?raw`/\n * `?inline` query variants all resolve without the user editing\n * tsconfig.json themselves. Next.js's next-env.d.ts plays the same\n * role via `next/types/global`.\n *\n * `vite` is a peer dep of `@timber-js/app`, so the reference always\n * resolves in a correctly-installed project.\n */\nconst TIMBER_ENV_DTS = [\n '// This file is auto-generated by timber.js. Do not edit.',\n '// It ensures TypeScript picks up the generated route types and',\n '// Vite-provided ambient types (CSS, assets, import.meta.env, HMR).',\n '/* eslint-disable @typescript-eslint/triple-slash-reference */',\n '/// <reference path=\".timber/timber-routes.d.ts\" />',\n '/// <reference types=\"vite/client\" />',\n '/// <reference types=\"react/canary\" />',\n '/// <reference types=\"react-dom/canary\" />',\n '',\n].join('\\n');\n\n/**\n * Codegen writes that have been started but have not yet landed on disk.\n *\n * `writeRouteCodegen` is deliberately unawaited on the dev/build hot path,\n * which leaves that caller no way to know the files exist yet. Anything that\n * tears down the project root — a build process exiting, a test removing its\n * temp root — then races the writes: `rmSync` empties a directory that a\n * pending `mkdir` immediately recreates, and the removal fails with ENOTEMPTY.\n *\n * Every started write registers here and deregisters when it settles, so\n * `flushCodegenWrites()` can await them instead of guessing at a delay.\n */\nconst pendingCodegenWrites = new Set<Promise<void>>();\n\n/**\n * Resolve once every codegen write started so far has landed on disk.\n *\n * Safe to call at any time and from anywhere — writes are tracked per process,\n * not per plugin instance, so a caller does not need a handle on the plugin\n * that started them. Never rejects: the tracked copy of each write has its\n * rejection swallowed, so a failing write cannot turn a teardown barrier into\n * an unhandled rejection. Callers that care about failure await the promise\n * `writeRouteCodegen` returned instead.\n */\nexport async function flushCodegenWrites(): Promise<void> {\n // Loop rather than a single Promise.all: a write started while we were\n // awaiting would otherwise be missed, and the set would still be non-empty\n // on return.\n //\n // Each round drops what it awaited rather than trusting the per-write\n // `finally` to have run, so the two removal paths are independent — a\n // deregistration that stopped firing would leak memory in dev, but it can\n // never turn this into a spin.\n while (pendingCodegenWrites.size > 0) {\n const inFlight = [...pendingCodegenWrites];\n await Promise.all(inFlight);\n for (const write of inFlight) pendingCodegenWrites.delete(write);\n }\n}\n\n/**\n * Write the generated route map, segment types, and the timber-env.d.ts\n * reference file for `tree`.\n *\n * Returns a promise that **rejects** if any write fails. The dev/build plugin\n * does not await it (types are a developer convenience there, not a runtime\n * dependency) and logs instead; `timber check` awaits it and fails the command.\n * Either way the write is registered with `flushCodegenWrites()`.\n */\n/**\n * Write `timber-env.d.ts` only when its content differs.\n *\n * Its content is constant per timber version, so almost every call is a no-op\n * — and a file that is not rewritten cannot be read half-written. It is not\n * replaced atomically because it lives in the user's project root, often\n * committed: a rename would turn a symlink into a regular file, reset its\n * permissions, and a process killed mid-write would leave a temp file next to\n * their source. The in-place write happens only on first run or a timber\n * upgrade.\n */\nasync function writeEnvDts(envPath: string): Promise<void> {\n const existing = await readFile(envPath, 'utf-8').catch(() => null);\n if (existing !== TIMBER_ENV_DTS) await writeFile(envPath, TIMBER_ENV_DTS, 'utf-8');\n}\n\nexport function writeRouteCodegen(tree: RouteTree, appDir: string, root: string): Promise<void> {\n const timberDir = join(root, '.timber');\n const content = generateRouteMap(tree, { appDir, outputDir: timberDir });\n const routesPath = join(root, CODEGEN_OUTPUT);\n const envPath = join(root, ENV_DTS_FILENAME);\n\n const done = mkdir(timberDir, { recursive: true })\n .then(() =>\n // The type checker can read these while they are being rewritten — an\n // editor's TS server during `timber dev`, a `tsgo` run during `vite\n // build`. A truncating write shows it an empty route map for the length\n // of the write, and every typed route degrades to `any` (TIM-1562).\n // The generated files under `.timber/` are replaced atomically.\n Promise.all([\n writeFileAtomic(routesPath, content),\n writeEnvDts(envPath),\n writeSegmentTypes(tree, appDir, root),\n ])\n )\n .then(() => undefined);\n\n // The tracked copy swallows rejection so `flushCodegenWrites` — a teardown\n // barrier — never rejects and never leaves an unhandled rejection behind.\n // The returned promise keeps its rejection for callers that want it.\n const tracked = done.catch(() => undefined);\n pendingCodegenWrites.add(tracked);\n void tracked.finally(() => pendingCodegenWrites.delete(tracked));\n\n return done;\n}\n","/**\n * The export a layout or page declares its options under (design/53\n * §\"Route-module options\"). One table for both readers: the build-time source\n * reader (`routing/route-options.ts`) and the runtime module loader\n * (`server/route-module-loader.ts`), which cannot import the source reader\n * because it pulls in `node:fs` and Vite's parser.\n */\n\nexport type RouteOptionsKind = 'layout' | 'page';\n\nexport const ROUTE_OPTIONS_EXPORT = {\n layout: 'layoutOptions',\n page: 'pageOptions',\n} as const satisfies Record<RouteOptionsKind, string>;\n","/**\n * Route-module options: `export const layoutOptions = { … }` in a layout and\n * `export const pageOptions = { … }` in a page, read from source.\n *\n * Design doc: design/53-segment-lifetime.md §\"Route-module options\".\n *\n * `prerender` is read here at build time, before any route module loads:\n * `plugins/prerender-sugar.ts` decides from it which pages to wrap in\n * `cache.component(...)`. Every other option is validated here and read at\n * runtime from the loaded module (`deferSuspenseFor`, in\n * `server/route-module-loader.ts`; `lifetime` and `key`, in\n * `server/segment-lifetime/segment-key.ts`). A key's `searchParams` and\n * `cookies` name definitions, so they are the one place a non-literal value is\n * accepted; `segmentParams` is checked against the segment's path by\n * `routing/route-options-lint.ts`. The whole object follows one rule so that\n * every key is checkable: this reader accepts one spelling —\n * `export const xOptions = { … }` of literal values, optionally behind\n * `satisfies` / `as` — and reports the others it can see as problems.\n * `routing/convention-lint.ts` turns problems into build errors:\n *\n * - a spread, a computed key, a getter or method, or a non-literal value\n * - an unknown key (a misspelled `prerendr`)\n * - `pageOptions` in a layout or `layoutOptions` in a page\n * - options in a `'use client'` file, whose exports the server never sees\n * - the removed floating exports, `export const prerender` and\n * `export const deferSuspenseFor`\n * - `let`, a destructured binding, a specifier or a named re-export\n * (`export { pageOptions } from`, `export * as pageOptions from`)\n *\n * What it cannot see is not reported: `export * from` is not followed, a\n * file that does not parse reads as having no options (the compiler reports\n * it), and MDX pages are not read at all, so `prerender` in an MDX page does\n * nothing and its `deferSuspenseFor` is unvalidated.\n */\n\nimport { headerKeyProblem } from '../shared/key-headers.ts';\nimport { existsSync } from 'node:fs';\nimport type {\n LayoutOptions,\n PageOptions,\n RoutePrerender,\n SegmentKey,\n SegmentLifetime,\n} from '../server/types.ts';\nimport { patternBinds, TRANSPARENT_WRAPPERS, tryParse } from './export-detect.ts';\nimport { readFileCached } from './file-cache.ts';\nimport { ROUTE_OPTIONS_EXPORT, type RouteOptionsKind } from '../shared/route-options-export.ts';\n\nconst OPTIONS_TYPE = { layout: 'LayoutOptions', page: 'PageOptions' } as const;\n\n/** Floating exports the options objects replaced (design/53). */\nconst REMOVED_EXPORTS = ['prerender', 'deferSuspenseFor'] as const;\n\nexport interface RouteOptionsRead {\n /**\n * The declared options. Undefined when the file declares none or when any\n * problem was found — a half-read object is never acted on.\n */\n options: LayoutOptions | PageOptions | undefined;\n /** One line per problem, each naming what to write instead. */\n problems: string[];\n}\n\n// ─── AST access ────────────────────────────────────────────────────────────\n\n/** An ESTree node as oxc's `parseAst` produces it, read field by field. */\ntype Node = { readonly type: string; readonly [field: string]: unknown };\n\nfunction isNode(value: unknown): value is Node {\n return (\n typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string'\n );\n}\n\nfunction child(node: Node, field: string): Node | undefined {\n const value = node[field];\n return isNode(value) ? value : undefined;\n}\n\nfunction list(node: Node, field: string): unknown[] {\n const value = node[field];\n return Array.isArray(value) ? value : [];\n}\n\n/** Strip `satisfies T`, `as T`, `(x)` and friends, which compile away. */\nfunction unwrap(node: Node): Node {\n let current = node;\n while (TRANSPARENT_WRAPPERS.has(current.type)) {\n const inner = child(current, 'expression');\n if (!inner) break;\n current = inner;\n }\n return current;\n}\n\n/** An identifier's name or a string literal's value (`export { x as \"y\" }`). */\nfunction nameOf(node: Node | undefined): string | undefined {\n if (!node) return undefined;\n if (typeof node.value === 'string') return node.value;\n return typeof node.name === 'string' ? node.name : undefined;\n}\n\n/** A literal's value; a template literal with no `${}` counts as a string. */\nfunction literal(node: Node): unknown {\n const n = unwrap(node);\n if (n.type === 'Literal') return n.value;\n if (n.type !== 'TemplateLiteral' || list(n, 'expressions').length > 0) return undefined;\n const [quasi] = list(n, 'quasis');\n // A TemplateElement's `value` is `{ raw, cooked }`, not a node.\n const parts = isNode(quasi) ? quasi.value : undefined;\n const value =\n typeof parts === 'object' && parts !== null && 'cooked' in parts ? parts.cooked : undefined;\n return typeof value === 'string' ? value : undefined;\n}\n\n/** `key: undefined` — the same as leaving the key out, as the types allow. */\nfunction isUndefined(node: Node): boolean {\n const n = unwrap(node);\n return n.type === 'Identifier' && n.name === 'undefined';\n}\n\n// ─── Value readers, one per option ────────────────────────────────────────\n\ntype Read<T> = { value: T } | { problem: string };\n\n/** A numeric literal is never negative (`-1` is a unary expression), so finite is enough. */\nfunction readNonNegativeNumber(node: Node, label: string): Read<number> {\n const value = literal(node);\n if (typeof value === 'number' && Number.isFinite(value)) return { value };\n return { problem: `${label} must be a non-negative number literal.` };\n}\n\nfunction readPrerender(node: Node): Read<RoutePrerender> {\n const value = literal(node);\n if (typeof value === 'boolean') return { value };\n const n = unwrap(node);\n if (n.type !== 'ObjectExpression') {\n return {\n problem: 'prerender must be `true`, `false`, or an object literal `{ ttl?, tags? }`.',\n };\n }\n const result: { ttl?: number; tags?: string[] } = {};\n for (const entry of readProperties(n, 'prerender')) {\n if ('problem' in entry) return entry;\n if (entry.key === 'ttl') {\n const ttl = readNonNegativeNumber(entry.value, 'prerender.ttl');\n if ('problem' in ttl) return ttl;\n result.ttl = ttl.value;\n } else if (entry.key === 'tags') {\n const tags = readStringArray(entry.value);\n if (!tags) return { problem: 'prerender.tags must be an array of string literals.' };\n result.tags = tags;\n } else {\n return { problem: `Unknown key \"${entry.key}\" in prerender. Allowed: ttl, tags.` };\n }\n }\n return { value: result };\n}\n\nfunction readStringArray(node: Node): string[] | undefined {\n const n = unwrap(node);\n if (n.type !== 'ArrayExpression') return undefined;\n const result: string[] = [];\n for (const element of list(n, 'elements')) {\n const value = isNode(element) ? literal(element) : undefined;\n if (typeof value !== 'string') return undefined;\n result.push(value);\n }\n return result;\n}\n\n/**\n * One reader per option key. Typed against the public option types, so an\n * option added to `PageOptions` / `LayoutOptions` without a reader here (or a\n * reader without the option) fails typecheck — the two lists cannot drift.\n */\ntype Readers<T> = {\n [K in keyof Required<T>]: (\n node: Node\n ) => Read<NonNullable<T[K]> extends SegmentKey ? BuildTimeKey : NonNullable<T[K]>>;\n};\n\nconst deferSuspenseFor = (node: Node) => readNonNegativeNumber(node, 'deferSuspenseFor');\n\nconst LIFETIMES: readonly SegmentLifetime[] = ['request', 'document'];\n\nfunction readLifetime(node: Node): Read<SegmentLifetime> {\n const value = literal(node);\n const lifetime = LIFETIMES.find((l) => l === value);\n if (lifetime) return { value: lifetime };\n return { problem: \"lifetime must be 'request' or 'document'.\" };\n}\n\n/**\n * What the build can read of a segment key: the param and header names. `searchParams`\n * and `cookies` name definitions — code the build cannot evaluate — so only\n * their shape is checked here; their values take effect from the loaded\n * module (`server/segment-lifetime/`). The route-options lint checks the\n * param names against the segment's path.\n */\ntype BuildTimeKey = Pick<SegmentKey, 'segmentParams' | 'headers'>;\n\nfunction readHeaderNames(node: Node): Read<string[]> {\n const names = readStringArray(node);\n if (!names) return { problem: 'key.headers must be an array of header-name string literals.' };\n for (const name of names) {\n const problem = headerKeyProblem(name);\n if (problem) return { problem };\n }\n return { value: names };\n}\n\n/** A value written in place, which cannot be a definition imported or declared elsewhere. */\nfunction isInlineValue(node: Node): boolean {\n const type = unwrap(node).type;\n return (\n literal(node) !== undefined ||\n type === 'ObjectExpression' ||\n type === 'ArrayExpression' ||\n type === 'Literal' ||\n type === 'TemplateLiteral'\n );\n}\n\nfunction readKey(node: Node): Read<BuildTimeKey> {\n const n = unwrap(node);\n if (n.type !== 'ObjectExpression') {\n return {\n problem:\n 'key must be an object literal `{ segmentParams?, searchParams?, cookies?, headers? }`.',\n };\n }\n const result: BuildTimeKey = {};\n for (const entry of readProperties(n, 'key')) {\n if ('problem' in entry) return entry;\n if (entry.key === 'segmentParams') {\n const names = readStringArray(entry.value);\n if (!names) return { problem: 'key.segmentParams must be an array of string literals.' };\n result.segmentParams = names;\n } else if (entry.key === 'searchParams') {\n if (isInlineValue(entry.value)) {\n return {\n problem:\n 'key.searchParams must name a search-params definition (`defineSearchParams`, or a `.pick()` of one).',\n };\n }\n } else if (entry.key === 'cookies') {\n const array = unwrap(entry.value);\n const elements = list(array, 'elements');\n const definitions = elements.every(\n (e) => isNode(e) && e.type !== 'SpreadElement' && !isInlineValue(e)\n );\n if (array.type !== 'ArrayExpression' || !definitions) {\n return {\n problem: 'key.cookies must be an array literal of cookie definitions (`defineCookie`).',\n };\n }\n } else if (entry.key === 'headers') {\n const headers = readHeaderNames(entry.value);\n if ('problem' in headers) return headers;\n result.headers = headers.value;\n } else {\n return {\n problem: `Unknown key \"${entry.key}\" in key. Allowed: segmentParams, searchParams, cookies, headers.`,\n };\n }\n }\n return { value: result };\n}\n\nconst READERS = {\n layout: {\n lifetime: readLifetime,\n key: readKey,\n prerender: readPrerender,\n deferSuspenseFor,\n } satisfies Readers<LayoutOptions>,\n page: {\n lifetime: readLifetime,\n key: readKey,\n prerender: readPrerender,\n deferSuspenseFor,\n } satisfies Readers<PageOptions>,\n};\n\n// ─── Object literal ───────────────────────────────────────────────────────\n\ntype Entry = { key: string; value: Node } | { problem: string };\n\n/**\n * The `key: value` entries of an object literal, or a problem per entry that\n * has none. `key: undefined` entries are dropped: they mean \"not set\".\n */\nfunction readProperties(object: Node, label: string): Entry[] {\n return list(object, 'properties').flatMap((prop): Entry[] => {\n if (!isNode(prop) || prop.type === 'SpreadElement') {\n return [{ problem: `${label} cannot use a spread; write every key in the literal.` }];\n }\n if (prop.computed === true) {\n return [{ problem: `${label} cannot use a computed key; write the key name.` }];\n }\n const value = child(prop, 'value');\n const key = nameOf(child(prop, 'key'));\n if (prop.kind !== 'init' || prop.method === true || !value || key === undefined) {\n return [{ problem: `${label} entries must be plain \\`key: value\\` pairs.` }];\n }\n return isUndefined(value) ? [] : [{ key, value }];\n });\n}\n\nfunction readOptionsObject(init: Node, kind: RouteOptionsKind, problems: string[]) {\n const name = ROUTE_OPTIONS_EXPORT[kind];\n const object = unwrap(init);\n if (object.type !== 'ObjectExpression') {\n problems.push(`${name} must be an object literal: \\`export const ${name} = { … }\\`.`);\n return undefined;\n }\n const readers: Record<string, (node: Node) => Read<unknown>> = READERS[kind];\n const options: Record<string, unknown> = {};\n for (const entry of readProperties(object, name)) {\n if ('problem' in entry) {\n problems.push(entry.problem);\n continue;\n }\n const reader = Object.hasOwn(readers, entry.key) ? readers[entry.key] : undefined;\n if (!reader) {\n problems.push(\n `Unknown key \"${entry.key}\" in ${name}. Allowed: ${Object.keys(readers).join(', ')}.`\n );\n continue;\n }\n const read = reader(entry.value);\n if ('problem' in read) problems.push(read.problem);\n else options[entry.key] = read.value;\n }\n return options;\n}\n\n// ─── File ─────────────────────────────────────────────────────────────────\n\nconst NONE: RouteOptionsRead = Object.freeze({ options: undefined, problems: [] });\n\n/** Every name the reader reacts to; a file containing none of them is not parsed. */\nconst MENTIONS = /Options|prerender|deferSuspenseFor/;\n\n/**\n * Read a layout's `layoutOptions` or a page's `pageOptions` from source.\n *\n * A missing or unparseable file reads as no options and no problems: the\n * compiler reports syntax errors, and guessing at a half-written file would\n * misreport it. `.ts` files are parsed as TypeScript, not TSX, so an\n * angle-bracket cast does not hide a file from this check.\n */\nexport function readRouteOptions(filePath: string, kind: RouteOptionsKind): RouteOptionsRead {\n if (!existsSync(filePath)) return NONE;\n const source = readFileCached(filePath);\n // Runs on every page and layout on each rescan; most declare nothing.\n if (!MENTIONS.test(source)) return NONE;\n const program = tryParse(source, /\\.[mc]?ts$/.test(filePath) ? 'ts' : 'tsx');\n if (!program) return NONE;\n\n const own = ROUTE_OPTIONS_EXPORT[kind];\n const otherKind: RouteOptionsKind = kind === 'page' ? 'layout' : 'page';\n const other = ROUTE_OPTIONS_EXPORT[otherKind];\n const problems: string[] = [];\n let init: Node | undefined;\n\n /** An export of a watched name in a form the build cannot read. */\n const report = (name: string | undefined) => {\n if (name === own) {\n problems.push(\n `${own} must be declared in this file as \\`export const ${own} = { … } satisfies ${OPTIONS_TYPE[kind]}\\`. ` +\n '`let`, destructuring, `export { … }` and re-exports cannot be read at build time.'\n );\n } else if (name === other) {\n problems.push(\n `${other} configures a ${otherKind}; this file is a ${kind}. Use \\`export const ${own}\\`.`\n );\n } else if (name && (REMOVED_EXPORTS as readonly string[]).includes(name)) {\n problems.push(\n `\\`export const ${name}\\` was removed. Move it into the options object: ` +\n `\\`export const ${own} = { ${name}: … } satisfies ${OPTIONS_TYPE[kind]}\\`.`\n );\n }\n };\n const watched = [own, other, ...REMOVED_EXPORTS];\n\n for (const stmt of program.body) {\n if (!isNode(stmt) || stmt.exportKind === 'type') continue;\n // `export * as pageOptions from` names an export; bare `export * from` does not.\n if (stmt.type === 'ExportAllDeclaration') report(nameOf(child(stmt, 'exported')));\n if (stmt.type !== 'ExportNamedDeclaration') continue;\n for (const spec of list(stmt, 'specifiers')) {\n if (isNode(spec) && spec.exportKind !== 'type') report(nameOf(child(spec, 'exported')));\n }\n const decl = child(stmt, 'declaration');\n if (!decl) continue;\n if (decl.type !== 'VariableDeclaration') {\n report(nameOf(child(decl, 'id'))); // function or class\n continue;\n }\n for (const declarator of list(decl, 'declarations')) {\n if (!isNode(declarator)) continue;\n const id = child(declarator, 'id');\n const value = child(declarator, 'init');\n if (id?.type !== 'Identifier') {\n for (const name of watched) if (patternBinds(id, name)) report(name);\n } else if (id.name === own && decl.kind === 'const' && value) {\n init = value;\n } else {\n report(nameOf(id));\n }\n }\n }\n\n if (init && isClientModule(program.body)) {\n problems.push(\n `A 'use client' ${kind} cannot declare ${own}: the server sees a client reference, ` +\n `not the object. Move ${own} to a server ${kind} that renders the client component.`\n );\n }\n const options = init ? readOptionsObject(init, kind, problems) : undefined;\n return { options: problems.length === 0 ? options : undefined, problems };\n}\n\n/** Whether the module starts with a 'use client' directive. */\nfunction isClientModule(body: readonly unknown[]): boolean {\n for (const stmt of body) {\n if (\n !isNode(stmt) ||\n stmt.type !== 'ExpressionStatement' ||\n typeof stmt.directive !== 'string'\n ) {\n return false;\n }\n if (stmt.directive === 'use client') return true;\n }\n return false;\n}\n","/**\n * Convention-lint check for route-module options (design/53 §\"Route-module\n * options\"): `layoutOptions` / `pageOptions` the build cannot read, and\n * options declared where nothing reads them. Called from\n * `lintConventions` in `convention-lint.ts`.\n */\n\nimport type { ConventionWarning } from './convention-lint.ts';\nimport { fileHasAnyExport, isScriptExtension } from './export-detect.ts';\nimport { readRouteOptions } from './route-options.ts';\nimport type { RouteFile, SegmentNode } from './types.ts';\nimport type { LayoutOptions, PageOptions, SegmentLifetime } from '../server/types.ts';\nimport { ROUTE_OPTIONS_EXPORT, type RouteOptionsKind } from '../shared/route-options-export.ts';\n\n/**\n * Fail the build on a `layoutOptions` / `pageOptions` the build cannot read.\n *\n * Proven from source and fatal in the sense the error level requires: the\n * developer declared an option that would otherwise silently do nothing — a\n * misspelled key, a value the build cannot read, an options object in the\n * wrong file kind, or a floating `export const prerender` that no longer\n * prerenders. See `routing/route-options.ts` for what is accepted.\n */\nexport function checkRouteOptions(\n node: SegmentNode,\n warnings: ConventionWarning[],\n position: RoutePosition,\n /** The app's `defaultLayoutLifetime` (design/53 §\"App-wide default\"). */\n defaultLayoutLifetime: SegmentLifetime,\n /** The params named on the path above this segment. */\n ancestorParams: readonly string[] = []\n): void {\n const here: RoutePosition = node.segmentType === 'intercepting' ? 'intercepting' : position;\n const pathParams = node.paramName ? [...ancestorParams, node.paramName] : ancestorParams;\n const files: Array<[RouteOptionsKind, RouteFile | undefined]> = [\n ['layout', node.layout],\n ['page', node.page],\n ];\n for (const [kind, file] of files) {\n if (!file || !isScriptExtension(file.extension)) continue;\n const { options, problems } = readRouteOptions(file.filePath, kind);\n problems.push(\n ...inertOptions(options, here),\n ...paramsOffPath(options, pathParams),\n ...keyWithoutDocument(options, kind === 'layout' ? defaultLayoutLifetime : 'request')\n );\n if (problems.length === 0) continue;\n warnings.push({\n id: `ROUTE_OPTIONS_INVALID:${file.filePath}`,\n summary: `${kind}.${file.extension} has invalid ${ROUTE_OPTIONS_EXPORT[kind]}: ${file.filePath}`,\n details:\n ` File: ${file.filePath}\\n\\n` +\n problems.map((problem) => ` - ${problem}\\n`).join('') +\n '\\n Options are read from source at build time, so they must be one object\\n' +\n ' literal of literal values.\\n',\n level: 'error',\n });\n }\n if (node.default && isScriptExtension(node.default.extension)) {\n const declared = fileHasAnyExport(node.default.filePath, OPTION_EXPORT_NAMES);\n if (declared.size > 0) {\n warnings.push({\n id: `ROUTE_OPTIONS_INVALID:${node.default.filePath}`,\n summary: `default.${node.default.extension} takes no route options: ${node.default.filePath}`,\n details:\n ` File: ${node.default.filePath}\\n\\n` +\n ` default.tsx exports ${[...declared].join(', ')}, which nothing reads.\\n` +\n ' To fix: remove the export; declare options on the slot page or layout.\\n',\n level: 'error',\n });\n }\n }\n for (const child of node.children) {\n checkRouteOptions(child, warnings, here, defaultLayoutLifetime, pathParams);\n }\n for (const slot of Object.values(node.slots)) {\n const slotPosition = here === 'intercepting' ? here : 'slot';\n checkRouteOptions(slot, warnings, slotPosition, defaultLayoutLifetime, pathParams);\n }\n}\n\n/**\n * A `key` applies only to a `'document'` segment; on any other it would\n * silently do nothing. A layout that declares no lifetime takes the app's\n * `defaultLayoutLifetime`, so under a `'document'` default it may declare a\n * key alone. A page always defaults to `'request'`.\n */\nfunction keyWithoutDocument(\n options: LayoutOptions | PageOptions | undefined,\n defaultLifetime: SegmentLifetime\n): string[] {\n if (options?.key === undefined || (options.lifetime ?? defaultLifetime) === 'document') return [];\n return [\n \"key applies only to lifetime: 'document'. Declare `lifetime: 'document'` or remove key.\",\n ];\n}\n\n/**\n * A key's `segmentParams` must name params on the segment's path — the\n * segment's own and every ancestor's, slots included. Anything else could\n * never change, so the key would silently ignore what the author meant\n * (design/53 §\"Segment keys\").\n */\nfunction paramsOffPath(\n options: LayoutOptions | PageOptions | undefined,\n pathParams: readonly string[]\n): string[] {\n const declared = options?.key?.segmentParams ?? [];\n return declared\n .filter((name) => !pathParams.includes(name))\n .map(\n (name) =>\n `key.segmentParams names \"${name}\", which is not a param on this segment's path. ` +\n (pathParams.length > 0\n ? `Params on the path: ${pathParams.join(', ')}.`\n : 'This path has no params.')\n );\n}\n\n/**\n * Where a segment sits decides which options take effect there.\n * - `main`: the matched route chain. Every option applies.\n * - `slot`: a parallel slot. `prerender` applies to slot pages (the sugar\n * walks slots); `deferSuspenseFor` does not — the hold is read from the\n * main chain's modules only (`server/route-module-loader.ts`).\n * - `intercepting`: an intercepting route and everything under it. It renders\n * only on a soft navigation, through the slot resolver, and the sugar skips\n * it, so no option applies.\n */\ntype RoutePosition = 'main' | 'slot' | 'intercepting';\n\nconst OPTION_EXPORT_NAMES = [\n ...Object.values(ROUTE_OPTIONS_EXPORT),\n 'prerender',\n 'deferSuspenseFor',\n] as const;\n\nfunction inertOptions(\n options: LayoutOptions | PageOptions | undefined,\n position: RoutePosition\n): string[] {\n if (!options || position === 'main') return [];\n const inert = Object.keys(options).filter(\n (key) => position === 'intercepting' || key === 'deferSuspenseFor'\n );\n return inert.map((key) =>\n position === 'intercepting'\n ? `${key} has no effect on an intercepting route: it renders only on a soft navigation, ` +\n 'through the slot that intercepts it. Declare it on the route being intercepted.'\n : `${key} has no effect in a parallel slot: the hold is read from the main route's ` +\n 'layouts and page. Declare it there.'\n );\n}\n","/**\n * Convention linter — validates common misconfigurations in the route tree.\n *\n * Runs at scan time (build and dev startup). Each check produces a warning\n * with the file path, what's wrong, and what to do about it.\n *\n * Most checks are warnings — they don't block the build. The goal is to catch\n * issues that would otherwise produce cryptic runtime behavior (silent 404s,\n * empty pages, confusing React errors).\n *\n * A check emits `level: 'error'` only when the misconfiguration is *proven*\n * (never inferred from an absence the analysis cannot see through) and either\n * fatal to rendering or a declaration that provably does nothing — a CSRF\n * exemption the gate never reads, a route option the build cannot read, a\n * middleware.ts in a slot. The developer believes the declaration is in\n * effect, so silence would ship the wrong behavior. `plugins/routing.ts` turns those into a thrown build error,\n * so a false positive there refuses a working app — see\n * `classifyClientBoundaryFile` for how that bar is met.\n *\n * Design doc: 07-routing.md, 10-error-handling.md\n */\n\nimport { existsSync } from 'node:fs';\nimport type { RouteFile, RouteTree, SegmentNode } from './types.ts';\nimport { swallow } from '../server/logger.ts';\nimport { HTTP_METHODS } from '../server/route-methods.ts';\nimport {\n fileDefaultExportIsLocalValue,\n fileHasAnyExport,\n fileHasDefaultExport,\n fileHasDirective,\n fileHasStarExport,\n getCsrfExport,\n isScriptExtension,\n} from './export-detect.ts';\nimport { checkRouteOptions } from './route-options-lint.ts';\nimport type { SegmentLifetime } from '../server/types.ts';\n\n// ─── Types ──────────────────────────────────────────────────────────────────\n\nexport interface ConventionWarning {\n /** Warning ID for deduplication and filtering. */\n id: string;\n /** Human-readable single-line summary. */\n summary: string;\n /** Multi-line details with file path and fix suggestion. */\n details: string;\n /** Severity: 'warn' for potential issues, 'error' for definite misconfigurations. */\n level: 'warn' | 'error';\n}\n\n// ─── Lint Rules ─────────────────────────────────────────────────────────────\n\n/**\n * Run all convention lint checks on a route tree.\n *\n * Returns an array of warnings. Empty array means everything looks good.\n */\nexport function lintConventions(\n tree: RouteTree,\n appDir: string,\n /** The config the checks depend on, as the build resolved it. */\n config: { defaultLayoutLifetime: SegmentLifetime | undefined }\n): ConventionWarning[] {\n const warnings: ConventionWarning[] = [];\n\n // Check 1: app/ directory exists (caller should check before scanning,\n // but we validate the root has at least one routable file)\n checkEmptyApp(tree.root, appDir, warnings);\n\n // Check 2: route.ts without recognized HTTP method exports\n checkRouteExports(tree.root, warnings);\n\n // Check 3: Segments with layout but no page/route anywhere in subtree\n // (not a misconfiguration per se — layouts without pages are valid for\n // route groups. Skip this check.)\n\n // Check 4: Root segment has no layout.tsx (no HTML shell)\n checkRootLayout(tree.root, warnings);\n\n // Check 5: page.tsx / layout.tsx without default export\n checkDefaultExports(tree.root, warnings);\n\n // Check 6: Client layouts cannot suppress server children before Flight\n // serializes them. They remain valid UI boundaries, but not authorization\n // or data-hiding boundaries.\n checkClientLayouts(tree.root, warnings);\n\n // Check 7: error.tsx / 404.tsx / 4xx.tsx / … without 'use client' directive\n checkClientBoundaryFiles(tree.root, warnings);\n if (tree.globalError) {\n checkFileUseClientDirective(tree.globalError, 'global-error', warnings);\n }\n\n // Check 8: middleware.ts inside a parallel slot subtree (silently dead)\n checkSlotMiddleware(tree.root, warnings);\n\n // Check 9: `export const csrf` anywhere but route.ts, or in a form the\n // scanner cannot read (TIM-1543)\n checkCsrfExports(tree.root, warnings);\n if (tree.proxy) checkCsrfExport(tree.proxy, 'proxy.ts', warnings);\n if (tree.globalError) checkCsrfExport(tree.globalError, 'global-error', warnings);\n\n // Check 10: layoutOptions / pageOptions the build cannot read, unknown\n // keys, and the removed floating exports (design/53)\n checkRouteOptions(tree.root, warnings, 'main', config.defaultLayoutLifetime ?? 'request');\n\n return warnings;\n}\n\nfunction checkClientLayouts(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.layout && isScriptExtension(node.layout.extension)) {\n try {\n const isClient = fileHasDirective(node.layout.filePath, 'use client');\n const isProvablyServer = fileDefaultExportIsLocalValue(node.layout.filePath);\n if (isClient || !isProvablyServer) {\n const certainty = isClient\n ? `This layout is a client component.`\n : `Timber cannot prove this layout is a server component because its default export comes from another module or an opaque expression.`;\n warnings.push({\n id: `CLIENT_LAYOUT_NOT_AUTH_BOUNDARY:${node.layout.filePath}`,\n summary: isClient\n ? `Client layout cannot securely suppress server children: ${node.layout.filePath}`\n : `Layout may resolve to a client component and cannot be trusted as an auth boundary: ${node.layout.filePath}`,\n details:\n ` File: ${node.layout.filePath}\\n\\n` +\n ` ${certainty}\\n` +\n ` React Flight resolves server content passed to a client layout before the layout runs in the browser.\\n` +\n ` Conditionally omitting children here does not prevent descendant server components from executing or being serialized.\\n\\n` +\n ` To fix: Put authorization in access.ts or a provably server layout with a locally defined default component, and keep client components inside that boundary.\\n`,\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable layout file ${node.layout.filePath}`);\n }\n }\n for (const child of node.children) checkClientLayouts(child, warnings);\n for (const slot of Object.values(node.slots)) checkClientLayouts(slot, warnings);\n}\n\n// ─── Check: CSRF Exemption Export ──────────────────────────────────────────\n\n/** Single-file segment conventions other than route.ts. */\nconst NON_ROUTE_FILE_KEYS = [\n 'page',\n 'layout',\n 'middleware',\n 'access',\n 'error',\n 'default',\n 'denied',\n] as const satisfies readonly (keyof SegmentNode)[];\n\n/**\n * Fail the build on a `csrf` export the CSRF gate would not honor.\n *\n * Both findings are proven from source, and both are fatal in the sense\n * the error level requires: the developer wrote an exemption that silently\n * does nothing, so a legitimate cross-site POST they meant to accept gets\n * a 403 in production, or they believe a page or action is exempt when\n * the gate still protects it. The exemption exists only on route.ts —\n * server actions always get the check (design/08 §\"Per-route exemption\").\n * A `'use server'` module cannot export it at all: plugin-rsc rejects every\n * non-async-function export there.\n */\nfunction checkCsrfExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.route) checkCsrfExport(node.route, 'route.ts', warnings);\n for (const key of NON_ROUTE_FILE_KEYS) {\n const file = node[key];\n if (file) checkCsrfExport(file, key, warnings);\n }\n // Status files and metadata routes (sitemap.ts, opengraph-image.tsx, …).\n // JSON status files are skipped by the script-extension check.\n for (const [name, file] of Object.entries(node.statusFiles ?? {})) {\n checkCsrfExport(file, name, warnings);\n }\n for (const [name, file] of Object.entries(node.metadataRoutes ?? {})) {\n checkCsrfExport(file, name, warnings);\n }\n for (const child of node.children) checkCsrfExports(child, warnings);\n for (const slot of Object.values(node.slots)) checkCsrfExports(slot, warnings);\n}\n\nfunction checkCsrfExport(file: RouteFile, convention: string, warnings: ConventionWarning[]): void {\n if (!isScriptExtension(file.extension)) return;\n const found = getCsrfExport(file.filePath);\n if (found === 'absent') return;\n const isRoute = convention === 'route.ts';\n if (isRoute && found === 'exempt') return;\n warnings.push({\n id: `CSRF_EXPORT_INVALID:${file.filePath}`,\n summary: isRoute\n ? `route.ts csrf export must be exactly \\`export const csrf = false\\`: ${file.filePath}`\n : `\\`csrf\\` can only be exported from route.ts, not ${convention}: ${file.filePath}`,\n details:\n ` File: ${file.filePath}\\n\\n` +\n (isRoute\n ? ' The CSRF gate reads this export from source before any module loads, so only\\n' +\n ' the literal form counts. Other values, `let`, and re-exports are not read.\\n\\n' +\n ' To fix: write `export const csrf = false;` in this file, or remove the export.\\n'\n : ' The per-route CSRF exemption applies only to route.ts handlers. Pages, layouts\\n' +\n ' and server actions always get the CSRF check.\\n\\n' +\n ' To fix: remove the export. To accept a cross-site POST, handle it in a route.ts\\n' +\n ' that exports `const csrf = false`.\\n'),\n level: 'error',\n });\n}\n\n// ─── Check: Empty App ───────────────────────────────────────────────────────\n\n/**\n * Warn when the app/ directory has no routable files at all.\n *\n * This catches the \"I created app/ but didn't add any pages\" case where\n * every request silently 404s with no guidance.\n */\nfunction checkEmptyApp(root: SegmentNode, appDir: string, warnings: ConventionWarning[]): void {\n if (hasAnyRoutable(root)) return;\n\n warnings.push({\n id: 'EMPTY_APP',\n summary: 'No pages or route handlers found in app/',\n details:\n ` Directory: ${appDir}\\n\\n` +\n ' Your app/ directory has no page.tsx or route.ts files.\\n' +\n ' Every request will return 404.\\n\\n' +\n ' To fix: Create app/page.tsx with a default export:\\n\\n' +\n ' export default function Home() {\\n return <h1>Hello</h1>;\\n }\\n',\n level: 'warn',\n });\n}\n\n/**\n * Check if a segment tree has any routable files (page or route) anywhere.\n */\nfunction hasAnyRoutable(node: SegmentNode): boolean {\n if (node.page || node.route) return true;\n for (const child of node.children) {\n if (hasAnyRoutable(child)) return true;\n }\n for (const slot of Object.values(node.slots)) {\n if (hasAnyRoutable(slot)) return true;\n }\n return false;\n}\n\n/**\n * Check if a segment tree has any page files (not just route handlers).\n * Used by checkRootLayout to avoid false positives for API-only apps (TIM-794).\n * API-only apps (just route.ts handlers) don't need a root layout.\n */\nfunction hasAnyPage(node: SegmentNode): boolean {\n if (node.page) return true;\n for (const child of node.children) {\n if (hasAnyPage(child)) return true;\n }\n for (const slot of Object.values(node.slots)) {\n if (hasAnyPage(slot)) return true;\n }\n return false;\n}\n\n// ─── Check: Route Exports ───────────────────────────────────────────────────\n\n/**\n * Warn when a route.ts file doesn't appear to export any recognized HTTP methods.\n *\n * Uses AST-based detection via parseAst for precise matching.\n * Falls back silently when the file can't be parsed (syntax errors produce\n * no spurious warning — the TS compiler will catch those).\n */\nfunction checkRouteExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.route) {\n const filePath = node.route.filePath;\n try {\n const methods = fileHasAnyExport(filePath, HTTP_METHODS);\n if (methods.size === 0 && !fileHasStarExport(filePath)) {\n const hasDefault = fileHasDefaultExport(filePath);\n const hint = hasDefault\n ? ' It looks like you have a default export. route.ts uses named exports\\n' +\n ' for HTTP methods (GET, POST, etc.), not a default export.\\n'\n : '';\n\n warnings.push({\n id: 'ROUTE_NO_METHODS',\n summary: `route.ts has no HTTP method exports: ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ' route.ts files must export named HTTP method handlers.\\n' +\n ' Without them, the route matches but returns 405 Method Not Allowed.\\n\\n' +\n hint +\n ' Example:\\n\\n' +\n ' export function GET(ctx: RouteContext) {\\n' +\n \" return Response.json({ hello: 'world' });\\n\" +\n ' }\\n',\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable route.ts ${filePath}`);\n }\n }\n\n // Recurse\n for (const child of node.children) {\n checkRouteExports(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkRouteExports(slot, warnings);\n }\n}\n\n// ─── Check: Root Layout ─────────────────────────────────────────────────────\n\n/**\n * Warn when the root segment has no layout.tsx.\n *\n * Without a root layout, there's no HTML shell (<html>, <body>).\n * The page will render but may have hydration issues or no proper document structure.\n */\nfunction checkRootLayout(root: SegmentNode, warnings: ConventionWarning[]): void {\n if (root.layout) return;\n\n // Only warn if there are pages — API-only apps (just route.ts handlers)\n // don't need a root layout (TIM-794).\n if (!hasAnyPage(root)) return;\n\n warnings.push({\n id: 'NO_ROOT_LAYOUT',\n summary: 'No root layout.tsx found',\n details:\n ' Your app has pages but no root layout.\\n' +\n ' Without app/layout.tsx, pages have no <html> or <body> wrapper.\\n\\n' +\n ' To fix: Create app/layout.tsx:\\n\\n' +\n ' export default function RootLayout({ children }: { children: React.ReactNode }) {\\n' +\n ' return (\\n' +\n ' <html lang=\"en\">\\n' +\n ' <body>{children}</body>\\n' +\n ' </html>\\n' +\n ' );\\n' +\n ' }\\n',\n level: 'warn',\n });\n}\n\n// ─── Check: Default Exports ───────────────────────────────────────────\n\n/**\n * Warn when page.tsx or layout.tsx files don't have a default export.\n *\n * Without a default export:\n * - page.tsx: the page renders nothing (empty content)\n * - layout.tsx: the layout module loads but has no component to render\n *\n * Uses AST-based detection via parseAst for precise matching. Falls back\n * silently when the file can't be parsed (no spurious warning on syntax errors).\n */\nfunction checkDefaultExports(node: SegmentNode, warnings: ConventionWarning[]): void {\n // Check page files (tsx/ts/jsx/js only — not mdx, which is default-exported by the mdx compiler)\n if (node.page && isScriptExtension(node.page.extension)) {\n checkFileDefaultExport(node.page.filePath, 'page', warnings);\n }\n\n // Check layout files\n if (node.layout && isScriptExtension(node.layout.extension)) {\n checkFileDefaultExport(node.layout.filePath, 'layout', warnings);\n }\n\n // Recurse\n for (const child of node.children) {\n checkDefaultExports(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkDefaultExports(slot, warnings);\n }\n}\n\nfunction checkFileDefaultExport(\n filePath: string,\n fileType: string,\n warnings: ConventionWarning[]\n): void {\n try {\n if (!fileHasDefaultExport(filePath)) {\n warnings.push({\n id: `NO_DEFAULT_EXPORT:${filePath}`,\n summary: `${fileType}.tsx has no default export: ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ` ${fileType}.tsx files must export a default React component.\\n` +\n ` Without a default export, the ${fileType === 'page' ? 'page renders nothing' : 'layout has no component to wrap children'}.\\n\\n` +\n ` To fix: Add a default export:\\n\\n` +\n ` export default function My${fileType === 'page' ? 'Page' : 'Layout'}(${fileType === 'layout' ? '{ children }' : ''}) {\\n` +\n ` return ${fileType === 'layout' ? '<div>{children}</div>' : '<h1>Hello</h1>'};\\n` +\n ` }\\n`,\n level: 'warn',\n });\n }\n } catch (err) {\n swallow(err, `convention-lint: unreadable ${fileType} file ${filePath}`);\n }\n}\n\n// ─── Check: Client Boundary Directive ───────────────────────────────────────\n\n/**\n * Check every file the renderer hands to `TimberErrorBoundary` as a component\n * prop: `error.tsx`, `global-error.tsx`, and the status-code family\n * (`404.tsx`, `4xx.tsx`, `503.tsx`, …).\n *\n * `TimberErrorBoundary` is a client component, so a server component passed as\n * `fallbackComponent` is a function crossing the RSC → client boundary. React\n * Flight refuses to serialize it, and because the boundary wraps the segment's\n * *children*, the failure hits every page under that segment — not just the\n * error path. The raw message (\"Functions cannot be passed directly to Client\n * Components\") names neither the file nor the fix (TIM-1329).\n *\n * `.json` status files never reach React at all, and are not in `statusFiles`.\n */\nfunction checkClientBoundaryFiles(node: SegmentNode, warnings: ConventionWarning[]): void {\n if (node.error) {\n checkFileUseClientDirective(node.error, 'error', warnings);\n }\n\n for (const [key, file] of Object.entries(node.statusFiles ?? {})) {\n checkFileUseClientDirective(file, key, warnings);\n }\n\n for (const child of node.children) {\n checkClientBoundaryFiles(child, warnings);\n }\n for (const slot of Object.values(node.slots)) {\n checkClientBoundaryFiles(slot, warnings);\n }\n}\n\n/**\n * `'client'` — carries the directive.\n * `'server'` — proven server component: no directive, and the default export is\n * a function or class built by this very module, so no other file's directive\n * can be governing it.\n * `'unknown'` — no directive, but the exported value may come from elsewhere\n * (`export { default } from './client-thing'`), or the file could not be\n * read or parsed. Never escalated to a build error.\n */\ntype ClientBoundaryVerdict = 'client' | 'server' | 'unknown';\n\nfunction classifyClientBoundaryFile(filePath: string): ClientBoundaryVerdict {\n if (fileHasDirective(filePath, 'use client')) return 'client';\n if (fileDefaultExportIsLocalValue(filePath)) return 'server';\n return 'unknown';\n}\n\n/** Example component name for the fix snippet, keyed by convention name. */\nfunction exampleComponentName(convention: string): string {\n if (convention === 'global-error') return 'GlobalError';\n if (convention === 'error') return 'ErrorBoundary';\n if (convention === '404') return 'NotFound';\n return 'StatusPage';\n}\n\n/**\n * @param file the route file (its extension decides whether the check applies)\n * @param convention the convention name — `error`, `global-error`, `404`, `4xx`, …\n */\nfunction checkFileUseClientDirective(\n file: RouteFile,\n convention: string,\n warnings: ConventionWarning[]\n): void {\n // Only script extensions need the 'use client' check — .json status files\n // never reach React at all, and are not in `statusFiles`.\n if (!isScriptExtension(file.extension)) return;\n\n const filePath = file.filePath;\n const label = `${convention}.${file.extension}`;\n let verdict: ClientBoundaryVerdict;\n try {\n verdict = classifyClientBoundaryFile(filePath);\n } catch (err) {\n swallow(err, `convention-lint: unreadable ${label} file ${filePath}`);\n return;\n }\n if (verdict === 'client') return;\n\n const isError = verdict === 'server';\n const name = exampleComponentName(convention);\n const props =\n convention === 'error' || convention === 'global-error' ? '{ error, reset }' : '{ status }';\n\n warnings.push({\n id: `NEEDS_USE_CLIENT:${filePath}`,\n summary: isError\n ? `${label} is a server component and must be a client component: ${filePath}`\n : `${label} may be missing 'use client': ${filePath}`,\n details:\n ` File: ${filePath}\\n\\n` +\n ` ${label} is handed to timber's error boundary — a client\\n` +\n ' component — as a prop. A server component cannot cross that boundary:\\n' +\n ' React fails with \"Functions cannot be passed directly to Client\\n' +\n ' Components\", and every page under this segment fails to render.\\n\\n' +\n (isError\n ? \" To fix: Add 'use client' as the first line of the file:\\n\\n\" +\n \" 'use client';\\n\\n\" +\n ` export default function ${name}(${props}) {\\n` +\n ' return <h1>…</h1>;\\n' +\n ' }\\n'\n : // The default export comes from somewhere this analysis cannot follow\n // — a re-export, an imported binding, a wrapper call. It may well\n // already be a client component, so say what was checked rather than\n // assert a break.\n \" This file has no 'use client' directive, and its default export\\n\" +\n ' comes from elsewhere, so timber cannot tell which it is. If the\\n' +\n \" module it re-exports starts with 'use client', nothing is wrong\\n\" +\n ' and you can ignore this. Otherwise add the directive there.\\n'),\n level: isError ? 'error' : 'warn',\n });\n}\n\n// ─── Check: Slot Middleware ─────────────────────────────────────────────────\n\n/**\n * Error when middleware.ts appears inside a parallel slot subtree.\n *\n * Middleware is collected from the main matched segment chain only\n * (route-matcher.ts `collectMiddlewareChain`). The slot resolver never\n * walks `middleware` on its matched chain, so a middleware.ts under any\n * `@slot/` directory silently never executes. `access.ts` in slot chains\n * DOES run (via SlotAccessGate), making the asymmetry invisible unless\n * you know to look.\n *\n * This is a build error rather than a warning: the file provably cannot\n * run and its presence misleads the author into thinking the slot is\n * middleware-protected.\n *\n * See design/07-routing.md §\"Parallel Routes\"\n */\nfunction checkSlotMiddleware(node: SegmentNode, warnings: ConventionWarning[]): void {\n for (const [slotName, slotRoot] of Object.entries(node.slots)) {\n collectSlotMiddleware(slotRoot, slotName, warnings);\n }\n for (const child of node.children) {\n checkSlotMiddleware(child, warnings);\n }\n}\n\n/**\n * Walk a slot subtree and report every middleware.ts found.\n */\nfunction collectSlotMiddleware(\n node: SegmentNode,\n slotName: string,\n warnings: ConventionWarning[]\n): void {\n if (node.middleware) {\n warnings.push({\n id: `SLOT_MIDDLEWARE:${node.middleware.filePath}`,\n summary: `middleware.ts inside slot @${slotName} never executes: ${node.middleware.filePath}`,\n details:\n ` File: ${node.middleware.filePath}\\n\\n` +\n ` Middleware is collected from the main route chain only.\\n` +\n ` The slot resolver does not run middleware — this file is silently dead.\\n` +\n ` (access.ts in slots does run via SlotAccessGate; middleware.ts does not.)\\n\\n` +\n ` To fix: Move the middleware logic into access.ts for slot-scoped auth,\\n` +\n ` or into a middleware.ts on the main route chain outside the slot.\\n`,\n level: 'error',\n });\n }\n for (const child of node.children) {\n collectSlotMiddleware(child, slotName, warnings);\n }\n for (const [nestedSlotName, nestedSlot] of Object.entries(node.slots)) {\n collectSlotMiddleware(nestedSlot, nestedSlotName, warnings);\n }\n}\n\n// ─── Check: App Directory Exists ────────────────────────────────────────────\n\n/**\n * Check if the app/ directory exists. Called before scanning.\n * Returns a warning if missing, or null if the directory exists.\n */\nexport function checkAppDirExists(appDir: string): ConventionWarning | null {\n if (existsSync(appDir)) return null;\n\n return {\n id: 'NO_APP_DIR',\n summary: 'No app/ directory found',\n details:\n ` Expected: ${appDir}\\n\\n` +\n ' timber.js requires an app/ directory for file-system routing.\\n' +\n ' Every request will return 404 until you create it.\\n\\n' +\n ' To fix: Create the app/ directory with a page:\\n\\n' +\n ' mkdir -p app\\n' +\n ' # Create app/layout.tsx and app/page.tsx\\n',\n level: 'error',\n };\n}\n\n// ─── Formatting ─────────────────────────────────────────────────────────────\n\nimport type { InspectColor } from 'node:util';\nimport { styleText } from 'node:util';\n\ntype Format = InspectColor | readonly InspectColor[];\nconst noValidate = { validateStream: false } as const;\n\nexport interface FormatOptions {\n /**\n * Emit ANSI escapes. Off when the text becomes an `Error` message —\n * whoever prints it decides its formatting, and colored escapes inside\n * an exception leak into logs and stack traces.\n */\n color?: boolean;\n}\n\n/**\n * Format warnings for terminal output.\n *\n * Groups by severity, uses colors, and includes fix suggestions.\n */\nexport function formatConventionWarnings(\n warnings: ConventionWarning[],\n options: FormatOptions = {}\n): string {\n const { color = true } = options;\n const style = (fmt: Format, text: string) => (color ? styleText(fmt, text, noValidate) : text);\n if (warnings.length === 0) return '';\n\n const errors = warnings.filter((w) => w.level === 'error');\n const warns = warnings.filter((w) => w.level === 'warn');\n\n const lines: string[] = [];\n\n if (errors.length > 0) {\n lines.push(\n `${style(['red', 'bold'], '[timber]')} ${style('red', `${errors.length} configuration error${errors.length !== 1 ? 's' : ''}:`)}`\n );\n for (const e of errors) {\n lines.push('');\n lines.push(` ${style('red', '✗')} ${e.summary}`);\n lines.push(style('dim', e.details));\n }\n }\n\n if (warns.length > 0) {\n if (errors.length > 0) lines.push('');\n lines.push(\n `${style(['yellow', 'bold'], '[timber]')} ${style('yellow', `${warns.length} configuration warning${warns.length !== 1 ? 's' : ''}:`)}`\n );\n for (const w of warns) {\n lines.push('');\n lines.push(` ${style('yellow', '⚠')} ${w.summary}`);\n lines.push(style('dim', w.details));\n }\n }\n\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;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AG,MAAM,KAAK,EAAE;EACpC,MAAM,KACJ,GAAG,MAAM,CAAC,UAAU,MAAM,GAAG,UAAU,EAAE,GAAG,MAAM,UAAU,GAAG,MAAM,OAAO,wBAAwB,MAAM,WAAW,IAAI,MAAM,GAAG,EAAE,GACtI;EACA,KAAK,MAAM,KAAK,OAAO;GACrB,MAAM,KAAK,EAAE;GACb,MAAM,KAAK,KAAK,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,SAAS;GACnD,MAAM,KAAK,MAAM,OAAO,EAAE,OAAO,CAAC;EACpC;CACF;CAEA,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as RESTART_EXIT_CODE } from "./dev-server-LO4McfQi.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as RENDER_TIMEOUT_CEILING_MS, t as DEFAULT_RENDER_TIMEOUT_MS } from "./render-timeout-MrrqD1wd.js";
|
|
2
2
|
import { n as STATUS_ENDPOINT_PATH, r as devRecordRoot, s as registerDevDiscovery } from "./dev-discovery-YnabkCKD.js";
|
|
3
|
-
import { o as matchUrlParts, t as collectInterceptionRewrites } from "./interception-
|
|
3
|
+
import { o as matchUrlParts, t as collectInterceptionRewrites } from "./interception-D1dCGNmQ.js";
|
|
4
4
|
import { o as isMetadataRouteServePath, s as isStaticMetadataExtension } from "./metadata-routes-MXNjWOt5.js";
|
|
5
5
|
import { n as isScannableSourceFile, t as buildSourceExtensions } from "./scan-CyizcBiX.js";
|
|
6
6
|
import "./graph-cache-B1LAg4t7.js";
|
|
@@ -1944,7 +1944,7 @@ function createGraphEndpointMiddleware(server, ctx) {
|
|
|
1944
1944
|
return;
|
|
1945
1945
|
}
|
|
1946
1946
|
try {
|
|
1947
|
-
const { classifyLiveFile, classifyLiveProject } = await import("./live-graph-
|
|
1947
|
+
const { classifyLiveFile, classifyLiveProject } = await import("./live-graph-DXhz6A_X.js");
|
|
1948
1948
|
const preserveSymlinks = server.config.resolve.preserveSymlinks;
|
|
1949
1949
|
const root = normalizePath(preserveSymlinks ? ctx.root : await realpath(ctx.root));
|
|
1950
1950
|
const appDir = normalizePath(preserveSymlinks ? ctx.appDir : await realpath(ctx.appDir).catch(() => join(root, relative(ctx.root, ctx.appDir))));
|
|
@@ -2776,4 +2776,4 @@ function listenForClientErrors(server, projectRoot) {
|
|
|
2776
2776
|
}
|
|
2777
2777
|
export { generateManifestModule as a, formatMissingPeers as c, VIRTUAL_IDS as i, reportConfigErrors as l, timberDevServer as n, generateSchemaModule as o, toWebRequest as r, checkPeerDependencies as s, RESTART_EXIT_CODE as t, validateConfig as u };
|
|
2778
2778
|
|
|
2779
|
-
//# sourceMappingURL=dev-server-
|
|
2779
|
+
//# sourceMappingURL=dev-server-LO4McfQi.js.map
|