@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
|
@@ -3,38 +3,37 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The header carries two unrelated things:
|
|
5
5
|
*
|
|
6
|
-
* - `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* - `documents` — the key digests of the `'document'` segments the client
|
|
7
|
+
* holds content for, by outlet path. An outlet gate skips a `'document'`
|
|
8
|
+
* segment without rendering it when the digest verifies against this
|
|
9
|
+
* request's key values (design/53-segment-lifetime.md). Always read on a
|
|
10
|
+
* navigation; excluded from the `_rsc` cache key.
|
|
10
11
|
* - `treePaths` — the `app/` directory paths of the segments mounted right
|
|
11
12
|
* now, for interception scoping (design/07-routing.md §"Intercepting
|
|
12
13
|
* Routes", TIM-1282).
|
|
13
14
|
*
|
|
14
|
-
* Neither is a security input. A forged
|
|
15
|
-
* skip for content the client claims to hold; the client checks every
|
|
16
|
-
* against the
|
|
17
|
-
* regardless. See design/13-security.md §"State tree manipulation".
|
|
15
|
+
* Neither is a security input. A forged digest can only make the server
|
|
16
|
+
* send a skip for content the client claims to hold; the client checks every
|
|
17
|
+
* skip against the digest of what it actually holds, and every `access.ts`
|
|
18
|
+
* runs regardless. See design/13-security.md §"State tree manipulation".
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
|
-
import {
|
|
21
|
+
import { KEY_DIGEST_SHAPE } from './segment-lifetime/key-digest.ts';
|
|
21
22
|
import { swallow } from './logger.ts';
|
|
22
23
|
|
|
23
24
|
/** The parsed header. */
|
|
24
25
|
export interface ClientStateTree {
|
|
25
|
-
/**
|
|
26
|
-
|
|
26
|
+
/** `'document'` key digests by outlet path, or null when none were sent. */
|
|
27
|
+
documents: ReadonlyMap<string, string> | null;
|
|
27
28
|
/** Directory paths of the mounted segments, or null when none were sent. */
|
|
28
29
|
treePaths: ReadonlySet<string> | null;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* More
|
|
33
|
+
* More entries than any route renders outlets. A map past it is not a
|
|
33
34
|
* client's: it is ignored rather than walked.
|
|
34
35
|
*/
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const HASH_SHAPE = new RegExp(`^[A-Za-z0-9_-]{${SEGMENT_HASH_LENGTH}}$`);
|
|
36
|
+
const MAX_ENTRIES = 512;
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Parse `X-Timber-State-Tree`. Null when the header is missing, malformed, or
|
|
@@ -44,7 +43,7 @@ export function parseClientStateTree(req: Request): ClientStateTree | null {
|
|
|
44
43
|
const header = req.headers.get('X-Timber-State-Tree');
|
|
45
44
|
if (!header) return null;
|
|
46
45
|
|
|
47
|
-
let parsed: {
|
|
46
|
+
let parsed: { documents?: unknown; treePaths?: unknown };
|
|
48
47
|
try {
|
|
49
48
|
parsed = JSON.parse(header) as typeof parsed;
|
|
50
49
|
} catch (err) {
|
|
@@ -53,23 +52,27 @@ export function parseClientStateTree(req: Request): ClientStateTree | null {
|
|
|
53
52
|
}
|
|
54
53
|
if (!parsed || typeof parsed !== 'object') return null;
|
|
55
54
|
|
|
56
|
-
const
|
|
57
|
-
if (parsed.hashes && typeof parsed.hashes === 'object' && !Array.isArray(parsed.hashes)) {
|
|
58
|
-
const entries = Object.entries(parsed.hashes as Record<string, unknown>);
|
|
59
|
-
if (entries.length <= MAX_HASHES) {
|
|
60
|
-
for (const [path, hash] of entries) {
|
|
61
|
-
if (typeof hash === 'string' && HASH_SHAPE.test(hash)) hashes.set(path, hash);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
55
|
+
const documents = readTokenMap(parsed.documents, KEY_DIGEST_SHAPE);
|
|
65
56
|
|
|
66
57
|
const treePaths = Array.isArray(parsed.treePaths)
|
|
67
58
|
? new Set(parsed.treePaths.filter((p): p is string => typeof p === 'string'))
|
|
68
59
|
: new Set<string>();
|
|
69
60
|
|
|
70
|
-
if (
|
|
61
|
+
if (documents.size === 0 && treePaths.size === 0) return null;
|
|
71
62
|
return {
|
|
72
|
-
|
|
63
|
+
documents: documents.size > 0 ? documents : null,
|
|
73
64
|
treePaths: treePaths.size > 0 ? treePaths : null,
|
|
74
65
|
};
|
|
75
66
|
}
|
|
67
|
+
|
|
68
|
+
/** A `{ [outletPath]: token }` map, keeping only tokens of the expected shape. */
|
|
69
|
+
function readTokenMap(value: unknown, shape: RegExp): Map<string, string> {
|
|
70
|
+
const map = new Map<string, string>();
|
|
71
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return map;
|
|
72
|
+
const entries = Object.entries(value as Record<string, unknown>);
|
|
73
|
+
if (entries.length > MAX_ENTRIES) return map;
|
|
74
|
+
for (const [path, token] of entries) {
|
|
75
|
+
if (typeof token === 'string' && shape.test(token)) map.set(path, token);
|
|
76
|
+
}
|
|
77
|
+
return map;
|
|
78
|
+
}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* smuggling primitive that the encoding contract closes.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { assertCookieRead, assertUnscopedRead } from './segment-lifetime/read-rule.ts';
|
|
16
|
+
import { COOKIE_READ_THROUGH, type CookieReadThrough } from '../shared/cookie-read-through.ts';
|
|
15
17
|
import { requestContextAls, type RequestContextStore } from './als-registry.ts';
|
|
16
18
|
import { isDebug } from './debug.ts';
|
|
17
19
|
import {
|
|
@@ -76,19 +78,31 @@ export function getCookieJar(): RequestCookies {
|
|
|
76
78
|
return {
|
|
77
79
|
// Reads are noted (dev only) so a later write of the same cookie can
|
|
78
80
|
// warn if React.cache may have memoized the old value (TIM-1529 D3).
|
|
81
|
+
// Inside a 'document' segment, only the cookies in its key (design/53).
|
|
79
82
|
get(name: string): string | undefined {
|
|
83
|
+
assertCookieRead(name);
|
|
84
|
+
noteCookieReadForReactCache(name);
|
|
85
|
+
return map.get(name);
|
|
86
|
+
},
|
|
87
|
+
// A typed definition's read: allowed for a keyed cookie read through the
|
|
88
|
+
// key's own definition (shared/cookie-read-through.ts).
|
|
89
|
+
[COOKIE_READ_THROUGH](name: string, codec: unknown): string | undefined {
|
|
90
|
+
assertCookieRead(name, codec);
|
|
80
91
|
noteCookieReadForReactCache(name);
|
|
81
92
|
return map.get(name);
|
|
82
93
|
},
|
|
83
94
|
has(name: string): boolean {
|
|
95
|
+
assertCookieRead(name);
|
|
84
96
|
noteCookieReadForReactCache(name);
|
|
85
97
|
return map.has(name);
|
|
86
98
|
},
|
|
87
99
|
getAll(): Array<{ name: string; value: string }> {
|
|
100
|
+
assertUnscopedRead('every cookie');
|
|
88
101
|
noteCookieReadForReactCache(ANY_COOKIE);
|
|
89
102
|
return Array.from(map.entries()).map(([name, value]) => ({ name, value }));
|
|
90
103
|
},
|
|
91
104
|
get size(): number {
|
|
105
|
+
assertUnscopedRead('the number of cookies');
|
|
92
106
|
noteCookieReadForReactCache(ANY_COOKIE);
|
|
93
107
|
return map.size;
|
|
94
108
|
},
|
|
@@ -234,6 +248,7 @@ export function getCookieJar(): RequestCookies {
|
|
|
234
248
|
},
|
|
235
249
|
|
|
236
250
|
toString(): string {
|
|
251
|
+
assertUnscopedRead('every cookie');
|
|
237
252
|
noteCookieReadForReactCache(ANY_COOKIE);
|
|
238
253
|
// Re-encode values when serializing as a Cookie header — the
|
|
239
254
|
// RYW map holds decoded logical values, but a Cookie header has
|
|
@@ -317,6 +332,8 @@ export type CookieDeleteOptions = Omit<CookieOptions, 'maxAge' | 'expires'>;
|
|
|
317
332
|
export interface RequestCookies {
|
|
318
333
|
/** Get a cookie value by name. Returns undefined if not present. */
|
|
319
334
|
get(name: string): string | undefined;
|
|
335
|
+
/** @internal A typed definition's read (`defineCookie().get()`). */
|
|
336
|
+
[COOKIE_READ_THROUGH]?: CookieReadThrough;
|
|
320
337
|
/** Check if a cookie exists. */
|
|
321
338
|
has(name: string): boolean;
|
|
322
339
|
/** Get all cookies as an array of { name, value } pairs. */
|
|
@@ -73,8 +73,6 @@ export interface NodeFlightAbort {
|
|
|
73
73
|
signal?: AbortSignal;
|
|
74
74
|
/** Abort with a `RenderTimeoutError` after this long, if still rendering. */
|
|
75
75
|
timeoutMs?: number;
|
|
76
|
-
/** Shown every chunk, and the end (`FlightRenderOptions.tap`). */
|
|
77
|
-
tap?: { observe(chunk: Uint8Array): void; end(): void };
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
/**
|
|
@@ -95,7 +93,7 @@ export interface NodeFlightAbort {
|
|
|
95
93
|
*/
|
|
96
94
|
export function pipeFlightToNode(
|
|
97
95
|
flight: PipeableFlight,
|
|
98
|
-
{ signal, timeoutMs
|
|
96
|
+
{ signal, timeoutMs }: NodeFlightAbort
|
|
99
97
|
): Readable {
|
|
100
98
|
const scope = new AbortController();
|
|
101
99
|
const timer =
|
|
@@ -109,11 +107,9 @@ export function pipeFlightToNode(
|
|
|
109
107
|
objectMode: true,
|
|
110
108
|
transform(chunk: NodeFlightChunk, _encoding, callback) {
|
|
111
109
|
const out = typeof chunk === 'string' ? chunk.toWellFormed() : chunk;
|
|
112
|
-
tap?.observe(typeof out === 'string' ? Buffer.from(out) : out);
|
|
113
110
|
callback(null, out);
|
|
114
111
|
},
|
|
115
112
|
destroy(error, callback) {
|
|
116
|
-
tap?.end();
|
|
117
113
|
endScope(scope);
|
|
118
114
|
clearTimeout(timer);
|
|
119
115
|
// Flight ended the stream (React calls `end()` once the render is
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import type { Readable } from 'node:stream';
|
|
25
|
+
import { isAppStackFrame } from './framework-stack-frames.ts';
|
|
25
26
|
import { nodeStreamsPlatform } from './node-streams-platform.ts';
|
|
26
27
|
import { releaseReason } from './render-utils.ts';
|
|
27
|
-
import { withTimeout } from './render-timeout.ts';
|
|
28
28
|
import {
|
|
29
29
|
concatBytes,
|
|
30
30
|
drainWithDeadline,
|
|
@@ -75,30 +75,6 @@ export interface FlightRenderOptions {
|
|
|
75
75
|
* themselves.
|
|
76
76
|
*/
|
|
77
77
|
timeoutMs?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Observes every chunk the render writes, and its end — the segment hash
|
|
80
|
-
* tap (segment-hash/stream-tap.ts). Chunks pass through unchanged.
|
|
81
|
-
*/
|
|
82
|
-
tap?: FlightTap;
|
|
83
|
-
/**
|
|
84
|
-
* Values to write as opaque references (`$T<id>`) instead of serializing —
|
|
85
|
-
* Flight's temporary references, keyed by the value. A segment-hash capture
|
|
86
|
-
* writes its nested outlets this way so decoding it can put the live outlet
|
|
87
|
-
* back (segment-hash/capture.ts).
|
|
88
|
-
*/
|
|
89
|
-
temporaryReferences?: WeakMap<object, string>;
|
|
90
|
-
/**
|
|
91
|
-
* Prefix for the ids `useId()` returns in server components. Each render
|
|
92
|
-
* counts from zero, so two renders whose output shares one document — the
|
|
93
|
-
* main render and a segment-hash capture — need different prefixes.
|
|
94
|
-
*/
|
|
95
|
-
identifierPrefix?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** An observer of a Flight render's output. */
|
|
99
|
-
export interface FlightTap {
|
|
100
|
-
observe(chunk: Uint8Array): void;
|
|
101
|
-
end(): void;
|
|
102
78
|
}
|
|
103
79
|
|
|
104
80
|
/**
|
|
@@ -124,8 +100,7 @@ export type WebFlightRenderer = (
|
|
|
124
100
|
options?: {
|
|
125
101
|
onError?: (error: unknown) => string | void;
|
|
126
102
|
signal?: AbortSignal;
|
|
127
|
-
|
|
128
|
-
identifierPrefix?: string;
|
|
103
|
+
filterStackFrame?: (url: string, functionName: string) => boolean;
|
|
129
104
|
}
|
|
130
105
|
) => ReadableStream<Uint8Array>;
|
|
131
106
|
|
|
@@ -134,13 +109,13 @@ export type NodeFlightRenderer = (
|
|
|
134
109
|
model: unknown,
|
|
135
110
|
options?: {
|
|
136
111
|
onError?: (error: unknown) => string | void;
|
|
137
|
-
|
|
138
|
-
identifierPrefix?: string;
|
|
112
|
+
filterStackFrame?: (url: string, functionName: string) => boolean;
|
|
139
113
|
}
|
|
140
114
|
) => import('./flight-source-node.ts').PipeableFlight;
|
|
141
115
|
|
|
142
116
|
/**
|
|
143
|
-
* Build `renderFlight()` from the platform's renderers.
|
|
117
|
+
* Build `renderFlight()` from the platform's renderers. Every render filters
|
|
118
|
+
* timber's own frames out of its dev debug info (framework-stack-frames.ts). The Node renderer is
|
|
144
119
|
* used whenever it was loaded (on Node it always is — see `rsc-runtime/rsc.ts`);
|
|
145
120
|
* otherwise every render is a Web stream.
|
|
146
121
|
*
|
|
@@ -160,13 +135,11 @@ export function createRenderFlight(
|
|
|
160
135
|
stream: pipeFlightToNode(
|
|
161
136
|
node(model, {
|
|
162
137
|
onError: options.onError,
|
|
163
|
-
|
|
164
|
-
identifierPrefix: options.identifierPrefix,
|
|
138
|
+
filterStackFrame: isAppStackFrame,
|
|
165
139
|
}),
|
|
166
140
|
{
|
|
167
141
|
signal: options.signal,
|
|
168
142
|
timeoutMs: options.timeoutMs ?? defaultRenderTimeoutMs,
|
|
169
|
-
tap: options.tap,
|
|
170
143
|
}
|
|
171
144
|
),
|
|
172
145
|
});
|
|
@@ -175,59 +148,12 @@ export function createRenderFlight(
|
|
|
175
148
|
const stream = web(model, {
|
|
176
149
|
onError: options.onError,
|
|
177
150
|
signal: options.signal,
|
|
178
|
-
|
|
179
|
-
identifierPrefix: options.identifierPrefix,
|
|
151
|
+
filterStackFrame: isAppStackFrame,
|
|
180
152
|
});
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
kind: 'web',
|
|
184
|
-
stream: options.tap ? tapWebFlight(stream, options.tap, timeoutMs) : stream,
|
|
185
|
-
};
|
|
153
|
+
return { kind: 'web', stream };
|
|
186
154
|
};
|
|
187
155
|
}
|
|
188
156
|
|
|
189
|
-
/**
|
|
190
|
-
* Pass a Web Flight stream through unchanged, showing each chunk to `tap`,
|
|
191
|
-
* and its end — whether it finished, failed, or was cancelled.
|
|
192
|
-
*/
|
|
193
|
-
function tapWebFlight(
|
|
194
|
-
source: ReadableStream<Uint8Array>,
|
|
195
|
-
tap: FlightTap,
|
|
196
|
-
timeoutMs: number | undefined
|
|
197
|
-
): ReadableStream<Uint8Array> {
|
|
198
|
-
const reader = source.getReader();
|
|
199
|
-
// The wrapper reads upstream, so its reads are guarded like every stream
|
|
200
|
-
// read (design/02 §"Always Timeout-Guard Stream Reads"): one deadline for
|
|
201
|
-
// the whole render, after which the upstream is cancelled.
|
|
202
|
-
const deadline = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
|
|
203
|
-
return new ReadableStream<Uint8Array>({
|
|
204
|
-
async pull(controller) {
|
|
205
|
-
try {
|
|
206
|
-
const read = reader.read();
|
|
207
|
-
const result =
|
|
208
|
-
deadline === undefined
|
|
209
|
-
? await read
|
|
210
|
-
: await withTimeout(read, Math.max(0, deadline - Date.now()), 'Flight render');
|
|
211
|
-
if (result.done) {
|
|
212
|
-
tap.end();
|
|
213
|
-
controller.close();
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
tap.observe(result.value);
|
|
217
|
-
controller.enqueue(result.value);
|
|
218
|
-
} catch (error) {
|
|
219
|
-
tap.end();
|
|
220
|
-
reader.cancel(releaseReason(error)).catch(() => {});
|
|
221
|
-
controller.error(error);
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
cancel(reason) {
|
|
225
|
-
tap.end();
|
|
226
|
-
return reader.cancel(releaseReason(reason));
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
157
|
// ─── Reading ────────────────────────────────────────────────────────────────
|
|
232
158
|
|
|
233
159
|
/** A pull reader over a Flight source, of either kind. */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which stack frames development Flight treats as the app's own.
|
|
3
|
+
*
|
|
4
|
+
* Dev Flight writes debug rows for the async work a server component awaited,
|
|
5
|
+
* awaited values included — but only for awaits made from app code, judged by
|
|
6
|
+
* the render's `filterStackFrame`. React's default counts everything outside
|
|
7
|
+
* `node_modules` as app code. Installed, timber sits in `node_modules`; run
|
|
8
|
+
* from source (this repo, its examples, a linked checkout) its own files would
|
|
9
|
+
* count as app code, and its internal awaits would be written into every dev
|
|
10
|
+
* payload.
|
|
11
|
+
*
|
|
12
|
+
* Next.js passes its own `filterStackFrameDEV` for the same reason; its code
|
|
13
|
+
* is always in `node_modules`, so it filters by source map instead.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The directory of the framework package this module was loaded from — its
|
|
18
|
+
* `src/` or `dist/` parent. Null when the module URL does not show one (a
|
|
19
|
+
* bundled Worker), where the default filter is all there is.
|
|
20
|
+
*/
|
|
21
|
+
function frameworkRoot(moduleUrl: string | undefined): string | null {
|
|
22
|
+
if (!moduleUrl) return null;
|
|
23
|
+
const path = stripFileScheme(moduleUrl);
|
|
24
|
+
const at = Math.max(path.lastIndexOf('/src/'), path.lastIndexOf('/dist/'));
|
|
25
|
+
return at > 0 ? path.slice(0, at + 1) : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function stripFileScheme(url: string): string {
|
|
29
|
+
return url.startsWith('file://') ? decodeURI(url.slice('file://'.length)) : url;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const FRAMEWORK_ROOT = frameworkRoot(import.meta.url);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `filterStackFrame` for every Flight render: React's default (no anonymous,
|
|
36
|
+
* `node:` or `node_modules` frames), and no frames from timber itself.
|
|
37
|
+
*/
|
|
38
|
+
export function isAppStackFrame(url: string): boolean {
|
|
39
|
+
if (url === '' || url.startsWith('node:') || url.includes('node_modules')) return false;
|
|
40
|
+
return FRAMEWORK_ROOT === null || !stripFileScheme(url).startsWith(FRAMEWORK_ROOT);
|
|
41
|
+
}
|
package/src/server/index.ts
CHANGED
|
@@ -8,6 +8,13 @@ export type { AccessContext } from './types.ts';
|
|
|
8
8
|
export type { MiddlewareContext } from './types.ts';
|
|
9
9
|
export type { RouteContext } from './types.ts';
|
|
10
10
|
export type { Metadata, MetadataRoute, MetadataHandler, MetadataResult } from './types.ts';
|
|
11
|
+
export type {
|
|
12
|
+
LayoutOptions,
|
|
13
|
+
PageOptions,
|
|
14
|
+
RoutePrerender,
|
|
15
|
+
SegmentKey,
|
|
16
|
+
SegmentLifetime,
|
|
17
|
+
} from './types.ts';
|
|
11
18
|
|
|
12
19
|
// Request Context — ALS-backed accessors (all sync)
|
|
13
20
|
// Prefer defineSearchParams().get() and getSegmentParams(SEGMENT_PATH) for typed access.
|
|
@@ -73,7 +73,7 @@ export type ParamCombo = CoercedParams;
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Resolve the param combos to capture for a route. Static routes have
|
|
76
|
-
* exactly one combo (the empty record) — `
|
|
76
|
+
* exactly one combo (the empty record) — `pageOptions.prerender`-style
|
|
77
77
|
* components on static pages need no enumerator. Dynamic routes require
|
|
78
78
|
* `generateStaticSegmentParams` (design/44 §generateStaticSegmentParams);
|
|
79
79
|
* without it every request renders live and the wrapper is a no-op.
|
|
@@ -212,6 +212,13 @@ export async function capturePrebuiltPayloads(
|
|
|
212
212
|
// entries awaiting the param-independence decision after all combos.
|
|
213
213
|
const pendingByComponent = new Map<string, { anyParamRead: boolean; entries: PendingEntry[] }>();
|
|
214
214
|
|
|
215
|
+
// Failed renders of components that no call site passes statically
|
|
216
|
+
// readable props to, so they were rendered with `{}` (see propsSets below).
|
|
217
|
+
// Such a render usually fails identically for every param combo — one log
|
|
218
|
+
// line per combo is noise, so the first is logged with a hint and the rest
|
|
219
|
+
// are counted (still recorded in summary.skipped) and reported once.
|
|
220
|
+
const emptyPropsFailures = new Map<string, number>();
|
|
221
|
+
|
|
215
222
|
const skip = (issue: CaptureIssue) => {
|
|
216
223
|
summary.skipped.push(issue);
|
|
217
224
|
log(
|
|
@@ -348,8 +355,8 @@ export async function capturePrebuiltPayloads(
|
|
|
348
355
|
// path (e.g., required prop access) and fail the build for a
|
|
349
356
|
// shape no JSX call site actually uses.
|
|
350
357
|
const capturedProps = options.callSiteProps?.[componentId];
|
|
351
|
-
const
|
|
352
|
-
|
|
358
|
+
const rendersEmptyProps = !capturedProps || capturedProps.length === 0;
|
|
359
|
+
const propsSets: Record<string, unknown>[] = rendersEmptyProps ? [{}] : [...capturedProps];
|
|
353
360
|
|
|
354
361
|
let pending = pendingByComponent.get(componentId);
|
|
355
362
|
if (!pending) {
|
|
@@ -423,6 +430,19 @@ export async function capturePrebuiltPayloads(
|
|
|
423
430
|
if (outcome.failure instanceof BuildTimeContextError) {
|
|
424
431
|
summary.hardErrors.push(issue);
|
|
425
432
|
log(`[timber] BUILD ERROR: ${issue.message}`);
|
|
433
|
+
} else if (rendersEmptyProps) {
|
|
434
|
+
const failures = (emptyPropsFailures.get(componentId) ?? 0) + 1;
|
|
435
|
+
emptyPropsFailures.set(componentId, failures);
|
|
436
|
+
if (failures === 1) {
|
|
437
|
+
skip({
|
|
438
|
+
...issue,
|
|
439
|
+
message:
|
|
440
|
+
`${issue.message} (rendered with empty props: no call site with statically ` +
|
|
441
|
+
`readable props was found — pass literals, not spreads or computed values)`,
|
|
442
|
+
});
|
|
443
|
+
} else {
|
|
444
|
+
summary.skipped.push(issue);
|
|
445
|
+
}
|
|
426
446
|
} else {
|
|
427
447
|
skip(issue);
|
|
428
448
|
}
|
|
@@ -486,6 +506,14 @@ export async function capturePrebuiltPayloads(
|
|
|
486
506
|
}
|
|
487
507
|
}
|
|
488
508
|
|
|
509
|
+
for (const [componentId, failures] of emptyPropsFailures) {
|
|
510
|
+
if (failures < 2) continue;
|
|
511
|
+
log(
|
|
512
|
+
`[timber] cache.component skipped "${componentId}" for ${failures} param combos in all, ` +
|
|
513
|
+
`each rendered with empty props — those requests render live`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
489
517
|
// Emit remaining buffered entries — only param-independent components
|
|
490
518
|
// still have entries here (param-dependent entries were emitted eagerly
|
|
491
519
|
// above, TIM-1179). Collapse to one entry per props set (TIM-1175).
|
|
@@ -20,7 +20,11 @@ import {
|
|
|
20
20
|
type ActionErrorForRender,
|
|
21
21
|
type RequestContextStore,
|
|
22
22
|
} from './als-registry.ts';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
_setGetSearchParamsFn,
|
|
25
|
+
_setGetSegmentParamsFn,
|
|
26
|
+
type SearchParamsReader,
|
|
27
|
+
} from '../shared/als-slots.ts';
|
|
24
28
|
import { appVisibleSearch } from '../shared/rsc-cache-key.ts';
|
|
25
29
|
import {
|
|
26
30
|
mergeSlotParams,
|
|
@@ -29,6 +33,13 @@ import {
|
|
|
29
33
|
} from '../shared/slot-params.ts';
|
|
30
34
|
import { isDebug } from './debug.ts';
|
|
31
35
|
import { runWithReactCacheScope, type ReactCacheScope } from './react-cache-scope.ts';
|
|
36
|
+
import {
|
|
37
|
+
assertSearchParamsRead,
|
|
38
|
+
assertUnscopedRead,
|
|
39
|
+
currentReadScope,
|
|
40
|
+
keyedHeaders,
|
|
41
|
+
scopedParams,
|
|
42
|
+
} from './segment-lifetime/read-rule.ts';
|
|
32
43
|
import type { ReactFormState } from 'react-dom/client';
|
|
33
44
|
|
|
34
45
|
// Re-export the ALS for framework-internal consumers that need direct access.
|
|
@@ -50,8 +61,10 @@ export function getHeaders(): ReadonlyHeaders {
|
|
|
50
61
|
'It can only be used in middleware, access checks, server components, and server actions.'
|
|
51
62
|
);
|
|
52
63
|
}
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
// A 'document' segment may read only the headers in its key — never all of
|
|
65
|
+
// them, which would include the pathname (design/53).
|
|
66
|
+
const scope = currentReadScope();
|
|
67
|
+
return scope ? keyedHeaders(store.headers, scope) : store.headers;
|
|
55
68
|
}
|
|
56
69
|
|
|
57
70
|
/**
|
|
@@ -71,8 +84,12 @@ export function getHeader(name: string): string | undefined {
|
|
|
71
84
|
* Returns the current request's raw URLSearchParams.
|
|
72
85
|
*
|
|
73
86
|
* @internal — not part of the public API. Use `defineSearchParams().get()` instead.
|
|
87
|
+
*
|
|
88
|
+
* @param reader The definition the caller parses through (its fields, codecs
|
|
89
|
+
* and URL keys), checked against a 'document' segment's key. Omitted for a
|
|
90
|
+
* raw read.
|
|
74
91
|
*/
|
|
75
|
-
export function getSearchParams(): URLSearchParams {
|
|
92
|
+
export function getSearchParams(reader?: SearchParamsReader): URLSearchParams {
|
|
76
93
|
const store = requestContextAls.getStore();
|
|
77
94
|
if (!store) {
|
|
78
95
|
throw new Error(
|
|
@@ -80,6 +97,10 @@ export function getSearchParams(): URLSearchParams {
|
|
|
80
97
|
'It can only be used in middleware, access checks, server components, and server actions.'
|
|
81
98
|
);
|
|
82
99
|
}
|
|
100
|
+
// A definition's `.get()` passes what it parses; a 'document' segment may
|
|
101
|
+
// read only fields its key reads the same way, and never the raw params.
|
|
102
|
+
if (reader) assertSearchParamsRead(reader);
|
|
103
|
+
else assertUnscopedRead('the raw search params');
|
|
83
104
|
|
|
84
105
|
return store.searchParams;
|
|
85
106
|
}
|
|
@@ -128,7 +149,8 @@ export function getSegmentParams(segmentPath?: string): CoercedParams {
|
|
|
128
149
|
// client's useSegmentParams() also reads, so the two halves of one
|
|
129
150
|
// documented API cannot drift (TIM-1285).
|
|
130
151
|
const slotResolved = resolveSegmentParams(store.segmentParams, store.slotParams, segmentPath);
|
|
131
|
-
|
|
152
|
+
// Inside a 'document' segment, a param outside its key throws (design/53).
|
|
153
|
+
if (slotResolved !== store.segmentParams) return scopedParams(slotResolved);
|
|
132
154
|
|
|
133
155
|
// Dev-mode validation: warn when the segment path expects dynamic
|
|
134
156
|
// segments that don't exist on the actual matched segment. This catches
|
|
@@ -149,7 +171,7 @@ export function getSegmentParams(segmentPath?: string): CoercedParams {
|
|
|
149
171
|
}
|
|
150
172
|
}
|
|
151
173
|
|
|
152
|
-
return store.segmentParams;
|
|
174
|
+
return scopedParams(store.segmentParams);
|
|
153
175
|
}
|
|
154
176
|
|
|
155
177
|
/**
|
|
@@ -318,6 +340,9 @@ function extractDynamicSegments(route: string): string[] {
|
|
|
318
340
|
*/
|
|
319
341
|
export function getRequestSearchString(): string {
|
|
320
342
|
const store = requestContextAls.getStore();
|
|
343
|
+
// A 'document' segment's redirect cannot carry search params outside its
|
|
344
|
+
// key (design/53): what it redirects to would freeze.
|
|
345
|
+
if (store) assertUnscopedRead('the raw search params');
|
|
321
346
|
return store?.searchString ?? '';
|
|
322
347
|
}
|
|
323
348
|
|