@timber-js/app 0.2.0-alpha.241 → 0.2.0-alpha.243
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-BCYVyoFl.js → actions-DoTj0Jd3.js} +78 -32
- package/dist/_chunks/actions-DoTj0Jd3.js.map +1 -0
- package/dist/_chunks/{als-registry-fabsRnPY.js → als-registry-C-iwbtvI.js} +1 -2
- package/dist/_chunks/{als-registry-fabsRnPY.js.map → als-registry-C-iwbtvI.js.map} +1 -1
- package/dist/_chunks/{cache-api-n5FL4wFs.js → cache-api-D3HmgsFh.js} +5 -5
- package/dist/_chunks/{cache-api-n5FL4wFs.js.map → cache-api-D3HmgsFh.js.map} +1 -1
- package/dist/_chunks/{chains-IswOWMnq.js → chains-BpvDwp08.js} +2 -2
- package/dist/_chunks/{chains-IswOWMnq.js.map → chains-BpvDwp08.js.map} +1 -1
- package/dist/_chunks/chains-CjlZZ5ad.js +1 -0
- package/dist/_chunks/{classify-B08RCF6s.js → classify-Bbb_lKjH.js} +2 -2
- package/dist/_chunks/{classify-B08RCF6s.js.map → classify-Bbb_lKjH.js.map} +1 -1
- package/dist/_chunks/{cli-check-tpFb6pBU.js → cli-check-DlQBSKIN.js} +3 -3
- package/dist/_chunks/{cli-check-tpFb6pBU.js.map → cli-check-DlQBSKIN.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-DRNJutey.js → cli-schema-sync-CWkGFlYu.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-DRNJutey.js.map → cli-schema-sync-CWkGFlYu.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-C0pXBtzG.js → cli-schema-sync-Dyvdkv_I.js} +1 -1
- package/dist/_chunks/{client-dep-entries-Dw5Dvatr.js → client-dep-entries-Dka67elj.js} +2 -2
- package/dist/_chunks/{client-dep-entries-Dw5Dvatr.js.map → client-dep-entries-Dka67elj.js.map} +1 -1
- package/dist/_chunks/{convention-lint-BfC_dAhZ.js → convention-lint-CGGcseNn.js} +19 -5
- package/dist/_chunks/convention-lint-CGGcseNn.js.map +1 -0
- package/dist/_chunks/dev-server-DrjLscqT.js +1 -0
- package/dist/_chunks/{dev-server-3R6Bl9_R.js → dev-server-LO4McfQi.js} +3 -4
- package/dist/_chunks/dev-server-LO4McfQi.js.map +1 -0
- package/dist/_chunks/{error-boundary-Dfhxigko.js → error-boundary-wuNvAJ4n.js} +8 -15
- package/dist/_chunks/error-boundary-wuNvAJ4n.js.map +1 -0
- package/dist/_chunks/{flight-source-node-QOpWZATb.js → flight-source-node-BeF00Wo_.js} +4 -7
- package/dist/_chunks/flight-source-node-BeF00Wo_.js.map +1 -0
- package/dist/_chunks/{interception-CtNt9jPt.js → interception-D1dCGNmQ.js} +6 -6
- package/dist/_chunks/{interception-CtNt9jPt.js.map → interception-D1dCGNmQ.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-5KFcC1yt.js → json-lossy-check-DpXneTBm.js} +2 -2
- package/dist/_chunks/{json-lossy-check-5KFcC1yt.js.map → json-lossy-check-DpXneTBm.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-D1dfVqoT.js → live-graph-DXhz6A_X.js} +4 -4
- package/dist/_chunks/{live-graph-D1dfVqoT.js.map → live-graph-DXhz6A_X.js.map} +1 -1
- package/dist/_chunks/{logger-BvGxPd1e.js → logger-D1sWX2I0.js} +18 -3
- package/dist/_chunks/logger-D1sWX2I0.js.map +1 -0
- package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
- package/dist/_chunks/{node-response-D5cfiyWP.js → node-response-Cp62CtH1.js} +2 -2
- package/dist/_chunks/{node-response-D5cfiyWP.js.map → node-response-Cp62CtH1.js.map} +1 -1
- package/dist/_chunks/{poison-scan-CX02ilxN.js → poison-scan-DdkJoHvP.js} +2 -2
- package/dist/_chunks/{poison-scan-CX02ilxN.js.map → poison-scan-DdkJoHvP.js.map} +1 -1
- package/dist/_chunks/{scanner-DneYxQoY.js → scanner-B6V2RqqF.js} +20 -3
- package/dist/_chunks/scanner-B6V2RqqF.js.map +1 -0
- package/dist/_chunks/{sizeof-BtQ3ErLf.js → sizeof-BKA6qOZq.js} +2 -2
- package/dist/_chunks/{sizeof-BtQ3ErLf.js.map → sizeof-BKA6qOZq.js.map} +1 -1
- package/dist/_chunks/{walkers-C9R2A4jN.js → walkers-BAZoAlfI.js} +3 -3
- package/dist/_chunks/{walkers-C9R2A4jN.js.map → walkers-BAZoAlfI.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/router-init.d.ts +0 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/document-withdrawal.d.ts +2 -0
- package/dist/client/document-withdrawal.d.ts.map +1 -0
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +3 -5
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-commit.d.ts +0 -7
- package/dist/client/navigation-commit.d.ts.map +1 -1
- package/dist/client/outlet-content-cache.d.ts +28 -42
- package/dist/client/outlet-content-cache.d.ts.map +1 -1
- package/dist/client/outlet-scope-context.d.ts +9 -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 -15
- 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 +2 -18
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/native/rsc/manifest.json +3 -4
- package/dist/native/rsc/routing/segment-keys.js.map +1 -1
- package/dist/native/rsc/server/als-registry.js +1 -2
- package/dist/native/rsc/server/als-registry.js.map +1 -1
- package/dist/native/rsc/server/client-state-tree.js +1 -5
- package/dist/native/rsc/server/client-state-tree.js.map +1 -1
- package/dist/native/rsc/server/cookie-context.js +7 -7
- package/dist/native/rsc/server/cookie-context.js.map +1 -1
- package/dist/native/rsc/server/deny-boundary.js +2 -1
- package/dist/native/rsc/server/deny-boundary.js.map +1 -1
- package/dist/native/rsc/server/dev-overlay-report.js +13 -0
- package/dist/native/rsc/server/dev-overlay-report.js.map +1 -0
- 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 +6 -41
- package/dist/native/rsc/server/flight-source.js.map +1 -1
- package/dist/native/rsc/server/framework-stack-frames.js.map +1 -1
- package/dist/native/rsc/server/logger.js +6 -1
- package/dist/native/rsc/server/logger.js.map +1 -1
- package/dist/native/rsc/server/pipeline-interception.js +4 -1
- package/dist/native/rsc/server/pipeline-interception.js.map +1 -1
- package/dist/native/rsc/server/pipeline.js.map +1 -1
- package/dist/native/rsc/server/request-context.js +6 -6
- package/dist/native/rsc/server/request-context.js.map +1 -1
- package/dist/native/rsc/server/route-element-builder.js +5 -5
- package/dist/native/rsc/server/route-element-builder.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/render-route.js +4 -30
- package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +0 -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/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 +45 -12
- package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/read-scope.js +50 -8
- package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/segment-key.js +17 -3
- package/dist/native/rsc/server/segment-lifetime/segment-key.js.map +1 -1
- package/dist/native/rsc/server/segment-lifetime/slot-outlets.js +4 -4
- package/dist/native/rsc/server/segment-lifetime/slot-outlets.js.map +1 -1
- package/dist/native/rsc/server/slot-resolver.js +8 -7
- package/dist/native/rsc/server/slot-resolver.js.map +1 -1
- package/dist/native/rsc/server/slot-subtree-contain.js +2 -1
- package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
- package/dist/native/rsc/server/subtree-walk.js +14 -5
- package/dist/native/rsc/server/subtree-walk.js.map +1 -1
- package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
- 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/ssr/client/document-withdrawal.js +17 -0
- package/dist/native/ssr/client/document-withdrawal.js.map +1 -0
- package/dist/native/ssr/client/outlet-content-cache.js +10 -25
- 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 +17 -21
- package/dist/native/ssr/client/segment-outlet.js.map +1 -1
- package/dist/native/ssr/manifest.json +6 -1
- package/dist/native/ssr/server/als-registry.js +0 -1
- package/dist/native/ssr/server/als-registry.js.map +1 -1
- package/dist/native/ssr/server/client-state-tree.js +1 -5
- package/dist/native/ssr/server/client-state-tree.js.map +1 -1
- package/dist/native/ssr/server/cookie-context.js +7 -7
- package/dist/native/ssr/server/cookie-context.js.map +1 -1
- package/dist/native/ssr/server/deny-boundary.js +2 -1
- package/dist/native/ssr/server/deny-boundary.js.map +1 -1
- package/dist/native/ssr/server/dev-overlay-report.js +6 -0
- package/dist/native/ssr/server/dev-overlay-report.js.map +1 -0
- 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 +0 -1
- package/dist/native/ssr/server/flight-source.js.map +1 -1
- package/dist/native/ssr/server/framework-stack-frames.js.map +1 -1
- package/dist/native/ssr/server/logger.js +6 -1
- package/dist/native/ssr/server/logger.js.map +1 -1
- package/dist/native/ssr/server/pipeline-interception.js +4 -1
- package/dist/native/ssr/server/pipeline-interception.js.map +1 -1
- package/dist/native/ssr/server/pipeline.js.map +1 -1
- package/dist/native/ssr/server/request-context.js +6 -6
- package/dist/native/ssr/server/request-context.js.map +1 -1
- package/dist/native/ssr/server/segment-lifetime/outlet-gate.js +11 -0
- package/dist/native/ssr/server/segment-lifetime/outlet-gate.js.map +1 -0
- package/dist/native/ssr/server/segment-lifetime/read-rule.js +45 -12
- package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -1
- package/dist/native/ssr/server/segment-lifetime/read-scope.js +16 -0
- package/dist/native/ssr/server/segment-lifetime/read-scope.js.map +1 -0
- package/dist/native/ssr/server/subtree-walk.js +149 -0
- package/dist/native/ssr/server/subtree-walk.js.map +1 -0
- package/dist/native/ssr/server/utils/element-type.js +21 -9
- package/dist/native/ssr/server/utils/element-type.js.map +1 -1
- package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
- package/dist/native/ssr/shared/key-headers.js +13 -0
- package/dist/native/ssr/shared/key-headers.js.map +1 -0
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/routing/index.js +3 -3
- package/dist/routing/route-options.d.ts.map +1 -1
- package/dist/routing/segment-keys.d.ts +3 -4
- package/dist/routing/segment-keys.d.ts.map +1 -1
- package/dist/routing/slot-placement.d.ts +23 -4
- package/dist/routing/slot-placement.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +20 -16
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/client-state-tree.d.ts +5 -11
- package/dist/server/client-state-tree.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/dev-overlay-report.d.ts +13 -0
- package/dist/server/dev-overlay-report.d.ts.map +1 -0
- 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 +0 -27
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/framework-stack-frames.d.ts +1 -4
- package/dist/server/framework-stack-frames.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +105 -26
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +10 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +13 -1
- package/dist/server/pipeline.d.ts.map +1 -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/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 +0 -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-stream.d.ts +2 -11
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- 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 +19 -13
- package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -1
- package/dist/server/segment-lifetime/read-scope.d.ts +48 -6
- package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -1
- package/dist/server/segment-lifetime/segment-key.d.ts +3 -0
- package/dist/server/segment-lifetime/segment-key.d.ts.map +1 -1
- package/dist/server/segment-lifetime/slot-outlets.d.ts +3 -3
- package/dist/server/segment-lifetime/slot-outlets.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts +5 -5
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/slot-subtree-contain.d.ts.map +1 -1
- package/dist/server/subtree-walk.d.ts +17 -3
- package/dist/server/subtree-walk.d.ts.map +1 -1
- package/dist/server/types.d.ts +8 -2
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/vite-handoff-rsc.d.ts +3 -10
- package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
- 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 +13 -44
- package/dist/shared/outlet-decision.d.ts.map +1 -1
- package/dist/shared/payload-root.d.ts +1 -1
- package/dist/shared/segment-info.d.ts +3 -7
- package/dist/shared/segment-info.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +1 -1
- package/docs/api/34-api-config.mdx +1 -1
- package/package.json +1 -1
- package/src/client/browser-entry/index.ts +0 -2
- package/src/client/browser-entry/router-init.ts +2 -4
- package/src/client/document-withdrawal.tsx +41 -0
- package/src/client/error-boundary.tsx +1 -1
- package/src/client/navigation-commit.ts +4 -18
- package/src/client/outlet-content-cache.ts +38 -60
- package/src/client/outlet-scope-context.ts +10 -5
- package/src/client/params-context.ts +1 -1
- package/src/client/router-types.ts +3 -14
- package/src/client/router.ts +0 -2
- package/src/client/rsc-fetch.ts +1 -1
- package/src/client/segment-cache.ts +2 -2
- package/src/client/segment-outlet.tsx +28 -54
- package/src/client/stale-segment.ts +2 -2
- package/src/config-types.ts +2 -18
- package/src/config-validation.ts +0 -1
- package/src/plugins/entries.ts +0 -1
- package/src/routing/interception.ts +5 -5
- package/src/routing/route-options.ts +20 -4
- package/src/routing/scanner.ts +1 -1
- package/src/routing/segment-keys.ts +3 -4
- package/src/routing/slot-placement.ts +41 -4
- package/src/rsc-runtime/vendor-types.d.ts +1 -1
- package/src/server/als-registry.ts +16 -23
- package/src/server/client-state-tree.ts +7 -18
- package/src/server/cookie-context.ts +7 -7
- package/src/server/deny-boundary.ts +4 -1
- package/src/server/dev-overlay-report.ts +22 -0
- package/src/server/flight-source-node.ts +1 -5
- package/src/server/flight-source.ts +1 -81
- package/src/server/framework-stack-frames.ts +1 -4
- package/src/server/logger.ts +13 -0
- package/src/server/pipeline-interception.ts +11 -2
- package/src/server/pipeline.ts +13 -1
- package/src/server/request-context.ts +12 -11
- package/src/server/route-element-builder.ts +15 -16
- package/src/server/rsc-entry/helpers.ts +1 -1
- package/src/server/rsc-entry/index.ts +7 -3
- package/src/server/rsc-entry/render-route.ts +7 -54
- package/src/server/rsc-entry/revalidate-renderer.ts +0 -2
- package/src/server/rsc-entry/rsc-stream.ts +3 -23
- package/src/server/segment-lifetime/outlet-gate.ts +102 -0
- package/src/server/segment-lifetime/read-rule.ts +110 -22
- package/src/server/segment-lifetime/read-scope.ts +131 -15
- package/src/server/segment-lifetime/segment-key.ts +31 -3
- package/src/server/segment-lifetime/slot-outlets.ts +6 -6
- package/src/server/slot-resolver.ts +30 -18
- package/src/server/slot-subtree-contain.ts +2 -1
- package/src/server/subtree-walk.ts +34 -9
- package/src/server/types.ts +8 -2
- package/src/server/vite-handoff-rsc.ts +3 -12
- package/src/shared/key-headers.ts +42 -0
- package/src/shared/outlet-decision.ts +13 -48
- package/src/shared/payload-root.ts +1 -1
- package/src/shared/segment-info.ts +3 -7
- package/dist/_chunks/actions-BCYVyoFl.js.map +0 -1
- package/dist/_chunks/chains-DPZAMMav.js +0 -1
- package/dist/_chunks/convention-lint-BfC_dAhZ.js.map +0 -1
- package/dist/_chunks/dev-server-3DNTXQV-.js +0 -1
- package/dist/_chunks/dev-server-3R6Bl9_R.js.map +0 -1
- package/dist/_chunks/error-boundary-Dfhxigko.js.map +0 -1
- package/dist/_chunks/flight-source-node-QOpWZATb.js.map +0 -1
- package/dist/_chunks/logger-BvGxPd1e.js.map +0 -1
- package/dist/_chunks/scanner-DneYxQoY.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 -101
- 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 -93
- 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 -229
- package/src/server/segment-hash/stream-tap.ts +0 -244
- package/src/server/segment-hash/value-hash.ts +0 -338
|
@@ -32,9 +32,7 @@ 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 { createFromReadableStream } from '../vite-handoff-rsc.ts';
|
|
37
|
-
import { createSegmentHashTap } from '../segment-hash/stream-tap.ts';
|
|
35
|
+
import type { SegmentRender } from '../segment-lifetime/outlet-gate.ts';
|
|
38
36
|
import type { KeyDigestSigner } from '../segment-lifetime/key-digest.ts';
|
|
39
37
|
import type { SegmentLifetime } from '../types.ts';
|
|
40
38
|
|
|
@@ -55,7 +53,6 @@ import { renderSsrResponse } from './ssr-renderer.ts';
|
|
|
55
53
|
export interface RenderRouteDeps {
|
|
56
54
|
clientBootstrap: ClientBootstrapConfig;
|
|
57
55
|
clientJsDisabled: boolean;
|
|
58
|
-
clientSegmentCache: boolean;
|
|
59
56
|
/**
|
|
60
57
|
* Issues and checks key digests for 'document' segments
|
|
61
58
|
* (design/53-segment-lifetime.md); null when client JavaScript is disabled,
|
|
@@ -102,43 +99,15 @@ export async function renderRoute(
|
|
|
102
99
|
return handleApiRoute(req, segments, responseHeaders);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
// Segment hash dedupe (design/52-segment-hash-dedupe.md), when the app
|
|
106
|
-
// opted in. Every render that can reach a client router hashes its live
|
|
107
|
-
// segments, document requests included — the client records those hashes
|
|
108
|
-
// as it hydrates. Only a navigation request carries hashes to compare
|
|
109
|
-
// against (`X-Timber-State-Tree`), so only it can skip.
|
|
110
|
-
const hashing = deps.clientSegmentCache && !clientJsDisabled;
|
|
111
|
-
const tap = hashing
|
|
112
|
-
? createSegmentHashTap({
|
|
113
|
-
timeoutMs: deps.renderTimeoutMs,
|
|
114
|
-
isOutlet: isOutletType,
|
|
115
|
-
decode: (stream) => createFromReadableStream(stream),
|
|
116
|
-
})
|
|
117
|
-
: null;
|
|
118
|
-
// A capture reports through the main render's error handler, which exists
|
|
119
|
-
// only once the main render starts — captures start inside it. The digests
|
|
120
|
-
// it hands out are remembered, so the main render passes a decoded error
|
|
121
|
-
// row through instead of reporting it a second time.
|
|
122
|
-
const relayedDigests = new Set<string>();
|
|
123
|
-
let mainOnError: ((error: unknown) => string | void) | null = null;
|
|
124
102
|
// Only a navigation carries the client's state; a document request renders
|
|
125
|
-
// every segment and the client records what it hydrates.
|
|
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).
|
|
126
106
|
const clientState = isRscRequest(req) ? parseClientStateTree(req) : null;
|
|
127
107
|
const signer = clientJsDisabled ? null : deps.keyDigestSigner;
|
|
128
|
-
const
|
|
129
|
-
clientHashes: hashing ? (clientState?.hashes ?? null) : null,
|
|
130
|
-
// 'document' segments are skipped when the client holds them under the
|
|
131
|
-
// current key — whether or not the app opted into hashing.
|
|
108
|
+
const segmentRender: SegmentRender = {
|
|
132
109
|
documents: signer ? { client: clientState?.documents ?? null, signer } : null,
|
|
133
110
|
defaultLayoutLifetime: deps.defaultLayoutLifetime,
|
|
134
|
-
tap,
|
|
135
|
-
captureTimeoutMs: deps.renderTimeoutMs,
|
|
136
|
-
signal: req.signal,
|
|
137
|
-
onCaptureError(error) {
|
|
138
|
-
const digest = mainOnError?.(error);
|
|
139
|
-
if (typeof digest === 'string') relayedDigests.add(digest);
|
|
140
|
-
return digest;
|
|
141
|
-
},
|
|
142
111
|
};
|
|
143
112
|
|
|
144
113
|
// Build the React element tree — runs access checks eagerly to gate
|
|
@@ -153,7 +122,7 @@ export async function renderRoute(
|
|
|
153
122
|
req,
|
|
154
123
|
match,
|
|
155
124
|
interception,
|
|
156
|
-
|
|
125
|
+
segmentRender,
|
|
157
126
|
buildManifest.metadataRouteHashes
|
|
158
127
|
);
|
|
159
128
|
} catch (error) {
|
|
@@ -231,23 +200,7 @@ export async function renderRoute(
|
|
|
231
200
|
|
|
232
201
|
// Render to RSC Flight stream with signal tracking.
|
|
233
202
|
const _rscStart = performance.now();
|
|
234
|
-
const { rscStream, signals
|
|
235
|
-
payload,
|
|
236
|
-
req,
|
|
237
|
-
deps.renderTimeoutMs,
|
|
238
|
-
leafDenyChain,
|
|
239
|
-
tap ?? undefined,
|
|
240
|
-
relayedDigests
|
|
241
|
-
);
|
|
242
|
-
// Released when the render ends: the outlet gates close over this handler,
|
|
243
|
-
// and dev keeps finished render's components reachable long enough that a
|
|
244
|
-
// handler still set here held every request (dev-request-retention).
|
|
245
|
-
if (tap) {
|
|
246
|
-
mainOnError = onError;
|
|
247
|
-
tap.onEnd(() => {
|
|
248
|
-
mainOnError = null;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
203
|
+
const { rscStream, signals } = renderRscStream(payload, req, deps.renderTimeoutMs, leafDenyChain);
|
|
251
204
|
|
|
252
205
|
recordTiming({
|
|
253
206
|
name: 'rsc-init',
|
|
@@ -47,7 +47,6 @@ import {
|
|
|
47
47
|
import type { CoercedParams } from '../../shared/param-value.ts';
|
|
48
48
|
|
|
49
49
|
import { runMiddlewareForAction } from './action-middleware-runner.ts';
|
|
50
|
-
import { NO_SEGMENT_HASHING } from '../segment-hash/outlet.ts';
|
|
51
50
|
import type { KeyDigestSigner } from '../segment-lifetime/key-digest.ts';
|
|
52
51
|
import type { SegmentLifetime } from '../types.ts';
|
|
53
52
|
import { RSC_CONTENT_TYPE } from '../../shared/rsc-media-type.ts';
|
|
@@ -351,7 +350,6 @@ export function createRevalidateRendererFactory(
|
|
|
351
350
|
match,
|
|
352
351
|
undefined,
|
|
353
352
|
{
|
|
354
|
-
...NO_SEGMENT_HASHING,
|
|
355
353
|
documents: deps.keyDigestSigner ? { client: null, signer: deps.keyDigestSigner } : null,
|
|
356
354
|
defaultLayoutLifetime: deps.defaultLayoutLifetime,
|
|
357
355
|
},
|
|
@@ -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. */
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The outlet gate: renders one segment as a `SegmentOutlet` whose decision is
|
|
3
|
+
* either its live content or a skip.
|
|
4
|
+
*
|
|
5
|
+
* Only a `'document'` segment (design/53-segment-lifetime.md) is ever
|
|
6
|
+
* skipped. Its decision is made before the tree renders
|
|
7
|
+
* (`document-outlet.ts`): when the client holds content rendered under the
|
|
8
|
+
* current key digest, the segment is skipped **without rendering**, and its
|
|
9
|
+
* nested outlets are decided as if it had rendered — lifetime does not
|
|
10
|
+
* cascade. Otherwise it is sent live with the digest it rendered under. Every
|
|
11
|
+
* other segment is sent live. Access runs for every segment either way.
|
|
12
|
+
*
|
|
13
|
+
* See design/53-segment-lifetime.md §"Skipping".
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { createElement, type ReactElement, type ReactNode } from 'react';
|
|
17
|
+
import type { OutletDecision } from '../../shared/outlet-decision.ts';
|
|
18
|
+
import { clientComponents } from '../vite-handoff-rsc.ts';
|
|
19
|
+
import type { DocumentKeys, DocumentOutlet } from './document-outlet.ts';
|
|
20
|
+
import type { SegmentLifetime } from '../types.ts';
|
|
21
|
+
|
|
22
|
+
/** One outlet in the element tree, and the outlets directly inside it. */
|
|
23
|
+
export interface OutletSpec {
|
|
24
|
+
segmentPath: string;
|
|
25
|
+
content: ReactNode;
|
|
26
|
+
nested: OutletSpec[];
|
|
27
|
+
/** Set on a `'document'` segment's outlet when the render can issue digests. */
|
|
28
|
+
document?: DocumentOutlet;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Per-request inputs to every gate in one render. */
|
|
32
|
+
export interface SegmentRender {
|
|
33
|
+
/**
|
|
34
|
+
* Key digests for `'document'` segments: the client's, and the signer that
|
|
35
|
+
* issues and checks them. Null when no client router can hold a segment.
|
|
36
|
+
*/
|
|
37
|
+
documents: DocumentKeys | null;
|
|
38
|
+
/**
|
|
39
|
+
* The lifetime of a layout that declares none: the app's
|
|
40
|
+
* `defaultLayoutLifetime` (design/53 §"App-wide default"). Pages always
|
|
41
|
+
* default to `'request'`.
|
|
42
|
+
*/
|
|
43
|
+
defaultLayoutLifetime: SegmentLifetime;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A render with no client router to hold segments: every outlet live. */
|
|
47
|
+
export const LIVE_ONLY_RENDER: SegmentRender = {
|
|
48
|
+
documents: null,
|
|
49
|
+
defaultLayoutLifetime: 'request',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The element for an outlet: a server component that decides when it renders
|
|
54
|
+
* — after every access gate above it.
|
|
55
|
+
*
|
|
56
|
+
* A closure with no props rather than a component taking `{ spec }`:
|
|
57
|
+
* dev Flight serializes a server component's props as debug info, and these
|
|
58
|
+
* would repeat the whole subtree in every dev payload.
|
|
59
|
+
*/
|
|
60
|
+
export function outletGate(spec: OutletSpec): ReactElement {
|
|
61
|
+
function OutletGate(): ReactElement {
|
|
62
|
+
const { SegmentOutlet } = clientComponents();
|
|
63
|
+
return createElement(SegmentOutlet, { segmentPath: spec.segmentPath, decision: decide(spec) });
|
|
64
|
+
}
|
|
65
|
+
OUTLET_GATES.add(OutletGate);
|
|
66
|
+
return createElement(OutletGate);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every gate component `outletGate` made, so a subtree walk can stop at one. */
|
|
70
|
+
const OUTLET_GATES = new WeakSet<object>();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether `node` is an outlet gate element — the boundary of the segment
|
|
74
|
+
* whose content contains it. A walk over one segment's output (a
|
|
75
|
+
* 'document' segment's read scope) stops here: what renders inside belongs
|
|
76
|
+
* to the nested segment and its own rules.
|
|
77
|
+
*/
|
|
78
|
+
export function isOutletGateElement(node: unknown): boolean {
|
|
79
|
+
if (typeof node !== 'object' || node === null || !('type' in node)) return false;
|
|
80
|
+
const type = (node as { type: unknown }).type;
|
|
81
|
+
return typeof type === 'function' && OUTLET_GATES.has(type);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function decide(spec: OutletSpec): OutletDecision {
|
|
85
|
+
if (!spec.document) return { children: spec.content };
|
|
86
|
+
if ('issued' in spec.document) return { children: spec.content, digest: spec.document.issued };
|
|
87
|
+
return documentSkip(spec, spec.document.held);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A `'document'` skip: the segment is not rendered, so nothing says which
|
|
92
|
+
* nested outlets its content would hold — every one is decided. The client
|
|
93
|
+
* renders only those in its cached copy; a nested segment a layout body hid
|
|
94
|
+
* at load is still rendered and serialized here (its own `access.ts` still
|
|
95
|
+
* gates it), which is why a `'document'` layout body is not a data-hiding
|
|
96
|
+
* boundary (design/53 §"What stays frozen").
|
|
97
|
+
*/
|
|
98
|
+
function documentSkip(spec: OutletSpec, digest: string): OutletDecision {
|
|
99
|
+
const outlets: Record<string, OutletDecision> = {};
|
|
100
|
+
for (const nested of spec.nested) outlets[nested.segmentPath] = decide(nested);
|
|
101
|
+
return { skip: true, digest, outlets };
|
|
102
|
+
}
|
|
@@ -3,11 +3,20 @@
|
|
|
3
3
|
* segment's read scope (`read-scope.ts`, design/53-segment-lifetime.md §"What
|
|
4
4
|
* a 'document' segment may read"). No React and no render machinery: the
|
|
5
5
|
* accessors in `request-context.ts` and `cookie-context.ts` import this.
|
|
6
|
+
*
|
|
7
|
+
* A read outside the key is detected and reported in every environment: the
|
|
8
|
+
* dev server's error overlay, or a warning in the log. The read returns its
|
|
9
|
+
* real value, and the component call that read is marked, so its output
|
|
10
|
+
* withdraws the segment from the client (`read-scope.ts`) and the segment renders
|
|
11
|
+
* as `'request'` for that client from then on (design/53 §"Reads outside the key").
|
|
6
12
|
*/
|
|
7
13
|
|
|
8
14
|
import { documentReadScopeAls, type DocumentReadScope } from '../als-registry.ts';
|
|
9
15
|
import type { CoercedParams } from '../../shared/param-value.ts';
|
|
10
16
|
import type { SearchParamsReader } from '../../shared/als-slots.ts';
|
|
17
|
+
import type { ReadonlyHeaders } from '../request-context.ts';
|
|
18
|
+
import { isUnkeyableHeader } from '../../shared/key-headers.ts';
|
|
19
|
+
import { logDocumentReadOutsideKey } from '../logger.ts';
|
|
11
20
|
|
|
12
21
|
/** The read scope the current render runs in, if it is a `'document'` segment's. */
|
|
13
22
|
export function currentReadScope(): DocumentReadScope | undefined {
|
|
@@ -15,39 +24,119 @@ export function currentReadScope(): DocumentReadScope | undefined {
|
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
/** Which part of a key would allow a read, for the error's fix. */
|
|
18
|
-
type KeyPart = 'segmentParams' | 'searchParams' | 'cookies';
|
|
27
|
+
type KeyPart = 'segmentParams' | 'searchParams' | 'cookies' | 'headers';
|
|
19
28
|
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
30
|
+
* Refuse a read outside the key: mark the component call that made it, report
|
|
31
|
+
* it once per segment render (naming the segment, what was read and the fix:
|
|
32
|
+
* add it to the key, or make the segment `'request'`), and return, so the
|
|
33
|
+
* caller performs the read.
|
|
23
34
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
function refuseRead(
|
|
36
|
+
scope: DocumentReadScope,
|
|
37
|
+
what: string,
|
|
38
|
+
part?: KeyPart,
|
|
39
|
+
/** Overrides the fix when adding the read to the key is not possible. */
|
|
40
|
+
fixOverride?: string
|
|
41
|
+
): void {
|
|
42
|
+
// A view (`keyedHeaders`, `scopedParams`) keeps the scope it was made in,
|
|
43
|
+
// and can be handed to a component that reads through it later: the call
|
|
44
|
+
// reading now is the one whose output carries the value, so it is marked
|
|
45
|
+
// too (codex on #1317).
|
|
46
|
+
scope.call.read = true;
|
|
47
|
+
const active = currentReadScope();
|
|
48
|
+
if (active) active.call.read = true;
|
|
49
|
+
if (scope.reported.done) return;
|
|
50
|
+
scope.reported.done = true;
|
|
51
|
+
logDocumentReadOutsideKey(readOutsideKey(scope, what, part, fixOverride), {
|
|
52
|
+
segment: scope.segmentPath,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readOutsideKey(
|
|
57
|
+
scope: DocumentReadScope,
|
|
58
|
+
what: string,
|
|
59
|
+
part?: KeyPart,
|
|
60
|
+
fixOverride?: string
|
|
61
|
+
): Error {
|
|
62
|
+
const fix =
|
|
63
|
+
fixOverride ??
|
|
64
|
+
(part
|
|
65
|
+
? `Add it to key.${part}, or declare lifetime: 'request'.`
|
|
66
|
+
: "A 'document' segment cannot depend on it; declare lifetime: 'request'.");
|
|
28
67
|
return new Error(
|
|
29
68
|
`[timber] ${scope.segmentPath} is lifetime: 'document' (declared, or from defaultLayoutLifetime) ` +
|
|
30
69
|
`and read ${what}, which is not in its key. ` +
|
|
31
70
|
`${fix} The segment is skipped without rendering while its key is unchanged, so the read ` +
|
|
32
|
-
`would freeze at its first value
|
|
71
|
+
`would freeze at its first value; until it is fixed, it renders as lifetime: 'request' ` +
|
|
72
|
+
`for this client instead. See design/53-segment-lifetime.md ` +
|
|
33
73
|
`§"What a 'document' segment may read".`
|
|
34
74
|
);
|
|
35
75
|
}
|
|
36
76
|
|
|
37
|
-
/**
|
|
38
|
-
|
|
77
|
+
/**
|
|
78
|
+
* The request headers as a `'document'` segment may read them: `get` and
|
|
79
|
+
* `has` of a header in its key. Any other name is refused, and so is reading
|
|
80
|
+
* them all (iteration, `entries`, `forEach`), which could see headers the
|
|
81
|
+
* key leaves out — the pathname among them.
|
|
82
|
+
*/
|
|
83
|
+
export function keyedHeaders(headers: ReadonlyHeaders, scope: DocumentReadScope): ReadonlyHeaders {
|
|
84
|
+
const keyed = (name: string): string => {
|
|
85
|
+
if (scope.headers.has(name.toLowerCase())) return name;
|
|
86
|
+
const what = `the header "${name}"`;
|
|
87
|
+
if (name.toLowerCase() === 'cookie') {
|
|
88
|
+
refuseRead(
|
|
89
|
+
scope,
|
|
90
|
+
what,
|
|
91
|
+
'cookies',
|
|
92
|
+
'Read cookies through a cookie definition in key.cookies.'
|
|
93
|
+
);
|
|
94
|
+
} else if (isUnkeyableHeader(name)) {
|
|
95
|
+
refuseRead(
|
|
96
|
+
scope,
|
|
97
|
+
what,
|
|
98
|
+
undefined,
|
|
99
|
+
"A key may not name a credential; declare lifetime: 'request'."
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
refuseRead(scope, what, 'headers');
|
|
103
|
+
}
|
|
104
|
+
return name;
|
|
105
|
+
};
|
|
106
|
+
const all = (): ReadonlyHeaders => {
|
|
107
|
+
refuseRead(
|
|
108
|
+
scope,
|
|
109
|
+
'every request header',
|
|
110
|
+
undefined,
|
|
111
|
+
"Read each header you need with getHeaders().get(name) and add it to key.headers, or declare lifetime: 'request'."
|
|
112
|
+
);
|
|
113
|
+
return headers;
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
get: (name) => headers.get(keyed(name)),
|
|
117
|
+
has: (name) => headers.has(keyed(name)),
|
|
118
|
+
entries: () => all().entries(),
|
|
119
|
+
keys: () => all().keys(),
|
|
120
|
+
values: () => all().values(),
|
|
121
|
+
forEach: (callback, thisArg) => all().forEach(callback, thisArg),
|
|
122
|
+
[Symbol.iterator]: () => all()[Symbol.iterator](),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Refuse the read if the current render may not read `what` at all (raw search params). */
|
|
127
|
+
export function checkUnscopedRead(what: string): void {
|
|
39
128
|
const scope = currentReadScope();
|
|
40
|
-
if (scope)
|
|
129
|
+
if (scope) refuseRead(scope, what);
|
|
41
130
|
}
|
|
42
131
|
|
|
43
132
|
/**
|
|
44
|
-
*
|
|
133
|
+
* Refuse the read if the current render reads search-param fields outside its key. A
|
|
45
134
|
* field is in the key only when the key's definition reads it through the
|
|
46
135
|
* same codec and URL key — a `.pick()` of the keyed definition, or the keyed
|
|
47
136
|
* definition itself. Another definition with a field of the same name may map
|
|
48
137
|
* it to another URL parameter or parse it differently.
|
|
49
138
|
*/
|
|
50
|
-
export function
|
|
139
|
+
export function checkSearchParamsRead(reader: SearchParamsReader): void {
|
|
51
140
|
const scope = currentReadScope();
|
|
52
141
|
if (!scope) return;
|
|
53
142
|
const outside = Object.keys(reader.codecs).filter((field) => {
|
|
@@ -59,24 +148,23 @@ export function assertSearchParamsRead(reader: SearchParamsReader): void {
|
|
|
59
148
|
);
|
|
60
149
|
});
|
|
61
150
|
if (outside.length > 0) {
|
|
62
|
-
|
|
151
|
+
refuseRead(scope, `the search params ${outside.join(', ')}`, 'searchParams');
|
|
63
152
|
}
|
|
64
153
|
}
|
|
65
154
|
|
|
66
155
|
/**
|
|
67
|
-
*
|
|
156
|
+
* Refuse the read if the current render reads a cookie outside its key. A keyed cookie
|
|
68
157
|
* is in the key only as its definition parses it, so it may be read only
|
|
69
158
|
* through that definition (`codec` is the reader's); a raw read, or another
|
|
70
159
|
* definition of the same name, could see a difference the key does not.
|
|
71
160
|
*/
|
|
72
|
-
export function
|
|
161
|
+
export function checkCookieRead(name: string, codec?: unknown): void {
|
|
73
162
|
const scope = currentReadScope();
|
|
74
163
|
if (!scope) return;
|
|
75
164
|
if (!scope.cookies.has(name)) {
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
throw readOutsideKey(
|
|
165
|
+
refuseRead(scope, `the cookie "${name}"`, 'cookies');
|
|
166
|
+
} else if (codec === undefined || scope.cookies.get(name) !== codec) {
|
|
167
|
+
refuseRead(
|
|
80
168
|
scope,
|
|
81
169
|
`the raw value of the cookie "${name}" (read it through the definition in its key)`,
|
|
82
170
|
'cookies'
|
|
@@ -100,7 +188,7 @@ const OBJECT_PROBES: ReadonlySet<string> = new Set([
|
|
|
100
188
|
]);
|
|
101
189
|
|
|
102
190
|
/**
|
|
103
|
-
* The params a scoped render sees: reading one outside the key
|
|
191
|
+
* The params a scoped render sees: reading one outside the key is refused. Its
|
|
104
192
|
* own keys are only the params in the key, so spreading it, or passing it to
|
|
105
193
|
* a client component, carries exactly what the segment may depend on.
|
|
106
194
|
*/
|
|
@@ -124,7 +212,7 @@ export function scopedParams<T extends CoercedParams>(params: T): T {
|
|
|
124
212
|
return new Proxy(target, {
|
|
125
213
|
get(target, name, receiver) {
|
|
126
214
|
if (refused(name)) {
|
|
127
|
-
|
|
215
|
+
refuseRead(scope, `the segment param "${String(name)}"`, 'segmentParams');
|
|
128
216
|
}
|
|
129
217
|
return Reflect.get(target, name, receiver);
|
|
130
218
|
},
|
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
* A `'document'` segment is skipped without rendering whenever its key is
|
|
7
7
|
* unchanged, so anything else it read would freeze silently at its load-time
|
|
8
|
-
* value. The rule
|
|
8
|
+
* value. The rule detects that in every environment, reports it (the dev
|
|
9
|
+
* overlay, or a warning in the log), and degrades the segment to `'request'`
|
|
10
|
+
* for the client (below). What it refuses:
|
|
9
11
|
*
|
|
10
|
-
* - `getSegmentParams()` returns a view that
|
|
11
|
-
* - a search-params definition's `.get()`
|
|
12
|
-
* in the key's definition, and the raw search params
|
|
13
|
-
* - the cookie jar
|
|
14
|
-
* - the
|
|
12
|
+
* - `getSegmentParams()` returns a view that refuses a param outside the key;
|
|
13
|
+
* - a search-params definition's `.get()` is refused unless every field it
|
|
14
|
+
* reads is in the key's definition, and so are the raw search params;
|
|
15
|
+
* - the cookie jar refuses a cookie outside the key, and `getAll()`;
|
|
16
|
+
* - `getHeaders()` reads only the headers in the key; any other header, and
|
|
17
|
+
* iterating them all, is refused — and with that the pathname, which no timber
|
|
15
18
|
* API exposes to a component except through a header.
|
|
16
19
|
*
|
|
17
20
|
* **Reach.** The scope is an AsyncLocalStorage scope around the segment's
|
|
@@ -25,13 +28,50 @@
|
|
|
25
28
|
* Not covered: values computed outside this render and handed to it — a
|
|
26
29
|
* `timber.cache` entry an earlier request filled, or a module-level value. The
|
|
27
30
|
* accessors' checks are `read-rule.ts`.
|
|
31
|
+
*
|
|
32
|
+
* **Degrading.** The read rule reports a refused read, lets it return its
|
|
33
|
+
* real value and marks the component call that made it: each scoped call runs
|
|
34
|
+
* in its own copy of the scope, with a fresh `call` record. The render has
|
|
35
|
+
* already sent the outlet's key digest (the outlet decides before the segment
|
|
36
|
+
* renders), so the content withdraws itself instead: when a call that read
|
|
37
|
+
* outside the key returns, its output gets a `DocumentWithdrawal` marker. The
|
|
38
|
+
* marker sits beside what the read produced, so the client commits it exactly
|
|
39
|
+
* when it commits that content — not in a Suspense fallback or an unrendered
|
|
40
|
+
* prop another component happened to finish in. When it commits, the client
|
|
41
|
+
* drops the segment's entry and records none for that outlet for the rest of
|
|
42
|
+
* the document (`client/outlet-content-cache.ts`). The client never advertises
|
|
43
|
+
* a digest for it again, so every later navigation renders it live —
|
|
44
|
+
* `'request'` for that client.
|
|
45
|
+
*
|
|
46
|
+
* A call that reads and then throws has no output to mark. Its error is
|
|
47
|
+
* remembered, and each catcher that renders a fallback in its place inside an
|
|
48
|
+
* outlet (a deny page, a slot's `default.tsx`) passes the fallback through
|
|
49
|
+
* `fallbackAfter`, which marks it. The marker withdraws whichever outlet the
|
|
50
|
+
* fallback lands in.
|
|
51
|
+
*
|
|
52
|
+
* An async iterable the call returned is advanced later, in a call record of
|
|
53
|
+
* its own; the first chunk it yields after a read carries the marker, or, for
|
|
54
|
+
* a read on its closing step, a last chunk of the marker alone.
|
|
55
|
+
*
|
|
56
|
+
* A scoped view (`getHeaders()`, `getSegmentParams()`) handed down to another
|
|
57
|
+
* component marks the call reading through it, as well as the one that made it.
|
|
58
|
+
*
|
|
59
|
+
* Not marked: a read in other work the call did not await, such as a promise
|
|
60
|
+
* handed to a client component (it lands in a call record nobody checks).
|
|
61
|
+
* See design/53 §"Reads outside the key".
|
|
28
62
|
*/
|
|
29
63
|
|
|
30
|
-
import { createElement, type ReactNode } from 'react';
|
|
64
|
+
import { createElement, Fragment, type ReactElement, type ReactNode } from 'react';
|
|
31
65
|
|
|
32
66
|
import { documentReadScopeAls, type DocumentReadScope } from '../als-registry.ts';
|
|
33
|
-
import { isOutletGateElement } from '
|
|
34
|
-
import {
|
|
67
|
+
import { isOutletGateElement } from './outlet-gate.ts';
|
|
68
|
+
import {
|
|
69
|
+
callAndRewrite,
|
|
70
|
+
isThenable,
|
|
71
|
+
type ServerComponent,
|
|
72
|
+
type SubtreeRule,
|
|
73
|
+
} from '../subtree-walk.ts';
|
|
74
|
+
import { clientComponents } from '../vite-handoff-rsc.ts';
|
|
35
75
|
import type { DocumentLifetime } from './segment-key.ts';
|
|
36
76
|
|
|
37
77
|
/** The read scope of one `'document'` segment. */
|
|
@@ -51,6 +91,9 @@ export function readScopeFor(
|
|
|
51
91
|
])
|
|
52
92
|
),
|
|
53
93
|
cookies: new Map((key.cookies ?? []).map((cookie) => [cookie.name, cookie.codec])),
|
|
94
|
+
headers: new Set((key.headers ?? []).map((name) => name.toLowerCase())),
|
|
95
|
+
reported: { done: false },
|
|
96
|
+
call: { read: false },
|
|
54
97
|
};
|
|
55
98
|
}
|
|
56
99
|
|
|
@@ -60,7 +103,7 @@ export function readScopeFor(
|
|
|
60
103
|
*/
|
|
61
104
|
export function inReadScope(component: ServerComponent, scope: DocumentReadScope): ServerComponent {
|
|
62
105
|
const rule = scopeRule(scope);
|
|
63
|
-
return (props) =>
|
|
106
|
+
return (props) => runCall(scope, () => callAndRewrite(component, props, rule));
|
|
64
107
|
}
|
|
65
108
|
|
|
66
109
|
/**
|
|
@@ -75,9 +118,66 @@ function ScopedServerComponent(props: {
|
|
|
75
118
|
scope: DocumentReadScope;
|
|
76
119
|
}): ReactNode | Promise<ReactNode> {
|
|
77
120
|
const { component, componentProps, scope } = props;
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
121
|
+
return runCall(scope, () => callAndRewrite(component, componentProps, scopeRule(scope)));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Run one scoped component call in its own copy of the scope — a fresh
|
|
126
|
+
* `call` record, the segment's shared `reported` — and append the client's
|
|
127
|
+
* withdrawal marker to its output if the call, or work it awaited, read
|
|
128
|
+
* outside the key.
|
|
129
|
+
*/
|
|
130
|
+
function runCall(
|
|
131
|
+
scope: DocumentReadScope,
|
|
132
|
+
call: () => ReactNode | Promise<ReactNode>
|
|
133
|
+
): ReactNode | Promise<ReactNode> {
|
|
134
|
+
const frame: DocumentReadScope = { ...scope, call: { read: false } };
|
|
135
|
+
const thrown = (error: unknown): never => {
|
|
136
|
+
if (frame.call.read && typeof error === 'object' && error !== null) {
|
|
137
|
+
THROWN_AFTER_READ.add(error);
|
|
138
|
+
}
|
|
139
|
+
throw error;
|
|
140
|
+
};
|
|
141
|
+
let output: ReactNode | Promise<ReactNode>;
|
|
142
|
+
try {
|
|
143
|
+
output = documentReadScopeAls.run(frame, call);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
return thrown(error);
|
|
146
|
+
}
|
|
147
|
+
if (isThenable(output)) {
|
|
148
|
+
return Promise.resolve(output).then(
|
|
149
|
+
(node) => (frame.call.read ? withMarker(node) : node),
|
|
150
|
+
thrown
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return frame.call.read ? withMarker(output) : output;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Errors thrown by a scoped call after it read outside its key. Weak: an
|
|
158
|
+
* error lives only as long as whoever handles it holds it.
|
|
159
|
+
*/
|
|
160
|
+
const THROWN_AFTER_READ = new WeakSet<object>();
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The fallback a catcher renders in place of a component that threw: marked
|
|
164
|
+
* to withdraw its outlet when the throw came from a scoped call that read
|
|
165
|
+
* outside its key, so the client does not keep the fallback under the key
|
|
166
|
+
* digest. Every catcher that renders a fallback inside an outlet calls this.
|
|
167
|
+
*/
|
|
168
|
+
export function fallbackAfter<T extends ReactNode>(error: unknown, fallback: T): T | ReactElement {
|
|
169
|
+
const marked = typeof error === 'object' && error !== null && THROWN_AFTER_READ.has(error);
|
|
170
|
+
return marked ? withMarker(fallback) : fallback;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `node` with a `DocumentWithdrawal` marker beside it. Two arguments, not an
|
|
175
|
+
* array: no key is needed, and `node` keeps its position as the fragment's
|
|
176
|
+
* first child.
|
|
177
|
+
*/
|
|
178
|
+
function withMarker(node: ReactNode): ReactElement {
|
|
179
|
+
const { DocumentWithdrawal } = clientComponents();
|
|
180
|
+
return createElement(Fragment, null, node, createElement(DocumentWithdrawal));
|
|
81
181
|
}
|
|
82
182
|
|
|
83
183
|
function scopeRule(scope: DocumentReadScope): SubtreeRule {
|
|
@@ -93,7 +193,23 @@ function scopeRule(scope: DocumentReadScope): SubtreeRule {
|
|
|
93
193
|
}),
|
|
94
194
|
// A nested outlet is another segment: its own lifetime decides what it reads.
|
|
95
195
|
isOpaque: isOutletGateElement,
|
|
96
|
-
// An async iterable it returned reads, as it is advanced, inside the scope
|
|
97
|
-
|
|
196
|
+
// An async iterable it returned reads, as it is advanced, inside the scope:
|
|
197
|
+
// in a call record of its own, so a chunk produced after a read outside
|
|
198
|
+
// the key carries the marker as a call's output would.
|
|
199
|
+
// Marked once: the marker commits with that chunk, and each marked chunk
|
|
200
|
+
// becomes an element, which an iterable read as data would notice. A read
|
|
201
|
+
// on the closing step yields the marker alone, since the return value is
|
|
202
|
+
// not rendered (codex on #1317).
|
|
203
|
+
iterate: () => {
|
|
204
|
+
const frame: DocumentReadScope = { ...scope, call: { read: false } };
|
|
205
|
+
let marked = false;
|
|
206
|
+
const due = () => frame.call.read && !marked && (marked = true);
|
|
207
|
+
return {
|
|
208
|
+
run: (fn) => documentReadScopeAls.run(frame, fn),
|
|
209
|
+
// What an async iterable rendered as a child yields is rendered as nodes.
|
|
210
|
+
yielded: (value) => (due() ? withMarker(value as ReactNode) : value),
|
|
211
|
+
beforeClose: () => (due() ? withMarker(null) : undefined),
|
|
212
|
+
};
|
|
213
|
+
},
|
|
98
214
|
};
|
|
99
215
|
}
|