@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,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation Pipeline — URL in, tree in React's hands.
|
|
3
|
+
*
|
|
4
|
+
* Everything between "the user asked for this URL" and "React is holding the
|
|
5
|
+
* destination's tree": consult the prefetch cache or fetch, prepare the commit
|
|
6
|
+
* that makes the page current, and hand the result over inside a transition.
|
|
7
|
+
*
|
|
8
|
+
* `router.ts` keeps the *operations* — `navigate`, `refresh`, `handlePopState`,
|
|
9
|
+
* `prefetch`, `applyRevalidation` — and each of them is a call into here. The
|
|
10
|
+
* split is the same one `router-effects.ts` and `router-lifecycle.ts` made
|
|
11
|
+
* (design/18-build-system.md §"No file >500 lines").
|
|
12
|
+
*
|
|
13
|
+
* See design/19-client-navigation.md §"Partial Rendering" and §"Prefetching".
|
|
14
|
+
*/
|
|
15
|
+
import type { FetchResult } from './rsc-fetch.js';
|
|
16
|
+
import { type ParamsSource } from '../shared/payload-root.js';
|
|
17
|
+
import type { PrefetchCache, PrefetchKey } from './segment-cache.js';
|
|
18
|
+
import type { StateTree } from '../shared/segment-info.js';
|
|
19
|
+
import type { NavigationState } from './navigation-context.js';
|
|
20
|
+
import type { NavigationCommitter } from './navigation-commit.js';
|
|
21
|
+
import type { RouterDeps } from './router-types.js';
|
|
22
|
+
/** A fetched payload plus the state update that makes it the current page. */
|
|
23
|
+
export type NavigationPayload = FetchResult & {
|
|
24
|
+
navState: NavigationState;
|
|
25
|
+
commit: () => void;
|
|
26
|
+
};
|
|
27
|
+
/** Options for a single `performNavigationFetch` call. */
|
|
28
|
+
export interface NavigationFetchOptions {
|
|
29
|
+
replace: boolean;
|
|
30
|
+
commitUrl?: string;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
skipHistory?: boolean;
|
|
33
|
+
departingUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface NavigationPipelineDeps extends Pick<NavigationCommitter, 'prepareNavigation' | 'currentStateTree'> {
|
|
36
|
+
deps: RouterDeps;
|
|
37
|
+
prefetchCache: PrefetchCache;
|
|
38
|
+
/** Record that this navigation's tree reached React (router-lifecycle.ts). */
|
|
39
|
+
markHandedOff: (owner: AbortController) => void;
|
|
40
|
+
/** React committed this navigation's tree (router-lifecycle.ts). */
|
|
41
|
+
forgetOlderHandoffs: (owner: AbortController) => void;
|
|
42
|
+
}
|
|
43
|
+
export interface NavigationPipeline {
|
|
44
|
+
/** Fetch (or replay a prefetch), then stage the commit. */
|
|
45
|
+
performNavigationFetch: (url: string, options: NavigationFetchOptions) => Promise<NavigationPayload>;
|
|
46
|
+
/** Hand a payload to React inside a transition, or render it directly in tests. */
|
|
47
|
+
renderViaTransition: (url: string, owner: AbortController, perform: () => Promise<NavigationPayload>) => Promise<void>;
|
|
48
|
+
/** Render a decoded payload into the DOM if a renderer is available. */
|
|
49
|
+
renderPayload: (payload: unknown, navState: NavigationState, params: ParamsSource) => void;
|
|
50
|
+
/** Resolve thenable payloads on the fallback (test) path. */
|
|
51
|
+
resolveForFallback: (payload: unknown) => Promise<unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Normalize a departing URL to the pathname the server is told about.
|
|
55
|
+
*
|
|
56
|
+
* This is the value sent as `X-Timber-URL` *and* the source half of the
|
|
57
|
+
* prefetch cache key — one function so a prefetch and the click that consumes
|
|
58
|
+
* it can never disagree about what "where we came from" means (TIM-1265). The
|
|
59
|
+
* query is dropped deliberately: it would land in the `_rsc` digest, which is
|
|
60
|
+
* logged (TIM-1268), and nothing downstream reads it — slot-skip resolution
|
|
61
|
+
* and interception scope both compare pathnames.
|
|
62
|
+
*
|
|
63
|
+
* Absolute inputs parse against the base and ignore it, so one call handles
|
|
64
|
+
* both `location.href` and a bare pathname.
|
|
65
|
+
*/
|
|
66
|
+
export declare function departingPathname(raw: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* The prefetch cache key for a destination.
|
|
69
|
+
*
|
|
70
|
+
* Both halves of the cache are keyed through here — the hover that writes an
|
|
71
|
+
* entry (`router.ts`'s `prefetch()`) and the click that consumes it
|
|
72
|
+
* (`performNavigationFetch` below) — so the two cannot disagree about what
|
|
73
|
+
* identifies a payload. That is the whole point of the key: `from` scopes it
|
|
74
|
+
* to the page the link was on (TIM-1265) and `scope` to the tree that was
|
|
75
|
+
* mounted (TIM-1282), and an entry written under one reading of either would
|
|
76
|
+
* simply never be found under the other, silently costing every prefetch.
|
|
77
|
+
*
|
|
78
|
+
* `departingPathname` is applied here rather than by callers for the same
|
|
79
|
+
* reason: it is also what goes out as `X-Timber-URL`, so the key and the
|
|
80
|
+
* request describe the same departure point.
|
|
81
|
+
*/
|
|
82
|
+
export declare function prefetchKeyFor(url: string, departingUrl: string, stateTree: StateTree | undefined): PrefetchKey;
|
|
83
|
+
export declare function createNavigationPipeline({ deps, prefetchCache, currentStateTree, prepareNavigation, markHandedOff, forgetOlderHandoffs, }: NavigationPipelineDeps): NavigationPipeline;
|
|
84
|
+
//# sourceMappingURL=router-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-pipeline.d.ts","sourceRoot":"","sources":["../../src/client/router-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,mBAAmB,EACnB,mBAAmB,GAAG,kBAAkB,CACzC;IACC,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,8EAA8E;IAC9E,aAAa,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAChD,oEAAoE;IACpE,mBAAmB,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,sBAAsB,EAAE,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChC,mFAAmF;IACnF,mBAAmB,EAAE,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,KACtC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,wEAAwE;IACxE,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3F,6DAA6D;IAC7D,kBAAkB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,WAAW,CAEb;AAwCD,wBAAgB,wBAAwB,CAAC,EACvC,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,GACpB,EAAE,sBAAsB,GAAG,kBAAkB,CAwO7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-ref.d.ts","sourceRoot":"","sources":["../../src/client/router-ref.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"router-ref.d.ts","sourceRoot":"","sources":["../../src/client/router-ref.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAE5D;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAK1C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,cAAc,GAAG,IAAI,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router Skew Recording — turning a rejection into "this bundle is superseded".
|
|
3
|
+
*
|
|
4
|
+
* Detection lives in `stale-client.ts`; this is the one place the router (and
|
|
5
|
+
* anything else holding an RSC rejection) turns an error into that verdict.
|
|
6
|
+
* Recovery is not here: every path that gives up on client-side navigation —
|
|
7
|
+
* skew or not — leaves through `createSpaExits()` in `router-effects.ts`.
|
|
8
|
+
*
|
|
9
|
+
* See design/33-version-skew.md §"Recovery on the next navigation"
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Record a version skew if `error` is one, and report whether it was.
|
|
13
|
+
*
|
|
14
|
+
* `VersionSkewError` is the origin saying so outright; the reactive shapes are
|
|
15
|
+
* inferred from the error text and are a no-op in dev.
|
|
16
|
+
*
|
|
17
|
+
* Closes over nothing — anywhere an RSC payload can fail needs it, including
|
|
18
|
+
* places that have no router instance to hand.
|
|
19
|
+
*/
|
|
20
|
+
export declare function recordSkew(error: unknown): boolean;
|
|
21
|
+
//# sourceMappingURL=router-skew.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-skew.d.ts","sourceRoot":"","sources":["../../src/client/router-skew.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMlD"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router Types — the router's surface, stated once.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `router.ts` so the factory file is navigation logic rather than
|
|
5
|
+
* declarations (design/18-build-system.md §"No file >500 lines"), and because
|
|
6
|
+
* `rsc-fetch.ts` needs `RouterDeps` while `router.ts` needs `FetchResult`:
|
|
7
|
+
* with the types here, neither imports the other.
|
|
8
|
+
*
|
|
9
|
+
* See design/19-client-navigation.md for the architecture these describe.
|
|
10
|
+
*/
|
|
11
|
+
import type { NavigationState } from './navigation-context.js';
|
|
12
|
+
import type { ParamsSource } from '../shared/payload-root.js';
|
|
13
|
+
import type { SegmentInfo } from '../shared/segment-info.js';
|
|
14
|
+
import type { SegmentCache, PrefetchCache } from './segment-cache.js';
|
|
15
|
+
import type { HistoryStack } from './history.js';
|
|
16
|
+
import type { TransitionResult } from './navigation-root.js';
|
|
17
|
+
export interface NavigationOptions {
|
|
18
|
+
/** Set to false to prevent scroll-to-top on forward navigation */
|
|
19
|
+
scroll?: boolean;
|
|
20
|
+
/** Use replaceState instead of pushState (replaces current history entry) */
|
|
21
|
+
replace?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @internal AbortSignal from the Navigation API's NavigateEvent.
|
|
24
|
+
* When provided, the signal is linked to the router's per-navigation
|
|
25
|
+
* AbortController so in-flight RSC fetches are cancelled when a new
|
|
26
|
+
* navigation starts.
|
|
27
|
+
*/
|
|
28
|
+
_signal?: AbortSignal;
|
|
29
|
+
/**
|
|
30
|
+
* @internal Skip pushState/replaceState — the Navigation API has already
|
|
31
|
+
* updated the URL via event.intercept(). Used for external navigations
|
|
32
|
+
* intercepted by the navigate event handler.
|
|
33
|
+
*/
|
|
34
|
+
_skipHistory?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @internal The URL the user is navigating FROM, captured before the
|
|
37
|
+
* Navigation API commits the destination. Sent as X-Timber-URL for
|
|
38
|
+
* slot skip comparison on the server (TIM-1232).
|
|
39
|
+
*/
|
|
40
|
+
_departingUrl?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Function that decodes an RSC Flight stream into a React element tree.
|
|
44
|
+
* In production: createFromFetch from @vitejs/plugin-rsc/browser.
|
|
45
|
+
* In tests: a mock that returns the raw payload.
|
|
46
|
+
*/
|
|
47
|
+
export type RscDecoder = (fetchPromise: Promise<Response>) => unknown;
|
|
48
|
+
/**
|
|
49
|
+
* Function that renders a decoded RSC element tree into the DOM.
|
|
50
|
+
* In production: reactRoot.render(element).
|
|
51
|
+
* In tests: a no-op or mock.
|
|
52
|
+
*
|
|
53
|
+
* Receives the current NavigationState explicitly — no temporal
|
|
54
|
+
* coupling with setNavigationState/getNavigationState. The renderer
|
|
55
|
+
* wraps the element in NavigationProvider with this state.
|
|
56
|
+
*/
|
|
57
|
+
export type RootRenderer = (element: unknown, navState: NavigationState, params: ParamsSource) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Platform dependencies injected for testability. In production these
|
|
60
|
+
* map to browser APIs; in tests they're replaced with mocks.
|
|
61
|
+
*/
|
|
62
|
+
export interface RouterDeps {
|
|
63
|
+
fetch: (url: string, init: RequestInit) => Promise<Response>;
|
|
64
|
+
pushState: (data: unknown, unused: string, url: string) => void;
|
|
65
|
+
replaceState: (data: unknown, unused: string, url: string) => void;
|
|
66
|
+
scrollTo: (x: number, y: number) => void;
|
|
67
|
+
getCurrentUrl: () => string;
|
|
68
|
+
getScrollY: () => number;
|
|
69
|
+
/** Decode RSC Flight stream into React elements. If not provided, raw response text is stored. */
|
|
70
|
+
decodeRsc?: RscDecoder;
|
|
71
|
+
/** Render decoded RSC tree into the DOM. If not provided, rendering is a no-op. */
|
|
72
|
+
renderRoot?: RootRenderer;
|
|
73
|
+
/**
|
|
74
|
+
* Schedule a callback after the next paint. In the browser, this is
|
|
75
|
+
* requestAnimationFrame + setTimeout(0) to run after React commits.
|
|
76
|
+
* In tests, this runs the callback synchronously.
|
|
77
|
+
*/
|
|
78
|
+
afterPaint?: (callback: () => void) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Hand a navigation's tree to React in a transition, so the departing page
|
|
81
|
+
* stays visible while the destination resolves. Pending state is not React
|
|
82
|
+
* state — it lives in this router's external store (`setPending`), which
|
|
83
|
+
* `TopLoader` and `usePendingNavigation()` subscribe to (TIM-1307).
|
|
84
|
+
*
|
|
85
|
+
* The `perform` callback receives a `wrapPayload` function to wrap the
|
|
86
|
+
* decoded RSC payload with NavigationProvider + NuqsAdapter before
|
|
87
|
+
* NavigationRoot sets it as the new element. The `wrapPayload` function
|
|
88
|
+
* receives the NavigationState explicitly — no temporal coupling with
|
|
89
|
+
* getNavigationState().
|
|
90
|
+
*
|
|
91
|
+
* If not provided (tests), the router falls back to renderRoot.
|
|
92
|
+
*/
|
|
93
|
+
navigateTransition?: (pendingUrl: string, perform: (wrapPayload: (payload: unknown, navState: NavigationState,
|
|
94
|
+
/**
|
|
95
|
+
* The params to publish over `payload`. On a partial navigation
|
|
96
|
+
* `payload` is the *retained* tree and these are the *incoming*
|
|
97
|
+
* route's — the two deliberately come from different payloads,
|
|
98
|
+
* which is the entire point of the client owning the provider
|
|
99
|
+
* (TIM-1297).
|
|
100
|
+
*/
|
|
101
|
+
params: ParamsSource, segmentUpdates?: Map<string, unknown>) => unknown) => Promise<TransitionResult<unknown>>) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the Navigation API is active and handling traversals.
|
|
104
|
+
* When true, the popstate handler is a no-op — the Navigation API's
|
|
105
|
+
* navigate event covers back/forward button presses.
|
|
106
|
+
*/
|
|
107
|
+
navigationApiActive?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Called around pushState/replaceState to set a flag that prevents
|
|
110
|
+
* the Navigation API's navigate listener from double-handling
|
|
111
|
+
* router-initiated navigations.
|
|
112
|
+
*/
|
|
113
|
+
setRouterNavigating?: (value: boolean) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Save scroll position via the Navigation API's per-entry state.
|
|
116
|
+
* When provided, used instead of history.replaceState for scroll storage.
|
|
117
|
+
*/
|
|
118
|
+
saveNavigationEntryScroll?: (scrollY: number) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Signal that a router-initiated navigation has completed. Resolves the
|
|
121
|
+
* deferred promise that ties the browser's native loading state to the
|
|
122
|
+
* navigation lifecycle. Called in the finally block of navigate/refresh,
|
|
123
|
+
* the same place `setPending(false)` clears the TopLoader.
|
|
124
|
+
*/
|
|
125
|
+
completeRouterNavigation?: () => void;
|
|
126
|
+
/**
|
|
127
|
+
* Get the current unwrapped RSC payload element. Used for partial
|
|
128
|
+
* navigation: the router re-wraps the same element with new
|
|
129
|
+
* NavigationProvider context so mounted SegmentOutlets are preserved.
|
|
130
|
+
*/
|
|
131
|
+
_getCurrentPayload?: () => unknown;
|
|
132
|
+
/**
|
|
133
|
+
* Initiate a navigation via the Navigation API (`navigation.navigate()`).
|
|
134
|
+
* Fires the navigate event BEFORE committing the URL, allowing Chrome
|
|
135
|
+
* to show its native loading indicator. Falls back to pushState when
|
|
136
|
+
* unavailable.
|
|
137
|
+
*/
|
|
138
|
+
navigationNavigate?: (url: string, replace: boolean) => void;
|
|
139
|
+
/**
|
|
140
|
+
* Scroll the element matching a URL #fragment into view. Returns true
|
|
141
|
+
* when a matching element was found and scrolled. When absent or false,
|
|
142
|
+
* the router falls back to scroll-to-top on forward navigation — same
|
|
143
|
+
* as a full page load with an unknown fragment landing at the top.
|
|
144
|
+
*/
|
|
145
|
+
scrollToHash?: (hash: string) => boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether the client segment cache is enabled. When false (the default),
|
|
148
|
+
* the router sends no segment/slot lists, so every navigation gets a full
|
|
149
|
+
* RSC payload.
|
|
150
|
+
*
|
|
151
|
+
* It does NOT gate the `treePaths` half of X-Timber-State-Tree. Those
|
|
152
|
+
* describe the tree currently mounted, and interception scoping needs them
|
|
153
|
+
* to open a modal on top of a modal — a routing behaviour, not a caching
|
|
154
|
+
* optimization, so it must not depend on a performance opt-in (TIM-1282).
|
|
155
|
+
*/
|
|
156
|
+
clientSegmentCache?: boolean;
|
|
157
|
+
}
|
|
158
|
+
export interface RouterInstance {
|
|
159
|
+
/** Navigate to a new URL (forward navigation) */
|
|
160
|
+
navigate(url: string, options?: NavigationOptions): Promise<void>;
|
|
161
|
+
/** Full re-render of the current URL — no state tree sent */
|
|
162
|
+
refresh(): Promise<void>;
|
|
163
|
+
/** Handle a popstate event (back/forward button). scrollY is read from history.state. */
|
|
164
|
+
handlePopState(url: string, scrollY?: number, externalSignal?: AbortSignal): Promise<void>;
|
|
165
|
+
/** Whether a navigation is currently in flight */
|
|
166
|
+
isPending(): boolean;
|
|
167
|
+
/** The URL currently being navigated to, or null if idle */
|
|
168
|
+
getPendingUrl(): string | null;
|
|
169
|
+
/** Subscribe to pending state changes */
|
|
170
|
+
onPendingChange(listener: (pending: boolean) => void): () => void;
|
|
171
|
+
/** Prefetch an RSC payload for a URL (used by Link hover) */
|
|
172
|
+
prefetch(url: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* Apply a piggybacked revalidation payload from a server action response.
|
|
175
|
+
* Takes the decoded payload *root* — tree plus the params it published —
|
|
176
|
+
* and renders it without a server fetch.
|
|
177
|
+
* See design/08-forms-and-actions.md §"Single-Roundtrip Revalidation".
|
|
178
|
+
*/
|
|
179
|
+
applyRevalidation(payloadRoot: unknown): void;
|
|
180
|
+
/**
|
|
181
|
+
* Populate the segment cache from server-provided segment metadata.
|
|
182
|
+
* Called on initial hydration with segment info embedded in the HTML.
|
|
183
|
+
*/
|
|
184
|
+
initSegmentCache(segments: SegmentInfo[]): void;
|
|
185
|
+
/** The segment cache (exposed for tests and <Link> prefetch) */
|
|
186
|
+
segmentCache: SegmentCache;
|
|
187
|
+
/** The prefetch cache (exposed for tests and <Link> prefetch) */
|
|
188
|
+
prefetchCache: PrefetchCache;
|
|
189
|
+
/** The history stack (exposed for tests) */
|
|
190
|
+
historyStack: HistoryStack;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Router navigation phase — discriminated union replacing scattered
|
|
194
|
+
* `pending` + `pendingUrl` boolean flags.
|
|
195
|
+
*
|
|
196
|
+
* - `idle`: No navigation in flight. The committed params/pathname
|
|
197
|
+
* are current.
|
|
198
|
+
* - `navigating`: A fetch or render is in progress. `targetUrl` is
|
|
199
|
+
* the destination being navigated to.
|
|
200
|
+
*/
|
|
201
|
+
export type RouterPhase = {
|
|
202
|
+
phase: 'idle';
|
|
203
|
+
} | {
|
|
204
|
+
phase: 'navigating';
|
|
205
|
+
targetUrl: string;
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=router-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-types.d.ts","sourceRoot":"","sources":["../../src/client/router-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,YAAY,KACjB,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,kGAAkG;IAClG,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,mFAAmF;IACnF,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC5C;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,EAAE,CACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CACP,WAAW,EAAE,CACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe;IACzB;;;;;;OAMG;IACH,MAAM,EAAE,YAAY,EACpB,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,KAClC,OAAO,KACT,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KACpC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAE/C;;;OAGG;IACH,yBAAyB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtD;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC;IAEnC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7D;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAEzC;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,6DAA6D;IAC7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,yFAAyF;IACzF,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3F,kDAAkD;IAClD,SAAS,IAAI,OAAO,CAAC;IACrB,4DAA4D;IAC5D,aAAa,IAAI,MAAM,GAAG,IAAI,CAAC;IAC/B,yCAAyC;IACzC,eAAe,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAClE,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9C;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAEhD,gEAAgE;IAChE,YAAY,EAAE,YAAY,CAAC;IAC3B,iEAAiE;IACjE,aAAa,EAAE,aAAa,CAAC;IAC7B,4CAA4C;IAC5C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/client/router.d.ts
CHANGED
|
@@ -1,188 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { SegmentInfo } from './segment-cache';
|
|
3
|
-
import { HistoryStack } from './history';
|
|
4
|
-
import { type NavigationState } from './navigation-context.js';
|
|
5
|
-
export interface NavigationOptions {
|
|
6
|
-
/** Set to false to prevent scroll-to-top on forward navigation */
|
|
7
|
-
scroll?: boolean;
|
|
8
|
-
/** Use replaceState instead of pushState (replaces current history entry) */
|
|
9
|
-
replace?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* @internal AbortSignal from the Navigation API's NavigateEvent.
|
|
12
|
-
* When provided, the signal is linked to the router's per-navigation
|
|
13
|
-
* AbortController so in-flight RSC fetches are cancelled when a new
|
|
14
|
-
* navigation starts.
|
|
15
|
-
*/
|
|
16
|
-
_signal?: AbortSignal;
|
|
17
|
-
/**
|
|
18
|
-
* @internal Skip pushState/replaceState — the Navigation API has already
|
|
19
|
-
* updated the URL via event.intercept(). Used for external navigations
|
|
20
|
-
* intercepted by the navigate event handler.
|
|
21
|
-
*/
|
|
22
|
-
_skipHistory?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* @internal The URL the user is navigating FROM, captured before the
|
|
25
|
-
* Navigation API commits the destination. Sent as X-Timber-URL for
|
|
26
|
-
* slot skip comparison on the server (TIM-1232).
|
|
27
|
-
*/
|
|
28
|
-
_departingUrl?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Function that decodes an RSC Flight stream into a React element tree.
|
|
32
|
-
* In production: createFromFetch from @vitejs/plugin-rsc/browser.
|
|
33
|
-
* In tests: a mock that returns the raw payload.
|
|
34
|
-
*/
|
|
35
|
-
export type RscDecoder = (fetchPromise: Promise<Response>) => unknown;
|
|
36
|
-
/**
|
|
37
|
-
* Function that renders a decoded RSC element tree into the DOM.
|
|
38
|
-
* In production: reactRoot.render(element).
|
|
39
|
-
* In tests: a no-op or mock.
|
|
40
|
-
*
|
|
41
|
-
* Receives the current NavigationState explicitly — no temporal
|
|
42
|
-
* coupling with setNavigationState/getNavigationState. The renderer
|
|
43
|
-
* wraps the element in NavigationProvider with this state.
|
|
44
|
-
*/
|
|
45
|
-
export type RootRenderer = (element: unknown, navState: NavigationState) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Platform dependencies injected for testability. In production these
|
|
48
|
-
* map to browser APIs; in tests they're replaced with mocks.
|
|
49
|
-
*/
|
|
50
|
-
export interface RouterDeps {
|
|
51
|
-
fetch: (url: string, init: RequestInit) => Promise<Response>;
|
|
52
|
-
pushState: (data: unknown, unused: string, url: string) => void;
|
|
53
|
-
replaceState: (data: unknown, unused: string, url: string) => void;
|
|
54
|
-
scrollTo: (x: number, y: number) => void;
|
|
55
|
-
getCurrentUrl: () => string;
|
|
56
|
-
getScrollY: () => number;
|
|
57
|
-
/** Decode RSC Flight stream into React elements. If not provided, raw response text is stored. */
|
|
58
|
-
decodeRsc?: RscDecoder;
|
|
59
|
-
/** Render decoded RSC tree into the DOM. If not provided, rendering is a no-op. */
|
|
60
|
-
renderRoot?: RootRenderer;
|
|
61
|
-
/**
|
|
62
|
-
* Schedule a callback after the next paint. In the browser, this is
|
|
63
|
-
* requestAnimationFrame + setTimeout(0) to run after React commits.
|
|
64
|
-
* In tests, this runs the callback synchronously.
|
|
65
|
-
*/
|
|
66
|
-
afterPaint?: (callback: () => void) => void;
|
|
67
|
-
/**
|
|
68
|
-
* Run a navigation inside a React transition with optimistic pending URL.
|
|
69
|
-
* The pending URL shows immediately (useOptimistic urgent update) and
|
|
70
|
-
* reverts when the transition commits (atomic with the new tree).
|
|
71
|
-
*
|
|
72
|
-
* The `perform` callback receives a `wrapPayload` function to wrap the
|
|
73
|
-
* decoded RSC payload with NavigationProvider + NuqsAdapter before
|
|
74
|
-
* NavigationRoot sets it as the new element. The `wrapPayload` function
|
|
75
|
-
* receives the NavigationState explicitly — no temporal coupling with
|
|
76
|
-
* getNavigationState().
|
|
77
|
-
*
|
|
78
|
-
* If not provided (tests), the router falls back to renderRoot.
|
|
79
|
-
*/
|
|
80
|
-
navigateTransition?: (pendingUrl: string, perform: (wrapPayload: (payload: unknown, navState: NavigationState, segmentUpdates?: Map<string, unknown>) => unknown) => Promise<{
|
|
81
|
-
element: unknown;
|
|
82
|
-
decodePromise: Promise<void> | null;
|
|
83
|
-
}>) => Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Whether the Navigation API is active and handling traversals.
|
|
86
|
-
* When true, the popstate handler is a no-op — the Navigation API's
|
|
87
|
-
* navigate event covers back/forward button presses.
|
|
88
|
-
*/
|
|
89
|
-
navigationApiActive?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Called around pushState/replaceState to set a flag that prevents
|
|
92
|
-
* the Navigation API's navigate listener from double-handling
|
|
93
|
-
* router-initiated navigations.
|
|
94
|
-
*/
|
|
95
|
-
setRouterNavigating?: (value: boolean) => void;
|
|
96
|
-
/**
|
|
97
|
-
* Save scroll position via the Navigation API's per-entry state.
|
|
98
|
-
* When provided, used instead of history.replaceState for scroll storage.
|
|
99
|
-
*/
|
|
100
|
-
saveNavigationEntryScroll?: (scrollY: number) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Signal that a router-initiated navigation has completed. Resolves the
|
|
103
|
-
* deferred promise that ties the browser's native loading state to the
|
|
104
|
-
* navigation lifecycle. Called in the finally block of navigate/refresh,
|
|
105
|
-
* aligned with when the TopLoader's pendingUrl clears.
|
|
106
|
-
*/
|
|
107
|
-
completeRouterNavigation?: () => void;
|
|
108
|
-
/**
|
|
109
|
-
* Get the current unwrapped RSC payload element. Used for partial
|
|
110
|
-
* navigation: the router re-wraps the same element with new
|
|
111
|
-
* NavigationProvider context so mounted SegmentOutlets are preserved.
|
|
112
|
-
*/
|
|
113
|
-
_getCurrentPayload?: () => unknown;
|
|
114
|
-
/**
|
|
115
|
-
* Initiate a navigation via the Navigation API (`navigation.navigate()`).
|
|
116
|
-
* Fires the navigate event BEFORE committing the URL, allowing Chrome
|
|
117
|
-
* to show its native loading indicator. Falls back to pushState when
|
|
118
|
-
* unavailable.
|
|
119
|
-
*/
|
|
120
|
-
navigationNavigate?: (url: string, replace: boolean) => void;
|
|
121
|
-
/**
|
|
122
|
-
* Scroll the element matching a URL #fragment into view. Returns true
|
|
123
|
-
* when a matching element was found and scrolled. When absent or false,
|
|
124
|
-
* the router falls back to scroll-to-top on forward navigation — same
|
|
125
|
-
* as a full page load with an unknown fragment landing at the top.
|
|
126
|
-
*/
|
|
127
|
-
scrollToHash?: (hash: string) => boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Whether the client segment cache is enabled. When false (the default),
|
|
130
|
-
* the router does not send X-Timber-State-Tree headers and does not
|
|
131
|
-
* populate the segment cache. Every navigation gets a full RSC payload.
|
|
132
|
-
*/
|
|
133
|
-
clientSegmentCache?: boolean;
|
|
134
|
-
}
|
|
135
|
-
export interface RouterInstance {
|
|
136
|
-
/** Navigate to a new URL (forward navigation) */
|
|
137
|
-
navigate(url: string, options?: NavigationOptions): Promise<void>;
|
|
138
|
-
/** Full re-render of the current URL — no state tree sent */
|
|
139
|
-
refresh(): Promise<void>;
|
|
140
|
-
/** Handle a popstate event (back/forward button). scrollY is read from history.state. */
|
|
141
|
-
handlePopState(url: string, scrollY?: number, externalSignal?: AbortSignal): Promise<void>;
|
|
142
|
-
/** Whether a navigation is currently in flight */
|
|
143
|
-
isPending(): boolean;
|
|
144
|
-
/** The URL currently being navigated to, or null if idle */
|
|
145
|
-
getPendingUrl(): string | null;
|
|
146
|
-
/** Subscribe to pending state changes */
|
|
147
|
-
onPendingChange(listener: (pending: boolean) => void): () => void;
|
|
148
|
-
/** Prefetch an RSC payload for a URL (used by Link hover) */
|
|
149
|
-
prefetch(url: string): void;
|
|
150
|
-
/**
|
|
151
|
-
* Apply a piggybacked revalidation payload from a server action response.
|
|
152
|
-
* Renders the element tree and updates head elements without a server fetch.
|
|
153
|
-
* See design/08-forms-and-actions.md §"Single-Roundtrip Revalidation".
|
|
154
|
-
*/
|
|
155
|
-
applyRevalidation(element: unknown): void;
|
|
156
|
-
/**
|
|
157
|
-
* Populate the segment cache from server-provided segment metadata.
|
|
158
|
-
* Called on initial hydration with segment info embedded in the HTML.
|
|
159
|
-
*/
|
|
160
|
-
initSegmentCache(segments: SegmentInfo[]): void;
|
|
161
|
-
/** The segment cache (exposed for tests and <Link> prefetch) */
|
|
162
|
-
segmentCache: SegmentCache;
|
|
163
|
-
/** The prefetch cache (exposed for tests and <Link> prefetch) */
|
|
164
|
-
prefetchCache: PrefetchCache;
|
|
165
|
-
/** The history stack (exposed for tests) */
|
|
166
|
-
historyStack: HistoryStack;
|
|
167
|
-
}
|
|
1
|
+
import type { RouterDeps, RouterInstance } from './router-types.js';
|
|
168
2
|
/**
|
|
169
3
|
* Create a router instance. In production, called once at app hydration
|
|
170
4
|
* with real browser APIs. In tests, called with mock dependencies.
|
|
171
5
|
*/
|
|
172
|
-
/**
|
|
173
|
-
* Router navigation phase — discriminated union replacing scattered
|
|
174
|
-
* `pending` + `pendingUrl` boolean flags.
|
|
175
|
-
*
|
|
176
|
-
* - `idle`: No navigation in flight. The committed params/pathname
|
|
177
|
-
* are current.
|
|
178
|
-
* - `navigating`: A fetch or render is in progress. `targetUrl` is
|
|
179
|
-
* the destination being navigated to.
|
|
180
|
-
*/
|
|
181
|
-
export type RouterPhase = {
|
|
182
|
-
phase: 'idle';
|
|
183
|
-
} | {
|
|
184
|
-
phase: 'navigating';
|
|
185
|
-
targetUrl: string;
|
|
186
|
-
};
|
|
187
6
|
export declare function createRouter(deps: RouterDeps): RouterInstance;
|
|
188
7
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/client/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/client/router.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAqB,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIvF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAmY7D"}
|
|
@@ -10,11 +10,24 @@
|
|
|
10
10
|
*
|
|
11
11
|
* See design/19-client-navigation.md §"RSC Payload Handling"
|
|
12
12
|
*/
|
|
13
|
-
import type {
|
|
14
|
-
import type
|
|
13
|
+
import type { RscManifest } from '../shared/rsc-manifest.js';
|
|
14
|
+
import { type PublishedParams } from '../shared/payload-root.js';
|
|
15
|
+
import type { SegmentInfo, StateTree } from '../shared/segment-info.js';
|
|
16
|
+
import type { RouterDeps } from './router-types.js';
|
|
15
17
|
/** Result of fetching an RSC payload — includes segment metadata. */
|
|
16
18
|
export interface FetchResult {
|
|
19
|
+
/** The renderable tree, split off the payload root. */
|
|
17
20
|
payload: unknown;
|
|
21
|
+
/**
|
|
22
|
+
* The params the same payload published beside that tree.
|
|
23
|
+
*
|
|
24
|
+
* Not a separate channel: both fields come out of one `splitPayloadRoot`
|
|
25
|
+
* call on one decoded root, so a response cannot deliver a tree and another
|
|
26
|
+
* route's params. They used to arrive on their own header, which is how a
|
|
27
|
+
* navigation could render one route and publish another's (TIM-1285,
|
|
28
|
+
* TIM-1294).
|
|
29
|
+
*/
|
|
30
|
+
params: PublishedParams | Promise<PublishedParams>;
|
|
18
31
|
/**
|
|
19
32
|
* Promise that settles when the RSC decode completes or fails.
|
|
20
33
|
* The payload thenable is NOT awaited before returning (for streaming),
|
|
@@ -25,8 +38,6 @@ export interface FetchResult {
|
|
|
25
38
|
decodePromise: Promise<void> | null;
|
|
26
39
|
/** Segment metadata from X-Timber-Segments header for populating the segment cache. */
|
|
27
40
|
segmentInfo: SegmentInfo[] | null;
|
|
28
|
-
/** Route params from X-Timber-Params header for populating useSegmentParams(). */
|
|
29
|
-
params: Record<string, string | string[]> | null;
|
|
30
41
|
/** Segment paths that were skipped by the server (for client-side merging). */
|
|
31
42
|
skippedSegments: string[] | null;
|
|
32
43
|
}
|
|
@@ -35,21 +46,22 @@ export declare const RSC_CONTENT_TYPE = "text/x-component";
|
|
|
35
46
|
export declare function setClientDeploymentId(id: string | null): void;
|
|
36
47
|
/** Get the client deployment ID. */
|
|
37
48
|
export declare function getClientDeploymentId(): string | null;
|
|
49
|
+
/** Set the deployment base path. Called once at bootstrap. */
|
|
50
|
+
export declare function setBasePath(base: string | undefined): void;
|
|
51
|
+
/** Get the normalized deployment base path. @internal Exported for testing. */
|
|
52
|
+
export declare function getBasePath(): string;
|
|
38
53
|
export declare function setStaticMode(enabled: boolean): void;
|
|
39
54
|
export declare function isStaticMode(): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* RSC manifest entry: hashed URL with optional inlined route params.
|
|
42
|
-
* Params are embedded at build time (TIM-1255) so no sidecar fetch needed.
|
|
43
|
-
*/
|
|
44
|
-
interface RscManifestEntry {
|
|
45
|
-
url: string;
|
|
46
|
-
params?: Record<string, string | string[]>;
|
|
47
|
-
}
|
|
48
|
-
type RscManifest = Record<string, RscManifestEntry>;
|
|
49
55
|
/** @internal Exported for testing. */
|
|
50
56
|
export declare function setRscManifest(manifest: RscManifest | null): void;
|
|
51
57
|
/**
|
|
52
|
-
* Compute the unhashed _rsc/*.rsc
|
|
58
|
+
* Compute the unhashed `_rsc/*.rsc` path for a route URL.
|
|
59
|
+
*
|
|
60
|
+
* Returns a **route-space** path: the deployment base is stripped from the
|
|
61
|
+
* incoming URL and is NOT re-applied, because this value doubles as the RSC
|
|
62
|
+
* manifest key, and the manifest is base-less. `toStaticRscUrl` applies the
|
|
63
|
+
* base to whatever is actually fetched.
|
|
64
|
+
*
|
|
53
65
|
* @internal Exported for testing.
|
|
54
66
|
*/
|
|
55
67
|
export declare function toUnhashedRscUrl(url: string): string;
|
|
@@ -62,9 +74,18 @@ export declare const DEPLOYMENT_ID_HEADER = "X-Timber-Deployment-Id";
|
|
|
62
74
|
* Triggers a full page reload if the server indicates the client is stale.
|
|
63
75
|
*/
|
|
64
76
|
export declare function checkReloadSignal(response: Response): boolean;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Build the headers for an RSC payload request.
|
|
79
|
+
*
|
|
80
|
+
* **Every header added here is hashed into the payload URL** as the `_rsc`
|
|
81
|
+
* cache key (see `rscCacheKey`), and URLs are logged by proxies, CDNs, and
|
|
82
|
+
* origin access logs. So: no credentials, no session identifiers, no
|
|
83
|
+
* user-supplied content. `fnv1aHash` is a cache-key hash, not a KDF — a
|
|
84
|
+
* low-entropy secret would be recoverable from the URL by brute force.
|
|
85
|
+
* Authentication already travels on cookies, which are not part of this
|
|
86
|
+
* object and never enter the key.
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildRscHeaders(stateTree: StateTree | undefined, currentUrl?: string): Record<string, string>;
|
|
68
89
|
/**
|
|
69
90
|
* Extract segment metadata from the X-Timber-Segments response header.
|
|
70
91
|
* Returns null if the header is missing or malformed.
|
|
@@ -83,13 +104,6 @@ export declare function extractSegmentInfo(response: Response): SegmentInfo[] |
|
|
|
83
104
|
* The client uses this to merge the partial payload with cached segments.
|
|
84
105
|
*/
|
|
85
106
|
export declare function extractSkippedSegments(response: Response): string[] | null;
|
|
86
|
-
/**
|
|
87
|
-
* Extract route params from the X-Timber-Params response header.
|
|
88
|
-
* Returns null if the header is missing or malformed.
|
|
89
|
-
*
|
|
90
|
-
* Used to populate useSegmentParams() after client-side navigation.
|
|
91
|
-
*/
|
|
92
|
-
export declare function extractParams(response: Response): Record<string, string | string[]> | null;
|
|
93
107
|
/**
|
|
94
108
|
* Thrown when an RSC payload response contains X-Timber-Redirect header.
|
|
95
109
|
* Caught in navigate() to trigger a soft router navigation to the redirect target.
|
|
@@ -142,5 +156,4 @@ export declare class NonRscResponse extends Error {
|
|
|
142
156
|
export declare function fetchRscPayload(url: string, deps: RouterDeps, stateTree?: {
|
|
143
157
|
segments: string[];
|
|
144
158
|
}, currentUrl?: string, signal?: AbortSignal): Promise<FetchResult>;
|
|
145
|
-
export {};
|
|
146
159
|
//# sourceMappingURL=rsc-fetch.d.ts.map
|