@timber-js/app 0.2.0-alpha.240 → 0.2.0-alpha.242
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-DIgnvDrG.js → actions-BkwgRwCl.js} +146 -12
- package/dist/_chunks/actions-BkwgRwCl.js.map +1 -0
- package/dist/_chunks/{als-registry-PPYstxK0.js → als-registry-C-iwbtvI.js} +4 -3
- package/dist/_chunks/{als-registry-PPYstxK0.js.map → als-registry-C-iwbtvI.js.map} +1 -1
- package/dist/_chunks/{als-slots-kbQrHTzm.js → als-slots-CVTF-AMz.js} +3 -3
- package/dist/_chunks/als-slots-CVTF-AMz.js.map +1 -0
- package/dist/_chunks/{cache-api-uWQwuxWb.js → cache-api-BGA7c5qJ.js} +5 -5
- package/dist/_chunks/{cache-api-uWQwuxWb.js.map → cache-api-BGA7c5qJ.js.map} +1 -1
- package/dist/_chunks/{chains-C7CExrUI.js → chains-Cuwwjv6T.js} +2 -2
- package/dist/_chunks/{chains-C7CExrUI.js.map → chains-Cuwwjv6T.js.map} +1 -1
- package/dist/_chunks/chains-LGjBHfSN.js +1 -0
- package/dist/_chunks/{classify-Cj9EeZoL.js → classify-Y8S9C0Na.js} +2 -2
- package/dist/_chunks/{classify-Cj9EeZoL.js.map → classify-Y8S9C0Na.js.map} +1 -1
- package/dist/_chunks/{cli-check-C3QOAru7.js → cli-check-KeE1QaIx.js} +7 -6
- package/dist/_chunks/cli-check-KeE1QaIx.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-DQUS_o3V.js → cli-schema-sync-DZEF31wd.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-DQUS_o3V.js.map → cli-schema-sync-DZEF31wd.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-BRxZz66D.js → cli-schema-sync-_y5O6MIg.js} +1 -1
- package/dist/_chunks/{client-dep-entries-ZETBdLgv.js → client-dep-entries-DpiwvoDi.js} +2 -2
- package/dist/_chunks/{client-dep-entries-ZETBdLgv.js.map → client-dep-entries-DpiwvoDi.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Dk5Hqo-O.js → cloudflare-9dbhVOxS.js} +2 -2
- package/dist/_chunks/{cloudflare-Dk5Hqo-O.js.map → cloudflare-9dbhVOxS.js.map} +1 -1
- package/dist/_chunks/{convention-lint-BoVISNS6.js → convention-lint-0AEsPK2T.js} +378 -10
- package/dist/_chunks/convention-lint-0AEsPK2T.js.map +1 -0
- package/dist/_chunks/dev-server-CboXr8zX.js +1 -0
- package/dist/_chunks/{dev-server-C5R6jx8Q.js → dev-server-DYDr8KIc.js} +9 -3
- package/dist/_chunks/dev-server-DYDr8KIc.js.map +1 -0
- package/dist/_chunks/{dist-C1Rjlo6s.js → dist-GyaJm4GA.js} +18 -2
- package/dist/_chunks/dist-GyaJm4GA.js.map +1 -0
- package/dist/_chunks/{error-boundary-DB51f9ih.js → error-boundary-wuNvAJ4n.js} +11 -14
- package/dist/_chunks/error-boundary-wuNvAJ4n.js.map +1 -0
- package/dist/_chunks/{flight-source-node-D9cHBhjP.js → flight-source-node-KQsX_OhS.js} +4 -7
- package/dist/_chunks/flight-source-node-KQsX_OhS.js.map +1 -0
- package/dist/_chunks/{json-lossy-check-Y1GxqVX_.js → json-lossy-check-BVDALqMf.js} +2 -2
- package/dist/_chunks/{json-lossy-check-Y1GxqVX_.js.map → json-lossy-check-BVDALqMf.js.map} +1 -1
- package/dist/_chunks/key-headers-uIig1_mU.js +40 -0
- package/dist/_chunks/key-headers-uIig1_mU.js.map +1 -0
- package/dist/_chunks/{live-graph-BDQWvnMm.js → live-graph-VhzO7Ol9.js} +4 -4
- package/dist/_chunks/{live-graph-BDQWvnMm.js.map → live-graph-VhzO7Ol9.js.map} +1 -1
- package/dist/_chunks/{logger-DmRR9tmZ.js → logger-C4m8rfMy.js} +2 -2
- package/dist/_chunks/{logger-DmRR9tmZ.js.map → logger-C4m8rfMy.js.map} +1 -1
- package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
- package/dist/_chunks/{node-response-yp8zdyRp.js → node-response-8Vz29cGS.js} +2 -2
- package/dist/_chunks/{node-response-yp8zdyRp.js.map → node-response-8Vz29cGS.js.map} +1 -1
- package/dist/_chunks/{poison-scan-WQgUydF_.js → poison-scan-Dpl3ibG-.js} +2 -2
- package/dist/_chunks/{poison-scan-WQgUydF_.js.map → poison-scan-Dpl3ibG-.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-D0cb0Gmc.js → rsc-cache-key-BGvUtMtN.js} +40 -4
- package/dist/_chunks/{rsc-cache-key-D0cb0Gmc.js.map → rsc-cache-key-BGvUtMtN.js.map} +1 -1
- package/dist/_chunks/{scanner-C9Lrf77z.js → scanner-CCEHN9Jg.js} +14 -81
- package/dist/_chunks/scanner-CCEHN9Jg.js.map +1 -0
- package/dist/_chunks/{sizeof-BISkSaU0.js → sizeof-CIF7fwSJ.js} +2 -2
- package/dist/_chunks/{sizeof-BISkSaU0.js.map → sizeof-CIF7fwSJ.js.map} +1 -1
- package/dist/_chunks/{walkers-Bxv4v7tX.js → walkers-BbotBhNG.js} +3 -3
- package/dist/_chunks/{walkers-Bxv4v7tX.js.map → walkers-BbotBhNG.js.map} +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +2 -2
- package/dist/adapters/cloudflare.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-check.d.ts +3 -0
- package/dist/cli-check.d.ts.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/client/browser-entry/router-init.d.ts +0 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +4 -5
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-commit.d.ts +3 -5
- package/dist/client/navigation-commit.d.ts.map +1 -1
- package/dist/client/outlet-content-cache.d.ts +25 -30
- package/dist/client/outlet-content-cache.d.ts.map +1 -1
- package/dist/client/outlet-scope-context.d.ts +4 -4
- package/dist/client/outlet-scope-context.d.ts.map +1 -1
- package/dist/client/params-context.d.ts +1 -1
- package/dist/client/router-types.d.ts +3 -13
- package/dist/client/router-types.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +2 -2
- package/dist/client/segment-outlet.d.ts +12 -13
- package/dist/client/segment-outlet.d.ts.map +1 -1
- package/dist/client/stale-segment.d.ts +2 -2
- package/dist/config-types.d.ts +22 -15
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +5 -2
- package/dist/cookies/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -26
- package/dist/index.js.map +1 -1
- package/dist/native/rsc/cookies/define-cookie.js +6 -2
- package/dist/native/rsc/cookies/define-cookie.js.map +1 -1
- package/dist/native/rsc/manifest.json +12 -4
- package/dist/native/rsc/routing/segment-keys.js +11 -1
- package/dist/native/rsc/routing/segment-keys.js.map +1 -1
- package/dist/native/rsc/search-params/define.js +4 -1
- package/dist/native/rsc/search-params/define.js.map +1 -1
- package/dist/native/rsc/server/als-registry.js +2 -2
- package/dist/native/rsc/server/als-registry.js.map +1 -1
- package/dist/native/rsc/server/client-state-tree.js +13 -12
- package/dist/native/rsc/server/client-state-tree.js.map +1 -1
- package/dist/native/rsc/server/cookie-context.js +12 -0
- package/dist/native/rsc/server/cookie-context.js.map +1 -1
- package/dist/native/rsc/server/flight-source-node.js +2 -5
- package/dist/native/rsc/server/flight-source-node.js.map +1 -1
- package/dist/native/rsc/server/flight-source.js +8 -40
- package/dist/native/rsc/server/flight-source.js.map +1 -1
- package/dist/native/rsc/server/framework-stack-frames.js +18 -0
- package/dist/native/rsc/server/framework-stack-frames.js.map +1 -0
- package/dist/native/rsc/server/prebuilt-builder.js +15 -1
- package/dist/native/rsc/server/prebuilt-builder.js.map +1 -1
- package/dist/native/rsc/server/request-context.js +11 -5
- package/dist/native/rsc/server/request-context.js.map +1 -1
- package/dist/native/rsc/server/route-element-builder.js +29 -11
- package/dist/native/rsc/server/route-element-builder.js.map +1 -1
- package/dist/native/rsc/server/route-module-loader.js +14 -6
- package/dist/native/rsc/server/route-module-loader.js.map +1 -1
- package/dist/native/rsc/server/rsc-cache-key-guard.js +5 -1
- package/dist/native/rsc/server/rsc-cache-key-guard.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/render-route.js +10 -29
- package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +7 -2
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/rsc-stream.js +2 -5
- package/dist/native/rsc/server/rsc-entry/rsc-stream.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/document-outlet.js +24 -0
- package/dist/native/rsc/server/segment-lifetime/document-outlet.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/key-digest.js +74 -0
- package/dist/native/rsc/server/segment-lifetime/key-digest.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/outlet-gate.js +44 -0
- package/dist/native/rsc/server/segment-lifetime/outlet-gate.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/read-rule.js +78 -0
- package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/read-scope.js +41 -0
- package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/segment-key.js +64 -0
- package/dist/native/rsc/server/segment-lifetime/segment-key.js.map +1 -0
- package/dist/native/rsc/server/segment-lifetime/slot-outlets.js +72 -0
- package/dist/native/rsc/server/segment-lifetime/slot-outlets.js.map +1 -0
- package/dist/native/rsc/server/slot-resolver.js +51 -27
- package/dist/native/rsc/server/slot-resolver.js.map +1 -1
- package/dist/native/rsc/server/slot-subtree-contain.js +17 -89
- package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
- package/dist/native/rsc/server/subtree-walk.js +140 -0
- package/dist/native/rsc/server/subtree-walk.js.map +1 -0
- package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/rsc/shared/als-slots.js +2 -2
- package/dist/native/rsc/shared/als-slots.js.map +1 -1
- package/dist/native/rsc/shared/cookie-read-through.js +5 -0
- package/dist/native/rsc/shared/cookie-read-through.js.map +1 -0
- package/dist/native/rsc/shared/key-headers.js +20 -0
- package/dist/native/rsc/shared/key-headers.js.map +1 -0
- package/dist/native/rsc/shared/outlet-decision.js.map +1 -1
- package/dist/native/rsc/shared/route-options-export.js +8 -0
- package/dist/native/rsc/shared/route-options-export.js.map +1 -0
- package/dist/native/rsc/shared/rsc-cache-key.js +19 -3
- package/dist/native/rsc/shared/rsc-cache-key.js.map +1 -1
- package/dist/native/rsc/shims/headers.js +3 -4
- package/dist/native/rsc/shims/headers.js.map +1 -1
- package/dist/native/ssr/client/outlet-content-cache.js +12 -18
- package/dist/native/ssr/client/outlet-content-cache.js.map +1 -1
- package/dist/native/ssr/client/outlet-scope-context.js.map +1 -1
- package/dist/native/ssr/client/segment-outlet.js +6 -19
- package/dist/native/ssr/client/segment-outlet.js.map +1 -1
- package/dist/native/ssr/cookies/define-cookie.js +6 -2
- package/dist/native/ssr/cookies/define-cookie.js.map +1 -1
- package/dist/native/ssr/manifest.json +5 -1
- package/dist/native/ssr/search-params/define.js +4 -1
- package/dist/native/ssr/search-params/define.js.map +1 -1
- package/dist/native/ssr/server/als-registry.js +2 -2
- package/dist/native/ssr/server/als-registry.js.map +1 -1
- package/dist/native/ssr/server/client-state-tree.js +13 -12
- package/dist/native/ssr/server/client-state-tree.js.map +1 -1
- package/dist/native/ssr/server/cookie-context.js +12 -0
- package/dist/native/ssr/server/cookie-context.js.map +1 -1
- package/dist/native/ssr/server/flight-source-node.js +2 -5
- package/dist/native/ssr/server/flight-source-node.js.map +1 -1
- package/dist/native/ssr/server/flight-source.js +1 -1
- package/dist/native/ssr/server/flight-source.js.map +1 -1
- package/dist/native/ssr/server/framework-stack-frames.js +18 -0
- package/dist/native/ssr/server/framework-stack-frames.js.map +1 -0
- package/dist/native/ssr/server/request-context.js +11 -5
- package/dist/native/ssr/server/request-context.js.map +1 -1
- package/dist/native/ssr/server/rsc-cache-key-guard.js +5 -1
- package/dist/native/ssr/server/rsc-cache-key-guard.js.map +1 -1
- package/dist/native/ssr/server/segment-lifetime/key-digest.js +6 -0
- package/dist/native/ssr/server/segment-lifetime/key-digest.js.map +1 -0
- package/dist/native/ssr/server/segment-lifetime/read-rule.js +78 -0
- package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -0
- package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/ssr/shared/als-slots.js +2 -2
- package/dist/native/ssr/shared/als-slots.js.map +1 -1
- package/dist/native/ssr/shared/cookie-read-through.js +5 -0
- package/dist/native/ssr/shared/cookie-read-through.js.map +1 -0
- package/dist/native/ssr/shared/key-headers.js +13 -0
- package/dist/native/ssr/shared/key-headers.js.map +1 -0
- package/dist/native/ssr/shared/rsc-cache-key.js +19 -3
- package/dist/native/ssr/shared/rsc-cache-key.js.map +1 -1
- package/dist/native/ssr/shims/headers.js +3 -4
- package/dist/native/ssr/shims/headers.js.map +1 -1
- package/dist/plugins/callsite-jsx.d.ts +8 -1
- package/dist/plugins/callsite-jsx.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/prerender-sugar.d.ts +9 -8
- package/dist/plugins/prerender-sugar.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts +11 -3
- package/dist/routing/convention-lint.d.ts.map +1 -1
- package/dist/routing/export-detect.d.ts +50 -23
- package/dist/routing/export-detect.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/routing/route-options-lint.d.ts +36 -0
- package/dist/routing/route-options-lint.d.ts.map +1 -0
- package/dist/routing/route-options.d.ts +55 -0
- package/dist/routing/route-options.d.ts.map +1 -0
- package/dist/routing/segment-keys.d.ts +38 -4
- package/dist/routing/segment-keys.d.ts.map +1 -1
- package/dist/search-params/index.js +5 -2
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/als-registry.d.ts +22 -13
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/client-state-tree.d.ts +11 -10
- package/dist/server/client-state-tree.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +3 -0
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts +1 -6
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts +4 -28
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/framework-stack-frames.d.ts +20 -0
- package/dist/server/framework-stack-frames.d.ts.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +102 -28
- package/dist/server/internal.js.map +1 -1
- package/dist/server/prebuilt/capture-routes.d.ts +1 -1
- package/dist/server/prebuilt-builder.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +6 -1
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +2 -2
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-module-loader.d.ts +10 -2
- package/dist/server/route-module-loader.d.ts.map +1 -1
- package/dist/server/rsc-cache-key-guard.d.ts +3 -1
- package/dist/server/rsc-cache-key-guard.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +10 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/revalidate-renderer.d.ts +12 -0
- package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +2 -11
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/segment-lifetime/document-outlet.d.ts +66 -0
- package/dist/server/segment-lifetime/document-outlet.d.ts.map +1 -0
- package/dist/server/segment-lifetime/key-digest.d.ts +46 -0
- package/dist/server/segment-lifetime/key-digest.d.ts.map +1 -0
- package/dist/server/segment-lifetime/outlet-gate.d.ts +58 -0
- package/dist/server/segment-lifetime/outlet-gate.d.ts.map +1 -0
- package/dist/server/segment-lifetime/read-rule.d.ts +53 -0
- package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -0
- package/dist/server/segment-lifetime/read-scope.d.ts +40 -0
- package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -0
- package/dist/server/segment-lifetime/segment-key.d.ts +63 -0
- package/dist/server/segment-lifetime/segment-key.d.ts.map +1 -0
- package/dist/server/segment-lifetime/slot-outlets.d.ts +81 -0
- package/dist/server/segment-lifetime/slot-outlets.d.ts.map +1 -0
- package/dist/server/slot-resolver.d.ts +10 -5
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/slot-subtree-contain.d.ts +2 -6
- package/dist/server/slot-subtree-contain.d.ts.map +1 -1
- package/dist/server/subtree-walk.d.ts +56 -0
- package/dist/server/subtree-walk.d.ts.map +1 -0
- package/dist/server/types.d.ts +75 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/vite-handoff-rsc.d.ts +1 -10
- package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
- package/dist/shared/als-slots.d.ts +12 -2
- package/dist/shared/als-slots.d.ts.map +1 -1
- package/dist/shared/cookie-read-through.d.ts +18 -0
- package/dist/shared/cookie-read-through.d.ts.map +1 -0
- package/dist/shared/key-headers.d.ts +13 -0
- package/dist/shared/key-headers.d.ts.map +1 -0
- package/dist/shared/outlet-decision.d.ts +16 -28
- package/dist/shared/outlet-decision.d.ts.map +1 -1
- package/dist/shared/payload-root.d.ts +1 -1
- package/dist/shared/route-options-export.d.ts +13 -0
- package/dist/shared/route-options-export.d.ts.map +1 -0
- package/dist/shared/rsc-cache-key.d.ts +22 -0
- package/dist/shared/rsc-cache-key.d.ts.map +1 -1
- package/dist/shared/segment-info.d.ts +7 -5
- package/dist/shared/segment-info.d.ts.map +1 -1
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +29 -0
- package/docs/api/32-api-cache.mdx +10 -4
- package/docs/api/34-api-config.mdx +5 -0
- package/docs/learn/09-streaming.mdx +6 -2
- package/docs/learn/10-caching.mdx +10 -4
- package/package.json +1 -1
- package/src/cli-check.ts +11 -3
- package/src/client/browser-entry/index.ts +0 -2
- package/src/client/browser-entry/router-init.ts +2 -4
- package/src/client/error-boundary.tsx +1 -1
- package/src/client/navigation-commit.ts +9 -14
- package/src/client/outlet-content-cache.ts +36 -42
- package/src/client/outlet-scope-context.ts +5 -5
- package/src/client/params-context.ts +1 -1
- package/src/client/router-types.ts +3 -14
- package/src/client/router.ts +1 -2
- package/src/client/rsc-fetch.ts +1 -1
- package/src/client/segment-cache.ts +2 -2
- package/src/client/segment-outlet.tsx +19 -45
- package/src/client/stale-segment.ts +2 -2
- package/src/config-types.ts +23 -15
- package/src/config-validation.ts +17 -1
- package/src/cookies/define-cookie.ts +5 -1
- package/src/index.ts +2 -1
- package/src/plugins/callsite-jsx.ts +104 -6
- package/src/plugins/entries.ts +3 -1
- package/src/plugins/prerender-sugar.ts +34 -18
- package/src/plugins/routing.ts +3 -1
- package/src/routing/convention-lint.ts +18 -7
- package/src/routing/export-detect.ts +14 -117
- package/src/routing/route-options-lint.ts +153 -0
- package/src/routing/route-options.ts +439 -0
- package/src/routing/scanner.ts +1 -1
- package/src/routing/segment-keys.ts +53 -4
- package/src/rsc-runtime/vendor-types.d.ts +5 -1
- package/src/search-params/define.ts +1 -1
- package/src/server/als-registry.ts +25 -17
- package/src/server/client-state-tree.ts +30 -27
- package/src/server/cookie-context.ts +17 -0
- package/src/server/flight-source-node.ts +1 -5
- package/src/server/flight-source.ts +8 -82
- package/src/server/framework-stack-frames.ts +41 -0
- package/src/server/index.ts +7 -0
- package/src/server/prebuilt/capture-routes.ts +1 -1
- package/src/server/prebuilt-builder.ts +30 -2
- package/src/server/request-context.ts +31 -6
- package/src/server/route-element-builder.ts +92 -18
- package/src/server/route-module-loader.ts +43 -10
- package/src/server/rsc-cache-key-guard.ts +17 -2
- package/src/server/rsc-entry/helpers.ts +1 -1
- package/src/server/rsc-entry/index.ts +16 -3
- package/src/server/rsc-entry/render-route.ts +22 -51
- package/src/server/rsc-entry/revalidate-renderer.ts +16 -2
- package/src/server/rsc-entry/rsc-stream.ts +3 -23
- package/src/server/segment-lifetime/document-outlet.ts +98 -0
- package/src/server/segment-lifetime/key-digest.ts +139 -0
- package/src/server/segment-lifetime/outlet-gate.ts +102 -0
- package/src/server/segment-lifetime/read-rule.ts +193 -0
- package/src/server/segment-lifetime/read-scope.ts +101 -0
- package/src/server/segment-lifetime/segment-key.ts +168 -0
- package/src/server/segment-lifetime/slot-outlets.ts +180 -0
- package/src/server/slot-resolver.ts +103 -60
- package/src/server/slot-subtree-contain.ts +35 -182
- package/src/server/subtree-walk.ts +316 -0
- package/src/server/types.ts +91 -0
- package/src/server/vite-handoff-rsc.ts +1 -12
- package/src/shared/als-slots.ts +19 -8
- package/src/shared/cookie-read-through.ts +18 -0
- package/src/shared/key-headers.ts +42 -0
- package/src/shared/outlet-decision.ts +16 -30
- package/src/shared/payload-root.ts +1 -1
- package/src/shared/route-options-export.ts +14 -0
- package/src/shared/rsc-cache-key.ts +41 -2
- package/src/shared/segment-info.ts +7 -5
- package/src/shims/headers.ts +5 -4
- package/dist/_chunks/actions-DIgnvDrG.js.map +0 -1
- package/dist/_chunks/als-slots-kbQrHTzm.js.map +0 -1
- package/dist/_chunks/chains-CSslTUdI.js +0 -1
- package/dist/_chunks/cli-check-C3QOAru7.js.map +0 -1
- package/dist/_chunks/convention-lint-BoVISNS6.js.map +0 -1
- package/dist/_chunks/dev-server-B8roKA3Q.js +0 -1
- package/dist/_chunks/dev-server-C5R6jx8Q.js.map +0 -1
- package/dist/_chunks/dist-C1Rjlo6s.js.map +0 -1
- package/dist/_chunks/error-boundary-DB51f9ih.js.map +0 -1
- package/dist/_chunks/flight-source-node-D9cHBhjP.js.map +0 -1
- package/dist/_chunks/scanner-C9Lrf77z.js.map +0 -1
- package/dist/native/rsc/server/segment-hash/capture.js +0 -107
- package/dist/native/rsc/server/segment-hash/capture.js.map +0 -1
- package/dist/native/rsc/server/segment-hash/outlet.js +0 -81
- package/dist/native/rsc/server/segment-hash/outlet.js.map +0 -1
- package/dist/native/rsc/server/segment-hash/stream-tap.js +0 -139
- package/dist/native/rsc/server/segment-hash/stream-tap.js.map +0 -1
- package/dist/native/rsc/server/segment-hash/value-hash.js +0 -171
- package/dist/native/rsc/server/segment-hash/value-hash.js.map +0 -1
- package/dist/native/ssr/server/segment-hash/value-hash.js +0 -162
- package/dist/native/ssr/server/segment-hash/value-hash.js.map +0 -1
- package/dist/server/segment-hash/capture.d.ts +0 -77
- package/dist/server/segment-hash/capture.d.ts.map +0 -1
- package/dist/server/segment-hash/outlet.d.ts +0 -65
- package/dist/server/segment-hash/outlet.d.ts.map +0 -1
- package/dist/server/segment-hash/stream-tap.d.ts +0 -49
- package/dist/server/segment-hash/stream-tap.d.ts.map +0 -1
- package/dist/server/segment-hash/value-hash.d.ts +0 -70
- package/dist/server/segment-hash/value-hash.d.ts.map +0 -1
- package/src/server/segment-hash/capture.ts +0 -232
- package/src/server/segment-hash/outlet.ts +0 -185
- package/src/server/segment-hash/stream-tap.ts +0 -244
- package/src/server/segment-hash/value-hash.ts +0 -338
|
@@ -40,8 +40,14 @@ import {
|
|
|
40
40
|
childrenOutletKey,
|
|
41
41
|
computeSegmentKeys,
|
|
42
42
|
computeSegmentTreePaths,
|
|
43
|
+
layoutOutletKey,
|
|
44
|
+
pageOutletKey,
|
|
43
45
|
} from '../routing/segment-keys.ts';
|
|
44
|
-
import {
|
|
46
|
+
import { documentOutletFor, pathParamNames } from './segment-lifetime/document-outlet.ts';
|
|
47
|
+
import { getSegmentParams } from './request-context.ts';
|
|
48
|
+
import { inReadScope, readScopeFor } from './segment-lifetime/read-scope.ts';
|
|
49
|
+
import type { ServerComponent } from './subtree-walk.ts';
|
|
50
|
+
import { outletGate, type OutletSpec, type SegmentRender } from './segment-lifetime/outlet-gate.ts';
|
|
45
51
|
import { METADATA_OUTLET_PATH } from '../shared/outlet-decision.ts';
|
|
46
52
|
import { setFirstDeniedSegmentIndex } from './deny-boundary.ts';
|
|
47
53
|
import { loadModule, type ManifestLoader } from './safe-load.ts';
|
|
@@ -181,7 +187,7 @@ export async function buildRouteElement(
|
|
|
181
187
|
req: Request,
|
|
182
188
|
match: RouteMatch,
|
|
183
189
|
interception: InterceptionContext | undefined,
|
|
184
|
-
render:
|
|
190
|
+
render: SegmentRender,
|
|
185
191
|
metadataRouteHashes?: Record<string, string>
|
|
186
192
|
): Promise<RouteElementResult> {
|
|
187
193
|
const segments = match.segments;
|
|
@@ -195,8 +201,19 @@ export async function buildRouteElement(
|
|
|
195
201
|
// placed below each AccessGate — denied segments' metadata() never
|
|
196
202
|
// executes because AccessGate prevents MetadataCollector from rendering.
|
|
197
203
|
// No pre-render access pass needed. See TIM-1363.
|
|
198
|
-
const {
|
|
199
|
-
|
|
204
|
+
const {
|
|
205
|
+
metadataSources,
|
|
206
|
+
layoutComponents,
|
|
207
|
+
PageComponent: LoadedPage,
|
|
208
|
+
deferSuspenseFor,
|
|
209
|
+
accessFns,
|
|
210
|
+
documentLifetimes,
|
|
211
|
+
} = await loadRouteModules(segments, req.url, render.defaultLayoutLifetime);
|
|
212
|
+
// The coerced params every 'document' key on the main chain reads from —
|
|
213
|
+
// read only when a segment needs them.
|
|
214
|
+
const hasDocumentSegment =
|
|
215
|
+
documentLifetimes.page !== undefined || documentLifetimes.layouts.some(Boolean);
|
|
216
|
+
const mainParams = hasDocumentSegment ? getSegmentParams() : {};
|
|
200
217
|
// An intercepted navigation renders a route its URL does not name. The
|
|
201
218
|
// URL's whole access chain gates the tree, from its top, with the URL's
|
|
202
219
|
// params; the segments both chains share get no gate of their own here, so
|
|
@@ -220,6 +237,20 @@ export async function buildRouteElement(
|
|
|
220
237
|
// compares against. One derivation, so a slot cannot be keyed two ways.
|
|
221
238
|
const segmentTreePaths = computeSegmentTreePaths(segments);
|
|
222
239
|
|
|
240
|
+
// A 'document' page runs in its read scope: a read outside its key throws
|
|
241
|
+
// (segment-lifetime/read-scope.ts). A client page never runs on the server.
|
|
242
|
+
const PageComponent =
|
|
243
|
+
documentLifetimes.page && !isClientReference(LoadedPage)
|
|
244
|
+
? inReadScope(
|
|
245
|
+
LoadedPage as ServerComponent,
|
|
246
|
+
readScopeFor(
|
|
247
|
+
pageOutletKey(segmentTreePaths[segments.length - 1]),
|
|
248
|
+
documentLifetimes.page,
|
|
249
|
+
pathParamNames(segments, segments.length - 1)
|
|
250
|
+
)
|
|
251
|
+
)
|
|
252
|
+
: LoadedPage;
|
|
253
|
+
|
|
223
254
|
// Build deny page fallback chains for each segment position.
|
|
224
255
|
// When AccessGate or PageDenyBoundary catches a DenySignal, they render
|
|
225
256
|
// the matching deny page in-tree instead of throwing into React Flight.
|
|
@@ -281,14 +312,35 @@ export async function buildRouteElement(
|
|
|
281
312
|
element = h(TracedPage, {});
|
|
282
313
|
}
|
|
283
314
|
|
|
315
|
+
// A 'document' page has an outlet of its own, so it can be skipped while
|
|
316
|
+
// the layouts above it and the metadata beside it are decided on their own
|
|
317
|
+
// (design/53-segment-lifetime.md §"Skipping"). Inside every access gate and
|
|
318
|
+
// error boundary of its segment, so access always runs.
|
|
319
|
+
let pageOutlet: OutletSpec | undefined;
|
|
320
|
+
if (documentLifetimes.page) {
|
|
321
|
+
const segmentPath = pageOutletKey(segmentTreePaths[leafIndex]);
|
|
322
|
+
pageOutlet = {
|
|
323
|
+
segmentPath,
|
|
324
|
+
content: element,
|
|
325
|
+
nested: [],
|
|
326
|
+
document: await documentOutletFor(
|
|
327
|
+
render,
|
|
328
|
+
segmentPath,
|
|
329
|
+
documentLifetimes.page,
|
|
330
|
+
pathParamNames(segments, leafIndex),
|
|
331
|
+
mainParams
|
|
332
|
+
),
|
|
333
|
+
};
|
|
334
|
+
element = outletGate(pageOutlet);
|
|
335
|
+
}
|
|
336
|
+
|
|
284
337
|
// Metadata is its own outlet, a SIBLING of the page rather than a wrapper.
|
|
285
338
|
// React renders siblings concurrently — the page starts immediately while
|
|
286
339
|
// MetadataHead awaits metadata promises. Float hoists the head elements to
|
|
287
340
|
// <head> regardless of tree position. Both resolve before onShellReady
|
|
288
341
|
// (outside Suspense), but they overlap. As its own outlet, a title that
|
|
289
342
|
// changes does not resend the page beside it, and a page's title does not
|
|
290
|
-
// land in the output of
|
|
291
|
-
// own unit"). See TIM-1363, TIM-1367, design/16-metadata.md.
|
|
343
|
+
// land in the output of a 'document' layout above it, which may be skipped. See TIM-1363, TIM-1367, design/16-metadata.md.
|
|
292
344
|
const metadataOutlet: OutletSpec = {
|
|
293
345
|
segmentPath: METADATA_OUTLET_PATH,
|
|
294
346
|
content: h(MetadataHead, {
|
|
@@ -299,7 +351,7 @@ export async function buildRouteElement(
|
|
|
299
351
|
}),
|
|
300
352
|
nested: [],
|
|
301
353
|
};
|
|
302
|
-
element = h(Fragment, null, outletGate(metadataOutlet
|
|
354
|
+
element = h(Fragment, null, outletGate(metadataOutlet), element);
|
|
303
355
|
|
|
304
356
|
// Build a lookup of layout components by segment for O(1) access.
|
|
305
357
|
const layoutBySegment = new Map(
|
|
@@ -309,8 +361,8 @@ export async function buildRouteElement(
|
|
|
309
361
|
// The outlets built so far that no outlet built so far contains — the ones
|
|
310
362
|
// the next outlet out will hold directly. A skipped outlet carries their
|
|
311
363
|
// decisions, because the client's cached copy of it still holds the old
|
|
312
|
-
// ones (segment-
|
|
313
|
-
let unclaimedOutlets: OutletSpec[] = [metadataOutlet];
|
|
364
|
+
// ones (segment-lifetime/outlet-gate.ts).
|
|
365
|
+
let unclaimedOutlets: OutletSpec[] = pageOutlet ? [metadataOutlet, pageOutlet] : [metadataOutlet];
|
|
314
366
|
|
|
315
367
|
for (let i = segments.length - 1; i >= 0; i--) {
|
|
316
368
|
const segment = segments[i];
|
|
@@ -351,10 +403,15 @@ export async function buildRouteElement(
|
|
|
351
403
|
// See design/04-authorization.md §"Access Failure".
|
|
352
404
|
if (layoutComponent) {
|
|
353
405
|
const segmentId = segmentKeys[i];
|
|
406
|
+
// A 'document' layout's outlet is keyed by its tree path: its skip is
|
|
407
|
+
// identity-addressed, and segment ids collide across route groups
|
|
408
|
+
// (`layoutOutletKey`). A 'request' layout keeps its segment id.
|
|
409
|
+
const layoutLifetime = documentLifetimes.layouts[i];
|
|
410
|
+
const layoutOutletPath = layoutLifetime ? layoutOutletKey(segmentTreePaths[i]) : segmentId;
|
|
354
411
|
|
|
355
412
|
// Everything this layout receives as `children` is one outlet, and the
|
|
356
|
-
// layout's own outlet below is another:
|
|
357
|
-
// chrome, not what renders under it.
|
|
413
|
+
// layout's own outlet below is another: skipping a 'document' layout
|
|
414
|
+
// skips its chrome, not what renders under it.
|
|
358
415
|
const childrenOutlet: OutletSpec = {
|
|
359
416
|
segmentPath: childrenOutletKey(segmentId),
|
|
360
417
|
content: element,
|
|
@@ -377,7 +434,7 @@ export async function buildRouteElement(
|
|
|
377
434
|
|
|
378
435
|
const segmentPath = computeLayoutSegmentPath(segments, i, match);
|
|
379
436
|
const parallelRouteKeys = Object.keys(segment.slots ?? {});
|
|
380
|
-
const layoutProps = { ...slots.props, children: outletGate(childrenOutlet
|
|
437
|
+
const layoutProps = { ...slots.props, children: outletGate(childrenOutlet) };
|
|
381
438
|
|
|
382
439
|
// Build the layout element.
|
|
383
440
|
// Keep the descendant tree in a SERVER layout's children prop. Moving it
|
|
@@ -397,7 +454,13 @@ export async function buildRouteElement(
|
|
|
397
454
|
// AccessGate and PageDenyBoundary). Without this, DenySignal
|
|
398
455
|
// escapes to React Flight onError and triggers the re-render
|
|
399
456
|
// fallback path. See TIM-668, design/04-authorization.md.
|
|
400
|
-
|
|
457
|
+
// A 'document' layout runs in its read scope (segment-lifetime/read-scope.ts).
|
|
458
|
+
const layoutComponentRef = layoutLifetime
|
|
459
|
+
? inReadScope(
|
|
460
|
+
layoutComponent as ServerComponent,
|
|
461
|
+
readScopeFor(layoutOutletPath, layoutLifetime, pathParamNames(segments, i))
|
|
462
|
+
)
|
|
463
|
+
: layoutComponent;
|
|
401
464
|
const layoutDenyPages = denyPageChains.get(i);
|
|
402
465
|
const TracedLayout = async (props: Record<string, unknown>) => {
|
|
403
466
|
try {
|
|
@@ -442,7 +505,7 @@ export async function buildRouteElement(
|
|
|
442
505
|
}
|
|
443
506
|
|
|
444
507
|
const layoutOutlet: OutletSpec = {
|
|
445
|
-
segmentPath:
|
|
508
|
+
segmentPath: layoutOutletPath,
|
|
446
509
|
content: h(clientComponents().SegmentProvider, {
|
|
447
510
|
segments: segmentPath,
|
|
448
511
|
segmentId,
|
|
@@ -450,8 +513,19 @@ export async function buildRouteElement(
|
|
|
450
513
|
children: layoutElement,
|
|
451
514
|
}),
|
|
452
515
|
nested: [childrenOutlet, ...slots.outlets],
|
|
516
|
+
// The URL depth the layout's `SegmentProvider` publishes is part of
|
|
517
|
+
// its output: a key that leaves out a catch-all must still re-render
|
|
518
|
+
// the layout when the depth it reports changes.
|
|
519
|
+
document: await documentOutletFor(
|
|
520
|
+
render,
|
|
521
|
+
layoutOutletPath,
|
|
522
|
+
layoutLifetime,
|
|
523
|
+
pathParamNames(segments, i),
|
|
524
|
+
mainParams,
|
|
525
|
+
segmentPath.length
|
|
526
|
+
),
|
|
453
527
|
};
|
|
454
|
-
element = outletGate(layoutOutlet
|
|
528
|
+
element = outletGate(layoutOutlet);
|
|
455
529
|
unclaimedOutlets = [layoutOutlet];
|
|
456
530
|
}
|
|
457
531
|
|
|
@@ -461,9 +535,9 @@ export async function buildRouteElement(
|
|
|
461
535
|
// exactly once, during render, inside React.cache scope — layouts
|
|
462
536
|
// share the cache. See TIM-1363, design/04-authorization.md.
|
|
463
537
|
//
|
|
464
|
-
// It sits in the enclosing outlet's content,
|
|
465
|
-
//
|
|
466
|
-
//
|
|
538
|
+
// It sits in the enclosing outlet's content, outside a 'document'
|
|
539
|
+
// layout's own outlet, so it runs on every request even when that layout
|
|
540
|
+
// is skipped (design/53 §"access.ts and metadata still run").
|
|
467
541
|
const accessFn = gateFor(i);
|
|
468
542
|
if (accessFn) {
|
|
469
543
|
element = wrapAccessGate(
|
|
@@ -9,9 +9,15 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { ManifestSegmentNode } from './route-matcher.ts';
|
|
12
|
-
import type { Metadata } from './types.ts';
|
|
12
|
+
import type { Metadata, SegmentLifetime } from './types.ts';
|
|
13
13
|
import { loadModule } from './safe-load.ts';
|
|
14
|
+
import { ROUTE_OPTIONS_EXPORT } from '../shared/route-options-export.ts';
|
|
14
15
|
import { NoPageComponentError, type LayoutComponentEntry } from './route-element-builder.ts';
|
|
16
|
+
import {
|
|
17
|
+
defaultLayoutLifetimeAt,
|
|
18
|
+
readDocumentLifetime,
|
|
19
|
+
type DocumentLifetime,
|
|
20
|
+
} from './segment-lifetime/segment-key.ts';
|
|
15
21
|
|
|
16
22
|
/** Metadata export from a layout or page module, with its segment context. */
|
|
17
23
|
export interface MetadataSource {
|
|
@@ -31,6 +37,8 @@ export interface LoadedRouteModules {
|
|
|
31
37
|
PageComponent: (...args: unknown[]) => unknown;
|
|
32
38
|
deferSuspenseFor: number;
|
|
33
39
|
accessFns: Array<AccessFn>;
|
|
40
|
+
/** `'document'` lifetimes (design/53), by segment index for layouts. */
|
|
41
|
+
documentLifetimes: { layouts: Array<DocumentLifetime | undefined>; page?: DocumentLifetime };
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
/**
|
|
@@ -51,14 +59,23 @@ function rejectLegacyGenerateMetadata(mod: Record<string, unknown>, filePath: st
|
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
62
|
+
* Return the maximum of `current` and the module's `deferSuspenseFor`
|
|
63
|
+
* option — `layoutOptions.deferSuspenseFor` in a layout,
|
|
64
|
+
* `pageOptions.deferSuspenseFor` in a page (design/53 §"Route-module
|
|
65
|
+
* options"). The build validated the object it could read from source
|
|
66
|
+
* (`routing/route-options.ts`); this runtime read is what takes effect.
|
|
56
67
|
*/
|
|
57
|
-
function extractDeferSuspenseFor(
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
function extractDeferSuspenseFor(
|
|
69
|
+
mod: Record<string, unknown>,
|
|
70
|
+
isPage: boolean,
|
|
71
|
+
current: number
|
|
72
|
+
): number {
|
|
73
|
+
const options = mod[ROUTE_OPTIONS_EXPORT[isPage ? 'page' : 'layout']];
|
|
74
|
+
if (typeof options !== 'object' || options === null || !('deferSuspenseFor' in options)) {
|
|
75
|
+
return current;
|
|
60
76
|
}
|
|
61
|
-
|
|
77
|
+
const value = options.deferSuspenseFor;
|
|
78
|
+
return typeof value === 'number' && value > current ? value : current;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
81
|
/**
|
|
@@ -83,7 +100,7 @@ function collectModuleExports(
|
|
|
83
100
|
segmentIndex,
|
|
84
101
|
});
|
|
85
102
|
}
|
|
86
|
-
return extractDeferSuspenseFor(mod, currentDefer);
|
|
103
|
+
return extractDeferSuspenseFor(mod, isPage, currentDefer);
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
/**
|
|
@@ -94,13 +111,16 @@ function collectModuleExports(
|
|
|
94
111
|
*/
|
|
95
112
|
export async function loadRouteModules(
|
|
96
113
|
segments: ManifestSegmentNode[],
|
|
97
|
-
requestUrl: string
|
|
114
|
+
requestUrl: string,
|
|
115
|
+
/** The app's `defaultLayoutLifetime` (design/53 §"App-wide default"). */
|
|
116
|
+
defaultLayoutLifetime: SegmentLifetime
|
|
98
117
|
): Promise<LoadedRouteModules> {
|
|
99
118
|
const metadataSources: MetadataSource[] = [];
|
|
100
119
|
const layoutComponents: LayoutComponentEntry[] = [];
|
|
101
120
|
const accessFns: Array<AccessFn> = [];
|
|
102
121
|
let PageComponent: ((...args: unknown[]) => unknown) | null = null;
|
|
103
122
|
let deferSuspenseFor = 0;
|
|
123
|
+
const documentLifetimes: LoadedRouteModules['documentLifetimes'] = { layouts: [] };
|
|
104
124
|
|
|
105
125
|
for (let i = 0; i < segments.length; i++) {
|
|
106
126
|
const segment = segments[i];
|
|
@@ -108,6 +128,11 @@ export async function loadRouteModules(
|
|
|
108
128
|
|
|
109
129
|
if (segment.layout) {
|
|
110
130
|
const mod = await loadModule(segment.layout);
|
|
131
|
+
documentLifetimes.layouts[i] = readDocumentLifetime(
|
|
132
|
+
mod,
|
|
133
|
+
'layout',
|
|
134
|
+
defaultLayoutLifetimeAt(segments.slice(0, i + 1), defaultLayoutLifetime)
|
|
135
|
+
);
|
|
111
136
|
if (mod.default) {
|
|
112
137
|
layoutComponents.push({
|
|
113
138
|
component: mod.default as (...args: unknown[]) => unknown,
|
|
@@ -129,6 +154,7 @@ export async function loadRouteModules(
|
|
|
129
154
|
if (mod.default) {
|
|
130
155
|
PageComponent = mod.default as (...args: unknown[]) => unknown;
|
|
131
156
|
}
|
|
157
|
+
documentLifetimes.page = readDocumentLifetime(mod, 'page', 'request');
|
|
132
158
|
deferSuspenseFor = collectModuleExports(
|
|
133
159
|
mod,
|
|
134
160
|
segment,
|
|
@@ -157,5 +183,12 @@ export async function loadRouteModules(
|
|
|
157
183
|
);
|
|
158
184
|
}
|
|
159
185
|
|
|
160
|
-
return {
|
|
186
|
+
return {
|
|
187
|
+
metadataSources,
|
|
188
|
+
layoutComponents,
|
|
189
|
+
PageComponent,
|
|
190
|
+
deferSuspenseFor,
|
|
191
|
+
accessFns,
|
|
192
|
+
documentLifetimes,
|
|
193
|
+
};
|
|
161
194
|
}
|
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
* See design/19-client-navigation.md §"The `_rsc` cache key".
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
rscCacheKey,
|
|
30
|
+
isRscCacheKeyShape,
|
|
31
|
+
RSC_KEY_PARAM,
|
|
32
|
+
stateTreeHasDocuments,
|
|
33
|
+
} from '../shared/rsc-cache-key.ts';
|
|
29
34
|
import { isRscContentType } from '../shared/rsc-media-type.ts';
|
|
30
35
|
import { preventResponseCaching } from './response-cache-policy.ts';
|
|
31
36
|
|
|
@@ -108,7 +113,9 @@ export function hardenRscPayloadResponse(response: Response): void {
|
|
|
108
113
|
* harmless lets a CDN apply heuristic caching to a response that has none.
|
|
109
114
|
*
|
|
110
115
|
* The cost is that a mismatched request loses developer-chosen *browser*
|
|
111
|
-
* caching too.
|
|
116
|
+
* caching too. A mismatch is a request no timber client ever makes. A request
|
|
117
|
+
* carrying 'document' key digests is one every client holding such a segment
|
|
118
|
+
* makes; it is private, no-store by default anyway.
|
|
112
119
|
*
|
|
113
120
|
* Purge tags (`Surrogate-Key`, `Cache-Tag`) are deliberately left alone:
|
|
114
121
|
* they address stored entries, and this response is not stored.
|
|
@@ -117,6 +124,14 @@ export function hardenRscPayloadResponse(response: Response): void {
|
|
|
117
124
|
* headers at this point (see TIM-866).
|
|
118
125
|
*/
|
|
119
126
|
export async function enforceRscCacheKey(req: Request, response: Response): Promise<void> {
|
|
127
|
+
// A request carrying 'document' key digests gets a response that depends
|
|
128
|
+
// on them — skips — while its `_rsc` key deliberately leaves them out
|
|
129
|
+
// (`stateTreeKeyValue`). Stored under that key, it would be served to a
|
|
130
|
+
// client that holds none of the skipped content. Same rule as a mismatch.
|
|
131
|
+
if (stateTreeHasDocuments(req.headers.get('X-Timber-State-Tree'))) {
|
|
132
|
+
preventResponseCaching(response.headers);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
120
135
|
if (await hasValidRscCacheKey(req)) return;
|
|
121
136
|
preventResponseCaching(response.headers);
|
|
122
137
|
}
|
|
@@ -15,7 +15,7 @@ import type { SegmentInfo } from '../../shared/segment-info.ts';
|
|
|
15
15
|
* interception scoping (design/07-routing.md §"Intercepting Routes").
|
|
16
16
|
*
|
|
17
17
|
* Nothing here is about caching — what the client may reuse is decided by
|
|
18
|
-
*
|
|
18
|
+
* the outlet decisions in the payload itself (design/53-segment-lifetime.md).
|
|
19
19
|
*/
|
|
20
20
|
export function buildSegmentInfo(
|
|
21
21
|
segments: ManifestSegmentNode[],
|
|
@@ -37,11 +37,15 @@ import loadCacheHandler from 'virtual:timber-cache-handler';
|
|
|
37
37
|
import { loadCdnPurgeHandler } from 'virtual:timber-cache-handler';
|
|
38
38
|
// @ts-expect-error — virtual module provided by timber-routing plugin
|
|
39
39
|
import globalSchemaCodecs from 'virtual:timber-schema';
|
|
40
|
+
// The build's secret: the server-action encryption key, from which the
|
|
41
|
+
// 'document' key digests derive their own (design/53 §"The key digest").
|
|
42
|
+
import encryptionKeySource from 'virtual:vite-rsc/encryption-key';
|
|
40
43
|
|
|
41
44
|
import { buildActionDispatcher } from './action-dispatcher.ts';
|
|
42
45
|
import type { BodyLimitsConfig } from '../body-limits.ts';
|
|
43
46
|
import type { DevHooks } from '../../dev-tools/dev-page-shell.ts';
|
|
44
47
|
import type { BuildManifest } from '../build-manifest.ts';
|
|
48
|
+
import type { SegmentLifetime } from '../types.ts';
|
|
45
49
|
import { resolveLogMode } from '../../dev-tools/logger.ts';
|
|
46
50
|
import { sendEarlyHints103 } from '../early-hints-sender.ts';
|
|
47
51
|
import { collectEarlyHintHeaders } from '../early-hints.ts';
|
|
@@ -66,6 +70,7 @@ import {
|
|
|
66
70
|
type DevStoreClear,
|
|
67
71
|
} from '../prebuilt/dev-store.ts';
|
|
68
72
|
import { renderRoute } from './render-route.ts';
|
|
73
|
+
import { createKeyDigestSigner } from '../segment-lifetime/key-digest.ts';
|
|
69
74
|
import { isDebug, isDevMode, setDebugFromConfig } from '../debug.ts';
|
|
70
75
|
import { capturePrebuiltPayloads } from '../prebuilt-builder.ts';
|
|
71
76
|
import { setPrebuiltPayloadSource } from '../prebuilt/payload-source.ts';
|
|
@@ -261,8 +266,13 @@ async function createRequestHandler(manifest: typeof routeManifest, runtimeConfi
|
|
|
261
266
|
| { disabled: boolean; enableHMRInDev: boolean }
|
|
262
267
|
| undefined;
|
|
263
268
|
const clientJsDisabled = clientJsConfig?.disabled ?? false;
|
|
264
|
-
|
|
265
|
-
|
|
269
|
+
// Written by `plugins/entries.ts` as exactly 'request' or 'document'.
|
|
270
|
+
const defaultLayoutLifetime: SegmentLifetime =
|
|
271
|
+
(runtimeConfig as Record<string, unknown>).defaultLayoutLifetime === 'document'
|
|
272
|
+
? 'document'
|
|
273
|
+
: 'request';
|
|
274
|
+
// One signer per server; it reads the secret on first use.
|
|
275
|
+
const keyDigestSigner = clientJsDisabled ? null : createKeyDigestSigner(encryptionKeySource);
|
|
266
276
|
const clientBootstrap = buildClientScripts({
|
|
267
277
|
...runtimeConfig,
|
|
268
278
|
clientJavascript: clientJsConfig ?? {
|
|
@@ -381,7 +391,8 @@ async function createRequestHandler(manifest: typeof routeManifest, runtimeConfi
|
|
|
381
391
|
{
|
|
382
392
|
clientBootstrap,
|
|
383
393
|
clientJsDisabled,
|
|
384
|
-
|
|
394
|
+
keyDigestSigner,
|
|
395
|
+
defaultLayoutLifetime,
|
|
385
396
|
renderDenyFallback,
|
|
386
397
|
buildManifest: typedBuildManifest,
|
|
387
398
|
renderTimeoutMs: (config as Record<string, unknown>).renderTimeoutMs as number,
|
|
@@ -485,6 +496,8 @@ async function createRequestHandler(manifest: typeof routeManifest, runtimeConfi
|
|
|
485
496
|
matchRoute,
|
|
486
497
|
coerceSegmentParams,
|
|
487
498
|
buildManifest: buildManifest as BuildManifest,
|
|
499
|
+
keyDigestSigner,
|
|
500
|
+
defaultLayoutLifetime,
|
|
488
501
|
}),
|
|
489
502
|
}),
|
|
490
503
|
};
|
|
@@ -32,9 +32,9 @@ import { DenySignal } from '../primitives.ts';
|
|
|
32
32
|
import { buildRouteElement, NoPageComponentError } from '../route-element-builder.ts';
|
|
33
33
|
import { recordTiming } from '../server-timing.ts';
|
|
34
34
|
import { parseClientStateTree } from '../client-state-tree.ts';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
35
|
+
import type { SegmentRender } from '../segment-lifetime/outlet-gate.ts';
|
|
36
|
+
import type { KeyDigestSigner } from '../segment-lifetime/key-digest.ts';
|
|
37
|
+
import type { SegmentLifetime } from '../types.ts';
|
|
38
38
|
|
|
39
39
|
import { handleApiRoute } from './api-handler.ts';
|
|
40
40
|
import type { DenyFallbackRenderer } from './deny-fallback.ts';
|
|
@@ -53,7 +53,14 @@ import { renderSsrResponse } from './ssr-renderer.ts';
|
|
|
53
53
|
export interface RenderRouteDeps {
|
|
54
54
|
clientBootstrap: ClientBootstrapConfig;
|
|
55
55
|
clientJsDisabled: boolean;
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Issues and checks key digests for 'document' segments
|
|
58
|
+
* (design/53-segment-lifetime.md); null when client JavaScript is disabled,
|
|
59
|
+
* since no client router can hold a segment.
|
|
60
|
+
*/
|
|
61
|
+
keyDigestSigner: KeyDigestSigner | null;
|
|
62
|
+
/** The app's `defaultLayoutLifetime` (design/53 §"App-wide default"). */
|
|
63
|
+
defaultLayoutLifetime: SegmentLifetime;
|
|
57
64
|
renderDenyFallback: DenyFallbackRenderer;
|
|
58
65
|
buildManifest: BuildManifest;
|
|
59
66
|
/**
|
|
@@ -92,35 +99,15 @@ export async function renderRoute(
|
|
|
92
99
|
return handleApiRoute(req, segments, responseHeaders);
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
?
|
|
103
|
-
|
|
104
|
-
isOutlet: isOutletType,
|
|
105
|
-
decode: (stream) => createFromReadableStream(stream),
|
|
106
|
-
})
|
|
107
|
-
: null;
|
|
108
|
-
// A capture reports through the main render's error handler, which exists
|
|
109
|
-
// only once the main render starts — captures start inside it. The digests
|
|
110
|
-
// it hands out are remembered, so the main render passes a decoded error
|
|
111
|
-
// row through instead of reporting it a second time.
|
|
112
|
-
const relayedDigests = new Set<string>();
|
|
113
|
-
let mainOnError: ((error: unknown) => string | void) | null = null;
|
|
114
|
-
const segmentHashRender: SegmentHashRender = {
|
|
115
|
-
clientHashes: hashing && isRscRequest(req) ? (parseClientStateTree(req)?.hashes ?? null) : null,
|
|
116
|
-
tap,
|
|
117
|
-
captureTimeoutMs: deps.renderTimeoutMs,
|
|
118
|
-
signal: req.signal,
|
|
119
|
-
onCaptureError(error) {
|
|
120
|
-
const digest = mainOnError?.(error);
|
|
121
|
-
if (typeof digest === 'string') relayedDigests.add(digest);
|
|
122
|
-
return digest;
|
|
123
|
-
},
|
|
102
|
+
// Only a navigation carries the client's state; a document request renders
|
|
103
|
+
// every segment and the client records what it hydrates. A 'document'
|
|
104
|
+
// segment is skipped when the client holds it under the current key
|
|
105
|
+
// (design/53-segment-lifetime.md).
|
|
106
|
+
const clientState = isRscRequest(req) ? parseClientStateTree(req) : null;
|
|
107
|
+
const signer = clientJsDisabled ? null : deps.keyDigestSigner;
|
|
108
|
+
const segmentRender: SegmentRender = {
|
|
109
|
+
documents: signer ? { client: clientState?.documents ?? null, signer } : null,
|
|
110
|
+
defaultLayoutLifetime: deps.defaultLayoutLifetime,
|
|
124
111
|
};
|
|
125
112
|
|
|
126
113
|
// Build the React element tree — runs access checks eagerly to gate
|
|
@@ -135,7 +122,7 @@ export async function renderRoute(
|
|
|
135
122
|
req,
|
|
136
123
|
match,
|
|
137
124
|
interception,
|
|
138
|
-
|
|
125
|
+
segmentRender,
|
|
139
126
|
buildManifest.metadataRouteHashes
|
|
140
127
|
);
|
|
141
128
|
} catch (error) {
|
|
@@ -213,23 +200,7 @@ export async function renderRoute(
|
|
|
213
200
|
|
|
214
201
|
// Render to RSC Flight stream with signal tracking.
|
|
215
202
|
const _rscStart = performance.now();
|
|
216
|
-
const { rscStream, signals
|
|
217
|
-
payload,
|
|
218
|
-
req,
|
|
219
|
-
deps.renderTimeoutMs,
|
|
220
|
-
leafDenyChain,
|
|
221
|
-
tap ?? undefined,
|
|
222
|
-
relayedDigests
|
|
223
|
-
);
|
|
224
|
-
// Released when the render ends: the outlet gates close over this handler,
|
|
225
|
-
// and dev keeps finished render's components reachable long enough that a
|
|
226
|
-
// handler still set here held every request (dev-request-retention).
|
|
227
|
-
if (tap) {
|
|
228
|
-
mainOnError = onError;
|
|
229
|
-
tap.onEnd(() => {
|
|
230
|
-
mainOnError = null;
|
|
231
|
-
});
|
|
232
|
-
}
|
|
203
|
+
const { rscStream, signals } = renderRscStream(payload, req, deps.renderTimeoutMs, leafDenyChain);
|
|
233
204
|
|
|
234
205
|
recordTiming({
|
|
235
206
|
name: 'rsc-init',
|
|
@@ -47,7 +47,8 @@ import {
|
|
|
47
47
|
import type { CoercedParams } from '../../shared/param-value.ts';
|
|
48
48
|
|
|
49
49
|
import { runMiddlewareForAction } from './action-middleware-runner.ts';
|
|
50
|
-
import {
|
|
50
|
+
import type { KeyDigestSigner } from '../segment-lifetime/key-digest.ts';
|
|
51
|
+
import type { SegmentLifetime } from '../types.ts';
|
|
51
52
|
import { RSC_CONTENT_TYPE } from '../../shared/rsc-media-type.ts';
|
|
52
53
|
|
|
53
54
|
/** Result of validating a `revalidatePath()` argument. */
|
|
@@ -137,6 +138,16 @@ export interface RevalidateRendererDeps {
|
|
|
137
138
|
matchRoute: RouteMatcher;
|
|
138
139
|
coerceSegmentParams: CoerceSegmentParamsFn;
|
|
139
140
|
buildManifest: BuildManifest;
|
|
141
|
+
/**
|
|
142
|
+
* Issues key digests for 'document' segments; null when client JavaScript
|
|
143
|
+
* is disabled. A revalidated tree renders every segment live (it carries no
|
|
144
|
+
* client claims), and issues digests from the cookies as the action left
|
|
145
|
+
* them, so the next navigation compares against what the browser now sends
|
|
146
|
+
* (design/53-segment-lifetime.md open question 4).
|
|
147
|
+
*/
|
|
148
|
+
keyDigestSigner: KeyDigestSigner | null;
|
|
149
|
+
/** The app's `defaultLayoutLifetime` (design/53 §"App-wide default"). */
|
|
150
|
+
defaultLayoutLifetime: SegmentLifetime;
|
|
140
151
|
}
|
|
141
152
|
|
|
142
153
|
/**
|
|
@@ -338,7 +349,10 @@ export function createRevalidateRendererFactory(
|
|
|
338
349
|
revalidateReq,
|
|
339
350
|
match,
|
|
340
351
|
undefined,
|
|
341
|
-
|
|
352
|
+
{
|
|
353
|
+
documents: deps.keyDigestSigner ? { client: null, signer: deps.keyDigestSigner } : null,
|
|
354
|
+
defaultLayoutLifetime: deps.defaultLayoutLifetime,
|
|
355
|
+
},
|
|
342
356
|
deps.buildManifest.metadataRouteHashes
|
|
343
357
|
);
|
|
344
358
|
return {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { renderFlight } from '../vite-handoff-rsc.ts';
|
|
14
|
-
import type { FlightSource
|
|
14
|
+
import type { FlightSource } from '../flight-source.ts';
|
|
15
15
|
import type { RscPayloadRoot } from '../../shared/payload-root.ts';
|
|
16
16
|
import { encodeErrorDigest } from '../../shared/error-digest.ts';
|
|
17
17
|
|
|
@@ -31,8 +31,6 @@ import { isDebug } from '../debug.ts';
|
|
|
31
31
|
export interface RscStreamResult {
|
|
32
32
|
rscStream: FlightSource;
|
|
33
33
|
signals: RenderSignals;
|
|
34
|
-
/** The render's error handler — segment-hash captures report through it. */
|
|
35
|
-
onError: (error: unknown) => string | void;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
/**
|
|
@@ -54,28 +52,11 @@ export function renderRscStream(
|
|
|
54
52
|
payload: RscPayloadRoot,
|
|
55
53
|
req: Request,
|
|
56
54
|
renderTimeoutMs: number,
|
|
57
|
-
leafDenyChain?: DenyPageEntry[]
|
|
58
|
-
tap?: FlightTap,
|
|
59
|
-
/**
|
|
60
|
-
* Digests a segment-hash capture already produced through this handler. A
|
|
61
|
-
* capture's error row decoded into the live content reaches this render
|
|
62
|
-
* again as an error carrying that digest: pass it through, it has been
|
|
63
|
-
* reported and signalled once already.
|
|
64
|
-
*/
|
|
65
|
-
relayedDigests?: ReadonlySet<string>
|
|
55
|
+
leafDenyChain?: DenyPageEntry[]
|
|
66
56
|
): RscStreamResult {
|
|
67
57
|
const recorder = createSignalRecorder();
|
|
68
58
|
|
|
69
59
|
const onError = (error: unknown): string | void => {
|
|
70
|
-
if (
|
|
71
|
-
typeof error === 'object' &&
|
|
72
|
-
error !== null &&
|
|
73
|
-
'digest' in error &&
|
|
74
|
-
typeof error.digest === 'string' &&
|
|
75
|
-
relayedDigests?.has(error.digest)
|
|
76
|
-
) {
|
|
77
|
-
return error.digest;
|
|
78
|
-
}
|
|
79
60
|
// Connection abort (user refreshed or navigated away) — suppress.
|
|
80
61
|
// Not an application error; no need to track or log.
|
|
81
62
|
if (isAbortError(error) || req.signal?.aborted) return;
|
|
@@ -179,11 +160,10 @@ export function renderRscStream(
|
|
|
179
160
|
const rscStream = renderFlight(payload, {
|
|
180
161
|
signal: req.signal,
|
|
181
162
|
timeoutMs: renderTimeoutMs,
|
|
182
|
-
tap,
|
|
183
163
|
onError,
|
|
184
164
|
});
|
|
185
165
|
|
|
186
|
-
return { rscStream, signals: recorder.signals
|
|
166
|
+
return { rscStream, signals: recorder.signals };
|
|
187
167
|
}
|
|
188
168
|
|
|
189
169
|
/** Log and report an unhandled render error; the ID it was logged with. */
|