@timber-js/app 0.2.0-alpha.192 → 0.2.0-alpha.195
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/agent-skill.md +2 -0
- package/dist/_chunks/{actions-BjbbNRFN.js → actions-CWYtq6ii.js} +3 -3
- package/dist/_chunks/actions-CWYtq6ii.js.map +1 -0
- package/dist/_chunks/als-registry-C6kcfprT.js.map +1 -1
- package/dist/_chunks/als-slots-BEEIPKYm.js.map +1 -1
- package/dist/_chunks/{build-output-helper-C3DrfzZR.js → build-output-helper-9dqCv1pZ.js} +3 -2
- package/dist/_chunks/build-output-helper-9dqCv1pZ.js.map +1 -0
- package/dist/_chunks/{cache-api-DllJ-Lyw.js → cache-api-CQeYzA5g.js} +6 -8
- package/dist/_chunks/cache-api-CQeYzA5g.js.map +1 -0
- package/dist/_chunks/chains-h7EO-u3n.js +412 -0
- package/dist/_chunks/chains-h7EO-u3n.js.map +1 -0
- package/dist/_chunks/{cli-check-DJZDc22E.js → cli-check-BVthpfLS.js} +43 -6
- package/dist/_chunks/cli-check-BVthpfLS.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-D4_AZVUb.js → cli-schema-sync-3Wutm8pH.js} +7 -6
- package/dist/_chunks/{cli-schema-sync-D4_AZVUb.js.map → cli-schema-sync-3Wutm8pH.js.map} +1 -1
- package/dist/_chunks/{cloudflare-CGP6BZKO.js → cloudflare-BKJC3SC_.js} +28 -22
- package/dist/_chunks/{cloudflare-CGP6BZKO.js.map → cloudflare-BKJC3SC_.js.map} +1 -1
- package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -1
- package/dist/_chunks/{convention-lint-CpteIpTm.js → convention-lint-DO10_pVl.js} +93 -7
- package/dist/_chunks/convention-lint-DO10_pVl.js.map +1 -0
- package/dist/_chunks/dist-DtrJyBbw.js +386 -0
- package/dist/_chunks/dist-DtrJyBbw.js.map +1 -0
- package/dist/_chunks/{error-boundary-D-ODYX41.js → error-boundary-D-lkwyaD.js} +3 -3
- package/dist/_chunks/{error-boundary-D-ODYX41.js.map → error-boundary-D-lkwyaD.js.map} +1 -1
- package/dist/_chunks/{file-cache-DmX7OqZP.js → file-cache-Dw6BJPG7.js} +5 -1
- package/dist/_chunks/{file-cache-DmX7OqZP.js.map → file-cache-Dw6BJPG7.js.map} +1 -1
- package/dist/_chunks/{format-CfwjgPz9.js → format-BKclgVbk.js} +3 -3
- package/dist/_chunks/{format-CfwjgPz9.js.map → format-BKclgVbk.js.map} +1 -1
- package/dist/_chunks/graph-cache-CP4GEmf9.js +304 -0
- package/dist/_chunks/graph-cache-CP4GEmf9.js.map +1 -0
- package/dist/_chunks/href-validation-CMc5JRls.js.map +1 -1
- package/dist/_chunks/live-graph-Bx4HodF1.js +150 -0
- package/dist/_chunks/live-graph-Bx4HodF1.js.map +1 -0
- package/dist/_chunks/{logger-CH7IcMmg.js → logger-pumCm3Il.js} +25 -7
- package/dist/_chunks/{logger-CH7IcMmg.js.map → logger-pumCm3Il.js.map} +1 -1
- package/dist/_chunks/{mdx-file-C005ay-P.js → mdx-file-CXyHGUpS.js} +3 -3
- package/dist/_chunks/mdx-file-CXyHGUpS.js.map +1 -0
- package/dist/_chunks/{plugin-context-rCinWLiE.js → plugin-context-8idfR3UZ.js} +2 -2
- package/dist/_chunks/plugin-context-8idfR3UZ.js.map +1 -0
- package/dist/_chunks/poison-rules-DoEhbqaY.js +110 -0
- package/dist/_chunks/poison-rules-DoEhbqaY.js.map +1 -0
- package/dist/_chunks/poison-scan-BAxfTT5L.js +101 -0
- package/dist/_chunks/poison-scan-BAxfTT5L.js.map +1 -0
- package/dist/_chunks/resolve-schema-CBR6Lm4i.js.map +1 -1
- package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/_chunks/{router-ref-DuYuV_0Q.js → router-ref-BzqbPwYC.js} +2 -2
- package/dist/_chunks/{router-ref-DuYuV_0Q.js.map → router-ref-BzqbPwYC.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DRqE_lD_.js → rsc-media-type-DDc7duTD.js} +17 -2
- package/dist/_chunks/{rsc-media-type-DRqE_lD_.js.map → rsc-media-type-DDc7duTD.js.map} +1 -1
- package/dist/_chunks/scan-BoP17W3w.js +140 -0
- package/dist/_chunks/scan-BoP17W3w.js.map +1 -0
- package/dist/_chunks/{scanner-CAietmj4.js → scanner-BRIOmHE2.js} +43 -4
- package/dist/_chunks/scanner-BRIOmHE2.js.map +1 -0
- package/dist/_chunks/schema-bridge-C83xa9lT.js.map +1 -1
- package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -1
- package/dist/_chunks/{segment-keys-BawYuNFO.js → segment-keys-BhqoHiLc.js} +14 -2
- package/dist/_chunks/{segment-keys-BawYuNFO.js.map → segment-keys-BhqoHiLc.js.map} +1 -1
- package/dist/_chunks/slot-params-BCTmZkQB.js.map +1 -1
- package/dist/_chunks/{ssr-data-14MXm7Pj.js → ssr-data-Ya2HJPFp.js} +1 -7
- package/dist/_chunks/{ssr-data-14MXm7Pj.js.map → ssr-data-Ya2HJPFp.js.map} +1 -1
- package/dist/_chunks/use-query-states-I3JMng6J.js.map +1 -1
- package/dist/_chunks/{use-segment-params-C4r4BD9T.js → use-segment-params-DzTBpkvj.js} +3 -3
- package/dist/_chunks/use-segment-params-DzTBpkvj.js.map +1 -0
- package/dist/_chunks/{walkers-BsVLmD1S.js → walkers-BU6z9xRV.js} +9 -6
- package/dist/_chunks/{walkers-BsVLmD1S.js.map → walkers-BU6z9xRV.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +1 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -1
- package/dist/adapters/cloudflare-dev.js.map +1 -1
- package/dist/adapters/cloudflare-kv-cache.d.ts +1 -1
- package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +7 -8
- package/dist/adapters/cloudflare-kv-cache.js.map +1 -1
- package/dist/adapters/cloudflare.d.ts +1 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +37 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -0
- package/dist/adapters/nitro-preview.d.ts +32 -0
- package/dist/adapters/nitro-preview.d.ts.map +1 -0
- package/dist/adapters/nitro.d.ts +28 -51
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +224 -171
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/chains.d.ts +124 -0
- package/dist/analyze/chains.d.ts.map +1 -0
- package/dist/analyze/classify.d.ts +150 -0
- package/dist/analyze/classify.d.ts.map +1 -0
- package/dist/analyze/crawl-entry.d.ts +17 -0
- package/dist/analyze/crawl-entry.d.ts.map +1 -0
- package/dist/analyze/crawl-entry.js +313 -0
- package/dist/analyze/crawl-entry.js.map +1 -0
- package/dist/analyze/crawl.d.ts +134 -0
- package/dist/analyze/crawl.d.ts.map +1 -0
- package/dist/analyze/graph-cache.d.ts +104 -0
- package/dist/analyze/graph-cache.d.ts.map +1 -0
- package/dist/analyze/graph-command.d.ts +43 -0
- package/dist/analyze/graph-command.d.ts.map +1 -0
- package/dist/analyze/graph-command.js +472 -0
- package/dist/analyze/graph-command.js.map +1 -0
- package/dist/analyze/live-graph.d.ts +81 -0
- package/dist/analyze/live-graph.d.ts.map +1 -0
- package/dist/analyze/poison-rules.d.ts +72 -0
- package/dist/analyze/poison-rules.d.ts.map +1 -0
- package/dist/analyze/poison-scan.d.ts +48 -0
- package/dist/analyze/poison-scan.d.ts.map +1 -0
- package/dist/analyze/scan.d.ts +73 -0
- package/dist/analyze/scan.d.ts.map +1 -0
- package/dist/cache/cache-api.d.ts +2 -2
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/index.d.ts +8 -8
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/redis-handler.d.ts +1 -1
- package/dist/cache/redis-handler.d.ts.map +1 -1
- package/dist/cache/stores/cloudflare-kv.d.ts +1 -1
- package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -1
- package/dist/cache/stores/cloudflare-kv.js.map +1 -1
- package/dist/cache/stores/memory.d.ts +1 -1
- package/dist/cache/stores/memory.d.ts.map +1 -1
- package/dist/cache/stores/memory.js.map +1 -1
- package/dist/cache/stores/redis.d.ts +1 -1
- package/dist/cache/stores/redis.d.ts.map +1 -1
- package/dist/cache/stores/redis.js.map +1 -1
- package/dist/cache/stores/vercel.d.ts +1 -1
- package/dist/cache/stores/vercel.d.ts.map +1 -1
- package/dist/cache/stores/vercel.js.map +1 -1
- package/dist/cache/tag-aware-handler.d.ts +2 -2
- package/dist/cache/tag-aware-handler.d.ts.map +1 -1
- package/dist/cache/timber-cache.d.ts +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.d.ts +1 -1
- package/dist/cdn/cloudflare-purge.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js.map +1 -1
- package/dist/cdn/fastly-purge.d.ts +1 -1
- package/dist/cdn/fastly-purge.d.ts.map +1 -1
- package/dist/cdn/fastly-purge.js.map +1 -1
- package/dist/cdn/index.d.ts +4 -4
- package/dist/cdn/index.d.ts.map +1 -1
- package/dist/cdn/workers-cache-purge.d.ts +5 -1
- package/dist/cdn/workers-cache-purge.d.ts.map +1 -1
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-check.d.ts +10 -0
- package/dist/cli-check.d.ts.map +1 -1
- package/dist/cli.d.ts +12 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +30 -6
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-entry/hydrate.d.ts +2 -2
- package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts +2 -2
- package/dist/client/browser-entry/router-init.d.ts +2 -2
- package/dist/client/browser-entry/rsc-stream.d.ts +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/form.d.ts +2 -2
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/history.d.ts +2 -2
- package/dist/client/index.d.ts +18 -18
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +19 -19
- package/dist/client/internal.d.ts.map +1 -1
- package/dist/client/internal.js +15 -19
- package/dist/client/internal.js.map +1 -1
- package/dist/client/link.d.ts +3 -3
- package/dist/client/navigation-commit.d.ts +5 -5
- package/dist/client/navigation-root.d.ts +1 -1
- package/dist/client/navigation-root.d.ts.map +1 -1
- package/dist/client/params-context.d.ts +3 -3
- package/dist/client/router-pipeline.d.ts +7 -7
- package/dist/client/router-ref.d.ts +1 -1
- package/dist/client/router-types.d.ts +6 -6
- package/dist/client/router-types.d.ts.map +1 -1
- package/dist/client/router.d.ts +1 -1
- package/dist/client/rsc-fetch.d.ts +4 -4
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +2 -2
- package/dist/client/slot-provider.d.ts +1 -1
- package/dist/client/ssr-data.d.ts +2 -2
- package/dist/client/state.d.ts +4 -4
- package/dist/client/use-query-states.d.ts +1 -1
- package/dist/client/use-segment-params.d.ts +3 -3
- package/dist/codec.d.ts +2 -2
- package/dist/codec.js.map +1 -1
- package/dist/config-types.d.ts +12 -9
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts +1 -1
- package/dist/cookies/define-cookie.d.ts +3 -3
- package/dist/cookies/index.d.ts +3 -3
- package/dist/cookies/index.js +4 -5
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +1 -1
- package/dist/dev-tools/404-page.d.ts +2 -2
- package/dist/dev-tools/error-page.d.ts +2 -2
- package/dist/dev-tools/index.d.ts +12 -12
- package/dist/dev-tools/instrumentation.d.ts +1 -1
- package/dist/dev-tools/logs.d.ts +1 -1
- package/dist/dev-tools/overlay.d.ts +2 -2
- package/dist/dev-tools/terminal.d.ts +1 -1
- package/dist/fonts/ast.d.ts +4 -4
- package/dist/fonts/bundle.d.ts +3 -3
- package/dist/fonts/css.d.ts +1 -1
- package/dist/fonts/dev-middleware.d.ts +1 -1
- package/dist/fonts/google.d.ts +1 -1
- package/dist/fonts/local.d.ts +1 -1
- package/dist/fonts/pipeline.d.ts +3 -3
- package/dist/fonts/transform.d.ts +2 -2
- package/dist/fonts/types.d.ts +1 -1
- package/dist/fonts/virtual-modules.d.ts +1 -1
- package/dist/index.d.ts +3 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +861 -314
- package/dist/index.js.map +1 -1
- package/dist/params/codec-registry.d.ts +1 -1
- package/dist/params/define-schema.d.ts +2 -2
- package/dist/params/index.d.ts +4 -4
- package/dist/params/index.js.map +1 -1
- package/dist/params/resolve-schema.d.ts +1 -1
- package/dist/plugin-context.d.ts +9 -9
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/adapter-build.d.ts +2 -2
- package/dist/plugins/build-manifest.d.ts +2 -2
- package/dist/plugins/build-report.d.ts +5 -5
- package/dist/plugins/cache.d.ts +1 -1
- package/dist/plugins/callsite-jsx.d.ts +2 -2
- package/dist/plugins/chunks.d.ts +1 -1
- package/dist/plugins/chunks.d.ts.map +1 -1
- package/dist/plugins/cloudflare-wasm.d.ts +1 -1
- package/dist/plugins/content.d.ts +1 -1
- package/dist/plugins/content.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +123 -0
- package/dist/plugins/dev-discovery.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +1 -1
- package/dist/plugins/fonts.d.ts +3 -3
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +112 -0
- package/dist/plugins/graph-endpoint.d.ts.map +1 -0
- package/dist/plugins/mdx.d.ts +1 -1
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/plugins/prebuilt-capture.d.ts +2 -2
- package/dist/plugins/prebuilt-options-analysis.d.ts +1 -1
- package/dist/plugins/prebuilt.d.ts +1 -1
- package/dist/plugins/prerender-sugar.d.ts +11 -14
- package/dist/plugins/prerender-sugar.d.ts.map +1 -1
- package/dist/plugins/request-dep/analysis.d.ts +1 -1
- package/dist/plugins/request-dep/index.d.ts +5 -5
- package/dist/plugins/request-dep/origin.d.ts +1 -1
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +5 -5
- package/dist/routing/codegen-shared.d.ts +1 -1
- package/dist/routing/codegen-write.d.ts +1 -1
- package/dist/routing/codegen.d.ts +1 -1
- package/dist/routing/collision-probe.d.ts +1 -1
- package/dist/routing/collision-spaces.d.ts +1 -1
- package/dist/routing/convention-lint.d.ts +1 -1
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/index.d.ts +13 -13
- package/dist/routing/index.js +3 -3
- package/dist/routing/interception.d.ts +1 -1
- package/dist/routing/interception.d.ts.map +1 -1
- package/dist/routing/link-codegen.d.ts +1 -1
- package/dist/routing/manifest-codegen.d.ts +1 -1
- package/dist/routing/scanner.d.ts +14 -1
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/schema-validation.d.ts +1 -1
- package/dist/routing/segment-classify.d.ts +1 -1
- package/dist/routing/segment-codegen.d.ts +1 -1
- package/dist/routing/segment-keys.d.ts +1 -1
- package/dist/routing/slot-placement.d.ts +1 -1
- package/dist/routing/walkers.d.ts +1 -1
- package/dist/rsc-runtime/transforms.d.ts +13 -0
- package/dist/rsc-runtime/transforms.d.ts.map +1 -0
- package/dist/schema-bridge.d.ts +1 -1
- package/dist/search-params/define.d.ts +3 -3
- package/dist/search-params/index.d.ts +3 -3
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/wrappers.d.ts +1 -1
- package/dist/server/access-gate.d.ts +1 -1
- package/dist/server/action-client.d.ts +1 -1
- package/dist/server/action-handler.d.ts +5 -5
- package/dist/server/actions.d.ts +2 -2
- package/dist/server/als-registry.d.ts +8 -8
- package/dist/server/asset-headers.d.ts +1 -1
- package/dist/server/chain-url-parts.d.ts +3 -3
- package/dist/server/children-interception.d.ts +2 -2
- package/dist/server/cookie-context.d.ts +1 -1
- package/dist/server/cookie-parsing.d.ts +2 -2
- package/dist/server/default-logger.d.ts +1 -1
- package/dist/server/deny-boundary.d.ts +2 -2
- package/dist/server/deny-renderer.d.ts +5 -5
- package/dist/server/early-hints.d.ts +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +2 -4
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/fallback-error.d.ts +5 -5
- package/dist/server/flight-injection-state.d.ts +1 -1
- package/dist/server/form-flash.d.ts +1 -1
- package/dist/server/html-injector-core.d.ts +2 -2
- package/dist/server/html-injectors.d.ts +1 -1
- package/dist/server/index.d.ts +18 -18
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +34 -38
- package/dist/server/index.js.map +1 -1
- package/dist/server/instrumentation.d.ts +1 -1
- package/dist/server/internal.d.ts +50 -50
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +1024 -1026
- package/dist/server/internal.js.map +1 -1
- package/dist/server/metadata-collector.d.ts +2 -2
- package/dist/server/metadata-platform.d.ts +2 -2
- package/dist/server/metadata-render.d.ts +2 -2
- package/dist/server/metadata-routes.d.ts +3 -3
- package/dist/server/metadata-social.d.ts +2 -2
- package/dist/server/metadata.d.ts +2 -2
- package/dist/server/middleware-runner.d.ts +1 -1
- package/dist/server/node-stream-transforms.d.ts +1 -1
- package/dist/server/param-coercion.d.ts +4 -4
- package/dist/server/pipeline-helpers.d.ts +3 -3
- package/dist/server/pipeline-interception.d.ts +1 -1
- package/dist/server/pipeline-metadata.d.ts +1 -1
- package/dist/server/pipeline-outcome.d.ts +2 -2
- package/dist/server/pipeline-phases.d.ts +3 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +9 -9
- package/dist/server/prebuilt/cache-key.d.ts +1 -1
- package/dist/server/prebuilt/capture-state.d.ts +1 -1
- package/dist/server/prebuilt/key-discipline.d.ts +1 -1
- package/dist/server/prebuilt/manifest-tag-index.d.ts +1 -1
- package/dist/server/prebuilt/overlay.d.ts +2 -2
- package/dist/server/prebuilt/payload-source.d.ts +1 -1
- package/dist/server/prebuilt/slots.d.ts +1 -1
- package/dist/server/prebuilt/synthetic-store.d.ts +2 -2
- package/dist/server/prebuilt-builder.d.ts +2 -2
- package/dist/server/primitives.d.ts +2 -2
- package/dist/server/publish-params.d.ts +1 -1
- package/dist/server/request-context.d.ts +3 -3
- package/dist/server/route-element-builder.d.ts +16 -6
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +1 -1
- package/dist/server/route-matcher.d.ts +4 -4
- package/dist/server/rsc-cache-key-guard.d.ts.map +1 -1
- package/dist/server/rsc-entry/action-middleware-runner.d.ts +2 -2
- package/dist/server/rsc-entry/api-handler.d.ts +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/deny-fallback.d.ts +3 -3
- package/dist/server/rsc-entry/error-renderer.d.ts +4 -4
- package/dist/server/rsc-entry/helpers.d.ts +6 -6
- package/dist/server/rsc-entry/index.d.ts +7 -6
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +4 -4
- package/dist/server/rsc-entry/revalidate-renderer.d.ts +4 -4
- package/dist/server/rsc-entry/rsc-payload.d.ts +4 -4
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +3 -3
- package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +7 -7
- package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +5 -5
- package/dist/server/sitemap-generator.d.ts +2 -2
- package/dist/server/sitemap-handler.d.ts +1 -1
- package/dist/server/skippable-prefix.d.ts +3 -3
- package/dist/server/slot-interception.d.ts +2 -2
- package/dist/server/slot-resolver.d.ts +3 -7
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-bridge-types.d.ts +2 -2
- package/dist/server/ssr-entry.d.ts +1 -1
- package/dist/server/static-generator.d.ts +1 -1
- package/dist/server/static-not-found.d.ts +1 -1
- package/dist/server/status-code-resolver.d.ts +1 -1
- package/dist/server/tracing.d.ts +3 -3
- package/dist/server/tree-builder.d.ts +3 -3
- package/dist/server/tree-match.d.ts +1 -1
- package/dist/server/types.d.ts +2 -2
- package/dist/server/utils/mdx-file.d.ts +2 -0
- package/dist/server/utils/mdx-file.d.ts.map +1 -1
- package/dist/server/workers-cache-bridge.d.ts +1 -1
- package/dist/shared/als-slots.d.ts +1 -1
- package/dist/shared/payload-root.d.ts +2 -2
- package/dist/shared/rsc-media-type.d.ts +12 -0
- package/dist/shared/rsc-media-type.d.ts.map +1 -1
- package/dist/shared/slot-params.d.ts +1 -1
- package/dist/shims/font-google.d.ts +1 -1
- package/dist/shims/font-google.js.map +1 -1
- package/dist/shims/font-local.d.ts +1 -1
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/navigation-client.d.ts +4 -4
- package/dist/shims/navigation.d.ts +2 -2
- package/docs/api/34-api-config.mdx +7 -4
- package/docs/api/36-cli.mdx +23 -3
- package/docs/learn/11-error-handling.mdx +11 -0
- package/docs/learn/13-configuration.mdx +1 -1
- package/docs/more/01-advanced-routing.mdx +1 -0
- package/package.json +11 -10
- package/src/adapters/build-output-helper.ts +4 -4
- package/src/adapters/cloudflare-dev.ts +7 -1
- package/src/adapters/cloudflare-kv-cache.ts +11 -8
- package/src/adapters/cloudflare.ts +21 -15
- package/src/adapters/compress-module.ts +2 -2
- package/src/adapters/nitro-presets.ts +139 -0
- package/src/adapters/nitro-preview.ts +340 -0
- package/src/adapters/nitro.ts +100 -465
- package/src/adapters/shared.ts +1 -1
- package/src/analyze/chains.ts +411 -0
- package/src/analyze/classify.ts +258 -0
- package/src/analyze/crawl-entry.ts +68 -0
- package/src/analyze/crawl.ts +500 -0
- package/src/analyze/graph-cache.ts +332 -0
- package/src/analyze/graph-command.ts +762 -0
- package/src/analyze/live-graph.ts +232 -0
- package/src/analyze/poison-rules.ts +165 -0
- package/src/analyze/poison-scan.ts +162 -0
- package/src/analyze/scan.ts +149 -0
- package/src/cache/cache-api.ts +7 -7
- package/src/cache/index.ts +9 -9
- package/src/cache/redis-handler.ts +2 -2
- package/src/cache/stores/cloudflare-kv.ts +1 -1
- package/src/cache/stores/memory.ts +2 -2
- package/src/cache/stores/redis.ts +1 -1
- package/src/cache/stores/vercel.ts +1 -1
- package/src/cache/tag-aware-handler.ts +2 -2
- package/src/cache/timber-cache.ts +8 -8
- package/src/cdn/cloudflare-purge.ts +1 -1
- package/src/cdn/fastly-purge.ts +1 -1
- package/src/cdn/index.ts +10 -4
- package/src/cdn/workers-cache-purge.ts +6 -2
- package/src/cli-check.ts +53 -4
- package/src/cli-schema-sync.ts +3 -3
- package/src/cli.ts +50 -11
- package/src/client/browser-dev.ts +1 -1
- package/src/client/browser-entry/action-dispatch.ts +5 -5
- package/src/client/browser-entry/hmr.ts +1 -1
- package/src/client/browser-entry/hydrate.ts +9 -9
- package/src/client/browser-entry/index.ts +10 -10
- package/src/client/browser-entry/post-hydration.ts +5 -5
- package/src/client/browser-entry/router-init.ts +9 -9
- package/src/client/browser-entry/rsc-stream.ts +3 -3
- package/src/client/error-boundary.tsx +4 -4
- package/src/client/form.tsx +7 -2
- package/src/client/history.ts +2 -2
- package/src/client/index.ts +21 -18
- package/src/client/internal.ts +19 -19
- package/src/client/link.tsx +9 -9
- package/src/client/navigation-api.ts +1 -1
- package/src/client/navigation-commit.ts +5 -5
- package/src/client/navigation-context.ts +1 -1
- package/src/client/navigation-root.tsx +1 -1
- package/src/client/nuqs-adapter.tsx +2 -2
- package/src/client/params-context.ts +4 -4
- package/src/client/router-effects.ts +3 -3
- package/src/client/router-lifecycle.ts +2 -2
- package/src/client/router-pipeline.ts +10 -10
- package/src/client/router-ref.ts +2 -2
- package/src/client/router-skew.ts +2 -2
- package/src/client/router-types.ts +6 -6
- package/src/client/router.ts +13 -13
- package/src/client/rsc-fetch.ts +11 -16
- package/src/client/segment-cache.ts +2 -2
- package/src/client/segment-outlet.tsx +1 -1
- package/src/client/shallow-url.ts +1 -1
- package/src/client/slot-outlet.tsx +1 -1
- package/src/client/slot-provider.tsx +1 -1
- package/src/client/ssr-data.ts +3 -3
- package/src/client/stale-client.ts +1 -1
- package/src/client/state.ts +4 -4
- package/src/client/top-loader.tsx +1 -1
- package/src/client/unload-guard.ts +1 -1
- package/src/client/use-cookie.ts +2 -2
- package/src/client/use-pathname.ts +2 -2
- package/src/client/use-pending-navigation.ts +1 -1
- package/src/client/use-query-states.ts +3 -3
- package/src/client/use-router.ts +2 -2
- package/src/client/use-search-params.ts +3 -3
- package/src/client/use-segment-params.ts +6 -6
- package/src/client/use-selected-layout-segment.ts +2 -2
- package/src/codec.ts +2 -2
- package/src/config-types.ts +12 -9
- package/src/config-validation.ts +1 -1
- package/src/cookies/define-cookie.ts +6 -6
- package/src/cookies/index.ts +3 -3
- package/src/cookies/json-cookie.ts +1 -1
- package/src/dev-tools/404-page.ts +4 -4
- package/src/dev-tools/dev-page-shell.ts +1 -1
- package/src/dev-tools/error-page.ts +4 -4
- package/src/dev-tools/index.ts +12 -12
- package/src/dev-tools/instrumentation.ts +1 -1
- package/src/dev-tools/logs.ts +1 -1
- package/src/dev-tools/overlay.ts +3 -3
- package/src/dev-tools/terminal.ts +2 -2
- package/src/fonts/ast.ts +5 -5
- package/src/fonts/bundle.ts +5 -5
- package/src/fonts/css.ts +1 -1
- package/src/fonts/dev-middleware.ts +2 -2
- package/src/fonts/google.ts +2 -2
- package/src/fonts/local.ts +4 -4
- package/src/fonts/pipeline.ts +8 -8
- package/src/fonts/transform.ts +5 -5
- package/src/fonts/types.ts +1 -1
- package/src/fonts/virtual-modules.ts +1 -1
- package/src/index.ts +90 -95
- package/src/params/codec-registry.ts +1 -1
- package/src/params/define-schema.ts +2 -2
- package/src/params/index.ts +4 -4
- package/src/params/resolve-schema.ts +2 -2
- package/src/plugin-context.ts +10 -10
- package/src/plugins/adapter-build.ts +5 -5
- package/src/plugins/build-manifest.ts +4 -4
- package/src/plugins/build-report.ts +6 -6
- package/src/plugins/cache.ts +3 -3
- package/src/plugins/callsite-ast.ts +1 -1
- package/src/plugins/callsite-jsx.ts +2 -2
- package/src/plugins/chunks.ts +1 -1
- package/src/plugins/cloudflare-wasm.ts +1 -1
- package/src/plugins/content.ts +5 -1
- package/src/plugins/dev-discovery.ts +218 -0
- package/src/plugins/dev-server.ts +97 -12
- package/src/plugins/entries.ts +1 -1
- package/src/plugins/fonts.ts +17 -10
- package/src/plugins/graph-endpoint.ts +532 -0
- package/src/plugins/mdx.ts +4 -3
- package/src/plugins/prebuilt-capture.ts +3 -3
- package/src/plugins/prebuilt-options-analysis.ts +1 -1
- package/src/plugins/prebuilt.ts +7 -7
- package/src/plugins/prerender-sugar.ts +11 -19
- package/src/plugins/request-dep/analysis.ts +1 -1
- package/src/plugins/request-dep/index.ts +8 -8
- package/src/plugins/request-dep/origin.ts +1 -1
- package/src/plugins/routing.ts +12 -7
- package/src/plugins/server-bundle.ts +9 -2
- package/src/plugins/shims.ts +16 -31
- package/src/plugins/static-build.ts +10 -10
- package/src/routing/codegen-shared.ts +1 -1
- package/src/routing/codegen-write.ts +3 -3
- package/src/routing/codegen.ts +14 -5
- package/src/routing/collision-probe.ts +3 -3
- package/src/routing/collision-spaces.ts +3 -3
- package/src/routing/convention-lint.ts +136 -6
- package/src/routing/export-detect.ts +1 -1
- package/src/routing/index.ts +13 -13
- package/src/routing/interception.ts +41 -4
- package/src/routing/link-codegen.ts +3 -3
- package/src/routing/manifest-codegen.ts +2 -2
- package/src/routing/scanner.ts +33 -9
- package/src/routing/schema-validation.ts +4 -4
- package/src/routing/segment-classify.ts +2 -2
- package/src/routing/segment-codegen.ts +1 -1
- package/src/routing/segment-keys.ts +1 -1
- package/src/routing/slot-placement.ts +1 -1
- package/src/routing/walkers.ts +1 -1
- package/src/rsc-runtime/transforms.ts +13 -0
- package/src/rsc-runtime/vendor-types.d.ts +12 -0
- package/src/schema-bridge.ts +1 -1
- package/src/search-params/define.ts +8 -8
- package/src/search-params/index.ts +3 -3
- package/src/search-params/wrappers.ts +3 -3
- package/src/server/access-gate.tsx +6 -6
- package/src/server/action-client.ts +5 -5
- package/src/server/action-handler.ts +16 -16
- package/src/server/actions.ts +5 -5
- package/src/server/als-registry.ts +8 -8
- package/src/server/asset-headers.ts +2 -2
- package/src/server/chain-url-parts.ts +5 -5
- package/src/server/children-interception.ts +4 -4
- package/src/server/compress.ts +1 -1
- package/src/server/cookie-context.ts +4 -4
- package/src/server/cookie-parsing.ts +2 -2
- package/src/server/default-logger.ts +3 -3
- package/src/server/deny-boundary.ts +10 -10
- package/src/server/deny-renderer.ts +38 -25
- package/src/server/early-hints-sender.ts +2 -2
- package/src/server/early-hints.ts +2 -2
- package/src/server/error-boundary-wrapper.ts +4 -12
- package/src/server/fallback-error.ts +13 -13
- package/src/server/flight-injection-state.ts +1 -1
- package/src/server/form-flash.ts +2 -2
- package/src/server/html-injector-core.ts +4 -4
- package/src/server/html-injectors.ts +5 -5
- package/src/server/index.ts +18 -18
- package/src/server/instrumentation.ts +1 -1
- package/src/server/internal.ts +50 -50
- package/src/server/logger.ts +4 -4
- package/src/server/metadata-collector.ts +7 -7
- package/src/server/metadata-platform.ts +2 -2
- package/src/server/metadata-render.ts +4 -4
- package/src/server/metadata-routes.ts +3 -3
- package/src/server/metadata-social.ts +2 -2
- package/src/server/metadata.ts +2 -2
- package/src/server/middleware-runner.ts +1 -1
- package/src/server/node-stream-transforms.ts +4 -4
- package/src/server/param-coercion.ts +8 -8
- package/src/server/pipeline-helpers.ts +7 -7
- package/src/server/pipeline-interception.ts +2 -2
- package/src/server/pipeline-metadata.ts +1 -1
- package/src/server/pipeline-outcome.ts +8 -8
- package/src/server/pipeline-phases.ts +24 -28
- package/src/server/pipeline.ts +22 -22
- package/src/server/prebuilt/cache-key.ts +1 -1
- package/src/server/prebuilt/capture-state.ts +1 -1
- package/src/server/prebuilt/key-discipline.ts +1 -1
- package/src/server/prebuilt/manifest-tag-index.ts +1 -1
- package/src/server/prebuilt/overlay.ts +6 -6
- package/src/server/prebuilt/payload-source.ts +2 -2
- package/src/server/prebuilt/slots.ts +5 -5
- package/src/server/prebuilt/synthetic-store.ts +2 -2
- package/src/server/prebuilt-builder.ts +16 -16
- package/src/server/prebuilt-runtime.ts +12 -12
- package/src/server/primitives.ts +7 -7
- package/src/server/publish-params.ts +3 -3
- package/src/server/request-context.ts +7 -7
- package/src/server/route-element-builder.ts +108 -50
- package/src/server/route-handler.ts +4 -4
- package/src/server/route-matcher.ts +5 -5
- package/src/server/rsc-cache-key-guard.ts +3 -5
- package/src/server/rsc-entry/action-middleware-runner.ts +7 -7
- package/src/server/rsc-entry/api-handler.ts +18 -9
- package/src/server/rsc-entry/deny-fallback.ts +10 -10
- package/src/server/rsc-entry/error-renderer.ts +27 -27
- package/src/server/rsc-entry/helpers.ts +10 -10
- package/src/server/rsc-entry/index.ts +51 -47
- package/src/server/rsc-entry/render-route.ts +20 -20
- package/src/server/rsc-entry/revalidate-renderer.ts +12 -12
- package/src/server/rsc-entry/rsc-payload.ts +19 -15
- package/src/server/rsc-entry/rsc-stream.ts +8 -8
- package/src/server/rsc-entry/ssr-bridge.ts +3 -3
- package/src/server/rsc-entry/ssr-renderer.ts +23 -23
- package/src/server/rsc-entry/wrap-action-dispatch.ts +9 -9
- package/src/server/rsc-prop-warnings.ts +1 -1
- package/src/server/sensitive-fields.ts +1 -1
- package/src/server/server-timing.ts +1 -1
- package/src/server/sitemap-generator.ts +3 -3
- package/src/server/sitemap-handler.ts +3 -3
- package/src/server/skippable-prefix.ts +7 -7
- package/src/server/slot-interception.ts +5 -5
- package/src/server/slot-resolver.ts +20 -28
- package/src/server/ssr-bridge-types.ts +2 -2
- package/src/server/ssr-entry.ts +18 -18
- package/src/server/ssr-render.ts +4 -4
- package/src/server/ssr-wrappers.tsx +1 -1
- package/src/server/state-tree-diff.ts +1 -1
- package/src/server/static-generator.ts +6 -6
- package/src/server/static-not-found.ts +3 -3
- package/src/server/status-code-resolver.ts +1 -1
- package/src/server/tracing.ts +5 -5
- package/src/server/tree-builder.ts +4 -4
- package/src/server/tree-match.ts +1 -1
- package/src/server/types.ts +2 -2
- package/src/server/utils/mdx-file.ts +2 -2
- package/src/server/waituntil-bridge.ts +1 -1
- package/src/server/workers-cache-bridge.ts +2 -2
- package/src/shared/als-slots.ts +1 -1
- package/src/shared/payload-root.ts +2 -2
- package/src/shared/rsc-media-type.ts +16 -0
- package/src/shared/slot-params.ts +1 -1
- package/src/shims/font-google.ts +1 -1
- package/src/shims/font-local.ts +1 -1
- package/src/shims/navigation-client.ts +5 -5
- package/src/shims/navigation.ts +2 -2
- package/dist/_chunks/actions-BjbbNRFN.js.map +0 -1
- package/dist/_chunks/build-output-helper-C3DrfzZR.js.map +0 -1
- package/dist/_chunks/cache-api-DllJ-Lyw.js.map +0 -1
- package/dist/_chunks/cli-check-DJZDc22E.js.map +0 -1
- package/dist/_chunks/convention-lint-CpteIpTm.js.map +0 -1
- package/dist/_chunks/dist-BA3u1z3W.js +0 -423
- package/dist/_chunks/dist-BA3u1z3W.js.map +0 -1
- package/dist/_chunks/mdx-file-C005ay-P.js.map +0 -1
- package/dist/_chunks/plugin-context-rCinWLiE.js.map +0 -1
- package/dist/_chunks/scanner-CAietmj4.js.map +0 -1
- package/dist/_chunks/use-segment-params-C4r4BD9T.js.map +0 -1
- package/dist/content/index.d.ts +0 -2
- package/dist/content/index.d.ts.map +0 -1
- package/dist/content/index.js +0 -0
- package/src/content/index.ts +0 -5
- package/src/shims/server-only-noop.js +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scanner-CAietmj4.js","names":[],"sources":["../../src/server/tree-match.ts","../../src/routing/collision-probe.ts","../../src/routing/interception.ts","../../src/routing/collision-spaces.ts","../../src/routing/slot-placement.ts","../../src/routing/scanner.ts"],"sourcesContent":["/**\n * Shared URL-matching tree walker for segment trees.\n *\n * Both the main route matcher (`route-matcher.ts`) and slot resolver\n * (`slot-resolver.ts`) need to walk a SegmentNode tree, matching URL\n * parts against children with the same priority semantics:\n *\n * static > dynamic > catch-all > optional-catch-all\n *\n * Before this module, each had its own walker with subtle divergences\n * (different group handling, missing backtracking, incomplete\n * optional-catch-all support). This shared walker is the single\n * source of truth for URL-to-segment matching.\n *\n * See design/07-routing.md §\"Request Lifecycle\" and TIM-940.\n */\n\nimport type { SegmentNode } from '../routing/types.js';\n\n// ─── Public API ───────────────────────────────────────────────────────────\n\n/** Result of matching URL parts against a segment tree. */\nexport interface TreeMatchResult<TFile> {\n /** Matched segment chain from root to leaf, inclusive. */\n chain: SegmentNode<TFile>[];\n /** Collected params, keyed by param name. Catch-all params are string[]. */\n params: Record<string, string | string[]>;\n}\n\nexport interface TreeMatchOptions {\n /**\n * When true (default), only match if the leaf node has a page or route\n * handler. Set to false for metadata route matching, where we just need\n * to find the owning segment regardless of whether it has a page.\n */\n requireTerminal?: boolean;\n}\n\n/**\n * Match URL path parts against a segment tree.\n *\n * Walks the tree depth-first with backtracking, applying priority\n * ordering globally across group boundaries. Returns the matched\n * segment chain and collected params, or null if no route matches.\n *\n * By default, a match requires a terminal node (one with `page` or\n * `route`) at the leaf. Pass `{ requireTerminal: false }` to match\n * any segment (used by metadata route matching).\n *\n * @param root The root segment node to start matching from.\n * @param parts URL path parts (e.g. ['blog', 'hello-world']).\n * Empty array matches the root itself (if terminal).\n */\nexport function matchUrlParts<TFile>(\n root: SegmentNode<TFile>,\n parts: string[],\n options?: TreeMatchOptions\n): TreeMatchResult<TFile> | null {\n const chain: SegmentNode<TFile>[] = [];\n const params: Record<string, string | string[]> = {};\n const requireTerminal = options?.requireTerminal ?? true;\n\n if (matchNode(root, parts, 0, chain, params, requireTerminal)) {\n return { chain, params };\n }\n return null;\n}\n\n// ─── Internal ─────────────────────────────────────────────────────────────\n\n/**\n * A child node flattened through group segments, along with the\n * chain of group nodes that must appear in the segment chain\n * before the child to preserve the tree path.\n */\ninterface EffectiveChild<TFile> {\n child: SegmentNode<TFile>;\n groupChain: SegmentNode<TFile>[];\n}\n\n/**\n * Flatten children through group segments.\n *\n * Groups are transparent for URL matching — their non-group descendants\n * are returned with the chain of group nodes leading to them. This lets\n * the caller apply priority ordering (static > dynamic > catch-all >\n * optional-catch-all) across all groups uniformly instead of per-group.\n */\nfunction collectEffectiveChildren<TFile>(\n node: SegmentNode<TFile>,\n groupChain: SegmentNode<TFile>[] = []\n): EffectiveChild<TFile>[] {\n const result: EffectiveChild<TFile>[] = [];\n for (const child of node.children) {\n if (child.segmentType === 'group') {\n const nested = collectEffectiveChildren(child, [...groupChain, child]);\n result.push(...nested);\n } else {\n result.push({ child, groupChain });\n }\n }\n return result;\n}\n\n/** A node is terminal if it can serve a response (has a page or route handler). */\nfunction isTerminal<TFile>(node: SegmentNode<TFile>): boolean {\n return !!(node.page || node.route);\n}\n\n/** Combined affix length for specificity ordering. */\nfunction affixLength<TFile>(node: SegmentNode<TFile>): number {\n return (node.paramPrefix?.length ?? 0) + (node.paramSuffix?.length ?? 0);\n}\n\n/**\n * Recursive depth-first matcher with backtracking.\n *\n * Mutates `chain` and `params` in place for performance; backtracks\n * (restores previous state) when a candidate doesn't lead to a match.\n */\nfunction matchNode<TFile>(\n node: SegmentNode<TFile>,\n parts: string[],\n index: number,\n chain: SegmentNode<TFile>[],\n params: Record<string, string | string[]>,\n requireTerminal: boolean\n): boolean {\n chain.push(node);\n\n // All parts consumed — check if this node is terminal (or any node if !requireTerminal)\n if (index >= parts.length) {\n if (!requireTerminal || isTerminal(node)) return true;\n\n // Groups don't consume URL segments, so a group child's page can\n // match at the same URL depth. Recurse into groups transparently.\n for (const child of node.children) {\n if (child.segmentType === 'group') {\n if (matchNode(child, parts, index, chain, params, requireTerminal)) {\n return true;\n }\n }\n }\n\n // Optional catch-all with zero segments (direct and through groups).\n // The param is NOT set — matching Next.js semantics for [[...slug]]\n // with no path segments.\n const effective = collectEffectiveChildren(node);\n for (const { child, groupChain } of effective) {\n if (child.segmentType === 'optional-catch-all' && (!requireTerminal || isTerminal(child))) {\n chain.push(...groupChain, child);\n return true;\n }\n }\n\n chain.pop();\n return false;\n }\n\n const part = parts[index];\n\n // Flatten children through groups so priority ordering applies globally.\n const effective = collectEffectiveChildren(node);\n\n // 1. Static segments (exact name match)\n for (const { child, groupChain } of effective) {\n if (child.segmentType === 'static' && child.segmentName === part) {\n chain.push(...groupChain);\n if (matchNode(child, parts, index + 1, chain, params, requireTerminal)) {\n return true;\n }\n chain.length -= groupChain.length;\n }\n }\n\n // 2. Affixed dynamic segments (e.g. img-[id].png) — more specific than bare dynamic.\n // Sorted by specificity: longer combined prefix+suffix wins.\n const affixed = effective.filter(\n ({ child }) =>\n child.segmentType === 'dynamic' && child.paramName && (child.paramPrefix || child.paramSuffix)\n );\n affixed.sort((a, b) => affixLength(b.child) - affixLength(a.child));\n for (const { child, groupChain } of affixed) {\n const prefix = child.paramPrefix ?? '';\n const suffix = child.paramSuffix ?? '';\n if (\n part.length > prefix.length + suffix.length &&\n (!prefix || part.startsWith(prefix)) &&\n (!suffix || part.endsWith(suffix))\n ) {\n const value = part.slice(prefix.length, part.length - (suffix.length || 0));\n chain.push(...groupChain);\n const prev = params[child.paramName!];\n params[child.paramName!] = value;\n if (matchNode(child, parts, index + 1, chain, params, requireTerminal)) {\n return true;\n }\n // Backtrack\n chain.length -= groupChain.length;\n if (prev !== undefined) {\n params[child.paramName!] = prev;\n } else {\n delete params[child.paramName!];\n }\n }\n }\n\n // 3. Bare dynamic segments ([param])\n for (const { child, groupChain } of effective) {\n if (\n child.segmentType === 'dynamic' &&\n child.paramName &&\n !child.paramPrefix &&\n !child.paramSuffix\n ) {\n chain.push(...groupChain);\n const prev = params[child.paramName];\n params[child.paramName] = part;\n if (matchNode(child, parts, index + 1, chain, params, requireTerminal)) {\n return true;\n }\n // Backtrack\n chain.length -= groupChain.length;\n if (prev !== undefined) {\n params[child.paramName] = prev;\n } else {\n delete params[child.paramName];\n }\n }\n }\n\n // 4. Catch-all segments ([...param]) — must be terminal unless the\n // caller passed requireTerminal:false (metadata route matching needs to\n // find the owning segment even when it has no page).\n for (const { child, groupChain } of effective) {\n if (\n child.segmentType === 'catch-all' &&\n child.paramName &&\n (!requireTerminal || isTerminal(child))\n ) {\n chain.push(...groupChain, child);\n params[child.paramName] = parts.slice(index);\n return true;\n }\n }\n\n // 5. Optional catch-all segments ([[...param]]) — same terminal rule\n for (const { child, groupChain } of effective) {\n if (\n child.segmentType === 'optional-catch-all' &&\n child.paramName &&\n (!requireTerminal || isTerminal(child))\n ) {\n chain.push(...groupChain, child);\n params[child.paramName] = parts.slice(index);\n return true;\n }\n }\n\n chain.pop();\n return false;\n}\n","/**\n * The order-dependence oracle shared by every route collision validator.\n *\n * A \"collision space\" is a set of pages that compete for URLs with each other:\n * the main tree, each parallel slot, each intercepting subtree. Two pages in\n * one space that answer the same URL are ambiguous — `matchNode` resolves the\n * tie by whichever `children` array lists first, so which page renders is\n * decided by filesystem enumeration order and renaming a route group can flip\n * it. Every space rejects that shape, and they all reject it the same way,\n * through this module.\n *\n * **The check asks the real matcher rather than modelling it.** For each leaf\n * we build a URL it matches, then run `matchUrlParts` twice — once on the\n * space, once on a clone with every `children` array reversed — and compare the\n * winners. A URL answered by two or more candidates in the same priority tier\n * resolves to whichever comes first in `children`, so reversing the arrays\n * flips it; a URL with a single winner, or one settled by a higher tier, is\n * unaffected. Order-dependence is therefore detected exactly, with no second\n * copy of the precedence rules to drift.\n *\n * That drift is why this is written as an oracle. The interception validator's\n * first version normalized each pattern into a \"match shape\" and compared\n * shapes, which meant reimplementing `matchNode`'s tiers, its group flattening,\n * and its zero-length optional-catch-all handling. Five review rounds found\n * five divergences between the two — param spelling, a zero-length catch-all,\n * the bracket tokens colliding with legal static directory names, a page\n * settling a grouped catch-all, and a page settling a *direct* one (which the\n * model could not express at all, because `matchNode` checks every route-group\n * page before any direct optional catch-all). Each fix was locally right and\n * the next divergence surfaced anyway. The model was the defect.\n *\n * **Every claim made here is existential** — \"here is a URL these two contend\n * for\" — which is what a finite set of probes can actually establish. The\n * reverse, \"this page can never win any URL\", is universal, and a probe's\n * silence is not evidence for it: a leaf that loses every probe may still own\n * URLs no probe visited. An earlier revision reported that as an\n * unreachable-page error and produced two false build errors in one review\n * round. Probe inadequacy must only ever cost a missed collision, never a\n * rejected app — so nothing here may report a leaf as unreachable.\n *\n * See design/07-routing.md §\"Comparing Routes by the URLs They Match\".\n */\n\nimport type { SegmentNode } from './types.js';\nimport { effectiveUrlSegment } from './segment-classify.js';\n// The validators ask the real matcher which page answers a URL rather than\n// modelling its precedence rules a second time. `tree-match.ts` is a pure\n// walker over `SegmentNode` with no request-time state, and\n// `server/chain-url-parts.ts` already imports the other direction.\nimport { matchUrlParts } from '../server/tree-match.js';\n\n/** One page-or-route-bearing node in a collision space. */\nexport interface ProbeLeaf {\n /** The file that serves it — what the error message names. */\n filePath: string;\n /**\n * The nodes from the space root down to this leaf that contribute URL parts\n * — route groups excluded, since they are transparent for matching. Empty\n * for the space root's own page: `matchUrlParts` matches parts against the\n * root's *children*, so the root itself consumes nothing.\n */\n chain: SegmentNode[];\n}\n\n/** Two files in one space that a single URL resolves to order-dependently. */\nexport interface ProbedCollision {\n /** The contended URL, written for a human (see `describeProbeUrl`). */\n url: string;\n /** The file that wins in filesystem order. */\n first: string;\n /** The file that wins when every `children` array is reversed. */\n second: string;\n}\n\n/**\n * Find a URL in this collision space whose winner depends on `children` order,\n * or null if every probed URL resolves the same way in both orderings.\n *\n * `spaceRoot` is the node `matchUrlParts` starts from — the app root, a slot\n * node, or an intercepting directory. `base` is the URL that root sits at, used\n * only to render the reported URL.\n */\nexport function findOrderDependentCollision(\n spaceRoot: SegmentNode,\n leaves: Iterable<ProbeLeaf>,\n base: string\n): ProbedCollision | null {\n const reversed = withReversedChildren(spaceRoot);\n const longTail = longTailLength(spaceRoot) + 1;\n // Computed once for the space, not per leaf: it bounds the second candidate\n // wave, which only runs for a leaf the first wave never reached.\n const minLength = longestStaticName(spaceRoot);\n\n // Each probe is checked as it is generated, and the first flipped winner\n // returns immediately. Accumulating every probe first and scanning afterwards\n // reports the same collision — this walks the same probes in the same order —\n // but it pays for the whole space before saying anything, and the leaves that\n // cost the most are exactly the ones a found collision makes irrelevant.\n //\n // In a space of N equivalent dynamic siblings, only the first and last can\n // win a probe (one per ordering), so every middle leaf is unreachable and\n // exhausts the entire candidate alphabet looking for a value that reaches it\n // — 300 such siblings took ~2.5s to produce a build error the very first\n // probe already proved (codex, on PR #1002). A valid space of the same size\n // scans in ~35ms, so the cost was confined to the error path, but a slow\n // error is still a bad error.\n //\n // Deduped so a space with many leaves does not re-probe one URL, and so the\n // collision reported does not depend on which leaf generated a shared probe.\n const seen = new Set<string>();\n for (const leaf of leaves) {\n for (const { parts, display } of probeUrlsForLeaf(\n spaceRoot,\n reversed,\n leaf,\n longTail,\n minLength\n )) {\n const key = parts.join('/');\n if (seen.has(key)) continue;\n seen.add(key);\n\n const first = matchedLeafFile(spaceRoot, parts);\n const second = matchedLeafFile(reversed, parts);\n if (!first || !second || first === second) continue;\n return { url: describeProbeUrl(base, display), first, second };\n }\n }\n\n return null;\n}\n\n/** Join a probe's display parts onto its space's base. */\nfunction describeProbeUrl(base: string, display: string[]): string {\n if (display.length === 0) return base || '/';\n return `${base === '/' ? '' : base}/${display.join('/')}`;\n}\n\n/**\n * The file `matchUrlParts` resolves for a URL, or null if nothing does.\n *\n * A `route.ts` counts: `isTerminal` accepts either, so a route handler is a\n * legitimate winner of the walk and an ambiguity between a page and a route\n * handler is as real as one between two pages.\n */\nfunction matchedLeafFile(node: SegmentNode, parts: string[]): string | null {\n const match = matchUrlParts(node, parts);\n if (!match) return null;\n const leaf = match.chain[match.chain.length - 1];\n return leaf.page?.filePath ?? leaf.route?.filePath ?? null;\n}\n\n/**\n * A generated URL, and how to show it to a human.\n *\n * `display` is built alongside `parts` rather than derived from it by\n * substitution: a *static* segment can legitimately be named the same as the\n * probe value, and replacing every occurrence of that string rewrote the\n * literal directory to `<any>` — reporting `/<any>/<any>` for a collision under\n * a static `atimber-probea`, which claims a URL position is dynamic when the\n * author wrote it out (codex, on PR #1002). Only the segment that generated a\n * value knows whether it stood for one.\n */\ninterface ProbeUrl {\n parts: string[];\n display: string[];\n /**\n * Whether any part of this URL stood in for a value. When nothing did, every\n * candidate generates the identical URL and the search can stop after one.\n */\n dynamic: boolean;\n}\n\n/**\n * The values a probe's dynamic parts are tried with, in order.\n *\n * A probe stands in for \"any value\" at a dynamic position, so it is only useful\n * if it reaches the leaf it was built for. A *static* sibling's literal name or\n * a more specific *affixed* sibling's pattern can claim it instead, and that\n * higher-priority segment then wins in both orderings — a genuine tie\n * underneath goes unreported, which is safe but is the whole thing these\n * validators are for.\n *\n * Which values are claimable is a question about `matchNode`'s precedence, so\n * `probeUrlsForLeaf` asks `matchUrlParts` rather than deciding it here. This\n * only has to offer enough shapes for the search to find one that works: an\n * affixed sibling constrains the head of the value, its tail, or both, so head\n * and tail are varied over an alphanumeric alphabet. The head varies fastest\n * because a prefix is the more common affix. Exhausting the list is a missed\n * collision like any other inadequate probe, so this is a search and not a\n * proof — nothing downstream may treat it as one.\n *\n * Exported so a test that has to *name* a capturing static sibling can derive\n * the name from this list rather than restate it — a fixture spelling the value\n * out by hand stops being a capture the moment the list changes, and passes.\n *\n * Three revisions of a hand-built value each dodged one more capture and were\n * each followed by another (avoid static names; avoid affix boundary\n * characters; avoid re-affixed forms of static names — then a strictly more\n * specific affixed sibling, TIM-1313). Each rule was modelling affix precedence\n * by hand, which is what the match-shape model was deleted for.\n */\nexport function* probeCandidates(minLength = 0): Generator<string> {\n const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const base = 'timber-probe';\n\n function* wave(core: string): Generator<string> {\n for (const tail of alphabet) {\n for (const head of alphabet) yield `${head}${core}${tail}`;\n }\n }\n\n yield* wave(base);\n\n // A second wave, longer than every static segment name in the space.\n //\n // A static sibling claims a probe only by **string equality**, so a value\n // longer than every static name in the space cannot be claimed by one — that\n // is a fact about lengths, not a model of `matchNode`'s precedence, which is\n // what makes it safe to state as an invariant where \"pick an unclaimable\n // value\" was not. An app holding a static directory for all 1296 first-wave\n // candidates claimed every probe and hid a real collision (codex, on\n // PR #1002); it cannot do the same here, because the length is derived from\n // its own longest static and adding a longer one only pushes this further out.\n //\n // Affix capture is not addressed by length and is not addressable this way:\n // an affixed pattern matches infinitely many values, so escaping one is still\n // the head/tail search below. The first wave is byte-identical to what it was\n // before this existed, so nothing that already found a value changes.\n const padded = base.padEnd(Math.max(base.length, minLength), 'x');\n if (padded !== base) yield* wave(padded);\n}\n\n/**\n * The longest static segment name anywhere in the space.\n *\n * Read through `effectiveUrlSegment` so an intercepting directory counts as the\n * segment it intercepts, and only static kinds count: a dynamic sibling claims\n * a probe by pattern rather than by equality, which no length can escape.\n */\nfunction longestStaticName(node: SegmentNode): number {\n let longest = 0;\n for (const child of node.children) {\n const seg = effectiveUrlSegment(child);\n if (seg.segmentType === 'static') longest = Math.max(longest, seg.segmentName.length);\n longest = Math.max(longest, longestStaticName(child));\n }\n return longest;\n}\n\n/**\n * The probe URLs for one leaf, built from the first candidate value that\n * actually reaches it.\n *\n * \"Reaches it\" is `matchUrlParts` resolving one of the leaf's own URLs to the\n * leaf's file, in either ordering — either is enough, because a leaf that wins\n * only in the reversed ordering is precisely the contention being looked for.\n * A catch-all leaf may be reached by its long probe and not its short one (at\n * one part it loses to a bare dynamic sibling deterministically), so any one of\n * the generated URLs landing is enough to accept the value.\n *\n * A leaf that no candidate reaches is shadowed at its position for every value\n * tried — most often because it sits below a catch-all, which `matchNode`\n * accepts only as a terminal and never descends past. Its probes are still\n * emitted, from the first candidate: a probe that misses its own leaf is never\n * *wrong* — it is a real URL, and a winner that differs between the two\n * orderings is a real ambiguity whichever leaf it belongs to. Nothing here may\n * report the leaf as unreachable; that is the universal claim these validators\n * do not make.\n */\nfunction probeUrlsForLeaf(\n root: SegmentNode,\n reversed: SegmentNode,\n leaf: ProbeLeaf,\n longTail: number,\n minLength: number\n): ProbeUrl[] {\n let fallback: ProbeUrl[] | null = null;\n\n for (const value of probeCandidates(minLength)) {\n const urls = probeUrlsFor(leaf.chain, value, longTail);\n const reaches = urls.some(\n ({ parts }) =>\n matchedLeafFile(root, parts) === leaf.filePath ||\n matchedLeafFile(reversed, parts) === leaf.filePath\n );\n if (reaches) return urls;\n fallback ??= urls;\n\n // A leaf with no dynamic part in its chain matches exactly one URL, so the\n // candidate value never appears in it and every further candidate would\n // generate the identical probe. Searching on would cost the whole alphabet\n // per statically-shadowed leaf — and in the main tree those are ordinary\n // (anything below a catch-all) rather than the pathology they are inside an\n // intercepting subtree. Stopping is not a weaker check: the URLs are the\n // same ones, and they are still probed via `fallback`.\n if (!urls.some(({ dynamic }) => dynamic)) break;\n }\n\n // `probeCandidates` is non-empty, so this is only reached with a fallback.\n return fallback ?? [];\n}\n\n/**\n * The URL part one segment contributes to a probe.\n *\n * A dynamic segment stands for any single value, so it contributes the\n * candidate value — re-affixed, since an affixed segment only matches parts\n * that carry its prefix and suffix, so a probe without them could not reach it.\n * A catch-all stands for one or more parts, and one is enough to reach the leaf.\n *\n * The re-affixed part is the reason a value cannot be checked once for the\n * whole space: it exposes the value to every affixed sibling that *extends*\n * this segment's affixes, which differs per position. `probeUrlsForLeaf` asks\n * the matcher whether the assembled URL reaches its leaf, and moves to the next\n * candidate when it does not.\n *\n * Segments are read through `effectiveUrlSegment` so an intercepting directory\n * contributes the part the segment it intercepts would.\n */\nfunction probePartFor(node: SegmentNode, value: string): ProbePart {\n const seg = effectiveUrlSegment(node);\n switch (seg.segmentType) {\n case 'dynamic': {\n const prefix = seg.paramPrefix ?? '';\n const suffix = seg.paramSuffix ?? '';\n // The affixes are kept in the shown form too: `x-<any>` says which URLs\n // are contended for, where a bare `<any>` would claim every value at that\n // position.\n return {\n part: `${prefix}${value}${suffix}`,\n shown: `${prefix}<any>${suffix}`,\n dynamic: true,\n };\n }\n case 'catch-all':\n case 'optional-catch-all':\n return { part: value, shown: '<any>', dynamic: true };\n default:\n return { part: seg.segmentName, shown: seg.segmentName, dynamic: false };\n }\n}\n\n/** One URL part of a probe: what to send, what to show, and whether it stands for a value. */\ninterface ProbePart {\n part: string;\n shown: string;\n dynamic: boolean;\n}\n\n/**\n * The URLs that reach a leaf.\n *\n * An **optional catch-all also matches zero parts**, so it answers the URL its\n * parent sits at as well as longer ones. Both are probed: whether the shorter\n * one is actually *its* to answer is `matchUrlParts`' business, not something\n * to decide here — a page above it, or in a route group beside it, may take\n * that URL deterministically, and the probe will simply report the same winner\n * in both orderings.\n */\nfunction probeUrlsFor(chain: SegmentNode[], value: string, longTail: number): ProbeUrl[] {\n const probeParts = chain.map((node) => probePartFor(node, value));\n const url = (ps: ProbePart[]): ProbeUrl => ({\n parts: ps.map((p) => p.part),\n display: ps.map((p) => p.shown),\n dynamic: ps.some((p) => p.dynamic),\n });\n\n // The kind that decides the probe lengths is the last part-CONTRIBUTING\n // segment's, which is why it is read off the chain rather than off the leaf\n // node. An empty chain is the space root's own page: the walk matches parts\n // against that node's children, so the node's own segment consumes nothing\n // and the only URL that reaches the page is the empty one — even when the\n // root is itself a catch-all (`(.)[...rest]`).\n const leaf = chain[chain.length - 1];\n const kind = leaf && effectiveUrlSegment(leaf).segmentType;\n const isCatchAll = kind === 'catch-all' || kind === 'optional-catch-all';\n if (!isCatchAll) return [url(probeParts)];\n\n // `matchNode` accepts a catch-all only as a terminal, so a catch-all that\n // *is* the leaf owns the whole tail of the probe and it can be re-sized\n // freely. (A catch-all higher in the chain has descendants nothing can\n // reach; those leaves are the statically-shadowed case above.)\n const head = probeParts.slice(0, -1);\n const urls = [url(probeParts)];\n\n // A LONG tail as well as a short one. At one part a catch-all loses to any\n // bare dynamic sibling, deterministically — so a one-part probe reports that\n // sibling in both orderings and two catch-alls competing at every longer URL\n // go unnoticed. `longTail` is past every finite branch in the space, where\n // no fixed-length competitor can still be matching.\n if (longTail > 1) {\n // Every part is the candidate value verbatim. Decorating them to differ\n // (`${value}-0`) puts them back inside patterns like `[value]-0/[...rest]`,\n // which outranks a catch-all — the trailing counter reintroduced exactly\n // the affix capture the value is being searched for (codex, on PR #1000).\n // The parts need not differ from each other; a catch-all consumes them all.\n const tail: ProbePart[] = Array.from({ length: longTail }, () => ({\n part: value,\n shown: '<any>',\n dynamic: true,\n }));\n urls.push(url([...head, ...tail]));\n }\n\n // An optional catch-all also matches zero parts.\n if (kind === 'optional-catch-all') urls.push(url(head));\n\n return urls;\n}\n\n/**\n * One more than the longest fixed-length path in the space.\n *\n * A probe of this length cannot be claimed by any branch that consumes a fixed\n * number of URL parts, so whatever matches it is a catch-all — which is\n * exactly the competition a short probe hides.\n */\nfunction longTailLength(node: SegmentNode): number {\n let deepest = 0;\n for (const child of node.children) {\n const own = child.segmentType === 'group' ? 0 : 1;\n deepest = Math.max(deepest, own + longTailLength(child));\n }\n return deepest;\n}\n\n/**\n * The subtree with every `children` array reversed, top to bottom.\n *\n * Nodes are shallow-copied, so files and slots are shared with the original —\n * only the ordering `matchNode` reads is different. Slots are not reversed\n * because `matchNode` never walks them; each slot is validated as its own\n * collision space, with its own reversed clone.\n */\nfunction withReversedChildren(node: SegmentNode): SegmentNode {\n return { ...node, children: [...node.children].reverse().map(withReversedChildren) };\n}\n","/**\n * Intercepting route utilities.\n *\n * Computes rewrite rules from the route tree that enable intercepting routes\n * to conditionally render when navigating via client-side (soft) navigation.\n *\n * The mechanism: at build time, each intercepting route directory generates a\n * conditional rewrite. On soft navigation, the client sends an `X-Timber-URL`\n * header with the current pathname. The server checks if any rewrite's source\n * (the intercepted URL) matches the target pathname AND the header matches\n * the intercepting route's parent URL. If both match, the intercepting route\n * renders instead of the normal route.\n *\n * On hard navigation (no header), no rewrite matches, and the normal route\n * renders.\n *\n * See design/07-routing.md §\"Intercepting Routes\"\n */\n\nimport type { SegmentNode, InterceptionMarker, RouteFile } from './types.js';\nimport { computeSegmentTreePaths, treePathDepth } from './segment-keys.js';\nimport { classifyUrlSegment, effectiveUrlSegment } from './segment-classify.js';\n// Every collision space — the main tree, each slot, each intercepting subtree\n// — decides order-dependence with the same oracle, so the spaces cannot drift\n// on what counts as two pages answering one URL. See TIM-1308.\nimport { findOrderDependentCollision, type ProbeLeaf } from './collision-probe.js';\n\n/** Fields shared by both interception shapes. */\ninterface InterceptionRewriteBase {\n /**\n * The URL pattern that this rewrite intercepts (the target of navigation).\n * E.g., \"/photo/[id]\" for a (.)photo/[id] interception.\n */\n interceptedPattern: string;\n /**\n * The tree path of the segment that OWNS the slot holding this\n * intercepting route (`computeSegmentTreePaths`, e.g. \"/feed\",\n * \"/(browse)\", \"/(browse)/feed\", or \"/\" at the app root).\n *\n * The rewrite only applies when the source route — the page the user is\n * navigating FROM — passes through that directory, because only then\n * does the slot holding the intercepting page exist in the rendered\n * tree. The server checks this by matching X-Timber-URL and testing its\n * segment chain's tree paths for this value.\n *\n * Neither of the identities already in the codebase works here:\n *\n * - A **URL prefix** cannot express it. Route groups contribute nothing\n * to `urlPath`, so `(browse)/@detail/(...)x` and a genuinely\n * root-level `@modal/(...)x` both have prefix \"/\" while meaning very\n * different things.\n * - A **state-tree key** (`computeSegmentKeys`) cannot either. It\n * qualifies a group with its ancestry but resets to `urlPath` at the\n * next URL-visible segment, so `(browse)/feed` and `(landing)/feed`\n * both key as \"/feed\" — and a navigation inside `(landing)/feed/…`\n * would reach `(browse)/feed`'s slot.\n *\n * Tree paths never reset, so two directories that render different\n * layouts never share one. \"/\" as a scope means the app root, which\n * every route passes through — preserving the intentional\n * match-from-anywhere behavior of a root-level `(...)` interception\n * (TIM-1006) without an exemption. See TIM-1279.\n */\n interceptingScope: string;\n}\n\n/**\n * A conditional rewrite rule generated from an intercepting route.\n *\n * `mode` records which of the two shapes the directory expresses, because the\n * two render through entirely different mechanisms and the fields they need\n * are not the same. It is a union rather than a flag so a reader cannot\n * re-match `interceptingPrefix` on the shape that has no such pathname.\n *\n * See design/07-routing.md §\"Intercepting Routes\".\n */\nexport type InterceptionRewrite = SlotInterceptionRewrite | ChildrenInterceptionRewrite;\n\n/**\n * A **modal overlay** interception — the intercepting directory is a direct\n * child of a parallel slot (`feed/@modal/(.)photo/[id]`).\n *\n * The server re-matches the *source* route and the slot resolver finds the\n * intercepting child inside the slot, so the intercepting page layers over\n * the page the user was already on.\n */\nexport interface SlotInterceptionRewrite extends InterceptionRewriteBase {\n mode: 'slot';\n /**\n * The pathname the server re-matches when this rewrite applies — the\n * intercepting slot owner's URL path. E.g., \"/feed\" for a (.)photo/[id]\n * inside /feed/@modal/.\n *\n * This is a build-time constant, never a client-supplied value: the\n * X-Timber-URL header selects a rewrite but never becomes the rendered\n * pathname.\n */\n interceptingPrefix: string;\n}\n\n/**\n * A **sibling layout swap** interception — the intercepting directory is a\n * direct child of an ordinary segment or route group\n * (`(browse)/(...)[artistSlug]/…`).\n *\n * There is no overlay, no slot and no `default.tsx`: the intercepting page\n * *replaces* `children` for the owner's layout chain. Nothing is re-matched\n * either. The server resolves the owner by `interceptingScope` — a tree path,\n * which identifies exactly one directory — and builds the rendered chain as\n * `[…owner ancestors, interceptingNode, …its matched descendants]`. That is an\n * ordinary segment chain, so `tree-builder.ts` renders it with no knowledge\n * that interception happened.\n *\n * Resolving the owner from the tree rather than from a URL is what makes this\n * shape work where the modal shape cannot: `interceptingPrefix` is\n * URL-derived, and a route group contributes nothing to `urlPath`, so an owner\n * like `app/(browse)/` serializes to \"/\" and re-matching it lands in whichever\n * group owns the canonical page. A tree path never collapses (TIM-1280).\n */\nexport interface ChildrenInterceptionRewrite extends InterceptionRewriteBase {\n mode: 'children';\n}\n\n/**\n * A set of sibling interceptors that compete for one URL position.\n *\n * `base` is the intercepted base they share — the URL their own segments sit\n * directly under — and `anchorIndex` is how many URL parts that base spans,\n * which is the index in a target pathname their segments are matched at.\n * Deeper anchors are more local and are tried first.\n */\nexport interface InterceptorAnchorGroup<TFile> {\n base: string;\n anchorIndex: number;\n interceptors: SegmentNode<TFile>[];\n}\n\n/**\n * Group an owner's intercepting children by the URL position they contend for.\n *\n * This is the definition of *which interceptors compete*, and it has exactly\n * one caller shape on each side of the build: `findInterceptingMatch` resolves\n * a group with one `matchUrlParts` walk, and\n * `assertNoInterceptedPatternCollisions` validates the same group as one\n * collision space. Written twice, the two would be free to disagree about what\n * competes — and a resolver that walks a wider set than the validator checked\n * is precisely the order-dependence the validator exists to reject (TIM-1310).\n *\n * Contention is keyed by the computed intercepted **base**, not by the marker:\n * under an owner at `/feed`, `(..)` and `(...)` both base at `/` and are both\n * matched at index 0, so they are one group. Different bases are different\n * positions — a `(.)` interceptor can never claim a target that belongs to a\n * `(..)` one beside it, because the base must also match the target's leading\n * parts.\n *\n * The base is a URL *pattern*, so its length is its part count only because\n * every pattern part stands for exactly one URL part. A catch-all in the base\n * breaks that, and `assertInterceptedBaseIsCountable` rejects the shape at\n * build time.\n *\n * A node missing either marker field is skipped, which `classifySegment` never\n * produces — it sets both whenever it reports `'intercepting'`. Stating the\n * filter here rather than defaulting the marker is what makes the validator and\n * the resolver see the same set: such a node renders nothing either way, and a\n * validator more permissive than the resolver would be checking a candidate\n * that never competes while the resolver walks one nobody checked.\n *\n * `children` is read directly rather than flattened through route groups,\n * matching both resolvers: the slot resolver reads `slotNode.children`, and an\n * interceptor deeper inside a slot subtree is rejected by\n * `validateInterceptionPlacement`. On the children path an interceptor under a\n * route group is legal and the *group* is its owner, so it is grouped with that\n * group's other interceptors — which is again exactly what the resolver walks,\n * since it resolves the owner by tree path.\n */\nexport function groupByInterceptedAnchor<TFile>(\n ownerUrlPath: string,\n children: readonly SegmentNode<TFile>[]\n): InterceptorAnchorGroup<TFile>[] {\n const byBase = new Map<string, InterceptorAnchorGroup<TFile>>();\n\n for (const child of children) {\n if (child.segmentType !== 'intercepting') continue;\n if (!child.interceptionMarker || !child.interceptedSegmentName) continue;\n\n const base = computeInterceptedBase(ownerUrlPath, child.interceptionMarker);\n const group = byBase.get(base);\n if (group) {\n group.interceptors.push(child);\n } else {\n byBase.set(base, {\n base,\n anchorIndex: base === '/' ? 0 : base.slice(1).split('/').length,\n interceptors: [child],\n });\n }\n }\n\n // Deepest anchor first: a `(.)` interception is the most local one and wins\n // over a `(...)` that reaches the same page from the root.\n return [...byBase.values()].sort((a, b) => b.anchorIndex - a.anchorIndex);\n}\n\n/**\n * Collect all interception rewrite rules from the route tree.\n *\n * Walks the tree recursively. For each intercepting segment, computes the\n * intercepted URL based on the marker and the segment's position.\n *\n * The list is returned **deepest scope first**, which is what makes\n * `findInterceptionMatch`'s first-match rule deterministic; see\n * `sortByScopeDepth`.\n */\nexport function collectInterceptionRewrites(root: SegmentNode): InterceptionRewrite[] {\n const rewrites: InterceptionRewrite[] = [];\n walkForInterceptions(root, [root], false, rewrites);\n return sortByScopeDepth(rewrites);\n}\n\n/**\n * Order the rewrites deepest scope first, so the request-time first-match rule\n * resolves two applicable rewrites by *nesting* rather than by tree-walk order.\n *\n * `findInterceptionMatch` returns the first rewrite whose pattern matches the\n * target and whose scope the source route reports. More than one can satisfy\n * both, and the case is not exotic — an owner and a directory *beneath* it may\n * each hold an interceptor for one URL:\n *\n * ```\n * app/feed/(.)photo/page.tsx scope /feed\n * app/feed/(a)/(.)photo/page.tsx scope /feed/(a)\n * ```\n *\n * A page inside `(a)` renders both owners' layouts, so the client reports both\n * tree paths and both scopes pass. Unsorted, the winner is whichever the\n * filesystem enumerated first — renaming the group flips which page a click\n * opens, the defect class TIM-1305/TIM-1308/TIM-1310 each rejected in a\n * different space. Here it is an ambiguity between *rewrites* rather than\n * between pages inside one walk, so no collision space sees it.\n *\n * **Deepest wins, and it is specified rather than rejected** because the shape\n * is one a correct app writes on purpose: a nested layout refining the\n * interception its parent declares, exactly as `groupByInterceptedAnchor`\n * already prefers the deepest *anchor* within one owner. The two rules are the\n * same preference — the more local interception is the author's more specific\n * statement — applied at the two levels the mechanism has.\n *\n * Depth is counted on the **tree path**, the identity that never collapses\n * (TIM-1279/TIM-1280); a `urlPath` prefix test would relate `(browse)` and\n * `(landing)`, which render different layouts and share no chain. Two scopes on\n * one rendered chain are strictly nested, so depth orders them totally, and two\n * scopes that are *not* on one chain — sibling groups, `feed/(a)` beside\n * `feed/(b)` — never both pass the scope check, so their relative order is not\n * observable. That is why this sorts on depth alone rather than testing\n * ancestry: it is a total order over the pairs that can compete, and it costs\n * nothing per request.\n *\n * Sorting is stable, so rewrites sharing one scope keep tree-walk order. Equal\n * scopes mean one owner, and of the three pairings that produces only one is an\n * ambiguity — a children-path interceptor beside a slot one, tracked as\n * TIM-1319. The enumeration is in design/07-routing.md §\"Selection Between\n * Owners\" rather than repeated here, so there is one place to correct if a\n * rewrite ever grows a field that makes two of them distinguishable.\n */\nfunction sortByScopeDepth(rewrites: InterceptionRewrite[]): InterceptionRewrite[] {\n return rewrites.sort(\n (a, b) => treePathDepth(b.interceptingScope) - treePathDepth(a.interceptingScope)\n );\n}\n\n/**\n * Validate that every intercepting segment sits where it can actually render.\n *\n * There are exactly two positions a renderer exists for, and they are the two\n * shapes interception has:\n *\n * 1. **Direct child of a parallel slot** — the modal overlay. The slot\n * resolver scans a slot node's *direct children* for an intercepting\n * segment (`server/slot-interception.ts`). Nothing between the slot and\n * the intercepting directory is allowed, because nothing walks it.\n * 2. **Direct child of an ordinary segment or route group** — the sibling\n * layout swap (TIM-1280). The pipeline resolves the owner by tree path and\n * builds the rendered chain through the intercepting node itself\n * (`server/children-interception.ts`).\n *\n * Everywhere else, rewrite generation still emits a rewrite and nothing\n * renders it: the rewrite matches the soft navigation, and the user is served\n * the page they were already on under a changed URL (TIM-1278). The rejected\n * positions are:\n *\n * - **Inside a slot subtree but not directly under the slot**\n * (`@modal/(inner)/(.)photo`). Neither renderer applies: the slot resolver\n * only reads direct children, and the children-path resolver builds a\n * *chain*, which cannot express a descent through a slot.\n * - **Inside another intercepting subtree** (`(.)a/(.)b`). Left unvalidated\n * `collectLeavesWithRewrites` walks the inner one as an ordinary URL\n * segment and emits a pattern containing a literal \"(.)b\".\n *\n * Two further shapes are rejected here (TIM-1288). Both are about a catch-all,\n * and both are specific to interception: elsewhere in the tree the same\n * shapes are inert or fail safely, and the general \"nothing below a catch-all\n * is reachable\" rule is tracked as TIM-1286.\n *\n * And one is specific to the children path: an owner chain that binds params\n * (see `assertOwnerChainBindsNoParams`).\n */\nexport function validateInterceptionPlacement(root: SegmentNode): void {\n walkForPlacement(root, '', {\n parentIsSlot: false,\n inSlotSubtree: false,\n inInterceptingSubtree: false,\n ancestorsBindParams: false,\n });\n}\n\n/**\n * Reject a children-path interception whose owner chain binds params.\n *\n * The rendered chain is `[…owner ancestors, interceptingNode, …descendants]`,\n * and the only pathname available to bind params from is the **target** — the\n * URL being navigated to. The intercepting subtree's own params come from it\n * by construction. The owner chain's do not, in general:\n *\n * - With a climbing marker the owner's URL segments are not in the target at\n * all. `app/[team]/(..)photo/[id]` bases at \"/\", so the target is\n * `/photo/9` — there is no team value anywhere in it, and `[team]`'s layout\n * would render with the param it declares missing.\n * - With `(.)` the base *is* the owner's `urlPath`, so the target's leading\n * parts would bind it. Supporting only that half means one marker behaves\n * differently from its siblings for reasons the author cannot see from the\n * directory names, so the rule is stated once, on the owner chain.\n *\n * A layout that silently renders without the param it declares is the failure\n * this prevents; it is rejected where it can be explained rather than left to\n * surface as `undefined` deep inside user code. Route groups and static\n * segments bind nothing and are unrestricted, which is the whole motivating\n * shape (`app/(browse)/(...)[artistSlug]/…`).\n *\n * The rule stops at a slot boundary: a slot-mode interception re-matches the\n * *source* route, which supplies the owner's params, so a dynamic owner is\n * fine there and always has been.\n */\n/**\n * Require a children-path interception's owner to have a `layout.tsx`.\n *\n * The scope is the owner's tree path, and the client reports which tree paths\n * it has mounted from `X-Timber-Segments` — which carries **one entry per\n * layout-bearing segment**, because those are the segments the client needs an\n * outlet and a cache node for. `buildSegmentInfo` skips the rest.\n *\n * For the modal shape that set is exactly the set of possible scope owners, by\n * construction: a slot is only resolved inside a rendering layout\n * (`route-element-builder.ts`), so a layoutless segment can never own one. A\n * children-path interception broke that equivalence — its owner is an ordinary\n * directory and needs no layout.\n *\n * Left unchecked the result is a swap that works exactly once: the first soft\n * navigation renders, then the client reports no such tree path, and the next\n * navigation fails the scope check and falls back to the canonical page. That\n * is fail-safe but silent, and the address-bar channel cannot recover it —\n * once the swap is on screen the address holds the *intercepted* URL, which\n * re-matches the canonical chain (the TIM-1282 problem, in the one shape the\n * rendered-scope fix does not reach).\n *\n * Requiring the layout restores the invariant the state tree is built on\n * rather than widening the wire format to carry segments that own no outlet\n * and no payload. It also costs the author nothing they were not already\n * doing: the point of this shape is to render inside the owner's own layout,\n * so an owner with no layout has no chrome to preserve.\n */\nfunction assertOwnerHasLayout(ownerPath: string, childPath: string): void {\n const owner = ownerPath || '(app root)';\n throw new Error(\n `Build error: intercepting route whose owner has no layout.\\n` +\n ` Directory: app/${childPath}\\n` +\n ` Owner: app/${owner}\\n` +\n `An intercepting directory outside a parallel slot renders inside its owner's ` +\n `layout chain, and the owner must have a layout.tsx: the client reports which ` +\n `directories it has mounted from its layout segments, and a scope it cannot ` +\n `report would let the interception fire once and then silently stop.\\n` +\n `Add app/${owner}/layout.tsx (a pass-through returning {children} is enough), or ` +\n `move the interception under a directory that has one.\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n}\n\nfunction assertOwnerChainBindsNoParams(childPath: string, marker: InterceptionMarker): void {\n throw new Error(\n `Build error: intercepting route under a dynamic segment.\\n` +\n ` Directory: app/${childPath}\\n` +\n `An intercepting directory outside a parallel slot renders inside its own ` +\n `layout chain, and the only pathname available to bind params from is the ` +\n `intercepted URL — which does not carry the values of the segments above ` +\n `\"${marker}\".\\n` +\n `Move the interception so every directory above it is a static segment or a ` +\n `route group, or place it inside a parallel slot (@modal/) to render it as an ` +\n `overlay over the source route instead.\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n}\n\n/**\n * Reject an intercepting route whose intercepted level is not well-defined.\n *\n * \"One level up\" is counted in URL segments, which works because every\n * pattern part stands for exactly one URL part — except a catch-all, which\n * stands for a number that varies per request. `anchorIndex` fixes the anchor\n * at the base's pattern length, so with an owner at `/docs/[...path]` the\n * interception resolves when the catch-all consumed exactly one segment\n * (`/docs/a/photo/5`) and is dropped when it consumed more\n * (`/docs/a/b/photo/5`), because the base no longer matches the target's\n * leading parts.\n *\n * Dropping is fail-safe — the canonical route renders, as on hard navigation\n * — so this is never a wrong page. But it is a modal that opens at one depth\n * and silently does not at another, with nothing to tell the author why, and\n * no request-time input can fix it: the only available source depth is\n * `X-Timber-URL`, which is the browser's address bar, and once a modal is\n * open that holds the *intercepted* URL rather than the source.\n *\n * So the shape is rejected where it can be explained. A marker that climbs\n * *past* the catch-all is fine — `(..)` from `/docs/[...path]` bases at\n * `/docs` — and so is `(...)`, which always bases at the root. The rule is on\n * the *computed* base, not on having a catch-all anywhere above.\n */\nfunction assertInterceptedBaseIsCountable(\n child: SegmentNode,\n ownerUrlPath: string,\n childPath: string\n): void {\n const marker = child.interceptionMarker ?? '(.)';\n const base = computeInterceptedBase(ownerUrlPath, marker);\n const baseParts = base === '/' ? [] : base.slice(1).split('/');\n const ambiguous = baseParts.find((part) => {\n const kind = classifyUrlSegment(part).kind;\n return kind === 'catch-all' || kind === 'optional-catch-all';\n });\n if (!ambiguous) return;\n\n throw new Error(\n `Build error: intercepting route below a catch-all segment.\\n` +\n ` Directory: app/${childPath}\\n` +\n ` Intercepted base: ${base}\\n` +\n `A catch-all (${ambiguous}) matches a number of URL segments that varies per ` +\n `request, so \"${marker}\" cannot identify which segment of a target pathname the ` +\n `interception starts at — the modal would open at one depth and silently not at ` +\n `another.\\n` +\n `Move the interception above the catch-all, or use a marker that climbs past it ` +\n `((..) or (...)).\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n}\n\n/**\n * Reject a catch-all inside an intercepting subtree that has directories\n * below it.\n *\n * A catch-all consumes the whole remaining path, so nothing under it is\n * reachable — `matchUrlParts` only accepts a catch-all as a terminal leaf and\n * never descends past one. Rewrite generation is not so strict: it walks the\n * subtree and emits `/feed/[...rest]/child`, and `pathnameMatchesPattern`\n * returns as soon as it reaches the catch-all without ever looking at\n * `child`. So the rewrite matches the navigation and then no renderer exists\n * — the TIM-1278 failure mode reached by a different route, with the user\n * served the page they were already on under a changed URL.\n *\n * The check covers the whole intercepting subtree, not just the intercepted\n * segment: `(.)photo/[...rest]/child` emits `/feed/photo/[...rest]/child` and\n * hijacks `/feed/photo/a/b` by exactly the same mechanism. And it does not\n * exempt a catch-all that carries its own page — that one does render, but\n * the rewrite generated for the unreachable descendant is broader than any\n * route in the tree, so the tail modal fires on navigations no directory\n * describes.\n *\n * Outside a slot the same shape merely 404s, which is why the general rule is\n * tracked separately (TIM-1286); here it is unsafe, and it only became\n * reachable when catch-all intercepted segments started matching at all\n * (TIM-1281).\n *\n * The walk descends `children` and not `slots`, mirroring\n * `collectLeavesWithRewrites` exactly: what this rejects is precisely the set\n * of paths rewrite generation emits, so the two cannot disagree about which\n * shapes exist. A slot nested inside an intercepting subtree produces no\n * rewrite and so cannot hijack anything.\n */\nfunction assertInterceptedCatchAllsAreTerminal(node: SegmentNode, nodePath: string): void {\n const { segmentType, segmentName } = effectiveUrlSegment(node);\n const isCatchAll = segmentType === 'catch-all' || segmentType === 'optional-catch-all';\n\n if (isCatchAll && node.children.length > 0) {\n throw new Error(\n `Build error: catch-all with nested segments inside an intercepting route.\\n` +\n ` Directory: app/${nodePath}\\n` +\n ` Nested: ${node.children.map((c) => c.segmentName).join(', ')}\\n` +\n `A catch-all (${segmentName}) consumes every remaining URL segment, so nothing ` +\n `below it can ever match — but the interception rewrite would still be generated ` +\n `and would hijack the navigation with no page to render.\\n` +\n `Move the nested routes above the catch-all, or intercept a named segment instead.\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n }\n\n for (const child of node.children) {\n assertInterceptedCatchAllsAreTerminal(child, `${nodePath}/${child.segmentName}`);\n }\n}\n\n/**\n * Reject two pages that answer one URL among the interceptors an owner\n * resolves in a single walk.\n *\n * `validateRouteGroupCollisions` in the scanner returns early on an\n * intercepting node, so nothing else validates in here. That exemption exists\n * for a real reason — an interception's computed URL legitimately mirrors the\n * canonical route it replaces, and interceptors at *different* anchors\n * deliberately target one URL, which the resolver then orders (deepest anchor\n * first). But the exemption was broader than its reason. Two shapes slip\n * through it, and they are the same shape seen from two levels:\n *\n * feed/(.)photo/(a)/page.tsx feed/@modal/(.)[a]/page.tsx\n * feed/(.)photo/(b)/page.tsx feed/@modal/(.)[b]/page.tsx\n *\n * Both pairs answer one URL, and in both `matchUrlParts` resolves the tie by\n * whichever `children` array lists first — so the winner is whichever the\n * filesystem enumerated first, and renaming a directory flips it. That is\n * exactly what `validateRouteGroupCollisions` and\n * `validateAffixedSiblingConflicts` exist to reject for ordinary siblings.\n *\n * **The collision space is the anchor group, not the directory.** An earlier\n * revision ran once per intercepting directory, which sees the left-hand pair\n * and not the right-hand one: those leaves live in two different directories.\n * The space is `groupByInterceptedAnchor`'s output — the same grouping\n * `findInterceptingMatch` hands to one `matchUrlParts` call — so what is\n * validated together is exactly what is resolved together. Interceptors at\n * different anchors stay independent, which is the documented case, and two\n * slots on one owner are two owners and so two spaces.\n *\n * **Two checks, and the difference between them matters.** A duplicate\n * intercepted *pattern* is decided by string equality, which is exact: two\n * leaves with one pattern claim one set of URLs, whatever the precedence rules\n * are. Everything else is decided by asking the matcher — `collision-probe.ts`,\n * the same oracle the main tree and every slot use, so the spaces cannot\n * disagree about whether a pair of pages collides.\n *\n * Not covered: two affixed dynamics that tie on specificity (`(x)/a-[id]` vs\n * `(y)/[slug]-b`, ambiguous only for a part shaped `a-…-b`). No single probe\n * URL exercises both, and `validateAffixedSiblingConflicts` already rejects\n * that pair by affix length — including through groups, inside intercepting\n * subtrees, and between two interceptors sharing an anchor.\n *\n * The shape applies to both interception mechanisms — a slot interceptor and a\n * children-path one produce their leaves through the same walk, and both are\n * resolved by `findInterceptingMatch` — so this is called from the one place in\n * `walkForPlacement` that sees every owner regardless of position.\n */\nfunction assertNoInterceptedPatternCollisions(owner: SegmentNode, ownerPath: string): void {\n for (const group of groupByInterceptedAnchor(owner.urlPath, owner.children)) {\n assertAnchorGroupHasNoCollisions(group, ownerPath);\n }\n}\n\n/**\n * The URL-matching identity of an intercepting node, as a node.\n *\n * `matchUrlParts` reads `segmentType` directly and knows nothing about\n * interception, so a marker'd directory has to be handed to it under the\n * identity of the segment it intercepts — `(.)[id]` as `[id]`. Priority\n * ordering, affix stripping and catch-all handling then come from the shared\n * walker rather than from a second classifier here.\n *\n * Shared with `findInterceptingMatch` for the same reason the grouping is: the\n * collision space is the resolver's synthetic anchor parent, so its children\n * have to carry the identity the resolver gives them or the validator would be\n * probing a tree that does not match the one served. The caller keeps its own\n * map back to the real node — the proxy is a matching identity, not a\n * replacement (tree paths still need the directory name).\n */\nexport function interceptorProxy<TFile>(node: SegmentNode<TFile>): SegmentNode<TFile> {\n return { ...node, ...effectiveUrlSegment(node) };\n}\n\nfunction assertAnchorGroupHasNoCollisions(\n group: InterceptorAnchorGroup<RouteFile>,\n ownerPath: string\n): void {\n const { base } = group;\n const owner = ownerPath || '(app root)';\n\n // The space the resolver walks: a synthetic parent sitting at the anchor\n // base, holding every interceptor of this group under its matching identity.\n // `matchUrlParts` starts below this node, so the interceptors' own segments\n // are matched parts here — which is what lets a probe reach across two\n // directories and find the pair that competes.\n const proxies = group.interceptors.map(interceptorProxy);\n const anchorNode: SegmentNode = {\n segmentName: '',\n segmentType: 'static',\n urlPath: base,\n children: proxies,\n slots: {},\n };\n\n const patterns = new Map<string, string>();\n const probeLeaves: ProbeLeaf[] = [];\n\n for (const proxy of proxies) {\n // The proxy's name, not the directory's `interceptedSegmentName`: they are\n // the same string, and this is the one `matchUrlParts` matches on, so the\n // reported pattern and the probed URL cannot describe different segments.\n const pattern = joinInterceptedBase(base, proxy.segmentName);\n walkInterceptedLeaves(proxy, pattern, [proxy], (page, leaf) => {\n // Two leaves whose intercepted pattern is the *same string* claim exactly\n // the same set of URLs — one is ambiguous with the other, or dead. This\n // needs no probe and no reasoning about precedence: identical patterns are\n // identical URL sets by definition. It is the case route groups make easy\n // to write, `(a)/page.tsx` beside `(b)/page.tsx`, and the one the main\n // tree already rejects by comparing urlPath. Across two interceptors it\n // is `(..)photo` beside `(...)photo` under `/feed`, which both base at\n // `/` and both intercept the literal `photo`.\n const duplicate = patterns.get(leaf.interceptedPattern);\n if (duplicate) {\n throw new Error(\n `Build error: route collision between intercepting routes — two pages intercept the same URL.\\n` +\n ` Owner: app/${owner}\\n` +\n ` Intercepted base: ${base}\\n` +\n ` URL: ${leaf.interceptedPattern}\\n` +\n ` File 1: ${duplicate}\\n` +\n ` File 2: ${page.filePath}\\n` +\n `A route group is transparent for matching, so moving a page into one does not ` +\n `give it a URL of its own — these two claim the same one. Rename or move one of ` +\n `them.\\n` +\n `See design/07-routing.md §\"Collisions Among Intercepting Routes\".`\n );\n }\n patterns.set(leaf.interceptedPattern, page.filePath);\n probeLeaves.push({ filePath: page.filePath, chain: leaf.chain });\n });\n }\n\n // Differently-spelled patterns that nonetheless compete: ask the matcher.\n const collision = findOrderDependentCollision(anchorNode, probeLeaves, base);\n if (collision) {\n throw new Error(\n `Build error: route collision between intercepting routes — two pages answer the same URL.\\n` +\n ` Owner: app/${owner}\\n` +\n ` Intercepted base: ${base}\\n` +\n ` URL: ${collision.url}\\n` +\n ` File 1: ${collision.first}\\n` +\n ` File 2: ${collision.second}\\n` +\n `Both match it, so which one renders would be decided by filesystem enumeration ` +\n `order — renaming a route group can flip it. Rename or move one of them.\\n` +\n `Pages are compared by the URLs they match, not by how they are spelled: [id] and ` +\n `[slug] match the same URLs, and an optional catch-all also matches with zero ` +\n `segments.\\n` +\n `Intercepting directories based at *different* URLs may target one page — the ` +\n `resolver tries the deepest first — so this rejects only an ambiguity among the ` +\n `ones based at ${base}.\\n` +\n `See design/07-routing.md §\"Collisions Among Intercepting Routes\".`\n );\n }\n}\n\n/** What the walk knows about the position it is currently standing in. */\ninterface PlacementContext {\n /** `node` is itself a slot node, so its children are direct slot children. */\n parentIsSlot: boolean;\n /** `node` is at or below a slot node. */\n inSlotSubtree: boolean;\n /** `node` is inside an intercepting subtree. */\n inInterceptingSubtree: boolean;\n /** Some segment from the root down to `node`, inclusive, binds a param. */\n ancestorsBindParams: boolean;\n}\n\nfunction walkForPlacement(node: SegmentNode, path: string, ctx: PlacementContext): void {\n for (const child of node.children) {\n const childPath = path ? `${path}/${child.segmentName}` : child.segmentName;\n\n if (child.segmentType === 'intercepting') {\n const marker = child.interceptionMarker ?? '(.)';\n\n if (ctx.inInterceptingSubtree) {\n throw new Error(\n `Build error: intercepting route nested inside another intercepting route.\\n` +\n ` Directory: app/${childPath}\\n` +\n `An intercepting directory (${marker}) resolves against the URL its own parent ` +\n `renders at, and an intercepting subtree has no such URL — nothing walks it, so ` +\n `the rewrite would match the navigation and then have nothing to render.\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n }\n\n // Inside a slot, only a *direct* slot child is reachable: the slot\n // resolver reads `slotNode.children` and stops. The children-path\n // renderer cannot pick it up either — it builds a segment chain, which\n // has no way to express a descent through a slot.\n if (ctx.inSlotSubtree && !ctx.parentIsSlot) {\n throw new Error(\n `Build error: intercepting route inside a parallel slot but not directly under it.\\n` +\n ` Directory: app/${childPath}\\n` +\n `An intercepting directory (${marker}) inside an @slot must be a *direct* child of ` +\n `that slot, e.g. app/feed/@modal/${child.segmentName}/page.tsx. The slot resolver ` +\n `scans the slot's direct children only; elsewhere the rewrite would match the ` +\n `navigation and then have nothing to render.\\n` +\n `See design/07-routing.md §\"Intercepting Routes\".`\n );\n }\n\n // Outside a slot the intercepting page replaces `children` for the\n // owner's own layout chain, so those layouts render against the\n // intercepted URL — which carries no values for params declared above\n // the interception.\n if (!ctx.parentIsSlot && ctx.ancestorsBindParams) {\n assertOwnerChainBindsNoParams(childPath, marker);\n }\n\n if (!ctx.parentIsSlot && !node.layout) {\n assertOwnerHasLayout(path, childPath);\n }\n\n // `node` is the owner — the slot (whose urlPath is the owning segment's,\n // since slots add no URL depth) or the ordinary segment holding the\n // interception. The same input rewrite generation bases from.\n assertInterceptedBaseIsCountable(child, node.urlPath, childPath);\n assertInterceptedCatchAllsAreTerminal(child, childPath);\n }\n\n walkForPlacement(child, childPath, {\n parentIsSlot: false,\n // A slot subtree stays a slot subtree all the way down: the deeper\n // positions are exactly the ones neither renderer reaches.\n inSlotSubtree: ctx.inSlotSubtree,\n inInterceptingSubtree: ctx.inInterceptingSubtree || child.segmentType === 'intercepting',\n ancestorsBindParams: ctx.ancestorsBindParams || !!child.paramName,\n });\n }\n\n // After every child has been recursed into, so a placement error inside any\n // intercepting subtree is reported in preference to what it causes here — a\n // nested interception leaves a node `matchUrlParts` cannot match at all, and\n // the resulting nonsense below it is not what the author needs to be told\n // about. This is per *owner* rather than per intercepting directory because\n // the collision space is the anchor group; see\n // `assertNoInterceptedPatternCollisions`.\n assertNoInterceptedPatternCollisions(node, path);\n\n for (const [slotName, slotNode] of Object.entries(node.slots)) {\n walkForPlacement(slotNode, path ? `${path}/@${slotName}` : `@${slotName}`, {\n parentIsSlot: true,\n inSlotSubtree: true,\n inInterceptingSubtree: ctx.inInterceptingSubtree,\n // A slot-mode interception never binds owner params from the target —\n // the pipeline re-matches the source route, which supplies them — so the\n // rule stops at the slot boundary.\n ancestorsBindParams: false,\n });\n }\n}\n\n/**\n * Recursively walk the segment tree to find intercepting routes.\n *\n * `ancestors` deliberately excludes slot nodes: a slot doesn't appear in a\n * matched route chain, so the last entry is always the nearest chain-visible\n * ancestor — the segment that owns the slot, and therefore the segment whose\n * presence in the source route gates the interception.\n *\n * Intercepting nodes only ever appear as a direct child of a slot or of an\n * ordinary chain segment in a valid tree; `validateInterceptionPlacement`\n * rejects every other placement at scan time, so this walk never has to\n * decide what an unrenderable intercepting node should generate.\n *\n * `parentIsSlot` is what distinguishes the two shapes, and it is the only\n * input that does: the owner, the scope and the intercepted pattern are all\n * computed identically either way.\n */\nfunction walkForInterceptions(\n node: SegmentNode,\n ancestors: SegmentNode[],\n parentIsSlot: boolean,\n rewrites: InterceptionRewrite[]\n): void {\n // Check children\n for (const child of node.children) {\n if (child.segmentType === 'intercepting' && child.interceptionMarker) {\n // Found an intercepting route — collect rewrites from its sub-tree\n collectFromInterceptingNode(child, ancestors, parentIsSlot, rewrites);\n } else {\n walkForInterceptions(child, [...ancestors, child], false, rewrites);\n }\n }\n\n // Check slots (intercepting routes are typically inside slots like @modal)\n for (const slot of Object.values(node.slots)) {\n walkForInterceptions(slot, ancestors, true, rewrites);\n }\n}\n\n/**\n * For an intercepting segment, find all leaf pages in its sub-tree and\n * generate rewrite rules for each.\n */\nfunction collectFromInterceptingNode(\n interceptingNode: SegmentNode,\n ancestors: SegmentNode[],\n parentIsSlot: boolean,\n rewrites: InterceptionRewrite[]\n): void {\n const marker = interceptingNode.interceptionMarker!;\n const segmentName = interceptingNode.interceptedSegmentName!;\n\n // Compute the intercepted URL base based on the marker\n const parentUrlPath = ancestors[ancestors.length - 1].urlPath;\n const interceptedUrlBase = computeInterceptedUrlBase(parentUrlPath, marker, segmentName);\n\n // The scope key and the re-match prefix both describe the same node — the\n // interception's owner — so they are derived here together from one\n // ancestor chain.\n const ancestorPaths = computeSegmentTreePaths(ancestors);\n const interceptingScope = ancestorPaths[ancestorPaths.length - 1];\n\n // Find all leaf pages in the intercepting sub-tree\n const shape: InterceptionShape = parentIsSlot\n ? { mode: 'slot', interceptingPrefix: parentUrlPath, interceptingScope }\n : { mode: 'children', interceptingScope };\n collectLeavesWithRewrites(interceptingNode, interceptedUrlBase, shape, rewrites);\n}\n\n/**\n * Everything about a rewrite except which URL it intercepts — one intercepting\n * directory produces one of these and one rewrite per leaf page beneath it.\n *\n * Written as a union of `Omit`s rather than `Omit` of the union: `Omit` is not\n * distributive, so the latter would silently collapse to the shapes' common\n * fields and drop `interceptingPrefix`.\n */\ntype InterceptionShape =\n | Omit<SlotInterceptionRewrite, 'interceptedPattern'>\n | Omit<ChildrenInterceptionRewrite, 'interceptedPattern'>;\n\n/**\n * Walk an intercepting sub-tree and visit every page-bearing node with the URL\n * pattern it is intercepted at, and URLs that reach it.\n *\n * Route groups are transparent, exactly as they are in the main tree — which\n * is what makes two groups under one interceptor able to claim one URL, and is\n * why the collision validator has to walk the same shape this does.\n *\n * Rewrite generation and that validator are the two callers. They share this\n * walk rather than each having their own so they cannot disagree about which\n * URLs an interceptor claims: a leaf the validator did not see is a rewrite\n * nobody checked, and a leaf only the validator sees is a build error for a\n * route that does not exist. Slots are not descended, here or in either caller\n * — a slot nested inside an intercepting subtree produces no rewrite.\n *\n * That answers the rewrite question only, and the resolution question is\n * answered elsewhere: `validateSlotsInsideInterceptingSubtree`\n * (`collision-spaces.ts`) gives each such slot its own collision space, and\n * `validateSlotPlacement` (`slot-placement.ts`) rejects the ones no renderer\n * reaches. Between them the slots this walk skips are covered; do not conclude\n * from the skip here that they are unvalidated (TIM-1308, TIM-1311).\n *\n * The walk reports the chain of URL-contributing nodes rather than building\n * probe URLs itself: choosing a probe value means running the matcher over the\n * whole subtree, which is the validator's business and not something rewrite\n * generation should be paying for or passing dummy arguments around.\n */\nfunction walkInterceptedLeaves(\n node: SegmentNode,\n interceptedUrlPath: string,\n chain: SegmentNode[],\n visit: (page: NonNullable<SegmentNode['page']>, leaf: InterceptedLeaf) => void\n): void {\n if (node.page) {\n // The page is handed over rather than the node so callers reading it do\n // not need a non-null assertion to say what this branch already proved.\n visit(node.page, { interceptedPattern: interceptedUrlPath, chain });\n }\n\n for (const child of node.children) {\n const isGroup = child.segmentType === 'group';\n walkInterceptedLeaves(\n child,\n isGroup ? interceptedUrlPath : `${interceptedUrlPath}/${child.segmentName}`,\n isGroup ? chain : [...chain, child],\n visit\n );\n }\n}\n\n/** What one page-bearing node in an intercepting subtree claims. */\ninterface InterceptedLeaf {\n /** The URL pattern the rewrite carries — the author's own spelling. */\n interceptedPattern: string;\n /**\n * The nodes from the intercepting directory down to this page that contribute\n * URL parts — route groups excluded, since they are transparent for matching.\n * Empty for the intercepting directory's own page.\n */\n chain: SegmentNode[];\n}\n\n/**\n * Recursively find leaf pages in an intercepting sub-tree and generate\n * rewrite rules for each.\n */\nfunction collectLeavesWithRewrites(\n node: SegmentNode,\n interceptedUrlPath: string,\n shape: InterceptionShape,\n rewrites: InterceptionRewrite[]\n): void {\n walkInterceptedLeaves(node, interceptedUrlPath, [], (_page, leaf) => {\n rewrites.push({ ...shape, interceptedPattern: leaf.interceptedPattern });\n });\n}\n\n/**\n * How many URL levels a marker climbs from the slot owner to reach the\n * intercepted segment, or `'root'` for a marker that climbs all the way.\n *\n * Level counting operates on URL path segments, NOT filesystem directories.\n * Route groups and parallel slots are already excluded from urlPath (they\n * don't add URL depth), so (..) correctly climbs visible segments. This\n * avoids the Vinext bug where path.dirname() on filesystem paths would\n * waste climbs on invisible route groups.\n *\n * Used only by `computeInterceptedBase` below — both rewrite generation and\n * the slot resolver go through that, so the arithmetic exists once.\n */\nfunction interceptionClimb(marker: InterceptionMarker): number | 'root' {\n switch (marker) {\n case '(.)':\n return 0;\n case '(..)':\n return 1;\n case '(..)(..)':\n return 2;\n case '(...)':\n return 'root';\n }\n}\n\n/**\n * Compute the base URL that an intercepting route intercepts, given the\n * parent's URL path and the interception marker.\n *\n * - (.) — same level: parent's URL path\n * - (..) — one level up: parent's parent URL path\n * - (...) — root level: /\n * - (..)(..) — two levels up: parent's grandparent URL path\n *\n * The result is a URL **pattern**, not a URL — `parentUrlPath` carries the\n * directory names, so a dynamic ancestor appears as `/docs/[...path]`.\n * Rewrite generation wants exactly that. The slot resolver imports this to\n * locate the intercepted segment in a concrete target pathname, and must\n * therefore account for a bracket part standing for a different number of\n * URL parts than itself (TIM-1281).\n *\n * Climbing past the root clamps to `/` rather than erroring, so generation\n * and resolution never disagree about what an over-reaching marker\n * intercepts.\n */\n/**\n * The URL pattern an intercepting directory's own page sits at — its\n * `computeInterceptedBase` joined with the segment it intercepts.\n *\n * The root case is why this is a function rather than a template literal at\n * each caller: a base of `/` must not produce `//photo`. Rewrite generation\n * and the collision validator both start their walk from this value, so the\n * two describe the same URLs by construction.\n */\nexport function computeInterceptedUrlBase(\n parentUrlPath: string,\n marker: InterceptionMarker,\n interceptedSegmentName: string\n): string {\n return joinInterceptedBase(computeInterceptedBase(parentUrlPath, marker), interceptedSegmentName);\n}\n\n/**\n * An intercepted base joined with one segment beneath it.\n *\n * The whole content of the \"function rather than a template literal\" rule\n * above: a base of `/` must not produce `//photo`. The collision validator has\n * the base in hand already (it groups by it) and joins through this rather than\n * re-deriving it from an owner path, so both callers spell the root case once.\n */\nexport function joinInterceptedBase(base: string, segmentName: string): string {\n return base === '/' ? `/${segmentName}` : `${base}/${segmentName}`;\n}\n\nexport function computeInterceptedBase(parentUrlPath: string, marker: InterceptionMarker): string {\n const climb = interceptionClimb(marker);\n if (climb === 'root') return '/';\n\n const parts = parentUrlPath.split('/').filter(Boolean);\n for (let i = 0; i < climb; i++) parts.pop();\n return parts.length === 0 ? '/' : `/${parts.join('/')}`;\n}\n","/**\n * Route collision spaces.\n *\n * A collision space is a set of routes that compete for URLs with each other,\n * and there are three: the main tree, each parallel slot, and each intercepting\n * subtree. This module owns the first two; `interception.ts` owns the third.\n * All of them decide order-dependence with the one oracle in\n * `collision-probe.ts`, so they cannot drift on what counts as two routes\n * answering a single URL.\n *\n * See design/07-routing.md §\"Route Collisions\".\n */\n\nimport type { SegmentNode } from './types.js';\nimport { computeInterceptedUrlBase } from './interception.js';\nimport { findOrderDependentCollision, type ProbeLeaf } from './collision-probe.js';\n\n/**\n * Validate that no two pages/routes in one collision space answer the same URL.\n *\n * Two route groups like (auth)/login/page.tsx and (marketing)/login/page.tsx both claim\n * /login — the scanner must detect and reject this at build time.\n *\n * Each parallel slot is validated as its OWN collision space: a slot's pages\n * intentionally share URL paths with the parent tree (that's the point of\n * parallel routes), but two route groups INSIDE one slot claiming the same\n * URL — e.g. @side/(a)/x/page.tsx + @side/(b)/x/page.tsx — still collide.\n */\nexport function validateRouteGroupCollisions(root: SegmentNode): void {\n validateCollisionSpace(root, '', root.urlPath);\n}\n\n/**\n * Validate one collision space — the main tree, or one parallel slot.\n *\n * **Two checks, and the difference between them matters.** Two leaves at the\n * same `urlPath` are decided by string equality, which is exact and needs no\n * probing: `(auth)/login` and `(marketing)/login` claim one set of URLs\n * whatever the precedence rules are, and naming the shared path is the clearest\n * thing to tell the author.\n *\n * Everything else is decided by asking the matcher, through the shared oracle\n * in `collision-probe.ts` (TIM-1308). Comparing `urlPath` spellings misses\n * every pair that matches the same URLs while being *spelled* differently:\n * `x/(a)/[id]` beside `x/(b)/[slug]` are two bare dynamics in one priority\n * tier, and `x/(a)/page.tsx` beside `x/(b)/[[...rest]]` both answer `/x`\n * because an optional catch-all also matches zero parts. Both built before\n * TIM-1308 with filesystem enumeration order deciding which page renders,\n * which is precisely what this validator and `validateAffixedSiblingConflicts`\n * exist to reject.\n *\n * Segment *kinds* stay distinct without any special-casing here, because the\n * oracle inherits `matchNode`'s priority ordering: `x/(a)/[id]` beside\n * `x/(b)/[...rest]` resolves the same way in either `children` order, so it is\n * not reported. So does an affixed sibling against a bare one; the\n * equal-specificity affix tie is `validateAffixedSiblingConflicts`' job, and\n * duplicating it here would double-report.\n */\nfunction validateCollisionSpace(spaceRoot: SegmentNode, segmentPath: string, base: string): void {\n const leaves: ProbeLeaf[] = [];\n collectRoutableLeaves(spaceRoot, new Map(), segmentPath, [], leaves, base);\n\n const collision = findOrderDependentCollision(spaceRoot, leaves, base);\n if (!collision) return;\n\n throw new Error(\n `Build error: route collision — two pages/routes answer the same URL.\\n` +\n ` URL: ${collision.url}\\n` +\n ` File 1: ${collision.first}\\n` +\n ` File 2: ${collision.second}\\n` +\n `Both match it, so which one renders would be decided by filesystem enumeration ` +\n `order — renaming a route group can flip it. Rename or move one of them.\\n` +\n `Routes are compared by the URLs they match, not by how they are spelled: [id] and ` +\n `[slug] match the same URLs, and an optional catch-all also matches with zero ` +\n `segments.`\n );\n}\n\n/**\n * Walk one collision space and collect its routable leaves (page or route\n * files), throwing on an exact `urlPath` collision. Each slot recurses as its\n * OWN space — slots are parallel routes that intentionally share URL paths with\n * their parent tree, but collisions within a single slot are real errors.\n *\n * The early return at an intercepting node drops that subtree's own pages from\n * this space, but not its slots: a slot is its own collision space wherever it\n * sits, so `validateSlotsInsideInterceptingSubtree` picks those up before\n * returning.\n *\n * `chain` accumulates the URL-contributing nodes from the space root down, for\n * the probe oracle. Route groups are excluded because they are transparent for\n * matching, and the space root itself is excluded because `matchUrlParts`\n * matches parts against its *children* — the root consumes nothing.\n */\nfunction collectRoutableLeaves(\n node: SegmentNode,\n seen: Map<string, { filePath: string; segmentPath: string }>,\n segmentPath: string,\n chain: SegmentNode[],\n leaves: ProbeLeaf[],\n base: string\n): void {\n // Intercepting routes are resolved by the interception resolvers, not URL\n // matching, and their computed urlPaths are not addresses — an interception\n // mirrors the canonical route it replaces, so comparing those paths here\n // would reject every correct interception. Skipping is not \"unvalidated\":\n // `assertNoInterceptedPatternCollisions` gives each intercepting subtree its\n // own collision space, keyed by the intercepted pattern rather than by these\n // paths (TIM-1305). See design/07-routing.md §\"Collisions Inside an\n // Intercepting Subtree\" and §\"Why urlPath Stays Parent-Relative Inside an\n // Intercepting Subtree\".\n const currentPath = segmentPath\n ? `${segmentPath}/${node.segmentName}`\n : node.segmentName || '(root)';\n\n // The intercepting subtree's own pages leave this space — but its SLOTS do\n // not leave every space, so they are picked up before returning. See\n // `validateSlotsInsideInterceptingSubtree`.\n if (node.segmentType === 'intercepting') {\n // `node.urlPath` on an intercepting node is its OWNER's path — the input\n // `computeInterceptedUrlBase` wants — because an intercepting segment adds\n // no URL depth.\n validateSlotsInsideInterceptingSubtree(\n node,\n currentPath,\n interceptedBaseOf(node, node.urlPath)\n );\n return;\n }\n\n const routableFile = node.page ?? node.route;\n if (routableFile) {\n const existing = seen.get(node.urlPath);\n if (existing) {\n throw new Error(\n `Build error: route collision — multiple route groups produce a page/route at the same URL path.\\n` +\n ` URL path: ${urlFromChain(base, chain)}\\n` +\n ` File 1: ${existing.filePath} (via ${existing.segmentPath})\\n` +\n ` File 2: ${routableFile.filePath} (via ${currentPath})\\n` +\n `Each URL path must map to exactly one page or route handler. ` +\n `Rename or move one of the conflicting files.`\n );\n }\n seen.set(node.urlPath, { filePath: routableFile.filePath, segmentPath: currentPath });\n leaves.push({ filePath: routableFile.filePath, chain });\n }\n\n // Recurse into children. A route group contributes no URL part, so it is\n // absent from the chain — exactly as `collectEffectiveChildren` flattens it\n // away in the matcher.\n for (const child of node.children) {\n const isGroup = child.segmentType === 'group';\n collectRoutableLeaves(\n child,\n seen,\n currentPath,\n isGroup ? chain : [...chain, child],\n leaves,\n base\n );\n }\n\n // Recurse into slots — each slot is its own collision space, with its own\n // seen map, its own leaf set and its own probe run.\n //\n // The base is accumulated from this space's own base rather than read off\n // `slotNode.urlPath`, because this walk also runs on slot spaces nested inside\n // an intercepting subtree, where `urlPath` is parent-relative and not an\n // address. Outside one the two are identical by construction.\n for (const slotNode of Object.values(node.slots)) {\n validateCollisionSpace(slotNode, currentPath, urlFromChain(base, chain));\n }\n}\n\n/**\n * Validate every parallel slot nested anywhere inside an intercepting subtree.\n *\n * Two walks each skip these slots for their own good reason, and together they\n * left them checked by nothing: `collectRoutableLeaves` returns at the\n * intercepting node before it reaches them, and `walkInterceptedLeaves`\n * deliberately does not descend slots — correct for rewrite generation, since a\n * slot inside an intercepting subtree produces no rewrite. But \"produces no\n * rewrite\" answers the rewrite question and not the resolution one, so\n * `@side/(a)/x/page.tsx` beside `@side/(b)/x/page.tsx` under an interceptor\n * built with filesystem order picking the page — the ordinary per-slot\n * collision that fails the build anywhere else in the tree (codex, on PR #1002).\n *\n * A slot is its own collision space wherever it sits, so each one is validated\n * as one.\n *\n * **Which interception shape this still applies to.** TIM-1311 answered the\n * question this was written under — whether such a slot renders at all — and\n * the answer is per-shape:\n *\n * - **Children path** (`(browse)/(...)photo/@side`): the intercepting node\n * joins the main route chain, so `route-element-builder.ts` resolves slots on\n * it and below it like any other chain segment. They render, and this is the\n * space where the check is load-bearing.\n * - **Modal** (`feed/@modal/(.)photo/@side`): the slot sits inside another\n * slot's subtree, which no renderer descends for slots — so it never renders,\n * and `validateSlotPlacement` now rejects the placement before this runs.\n * That rule subsumes this one for the modal shape rather than conflicting\n * with it, exactly as anticipated.\n *\n * So this walk is reached only for children-path interceptors in a valid tree.\n * It is not narrowed to them: the rule it states — a slot is its own collision\n * space wherever it sits — is shape-independent, and making it conditional on a\n * property the placement validator already guarantees would just be a second\n * place for the two to disagree.\n *\n * The walk covers the whole subtree, not just the interceptor's direct slot\n * children: `(...)photo/[id]/@side` is reached by neither walk for exactly the\n * same reason as `(...)photo/@side`.\n */\nfunction validateSlotsInsideInterceptingSubtree(\n node: SegmentNode,\n segmentPath: string,\n base: string\n): void {\n for (const slotNode of Object.values(node.slots)) {\n // A slot adds no URL depth, so it answers its owner's base.\n validateCollisionSpace(slotNode, segmentPath, base);\n }\n for (const child of node.children) {\n validateSlotsInsideInterceptingSubtree(\n child,\n `${segmentPath}/${child.segmentName}`,\n childInterceptedBase(child, base)\n );\n }\n}\n\n/**\n * The URL a leaf answers, built from its space's base and its own chain.\n *\n * Read instead of `node.urlPath` because `urlPath` inside an intercepting\n * subtree is parent-relative and is not an address — the collision URL has to\n * be one the author can actually find. Outside an intercepting subtree the two\n * are identical by construction: the base is the space root's `urlPath` and the\n * chain is every URL-contributing segment below it.\n */\nfunction urlFromChain(base: string, chain: SegmentNode[]): string {\n if (chain.length === 0) return base || '/';\n const tail = chain.map((n) => n.segmentName).join('/');\n return `${base === '/' ? '' : base}/${tail}`;\n}\n\n/**\n * The intercepted URL an intercepting directory's own page sits at.\n *\n * `urlPath` inside an intercepting subtree is deliberately parent-relative and\n * is **not** an address (see design/07-routing.md §\"Why urlPath Stays\n * Parent-Relative Inside an Intercepting Subtree\"), so a collision reported\n * from one names a URL the author cannot find. The intercepted base is the real\n * address, and it is what rewrite generation and the interception collision\n * validator both already use.\n */\nfunction interceptedBaseOf(node: SegmentNode, ownerUrlPath: string): string {\n return computeInterceptedUrlBase(\n ownerUrlPath,\n node.interceptionMarker ?? '(.)',\n node.interceptedSegmentName ?? node.segmentName\n );\n}\n\n/**\n * Extend an intercepted base by one child segment.\n *\n * Route groups are transparent and contribute nothing. A nested intercepting\n * node re-bases from its own marker rather than appending — that tree is\n * rejected by `validateInterceptionPlacement`, but collision validation runs\n * first, so it still has to produce a sensible URL rather than one containing a\n * literal \"(.)b\".\n */\nfunction childInterceptedBase(child: SegmentNode, base: string): string {\n // Slots are not in `children` — `scanChildren` files them under `slots` — so\n // only groups are transparent here.\n if (child.segmentType === 'group') return base;\n if (child.segmentType === 'intercepting') return interceptedBaseOf(child, base);\n return base === '/' ? `/${child.segmentName}` : `${base}/${child.segmentName}`;\n}\n","/**\n * Parallel slot placement.\n *\n * One rule: a slot is resolved only for a segment on the **matched route\n * chain**, and a slot's own subtree is never on that chain. So a slot declared\n * anywhere inside another slot's subtree can never render, and is rejected at\n * build time rather than left as a directory the author will keep editing.\n *\n * See design/07-routing.md §\"Parallel Routes\".\n */\n\nimport type { SegmentNode } from './types.js';\n\n/**\n * Reject every parallel slot that no renderer reaches.\n *\n * **Where slots are resolved.** Two places read `segment.slots`, and both walk\n * the main route chain: `route-element-builder.ts` (the RSC render) and\n * `tree-builder.ts`. Neither is reachable from inside a slot. The slot's own\n * subtree is rendered by `slot-resolver.ts`, which walks the slot's matched\n * chain to apply that chain's layouts, error boundaries and access gates\n * (`wrapWithIntermediateSegments`, `wrapWithLayout`) and never reads `.slots`\n * on any of those nodes. So `app/feed/@modal/photo/@side/page.tsx` and\n * everything below it is dead: the file is scanned, typed, code-split and\n * shipped, and no request can render it.\n *\n * That is the TIM-1278 failure — a directory that silently never renders —\n * and the reason it is a build error rather than a documented limit is that\n * nothing at request time can report it. A slot that does not match renders\n * `default.tsx` or `null`, which is exactly what a slot the resolver never\n * looked at also produces, so the author sees the *designed* behaviour of a\n * non-matching slot and has no signal to distinguish it from a slot that\n * cannot match at all.\n *\n * **Interception is incidental.** TIM-1311 arrived as\n * `feed/@modal/(.)photo/@side`, and the interception contributes nothing: the\n * identical `feed/@modal/photo/@side` never renders either, for the same\n * reason and with no marker anywhere. Rejecting only the intercepting spelling\n * would have drawn a line the author cannot see from the directory names.\n *\n * The children-path interception shape is **not** affected and must not be:\n * its intercepting node joins the main chain (`server/children-interception.ts`\n * splices `[…owner ancestors, interceptingNode, …descendants]` into an ordinary\n * `RouteMatch`), so `route-element-builder.ts` resolves slots on it and below\n * it exactly as it does for any other chain segment. `(browse)/(...)photo/[id]/@side`\n * renders; `feed/@modal/(.)photo/@side` does not. The discriminator is the slot\n * boundary, which is what this walk tracks — not the marker.\n */\nexport function validateSlotPlacement(root: SegmentNode): void {\n walkForSlotPlacement(root, '', null);\n}\n\n/**\n * `enclosingSlotPath` is the `app/`-relative path of the nearest slot at or\n * above `node`, or null on the main chain. It is carried rather than recomputed\n * so the error can name the slot that swallows the offender — \"this is inside\n * @modal\" is the part of the diagnosis the author cannot see from the offending\n * path alone.\n */\nfunction walkForSlotPlacement(\n node: SegmentNode,\n path: string,\n enclosingSlotPath: string | null\n): void {\n for (const [slotName, slotNode] of Object.entries(node.slots)) {\n const slotPath = path ? `${path}/@${slotName}` : `@${slotName}`;\n if (enclosingSlotPath !== null) {\n throwNestedSlot(slotPath, enclosingSlotPath);\n }\n walkForSlotPlacement(slotNode, slotPath, slotPath);\n }\n\n for (const child of node.children) {\n walkForSlotPlacement(\n child,\n path ? `${path}/${child.segmentName}` : child.segmentName,\n enclosingSlotPath\n );\n }\n}\n\nfunction throwNestedSlot(slotPath: string, enclosingSlotPath: string): never {\n throw new Error(\n `Build error: parallel slot nested inside another parallel slot.\\n` +\n ` Directory: app/${slotPath}\\n` +\n ` Inside: app/${enclosingSlotPath}\\n` +\n `A parallel slot is resolved only for a segment on the matched route chain, and a ` +\n `slot's own subtree is never on that chain — the slot resolver walks the slot's ` +\n `matched chain to apply its layouts, error boundaries and access gates, and never ` +\n `looks at slots declared inside it. So app/${slotPath} and everything below it can ` +\n `never render, and no request-time signal can tell you: an unreachable slot ` +\n `produces exactly what a slot that simply did not match produces.\\n` +\n `Declare the slot on a segment of the main route chain instead, or move its pages ` +\n `into app/${enclosingSlotPath}'s own subtree.\\n` +\n `See design/07-routing.md §\"Parallel Routes\".`\n );\n}\n","/**\n * Route discovery scanner.\n *\n * Pure function: (appDir, config) → RouteTree\n *\n * Scans the app/ directory and builds a segment tree recognizing all\n * timber.js file conventions. Does NOT handle request matching — this\n * is discovery only.\n */\n\nimport { readdirSync, statSync } from 'node:fs';\nimport { join, extname, basename } from 'node:path';\nimport type {\n RouteTree,\n SegmentNode,\n SegmentType,\n RouteFile,\n ScannerConfig,\n InterceptionMarker,\n} from './types.js';\nimport { classifySegment, effectiveUrlSegment } from './segment-classify.js';\nimport { validateInterceptionPlacement, computeInterceptedBase } from './interception.js';\nimport { validateRouteGroupCollisions } from './collision-spaces.js';\nimport { validateSlotPlacement } from './slot-placement.js';\nimport { DEFAULT_PAGE_EXTENSIONS } from './types.js';\nimport { classifyMetadataRoute, isDynamicMetadataExtension } from '../server/metadata-routes.js';\nimport { swallow } from '../server/logger.js';\nimport { ENCODED_SEPARATOR_RE, NULL_BYTE_RE } from '../server/canonicalize.js';\n\n/**\n * File convention names that use pageExtensions (can be .tsx, .ts, .jsx, .js, .mdx, etc.)\n */\nconst PAGE_EXT_CONVENTIONS = new Set(['page', 'layout', 'error', 'default', 'denied']);\n\n/**\n * File convention names that are always .ts/.tsx (never .mdx etc.)\n */\nconst FIXED_CONVENTIONS = new Set(['middleware', 'access', 'route']);\n\n/**\n * Status-code file patterns:\n * - Exact 3-digit codes: 401.tsx, 429.tsx, 503.tsx\n * - Category catch-alls: 4xx.tsx, 5xx.tsx\n */\nconst STATUS_CODE_PATTERN = /^(\\d{3}|[45]xx)$/;\n\n/**\n * Scan the app/ directory and build the route tree.\n *\n * @param appDir - Absolute path to the app/ directory\n * @param config - Scanner configuration\n * @returns The complete route tree\n */\nexport function scanRoutes(appDir: string, config: ScannerConfig = {}): RouteTree {\n const pageExtensions = config.pageExtensions ?? DEFAULT_PAGE_EXTENSIONS;\n const extSet = new Set(pageExtensions);\n\n const tree: RouteTree = {\n root: createSegmentNode('', 'static', '/'),\n };\n\n // Check for proxy.ts at app root\n const proxyFile = findFixedFile(appDir, 'proxy');\n if (proxyFile) {\n tree.proxy = proxyFile;\n }\n\n // Check for global-error.{tsx,ts,jsx,js} at app root.\n // Tier 2 error page — renders standalone (no layouts) when no segment-level\n // error file is found. See design/10-error-handling.md §\"Tier 2\".\n const globalErrorFile = findPageExtFile(appDir, 'global-error', extSet);\n if (globalErrorFile) {\n tree.globalError = globalErrorFile;\n }\n\n // Scan the root directory's files\n scanSegmentFiles(appDir, tree.root, extSet);\n\n // Scan children recursively\n scanChildren(appDir, tree.root, extSet);\n\n // Validate: every parallel slot sits where a renderer reaches it. First,\n // because a slot nested inside another slot never renders, and a collision\n // reported from inside one would send the author to fix an ambiguity between\n // two pages that were both already dead.\n validateSlotPlacement(tree.root);\n\n // Validate: detect route group collisions (different groups producing pages at the same URL)\n validateRouteGroupCollisions(tree.root);\n\n // Validate: detect duplicate param names in nested dynamic segments\n // e.g., /[id]/items/[id] — same param name in ancestor and descendant\n validateDuplicateParamNames(tree.root);\n\n // Validate: detect same param name used with different bracket forms\n // e.g., [id] in one route and [...id] in another\n validateUniqueBracketForms(tree.root);\n\n // Validate: detect affixed dynamic siblings with equal specificity\n // e.g., a-[id] and [slug]-b both have prefix+suffix length = 2\n validateAffixedSiblingConflicts(tree.root);\n\n // Validate: intercepting routes must be direct children of a parallel slot —\n // the slot resolver is the only thing that can render one.\n validateInterceptionPlacement(tree.root);\n\n return tree;\n}\n\n/**\n * Create an empty segment node.\n */\nfunction createSegmentNode(\n segmentName: string,\n segmentType: SegmentType,\n urlPath: string,\n paramName?: string,\n interceptionMarker?: InterceptionMarker,\n interceptedSegmentName?: string,\n paramPrefix?: string,\n paramSuffix?: string\n): SegmentNode {\n return {\n segmentName,\n segmentType,\n urlPath,\n paramName,\n paramPrefix,\n paramSuffix,\n interceptionMarker,\n interceptedSegmentName,\n children: [],\n slots: {},\n };\n}\n\n/**\n * Compute the URL path for a child segment given its parent's URL path.\n * Route groups, slots, and intercepting routes do NOT add URL depth.\n */\nfunction computeUrlPath(parentUrlPath: string, dirName: string, segmentType: SegmentType): string {\n // Groups, slots, and intercepting routes don't add to URL path\n if (segmentType === 'group' || segmentType === 'slot' || segmentType === 'intercepting') {\n return parentUrlPath;\n }\n\n const parentPath = parentUrlPath === '/' ? '' : parentUrlPath;\n return `${parentPath}/${dirName}`;\n}\n\n/**\n * Scan a directory for file conventions and populate the segment node.\n */\nfunction scanSegmentFiles(dirPath: string, node: SegmentNode, extSet: Set<string>): void {\n let entries: string[];\n try {\n entries = readdirSync(dirPath);\n } catch (err) {\n swallow(err, `scanSegmentFiles: unreadable directory ${dirPath}`, { level: 'warn' });\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dirPath, entry);\n\n // Skip directories — handled by scanChildren\n try {\n if (statSync(fullPath).isDirectory()) continue;\n } catch {\n continue;\n }\n\n const ext = extname(entry).slice(1); // remove leading dot\n const name = basename(entry, `.${ext}`);\n\n // Page-extension conventions (page, layout, error, default, denied)\n if (PAGE_EXT_CONVENTIONS.has(name) && extSet.has(ext)) {\n const key = name as 'page' | 'layout' | 'error' | 'default' | 'denied';\n const existing = node[key];\n if (existing) {\n throwDuplicateConvention(name, existing.filePath, fullPath);\n }\n node[key] = { filePath: fullPath, extension: ext };\n continue;\n }\n\n // Fixed conventions (middleware, access, route) — only\n // .ts/.tsx/.js/.jsx, never pageExtensions like .mdx. The regex is\n // anchored: mts/cts/mjs/cjs (and stray tail matches like `.foots`)\n // are NOT recognized. See design/07-routing.md §\"Page Extensions\".\n if (FIXED_CONVENTIONS.has(name) && /^[jt]sx?$/.test(ext)) {\n const key = name as 'middleware' | 'access' | 'route';\n const existing = node[key];\n if (existing) {\n throwDuplicateConvention(name, existing.filePath, fullPath);\n }\n node[key] = { filePath: fullPath, extension: ext };\n continue;\n }\n\n // JSON status-code files (401.json, 4xx.json, 503.json, 5xx.json)\n // Recognized regardless of pageExtensions — .json is a data format, not a page extension.\n if (STATUS_CODE_PATTERN.test(name) && ext === 'json') {\n if (!node.jsonStatusFiles) {\n node.jsonStatusFiles = {};\n }\n node.jsonStatusFiles[name] = { filePath: fullPath, extension: ext };\n continue;\n }\n\n // Status-code files (401.tsx, 4xx.tsx, 503.tsx, 5xx.tsx)\n if (STATUS_CODE_PATTERN.test(name) && extSet.has(ext)) {\n if (!node.statusFiles) {\n node.statusFiles = {};\n }\n const existing = node.statusFiles[name];\n if (existing) {\n throwDuplicateConvention(name, existing.filePath, fullPath);\n }\n node.statusFiles[name] = { filePath: fullPath, extension: ext };\n continue;\n }\n\n // Metadata route files (sitemap.ts, robots.ts, icon.tsx, opengraph-image.tsx, etc.)\n // Both static (.xml, .txt, .png, .ico, etc.) and dynamic (.ts, .tsx) files are recognized.\n // When both exist for the same base name, dynamic takes precedence.\n // Two files of the SAME kind (static+static or dynamic+dynamic) are a\n // build error — picking one by readdir order is platform-dependent.\n // See design/16-metadata.md §\"Metadata Routes\"\n const metaInfo = classifyMetadataRoute(entry);\n if (metaInfo) {\n if (!metaInfo.nestable && node.segmentName !== '') {\n throw new Error(\n `Build error: '${name}' is a root-only metadata convention and must be in the app root directory.\\n` +\n ` File: ${fullPath}\\n` +\n ` Move this file to the app root (not a route group or nested segment).`\n );\n }\n if (!node.metadataRoutes) {\n node.metadataRoutes = {};\n }\n const existing = node.metadataRoutes[name];\n if (existing) {\n const existingIsDynamic = isDynamicMetadataExtension(name, existing.extension);\n const newIsDynamic = isDynamicMetadataExtension(name, ext);\n if (existingIsDynamic === newIsDynamic) {\n throwDuplicateConvention(name, existing.filePath, fullPath);\n }\n // Dynamic > static precedence: overwrite only when the new file is dynamic.\n if (newIsDynamic) {\n node.metadataRoutes[name] = { filePath: fullPath, extension: ext };\n }\n } else {\n node.metadataRoutes[name] = { filePath: fullPath, extension: ext };\n }\n }\n }\n\n // Validate: route.ts + page.* is a hard build error\n if (node.route && node.page) {\n throw new Error(\n `Build error: route.ts and page.* cannot coexist in the same segment.\\n` +\n ` route.ts: ${node.route.filePath}\\n` +\n ` page: ${node.page.filePath}\\n` +\n `A URL is either an API endpoint or a rendered page, not both.`\n );\n }\n}\n\n/**\n * Throw a build error for two files claiming the same convention slot in\n * one segment (e.g. page.tsx + page.jsx). Which file readdir returns first\n * is platform-dependent (APFS sorts entries, ext4 does not) — silently\n * picking one would let macOS dev and Linux CI serve different\n * implementations of the same route.\n */\nfunction throwDuplicateConvention(\n convention: string,\n firstPath: string,\n secondPath: string\n): never {\n throw new Error(\n `Build error: duplicate '${convention}' files in the same route segment.\\n` +\n ` File 1: ${firstPath}\\n` +\n ` File 2: ${secondPath}\\n` +\n `Each segment may define '${convention}' at most once. Remove one of the files.`\n );\n}\n\n/**\n * Recursively scan child directories and build the segment tree.\n */\nfunction scanChildren(dirPath: string, parentNode: SegmentNode, extSet: Set<string>): void {\n let entries: string[];\n try {\n entries = readdirSync(dirPath);\n } catch (err) {\n swallow(err, `scanChildren: unreadable directory ${dirPath}`, { level: 'warn' });\n return;\n }\n\n for (const entry of entries) {\n const fullPath = join(dirPath, entry);\n\n try {\n if (!statSync(fullPath).isDirectory()) continue;\n } catch {\n continue;\n }\n\n // Reject directories with encoded path delimiters or null bytes.\n // These can cause route collisions when decoded at the URL boundary.\n // See design/13-security.md §\"Encoded separators rejected\" and §\"Null bytes rejected\".\n if (ENCODED_SEPARATOR_RE.test(entry)) {\n throw new Error(\n `Build error: directory name contains an encoded path delimiter (%2F or %5C).\\n` +\n ` Directory: ${fullPath}\\n` +\n `Encoded separators in directory names cause route collisions when decoded. ` +\n `Rename the directory to remove the encoded delimiter.`\n );\n }\n if (NULL_BYTE_RE.test(entry)) {\n throw new Error(\n `Build error: directory name contains an encoded null byte (%00).\\n` +\n ` Directory: ${fullPath}\\n` +\n `Encoded null bytes in directory names are not allowed. ` +\n `Rename the directory to remove the null byte encoding.`\n );\n }\n\n const {\n type,\n paramName,\n paramPrefix,\n paramSuffix,\n interceptionMarker,\n interceptedSegmentName,\n } = classifySegment(entry);\n\n // Skip private folders — underscore-prefixed dirs are excluded from routing\n if (type === 'private') continue;\n\n const urlPath = computeUrlPath(parentNode.urlPath, entry, type);\n const childNode = createSegmentNode(\n entry,\n type,\n urlPath,\n paramName,\n interceptionMarker,\n interceptedSegmentName,\n paramPrefix,\n paramSuffix\n );\n\n // Scan this segment's files\n scanSegmentFiles(fullPath, childNode, extSet);\n\n // Recurse into subdirectories\n scanChildren(fullPath, childNode, extSet);\n\n // Attach to parent: slots go into slots record, everything else is a child\n if (type === 'slot') {\n const slotName = entry.slice(1); // remove @\n parentNode.slots[slotName] = childNode;\n } else {\n parentNode.children.push(childNode);\n }\n }\n}\n\n/**\n * Validate that no route chain contains duplicate dynamic param names.\n *\n * Example violation:\n * app/[id]/items/[id]/page.tsx — 'id' appears twice in the ancestor chain.\n *\n * Route groups are transparent — params accumulate through them.\n * Slots are independent — duplicate detection does NOT cross slot boundaries.\n *\n * See design/07-routing.md §\"Duplicate Param Name Detection\"\n */\nfunction validateDuplicateParamNames(root: SegmentNode): void {\n walkForDuplicateParams(root, new Map());\n}\n\n/**\n * Recursively walk the segment tree, tracking seen param names → segment paths.\n * Throws on the first duplicate found.\n */\nfunction walkForDuplicateParams(node: SegmentNode, seen: Map<string, string>): void {\n // Read through the effective identity so an intercepting directory is seen\n // as the segment it intercepts: the scanner leaves `paramName` unset on\n // `(.)[id]`, so a validator reading the node directly is blind to a param\n // the resolver goes on to bind — `@modal/(.)[id]/[id]` would pass here and\n // then silently overwrite the outer `id` at match time, where the ordinary\n // `/[id]/[id]` is rejected. See TIM-1288.\n const { paramName } = effectiveUrlSegment(node);\n\n // If this node introduces a param name, check for duplicates\n if (paramName) {\n const existing = seen.get(paramName);\n if (existing) {\n throw new Error(\n `[timber] Duplicate param name '${paramName}' in route chain.\\n` +\n ` First defined at: ${existing}\\n` +\n ` Duplicate at: ${node.urlPath || '/'}\\n` +\n ` Rename one of the segments to avoid ambiguity.`\n );\n }\n // Add to seen for descendants (use a new Map to avoid polluting siblings)\n seen = new Map(seen);\n seen.set(paramName, node.urlPath || '/');\n }\n\n // Recurse into children (they inherit the accumulated params)\n for (const child of node.children) {\n walkForDuplicateParams(child, seen);\n }\n\n // A slot INHERITS the ancestor params rather than starting fresh: a slot\n // child may not reuse a name its owner already bound\n // (`app/gallery/[id]/@modal/[id]` is rejected). The copy is so sibling\n // slots don't see each other's names, not so the chain is reset.\n //\n // Whether that rule is right is a separate question — slot params are\n // merged over the main route's at read time, so a collision is defined\n // rather than ambiguous — but changing it would change every slot.\n // Tracked as TIM-1287; do not \"fix\" this by making the map fresh without\n // deciding that.\n for (const slotNode of Object.values(node.slots)) {\n walkForDuplicateParams(slotNode, new Map(seen));\n }\n}\n\n/**\n * Validate that each param name uses a single bracket form across the entire route tree.\n *\n * Different bracket forms produce different types:\n * [id] → string\n * [...id] → string[]\n * [[...id]] → string[] | undefined\n *\n * If the same param name appears with multiple forms, the no-argument\n * getSegmentParams() / useSegmentParams() return type becomes ambiguous.\n *\n * Same name + same form across different routes is fine and expected.\n */\nfunction validateUniqueBracketForms(root: SegmentNode): void {\n const forms = new Map<string, { segmentType: SegmentType; urlPath: string }>();\n collectBracketForms(root, forms);\n}\n\nfunction collectBracketForms(\n node: SegmentNode,\n forms: Map<string, { segmentType: SegmentType; urlPath: string }>\n): void {\n // Effective identity, so `(.)[...rest]` is compared as the catch-all it\n // intercepts rather than skipped as an 'intercepting' node (TIM-1288).\n const { paramName, segmentType } = effectiveUrlSegment(node);\n\n if (paramName && segmentType !== 'static' && segmentType !== 'group') {\n const existing = forms.get(paramName);\n if (existing && existing.segmentType !== segmentType) {\n const bracketExamples: Record<string, string> = {\n 'dynamic': `[${paramName}]`,\n 'catch-all': `[...${paramName}]`,\n 'optional-catch-all': `[[...${paramName}]]`,\n };\n throw new Error(\n `[timber] Param name '${paramName}' uses multiple bracket forms.\\n` +\n ` ${bracketExamples[existing.segmentType] ?? existing.segmentType} at: ${existing.urlPath}\\n` +\n ` ${bracketExamples[segmentType] ?? segmentType} at: ${node.urlPath || '/'}\\n` +\n ` Each param name must use a single bracket form across all routes.\\n` +\n ` Rename one of the segments to fix this (e.g., [${paramName}] → [${paramName}Id]).`\n );\n }\n if (!existing) {\n forms.set(paramName, {\n segmentType,\n urlPath: node.urlPath || '/',\n });\n }\n }\n\n for (const child of node.children) {\n collectBracketForms(child, forms);\n }\n for (const slotNode of Object.values(node.slots)) {\n collectBracketForms(slotNode, forms);\n }\n}\n\n/**\n * Validate that no sibling affixed dynamic segments have equal specificity.\n *\n * Among affixed siblings, longer combined prefix+suffix length wins. When two\n * siblings tie (same total affix length), the router would fall back to\n * filesystem scan order — which is platform-dependent. This is a build error.\n *\n * Route groups are URL-transparent, so affixed segments inside different groups\n * at the same level still conflict with each other.\n *\n * Ambiguity requires the two segments to be candidates for the *same* URL\n * part, which is narrower than \"same parent\" once interception is involved:\n *\n * - Plain children and intercepting children never compete. They are resolved\n * by different walks — `findSlotMatch` matches the slot subtree (where\n * `tree-match.ts` ignores intercepting nodes outright) and\n * `findInterceptingMatch` builds a synthetic parent holding only\n * interceptors.\n * - Two interceptors compete only at the same anchor. `(.)a-[id]` and\n * `(..)[slug]-b` in one slot are based at different URL depths, so no\n * pathname reaches both, and `anchorIndex` rejects the one whose base does\n * not match the target. Grouping them together would fail the build for a\n * pair that can never be ambiguous.\n *\n * So candidates are keyed by the position they contend for, then by affix\n * length. See design/07-routing.md §\"Priority\" and §\"Intercepting Routes\".\n */\nfunction validateAffixedSiblingConflicts(node: SegmentNode): void {\n const affixed = collectEffectiveAffixed(node);\n\n if (affixed.length >= 2) {\n const byLength = new Map<string, SegmentNode[]>();\n for (const child of affixed) {\n // `\\0` as the separator, written as the escape rather than a literal\n // byte: a raw NUL in the source makes git and grep treat this file as\n // binary. A contention key is a URL path, which cannot contain one, so\n // the two halves of the key can never run together.\n const key = `${contentionKey(node, child)}\\0${affixLengthOf(child)}`;\n const group = byLength.get(key);\n if (group) {\n group.push(child);\n } else {\n byLength.set(key, [child]);\n }\n }\n\n for (const [, group] of byLength) {\n if (group.length >= 2) {\n throw new Error(\n `Build error: ambiguous affixed dynamic siblings with equal specificity.\\n` +\n ` Parent: ${node.urlPath || '/'}\\n` +\n ` Segments: ${group.map((s) => s.segmentName).join(', ')}\\n` +\n ` Combined prefix+suffix length: ${affixLengthOf(group[0]!)}\\n` +\n `The router cannot deterministically choose between these — filesystem scan order is platform-dependent.\\n` +\n `Rename one segment to give it a longer or shorter combined affix.`\n );\n }\n }\n }\n\n for (const child of node.children) {\n validateAffixedSiblingConflicts(child);\n }\n for (const slotNode of Object.values(node.slots)) {\n validateAffixedSiblingConflicts(slotNode);\n }\n}\n\n/**\n * The URL position a child contends for, as a comparable key.\n *\n * Plain children contend for the parent's next part. An intercepting child\n * contends for a part determined by its marker's intercepted base, so two\n * markers of different depth are simply different positions — and two markers\n * that compute the *same* base do contend, which is why the key is the base\n * rather than the marker (`(..)` and `(...)` under `/feed` both base at `/`).\n *\n * `groupByInterceptedAnchor` (`routing/interception.ts`) is the canonical\n * statement of that grouping — it is what the resolver walks and what the\n * collision validator checks. This computes the same key from the same\n * `computeInterceptedBase` rather than calling it, because affix ambiguity is\n * decided per *child* and `collectEffectiveAffixed` looks through route groups,\n * so the two do not partition the same set of nodes.\n */\nfunction contentionKey(parent: SegmentNode, child: SegmentNode): string {\n if (child.segmentType !== 'intercepting') return 'child';\n return `intercept:${computeInterceptedBase(parent.urlPath, child.interceptionMarker ?? '(.)')}`;\n}\n\n/** Combined affix length of a node, read through its effective identity. */\nfunction affixLengthOf(node: SegmentNode): number {\n const { paramPrefix, paramSuffix } = effectiveUrlSegment(node);\n return (paramPrefix?.length ?? 0) + (paramSuffix?.length ?? 0);\n}\n\n/**\n * Collect affixed dynamic segments that are effective children of a node.\n * Route groups are URL-transparent, so we look through them recursively.\n *\n * Segments are read through `effectiveUrlSegment`, so an intercepting\n * directory counts as the affixed segment it intercepts: `(.)a-[id]` is\n * `a-[id]`. The proxy the slot resolver builds hands those affixes to\n * `matchUrlParts`, whose equal-length sort is not stable across equal\n * specificity — so two intercepting siblings with the same combined affix\n * length would resolve by filesystem enumeration order, which is precisely\n * what this validator exists to prevent for ordinary siblings (TIM-1288).\n */\nfunction collectEffectiveAffixed(node: SegmentNode): SegmentNode[] {\n const result: SegmentNode[] = [];\n for (const child of node.children) {\n const { segmentType, paramPrefix, paramSuffix } = effectiveUrlSegment(child);\n if (segmentType === 'dynamic' && (paramPrefix || paramSuffix)) {\n result.push(child);\n } else if (segmentType === 'group') {\n result.push(...collectEffectiveAffixed(child));\n }\n }\n return result;\n}\n\n/**\n * Find a fixed-extension file (proxy.ts) in a directory.\n */\nfunction findFixedFile(dirPath: string, name: string): RouteFile | undefined {\n for (const ext of ['ts', 'tsx']) {\n const fullPath = join(dirPath, `${name}.${ext}`);\n try {\n if (statSync(fullPath).isFile()) {\n return { filePath: fullPath, extension: ext };\n }\n } catch {\n // File doesn't exist\n }\n }\n return undefined;\n}\n\n/**\n * Find a file using the configured page extensions (tsx, ts, jsx, js, mdx, etc.).\n * Used for app-root conventions like global-error that aren't per-segment.\n */\nfunction findPageExtFile(\n dirPath: string,\n name: string,\n extSet: Set<string>\n): RouteFile | undefined {\n for (const ext of extSet) {\n const fullPath = join(dirPath, `${name}.${ext}`);\n try {\n if (statSync(fullPath).isFile()) {\n return { filePath: fullPath, extension: ext };\n }\n } catch {\n // File doesn't exist\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,cACd,MACA,OACA,SAC+B;CAC/B,MAAM,QAA8B,CAAC;CACrC,MAAM,SAA4C,CAAC;CAGnD,IAAI,UAAU,MAAM,OAAO,GAAG,OAAO,QAFb,SAAS,mBAAmB,IAEQ,GAC1D,OAAO;EAAE;EAAO;CAAO;CAEzB,OAAO;AACT;;;;;;;;;AAsBA,SAAS,yBACP,MACA,aAAmC,CAAC,GACX;CACzB,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,SAAS,KAAK,UACvB,IAAI,MAAM,gBAAgB,SAAS;EACjC,MAAM,SAAS,yBAAyB,OAAO,CAAC,GAAG,YAAY,KAAK,CAAC;EACrE,OAAO,KAAK,GAAG,MAAM;CACvB,OACE,OAAO,KAAK;EAAE;EAAO;CAAW,CAAC;CAGrC,OAAO;AACT;;AAGA,SAAS,WAAkB,MAAmC;CAC5D,OAAO,CAAC,EAAE,KAAK,QAAQ,KAAK;AAC9B;;AAGA,SAAS,YAAmB,MAAkC;CAC5D,QAAQ,KAAK,aAAa,UAAU,MAAM,KAAK,aAAa,UAAU;AACxE;;;;;;;AAQA,SAAS,UACP,MACA,OACA,OACA,OACA,QACA,iBACS;CACT,MAAM,KAAK,IAAI;CAGf,IAAI,SAAS,MAAM,QAAQ;EACzB,IAAI,CAAC,mBAAmB,WAAW,IAAI,GAAG,OAAO;EAIjD,KAAK,MAAM,SAAS,KAAK,UACvB,IAAI,MAAM,gBAAgB;OACpB,UAAU,OAAO,OAAO,OAAO,OAAO,QAAQ,eAAe,GAC/D,OAAO;EAAA;EAQb,MAAM,YAAY,yBAAyB,IAAI;EAC/C,KAAK,MAAM,EAAE,OAAO,gBAAgB,WAClC,IAAI,MAAM,gBAAgB,yBAAyB,CAAC,mBAAm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KAAK;AAC9F;;AAGA,SAAS,cAAc,MAA2B;CAChD,MAAM,EAAE,aAAa,gBAAgB,oBAAoB,IAAI;CAC7D,QAAQ,aAAa,UAAU,MAAM,aAAa,UAAU;AAC9D;;;;;;;;;;;;;AAcA,SAAS,wBAAwB,MAAkC;CACjE,MAAM,SAAwB,CAAC;CAC/B,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,EAAE,aAAa,aAAa,gBAAgB,oBAAoB,KAAK;EAC3E,IAAI,gBAAgB,cAAc,eAAe,cAC/C,OAAO,KAAK,KAAK;OACZ,IAAI,gBAAgB,SACzB,OAAO,KAAK,GAAG,wBAAwB,KAAK,CAAC;CAEjD;CACA,OAAO;AACT;;;;AAKA,SAAS,cAAc,SAAiB,MAAqC;CAC3E,KAAK,MAAM,OAAO,CAAC,MAAM,KAAK,GAAG;EAC/B,MAAM,WAAW,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EAC/C,IAAI;GACF,IAAI,SAAS,QAAQ,CAAC,CAAC,OAAO,GAC5B,OAAO;IAAE,UAAU;IAAU,WAAW;GAAI;EAEhD,QAAQ,CAER;CACF;AAEF;;;;;AAMA,SAAS,gBACP,SACA,MACA,QACuB;CACvB,KAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,WAAW,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;EAC/C,IAAI;GACF,IAAI,SAAS,QAAQ,CAAC,CAAC,OAAO,GAC5B,OAAO;IAAE,UAAU;IAAU,WAAW;GAAI;EAEhD,QAAQ,CAER;CACF;AAEF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-segment-params-C4r4BD9T.js","names":[],"sources":["../../src/client/use-pending-navigation.ts","../../src/client/navigation-context.ts","../../src/client/top-loader.tsx","../../src/client/navigation-root.tsx","../../src/client/params-context.ts","../../src/client/use-segment-params.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport { getRouterOrNull } from './router-ref.js';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const router = getRouterOrNull();\n if (!router) return () => {};\n return router.onPendingChange(onStoreChange);\n}\n\nfunction getSnapshot(): boolean {\n const router = getRouterOrNull();\n return router ? router.isPending() : false;\n}\n\nconst getServerSnapshot = getSnapshot;\n\n/**\n * Returns true while an RSC navigation is in flight.\n *\n * Reads from the router's external pending store via useSyncExternalStore.\n * Only components that call this hook re-render when pending state\n * changes — no full-tree re-render.\n *\n * ```tsx\n * 'use client'\n * import { usePendingNavigation } from '@timber-js/app/client'\n *\n * export function NavBar() {\n * const isPending = usePendingNavigation()\n * return (\n * <nav className={isPending ? 'opacity-50' : ''}>\n * <Link href=\"/dashboard\">Dashboard</Link>\n * </nav>\n * )\n * }\n * ```\n */\nexport function usePendingNavigation(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","'use client';\n\n/**\n * NavigationContext — React context for navigation state.\n *\n * Holds the current pathname and search, updated atomically with the RSC\n * tree on each navigation. This replaces the previous useSyncExternalStore\n * approach for usePathname() and useSearchParams(), which suffered from a\n * timing gap: the new tree could commit before the external store\n * re-renders fired, causing a frame where both old and new active states\n * were visible simultaneously.\n *\n * Segment params are NOT here — see the note on NavigationState below.\n *\n * By wrapping the RSC payload element in NavigationProvider inside\n * renderRoot(), the context value and the element tree are passed to\n * reactRoot.render() in the same call — atomic by construction.\n * All consumers (usePathname, useSearchParams) see the new values in the\n * same render pass as the new tree.\n *\n * During SSR, no NavigationProvider is mounted. Hooks fall back to\n * the ALS-backed getSsrData() for per-request isolation.\n *\n * IMPORTANT: createContext and useContext are NOT available in the RSC\n * environment (React Server Components use a stripped-down React).\n * The context is lazily initialized on first access, and all functions\n * that depend on these APIs are safe to call from any environment —\n * they return null or no-op when the APIs aren't available.\n *\n * SINGLETON GUARANTEE: All shared mutable state uses globalThis via\n * Symbol.for keys. The RSC client bundler can duplicate this module\n * across chunks (browser-entry graph + client-reference graph). With\n * ESM output, each chunk gets its own module scope — module-level\n * variables would create separate singleton instances per chunk.\n * globalThis guarantees a single instance regardless of duplication.\n *\n * This workaround will be removed when Rolldown ships `format: 'app'`\n * (module registry format that deduplicates like webpack/Turbopack).\n * See design/27-chunking-strategy.md.\n *\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport React, { createElement, type ReactNode } from 'react';\nimport type { SlotParamsRecord } from '../shared/slot-params.js';\n\n// ---------------------------------------------------------------------------\n// Context type\n// ---------------------------------------------------------------------------\n\n/**\n * What the browser knows about the current location.\n *\n * Params are deliberately absent: they are a property of the tree the server\n * rendered, not of the address bar, and they now travel inside the payload as\n * the payload root. Keeping a copy here meant the router had to thread\n * the record from a response header into context on every path — navigation,\n * traversal, prefetch, revalidation — and each of those was a place to drop it\n * (TIM-1294).\n */\nexport interface NavigationState {\n pathname: string;\n search: string;\n}\n\n// ---------------------------------------------------------------------------\n// Lazy context initialization\n// ---------------------------------------------------------------------------\n\n/**\n * The context is created lazily to avoid calling createContext at module\n * level. In the RSC environment, React.createContext doesn't exist —\n * calling it at import time would crash the server.\n *\n * Context instances are stored on globalThis (NOT in module-level\n * variables) because the ESM bundler can duplicate this module across\n * chunks. Module-level variables would create separate instances per\n * chunk — the provider in NavigationRoot (index chunk) would use\n * context A while the consumer in usePendingNavigation (shared chunk)\n * reads from context B. globalThis guarantees a single instance.\n *\n * See design/27-chunking-strategy.md §\"Singleton Safety\"\n */\n\n// Symbol keys for globalThis storage — prevents collisions with user code\nconst NAV_CTX_KEY = Symbol.for('__timber_nav_ctx');\n\nfunction getOrCreateContext(): React.Context<NavigationState | null> | undefined {\n const existing = (globalThis as Record<symbol, unknown>)[NAV_CTX_KEY] as\n | React.Context<NavigationState | null>\n | undefined;\n if (existing !== undefined) return existing;\n // createContext may not exist in the RSC environment\n if (typeof React.createContext === 'function') {\n const ctx = React.createContext<NavigationState | null>(null);\n (globalThis as Record<symbol, unknown>)[NAV_CTX_KEY] = ctx;\n return ctx;\n }\n return undefined;\n}\n\n/**\n * Read the navigation context. Returns null during SSR (no provider)\n * or in the RSC environment (no context available).\n * Internal — used by usePathname() and useSearchParams().\n */\nexport function useNavigationContext(): NavigationState | null {\n const ctx = getOrCreateContext();\n if (!ctx) return null;\n // useContext may not exist in the RSC environment — caller wraps in try/catch\n if (typeof React.useContext !== 'function') return null;\n // eslint-disable-next-line rules-of-hooks -- conditional on environment, not render path\n return React.useContext(ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Provider component\n// ---------------------------------------------------------------------------\n\nexport interface NavigationProviderProps {\n value: NavigationState;\n children?: ReactNode;\n}\n\n/**\n * Wraps children with NavigationContext.Provider.\n *\n * Used in browser-entry.ts renderRoot to wrap the RSC payload element\n * so that navigation state updates atomically with the tree render.\n */\nexport function NavigationProvider({\n value,\n children,\n}: NavigationProviderProps): React.ReactElement {\n const ctx = getOrCreateContext();\n if (!ctx) {\n // RSC environment — no context available. Return children as-is.\n return children as React.ReactElement;\n }\n return createElement(ctx.Provider, { value }, children);\n}\n\n// ---------------------------------------------------------------------------\n// Module-level state for renderRoot to read\n// ---------------------------------------------------------------------------\n\n/**\n * Navigation state communicated between the router and renderRoot.\n *\n * The router calls setNavigationState() before renderRoot(). The\n * renderRoot callback reads via getNavigationState() to create the\n * NavigationProvider with the correct params/pathname.\n *\n * This is NOT used by hooks directly — hooks read from React context.\n *\n * Stored on globalThis (like the context instances above) because the\n * router lives in one chunk while renderRoot lives in another. Module-\n * level variables would be separate per chunk.\n */\nconst NAV_STATE_KEY = Symbol.for('__timber_nav_state');\n\nfunction _getNavStateStore(): { current: NavigationState } {\n const g = globalThis as Record<symbol, unknown>;\n if (!g[NAV_STATE_KEY]) {\n g[NAV_STATE_KEY] = { current: { pathname: '/', search: '' } };\n }\n return g[NAV_STATE_KEY] as { current: NavigationState };\n}\n\nexport function setNavigationState(state: NavigationState): void {\n _getNavStateStore().current = state;\n}\n\nexport function getNavigationState(): NavigationState {\n return _getNavStateStore().current;\n}\n\n// ---------------------------------------------------------------------------\n// Pending navigation state lives in the router, not here\n// ---------------------------------------------------------------------------\n\n/**\n * There was a second React context here — `PendingNavigationContext`, holding\n * the in-flight navigation URL, provided by `NavigationRoot` out of a\n * `useState` — plus a `usePendingNavigationUrl()` reader for it. Both are gone\n * (TIM-1307).\n *\n * Nothing read them. `usePendingNavigation()` (use-pending-navigation.ts) and\n * `TopLoader` both subscribe to the router's external pending store via\n * `useSyncExternalStore`: sync priority, immune to transition entanglement,\n * and cleared by `runNavigation`'s supersession-guarded `finally` (TIM-1034).\n * The context was a parallel representation of the same fact that no consumer\n * ever migrated to, and one that could not even agree with the store — a\n * navigation superseded by a cached popstate replay left its URL set until the\n * next full navigation, because the staleness guard skipped the clear and no\n * other path touched it.\n *\n * One representation, and it is the router's. See\n * design/19-client-navigation.md §\"How Pending State Works\".\n */\n","/**\n * TopLoader — Built-in progress bar for client navigations.\n *\n * Shows an animated progress bar at the top of the viewport while an RSC\n * navigation is in flight. Injected automatically by the framework into\n * NavigationRoot — users never render this component directly.\n *\n * Configuration is via timber.config.ts `topLoader` key. Enabled by default.\n * Users who want a fully custom progress indicator disable the built-in one\n * (`topLoader: { enabled: false }`) and use `usePendingNavigation()` directly.\n *\n * Animation approach: pure CSS @keyframes. The bar crawls from 0% to ~90%\n * width over ~30s using ease-out timing. When navigation completes, the bar\n * snaps to 100% and fades out over 200ms. No JS animation loops (RAF, setInterval).\n *\n * Phase transitions are derived synchronously during render (React's\n * getDerivedStateFromProps pattern) — no useEffect needed for state tracking.\n * The finishing → hidden cleanup uses onTransitionEnd from the CSS transition.\n *\n * When delay > 0, CSS animation-delay + a visibility keyframe ensure the bar\n * stays invisible during the delay period. If navigation finishes before the\n * delay, the bar was never visible so the finish transition is also invisible.\n *\n * See design/19-client-navigation.md §\"usePendingNavigation()\"\n * See LOCAL-336 for design decisions.\n */\n\n'use client';\n\nimport { useState, createElement } from 'react';\nimport { usePendingNavigation } from './use-pending-navigation.js';\n\n// ─── Types ───────────────────────────────────────────────────────\n\nexport interface TopLoaderConfig {\n /** Whether the top-loader is enabled. Default: true. */\n enabled?: boolean;\n /** Bar color. Default: '#2299DD'. */\n color?: string;\n /** Bar height in pixels. Default: 3. */\n height?: number;\n /** Show subtle glow/shadow effect. Default: false. */\n shadow?: boolean;\n /** Delay in ms before showing the bar. Default: 0. */\n delay?: number;\n /** CSS z-index. Default: 1600. */\n zIndex?: number;\n}\n\n// ─── Defaults ────────────────────────────────────────────────────\n\nconst DEFAULT_COLOR = '#2299DD';\nconst DEFAULT_HEIGHT = 3;\nconst DEFAULT_SHADOW = false;\nconst DEFAULT_DELAY = 0;\nconst DEFAULT_Z_INDEX = 1600;\n\n// ─── Keyframes ───────────────────────────────────────────────────\n\n// Unique keyframes name to avoid collisions with user styles.\nconst CRAWL_KEYFRAMES = '__timber_top_loader_crawl';\nconst APPEAR_KEYFRAMES = '__timber_top_loader_appear';\nconst FINISH_KEYFRAMES = '__timber_top_loader_finish';\n\n// Track whether the @keyframes rules have been injected into the document.\nlet keyframesInjected = false;\n\n/**\n * Inject the @keyframes rules into the document head once.\n * Called during render (idempotent). Uses a <style> tag so the\n * animations are available for inline-styled elements.\n */\nfunction ensureKeyframes(): void {\n if (keyframesInjected) return;\n if (typeof document === 'undefined') return;\n\n const style = document.createElement('style');\n style.textContent = `\n@keyframes ${CRAWL_KEYFRAMES} {\n 0% { width: 0%; }\n 100% { width: 90%; }\n}\n@keyframes ${APPEAR_KEYFRAMES} {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n@keyframes ${FINISH_KEYFRAMES} {\n 0% { width: 90%; opacity: 1; }\n 50% { width: 100%; opacity: 1; }\n 100% { width: 100%; opacity: 0; }\n}\n`;\n document.head.appendChild(style);\n keyframesInjected = true;\n}\n\n// ─── Component ───────────────────────────────────────────────────\n\n/**\n * Internal top-loader component. Injected by NavigationRoot.\n *\n * Reads pending navigation state from the router's external store, via\n * usePendingNavigation() — the one pending representation (TIM-1307).\n * Phase transitions are derived synchronously during render:\n *\n * hidden → crawling: when isPending becomes true\n * crawling → finishing: when isPending becomes false\n * finishing → hidden: when CSS transition ends (onTransitionEnd)\n * finishing → crawling: when isPending becomes true again\n *\n * No useEffect — all state changes are either derived during render\n * (getDerivedStateFromProps pattern) or triggered by DOM events.\n */\nexport function TopLoader({ config }: { config?: TopLoaderConfig }): React.ReactElement | null {\n // Read pending state from the router's external store via\n // useSyncExternalStore (inside usePendingNavigation). Only this\n // component re-renders when pending changes — no full-tree re-render.\n const isPending = usePendingNavigation();\n\n const color = config?.color ?? DEFAULT_COLOR;\n const height = config?.height ?? DEFAULT_HEIGHT;\n const shadow = config?.shadow ?? DEFAULT_SHADOW;\n const delay = config?.delay ?? DEFAULT_DELAY;\n const zIndex = config?.zIndex ?? DEFAULT_Z_INDEX;\n\n const [phase, setPhase] = useState<'hidden' | 'crawling' | 'finishing'>('hidden');\n\n // ─── Synchronous phase derivation (getDerivedStateFromProps) ──\n // React allows setState during render if the value changes — it\n // immediately re-renders with the updated state before committing.\n\n if (isPending && (phase === 'hidden' || phase === 'finishing')) {\n setPhase('crawling');\n }\n if (!isPending && phase === 'crawling') {\n setPhase('finishing');\n }\n\n // Inject keyframes on first visible render (idempotent)\n if (phase !== 'hidden') {\n ensureKeyframes();\n }\n\n if (phase === 'hidden') return null;\n\n // ─── Styles ──────────────────────────────────────────────────\n\n const containerStyle: React.CSSProperties = {\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: `${height}px`,\n zIndex,\n pointerEvents: 'none',\n };\n\n const barStyle: React.CSSProperties = {\n height: '100%',\n backgroundColor: color,\n ...(phase === 'crawling'\n ? {\n // Crawl from 0% to 90% over 30s. When delay > 0, both the crawl\n // and a visibility animation are delayed — the bar stays at width 0%\n // and opacity 0 during the delay, then appears and starts crawling.\n // With delay 0, the appear animation is instant (0s duration, no delay).\n animation: [\n `${CRAWL_KEYFRAMES} 30s ease-out ${delay}ms forwards`,\n `${APPEAR_KEYFRAMES} 0s ${delay}ms both`,\n ].join(', '),\n }\n : {\n // Finishing: fill to 100% then fade out via a keyframe animation.\n // We use a keyframe instead of a CSS transition because the\n // animation-to-transition handoff is unreliable — the browser\n // may not capture the animated width as the transition's \"from\"\n // value when both the animation removal and transition are\n // applied in the same render frame.\n animation: `${FINISH_KEYFRAMES} 400ms ease forwards`,\n }),\n ...(shadow\n ? {\n boxShadow: `0 0 10px ${color}, 0 0 5px ${color}`,\n }\n : {}),\n };\n\n // Clean up the finishing phase when the finish animation completes.\n const handleAnimationEnd =\n phase === 'finishing'\n ? (e: React.AnimationEvent) => {\n if (e.animationName === FINISH_KEYFRAMES) {\n setPhase('hidden');\n }\n }\n : undefined;\n\n return createElement(\n 'div',\n {\n 'style': containerStyle,\n 'aria-hidden': 'true',\n 'data-timber-top-loader': '',\n },\n createElement('div', { style: barStyle, onAnimationEnd: handleAnimationEnd })\n );\n}\n","/**\n * NavigationRoot — Wrapper component for transition-based rendering.\n *\n * Solves the \"new boundary has no old content\" problem for client-side\n * navigation. When React renders a completely new Suspense boundary via\n * root.render(), it shows the fallback immediately — root.render() is\n * always an urgent update regardless of startTransition.\n *\n * NavigationRoot holds the current element in React state. Navigation\n * updates call startTransition(() => setState(newElement)), which IS\n * a transition update. React keeps the old committed tree visible while\n * the new tree resolves, instead of hiding it behind a Suspense fallback.\n *\n * The navigation's async work runs OUTSIDE the transition scope and every\n * state update it schedules gets its own synchronous `startTransition` — a\n * transition scope does not survive an `await`, and an async callback that\n * returns a thenable defers the commit past the promise callers await. See\n * the long comment on `_navigateTransition` (TIM-1306).\n *\n * This component holds no pending state. The `TopLoader` it renders and the\n * public `usePendingNavigation()` both subscribe to the router's external\n * pending store; NavigationRoot's own `pendingUrl` was a second, unread\n * representation of the same fact and is gone (TIM-1307).\n *\n * Hard navigation guard: When a hard navigation is triggered (500 error,\n * version skew), the component throws an unresolved thenable AFTER all\n * hooks to suspend forever — preventing React from rendering children\n * during page teardown. The throw must come after hooks to satisfy\n * React's rules (same hook count every render) while still preventing\n * child renders that could hit hook count mismatches in components\n * whose positions shift during teardown. This pattern is borrowed from\n * Next.js (app-router.tsx pushRef.mpaNavigation — also after hooks).\n *\n * See design/05-streaming.md §\"deferSuspenseFor\"\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport {\n createElement,\n Fragment,\n startTransition,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { TopLoader, type TopLoaderConfig } from './top-loader.js';\n\n// ─── Transition Result ──────────────────────────────────────────\n\n/**\n * What a navigation's `perform()` hands back to the transition.\n *\n * Declared once and shared by every layer that passes it along — the router's\n * `RouterDeps.navigateTransition` imports it too — so a field cannot be added\n * to the producer and dropped by the adapter in between. `E` is the element\n * type: `ReactNode` here, `unknown` in the router, which never touches it.\n */\nexport interface TransitionResult<E = ReactNode> {\n /** The wrapped tree to render. */\n element: E;\n /** Resolves when the Flight stream finishes decoding, or null. */\n decodePromise: Promise<void> | null;\n /**\n * Publishes the navigation's state — segment cache, pathname, address bar,\n * history stack, and the client's record of the mounted tree — and\n * announces it to listeners outside React.\n *\n * Run when React commits this tree, not when the tree is handed over: a\n * tree React is still waiting on, or one a later navigation replaces first,\n * has been given to React without being on screen. A superseded navigation\n * never runs it and leaves every one of those consumers describing the\n * route still on screen (TIM-1301).\n */\n commit: () => void;\n}\n\n/**\n * The tree NavigationRoot holds in state, and the state publish that belongs\n * to it. They travel as one object so React's commit of the tree is the event\n * that publishes — see the effect in NavigationRoot.\n */\ninterface RenderedTree {\n element: ReactNode;\n publish: (() => void) | null;\n}\n\n// ─── Navigation Transition Counter ──────────────────────────────\n// Monotonically increasing counter that increments each time\n// navigateTransition() is called. Used to detect stale transitions:\n// if a newer transition started while the current one's perform()\n// was in flight, the current transition is stale and should reject.\n//\n// Separate from the link-pending navId (which only increments on\n// link clicks). This counter covers all navigation types: link clicks,\n// programmatic navigate(), refresh(), and handlePopState().\n//\n// Uses globalThis for singleton guarantee across chunks — same pattern\n// as NavigationContext and the link pending store.\n\nconst NAV_TRANSITION_KEY = Symbol.for('__timber_nav_transition_counter');\n\n/**\n * `waiters` are woken on every bump so an in-flight navigation can stop\n * waiting on its own payload the moment it is superseded — see\n * `settleOnDecodeOrSupersession`.\n */\ninterface TransitionCounter {\n id: number;\n waiters: Set<() => void>;\n}\n\nfunction getTransitionCounter(): TransitionCounter {\n const g = globalThis as Record<symbol, unknown>;\n const existing = g[NAV_TRANSITION_KEY] as Partial<TransitionCounter> | undefined;\n if (!existing) {\n const created: TransitionCounter = { id: 0, waiters: new Set() };\n g[NAV_TRANSITION_KEY] = created;\n return created;\n }\n // A duplicated copy of this module may have created the singleton before\n // `waiters` existed. The object is shared across chunks, so fill it in\n // rather than replacing it — replacing would strand the other copy's id.\n existing.waiters ??= new Set();\n return existing as TransitionCounter;\n}\n\n/** Bump the counter and wake everything waiting on an older transition. */\nfunction bumpTransitionCounter(): number {\n const counter = getTransitionCounter();\n counter.id += 1;\n for (const wake of [...counter.waiters]) wake();\n return counter.id;\n}\n\n/**\n * Invalidate all in-flight navigation transitions. Any navigateTransition()\n * call whose perform() has not yet committed will reject with AbortError\n * instead of committing its element.\n *\n * Called by the router when a render supersedes in-flight navigations\n * WITHOUT going through navigateTransition() — the cached popstate replay\n * renders via transitionRender(), which doesn't bump the counter, so a\n * stale forward navigation's setElement would otherwise pass the\n * `counter.id !== transId` guard and commit the forward page over the\n * replayed back page (TIM-1022).\n */\nexport function supersedeNavigationTransitions(): void {\n bumpTransitionCounter();\n}\n\n/**\n * Wait for the payload to finish decoding, OR for this transition to be\n * superseded — whichever happens first.\n *\n * A superseded navigation must stop waiting on its own stream. The stream is\n * deliberately NOT aborted once its tree has been handed to React (the tree\n * may be on screen with boundaries still feeding from it — see\n * `handedOffNavAbort` in `client/router.ts`), so there is nothing left to make\n * `decodePromise` settle promptly. Awaiting it bare would keep the loser's\n * `router.navigate()` promise pending for the rest of the stream — and\n * forever if it stalls — which is what `<Link>`'s `isPending` is timed\n * against, so the losing link would sit spinning while the winner loaded\n * (codex on #1004).\n *\n * A decode *failure* still propagates: it is a real error for this\n * navigation, and the caller's recovery is timed against it.\n */\nfunction settleOnDecodeOrSupersession(\n decodePromise: Promise<void>,\n counter: TransitionCounter,\n transId: number\n): Promise<void> {\n if (counter.id !== transId) return Promise.resolve();\n return new Promise<void>((resolve, reject) => {\n const stopWaiting = (): void => {\n counter.waiters.delete(wake);\n };\n const wake = (): void => {\n if (counter.id !== transId) {\n stopWaiting();\n resolve();\n }\n };\n counter.waiters.add(wake);\n decodePromise.then(\n () => {\n stopWaiting();\n resolve();\n },\n (error: unknown) => {\n stopWaiting();\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n );\n });\n}\n\n// ─── Hard Navigation Guard ──────────────────────────────────────\n\n/**\n * Module-level flag indicating a hard (MPA) navigation is in progress.\n *\n * When true:\n * - NavigationRoot throws an unresolved thenable to suspend forever,\n * preventing React from rendering children during page teardown\n * (avoids \"Rendered more hooks\" crashes).\n * - The Navigation API handler skips interception, letting the browser\n * perform a full page load (prevents infinite loops where\n * window.location.href → navigate event → router.navigate → 500 →\n * window.location.href → ...).\n *\n * Uses globalThis for singleton guarantee across chunks (same pattern\n * as NavigationContext). See design/19-client-navigation.md §\"Singleton\n * Guarantee via globalThis\".\n */\nconst HARD_NAV_KEY = Symbol.for('__timber_hard_navigating');\n\nfunction getHardNavStore(): { value: boolean } {\n const g = globalThis as Record<symbol, unknown>;\n if (!g[HARD_NAV_KEY]) {\n g[HARD_NAV_KEY] = { value: false };\n }\n return g[HARD_NAV_KEY] as { value: boolean };\n}\n\n/**\n * Set the hard-navigating flag. Call this BEFORE setting\n * window.location.href or window.location.reload() to prevent:\n * 1. React from rendering children during page teardown\n * 2. Navigation API from intercepting the hard navigation\n */\nexport function setHardNavigating(value: boolean): void {\n getHardNavStore().value = value;\n}\n\n/**\n * Check if a hard navigation is in progress.\n * Used by NavigationRoot (throw unresolvedThenable) and by the\n * Navigation API handler (skip interception).\n */\nexport function isHardNavigating(): boolean {\n return getHardNavStore().value;\n}\n\n/**\n * A thenable that never resolves. When thrown during React render,\n * it causes the component to suspend forever — React keeps the\n * old committed tree visible and never attempts to render children.\n *\n * This is the same pattern Next.js uses in app-router.tsx for MPA\n * navigations (pushRef.mpaNavigation → throw unresolvedThenable).\n */\n// for React's Suspense mechanism. Same pattern as Next.js's unresolvedThenable.\n// eslint-disable-next-line unicorn/no-thenable -- Intentionally a never-resolving thenable\nconst unresolvedThenable = { then() {} } as PromiseLike<never>;\n\n// ─── Module-level functions ──────────────────────────────────────\n\n/**\n * Module-level reference to the state setter wrapped in startTransition.\n * Used for non-navigation renders (applyRevalidation, popstate replay).\n */\nlet _transitionRender: ((element: ReactNode) => void) | null = null;\n\n/**\n * Module-level reference to the navigation transition function.\n *\n * Runs the fetch OUTSIDE any transition scope and wraps only the state update\n * that hands the resulting tree to React — describing this as \"a full\n * navigation in a single startTransition\" is the shape TIM-1306 removed.\n */\nlet _navigateTransition:\n | ((url: string, perform: () => Promise<TransitionResult>) => Promise<void>)\n | null = null;\n\n// ─── Component ───────────────────────────────────────────────────\n\n/**\n * Root wrapper component that enables transition-based rendering.\n *\n * Renders the TopLoader alongside the tree it holds in state. Neither adds a\n * DOM element on the hydration path, so the tree matches the server HTML.\n *\n * Usage in browser-entry.ts:\n * const rootEl = createElement(NavigationRoot, { initial: wrapped });\n * reactRoot = hydrateRoot(document, rootEl);\n *\n * Subsequent navigations:\n * navigateTransition(url, async () => { fetch; return wrappedElement; });\n *\n * Non-navigation renders:\n * transitionRender(newWrappedElement);\n */\nexport function NavigationRoot({\n initial,\n topLoaderConfig,\n}: {\n initial: ReactNode;\n topLoaderConfig?: TopLoaderConfig;\n}): ReactNode {\n const [rendered, setRendered] = useState<RenderedTree>({ element: initial, publish: null });\n\n // Publish the navigation's state when React commits its tree — not when the\n // tree is handed over. A tree React is still waiting on, or one a later\n // navigation replaces before React renders it, has been *given* to React\n // without being on screen; publishing then describes a route the user never\n // saw, which is the defect this ordering exists to prevent (TIM-1301).\n //\n // A **layout** effect, so the publish lands before the browser paints and,\n // more importantly, before every descendant's passive effect. A destination\n // component that navigates from a mount effect — a redirect guard, a\n // `refresh()` on mount — would otherwise start its navigation while the\n // segment cache, address bar and pathname still described the departing\n // route, and send an X-Timber-State-Tree for a tree that is no longer\n // mounted (codex on #998).\n //\n // Descendant *layout* effects still run first: React runs layout effects\n // child-before-parent, and the only way to precede them would be a fiber\n // rendered as an earlier sibling of the payload. That is not free here —\n // `server/ssr-wrappers.tsx` mirrors this component's fiber shape so `useId`\n // agrees across hydration, and an extra sibling shifts every id in the\n // payload subtree. A layout effect that navigates on mount is the price.\n //\n // Keyed on the tree object rather than on the effect run. A publish moves\n // the address bar, which is not idempotent, so any second invocation for the\n // same tree — an effect re-run React is entitled to perform — must be a\n // no-op rather than a second history entry.\n const publishedRef = useRef<RenderedTree | null>(null);\n useLayoutEffect(() => {\n if (publishedRef.current === rendered) return;\n publishedRef.current = rendered;\n rendered.publish?.();\n }, [rendered]);\n\n // NOTE: We use standalone `startTransition` (imported from 'react'),\n // NOT `useTransition`. The `useTransition` hook's `startTransition`\n // is tied to a single fiber and tracks one async callback at a time.\n // When two navigations overlap (click slow-page, then click dashboard),\n // calling useTransition's startTransition twice with concurrent async\n // callbacks corrupts React's internal hook tracking — causing\n // \"Rendered more hooks than during the previous render.\"\n //\n // Standalone `startTransition` creates independent transition lanes\n // for each call, so concurrent navigations don't interfere. We don't\n // need useTransition's `isPending` — pending state lives in the router's\n // external store, which TopLoader and usePendingNavigation() subscribe to.\n //\n // This matches the Next.js pattern (TIM-625): \"No useTransition in\n // the router at all — only standalone startTransition.\"\n\n // Non-navigation render (revalidation, popstate cached replay).\n // Non-navigation render (revalidation, popstate cached replay). Both publish\n // synchronously in the router before calling this — neither has an in-flight\n // window in which it could be superseded — so there is nothing to publish\n // on commit.\n _transitionRender = (newElement: ReactNode) => {\n startTransition(() => {\n setRendered({ element: newElement, publish: null });\n });\n };\n\n // Full navigation transition.\n //\n // The async work runs OUTSIDE any transition scope, and each state update is\n // its own synchronous `startTransition`. Two React behaviours force that\n // shape; both were measured on React 19.2.7 (tests/navigation-transition-\n // suspense.test.ts pins the observable half).\n //\n // 1. A transition scope does not survive an `await`. `startTransition`\n // restores the previous scope in its `finally`, which for an async\n // callback runs when that callback RETURNS — i.e. at its first `await`.\n // So an update scheduled past an await inside `startTransition(async …)`\n // is an ordinary urgent update:\n //\n // startTransition(() => setEl(x)) -> 'HOME' held\n // startTransition(async () => { await p; setEl(x) }) -> fallback shown\n //\n // Left uncorrected, every navigation whose new tree suspends replaces the\n // visible page with a Suspense fallback — the exact thing this component\n // exists to prevent (TIM-1306). React documents the caveat under\n // `startTransition`: updates after an await need their own transition.\n //\n // 2. Re-wrapping *inside* the async callback is not enough. Returning a\n // thenable from `startTransition` hands it to `ReactSharedInternals.S`,\n // which calls react-dom's `entangleAsyncAction`. That opens an action\n // scope: `currentEntangledLane` collects EVERY transition update\n // scheduled while the scope is open — including one from a nested,\n // fully synchronous `startTransition` — and rendering that lane throws\n // `currentEntangledActionThenable`, suspending until the action settles.\n // Which is after the promise `navigateTransition` hands back, so a caller\n // that awaits a navigation and then reads the DOM sees the departing\n // page, and the TIM-1301 publish (a layout effect on the commit) is just\n // as late. (Not `ReactSharedInternals.asyncTransitions` — that counter is\n // write-only in 19.2.7.)\n //\n // No async action is created here, so every navigation commits as soon as\n // React can render its destination — where TIM-1301 put it. That\n // now holds for ALL of them. It used not to hold for `<Link>`, which wrapped\n // `router.navigate()` in its own `useTransition`: that action scope\n // entangled this component's updates just the same, so a Link navigation\n // committed only once the payload had finished decoding, and with it\n // `pushState`, the segment cache and `timber:navigation-end`. Link now calls\n // `router.navigate()` outside any transition and tracks its own `isPending`\n // with a plain `useState` (TIM-1307).\n //\n // Nothing here may reopen an action scope: no `startTransition` callback in\n // this path may return a thenable, and no caller may invoke this from inside\n // a React action scope. That is a rule about `startTransition`, not about\n // `perform` — `perform` is async by contract and is awaited OUTSIDE any\n // transition scope, which is exactly why it is safe.\n //\n // Standalone `startTransition` rather than `useTransition`'s is still\n // deliberate — see the TIM-625 note above; each navigation needs an\n // independent lane.\n //\n // `url` is unused: it named the pending state this component used to hold,\n // and the router already publishes the same URL to its own pending store\n // before calling here. It stays in the signature because the router's\n // `RouterDeps.navigateTransition` adapter passes it and the argument reads\n // at the call site.\n _navigateTransition = (_url: string, perform: () => Promise<TransitionResult>) => {\n // Increment the transition counter SYNCHRONOUSLY (before any await). Each\n // call gets a unique transId; the counter is the same globalThis\n // singleton, so a newer call always has a higher id.\n const counter = getTransitionCounter();\n const transId = bumpTransitionCounter();\n\n const superseded = () => new DOMException('Navigation superseded', 'AbortError');\n\n return (async () => {\n const { element, decodePromise, commit } = await perform();\n if (counter.id !== transId) {\n decodePromise?.catch(() => {});\n throw superseded();\n }\n // Hand the tree over with its commit attached. The effect above runs\n // it if and when React commits this tree, so a navigation that is\n // superseded while its payload streams publishes nothing (TIM-1301).\n //\n // This is THE update that must not hide the departing page (TIM-1306).\n startTransition(() => {\n setRendered({ element, publish: commit });\n });\n // React may commit the tree before this settles — that is the point:\n // the destination reveals as React is able to render it\n // rather than waiting for the whole Flight stream. The await is here so\n // the promise this function hands back still means \"the payload is\n // decoded\", which is what the router's scroll restoration, the\n // Navigation API deferred and `<Link>`'s `isPending` are timed against.\n //\n // ...unless this navigation loses first, in which case it stops waiting\n // on a stream that is no longer its business. See\n // `settleOnDecodeOrSupersession`.\n if (decodePromise) await settleOnDecodeOrSupersession(decodePromise, counter, transId);\n if (counter.id !== transId) throw superseded();\n })();\n };\n\n // ─── Hard navigation guard ─────────────────────────────────\n // When a hard navigation is in progress (500 error, version skew),\n // suspend forever to prevent React from rendering children during\n // page teardown. This avoids \"Rendered more hooks\" crashes in\n // CHILD components whose hook counts may shift during teardown.\n //\n // CRITICAL: This throw MUST come AFTER all hooks (the useState,\n // useRef and useLayoutEffect above). React requires the same hooks\n // to run on every render. If we threw before hooks, React would see\n // 0 hooks on the re-render vs 3 on the initial render — triggering\n // the exact \"Rendered more hooks\" error we're trying to prevent.\n //\n // By placing it after hooks but before the return, all hooks\n // satisfy React's rules, but the thrown thenable prevents any\n // children from rendering. Same pattern as Next.js app-router.tsx\n // (pushRef.mpaNavigation — also placed after all hooks).\n if (isHardNavigating()) {\n throw unresolvedThenable;\n }\n\n // Inject TopLoader alongside the element tree. It subscribes to the router's\n // pending store itself, so it takes no props from here beyond its config,\n // and only it re-renders when a navigation starts or ends. Rendered only\n // when not explicitly disabled via config.\n //\n // This Fragment is a FORK — two children — so it advances React's tree\n // context and shifts every `useId` below it. `server/ssr-wrappers.tsx`\n // mirrors it for exactly that reason; a single-child wrapper would not need\n // a mirror. See tests/ssr-wrapper-parity.test.ts.\n const showTopLoader = topLoaderConfig?.enabled !== false;\n if (!showTopLoader) return rendered.element;\n return createElement(\n Fragment,\n null,\n createElement(TopLoader, { config: topLoaderConfig }),\n rendered.element\n );\n}\n\n// ─── Public API ──────────────────────────────────────────────────\n\n/**\n * Trigger a transition render for non-navigation updates.\n * React keeps the old committed tree visible while any new Suspense\n * boundaries in the update resolve.\n *\n * Used for: applyRevalidation, popstate replay with cached payload.\n */\nexport function transitionRender(element: ReactNode): void {\n if (_transitionRender) {\n _transitionRender(element);\n }\n}\n\n/**\n * Run a full navigation, handing its tree to React in a transition.\n *\n * The `perform` callback fetches the RSC payload, updates router state, and\n * returns the wrapped React element. `perform` is async by contract and runs\n * OUTSIDE any transition scope — only the `setRendered` that hands its result\n * over is wrapped, in a synchronous `startTransition`.\n *\n * Do not call this from inside a React action scope, and never let a\n * `startTransition` callback in this path return a thenable: either opens an\n * action scope that entangles the update and defers the commit until the\n * action settles (TIM-1306, TIM-1307).\n *\n * Returns a Promise that resolves when the async work completes — the payload\n * is fetched, decoded, and handed to React. It does **not** wait for React to\n * commit the tree, so the state that publishes on that commit (address bar,\n * segment cache, history entry, pathname) may still be a beat behind when it\n * resolves. Anything that needs the destination to be current should listen\n * for `timber:navigation-end`, which is dispatched by the publish itself.\n *\n * Awaiting the publish here was tried and rejected: it makes the promise\n * depend on a React commit, which never arrives if the root unmounts\n * mid-navigation, and deadlocks any caller that awaits a navigation inside\n * `act()`.\n *\n * Used for: navigate(), refresh(), popstate with fetch.\n */\nexport function navigateTransition(\n url: string,\n perform: () => Promise<TransitionResult>\n): Promise<void> {\n if (_navigateTransition) {\n return _navigateTransition(url, perform);\n }\n // Fallback: no NavigationRoot mounted (shouldn't happen in production).\n // Nothing can supersede a transition that does not exist, so the commit\n // runs unconditionally.\n return perform().then((result) => result.commit());\n}\n\n/**\n * Install one-shot deferred callbacks for the no-RSC bootstrap path (TIM-600).\n *\n * When there's no RSC payload, we can't create a React root immediately —\n * `createRoot(document).render(...)` would blank the SSR HTML. Instead,\n * this sets up `_transitionRender` and `_navigateTransition` so that the\n * first client navigation triggers root creation via `createAndMount`.\n *\n * After `createAndMount` runs, NavigationRoot renders and overwrites these\n * callbacks with its real `startTransition`-based implementations.\n */\nexport function installDeferredNavigation(createAndMount: (initial: ReactNode) => void): void {\n let mounted = false;\n const mountOnce = (element: ReactNode) => {\n if (mounted) return;\n mounted = true;\n createAndMount(element);\n };\n _transitionRender = (element: ReactNode) => {\n mountOnce(element);\n };\n _navigateTransition = async (_url: string, perform: () => Promise<TransitionResult>) => {\n const { element, commit } = await perform();\n commit();\n mountOnce(element);\n };\n}\n","/**\n * Segment params context — the one channel params use to reach the browser.\n *\n * Params ride the RSC payload's root row as a sibling of the tree\n * (`{ tree, params, slotParams }`), rather than in four side channels that\n * raced to seed them: a response header, an inline script, and two build-time\n * manifest fields all previously carried the same record, each with its own\n * `JSON.stringify` (TIM-1294).\n *\n * Riding the payload is what makes them *typed*. `defineSchema` takes any\n * `Codec<T>`, so a coerced param is whatever the codec returned — a `Date`, a\n * `bigint` — and `JSON.stringify` either flattened it to a string or threw\n * mid-response. React Flight carries those values natively, so the client\n * reads the value the server produced instead of a lossy copy of it. See\n * design/41-global-params.md §\"Transport\".\n *\n * **The client owns the provider.** There is exactly one `ParamsProvider` in\n * the browser's tree, rendered by `PayloadRoot` above the point where a\n * partial navigation splices the new payload into the retained tree. It has to\n * be there and it has to be alone: a provider *inside* the payload lands below\n * the retained region, whose own root is the departing route's provider, so\n * every reader in a skipped layout resolves to the departing record and no\n * amount of wrapping above it helps (TIM-1297).\n *\n * Ordering still holds without a bootstrap contract, for the same reason it\n * did when the provider was in the tree: a provider renders before its own\n * descendants by construction, so `useSegmentParams()` is correct during\n * hydration without anything having to run before `hydrateRoot()`.\n */\n\n'use client';\n\nimport React, { createElement, useMemo, use } from 'react';\nimport { _setCurrentParams, _setCurrentSlotParams } from './state.js';\nimport { toNullProtoRecord, type CoercedParams } from '../shared/param-value.js';\nimport { readPublishedParams, type PublishedParams } from '../shared/payload-root.js';\nimport type { SlotParamsRecord } from '../shared/slot-params.js';\n\n// ─── Types ───────────────────────────────────────────────────────\n\nexport type ParamsContextValue = PublishedParams;\n\n// ─── Context ─────────────────────────────────────────────────────\n\n/**\n * SINGLETON GUARANTEE: globalThis + `Symbol.for`, the same pattern as\n * `NavigationContext` and `SegmentUpdateContext`.\n *\n * The RSC client bundler can duplicate a module across chunks, and with ESM\n * output each chunk gets its own module scope — so a bare `createContext` at\n * module level yields one context per chunk. This module is now reached from\n * *both* graphs: `PayloadRoot` is imported by the browser entry, while\n * `useParamsContext()` arrives through the client-reference graph with the\n * app's own components. A duplicate would put the provider on instance A and\n * every reader on instance B, so `useContext` returns `null` and every\n * `useSegmentParams()` call silently falls back to the module snapshot.\n *\n * This module was the one client context without the guard — harmless while\n * the provider travelled inside the payload, in the same graph as its readers,\n * and load-bearing the moment the client started rendering it (TIM-1297).\n *\n * The React APIs are reached through the namespace rather than named imports,\n * for the same reason `segment-update-context.ts` and `navigation-context.ts`\n * do it: React's `react-server` export provides neither `createContext` nor\n * `useContext`, and a *named* ESM import of a missing export fails at module\n * instantiation — before any feature check could run. This module is reachable\n * from every entry a Server Component imports, so the named form crashed\n * those entries outright (codex, PR #992; originally reproduced against\n * `@timber-js/app/segment-params`, an entry point since deleted by TIM-1342 —\n * the hazard is unchanged for the entries that remain).\n *\n * See design/19-client-navigation.md §\"Singleton Guarantee via globalThis\"\n */\nconst PARAMS_CTX_KEY = Symbol.for('__timber_params_ctx');\n\nfunction getOrCreateContext(): React.Context<ParamsContextValue | null> {\n const store = globalThis as Record<symbol, unknown>;\n const existing = store[PARAMS_CTX_KEY] as React.Context<ParamsContextValue | null> | undefined;\n if (existing !== undefined) return existing;\n if (typeof React.createContext !== 'function') {\n // RSC environment — no contexts here. Nothing in this module runs on that\n // side; it only has to import cleanly.\n return undefined as unknown as React.Context<ParamsContextValue | null>;\n }\n const ctx = React.createContext<ParamsContextValue | null>(null);\n store[PARAMS_CTX_KEY] = ctx;\n return ctx;\n}\n\nconst ParamsContext = getOrCreateContext();\n\n/**\n * Read the params provided by the tree. Returns null when no provider is\n * above the caller — a component rendered outside a timber route, a\n * `useSegmentParams()` call from outside React entirely, or any component\n * during SSR (where the params reach the hook through the ALS-backed SSR data\n * context instead, and there is no client-owned tree to hold a provider).\n */\nexport function useParamsContext(): ParamsContextValue | null {\n return React.useContext(ParamsContext);\n}\n\n// ─── Provider ────────────────────────────────────────────────────\n\ninterface ParamsProviderProps {\n params: CoercedParams;\n slotParams: SlotParamsRecord | null;\n children?: React.ReactNode;\n}\n\n/**\n * Provides the current navigation's params to everything below it.\n *\n * Rendered only by `PayloadRoot`. Not exported: a second provider anywhere in\n * the tree would shadow this one for the region below it, which is precisely\n * the defect TIM-1297 fixed.\n *\n * The module-level snapshot in `state.ts` is written during render rather\n * than in an effect. It is the fallback path for `useSegmentParams()` called\n * outside a component (tests, module scope), and an effect would leave that\n * path reading the *previous* route's params for the whole commit — the\n * window in which a navigation's components actually run. Writing during\n * render is safe here because the value is derived entirely from props: a\n * double-invoked render in StrictMode writes the same record twice.\n */\nfunction ParamsProvider({ params, slotParams, children }: ParamsProviderProps) {\n // Restore the null prototype the wire could not carry. Flight rejects a\n // null-prototype object, so `withPublishedParams` flattens the records;\n // rebuilding them here is what keeps `params.constructor` returning\n // `undefined` instead of a function for a param the route does not define\n // (design/13-security.md #36c). Memoized on the props so a re-render with\n // the same records does not rebuild — the identity of what the hook returns\n // is load-bearing for `useEffect` dependencies (TIM-1285).\n const value = useMemo(\n () => ({\n params: toNullProtoRecord(params),\n slotParams: toNullProtoRecord(slotParams),\n }),\n [params, slotParams]\n );\n\n // Keep the out-of-component fallback in step with the tree being rendered.\n _setCurrentParams(value.params);\n _setCurrentSlotParams(value.slotParams);\n\n return createElement(ParamsContext.Provider, { value }, children);\n}\n\n// ─── Payload root ────────────────────────────────────────────────\n\n/**\n * The client's root: publishes a payload's params over the tree being shown.\n *\n * Rendered at the same position in the wrapper chain on **every** render path\n * — hydration, full navigation, partial navigation, popstate replay, shallow\n * search sync, and revalidation from a server action. Being unconditional is\n * load-bearing twice over: an element type that appears on one render and not\n * the next remounts everything below it, destroying exactly the layout state a\n * partial navigation exists to preserve; and a reader in a skipped layout has\n * to have *some* provider above it on every path or it falls back to the\n * module-level snapshot.\n *\n * `children` is the tree to display, which is not always `source`'s tree:\n *\n * - Full navigation, hydration, replay — `source` is the payload being shown,\n * and `children` is its own tree.\n * - **Partial navigation** — `children` is the *retained* tree and `source` is\n * the *incoming* payload. This is the case the whole design exists for: the\n * retained tree is not re-rendered, so the destination's params can only\n * reach it from above, and this provider is above it.\n *\n * `source` may be a thenable, in which case this suspends on the payload's\n * root row. That happens on the hydration path only, where the payload\n * promise was going to be rendered at this position anyway. Every other path\n * resolves the row in the router — inside the navigation transition — and\n * hands over a settled value, so a decode rejection surfaces where React\n * renders the tree and is caught by the error boundary *around* it, rather\n * than here, above every boundary the app has.\n */\nexport function PayloadRoot({ source, children }: { source: unknown; children?: React.ReactNode }) {\n const resolved = isThenable(source) ? use(source) : source;\n const { params, slotParams } = readPublishedParams(resolved);\n return createElement(ParamsProvider, { params, slotParams }, children);\n}\n\nfunction isThenable(value: unknown): value is Promise<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n","/**\n * useParams() — client-side hook for accessing route params.\n *\n * Returns the dynamic route parameters for the current URL.\n * When called with a route pattern argument, TypeScript narrows\n * the return type to the exact params shape for that route.\n *\n * Two layers of type narrowing work together:\n * 1. The generic overload here uses the Routes interface directly —\n * `useParams<R>()` returns `Routes[R]['segmentParams']`.\n * 2. Build-time codegen generates per-route string-literal overloads\n * in the .d.ts file for IDE autocomplete (see routing/codegen.ts).\n *\n * When the Routes interface is empty (no codegen yet), the generic\n * overload has `keyof Routes = never`, so only the fallback matches.\n *\n * During SSR, params are read from the ALS-backed SSR data context\n * (populated by ssr-entry.ts) to ensure correct per-request isolation\n * across concurrent requests with streaming Suspense.\n *\n * Reactivity: On the client, useParams() reads from ParamsContext, published\n * by the one provider the client renders above the merge point\n * (`PayloadRoot`). Params update atomically with the tree because they travel\n * on the same payload root — there is no separate channel that could be\n * seeded a render early or late (TIM-1294, TIM-1297).\n *\n * All mutable state is delegated to client/state.ts for singleton guarantees.\n * See design/18-build-system.md §\"Singleton State Registry\"\n *\n * Design doc: design/09-typescript.md §\"Typed Routes\"\n */\n\nimport type { CoercedParams } from '../shared/param-value.js';\nimport type { Routes } from '../index.js';\nimport { getSsrData } from './ssr-data.js';\nimport {\n currentParams,\n currentSlotParams,\n _setCurrentParams,\n _setCurrentSlotParams,\n paramsListeners,\n} from './state.js';\nimport { resolveSegmentParams, type SlotParamsRecord } from '../shared/slot-params.js';\nimport { useParamsContext } from './params-context.js';\n\n// ---------------------------------------------------------------------------\n// Module-level subscribe/notify pattern — kept for backward compat and tests\n// ---------------------------------------------------------------------------\n\n/**\n * Subscribe to params changes.\n * Retained for backward compatibility with tests that verify the\n * subscribe/notify contract. On the client, useParams() reads from\n * NavigationContext instead.\n */\nexport function subscribe(callback: () => void): () => void {\n paramsListeners.add(callback);\n return () => paramsListeners.delete(callback);\n}\n\n/**\n * Get the current params snapshot (module-level fallback).\n * Used by tests and by the hook when called outside a React component.\n */\nexport function getSnapshot(): CoercedParams {\n return currentParams;\n}\n\n// ---------------------------------------------------------------------------\n// Framework API — called by the segment router on each navigation\n// ---------------------------------------------------------------------------\n\n/**\n * Set the current route params in the module-level store.\n *\n * Called by the router on each navigation. This updates the fallback\n * snapshot used by tests and by the hook when called outside a React\n * component (no NavigationContext available).\n *\n * On the client, the primary reactivity path is NavigationContext —\n * the router calls setNavigationState() then renderRoot() which wraps\n * the element in NavigationProvider. setCurrentParams is still called\n * for the module-level fallback.\n *\n * During SSR, params are also available via getSsrData().params\n * (ALS-backed).\n */\nexport function setCurrentParams(params: CoercedParams): void {\n _setCurrentParams(params);\n}\n\n/**\n * Set the per-slot params snapshot in the module-level store.\n *\n * Paired with `setCurrentParams`: the router calls both on every navigation,\n * including with `null` when a response carries no slot params, so a slot's\n * params from the *previous* route cannot be read on the next one. Fill and\n * serve are paired; so are fill and clear. See TIM-1285.\n */\nexport function setCurrentSlotParams(slotParams: SlotParamsRecord | null): void {\n _setCurrentSlotParams(slotParams);\n}\n\n/**\n * Notify all legacy subscribers that params have changed.\n *\n * Retained for backward compatibility with tests. On the client,\n * the NavigationContext + renderRoot pattern replaces this — params\n * update atomically with the tree render, so explicit notification\n * is no longer needed.\n */\nexport function notifyParamsListeners(): void {\n for (const listener of paramsListeners) {\n listener();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public hook\n// ---------------------------------------------------------------------------\n\n/**\n * Read the current route's dynamic params.\n *\n * The optional `_route` argument exists only for TypeScript narrowing —\n * it does not affect the runtime return value.\n *\n * On the client, reads from ParamsContext, published by `PayloadRoot` above\n * everything the navigation renders. Params update atomically with the RSC\n * tree — no timing gap.\n *\n * During SSR, reads from the ALS-backed SSR data context to ensure\n * per-request isolation across concurrent requests with streaming Suspense.\n *\n * When called outside a React component (e.g., in test assertions),\n * falls back to the module-level snapshot.\n *\n * @overload Typed — when a known segment path is passed, returns the\n * exact params shape from the generated Routes interface.\n * @overload Fallback — returns the generic params record.\n */\nexport function useSegmentParams<R extends keyof Routes>(\n segmentPath: R\n): Routes[R] extends { segmentParams: infer P } ? P : CoercedParams;\nexport function useSegmentParams(segmentPath?: string): CoercedParams;\nexport function useSegmentParams(segmentPath?: string): CoercedParams {\n // Try the client-owned provider first. It sits above everything a navigation\n // renders, so any component on the page — initial document, full navigation,\n // or a layout the server skipped — has one above it. Absent during SSR,\n // where the ALS path below is the answer. When called outside a React\n // component, useContext throws — caught below.\n try {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- conditional on environment, not render path\n const paramsContext = useParamsContext();\n if (paramsContext !== null) {\n return resolveSegmentParams(paramsContext.params, paramsContext.slotParams, segmentPath);\n }\n } catch {\n // No React dispatcher available (called outside a component).\n // Fall through to module-level snapshot below.\n }\n\n // SSR path: read from ALS-backed SSR data context.\n // Falls back to module-level currentParams for tests.\n const ssrData = getSsrData();\n if (ssrData) return resolveSegmentParams(ssrData.params, ssrData.slotParams, segmentPath);\n return resolveSegmentParams(currentParams, currentSlotParams, segmentPath);\n}\n"],"mappings":";;;;;;AAGA,SAAS,UAAU,eAAuC;CACxD,MAAM,SAAS,gBAAgB;CAC/B,IAAI,CAAC,QAAQ,aAAa,CAAC;CAC3B,OAAO,OAAO,gBAAgB,aAAa;AAC7C;AAEA,SAAS,cAAuB;CAC9B,MAAM,SAAS,gBAAgB;CAC/B,OAAO,SAAS,OAAO,UAAU,IAAI;AACvC;AAEA,IAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;AAuB1B,SAAgB,uBAAgC;CAC9C,OAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC8CA,IAAM,cAAc,OAAO,IAAI,kBAAkB;AAEjD,SAAS,uBAAwE;CAC/E,MAAM,WAAY,WAAuC;CAGzD,IAAI,aAAa,KAAA,GAAW,OAAO;CAEnC,IAAI,OAAO,MAAM,kBAAkB,YAAY;EAC7C,MAAM,MAAM,MAAM,cAAsC,IAAI;EAC5D,WAAwC,eAAe;EACvD,OAAO;CACT;AAEF;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/content/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC"}
|
package/dist/content/index.js
DELETED
|
File without changes
|
package/src/content/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// oxlint-disable
|
|
2
|
-
// No-op shim for server-only/client-only packages.
|
|
3
|
-
// In dev mode, Vite externalizes node_modules and loads them via Node's
|
|
4
|
-
// require(). Deps like `bright` that import `server-only` would hit the
|
|
5
|
-
// real CJS package which throws. This shim replaces it with a no-op
|
|
6
|
-
// in server environments (RSC/SSR) where the import is always safe.
|