@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
|
@@ -33,10 +33,8 @@ export interface SegmentInfo {
|
|
|
33
33
|
/**
|
|
34
34
|
* The client's `X-Timber-State-Tree` request header.
|
|
35
35
|
*
|
|
36
|
-
* `
|
|
37
|
-
*
|
|
38
|
-
* `clientSegmentCache` (design/52-segment-hash-dedupe.md). `treePaths` is
|
|
39
|
-
* not caching: it describes the *shape* of the tree currently on screen, so
|
|
36
|
+
* `documents` are the key digests of the `'document'` segments the client
|
|
37
|
+
* holds. `treePaths` is not caching: it describes the *shape* of the tree currently on screen, so
|
|
40
38
|
* the server can answer "does the rendered route pass through the segment
|
|
41
39
|
* that owns this intercepting slot?" without re-deriving it from the address
|
|
42
40
|
* bar, which stops being the source route the moment a modal is open
|
|
@@ -45,7 +43,11 @@ export interface SegmentInfo {
|
|
|
45
43
|
* Neither is a security input. Every `access.ts` runs regardless.
|
|
46
44
|
*/
|
|
47
45
|
export interface StateTree {
|
|
48
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The key digests of the `'document'` segments the client holds, by outlet
|
|
48
|
+
* path (design/53-segment-lifetime.md). Left out of the `_rsc` cache key.
|
|
49
|
+
*/
|
|
50
|
+
documents?: Record<string, string>;
|
|
49
51
|
treePaths?: string[];
|
|
50
52
|
}
|
|
51
53
|
//# sourceMappingURL=segment-info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment-info.d.ts","sourceRoot":"","sources":["../../src/shared/segment-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED
|
|
1
|
+
{"version":3,"file":"segment-info.d.ts","sourceRoot":"","sources":["../../src/shared/segment-info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;G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IAC/D,QAAQ,IAAI,MAAM,CAAC;CACpB;AAUD;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,kBAAkB,CAwD5C"}
|
|
@@ -194,6 +194,35 @@ The full metadata type — see [Metadata & SEO](/docs/metadata-and-fonts) for us
|
|
|
194
194
|
|
|
195
195
|
Type for metadata route files (sitemap, robots, etc.).
|
|
196
196
|
|
|
197
|
+
### `LayoutOptions` / `PageOptions`
|
|
198
|
+
|
|
199
|
+
Options for a layout or page. Export one object per file, named for the file kind:
|
|
200
|
+
|
|
201
|
+
```ts title="app/docs/layout.tsx"
|
|
202
|
+
import type { LayoutOptions } from '@timber-js/app/server';
|
|
203
|
+
|
|
204
|
+
export const layoutOptions = {
|
|
205
|
+
deferSuspenseFor: 200,
|
|
206
|
+
} satisfies LayoutOptions;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```ts title="app/docs/[slug]/page.tsx"
|
|
210
|
+
import type { PageOptions } from '@timber-js/app/server';
|
|
211
|
+
|
|
212
|
+
export const pageOptions = {
|
|
213
|
+
prerender: { ttl: 3600, tags: ['docs'] },
|
|
214
|
+
} satisfies PageOptions;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
| Option | Applies to | Meaning |
|
|
218
|
+
| ------------------ | ------------ | ----------------------------------------------------------------------------------------------------------- |
|
|
219
|
+
| `lifetime` | layout, page | `'request'` (default) or `'document'`: render once per loaded document and skip on client navigations until `key` changes ([Document lifetime](/docs/client-navigation#document-lifetime)). Slots included. |
|
|
220
|
+
| `key` | layout, page | What a `'document'` segment depends on: `segmentParams` (names on its path; default all of them), `searchParams` (a definition), `cookies` (definitions), `headers` (header names). |
|
|
221
|
+
| `prerender` | layout, page | Render at build time ([route-level sugar](/docs/api-cache#route-level-sugar)). Layouts cascade it to pages, slot pages included. |
|
|
222
|
+
| `deferSuspenseFor` | layout, page | Hold the SSR stream up to N ms ([`deferSuspenseFor`](/docs/streaming#defersuspensefor)). Main route only, not parallel slots. |
|
|
223
|
+
|
|
224
|
+
The build reads these objects from source, so write them as one object literal with literal values. The exception is `key.searchParams` and `key.cookies`, which name the definitions you import. A `key.segmentParams` name that is not on the segment's path, or a `key` on a segment that is not `'document'`, fails the build. A layout that declares no `lifetime` takes the app's [`defaultLayoutLifetime`](/docs/client-navigation#making-layouts-document-by-default), so under a `'document'` default it may declare `key` alone. A spread, a computed key, a value from a variable, an unknown key, or `layoutOptions` in a page (or the reverse) fails the build with a message naming the fix. An option where it would do nothing also fails the build: in a `'use client'` file, in `default.tsx`, on an intercepting route, or `deferSuspenseFor` in a parallel slot. `satisfies` adds editor completion and type errors; the build checks the object either way. MDX pages are not checked, and `prerender` has no effect in them. `metadata`, `searchParams` and `segmentParams` stay separate exports.
|
|
225
|
+
|
|
197
226
|
## Tracing
|
|
198
227
|
|
|
199
228
|
### `getTraceId()`
|
|
@@ -141,17 +141,23 @@ Slot props are excluded from the cache key — two instances with the same data
|
|
|
141
141
|
|
|
142
142
|
### Route-Level Sugar
|
|
143
143
|
|
|
144
|
-
For "this whole route is static,"
|
|
144
|
+
For "this whole route is static," set `prerender` in a page's `pageOptions` or a layout's `layoutOptions` instead of wrapping manually:
|
|
145
145
|
|
|
146
146
|
```ts title="Fully static route"
|
|
147
|
-
|
|
147
|
+
import type { PageOptions } from '@timber-js/app/server';
|
|
148
|
+
|
|
149
|
+
export const pageOptions = { prerender: true } satisfies PageOptions;
|
|
148
150
|
```
|
|
149
151
|
|
|
150
152
|
```ts title="Route-level ISR"
|
|
151
|
-
|
|
153
|
+
import type { PageOptions } from '@timber-js/app/server';
|
|
154
|
+
|
|
155
|
+
export const pageOptions = {
|
|
156
|
+
prerender: { ttl: 3600, tags: ['docs'] },
|
|
157
|
+
} satisfies PageOptions;
|
|
152
158
|
```
|
|
153
159
|
|
|
154
|
-
This desugars to wrapping the page's default export in `cache.component(...)`.
|
|
160
|
+
This desugars to wrapping the page's default export in `cache.component(...)`. A layout's `prerender` cascades to descendant pages unless overridden (most-specific-wins); the layout itself is never cached. The build reads the value from source, so it must be a literal: see [`PageOptions`](/docs/api-server#layoutoptions--pageoptions).
|
|
155
161
|
|
|
156
162
|
### Nesting
|
|
157
163
|
|
|
@@ -32,6 +32,7 @@ interface TimberUserConfig {
|
|
|
32
32
|
optimizePackageImports?: string[];
|
|
33
33
|
slowRequestMs?: number;
|
|
34
34
|
renderTimeoutMs?: number;
|
|
35
|
+
defaultLayoutLifetime?: 'request' | 'document';
|
|
35
36
|
devBrowserLogs?: 'error' | 'warn' | 'info' | 'none';
|
|
36
37
|
dev?: {
|
|
37
38
|
slowPhaseMs?: number;
|
|
@@ -210,6 +211,10 @@ Slow request threshold in milliseconds. Requests exceeding this emit a warning v
|
|
|
210
211
|
|
|
211
212
|
Render timeout in milliseconds. If an SSR render or RSC stream read does not complete within this duration, the render is aborted and the connection is closed. Protects against hung fetches and Suspense components that never resolve. Setting `0` uses a 120-second safety ceiling rather than disabling the timeout entirely. The same value bounds how long concurrent `timber.cache` callers wait on a shared fill, and how long static generation waits for each page.
|
|
212
213
|
|
|
214
|
+
### `defaultLayoutLifetime`
|
|
215
|
+
|
|
216
|
+
The lifetime of every layout that does not declare one, slot layouts included. `'request'` (the default) or `'document'`. Pages are unaffected, and a layout's own `layoutOptions.lifetime` wins. Under `'document'`, a layout that reads a request input outside its key throws, one that shows data that changes during a visit keeps its load-time value, and one that hides its children in its body no longer keeps them out of the payload. Layouts in and below an intercepting directory stay `'request'`. See [Making layouts `'document'` by default](/docs/client-navigation#making-layouts-document-by-default).
|
|
217
|
+
|
|
213
218
|
### `devBrowserLogs`
|
|
214
219
|
|
|
215
220
|
- **Type:** `'error' | 'warn' | 'info' | 'none'`
|
|
@@ -106,14 +106,16 @@ Sometimes Suspense content resolves fast enough that you'd rather wait for it th
|
|
|
106
106
|
```tsx title="app/products/[id]/page.tsx" use="schema"
|
|
107
107
|
import { Suspense } from 'react';
|
|
108
108
|
import { SEGMENT_PATH } from './$segment';
|
|
109
|
-
import { deny, getSegmentParams } from '@timber-js/app/server';
|
|
109
|
+
import { deny, getSegmentParams, type PageOptions } from '@timber-js/app/server';
|
|
110
110
|
|
|
111
111
|
declare function getProduct(id: string): Promise<{ id: string; name: string } | null>;
|
|
112
112
|
declare function ProductHeader(props: { product: { name: string } }): React.ReactElement;
|
|
113
113
|
declare function ReviewsSkeleton(): React.ReactElement;
|
|
114
114
|
declare function ProductReviews(props: { productId: string }): React.ReactElement;
|
|
115
115
|
|
|
116
|
-
export const
|
|
116
|
+
export const pageOptions = {
|
|
117
|
+
deferSuspenseFor: 200, // milliseconds
|
|
118
|
+
} satisfies PageOptions;
|
|
117
119
|
|
|
118
120
|
export default async function ProductPage() {
|
|
119
121
|
const { id } = getSegmentParams(SEGMENT_PATH);
|
|
@@ -133,6 +135,8 @@ export default async function ProductPage() {
|
|
|
133
135
|
|
|
134
136
|
If reviews resolve within 200ms, they render inline — no fallback shown. If they take longer, the fallback flushes and reviews stream in when ready.
|
|
135
137
|
|
|
138
|
+
`deferSuspenseFor` works in a layout's `layoutOptions` too. The route holds for the longest value across its layouts and page. Parallel slots don't set the hold: `deferSuspenseFor` in a slot is a build error.
|
|
139
|
+
|
|
136
140
|
## Signal Promotion
|
|
137
141
|
|
|
138
142
|
When `deny()` or `redirect()` fires inside a `<Suspense>` boundary:
|
|
@@ -237,23 +237,29 @@ export default async function BlogPost() {
|
|
|
237
237
|
|
|
238
238
|
### Route-Level Shorthand
|
|
239
239
|
|
|
240
|
-
For fully static routes,
|
|
240
|
+
For fully static routes, set `prerender` in `pageOptions` instead of wrapping the component manually:
|
|
241
241
|
|
|
242
242
|
```ts title="app/about/page.tsx"
|
|
243
|
-
|
|
243
|
+
import type { PageOptions } from '@timber-js/app/server';
|
|
244
|
+
|
|
245
|
+
export const pageOptions = { prerender: true } satisfies PageOptions;
|
|
244
246
|
```
|
|
245
247
|
|
|
246
248
|
This desugars to `cache.component(...)` around the page's default export. For dynamic routes (`[slug]`), pair it with `generateStaticSegmentParams` so the build knows which params to prerender:
|
|
247
249
|
|
|
248
250
|
```ts title="app/docs/[slug]/page.tsx"
|
|
249
|
-
|
|
251
|
+
import type { PageOptions } from '@timber-js/app/server';
|
|
252
|
+
|
|
253
|
+
export const pageOptions = {
|
|
254
|
+
prerender: { ttl: 3600, tags: ['docs'] },
|
|
255
|
+
} satisfies PageOptions;
|
|
250
256
|
|
|
251
257
|
export async function generateStaticSegmentParams() {
|
|
252
258
|
return allDocs.map((d) => ({ slug: d.slug }));
|
|
253
259
|
}
|
|
254
260
|
```
|
|
255
261
|
|
|
256
|
-
|
|
262
|
+
`layoutOptions.prerender` on a layout cascades to descendant pages unless a closer layout or page overrides it.
|
|
257
263
|
|
|
258
264
|
### In Development
|
|
259
265
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.242",
|
|
4
4
|
"description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
package/src/cli-check.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { scanRoutes } from './routing/scanner.ts';
|
|
|
37
37
|
import { lintConventions, formatConventionWarnings } from './routing/convention-lint.ts';
|
|
38
38
|
import { writeRouteCodegen, CODEGEN_OUTPUT, ENV_DTS_FILENAME } from './routing/codegen-write.ts';
|
|
39
39
|
import { resolveTimberContext, type ResolveViteConfig } from './cli-context.ts';
|
|
40
|
+
import type { SegmentLifetime } from './server/types.ts';
|
|
40
41
|
|
|
41
42
|
/** The npm package that provides tsgo. Named in the missing-tool message. */
|
|
42
43
|
const TSGO_PACKAGE = '@typescript/native-preview';
|
|
@@ -142,6 +143,8 @@ export interface RouteInputs {
|
|
|
142
143
|
root: string;
|
|
143
144
|
appDir: string;
|
|
144
145
|
pageExtensions: string[] | undefined;
|
|
146
|
+
/** Read by the route-options lint (design/53 §"App-wide default"). */
|
|
147
|
+
defaultLayoutLifetime: SegmentLifetime | undefined;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
/**
|
|
@@ -157,7 +160,12 @@ export async function resolveRouteInputs(
|
|
|
157
160
|
deps: CheckDeps = {}
|
|
158
161
|
): Promise<RouteInputs> {
|
|
159
162
|
const ctx = await resolveTimberContext('check', options.viteConfigFile, deps.resolveViteConfig);
|
|
160
|
-
return {
|
|
163
|
+
return {
|
|
164
|
+
root: ctx.root,
|
|
165
|
+
appDir: ctx.appDir,
|
|
166
|
+
pageExtensions: ctx.config.pageExtensions,
|
|
167
|
+
defaultLayoutLifetime: ctx.config.defaultLayoutLifetime,
|
|
168
|
+
};
|
|
161
169
|
}
|
|
162
170
|
|
|
163
171
|
/**
|
|
@@ -176,11 +184,11 @@ export async function checkRoutes(
|
|
|
176
184
|
deps: CheckDeps = {}
|
|
177
185
|
): Promise<RouteInputs> {
|
|
178
186
|
const inputs = await resolveRouteInputs(options, deps);
|
|
179
|
-
const { root, appDir, pageExtensions } = inputs;
|
|
187
|
+
const { root, appDir, pageExtensions, defaultLayoutLifetime } = inputs;
|
|
180
188
|
|
|
181
189
|
const tree = scanRoutes(appDir, { pageExtensions });
|
|
182
190
|
|
|
183
|
-
const warnings = lintConventions(tree, appDir);
|
|
191
|
+
const warnings = lintConventions(tree, appDir, { defaultLayoutLifetime });
|
|
184
192
|
const fatal = warnings.filter((w) => w.level === 'error');
|
|
185
193
|
if (fatal.length > 0) {
|
|
186
194
|
throw new Error(formatConventionWarnings(fatal, { color: false }));
|
|
@@ -103,8 +103,6 @@ function bootstrap(runtimeConfig: typeof config, formState: ReactFormState | nul
|
|
|
103
103
|
});
|
|
104
104
|
const { router, navApiController, hydrate } = createTimberRouter({
|
|
105
105
|
render: reactRoot.render,
|
|
106
|
-
clientSegmentCache:
|
|
107
|
-
((runtimeConfig as Record<string, unknown>).clientSegmentCache as boolean) ?? false,
|
|
108
106
|
});
|
|
109
107
|
|
|
110
108
|
// Step 4: Make the page current and hydrate (no root without a payload)
|
|
@@ -36,7 +36,6 @@ export interface RouterInitOptions {
|
|
|
36
36
|
* around `root.render`, and the `publish` it takes runs on React's commit.
|
|
37
37
|
*/
|
|
38
38
|
render: NavigationRender;
|
|
39
|
-
clientSegmentCache?: boolean;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
export interface RouterInitResult {
|
|
@@ -82,12 +81,12 @@ export function createTimberRouter(options: RouterInitOptions): RouterInitResult
|
|
|
82
81
|
*/
|
|
83
82
|
let displayed: { tree: unknown; params: ParamsSource; navState: NavigationState } | null = null;
|
|
84
83
|
|
|
85
|
-
// The
|
|
84
|
+
// The 'document' content the client has committed, by segment path and digest.
|
|
86
85
|
// Owned here so there is exactly one per router (never a module or
|
|
87
86
|
// globalThis singleton — SegmentOutlet also executes during SSR, where a
|
|
88
87
|
// process-wide record would be shared across requests). Read by
|
|
89
88
|
// SegmentOutlet in render, written by it at commit only, and read by the
|
|
90
|
-
// router for the
|
|
89
|
+
// router for the digests it advertises. See client/outlet-content-cache.ts.
|
|
91
90
|
const outletContentCache = new OutletContentCache();
|
|
92
91
|
|
|
93
92
|
/**
|
|
@@ -237,7 +236,6 @@ export function createTimberRouter(options: RouterInitOptions): RouterInitResult
|
|
|
237
236
|
};
|
|
238
237
|
|
|
239
238
|
const deps: RouterDeps = {
|
|
240
|
-
clientSegmentCache: options?.clientSegmentCache ?? false,
|
|
241
239
|
outletContentCache,
|
|
242
240
|
fetch: (url, init) => window.fetch(url, init),
|
|
243
241
|
pushState: (data, unused, url) => {
|
|
@@ -154,7 +154,7 @@ let _pendingRedirectLocation: string | null = null;
|
|
|
154
154
|
* Resets a boundary showing an error once a new navigation reaches it.
|
|
155
155
|
*
|
|
156
156
|
* Live content resets the boundary through new `children`. Content a skip
|
|
157
|
-
* reuses (design/
|
|
157
|
+
* reuses (design/53) is the same element tree as before — the boundary sees
|
|
158
158
|
* the same `children` and would keep showing the old error, never mounting
|
|
159
159
|
* the nested outlet that holds the new decision. What a skip does change is
|
|
160
160
|
* the outlet scope: a new one for every decision. A scope other than the one
|
|
@@ -141,13 +141,11 @@ export function deriveNavigationState(url: string): NavigationState {
|
|
|
141
141
|
export function createNavigationCommitter(deps: {
|
|
142
142
|
segmentCache: SegmentCache;
|
|
143
143
|
historyStack: HistoryStack;
|
|
144
|
-
/** Read at call time — the router's `clientSegmentCache` opt-in. */
|
|
145
|
-
clientSegmentCache: () => boolean | undefined;
|
|
146
144
|
/**
|
|
147
|
-
* The
|
|
148
|
-
* (`OutletContentCache.
|
|
145
|
+
* The key digests of the `'document'` segments the client holds content
|
|
146
|
+
* for (`OutletContentCache.documents()`). Empty outside a browser router.
|
|
149
147
|
*/
|
|
150
|
-
|
|
148
|
+
outletDocuments: () => Record<string, string>;
|
|
151
149
|
}): NavigationCommitter {
|
|
152
150
|
const { segmentCache, historyStack } = deps;
|
|
153
151
|
|
|
@@ -164,10 +162,9 @@ export function createNavigationCommitter(deps: {
|
|
|
164
162
|
/**
|
|
165
163
|
* The X-Timber-State-Tree to send with the next RSC request.
|
|
166
164
|
*
|
|
167
|
-
* Two different things travel on one header. `
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* `treePaths` is how the server learns which route is actually mounted,
|
|
165
|
+
* Two different things travel on one header. `documents` are the key
|
|
166
|
+
* digests of 'document' segments (design/53), sent whenever the client
|
|
167
|
+
* holds one. `treePaths` is how the server learns which route is actually mounted,
|
|
171
168
|
* which stops being derivable from the address bar as soon as a modal is
|
|
172
169
|
* open — so it crosses regardless (TIM-1282). Undefined when there is
|
|
173
170
|
* nothing to say, so a no-op header never enters the `_rsc` cache key.
|
|
@@ -180,11 +177,9 @@ export function createNavigationCommitter(deps: {
|
|
|
180
177
|
const tree: StateTree = {};
|
|
181
178
|
const treePaths = segmentCache.treePaths();
|
|
182
179
|
if (treePaths.length > 0) tree.treePaths = treePaths;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
return tree.treePaths || tree.hashes ? tree : undefined;
|
|
180
|
+
const documents = deps.outletDocuments();
|
|
181
|
+
if (Object.keys(documents).length > 0) tree.documents = documents;
|
|
182
|
+
return tree.treePaths || tree.documents ? tree : undefined;
|
|
188
183
|
},
|
|
189
184
|
|
|
190
185
|
/**
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The router-owned record of
|
|
3
|
-
* segment path and the
|
|
2
|
+
* The router-owned record of `'document'` segment content the client has
|
|
3
|
+
* *committed* (design/53-segment-lifetime.md), by segment path and the key
|
|
4
|
+
* digest it rendered under.
|
|
4
5
|
*
|
|
5
|
-
* A skipped outlet renders the content it holds under the skip's
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* A skipped outlet renders the content it holds under the skip's digest, so
|
|
7
|
+
* an outlet looks up `(path, digest)`, never "whatever was last at this
|
|
8
|
+
* path". A stored payload replayed later, or a prefetch consumed after the
|
|
9
|
+
* tree moved on, therefore either finds exactly the content the server
|
|
10
|
+
* matched or finds nothing — never a newer or older copy. Only `'document'`
|
|
11
|
+
* content is recorded: nothing else is ever skipped.
|
|
11
12
|
*
|
|
12
13
|
* Ownership and write discipline (TIM-1423):
|
|
13
14
|
*
|
|
@@ -18,10 +19,6 @@
|
|
|
18
19
|
* - **Written only at commit.** `SegmentOutlet` records from a layout effect,
|
|
19
20
|
* never during render, so a render React discards — a superseded
|
|
20
21
|
* transition, a Suspense retry — records nothing.
|
|
21
|
-
* - **A hash attaches to its own entry.** The hash arrives after the content
|
|
22
|
-
* (it is computed from the rows that carried it), so the effect records the
|
|
23
|
-
* content first and attaches the hash to that entry when it resolves. An
|
|
24
|
-
* entry without a hash is never advertised.
|
|
25
22
|
* - **`null` outside a router.** SSR renders no provider; the server never
|
|
26
23
|
* sends a skip to a document request, and layout effects do not run there.
|
|
27
24
|
*
|
|
@@ -35,7 +32,8 @@ import { createGlobalContext } from './global-context.ts';
|
|
|
35
32
|
|
|
36
33
|
interface Entry {
|
|
37
34
|
content: ReactNode;
|
|
38
|
-
|
|
35
|
+
/** The key digest the content rendered under. */
|
|
36
|
+
digest: string;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
/**
|
|
@@ -47,20 +45,23 @@ const ENTRIES_PER_PATH = 3;
|
|
|
47
45
|
|
|
48
46
|
/**
|
|
49
47
|
* Paths kept, least recently committed evicted first. Bounds the memory the
|
|
50
|
-
* cache pins (each entry holds a rendered subtree) and the `
|
|
51
|
-
* router sends on every navigation, which must stay well inside a
|
|
52
|
-
* header limits — the server ignores a map of more than 512 entries.
|
|
48
|
+
* cache pins (each entry holds a rendered subtree) and the `documents` map
|
|
49
|
+
* the router sends on every navigation, which must stay well inside a
|
|
50
|
+
* server's header limits — the server ignores a map of more than 512 entries.
|
|
53
51
|
*/
|
|
54
52
|
const MAX_PATHS = 64;
|
|
55
53
|
|
|
56
54
|
export class OutletContentCache {
|
|
57
55
|
private readonly byPath = new Map<string, Entry[]>();
|
|
58
56
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Record content an outlet committed. Only a `'document'` segment's
|
|
59
|
+
* content, which carries the key digest it rendered under, is kept.
|
|
60
|
+
*/
|
|
61
|
+
record(segmentPath: string, content: ReactNode, digest: string | undefined): void {
|
|
62
|
+
if (digest === undefined) return;
|
|
61
63
|
const entries = this.byPath.get(segmentPath) ?? [];
|
|
62
|
-
|
|
63
|
-
entries.unshift(entry);
|
|
64
|
+
entries.unshift({ content, digest });
|
|
64
65
|
if (entries.length > ENTRIES_PER_PATH) entries.length = ENTRIES_PER_PATH;
|
|
65
66
|
// Re-inserted, so the Map's order is least recently committed first.
|
|
66
67
|
this.byPath.delete(segmentPath);
|
|
@@ -69,45 +70,38 @@ export class OutletContentCache {
|
|
|
69
70
|
if (this.byPath.size <= MAX_PATHS) break;
|
|
70
71
|
this.byPath.delete(path);
|
|
71
72
|
}
|
|
72
|
-
return entry;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Attach the server's hash for a recorded entry, if it is still held. */
|
|
76
|
-
attachHash(segmentPath: string, entry: Entry, hash: string): void {
|
|
77
|
-
const entries = this.byPath.get(segmentPath);
|
|
78
|
-
if (!entries?.includes(entry)) return;
|
|
79
|
-
// An identical earlier version is now redundant — keep the newest.
|
|
80
|
-
const duplicate = entries.findIndex((e) => e !== entry && e.hash === hash);
|
|
81
|
-
if (duplicate !== -1) entries.splice(duplicate, 1);
|
|
82
|
-
entry.hash = hash;
|
|
83
73
|
}
|
|
84
74
|
|
|
85
|
-
/** The content committed under `
|
|
86
|
-
lookup(segmentPath: string,
|
|
87
|
-
return this.byPath.get(segmentPath)?.find((e) => e.
|
|
75
|
+
/** The content committed under `digest` at `segmentPath`, if held. */
|
|
76
|
+
lookup(segmentPath: string, digest: string): { content: ReactNode } | undefined {
|
|
77
|
+
return this.byPath.get(segmentPath)?.find((e) => e.digest === digest);
|
|
88
78
|
}
|
|
89
79
|
|
|
90
80
|
/**
|
|
91
|
-
* What to advertise in `X-Timber-State-Tree`: per path, the
|
|
92
|
-
* most recently committed content
|
|
93
|
-
*
|
|
81
|
+
* What to advertise as `documents` in `X-Timber-State-Tree`: per path, the
|
|
82
|
+
* key digest of the most recently committed content. Kept out of the
|
|
83
|
+
* `_rsc` key.
|
|
94
84
|
*/
|
|
95
|
-
|
|
85
|
+
documents(): Record<string, string> {
|
|
96
86
|
const out: Record<string, string> = {};
|
|
97
87
|
for (const [path, entries] of this.byPath) {
|
|
98
88
|
const latest = entries[0];
|
|
99
|
-
if (latest
|
|
89
|
+
if (latest) out[path] = latest.digest;
|
|
100
90
|
}
|
|
101
91
|
return out;
|
|
102
92
|
}
|
|
103
93
|
|
|
104
94
|
/**
|
|
105
|
-
* A skip committed
|
|
106
|
-
*
|
|
95
|
+
* A skip committed the held `content` at `segmentPath`: it is on screen
|
|
96
|
+
* again, so it becomes the entry advertised for the path (a back navigation
|
|
97
|
+
* that skipped to an older version must not keep advertising the newer one
|
|
98
|
+
* it left), and the path moves to the back of the eviction order.
|
|
107
99
|
*/
|
|
108
|
-
touch(segmentPath: string): void {
|
|
100
|
+
touch(segmentPath: string, content: ReactNode): void {
|
|
109
101
|
const entries = this.byPath.get(segmentPath);
|
|
110
102
|
if (!entries) return;
|
|
103
|
+
const used = entries.findIndex((e) => e.content === content);
|
|
104
|
+
if (used > 0) entries.unshift(...entries.splice(used, 1));
|
|
111
105
|
this.byPath.delete(segmentPath);
|
|
112
106
|
this.byPath.set(segmentPath, entries);
|
|
113
107
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* A skipped outlet renders its cached content, and that content still holds
|
|
6
6
|
* the nested `SegmentOutlet` elements from when it was committed — with
|
|
7
|
-
* their old decisions. The skip carries the new ones (`
|
|
7
|
+
* their old decisions. The skip carries the new ones (`DocumentSkip.outlets`)
|
|
8
8
|
* and provides them here, so each old outlet element renders its segment's
|
|
9
9
|
* new decision in place: same element type, same position, so React keeps
|
|
10
10
|
* every component's state below it.
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* segment was sent or skipped.
|
|
15
15
|
*
|
|
16
16
|
* Singleton across bundler-duplicated chunks via `createGlobalContext`.
|
|
17
|
-
* See design/
|
|
17
|
+
* See design/53-segment-lifetime.md §"Skipping".
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
'use client';
|
|
21
21
|
|
|
22
|
-
import type {
|
|
22
|
+
import type { OutletDecision } from '../shared/outlet-decision.ts';
|
|
23
23
|
import { createGlobalContext } from './global-context.ts';
|
|
24
24
|
|
|
25
25
|
export interface OutletScope {
|
|
@@ -28,12 +28,12 @@ export interface OutletScope {
|
|
|
28
28
|
* entry in `decisions` would render a stale decision, so it refuses to.
|
|
29
29
|
*/
|
|
30
30
|
skipped: boolean;
|
|
31
|
-
decisions: ReadonlyMap<string,
|
|
31
|
+
decisions: ReadonlyMap<string, OutletDecision>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const LIVE_OUTLET_SCOPE: OutletScope = Object.freeze({
|
|
35
35
|
skipped: false,
|
|
36
|
-
decisions: new Map<string,
|
|
36
|
+
decisions: new Map<string, OutletDecision>(),
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
export const OutletScopeContext = createGlobalContext<OutletScope>(
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* to be there and it has to be alone: a segment the server skipped renders the
|
|
20
20
|
* content the client cached for it, which carries no provider of its own, so a
|
|
21
21
|
* provider *inside* the payload would never reach a reader in a skipped layout
|
|
22
|
-
* (TIM-1297, design/
|
|
22
|
+
* (TIM-1297, design/53-segment-lifetime.md).
|
|
23
23
|
*
|
|
24
24
|
* Ordering still holds without a bootstrap contract, for the same reason it
|
|
25
25
|
* did when the provider was in the tree: a provider renders before its own
|
|
@@ -154,20 +154,9 @@ export interface RouterDeps {
|
|
|
154
154
|
scrollToHash?: (hash: string) => boolean;
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* It does NOT gate the `treePaths` half of X-Timber-State-Tree. Those
|
|
162
|
-
* describe the tree currently mounted, and interception scoping needs them
|
|
163
|
-
* to open a modal on top of a modal — a routing behaviour, not a caching
|
|
164
|
-
* optimization, so it must not depend on a performance opt-in (TIM-1282).
|
|
165
|
-
*/
|
|
166
|
-
clientSegmentCache?: boolean;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The router's record of committed outlet content and its hashes — the
|
|
170
|
-
* source of the hashes the router advertises. Absent outside a browser.
|
|
157
|
+
* The router's record of committed `'document'` content and its key
|
|
158
|
+
* digests — the source of the digests the router advertises. Absent
|
|
159
|
+
* outside a browser.
|
|
171
160
|
*/
|
|
172
161
|
outletContentCache?: OutletContentCache;
|
|
173
162
|
}
|
package/src/client/router.ts
CHANGED
|
@@ -55,8 +55,7 @@ export function createRouter(deps: RouterDeps): RouterInstance {
|
|
|
55
55
|
const { prepareNavigation, currentStateTree, committedSegmentInfo } = createNavigationCommitter({
|
|
56
56
|
segmentCache,
|
|
57
57
|
historyStack,
|
|
58
|
-
|
|
59
|
-
outletHashes: () => deps.outletContentCache?.hashes() ?? {},
|
|
58
|
+
outletDocuments: () => deps.outletContentCache?.documents() ?? {},
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
// Ownership of the router: who is navigating, whose fetch may be cut, and
|
package/src/client/rsc-fetch.ts
CHANGED
|
@@ -481,7 +481,7 @@ export async function fetchRscPayload(
|
|
|
481
481
|
// Accept headers, so the route URL would return HTML.
|
|
482
482
|
const staticTarget = staticMode ? toStaticRscUrl(url) : null;
|
|
483
483
|
const fetchTarget = staticTarget ? staticTarget.url : url;
|
|
484
|
-
// Static hosts resolve neither
|
|
484
|
+
// Static hosts resolve neither key digests nor intercepting routes,
|
|
485
485
|
// so neither the state tree nor the source URL is sent — and neither may
|
|
486
486
|
// fragment the cache key of a file that does not vary on them.
|
|
487
487
|
const headers = staticMode
|
|
@@ -35,8 +35,8 @@ export interface PrefetchResult {
|
|
|
35
35
|
* interception scoping (TIM-1282).
|
|
36
36
|
*
|
|
37
37
|
* Content reuse is not decided here. The outlet content cache holds what the
|
|
38
|
-
* client can reuse, keyed by
|
|
39
|
-
* design/
|
|
38
|
+
* client can reuse, keyed by key digest (client/outlet-content-cache.ts,
|
|
39
|
+
* design/53-segment-lifetime.md).
|
|
40
40
|
*
|
|
41
41
|
* Written only by a navigation's commit (`navigation-commit.ts`), so a
|
|
42
42
|
* superseded navigation never describes the mounted tree (TIM-1301).
|