@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.224
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-B7o4As0l.js} +383 -55
- package/dist/_chunks/dev-server-B7o4As0l.js.map +1 -0
- package/dist/_chunks/dev-server-hZzmbMvK.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 +40 -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.d.ts.map +1 -1
- package/dist/index.js +698 -237
- 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/optimize-package-imports-defaults.d.ts +13 -0
- package/dist/plugins/optimize-package-imports-defaults.d.ts.map +1 -0
- package/dist/plugins/optimize-package-imports.d.ts +113 -0
- package/dist/plugins/optimize-package-imports.d.ts.map +1 -0
- 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 +42 -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 +40 -5
- package/src/config-validation.ts +37 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/index.ts +2 -0
- 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/optimize-package-imports-defaults.ts +88 -0
- package/src/plugins/optimize-package-imports.ts +439 -0
- 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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="@vitejs/plugin-rsc/types" />
|
|
3
|
+
// Declares the server-reference virtual for projects that typecheck this
|
|
4
|
+
// file without the package tsconfig (the website).
|
|
5
|
+
/// <reference path="./vendor-types.d.ts" />
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Load a server action by reference ID, telling a reference that does not
|
|
9
|
+
* exist apart from a module that fails to load (TIM-1601).
|
|
10
|
+
*
|
|
11
|
+
* plugin-rsc's `loadServerAction` rejects the same way for both: an unknown
|
|
12
|
+
* module ID throws from its reference lookup, and a real `'use server'`
|
|
13
|
+
* module that fails to import throws from the import. The first is a client
|
|
14
|
+
* error, the second a server fault, and the error message is the only thing
|
|
15
|
+
* that differs. So the lookup is asked first, through the same table
|
|
16
|
+
* plugin-rsc's loader reads, and an unknown module resolves to `undefined`:
|
|
17
|
+
* what plugin-rsc already resolves for an unknown export of a known module.
|
|
18
|
+
* A rejection from the load itself is then a real failure.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { loadServerAction as loadServerReference } from '@vitejs/plugin-rsc/rsc';
|
|
22
|
+
import serverReferences from 'virtual:vite-rsc/server-references';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether plugin-rsc knows `moduleId` as a `'use server'` module.
|
|
26
|
+
*
|
|
27
|
+
* - Build: the keys of `virtual:vite-rsc/server-references`, the table
|
|
28
|
+
* plugin-rsc's build loader indexes. Own keys only: the table is a plain
|
|
29
|
+
* object, so `constructor` would otherwise be found on its prototype.
|
|
30
|
+
* - Dev: plugin-rsc's reference-validation virtual, which its dev loader
|
|
31
|
+
* imports before the module itself, and which fails for a module ID it has
|
|
32
|
+
* no server-reference metadata for (after transforming the file once, so a
|
|
33
|
+
* module no render has reached yet is still found). plugin-rsc swallows
|
|
34
|
+
* the transform's own error, so a module that fails to transform in the
|
|
35
|
+
* RSC environment (a syntax error, a non-async export) counts as unknown
|
|
36
|
+
* here too, and is answered with a 400 and a warning. When an RSC render
|
|
37
|
+
* imports the module, that render reports the error. When only a client
|
|
38
|
+
* component imports it, nothing does until the production build fails on
|
|
39
|
+
* it. Any other rejection of this import (the environment closing during a
|
|
40
|
+
* restart) is likewise read as unknown. These cases are dev-only: a build
|
|
41
|
+
* never contains a module that failed to transform.
|
|
42
|
+
*/
|
|
43
|
+
async function isServerReferenceModule(moduleId: string): Promise<boolean> {
|
|
44
|
+
if (import.meta.env.__vite_rsc_build__) {
|
|
45
|
+
return Object.hasOwn(serverReferences, moduleId);
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
// The ID plugin-rsc's dev loader imports (`toReferenceValidationVirtual`
|
|
49
|
+
// in its plugins/shared.ts), which it does not export.
|
|
50
|
+
await import(
|
|
51
|
+
/* @vite-ignore */
|
|
52
|
+
'/@id/__x00__virtual:vite-rsc/reference-validation?type=server&id=' +
|
|
53
|
+
encodeURIComponent(moduleId) +
|
|
54
|
+
'&lang.js'
|
|
55
|
+
);
|
|
56
|
+
return true;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The export `id` (`<module>#<export>`) names, or `undefined` when the module
|
|
64
|
+
* or the export does not exist. Rejects only when a known module fails to
|
|
65
|
+
* load. The value is not checked: the caller decides whether it is a server
|
|
66
|
+
* function.
|
|
67
|
+
*/
|
|
68
|
+
export async function loadServerAction(id: string): Promise<unknown> {
|
|
69
|
+
// Split at `#` as plugin-rsc's `loadServerAction` does.
|
|
70
|
+
const [moduleId] = id.split('#');
|
|
71
|
+
if (!(await isServerReferenceModule(moduleId))) return undefined;
|
|
72
|
+
return loadServerReference(id);
|
|
73
|
+
}
|
|
@@ -5,6 +5,15 @@ declare module 'virtual:vite-rsc/encryption-key' {
|
|
|
5
5
|
export default encryptionKey;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
// plugin-rsc's server-reference table (its `vite-rsc/server-references`
|
|
9
|
+
// virtual): reference key → module loader in a build, read by
|
|
10
|
+
// server-references.ts. In dev the virtual exports nothing, so this is
|
|
11
|
+
// undefined there and is read only behind `__vite_rsc_build__`.
|
|
12
|
+
declare module 'virtual:vite-rsc/server-references' {
|
|
13
|
+
const serverReferences: Record<string, () => Promise<Record<string, unknown>>>;
|
|
14
|
+
export default serverReferences;
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
// src renders through plugin-rsc's wrappers (rsc-runtime/rsc.ts); tests stand
|
|
9
18
|
// in the vendored servers for them, with an empty client manifest.
|
|
10
19
|
declare module '@vitejs/plugin-rsc/vendor/react-server-dom/server.node' {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { DenySignal, RedirectSignal } from './primitives.ts';
|
|
17
17
|
import { isDenySignal, isRedirectSignal } from './signal-identity.ts';
|
|
18
|
-
import {
|
|
18
|
+
import { runTracedAccess } from './traced-access.ts';
|
|
19
19
|
import { isDebug } from './debug.ts';
|
|
20
20
|
import type { DenyPageEntry } from './deny-boundary.ts';
|
|
21
21
|
import { handleCaughtDeny, setFirstDeniedSegmentIndex } from './deny-boundary.ts';
|
|
@@ -79,6 +79,15 @@ export interface AccessGateProps {
|
|
|
79
79
|
* return rscErrorEnvelope for a client hard-navigate.
|
|
80
80
|
*/
|
|
81
81
|
skippedSegment?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* When true, this gate guards a segment of the URL's own route that is not
|
|
84
|
+
* in the rendered tree — an intercepted navigation renders one for each
|
|
85
|
+
* (TIM-1607). On deny it marks the signal `_leaveSpa` and rethrows: no
|
|
86
|
+
* deny page of that segment can render here, so the client leaves the SPA
|
|
87
|
+
* and the document request answers. Never set with `denyPages` or
|
|
88
|
+
* `segmentIndex`, which describe positions in the rendered chain.
|
|
89
|
+
*/
|
|
90
|
+
outsideTree?: boolean;
|
|
82
91
|
children: ReactNode;
|
|
83
92
|
}
|
|
84
93
|
|
|
@@ -128,10 +137,21 @@ export interface SlotAccessGateProps {
|
|
|
128
137
|
* in-tree — the client's cached layout chrome would wrap them incorrectly.
|
|
129
138
|
* Instead, the deny is recorded in ALS and rethrown so the response path
|
|
130
139
|
* can return rscErrorEnvelope for a client hard-navigate.
|
|
140
|
+
*
|
|
141
|
+
* For a segment outside the rendered tree (outsideTree=true), see
|
|
142
|
+
* `DenySignal._leaveSpa`.
|
|
131
143
|
*/
|
|
132
144
|
export function AccessGate(props: AccessGateProps): Promise<ReactNode> {
|
|
133
|
-
const {
|
|
134
|
-
|
|
145
|
+
const {
|
|
146
|
+
accessFn,
|
|
147
|
+
segmentName,
|
|
148
|
+
segmentKey,
|
|
149
|
+
segmentIndex,
|
|
150
|
+
denyPages,
|
|
151
|
+
skippedSegment,
|
|
152
|
+
outsideTree,
|
|
153
|
+
children,
|
|
154
|
+
} = props;
|
|
135
155
|
|
|
136
156
|
return accessGateFallback(
|
|
137
157
|
accessFn,
|
|
@@ -140,6 +160,7 @@ export function AccessGate(props: AccessGateProps): Promise<ReactNode> {
|
|
|
140
160
|
segmentIndex,
|
|
141
161
|
skippedSegment ? undefined : denyPages,
|
|
142
162
|
skippedSegment,
|
|
163
|
+
outsideTree,
|
|
143
164
|
children
|
|
144
165
|
);
|
|
145
166
|
}
|
|
@@ -155,32 +176,23 @@ async function accessGateFallback(
|
|
|
155
176
|
segmentIndex: AccessGateProps['segmentIndex'],
|
|
156
177
|
denyPages: DenyPageEntry[] | undefined,
|
|
157
178
|
skippedSegment: boolean | undefined,
|
|
179
|
+
outsideTree: boolean | undefined,
|
|
158
180
|
children: ReactNode
|
|
159
181
|
): Promise<ReactNode> {
|
|
160
182
|
try {
|
|
161
|
-
await
|
|
162
|
-
try {
|
|
163
|
-
await accessFn();
|
|
164
|
-
await setSpanAttribute('timber.result', 'pass');
|
|
165
|
-
} catch (error: unknown) {
|
|
166
|
-
if (isDenySignal(error)) {
|
|
167
|
-
await setSpanAttribute('timber.result', 'deny');
|
|
168
|
-
await setSpanAttribute('timber.deny_status', error.status);
|
|
169
|
-
if (error.sourceFile) {
|
|
170
|
-
await setSpanAttribute('timber.deny_file', error.sourceFile);
|
|
171
|
-
}
|
|
172
|
-
} else if (isRedirectSignal(error)) {
|
|
173
|
-
await setSpanAttribute('timber.result', 'redirect');
|
|
174
|
-
}
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
183
|
+
await runTracedAccess(accessFn, segmentName);
|
|
178
184
|
} catch (error: unknown) {
|
|
179
185
|
if (isDenySignal(error)) {
|
|
180
186
|
if (segmentIndex !== undefined) {
|
|
181
187
|
setFirstDeniedSegmentIndex(segmentIndex);
|
|
182
188
|
}
|
|
183
189
|
|
|
190
|
+
if (outsideTree) {
|
|
191
|
+
error._hardNavigate = true;
|
|
192
|
+
error._leaveSpa = true;
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
|
|
184
196
|
if (skippedSegment) {
|
|
185
197
|
error._hardNavigate = true;
|
|
186
198
|
throw error;
|
|
@@ -37,7 +37,7 @@ import type { ReactFormState } from 'react-dom/client';
|
|
|
37
37
|
import { encodeErrorDigest } from '../shared/error-digest.ts';
|
|
38
38
|
import { clientErrorMessage } from './client-error-message.ts';
|
|
39
39
|
import { checkVersionSkew, applyReloadHeaders } from './version-skew.ts';
|
|
40
|
-
import { logActionError, swallow } from './logger.ts';
|
|
40
|
+
import { logActionError, logActionRejected, swallow } from './logger.ts';
|
|
41
41
|
import { fireOnRequestError } from './pipeline-helpers.ts';
|
|
42
42
|
import { withTimeout, RenderTimeoutError, DEFAULT_RENDER_TIMEOUT_MS } from './render-timeout.ts';
|
|
43
43
|
import { canonicalize } from './canonicalize.ts';
|
|
@@ -268,29 +268,29 @@ async function reportRevalidationErrors(req: Request, errors: readonly unknown[]
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
|
-
* Answer an action request
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
271
|
+
* Answer an action request the client got wrong with a bare 400, never a 200
|
|
272
|
+
* action-error payload: a fabricated action id must not look like an action
|
|
273
|
+
* that ran (tests/e2e/security.test.ts). The request is wrong in a way the
|
|
274
|
+
* handler can see for itself: the reference names no server function, or the
|
|
275
|
+
* body will not parse, decode, or decode to an argument list.
|
|
275
276
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* split (`decodeAction` decodes and loads in one call) and answers 400;
|
|
285
|
-
* see `handleFormAction`.
|
|
277
|
+
* Any client can send these, so they are logged at warn with the reason and
|
|
278
|
+
* no stack, and are not reported to `onRequestError`: an error tracker would
|
|
279
|
+
* otherwise record whatever a client makes up (TIM-1601). A known action
|
|
280
|
+
* module that fails to load is the server's fault, and `decodeRscActionCall`
|
|
281
|
+
* answers it with a 500 and reports it. Two loads cannot be split that way
|
|
282
|
+
* and land here: a server function passed as an argument, which
|
|
283
|
+
* `decodeReply` loads, and the no-JS action, which `decodeAction` loads.
|
|
284
|
+
* Their module's error is still the logged reason.
|
|
286
285
|
*/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
function rejectActionRequest(req: Request, reason: unknown): Response {
|
|
287
|
+
logActionRejected({
|
|
288
|
+
method: req.method,
|
|
289
|
+
path: new URL(req.url).pathname,
|
|
290
|
+
status: 400,
|
|
291
|
+
reason: reason instanceof Error ? reason.message : String(reason),
|
|
292
|
+
});
|
|
293
|
+
return new Response(null, { status: 400 });
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/**
|
|
@@ -340,8 +340,9 @@ function isServerReference(value: unknown): value is (...args: unknown[]) => Pro
|
|
|
340
340
|
/**
|
|
341
341
|
* Load the action by reference ID and decode its args from the request body
|
|
342
342
|
* (RSC wire format). Returns a Response for a request that fails before the
|
|
343
|
-
* action can run:
|
|
344
|
-
*
|
|
343
|
+
* action can run: a 400 for the client's mistakes (`rejectActionRequest`),
|
|
344
|
+
* a 500 for a known action module that fails to load, and the field limit's
|
|
345
|
+
* own status.
|
|
345
346
|
*/
|
|
346
347
|
async function decodeRscActionCall(
|
|
347
348
|
req: Request,
|
|
@@ -352,11 +353,15 @@ async function decodeRscActionCall(
|
|
|
352
353
|
try {
|
|
353
354
|
loaded = await loadServerAction(actionId);
|
|
354
355
|
} catch (error) {
|
|
355
|
-
|
|
356
|
+
// The module exists but failed to import or evaluate: a server fault.
|
|
357
|
+
// An unknown module does not get here; it loads as undefined (below).
|
|
358
|
+
await reportActionError(req, error);
|
|
359
|
+
return new Response(null, { status: 500 });
|
|
356
360
|
}
|
|
357
361
|
if (!isServerReference(loaded)) {
|
|
358
|
-
//
|
|
359
|
-
|
|
362
|
+
// No such module or export, or not a server function: a reference the
|
|
363
|
+
// client made up.
|
|
364
|
+
return rejectActionRequest(req, `Unknown server action "${actionId}"`);
|
|
360
365
|
}
|
|
361
366
|
const actionFn = loaded;
|
|
362
367
|
|
|
@@ -377,13 +382,13 @@ async function decodeRscActionCall(
|
|
|
377
382
|
decoded = await decodeReply(await req.text());
|
|
378
383
|
}
|
|
379
384
|
} catch (error) {
|
|
380
|
-
return rejectActionRequest(req, error
|
|
385
|
+
return rejectActionRequest(req, error);
|
|
381
386
|
}
|
|
382
387
|
// The client always encodes an argument list. Anything else would fail
|
|
383
388
|
// when `executeAction` spreads it, inside the action's own catch, and
|
|
384
389
|
// come back as a 200 INTERNAL_ERROR for what is the caller's mistake.
|
|
385
390
|
if (!Array.isArray(decoded)) {
|
|
386
|
-
return rejectActionRequest(req,
|
|
391
|
+
return rejectActionRequest(req, 'Server action body is not an argument list');
|
|
387
392
|
}
|
|
388
393
|
return { actionFn, args: decoded };
|
|
389
394
|
}
|
|
@@ -620,7 +625,7 @@ async function handleFormAction(
|
|
|
620
625
|
try {
|
|
621
626
|
formData = await req.clone().formData();
|
|
622
627
|
} catch (error) {
|
|
623
|
-
return rejectActionRequest(req, error
|
|
628
|
+
return rejectActionRequest(req, error);
|
|
624
629
|
}
|
|
625
630
|
|
|
626
631
|
// Enforce field count limit after parsing FormData.
|
|
@@ -641,10 +646,11 @@ async function handleFormAction(
|
|
|
641
646
|
// decodeAction both decodes the form's `$ACTION_REF_` metadata and loads
|
|
642
647
|
// the module, and React does not say which failed. On a no-JS POST that
|
|
643
648
|
// metadata is written by React into the form, so a failure is almost
|
|
644
|
-
// always a forged or truncated request: 400
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
|
|
649
|
+
// always a forged or truncated request: 400, logged at warn with the
|
|
650
|
+
// error as the reason. A module that genuinely fails to import also
|
|
651
|
+
// breaks the RSC render of a page that imports it, which reports it; an
|
|
652
|
+
// action module only a client component imports gets the warning alone.
|
|
653
|
+
return rejectActionRequest(req, error);
|
|
648
654
|
}
|
|
649
655
|
if (!actionFn) {
|
|
650
656
|
return null;
|
|
@@ -120,3 +120,30 @@ export function canonicalRequestPath(rawPathname: string, stripTrailingSlash = t
|
|
|
120
120
|
}
|
|
121
121
|
return pathname;
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Build a request's URL from its origin and its raw request target, or
|
|
126
|
+
* return null when the result is not a URL (the caller answers 400).
|
|
127
|
+
*
|
|
128
|
+
* An origin-form target (`/path`) is concatenated, not resolved against the
|
|
129
|
+
* origin: resolved as a relative reference, `//evil.com/` names another host,
|
|
130
|
+
* and the pipeline would see `/` instead of the path it must redirect to
|
|
131
|
+
* `/evil.com` (TIM-1571). Any other form is resolved against the origin:
|
|
132
|
+
* the asterisk-form `OPTIONS *` becomes `/*`, and an absolute-form target
|
|
133
|
+
* (`GET http://host/a`) keeps only its path and query. Its scheme and
|
|
134
|
+
* authority are the client's word, not the connection's: they would stand in
|
|
135
|
+
* for the Host that the dev server's allowedHosts check and CSRF read, and a
|
|
136
|
+
* non-http scheme (`foo://x/`) makes an opaque origin the pipeline cannot
|
|
137
|
+
* build URLs from, so that is null too.
|
|
138
|
+
*
|
|
139
|
+
* Shared by the dev server and the Nitro preview server (which ships this
|
|
140
|
+
* file as `_canonicalize.mjs`), so the two cannot disagree about which path a
|
|
141
|
+
* request target names. Production adapters build the URL in their own
|
|
142
|
+
* runtime (srvx for Nitro).
|
|
143
|
+
*/
|
|
144
|
+
export function requestTargetUrl(origin: string, target: string): URL | null {
|
|
145
|
+
if (target.startsWith('/')) return URL.parse(origin + target);
|
|
146
|
+
const resolved = URL.parse(target, origin);
|
|
147
|
+
if (resolved?.protocol !== 'http:' && resolved?.protocol !== 'https:') return null;
|
|
148
|
+
return URL.parse(origin + resolved.pathname + resolved.search);
|
|
149
|
+
}
|
|
@@ -185,7 +185,7 @@ export function getCookieJar(): RequestCookies {
|
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
|
|
188
|
-
delete(name: string, options?:
|
|
188
|
+
delete(name: string, options?: CookieDeleteOptions): void {
|
|
189
189
|
assertMutable(store, 'delete');
|
|
190
190
|
// Validate the name even though delete writes an empty value — a
|
|
191
191
|
// smuggled name (`;` or CR/LF) would corrupt the Set-Cookie header
|
|
@@ -208,7 +208,7 @@ export function getCookieJar(): RequestCookies {
|
|
|
208
208
|
expires: new Date(0),
|
|
209
209
|
};
|
|
210
210
|
// delete() is a jar entry point like set() — caller-supplied
|
|
211
|
-
//
|
|
211
|
+
// attributes are serialized verbatim into the Set-Cookie header,
|
|
212
212
|
// so they must pass the same attribute-injection guard. See
|
|
213
213
|
// design/29-cookies.md §"Cookie Attribute Validation" (TIM-1026).
|
|
214
214
|
assertValidCookieOptions(opts);
|
|
@@ -300,6 +300,14 @@ export interface CookieOptions {
|
|
|
300
300
|
partitioned?: boolean;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Options for deleting a cookie: every attribute but the lifetime, which
|
|
305
|
+
* delete() forces to the past. Pass the attributes the cookie was set with —
|
|
306
|
+
* a partitioned cookie is only removed by a deletion that is also
|
|
307
|
+
* `Partitioned`, since browsers keep it in a separate jar (TIM-1606).
|
|
308
|
+
*/
|
|
309
|
+
export type CookieDeleteOptions = Omit<CookieOptions, 'maxAge' | 'expires'>;
|
|
310
|
+
|
|
303
311
|
/**
|
|
304
312
|
* Cookie accessor returned by `getCookies()`.
|
|
305
313
|
*
|
|
@@ -340,7 +348,7 @@ export interface RequestCookies {
|
|
|
340
348
|
*/
|
|
341
349
|
setFromHeaders(headers: Headers): void;
|
|
342
350
|
/** Delete a cookie. Only available in mutable contexts. */
|
|
343
|
-
delete(name: string, options?:
|
|
351
|
+
delete(name: string, options?: CookieDeleteOptions): void;
|
|
344
352
|
/** Delete all cookies. Only available in mutable contexts. */
|
|
345
353
|
clear(): void;
|
|
346
354
|
/** Serialize cookies as a Cookie header string. */
|
|
@@ -21,6 +21,7 @@ import { NodeBodyResponse } from './node-body-response.ts';
|
|
|
21
21
|
import { DEFAULT_MAX_BUFFER_BYTES, teeBufferExceeded } from './stream-utils.ts';
|
|
22
22
|
import { onAbortUntil } from './abort-scope.ts';
|
|
23
23
|
import { RenderTimeoutError } from './render-timeout.ts';
|
|
24
|
+
import { releaseReason } from './render-utils.ts';
|
|
24
25
|
|
|
25
26
|
// `String.prototype.toWellFormed` ships in every Node timber supports
|
|
26
27
|
// (engines: >=22.18) but is ES2024, past the project's ES2022 lib; this file
|
|
@@ -110,8 +111,10 @@ export function pipeFlightToNode(
|
|
|
110
111
|
destroy(error, callback) {
|
|
111
112
|
scope.abort();
|
|
112
113
|
clearTimeout(timer);
|
|
113
|
-
// A no-op once Flight has finished (it ignores abort after close).
|
|
114
|
-
|
|
114
|
+
// A no-op once Flight has finished (it ignores abort after close). A
|
|
115
|
+
// release without a reason aborts with an AbortError, so the render's
|
|
116
|
+
// onError does not log the abort (releaseReason, TIM-1597).
|
|
117
|
+
flight.abort(releaseReason(error));
|
|
115
118
|
callback(error);
|
|
116
119
|
},
|
|
117
120
|
});
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import type { Readable } from 'node:stream';
|
|
25
25
|
import { nodeStreamsPlatform } from './node-streams-platform.ts';
|
|
26
|
+
import { releaseReason } from './render-utils.ts';
|
|
26
27
|
import {
|
|
27
28
|
concatBytes,
|
|
28
29
|
drainWithDeadline,
|
|
@@ -157,7 +158,7 @@ export function openFlightReader(source: FlightSource): FlightReader {
|
|
|
157
158
|
return {
|
|
158
159
|
read: () => reader.read(),
|
|
159
160
|
takeBuffered: () => [],
|
|
160
|
-
cancel: (reason) => void reader.cancel(reason).catch(() => {}),
|
|
161
|
+
cancel: (reason) => void reader.cancel(releaseReason(reason)).catch(() => {}),
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
164
|
const { destroyNodeFlight } = requireNodeFlight();
|
|
@@ -186,7 +187,7 @@ export function openFlightReader(source: FlightSource): FlightReader {
|
|
|
186
187
|
/** Release a source nothing will read, aborting the render behind it. */
|
|
187
188
|
export function cancelFlightSource(source: FlightSource, reason?: unknown): void {
|
|
188
189
|
if (source.kind === 'web') {
|
|
189
|
-
source.stream.cancel(reason).catch(() => {});
|
|
190
|
+
source.stream.cancel(releaseReason(reason)).catch(() => {});
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
193
|
requireNodeFlight().destroyNodeFlight(source.stream, reason);
|
|
@@ -281,7 +282,7 @@ export function peekFlight(source: FlightSource): FlightPeek {
|
|
|
281
282
|
else controller.enqueue(result.value);
|
|
282
283
|
},
|
|
283
284
|
cancel(reason) {
|
|
284
|
-
return reader.cancel(reason);
|
|
285
|
+
return reader.cancel(releaseReason(reason));
|
|
285
286
|
},
|
|
286
287
|
});
|
|
287
288
|
return { ready, source: { kind: 'web', stream } };
|
package/src/server/index.ts
CHANGED
|
@@ -18,7 +18,12 @@ export type { ReadonlyHeaders } from './request-context.ts';
|
|
|
18
18
|
// Cookie Context — ALS-backed getCookieJar() escape hatch
|
|
19
19
|
// Design doc: design/29-cookies.md
|
|
20
20
|
export { getCookieJar } from './cookie-context.ts';
|
|
21
|
-
export type {
|
|
21
|
+
export type {
|
|
22
|
+
RequestCookies,
|
|
23
|
+
CookieOptions,
|
|
24
|
+
CookieDeleteOptions,
|
|
25
|
+
SetCookieOptions,
|
|
26
|
+
} from './cookie-context.ts';
|
|
22
27
|
|
|
23
28
|
// Runtime primitives
|
|
24
29
|
export {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The URL's own access gates in an intercepted tree (TIM-1607).
|
|
3
|
+
*
|
|
4
|
+
* An intercepted navigation renders a different route than its URL names —
|
|
5
|
+
* the source route with the target in a slot, or the owner's chain through
|
|
6
|
+
* its intercepting child. The response is still for the URL, so the URL's
|
|
7
|
+
* whole `access.ts` chain gates it, in the one render, as one group of gates
|
|
8
|
+
* at the top of the tree:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* [Gate(/) → Gate(secret) → Gate(secret/[id])] → root layout → … → Gate(feed) → …
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The whole chain, shared segments included, for two reasons:
|
|
15
|
+
*
|
|
16
|
+
* - **Params.** Each gate must read the URL's params. A shared segment's
|
|
17
|
+
* in-tree gate reads the rendered route's, and in the modal shape those come
|
|
18
|
+
* from re-matching `interceptingPrefix`, a pattern — a shared `[org]` reads
|
|
19
|
+
* the literal `'[org]'`, not `'acme'`.
|
|
20
|
+
* - **Coverage.** Nothing renders outside the top of the tree. Placed any
|
|
21
|
+
* lower, the gates miss whatever an ancestor layout renders beside them —
|
|
22
|
+
* a modal slot is a prop of its owner's layout, and the rendered chain can
|
|
23
|
+
* continue past the owner through a route group the target shares
|
|
24
|
+
* (`app/@modal/(.)secret/[id]` over `app/(main)/page.tsx`).
|
|
25
|
+
*
|
|
26
|
+
* The shared segments' in-tree gates are dropped (`sharedCount`), so each
|
|
27
|
+
* access.ts still runs once, outer → inner: the URL's chain, then the gates
|
|
28
|
+
* only the rendered chain has.
|
|
29
|
+
*
|
|
30
|
+
* Each gate is marked `outsideTree`: the URL's deny pages, and the layouts
|
|
31
|
+
* they render in, are not this tree's, so a deny leaves the SPA for the URL's
|
|
32
|
+
* document instead of being placed here. See `DenySignal._leaveSpa`,
|
|
33
|
+
* design/07-routing.md §"Intercepting Routes".
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import type React from 'react';
|
|
37
|
+
import { AccessGate } from './access-gate.tsx';
|
|
38
|
+
import type { RouteMatch } from './pipeline.ts';
|
|
39
|
+
import { runWithRouteParams } from './pipeline-interception.ts';
|
|
40
|
+
import { loadModule } from './safe-load.ts';
|
|
41
|
+
|
|
42
|
+
export interface InterceptionGates {
|
|
43
|
+
/**
|
|
44
|
+
* How many segments, from the root, the rendered chain shares with the
|
|
45
|
+
* URL's route. Their access.ts runs in the group; the builder gives them no
|
|
46
|
+
* gate of their own.
|
|
47
|
+
*/
|
|
48
|
+
sharedCount: number;
|
|
49
|
+
/** Wrap the whole tree in the URL's gates, outermost first. */
|
|
50
|
+
wrap(
|
|
51
|
+
element: React.ReactElement,
|
|
52
|
+
h: (...args: unknown[]) => React.ReactElement
|
|
53
|
+
): React.ReactElement;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The gates an intercepted match needs, or null when it is not intercepted. */
|
|
57
|
+
export async function loadInterceptionGates(match: RouteMatch): Promise<InterceptionGates | null> {
|
|
58
|
+
const canonical = match.canonical;
|
|
59
|
+
if (!canonical) return null;
|
|
60
|
+
|
|
61
|
+
// Both chains are paths from the manifest root through one tree, so the
|
|
62
|
+
// segments they share are exactly a common prefix.
|
|
63
|
+
const rendered = match.segments;
|
|
64
|
+
let sharedCount = 0;
|
|
65
|
+
while (
|
|
66
|
+
sharedCount < rendered.length &&
|
|
67
|
+
sharedCount < canonical.segments.length &&
|
|
68
|
+
rendered[sharedCount] === canonical.segments[sharedCount]
|
|
69
|
+
) {
|
|
70
|
+
sharedCount++;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const gates: Array<{ segmentName: string; accessFn: () => unknown }> = [];
|
|
74
|
+
for (const segment of canonical.segments) {
|
|
75
|
+
if (!segment.access) continue;
|
|
76
|
+
const mod = await loadModule(segment.access);
|
|
77
|
+
const accessFn = mod.default as (() => unknown) | undefined;
|
|
78
|
+
if (!accessFn) continue;
|
|
79
|
+
gates.push({
|
|
80
|
+
segmentName: segment.segmentName,
|
|
81
|
+
accessFn: () => runWithRouteParams(canonical, accessFn),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
sharedCount,
|
|
87
|
+
wrap(element, h) {
|
|
88
|
+
for (let i = gates.length - 1; i >= 0; i--) {
|
|
89
|
+
element = h(AccessGate, { ...gates[i], outsideTree: true, children: element });
|
|
90
|
+
}
|
|
91
|
+
return element;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
package/src/server/logger.ts
CHANGED
|
@@ -178,6 +178,21 @@ export function logActionError(data: {
|
|
|
178
178
|
_logger.error('unhandled server action error', withTraceContext(data));
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Log a server action request rejected as the client's mistake before the
|
|
183
|
+
* action ran: a reference that does not exist, a body that will not decode.
|
|
184
|
+
* Level: warn, with the reason but no stack — any client can send these, so
|
|
185
|
+
* they must not read as server faults (TIM-1601).
|
|
186
|
+
*/
|
|
187
|
+
export function logActionRejected(data: {
|
|
188
|
+
method: string;
|
|
189
|
+
path: string;
|
|
190
|
+
status: number;
|
|
191
|
+
reason: string;
|
|
192
|
+
}): void {
|
|
193
|
+
_logger.warn('server action request rejected', withTraceContext(data));
|
|
194
|
+
}
|
|
195
|
+
|
|
181
196
|
/** Log unhandled error in route handler. Level: error. */
|
|
182
197
|
export function logRouteError(data: { method: string; path: string; error: unknown }): void {
|
|
183
198
|
if (isControlFlowSignal(data.error)) return;
|
|
@@ -199,6 +214,14 @@ export function logWaitUntilRejected(data: { error: unknown }): void {
|
|
|
199
214
|
_logger.warn('waitUntil() promise rejected', withTraceContext(data));
|
|
200
215
|
}
|
|
201
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Log a cached value computed from request context its key leaves out
|
|
219
|
+
* (design/45 §Enforcement). Level: error.
|
|
220
|
+
*/
|
|
221
|
+
export function logKeyDisciplineViolation(event: string, data: Record<string, unknown>): void {
|
|
222
|
+
_logger.error(event, withTraceContext(data));
|
|
223
|
+
}
|
|
224
|
+
|
|
202
225
|
/** Log staleWhileRevalidate refetch failure. Level: warn. */
|
|
203
226
|
export function logSwrRefetchFailed(data: { cacheKey: string; error: unknown }): void {
|
|
204
227
|
_logger.warn('staleWhileRevalidate refetch failed', withTraceContext(data));
|
|
@@ -28,6 +28,28 @@ export class ParamCoercionError extends Error {
|
|
|
28
28
|
this.name = 'ParamCoercionError';
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The dev diagnostic for a match whose params a codec rejected; the caller
|
|
34
|
+
* answers 404. Shared by page/route.ts matches and metadata routes, so a
|
|
35
|
+
* silent coercion 404 explains itself the same way on either.
|
|
36
|
+
*/
|
|
37
|
+
export function warnParamCoercionFailure(
|
|
38
|
+
method: string,
|
|
39
|
+
pathname: string,
|
|
40
|
+
segments: readonly { segmentName: string }[],
|
|
41
|
+
error: ParamCoercionError
|
|
42
|
+
): void {
|
|
43
|
+
if (!isDebug()) return;
|
|
44
|
+
const segmentChain = segments.map((s) => s.segmentName || '/').join(' → ');
|
|
45
|
+
console.warn(
|
|
46
|
+
`[timber] Param coercion failed for ${method} ${pathname} — responding with 404\n` +
|
|
47
|
+
` Matched segments: ${segmentChain}\n` +
|
|
48
|
+
` Error: ${error.message}\n` +
|
|
49
|
+
` This usually means a codec in app/schema.ts rejected the URL value.\n` +
|
|
50
|
+
` Check the codec for the bracket key of the segment named above.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
31
53
|
import { isDebug } from './debug.ts';
|
|
32
54
|
|
|
33
55
|
// ---------------------------------------------------------------------------
|