@timber-js/app 0.2.0-alpha.185 → 0.2.0-alpha.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{actions-O_LsyCE4.js → actions-C-Rw9vPc.js} +3 -3
- package/dist/_chunks/{actions-O_LsyCE4.js.map → actions-C-Rw9vPc.js.map} +1 -1
- package/dist/_chunks/als-slots-mFweg276.js +27 -0
- package/dist/_chunks/als-slots-mFweg276.js.map +1 -0
- package/dist/_chunks/base-path-DaQrzbez.js +80 -0
- package/dist/_chunks/base-path-DaQrzbez.js.map +1 -0
- package/dist/_chunks/build-manifest-DWppEdLB.js +86 -0
- package/dist/_chunks/build-manifest-DWppEdLB.js.map +1 -0
- package/dist/_chunks/build-output-helper-C3DrfzZR.js +369 -0
- package/dist/_chunks/build-output-helper-C3DrfzZR.js.map +1 -0
- package/dist/_chunks/{cache-api-B-lhk9p4.js → cache-api-Cd0VZ_Pd.js} +3 -3
- package/dist/_chunks/{cache-api-B-lhk9p4.js.map → cache-api-Cd0VZ_Pd.js.map} +1 -1
- package/dist/_chunks/cli-schema-sync-CKgHC2MB.js +1857 -0
- package/dist/_chunks/cli-schema-sync-CKgHC2MB.js.map +1 -0
- package/dist/_chunks/{cloudflare-CnT5Lr7U.js → cloudflare-Cs0uZXea.js} +89 -12
- package/dist/_chunks/{cloudflare-CnT5Lr7U.js.map → cloudflare-Cs0uZXea.js.map} +1 -1
- package/dist/_chunks/error-boundary-DpYRI_I1.js +330 -0
- package/dist/_chunks/error-boundary-DpYRI_I1.js.map +1 -0
- package/dist/_chunks/{fast-hash-D6hIVt1Y.js → fast-hash-C-tVYrLb.js} +6 -1
- package/dist/_chunks/fast-hash-C-tVYrLb.js.map +1 -0
- package/dist/_chunks/fs-identity-D7vb6GdI.js +208 -0
- package/dist/_chunks/fs-identity-D7vb6GdI.js.map +1 -0
- package/dist/_chunks/{logger-AWfuX-KJ.js → logger-N7e5auP0.js} +9 -13
- package/dist/_chunks/logger-N7e5auP0.js.map +1 -0
- package/dist/_chunks/navigation-root-B29qg0_T.js +274 -0
- package/dist/_chunks/navigation-root-B29qg0_T.js.map +1 -0
- package/dist/_chunks/param-value-C8TNYchQ.js +66 -0
- package/dist/_chunks/param-value-C8TNYchQ.js.map +1 -0
- package/dist/_chunks/{plugin-context---kTF5v8.js → plugin-context-DEGLSJs3.js} +2 -1
- package/dist/_chunks/plugin-context-DEGLSJs3.js.map +1 -0
- package/dist/_chunks/{router-ref-CtmF-aPv.js → router-ref-DuYuV_0Q.js} +2 -2
- package/dist/_chunks/router-ref-DuYuV_0Q.js.map +1 -0
- package/dist/_chunks/rsc-cache-key-DD0fl_-s.js +243 -0
- package/dist/_chunks/rsc-cache-key-DD0fl_-s.js.map +1 -0
- package/dist/_chunks/rsc-error-envelope-tT5PJs4q.js +40 -0
- package/dist/_chunks/rsc-error-envelope-tT5PJs4q.js.map +1 -0
- package/dist/_chunks/rsc-payload-path-B_LBodc2.js +48 -0
- package/dist/_chunks/rsc-payload-path-B_LBodc2.js.map +1 -0
- package/dist/_chunks/{segment-classify-Byy425ng.js → segment-classify-C539Pa2O.js} +23 -2
- package/dist/_chunks/{segment-classify-Byy425ng.js.map → segment-classify-C539Pa2O.js.map} +1 -1
- package/dist/_chunks/{canonicalize-DQHyFClh.js → segment-keys-BawYuNFO.js} +61 -2
- package/dist/_chunks/segment-keys-BawYuNFO.js.map +1 -0
- package/dist/_chunks/slot-params-BCTmZkQB.js +76 -0
- package/dist/_chunks/slot-params-BCTmZkQB.js.map +1 -0
- package/dist/_chunks/{ssr-data-BOWsq18U.js → ssr-data-14MXm7Pj.js} +17 -2
- package/dist/_chunks/ssr-data-14MXm7Pj.js.map +1 -0
- package/dist/_chunks/use-segment-params-ClyUNq4d.js +128 -0
- package/dist/_chunks/use-segment-params-ClyUNq4d.js.map +1 -0
- package/dist/_chunks/{walkers-_6zKFlch.js → walkers-BhhwI9TD.js} +21 -87
- package/dist/_chunks/walkers-BhhwI9TD.js.map +1 -0
- package/dist/adapters/build-output-helper.d.ts +37 -0
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/fs-identity.d.ts +64 -0
- package/dist/adapters/fs-identity.d.ts.map +1 -0
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +2 -3
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +57 -1
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/types.d.ts +13 -1
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cache/fast-hash.d.ts +5 -0
- package/dist/cache/fast-hash.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/hydrate.d.ts +20 -9
- package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts +4 -1
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/browser-entry/router-init.d.ts +3 -0
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/browser-entry/rsc-stream.d.ts +8 -0
- package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts +1 -0
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -162
- package/dist/client/history.d.ts +13 -6
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.js +18 -11
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +4 -3
- package/dist/client/internal.d.ts.map +1 -1
- package/dist/client/internal.js +865 -306
- package/dist/client/internal.js.map +1 -1
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/navigation-api.d.ts +2 -2
- package/dist/client/navigation-commit.d.ts +71 -0
- package/dist/client/navigation-commit.d.ts.map +1 -0
- package/dist/client/navigation-context.d.ts +37 -20
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/navigation-root.d.ts +63 -23
- package/dist/client/navigation-root.d.ts.map +1 -1
- package/dist/client/params-context.d.ts +81 -0
- package/dist/client/params-context.d.ts.map +1 -0
- package/dist/client/router-effects.d.ts +129 -0
- package/dist/client/router-effects.d.ts.map +1 -0
- package/dist/client/router-lifecycle.d.ts +55 -0
- package/dist/client/router-lifecycle.d.ts.map +1 -0
- package/dist/client/router-pipeline.d.ts +84 -0
- package/dist/client/router-pipeline.d.ts.map +1 -0
- package/dist/client/router-ref.d.ts +1 -1
- package/dist/client/router-ref.d.ts.map +1 -1
- package/dist/client/router-skew.d.ts +21 -0
- package/dist/client/router-skew.d.ts.map +1 -0
- package/dist/client/router-types.d.ts +207 -0
- package/dist/client/router-types.d.ts.map +1 -0
- package/dist/client/router.d.ts +1 -182
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +38 -25
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +79 -34
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/ssr-data.d.ts +6 -0
- package/dist/client/ssr-data.d.ts.map +1 -1
- package/dist/client/stale-client.d.ts +69 -0
- package/dist/client/stale-client.d.ts.map +1 -0
- package/dist/client/state.d.ts +10 -1
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/top-loader.d.ts +2 -1
- package/dist/client/top-loader.d.ts.map +1 -1
- package/dist/client/unload-guard.d.ts +5 -0
- package/dist/client/unload-guard.d.ts.map +1 -1
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/client/use-router.d.ts +1 -1
- package/dist/client/use-segment-params.d.ts +18 -8
- package/dist/client/use-segment-params.d.ts.map +1 -1
- package/dist/cookies/index.js +3 -3
- package/dist/cookies/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +906 -321
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts +31 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts +1 -1
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/request-dep/analysis.d.ts +106 -0
- package/dist/plugins/request-dep/analysis.d.ts.map +1 -0
- package/dist/plugins/request-dep/index.d.ts +75 -0
- package/dist/plugins/request-dep/index.d.ts.map +1 -0
- package/dist/plugins/request-dep/origin.d.ts +61 -0
- package/dist/plugins/request-dep/origin.d.ts.map +1 -0
- package/dist/plugins/routing.d.ts +9 -0
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +136 -8
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/codegen-types.d.ts +18 -0
- package/dist/routing/codegen-types.d.ts.map +1 -1
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/collision-probe.d.ts +104 -0
- package/dist/routing/collision-probe.d.ts.map +1 -0
- package/dist/routing/collision-spaces.d.ts +26 -0
- package/dist/routing/collision-spaces.d.ts.map +1 -0
- package/dist/routing/index.js +3 -3
- package/dist/routing/interception.d.ts +235 -6
- package/dist/routing/interception.d.ts.map +1 -1
- package/dist/routing/manifest-codegen.d.ts.map +1 -1
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/segment-classify.d.ts +33 -0
- package/dist/routing/segment-classify.d.ts.map +1 -1
- package/dist/routing/segment-keys.d.ts +95 -0
- package/dist/routing/segment-keys.d.ts.map +1 -0
- package/dist/routing/slot-placement.d.ts +48 -0
- package/dist/routing/slot-placement.d.ts.map +1 -0
- package/dist/routing/walkers.d.ts +6 -0
- package/dist/routing/walkers.d.ts.map +1 -1
- package/dist/search-params/define.d.ts +0 -6
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.js +176 -2
- package/dist/search-params/index.js.map +1 -1
- package/dist/segment-params/define.d.ts +0 -6
- package/dist/segment-params/define.d.ts.map +1 -1
- package/dist/segment-params/index.js +69 -1
- package/dist/segment-params/index.js.map +1 -0
- package/dist/server/actions.d.ts +6 -3
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +2 -1
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +13 -1
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/chain-url-parts.d.ts +82 -0
- package/dist/server/chain-url-parts.d.ts.map +1 -0
- package/dist/server/children-interception.d.ts +49 -0
- package/dist/server/children-interception.d.ts.map +1 -0
- package/dist/server/default-status-page.d.ts +45 -0
- package/dist/server/default-status-page.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts +14 -3
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/head-response.d.ts +35 -0
- package/dist/server/head-response.d.ts.map +1 -0
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +393 -212
- package/dist/server/internal.js.map +1 -1
- package/dist/server/param-coercion.d.ts +10 -1
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-helpers.d.ts +0 -18
- package/dist/server/pipeline-helpers.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +59 -9
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-outcome.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +11 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/publish-params.d.ts +33 -0
- package/dist/server/publish-params.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +48 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +32 -2
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +13 -0
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-cache-key-guard.d.ts +78 -0
- package/dist/server/rsc-cache-key-guard.d.ts.map +1 -0
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +14 -2
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +2 -10
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +3 -2
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +3 -2
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +2 -0
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/skippable-prefix.d.ts +23 -0
- package/dist/server/skippable-prefix.d.ts.map +1 -0
- package/dist/server/slot-interception.d.ts +80 -0
- package/dist/server/slot-interception.d.ts.map +1 -0
- package/dist/server/slot-resolver.d.ts +70 -8
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-bridge-types.d.ts +6 -0
- package/dist/server/ssr-bridge-types.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-wrappers.d.ts +24 -13
- package/dist/server/ssr-wrappers.d.ts.map +1 -1
- package/dist/server/state-tree-diff.d.ts +6 -27
- package/dist/server/state-tree-diff.d.ts.map +1 -1
- package/dist/server/static-generator.d.ts +6 -0
- package/dist/server/static-generator.d.ts.map +1 -1
- package/dist/server/static-not-found.d.ts +52 -0
- package/dist/server/static-not-found.d.ts.map +1 -0
- package/dist/shared/als-slots.d.ts +41 -0
- package/dist/shared/als-slots.d.ts.map +1 -0
- package/dist/shared/base-path.d.ts +56 -0
- package/dist/shared/base-path.d.ts.map +1 -0
- package/dist/shared/param-value.d.ts +80 -0
- package/dist/shared/param-value.d.ts.map +1 -0
- package/dist/shared/payload-root.d.ts +108 -0
- package/dist/shared/payload-root.d.ts.map +1 -0
- package/dist/shared/rsc-cache-key.d.ts +163 -0
- package/dist/shared/rsc-cache-key.d.ts.map +1 -0
- package/dist/shared/rsc-error-envelope.d.ts +25 -0
- package/dist/shared/rsc-error-envelope.d.ts.map +1 -0
- package/dist/shared/rsc-manifest.d.ts +28 -0
- package/dist/shared/rsc-manifest.d.ts.map +1 -0
- package/dist/shared/rsc-payload-path.d.ts +42 -0
- package/dist/shared/rsc-payload-path.d.ts.map +1 -0
- package/dist/shared/segment-info.d.ts +59 -0
- package/dist/shared/segment-info.d.ts.map +1 -0
- package/dist/shared/slot-params.d.ts +51 -0
- package/dist/shared/slot-params.d.ts.map +1 -0
- package/dist/shared/static-platform-files.d.ts +71 -0
- package/dist/shared/static-platform-files.d.ts.map +1 -0
- package/docs/api/31-api-client.mdx +4 -2
- package/docs/learn/02-pages-and-layouts.mdx +1 -1
- package/docs/learn/11-error-handling.mdx +2 -0
- package/docs/learn/12-client-navigation.mdx +2 -2
- package/docs/learn/14-deploying.mdx +23 -0
- package/docs/more/01-advanced-routing.mdx +172 -2
- package/docs/more/04-metadata-and-fonts.mdx +1 -1
- package/package.json +2 -2
- package/src/adapters/build-output-helper.ts +116 -3
- package/src/adapters/cloudflare.ts +86 -11
- package/src/adapters/fs-identity.ts +156 -0
- package/src/adapters/nitro.ts +6 -6
- package/src/adapters/shared.ts +196 -21
- package/src/adapters/types.ts +13 -1
- package/src/cache/fast-hash.ts +5 -0
- package/src/client/browser-entry/action-dispatch.ts +9 -4
- package/src/client/browser-entry/hydrate.ts +40 -29
- package/src/client/browser-entry/index.ts +15 -1
- package/src/client/browser-entry/post-hydration.ts +10 -9
- package/src/client/browser-entry/router-init.ts +104 -48
- package/src/client/browser-entry/rsc-stream.ts +11 -2
- package/src/client/error-boundary.tsx +20 -15
- package/src/client/history.ts +13 -6
- package/src/client/internal.ts +4 -3
- package/src/client/link.tsx +55 -8
- package/src/client/navigation-api.ts +3 -3
- package/src/client/navigation-commit.ts +174 -0
- package/src/client/navigation-context.ts +40 -67
- package/src/client/navigation-root.tsx +326 -101
- package/src/client/params-context.ts +192 -0
- package/src/client/router-effects.ts +231 -0
- package/src/client/router-lifecycle.ts +288 -0
- package/src/client/router-pipeline.ts +389 -0
- package/src/client/router-ref.ts +1 -1
- package/src/client/router-skew.ts +30 -0
- package/src/client/router-types.ts +230 -0
- package/src/client/router.ts +242 -707
- package/src/client/rsc-fetch.ts +169 -102
- package/src/client/segment-cache.ts +121 -44
- package/src/client/ssr-data.ts +6 -0
- package/src/client/stale-client.ts +191 -0
- package/src/client/state.ts +14 -1
- package/src/client/top-loader.tsx +2 -1
- package/src/client/unload-guard.ts +34 -2
- package/src/client/use-cookie.ts +9 -2
- package/src/client/use-router.ts +1 -1
- package/src/client/use-segment-params.ts +41 -18
- package/src/index.ts +5 -1
- package/src/plugin-context.ts +32 -0
- package/src/plugins/adapter-build.ts +4 -0
- package/src/plugins/build-manifest.ts +34 -13
- package/src/plugins/entries.ts +4 -0
- package/src/plugins/fonts.ts +11 -8
- package/src/plugins/request-dep/analysis.ts +447 -0
- package/src/plugins/request-dep/index.ts +376 -0
- package/src/plugins/request-dep/origin.ts +310 -0
- package/src/plugins/routing.ts +59 -2
- package/src/plugins/static-build.ts +315 -73
- package/src/routing/codegen-types.ts +18 -0
- package/src/routing/codegen.ts +50 -10
- package/src/routing/collision-probe.ts +438 -0
- package/src/routing/collision-spaces.ts +281 -0
- package/src/routing/interception.ts +896 -50
- package/src/routing/manifest-codegen.ts +5 -3
- package/src/routing/scanner.ts +114 -89
- package/src/routing/segment-classify.ts +57 -0
- package/src/routing/segment-keys.ts +146 -0
- package/src/routing/slot-placement.ts +97 -0
- package/src/routing/walkers.ts +8 -0
- package/src/search-params/define.ts +6 -29
- package/src/segment-params/define.ts +4 -27
- package/src/server/action-handler.ts +3 -1
- package/src/server/actions.ts +6 -3
- package/src/server/als-registry.ts +2 -1
- package/src/server/build-manifest.ts +14 -1
- package/src/server/chain-url-parts.ts +163 -0
- package/src/server/children-interception.ts +115 -0
- package/src/server/default-status-page.ts +127 -0
- package/src/server/deny-renderer.ts +81 -20
- package/src/server/head-response.ts +54 -0
- package/src/server/param-coercion.ts +48 -18
- package/src/server/pipeline-helpers.ts +0 -45
- package/src/server/pipeline-interception.ts +81 -32
- package/src/server/pipeline-outcome.ts +2 -4
- package/src/server/pipeline-phases.ts +68 -16
- package/src/server/pipeline.ts +57 -10
- package/src/server/prebuilt-runtime.ts +4 -4
- package/src/server/publish-params.ts +42 -0
- package/src/server/request-context.ts +97 -18
- package/src/server/route-element-builder.ts +89 -98
- package/src/server/route-handler.ts +8 -8
- package/src/server/route-matcher.ts +21 -9
- package/src/server/rsc-cache-key-guard.ts +170 -0
- package/src/server/rsc-entry/api-handler.ts +6 -8
- package/src/server/rsc-entry/error-renderer.ts +64 -25
- package/src/server/rsc-entry/helpers.ts +31 -16
- package/src/server/rsc-entry/index.ts +36 -28
- package/src/server/rsc-entry/render-route.ts +9 -4
- package/src/server/rsc-entry/revalidate-renderer.ts +1 -1
- package/src/server/rsc-entry/rsc-payload.ts +14 -25
- package/src/server/rsc-entry/rsc-stream.ts +4 -3
- package/src/server/rsc-entry/ssr-renderer.ts +13 -9
- package/src/server/skippable-prefix.ts +92 -0
- package/src/server/slot-interception.ts +168 -0
- package/src/server/slot-resolver.ts +253 -156
- package/src/server/ssr-bridge-types.ts +6 -0
- package/src/server/ssr-entry.ts +12 -4
- package/src/server/ssr-wrappers.tsx +33 -32
- package/src/server/state-tree-diff.ts +14 -55
- package/src/server/static-generator.ts +65 -27
- package/src/server/static-not-found.ts +134 -0
- package/src/shared/als-slots.ts +72 -0
- package/src/shared/base-path.ts +80 -0
- package/src/shared/param-value.ts +244 -0
- package/src/shared/payload-root.ts +151 -0
- package/src/shared/rsc-cache-key.ts +269 -0
- package/src/shared/rsc-error-envelope.ts +31 -0
- package/src/shared/rsc-manifest.ts +29 -0
- package/src/shared/rsc-payload-path.ts +45 -0
- package/src/shared/segment-info.ts +60 -0
- package/src/shared/slot-params.ts +111 -0
- package/src/shared/static-platform-files.ts +75 -0
- package/dist/_chunks/build-output-helper-DOGYFb_X.js +0 -196
- package/dist/_chunks/build-output-helper-DOGYFb_X.js.map +0 -1
- package/dist/_chunks/canonicalize-DQHyFClh.js.map +0 -1
- package/dist/_chunks/cli-schema-sync-BTWEKJXo.js +0 -668
- package/dist/_chunks/cli-schema-sync-BTWEKJXo.js.map +0 -1
- package/dist/_chunks/define-COtkxMRT.js +0 -191
- package/dist/_chunks/define-COtkxMRT.js.map +0 -1
- package/dist/_chunks/define-c4au4I9R.js +0 -82
- package/dist/_chunks/define-c4au4I9R.js.map +0 -1
- package/dist/_chunks/fast-hash-D6hIVt1Y.js.map +0 -1
- package/dist/_chunks/logger-AWfuX-KJ.js.map +0 -1
- package/dist/_chunks/navigation-root-bUDZLw74.js +0 -124
- package/dist/_chunks/navigation-root-bUDZLw74.js.map +0 -1
- package/dist/_chunks/plugin-context---kTF5v8.js.map +0 -1
- package/dist/_chunks/router-ref-CtmF-aPv.js.map +0 -1
- package/dist/_chunks/ssr-data-BOWsq18U.js.map +0 -1
- package/dist/_chunks/use-segment-params-D1CzlgBo.js +0 -151
- package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +0 -1
- package/dist/_chunks/walkers-_6zKFlch.js.map +0 -1
- package/dist/client/error-boundary.js.map +0 -1
- package/dist/plugins/request-dep.d.ts +0 -32
- package/dist/plugins/request-dep.d.ts.map +0 -1
- package/src/plugins/request-dep.ts +0 -499
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform files the static build is allowed to overwrite in the output.
|
|
3
|
+
*
|
|
4
|
+
* The build merges two trees into the deployed directory — the client bundle
|
|
5
|
+
* (which carries everything the user put in `public/`) and the pre-rendered
|
|
6
|
+
* site. That merge otherwise refuses overlaps, because a silent overwrite
|
|
7
|
+
* leaves one of two artifacts deployed with nothing recording which
|
|
8
|
+
* (TIM-1266).
|
|
9
|
+
*
|
|
10
|
+
* These names are the exception, and only because the pre-rendered copy is
|
|
11
|
+
* *derived from* the one it replaces rather than competing with it:
|
|
12
|
+
* `plugins/static-build.ts` reads `public/_redirects` and writes the
|
|
13
|
+
* generated rules plus the user's, so the winner is a superset of the loser.
|
|
14
|
+
*
|
|
15
|
+
* That holds only for a file the current pass produced, which is why
|
|
16
|
+
* `cleanConditionalArtifacts` deletes a previous build's `_redirects` before
|
|
17
|
+
* generation: written only when a pass finds redirects, it would otherwise
|
|
18
|
+
* survive into a pass that produced nothing and claim an exemption it no
|
|
19
|
+
* longer earns.
|
|
20
|
+
*
|
|
21
|
+
* `_headers` is NOT here. It is not written into the pre-rendered tree at
|
|
22
|
+
* all — adapters generate it directly into the output, folding in the
|
|
23
|
+
* user's copy as they go (TIM-1326).
|
|
24
|
+
*
|
|
25
|
+
* Declared once so the code that performs the merge and the code that
|
|
26
|
+
* produces the merged file cannot disagree about which names are exempt.
|
|
27
|
+
*
|
|
28
|
+
* Isomorphic: no server, client, or build-time imports.
|
|
29
|
+
*/
|
|
30
|
+
/** Platform redirect rules (Cloudflare Pages, Netlify). See TIM-1245/TIM-1249. */
|
|
31
|
+
export declare const REDIRECTS_FILE = "_redirects";
|
|
32
|
+
/** Platform header rules (Cloudflare Pages, Netlify). See TIM-1241/TIM-1326. */
|
|
33
|
+
export declare const HEADERS_FILE = "_headers";
|
|
34
|
+
/**
|
|
35
|
+
* Where a user authors platform files. Stated once because two modules read
|
|
36
|
+
* from here — `plugins/static-build.ts` for `_redirects`, adapters for
|
|
37
|
+
* `_headers` — and they must look in the same place.
|
|
38
|
+
*
|
|
39
|
+
* Both read the **project source**, never the build output. The generated
|
|
40
|
+
* file lands under the same name in the output directory, so a reader aimed
|
|
41
|
+
* there would fold the previous build's generated rules back in and compound
|
|
42
|
+
* them on every rebuild.
|
|
43
|
+
*/
|
|
44
|
+
export declare const USER_PLATFORM_DIR = "public";
|
|
45
|
+
/** Output-relative paths whose pre-rendered copy subsumes the `public/` one. */
|
|
46
|
+
export declare const USER_MERGED_PLATFORM_FILES: readonly string[];
|
|
47
|
+
/**
|
|
48
|
+
* Output paths the framework writes itself, which no route may claim.
|
|
49
|
+
*
|
|
50
|
+
* These are written outside the per-entry writer — `_redirects` after
|
|
51
|
+
* generation, `_headers` by the adapter after the copy — so the collision
|
|
52
|
+
* tracker never sees them and a route rendering to one of these paths is
|
|
53
|
+
* overwritten with nothing recording it.
|
|
54
|
+
*
|
|
55
|
+
* Reserved rather than tracked, because there is no version of "serve a route
|
|
56
|
+
* at `/_headers`" that works: Cloudflare Pages and Netlify read these two
|
|
57
|
+
* files themselves and never serve them, so the route is unservable however
|
|
58
|
+
* the conflict is resolved.
|
|
59
|
+
*
|
|
60
|
+
* That justification is per-file, not per-mechanism. `.nojekyll` is written
|
|
61
|
+
* the same way and is deliberately NOT here: only the `github-pages` target
|
|
62
|
+
* writes it, and everywhere else `/.nojekyll` is an ordinary servable path,
|
|
63
|
+
* so reserving it globally would refuse a valid Cloudflare site. Its write
|
|
64
|
+
* site skips the write when a file is already there instead — GitHub Pages
|
|
65
|
+
* only cares that the file exists.
|
|
66
|
+
*
|
|
67
|
+
* Same reasoning as the synthetic 404 entry using an internal urlPath so a
|
|
68
|
+
* real `/404` route cannot collide with `404.html`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const RESERVED_OUTPUT_PATHS: readonly string[];
|
|
71
|
+
//# sourceMappingURL=static-platform-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-platform-files.d.ts","sourceRoot":"","sources":["../../src/shared/static-platform-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,kFAAkF;AAClF,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,gFAAgF;AAChF,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAqB,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAmC,CAAC"}
|
|
@@ -28,7 +28,7 @@ import { Link } from '@timber-js/app/client';
|
|
|
28
28
|
| ------------ | ------------------- | ------------------------------------------- |
|
|
29
29
|
| `href` | `string` | Target URL (type-checked against route map) |
|
|
30
30
|
| `replace` | `boolean` | Use `replaceState` instead of `pushState` |
|
|
31
|
-
| `prefetch` | `boolean` | Prefetch on hover
|
|
31
|
+
| `prefetch` | `boolean` | Prefetch the RSC payload on hover |
|
|
32
32
|
| `onNavigate` | `OnNavigateHandler` | Intercept navigation before routing |
|
|
33
33
|
|
|
34
34
|
### `<TimberErrorBoundary>`
|
|
@@ -60,6 +60,8 @@ router.forward();
|
|
|
60
60
|
| `back()` | Go back |
|
|
61
61
|
| `forward()` | Go forward |
|
|
62
62
|
|
|
63
|
+
If the server answers a navigation or a `refresh()` with an error, the router hands the URL back to the server as a full page load so it can render the error page as HTML with the right status code. That applies to back/forward too. None of these methods report the failure to your code — there is nothing to catch, and nothing to render a fallback for.
|
|
64
|
+
|
|
63
65
|
### `usePathname()`
|
|
64
66
|
|
|
65
67
|
Returns the current pathname as a string.
|
|
@@ -97,7 +99,7 @@ const pending = usePendingNavigation();
|
|
|
97
99
|
Per-link pending state. Must be used inside a `<Link>` component's children.
|
|
98
100
|
|
|
99
101
|
```tsx
|
|
100
|
-
const {
|
|
102
|
+
const { isPending } = useLinkStatus();
|
|
101
103
|
```
|
|
102
104
|
|
|
103
105
|
### `useSegmentParams(segmentPath?)`
|
|
@@ -140,7 +140,7 @@ app/
|
|
|
140
140
|
timber produces build errors for ambiguous route configurations:
|
|
141
141
|
|
|
142
142
|
- **Duplicate convention files** — `page.tsx` and `page.jsx` in the same directory is an error, not a silent winner-by-filesystem-order
|
|
143
|
-
- **Route
|
|
143
|
+
- **Route collisions** — two pages (or a page and a `route.ts`) that answer the same URL are caught at build time. Routes are compared by the URLs they match, not by how they are spelled: `x/(a)/[id]/page.tsx` and `x/(b)/[slug]/page.tsx` collide, and so do `x/(a)/page.tsx` and `x/(b)/[[...rest]]/page.tsx`, since an optional catch-all also matches with zero segments. Different segment _kinds_ don't collide — `[id]` beside `[...rest]` is ordered deterministically and keeps building
|
|
144
144
|
|
|
145
145
|
This behavior is deterministic regardless of filesystem `readdir` order. In Next.js, the result of these ambiguities depends on the OS and filesystem, which can produce different behavior between local development and CI.
|
|
146
146
|
|
|
@@ -73,6 +73,8 @@ Priority order (innermost to outermost):
|
|
|
73
73
|
3. `error.tsx` — catches anything unmatched
|
|
74
74
|
4. Parent segments → framework default
|
|
75
75
|
|
|
76
|
+
If nothing in the chain matches, timber renders a built-in status page: a plain document with the status code and its reason phrase, and nothing else — no request URL, no error message. It is what a static build writes to `404.html` when your app has no not-found page, so a static deploy always ships one. Add a root `app/404.tsx` (or `4xx.tsx` / `error.tsx`) to replace it.
|
|
77
|
+
|
|
76
78
|
## `error.tsx`
|
|
77
79
|
|
|
78
80
|
The general error boundary. It's a client component:
|
|
@@ -93,8 +93,8 @@ Track per-link pending state during navigation:
|
|
|
93
93
|
import { Link, useLinkStatus } from '@timber-js/app/client';
|
|
94
94
|
|
|
95
95
|
function NavItemInner({ children }: { children: React.ReactNode }) {
|
|
96
|
-
const {
|
|
97
|
-
return <span className={
|
|
96
|
+
const { isPending } = useLinkStatus();
|
|
97
|
+
return <span className={isPending ? 'opacity-50' : ''}>{children}</span>;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export function NavItem({ href, children }: { href: string; children: React.ReactNode }) {
|
|
@@ -200,6 +200,29 @@ export default {
|
|
|
200
200
|
|
|
201
201
|
Pre-renders every route to HTML at build time. Add `clientJavascript: false` for zero-JavaScript output. Deploy to any static file host — S3, CloudFront, Cloudflare Pages, GitHub Pages, Netlify, or any HTTP server.
|
|
202
202
|
|
|
203
|
+
### Serving from a sub-path
|
|
204
|
+
|
|
205
|
+
To deploy under a path instead of a domain root — `https://user.github.io/repo/` on GitHub Pages, for example — set Vite's `base`:
|
|
206
|
+
|
|
207
|
+
```ts title="vite.config.ts"
|
|
208
|
+
export default defineConfig({
|
|
209
|
+
base: '/repo/',
|
|
210
|
+
plugins: [timber()],
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Every URL timber emits picks up the prefix: client assets, fonts, and the RSC payloads behind client-side navigation.
|
|
215
|
+
|
|
216
|
+
Your own links are not rewritten. `base` prefixes emitted assets, not application URLs, so an `href` must include the prefix itself:
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
<Link href={`${import.meta.env.BASE_URL}about`}>About</Link>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
A plain `href="/about"` points at the domain root, outside your deployment.
|
|
223
|
+
|
|
224
|
+
A relative base (`'./'`) can't tell timber where the site lives, so payload URLs fall back to the domain root and client-side navigation degrades to full page loads on a sub-path deployment. The build warns when it sees one — use an absolute base like `'/repo/'`.
|
|
225
|
+
|
|
203
226
|
## CDN Integration
|
|
204
227
|
|
|
205
228
|
timber.js provides typed helpers for CDN caching headers and tag-based purging. CDN caching is always developer-elected — the framework never sets cache headers automatically.
|
|
@@ -112,11 +112,28 @@ export default function DashboardLayout({
|
|
|
112
112
|
|
|
113
113
|
Slots don't add URL depth. Each slot independently matches the current URL and can have its own `access.ts`, `error.tsx`, and layouts. If a slot's access check fails, the slot degrades gracefully — the rest of the page is unaffected (see [Access Control](/docs/access-control)).
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
**A slot cannot be nested inside another slot.** Slots are resolved for segments on the matched route chain, and a slot's own subtree is not on that chain — so a nested slot could never render, and the build rejects it:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
app/dashboard/layout.tsx ← receives { children, sidebar }
|
|
119
|
+
app/dashboard/@sidebar/page.tsx ✓
|
|
120
|
+
app/dashboard/settings/layout.tsx ← receives { children, panel }
|
|
121
|
+
app/dashboard/settings/@panel/page.tsx ✓ a second slot deeper on the main chain
|
|
122
|
+
app/dashboard/@sidebar/@panel/page.tsx ✗ build error — nested inside @sidebar
|
|
123
|
+
app/dashboard/@sidebar/settings/@panel/... ✗ build error — same, further down
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This is a build error rather than a documented limit because nothing at request time could tell you: a slot that never rendered looks exactly like a slot that simply didn't match. Put the second slot on a segment of the main route chain instead.
|
|
127
|
+
|
|
128
|
+
Note the `layout.tsx` beside each slot. A slot is handed to its owning segment's layout as a named prop, so **the owner must have one** — `app/dashboard/@sidebar/` with no `app/dashboard/layout.tsx` has nothing to be passed to and never renders. That case is dead in the same way as a nested slot, and the build does not currently catch it.
|
|
129
|
+
|
|
130
|
+
Each slot is also its own collision space: a slot page sharing a URL with the parent page is the point of parallel routes, but two pages inside one slot that answer the same URL (`@side/(a)/x/page.tsx` + `@side/(b)/x/page.tsx`) fail the build, just like the same collision outside a slot. Interceptors that start at the same URL are their own space on the same principle — see [Intercepting routes](#intercepting-routes).
|
|
131
|
+
|
|
132
|
+
Every collision space is checked the same way: routes are compared by the URLs they match rather than by how they are spelled, so `(a)/[id]` and `(b)/[slug]` collide even though their paths read differently, and a page collides with an optional catch-all beside it because `[[...rest]]` also matches with zero segments. Segment kinds stay distinct — `[id]` beside `[...rest]`, or an affixed `img-[id]` beside a bare `[slug]`, are ordered deterministically and keep building.
|
|
116
133
|
|
|
117
134
|
## Intercepting Routes
|
|
118
135
|
|
|
119
|
-
Intercepting routes show a different component on soft navigation (client-side link click) vs hard navigation (direct URL).
|
|
136
|
+
Intercepting routes show a different component on soft navigation (client-side link click) vs hard navigation (direct URL).
|
|
120
137
|
|
|
121
138
|
| Marker | Meaning |
|
|
122
139
|
| ---------- | ------------- |
|
|
@@ -125,6 +142,159 @@ Intercepting routes show a different component on soft navigation (client-side l
|
|
|
125
142
|
| `(..)(..)` | Two levels up |
|
|
126
143
|
| `(...)` | Root level |
|
|
127
144
|
|
|
145
|
+
Where you put the intercepting directory picks between two behaviours.
|
|
146
|
+
|
|
147
|
+
**Inside a parallel slot → modal overlay.** The slot renders the intercepting page on top; the page you came from stays mounted behind it.
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
app/feed/@modal/(.)photo/[id]/page.tsx ← soft nav: modal over the feed
|
|
151
|
+
app/feed/photo/[id]/page.tsx ← hard nav: the full page
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**As a plain child of a segment or route group → sibling layout swap.** No overlay and no slot: the intercepting page replaces the content of *its own* directory's layout chain. This is how two route groups can serve one URL with different layouts.
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
app/(landing)/layout.tsx
|
|
158
|
+
app/(landing)/[artistSlug]/[year]/page.tsx ← hard nav renders this
|
|
159
|
+
app/(browse)/layout.tsx
|
|
160
|
+
app/(browse)/(...)[artistSlug]/[year]/page.tsx ← soft nav from inside (browse) renders this
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Navigate directly to `/grateful-dead/1977` and you get `(landing)`'s page under `(landing)`'s layout. Click a link to it from anywhere inside `(browse)` and you stay in `(browse)`'s layout with the intercepting page beneath it. Unlike the modal shape, the intercepting page's params come from the URL you navigated to, so `getSegmentParams()` works exactly as it does on a canonical route.
|
|
164
|
+
|
|
165
|
+
An intercepting directory must be a **direct** child of one or the other. A marker one directory deeper inside a slot, or nested inside another intercepting subtree, would match the navigation and then have nothing to render — the build fails naming the directory rather than silently serving the wrong page.
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
app/feed/@modal/(.)photo/[id]/page.tsx ✓ modal overlay
|
|
169
|
+
app/feed/(.)photo/[id]/page.tsx ✓ layout swap (feed/layout.tsx required)
|
|
170
|
+
app/(browse)/(...)photo/[id]/page.tsx ✓ layout swap, scoped to (browse)
|
|
171
|
+
app/feed/@modal/(x)/(.)photo/page.tsx ✗ build error — not a direct slot child
|
|
172
|
+
app/feed/(.)a/(.)b/page.tsx ✗ build error — nested interception
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Outside a slot, the directory holding the marker must have a `layout.tsx`. That is the directory the swap is scoped to, and the browser reports which directories it has mounted from its layouts — a scope it cannot report would let the swap fire once and then quietly stop. In practice you already have one, since rendering inside that layout is the point.
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
app/(browse)/layout.tsx ✓ required
|
|
179
|
+
app/(browse)/(...)photo/[id]/page.tsx
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Also outside a slot, every directory above the marker must be a static segment or a route group. The swapped page renders its own layouts against the URL you navigated to, and that URL carries no values for params declared above the marker — so a dynamic ancestor is a build error rather than a layout that renders with a missing param. Put the same interception in a slot if you need one: the modal shape re-matches the source route, which supplies them.
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
app/(browse)/(...)photo/[id]/page.tsx ✓
|
|
186
|
+
app/docs/guides/(.)[id]/page.tsx ✓
|
|
187
|
+
app/[team]/(..)photo/[id]/page.tsx ✗ build error — [team] is above the marker
|
|
188
|
+
app/[team]/@modal/(.)photo/[id]/page.tsx ✓ a slot supplies [team] from the source route
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Two pages that intercept the same URL are a build error when both sit under interceptors that **start at the same URL** — the set timber resolves in one pass. Route groups are transparent here just as they are elsewhere, so two of them under one marker both claim the same target; and two markers that compute the same starting point are the same case one level up. Either way, which page renders would come down to the order the filesystem happens to list them in.
|
|
192
|
+
|
|
193
|
+
Pages are compared by the URLs they match, not by how you spell them — so param names don't make two dynamic segments different, and an optional catch-all also matches with *zero* segments.
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
app/feed/(.)photo/(a)/page.tsx ✗ build error — both intercept /feed/photo
|
|
197
|
+
app/feed/(.)photo/(b)/page.tsx
|
|
198
|
+
|
|
199
|
+
app/feed/(.)photo/(a)/[id]/page.tsx ✗ build error — [id] and [slug] match the same URLs
|
|
200
|
+
app/feed/(.)photo/(b)/[slug]/page.tsx
|
|
201
|
+
|
|
202
|
+
app/feed/(.)photo/(a)/page.tsx ✗ build error — [[...rest]] also matches zero segments,
|
|
203
|
+
app/feed/(.)photo/(b)/[[...rest]]/page.tsx so it claims /feed/photo too
|
|
204
|
+
|
|
205
|
+
app/feed/(.)photo/page.tsx ✓ a page plus a tail — the page always wins
|
|
206
|
+
app/feed/(.)photo/[[...rest]]/page.tsx /feed/photo, the catch-all takes the rest
|
|
207
|
+
|
|
208
|
+
app/feed/(.)photo/(x)/a/page.tsx ✓ different URLs
|
|
209
|
+
app/feed/(.)photo/(y)/b/page.tsx
|
|
210
|
+
|
|
211
|
+
app/feed/(.)photo/(x)/[id]/page.tsx ✓ different kinds — a single segment always
|
|
212
|
+
app/feed/(.)photo/(y)/[...rest]/page.tsx beats a catch-all, so this is unambiguous
|
|
213
|
+
|
|
214
|
+
app/feed/@modal/(.)[a]/page.tsx ✗ build error — two markers, one starting point,
|
|
215
|
+
app/feed/@modal/(.)[b]/page.tsx same kind: nothing separates them
|
|
216
|
+
|
|
217
|
+
app/feed/@modal/(.)photo/[id]/page.tsx ✓ same starting point, different kinds — the
|
|
218
|
+
app/feed/@modal/(.)[albumSlug]/page.tsx literal `photo` wins, everything else the second
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
A route group is transparent for matching, so putting a page inside one does not give it a URL of its own:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
app/feed/(.)photo/page.tsx ✗ build error — both are /feed/photo, so the
|
|
225
|
+
app/feed/(.)photo/(a)/page.tsx one in the group could never render
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Interceptors that start at **different** URLs stay legal even when they target one page — `(.)x` beside `(..)x`, or interceptors in two different slots. Those are separate spaces, and the resolver orders them (deepest marker first).
|
|
229
|
+
|
|
230
|
+
### Dynamic intercepted segments
|
|
231
|
+
|
|
232
|
+
The marker is a prefix on an ordinary segment name, so the name after it uses the same bracket syntax as anywhere else:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
app/gallery/@modal/(.)photo/[id]/page.tsx # intercepts /gallery/photo/{id}
|
|
236
|
+
app/gallery/@modal/(.)[albumSlug]/page.tsx # intercepts /gallery/{albumSlug}
|
|
237
|
+
app/gallery/@modal/(.)[...rest]/page.tsx # intercepts the whole tail
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Intercepting siblings in one slot follow the usual priority — static, then dynamic, then catch-all — so `(.)photo/[id]` and `(.)[albumSlug]` can live in the same `@modal` without ambiguity.
|
|
241
|
+
|
|
242
|
+
Two affixed interceptors are the one case priority cannot separate: `(.)a-[id]` and `(.)[slug]-b` both match `/gallery/a-b` with the same combined affix length, so which modal opened would come down to filesystem order. That fails the build, exactly as it does for ordinary affixed siblings.
|
|
243
|
+
|
|
244
|
+
One placement fails the build: an interception whose intercepted level lands below a catch-all. Markers count URL segments, and a catch-all matches a number of them that changes per request, so "same level as `/docs/[...path]`" has no fixed position in `/docs/a/b/c`. Such an interception would fire only when the catch-all consumed exactly one segment and be silently dropped otherwise, so timber names the directory in a build error instead. Climbing past the catch-all avoids it:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
app/docs/[...path]/@modal/(.)photo/[id]/page.tsx ✗ build error
|
|
248
|
+
app/docs/[...path]/@modal/(..)photo/[id]/page.tsx ✓ (..) climbs past it, basing at /docs
|
|
249
|
+
app/docs/[...path]/@modal/(...)photo/[id]/page.tsx ✓ (...) bases at the root
|
|
250
|
+
app/[artistSlug]/@modal/(.)photo/[id]/page.tsx ✓ a dynamic segment is one URL part
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
A catch-all inside an intercepting route must also be the last segment — nothing below a catch-all can ever match, and the rewrite generated for the unreachable page would hijack the navigation with nothing to render:
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
app/feed/@modal/(.)[...rest]/page.tsx ✓
|
|
257
|
+
app/feed/@modal/(.)photo/[...rest]/page.tsx ✓
|
|
258
|
+
app/feed/@modal/(.)[...rest]/child/page.tsx ✗ build error — child is unreachable
|
|
259
|
+
app/feed/@modal/(.)photo/[...rest]/child/page.tsx ✗ build error — same, one level down
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Params in intercepting directories
|
|
263
|
+
|
|
264
|
+
A dynamic intercepted segment binds a param like any other, so the ordinary param rules apply to it:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
app/feed/@modal/(.)[id]/[id]/page.tsx ✗ build error — duplicate param name
|
|
268
|
+
app/feed/@modal/(.)[albumSlug]/[id]/... ✓
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Params inside an intercepting page
|
|
272
|
+
|
|
273
|
+
This section is about the **modal** shape. A layout-swap interception has nothing special going on: its chain is the main route, so `getSegmentParams()` returns the URL's params everywhere in it, exactly as on a canonical route.
|
|
274
|
+
|
|
275
|
+
Inside a slot, `getSegmentParams()` returns **the intercepted route's** params — what the page's own directories declare:
|
|
276
|
+
|
|
277
|
+
```tsx title="app/gallery/@modal/(.)photo/[id]/page.tsx"
|
|
278
|
+
export default async function PhotoModal() {
|
|
279
|
+
const { id } = getSegmentParams(); // the photo's id, not the gallery's params
|
|
280
|
+
return <Modal photo={await getPhoto(id)} />;
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
That is worth stating because the request itself is matched against the *source* route (`/gallery`) — the page still rendering behind the modal. The modal's own params are scoped to it, and the source page underneath keeps reading its own.
|
|
285
|
+
|
|
286
|
+
This is the general slot rule: inside a parallel slot, a no-arg `getSegmentParams()` returns that slot's own params merged over the main route's — the same value as passing the slot's segment path explicitly. Params the slot re-derives win, so a slot that reads a URL part as `[...year]` gets `string[]` even when the main route read it as `[year]`.
|
|
287
|
+
|
|
288
|
+
### Scope
|
|
289
|
+
|
|
290
|
+
An interception fires only when the departing page renders the directory that owns it — the slot's parent for a modal, the marker's own parent for a layout swap. For `app/feed/@modal/(.)photo/`, that directory is `/feed`: clicking a photo link from `/feed` or `/feed/trending` opens the modal; clicking one from `/settings` does not.
|
|
291
|
+
|
|
292
|
+
Route groups count here even though they are invisible in the URL. Anything owned by `app/(browse)/` is scoped to `(browse)`, so a navigation starting in a sibling `(landing)` group renders the normal route, not the interception — that is what makes the layout-swap shape work. A directory at the app root is scoped to the root, which every page renders, which is why `(...)` at the root intercepts from anywhere.
|
|
293
|
+
|
|
294
|
+
**When two interceptions both apply, the innermost one wins.** A directory and a directory beneath it may each hold a marker for the same URL, and a page inside the inner one renders both — so `app/feed/(.)photo/` and `app/feed/(a)/(.)photo/` both qualify for a click made inside `(a)`. The one scoped to `(a)` renders, on the same reasoning that a `(.)` marker beats a `(...)` one beside it: the more local directory is the more specific statement. Directories that are *not* on one chain — `(a)` beside `(b)` — never both qualify, so they stay independent.
|
|
295
|
+
|
|
296
|
+
Because scope depends on where the click starts, so does a prefetch: `<Link prefetch>` fetches the variant for the page the link is on, and the cached payload is only used by a click that starts there. Hovering an intercepting link gets you the modal; the same URL prefetched from elsewhere stays the full page.
|
|
297
|
+
|
|
128
298
|
## API Routes
|
|
129
299
|
|
|
130
300
|
Export HTTP method handlers from `route.ts`:
|
|
@@ -91,7 +91,7 @@ If you declare `openGraph.images` in your metadata, both auto-linked tags are su
|
|
|
91
91
|
|
|
92
92
|
`favicon.tsx` lets you generate favicons dynamically (e.g. tenant branding). The URL stays `/favicon.ico` for browser compatibility.
|
|
93
93
|
|
|
94
|
-
For OG image generation, use
|
|
94
|
+
For OG image generation, use `takumi-js/response` (BYO package — not bundled with timber):
|
|
95
95
|
|
|
96
96
|
```tsx title="app/opengraph-image.tsx"
|
|
97
97
|
import { ImageResponse } from 'takumi-js/response';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.186",
|
|
4
4
|
"description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
"scripts": {
|
|
201
201
|
"copy-docs": "node scripts/copy-docs.js",
|
|
202
|
-
"build": "vite build --config vite.lib.config.ts &&
|
|
202
|
+
"build": "vite build --config vite.lib.config.ts && node scripts/build-types.js && pnpm run copy-docs",
|
|
203
203
|
"typecheck": "tsgo --noEmit"
|
|
204
204
|
}
|
|
205
205
|
}
|
|
@@ -13,7 +13,16 @@
|
|
|
13
13
|
|
|
14
14
|
import { writeFile, mkdir, cp, rm, readdir, readFile } from 'node:fs/promises';
|
|
15
15
|
import { join, basename, relative } from 'node:path';
|
|
16
|
-
import { generateHeadersFile } from './shared.js';
|
|
16
|
+
import { adapterBase, generateHeadersFile } from './shared.js';
|
|
17
|
+
// Isomorphic, zero-import module — safe to load from an adapter, which Node's
|
|
18
|
+
// native ESM loader evaluates before Vite's resolver exists. Same precedent as
|
|
19
|
+
// `adapters/shared.ts` importing `../shared/base-path.js`.
|
|
20
|
+
import {
|
|
21
|
+
HEADERS_FILE,
|
|
22
|
+
USER_MERGED_PLATFORM_FILES,
|
|
23
|
+
USER_PLATFORM_DIR,
|
|
24
|
+
} from '../shared/static-platform-files.js';
|
|
25
|
+
import { detectFsIdentity, fsKey } from './fs-identity.js';
|
|
17
26
|
import type { TimberConfig } from './types';
|
|
18
27
|
|
|
19
28
|
/** Options for the shared build output steps. */
|
|
@@ -77,8 +86,7 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
|
|
|
77
86
|
// Scan for unhashed files so they get per-file Cache-Control rules in the
|
|
78
87
|
// _headers file. On platforms like Cloudflare Workers Static Assets, the
|
|
79
88
|
// worker never sees static file requests — _headers is the only mechanism.
|
|
80
|
-
|
|
81
|
-
await writeFile(join(publicDir, '_headers'), generateHeadersFile(unhashedPaths));
|
|
89
|
+
await writeHeadersFile(publicDir, config, await findUnhashedStaticFiles(publicDir));
|
|
82
90
|
|
|
83
91
|
// 4. Copy RSC + SSR server bundles into the output directory.
|
|
84
92
|
await cp(join(buildDir, 'rsc'), join(outDir, 'rsc'), { recursive: true });
|
|
@@ -218,11 +226,116 @@ export async function buildStaticDirectoryOutput(
|
|
|
218
226
|
});
|
|
219
227
|
|
|
220
228
|
// Copy pre-rendered static pages (HTML + RSC flight + API routes).
|
|
229
|
+
//
|
|
230
|
+
// This is the one place the build merges two independently-produced trees
|
|
231
|
+
// into a single directory, and `cp` resolves an overlap by overwriting with
|
|
232
|
+
// no diagnostic — the deployment then contains one of the two artifacts and
|
|
233
|
+
// nothing recorded which. Refuse instead (TIM-1266).
|
|
221
234
|
if (config.staticPagesDir) {
|
|
235
|
+
await assertNoTreeCollision(config.staticPagesDir, publicDir);
|
|
222
236
|
await cp(config.staticPagesDir, publicDir, { recursive: true });
|
|
223
237
|
}
|
|
224
238
|
}
|
|
225
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Write the `_headers` file, folding in the user's `public/_headers`.
|
|
242
|
+
*
|
|
243
|
+
* Every adapter used to `writeFile` a generated `_headers` over whatever
|
|
244
|
+
* Vite had copied out of `public/`, so an app shipping its own CSP, CORS, or
|
|
245
|
+
* cache rules deployed without them and without a word (TIM-1326). The
|
|
246
|
+
* generated rules and the user's are not competitors — they address different
|
|
247
|
+
* paths — so this merges rather than refusing, the way `_redirects` has since
|
|
248
|
+
* TIM-1249.
|
|
249
|
+
*
|
|
250
|
+
* **Read from the project, not the output.** The generated file lands under
|
|
251
|
+
* the same name in the output directory, and `runSharedBuildSteps` does not
|
|
252
|
+
* clean `outDir`; a reader aimed there would fold the previous build's
|
|
253
|
+
* generated rules back in and compound them on every rebuild — the defect
|
|
254
|
+
* this pass fixed for `_redirects`.
|
|
255
|
+
*
|
|
256
|
+
* User rules go last. On Cloudflare and Netlify a `_headers` file applies
|
|
257
|
+
* every matching rule, so appending means the user's rules take effect; where
|
|
258
|
+
* a platform resolves a conflict in favour of the earlier rule instead, the
|
|
259
|
+
* framework keeps the paths it owns and the user keeps the rest. Under either
|
|
260
|
+
* reading this is no worse than the previous behaviour, which was to drop the
|
|
261
|
+
* user's rules entirely.
|
|
262
|
+
*
|
|
263
|
+
* @internal Exported for testing.
|
|
264
|
+
*/
|
|
265
|
+
export async function writeHeadersFile(
|
|
266
|
+
dir: string,
|
|
267
|
+
config: TimberConfig,
|
|
268
|
+
unhashedPaths: string[]
|
|
269
|
+
): Promise<void> {
|
|
270
|
+
const userRules = await readUserPlatformFile(config.root, HEADERS_FILE);
|
|
271
|
+
await writeFile(
|
|
272
|
+
join(dir, HEADERS_FILE),
|
|
273
|
+
generateHeadersFile({
|
|
274
|
+
base: adapterBase(config),
|
|
275
|
+
unhashedPaths,
|
|
276
|
+
contentTypes: config.staticContentTypes,
|
|
277
|
+
userRules: userRules ?? undefined,
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Read a user-authored platform file from the project's `public/` directory.
|
|
284
|
+
* Returns null when the project has none, or when no root is configured —
|
|
285
|
+
* a caller without a root cannot locate the project at all, and inventing
|
|
286
|
+
* one from `process.cwd()` would read a different project's file.
|
|
287
|
+
*/
|
|
288
|
+
async function readUserPlatformFile(
|
|
289
|
+
root: string | undefined,
|
|
290
|
+
name: string
|
|
291
|
+
): Promise<string | null> {
|
|
292
|
+
if (!root) return null;
|
|
293
|
+
try {
|
|
294
|
+
return await readFile(join(root, USER_PLATFORM_DIR, name), 'utf-8');
|
|
295
|
+
} catch {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Throw if copying `srcDir` over `destDir` would overwrite an existing file.
|
|
302
|
+
*
|
|
303
|
+
* Compared against the destination **as it stands**, not against the other
|
|
304
|
+
* source tree: the first copy is filtered (client JS is dropped when client
|
|
305
|
+
* JavaScript is disabled), so the files that are actually there are the only
|
|
306
|
+
* ones a second copy can clobber.
|
|
307
|
+
*
|
|
308
|
+
* @internal Exported for testing.
|
|
309
|
+
*/
|
|
310
|
+
export async function assertNoTreeCollision(srcDir: string, destDir: string): Promise<void> {
|
|
311
|
+
const [srcFiles, destFiles, identity] = await Promise.all([
|
|
312
|
+
collectFiles(srcDir).catch(() => [] as string[]),
|
|
313
|
+
collectFiles(destDir).catch(() => [] as string[]),
|
|
314
|
+
// `cp` will resolve these paths the way the destination filesystem does,
|
|
315
|
+
// so the comparison predicting it has to as well: on macOS a hand-written
|
|
316
|
+
// `public/About/index.html` and a generated `about/index.html` are one
|
|
317
|
+
// file, and an exact-string set waves the overwrite through (TIM-1266).
|
|
318
|
+
detectFsIdentity(destDir),
|
|
319
|
+
]);
|
|
320
|
+
|
|
321
|
+
const key = (p: string) => fsKey(p, identity);
|
|
322
|
+
const existing = new Set(destFiles.map((f) => key(relative(destDir, f).replace(/\\/g, '/'))));
|
|
323
|
+
const exempt = new Set(USER_MERGED_PLATFORM_FILES.map(key));
|
|
324
|
+
const collisions = srcFiles
|
|
325
|
+
.map((f) => relative(srcDir, f).replace(/\\/g, '/'))
|
|
326
|
+
.filter((rel) => existing.has(key(rel)) && !exempt.has(key(rel)))
|
|
327
|
+
.sort();
|
|
328
|
+
|
|
329
|
+
if (collisions.length === 0) return;
|
|
330
|
+
|
|
331
|
+
throw new Error(
|
|
332
|
+
`[timber] Build output: ${collisions.length} file(s) in the pre-rendered site ` +
|
|
333
|
+
`collide with files already in the output directory. Copying would silently ` +
|
|
334
|
+
`overwrite them — a generated page and a file in public/ cannot share a path:\n` +
|
|
335
|
+
collisions.map((c) => ` - ${c}`).join('\n')
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
226
339
|
async function collectFiles(dir: string): Promise<string[]> {
|
|
227
340
|
const result: string[] = [];
|
|
228
341
|
const entries = await readdir(dir, { withFileTypes: true });
|