@timber-js/app 0.2.0-alpha.239 → 0.2.0-alpha.240
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-Top9GftB.js → actions-DIgnvDrG.js} +4 -4
- package/dist/_chunks/{actions-Top9GftB.js.map → actions-DIgnvDrG.js.map} +1 -1
- package/dist/_chunks/{als-registry-DpygwCp0.js → als-registry-PPYstxK0.js} +2 -1
- package/dist/_chunks/{als-registry-DpygwCp0.js.map → als-registry-PPYstxK0.js.map} +1 -1
- package/dist/_chunks/{cache-api-Bo8c7XVF.js → cache-api-uWQwuxWb.js} +5 -5
- package/dist/_chunks/{cache-api-Bo8c7XVF.js.map → cache-api-uWQwuxWb.js.map} +1 -1
- package/dist/_chunks/{chains-DMoHX4yH.js → chains-C7CExrUI.js} +2 -2
- package/dist/_chunks/{chains-DMoHX4yH.js.map → chains-C7CExrUI.js.map} +1 -1
- package/dist/_chunks/chains-CSslTUdI.js +1 -0
- package/dist/_chunks/{classify-BwyAd-dZ.js → classify-Cj9EeZoL.js} +2 -2
- package/dist/_chunks/{classify-BwyAd-dZ.js.map → classify-Cj9EeZoL.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQAD9MLo.js → cli-check-C3QOAru7.js} +3 -3
- package/dist/_chunks/{cli-check-DQAD9MLo.js.map → cli-check-C3QOAru7.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-C_xNLqBj.js → cli-schema-sync-BRxZz66D.js} +1 -1
- package/dist/_chunks/{cli-schema-sync-CmGls3dc.js → cli-schema-sync-DQUS_o3V.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-CmGls3dc.js.map → cli-schema-sync-DQUS_o3V.js.map} +1 -1
- package/dist/_chunks/{client-dep-entries-C5BTQtFS.js → client-dep-entries-ZETBdLgv.js} +2 -2
- package/dist/_chunks/{client-dep-entries-C5BTQtFS.js.map → client-dep-entries-ZETBdLgv.js.map} +1 -1
- package/dist/_chunks/{convention-lint-GQA6WTRo.js → convention-lint-BoVISNS6.js} +3 -3
- package/dist/_chunks/{convention-lint-GQA6WTRo.js.map → convention-lint-BoVISNS6.js.map} +1 -1
- package/dist/_chunks/dev-server-B8roKA3Q.js +1 -0
- package/dist/_chunks/{dev-server-Cr3_Fu5A.js → dev-server-C5R6jx8Q.js} +2 -2
- package/dist/_chunks/{dev-server-Cr3_Fu5A.js.map → dev-server-C5R6jx8Q.js.map} +1 -1
- package/dist/_chunks/{dev-span-RsVeYYc_.js → dev-span-0aG7Q_Ph.js} +3 -7
- package/dist/_chunks/dev-span-0aG7Q_Ph.js.map +1 -0
- package/dist/_chunks/{error-boundary-Bh-egWUI.js → error-boundary-DB51f9ih.js} +98 -419
- package/dist/_chunks/error-boundary-DB51f9ih.js.map +1 -0
- package/dist/_chunks/{flight-source-node-BsrlUjMO.js → flight-source-node-D9cHBhjP.js} +7 -4
- package/dist/_chunks/flight-source-node-D9cHBhjP.js.map +1 -0
- package/dist/_chunks/{json-lossy-check-D47R9Fp5.js → json-lossy-check-Y1GxqVX_.js} +2 -2
- package/dist/_chunks/{json-lossy-check-D47R9Fp5.js.map → json-lossy-check-Y1GxqVX_.js.map} +1 -1
- package/dist/_chunks/{live-graph-HcLScfiV.js → live-graph-BDQWvnMm.js} +4 -4
- package/dist/_chunks/{live-graph-HcLScfiV.js.map → live-graph-BDQWvnMm.js.map} +1 -1
- package/dist/_chunks/{logger-DDLtp5e-.js → logger-DmRR9tmZ.js} +2 -2
- package/dist/_chunks/{logger-DDLtp5e-.js.map → logger-DmRR9tmZ.js.map} +1 -1
- package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
- package/dist/_chunks/{node-response-omewa8e6.js → node-response-yp8zdyRp.js} +2 -2
- package/dist/_chunks/{node-response-omewa8e6.js.map → node-response-yp8zdyRp.js.map} +1 -1
- package/dist/_chunks/plugin-context-BtaQcMuh.js.map +1 -1
- package/dist/_chunks/{poison-scan-DONdiCGX.js → poison-scan-WQgUydF_.js} +2 -2
- package/dist/_chunks/{poison-scan-DONdiCGX.js.map → poison-scan-WQgUydF_.js.map} +1 -1
- package/dist/_chunks/{scanner-DSAJjH0x.js → scanner-C9Lrf77z.js} +3 -2
- package/dist/_chunks/{scanner-DSAJjH0x.js.map → scanner-C9Lrf77z.js.map} +1 -1
- package/dist/_chunks/{sizeof-DVhEVN_y.js → sizeof-BISkSaU0.js} +2 -2
- package/dist/_chunks/{sizeof-DVhEVN_y.js.map → sizeof-BISkSaU0.js.map} +1 -1
- package/dist/_chunks/{walkers-96YopJds.js → walkers-Bxv4v7tX.js} +3 -3
- package/dist/_chunks/{walkers-96YopJds.js.map → walkers-Bxv4v7tX.js.map} +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/analyze/crawl-entry.js +3 -3
- package/dist/analyze/graph-command.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/cache/stores/memory.js +1 -1
- package/dist/cdn/workers-cache-purge.js +1 -1
- package/dist/cli.js +3 -3
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/hydrate.d.ts +1 -1
- package/dist/client/browser-entry/router-init.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 -1
- package/dist/client/history.d.ts +4 -5
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.js +6 -7
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +1 -1
- package/dist/client/internal.d.ts.map +1 -1
- package/dist/client/internal.js +194 -55
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-commit.d.ts +6 -25
- package/dist/client/navigation-commit.d.ts.map +1 -1
- package/dist/client/outlet-content-cache.d.ts +59 -0
- package/dist/client/outlet-content-cache.d.ts.map +1 -0
- package/dist/client/outlet-scope-context.d.ts +30 -0
- package/dist/client/outlet-scope-context.d.ts.map +1 -0
- package/dist/client/params-context.d.ts +10 -11
- package/dist/client/params-context.d.ts.map +1 -1
- package/dist/client/router-pipeline.d.ts +5 -5
- package/dist/client/router-pipeline.d.ts.map +1 -1
- package/dist/client/router-types.d.ts +10 -24
- package/dist/client/router-types.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +4 -17
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +15 -103
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts +28 -52
- package/dist/client/segment-outlet.d.ts.map +1 -1
- package/dist/client/stale-segment.d.ts +39 -0
- package/dist/client/stale-segment.d.ts.map +1 -0
- package/dist/client/use-segment-params.d.ts +1 -1
- package/dist/config-types.d.ts +7 -6
- package/dist/config-types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -732
- package/dist/index.js.map +1 -1
- package/dist/native/rsc/manifest.json +6 -4
- package/dist/native/rsc/routing/segment-keys.js +3 -11
- package/dist/native/rsc/routing/segment-keys.js.map +1 -1
- package/dist/native/rsc/server/access-gate.js +3 -7
- package/dist/native/rsc/server/access-gate.js.map +1 -1
- package/dist/native/rsc/server/als-registry.js +2 -1
- package/dist/native/rsc/server/als-registry.js.map +1 -1
- package/dist/native/rsc/server/build-manifest.js.map +1 -1
- package/dist/native/rsc/server/chain-url-parts.js +1 -6
- package/dist/native/rsc/server/chain-url-parts.js.map +1 -1
- package/dist/native/rsc/server/client-state-tree.js +33 -0
- package/dist/native/rsc/server/client-state-tree.js.map +1 -0
- package/dist/native/rsc/server/flight-source-node.js +5 -2
- package/dist/native/rsc/server/flight-source-node.js.map +1 -1
- package/dist/native/rsc/server/flight-source.js +46 -7
- package/dist/native/rsc/server/flight-source.js.map +1 -1
- package/dist/native/rsc/server/pipeline-interception.js +1 -1
- package/dist/native/rsc/server/publish-params.js.map +1 -1
- package/dist/native/rsc/server/route-element-builder.js +43 -61
- package/dist/native/rsc/server/route-element-builder.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/helpers.js +5 -28
- package/dist/native/rsc/server/rsc-entry/helpers.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/render-route.js +33 -7
- package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +2 -1
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/rsc-payload.js +2 -5
- package/dist/native/rsc/server/rsc-entry/rsc-payload.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/rsc-stream.js +44 -40
- package/dist/native/rsc/server/rsc-entry/rsc-stream.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/ssr-renderer.js +1 -1
- package/dist/native/rsc/server/rsc-entry/ssr-renderer.js.map +1 -1
- package/dist/native/rsc/server/segment-hash/capture.js +107 -0
- package/dist/native/rsc/server/segment-hash/capture.js.map +1 -0
- package/dist/native/rsc/server/segment-hash/outlet.js +81 -0
- package/dist/native/rsc/server/segment-hash/outlet.js.map +1 -0
- package/dist/native/rsc/server/segment-hash/stream-tap.js +139 -0
- package/dist/native/rsc/server/segment-hash/stream-tap.js.map +1 -0
- package/dist/native/rsc/server/segment-hash/value-hash.js +171 -0
- package/dist/native/rsc/server/segment-hash/value-hash.js.map +1 -0
- package/dist/native/rsc/server/slot-resolver.js +20 -124
- package/dist/native/rsc/server/slot-resolver.js.map +1 -1
- package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/rsc/shared/outlet-decision.js +5 -0
- package/dist/native/rsc/shared/outlet-decision.js.map +1 -0
- package/dist/native/ssr/client/error-boundary.js +16 -3
- package/dist/native/ssr/client/error-boundary.js.map +1 -1
- package/dist/native/ssr/client/navigation-commit.js +1 -5
- package/dist/native/ssr/client/navigation-commit.js.map +1 -1
- package/dist/native/ssr/client/outlet-content-cache.js +53 -0
- package/dist/native/ssr/client/outlet-content-cache.js.map +1 -0
- package/dist/native/ssr/client/outlet-scope-context.js +12 -0
- package/dist/native/ssr/client/outlet-scope-context.js.map +1 -0
- package/dist/native/ssr/client/params-context.js.map +1 -1
- package/dist/native/ssr/client/rsc-fetch.js +1 -12
- package/dist/native/ssr/client/rsc-fetch.js.map +1 -1
- package/dist/native/ssr/client/segment-outlet.js +34 -13
- package/dist/native/ssr/client/segment-outlet.js.map +1 -1
- package/dist/native/ssr/client/stale-segment.js +29 -0
- package/dist/native/ssr/client/stale-segment.js.map +1 -0
- package/dist/native/ssr/manifest.json +5 -4
- package/dist/native/ssr/routing/segment-keys.js +5 -1
- package/dist/native/ssr/routing/segment-keys.js.map +1 -1
- package/dist/native/ssr/server/access-gate.js +3 -7
- package/dist/native/ssr/server/access-gate.js.map +1 -1
- package/dist/native/ssr/server/als-registry.js +1 -0
- package/dist/native/ssr/server/als-registry.js.map +1 -1
- package/dist/native/ssr/server/build-manifest.js.map +1 -1
- package/dist/native/ssr/server/client-state-tree.js +33 -0
- package/dist/native/ssr/server/client-state-tree.js.map +1 -0
- package/dist/native/ssr/server/flight-source-node.js +5 -2
- package/dist/native/ssr/server/flight-source-node.js.map +1 -1
- package/dist/native/ssr/server/flight-source.js +1 -0
- package/dist/native/ssr/server/flight-source.js.map +1 -1
- package/dist/native/ssr/server/pipeline-interception.js +1 -1
- package/dist/native/ssr/server/segment-hash/value-hash.js +162 -0
- package/dist/native/ssr/server/segment-hash/value-hash.js.map +1 -0
- package/dist/native/ssr/server/ssr-wrappers.js.map +1 -1
- package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/ssr/shared/payload-root.js.map +1 -1
- package/dist/plugin-context.d.ts +0 -16
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/routing/segment-keys.d.ts +8 -21
- package/dist/routing/segment-keys.d.ts.map +1 -1
- package/dist/server/access-gate.d.ts +0 -14
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +16 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +1 -10
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/chain-url-parts.d.ts +3 -13
- package/dist/server/chain-url-parts.d.ts.map +1 -1
- package/dist/server/client-state-tree.d.ts +31 -0
- package/dist/server/client-state-tree.d.ts.map +1 -0
- package/dist/server/flight-source-node.d.ts +6 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts +27 -0
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +48 -47
- package/dist/server/internal.js.map +1 -1
- package/dist/server/publish-params.d.ts +5 -4
- package/dist/server/publish-params.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +4 -19
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +7 -13
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +1 -2
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +11 -2
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +0 -2
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/segment-hash/capture.d.ts +77 -0
- package/dist/server/segment-hash/capture.d.ts.map +1 -0
- package/dist/server/segment-hash/outlet.d.ts +65 -0
- package/dist/server/segment-hash/outlet.d.ts.map +1 -0
- package/dist/server/segment-hash/stream-tap.d.ts +49 -0
- package/dist/server/segment-hash/stream-tap.d.ts.map +1 -0
- package/dist/server/segment-hash/value-hash.d.ts +70 -0
- package/dist/server/segment-hash/value-hash.d.ts.map +1 -0
- package/dist/server/slot-resolver.d.ts +13 -78
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-wrappers.d.ts +7 -9
- package/dist/server/ssr-wrappers.d.ts.map +1 -1
- package/dist/server/vite-handoff-rsc.d.ts +10 -1
- package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
- package/dist/shared/outlet-decision.d.ts +48 -0
- package/dist/shared/outlet-decision.d.ts.map +1 -0
- package/dist/shared/payload-root.d.ts +5 -8
- package/dist/shared/payload-root.d.ts.map +1 -1
- package/dist/shared/segment-info.d.ts +13 -28
- package/dist/shared/segment-info.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/browser-entry/action-dispatch.ts +1 -15
- package/src/client/browser-entry/hydrate.ts +3 -3
- package/src/client/browser-entry/router-init.ts +28 -47
- package/src/client/error-boundary.tsx +49 -9
- package/src/client/history.ts +4 -5
- package/src/client/internal.ts +1 -1
- package/src/client/navigation-commit.ts +25 -83
- package/src/client/outlet-content-cache.ts +119 -0
- package/src/client/outlet-scope-context.ts +42 -0
- package/src/client/params-context.ts +11 -12
- package/src/client/router-pipeline.ts +10 -74
- package/src/client/router-types.ts +11 -26
- package/src/client/router.ts +7 -22
- package/src/client/rsc-fetch.ts +5 -30
- package/src/client/segment-cache.ts +19 -264
- package/src/client/segment-outlet.tsx +80 -72
- package/src/client/stale-segment.ts +60 -0
- package/src/client/use-segment-params.ts +1 -1
- package/src/config-types.ts +7 -6
- package/src/index.ts +0 -2
- package/src/plugin-context.ts +0 -16
- package/src/plugins/build-manifest.ts +1 -22
- package/src/routing/scanner.ts +12 -0
- package/src/routing/segment-keys.ts +9 -35
- package/src/rsc-runtime/vendor-types.d.ts +8 -0
- package/src/server/access-gate.tsx +3 -32
- package/src/server/als-registry.ts +23 -0
- package/src/server/build-manifest.ts +1 -11
- package/src/server/chain-url-parts.ts +3 -21
- package/src/server/client-state-tree.ts +75 -0
- package/src/server/flight-source-node.ts +7 -2
- package/src/server/flight-source.ts +102 -9
- package/src/server/pipeline-interception.ts +1 -1
- package/src/server/publish-params.ts +5 -4
- package/src/server/route-element-builder.ts +77 -206
- package/src/server/rsc-entry/helpers.ts +11 -65
- package/src/server/rsc-entry/render-route.ts +54 -28
- package/src/server/rsc-entry/revalidate-renderer.ts +2 -1
- package/src/server/rsc-entry/rsc-payload.ts +11 -39
- package/src/server/rsc-entry/rsc-stream.ts +123 -101
- package/src/server/rsc-entry/ssr-renderer.ts +1 -3
- package/src/server/segment-hash/capture.ts +232 -0
- package/src/server/segment-hash/outlet.ts +185 -0
- package/src/server/segment-hash/stream-tap.ts +244 -0
- package/src/server/segment-hash/value-hash.ts +338 -0
- package/src/server/slot-resolver.ts +37 -323
- package/src/server/ssr-wrappers.tsx +7 -9
- package/src/server/vite-handoff-rsc.ts +12 -1
- package/src/shared/outlet-decision.ts +54 -0
- package/src/shared/payload-root.ts +5 -8
- package/src/shared/segment-info.ts +13 -28
- package/dist/_chunks/chains-CmzbpG-6.js +0 -1
- package/dist/_chunks/dev-server--4_Ogy_6.js +0 -1
- package/dist/_chunks/dev-span-RsVeYYc_.js.map +0 -1
- package/dist/_chunks/error-boundary-Bh-egWUI.js.map +0 -1
- package/dist/_chunks/flight-source-node-BsrlUjMO.js.map +0 -1
- package/dist/client/segment-update-context.d.ts +0 -15
- package/dist/client/segment-update-context.d.ts.map +0 -1
- package/dist/client/slot-content-cache-context.d.ts +0 -35
- package/dist/client/slot-content-cache-context.d.ts.map +0 -1
- package/dist/native/rsc/server/request-dep.js +0 -12
- package/dist/native/rsc/server/request-dep.js.map +0 -1
- package/dist/native/rsc/server/route-element-helpers.js +0 -20
- package/dist/native/rsc/server/route-element-helpers.js.map +0 -1
- package/dist/native/rsc/server/skippable-prefix.js +0 -72
- package/dist/native/rsc/server/skippable-prefix.js.map +0 -1
- package/dist/native/rsc/server/state-tree-diff.js +0 -35
- package/dist/native/rsc/server/state-tree-diff.js.map +0 -1
- package/dist/native/ssr/client/segment-cache.js +0 -119
- package/dist/native/ssr/client/segment-cache.js.map +0 -1
- package/dist/native/ssr/client/segment-update-context.js +0 -9
- package/dist/native/ssr/client/segment-update-context.js.map +0 -1
- package/dist/native/ssr/client/slot-content-cache-context.js +0 -8
- package/dist/native/ssr/client/slot-content-cache-context.js.map +0 -1
- package/dist/native/ssr/server/state-tree-diff.js +0 -23
- package/dist/native/ssr/server/state-tree-diff.js.map +0 -1
- package/dist/plugins/request-dep/analysis.d.ts +0 -106
- package/dist/plugins/request-dep/analysis.d.ts.map +0 -1
- package/dist/plugins/request-dep/index.d.ts +0 -75
- package/dist/plugins/request-dep/index.d.ts.map +0 -1
- package/dist/plugins/request-dep/origin.d.ts +0 -61
- package/dist/plugins/request-dep/origin.d.ts.map +0 -1
- package/dist/server/request-dep.d.ts +0 -15
- package/dist/server/request-dep.d.ts.map +0 -1
- package/dist/server/route-element-helpers.d.ts +0 -12
- package/dist/server/route-element-helpers.d.ts.map +0 -1
- package/dist/server/skippable-prefix.d.ts +0 -29
- package/dist/server/skippable-prefix.d.ts.map +0 -1
- package/dist/server/state-tree-diff.d.ts +0 -78
- package/dist/server/state-tree-diff.d.ts.map +0 -1
- package/src/client/segment-update-context.ts +0 -23
- package/src/client/slot-content-cache-context.ts +0 -43
- package/src/plugins/request-dep/analysis.ts +0 -447
- package/src/plugins/request-dep/index.ts +0 -376
- package/src/plugins/request-dep/origin.ts +0 -310
- package/src/server/request-dep.ts +0 -37
- package/src/server/route-element-helpers.ts +0 -37
- package/src/server/skippable-prefix.ts +0 -172
- package/src/server/state-tree-diff.ts +0 -132
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* See design/19-client-navigation.md §"State Update Invariants".
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import type { SegmentCache } from './segment-cache.ts';
|
|
14
14
|
import type { HistoryStack } from './history.ts';
|
|
15
15
|
import type { SegmentInfo, StateTree } from '../shared/segment-info.ts';
|
|
16
16
|
import type { ParamsSource } from '../shared/payload-root.ts';
|
|
@@ -28,9 +28,9 @@ import {
|
|
|
28
28
|
// A status page replaces a subtree: a deny page lands at the segment owning
|
|
29
29
|
// the matched file and nothing below it mounts; an `error.tsx` fallback
|
|
30
30
|
// discards everything under the boundary that rendered it. `X-Timber-Segments`
|
|
31
|
-
// nonetheless
|
|
32
|
-
//
|
|
33
|
-
//
|
|
31
|
+
// can nonetheless describe the whole chain the payload was built against — a
|
|
32
|
+
// deny that lands after the headers went out is not in it — so the cache of
|
|
33
|
+
// mounted tree paths has to be told not to learn from such a tree.
|
|
34
34
|
//
|
|
35
35
|
// The HTTP status used to say so, and could not be trusted to: an RSC payload
|
|
36
36
|
// response commits one macrotask after its first chunk, and a nested
|
|
@@ -51,8 +51,8 @@ import {
|
|
|
51
51
|
// hydrated, would otherwise leave a tree in the cache that is no longer on
|
|
52
52
|
// screen. Consuming the flag at commit is what keeps the same navigation from
|
|
53
53
|
// re-seeding it a moment later. Both are over-approximations — a page-level
|
|
54
|
-
// deny leaves every layout standing — at the cost of
|
|
55
|
-
// next navigation.
|
|
54
|
+
// deny leaves every layout standing — at the cost of a narrower interception
|
|
55
|
+
// scope on the next navigation.
|
|
56
56
|
//
|
|
57
57
|
// Slot boundaries do not report: a slot degrading is the page staying, and
|
|
58
58
|
// the chain it mounted is the chain the header describes. See TIM-1356,
|
|
@@ -91,54 +91,6 @@ export interface NavigationCommitInput {
|
|
|
91
91
|
/** When true, clear the segment cache if segmentInfo is absent
|
|
92
92
|
* (popstate replay for entries without layout metadata). */
|
|
93
93
|
clearSegmentCacheOnEmpty?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Layouts the server skipped on this response (`X-Timber-Skipped-Segments`),
|
|
96
|
-
* when it came from a fetch. Omitted by replays and revalidation.
|
|
97
|
-
*
|
|
98
|
-
* Together with `skipped` slot entries in `segmentInfo`, this decides
|
|
99
|
-
* whether the payload can be *replayed*. A partial payload only renders
|
|
100
|
-
* merged over the tree on screen, and a `skip=true` outlet resolves against
|
|
101
|
-
* the slot content cache at render time — so a stored copy of either,
|
|
102
|
-
* replayed later, shows whatever the client holds *then*, not what was on
|
|
103
|
-
* screen when the entry committed. Such entries store a null payload and
|
|
104
|
-
* traversals to them fetch instead. Decided here, not at the fetch call
|
|
105
|
-
* sites, because there are three of those (`performNavigationFetch`,
|
|
106
|
-
* `refresh()`, and uncached traversal) and a rule applied at one of them
|
|
107
|
-
* holds by accident: `performNavigationFetch` had the check and
|
|
108
|
-
* `fetchCommitAndRender` did not, so a back/forward fetch that was
|
|
109
|
-
* answered with skips stored the holes (TIM-1432).
|
|
110
|
-
*/
|
|
111
|
-
skippedSegments?: string[] | null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Whether a response skipped layouts — its payload merges over the tree on screen. */
|
|
115
|
-
export function isPartialNavigation(skippedSegments: string[] | null | undefined): boolean {
|
|
116
|
-
return skippedSegments != null && skippedSegments.length > 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Whether a payload can stand on its own when replayed from the history
|
|
121
|
-
* stack. See `NavigationCommitInput.skippedSegments`.
|
|
122
|
-
*/
|
|
123
|
-
function isReplayable(opts: NavigationCommitInput): boolean {
|
|
124
|
-
return !isPartialNavigation(opts.skippedSegments) && !hasSkippedSlot(opts.segmentInfo);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function hasSkippedSlot(segmentInfo: SegmentInfo[] | null | undefined): boolean {
|
|
128
|
-
return segmentInfo?.some((s) => s.slot && s.skipped) ?? false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The metadata a committed page keeps — on its history entry, and as the
|
|
133
|
-
* current page's `committedSegmentInfo()`. `skipped` describes the
|
|
134
|
-
* *response* — "this slot's content was omitted" — and neither stores such
|
|
135
|
-
* a payload (the entry stores null). Kept, the flag outlives the response:
|
|
136
|
-
* `applyActionResult()` reuses the current page's metadata beside a full
|
|
137
|
-
* re-render and would have that judged non-replayable too.
|
|
138
|
-
*/
|
|
139
|
-
function storedSegmentInfo(segmentInfo: SegmentInfo[] | null | undefined) {
|
|
140
|
-
if (!hasSkippedSlot(segmentInfo)) return segmentInfo;
|
|
141
|
-
return segmentInfo!.map(({ skipped: _skipped, ...rest }) => rest);
|
|
142
94
|
}
|
|
143
95
|
|
|
144
96
|
/**
|
|
@@ -167,10 +119,6 @@ export interface NavigationCommitter {
|
|
|
167
119
|
* (`/a?` against `/a`, a percent-encoded path against a decoded one).
|
|
168
120
|
*/
|
|
169
121
|
committedSegmentInfo(): SegmentInfo[] | null;
|
|
170
|
-
/** Whether segment reuse is currently suppressed (TIM-1466). */
|
|
171
|
-
isSegmentReuseSuppressed(): boolean;
|
|
172
|
-
/** Lift segment reuse suppression after fresh data has been fetched (TIM-1466). */
|
|
173
|
-
restoreSegmentReuse(): void;
|
|
174
122
|
}
|
|
175
123
|
|
|
176
124
|
/**
|
|
@@ -195,6 +143,11 @@ export function createNavigationCommitter(deps: {
|
|
|
195
143
|
historyStack: HistoryStack;
|
|
196
144
|
/** Read at call time — the router's `clientSegmentCache` opt-in. */
|
|
197
145
|
clientSegmentCache: () => boolean | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* The segment hashes the client holds content for, by outlet path
|
|
148
|
+
* (`OutletContentCache.hashes()`). Empty outside a browser router.
|
|
149
|
+
*/
|
|
150
|
+
outletHashes: () => Record<string, string>;
|
|
198
151
|
}): NavigationCommitter {
|
|
199
152
|
const { segmentCache, historyStack } = deps;
|
|
200
153
|
|
|
@@ -205,31 +158,15 @@ export function createNavigationCommitter(deps: {
|
|
|
205
158
|
// navigation to consume the report still empties the cache.
|
|
206
159
|
_setOnStatusPageRendered(() => segmentCache.clear());
|
|
207
160
|
|
|
208
|
-
/**
|
|
209
|
-
* Update the segment cache from server-provided segment metadata.
|
|
210
|
-
*
|
|
211
|
-
* Runs whether or not `clientSegmentCache` is enabled: the tree is also
|
|
212
|
-
* where the mounted tree paths come from, and those cross on every
|
|
213
|
-
* navigation. What the flag gates is which parts get serialized — see
|
|
214
|
-
* `currentStateTree`.
|
|
215
|
-
*/
|
|
216
|
-
function updateSegmentCache(segmentInfo: SegmentInfo[]): void {
|
|
217
|
-
const tree = buildSegmentTree(segmentInfo);
|
|
218
|
-
if (tree) {
|
|
219
|
-
segmentCache.set('/', tree);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
161
|
return {
|
|
224
162
|
committedSegmentInfo: () => committedSegmentInfo,
|
|
225
|
-
isSegmentReuseSuppressed: () => segmentCache.isReuseSuppressed(),
|
|
226
|
-
restoreSegmentReuse: () => segmentCache.restoreReuse(),
|
|
227
163
|
|
|
228
164
|
/**
|
|
229
165
|
* The X-Timber-State-Tree to send with the next RSC request.
|
|
230
166
|
*
|
|
231
|
-
* Two different things travel on one header. `
|
|
232
|
-
*
|
|
167
|
+
* Two different things travel on one header. `hashes` are the caching
|
|
168
|
+
* opt-in — the segment hashes the client holds content for — and are
|
|
169
|
+
* omitted unless `clientSegmentCache` is on (design/52).
|
|
233
170
|
* `treePaths` is how the server learns which route is actually mounted,
|
|
234
171
|
* which stops being derivable from the address bar as soon as a modal is
|
|
235
172
|
* open — so it crosses regardless (TIM-1282). Undefined when there is
|
|
@@ -240,9 +177,14 @@ export function createNavigationCommitter(deps: {
|
|
|
240
177
|
* (TIM-1301).
|
|
241
178
|
*/
|
|
242
179
|
currentStateTree(): StateTree | undefined {
|
|
243
|
-
const tree =
|
|
244
|
-
|
|
245
|
-
|
|
180
|
+
const tree: StateTree = {};
|
|
181
|
+
const treePaths = segmentCache.treePaths();
|
|
182
|
+
if (treePaths.length > 0) tree.treePaths = treePaths;
|
|
183
|
+
if (deps.clientSegmentCache()) {
|
|
184
|
+
const hashes = deps.outletHashes();
|
|
185
|
+
if (Object.keys(hashes).length > 0) tree.hashes = hashes;
|
|
186
|
+
}
|
|
187
|
+
return tree.treePaths || tree.hashes ? tree : undefined;
|
|
246
188
|
},
|
|
247
189
|
|
|
248
190
|
/**
|
|
@@ -276,7 +218,7 @@ export function createNavigationCommitter(deps: {
|
|
|
276
218
|
*/
|
|
277
219
|
prepareNavigation(url: string, opts: NavigationCommitInput): PreparedNavigation {
|
|
278
220
|
const navState = deriveNavigationState(url);
|
|
279
|
-
const payload =
|
|
221
|
+
const payload = opts.payload;
|
|
280
222
|
|
|
281
223
|
// The tree this navigation renders has not rendered yet. Whatever a
|
|
282
224
|
// boundary reported before now belongs to a commit that had no
|
|
@@ -299,12 +241,12 @@ export function createNavigationCommitter(deps: {
|
|
|
299
241
|
const segmentInfo = cacheable ? opts.segmentInfo : [];
|
|
300
242
|
|
|
301
243
|
if (segmentInfo && segmentInfo.length > 0) {
|
|
302
|
-
|
|
244
|
+
segmentCache.record(segmentInfo);
|
|
303
245
|
} else if (segmentInfo?.length === 0 || opts.clearSegmentCacheOnEmpty) {
|
|
304
246
|
segmentCache.clear();
|
|
305
247
|
}
|
|
306
248
|
|
|
307
|
-
committedSegmentInfo =
|
|
249
|
+
committedSegmentInfo = segmentInfo ?? null;
|
|
308
250
|
|
|
309
251
|
historyStack.push(url, {
|
|
310
252
|
payload,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router-owned record of outlet content the client has *committed*, by
|
|
3
|
+
* segment path and the hash the server advertised for it.
|
|
4
|
+
*
|
|
5
|
+
* A skipped outlet renders the content it holds under the skip's hash, so
|
|
6
|
+
* the record is content-addressed: an outlet looks up `(path, hash)`, never
|
|
7
|
+
* "whatever was last at this path". A stored payload replayed later, or a
|
|
8
|
+
* prefetch consumed after the tree moved on, therefore either finds exactly
|
|
9
|
+
* the content the server matched or finds nothing — never a newer or older
|
|
10
|
+
* copy (design/52 §"The client checks before reusing").
|
|
11
|
+
*
|
|
12
|
+
* Ownership and write discipline (TIM-1423):
|
|
13
|
+
*
|
|
14
|
+
* - **One instance per router.** `createTimberRouter` creates it and provides
|
|
15
|
+
* it above every tree it hands to React — hydration included. It is not a
|
|
16
|
+
* module or `globalThis` singleton: `SegmentOutlet` also executes during
|
|
17
|
+
* SSR, where a process-wide record would be shared by concurrent requests.
|
|
18
|
+
* - **Written only at commit.** `SegmentOutlet` records from a layout effect,
|
|
19
|
+
* never during render, so a render React discards — a superseded
|
|
20
|
+
* transition, a Suspense retry — records nothing.
|
|
21
|
+
* - **A hash attaches to its own entry.** The hash arrives after the content
|
|
22
|
+
* (it is computed from the rows that carried it), so the effect records the
|
|
23
|
+
* content first and attaches the hash to that entry when it resolves. An
|
|
24
|
+
* entry without a hash is never advertised.
|
|
25
|
+
* - **`null` outside a router.** SSR renders no provider; the server never
|
|
26
|
+
* sends a skip to a document request, and layout effects do not run there.
|
|
27
|
+
*
|
|
28
|
+
* Singleton context across bundler-duplicated chunks via `createGlobalContext`.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
'use client';
|
|
32
|
+
|
|
33
|
+
import type { ReactNode } from 'react';
|
|
34
|
+
import { createGlobalContext } from './global-context.ts';
|
|
35
|
+
|
|
36
|
+
interface Entry {
|
|
37
|
+
content: ReactNode;
|
|
38
|
+
hash: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Entries kept per path. More than one, so a replayed payload or a prefetch
|
|
43
|
+
* that matched an earlier version still finds it; few, because each holds a
|
|
44
|
+
* whole rendered subtree.
|
|
45
|
+
*/
|
|
46
|
+
const ENTRIES_PER_PATH = 3;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Paths kept, least recently committed evicted first. Bounds the memory the
|
|
50
|
+
* cache pins (each entry holds a rendered subtree) and the `hashes` map the
|
|
51
|
+
* router sends on every navigation, which must stay well inside a server's
|
|
52
|
+
* header limits — the server ignores a map of more than 512 entries.
|
|
53
|
+
*/
|
|
54
|
+
const MAX_PATHS = 64;
|
|
55
|
+
|
|
56
|
+
export class OutletContentCache {
|
|
57
|
+
private readonly byPath = new Map<string, Entry[]>();
|
|
58
|
+
|
|
59
|
+
/** Record content an outlet committed. Returns the entry to attach its hash to. */
|
|
60
|
+
record(segmentPath: string, content: ReactNode): Entry {
|
|
61
|
+
const entries = this.byPath.get(segmentPath) ?? [];
|
|
62
|
+
const entry: Entry = { content, hash: null };
|
|
63
|
+
entries.unshift(entry);
|
|
64
|
+
if (entries.length > ENTRIES_PER_PATH) entries.length = ENTRIES_PER_PATH;
|
|
65
|
+
// Re-inserted, so the Map's order is least recently committed first.
|
|
66
|
+
this.byPath.delete(segmentPath);
|
|
67
|
+
this.byPath.set(segmentPath, entries);
|
|
68
|
+
for (const path of this.byPath.keys()) {
|
|
69
|
+
if (this.byPath.size <= MAX_PATHS) break;
|
|
70
|
+
this.byPath.delete(path);
|
|
71
|
+
}
|
|
72
|
+
return entry;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Attach the server's hash for a recorded entry, if it is still held. */
|
|
76
|
+
attachHash(segmentPath: string, entry: Entry, hash: string): void {
|
|
77
|
+
const entries = this.byPath.get(segmentPath);
|
|
78
|
+
if (!entries?.includes(entry)) return;
|
|
79
|
+
// An identical earlier version is now redundant — keep the newest.
|
|
80
|
+
const duplicate = entries.findIndex((e) => e !== entry && e.hash === hash);
|
|
81
|
+
if (duplicate !== -1) entries.splice(duplicate, 1);
|
|
82
|
+
entry.hash = hash;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The content committed under `hash` at `segmentPath`, if held. */
|
|
86
|
+
lookup(segmentPath: string, hash: string): { content: ReactNode } | undefined {
|
|
87
|
+
return this.byPath.get(segmentPath)?.find((e) => e.hash === hash);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* What to advertise in `X-Timber-State-Tree`: per path, the hash of the
|
|
92
|
+
* most recently committed content — only when it is known. A path whose
|
|
93
|
+
* latest content has no hash yet advertises nothing, which means a resend.
|
|
94
|
+
*/
|
|
95
|
+
hashes(): Record<string, string> {
|
|
96
|
+
const out: Record<string, string> = {};
|
|
97
|
+
for (const [path, entries] of this.byPath) {
|
|
98
|
+
const latest = entries[0];
|
|
99
|
+
if (latest?.hash) out[path] = latest.hash;
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A skip committed content held at `segmentPath`: it is in use, so it moves
|
|
106
|
+
* to the back of the eviction order.
|
|
107
|
+
*/
|
|
108
|
+
touch(segmentPath: string): void {
|
|
109
|
+
const entries = this.byPath.get(segmentPath);
|
|
110
|
+
if (!entries) return;
|
|
111
|
+
this.byPath.delete(segmentPath);
|
|
112
|
+
this.byPath.set(segmentPath, entries);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const OutletContentCacheContext = createGlobalContext<OutletContentCache | null>(
|
|
117
|
+
Symbol.for('__timber_outlet_content_cache_ctx'),
|
|
118
|
+
null
|
|
119
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OutletScopeContext — the decisions a skipped outlet hands to the outlets
|
|
3
|
+
* nested directly inside it.
|
|
4
|
+
*
|
|
5
|
+
* A skipped outlet renders its cached content, and that content still holds
|
|
6
|
+
* the nested `SegmentOutlet` elements from when it was committed — with
|
|
7
|
+
* their old decisions. The skip carries the new ones (`SkipDecision.outlets`)
|
|
8
|
+
* and provides them here, so each old outlet element renders its segment's
|
|
9
|
+
* new decision in place: same element type, same position, so React keeps
|
|
10
|
+
* every component's state below it.
|
|
11
|
+
*
|
|
12
|
+
* Every `SegmentOutlet` provides a scope to its content — the skip's
|
|
13
|
+
* decisions, or none — so the element structure is the same whether a
|
|
14
|
+
* segment was sent or skipped.
|
|
15
|
+
*
|
|
16
|
+
* Singleton across bundler-duplicated chunks via `createGlobalContext`.
|
|
17
|
+
* See design/52-segment-hash-dedupe.md §"Wire format".
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
'use client';
|
|
21
|
+
|
|
22
|
+
import type { OutletDecisionValue } from '../shared/outlet-decision.ts';
|
|
23
|
+
import { createGlobalContext } from './global-context.ts';
|
|
24
|
+
|
|
25
|
+
export interface OutletScope {
|
|
26
|
+
/**
|
|
27
|
+
* Set inside a skipped outlet's cached content. There, an outlet with no
|
|
28
|
+
* entry in `decisions` would render a stale decision, so it refuses to.
|
|
29
|
+
*/
|
|
30
|
+
skipped: boolean;
|
|
31
|
+
decisions: ReadonlyMap<string, OutletDecisionValue>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const LIVE_OUTLET_SCOPE: OutletScope = Object.freeze({
|
|
35
|
+
skipped: false,
|
|
36
|
+
decisions: new Map<string, OutletDecisionValue>(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const OutletScopeContext = createGlobalContext<OutletScope>(
|
|
40
|
+
Symbol.for('__timber_outlet_scope_ctx'),
|
|
41
|
+
LIVE_OUTLET_SCOPE
|
|
42
|
+
);
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
* design/41-global-params.md §"Transport".
|
|
16
16
|
*
|
|
17
17
|
* **The client owns the provider.** There is exactly one `ParamsProvider` in
|
|
18
|
-
* the browser's tree, rendered by `PayloadRoot` above the
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* the
|
|
22
|
-
*
|
|
23
|
-
* amount of wrapping above it helps (TIM-1297).
|
|
18
|
+
* the browser's tree, rendered by `PayloadRoot` above the payload root. It has
|
|
19
|
+
* to be there and it has to be alone: a segment the server skipped renders the
|
|
20
|
+
* content the client cached for it, which carries no provider of its own, so a
|
|
21
|
+
* provider *inside* the payload would never reach a reader in a skipped layout
|
|
22
|
+
* (TIM-1297, design/52-segment-hash-dedupe.md).
|
|
24
23
|
*
|
|
25
24
|
* Ordering still holds without a bootstrap contract, for the same reason it
|
|
26
25
|
* did when the provider was in the tree: a provider renders before its own
|
|
@@ -44,7 +43,7 @@ export type ParamsContextValue = PublishedParams;
|
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* SINGLETON GUARANTEE: globalThis + `Symbol.for`, the same pattern as
|
|
47
|
-
* `NavigationContext` and `
|
|
46
|
+
* `NavigationContext` and `OutletScopeContext`.
|
|
48
47
|
*
|
|
49
48
|
* The RSC client bundler can duplicate a module across chunks, and with ESM
|
|
50
49
|
* output each chunk gets its own module scope — so a bare `createContext` at
|
|
@@ -135,11 +134,11 @@ function ParamsProvider({ params, slotParams, children }: ParamsProviderProps) {
|
|
|
135
134
|
* The client's root: publishes a payload's params over the tree being shown.
|
|
136
135
|
*
|
|
137
136
|
* Rendered at the same position in the wrapper chain on **every** render path
|
|
138
|
-
* — hydration,
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
137
|
+
* — hydration, navigation, popstate replay, shallow search sync, and
|
|
138
|
+
* revalidation from a server action. Being unconditional is load-bearing twice
|
|
139
|
+
* over: an element type that appears on one render and not the next remounts
|
|
140
|
+
* everything below it, destroying exactly the layout state a skipped segment
|
|
141
|
+
* keeps; and a reader in a skipped layout has
|
|
143
142
|
* to have *some* provider above it on every path or it falls back to the
|
|
144
143
|
* module-level snapshot.
|
|
145
144
|
*
|
|
@@ -20,7 +20,7 @@ import type { PrefetchCache, PrefetchKey } from './segment-cache.ts';
|
|
|
20
20
|
import { prefetchScopeOf } from './segment-cache.ts';
|
|
21
21
|
import type { StateTree } from '../shared/segment-info.ts';
|
|
22
22
|
import type { NavigationState } from './navigation-context.ts';
|
|
23
|
-
import {
|
|
23
|
+
import type { NavigationCommitter } from './navigation-commit.ts';
|
|
24
24
|
import type { RouterDeps } from './router-types.ts';
|
|
25
25
|
import type { NavigationHandle, RenderOwner } from './navigation-transition.ts';
|
|
26
26
|
import { recordSkew } from './router-skew.ts';
|
|
@@ -60,7 +60,7 @@ export interface NavigationFetchOptions {
|
|
|
60
60
|
|
|
61
61
|
export interface NavigationPipelineDeps extends Pick<
|
|
62
62
|
NavigationCommitter,
|
|
63
|
-
'prepareNavigation' | 'currentStateTree'
|
|
63
|
+
'prepareNavigation' | 'currentStateTree'
|
|
64
64
|
> {
|
|
65
65
|
deps: RouterDeps;
|
|
66
66
|
prefetchCache: PrefetchCache;
|
|
@@ -93,8 +93,8 @@ export interface NavigationPipeline {
|
|
|
93
93
|
* prefetch cache key — one function so a prefetch and the click that consumes
|
|
94
94
|
* it can never disagree about what "where we came from" means (TIM-1265). The
|
|
95
95
|
* query is dropped deliberately: it would land in the `_rsc` digest, which is
|
|
96
|
-
* logged (TIM-1268), and nothing downstream reads it —
|
|
97
|
-
*
|
|
96
|
+
* logged (TIM-1268), and nothing downstream reads it — interception scope
|
|
97
|
+
* compares pathnames.
|
|
98
98
|
*
|
|
99
99
|
* Absolute inputs parse against the base and ignore it, so one call handles
|
|
100
100
|
* both `location.href` and a bare pathname.
|
|
@@ -126,25 +126,6 @@ export function prefetchKeyFor(
|
|
|
126
126
|
return { url, from: departingPathname(departingUrl), scope: prefetchScopeOf(stateTree) };
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* Build a segment updates map for partial navigation. Identifies the
|
|
131
|
-
* first non-skipped segment and maps it to the payload content.
|
|
132
|
-
*/
|
|
133
|
-
function buildSegmentUpdates(result: FetchResult, payload: unknown): Map<string, unknown> {
|
|
134
|
-
const skipped = new Set(result.skippedSegments!);
|
|
135
|
-
const segmentInfo = result.segmentInfo;
|
|
136
|
-
const updates = new Map<string, unknown>();
|
|
137
|
-
if (segmentInfo) {
|
|
138
|
-
for (const info of segmentInfo) {
|
|
139
|
-
if (!skipped.has(info.segmentId ?? info.path)) {
|
|
140
|
-
updates.set(info.segmentId ?? info.path, payload);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return updates;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
129
|
/**
|
|
149
130
|
* Inspect a decode rejection for version skew before handing the promise on,
|
|
150
131
|
* without changing what the consumer sees.
|
|
@@ -165,8 +146,6 @@ export function createNavigationPipeline({
|
|
|
165
146
|
prefetchCache,
|
|
166
147
|
currentStateTree,
|
|
167
148
|
prepareNavigation,
|
|
168
|
-
isSegmentReuseSuppressed,
|
|
169
|
-
restoreSegmentReuse,
|
|
170
149
|
markHandedOff,
|
|
171
150
|
forgetOlderHandoffs,
|
|
172
151
|
}: NavigationPipelineDeps): NavigationPipeline {
|
|
@@ -223,28 +202,9 @@ export function createNavigationPipeline({
|
|
|
223
202
|
// only on the paths that called it.
|
|
224
203
|
const payload = await result.payload;
|
|
225
204
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// Re-wrap the CURRENT element with new context values.
|
|
230
|
-
// SegmentOutlets read updates from SegmentUpdateContext;
|
|
231
|
-
// NavigationProvider gets the new pathname; the params published
|
|
232
|
-
// above the retained tree are the *incoming* route's.
|
|
233
|
-
const element = wrapPayload(
|
|
234
|
-
deps._getCurrentPayload?.() ?? payload,
|
|
235
|
-
result.navState,
|
|
236
|
-
params,
|
|
237
|
-
segmentUpdates
|
|
238
|
-
);
|
|
239
|
-
handOff();
|
|
240
|
-
return {
|
|
241
|
-
element,
|
|
242
|
-
decodePromise: observeSkew(result.decodePromise),
|
|
243
|
-
commit: commitAndForget(result.commit),
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Full navigation — empty updates, render the new tree.
|
|
205
|
+
// Every navigation renders the payload root. Segments the server
|
|
206
|
+
// skipped render the content the client holds for them, in place
|
|
207
|
+
// (client/segment-outlet.tsx), so their state survives.
|
|
248
208
|
const element = wrapPayload(payload, result.navState, params);
|
|
249
209
|
handOff();
|
|
250
210
|
return {
|
|
@@ -276,11 +236,6 @@ export function createNavigationPipeline({
|
|
|
276
236
|
// `currentUrl` is read back off the key rather than computed beside it, so
|
|
277
237
|
// the pathname sent as X-Timber-URL is the one the lookup used.
|
|
278
238
|
const stateTree = currentStateTree();
|
|
279
|
-
// Capture whether reuse is suppressed at the time we build the state
|
|
280
|
-
// tree. If so, segments/slots are empty and the server will send a
|
|
281
|
-
// full render. We restore reuse after the response is processed so
|
|
282
|
-
// only navigations that fetched with suppression can lift it (TIM-1466).
|
|
283
|
-
let reuseSuppressedAtFetch = isSegmentReuseSuppressed();
|
|
284
239
|
const cacheKey = prefetchKeyFor(url, options.departingUrl ?? deps.getCurrentUrl(), stateTree);
|
|
285
240
|
const currentUrl = cacheKey.from;
|
|
286
241
|
|
|
@@ -307,7 +262,6 @@ export function createNavigationPipeline({
|
|
|
307
262
|
// the prefetch that started it (TIM-1275).
|
|
308
263
|
decodePromise: prefetched.decodePromise ?? null,
|
|
309
264
|
segmentInfo: prefetched.segmentInfo ?? null,
|
|
310
|
-
skippedSegments: prefetched.skippedSegments ?? null,
|
|
311
265
|
}
|
|
312
266
|
: undefined;
|
|
313
267
|
|
|
@@ -344,7 +298,6 @@ export function createNavigationPipeline({
|
|
|
344
298
|
params: outcome.result.params ?? readPublishedParams(undefined),
|
|
345
299
|
decodePromise: outcome.result.decodePromise ?? null,
|
|
346
300
|
segmentInfo: outcome.result.segmentInfo ?? null,
|
|
347
|
-
skippedSegments: outcome.result.skippedSegments ?? null,
|
|
348
301
|
};
|
|
349
302
|
}
|
|
350
303
|
} catch (error) {
|
|
@@ -368,12 +321,8 @@ export function createNavigationPipeline({
|
|
|
368
321
|
if (result === undefined) {
|
|
369
322
|
// No in-flight hover prefetch, or the joined flight failed — fetch
|
|
370
323
|
// directly with the navigation's signal so superseded navigations
|
|
371
|
-
// abort immediately.
|
|
372
|
-
//
|
|
373
|
-
// through because an invalidation bumped the eviction gen,
|
|
374
|
-
// invalidateReuse() has suppressed segment/slot reuse since our
|
|
375
|
-
// original capture (TIM-1466, codex on #1167).
|
|
376
|
-
reuseSuppressedAtFetch = isSegmentReuseSuppressed();
|
|
324
|
+
// abort immediately. The state tree is resampled: hashes the client
|
|
325
|
+
// recorded while it waited on a joined flight are worth advertising.
|
|
377
326
|
const freshStateTree = currentStateTree();
|
|
378
327
|
result = await fetchRscPayload(url, deps, freshStateTree, currentUrl, options.signal);
|
|
379
328
|
}
|
|
@@ -401,26 +350,13 @@ export function createNavigationPipeline({
|
|
|
401
350
|
const params = await result.params;
|
|
402
351
|
|
|
403
352
|
// Prepare the atomic navigation-state update. It is published by the
|
|
404
|
-
// caller once this navigation is known to have won (TIM-1301).
|
|
405
|
-
// the payload is stored for replay — not when it has skip holes — is
|
|
406
|
-
// `prepareNavigation`'s decision, made from `skippedSegments` and
|
|
407
|
-
// `segmentInfo` (TIM-1432).
|
|
353
|
+
// caller once this navigation is known to have won (TIM-1301).
|
|
408
354
|
const { navState, commit } = prepareNavigation(url, {
|
|
409
355
|
payload: result.payload,
|
|
410
356
|
params,
|
|
411
357
|
segmentInfo: result.segmentInfo,
|
|
412
|
-
skippedSegments: result.skippedSegments,
|
|
413
358
|
});
|
|
414
359
|
|
|
415
|
-
// This navigation's fetch used the suppressed state tree (empty
|
|
416
|
-
// segments/slots), so the server sent a full render. The response
|
|
417
|
-
// data is post-invalidation — safe to restore reuse for subsequent
|
|
418
|
-
// navigations. Must happen here (at response time, before the commit
|
|
419
|
-
// thunk), not in set(), because a pre-invalidation navigation's
|
|
420
|
-
// commit thunk also calls set() and would lift suppression too early
|
|
421
|
-
// (codex on #1167).
|
|
422
|
-
if (reuseSuppressedAtFetch) restoreSegmentReuse();
|
|
423
|
-
|
|
424
360
|
return {
|
|
425
361
|
...result,
|
|
426
362
|
params,
|
|
@@ -14,6 +14,7 @@ import type { ParamsSource } from '../shared/payload-root.ts';
|
|
|
14
14
|
import type { SegmentInfo } from '../shared/segment-info.ts';
|
|
15
15
|
import type { SegmentCache, PrefetchCache } from './segment-cache.ts';
|
|
16
16
|
import type { TransitionResult, NavigationHandle, RenderOwner } from './navigation-transition.ts';
|
|
17
|
+
import type { OutletContentCache } from './outlet-content-cache.ts';
|
|
17
18
|
import type { NavigationEpoch } from './router-lifecycle.ts';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -132,15 +133,8 @@ export interface RouterDeps {
|
|
|
132
133
|
wrapPayload: (
|
|
133
134
|
payload: unknown,
|
|
134
135
|
navState: NavigationState,
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
* `payload` is the *retained* tree and these are the *incoming*
|
|
138
|
-
* route's — the two deliberately come from different payloads,
|
|
139
|
-
* which is the entire point of the client owning the provider
|
|
140
|
-
* (TIM-1297).
|
|
141
|
-
*/
|
|
142
|
-
params: ParamsSource,
|
|
143
|
-
segmentUpdates?: Map<string, unknown>
|
|
136
|
+
/** The params to publish over `payload` (TIM-1297). */
|
|
137
|
+
params: ParamsSource
|
|
144
138
|
) => unknown
|
|
145
139
|
) => Promise<TransitionResult<unknown>>
|
|
146
140
|
) => NavigationHandle;
|
|
@@ -151,13 +145,6 @@ export interface RouterDeps {
|
|
|
151
145
|
*/
|
|
152
146
|
saveNavigationEntryScroll?: (scrollY: number) => void;
|
|
153
147
|
|
|
154
|
-
/**
|
|
155
|
-
* Get the current unwrapped RSC payload element. Used for partial
|
|
156
|
-
* navigation: the router re-wraps the same element with new
|
|
157
|
-
* NavigationProvider context so mounted SegmentOutlets are preserved.
|
|
158
|
-
*/
|
|
159
|
-
_getCurrentPayload?: () => unknown;
|
|
160
|
-
|
|
161
148
|
/**
|
|
162
149
|
* Scroll the element matching a URL #fragment into view. Returns true
|
|
163
150
|
* when a matching element was found and scrolled. When absent or false,
|
|
@@ -168,8 +155,8 @@ export interface RouterDeps {
|
|
|
168
155
|
|
|
169
156
|
/**
|
|
170
157
|
* Whether the client segment cache is enabled. When false (the default),
|
|
171
|
-
* the router
|
|
172
|
-
*
|
|
158
|
+
* the router advertises no segment hashes, so the server sends every
|
|
159
|
+
* segment (design/52-segment-hash-dedupe.md).
|
|
173
160
|
*
|
|
174
161
|
* It does NOT gate the `treePaths` half of X-Timber-State-Tree. Those
|
|
175
162
|
* describe the tree currently mounted, and interception scoping needs them
|
|
@@ -177,6 +164,12 @@ export interface RouterDeps {
|
|
|
177
164
|
* optimization, so it must not depend on a performance opt-in (TIM-1282).
|
|
178
165
|
*/
|
|
179
166
|
clientSegmentCache?: boolean;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The router's record of committed outlet content and its hashes — the
|
|
170
|
+
* source of the hashes the router advertises. Absent outside a browser.
|
|
171
|
+
*/
|
|
172
|
+
outletContentCache?: OutletContentCache;
|
|
180
173
|
}
|
|
181
174
|
|
|
182
175
|
export interface RouterInstance {
|
|
@@ -270,14 +263,6 @@ export interface RouterInstance {
|
|
|
270
263
|
* displaces a suspended transition (TIM-1480).
|
|
271
264
|
*/
|
|
272
265
|
settleHandoffs(): void;
|
|
273
|
-
/**
|
|
274
|
-
* Make the next navigation a full render: the server re-renders every
|
|
275
|
-
* segment instead of skipping the shared layouts the client reports as
|
|
276
|
-
* mounted (TIM-1466). Called when `revalidatePath` named a page other
|
|
277
|
-
* than the current one — a layout that page shares with this one may now
|
|
278
|
-
* be stale, and the server cannot tell that from the state tree.
|
|
279
|
-
*/
|
|
280
|
-
suppressSegmentReuse(): void;
|
|
281
266
|
/**
|
|
282
267
|
* Evict all prefetch cache entries and history stack payloads (TIM-1476).
|
|
283
268
|
* Called after a server action that revalidated data — the mutation may
|