@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.223
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/agent-skill.md +21 -5
- package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
- package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
- package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
- package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
- package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
- package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
- package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
- package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
- package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
- package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
- package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
- package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
- package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
- package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
- package/dist/_chunks/chains-CwOr3Myj.js +1 -0
- package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
- package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
- package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
- package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
- package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
- package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
- package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
- package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
- package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
- package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
- package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
- package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
- package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
- package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
- package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-C61GWpGg.js} +369 -55
- package/dist/_chunks/dev-server-C61GWpGg.js.map +1 -0
- package/dist/_chunks/dev-server-CBvvM7Lr.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
- package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
- package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
- package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
- package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
- package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
- package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
- package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
- package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
- package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
- package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
- package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
- package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
- package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
- package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
- package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
- package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
- package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
- package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
- package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
- package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
- package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
- package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
- package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
- package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
- package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
- package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
- package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
- package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
- package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
- package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
- package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
- package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
- package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
- package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
- package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
- package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
- package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
- package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
- package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
- package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
- package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
- package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
- package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
- package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
- package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
- package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +10 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -3
- package/dist/adapters/cloudflare-kv-cache.js +3 -4
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +6 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -1
- package/dist/adapters/nitro-preview.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +94 -57
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/crawl-entry.js +7 -9
- package/dist/analyze/crawl-entry.js.map +1 -1
- package/dist/analyze/graph-command.d.ts.map +1 -1
- package/dist/analyze/graph-command.js +19 -105
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/key-discipline.d.ts +61 -0
- package/dist/cache/key-discipline.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +1 -2
- package/dist/cache/stores/memory.js +2 -3
- package/dist/cache/stores/redis.js +1 -2
- package/dist/cache/stores/vercel.js +1 -2
- package/dist/cache/timber-cache.d.ts +5 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js +1 -2
- package/dist/cdn/fastly-purge.js +1 -2
- package/dist/cdn/index.js +2 -3
- package/dist/cdn/workers-cache-purge.js +3 -5
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-dev-status.d.ts +75 -0
- package/dist/cli-dev-status.d.ts.map +1 -0
- package/dist/cli-init.d.ts +72 -0
- package/dist/cli-init.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -54
- package/dist/cli.js.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +22 -34
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +13 -18
- package/dist/client/internal.js.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +22 -5
- 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 +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.js +266 -229
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +5 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +59 -4
- package/dist/plugins/dev-store-clear.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/search-params/index.js +5 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/access-gate.d.ts +12 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +21 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +8 -1
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -13
- package/dist/server/index.js.map +1 -1
- package/dist/server/interception-gates.d.ts +49 -0
- package/dist/server/interception-gates.d.ts.map +1 -0
- package/dist/server/internal.js +1061 -943
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +17 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +8 -0
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +34 -4
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata-route.d.ts +24 -0
- package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
- package/dist/server/pipeline-metadata.d.ts +3 -2
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +9 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +68 -22
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
- package/dist/server/prebuilt/overlay.d.ts +8 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +13 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +21 -0
- package/dist/server/render-utils.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +14 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +7 -0
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +14 -3
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/signal-identity.d.ts +6 -0
- package/dist/server/signal-identity.d.ts.map +1 -1
- package/dist/server/traced-access.d.ts +18 -0
- package/dist/server/traced-access.d.ts.map +1 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-local.js +1 -2
- package/dist/shims/headers.d.ts +11 -4
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +3 -1
- package/docs/api/32-api-cache.mdx +1 -1
- package/docs/api/34-api-config.mdx +22 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +2 -2
- package/docs/learn/10-caching.mdx +26 -5
- package/llms.txt +1 -1
- package/package.json +12 -12
- package/src/adapters/build-output-helper.ts +26 -4
- package/src/adapters/cloudflare.ts +1 -0
- package/src/adapters/nitro-presets.ts +15 -0
- package/src/adapters/nitro-preview.ts +66 -34
- package/src/adapters/nitro.ts +14 -6
- package/src/analyze/graph-command.ts +25 -133
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +42 -5
- package/src/cli-dev-status.ts +196 -0
- package/src/cli-init.ts +278 -0
- package/src/cli.ts +33 -79
- package/src/client/error-boundary.tsx +19 -2
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +22 -5
- package/src/config-validation.ts +17 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +96 -37
- package/src/plugins/dev-store-clear.ts +105 -7
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +9 -0
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +40 -34
- package/src/server/canonicalize.ts +27 -0
- package/src/server/cookie-context.ts +11 -3
- package/src/server/flight-source-node.ts +5 -2
- package/src/server/flight-source.ts +4 -3
- package/src/server/index.ts +6 -1
- package/src/server/interception-gates.ts +94 -0
- package/src/server/logger.ts +23 -0
- package/src/server/param-coercion.ts +22 -0
- package/src/server/pipeline-interception.ts +64 -4
- package/src/server/pipeline-metadata-route.ts +242 -0
- package/src/server/pipeline-metadata.ts +7 -5
- package/src/server/pipeline-phases.ts +71 -131
- package/src/server/pipeline.ts +20 -2
- package/src/server/prebuilt/dev-store.ts +113 -34
- package/src/server/prebuilt/overlay.ts +18 -0
- package/src/server/prebuilt-runtime.ts +43 -44
- package/src/server/primitives.ts +14 -0
- package/src/server/render-utils.ts +25 -0
- package/src/server/request-context.ts +27 -3
- package/src/server/route-element-builder.ts +15 -2
- package/src/server/route-handler.ts +3 -2
- package/src/server/route-matcher.ts +48 -33
- package/src/server/rsc-entry/api-handler.ts +2 -33
- package/src/server/rsc-entry/index.ts +8 -3
- package/src/server/rsc-entry/rsc-stream.ts +7 -1
- package/src/server/signal-identity.ts +30 -12
- package/src/server/traced-access.ts +50 -0
- package/src/server/tracing.ts +18 -1
- package/src/server/types.ts +5 -4
- package/src/shims/headers.ts +12 -4
- package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
- package/dist/_chunks/chains-B8TCLved.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
- package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
- package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/server/prebuilt/key-discipline.d.ts +0 -52
- package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
- package/src/server/prebuilt/key-discipline.ts +0 -122
|
@@ -26,16 +26,14 @@ import { withSpan } from './tracing.ts';
|
|
|
26
26
|
import { requestCspNonce } from './csp-nonce.ts';
|
|
27
27
|
import { logRenderError } from './logger.ts';
|
|
28
28
|
import { isDenySignal, isRedirectSignal } from './signal-identity.ts';
|
|
29
|
-
import { ParamCoercionError } from './param-coercion.ts';
|
|
30
29
|
import { checkVersionSkew, applyReloadHeaders } from './version-skew.ts';
|
|
30
|
+
import { serveMetadataRoute } from './pipeline-metadata-route.ts';
|
|
31
31
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from './pipeline-
|
|
36
|
-
import {
|
|
37
|
-
import { resolveInterceptedRoute } from './pipeline-interception.ts';
|
|
38
|
-
import { isApiRouteChain } from './route-matcher.ts';
|
|
32
|
+
interceptedMiddlewareChain,
|
|
33
|
+
resolveInterceptedRoute,
|
|
34
|
+
runWithRouteParams,
|
|
35
|
+
} from './pipeline-interception.ts';
|
|
36
|
+
import { isApiRouteChain, matchedSegmentPath } from './route-matcher.ts';
|
|
39
37
|
import {
|
|
40
38
|
applyCookieJar,
|
|
41
39
|
cloneWithMutableHeaders,
|
|
@@ -43,7 +41,11 @@ import {
|
|
|
43
41
|
fireOnRequestError,
|
|
44
42
|
type ProxyResolver,
|
|
45
43
|
} from './pipeline-helpers.ts';
|
|
46
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
coerceSegmentParams,
|
|
46
|
+
ParamCoercionError,
|
|
47
|
+
warnParamCoercionFailure,
|
|
48
|
+
} from './param-coercion.ts';
|
|
47
49
|
import { outcomeToResponse, thrownOutcome, type PhaseOutcome } from './pipeline-outcome.ts';
|
|
48
50
|
import type { InterceptionContext, PipelineConfig, RouteMatch } from './pipeline.ts';
|
|
49
51
|
import type { MetadataHandler, MetadataRoute, MiddlewareContext } from './types.ts';
|
|
@@ -93,23 +95,29 @@ export async function runProxyPhase(
|
|
|
93
95
|
|
|
94
96
|
/**
|
|
95
97
|
* Run the middleware chain phase. If the chain short-circuits with a Response,
|
|
96
|
-
* returns it as a 'response' outcome
|
|
97
|
-
* overlay and
|
|
98
|
+
* returns it as a 'response' outcome, and a thrown signal or error as its
|
|
99
|
+
* outcome. Otherwise applies the request header overlay and returns null: the
|
|
100
|
+
* request continues to the render phase.
|
|
101
|
+
*
|
|
102
|
+
* The chain is the URL's. On an intercepted navigation that is
|
|
103
|
+
* `match.canonical`'s, not the rendered route's: the URL's middleware
|
|
104
|
+
* followed by any only the rendered chain has, run with the URL's params
|
|
105
|
+
* (TIM-1607).
|
|
98
106
|
*/
|
|
99
107
|
export async function runMiddlewarePhase(
|
|
100
108
|
config: PipelineConfig,
|
|
101
109
|
req: Request,
|
|
102
110
|
match: RouteMatch,
|
|
103
|
-
responseHeaders: Headers
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
responseHeaders: Headers
|
|
112
|
+
): Promise<PhaseOutcome | null> {
|
|
113
|
+
const route = match.canonical ?? match;
|
|
106
114
|
const detailed = config.serverTiming === 'detailed';
|
|
107
115
|
const requestHeaderOverlay = new Headers();
|
|
108
116
|
const ctx: MiddlewareContext = {
|
|
109
117
|
req,
|
|
110
118
|
requestHeaders: requestHeaderOverlay,
|
|
111
119
|
headers: responseHeaders,
|
|
112
|
-
segmentParams:
|
|
120
|
+
segmentParams: route.segmentParams,
|
|
113
121
|
// Lazy: reading it is the opt-in that makes the render nonce its scripts.
|
|
114
122
|
get nonce() {
|
|
115
123
|
return requestCspNonce();
|
|
@@ -133,7 +141,8 @@ export async function runMiddlewarePhase(
|
|
|
133
141
|
};
|
|
134
142
|
|
|
135
143
|
try {
|
|
136
|
-
const
|
|
144
|
+
const runChain = () => runMiddlewareChain(route.middlewareChain, ctx);
|
|
145
|
+
const chainFn = match.canonical ? () => runWithRouteParams(route, runChain) : runChain;
|
|
137
146
|
// Enable cookie mutation during middleware (design/29-cookies.md §"Context Tracking")
|
|
138
147
|
const middlewareResponse = await (async () => {
|
|
139
148
|
setMutableCookieContext(true);
|
|
@@ -151,8 +160,7 @@ export async function runMiddlewarePhase(
|
|
|
151
160
|
// Middleware chain completed without short-circuiting — apply any
|
|
152
161
|
// injected request headers so getHeaders() returns them downstream.
|
|
153
162
|
applyRequestHeaderOverlay(requestHeaderOverlay);
|
|
154
|
-
|
|
155
|
-
return runRenderPhase(config, req, match, responseHeaders, renderContext);
|
|
163
|
+
return null;
|
|
156
164
|
} catch (error) {
|
|
157
165
|
return thrownOutcome('middleware', error);
|
|
158
166
|
}
|
|
@@ -247,84 +255,12 @@ export async function handleRequest(
|
|
|
247
255
|
}
|
|
248
256
|
|
|
249
257
|
// Stage 1b: Metadata route matching — runs before regular route matching.
|
|
250
|
-
//
|
|
258
|
+
// Files below the root run their segments' coercion, middleware.ts and
|
|
259
|
+
// access.ts; root files are the public crawler surface and skip them.
|
|
251
260
|
// See design/16-metadata.md §"Pipeline Integration"
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
try {
|
|
256
|
-
// Static metadata files (.xml, .txt, .png, .ico, etc.) are served
|
|
257
|
-
// directly from disk. Dynamic metadata routes (.ts, .tsx) export a
|
|
258
|
-
// handler function that generates the response.
|
|
259
|
-
if (metaMatch.isStatic) {
|
|
260
|
-
return await serveStaticMetadataFile(metaMatch);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
setSegmentParams(metaMatch.segmentParams);
|
|
264
|
-
const mod = await loadModule<{ default?: MetadataHandler }>(metaMatch.file);
|
|
265
|
-
if (typeof mod.default !== 'function') {
|
|
266
|
-
if (isDebug()) {
|
|
267
|
-
console.warn(
|
|
268
|
-
`[timber] Metadata route ${metaMatch.file} does not export a default function — responding with 500\n` +
|
|
269
|
-
` Metadata routes must export a default function that returns the metadata content.`
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
return new Response('Metadata route must export a default function', { status: 500 });
|
|
273
|
-
}
|
|
274
|
-
const handlerResult = await mod.default();
|
|
275
|
-
// If the handler returns a Response, normalize headers so the
|
|
276
|
-
// outer Server-Timing writer can append without hitting an
|
|
277
|
-
// immutable header bag (e.g. user returns Response.redirect()).
|
|
278
|
-
// No default Cache-Control here: the handler runs in the request
|
|
279
|
-
// context and may vary on cookies or headers, so a public default
|
|
280
|
-
// could serve one user's response to another (#1064).
|
|
281
|
-
if (handlerResult instanceof Response) {
|
|
282
|
-
return cloneWithMutableHeaders(handlerResult);
|
|
283
|
-
}
|
|
284
|
-
// Otherwise, serialize based on content type. The type discriminator
|
|
285
|
-
// here is the metadata route's declared content type (from the file
|
|
286
|
-
// convention), not the shape of `handlerResult` — TS can't narrow the
|
|
287
|
-
// `MetadataResult` union on that, so we assert against the expected
|
|
288
|
-
// shape at each branch.
|
|
289
|
-
const contentType = metaMatch.contentType;
|
|
290
|
-
let body: string;
|
|
291
|
-
if (typeof handlerResult === 'string') {
|
|
292
|
-
body = handlerResult;
|
|
293
|
-
} else if (contentType === 'application/xml') {
|
|
294
|
-
body = serializeSitemap(handlerResult as MetadataRoute.Sitemap);
|
|
295
|
-
} else if (contentType === 'application/manifest+json') {
|
|
296
|
-
body = JSON.stringify(handlerResult, null, 2);
|
|
297
|
-
} else {
|
|
298
|
-
body = String(handlerResult);
|
|
299
|
-
}
|
|
300
|
-
return new Response(body, {
|
|
301
|
-
status: 200,
|
|
302
|
-
headers: {
|
|
303
|
-
'Content-Type': `${contentType}; charset=utf-8`,
|
|
304
|
-
'Cache-Control': METADATA_CACHE_CONTROL,
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
} catch (error) {
|
|
308
|
-
// Control-flow signals from the metadata handler (e.g. a sitemap that
|
|
309
|
-
// calls deny(404) for an unknown tenant, or a dynamic icon that
|
|
310
|
-
// redirects to a CDN-hosted asset) translate to proper HTTP responses
|
|
311
|
-
// instead of being logged as 500s.
|
|
312
|
-
if (isRedirectSignal(error)) {
|
|
313
|
-
return new Response(null, {
|
|
314
|
-
status: error.status,
|
|
315
|
-
headers: { Location: error.location },
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
if (isDenySignal(error)) {
|
|
319
|
-
return new Response(null, { status: error.status });
|
|
320
|
-
}
|
|
321
|
-
logRenderError({ method, path, error });
|
|
322
|
-
await fireOnRequestError(error, req, 'route');
|
|
323
|
-
if (config.onPipelineError && error instanceof Error)
|
|
324
|
-
config.onPipelineError(error, 'metadata-route');
|
|
325
|
-
return new Response(null, { status: 500 });
|
|
326
|
-
}
|
|
327
|
-
}
|
|
261
|
+
const metaMatch = config.matchMetadataRoute?.(canonicalPathname);
|
|
262
|
+
if (metaMatch) {
|
|
263
|
+
return serveMetadataRoute(config, req, method, path, canonicalPathname, metaMatch);
|
|
328
264
|
}
|
|
329
265
|
|
|
330
266
|
// Stage 1b.2: Auto-generated sitemap — serves /sitemap.xml and /sitemap/N.xml
|
|
@@ -392,7 +328,13 @@ export async function handleRequest(
|
|
|
392
328
|
try {
|
|
393
329
|
// Stage 2: Route matching, then 2a: intercepting route resolution.
|
|
394
330
|
match = config.matchRoute(canonicalPathname);
|
|
395
|
-
|
|
331
|
+
let canonical: RouteMatch | undefined;
|
|
332
|
+
({ match, interception, canonical } = resolveInterceptedRoute(
|
|
333
|
+
config,
|
|
334
|
+
req,
|
|
335
|
+
canonicalPathname,
|
|
336
|
+
match
|
|
337
|
+
));
|
|
396
338
|
|
|
397
339
|
if (!match) {
|
|
398
340
|
// Dev-time diagnostic: log the unmatched pathname so developers can
|
|
@@ -430,22 +372,24 @@ export async function handleRequest(
|
|
|
430
372
|
// Coerce raw string params through the app/schema.ts codecs.
|
|
431
373
|
// Coercion failure → 404
|
|
432
374
|
// (middleware never runs). See design/07-routing.md §"Where Coercion Runs"
|
|
375
|
+
//
|
|
376
|
+
// An intercepted navigation coerces the URL's own params too: its gates
|
|
377
|
+
// read them, and a value its codecs reject 404s exactly as a direct
|
|
378
|
+
// navigation to the URL would.
|
|
433
379
|
try {
|
|
434
380
|
match = { ...match, segmentParams: await coerceSegmentParams(match) };
|
|
381
|
+
if (canonical) {
|
|
382
|
+
canonical = {
|
|
383
|
+
...canonical,
|
|
384
|
+
segmentParams: await coerceSegmentParams(canonical),
|
|
385
|
+
middlewareChain: interceptedMiddlewareChain(canonical, match),
|
|
386
|
+
};
|
|
387
|
+
match = { ...match, canonical };
|
|
388
|
+
}
|
|
435
389
|
} catch (error) {
|
|
436
390
|
if (error instanceof ParamCoercionError) {
|
|
437
|
-
// Dev-time diagnostic:
|
|
438
|
-
|
|
439
|
-
if (isDebug()) {
|
|
440
|
-
const segmentChain = match.segments.map((s) => s.segmentName || '/').join(' → ');
|
|
441
|
-
console.warn(
|
|
442
|
-
`[timber] Param coercion failed for ${method} ${canonicalPathname} — responding with 404\n` +
|
|
443
|
-
` Matched segments: ${segmentChain}\n` +
|
|
444
|
-
` Error: ${error.message}\n` +
|
|
445
|
-
` This usually means a codec in app/schema.ts rejected the URL value.\n` +
|
|
446
|
-
` Check the codec for the bracket key of the segment named above.`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
391
|
+
// Dev-time diagnostic: silent coercion 404s are brutal to debug.
|
|
392
|
+
warnParamCoercionFailure(method, canonicalPathname, match.segments, error);
|
|
449
393
|
// For API routes (route.ts), return a bare 404 — not an HTML page.
|
|
450
394
|
// API consumers expect JSON/empty responses, not rendered HTML.
|
|
451
395
|
if (isApiRouteChain(match.segments)) {
|
|
@@ -465,13 +409,7 @@ export async function handleRequest(
|
|
|
465
409
|
setSegmentParams(match.segmentParams);
|
|
466
410
|
|
|
467
411
|
// Store the matched segment path for dev-mode validation in getSegmentParams().
|
|
468
|
-
|
|
469
|
-
const segmentPath =
|
|
470
|
-
match.segments
|
|
471
|
-
.map((s) => s.segmentName)
|
|
472
|
-
.filter(Boolean)
|
|
473
|
-
.join('/') || '/';
|
|
474
|
-
setMatchedSegmentPath(segmentPath.startsWith('/') ? segmentPath : `/${segmentPath}`);
|
|
412
|
+
setMatchedSegmentPath(matchedSegmentPath(match.segments));
|
|
475
413
|
} catch (error) {
|
|
476
414
|
return outcomeToResponse(config, thrownOutcome('setup', error), {
|
|
477
415
|
req,
|
|
@@ -482,22 +420,24 @@ export async function handleRequest(
|
|
|
482
420
|
});
|
|
483
421
|
}
|
|
484
422
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
423
|
+
// Middleware answers for the URL: on an intercepted navigation, a
|
|
424
|
+
// short-circuit or signal is the URL's answer, resolved against its own
|
|
425
|
+
// chain and rendered with its own params — a deny page's layouts read them
|
|
426
|
+
// and its payload publishes them — exactly as a navigation the
|
|
427
|
+
// interception did not apply to.
|
|
428
|
+
const outcomeContext = { req, method, path, responseHeaders };
|
|
429
|
+
const route = match.canonical ?? match;
|
|
430
|
+
if (route.middlewareChain.length > 0) {
|
|
431
|
+
const stopped = await runMiddlewarePhase(config, req, match, responseHeaders);
|
|
432
|
+
if (stopped) {
|
|
433
|
+
const answer = () => outcomeToResponse(config, stopped, { ...outcomeContext, match: route });
|
|
434
|
+
return match.canonical ? runWithRouteParams(route, answer) : answer();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
495
437
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
path,
|
|
500
|
-
responseHeaders,
|
|
501
|
-
match,
|
|
438
|
+
const outcome = await runRenderPhase(config, req, match, responseHeaders, {
|
|
439
|
+
canonicalPathname,
|
|
440
|
+
interception,
|
|
502
441
|
});
|
|
442
|
+
return outcomeToResponse(config, outcome, { ...outcomeContext, match });
|
|
503
443
|
}
|
package/src/server/pipeline.ts
CHANGED
|
@@ -74,6 +74,18 @@ export interface RouteMatch {
|
|
|
74
74
|
rawSegmentParams: Record<string, string | string[]>;
|
|
75
75
|
/** Middleware chain from the segment tree, ordered root-to-leaf. */
|
|
76
76
|
middlewareChain: MiddlewareFn[];
|
|
77
|
+
/**
|
|
78
|
+
* The URL's own route, with coerced params, when this match renders an
|
|
79
|
+
* interception of it (either shape). Set by the pipeline only.
|
|
80
|
+
*
|
|
81
|
+
* The rendered chain is a different route, and nothing on it was written
|
|
82
|
+
* to protect this URL. So the URL's `middleware.ts` chain runs before
|
|
83
|
+
* render, and its `access.ts` files render as gates in this tree — those
|
|
84
|
+
* of segments the two chains do not share, placed around the deepest
|
|
85
|
+
* shared segment's layout (TIM-1607, design/07-routing.md §"Intercepting
|
|
86
|
+
* Routes"). A match with `canonical` set never nests another.
|
|
87
|
+
*/
|
|
88
|
+
canonical?: RouteMatch;
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
/** Function that matches a canonical pathname to a route. */
|
|
@@ -153,6 +165,12 @@ export interface PipelineConfig {
|
|
|
153
165
|
stripTrailingSlash?: boolean;
|
|
154
166
|
/** Slow request threshold in ms. Requests exceeding this emit a warning. 0 to disable. Default: 3000. */
|
|
155
167
|
slowRequestMs?: number;
|
|
168
|
+
/**
|
|
169
|
+
* The resolved `renderTimeoutMs`: the deadline for reading a dynamic
|
|
170
|
+
* metadata route's Response body before it is answered. Defaults to
|
|
171
|
+
* `DEFAULT_RENDER_TIMEOUT_MS` for direct callers.
|
|
172
|
+
*/
|
|
173
|
+
renderTimeoutMs?: number;
|
|
156
174
|
/**
|
|
157
175
|
* Interception rewrites — conditional routes for the modal pattern.
|
|
158
176
|
* Generated at build time from intercepting route directories.
|
|
@@ -529,8 +547,8 @@ export function createPipeline(config: PipelineConfig): (req: Request) => Promis
|
|
|
529
547
|
|
|
530
548
|
// Append Server-Timing header based on configured mode.
|
|
531
549
|
// Header mutability is guaranteed by the producer-side clone
|
|
532
|
-
// in `outcomeToResponse` and the
|
|
533
|
-
// user-handler
|
|
550
|
+
// in `outcomeToResponse`, `serveMetadataRoute`, and the
|
|
551
|
+
// auto-sitemap user-handler clone in `handleRequest`, so we can write
|
|
534
552
|
// directly without a runtime probe. See TIM-866.
|
|
535
553
|
if (serverTiming === 'detailed') {
|
|
536
554
|
// Detailed: per-phase breakdown (proxy, middleware, render).
|
|
@@ -9,21 +9,30 @@
|
|
|
9
9
|
* that. Runtime-tier entries (`ttl`/`tags`) keep using the cache-handler
|
|
10
10
|
* overlay; in dev their keys carry this store's namespace (`overlayKey`).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* Every dev-server watcher event clears the store. The dev-server plugin
|
|
13
|
+
* sends `PREBUILT_DEV_CLEAR_EVENT` to the RSC environment and the RSC entry
|
|
14
|
+
* calls `clearDevPrebuiltStore()` (plugins/dev-store-clear.ts, TIM-1599).
|
|
15
|
+
* A save of a file the RSC module graph knows is scoped: the event names
|
|
16
|
+
* the components declared in the saved module and its transitive
|
|
17
|
+
* importers, which are the only call sites whose code could have changed.
|
|
18
|
+
* Any other event (a file read with `fs`, an add or a delete) names none,
|
|
19
|
+
* and clears everything — the module graph never says who reads a file
|
|
20
|
+
* with `fs`. A clear
|
|
21
|
+
* does three things:
|
|
18
22
|
*
|
|
19
|
-
* 1. drops every seed
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* 1. drops the seeds of the named components and every ISR seed (every
|
|
24
|
+
* seed, unscoped);
|
|
25
|
+
* 2. bumps the generation, which namespaces dev overlay keys and
|
|
26
|
+
* `cache.data` keys, so EVERY runtime-tier and data entry stored
|
|
27
|
+
* before the save becomes unreachable, scoped or not. Those tiers are
|
|
28
|
+
* cheap to refill, and a data function's ID comes from its call site,
|
|
29
|
+
* so a scoped answer for them would need a dependency walk of its own;
|
|
30
|
+
* 3. records an invalidation of the named components (of everything,
|
|
31
|
+
* unscoped), so a capture of one already in flight — which may have
|
|
32
|
+
* loaded the pre-save code — is not stored, and a request arriving
|
|
33
|
+
* after the save does not join that flight (the TIM-1028 guard every
|
|
34
|
+
* capture path already runs). Captures of the other components are
|
|
35
|
+
* untouched.
|
|
27
36
|
*
|
|
28
37
|
* Inactive outside dev: production never enables it. Dev enables it only
|
|
29
38
|
* when HMR is on — with `server.hmr: false` Vite delivers no watcher events
|
|
@@ -37,6 +46,14 @@ import { recordInvalidation, recordInvalidationOfAll } from '../../cache/invalid
|
|
|
37
46
|
/** Custom HMR event the dev-server plugin sends to the RSC environment. */
|
|
38
47
|
export const PREBUILT_DEV_CLEAR_EVENT = 'timber:prebuilt-dev-clear';
|
|
39
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The `PREBUILT_DEV_CLEAR_EVENT` payload: the components whose seeds to
|
|
51
|
+
* drop. Absent means every component.
|
|
52
|
+
*/
|
|
53
|
+
export interface DevStoreClear {
|
|
54
|
+
componentIds?: string[];
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
/** One captured prerender-tier entry — the dev counterpart of a `.flight` seed. */
|
|
41
58
|
export interface DevSeed {
|
|
42
59
|
bytes: Uint8Array;
|
|
@@ -44,6 +61,11 @@ export interface DevSeed {
|
|
|
44
61
|
tags: string[];
|
|
45
62
|
/** Capture time; stands in for the manifest's buildTimestamp. */
|
|
46
63
|
capturedAt: number;
|
|
64
|
+
/**
|
|
65
|
+
* The component also has a runtime lifetime (`ttl`/`tags`, ISR): its
|
|
66
|
+
* newer renders live in the overlay, which every clear moves on from.
|
|
67
|
+
*/
|
|
68
|
+
isr: boolean;
|
|
47
69
|
}
|
|
48
70
|
|
|
49
71
|
/**
|
|
@@ -59,7 +81,10 @@ export type DevPrebuiltStoreMode = 'off' | 'active' | 'bypass';
|
|
|
59
81
|
|
|
60
82
|
let mode: DevPrebuiltStoreMode = 'off';
|
|
61
83
|
let generation = 0;
|
|
62
|
-
|
|
84
|
+
/** Components already announced by the one-time dev log. */
|
|
85
|
+
const loggedIds = new Set<string>();
|
|
86
|
+
/** Component ID → cache key → seed. */
|
|
87
|
+
const seeds = new Map<string, Map<string, DevSeed>>();
|
|
63
88
|
|
|
64
89
|
/**
|
|
65
90
|
* Distinguishes this process's overlay keys from a previous dev session's,
|
|
@@ -71,12 +96,15 @@ const seeds = new Map<string, DevSeed>();
|
|
|
71
96
|
*/
|
|
72
97
|
let processToken: string | null = null;
|
|
73
98
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Set by the RSC entry in dev (and by tests). A change of mode starts the
|
|
101
|
+
* store empty. Setting the same mode again keeps it: the RSC entry
|
|
102
|
+
* self-accepts, so it re-runs whenever anything it imports changes (with
|
|
103
|
+
* Tailwind, every source save reaches it through the CSS), and the save
|
|
104
|
+
* has already cleared what it could have changed.
|
|
105
|
+
*/
|
|
79
106
|
export function setDevPrebuiltStoreMode(next: DevPrebuiltStoreMode): void {
|
|
107
|
+
if (next === mode) return;
|
|
80
108
|
mode = next;
|
|
81
109
|
seeds.clear();
|
|
82
110
|
}
|
|
@@ -116,37 +144,86 @@ export function devDataCacheKey(key: string): string {
|
|
|
116
144
|
}
|
|
117
145
|
|
|
118
146
|
export function getDevSeed(componentId: string, cacheKey: string): DevSeed | undefined {
|
|
119
|
-
return seeds.get(
|
|
147
|
+
return seeds.get(componentId)?.get(cacheKey);
|
|
120
148
|
}
|
|
121
149
|
|
|
122
150
|
/**
|
|
123
|
-
* Store a captured seed
|
|
124
|
-
* tag invalidation) happened while it
|
|
151
|
+
* Store a captured seed, announcing the component's first one. The caller
|
|
152
|
+
* has already checked that no clear (or tag invalidation) happened while it
|
|
153
|
+
* was capturing.
|
|
125
154
|
*/
|
|
126
155
|
export function setDevSeed(componentId: string, cacheKey: string, seed: DevSeed): void {
|
|
127
|
-
seeds.
|
|
156
|
+
let entries = seeds.get(componentId);
|
|
157
|
+
if (!entries) seeds.set(componentId, (entries = new Map()));
|
|
158
|
+
entries.set(cacheKey, seed);
|
|
159
|
+
if (!loggedIds.has(componentId)) {
|
|
160
|
+
loggedIds.add(componentId);
|
|
161
|
+
console.log(
|
|
162
|
+
`[timber] cache.component "${componentId}": prerendered in dev — served from memory until ` +
|
|
163
|
+
`a file it depends on changes. A hard reload (Cache-Control: no-cache) renders it again.`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
128
166
|
}
|
|
129
167
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
168
|
+
/**
|
|
169
|
+
* An invalidation-epoch tag for one component (it never reaches a cache
|
|
170
|
+
* handler; the NUL keeps it apart from user tags), recorded when a scoped
|
|
171
|
+
* clear drops the component. Dev captures add it
|
|
172
|
+
* to their invalidation checks, so a scoped clear reaches a capture of the
|
|
173
|
+
* component that is in flight, including its first, which has no seed yet.
|
|
174
|
+
*/
|
|
175
|
+
export function devComponentTag(componentId: string): string {
|
|
176
|
+
return `\u0000timber-dev-component:${componentId}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A source change: drop the seeds of `componentIds`, or of every component
|
|
181
|
+
* when absent. Every clear bumps the generation (see the header).
|
|
182
|
+
*/
|
|
183
|
+
export function clearDevPrebuiltStore(componentIds?: Iterable<string>): void {
|
|
133
184
|
generation++;
|
|
134
|
-
|
|
185
|
+
if (componentIds === undefined) {
|
|
186
|
+
seeds.clear();
|
|
187
|
+
recordInvalidationOfAll();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
for (const id of componentIds) {
|
|
191
|
+
recordInvalidation({ tag: devComponentTag(id) });
|
|
192
|
+
seeds.delete(id);
|
|
193
|
+
}
|
|
194
|
+
// An ISR seed is the base its overlay entries refresh. Kept while they
|
|
195
|
+
// become unreachable, it would serve a render older than the last one.
|
|
196
|
+
for (const entries of seeds.values()) {
|
|
197
|
+
for (const [cacheKey, seed] of entries) {
|
|
198
|
+
if (seed.isr) entries.delete(cacheKey);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The invalidation-epoch key dev captures of one entry check. Unlike the
|
|
205
|
+
* overlay key it carries no generation, like the seed it guards: a capture
|
|
206
|
+
* that a scoped clear kept in flight started under an older generation,
|
|
207
|
+
* and must still see a hard reload that comes after the clear.
|
|
208
|
+
*/
|
|
209
|
+
export function devEntryKey(componentId: string, cacheKey: string): string {
|
|
210
|
+
return `\u0000timber-dev-entry:${componentId}:${cacheKey}`;
|
|
135
211
|
}
|
|
136
212
|
|
|
137
213
|
/**
|
|
138
214
|
* A hard reload: discard one entry — its seed and its overlay record — so
|
|
139
|
-
* the request renders it again. Recorded as an invalidation of its
|
|
140
|
-
* first, so a capture of it already in flight (which may have read the
|
|
141
|
-
* external data) neither stores nor is joined by this request.
|
|
215
|
+
* the request renders it again. Recorded as an invalidation of both its
|
|
216
|
+
* keys first, so a capture of it already in flight (which may have read the
|
|
217
|
+
* old external data) neither stores nor is joined by this request.
|
|
142
218
|
*/
|
|
143
219
|
export async function discardDevEntry(
|
|
144
220
|
componentId: string,
|
|
145
221
|
cacheKey: string,
|
|
146
222
|
overlayKey: string
|
|
147
223
|
): Promise<void> {
|
|
224
|
+
recordInvalidation({ key: devEntryKey(componentId, cacheKey) });
|
|
148
225
|
recordInvalidation({ key: overlayKey });
|
|
149
|
-
seeds.delete(
|
|
226
|
+
seeds.get(componentId)?.delete(cacheKey);
|
|
150
227
|
await getCacheHandler().invalidate({ key: overlayKey });
|
|
151
228
|
}
|
|
152
229
|
|
|
@@ -156,8 +233,10 @@ export async function discardDevEntry(
|
|
|
156
233
|
* mechanics) — the next request misses and captures again.
|
|
157
234
|
*/
|
|
158
235
|
export function invalidateDevSeedsByTag(tag: string): void {
|
|
159
|
-
for (const
|
|
160
|
-
|
|
236
|
+
for (const entries of seeds.values()) {
|
|
237
|
+
for (const [cacheKey, seed] of entries) {
|
|
238
|
+
if (seed.tags.includes(tag)) entries.delete(cacheKey);
|
|
239
|
+
}
|
|
161
240
|
}
|
|
162
241
|
}
|
|
163
242
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { getCacheHandler, isCacheHandlerConfigured } from '../../cache/handler-store.ts';
|
|
17
17
|
import { MemoryCacheHandler } from '../../cache/index.ts';
|
|
18
18
|
import { guardedRead } from '../../cache/guarded-read.ts';
|
|
19
|
+
import { wasInvalidatedSince } from '../../cache/invalidation-epoch.ts';
|
|
19
20
|
import { getDeploymentId } from '../version-skew.ts';
|
|
20
21
|
import { devOverlayNamespace } from './dev-store.ts';
|
|
21
22
|
import { buildTagIndex, type SeedKeyInfo } from './manifest-tag-index.ts';
|
|
@@ -74,6 +75,23 @@ export function overlayKey(componentId: string, cacheKey: string): string {
|
|
|
74
75
|
return `timber:c:${deploymentId}:${componentId}:${cacheKey}`;
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Whether a re-render that started at `startEpoch` may store its capture
|
|
80
|
+
* under `oKey`: nothing invalidated the key or its tags meanwhile
|
|
81
|
+
* (TIM-1028), and the overlay key has not moved on. In dev a save moves it
|
|
82
|
+
* to a new namespace, and the bytes may come from the pre-save code: stored,
|
|
83
|
+
* they would answer every request after the save.
|
|
84
|
+
*/
|
|
85
|
+
export function mayStoreRerender(
|
|
86
|
+
startEpoch: number,
|
|
87
|
+
componentId: string,
|
|
88
|
+
cacheKey: string,
|
|
89
|
+
oKey: string,
|
|
90
|
+
tags: string[]
|
|
91
|
+
): boolean {
|
|
92
|
+
return !wasInvalidatedSince(startEpoch, oKey, tags) && overlayKey(componentId, cacheKey) === oKey;
|
|
93
|
+
}
|
|
94
|
+
|
|
77
95
|
// ─── Overlay read ────────────────────────────────────────────────────────
|
|
78
96
|
|
|
79
97
|
export interface OverlayLookupResult {
|