@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
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* SegmentOutlet — the client boundary around one segment: a layout's own
|
|
3
3
|
* chrome, a layout's `children`, a parallel slot, or the page's metadata.
|
|
4
4
|
*
|
|
5
|
-
* The server decides each outlet (server/segment-
|
|
5
|
+
* The server decides each outlet (server/segment-lifetime/outlet-gate.ts):
|
|
6
6
|
*
|
|
7
7
|
* - **Live** — the outlet renders the content it was sent, and once React
|
|
8
|
-
* commits it, records it in the router's outlet content cache beside
|
|
9
|
-
*
|
|
10
|
-
* - **Skip** — the client
|
|
8
|
+
* commits it, records it in the router's outlet content cache — beside its
|
|
9
|
+
* key digest when it is a `'document'` segment.
|
|
10
|
+
* - **Skip** — the client holds this `'document'` segment's content under
|
|
11
|
+
* the skip's key digest; the server did not render it at all. The outlet
|
|
11
12
|
* renders the cached copy, and provides the nested outlets' new decisions
|
|
12
13
|
* to the outlet elements inside that copy (client/outlet-scope-context.ts),
|
|
13
14
|
* so each renders its segment's new decision in place.
|
|
@@ -22,18 +23,14 @@
|
|
|
22
23
|
* what a later skip resolves to (TIM-1423).
|
|
23
24
|
*
|
|
24
25
|
* Security: performance only. The server runs every access.ts regardless, and
|
|
25
|
-
* a skip whose
|
|
26
|
+
* a skip whose digest the client does not hold leaves the SPA rather than show
|
|
26
27
|
* other content. See design/13-security.md §"State tree manipulation".
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
'use client';
|
|
30
31
|
|
|
31
|
-
import { createElement,
|
|
32
|
-
import type {
|
|
33
|
-
CaptureHole,
|
|
34
|
-
OutletDecision,
|
|
35
|
-
OutletDecisionValue,
|
|
36
|
-
} from '../shared/outlet-decision.ts';
|
|
32
|
+
import { createElement, useContext, useLayoutEffect, useMemo, type ReactNode } from 'react';
|
|
33
|
+
import type { OutletDecision } from '../shared/outlet-decision.ts';
|
|
37
34
|
import { OutletContentCacheContext } from './outlet-content-cache.ts';
|
|
38
35
|
import { LIVE_OUTLET_SCOPE, OutletScopeContext, type OutletScope } from './outlet-scope-context.ts';
|
|
39
36
|
import { staleSegmentError } from './stale-segment.ts';
|
|
@@ -41,23 +38,13 @@ import { staleSegmentError } from './stale-segment.ts';
|
|
|
41
38
|
export interface SegmentOutletProps {
|
|
42
39
|
/**
|
|
43
40
|
* The outlet's key: a segment id (`/`, `/(marketing)`), a slot key
|
|
44
|
-
* (`/@sidebar`), a layout's children (`/dashboard/@children`),
|
|
45
|
-
* metadata
|
|
41
|
+
* (`/@sidebar`), a layout's children (`/dashboard/@children`), a
|
|
42
|
+
* `'document'` segment's tree-path key (`/#layout`), or the metadata
|
|
43
|
+
* outlet.
|
|
46
44
|
*/
|
|
47
45
|
segmentPath: string;
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
* a capture render emits, which never reach the client.
|
|
51
|
-
*/
|
|
52
|
-
decision?: OutletDecisionValue | CaptureHole;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function isCaptureHole(value: OutletDecisionValue | CaptureHole): value is CaptureHole {
|
|
56
|
-
return 'captureHole' in value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isThenable(value: OutletDecisionValue): value is PromiseLike<OutletDecision> {
|
|
60
|
-
return typeof (value as PromiseLike<OutletDecision>).then === 'function';
|
|
46
|
+
/** What the server decided for this segment. */
|
|
47
|
+
decision: OutletDecision;
|
|
61
48
|
}
|
|
62
49
|
|
|
63
50
|
export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): ReactNode {
|
|
@@ -66,13 +53,10 @@ export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): Re
|
|
|
66
53
|
|
|
67
54
|
// Inside a skipped segment's cached content this element is from an
|
|
68
55
|
// earlier render; the skip handed down this segment's new decision.
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
// through is a decision the client does not have.
|
|
72
|
-
if (value === undefined || isCaptureHole(value)) throw staleSegmentError(segmentPath);
|
|
73
|
-
const resolved = isThenable(value) ? use(value) : value;
|
|
56
|
+
const resolved = scope.skipped ? scope.decisions.get(segmentPath) : decision;
|
|
57
|
+
if (resolved === undefined) throw staleSegmentError(segmentPath);
|
|
74
58
|
|
|
75
|
-
const cached = resolved.skip ? cache?.lookup(segmentPath, resolved.
|
|
59
|
+
const cached = resolved.skip ? cache?.lookup(segmentPath, resolved.digest) : undefined;
|
|
76
60
|
if (resolved.skip && !cached) throw staleSegmentError(segmentPath);
|
|
77
61
|
const content: ReactNode = resolved.skip ? cached!.content : resolved.children;
|
|
78
62
|
const childScope = useMemo<OutletScope>(
|
|
@@ -83,21 +67,11 @@ export function SegmentOutlet({ segmentPath, decision }: SegmentOutletProps): Re
|
|
|
83
67
|
[resolved]
|
|
84
68
|
);
|
|
85
69
|
|
|
86
|
-
// Commit-time write: live content is recorded once React commits it
|
|
87
|
-
// its hash attached when the server's arrives.
|
|
70
|
+
// Commit-time write: live content is recorded once React commits it.
|
|
88
71
|
useLayoutEffect(() => {
|
|
89
72
|
if (cache === null) return;
|
|
90
|
-
if (resolved.skip)
|
|
91
|
-
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const entry = cache.record(segmentPath, content);
|
|
95
|
-
resolved.hash?.then(
|
|
96
|
-
(hash) => {
|
|
97
|
-
if (hash) cache.attachHash(segmentPath, entry, hash);
|
|
98
|
-
},
|
|
99
|
-
() => {}
|
|
100
|
-
);
|
|
73
|
+
if (resolved.skip) cache.touch(segmentPath, content);
|
|
74
|
+
else cache.record(segmentPath, content, resolved.digest);
|
|
101
75
|
}, [resolved, cache, segmentPath, content]);
|
|
102
76
|
|
|
103
77
|
return createElement(OutletScopeContext.Provider, { value: childScope }, content);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The error a `SegmentOutlet` throws when it cannot render what the server
|
|
3
|
-
* decided — a skip whose content the client no longer holds under that
|
|
3
|
+
* decided — a skip whose content the client no longer holds under that digest,
|
|
4
4
|
* or an outlet inside a skipped segment that received no new decision.
|
|
5
5
|
*
|
|
6
6
|
* Either means the client's record moved on between the request and the
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* evicted). Rendering anything else would show content the server did not
|
|
9
9
|
* produce, so the error passes every boundary to the terminal, which fetches
|
|
10
10
|
* the page again (`recoverFromStaleSegment`) — and leaves the SPA only if
|
|
11
|
-
* that misses too (design/
|
|
11
|
+
* that misses too (design/53-segment-lifetime.md §"Skipping").
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export interface StaleSegmentDigest {
|
package/src/config-types.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* and internal plugin-context.ts can import them without circular deps.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { SegmentLifetime } from './server/types.ts';
|
|
9
|
+
|
|
8
10
|
/** Configuration for client-side JavaScript output. */
|
|
9
11
|
export interface ClientJavascriptConfig {
|
|
10
12
|
/** When true, no client JS bundles are emitted or referenced in HTML. */
|
|
@@ -327,22 +329,28 @@ export interface TimberUserConfig {
|
|
|
327
329
|
*/
|
|
328
330
|
buildDir?: string;
|
|
329
331
|
/**
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* `
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
332
|
+
* The lifetime of every layout that does not declare one, slot layouts
|
|
333
|
+
* included. Pages are unaffected, and a layout's own
|
|
334
|
+
* `layoutOptions.lifetime` wins.
|
|
335
|
+
*
|
|
336
|
+
* `'document'` renders each layout on the document request and skips it on
|
|
337
|
+
* client navigations until its key changes. Every `'document'` rule
|
|
338
|
+
* applies: the default key is every param on the layout's path, and the
|
|
339
|
+
* layout may read only the request inputs in its key. Check three things
|
|
340
|
+
* before turning it on: a layout that reads anything else (a header, a
|
|
341
|
+
* cookie outside its key) throws; a layout that shows data that changes
|
|
342
|
+
* during a visit (a cart badge) keeps the value it had at load; and a layout
|
|
343
|
+
* that hides its children in its body no longer keeps them out of the
|
|
344
|
+
* payload, since a skip never runs it. Declare
|
|
345
|
+
* `layoutOptions = { lifetime: 'request' }` on those, and gate in
|
|
346
|
+
* `access.ts`. Layouts in and below an intercepting directory take no
|
|
347
|
+
* options and stay `'request'`.
|
|
348
|
+
*
|
|
349
|
+
* Default: `'request'`.
|
|
350
|
+
*
|
|
351
|
+
* See design/53-segment-lifetime.md §"App-wide default".
|
|
344
352
|
*/
|
|
345
|
-
|
|
353
|
+
defaultLayoutLifetime?: SegmentLifetime;
|
|
346
354
|
/**
|
|
347
355
|
* Cache behavior configuration.
|
|
348
356
|
*/
|
package/src/config-validation.ts
CHANGED
|
@@ -56,7 +56,7 @@ const KNOWN_CONFIG_KEYS = {
|
|
|
56
56
|
sitemap: true,
|
|
57
57
|
buildDir: true,
|
|
58
58
|
cache: true,
|
|
59
|
-
|
|
59
|
+
defaultLayoutLifetime: true,
|
|
60
60
|
topLoader: true,
|
|
61
61
|
budget: true,
|
|
62
62
|
} satisfies Record<keyof TimberUserConfig, true>;
|
|
@@ -193,6 +193,22 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
// defaultLayoutLifetime — not fatal: every reader treats a value other than
|
|
197
|
+
// 'document' as 'request', the default, which is slower but never wrong
|
|
198
|
+
// (design/53 §"App-wide default").
|
|
199
|
+
if (
|
|
200
|
+
config.defaultLayoutLifetime !== undefined &&
|
|
201
|
+
config.defaultLayoutLifetime !== 'request' &&
|
|
202
|
+
config.defaultLayoutLifetime !== 'document'
|
|
203
|
+
) {
|
|
204
|
+
errors.push({
|
|
205
|
+
field: 'defaultLayoutLifetime',
|
|
206
|
+
message: `Invalid defaultLayoutLifetime value: ${JSON.stringify(config.defaultLayoutLifetime)}.`,
|
|
207
|
+
value: config.defaultLayoutLifetime,
|
|
208
|
+
suggestion: "Use 'request' (the default) or 'document'.",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
196
212
|
// devBrowserLogs
|
|
197
213
|
if (config.devBrowserLogs !== undefined) {
|
|
198
214
|
const valid = ['error', 'warn', 'info', 'none'];
|
|
@@ -88,6 +88,7 @@ export interface CookieDefinition<T> extends ServerOnlyCookieDefinition<T> {
|
|
|
88
88
|
// Schema: fromSchema is a pure function — safe in all environments.
|
|
89
89
|
|
|
90
90
|
import { getCookieJar } from '@timber-js/app/server';
|
|
91
|
+
import { COOKIE_READ_THROUGH } from '../shared/cookie-read-through.ts';
|
|
91
92
|
import {
|
|
92
93
|
useCookie as useRawCookie,
|
|
93
94
|
getCookieValue,
|
|
@@ -184,7 +185,10 @@ export function defineCookie<T, HttpOnly extends boolean = true>(
|
|
|
184
185
|
get(): T {
|
|
185
186
|
const serverJar = tryGetServerCookieJar();
|
|
186
187
|
if (serverJar) {
|
|
187
|
-
|
|
188
|
+
// Through the jar's typed read, naming this codec: a 'document'
|
|
189
|
+
// segment may read a keyed cookie only through its key's definition.
|
|
190
|
+
const readThrough = serverJar[COOKIE_READ_THROUGH];
|
|
191
|
+
return codec.parse(readThrough ? readThrough(name, codec) : serverJar.get(name));
|
|
188
192
|
}
|
|
189
193
|
// Client path
|
|
190
194
|
if (isHttpOnly) {
|
package/src/index.ts
CHANGED
|
@@ -79,6 +79,7 @@ export type { TimberUserConfig } from './config-types.ts';
|
|
|
79
79
|
// root re-export is a convenience for typed metadata route handlers.
|
|
80
80
|
// See design/16-metadata.md §"Metadata Routes".
|
|
81
81
|
export type { Metadata, MetadataRoute, MetadataHandler, MetadataResult } from './server/types.ts';
|
|
82
|
+
export type { LayoutOptions, PageOptions, RoutePrerender } from './server/types.ts';
|
|
82
83
|
|
|
83
84
|
/**
|
|
84
85
|
* Route map interface — augmented by the generated timber-routes.d.ts.
|
|
@@ -592,7 +593,7 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
592
593
|
timberOptimizePackageImports(ctx), // Listed barrels → the modules that define the imported names
|
|
593
594
|
timberClientInServerPackageDeps(), // Dev: a package's inner 'use client' file → its bare path, so the browser pre-bundles it
|
|
594
595
|
timberCacheTransform(ctx),
|
|
595
|
-
timberPrerenderSugar(ctx), //
|
|
596
|
+
timberPrerenderSugar(ctx), // pageOptions/layoutOptions.prerender → cache.component() desugaring
|
|
596
597
|
prebuilt, // cache.component() → __prebuilt() callsite rewrite
|
|
597
598
|
timberStaticBuild(ctx), // Static mode: validate dynamic API usage
|
|
598
599
|
timberContent(ctx),
|
|
@@ -12,7 +12,14 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { PluginContext } from '../plugin-context.ts';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
CallExpressionNode,
|
|
17
|
+
IdentifierNode,
|
|
18
|
+
ImportDeclarationNode,
|
|
19
|
+
MemberExpressionNode,
|
|
20
|
+
PositionedNode,
|
|
21
|
+
ProgramNode,
|
|
22
|
+
} from './callsite-ast.ts';
|
|
16
23
|
|
|
17
24
|
interface JSXElementNode extends PositionedNode {
|
|
18
25
|
type: 'JSXElement';
|
|
@@ -156,18 +163,112 @@ export function extractStaticJsxProps(
|
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
/**
|
|
159
|
-
*
|
|
166
|
+
* Extract static props from the props argument of a compiled JSX call —
|
|
167
|
+
* `_jsx(Embed, { url: "…", imagesFirst: true })`. The automatic runtime
|
|
168
|
+
* puts children in the props object and the key in the third argument, so
|
|
169
|
+
* the same rules as `extractStaticJsxProps` apply: a `children` prop bails
|
|
170
|
+
* (matching the JSX children rule), `key`/`ref` are stripped, and anything
|
|
171
|
+
* non-literal — spreads, computed keys, identifiers, methods — bails to null.
|
|
172
|
+
* A props argument that is not an object literal (`Object.assign(…)`, what
|
|
173
|
+
* compilers emit for spreads) is dynamic too.
|
|
174
|
+
*/
|
|
175
|
+
function extractStaticCallProps(
|
|
176
|
+
node: PositionedNode | undefined
|
|
177
|
+
): Record<string, JsonValue> | null {
|
|
178
|
+
if (node?.type !== 'ObjectExpression') return null;
|
|
179
|
+
const value = tryExtractStaticValue(node);
|
|
180
|
+
if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (Object.hasOwn(value, 'children')) return null;
|
|
184
|
+
delete value.key;
|
|
185
|
+
delete value.ref;
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** The automatic JSX runtime's element factories (react/jsx-runtime, react/jsx-dev-runtime). */
|
|
190
|
+
const JSX_RUNTIME_FACTORIES = new Set(['jsx', 'jsxs', 'jsxDEV']);
|
|
191
|
+
const JSX_RUNTIME_SOURCE = /(^|\/)jsx(-dev)?-runtime$/;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The local names under which this module imports the automatic runtime's
|
|
195
|
+
* factories: `factories` for `import { jsx as _jsx }`, `namespaces` for
|
|
196
|
+
* `import * as runtime`. Calls are matched by these bindings rather than by
|
|
197
|
+
* callee name, so a user function that happens to be called `jsx` is never
|
|
198
|
+
* read as an element.
|
|
199
|
+
*/
|
|
200
|
+
function collectJsxRuntimeBindings(program: ProgramNode): {
|
|
201
|
+
factories: Set<string>;
|
|
202
|
+
namespaces: Set<string>;
|
|
203
|
+
} {
|
|
204
|
+
const factories = new Set<string>();
|
|
205
|
+
const namespaces = new Set<string>();
|
|
206
|
+
for (const stmt of program.body) {
|
|
207
|
+
if (stmt.type !== 'ImportDeclaration') continue;
|
|
208
|
+
const decl = stmt as ImportDeclarationNode;
|
|
209
|
+
if (!JSX_RUNTIME_SOURCE.test(decl.source.value)) continue;
|
|
210
|
+
for (const spec of decl.specifiers) {
|
|
211
|
+
if (spec.type === 'ImportNamespaceSpecifier') namespaces.add(spec.local.name);
|
|
212
|
+
else if (
|
|
213
|
+
spec.type === 'ImportSpecifier' &&
|
|
214
|
+
JSX_RUNTIME_FACTORIES.has(spec.imported?.name ?? '')
|
|
215
|
+
) {
|
|
216
|
+
factories.add(spec.local.name);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { factories, namespaces };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Walk an AST tree and collect element usages of the given binding names,
|
|
160
225
|
* returning the static props for each usage. Returns a map of
|
|
161
226
|
* bindingName → array of static prop objects (or null for dynamic props).
|
|
227
|
+
*
|
|
228
|
+
* Usages are found in both forms an element can take in the code being
|
|
229
|
+
* scanned: JSX syntax (`<Embed url="…" />`, what the transform hook sees in
|
|
230
|
+
* a .tsx module) and compiled automatic-runtime calls
|
|
231
|
+
* (`_jsx(Embed, { url: "…" })`). The second is what MDX compiles to, and
|
|
232
|
+
* what `generateBundle`'s module info holds for every importer — Vite has
|
|
233
|
+
* already compiled the JSX away by then.
|
|
162
234
|
*/
|
|
163
235
|
export function collectJsxUsages(
|
|
164
236
|
program: ProgramNode,
|
|
165
237
|
bindingNames: Set<string>
|
|
166
238
|
): Map<string, Array<Record<string, JsonValue> | null>> {
|
|
167
239
|
const result = new Map<string, Array<Record<string, JsonValue> | null>>();
|
|
240
|
+
const record = (name: string, props: Record<string, JsonValue> | null) => {
|
|
241
|
+
const usages = result.get(name) ?? [];
|
|
242
|
+
usages.push(props);
|
|
243
|
+
result.set(name, usages);
|
|
244
|
+
};
|
|
245
|
+
const runtime = collectJsxRuntimeBindings(program);
|
|
246
|
+
const isJsxFactory = (callee: PositionedNode): boolean => {
|
|
247
|
+
if (callee.type === 'Identifier') return runtime.factories.has((callee as IdentifierNode).name);
|
|
248
|
+
if (callee.type !== 'MemberExpression') return false;
|
|
249
|
+
const member = callee as MemberExpressionNode;
|
|
250
|
+
return (
|
|
251
|
+
!member.computed &&
|
|
252
|
+
member.object.type === 'Identifier' &&
|
|
253
|
+
runtime.namespaces.has((member.object as IdentifierNode).name) &&
|
|
254
|
+
member.property.type === 'Identifier' &&
|
|
255
|
+
JSX_RUNTIME_FACTORIES.has((member.property as IdentifierNode).name)
|
|
256
|
+
);
|
|
257
|
+
};
|
|
168
258
|
const walk = (node: unknown) => {
|
|
169
259
|
if (!node || typeof node !== 'object') return;
|
|
170
260
|
const n = node as PositionedNode;
|
|
261
|
+
if (n.type === 'CallExpression') {
|
|
262
|
+
const call = n as CallExpressionNode;
|
|
263
|
+
const [type, props] = call.arguments;
|
|
264
|
+
if (
|
|
265
|
+
type?.type === 'Identifier' &&
|
|
266
|
+
bindingNames.has((type as IdentifierNode).name) &&
|
|
267
|
+
isJsxFactory(call.callee)
|
|
268
|
+
) {
|
|
269
|
+
record((type as IdentifierNode).name, extractStaticCallProps(props));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
171
272
|
if (n.type === 'JSXElement') {
|
|
172
273
|
const jsx = n as unknown as JSXElementNode;
|
|
173
274
|
const tagName = jsx.openingElement.name;
|
|
@@ -188,10 +289,7 @@ export function collectJsxUsages(
|
|
|
188
289
|
}
|
|
189
290
|
return true;
|
|
190
291
|
});
|
|
191
|
-
|
|
192
|
-
const usages = result.get(name) ?? [];
|
|
193
|
-
usages.push(props);
|
|
194
|
-
result.set(name, usages);
|
|
292
|
+
record(name, hasChildren ? null : extractStaticJsxProps(jsx.openingElement.attributes));
|
|
195
293
|
}
|
|
196
294
|
}
|
|
197
295
|
}
|
package/src/plugins/entries.ts
CHANGED
|
@@ -164,7 +164,9 @@ function generateConfigModule(ctx: PluginContext): string {
|
|
|
164
164
|
// Per-build deployment ID for version skew detection (TIM-446).
|
|
165
165
|
// Null in dev mode — HMR handles code updates without full reloads.
|
|
166
166
|
deploymentId: ctx.deploymentId ?? null,
|
|
167
|
-
|
|
167
|
+
// Read by the RSC entry only: the lifetime of a layout that declares none
|
|
168
|
+
// (design/53 §"App-wide default").
|
|
169
|
+
defaultLayoutLifetime: ctx.config.defaultLayoutLifetime === 'document' ? 'document' : 'request',
|
|
168
170
|
cache: {
|
|
169
171
|
strictKeyDiscipline: ctx.config.cache?.strictKeyDiscipline ?? false,
|
|
170
172
|
},
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* timber-prerender-sugar — Vite plugin that desugars `
|
|
3
|
-
*
|
|
2
|
+
* timber-prerender-sugar — Vite plugin that desugars `prerender` in a page's
|
|
3
|
+
* `pageOptions` (or an ancestor layout's `layoutOptions`) into a
|
|
4
|
+
* `cache.component(...)` wrapper around the page.
|
|
4
5
|
*
|
|
5
6
|
* Design doc: design/45-cache-lifetimes.md §"Route-Level Static" and
|
|
6
|
-
* §"Layout Propagation".
|
|
7
|
+
* §"Layout Propagation"; design/53-segment-lifetime.md §"Route-module options".
|
|
7
8
|
*
|
|
8
|
-
* `
|
|
9
|
+
* `pageOptions = { prerender: true }` on a page is pure sugar: it desugars to
|
|
9
10
|
* wrapping the page's default export in `timber.cache.component(Component,
|
|
10
11
|
* { prerender: true })`. Layout propagation cascades a layout's
|
|
11
|
-
* `
|
|
12
|
+
* `layoutOptions.prerender` to descendant pages via most-specific-wins:
|
|
12
13
|
* walk the segment tree from leaf to root, first explicit value wins.
|
|
13
14
|
*
|
|
14
15
|
* Layout declarations are propagation policy only. Layouts receive the real
|
|
@@ -24,7 +25,8 @@ import MagicString from 'magic-string';
|
|
|
24
25
|
import type { Plugin } from 'vite';
|
|
25
26
|
import type { PluginContext } from '../plugin-context.ts';
|
|
26
27
|
import type { SegmentNode, RouteFile } from '../routing/types.ts';
|
|
27
|
-
import {
|
|
28
|
+
import type { RoutePrerender } from '../server/types.ts';
|
|
29
|
+
import { readRouteOptions } from '../routing/route-options.ts';
|
|
28
30
|
|
|
29
31
|
interface AstNode {
|
|
30
32
|
type: string;
|
|
@@ -40,25 +42,25 @@ interface AstNode {
|
|
|
40
42
|
* Walk the segment tree and resolve the effective prerender value for
|
|
41
43
|
* every page. Returns a map from page file path to resolved value.
|
|
42
44
|
*
|
|
43
|
-
* **Pages:** walk from leaf toward root; first explicit `
|
|
45
|
+
* **Pages:** walk from leaf toward root; first explicit `prerender` option
|
|
44
46
|
* wins (page > nearest layout > ... > root layout). If none, dynamic.
|
|
45
47
|
*
|
|
46
48
|
* **Layouts:** declarations propagate to descendant pages but layouts are not
|
|
47
49
|
* included in the result. Their real React-element `children` preserve secure
|
|
48
50
|
* containment and deliberately make child-independent layout caching invalid.
|
|
49
51
|
*/
|
|
50
|
-
export function resolvePagePrerender(root: SegmentNode): Map<string,
|
|
51
|
-
const result = new Map<string,
|
|
52
|
+
export function resolvePagePrerender(root: SegmentNode): Map<string, RoutePrerender> {
|
|
53
|
+
const result = new Map<string, RoutePrerender>();
|
|
52
54
|
|
|
53
|
-
function walk(node: SegmentNode, ancestorStack:
|
|
55
|
+
function walk(node: SegmentNode, ancestorStack: RoutePrerender[]) {
|
|
54
56
|
if (node.segmentType === 'intercepting' || node.segmentType === 'private') return;
|
|
55
57
|
|
|
56
58
|
// Check this segment's layout for a prerender export
|
|
57
|
-
const layoutValue = node.layout ?
|
|
59
|
+
const layoutValue = node.layout ? declaredPrerender(node.layout, 'layout') : undefined;
|
|
58
60
|
const stack = layoutValue !== undefined ? [layoutValue, ...ancestorStack] : ancestorStack;
|
|
59
61
|
|
|
60
62
|
if (node.page) {
|
|
61
|
-
const pageValue =
|
|
63
|
+
const pageValue = declaredPrerender(node.page, 'page');
|
|
62
64
|
// Page's own value takes priority; otherwise use nearest ancestor
|
|
63
65
|
const resolved = pageValue !== undefined ? pageValue : stack[0];
|
|
64
66
|
// Only record if the resolved value is truthy (prerender: true or options object)
|
|
@@ -76,10 +78,23 @@ export function resolvePagePrerender(root: SegmentNode): Map<string, PrerenderEx
|
|
|
76
78
|
return result;
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The `prerender` a file declares. An options object with any problem reads
|
|
83
|
+
* as `false`, not as "undeclared": the build fails on it anyway, but in dev
|
|
84
|
+
* the error overlay is up while this plugin keeps re-resolving from disk, and
|
|
85
|
+
* "undeclared" would let the page inherit an ancestor's `prerender: true` —
|
|
86
|
+
* caching a page whose author wrote `prerender: false` next to a typo.
|
|
87
|
+
* Dynamic is the safe default: it can only be slower, never stale.
|
|
88
|
+
*/
|
|
89
|
+
function declaredPrerender(file: RouteFile, kind: 'layout' | 'page'): RoutePrerender | undefined {
|
|
90
|
+
const { options, problems } = readRouteOptions(file.filePath, kind);
|
|
91
|
+
return problems.length > 0 ? false : options?.prerender;
|
|
92
|
+
}
|
|
93
|
+
|
|
79
94
|
/**
|
|
80
95
|
* Build the `cache.component` options source text from a resolved value.
|
|
81
96
|
*/
|
|
82
|
-
function buildOptionsSource(value:
|
|
97
|
+
function buildOptionsSource(value: RoutePrerender): string {
|
|
83
98
|
if (value === true) return '{ prerender: true }';
|
|
84
99
|
if (typeof value === 'object') {
|
|
85
100
|
const parts = ['prerender: true'];
|
|
@@ -162,7 +177,7 @@ function findDefaultExport(program: { body: AstNode[] }, source: string): Defaul
|
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
export function timberPrerenderSugar(ctx: PluginContext): Plugin {
|
|
165
|
-
let resolvedPages: Map<string,
|
|
180
|
+
let resolvedPages: Map<string, RoutePrerender> | null = null;
|
|
166
181
|
/** The route tree `resolvedPages` was computed from — a rescan replaces it. */
|
|
167
182
|
let resolvedFor: PluginContext['routeTree'] | undefined;
|
|
168
183
|
|
|
@@ -182,18 +197,18 @@ export function timberPrerenderSugar(ctx: PluginContext): Plugin {
|
|
|
182
197
|
|
|
183
198
|
/**
|
|
184
199
|
* Dev: an edit can change the resolved prerender value of pages other
|
|
185
|
-
* than the edited file — a layout's `
|
|
200
|
+
* than the edited file — a layout's `layoutOptions.prerender` cascades to
|
|
186
201
|
* every descendant page. Vite re-transforms only the edited file, so
|
|
187
202
|
* the pages whose value changed are added to the update; through the
|
|
188
203
|
* RSC entry's HMR boundary they re-execute with the new wrapping
|
|
189
204
|
* (TIM-1588: dev caches prerendered output, so a stale wrapping is
|
|
190
|
-
* observable — a page switched to `prerender
|
|
205
|
+
* observable — a page switched to `prerender: false` would still be
|
|
191
206
|
* captured under the build rules). Runs after timber-routing's watcher
|
|
192
207
|
* rescan, which happens synchronously when the event fires.
|
|
193
208
|
*/
|
|
194
209
|
hotUpdate({ file, modules }) {
|
|
195
210
|
if (this.environment.name !== 'rsc' || !file.startsWith(ctx.appDir)) return;
|
|
196
|
-
const previous = resolvedPages ?? new Map<string,
|
|
211
|
+
const previous = resolvedPages ?? new Map<string, RoutePrerender>();
|
|
197
212
|
// Values are read from disk (mtime-checked), so resolve again even
|
|
198
213
|
// when the tree object is unchanged.
|
|
199
214
|
resolvedPages = null;
|
|
@@ -240,7 +255,8 @@ export function timberPrerenderSugar(ctx: PluginContext): Plugin {
|
|
|
240
255
|
if (value) {
|
|
241
256
|
const relPath = id.replace(ctx.root + '/', '');
|
|
242
257
|
console.warn(
|
|
243
|
-
`[timber] ${relPath}:
|
|
258
|
+
`[timber] ${relPath}: prerender applies to this page (from its pageOptions or an ` +
|
|
259
|
+
`ancestor layout's layoutOptions) but the default ` +
|
|
244
260
|
`export cannot be wrapped (re-export or missing). The prerender declaration ` +
|
|
245
261
|
`will be ignored for this file.`
|
|
246
262
|
);
|
package/src/plugins/routing.ts
CHANGED
|
@@ -114,7 +114,9 @@ export function timberRouting(ctx: PluginContext): Plugin {
|
|
|
114
114
|
// an unattributed React error on an unrelated page (TIM-1329). Never
|
|
115
115
|
// deduplicated against `warnedFiles`: an error must not be downgraded to
|
|
116
116
|
// silence by an earlier scan in the same process.
|
|
117
|
-
const conventionWarnings = lintConventions(tree, ctx.appDir
|
|
117
|
+
const conventionWarnings = lintConventions(tree, ctx.appDir, {
|
|
118
|
+
defaultLayoutLifetime: ctx.config.defaultLayoutLifetime,
|
|
119
|
+
});
|
|
118
120
|
const fatal = conventionWarnings.filter((w) => w.level === 'error');
|
|
119
121
|
if (fatal.length > 0) {
|
|
120
122
|
throw new Error(formatConventionWarnings(fatal, { color: false }));
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
* empty pages, confusing React errors).
|
|
10
10
|
*
|
|
11
11
|
* A check emits `level: 'error'` only when the misconfiguration is *proven*
|
|
12
|
-
* (never inferred from an absence the analysis cannot see through) and
|
|
13
|
-
* to rendering
|
|
12
|
+
* (never inferred from an absence the analysis cannot see through) and either
|
|
13
|
+
* fatal to rendering or a declaration that provably does nothing — a CSRF
|
|
14
|
+
* exemption the gate never reads, a route option the build cannot read, a
|
|
15
|
+
* middleware.ts in a slot. The developer believes the declaration is in
|
|
16
|
+
* effect, so silence would ship the wrong behavior. `plugins/routing.ts` turns those into a thrown build error,
|
|
14
17
|
* so a false positive there refuses a working app — see
|
|
15
18
|
* `classifyClientBoundaryFile` for how that bar is met.
|
|
16
19
|
*
|
|
@@ -28,7 +31,10 @@ import {
|
|
|
28
31
|
fileHasDirective,
|
|
29
32
|
fileHasStarExport,
|
|
30
33
|
getCsrfExport,
|
|
34
|
+
isScriptExtension,
|
|
31
35
|
} from './export-detect.ts';
|
|
36
|
+
import { checkRouteOptions } from './route-options-lint.ts';
|
|
37
|
+
import type { SegmentLifetime } from '../server/types.ts';
|
|
32
38
|
|
|
33
39
|
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
34
40
|
|
|
@@ -50,7 +56,12 @@ export interface ConventionWarning {
|
|
|
50
56
|
*
|
|
51
57
|
* Returns an array of warnings. Empty array means everything looks good.
|
|
52
58
|
*/
|
|
53
|
-
export function lintConventions(
|
|
59
|
+
export function lintConventions(
|
|
60
|
+
tree: RouteTree,
|
|
61
|
+
appDir: string,
|
|
62
|
+
/** The config the checks depend on, as the build resolved it. */
|
|
63
|
+
config: { defaultLayoutLifetime: SegmentLifetime | undefined }
|
|
64
|
+
): ConventionWarning[] {
|
|
54
65
|
const warnings: ConventionWarning[] = [];
|
|
55
66
|
|
|
56
67
|
// Check 1: app/ directory exists (caller should check before scanning,
|
|
@@ -90,6 +101,10 @@ export function lintConventions(tree: RouteTree, appDir: string): ConventionWarn
|
|
|
90
101
|
if (tree.proxy) checkCsrfExport(tree.proxy, 'proxy.ts', warnings);
|
|
91
102
|
if (tree.globalError) checkCsrfExport(tree.globalError, 'global-error', warnings);
|
|
92
103
|
|
|
104
|
+
// Check 10: layoutOptions / pageOptions the build cannot read, unknown
|
|
105
|
+
// keys, and the removed floating exports (design/53)
|
|
106
|
+
checkRouteOptions(tree.root, warnings, 'main', config.defaultLayoutLifetime ?? 'request');
|
|
107
|
+
|
|
93
108
|
return warnings;
|
|
94
109
|
}
|
|
95
110
|
|
|
@@ -361,10 +376,6 @@ function checkDefaultExports(node: SegmentNode, warnings: ConventionWarning[]):
|
|
|
361
376
|
}
|
|
362
377
|
}
|
|
363
378
|
|
|
364
|
-
function isScriptExtension(ext: string): boolean {
|
|
365
|
-
return ext === 'tsx' || ext === 'ts' || ext === 'jsx' || ext === 'js';
|
|
366
|
-
}
|
|
367
|
-
|
|
368
379
|
function checkFileDefaultExport(
|
|
369
380
|
filePath: string,
|
|
370
381
|
fileType: string,
|